# Stack & Topple: A 3D Physics Toy from a Brief

> Write four lines (setting, hero, props, mood) and get a 3D physics toy with two modes in one offline HTML file: stack eight generated objects into a wobbling tower, then knock a two-stack tower down with kicks and a slingshot. The hero, six props, the sky, the voice and the music are generated through SandBase; the yard, both modes and the Rapier physics are code.

- Type: Lab Skill (downloadable Agent Skill)
- Category: [Game creation](https://www.sandbase.ai/skills/games)
- Version: 0.1.1
- Runs online: yes
- Page: https://www.sandbase.ai/skills/games/stack-topple

## What you get

Bring a setting, a hero, six props and a mood; optionally the palette, landmark and music. The Skill returns a downloadable Skill (the physics-toy engine, a budgeted 3D asset generator with rigging, verification) and one playable example with its generated media and billed cost.

## Install

Download the Skill package from https://www.sandbase.ai/skills/games/stack-topple (sign-in required), unzip it into your agent's skills folder, then ask your agent to use it:

```text
/stack-topple build a 3D physics toy in <your setting>, with <your hero> and <your props>, in a <your mood> mood
```

## How it works

1. **Fill the slots** Describe the setting, the hero, the six props and the mood, for example a misty mountain tea terrace at sunrise, a cheerful tea picker, a tea crate, a bamboo steamer, a stone lantern, a clay teapot, a woven tray and a jade frog. The agent turns the brief into a theme.
2. **Plan and generate the media** npm run assets prints every SandBase call with its worst-case estimate and refuses a plan over the budget, without spending. With --confirm-real it makes the calls through your logged-in sandbase CLI or SANDBASE_API_KEY, saves each run id at once so --recover can download finished runs without paying again, and compresses the rigged hero and the six props. The example made 26 calls and billed a few US dollars.
3. **Build and verify** THEME=<id> npm run build:single inlines Three.js, both modes, Rapier physics (WebAssembly inlined), the rigged hero, the six props, the sky and every sound into one file that makes no network requests. npm run shoot runs the scene-verify checks. The example passed 38 of 38 checks.

## FAQ

### Does Stack & Topple call a model or need a key?

Only while your agent builds a theme. The asset step calls SandBase models for the rigged hero, the six props, the sky, the voice and the music, through your own SandBase login, and the scripts never read, print or store the key. Once built, the yard page itself makes no network requests and calls no model. Nothing is billed without --confirm-real.

### How is Stack & Topple usage billed?

Stack & Topple’s asset step calls SandBase models for the models, sky, voice and music, billed to your SandBase account. Every planned call is listed with its worst-case price before anything runs, an over-budget plan is refused, and billing starts only with --confirm-real. Current model prices come from sandbase inspect.

### Why is the yard inside a frame?

The physics toy has no network and an opaque origin, so it cannot read this page or reach the internet — you play the verified build.

### Can the props be my own objects?

Yes — the six props can be your objects. Put your own GLB files in the theme’s media folder, skip generating those parts, and record their source and licence in CREDITS.json.

### Why does the game use WebAssembly?

The Rapier physics engine compiles to WebAssembly for rigid-body stacking and toppling; it is inlined in the file, so the demo is served with the game-sandbox policy.

### Can this page build a new yard?

Not yet — building a theme calls SandBase models and the sandbox has no key for that. Run the Skill locally with your own agent for now.

## Examples

- Stack & Topple playable physics toy (scene)
- Tea Terrace (video)
