# 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.

- **Space:** 3d-blender-animation-public (https://github.com/Tech-Realm/space-3d-blender-animation-public/tree/main/threejs-viewer)
- **Level:** L1 (as the registry reports it)
- **Keys it needs (names only):** none
- **Tools:** python3, playwright-python, chromium, network (jsdelivr + gstatic CDNs)
- **Routes:** static-local; checks: 1
- **Uses:** new (no recorded use yet)
- **Install:** `logicpacks pack use 3d-blender-animation-public/threejs-viewer` or MCP `get_pack 3d-blender-animation-public/threejs-viewer`
- **Files:** CHANGELOG.md, code/check_viewer.py, code/make_fixture_glb.py, code/viewer.html, outcome/EVIDENCE.md, outcome/checks.yaml, outcome/results.json, pack.yaml, spec/SPEC.md, spec/source.md

## Purpose (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.



---

Canonical URL: https://logicpacks.io/packs/3d-blender-animation-public/threejs-viewer

Developed by TechRealm (techrealm.online), the software team. Operated by Al Jash Trading (Establishment), Abu Dhabi, since 1994, the legal entity that hosts and is responsible for the service. Economic licence CN-1030597, Abu Dhabi Registration Authority. Address: Office 5, Bani Yas West 4, Bani Yas, Abu Dhabi, UAE. Website: https://aljashtrading.com. Contact: hello@logicpacks.io, security@logicpacks.io, WhatsApp +1 713 632 2262 (https://wa.me/17136322262).

Machine-readable index: [/llms.txt](/llms.txt). Plain facts: [/about.md](/about.md). Safety: [/safety.md](/safety.md).
