Skip to content

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-model
get_pack threejs-public/scene-with-glb-model

The 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

  1. Copy code/ and put the model next to index.html (or pass ?model=path.glb).
  2. Compress big models first: npx gltf-transform optimize in.glb out.glb --compress draco --texture-compress ktx2 (decoders are already wired).
  3. Serve and open; the model is centred and the camera distance is set from its bounding box.
  4. 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.