threedog 0.7.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 (544) hide show
  1. package/CHANGELOG.md +196 -1
  2. package/README.md +6 -9
  3. package/core/{Animator.js → assets/Animator.js} +28 -18
  4. package/core/{Assets.js → assets/Assets.js} +98 -54
  5. package/core/{Baked.js → assets/Baked.js} +4 -4
  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} +55 -16
  9. package/core/assets/assetLod.js +113 -0
  10. package/core/{assetManifest.js → assets/assetManifest.js} +19 -11
  11. package/core/{assetReport.js → assets/assetReport.js} +6 -12
  12. package/core/{namedModel.js → assets/namedModel.js} +17 -13
  13. package/core/{Audio.js → audio/Audio.js} +26 -23
  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} +98 -110
  21. package/core/{errorHints.js → base/errorHints.js} +5 -9
  22. package/core/{errors.js → base/errors.js} +6 -6
  23. package/core/{events.generated.js → base/events.generated.js} +1 -0
  24. package/core/{math.js → base/math.js} +15 -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} +28 -7
  28. package/core/{Engine.js → engine/Engine.js} +80 -77
  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} +14 -12
  33. package/core/{loop.js → engine/loop.js} +68 -47
  34. package/core/{moduleSlots.js → engine/moduleSlots.js} +6 -6
  35. package/core/{moduleTypes.js → engine/moduleTypes.js} +13 -14
  36. package/core/{modules.js → engine/modules.js} +14 -11
  37. package/core/{page.js → engine/page.js} +36 -23
  38. package/core/{plugins.js → engine/plugins.js} +6 -9
  39. package/core/{services.js → engine/services.js} +47 -40
  40. package/core/{startup.js → engine/startup.js} +26 -24
  41. package/core/{Input.js → input/Input.js} +30 -22
  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} +21 -20
  47. package/core/{DebugOverrides.js → inspect/DebugOverrides.js} +30 -16
  48. package/core/{Describe.js → inspect/Describe.js} +26 -22
  49. package/core/{Inspect.js → inspect/Inspect.js} +9 -7
  50. package/core/{InspectMaterials.js → inspect/InspectMaterials.js} +7 -8
  51. package/core/{InspectPerf.js → inspect/InspectPerf.js} +19 -13
  52. package/core/{InspectScene.js → inspect/InspectScene.js} +8 -5
  53. package/core/{MaterialInfo.js → inspect/MaterialInfo.js} +3 -2
  54. package/core/{UrlState.js → inspect/UrlState.js} +52 -20
  55. package/core/{catalog.js → inspect/catalog.js} +3 -3
  56. package/core/{checks.js → inspect/checks.js} +7 -5
  57. package/core/{debugView.js → inspect/debugView.js} +4 -4
  58. package/core/{describeRender.js → inspect/describeRender.js} +21 -20
  59. package/core/{describeText.js → inspect/describeText.js} +11 -6
  60. package/core/inspect/geometryWatch.js +38 -0
  61. package/core/{lightWatch.js → inspect/lightWatch.js} +8 -8
  62. package/core/{pictureWriters.js → inspect/pictureWriters.js} +15 -16
  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} +14 -17
  72. package/core/{sharedPoint.js → ops/sharedPoint.js} +8 -8
  73. package/core/{stackFrames.js → ops/stackFrames.js} +2 -2
  74. package/core/{stacks.js → ops/stacks.js} +12 -14
  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} +23 -25
  84. package/core/{Views.js → scene/Views.js} +14 -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} +17 -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/{pictureSlots.js → scene/pictureSlots.js} +2 -2
  95. package/core/{sceneDelta.js → scene/sceneDelta.js} +2 -2
  96. package/core/{sceneMethods.js → scene/sceneMethods.js} +36 -13
  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} +6 -5
  100. package/core/{thingOps.js → scene/thingOps.js} +4 -3
  101. package/core/{things.js → scene/things.js} +18 -5
  102. package/core/{threePatches.js → scene/threePatches.js} +1 -1
  103. package/core/{view.js → scene/view.js} +17 -16
  104. package/core/{Batching.js → stream/Batching.js} +85 -27
  105. package/core/{Stream.js → stream/Stream.js} +60 -30
  106. package/core/{batchGroups.js → stream/batchGroups.js} +10 -9
  107. package/core/{chunkStream.js → stream/chunkStream.js} +40 -0
  108. package/core/{scatter.js → stream/scatter.js} +2 -2
  109. package/core/{streamSources.js → stream/streamSources.js} +12 -7
  110. package/core/{Commits.js → threads/Commits.js} +6 -5
  111. package/core/{Jobs.js → threads/Jobs.js} +12 -10
  112. package/core/{Threads.js → threads/Threads.js} +16 -16
  113. package/core/{threadPure.js → threads/threadPure.js} +7 -5
  114. package/core/{threadServe.js → threads/threadServe.js} +3 -3
  115. package/core/{Clock.js → time/Clock.js} +17 -10
  116. package/core/{dayTime.js → time/dayTime.js} +5 -1
  117. package/core/{skip.js → time/skip.js} +18 -17
  118. package/core/{time.js → time/time.js} +18 -12
  119. package/core/{uiClock.js → time/uiClock.js} +4 -4
  120. package/docs/AI.md +22 -19
  121. package/docs/API.md +24 -23
  122. package/docs/CODEMAP.md +76 -183
  123. package/docs/COMMANDS.md +66 -58
  124. package/docs/CONVENTIONS.md +54 -14
  125. package/docs/MIGRATING-0.8.md +169 -0
  126. package/docs/THREE.md +78 -29
  127. package/docs/api/assets.md +12 -13
  128. package/docs/api/audio.md +6 -5
  129. package/docs/api/budget.md +4 -4
  130. package/docs/api/calendar.md +10 -11
  131. package/docs/api/cameraRig.md +29 -29
  132. package/docs/api/characters.md +23 -18
  133. package/docs/api/clock.md +1 -1
  134. package/docs/api/collision.md +12 -9
  135. package/docs/api/content.md +6 -6
  136. package/docs/api/dialogue.md +3 -3
  137. package/docs/api/engine.md +45 -43
  138. package/docs/api/events.md +3 -2
  139. package/docs/api/flow.md +1 -1
  140. package/docs/api/grids.md +1 -1
  141. package/docs/api/ground.md +4 -5
  142. package/docs/api/hud.md +2 -2
  143. package/docs/api/i18n.md +6 -6
  144. package/docs/api/input.md +7 -7
  145. package/docs/api/interactions.md +4 -4
  146. package/docs/api/inventory.md +9 -9
  147. package/docs/api/jobs.md +5 -5
  148. package/docs/api/level.md +7 -7
  149. package/docs/api/lightPool.md +1 -6
  150. package/docs/api/music.md +3 -3
  151. package/docs/api/nav.md +10 -10
  152. package/docs/api/openWorld.md +1 -1
  153. package/docs/api/particles.md +2 -2
  154. package/docs/api/photo.md +4 -2
  155. package/docs/api/pickups.md +2 -2
  156. package/docs/api/post.md +20 -3
  157. package/docs/api/quests.md +3 -3
  158. package/docs/api/rays.md +5 -7
  159. package/docs/api/rigid.md +27 -18
  160. package/docs/api/saves.md +8 -7
  161. package/docs/api/settings.md +9 -8
  162. package/docs/api/sky.md +8 -7
  163. package/docs/api/stream.md +7 -7
  164. package/docs/api/swarm.md +34 -0
  165. package/docs/api/terrain.md +7 -8
  166. package/docs/api/terrainDraw.md +1 -1
  167. package/docs/api/timeline.md +2 -2
  168. package/docs/api/tools.md +25 -22
  169. package/docs/api/vars.md +1 -1
  170. package/docs/api/vegetation.md +4 -3
  171. package/docs/api/vegetationDraw.md +1 -1
  172. package/docs/api/water.md +1 -1
  173. package/docs/api/weather.md +9 -9
  174. package/docs/api/weatherDraw.md +3 -3
  175. package/docs/api/world.md +5 -5
  176. package/docs/recipes/01-new-game.md +25 -40
  177. package/docs/recipes/02-npc.md +19 -20
  178. package/docs/recipes/03-items-pickups.md +27 -43
  179. package/docs/recipes/04-quests.md +3 -4
  180. package/docs/recipes/05-props-bake.md +29 -39
  181. package/docs/recipes/06-clock-events.md +27 -18
  182. package/docs/recipes/07-flow-scenes-pause.md +12 -17
  183. package/docs/recipes/08-weather-sky.md +88 -34
  184. package/docs/recipes/09-materials-lights-models.md +22 -36
  185. package/docs/recipes/10-blender-level.md +6 -7
  186. package/docs/recipes/11-vehicles.md +30 -22
  187. package/docs/recipes/12-navmesh.md +9 -8
  188. package/docs/recipes/13-animation.md +39 -17
  189. package/docs/recipes/14-custom-module.md +14 -13
  190. package/docs/recipes/15-perf.md +49 -26
  191. package/docs/recipes/16-dev-bridge.md +32 -52
  192. package/docs/recipes/18-world.md +36 -23
  193. package/docs/recipes/19-shooting-picking.md +4 -2
  194. package/docs/recipes/20-content-actions-save.md +30 -35
  195. package/docs/recipes/21-camera.md +33 -5
  196. package/docs/recipes/22-shop-gold.md +0 -4
  197. package/docs/recipes/23-ops.md +10 -10
  198. package/docs/recipes/26-ui-parts.md +22 -12
  199. package/docs/recipes/27-net.md +0 -2
  200. package/docs/recipes/28-terrain.md +117 -21
  201. package/docs/recipes/29-grid.md +2 -2
  202. package/docs/recipes/30-templates.md +55 -19
  203. package/docs/recipes/31-audio.md +5 -5
  204. package/docs/recipes/32-action-game.md +15 -6
  205. package/docs/recipes/33-stream-sources.md +2 -2
  206. package/docs/recipes/34-environment-lighting.md +67 -19
  207. package/docs/recipes/35-picture-from-reference.md +10 -17
  208. package/docs/recipes/36-ground-plants.md +105 -0
  209. package/docs/recipes/40-scene.md +7 -11
  210. package/docs/recipes/43-shader-patches-surfaces.md +20 -41
  211. package/docs/recipes/44-water-weather-hooks.md +48 -43
  212. package/docs/recipes/45-cascaded-shadows.md +39 -17
  213. package/docs/recipes/46-blender-art-route.md +7 -8
  214. package/docs/recipes/49-game-module-contract.md +5 -5
  215. package/docs/recipes/50-own-renderer.md +2 -2
  216. package/docs/recipes/52-around-the-picture.md +54 -98
  217. package/docs/recipes/53-ground-up-close.md +61 -24
  218. package/docs/recipes/55-mods-time-wrap.md +12 -16
  219. package/docs/recipes/56-webgpu-tsl.md +16 -14
  220. package/docs/recipes/57-control.md +9 -2
  221. package/docs/recipes/58-input.md +2 -2
  222. package/docs/recipes/59-depth-post-effects.md +1 -1
  223. package/docs/recipes/60-judge-the-picture.md +29 -24
  224. package/docs/recipes/62-picture-code.md +49 -17
  225. package/docs/recipes/63-third-person-start.md +17 -4
  226. package/docs/recipes/64-particles.md +1 -1
  227. package/docs/recipes/65-swarm.md +140 -0
  228. package/examples/action/.threedog/content-index.json +1 -1
  229. package/examples/action/GAMEMAP.md +2 -2
  230. package/examples/{sheepisland → perf-island}/.threedog/content-index.json +1 -1
  231. package/examples/{sheepisland → perf-island}/GAMEMAP.md +12 -11
  232. package/examples/{sheepisland → perf-island}/assets.js +1 -1
  233. package/examples/{sheepisland → perf-island}/main.js +8 -8
  234. package/examples/{sheepisland → perf-island}/models.js +1 -1
  235. package/examples/{sheepisland → perf-island}/params.js +1 -1
  236. package/examples/{sheepisland → perf-island}/picture/index.js +1 -1
  237. package/examples/{sheepisland → perf-island}/picture/palette.js +2 -2
  238. package/examples/{sheepisland → perf-island}/views.js +1 -1
  239. package/examples/plain-picture/GAMEMAP.md +1 -0
  240. package/examples/rc2d/GAMEMAP.md +3 -2
  241. package/examples/rc2d/main.js +1 -3
  242. package/examples/styletest/.threedog/content-index.json +1 -1
  243. package/examples/styletest/GAMEMAP.md +3 -2
  244. package/examples/techniques/contact-shadows/contactShadows.js +1 -1
  245. package/examples/techniques/contact-shadows/main.js +1 -1
  246. package/examples/techniques/interior-light/main.js +1 -1
  247. package/examples/techniques/modular-building/README.md +7 -6
  248. package/examples/techniques/outlines-and-rim/picture/post.js +1 -1
  249. package/examples/techniques/procedural-animation/README.md +1 -1
  250. package/examples/webgpu-tsl/GAMEMAP.md +1 -0
  251. package/examples/world/.threedog/content-index.json +1 -1
  252. package/examples/world/GAMEMAP.md +4 -3
  253. package/examples/world/picture/sky.js +1 -1
  254. package/index.d.ts +8 -7
  255. package/index.js +31 -31
  256. package/llms.txt +9 -13
  257. package/modules/ambience/Ambience.js +11 -8
  258. package/modules/calendar/Calendar.js +19 -19
  259. package/modules/calendar/index.js +13 -13
  260. package/modules/calendar/schedule.js +11 -6
  261. package/modules/calendar/seasons.js +7 -7
  262. package/modules/camera/FirstPersonCamera.js +2 -2
  263. package/modules/camera/FixedCamera.js +14 -15
  264. package/modules/camera/FollowCamera.js +4 -4
  265. package/modules/camera/RtsCamera.js +11 -11
  266. package/modules/camera/common.js +48 -24
  267. package/modules/camera/contract.js +1 -0
  268. package/modules/camera/projection.js +2 -2
  269. package/modules/characters/Character.js +33 -30
  270. package/modules/characters/NPC.js +27 -19
  271. package/modules/characters/assetModel.js +14 -10
  272. package/modules/characters/astar.js +7 -5
  273. package/modules/characters/behaviors.js +4 -5
  274. package/modules/characters/contract.js +2 -2
  275. package/modules/characters/index.js +168 -214
  276. package/modules/characters/moveHelpers.js +14 -3
  277. package/modules/characters/movers/common.js +16 -14
  278. package/modules/characters/movers/manual.js +1 -1
  279. package/modules/characters/movers/rapier.js +7 -6
  280. package/modules/characters/movers/simple.js +3 -3
  281. package/modules/characters/movers/support.js +8 -8
  282. package/modules/characters/npcAvoid.js +4 -4
  283. package/modules/characters/npcSim.js +23 -17
  284. package/modules/characters/npcView.js +6 -5
  285. package/modules/characters/pathAsync.js +12 -10
  286. package/modules/characters/pathWorker.js +1 -1
  287. package/modules/characters/player.js +108 -0
  288. package/modules/characters/playerStrings.js +2 -2
  289. package/modules/characters/proceduralRig.js +2 -2
  290. package/modules/characters/useModel.js +3 -3
  291. package/modules/characters/walkTo.js +11 -17
  292. package/modules/collision/Collision.js +26 -20
  293. package/modules/collision/contract.js +15 -0
  294. package/modules/content/explain.js +1 -2
  295. package/modules/content/fields.js +24 -3
  296. package/modules/content/ids.js +2 -2
  297. package/modules/content/index.js +61 -99
  298. package/modules/content/loader.js +14 -17
  299. package/modules/content/markers.js +25 -0
  300. package/modules/content/models.js +10 -7
  301. package/modules/content/packs.js +3 -3
  302. package/modules/content/parts.js +2 -2
  303. package/modules/content/places.js +35 -0
  304. package/modules/content/props.js +17 -14
  305. package/modules/content/rules.js +25 -21
  306. package/modules/content/stages.js +7 -7
  307. package/modules/content/templates.js +20 -20
  308. package/modules/content/words.js +34 -0
  309. package/modules/debug/DebugPanel.js +10 -43
  310. package/modules/flow/contract.js +1 -1
  311. package/modules/flow/index.js +11 -7
  312. package/modules/gameplay/Container.js +12 -11
  313. package/modules/gameplay/Containers.js +14 -5
  314. package/modules/gameplay/Dialogue.js +13 -11
  315. package/modules/gameplay/Interactions.js +37 -24
  316. package/modules/gameplay/Inventory.js +8 -9
  317. package/modules/gameplay/Quests.js +16 -9
  318. package/modules/gameplay/boxOps.js +1 -1
  319. package/modules/gameplay/dialogueBubbles.js +3 -4
  320. package/modules/gameplay/inventoryOps.js +0 -1
  321. package/modules/gameplay/pickups.js +22 -23
  322. package/modules/gameplay/questSave.js +3 -3
  323. package/modules/grid/Grid.js +1 -1
  324. package/modules/grid/Layer.js +4 -4
  325. package/modules/grid/index.js +7 -8
  326. package/modules/grid/preview.js +7 -7
  327. package/modules/grid/tiles.js +6 -6
  328. package/modules/hlod/index.js +37 -55
  329. package/modules/hud/index.js +17 -11
  330. package/modules/hud/parts.js +4 -4
  331. package/modules/level/contract.js +16 -0
  332. package/modules/level/heightfield.js +12 -10
  333. package/modules/level/index.js +47 -152
  334. package/modules/level/load.js +79 -0
  335. package/modules/level/meshes.js +65 -0
  336. package/modules/level/nodes.js +6 -7
  337. package/modules/lights/index.js +28 -181
  338. package/modules/lights/slots.js +93 -0
  339. package/modules/lights/sources.js +88 -0
  340. package/modules/music/Music.js +30 -26
  341. package/modules/music/rules.js +1 -1
  342. package/modules/nav/contract.js +14 -0
  343. package/modules/nav/index.js +11 -10
  344. package/modules/net/Client.js +7 -7
  345. package/modules/net/Host.js +7 -7
  346. package/modules/net/Net.js +1 -1
  347. package/modules/net/index.js +5 -4
  348. package/modules/net/sync.js +2 -2
  349. package/modules/net/transports.js +2 -2
  350. package/modules/particles/Particles.js +11 -8
  351. package/modules/particles/effect.js +7 -5
  352. package/modules/particles/shaders.js +2 -1
  353. package/modules/photo/Photo.js +15 -17
  354. package/modules/rigid/RigidBodies.js +66 -43
  355. package/modules/rigid/Vehicles.js +2 -3
  356. package/modules/rigid/ragdoll.js +287 -0
  357. package/modules/rigid/ragdollBones.js +159 -0
  358. package/modules/rigid/sync.js +6 -6
  359. package/modules/settings/Settings.js +108 -39
  360. package/modules/settings/apply.js +6 -6
  361. package/modules/settings/sections.js +16 -14
  362. package/modules/settings/view.js +3 -3
  363. package/modules/sky/Sky.js +29 -22
  364. package/modules/sky/clouds.js +7 -7
  365. package/modules/sky/dome.js +33 -20
  366. package/modules/sky/domeLayers.js +9 -9
  367. package/modules/sky/environment.js +6 -6
  368. package/modules/sky/frame.js +19 -10
  369. package/modules/sky/season.js +7 -1
  370. package/modules/sky/shader.js +24 -25
  371. package/modules/sky/skyModule.js +14 -27
  372. package/modules/sky/tint.js +1 -1
  373. package/modules/swarm/Swarm.js +346 -0
  374. package/modules/swarm/draw.js +68 -0
  375. package/modules/swarm/grid.js +63 -0
  376. package/modules/terrain/ChunkManager.js +70 -52
  377. package/modules/terrain/chunkQueries.js +7 -24
  378. package/modules/terrain/chunkWorker.js +1 -1
  379. package/modules/terrain/draw.js +14 -11
  380. package/modules/terrain/index.js +28 -34
  381. package/modules/terrain/terrainColorMap.js +6 -3
  382. package/modules/terrain/terrainDefaults.js +2 -1
  383. package/modules/terrain/terrainEdit.js +32 -27
  384. package/modules/terrain/terrainGen.js +17 -12
  385. package/modules/terrain/terrainIsland.js +2 -2
  386. package/modules/terrain/terrainMesh.js +7 -6
  387. package/modules/terrain/terrainShape.js +8 -10
  388. package/modules/terrain/terrainShapeMain.js +3 -3
  389. package/modules/timeline/Timeline.js +27 -19
  390. package/modules/timeline/Tween.js +6 -6
  391. package/modules/timeline/shots.js +5 -7
  392. package/modules/triggers/index.js +9 -9
  393. package/modules/vegetation/Vegetation.js +30 -23
  394. package/modules/vegetation/densityMap.js +4 -7
  395. package/modules/vegetation/draw.js +23 -18
  396. package/modules/vegetation/groundChunks.js +11 -31
  397. package/modules/vegetation/index.js +8 -6
  398. package/modules/vegetation/modelGeometry.js +3 -6
  399. package/modules/vegetation/nearFade.js +1 -1
  400. package/modules/water/Water.js +16 -16
  401. package/modules/water/surface.js +3 -3
  402. package/modules/weather/Weather.js +41 -30
  403. package/modules/weather/particles.js +8 -8
  404. package/modules/weather/weatherDraw.js +22 -18
  405. package/modules/world/World.js +8 -8
  406. package/modules/world/explain.js +1 -1
  407. package/modules/world/index.js +18 -12
  408. package/modules/world/persist.js +73 -25
  409. package/modules/world/pos.js +4 -4
  410. package/modules/world/records.js +28 -8
  411. package/modules/world/sim.js +4 -4
  412. package/modules/world/state.js +12 -5
  413. package/modules/world/thingSource.js +4 -2
  414. package/modules/world/views.js +11 -9
  415. package/package.json +42 -7
  416. package/presets.js +1 -3
  417. package/render/PostFX.js +39 -27
  418. package/render/backend.js +26 -32
  419. package/render/cascades.js +17 -12
  420. package/render/cascades.tsl.js +5 -8
  421. package/render/daylight.js +20 -3
  422. package/render/detail.js +8 -7
  423. package/render/effects.js +28 -25
  424. package/render/fuse.js +3 -3
  425. package/render/fx/cloudShadow.tsl.js +3 -3
  426. package/render/fx/detail.tsl.js +1 -1
  427. package/render/fx/index.js +5 -10
  428. package/render/fx/library.tsl.js +11 -0
  429. package/render/fx/lighting.tsl.js +2 -1
  430. package/render/fx/nodeErrors.tsl.js +2 -2
  431. package/render/fx/objectOrigin.tsl.js +1 -2
  432. package/render/fx/patchNodes.tsl.js +5 -15
  433. package/render/fx/postWebGPU.tsl.js +27 -23
  434. package/render/fx/sky.tsl.js +15 -17
  435. package/render/fx/uniforms.tsl.js +4 -4
  436. package/render/fx/wind.tsl.js +1 -1
  437. package/render/fxNumbers.js +3 -0
  438. package/render/layers.js +1 -1
  439. package/render/lighting.js +5 -3
  440. package/render/lightmap.js +20 -20
  441. package/render/lights.js +6 -6
  442. package/render/lit.js +24 -0
  443. package/render/materials.js +8 -7
  444. package/render/mergeCommon.js +22 -0
  445. package/render/modeling.js +2 -2
  446. package/render/occlusion.js +20 -4
  447. package/render/ownFrame.js +4 -4
  448. package/render/patches.js +13 -13
  449. package/render/postWebGL.js +12 -10
  450. package/render/probes.js +16 -19
  451. package/render/recordSweep.js +117 -0
  452. package/render/shaderErrors.js +10 -9
  453. package/render/shadowCache.tsl.js +107 -0
  454. package/render/shadowTypes.js +9 -0
  455. package/{core → render}/shadows.js +57 -11
  456. package/render/slots.js +7 -7
  457. package/render/terms.js +22 -24
  458. package/render/uniformDecl.js +1 -1
  459. package/types/core.d.ts +200 -153
  460. package/types/gameplay.d.ts +163 -91
  461. package/types/generated/core/{Audio.d.ts → audio/Audio.d.ts} +22 -7
  462. package/types/generated/core/{audioVoice.d.ts → audio/audioVoice.d.ts} +2 -2
  463. package/types/generated/core/{Events.d.ts → base/Events.d.ts} +4 -4
  464. package/types/generated/core/{I18n.d.ts → base/I18n.d.ts} +7 -15
  465. package/types/generated/core/{Random.d.ts → base/Random.d.ts} +4 -3
  466. package/types/generated/core/{page.d.ts → engine/page.d.ts} +8 -9
  467. package/types/generated/core/{Input.d.ts → input/Input.d.ts} +12 -8
  468. package/types/generated/core/{Budget.d.ts → inspect/Budget.d.ts} +36 -26
  469. package/types/generated/core/{DebugOverrides.d.ts → inspect/DebugOverrides.d.ts} +2 -2
  470. package/types/generated/core/{Ops.d.ts → ops/Ops.d.ts} +4 -3
  471. package/types/generated/core/{control.d.ts → ops/control.d.ts} +4 -10
  472. package/types/generated/core/{Saves.d.ts → saves/Saves.d.ts} +37 -13
  473. package/types/generated/core/{session.d.ts → saves/session.d.ts} +2 -1
  474. package/types/generated/core/{Rays.d.ts → scene/Rays.d.ts} +8 -27
  475. package/types/generated/core/{Views.d.ts → scene/Views.d.ts} +1 -1
  476. package/types/generated/core/{Batching.d.ts → stream/Batching.d.ts} +7 -7
  477. package/types/generated/core/{Stream.d.ts → stream/Stream.d.ts} +18 -16
  478. package/types/generated/core/{Commits.d.ts → threads/Commits.d.ts} +1 -1
  479. package/types/generated/core/{Jobs.d.ts → threads/Jobs.d.ts} +6 -6
  480. package/types/generated/core/{Threads.d.ts → threads/Threads.d.ts} +4 -4
  481. package/types/generated/modules/calendar/Calendar.d.ts +10 -11
  482. package/types/generated/modules/debug/DebugPanel.d.ts +1 -9
  483. package/types/generated/modules/grid/Layer.d.ts +1 -1
  484. package/types/generated/modules/grid/index.d.ts +3 -3
  485. package/types/generated/modules/music/Music.d.ts +7 -5
  486. package/types/generated/modules/particles/Particles.d.ts +1 -1
  487. package/types/generated/modules/sky/Sky.d.ts +21 -10
  488. package/types/generated/modules/swarm/Swarm.d.ts +80 -0
  489. package/types/generated/modules/timeline/Timeline.d.ts +2 -1
  490. package/types/generated/modules/water/Water.d.ts +1 -0
  491. package/types/generated/modules/weather/Weather.d.ts +16 -12
  492. package/types/generated/modules/weather/weatherDraw.d.ts +3 -3
  493. package/types/generated/modules/world/World.d.ts +5 -3
  494. package/types/generated/render/PostFX.d.ts +17 -11
  495. package/types/generated/render/materials.d.ts +1 -0
  496. package/types/generated/render/occlusion.d.ts +9 -0
  497. package/types/generated/render/patches.d.ts +1 -0
  498. package/types/generated/ui/Focus.d.ts +1 -0
  499. package/types/generated/ui/UI.d.ts +1 -0
  500. package/types/nav.d.ts +11 -11
  501. package/types/physics.d.ts +99 -70
  502. package/types/tsl.d.ts +37 -4
  503. package/types/world.d.ts +38 -71
  504. package/ui/Focus.js +10 -9
  505. package/ui/Parts.js +4 -3
  506. package/ui/UI.js +7 -7
  507. package/ui/defaults.js +3 -2
  508. package/ui/theme.js +5 -3
  509. package/core/assetEntry.js +0 -109
  510. package/core/holds.js +0 -134
  511. package/core/shadowTypes.js +0 -16
  512. package/core/util.js +0 -17
  513. package/docs/MIGRATING-0.3.md +0 -248
  514. package/docs/MIGRATING-0.4.md +0 -320
  515. package/docs/MIGRATING-0.5.md +0 -68
  516. package/docs/MIGRATING-0.6.md +0 -126
  517. package/docs/PERF.md +0 -245
  518. package/docs/recipes/36-sky-ground-plants.md +0 -158
  519. package/docs/recipes/37-terrain-hooks.md +0 -115
  520. package/docs/recipes/38-environment-hooks.md +0 -67
  521. package/docs/recipes/42-terrain-shape.md +0 -64
  522. package/docs/recipes/47-island-snow-backdrop.md +0 -43
  523. package/docs/recipes/54-three-idioms.md +0 -88
  524. package/examples/plain-picture/FINDINGS.md +0 -53
  525. /package/core/{Vars.js → base/Vars.js} +0 -0
  526. /package/core/{mulberry32.js → base/mulberry32.js} +0 -0
  527. /package/core/{inputDefaults.js → input/inputDefaults.js} +0 -0
  528. /package/core/{textureBytes.js → inspect/textureBytes.js} +0 -0
  529. /package/core/{actor.js → ops/actor.js} +0 -0
  530. /package/core/{opsFail.js → ops/opsFail.js} +0 -0
  531. /package/core/{opsHistory.js → ops/opsHistory.js} +0 -0
  532. /package/core/{saveIds.js → saves/saveIds.js} +0 -0
  533. /package/core/{screenToGround.js → scene/screenToGround.js} +0 -0
  534. /package/core/{tier.js → scene/tier.js} +0 -0
  535. /package/core/{cells.js → stream/cells.js} +0 -0
  536. /package/core/{streamCells.js → stream/streamCells.js} +0 -0
  537. /package/core/{pureWorker.js → threads/pureWorker.js} +0 -0
  538. /package/examples/{sheepisland → perf-island}/content/index.js +0 -0
  539. /package/examples/{sheepisland → perf-island}/content/props.js +0 -0
  540. /package/examples/{sheepisland → perf-island}/content/templates.js +0 -0
  541. /package/examples/{sheepisland → perf-island}/content/vegetation.js +0 -0
  542. /package/examples/{sheepisland → perf-island}/picture/lights.js +0 -0
  543. /package/examples/{sheepisland → perf-island}/picture/materials.js +0 -0
  544. /package/examples/{sheepisland → perf-island}/picture/sky.js +0 -0
