threedog 0.2.1 → 0.5.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 (593) hide show
  1. package/CHANGELOG.md +290 -0
  2. package/README.md +9 -8
  3. package/core/Animator.js +15 -12
  4. package/core/Assets.js +71 -16
  5. package/core/Audio.js +45 -38
  6. package/core/Baked.js +32 -8
  7. package/core/Batching.js +102 -15
  8. package/core/Budget.js +39 -18
  9. package/core/Clock.js +40 -80
  10. package/core/DebugOverrides.js +45 -10
  11. package/core/Describe.js +104 -43
  12. package/core/Engine.js +183 -59
  13. package/core/Events.js +4 -1
  14. package/core/I18n.js +25 -13
  15. package/core/Input.js +168 -79
  16. package/core/Inspect.js +2 -2
  17. package/core/InspectMaterials.js +85 -0
  18. package/core/InspectPerf.js +61 -0
  19. package/core/InspectScene.js +13 -2
  20. package/core/Loading.js +2 -1
  21. package/core/Ops.js +50 -9
  22. package/core/Random.js +9 -2
  23. package/core/Rays.js +5 -5
  24. package/core/SaveStore.js +41 -9
  25. package/core/Saves.js +71 -15
  26. package/core/Stream.js +14 -10
  27. package/core/Threads.js +26 -7
  28. package/core/UrlState.js +25 -9
  29. package/core/Views.js +9 -6
  30. package/core/actor.js +1 -1
  31. package/core/adaptive.js +93 -0
  32. package/core/assetEntry.js +22 -5
  33. package/core/assetHot.js +176 -0
  34. package/core/assetLoad.js +38 -11
  35. package/core/assetManifest.js +48 -9
  36. package/core/assetReport.js +1 -1
  37. package/core/audioRules.js +13 -11
  38. package/core/audioVoice.js +69 -42
  39. package/core/canvasBox.js +1 -2
  40. package/core/catalog.js +5 -2
  41. package/core/cells.js +62 -0
  42. package/core/checks.js +10 -8
  43. package/core/chunkStream.js +87 -0
  44. package/core/control.js +149 -0
  45. package/core/copies.js +32 -0
  46. package/core/dayTime.js +12 -6
  47. package/core/debugView.js +82 -15
  48. package/core/describeRender.js +37 -17
  49. package/core/describeText.js +41 -21
  50. package/core/engineCamera.js +32 -0
  51. package/core/errorCodes.js +438 -19
  52. package/core/errorHints.js +37 -141
  53. package/core/errors.js +31 -8
  54. package/core/events.generated.js +12 -7
  55. package/core/gameLights.js +62 -0
  56. package/core/grayMap.js +20 -0
  57. package/core/grid.js +14 -13
  58. package/core/gridLoad.js +2 -1
  59. package/core/ground.js +6 -4
  60. package/core/headlessLoad.js +55 -0
  61. package/core/holds.js +78 -50
  62. package/core/inputContext.js +11 -7
  63. package/core/inputDefaults.js +24 -21
  64. package/core/inputPad.js +1 -1
  65. package/core/inputPointer.js +1 -1
  66. package/core/inputTouch.js +2 -2
  67. package/core/lifecycle.js +48 -12
  68. package/core/lightWatch.js +6 -4
  69. package/core/look/coreParts.js +137 -30
  70. package/core/look/part.js +175 -95
  71. package/core/look/points.js +255 -0
  72. package/core/look/report.js +34 -17
  73. package/core/look/shadowPart.js +63 -0
  74. package/core/look/state.js +45 -0
  75. package/core/look/write.js +12 -28
  76. package/core/loop.js +100 -41
  77. package/core/math.js +11 -3
  78. package/core/moduleSlots.js +75 -0
  79. package/core/moduleTypes.js +73 -0
  80. package/core/modules.js +145 -27
  81. package/core/movement.js +2 -2
  82. package/core/namedModel.js +70 -0
  83. package/core/opsCheck.js +3 -3
  84. package/core/opsFail.js +15 -6
  85. package/core/opsGuard.js +4 -4
  86. package/core/opsRun.js +4 -3
  87. package/core/owned.js +168 -0
  88. package/core/page.js +2 -1
  89. package/core/params.js +30 -8
  90. package/core/plugins.js +277 -0
  91. package/core/saveApply.js +99 -17
  92. package/core/saveFiles.js +8 -6
  93. package/core/saveValues.js +46 -0
  94. package/core/saveVersions.js +20 -3
  95. package/core/scatter.js +48 -19
  96. package/core/sceneDelta.js +203 -0
  97. package/core/sceneMethods.js +35 -30
  98. package/core/screenToGround.js +1 -1
  99. package/core/services.js +27 -11
  100. package/core/session.js +28 -25
  101. package/core/shaderCost.js +78 -0
  102. package/core/shadowTypes.js +2 -1
  103. package/core/sharedPoint.js +317 -0
  104. package/core/skip.js +36 -28
  105. package/core/stackFrames.js +34 -0
  106. package/core/stacks.js +166 -0
  107. package/core/startup.js +153 -11
  108. package/core/streamSources.js +0 -11
  109. package/core/styleParts.js +63 -47
  110. package/core/targeting.js +1 -1
  111. package/core/textureBytes.js +20 -0
  112. package/core/thingExplain.js +2 -2
  113. package/core/thingOps.js +29 -6
  114. package/core/things.js +21 -11
  115. package/core/threadPure.js +7 -3
  116. package/core/threePatches.js +47 -0
  117. package/core/tier.js +21 -10
  118. package/core/time.js +236 -0
  119. package/core/uiClock.js +25 -0
  120. package/core/util.js +7 -1
  121. package/core/validate.js +65 -86
  122. package/core/wrap.js +106 -0
  123. package/docs/AI.md +87 -100
  124. package/docs/API.md +32 -28
  125. package/docs/CODEMAP.md +220 -147
  126. package/docs/COMMANDS.md +56 -35
  127. package/docs/CONVENTIONS.md +90 -28
  128. package/docs/MIGRATING-0.3.md +248 -0
  129. package/docs/MIGRATING-0.4.md +228 -0
  130. package/docs/MIGRATING-0.5.md +68 -0
  131. package/docs/PERF.md +35 -7
  132. package/docs/THREE.md +79 -27
  133. package/docs/api/ambience.md +0 -1
  134. package/docs/api/assets.md +11 -9
  135. package/docs/api/audio.md +10 -14
  136. package/docs/api/calendar.md +41 -0
  137. package/docs/api/cameraRig.md +16 -5
  138. package/docs/api/characters.md +38 -23
  139. package/docs/api/clock.md +6 -5
  140. package/docs/api/collision.md +9 -6
  141. package/docs/api/content.md +6 -4
  142. package/docs/api/dialogue.md +9 -9
  143. package/docs/api/engine.md +63 -60
  144. package/docs/api/events.md +19 -14
  145. package/docs/api/grids.md +3 -3
  146. package/docs/api/ground.md +1 -1
  147. package/docs/api/hud.md +2 -2
  148. package/docs/api/i18n.md +1 -1
  149. package/docs/api/input.md +11 -6
  150. package/docs/api/interactions.md +7 -5
  151. package/docs/api/inventory.md +17 -16
  152. package/docs/api/level.md +0 -1
  153. package/docs/api/lightPool.md +3 -1
  154. package/docs/api/music.md +1 -1
  155. package/docs/api/nav.md +3 -0
  156. package/docs/api/openWorld.md +2 -1
  157. package/docs/api/particles.md +2 -2
  158. package/docs/api/photo.md +0 -2
  159. package/docs/api/pickups.md +15 -0
  160. package/docs/api/post.md +5 -4
  161. package/docs/api/quests.md +2 -3
  162. package/docs/api/rigid.md +16 -14
  163. package/docs/api/saves.md +6 -4
  164. package/docs/api/settings.md +2 -3
  165. package/docs/api/sky.md +11 -44
  166. package/docs/api/stream.md +1 -1
  167. package/docs/api/style.md +28 -26
  168. package/docs/api/terrain.md +9 -6
  169. package/docs/api/terrainLook.md +10 -0
  170. package/docs/api/timeline.md +3 -4
  171. package/docs/api/tools.md +29 -13
  172. package/docs/api/triggers.md +5 -10
  173. package/docs/api/vegetation.md +11 -8
  174. package/docs/api/vegetationLook.md +10 -0
  175. package/docs/api/water.md +4 -20
  176. package/docs/api/weather.md +5 -15
  177. package/docs/api/weatherLook.md +10 -0
  178. package/docs/api/world.md +2 -1
  179. package/docs/recipes/01-new-game.md +48 -34
  180. package/docs/recipes/02-npc.md +24 -7
  181. package/docs/recipes/03-items-pickups.md +35 -21
  182. package/docs/recipes/04-quests.md +12 -5
  183. package/docs/recipes/05-props-bake.md +151 -15
  184. package/docs/recipes/06-clock-events.md +100 -52
  185. package/docs/recipes/07-flow-scenes-pause.md +40 -9
  186. package/docs/recipes/08-weather-sky.md +145 -36
  187. package/docs/recipes/{09-style-pack.md → 09-style.md} +101 -52
  188. package/docs/recipes/10-blender-level.md +14 -2
  189. package/docs/recipes/11-vehicles.md +64 -7
  190. package/docs/recipes/13-animation.md +14 -6
  191. package/docs/recipes/14-custom-module.md +61 -29
  192. package/docs/recipes/15-perf.md +30 -9
  193. package/docs/recipes/16-dev-bridge.md +61 -37
  194. package/docs/recipes/18-world.md +16 -6
  195. package/docs/recipes/19-shooting-picking.md +6 -6
  196. package/docs/recipes/20-content-actions-save.md +55 -17
  197. package/docs/recipes/21-camera.md +49 -16
  198. package/docs/recipes/22-shop-gold.md +3 -3
  199. package/docs/recipes/23-ops.md +16 -10
  200. package/docs/recipes/26-ui-parts.md +61 -12
  201. package/docs/recipes/27-net.md +11 -5
  202. package/docs/recipes/28-terrain.md +34 -1
  203. package/docs/recipes/29-grid.md +34 -16
  204. package/docs/recipes/30-templates.md +64 -12
  205. package/docs/recipes/31-audio.md +20 -12
  206. package/docs/recipes/32-action-game.md +35 -2
  207. package/docs/recipes/34-environment-lighting.md +26 -3
  208. package/docs/recipes/35-style-from-reference.md +88 -19
  209. package/docs/recipes/36-sky-ground-plant-looks.md +18 -18
  210. package/docs/recipes/37-terrain-look-hooks.md +3 -2
  211. package/docs/recipes/38-environment-look-hooks.md +37 -26
  212. package/docs/recipes/40-scene.md +16 -13
  213. package/docs/recipes/41-thing-registry.md +11 -7
  214. package/docs/recipes/42-terrain-shape.md +2 -2
  215. package/docs/recipes/43-shader-patches-surface-looks.md +158 -76
  216. package/docs/recipes/44-water-weather-look-hooks.md +26 -17
  217. package/docs/recipes/45-cascaded-shadows.md +16 -7
  218. package/docs/recipes/47-island-snow-backdrop.md +7 -7
  219. package/docs/recipes/48-make-material.md +11 -6
  220. package/docs/recipes/49-game-module-contract.md +30 -17
  221. package/docs/recipes/50-own-renderer.md +2 -2
  222. package/docs/recipes/51-capability-catalog.md +3 -3
  223. package/docs/recipes/52-look.md +197 -61
  224. package/docs/recipes/53-ground-up-close.md +1 -1
  225. package/docs/recipes/54-three-idioms.md +88 -0
  226. package/docs/recipes/55-mods-time-wrap.md +112 -0
  227. package/docs/recipes/56-webgpu-tsl.md +260 -0
  228. package/docs/recipes/57-control.md +65 -0
  229. package/docs/recipes/58-input.md +57 -0
  230. package/docs/recipes/59-depth-post-effects.md +83 -0
  231. package/docs/recipes/60-judge-the-picture.md +55 -0
  232. package/examples/action/.threedog/content-index.json +1 -0
  233. package/examples/action/GAMEMAP.md +17 -13
  234. package/examples/action/assets.js +8 -0
  235. package/examples/action/content/actions.js +1 -1
  236. package/examples/action/content/audio.js +5 -5
  237. package/examples/action/look.js +1 -1
  238. package/examples/action/main.js +10 -14
  239. package/examples/action/models.js +24 -23
  240. package/examples/pullable.json +111 -0
  241. package/examples/rc2d/.threedog/content-index.json +1 -0
  242. package/examples/rc2d/GAMEMAP.md +83 -0
  243. package/examples/rc2d/README.md +52 -0
  244. package/examples/rc2d/main.js +63 -0
  245. package/examples/rc2d/rc2d.js +197 -0
  246. package/examples/rc2d/shaders.js +144 -0
  247. package/examples/sheepisland/.threedog/content-index.json +1 -0
  248. package/examples/sheepisland/GAMEMAP.md +13 -11
  249. package/examples/sheepisland/assets.js +5 -0
  250. package/examples/sheepisland/main.js +17 -12
  251. package/examples/sheepisland/style/index.js +6 -6
  252. package/examples/styletest/.threedog/content-index.json +1 -0
  253. package/examples/styletest/GAMEMAP.md +15 -16
  254. package/examples/styletest/assets.js +6 -0
  255. package/examples/styletest/content/templates.js +1 -1
  256. package/examples/styletest/content/vegetation.js +1 -1
  257. package/examples/styletest/look.js +1 -1
  258. package/examples/styletest/main.js +17 -16
  259. package/examples/styletest/models.js +1 -1
  260. package/examples/styletest/params.js +3 -3
  261. package/examples/techniques/contact-shadows/README.md +92 -0
  262. package/examples/techniques/contact-shadows/contactShadows.js +51 -0
  263. package/examples/techniques/contact-shadows/main.js +53 -0
  264. package/examples/techniques/day-night-grade/README.md +86 -0
  265. package/examples/techniques/day-night-grade/dayNightGrade.js +76 -0
  266. package/examples/techniques/day-night-grade/main.js +51 -0
  267. package/examples/techniques/interior-light/README.md +103 -0
  268. package/examples/techniques/interior-light/interiorLight.js +45 -0
  269. package/examples/techniques/interior-light/main.js +124 -0
  270. package/examples/techniques/modular-building/README.md +125 -0
  271. package/examples/techniques/modular-building/kit.js +426 -0
  272. package/examples/techniques/modular-building/main.js +47 -0
  273. package/examples/techniques/night-lights/README.md +94 -0
  274. package/examples/techniques/night-lights/main.js +70 -0
  275. package/examples/techniques/night-lights/nightLights.js +91 -0
  276. package/examples/techniques/outlines-and-rim/README.md +59 -0
  277. package/examples/techniques/outlines-and-rim/main.js +84 -0
  278. package/examples/techniques/outlines-and-rim/outlines.js +64 -0
  279. package/examples/techniques/procedural-animation/README.md +77 -0
  280. package/examples/techniques/procedural-animation/creature.js +44 -0
  281. package/examples/techniques/procedural-animation/main.js +45 -0
  282. package/examples/techniques/procedural-animation/proceduralAnim.js +118 -0
  283. package/examples/techniques/procedural-surface/README.md +67 -0
  284. package/examples/techniques/procedural-surface/main.js +103 -0
  285. package/examples/techniques/procedural-surface/surface.js +120 -0
  286. package/examples/techniques/stylized-shading/README.md +75 -0
  287. package/examples/techniques/stylized-shading/main.js +93 -0
  288. package/examples/techniques/stylized-shading/shading.js +131 -0
  289. package/examples/techniques/sun-and-key-light/README.md +135 -0
  290. package/examples/techniques/sun-and-key-light/keyLight.js +53 -0
  291. package/examples/techniques/sun-and-key-light/main.js +95 -0
  292. package/examples/techniques/wet-road/README.md +99 -0
  293. package/examples/techniques/wet-road/main.js +68 -0
  294. package/examples/techniques/wet-road/wetRoad.js +209 -0
  295. package/examples/webgpu-tsl/.threedog/content-index.json +1 -0
  296. package/examples/webgpu-tsl/GAMEMAP.md +84 -0
  297. package/examples/webgpu-tsl/README.md +42 -0
  298. package/examples/webgpu-tsl/main.js +21 -0
  299. package/examples/webgpu-tsl/tslScene.js +75 -0
  300. package/examples/world/.threedog/content-index.json +1 -0
  301. package/examples/world/GAMEMAP.md +22 -15
  302. package/examples/world/art/humanoid.js +42 -0
  303. package/examples/world/art/index.js +11 -0
  304. package/examples/world/art/models.js +58 -0
  305. package/examples/world/art/shapes.js +9 -0
  306. package/examples/world/assets.js +6 -0
  307. package/examples/world/content/audio.js +5 -5
  308. package/examples/world/content/npcs.js +1 -1
  309. package/examples/world/content/props.js +1 -1
  310. package/examples/world/content/rules.js +1 -1
  311. package/examples/world/content/templates.js +1 -1
  312. package/examples/world/content/vegetation.js +1 -1
  313. package/examples/world/main.js +17 -13
  314. package/examples/world/style/index.js +61 -0
  315. package/examples/world/style/plugins/10-bloom.js +5 -0
  316. package/index.d.ts +44 -45
  317. package/index.js +26 -22
  318. package/llms.txt +11 -4
  319. package/modules/ambience/Ambience.js +34 -23
  320. package/modules/calendar/Calendar.js +163 -0
  321. package/modules/calendar/contract.js +21 -0
  322. package/modules/calendar/index.js +81 -0
  323. package/modules/{sky → calendar}/schedule.js +17 -16
  324. package/modules/calendar/seasons.js +55 -0
  325. package/modules/camera/FirstPersonCamera.js +6 -15
  326. package/modules/camera/FixedCamera.js +33 -15
  327. package/modules/camera/FollowCamera.js +90 -16
  328. package/modules/camera/RtsCamera.js +18 -17
  329. package/modules/camera/common.js +70 -19
  330. package/modules/camera/contract.js +17 -0
  331. package/modules/camera/projection.js +11 -24
  332. package/modules/characters/Character.js +177 -42
  333. package/modules/characters/NPC.js +87 -36
  334. package/modules/characters/assetModel.js +4 -13
  335. package/modules/characters/behaviors.js +2 -1
  336. package/modules/characters/contract.js +13 -0
  337. package/modules/characters/footsteps.js +1 -1
  338. package/modules/characters/index.js +87 -49
  339. package/modules/characters/moveHelpers.js +4 -5
  340. package/modules/characters/movers/common.js +97 -19
  341. package/modules/characters/movers/manual.js +20 -0
  342. package/modules/characters/movers/rapier.js +19 -16
  343. package/modules/characters/movers/simple.js +14 -11
  344. package/modules/characters/movers/support.js +172 -0
  345. package/modules/characters/npcAvoid.js +47 -42
  346. package/modules/characters/npcSim.js +12 -8
  347. package/modules/characters/npcView.js +44 -16
  348. package/modules/characters/pathAsync.js +7 -3
  349. package/modules/characters/playerStrings.js +4 -3
  350. package/modules/characters/proceduralRig.js +2 -1
  351. package/modules/characters/useModel.js +1 -1
  352. package/modules/characters/vehicle.contract.js +21 -0
  353. package/modules/characters/walkTo.js +21 -7
  354. package/modules/collision/Collision.js +65 -25
  355. package/modules/collision/grid.js +8 -6
  356. package/modules/content/explain.js +2 -2
  357. package/modules/content/fields.js +102 -0
  358. package/modules/content/ids.js +8 -6
  359. package/modules/content/index.js +96 -27
  360. package/modules/content/loader.js +45 -33
  361. package/modules/content/models.js +11 -40
  362. package/modules/content/packs.js +6 -5
  363. package/modules/content/parts.js +41 -0
  364. package/modules/content/props.js +16 -9
  365. package/modules/content/rules.js +58 -0
  366. package/modules/content/stages.js +80 -0
  367. package/modules/content/templates.js +121 -30
  368. package/modules/debug/DebugPanel.js +24 -17
  369. package/modules/flow/contract.js +16 -0
  370. package/modules/flow/index.js +21 -15
  371. package/modules/gameplay/Container.js +41 -32
  372. package/modules/gameplay/Containers.js +30 -15
  373. package/modules/gameplay/Dialogue.js +113 -55
  374. package/modules/gameplay/Interactions.js +193 -67
  375. package/modules/gameplay/Inventory.js +69 -73
  376. package/modules/gameplay/Quests.js +75 -39
  377. package/modules/gameplay/boxOps.js +3 -3
  378. package/modules/gameplay/dialogue.contract.js +21 -0
  379. package/modules/gameplay/dialogueBox.js +4 -2
  380. package/modules/gameplay/dialogueBubbles.js +116 -0
  381. package/modules/gameplay/interactionPrompt.js +4 -1
  382. package/modules/gameplay/interactions.contract.js +16 -0
  383. package/modules/gameplay/inventory.contract.js +23 -0
  384. package/modules/gameplay/inventoryOps.js +18 -16
  385. package/modules/gameplay/pickups.js +268 -85
  386. package/modules/gameplay/questLog.js +4 -4
  387. package/modules/gameplay/quests.contract.js +17 -0
  388. package/modules/grid/Grid.js +92 -50
  389. package/modules/grid/Layer.js +14 -13
  390. package/modules/grid/index.js +60 -36
  391. package/modules/grid/ops.js +20 -18
  392. package/modules/grid/preview.js +15 -16
  393. package/modules/grid/strings.js +12 -0
  394. package/modules/grid/tiles.js +6 -5
  395. package/modules/hlod/index.js +51 -19
  396. package/modules/hud/index.js +35 -20
  397. package/modules/hud/parts.js +20 -7
  398. package/modules/level/heightfield.js +3 -1
  399. package/modules/level/index.js +45 -20
  400. package/modules/level/nodes.js +4 -3
  401. package/modules/lights/index.js +42 -18
  402. package/modules/music/Music.js +38 -21
  403. package/modules/music/rules.js +1 -1
  404. package/modules/nav/index.js +48 -42
  405. package/modules/net/Client.js +13 -6
  406. package/modules/net/Host.js +19 -5
  407. package/modules/net/Net.js +2 -1
  408. package/modules/net/index.js +13 -8
  409. package/modules/net/sync.js +9 -8
  410. package/modules/net/transports.js +77 -27
  411. package/modules/particles/Particles.js +23 -14
  412. package/modules/particles/contract.js +17 -0
  413. package/modules/particles/effect.js +39 -11
  414. package/modules/photo/Photo.js +53 -36
  415. package/modules/rigid/RigidBodies.js +194 -32
  416. package/modules/rigid/Vehicles.js +18 -15
  417. package/modules/rigid/sync.js +62 -17
  418. package/modules/settings/Settings.js +57 -52
  419. package/modules/settings/apply.js +38 -3
  420. package/modules/settings/sections.js +5 -3
  421. package/modules/settings/strings.js +3 -2
  422. package/modules/settings/view.js +5 -3
  423. package/modules/sky/Sky.js +88 -176
  424. package/modules/sky/cascades.js +86 -25
  425. package/modules/sky/cascades.tsl.js +82 -0
  426. package/modules/sky/clouds.js +34 -19
  427. package/modules/sky/domeLayers.js +30 -15
  428. package/modules/sky/environment.js +83 -13
  429. package/modules/sky/fog.js +140 -95
  430. package/modules/sky/frame.js +112 -44
  431. package/modules/sky/look.js +22 -19
  432. package/modules/sky/lookFog.js +48 -52
  433. package/modules/sky/lookShadow.js +53 -41
  434. package/modules/sky/lookSky.js +82 -21
  435. package/modules/sky/season.js +21 -0
  436. package/modules/sky/shader.js +41 -19
  437. package/modules/sky/shadow.js +44 -20
  438. package/modules/sky/skyModule.js +45 -33
  439. package/modules/sky/tint.js +61 -0
  440. package/modules/terrain/ChunkManager.js +175 -108
  441. package/modules/terrain/chunkJob.js +1 -1
  442. package/modules/terrain/chunkQueries.js +6 -4
  443. package/modules/terrain/index.js +105 -50
  444. package/modules/terrain/look.js +83 -0
  445. package/modules/terrain/lookGround.js +21 -16
  446. package/modules/terrain/terrainDefaults.js +1 -1
  447. package/modules/terrain/terrainEdit.js +18 -20
  448. package/modules/terrain/terrainGen.js +5 -3
  449. package/modules/terrain/terrainIsland.js +5 -4
  450. package/modules/terrain/terrainShape.js +12 -12
  451. package/modules/terrain/terrainShapeMain.js +8 -7
  452. package/modules/terrain/terrainTexture.js +21 -19
  453. package/modules/timeline/Timeline.js +95 -43
  454. package/modules/timeline/Tween.js +18 -10
  455. package/modules/timeline/letterbox.js +2 -2
  456. package/modules/timeline/shots.js +5 -1
  457. package/modules/triggers/index.js +107 -76
  458. package/modules/vegetation/Vegetation.js +186 -110
  459. package/modules/vegetation/densityMap.js +62 -0
  460. package/modules/vegetation/groundChunks.js +52 -58
  461. package/modules/vegetation/index.js +32 -11
  462. package/modules/vegetation/look.js +119 -0
  463. package/modules/vegetation/lookWind.js +71 -10
  464. package/modules/vegetation/modelGeometry.js +3 -2
  465. package/modules/vegetation/nearFade.js +8 -2
  466. package/modules/water/Water.js +65 -27
  467. package/modules/water/look.js +29 -18
  468. package/modules/water/surface.js +64 -25
  469. package/modules/water/surfaceDefaults.js +3 -0
  470. package/modules/weather/Weather.js +62 -104
  471. package/modules/weather/look.js +1 -2
  472. package/modules/weather/particles.js +24 -9
  473. package/modules/weather/strings.js +2 -2
  474. package/modules/weather/weatherLook.js +135 -0
  475. package/modules/world/World.js +24 -7
  476. package/modules/world/explain.js +1 -1
  477. package/modules/world/index.js +18 -4
  478. package/modules/world/persist.js +62 -2
  479. package/modules/world/pos.js +3 -2
  480. package/modules/world/records.js +8 -6
  481. package/modules/world/sim.js +60 -20
  482. package/modules/world/simFar.js +4 -3
  483. package/modules/world/state.js +3 -2
  484. package/modules/world/thingSource.js +1 -1
  485. package/modules/world/views.js +7 -5
  486. package/package.json +7 -3
  487. package/presets.js +41 -27
  488. package/render/PostFX.js +145 -120
  489. package/render/backend.js +440 -0
  490. package/render/detail.js +120 -39
  491. package/render/effects.js +130 -38
  492. package/render/engineUniforms.js +10 -1
  493. package/render/fuse.js +5 -4
  494. package/render/fx/cloudShadow.tsl.js +16 -0
  495. package/render/fx/detail.tsl.js +66 -0
  496. package/render/fx/index.js +26 -0
  497. package/render/fx/lighting.tsl.js +28 -0
  498. package/render/fx/nodeErrors.tsl.js +68 -0
  499. package/render/fx/noise.tsl.js +12 -0
  500. package/render/fx/objectOrigin.tsl.js +42 -0
  501. package/render/fx/particles.tsl.js +139 -0
  502. package/render/fx/patchNodes.tsl.js +403 -0
  503. package/render/fx/postWebGPU.tsl.js +158 -0
  504. package/render/fx/season.tsl.js +13 -0
  505. package/render/fx/sky.tsl.js +260 -0
  506. package/render/fx/uniforms.tsl.js +67 -0
  507. package/render/fx/water.tsl.js +53 -0
  508. package/render/fx/wind.tsl.js +22 -0
  509. package/render/fxNumbers.js +36 -0
  510. package/render/hotGlsl.js +24 -0
  511. package/render/lighting.js +66 -14
  512. package/render/lights.js +223 -4
  513. package/render/lookGlow.js +139 -0
  514. package/render/lookSurface.js +99 -36
  515. package/render/materials.js +71 -52
  516. package/render/modeling.js +73 -0
  517. package/render/ownFrame.js +76 -0
  518. package/render/patches.js +311 -34
  519. package/render/postLook.js +124 -46
  520. package/render/postWebGL.js +197 -0
  521. package/render/probes.js +231 -0
  522. package/render/shaderErrors.js +154 -0
  523. package/render/slots.js +165 -0
  524. package/render/surface.js +53 -17
  525. package/render/terms.js +211 -0
  526. package/render/uniformDecl.js +3 -2
  527. package/types/common.d.ts +2 -2
  528. package/types/core.d.ts +614 -240
  529. package/types/gameplay.d.ts +482 -312
  530. package/types/generated/core/Audio.d.ts +26 -42
  531. package/types/generated/core/Batching.d.ts +6 -2
  532. package/types/generated/core/Budget.d.ts +2 -8
  533. package/types/generated/core/DebugOverrides.d.ts +44 -3
  534. package/types/generated/core/I18n.d.ts +2 -2
  535. package/types/generated/core/Input.d.ts +102 -31
  536. package/types/generated/core/Ops.d.ts +31 -0
  537. package/types/generated/core/Random.d.ts +2 -2
  538. package/types/generated/core/Saves.d.ts +10 -2
  539. package/types/generated/core/Stream.d.ts +1 -1
  540. package/types/generated/core/Threads.d.ts +4 -1
  541. package/types/generated/core/Views.d.ts +0 -1
  542. package/types/generated/core/audioVoice.d.ts +17 -9
  543. package/types/generated/core/control.d.ts +55 -0
  544. package/types/generated/core/session.d.ts +2 -1
  545. package/types/generated/modules/ambience/Ambience.d.ts +0 -9
  546. package/types/generated/modules/calendar/Calendar.d.ts +84 -0
  547. package/types/generated/modules/calendar/index.d.ts +10 -0
  548. package/types/generated/modules/debug/DebugPanel.d.ts +2 -2
  549. package/types/generated/modules/grid/Grid.d.ts +61 -25
  550. package/types/generated/modules/grid/Layer.d.ts +5 -5
  551. package/types/generated/modules/grid/index.d.ts +29 -17
  552. package/types/generated/modules/music/Music.d.ts +5 -3
  553. package/types/generated/modules/net/index.d.ts +3 -3
  554. package/types/generated/modules/net/transports.d.ts +12 -3
  555. package/types/generated/modules/particles/Particles.d.ts +1 -1
  556. package/types/generated/modules/sky/Sky.d.ts +12 -104
  557. package/types/generated/modules/sky/skyModule.d.ts +1 -1
  558. package/types/generated/modules/timeline/Timeline.d.ts +8 -6
  559. package/types/generated/modules/weather/Weather.d.ts +17 -18
  560. package/types/generated/modules/weather/weatherLook.d.ts +12 -0
  561. package/types/generated/modules/world/World.d.ts +18 -3
  562. package/types/generated/render/PostFX.d.ts +67 -30
  563. package/types/generated/render/materials.d.ts +26 -20
  564. package/types/generated/render/modeling.d.ts +30 -0
  565. package/types/generated/render/patches.d.ts +16 -2
  566. package/types/generated/ui/UI.d.ts +6 -3
  567. package/types/nav.d.ts +6 -0
  568. package/types/physics.d.ts +137 -44
  569. package/types/style.d.ts +109 -81
  570. package/types/tsl.d.ts +86 -0
  571. package/types/world.d.ts +158 -110
  572. package/ui/Focus.js +25 -14
  573. package/ui/LoadingScreen.js +1 -1
  574. package/ui/Parts.js +27 -11
  575. package/ui/UI.js +20 -10
  576. package/ui/cursor.js +115 -0
  577. package/ui/defaults.js +15 -11
  578. package/ui/theme.js +9 -6
  579. package/ui/touchPart.js +1 -1
  580. package/core/claims.js +0 -51
  581. package/core/look/layers.js +0 -136
  582. package/core/renamed.js +0 -22
  583. package/docs/api/entities.md +0 -61
  584. package/examples/styletest/overrides.js +0 -33
  585. package/examples/styletest/panel.js +0 -135
  586. package/modules/entities/Entities.js +0 -243
  587. package/modules/entities/build.js +0 -25
  588. package/modules/entities/index.js +0 -4
  589. package/modules/sky/calendar.js +0 -80
  590. package/modules/sky/layers.js +0 -69
  591. package/modules/terrain/chunkLevels.js +0 -40
  592. package/modules/terrain/mountTerrain.js +0 -32
  593. package/modules/world/cells.js +0 -42
