threedog 0.5.0 → 0.8.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 (750) hide show
  1. package/CHANGELOG.md +276 -1
  2. package/README.md +18 -13
  3. package/core/{Animator.js → assets/Animator.js} +28 -18
  4. package/core/{Assets.js → assets/Assets.js} +116 -61
  5. package/core/{Baked.js → assets/Baked.js} +16 -25
  6. package/core/assets/assetEntry.js +237 -0
  7. package/core/{assetHot.js → assets/assetHot.js} +7 -6
  8. package/core/{assetLoad.js → assets/assetLoad.js} +66 -29
  9. package/core/assets/assetLod.js +113 -0
  10. package/core/{assetManifest.js → assets/assetManifest.js} +23 -12
  11. package/core/{assetReport.js → assets/assetReport.js} +9 -15
  12. package/core/{namedModel.js → assets/namedModel.js} +24 -16
  13. package/core/{Audio.js → audio/Audio.js} +27 -24
  14. package/core/{audioRules.js → audio/audioRules.js} +8 -5
  15. package/core/{audioVoice.js → audio/audioVoice.js} +17 -30
  16. package/core/{Events.js → base/Events.js} +3 -3
  17. package/core/{I18n.js → base/I18n.js} +10 -10
  18. package/core/{Random.js → base/Random.js} +5 -4
  19. package/core/{easing.js → base/easing.js} +1 -1
  20. package/core/{errorCodes.js → base/errorCodes.js} +154 -139
  21. package/core/{errorHints.js → base/errorHints.js} +9 -10
  22. package/core/{errors.js → base/errors.js} +9 -9
  23. package/core/{events.generated.js → base/events.generated.js} +2 -0
  24. package/core/{math.js → base/math.js} +22 -4
  25. package/core/{params.js → base/params.js} +3 -4
  26. package/core/base/util.js +32 -0
  27. package/core/{validate.js → base/validate.js} +29 -8
  28. package/core/{Engine.js → engine/Engine.js} +112 -105
  29. package/core/{Loading.js → engine/Loading.js} +4 -2
  30. package/core/{copies.js → engine/copies.js} +4 -4
  31. package/core/{headlessLoad.js → engine/headlessLoad.js} +4 -4
  32. package/core/{lifecycle.js → engine/lifecycle.js} +16 -16
  33. package/core/{loop.js → engine/loop.js} +80 -52
  34. package/core/{moduleSlots.js → engine/moduleSlots.js} +35 -10
  35. package/core/{moduleTypes.js → engine/moduleTypes.js} +30 -18
  36. package/core/{modules.js → engine/modules.js} +20 -17
  37. package/core/engine/page.js +125 -0
  38. package/core/{plugins.js → engine/plugins.js} +68 -103
  39. package/core/{services.js → engine/services.js} +47 -40
  40. package/core/{startup.js → engine/startup.js} +35 -35
  41. package/core/{Input.js → input/Input.js} +41 -27
  42. package/core/{inputContext.js → input/inputContext.js} +14 -5
  43. package/core/{inputPad.js → input/inputPad.js} +1 -1
  44. package/core/{inputPointer.js → input/inputPointer.js} +8 -2
  45. package/core/{inputTouch.js → input/inputTouch.js} +1 -1
  46. package/core/{Budget.js → inspect/Budget.js} +23 -22
  47. package/core/{DebugOverrides.js → inspect/DebugOverrides.js} +60 -31
  48. package/core/{Describe.js → inspect/Describe.js} +33 -30
  49. package/core/{Inspect.js → inspect/Inspect.js} +14 -9
  50. package/core/{InspectMaterials.js → inspect/InspectMaterials.js} +8 -10
  51. package/core/{InspectPerf.js → inspect/InspectPerf.js} +29 -16
  52. package/core/{InspectScene.js → inspect/InspectScene.js} +8 -5
  53. package/core/{MaterialInfo.js → inspect/MaterialInfo.js} +9 -6
  54. package/core/inspect/UrlState.js +182 -0
  55. package/core/{catalog.js → inspect/catalog.js} +18 -5
  56. package/core/{checks.js → inspect/checks.js} +7 -5
  57. package/core/{debugView.js → inspect/debugView.js} +8 -8
  58. package/core/inspect/describeRender.js +148 -0
  59. package/core/{describeText.js → inspect/describeText.js} +17 -12
  60. package/core/inspect/geometryWatch.js +38 -0
  61. package/core/{lightWatch.js → inspect/lightWatch.js} +11 -9
  62. package/core/inspect/pictureWriters.js +342 -0
  63. package/core/{shaderCost.js → inspect/shaderCost.js} +1 -1
  64. package/core/{Ops.js → ops/Ops.js} +16 -11
  65. package/core/{control.js → ops/control.js} +13 -12
  66. package/core/ops/holds.js +139 -0
  67. package/core/{opsAtomic.js → ops/opsAtomic.js} +2 -1
  68. package/core/{opsCheck.js → ops/opsCheck.js} +4 -5
  69. package/core/{opsGuard.js → ops/opsGuard.js} +3 -3
  70. package/core/{opsRun.js → ops/opsRun.js} +7 -4
  71. package/core/{owned.js → ops/owned.js} +37 -37
  72. package/core/{sharedPoint.js → ops/sharedPoint.js} +13 -27
  73. package/core/{stackFrames.js → ops/stackFrames.js} +17 -6
  74. package/core/{stacks.js → ops/stacks.js} +18 -20
  75. package/core/{wrap.js → ops/wrap.js} +8 -6
  76. package/core/{SaveStore.js → saves/SaveStore.js} +1 -1
  77. package/core/{Saves.js → saves/Saves.js} +58 -36
  78. package/core/{saveApply.js → saves/saveApply.js} +13 -9
  79. package/core/{saveFiles.js → saves/saveFiles.js} +17 -15
  80. package/core/{saveValues.js → saves/saveValues.js} +20 -3
  81. package/core/{saveVersions.js → saves/saveVersions.js} +4 -17
  82. package/core/{session.js → saves/session.js} +31 -17
  83. package/core/{Rays.js → scene/Rays.js} +27 -24
  84. package/core/{Views.js → scene/Views.js} +15 -6
  85. package/core/{adaptive.js → scene/adaptive.js} +15 -8
  86. package/core/{canvasBox.js → scene/canvasBox.js} +2 -3
  87. package/core/{engineCamera.js → scene/engineCamera.js} +1 -1
  88. package/core/{gameLights.js → scene/gameLights.js} +24 -7
  89. package/core/{grayMap.js → scene/grayMap.js} +8 -2
  90. package/core/{grid.js → scene/grid.js} +4 -4
  91. package/core/{gridLoad.js → scene/gridLoad.js} +1 -1
  92. package/core/{ground.js → scene/ground.js} +9 -9
  93. package/core/{movement.js → scene/movement.js} +3 -3
  94. package/core/scene/pictureSlots.js +33 -0
  95. package/core/{sceneDelta.js → scene/sceneDelta.js} +14 -6
  96. package/core/{sceneMethods.js → scene/sceneMethods.js} +36 -20
  97. package/core/scene/stepPoses.js +55 -0
  98. package/core/{targeting.js → scene/targeting.js} +4 -5
  99. package/core/{thingExplain.js → scene/thingExplain.js} +7 -6
  100. package/core/{thingOps.js → scene/thingOps.js} +4 -3
  101. package/core/{things.js → scene/things.js} +19 -6
  102. package/core/{threePatches.js → scene/threePatches.js} +1 -1
  103. package/core/{tier.js → scene/tier.js} +1 -1
  104. package/core/scene/view.js +44 -0
  105. package/core/{Batching.js → stream/Batching.js} +85 -27
  106. package/core/{Stream.js → stream/Stream.js} +62 -33
  107. package/core/{batchGroups.js → stream/batchGroups.js} +18 -9
  108. package/core/{chunkStream.js → stream/chunkStream.js} +41 -1
  109. package/core/{scatter.js → stream/scatter.js} +2 -2
  110. package/core/{streamSources.js → stream/streamSources.js} +12 -7
  111. package/core/{Commits.js → threads/Commits.js} +6 -5
  112. package/core/{Jobs.js → threads/Jobs.js} +12 -10
  113. package/core/{Threads.js → threads/Threads.js} +16 -16
  114. package/core/{threadPure.js → threads/threadPure.js} +7 -5
  115. package/core/{threadServe.js → threads/threadServe.js} +3 -3
  116. package/core/{Clock.js → time/Clock.js} +17 -10
  117. package/core/{dayTime.js → time/dayTime.js} +5 -1
  118. package/core/{skip.js → time/skip.js} +18 -17
  119. package/core/{time.js → time/time.js} +18 -12
  120. package/core/{uiClock.js → time/uiClock.js} +4 -4
  121. package/docs/AI.md +70 -63
  122. package/docs/API.md +30 -29
  123. package/docs/CODEMAP.md +98 -223
  124. package/docs/COMMANDS.md +80 -69
  125. package/docs/CONVENTIONS.md +87 -41
  126. package/docs/MIGRATING-0.7.md +39 -0
  127. package/docs/MIGRATING-0.8.md +169 -0
  128. package/docs/THREE.md +100 -49
  129. package/docs/api/assets.md +17 -16
  130. package/docs/api/audio.md +8 -7
  131. package/docs/api/budget.md +8 -4
  132. package/docs/api/calendar.md +10 -11
  133. package/docs/api/cameraRig.md +29 -29
  134. package/docs/api/characters.md +26 -19
  135. package/docs/api/clock.md +1 -1
  136. package/docs/api/collision.md +14 -11
  137. package/docs/api/content.md +6 -6
  138. package/docs/api/dialogue.md +3 -3
  139. package/docs/api/engine.md +82 -53
  140. package/docs/api/events.md +5 -3
  141. package/docs/api/flow.md +1 -1
  142. package/docs/api/grids.md +9 -2
  143. package/docs/api/ground.md +4 -5
  144. package/docs/api/hud.md +4 -1
  145. package/docs/api/i18n.md +6 -6
  146. package/docs/api/input.md +10 -9
  147. package/docs/api/interactions.md +6 -4
  148. package/docs/api/inventory.md +10 -11
  149. package/docs/api/jobs.md +5 -5
  150. package/docs/api/level.md +7 -8
  151. package/docs/api/lightPool.md +2 -7
  152. package/docs/api/music.md +3 -3
  153. package/docs/api/nav.md +10 -10
  154. package/docs/api/occlusion.md +5 -0
  155. package/docs/api/openWorld.md +1 -1
  156. package/docs/api/particles.md +8 -5
  157. package/docs/api/photo.md +4 -2
  158. package/docs/api/pickups.md +7 -1
  159. package/docs/api/post.md +24 -5
  160. package/docs/api/quests.md +3 -3
  161. package/docs/api/rays.md +5 -7
  162. package/docs/api/rigid.md +27 -18
  163. package/docs/api/saves.md +8 -7
  164. package/docs/api/settings.md +9 -8
  165. package/docs/api/sky.md +17 -14
  166. package/docs/api/stream.md +7 -7
  167. package/docs/api/swarm.md +34 -0
  168. package/docs/api/terrain.md +17 -12
  169. package/docs/api/terrainDraw.md +12 -0
  170. package/docs/api/timeline.md +2 -2
  171. package/docs/api/tools.md +30 -26
  172. package/docs/api/triggers.md +2 -0
  173. package/docs/api/vars.md +1 -1
  174. package/docs/api/vegetation.md +11 -5
  175. package/docs/api/vegetationDraw.md +10 -0
  176. package/docs/api/water.md +7 -3
  177. package/docs/api/weather.md +11 -6
  178. package/docs/api/weatherDraw.md +10 -0
  179. package/docs/api/world.md +6 -6
  180. package/docs/recipes/01-new-game.md +38 -57
  181. package/docs/recipes/02-npc.md +19 -20
  182. package/docs/recipes/03-items-pickups.md +47 -42
  183. package/docs/recipes/04-quests.md +3 -4
  184. package/docs/recipes/05-props-bake.md +72 -66
  185. package/docs/recipes/06-clock-events.md +30 -21
  186. package/docs/recipes/07-flow-scenes-pause.md +21 -17
  187. package/docs/recipes/08-weather-sky.md +117 -75
  188. package/docs/recipes/09-materials-lights-models.md +171 -0
  189. package/docs/recipes/10-blender-level.md +6 -7
  190. package/docs/recipes/11-vehicles.md +33 -25
  191. package/docs/recipes/12-navmesh.md +9 -8
  192. package/docs/recipes/13-animation.md +50 -22
  193. package/docs/recipes/14-custom-module.md +20 -17
  194. package/docs/recipes/15-perf.md +52 -29
  195. package/docs/recipes/16-dev-bridge.md +47 -57
  196. package/docs/recipes/18-world.md +45 -30
  197. package/docs/recipes/19-shooting-picking.md +11 -7
  198. package/docs/recipes/20-content-actions-save.md +36 -37
  199. package/docs/recipes/21-camera.md +41 -8
  200. package/docs/recipes/22-shop-gold.md +0 -4
  201. package/docs/recipes/23-ops.md +11 -11
  202. package/docs/recipes/26-ui-parts.md +56 -22
  203. package/docs/recipes/27-net.md +0 -2
  204. package/docs/recipes/28-terrain.md +126 -30
  205. package/docs/recipes/29-grid.md +16 -7
  206. package/docs/recipes/30-templates.md +62 -21
  207. package/docs/recipes/31-audio.md +9 -9
  208. package/docs/recipes/32-action-game.md +32 -9
  209. package/docs/recipes/33-stream-sources.md +2 -2
  210. package/docs/recipes/34-environment-lighting.md +164 -52
  211. package/docs/recipes/35-picture-from-reference.md +140 -0
  212. package/docs/recipes/36-ground-plants.md +105 -0
  213. package/docs/recipes/40-scene.md +105 -30
  214. package/docs/recipes/{43-shader-patches-surface-looks.md → 43-shader-patches-surfaces.md} +74 -106
  215. package/docs/recipes/44-water-weather-hooks.md +196 -0
  216. package/docs/recipes/45-cascaded-shadows.md +145 -25
  217. package/docs/recipes/46-blender-art-route.md +21 -25
  218. package/docs/recipes/49-game-module-contract.md +5 -5
  219. package/docs/recipes/50-own-renderer.md +3 -3
  220. package/docs/recipes/52-around-the-picture.md +137 -0
  221. package/docs/recipes/53-ground-up-close.md +65 -28
  222. package/docs/recipes/55-mods-time-wrap.md +25 -17
  223. package/docs/recipes/56-webgpu-tsl.md +73 -28
  224. package/docs/recipes/57-control.md +47 -1
  225. package/docs/recipes/58-input.md +3 -0
  226. package/docs/recipes/59-depth-post-effects.md +5 -5
  227. package/docs/recipes/60-judge-the-picture.md +47 -27
  228. package/docs/recipes/61-deploy.md +27 -0
  229. package/docs/recipes/62-picture-code.md +276 -0
  230. package/docs/recipes/63-third-person-start.md +90 -0
  231. package/docs/recipes/64-particles.md +35 -0
  232. package/docs/recipes/65-swarm.md +140 -0
  233. package/examples/action/.threedog/content-index.json +1 -1
  234. package/examples/action/GAMEMAP.md +9 -7
  235. package/examples/action/main.js +5 -4
  236. package/examples/action/models.js +12 -14
  237. package/examples/action/picture/index.js +13 -0
  238. package/examples/action/picture/lights.js +35 -0
  239. package/examples/action/picture/materials.js +8 -0
  240. package/examples/action/picture/palette.js +33 -0
  241. package/examples/perf-island/.threedog/content-index.json +1 -0
  242. package/examples/{sheepisland → perf-island}/GAMEMAP.md +18 -14
  243. package/examples/{sheepisland → perf-island}/assets.js +2 -2
  244. package/examples/{sheepisland → perf-island}/content/templates.js +1 -1
  245. package/examples/{sheepisland → perf-island}/content/vegetation.js +3 -1
  246. package/examples/{sheepisland → perf-island}/main.js +22 -16
  247. package/examples/{sheepisland/style → perf-island}/models.js +13 -24
  248. package/examples/{sheepisland → perf-island}/params.js +1 -1
  249. package/examples/perf-island/picture/index.js +20 -0
  250. package/examples/perf-island/picture/lights.js +34 -0
  251. package/examples/perf-island/picture/materials.js +61 -0
  252. package/examples/perf-island/picture/palette.js +60 -0
  253. package/examples/perf-island/picture/sky.js +20 -0
  254. package/examples/{sheepisland → perf-island}/views.js +1 -1
  255. package/examples/plain-picture/.threedog/content-index.json +1 -0
  256. package/examples/plain-picture/GAMEMAP.md +91 -0
  257. package/examples/plain-picture/main.js +48 -0
  258. package/examples/plain-picture/picture/index.js +21 -0
  259. package/examples/plain-picture/picture/lights.js +54 -0
  260. package/examples/plain-picture/picture/materials.js +24 -0
  261. package/examples/plain-picture/picture/palette.js +16 -0
  262. package/examples/plain-picture/picture/sky.js +37 -0
  263. package/examples/pullable.json +31 -9
  264. package/examples/rc2d/GAMEMAP.md +10 -4
  265. package/examples/rc2d/README.md +11 -6
  266. package/examples/rc2d/main.js +26 -36
  267. package/examples/rc2d/picture/index.js +18 -0
  268. package/examples/rc2d/picture/lights.js +11 -0
  269. package/examples/rc2d/picture/materials.js +18 -0
  270. package/examples/rc2d/picture/palette.js +15 -0
  271. package/examples/rc2d/picture/post.js +11 -0
  272. package/examples/rc2d/rc2d.js +18 -28
  273. package/examples/styletest/.threedog/content-index.json +1 -1
  274. package/examples/styletest/GAMEMAP.md +15 -10
  275. package/examples/styletest/main.js +20 -30
  276. package/examples/styletest/models.js +29 -29
  277. package/examples/styletest/params.js +1 -4
  278. package/examples/styletest/picture/env.js +38 -0
  279. package/examples/styletest/picture/index.js +16 -0
  280. package/examples/styletest/picture/lights.js +9 -0
  281. package/examples/styletest/picture/materials.js +28 -0
  282. package/examples/styletest/picture/palette.js +22 -0
  283. package/examples/techniques/contact-shadows/README.md +22 -23
  284. package/examples/techniques/contact-shadows/contactShadows.js +32 -16
  285. package/examples/techniques/contact-shadows/main.js +20 -18
  286. package/examples/techniques/contact-shadows/picture/index.js +14 -0
  287. package/examples/techniques/contact-shadows/picture/lights.js +34 -0
  288. package/examples/techniques/contact-shadows/picture/materials.js +12 -0
  289. package/examples/techniques/contact-shadows/picture/palette.js +17 -0
  290. package/examples/techniques/day-night-grade/README.md +13 -16
  291. package/examples/techniques/day-night-grade/main.js +15 -25
  292. package/examples/techniques/day-night-grade/picture/index.js +20 -0
  293. package/examples/techniques/day-night-grade/picture/lights.js +45 -0
  294. package/examples/techniques/day-night-grade/picture/materials.js +15 -0
  295. package/examples/techniques/day-night-grade/picture/palette.js +59 -0
  296. package/examples/techniques/day-night-grade/picture/post.js +25 -0
  297. package/examples/techniques/day-night-grade/picture/sky.js +33 -0
  298. package/examples/techniques/interior-light/README.md +16 -13
  299. package/examples/techniques/interior-light/interiorLight.js +19 -17
  300. package/examples/techniques/interior-light/main.js +31 -68
  301. package/examples/techniques/interior-light/picture/index.js +24 -0
  302. package/examples/techniques/interior-light/picture/lights.js +52 -0
  303. package/examples/techniques/interior-light/picture/materials.js +13 -0
  304. package/examples/techniques/interior-light/picture/palette.js +32 -0
  305. package/examples/techniques/interior-light/picture/sky.js +40 -0
  306. package/examples/techniques/modular-building/README.md +8 -6
  307. package/examples/techniques/modular-building/kit.js +2 -2
  308. package/examples/techniques/modular-building/main.js +9 -17
  309. package/examples/techniques/modular-building/picture/index.js +17 -0
  310. package/examples/techniques/modular-building/picture/lights.js +26 -0
  311. package/examples/techniques/modular-building/picture/materials.js +13 -0
  312. package/examples/techniques/modular-building/picture/palette.js +23 -0
  313. package/examples/techniques/night-lights/README.md +15 -14
  314. package/examples/techniques/night-lights/main.js +20 -43
  315. package/examples/techniques/night-lights/nightLights.js +25 -21
  316. package/examples/techniques/night-lights/picture/index.js +18 -0
  317. package/examples/techniques/night-lights/picture/lights.js +44 -0
  318. package/examples/techniques/night-lights/picture/materials.js +15 -0
  319. package/examples/techniques/night-lights/picture/palette.js +34 -0
  320. package/examples/techniques/night-lights/picture/post.js +9 -0
  321. package/examples/techniques/night-lights/picture/sky.js +36 -0
  322. package/examples/techniques/outlines-and-rim/README.md +2 -2
  323. package/examples/techniques/outlines-and-rim/main.js +15 -38
  324. package/examples/techniques/outlines-and-rim/outlines.js +3 -3
  325. package/examples/techniques/outlines-and-rim/picture/index.js +16 -0
  326. package/examples/techniques/outlines-and-rim/picture/lights.js +18 -0
  327. package/examples/techniques/outlines-and-rim/picture/materials.js +11 -0
  328. package/examples/techniques/outlines-and-rim/picture/palette.js +16 -0
  329. package/examples/techniques/outlines-and-rim/picture/post.js +10 -0
  330. package/examples/techniques/procedural-animation/README.md +6 -4
  331. package/examples/techniques/procedural-animation/main.js +9 -7
  332. package/examples/techniques/procedural-animation/picture/index.js +15 -0
  333. package/examples/techniques/procedural-animation/picture/lights.js +35 -0
  334. package/examples/techniques/procedural-animation/picture/materials.js +10 -0
  335. package/examples/techniques/procedural-animation/picture/palette.js +16 -0
  336. package/examples/techniques/procedural-animation/picture/sky.js +31 -0
  337. package/examples/techniques/procedural-animation/proceduralAnim.js +1 -1
  338. package/examples/techniques/procedural-surface/README.md +2 -0
  339. package/examples/techniques/procedural-surface/main.js +17 -55
  340. package/examples/techniques/procedural-surface/picture/index.js +14 -0
  341. package/examples/techniques/procedural-surface/picture/lights.js +18 -0
  342. package/examples/techniques/procedural-surface/picture/materials.js +34 -0
  343. package/examples/techniques/procedural-surface/picture/palette.js +15 -0
  344. package/examples/techniques/stylized-shading/README.md +13 -14
  345. package/examples/techniques/stylized-shading/main.js +11 -42
  346. package/examples/techniques/stylized-shading/picture/index.js +14 -0
  347. package/examples/techniques/stylized-shading/picture/lights.js +23 -0
  348. package/examples/techniques/stylized-shading/picture/materials.js +18 -0
  349. package/examples/techniques/stylized-shading/picture/palette.js +19 -0
  350. package/examples/techniques/stylized-shading/shading.js +2 -2
  351. package/examples/techniques/sun-and-key-light/README.md +20 -22
  352. package/examples/techniques/sun-and-key-light/keyLight.js +47 -29
  353. package/examples/techniques/sun-and-key-light/main.js +19 -63
  354. package/examples/techniques/sun-and-key-light/picture/index.js +13 -0
  355. package/examples/techniques/sun-and-key-light/picture/lights.js +33 -0
  356. package/examples/techniques/sun-and-key-light/picture/materials.js +9 -0
  357. package/examples/techniques/sun-and-key-light/picture/palette.js +29 -0
  358. package/examples/techniques/sun-and-key-light/picture/sky.js +16 -0
  359. package/examples/techniques/three-looks/README.md +21 -0
  360. package/examples/techniques/three-looks/main.js +58 -0
  361. package/examples/techniques/three-looks/picture/cartoon.js +23 -0
  362. package/examples/techniques/three-looks/picture/cinematic.js +27 -0
  363. package/examples/techniques/three-looks/picture/comic.js +27 -0
  364. package/examples/techniques/three-looks/picture/index.js +14 -0
  365. package/examples/techniques/three-looks/picture/sun.js +23 -0
  366. package/examples/techniques/wet-road/README.md +7 -4
  367. package/examples/techniques/wet-road/main.js +18 -38
  368. package/examples/techniques/wet-road/picture/index.js +17 -0
  369. package/examples/techniques/wet-road/picture/lights.js +57 -0
  370. package/examples/techniques/wet-road/picture/materials.js +16 -0
  371. package/examples/techniques/wet-road/picture/palette.js +24 -0
  372. package/examples/techniques/wet-road/picture/sky.js +46 -0
  373. package/examples/webgpu-tsl/GAMEMAP.md +10 -4
  374. package/examples/webgpu-tsl/README.md +13 -10
  375. package/examples/webgpu-tsl/main.js +30 -7
  376. package/examples/webgpu-tsl/picture/index.js +18 -0
  377. package/examples/webgpu-tsl/picture/lights.js +25 -0
  378. package/examples/webgpu-tsl/picture/materials.js +36 -0
  379. package/examples/webgpu-tsl/picture/palette.js +23 -0
  380. package/examples/webgpu-tsl/picture/post.js +16 -0
  381. package/examples/webgpu-tsl/picture/sky.js +30 -0
  382. package/examples/world/.threedog/content-index.json +1 -1
  383. package/examples/world/GAMEMAP.md +16 -12
  384. package/examples/world/art/humanoid.js +9 -13
  385. package/examples/world/art/index.js +2 -2
  386. package/examples/world/art/models.js +3 -4
  387. package/examples/world/art/shapes.js +2 -2
  388. package/examples/world/assets.js +2 -2
  389. package/examples/world/content/audio.js +1 -1
  390. package/examples/world/content/items.js +1 -1
  391. package/examples/world/content/props.js +1 -1
  392. package/examples/world/content/templates.js +1 -1
  393. package/examples/world/content/vegetation.js +1 -1
  394. package/examples/world/main.js +10 -10
  395. package/examples/world/models.js +17 -7
  396. package/examples/world/picture/index.js +20 -0
  397. package/examples/world/picture/lights.js +41 -0
  398. package/examples/world/picture/materials.js +34 -0
  399. package/examples/world/picture/palette.js +74 -0
  400. package/examples/world/picture/post.js +9 -0
  401. package/examples/world/picture/sky.js +39 -0
  402. package/index.d.ts +14 -22
  403. package/index.js +36 -36
  404. package/llms.txt +19 -21
  405. package/modules/ambience/Ambience.js +12 -9
  406. package/modules/calendar/Calendar.js +20 -20
  407. package/modules/calendar/index.js +14 -13
  408. package/modules/calendar/schedule.js +11 -6
  409. package/modules/calendar/seasons.js +7 -7
  410. package/modules/camera/FirstPersonCamera.js +2 -2
  411. package/modules/camera/FixedCamera.js +14 -15
  412. package/modules/camera/FollowCamera.js +4 -4
  413. package/modules/camera/RtsCamera.js +11 -11
  414. package/modules/camera/common.js +51 -25
  415. package/modules/camera/contract.js +1 -0
  416. package/modules/camera/projection.js +2 -2
  417. package/modules/characters/Character.js +47 -39
  418. package/modules/characters/NPC.js +30 -22
  419. package/modules/characters/assetModel.js +18 -13
  420. package/modules/characters/astar.js +7 -5
  421. package/modules/characters/behaviors.js +4 -5
  422. package/modules/characters/contract.js +2 -2
  423. package/modules/characters/index.js +172 -193
  424. package/modules/characters/moveHelpers.js +14 -3
  425. package/modules/characters/movers/common.js +22 -15
  426. package/modules/characters/movers/manual.js +4 -1
  427. package/modules/characters/movers/rapier.js +7 -6
  428. package/modules/characters/movers/simple.js +3 -3
  429. package/modules/characters/movers/support.js +32 -18
  430. package/modules/characters/npcAvoid.js +4 -4
  431. package/modules/characters/npcSim.js +28 -18
  432. package/modules/characters/npcView.js +6 -5
  433. package/modules/characters/pathAsync.js +12 -10
  434. package/modules/characters/pathWorker.js +1 -1
  435. package/modules/characters/player.js +108 -0
  436. package/modules/characters/playerStrings.js +2 -2
  437. package/modules/characters/proceduralRig.js +19 -5
  438. package/modules/characters/useModel.js +5 -5
  439. package/modules/characters/walkTo.js +11 -17
  440. package/modules/collision/Collision.js +30 -22
  441. package/modules/collision/contract.js +15 -0
  442. package/modules/content/explain.js +1 -2
  443. package/modules/content/fields.js +24 -3
  444. package/modules/content/ids.js +2 -2
  445. package/modules/content/index.js +68 -98
  446. package/modules/content/loader.js +14 -17
  447. package/modules/content/markers.js +25 -0
  448. package/modules/content/models.js +66 -18
  449. package/modules/content/packs.js +3 -3
  450. package/modules/content/parts.js +2 -2
  451. package/modules/content/places.js +35 -0
  452. package/modules/content/props.js +19 -14
  453. package/modules/content/rules.js +34 -22
  454. package/modules/content/stages.js +7 -7
  455. package/modules/content/templates.js +24 -22
  456. package/modules/content/words.js +34 -0
  457. package/modules/debug/DebugPanel.js +10 -43
  458. package/modules/flow/contract.js +1 -1
  459. package/modules/flow/index.js +11 -7
  460. package/modules/gameplay/Container.js +12 -11
  461. package/modules/gameplay/Containers.js +14 -5
  462. package/modules/gameplay/Dialogue.js +13 -11
  463. package/modules/gameplay/Interactions.js +115 -27
  464. package/modules/gameplay/Inventory.js +11 -12
  465. package/modules/gameplay/Quests.js +16 -9
  466. package/modules/gameplay/boxOps.js +1 -1
  467. package/modules/gameplay/dialogueBox.js +1 -1
  468. package/modules/gameplay/dialogueBubbles.js +4 -5
  469. package/modules/gameplay/interactionPrompt.js +1 -1
  470. package/modules/gameplay/interactions.contract.js +1 -1
  471. package/modules/gameplay/inventoryOps.js +2 -3
  472. package/modules/gameplay/pickups.js +81 -44
  473. package/modules/gameplay/questLog.js +2 -2
  474. package/modules/gameplay/questSave.js +3 -3
  475. package/modules/grid/Grid.js +1 -1
  476. package/modules/grid/Layer.js +16 -3
  477. package/modules/grid/index.js +47 -19
  478. package/modules/grid/preview.js +29 -20
  479. package/modules/grid/tiles.js +19 -23
  480. package/modules/hlod/index.js +38 -55
  481. package/modules/hud/index.js +27 -8
  482. package/modules/hud/parts.js +13 -11
  483. package/modules/level/contract.js +16 -0
  484. package/modules/level/heightfield.js +12 -10
  485. package/modules/level/index.js +48 -152
  486. package/modules/level/load.js +79 -0
  487. package/modules/level/meshes.js +65 -0
  488. package/modules/level/nodes.js +6 -7
  489. package/modules/lights/index.js +34 -183
  490. package/modules/lights/slots.js +93 -0
  491. package/modules/lights/sources.js +88 -0
  492. package/modules/music/Music.js +31 -27
  493. package/modules/music/rules.js +1 -1
  494. package/modules/nav/contract.js +14 -0
  495. package/modules/nav/index.js +11 -10
  496. package/modules/net/Client.js +7 -7
  497. package/modules/net/Host.js +7 -7
  498. package/modules/net/Net.js +1 -1
  499. package/modules/net/index.js +5 -4
  500. package/modules/net/sync.js +2 -2
  501. package/modules/net/transports.js +2 -2
  502. package/modules/particles/Particles.js +49 -25
  503. package/modules/particles/effect.js +27 -10
  504. package/modules/particles/shaders.js +2 -1
  505. package/modules/photo/Photo.js +26 -27
  506. package/modules/rigid/RigidBodies.js +66 -43
  507. package/modules/rigid/Vehicles.js +2 -3
  508. package/modules/rigid/ragdoll.js +287 -0
  509. package/modules/rigid/ragdollBones.js +159 -0
  510. package/modules/rigid/sync.js +6 -6
  511. package/modules/settings/Settings.js +114 -45
  512. package/modules/settings/apply.js +10 -10
  513. package/modules/settings/sections.js +16 -14
  514. package/modules/settings/strings.js +1 -1
  515. package/modules/settings/view.js +3 -3
  516. package/modules/sky/Sky.js +125 -103
  517. package/modules/sky/clouds.js +22 -23
  518. package/modules/sky/dome.js +113 -0
  519. package/modules/sky/domeLayers.js +13 -13
  520. package/modules/sky/environment.js +47 -171
  521. package/modules/sky/fog.js +5 -180
  522. package/modules/sky/frame.js +42 -97
  523. package/modules/sky/season.js +9 -3
  524. package/modules/sky/shader.js +49 -44
  525. package/modules/sky/skyModule.js +25 -35
  526. package/modules/sky/tint.js +9 -11
  527. package/modules/swarm/Swarm.js +346 -0
  528. package/modules/swarm/draw.js +68 -0
  529. package/modules/swarm/grid.js +63 -0
  530. package/modules/terrain/ChunkManager.js +97 -62
  531. package/modules/terrain/chunkQueries.js +7 -24
  532. package/modules/terrain/chunkWorker.js +1 -1
  533. package/modules/terrain/draw.js +157 -0
  534. package/modules/terrain/index.js +60 -88
  535. package/modules/terrain/terrainColorMap.js +6 -3
  536. package/modules/terrain/terrainDefaults.js +4 -3
  537. package/modules/terrain/terrainEdit.js +32 -27
  538. package/modules/terrain/terrainGen.js +19 -14
  539. package/modules/terrain/terrainIsland.js +2 -2
  540. package/modules/terrain/terrainMesh.js +7 -6
  541. package/modules/terrain/terrainShape.js +8 -10
  542. package/modules/terrain/terrainShapeMain.js +3 -3
  543. package/modules/timeline/Timeline.js +27 -19
  544. package/modules/timeline/Tween.js +6 -6
  545. package/modules/timeline/shots.js +5 -7
  546. package/modules/triggers/index.js +19 -15
  547. package/modules/vegetation/Vegetation.js +87 -39
  548. package/modules/vegetation/densityMap.js +4 -7
  549. package/modules/vegetation/draw.js +196 -0
  550. package/modules/vegetation/groundChunks.js +11 -31
  551. package/modules/vegetation/index.js +18 -16
  552. package/modules/vegetation/modelGeometry.js +3 -6
  553. package/modules/vegetation/nearFade.js +1 -1
  554. package/modules/water/Water.js +140 -93
  555. package/modules/water/surface.js +56 -56
  556. package/modules/weather/Weather.js +84 -38
  557. package/modules/weather/particles.js +18 -10
  558. package/modules/weather/shaders.js +1 -1
  559. package/modules/weather/weatherDraw.js +145 -0
  560. package/modules/world/World.js +10 -10
  561. package/modules/world/explain.js +1 -1
  562. package/modules/world/index.js +18 -12
  563. package/modules/world/persist.js +73 -25
  564. package/modules/world/pos.js +4 -4
  565. package/modules/world/records.js +28 -8
  566. package/modules/world/sim.js +4 -4
  567. package/modules/world/state.js +12 -5
  568. package/modules/world/thingSource.js +4 -2
  569. package/modules/world/views.js +12 -10
  570. package/package.json +44 -8
  571. package/presets.js +3 -5
  572. package/render/PostFX.js +233 -63
  573. package/render/backend.js +72 -32
  574. package/render/cascades.js +200 -0
  575. package/render/cascades.tsl.js +93 -0
  576. package/render/daylight.js +56 -0
  577. package/render/detail.js +13 -12
  578. package/render/effects.js +60 -42
  579. package/render/fuse.js +3 -3
  580. package/render/fx/cel.tsl.js +42 -0
  581. package/render/fx/cloudShadow.tsl.js +3 -3
  582. package/render/fx/detail.tsl.js +1 -1
  583. package/render/fx/index.js +10 -13
  584. package/render/fx/library.tsl.js +11 -0
  585. package/render/fx/lighting.tsl.js +2 -1
  586. package/render/fx/nodeErrors.tsl.js +2 -2
  587. package/render/fx/objectOrigin.tsl.js +1 -2
  588. package/render/fx/patchNodes.tsl.js +6 -16
  589. package/render/fx/postWebGPU.tsl.js +55 -28
  590. package/render/fx/sky.tsl.js +34 -109
  591. package/render/fx/uniforms.tsl.js +4 -4
  592. package/render/fx/water.tsl.js +1 -1
  593. package/render/fx/wind.tsl.js +1 -1
  594. package/render/fxNumbers.js +3 -0
  595. package/render/layers.js +14 -0
  596. package/render/lighting.js +11 -8
  597. package/render/lightmap.js +142 -0
  598. package/render/lights.js +26 -204
  599. package/render/lit.js +24 -0
  600. package/render/materials.js +47 -162
  601. package/render/mergeCommon.js +22 -0
  602. package/render/modeling.js +2 -2
  603. package/render/neutral.js +23 -0
  604. package/render/occlusion.js +200 -0
  605. package/render/ownFrame.js +5 -5
  606. package/render/patches.js +46 -41
  607. package/render/postWebGL.js +19 -9
  608. package/render/probes.js +182 -128
  609. package/render/recordSweep.js +117 -0
  610. package/render/shaderErrors.js +10 -9
  611. package/render/shadowCache.tsl.js +107 -0
  612. package/render/shadowTypes.js +9 -0
  613. package/render/shadows.js +451 -0
  614. package/render/slots.js +11 -11
  615. package/render/terms.js +63 -113
  616. package/render/uniformDecl.js +2 -2
  617. package/types/core.d.ts +489 -405
  618. package/types/gameplay.d.ts +225 -114
  619. package/types/generated/core/{Audio.d.ts → audio/Audio.d.ts} +23 -8
  620. package/types/generated/core/{audioVoice.d.ts → audio/audioVoice.d.ts} +2 -2
  621. package/types/generated/core/{Events.d.ts → base/Events.d.ts} +4 -4
  622. package/types/generated/core/{I18n.d.ts → base/I18n.d.ts} +7 -15
  623. package/types/generated/core/{Random.d.ts → base/Random.d.ts} +4 -3
  624. package/types/generated/core/engine/page.d.ts +24 -0
  625. package/types/generated/core/{Input.d.ts → input/Input.d.ts} +21 -10
  626. package/types/generated/core/{Budget.d.ts → inspect/Budget.d.ts} +36 -26
  627. package/types/generated/core/{DebugOverrides.d.ts → inspect/DebugOverrides.d.ts} +16 -8
  628. package/types/generated/core/{Ops.d.ts → ops/Ops.d.ts} +4 -3
  629. package/types/generated/core/{control.d.ts → ops/control.d.ts} +4 -10
  630. package/types/generated/core/{Saves.d.ts → saves/Saves.d.ts} +37 -13
  631. package/types/generated/core/{session.d.ts → saves/session.d.ts} +2 -1
  632. package/types/generated/core/{Rays.d.ts → scene/Rays.d.ts} +8 -27
  633. package/types/generated/core/{Views.d.ts → scene/Views.d.ts} +1 -1
  634. package/types/generated/core/{Batching.d.ts → stream/Batching.d.ts} +7 -7
  635. package/types/generated/core/{Stream.d.ts → stream/Stream.d.ts} +18 -16
  636. package/types/generated/core/{Commits.d.ts → threads/Commits.d.ts} +1 -1
  637. package/types/generated/core/{Jobs.d.ts → threads/Jobs.d.ts} +6 -6
  638. package/types/generated/core/{Threads.d.ts → threads/Threads.d.ts} +4 -4
  639. package/types/generated/modules/calendar/Calendar.d.ts +10 -11
  640. package/types/generated/modules/debug/DebugPanel.d.ts +1 -9
  641. package/types/generated/modules/grid/Layer.d.ts +9 -1
  642. package/types/generated/modules/grid/index.d.ts +32 -8
  643. package/types/generated/modules/music/Music.d.ts +7 -5
  644. package/types/generated/modules/particles/Particles.d.ts +14 -7
  645. package/types/generated/modules/sky/Sky.d.ts +101 -23
  646. package/types/generated/modules/sky/skyModule.d.ts +1 -1
  647. package/types/generated/modules/swarm/Swarm.d.ts +80 -0
  648. package/types/generated/modules/timeline/Timeline.d.ts +2 -1
  649. package/types/generated/modules/water/Water.d.ts +51 -3
  650. package/types/generated/modules/weather/Weather.d.ts +44 -10
  651. package/types/generated/modules/weather/weatherDraw.d.ts +11 -0
  652. package/types/generated/modules/world/World.d.ts +7 -5
  653. package/types/generated/render/PostFX.d.ts +69 -20
  654. package/types/generated/render/lighting.d.ts +29 -0
  655. package/types/generated/render/materials.d.ts +20 -44
  656. package/types/generated/render/occlusion.d.ts +22 -0
  657. package/types/generated/render/patches.d.ts +1 -0
  658. package/types/generated/ui/Focus.d.ts +1 -0
  659. package/types/generated/ui/UI.d.ts +1 -0
  660. package/types/nav.d.ts +11 -11
  661. package/types/physics.d.ts +104 -73
  662. package/types/tsl.d.ts +45 -4
  663. package/types/world.d.ts +372 -86
  664. package/ui/Focus.js +21 -10
  665. package/ui/LoadingScreen.js +2 -2
  666. package/ui/Parts.js +12 -7
  667. package/ui/UI.js +17 -17
  668. package/ui/cursor.js +1 -1
  669. package/ui/defaults.js +3 -2
  670. package/ui/theme.js +36 -28
  671. package/ui/touchPart.js +1 -1
  672. package/core/UrlState.js +0 -110
  673. package/core/assetEntry.js +0 -106
  674. package/core/describeRender.js +0 -71
  675. package/core/holds.js +0 -134
  676. package/core/look/coreParts.js +0 -219
  677. package/core/look/part.js +0 -253
  678. package/core/look/points.js +0 -255
  679. package/core/look/report.js +0 -96
  680. package/core/look/shadowPart.js +0 -63
  681. package/core/look/state.js +0 -45
  682. package/core/look/write.js +0 -70
  683. package/core/page.js +0 -79
  684. package/core/shadowTypes.js +0 -16
  685. package/core/styleParts.js +0 -114
  686. package/core/util.js +0 -17
  687. package/docs/MIGRATING-0.3.md +0 -248
  688. package/docs/MIGRATING-0.4.md +0 -228
  689. package/docs/MIGRATING-0.5.md +0 -68
  690. package/docs/PERF.md +0 -245
  691. package/docs/api/style.md +0 -136
  692. package/docs/api/terrainLook.md +0 -10
  693. package/docs/api/vegetationLook.md +0 -10
  694. package/docs/api/weatherLook.md +0 -10
  695. package/docs/recipes/09-style.md +0 -218
  696. package/docs/recipes/35-style-from-reference.md +0 -153
  697. package/docs/recipes/36-sky-ground-plant-looks.md +0 -118
  698. package/docs/recipes/37-terrain-look-hooks.md +0 -119
  699. package/docs/recipes/38-environment-look-hooks.md +0 -99
  700. package/docs/recipes/41-thing-registry.md +0 -97
  701. package/docs/recipes/42-terrain-shape.md +0 -64
  702. package/docs/recipes/44-water-weather-look-hooks.md +0 -144
  703. package/docs/recipes/47-island-snow-backdrop.md +0 -45
  704. package/docs/recipes/48-make-material.md +0 -75
  705. package/docs/recipes/52-look.md +0 -282
  706. package/docs/recipes/54-three-idioms.md +0 -88
  707. package/examples/action/look.js +0 -5
  708. package/examples/sheepisland/.threedog/content-index.json +0 -1
  709. package/examples/sheepisland/style/index.js +0 -79
  710. package/examples/styletest/look.js +0 -11
  711. package/examples/techniques/day-night-grade/dayNightGrade.js +0 -76
  712. package/examples/webgpu-tsl/tslScene.js +0 -75
  713. package/examples/world/style/index.js +0 -61
  714. package/examples/world/style/plugins/10-bloom.js +0 -5
  715. package/modules/sky/cascades.js +0 -186
  716. package/modules/sky/cascades.tsl.js +0 -82
  717. package/modules/sky/look.js +0 -54
  718. package/modules/sky/lookFog.js +0 -76
  719. package/modules/sky/lookShadow.js +0 -62
  720. package/modules/sky/lookSky.js +0 -169
  721. package/modules/sky/shadow.js +0 -98
  722. package/modules/terrain/look.js +0 -83
  723. package/modules/terrain/lookGround.js +0 -66
  724. package/modules/vegetation/look.js +0 -119
  725. package/modules/vegetation/lookWind.js +0 -98
  726. package/modules/water/look.js +0 -91
  727. package/modules/water/surfaceDefaults.js +0 -3
  728. package/modules/weather/look.js +0 -74
  729. package/modules/weather/weatherLook.js +0 -135
  730. package/render/lookGlow.js +0 -139
  731. package/render/lookSurface.js +0 -224
  732. package/render/postLook.js +0 -164
  733. package/render/surface.js +0 -105
  734. package/types/generated/core/page.d.ts +0 -18
  735. package/types/generated/modules/weather/weatherLook.d.ts +0 -12
  736. package/types/style.d.ts +0 -671
  737. /package/core/{Vars.js → base/Vars.js} +0 -0
  738. /package/core/{mulberry32.js → base/mulberry32.js} +0 -0
  739. /package/core/{inputDefaults.js → input/inputDefaults.js} +0 -0
  740. /package/core/{textureBytes.js → inspect/textureBytes.js} +0 -0
  741. /package/core/{actor.js → ops/actor.js} +0 -0
  742. /package/core/{opsFail.js → ops/opsFail.js} +0 -0
  743. /package/core/{opsHistory.js → ops/opsHistory.js} +0 -0
  744. /package/core/{saveIds.js → saves/saveIds.js} +0 -0
  745. /package/core/{screenToGround.js → scene/screenToGround.js} +0 -0
  746. /package/core/{cells.js → stream/cells.js} +0 -0
  747. /package/core/{streamCells.js → stream/streamCells.js} +0 -0
  748. /package/core/{pureWorker.js → threads/pureWorker.js} +0 -0
  749. /package/examples/{sheepisland → perf-island}/content/index.js +0 -0
  750. /package/examples/{sheepisland → perf-island}/content/props.js +0 -0
