Skip to content

Checking your reading list…

Retry

Stay curious. Build better.

Appearance

Choose how BestHub looks on this device.

Changes apply immediately.

Search articles

Open Discover with these filters

Suggested searches

Google's Three-Live: Three.js as Portable 3D IR for AI Video

Google's open-source Three-Live uses Three.js as a portable 3D intermediate representation, enabling AI agents to generate structured 3D scenes via sandboxed compilation, headless validation, and export to GLB/USDZ for cross-platform rendering, addressing gaps in AI-driven 3D video production.

Why Three.js as a 3D Intermediate Representation?

Traditional 3D pipelines either rely on desktop modeling tools exporting static binary assets ( .glb, .fbx, .usdz) or bind imperative rendering code to a single engine. When large language models (LLMs) or programming agents enter the workflow, both paths show clear shortcomings. According to the project's docs/why-three-live.md, three core reasons drive the choice of Three.js as a compiler input language:

LLMs cannot reliably output binary 3D files : Raw vertex buffers, quaternion data, or byte-aligned archive formats are unsuitable for token-by-token assembly; a few wrong bytes corrupt the entire file.

Text-to-mesh diffusion models lack scene structure : Their output is typically a single merged triangle mesh without part hierarchy, named nodes, mechanical joint constraints, precise parametric dimensions, or separated PBR materials. Without hierarchy, driving per-part motion or explosion animations in 3D video is difficult.

LLMs are already proficient at writing Three.js syntax : Constructors like THREE.Mesh, THREE.Group, THREE.BoxGeometry, and THREE.MeshStandardMaterial have high coverage in public code corpora, yielding higher generation accuracy than hundreds of lines of platform-native 3D and shader boilerplate.

Three-Live repositions Three.js from a browser-only rendering API to a compiler input language. Scripts no longer manipulate the browser DOM directly; they first pass through sandboxed compilation and quota validation, then lower to standardized asset files or feed directly into native renderers on Android Filament, Apple RealityKit, and WebGL2/WebGPU.

Three-Live compiles standard Three.js scripts into .glb/.usdz assets and multi-platform native scenes
Three-Live compiles standard Three.js scripts into .glb/.usdz assets and multi-platform native scenes

This means structured information — base placement, gear radius, rotation axes, surface materials — survives the compilation chain intact instead of being flattened into an inseparable mesh.

How It Differs from Traditional 3D Approaches

Running Three.js in a server-side or on-device sandbox differs fundamentally from running Three.js bare in a webpage, displaying static .glb files, or using a full game engine. The project's comparison table highlights five dimensions where Three-Live fills the middle-layer gap: generation barrier, scene structure, AI self-check capability, untrusted code isolation, and cross-platform delivery.

Comparison of traditional AI 3D routes vs Three-Live on structure retention, safety isolation, and headless validation
Comparison of traditional AI 3D routes vs Three-Live on structure retention, safety isolation, and headless validation

Three key isolation and unification layers:

Sandboxed script execution : On Android (via JNI), Apple platforms (via C FFI), and CLI tools, Three.js runs inside an embedded Rust Boa engine. In browsers, it runs in a stripped-down Web Worker (no fetch, WebSocket, indexedDB) or an isolated <iframe sandbox="allow-scripts">. Both enforce timeout guards, memory limits, and geometry quotas (Web docs specify 3–5 second script watchdog, max 1,000 meshes, 100k vertices, 300k indices, 16 textures per scene) to prevent runaway LLM-generated code from crashing the host.

Loop-free node shaders and cross-platform PBR materials : For custom material animation, Three-Live supports acyclic THREE.TSL node graphs (max 128 SSA nodes, 16 uniforms, TSL.Loop prohibited). The same material definition compiles to Android Filament, Apple .usdz MaterialX ( UsdShade), WebGL2 GLSL, WebGPU WGSL, and a CPU software rasterizer. Eleven procedural PBR presets are built in: wood, marble, brick, concrete, brushedMetal, rust, leather, fabric, carbonFiber, checkerboard, grid.

