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,16 +4,15 @@
4
4
  // a world coordinate.
5
5
  // Optional floor (reference height on multi-layer ground) and y (meters above that ground): see content.where.
6
6
  import { toast } from '../../ui/UI.js';
7
- import { parseClock } from '../../core/dayTime.js';
8
- import { vegetationModel } from '../../core/namedModel.js';
7
+ import { vegetationModel } from '../../core/assets/namedModel.js';
9
8
  import { addProps, needWorld } from './props.js';
10
9
  import { defineTemplates } from './templates.js';
11
10
  import { srcOf, applyRenames, pickupId } from './ids.js';
12
- import { DEV, warnOnce } from '../../core/validate.js';
13
- import { readParams, keysSchema } from '../../core/params.js';
14
- import { NO_GAME_EFFECTS, contentFiles, kindProblems, unknownContent, list } from './rules.js';
15
- import { codedError, coded } from '../../core/errorHints.js';
16
- import { reportError } from '../../core/errors.js';
11
+ import { DEV, warnOnce } from '../../core/base/validate.js';
12
+ import { readParams, keysSchema } from '../../core/base/params.js';
13
+ import { NO_GAME_EFFECTS, contentFiles, kindProblems, unknownContent } from './rules.js';
14
+ import { codedError, coded } from '../../core/base/errorHints.js';
15
+ import { reportError } from '../../core/base/errors.js';
17
16
 
18
17
  const each = (o, fn) => Object.entries(o || {}).forEach(([k, v]) => fn(k, v));
19
18
  const all = (o, fn) => Object.entries(o || {}).every(([k, n]) => fn(k, n));
