three
heygen-com/hyperframes
Three.js and WebGL adapter for deterministic, seekable 3D scenes in HyperFrames compositions.
What is three?
Integrates Three.js with HyperFrames to render deterministic 3D scenes, animations, and shader-driven visuals that respond to frame-accurate seek events. Use this when you need camera motion, AnimationMixer timelines, particle systems, or product spins that must render at exact times rather than wall-clock time.
- Render Three.js scenes deterministically from HyperFrames time via hf-seek events
- Support AnimationMixer timelines by seeking mixer state directly to match composition time
- Enable camera motion and transforms derived from composition time
- Handle shader-driven visuals and WebGL canvas layers with frame-accurate control
- Load models, textures, and HDRIs synchronously before render-critical seeking
How to install three
npx skills add https://github.com/heygen-com/hyperframes --skill three- Three.js library (e.g., via CDN or npm)
- HyperFrames composition setup with canvas element
- Models, textures, and HDRIs pre-loaded before validation
How to use three
- 1.Create scene, camera, renderer, materials, and assets synchronously in your composition
- 2.Set renderer size and pixel ratio to match your composition frame dimensions
- 3.Listen for the hf-seek CustomEvent on window and call your renderAt(time) function
- 4.Inside renderAt(), update scene state (rotation, mixer time, camera position) based on the time parameter
- 5.Call renderer.render(scene, camera) to output the frame at that exact time
- 6.Avoid requestAnimationFrame or renderer.setAnimationLoop; use hf-seek as the source of truth
- 7.Run npx hyperframes lint and npx hyperframes validate to verify your composition
Use cases
- Product spin or 3D object rotation synchronized to composition timeline
- GLTF animation clips with frame-accurate playback across multiple mixers
- Particle systems or procedural geometry with seeded, deterministic behavior
- Camera moves and dolly shots timed to composition events
- Shader-based visual effects and post-processing tied to composition time
- 3D motion designers and animators using HyperFrames
- Developers building product visualization or interactive 3D content
- Teams creating deterministic video renders with Three.js
- Engineers integrating WebGL canvas layers into HyperFrames compositions
three FAQ
No. These are wall-clock based and will break determinism. Listen to hf-seek events instead and render from the time value in event.detail.time.
Call mixer.setTime(time) on each mixer from the same time value inside your renderAt() function.
No. Load all remote assets (models, textures, HDRIs) synchronously before validation completes. Fetching at seek time will cause frame drops and non-determinism.
Use the time parameter from the hf-seek event detail, or window.__hfThreeTime. Derive all motion and transforms from composition time, not wall-clock time.
Avoid them unless you can reconstruct the full state from the time value alone. HyperFrames seeks to arbitrary frames, so frame-history-dependent effects will break.
Full instructions (SKILL.md)
Source of truth, from heygen-com/hyperframes.
name: three description: Three.js and WebGL adapter patterns for HyperFrames. Use when creating deterministic Three.js scenes, WebGL canvas layers, AnimationMixer timelines, camera motion, shader-driven visuals, or canvas renders that respond to HyperFrames hf-seek events.
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-seekevent and render exactly that time. - Load models, textures, and HDRIs before render-critical seeking. Do not fetch them at seek time.
- Avoid
requestAnimationFrameorrenderer.setAnimationLoopas 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
<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>
#three-layer {
width: 100%;
height: 100%;
display: block;
}
AnimationMixer Pattern
For GLTF or authored clip animation, seek the mixer directly:
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:
npx hyperframes lint
npx hyperframes validate
Credits And References
- HyperFrames adapter source:
packages/core/src/runtime/adapters/three.ts. - Three.js
WebGLRendererdocs: https://threejs.org/docs/pages/WebGLRenderer.html - Three.js
AnimationMixer.setTime()docs: https://threejs.org/docs/pages/AnimationMixer.html
Related skills
More from heygen-com/hyperframes and the wider catalog.
hyperframes
Router and entry skill for video authoring—renders video from HTML with intent-based workflow selection.
hyperframes-cli
CLI for HyperFrames video composition: scaffold, lint, validate, render locally or on AWS Lambda.
hyperframes-registry
Install and wire reusable blocks and components into HyperFrames compositions via registry.
remotion-to-hyperframes
Port existing Remotion (React) video compositions to HyperFrames HTML—one-way translation only.
hyperframes-media
Audio and media engine for HyperFrames: TTS, background music, sound effects, transcription, captions, and background removal.
gsap
GSAP animation reference for HyperFrames compositions with timelines, easing, and performance optimization.