### Create and install the example project Source: https://wiki.spawnite.com/learn/your-first-game Run this command to create a new project from the example template and install its npm dependencies. The install requires no token because packages come from npm. To use a different theme, add `--theme slate` to the create command. ```bash npx @spawnite/cli create my-game --template example cd my-game && npm install ``` -------------------------------- ### Install and run Spawnite example simulation Source: https://wiki.spawnite.com/learn/for-evaluating-agents Requires Node 24.2 or later and npm. Creates a game from the example template, installs dependencies, and runs the example's run scene for five seconds of game time with no window. Output starts with 'Stepped 300 steps.' and a hash, and the dump shows 3 coins in the wallet. ```bash npx @spawnite/cli create my-game --template example cd my-game npm install npx spawnite simulate --scene run --seconds 5 --keys w --fields wallet ``` -------------------------------- ### Create a game from the example template and install packages Source: https://wiki.spawnite.com/learn/install Run these commands in the folder where you keep your projects. `npx @spawnite/cli create my-game --template example` creates a game from the example template, `cd my-game` moves into it, and `npm install` installs the engine and dependencies. The `--template` flag can be changed to other templates listed by `npx @spawnite/cli list`. ```bash npx @spawnite/cli create my-game --template example cd my-game npm install ``` -------------------------------- ### Game code file list example Source: https://wiki.spawnite.com/platform/publishing Example output from `spawnite build` showing the heaviest files a player downloads before the game starts, with gzipped sizes and source packages. The example keeps three of 26 listed files. ```text Game code: 32 KB gzipped Files a player downloads before the game starts, gzipped bytes, heaviest first: 122,856 release @spawnite/engine.js: @pixiv/three-vrm-animation, @spawnite/assets, @spawnite/engine, framer-motion, react-error-boundary 100,768 release chunks/three.core-BoJD7UsQ.js: three ... 20,348 page assets/index-tgKY-7nf.js ... and 68 smaller files, 86,181 bytes ``` -------------------------------- ### Run Holdfast locally Source: https://wiki.spawnite.com/games/holdfast Commands to create a copy of Holdfast, install dependencies, and start a local room. `spawnite play start` starts a room beside the dev server and opens the game; `--pages 2` opens a second warden's page, and `--bots 3` adds three bots. ```bash npx @spawnite/cli create my-holdfast --template holdfast cd my-holdfast pnpm install spawnite play start ``` -------------------------------- ### spawnite play start --device and touch input Source: https://wiki.spawnite.com/engine/testing/director Start a session with a device emulation and simulate touch input. The device name must be one Playwright recognizes, such as "Pixel 7" or "iPhone 15". The page takes the device's screen size, pixel ratio, touch screen, and coarse pointer. The example shows starting as a Pixel 7 and then holding, moving, and releasing a touch point. ```bash spawnite play start --device "Pixel 7" spawnite play hold Touch1 --at 150,250 spawnite play move Touch1 --by 120,0 spawnite play release Touch1 ``` -------------------------------- ### defineGame example Source: https://wiki.spawnite.com/reference/game/definegame Example of defining a game with defineGame, including name, start scene, room, worlds, and plugins. ```typescript export const game = defineGame({ name: "three-mmorpg", start: "meadow", room: defineRoom(), worlds: true, plugins: [characters(), stats(), resources()], }); ``` -------------------------------- ### Install uv on Windows Source: https://wiki.spawnite.com/learn/blender Install uv, which runs the server, on Windows. ```bash winget install astral-sh.uv ``` -------------------------------- ### Install uv on Linux Source: https://wiki.spawnite.com/learn/blender Install uv, which runs the server, on Linux. ```bash curl -LsSf https://astral.sh/uv/install.sh | sh ``` -------------------------------- ### useTextChat example: render messages Source: https://wiki.spawnite.com/reference/text_chat/usetextchat Example usage of useTextChat to get messages and send function, then render each message as a paragraph element. ```jsx const { messages, send } = useTextChat(); return messages.map((message) =>

