threedog 0.5.0 → 0.7.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 (511) hide show
  1. package/CHANGELOG.md +81 -1
  2. package/README.md +21 -13
  3. package/core/Assets.js +23 -12
  4. package/core/Audio.js +1 -1
  5. package/core/Baked.js +14 -23
  6. package/core/Budget.js +2 -2
  7. package/core/DebugOverrides.js +33 -18
  8. package/core/Describe.js +10 -11
  9. package/core/Engine.js +50 -46
  10. package/core/I18n.js +2 -2
  11. package/core/Input.js +11 -5
  12. package/core/Inspect.js +6 -3
  13. package/core/InspectMaterials.js +2 -3
  14. package/core/InspectPerf.js +11 -4
  15. package/core/MaterialInfo.js +7 -5
  16. package/core/Rays.js +7 -2
  17. package/core/Stream.js +2 -3
  18. package/core/UrlState.js +49 -9
  19. package/core/Views.js +1 -0
  20. package/core/adaptive.js +2 -2
  21. package/core/assetEntry.js +5 -2
  22. package/core/assetLoad.js +13 -15
  23. package/core/assetManifest.js +6 -3
  24. package/core/assetReport.js +4 -4
  25. package/core/batchGroups.js +9 -1
  26. package/core/catalog.js +16 -3
  27. package/core/chunkStream.js +1 -1
  28. package/core/copies.js +1 -1
  29. package/core/debugView.js +4 -4
  30. package/core/describeRender.js +104 -28
  31. package/core/describeText.js +6 -6
  32. package/core/errorCodes.js +72 -45
  33. package/core/errorHints.js +4 -1
  34. package/core/errors.js +4 -4
  35. package/core/events.generated.js +1 -0
  36. package/core/gameLights.js +9 -2
  37. package/core/lifecycle.js +2 -4
  38. package/core/lightWatch.js +5 -3
  39. package/core/loop.js +18 -11
  40. package/core/math.js +7 -0
  41. package/core/moduleSlots.js +32 -7
  42. package/core/moduleTypes.js +20 -7
  43. package/core/modules.js +7 -7
  44. package/core/namedModel.js +8 -4
  45. package/core/owned.js +33 -30
  46. package/core/page.js +43 -10
  47. package/core/pictureSlots.js +33 -0
  48. package/core/pictureWriters.js +343 -0
  49. package/core/plugins.js +64 -96
  50. package/core/sceneDelta.js +12 -4
  51. package/core/sceneMethods.js +2 -9
  52. package/core/services.js +1 -1
  53. package/core/shadowTypes.js +1 -1
  54. package/core/shadows.js +405 -0
  55. package/core/sharedPoint.js +5 -19
  56. package/core/stackFrames.js +16 -5
  57. package/core/stacks.js +6 -6
  58. package/core/startup.js +9 -11
  59. package/core/thingExplain.js +1 -1
  60. package/core/things.js +1 -1
  61. package/core/tier.js +1 -1
  62. package/core/util.js +1 -1
  63. package/core/validate.js +1 -1
  64. package/core/view.js +43 -0
  65. package/docs/AI.md +62 -58
  66. package/docs/API.md +15 -15
  67. package/docs/CODEMAP.md +36 -54
  68. package/docs/COMMANDS.md +28 -25
  69. package/docs/CONVENTIONS.md +36 -30
  70. package/docs/MIGRATING-0.4.md +93 -1
  71. package/docs/MIGRATING-0.6.md +126 -0
  72. package/docs/MIGRATING-0.7.md +39 -0
  73. package/docs/THREE.md +24 -22
  74. package/docs/api/assets.md +5 -3
  75. package/docs/api/audio.md +2 -2
  76. package/docs/api/budget.md +4 -0
  77. package/docs/api/characters.md +3 -1
  78. package/docs/api/collision.md +2 -2
  79. package/docs/api/engine.md +47 -20
  80. package/docs/api/events.md +2 -1
  81. package/docs/api/grids.md +8 -1
  82. package/docs/api/ground.md +1 -1
  83. package/docs/api/hud.md +3 -0
  84. package/docs/api/input.md +3 -2
  85. package/docs/api/interactions.md +3 -1
  86. package/docs/api/inventory.md +1 -2
  87. package/docs/api/level.md +0 -1
  88. package/docs/api/lightPool.md +1 -1
  89. package/docs/api/occlusion.md +5 -0
  90. package/docs/api/particles.md +6 -3
  91. package/docs/api/pickups.md +6 -0
  92. package/docs/api/post.md +5 -3
  93. package/docs/api/sky.md +12 -10
  94. package/docs/api/terrain.md +12 -6
  95. package/docs/api/terrainDraw.md +12 -0
  96. package/docs/api/tools.md +8 -7
  97. package/docs/api/triggers.md +2 -0
  98. package/docs/api/vegetation.md +7 -2
  99. package/docs/api/vegetationDraw.md +10 -0
  100. package/docs/api/water.md +6 -2
  101. package/docs/api/weather.md +5 -0
  102. package/docs/api/weatherDraw.md +10 -0
  103. package/docs/api/world.md +1 -1
  104. package/docs/recipes/01-new-game.md +19 -23
  105. package/docs/recipes/03-items-pickups.md +25 -4
  106. package/docs/recipes/05-props-bake.md +53 -37
  107. package/docs/recipes/06-clock-events.md +3 -3
  108. package/docs/recipes/07-flow-scenes-pause.md +12 -3
  109. package/docs/recipes/08-weather-sky.md +45 -57
  110. package/docs/recipes/09-materials-lights-models.md +185 -0
  111. package/docs/recipes/10-blender-level.md +2 -2
  112. package/docs/recipes/11-vehicles.md +3 -3
  113. package/docs/recipes/13-animation.md +13 -7
  114. package/docs/recipes/14-custom-module.md +7 -5
  115. package/docs/recipes/15-perf.md +3 -3
  116. package/docs/recipes/16-dev-bridge.md +22 -12
  117. package/docs/recipes/18-world.md +10 -8
  118. package/docs/recipes/19-shooting-picking.md +7 -5
  119. package/docs/recipes/20-content-actions-save.md +6 -2
  120. package/docs/recipes/21-camera.md +8 -3
  121. package/docs/recipes/23-ops.md +1 -1
  122. package/docs/recipes/26-ui-parts.md +35 -11
  123. package/docs/recipes/28-terrain.md +12 -12
  124. package/docs/recipes/29-grid.md +14 -5
  125. package/docs/recipes/30-templates.md +8 -3
  126. package/docs/recipes/31-audio.md +4 -4
  127. package/docs/recipes/32-action-game.md +18 -4
  128. package/docs/recipes/34-environment-lighting.md +102 -38
  129. package/docs/recipes/35-picture-from-reference.md +147 -0
  130. package/docs/recipes/36-sky-ground-plants.md +158 -0
  131. package/docs/recipes/{37-terrain-look-hooks.md → 37-terrain-hooks.md} +9 -13
  132. package/docs/recipes/38-environment-hooks.md +67 -0
  133. package/docs/recipes/40-scene.md +106 -27
  134. package/docs/recipes/42-terrain-shape.md +1 -1
  135. package/docs/recipes/{43-shader-patches-surface-looks.md → 43-shader-patches-surfaces.md} +66 -77
  136. package/docs/recipes/44-water-weather-hooks.md +191 -0
  137. package/docs/recipes/45-cascaded-shadows.md +121 -23
  138. package/docs/recipes/46-blender-art-route.md +17 -20
  139. package/docs/recipes/47-island-snow-backdrop.md +10 -12
  140. package/docs/recipes/49-game-module-contract.md +1 -1
  141. package/docs/recipes/50-own-renderer.md +3 -3
  142. package/docs/recipes/52-around-the-picture.md +181 -0
  143. package/docs/recipes/53-ground-up-close.md +12 -12
  144. package/docs/recipes/54-three-idioms.md +18 -18
  145. package/docs/recipes/55-mods-time-wrap.md +17 -5
  146. package/docs/recipes/56-webgpu-tsl.md +66 -23
  147. package/docs/recipes/57-control.md +39 -0
  148. package/docs/recipes/58-input.md +3 -0
  149. package/docs/recipes/59-depth-post-effects.md +5 -5
  150. package/docs/recipes/60-judge-the-picture.md +39 -24
  151. package/docs/recipes/61-deploy.md +27 -0
  152. package/docs/recipes/62-picture-code.md +244 -0
  153. package/docs/recipes/63-third-person-start.md +77 -0
  154. package/docs/recipes/64-particles.md +35 -0
  155. package/examples/action/.threedog/content-index.json +1 -1
  156. package/examples/action/GAMEMAP.md +7 -5
  157. package/examples/action/main.js +5 -4
  158. package/examples/action/models.js +12 -14
  159. package/examples/action/picture/index.js +13 -0
  160. package/examples/action/picture/lights.js +35 -0
  161. package/examples/action/picture/materials.js +8 -0
  162. package/examples/action/picture/palette.js +33 -0
  163. package/examples/plain-picture/.threedog/content-index.json +1 -0
  164. package/examples/plain-picture/FINDINGS.md +53 -0
  165. package/examples/plain-picture/GAMEMAP.md +90 -0
  166. package/examples/plain-picture/main.js +48 -0
  167. package/examples/plain-picture/picture/index.js +21 -0
  168. package/examples/plain-picture/picture/lights.js +54 -0
  169. package/examples/plain-picture/picture/materials.js +24 -0
  170. package/examples/plain-picture/picture/palette.js +16 -0
  171. package/examples/plain-picture/picture/sky.js +37 -0
  172. package/examples/pullable.json +31 -9
  173. package/examples/rc2d/GAMEMAP.md +8 -3
  174. package/examples/rc2d/README.md +11 -6
  175. package/examples/rc2d/main.js +25 -33
  176. package/examples/rc2d/picture/index.js +18 -0
  177. package/examples/rc2d/picture/lights.js +11 -0
  178. package/examples/rc2d/picture/materials.js +18 -0
  179. package/examples/rc2d/picture/palette.js +15 -0
  180. package/examples/rc2d/picture/post.js +11 -0
  181. package/examples/rc2d/rc2d.js +18 -28
  182. package/examples/sheepisland/.threedog/content-index.json +1 -1
  183. package/examples/sheepisland/GAMEMAP.md +13 -10
  184. package/examples/sheepisland/assets.js +2 -2
  185. package/examples/sheepisland/content/templates.js +1 -1
  186. package/examples/sheepisland/content/vegetation.js +3 -1
  187. package/examples/sheepisland/main.js +15 -9
  188. package/examples/sheepisland/{style/models.js → models.js} +13 -24
  189. package/examples/sheepisland/picture/index.js +20 -0
  190. package/examples/sheepisland/picture/lights.js +34 -0
  191. package/examples/sheepisland/picture/materials.js +61 -0
  192. package/examples/sheepisland/picture/palette.js +60 -0
  193. package/examples/sheepisland/picture/sky.js +20 -0
  194. package/examples/sheepisland/views.js +1 -1
  195. package/examples/styletest/.threedog/content-index.json +1 -1
  196. package/examples/styletest/GAMEMAP.md +15 -11
  197. package/examples/styletest/main.js +20 -30
  198. package/examples/styletest/models.js +29 -29
  199. package/examples/styletest/params.js +1 -4
  200. package/examples/styletest/picture/env.js +38 -0
  201. package/examples/styletest/picture/index.js +16 -0
  202. package/examples/styletest/picture/lights.js +9 -0
  203. package/examples/styletest/picture/materials.js +28 -0
  204. package/examples/styletest/picture/palette.js +22 -0
  205. package/examples/techniques/contact-shadows/README.md +22 -23
  206. package/examples/techniques/contact-shadows/contactShadows.js +32 -16
  207. package/examples/techniques/contact-shadows/main.js +20 -18
  208. package/examples/techniques/contact-shadows/picture/index.js +14 -0
  209. package/examples/techniques/contact-shadows/picture/lights.js +34 -0
  210. package/examples/techniques/contact-shadows/picture/materials.js +12 -0
  211. package/examples/techniques/contact-shadows/picture/palette.js +17 -0
  212. package/examples/techniques/day-night-grade/README.md +13 -16
  213. package/examples/techniques/day-night-grade/main.js +15 -25
  214. package/examples/techniques/day-night-grade/picture/index.js +20 -0
  215. package/examples/techniques/day-night-grade/picture/lights.js +45 -0
  216. package/examples/techniques/day-night-grade/picture/materials.js +15 -0
  217. package/examples/techniques/day-night-grade/picture/palette.js +59 -0
  218. package/examples/techniques/day-night-grade/picture/post.js +25 -0
  219. package/examples/techniques/day-night-grade/picture/sky.js +33 -0
  220. package/examples/techniques/interior-light/README.md +16 -13
  221. package/examples/techniques/interior-light/interiorLight.js +19 -17
  222. package/examples/techniques/interior-light/main.js +30 -67
  223. package/examples/techniques/interior-light/picture/index.js +24 -0
  224. package/examples/techniques/interior-light/picture/lights.js +52 -0
  225. package/examples/techniques/interior-light/picture/materials.js +13 -0
  226. package/examples/techniques/interior-light/picture/palette.js +32 -0
  227. package/examples/techniques/interior-light/picture/sky.js +40 -0
  228. package/examples/techniques/modular-building/README.md +4 -3
  229. package/examples/techniques/modular-building/kit.js +2 -2
  230. package/examples/techniques/modular-building/main.js +9 -17
  231. package/examples/techniques/modular-building/picture/index.js +17 -0
  232. package/examples/techniques/modular-building/picture/lights.js +26 -0
  233. package/examples/techniques/modular-building/picture/materials.js +13 -0
  234. package/examples/techniques/modular-building/picture/palette.js +23 -0
  235. package/examples/techniques/night-lights/README.md +15 -14
  236. package/examples/techniques/night-lights/main.js +20 -43
  237. package/examples/techniques/night-lights/nightLights.js +25 -21
  238. package/examples/techniques/night-lights/picture/index.js +18 -0
  239. package/examples/techniques/night-lights/picture/lights.js +44 -0
  240. package/examples/techniques/night-lights/picture/materials.js +15 -0
  241. package/examples/techniques/night-lights/picture/palette.js +34 -0
  242. package/examples/techniques/night-lights/picture/post.js +9 -0
  243. package/examples/techniques/night-lights/picture/sky.js +36 -0
  244. package/examples/techniques/outlines-and-rim/README.md +2 -2
  245. package/examples/techniques/outlines-and-rim/main.js +15 -38
  246. package/examples/techniques/outlines-and-rim/outlines.js +3 -3
  247. package/examples/techniques/outlines-and-rim/picture/index.js +16 -0
  248. package/examples/techniques/outlines-and-rim/picture/lights.js +18 -0
  249. package/examples/techniques/outlines-and-rim/picture/materials.js +11 -0
  250. package/examples/techniques/outlines-and-rim/picture/palette.js +16 -0
  251. package/examples/techniques/outlines-and-rim/picture/post.js +10 -0
  252. package/examples/techniques/procedural-animation/README.md +5 -3
  253. package/examples/techniques/procedural-animation/main.js +9 -7
  254. package/examples/techniques/procedural-animation/picture/index.js +15 -0
  255. package/examples/techniques/procedural-animation/picture/lights.js +35 -0
  256. package/examples/techniques/procedural-animation/picture/materials.js +10 -0
  257. package/examples/techniques/procedural-animation/picture/palette.js +16 -0
  258. package/examples/techniques/procedural-animation/picture/sky.js +31 -0
  259. package/examples/techniques/procedural-animation/proceduralAnim.js +1 -1
  260. package/examples/techniques/procedural-surface/README.md +2 -0
  261. package/examples/techniques/procedural-surface/main.js +17 -55
  262. package/examples/techniques/procedural-surface/picture/index.js +14 -0
  263. package/examples/techniques/procedural-surface/picture/lights.js +18 -0
  264. package/examples/techniques/procedural-surface/picture/materials.js +34 -0
  265. package/examples/techniques/procedural-surface/picture/palette.js +15 -0
  266. package/examples/techniques/stylized-shading/README.md +13 -14
  267. package/examples/techniques/stylized-shading/main.js +11 -42
  268. package/examples/techniques/stylized-shading/picture/index.js +14 -0
  269. package/examples/techniques/stylized-shading/picture/lights.js +23 -0
  270. package/examples/techniques/stylized-shading/picture/materials.js +18 -0
  271. package/examples/techniques/stylized-shading/picture/palette.js +19 -0
  272. package/examples/techniques/stylized-shading/shading.js +2 -2
  273. package/examples/techniques/sun-and-key-light/README.md +20 -22
  274. package/examples/techniques/sun-and-key-light/keyLight.js +47 -29
  275. package/examples/techniques/sun-and-key-light/main.js +19 -63
  276. package/examples/techniques/sun-and-key-light/picture/index.js +13 -0
  277. package/examples/techniques/sun-and-key-light/picture/lights.js +33 -0
  278. package/examples/techniques/sun-and-key-light/picture/materials.js +9 -0
  279. package/examples/techniques/sun-and-key-light/picture/palette.js +29 -0
  280. package/examples/techniques/sun-and-key-light/picture/sky.js +16 -0
  281. package/examples/techniques/three-looks/README.md +21 -0
  282. package/examples/techniques/three-looks/main.js +58 -0
  283. package/examples/techniques/three-looks/picture/cartoon.js +23 -0
  284. package/examples/techniques/three-looks/picture/cinematic.js +27 -0
  285. package/examples/techniques/three-looks/picture/comic.js +27 -0
  286. package/examples/techniques/three-looks/picture/index.js +14 -0
  287. package/examples/techniques/three-looks/picture/sun.js +23 -0
  288. package/examples/techniques/wet-road/README.md +7 -4
  289. package/examples/techniques/wet-road/main.js +18 -38
  290. package/examples/techniques/wet-road/picture/index.js +17 -0
  291. package/examples/techniques/wet-road/picture/lights.js +57 -0
  292. package/examples/techniques/wet-road/picture/materials.js +16 -0
  293. package/examples/techniques/wet-road/picture/palette.js +24 -0
  294. package/examples/techniques/wet-road/picture/sky.js +46 -0
  295. package/examples/webgpu-tsl/GAMEMAP.md +9 -4
  296. package/examples/webgpu-tsl/README.md +13 -10
  297. package/examples/webgpu-tsl/main.js +30 -7
  298. package/examples/webgpu-tsl/picture/index.js +18 -0
  299. package/examples/webgpu-tsl/picture/lights.js +25 -0
  300. package/examples/webgpu-tsl/picture/materials.js +36 -0
  301. package/examples/webgpu-tsl/picture/palette.js +23 -0
  302. package/examples/webgpu-tsl/picture/post.js +16 -0
  303. package/examples/webgpu-tsl/picture/sky.js +30 -0
  304. package/examples/world/.threedog/content-index.json +1 -1
  305. package/examples/world/GAMEMAP.md +15 -12
  306. package/examples/world/art/humanoid.js +9 -13
  307. package/examples/world/art/index.js +2 -2
  308. package/examples/world/art/models.js +3 -4
  309. package/examples/world/art/shapes.js +2 -2
  310. package/examples/world/assets.js +2 -2
  311. package/examples/world/content/audio.js +1 -1
  312. package/examples/world/content/items.js +1 -1
  313. package/examples/world/content/props.js +1 -1
  314. package/examples/world/content/templates.js +1 -1
  315. package/examples/world/content/vegetation.js +1 -1
  316. package/examples/world/main.js +10 -10
  317. package/examples/world/models.js +17 -7
  318. package/examples/world/picture/index.js +20 -0
  319. package/examples/world/picture/lights.js +41 -0
  320. package/examples/world/picture/materials.js +34 -0
  321. package/examples/world/picture/palette.js +74 -0
  322. package/examples/world/picture/post.js +9 -0
  323. package/examples/world/picture/sky.js +39 -0
  324. package/index.d.ts +7 -16
  325. package/index.js +7 -7
  326. package/llms.txt +15 -13
  327. package/modules/ambience/Ambience.js +1 -1
  328. package/modules/calendar/Calendar.js +1 -1
  329. package/modules/calendar/index.js +1 -0
  330. package/modules/camera/FirstPersonCamera.js +1 -1
  331. package/modules/camera/FixedCamera.js +2 -2
  332. package/modules/camera/RtsCamera.js +1 -1
  333. package/modules/camera/common.js +7 -5
  334. package/modules/characters/Character.js +15 -10
  335. package/modules/characters/NPC.js +5 -5
  336. package/modules/characters/assetModel.js +5 -4
  337. package/modules/characters/index.js +28 -3
  338. package/modules/characters/movers/common.js +6 -1
  339. package/modules/characters/movers/manual.js +3 -0
  340. package/modules/characters/movers/support.js +25 -11
  341. package/modules/characters/npcSim.js +5 -1
  342. package/modules/characters/proceduralRig.js +18 -4
  343. package/modules/characters/useModel.js +2 -2
  344. package/modules/collision/Collision.js +4 -2
  345. package/modules/content/index.js +8 -0
  346. package/modules/content/models.js +56 -11
  347. package/modules/content/props.js +5 -3
  348. package/modules/content/rules.js +12 -4
  349. package/modules/content/templates.js +5 -3
  350. package/modules/gameplay/Interactions.js +91 -16
  351. package/modules/gameplay/Inventory.js +3 -3
  352. package/modules/gameplay/dialogueBox.js +1 -1
  353. package/modules/gameplay/dialogueBubbles.js +1 -1
  354. package/modules/gameplay/interactionPrompt.js +1 -1
  355. package/modules/gameplay/interactions.contract.js +1 -1
  356. package/modules/gameplay/inventoryOps.js +2 -2
  357. package/modules/gameplay/pickups.js +62 -24
  358. package/modules/gameplay/questLog.js +2 -2
  359. package/modules/grid/Layer.js +13 -0
  360. package/modules/grid/index.js +40 -11
  361. package/modules/grid/preview.js +24 -15
  362. package/modules/grid/tiles.js +15 -19
  363. package/modules/hlod/index.js +3 -2
  364. package/modules/hud/index.js +13 -0
  365. package/modules/hud/parts.js +9 -7
  366. package/modules/level/index.js +5 -4
  367. package/modules/lights/index.js +12 -8
  368. package/modules/music/Music.js +1 -1
  369. package/modules/particles/Particles.js +41 -20
  370. package/modules/particles/effect.js +21 -6
  371. package/modules/photo/Photo.js +11 -10
  372. package/modules/settings/Settings.js +7 -7
  373. package/modules/settings/apply.js +5 -5
  374. package/modules/settings/sections.js +2 -2
  375. package/modules/settings/strings.js +1 -1
  376. package/modules/sky/Sky.js +104 -89
  377. package/modules/sky/clouds.js +16 -17
  378. package/modules/sky/dome.js +100 -0
  379. package/modules/sky/domeLayers.js +5 -5
  380. package/modules/sky/environment.js +45 -169
  381. package/modules/sky/fog.js +5 -180
  382. package/modules/sky/frame.js +26 -90
  383. package/modules/sky/season.js +3 -3
  384. package/modules/sky/shader.js +35 -29
  385. package/modules/sky/skyModule.js +25 -22
  386. package/modules/sky/tint.js +9 -11
  387. package/modules/terrain/ChunkManager.js +29 -12
  388. package/modules/terrain/draw.js +154 -0
  389. package/modules/terrain/index.js +44 -66
  390. package/modules/terrain/terrainDefaults.js +2 -2
  391. package/modules/terrain/terrainEdit.js +1 -1
  392. package/modules/terrain/terrainGen.js +2 -2
  393. package/modules/triggers/index.js +10 -6
  394. package/modules/vegetation/Vegetation.js +58 -17
  395. package/modules/vegetation/draw.js +191 -0
  396. package/modules/vegetation/groundChunks.js +1 -1
  397. package/modules/vegetation/index.js +10 -10
  398. package/modules/water/Water.js +135 -88
  399. package/modules/water/surface.js +53 -53
  400. package/modules/weather/Weather.js +52 -17
  401. package/modules/weather/particles.js +13 -5
  402. package/modules/weather/shaders.js +1 -1
  403. package/modules/weather/weatherDraw.js +141 -0
  404. package/modules/world/World.js +2 -2
  405. package/modules/world/views.js +1 -1
  406. package/package.json +3 -2
  407. package/presets.js +2 -2
  408. package/render/PostFX.js +199 -41
  409. package/render/backend.js +52 -6
  410. package/render/cascades.js +195 -0
  411. package/render/cascades.tsl.js +96 -0
  412. package/render/daylight.js +39 -0
  413. package/render/detail.js +5 -5
  414. package/render/effects.js +41 -26
  415. package/render/fx/cel.tsl.js +42 -0
  416. package/render/fx/index.js +7 -5
  417. package/render/fx/patchNodes.tsl.js +1 -1
  418. package/render/fx/postWebGPU.tsl.js +30 -7
  419. package/render/fx/sky.tsl.js +19 -92
  420. package/render/fx/water.tsl.js +1 -1
  421. package/render/layers.js +14 -0
  422. package/render/lighting.js +6 -5
  423. package/render/lightmap.js +142 -0
  424. package/render/lights.js +23 -201
  425. package/render/materials.js +44 -160
  426. package/render/neutral.js +23 -0
  427. package/render/occlusion.js +184 -0
  428. package/render/ownFrame.js +1 -1
  429. package/render/patches.js +34 -29
  430. package/render/postWebGL.js +11 -3
  431. package/render/probes.js +179 -122
  432. package/render/slots.js +4 -4
  433. package/render/terms.js +53 -101
  434. package/render/uniformDecl.js +1 -1
  435. package/types/core.d.ts +333 -296
  436. package/types/gameplay.d.ts +65 -26
  437. package/types/generated/core/Audio.d.ts +1 -1
  438. package/types/generated/core/DebugOverrides.d.ts +14 -6
  439. package/types/generated/core/Input.d.ts +9 -2
  440. package/types/generated/core/page.d.ts +9 -2
  441. package/types/generated/modules/grid/Layer.d.ts +8 -0
  442. package/types/generated/modules/grid/index.d.ts +29 -5
  443. package/types/generated/modules/particles/Particles.d.ts +13 -6
  444. package/types/generated/modules/sky/Sky.d.ts +85 -18
  445. package/types/generated/modules/sky/skyModule.d.ts +1 -1
  446. package/types/generated/modules/water/Water.d.ts +50 -3
  447. package/types/generated/modules/weather/Weather.d.ts +33 -3
  448. package/types/generated/modules/weather/weatherDraw.d.ts +11 -0
  449. package/types/generated/modules/world/World.d.ts +2 -2
  450. package/types/generated/render/PostFX.d.ts +53 -10
  451. package/types/generated/render/lighting.d.ts +29 -0
  452. package/types/generated/render/materials.d.ts +19 -44
  453. package/types/generated/render/occlusion.d.ts +13 -0
  454. package/types/physics.d.ts +5 -3
  455. package/types/tsl.d.ts +8 -0
  456. package/types/world.d.ts +376 -57
  457. package/ui/Focus.js +12 -2
  458. package/ui/LoadingScreen.js +2 -2
  459. package/ui/Parts.js +8 -4
  460. package/ui/UI.js +10 -10
  461. package/ui/cursor.js +1 -1
  462. package/ui/theme.js +33 -27
  463. package/ui/touchPart.js +1 -1
  464. package/core/look/coreParts.js +0 -219
  465. package/core/look/part.js +0 -253
  466. package/core/look/points.js +0 -255
  467. package/core/look/report.js +0 -96
  468. package/core/look/shadowPart.js +0 -63
  469. package/core/look/state.js +0 -45
  470. package/core/look/write.js +0 -70
  471. package/core/styleParts.js +0 -114
  472. package/docs/api/style.md +0 -136
  473. package/docs/api/terrainLook.md +0 -10
  474. package/docs/api/vegetationLook.md +0 -10
  475. package/docs/api/weatherLook.md +0 -10
  476. package/docs/recipes/09-style.md +0 -218
  477. package/docs/recipes/35-style-from-reference.md +0 -153
  478. package/docs/recipes/36-sky-ground-plant-looks.md +0 -118
  479. package/docs/recipes/38-environment-look-hooks.md +0 -99
  480. package/docs/recipes/41-thing-registry.md +0 -97
  481. package/docs/recipes/44-water-weather-look-hooks.md +0 -144
  482. package/docs/recipes/48-make-material.md +0 -75
  483. package/docs/recipes/52-look.md +0 -282
  484. package/examples/action/look.js +0 -5
  485. package/examples/sheepisland/style/index.js +0 -79
  486. package/examples/styletest/look.js +0 -11
  487. package/examples/techniques/day-night-grade/dayNightGrade.js +0 -76
  488. package/examples/webgpu-tsl/tslScene.js +0 -75
  489. package/examples/world/style/index.js +0 -61
  490. package/examples/world/style/plugins/10-bloom.js +0 -5
  491. package/modules/sky/cascades.js +0 -186
  492. package/modules/sky/cascades.tsl.js +0 -82
  493. package/modules/sky/look.js +0 -54
  494. package/modules/sky/lookFog.js +0 -76
  495. package/modules/sky/lookShadow.js +0 -62
  496. package/modules/sky/lookSky.js +0 -169
  497. package/modules/sky/shadow.js +0 -98
  498. package/modules/terrain/look.js +0 -83
  499. package/modules/terrain/lookGround.js +0 -66
  500. package/modules/vegetation/look.js +0 -119
  501. package/modules/vegetation/lookWind.js +0 -98
  502. package/modules/water/look.js +0 -91
  503. package/modules/water/surfaceDefaults.js +0 -3
  504. package/modules/weather/look.js +0 -74
  505. package/modules/weather/weatherLook.js +0 -135
  506. package/render/lookGlow.js +0 -139
  507. package/render/lookSurface.js +0 -224
  508. package/render/postLook.js +0 -164
  509. package/render/surface.js +0 -105
  510. package/types/generated/modules/weather/weatherLook.d.ts +0 -12
  511. package/types/style.d.ts +0 -671