@@ -4,67 +4,74 @@ Characters: createPlayer() (characters() module)
4
4
 
5
5
  - Options `CharactersOptions`:
6
6
  - `npcs?: boolean` Whether to enable NPCs (engine.npcs), default true
7
- - `npcTiers?: { fullRadius: number; nearEvery: number }` Near tiers for large NPC crowds, off by default (every near NPC walks every fixed step); same as engine.npcs.tiers(opts)
7
+ - `npcTiers?: { fullRadius: number; nearEvery: number }` (experimental) Near tiers for large NPC crowds, off by default (every near NPC walks every fixed step); same as engine.npcs.tiers(opts)
8
+ - `animation?: AnimatorOptions` What every character's Animator starts from, e.g. { fade: 0.15 }; a model's manifest mapping and the character's own animation win over it
8
9
 
9
10
  ## Methods and properties
10
11
  - `characters.findSpawn(position?: PositionLike, opts?: FindSpawnOptions) → Vector3` — Find a spawn point: searches outward from position (default origin) for walkable (not steep, no obstacle), non-water ground, without assuming terrain height; e.g. findSpawn(v, { minH: 3, maxH: 20 }). Returns a Vector3 (y is the ground height)
11
12
  - `characters.createPlayer(opts: PlayerOptions) → Character` — Create the player and set engine.player; control is required (no default feel), e.g. createPlayer({ ...presets.player.thirdPerson, spawn }). An existing player is deleted first
