# Introduction

Why Motion SDK exists, and how the spec, the renderer and the exports fit together.

Agents are good at 3D now. The viral Claude Opus 5.6 animations show it. But they get there by writing a whole Three.js program, and that has three problems:

- **It costs a lot of tokens.** Every scene is hundreds of lines of setup: renderer, loaders, materials, render loop, resizing, post passes. To change one thing, the agent rewrites most of it.
- **It isn't deterministic.** Frame timing, `Math.random()` and the browser decide what you see. The same code makes a different video every run, so you can't diff it, test it or export it reliably.
- **Nothing checks it.** A typo in a property name fails silently. The agent finds out by looking at a black screen, if it can look at all.

Motion SDK replaces the program with a document. The agent describes *what* is in the scene and how it moves. The engine owns *how* it's drawn.

## How It Fits Together

```text
agent ──▶ JSON scene or RFC 6902 patches
            │
            ▼
      motion-sdk-spec ── validate ──▶ issues with path + suggested_fix
            │
            ▼
      motion-sdk-core  (scene graph, timeline at any t, state machines)
            │
            ▼
      motion-sdk-render (wgpu: WebGPU, WebGL2, Vulkan, Metal, DX12)
        │           │
        ▼           ▼
   browser player   motion-sdk-export ──▶ MP4, GIF, PNG
   (@motion-sdk/core)   (motion-sdk CLI)
```

- **The spec** is the JSON document agents write, with a [JSON Schema](https://github.com/brainfish-ai/motion/blob/main/schema/scene.schema.json) generated from the Rust types. Every field has a default, so `{}` renders.
- **The core** evaluates the scene at any time `t` without allocating, so frame 300 doesn't depend on frames 0 to 299.
- **The renderer** is one lean wgpu renderer. The same code draws in the browser, natively, and headless in CI on a software GPU.
- **Export** steps frames at the export's fps and writes MP4, GIF or PNG sequences with social presets, captions and loop checks.

## What's Different

  - [A JSON Scene Spec](/docs/concepts/scene-document): Small, predictable shapes a model writes correctly in few tokens.
  - [Streamed Patches](/docs/concepts/streaming): Every accepted patch leaves a renderable scene.
  - [Errors with Fixes](/docs/concepts/validation): A JSON Pointer path and a fix, often a ready patch.
  - [Deterministic Renders](/docs/concepts/determinism): Same spec, same seed, same pixels.
  - [One Small Runtime](/docs/guides/performance): About 289 kB brotli in the browser, with timeline, text and particles included.
  - [Native and Headless](/docs/concepts/runtimes): The browser, the CLI and CI all use the same renderer.

## Principles

- **Valid at every step.** A streamed scene is renderable after every patch.
- **Errors an agent can act on.** Every issue has a `path`, a `message` and a concrete `suggested_fix`.
- **Deterministic.** No wall clock, no unseeded randomness, fixed-iteration math.
- **Fast by construction.** Stable ids so patches update GPU state incrementally, instancing in the spec, no per-frame allocation.
- **Beautiful by default.** Presets for materials, light rigs, camera moves, easing, particles and text are tuned so the default output already looks good.