package/core/UrlState.js CHANGED
@@ -1,25 +1,38 @@
1
1
  // engine.applyState: one-call scenarios.
2
- // Reproduce a scenario in one call: engine.applyState({ time, season, weather, pos, save, wait, cutscene, view, play, state }), engine.defineState(name, params).
2
+ // Reproduce a scenario in one call: engine.applyState({ time, season, weather, pos, at, save, wait, cutscene, view, play, fresh, state }), engine.defineState(name, params).
3
3
  // In dev (or with createEngine({ urlState: true })) URL parameters are read automatically: /?time=18:30&weather=rain&pos=40,-20&cutscene=skip&wait=3&state=name
4
4
  // ?play (any value) leaves the title screen the way its Start does (engine.session.newGame(), then the title part closes; flow's start state too): `shot --play`, tests
5
+ // ?fresh (bare, or ?fresh=1; false and 0 do nothing) deletes every save of this page first, so the title offers no Continue and a key press on it starts a new run; on a running page it also ends
6
+ // the run and goes back to the title (session.quit). For repeatable script runs: Enter on a title picks Continue when a save exists, so a rerun played the last
7
+ // autosave. ?fresh&play is a clean start in play, with or without a title screen. Read from the URL in dev mode only: outside it early() drops fresh with one warning,
8
+ // even with createEngine({ urlState: true }), because a link must never delete a player's saves in a shipped game. The game's own engine.applyState({ fresh: true }) still acts
9
+ // ?at=<place> is ?play plus standing at a named place, with the game's own camera on the player: `shot --at <place>`. Every game wrote this by hand (15-20 lines), and
10
+ // a placement made before session:start is undone by it, so it happens here, after the run started. Names are a module's: its applyState hook answers { at } with
11
+ // a position, and core does the placing, so core names no module
5
12
  //
