Skip to content

Packs / 3d-blender-animation-public

threejs-viewer

A no-build three.js GLB viewer (import map + CDN, GLTFLoader + DRACOLoader, orbit controls, auto-fit camera, animation playback) with a Playwright check: model loads, no console errors, no horizontal scroll at 390px.

Install

logicpacks pack use 3d-blender-animation-public/threejs-viewer
get_pack 3d-blender-animation-public/threejs-viewer

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: 1 in outcome/checks.yaml
  • Code: check_viewer.pymake_fixture_glb.pyviewer.html
  • Tools: python3, playwright-python, chromium, network (jsdelivr + gstatic CDNs)

Usage, last 8 weeks

New: no recorded use yet.

Purpose (from spec/SPEC.md)

A no-build three.js GLB viewer (import map + CDN, GLTFLoader + DRACOLoader, orbit controls, auto-fit camera, animation playback) with a Playwright check: model loads, no console errors, no horizontal scroll at 390px.

Goal

Show any GLB (Draco or not, animated or not) on a web page with sane defaults, verified headless.

Steps

  1. Copy code/viewer.html next to your model and open viewer.html?src=model.glb through any static server (python3 -m http.server).
  2. The page fits the camera to the model bounds, plays the first animation clip if present and caps devicePixelRatio at 2.
  3. Check it: python3 code/check_viewer.py builds a fixture GLB (stdlib), serves the folder, loads the page at 1440px and 390px, and fails on console errors, a missing model or horizontal scroll.
  4. For production, vendor three.js into the site (or pin the CDN version) and host models on the site's own storage.

Edge cases

  • Draco models need the decoder path (gstatic CDN here); without it the load fails with a decoder error.
  • Headless Chromium uses SwiftShader (CPU WebGL): fine for checks, slow for big scenes. On GPU boxes pass ANGLE flags (see gpu-render-homelab-vast).
  • file:// URLs block module imports and fetch; always serve over http.

Don'ts

  • Don't hotlink models from motionsites/home servers on a live site.
  • Don't load an unpinned three@latest in production; pin the version.
  • Don't render at full devicePixelRatio 3 on phones.