@@ -2,7 +2,7 @@
2
2
  // quests, photo mode, ambience, debug.
3
3
  import type { Object3D, Vector3, Vector2, Quaternion, Texture, ColorLike, Vec3Like, Ease, Handle, Range, XZ, Loose, PositionLike, Material } from './common';
4
4
  import type { Engine } from './core';
5
- import type { Input } from './generated/core/Input';
5
+ import type { Input } from './generated/core/input/Input';
6
6
  import type { Animator, AnimatorOptions, Rideable } from './physics';
7
7
  import type { WorldRecord } from './generated/modules/world/World';
8
8
 
@@ -93,15 +93,15 @@ export interface LevelOptions {
93
93
  outside?: number;
94
94
  /** Water surface height (meters), default no water */
95
95
  waterLevel?: number;
96
- /** Expand the collision box outward by this much (meters) */
96
+ /** Expand the collision box outward by this much (meters) @experimental */
97
97
  colliderPad?: number;
98
- /** Minimum height of the collision box (meters) */
98
+ /** Minimum height of the collision box (meters) @experimental */
99
99
  colliderHeight?: number;
100
- /** Treat it as a step edge when the height difference between adjacent grid points exceeds this (meters), default 0.6 */
100
+ /** Treat it as a step edge when the height difference between adjacent grid points exceeds this (meters), default 0.6 @experimental */
101
101
  sharpEdge?: number;
102
- /** Hide the marker placeholder meshes, default true */
102
+ /** Hide the marker placeholder meshes, default true @experimental */
103
103
  hideMarkers?: boolean;
104
- /** Add the scene to engine.scene, default true */
104
+ /** Add the scene to engine.scene, default true @experimental */
105
105
  addToScene?: boolean;
106
106
  }