6
- // Who handles which key: core handles save (saves.load), pos (player.placeAt, or sets the focus without a player) and wait (advances with engine.step);
13
+ // Who handles which key: core handles save (saves.load), pos and at (player.placeAt, or sets the focus without a player; then state:placed, so a rig that eases
14
+ // jumps instead of gliding across the map) and wait (advances with engine.step);
7
15
  // the rest go to the module hook applyState(e, params) (written like the describe hook): calendar -> time and season (sky -> its fixed time without a calendar), weather -> weather, timeline -> cutscene.
8
16
  // Two phases, both called from start():
9
17
  // early(): before modules are ready, applies save, pos, time, weather (terrain is generated directly at the new position)
10
- // late(): after engine:ready, play (start a run when the title is up), view (engine.views), cutscene ('skip' skips the opening cutscene), sets weather once more, advances wait seconds, aligns time again, then emits state:applied
18
+ // late(): after engine:ready, play (start a run when the title is up), at, view (engine.views), cutscene ('skip' skips the opening cutscene), sets weather once more, advances wait seconds, aligns time again, then emits state:applied
11
19
  // In a game, await engine.applyState({...}) at any time runs both phases back to back.
12
- import { warnMissing } from './validate.js';
20
+ import { warnMissing, warnOnce, DEV } from './validate.js';
13
21
  import { readParams, keysSchema } from './params.js';
