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,772 @@
1
+ // World modules: terrain, vegetation, sky, weather, water.
2
+ import type { Object3D, Vector3, Color, Material, BufferGeometry, ColorLike, Handle, PositionLike } from './common';
3
+ import type { Engine, ModuleDef } from './core';
4
+ import type { StyleSky, StyleShadow, StyleFog } from './style';
5
+
6
+ // ======================================================================
7
+ // Terrain terrain()
8
+ // ======================================================================
9
+
10
+ /** Steep-slope colors: used when the normal's Y component is below maxNormalY */
11
+ export interface SteepRule { maxNormalY: number; colors: string[] }
12
+ /** Flattened plot (for villages, houses): center x/z, radius (meters), height optionally fixes the height */
13
+ export interface FlattenZone { x: number; z: number; radius: number; height?: number; clearRatio?: number }
14
+
15
+ /** Noise helpers handed to a custom height / groundType function (it cannot import anything) */
16
+ export interface TerrainNoise {
17
+ fbm(x: number, z: number, octaves?: number): number; noise(x: number, z: number): number; hash(x: number, z: number, salt?: number): number; seed: number;
18
+ /** The terrain's water level (meters; -Infinity when the terrain has no water) */
19
+ waterLevel: number;
20
+ /** terrain({ params }): plain data for the generator (a preset's settings) */
21
+ params: Record<string, any>;
22
+ }
23
+
24
+ /** Options of engine.terrain.edit() */
25
+ export interface TerrainEditOptions {
26
+ /** Meters, default half a cell. Heights snap to grid points and paint to cells inside the shape; the nearest one when the shape is smaller */
27
+ radius?: number;
28
+ /** Default 'circle' */
29
+ shape?: 'circle' | 'square';
30
+ /** Raise by meters (one of raise / lower / flatten) */
31
+ raise?: number;
32
+ /** Lower by meters (dig) */
33
+ lower?: number;
34
+ /** Set the height to this many meters (level a foundation) */
35
+ flatten?: number;
36
+ /** Paint the ground type ('tilled', 'wet', or a game's own with biomeColors[type]); null gives the cells back their generated type */
37
+ paint?: string | null;
38
+ }
39
+
40
+ /**
41
+ * World outline, terrain({ shape }): ground only where mask > 0, cut along straight lines through the cells where it crosses 0, with walls
42
+ * down the rim (side) and optionally a hanging underside (bottom). Off it engine.surface is -Infinity, engine.ground.has false, slope 0,
43
+ * groundType 'void'; nothing grows there; a fall below voidY emits terrain:void. Without shape the terrain is unchanged.
44
+ * Depth and mask functions are pure like height (they run in workers). See recipes/42-terrain-shape.md.
45
+ * @example terrain({ height: (x, z, n) => 6 * n.fbm(x * 0.02, z * 0.02), shape: { mask: (x, z) => 40 - Math.hypot(x, z),
46
+ * edge: { noise: 5, size: 14 }, side: { depth: 2, ground: 'cliff' }, bottom: { depth: (x, z, n, m) => 4 + m * 0.6, ground: 'rock' } } })
47
+ */
48
+ export interface TerrainShape {
49
+ /**
50
+ * Where there is ground: (x, z, n) => number, > 0 ground (distance-like values in meters read best: 40 - Math.hypot(x, z) is a 40 m disc).
51
+ * Or a gray image: whiter is ground, value = gray - threshold (default 0.5); outside the image is void.
52
+ */
53
+ mask: ((x: number, z: number, n: TerrainNoise) => number) | string
54
+ | { url?: string; data?: ArrayLike<number>; width?: number; height?: number; size: number[]; center?: number[]; threshold?: number };
55
+ /**
56
+ * The rim's look. noise: meters of fbm added to the mask (a ragged outline), size: its wavelength in meters (default 16; keep it above a cell,
57
+ * the cut cannot be finer than `resolution`); jitter: meters of per-grid-point random offset (a jagged rim); round: meters the top bends down
58
+ * towards the rim (0 = a hard cliff edge)
59
+ */
60
+ edge?: { noise?: number; size?: number; jitter?: number; round?: number };
61
+ /**
62
+ * Wall down from the rim: depth meters (default 2) or (x, z, n) => meters; ground: color = biomeColors[ground] (default 'cliff');
63
+ * material: a Material (or (engine) => Material) for sides and bottom
64
+ */
65
+ side?: { depth?: number | ((x: number, z: number, n: TerrainNoise) => number) | string; ground?: string;
66
+ material?: Material | ((engine: Engine) => Material) };
67
+ /**
68
+ * Underside, below the side band: depth meters (default 4) or (x, z, n, m) => meters, m = mask value there (larger inland, so the middle
69
+ * hangs lower); ground default 'rock'. Without it the island is open below
70
+ */
71
+ bottom?: { depth?: number | ((x: number, z: number, n: TerrainNoise, m: number) => number) | string; ground?: string } | null;
72
+ /** Height below which a fall emits terrain:void (default 50 m under the lowest island chunk loaded so far); give it for replay-exact games */
73
+ voidY?: number;
74
+ }
75
+
76
+ /** Terrain generation parameters (JSON-able; a custom height / groundType function is sent to workers as source text) */
77
+ export interface TerrainConfig {
78
+ /** Random seed; the same seed gives the same terrain */
79
+ seed: number;
80
+ /** Chunk edge length (meters), default 64 */
81
+ chunkSize: number;
82
+ /** Cells per chunk; smaller is more "low poly", default 16 */
83
+ resolution: number;
84
+ /** Water level (meters), default -Infinity = no water (terrainPreset() from @threedog/terrain-noise sets 0) */
85
+ waterLevel: number;
86
+ /** Flattened plots */
87
+ flatten: FlattenZone[];
88
+ /** Ground type → palette color names (two are blended by noise); usually from style.terrain.biomeColors */
89
+ biomeColors: Record<string, string[]>;
90
+ /** Steep-slope color rule */
91
+ steep: SteepRule[];
92
+ /** Heightmap (used when there is no height function): url grayscale image, size [width m, length m], min/max height (meters), center [x, z] */
93
+ heightmap: { url?: string; size?: number[]; min?: number; max?: number; center?: number[]; outside?: number; data?: ArrayLike<number>; width?: number; height?: number } | null;
94
+ /**
95
+ * Height generator: (x, z, n) => meters. Without one (and without a heightmap) the ground is flat at y = 0, a placeholder (dev warning).
96
+ * Runs in workers, so it must be pure (only its parameters and globals like Math); an outside variable throws at terrain() naming it.
97
+ * n = { fbm(x, z, octaves?), noise(x, z), hash(x, z, salt?), seed, waterLevel, params }. Flatten still applies. Presets: terrainPreset() from
98
+ * @threedog/terrain-noise.
99
+ * @example terrain({ height: (x, z, n) => 4 + 12 * n.fbm(x * 0.01, z * 0.01) })
100
+ */
101
+ height: ((x: number, z: number, n: TerrainNoise) => number) | string | null;
102
+ /**
103
+ * Ground type: (x, z, h, slope, n) => type name (null = 'default'). Pure, like height. Colors come from biomeColors[type]; vegetation rules and
104
+ * footsteps match by name.
105
+ * @example terrain({ groundType: (x, z, h, slope) => slope > 0.7 ? 'rock' : h < 2 ? 'beach' : 'grass' })
106
+ */
107
+ groundType: ((x: number, z: number, h: number, slope: number, n: TerrainNoise) => string | null) | string | null;
108
+ /** Plain data handed to height / groundType as n.params (a preset's settings); must be serializable */
109
+ params: Record<string, any> | null;
110
+ /**
111
+ * How the ground gets its color: 'smooth' (default) blended per grid point | 'flat' one color and normal per triangle (low poly) |
112
+ * 'texture' per-chunk color map sampled per pixel, so color borders (a river bank) are not confined to triangle edges and the mesh can stay coarse.
113
+ * See recipes/37-terrain-look-hooks.md. A style may set it (style.terrain.config.shading).
114
+ */
115
+ shading: 'flat' | 'smooth' | 'texture';
116
+ /** Texture shading: color map pixels per chunk edge (default 128, 64 on low-tier devices; independent of `resolution`). A style may set it */
117
+ colorResolution: number;
118
+ /** Texture shading only: lighting normals 'smooth' (default) | 'flat'. A style may set it */
119
+ normals: 'smooth' | 'flat' | null;
120
+ /**
121
+ * Replace the smooth normal at grid point (i, j): (i, j, h, cell) => [nx, ny, nz] (any length; the engine normalizes). h(i, j) is a grid-point
122
+ * height, cell the grid spacing in meters. Pure, like height (workers get its source). Default: central difference of the neighbors.
123
+ * @example terrain({ normalFn: (i, j, h, cell) => [(h(i - 1, j) - h(i + 1, j)) / (2 * cell), 2, (h(i, j - 1) - h(i, j + 1)) / (2 * cell)] }) // flatter lighting
124
+ */
125
+ normalFn: ((i: number, j: number, h: (i: number, j: number) => number, cell: number) => number[]) | string | null;
126
+ /**
127
+ * How each cell is cut into two triangles: 'fixed' (default, the same diagonal everywhere) | 'adaptive' (along the diagonal with the smaller
128
+ * height difference, fewer zigzag ridges on slopes) | 'alternate' (flips every other cell). It is shape: engine.surface follows it. World setting, not style
129
+ */
130
+ diagonal: 'fixed' | 'adaptive' | 'alternate';
131
+ /** Chunk bounding sphere margin in meters (default { up: 3, radius: 8 }): center raised by `up`, radius grown by `radius`. Raise it when a shader moves vertices far */
132
+ boundsPad: { up?: number; radius?: number };
133
+ /** World outline (default null = ground everywhere): an island, a floating rock, a coastline that ends. World setting, not style */
134
+ shape: TerrainShape | null;
135
+ /** Palette: color name → color */
136
+ colors: Record<string, ColorLike>;
137
+ }
138
+
139
+ /** Parameters of terrain({...}) */
140
+ export interface TerrainOptions extends Partial<TerrainConfig> {
141
+ /** View distance (in chunks), default 4 */
142
+ viewChunks?: number;
143
+ /** Vegetation density multiplier, default 1 */
144
+ density?: number;
145
+ /** 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) */
146
+ viewFog?: boolean;
147
+ /** 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 */
148
+ material?: Material | ((engine: Engine) => Material);
149
+ }
150
+
151
+ /** Pure-computation terrain returned by createTerrain() (draws nothing, only computes heights; usable before the engine exists, e.g. for previews) */
152
+ export interface TerrainGen {
153
+ config: TerrainConfig;
154
+ /** Chunk edge length (meters) */
155
+ CHUNK: number;
156
+ /** Cells per chunk */
157
+ RES: number;
158
+ /** Cell size (meters) */
159
+ CELL: number;
160
+ /** Water level (meters) */
161
+ waterLevel: number;
162
+ /** Ground height at (x, z) (meters); -Infinity off the outline of shape */
163
+ surface(x: number, z: number): number;
164
+ /** Is there ground at (x, z) (false only off the outline of shape) */
165
+ has(x: number, z: number): boolean;
166
+ /** Slope at (x, z) */
167
+ slope(x: number, z: number): number;
168
+ /** Ground type name ('default' without a groundType function) */
169
+ biomeAt(x: number, z: number, h?: number, slope?: number): string;
170
+ /** The noise helpers a height / groundType function receives (n), e.g. for a preset's riverAt(x, z, gen.noise) */
171
+ noise: TerrainNoise;
172
+ /** Fractal noise 0–1 */
173
+ fbm(x: number, z: number, octaves?: number): number;
174
+ buildChunk(cx: number, cz: number): any;
175
+ place(cx: number, cz: number, rule: VegetationRule, density?: number): any;
176
+ }
177
+
178
+ /** engine.terrain: chunk manager */
179
+ export interface Terrain {
180
+ engine: Engine;
181
+ /** Pure-computation terrain (height, landform) */
182
+ T: TerrainGen;
183
+ /** Chunk edge length (meters) */
184
+ readonly CHUNK: number;
185
+ /**
186
+ * terrain({ shape }) only: below this height the player or a moving rigid body has fallen out of the world (one terrain:void per fall).
187
+ * shape.voidY, else 50 m under the lowest island chunk loaded so far; -Infinity without a shape
188
+ * @example engine.events.on('terrain:void', ({ who }) => { if (who === engine.player) engine.player.placeAt(home); });
189
+ */
190
+ readonly voidY: number;
191
+ /** Loaded chunks: 'cx,cz' → chunk */
192
+ chunks: Map<string, any>;
193
+ /** View distance (in chunks) */
194
+ viewChunks: number;
195
+ /** Vegetation density multiplier */
196
+ density: number;
197
+ /** Time budget (milliseconds) for uploading chunks per frame */
198
+ applyBudgetMs: number;
199
+ /** Statistics (for the debug panel) */
200
+ stats: { builtThisFrame: number; applyMs: number; queued: number; visible?: number; loaded?: number; instances?: number };
201
+ /** Change the view distance (in chunks); fog and camera far plane adjust too */
202
+ setViewChunks(n: number): void;
203
+ /** Change the vegetation density (rebuilds all chunks) */
204
+ setDensity(d: number): void;
205
+ /** Rebuild all chunks */
206
+ rebuild(): void;
207
+ /** Grid spacing (meters) = chunkSize / resolution: edits snap to it, paint colors whole cells of this size */
208
+ readonly cellSize: number;
209
+ /**
210
+ * Change the ground: dig, raise, flatten, paint the ground type. Saved gameplay state: call it from an op or a fixed step.
211
+ * engine.surface / slope / groundType, collision, paths and vegetation follow at once; it is saved, and chunks generated later come out edited.
212
+ * @example
213
+ * engine.terrain.edit(pos, { radius: 3, lower: 1.5 }); // dig a pit
214
+ * engine.terrain.edit(pos, { shape: 'square', radius: engine.terrain.cellSize / 2, paint: 'tilled' }); // till one cell
215
+ * @experimental
216
+ */
217
+ edit(position: PositionLike, opts: TerrainEditOptions): { heights: number; cells: number };
218
+ /** Whether the chunks within rings rings (default 1) around position are all loaded */
219
+ isReadyAround(position: PositionLike, opts?: { rings?: number }): boolean;
220
+ }
221
+
222
+ // ======================================================================
223
+ // Vegetation vegetation()
224
+ // ======================================================================
225
+
226
+ /** Vegetation placement rule (must be JSON-able, no functions) */
227
+ export interface VegetationRule {
228
+ /** Placement attempts per chunk, default 100 */
229
+ perChunk?: number;
230
+ /** Success probability of each attempt 0–1 (when cluster is 'none'), default 1 */
231
+ chance?: number;
232
+ /** Altitude range (meters); default unlimited both ways (a terrain game names its band above the water, e.g. minHeight: 1.5) */
233
+ minHeight?: number;
234
+ maxHeight?: number;
235
+ /** Max slope */
236
+ maxSlope?: number;
237
+ /** Clustering: 'forest' grows into woods | 'meadow' grows in open ground | 'none' even */
238
+ cluster?: 'forest' | 'meadow' | 'none';
239
+ /** Size range [min, max] multiplier */
240
+ scale?: number[];
241
+ /** Height stretch [min, max] multiplier */
242
+ stretch?: number[];
243
+ /** How deep to bury into the ground (meters, multiplied by size) */
244
+ sink?: number;
245
+ /** Random color jitter 0–1 */
246
+ tintJitter?: number;
247
+ /** Special color: color [r, g, b] multiplier, chance probability */
248
+ tints?: { color: number[]; chance: number }[];
249
+ /**
250
+ * Which ground types it grows on: { type: probability 0–1 } (engine.groundType: a terrain groundType, a level mesh's groundType property or material
251
+ * name); omitted = grows anywhere
252
+ */
253
+ biomes?: Record<string, number> | null;
254
+ /** Collision circle radius (meters, multiplied by size), 0 = no collision */
255
+ collider?: number;
256
+ /** Avoid flattened plots (villages), default true */
257
+ avoidFlat?: boolean;
258
+ /** Random seed offset (default computed from the name) */
259
+ salt?: number;
260
+ }
261
+ /** Parameters of engine.vegetation.add(name, {...}) */
262
+ export interface VegetationOptions {
263
+ /** High-detail model (this or model is required) */
264
+ geometry?: BufferGeometry;
265
+ /** Multi-material model (one material per mesh, e.g. bark trunk + leaf cards); still one InstancedMesh per species. Its materials are cloned */
266
+ model?: Object3D;
267
+ /** 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 */
268
+ lodGeometry?: BufferGeometry | Object3D;
269
+ /** Placement rule */
270
+ rule?: VegetationRule;
271
+ /** Wind sway amplitude, 0 = still */
272
+ wind?: number;
273
+ /** Only generated near the player (grass, flowers) */
274
+ nearOnly?: boolean;
275
+ /** No longer drawn beyond this many rings */
276
+ maxRing?: number;
277
+ /** Switch to the low-detail model beyond this many rings, default 1 */
278
+ lodRing?: number;
279
+ /** Cast shadows */
280
+ castShadow?: boolean;
281
+ /** Cast shadows within this many rings */
282
+ shadowRing?: number;
283
+ /** Receive shadows, default true */
284
+ receiveShadow?: boolean;
285
+ /** Custom material, any three.js material (default: the style pack's 'vegetation' role); wind, cloud shadows and season tint are added to it */
286
+ material?: Material;
287
+ /** false: leave a custom material untouched (no wind / clouds / season added) */
288
+ effects?: boolean;
289
+ /** Double-sided rendering */
290
+ doubleSided?: boolean;
291
+ }
292
+ /** A registered kind of vegetation */
293
+ export interface Species {
294
+ name: string; geometry: BufferGeometry; lodGeometry: BufferGeometry | null; rule: VegetationRule;
295
+ nearOnly: boolean; maxRing: number; lodRing: number; castShadow: boolean; shadowRing: number; receiveShadow: boolean; material: Material | Material[];
296
+ }
297
+ /** A found plant: species name, chunk cx/cz, stable id, world coordinates position */
298
+ export interface VegetationHit { species: string; cx: number; cz: number; id: number; position: Vector3 }
299
+ export interface VegetationRemoveEvent { species: string; cx: number; cz: number; id: number }
300
+
301
+ /** vegetation({...}): only without terrain (with terrain these are terrain options and are refused) */
302
+ export interface VegetationModuleOptions {
303
+ /** Chunk edge (meters), default 32 */
304
+ chunkSize?: number;
305
+ /** Rings of chunks drawn around each stream source, default 3 */
306
+ viewChunks?: number;
307
+ /** Placement attempts multiplier, default 1 */
308
+ density?: number;
309
+ /** Where it may grow: { min: [x, z], max: [x, z] }; default anywhere the ground is */
310
+ area?: { min: number[]; max: number[] } | null;
311
+ /** Placement seed, default 1 */
312
+ seed?: number;
313
+ }
314
+
315
+ /** engine.vegetation */
316
+ export interface Vegetation {
317
+ /**
318
+ * Place every chunk again: after changing the ground behind the same provider (a ground function reading game state). A new setGround or level is
319
+ * followed automatically
320
+ */
321
+ rebuild(): void;
322
+ /**
323
+ * 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,
324
+ * 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
325
+ * @example engine.vegetation.setShadowRing('tree', 0); // graphics setting "shadows: low": trees shadow only the nearest chunk
326
+ */
327
+ setShadowRing(name: string, ring: number): void;
328
+ /** Register a kind of vegetation */
329
+ add(name: string, opts: VegetationOptions): Species;
330
+ get(name: string): Species | undefined;
331
+ list(): Species[];
332
+ isRemoved(species: string, cx: number, cz: number, id: number): boolean;
333
+ /**
334
+ * Remove one (chop a tree). regrowSeconds: grows back after this many game seconds, 0 = permanent. The record is saved with the save (save key
335
+ * 'vegetation'). Returns the entry name
336
+ */
337
+ removeInstance(species: string, cx: number, cz: number, id: number, opts?: { regrowSeconds?: number }): string;
338
+ /** Restore one */
339
+ restoreInstance(species: string, cx: number, cz: number, id: number): void;
340
+ /** The one nearest to position within radius meters (default 2) (species restricts to one kind), null if none */
341
+ instanceAt(position: PositionLike, opts?: { radius?: number; species?: string | null }): VegetationHit | null;
342
+ }
343
+
344
+ // ======================================================================
345
+ // Sky sky()
346
+ // ======================================================================
347
+
348
+ /** What engine.sky.environment reports */
349
+ export interface SkyEnvironmentInfo { source: string, intensity: number, rotation: number, interval: number, builds: number }
350
+
351
+ export interface SkyOptions extends Omit<StyleSky, 'fog'> {
352
+ /**
353
+ * Who owns scene.fog: true (default; the sky creates it and writes color and distance every frame) | 'manual' (created once, then never written:
354
+ * 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,
355
+ * color, density...) and means true. A sky() option, not a style key. Custom kinds / glsl share the page's shader chunks: a second engine needs
356
+ * the same setting or it throws. See recipes/38
357
+ * @example sky({ fog: 'manual' }) // the game manages scene.fog itself
358
+ */
359
+ fog?: boolean | 'manual' | StyleFog;
360
+ /** Time of day at start: fraction of a day 0–1 (0.5 noon), default 0.33 (afterwards read / write engine.sky.timeOfDay) */
361
+ time?: number;
362
+ /** 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 */
363
+ dayLength?: number;
364
+ /** 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 */
365
+ hoursPerDay?: number;
366
+ /** Which day to start from, default 1 */
367
+ day?: number;
368
+ /** Days of each season given by name only, default 7 */
369
+ daysPerSeason?: number;
370
+ /**
371
+ * The calendar's seasons, default none ([]): names (each daysPerSeason days) or { name, days } for seasons of their own length, e.g. ['spring',
372
+ * 'summer', 'autumn', 'winter']
373
+ */
374
+ seasons?: (string | { name: string, days: number })[];
375
+ /**
376
+ * Whether the sky drives engine.lights.sun: true (default; color, intensity, direction and shadow box from the keyframes) | 'manual' (still aimed
377
+ * 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
378
+ * three.js lights). How the game lights its world, so a sky() option, not a style key. See recipes/38
379
+ * @example sky({ sun: false, hemisphere: false }) // a dungeon lit by the game's own lights
380
+ */
381
+ sun?: boolean | 'manual';
382
+ /** Same for engine.lights.hemi (ambient): true (default) | 'manual' (colors and intensity are the game's) | false (hidden) */
383
+ hemisphere?: boolean | 'manual';
384
+ }
385
+ /** Parameters of sky.at() / daily() */
386
+ export interface SkyAtOptions {
387
+ /** Only fire on these days: a list of days, or (day) => whether to fire */
388
+ days?: number[] | ((day: number) => boolean);
389
+ /** When one advance crosses several trigger points: 'all' fire them all | 'once' fire once (default) | 'skip' do not make up */
390
+ catchUp?: 'all' | 'once' | 'skip';
391
+ }
392
+ /** Callback of sky.between: on is called when entering the period, off when leaving it */
393
+ export interface SkyBetweenOptions {
394
+ /** Entering the period (or found inside it when aligned) */
395
+ on?: () => void;
396
+ /** Leaving the period (or found outside it when aligned) */
397
+ off?: () => void;
398
+ }
399
+ /** Sky modifiers: weather and other modules write them every frame, the sky layers them on its own result */
400
+ /** Sky modifiers (sky.modifiers is the combined result of all layers, read-only) */
401
+ export interface SkyModifiers {
402
+ /** Sunlight multiplier (layers multiply) */
403
+ readonly sun: number;
404
+ /** Ambient light multiplier (layers multiply) */
405
+ readonly ambient: number;
406
+ /** Fog distance multiplier (layers multiply, smaller = denser fog) */
407
+ readonly fog: number;
408
+ /** Sky tint (layers blend weighted by tint amount) */
409
+ readonly tint: Color;
410
+ /** Zenith tint amount 0–1 */
411
+ readonly tintAmount: number;
412
+ /** Horizon tint amount 0–1 */
413
+ readonly horizonTintAmount: number;
414
+ /** Lightning brightness (layers take the max) */
415
+ readonly flash: number;
416
+ }
417
+
418
+ /** One layer of sky.modify: write only what to change, omitted items have no effect */
419
+ export interface SkyLayer {
420
+ /** Sunlight multiplier, default 1 */
421
+ sun?: number;
422
+ /** Ambient light multiplier, default 1 */
423
+ ambient?: number;
424
+ /** Fog distance multiplier, default 1 (smaller = denser fog) */
425
+ fog?: number;
426
+ /** Sky tint (color number or Color) */
427
+ tint?: Color | number;
428
+ /** Zenith tint amount 0–1, default 0 */
429
+ tintAmount?: number;
430
+ /** Horizon tint amount 0–1, default 0 */
431
+ horizonTintAmount?: number;
432
+ /** Lightning brightness, default 0 */
433
+ flash?: number;
434
+ /** Cover color laid over the foliage season tint (snow, ash, frost); null removes it. Rides the season patch, see recipes/47 */
435
+ foliageCover?: Color | number | null;
436
+ /** Cover color laid over the ground season tint */
437
+ groundCover?: Color | number | null;
438
+ /** How far toward the cover colors, 0–1, default 0 (style.weather.snow.cover drives the weather layer's from the snow amount) */
439
+ coverAmount?: number;
440
+ }
441
+
442
+ // Sky (engine.sky) is generated from the JSDoc in modules/sky/Sky.js (npm run map); only the types are re-exported here
443
+ import type { Sky } from './generated/modules/sky/Sky';
444
+ export type { Sky };
445
+
446
+ // ======================================================================
447
+ // Weather weather()
448
+ // ======================================================================
449
+
450
+ /** Weather preset: intensities of about 0–1 */
451
+ export interface WeatherPreset {
452
+ /** Cloud cover 0–1 */
453
+ cloud: number;
454
+ /** Sunlight multiplier */
455
+ sun: number;
456
+ /** Fog distance multiplier (smaller = denser fog) */
457
+ fog: number;
458
+ /** Wind multiplier */
459
+ wind: number;
460
+ /** Rain amount 0–1 */
461
+ rain: number;
462
+ /** Snow amount 0–1 */
463
+ snow: number;
464
+ /** How gray the sky turns 0–1 */
465
+ grey: number;
466
+ /** Thunder: above 0.5 it thunders */
467
+ lightning: number;
468
+ }
469
+ /** A weather name from the game's table (weather() alone has only 'clear'; presets.weather.temperate brings seven) */
470
+ export type WeatherName = string;
471
+
472
+ export interface WeatherOptions {
473
+ /** Starting weather, default 'clear' (or the first of the game's types when it has no 'clear') */
474
+ start?: WeatherName;
475
+ /** Automatic weather changes */
476
+ auto?: boolean;
477
+ /** Rain / snow particle count, default 6000 */
478
+ particles?: number;
479
+ /** 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 */
480
+ types?: Record<string, Partial<WeatherPreset> & Record<string, number>>;
481
+ /** Candidates for automatic changes (repeat an entry for higher probability) */
482
+ autoPool?: string[];
483
+ /** Interval between automatic changes [shortest, longest] seconds */
484
+ autoInterval?: number[];
485
+ /** Transition seconds of automatic changes, default 25 */
486
+ transition?: number;
487
+ /** Rain / snow coverage (meters) */
488
+ area?: number;
489
+ }
490
+
491
+ // Weather (engine.weather) is generated from the JSDoc in modules/weather/Weather.js (npm run map); only the types are re-exported here
492
+ import type { Weather } from './generated/modules/weather/Weather';
493
+ export type { Weather };
494
+
495
+ // ======================================================================
496
+ // Water water()
497
+ // ======================================================================
498
+
499
+ /**
500
+ * Parameters of engine.addWaterBody(): position center, level water surface height (meters); give radius for a circle, halfWidth / halfDepth for a
501
+ * rectangle
502
+ */
503
+ export interface WaterBodyOptions {
504
+ position: PositionLike;
505
+ level: number;
506
+ radius?: number;
507
+ halfWidth?: number;
508
+ halfDepth?: number;
509
+ }
510
+ /**
511
+ * A standalone body of water (stored in engine.waterBodies and given by the water:add event, already converted): circle { x, z, radius, level } or
512
+ * rectangle { x, z, hw, hd, level } (meters)
513
+ */
514
+ export interface WaterBody {
515
+ /** Center position (meters) */
516
+ x: number; z: number;
517
+ /** Water surface height (meters) */
518
+ level: number;
519
+ /** Radius of a circular body (meters) */
520
+ radius?: number;
521
+ /** Half width and half depth of a rectangular body (meters) */
522
+ hw?: number; hd?: number;
523
+ }
524
+
525
+ export interface WaterOptions {
526
+ /** false: do not draw the global water surface (sea) */
527
+ sea?: boolean;
528
+ /** Global water level (meters); if omitted, the terrain's water level is used */
529
+ level?: number;
530
+ color?: ColorLike;
531
+ opacity?: number;
532
+ flat?: boolean;
533
+ waveHeight?: number;
534
+ waveScale?: number;
535
+ waveSpeed?: number;
536
+ fresnel?: number;
537
+ size?: number;
538
+ segments?: number;
539
+ normalMap?: string;
540
+ normalScale?: number;
541
+ normalRepeat?: number;
542
+ normalSpeed?: number[];
543
+ shininess?: number;
544
+ specular?: ColorLike;
545
+ /** Replace the whole surface material, same as style.water.material */
546
+ material?: import('./style').StyleWater['material'];
547
+ depthColor?: import('./style').StyleWater['depthColor'];
548
+ foam?: import('./style').StyleWater['foam'];
549
+ glsl?: import('./style').StyleWater['glsl'];
550
+ uniforms?: import('./style').StyleWater['uniforms'];
551
+ }
552
+
553
+ // Water (engine.water) is generated from the JSDoc in modules/water/Water.js (npm run map); only the types are re-exported here
554
+ import type { Water } from './generated/modules/water/Water';
555
+ export type { Water };
556
+
557
+ // ======================================================================
558
+ // Module factories
559
+ // ======================================================================
560
+
561
+ // ======================================================================
562
+ // Distant merging hlod()
563
+ // ======================================================================
564
+
565
+ /** Parameters of hlod() (also the defaults of add()) */
566
+ export interface HlodOptions {
567
+ /** Handle levels automatically (adds the level on level:loaded), default true */
568
+ level?: boolean;
569
+ /** Merge cell edge length (meters), default 64 */
570
+ cell?: number;
571
+ /** Beyond this distance (meters) the merged proxy is shown, default 160 */
572
+ near?: number;
573
+ /** Proxy casts shadows, default false */
574
+ castShadow?: boolean;
575
+ /** Which meshes to merge (return false to skip) */
576
+ include?: (mesh: Object3D) => boolean;
577
+ }
578
+ /** Parameters of hlod.add() */
579
+ export interface HlodAddOptions {
580
+ cell?: number;
581
+ near?: number;
582
+ castShadow?: boolean;
583
+ /** Which meshes to merge (return false to skip) */
584
+ include?: (mesh: Object3D) => boolean;
585
+ }
586
+ /** One merged cell: proxy is the merged proxy meshes, originals the original objects */
587
+ export interface HlodCell {
588
+ /** Cell key 'x,z' */
589
+ key: string;
590
+ /** Merged proxy meshes (one per material) */
591
+ proxy: Object3D[];
592
+ /** Originals */
593
+ originals: Object3D[];
594
+ /** Average center of the originals (for distance) */
595
+ center: Vector3;
596
+ /** The proxy is currently shown */
597
+ far: boolean;
598
+ }
599
+ /** Handle returned by hlod.add() */
600
+ export interface HlodHandle {
601
+ cells: HlodCell[];
602
+ /** Beyond this distance (meters) the proxy is shown */
603
+ near: number;
604
+ /** Are all proxies merged (done over several frames) */
605
+ readonly ready: boolean;
606
+ /** Promise that resolves when merging is done: await h.whenReady */
607
+ whenReady: Promise<HlodHandle>;
608
+ /** Cancel: restore the originals, free the proxies */
609
+ remove(): void;
610
+ }
611
+ /** engine.hlod: merge a patch of distant objects into a few meshes to cut draw calls @experimental */
612
+ export interface Hlod {
613
+ /** All merged cells */
614
+ cells: HlodCell[];
615
+ /** Register a group of objects (a root or an array), merged into proxies by cell */
616
+ add(target: Object3D | Object3D[], opts?: HlodAddOptions): HlodHandle;
617
+ }
618
+
619
+ // ======================================================================
620
+ // Light pool engine.lightPool (lightPool() module)
621
+ // ======================================================================
622
+
623
+ /** Parameters of lightPool(): how many real lights exist (fixed for the whole game, so shaders never recompile) */
624
+ export interface LightPoolOptions {
625
+ /** Real PointLights, default 8 */
626
+ point?: number;
627
+ /** Real SpotLights, default 0 (sources added with type: 'spot' use them) */
628
+ spot?: number;
629
+ /** How many of the point lights cast shadows, default 0; only sources added with castShadow: true get them */
630
+ shadows?: number;
631
+ /** Seconds between choosing which sources get the lights, default 0.1 (fading and following run every frame) */
632
+ every?: number;
633
+ /** Seconds a light takes to fade in or out when it moves to another source, default 0.3 */
634
+ fade?: number;
635
+ /** Measure distance from this object / position instead of the camera (e.g. the player in a top-down game) */
636
+ focus?: PositionLike | null;
637
+ }
638
+ /** Options of lightPool.add(position, opts): one light source (a torch, lamp, campfire, muzzle flash...) */
639
+ export interface LightSourceOptions {
640
+ /** Name shown in lightPool.usage() */
641
+ name?: string;
642
+ /** 'point' (default) or 'spot' (needs lightPool({ spot: n })) */
643
+ type?: 'point' | 'spot';
644
+ /** Light color, default white */
645
+ color?: ColorLike;
646
+ /** three.js intensity at full strength, default 1; 0 = off (it gives its light away) */
647
+ intensity?: number;
648
+ /** three.js light distance (range, meters), default 10; also the scale of the distance score */
649
+ distance?: number;
650
+ /** three.js decay, default 2 */
651
+ decay?: number;
652
+ /** Weight in the choice, default 1: 3 = picked over a 1 three times as bright at the same distance (a quest lamp, a muzzle flash) */
653
+ priority?: number;
654
+ /** May take one of the shadow-casting lights (lightPool({ shadows })), default false; fixed when added */
655
+ castShadow?: boolean;
656
+ /** Spot cone half-angle (radians), default PI / 4 */
657
+ angle?: number;
658
+ /** Spot penumbra 0-1, default 0.3 */
659
+ penumbra?: number;
660
+ /** Spot aim: a position or an Object3D it follows; default straight down */
661
+ target?: PositionLike | null;
662
+ /** Brightness factor each frame (time = presentation seconds, index = the source's number): (t, i) => 0.85 + 0.15 * Math.sin(t * 13 + i) */
663
+ flicker?: ((time: number, index: number) => number) | null;
664
+ /**
665
+ * Stand-in shown while the source has no real light: a halo Sprite / Mesh (its material's opacity) or an emissive material (emissiveIntensity) scaled
666
+ * from its value at add() down to 0 as the real light fades in. Give each source its own material
667
+ */
668
+ glow?: Material | Object3D | null;
669
+ }
670
+ /** What lightPool.add().set(patch) can change (type and castShadow are fixed when added) */
671
+ export interface LightSourcePatch {
672
+ /** New position, or an Object3D to follow */
673
+ position?: PositionLike;
674
+ name?: string;
675
+ color?: ColorLike;
676
+ intensity?: number;
677
+ distance?: number;
678
+ decay?: number;
679
+ priority?: number;
680
+ angle?: number;
681
+ penumbra?: number;
682
+ target?: PositionLike | null;
683
+ flicker?: ((time: number, index: number) => number) | null;
684
+ glow?: Material | Object3D | null;
685
+ }
686
+ /** Handle returned by lightPool.add() */
687
+ export interface LightSource {
688
+ /** The real light lighting this source now, null while it has none */
689
+ readonly light: Object3D | null;
690
+ /** How much of its light it has now, 0-1 */
691
+ readonly weight: number;
692
+ /** Change the source; returns the same handle */
693
+ set(patch: LightSourcePatch): LightSource;
694
+ /** Unregister: its light fades out and moves on, the stand-in is put back (safe to call twice) */
695
+ remove(): void;
696
+ }
697
+ /** lightPool.usage(): what the pool is doing now */
698
+ export interface LightPoolUsage {
699
+ /** Registered sources */
700
+ sources: number;
701
+ /** Real lights lighting a source now */
702
+ lit: number;
703
+ /** One per real light: its kind, whether it casts shadows, the source it holds (name or number, null = idle) and its fade 0-1 */
704
+ slots: { type: 'point' | 'spot'; shadow: boolean; source: string | number | null; weight: number }[];
705
+ }
706
+ /** engine.lightPool: register any number of light sources; a fixed set of real lights moves to the most relevant ones */
707
+ export interface LightPool {
708
+ /** The real three.js lights, created once at install and never added, removed or hidden (the pool sets their position, color, intensity) */
709
+ readonly lights: Object3D[];
710
+ /** Distance is measured from this object / position; null = the camera */
711
+ focus: PositionLike | null;
712
+ /**
713
+ * Register a light source at a position (an Object3D: it follows that object every frame)
714
+ * @example
715
+ * const torch = engine.lightPool.add(torchMesh, { color: 0xffa040, intensity: 4, distance: 8, glow: haloSprite });
716
+ * torch.set({ intensity: 0 }); // put out: its light goes to another torch
717
+ */
718
+ add(position: PositionLike, opts?: LightSourceOptions): LightSource;
719
+ /** What the pool is doing now (also in describe().lightPool) */
720
+ usage(): LightPoolUsage;
721
+ }
722
+
723
+ // ======================================================================
724
+ // Performance budget engine.budget (core, off by default)
725
+ // ======================================================================
726
+
727
+ /** Budget limits: only the given categories are checked. fps/low1 are lower bounds (frame rate must not drop below), the rest are upper bounds */
728
+ export interface BudgetLimits {
729
+ /** Draw calls */
730
+ drawCalls?: number;
731
+ /** Average frame rate (lower bound) */
732
+ fps?: number;
733
+ /** Worst 1% frame rate (lower bound) */
734
+ low1?: number;
735
+ /** CPU milliseconds per frame */
736
+ cpuMs?: number;
737
+ /** Triangle count */
738
+ triangles?: number;
739
+ /** Texture count */
740
+ textures?: number;
741
+ /** Terrain chunk upload milliseconds per frame */
742
+ chunkApplyMs?: number;
743
+ /** Rigid body count */
744
+ rigidBodies?: number;
745
+ /** Per-frame cost of applying background results, by stage (engine.budget.cost): worker transit (approximate), creating three.js objects, colliders, GPU upload (approximate), stream build() */
746
+ applyTransitMs?: number;
747
+ applyBuildMs?: number;
748
+ applyColliderMs?: number;
749
+ applyUploadMs?: number;
750
+ applyStreamMs?: number;
751
+ /** Time from opening to playable (milliseconds); when exceeded, the slowest module is named */
752
+ startupMs?: number;
753
+ /** Single module startup (init + wait for ready, milliseconds); when exceeded, that module is named */
754
+ moduleMs?: number;
755
+ /** Custom module categories (registered via budget.metric) */
756
+ [metric: string]: number | undefined;
757
+ }
758
+ /** One overrun: top is the biggest draw-call contributors grouped by userData.budgetTag */
759
+ export interface BudgetOver { category: string; value: number; limit: number; top: BudgetTagStat[] }
760
+ /** A category estimated by userData.budgetTag: 'terrain', 'vegetation', 'hlod', 'sky', 'weather', untagged 'other'… */
761
+ export interface BudgetTagStat { tag: string; drawCalls: number; triangles: number }
762
+ /** Budget report: ok means everything is within budget */
763
+ export interface BudgetReport { ok: boolean; over: BudgetOver[] }
764
+ // Budget (engine.budget) is generated from the JSDoc in core/Budget.js (npm run map); only the types are re-exported here
765
+ import type { Budget } from './generated/core/Budget';
766
+ export type { Budget };
767
+
768
+ export type TerrainModule = ModuleDef<Terrain>;
769
+ export type VegetationModule = ModuleDef<Vegetation>;
770
+ export type SkyModule = ModuleDef<Sky>;
771
+ export type WeatherModule = ModuleDef<Weather>;
772
+ export type WaterModule = ModuleDef<Water>;