Sign in

Search issue titles and bodies, change requests and comments. Private repositories you cannot read are not included.

vole
Site
Clone

Read only, no credentials:

https://rodent.software/vole.git

Write over SSH with a registered key:

git clone ssh://git@rodent.software/vole.git

Self-hosted forge that lives in your Git repo.

Code

527 commit(s) on main

Put job execution behind an interface Keenan Nemetz · 2h ago de3eec16
1# 3D model preview
2
3`model-viewer.js` is Vole's viewer: it draws a blob into a canvas with
4drag-to-turn (a turntable: sideways spins the model about its own up axis, up
5and down tips it over the top, and the two mix without rolling it), wheel,
6pinch or button zoom, a six-face orientation cube for snap views, a wireframe
7toggle, and a Sync button that turns and zooms the two viewers of a diff
8together.
9`app.js` imports it only when a page contains a `[data-model]` element, so no
10other page downloads it.
11
12`three.bundle.js` is a generated ES module containing three.js and the loaders
13the viewer uses. It is committed so an instance is still one binary and there is
14no npm step in the build:
15
16- three.js r187, `three.module.js` and the `OrbitControls`, `STLLoader`,
17 `OBJLoader`, `GLTFLoader` and `ThreeMFLoader` example modules.
18 MIT License. See `three.LICENSE`.
19- fflate 0.8.3, which the 3MF loader uses to unzip the package.
20 MIT License. See `fflate.LICENSE`.
21
22Regenerate the bundle after bumping `THREE_VERSION` in the script:
23
24```sh
25python3 scripts/vendor-three.py # write three.bundle.js and three.LICENSE
26python3 scripts/vendor-three.py --check # compare, exit 1 if they differ
27```
28
29Node and `npx` are needed to regenerate the bundle, because esbuild resolves the
30loaders' bare `three` imports and their own dependencies into one module. Running
31Vole does not need either. Bump `ESBUILD_VERSION` with `THREE_VERSION` when the
32pinned esbuild no longer builds the release.
33
34## Formats
35
36| Extension | Loader | Notes |
37|---|---|---|
38| `.stl` | `STLLoader` | Binary and ASCII |
39| `.obj` | `OBJLoader` | Geometry only; a companion `.mtl` is not loaded |
40| `.gltf` | `GLTFLoader` | Relative buffers and textures resolve through the raw route |
41| `.glb` | `GLTFLoader` | Same, self-contained |
42| `.3mf` | `ThreeMFLoader` | Unzipped in the browser by fflate |
43
44Compressed glTF assets are not supported: Draco, KTX2 and meshopt need their own
45decoders, and those would add a WASM eval or more vendored code. A model that
46uses them reports that it could not be loaded and keeps its download link.
47
48The viewer creates blob URLs to decode textures embedded in a glTF or 3MF file.
49That is why the page's Content-Security-Policy allows `blob:` for images and
50connections; see `server/web/auth.go`.
51