Standard .glb and .usdz asset export : Compiled scenes package into standard files containing hierarchy nodes, PBR materials, rigid-body physics properties, and interaction behavior graphs, ready for native system renderers or DCC software.

Three Practical Capabilities for AI 3D Video

1. Headless Visual & Spatial Self-Check Loop (Fixing AI Blind 3D Coding)

LLMs writing 3D code often produce syntactically correct but visually broken scenes: camera inside a box, model out of view, millimeter-scale units making objects building-sized, high-metalness materials turning black without environment maps, parts overlapping or floating. Three-Live provides a GPU-free, single-binary native tool three-live-cli (also as zero-dependency MCP stdio service three-live-cli mcp) that embeds spatial static analysis and CPU headless rasterization into the agent workflow. The agent must pass structured JSON diagnostics and quad-view renders before considering the script done.

three-live-cli spatial linter and headless quad-view rendering for AI agent auto-debug loop
three-live-cli spatial linter and headless quad-view rendering for AI agent auto-debug loop

Typical validation commands (from docs/llm-guide.md and README.md):

# 1. Run spatial static check, output JSON diagnostics (detects camera-inside-box TL302, out-of-view TL303, missing-light-black TL305, overlap-penetration TL306, floating/sunken TL307, etc.)
npx three-live-cli validate scene.js --json

# 2. Pure CPU render quad engineering views (perspective + front + right + top) with 1m grid and bounding-box annotations
npx three-live-cli render scene.js --view=quad --grid --annotations -o preview.png

# 3. Slice-render multi-frame sequence by duration to verify animate(t) animation and interaction state transitions
npx three-live-cli render scene.js -o anim.png --frames=4 --duration=2.0

With --reference=blueprint.png, the CLI outputs a comparison sheet (reference, render, 50/50 overlay, contour diff) and computes scale-translation-invariant silhouette IoU, helping agents align camera and proportion. This millisecond-to-second self-check without GPU or heavy desktop software is more engineering-valuable than a mere web player for automated 3D animation storyboard previsualization.

2. Parametric Domain Parts, Skeletons & Physics Joints, Direct Export for Reuse

Assembling complex objects from basic primitives (boxes, spheres, cylinders) yields crude models. Beyond primitives and CSG Boolean operations ( union, subtract, intersect), Three-Live offers on-demand Domain Kits: 57 watertight (2-manifold) parametric components across five categories:

Mechanical Engineering ( THREE.Mechanical , 15 types) : spur gears, bevel gears, racks, pulleys, metric bolts/nuts, bearings, springs.

Architecture ( THREE.Architecture , 9 types) : walls with openings, slabs, straight/spiral stairs, roofs, doors/windows, columns/railings.

Industrial Plant ( THREE.Industrial , 10 types) : flanged 3D piping, valves, centrifugal pumps, racks, conveyors, tanks.

Scientific Visualization ( THREE.Science , 14 types) : molecular structures, protein ribbons, crystal lattices, isosurfaces, streamlines, double helices.

Electronics Hardware ( THREE.Electronics , 9 types) : PCBs, enclosures with vent holes, heatsinks, common IC packages and connectors.

Animation and simulation support includes node TRS keyframes, GPU skinning up to 64 joints, morph targets, analytical two-bone and FABRIK inverse kinematics ( THREE.IKSolver), and 60 Hz deterministic rigid-body physics with mechanical joint constraints (hinge, slider, spring, ball). Web side uses the repo's xr-live-sim module; native mobile and CLI/MCP have it built in.

Example script (per project docs) declaring a named mechanical part with PBR material, orbital motion, and kinematic rigid-body properties:

