threedog 1.1.0 → 1.3.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/CHANGELOG.md +893 -798
- package/README.md +1 -1
- package/core/assets/Animator.js +41 -3
- package/core/assets/Assets.js +100 -24
- package/core/assets/assetEntry.js +73 -20
- package/core/assets/assetHot.js +68 -16
- package/core/assets/assetLoad.js +6 -6
- package/core/assets/assetLod.js +9 -2
- package/core/assets/assetManifest.js +12 -2
- package/core/assets/assetPart.js +54 -0
- package/core/assets/ik.js +271 -0
- package/core/assets/modelNeeds.js +37 -0
- package/core/assets/namedModel.js +102 -29
- package/core/assets/nodeVisibility.js +15 -0
- package/core/audio/Audio.js +36 -4
- package/core/audio/audioReverb.js +99 -0
- package/core/audio/audioRules.js +1 -1
- package/core/audio/audioVoice.js +1 -1
- package/core/base/Events.js +14 -4
- package/core/base/Random.js +1 -1
- package/core/base/Vars.js +1 -1
- package/core/base/docRef.js +51 -0
- package/core/base/errorCodes.js +187 -126
- package/core/base/errorHints.js +9 -7
- package/core/base/errors.js +25 -10
- package/core/base/events.generated.js +2 -0
- package/core/base/freeParts.js +76 -0
- package/core/base/math.js +28 -0
- package/core/base/sections.js +5 -5
- package/core/base/validate.js +31 -3
- package/core/engine/Engine.js +17 -7
- package/core/engine/Loading.js +5 -3
- package/core/engine/copies.js +1 -1
- package/core/engine/headlessLoad.js +4 -1
- package/core/engine/lifecycle.js +32 -16
- package/core/engine/loop.js +71 -27
- package/core/engine/moduleSlots.js +2 -2
- package/core/engine/moduleTypes.js +3 -3
- package/core/engine/modules.js +65 -39
- package/core/engine/page.js +6 -3
- package/core/engine/services.js +6 -5
- package/core/engine/startup.js +8 -7
- package/core/input/Input.js +28 -14
- package/core/input/inputContext.js +28 -16
- package/core/input/inputKeyboard.js +31 -3
- package/core/input/inputPad.js +4 -0
- package/core/input/inputPointer.js +2 -1
- package/core/input/inputSeat.js +1 -1
- package/core/inspect/Budget.js +109 -19
- package/core/inspect/DebugOverrides.js +28 -4
- package/core/inspect/Describe.js +17 -9
- package/core/inspect/Inspect.js +4 -2
- package/core/inspect/InspectMaterials.js +3 -1
- package/core/inspect/InspectPerf.js +19 -9
- package/core/inspect/InspectScene.js +32 -7
- package/core/inspect/MaterialInfo.js +19 -2
- package/core/inspect/UrlState.js +50 -28
- package/core/inspect/catalog.js +28 -9
- package/core/inspect/debugView.js +2 -1
- package/core/inspect/describeRender.js +25 -13
- package/core/inspect/describeText.js +14 -6
- package/core/inspect/lightWatch.js +1 -1
- package/core/inspect/metadata.generated.js +35 -17
- package/core/inspect/pictureChecks.js +148 -0
- package/core/inspect/pictureMenu.js +84 -0
- package/core/inspect/pictureWriters.js +26 -6
- package/core/inspect/textureBytes.js +12 -2
- package/core/inspect/toolDoor.js +2 -4
- package/core/ops/Ops.js +11 -4
- package/core/ops/holds.js +27 -10
- package/core/ops/opsAtomic.js +15 -7
- package/core/ops/opsGuard.js +2 -2
- package/core/ops/opsRun.js +8 -7
- package/core/ops/sharedPoint.js +72 -21
- package/core/ops/stacks.js +56 -16
- package/core/saves/SaveStore.js +9 -3
- package/core/saves/Saves.js +32 -23
- package/core/saves/saveApply.js +96 -44
- package/core/saves/saveIds.js +1 -1
- package/core/saves/saveVersions.js +7 -5
- package/core/saves/session.js +17 -8
- package/core/saves/stateReplace.js +34 -15
- package/core/scene/Rays.js +52 -10
- package/core/scene/Views.js +36 -15
- package/core/scene/adaptive.js +144 -21
- package/core/scene/drawOnly.js +17 -0
- package/core/scene/gameLights.js +47 -4
- package/core/scene/sceneMethods.js +13 -11
- package/core/scene/stepPoses.js +11 -3
- package/core/scene/targeting.js +5 -3
- package/core/scene/thingOps.js +1 -1
- package/core/scene/tier.js +15 -0
- package/core/stream/Batching.js +30 -7
- package/core/stream/Stream.js +26 -7
- package/core/stream/batchGroups.js +2 -2
- package/core/stream/chunkStream.js +7 -5
- package/core/stream/prepare.js +77 -0
- package/core/time/skip.js +3 -1
- package/core/time/time.js +4 -2
- package/docs/AI.md +82 -83
- package/docs/API.md +16 -16
- package/docs/CODEMAP.md +17 -11
- package/docs/COMMANDS.md +139 -142
- package/docs/CONVENTIONS.md +37 -49
- package/docs/MIGRATING-0.8.md +2 -2
- package/docs/MIGRATING-1.0.md +2 -2
- package/docs/THREE.md +30 -35
- package/docs/api/assets.md +3 -1
- package/docs/api/audio.md +4 -2
- package/docs/api/budget.md +5 -0
- package/docs/api/characters.md +10 -8
- package/docs/api/collision.md +6 -4
- package/docs/api/engine.md +16 -16
- package/docs/api/events.md +3 -2
- package/docs/api/ground.md +6 -5
- package/docs/api/hud.md +4 -2
- package/docs/api/input.md +5 -5
- package/docs/api/particles.md +2 -1
- package/docs/api/photo.md +3 -0
- package/docs/api/post.md +7 -4
- package/docs/api/quests.md +2 -2
- package/docs/api/rays.md +1 -2
- package/docs/api/saves.md +7 -7
- package/docs/api/settings.md +2 -2
- package/docs/api/tools.md +3 -1
- package/docs/api/vars.md +1 -1
- package/docs/api/vegetation.md +4 -2
- package/docs/api/world.md +1 -1
- package/docs/recipes/01-new-game.md +16 -17
- package/docs/recipes/02-npc.md +22 -18
- package/docs/recipes/03-items-pickups.md +37 -35
- package/docs/recipes/04-quests.md +15 -10
- package/docs/recipes/05-props-bake.md +101 -95
- package/docs/recipes/06-clock-events.md +28 -28
- package/docs/recipes/07-flow-scenes-pause.md +29 -26
- package/docs/recipes/08-weather-sky.md +52 -64
- package/docs/recipes/09-materials-lights-models.md +26 -17
- package/docs/recipes/10-blender-level.md +15 -10
- package/docs/recipes/11-vehicles.md +12 -7
- package/docs/recipes/12-navmesh.md +44 -26
- package/docs/recipes/13-animation.md +56 -45
- package/docs/recipes/14-custom-module.md +21 -18
- package/docs/recipes/15-perf.md +61 -55
- package/docs/recipes/16-dev-bridge.md +24 -33
- package/docs/recipes/18-world.md +36 -42
- package/docs/recipes/19-shooting-picking.md +20 -15
- package/docs/recipes/20-content-actions-save.md +48 -56
- package/docs/recipes/21-camera.md +45 -54
- package/docs/recipes/22-shop-gold.md +12 -7
- package/docs/recipes/23-ops.md +25 -23
- package/docs/recipes/26-ui-parts.md +67 -47
- package/docs/recipes/27-net.md +12 -7
- package/docs/recipes/28-terrain.md +24 -21
- package/docs/recipes/29-grid.md +32 -27
- package/docs/recipes/30-templates.md +21 -20
- package/docs/recipes/31-audio.md +39 -22
- package/docs/recipes/32-action-game.md +19 -14
- package/docs/recipes/33-stream-sources.md +15 -11
- package/docs/recipes/34-environment-lighting.md +126 -70
- package/docs/recipes/35-picture-from-reference.md +8 -8
- package/docs/recipes/36-ground-plants.md +27 -21
- package/docs/recipes/40-scene.md +19 -28
- package/docs/recipes/43-shader-patches-surfaces.md +15 -12
- package/docs/recipes/44-water-weather-hooks.md +34 -31
- package/docs/recipes/45-cascaded-shadows.md +35 -26
- package/docs/recipes/46-blender-art-route.md +7 -2
- package/docs/recipes/49-game-module-contract.md +13 -8
- package/docs/recipes/50-own-renderer.md +6 -2
- package/docs/recipes/51-capability-catalog.md +15 -8
- package/docs/recipes/52-around-the-picture.md +34 -32
- package/docs/recipes/53-ground-up-close.md +6 -1
- package/docs/recipes/55-mods-time-wrap.md +27 -19
- package/docs/recipes/56-webgpu-tsl.md +75 -43
- package/docs/recipes/57-control.md +18 -13
- package/docs/recipes/58-input.md +26 -16
- package/docs/recipes/59-depth-post-effects.md +8 -3
- package/docs/recipes/60-judge-the-picture.md +10 -9
- package/docs/recipes/61-deploy.md +5 -0
- package/docs/recipes/62-picture-code.md +72 -79
- package/docs/recipes/63-third-person-start.md +48 -45
- package/docs/recipes/64-particles.md +22 -10
- package/docs/recipes/65-swarm.md +18 -13
- package/docs/recipes/66-common-tasks.md +38 -35
- package/examples/action/.threedog/content-index.json +1 -1
- package/examples/action/GAMEMAP.md +2 -3
- package/examples/action/main.js +3 -3
- package/examples/action/picture/lights.js +3 -1
- package/examples/perf-island/.threedog/content-index.json +1 -1
- package/examples/perf-island/GAMEMAP.md +3 -3
- package/examples/perf-island/picture/lights.js +2 -1
- package/examples/plain-picture/GAMEMAP.md +1 -1
- package/examples/rc2d/GAMEMAP.md +1 -1
- package/examples/styletest/.threedog/content-index.json +1 -1
- package/examples/styletest/GAMEMAP.md +2 -2
- package/examples/styletest/main.js +1 -1
- package/examples/techniques/interior-light/README.md +3 -3
- package/examples/techniques/interior-light/interiorLight.js +2 -4
- package/examples/techniques/interior-light/picture/lights.js +2 -1
- package/examples/techniques/modular-building/picture/lights.js +3 -1
- package/examples/techniques/outlines-and-rim/picture/lights.js +3 -1
- package/examples/techniques/procedural-animation/README.md +1 -1
- package/examples/techniques/procedural-animation/main.js +1 -1
- package/examples/webgpu-tsl/GAMEMAP.md +1 -1
- package/examples/world/.threedog/content-index.json +1 -1
- package/examples/world/GAMEMAP.md +2 -3
- package/examples/world/art/humanoid.js +1 -1
- package/examples/world/main.js +6 -3
- package/index.d.ts +2 -2
- package/llms.txt +101 -0
- package/modules/ambience/Ambience.js +21 -5
- package/modules/calendar/index.js +9 -5
- package/modules/calendar/schedule.js +23 -8
- package/modules/camera/FirstPersonCamera.js +3 -1
- package/modules/camera/FollowCamera.js +10 -5
- package/modules/camera/RtsCamera.js +4 -3
- package/modules/camera/common.js +70 -8
- package/modules/camera/contract.js +1 -1
- package/modules/characters/Character.js +16 -10
- package/modules/characters/NPC.js +31 -19
- package/modules/characters/assetModel.js +14 -9
- package/modules/characters/astar.js +6 -1
- package/modules/characters/contract.js +2 -2
- package/modules/characters/index.js +34 -22
- package/modules/characters/movers/manual.js +1 -1
- package/modules/characters/movers/rapier.js +17 -2
- package/modules/characters/movers/simple.js +1 -1
- package/modules/characters/movers/support.js +16 -7
- package/modules/characters/npcAvoid.js +2 -2
- package/modules/characters/npcSim.js +3 -2
- package/modules/characters/pathAsync.js +24 -8
- package/modules/characters/pathJob.js +1 -1
- package/modules/characters/player.js +10 -9
- package/modules/characters/playerStrings.js +5 -5
- package/modules/characters/proceduralRig.js +5 -5
- package/modules/characters/useModel.js +6 -0
- package/modules/characters/walkTo.js +1 -1
- package/modules/collision/Collision.js +29 -18
- package/modules/collision/grid.js +22 -4
- package/modules/content/index.js +3 -1
- package/modules/content/loader.js +1 -1
- package/modules/content/models.js +82 -33
- package/modules/content/props.js +2 -1
- package/modules/content/rules.js +11 -5
- package/modules/content/templates.js +3 -3
- package/modules/content/words.js +2 -2
- package/modules/debug/DebugPanel.js +9 -9
- package/modules/flow/index.js +9 -6
- package/modules/gameplay/Dialogue.js +34 -20
- package/modules/gameplay/Interactions.js +19 -15
- package/modules/gameplay/Inventory.js +9 -4
- package/modules/gameplay/Quests.js +12 -10
- package/modules/gameplay/pickups.js +23 -11
- package/modules/grid/index.js +1 -1
- package/modules/grid/preview.js +2 -2
- package/modules/grid/tiles.js +1 -1
- package/modules/hlod/index.js +4 -1
- package/modules/hud/index.js +47 -10
- package/modules/hud/parts.js +28 -9
- package/modules/level/geometry.js +8 -3
- package/modules/level/index.js +10 -5
- package/modules/level/load.js +4 -2
- package/modules/lights/sources.js +1 -1
- package/modules/music/Music.js +22 -4
- package/modules/nav/index.js +20 -10
- package/modules/particles/Particles.js +31 -14
- package/modules/particles/effect.js +20 -5
- package/modules/particles/lit.js +72 -0
- package/modules/photo/Photo.js +72 -28
- package/modules/photo/pathTrace.js +106 -0
- package/modules/rigid/RigidBodies.js +23 -14
- package/modules/rigid/Vehicles.js +3 -13
- package/modules/rigid/sync.js +2 -1
- package/modules/settings/Settings.js +52 -20
- package/modules/settings/apply.js +23 -9
- package/modules/settings/sections.js +39 -6
- package/modules/settings/strings.js +2 -0
- package/modules/settings/view.js +19 -3
- package/modules/sky/dome.js +15 -3
- package/modules/sky/environment.js +28 -12
- package/modules/sky/fog.js +1 -1
- package/modules/sky/frame.js +6 -1
- package/modules/sky/shader.js +4 -3
- package/modules/sky/skyModule.js +8 -4
- package/modules/swarm/Swarm.js +1 -1
- package/modules/terrain/ChunkManager.js +61 -15
- package/modules/terrain/chunkJob.js +2 -2
- package/modules/terrain/index.js +20 -5
- package/modules/terrain/terrainEdit.js +8 -4
- package/modules/terrain/terrainTexture.js +4 -2
- package/modules/timeline/Timeline.js +4 -3
- package/modules/timeline/Tween.js +3 -0
- package/modules/timeline/letterbox.js +1 -0
- package/modules/triggers/index.js +36 -17
- package/modules/vegetation/Vegetation.js +81 -19
- package/modules/vegetation/densityMap.js +13 -8
- package/modules/vegetation/draw.js +147 -24
- package/modules/vegetation/groundChunks.js +20 -5
- package/modules/vegetation/index.js +3 -3
- package/modules/vegetation/modelGeometry.js +9 -4
- package/modules/water/Water.js +11 -8
- package/modules/weather/Weather.js +7 -2
- package/modules/weather/shaders.js +25 -5
- package/modules/weather/weatherDraw.js +20 -6
- package/modules/world/World.js +2 -1
- package/modules/world/index.js +2 -2
- package/modules/world/persist.js +6 -2
- package/modules/world/views.js +15 -2
- package/package.json +5 -1
- package/presets.js +5 -5
- package/render/PostFX.js +102 -42
- package/render/backend.js +142 -16
- package/render/bindingLimits.js +59 -0
- package/render/cascades.js +3 -1
- package/render/cascades.tsl.js +2 -0
- package/render/daylight.js +7 -1
- package/render/detail.js +7 -4
- package/render/effects.js +27 -8
- package/render/fogLook.js +24 -0
- package/render/fuse.js +5 -2
- package/render/fx/compareLevel.tsl.js +23 -0
- package/render/fx/detail.tsl.js +9 -7
- package/render/fx/index.js +9 -2
- package/render/fx/library.tsl.js +1 -0
- package/render/fx/lightShaft.tsl.js +114 -0
- package/render/fx/noise.tsl.js +25 -8
- package/render/fx/objectOrigin.tsl.js +39 -10
- package/render/fx/particles.tsl.js +23 -6
- package/render/fx/patchNodes.tsl.js +17 -12
- package/render/fx/pcss.tsl.js +51 -0
- package/render/fx/postWebGPU.tsl.js +104 -29
- package/render/fx/sky.tsl.js +3 -9
- package/render/fxNumbers.js +10 -4
- package/render/impostor.tsl.js +107 -0
- package/render/lighting.js +33 -1
- package/render/lightmap.js +42 -28
- package/render/lights.js +19 -3
- package/render/materials.js +6 -4
- package/render/mergeCommon.js +4 -1
- package/render/occlusion.js +14 -4
- package/render/patches.js +79 -41
- package/render/postRuns.js +32 -0
- package/render/postWebGL.js +97 -10
- package/render/probes.js +10 -14
- package/render/shaderErrors.js +44 -7
- package/render/shadowCache.tsl.js +33 -5
- package/render/shadows.js +42 -16
- package/render/slots.js +8 -5
- package/render/vertexInputs.js +52 -0
- package/types/core.d.ts +115 -47
- package/types/gameplay.d.ts +56 -23
- package/types/generated/core/audio/Audio.d.ts +27 -1
- package/types/generated/core/base/Random.d.ts +1 -1
- package/types/generated/core/input/Input.d.ts +6 -8
- package/types/generated/core/input/inputSeat.d.ts +1 -1
- package/types/generated/core/inspect/Budget.d.ts +26 -0
- package/types/generated/core/inspect/DebugOverrides.d.ts +0 -2
- package/types/generated/core/saves/Saves.d.ts +10 -7
- package/types/generated/core/saves/session.d.ts +8 -2
- package/types/generated/core/scene/Rays.d.ts +1 -3
- package/types/generated/core/scene/Views.d.ts +17 -3
- package/types/generated/modules/particles/Particles.d.ts +1 -1
- package/types/generated/modules/world/World.d.ts +2 -1
- package/types/generated/render/PostFX.d.ts +35 -9
- package/types/physics.d.ts +796 -764
- package/types/pixel.d.ts +1 -1
- package/types/tsl.d.ts +62 -1
- package/types/world.d.ts +12 -3
- package/ui/Focus.js +7 -5
- package/ui/Parts.js +1 -1
- package/ui/touchPart.js +6 -3
package/docs/COMMANDS.md
CHANGED
|
@@ -1,142 +1,139 @@
|
|
|
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
|
|
5
|
-
|
|
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',
|
|
22
|
-
url: '/?cutscene=skip',
|
|
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}`);
|
|
27
|
-
await page.keyboard.press('KeyE');
|
|
28
|
-
await frames(3);
|
|
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,
|
|
37
|
-
|
|
38
|
-
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
| `npm run
|
|
49
|
-
|
|
|
50
|
-
|
|
|
51
|
-
| `npm
|
|
52
|
-
| `
|
|
53
|
-
| `threedog
|
|
54
|
-
| `threedog
|
|
55
|
-
| `threedog art
|
|
56
|
-
| `threedog
|
|
57
|
-
| `threedog lib
|
|
58
|
-
| `threedog lib
|
|
59
|
-
| `threedog
|
|
60
|
-
| `threedog
|
|
61
|
-
| `threedog
|
|
62
|
-
| `threedog content
|
|
63
|
-
| `threedog content
|
|
64
|
-
| `threedog content
|
|
65
|
-
| `threedog content
|
|
66
|
-
| `threedog
|
|
67
|
-
| `threedog
|
|
68
|
-
| `threedog
|
|
69
|
-
| `threedog shot --
|
|
70
|
-
| `threedog
|
|
71
|
-
|
|
|
72
|
-
| `npm run
|
|
73
|
-
| `npm run shot -- / --
|
|
74
|
-
| `npm run shot --
|
|
75
|
-
| `
|
|
76
|
-
| `
|
|
77
|
-
| `npm run
|
|
78
|
-
| `
|
|
79
|
-
| `
|
|
80
|
-
| `
|
|
81
|
-
| `
|
|
82
|
-
|
|
|
83
|
-
| `
|
|
84
|
-
| `
|
|
85
|
-
| `threedog
|
|
86
|
-
| `threedog picture
|
|
87
|
-
| `
|
|
88
|
-
|
|
|
89
|
-
|
|
|
90
|
-
|
|
|
91
|
-
| `
|
|
92
|
-
| `
|
|
93
|
-
| `threedog
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
| `threedog
|
|
105
|
-
| `threedog
|
|
106
|
-
| `threedog
|
|
107
|
-
| `threedog
|
|
108
|
-
| `threedog
|
|
109
|
-
| `threedog
|
|
110
|
-
| `threedog
|
|
111
|
-
| `threedog snap
|
|
112
|
-
| `threedog
|
|
113
|
-
| `threedog
|
|
114
|
-
| `threedog
|
|
115
|
-
| `threedog
|
|
116
|
-
| `threedog
|
|
117
|
-
| `threedog
|
|
118
|
-
| `threedog
|
|
119
|
-
| `threedog
|
|
120
|
-
| `threedog
|
|
121
|
-
| `threedog
|
|
122
|
-
| `threedog
|
|
123
|
-
| `threedog
|
|
124
|
-
| `threedog
|
|
125
|
-
| `threedog
|
|
126
|
-
| `threedog
|
|
127
|
-
| `threedog
|
|
128
|
-
| `threedog
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
-
|
|
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`.
|
|
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` is the same (npx adds about 2.5 s per call).
|
|
5
|
+
Every command checks its options: an unknown one fails and lists the valid ones (`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; hold the loop with `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.
|
|
37
|
+
- 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).
|
|
38
|
+
- 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.
|
|
39
|
+
|
|
40
|
+
> 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.
|
|
41
|
+
|
|
42
|
+
> 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.
|
|
43
|
+
|
|
44
|
+
## Command table
|
|
45
|
+
| Command | When to use |
|
|
46
|
+
|---|---|
|
|
47
|
+
| `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) |
|
|
48
|
+
| `npm run check` | Run after every change (`map` first when the docs need regenerating, then `check`, then the related tests): rule checks (`packages/tools/rules/`; detection and allowlists at the top of each file) + types + content validation + generated docs up to date. Errors print in full, warnings as one count line per rule. `-- --rule R4` runs one rule, `-- -w game` (or `check` inside a game folder) reports only that game's problems and sets the exit code from them alone; plain `check` at the repo root stays repo-wide (run it before committing engine changes); `-- --json` one JSON result (shape below). Other options: `threedog check --help` |
|
|
49
|
+
| R40 bypass hints (part of `check`, warnings only) | Game code that hand-rolls what an engine system does (a timer, `Math.random`, an inventory, a localStorage save, raw `keydown` listeners, `AudioContext`, a `requestAnimationFrame` loop, a camera follow, a tween, a pointer raycast, a physics library, …) is pointed to that system; each system declares its own hint, also in a game installed from npm. Plain `check` lists the first 5, `check --rule R40` 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 |
|
|
50
|
+
| `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 |
|
|
51
|
+
| `npm test` | Full browser tests (slow). Normally `threedog test name` runs only the related ones (name substring, any case, e.g. `-- hlod`; a word that matches nothing fails), `-- -w game` tests one game. Prints failed items, a progress line and the summary. `threedog test pack` is the build test: each game's real build opened from dist only (engine ready, no 4xx, no console errors). Parallel jobs, `serial` specs, `--verbose`, `--update-snapshots` (describe baselines), `--json`: `threedog test --help` |
|
|
52
|
+
| `threedog session [--minutes N]` / `session stop` / `session status` | Optional: keeps one small local process alive (127.0.0.1, token, `.threedog/session.json`) so bridge commands skip module loading (about 0.1 to 0.15 s each); exits after N idle minutes (default 10). Without a live one every command calls directly. Restart it after editing the tools |
|
|
53
|
+
| `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 |
|
|
54
|
+
| `threedog art list <source> [--full]` · `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 |
|
|
55
|
+
| `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, with a preview where one exists, file, size and where it is used (file:line), and a status: used, unused, missing, or not traced (a name built at run time is never called unused). Each item copies one line for the AI. `--live` also asks the running game what it really loaded; `?panel=1` shows the same list in folder "art" |
|
|
56
|
+
| `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 |
|
|
57
|
+
| `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 |
|
|
58
|
+
| `threedog lib add <file|folder|exportName>` · `threedog lib list [words] [--card]` · `threedog lib pull <name> [--to art/] [--dry]` · `threedog lib page` | Your own library of art and techniques from earlier games (`~/.threedog/library`; `THREEDOG_LIBRARY` or `--lib dir` moves it): `add` copies a piece in with its local imports, textures and models, `list` one line per entry, `pull` copies an entry into this game (refused when it cannot draw on the game's renderer; a code entry gets a wiring file in `plugins/`), `page` a page of all previews. More: `threedog lib --help`. MCP: `lib_list`. recipes/05-props-bake.md §2d |
|
|
59
|
+
| `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 |
|
|
60
|
+
| `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 |
|
|
61
|
+
| `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` |
|
|
62
|
+
| `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` |
|
|
63
|
+
| `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 |
|
|
64
|
+
| `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 |
|
|
65
|
+
| `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 |
|
|
66
|
+
| `threedog mcp [--allow-js]` | The dev bridge as an MCP server over stdio. `recipes/16-dev-bridge.md` section 10 |
|
|
67
|
+
| `threedog assets check new.glb --against old.glb` | What the old export had and the new one lacks. `recipes/46-blender-art-route.md` |
|
|
68
|
+
| `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 (`--pos` only places the player). Not with `--view`; negative numbers work with or without `=`. |
|
|
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: 1 image of 960x540 into the workspace's .threedog/shots/; **read the state as text first with `--describe-only`** (`--json` gives the whole state). `/<page>.html` switches the page, `-w game` the game, `--wait seconds` advances time, `--play` starts in play past the title screen. The shot waits for loading and for the game's own code after `await engine.start()`, and fails naming what is still pending. Other options (`--no-build`, `--load-timeout`, `--keep-cutscene`, `--tier`, `--out`): `threedog shot --help` |
|
|
73
|
+
| `npm run shot -- / [--ref image] [--no-picture] [--json]` · `shot http://localhost:5173/` · `shot --image file.png` | After every shot (and every `threedog snap`): picture numbers measured on the 3D canvas and at most four one-sentence hints (contradictions, facts, intent; recipes/35 "Picture check after every shot"). Nothing fails and nothing is changed; every value touched by its few extra renders is put back. `--json` gives every hint in full. A full URL opens an already running page without a build; `--image` reads a picture taken another way and gives the pixel part only. A screenshot of your own skips the check: take pictures with `shot` or `snap` |
|
|
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`) | Game-ready copies of art/models/ into public/optimized/, originals untouched: Meshopt geometry, KTX2 textures by slot (data maps linear UASTC, color maps sRGB ETC1S; each read back and checked). Writes `assets.optimized.js` and imports it in assets.js, so the names point at the results; a rerun handles only changed files. Per file: size before / after, estimated GPU memory and problems (over `--budget` MB, color space, missing UVs). `--dry` reports the estimate only; `--lod` also writes lower-detail levels (recipe 15 §4a). Needs `@gltf-transform/cli`; textures go through `ktx` (KTX-Software 4.3+) when it is on PATH, else the WebAssembly encoder of `ktx2-encoder` that comes with the tools. Baked lightmaps are left as baked. 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. Run it first when the environment acts strange. Covers Node, node_modules, workspace links, package-lock, the physical copy of engine / tools / three each context loads (a `MISMATCH` line when they differ, e.g. vendor/ vs node_modules), port 5173, the recorded dev server, and one real engine frame on software and on GPU rendering. `--ci`, `--json`: `threedog doctor --help` |
|
|
84
|
+
| `threedog api-count [--unused] [--json] [--games dirA,dirB]` | Engine repository only: counts the public surface an AI meets (createEngine options, engine members, module options and APIs, package exports, CLI commands and options, error codes), one line per group; `--unused` lists items nothing uses (ones kept on purpose apart as `kept`) |
|
|
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; `--region` measures one rectangle, `--ignore-ui` cuts a flat frame around the picture (a plain sky at the edge looks the same: check with `--crop out.png`, which saves the measured area). 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, fine detail, main color) plus one neutral sentence ("18% darker, 2.3x more broken up"); both pictures are scaled down to one size. Regions match by position, 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 | Try values with `threedog js` (`engine.scene.fog.far = 90`), look with `threedog snap`, then write the result 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 |
|
|
90
|
+
| `threedog gallery [-w game]` · `threedog gallery --shots [--mode …] [--light …] [--material name]` | Every registered model and texture on a turntable under three neutral light setups (tone mapping copied from the game), and the look-dev page (recipe 05 "Look-dev"). Without `--shots` it serves the game in dev and prints the `?gallery=1` URL; `--shots` writes `.threedog/gallery/` pictures, `index.html` and `index.json` headless, and `--mode` adds review pictures (silhouette, value, material channels) with measured facts and no thresholds. Options: `threedog gallery --help`. `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; view=name or view=x,y,z,tx,ty,tz[,fov] puts the camera on a declared view or a pose, for the next snap (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 [--freeze-reload: saves do not reload the page during the run] (prints failed checks and the Coverage block of verify; the scenario leaves the page halted) |
|
|
122
|
+
| `threedog catalog` | what the game can do: 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 picture = picture menu + checks; 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 [--freeze-reload: saves do not reload the page during the run] [--save-baseline: perf medians to .threedog/]; a Perf: line if over budget or slower. 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. An engine that cannot be reached within 40 seconds fails with the page status, the latest page errors and the fix.
|
|
137
|
+
- Advancing dialogue headlessly: recipe 02.
|
|
138
|
+
- Debug objects on window: `window.engine` is declared; for a game's own, `/** @type {any} */ (window).game = {...}`.
|
|
139
|
+
- To operate a running game: the dev bridge, `recipes/16-dev-bridge.md`.
|