@@ -50,10 +49,9 @@ const markerId = raw => raw.id ?? (typeof raw === 'string' ? raw : raw.place ??
50
49
  /**
51
50
  * Load one content pack. c is the merged object of content/index.js (or one pack of a list); api is engine.content; ids is the IdCheck shared by every pack of
52
51
  * this load call (ids.js); st is the content module's load state (shared across repeated load calls):
53
- * { triggers: merged trigger table, subs: listener handles, startOn: quest id -> listener handle, pending: set of model Promises being generated,
54
- * levelPlace(name) }
52
+ * { triggers: merged trigger table, subs: listener handles, startOn: quest id -> listener handle, levelPlace(name) }
55
53
  * Order: vocabulary -> key actions -> vegetation -> items -> containers -> pickups -> NPCs -> dialogues -> quests -> trigger zones -> templates -> props.
56
- * Pickups, props and NPCs are initial world data: the save records only changes and removals, independent of load order (rules at the top of world/World.js).
54
+ * Pickups, props and NPCs are initial world data: the save records only changes and removals, independent of load order (rules at the top of world/persist.js).
57
55
  * Positions that use level markers (not in places) belong to the current level: pickup, prop and NPC data carry a zone (= current level name,
58
56
  * engine.world.zone),
59
57
  * a level change only tears down models and they are rebuilt on return, with taken / moved / removed state intact; trigger zones are not data and are removed
@@ -81,15 +79,15 @@ export function loadContent(e, api, c, st, ids) {
81
79
  // a pack's actions are the game's own (owner 'game'): loading the pack again replaces them, it is not a second binder
82
80
  each(c.actions, (name, a) => e.input.action(name, { label: a.label, keys: a.keys, ...(a.context ? { context: a.context } : {}) }));
83
81
 
84
- // audio: sounds / footsteps by name into engine.audio.config, rules to ambience() / music() (core/audioRules.js). A pack loaded again
82
+ // audio: sounds / footsteps by name into engine.audio.config, rules to ambience() / music() (core/audio/audioRules.js). A pack loaded again
85
83
  // replaces its own rules (hot reload): a named pack by its name, an unnamed one by the data object itself, so loading the same object
86
84
  // twice never stacks its rules (a fresh key per load did); two different unnamed objects both keep theirs
87
85
  if (c.audio) e.audio.contentPack(c.name ? 'pack:' + c.name : c, c.name ? `pack "${c.name}"` : 'pack (no name)', c.audio);
88
86
 
89
- // views: named fixed camera views (core/Views.js); defining a name again replaces it, so a hot reload just works
87
+ // views: named fixed camera views (core/scene/Views.js); defining a name again replaces it, so a hot reload just works
90
88
  each(c.views, (name, v) => e.views.define(name, v));
91
89
 
92
- // vegetation: model names resolve through vegetationModel (models.js, the same resolver vegetation.define uses for a name); register all
90
+ // vegetation: model names resolve through vegetationModel (core/assets/namedModel.js, the same resolver vegetation.define uses for a name); register all
93
91
  // kinds at the same moment once all models are ready
94
92
  // (each registration rebuilds terrain chunks; registering one by one would rebuild several times at start). content's isReady waits for them
95
93
  const veg = [];
@@ -115,7 +113,6 @@ export function loadContent(e, api, c, st, ids) {
115
113
  origin(id, c.pickups, i);
116
114
  });
117
115
 
118
- const hpd = e.calendar?.hoursPerDay ?? 24;
119
116
  each(c.npcs, (id, n) => { // the key in content is the NPC's stable id (used by saves and quest targets)
120
117
  const plan = n.schedule ?? [];
121
118
  ids.claim(id, `npcs.${id}`);
@@ -123,7 +120,7 @@ export function loadContent(e, api, c, st, ids) {
123
120
  // The content form owns start / schedule (clock strings, places) and the id (the key), so those are translated below and not passed as written
124
121
  readParams(`content npcs.${id}`, keysSchema([...e.npcs.optionKeys.filter(k => !['id', 'position', 'zone', 'initial'].includes(k)), 'start']), n);
125
122
  const { start: _s, schedule: _p, ...rest } = n;
126
- e.npcs.add({ ...rest, id, schedule: plan.map(s => ({ at: parseClock(s.at, hpd), position: where(s) })), position: where(n.start || plan[0]), zone: zoneOf(n.start, ...plan), initial: true });
123
+ e.npcs.add({ ...rest, id, schedule: plan.map(s => ({ at: s.at, position: where(s) })), position: where(n.start || plan[0]), zone: zoneOf(n.start, ...plan), initial: true });
127
124
  origin(id, c.npcs, id);
128
125
  });
129
126
 
@@ -162,7 +159,7 @@ export function loadContent(e, api, c, st, ids) {
162
159
  ...(q.fail && { fail: () => api.test(q.fail) }), ...(q.onFail && { onFail: () => api.run(q.onFail) }),
163
160
  });
164
161
  st.startOn.get(id)?.remove(); // loading the same quest again: replace the old listener instead of attaching twice
165
- if (q.startOn) st.startOn.set(id, e.events.on(q.startOn, () => e.quests.start(id)));
162
+ if (q.startOn) st.startOn.set(id, st.track(e.events.on(q.startOn, () => e.quests.start(id))));
166
163
  });
167
164
 
168
165
  // trigger zones: fromLevel = the level's trigger_<tag> marker; otherwise placed by position. Enter/exit effects look up the merged table, and the listener is
@@ -191,7 +188,7 @@ export function loadContent(e, api, c, st, ids) {
191
188
  if (c.props?.length) addProps(e, api, c.props, st, zoneOf, ids);
192
189
 
193
190
  // game kinds last: their data may name the items, NPCs and places loaded above
194
- each(st.kinds, (name, k) => { if (c[name] !== undefined) k.load(e, c[name], api); });
191
+ each(st.kinds, (name, k) => { if (c[name] !== undefined) k.load?.(e, c[name], api); });
195
192
  }
196
193
 
197
194
  /** Op names that content data refers to ({ op: [...] } / { can: [...] } anywhere), checked against engine.ops once the game is ready */
@@ -0,0 +1,25 @@
1
+ // What the marker / clearMarker effects show: playthrough state, kept in the 'content' save part, so a load shows the save's markers and a new game none of the old
2
+ // ones. st.marks holds id -> [position, label]; api.markers holds the hud markers on screen now.
3
+ import { refuseSave } from '../../core/saves/saveValues.js';
4
+
5
+ /** content._mark: set (v = position) or clear (v = null) marker id */
6
+ export function setMark(e, api, st, id, v, label) {
7
+ api.markers.get(id)?.remove(); api.markers.delete(id); st.marks.delete(id);
8
+ if (!v) return;
9
+ st.marks.set(id, [v, label ?? null]);
10
+ const m = e.hud?.marker(v, { label });
11
+ if (m) api.markers.set(id, m);
12
+ }
13
+
14
+ /** The 'content' save part */
15
+ export function marksPart(api, st) {
16
+ return {
17
+ save: () => ({ marks: [...st.marks].map(([id, [v, label]]) => [id, v, label]) }),
18
+ load: d => {
19
+ const marks = d?.marks ?? [];
20
+ if (!Array.isArray(marks) || !marks.every(m => Array.isArray(m) && typeof m[0] === 'string')) refuseSave('content', 'marks', 'must be a list of [id, value, label]', marks);
21
+ for (const id of [...st.marks.keys()]) api._mark(id, null);
22
+ for (const [id, v, label] of marks) api._mark(id, v, label ?? undefined);
23
+ },
24
+ };
25
+ }
@@ -1,39 +1,87 @@
1
- // Models of placed content records: clone the shared prototype of a model name (core/namedModel.js protoOf, the one path every system uses),
1
+ // Models of placed content records: clone the shared prototype of a model name (core/assets/namedModel.js protoOf, the one path every system uses),
2
2
  // align it and its collision to the record (props and template instances).
3
- import { protoOf } from '../../core/namedModel.js';
4
- import { list } from './rules.js';
3
+ import { protoOf } from '../../core/assets/namedModel.js';
4
+ import { wrapLod } from '../../core/assets/assetLod.js';
5
+ import { Vector3 } from 'three';
6
+ import { list } from '../../core/base/util.js';
7
+
8
+ const BASE_BAND = 0.2; // the share of the model's height above the ground that counts as its base
9
+
10
+ /**
11
+ * Where a model stands, in model space, measured once per prototype: { x, z } centre and width of the base (its larger side, so a plain box keeps the same radius).
12
+ * Why this measure: the base is the geometry in the lowest fifth of the height above y = 0 (above its lowest point when it floats), clipped from the triangles, because a crown or an arm starts higher, a tall box has no vertex halfway up and a boulder's belly is what walkers hit.
13
+ * @internal
14
+ */
15
+ export function baseOf(proto) {
16
+ if (proto.base) return proto.base;
17
+ const meshes = [], p = new Vector3();
18
+ let bottom = Infinity, top = -Infinity, instanced = false;
19
+ proto.obj.updateMatrixWorld(true);
20
+ proto.obj.traverse(m => {
21
+ if (!m.isMesh || !m.geometry?.attributes.position) return;
22
+ instanced ||= !!(m.isInstancedMesh || m.isBatchedMesh);
23
+ const pos = m.geometry.attributes.position, at = new Float32Array(pos.count * 3);
24
+ for (let i = 0; i < pos.count; i++) {
25
+ p.fromBufferAttribute(pos, i).applyMatrix4(m.matrixWorld).toArray(at, i * 3);
26
+ bottom = Math.min(bottom, p.y); top = Math.max(top, p.y);
27
+ }
28
+ meshes.push({ at, index: m.geometry.index });
29
+ });
30
+ const low = top > 0 ? Math.max(bottom, 0) : bottom, high = low + (top - low) * BASE_BAND;
31
+ let x0 = Infinity, x1 = -Infinity, z0 = Infinity, z1 = -Infinity;
32
+ const take = (x, z) => { x0 = Math.min(x0, x); x1 = Math.max(x1, x); z0 = Math.min(z0, z); z1 = Math.max(z1, z); };
33
+ const edge = (at, a, b) => {
34
+ const ay = at[a + 1], by = at[b + 1];
35
+ if (ay >= low && ay <= high) take(at[a], at[a + 2]);
36
+ for (const y of [low, high]) if ((ay - y) * (by - y) < 0) { const t = (y - ay) / (by - ay); take(at[a] + (at[b] - at[a]) * t, at[a + 2] + (at[b + 2] - at[a + 2]) * t); }
37
+ };
38
+ for (const { at, index } of meshes) {
39
+ const n = index ? index.count : at.length / 3, v = i => (index ? index.getX(i) : i) * 3;
40
+ for (let i = 0; i + 2 < n; i += 3) { const a = v(i), b = v(i + 1), c = v(i + 2); edge(at, a, b); edge(at, b, c); edge(at, c, a); }
41
+ }
42
+ // shortcut: instanced parts and models without triangles (points, lines, sprites) use the bounding box; measure their instances if a prop ever needs it
43
+ const { size, center } = proto;
44
+ return proto.base = instanced || x0 > x1 ? { x: center.x, z: center.z, width: Math.max(size.x, size.z) }
45
+ : { x: (x0 + x1) / 2, z: (z0 + z1) / 2, width: Math.max(x1 - x0, z1 - z0) };
46
+ }
5
47
 
6
48
  /**
7
49
  * Align a built model and its collision to the record (once when built, again after the record moved or rot / scale changed).
8
- * look = { collide, static } comes from the prop record, or from the template definition for template instances.
50
+ * solid = { collide, static } comes from the prop record, or from the template definition for template instances.
51
+ * A circle stands on the model's base (baseOf); { circle: radius } gives the radius in model meters, so it follows the scale as the model does.
9
52
  * mul: a template stage's scale, multiplied onto the record's own scale (the record keeps only its authored scale). @internal
10
53
  */
11
- export function settle(e, rec, o, look, mul = 1) {
54
+ export function settle(e, rec, o, solid, mul = 1) {
12
55
  const { x, z } = rec.position, rot = rec.rot ?? 0, scale = (rec.scale ?? 1) * mul, ud = o.userData;
13
- ud.fit = fitKey(rec, mul);
56
+ ud.fit = { x, z, rot, scale };
14
57
  rec.position.y = e.surface(x, z, rec.floor) + (rec.offsetY ?? 0);
15
58
  o.position.y = rec.position.y; o.rotation.y = rot; o.scale.setScalar(scale);
16
59
  ud.unstatic?.remove(); ud.unstatic = null;
17
60
  for (const h of ud.colliders.splice(0)) h.remove();
18
- if (look.static !== false && e.rays) { o.updateMatrixWorld(true); ud.unstatic = e.rays.addStatic(o); }
19
- if (!look.collide || !e.collision) return;
20
- const size = ud.proto.size.clone().multiplyScalar(scale), c = ud.proto.center.clone().multiplyScalar(scale);
21
- const cx = x + c.x * Math.cos(rot) + c.z * Math.sin(rot), cz = z - c.x * Math.sin(rot) + c.z * Math.cos(rot);
22
- ud.colliders.push(look.collide === 'circle'
23
- ? e.collision.addCircle({ x: cx, z: cz }, { radius: Math.max(size.x, size.z) / 2, height: size.y })
24
- : e.collision.addBox({ x: cx, z: cz }, { halfWidth: size.x / 2, halfDepth: size.z / 2, rotation: rot, height: size.y }));
61
+ // a solid prop blocks the camera with its whole mesh, not only its footprint collider: crowns and eaves stand outside the footprint, and no game code should have to say so
62
+ const blocks = !!solid.collide && solid.collide.occluder !== false && solid.occluder !== false;
63
+ if (solid.static !== false && e.rays) { o.updateMatrixWorld(true); ud.unstatic = e.rays.addStatic(o, { occluder: blocks }); }
64
+ if (!solid.collide || !e.collision) return;
65
+ const { collide } = solid, set = typeof collide === 'object' ? collide : null, base = set || collide === 'circle' ? baseOf(ud.proto) : null;
66
+ const size = ud.proto.size.clone().multiplyScalar(scale), c = base ?? ud.proto.center, ox = c.x * scale, oz = c.z * scale;
67
+ const cx = x + ox * Math.cos(rot) + oz * Math.sin(rot), cz = z - ox * Math.sin(rot) + oz * Math.cos(rot);
68
+ ud.colliders.push(base
69
+ ? e.collision.addCircle({ x: cx, z: cz }, { radius: (set?.circle ?? base.width / 2) * scale, height: size.y, occluder: blocks })
70
+ : e.collision.addBox({ x: cx, z: cz }, { halfWidth: size.x / 2, halfDepth: size.z / 2, rotation: rot, height: size.y, occluder: blocks }));
25
71
  }
26
- /** What settle last aligned to; update compares it because world.move sends no event @internal */
27
- export const fitKey = (rec, mul = 1) => `${rec.position.x},${rec.position.z},${rec.rot ?? 0},${(rec.scale ?? 1) * mul}`;
72
+ /** Is the model still as settle aligned it? update asks every frame for every built prop, because world.move sends no event: four compares, no text @internal */
73
+ export const fits = (o, rec, mul = 1) => { const f = o.userData.fit, p = rec.position; return f.x === p.x && f.z === p.z && f.rot === (rec.rot ?? 0) && f.scale === (rec.scale ?? 1) * mul; };
28
74
 
29
75
  /** Clone the shared prototype of a model for one record and align it (props and template instances) @internal */
30
- export async function buildModel(e, api, rec, model, look, mul = 1) {
31
- const proto = await protoOf(e, api, model), o = proto.obj.clone(), name = list(model)[0];
76
+ export async function buildModel(e, api, rec, model, solid, mul = 1) {
77
+ const proto = await protoOf(e, api, model), name = list(model)[0], lod = rec.lod ?? solid.lod;
78
+ // settle below measures proto, never o, so collision stays the full model's; the record keeps only the word `lod`, so a save holds no level
79
+ const o = lod ? await wrapLod(e.assets, name, proto.obj.clone(), { distances: Array.isArray(lod) ? lod : undefined, scale: (rec.scale ?? 1) * mul }) : proto.obj.clone();
32
80
  o.name ||= name; o.userData.name ??= name;
33
81
  o.userData.proto = proto; o.userData.colliders = [];
34
82
  if (rec.batch === false) o.userData.batch = false; // opt out of engine.batching for this record
35
83
  o.position.set(rec.position.x, 0, rec.position.z); // world puts the model on the record after build; height and collision are aligned here
36
- settle(e, rec, o, look, mul);
84
+ settle(e, rec, o, solid, mul);
37
85
  return o;
38
86
  }
39
87
  /** Tear down only: geometry and material belong to the shared prototype, the next build clones it again @internal */
@@ -10,9 +10,9 @@
10
10
  // - a pack may carry name: 'forest-dlc' for error messages; no other extra key (unknown keys are errors)
11
11
  // Content references assets by name only: a model written as a file path or a function is reported here in dev (the static check is
12
12
  // npm run check -> content-check, packages/tools/content-check/world.mjs).
13
- import { DEV, warnOnce, fmt } from '../../core/validate.js';
14
- import { codedError } from '../../core/errorHints.js';
15
- import { isPlainObject } from '../../core/util.js';
13
+ import { DEV, warnOnce, fmt } from '../../core/base/validate.js';
14
+ import { codedError } from '../../core/base/errorHints.js';
15
+ import { isPlainObject } from '../../core/base/util.js';
16
16
 
17
17
  const STRINGS = {
18
18
  dup: 'content.load: {key}.{id} is defined by both {a} and {b}. Packs loaded together may not share an id: rename one, or drop it from one pack',
@@ -4,8 +4,8 @@
4
4
  // gets its position in the joined array as id, and content check, write-back and the game must agree on it), and the dev line table must keep
5
5
  // naming the right file ("defined in content/props/town.js:14").
6
6
  // content/index.js: const props = contentParts(import.meta.glob('./props/*.js', { eager: true }));
7
- import { DEV } from '../../core/validate.js';
8
- import { codedError } from '../../core/errorHints.js';
7
+ import { DEV } from '../../core/base/validate.js';
8
+ import { codedError } from '../../core/base/errorHints.js';
9
9
 
10
10
  /**
11
11
  * Join the modules of one content folder into one array / object (what a single content/<kind>.js would export).
@@ -0,0 +1,35 @@
1
+ // Places in content: named positions (a pack's places file, the places option, level markers) and the position notation { place?, x?, z?, floor?, y? }.
2
+ // api is engine.content: where and offset read a place through api.place, so a wrapped place is the one they use.
3
+ import { placeY } from '../../core/scene/ground.js';
4
+ import { codedError } from '../../core/base/errorHints.js';
5
+
6
+ /** content.load: add the packs' places, then the places option on top. A text entry in a place file waits for the option */
7
+ export function addPlaces(places, packs, given) {
8
+ const pl = {};
9
+ for (const p of packs) for (const [name, at] of Object.entries(p.places ?? {})) if (at && typeof at === 'object') pl[name] = at;
10
+ Object.assign(pl, given);
11
+ for (const [name, p] of Object.entries(pl)) if (p?.rot !== undefined && !Number.isFinite(p.rot)) throw codedError('content-place', `Place "${name}": rot must be a number of radians about Y, got ${JSON.stringify(p.rot)}`);
12
+ Object.assign(places, pl);
13
+ }
14
+
15
+ /** content.place */
16
+ export function placeOf(e, places, name) {
17
+ const p = places[name] ?? e.level?.marker(name)?.position;
18
+ return p ? { x: p.x, z: p.z, ...(p.y !== undefined && { y: p.y }), ...(p.rot !== undefined && { rot: p.rot }) } : null;
19
+ }
20
+
21
+ /** content.offset */
22
+ export function offsetFrom(api, place, x, z) {
23
+ const base = place ? api.place(place) : null, dx = x - (base?.x ?? 0), dz = z - (base?.z ?? 0), c = Math.cos(base?.rot ?? 0), s = Math.sin(base?.rot ?? 0);
24
+ return { x: dx * c - dz * s, z: dx * s + dz * c };
25
+ }
26
+
27
+ /** content.where */
28
+ export function whereOf(e, api, p) {
29
+ const base = p.place ? api.place(p.place) : null;
30
+ if (p.place && !base) throw codedError('content-place', `Place "${p.place}" not found: give its coordinates in the places of content.load, or add this marker to the level`);
31
+ const ox = p.x ?? 0, oz = p.z ?? 0, c = Math.cos(base?.rot ?? 0), s = Math.sin(base?.rot ?? 0);
32
+ const x = (base?.x ?? 0) + ox * c + oz * s, z = (base?.z ?? 0) - ox * s + oz * c, floor = p.floor ?? base?.y;
33
+ if (floor === undefined && p.y === undefined) return { x, z };
34
+ return { x, y: placeY(e, `content.where(${JSON.stringify(p.place ?? { x: p.x, z: p.z })})`, x, z, floor) + (p.y ?? 0), z };
35
+ }
@@ -1,6 +1,7 @@
1
1
  // Props (each item of content/props.js): data is a plain record in engine.world with kind 'prop'; model and collision are "presentation that exists only when
2
2
  // near".
3
- // record: { id, kind: 'prop', position: {x,y,z}, model, rot?, scale?, collide?, offsetY?, static?, batch?, zone? } (plain values only)
3
+ // record: { id, kind: 'prop', position: {x,y,z}, model, rot?, scale?, collide?, occluder?, offsetY?, static?, batch?, source?, zone? } (plain values only)
4
+ // rot = the entry's rot plus its place's. source names the arrangement an entry was copied from: a tag for world.query, nothing at runtime reads it.
4
5
  // Initial world data (initial: true on add): the save records only moves / removals, independent of content.load running before or after loading a save;
5
6
  // positions using level markers carry a zone (data is kept across level changes).
6
7
  // id: the written id if content gives one; otherwise `prop:<model name>:<index in this props array>` (same on every load of the same content, no collisions).
@@ -12,14 +13,14 @@
12
13
  // collision: built / torn down with the model (only things near the player need to block), so props beyond the collision radius take no space in the collision
13
14
  // table.
14
15
  // An entry with template (instead of model) is an instance of a content template: see templates.js.
15
- import { buildModel, settle, fitKey, unbuildModel } from './models.js';
16
+ import { buildModel, settle, fits, unbuildModel } from './models.js';
16
17
  import { placeTemplate } from './templates.js';
17
18
  import { srcOf } from './ids.js';
18
- import { placeY } from '../../core/ground.js';
19
- import { list, PLACEMENT_FIELDS } from './rules.js';
20
- import { DEV, fmt, closest } from '../../core/validate.js';
21
- import { codedError } from '../../core/errorHints.js';
22
-
19
+ import { placeY } from '../../core/scene/ground.js';
20
+ import { PLACEMENT_FIELDS, collideProblem } from './rules.js';
21
+ import { list } from '../../core/base/util.js';
22
+ import { DEV, fmt, closest } from '../../core/base/validate.js';
23
+ import { codedError } from '../../core/base/errorHints.js';
23
24
 
24
25
  /** Stable id of a prop: the written id if given, otherwise "model name + array index" */
25
26
  const propId = (p, i) => p.id ?? `prop:${list(p.model)[0]}:${i}`;
@@ -35,16 +36,20 @@ export function addProps(e, api, props, st, zoneOf, ids) {
35
36
  const at = DEV ? srcOf(props, i) : null;
36
37
  if (p.template) return placeTemplate(e, api, st, p, i, zoneOf(p), ids, at); // an instance of a content template (templates.js), not a plain prop
37
38
  if (p.grid) return placeGridItem(e, p, i, zoneOf(p), ids, at); // a pre-placed grid item (grid module)
39
+ const collide = collideProblem(p.collide);
40
+ if (collide) throw codedError('content-misuse', `props[${i}] (model ${JSON.stringify(p.model)}): collide ${collide}`);
38
41
  const id = propId(p, i), { x, y, z } = api.where(p), zone = zoneOf(p), floor = api._floorOf(p);
39
42
  if (p.id != null) ids.claim(p.id, `props[${i}] (model ${JSON.stringify(p.model)})`);
40
43
  // compute y from the ground now (same as when the model is built): unmoved props equal the content and stay out of the save
41
44
  const def = { id, kind: 'prop', position: { x, y: y ?? placeY(e, `props[${i}] (model ${JSON.stringify(p.model)})`, x, z), z }, model: p.model };
42
- for (const k of ['rot', 'scale', 'collide', 'static', 'batch']) if (p[k] !== undefined) def[k] = p[k];
45
+ for (const k of ['scale', 'collide', 'occluder', 'static', 'batch', 'lod', 'source']) if (p[k] !== undefined) def[k] = p[k];
46
+ const rot = api._facingOf(p);
47
+ if (rot !== undefined) def.rot = rot;
43
48
  if (p.y) def.offsetY = p.y;
44
49
  if (floor !== undefined) def.floor = floor; // kept so a moved prop lands on the same storey
45
50
  if (zone != null) def.zone = zone;
46
51
  const rec = world.add(def, { initial: true });
47
- if (rec && (rec.kind !== 'prop' || JSON.stringify(rec.model) !== JSON.stringify(p.model))) throw codedError('pickup-prop-id', `Prop id "${id}" is already used by other data (${rec.kind}${rec.model ? ' ' + JSON.stringify(rec.model) : ''}): give this item a different id, e.g. { id: '${id}-2', model: ... }`);
52
+ if (rec && (rec.kind !== 'prop' || JSON.stringify(rec.model) !== JSON.stringify(p.model))) throw codedError('world-id', `Prop id "${id}" is already used by other data (${rec.kind}${rec.model ? ' ' + JSON.stringify(rec.model) : ''}): give this item a different id, e.g. { id: '${id}-2', model: ... }`);
48
53
  if (DEV) world.setOrigin(id, { definedAt: at, model: p.model });
49
54
  });
50
55
  }
@@ -71,13 +76,13 @@ function placeGridItem(e, p, i, zone, ids, at) {
71
76
  ids.claim(p.id, `props[${i}] (grid ${p.grid} item ${p.item})`);
72
77
  const { kind, fields } = e.grids.placement(p.grid, p.item, p.cell, p.rotation ?? 0);
73
78
  const rec = e.world.add({ id: p.id, kind, ...fields, ...structuredClone(p.fields ?? {}), ...(zone != null && { zone }) }, { initial: true });
74
- if (rec && rec.kind !== kind) throw codedError('pickup-prop-id', `grid item id "${p.id}" is already used by other data (kind ${rec.kind}): give it a different id`);
79
+ if (rec && rec.kind !== kind) throw codedError('world-id', `grid item id "${p.id}" is already used by other data (kind ${rec.kind}): give it a different id`);
75
80
  if (DEV) e.world.setOrigin(p.id, { definedAt: at });
76
81
  }
77
82
 
78
83
  /** Dev error when the world module is not installed */
79
84
  export function needWorld(e) {
80
- if (!e.world) throw codedError('world-missing', 'content has props or pickups, whose data is stored in world: call engine.use(world()) first (the openWorld() preset already installs it)');
85
+ if (!e.world) throw codedError('module-needs', 'content has props or pickups, whose data is stored in world: call engine.use(world()) first (the openWorld() preset already installs it)');
81
86
  return e.world;
82
87
  }
83
88
 
@@ -85,12 +90,12 @@ export function needWorld(e) {
85
90
  function presentProps(e, api, world, st) {
86
91
  if (st.propsPresenter) return;
87
92
 
88
- st.propsPresenter = world.present('prop', {
93
+ st.propsPresenter = st.track(world.present('prop', {
89
94
  // build by view distance: follows the terrain view distance (fog distance if no terrain), also when changed at runtime
90
95
  radius: () => Math.max(world.radius, e.stream.activeRadius),
91
96
  build: rec => buildModel(e, api, rec, rec.model, rec), // a failed model generation is reported by world (does not block loading), retried when near again
92
97
  // moved / rot or scale changed (world.move sends no event, so compare here): world already put the model at the new position; collision and rays follow
93
- update(rec, o) { if (o.userData.fit !== fitKey(rec)) settle(e, rec, o, rec); },
98
+ update(rec, o) { if (!fits(o, rec)) settle(e, rec, o, rec); },
94
99
  dispose: (rec, o) => unbuildModel(e, o),
95
- });
100
+ }));
96
101
  }
@@ -1,5 +1,5 @@
1
1
  // Content vocabulary: the "conditions" and "effects" that content files (content/*.js) can use. Shared by the loader, the validator packages/tools/content-check.mjs and the map packages/tools/gamemap.mjs.
2
- // Plain data + small functions, no import of three or the engine (the validator reads it directly in node). Real execution is in loader.js.
2
+ // Plain data + small functions, no import of three and nothing from the engine but node-safe core/base/util.js (the validator reads it directly in node). Real execution is in loader.js.
3
3
  //
4
4
  // Conditions (quest step done, dialogue option if, line variant if): several items in one object must all hold; array = every item holds
5
5
  // { flag: 'metFisher' } { notFlag: 'x' } { has: { berry: 3 } } { lacks: { film: 6 } } { counter: { sunsetPhotos: 1 } }
@@ -19,14 +19,16 @@
19
19
  //
20
20
  // Game content kinds: the same content/rules.js may export kinds: { name: { desc, load, check, map } }, so a game keeps its own data
21
21
  // (enemies, recipes, loot tables, waves, shop stock) in content/<name>.js. The loader, content-check and GAMEMAP all read this one table:
22
- // desc one line (map, file list) · load(e, data, content) hands the data to the game when engine.content.load runs (required)
22
+ // desc one line (map, file list) · load(e, data, content) hands the data to the game when engine.content.load runs (optional: a game that imports the file itself needs none)
23
23
  // check(data, ctx) optional validation in npm run check: ctx.err(msg) / ctx.warn(msg); ctx.data is all content (items, npcs…), ctx.known(obj) lists ids
24
24
  // map(data) optional GAMEMAP lines (default: the number of entries and their ids)
25
- // fields optional { key: 'int?' | { type, min, max, values, desc } } (core/params.js format, no default): the keys of each entry; content-check
25
+ // fields optional { key: 'int?' | { type, min, max, values, desc } } (core/base/params.js format, no default): the keys of each entry; content-check
26
26
  // reports unknown keys (did you mean), wrong types, out of range, and missing required keys; engine.content.fields(name) returns it
27
27
  // export default { kinds: { recipes: { desc: 'crafting recipes (id -> { needs: { item: n }, makes })', load: (e, data) => e.crafting.add(data),
28
28
  // check: (data, ctx) => { for (const [id, r] of Object.entries(data)) if (!ctx.data.items?.[r.makes]) ctx.err(`recipe ${id} makes unknown item ${r.makes}`); } } } };
29
29
 
30
+ import { list, isObject } from '../../core/base/util.js';
31
+
30
32
  const counts = o => Object.entries(o || {}).map(([k, n]) => `${k}×${n}`).join('、');
31
33
  const opText = v => Array.isArray(v) ? `${v[0]}${v[1] ? ' ' + Object.entries(v[1]).map(([k, x]) => `${k}=${x}`).join(' ') : ''}` : String(v);
32
34
  const posText = v => typeof v === 'string' ? v : v.place ? `${v.place}${v.x || v.z ? `(${v.x ?? 0},${v.z ?? 0})` : ''}` : `(${v.x},${v.z})`;
@@ -49,7 +51,8 @@ const RULE_STRINGS = {
49
51
  toast: { ref: 'text', desc: 'show a toast', describe: v => `toast "${v}"` },
50
52
  particles: { ref: 'particles', desc: 'play particles', describe: v => `particles ${v.name}×${v.count ?? ''}` },
51
53
  marker: { ref: 'position', desc: 'add an objective marker (hud module)', describe: v => `marker ${posText(v)}${v.label ? `"${v.label}"` : ''}` },
52
- clearMarker: { ref: 'position', desc: 'remove an objective marker', describe: v => `remove marker ${posText(v)}` },
54
+ // raw: the value names the marker (content-check still reads it as a place); a place that is gone, on a level left behind, must not stop the clearing
55
+ clearMarker: { ref: 'position', raw: true, desc: 'remove an objective marker', describe: v => `remove marker ${posText(v)}` },
53
56
  op: { ref: 'op', desc: "run a game op (engine.ops.run); the game's own actions are ops", describe: v => `op ${opText(v)}` },
54
57
  },
55
58
  // content file name -> description (only these files are recognized in content/)
@@ -57,13 +60,13 @@ const RULE_STRINGS = {
57
60
  items: 'items (id -> name, icon, description); also export startItems for starting items',
58
61
  pickups: 'pickups on the ground (list)',
59
62
  containers: 'chests / shelves (container id -> { capacity, items: starting goods }; starting goods are placed only the first time, then saved)',
60
- npcs: 'NPCs (id -> name, schedule, dialogue)',
63
+ npcs: 'NPCs (id -> name, schedule, interact)',
61
64
  dialogues: 'dialogues (id -> speaker, nodes)',
62
65
  quests: 'quests (id -> title, steps, reward; a step can have a target position)',
63
66
  actions: 'own key actions of the game (action name -> default key, label)',
64
- places: 'place names (coordinates computed at runtime in main.js)',
67
+ places: 'place names (name -> { x, z, y?, rot? }; rot turns everything placed there about Y; coordinates may be computed at runtime in main.js)',
65
68
  triggers: 'trigger zones (tag -> position / from level, enter/exit effects)',
66
- level: 'level markers (spawn point, NPCs, trigger zones)',
69
+ level: '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',
67
70
  vegetation: 'vegetation (name -> model, growth rule)',
68
71
  props: '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',
69
72
  templates: 'reusable objects (name -> model, collide, interact, container, sound, animate, state defaults, physics body); shared read-only definitions',
@@ -71,36 +74,40 @@ const RULE_STRINGS = {
71
74
  views: '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',
72
75
  grids: 'placement grids (name -> { cell, origin, size, zone?, flat? }); layout rules, not saved',
73
76
  renames: "renamed or deleted authored ids (old id -> new id, or null = deleted on purpose): the player's saved changes follow the new id",
74
- rules: 'condition words added by the game ({ conditions }); actions are ops, not effect words',
77
+ rules: 'condition words and data kinds added by the game ({ conditions, kinds }); actions are ops, not effect words',
75
78
  },
76
- // Placement fields: the keys one entry of a content file may have, in the core/params.js spec format. Declared once here, read by the loader
79
+ // Placement fields: the keys one entry of a content file may have, in the core/base/params.js spec format. Declared once here, read by the loader
77
80
  // (unknown keys), content-check (unknown keys with did-you-mean, wrong type, out of range, not in values) and engine.content.fields() (an editor
78
81
  // panel's rows), so the three cannot drift apart. props has three entry shapes: a plain model ('props'), a template instance ('props.template',
79
82
  // plus the template's state fields) and a grid item ('props.grid'). Required-ness of x / z / model is checked by the content rules themselves
80
83
  // (x, z are optional when place is given), so they are marked optional here.
81
84
  fields: (() => {
82
85
  const at = {
83
- place: { type: 'string', optional: true, desc: 'place name (places.js / level marker); x and z are then offsets from it' },
86
+ place: { type: 'string', optional: true, desc: "place name (places.js / level marker); x and z are then offsets from it and turn with the place's rot" },
84
87
  x: { type: 'number', optional: true, desc: 'meters along x (offset from place when place is given)' },
85
88
  z: { type: 'number', optional: true, desc: 'meters along z (offset from place when place is given)' },
86
89
  floor: { type: 'number', optional: true, desc: 'reference height of the storey it stands on (multi-layer ground)' },
87
90
  y: { type: 'number', optional: true, desc: 'meters above the ground it stands on' },
88
91
  };
89
- const look = {
92
+ const pose = {
90
93
  rot: { type: 'number', optional: true, desc: 'facing around the vertical axis, radians' },
91
94
  scale: { type: 'number', optional: true, min: 0, desc: 'uniform scale (1 = model size)' },
92
95
  };
96
+ // a plain tag, so world.query({ where: r => r.source === 'stall' }) finds every copy of one arrangement; nothing else reads it
97
+ const copied = { source: { type: 'string', optional: true, desc: 'name of the arrangement this entry was copied from; queryable, no other effect' } };
93
98
  return {
94
99
  props: {
95
100
  id: { type: 'string', optional: true, desc: 'stable id (needed when entries are later inserted in the middle)' },
96
- model: { type: 'any', desc: "model name, or [name, ...args] for a generated model" }, ...at, ...look,
97
- collide: { type: 'any', optional: true, values: [false, 'box', 'circle'], desc: 'collision shape, false = none' },
101
+ model: { type: 'any', desc: "model name, or [name, ...args] for a generated model" }, ...at, ...pose, ...copied,
102
+ collide: { type: 'any', optional: true, desc: "collision: 'box', 'circle', { circle: radius, occluder?: false }, or false = none" },
103
+ occluder: { type: 'bool', optional: true, desc: 'false = a solid prop the follow camera may pass through (walkers are still stopped)' },
98
104
  static: { type: 'bool', optional: true, desc: 'never moves (may be merged into one draw call)' },
99
105
  batch: { type: 'bool', optional: true, desc: 'false = never batch this copy' },
106
+ lod: { type: 'any', optional: true, desc: 'true = lower-detail levels far away (threedog assets optimize --lod), or rising distances in meters like [40, 120]; such a copy is never batched' },
100
107
  },
101
108
  'props.template': {
102
109
  template: { type: 'string', desc: 'template name (content/templates.js)' },
103
- id: { type: 'string', optional: true, desc: 'stable id; instances with state should have one' }, ...at, ...look,
110
+ id: { type: 'string', optional: true, desc: 'stable id; instances with state should have one' }, ...at, ...pose, ...copied,
104
111
  items: { type: 'object', optional: true, desc: "starting goods of the instance's container { itemId: count }" },
105
112
  },
106
113
  'props.grid': {
@@ -145,8 +152,15 @@ export const EFFECTS = RULE_STRINGS.effects;
145
152
  export const REFS = RULE_STRINGS.refs;
146
153
  /** content file name -> description */
147
154
  export const CONTENT_FILES = RULE_STRINGS.files;
148
- /** content entry shape -> { key: field spec } (core/params.js format): 'props', 'props.template', 'props.grid', 'pickups', 'views'. Read via fields.js */
155
+ /** content entry shape -> { key: field spec } (core/base/params.js format): 'props', 'props.template', 'props.grid', 'pickups', 'views'. Read via fields.js */
149
156
  export const PLACEMENT_FIELDS = RULE_STRINGS.fields;
157
+ /** Why a prop's or template's `collide` is wrong, or null. One rule for the load and content-check: a mistyped object must not quietly become a box */
158
+ export function collideProblem(v) {
159
+ if (v === undefined || v === false || v === 'box' || v === 'circle') return null;
160
+ const form = isObject(v) && Object.keys(v).every(k => k === 'circle' || k === 'occluder');
161
+ if (form && Number.isFinite(v.circle) && v.circle > 0 && (v.occluder === undefined || typeof v.occluder === 'boolean')) return null;
162
+ return `must be one of false, "box", "circle" or { circle: radius in meters above 0, occluder?: false }, got ${JSON.stringify(v)}`;
163
+ }
150
164
  /** Clock time notation 'HH:MM' (24-hour) */
151
165
  export const CLOCK_RE = /^([01]\d|2[0-3]):[0-5]\d$/;
152
166
 
@@ -160,22 +174,20 @@ export function contentFiles(game = {}) {
160
174
  for (const [name, k] of Object.entries(game?.kinds || {})) out[name] ??= k?.desc || 'game data kind';
161
175
  return out;
162
176
  }
163
- /** Problems with a game's kinds table (name clashes with an engine file, no load): a list of messages */
177
+ /** Problems with a game's kinds table (name clashes with an engine file, a load that is no function): a list of messages */
164
178
  export function kindProblems(game = {}) {
165
179
  return Object.entries(game?.kinds || {}).flatMap(([name, k]) => [
166
180
  ...(CONTENT_FILES[name] || name === 'startItems' ? [`kind "${name}" is an engine content file name: pick another name (engine files: ${Object.keys(CONTENT_FILES).join(', ')})`] : []),
167
- ...(typeof k?.load !== 'function' ? [`kind "${name}" has no load(e, data) function, so its data would never reach the game`] : []),
181
+ ...(k?.load !== undefined && typeof k.load !== 'function' ? [`kind "${name}": load must be a function (e, data) => …, or left out when the game imports the file itself`] : []),
168
182
  ]);
169
183
  }
170
184
  /** Error text for a content name that is neither an engine file nor a registered kind */
171
185
  export const unknownContent = (name, game) => `unknown content "${name}". Known: ${Object.keys(contentFiles(game)).join(', ')}. `
172
- + `For the game's own data, register it in content/rules.js: export default { kinds: { ${name}: { desc: '…', load: (e, data) => { … } } } }`;
173
- /** Error text when a game's content/rules.js still exports effects */
174
- export const NO_GAME_EFFECTS = "content/rules.js: games no longer add effect words. Register the action as an op (engine.ops.define('noun.verb', { can, run }) in main.js) "
186
+ + `For the game's own data, register it in content/rules.js: export default { kinds: { ${name}: { desc: '…', load: (e, data) => { … } } } }, and list \`rules\` in content/index.js too: the loader only knows what it is handed`;
187
+ /** Error text for an effects key in a game's content/rules.js */
188
+ export const NO_GAME_EFFECTS = "content/rules.js: effects is not a key here. Register the action as an op (engine.ops.define('noun.verb', { can, run }) in main.js) "
175
189
  + "and call it from content with { op: ['noun.verb', { args }] }; see recipes/23-ops.md";
176
190
 
177
- /** Wrap a single value into an array (a model written as 'tree' or ['tree', ...args]); the one copy for the content files @param {any} v @returns {any[]} */
178
- export const list = v => (Array.isArray(v) ? v : [v]);
179
191
  const say = (vocab, x) => Object.entries(x).map(([k, v]) => vocab[k]?.describe?.(v) ?? `${k} ${JSON.stringify(v)}`);
180
192
 
181
193
  /** Describe a condition as one human-readable sentence (for the map); vocab defaults to the engine vocabulary */
@@ -5,15 +5,15 @@
5
5
  // canGrow: (rec, e) => rec.watered }
6
6
  // Why the stage lives on the record and not on a separate registry: the record is what world saves, what content-check / content.fields() describe
7
7
  // and what the editor edits, so `stage` is an ordinary state field (default 0, range 0..n-1) and `stageAt` (engine.clock.now when it entered the stage)
8
- // sits beside it. Growth is counted in game seconds (clock.now), so a far record, a loaded save or a time skip all catch up in one pass.
8
+ // sits beside it. Growth is counted in calendar seconds (clock.now), so a far record, a loaded save or a time skip all catch up in one pass.
9
9
  // Node-safe (no three): content-check imports this file directly, so the engine and the check accept the same stages.
10
- import { closest } from '../../core/validate.js';
10
+ import { closest } from '../../core/base/validate.js';
11
+ import { isModelName } from '../../core/base/util.js';
11
12
 
12
13
  const STAGE_KEYS = ['name', 'duration', 'scale', 'model'];
13
- const isModel = m => typeof m === 'string' || (Array.isArray(m) && typeof m[0] === 'string');
14
14
 
15
15
  /**
16
- * Problems of a template's stages list (empty list = fine). Every stage but the last needs a duration (game seconds spent there); the last may omit it
16
+ * Problems of a template's stages list (empty list = fine). Every stage but the last needs a duration (calendar seconds spent there); the last may omit it
17
17
  * (stays there). model is a model name like the template's own model (no functions: stages are data an editor can show and content-check can read).
18
18
  * @param {string} where e.g. "template 'crop'"
19
19
  * @param {any} stages
@@ -37,12 +37,12 @@ export function stagesProblems(where, stages) {
37
37
  else if (names.has(s.name)) out.push(`${at}: name '${s.name}' is used by an earlier stage; stage names must differ`);
38
38
  else names.add(s.name);
39
39
  const last = i === stages.length - 1;
40
- if (s.duration === undefined) { if (!last) out.push(`${at} needs duration (game seconds spent in this stage); only the last stage may leave it out`); }
41
- else if (!Number.isFinite(s.duration) || s.duration <= 0) out.push(`${at}: duration must be a positive number of game seconds, got ${JSON.stringify(s.duration)}`);
40
+ if (s.duration === undefined) { if (!last) out.push(`${at} needs duration (calendar seconds spent in this stage); only the last stage may leave it out`); }
41
+ else if (!Number.isFinite(s.duration) || s.duration <= 0) out.push(`${at}: duration must be a positive number of calendar seconds, got ${JSON.stringify(s.duration)}`);
42
42
  if (s.scale !== undefined && (!Number.isFinite(s.scale) || s.scale <= 0)) {
43
43
  out.push(`${at}: scale must be a positive number (multiplies the instance scale), got ${JSON.stringify(s.scale)}`);
44
44
  }
45
- if (s.model !== undefined && !isModel(s.model)) out.push(`${at}: model must be a model name (like the template's model), got ${JSON.stringify(s.model)}`);
45
+ if (s.model !== undefined && !isModelName(s.model)) out.push(`${at}: model must be a model name (like the template's model), got ${JSON.stringify(s.model)}`);
46
46
  });
47
47
  return out;
48
48
  }