12
13
  - `characters.moveInput() → { x, z, run }` — The 'camera' player control as a value: keys / stick relative to the camera, the 'run' action if bound, input.autopilot. Reused object; call it inside your own control function to wrap it
13
14
  - `characters.support(object: any, opts?: { id?, safe?, carry?, inherit? }) → { id: string; remove(): void }` — Something characters stand on and ride (moving platform, lift, raft). Move the object any way (onFixed before or after the player, a timeline, physics): riders follow how its matrix changed, so the order does not matter. safe: false = never a respawn spot; carry 'position+yaw' turns riders with it; inherit: false = jumping off keeps none of its speed. With mover 'rapier' give it a collider too. Example: `const lift = engine.characters.support(liftMesh); engine.onFixed(() => { liftMesh.position.y = 2 + Math.sin(engine.time.now('real')); });`
14
- - `characters.removePlayer()` — Delete the current player (exits the vehicle first, stops responding to keys, fully deletes the model). The player save (key player) carries the position and the vehicle; loading an on-foot save exits the vehicle first
15
+ - `characters.removePlayer()` — (experimental) Delete the current player (exits the vehicle first, stops responding to keys, fully deletes the model). The player save (key player) carries the position and the vehicle; loading an on-foot save exits the vehicle first
15
16
  - `characters.findPath(from: PositionLike, to: PositionLike, opts?: FindPathOptions & { detailed?: false }) → XZ[] | null` / `findPath(from: PositionLike, to: PositionLike, opts: FindPathOptions & { detailed: true }) → PathResult` — Pathfinding (the single entry point): uses the navmesh when nav is installed and ready, otherwise the A* fallback. Returns a path [{ x, z }...], or null if unreachable
