Packs / threejs-public
scene-with-glb-model
Load a GLB model (plain, Draco or KTX2-compressed) into a lit three.js scene with orbit controls, auto-framing and a fallback message on load errors
Install
logicpacks pack use threejs-public/scene-with-glb-modelget_pack threejs-public/scene-with-glb-modelThe second line is the MCP tool call for the LogicPacks connector (Claude Code, Codex, Claude.ai and others). The first run of a pack someone else wrote asks for your yes.
Keys it needs (names only)
None.
Playbooks included
- Spec:
spec/SPEC.md(goal, steps, edge cases, don’ts) - Routes:
static-local - Checks: 2 in
outcome/checks.yaml - Code:
boot.jsindex.htmlmain.jsmodel.glb - Tools: python3, playwright-python, chromium
Usage, last 8 weeks
New: no recorded use yet.
Purpose (from spec/SPEC.md)
Goal
A page that loads any .glb (via ?model= or the bundled sample), centres and frames it, lights it and lets the user orbit, with Draco and KTX2 decoders wired so compressed assets also load.
Steps
- Copy
code/and put the model next toindex.html(or pass?model=path.glb). - Compress big models first:
npx gltf-transform optimize in.glb out.glb --compress draco --texture-compress ktx2(decoders are already wired). - Serve and open; the model is centred and the camera distance is set from its bounding box.
- Run the check:
python3 ../tools/webgl_check.py code --js "window.__model && window.__model.meshes >= 1".
Edge cases
- Draco/KTX2 decoder paths point at the jsdelivr copy of the same three version; self-host them for offline use.
- Huge scenes: check
window.__stats()triangles; split or LOD above ~500k on phones. - Wrong scale from DCC tools: auto-framing hides it; check real units before physics.
Don'ts
- Don't mix three versions between the core and the addons/decoders.
- Don't ship uncompressed 4K PNG textures to phones.