threedog 0.1.0 → 0.2.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.
Files changed (217) hide show
  1. package/core/Animator.js +1 -0
  2. package/core/Assets.js +16 -0
  3. package/core/DebugOverrides.js +143 -0
  4. package/core/Describe.js +14 -3
  5. package/core/Engine.js +32 -69
  6. package/core/Events.js +59 -1
  7. package/core/I18n.js +2 -2
  8. package/core/Inspect.js +12 -32
  9. package/core/InspectScene.js +7 -3
  10. package/core/MaterialInfo.js +32 -0
  11. package/core/Ops.js +43 -59
  12. package/core/Saves.js +5 -4
  13. package/core/UrlState.js +3 -2
  14. package/core/Vars.js +1 -0
  15. package/core/Views.js +49 -0
  16. package/core/actor.js +2 -2
  17. package/core/assetReport.js +83 -0
  18. package/core/catalog.js +169 -0
  19. package/core/checks.js +67 -0
  20. package/core/claims.js +51 -0
  21. package/core/debugView.js +76 -0
  22. package/core/describeRender.js +45 -0
  23. package/core/describeText.js +11 -4
  24. package/core/errorCodes.js +33 -0
  25. package/core/errorHints.js +6 -1
  26. package/core/holds.js +106 -0
  27. package/core/lifecycle.js +1 -0
  28. package/core/lightWatch.js +23 -3
  29. package/core/look/coreParts.js +112 -0
  30. package/core/look/layers.js +136 -0
  31. package/core/look/part.js +173 -0
  32. package/core/look/report.js +79 -0
  33. package/core/look/write.js +86 -0
  34. package/core/loop.js +15 -14
  35. package/core/modules.js +19 -5
  36. package/core/opsAtomic.js +31 -0
  37. package/core/opsCheck.js +25 -14
  38. package/core/opsFail.js +20 -0
  39. package/core/opsHistory.js +6 -6
  40. package/core/opsRun.js +77 -0
  41. package/core/params.js +132 -0
  42. package/core/renamed.js +21 -0
  43. package/core/saveApply.js +2 -2
  44. package/core/sceneMethods.js +9 -34
  45. package/core/services.js +73 -0
  46. package/core/startup.js +3 -1
  47. package/core/styleParts.js +2 -2
  48. package/core/thingExplain.js +68 -0
  49. package/core/thingOps.js +35 -24
  50. package/core/things.js +15 -1
  51. package/core/util.js +11 -0
  52. package/core/validate.js +23 -7
  53. package/docs/AI.md +83 -109
  54. package/docs/API.md +7 -8
  55. package/docs/CODEMAP.md +63 -51
  56. package/docs/COMMANDS.md +17 -5
  57. package/docs/CONVENTIONS.md +17 -6
  58. package/docs/THREE.md +3 -3
  59. package/docs/api/assets.md +2 -0
  60. package/docs/api/characters.md +2 -0
  61. package/docs/api/collision.md +4 -0
  62. package/docs/api/content.md +1 -0
  63. package/docs/api/engine.md +20 -11
  64. package/docs/api/events.md +5 -1
  65. package/docs/api/post.md +5 -4
  66. package/docs/api/saves.md +2 -1
  67. package/docs/api/sky.md +3 -3
  68. package/docs/api/style.md +3 -3
  69. package/docs/api/tools.md +2 -0
  70. package/docs/api/weather.md +1 -1
  71. package/docs/recipes/02-npc.md +16 -0
  72. package/docs/recipes/03-items-pickups.md +1 -1
  73. package/docs/recipes/06-clock-events.md +13 -0
  74. package/docs/recipes/07-flow-scenes-pause.md +4 -0
  75. package/docs/recipes/08-weather-sky.md +1 -1
  76. package/docs/recipes/09-style-pack.md +5 -5
  77. package/docs/recipes/12-navmesh.md +22 -0
  78. package/docs/recipes/13-animation.md +3 -0
  79. package/docs/recipes/15-perf.md +1 -1
  80. package/docs/recipes/16-dev-bridge.md +51 -17
  81. package/docs/recipes/21-camera.md +51 -2
  82. package/docs/recipes/23-ops.md +45 -9
  83. package/docs/recipes/27-net.md +1 -1
  84. package/docs/recipes/29-grid.md +1 -1
  85. package/docs/recipes/34-environment-lighting.md +9 -8
  86. package/docs/recipes/38-environment-look-hooks.md +8 -6
  87. package/docs/recipes/40-scene.md +29 -0
  88. package/docs/recipes/41-thing-registry.md +29 -0
  89. package/docs/recipes/43-shader-patches-surface-looks.md +2 -0
  90. package/docs/recipes/44-water-weather-look-hooks.md +6 -4
  91. package/docs/recipes/45-cascaded-shadows.md +1 -1
  92. package/docs/recipes/46-blender-art-route.md +22 -0
  93. package/docs/recipes/48-make-material.md +70 -0
  94. package/docs/recipes/49-game-module-contract.md +71 -0
  95. package/docs/recipes/50-own-renderer.md +12 -0
  96. package/docs/recipes/51-capability-catalog.md +63 -0
  97. package/docs/recipes/52-look.md +108 -0
  98. package/examples/action/GAMEMAP.md +5 -5
  99. package/examples/action/content/index.js +2 -1
  100. package/examples/action/content/views.js +6 -0
  101. package/examples/sheepisland/GAMEMAP.md +2 -3
  102. package/examples/styletest/GAMEMAP.md +3 -3
  103. package/examples/styletest/main.js +1 -1
  104. package/examples/styletest/panel.js +3 -3
  105. package/examples/world/GAMEMAP.md +3 -3
  106. package/index.d.ts +27 -0
  107. package/index.js +3 -1
  108. package/llms.txt +5 -0
  109. package/modules/ambience/Ambience.js +5 -2
  110. package/modules/camera/FirstPersonCamera.js +3 -5
  111. package/modules/camera/FixedCamera.js +19 -12
  112. package/modules/camera/FollowCamera.js +14 -8
  113. package/modules/camera/RtsCamera.js +3 -5
  114. package/modules/camera/common.js +40 -10
  115. package/modules/camera/index.js +1 -1
  116. package/modules/camera/projection.js +34 -0
  117. package/modules/characters/Character.js +29 -17
  118. package/modules/characters/astar.js +14 -7
  119. package/modules/characters/index.js +6 -3
  120. package/modules/characters/movers/simple.js +6 -1
  121. package/modules/characters/npcSim.js +8 -2
  122. package/modules/characters/pathAsync.js +12 -6
  123. package/modules/characters/pathJob.js +2 -1
  124. package/modules/characters/proceduralRig.js +5 -1
  125. package/modules/characters/useModel.js +22 -0
  126. package/modules/characters/walkTo.js +58 -0
  127. package/modules/collision/Collision.js +102 -4
  128. package/modules/content/explain.js +13 -0
  129. package/modules/content/index.js +2 -0
  130. package/modules/content/loader.js +3 -0
  131. package/modules/content/rules.js +1 -0
  132. package/modules/debug/DebugPanel.js +11 -5
  133. package/modules/entities/Entities.js +6 -2
  134. package/modules/flow/index.js +5 -2
  135. package/modules/gameplay/Dialogue.js +5 -2
  136. package/modules/gameplay/Interactions.js +12 -2
  137. package/modules/gameplay/Inventory.js +21 -11
  138. package/modules/gameplay/Quests.js +13 -3
  139. package/modules/gameplay/pickups.js +5 -3
  140. package/modules/grid/Layer.js +1 -1
  141. package/modules/grid/index.js +1 -1
  142. package/modules/grid/tiles.js +9 -5
  143. package/modules/hlod/index.js +5 -2
  144. package/modules/hud/index.js +5 -2
  145. package/modules/level/index.js +5 -3
  146. package/modules/lights/index.js +5 -2
  147. package/modules/music/Music.js +6 -2
  148. package/modules/nav/index.js +5 -3
  149. package/modules/net/Client.js +4 -3
  150. package/modules/net/Host.js +2 -2
  151. package/modules/net/index.js +5 -3
  152. package/modules/particles/Particles.js +1 -1
  153. package/modules/photo/Photo.js +10 -7
  154. package/modules/rigid/RigidBodies.js +5 -2
  155. package/modules/settings/Settings.js +6 -3
  156. package/modules/settings/apply.js +2 -1
  157. package/modules/sky/Sky.js +21 -19
  158. package/modules/sky/cascades.js +6 -6
  159. package/modules/sky/domeLayers.js +1 -1
  160. package/modules/sky/environment.js +39 -13
  161. package/modules/sky/fog.js +9 -6
  162. package/modules/sky/frame.js +4 -3
  163. package/modules/sky/look.js +3 -2
  164. package/modules/sky/lookFog.js +80 -0
  165. package/modules/sky/lookShadow.js +50 -0
  166. package/modules/sky/lookSky.js +108 -0
  167. package/modules/sky/shader.js +2 -2
  168. package/modules/sky/shadow.js +4 -10
  169. package/modules/sky/skyModule.js +4 -3
  170. package/modules/terrain/ChunkManager.js +2 -33
  171. package/modules/terrain/chunkLevels.js +40 -0
  172. package/modules/terrain/index.js +10 -2
  173. package/modules/terrain/lookGround.js +61 -0
  174. package/modules/timeline/Timeline.js +7 -3
  175. package/modules/timeline/Tween.js +3 -7
  176. package/modules/timeline/shots.js +6 -4
  177. package/modules/triggers/index.js +9 -2
  178. package/modules/vegetation/Vegetation.js +2 -1
  179. package/modules/vegetation/index.js +6 -3
  180. package/modules/vegetation/lookWind.js +37 -0
  181. package/modules/water/Water.js +19 -3
  182. package/modules/water/look.js +80 -0
  183. package/modules/weather/Weather.js +22 -31
  184. package/modules/weather/look.js +75 -0
  185. package/modules/weather/particles.js +1 -1
  186. package/modules/weather/strings.js +15 -0
  187. package/modules/world/explain.js +11 -0
  188. package/modules/world/index.js +11 -4
  189. package/modules/world/thingSource.js +44 -0
  190. package/package.json +1 -1
  191. package/render/PostFX.js +48 -51
  192. package/render/effects.js +4 -2
  193. package/render/fuse.js +12 -0
  194. package/render/lights.js +4 -2
  195. package/render/lookSurface.js +161 -0
  196. package/render/materials.js +27 -10
  197. package/render/postLook.js +86 -0
  198. package/render/surface.js +3 -1
  199. package/types/core.d.ts +216 -24
  200. package/types/gameplay.d.ts +10 -0
  201. package/types/generated/core/DebugOverrides.d.ts +52 -0
  202. package/types/generated/core/Events.d.ts +43 -0
  203. package/types/generated/core/Ops.d.ts +62 -21
  204. package/types/generated/core/Saves.d.ts +1 -0
  205. package/types/generated/core/Views.d.ts +33 -0
  206. package/types/generated/modules/debug/DebugPanel.d.ts +2 -2
  207. package/types/generated/modules/grid/Layer.d.ts +1 -0
  208. package/types/generated/modules/sky/Sky.d.ts +10 -17
  209. package/types/generated/modules/weather/Weather.d.ts +5 -15
  210. package/types/generated/render/PostFX.d.ts +20 -23
  211. package/types/generated/render/materials.d.ts +10 -0
  212. package/types/physics.d.ts +8 -0
  213. package/types/style.d.ts +16 -6
  214. package/ui/Parts.js +6 -2
  215. package/ui/UI.js +1 -1
  216. package/ui/defaults.js +1 -1
  217. package/docs/api/debug.md +0 -10
