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>
1.5 KiB
forgejo-stlview
Interactive 3D previews for .stl files in Forgejo, with no patches to Forgejo itself.
Written up here: 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,
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.