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,242 @@
1
+ // Generated by npm run map, do not edit by hand. Source: packages/engine/modules/world/World.js (edit the JSDoc in the source, then run npm run map)
2
+ /** World data (see the top of the file) */
3
+ export class World {
4
+ /**
5
+ * @param {any} engine
6
+ * @param {{ cellSize?: number, radius?: number, farEvery?: number, farMaxPerTick?: number, buildPerFrame?: number }} [opts]
7
+ */
8
+ constructor(engine: any, opts?: {
9
+ cellSize?: number;
10
+ radius?: number;
11
+ farEvery?: number;
12
+ farMaxPerTick?: number;
13
+ buildPerFrame?: number;
14
+ });
15
+ /** All records: id → record (read-only; use set to change fields, move to change position) @type {Map<string, WorldRecord>} */
16
+ records: Map<string, WorldRecord>;
17
+ /**
18
+ * Default distance (meters) for building models and counting as near; present / simulate can override it. Changing it at runtime affects those without
19
+ * their own radius @type {number}
20
+ */
21
+ radius: number;
22
+ /** Default interval (seconds) between far simulations, same unit as dt @type {number} */
23
+ farEvery: number;
24
+ /**
25
+ * Max far simulations per fixed step; the rest queue for the next step (dt accumulates, no time is lost). Counted by records, not milliseconds, so results
26
+ * do not depend on machine speed @type {number}
27
+ */
28
+ farMaxPerTick: number;
29
+ /** Max models built per frame; the rest continue next frame (ready waits for all of them; loading is not limited) @type {number} */
30
+ buildPerFrame: number;
31
+ set anchor(a: any);
32
+ /**
33
+ * Gameplay simulation center (near / far is measured from it): null (default) = where engine.actor is (engine.actorPosition(): the player, or engine.focus
34
+ * when there is no player). The built-in stream source engine.stream.player follows the player too (models and colliders around it); the camera source
35
+ * engine.stream.camera adds models only.
36
+ * For another center (a strategy game's base) set a Vector3 / object / { x, z } / [x, y, z]; set null to restore. Read once at the start of each fixed step
37
+ * @example engine.world.anchor = baseObject
38
+ * @type {any}
39
+ */
40
+ get anchor(): any;
41
+ set zone(z: string | null);
42
+ /**
43
+ * Current zone (e.g. level name, set by the level module on level change): once set, records of another zone get no model and no near simulation; null = no
44
+ * zoning @type {string | null}
45
+ */
46
+ get zone(): string | null;
47
+ /**
48
+ * Add a record and return it (a plain object). kind is required; without id one is numbered automatically (kind#1, kind#2…, saved; `#` never appears in an
49
+ * authored id, so the two can never collide).
50
+ * opts.initial: initial record written in content (needs an id); saves only keep its changes and removal; if the id already exists the existing one is
51
+ * returned (content may load twice);
52
+ * returns null if the save removed it (it is not added back). opts.save: false: not saved (temporary things).
53
+ * @example engine.world.add({ id: 'shop_owner', kind: 'npc', position: [12, 0, -30], name: '店主', mood: 'calm' }, { initial: true })
54
+ * @param {{ kind: string, id?: string, position?: any, [field: string]: any }} def
55
+ * @param {{ initial?: boolean, save?: boolean }} [opts]
56
+ * @returns {WorldRecord | null}
57
+ */
58
+ add(def: {
59
+ kind: string;
60
+ id?: string;
61
+ position?: any;
62
+ [field: string]: any;
63
+ }, opts?: {
64
+ initial?: boolean;
65
+ save?: boolean;
66
+ }): WorldRecord | null;
67
+ /**
68
+ * Where a record comes from (filled in dev and test builds; null in release): { definedAt: 'content/props.js:14' } for a content entry,
69
+ * { level, node } for a level-model node, { template } when it is a template instance, { spawned: { op, tick } } for a record created during play.
70
+ * engine.inspect(id) and engine.pick(...).thing show it, so you know which file to edit to change the level for good.
71
+ * @example engine.world.origin('chest-home') // { definedAt: 'content/props.js:14', template: 'chest' }
72
+ * @param {string} id
73
+ * @returns {{ definedAt?: string, level?: string, node?: string, template?: string, spawned?: { op: string | null, tick: number } } | null}
74
+ */
75
+ origin(id: string): {
76
+ definedAt?: string;
77
+ level?: string;
78
+ node?: string;
79
+ template?: string;
80
+ spawned?: {
81
+ op: string | null;
82
+ tick: number;
83
+ };
84
+ } | null;
85
+ /**
86
+ * The id of the record whose model contains obj (obj itself or one of its parents is a built model), else null. A ray hit on a model names its record this
87
+ * way.
88
+ * @example const h = engine.pick(0, 0); const id = h && engine.world.idOf(h.object);
89
+ * @param {any} obj a THREE.Object3D (a mesh of the model is fine)
90
+ * @returns {string | null}
91
+ */
92
+ idOf(obj: any): string | null;
93
+ /**
94
+ * Get a record by id (undefined if missing, like a Map)
95
+ * @param {string} id
96
+ * @returns {WorldRecord | undefined}
97
+ */
98
+ get(id: string): WorldRecord | undefined;
99
+ /**
100
+ * Merge fields into a record and emit the world:change event; a position in patch also moves it. Returns the record.
101
+ * For discrete changes (chest opened, growth stage, picked up); if present has show, it is re-evaluated after the change. id / kind cannot be changed
102
+ * @example engine.world.set('crate_1', { opened: true })
103
+ * @param {string} id
104
+ * @param {Record<string, any>} patch
105
+ * @returns {WorldRecord}
106
+ */
107
+ set(id: string, patch: Record<string, any>): WorldRecord;
108
+ /**
109
+ * Move a record (no event; use it in simulate for things that move every step); still saved (saves diff against content).
110
+ * The model of a positionFrom 'record' (default) record follows this frame; to do something else with the position in presentation, compare in update
111
+ * @example engine.world.move(rec.id, { x: rec.position.x + 1, z: rec.position.z })
112
+ * @param {string} id
113
+ * @param {any} position Vector3 / object / [x, y, z] / { x, z } (y stays unchanged if omitted)
114
+ * @returns {void}
115
+ */
116
+ move(id: string, position: any): void;
117
+ /**
118
+ * Remove a record (its model is torn down too) and emit the world:remove event. Does nothing if the id does not exist. Removing an initial record is saved,
119
+ * so it stays gone after loading
120
+ * @param {string} id
121
+ * @returns {void}
122
+ */
123
+ remove(id: string): void;
124
+ /**
125
+ * Query records; returns an array. With near only nearby cells are scanned and results are sorted nearest first (radius defaults to 30 m); where filters
126
+ * further. For neighbor queries every step use forEachNear
127
+ * @example engine.world.query({ kind: 'zombie', near: engine.player, radius: 30, where: z => !z.dead })
128
+ * @param {{ kind?: string, near?: any, radius?: number, where?: (rec: WorldRecord) => boolean, zone?: string | null }} [opts]
129
+ * @returns {WorldRecord[]}
130
+ */
131
+ query(opts?: {
132
+ kind?: string;
133
+ near?: any;
134
+ radius?: number;
135
+ where?: (rec: WorldRecord) => boolean;
136
+ zone?: string | null;
137
+ }): WorldRecord[];
138
+ /**
139
+ * Call fn(rec, d2) for each record within radius meters (horizontal distance) of center; d2 is the squared distance. Unsorted, no allocation: use it for
140
+ * per-step neighbor queries (hundreds of zombies avoiding each other).
141
+ * Don't add / remove / move in the callback (moving into a cell not yet visited visits it again): record the change and apply it after the loop
142
+ * @example engine.world.forEachNear(rec.position, 5, (o, d2) => { if (o !== rec && o.kind === 'zombie') n++; })
143
+ * @param {any} center Vector3 / object / { x, z }
144
+ * @param {number} radius
145
+ * @param {(rec: WorldRecord, d2: number) => void} fn
146
+ * @returns {void}
147
+ */
148
+ forEachNear(center: any, radius: number, fn: (rec: WorldRecord, d2: number) => void): void;
149
+ /**
150
+ * Register how a kind of thing looks: models are built automatically within radius meters of any full-detail stream source (engine.stream: player, camera
151
+ * focus, teleport destination) and torn down when far from all of them (radius × 1.25); tearing down never touches the record. Callbacks:
152
+ * build(rec) → three.js object (may be async). world adds it to the scene and places it at rec.position; if it throws / fails / returns a non-object:
153
+ * reported once, does not block ready, retried when you leave and come back.
154
+ * update(rec, obj, dt): called every frame for records that have a model (change the look from the data, e.g. an opened chest swaps texture).
155
+ * dispose(rec, obj): called on teardown (record first, model second); if omitted, engine.remove(obj).
156
+ * show(rec) → false: this record has no model right now (picked up, waiting to respawn); re-evaluated when world.set changes records of this kind.
157
+ * radius: meters, or a function (for distances that change, like terrain view distance); defaults to world.radius. Registering the same kind again: old
158
+ * models are torn down with the old dispose and rebuilt with the new one.
159
+ * positionFrom: 'record' (default, the model follows the record every frame) or 'view' (the model moves itself, e.g. driven by a character mover; model
160
+ * position is copied back to the record at the end of each fixed step).
161
+ * @example engine.world.present('chest', { build: rec => new THREE.Mesh(boxGeo, makeMaterial('prop')), dispose: (rec, obj) => engine.remove(obj), show: rec
162
+ * => !rec.looted })
163
+ * @param {string} kind
164
+ * @param {{ build: (rec: WorldRecord) => any, update?: (rec: WorldRecord, obj: any, dt: number) => void, dispose?: (rec: WorldRecord, obj: any) => void,
165
+ * show?: (rec: WorldRecord) => boolean, radius?: number | (() => number), positionFrom?: 'record' | 'view' }} opts
166
+ * @returns {{ remove(): void }}
167
+ */
168
+ present(kind: string, opts: {
169
+ build: (rec: WorldRecord) => any;
170
+ update?: (rec: WorldRecord, obj: any, dt: number) => void;
171
+ dispose?: (rec: WorldRecord, obj: any) => void;
172
+ show?: (rec: WorldRecord) => boolean;
173
+ radius?: number | (() => number);
174
+ positionFrom?: "record" | "view";
175
+ }): {
176
+ remove(): void;
177
+ };
178
+ /**
179
+ * The current model of this record (only exists nearby; null if not built yet or far away)
180
+ * @param {string} id
181
+ * @returns {any}
182
+ */
183
+ view(id: string): any;
184
+ /**
185
+ * All models that should exist near the stream sources are built (async ones too; failed builds do not count as pending). The loading screen waits for it; to
186
+ * wait yourself, await world.whenReady @type {boolean}
187
+ */
188
+ get ready(): boolean;
189
+ /** Promise that resolves when ready becomes true @type {Promise<void>} */
190
+ get whenReady(): Promise<void>;
191
+ /**
192
+ * Build / tear down models for the stream sources right now (normally automatic every frame, with a per-frame limit). Use it right after add when you need
193
+ * the model: sync builds are available via view(id) after the call, for async ones also await world.whenReady
194
+ * @example engine.world.add({ id: 'gate', kind: 'gate', position: p }); engine.world.refresh(); engine.world.view('gate')
195
+ * @returns {void}
196
+ */
197
+ refresh(): void;
198
+ /**
199
+ * Register how a kind of thing changes (gameplay logic goes here, runs in the fixed step); near / far is split by distance from world.anchor (default: the
200
+ * player):
201
+ * near(rec, dt, obj): within radius, once per fixed step (obj is the model, may be null if not built yet; gameplay must not depend on it);
202
+ * far(rec, dt): farther away, once every farEvery seconds; dt is the seconds accumulated since the last simulation (can catch up a long time at once); on the
203
+ * far → near step, far runs first to pay back the owed time.
204
+ * With only far (crops), near also advances via far; with only near, far records are not simulated and owed time is not made up.
205
+ * Both dt are accumulated fixed-step seconds (not multiplied by clock.timeScale). For things measured in game clock (grows over days) store engine.clock.now
206
+ * and compare.
207
+ * radius defaults to the present radius ('view' widened by 1.25), or world.radius without present; may also be a function.
208
+ * worker: true (experimental) runs far in engine.threads workers (batched per step, written back 4 steps later, bit-identical with threads off). far must
209
+ * then be self-contained:
210
+ * it is recompiled from source and sees only (rec, dt) and globals like Math; an outside variable throws naming it (threads on or off alike).
211
+ * @example engine.world.simulate('zombie', { near: (rec, dt) => chase(rec, dt), far: (rec, dt) => wander(rec, dt), farEvery: 2 })
212
+ * @example engine.world.simulate('crop', { far: (rec, dt) => { rec.growth = Math.min(1, rec.growth + dt / 600); }, worker: true })
213
+ * @param {string} kind
214
+ * @param {{ near?: (rec: WorldRecord, dt: number, obj: any) => void, far?: (rec: WorldRecord, dt: number) => void, farEvery?: number, radius?: number | (()
215
+ * => number), worker?: boolean }} opts
216
+ * @returns {{ remove(): void }}
217
+ */
218
+ simulate(kind: string, opts: {
219
+ near?: (rec: WorldRecord, dt: number, obj: any) => void;
220
+ far?: (rec: WorldRecord, dt: number) => void;
221
+ farEvery?: number;
222
+ radius?: number | (() => number);
223
+ worker?: boolean;
224
+ }): {
225
+ remove(): void;
226
+ };
227
+ /** Number of fixed steps simulated */ get steps(): number;
228
+ }
229
+ /**
230
+ * One world record: id, kind and position are fixed fields, the rest are yours (plain values only)
231
+ */
232
+ export type WorldRecord = {
233
+ id: string;
234
+ kind: string;
235
+ position: {
236
+ x: number;
237
+ y: number;
238
+ z: number;
239
+ };
240
+ zone?: string;
241
+ [field: string]: any;
242
+ };
@@ -0,0 +1,15 @@
1
+ // Generated by npm run map, do not edit by hand. Source: packages/engine/modules/world/index.js (edit the JSDoc in the source, then run npm run map)
2
+ /**
3
+ * 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
4
+ * @example engine.use(world())
5
+ * @param {{ cellSize?: number, radius?: number, farEvery?: number, farMaxPerTick?: number, buildPerFrame?: number }} [opts]
6
+ * @returns {import('../../../core').ModuleDef<World>}
7
+ */
8
+ export function world(opts?: {
9
+ cellSize?: number;
10
+ radius?: number;
11
+ farEvery?: number;
12
+ farMaxPerTick?: number;
13
+ buildPerFrame?: number;
14
+ }): import("../../../core").ModuleDef<World>;
15
+ import { World } from './World.js';
@@ -0,0 +1,125 @@
1
+ // Generated by npm run map, do not edit by hand. Source: packages/engine/render/PostFX.js (edit the JSDoc in the source, then run npm run map)
2
+ export class PostFX {
3
+ /**
4
+ * MSAA on (read-only; switch with post.setAntialias(on))
5
+ * @returns {boolean}
6
+ */
7
+ get antialias(): boolean;
8
+ /**
9
+ * Whether any post work runs (antialias or an enabled effect)
10
+ * @returns {boolean}
11
+ */
12
+ get active(): boolean;
13
+ /**
14
+ * Renamed in 0.2: throws and names the new call (engine.look.post.patch / engine.look.post.replace, recipes/52-look.md)
15
+ * @param {PostEffect} _effect
16
+ * @param {{ slot?: PostSlot, order?: number, enabled?: boolean }} [_opts]
17
+ * @returns {never}
18
+ * @experimental
19
+ */
20
+ add(_effect: PostEffect, _opts?: {
21
+ slot?: PostSlot;
22
+ order?: number;
23
+ enabled?: boolean;
24
+ }): never;
25
+ /**
26
+ * Read-only record of an added effect (name, slot, order, enabled, params), or undefined. Change one with engine.look.post.set({ 'bloom.strength': 0.6 })
27
+ * @param {string} name
28
+ * @returns {PostHandle | undefined}
29
+ * @experimental
30
+ */
31
+ get(name: string): PostHandle | undefined;
32
+ /**
33
+ * Renamed in 0.2: throws and names the new call (engine.look.post.set({ 'bloom.enabled': on }); MSAA: engine.post.setAntialias(on))
34
+ * @param {string} _name
35
+ * @param {boolean} _on
36
+ * @returns {never}
37
+ * @experimental
38
+ */
39
+ enable(_name: string, _on: boolean): never;
40
+ /**
41
+ * Turn MSAA (antialiasing of the post chain) on or off. It is a render target setting, not a look part.
42
+ * @example engine.post.setAntialias(false);
43
+ * @param {boolean} on
44
+ * @returns {void}
45
+ * @experimental
46
+ */
47
+ setAntialias(on: boolean): void;
48
+ /**
49
+ * Effects in render order: [{ name, slot, order, enabled }]
50
+ * @returns {{ name: string, slot: PostSlot, order: number, enabled: boolean }[]}
51
+ * @experimental
52
+ */
53
+ list(): {
54
+ name: string;
55
+ slot: PostSlot;
56
+ order: number;
57
+ enabled: boolean;
58
+ }[];
59
+ /** @param {number} w @param {number} h @returns {void} */
60
+ setSize(w: number, h: number): void;
61
+ /** @param {number} r @returns {void} */
62
+ setPixelRatio(r: number): void;
63
+ /** @param {number} dt @returns {void} */
64
+ render(dt: number): void;
65
+ }
66
+ /**
67
+ * scene: replaces the scene render (one at a time, e.g. a pixelating render); hdr: linear color before tone mapping (bloom, AO,
68
+ * outline); ldr: sRGB color after tone mapping (LUT, palette, grain, vignette); final: last of all (FXAA / SMAA).
69
+ */
70
+ export type PostSlot = "scene" | "hdr" | "ldr" | "final";
71
+ /**
72
+ * width / height are in device pixels.
73
+ */
74
+ export type PostContext = {
75
+ engine: Engine;
76
+ scene: import("three").Scene;
77
+ camera: import("three").Camera;
78
+ width: number;
79
+ height: number;
80
+ params: Record<string, any>;
81
+ };
82
+ /**
83
+ * A GLSL snippet that colors the pixel; neighboring effects with a fuse run as ONE fullscreen pass. glsl is statements that edit
84
+ * `vec4 color` (the input pixel so far) and may use vUv, tDiffuse, uTime (s), uResolution (device px) and fxHash(vec2). uniforms
85
+ * declares extra ones by GLSL type ({ uVigStrength: 'float' }; names must be unique across effects, prefix with the effect name);
86
+ * values(params) returns their current values. reads: true when the snippet samples tDiffuse at other uvs (blur, color fringe):
87
+ * it then starts a new group, so it sees the real input.
88
+ */
89
+ export type PostFuse = {
90
+ uniforms?: Record<string, string>;
91
+ values?: (params: Record<string, any>) => Record<string, any>;
92
+ glsl: string;
93
+ reads?: boolean;
94
+ };
95
+ /**
96
+ * create: builds the implementation the first time the effect is on (WebGL: a three.js postprocessing Pass); optional when fuse is given.
97
+ * fuse: see PostFuse; effects with a fuse in the same slot next to each other are merged (never in slot 'scene'), their params
98
+ * update in place (no update() needed).
99
+ * order: position inside the slot, low first (ties keep add order). costly: off by default on low-tier devices.
100
+ * needsDepth: the scene's depth texture is kept for it (readBuffer.depthTexture). Only the buffer the scene render wrote holds
101
+ * scene depth, so a depth reader must run before any pass that swaps buffers (needsSwap, e.g. a ShaderPass, a scene-slot
102
+ * RenderPixelatedPass, or the tone-mapping output); the chain throws when it would not. A pass that writes the scene depth into its own output (gl_FragDepth, then set pass.keepsDepth = true; dof does) does not count as a swap. update: apply new params in place;
103
+ * without it set() rebuilds the implementation.
104
+ */
105
+ export type PostEffect = {
106
+ name: string;
107
+ create?: (ctx: PostContext) => object;
108
+ fuse?: PostFuse;
109
+ slot?: PostSlot;
110
+ order?: number;
111
+ enabled?: boolean;
112
+ costly?: boolean;
113
+ needsDepth?: boolean;
114
+ params?: Record<string, any>;
115
+ update?: (impl: any, params: Record<string, any>) => void;
116
+ };
117
+ export type PostHandle = {
118
+ readonly name: string;
119
+ readonly slot: PostSlot;
120
+ readonly order: number;
121
+ readonly enabled: boolean;
122
+ readonly params: Record<string, any>;
123
+ };
124
+ import type { Engine } from '../../core';
125
+ import * as THREE from 'three';
@@ -0,0 +1,100 @@
1
+ // Generated by npm run map, do not edit by hand. Source: packages/engine/render/materials.js (edit the JSDoc in the source, then run npm run map)
2
+
3
+ /**
4
+ * Create a material by role: makeMaterial('furniture', { color: 0x8a5a36 }); the look comes from the style pack's materials[role] (unlisted roles use materials.default).
5
+ * Roles the engine uses: default terrain vegetation character water pickup prop (MATERIAL_PURPOSES); a game may pick new names (e.g. 'building'),
6
+ * and a name close to an existing role ('props', 'charcter') warns in dev.
7
+ * A style pack entry has one of three forms; params are then applied to the result (keys the material lacks are skipped):
8
+ * @example
9
+ * materials: {
10
+ * default: { type: 'toon', steps: 3 }, // spec: type lambert | phong | standard | physical | toon | basic, plus properties
11
+ * water: new THREE.MeshMatcapMaterial({ matcap: tex }), // instance: cloned on every call
12
+ * prop: (params, purpose, engine) => new THREE.ShaderMaterial({ ... }), // function: returns any three.js Material
13
+ * }
14
+ * A pack Material instance is cloned with its shader patches (applyEffects) kept.
15
+ * Whose style pack decides: engine.makeMaterial(purpose, params) (this engine's) or the third argument; without either the first live engine's
16
+ * (fine for a one-engine game; engine code and style packs always pass the engine, and two engines on the page warn in dev).
17
+ * @param {string} [purpose]
18
+ * @param {{ color?: ColorLike, [prop: string]: any }} [params]
19
+ * @param {{ style: any }} [engine]
20
+ * @returns {Material}
21
+ */
22
+ export function makeMaterial(purpose?: string, params?: {
23
+ color?: ColorLike;
24
+ [prop: string]: any;
25
+ }, engine?: {
26
+ style: any;
27
+ }): THREE.Material;
28
+ export function windCustom({ glsl, uniforms }: {
29
+ glsl: any;
30
+ uniforms: any;
31
+ }): {
32
+ uniforms: Record<string, {
33
+ value: any;
34
+ }>;
35
+ decl: string;
36
+ glsl: any;
37
+ };
38
+ /**
39
+ * Add effects to any material (built-in, from a style pack, or third-party); returns the same material. The one entry for shader effects:
40
+ * wind (sway amplitude; the shadow sways too, nothing else to set up), clouds (drifting cloud shadows, default on; how dark is
41
+ * style.clouds.shadow), season ('foliage' | 'ground' seasonal tint), and patches: your own named patches (see ShaderPatch in
42
+ * render/patches.js), detail (grain / paper / strokes / a texture over the surface, see MaterialDetail in types/style.d.ts; a texture given by
43
+ * 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
44
+ * patches that lists it in needs.patches.
45
+ * Built-in effects the material cannot take (MeshBasicMaterial has no lighting chunk for clouds) are skipped with a one-time warning;
46
+ * your own patches throw when their anchor is missing. Calling again with the same effect replaces it.
47
+ * @example
48
+ * applyEffects(new THREE.MeshToonMaterial({ color: 0x5a8a3a }), { wind: 0.03, season: 'foliage' });
49
+ * applyEffects(mat, { clouds: false, patches: [{ name: 'snap', cacheKey: 64, uniforms: { uGrid: { value: 64 } },
50
+ * glsl: { vertex: { pars: 'uniform float uGrid;', project_vertex: 'gl_Position.xy = floor(gl_Position.xy / gl_Position.w * uGrid) / uGrid * gl_Position.w;' } } }] });
51
+ * @param {Material} material
52
+ * @param {{ wind?: number | { amplitude: number, glsl: string, uniforms?: Record<string, any> }, clouds?: boolean, season?: 'foliage' | 'ground', detail?: import('../../../render/detail').DetailOptions, engine?: { assets: any }, patches?: import('./patches.js').ShaderPatch[] }} [opts]
53
+ * @returns {Material}
54
+ */
55
+ export function applyEffects(material: THREE.Material, { wind, clouds, season, detail, engine, patches }?: {
56
+ wind?: number | {
57
+ amplitude: number;
58
+ glsl: string;
59
+ uniforms?: Record<string, any>;
60
+ };
61
+ clouds?: boolean;
62
+ season?: "foliage" | "ground";
63
+ detail?: import("../../../render/detail").DetailOptions;
64
+ engine?: {
65
+ assets: any;
66
+ };
67
+ patches?: import("./patches.js").ShaderPatch[];
68
+ }): THREE.Material;
69
+ /**
70
+ * Terrain material: base (default the style's 'terrain' role with vertex colors) + cloud shadows + season tint + optional detail texture
71
+ * (style.terrain.detail). Pass the engine so its style pack and assets are used.
72
+ * @param {Material | null} [base]
73
+ * @param {{ style: any, assets: any }} [engine]
74
+ * @returns {Material}
75
+ */
76
+ export function terrainMaterial(base?: THREE.Material | null, engine?: {
77
+ style: any;
78
+ assets: any;
79
+ }): THREE.Material;
80
+ /**
81
+ * Merge several geometries into one vertex-colored geometry (a tree = trunk + canopy in one draw call): [[geometry, color], ...].
82
+ * flat (default true): one normal per triangle, the faceted low-poly look; false keeps each part's own (smooth) normals.
83
+ * UVs are kept when every part has them, so the merged model can still take a texture.
84
+ * @example
85
+ * const trunk = new THREE.CylinderGeometry(0.2, 0.3, 2).translate(0, 1, 0), crown = new THREE.SphereGeometry(1.2).translate(0, 2.6, 0);
86
+ * const tree = mergeColored([[trunk, 0x7a5536], [crown, 0x4c8a3b]], { flat: false }); // smooth crown
87
+ * @param {[BufferGeometry, ColorLike][]} parts
88
+ * @param {{ flat?: boolean }} [opts]
89
+ * @returns {BufferGeometry}
90
+ */
91
+ export function mergeColored(parts: [THREE.BufferGeometry, ColorLike][], { flat }?: {
92
+ flat?: boolean;
93
+ }): THREE.BufferGeometry;
94
+ /**
95
+ * Material roles the engine itself uses
96
+ * @type {string[]}
97
+ */
98
+ export const MATERIAL_PURPOSES: string[];
99
+ import type { ColorLike } from '../../common';
100
+ import * as THREE from 'three';
@@ -0,0 +1,41 @@
1
+ // Generated by npm run map, do not edit by hand. Source: packages/engine/render/patches.js (edit the JSDoc in the source, then run npm run map)
2
+
3
+ /**
4
+ * Names of the patches on a material (in order), e.g. ['clouds', 'tint', 'wind']
5
+ * @param {Material} material
6
+ * @returns {string[]}
7
+ */
8
+ export function materialPatches(material: THREE.Material): string[];
9
+ /**
10
+ * code for one anchor (a plain string goes after the include;
11
+ * replace swaps the include itself for new code, one patch per anchor)
12
+ */
13
+ export type PatchCode = {
14
+ before?: string;
15
+ after?: string;
16
+ replace?: string;
17
+ } | string;
18
+ /**
19
+ * glsl.vertex / glsl.fragment: anchor chunk name -> code; the key `pars` is declarations placed at the top of the shader.
20
+ * shadow: the patch moves vertices, so the depth and point-light distance passes run its vertex code too.
21
+ * needs.data: program inputs read, e.g. ['instancing']; needs.patches: patches it builds on, e.g. ['world'] (the vThreedogWorld varying).
22
+ * conflicts: patch names it cannot be combined with. cacheKey: changes whenever the GLSL text changes (see the header).
23
+ */
24
+ export type ShaderPatch = {
25
+ name: string;
26
+ cacheKey?: string | number;
27
+ uniforms?: Record<string, {
28
+ value: any;
29
+ }>;
30
+ shadow?: boolean;
31
+ needs?: {
32
+ data?: string[];
33
+ patches?: string[];
34
+ };
35
+ conflicts?: string[];
36
+ glsl?: {
37
+ vertex?: Record<string, PatchCode>;
38
+ fragment?: Record<string, PatchCode>;
39
+ };
40
+ };
41
+ import * as THREE from 'three';
@@ -0,0 +1,11 @@
1
+ // Generated by npm run map, do not edit by hand. Source: packages/engine/ui/Focus.js (edit the JSDoc in the source, then run npm run map)
2
+ /** @import { Engine } from '../../core' */
3
+ /** @import { UIFocus } from '../../gameplay' */
4
+ /**
5
+ * 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
6
+ * @param {Engine} engine
7
+ * @returns {UIFocus}
8
+ */
9
+ export function uiFocus(engine: Engine): UIFocus;
10
+ import type { Engine } from '../../core';
11
+ import type { UIFocus } from '../../gameplay';
@@ -0,0 +1,2 @@
1
+ // Generated by npm run map, do not edit by hand. Source: packages/engine/ui/LoadingScreen.js (edit the JSDoc in the source, then run npm run map)
2
+
@@ -0,0 +1,57 @@
1
+ // Generated by npm run map, do not edit by hand. Source: packages/engine/ui/UI.js (edit the JSDoc in the source, then run npm run map)
2
+
3
+ /**
4
+ * 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
5
+ * or turns it off with createEngine({ ui: { toast: false } }). kind says where it came from: 'info' (default), 'quest', 'item', 'save', 'error'.
6
+ * @param {Engine} engine
7
+ * @param {string} text
8
+ * @param {{ kind?: string, ms?: number }} [opts] ms default 2600
9
+ * @returns {void}
10
+ * @example toast(engine, 'Saved', { kind: 'save' })
11
+ */
12
+ export function toast(engine: Engine, text: string, { kind, ms }?: {
13
+ kind?: string;
14
+ ms?: number;
15
+ }): void;
16
+ /**
17
+ * A toggleable window
18
+ * @param {Engine} engine
19
+ * @param {WindowOptions} opts
20
+ * @returns {UIWindow}
21
+ */
22
+ export function makeWindow(engine: Engine, opts: WindowOptions): UIWindow;
23
+ /**
24
+ * Window toggle key: call once per frame in a frame hook; opens on the action when closed, closes on another press when open
25
+ * @param {Engine} engine
26
+ * @param {{ open: boolean, toggle(on?: boolean): void }} win a makeWindow window or any handle with open / toggle
27
+ * @param {string} action
28
+ * @returns {void}
29
+ */
30
+ export function toggleOnKey(engine: Engine, win: {
31
+ open: boolean;
32
+ toggle(on?: boolean): void;
33
+ }, action: string): void;
34
+ /**
35
+ * 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)
36
+ * @param {Engine} engine
37
+ * @param {PositionLike} pos
38
+ * @returns {ScreenPoint}
39
+ */
40
+ export function worldToScreen(engine: Engine, pos: PositionLike): ScreenPoint;
41
+ /**
42
+ * Fade the whole screen to `to` (0 clear ... 1 fully covered) over `seconds` (default 0.5); the Promise resolves when the fade ends
43
+ * @param {Engine} engine
44
+ * @param {number} to 0 clear ... 1 fully covered
45
+ * @param {number} [seconds] default 0.5
46
+ * @returns {Promise<void>}
47
+ */
48
+ export function fadeScreen(engine: Engine, to: number, seconds?: number): Promise<void>;
49
+ export function iconHTML(def: any): string;
50
+ import type { Engine } from '../../core';
51
+ import type { WindowOptions } from '../../gameplay';
52
+ import type { UIWindow } from '../../gameplay';
53
+ import type { PositionLike } from '../../common';
54
+ import type { ScreenPoint } from '../../gameplay';
55
+ import { uiFocus } from './Focus.js';
56
+ import { injectUICSS } from '../../../ui/theme';
57
+ export { uiFocus, injectUICSS };
package/types/nav.d.ts ADDED
@@ -0,0 +1,52 @@
1
+ // Navmesh nav() → engine.nav (Recast, levels only for now).
2
+ import type { XZ, PositionLike } from './common';
3
+
4
+ /** Options of nav() */
5
+ export interface NavOptions {
6
+ /** Voxel cell size (meters), default 0.3; smaller is more accurate but slower to build */
7
+ cellSize?: number;
8
+ /** Character radius (meters), default reads engine.movement.radius (this is an override) */
9
+ agentRadius?: number;
10
+ /** Character height (meters), default reads engine.movement.height */
11
+ agentHeight?: number;
12
+ /** Step height that can be climbed (meters), default reads engine.movement.stepHeight */
13
+ maxClimb?: number;
14
+ /** Max walkable slope (degrees), default reads engine.movement.maxSlope */
15
+ maxSlope?: number;
16
+ /** Tile size (in cells), default 32 */
17
+ tileSize?: number;
18
+ /** NPCs use Recast crowd avoidance, default false */
19
+ crowd?: boolean;
20
+ /** Show the navmesh (debug), default false */
21
+ debug?: boolean;
22
+ }
23
+
24
+ /**
25
+ * engine.nav: navmesh. Usually not called directly; engine.characters.findPath uses it automatically once ready.
26
+ * The mesh comes from the ground API's navGeometry() (optional) or staticTrimeshes() (the level's walkable mesh);
27
+ * collision boxes / circles (level col_ walls, those added by collision.addBox) all become dynamic obstacles and update automatically when added or removed.
28
+ */
29
+ export interface Nav {
30
+ /** The navmesh has been generated */
31
+ readonly ready: boolean;
32
+ /** Native Recast NavMesh (null until ready) */
33
+ navMesh: any;
34
+ /** Native Recast NavMeshQuery */
35
+ query: any;
36
+ /** Native Recast TileCache (for dynamic obstacles) */
37
+ tileCache: any;
38
+ /** Native Recast Crowd (only when crowd: true) */
39
+ crowd: any;
40
+ /** three.js object for the debug display (only when debug: true) */
41
+ helper: any;
42
+ /** +1 on rebuild / unload: code that cached native objects (crowd agents etc.) must recreate them when it changes */
43
+ readonly version: number;
44
+ /** Path from from to to [{ x, z }…] (meters); null if not ready or unreachable. Usually use engine.characters.findPath */
45
+ findPath(from: PositionLike, to: PositionLike, opts?: { radius?: number; detailed?: false }): XZ[] | null;
46
+ /** Pass detailed: true: returns { status: 'ok' | 'noPath' | 'notReady', path }, telling "unreachable" from "mesh not generated yet" */
47
+ findPath(from: PositionLike, to: PositionLike, opts: { radius?: number; detailed: true }): { status: 'ok' | 'noPath' | 'notReady'; path: XZ[] | null };
48
+ /** Character size actually in effect (from engine.movement, or the override in nav()) */
49
+ readonly agent: { radius: number; height: number; maxClimb: number; maxSlope: number } | null;
50
+ /** Unload the navmesh (frees native objects); characters.findPath then falls back to A* */
51
+ dispose(): void;
52
+ }