package/core/validate.js CHANGED
@@ -92,16 +92,32 @@ export function warnMissing(kind, name, list) {
92
92
  }
93
93
 
94
94
  /**
95
- * Check an options object for unknown keys. where is the origin (such as 'npcs.add()'), known are the keys the code actually reads.
96
- * loose: warn only when a key is "very close to a known key" (for data like items and entities, where games often add their own fields).
95
+ * The one unknown-option rule, shared by readParams (strict) and checkOptions (loose): text for a key not in known, or null when it is fine.
96
+ * Why one function: the "did you mean" search and the wording must not drift between the two readers.
97
+ * soft: a key with no close match is not reported (data like items and entities, where games add their own fields).
98
+ */
99
+ export function unknownOptionText(where, key, known, { soft = false } = {}) {
100
+ if (known.includes(key)) return null;
101
+ const c = closest(key, known);
102
+ if (!c && soft) return null;
103
+ return fmt(STRINGS.unknownKey, { where, key, hint: c ? fmt(STRINGS.didYouMean, { name: c }) : fmt(STRINGS.available, { list: known.join(', ') }) });
104
+ }
105
+ /** Is options an object a game passed (not a Three.js object, array or missing)? */
106
+ export const isOptionsObject = o => !!o && typeof o === 'object' && !Array.isArray(o) && !o.isObject3D && !o.isVector3;
107
+
108
+ /**
109
+ * Check an options object for unknown keys (the loose mode of readParams: same detection, same hint, but nothing is read or filled in).
110
+ * where is the origin (such as 'npcs.add()'), known are the keys the code actually reads.
111
+ * It only warns (once), in every build: the callers are hand-written checks of data and style objects that games and tests deliberately feed
112
+ * misspellings, and their known lists can lag behind the code. The module factories that went through readParams (the strict mode: dev throws,
113
+ * release warns once, decision 2026-11-01) get the throw there. loose: report only near-misses (items and entities, where games add their own fields).
97
114
  */
98
115
  export function checkOptions(where, opts, known, { loose = false } = {}) {
99
- if (!enabled || !opts || typeof opts !== 'object' || Array.isArray(opts) || opts.isObject3D || opts.isVector3) return;
116
+ if (!enabled || !isOptionsObject(opts)) return;
100
117
  for (const k of Object.keys(opts)) {
101
- if (known.includes(k)) continue;
102
- const c = closest(k, known);
103
- if (!c && loose) continue;
104
- warnOnce(fmt(STRINGS.unknownKey, { where, key: k, hint: c ? fmt(STRINGS.didYouMean, { name: c }) : fmt(STRINGS.available, { list: known.join(', ') }) }));
118
+ const msg = unknownOptionText(where, k, known, { soft: loose });
119
+ if (!msg) continue;
120
+ warnOnce(msg);
105
121
  }
106
122
  }
107
123
 
package/docs/AI.md CHANGED
@@ -4,146 +4,120 @@ threedog.js is a web 3D game engine on top of three.js 0.187 (plain three.js, no
4
4
  demand with `engine.use`) -> **style pack** (all art, an optional separate package; the engine ships none and draws gray placeholders without one).
