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.
|
3b2bcc30
Keenan Nemetz
13d ago
|
1 | # 3D model preview |
| 2 | ||
| 3 | `model-viewer.js` is Vole's viewer: it draws a blob into a canvas with | |
|
f865b269
Keenan Nemetz
9d ago
|
4 | drag-to-turn (a turntable: sideways spins the model about its own up axis, up |
| 5 | and down tips it over the top, and the two mix without rolling it), wheel, | |
| 6 | pinch or button zoom, a six-face orientation cube for snap views, a wireframe | |
|
7d989146
Keenan Nemetz
8d ago
|
7 | toggle, and a Sync button that turns and zooms the two viewers of a diff |
| 8 | together. | |
|
32eefb58
Keenan Nemetz
9d ago
|
9 | `app.js` imports it only when a page contains a `[data-model]` element, so no |
| 10 | other page downloads it. | |
|
3b2bcc30
Keenan Nemetz
13d ago
|
11 | |
| 12 | `three.bundle.js` is a generated ES module containing three.js and the loaders | |
| 13 | the viewer uses. It is committed so an instance is still one binary and there is | |
| 14 | no 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 | ||
| 22 | Regenerate the bundle after bumping `THREE_VERSION` in the script: | |
| 23 | ||
| 24 | ```sh | |
| 25 | python3 scripts/vendor-three.py # write three.bundle.js and three.LICENSE | |
| 26 | python3 scripts/vendor-three.py --check # compare, exit 1 if they differ | |
| 27 | ``` | |
| 28 | ||
| 29 | Node and `npx` are needed to regenerate the bundle, because esbuild resolves the | |
| 30 | loaders' bare `three` imports and their own dependencies into one module. Running | |
| 31 | Vole does not need either. Bump `ESBUILD_VERSION` with `THREE_VERSION` when the | |
| 32 | pinned 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 | ||
| 44 | Compressed glTF assets are not supported: Draco, KTX2 and meshopt need their own | |
| 45 | decoders, and those would add a WASM eval or more vendored code. A model that | |
| 46 | uses them reports that it could not be loaded and keeps its download link. | |
| 47 | ||
| 48 | The viewer creates blob URLs to decode textures embedded in a glTF or 3MF file. | |
| 49 | That is why the page's Content-Security-Policy allows `blob:` for images and | |
| 50 | connections; see `server/web/auth.go`. |