Creative Coding

Google's Three-Live Treats AI-Written Three.js Code as Untrusted — and Compiles It Into AR You Can Actually Ship

Three-Live runs an AI agent's generated Three.js script inside a sandboxed Rust VM, then compiles the result into portable glTF (GLB) or USDZ files that work natively on web, Android, and iOS.

An AI coding agent asked to “write a Three.js scene” will happily produce a working script — and a security team’s nightmare, if that script runs straight in a browser’s WebGL/WebXR context with full access to whatever else is on the page. Google’s Open Source team published Three-Live on November 3 as a direct answer to that problem, and the design is more interesting than the usual “sandbox the JS” approach.

Compile first, run later, somewhere else entirely

Three-Live treats AI-generated Three.js as untrusted input that never reaches a renderer directly. Instead, it compiles the script — in milliseconds, per the project’s own documentation — into binary glTF 2.0 (GLB) or USDZ files. Those are portable 3D formats that already have native viewers everywhere: WebGL2/WebXR in a browser, Google’s Filament and Scene Viewer on Android, and Apple’s RealityKit and Quick Look on iOS. The compiler itself runs the AI’s script inside a sandboxed Rust virtual machine built on the Boa ECMAScript engine — a JavaScript interpreter written in Rust, chosen specifically so the untrusted code executes somewhere with none of a real browser’s capabilities, before its output is ever trusted enough to display.

That’s a meaningfully different shape than “run the AI’s code in an iframe and hope.” The AI’s script produces a static, inspectable artifact — a GLB or USDZ file — rather than a live program with ongoing execution privileges. Once that file exists, it behaves exactly like any other 3D asset: viewable, shareable, droppable into an AR Quick Look link on iOS with zero app install.

Why this matters beyond the security angle

The practical effect is that “describe a 3D scene to an AI, get an AR-ready file” becomes a genuinely cross-platform pipeline rather than a browser-only demo. Three.js scripts have always been able to construct scenes procedurally — generative geometry, physics-driven layouts, parametric objects — and Three-Live’s compile step means that procedural generation now has an output path straight into Android’s and iOS’s native AR viewers, which is otherwise an awkward export process.

It ships as a custom HTML element on the web, loadable straight from a jsDelivr CDN reference, so a page can drop in <three-live>-style usage without a build step. Versioning has moved fast since the November 3 announcement — the public repository already carries point releases past v1.0.0 — which is normal for a Developer Preview but worth checking before pinning a version in production.