threedog 0.0.0-stage → 0.2.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 (506) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/LICENSE +21 -0
  3. package/README.md +39 -2
  4. package/core/Animator.js +268 -0
  5. package/core/Assets.js +256 -0
  6. package/core/Audio.js +267 -0
  7. package/core/Baked.js +72 -0
  8. package/core/Batching.js +247 -0
  9. package/core/Budget.js +221 -0
  10. package/core/Clock.js +94 -0
  11. package/core/Commits.js +77 -0
  12. package/core/DebugOverrides.js +143 -0
  13. package/core/Describe.js +145 -0
  14. package/core/Engine.js +184 -0
  15. package/core/Events.js +153 -0
  16. package/core/I18n.js +94 -0
  17. package/core/Input.js +245 -0
  18. package/core/Inspect.js +77 -0
  19. package/core/InspectScene.js +191 -0
  20. package/core/Jobs.js +146 -0
  21. package/core/Loading.js +149 -0
  22. package/core/MaterialInfo.js +32 -0
  23. package/core/Ops.js +256 -0
  24. package/core/Random.js +52 -0
  25. package/core/Rays.js +160 -0
  26. package/core/SaveStore.js +85 -0
  27. package/core/Saves.js +254 -0
  28. package/core/Stream.js +279 -0
  29. package/core/Threads.js +158 -0
  30. package/core/UrlState.js +94 -0
  31. package/core/Vars.js +35 -0
  32. package/core/Views.js +49 -0
  33. package/core/actor.js +23 -0
  34. package/core/assetEntry.js +89 -0
  35. package/core/assetLoad.js +190 -0
  36. package/core/assetManifest.js +35 -0
  37. package/core/assetReport.js +83 -0
  38. package/core/audioRules.js +121 -0
  39. package/core/audioVoice.js +225 -0
  40. package/core/batchGroups.js +116 -0
  41. package/core/canvasBox.js +63 -0
  42. package/core/catalog.js +169 -0
  43. package/core/checks.js +67 -0
  44. package/core/claims.js +51 -0
  45. package/core/dayTime.js +15 -0
  46. package/core/debugView.js +76 -0
  47. package/core/describeRender.js +45 -0
  48. package/core/describeText.js +143 -0
  49. package/core/easing.js +34 -0
  50. package/core/errorCodes.js +205 -0
  51. package/core/errorHints.js +208 -0
  52. package/core/errors.js +40 -0
  53. package/core/events.generated.js +84 -0
  54. package/core/ground.js +102 -0
  55. package/core/holds.js +106 -0
  56. package/core/inputContext.js +69 -0
  57. package/core/inputDefaults.js +22 -0
  58. package/core/inputPad.js +35 -0
  59. package/core/inputPointer.js +48 -0
  60. package/core/inputTouch.js +48 -0
  61. package/core/lifecycle.js +69 -0
  62. package/core/lightWatch.js +56 -0
  63. package/core/look/coreParts.js +112 -0
  64. package/core/look/layers.js +136 -0
  65. package/core/look/part.js +173 -0
  66. package/core/look/report.js +79 -0
  67. package/core/look/write.js +86 -0
  68. package/core/loop.js +200 -0
  69. package/core/math.js +33 -0
  70. package/core/modules.js +196 -0
  71. package/core/movement.js +19 -0
  72. package/core/mulberry32.js +14 -0
  73. package/core/opsAtomic.js +31 -0
  74. package/core/opsCheck.js +97 -0
  75. package/core/opsFail.js +20 -0
  76. package/core/opsGuard.js +26 -0
  77. package/core/opsHistory.js +27 -0
  78. package/core/opsRun.js +77 -0
  79. package/core/page.js +78 -0
  80. package/core/params.js +132 -0
  81. package/core/pureWorker.js +5 -0
  82. package/core/renamed.js +21 -0
  83. package/core/saveApply.js +128 -0
  84. package/core/saveFiles.js +139 -0
  85. package/core/saveIds.js +53 -0
  86. package/core/saveVersions.js +97 -0
  87. package/core/scatter.js +92 -0
  88. package/core/sceneMethods.js +100 -0
  89. package/core/screenToGround.js +39 -0
  90. package/core/services.js +73 -0
  91. package/core/session.js +171 -0
  92. package/core/shadowTypes.js +15 -0
  93. package/core/skip.js +104 -0
  94. package/core/startup.js +135 -0
  95. package/core/streamCells.js +24 -0
  96. package/core/streamSources.js +73 -0
  97. package/core/styleParts.js +96 -0
  98. package/core/targeting.js +64 -0
  99. package/core/thingExplain.js +68 -0
  100. package/core/thingOps.js +168 -0
  101. package/core/things.js +212 -0
  102. package/core/threadPure.js +120 -0
  103. package/core/threadServe.js +25 -0
  104. package/core/tier.js +11 -0
  105. package/core/util.js +11 -0
  106. package/core/validate.js +204 -0
  107. package/docs/AI.md +123 -0
  108. package/docs/API.md +83 -0
  109. package/docs/CODEMAP.md +347 -0
  110. package/docs/COMMANDS.md +108 -0
  111. package/docs/CONVENTIONS.md +145 -0
  112. package/docs/PERF.md +217 -0
  113. package/docs/THREE.md +86 -0
  114. package/docs/api/ambience.md +15 -0
  115. package/docs/api/assets.md +62 -0
  116. package/docs/api/audio.md +53 -0
  117. package/docs/api/budget.md +40 -0
  118. package/docs/api/cameraRig.md +120 -0
  119. package/docs/api/characters.md +144 -0
  120. package/docs/api/clock.md +7 -0
  121. package/docs/api/collision.md +39 -0
  122. package/docs/api/content.md +64 -0
  123. package/docs/api/dialogue.md +39 -0
  124. package/docs/api/engine.md +199 -0
  125. package/docs/api/entities.md +61 -0
  126. package/docs/api/events.md +95 -0
  127. package/docs/api/flow.md +27 -0
  128. package/docs/api/grids.md +11 -0
  129. package/docs/api/ground.md +16 -0
  130. package/docs/api/hlod.md +34 -0
  131. package/docs/api/hud.md +31 -0
  132. package/docs/api/i18n.md +10 -0
  133. package/docs/api/input.md +24 -0
  134. package/docs/api/interactions.md +31 -0
  135. package/docs/api/inventory.md +66 -0
  136. package/docs/api/jobs.md +10 -0
  137. package/docs/api/level.md +41 -0
  138. package/docs/api/lightPool.md +56 -0
  139. package/docs/api/music.md +34 -0
  140. package/docs/api/nav.md +26 -0
  141. package/docs/api/net.md +14 -0
  142. package/docs/api/openWorld.md +24 -0
  143. package/docs/api/particles.md +41 -0
  144. package/docs/api/photo.md +15 -0
  145. package/docs/api/post.md +10 -0
  146. package/docs/api/quests.md +36 -0
  147. package/docs/api/rays.md +26 -0
  148. package/docs/api/rigid.md +84 -0
  149. package/docs/api/saves.md +32 -0
  150. package/docs/api/settings.md +36 -0
  151. package/docs/api/sky.md +58 -0
  152. package/docs/api/stream.md +31 -0
  153. package/docs/api/style.md +134 -0
  154. package/docs/api/terrain.md +34 -0
  155. package/docs/api/timeline.md +39 -0
  156. package/docs/api/tools.md +57 -0
  157. package/docs/api/triggers.md +56 -0
  158. package/docs/api/vars.md +9 -0
  159. package/docs/api/vegetation.md +52 -0
  160. package/docs/api/water.md +48 -0
  161. package/docs/api/weather.md +29 -0
  162. package/docs/api/world.md +30 -0
  163. package/docs/recipes/01-new-game.md +148 -0
  164. package/docs/recipes/02-npc.md +167 -0
  165. package/docs/recipes/03-items-pickups.md +158 -0
  166. package/docs/recipes/04-quests.md +83 -0
  167. package/docs/recipes/05-props-bake.md +159 -0
  168. package/docs/recipes/06-clock-events.md +117 -0
  169. package/docs/recipes/07-flow-scenes-pause.md +132 -0
  170. package/docs/recipes/08-weather-sky.md +74 -0
  171. package/docs/recipes/09-style-pack.md +234 -0
  172. package/docs/recipes/10-blender-level.md +67 -0
  173. package/docs/recipes/11-vehicles.md +55 -0
  174. package/docs/recipes/12-navmesh.md +79 -0
  175. package/docs/recipes/13-animation.md +149 -0
  176. package/docs/recipes/14-custom-module.md +91 -0
  177. package/docs/recipes/15-perf.md +78 -0
  178. package/docs/recipes/16-dev-bridge.md +180 -0
  179. package/docs/recipes/18-world.md +185 -0
  180. package/docs/recipes/19-shooting-picking.md +76 -0
  181. package/docs/recipes/20-content-actions-save.md +176 -0
  182. package/docs/recipes/21-camera.md +153 -0
  183. package/docs/recipes/22-shop-gold.md +107 -0
  184. package/docs/recipes/23-ops.md +175 -0
  185. package/docs/recipes/26-ui-parts.md +138 -0
  186. package/docs/recipes/27-net.md +96 -0
  187. package/docs/recipes/28-terrain.md +80 -0
  188. package/docs/recipes/29-grid.md +87 -0
  189. package/docs/recipes/30-templates.md +131 -0
  190. package/docs/recipes/31-audio.md +126 -0
  191. package/docs/recipes/32-action-game.md +33 -0
  192. package/docs/recipes/33-stream-sources.md +37 -0
  193. package/docs/recipes/34-environment-lighting.md +36 -0
  194. package/docs/recipes/35-style-from-reference.md +89 -0
  195. package/docs/recipes/36-sky-ground-plant-looks.md +116 -0
  196. package/docs/recipes/37-terrain-look-hooks.md +97 -0
  197. package/docs/recipes/38-environment-look-hooks.md +83 -0
  198. package/docs/recipes/40-scene.md +108 -0
  199. package/docs/recipes/41-thing-registry.md +93 -0
  200. package/docs/recipes/42-terrain-shape.md +64 -0
  201. package/docs/recipes/43-shader-patches-surface-looks.md +120 -0
  202. package/docs/recipes/44-water-weather-look-hooks.md +135 -0
  203. package/docs/recipes/45-cascaded-shadows.md +51 -0
  204. package/docs/recipes/46-blender-art-route.md +114 -0
  205. package/docs/recipes/47-island-snow-backdrop.md +44 -0
  206. package/docs/recipes/48-make-material.md +70 -0
  207. package/docs/recipes/49-game-module-contract.md +71 -0
  208. package/docs/recipes/50-own-renderer.md +12 -0
  209. package/docs/recipes/51-capability-catalog.md +63 -0
  210. package/docs/recipes/52-look.md +108 -0
  211. package/examples/action/DESIGN.md +3 -0
  212. package/examples/action/GAMEMAP.md +127 -0
  213. package/examples/action/content/actions.js +8 -0
  214. package/examples/action/content/audio.js +9 -0
  215. package/examples/action/content/index.js +10 -0
  216. package/examples/action/content/items.js +4 -0
  217. package/examples/action/content/places.js +4 -0
  218. package/examples/action/content/props.js +11 -0
  219. package/examples/action/content/templates.js +10 -0
  220. package/examples/action/content/views.js +6 -0
  221. package/examples/action/look.js +5 -0
  222. package/examples/action/main.js +137 -0
  223. package/examples/action/models.js +25 -0
  224. package/examples/sheepisland/GAMEMAP.md +107 -0
  225. package/examples/sheepisland/content/index.js +6 -0
  226. package/examples/sheepisland/content/props.js +19 -0
  227. package/examples/sheepisland/content/templates.js +5 -0
  228. package/examples/sheepisland/content/vegetation.js +8 -0
  229. package/examples/sheepisland/main.js +71 -0
  230. package/examples/sheepisland/params.js +25 -0
  231. package/examples/sheepisland/style/index.js +79 -0
  232. package/examples/sheepisland/style/models.js +59 -0
  233. package/examples/sheepisland/views.js +9 -0
  234. package/examples/styletest/GAMEMAP.md +135 -0
  235. package/examples/styletest/content/index.js +9 -0
  236. package/examples/styletest/content/items.js +8 -0
  237. package/examples/styletest/content/npcs.js +8 -0
  238. package/examples/styletest/content/places.js +5 -0
  239. package/examples/styletest/content/props.js +16 -0
  240. package/examples/styletest/content/templates.js +9 -0
  241. package/examples/styletest/content/vegetation.js +31 -0
  242. package/examples/styletest/look.js +11 -0
  243. package/examples/styletest/main.js +95 -0
  244. package/examples/styletest/models.js +87 -0
  245. package/examples/styletest/overrides.js +33 -0
  246. package/examples/styletest/panel.js +135 -0
  247. package/examples/styletest/params.js +32 -0
  248. package/examples/styletest/views.js +31 -0
  249. package/examples/world/DESIGN.md +5 -0
  250. package/examples/world/GAMEMAP.md +171 -0
  251. package/examples/world/content/actions.js +8 -0
  252. package/examples/world/content/audio.js +25 -0
  253. package/examples/world/content/bodies.js +12 -0
  254. package/examples/world/content/containers.js +4 -0
  255. package/examples/world/content/dialogues.js +33 -0
  256. package/examples/world/content/index.js +17 -0
  257. package/examples/world/content/items.js +10 -0
  258. package/examples/world/content/npcs.js +14 -0
  259. package/examples/world/content/pickups.js +11 -0
  260. package/examples/world/content/places.js +6 -0
  261. package/examples/world/content/props.js +12 -0
  262. package/examples/world/content/quests.js +15 -0
  263. package/examples/world/content/rules.js +23 -0
  264. package/examples/world/content/templates.js +5 -0
  265. package/examples/world/content/vegetation.js +32 -0
  266. package/examples/world/main.js +168 -0
  267. package/examples/world/models.js +28 -0
  268. package/index.d.ts +306 -0
  269. package/index.js +122 -0
  270. package/llms.txt +61 -0
  271. package/modules/ambience/Ambience.js +186 -0
  272. package/modules/camera/FirstPersonCamera.js +131 -0
  273. package/modules/camera/FixedCamera.js +162 -0
  274. package/modules/camera/FollowCamera.js +91 -0
  275. package/modules/camera/RtsCamera.js +132 -0
  276. package/modules/camera/common.js +182 -0
  277. package/modules/camera/index.js +11 -0
  278. package/modules/camera/projection.js +34 -0
  279. package/modules/characters/Character.js +235 -0
  280. package/modules/characters/NPC.js +242 -0
  281. package/modules/characters/assetModel.js +42 -0
  282. package/modules/characters/astar.js +66 -0
  283. package/modules/characters/behaviors.js +72 -0
  284. package/modules/characters/footsteps.js +13 -0
  285. package/modules/characters/index.js +215 -0
  286. package/modules/characters/moveHelpers.js +29 -0
  287. package/modules/characters/movers/common.js +62 -0
  288. package/modules/characters/movers/rapier.js +74 -0
  289. package/modules/characters/movers/simple.js +43 -0
  290. package/modules/characters/npcAvoid.js +129 -0
  291. package/modules/characters/npcSim.js +150 -0
  292. package/modules/characters/npcView.js +42 -0
  293. package/modules/characters/pathAsync.js +113 -0
  294. package/modules/characters/pathJob.js +62 -0
  295. package/modules/characters/pathWorker.js +7 -0
  296. package/modules/characters/playerStrings.js +12 -0
  297. package/modules/characters/proceduralRig.js +58 -0
  298. package/modules/characters/useModel.js +22 -0
  299. package/modules/characters/walkTo.js +58 -0
  300. package/modules/collision/Collision.js +274 -0
  301. package/modules/collision/grid.js +63 -0
  302. package/modules/content/explain.js +13 -0
  303. package/modules/content/ids.js +95 -0
  304. package/modules/content/index.js +154 -0
  305. package/modules/content/loader.js +190 -0
  306. package/modules/content/models.js +69 -0
  307. package/modules/content/packs.js +69 -0
  308. package/modules/content/props.js +89 -0
  309. package/modules/content/rules.js +134 -0
  310. package/modules/content/templates.js +189 -0
  311. package/modules/debug/DebugPanel.js +174 -0
  312. package/modules/entities/Entities.js +243 -0
  313. package/modules/entities/build.js +25 -0
  314. package/modules/entities/index.js +4 -0
  315. package/modules/flow/index.js +101 -0
  316. package/modules/gameplay/Container.js +227 -0
  317. package/modules/gameplay/Containers.js +89 -0
  318. package/modules/gameplay/Dialogue.js +219 -0
  319. package/modules/gameplay/Interactions.js +253 -0
  320. package/modules/gameplay/Inventory.js +224 -0
  321. package/modules/gameplay/Quests.js +205 -0
  322. package/modules/gameplay/boxOps.js +60 -0
  323. package/modules/gameplay/dialogueBox.js +48 -0
  324. package/modules/gameplay/interactionPrompt.js +28 -0
  325. package/modules/gameplay/inventoryOps.js +137 -0
  326. package/modules/gameplay/pickups.js +115 -0
  327. package/modules/gameplay/questLog.js +54 -0
  328. package/modules/gameplay/questSave.js +71 -0
  329. package/modules/grid/Grid.js +184 -0
  330. package/modules/grid/Layer.js +142 -0
  331. package/modules/grid/index.js +236 -0
  332. package/modules/grid/ops.js +73 -0
  333. package/modules/grid/preview.js +85 -0
  334. package/modules/grid/tiles.js +79 -0
  335. package/modules/hlod/index.js +167 -0
  336. package/modules/hud/index.js +167 -0
  337. package/modules/hud/parts.js +80 -0
  338. package/modules/level/geometry.js +46 -0
  339. package/modules/level/heightfield.js +160 -0
  340. package/modules/level/index.js +233 -0
  341. package/modules/level/nodes.js +84 -0
  342. package/modules/lights/index.js +227 -0
  343. package/modules/music/Music.js +294 -0
  344. package/modules/music/index.js +2 -0
  345. package/modules/music/rules.js +28 -0
  346. package/modules/nav/index.js +156 -0
  347. package/modules/nav/navPath.js +17 -0
  348. package/modules/net/Client.js +137 -0
  349. package/modules/net/Host.js +117 -0
  350. package/modules/net/Net.js +49 -0
  351. package/modules/net/index.js +77 -0
  352. package/modules/net/sync.js +114 -0
  353. package/modules/net/transports.js +118 -0
  354. package/modules/particles/Particles.js +179 -0
  355. package/modules/particles/effect.js +112 -0
  356. package/modules/particles/shaders.js +28 -0
  357. package/modules/photo/Photo.js +146 -0
  358. package/modules/rigid/RigidBodies.js +265 -0
  359. package/modules/rigid/Vehicles.js +97 -0
  360. package/modules/rigid/sync.js +158 -0
  361. package/modules/settings/Settings.js +297 -0
  362. package/modules/settings/apply.js +21 -0
  363. package/modules/settings/index.js +3 -0
  364. package/modules/settings/sections.js +156 -0
  365. package/modules/settings/strings.js +53 -0
  366. package/modules/settings/view.js +65 -0
  367. package/modules/sky/Sky.js +259 -0
  368. package/modules/sky/calendar.js +80 -0
  369. package/modules/sky/cascades.js +125 -0
  370. package/modules/sky/clouds.js +79 -0
  371. package/modules/sky/domeLayers.js +33 -0
  372. package/modules/sky/environment.js +141 -0
  373. package/modules/sky/fog.js +139 -0
  374. package/modules/sky/frame.js +77 -0
  375. package/modules/sky/layers.js +69 -0
  376. package/modules/sky/look.js +51 -0
  377. package/modules/sky/lookFog.js +80 -0
  378. package/modules/sky/lookShadow.js +50 -0
  379. package/modules/sky/lookSky.js +108 -0
  380. package/modules/sky/schedule.js +80 -0
  381. package/modules/sky/shader.js +96 -0
  382. package/modules/sky/shadow.js +74 -0
  383. package/modules/sky/skyModule.js +60 -0
  384. package/modules/terrain/ChunkManager.js +260 -0
  385. package/modules/terrain/chunkJob.js +19 -0
  386. package/modules/terrain/chunkLevels.js +40 -0
  387. package/modules/terrain/chunkQueries.js +42 -0
  388. package/modules/terrain/chunkWorker.js +5 -0
  389. package/modules/terrain/index.js +118 -0
  390. package/modules/terrain/lookGround.js +61 -0
  391. package/modules/terrain/mountTerrain.js +32 -0
  392. package/modules/terrain/terrainColorMap.js +41 -0
  393. package/modules/terrain/terrainDefaults.js +39 -0
  394. package/modules/terrain/terrainEdit.js +139 -0
  395. package/modules/terrain/terrainGen.js +155 -0
  396. package/modules/terrain/terrainIsland.js +131 -0
  397. package/modules/terrain/terrainMesh.js +92 -0
  398. package/modules/terrain/terrainShape.js +108 -0
  399. package/modules/terrain/terrainShapeMain.js +41 -0
  400. package/modules/terrain/terrainTexture.js +44 -0
  401. package/modules/timeline/Timeline.js +253 -0
  402. package/modules/timeline/Tween.js +114 -0
  403. package/modules/timeline/letterbox.js +24 -0
  404. package/modules/timeline/shots.js +90 -0
  405. package/modules/triggers/index.js +268 -0
  406. package/modules/vegetation/Vegetation.js +256 -0
  407. package/modules/vegetation/groundChunks.js +177 -0
  408. package/modules/vegetation/index.js +43 -0
  409. package/modules/vegetation/lookWind.js +37 -0
  410. package/modules/vegetation/modelGeometry.js +21 -0
  411. package/modules/water/Water.js +160 -0
  412. package/modules/water/look.js +80 -0
  413. package/modules/water/surface.js +88 -0
  414. package/modules/weather/Weather.js +242 -0
  415. package/modules/weather/look.js +75 -0
  416. package/modules/weather/particles.js +92 -0
  417. package/modules/weather/shaders.js +49 -0
  418. package/modules/weather/strings.js +15 -0
  419. package/modules/world/World.js +231 -0
  420. package/modules/world/cells.js +42 -0
  421. package/modules/world/explain.js +11 -0
  422. package/modules/world/index.js +71 -0
  423. package/modules/world/persist.js +107 -0
  424. package/modules/world/pos.js +20 -0
  425. package/modules/world/records.js +89 -0
  426. package/modules/world/sim.js +175 -0
  427. package/modules/world/simFar.js +82 -0
  428. package/modules/world/state.js +115 -0
  429. package/modules/world/thingSource.js +44 -0
  430. package/modules/world/views.js +182 -0
  431. package/package.json +66 -4
  432. package/presets.js +96 -0
  433. package/render/PostFX.js +240 -0
  434. package/render/detail.js +105 -0
  435. package/render/effects.js +144 -0
  436. package/render/engineUniforms.js +23 -0
  437. package/render/fuse.js +84 -0
  438. package/render/lighting.js +100 -0
  439. package/render/lights.js +18 -0
  440. package/render/lookSurface.js +161 -0
  441. package/render/materials.js +220 -0
  442. package/render/patches.js +252 -0
  443. package/render/postLook.js +86 -0
  444. package/render/surface.js +69 -0
  445. package/render/uniformDecl.js +29 -0
  446. package/types/common.d.ts +34 -0
  447. package/types/core.d.ts +1965 -0
  448. package/types/gameplay.d.ts +1822 -0
  449. package/types/generated/core/Audio.d.ts +200 -0
  450. package/types/generated/core/Batching.d.ts +47 -0
  451. package/types/generated/core/Budget.d.ts +90 -0
  452. package/types/generated/core/Commits.d.ts +31 -0
  453. package/types/generated/core/DebugOverrides.d.ts +52 -0
  454. package/types/generated/core/Events.d.ts +89 -0
  455. package/types/generated/core/I18n.d.ts +30 -0
  456. package/types/generated/core/Input.d.ts +118 -0
  457. package/types/generated/core/Jobs.d.ts +41 -0
  458. package/types/generated/core/Ops.d.ts +203 -0
  459. package/types/generated/core/Random.d.ts +49 -0
  460. package/types/generated/core/Rays.d.ts +49 -0
  461. package/types/generated/core/Saves.d.ts +162 -0
  462. package/types/generated/core/Stream.d.ts +93 -0
  463. package/types/generated/core/Threads.d.ts +82 -0
  464. package/types/generated/core/Views.d.ts +33 -0
  465. package/types/generated/core/audioVoice.d.ts +47 -0
  466. package/types/generated/core/page.d.ts +18 -0
  467. package/types/generated/core/session.d.ts +48 -0
  468. package/types/generated/modules/ambience/Ambience.d.ts +48 -0
  469. package/types/generated/modules/debug/DebugPanel.d.ts +24 -0
  470. package/types/generated/modules/flow/index.d.ts +10 -0
  471. package/types/generated/modules/grid/Grid.d.ts +151 -0
  472. package/types/generated/modules/grid/Layer.d.ts +65 -0
  473. package/types/generated/modules/grid/index.d.ts +86 -0
  474. package/types/generated/modules/hlod/index.d.ts +11 -0
  475. package/types/generated/modules/hud/index.d.ts +10 -0
  476. package/types/generated/modules/lights/index.d.ts +13 -0
  477. package/types/generated/modules/music/Music.d.ts +111 -0
  478. package/types/generated/modules/net/Net.d.ts +34 -0
  479. package/types/generated/modules/net/index.d.ts +53 -0
  480. package/types/generated/modules/net/transports.d.ts +58 -0
  481. package/types/generated/modules/particles/Particles.d.ts +69 -0
  482. package/types/generated/modules/sky/Sky.d.ts +145 -0
  483. package/types/generated/modules/sky/skyModule.d.ts +10 -0
  484. package/types/generated/modules/timeline/Timeline.d.ts +51 -0
  485. package/types/generated/modules/water/Water.d.ts +29 -0
  486. package/types/generated/modules/weather/Weather.d.ts +62 -0
  487. package/types/generated/modules/world/World.d.ts +242 -0
  488. package/types/generated/modules/world/index.d.ts +15 -0
  489. package/types/generated/render/PostFX.d.ts +125 -0
  490. package/types/generated/render/materials.d.ts +100 -0
  491. package/types/generated/render/patches.d.ts +41 -0
  492. package/types/generated/ui/Focus.d.ts +11 -0
  493. package/types/generated/ui/LoadingScreen.d.ts +2 -0
  494. package/types/generated/ui/UI.d.ts +57 -0
  495. package/types/nav.d.ts +52 -0
  496. package/types/physics.d.ts +592 -0
  497. package/types/style.d.ts +638 -0
  498. package/types/worker.d.ts +11 -0
  499. package/types/world.d.ts +772 -0
  500. package/ui/Focus.js +51 -0
  501. package/ui/LoadingScreen.js +42 -0
  502. package/ui/Parts.js +199 -0
  503. package/ui/UI.js +167 -0
  504. package/ui/defaults.js +85 -0
  505. package/ui/theme.js +124 -0
  506. package/ui/touchPart.js +49 -0