5
5
  This file is the index for the AI that builds a game on the engine. Paths are relative to this `docs/` folder (`node_modules/threedog/docs/`).
6
6
 
7
- **Before writing gameplay code**, look for the system in the entry table below (inventory, collision, saves, quests, grids, templates... already
8
- exist). Hand-write a system only when no row fits.
7
+ ## Most common mistakes
8
+ - Hand-writing a system the table lists (inventory, saves, quests, grids, collision): find the row first.
9
+ - `Math.random()`, `setTimeout`, `performance.now()` in game logic: use `engine.random`, `engine.clock.after / every`, fixed `dt`.
10
+ - `addEventListener('keydown')` for gameplay: define an action with `input.define` and read it in the fixed step.
11
+ - Changing gameplay state from a frame hook or a raw callback: do it in `onFixed`, in an op, or via `engine.nextFixed(fn)`.
12
+ - Saving positions or object references: save stable ids; `await` every `saves.*` call.
13
+ - A mesh added with plain `scene.add` and no id: `engine.add(obj, { id })` is what makes it saveable and inspectable.
14
+ - Changing a look by editing `renderer` / `scene.fog` / materials directly, or in logic: `engine.look.<part>` (recipe 52), values in the style pack.
15
+ - Putting game content (dialogue, quests, items, layout) inside the engine package: it lives in the game's `content/`.
16
+ - Editing generated docs (GAMEMAP, API.md, api/, CODEMAP, `types/generated/`): change the code, run `npm run map`.
17
+ - Guessing a name: look it up in `api/<module>.md`; an engine error carries `err.code` / `err.fix` / `err.docs`.
9
18
 
10
19
  ## What to read, in order (stop when you have enough)
11
20
  1. This file: find the task in the entry table below.
12
21
  2. The recipe the row points to (`recipes/NN-*.md`): how to do the task, with a working pattern.
13
- 3. `api/<module>.md` for signatures, options and data shapes (generated from JSDoc; `API.md` is the index, `api/events.md` the events).
22
+ 3. `api/<module>.md` for signatures, options and data shapes (`API.md` is the index, `api/events.md` the events).
14
23
  4. The game's own `GAMEMAP.md` (generated): what this game has, and "Read for this game".
15
- 5. When needed: `CODEMAP.md` (engine files, event emitters / listeners) · `THREE.md` (what the engine lacks: use three.js) · `PERF.md` ·
16
- `COMMANDS.md` (commands, scenarios, folders) · `CONVENTIONS.md` (the conventions below in detail).
24
+ 5. When needed: `CODEMAP.md` · `THREE.md` (what the engine lacks: use three.js) · `PERF.md` · `COMMANDS.md` · `CONVENTIONS.md`.
17
25
 
18
- Generated docs (GAMEMAP, API.md, api/, CODEMAP, `types/generated/`) are never edited by hand; after changing code run `npm run map`.
26
+ What can I do here: `threedog catalog`, `threedog how "<task>"` (ranks these rows and recipes for a task in your own words).
19
27
 
20
28
  ## One thing, one entry point (don't build another)
21
- Three outward concepts: **Scene** (what is in the world, where, how you interact; content packs are part of it: `recipes/40-scene.md`), **Assets**
22
- (models, textures, sounds, fonts: `recipes/05-props-bake.md` §3b), **Style** (the look; material roles are labels inside it: `recipes/09-style-pack.md`).
23
- Patches, ops and world records are the scene's inner machinery.
29
+ Three outward concepts: **Scene** (what is in the world; content packs are part of it), **Assets** (models, textures, sounds, fonts),
30
+ **Style** (the look; material roles are labels inside it). Patches, ops and world records are the scene's inner machinery.
24
31
 
25
32
  ### Scene
26
33
  | To do | Use | Recipe |
27
34
  |---|---|---|
28
- | New game, project layout | `npm run new-game name`, `createEngine({ canvas, style })`, `engine.use(...)`, `engine.start()` | `recipes/01-new-game.md` |
29
- | Canvas in a page section or editor panel | the canvas's CSS box decides (pointer, pick, UI follow it) | `recipes/01-new-game.md` §5 |
30
- | Preset parts on / off | `openWorld({ camera: 'follow', sky: {...}, debug: false })` | `recipes/01-new-game.md` |
31
- | Put something in the scene (two doors, one scene) | plain `engine.add(obj, { id })`, or a template: `engine.spawn(name, at)` (needs `content()`) / content props | `recipes/40-scene.md` |
32
- | Game content data, content packs | `engine.content.load(data, { places })` or `load([base, dlc])`; own data kinds in `content/rules.js` | `recipes/20-content-actions-save.md` |
33
- | Reusable object definitions (prefabs) | content `templates` (model + collision + op + defaults); place with props `{ template, x, z }` or `engine.spawn(name, pos)` | `recipes/30-templates.md` |
34
- | A few props / many repeated objects, deleting objects | content `props` / `vegetation` (`engine.vegetation`), `engine.remove(obj)` | `recipes/05-props-bake.md` |
35
- | What is this thing, where is it defined (point -> id) | `engine.pick(x, y).thing`, `engine.world.origin(id)` / `idOf(obj)`, `npx threedog pick x,y`, MCP `pick` | `recipes/30-templates.md` §5 |
36
- | Many copies of one static model | automatic `engine.batching`; opt out `batch: false`, recolor one `engine.batching.tint(obj, color)` | `recipes/05-props-bake.md` §2b |
37
- | Saved / far-away objects, the player record | `engine.world` (`present` near, `simulate` far), `player.placeAt()` | `recipes/18-world.md` |
38
- | Stream in, teleport, what is loaded where | `engine.stream.add({ position, build })`, `await engine.stream.teleport(p)`, `engine.stream.source(...)` | `recipes/18-world.md` |
39
- | Blender level | `engine.level`; check a level file first with `npm run assets -- check` | `recipes/10-blender-level.md` |
40
- | Grass and trees without terrain | `vegetation({ area })`, rule `biomes` by ground type, `engine.vegetation.rebuild()` | `recipes/10-blender-level.md` §4 |
41
- | Terrain generator, ground height, terrain editing | `terrain({ height, groundType })` or `terrainPreset()` (`@threedog/terrain-noise`; none = flat), `engine.surface(x, z)`, `engine.ground`, `engine.terrain.edit()` | `recipes/28-terrain.md` |
42
- | Ground color borders (river banks), mesh cut, lighting normals | `terrain({ shading: 'texture', colorResolution, normals, normalFn, diagonal, boundsPad })` | `recipes/37-terrain-look-hooks.md` |
35
+ | New game, project layout, canvas inside a page or editor panel | `npm run new-game name`, `createEngine({ canvas, style })`, `engine.use(...)`, `engine.start()` | `recipes/01-new-game.md` |
36
+ | Preset parts on / off, blank game | `openWorld({ camera: 'follow', sky: {...}, debug: false })`, `new-game name --blank` | `recipes/01-new-game.md` |
37
+ | Put something in the scene | `engine.add(obj, { id })`, `engine.spawn(name, at)`, content props | `recipes/40-scene.md` |
38
+ | Game content data, content packs | `engine.content.load(data, { places })`, `load([base, dlc])`, rules in `content/rules.js` | `recipes/20-content-actions-save.md` |
39
+ | Reusable object definitions (prefabs) | content `templates`; props `{ template, x, z }` | `recipes/30-templates.md` |
40
+ | Props, many repeated objects, delete an object, static batching | content `props` / `vegetation`, `engine.remove(obj)`, `engine.batching` (`batch: false`, `tint`) | `recipes/05-props-bake.md` |
41
+ | What is this thing, where is it defined (point -> id) | `engine.pick(x, y).thing`, `engine.world.origin(id)`, `engine.thing(id).explain()` | `recipes/30-templates.md` §5 |
42
+ | Saved / far-away objects, the player record, stream in, teleport | `engine.world`, `player.placeAt()`, `engine.stream.add / teleport / source` | `recipes/18-world.md` |
43
+ | Blender level, grass and trees without terrain | `engine.level`, `npm run assets -- check`, `vegetation({ area })`, `engine.vegetation.rebuild()` | `recipes/10-blender-level.md` |
44
+ | Terrain generator, ground height, terrain editing | `terrain({ height, groundType })`, `terrainPreset()`, `engine.surface(x, z)`, `engine.ground`, `engine.terrain.edit()` | `recipes/28-terrain.md` |
45
+ | Ground color borders, mesh cut, lighting normals | `terrain({ shading: 'texture', colorResolution, normals, diagonal })` | `recipes/37-terrain-look-hooks.md` |
46
+ | Island, floating rock, world with an edge | `terrain({ shape: { mask, edge, side, bottom } })`, `engine.ground.has`, event `terrain:void` | `recipes/42-terrain-shape.md` |
43
47
  | Grid placement, per-cell soil state | `engine.grids.add / define`, ops `grid.place / move / remove` | `recipes/29-grid.md` |