16
17
  - `characters.findPathAsync(from: PositionLike, to: PositionLike, done: (path, status) => void, opts?: { radius?, step?, maxNodes? }) → { remove(): void }` — findPath for many callers (NPC crowds, AI squads): solved in engine.threads workers; done(path, status) runs on a fixed step a few steps later (same paths with threads on or off). Recipe 12 section 4
17
18
  - Properties:
19
+ - `material: Material` The three.js material of every placeholder capsule. Set it to swap the look of all of them at once; used as given, with no patches added. A character with colors.body draws with a copy of it in that color. A model's own materials are the model's. Example: `engine.characters.material = new THREE.MeshToonMaterial({ color: 0xd9a066 });`
18
20
  - `pathsPerStep: number` How many findPathAsync requests leave per fixed step (default 32); the rest wait for the next steps
19
21
 
20
22
  ## Character (engine.player / NPC are both Character)
21
23
  - `player.push(vx: number, vz: number, seconds: number)` — Move at a fixed velocity (m/s) for seconds, ignoring move()'s direction and without turning (knockback, dodge roll); gravity and collision still apply
22
24
  - `player.stat(name: 'speed' | 'runSpeed' | 'gravity' | …) → number` — A movement stat as the mover uses it now: the base field with every engine.mod('move.<name>') entry applied (canJump reads 1 / 0). Example: `engine.mod('move.speed', { owner: 'haste', id: 'player', mul: 1.2, for: 5 }); player.stat('speed') // 1.2 x player.speed`
23
- - `player.addJumps(n?: number)` — Give back n jumps for this airtime (pickup, wall touch)
24
- - `player.resetJumps()` — All jumps back, as if it had landed
25
+ - `player.addJumps(n?: number)` — (experimental) Give back n jumps for this airtime (pickup, wall touch)
26
+ - `player.resetJumps()` — (experimental) All jumps back, as if it had landed
25
27
  - `player.launch(speed: number, opts?: { owner?: string })` — Throw it upward at speed m/s (jump pad, spring): leaves the ground, ends coyote time, the ground jump counts as used (air jumps stay); emits character:launch. Example: `player.launch(19, { owner: 'pad' })`