107
107
  /** Markers in the level (spawn, npc_*, trigger_*, marker_*), in world coordinates */
@@ -116,7 +116,7 @@ export interface Level {
116
116
  markers: Record<string, LevelMarker>;
117
117
  /** Spawn point position */
118
118
  spawn: Vector3;
119
- /** Heightfield (for debugging) */
119
+ /** Heightfield (for debugging) @experimental */
120
120
  heightfield: any;
121
121
  /** Whether loading is finished */
122
122
  readonly ready: boolean;
@@ -124,7 +124,7 @@ export interface Level {
124
124
  marker(name: string): LevelMarker | null;
125
125
  /** Get all markers whose names start with prefix, e.g. markersWith('npc_') */
126
126
  markersWith(prefix: string): LevelMarker[];
127
- /** Unload the level (the scene is fully deleted with engine.remove; collision, ray registrations and things registered with track are removed together) */
127
+ /** Unload the level (the scene is fully deleted with engine.remove; collision, ray registrations and things registered with track are removed together) @experimental */
128
128
  unload(): void;
129
129
  /**
130
130
  * Change level: unload the current one, load the new one (glTF path/asset name, or a THREE object), and emit level:loaded when done. When a load
@@ -237,7 +237,7 @@ export interface Triggers {
237
237
 
238
238
  /** Particle effect parameters (define(), and each entry of particles({ effects, default })). All optional */
239
239
  export interface ParticleOptions {
240
- /** Maximum alive at once, default 120 (halved on low-end devices) */
240
+ /** Maximum alive at once, default 120 (60 on low-tier devices; a number the game gives stands) */
241
241
  max?: number;
242
242
  /** Seconds each particle lives [min, max] */
243
243
  lifetime?: Range;
@@ -307,13 +307,48 @@ export interface ParticlesOptions {
307
307
 
308
308
  // Particles (engine.particles) is generated from the JSDoc in modules/particles/Particles.js (npm run map); only the type is re-exported here
309
309
  import type { Particles } from './generated/modules/particles/Particles';
310
+
311
+ // Swarm swarm()
312
+
313
+ /** Options of engine.swarm(). See recipes/65-swarm.md */
314
+ export interface SwarmOptions {
315
+ /** Unique name: shown in describe(), the key in a save */
316
+ name: string;
317
+ /** Most objects alive at once; all memory is taken up front */
318
+ capacity: number;
319
+ /** Plain three.js geometry, stays the game's to dispose. Leave out with material for a swarm that draws nothing */
320
+ geometry?: import('three').BufferGeometry;
321
+ /** Plain three.js material, stays the game's to dispose */
322
+ material?: import('three').Material;
323
+ /** Number columns beside x, y, z. yaw, pitch, roll (radians, order YXZ) and scale are also drawn by the engine */
324
+ fields?: string[];
325
+ /** Per-object colour: columns r, g, b (linear) and spawn({ color: 0xff8800 }) */
326
+ color?: boolean;
327
+ /** Time channel of the onStep dt (default 'world') */
328
+ channel?: string;
329
+ /** Grid cell for near, in meters: about the usual query radius (default 2) */
330
+ cell?: number;
331
+ /** Keep this swarm in saves; otherwise it is empty after a load or new game */
332
+ save?: boolean;
333
+ }
334
+ /** The columns of a swarm: d.x[row], d.vx[row]... and d.id[row], the handle of that row */
335
+ export type SwarmData = { x: Float32Array; y: Float32Array; z: Float32Array; id: Float64Array } & Record<string, Float32Array | Float64Array>;
336
+ /** Runs for each live row every fixed step; returning false removes the object, anything else keeps it */
337
+ export type SwarmRowFn = (d: SwarmData, i: number, dt: number) => unknown;
338
+ import type { Swarm } from './generated/modules/swarm/Swarm';
339
+ export type { Swarm };
340
+ /** engine.swarm: call it to make a swarm */
341
+ export interface SwarmMaker {
342
+ /** Make a swarm. Returns a Swarm: spawn, free, row, onStep, near, clear, dispose, count, capacity, data, mesh */
343
+ (opts: SwarmOptions): Swarm;
344
+ }
310
345
  export type { Particles };
311
346
 
312
347
  // ======================================================================
313
348
  // Settings menu settings()
314
349
  // ======================================================================
315
350
 
316
- /** Contents of a graphics quality preset */
351
+ /** Contents of a graphics quality preset. pixelRatio is a share from 0 to 1 of the ratio the engine picked for this device, so one preset fits every screen */
317
352
  export interface QualityPreset { pixelRatio?: number; shadows?: boolean; antialias?: boolean; bloom?: boolean; ao?: boolean; viewChunks?: number; density?: number; [key: string]: any }
318
353
  /**
319
354
  * The tools a settings tab's render(tools, e, s) receives: escaping, translation and the control helpers (each returns HTML)
@@ -356,10 +391,12 @@ export interface SettingsOptions {
356
391
  /**
357
392
  * Tabs: true (default) graphics, audio, controls, language, saves; false none; or a list by name, which may include the optional
358
393
  * 'game' (resume, load a save, back to title) and 'camera' (mouse sensitivity, invert Y, field of view; saved as camera.sensitivity / camera.invertY
359
- * / camera.fov)
394
+ * / camera.fov). The entry { id: 'graphics', omit } leaves graphics rows out (quality, pixelRatio, shadows, antialias, bloom, ao, adaptive, viewChunks,
395
+ * density): an omitted row stays the game's value, and no preset or stored value moves it
360
396
  * @example settings({ sections: ['game', 'graphics', 'audio', 'controls', 'camera'] })
397
+ * @example settings({ sections: [{ id: 'graphics', omit: ['pixelRatio', 'antialias', 'adaptive'] }, 'audio', 'controls', 'language', 'saves'] }) // a fixed pixel look
361
398
  */
362
- sections?: boolean | string[];
399
+ sections?: boolean | (string | { id: 'graphics'; omit: string[] })[];
363
400
  /**
364
401
  * Pause gameplay while the menu is open (with flow installed it switches to flow's 'paused' and returns to the previous state on close; without flow
365
402
  * it uses engine.freeze); the picture keeps running, default false
@@ -369,19 +406,19 @@ export interface SettingsOptions {
369
406
 
370
407
  /** engine.settings */
371
408
  export interface Settings {
372
- /** All current setting values */
373
- values: Record<string, any>;
409
+ /** All current setting values, read only (set() changes one). pixelRatio is the renderer's real ratio */
410
+ readonly values: Record<string, any>;
374
411
  /** Graphics presets */
375
412
  presets: Record<string, QualityPreset>;
376
- /** Tabs */
413
+ /** Tabs @experimental */
377
414
  sections: Map<string, any>;
378
- /** Whether the menu is open */
415
+ /** Whether the menu is open @experimental */
379
416
  readonly isOpen: boolean;
380
417
  /** Read a setting, e.g. get('vol.music') */
381
418
  get(key: string): any;
382
419
  /** Change a setting (takes effect immediately + saved) */
383
420
  set(key: string, value: any, opts?: { save?: boolean }): void;
384
- /** Graphics preset: 'low' | 'medium' | 'high' */
421
+ /** Graphics preset: 'low' | 'medium' | 'high' @experimental */
385
422
  preset(name: 'low' | 'medium' | 'high' | (string & {})): void;
386
423
  /** Game-defined setting: default value + apply function (saved automatically), or { apply, limits }. limits names the shared value(s) the row
387
424
  * restricts on the settings layer, like the built-in shadows row: off holds it off (the scene, weather or a cutscene cannot turn it back on),
@@ -389,15 +426,16 @@ export interface Settings {
389
426
  define<T = any>(key: string, def: T, apply?: ((value: T, e: Engine) => void) | { apply?: (value: T, e: Engine) => void; limits?: string | string[] }): this;
390
427
  /** Add a tab of your own, or a built-in / optional one by name: addSection('camera') */
391
428
  addSection(id: string, section?: SettingsSection): this;
392
- removeSection(id: string): void;
393
429
  open(): void;
394
430
  close(): void;
395
431
  toggle(on?: boolean): void;
396
- /** Restore all keys to defaults */
432
+ /** Put one setting (or all, with no key) back to its default: the engine's start value, or the default the game gave define(). Keys: resetBindings */
433
+ reset(key?: string): void;
434
+ /** Restore all keys to defaults @experimental */
397
435
  resetBindings(): void;
398
436
  /** Change the first key of an action to code */
399
437
  rebind(action: string, code: string): void;
400
- /** Key list (for the UI) */
438
+ /** Key list (for the UI) @experimental */
401
439
  actionList(): any[];
402
440
  /** Save to the browser */
403
441
  save(): void;
@@ -425,7 +463,7 @@ export interface MusicOptions {
425
463
  fade?: number;
426
464
  /** Duck the music bus during dialogue to this (0-1, e.g. 0.35); default false = no duck (the game opts in) */
427
465
  duckDialogue?: number | false;
428
- /** Fade seconds for the ducking */
466
+ /** Fade seconds for the ducking @experimental */
429
467
  duckFade?: number;
430
468
  /** Rule debounce seconds, default 2 */
431
469
  hold?: number;
@@ -561,10 +599,8 @@ export type CharacterState = 'idle' | 'walk' | 'run' | 'swim' | 'jump' | 'fall'
561
599
  /** Character (player and NPCs) */
562
600
  export declare class Character {
563
601
  constructor(engine: Engine, opts?: CharacterOptions);
564
- /** Root node (this is what gets added to the scene) */
602
+ /** 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 */
565
603
  root: Object3D;
566
- /** Same as root: add children, change visible and scale on it */
567
- readonly object: Object3D;
568
604
  /** Position (= root.position) */
569
605
  readonly position: Vector3;
570
606
  /** 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') */
@@ -574,11 +610,11 @@ export declare class Character {
574
610
  * root.rotation.y)
575
611
  */
576
612
  facing: number;
577
- /** Vertical velocity (m/s). Writable: setting it is an impulse (launch() does the same and also leaves the ground cleanly) */
613
+ /** 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) */
578
614
  vy: number;
579
615
  /** Whether standing on the ground */
580
616
  grounded: boolean;
581
- /** Whether swimming */
617
+ /** Whether swimming @experimental */
582
618
  swimming: boolean;
583
619
  /** Current action state */
584
620
  state: CharacterState;
@@ -588,15 +624,23 @@ export declare class Character {
588
624
  faceMode: FaceMode;
589
625
  /** What faceMode 'target' faces */
590
626
  faceTarget: PositionLike | null;
591
- /** Player only: whether the camera module follows it (see PlayerOptions.cameraFollow) */
627
+ /** Player only: whether the camera module follows it (see PlayerOptions.cameraFollow) @experimental */
592
628
  cameraFollow?: boolean;
593
629
  /** Move at a fixed velocity (m/s) for seconds, ignoring move()'s direction and without turning (knockback, dodge roll); gravity and collision still apply */
594
630
  push(vx: number, vz: number, seconds: number): void;
595
- speed: number; runSpeed: number; radius: number; water: CharacterWater; states: CharacterStates | null; swimDepth: number; swimSpeedFactor: number;
596
- turnSpeed: number; acceleration: number; gravity: number; jumpSpeed: number; stepHeight: number; airControl: number; coyoteTime: number; canJump: boolean;
597
- /** Base jump values (the game's; modifiers go through engine.mod('move.jumpSpeed')) */
598
- maxJumps: number; airJumpSpeed: number | null; jumpBuffer: number;
599
- /** Fall check (see CharacterOptions.fall); a plain property */
631
+ speed: number; runSpeed: number; radius: number; water: CharacterWater; states: CharacterStates | null;
632
+ /** @experimental */ swimDepth: number;
633
+ /** @experimental */ swimSpeedFactor: number;
634
+ /** @experimental */ turnSpeed: number;
635
+ /** @experimental */ acceleration: number; gravity: number; jumpSpeed: number;
636
+ /** @experimental */ stepHeight: number;
637
+ /** @experimental */ airControl: number;
638
+ /** @experimental */ coyoteTime: number; canJump: boolean;
639
+ /** Base jump values (the game's; modifiers go through engine.mod('move.jumpSpeed')) @experimental */
640
+ maxJumps: number;
641
+ /** @experimental */ airJumpSpeed: number | null;
642
+ /** @experimental */ jumpBuffer: number;
643
+ /** Fall check (see CharacterOptions.fall); a plain property @experimental */
600
644
  fall: false | { belowY: number | ((character: Character) => boolean) };
601
645
  /** Time channel the engine drives it on (see CharacterOptions.channel) */
602
646
  channel: string;
@@ -607,25 +651,21 @@ export declare class Character {
607
651
  * @example engine.mod('move.speed', { owner: 'haste', id: 'player', mul: 1.2, for: 5 }); player.stat('speed') // 1.2 x player.speed
608
652
  */
609
653
  stat(name: 'speed' | 'runSpeed' | 'gravity' | 'jumpSpeed' | 'canJump'): number;
610
- /** Give back n jumps for this airtime (pickup, wall touch) */
654
+ /** Give back n jumps for this airtime (pickup, wall touch) @experimental */
611
655
  addJumps(n?: number): this;
612
- /** All jumps back, as if it had landed */
656
+ /** All jumps back, as if it had landed @experimental */
613
657
  resetJumps(): this;
614
658
  /**
615
659
  * 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
616
660
  * @example player.launch(19, { owner: 'pad' })
617
661
  */
618
662
  launch(speed: number, opts?: { owner?: string }): this;
619
- /** Jump state now, read-only */
663
+ /** Jump state now, read-only @experimental */
620
664
  jumpState(): { grounded: boolean; coyoteLeft: number; bufferLeft: number; jumpsUsed: number; jumpsLeft: number; vy: number };
621
665
  /** What it stands on, read-only (reused object); 'platform' = a registered support (characters.support), which carries it */
622
666
  readonly support: { kind: 'ground' | 'platform' | 'collider' | 'water' | null; object: any; id: string | null; safe: boolean; velocity: { x: number; y: number; z: number } };
623
667
  /** Last spot it stood still on safe ground (where a fall returns it); null until it first stands. Saved with the motion */
624
668
  safeGround: Vector3 | null;
625
- /** Called when a foot lands (the argument is the ground type underfoot) */
626
- onStep: ((groundType: string) => void) | null;
627
- /** Called on landing (the argument is the landing speed) */
628
- onLand: ((impact: number) => void) | null;
629
669
  /** 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' */
630
670
  get mover(): { name: 'simple' | 'rapier' | 'manual'; controller?: any; body?: any; collider?: any; move(dirX: number, dirZ: number, run: boolean, dt: number): void; dispose?(): void };
631
671
  set mover(name: 'simple' | 'rapier' | 'manual');
@@ -635,7 +675,7 @@ export declare class Character {
635
675
  ready: boolean;
636
676
  /**
637
677
  * Settles (never rejects) when a model named by asset is swapped in or has failed; already settled otherwise
638
- * @example const npc = new Character(engine, { model: 'villager' }).addTo(); // import { Character } from 'threedog' await npc.whenReady;
678
+ * @example const npc = new Character(engine, { model: 'villager' }); engine.add(npc.root); // import { Character } from 'threedog' await npc.whenReady;
639
679
  * npc.playAction('Wave');
640
680
  */
641
681
  readonly whenReady: Promise<void>;
@@ -664,8 +704,6 @@ export declare class Character {
664
704
  * @example createPlayer({ ...presets.player.thirdPerson, maxJumps: 2 }) // double jump
665
705
  */
666
706
  jump(opts?: { air?: boolean }): this;
667
- /** Add to the scene */
668
- addTo(scene?: any): this;
669
707
  /** Put it on the ground at position (Vector3 / object / [x, y, z] / { x, z }) */
670
708
  placeAt(position: PositionLike): this;
671
709
  /**
@@ -693,9 +731,10 @@ export declare class Character {
693
731
  /**
694
732
  * Copy the motion state into a plain object (velocity, vertical velocity, heading, movement amount, grounded, swimming) to store in world data; after
695
733
  * the model is rebuilt or a save is loaded, loadMotion continues from it with identical results
734
+ * @experimental
696
735
  */
697
736
  saveMotion(out?: CharacterMotion): CharacterMotion;
698
- /** Restore the motion state from the plain object of saveMotion */
737
+ /** Restore the motion state from the plain object of saveMotion @experimental */
699
738
  loadMotion(m: CharacterMotion | null | undefined): this;
700
739
  }
701
740
  /** Result of Character.saveMotion (plain values, can be saved); facing is the same as Character.facing: 0 = +Z, forward (sin f, cos f) */
@@ -888,6 +927,7 @@ export interface CharactersApi {
888
927
  /**
889
928
  * Delete the current player (exits the vehicle first, stops responding to keys, fully deletes the model). The player save (key player) carries the
890
929
  * position and the vehicle; loading an on-foot save exits the vehicle first
930
+ * @experimental
891
931
  */
892
932
  removePlayer(): void;
893
933
  /**
@@ -921,7 +961,7 @@ export interface FindSpawnOptions { minH?: number; maxH?: number; maxSlope?: num
921
961
  export interface CharactersOptions {
922
962
  /** Whether to enable NPCs (engine.npcs), default true */
923
963
  npcs?: boolean;
924
- /** Near tiers for large NPC crowds, off by default (every near NPC walks every fixed step); same as engine.npcs.tiers(opts) */
964
+ /** Near tiers for large NPC crowds, off by default (every near NPC walks every fixed step); same as engine.npcs.tiers(opts) @experimental */
925
965
  npcTiers?: { fullRadius: number; nearEvery: number };
926
966
  /** 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 */
927
967
  animation?: AnimatorOptions;
@@ -936,6 +976,34 @@ export interface FindPathOptions { step?: number; maxNodes?: number; radius?: nu
936
976
  // Interactions interactions()
937
977
  // ======================================================================
938
978
 
979
+ /** One live interaction, as interactions.get(id) and interactions.items give it */
980
+ export interface Interaction {
981
+ id: string;
982
+ /** What it follows; a fixed position is an empty Object3D placed there */
983
+ object: Object3D;
984
+ label: string | ((object: Object3D, ctx: { actor: string }) => string);
985
+ radius: number;
986
+ action: string;
987
+ onUse?: (object: Object3D, ctx: { actor: string }) => any;
988
+ enabled: (object: Object3D, ctx: { actor: string }) => boolean;
989
+ height?: number;
990
+ hold: number;
991
+ approach: boolean;
992
+ once: boolean;
993
+ counter?: string;
994
+ }
995
+ /** inventory.add: what went in, or why nothing did */
996
+ export interface ItemAddResult {
997
+ ok: boolean;
998
+ /** The entry they went into ('arrow', 'sword#3'); set when ok */
999
+ key?: string;
1000
+ /** How many fit (a partial fit places what fits); set when ok */
1001
+ added?: number;
1002
+ /** 'full' when none fit */
1003
+ code?: 'full';
1004
+ facts?: { id: string; n: number };
1005
+ nextActions?: any[];
1006
+ }
939
1007
  export interface InteractionOptions {
940
1008
  /** Stable id for the op interaction.use { id } (default: the world record id it was built for, else a running number) */
941
1009
  id?: string;
@@ -966,15 +1034,15 @@ export interface InteractionOptions {
966
1034
  approach?: boolean;
967
1035
  /** Hide the object after a use and allow no second one (onUse returning { ok: false } leaves it). Saved under id, else the object's name; development throws when it has neither */
968
1036
  once?: boolean;
969
- /** Name of a HUD counter each use adds 1 to (hud.add; nothing without hud()). Saved; read the total with hud.value(name) */
1037
+ /** Name of a HUD counter each use adds 1 to (hud.bump; nothing without hud()). Saved; read the total with hud.value(name) */
970
1038
  counter?: string;
971
1039
  }
972
1040
  /** engine.interactions */
973
1041
  export interface Interactions {
974
- /** How high the prompt floats (meters) */
1042
+ /** How high the prompt floats (meters) @experimental */
975
1043
  promptHeight: number;
976
1044
  /** All interactions in the order added (a fresh array each read; get(id) finds one without it) */
977
- readonly items: any[];
1045
+ readonly items: Interaction[];
978
1046
  /** Default reach of add() in meters (2.5) */
979
1047
  radius: number;
980
1048
  /** How the one in front of the actor is chosen; can be changed at runtime */
@@ -990,8 +1058,8 @@ export interface Interactions {
990
1058
  * Returns a handle { remove() }
991
1059
  */
992
1060
  add(target: Object3D | PositionLike, opts?: InteractionOptions): Handle;
993
- /** The interaction with this id, or null. Using one is the op: engine.ops.run('interaction.use', { id }) (no id = the one the actor would pick) */
994
- get(id: string): any;
1061
+ /** The interaction with this id, or undefined. Using one is the op: engine.ops.run('interaction.use', { id }) (no id = the one the actor would pick) */
1062
+ get(id: string): Interaction | undefined;
995
1063
  }
996
1064
  /**
997
1065
  * What the 'prompt' UI part receives in update(view) every frame while an interaction is in reach (hide() when none). Call use() on click: it runs the
@@ -1097,7 +1165,7 @@ export interface BubbleView { speaker: string; text: string; x: number; y: numbe
1097
1165
  export interface Dialogue {
1098
1166
  /** Story state: state.flags is engine.vars.flags (autosaved) */
1099
1167
  readonly state: DialogueState;
1100
- /** All scripts */
1168
+ /** All scripts @experimental */
1101
1169
  scripts: Map<string, DialogueScript>;
1102
1170
  /**
1103
1171
  * The dialogue in progress (null when none). speaker: the script name; node: the current node OBJECT (its fields: text, choices, data...);
@@ -1105,10 +1173,10 @@ export interface Dialogue {
1105
1173
  * @example const atAsk = engine.dialogue.active?.id === 'ask'; // the node id; active.node.data holds the node's own fields
1106
1174
  */
1107
1175
  readonly active: { speaker: string; nodes: DialogueScript; node?: DialogueNode; id?: string; onEnd: (() => void) | null } | null;
1108
- /** The script the main dialogue is playing */
1176
+ /** The script the main dialogue is playing @experimental */
1109
1177
  readonly speaking: string | null;
1110
- /** Typing speed (characters/second) */
1111
- cps: number;
1178
+ /** Typing speed (characters/second) @experimental */
1179
+ charsPerSecond: number;
1112
1180
  /** Define a dialogue (the name is usually the speaker) */
1113
1181
  define(speaker: string, nodes: DialogueScript): void;
1114
1182
  /**
@@ -1263,7 +1331,7 @@ export interface PickupOptions {
1263
1331
  auto?: boolean;
1264
1332
  /** The game's own three.js object for this one pickup (only detached when it goes; otherwise the model name decides the shape) */
1265
1333
  mesh?: Object3D | null;
1266
- /** Game seconds until it reappears, 0 = never reappears */
1334
+ /** Calendar seconds until it reappears, 0 = never reappears */
1267
1335
  respawnSeconds?: number;
1268
1336
  /** Bob up and down and rotate, default true */
1269
1337
  bob?: boolean;
@@ -1289,7 +1357,7 @@ export interface Pickups {
1289
1357
  material: Material;
1290
1358
  /** Edge of the placeholder box (meters), read when one is built */
1291
1359
  size: number;
1292
- /** Height above the ground new pickups float at (meters) */
1360
+ /** Height above the ground new pickups float at (meters) @experimental */
1293
1361
  lift: number;
1294
1362
  /**
1295
1363
  * Place a pickup on the ground at position; its y, if any, is the reference height on multi-layer ground (needs the interactions module unless auto):
@@ -1302,7 +1370,7 @@ export interface Pickups {
1302
1370
  export interface PickupsOptions {
1303
1371
  /** Reach of pickups that do not set their own radius (meters), default 2 */
1304
1372
  radius?: number;
1305
- /** Pickups have a model, float and spin only within this distance (meters) of the stream sources, default 60 */
1373
+ /** Pickups have a model, float and spin only within this distance (meters) of the stream sources, default 60 @experimental */
1306
1374
  showDistance?: number;
1307
1375
  /** Who walks into auto pickups (actor ids); default engine.actor, plus net peers on a host */
1308
1376
  takers?: (e: Engine) => string[];
@@ -1330,7 +1398,7 @@ export interface Container {
1330
1398
  /** Whether there are at least n (default 1) */
1331
1399
  has(x: string, n?: number): boolean;
1332
1400
  /** One entry by key, or null */
1333
- get(key: string): ItemEntry | null;
1401
+ get(key: string): ItemEntry | undefined;
1334
1402
  /** Slots used */
1335
1403
  readonly slotsUsed: number;
1336
1404
  /** Total weight */
@@ -1339,8 +1407,8 @@ export interface Container {
1339
1407
  list(): ItemEntry[];
1340
1408
  /** How many more fit (Infinity = no limit), for an item without data, with this data, or like an existing entry key */
1341
1409
  room(x: string, data?: Record<string, any>): number;
1342
- /** Add n (default 1), optionally with data; returns the entry key, false if none fit; silent suppresses the toast (only the bag of engine.actor shows one) */
1343
- add(id: string, n?: number, opts?: { data?: Record<string, any>; silent?: boolean }): string | false;
1410
+ /** Add n (default 1), optionally with data; returns { ok: true, key, added } (added: how many fit), or { ok: false, code: 'full' } when none fit; silent suppresses the toast (only the bag of engine.actor shows one) */
1411
+ add(id: string, n?: number, opts?: { data?: Record<string, any>; silent?: boolean }): ItemAddResult;
1344
1412
  /** Remove n (default 1) of an item or entry key, returns false if there are not enough */
1345
1413
  remove(x: string, n?: number): boolean;
1346
1414
  /**
@@ -1360,13 +1428,13 @@ export interface Container {
1360
1428
  export interface Inventory {
1361
1429
  /** true: gameplay freezes while the inventory window is open (set from inventory({ pauseGame }) or at runtime) */
1362
1430
  pauseGame: boolean;
1363
- /** Slot limit of the player inventory */
1431
+ /** Slot limit of the player inventory @experimental */
1364
1432
  capacity: number;
1365
- /** Player inventory: the bag of engine.actor (= of()) */
1433
+ /** Player inventory: the bag of engine.actor (= of()) @experimental */
1366
1434
  readonly bag: Container;
1367
1435
  /** The bag of an actor (default engine.actor): the container with the actor's id, created empty on first use; inside an op pass ctx.actor */
1368
1436
  of(actor?: string): Container;
1369
- defaultStack: number;
1437
+ /** @experimental */ defaultStack: number;
1370
1438
  action: string;
1371
1439
  /** Define an item (chainable) */
1372
1440
  define(id: string, def: ItemDef): this;
@@ -1376,14 +1444,12 @@ export interface Inventory {
1376
1444
  count(x: string): number;
1377
1445
  /** Whether there are at least n (default 1) */
1378
1446
  has(x: string, n?: number): boolean;
1379
- /** Slots used */
1380
- readonly slotsUsed: number;
1381
1447
  /** Player inventory entries (for custom UI) */
1382
1448
  list(): ItemEntry[];
1383
- /** One player inventory entry by key, or null */
1384
- get(key: string): ItemEntry | null;
1385
- /** Add n to the player inventory (default 1), opts { data, silent }; returns the entry key, false if it does not fit */
1386
- add(id: string, n?: number, opts?: { data?: Record<string, any>; silent?: boolean }): string | false;
1449
+ /** One player inventory entry by key, or undefined */
1450
+ get(key: string): ItemEntry | undefined;
1451
+ /** Add n to the player inventory (default 1), opts { data, silent }; returns { ok: true, key, added }, or { ok: false, code: 'full' } when none fit */
1452
+ add(id: string, n?: number, opts?: { data?: Record<string, any>; silent?: boolean }): ItemAddResult;
1387
1453
  /** Remove n (default 1) of an item or entry key, returns false if there are not enough */
1388
1454
  remove(x: string, n?: number): boolean;
1389
1455
  /**
@@ -1407,9 +1473,9 @@ export interface Inventory {
1407
1473
  transfer(from: Container | string, to: Container | string, item: string, n?: number): number;
1408
1474
  /** Delete a container together with its contents ('player' cannot be deleted), returns whether one was deleted */
1409
1475
  removeContainer(id: string): boolean;
1410
- /** Every container's items as plain data, the player bag included: { [containerId]: entries } (what setContents takes; net syncs through these two) */
1476
+ /** Every container's items as plain data, the player bag included: { [containerId]: entries } (what setContents takes; net syncs through these two) @experimental */
1411
1477
  contents(): Record<string, any[]>;
1412
- /** Replace containers' items from contents() data, silently like a save load; a null entry empties that container, only: true empties the rest too */
1478
+ /** Replace containers' items from contents() data, silently like a save load; a null entry empties that container, only: true empties the rest too @experimental */
1413
1479
  setContents(data: Record<string, any[] | null>, opts?: { only?: boolean }): void;
1414
1480
  }
1415
1481
  export interface InventoryOptions {
@@ -1421,7 +1487,7 @@ export interface InventoryOptions {
1421
1487
  capacity?: number;
1422
1488
  /** Weight limit of the player inventory, default Infinity */
1423
1489
  maxWeight?: number;
1424
- /** Default stack limit, default 99 */
1490
+ /** Default stack limit, default 99 @experimental */
1425
1491
  defaultStack?: number;
1426
1492
  }
1427
1493
 
@@ -1475,10 +1541,10 @@ export interface Quests {
1475
1541
  state(id: string): { step: number; steps: number; done: boolean; failed: boolean; active: boolean } | null;
1476
1542
  /** Finish the current step from code (its done() is not asked) and go on; the last step completes the quest. false when not active */
1477
1543
  advance(id: string): boolean;
1478
- isDone(id: string): boolean;
1544
+ /** @experimental */ isDone(id: string): boolean;
1479
1545
  /** Started, not done and not failed */
1480
1546
  isActive(id: string): boolean;
1481
- /** Its fail condition held (start(id) begins it again) */
1547
+ /** Its fail condition held (start(id) begins it again) @experimental */
1482
1548
  isFailed(id: string): boolean;
1483
1549
  /** Check completion conditions once immediately */
1484
1550
  check(): void;
@@ -1510,7 +1576,7 @@ export interface QuestLogView {
1510
1576
  export interface QuestsOptions {
1511
1577
  /** Action name that opens the quest log, default 'quests' */
1512
1578
  action?: string;
1513
- /** Check interval (game seconds, checked in the fixed step; not checked while frozen / paused), default 0.5 */
1579
+ /** Check interval (real seconds, checked in the fixed step; not checked while frozen / paused), default 0.5 @experimental */
1514
1580
  checkInterval?: number;
1515
1581
  /**
1516
1582
  * Messages on quest start / step / done: true a toast with kind 'quest' (default) · false none · a function to show them your way.
@@ -1547,7 +1613,7 @@ export interface PhotoTakeOptions {
1547
1613
  format?: string;
1548
1614
  }
1549
1615
  export interface PhotoOptions extends PhotoTakeOptions {
1550
- /** How many photos the album keeps at most, default 50 */
1616
+ /** How many photos the album keeps at most, default 50 @experimental */
1551
1617
  maxAlbum?: number;
1552
1618
  }
1553
1619
  /** engine.photo */
@@ -1556,10 +1622,12 @@ export interface Photo {
1556
1622
  album: PhotoShot[];
1557
1623
  /** The op photo.take's can: return true, or false / a reason string to refuse (e.g. () => engine.inventory.has('film') || 'noFilm') */
1558
1624
  canTake: () => boolean | string;
1559
- scale: number; shadowMapSize: number; bloom: boolean; quality: number; format: string; maxAlbum: number;
1625
+ scale: number; shadowMapSize: number; bloom: boolean; quality: number;
1626
+ /** @experimental */ format: string;
1627
+ /** @experimental */ maxAlbum: number;
1560
1628
  /** Capture a photo now without checks. Gameplay takes photos through the op: engine.ops.run('photo.take') (checks canTake, logged) */
1561
1629
  take(opts?: PhotoTakeOptions): PhotoShot;
1562
- /** What is in the middle of the frame (NPC, entity, named object, vegetation), null if nothing; this is the subject of take() */
1630
+ /** What is in the middle of the frame (NPC, entity, named object, vegetation), null if nothing; this is the subject of take() @experimental */
1563
1631
  subject(): { name: string; kind: string; distance: number } | null;
1564
1632
  }
1565
1633
 
@@ -1672,7 +1740,7 @@ export interface Clock {
1672
1740
  * Call fn after seconds calendar seconds; if an event name is passed, the event is emitted when due (with data, can be saved).
1673
1741
  * { channel } counts that time channel's seconds instead (a poison tick that slows down in bullet time)
1674
1742
  */
1675
- after(seconds: number, fnOrEvent: (() => void) | string, data?: any, opts?: { channel?: string }): Handle;
1743
+ after(seconds: number, fnOrEvent: (() => void) | string, opts?: { data?: any; channel?: string }): Handle;
1676
1744
  /** Call once every seconds calendar seconds ({ channel }: 'real' or a time channel's seconds instead) */
1677
1745
  every(seconds: number, fn: () => void, opts?: { channel?: string }): Handle;
1678
1746
  }
@@ -1721,7 +1789,7 @@ export interface Stack {
1721
1789
  /** End owner's entry; false when it held none */
1722
1790
  release(owner: string, opts?: { id?: string }): boolean;
1723
1791
  }
1724
- /** engine.stacks: every shared point by name ('time.<channel>', 'time.local', 'clock.rate', 'freeze', 'pause', 'camera', 'debug.view', slots, your own) */
1792
+ /** engine.stacks: every shared point by name ('time.<channel>', 'time.local', 'clock.rate', 'freeze', 'halt', 'camera', 'debug.view', slots, your own) */
1725
1793
  export interface Stacks {
1726
1794
  /**
1727
1795
  * Define your own point: kind 'number' (default, base 1), 'value' (any data, set only), 'any' (true while held), 'top' (latest holder wins),
@@ -1739,19 +1807,19 @@ export interface Stacks {
1739
1807
  }
1740
1808
  /** engine.time: time channels (world, player, your own). Speeds change only through engine.mod('time.<channel>', ...) */
1741
1809
  export interface Time {
1742
- /** Define a channel; parent (default 'world') multiplies its speed */
1810
+ /** Define a channel; parent (default 'world') multiplies its speed @experimental */
1743
1811
  channel(name: string, opts?: { parent?: string | null; stack?: string }): Time;
1744
- channels(): string[];
1812
+ /** @experimental */ channels(): string[];
1745
1813
  /** Effective speed: parent x the channel's stack (x the record's 'time.local' stack when id is given) */
1746
1814
  scale(name: string, id?: string): number;
1747
- /** Fixed steps run this playthrough: the one time counter (= engine.tick); every other time is a read-only view of it */
1815
+ /** Fixed steps run this playthrough: the one time counter; every other time is a read-only view of it */
1748
1816
  readonly tick: number;
1749
1817
  /**
1750
1818
  * Seconds on a view: 'real' (tick / 60, no scale, stops while frozen), 'ambient' (= uniforms.uTime, keeps moving while frozen),
1751
1819
  * 'calendar' (= engine.clock.now) or a channel ('world', 'player', your own)
1752
1820
  */
1753
1821
  now(name: 'real' | 'ambient' | 'calendar' | 'world' | 'player' | (string & {})): number;
1754
- /** This fixed step's dt on a channel (1/60 x scale). Change a speed with engine.mod('time.<channel>', { owner, set | mul }); timers: engine.clock.after(s, fn, data, { channel }) */
1822
+ /** This fixed step's dt on a channel (1/60 x scale). Change a speed with engine.mod('time.<channel>', { owner, set | mul }); timers: engine.clock.after(s, fn, data, { channel }) @experimental */
1755
1823
  dt(name: string, id?: string): number;
1756
1824
  }
1757
1825
  /** engine.vars: story flags and counters (autosaved) */
@@ -1762,7 +1830,7 @@ export interface Vars {
1762
1830
  counters: Record<string, number>;
1763
1831
  /** Read a flag */
1764
1832
  flag(key: string): any;
1765
- /** Set a flag (default true) */
1833
+ /** Set a flag (default true) @experimental */
1766
1834
  setFlag(key: string, value?: any): void;
1767
1835
  /** Read a counter (0 if none) */
1768
1836
  counter(key: string): number;
@@ -1814,6 +1882,8 @@ export interface PropDef {
1814
1882
  static?: boolean;
1815
1883
  /** false: never drawn through engine.batching (default: repeated props batch automatically) */
1816
1884
  batch?: boolean;
1885
+ /** true: lower-detail levels far away (`threedog assets optimize --lod`), or rising distances in meters. Collision, rays and saves keep the full model; such a copy is never batched @experimental */
1886
+ lod?: boolean | number[];
1817
1887
  }
1818
1888
  /** engine.content: loads the plain data of the game's content/*.js into the engine */
1819
1889
  export interface Content {
@@ -1843,7 +1913,7 @@ export interface Content {
1843
1913
  */
1844
1914
  template(name: string): Readonly<ContentTemplate>;
1845
1915
  /**
1846
- * The fields one content entry may have (core/params.js spec format): what an editor panel lists and what content-check validates against.
1916
+ * The fields one content entry may have (core/base/params.js spec format): what an editor panel lists and what content-check validates against.
1847
1917
  * name: a template name (placement fields plus its state fields, default = the value in state), an engine entry shape ('props', 'props.template',
1848
1918
  * 'props.grid', 'pickups', 'views'), a game kind that declares fields (content/rules.js kinds), or a world record id. Unknown names throw.
1849
1919
  * @example engine.content.fields('crop').stage // { type: 'int', optional: true, default: 0, min: 0, max: 4 }
@@ -1857,10 +1927,10 @@ export interface Content {
1857
1927
  */
1858
1928
  spawn(name: string, at: any, fields?: { id?: string; rot?: number; scale?: number; y?: number; items?: Record<string, number>; [stateField: string]: any }): WorldRecord;
1859
1929
  }
1860
- /** One stage of a template with stages: a named step it stays in for duration game seconds (clock.now), e.g. seed -> sprout -> ripe, cold -> armed */
1930
+ /** One stage of a template with stages: a named step it stays in for duration calendar seconds (clock.now), e.g. seed -> sprout -> ripe, cold -> armed */
1861
1931
  export interface ContentTemplateStage {
1862
1932
  name: string;
1863
- /** Game seconds spent in this stage; only the last stage may leave it out (it stays there) */
1933
+ /** Calendar seconds spent in this stage; only the last stage may leave it out (it stays there) */
1864
1934
  duration?: number;
1865
1935
  /** Multiplies the instance's scale while in this stage */
1866
1936
  scale?: number;
@@ -1869,7 +1939,7 @@ export interface ContentTemplateStage {
1869
1939
  }
1870
1940
  /** template:stage event: a template instance entered a new stage by growing (several stages crossed at once give one event) */
1871
1941
  export interface TemplateStageEvent { id: string; template: string; stage: number; name: string }
1872
- /** One field of a content entry (engine.content.fields): the core/params.js spec as plain data */
1942
+ /** One field of a content entry (engine.content.fields): the core/base/params.js spec as plain data */
1873
1943
  export interface ContentField {
1874
1944
  type: 'string' | 'number' | 'int' | 'bool' | 'position' | 'id' | 'any' | 'object' | 'array' | 'function';
1875
1945
  optional?: boolean;
@@ -1888,6 +1958,8 @@ export interface ContentTemplate {
1888
1958
  collide?: 'box' | 'circle' | false | { circle: number; occluder?: boolean };
1889
1959
  /** false = not registered for rays */
1890
1960
  static?: boolean;
1961
+ /** true: lower-detail levels far away (`threedog assets optimize --lod`), or rising distances in meters; such copies are never batched @experimental */
1962
+ lod?: boolean | number[];
1891
1963
  /** Interaction: using an instance runs op with { id } */
1892
1964
  interact?: { op: string; label?: string | ((rec: WorldRecord, e: Engine) => string); radius?: number; height?: number; action?: string; enabled?: (rec: WorldRecord, e: Engine) => boolean };
1893
1965
  /** Each instance gets a container with its record id; items = starting goods (placed once) */
@@ -1951,7 +2023,7 @@ export interface FlowTransitionOptions {
1951
2023
  export interface Flow {
1952
2024
  /** Current state name */
1953
2025
  state: string;
1954
- /** A scene transition is in progress */
2026
+ /** A scene transition is in progress @experimental */
1955
2027
  readonly transitioning: boolean;
1956
2028
  /** Define a state (built-in 'playing', 'paused') */
1957
2029
  define(name: string, def: FlowStateDef): this;
@@ -2018,10 +2090,10 @@ export interface Hud {
2018
2090
  markers: HudMarker[];
2019
2091
  /** Add an objective marker: target is an object, position or place name */
2020
2092
  marker(target: HudTarget, opts?: HudMarkerOptions): HudMarker;
2021
- /** Counter or text status (calling again with the same id = update; calling every frame is fine): counter('fish', { label: '鱼', value: 2, max: 5 }), counter('clock', { value: '08:30' }); no value = the label alone */
2093
+ /** Counter or text status (calling again with the same id = update; calling every frame is fine): counter('fish', { label: '鱼', value: 2, max: 5 }), counter('clock', { value: '08:30' }); no value = the label alone, no label = the value alone (the id is not shown) */
2022
2094
  counter(id: string, opts: { label?: string; icon?: string; value?: number | string; max?: number; anchor?: HudAnchor }): void;
2023
2095
  /** Add n (default 1) to a number counter, return the new value; one not declared yet starts at 0 with its id as the label */
2024
- add(id: string, n?: number): number;
2096
+ bump(id: string, n?: number): number;
2025
2097
  /** Current value of a counter or bar (number or text), undefined when there is none; reads what interactions.add({ counter }) has added up */
2026
2098
  value(id: string): number | string | undefined;
2027
2099
  /** Progress bar (calling again with the same id = update; calling every frame is fine, the DOM is untouched when the value is unchanged),