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
@@ -28,17 +28,17 @@ import { xzOf } from '../../core/math.js';
28
28
  import { placeY } from '../../core/ground.js';
29
29
  import { buildModel, settle, fitKey, unbuildModel } from './models.js';
30
30
  import { srcOf, stateful, templateId } from './ids.js';
31
- import { PLACEMENT_FIELDS } from './rules.js';
31
+ import { PLACEMENT_FIELDS, collideProblem } from './rules.js';
32
32
  import { fieldsShape } from './fields.js';
33
33
  import { whyBad, readParams, keysSchema } from '../../core/params.js';
34
34
  import { stagesProblems, stagedFields, growStages } from './stages.js';
35
35
  import { codedError } from '../../core/errorHints.js';
36
36
 
37
- const DEF_KEYS = ['model', 'collide', 'static', 'interact', 'container', 'sound', 'animate', 'state', 'fields', 'body', 'stages', 'update', 'canGrow'];
37
+ const DEF_KEYS = ['model', 'collide', 'occluder', 'static', 'interact', 'container', 'sound', 'animate', 'state', 'fields', 'body', 'stages', 'update', 'canGrow'];
38
38
  const BODY_KEYS = ['shape', 'mass', 'friction', 'restitution', 'damping', 'angularDamping'];
39
39
  // what a placement may set besides the state fields: the placement field table (rules.js), so the loader, content-check and content.fields() agree
40
40
  const PLACE_KEYS = Object.keys(PLACEMENT_FIELDS['props.template']);
41
- // content.spawn gets its position as an argument, so only the id and the look / goods keys of the same table
41
+ // content.spawn gets its position as an argument, so only the id and the picture / goods keys of the same table
42
42
  const SPAWN_KEYS = PLACE_KEYS.filter(k => !['template', 'place', 'x', 'z', 'floor'].includes(k));
43
43
 