26
- - `player.jumpState() → { grounded, coyoteLeft, bufferLeft, jumpsUsed, jumpsLeft, vy }` — Jump state now, read-only
28
+ - `player.jumpState() → { grounded, coyoteLeft, bufferLeft, jumpsUsed, jumpsLeft, vy }` — (experimental) Jump state now, read-only
27
29
  - `player.enter(vehicle: Rideable)` — Board a vehicle (rigid.addWheeled's, or any object with the vehicle contract): the driver seat when free, else a free passenger seat; no-op when full
28
30
  - `player.exit()` — Exit the vehicle
29
31
  - `player.playAction(name: string)` — Play a one-shot action (e.g. 'wave'); skipped if the model has no such clip
30
32
  - `player.onPose(fn: (character, dt) => void) → { remove(): void }` — Run fn(character, dt) every frame right after the animation pose is applied (model clips or procedural rig): attach things to bones or adjust bones. h.remove() stops it. Presentation only. Example: `const h = player.onPose(() => sword.position.copy(hand.getWorldPosition(v)));`
31
33
  - `player.dispose()` — Fully delete this character: exits the vehicle first, releases animation and movement, removes it from the scene and releases geometry and materials (used by npcs.remove / removePlayer)
32
34
  - `player.jump(opts?: { air?: boolean })` — Request a jump (buffered for jumpBuffer s): the ground jump on the ground or in coyote time, else an air jump while maxJumps allows; air: false = ground only. Example: `createPlayer({ ...presets.player.thirdPerson, maxJumps: 2 }) // double jump`
33
- - `player.addTo(scene?: any)` — Add to the scene
34
35
  - `player.placeAt(position: PositionLike)` — Put it on the ground at position (Vector3 / object / [x, y, z] / { x, z })
35
36
  - `player.syncRecord()` — After moving root yourself (a cutscene path, a scripted pose): write position and motion back to its world record (the player's), so a save right after has it
36
37
  - `player.walkTo(target: Vector3 | { x: number; z: number } | [number, number, number] | …, opts?: { speed?, arrive?, turnRate?, stuckSeconds?, maxRepaths?, run? }) → Promise<{ status: 'arri… & { remove(): void }` — Walk to a point along characters.findPath on fixed steps; never rejects. One walk per character: a new walkTo, dispose() or a save load ends the old one with 'cancelled'. Transient: not saved, not fast-forwarded by engine.skip. Holds the character's control on layer 'script' (owner 'walkTo'): the player's keys / an NPC's schedule pause meanwhile, a cutscene pauses the walk, and another script owner on it is control-conflict
37
38
  - `player.move(dirX: number, dirZ: number, run: boolean, dt: number)` — Move in a direction (called once per fixed step): dirX/dirZ is the world direction (length 0–1 scales the speed), run to run, dt in seconds (used as given). Speed comes from the stats: engine.mod('move.speed', { owner, id: character.id, ... }) (the player: id 'player'), the one way to change speed. A character someone controls (engine.control.of(ch)) moves only through its holder: called from anywhere else it is control-bypass in dev; take control and use handle.move() / step instead
38
39
  - `player.groundType() → string` — Ground type underfoot ('water' while swimming)
39
40
  - `player.face(target: PositionLike | number)` — Turn at once to a position, or to an angle in radians (0 = +Z)
40
- - `player.saveMotion(out?: CharacterMotion) → CharacterMotion` — Copy the motion state into a plain object (velocity, vertical velocity, heading, movement amount, grounded, swimming) to store in world data; after the model is rebuilt or a save is loaded, loadMotion continues from it with identical results
41
- - `player.loadMotion(m: CharacterMotion | null | undefined)` — Restore the motion state from the plain object of saveMotion
41
+ - `player.saveMotion(out?: CharacterMotion) → CharacterMotion` — (experimental) Copy the motion state into a plain object (velocity, vertical velocity, heading, movement amount, grounded, swimming) to store in world data; after the model is rebuilt or a save is loaded, loadMotion continues from it with identical results
42
+ - `player.loadMotion(m: CharacterMotion | null | undefined)` — (experimental) Restore the motion state from the plain object of saveMotion
42
43
  - Properties:
43
- - `root: Object3D` Root node (this is what gets added to the scene)
44
- - `object: Object3D` Same as root: add children, change visible and scale on it
44
+ - `root: Object3D` Root node: add it to the scene with engine.add(character.root) when you built the Character yourself; add children, change visible and scale on it
45
45
  - `position: Vector3` Position (= root.position)
46
46
  - `velocity: Vector2` Horizontal velocity (x, y map to world x, z). Writable: a write is an impulse the mover steers back toward the input (lasting knockback: push(); full control: mover 'manual')
47
47
  - `facing: number` Heading (radians): 0 faces +Z, forward = (sin facing, cos facing); increasing turns toward +X (rotation about the Y axis, consistent with root.rotation.y)
48
- - `vy: number` Vertical velocity (m/s). Writable: setting it is an impulse (launch() does the same and also leaves the ground cleanly)
48
+ - `vy: number` Vertical velocity (m/s), kept apart from velocity, which is horizontal only (velocity.y is world z, not this). Writable: setting it is an impulse (launch() does the same and also leaves the ground cleanly)
49
49
  - `grounded: boolean` Whether standing on the ground
50
- - `swimming: boolean` Whether swimming
50
+ - `swimming: boolean` (experimental) Whether swimming
51
51
  - `state: CharacterState` Current action state
52
52
  - `moveAmount: number` Current movement speed (m/s)
53
53
  - `faceMode: FaceMode` Facing mode, change at any time; see CharacterOptions.faceMode
54
54
  - `faceTarget: PositionLike | null` What faceMode 'target' faces
55
- - `cameraFollow?: boolean` Player only: whether the camera module follows it (see PlayerOptions.cameraFollow)
56
- - `maxJumps: number` Base jump values (the game's; modifiers go through engine.mod('move.jumpSpeed'))
57
- - `fall: false | { belowY }` Fall check (see CharacterOptions.fall); a plain property
55
+ - `cameraFollow?: boolean` (experimental) Player only: whether the camera module follows it (see PlayerOptions.cameraFollow)
56
+ - `swimDepth: number` (experimental)
57
+ - `swimSpeedFactor: number` (experimental)
58
+ - `turnSpeed: number` (experimental)
59
+ - `acceleration: number` (experimental)
60
+ - `stepHeight: number` (experimental)
61
+ - `airControl: number` (experimental)
62
+ - `coyoteTime: number` (experimental)
63
+ - `maxJumps: number` (experimental) Base jump values (the game's; modifiers go through engine.mod('move.jumpSpeed'))
64
+ - `airJumpSpeed: number | null` (experimental)
65
+ - `jumpBuffer: number` (experimental)
66
+ - `fall: false | { belowY }` (experimental) Fall check (see CharacterOptions.fall); a plain property
58
67
  - `channel: string` Time channel the engine drives it on (see CharacterOptions.channel)
59
68
  - `id: string` The character's id, the one form engine.mod / time.local take: its world record id ('player', an NPC's record id), else the id option, else a generated one
60
69
  - `support: { kind, object, id, safe, velocity }` What it stands on, read-only (reused object); 'platform' = a registered support (characters.support), which carries it
61
70
  - `safeGround: Vector3 | null` Last spot it stood still on safe ground (where a fall returns it); null until it first stands. Saved with the motion
62
- - `onStep: ((groundType: string) => void) | null` Called when a foot lands (the argument is the ground type underfoot)
63
- - `onLand: ((impact: number) => void) | null` Called on landing (the argument is the landing speed)
64
71
  - `mover: { name, controller?, body?, collider?, move, dispose? }` How it walks now; name is 'simple' / 'rapier' / 'manual', controller is the native Rapier character controller (when rapier). Assign a name to switch: c.mover = 'manual'
65
72
  - `anim: Animator | null` Skeletal animation state machine (when there is a glTF model; null while a model named by asset is still loading)
66
73
  - `ready: boolean` false while a model named by asset is loading (the placeholder body shows); true otherwise, also after a failed load (placeholder kept)
67
- - `whenReady: Promise<void>` Settles (never rejects) when a model named by asset is swapped in or has failed; already settled otherwise. Example: `const npc = new Character(engine, { model: 'villager' }).addTo(); // import { Character } from 'threedog' await npc.whenReady; npc.playAction('Wave');`
74
+ - `whenReady: Promise<void>` Settles (never rejects) when a model named by asset is swapped in or has failed; already settled otherwise. Example: `const npc = new Character(engine, { model: 'villager' }); engine.add(npc.root); // import { Character } from 'threedog' await npc.whenReady; npc.playAction('Wave');`
68
75
  - `vehicle: Rideable | null` The vehicle it sits in (null on foot)
69
76
  - `seat: number | null` Its seat in the vehicle: 0 drives, others ride; null on foot
70
77
 
@@ -113,7 +120,7 @@ Characters: createPlayer() (characters() module)
113
120
  - `control: PlayerControl` Required, no default: 'camera' (keys relative to the camera) / (player, input, dt) => ({ x, z, run? }) (null stands still). presets.player.* fill it. Given once: a game that steers the player for a while takes control (engine.control.take(player, { owner, layer: 'script', step }))
114
121
  - `cameraFollow?: boolean` true: the camera module follows the player (and back after a vehicle, and on a new session). Omitted with a camera installed warns in dev
115
122
  - **CharacterOptions** Character parameters (shared by the player and NPCs)
116
- - `colors?: { body?, skin?, legs?, hair? }` Per-character part colors: recolor the body's meshes marked userData.part (a humanoid rig: body, skin, legs, hair); the style tints by material role
123
+ - `colors?: { body?, skin?, legs?, hair? }` Per-character part colors: recolor the body's meshes marked userData.part (a humanoid rig: body, skin, legs, hair)
117
124
  - `speed?: number` Walking speed (m/s), default 4.5
118
125
  - `runSpeed?: number` Running speed (m/s), default 7
119
126
  - `radius?: number` Collision radius (meters), default 0.4
package/docs/api/clock.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # engine.clock (Clock) — engine.clock: calendar seconds and "after how long / every how long"
2
2
 
3
- - `clock.after(seconds: number, fnOrEvent: (() => void) | string, data?: any, opts?: { channel?: string }) → Handle` — Call fn after seconds calendar seconds; if an event name is passed, the event is emitted when due (with data, can be saved). { channel } counts that time channel's seconds instead (a poison tick that slows down in bullet time)
3
+ - `clock.after(seconds: number, fnOrEvent: (() => void) | string, opts?: { data?: any; channel?: string }) → Handle` — Call fn after seconds calendar seconds; if an event name is passed, the event is emitted when due (with data, can be saved). { channel } counts that time channel's seconds instead (a poison tick that slows down in bullet time)
4
4
  - `clock.every(seconds: number, fn: () => void, opts?: { channel?: string }) → Handle` — Call once every seconds calendar seconds ({ channel }: 'real' or a time channel's seconds instead)
5
5
  - Properties:
6
6
  - `now: number` Calendar seconds = world-channel seconds x clock.rate, does not advance while paused / frozen, saved with the game; one calendar day = calendar.dayLength calendar seconds
@@ -5,28 +5,31 @@ Lightweight collision (collision() module): no clipping while walking, the camer
5
5
  - Options `CollisionOptions`:
6
6
  - `maxClimb?: number` Max walkable slope (height difference / horizontal distance), default 1.1
7
7
  - `canopyHeight?: number` A camera above this height (meters) is not considered blocked by trees, default 5
8
- - `cameraPad?: number` Margin between the camera and obstacles (meters), default 0.5
8
+ - `cameraPad?: number` (experimental) Margin between the camera and obstacles (meters), default 0.5
9
9
  - `cameraMin?: number` Nearest camera distance (meters), default 1.5
10
- - `walkableWaterMargin?: number` Height above the water surface (meters) at which it counts as walkable, default 0.2
11
- - `cameraOcclusion?: 'colliders' | 'meshes' | 'both'` What camera occlusion checks: 'colliders' (default) / 'meshes' registered static meshes (engine.rays) / 'both'
10
+ - `walkableWaterMargin?: number` (experimental) Height above the water surface (meters) at which it counts as walkable, default 0.2
11
+ - `cameraOcclusion?: 'colliders' | 'meshes' | 'both'` What camera occlusion checks: 'both' (default) / 'colliders' / 'meshes' = static meshes registered with engine.rays.addStatic(mesh, { occluder: true })
12
12
 
13
13
  ## Methods and properties
14
14
  - `collision.addCircle(position: PositionLike, opts?: CircleColliderOptions) → Handle` — Add a circle collider (pillar, campfire): position is the center, e.g. addCircle(mesh, { radius: 1 }). Returns a handle { remove() }
15
15
  - `collision.addBox(position: PositionLike, opts?: BoxColliderOptions) → Handle` — Add a box collider (house, fence): position is the center, e.g. addBox(house, { halfWidth: 3, halfDepth: 2, rotation: 0.3 }). Returns a handle { remove() }
16
16
  - `collision.addSegment(a: PositionLike, b: PositionLike, opts?: { thickness?, height?, y?, occluder? }) → Handle` — Add a thin wall along a -> b (fence). Options: thickness (default 0.3), height, y, occluder (as in addBox). A gap between segments is a gate. Returns a handle { remove() }
17
- - `collision.addBlocked(fn: (x: number, z: number) => boolean, opts?: { bounds? }) → Handle` — Mark ground impassable where fn(x, z) is true (river, lava); fn must be pure. bounds { minX, maxX, minZ, maxZ } (world metres, the field's x / z extent) skips fn outside it; give it to keep findPathAsync's ground sampling cheap. Returns a handle { remove() }
18
- - `collision.blockedAt(x: number, z: number, radius?: number) → boolean` — Is a character of this radius touching addBlocked ground at (x, z)
17
+ - `collision.addBlocked(fn: (x: number, z: number) => boolean, opts?: { bounds? }) → Handle` — Mark ground impassable where fn(x, z) is true (river, lava); fn must be pure (no side effects, same answer for the same (x, z)); reading engine.ground in it is fine. findPathAsync caches the answers, so after the ground or your own state changes, remove() and add the field again. bounds { minX, maxX, minZ, maxZ } (world metres, the field's x / z extent) skips fn outside it; give it to keep findPathAsync's ground sampling cheap. Returns a handle { remove() }
18
+ - `collision.blockedAt(x: number, z: number, radius?: number) → boolean` — (experimental) Is a character of this radius touching addBlocked ground at (x, z)
19
19
  - `collision.addObject(obj: Object3D, opts?: { pad?: number; occluder?: boolean }) → Handle` — Add a collider from an object's bounding box, pad expands outward (meters), occluder as in addBox. Returns a handle { remove() }
20
- - `collision.forEachStatic(fn: (type, data) => void)` — Iterate all static colliders added by hand
21
- - `collision.mirror(fns: { add, remove }) → { sync, clear, size }` — Keep an outside copy of the static colliders in step (physics colliders, navmesh obstacles): add builds one piece, remove drops one; sync() diffs only when colliders changed and returns whether it compared; clear() forgets every piece without remove (the outside world was thrown away)
20
+ - `collision.forEachStatic(fn: (type, data) => void)` — (experimental) Iterate all static colliders added by hand
21
+ - `collision.mirror(fns: { add, remove }) → { sync, clear, size }` — (experimental) Keep an outside copy of the static colliders in step (physics colliders, navmesh obstacles): add builds one piece, remove drops one; sync() diffs only when colliders changed and returns whether it compared; clear() forgets every piece without remove (the outside world was thrown away)
22
22
  - `collision.walkable(position: PositionLike, opts?: { radius?: number }) → boolean` — Whether someone can stand at this position (for pathfinding): not in water, not too steep, not inside an obstacle. radius is the character radius (meters, default engine.movement.radius)
23
23
  - `collision.walkableAt(x: number, z: number, radius?: number) → boolean` — walkable with plain numbers, allocating nothing (A* inner loops); radius defaults to engine.movement.radius
24
24
  - `collision.lineClear(a: PositionLike, b: PositionLike, opts?: { radius?, who? }) → boolean` — Line of sight with height: is the 3D segment a -> b free of boxes, circles and terrain trees? radius fattens the line; addBlocked water is ignored. Give eye heights in a / b
25
25
  - Properties:
26
- - `cameraOcclusion: 'colliders' | 'meshes' | 'both'` What camera occlusion checks (see CollisionOptions.cameraOcclusion)
27
- - `circles: Set<CircleCollider>` Circle colliders added by hand
28
- - `boxes: Set<BoxCollider>` Box colliders added by hand
29
- - `version: number` +1 each time a static collider is added or removed
26
+ - `maxClimb: number` (experimental)
27
+ - `canopyHeight: number` (experimental)
28
+ - `cameraPad: number` (experimental)
29
+ - `cameraMin: number` (experimental)
30
+ - `walkableWaterMargin: number` (experimental)
31
+ - `cameraOcclusion: 'colliders' | 'meshes' | 'both'` (experimental) What camera occlusion checks (see CollisionOptions.cameraOcclusion)
32
+ - `version: number` (experimental) +1 each time a static collider is added or removed
30
33
 
31
34
  ## Data structures
32
35
  - **CircleColliderOptions** Parameters of addCircle() (meters)
@@ -11,7 +11,7 @@ Content loading (content() module)
11
11
  - `content.place(name: string) → XZ | null` — Place name -> position (load's places first, then level markers), null if none
12
12
  - `content.where(p: { place?, x?, z? }) → XZ` — Position form in content { place?, x?, z? } -> world coordinates
13
13
  - `content.template(name: string) → Readonly<ContentTemplate>` — The shared, frozen definition of a content template (content/templates.js); instance state lives on the world record. e.g. template('chest').container.capacity
14
- - `content.fields(name: string) → Record<string, ContentField>` — The fields one content entry may have (core/params.js spec format): what an editor panel lists and what content-check validates against. name: a template name (placement fields plus its state fields, default = the value in state), an engine entry shape ('props', 'props.template', 'props.grid', 'pickups', 'views'), a game kind that declares fields (content/rules.js kinds), or a world record id. Unknown names throw. Example: `engine.content.fields('crop').stage // { type: 'int', optional: true, default: 0, min: 0, max: 4 }`
14
+ - `content.fields(name: string) → Record<string, ContentField>` — The fields one content entry may have (core/base/params.js spec format): what an editor panel lists and what content-check validates against. name: a template name (placement fields plus its state fields, default = the value in state), an engine entry shape ('props', 'props.template', 'props.grid', 'pickups', 'views'), a game kind that declares fields (content/rules.js kinds), or a world record id. Unknown names throw. Example: `engine.content.fields('crop').stage // { type: 'int', optional: true, default: 0, min: 0, max: 4 }`
15
15
  - `content.spawn(name: string, at: any, fields?: { id?, rot?, scale?, y?, items?, … }) → WorldRecord` — Place a new runtime instance of a content template (inside an op or a fixed step), saved whole; returns the world record (kind = template name, id `<template>#<n>` unless fields.id is given). fields: id, rot, scale, y (height above ground), items (container start goods), state fields (stage too, for a template with stages). Example: `engine.ops.define('chest.build', { run: (e, { x, z }) => e.content.spawn('chest', { x, z }, { items: { stick: 3 } }).id })`
16
16
  - Properties:
17
17
  - `ready: boolean` All vegetation models are fetched and the models of world data such as nearby props are built (world.ready)
@@ -48,13 +48,13 @@ Conditions are used in quest step done, dialogue option if and line variant if;
48
48
  - `items.js` items (id -> name, icon, description); also export startItems for starting items
49
49
  - `pickups.js` pickups on the ground (list)
50
50
  - `containers.js` chests / shelves (container id -> { capacity, items: starting goods }; starting goods are placed only the first time, then saved)
51
- - `npcs.js` NPCs (id -> name, schedule, dialogue)
51
+ - `npcs.js` NPCs (id -> name, schedule, interact)
52
52
  - `dialogues.js` dialogues (id -> speaker, nodes)
53
53
  - `quests.js` quests (id -> title, steps, reward; a step can have a target position)
54
54
  - `actions.js` own key actions of the game (action name -> default key, label)
55
- - `places.js` place names (coordinates computed at runtime in main.js)
55
+ - `places.js` place names (name -> { x, z, y?, rot? }; rot turns everything placed there about Y; coordinates may be computed at runtime in main.js)
56
56
  - `triggers.js` trigger zones (tag -> position / from level, enter/exit effects)
57
- - `level.js` level markers (spawn point, NPCs, trigger zones)
57
+ - `level.js` level markers (spawn point, NPCs, trigger zones) of a code-built level: for the tools (content checks, GAMEMAP); load() accepts the file and does not read it
58
58
  - `vegetation.js` vegetation (name -> model, growth rule)
59
59
  - `props.js` props (list: model, position, facing, collision; or { template, x, z } = an instance of a template; or { id, grid, item, cell } = a grid item), streamed in on demand
60
60
  - `templates.js` reusable objects (name -> model, collide, interact, container, sound, animate, state defaults, physics body); shared read-only definitions
@@ -62,5 +62,5 @@ Conditions are used in quest step done, dialogue option if and line variant if;
62
62
  - `views.js` named fixed camera views (name -> { position: [x, y, z], target?: [x, y, z], fov? }); engine.views.show(name), ?view=name, npm run shot -- -w game --view name
63
63
  - `grids.js` placement grids (name -> { cell, origin, size, zone?, flat? }); layout rules, not saved
64
64
  - `renames.js` renamed or deleted authored ids (old id -> new id, or null = deleted on purpose): the player's saved changes follow the new id
65
- - `rules.js` condition words added by the game ({ conditions }); actions are ops, not effect words
66
- - any other `<name>.js` the game registers in content/rules.js as kinds: { name: { desc, load(e, data), check?, map? } } (enemies, recipes, loot tables…)
65
+ - `rules.js` condition words and data kinds added by the game ({ conditions, kinds }); actions are ops, not effect words
66
+ - any other `<name>.js` the game registers in content/rules.js as kinds: { name: { desc, load?(e, data), check?, map? } } (enemies, recipes, loot tables…)
@@ -15,10 +15,10 @@ Dialogue (dialogue() module). Ops: `dialogue.advance` (finish typing the line, e
15
15
  - `dialogue.end()` — End the main dialogue
16
16
  - Properties:
17
17
  - `state: DialogueState` Story state: state.flags is engine.vars.flags (autosaved)
18
- - `scripts: Map<string, DialogueScript>` All scripts
18
+ - `scripts: Map<string, DialogueScript>` (experimental) All scripts
19
19
  - `active: { speaker, nodes, node?, id?, onEnd } | null` The dialogue in progress (null when none). speaker: the script name; node: the current node OBJECT (its fields: text, choices, data...); id: that node's id string ('start', 'ask'); both are set once the first line shows. Read-only: drive it with start / end / the dialogue ops. Example: `const atAsk = engine.dialogue.active?.id === 'ask'; // the node id; active.node.data holds the node's own fields`
20
- - `speaking: string | null` The script the main dialogue is playing
21
- - `cps: number` Typing speed (characters/second)
20
+ - `speaking: string | null` (experimental) The script the main dialogue is playing
21
+ - `charsPerSecond: number` (experimental) Typing speed (characters/second)
22
22
 
23
23
  ## Data structures
24
24
  - **DialogueScript** = `Record<string, DialogueNode>` — Dialogue script: node name -> node, starting from 'start'
@@ -1,16 +1,15 @@
1
1
  # engine — createEngine and the Engine class (core)
2
2
 
3
- - `createEngine(opts: EngineOptions) → Engine` — Create an engine (core only). canvas is required; style is the game's style (see recipes/09-style.md)
3
+ - `createEngine(opts: EngineOptions) → Engine` — Create an engine (core only). canvas is required
4
4
  - Options `EngineOptions`:
5
5
  - `canvas?: HTMLCanvasElement | HTMLElement` Canvas element (required unless renderer is given), e.g. document.getElementById('view')
6
6
  - `renderer?: 'webgl' | 'webgpu' | EngineRenderer` 'webgl' (default): the engine builds a WebGLRenderer. 'webgpu': it builds three's WebGPURenderer (needs import 'threedog/tsl' first) and start() awaits its init(). Or a ready three.js renderer (WebGLRenderer or WebGPURenderer) used as is; canvas then defaults to renderer.domElement.
7
7
  - `fallback?: 'webgl2' | 'webgl' | 'error'` WebGPU route only: what start() does when the browser gives no WebGPU. 'webgl2' (default): the same WebGPURenderer on its WebGL2 backend, TSL keeps working; 'webgl': a WebGLRenderer instead (faster, but NodeMaterials cannot draw: start() fails if the scene has one); 'error': start() rejects.
8
- - `style?: StyleInput` Style (looks only: materials, sky, lighting, post, UI look), the game's own style (import style from './style/index.js'), or a list of parts deep-merged left to right: [basePack, { sky: { sunSize: 600 } }]. Without one: neutral gray placeholders
9
- - `antialias?: boolean` MSAA anti-aliasing (kept with post effects on), default style.antialias, else on for desktop and off for low-tier devices; with a renderer of your own, its own antialias. The start value is the canvas's own MSAA (no post chain while no effect is on)
8
+ - `antialias?: boolean` MSAA anti-aliasing (kept with post effects on), default on for desktop and off for low-tier devices; with a renderer of your own, its own antialias. The start value is the canvas's own MSAA (no post chain while no effect is on)
10
9
  - `pixelRatio?: number` Render resolution, default min(device pixel ratio, 1.5); the low tier uses at least 0.75 x device pixel ratio (never below 1). describe().render.scale reports it
11
10
  - `adaptiveResolution?: boolean` Automatically lower resolution when the frame rate is too low, default true. Never silent: a dev warning once, and describe().render.scale.autoLowered
12
11
  - `targetFps?: number` Target frame rate for automatic resolution lowering, default 55
13
- - `ui?: Record<string, UIPartValue>` UI parts: replace or turn off any piece of screen UI (loading, toast, title, hud.marker, hud.counter, hud.bar). Default title screen is off. Example: `createEngine({ canvas, ui: { loading: { title: 'My Game' }, title: { title: 'My Game' }, toast: false } })`
12
+ - `ui?: UIOptions` All screen UI: replace or turn off any part (loading, toast, title, hud.marker, hud.counter, hud.bar; the default title screen is off), and the look of the default parts (theme, css, fonts, templates). Example: `createEngine({ canvas, ui: { loading: { title: 'My Game' }, title: { title: 'My Game' }, toast: false } })`
14
13
  - `audio?: AudioConfig` Volume of each channel, 0–1
15
14
  - `fov?: number` Camera field of view (degrees), default 55
16
15
  - `near?: number` Camera near clipping plane (meters), default 0.3
@@ -20,27 +19,27 @@
20
19
  - `saveKey?: string` Save name prefix; must differ when several games share one site, default 'game'
21
20
  - `joystick?: 'auto' | boolean` On-screen joystick: 'auto' (only on touch devices) / true / false
22
21
  - `headless?: boolean` Headless mode: no real-time loop and no per-frame rendering, advances only on step() (for tests and screenshots). Adding ?threedog-headless to the URL also turns it on
23
- - `validate?: boolean` Check parameter names at runtime and warn on misspelled names (the console prints "did you mean xxx"), default true; a release build can write false to turn it off
24
- - `decoders?: string` Directory of Draco/KTX2 decoders (a URL containing draco/ and basis/), for when they live on a CDN. Normally not needed: the decoders bundled with three are packed by vite automatically
22
+ - `validate?: boolean` (experimental) Check parameter names at runtime and warn on misspelled names (the console prints "did you mean xxx"), default true; a release build can write false to turn it off
23
+ - `decoders?: string` (experimental) Directory of Draco/KTX2 decoders (a URL containing draco/ and basis/), for when they live on a CDN. Normally not needed: the decoders bundled with three are packed by vite automatically
25
24
  - `budget?: BudgetLimits` Performance budget limits, e.g. { drawCalls: 250, fps: 55 }; only the given categories are checked; off by default
26
- - `urlState?: boolean` Set up a scenario from URL parameters (?time=18:30&weather=rain&pos=40,-20), default on only in development
25
+ - `urlState?: boolean` (experimental) Set up a scenario from URL parameters (?time=18:30&weather=rain&pos=40,-20), default on only in development
27
26
  - `seed?: number` Seed for engine.random; default 1 in headless mode (reproducible), the current time for live runs (different every game)
28
27
  - `movement?: Partial<MovementProfile>` Shared "can walk there" parameters (meters / degrees): collision, the Rapier capsule, navigation and level steps all read them by default. Default { radius: 0.4, height: 1.8, maxSlope: 48, stepHeight: 0.45 }
29
28
  - `threads?: 'auto' | number | false` (experimental) Worker pool size for engine.threads: 'auto' (default: cores - 1, at most 4), a worker count, or false (all on the main thread, same results, no workers created)
30
29
  - `pauseOnBlur?: boolean` Gameplay waits while the window is in the background or the tab is hidden; default true (engine.page)
31
- - `lights?: boolean` false: no default lights in the scene at all (engine.lights.sun / hemi still exist, detached, so sky and describe never see undefined); the game adds its own. Default true
32
- - `batching?: false | BatchingOptions` Automatic instancing of repeated static models the engine places (engine.batching; your own meshes opt in with userData.batch = true): false turns it off; default { minCount: 8, cell: engine.stream.cellSize }
30
+ - `lights?: boolean` false: no default lights in the scene at all (engine.lights.sun / hemi still exist, detached, so sky and describe never see undefined); the game adds its own. No light of the engine's reaches the picture. Default true
31
+ - `batching?: false | BatchingOptions` Automatic instancing of repeated static models the engine places (engine.batching; your own meshes opt in with userData.batch = true): false turns it off; default { minCount: 8, cell: 4 * engine.stream.cellSize }
33
32
 
34
33
  ## engine methods
35
34
  - `engine.actorPosition(id?: string) → { x, y, z } | null` — Where an actor is now (default engine.actor): the player's position for 'player' (engine.focus without a player), else its model or world record position; null when unknown. Example: `engine.actor = 'boat_1'; engine.actorPosition()`
36
35
  - `engine.catalog(id?: string | { find?: string }) → any` — What this game can do, read from the existing registrations (modules, ops, save parts, describe, params schemas). No argument: the short list, an ARRAY of { id, kind, label, ops, saves, ... } (read .id, not Object.keys); a module id / op name: that entry expanded (null if unknown); { find }: the short list filtered. recipes/51-capability-catalog.md. Example: `engine.catalog().map(s => s.id); engine.catalog('shop').ops[0].failures // ['soldOut', 'noMoney']`
37
36
  - `engine.takeCamera(owner: string | ({ owner: string } & Partial<CameraOverride>), opts?: Partial<CameraOverride>) → OwnerHandle` — Take the camera over (camera modules leave it alone) until remove(); the latest holder is in charge, releasing hands it back to the previous one
38
- - `engine.mod(name: string, opts: import('./gameplay').ModOptions) → import('./gameplay').ModHandle` — The one way several systems change a shared quantity: an entry per owner, combined by layer, ended by its handle; nothing remembers an old value. Example: `engine.mod('time.enemies', { owner: 'bullet-time', mul: 0.35, for: 2 }) // bullet time on the enemies channel`
39
- - `engine.wrap(target: T, method: string, fn: (next, args) => any, opts?: { owner?: string }) → Handle` — The one way to change what a module's public method does without copying the module: fn(next, ...args) runs instead of it; call next(...args) for the method (do work before, after, or skip it). Several wrappers compose (the last wrapped runs first); remove() takes one out; listed in describe().wraps. Private (_) methods throw. The methods a module promises are its contract.js api. Example: `engine.wrap(engine.inventory, 'add', (next, id, n = 1, o) => carried() + weightOf(id) * n > 30 ? false : next(id, n, o), { owner: 'weight' })`
37
+ - `engine.mod(name: string, opts: import('./gameplay').ModOptions) → import('./gameplay').ModHandle` — (experimental) The one way several systems change a shared quantity: an entry per owner, combined by layer, ended by its handle; nothing remembers an old value. Example: `engine.time.channel('enemies'); engine.mod('time.enemies', { owner: 'bullet-time', mul: 0.35, for: 2 }) // bullet time on a channel the game made`
38
+ - `engine.wrap(target: T, method: string, fn: (next, args) => any, opts?: { owner?: string }) → Handle` — (experimental) The one way to change what a module's public method does without copying the module: fn(next, ...args) runs instead of it; call next(...args) for the method (do work before, after, or skip it). Several wrappers compose (the last wrapped runs first); remove() takes one out; listed in describe().wraps. Private (_) methods throw. The methods a module promises are its contract.js api. Example: `engine.wrap(engine.inventory, 'add', (next, id, n = 1, o) => carried() + weightOf(id) * n > 30 ? false : next(id, n, o), { owner: 'weight' })`
40
39
  - `engine.setCamera(kind: CameraKind, opts?: object) → CameraRig` — Switch the camera at runtime between kinds, once a camera module is installed (openWorld installs followCamera; with none it throws camera-none naming the module to install, e.g. engine.use(fixedCamera({ position, lookAt }))): the target and horizontal heading carry over; the first-person camera hides the character body automatically (the shadow stays) and locks / releases the mouse; the camera switched out is kept, with its parameters, for switching back. Passing opts rebuilds this kind of camera with the new parameters. A wrong kind throws and lists the available options. Example: `engine.onFrame(() => { if (engine.input.pressedRaw('toggleView')) engine.setCamera(engine.cameraRig.kind === 'follow' ? 'firstPerson' : 'follow'); });`
41
40
  - `engine.use(...mods: (ModuleInput | { replaces })[])` — Install one or more modules (in order; dependencies must be installed first). A last argument { replaces: 'slot' } swaps the module that holds that exclusive slot: it is unloaded first (its handles, changes and dispose) and put back if the new install fails. Example: `engine.use(myInventory(), { replaces: 'inventory' })`
41
+ - `engine.unuse(name: string)` — Unload one installed module: its tracked handles, its slots and ctx.mod entries, its dispose. What it added some other way stays (dev reports a picture module's leftovers). Throws while another module still requires it. To swap a holder use engine.use(mine(), { replaces: 'slot' }). Example: `engine.unuse('rain');`
42
42
  - `engine.has(name: string) → boolean` — Whether a module is installed
43
- - `engine.makeMaterial(purpose?: string, params?: MaterialSpec) → Material` — Material by role from this engine's style: engine.makeMaterial('prop', { color: 0x8a5a36 })
44
43
  - `engine.setGround(g: Partial<Ground>)` — Set the ground (called by the terrain and level modules); missing parts fall back to flat ground
45
44
  - `engine.surface(x: number, z: number, refY?: number) → number` / `surface(at: PositionLike, refY?: number) → number` — Ground height (meters) at (x, z); a position or object also works: engine.surface(mesh.position). For multi-layer ground (bridges, caves, interiors) pass a reference height refY: returns the highest layer not above refY + one step (0.45 m), so standing under a bridge gives the ground and standing on it gives the deck; without it the highest layer is used (as before). Procedural terrain and flat ground have one layer and ignore refY. Off the outline of terrain({ shape }) it is -Infinity (no ground there; engine.ground.has(x, z) says so as a boolean)
46
45
  - `engine.slope(x: number, z: number) → number` / `slope(at: PositionLike) → number` — Slope at (x, z); a position or object also works
@@ -48,7 +47,7 @@
48
47
  - `engine.waterAt(x: number, z: number) → number` / `waterAt(at: PositionLike) → number` — Water surface height at (x, z): standalone water bodies first, otherwise the global water level; -Infinity when there is no water. A position or object also works
49
48
  - `engine.snapToGround(obj: T, offset?: number) → T` — Put an object on the ground under it (y = ground height + offset) and return the object. With multi-layer ground the object's current y is the reference height
50
49
  - `engine.addWaterBody(opts: WaterBodyOptions) → Handle & { body: WaterBody }` — Add a water body (give radius for a circle, halfWidth / halfDepth for a rectangle) and return a handle { body, remove() }. The water module draws it
51
- - `engine.t(key: string, params?: Record<string, any>) → string` — Get UI text (i18n)
50
+ - `engine.t(key: string, params?: Record<string, any>) → string` — Get UI text (i18n): {name} in the text takes params.name, {key:action} the label of the key bound to that action; a key with no text comes back as itself. Example: `engine.t('shop.buy', { name: 'Fish' });`
52
51
  - `engine.add(obj: T, ...more: (Object3D | { id?, save? })[]) → T` — Add objects to the scene and register them (engine.thing), returns the first one. The last argument may be { id?, save? }: id makes thing.set / thing.remove changes saved (unique, no '#', one object per call); without it a unique obj.name is used, else a session id obj#n. save: true asks dev to warn when it cannot be saved. engine.scene.add adds without registering. Example: `engine.add(windmill, { id: 'windmill' });`
53
52
  - `engine.thing(idOrObj: string | Object3D) → Thing` — What a thing is and what a save keeps: a world record id, an engine.add id or name, or any Object3D (its registered ancestor). object is the live Object3D (not enumerable). Throws with the closest id when nothing matches. Change it with ops.run('thing.set' / 'thing.remove', { id, ... }). Example: `engine.thing('windmill').saved // 'code'`
54
53
  - `engine.remove(...objs: Object3D[])` — Fully delete an object (use it when you no longer want the object): removes it from its parent, unregisters rays, and releases the geometry and materials of it and its children (textures and geometry / materials shared by assets are not released)
@@ -57,47 +56,47 @@
57
56
  - `engine.onFrame(fn: (dt: number) => void) → Handle` — Once per frame (dt in frame seconds): animation, camera, UI and UI keys (menus read this frame's latest input). Gameplay keys belong in onFixed. Returns a handle { remove() }
58
57
  - `engine.onRender(fn: (ctx) => void, opts?: { when?: 'before' | 'after' }) → Handle` — Around the main frame render, after the camera update and batching. when 'before' (default): render into your own render target here (mirror, minimap, portal, picking); the render target is reset to the screen afterwards. 'after': right after the frame (read pixels). The main frame render itself stays the engine's (post chain). Returns a handle { remove() }. Example: `const rt = new THREE.WebGLRenderTarget(256, 256); engine.onRender(({ renderer, scene }) => { renderer.setRenderTarget(rt); renderer.render(scene, mapCam); });`
59
58
  - `engine.renderOnce(target?: import('three').RenderTarget | null, camera?: import('three').Camera)` — Draw one picture now, outside the loop, on either renderer. `renderOnce()`: the frame the player sees, onto the canvas through engine.post (read the canvas in the same task, as photo mode does). `renderOnce(target)`: that frame through engine.post into a render target (the canvas's pixels). `renderOnce(target, camera)` with another camera: the scene from that camera, without post. On WebGPURenderer each call is a fresh node frame, so two calls in one task give two pictures (a RenderPipeline draws its scene pass once per frame). Example: `engine.renderOnce(); const url = engine.renderer.domElement.toDataURL('image/png'); engine.renderOnce(rt, mapCamera); // a minimap / thumbnail into your own render target`
60
- - `engine.bakeProbes(opts: { bounds, spacing, resolution?, include?, height?, follow?, … }) → Promise<ProbeSet>` — Bake a grid of light probes from the scene as it is now: a cube render at every grid point, turned into spherical harmonics (three's LightProbeGenerator), then one scene `LightProbe` that follows a point (`follow`, default the camera focus) and takes the light interpolated there every frame. The probe light adds to whatever ambient light the scene has (hemi, environment): lower those yourself where the probes take over. A load-time cost, not per frame: 6 renders + a GPU read back per probe, awaited one probe at a time so the page keeps drawing; ship the result with `toJSON()` + `engine.loadProbes(json)` instead of baking at every start. Render targets and cube cameras are disposed before it resolves. Adding the probe changes the light setup: bake at start-up, not mid-play. Example: `const probes = await engine.bakeProbes({ bounds: { min: [-20, 0, -20], max: [20, 6, 20] }, spacing: 4, include: o => !o.userData.moving }); probes.sample(npc.position, npcProbe); // your own probe for one object`
61
- - `engine.loadProbes(json: ProbeData, opts?: { follow?, owner? }) → ProbeSet` — A probe set from a file made by `handle.toJSON()` (no baking). A wrong shape is refused with code `probes-data` and nothing is added. Example: `const probes = engine.loadProbes(await (await fetch('probes.json')).json());`
62
- - `engine.setPixelRatio(p: number)` — Render resolution
59
+ - `engine.bakeProbes(opts: { bounds, spacing, resolution?, include?, owner? }) → Promise<ProbeSet>` — (experimental) Bake a grid of light probes from the scene as it is now: three's probe grid renders a cube at every grid point and keeps spherical harmonics, and every lit pixel inside the grid then takes its own interpolated light, on WebGL and WebGPU alike. The grid adds to whatever ambient light the scene has (hemi, environment), which the bake also saw: lower those where the probes take over (a warning and describe().render.probes say so). Outside the grid there is no probe light. A load-time cost, not per frame: 6 renders per probe, a few probes per task so the page keeps drawing; ship the result with `toJSON()` + `engine.loadProbes(json)` instead of baking at every start. Adding a grid recompiles the lit materials once: bake at start-up, not mid-play. Example: `const probes = await engine.bakeProbes({ bounds: { min: [-20, 0, -20], max: [20, 6, 20] }, spacing: 4, include: o => !o.userData.moving }); saveFile('probes.json', JSON.stringify(probes.toJSON()));`
60
+ - `engine.loadProbes(json: ProbeData, opts?: { owner?: string }) → ProbeSet` — (experimental) A probe set from a file made by `handle.toJSON()` (no baking), on either renderer whichever one baked it. A wrong shape is refused with code `probes-data` and nothing is added. Example: `const probes = engine.loadProbes(await (await fetch('probes.json')).json());`
61
+ - `engine.loadLightmap(file: string | ArrayBuffer, opts?: { owner?: string }) → Promise<Lightmap>` — (experimental) Put a baked lightmap on the scene: `threedog bake light` wrote the file from the meshes the game marked `userData.static = true`; this rebuilds each with its second UV set and sets plain `material.lightMap`, on WebGL and WebGPU alike. Call it once the level is built, with its lights as they will be played. Nothing runs per frame. Keep the sun real-time; the ambient light the bake saw (hemisphere, environment) has to go, or it counts twice. A wrong file is refused with code `lightmap-data` and nothing is changed. `material.lightMapIntensity` is yours. describe().render.lightmap says what was skipped, moved or doubled. Example: `const light = await engine.loadLightmap('light/level.lightmap');`
62
+ - `engine.setPixelRatio(p: number)` — Render resolution, and the top adaptive resolution climbs back to
63
63
  - `engine.raycast(origin: Vec3Like, dir: Vec3Like, opts?: RaycastOptions) → RayHit | null` — Ray: shoot from origin along dir, returns the nearest hit or null (by default only registered static objects are hit)
64
- - `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)
65
- - `engine.applyState(params: StateParams) → Promise<void>` — Set up a scenario: time of day, weather, player position, load a save, advance time, skip cutscenes; emits state:applied when done
64
+ - `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). The ray comes from the camera as last drawn: a rig.yaw / rig.pitch write reaches it on the next drawn step, so several shots in one step with recoil between them cast from the rig's angles with engine.raycast (recipe 19)
65
+ - `engine.applyState(params: StateParams) → Promise<{ ok: boolean, refused: {…` — Set up a scenario: time of day, weather, player position, load a save, advance time, skip cutscenes; emits state:applied when done
66
66
  - `engine.defineState(name: string, params: StateParams, opts?: { owner?: string }) → { owner?: string; remove(): void }` — Name a group of scenario parameters, then use applyState({ state: name }) or URL ?state=name. Returns a handle: remove() forgets the name
67
67
  - `engine.start() → Promise<this>` — Start: initialize modules, preload assets, wait for the world to be ready
68
- - `engine.pause(owner?: string | { owner?, kind? }, opts?: { kind?: 'test' }) → OwnerHandle` — Pause the real-time loop: the picture stops and even rendering stops, only step() advances (for tests and screenshots). Use freeze() for a game menu pause
68
+ - `engine.haltLoop(owner?: string | { owner?: string }) → OwnerHandle` — Pause the real-time loop: the picture stops and even rendering stops, only step() advances (for tests and screenshots). Use freeze() for a game menu pause
69
69
  - `engine.nextFixed(fn: () => T) → Promise<T>` — Run fn at the start of the next fixed step (via commits); a Promise of fn's value
70
- - `engine.freeze(owner?: string | { owner?, kind?, ambient? }, opts?: { kind?, ambient? }) → OwnerHandle` — Gameplay pause (menu, flow's paused): fixed steps are skipped entirely (onFixed, module fixed, tick and every time view but ambient stop), frame hooks and rendering continue and the UI works. So gameplay logic (movement, timing, quest checks, cutscene waits) belongs in fixed, or check engine.frozen first in frame. owner is the freezer's name, default 'game'. uniforms.uTime (wind, water, clouds) keeps moving while frozen; { ambient: true } stops it too
70
+ - `engine.freeze(owner?: string | { owner?, kind?, ambient? }, opts?: { kind?, ambient? }) → OwnerHandle` — Gameplay pause (menu, flow's paused): fixed steps are skipped entirely (onFixed, module fixed, tick and every time view but ambient stop), frame hooks and rendering continue and the UI works. So gameplay logic (movement, timing, quest checks, cutscene waits) belongs in fixed, or check engine.frozen first in frame. owner is the freezer's name, default 'game'. uniforms.uTime (wind, water, clouds), skeletal animation and particles keep moving while frozen; { ambient: true } stops them too (a still)
71
71
  - `engine.step(seconds: number, opts?: { render?, frameEvery?, describe? }) → GameState | null` — Advance seconds of fixed-step time synchronously; seconds must be a finite number >= 0: 0 advances nothing (no step, no render), negative or non-finite throws (code step-seconds), any positive value runs at least one fixed step (60Hz; time channels and the calendar clock.now / sky time of day run at their own speeds; frame hooks run once every frameEvery fixed steps, default 2; describe: false returns null instead of building describe()). jobs ignore real time and finish every frame; results of stream's synchronous build are attached to the scene before returning. When render is true (default) one frame is rendered at the end. Returns the describe() result after advancing
72
72
  - `engine.skip(opts: SkipOptions) → Promise<{ seconds: number; clock:…` — Skip game time forward (sleep until morning, wait an hour) without stepping every fixed step. clock.after / every, sky.at / daily / between, day:start and season:change fire in time order as if stepped (each crossing once); world records with far catch up the span in one far(rec, dt). onFixed, module fixed hooks, physics and near simulation do not run; every time view (tick, real, ambient, channels, calendar) moves as if stepped. Input is locked and gameplay frozen during the skip; emits time:skip. fade 0 (default): the time has moved when skip returns. fade > 0: fade out, jump, save, fade in; the Promise resolves after the fade in (it needs frames). session.newGame / load / quit cancel a running skip: it resolves null. Example: `await engine.skip({ to: '06:00' })`
73
73
  - `engine.checkSkip(seconds: number, opts?: { ignore?: string[] }) → Promise<{ ok: boolean; code?: 'fr…` — Consistency check: engine.skip({ seconds }) vs stepping the same span in fixed steps; compares the saved state. Leaves the world at the stepped state (use a scratch playthrough or a test). Example: `const r = await engine.checkSkip(600); if (!r.ok) console.log(r.diffs);`
74
74
  - `engine.checkSave(opts?: { ignore?: string[] }) → Promise<{ ok: boolean; diffs: { p…` — Consistency check: save -> load gives the same saved state back (nothing is written to the browser). Example: `const r = await engine.checkSave(); if (!r.ok) console.log(r.diffs);`
75
- - `engine.describeText(opts?: { radius?, full?, path? }) → string` — The same information as English text, summary first: at most 30 lines (standard lines, the 5 nearest things, the game's describe.add sections, one line per module with its key counts, the engine tables such as shared / slots / look as one count line), ending with how to expand. { path: 'world.byKind' } returns one part of describe() as JSON; { full: true } returns everything (all nearby things, every module's full data). Example: `engine.describeText() engine.describeText({ path: 'quests' }) engine.describeText({ full: true })`
75
+ - `engine.describeText(opts?: { radius?, full?, path? }) → string` — The same information as English text, summary first: at most 30 lines (standard lines, the 5 nearest things, the game's describe.add sections, one line per module with its key counts, the engine tables such as shared / slots / owned as one count line), ending with how to expand. { path: 'world.byKind' } returns one part of describe() as JSON; { full: true } returns everything (all nearby things, every module's full data). Example: `engine.describeText() engine.describeText({ path: 'quests' }) engine.describeText({ full: true })`
76
76
  - `engine.explain(q: { op, args?, actor? } | Record<string, any>) → { ok, code?, text, detail?, recent?, events?, … }` — Why something is the way it is. { op, args?, actor? }: text says whether it can run now, and if not the reason and the op's note on fixing it (reason first); detail has the last attempt and the events around it; recent / events are the raw last 5 attempts and event names within a step of the last one. Other keys are answered by modules (definition field explain: { key(e, value, query) { return { ok, text } } }); the quests module answers { quest: id }. Example: `engine.explain({ op: 'shop.buy', args: { shop: 'bakery', item: 'bread' } }).text // 'shop.buy {...} cannot run now: noMoney (Not enough gold)'`
77
77
  - `engine.profile(on: boolean)` / `profile() → Record<string, number> | null` — Module hook timing: pass true to turn on, false to turn off (returns the engine); with no argument returns { moduleName: average milliseconds per rendered frame } and resets, or null when not on
78
78
  - `engine.dispose(opts?: { keepContext?: boolean })` — Destroy the engine: stop the main loop, call each module's dispose(e) in reverse install order, then reclaim listeners, timers, audio, UI and GPU memory (scene, assets cache, post-processing, renderer). After that no callbacks fire and step() returns null. Safe to call repeatedly. Don't use it for level changes; use level.track(handle). The engine's own renderer gives its WebGL context back (browsers keep about 16 live ones), so that canvas cannot host a new engine; keepContext: true keeps it. A renderer passed to createEngine({ renderer }) is never released.
79
79
  - `engine.counts() → EngineCounts` — Counts for leak hunting: they should not keep growing after repeatedly entering / leaving levels or opening / closing windows. geometries / textures come from three.js renderer.info.memory (counted only after rendering)
80
80
 
81
81
  ## engine properties (module properties are on each module page)
82
- - `THREE: typeof import('three')` three.js (a game can also import { THREE } from 'threedog' directly)
83
- - `style: Style` Style
82
+ - `validate: boolean` False when createEngine({ validate: false }) turned the development checks off for this engine
84
83
  - `renderer: EngineRenderer` three.js renderer: WebGLRenderer, or WebGPURenderer on the WebGPU route (EngineRenderer)
85
84
  - `tier: 'low' | 'high'` Device tier: 'low' (phones, integrated graphics) / 'high'. A headless page takes it from ?threedog-tier=low/high (threedog shot / gallery / capture pass high, shot --tier low checks the low tier)
86
85
  - `scene: import('three').Scene` three.js scene
87
- - `lights: { sun, hemi }` Default lights (neutral without sky; the sky module drives these same two). Hide or retune them for your own lighting: `engine.lights.sun.visible = false`
88
- - `camera: import('three').PerspectiveCamera` three.js PerspectiveCamera (class EngineCamera, core/engineCamera.js): a camera rig with projection: 'orthographic' switches it to an orthographic matrix in place (orthoSize; describe().camera.projection says which)
86
+ - `lights: { sun, hemi }` Placeholder lights: neutral and still, nothing moves them (the sky only gives signals). createEngine({ lights: false }) leaves them out of the scene
87
+ - `camera: import('three').PerspectiveCamera` three.js PerspectiveCamera (class EngineCamera, core/scene/engineCamera.js): a camera rig with projection: 'orthographic' switches it to an orthographic matrix in place (orthoSize; describe().camera.projection says which)
89
88
  - `focus: Vector3` Camera focus, updated every frame by the camera module: terrain, models etc. load around it. The center of gameplay simulation is world.anchor (the player by default), which does not follow the camera
90
89
  - `ground: Ground` Current ground
91
90
  - `movement: Readonly<MovementProfile>` Shared parameters for whether a character can walk somewhere (set by createEngine({ movement }), read-only); same-named options of individual modules are only overrides
92
91
  - `player: Character | null` The player (exists only after characters.createPlayer()). Its position belongs to the character's mover: other systems request movement (placeAt / move / vehicle enter), don't modify position directly
93
92
  - `actor: string` World record id of the one the local user controls (default 'player'): interactions, trigger zones, marker distances, the world simulation center and ops (ctx.actor) use it. Set it to hand control to a vehicle or squad member
94
- - `phase: 'constructed' | 'loading' | 'ready' | 'running' | 'disposed'` Where the engine is in its life: 'constructed' (start() not called) -> 'loading' (start() running: frame hooks only, no fixed step, so no game time passes and every machine opens at tick 0) -> 'ready' (world built: fixed steps run, engine:ready fires) -> 'running' (start() resolved) -> 'disposed'. engine.step() during loading runs frame hooks only
93
+ - `phase: 'constructed' | 'starting' | 'loading' | 'ready' | 'running' | 'disposed'` Where the engine is in its life: 'constructed' (start() not called) -> 'starting' (modules init) -> 'loading' (assets and the world; in both frame hooks only, no fixed step, so no game time passes and every machine opens at tick 0) -> 'ready' (world built: fixed steps run, engine:ready fires) -> 'running' (start() resolved) -> 'disposed'.
95
94
  - `ready: boolean` phase is 'ready' or 'running': the world is built and the loading screen is gone (every "is it ready" in the engine is such a boolean property)
96
95
  - `disposed: boolean` phase is 'disposed'
97
- - `moduleOrder: string[]` Execution order of module hooks (module names, first -> last), for debugging "who runs before whom"
98
- - `moduleStates: Record<string, 'registered' | 'initializing' | 'running' | …` Where each module is: 'registered' (init not started), 'initializing', 'running', 'failed' (init threw: its hooks never run) or 'disposed'. A module installed after start() runs no fixed / frame hook until it is 'running'; `await engine.loading.settled()` waits for that
96
+ - `moduleOrder: string[]` (experimental) Execution order of module hooks (module names, first -> last), for debugging "who runs before whom"
97
+ - `moduleStates: Record<string, 'registered' | 'initializing' | 'running' | …` (experimental) Where each module is: 'registered' (init not started), 'initializing', 'running', 'failed' (init threw: its hooks never run) or 'disposed'. A module installed after start() runs no fixed / frame hook until it is 'running'; `await engine.loading.settled()` waits for that
99
98
  - `error: EngineError | null` Gameplay error in development / testing (module hooks, onFixed / onFrame / clock callbacks, event listeners): { where (location of the error), message }, gameplay is frozen; null when there is no error. A release build does not freeze, it reports once in the console
100
- - `disabledModules: Set<string>` Names of look / ui modules disabled after an error (a module's type decides: look and ui fail soft)
99
+ - `disabledModules: Set<string>` (experimental) Names of picture / ui modules disabled after an error (a module's type decides: picture and ui fail soft)
101
100
  - `signal: AbortSignal` The engine's cancel signal (AbortSignal): for DOM listeners write addEventListener(type, fn, { signal: engine.signal }), removed automatically on dispose()
102
101
  - `uiRoot: HTMLDivElement` UI root node: UI elements of the engine and modules hang under it (don't attach to document.body directly), the whole tree is removed on dispose()
103
102
  - `modules: Map<string, ModuleDef>` Installed modules: name -> module definition
@@ -112,28 +111,25 @@
112
111
  - `assets: Assets` Assets
113
112
  - `loading: Loading` Observable loading: every asset load, module init / isReady and track() step as a task (phase, error, source manifest)
114
113
  - `post: PostFX` Post-processing: named effects in slots (add / get / enable / list)
115
- - `look: Look` Every look in one place: engine.look.<part>.set / patch / replace (recipes/52-look.md)
114
+ - `occlusion: Occlusion` Occlusion culling of the engine's big things (hlod cells, batched groups) on both renderers. Off by default; it pays only when heavy things hide behind others (recipe 34)
116
115
  - `ui: UIParts` UI parts: every piece of screen UI is replaceable or off (see recipes/26-ui-parts.md)
117
116
  - `adaptive: AdaptiveState` Automatic resolution state
118
- - `cpuMs: number` Main-thread CPU milliseconds of the last real-time frame: input, fixed steps, frame hooks, render submission and afterRender hooks (not GPU time, not the wait for the next frame). Only the real-time loop updates it; step() does not.
119
- - `cpuPhases: { fixed, frame, render, afterRender }` cpuMs split by phase (last frame): fixed = input + fixed steps, frame = frame hooks incl. stream / jobs, render = draw submission, afterRender = its hooks
117
+ - `stepBlend: number` How far the drawn frame is from the last fixed step to the next, 0-1 (real loop); 1 after step(). Holds still while frozen. For drawing fixed-step state smoothly
120
118
  - `cameraOverride: CameraOverride | null` The camera holder in charge (latest engine.takeCamera claim), null when nobody holds it. Read-only
121
119
  - `runState: RunState` Why the page is (not) advancing; the dev bridge and MCP tools copy it as-is
122
- - `decoders: string` Draco/KTX2 decoder directory
123
120
  - `clock: Clock` Calendar clock: calendar seconds now, after / every, the rate (clock-time / season timers are on engine.calendar)
124
- - `stacks: import('./gameplay').Stacks` Every shared quantity by name; define your own with engine.stacks.define(name, { base })
125
- - `control: Control` Who decides where each character goes: one holder in charge per character, layers base < script < cutscene < net; a higher one pauses the lower until it ends. engine.control.take(ch, { owner, layer, step }) / .of(ch). Recipe 57. Example: `const h = engine.control.take(npc, { owner: 'escort', layer: 'script', step: () => ({ x: 0, z: 1 }) }); ... h.remove();`
126
- - `time: import('./gameplay').Time` Time channels: real seconds, channel seconds (world, player, your own), read speeds with scale(ch, id?)
121
+ - `stacks: import('./gameplay').Stacks` (experimental) Every shared quantity by name; define your own with engine.stacks.define(name, { base })
122
+ - `control: Control` Who decides where each character goes: one holder in charge per character, layers base < script < cutscene < physics < net; a higher one pauses the lower until it ends. engine.control.take(ch, { owner, layer, step }) / .of(ch). Recipe 57. Example: `const h = engine.control.take(npc, { owner: 'escort', layer: 'script', step: () => ({ x: 0, z: 1 }) }); ... h.remove();`
123
+ - `time: import('./gameplay').Time` Time channels: read seconds with time.now('real' / 'ambient' / 'calendar' / a channel such as 'world'), speeds with scale(ch, id?)
127
124
  - `vars: Vars` Story flags and counters (autosaved)
128
125
  - `budget: Budget` Performance budget (off by default)
129
- - `plugins: { add, off, on, list }` The plugins folder: files in the game's plugins/ plugged at start by what they export (core/plugins.js); describe().slots lists them (add() off() on() list())
126
+ - `plugins: { add, off, on, list }` The plugins folder: files in the game's plugins/ plugged at start by what they export (core/engine/plugins.js); describe().slots lists them (add() off() on() list())
130
127
  - `rays: Rays` Ray registry (what engine.raycast hits)
131
128
  - `jobs: Jobs` Frame-spread job scheduler
132
- - `commits: Commits` Background results that affect gameplay take effect on a fixed tick (chunk collision, spread jobs with apply...), see Commits
129
+ - `commits: Commits` (experimental) Background results that affect gameplay take effect on a fixed tick (chunk collision, spread jobs with apply...), see Commits
133
130
  - `threads: Threads` (experimental) Worker pool (createEngine({ threads })): lane() for your own worker script, pure() for self-contained functions, array() for shared typed arrays. Results that affect gameplay go through commits
134
131
  - `ops: Ops` One entry point for actions players and NPCs decide to do: define / run / can / list / recent, see Ops and recipes/23-ops.md
135
132
  - `views: Views` Named fixed camera views for repeatable screenshots: define / show / release (recipes/46-blender-art-route.md)
136
- - `tick: number` Fixed-step count (= engine.time.tick, the one time counter: does not advance while frozen; commits due times, event history and the operation log use it). Seconds are views of it: engine.time.now('real' / 'ambient' / 'calendar' / channel)
137
133
  - `random: Random` Seeded random numbers, an object (not a function): engine.random.next() in [0, 1), .range(a, b), .int(a, b), .pick(list), .chance(p). Use it for gameplay randomness: reproducible and saved with the game
138
134
  - `stream: Stream` Spatial stream-in and the stream sources (where the world is loaded: terrain, colliders, models, stream entries; built-in player and camera sources, add one for a teleport destination)
139
135
  - `batching: Batching` Automatic batching: the same static model the engine placed (world records, stream builds, level files) many times in a cell is drawn as one InstancedMesh; your own meshes only with userData.batch = true (createEngine({ batching }))
@@ -141,29 +137,36 @@
141
137
  - `uniforms: EngineUniforms` This engine's shader uniforms, read by the built-in effects (wind, clouds, season, water, sky, rain). Share these objects in your own ShaderMaterial or patch instead of making your own uTime. Weather and sky write them; uTime is engine.time.now('ambient'). Example: `new THREE.ShaderMaterial({ uniforms: { uTime: engine.uniforms.uTime }, vertexShader, fragmentShader });`
142
138
  - `waterLevel: number` Global water level (meters); -Infinity when there is no water
143
139
  - `debug: DebugOverrides & { panel: DebugPanel | null }` Diagnostic overrides and view modes with an owner (override / clear / view: core, always there); panel is the F3 panel, null without the debug() module
144
- - `exposureDriver: ((sky: any) => number) | null` Exposure per frame from style.exposure / look.tone keyframes or function, null for a plain number; the sky module calls it with engine.sky
145
- - `stateApplied: boolean` Scenario is ready: start() completed, and the URL parameters / the latest applyState have all been applied. Tests and screenshots wait for it: page.waitForFunction(() => window.engine?.stateApplied)
140
+ - `shadows: Shadows` Shadow engineering on lights you hand in: enabled, cascades, box, budget, include (recipes/45): core, always there
141
+ - `autoView: View` The camera and drawing-buffer values the engine changes on its own: manual() takes one (recipes/52): core, always there
142
+ - `shaderTerms: Terms` Your own cloud shadow or season tint in place of the engine's (recipes/52): core, always there
143
+ - `stateApplied: boolean` (experimental) Scenario is ready: start() completed, and the URL parameters / the latest applyState have all been applied. Tests and screenshots wait for it: page.waitForFunction(() => window.engine?.stateApplied)
144
+ - `stateRefused: { key: string, value: any, reason: string }[]` (experimental) What the URL parameters or the latest applyState could not do, e.g. ?weather=typo. Read it after stateApplied
146
145
  - `headless: boolean` Whether in headless mode (createEngine({ headless: true }))
147
- - `paused: boolean` Whether paused (headless mode is paused by default, only step() advances)
146
+ - `halted: boolean` Whether the real-time loop is stopped: only step() advances the game (headless mode starts this way)
148
147
  - `fps: number` Smoothed frame rate
149
- - `openWindows: Set<string>` Ids of the open windows
150
148
  - `frozen: boolean` Is anyone freezing gameplay?
149
+ - `still: boolean` True while a freeze asked for a full still (freeze(owner, { ambient: true })): frame code that moves things reads this, as animation and particles do
151
150
  - `describe: { add }` Call engine.describe(opts?: { radius?: number }) to get the current game state (a plain object, JSON.stringify-able); radius is how far counts as "nearby" (meters, default 30).
152
151
  - `inspect: { scene, materials, perf }` What is around an actor or a spot, and what that actor can do now (each op offer checked with can, possible first, at most 8; failed ones carry code and the op's reasons note). at: a world record id (that actor), [x, z] / { x, z } (a spot, ops as the player), or nothing (the player). radius default 10 m. Example: `engine.inspect(); // { actor: 'player', at: { x, z }, near: [...], ops: [{ op: 'shop.buy', args, ok: false, code: 'noMoney', why: 'Not enough gold' }] }`
153
152
 
154
153
  ## Module definition (engine.use(myModule()))
155
154
  - **ModuleDef** A module (the argument of engine.use). The name is the property name on the engine once installed. Per-frame hook order follows stage, then before / after within a stage, then install order.
156
155
  - `name: string` Module name; after install, access the object returned by install through engine[name]
157
- - `type: ModuleType` What the module may own (required; core/moduleTypes.js): 'world' state, records, ops (draws nothing) / 'look' what is seen and heard (changes no game state: no ops, no world record writes) / 'actor' characters / 'rules' game logic / 'ui' panels and menus (binds no keys, no game save part) / 'net' multiplayer / 'tool' a one-shot job.
156
+ - `type?: ModuleType` What the module owns (default 'rules'; core/engine/moduleTypes.js): 'world' state, records, ops (draws nothing) / 'picture' what is seen and heard (changes no game state: no ops, no world record writes) / 'actor' characters / 'rules' game logic / 'ui' panels and menus (binds no keys, no game save part) / 'net' multiplayer / 'tool' a one-shot job.
158
157
  - `label?: string` Display name (used by the loading screen)
159
158
  - `requires?: string[]` Capabilities this depends on: slot names another module provides ('inventory', 'world', 'sky'), never a particular module. Missing throws with both fixes: install the engine's part of that name first, or your own module with provides: ['inventory']
160
- - `provides?: string[]` Capabilities this module holds while installed ("only one may hold this": 'sky', 'inventory'); engine.<slot> is its API too, so dependents keep working when a game swaps it: engine.use(mine(), { replaces: 'inventory' }). A second provider throws shared-taken. describe().shared shows the holder.
159
+ - `provides?: (PictureSlot | (string & {}))[]` Capabilities this module holds while installed ("only one may hold this": 'sky', 'inventory'); engine.<slot> is its API too, so dependents keep working when a game swaps it: engine.use(mine(), { replaces: 'inventory' }). A second provider throws shared-taken. describe().shared shows the holder.
161
160
  - `optional?: string[] | Record<string, string>` Optional dependencies (modules the code uses as e.xxx?. or guards with if (e.xxx); rule R16 requires listing them all). An array only registers them; written as { moduleName: 'what is lost when missing' }, start() prints a one-time development hint when one is missing; use this form when it changes gameplay results
162
161
  - `stage?: 'control' | 'ground' | 'environment' | 'gameplay' | 'effects' | 'late' | 'audio'` Hook stages, only the run order (first -> last): 'control' timeline, camera -> 'ground' terrain, level -> 'environment' weather, sky, water -> 'gameplay' interactions, dialogue, triggers -> 'effects' particles, settings, objective markers -> 'late' (default) -> 'audio' music. Within a stage use before / after, then install order.
163
162
  - `before?: string[]` Hooks run before these modules, inside one stage (ignored if not installed; use() throws on a cycle, or when the other module's stage already runs earlier)
164
163
  - `after?: string[]` Hooks run after these modules, inside one stage (ignored if not installed; use() throws on a cycle, or when the other module's stage already runs later)
165
- - `critical?: boolean` The game cannot run without this module (default false): when its init() fails, engine.start() rejects with the module name and reason instead of starting a broken game. Without it a failed init is reported by severity (type look / ui: disabled and the game carries on; other types: error tiers) and start() goes on. Example: `engine.use({ name: 'saveSlots', type: 'rules', critical: true, async init(e) { await loadSlots(); } })`
164
+ - `critical?: boolean` The game cannot run without this module (default false): when its init() fails, engine.start() rejects with the module name and reason instead of starting a broken game. Without it a failed init is reported by severity (type picture / ui: disabled and the game carries on; other types: error tiers) and start() goes on. Example: `engine.use({ name: 'saveSlots', type: 'rules', critical: true, async init(e) { await loadSlots(); } })`
165
+ - `noSkip?: string` Why a module with a fixed hook has no skip hook: engine.catalog shows it instead of a warning
166
+ - `params?: any` The option schema (core/base/params.js): engine.catalog shows it, and dev checks the module's options against it
167
+ - `docs?: string` Where its docs live, shown by engine.catalog
166
168
  - `explain?: Record<string, (e: Engine, value: any, query: Record<string…` Optional: answer engine.explain({ key: value }) for your own keys, e.g. explain: { quest: (e, id) => ({ ok: false, text: 'waits on step 2: ...' }) }
169
+ - `stateKeys?: string[]` Optional: the applyState keys this module handles; a key no module handles is reported in applyState's refused list. Leave out to count for every key
167
170
  - `install(e: Engine, ctx: ModuleCtx) → Api` — Install: create and return the object the game uses (engine.name). Register listeners / timers through ctx.track so they leave with the module (a use() batch that rolls back, a failed init, engine.dispose). Example: `install(e, ctx) { ctx.track(e.events.on('item:add', onAdd)); return api; }`
168
171
  - `init(e: Engine, ctx: ModuleCtx) → void | Promise<void>` — Called at startup (download things, wait for assets); may be async. ctx is the same as install's
169
172
  - `isReady(e: Engine) → boolean` — The loading screen waits until this returns true before disappearing (the hook is called isReady; in the engine ready is always a boolean property)
@@ -174,9 +177,33 @@
174
177
  - `skip(dt: number, e: Engine, done: boolean)` — engine.skip moved time without stepping: advance your own time by dt fixed seconds (calendar seconds = dt x clock.speed), no per-step work. Called once per skip segment (segments end at timers and calendar clock marks); done is true on the last one: do expensive catch-up only then. Only for modules that keep time themselves (calendar, world); modules that compare against clock.now need nothing
175
178
  - `describe(e: Engine, ctx: DescribeContext) → any` — Optional: add state to engine.describe(). The (JSON-able) return value goes into the result keyed by the module name; nothing is added if it returns nothing. It may also fill in the standard fields of ctx.out, or use ctx.near() to report "nearby things"
176
179
  - `counts(e: Engine) → number | Record<string, number>` — Optional: leak-hunting counts for engine.counts(), put there under the module name (a number or an object of numbers that should not keep growing)
177
- - `applyState(e: Engine, params: StateParams) → void | Promise<void>` — Optional: handle the keys of engine.applyState that this module owns (e.g. calendar handles time and season)
180
+ - `applyState(e: Engine, params: StateParams) → void | PositionLike | { refused } | Promise<void>` — Optional: handle the keys of engine.applyState that this module owns (e.g. calendar handles time and season); for at, return the place's position; return { refused: { key: reason } } for a value it cannot apply
178
181
  - `dispose(e: Engine)` — Optional: called on engine.dispose() (in reverse install order). Only clean up what the core cannot: Workers, the physics world, real-time timers, Audio nodes you connected yourself. Events, onFixed / onFrame, clock timers, jobs, stream, ray registrations and GPU memory in the scene are reclaimed by the core; DOM listeners attached to engine.signal and UI attached to engine.uiRoot are cleaned up automatically too
179
182
 
183
+ ## createEngine({ ui })
184
+ - **UIOptions** createEngine({ ui }): the look of the default parts (theme, css, fonts, templates); every other key is a part name
185
+ - `theme?: UITheme` CSS values of every default part
186
+ - `css?: string` Extra CSS, placed after every default (overrides .threedog-* classes)
187
+ - `fonts?: string[]` Font asset names the UI uses (engine.assets.manifest({ fonts })); loaded at start(), then written in theme.font: '"pixel", system-ui'
188
+ - `templates?: Record<string, UITemplate>` Replace the content of a window wholesale: inventory, quests, settings, loading, hudMarker, hudCounter, hudBar…
189
+ - **UITheme** The CSS values of every default UI part: each key becomes the variable --threedog-<key> on engine.uiRoot
190
+ - `bg?: string` Background color
191
+ - `fg?: string` Text color
192
+ - `muted?: string` Secondary text color
193
+ - `accent?: string` Accent color
194
+ - `good?: string` Color for good news such as "done"
195
+ - `line?: string` Divider color
196
+ - `font?: string` Font (CSS font-family)
197
+ - `radius?: string` Corner radius of windows and the dialogue box (CSS, e.g. '12px')
198
+ - `radiusSmall?: string` Corner radius of small things: buttons, prompts, toasts, bubbles, HUD counters (CSS, default '8px')
199
+ - `loadingBg?: string` Loading screen background
200
+ - `shadow?: string` Window shadow (CSS)
201
+ - `shadowSmall?: string` Shadow of small things: speech bubbles, objective marker labels (CSS)
202
+ - `fadeBg?: string` Fade color for scene transitions (CSS), default '#000'
203
+ - `hudBg?: string` Background / text / accent of objective markers, counters and progress bars (CSS); default: follow bg, fg and accent
204
+ - `hudFg?: string`
205
+ - `hudAccent?: string`
206
+
180
207
  ## Data structures
181
208
  - **Handle** Handle: returned by every "add / register / listen / attach" API (events.on, onFrame, clock.after, collision.addBox, interactions.add, rays.addStatic…), call remove() to undo that registration (removes the listener, collider, timer…; safe to call repeatedly). Some handles carry extra fields (such as setTarget on hud.marker)
182
209
  - `remove()`
@@ -186,17 +213,19 @@
186
213
  - `season?: string` Season name from calendar({ seasons }): jumps calendar.day to that season's first day (time of day kept)
187
214
  - `weather?: string` Weather name
188
215
  - `pos?: string | PositionLike` Player position: 'x,z' or a position (sets the focus when there is no player)
216
+ - `at?: string` Start at a named place (content places, level markers): past the title like play, then the player stands there with the game's camera on it
189
217
  - `save?: string` Which save slot to load
190
218
  - `wait?: number` How many seconds to advance (real seconds: fixed-step seconds, no scale)
191
219
  - `cutscene?: 'skip' | 'keep'` Opening cutscene: 'skip' skips it / 'keep' plays it as usual
192
220
  - `view?: string` A view declared with engine.views to show after engine:ready (?view=name); ignored when the game declared no views
193
221
  - `play?: string | boolean` Present (?play, any value): leave the title screen the way its Start does (engine.session.newGame(), the title part closes; flow leaves its start state) before wait; nothing when no title is up
222
+ - `fresh?: string | boolean` Delete every save of this page first (no Continue on the title); on a running page also end the run and go back to the title. ?fresh in the URL
194
223
  - **StartupReport** Startup timing (milliseconds): totalMs page open to playable, startMs start() to playable, preloadMs preloading, streamMs the nearby builds required by stream registrations finished, compileMs shader compilation before the first frame, modules is the init / ready time of each module. With a budget on and startupMs (open to playable) / moduleMs (a single module) given, the slowest module is reported in the console when exceeded. firstFrameMs: page open to the end of the first frame drawn after the loading screen (null until that frame, and headless); phases add up to it: script (page open until createEngine), construct (createEngine), setup (game code until start()), init (saves, renderer, module init), preload, world (scenario parameters, nearby builds), compile (shaders + hidden warm-up frame), draw (ready until the first frame's draw calls were submitted)
195
- - `totalMs: number`
196
- - `startMs: number`
197
- - `preloadMs: number`
198
- - `streamMs: number | null`
224
+ - `totalMs: number` (experimental)
225
+ - `startMs: number` (experimental)
226
+ - `preloadMs: number` (experimental)
227
+ - `streamMs: number | null` (experimental)
199
228
  - `compileMs: number`
200
229
  - `modules: Record<string, { init?: number; ready?: number }>`
201
- - `firstFrameMs: number | null`
202
- - `phases: { script, construct, setup, init, preload, world, … }`
230
+ - `firstFrameMs: number | null` (experimental)
231
+ - `phases: { script, construct, setup, init, preload, world, … }` (experimental)