@@ -0,0 +1,83 @@
1
+ # A post effect that reads depth (volumetric fog, god rays)
2
+
3
+ Fog you march through, light shafts, haze that thickens with distance, edge or focus effects: they all read the scene depth behind each pixel
4
+ and turn it into a distance or a world position. This recipe writes one such effect with both forms, a three.js `Pass` (GLSL) for
5
+ WebGLRenderer and a TSL node for WebGPURenderer, in one effect object. How effects are ordered, switched and tuned is recipe 52's
6
+ [Post effect chain](52-look.md#post-effect-chain); the TSL side in general is [recipe 56](56-webgpu-tsl.md#post-effects-as-nodes).
7
+ For plain distance or height fog on materials, `engine.look.fog` is enough (recipe 38); a post effect is for what fog on materials cannot do.
8
+
9
+ ## One effect, both renderers
10
+ `needsDepth: true` gives the WebGL pass the scene depth as `readBuffer.depthTexture`; on WebGPU the same depth is `ctx.scenePass.getTextureNode('depth')`.
11
+ Both turn the stored depth into the view distance with the camera's near and far. Number and color params are live: `look.post.set` writes
12
+ them without a rebuild (WebGL through `update`, WebGPU through the uniforms in `ctx.p`).
13
+ ```js
14
+ import * as THREE from 'three';
15
+ import { Pass, FullScreenQuad } from 'three/addons/postprocessing/Pass.js';
16
+
17
+ class DepthHazePass extends Pass {
18
+ constructor(camera) {
19
+ super();
20
+ this.camera = camera;
21
+ this.material = new THREE.ShaderMaterial({
22
+ uniforms: { tDiffuse: { value: null }, tDepth: { value: null }, uNear: { value: 0.1 }, uFar: { value: 1000 },
23
+ uColor: { value: new THREE.Color() }, uDensity: { value: 0.02 } },
24
+ vertexShader: 'varying vec2 vUv; void main() { vUv = uv; gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); }',
25
+ fragmentShader: `uniform sampler2D tDiffuse; uniform sampler2D tDepth; uniform float uNear, uFar, uDensity; uniform vec3 uColor; varying vec2 vUv;
26
+ void main() {
27
+ vec4 base = texture2D(tDiffuse, vUv);
28
+ float z = texture2D(tDepth, vUv).x * 2.0 - 1.0;
29
+ float dist = 2.0 * uNear * uFar / (uFar + uNear - z * (uFar - uNear)); // view distance in world units
30
+ gl_FragColor = vec4(mix(base.rgb, uColor, 1.0 - exp(-uDensity * dist)), base.a);
31
+ }`,
32
+ depthTest: false, depthWrite: false,
33
+ });
34
+ this.quad = new FullScreenQuad(this.material);
35
+ }
36
+ render(renderer, writeBuffer, readBuffer) {
37
+ const u = this.material.uniforms;
38
+ u.tDiffuse.value = readBuffer.texture; u.tDepth.value = readBuffer.depthTexture;
39
+ u.uNear.value = this.camera.near; u.uFar.value = this.camera.far;
40
+ renderer.setRenderTarget(this.renderToScreen ? null : writeBuffer);
41
+ this.quad.render(renderer);
42
+ }
43
+ dispose() { this.material.dispose(); this.quad.dispose(); }
44
+ }
45
+
46
+ // WebGPU: the same math as a node. onRenderUpdate's callback RETURNS the new value (it is not handed one to edit)
47
+ function depthHazeNode(input, { tsl: T, scenePass, camera, p }) {
48
+ const near = T.uniform(camera.near).onRenderUpdate(() => camera.near), far = T.uniform(camera.far).onRenderUpdate(() => camera.far);
49
+ const depth = scenePass.getTextureNode('depth').sample(T.screenUV).x;
50
+ const dist = T.perspectiveDepthToViewZ(depth, near, far).negate();
51
+ return T.vec4(T.mix(input.rgb, p.color, T.float(1).sub(T.exp(p.density.mul(dist).negate()))), input.a);
52
+ }
53
+
54
+ const update = (pass, p) => { pass.material.uniforms.uColor.value.copy(p.color); pass.material.uniforms.uDensity.value = p.density; };
55
+ engine.look.post.add({ name: 'depthHaze', slot: 'hdr', needsDepth: true, params: { color: new THREE.Color(0.72, 0.76, 0.82), density: 0.02 },
56
+ create: ({ camera, params }) => { const pass = new DepthHazePass(camera); update(pass, params); return pass; }, update, node: depthHazeNode });
57
+ engine.look.post.set({ 'depthHaze.density': 0.05 }); // live on both renderers
58
+ ```
59
+ - Slot `hdr`: the effect works in linear color, before tone mapping, so a bright sun shaft can bloom after it.
60
+ - A world position instead of a distance (height fog, a fog volume): on WebGL multiply the clip-space point by `camera.projectionMatrixInverse`,
61
+ then `camera.matrixWorld` (pass both as uniforms each frame); on WebGPU scale the view ray by the view depth and use `T.cameraWorldMatrix`.
62
+ Both routes must give the same point; compare them with `threedog shot` on each renderer.
63
+ - Depth order: a depth reader runs before any pass that swaps buffers; recipe 52 says how `order` keeps it so and what throws when it does not.
64
+
65
+ ## Volumetric fog: march along the ray
66
+ A raymarch adds up fog in steps from the camera to the depth found above. On WebGPU the march is a `Loop`, and a `Loop` (like `If` or
67
+ `.addAssign`) is a statement: it must be written inside an `Fn`, or three drops it with no error and the fog vanishes (the engine warns in dev
68
+ for an effect's node). On WebGL it is a plain `for` loop in the fragment shader.
69
+ ```js
70
+ // WebGPU: give it as an effect's node, beside a create() whose GLSL marches with a for loop
71
+ function marchedFogNode(input, { tsl: T, p }) {
72
+ return T.Fn(() => {
73
+ const acc = T.float(0).toVar();
74
+ T.Loop(16, ({ i }) => { acc.addAssign(p.density.mul(T.float(i).add(0.5))); }); // your density per step goes here
75
+ return T.vec4(T.mix(input.rgb, p.color, acc.clamp(0, 1)), input.a);
76
+ })();
77
+ }
78
+ ```
79
+ ## God rays
80
+ Light shafts from the sun: sample the color (or a mask: depth at the far plane is sky) along the line from each pixel toward the sun's point on
81
+ screen and add it up with falling weight. The sun's screen point is `engine.uniforms.uSunDir` projected with the camera each frame; when it is
82
+ behind the camera, fade the effect out. The color at other pixels needs the input as a texture: on WebGPU `ctx.display.texture(input)`, on
83
+ WebGL the pass's `readBuffer.texture`.
@@ -0,0 +1,55 @@
1
+ # 60 Make the picture look good: what each knob does and how to judge it
2
+
3
+ A map for visual polish: when you want to tune the picture, make a scene look prettier or closer to what the game wants, this page lists the
4
+ knobs, what each one changes on screen and how to tell it is right. **It is not a list of steps and nothing here is required**: pick the knobs
5
+ your style needs and leave the rest alone. There are no values to copy on purpose; the right value depends on the style, the camera and the
6
+ time of day, so every row says what to look for instead.
7
+
8
+ Where the rest lives (one home each, this page only points there):
9
+ - the calls, their parameters and who writes what: [recipe 52](52-look.md) (the look API, every part);
10
+ - the plain three.js way and how the engine yields to it: [THREE.md](../THREE.md) (a direct write takes the value over; the engine stops writing it);
11
+ - questions about the whole picture (light roles, readability, consistency) and the numbers each shot prints: [recipe 35](35-style-from-reference.md) "Look questions" and "Look check after every shot";
12
+ - a whole look as one package: a style pack ([recipe 09](09-style.md)).
13
+
14
+ ## How to judge, in one loop
15
+ Change one knob, take a shot (`threedog shot`, or `threedog snap` on a running page), compare with the one before, keep or undo. Shoot the
16
+ times and weathers the game really shows (`threedog shot --time`), not only noon. A knob is right when the difference you wanted is visible
17
+ and nothing else got worse; when you cannot say what difference a knob should make, leave it at the style's value.
18
+
19
+ ## The knobs
20
+
21
+ | Knob | What it changes on screen | It is right when | Engine line (details) | Plain three.js |
22
+ |---|---|---|---|---|
23
+ | Sky gradient, horizon | the color from the top of the sky down to where it meets the ground | the horizon band and the fog agree where they meet; the top-to-horizon change matches the hour and mood; no visible seam | `look.sky.set({ top, horizon })` ([08 §3](08-weather-sky.md#3-changing-sky-colors-sun-stars-style)); own shader: share `engine.uniforms.uSkyHorizon` / `uSkyTop` ([08](08-weather-sky.md#sky-color-for-my-shader-horizon-color-zenith-color)) | `engine.look.sky.replace(mySky)` with three/addons `Sky` or a `ShaderMaterial` dome |
24
+ | Fog near / far | how fast distant things fade | the play space stays clear, the far edge of the world dissolves instead of ending in a line, landmarks you want seen still read | `look.fog.set({ near, far })` ([52 Atmosphere](52-look.md#atmosphere-parts-sky-module-fog-sky-shadow)) | `engine.scene.fog = new THREE.Fog(color, near, far)` |
25
+ | Fog color vs sky | whether the distance melts into the sky or into its own haze | distant hills fade toward the sky behind them; a fog color of its own is a choice you can name (smoke, mist, a dream) | `look.fog.set({ color })` (`'horizon'` follows the sky; [38 Fog](38-environment-look-hooks.md#fog-kind-color-density-your-own-math-or-your-own-fog)) | `engine.scene.fog.color.set(c)` |
26
+ | Exposure | overall brightness after lighting | the brightest things you care about keep detail and the darkest still read; a night is dark because the lights are, not because exposure hides it | `look.tone.set({ exposure })` ([38 Exposure](38-environment-look-hooks.md#exposure-over-time-and-the-tone-curve)) | `engine.renderer.toneMappingExposure = v` |
27
+ | Tone mapping curve | how highlights roll off and how saturated bright colors stay | bright colors keep their hue where the style wants color, highlights soften where it wants film; flat-color styles may want almost no curve | (plain three.js is the route; [52 Who writes it](52-look.md#who-writes-it-the-ownership-table)) | `engine.renderer.toneMapping = THREE.AgXToneMapping` (or ACESFilmic, Neutral, No) |
28
+ | Sun direction | where shadows fall and which faces are lit | shapes read from the camera (lit side and shaded side both visible), shadows point somewhere useful, the hour looks like the hour | time of day (`engine.calendar`, [06](06-clock-events.md)); sun path: `look.sky.set({ orbitTilt })`; fixed: `look.lights.manual('sun.direction')` ([52 table](52-look.md#who-writes-it-the-ownership-table)) | `engine.lights.sun.position.set(x, y, z)` after the manual call, or your own `DirectionalLight` |
29
+ | Sun color, intensity | the key light: color and strength of lit faces | lit and shaded sides separate; whites under the sun are the white the style wants (warm, neutral, cool) | `look.lights.set({ sun: { color, intensity } })` ([52 table](52-look.md#who-writes-it-the-ownership-table)) | `engine.lights.sun.color.set(c)` |
30
+ | Ambient / hemisphere, environment | the fill: how bright and what color the shaded side is | shadows are as deep as the style wants and still show shape; up-facing and down-facing faces differ; metals have something to reflect | `look.lights.set({ hemi: { color, ground, intensity } })`, `look.env.set({ intensity })` ([34](34-environment-lighting.md), [08 brightness](08-weather-sky.md#3-changing-sky-colors-sun-stars-style)) | `engine.lights.hemi.groundColor.set(c)`, `engine.scene.environmentIntensity = v` |
31
+ | Shadow softness | hard or blurred shadow edges | edges match the light (crisp under a clear sun, soft under cloud or for a gentle style); no stair-steps or speckle | `look.shadow.set({ type, radius })` ([52 Atmosphere](52-look.md#atmosphere-parts-sky-module-fog-sky-shadow), [45](45-cascaded-shadows.md)) | `engine.lights.sun.shadow.radius = r` |
32
+ | Shadow distance, detail | how far shadows reach and how sharp small ones are | the area the player looks at has shadows; small props keep theirs; objects touch the ground (no gap under a foot) | `look.shadow.set({ extent, cascades, maxFar, bias })` ([52 Atmosphere](52-look.md#atmosphere-parts-sky-module-fog-sky-shadow)) | `engine.lights.sun.shadow.camera` sides, `engine.lights.sun.shadow.mapSize` |
33
+ | Bloom | light bleeding around bright pixels | the bright things you meant (sun, lamps, magic) glow and nothing else does; the picture does not turn milky | `look.post.add(bloom())` from `@threedog/post-effects`, then `look.post.set({ bloom: { strength } })` ([52 Post chain](52-look.md#post-effect-chain)) | `engine.look.post.add(new UnrealBloomPass(size, strength, radius, threshold))` |
34
+ | Light glow / halo | lamps, windows, signs that read as lit | a glowing object keeps its hue at the center (it is not a white block), has a halo where bloom is on, and lights its surroundings if it should | `look.materials.glow(match, { night })` ([52 Night glow](52-look.md#night-glow-emissive-that-follows-daylight)); many lamps: `lightPool` ([09 §1b](09-style.md#1b-lights-and-stalls)) | `material.emissive` / `material.emissiveIntensity`, an additive `THREE.Sprite` for a halo |
35
+ | Water, sea | color with depth, waves, foam, what it reflects | shallow and deep read differently, the far sea meets the sky without a seam, foam sits where waves break | `look.water.set({ depthColor, foam, waveHeight })` ([44](44-water-weather-look-hooks.md)) | three/addons `Water`, or a `ShaderMaterial` that reads `engine.uniforms.uSkyHorizon` ([44 own material](44-water-weather-look-hooks.md#water-your-own-material-reflections-refraction)) |
36
+ | Wet ground | streets and stone after rain | wet is darker and glossier together, gloss shows reflections of something bright, puddles have soft edges | no engine look: read `engine.weather.current.rain`, then `look.materials.set({ role: { color, roughness } })` ([08 §7](08-weather-sky.md#7-wet-roads-and-puddles-after-rain)) | `material.roughness`, `material.color` on your ground material |
37
+ | Color grading | contrast, saturation and warm / cool shift of the whole frame | the frame has the mood you named; skin, foliage and the player's colors still read | `look.post.add(lut())` from `@threedog/post-effects` ([52 Post chain](52-look.md#post-effect-chain)) | `engine.look.post.add(new LUTPass({ lut }))` |
38
+ | Cloud shadow | moving dark patches on the ground | the patches drift slowly enough to read as clouds, are as dark as the sky is cloudy, and do not hide gameplay | `look.cloudShadow.set({ shadow, scale, speed })`; clouds in the sky: `look.sky.set({ clouds })` ([36](36-sky-ground-plant-looks.md)) | your own patch: `look.cloudShadow.replace(spec)` ([52 Surface](52-look.md#surface-parts-materials-surface-ground-wind)) |
39
+ | Grain, vignette | film noise; darker frame corners | you notice the mood, not the effect; text and the HUD stay clean | `look.post.add(grain())`, `look.post.add(vignette())` ([52 Post chain](52-look.md#post-effect-chain)) | a pixel snippet: `engine.look.post.add({ name, fuse: { glsl }, slot: 'ldr' })` |
40
+ | Ambient occlusion | darker creases and contact corners | objects sit on the ground and corners have weight; no dark halo around thin things | `look.post.add(ao())` ([52 Post chain](52-look.md#post-effect-chain)) | three/addons `GTAOPass` through `engine.look.post.add(pass)` |
41
+ | Outline | lines around shapes | lines help read shapes at play distance and match the style's line weight | `look.post.add(outline())` ([52 Post chain](52-look.md#post-effect-chain)) | three/addons `OutlinePass` through `engine.look.post.add(pass)` |
42
+ | Surface shading | how light falls across a surface (smooth, banded, flat) | materials that should differ (wood, stone, metal, cloth) differ in response, not only in color | `look.surface.set({ lighting })`, `look.materials.set({ role: { ... } })` ([43](43-shader-patches-surface-looks.md), [48](48-make-material.md)) | `new THREE.MeshToonMaterial({ gradientMap })` or any material of yours |
43
+ | God rays, volumetric fog | light shafts, fog thick in the air | shafts come from where the light is and fade when it leaves the screen | your own depth effect ([59](59-depth-post-effects.md)) | a Pass of yours through `engine.look.post.add(pass)` |
44
+
45
+ ## Same knob, different styles
46
+ A knob is a direction, not a setting. Three styles, the same three knobs, moved different ways:
47
+
48
+ | Knob | Realistic dusk | Flat cartoon | Gloomy rainy night |
49
+ |---|---|---|---|
50
+ | Key against fill (sun, hemisphere) | a low, warm key against a cool fill: long shadows, faces lit on one side | a soft key and a strong fill, so shadows are a shape of color, not darkness; little warm / cool split | almost no key; the fill is dim and cool, and the light comes from lamps and windows instead |
51
+ | Fog | follows the horizon color; starts far, so the distance turns golden-grey | often light or off, so the bright flat colors stay clean; if on, a pale tint of the sky | close and dark, a color of its own (blue-grey), so lamps are islands in it |
52
+ | Bloom and glow | a gentle bloom on the sun and the first lit windows | little or none; glowing things are a brighter flat color | lamps and signs carry it: saturated glow, a halo through the rain, reflections on the wet ground below |
53
+
54
+ Read the other knobs the same way: ask what the style wants the viewer to notice first, then move the knob toward that and stop when the shot
55
+ shows it.
@@ -0,0 +1 @@
1
+ {"version":1,"files":{"content/actions.js":{"kind":"actions","mtime":1793699847055.6516,"from":0,"count":4,"indexIds":0,"positional":[]},"content/audio.js":{"kind":"audio","mtime":1793627600000,"from":0,"count":1,"indexIds":0,"positional":[]},"content/items.js":{"kind":"items","mtime":1793474271374.5977,"from":0,"count":1,"indexIds":0,"positional":[]},"content/places.js":{"kind":"places","mtime":1793474271377.595,"from":0,"count":1,"indexIds":0,"positional":[]},"content/props.js":{"kind":"props","mtime":1793474271380.606,"from":0,"count":8,"indexIds":0,"positional":[]},"content/templates.js":{"kind":"templates","mtime":1793474271383.605,"from":0,"count":4,"indexIds":0,"positional":[]},"content/views.js":{"kind":"views","mtime":1793530314731.8745,"from":0,"count":2,"indexIds":0,"positional":[]}},"ids":{"attack":[{"file":"content/actions.js","kind":"actions","line":4,"placed":false}],"retry":[{"file":"content/actions.js","kind":"actions","line":5,"placed":false}],"save":[{"file":"content/actions.js","kind":"actions","line":6,"placed":false}],"load":[{"file":"content/actions.js","kind":"actions","line":7,"placed":false}],"sounds":[{"file":"content/audio.js","kind":"audio","line":4,"placed":false}],"gem":[{"file":"content/items.js","kind":"items","line":3,"placed":false}],"room":[{"file":"content/places.js","kind":"places","line":3,"placed":false}],"floor":[{"file":"content/props.js","kind":"props","line":3,"placed":true},{"file":"content/templates.js","kind":"templates","line":4,"placed":false}],"wall-n":[{"file":"content/props.js","kind":"props","line":4,"placed":true}],"wall-s":[{"file":"content/props.js","kind":"props","line":5,"placed":true}],"wall-w":[{"file":"content/props.js","kind":"props","line":6,"placed":true}],"wall-e":[{"file":"content/props.js","kind":"props","line":7,"placed":true}],"pillar-1":[{"file":"content/props.js","kind":"props","line":8,"placed":true}],"pillar-2":[{"file":"content/props.js","kind":"props","line":9,"placed":true}],"slime-1":[{"file":"content/props.js","kind":"props","line":10,"placed":true}],"wall":[{"file":"content/templates.js","kind":"templates","line":5,"placed":false}],"pillar":[{"file":"content/templates.js","kind":"templates","line":6,"placed":false}],"slime":[{"file":"content/templates.js","kind":"templates","line":9,"placed":false}],"corner":[{"file":"content/views.js","kind":"views","line":4,"placed":false}],"door":[{"file":"content/views.js","kind":"views","line":5,"placed":false}]}}
@@ -13,28 +13,31 @@ Content: actions 4 · audio 1 · items 1 · places 1 · props 8 (from templates
13
13
 
14
14
  ## Engine modules (engine.use)
15
15
 
16
- - createEngine: { style, ui: { loading: { title: 'action' } }, saveKey: 'threedog-action' }
17
- - openWorld preset ({ camera: followCamera({ ...presets.camera.overShoulder, yaw: Math.PI }), terrain: false, vegetatio…) → world, sky, collision, characters, settings, debug
16
+ - createEngine: { bindings: { ...presets.bindings.walk, ...presets.bindings.interact, ...presets.bindings.inventory, ...prese…
17
+ - openWorld preset ({ camera: followCamera({ ...presets.camera.overShoulder, yaw: Math.PI }), terrain: false, vegetatio…) → world, calendar, sky, collision, characters, settings, debug
18
18
  - interactions ({ ...presets.interactions.nearest })
19
- - inventory ({ ...presets.keys.inventory })
19
+ - inventory
20
+ - pickups
20
21
  - content
21
22
  - hud
22
23
 
23
24
  ## Read for this game (per installed module: recipe · api page; core API: `node_modules/threedog/docs/api/engine.md`)
24
25
 
25
26
  - world: `node_modules/threedog/docs/recipes/18-world.md` · `node_modules/threedog/docs/api/world.md`
27
+ - calendar: `node_modules/threedog/docs/recipes/06-clock-events.md` · `node_modules/threedog/docs/api/calendar.md`
26
28
  - sky: `node_modules/threedog/docs/recipes/08-weather-sky.md` · `node_modules/threedog/docs/api/sky.md`
27
29
  - collision: `node_modules/threedog/docs/recipes/12-navmesh.md` · `node_modules/threedog/docs/api/collision.md`
28
30
  - characters: `node_modules/threedog/docs/recipes/12-navmesh.md` · `node_modules/threedog/docs/api/characters.md`
29
31
  - settings: `node_modules/threedog/docs/recipes/26-ui-parts.md` · `node_modules/threedog/docs/api/settings.md`
30
32
  - interactions: `node_modules/threedog/docs/recipes/20-content-actions-save.md` · `node_modules/threedog/docs/api/interactions.md`
31
33
  - inventory: `node_modules/threedog/docs/recipes/03-items-pickups.md` · `node_modules/threedog/docs/api/inventory.md`
32
- - content: `node_modules/threedog/docs/recipes/01-new-game.md` · `node_modules/threedog/docs/api/content.md`
33
- - hud: `node_modules/threedog/docs/recipes/04-quests.md` · `node_modules/threedog/docs/api/hud.md`
34
+ - pickups: `node_modules/threedog/docs/recipes/03-items-pickups.md` · `node_modules/threedog/docs/api/pickups.md`
35
+ - content: `node_modules/threedog/docs/recipes/30-templates.md` · `node_modules/threedog/docs/api/content.md`
36
+ - …1 more modules: their pages are in `node_modules/threedog/docs/api/`
34
37
 
35
38
  Not used yet (check these before writing the system yourself):
36
39
 
37
- - quests: goals with steps, conditions and rewards: `quests({ ...presets.keys.quests })` (keys required), content/quests.js (node_modules/threedog/docs/recipes/04-quests.md)
40
+ - quests: goals with steps, conditions and rewards: `quests()` + key map presets.bindings.quests, content/quests.js (node_modules/threedog/docs/recipes/04-quests.md)
38
41
  - grids: cell placement for farming and building: `grids()` (node_modules/threedog/docs/recipes/29-grid.md)
39
42
 
40
43
  ## Files
@@ -43,6 +46,7 @@ content/*.js is content data: how to write it in `node_modules/threedog/docs/rec
43
46
 
44
47
  | File | Lines | Description |
45
48
  |---|---|---|
49
+ | assets.js | 9 | The asset packs this game registers (main.js: engine.assets.manifest(packs)). Kept in their own fil… |
46
50
  | content/actions.js | 9 | |
47
51
  | content/audio.js | 10 | |
48
52
  | content/index.js | 11 | |
@@ -51,9 +55,9 @@ content/*.js is content data: how to write it in `node_modules/threedog/docs/rec
51
55
  | content/props.js | 12 | |
52
56
  | content/templates.js | 11 | |
53
57
  | content/views.js | 7 | |
54
- | look.js | 6 | This example's look, as a style part merged over the lowpoly pack (createEngine({ style: [lowpoly, … |
55
- | main.js | 139 | @ts-check Action example: one room, one player, one slime, one drop. Shows how an action game wires… |
56
- | models.js | 26 | Models this example builds in code (floor, wall, pillar, enemy), registered by name in main.js and … |
58
+ | look.js | 6 | This example's look, its whole style (createEngine({ style: look })): the colors models.js reads. L… |
59
+ | main.js | 135 | @ts-check Action example: one room, one player, one slime, one drop. Shows how an action game wires… |
60
+ | models.js | 27 | Models this example builds in code (floor, wall, pillar, enemy), registered by name through assets.… |
57
61
 
58
62
  ## NPCs (content/npcs.js)
59
63
 
@@ -79,7 +83,7 @@ Starting inventory: empty. Pickups: 0.
79
83
 
80
84
  - Place room: the centre of the one room (the origin)
81
85
 
82
- ## Object templates (content/templates.js; placed with props { template }, spawned with engine.spawn)
86
+ ## Object templates (content/templates.js; placed with props { template }, spawned with engine.content.spawn)
83
87
 
84
88
  | Template | Model | Collide | Interact (op / label) | Container | State (defaults) | Instances |
85
89
  |---|---|---|---|---|---|---|
@@ -119,9 +123,9 @@ Code that breaks saves or manages world models: none (rule R33).
119
123
  - Save slots: slot1
120
124
  - Save entries the game registers itself: ' +
121
125
  'action
122
- - Saved parts of the engine modules (vars, inventory, quests, timers, world...): `npx threedog catalog` (saves per module)
126
+ - Saved parts of the engine modules (vars, inventory, quests, timers, world...): `threedog catalog` (saves per module)
123
127
 
124
- ## Style pack keys
128
+ ## Style keys
125
129
 
126
- - Style pack: none (all neutral fallback look)
130
+ - Style: none (all neutral fallback look)
127
131
  - Models (asset names): floor, wall, pillar, enemy
@@ -0,0 +1,8 @@
1
+ // The asset packs this game registers (main.js: engine.assets.manifest(packs)). Kept in their own file so `npm run check` imports the same
2
+ // objects and checks the model / sound names content uses against them (one source, no scanning of main.js).
3
+ import { models } from './models.js';
4
+
5
+ // blip: a tiny synth content/audio.js names; a sound made in code is registered like a file, by name
6
+ const blip = (a, p, out) => { a.tone({ freq: (p.freq ?? 440) * p.pitch, dur: 0.12, out }); return 0.12; };
7
+
8
+ export default [{ name: 'action', models, sounds: { blip } }];
@@ -1,5 +1,5 @@
1
1
  // This example's key actions: name -> keys and label. What a press does lives in main.js (attack in a fixed step, retry / save / load in the frame hook).
2
- // Move, interact (E, from presets.interactions.nearest) and the bag (I, from presets.keys.inventory) come from their modules.
2
+ // Move, interact (E, presets.bindings.interact) and the bag (I, presets.bindings.inventory) come from their modules.
3
3
  export default {
4
4
  attack: { keys: ['Mouse0', 'KeyF'], label: 'Attack' },
5
5
  retry: { keys: ['KeyR'], label: 'Retry' },
@@ -1,9 +1,9 @@
1
- // Sounds as content data (no functions, no paths). 'blip' is a tiny synth main.js registers (engine.audio.register); a game with files names
2
- // asset-pack sounds here instead ({ hit: ['hit-1', 'hit-2'] }).
1
+ // How sounds play, as content data (no functions, no paths). 'blip' is a tiny synth main.js registers as a sound asset (assets.manifest({ sounds }));
2
+ // a game with files names its asset-pack sounds the same way ({ hit: ['hit-1', 'hit-2'] }).
3
3
  export default {
4
4
  sounds: {
5
- hit: { synth: 'blip', params: { freq: 660 } },
6
- hurt: { synth: 'blip', params: { freq: 170 } },
7
- kill: { synth: 'blip', params: { freq: 990 } },
5
+ hit: { src: 'blip', params: { freq: 660 } },
6
+ hurt: { src: 'blip', params: { freq: 170 } },
7
+ kill: { src: 'blip', params: { freq: 990 } },
8
8
  },
9
9
  };
@@ -1,4 +1,4 @@
1
- // This example's look, as a style part merged over the lowpoly pack (createEngine({ style: [lowpoly, look] })). Logic never reads colors; models.js does.
1
+ // This example's look, its whole style (createEngine({ style: look })): the colors models.js reads. Logic never reads colors; models.js does.
2
2
  export default {
3
3
  name: 'action', // a part needs at least one Style field (TypeScript rejects an object that shares none), so it names itself
4
4
  action: { floor: 0x5b6168, wall: 0x8a8f96, pillar: 0x9a8c78, enemy: 0x6fbf5a, eye: 0x1d2024 },
@@ -2,11 +2,10 @@
2
2
  // Action example: one room, one player, one slime, one drop. Shows how an action game wires the engine's systems; the combat rules are this file's own.
3
3
  // main.js holds rules only: modules, ops (attack, damage, enemy attack, death), fixed-step logic, presentation. The room, the slime and its stats are
4
4
  // content (content/templates.js + props.js, rule R33). The engine has no health, damage or death: all of that is below, as plain game state and ops.
5
- import { createEngine, openWorld, followCamera, presets, interactions, inventory, content, hud, toast } from '../../index.js';
6
- import lowpoly, { assets as lowpolyAssets } from '@threedog/style-lowpoly'; // optional style pack + its asset pack (the humanoid body); ?style=none runs with the engine's gray placeholders
7
- import look from './look.js';
5
+ import { createEngine, openWorld, followCamera, presets, interactions, inventory, pickups, content, hud, toast } from '../../index.js';
6
+ import look from './look.js'; // this example's whole look (room and enemy colors); ?style=none runs with the engine's gray placeholders
8
7
  import data from './content/index.js';
9
- import { models } from './models.js';
8
+ import packs from './assets.js';
10
9
 
11
10
  const url = new URLSearchParams(location.search);
12
11
  // Tuning of the rules (the slime's own numbers are instance state in content/templates.js)
@@ -19,19 +18,16 @@ const TUNE = Object.freeze({
19
18
  onDeath: url.get('death') ?? 'respawn',
20
19
  });
21
20
 
22
- const style = url.get('style') === 'none' ? undefined : [lowpoly, look];
23
- const engine = createEngine({ canvas: /** @type {HTMLCanvasElement} */ (document.getElementById('view')), style, ui: { loading: { title: 'action' } }, saveKey: 'threedog-action' });
21
+ const style = url.get('style') === 'none' ? undefined : look;
22
+ const engine = createEngine({ bindings: { ...presets.bindings.walk, ...presets.bindings.interact, ...presets.bindings.inventory, ...presets.bindings.debug }, canvas: /** @type {HTMLCanvasElement} */ (document.getElementById('view')), style, ui: { loading: { title: 'action' } }, saveKey: 'threedog-action' });
24
23
  // A room needs no terrain, plants, weather, water or physics; a fixed time of day; an over-the-shoulder camera that locks the mouse on click,
25
24
  // starting behind the player looking along +Z into the room (yaw = which side of the player the camera sits on: PI = the -Z side)
26
25
  engine.use(openWorld({ camera: followCamera({ ...presets.camera.overShoulder, yaw: Math.PI }), terrain: false, vegetation: false, weather: false, water: false, rigid: false, ambience: false,
27
- sky: { ...presets.calendar.fixedTime, time: 0.42 }, characters: { npcs: false } }),
28
- interactions({ ...presets.interactions.nearest }), inventory({ ...presets.keys.inventory }), content(), hud());
26
+ calendar: { ...presets.calendar.fixedTime, time: 0.42 }, characters: { npcs: false } }),
27
+ interactions({ ...presets.interactions.nearest }), inventory(), pickups(), content(), hud());
29
28
 
30
- const m = models(engine); // the names content/templates.js uses, written out so `npm run check` can see them
31
- engine.assets.manifest({ name: 'action', models: { floor: m.floor, wall: m.wall, pillar: m.pillar, enemy: m.enemy } });
32
- engine.audio.register('blip', (a, p, out) => { a.tone({ freq: (p.freq ?? 440) * p.pitch, dur: 0.12, out }); return 0.12; }); // content/audio.js names it
33
- if (style) engine.assets.manifest(lowpolyAssets); // the 'humanoid' body; style=none keeps the gray capsule
34
- engine.characters.createPlayer({ ...presets.player.aim, model: style ? 'humanoid' : null, spawn: TUNE.spawn }); // face where the camera looks: a swing goes where you aim
29
+ engine.assets.manifest(packs); // assets.js: floor / wall / pillar / enemy (content/templates.js) and the blip synth (content/audio.js)
30
+ engine.characters.createPlayer({ ...presets.player.aim, spawn: TUNE.spawn }); // no body asset: the engine's gray capsule; face where the camera looks: a swing goes where you aim
35
31
  engine.content.load(data, { places: { room: { x: 0, z: 0 } } });
36
32
 
37
33
  // ---------- Game state: plain values, described and saved (one player, so it is not keyed by actor) ----------
@@ -66,7 +62,7 @@ engine.ops.define('enemy.damage', {
66
62
  const r = e.world.get(id), hp = Math.max(0, r.hp - amount);
67
63
  if (hp > 0) { e.world.set(id, { hp }); e.audio.sfx('hit', { at: r.position }); return hp; }
68
64
  // Death: the drop is a pickup made during play (inside an op, rule R33); a stable id ties it to this slime so a save keeps it
69
- e.inventory.spawnPickup(r.drop, r.position, { id: `${id}-drop`, respawnSeconds: 0 });
65
+ e.pickups.spawn(r.position, { give: r.drop, id: `${id}-drop` });
70
66
  e.world.remove(id); // the saved world remembers the slime is gone
71
67
  e.vars.bump('kills');
72
68
  e.audio.sfx('kill', { at: r.position });
@@ -1,25 +1,26 @@
1
- // Models this example builds in code (floor, wall, pillar, enemy), registered by name in main.js and placed by content/templates.js + props.js.
2
- // Colors come from the style pack's `action` key (look.js, merged as a style part); with no style pack every model is the engine's neutral gray.
1
+ // Models this example builds in code (floor, wall, pillar, enemy), registered by name through assets.js and placed by content/templates.js + props.js.
2
+ // Colors come from the style's `action` key (look.js, merged as a style part); with no style every model is the engine's neutral gray.
3
+ // Written with `function` (not arrows): a generator's `this` is { palette, engine }, so it reads the style without closing over an engine,
4
+ // which keeps this file importable on its own (assets.js, `npm run check`).
3
5
  import { THREE, makeMaterial } from '../../index.js';
4
6
 
5
- /** Model generators that read their colors from engine.style.action (missing = gray) @param {{ style: any }} engine */
6
- export function models(engine) {
7
- const look = () => engine.style?.action ?? {};
8
- const mesh = (geo, role, color) => {
9
- const m = new THREE.Mesh(geo, makeMaterial(role, color === undefined ? {} : { color, flatShading: true }));
10
- m.castShadow = m.receiveShadow = true;
11
- return m;
12
- };
13
- return {
14
- floor: () => mesh(new THREE.BoxGeometry(16, 0.2, 16).translate(0, -0.1, 0), 'prop', look().floor),
15
- wall: () => mesh(new THREE.BoxGeometry(16, 2.4, 0.5).translate(0, 1.2, 0), 'prop', look().wall),
16
- pillar: () => mesh(new THREE.CylinderGeometry(0.5, 0.6, 2.8, 8).translate(0, 1.4, 0), 'prop', look().pillar),
17
- // A squat body with two eyes: the eyes face +Z, the facing every character uses (CONVENTIONS: characters face +Z)
18
- enemy: () => {
19
- const g = new THREE.Group();
20
- g.add(mesh(new THREE.SphereGeometry(0.55, 10, 8).scale(1, 0.75, 1).translate(0, 0.42, 0), 'character', look().enemy));
21
- for (const x of [-0.2, 0.2]) g.add(mesh(new THREE.SphereGeometry(0.09, 6, 4).translate(x, 0.6, 0.48), 'character', look().eye));
22
- return g;
23
- },
24
- };
25
- }
7
+ const look = ctx => ctx?.engine?.style?.action ?? {};
8
+ const mesh = (geo, role, color) => {
9
+ const m = new THREE.Mesh(geo, makeMaterial(role, color === undefined ? {} : { color, flatShading: true }));
10
+ m.castShadow = m.receiveShadow = true;
11
+ return m;
12
+ };
13
+
14
+ /** Model generators that read their colors from engine.style.action (missing = gray) */
15
+ export const models = {
16
+ floor() { return mesh(new THREE.BoxGeometry(16, 0.2, 16).translate(0, -0.1, 0), 'prop', look(this).floor); },
17
+ wall() { return mesh(new THREE.BoxGeometry(16, 2.4, 0.5).translate(0, 1.2, 0), 'prop', look(this).wall); },
18
+ pillar() { return mesh(new THREE.CylinderGeometry(0.5, 0.6, 2.8, 8).translate(0, 1.4, 0), 'prop', look(this).pillar); },
19
+ // A squat body with two eyes: the eyes face +Z, the facing every character uses (CONVENTIONS: characters face +Z)
20
+ enemy() {
21
+ const g = new THREE.Group(), c = look(this);
22
+ g.add(mesh(new THREE.SphereGeometry(0.55, 10, 8).scale(1, 0.75, 1).translate(0, 0.42, 0), 'character', c.enemy));
23
+ for (const x of [-0.2, 0.2]) g.add(mesh(new THREE.SphereGeometry(0.09, 6, 4).translate(x, 0.6, 0.48), 'character', c.eye));
24
+ return g;
25
+ },
26
+ };
@@ -0,0 +1,111 @@
1
+ {
2
+ "about": "Examples `threedog examples list|pull` can copy into a game. The single list: a folder under examples/ is pullable only when it is named here. Summary = the first line of its README.md. files = the game-facing files (the demo page and its main.js stay here). use = the line to print after a pull, paths relative to the pulled folder.",
3
+ "examples": {
4
+ "contact-shadows": {
5
+ "dir": "techniques/contact-shadows",
6
+ "files": [
7
+ "README.md",
8
+ "contactShadows.js"
9
+ ],
10
+ "use": "import { applyContactShadows, groundStatic } from './contactShadows.js'; applyContactShadows(engine);"
11
+ },
12
+ "day-night-grade": {
13
+ "dir": "techniques/day-night-grade",
14
+ "files": [
15
+ "README.md",
16
+ "dayNightGrade.js"
17
+ ],
18
+ "use": "import { dayNightStyle, followDayNight } from './dayNightGrade.js'; createEngine({ style: [yourStyle, dayNightStyle()] }); followDayNight(engine, { lamps });"
19
+ },
20
+ "interior-light": {
21
+ "dir": "techniques/interior-light",
22
+ "files": [
23
+ "README.md",
24
+ "interiorLight.js"
25
+ ],
26
+ "use": "import { exposureZones, windowLight } from './interiorLight.js'; exposureZones(engine, { isInside, exposure, ambient }); windowLight(engine, { position, lookAt, width, height });"
27
+ },
28
+ "modular-building": {
29
+ "dir": "techniques/modular-building",
30
+ "files": [
31
+ "README.md",
32
+ "kit.js"
33
+ ],
34
+ "use": "import { createModularKit } from './kit.js'; const kit = createModularKit({ slots: { wall: yourWallMaterial } }); engine.assets.manifest(kit.pack);"
35
+ },
36
+ "night-lights": {
37
+ "dir": "techniques/night-lights",
38
+ "files": [
39
+ "README.md",
40
+ "nightLights.js"
41
+ ],
42
+ "use": "import { createNightLights } from './nightLights.js'; createNightLights(engine, { /* lamps, glow names */ });"
43
+ },
44
+ "outlines-and-rim": {
45
+ "dir": "techniques/outlines-and-rim",
46
+ "files": [
47
+ "README.md",
48
+ "outlines.js"
49
+ ],
50
+ "use": "import { trackResolution, addHull, rimPatch } from './outlines.js'; // see README for which route fits your DESIGN.md"
51
+ },
52
+ "procedural-animation": {
53
+ "dir": "techniques/procedural-animation",
54
+ "files": [
55
+ "README.md",
56
+ "proceduralAnim.js",
57
+ "creature.js"
58
+ ],
59
+ "use": "import { createProceduralAnimator, KNOBS } from './proceduralAnim.js'; const anim = createProceduralAnimator({ body, legs, tail }); // update it in onFrame (README)"
60
+ },
61
+ "procedural-surface": {
62
+ "dir": "techniques/procedural-surface",
63
+ "files": [
64
+ "README.md",
65
+ "surface.js"
66
+ ],
67
+ "use": "import { scaleForCamera, worldVariation, brushTexture, cavity } from './surface.js'; // see README for which route fits your DESIGN.md"
68
+ },
69
+ "rc2d": {
70
+ "dir": "rc2d",
71
+ "files": [
72
+ "README.md",
73
+ "rc2d.js",
74
+ "shaders.js"
75
+ ],
76
+ "use": "import { createRadianceCascades2D } from './rc2d.js'; createRadianceCascades2D(engine, { layer: 5, ambient: 0.15 });"
77
+ },
78
+ "stylized-shading": {
79
+ "dir": "techniques/stylized-shading",
80
+ "files": [
81
+ "README.md",
82
+ "shading.js"
83
+ ],
84
+ "use": "import { rampTexture, toonMaterial, toonPatch, painterlyMaterial } from './shading.js'; // see README for which route fits your DESIGN.md"
85
+ },
86
+ "sun-and-key-light": {
87
+ "dir": "techniques/sun-and-key-light",
88
+ "files": [
89
+ "README.md",
90
+ "keyLight.js"
91
+ ],
92
+ "use": "import { applyKeyFill, aimSun, fitSunShadow } from './keyLight.js'; applyKeyFill(engine, route); aimSun(engine, { elevation, azimuth, camera }); fitSunShadow(engine, { extent });"
93
+ },
94
+ "webgpu-tsl": {
95
+ "dir": "webgpu-tsl",
96
+ "files": [
97
+ "README.md",
98
+ "tslScene.js"
99
+ ],
100
+ "use": "import 'threedog/tsl'; import { createTslScene } from './tslScene.js'; createEngine({ renderer: 'webgpu' }); createTslScene(engine); // before engine.start()"
101
+ },
102
+ "wet-road": {
103
+ "dir": "techniques/wet-road",
104
+ "files": [
105
+ "README.md",
106
+ "wetRoad.js"
107
+ ],
108
+ "use": "import { createWetRoad } from './wetRoad.js'; createWetRoad(engine, { materials: [roadMaterial] });"
109
+ }
110
+ }
111
+ }
@@ -0,0 +1 @@
1
+ {"version":1,"files":{},"ids":{}}
@@ -0,0 +1,83 @@
1
+ # Game map: rc2d (generated, do not edit by hand)
2
+
3
+ > Generated by `npm run map` by scanning this folder; paths are relative to it. Pages: /rc2d.html, entry `main.js`.
4
+ > Content data is in `content/*.js` (condition/effect syntax: `node_modules/threedog/docs/recipes/20-content-actions-save.md`), which main.js hands to the engine with `engine.content.load()`; for the engine API read `node_modules/threedog/docs/API.md` (index) first, then only the module pages listed below.
5
+
6
+ Content: none (no content/ folder)
7
+
8
+ ## Design decisions (hand-written, from DESIGN.md)
9
+
10
+ None yet, write them in `DESIGN.md` (why it is designed this way, what not to change).
11
+
12
+ ## Engine modules (engine.use)
13
+
14
+ - createEngine: { lights: false, ui: { loading: false }, saveKey: 'threedog-rc2d' }
15
+ - fixedCamera ({ shots: { top }, start: 'top' })
16
+
17
+ ## Read for this game (per installed module: recipe · api page; core API: `node_modules/threedog/docs/api/engine.md`)
18
+
19
+ - cameraRig: `node_modules/threedog/docs/recipes/21-camera.md` · `node_modules/threedog/docs/api/cameraRig.md`
20
+
21
+ Not used yet (check these before writing the system yourself):
22
+
23
+ - inventory: items, stacks, containers and pickups: `inventory()` + key map presets.bindings.inventory, content/items.js (node_modules/threedog/docs/recipes/03-items-pickups.md)
24
+ - collision: walls and blocking for characters: `collision()` (in openWorld), template `collide` (node_modules/threedog/docs/recipes/18-world.md)
25
+ - characters: player and NPC movement, spawn, schedules: `characters()` (in openWorld), content/npcs.js (node_modules/threedog/docs/recipes/02-npc.md)
26
+ - saves: save your own state: `engine.saves.register(key, { version, save, load })` (node_modules/threedog/docs/recipes/20-content-actions-save.md)
27
+ - interactions: press a key near a thing: `interactions({ ...presets.interactions.nearest })` (E, nearest; the game picks the pick mode and keys), template `interact: { label, op }` (node_modules/threedog/docs/recipes/30-templates.md)
28
+ - quests: goals with steps, conditions and rewards: `quests()` + key map presets.bindings.quests, content/quests.js (node_modules/threedog/docs/recipes/04-quests.md)
29
+ - grids: cell placement for farming and building: `grids()` (node_modules/threedog/docs/recipes/29-grid.md)
30
+ - templates: reusable objects placed from content: content/templates.js + props { template } (node_modules/threedog/docs/recipes/30-templates.md)
31
+
32
+ ## Files
33
+
34
+ content/*.js is content data: how to write it in `node_modules/threedog/docs/recipes/` (02-npc, 03-items-pickups, 04-quests, 20-content-actions-save…).
35
+
36
+ | File | Lines | Description |
37
+ |---|---|---|
38
+ | main.js | 64 | @ts-check 2D radiance cascades demo (page /rc2d.html): a top-down street at night. Street lamps, li… |
39
+ | rc2d.js | 198 | @ts-check 2D radiance cascades: screen-space global illumination for top-down and side-view games (… |
40
+ | shaders.js | 145 | GLSL for rc2d.js (2D radiance cascades), GLSL ES 3.0 as three.js compiles a ShaderMaterial under We… |
41
+
42
+ ## NPCs (content/npcs.js)
43
+
44
+ (none)
45
+
46
+ ## Dialogues (content/dialogues.js, node → destination)
47
+
48
+ (none)
49
+
50
+ ## Items (content/items.js)
51
+
52
+ (none)
53
+
54
+ ## Quests (content/quests.js)
55
+
56
+ (none)
57
+
58
+ ## Trigger zones, level markers, places
59
+
60
+ (none)
61
+
62
+ ## Placements (the level is content; counts per content file)
63
+
64
+ - none in content yet: place things with a template (content/templates.js) and a placement (content/props.js)
65
+
66
+ Code that breaks saves or manages world models: none (rule R33).
67
+
68
+ ## Key actions defined by the game (the engine's own are in node_modules/threedog/docs/CODEMAP.md)
69
+
70
+ (none)
71
+
72
+ ## Events the game emits / listens to
73
+
74
+ (none)
75
+
76
+ ## Saves
77
+
78
+ - Save prefix saveKey: threedog-rc2d
79
+ - Saved parts of the engine modules (vars, inventory, quests, timers, world...): `threedog catalog` (saves per module)
80
+
81
+ ## Style keys
82
+
83
+ - Style: none (all neutral fallback look)