44
44
  const STRINGS = {
@@ -63,6 +63,8 @@ export function defineTemplates(e, api, st, defs) {
63
63
  for (const [name, d] of Object.entries(defs)) {
64
64
  readParams(`template '${name}'`, keysSchema(DEF_KEYS), d);
65
65
  if (!d?.model) throw codedError('content-template', fmt(STRINGS.noModel, { name }));
66
+ const collide = collideProblem(d.collide);
67
+ if (collide) throw codedError('content-template', `template '${name}': collide ${collide}`);
66
68
  if (d.interact) {
67
69
  readParams(`template '${name}' interact`, keysSchema(['label', 'op', 'radius', 'height', 'action', 'enabled']), d.interact);
68
70
  // why a throw and not the usual unknown-key warning: a callback here would be a second, unlogged way to change saved state
@@ -9,10 +9,13 @@
9
9
  // How the one in front of you is chosen is the pick option: 'nearest' | 'facing' | 'aim' | a function (see interactions()). Each action is picked on its own,
10
10
  // so one object can carry "Open" and "Lock" as two interactions with different action names (each bound to the game's own key).
11
11
  // The prompt is the UI part 'prompt' (default interactionPrompt.js, CSS class .threedog-prompt): replace it or turn it off with engine.ui.set('prompt', ...);
12
- // prompt height style.ui.promptHeight (meters)
12
+ // prompt height interactions({ promptHeight }) (meters)
13
13
  // hold: seconds turns the press into "keep it down": the engine counts progress on fixed steps and interrupts it on release, leaving reach, disabled or
14
14
  // locked input, in one place, so no game re-writes a hold timer per verb; the prompt part gets progress 0-1 to draw.
15
15
  // approach: true walks the actor's character there first (walkTo), then uses it: point-and-click, "talk to the shopkeeper across the room".
16
+ // once: true hides the object after a use that went through and it stays gone; counter: 'shells' adds 1 to that HUD counter (optional: engine.hud?.). So a
17
+ // mesh the game already built is a pick-and-count thing with no world record or bag; what was used is this module's save part, because a thing that comes
18
+ // back after a load while the count does not would be silently lost progress. Things that go in a bag, respawn or are decided by a net host: pickups.js.
16
19
  // Finding candidates goes through one shared xz index (core/cells.js) keyed by each item's actual world position, instead of measuring every interaction
17
20
  // each frame. Before a pick pass reads it, items that follow an object are re-filed if they moved: for an object straight under the scene (models, pickups,
18
21
  // hand-placed meshes) the check is its local position against the last one seen, so a still crowd costs a few compares; a nested one (a part of a vehicle)
@@ -25,6 +28,7 @@ import { promptPart } from './interactionPrompt.js';
25
28
 
26
29
  import { readParams, keysSchema } from '../../core/params.js';
27
30
  import { codedError } from '../../core/errorHints.js';
31
+ import { DEV } from '../../core/validate.js';
28
32
  import { vec3 } from '../../core/math.js';
29
33
  import { Cells } from '../../core/cells.js';
30
34
 
@@ -38,6 +42,10 @@ const V = new THREE.Vector3(), W = new THREE.Vector3(), O = new THREE.Vector3(),
38
42
  // when the circle covers more cells than exist)
39
43
  const CELL = 8;
40
44
 
45
+ // The line that makes an action usable; the preset only for the action it covers. The message carries it because this fault looks like a working game to
46
+ // every other tool, so whoever hits it needs the fix on the spot.
47
+ const bindLine = action => action === 'interact' ? 'createEngine({ bindings: { ...presets.bindings.interact } }), or engine.input.bind(presets.bindings.interact) (E / gamepad X)'
48
+ : `engine.input.bind('${action}', ['KeyX'])`;
41
49
  const SETUP_FIX = "e.g. engine.use(interactions({ ...presets.interactions.nearest })) (import { presets } from 'threedog'), or interactions({ pick: 'nearest' | 'facing' | 'aim' | fn })";
42
50
 
43
51
  export class Interactions {
@@ -50,7 +58,7 @@ export class Interactions {
50
58
  this.engine = engine;
51
59
  this.action = action;
52
60
  this.radius = radius;
53
- this.promptHeight = promptHeight ?? engine.style.ui?.promptHeight ?? 2.4;
61
+ this.promptHeight = promptHeight ?? 2.4;
54
62
  /**
55
63
  * How the interaction in front of the actor is chosen; can be swapped at runtime (first person: 'aim', top-down: 'nearest') @type {'nearest' | 'facing' |
56
64
  * 'aim' | Function}
@@ -81,6 +89,10 @@ export class Interactions {
81
89
  this._shown = false;
82
90
  /** The hold in progress { id, action, seconds, progress (0-1) }, null when none. Read-only: releasing the key stops it @type {any} */
83
91
  this.holding = null;
92
+ /** @internal dev: an add since the last key check */ this._keysDue = false;
93
+ /** @internal ids of the once items already used; _counted: counter name -> what uses added. The saved state, so both follow a load and a new game */
94
+ this._spent = new Set(); this._counted = new Map();
95
+ engine.saves.register('interactions', { version: 1, save: () => ({ spent: [...this._spent], counted: Object.fromEntries(this._counted) }), load: d => this._load(d) });
84
96
  }
85
97
 
86
98
  /**
@@ -90,38 +102,73 @@ export class Interactions {
90
102
  * radius defaults to interactions({ radius }) (2.5 m; Infinity = from anywhere, usually with approach). Add two with different actions to give one object
91
103
  * two verbs. hold: seconds the key must stay down (progress goes to the prompt; release, leaving reach or disabled interrupts it: interaction:interrupt).
92
104
  * approach: true walks the player there first (walkTo, stops 1.2 m away), then uses it. Returns a handle { remove() }.
105
+ * once: true hides the object after a use and it cannot be used again (onUse returning { ok: false } leaves it); saved, and back on a new game. The save
106
+ * knows it by id, else the object's name; development throws when it has neither. counter: name of a HUD counter that each use
107
+ * adds 1 to (hud.add; nothing without hud()); declare it once at setup with hud.counter(name, { label, value: 0, max }), not on session:start.
93
108
  * label, enabled and onUse are called with (object, { actor }): actor is the world record id of who asks / uses it (engine.actor for the local user,
94
109
  * a net peer's or an NPC's id when they run interaction.use), so per-actor rules never read engine.player.
95
110
  * @example engine.interactions.add(door, { label: (o, { actor }) => owns(actor) ? 'Open' : 'Knock', onUse: (o, { actor }) => engine.ops.run('door.open', { id: o.name }, { actor }) });
96
111
  * @example engine.interactions.add(door, { label: 'Open', onUse: open });
97
112
  * engine.interactions.add(door, { label: 'Lock', action: 'lock', enabled: () => hasKey, onUse: lock }); // a second verb: define the 'lock' action's key
98
113
  * first
114
+ * @example engine.interactions.add(shell, { id: 'shell-1', label: 'Pick up', once: true, counter: 'shells' }); // a mesh you built: gone after E, counted
99
115
  * @example engine.interactions.add(well, { label: 'Pump', hold: 1.5, onUse: fill }); // keep E down 1.5 s
100
116
  * engine.interactions.add(clerk, { label: 'Talk', radius: Infinity, approach: true, onUse: talk }); // from anywhere: walk over, then talk
101
117
  * @example // onUse may return a result; interaction.use hands it back as value. Returning { ok: false, code } (failure(code)) fails the op with that code:
102
118
  * const r = engine.ops.run('interaction.use'); if (!r.ok) say(r.code) // 'full' for a pickup in a full bag
103
119
  */
104
120
  add(target, opts = {}) {
105
- readParams('interactions.add()', keysSchema(['id', 'label', 'radius', 'action', 'onUse', 'enabled', 'height', 'hold', 'approach']), opts);
106
- const { label = '', radius = this.radius, action = this.action, onUse, enabled = () => true, height, hold = 0, approach = false } = opts;
121
+ readParams('interactions.add()', keysSchema(['id', 'label', 'radius', 'action', 'onUse', 'enabled', 'height', 'hold', 'approach', 'once', 'counter']), opts);
122
+ const { label = '', radius = this.radius, action = this.action, onUse, enabled: allowed = () => true, height, hold = 0, approach = false, once = false, counter } = opts;
107
123
  if (!(typeof hold === 'number' && hold >= 0)) throw codedError('interaction-option', `interactions.add(): hold is the seconds the key stays down (hold: 1.5), got ${JSON.stringify(hold)}`, TypeError);
108
124
  if (!(radius > 0)) throw codedError('interaction-option', `interactions.add(): radius is meters > 0 (Infinity = from anywhere), got ${radius}`, TypeError);
109
- // stable id for the interaction.use op: given, else the world record being built (pickup, NPC, entity), else a running number
110
- let id = opts.id ?? this.engine.world?.buildingId ?? 'interaction' + (++this._seq);
125
+ if (counter !== undefined && !(typeof counter === 'string' && counter)) throw codedError('interaction-option', `interactions.add(): counter is the name of a HUD counter (counter: 'shells'), got ${JSON.stringify(counter)}`, TypeError);
126
+ // stable id for the interaction.use op: given, else the world record being built (pickup, NPC, entity), else (once: the save knows it by id) the mesh's
127
+ // name, else a running number. The number counts adds over the page's life, so it means another thing after a rebuild: a once item kept under one
128
+ // comes back after a load while its count stays, or hides the wrong thing. So once refuses it in development, where the fix is one word
129
+ let id = opts.id ?? this.engine.world?.buildingId ?? (once && target?.name || null);
130
+ if (once && DEV && (id == null || this.get(id))) throw codedError('interaction-option', `interactions.add(): a once item is saved by its id, and this one has ${id == null ? 'none' : `the same id as another ('${id}')`}. Give each a stable one: { id: 'shell-3', once: true }, or set mesh.name`, TypeError);
131
+ id ??= 'interaction' + (++this._seq);
111
132
  if (this.get(id)) id += '#' + (++this._seq);
112
133
  let object = target;
113
134
  if (!target?.isObject3D) { object = new THREE.Object3D(); vec3(target, object.position); }
114
135
  // a fixed position never moves: its world position is known now; an object is measured once per pass (_at)
115
- const it = { id, object, label, radius, action, onUse, enabled, height, hold, approach: !!approach, _p: new THREE.Vector3(), _at: target?.isObject3D ? -1 : Infinity,
136
+ // a used once item is simply not enabled: pick, the hold, describe and the op's can all ask enabled, so none of them needs a rule of its own
137
+ const enabled = once ? (o, c) => !this._spent.has(id) && allowed(o, c) : allowed;
138
+ const it = { id, object, label, radius, action, onUse, enabled, height, hold, approach: !!approach, once: !!once, counter, _p: new THREE.Vector3(), _at: target?.isObject3D ? -1 : Infinity,
116
139
  _n: this._order++, _en: null, _ix: null, _lx: NaN, _lz: NaN, _par: undefined };
117
140
  if (!target?.isObject3D) it._p.copy(object.position);
141
+ if (once && this._spent.has(id)) object.visible = false; // added again after a load (a level rebuilt): still gone
118
142
  this._byId.set(id, it);
119
143
  this._index(it);
120
144
  return { remove: () => { if (it._gone) return; it._gone = true; this._byId.delete(it.id); this._unindex(it); if (this.current === it) this.current = null; } };
121
145
  }
146
+ /** @internal Every use ends here (key, click, hold, approach, op): once and counter count only a use that went through */
147
+ _run(it, actor) {
148
+ const r = it.onUse?.(it.object, { actor });
149
+ if (r?.ok === false) return r;
150
+ if (it.counter && this.engine.hud) { this.engine.hud.add(it.counter); this._counted.set(it.counter, (this._counted.get(it.counter) ?? 0) + 1); }
151
+ // shortcut: once lives on the local peer (interaction.use is net: 'local'); a thing all peers share in a net game is a pickup (the host decides)
152
+ if (it.once) { this._spent.add(it.id); it.object.visible = false; }
153
+ return r;
154
+ }
155
+ /**
156
+ * @internal Load or new game. A counter gets the difference, not a value: its base is the game's (hud.counter(name, { value })), this module only knows
157
+ * what uses added. Only things whose state changed are shown or hidden: a once item the game hid itself stays hidden
158
+ */
159
+ _load({ spent, counted }) {
160
+ const was = this._spent; this._spent = new Set(spent);
161
+ for (const it of this._byId.values()) if (it.once && was.has(it.id) !== this._spent.has(it.id)) it.object.visible = !this._spent.has(it.id);
162
+ for (const name of new Set([...this._counted.keys(), ...Object.keys(counted)])) {
163
+ const d = (counted[name] ?? 0) - (this._counted.get(name) ?? 0);
164
+ if (d) this.engine.hud?.add(name, d);
165
+ }
166
+ this._counted = new Map(Object.entries(counted));
167
+ }
122
168
  /** @internal File a new item: unbounded reach in the plain list, else in the cells (a followed one is placed for real on the next refresh) */
123
169
  _index(it) {
124
170
  this._actions.set(it.action, (this._actions.get(it.action) ?? 0) + 1);
171
+ this._keysDue = true;
125
172
  if (it.radius === Infinity) { this._wide.add(it); return; }
126
173
  // a fixed one is filed at its position; a followed one at its own xz (_ix), apart from _p, the exact per-pass measurement
127
174
  it._en = { id: '#' + it._n, position: it._at === Infinity ? it._p : (it._ix = { x: NaN, z: NaN }), it };
@@ -274,20 +321,33 @@ export class Interactions {
274
321
  this._pass = ++this._passes;
275
322
  try { this._update(); } finally { this._pass = 0; }
276
323
  }
324
+ /**
325
+ * @internal Dev: an interaction whose action has no key cannot be reached by any player, yet everything else about it works, so nothing else would say so.
326
+ * Thrown from the frame hook, it freezes gameplay and shows in engine.error, describe() and the test tools. Only once running: code right after
327
+ * `await engine.start()` may still bind. Release builds skip it; there the op and the prompt still say so.
328
+ */
329
+ _checkKeys() {
330
+ this._keysDue = false;
331
+ for (const a of this._actions.keys()) {
332
+ if (this.engine.input.isUnbound(a)) throw codedError('interaction-no-key', `interactions: action '${a}' has no key, so the player can never use what was added to it. Add: ${bindLine(a)}`);
333
+ }
334
+ }
277
335
  /** @internal */
278
336
  _update() {
337
+ if (DEV && this._keysDue && this.engine.phase === 'running') this._checkKeys();
279
338
  this.options.length = 0;
280
339
  const best = this.current = this._actions.size > 1 ? this._perAction() : this.pick();
281
340
  if (best && this._actions.size === 1) this.options.push({ action: best.action, id: best.id, label: labelOf(best, this.engine.actor) });
282
341
  const input = this.engine.input;
283
342
  const part = this.engine.ui.get('prompt');
284
343
  if (!best || !input.enabled || !part) { if (this._shown) part?.hide(); this._shown = false; return; }
285
- const label = labelOf(best, this.engine.actor), key = input.label(best.action);
344
+ // never an empty name: an action that needs a key says it has none; one with no key on purpose (a touch button, click only) shows just its label
345
+ const label = labelOf(best, this.engine.actor), key = input.label(best.action) || (input.isUnbound(best.action) ? this.engine.t('input.noKey') : '');
286
346
  best.object.getWorldPosition(V); V.y += best.height ?? this.promptHeight;
287
347
  const s = worldToScreen(this.engine, V);
288
348
  // progress: the running hold on this one (0-1), 0 for a hold not started, null for a plain press
289
349
  const progress = this.holding?.id === best.id ? this.holding.progress : best.hold > 0 ? 0 : null;
290
- part.update({ id: best.id, action: best.action, key, label, text: `${key} · ${label}`, x: s.x, y: s.y, onScreen: s.onScreen, use: this._use, options: this.options, progress });
350
+ part.update({ id: best.id, action: best.action, key, label, text: key ? `${key} · ${label}` : label, x: s.x, y: s.y, onScreen: s.onScreen, use: this._use, options: this.options, progress });
291
351
  this._shown = true;
292
352
  }
293
353
  /** @internal Several actions: fill options, return the default action's pick (else the first found) for the prompt */
@@ -332,17 +392,30 @@ const INTERACTION_PARAMS = {
332
392
  export function interactions(opts) {
333
393
  const o = readParams('interactions', INTERACTION_PARAMS, opts ?? {});
334
394
  let i = null;
335
- return { name: 'interactions', type: 'rules', provides: ['interactions'], label: 'Interactions', params: INTERACTION_PARAMS, options: o, noSkip: 'input and prompt state only', stage: 'gameplay',
395
+ return { name: 'interactions', type: 'rules', provides: ['interactions'], optional: ['hud'], label: 'Interactions', params: INTERACTION_PARAMS, options: o, noSkip: 'input and prompt state only', stage: 'gameplay',
336
396
  // o: the schema defaults are filled in, the class repeats none
337
397
  install(e, ctx) { e.i18n.add({ 'zh-CN': { 'module.interactions': '交互' }, en: { 'module.interactions': 'interactions' } }); i = new Interactions(e, o, ctx.track); defineUse(e, i); return i; },
338
398
  fixed(dt) { i.fixed(dt); }, frame() { i.update(); },
339
399
  // interactions are "weak" info: when an NPC, pickup or entity already reported the same object, only add "interactable: xxx"
340
400
  describe(e, ctx) {
341
- for (const it of i._byId.values()) if (it.enabled(it.object, { actor: e.actor })) { const use = labelOf(it, e.actor); ctx.near(it.object, { name: use, kind: 'interactable', use }, true); }
401
+ // no key: not "interactable", and no plain "interact: X" on an NPC's line, because no player input reaches it
402
+ for (const it of i._byId.values()) if (it.enabled(it.object, { actor: e.actor })) {
403
+ const name = labelOf(it, e.actor), noKey = e.input.isUnbound(it.action);
404
+ ctx.near(it.object, { name, kind: noKey ? 'noKey' : 'interactable', use: noKey ? `${name} (no key bound for '${it.action}')` : name }, true);
405
+ }
342
406
  if (i.current) return { current: labelOf(i.current, e.actor) };
343
407
  } };
344
408
  }
345
409
 
410
+ /**
411
+ * What keeps input locked, for the inputLocked result: a bare code sent a script through describe to learn that the title was still up.
412
+ * by: the top opaque input context without its ui- / win- prefix ('title', 'settings', 'dialogue', 'cutscene', a game's own context).
413
+ */
414
+ function lockFacts(e) {
415
+ const top = (e.input.holders ?? []).filter(h => !h.pass).at(-1)?.context ?? 'unknown', by = top.replace(/^(ui|win)-/, '');
416
+ return by === 'title' ? { by, fix: "start a run: engine.applyState({ play: true }) or threedog state play=1 (session.newGame() alone leaves the title open)" } : { by };
417
+ }
418
+
346
419
  /** The engine op interaction.use { id?, action? }: what the interact key, the prompt click, the dev bridge and tests all run */
347
420
  function defineUse(e, i) {
348
421
  const find = (id, action, ctx) => id !== undefined ? i.get(id) : i.pick(ctx.actor, action);
@@ -354,7 +427,9 @@ function defineUse(e, i) {
354
427
  const it = find(id, action, ctx);
355
428
  if (!it) return id === undefined ? 'nothingNear' : 'unknown';
356
429
  if (!it.enabled(it.object, { actor: ctx.actor })) return 'disabled';
357
- if (ctx.actor === e.actor && !e.input.enabled) return 'inputLocked';
430
+ // the local player only: a net peer or an NPC does not go through this page's keys. The bridge and tests are refused too, so `ops` never shows a ✓ no player can do
431
+ if (ctx.actor === e.actor && e.input.isUnbound(it.action)) return { code: 'noKey', facts: { action: it.action, fix: bindLine(it.action) } };
432
+ if (ctx.actor === e.actor && !e.input.enabled) return { code: 'inputLocked', facts: lockFacts(e) };
358
433
  if (it.approach && !walkerOf(e, ctx.actor)) return 'cannotWalk';
359
434
  const p = e.actorPosition(ctx.actor);
360
435
  if (it.approach || !p) return true;
@@ -367,13 +442,13 @@ function defineUse(e, i) {
367
442
  // approach from afar: the value is { approaching } (a Promise of onUse's result after arrival, or the walk's { status } when it did not arrive)
368
443
  run(e, { id, action }, ctx) {
369
444
  const it = find(id, action, ctx);
370
- if (!it.approach) return it.onUse?.(it.object, { actor: ctx.actor });
445
+ if (!it.approach) return i._run(it, ctx.actor);
371
446
  const ch = walkerOf(e, ctx.actor), q = it.object.getWorldPosition(new THREE.Vector3());
372
- if (Math.hypot(q.x - ch.position.x, q.z - ch.position.z) <= APPROACH_ARRIVE + 0.3) return it.onUse?.(it.object, { actor: ctx.actor });
447
+ if (Math.hypot(q.x - ch.position.x, q.z - ch.position.z) <= APPROACH_ARRIVE + 0.3) return i._run(it, ctx.actor);
373
448
  // used after arrival, so checked again then: removed or disabled while walking = not used
374
- return { approaching: ch.walkTo(q, { arrive: APPROACH_ARRIVE }).then(r => r.status === 'arrived' && !it._gone && it.enabled(it.object, { actor: ctx.actor }) ? it.onUse?.(it.object, { actor: ctx.actor }) : r) };
449
+ return { approaching: ch.walkTo(q, { arrive: APPROACH_ARRIVE }).then(r => r.status === 'arrived' && !it._gone && it.enabled(it.object, { actor: ctx.actor }) ? i._run(it, ctx.actor) : r) };
375
450
  },
376
451
  offers(e, ctx) { const it = find(undefined, undefined, ctx); return it ? [{ id: it.id }] : []; },
377
- reasons: { unknown: 'No interaction with this id', nothingNear: 'No interaction in range', disabled: 'Its enabled() is false', tooFar: 'Actor is outside its radius', cannotWalk: 'approach walks the player; this actor has no character to walk', inputLocked: 'A window or dialogue locks input' },
452
+ reasons: { unknown: 'No interaction with this id', noKey: 'Its action has no key bound, so the player cannot reach it', nothingNear: 'No interaction in range', disabled: 'Its enabled() is false', tooFar: 'Actor is outside its radius', cannotWalk: 'approach walks the player; this actor has no character to walk', inputLocked: 'A title, window, dialogue or cutscene locks input; facts.by names it' },
378
453
  });
379
454
  }
@@ -10,9 +10,9 @@
10
10
  // Chest / corpse / shelf: inventory.container('chest-1', { capacity: 8 }).add('fish'); inventory.transfer('chest-1', 'player', 'fish', 2);
11
11
  // Player actions with items are ops: inventory.transfer / inventory.use / inventory.drop (inventoryOps.js).
12
12
  //
13
- // Look:
14
- // window UI part 'inventory' (engine.ui.set('inventory', false | { drop: true } | yourPart)); body via style.ui.templates.inventory(data, { esc, t, icon })
15
- // list styling CSS classes .threedog-win-inventory .threedog-row ... (override in style.ui.css)
13
+ // Picture:
14
+ // window UI part 'inventory' (engine.ui.set('inventory', false | { drop: true } | yourPart)); body via ui.templates.inventory(data, { esc, t, icon })
15
+ // list styling CSS classes .threedog-win-inventory .threedog-row ... (override in ui.css)
16
16
  import { checkOptions, warnMissing, freezeDef } from '../../core/validate.js';
17
17
  import { readParams } from '../../core/params.js';
18
18
  import { codedError } from '../../core/errorHints.js';
@@ -1,7 +1,7 @@
1
1
  // Default 'dialogue' UI part: a box at the bottom with the speaker, the typed text, numbered choice buttons (the one under the choice cursor has
2
2
  // .is-cursor) and a "continue" hint.
3
3
  // It only draws what Dialogue hands it; a click calls d.advance() / d.choose(i), which run the ops dialogue.advance / dialogue.choose.
4
- // Look: CSS classes .threedog-dlg* (style.ui.css). A whole different box: engine.ui.set('dialogue', yourPart) (recipes/26-ui-parts.md).
4
+ // Picture: CSS classes .threedog-dlg* (ui.css). A whole different box: engine.ui.set('dialogue', yourPart) (recipes/26-ui-parts.md).
5
5
  import { injectUICSS } from '../../ui/UI.js';
6
6
  /** @import { Engine, UIPart } from '../../types/core' */
7
7
  /** @import { DialogueView } from '../../types/gameplay' */
@@ -11,7 +11,7 @@ import { injectUICSS, worldToScreen, placeAt, esc } from '../../ui/UI.js';
11
11
  /** @import { Engine, UIPart } from '../../types/core' */
12
12
 
13
13
  const CSS = `
14
- .threedog-bubble{position:absolute;left:0;top:0;transform:translate(-50%,-100%);max-width:240px;padding:6px 10px;border-radius:10px;background:var(--threedog-bg);color:var(--threedog-fg);font:14px/1.35 var(--threedog-font);pointer-events:none;box-shadow:0 2px 8px rgba(0,0,0,.25)}
14
+ .threedog-bubble{position:absolute;left:0;top:0;transform:translate(-50%,-100%);max-width:240px;padding:6px 10px;border-radius:var(--threedog-radius-small);background:var(--threedog-bg);color:var(--threedog-fg);font:14px/1.35 var(--threedog-font);pointer-events:none;box-shadow:var(--threedog-shadow-small)}
15
15
  .threedog-bubble b{display:block;font-size:12px;opacity:.75}
16
16
  .threedog-bubbles-screen{position:absolute;left:50%;bottom:22%;transform:translateX(-50%);display:flex;flex-direction:column;align-items:center;gap:6px;pointer-events:none}
17
17
  .threedog-bubbles-screen .threedog-bubble{position:static;transform:none}
@@ -1,5 +1,5 @@
1
1
  // Default 'prompt' UI part: the "E · Talk" label that follows the nearest interaction. Interactions picks the target and projects it to the screen;
2
- // this only draws { x, y, text } and turns a click into view.use() (the op interaction.use). Look: CSS class .threedog-prompt (style.ui.css).
2
+ // this only draws { x, y, text } and turns a click into view.use() (the op interaction.use). Picture: CSS class .threedog-prompt (ui.css).
3
3
  import { injectUICSS, placeAt } from '../../ui/UI.js';
4
4
  /** @import { Engine, UIPart } from '../../types/core' */
5
5
  /** @import { PromptView } from '../../types/gameplay' */
@@ -5,7 +5,7 @@ export default {
5
5
  api: ['add', 'get', 'pick'],
6
6
  ops: ['interaction.use'],
7
7
  events: ['interaction:hold', 'interaction:interrupt'],
8
- saves: {}, // not saved: the game / world adds interactions again when things are rebuilt on load
8
+ saves: { interactions: 1 }, // only what once / counter used; the interactions themselves the game / world adds again when things are rebuilt on load
9
9
  describe: true,
10
10
  options: { pick: 'nearest' }, // the probe needs no key (the game binds it in real use)
11
11
  probe: {
@@ -23,7 +23,7 @@ export function windowData(inv) {
23
23
 
24
24
  /**
25
25
  * Default 'inventory' part: the list window. Rows of items with a use function get a Use button; options.drop adds a Drop button. Buttons run ops.
26
- * The style can replace the body with style.ui.templates.inventory(data, { esc, t, icon }).
26
+ * The game can replace the body with ui.templates.inventory(data, { esc, t, icon }).
27
27
  * @internal
28
28
  */
29
29
  export function inventoryWindow(e, o = {}) {
@@ -37,7 +37,7 @@ export function inventoryWindow(e, o = {}) {
37
37
  <span class="threedog-count">×${it.count}</span>${acts}</div>`;
38
38
  };
39
39
  const draw = d => {
40
- const tpl = e.style.ui?.templates?.inventory;
40
+ const tpl = e.ui.templates.inventory;
41
41
  const body = tpl ? tpl(d, tools) : d.items.length ? `<div class="threedog-list">${d.items.map(row).join('')}</div>` : `<p class="threedog-empty">${esc(e.t('inventory.empty'))}</p>`;
42
42
  el.innerHTML = `<div class="threedog-win-head"><span>${esc(d.title)}</span><span><span class="threedog-win-hint">${esc(d.hint)}</span> `
43
43
  + `<button class="threedog-btn threedog-close" type="button">${esc(e.t('common.close'))}</button></span></div>${body}`;
@@ -10,10 +10,12 @@
10
10
  // some games turn that into a bag entry. And who touches it is any actor: the local user, a net peer on the host, an NPC; the item goes into that actor's
11
11
  // container, never a fixed 'player' bag. Taking is the op pickup.take (net: 'peer'), so a client's press is sent to the host and the host decides.
12
12
  //
13
- // Look: shape = a model name from an asset pack: model option or the item's define(id, { model }), else a model named 'pickup:<item>', else 'pickup', else a
14
- // gray box; style.pickup = { color, size, lift } (look values only); spawn(pos, { mesh }) puts the game's own object down instead.
13
+ // Picture: shape = a model name from an asset pack: model option or the item's define(id, { model }), else a model named 'pickup:<item>', else 'pickup', else a
14
+ // gray box; pickups({ color, size, lift }) for the plain values; engine.pickups.material is the three.js material the box and geometry-only models draw with;
15
+ // spawn(pos, { mesh }) puts the game's own object down instead.
15
16
  import * as THREE from 'three';
16
- import { makeMaterial } from '../../render/materials.js';
17
+ import { neutralMaterial } from '../../render/neutral.js';
18
+ import { copyPatches, isEngineMade, markEngineMade } from '../../render/patches.js';
17
19
  import { xzOf } from '../../core/math.js';
18
20
  import { placeY } from '../../core/ground.js';
19
21
  import { warnOnce } from '../../core/validate.js';
@@ -26,15 +28,19 @@ import { codedError, coded } from '../../core/errorHints.js';
26
28
 
27
29
  const STRINGS = { 'zh-CN': { 'module.pickups': '拾取物', 'pickups.take': '捡起 {name}' }, en: { 'module.pickups': 'pickups', 'pickups.take': 'Pick up {name}' } };
28
30
  const SPAWN_KEYS = ['give', 'count', 'data', 'name', 'model', 'color', 'mesh', 'respawnSeconds', 'bob', 'id', 'initial', 'zone', 'radius', 'auto'];
29
- const STYLE_KEYS = ['color', 'size', 'lift'];
30
31
  const NO_ACTORS = [];
32
+ const DEFAULT_COLOR = 0xcccccc;
31
33
  // A net host measures peers at the position they last sent (a few steps old): pickup.take allows this much beyond the radius so a fair press is not refused
32
34
  const NET_SLACK = 1;
33
35
 
34
36
  export class Pickups {
35
37
  /** @internal track: the module's ctx.track */
36
- constructor(engine, { radius = 2, showDistance = 60, takers } = {}, track) {
38
+ constructor(engine, { radius = 2, showDistance = 60, takers, color = DEFAULT_COLOR, size = 0.25, lift = 0.4 } = {}, track) {
37
39
  this.engine = engine;
40
+ /** Edge of the placeholder box (meters), read when one is built */ this.size = size;
41
+ /** Height above the ground new pickups float at (meters) */ this.lift = lift;
42
+ /** @internal */ this._material = neutralMaterial('pickup', { color });
43
+ /** @internal copies of the material for a pickup's own color or a vertex-colored geometry: 'color' or 'color:vc' -> material */ this._copies = new Map();
38
44
  /** Reach of pickups that set no radius (meters); auto pickups are taken within it */ this.radius = radius;
39
45
  /** @internal pickups float, spin and have a model only within this distance of the stream sources */ this.showDistance = showDistance;
40
46
  /**
@@ -58,6 +64,27 @@ export class Pickups {
58
64
  present(this);
59
65
  }
60
66
 
67
+ /**
68
+ * The three.js material of every placeholder box and geometry-only model. Set it to swap the look of all of them at once; it is used as given, with no patches added.
69
+ * A pickup with a color of its own (spawn({ color }), inventory.define(id, { color })) or a vertex-colored geometry draws with a copy of it carrying that color.
70
+ * A file model and a generator's own Object3D keep their materials.
71
+ * @example engine.pickups.material = new THREE.MeshStandardMaterial({ color: 0xffd24a, metalness: 0.8, roughness: 0.3 });
72
+ * @type {THREE.Material}
73
+ */
74
+ get material() { return this._material; }
75
+ set material(m) {
76
+ if (!m?.isMaterial) throw codedError('pickup-misuse', `engine.pickups.material takes a three.js material, got ${m}. Example: engine.pickups.material = new THREE.MeshStandardMaterial({ color: 0xffd24a })`);
77
+ const old = this._material;
78
+ if (m === old) return;
79
+ this._material = m;
80
+ for (const c of this._copies.values()) c.dispose();
81
+ this._copies.clear();
82
+ if (isEngineMade(old)) old.dispose(); // a material the game gave stays the game's
83
+ const w = this.engine.world;
84
+ // only what is built now: a pickup out of reach has no model, and one built later asks for the current material
85
+ for (const r of w.query({ kind: 'pickup' })) w.view(r.id)?.traverse(o => { if (o.userData.pickupColor !== undefined) /** @type {any} */ (o).material = pickupMaterial(this, o); });
86
+ }
87
+
61
88
  /**
62
89
  * Place a pickup at position. give: an item id (goes into the picker's container, inventory.of(actor); needs inventory()) or a function
63
90
  * (e, { actor, pickup }) => result for an instant effect (heal, score, power-up; no inventory needed). Returning { ok: false, code } (failure(code)) leaves it
@@ -92,7 +119,7 @@ export class Pickups {
92
119
  const data = copyData('pickups.spawn', what, opts.data);
93
120
  const def = { id, kind: 'pickup', ...(item && { item }), count, bob, ...(data && { data }), ...(name != null && { name }), ...(m != null && { model: m }), ...(color != null && { color }),
94
121
  ...(radius != null && { radius }), ...(auto && { auto: true }), ...(respawnSeconds > 0 && { respawn: respawnSeconds }), ...(zone != null && { zone }),
95
- position: [x, placeY(e, `pickups.spawn('${what}')`, x, z, refY) + (e.style.pickup?.lift ?? 0.4), z] };
122
+ position: [x, placeY(e, `pickups.spawn('${what}')`, x, z, refY) + this.lift, z] };
96
123
  const rec = initial ? w.add(def, { initial }) : id != null && w.get(id) || w.add(def); // initial data: world decides whether it exists / was deleted from the save (null)
97
124
  if (rec && (rec.kind !== 'pickup' || (rec.item ?? null) !== item)) throw codedError('pickup-prop-id', `pickup id '${id}' is already used by other data (${rec.kind}${rec.item ? ' ' + rec.item : ''}): use a different id`);
98
125
  const wid = rec?.id ?? id;
@@ -160,7 +187,7 @@ export class Pickups {
160
187
 
161
188
  const inReach = (rec, p, r) => { const dx = rec.position.x - p.x, dy = rec.position.y - (p.y ?? 0), dz = rec.position.z - p.z; return dx * dx + dy * dy + dz * dz <= r * r; };
162
189
 
163
- /** Register how pickups look and respawn (once, on install) @internal */
190
+ /** Register how pickups picture and respawn (once, on install) @internal */
164
191
  function present(pk) {
165
192
  const e = pk.engine, w = e.world;
166
193
  w.present('pickup', {
@@ -172,7 +199,7 @@ function present(pk) {
172
199
  const t = e.time.now('real'), x = rec.position.x;
173
200
  o.rotation.y = t * 1.5 + x; o.position.y = rec.position.y + Math.sin(t * 2 + x) * 0.08;
174
201
  },
175
- // only detached: a game's mesh is the game's, a model clone shares geometry / material with its prototype (protoOf), materials are shared per color;
202
+ // only detached: a game's mesh is the game's, a model clone shares geometry / material with its prototype (protoOf), the material is shared by every pickup;
176
203
  // the placeholder box is the one thing built here alone, so its geometry is freed
177
204
  dispose: (rec, o) => { o.userData.useHandle?.remove(); e.detach(o); o.traverse(c => { if (c.userData.ownGeometry) /** @type {any} */ (c).geometry.dispose(); }); },
178
205
  });
@@ -182,7 +209,7 @@ function present(pk) {
182
209
  }
183
210
 
184
211
  // A pickup's shape goes one way only: a model name from assets (same protoOf as content props / templates: file or code-generated, cache, bake and shadow rules are identical).
185
- // Name order: the pickup's own model -> the item definition's model -> 'pickup:<item id>' in assets -> 'pickup' -> neutral grey-box placeholder (warns once). Styles give no shape, only color / size / lift.
212
+ // Name order: the pickup's own model -> the item definition's model -> 'pickup:<item id>' in assets -> 'pickup' -> neutral grey-box placeholder (warns once).
186
213
  const NO_PICKUP = "pickups: no model for '{item}', so it lies on the ground as a gray box (a placeholder). Register a model in an asset pack and name it: "
187
214
  + "pickups.spawn(p, { model: 'gem' }) / inventory.define('{item}', { model: 'gem' }), or call the model 'pickup:{item}' (this item) / 'pickup' (every pickup without its own)";
188
215
  const NO_NAME = "pickups: '{item}' has model '{model}', but no asset pack registers a model of that name (engine.assets.manifest({ models: { {model}: fn | '/models/{model}.glb' } })); using the gray placeholder box";
@@ -202,21 +229,21 @@ function pickupModelName(e, item, model) {
202
229
  * file models must download and generators may read the dev cache, and none of that should make "a pickup nearby" appear a frame late.
203
230
  */
204
231
  function model(pk, rec) {
205
- const e = pk.engine, def = rec.item && e.inventory ? e.inventory.item(rec.item) : {}, st = e.style.pickup || {};
232
+ const e = pk.engine, def = rec.item && e.inventory ? e.inventory.item(rec.item) : {};
206
233
  let obj = pk._live.get(rec.id)?.mesh;
207
234
  if (obj) obj.castShadow = true; // a mesh the game passed in stays the game's; only made to cast
208
235
  else {
209
- const color = rec.color ?? def.color ?? st.color ?? 0xcccccc, name = pickupModelName(e, rec.item ?? null, rec.model ?? def.model), holder = new THREE.Group();
236
+ const color = rec.color ?? def.color ?? null, name = pickupModelName(e, rec.item ?? null, rec.model ?? def.model), holder = new THREE.Group();
210
237
  holder.name = name ?? 'pickup'; holder.userData.name = holder.name; obj = holder;
211
238
  const box = () => { // the neutral placeholder: also what a model that failed to build falls back to
212
- const size = st.size ?? 0.25, m = shadowDefaults(new THREE.Mesh(new THREE.BoxGeometry(size, size, size), pickupMaterial(pk, color, null)), {});
213
- m.userData.ownGeometry = true; holder.add(m);
239
+ const size = pk.size, m = shadowDefaults(new THREE.Mesh(new THREE.BoxGeometry(size, size, size)), {});
240
+ m.userData.ownGeometry = true; drawnBy(pk, m, color); holder.add(m);
214
241
  };
215
242
  if (!name) box();
216
243
  else protoOf(e, pk, name).then(proto => {
217
244
  const o = proto.obj.clone(); // geometry / materials stay the prototype's (shadow flags were settled once there, as for content props)
218
- // generator gave only geometry: swap in the 'pickup' role's material and the item's own color (same color shares one); generators that return a full Object3D / file models stay as they are
219
- if (proto.fromGeometry) /** @type {any} */ (o).material = pickupMaterial(pk, color, /** @type {any} */ (o).geometry);
245
+ // generator gave only geometry: draw it with the pickups material in the item's own color (same color shares one); generators that return a full Object3D / file models stay as they are
246
+ if (proto.fromGeometry) drawnBy(pk, o, color);
220
247
  holder.add(o);
221
248
  }).catch(err => { warnOnce(`pickups: model '${name}' of '${rec.item ?? rec.id}' failed to build (${err?.message ?? err}); showing the gray placeholder box`); box(); });
222
249
  }
@@ -233,12 +260,22 @@ function model(pk, rec) {
233
260
  return obj;
234
261
  }
235
262
 
236
- /** One 'pickup' role material per color (and vertex colors or not), shared by every pickup of that color @internal */
237
- function pickupMaterial(pk, color, geometry) {
238
- const vc = !!geometry?.attributes?.color, key = color + (vc ? ':vc' : '');
239
- const m = (pk._mats ||= new Map());
240
- if (!m.has(key)) m.set(key, makeMaterial('pickup', { color, ...(vc && { vertexColors: true }) }, pk.engine));
241
- return m.get(key);
263
+ /** Mark a mesh as drawn by the pickups material (color: its own, or null) and give it that material @internal */
264
+ function drawnBy(pk, mesh, color) { mesh.userData.pickupColor = color; mesh.material = pickupMaterial(pk, mesh); }
265
+
266
+ /** The material of one marked mesh: pk.material itself, or a copy shared by every pickup of that color (and vertex colors or not) @internal */
267
+ function pickupMaterial(pk, mesh) {
268
+ const color = mesh.userData.pickupColor, vc = !!mesh.geometry.attributes.color, base = pk.material;
269
+ if (color == null && !vc) return base;
270
+ const key = color + (vc ? ':vc' : '');
271
+ if (!pk._copies.has(key)) {
272
+ const m = copyPatches(base, base.clone());
273
+ if (color != null) /** @type {any} */ (m).color?.set(color);
274
+ if (vc) m.vertexColors = true;
275
+ if (isEngineMade(base)) markEngineMade(m);
276
+ pk._copies.set(key, m);
277
+ }
278
+ return pk._copies.get(key);
242
279
  }
243
280
 
244
281
  /** The op pickup.take { id }: the interact key, auto pickups, a net peer's request, the dev bridge and tests all run it, as ctx.actor @internal */
@@ -269,12 +306,15 @@ const PICKUP_PARAMS = {
269
306
  radius: { type: 'number', default: 2, min: 0, desc: 'reach of pickups that set no radius (meters); auto pickups are taken within it' },
270
307
  showDistance: { type: 'number', default: 60, min: 0, desc: 'pickups have a model, float and spin only within this distance of the stream sources (meters)' },
271
308
  takers: { type: 'any', optional: true, desc: 'e => actor ids that walk into auto pickups (default engine.actor, plus net peers on a host)' },
309
+ color: { type: 'any', default: DEFAULT_COLOR, desc: 'color of the placeholder box and geometry-only models when the pickup and its item set none' },
310
+ size: { type: 'number', default: 0.25, min: 0, desc: 'edge of the placeholder box (meters)' },
311
+ lift: { type: 'number', default: 0.4, desc: 'height above the ground a pickup floats at (meters)' },
272
312
  };
273
313
 
274
314
  /**
275
315
  * Pickups module: things on the ground that give whoever takes them an item (into that actor's container) or an instant effect. Installs engine.pickups and
276
316
  * the op pickup.take. Needs world() first; interactions() for the key prompt (auto: true pickups need none); inventory() only for give: itemId.
277
- * Options: radius (default reach, 2 m), showDistance (60 m), takers (who walks into auto pickups).
317
+ * Options: radius (default reach, 2 m), showDistance (60 m), takers (who walks into auto pickups), color, size, lift (the placeholder's plain values); engine.pickups.material for the picture.
278
318
  * @example engine.use(openWorld(), interactions({ ...presets.interactions.nearest }), inventory(), pickups())
279
319
  * @example engine.use(world(), pickups({ radius: 1 })) // coins and health packs only: auto pickups with give functions, no inventory, no prompt
280
320
  */
@@ -285,8 +325,6 @@ export function pickups(opts = {}) {
285
325
  name: 'pickups', type: 'rules', label: 'Pickups', params: PICKUP_PARAMS, options: o, requires: ['world'], optional: ['interactions', 'inventory', 'net'], stage: 'gameplay',
286
326
  noSkip: 'auto pickups are spatial; respawn follows the game clock',
287
327
  install(e, ctx) {
288
- // same rule as style.weather: style sections a module reads go through readParams; the 0.2 style.pickup.model (no longer read) names the new form first (in dev), never silently does nothing
289
- if (e.style.pickup) readParams('style.pickup', keysSchema(STYLE_KEYS), e.style.pickup);
290
328
  pk = new Pickups(e, opts, ctx.track); defineTake(e, pk); return pk;
291
329
  },
292
330
  fixed() { pk._auto(); },
@@ -1,6 +1,6 @@
1
1
  // The quest log window as the UI part 'questLog'. Quests keeps the behavior through engine.ui (the J key toggles it; open = UI focus stack, input lock,
2
2
  // Esc closes, ui:open / ui:close 'questLog'); the part only draws { title, key, quests, close() }. Replace it or turn it off with engine.ui.set('questLog', ...).
3
- // Default look: a .threedog-win window; its body can be replaced by style.ui.templates.quests({ quests }, { esc, t }) or restyled via .threedog-quest*.
3
+ // Default picture: a .threedog-win window; its body can be replaced by ui.templates.quests({ quests }, { esc, t }) or restyled via .threedog-quest*.
4
4
  import { injectUICSS, esc } from '../../ui/UI.js';
5
5
  /** @import { Engine, UIPart } from '../../types/core' */
6
6
  /** @import { QuestLogView } from '../../types/gameplay' */
@@ -25,7 +25,7 @@ function questLogPart(engine) {
25
25
  const draw = v => {
26
26
  if (!w) { w = document.createElement('div'); w.className = 'threedog-ui threedog-win threedog-win-quests'; engine.uiRoot.appendChild(w); }
27
27
  w.hidden = false;
28
- const tpl = engine.style.ui?.templates?.quests;
28
+ const tpl = engine.ui.templates.quests;
29
29
  w.innerHTML = `<div class="threedog-win-head"><span>${esc(v.title)}</span><span><span class="threedog-win-hint">${esc(v.key)}</span> <button class="threedog-btn threedog-close" type="button">${esc(engine.t('common.close'))}</button></span></div>${tpl ? tpl(v, tools) : body(v)}`;
30
30
  w.querySelector('.threedog-close').onclick = () => v.close();
31
31
  };
@@ -42,6 +42,19 @@ export class Layer {
42
42
  /** @internal 'i,j' -> authored data (content/grids.js layers): what the save diffs against */ this._base = new Map();
43
43
  /** @internal the last save diff applied, so a baseline set after the load (content after the save) still gets it */ this._diff = null;
44
44
  }
45
+ /**
46
+ * The three.js material of this layer's tiles (null when it draws none: a data layer, tiles: false or your own part). Set it to swap the picture, used as given.
47
+ * Tile colors are vertex colors, so a material with vertexColors: true shows them; without it, its own color covers every tile.
48
+ * @example field.layer('soil').material = new THREE.MeshStandardMaterial({ vertexColors: true, roughness: 1 });
49
+ * @type {import('three').Material | null}
50
+ */
51
+ get material() { return this.grid._owner._tiles.get(this)?.mesh?.material ?? null; }
52
+ set material(m) {
53
+ const mesh = this.grid._owner._tiles.get(this)?.mesh;
54
+ if (!mesh) throw codedError('grids-misuse', `layer '${this.name}'.material: this layer draws no default tiles; give it a picture first: grid.layer('${this.name}', { tiles: true })`);
55
+ if (!m?.isMaterial) throw codedError('grids-misuse', `layer '${this.name}'.material takes a three.js material, got ${m}`);
56
+ mesh.material = m;
57
+ }
45
58
  /** @internal */
46
59
  _guard(what) { DEV && this.grid.engine.ops.guard(`grid layer ${this.grid.name}.${this.name}.${what}`); }
47
60
  /**