68 lines
2.2 KiB
Markdown
68 lines
2.2 KiB
Markdown
# DFG 3D Viewer — JavaScript Library
|
|
|
|
Three.js-based 3D viewer. Ships as a minified bundle for `web/libraries/dfg-3dviewer/` or standalone HTML embeds.
|
|
|
|
**Drupal integration** is provided by the separate [`dfg_3dviewer`](https://gitlab.nasarek.dev/rnsrk/dfg_3dviewer_drupal_module) module.
|
|
|
|
## Build and package
|
|
|
|
```bash
|
|
npm install
|
|
npm run build:library
|
|
npm run pack:library
|
|
```
|
|
|
|
Output:
|
|
|
|
- `dist/library/` — `dfg_3dviewer.min.js` and `assets/` (CSS, draco, IFC WASM, fonts)
|
|
- `dfg-3dviewer-library.zip` — extract to `web/libraries/dfg-3dviewer/` on Drupal (gitignored)
|
|
|
|
## Local development
|
|
|
|
```bash
|
|
cp viewer/viewer-settings-example.json viewer-settings.json
|
|
npm run dev:test
|
|
# http://localhost:1234
|
|
```
|
|
|
|
## Install on Drupal
|
|
|
|
1. Install the library to `web/libraries/dfg-3dviewer/` — either build locally (see above) and extract `dfg-3dviewer-library.zip`, or download a [release](https://gitlab.nasarek.dev/rnsrk/dfg_3dviewer_js_library/-/releases) prebuild.
|
|
|
|
Latest release:
|
|
|
|
```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
|
|
```
|
|
|
|
Pin a version (replace `0.0.1` with the tag you need):
|
|
|
|
```bash
|
|
curl -fL "https://gitlab.nasarek.dev/rnsrk/dfg_3dviewer_js_library/-/releases/0.0.1/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
|
|
```
|
|
|
|
Run from your Drupal project root (e.g. `/opt/drupal`).
|
|
|
|
2. Enable the `dfg_3dviewer` Drupal module and configure at `/admin/config/dfg_3dviewer`
|
|
|
|
## Standalone embed
|
|
|
|
```html
|
|
<div id="DFG_3DViewer" 3d="./examples/box.stl"></div>
|
|
<script type="module" src="./dfg_3dviewer.min.js"></script>
|
|
```
|
|
|
|
Or pass config in code: `await Viewer.MainInit({ ... })`.
|
|
|
|
## Repository layout
|
|
|
|
- `viewer/` — source
|
|
- `dist/` — build output (gitignored; run `npm run build:library`)
|
|
- `rollup.config.js` — production builds
|
|
- `tests/` — Playwright E2E
|