forgejo-stlview/README.md
butterrobot 17a64d6a46 Initial import of the Forgejo STL viewer setup
Files are copied verbatim from the running deployment at git.nakama.town,
except footer.tmpl, which uses {{AppSubUrl}} rather than a hardcoded /assets
path (identical output when Forgejo is served at the root).

The two three.js example modules are patched to import the build by relative
path instead of the bare 'three' specifier, which browsers cannot resolve
without an import map.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-10 13:46:24 +00:00

35 lines
1.5 KiB
Markdown

# forgejo-stlview
Interactive 3D previews for `.stl` files in [Forgejo](https://forgejo.org/), with no patches to Forgejo itself.
Written up here: **[Adding STL 3D Previews to Forgejo](https://fmartingr.com/blog/2026/03/15/adding-stl-3d-previews-to-forgejo/)**
## Contents
```
custom/templates/custom/header.tmpl injects the .stl-page class + loading placeholder
custom/templates/custom/footer.tmpl loads the viewer as an ES module
custom/public/assets/stlview.js the viewer
custom/public/assets/three.js/ pinned three.js r160 (three modules only)
docker-compose.example.yml markup config + volume mounts
```
Mount `custom/templates` and `custom/public` into the container and set the
`markup.stl` environment variables — see `docker-compose.example.yml`.
## Notes
`three.js/examples/jsm/loaders/STLLoader.js` and
`three.js/examples/jsm/controls/TrackballControls.js` are **patched**. Stock r160
imports three via the bare specifier `'three'`, which a browser cannot resolve
without an import map; both files here point at `../../../build/three.module.min.js`
instead. That is the only change, and `build/three.module.min.js` is byte-identical
to the r160 release.
## Licensing
`stlview.js` is derived from [Codeberg's `stlview.js`](https://codeberg.org/Codeberg-Infrastructure/build-deploy-forgejo/src/branch/codeberg-8/etc/gitea/public/assets/stlview.js),
which is AGPL-3.0. `LICENSE` therefore applies to the viewer and templates.
Vendored three.js under `custom/public/assets/three.js/` is MIT — see
`custom/public/assets/three.js/LICENSE`.