Skip to content

Packs / web-development-public

3d-website

Three.js scene fixed behind normal HTML content with a scroll-driven camera tour (one stop per section), pointer parallax, capped pixel ratio, pause when hidden, static frame under reduced motion and a CSS fallback without WebGL. No build step (import map + CDN).

Install

logicpacks pack use web-development-public/3d-website
get_pack web-development-public/3d-website

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: _shots/shot-1280-rm.png_shots/shot-1280.png_shots/shot-390-rm.png_shots/shot-390.pngindex.htmlscene.jsstyle.css
  • Tools: python3, playwright-python, chromium, network (jsdelivr CDN for three@0.170.0)

Usage, last 8 weeks

New: no recorded use yet.

Purpose (from spec/SPEC.md)

Goal

A marketing site where a real-time 3D object carries the story: as the visitor scrolls, the camera moves between stops that match each section. Text stays real HTML (SEO, accessibility), the page stays fast on phones, and nothing breaks without WebGL.

Steps

  1. Copy code/ (index.html, style.css, scene.js). Keep the import map; pin the three version (three@0.170.0). For production either keep the CDN or npm i three and bundle.
  2. Replace the knot with your model: GLTFLoader from three/addons/loaders/GLTFLoader.js (add "three/addons/": ".../examples/jsm/" to the import map). Compress with gltf-transform optimize in.glb out.glb --compress draco --texture-compress webp; keep it under ~2 MB.
  3. Give each content section a data-step and define one camera stop per step (pos, look, rotY). The scroll handler only sets targets; the render loop eases toward them with frame-rate independent damping.
  4. Phone framing: below 700 px push the camera back and lower the object so it sits behind or under the text.
  5. Performance guards: setPixelRatio(min(dpr, 1.75)), pause the loop on visibilitychange, render a single frame on scroll when the loop is stopped (reduced motion).
  6. Fallback: no WebGL or a lost context sets html[data-webgl="off"] and shows the CSS gradient layer.
  7. Run the outcome checks (needs network for the CDN).

Edge cases

  • iOS low-power mode throttles rAF to 30 fps: damping is time-based, so motion stays correct.
  • Huge GLB on mobile data: show the poster/fallback first and load the model after load or on interaction.
  • Text contrast over the object: soft text-shadow on phones, or a translucent plate.
  • WebGL context loss (tab in background for long): handled; consider re-init on webglcontextrestored.

Don'ts

  • Never put headings or copy inside the canvas.
  • Do not run postprocessing (bloom, SSAO) on phones by default.
  • Do not create geometries or materials inside the render loop.