# DFG 3D Viewer — Drupal Module

Drupal/WissKI integration for the [DFG 3D Viewer JavaScript library](https://gitlab.nasarek.dev/rnsrk/dfg_3dviewer_js_library).

**This repository contains PHP/YAML only** — no bundled JavaScript, no npm build step on the server.

## Requirements

1. **JS library** at `web/libraries/dfg-3dviewer/` — download from [releases](https://gitlab.nasarek.dev/rnsrk/dfg_3dviewer_js_library/-/releases), or build from `js_library_dfg_3dviewer` with `npm run build:library` / `npm run pack:library`

2. **This module** at `web/modules/custom/dfg_3dviewer/` — clone this repository, or pack locally with `node scripts/pack-drupal-module.js`

## Install

```bash
curl -fL "https://gitlab.nasarek.dev/rnsrk/dfg_3dviewer_js_library/-/releases/permalink/latest/downloads/dfg-3dviewer-library.zip" -o /tmp/dfg-3dviewer-library.zip
mkdir -p web/libraries/dfg-3dviewer
unzip -o /tmp/dfg-3dviewer-library.zip -d web/libraries/dfg-3dviewer
rm /tmp/dfg-3dviewer-library.zip
# clone or unzip this module to web/modules/custom/dfg_3dviewer
drush en dfg_3dviewer -y
drush cr
```

Configure at `/admin/config/dfg_3dviewer`, or apply the bundled local development preset:

```bash
drush dfg-3dviewer:configure
```

Example with lightweight preset with all settings explicit (adjust config with your settings):

```bash
drush dfg-3dviewer:configure \
  --main-url=http://example.com/ \
  --container=DFG_3DViewer \
  --entitybundle=bd3d7baa74856d141bcff7b4193fa128 \
  --viewer-file-upload=fbf95bddee5160d515b982b3fd2e05f7 \
  --viewer-file-name=faa602a0be629324806aef22892cdbe5 \
  --lightweight=1 \
  --scale-container-x=1 \
  --scale-container-y=1.4 \
  --base-module-path=/libraries/dfg-3dviewer/assets \
  --entity-id-uri='/wisski/navigate/(.*)/view' \
  --view-entity-path=/wisski/navigate/ \
  --attribute-id=wisski_id
```

Override individual values with options, for example `--main-url=https://example.test/`. Settings are passed to the browser as `drupalSettings.dfg_3dviewer`.

## Package contents

| Path | Purpose |
|------|---------|
| `src/` | Controllers, form, field formatters, queue worker |
| `config/` | Default config and schema |
| `dfg_3dviewer.*.yml` | Routing, libraries, permissions |
| `dfg_3dviewer.module` | Hooks, conversion workflow |
| `scripts/` | Model conversion shell/Python scripts |

## Library attachment

`dfg_3dviewer.libraries.yml` loads:

- `/libraries/dfg-3dviewer/dfg_3dviewer.min.js`
- `/libraries/dfg-3dviewer/assets/css/viewer.css`

## Package zip (maintainers)

```bash
node scripts/pack-drupal-module.js
```

Produces `dfg_3dviewer-drupal.zip` (gitignored).
