
Three
Build deterministic Three.js/WebGL layers in HyperFrames that render on `hf-seek` using `window.__hfThreeTime`, not requestAnimationFrame.
Overview
Three.js for HyperFrames is an agent skill for the Build phase that defines deterministic WebGL scenes driven by `hf-seek` events and HyperFrames time, not real-time animation loops.
Install
npx skills add https://github.com/heygen-com/hyperframes --skill threeWhat is this skill?
- HyperFrames `three` adapter publishes time via `window.__hfThreeTime` and `hf-seek` CustomEvent
- Scene, camera, renderer, and assets should initialize synchronously; preload models/textures/HDRIs before seek
- Explicitly avoids rAF and `setAnimationLoop` as the source of truth for render-critical motion
- WebGLRenderer sizing pattern (e.g. 1920×1080, pixelRatio 1) aligned to composition frame size
- Supports AnimationMixer timelines, camera motion, and shader-driven visuals on seek
- Example Three.js 0.181.2 ESM import from CDN
- Renderer example uses 1920×1080 with pixelRatio 1
Adoption & trust: 61.7k installs on skills.sh; 25.6k GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
Your Three.js layer plays in real time or loads assets mid-seek, so exported frames do not match the composition timeline.
Who is it for?
Developers adding WebGL/Three.js hero shots, 3D product spins, or shader visuals inside HyperFrames compositions.
Skip if: Interactive 3D games or editors where the user drives continuous rAF rendering outside HyperFrames export.
When should I use this skill?
Creating deterministic Three.js scenes, WebGL canvas layers, mixer timelines, or shader visuals that must respond to HyperFrames hf-seek events.
What do I get? / Deliverables
You implement seek-listening render paths with preloaded assets and fixed-size canvases that reproduce the same 3D frame at each HyperFrames timestamp.
- Seek-driven WebGL canvas module for HyperFrames
- Event listener wiring for hf-seek rendering
Recommended Skills
Journey fit
Three.js scene code for HyperFrames is frontend/WebGL composition work completed before ship-time video export. Focuses on canvas scenes, mixers, shaders, and camera motion wired to HyperFrames events—not server APIs.
How it compares
Frame-seek WebGL contract for video compositions—not a general Three.js getting-started course.
Common Questions / FAQ
Who is three for?
Solo builders combining Three.js with HeyGen HyperFrames for canvas-based, export-controlled 3D motion.
When should I use three?
During Build when authoring WebGL layers, wiring AnimationMixer or camera moves to `hf-seek`, or fixing async load issues during render.
Is three safe to install?
Check this page’s Security Audits panel and review skill files before agents fetch external Three.js ESM/CDN modules in your project.
SKILL.md
READMESKILL.md - Three
# Three.js for HyperFrames HyperFrames supports Three.js through its `three` runtime adapter. The adapter does not own your scene. It publishes HyperFrames time and dispatches a seek event so your composition can render the exact frame. ## Contract - Create the scene, camera, renderer, materials, and assets synchronously when possible. - Render from HyperFrames time, not wall-clock time. - Listen for the `hf-seek` event and render exactly that time. - Load models, textures, and HDRIs before render-critical seeking. Do not fetch them at seek time. - Avoid `requestAnimationFrame` or `renderer.setAnimationLoop` as the source of truth for render-critical motion. The adapter sets `window.__hfThreeTime` and dispatches `new CustomEvent("hf-seek", { detail: { time } })` on each seek. ## Basic Pattern ```html <canvas id="three-layer"></canvas> <script type="module"> import * as THREE from "https://cdn.jsdelivr.net/npm/three@0.181.2/+esm"; const canvas = document.getElementById("three-layer"); const renderer = new THREE.WebGLRenderer({ canvas, alpha: true, antialias: true }); // Match these to your composition's frame size. renderer.setSize(1920, 1080, false); renderer.setPixelRatio(1); const scene = new THREE.Scene(); const camera = new THREE.PerspectiveCamera(35, 1920 / 1080, 0.1, 100); camera.position.set(0, 0, 6); const mesh = new THREE.Mesh( new THREE.IcosahedronGeometry(1.4, 4), new THREE.MeshStandardMaterial({ color: 0x64d2ff, roughness: 0.38 }), ); scene.add(mesh); scene.add(new THREE.HemisphereLight(0xffffff, 0x223344, 2)); function renderAt(time) { mesh.rotation.y = time * 0.7; mesh.rotation.x = Math.sin(time * 0.6) * 0.16; renderer.render(scene, camera); } window.addEventListener("hf-seek", (event) => { renderAt(event.detail.time); }); renderAt(window.__hfThreeTime || 0); </script> ``` ```css #three-layer { width: 100%; height: 100%; display: block; } ``` ## AnimationMixer Pattern For GLTF or authored clip animation, seek the mixer directly: ```js function renderAt(time) { mixer.setTime(time); renderer.render(scene, camera); } ``` If several mixers exist, seek all of them from the same `time`. ## Good Uses - Deterministic 3D objects, product spins, particles with seeded data, and shader plates. - Camera moves derived from `time`. - GLTF animation clips when assets are local and loaded before validation completes. ## Avoid - Using `Date.now()`, `performance.now()`, or clock deltas to update scene state. - Leaving render-critical work inside a free-running animation loop. - Loading remote models or textures at render time. - Device-pixel-ratio dependent output. Pin renderer size and pixel ratio for video renders. - Post-processing passes that depend on previous frame history unless you can reconstruct state from time. ## Validation After editing a Three.js composition: ```bash npx hyperframes lint npx hyperframes validate ``` ## Credits And References - HyperFrames adapter source: `packages/core/src/runtime/adapters/three.ts`. - Three.js `WebGLRenderer` docs: https://threejs.org/docs/pages/WebGLRenderer.html - Three.js `AnimationMixer.setTime()` docs: https://threejs.org/docs/pages/AnimationMixer.html