@@ -0,0 +1,58 @@
1
+ # engine.sky — sky(opts?: SkyOptions)
2
+
3
+ Sky, day/night, calendar (sky() module)
4
+
5
+ - Options `SkyOptions` (also includes the fields of Omit<StyleSky, 'fog'>):
6
+ - `fog?: boolean | 'manual' | StyleFog` Who owns scene.fog: true (default; the sky creates it and writes color and distance every frame) / 'manual' (created once, then never written: the game sets its color / near / far or its own object) / false (scene.fog = null, never touched). An object is style.sky.fog settings (kind, color, density...) and means true. A sky() option, not a style key. Example: `sky({ fog: 'manual' }) // the game manages scene.fog itself`
7
+ - `time?: number` Time of day at start: fraction of a day 0–1 (0.5 noon), default 0.33 (afterwards read / write engine.sky.timeOfDay)
8
+ - `dayLength?: number` Game seconds per day, default Infinity: the time of day never moves until the game sets a length (presets.calendar.cycle has 360) (one sky hour = dayLength / hoursPerDay game seconds; with timeScale 1 game seconds are fixed-step seconds); Infinity = the time of day never moves
9
+ - `hoursPerDay?: number` Hours per day of the displayed clock and of clock notation ('18:30'), default 24. Gameplay timing, so a sky() option and not a style key
10
+ - `day?: number` Which day to start from, default 1
11
+ - `daysPerSeason?: number` Days of each season given by name only, default 7
12
+ - `seasons?: (string | { name: string, days: number })[]` The calendar's seasons, default none ([]): names (each daysPerSeason days) or { name, days } for seasons of their own length, e.g. ['spring', 'summer', 'autumn', 'winter']
13
+ - `sun?: boolean | 'manual'` Whether the sky drives engine.lights.sun: true (default; color, intensity, direction and shadow box from the keyframes) / 'manual' (still aimed along the time of day with the shadow box; color and intensity are the game's) / false (hidden, never touched: light the world with your own three.js lights). Example: `sky({ sun: false, hemisphere: false }) // a dungeon lit by the game's own lights`
14
+ - `hemisphere?: boolean | 'manual'` Same for engine.lights.hemi (ambient): true (default) / 'manual' (colors and intensity are the game's) / false (hidden)
15
+
16
+ ## Methods and properties
17
+ - `sky.modify(owner: string, values: SkyLayer | null)` — Write a modifier layer (only the given fields; unwritten fields have no effect); values null removes the layer. Weather uses the 'weather' layer, games use their own layer name. Layers composite every frame: sun / ambient / fog multiply; tint blends weighted by tintAmount; flash takes the max. Example: `engine.sky.modify('cave', { sun: 0.3, ambient: 0.4 }); engine.sky.modify('cave', null);`
18
+ - `sky.at(clock: string | number, fn: (day: number) => void, opts?: SkyAtOptions) → Handle` — Call fn every day at a clock time: at('18:00', fn) or at(0.75, fn). Fires only when time moves forward across the clock time: natural flow, step fast-forward and setting timeOfDay later all count; crossing several triggers at once is replayed per catchUp; rewinding time and loading a save do not fire, they only reset the baseline. To hold a state during a time range (lights, shop door) use between
19
+ - `sky.between(from: string | number, to: string | number, opts: SkyBetweenOptions) → Handle` — Time-range switch: on() while clock time is in [from, to), otherwise off() (from > to wraps midnight). Aligns once immediately on registration, new game, load, applying a scenario and time rewind; afterwards it calls on/off when crossing a boundary. Example: `engine.sky.between('18:00', '06:00', { on: () => lamp.on(), off: () => lamp.off() })`
20
+ - `sky.daily(fn: (day: number) => void, opts?: SkyAtOptions) → Handle` — Call fn(day) at the start of each day (00:00)
21
+ - `sky.onSeason(name: string, fn: (season: string) => void) → Handle` — Call fn(seasonName) on entering season name
22
+ - `sky.setShadow(_opts?: Partial<SkyShadowParams>) → never` — Renamed in 0.2: throws and names the new call, engine.look.shadow.set(opts) (fields: bias, normalBias, updateEvery, snap, ahead, type, radius, blurSamples, cascades; recipes/45)
23
+ - `sky.setShadowMapSize(n: number)` — Change shadow resolution (raise temporarily for photo mode)
24
+ - `sky.setEnvironment(_opts?: { source?, intensity?, rotation?, interval? } | null) → never` — Renamed in 0.2: throws and names the new call, engine.look.env.replace(source) then engine.look.env.set({ intensity, rotation, interval })
25
+ - Properties:
26
+ - `timeOfDay: number` Sky time of day: 0-1 (0 midnight, 0.25 6am, 0.5 noon, 0.75 6pm); one day = dayLength game seconds (the unit of engine.clock.now). Fixed-step seconds (unaffected by timeScale) are engine.elapsed
27
+ - `dayLength: number` Game seconds per day (1 sky hour = dayLength / 24 game seconds; at timeScale 1 game seconds equal fixed-step seconds); Infinity = the time of day never moves
28
+ - `day: number` Day number (1-based)
29
+ - `daysPerSeason: number` Days per season for seasons given by name only
30
+ - `seasons: string[]` Season names, [] when the game has no seasons (the default)
31
+ - `dome: THREE.Object3D` Dome mesh
32
+ - `hemi: any` Hemisphere ambient light (engine.lights.hemi, driven by the sky)
33
+ - `sun: any` Sun directional light (engine.lights.sun driven by the sky; moonlight at night, shadows live on it)
34
+ - `sunDir: THREE.Vector3` Sun direction (unit vector toward the sun)
35
+ - `orbit: { tilt: number; sway: number; distance: number }` Sun orbit: tilt = north-south tilt, sway = east-west swing, distance = light distance (meters)
36
+ - `shadow: SkyShadowParams` Current shadow params (change via look.shadow.set)
37
+ - `csm: any` three's CSM (addons/csm) while shadow.cascades > 1, else null; its lights[0] is sun (recipes/45)
38
+ - `hoursPerDay: number` Hours per day
39
+ - `modifiers: SkyModifiers` Composite of all modifier layers (read-only; use modify to adjust brightness)
40
+ - `shadowMapSize: number` Shadow resolution (pixels)
41
+ - `clock: string` Clock text, e.g. "18:00"
42
+ - `sunHeight: number` Sun elevation -1 (midnight) ... 0 (horizon) ... 1 (noon). Day/night is computed only here; other modules read isDay / daylight
43
+ - `isDay: boolean` Whether it is daytime (sun above the horizon)
44
+ - `daylight: number` Daylight amount 0-1 (0 at night, 1 at noon); ambience etc. fade by it
45
+ - `seasonIndex: number` Current season index, -1 without seasons
46
+ - `season: string | null` Current season name, e.g. 'spring'; null without seasons
47
+ - `dayOfSeason: number` Day within the season (1-based); 0 without seasons
48
+ - `seasonProgress: number` Fraction of the season elapsed, 0-1 (includes time of day); 0 without seasons
49
+ - `totalDays: number` Total game time in days (fractional), for growth, cooldowns and the like
50
+ - `environment: SkyEnvironmentInfo | null` Environment lighting now: { source, intensity, rotation, interval, builds }, null when off
51
+
52
+ ## Data structures
53
+ - **SkyAtOptions** Parameters of sky.at() / daily()
54
+ - `days?: number[] | ((day: number) => boolean)` Only fire on these days: a list of days, or (day) => whether to fire
55
+ - `catchUp?: 'all' | 'once' | 'skip'` When one advance crosses several trigger points: 'all' fire them all / 'once' fire once (default) / 'skip' do not make up
56
+ - **SkyBetweenOptions** Callback of sky.between: on is called when entering the period, off when leaving it
57
+ - `on?: () => void` Entering the period (or found inside it when aligned)
58
+ - `off?: () => void` Leaving the period (or found outside it when aligned)
@@ -0,0 +1,31 @@
1
+ # engine.stream (Stream) — engine.stream builds on demand by space: only entries near the focus get built
2
+
3
+ - `stream.add(def: StreamEntryOptions) → StreamHandle` — Register something to stream in (not built at once); an object returned by build with no parent is added to the scene automatically. Example: `engine.stream.add({ position: [40, 0, 12], radius: 6, build: () => makeHouse() });`
4
+ - `stream.setRadius(m: number)` — Set the build radius in meters
5
+ - `stream.source(position: any, opts?: StreamSourceOptions) → StreamSource` — (experimental) Add a stream source: the world around position is loaded (terrain chunks, colliders, nearby models, stream entries) until remove() or until. position may be live (an Object3D or Vector3 that moves) or a function. detail 'simple' loads only terrain and hlod proxies (a far view); physics defaults to true for 'full'; pass false for a camera that only needs a picture. radius caps every loader's range (default: each loader's own range). until: a Promise (removed when it settles) or a function checked every frame (removed when it returns true). Example: `const dest = engine.stream.source([800, 0, 300], { radius: 64 }); await dest.whenReady; engine.player.placeAt([800, 0, 300]); dest.remove();`
6
+ - `stream.teleport(position: any, opts?: { radius?, move?, timeout? }) → Promise<void>` — (experimental) Load the destination first, then move: resolves after the player (engine.focus without one) is placed. Until the destination is ready (terrain chunks, collision, nearby models) the player stays where it is. move replaces the default placement (for a vehicle or a custom character). timeout (seconds of frame time, default 60; Infinity waits forever): when the destination is still not ready, the Promise rejects (code stream-timeout, naming the loaders still waiting) and the player is not moved. Example: `await engine.stream.teleport([800, 0, 300]);`
7
+ - `stream.readyCheck(name: string, fn: (source: StreamSource) => boolean) → { remove(): void }` — (experimental) Register a readiness check for loaders: fn(source) returns whether this loader finished what that source asks for. For module authors whose loader reads stream sources; games only read source.ready. Example: `engine.stream.readyCheck('props', s => s.detail !== 'full' // props.queued === 0)`
8
+ - `stream.sources(pick?: { detail?, physics? }) → StreamSource[]` — (experimental) Sources with fresh positions, filtered: { detail: 'full' } for models and stream entries, { physics: true } for colliders, no filter for terrain
9
+ - Properties:
10
+ - `radius: number | null` Build radius in meters around each full-detail stream source (a source radius caps it); null = follow the terrain view distance (the fog distance engine.fogFar without terrain)
11
+ - `cellSize: number` Grid cell edge in meters, shared with hlod, default 64
12
+ - `unloadFactor: number` Unload only beyond radius x this (walking back and forth does not rebuild), default 1.25
13
+ - `player: StreamSource` Built-in source at the gameplay anchor (world.anchor, else the player, else engine.focus): full detail and physics
14
+ - `camera: StreamSource` Built-in source at the camera focus engine.focus: full detail, no physics
15
+ - `activeRadius: number` The build radius actually in use, in meters
16
+ - `ready: boolean` Everything registered within radius is built (start() waits for it before the loading screen goes away)
17
+ - `stats: { entries: number; built: number; queued: number }` entries is the registered count, built the built count, queued the queued count
18
+
19
+ ## Data structures
20
+ - **StreamEntryOptions** Parameters of engine.stream.add(): position is the location, radius the size (meters), build generates (may be async), dispose unloads
21
+ - `position: PositionLike` Position (Vector3 / object / [x, y, z] / { x, z }; only the horizontal coordinates count)
22
+ - `radius?: number` Object size (meters); larger ones are built earlier
23
+ - `build: () => Object3D | Promise<Object3D>` Generate the object (called when entering range, run spread over frames through engine.jobs)
24
+ - `dispose?: (obj: Object3D) => void` Unload (called when leaving range), default engine.remove (full removal); write your own when the object is reused (e.g. engine.detach)
25
+ - `keep?: boolean` Do not unload even when out of range
26
+ - `priority?: number` Build order: larger first (nearer first within the same priority), default 0
27
+ - **StreamHandle** Handle returned by stream.add(): object is the generated object (null while not generated)
28
+ - `def: StreamEntryOptions`
29
+ - `object: Object3D | null`
30
+ - `built: boolean`
31
+ - `remove()`
@@ -0,0 +1,134 @@
1
+ # Style pack Style — createEngine({ style }), all the look (example: @threedog/style-lowpoly, packages/styles/lowpoly/index.js)
2
+
3
+ - **Style** fields (all optional):
4
+ - `name?: string` Style pack name
5
+ - `exposure?: number | number[][] | ((sky: any) => number)` Exposure, default 1 (lowpoly: 1.05): a number, or over the day [[time 0-1, exposure], ...] (sorted, wraps across midnight) or (sky) => number, evaluated by the sky module every frame. engine.look.tone.set changes it at run time. Example: `exposure: [[0, 1.6], [0.3, 1], [0.75, 1.1]] // brighter nights`
6
+ - `toneMapping?: Loose<'aces' | 'agx' | 'neutral' | 'none'>` Tone mapping. Engine default 'none' (no style pack, no tone mapping); the style pack picks the look (lowpoly: 'aces')
7
+ - `background?: ColorLike` Background color (when there is no sky module)
8
+ - `post?: (Omit<import('./generate… & { slot? })[]` Post effects registered at startup, in any order (slot and order decide where each runs), e.g. [outline({ enabled: true }), bloom()] from '@threedog/post-effects'
9
+ - `materials?: Record<string, MaterialSpec | import('three').Material | ((…` Material per role (default, terrain, vegetation, character, water, building, pickup…): a spec, a three.js Material instance (cloned per use), or a function (params, purpose) => Material
10
+ - `antialias?: boolean` Anti-aliasing: true = MSAA (also inside post-processing), false = off (pixel art, sharp edges). Default: on for desktop, off for low tier; createEngine({ antialias }) wins
11
+ - `lighting?: MaterialLighting` Light shaping for every lit material of the pack (shadow tint, rim, wrap, glsl); a material's `lighting` wins, `lighting: false` opts out
12
+ - `seasons?: StyleSeasons` Seasonal tint: { spring: { foliage, ground }, ... }. mode 'multiply' (default) multiplies the color onto the surface (pick tints near white: orange times green is muddy); 'mix' moves the surface `strength` (0-1, default 0.5) of the way to the color. Season names are the other keys, so none can be called mode or strength
13
+ - `clouds?: { shadow?: number; scale?: number; speed?: number[] }` Cloud shadow: shadow darkest level 0–1 (default 0 = no cloud shadows; lowpoly 0.55), scale cloud size (smaller means bigger clouds), speed [x, z]
14
+ - `palette?: Record<string, ColorLike>` Named colors the procedural model generators read (trees, rocks, grass: a generator written with `function` gets them as this.palette; lowpoly keys: bark, pine, leaf, rock, grassTip...). One place to retint all of them, e.g. style: [lowpoly, { palette: { leaf: 0xd98a3a } }]; keys left out keep the pack's values
15
+ - `wind?: StyleWind` Wind: frequency sway frequency multiplier
16
+ - `terrain?: StyleTerrain` Terrain colors etc.
17
+ - `sky?: StyleSky` Sky
18
+ - `weather?: StyleWeather` Weather look
19
+ - `water?: StyleWater` Water look
20
+ - `pickup?: { color?, size?, lift?, model? }` Default look of pickups on the ground: color (the item's own color wins), size (meters), lift height above ground (meters), model(item, { color, size }, engine) builds the shape (a geometry gets materials.pickup; make materials with engine.makeMaterial; without model a plain box)
21
+ - `character?: { model?, colors?, create?, animation? }` Default character: colors palette; create(engine, colors) returns the procedural character (without it a gray capsule); model names a registered model asset every character uses unless it passes its own model (the procedural body shows until it loads); animation.fade skeletal animation transition seconds
22
+ - `ui?: StyleUI` UI colors, fonts, templates
23
+ - `particles?: Record<string, ParticleOptions>` Particle presets: name → parameters; default is the fallback for all effects
24
+ - `triggers?: { debugColor?: ColorLike; debugOpacity?: number }` Trigger zone debug wireframe
25
+ - `grid?: { ok?, bad?, previewOpacity?, previewHeight?, tileLift?, tiles? }` Grid placement (grids() module): preview ok / bad colors and opacity, tile lift (m), and per-layer tile colors { layer: { field: color } } (first truthy field of a cell's data wins)
26
+
27
+ ## Sub-structures
28
+ - **StyleSky**
29
+ - `keyframes?: SkyKeyframe[]` Colors and light intensities at each time of day
30
+ - `backdrop?: ColorLike | ((sky: Sky) => ColorLike)` A flat background color in place of the dome (no gradient, horizon line, sun / moon disk, stars or clouds), or (sky) => color per frame. Drawn as written (no tone mapping); the keyframes still light the world; fog in its default horizon color follows it (a fog.color of your own still wins). Leave out for the dome. Not with skybox. recipes/47. Example: `backdrop: sky => sky.isDay ? 0xefebe4 : 0x2c3346`
31
+ - `sunSize?: number` Larger means a smaller sun, default 900
32
+ - `sunGlow?: number` Sun glow, default 0.18
33
+ - `sunBrightness?: number` Sun brightness, default 6
34
+ - `moonSize?: number` Larger means a smaller moon
35
+ - `moonColor?: ColorLike`
36
+ - `moonBrightness?: number`
37
+ - `orbitTilt?: number` North-south tilt of the sun path
38
+ - `orbitSway?: number` East-west swing of the sun path
39
+ - `starDensity?: number` Star density
40
+ - `starScale?: number` Larger means smaller and more numerous stars
41
+ - `gradientCurve?: number` Gradient curve from zenith to horizon
42
+ - `groundTint?: ColorLike` Ground bounce color of the ambient light
43
+ - `clouds?: StyleSkyClouds` Clouds in the sky (cloud cover follows the weather); see StyleSkyClouds
44
+ - `skybox?: string` Panorama (equirectangular) replacing the gradient sky, asset name or path
45
+ - `shadow?: StyleShadow` Shadows: mapSize resolution (pixels), extent coverage (meters), etc., see StyleShadow
46
+ - `environment?: StyleEnvironment` Environment lighting (scene.environment), off unless a source is given; see engine.look.env. A pack can give defaults, sky({ environment }) overrides
47
+ - `fog?: StyleFog` Fog model and color (default: linear fog in the horizon color); see StyleFog
48
+ - `layers?: StyleSkyLayer[]` Extra dome layers drawn after the clouds and stars (rainbow, aurora), default none; see StyleSkyLayer
49
+ - **StyleShadow**
50
+ - `mapSize?: number` Shadow resolution (pixels), default 2048
51
+ - `extent?: number` Coverage radius (meters), default 70
52
+ - `distance?: number` Distance of the light from the shadow center (meters), default 160
53
+ - `bias?: number` Anti shadow-acne bias, default -0.0006
54
+ - `normalBias?: number` Normal-offset anti-acne, default 0.04
55
+ - `updateEvery?: number` Update shadows every N frames, default 1 (every frame); larger saves more, still updates promptly when the focus moves
56
+ - `snap?: number | 'texel'` Shadow center snapping grid (meters), default 0.5; 'texel' snaps to shadow pixels (shadow edges do not shimmer while moving)
57
+ - `ahead?: number` How far ahead of the view direction the shadow center is shifted (meters), default 0
58
+ - `type?: Loose<'basic' | 'pcf' | 'vsm'>` Shadow filter: 'basic' (hard edge, cheapest) / 'pcf' (default, soft edge) / 'vsm' (softest, costliest). Default: the engine's shadowType option
59
+ - `radius?: number` Edge softness for 'pcf' and 'vsm' (no effect on 'basic'), default 1
60
+ - `blurSamples?: number` Blur sample count, 'vsm' only, default 8
61
+ - `cascades?: number` Cascaded shadows (recipes/45): 1 (default) = one shadow map around the focus, the plain path; 2-4 split the sun's shadow along the view, sharp near the camera and wide far away. Each cascade draws the casters once more. Low-tier devices stay at 1 unless low.cascades says so. Example: `shadow: { cascades: 3, maxFar: 150, low: { cascades: 2, fade: false } } // low-tier devices: 2 cascades instead of one map`
62
+ - `maxFar?: number` Cascades: meters from the camera they cover (no sun shadow beyond), default 120
63
+ - `fade?: boolean` Cascades: cross-fade at each border so no seam shows (two shadow lookups there), default true
64
+ - `lightMargin?: number` Cascades: meters behind each cascade box toward the light still caught as casters (tall things outside the view), default 100
65
+ - `split?: Loose<'practical' | 'un… | ((count, near, far, out) => void)` Cascades: where borders fall, 'practical' (default) / 'uniform' / 'logarithmic' / (count, near, far, out: number[]) => void (three CSM customSplitsCallback)
66
+ - `low?: Omit<StyleShadow, 'low'>` Overrides used on low-tier devices (engine.tier 'low'), default { mapSize: 1024, cascades: 1 }. updateEvery above 1 saves more but makes wind-swayed shadows step visibly. sky({ shadow }) options replace the whole shadow block, low included.
67
+ - **StyleWeather**
68
+ - `area?: number` Rain / snow coverage (meters, centered on the camera)
69
+ - `overcastColor?: ColorLike` Target color the sky turns to when overcast
70
+ - `lightningBrightness?: number` Lightning brightness multiplier
71
+ - `lightning?: (flash: number, engine: Engine) => number` Lightning look: flash (1 at the strike, fading in a third of a second) -> sky flash amount; default flickers. Return 0 and draw your own bolt on the weather:lightning event for a whole replacement. Example: `lightning: f => f * f * 0.8`
72
+ - `rain?: StyleWeatherParticles` Rain particles (default streaks: color 0xc8c8c8, opacity 0.55, length 0.7 m, speed 22 m/s, slant 1); a texture or a sprite shape draws drops
73
+ - `snow?: StyleWeatherSnow` Snow particles (default round sprites: color 0xffffff, opacity 0.9, size 20, maxSize 5 px, speed 1.6 m/s, sway 1.5 m)
74
+ - `types?: Record<string, Partial<WeatherPreset>>` Retune the look of weather types the game has (e.g. a darker storm); never adds a type: the list is the game's weather({ types })
75
+ - **StyleWater**
76
+ - `material?: (engine, ctx) => Material` Replace the whole water surface material (the built-in role 'water', waves and fresnel are skipped). Receives the shared uniforms (uTime, uWave, uWaveScale, uWaveSpeed), the built-in wave patch, the surface patch (depthColor / foam / glsl.surface; null without them; put it after waves) and the scrolling normal map (null without one). Example: `material: (engine, { waves }) => applyEffects(new THREE.MeshToonMaterial({ color: 0x3a8acf }), { clouds: false, patches: [waves] })`
77
+ - `depthColor?: StyleWaterDepth` Water color from the view angle (by 'view', default: shallow looking down, deep at grazing angles) or the wave height (by 'wave': shallow on crests); replaces color. curve shapes the blend (default 1)
78
+ - `foam?: StyleWaterFoam | true` Crest foam from the wave height (start / end: fraction of glsl.waveMax where foam begins / is full, default 0.55 / 0.85); true = defaults. Shore foam needs depth: recipes/44
79
+ - `glsl?: { wave?: string; surface?: string; waveMax?: number }` Your own GLSL. wave: `float threedogWaterWave(vec3 p, float t)` (p = world position * waveScale, t = time * waveSpeed) returns the height before waveHeight; waveMax = its peak (default 0.29), which foam and depthColor 'wave' divide by.
80
+ - `uniforms?: Record<string, any>` Uniforms for your glsl, in both stages: numbers, colors, [x, y(, z, w)] arrays or textures; live in engine.water.material.uniforms
81
+ - `color?: ColorLike`
82
+ - `opacity?: number` Opacity 0–1
83
+ - `flat?: boolean` Flat shading (low poly)
84
+ - `waveHeight?: number` Wave height multiplier
85
+ - `waveScale?: number`
86
+ - `waveSpeed?: number`
87
+ - `fresnel?: number` Grazing-angle reflection strength 0–1
88
+ - `normalMap?: string` Normal map (asset name or path)
89
+ - `normalScale?: number`
90
+ - `normalRepeat?: number`
91
+ - `normalSpeed?: number[]` Normal map flow speed [x, z]
92
+ - `shininess?: number`
93
+ - `specular?: ColorLike`
94
+ - `segments?: number` Mesh subdivision of the global water (quality, not the world; default 150)
95
+ - **StyleTerrain**
96
+ - `colors?: Record<string, ColorLike>` Palette: color name → color (e.g. sand, meadowA, rock)
97
+ - `biomeColors?: Record<string, string[]>` Landform → palette color name (two names are blended by noise)
98
+ - `steep?: SteepRule[]` Color rule for steep slopes
99
+ - `variation?: { blend?, jitter?, patches? }` How ground colors vary (plain data, sent to the terrain workers). Every default is the original look; set only what you want to change. blend: the two-color noise (size = wavelength in meters, default 33; strength = contrast, default 1). Example: `variation: { blend: { size: 14 }, jitter: { range: 0.04 }, patches: { size: 60, strength: 0.25, levels: 4, tint: 0xb59a5a } }`
100
+ - `config?: { shading?, colorResolution?, normals?, normalFn? }` Looks of the ground mesh only. shading: 'flat' one color and normal per triangle (facets) / 'smooth' (engine default) / 'texture' (per-chunk color map, colors independent of the mesh); colorResolution: color map pixels per chunk edge; normals: 'smooth' / 'flat' lighting in texture mode; normalFn: custom grid-point normal.
101
+ - `material?: Material | ((engine: Engine) => Material)` Whole ground material: a Material or (engine) => Material (uv = world xz / chunk size; terrain({ material }) wins)
102
+ - `detail?: { texture: string; scale?: number; strength?: number }` Ground detail texture: texture asset name, scale repeats per meter, strength 0–1
103
+ - **StyleUI**
104
+ - `bg?: string` Background color
105
+ - `fg?: string` Text color
106
+ - `muted?: string` Secondary text color
107
+ - `accent?: string` Accent color
108
+ - `good?: string` Color for good news such as "done"
109
+ - `line?: string` Divider color
110
+ - `font?: string` Font (CSS font-family)
111
+ - `radius?: string` Corner radius (CSS, e.g. '12px')
112
+ - `loadingBg?: string` Loading screen background
113
+ - `shadow?: string` Window shadow (CSS)
114
+ - `promptHeight?: number` Height of the interaction prompt above the object (meters)
115
+ - `fadeBg?: string` Fade color for scene transitions (CSS), default '#000'
116
+ - `hudBg?: string` Background / text / accent colors of objective markers, counters and progress bars (CSS)
117
+ - `hudFg?: string`
118
+ - `hudAccent?: string`
119
+ - `fonts?: string[]` Font asset names the UI uses (engine.assets.manifest({ fonts })); loaded at start(), then written in font: '"pixel", system-ui'. A style never holds a font file path
120
+ - `css?: string` Extra CSS (overrides .threedog-* classes)
121
+ - `templates?: Record<string, UITemplate>` Replace the content of a window wholesale: inventory, quests, settings, loading, hudMarker, hudCounter, hudBar…
122
+ - **MaterialSpec** Material parameters for one role (other fields are set on the three.js material as is, e.g. roughness, shininess, specular)
123
+ - `type?: MaterialType` Material type, default 'lambert'
124
+ - `steps?: number` Number of light/dark steps for the toon type, default 3
125
+ - `ramp?: (number | ColorLike)[]` toon only: the light ramp, dark to light: grays 0-1 (light strength in the band) or colors (tint the band). Replaces steps
126
+ - `soften?: number` toon only, with ramp: 0 = hard bands, up to 1 = the bands melt into each other
127
+ - `color?: ColorLike`
128
+ - `map?: string | import('three').Texture` Texture slots take an asset name: map, emissiveMap (sRGB), normalMap, roughnessMap, metalnessMap, aoMap, bumpMap, alphaMap, displacementMap... (linear). Loaded through engine.assets.texture, a neutral stand-in until the image arrives; the key must be a slot the type has (roughnessMap needs 'standard'). A THREE.Texture also works.
129
+ - `normalMap?: string | import('three').Texture`
130
+ - `roughnessMap?: string | import('three').Texture`
131
+ - `repeat?: number | [number, number]` How many times the textures of this material repeat (a number, or [x, y]); default 1
132
+ - `wrap?: Loose<'repeat' | 'clamp' | 'mirror'>` Texture wrapping: 'repeat' (default) / 'clamp' / 'mirror'
133
+ - `detail?: MaterialDetail` Grain, paper, strokes or a texture laid over the surface in world space (no UVs needed); off unless given
134
+ - `lighting?: MaterialLighting | false` Extra light shaping (shadow tint, rim, wrap, your own GLSL); merged over style.lighting, false opts out
@@ -0,0 +1,34 @@
1
+ # engine.terrain — terrain(opts?: TerrainOptions)
2
+
3
+ Procedural terrain (terrain() module)
4
+
5
+ - Options `TerrainOptions` (also includes the fields of Partial<TerrainConfig>):
6
+ - `viewChunks?: number` View distance (in chunks), default 4
7
+ - `density?: number` Vegetation density multiplier, default 1
8
+ - `viewFog?: boolean` true: the fog distance (engine.fogFar) follows the view distance so the far chunk edge fades out; default false keeps the game's fog (openWorld() sets true)
9
+ - `material?: Material | ((engine: Engine) => Material)` Ground material (default style.terrain.material, else the 'terrain' role with vertex colors); chunks have uv = world xz / chunk size. Cloud shadows and season tint are added
10
+
11
+ ## Methods and properties
12
+ - `terrain.setViewChunks(n: number)` — Change the view distance (in chunks); fog and camera far plane adjust too
13
+ - `terrain.setDensity(d: number)` — Change the vegetation density (rebuilds all chunks)
14
+ - `terrain.rebuild()` — Rebuild all chunks
15
+ - `terrain.edit(position: PositionLike, opts: TerrainEditOptions) → { heights: number; cells: number }` — (experimental) Change the ground: dig, raise, flatten, paint the ground type. Saved gameplay state: call it from an op or a fixed step. engine.surface / slope / groundType, collision, paths and vegetation follow at once; it is saved, and chunks generated later come out edited. Example: `engine.terrain.edit(pos, { radius: 3, lower: 1.5 }); // dig a pit engine.terrain.edit(pos, { shape: 'square', radius: engine.terrain.cellSize / 2, paint: 'tilled' }); // till one cell`
16
+ - `terrain.isReadyAround(position: PositionLike, opts?: { rings?: number }) → boolean` — Whether the chunks within rings rings (default 1) around position are all loaded
17
+ - Properties:
18
+ - `T: TerrainGen` Pure-computation terrain (height, landform)
19
+ - `CHUNK: number` Chunk edge length (meters)
20
+ - `voidY: number` terrain({ shape }) only: below this height the player or a moving rigid body has fallen out of the world (one terrain:void per fall). shape.voidY, else 50 m under the lowest island chunk loaded so far; -Infinity without a shape. Example: `engine.events.on('terrain:void', ({ who }) => { if (who === engine.player) engine.player.placeAt(home); });`
21
+ - `chunks: Map<string, any>` Loaded chunks: 'cx,cz' → chunk
22
+ - `viewChunks: number` View distance (in chunks)
23
+ - `density: number` Vegetation density multiplier
24
+ - `applyBudgetMs: number` Time budget (milliseconds) for uploading chunks per frame
25
+ - `stats: { builtThisFrame, applyMs, queued, visible?, loaded?, instances? }` Statistics (for the debug panel)
26
+ - `cellSize: number` Grid spacing (meters) = chunkSize / resolution: edits snap to it, paint colors whole cells of this size
27
+
28
+ ## Data structures
29
+ - **FlattenZone** Flattened plot (for villages, houses): center x/z, radius (meters), height optionally fixes the height
30
+ - `x: number`
31
+ - `z: number`
32
+ - `radius: number`
33
+ - `height?: number`
34
+ - `clearRatio?: number`
@@ -0,0 +1,39 @@
1
+ # engine.timeline — timeline(opts?: TimelineOptions)
2
+
3
+ Cutscenes, tweens (timeline() module)
4
+
5
+ - Options `TimelineOptions`:
6
+ - `skipKeys?: string[]` Keys that skip a cutscene, default ['Escape', 'Backspace'] (Esc is the back key, which the UI focus stack hands to the topmost cutscene; cutscenes do not advance while frozen)
7
+
8
+ ## Methods and properties
9
+ - `timeline.tween(target: any, to: TweenTo, duration?: number, ease?: Ease) → TweenPromise` — General tween (the only entry point for tweens in the engine): await engine.timeline.tween(mesh, { 'position.y': 2 }, 1, 'outCubic'); duration in seconds. Returns a Promise (with finish()/cancel())
10
+ - `timeline.play(steps: TimelineStep | TimelineStep[], opts?: TimelinePlayOptions) → Promise<{ skipped: boolean }>` — Play a timeline; resolves with { skipped } when it ends
11
+ - `timeline.skip(run?: any)` — Skip all (or one) playing timelines
12
+ - Properties:
13
+ - `skipAll: boolean` Skip every cutscene immediately (set by scenario param cutscene=skip)
14
+ - `playing: boolean` Whether a cutscene is playing
15
+
16
+ ## Timeline steps (engine.timeline.play([...]))
17
+ - **TimelineStep** Timeline steps (run in order), which can be any of the following:
18
+ - `TimelineStep[]`
19
+ - `((engine: Engine, run: any) => any)`
20
+ - `{ parallel: TimelineStep[] }`
21
+ - `{ sequence: TimelineStep[] }`
22
+ - `{ wait: number }` — Wait some seconds
23
+ - `{ waitFor: string, timeout? }` — Wait for an event; timeout is the maximum seconds to wait
24
+ - `{ do: (engine: Engine, run: any) => any }` — Run a piece of code (may be async)
25
+ - `{ tween: { target: any; to: TweenTo; duration?: number; ease?: Ease } }` — Tween: target is the object, to the target values, duration in seconds
26
+ - `{ camera: { from?, to?, duration?, ease?, fov?, release? } | { release: true } }` — Camera: from/to end points, duration in seconds, fov target field of view; or { release: true } to hand the camera back
27
+ - `{ path: { object, points, duration?, ease?, lookAhead?, ground?, … } }` — * Move an object (or character, or camera) along a path: points are the path points, duration in seconds, lookAhead how far ahead to look (0–1), ground snaps to the ground (a number = height above ground)
28
+ - `{ fade: number, to? }` — Full-screen fade: fade is the seconds, to is the target cover (0 transparent ... 1 full black, default 1)
29
+ - `{ say: { speaker?, text?, nodes?, node? } }` — Say a line of dialogue (needs the dialogue module) and wait for the dialogue to end
30
+
31
+ ## Data structures
32
+ - **TimelinePlayOptions**
33
+ - `skippable?: boolean` Can be skipped, default true
34
+ - `letterbox?: boolean` Letterbox bars, default false
35
+ - `lockInput?: boolean` Lock player input while playing, default true
36
+ - **CameraPose** One end point of a camera move
37
+ - `position?: Vec3Like` Camera position
38
+ - `lookAt?: Vec3Like | Object3D` The point to look at, or a moving object
39
+ - `fov?: number` Field of view (degrees)
@@ -0,0 +1,57 @@
1
+ # Utility functions (imported from threedog)
2
+
3
+ - `postAdd(...effects: PostEffect[]) → Style` — A style part that adds post effects to the ones before it (a plain { post: [...] } would replace the whole list); an effect with the same name replaces that one in place. Style parts with it: createEngine({ style: [lowpoly, postAdd(myGrain, bloom({ strength: 0.6 }))] })
4
+ - `postRemove(...names: string[]) → Style` — A style part that removes post effects by name from the ones before it: createEngine({ style: [lowpoly, postRemove('ao', 'outline')] })
5
+ - `presets: { weather, calendar, player, interactions, keys, camera }` — Opt-in gameplay presets: named option objects a game picks on purpose (the engine never applies one itself). Each only bundles options the game could write; spread and override: weather({ ...presets.weather.temperate, autoPool: ['clear', 'rain'] })
6
+ - `world(opts?: { cellSize?, radius?, farEvery?, farMaxPerTick?, buildPerFrame? }) → import("../../../core").ModuleDef…` — World data module: installed as engine.world. Put things here that must be saved, survive level changes and keep changing while far away; models are only built while nearby
7
+ - `net(opts?: { role, transport, sync?, syncEvery?, keepAlive?, rate?, … }) → import("../../../core").ModuleDef…` — (experimental) Optional co-op multiplayer: one host owns the state, clients mirror it and ask for changes through ops. Installed as engine.net. Host: peers' requests run as `ops.run(name, args, { source: 'net', actor })` only for ops defined with net: 'peer', with the op's args shape checked, the optional owner check, and a per-peer rate limit; the result comes back after the state diff that contains it. State: world records, containers, vars and the other save parts are sent as a snapshot on join and as diffs every syncEvery steps. Client: ops.run of a peer op returns { ok: true, pending: true, seq } (watch state or the net:result event, not the return value); its own avatar moves locally and is sent to the host (clamped to maxSpeed); other avatars glide between updates.
8
+ - `fakeNetwork(opts?: { latency?, jitter?, loss?, seed?, manual? }) → { host, connect, advance, now, loss, latency, … }` — (experimental) An in-process network for tests and offline demos: one host and any number of clients in the same page, with optional latency, jitter and loss. Messages are deep-copied on send (no shared objects, like a real wire). Order per link is kept, as on a WebSocket. manual: true delivers only when you call advance(ms) (deterministic tests); otherwise messages land after real time.
9
+ - `webSocket(url: string, { host, key }?: { host?: boolean; key?: string }) → { send, on, close, key, id }` — (experimental) WebSocket transport: talks to the relay in packages/tools/net-relay.mjs (`node packages/tools/net-relay.mjs 8787`). The host joins a room with host: true; clients join the same room. The relay assigns peer ids and remembers each client's key for reconnects. Messages are JSON. For a dedicated server or Colyseus, write another transport with the same send / on / close shape instead.
10
+ - `grids() → import("../../../core").ModuleDef…` — (experimental) Grid placement module: installed as engine.grids. Needs world(). Adds the ops grid.place / grid.remove / grid.move and the save key 'grids' (layers).
11
+ - `screenToGround(engine: Engine, ndcX: number, ndcY: number, opts?: { maxDistance?: number }) → Vector3 | null` — Screen coordinates (-1..1) -> point on the ground; null if the ray misses the ground
12
+ - `EASINGS: Record<EaseName, (t: number) => number>` — All easing functions: name -> function
13
+ - `ease(e: Ease) → (t: number) => number` — Name or function -> easing function
14
+ - `checkOptions(where: string, opts: object | null | undefined, known: string[], flags?: { loose?: boolean })` — Warn (once, in development) about unknown keys in an options object, with a "did you mean" hint. For your own modules. where names the call ('stamina()'); known lists the keys your code reads; loose only warns on near-misses (data with game-specific fields).
15
+ - `readParams(where: string, schema: Record<string, ParamSpec>, opts?: object) → T` — Module options read through a params schema: unknown keys and wrong types throw in dev with the fix, defaults are filled in. Also put params / options on the module definition so engine.catalog(name) shows them (recipes/51-capability-catalog.md).
16
+ - `defineLookPart(engine: any, spec: { id, group?, module?, object?, params?, style?, … }) → LookPart` — Register a module's own look part: engine.look.<id> with set / patch / replace, engine.catalog('look.<id>') and describe().look (recipes/52-look.md). Every param needs a default; a default that changes the picture also needs why and off (or neutral: true).
17
+ - `createTerrain(cfg?: Partial<TerrainConfig>) → TerrainGen` — Pure terrain computation (no engine needed), for previewing heights before start: createTerrain({ seed, ...terrainPreset() }).surface(x, z)
18
+ - `terrainMaterial(base?: THREE.Material | null, engine?: { style: any; assets: any }) → THREE.Material` — Terrain material: base (default the style's 'terrain' role with vertex colors) + cloud shadows + season tint + optional detail texture (style.terrain.detail). Pass the engine so its style pack and assets are used.
19
+ - `mergeColored(parts: [THREE.BufferGeometry, ColorLike][], { flat }?: { flat?: boolean }) → THREE.BufferGeometry` — Merge several geometries into one vertex-colored geometry (a tree = trunk + canopy in one draw call): [[geometry, color], ...]. flat (default true): one normal per triangle, the faceted low-poly look; false keeps each part's own (smooth) normals. UVs are kept when every part has them, so the merged model can still take a texture.
20
+ - `applyEffects(material: THREE.Material, { wind, clouds, season, detail, engine, patches }?: { wind?, clouds?, season?, detail?, engine?, patches? }) → THREE.Material` — Add effects to any material (built-in, from a style pack, or third-party); returns the same material. The one entry for shader effects: wind (sway amplitude; the shadow sways too, nothing else to set up), clouds (drifting cloud shadows, default on; how dark is style.clouds.shadow), season ('foliage' / 'ground' seasonal tint), and patches: your own named patches (see ShaderPatch in render/patches.js), detail (grain / paper / strokes / a texture over the surface, see MaterialDetail in types/style.d.ts; a texture given by asset name loads from `engine`, default the first live engine). The 'world' patch (varying vThreedogWorld, world position) comes with clouds, and is added for any of your patches that lists it in needs.patches.
21
+ - `MATERIAL_PURPOSES: string[]` — Material roles the engine itself uses
22
+ - `makeMaterial(purpose?: string, params?: { color?, … }, engine?: { style: any }) → THREE.Material` — Create a material by role: makeMaterial('furniture', { color: 0x8a5a36 }); the look comes from the style pack's materials[role] (unlisted roles use materials.default). Roles the engine uses: default terrain vegetation character water pickup prop (MATERIAL_PURPOSES); a game may pick new names (e.g. 'building'), and a name close to an existing role ('props', 'charcter') warns in dev. A style pack entry has one of three forms; params are then applied to the result (keys the material lacks are skipped):
23
+ - `materialPatches(material: THREE.Material) → string[]` — Names of the patches on a material (in order), e.g. ['clouds', 'tint', 'wind']
24
+ - `toast(engine: Engine, text: string, { kind, ms }?: { kind?: string; ms?: number })` — Show a short message through the 'toast' UI part (default: top of the screen, gone after ms). A game restyles it, filters it by kind or turns it off with createEngine({ ui: { toast: false } }). kind says where it came from: 'info' (default), 'quest', 'item', 'save', 'error'.
25
+ - `makeWindow(engine: Engine, opts: WindowOptions) → UIWindow` — A toggleable window
26
+ - `worldToScreen(engine: Engine, pos: PositionLike) → ScreenPoint` — World coordinates (position or object) -> pixels from the canvas's top-left corner { x, y, onScreen, behind } (the UI root covers the canvas, so these place UI elements directly)
27
+ - `fadeScreen(engine: Engine, to: number, seconds?: number) → Promise<void>` — Fade the whole screen to `to` (0 clear ... 1 fully covered) over `seconds` (default 0.5); the Promise resolves when the fade ends
28
+ - `uiFocus(engine: Engine) → UIFocus` — UI focus stack: windows, dialogue and cutscenes push in open order; the back key (Esc) goes to the top only; an empty stack hands it to the settings menu
29
+ - `toggleOnKey(engine: Engine, win: { open, toggle }, action: string)` — Window toggle key: call once per frame in a frame hook; opens on the action when closed, closes on another press when open
30
+ - `parseClock(clock: string | number, hoursPerDay?: number) → number` — Clock time -> fraction of the day: parseClock('18:30') = 0.77; a number or numeric string ('0.25') is converted as is. hoursPerDay is hours per day, default 24
31
+ - `formatClock(t: number, hoursPerDay?: number) → string` — Fraction of the day -> 'HH:MM': formatClock(0.75) = '18:00'
32
+ - `inRange(t: number, from: string | number, to: string | number, hoursPerDay?: number) → boolean` — Is time t (0-1, e.g. sky.timeOfDay) inside the range [from, to)? from and to are 'HH:MM' or 0-1; from > to wraps past midnight. Used by sky.between and the audio rule condition { time: [from, to] }
33
+ - `pickTarget(from: PositionLike, view: { x: number; z: number } | number, candidates: Iterable<T>, opts?: TargetOptions<T>) → T | null` — Best target in front: lowest "distance + angle off view × angleWeight" inside radius and cone. view is a direction { x, z } (cameraRig.forward()) or a facing angle. Returns the candidate or null
34
+ - `switchTarget(from: PositionLike, view: { x: number; z: number } | number, current: T | null, candidates: Iterable<T>, side: 1 | -1, opts?: Pick<TargetOptions<T>, 'radius' | '…) → T | null` — Next target to the right (side 1) or left (-1) of current as seen along view, wrapping; current missing → the leftmost. Returns a candidate or null
35
+ - `THREE` — three.js itself (any): `import { THREE } from 'threedog'`
36
+
37
+ ## Data structures
38
+ - **WindowOptions** Parameters of makeWindow()
39
+ - `id: string` Window name (also the style pack's template name)
40
+ - `title: () => string` Title
41
+ - `hintAction?: string` Action name that toggles it (shows the key hint)
42
+ - `render: (data, tools) => string` Default content: (data, tools) => HTML
43
+ - `data?: () => any` Template data
44
+ - `onCancel?: () => void` What to do on the back key (Esc), default closes the window (an open window is on the UI focus stack, and Esc goes only to the topmost)
45
+ - **UIWindow** Window returned by makeWindow()
46
+ - `el: HTMLElement`
47
+ - `open: boolean` Whether it is open
48
+ - `refresh()` — Redraw the content
49
+ - `toggle(on?: boolean)` — Open / close (toggle if no argument is passed)
50
+ - **ScreenPoint** Result of worldToScreen(): x/y are pixels from the canvas's top-left corner (the UI root covers the canvas), onScreen is inside the view, behind is behind the camera
51
+ - `x: number`
52
+ - `y: number`
53
+ - `onScreen: boolean`
54
+ - `behind: boolean`
55
+
56
+ ## Other exported classes and functions
57
+ - `serve(handler: (msg: any) => any)` — Start answering lane messages in a worker. handler is the same function the lane's local() returns on the main thread.
@@ -0,0 +1,56 @@
1
+ # engine.triggers — triggers(opts?: TriggersOptions)
2
+
3
+ Trigger zones (triggers() module)
4
+
5
+ - Options `TriggersOptions`:
6
+ - `debug?: boolean` Show the wireframes from the start
7
+ - `action?: string` Action name that toggles the wireframes, default 'triggersDebug'
8
+ - `keys?: string[]` Key that toggles the wireframes: default ['F4'] in dev builds, none in release builds
9
+
10
+ ## Methods and properties
11
+ - `triggers.list() → Trigger[]` — All trigger zones (a new array)
12
+ - `triggers.add(opts?: TriggerOptions) → Trigger` — Add a trigger zone
13
+ - `triggers.clear()` — Delete all (delete a single one with trigger.remove())
14
+ - `triggers.byTag(tag: string) → Trigger[]` — Find by tag
15
+ - `triggers.fromMarkers(opts?: TriggerOptions) → Trigger[]` — Every trigger_xxx marker in the level becomes a trigger zone with tag xxx; opts is shared by all of them
16
+ - `triggers.setDebug(on: boolean)` — Show / hide the wireframes
17
+ - Properties:
18
+ - `debug: boolean` Whether wireframes are shown
19
+
20
+ ## Data structures
21
+ - **TriggerOptions** Trigger zone parameters
22
+ - `shape?: 'cylinder' | 'sphere' | 'box'` Shape: 'cylinder' upright cylinder (default) / 'sphere' / 'box' cuboid
23
+ - `position?: PositionLike` Center { x, y, z } / [x, y, z] / Vector3 / object (meters); for box and cylinder y is the bottom height; without y the ground height is used
24
+ - `radius?: number` Sphere/cylinder radius (meters), default 1.5
25
+ - `size?: number[]` Box size [width, height, depth] (meters), default [2, 2, 2]
26
+ - `height?: number` Cylinder height (meters), default 3
27
+ - `rotation?: number` Box rotation around the Y axis (radians)
28
+ - `onEnter?: ((t: Trigger, who: Vector3) => void) | null` Called on entering; who is the position that entered
29
+ - `onExit?: ((t: Trigger, who: Vector3 | null) => void) | null` Called on leaving
30
+ - `onStay?: ((dt: number, t: Trigger, who: Vector3) => void) | null` Called every fixed step while inside (dt in seconds)
31
+ - `once?: boolean` Fire on the first enter only (exit follows at once); the zone stays with used = true, and a new playthrough (engine.session) re-arms it
32
+ - `enabled?: boolean` false pauses detection
33
+ - `tag?: string` Name (carried in events)
34
+ - `who?: Vector3 | Object3D | { x, y, z } | (() => Array<{ x: number; …) | null` Who can trigger it: the player by default; or a position, an object (its position is used), or a function returning an array of positions
35
+ - `cooldown?: number` Seconds after leaving during which entering does not fire again, default 0
36
+ - `userData?: Record<string, any>` Custom data
37
+ - **Trigger** A trigger zone (the return value of add())
38
+ - `shape: 'cylinder' | 'sphere' | 'box'`
39
+ - `x: number` Position (meters)
40
+ - `y: number`
41
+ - `z: number`
42
+ - `radius: number`
43
+ - `height: number`
44
+ - `rotation: number`
45
+ - `tag: string`
46
+ - `inside: boolean` Whether the player is inside now
47
+ - `enabled: boolean` Can be changed at any time: false pauses detection
48
+ - `once: boolean`
49
+ - `used: boolean` A once zone that already fired this playthrough
50
+ - `cooldown: number`
51
+ - `userData: Record<string, any>`
52
+ - `onEnter: TriggerOptions['onEnter']`
53
+ - `onExit: TriggerOptions['onExit']`
54
+ - `onStay: TriggerOptions['onStay']`
55
+ - `remove()` — Delete this trigger zone
56
+ - `contains(p: { x: number; y: number; z: number }) → boolean` — Whether a point is inside
@@ -0,0 +1,9 @@
1
+ # engine.vars (Vars) — engine.vars: story flags and counters (autosaved)
2
+
3
+ - `vars.flag(key: string) → any` — Read a flag
4
+ - `vars.setFlag(key: string, value?: any)` — Set a flag (default true)
5
+ - `vars.counter(key: string) → number` — Read a counter (0 if none)
6
+ - `vars.bump(key: string, n?: number) → number` — Counter +n (default 1), returns the new value
7
+ - Properties:
8
+ - `flags: Record<string, any>` All flags
9
+ - `counters: Record<string, number>` All counters
@@ -0,0 +1,52 @@
1
+ # engine.vegetation — vegetation(opts?: VegetationModuleOptions)
2
+
3
+ Vegetation (vegetation() module; grows on terrain or on any ground provider)
4
+
5
+ - Options `VegetationModuleOptions`:
6
+ - `chunkSize?: number` Chunk edge (meters), default 32
7
+ - `viewChunks?: number` Rings of chunks drawn around each stream source, default 3
8
+ - `density?: number` Placement attempts multiplier, default 1
9
+ - `area?: { min: number[]; max: number[] } | null` Where it may grow: { min: [x, z], max: [x, z] }; default anywhere the ground is
10
+ - `seed?: number` Placement seed, default 1
11
+
12
+ ## Methods and properties
13
+ - `vegetation.rebuild()` — Place every chunk again: after changing the ground behind the same provider (a ground function reading game state). A new setGround or level is followed automatically
14
+ - `vegetation.setShadowRing(name: string, ring: number)` — Change at runtime how far a vegetation kind casts shadows: within `ring` chunk rings of the player (0 = only the chunk you stand in, 1 = the default, larger = further and dearer). Takes effect at once; the add() option shadowRing is only the starting value. An unknown name warns with the known ones. Example: `engine.vegetation.setShadowRing('tree', 0); // graphics setting "shadows: low": trees shadow only the nearest chunk`
15
+ - `vegetation.add(name: string, opts: VegetationOptions) → Species` — Register a kind of vegetation
16
+ - `vegetation.removeInstance(species: string, cx: number, cz: number, id: number, opts?: { regrowSeconds?: number }) → string` — Remove one (chop a tree). regrowSeconds: grows back after this many game seconds, 0 = permanent. The record is saved with the save (save key 'vegetation'). Returns the entry name
17
+ - `vegetation.restoreInstance(species: string, cx: number, cz: number, id: number)` — Restore one
18
+ - `vegetation.instanceAt(position: PositionLike, opts?: { radius?, species? }) → VegetationHit | null` — The one nearest to position within radius meters (default 2) (species restricts to one kind), null if none
19
+ - Also: `vegetation.get(name: string) → Species | undefined`, `vegetation.list() → Species[]`, `vegetation.isRemoved(species: string, cx: number, cz: number, id: number) → boolean`
20
+
21
+ ## Data structures
22
+ - **VegetationOptions** Parameters of engine.vegetation.add(name, {...})
23
+ - `geometry?: BufferGeometry` High-detail model (this or model is required)
24
+ - `model?: Object3D` Multi-material model (one material per mesh, e.g. bark trunk + leaf cards); still one InstancedMesh per species. Its materials are cloned
25
+ - `lodGeometry?: BufferGeometry | Object3D` Low-detail model, switched to beyond lodRing rings; with model an Object3D with the same mesh order, or a geometry drawn with the first material
26
+ - `rule?: VegetationRule` Placement rule
27
+ - `wind?: number` Wind sway amplitude, 0 = still
28
+ - `nearOnly?: boolean` Only generated near the player (grass, flowers)
29
+ - `maxRing?: number` No longer drawn beyond this many rings
30
+ - `lodRing?: number` Switch to the low-detail model beyond this many rings, default 1
31
+ - `castShadow?: boolean` Cast shadows
32
+ - `shadowRing?: number` Cast shadows within this many rings
33
+ - `receiveShadow?: boolean` Receive shadows, default true
34
+ - `material?: Material` Custom material, any three.js material (default: the style pack's 'vegetation' role); wind, cloud shadows and season tint are added to it
35
+ - `effects?: boolean` false: leave a custom material untouched (no wind / clouds / season added)
36
+ - `doubleSided?: boolean` Double-sided rendering
37
+ - **VegetationRule** Vegetation placement rule (must be JSON-able, no functions)
38
+ - `perChunk?: number` Placement attempts per chunk, default 100
39
+ - `chance?: number` Success probability of each attempt 0–1 (when cluster is 'none'), default 1
40
+ - `minHeight?: number` Altitude range (meters); default unlimited both ways (a terrain game names its band above the water, e.g. minHeight: 1.5)
41
+ - `maxHeight?: number`
42
+ - `maxSlope?: number` Max slope
43
+ - `cluster?: 'forest' | 'meadow' | 'none'` Clustering: 'forest' grows into woods / 'meadow' grows in open ground / 'none' even
44
+ - `scale?: number[]` Size range [min, max] multiplier
45
+ - `stretch?: number[]` Height stretch [min, max] multiplier
46
+ - `sink?: number` How deep to bury into the ground (meters, multiplied by size)
47
+ - `tintJitter?: number` Random color jitter 0–1
48
+ - `tints?: { color: number[]; chance: number }[]` Special color: color [r, g, b] multiplier, chance probability
49
+ - `biomes?: Record<string, number> | null` Which ground types it grows on: { type: probability 0–1 } (engine.groundType: a terrain groundType, a level mesh's groundType property or material name); omitted = grows anywhere
50
+ - `collider?: number` Collision circle radius (meters, multiplied by size), 0 = no collision
51
+ - `avoidFlat?: boolean` Avoid flattened plots (villages), default true
52
+ - `salt?: number` Random seed offset (default computed from the name)
@@ -0,0 +1,48 @@
1
+ # engine.water — water(opts?: WaterOptions)
2
+
3
+ Water surface (water() module)
4
+
5
+ - Options `WaterOptions`:
6
+ - `sea?: boolean` false: do not draw the global water surface (sea)
7
+ - `level?: number` Global water level (meters); if omitted, the terrain's water level is used
8
+ - `color?: ColorLike`
9
+ - `opacity?: number`
10
+ - `flat?: boolean`
11
+ - `waveHeight?: number`
12
+ - `waveScale?: number`
13
+ - `waveSpeed?: number`
14
+ - `fresnel?: number`
15
+ - `size?: number`
16
+ - `segments?: number`
17
+ - `normalMap?: string`
18
+ - `normalScale?: number`
19
+ - `normalRepeat?: number`
20
+ - `normalSpeed?: number[]`
21
+ - `shininess?: number`
22
+ - `specular?: ColorLike`
23
+ - `material?: import('./style').StyleWater['material']` Replace the whole surface material, same as style.water.material
24
+ - `depthColor?: import('./style').StyleWater['depthColor']`
25
+ - `foam?: import('./style').StyleWater['foam']`
26
+ - `glsl?: import('./style').StyleWater['glsl']`
27
+ - `uniforms?: import('./style').StyleWater['uniforms']`
28
+
29
+ ## Methods and properties
30
+ - Properties:
31
+ - `material: THREE.Material` Water material (shared by all water)
32
+ - `bodies: Map<WaterBody, THREE.Mesh>` Water body → mesh
33
+ - `sea: THREE.Mesh | null` Global water mesh (null when absent)
34
+
35
+ ## Data structures
36
+ - **WaterBodyOptions** Parameters of engine.addWaterBody(): position center, level water surface height (meters); give radius for a circle, halfWidth / halfDepth for a rectangle
37
+ - `position: PositionLike`
38
+ - `level: number`
39
+ - `radius?: number`
40
+ - `halfWidth?: number`
41
+ - `halfDepth?: number`
42
+ - **WaterBody** A standalone body of water (stored in engine.waterBodies and given by the water:add event, already converted): circle { x, z, radius, level } or rectangle { x, z, hw, hd, level } (meters)
43
+ - `x: number` Center position (meters)
44
+ - `z: number`
45
+ - `level: number` Water surface height (meters)
46
+ - `radius?: number` Radius of a circular body (meters)
47
+ - `hw?: number` Half width and half depth of a rectangular body (meters)
48
+ - `hd?: number`
@@ -0,0 +1,29 @@
1
+ # engine.weather — weather(opts?: WeatherOptions)
2
+
3
+ Weather (weather() module, needs sky)
4
+
5
+ - Options `WeatherOptions`:
6
+ - `start?: WeatherName` Starting weather, default 'clear' (or the first of the game's types when it has no 'clear')
7
+ - `auto?: boolean` Automatic weather changes
8
+ - `particles?: number` Rain / snow particle count, default 6000
9
+ - `types?: Record<string, Partial<WeatherPreset> & Record<string, numb…` The game's weather table, the whole list (default only a calm 'clear'; seven temperate ones in presets.weather.temperate.types, extend them with { ...presets.weather.temperate.types, dust: {...} }). Left-out fields are calm; extra numeric fields of the game's own blend too and show in weather.current
10
+ - `autoPool?: string[]` Candidates for automatic changes (repeat an entry for higher probability)
11
+ - `autoInterval?: number[]` Interval between automatic changes [shortest, longest] seconds
12
+ - `transition?: number` Transition seconds of automatic changes, default 25
13
+ - `area?: number` Rain / snow coverage (meters)
14
+
15
+ ## Methods and properties
16
+ - `weather.define(_field: string, _spec?: import("../../../style").StyleWeath…) → never` — Renamed in 0.2: throws and names the new call, engine.look.weather.replace({ [field]: spec }) (recipes/44-water-weather-look-hooks.md)
17
+ - `weather.setAuto(on: boolean)` — Automatic weather on/off
18
+ - `weather.set(name: WeatherName, seconds?: number)` — Switch weather. seconds: transition seconds, default 15
19
+ - `weather.label(name?: string) → string` — Display name of a weather (string table weather.<name>, falls back to the name itself); defaults to the current weather
20
+ - Properties:
21
+ - `types: Record<string, WeatherPreset>` The weather types this game has: name -> numbers (the standard fields plus any of the game's own, all blended on change)
22
+ - `current: WeatherPreset` Current (mid-transition) weather parameters
23
+ - `name: string` Current weather name
24
+ - `auto: boolean` Automatic weather on/off
25
+ - `autoPool: string[]` Candidates for automatic weather (repeat a name to make it likelier)
26
+ - `autoInterval: number[]` Automatic weather interval [min, max] seconds
27
+ - `autoTransition: number` Transition seconds for automatic weather
28
+ - `particles: number` Default particle count per system (halved on low-tier devices)
29
+ - `systems: Map<string, any>` Particle systems drawn now: field -> { field, object, uniforms } (rain / snow when the table has them, plus define())