// Example scene.js: define a mechanical part with orbital motion and kinematic rigid-body properties (doc syntax illustration)
const gear = new THREE.Mesh(
  new THREE.CylinderGeometry(0.4, 0.4, 0.12, 32),
  new THREE.MeshStandardMaterial({
    color: 0x38bdf8,
    metalness: 0.8,
    roughness: 0.25,
  })
);
gear.name = 'main-rotor';
gear.userData.xr = {
  orbit: { speed: -0.4 },
  physics: { body: 'kinematic', shape: 'cylinder' },
};
scene.add(gear);

const keyLight = new THREE.DirectionalLight(0xffffff, 2.0);
keyLight.position.set(2, 4, 3);
scene.add(keyLight);
scene.add(new THREE.AmbientLight(0xffffff, 0.5));

After validate passes, conversion commands produce standard assets carrying full hierarchy, materials, and physics/interaction metadata:

npx three-live-cli convert scene.js -o model.glb
npx three-live-cli convert scene.js -o model.usdz

These .glb / .usdz files can then go into Blender or Unreal Engine for high-fidelity rendering and camera composition, or into a web <three-live> component for code-driven shot recording.

3. Image-to-Scene ( compileFromImage ) and Local Natural-Language Tweaks

At the prototyping stage, Two AI-assisted paths:

Reconstruct procedural scene from reference image : CLI from-image (and Web/mobile API compileFromImage) lets a model generate Three.js scripts from photos, sketches, or blueprints, gated by checks for at least two meshes, finite bounding box, non-empty view frustum coverage, and zero severe overlaps. Setting --visual-turns (0–5 rounds) triggers multi-turn correction loops where headless renders (reference | render | 50/50 overlay) plus quad views are fed back to the model. On mobile, it can ingest Android ARCore or Apple RoomPlan plane and object size priors to anchor generated results to real-world scale.

Local voice/text hot updates : Enabling the three-live-ai module in the web component allows editScene('make the roof red and add a chimney') or click/voice selection ( selectByVoice) for partial edits. Each change re-compiles and re-validates in the sandbox; only on success does it hot-swap the live view, otherwise the original scene persists with undo support ( undoEdit).

Capability Boundaries: When Not to Use Three-Live

Per docs/why-three-live.md, three scenarios warrant other tools:

Cinematic photorealistic path tracing, volumetric light/fog, complex fluid VFX : Three-Live targets lightweight, deterministic, cross-platform real-time rendering and fast headless rasterization; it cannot replace Blender Cycles or Unreal Engine Movie Render Queue for film-grade offline rendering. Better to use Three-Live for structured modeling, scale/overlap validation, and .glb / .usdz export, then import into heavy DCC tools for final render.

Only need to display existing static artist models on the web : If models are already authored and exported as .glb with no dynamic geometry generation, CAD Booleans, physics interaction, or Android/iOS native SDK sync, <model-viewer> or the minimal three-live-viewer.min.js (under 31 KB gzipped) suffices.

Heavy reliance on browser features or massive open-world pipelines : Three-Live's fail-closed sandbox blocks network requests ( fetch), host DOM manipulation, arbitrary-loop custom shaders/compute pipelines. It also doesn't suit streaming multi-GB world assets, complex navmeshes, or full console-grade game builds.

For 3D video directions like mechanical teardowns, technical architecture animations, architectural/product multi-angle showcases, or procedural educational shorts , Three-Live offers high research value — a foundational toolchain letting AI agents safely write hierarchical 3D scripts, self-correct via visual feedback, and stably output .glb / .usdz. Treat it as the "structured scene compiler and spatial QA inspector" in the AI 3D video pipeline, not a replacement for post-production renderers, to leverage its engineering strengths.

About this article

For questions about attribution, corrections or content rights, please contactadmin@besthub.devand we will review it promptly.

Three.jsLLM AgentsAI 3D videoGLBheadless renderingimage-to-sceneparametric partsphysics jointssandbox compilationThree-LiveUSDZ

Discussion 0

Questions, practical examples and thoughtful responses.

Open full discussion