44
- | Collision, physics, vehicles | `engine.collision`, `engine.rigid` (Rapier; `rigid({ treeRadius })` limits tree colliders) | `recipes/11-vehicles.md` |
45
- | Pathfinding, navmesh, "can walk there" | `engine.characters.findPath(from, to)`, `engine.nav`, `createEngine({ movement })` | `recipes/12-navmesh.md` |
46
- | Interaction prompts (talk, pick up, open) | `engine.interactions` (`interactions({ ...presets.interactions.nearest })` or `{ pick, keys }`) | `recipes/20-content-actions-save.md` |
47
- | Trigger zones | content `triggers`, `engine.triggers` | `recipes/20-content-actions-save.md` |
48
- | Ray / mouse picking, shooting, lock-on | `engine.raycast / pick`, `engine.rays.addStatic(obj)`, `engine.entities`, `engine.particles`, `pickTarget` | `recipes/19-shooting-picking.md` |
49
- | NPCs and what they do | content `npcs` (`behavior`: `schedule` / `wander`), `engine.npcs.behavior(name, { near, far })` | `recipes/02-npc.md` |
50
- | Dialogue | content `dialogues`, `engine.dialogue` | `recipes/02-npc.md` |
51
- | Items, pickups, inventory | content `items` / `pickups`, `engine.inventory` | `recipes/03-items-pickups.md` |
52
- | Chests, corpses, shelves, transfers | `engine.inventory.container(id, { capacity, items })`, `inventory.transfer(from, to, item, n)` | `recipes/22-shop-gold.md` |
53
- | Shops, gold | currency item + ops | `recipes/22-shop-gold.md` |
54
- | Quests, objective markers | content `quests` (a step's `target` is marked automatically), `engine.quests`, `engine.hud.marker()` | `recipes/04-quests.md` |
48
+ | Collision, fences, rivers, physics, vehicles | `engine.collision` (`addSegment`, `addBlocked`, `lineClear`), `engine.rigid` | `recipes/11-vehicles.md` |
49
+ | Pathfinding, navmesh, "can walk there" | `engine.characters.findPath`, `engine.nav`, `createEngine({ movement })` | `recipes/12-navmesh.md` |
50
+ | Interaction prompts (talk, pick up, open a door or chest), trigger zones | `engine.interactions`, `interactions({ ...presets.interactions.nearest })`, `engine.triggers` | `recipes/20-content-actions-save.md` |
51
+ | Ray / mouse picking, shooting, lock-on | `engine.raycast / pick`, `engine.rays.addStatic`, `engine.entities`, `engine.particles` | `recipes/19-shooting-picking.md` |
52
+ | NPCs and what they do, dialogue | content `npcs` (`behavior`), `engine.npcs.behavior`, content `dialogues`, `engine.dialogue` | `recipes/02-npc.md` |
53
+ | Items, pickups, inventory, chests, shops, gold | content `items` / `pickups`, `engine.inventory` (`container`, `transfer`), currency item + ops | `recipes/03-items-pickups.md`, `22-shop-gold.md` |
54
+ | Quests, objective markers | content `quests`, `engine.quests`, `engine.hud.marker()` | `recipes/04-quests.md` |
55
55
  | Player and characters | `engine.player`, `engine.characters.createPlayer({ ...presets.player.thirdPerson, model })` | `recipes/13-animation.md` |
56
- | Camera | `openWorld({ camera })` (required), `engine.setCamera(...)`, `engine.cameraRig` | `recipes/21-camera.md` |
57
- | Action game: hp, attacks, enemy AI, drops, death (no combat rules in the engine) | your ops (`player.attack`) + `world.simulate` + `inventory.spawnPickup`; `examples/action/` | `recipes/32-action-game.md` |
56
+ | Camera, orthographic camera | `openWorld({ camera })` (required), `engine.setCamera(...)`, `engine.cameraRig`, `engine.takeCamera` | `recipes/21-camera.md` |
57
+ | Action game: hp, attacks, enemy AI, drops | your ops + `world.simulate` + `inventory.spawnPickup`; `examples/action/` | `recipes/32-action-game.md` |
58
+ | Use three.js directly, own renderer, no default lights | `engine.scene / renderer / camera`, `createEngine({ lights: false, renderer })` | `recipes/40-scene.md` §8, `50-own-renderer.md` |
58
59
 
59
60
  ### Assets
60
61
  | To do | Use | Recipe |
61
62
  |---|---|---|
62
- | Art assets, asset packs, fonts, loading, what failed | `engine.assets.manifest({ models, textures, sounds, fonts })` (a pack: lowpoly's `assets`), `engine.loading`, `npx threedog loading` | `recipes/05-props-bake.md` |
63
- | Skeletal animation | `engine.assets.animate(model, config)`, mapping as data on the manifest entry, `anim.sync`, `anim.check` | `recipes/13-animation.md` |
64
- | Far detail (HLOD) | `engine.hlod` | `recipes/15-perf.md` |
65
- | Sound, buses, ambience rules, music, footsteps, ducking | `createEngine({ audio })`, `engine.audio.sfx(name)`, `engine.ambience`, `engine.music`; as content data: pack `audio: {...}` with `when` | `recipes/31-audio.md` |
63
+ | Art assets, asset packs, fonts, loading, what failed | `engine.assets.manifest({ models, textures, sounds, fonts })`, `engine.loading`, `threedog loading` | `recipes/05-props-bake.md` |
64
+ | Real art assets: Blender -> GLB, baked textures | `threedog assets check [--against old.glb]`, `engine.assets.manifest({ models })` | `recipes/46-blender-art-route.md` |
65
+ | Skeletal animation, far detail (HLOD) | `engine.assets.animate(model, config)`, `anim.sync`, `character.onPose(fn)`, `engine.hlod` | `recipes/13-animation.md`, `15-perf.md` |
66
+ | Sound, buses, ambience, music, footsteps | `createEngine({ audio })`, `engine.audio.sfx(name)`, `engine.ambience`, `engine.music` | `recipes/31-audio.md` |
66
67
 
67
- ### Style
68
+ ### Style and look
68
69
  | To do | Use | Recipe |
69
70
  |---|---|---|
70
- | Look, materials, post-processing, mixing packs | style pack (`createEngine({ style })`, e.g. `@threedog/style-lowpoly`, or parts `style: [lowpoly, { sky }]`), `engine.makeMaterial('role', {...})`, `style.palette`, `postAdd` / `postRemove`, `engine.post`, `engine.uniforms`; surface feel in a material spec: texture names (`map`, `normalMap`…), `detail`, `lighting`, toon `ramp`. **A material role name is free: invent a new one; the engine warns only on a name that looks like a typo of a known role** | `recipes/09-style-pack.md`, `recipes/43-shader-patches-surface-looks.md` |
71
- | An island / floating rock / a world with an edge | `terrain({ shape: { mask, edge, side, bottom } })`; outside it `engine.surface` is `-Infinity`, check `engine.ground.has(x, z)`; falling out fires `terrain:void`, you handle respawn | `recipes/42-terrain-shape.md` |
72
- | Real art assets (Blender model, baked textures, GLB) | Blender → GLB → `threedog assets check` → `engine.assets.manifest({ models })` | `recipes/46-blender-art-route.md` |
73
- | Water depth colour / foam / reflection, rain and snow shapes, own weather particles | `style.water`, `style.weather`, `engine.weather.define` | `recipes/44-water-weather-look-hooks.md` |
74
- | Shadows too blurry near the camera | `sky({ shadow: { cascades: 3 } })` (cascaded, off by default, switching recompiles once; set it in settings, not in play) | `recipes/45-cascaded-shadows.md` |
75
- | Island edge, snow cover, flat-colour backdrop | `style.weather.snow.cover`, `style.sky.backdrop`, `weather:change`, `applyState({ season })` | `recipes/47-island-snow-backdrop.md` |
76
- | Blank game / flat island / fixed dusk / still NPC | `npx threedog new-game name --blank`; `terrain({ height: () => 2, shape })`; `openWorld({ time })` without `calendar.cycle`; NPC without `schedule`+`behavior` | `recipes/01-new-game.md`, `28-terrain.md`, `08-weather-sky.md`, `02-npc.md` |
77
- | `verify` scenario, why `shot` shows a fresh game | `tests/scenarios/x.json`; teleport + `step 1` collects `auto` pickups; `shot` = fresh, `snap` = current session | `recipes/16-dev-bridge.md` |
78
- | `isDay`, dialogue in `describe`, HUD counter from items | `isDay` = 06:00-18:00 exclusive; `describe().ui.dialogue`, event `dialogue:line`; `hud.counter` in `onFrame` | `recipes/08-weather-sky.md`, `02-npc.md`, `26-ui-parts.md` |
79
- | Make a new style from a reference image | `threedog style palette <image>`, `npm run new-style`, `threedog style check`, `style compare <ref> <shot>`; `threedog shot styletest --view room`, `/styletest.html?panel=1` | `recipes/35-style-from-reference.md` |
80
- | Look knobs: clouds, ground patches, wind, fog, exposure, sky layers | `style.sky.clouds`, `terrain.variation`, `wind.glsl`, `sky.fog`, `sky.layers`, `style.exposure`; own lights / fog: `sky({ sun: false, fog: 'manual' })` | `recipes/36-sky-ground-plant-looks.md`, `recipes/38-environment-look-hooks.md` |
81
- | Environment lighting (PBR reflections, ambient from the sky or an HDR) | `engine.sky.setEnvironment({ source: 'sky' \| asset name })` | `recipes/34-environment-lighting.md` |
82
- | Color grading, grain, vignette, depth of field; outline modes | `@threedog/post-effects`: `bloom`, `ao`, `outline`, `dof`, `lut`… (`style: [lowpoly, postAdd(vignette({ enabled: true }), grain({ enabled: true }))]`); a style pack never imports another style pack, shared effects come from post-effects (R34) | `recipes/09-style-pack.md` |
83
- | Many lights (torches, lamps, muzzle flashes) | `lightPool({ point })`, `engine.lightPool.add(obj, { color, intensity, distance, flicker, glow })` | `recipes/09-style-pack.md` |
84
- | Day, night, seasons, sky, weather | `engine.sky` (`at / between / daily / onSeason`, `isDay`; fixed unless `sky({ dayLength })`), `engine.weather` (`weather({ types })`) | `recipes/08-weather-sky.md` |
85
- | Water | `engine.water` | `recipes/08-weather-sky.md` |
86
- | Shadow type and softness | `createEngine({ shadowType: 'basic' \| 'pcf' \| 'vsm' })`, `engine.sky.setShadow({ type, radius })`; switching recompiles materials | `recipes/15-perf.md` |
71
+ | Change any look at run time: tone, lights, fog, sky, clouds, shadow, wind, ground, water, weather, post | `engine.look.<part>.set / patch / replace` (`engine.catalog('look')`); own plain three.js: when to | `recipes/52-look.md`, `40-scene.md` §8 |
72
+ | Set the starting look: pack, materials, mixing packs, exposure, sky layers | style pack (`style: [lowpoly, { sky }]`), `engine.makeMaterial('role', {...})`, `style.palette`, `postAdd` / `postRemove` | `recipes/09-style-pack.md`, `36-sky-ground-plant-looks.md`, `48-make-material.md` |
73
+ | Material and lighting shader patches, toon ramp, wind, fog hooks | `applyEffects`, `look.surface.patch`, `look.wind.patch`, `look.fog.patch` | `recipes/43-shader-patches-surface-looks.md`, `38-environment-look-hooks.md` |
74
+ | Water depth / foam, rain and snow shapes, own weather particles, snow cover, backdrop | `look.water`, `look.weather`, `style.weather.snow.cover`, `style.sky.backdrop` | `recipes/44-water-weather-look-hooks.md`, `47-island-snow-backdrop.md` |
75
+ | Shadows too blurry near the camera; shadow type | `look.shadow.set({ cascades: 3, type })` | `recipes/45-cascaded-shadows.md`, `15-perf.md` |
76
+ | Environment lighting (PBR reflections, HDR) | `look.env.replace('sky' | asset)`, `look.env.set({ intensity })`\| asset })`, `look.env` | `recipes/34-environment-lighting.md` |
77
+ | Color grading, grain, vignette, DOF, outline, bloom | `@threedog/post-effects`, `postAdd(vignette())`, `engine.post`, `look.post.set` | `recipes/09-style-pack.md`, `52-look.md` |
78
+ | Many lights (torches, lamps, muzzle flashes) | `lightPool({ point })`, `engine.lightPool.add(obj, { color, intensity, distance, flicker })` | `recipes/09-style-pack.md` |
79
+ | Day, night, seasons, sky, weather, water, isDay | `engine.sky` (`at / between / daily / onSeason`), `engine.weather`, `engine.water` | `recipes/08-weather-sky.md` |
80
+ | Who set tone / post / lights; why does it look like this | `engine.describe().look` (value, by, at), `describe().render`, `debug.view('albedo'\|'lighting'\|'shadow'\|'normals')` | `recipes/52-look.md`, `16-dev-bridge.md` |
81
+ | New style from a reference image | `threedog style palette <image>`, `npm run new-style`, `style check`, `style compare <ref> <shot>` | `recipes/35-style-from-reference.md` |
87
82
 
88
83
  ### Rules and flow
89
84
  | To do | Use | Recipe |
90
85
  |---|---|---|
91
- | Player actions, UI buttons that change state | `engine.ops.define('noun.verb', { can, run, undo })`, `ops.run(name, args)`, `ops.undo(name, args, value)` | `recipes/23-ops.md` |
92
- | Why can't / what can the player do here | `engine.explain(...)`, `engine.inspect(at?)`, scenario tests `tests/scenarios/*.json` | `recipes/23-ops.md` |
86
+ | Player actions, UI buttons that change state | `engine.ops.define('noun.verb', { can, run, undo })`, `ops.run(name, args)` | `recipes/23-ops.md` |
87
+ | What can this game do (modules, ops, saves, time) | `engine.catalog(id?)`, `threedog catalog [id]` | `recipes/51-capability-catalog.md` |
88
+ | Why can't / what can the player do here | `engine.explain(...)`, `engine.inspect(at?)`, `describeText()`, scenario tests | `recipes/23-ops.md` |
93
89
  | Story flags, counters | `engine.vars` (`setFlag / flag / bump / counter`, saved) | `recipes/20-content-actions-save.md` |
94
- | Saves | `engine.saves.register(key, { save, load })`; `await` every `saves.*` call; `saves.autosave(minutes)`; save stable ids, never positions | `recipes/20-content-actions-save.md` |
95
- | New game / continue / back to title / retry | `await engine.session.newGame() / load(slot)`, `quit()`; things made during play go through `session.track(h)` | `recipes/07-flow-scenes-pause.md` |
96
- | Scene flow, fades, pausing gameplay | `engine.flow` (`transition(fn)`, state `'paused'`), `fadeScreen(engine, to, s)` | `recipes/07-flow-scenes-pause.md` |
97
- | Cutscenes, tweens | `engine.timeline` (`tween(obj, { 'position.y': 2 }, s)`; no other tween class) | `recipes/07-flow-scenes-pause.md` |
98
- | Time, timers, skipping time | `engine.clock` (game seconds, `after / every`), `await engine.skip({ to: '06:00' })` | `recipes/06-clock-events.md` |
99
- | Events | `engine.events.on / emit` (`noun:action`; a game declares its own in `GameEvents`) | `recipes/06-clock-events.md` |
100
- | Gameplay randomness | `engine.random` (saved; never `Math.random`) | `recipes/23-ops.md` |
101
- | Opt-in feel presets (weather, calendars, player, keys, interaction pick, camera) | `presets.weather.temperate`, `presets.calendar.cycle`, `presets.player.thirdPerson`, `presets.keys.*`, `presets.camera.*`; never auto-applied | `recipes/01-new-game.md` |
102
- | Text and languages | `engine.t(key)`, `engine.i18n` | `recipes/26-ui-parts.md` |
103
- | Keys and input contexts | `input.define('action', keys, label)`, read by action in the fixed step, `engine.input.push('menu')`, `input.simulate(action, down)` | `recipes/26-ui-parts.md` |
104
- | Screen UI parts, Esc / UI layering, settings menu, labels over the world | `createEngine({ ui })`, `engine.ui.set(name, ...)`, `engine.hud`, `uiFocus(engine)`, `engine.settings`, `worldToScreen()` | `recipes/26-ui-parts.md` |
105
- | Photo mode | `engine.photo` | `recipes/26-ui-parts.md` |
106
- | Set up a scenario, dev bridge | `engine.applyState({...})`, `engine.defineState(name, params)`, `npx threedog play`, `status`, `verify <scenario>`, `scene --hidden` (mesh not drawn) | `recipes/16-dev-bridge.md` |
107
- | Drive the game from an MCP client (Claude Code, Cursor) | `claude mcp add threedog -- npx threedog mcp` (`js` only with `--allow-js`) | `recipes/16-dev-bridge.md` §10 |
108
- | Describe state for tests | `engine.describe()`, `engine.describe.add(name, fn)`, `describeText()` | `recipes/16-dev-bridge.md` |
109
- | An engine error: what to do | `err.code` / `err.fix` / `err.docs` (also `engine.error`, `.threedog/errors.log`) | `recipes/16-dev-bridge.md` §8 |
110
- | What is this thing / will a save keep it | `engine.add(obj, { id })` (only an id makes it saveable), `engine.thing(id \| obj)`, `pick().thing`, ops `thing.set` / `thing.remove` (undoable) | `recipes/41-thing-registry.md` |
111
- | Your own module | `{ name, install, fixed, frame, describe, afterLoad }` + `engine.use` | `recipes/14-custom-module.md` |
112
- | A module will not install, or runs in the wrong order | `engine.use(a, b)` installs a batch atomically; `before` / `after` sort inside one `stage`; `critical: true` | `recipes/14-custom-module.md` |
113
- | Heavy loops, workers, background results | `engine.jobs.add(function* () {})`, `engine.threads.lane(...)`, `engine.commits` | `recipes/15-perf.md` |
114
- | Performance budget, debug panel, where the time goes | `engine.budget`, `engine.debug`, `describe().perf`, `threedog capture` | `recipes/15-perf.md` |
115
- | Random operation sequences, order-dependent bugs | the engine repository's `Properties` specs (fast-check) | `recipes/23-ops.md` |
90
+ | Saves: save game, load game, progress, slot, autosave, 存档 | `engine.saves.register(key, { save, load })`, `saves.autosave(minutes)` | `recipes/20-content-actions-save.md` |
91
+ | New game / continue / back to title / retry | `await engine.session.newGame() / load(slot)`, `quit()`, `session.track(h)` | `recipes/07-flow-scenes-pause.md` |
92
+ | Scene flow, fades, pausing, cutscenes, tweens | `engine.flow`, `fadeScreen(engine, to, s)`, `engine.pause(owner)`, `engine.timeline.tween` | `recipes/07-flow-scenes-pause.md` |
93
+ | Time, timers, skipping time | `engine.clock` (`after / every`), `await engine.skip({ to: '06:00' })`, `checkSkip`, `checkSave` | `recipes/06-clock-events.md` |
94
+ | Events, cause chain, randomness | `engine.events.on / emit`, `engine.random` (saved), `events.trace(name)`, `traceFocus(id)` | `recipes/06-clock-events.md` |
95
+ | Keys, input contexts, open / interact key; text and languages (`engine.t`, `engine.i18n`) | `input.define('action', keys, label)`, `engine.input.push('menu')`, `input.simulate` | `recipes/26-ui-parts.md` |
96
+ | Screen UI parts, Esc layering, settings menu, labels over the world, photo mode | `createEngine({ ui })`, `engine.ui.set`, `engine.hud`, `engine.settings`, `worldToScreen()`, `engine.photo` | `recipes/26-ui-parts.md` |
97
+ | Drive and test the running game | dev bridge: `applyState`, `defineState`, `status`, `verify <scenario>`, `scene --hidden`, `state`, `step`, `skip` | `recipes/16-dev-bridge.md` |
98
+ | Fixed camera views, same shot before / after | `engine.views.define`, `shot --view name --compare` | `recipes/46-blender-art-route.md` |
99
+ | Drive the game from an MCP client | `claude mcp add threedog -- npx threedog mcp` | `recipes/16-dev-bridge.md` §10 |
100
+ | Will a save keep it; hide / recolor on screen only | `engine.add(obj, { id })`, `engine.thing(id)`, ops `thing.set / remove`, `debug.override(owner, id, {...})` | `recipes/41-thing-registry.md` |
101
+ | Your own module, own game system (crop, machine) | `{ name, install, fixed, frame, describe, afterLoad }`, `engine.use`; `before` / `after`, `critical`; save, `skip` hook, ops `can` | `recipes/14-custom-module.md`, `49-game-module-contract.md` |
102
+ | Heavy loops, workers; performance budget, debug panel | `engine.jobs.add`, `engine.threads.lane`, `engine.commits`, `engine.budget`, `engine.debug.panel`, `threedog capture` | `recipes/15-perf.md` |
116
103
  | Co-op multiplayer | `engine.use(net({ role, transport }))`, `engine.net` | `recipes/27-net.md` |
117
104
 
118
- ## Commands (game side; details in `COMMANDS.md`)
119
- `npm run dev` · `npm run check` (after every change) · `npm test -- name` (only related tests) · `npm run map` (after changing code, JSDoc or content)
120
- · `npm run new-game name` · `npm run shot -- --describe-only`. Browser errors go to `.threedog/errors.log`: **read it first when something breaks**.
105
+ ## Commands
106
+ Drive the running game with the MCP tools or `node node_modules/@threedog/tools/bin/threedog.mjs <cmd>` (avoid npx: +2.5 s per call); details
107
+ in `COMMANDS.md`. `npm run dev` · `npm run check` (after every change) · `npm test -- name` (related tests only) · `npm run map` (after code,
108
+ JSDoc or content changes). Browser errors go to `.threedog/errors.log`: **read it first when something breaks**.
121
109
 
122
110
  ## Verification rules for AI
123
- 1. Order: `npm run map` (after API, JSDoc or content changes) -> `npm run check` -> the related tests.
124
- 2. Check logic with `describeText()`, not screenshots; drive a running game with the dev bridge, not playwright scripts. Ops run through the
125
- bridge change this session only; a lasting level change is an edit to `content/*.js`. `main.js` sets `window.engine = engine` before `start()`.
126
- 3. Screenshots only for what the eye must judge. A known error names the recipe to read.
111
+ 1. Order: `npm run map` -> `npm run check` -> the related tests.
112
+ 2. Check logic with `describeText()`, not screenshots; screenshots only for what the eye must judge. Ops run through the bridge change this
113
+ session only; a lasting change is an edit to `content/*.js`. `main.js` sets `window.engine = engine` before `start()`.
127
114
 
128
- ## Conventions (each line is detailed in `CONVENTIONS.md`)
115
+ ## Conventions (detailed in `CONVENTIONS.md`)
129
116
  - **A position is one argument** (Vector3, Object3D, `[x, y, z]` or `{ x, z }`); sizes and counts go in the options object after it.
130
- - **Registrations return a handle**; `h.remove()` undoes it. Objects are deleted with `engine.remove(obj)`.
131
- - **Ready is the boolean `ready`** (`await h.whenReady`). **Event names are `noun:action`** (`item:add`).
132
- - **Time**: fixed seconds (`dt`) and game seconds (`engine.clock.now`); never `setTimeout` / `setInterval` / `performance.now()` in game logic.
133
- - **Fixed step vs frame**: `onFixed` runs game time (damage, cooldowns, AI, timers); `onFrame` is presentation (animation, camera feel, HUD).
134
- - **Input**: gameplay keys in the fixed step, UI keys in the frame hook; never `addEventListener('keydown')` for gameplay.
135
- - **Gameplay state** (world, containers, vars, quests) changes only in fixed steps or ops.
136
- - **The engine owns** sky lights, fog and the camera every frame; adjust with `engine.sky.modify` / `engine.cameraOverride`.
137
- - **Two doors, one scene**: plain three.js (`engine.add(mesh, { id })`) and templates (`engine.spawn`, content props) land in the same
138
- scene (`recipes/40-scene.md`). Put what must be saved and edited without code in content (stable ids: `npx threedog content ids --write`,
139
- `content/renames.js`); <!-- r18-ignore-line --> the check (R33) flags only startup calls that would repeat after a load. <!-- r18-ignore-line -->
140
- - **Look parameters** belong in the style pack or content, never in logic; materials via `makeMaterial`.
141
- - **Units** are meters, Y up, north -Z; characters face +Z.
142
- - **Errors say how to fix it**: an old form throws with the fix.
117
+ - **Registrations return a handle**; `h.remove()` undoes it. **Ready is the boolean `ready`**. **Event names are `noun:action`**.
118
+ - **Fixed step vs frame**: `onFixed` runs game time (damage, AI, timers); `onFrame` is presentation (animation, camera feel, HUD).
119
+ - **The engine owns** sky lights, fog and the camera every frame: see CONVENTIONS "Adjusting sky brightness".
120
+ - **Units** are meters, Y up, north -Z; characters face +Z. **Errors say how to fix it**: an old form throws with the fix.
143
121
 
144
122
  ## Stability
145
- Tested but may change before 1.0 (api pages mark "(experimental)"): co-op `net()` · `engine.threads` ·
146
- `grids()` · `engine.terrain.edit` · `world.simulate(kind, { worker: true })` · `engine.post.add` · `engine.stream.source` · `hlod()` · `engine.ops.guard / allow`.
147
-
148
- ## Hard rule for game content
149
- Game content (dialogues, quests, items, map layout) lives in the game's own `content/` folder, never inside the engine.
123
+ Tested but may change before 1.0: `net()` · `engine.threads` · `grids()` · `terrain.edit` · `world.simulate({ worker })` · `look.post.add` · `stream.source` · `hlod()` · `ops.guard / allow`.
package/docs/API.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Engine API index (generated, do not edit by hand; produced by npm run map)
2
2
 
3
- > **To do something, first look at the recipe in `recipes/` whose file name matches** (it has a ready-made pattern, faster than browsing the API): 01-new-game · 02-npc · 03-items-pickups · 04-quests · 05-props-bake · 06-clock-events · 07-flow-scenes-pause · 08-weather-sky · 09-style-pack · 10-blender-level · 11-vehicles · 12-navmesh · 13-animation · 14-custom-module · 15-perf · 16-dev-bridge · 18-world · 19-shooting-picking · 20-content-actions-save · 21-camera · 22-shop-gold · 23-ops · 26-ui-parts · 27-net · 28-terrain · 29-grid · 30-templates · 31-audio · 32-action-game · 33-stream-sources · 34-environment-lighting · 35-style-from-reference · 36-sky-ground-plant-looks · 37-terrain-look-hooks · 38-environment-look-hooks · 40-scene · 41-thing-registry · 42-terrain-shape · 43-shader-patches-surface-looks · 44-water-weather-look-hooks · 45-cascaded-shadows · 46-blender-art-route · 47-island-snow-backdrop
3
+ > **To do something, first look at the recipe in `recipes/` whose file name matches** (it has a ready-made pattern, faster than browsing the API): 01-new-game · 02-npc · 03-items-pickups · 04-quests · 05-props-bake · 06-clock-events · 07-flow-scenes-pause · 08-weather-sky · 09-style-pack · 10-blender-level · 11-vehicles · 12-navmesh · 13-animation · 14-custom-module · 15-perf · 16-dev-bridge · 18-world · 19-shooting-picking · 20-content-actions-save · 21-camera · 22-shop-gold · 23-ops · 26-ui-parts · 27-net · 28-terrain · 29-grid · 30-templates · 31-audio · 32-action-game · 33-stream-sources · 34-environment-lighting · 35-style-from-reference · 36-sky-ground-plant-looks · 37-terrain-look-hooks · 38-environment-look-hooks · 40-scene · 41-thing-registry · 42-terrain-shape · 43-shader-patches-surface-looks · 44-water-weather-look-hooks · 45-cascaded-shadows · 46-blender-art-route · 47-island-snow-backdrop · 48-make-material · 49-game-module-contract · 50-own-renderer · 51-capability-catalog · 52-look
4
4
  > The api pages are generated too, do not edit them by hand; `?` in a signature means optional, what follows `→` is the return value; the full types are in `types/*.d.ts`.
5
5
  > With no matching recipe: read this page first: the core everyday API + one line per core object / module (listing method names). For the one you need, **read only that page** `api/<name>.md` (methods, parameters, properties and data structures are all in it).
6
6
  > Paths are relative to the package (`node_modules/threedog/`). Entry: `import { createEngine, openWorld, … } from 'threedog'` (the engine package's own examples use relative paths); a module that is not installed is undefined, so use `engine.xxx?.method()`.
@@ -21,8 +21,8 @@
21
21
  - `engine.snapToGround(obj: T, offset?: number) → T` — Put an object on the ground under it (y = ground height + offset) and return the object
22
22
  - `engine.raycast(origin: Vec3Like, dir: Vec3Like, opts?: RaycastOptions) → RayHit | null` — Ray: shoot from origin along dir, returns the nearest hit or null…
23
23
  - `engine.pick(ndcX: number, ndcY: number, opts?: RaycastOptions) → RayHit | null` — Shoot a ray through the camera from screen coordinates (-1..1, e.g. input.pointer.ndcX/ndcY)
24
- - `engine.freeze(owner?: string)` — Gameplay pause (menu, flow's paused): fixed steps are skipped entirely…
25
- - `engine.pause()` — Pause the real-time loop: the picture stops and even rendering stops, only step() advances…
24
+ - `engine.freeze(owner?: string | { owner?, kind? }, opts?: { kind?: 'title' }) → ChainedHandle` — Gameplay pause (menu, flow's paused): fixed steps are skipped entirely…
25
+ - `engine.pause(owner?: string | { owner?, kind? }, opts?: { kind?: 'test' }) → ChainedHandle` — Pause the real-time loop: the picture stops and even rendering stops, only step() advances…
26
26
  - `engine.stateApplied` — Scenario is ready: start() completed, and the URL parameters / the latest applyState have all been …
27
27
  - `engine.ready` — True once start() completes and the loading screen is gone…
28
28
  - `engine.player` — The player (exists only after characters.createPlayer())
@@ -30,7 +30,7 @@
30
30
  - `engine.camera` — three.js perspective camera
31
31
 
32
32
  ## Core objects (engine.xxx, no install needed)
33
- - [`engine.events`](api/events.md) the event bus: recent on once emit; event table
33
+ - [`engine.events`](api/events.md) the event bus: traceFocus note trace recent on once emit; event table
34
34
  - [`engine.input`](api/input.md) Input: read by "action": define touchButton simulate rebind keysOf label down pressed released pressedRaw push
35
35
  - [`engine.clock`](api/clock.md) game seconds and "after how long / every how long": after every
36
36
  - [`engine.vars`](api/vars.md) story flags and counters (autosaved): flag setFlag counter bump
@@ -42,7 +42,7 @@
42
42
  - [`engine.jobs`](api/jobs.md) engine.jobs queues build work in a binary heap: add run
43
43
  - [`engine.stream`](api/stream.md) engine.stream builds on demand by space: only entries n…: add setRadius source teleport readyCheck sources
44
44
  - [`engine.budget`](api/budget.md) performance budget (turned on by createEngine: enable disable metric limitOf report checkStartup values byTag
45
- - [`engine.post`](api/post.md) PostFX: add get enable list
45
+ - [`engine.post`](api/post.md) PostFX: add get enable setAntialias list
46
46
  - [`engine.ground`](api/ground.md) Ground: whoever provides the ground height is the "terr…: height slope type has voidY forEachCollider viewRange chunkCollision staticTrimeshes staticVersion navGeometry
47
47
 
48
48
  ## Modules (installed with engine.use; the openWorld preset installs only world and environment, see [api/openWorld.md](api/openWorld.md))
@@ -54,7 +54,7 @@
54
54
  - [`engine.world`](api/world.md) World data: add origin idOf get set move remove query forEachNear present view refresh …
55
55
  - [`engine.net`](api/net.md) net: reconnect
56
56
  - [`engine.grids`](api/grids.md) grids: add get list define preview
57
- - [`engine.collision`](api/collision.md) collision() Lightweight collision: addCircle addBox addObject forEachStatic walkable walkableAt
57
+ - [`engine.collision`](api/collision.md) collision() Lightweight collision: addCircle addBox addSegment addBlocked blockedAt addObject forEachStatic walkable walkableAt lineClear
58
58
  - [`engine.rigid`](api/rigid.md) rigid() Real physics, Rapier: addBox addBall addHull impulse setPosition groundReady addVehicle
59
59
  - [`engine.cameraRig`](api/cameraRig.md) followCamera() / firstPersonCamera() / fixedCamera() / rtsCamera() Current camera: follow forward right focusPoint update onOverride onEnter onExit
60
60
  - [`engine.timeline`](api/timeline.md) timeline() Cutscenes, tweens: tween play skip
@@ -71,7 +71,6 @@
71
71
  - [`engine.quests`](api/quests.md) quests() Quests: define start isDone isActive isFailed check list
72
72
  - [`engine.photo`](api/photo.md) photo() Photo mode: take subject
73
73
  - [`engine.ambience`](api/ambience.md) ambience() Ambience: add rules nearWater
74
- - [`engine.debug`](api/debug.md) debug() F3 debug panel: startBench
75
74
  - [`engine.nav`](api/nav.md) nav() Navmesh: findPath dispose
76
75
  - [`engine.hlod`](api/hlod.md) hlod() hlod: add
77
76
  - [`engine.lightPool`](api/lightPool.md) lightPool() Light pool: add usage
@@ -81,4 +80,4 @@
81
80
 
82
81
  ## Other
83
82
  - [Style pack Style](api/style.md): all look options (sky, weather, water, terrain, UI, materials, particles, sound, models)
84
- - [Utility functions](api/tools.md): postAdd postRemove presets world net fakeNetwork webSocket grids screenToGround EASINGS ease checkOptions createTerrain terrainMaterial mergeColored applyEffects MATERIAL_PURPOSES makeMaterial materialPatches toast makeWindow worldToScreen fadeScreen uiFocus …
83
+ - [Utility functions](api/tools.md): postAdd postRemove presets world net fakeNetwork webSocket grids screenToGround EASINGS ease checkOptions readParams defineLookPart createTerrain terrainMaterial mergeColored applyEffects MATERIAL_PURPOSES makeMaterial materialPatches toast makeWindow worldToScreen …