14
- import { xzOf } from './math.js';
22
+ import { xzOf, yOf } from './math.js';
15
23
  import { unsettled } from './headlessLoad.js';
24
+ import { codedError } from './errorHints.js';
16
25
 
17
- const KEYS = ['state', 'time', 'season', 'weather', 'pos', 'save', 'wait', 'cutscene', 'view', 'play'];
26
+ // fresh deletes saves, so it acts only on a clear yes: a bare ?fresh reads as ''
27
+ const freshOn = v => v === true || v === '1' || v === '';
28
+ const KEYS = ['state', 'time', 'season', 'weather', 'pos', 'at', 'save', 'wait', 'cutscene', 'view', 'play', 'fresh'];
18
29
 
19
30
  export class UrlState {
20
- constructor(engine, { fromUrl = false } = {}) {
31
+ constructor(engine, { fromUrl = false, dev = DEV } = {}) {
21
32
  this.engine = engine;
22
33
  this.fromUrl = fromUrl;
34
+ this.dev = dev;
35
+ this._ended = false; // fresh ended a running playthrough, so play must start one even when no title is up
23
36
  this.states = new Map(); // name -> params
24
37
  this.pending = null; // URL parameters (used by start())
25
38
  this.applied = false; // URL parameters are fully applied (npm run shot waits for it)
@@ -42,6 +55,7 @@ export class UrlState {
42
55
  readParams('applyState()', keysSchema(KEYS), p);
43
56
  if (typeof p.pos === 'string') { const [x, z] = p.pos.split(',').map(Number); p.pos = { x, z }; }
44
57
  if (p.wait != null) p.wait = +p.wait;
58
+ if (p.at != null) p.play ??= true; // a place is somewhere in the game, never on the start screen
45
59
  return p;
46
60
  }
47
61
  _hooks(p, keys) {
@@ -60,20 +74,42 @@ export class UrlState {
60
74
  await new Promise(r => setTimeout(r, 16)); // main-loop: yield to the browser (background threads, Promise continuations) without advancing game time
61
75
  }
62
76
  }
77
+ _place(pos) {
78
+ const e = this.engine, [x, z] = xzOf(pos);
79
+ if (e.player) e.player.placeAt(pos); else e.focus.set(x, e.surface(x, z, yOf(pos)), z);
80
+ e.events.emit('state:placed', { x, z });
81
+ }
82
+ async _fresh() {
83
+ const e = this.engine;
84
+ await Promise.all(e.saves.list().map(s => e.saves.remove(s.slot)));
85
+ if (!e.ready) return; // during start(): the title has not been drawn yet, and nothing runs to end
86
+ if (e.ui.isOpen('title')) e.ui.close('title'); // closed first so quit draws it again, without Continue
87
+ await e.session.quit();
88
+ this._ended = true;
89
+ }
63
90
  async _early(p) {
64
91
  const e = this.engine;
92
+ if (freshOn(p.fresh)) await this._fresh();
65
93
  if (p.save != null) await e.saves.load(String(p.save));
66
- if (p.pos) { const [x, z] = xzOf(p.pos); if (e.player) e.player.placeAt({ x, z }); else e.focus.set(x, e.surface(x, z), z); }
94
+ if (p.pos) this._place(p.pos);
67
95
  await Promise.all(this._hooks(p, ['time', 'season', 'weather']));
68
96
  }
69
97
  async _late(p) {
70
98
  const e = this.engine;
71
99
  // play: what the title's Start does (ui/defaults.js), so the game's session:start setup runs; a module with a title of its own (flow's
72
100
  // start state) leaves it in its applyState hook. Before wait, so the advanced seconds are played seconds
101
+ const ended = this._ended; this._ended = false;
73
102
  if (p.play != null) {
74
- if (e.ui.isOpen('title')) { await e.session.newGame(); e.ui.close('title'); }
103
+ // ended: without a title part quit leaves nothing open to press Start on, and a run that ended must still start again (session:start)
104
+ if (ended || e.ui.isOpen('title')) { await e.session.newGame(); e.ui.close('title'); }
75
105
  await Promise.all(this._hooks(p, ['play']));
76
106
  }
107
+ if (p.at != null) {
108
+ const where = (await Promise.all(this._hooks(p, ['at']))).find(Boolean);
109
+ if (!where) throw codedError('state-at', `applyState({ at: '${p.at}' }): no installed module knows place names`);
110
+ this._place(where);
111
+ await this._settle(); // the ground and models around the place, before wait and the picture
112
+ }
77
113
  await Promise.all(this._hooks(p, ['cutscene', 'weather'])); // set weather once more: the opening auto-weather or settings in engine:ready may have changed it
78
114
  if (p.wait > 0) for (let s = p.wait; s > 1e-6; s -= 0.5) { // advance in small slices so Promises (the next cutscene segment) and background threads continue between them
79
115
  e.step(Math.min(0.5, s), { render: false, describe: false });
@@ -99,6 +135,10 @@ export class UrlState {
99
135
  for (const k of KEYS) if (q.has(k)) raw[k] = q.get(k);
100
136
  if (!Object.keys(raw).length) return;
101
137
  this.pending = this._expand(raw);
138
+ if (!this.dev && this.pending.fresh != null) { // after _expand: a named ?state= can carry fresh too
139
+ delete this.pending.fresh;
140
+ warnOnce('?fresh is ignored outside dev mode: a link must not delete saves in a shipped game. Game code can call engine.applyState({ fresh: true }).');
141
+ }
102
142
  return this._early(this.pending);
103
143
  }
104
144
  /** In start(), after engine:ready: cutscene, wait, align time again, then emit state:applied */
package/core/Views.js CHANGED
@@ -45,6 +45,7 @@ export class Views {
45
45
  if (v.fov != null && c.isPerspectiveCamera) { c.fov = v.fov; c.updateProjectionMatrix(); e._oFov?.mark(); } // asked through the engine: not an outside write
46
46
  c.updateMatrixWorld(true);
47
47
  this.current = name;
48
+ e.events.emit('camera:shot', { name }); // a cut: what follows the camera (the light pool) settles at once instead of easing over
48
49
  return { remove: () => { if (this.current === name) this.release(); } };
49
50
  }
50
51
  /** Give the camera back (to the previous holder, e.g. a running cutscene, or to the rig) */
package/core/adaptive.js CHANGED
@@ -8,7 +8,7 @@
8
8
  // one-off costs that resolution cannot fix.
9
9
  //
10
10
  // shortcut: only the resolution is adjusted. A tier ladder (resolution -> shadows -> view distance -> vegetation) would hang off decide() below as
11
- // further steps once a game needs it; until then the other knobs stay the game's (settings / look.view).
11
+ // further steps once a game needs it; until then the other knobs stay the game's (settings / engine.view).
12
12
  import { DEV, warnOnce } from './validate.js';
13
13
 
14
14
  const GRACE = 3; // s after ready that are not judged (warm-up compiles, first uploads, stream fill)
@@ -37,7 +37,7 @@ export function adapt(e, dt, cost, compiled, gpuKnown) {
37
37
  if (!compiled) { a.costs.push(cost); a.gaps.push(dt * 1000); }
38
38
  if (a.t < WINDOW) return;
39
39
  const costs = a.costs, gaps = a.gaps; a.t = 0; a.costs = []; a.gaps = [];
40
- // the game set renderer.setPixelRatio itself: adaptive resolution stops (core/owned.js); look.view.manual('pixelRatio', false) resumes it
40
+ // the game set renderer.setPixelRatio itself: adaptive resolution stops (core/owned.js); engine.view.manual('pixelRatio', false) resumes it
41
41
  e._oPixelRatio.check(); if (!e._oPixelRatio.on) return;
42
42
  if (!gaps.length) return;
43
43
  const gap = median(gaps), clustered = gaps.filter(g => Math.abs(g - gap) <= gap * LOCK_TOL).length >= gaps.length * 0.7;
@@ -37,7 +37,10 @@ export function shadowDefaults(root, { castShadow, receiveShadow } = {}) {
37
37
 
38
38
  /** Load an entry as a task in engine.loading; a registered, non-critical file that fails resolves to its fallback */
39
39
  export function fetchEntry(a, e) {
40
+ // shortcut: the stale build stays in memory while its copies live and is not disposed after them; freeing it needs a user count per build, worth it if a game rewrites the palette often
41
+ if (a._stale(e)) e.promise = e.value = null;
40
42
  if (e.promise) return e.promise;
43
+ e.palette = a._paletteKey;
41
44
  const L = a.engine.loading, name = e.variantOf ?? e.name ?? e.url;
42
45
  const t = L._begin(name, e.type, { critical: e.opts.critical === true, url: e.opts.build || e.opts.texture ? null : e.url, manifest: e.manifest ?? null });
43
46
  if (e.type === 'model') {
@@ -69,7 +72,7 @@ function failedEntry(a, e, t, err) {
69
72
  if (!degrade) throw codedError('asset-load', msg);
70
73
  warnOnce(coded('asset-load', msg + fmt(STRINGS.fellBack, { fallback: e.opts.fallback ? `"${fb}"` : fb })));
71
74
  if (e.opts.fallback) return (e.promise = fetchEntry(a, a._resolve(e.opts.fallback, e.type))); // e.value stays null: the fallback entry owns the memory
72
- e.value = e.type === 'model' ? shareModel(a, placeholder('model', a.engine)) : placeholder(e.type);
75
+ e.value = e.type === 'model' ? shareModel(a, placeholder('model')) : placeholder(e.type);
73
76
  return (e.promise = Promise.resolve(e.value));
74
77
  }
75
78
 
@@ -92,7 +95,7 @@ export function freeEntry(e) {
92
95
 
93
96
  /** Load the entries preload() wants and report progress; returns { loaded, failed, ok } (Assets.preload documents it) */
94
97
  export async function preloadEntries(a, onProgress, onlyMarked) {
95
- // generators and fonts only when marked: a font pack may hold many faces, and only those style.ui.fonts names (or preload: true) are wanted
98
+ // generators and fonts only when marked: a font pack may hold many faces, and only those ui.fonts names (or preload: true) are wanted
96
99
  const list = [...a.entries.entries()].filter(([, e]) => e.opts.build || e.type === 'font' ? e.opts.preload : !onlyMarked || e.opts.preload);
97
100
  let done = 0;
98
101
  onProgress?.(list.length ? 0 : 1, '');
package/core/assetLoad.js CHANGED
@@ -5,7 +5,7 @@ import { coded } from './errorHints.js';
5
5
  import * as THREE from 'three';
6
6
  import { restoreBaked, toGLB, fromGLTF } from './Baked.js';
7
7
  import { warnOnce, DEV_SERVER, BASE_URL } from './validate.js';
8
- import { makeMaterial } from '../render/materials.js';
8
+ import { neutralMaterial } from '../render/neutral.js';
9
9
  import { maxAnisotropy } from '../render/backend.js';
10
10
 
11
11
  const BASE = BASE_URL; // DEV_SERVER: only npm run dev serves the /__threedog/cache endpoint
@@ -76,7 +76,7 @@ export async function loadGltf(assets, url, task) {
76
76
  const parsing = assets.gltf.parseAsync(buf, THREE.LoaderUtils.extractUrlBase(url));
77
77
  assets.gltf.manager = prev;
78
78
  let gltf;
79
- try { gltf = restoreBaked(await parsing, assets.engine); } // baked file: restore materials etc.
79
+ try { gltf = restoreBaked(await parsing); } // baked file: restore materials etc.
80
80
  catch (err) { throw new LoadError(String(err?.message ?? err) + (missing.length ? ` (missing: ${missing.join(', ')})` : ''), { url: missing[0] ?? url }); }
81
81
  task.source.animations = gltf.animations.map(a => a.name);
82
82
  const tex = new Set();
@@ -85,18 +85,14 @@ export async function loadGltf(assets, url, task) {
85
85
  return gltf;
86
86
  }
87
87
 
88
- /** Textures made in code and registered by name: makeMaterial keeps their own wrap / repeat unless the spec writes one (render/surface.js) */
89
- export const CODE_TEXTURES = new WeakSet();
90
-
91
88
  /** Load a texture (.ktx2 through KTX2Loader, .hdr through HDRLoader), apply the entry's options and upload it */
92
89
  export async function loadTexture(assets, e, task) {
93
90
  // a texture made in code, registered by name (manifest textures: { brick: () => makeBrick() } or { brick: myTexture }): used as made,
94
91
  // its own colorSpace / wrap / repeat untouched (the game chose them); a function runs once per entry, `this` like a model generator
95
92
  if (e.opts.build || e.opts.texture) {
96
93
  task.phase('build');
97
- const t = e.opts.texture ?? await e.opts.build.call({ palette: assets.engine.style.palette, engine: assets.engine });
94
+ const t = e.opts.texture ?? await e.opts.build.call({ palette: assets.palette, engine: assets.engine });
98
95
  if (!t?.isTexture) throw new LoadError(`the texture generator returned ${t === null ? 'null' : typeof t}, not a THREE.Texture`, { url: null });
99
- CODE_TEXTURES.add(t);
100
96
  return t;
101
97
  }
102
98
  task.phase('download');
@@ -162,26 +158,28 @@ export async function loadFont(assets, e, task) {
162
158
  }
163
159
 
164
160
  /** Stand-ins for a degradable asset that failed: neutral gray (hard rule 1: the engine has no art of its own) */
165
- export function placeholder(type, engine) {
161
+ export function placeholder(type) {
166
162
  if (type === 'texture') { const t = new THREE.DataTexture(new Uint8Array([128, 128, 128, 255]), 1, 1); t.needsUpdate = true; return t; }
167
163
  if (type === 'model') {
168
164
  const g = new THREE.Group();
169
- g.add(new THREE.Mesh(new THREE.BoxGeometry(1, 1, 1).translate(0, 0.5, 0), makeMaterial('default', {}, engine)));
165
+ g.add(new THREE.Mesh(new THREE.BoxGeometry(1, 1, 1).translate(0, 0.5, 0), neutralMaterial('default')));
170
166
  g.name = 'placeholder';
171
167
  return { scene: g, animations: [] };
172
168
  }
173
- return null; // sound: silence; font: the next family in style.ui.font (the system font)
169
+ return null; // sound: silence; font: the next family in ui.theme.font (the system font)
174
170
  }
175
171
 
176
172
  /** Code-generated model: baked file -> dev cache -> build now (Assets.cached, internal); returns { scene, animations, geometry? } */
177
173
  export async function generated(assets, name, build, params, task) {
178
174
  const wrap = v => v.isBufferGeometry
179
- ? { geometry: v, scene: new THREE.Mesh(v, makeMaterial('default', { vertexColors: !!v.attributes.color }, assets.engine)), animations: [] }
175
+ ? { geometry: v, scene: new THREE.Mesh(v, neutralMaterial('default', { vertexColors: !!v.attributes.color })), animations: [] }
180
176
  : { scene: v, animations: v.animations ?? [] };
181
177
  const same = JSON.stringify(params ?? null);
182
- const ctx = { palette: assets.engine.style.palette, engine: assets.engine }; // a function() generator reads this.palette (style.palette)
178
+ const ctx = { palette: assets.palette, engine: assets.engine }; // a function() generator reads this.palette
179
+ const colored = Object.keys(assets.palette).length > 0;
183
180
  const baked = (await bakedIndex(assets))[name];
184
- const bakedOk = baked && JSON.stringify(baked.params ?? null) === same;
181
+ // npm run bake has no engine, so a baked file carries no palette: with one set, only a hand-made file (source: 'file') stands in for the generator
182
+ const bakedOk = baked && JSON.stringify(baked.params ?? null) === same && (!colored || baked.source === 'file');
185
183
  const file = async url => wrap(fromGLTF(await loadGltf(assets, url, task)));
186
184
  if (!DEV_SERVER) return bakedOk ? file(BASE + 'models/baked/' + baked.file) : wrap(await build.call(ctx, params));
187
185
  // In dev: ask the dev server for the current hash of this generator (with its file and imports)
@@ -191,7 +189,7 @@ export async function generated(assets, name, build, params, task) {
191
189
  // template's own vite config, which sent the AI to a config that was already right
192
190
  let info = null, why = null;
193
191
  try {
194
- const r = await fetch(CACHE + 'key', { method: 'POST', body: JSON.stringify({ name, src: String(build), params: ctx.palette ? [params ?? null, ctx.palette] : params ?? null }) });
192
+ const r = await fetch(CACHE + 'key', { method: 'POST', body: JSON.stringify({ name, src: String(build), params: colored ? [params ?? null, ctx.palette] : params ?? null }) });
195
193
  const text = await r.text();
196
194
  if (r.ok && !/^\s*</.test(text)) info = JSON.parse(text);
197
195
  else if (!r.ok) why = `${r.status}${text ? ': ' + text.slice(0, 160) : ''}`;
@@ -208,7 +206,7 @@ export async function generated(assets, name, build, params, task) {
208
206
  const t0 = performance.now(), v = await build.call(ctx, params); // measure:build time
209
207
  // { build, cache: false } in the manifest: never stored (a material the GLB round trip cannot keep, see Baked.js)
210
208
  if (performance.now() - t0 >= assets.cacheMinMs && assets.entries.get(name)?.opts.cache !== false) // measure
211
- toGLB(v, assets.engine, name).then(buf => fetch(CACHE + info.key + '.glb', { method: 'PUT', body: buf })).catch(err => warnOnce(coded('asset-cache', '[cache] could not store a built model in .threedog/cache (' + err.message + '); it is built again next time')));
209
+ toGLB(v, name).then(buf => fetch(CACHE + info.key + '.glb', { method: 'PUT', body: buf })).catch(err => warnOnce(coded('asset-cache', '[cache] could not store a built model in .threedog/cache (' + err.message + '); it is built again next time')));
212
210
  return wrap(v);
213
211
  }
214
212
  /** Bake manifest public/models/baked/index.json (empty if missing) */
@@ -1,5 +1,5 @@
1
1
  // engine.assets.manifest(pack) (helper of Assets.js): registers the named models, textures, sounds and fonts of an asset pack. `a` is the Assets instance.
2
- import { fmt, warnOnce } from './validate.js';
2
+ import { fmt, warnOnce, BASE_URL } from './validate.js';
3
3
  import { codedError } from './errorHints.js';
4
4
  import { parseSchema, readParams, keysSchema } from './params.js';
5
5
 
@@ -25,12 +25,15 @@ export function registerManifest(a, pack, hot = null) {
25
25
  readParams('assets.manifest()', keysSchema(MANIFEST_KEYS), pack);
26
26
  const { models = {}, textures = {}, sounds = {}, fonts = {}, base = null } = pack, list = pack.name ?? 'manifest#' + (a._lists = (a._lists || 0) + 1);
27
27
  const at = base == null ? null : new URL(String(base).replace(/\/?$/, '/'), location.href);
28
- const resolve = u => at && typeof u === 'string' && !u.startsWith('/') && !/^[a-z][a-z\d+.-]*:/i.test(u) ? new URL(u, at).href : u;
28
+ // '/models/x.glb' means the game's public/ folder, which a build with --base /my-game/ serves under that path (recipes/61-deploy.md): vite
29
+ // rewrites bundled URLs only, never these strings, so a game deployed under a sub-path asked the site root for every asset
30
+ const resolve = u => typeof u !== 'string' || /^[a-z][a-z\d+.-]*:/i.test(u) || u.startsWith('//') ? u
31
+ : u.startsWith('/') ? BASE_URL + u.slice(1) : at ? new URL(u, at).href : u;
29
32
  const add = (type, map) => {
30
33
  for (const [name, v] of Object.entries(map)) {
31
34
  const o0 = typeof v === 'string' ? { url: v } : typeof v === 'function' ? { build: v } : v?.isTexture && type === 'texture' ? { texture: v } : v;
32
35
  if (type === 'font') readParams(`assets.manifest() fonts.${name}`, keysSchema(FONT_KEYS), o0);
33
- const o = o0.url && at ? { ...o0, url: resolve(o0.url) } : o0;
36
+ const o = o0.url ? { ...o0, url: resolve(o0.url) } : o0;
34
37
  const old = a.entries.get(name);
35
38
  // a model's params is a schema (core/params.js format, parsed here so a bad spec fails at registration, naming the field)
36
39
  const schema = type === 'model' && o.params ? parseSchema(`assets.manifest() models.${name}.params`, o.params) : null;
@@ -38,11 +38,11 @@ export function reportGltf(gltf, entry = {}, root = gltf.scene, renderer) {
38
38
  const mats = [...materials].map(m => {
39
39
  const maps = {};
40
40
  for (const k of [...COLOR_SLOTS, ...DATA_SLOTS]) if (m[k]?.isTexture) {
41
- maps[k] = m[k].colorSpace || LINEAR;
41
+ maps[k] = m[k].colorSpace || 'none'; // not LINEAR: NoColorSpace is '', so a correct data map read as absent and every intact normal map was reported lost
42
42
  const t = textures.get(m[k]) ?? textures.set(m[k], { name: m[k].name || '(unnamed)', slots: [] }).get(m[k]);
43
43
  if (!t.slots.includes(k)) t.slots.push(k);
44
44
  }
45
- return { name: m.name || '(unnamed)', type: m.type, maps, flatShading: !!m.flatShading, vertexColors: !!m.vertexColors, madeByStyle: !!m.userData?.materialSource };
45
+ return { name: m.name || '(unnamed)', type: m.type, maps, flatShading: !!m.flatShading, vertexColors: !!m.vertexColors, madeByEngine: !!m.userData?.purpose };
46
46
  });
47
47
  const texList = [...textures].map(([t, v]) => ({ ...v, colorSpace: t.colorSpace || LINEAR, problems: colorSpaceIssues(t, v.slots) }));
48
48
  for (const t of texList) for (const p of t.problems) flag('warn', 'color-space', `texture ${t.name}: ${p}`);
@@ -57,7 +57,7 @@ export function reportGltf(gltf, entry = {}, root = gltf.scene, renderer) {
57
57
  if (fm.pbrMetallicRoughness?.baseColorTexture && !live.maps.map) flag('warn', 'base-color-lost', `material "${live.name}" has a base color texture in the file but none in the scene`);
58
58
  if (fm.pbrMetallicRoughness?.metallicRoughnessTexture && !live.maps.roughnessMap && !live.maps.metalnessMap) flag('warn', 'metal-rough-lost', `material "${live.name}" has a metallic-roughness texture in the file but none in the scene`);
59
59
  if (live.flatShading) flag('warn', 'flat-shading', `material "${live.name}" is flat shaded; the file asks for smooth normals`);
60
- if (live.madeByStyle) flag('warn', 'material-replaced', `material "${live.name}" was made by makeMaterial (style role), not read from the file`);
60
+ if (live.madeByEngine) flag('warn', 'material-replaced', `material "${live.name}" was made by the engine, not read from the file`);
61
61
  }
62
62
  for (const a of json.animations || []) if (!clips.some(c => c.name === a.name)) flag('warn', 'clip-lost', `file clip "${a.name}" did not load`);
63
63
  const names = new Set(nodes.map(sanitize)), gone = (json.nodes || []).map(n => sanitize(n.name)).filter(n => n && !names.has(n));
@@ -76,7 +76,7 @@ export function reportGltf(gltf, entry = {}, root = gltf.scene, renderer) {
76
76
  /** Text for the console / describe: one block, issues last */
77
77
  export function reportText(r) {
78
78
  const c = r.counts, L = [`model ${r.name ?? r.url}${r.fromFile ? '' : ' (built in code: no file to compare with)'}: ${c.nodes} nodes · ${c.materials} materials · ${c.textures} textures (${c.normalMaps} normal maps) · ${c.clips} clips · ${c.colliders} col_ · ${c.templates} template/id nodes`];
79
- for (const m of r.materials) L.push(` material ${m.name} (${m.type}${m.flatShading ? ', flat' : ''}${m.madeByStyle ? ', from style' : ''}) ${Object.entries(m.maps).map(([k, v]) => `${k}:${v}`).join(' ') || 'no textures'}`);
79
+ for (const m of r.materials) L.push(` material ${m.name} (${m.type}${m.flatShading ? ', flat' : ''}${m.madeByEngine ? ', made by the engine' : ''}) ${Object.entries(m.maps).map(([k, v]) => `${k}:${v}`).join(' ') || 'no textures'}`);
80
80
  for (const c of r.clips) L.push(` clip ${c.name} ${c.seconds}s`);
81
81
  for (const i of r.issues) L.push(` ${i.severity === 'warn' ? '!' : '·'} [${i.code}] ${i.msg}`);
82
82
  return L.join('\n');
@@ -3,10 +3,11 @@
3
3
  // e an entry (one mesh of one placed object). Hidden instances are swap-removed, not zero-scaled (vegetation's way), so batch bounds stay tight.
4
4
  import * as THREE from 'three';
5
5
  import { copyPatches } from '../render/patches.js';
6
+ import { RESERVED_LAYERS } from '../render/layers.js';
6
7
 
7
8
  const noRaycast = () => {};
8
9
  /** Layer a batched original is moved to: the camera does not draw it (nor its shadow), engine.rays still tests it */
9
- export const BATCH_LAYER = 31;
10
+ export const BATCH_LAYER = RESERVED_LAYERS.batched;
10
11
  const WHITE = new THREE.Color(1, 1, 1);
11
12
  const _m = new THREE.Matrix4(), _c = new THREE.Color();
12
13
  const hold = (B, x, d) => { const n = (B.held.get(x) ?? 0) + d; if (n > 0) B.held.set(x, n); else B.held.delete(x); };
@@ -18,6 +19,12 @@ function makeMesh(B, g, capacity) {
18
19
  im.matrixAutoUpdate = false; im.raycast = noRaycast; // rays hit the originals (on BATCH_LAYER), never the batch
19
20
  im.userData = { budgetTag: 'batch', cell: g.cell };
20
21
  g.mesh = im; B.byMesh.set(im, g); B.root.add(im);
22
+ g.watch?.remove();
23
+ let version = -1; // the box follows the instances: a stale one would hide what stands elsewhere now
24
+ g.watch = B.engine.occlusion.watch([im], () => {
25
+ if (version !== im.instanceMatrix.version) { version = im.instanceMatrix.version; im.computeBoundingBox(); }
26
+ return im.boundingBox;
27
+ });
21
28
  return im;
22
29
  }
23
30
 
@@ -60,6 +67,7 @@ export function leave(B, g, e) {
60
67
  /** Back to plain meshes (the group dropped under half of minCount, or batching was switched off) */
61
68
  export function dissolve(B, g) {
62
69
  for (const e of [...g.items].reverse()) leave(B, g, e);
70
+ g.watch?.remove(); g.watch = null;
63
71
  g.mesh.removeFromParent(); g.mesh.dispose(); g.mesh = null; g.colored = false;
64
72
  hold(B, g.geometry, -1); hold(B, g.material, -1);
65
73
  }
package/core/catalog.js CHANGED
@@ -5,12 +5,12 @@
5
5
  // engine.catalog('shop') -> one module expanded: dependencies, ops with args / defaults / failure codes, saved parts, time model
6
6
  // engine.catalog('shop.buy') -> one op expanded (args schema, reasons, its last attempt)
7
7
  // engine.catalog({ find: 'buy' }) -> the short list filtered by id, label, op or save name
8
+ // engine.catalog('post') -> a capability that is no module (post chain, shadows): its entry names and what it holds now
8
9
  // Ownership: engine.use / module init take a snapshot of the op, save and describe names before and after (catalogSnap / catalogClaim);
9
10
  // what existed before the first engine.use is 'core', what appeared outside any module is 'game'. An op named '<module>.verb' or a save
10
11
  // part keyed by the module name belongs to that module even when registered later (from game code calling into the module).
11
12
  import { parseSchema, schemaInfo } from './params.js';
12
13
  import { ENGINE_PARAMS } from './Engine.js';
13
- import { lookCatalog, lookSummaries } from './look/report.js';
14
14
 
15
15
  const TIME_HOOKS = ['fixed', 'frame', 'afterRender', 'skip', 'afterLoad'];
16
16
  const MAX_API = 200; // the dev bridge narrows this to what the api page lists (tools/threedog/catalog.mjs)
@@ -127,6 +127,17 @@ function looseEntry(e, id) {
127
127
  ...(id === 'core' ? { params: paramsOf({ name: 'core', params: ENGINE_PARAMS, options: e._createParams }) } : {}) };
128
128
  }
129
129
 
130
+ // Not modules, but a reader asks for them the same way. Read live from the object, so nothing here can drift
131
+ const CAPABILITIES = {
132
+ post: e => ({ describe: 'describe().render', facts: { antialias: e.post.antialias, ownedByGame: !e.post._own.on,
133
+ effects: e.post._list.map(h => ({ name: h.name, slot: h.slot, order: h.order, enabled: h.enabled, params: Object.fromEntries(Object.entries(h.params).map(([k, v]) => [k, toData(v)])) })) } }),
134
+ shadows: e => ({ describe: 'describe().picture', facts: { enabled: e.shadows.enabled, cascades: !!e.shadows.csm } }),
135
+ };
136
+ function capabilityEntry(e, id) {
137
+ const { describe, facts } = CAPABILITIES[id](e);
138
+ return { id, kind: 'capability', ops: [], saves: [], queries: { describe, extra: [], api: apiNames(e[id]) }, facts, problems: [] };
139
+ }
140
+
130
141
  function summary(x) {
131
142
  const s = { id: x.id, kind: x.kind };
132
143
  if (x.label) s.label = x.label;
@@ -142,6 +153,7 @@ function summary(x) {
142
153
  function entries(e) {
143
154
  const out = [...e.modules.values()].map(m => moduleEntry(e, m));
144
155
  for (const id of ['core', 'game']) { const x = looseEntry(e, id); if (x.ops.length || x.saves.length || x.queries.extra.length) out.push(x); }
156
+ for (const id of Object.keys(CAPABILITIES)) if (e[id] && !e.modules.has(id)) out.push(capabilityEntry(e, id));
145
157
  return out;
146
158
  }
147
159
 
@@ -150,6 +162,7 @@ function entries(e) {
150
162
  * No argument: a short list (id, state, stage, op and save names, time model, problem count). A module id: that module expanded
151
163
  * (requires / optional, params with defaults and the values in use, ops with args schema and failure codes, saved parts and versions,
152
164
  * time hooks, describe fields and api names, problems such as "fixed hook but no skip hook"). An op name: that op expanded, with its last attempt.
165
+ * 'post' or 'shadows': that capability's entry names and what it holds now (effects in the chain, cascades on or off).
153
166
  * The dev bridge `threedog catalog [id]` prints the same data and adds the doc, recipe and source files.
154
167
  * @param {string | { find?: string }} [id]
155
168
  * @returns {any}
@@ -163,10 +176,10 @@ export function catalog(e, id) {
163
176
  if (e.modules.has(id)) return moduleEntry(e, e.modules.get(id));
164
177
  if (e.ops.defs.has(id)) return opInfo(e, id, true);
165
178
  if (id === 'core' || id === 'game') return looseEntry(e, id);
166
- if (id === 'look' || id.startsWith('look.')) return lookCatalog(e, id); // look parts (look/part.js): params with why / off, hooks, replace contract
179
+ if (id in CAPABILITIES && e[id]) return capabilityEntry(e, id);
167
180
  return null;
168
181
  }
169
- const list = [...entries(e).map(summary), ...lookSummaries(e)];
182
+ const list = entries(e).map(summary);
170
183
  const q = id?.find?.toLowerCase();
171
184
  return q ? list.filter(s => [s.id, s.label, ...s.ops, ...s.saves].some(x => x?.toLowerCase().includes(q))) : list;
172
185
  }
@@ -22,7 +22,7 @@ export class ChunkStream {
22
22
  this._byDist = (a, b) => this._d2(a) - this._d2(b);
23
23
  }
24
24
 
25
- /** Ring of a chunk from the nearest source; a 'simple' source counts as the outer ring (far look, no near detail) */
25
+ /** Ring of a chunk from the nearest source; a 'simple' source counts as the outer ring (far picture, no near detail) */
26
26
  ring(c) {
27
27
  let r = Infinity;
28
28
  for (const s of this.centers) r = Math.min(r, Math.max(Math.abs(c.cx - s.cx), Math.abs(c.cz - s.cz), s.simple ? this.table.viewChunks : 0));
package/core/copies.js CHANGED
@@ -6,7 +6,7 @@
6
6
  // A hot reload re-runs the same file (same path, a ?t= query): that is one copy, not two, so the path without the query decides.
7
7
  import { coded } from './errorHints.js';
8
8
 
9
- export const VERSION = '0.5.0'; // kept equal to package.json by the "[guard] engine copies" spec
9
+ export const VERSION = '0.7.0'; // kept equal to package.json by the "[guard] engine copies" spec
10
10
 
11
11
  const KEY = Symbol.for('threedog.engine.copies');
12
12
 
package/core/debugView.js CHANGED
@@ -1,7 +1,7 @@
1
1
  // Diagnostic view modes behind engine.debug.view('albedo' | 'lighting' | 'shadow' | 'normals' | 'overdraw' | 'shaderCost' | 'off') (DebugOverrides.js).
2
2
  // Temporary and owner-scoped: it changes how the scene is drawn (material swap / scene.overrideMaterial / lights hidden) and puts everything back on 'off'
3
3
  // or when its owner clears (engine.debug.clear(owner)). Never saved, never part of the game's state; describe().render says so while one is active,
4
- // so an AI reading a screenshot does not take "all white clay" for the real look.
4
+ // so an AI reading a screenshot does not take "all white clay" for the real picture.
5
5
  // Why a view is an entry of the debug override chain and not its own material swap: two independent swaps on one mesh restored each other's stale
6
6
  // material and disposed the real one (review H3). In the chain, the albedo view is a { material: 'flat' } entry on the scene and the other modes an apply()
7
7
  // entry whose undo only puts back what it changed, and only disposes the override material it created.
@@ -24,7 +24,7 @@ const EXPLAIN = {
24
24
  lighting: 'every surface plain white matte: shows only what the lights do (no textures)',
25
25
  shadow: 'plain white matte lit by direct lights only (ambient and hemisphere lights hidden, environment map off): shadows read as black',
26
26
  normals: 'surface normals as color (x/y/z -> r/g/b); a normal map shows here, flat shading looks faceted',
27
- overdraw: 'every drawn layer adds a little orange, depth test off: bright = many surfaces drawn over each other on that pixel (transparent foliage, particles, stacked planes)',
27
+ overdraw: 'every drawn layer adds a little orange, depth test off: bright = many layers drawn over each other on that pixel (transparent foliage, particles, stacked planes)',
28
28
  shaderCost: 'each material colored by its compiled program cost (fragment code lines + samplers, approximate): green cheap, red the costliest in this scene, gray not compiled yet',
29
29
  };
30
30
  const OVERDRAW = 0x1a0c04; // per layer: ~10 layers of it reach white
@@ -91,7 +91,7 @@ export class DebugView {
91
91
  /** @param {any} engine @param {any} debug the engine.debug override chain it lives in */
92
92
  constructor(engine, debug) {
93
93
  this.engine = engine; this.debug = debug;
94
- /** @type {{ mode: string, owner: string } | null} the active view (null = the real look) */
94
+ /** @type {{ mode: string, owner: string } | null} the active view (null = the real picture) */
95
95
  this.active = null;
96
96
  this._holder = engine.stacks.define('debug.view', { kind: 'top', save: false });
97
97
  this._entry = null;
@@ -112,7 +112,7 @@ export class DebugView {
112
112
  /** Every mode a view can show now: the built-in ones and those modules added @returns {string[]} */
113
113
  modes() { return [...VIEW_MODES, ...this._defs.keys()]; }
114
114
  /**
115
- * Show a diagnostic view; 'off' restores the real look. Temporary: never saved, and a game that reads it must not branch on it.
115
+ * Show a diagnostic view; 'off' restores the real picture. Temporary: never saved, and a game that reads it must not branch on it.
116
116
  * owner names who asked ('debug' by default): while one owner's view is on, another owner can neither switch it nor turn it off unless it passes force.
117
117
  * @param {'albedo' | 'lighting' | 'shadow' | 'normals' | 'overdraw' | 'shaderCost' | 'off' | string} mode a built-in mode or one a module added (defineView)
118
118
  * @param {{ owner?: string, force?: boolean }} [opts]