threedog 1.0.1 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/docs/COMMANDS.md CHANGED
@@ -1,141 +1,142 @@
1
- # Commands and debugging details
2
-
3
- The scripts in `package.json` forward to the CLI `threedog` (from `@threedog/tools`; the root `build` runs each workspace's own `build`);
4
- **`threedog xxx` on this page means `node node_modules/@threedog/tools/bin/threedog.mjs xxx`** (in this repo: `node packages/tools/bin/threedog.mjs xxx`): plain node starts fastest. `npm run xxx` runs the same command (npx adds about 2.5 s per call, so it is not used here). The tools find every path through their `paths.mjs`, in the engine repository and in a game
5
- installed from npm alike. Every command checks its options: an unknown or misspelled one fails and lists the valid ones (dev bridge commands read their own options; `dev` / `build` / `preview` pass theirs to vite).
6
-
7
- ## Running one game only
8
- After `-w` write the directory or the package name (inside a game directory a plain `npm run ...` does the same):
9
- - Dev: `npm run dev -w games/my-game`, or from the root `npm run dev -- my-game` (part of the name is enough); no name means the engine example. To
10
- change the port (default 5173; if taken it moves to the next one): `npm run dev -- my-game --port 5000` (the game name must come first, the
11
- remaining arguments go to vite untouched; don't add another `--`).
12
- - Test: `npm test -w games/my-game`, or `threedog test -w my-game`; `npm test` at the root tests every workspace (engine + each game).
13
- - Build: `npm run build -w games/my-game`; `npm run build` at the root builds all (every *.html in a workspace root is bundled, no change to
14
- vite.config.js needed); under a sub-path of a site: `threedog build my-game --base /my-game/` (recipes/61-deploy.md).
15
- - Screenshot / bake / compress models: `npm run shot -- -w my-game / --describe-only` (`--out day.png` your own name, still in `.threedog/shots/` (a path with a directory is written as given), `--tier low|high` render at that device tier (default: the desktop tier, skipped effects are named), `--keep` timestamped file name; the rest in the table below), `npm run bake -- -w my-game`, `npm run assets -- optimize -w my-game`.
16
- - A game's tests: every `games/<game>/tests/specs/*.mjs` runs (each exports a `specs` array; the runner finds the files, nothing to register); without
17
- `tests/specs/` a smoke test runs automatically (page opens, engine ready, no console errors). Minimal example:
18
- ```js
19
- // games/my-farm/tests/specs/farm.mjs — export a specs array, one entry per page
20
- export const specs = [{
21
- name: 'farm: pick up apple', // threedog test apple matches by name substring, any case
22
- url: '/?cutscene=skip', // page path + URL parameters
23
- async run({ page, check, ev, frames, wait }) {
24
- // ev(fn, arg): runs in the page (engine is available). The function is serialized, so it can't use outer variables; pass them as the argument:
25
- const n = await ev(id => engine.inventory.count(id), 'apple');
26
- check('no apple at start', n === 0, `actual ${n}`); // check(label, passed, details on failure)
27
- await page.keyboard.press('KeyE'); // page is a Playwright page: keys, clicks
28
- await frames(3); // wait 3 frames of the real-time loop (software rendering is slow; waiting by frames is more reliable than wait(ms))
29
- check('has apple after pickup', await ev(id => engine.inventory.count(id), 'apple') > 0);
30
- },
31
- }];
32
- ```
33
- Tests run against the built bundle (not the dev server): main.js must set `window.engine = engine;` before `await engine.start()`, otherwise the
34
- test waits for the engine until timeout (the error explains why).
35
- A spec whose run() reads pixels (`page.screenshot`) moves to software rendering, which is much slower; `software: false` on the spec keeps it on the GPU for a real picture. Frame times measured beside other pages read several times too high: give such a spec `serial: true`, or run with `--jobs 1`. A spec file and what it imports run in Node. Importing `threedog` there works, but a file that touches `document` or `window` at its top level fails: move that code into a function, move plain data into a file of its own, or read the value in the page through `ev`.
36
- A test that steers: `frames(n)` and `wait(ms)` follow the machine, so under load the same script takes a different path. Hold the loop with
37
- `engine.haltLoop('my-test')` and advance game time yourself, `await page.keyboard.down('KeyW'); await ev(() => engine.step(0.25));`: the same steps give the same path on any machine.
38
- - New game: `npm run new-game -- name [--open-world | --pixel] [--webgl]` (the blank and `--open-world` starts: `recipes/01-new-game.md`; `--pixel` starts a sprite character in a pixel-snapped orthographic view with input, interaction, dialogue and saves wired, gray placeholders, not together with `--open-world`; the game runs on WebGPU and writes shaders in TSL, `--webgl` on WebGL with GLSL).
39
- - Game in your own folder (outside this repo): after `npm install threedog@1 three@~0.187.0 @threedog/tools@1`, run `node node_modules/@threedog/tools/bin/threedog.mjs init [folder] [--open-world] [--webgl]` (folder: the one to create, default the current folder): it copies the new-game template without overwriting anything, merges package.json and writes `.mcp.json`, so Claude Code opened in that folder starts the threedog MCP server by itself.
40
-
41
- > Git Bash (MSYS) rewrites arguments that start with `/` into a path under the Git install (`/` turns into `C:/Program Files/Git/`). Page arguments (`shot`, `capture`, `--page`) undo that by themselves, through `npm run` too (npm still echoes `> threedog shot C:/...`; shot then prints the page it really opens); if the Git folder cannot be found the error says so: then write `shot styletest`, set `MSYS_NO_PATHCONV=1`, or use PowerShell.
42
-
43
- > Windows PowerShell 5.1: `Get-Content` / `Set-Content` without `-Encoding utf8` read and write UTF-8 files in the system code page (mojibake, lost newlines). Pass `-Encoding utf8`, or edit files with your editor tools.
44
-
45
- ## Command table
46
- | Command | When to use |
47
- |---|---|
48
- | `npm run dev` | Development. Browser errors are sent automatically to the terminal and to the workspace's `.threedog/errors.log` (e.g. `games/my-game/.threedog/errors.log`): read that file first when something breaks, before taking screenshots. Known error classes carry `Possible cause: …` and `Read: recipes/…` lines (tables `core/base/errorCodes.js` for engine errors, `core/base/errorHints.js` for browser / JavaScript ones) |
49
- | `npm run check` | Run after every change (order: if the docs need regenerating `map` -> `check` -> related tests; otherwise `check` -> related tests): rule checks (`packages/tools/rules/`, the engine's hard rules among them; detection and allowlists are at the top of each file; the save round trip is in npm test) + types + content validation + generated docs up to date. Errors print in full, warnings as one count line per rule; `-- --verbose` lists them (the first 15 per rule), `-- --all` every one. `-- --rule R4` runs one rule (`R04` works; an unknown id fails and lists them), `-- -w game` (or `threedog check -w game`, or `check` run inside a game folder, as `new-game` does) reports only that game's rule, type and content problems and sets the exit code from them alone, with other games and the engine as one count line each; plain `check` at the repo root stays repo-wide (run it before committing engine changes); `-- --json` prints one JSON result instead (shape below, text to stderr, same exit code) |
50
- | R40 bypass hints (part of `check`, warnings only) | Game code that hand-rolls what an engine system does is pointed to that system: timers (also `await new Promise(r => setTimeout(r, ms))`), `Math.random`, an inventory, quests, grid/height blending, a localStorage save (any `setItem` except an obvious preference), pause, a settings menu, raw `keydown` listeners, `AudioContext`, a dialogue box, a loading screen, a language table, an interact-distance check, box collision, an `AnimationMixer`, a `requestAnimationFrame` loop, a camera follow, a particle loop, a tween, a pool of shots, a pointer raycast, a physics library. Each system declares its own hint; it works the same in a game installed from npm. Plain `check` lists the first 5 and ends "check passed, N bypasses"; `check --rule R40` lists all. Off per line `// hint-off(kind)`, per file `// hint-off-file(kind)`, per project `package.json "threedog": { "hints": false | { "kind": false } }`, per run `THREEDOG_HINTS=off`. A deliberate choice goes in DESIGN.md Systems |
51
- | `npm run types` | Type check only (does game code misuse the engine API). Plain JS TypeScript cannot follow (a field added to your own object later, a union from your own ternary, TSL node inference) is a `!` hint, not an error: no `// @ts-nocheck` needed |
52
- | `npm test` | Full browser tests (slow; test pages run in parallel, `-- --jobs N` sets how many, `--jobs 1` one at a time; without `--jobs`, at most 2 software-rendered pages at once; a spec with `serial: true` runs alone; a failure that happens only beside other pages is retried alone and listed). Normally `threedog test name` runs only the related ones (matched by test-name substring, any case, e.g. `-- hlod`; a word that matches nothing fails), `-- -w game` tests one game. Prints only failed items (with their failed checks), a progress line and the summary; `-- --verbose` prints every check. `-- --update-snapshots` makes tests that use `expectDescribe` write their describe baselines (`tests/snapshots/*.describe.json`) instead of comparing. `threedog test pack` (the build test): after a real build of each game, open only dist from a static server and check that the engine is ready, no 4xx resources, no console errors; `-- --json` prints the result as the same JSON shape, one item per failed check |
53
- | `threedog session [--minutes N]` / `session stop` / `session status` | Optional: keeps one small local process alive (127.0.0.1, token, `.threedog/session.json`) so later bridge commands skip module loading (about 0.1 to 0.15 s less per command); exits by itself after N idle minutes (default 10). Every command works the same without it: no session, a dead one or an unreachable one falls back to a direct call. Restart it after editing the tools |
54
- | `threedog bake light [-w game] [--out public/light/level.lightmap] [--size 1024] [--samples 128] [--page /]` | Bake a lightmap of the meshes marked `userData.static` in system Chrome on the real GPU; stops if WebGPU is not real. `recipes/34-environment-lighting.md`. `--samples` is rays per texel: raise it if flat walls look blotchy. A map with no light fails and writes nothing |
55
- | `threedog art list <source>` · `threedog art copy <source> [names…] [--to art/] [--force] [--dry]` | Reuse art code by copying it into this game (no dependency, no link back): the source is a game folder (its `art/`), a local folder or file, or an installed package. What `list` shows and what `copy` brings along: the recipe. MCP: `art_list`. `recipes/09-materials-lights-models.md` section 2a |
56
- | `threedog art board [-w game] [--out file.html] [--json] [--live] [--lib dir]` | Every art resource of one game on one page (default `.threedog/art-board/index.html`): models, textures, sounds, fonts, materials, shaders and library entries, each with a preview where one exists, its file, size and where it is used as file:line. Status: used, unused, missing, or not traced (a name built at run time or plain text that may mean it; never called unused). Each item copies one line for the AI; several items plus a note copy one request. `--json` prints the same data. `--live` also asks the running game (dev server, dev bridge) what it has really loaded; `?panel=1` shows the same list in folder "art". A model gets a picture once `threedog gallery --shots` has made one. |
57
- | `threedog lib status [-w game] [--lib dir]` | What this game pulled from the library (read from its `.threedog-lib.json`, which every `lib pull` writes): each entry changed or not, and newer in the library or not. It only reports: a pull belongs to the game and nothing updates it |
58
- | `threedog lib check [-w game]` | Do the things this game pulled fit together? Fails on a need nothing gives, on two entries writing one three.js value, and on code the game's renderer cannot run (GLSL in a WebGPU game, a node material in a WebGL game); sizes and styles that do not fit are notes. It reads the game's copies, so an edit or a port clears a clash |
59
- | `threedog lib add <file|folder|exportName> [-w game] [--name n] [--summary s] [--kind k] [--use s] [--plug "makeIt({ ... })"] [--style a,b] [--usage s] [--no-proof] [--preview url|png] [--force]` · `threedog lib list [words] [--card] [-w game]` · `threedog lib pull <name> [-w game] [--to art/] [--plug "makeIt({ ... })"] [--force] [--dry]` · `threedog lib page` | Your own library of art and techniques from earlier games, kept outside the engine (`~/.threedog/library`; `THREEDOG_LIBRARY` or `--lib dir` moves it): one folder per entry with the copied files, `entry.json` (kind model / texture / material / shader / effect / module / other, summary, the use line, backends, params, which game and day it came from) and `preview.png`. `add` copies from a game the way `art copy` does (local imports, textures, models), summary defaults to the first JSDoc line, never replaces a different existing entry without `--force`; a model or texture gets the gallery turntable when the game registers it, a code entry a picture only with `--preview <url of a running scene>` or `--preview file.png`. `list` is one line per entry (words narrow it); `pull` copies an entry into this game and prints the use line with the path where the file landed. An entry that cannot draw on the game's renderer (`backends` in `entry.json`, `lib list` shows it, `lib list webgpu` narrows to it) is refused with nothing copied; `--force` copies it to port by hand. Where it lands goes by kind: a `picture` or `material` entry in `picture/` (a `.glsl` in `picture/shaders/`) with no wiring file, you import it yourself; a model or texture in `art/`; a `shader`, `effect` or `module` entry in `plugins/<name>/` plus the wiring file `plugins/<name>.js` that calls its factory (the entry's plug line, set by `add --plug`, else its exported function; `pull --plug` overrides), so it plugs at start with nothing hand-written; a `system` in `systems/<name>/` plus that wiring file; `page` writes `index.html` with all previews. MCP: `lib_list`. recipes/05-props-bake.md §2d |
60
- | `threedog examples list` · `threedog examples pull <name> [--out dir] [--force]` | Technique and optional examples you copy and adapt (the list is `examples/pullable.json` in the engine package; the summary is each README's first line). `pull` copies the game-facing files to `<game>/techniques/<name>/` (or `--out`), never overwrites a changed file without `--force` (then nothing is written), prints the import line and the packages the code imports. An unknown name fails with did-you-mean |
61
- | `threedog how "<task>" [--full]`, `--browse [category]`, `--card <id> [--full]` | One recommended route for a task in your own words (not the only allowed one): is it installed in this game, what is missing, a minimal example, the next route; `--full` lists the other routes. With no words, or `--browse`: the categories, then one line per capability. `--card`: what a capability solves, when it does not fit, install, dependencies, time, saves, an example and what verified it. The MCP tool `how` has the same three as fields `task`, `browse`, `card`. `recipes/51-capability-catalog.md` section 5 |
62
- | `threedog content set <id> x=12 place=home … [--expect x=5] [--in props] [--file content/x.js] [--dry]` | Write a permanent change into the content entry (several fields, one write, all-or-nothing; refused when `--expect` no longer matches). `recipes/40-scene.md` |
63
- | `threedog content add <kind> id=<id> field=value … [--file content/props/town.js]` · `threedog content remove <id> [--in kind]` | Append one entry at the end of a kind (always with an id) / delete one. Reads and checks only that file (id index `.threedog/content-index.json`). `recipes/40-scene.md` |
64
- | `threedog content stamp <arrangement> id=stall-1 x=20 z=5 [rot=1.6] [--dry]` | (experimental) Copy `content/arrangements/<arrangement>.js` (recipe 30 section 7) into the game: one place in `content/places.js` and one plain props entry per part, id `<id>-<part>`, `source: <arrangement>`. An id clash lists every clash; any failure writes nothing |
65
- | `threedog content set --source <arrangement> <part> field=value … [--dry]` | Explicit batch edit: the same change in that part of every copy, all or nothing, and it prints how many changed (`--dry` lists them first). Copies do not follow automatically, and the arrangement file is not changed. Without `--source`, `content set` edits only that entry |
66
- | `threedog content capture <groupName> --as <arrangement> [--page /p.html] [--force] [--dry]` | (experimental) From the running game (dev server): read a named `THREE.Group`'s direct children (position, turn, scale relative to the group, named model or template of each) and write the arrangement. Placement only, never geometry. A child with no named model, a tilt or an uneven scale is listed by name with the fix, and nothing is written. Afterwards delete the code that placed the group, or it appears twice; `check` warns (R52) while its name is still in the code |
67
- | `threedog mcp [--allow-js]` | The dev bridge as an MCP server over stdio. `recipes/16-dev-bridge.md` section 10 |
68
- | `threedog assets check new.glb --against old.glb` | What the old export had and the new one lacks. `recipes/46-blender-art-route.md` |
69
- | `threedog shot --view name [--compare before.png]` | A named camera view (`engine.views.define`) and a pixel diff against an earlier picture. `recipes/46-blender-art-route.md` |
70
- | Result of every bridge command | CLI text ends with one line on the game state and the way back (`Game loop halted, tick 180: threedog resume restores real-time running`; frozen by a menu says which). MCP adds `structuredContent` { ok, code, summary, runtime { ready, mode running|halted|frozen, tick, headless, blockedBy[] }, data } and an `outputSchema` on every tool. `code`: ok, blocked (ran, refused), not-ready, no-server / starting / busy / page-error / no-bridge (cannot reach the game), command-error. **Advance game time**: step, press, hold, skip, scenario, verify. **No game time**: op, state, eval, js, resume, reload. Everything else only observes. eval / js and describe with a path or --full / --all print no state line (parseable); runtime still has it. |
71
- | `npm run map` | Regenerate CODEMAP, API.md + api/, each game's GAMEMAP and the event-name list (generated from `EventMap` in core.d.ts; add a new event to EventMap first) after changing code, JSDoc or content (run it before `check`) |
72
- | `npm run shot -- / --time 18:30 --weather rain --pos x,z` (or `--at place`: in play at a named place) | Only when you need to see the picture; by default 1 image of 960x540 into the workspace's .threedog/shots/; **read the state as text first with `--describe-only`**. Under a picture it prints only what bears on it (time, weather, camera; the same lines as `threedog snap`); `--describe-only` and `--json` give the whole state. `/<page>.html` switches the page, `-w game` switches the game, `--wait seconds` advances time. The shot waits until loading is finished (`--load-timeout` seconds, default 120) and fails naming what is still pending, then for the game's own code after `await engine.start()` (no request open and the scene's objects / lights / materials unchanged for 0.3 s, at most 10 s; it prints how long and what was added; if the scene still changes after the picture, it warns that the picture may be incomplete); a page error before `window.engine` fails at once with the error. `--no-build` reuses the last dist/ (code unchanged); a playing cutscene is skipped unless `--keep-cutscene`; `--play` starts straight in play, past the title screen the way its Start does (the engine's `?play` URL key) |
73
- | `npm run shot -- / [--ref image] [--no-picture] [--json]` · `shot http://localhost:5173/` · `shot --image file.png` | After every shot (and every `threedog snap`, on the live page): picture numbers measured on the 3D canvas and hints: contradictions, facts and intent, listed in recipes/35 "Picture check after every shot". Nothing fails and nothing is changed. Printed short: the numbers line (noon / midnight with each exposure when the two differ), then at most four one-sentence hint lines, contradictions first and then by measured size, and `N more: threedog shot --json (picture.hints)`. A few extra renders of the current view (about 0.3 s on a GPU), every touched value put back. `--json` prints one object (file, look, probe, every hint in full, describe) for MCP / the dev bridge. A full URL opens that already running page without a build, and a local server of another game's folder is refused (one that cannot say which game it serves gets a printed note); `--image` reads a picture taken any other way and gives the pixel part only (shares, near-white spots, intent), saying what needs the live page. A screenshot of your own skips the check: take pictures with `shot` or `snap`. recipes/35 |
74
- | `npm run shot -- styletest --view room --time dusk --weather rain` | The fixed style-judging scene (`examples/styletest`, page `/styletest.html`; a bare name is a page of the workspace). Views and the `--time` / `--weather` words: recipes/35. Same arguments every round, so only the style differs. `--panel` is not a shot option: open `/styletest.html?panel=1` in a browser for the workbench (recipes/35) |
75
- | `threedog capture [page] [--top N] [--no-spector] [--spector-url url] [--full] [--no-build]` | Find out what a frame draws: renders one steady frame headless and prints draw calls, shadow-map draws, render passes (post effects) and the largest draws with world record id, budget tag and material purpose. Also records the WebGL command stream of that frame with Spector.js (fetched on first use into `.threedog/cache/`, not a dependency) to `.threedog/captures/`; `--no-spector` skips it, `--spector-url` fetches it from another source. Works on the game's own renderer, WebGL or WebGPU, and prints which one it measured; Spector only runs on WebGL. A frame with no draws fails |
76
- | `npm run bake` | Before release, or to take code-generated models into Blender: exports public/models/baked/*.glb (`-- -w game`) |
77
- | `npm run assets -- check [glb or folder] [--json] [--strict]` | Inspect models without building (default art/models/; a game with no such folder has nothing to check and passes, and only models are read: sprite and texture PNGs are never looked at): the level manifest (spawns, col_ colliders, trigger_ zones, npcs, markers, template / id nodes, missing templates, duplicate ids), material and color-space suspicions (data texture in a color slot, BLEND, texture without UV, oversized texture), statistics. `--json` for tools, exit 1 on errors (`--strict`: on warnings too). `npm run check` also reads the level glbs for content validation |
78
- | `threedog assets optimize [-w game] [--dry] [--force] [--budget MB] [--strict] [--lod [--lod-shares 0.5,0.2]]` (`npm run assets -- optimize`) | `--lod` also writes lower-detail levels and reports triangles per level, saying which models it skipped and why (recipe 15 §4a). Make game-ready copies of the models in art/models/ without touching them: Meshopt geometry, KTX2 textures encoded by slot (normal / occlusion / roughness maps as linear UASTC, color maps as sRGB ETC1S; each output texture is read back and checked against its slot), into public/optimized/. Writes `assets.optimized.js` and adds its import to assets.js, so the names point at the results. A rerun handles only changed files (content hash, options, tool versions). Per file: size before / after, estimated GPU memory, and problems (over `--budget` MB of texture memory, color space, texture without UV or without the second UV set it asks for). `--dry` writes nothing and reports the estimate. Needs `@gltf-transform/cli`. Textures are encoded by the `ktx` command (KTX-Software 4.3+) when it is on PATH, else by the WebAssembly encoder of the npm package `ktx2-encoder` (MIT; its Basis Universal build is Apache-2.0), which comes with the tools. The output says which encoder ran and how long encoding took. With neither, only this command fails and says what to install. Baked lightmaps are left as baked (banding after compression is not measured). Report: `.threedog/optimize-report.json` |
79
- | `npm run perf` | Performance comparison (plain three.js vs engine vs per-module cost in openWorld). Prints the renderer first. `threedog perf -w my-game [frames]`: your game's page in play, standing still: frame ms, JS ms, draw calls, memory |
80
- | `threedog stress [-w game] [--only a,b] [--frames 30] [--json]` | At what load this game drops: from a game folder (or `-w`) the load ramps go on top of the game's own scene on its own renderer in system Chrome, one axis at a time (extra meshes, triangles, instances, point lights), after a line with the game alone; then the load that fits 16.7 and 33 ms per axis. A WebGPU game on a browser without real WebGPU is refused. In the engine repo with no game it runs the neutral page `tests/stress/` for the engine's own measurements, and says so |
81
- | `--gpu` · `--software` · `THREEDOG_RENDER=gpu` or `software` | Renderer of the headless browser. `shot`, the dev bridge's headless page, `gallery --shots`, `perf` and `stress` prefer the hardware GPU (ANGLE d3d11 / metal / vulkan), check the renderer string after launch and fall back to SwiftShader with one note line; tests that read rendered pixels (`software: true` on the spec; unmarked ones are caught at the end of a GPU run) start on SwiftShader (same pixels everywhere), the others on the GPU when it is reachable |
82
- | `threedog content ids [-w game \| folder] [--write]` | Stateful content entries that rely on their index id: prints the id each has now as `-`/`+` lines (dry run); `--write` writes them in. Recipe 30, "Writing the ids, renaming them" | <!-- r18-ignore-line -->
83
- | `npm run doctor` | Check the environment, one line per item: ✓ passed · ✗ problem -> fix · – info only; `-- --ci` does not fail the command on problems; `-- --json` prints the same shape as `check --json`: `{ ok, summary, items }` (items are the problems and info lines); exit code 0 only when `ok`. Checks Node version, node_modules, workspace links, package-lock consistency, `.threedog` writable, the physical copy (real path, version, package.json mtime) of engine / tools / three per context (check, run/build per game; a `MISMATCH` line when contexts use different copies, e.g. vendor/ vs node_modules), port 5173, the dev server recorded in `.threedog/dev.json`, then renders one real engine frame on software rendering (what tests use; failing is a problem) and on the GPU path (whether a hardware GPU is available to headless; info only), and whether `EXT_disjoint_timer_query_webgl2` gives GPU ms. Run it first when the environment acts strange |
84
- | `threedog api-count [--unused] [--json] [--games dirA,dirB]` | Engine repository only: counts the public surface an AI meets (createEngine options, engine members and their sub-objects, module options and APIs, exports of `threedog` / `threedog/tsl` / `@threedog/post-effects`, CLI commands and options, error codes) from the type declarations, one line per group; `--unused` lists the items no engine source, example, template or recipe code block uses (deletion candidates, a name heuristic); unused items kept on purpose (CLI commands, error codes, tuning options with a default) are reported apart as `kept`. For engine maintainers deciding what to delete |
85
- | `threedog picture palette <image> [--n 8] [--average] [--region x,y,w,h] [--ignore-ui] [--crop out.png] [--json]` | Dominant colors of a reference picture and a one-line summary. `--average` adds the mean color (HSL); `--region` measures one rectangle; `--ignore-ui` cuts a flat frame around the picture (edge row / column one flat color, frame 3% to 45% of the picture; a plain sky at the edge looks the same, so check with `--crop out.png`, which saves the measured area). The output says what was measured; `--json` prints the JSON only (summary inside). A path that starts with `-` goes after `--`. A measurement, not a design decision |
86
- | `threedog picture compare <reference> <screenshot> [--region x,y,w,h] [--ref-region ..] [--shot-region ..] [--json]` | Differences as numbers: brightness, saturation, contrast (std of luma), fine detail (variance of the Laplacian of luma; read as a ratio), average and main color (hue / saturation / lightness), plus one neutral sentence ("18% darker, 2.3x more broken up"). Both pictures are scaled down to one size, never enlarged (detail is measured at the smaller picture's scale), and the notes say so. Regions are matched by position: a shifted feature shows as a large hue difference, so cut the same content with `--ref-region` / `--shot-region`. **An aid to judging, not a replacement for looking; no number is a quality score and there is no "similarity %".** recipes/35 |
87
- | `?panel=1` with `import('@threedog/tools/panel').then(m => m.openPanel(engine))` | The dev panel in any game: live sliders straight on the three.js objects, "write back" for `threedog tune`. `recipes/35-picture-from-reference.md` |
88
- | `threedog tune show [-w game]` · `threedog tune write [file] [--apply] [-w game]` | Values from `.threedog/tune.json` as one `// threedog:tune begin ... end` block of plain three.js writes (`engine.scene.fog.far = 90;`, `material.setValues` by name, UI CSS variables) in `file`. A later write merges into the block, so values the panel no longer holds stay; delete a line to drop it. Model generator params (the panel's models folder) become the `default` in that model's `params` schema where it is registered (no file needed for those). Without `--apply` it only prints the diff. `recipes/35-picture-from-reference.md` |
89
- | Tuning without a mouse | The panel is for a person. An AI does not need it: try values with `threedog js` (`engine.scene.fog.far = 90`), look with `threedog snap`, then write what it settled on into `.threedog/tune.json` as `{ "values": { "engine.scene.fog.far": 90, "engine.scene.background": "#336699" }, "css": { "accent": "#7fd3ff" }, "materials": { "rock": { "roughness": 0.8 } }, "models": { "tree": { "height": 4 } } }` and run `threedog tune write main.js --apply`. Or write the value straight into the code; the file only saves reviewing the change first |
90
- | `threedog gallery [-w game] [--port 5181]` · `threedog gallery --shots [--size 256] [--only a,b] [--mode silhouette,value]` | Every registered model and texture on a turntable under three neutral light setups (midday, low sun, overcast; tone mapping copied from the game). Without `--shots` it serves the game in dev and prints the `?gallery=1` URL (any dev page opens it with `?gallery=1`); `--shots` writes `.threedog/gallery/<name>-<light>.png`, `index.html` and `index.json` headless. `--mode` adds review pictures beside them: `silhouette` (each model pure black on white: `fill`, `boxFill`, `aspect`) and `value` (the midday shot as grayscale luminance: `p5` / `p50` / `p95` inside the outline); the facts are printed per asset and stored in `index.json`, with no thresholds. `recipes/05-props-bake.md` section 2c |
91
- | `npm run build` | Bundle each workspace into its own dist/ |
92
- | `threedog preview [game]` (or `-w game`, as for dev and build) | Serve a workspace's built dist/ (vite preview) to open the production build in a browser. It is the shipped game, so URL keys (`?play`, `?time`…) are not read; `shot`, `test` and `dev` read them, or set `createEngine({ urlState: true })` (`?fresh` stays dev-only) |
93
- | `threedog relay [port]` | The WebSocket relay for the net module (default port 8787, no dependencies). `recipes/27-net.md` |
94
-
95
- **`--json` result** (`check`, `test`): one line on stdout, `{ ok, summary, items: [{ code, level, file, line, message, fix }] }`. `level` is `error` or `warn`; a field is present only when known. `code` is the rule id (`R4`), a TypeScript code (`TS2345`), `content` or `test`. A test item's message is `<item name>: <check> → <reason>`; the totals are in `summary`. `ok` and the exit code agree.
96
-
97
- ## Dev bridge commands
98
- They drive the running game. Run them inside the game folder or with `-w game`; at the repo root the one running dev server is used (several: the error lists them for `-w`). `threedog <command> --help` prints the same line. `recipes/16-dev-bridge.md`
99
-
100
- <!-- rows written by npm run map from packages/tools/threedog/command-table.mjs: edit them there -->
101
- | Command | What it does |
102
- |---|---|
103
- | `threedog describe` | compact scenario description (--full for the describeText summary, --all for everything, describe player.x for one item, --max characters); recipes/16-dev-bridge.md |
104
- | `threedog step` | advance N real seconds: step 2. The loop stays halted afterwards (threedog resume) |
105
- | `threedog skip` | jump the clock like sleeping: skip to=06:00 / skip seconds=600 (engine.skip: op time.skip, sky clock and time-keeping modules catch up; optional fade=0.6 save=auto). to works with calendar() alone; the sky only follows the clock when installed |
106
- | `threedog press` | press a key or action: press interact / press KeyE / press e (held 0.1 s, then renders 1/60 s; --for 0.02 shortens the hold) |
107
- | `threedog hold` | hold for N seconds: hold moveForward 1.5. moveForward walks along the camera's heading, so with a follow camera at its start angle it goes diagonally, not along an axis: place things by reading player after a short hold |
108
- | `threedog state` | change the scenario without a reload: state time=18:30 weather=rain pos=40,-20 (pos=x,z has no height: the hero stands on the highest support over that spot, a ledge included; to stand under it, js "engine.player.placeAt([x, y, z])") |
109
- | `threedog js` | evaluate an expression in the page (engine is available, await works; one expression prints its value, several statements print what they return): js "engine.calendar.timeOfDay"; long scripts: js --file path. A script that calls assert(cond, msg) or expect(v).toBe/toEqual/toBeCloseTo/toBeGreaterThan(x, msg) (or expect(v, msg)) runs as checks in ONE call: failed checks are recorded and the script goes on, a throw stops it; output ✓ 7 checks passed, or the failures then ✗ 2 of 7 checks failed; exit 1 on failure; --verbose adds passes, log lines and the return value. A script without those calls is the plain form. Both modes get the globals engine, step(seconds), log(...), assert, expect. --wait <seconds>, default 120: how long a script may wait on a page that looks stopped (driven by manual step, nothing loading, no clock tick); the command then ends and says the script may be waiting on the game clock, and the script may still run in the page |
110
- | `threedog snap-describe` | describe snapshot instead of a screenshot, a baseline of the gameplay part of describe(): snap-describe save\|diff name [--only a,b] [--ignore x.y] [--tolerance 0.5] (recipes/16-dev-bridge.md section 7); in tests one line expectDescribe({ check, ev }, name, { only, tolerance }) from @threedog/tools/describe-snapshot |
111
- | `threedog snap` | save a screenshot to .threedog/shots/name.png and run the picture check on the page, as threedog shot does (snap name, or snap path/to/file.png used as given; --play first leaves the title as shot --play; --width N scales the returned image down, the saved file stays full size; --no-picture skips the check) |
112
- | `threedog errors` | page errors with id (E1…), time, tick, source and count; the same error repeated is one line with its first and last id / time and ×N. errors = new since the last read; errors latest [N] = the last N (default 3), same answer every time; errors --since E5 = after id 5, never moves the read position. Every result prints a cursor (known classes come with the cause and the doc page) |
113
- | `threedog reload` | reload the page |
114
- | `threedog resume` | resume real-time running (the page is halted after step / press) |
115
- | `threedog ops` | what the player can do now (each op offer checked with can): ✓ shop.buy shop=bakery item=bread · ✗ … (reason); recipes/23-ops.md |
116
- | `threedog op` | run an op as source bridge (no time passes): op shop.buy shop=bakery item=bread n=2 (values converted by the op args shape) |
117
- | `threedog inspect` | what is around the player (or inspect npc_3 / inspect 10,-4) and which ops it can do now, with reasons. inspect materials (engine.inspect.materials(), plain three.js: scene.traverse + texture.colorSpace) = every material: textures (slot, size, color space, estimated GPU MB, shared-by), engine- or game-made, shader patches and their slots, meshes sharing it; materials that read the same are one line with ×N; wrong color spaces first (color map not sRGB = washed out; normal / roughness map marked sRGB). inspect perf (engine.inspect.perf(), plain three.js: renderer.info) = the last frame against budgets: draw calls, triangles, programs, texture MB (estimate), JS ms by phase, compile stalls during play, costliest programs; ✗ lines name the next call. Budgets: engine.budget limits, else a desktop reference. The engine benchmark suite is npm run perf |
118
- | `threedog scene` | the mesh exists but is not drawn: use this first. Counts, one Not drawn because: line over every Mesh / Points / Line / Sprite, then the first 6 undrawn ones (surprising before plain view culling) with every reason, most likely first: visible=false on it or a parent, layers vs camera, material flags, scale 0 / NaN, NaN position or vertices, empty geometry, behind the camera, beyond camera.far, outside the view. "maybe" reasons (depthWrite off, fully fogged...) do not stop drawing. scene [--hidden (only undrawn)] [--limit N \| --full (40)] [--json]. Code: engine.inspect.scene(). Cannot see shader output |
119
- | `threedog pick` | what is at screen pixel x,y (from the canvas top-left): pick 480,270 -> record id, kind, template, where it is defined (content file:line), fields |
120
- | `threedog explain` | why: explain op shop.buy shop=bakery item=bread (can it run; --full adds its last attempt) / explain quest first-light (where it is stuck) / explain value fog.far (which line last changed it) / explain thing player-chest (where it is defined; --full: everything about the id as JSON) / explain module quests / explain capability ground. engine.explain; recipes/23-ops.md, recipes/40-scene.md section 9, recipes/62-picture-code.md |
121
- | `threedog scenario` | run one scenario test (tests/scenarios/<name>.json) on this page: scenario barter (prints failed checks and the Coverage block of verify; the scenario leaves the page halted) |
122
- | `threedog catalog` | what the game can do, from its registrations: catalog = a line per module with ops or problems, the rest named on one line (--full: a line each); catalog shop = one module (dependencies, params + defaults, ops with args and failure codes, saved parts, time hooks, problems, doc / recipe / source files); catalog shop.buy = one op; catalog --find throw; --json for the raw data; recipes/51-capability-catalog.md |
123
- | `threedog loading` | what loading waits for / what failed / does it block the start (answers while start() is stuck); loading hero: one task with its manifest and path; recipes/05-props-bake.md |
124
- | `threedog play` | start the game for the AI: starts the dev server if none runs (detached, output in .threedog/dev.log), waits for the bridge and the engine, prints the page address and whether a headless or a live browser page is connected (play --stop stops the server play started) |
125
- | `threedog impact` | before a change, what it touches, from the files alone: impact coin / impact shop.buy / impact stack / impact collider3d lists content, calls, saved parts, templates, tests and engine facts, then says what it cannot see (names computed in game code, what only a page or a save holds). --full lists every place |
126
- | `threedog report` | one file another AI can rerun a problem from: engine version, seed, tick, describe, recent ops, errors with hints, modules and capability state, steps to reproduce and a derived scenario; no tokens or user paths. Writes .threedog/reports/ (--out file); --scenario also writes tests/scenarios/report.json for threedog verify report. Works with no page, and says what is then missing |
127
- | `threedog status` | is it ready: engine ready / loading / page errors / running, halted or frozen. When the bridge cannot answer it names one of five causes with one next step: no server (threedog play), server still starting (wait, status again), server busy and not answering in time (wait, status again), page script error (threedog errors latest), no dev bridge installed (use gameConfig) |
128
- | `threedog verify` | run a scenario (tests/scenarios/<name>.json) and report PASS / FAIL, what it tested (ops with outcomes, describe sections compared, time advanced) and what it never touched (ops never run, sections never compared, steps skipped after a failure, key path, picture): verify barter. Also a Layers: line (steps by layer: direct = op/describe call, simulated-input = bridge press; real-browser-input is always 0 and printed as not verified, visual 0 because scenario snapshots are describe, not pixels), tests that mention an error code seen, and the threedog test command to re-run. A page error during the run fails it. JSON adds layers / layerCounts / evidence (per-check layers, notProven, ops / modules coverage; text: Evidence, NOT proven, Coverage: ops ran/total with refused ones marked, modules tested / indirect / untested, lists capped with "+N more") |
129
- <!-- end of generated rows -->
130
-
131
- ## Reproducing a scenario and debugging
132
- - Add `?time=18:30&weather=rain&pos=40,-20&save=slot1&cutscene=skip&state=name` to the URL (effective in development).
133
- - In the console / tests: `engine.describeText()` reads the state as English text; `engine.step(seconds)` fast-forwards synchronously (no rendering);
134
- `engine.haltLoop()` stops the real-time loop.
135
- - To wait for the page: `page.waitForFunction(() => window.engine?.stateApplied)` (start has finished and all URL parameters are applied), then read `engine.stateRefused` for what the URL could not do (`shot` and `capture` fail on it); never read
136
- `_`-prefixed private fields. When the dev bridge / `npm test` / `npm run shot` cannot reach the engine (no `window.engine` after 40 seconds, or it
137
- exists but never becomes ready), the error states the page status, the latest page errors and the fix.
138
- - Advancing dialogue headlessly: recipe 02.
139
- - Debug objects on window: `window.engine = engine` is already declared; for a game's own, write `/** @type {any} */ (window).game = {...}`
140
- (`npm run types` reports properties on window as web hints, not errors).
141
- - To operate a running game use the dev bridge, see `recipes/16-dev-bridge.md`.
1
+ # Commands and debugging details
2
+
3
+ The scripts in `package.json` forward to the CLI `threedog` (from `@threedog/tools`; the root `build` runs each workspace's own `build`);
4
+ **`threedog xxx` on this page means `node node_modules/@threedog/tools/bin/threedog.mjs xxx`** (in this repo: `node packages/tools/bin/threedog.mjs xxx`): plain node starts fastest. `npm run xxx` runs the same command (npx adds about 2.5 s per call, so it is not used here). The tools find every path through their `paths.mjs`, in the engine repository and in a game
5
+ installed from npm alike. Every command checks its options: an unknown or misspelled one fails and lists the valid ones (dev bridge commands read their own options; `dev` / `build` / `preview` pass theirs to vite).
6
+
7
+ ## Running one game only
8
+ After `-w` write the directory or the package name (inside a game directory a plain `npm run ...` does the same):
9
+ - Dev: `npm run dev -w games/my-game`, or from the root `npm run dev -- my-game` (part of the name is enough); no name means the engine example. To
10
+ change the port (default 5173; if taken it moves to the next one): `npm run dev -- my-game --port 5000` (the game name must come first, the
11
+ remaining arguments go to vite untouched; don't add another `--`).
12
+ - Test: `npm test -w games/my-game`, or `threedog test -w my-game`; `npm test` at the root tests every workspace (engine + each game).
13
+ - Build: `npm run build -w games/my-game`; `npm run build` at the root builds all (every *.html in a workspace root is bundled, no change to
14
+ vite.config.js needed); under a sub-path of a site: `threedog build my-game --base /my-game/` (recipes/61-deploy.md).
15
+ - Screenshot / bake / compress models: `npm run shot -- -w my-game / --describe-only` (`--out day.png` your own name, still in `.threedog/shots/` (a path with a directory is written as given), `--tier low|high` render at that device tier (default: the desktop tier, skipped effects are named), `--keep` timestamped file name; the rest in the table below), `npm run bake -- -w my-game`, `npm run assets -- optimize -w my-game`.
16
+ - A game's tests: every `games/<game>/tests/specs/*.mjs` runs (each exports a `specs` array; the runner finds the files, nothing to register); without
17
+ `tests/specs/` a smoke test runs automatically (page opens, engine ready, no console errors). Minimal example:
18
+ ```js
19
+ // games/my-farm/tests/specs/farm.mjs — export a specs array, one entry per page
20
+ export const specs = [{
21
+ name: 'farm: pick up apple', // threedog test apple matches by name substring, any case
22
+ url: '/?cutscene=skip', // page path + URL parameters
23
+ async run({ page, check, ev, frames, wait }) {
24
+ // ev(fn, arg): runs in the page (engine is available). The function is serialized, so it can't use outer variables; pass them as the argument:
25
+ const n = await ev(id => engine.inventory.count(id), 'apple');
26
+ check('no apple at start', n === 0, `actual ${n}`); // check(label, passed, details on failure)
27
+ await page.keyboard.press('KeyE'); // page is a Playwright page: keys, clicks
28
+ await frames(3); // wait 3 frames of the real-time loop (software rendering is slow; waiting by frames is more reliable than wait(ms))
29
+ check('has apple after pickup', await ev(id => engine.inventory.count(id), 'apple') > 0);
30
+ },
31
+ }];
32
+ ```
33
+ Tests run against the built bundle (not the dev server): main.js must set `window.engine = engine;` before `await engine.start()`, otherwise the
34
+ test waits for the engine until timeout (the error explains why).
35
+ A spec whose run() reads pixels (`page.screenshot`) moves to software rendering, which is much slower; `software: false` on the spec keeps it on the GPU for a real picture. Frame times measured beside other pages read several times too high: give such a spec `serial: true`, or run with `--jobs 1`. A spec file and what it imports run in Node. Importing `threedog` there works, but a file that touches `document` or `window` at its top level fails: move that code into a function, move plain data into a file of its own, or read the value in the page through `ev`.
36
+ A test that steers: `frames(n)` and `wait(ms)` follow the machine, so under load the same script takes a different path. Hold the loop with
37
+ `engine.haltLoop('my-test')` and advance game time yourself, `await page.keyboard.down('KeyW'); await ev(() => engine.step(0.25));`: the same steps give the same path on any machine.
38
+ - New game: `npm run new-game -- name [--open-world | --pixel] [--webgl]` (the blank and `--open-world` starts: `recipes/01-new-game.md`; `--pixel` starts a sprite character in a pixel-snapped orthographic view with input, interaction, dialogue and saves wired, gray placeholders, not together with `--open-world`; the game runs on WebGPU and writes shaders in TSL, `--webgl` on WebGL with GLSL).
39
+ - Game in your own folder (outside this repo): after `npm install threedog@1 three@~0.187.0 @threedog/tools@1`, run `node node_modules/@threedog/tools/bin/threedog.mjs init [folder] [--open-world] [--webgl]` (folder: the one to create, default the current folder): it copies the new-game template without overwriting anything, merges package.json and writes `.mcp.json`, so Claude Code opened in that folder starts the threedog MCP server by itself.
40
+
41
+ > Git Bash (MSYS) rewrites arguments that start with `/` into a path under the Git install (`/` turns into `C:/Program Files/Git/`). Page arguments (`shot`, `capture`, `--page`) undo that by themselves, through `npm run` too (npm still echoes `> threedog shot C:/...`; shot then prints the page it really opens); if the Git folder cannot be found the error says so: then write `shot styletest`, set `MSYS_NO_PATHCONV=1`, or use PowerShell.
42
+
43
+ > Windows PowerShell 5.1: `Get-Content` / `Set-Content` without `-Encoding utf8` read and write UTF-8 files in the system code page (mojibake, lost newlines). Pass `-Encoding utf8`, or edit files with your editor tools.
44
+
45
+ ## Command table
46
+ | Command | When to use |
47
+ |---|---|
48
+ | `npm run dev` | Development. Browser errors are sent automatically to the terminal and to the workspace's `.threedog/errors.log` (e.g. `games/my-game/.threedog/errors.log`): read that file first when something breaks, before taking screenshots. Known error classes carry `Possible cause: …` and `Read: recipes/…` lines (tables `core/base/errorCodes.js` for engine errors, `core/base/errorHints.js` for browser / JavaScript ones) |
49
+ | `npm run check` | Run after every change (order: if the docs need regenerating `map` -> `check` -> related tests; otherwise `check` -> related tests): rule checks (`packages/tools/rules/`, the engine's hard rules among them; detection and allowlists are at the top of each file; the save round trip is in npm test) + types + content validation + generated docs up to date. Errors print in full, warnings as one count line per rule; `-- --verbose` lists them (the first 15 per rule), `-- --all` every one. `-- --rule R4` runs one rule (`R04` works; an unknown id fails and lists them), `-- -w game` (or `threedog check -w game`, or `check` run inside a game folder, as `new-game` does) reports only that game's rule, type and content problems and sets the exit code from them alone, with other games and the engine as one count line each; plain `check` at the repo root stays repo-wide (run it before committing engine changes); `-- --json` prints one JSON result instead (shape below, text to stderr, same exit code) |
50
+ | R40 bypass hints (part of `check`, warnings only) | Game code that hand-rolls what an engine system does is pointed to that system: timers (also `await new Promise(r => setTimeout(r, ms))`), `Math.random`, an inventory, quests, grid/height blending, a localStorage save (any `setItem` except an obvious preference), pause, a settings menu, raw `keydown` listeners, `AudioContext`, a dialogue box, a loading screen, a language table, an interact-distance check, box collision, an `AnimationMixer`, a `requestAnimationFrame` loop, a camera follow, a particle loop, a tween, a pool of shots, a pointer raycast, a physics library. Each system declares its own hint; it works the same in a game installed from npm. Plain `check` lists the first 5 and ends "check passed, N bypasses"; `check --rule R40` lists all. Off per line `// hint-off(kind)`, per file `// hint-off-file(kind)`, per project `package.json "threedog": { "hints": false | { "kind": false } }`, per run `THREEDOG_HINTS=off`. A deliberate choice goes in DESIGN.md Systems |
51
+ | `npm run types` | Type check only (does game code misuse the engine API). Plain JS TypeScript cannot follow (a field added to your own object later, a union from your own ternary, TSL node inference) is a `!` hint, not an error: no `// @ts-nocheck` needed |
52
+ | `npm test` | Full browser tests (slow; test pages run in parallel, `-- --jobs N` sets how many, `--jobs 1` one at a time; without `--jobs`, at most 2 software-rendered pages at once; a spec with `serial: true` runs alone; a failure that happens only beside other pages is retried alone and listed). Normally `threedog test name` runs only the related ones (matched by test-name substring, any case, e.g. `-- hlod`; a word that matches nothing fails), `-- -w game` tests one game. Prints only failed items (with their failed checks), a progress line and the summary; `-- --verbose` prints every check. `-- --update-snapshots` makes tests that use `expectDescribe` write their describe baselines (`tests/snapshots/*.describe.json`) instead of comparing. `threedog test pack` (the build test): after a real build of each game, open only dist from a static server and check that the engine is ready, no 4xx resources, no console errors; `-- --json` prints the result as the same JSON shape, one item per failed check |
53
+ | `threedog session [--minutes N]` / `session stop` / `session status` | Optional: keeps one small local process alive (127.0.0.1, token, `.threedog/session.json`) so later bridge commands skip module loading (about 0.1 to 0.15 s less per command); exits by itself after N idle minutes (default 10). Every command works the same without it: no session, a dead one or an unreachable one falls back to a direct call. Restart it after editing the tools |
54
+ | `threedog bake light [-w game] [--out public/light/level.lightmap] [--size 1024] [--samples 128] [--page /]` | Bake a lightmap of the meshes marked `userData.static` in system Chrome on the real GPU; stops if WebGPU is not real. `recipes/34-environment-lighting.md`. `--samples` is rays per texel: raise it if flat walls look blotchy. A map with no light fails and writes nothing |
55
+ | `threedog art list <source>` · `threedog art copy <source> [names…] [--to art/] [--force] [--dry]` | Reuse art code by copying it into this game (no dependency, no link back): the source is a game folder (its `art/`), a local folder or file, or an installed package. What `list` shows and what `copy` brings along: the recipe. MCP: `art_list`. `recipes/09-materials-lights-models.md` section 2a |
56
+ | `threedog art board [-w game] [--out file.html] [--json] [--live] [--lib dir]` | Every art resource of one game on one page (default `.threedog/art-board/index.html`): models, textures, sounds, fonts, materials, shaders and library entries, each with a preview where one exists, its file, size and where it is used as file:line. Status: used, unused, missing, or not traced (a name built at run time or plain text that may mean it; never called unused). Each item copies one line for the AI; several items plus a note copy one request. `--json` prints the same data. `--live` also asks the running game (dev server, dev bridge) what it has really loaded; `?panel=1` shows the same list in folder "art". A model gets a picture once `threedog gallery --shots` has made one. |
57
+ | `threedog lib status [-w game] [--lib dir]` | What this game pulled from the library (read from its `.threedog-lib.json`, which every `lib pull` writes): each entry changed or not, and newer in the library or not. It only reports: a pull belongs to the game and nothing updates it |
58
+ | `threedog lib check [-w game]` | Do the things this game pulled fit together? Fails on a need nothing gives, on two entries writing one three.js value, and on code the game's renderer cannot run (GLSL in a WebGPU game, a node material in a WebGL game); sizes and styles that do not fit are notes. It reads the game's copies, so an edit or a port clears a clash |
59
+ | `threedog lib add <file|folder|exportName> [-w game] [--name n] [--summary s] [--kind k] [--use s] [--plug "makeIt({ ... })"] [--style a,b] [--usage s] [--no-proof] [--preview url|png] [--force]` · `threedog lib list [words] [--card] [-w game]` · `threedog lib pull <name> [-w game] [--to art/] [--plug "makeIt({ ... })"] [--force] [--dry]` · `threedog lib page` | Your own library of art and techniques from earlier games, kept outside the engine (`~/.threedog/library`; `THREEDOG_LIBRARY` or `--lib dir` moves it): one folder per entry with the copied files, `entry.json` (kind model / texture / material / shader / effect / module / other, summary, the use line, backends, params, which game and day it came from) and `preview.png`. `add` copies from a game the way `art copy` does (local imports, textures, models), summary defaults to the first JSDoc line, never replaces a different existing entry without `--force`; a model or texture gets the gallery turntable when the game registers it, a code entry a picture only with `--preview <url of a running scene>` or `--preview file.png`. `list` is one line per entry (words narrow it); `pull` copies an entry into this game and prints the use line with the path where the file landed. An entry that cannot draw on the game's renderer (`backends` in `entry.json`, `lib list` shows it, `lib list webgpu` narrows to it) is refused with nothing copied; `--force` copies it to port by hand. Where it lands goes by kind: a `picture` or `material` entry in `picture/` (a `.glsl` in `picture/shaders/`) with no wiring file, you import it yourself; a model or texture in `art/`; a `shader`, `effect` or `module` entry in `plugins/<name>/` plus the wiring file `plugins/<name>.js` that calls its factory (the entry's plug line, set by `add --plug`, else its exported function; `pull --plug` overrides), so it plugs at start with nothing hand-written; a `system` in `systems/<name>/` plus that wiring file; `page` writes `index.html` with all previews. MCP: `lib_list`. recipes/05-props-bake.md §2d |
60
+ | `threedog examples list` · `threedog examples pull <name> [--out dir] [--force]` | Technique and optional examples you copy and adapt (the list is `examples/pullable.json` in the engine package; the summary is each README's first line). `pull` copies the game-facing files to `<game>/techniques/<name>/` (or `--out`), never overwrites a changed file without `--force` (then nothing is written), prints the import line and the packages the code imports. An unknown name fails with did-you-mean |
61
+ | `threedog how "<task>" [--full]`, `--browse [category]`, `--card <id> [--full]` | One recommended route for a task in your own words (not the only allowed one): is it installed in this game, what is missing, a minimal example, the next route; `--full` lists the other routes. With no words, or `--browse`: the categories, then one line per capability. `--card`: what a capability solves, when it does not fit, install, dependencies, time, saves, an example and what verified it. The MCP tool `how` has the same three as fields `task`, `browse`, `card`. `recipes/51-capability-catalog.md` section 5 |
62
+ | `threedog content set <id> x=12 place=home … [--expect x=5] [--in props] [--file content/x.js] [--dry]` | Write a permanent change into the content entry (several fields, one write, all-or-nothing; refused when `--expect` no longer matches). `recipes/40-scene.md` |
63
+ | `threedog content add <kind> id=<id> field=value … [--file content/props/town.js]` · `threedog content remove <id> [--in kind]` | Append one entry at the end of a kind (always with an id) / delete one. Reads and checks only that file (id index `.threedog/content-index.json`). `recipes/40-scene.md` |
64
+ | `threedog content stamp <arrangement> id=stall-1 x=20 z=5 [rot=1.6] [--dry]` | (experimental) Copy `content/arrangements/<arrangement>.js` (recipe 30 section 7) into the game: one place in `content/places.js` and one plain props entry per part, id `<id>-<part>`, `source: <arrangement>`. An id clash lists every clash; any failure writes nothing |
65
+ | `threedog content set --source <arrangement> <part> field=value … [--dry]` | Explicit batch edit: the same change in that part of every copy, all or nothing, and it prints how many changed (`--dry` lists them first). Copies do not follow automatically, and the arrangement file is not changed. Without `--source`, `content set` edits only that entry |
66
+ | `threedog content capture <groupName> --as <arrangement> [--page /p.html] [--force] [--dry]` | (experimental) From the running game (dev server): read a named `THREE.Group`'s direct children (position, turn, scale relative to the group, named model or template of each) and write the arrangement. Placement only, never geometry. A child with no named model, a tilt or an uneven scale is listed by name with the fix, and nothing is written. Afterwards delete the code that placed the group, or it appears twice; `check` warns (R52) while its name is still in the code |
67
+ | `threedog mcp [--allow-js]` | The dev bridge as an MCP server over stdio. `recipes/16-dev-bridge.md` section 10 |
68
+ | `threedog assets check new.glb --against old.glb` | What the old export had and the new one lacks. `recipes/46-blender-art-route.md` |
69
+ | `threedog shot --cam x,y,z,tx,ty,tz[,fov]` | A camera pose (position, target, optional fov in degrees) with no view declared in the game: judge a building, a facade or a far backdrop from outside (`--pos` only places the player). Not with `--view`; negative numbers work with or without `=`. |
70
+ | `threedog shot --view name [--compare before.png]` | A named camera view (`engine.views.define`) and a pixel diff against an earlier picture. `recipes/46-blender-art-route.md` |
71
+ | Result of every bridge command | CLI text ends with one line on the game state and the way back (`Game loop halted, tick 180: threedog resume restores real-time running`; frozen by a menu says which). MCP adds `structuredContent` { ok, code, summary, runtime { ready, mode running|halted|frozen, tick, headless, blockedBy[] }, data } and an `outputSchema` on every tool. `code`: ok, blocked (ran, refused), not-ready, no-server / starting / busy / page-error / no-bridge (cannot reach the game), command-error. **Advance game time**: step, press, hold, skip, scenario, verify. **No game time**: op, state, eval, js, resume, reload. Everything else only observes. eval / js and describe with a path or --full / --all print no state line (parseable); runtime still has it. |
72
+ | `npm run map` | Regenerate CODEMAP, API.md + api/, each game's GAMEMAP and the event-name list (generated from `EventMap` in core.d.ts; add a new event to EventMap first) after changing code, JSDoc or content (run it before `check`) |
73
+ | `npm run shot -- / --time 18:30 --weather rain --pos x,z` (or `--at place`: in play at a named place) | Only when you need to see the picture; by default 1 image of 960x540 into the workspace's .threedog/shots/; **read the state as text first with `--describe-only`**. Under a picture it prints only what bears on it (time, weather, camera; the same lines as `threedog snap`); `--describe-only` and `--json` give the whole state. `/<page>.html` switches the page, `-w game` switches the game, `--wait seconds` advances time. The shot waits until loading is finished (`--load-timeout` seconds, default 120) and fails naming what is still pending, then for the game's own code after `await engine.start()` (no request open and the scene's objects / lights / materials unchanged for 0.3 s, at most 10 s; it prints how long and what was added; if the scene still changes after the picture, it warns that the picture may be incomplete); a page error before `window.engine` fails at once with the error. `--no-build` reuses the last dist/ (code unchanged); a playing cutscene is skipped unless `--keep-cutscene`; `--play` starts straight in play, past the title screen the way its Start does (the engine's `?play` URL key) |
74
+ | `npm run shot -- / [--ref image] [--no-picture] [--json]` · `shot http://localhost:5173/` · `shot --image file.png` | After every shot (and every `threedog snap`, on the live page): picture numbers measured on the 3D canvas and hints: contradictions, facts and intent, listed in recipes/35 "Picture check after every shot". Nothing fails and nothing is changed. Printed short: the numbers line (noon / midnight with each exposure when the two differ), then at most four one-sentence hint lines, contradictions first and then by measured size, and `N more: threedog shot --json (picture.hints)`. A few extra renders of the current view (about 0.3 s on a GPU), every touched value put back. `--json` prints one object (file, look, probe, every hint in full, describe) for MCP / the dev bridge. A full URL opens that already running page without a build, and a local server of another game's folder is refused (one that cannot say which game it serves gets a printed note); `--image` reads a picture taken any other way and gives the pixel part only (shares, near-white spots, intent), saying what needs the live page. A screenshot of your own skips the check: take pictures with `shot` or `snap`. recipes/35 |
75
+ | `npm run shot -- styletest --view room --time dusk --weather rain` | The fixed style-judging scene (`examples/styletest`, page `/styletest.html`; a bare name is a page of the workspace). Views and the `--time` / `--weather` words: recipes/35. Same arguments every round, so only the style differs. `--panel` is not a shot option: open `/styletest.html?panel=1` in a browser for the workbench (recipes/35) |
76
+ | `threedog capture [page] [--top N] [--no-spector] [--spector-url url] [--full] [--no-build]` | Find out what a frame draws: renders one steady frame headless and prints draw calls, shadow-map draws, render passes (post effects) and the largest draws with world record id, budget tag and material purpose. Also records the WebGL command stream of that frame with Spector.js (fetched on first use into `.threedog/cache/`, not a dependency) to `.threedog/captures/`; `--no-spector` skips it, `--spector-url` fetches it from another source. Works on the game's own renderer, WebGL or WebGPU, and prints which one it measured; Spector only runs on WebGL. A frame with no draws fails |
77
+ | `npm run bake` | Before release, or to take code-generated models into Blender: exports public/models/baked/*.glb (`-- -w game`) |
78
+ | `npm run assets -- check [glb or folder] [--json] [--strict]` | Inspect models without building (default art/models/; a game with no such folder has nothing to check and passes, and only models are read: sprite and texture PNGs are never looked at): the level manifest (spawns, col_ colliders, trigger_ zones, npcs, markers, template / id nodes, missing templates, duplicate ids), material and color-space suspicions (data texture in a color slot, BLEND, texture without UV, oversized texture), statistics. `--json` for tools, exit 1 on errors (`--strict`: on warnings too). `npm run check` also reads the level glbs for content validation |
79
+ | `threedog assets optimize [-w game] [--dry] [--force] [--budget MB] [--strict] [--lod [--lod-shares 0.5,0.2]]` (`npm run assets -- optimize`) | `--lod` also writes lower-detail levels and reports triangles per level, saying which models it skipped and why (recipe 15 §4a). Make game-ready copies of the models in art/models/ without touching them: Meshopt geometry, KTX2 textures encoded by slot (normal / occlusion / roughness maps as linear UASTC, color maps as sRGB ETC1S; each output texture is read back and checked against its slot), into public/optimized/. Writes `assets.optimized.js` and adds its import to assets.js, so the names point at the results. A rerun handles only changed files (content hash, options, tool versions). Per file: size before / after, estimated GPU memory, and problems (over `--budget` MB of texture memory, color space, texture without UV or without the second UV set it asks for). `--dry` writes nothing and reports the estimate. Needs `@gltf-transform/cli`. Textures are encoded by the `ktx` command (KTX-Software 4.3+) when it is on PATH, else by the WebAssembly encoder of the npm package `ktx2-encoder` (MIT; its Basis Universal build is Apache-2.0), which comes with the tools. The output says which encoder ran and how long encoding took. With neither, only this command fails and says what to install. Baked lightmaps are left as baked (banding after compression is not measured). Report: `.threedog/optimize-report.json` |
80
+ | `npm run perf` | Performance comparison (plain three.js vs engine vs per-module cost in openWorld). Prints the renderer first. `threedog perf -w my-game [frames]`: your game's page in play, standing still: frame ms, JS ms, draw calls, memory |
81
+ | `threedog stress [-w game] [--only a,b] [--frames 30] [--json]` | At what load this game drops: from a game folder (or `-w`) the load ramps go on top of the game's own scene on its own renderer in system Chrome, one axis at a time (extra meshes, triangles, instances, point lights), after a line with the game alone; then the load that fits 16.7 and 33 ms per axis. A WebGPU game on a browser without real WebGPU is refused. In the engine repo with no game it runs the neutral page `tests/stress/` for the engine's own measurements, and says so |
82
+ | `--gpu` · `--software` · `THREEDOG_RENDER=gpu` or `software` | Renderer of the headless browser. `shot`, the dev bridge's headless page, `gallery --shots`, `perf` and `stress` prefer the hardware GPU (ANGLE d3d11 / metal / vulkan), check the renderer string after launch and fall back to SwiftShader with one note line; tests that read rendered pixels (`software: true` on the spec; unmarked ones are caught at the end of a GPU run) start on SwiftShader (same pixels everywhere), the others on the GPU when it is reachable |
83
+ | `threedog content ids [-w game \| folder] [--write]` | Stateful content entries that rely on their index id: prints the id each has now as `-`/`+` lines (dry run); `--write` writes them in. Recipe 30, "Writing the ids, renaming them" | <!-- r18-ignore-line -->
84
+ | `npm run doctor` | Check the environment, one line per item: ✓ passed · ✗ problem -> fix · – info only; `-- --ci` does not fail the command on problems; `-- --json` prints the same shape as `check --json`: `{ ok, summary, items }` (items are the problems and info lines); exit code 0 only when `ok`. Checks Node version, node_modules, workspace links, package-lock consistency, `.threedog` writable, the physical copy (real path, version, package.json mtime) of engine / tools / three per context (check, run/build per game; a `MISMATCH` line when contexts use different copies, e.g. vendor/ vs node_modules), port 5173, the dev server recorded in `.threedog/dev.json`, then renders one real engine frame on software rendering (what tests use; failing is a problem) and on the GPU path (whether a hardware GPU is available to headless; info only), and whether `EXT_disjoint_timer_query_webgl2` gives GPU ms. Run it first when the environment acts strange |
85
+ | `threedog api-count [--unused] [--json] [--games dirA,dirB]` | Engine repository only: counts the public surface an AI meets (createEngine options, engine members and their sub-objects, module options and APIs, exports of `threedog` / `threedog/tsl` / `@threedog/post-effects`, CLI commands and options, error codes) from the type declarations, one line per group; `--unused` lists the items no engine source, example, template or recipe code block uses (deletion candidates, a name heuristic); unused items kept on purpose (CLI commands, error codes, tuning options with a default) are reported apart as `kept`. For engine maintainers deciding what to delete |
86
+ | `threedog picture palette <image> [--n 8] [--average] [--region x,y,w,h] [--ignore-ui] [--crop out.png] [--json]` | Dominant colors of a reference picture and a one-line summary. `--average` adds the mean color (HSL); `--region` measures one rectangle; `--ignore-ui` cuts a flat frame around the picture (edge row / column one flat color, frame 3% to 45% of the picture; a plain sky at the edge looks the same, so check with `--crop out.png`, which saves the measured area). The output says what was measured; `--json` prints the JSON only (summary inside). A path that starts with `-` goes after `--`. A measurement, not a design decision |
87
+ | `threedog picture compare <reference> <screenshot> [--region x,y,w,h] [--ref-region ..] [--shot-region ..] [--json]` | Differences as numbers: brightness, saturation, contrast (std of luma), fine detail (variance of the Laplacian of luma; read as a ratio), average and main color (hue / saturation / lightness), plus one neutral sentence ("18% darker, 2.3x more broken up"). Both pictures are scaled down to one size, never enlarged (detail is measured at the smaller picture's scale), and the notes say so. Regions are matched by position: a shifted feature shows as a large hue difference, so cut the same content with `--ref-region` / `--shot-region`. **An aid to judging, not a replacement for looking; no number is a quality score and there is no "similarity %".** recipes/35 |
88
+ | `?panel=1` with `import('@threedog/tools/panel').then(m => m.openPanel(engine))` | The dev panel in any game: live sliders straight on the three.js objects, "write back" for `threedog tune`. `recipes/35-picture-from-reference.md` |
89
+ | `threedog tune show [-w game]` · `threedog tune write [file] [--apply] [-w game]` | Values from `.threedog/tune.json` as one `// threedog:tune begin ... end` block of plain three.js writes (`engine.scene.fog.far = 90;`, `material.setValues` by name, UI CSS variables) in `file`. A later write merges into the block, so values the panel no longer holds stay; delete a line to drop it. Model generator params (the panel's models folder) become the `default` in that model's `params` schema where it is registered (no file needed for those). Without `--apply` it only prints the diff. `recipes/35-picture-from-reference.md` |
90
+ | Tuning without a mouse | The panel is for a person. An AI does not need it: try values with `threedog js` (`engine.scene.fog.far = 90`), look with `threedog snap`, then write what it settled on into `.threedog/tune.json` as `{ "values": { "engine.scene.fog.far": 90, "engine.scene.background": "#336699" }, "css": { "accent": "#7fd3ff" }, "materials": { "rock": { "roughness": 0.8 } }, "models": { "tree": { "height": 4 } } }` and run `threedog tune write main.js --apply`. Or write the value straight into the code; the file only saves reviewing the change first |
91
+ | `threedog gallery [-w game] [--port 5181]` · `threedog gallery --shots [--size 256] [--only a,b] [--mode silhouette,value]` | Every registered model and texture on a turntable under three neutral light setups (midday, low sun, overcast; tone mapping copied from the game). Without `--shots` it serves the game in dev and prints the `?gallery=1` URL (any dev page opens it with `?gallery=1`); `--shots` writes `.threedog/gallery/<name>-<light>.png`, `index.html` and `index.json` headless. `--mode` adds review pictures beside them: `silhouette` (each model pure black on white: `fill`, `boxFill`, `aspect`) and `value` (the midday shot as grayscale luminance: `p5` / `p50` / `p95` inside the outline); the facts are printed per asset and stored in `index.json`, with no thresholds. `recipes/05-props-bake.md` section 2c |
92
+ | `npm run build` | Bundle each workspace into its own dist/ |
93
+ | `threedog preview [game]` (or `-w game`, as for dev and build) | Serve a workspace's built dist/ (vite preview) to open the production build in a browser. It is the shipped game, so URL keys (`?play`, `?time`…) are not read; `shot`, `test` and `dev` read them, or set `createEngine({ urlState: true })` (`?fresh` stays dev-only) |
94
+ | `threedog relay [port]` | The WebSocket relay for the net module (default port 8787, no dependencies). `recipes/27-net.md` |
95
+
96
+ **`--json` result** (`check`, `test`): one line on stdout, `{ ok, summary, items: [{ code, level, file, line, message, fix }] }`. `level` is `error` or `warn`; a field is present only when known. `code` is the rule id (`R4`), a TypeScript code (`TS2345`), `content` or `test`. A test item's message is `<item name>: <check> → <reason>`; the totals are in `summary`. `ok` and the exit code agree.
97
+
98
+ ## Dev bridge commands
99
+ They drive the running game. Run them inside the game folder or with `-w game`; at the repo root the one running dev server is used (several: the error lists them for `-w`). `threedog <command> --help` prints the same line. `recipes/16-dev-bridge.md`
100
+
101
+ <!-- rows written by npm run map from packages/tools/threedog/command-table.mjs: edit them there -->
102
+ | Command | What it does |
103
+ |---|---|
104
+ | `threedog describe` | compact scenario description (--full for the describeText summary, --all for everything, describe player.x for one item, --max characters); recipes/16-dev-bridge.md |
105
+ | `threedog step` | advance N real seconds: step 2. The loop stays halted afterwards (threedog resume) |
106
+ | `threedog skip` | jump the clock like sleeping: skip to=06:00 / skip seconds=600 (engine.skip: op time.skip, sky clock and time-keeping modules catch up; optional fade=0.6 save=auto). to works with calendar() alone; the sky only follows the clock when installed |
107
+ | `threedog press` | press a key or action: press interact / press KeyE / press e (held 0.1 s, then renders 1/60 s; --for 0.02 shortens the hold) |
108
+ | `threedog hold` | hold for N seconds: hold moveForward 1.5. moveForward walks along the camera's heading, so with a follow camera at its start angle it goes diagonally, not along an axis: place things by reading player after a short hold |
109
+ | `threedog state` | change the scenario without a reload: state time=18:30 weather=rain pos=40,-20 (pos=x,z has no height: the hero stands on the highest support over that spot, a ledge included; to stand under it, js "engine.player.placeAt([x, y, z])") |
110
+ | `threedog js` | evaluate an expression in the page (engine is available, await works; one expression prints its value, several statements print what they return): js "engine.calendar.timeOfDay"; long scripts: js --file path. A script that calls assert(cond, msg) or expect(v).toBe/toEqual/toBeCloseTo/toBeGreaterThan(x, msg) (or expect(v, msg)) runs as checks in ONE call: failed checks are recorded and the script goes on, a throw stops it; output ✓ 7 checks passed, or the failures then ✗ 2 of 7 checks failed; exit 1 on failure; --verbose adds passes, log lines and the return value. A script without those calls is the plain form. Both modes get the globals engine, step(seconds), log(...), assert, expect. --wait <seconds>, default 120: how long a script may wait on a page that looks stopped (driven by manual step, nothing loading, no clock tick); the command then ends and says the script may be waiting on the game clock, and the script may still run in the page |
111
+ | `threedog snap-describe` | describe snapshot instead of a screenshot, a baseline of the gameplay part of describe(): snap-describe save\|diff name [--only a,b] [--ignore x.y] [--tolerance 0.5] (recipes/16-dev-bridge.md section 7); in tests one line expectDescribe({ check, ev }, name, { only, tolerance }) from @threedog/tools/describe-snapshot |
112
+ | `threedog snap` | save a screenshot to .threedog/shots/name.png and run the picture check on the page, as threedog shot does (snap name, or snap path/to/file.png used as given; --play first leaves the title as shot --play; --width N scales the returned image down, the saved file stays full size; --no-picture skips the check) |
113
+ | `threedog errors` | page errors with id (E1…), time, tick, source and count; the same error repeated is one line with its first and last id / time and ×N. errors = new since the last read; errors latest [N] = the last N (default 3), same answer every time; errors --since E5 = after id 5, never moves the read position. Every result prints a cursor (known classes come with the cause and the doc page) |
114
+ | `threedog reload` | reload the page |
115
+ | `threedog resume` | resume real-time running (the page is halted after step / press) |
116
+ | `threedog ops` | what the player can do now (each op offer checked with can): ✓ shop.buy shop=bakery item=bread · ✗ … (reason); recipes/23-ops.md |
117
+ | `threedog op` | run an op as source bridge (no time passes): op shop.buy shop=bakery item=bread n=2 (values converted by the op args shape) |
118
+ | `threedog inspect` | what is around the player (or inspect npc_3 / inspect 10,-4) and which ops it can do now, with reasons. inspect materials (engine.inspect.materials(), plain three.js: scene.traverse + texture.colorSpace) = every material: textures (slot, size, color space, estimated GPU MB, shared-by), engine- or game-made, shader patches and their slots, meshes sharing it; materials that read the same are one line with ×N; wrong color spaces first (color map not sRGB = washed out; normal / roughness map marked sRGB). inspect perf (engine.inspect.perf(), plain three.js: renderer.info) = the last frame against budgets: draw calls, triangles, programs, texture MB (estimate), JS ms by phase, compile stalls during play, costliest programs; ✗ lines name the next call. Budgets: engine.budget limits, else a desktop reference. The engine benchmark suite is npm run perf |
119
+ | `threedog scene` | the mesh exists but is not drawn: use this first. Counts, one Not drawn because: line over every Mesh / Points / Line / Sprite, then the first 6 undrawn ones (surprising before plain view culling) with every reason, most likely first: visible=false on it or a parent, layers vs camera, material flags, scale 0 / NaN, NaN position or vertices, empty geometry, behind the camera, beyond camera.far, outside the view. "maybe" reasons (depthWrite off, fully fogged...) do not stop drawing. scene [--hidden (only undrawn)] [--limit N \| --full (40)] [--json]. Code: engine.inspect.scene(). Cannot see shader output |
120
+ | `threedog pick` | what is at screen pixel x,y (from the canvas top-left): pick 480,270 -> record id, kind, template, where it is defined (content file:line), fields |
121
+ | `threedog explain` | why: explain op shop.buy shop=bakery item=bread (can it run; --full adds its last attempt) / explain quest first-light (where it is stuck) / explain value fog.far (which line last changed it) / explain thing player-chest (where it is defined; --full: everything about the id as JSON) / explain module quests / explain capability ground. engine.explain; recipes/23-ops.md, recipes/40-scene.md section 9, recipes/62-picture-code.md |
122
+ | `threedog scenario` | run one scenario test (tests/scenarios/<name>.json) on this page: scenario barter (prints failed checks and the Coverage block of verify; the scenario leaves the page halted) |
123
+ | `threedog catalog` | what the game can do, from its registrations: catalog = a line per module with ops or problems, the rest named on one line (--full: a line each); catalog shop = one module (dependencies, params + defaults, ops with args and failure codes, saved parts, time hooks, problems, doc / recipe / source files); catalog shop.buy = one op; catalog --find throw; --json for the raw data; recipes/51-capability-catalog.md |
124
+ | `threedog loading` | what loading waits for / what failed / does it block the start (answers while start() is stuck); loading hero: one task with its manifest and path; recipes/05-props-bake.md |
125
+ | `threedog play` | start the game for the AI: starts the dev server if none runs (detached, output in .threedog/dev.log), waits for the bridge and the engine, prints the page address and whether a headless or a live browser page is connected (play --stop stops the server play started) |
126
+ | `threedog impact` | before a change, what it touches, from the files alone: impact coin / impact shop.buy / impact stack / impact collider3d lists content, calls, saved parts, templates, tests and engine facts, then says what it cannot see (names computed in game code, what only a page or a save holds). --full lists every place |
127
+ | `threedog report` | one file another AI can rerun a problem from: engine version, seed, tick, describe, recent ops, errors with hints, modules and capability state, steps to reproduce and a derived scenario; no tokens or user paths. Writes .threedog/reports/ (--out file); --scenario also writes tests/scenarios/report.json for threedog verify report. Works with no page, and says what is then missing |
128
+ | `threedog status` | is it ready: engine ready / loading / page errors / running, halted or frozen. When the bridge cannot answer it names one of five causes with one next step: no server (threedog play), server still starting (wait, status again), server busy and not answering in time (wait, status again), page script error (threedog errors latest), no dev bridge installed (use gameConfig) |
129
+ | `threedog verify` | run a scenario (tests/scenarios/<name>.json) and report PASS / FAIL, what it tested (ops with outcomes, describe sections compared, time advanced) and what it never touched (ops never run, sections never compared, steps skipped after a failure, key path, picture): verify barter. Also a Layers: line (steps by layer: direct = op/describe call, simulated-input = bridge press; real-browser-input is always 0 and printed as not verified, visual 0 because scenario snapshots are describe, not pixels), tests that mention an error code seen, and the threedog test command to re-run. A page error during the run fails it. JSON adds layers / layerCounts / evidence (per-check layers, notProven, ops / modules coverage; text: Evidence, NOT proven, Coverage: ops ran/total with refused ones marked, modules tested / indirect / untested, lists capped with "+N more") |
130
+ <!-- end of generated rows -->
131
+
132
+ ## Reproducing a scenario and debugging
133
+ - Add `?time=18:30&weather=rain&pos=40,-20&save=slot1&cutscene=skip&state=name` to the URL (effective in development).
134
+ - In the console / tests: `engine.describeText()` reads the state as English text; `engine.step(seconds)` fast-forwards synchronously (no rendering);
135
+ `engine.haltLoop()` stops the real-time loop.
136
+ - To wait for the page: `page.waitForFunction(() => window.engine?.stateApplied)` (start has finished and all URL parameters are applied), then read `engine.stateRefused` for what the URL could not do (`shot` and `capture` fail on it); never read
137
+ `_`-prefixed private fields. When the dev bridge / `npm test` / `npm run shot` cannot reach the engine (no `window.engine` after 40 seconds, or it
138
+ exists but never becomes ready), the error states the page status, the latest page errors and the fix.
139
+ - Advancing dialogue headlessly: recipe 02.
140
+ - Debug objects on window: `window.engine = engine` is already declared; for a game's own, write `/** @type {any} */ (window).game = {...}`
141
+ (`npm run types` reports properties on window as web hints, not errors).
142
+ - To operate a running game use the dev bridge, see `recipes/16-dev-bridge.md`.
@@ -13,8 +13,8 @@ Current camera (one of followCamera / firstPersonCamera / fixedCamera / rtsCamer
13
13
  - `height?: number` How high above the character to look at (meters), default 1.4
14
14
  - `smoothing?: number` (experimental) Follow smoothing, default 10
15
15
  - `sensitivity?: number` Drag sensitivity, default 1
16
- - `minPitch?: number` Pitch range (radians)
17
- - `maxPitch?: number` (experimental)
16
+ - `minPitch?: number` Pitch range (radians), default 0.05 to 1.35. The camera never goes below the look point, so the view cannot look up (a tall building's roof stays out of sight); a negative minPitch looks up (recipe 21 section 4b)
17
+ - `maxPitch?: number` (experimental) Upper pitch limit (looking down), default 1.35 (about 77 degrees, not straight down)
18
18
  - `zoomStep?: number` (experimental) Zoom ratio per wheel notch, default 0.1
19
19
  - `groundClearance?: number` (experimental) Minimum camera height above the ground (meters), default 1.2
20
20
  - `invertY?: boolean` (experimental) Invert vertical
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "threedog",
3
- "version": "1.0.1",
3
+ "version": "1.1.0",
4
4
  "description": "Web 3D game engine on three.js: core + optional modules, no built-in art (the picture comes from your own style), built to be driven by an AI",
5
5
  "license": "MIT",
6
6
  "repository": {