{message.text}

); ``` -------------------------------- ### Install game dependencies Source: https://wiki.spawnite.com/learn/agent-checklist The create command ends with the install command for the game's package manager, such as 'npm install'. Run it in the game's folder. ```bash npm install ``` -------------------------------- ### Publish command output example Source: https://wiki.spawnite.com/platform/publishing Example output from the spawnite publish command, showing the build report, uploaded version, and the game's link and state. ```text Built the bundle at dist/bundle: engine 0.1.0, game code 146 KB gzipped. Uploaded version 3: 41 files, checked. Published version 3 of Tower Defense, game 48201973. Players load it within a minute. Link: https://spawnite.com/games/tower-defense/48201973?k=pT3xR9sYw2KqLmN8vB4cZa Live version: 3 State: unlisted, not on the store. Only people with the link can play. To put it on the store, send a store page with spawnite store upload, then run spawnite visibility public ``` -------------------------------- ### Set starting quality levels per device class Source: https://wiki.spawnite.com/engine/ui/graphics-quality Use the `quality.start` map to set the starting quality level for specific device classes. Classes not listed start at the engine's default level. This example sets `GraphicsCardLargeScreen` to High and `Touch` to Minimum. ```tsx import { defineGame, DeviceClass, Game, QualityLevel } from "@spawnite/engine"; const game = defineGame({ name: "bladebound", start: "lobby" }); {/* scenes */} ; ``` -------------------------------- ### Install blender-live plugin Source: https://wiki.spawnite.com/learn/blender Add the spawnite/plugin marketplace and install the blender-live plugin. ```bash claude plugin marketplace add spawnite/plugin claude plugin install blender-live@spawnite ``` -------------------------------- ### readDrawnFlight usage example Source: https://wiki.spawnite.com/reference/physics/readdrawnflight Example of using readDrawnFlight to get the drawn flight data and update a shadow's position. The function returns null if the ball is drawn at the page's own tick or on a non-page world. ```javascript const drawn = readDrawnFlight(world, ball); if (drawn) shadow.position.set(drawn.position.x, 0, drawn.position.z); ``` -------------------------------- ### List Spawnite templates with CLI Source: https://wiki.spawnite.com/learn/agent-checklist Run this command in the session's folder to verify the CLI is reachable and that the 'example' template is available. If node is missing or older than 24.2, ask the user to install Node 24 from nodejs.org. If npm is unreachable, ask the user to check the network. If the harness refuses the command, ask the user to run it and read the templates from their paste. ```bash npx -y @spawnite/cli list --json ``` -------------------------------- ### readNextPose usage example Source: https://wiki.spawnite.com/reference/physics/readnextpose Calls readNextPose to get the next pose for the entity 'lift' into 'nextPose', then modifies the y position by 'rise'. ```typescript readNextPose(world, lift, nextPose).position.y += rise; ``` -------------------------------- ### Install Chromium dependencies with Playwright Source: https://wiki.spawnite.com/learn/troubleshooting On Linux, when the browser fails to start with 'error while loading shared libraries: libnspr4.so' or 'Host system is missing dependencies', run this command to install the system libraries Chromium needs. Requires administrator rights. ```bash sudo npx -y playwright install-deps chromium ``` -------------------------------- ### Start a game with a room using spawnite play start Source: https://wiki.spawnite.com/learn/get-started Starts the game with a room. Use the same package manager as the project, e.g., npm exec. The dev command does not start a room. ```bash npm exec spawnite play start ``` -------------------------------- ### useMachineState usage example Source: https://wiki.spawnite.com/reference/state/usemachinestate Shows how to get the current top state of a machine on an entity using useMachineState. The example queries an entity with the Siege trait and reads its machine state, which can be "waiting", "fight", or other states. ```typescript const siege = useQueryFirst(Siege.trait); const phase = useMachineState(Siege, siege); // "waiting" | "fight" | ... ``` -------------------------------- ### App component defining a Game root with scenes and global UI Source: https://wiki.spawnite.com/engine/structure/game The example template's App is a whole game root. It reads room and renderer options from the URL, renders a Game with scenes, a global Readout, and optional devtools. The room joins a room named by the page address, gl picks the renderer, and ExampleDevtools loads only in development. ```tsx export function App() { // Game reads its room and its renderer once, when it mounts. const [room] = useState(() => readRoomOptions(window.location.search)); const [renderer] = useState(() => readRenderer(window.location.search)); return ( {ExampleDevtools && ( )} ); } export default App; ``` -------------------------------- ### readViewTrait usage example Source: https://wiki.spawnite.com/reference/physics/readviewtrait Calls readViewTrait with a step, target entity, HitZonesTrait, and a command to get the trait's value at that rewind moment. ```typescript const zones = readViewTrait(step, target, HitZonesTrait, command); ``` -------------------------------- ### Build and profile a game with `spawnite play profile` Source: https://wiki.spawnite.com/engine/testing/measuring Build the game without minification and with a source map so the CPU profile's function names map back to the engine's files, then profile it for 20 seconds. The command serves the build with `vite preview` and opens it in a headless Chromium at 1920x1080. ```bash pnpm build --minify=false --sourcemap=true spawnite play profile --seconds 20 ``` -------------------------------- ### readViewPosition usage example Source: https://wiki.spawnite.com/reference/physics/readviewposition Calls readViewPosition with a step, an entity's ball, and a command to get the entity's position at that rewind point. ```javascript const at = readViewPosition(step, command.payload.ball, command); ``` -------------------------------- ### Verify Spawnite connection by listing templates Source: https://wiki.spawnite.com/learn/connect-your-agent Ask your agent to list game templates. The agent should call the `list_templates` tool and name the `example` template. If the agent says it has no such tool, see Troubleshooting. ```text List the game templates. ```