threedog 0.0.0-stage → 0.1.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 (459) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/LICENSE +21 -0
  3. package/README.md +39 -2
  4. package/core/Animator.js +267 -0
  5. package/core/Assets.js +240 -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/Describe.js +134 -0
  13. package/core/Engine.js +221 -0
  14. package/core/Events.js +95 -0
  15. package/core/I18n.js +94 -0
  16. package/core/Input.js +245 -0
  17. package/core/Inspect.js +97 -0
  18. package/core/InspectScene.js +187 -0
  19. package/core/Jobs.js +146 -0
  20. package/core/Loading.js +149 -0
  21. package/core/Ops.js +272 -0
  22. package/core/Random.js +52 -0
  23. package/core/Rays.js +160 -0
  24. package/core/SaveStore.js +85 -0
  25. package/core/Saves.js +253 -0
  26. package/core/Stream.js +279 -0
  27. package/core/Threads.js +158 -0
  28. package/core/UrlState.js +93 -0
  29. package/core/Vars.js +34 -0
  30. package/core/actor.js +23 -0
  31. package/core/assetEntry.js +89 -0
  32. package/core/assetLoad.js +190 -0
  33. package/core/assetManifest.js +35 -0
  34. package/core/audioRules.js +121 -0
  35. package/core/audioVoice.js +225 -0
  36. package/core/batchGroups.js +116 -0
  37. package/core/canvasBox.js +63 -0
  38. package/core/dayTime.js +15 -0
  39. package/core/describeText.js +136 -0
  40. package/core/easing.js +34 -0
  41. package/core/errorCodes.js +172 -0
  42. package/core/errorHints.js +203 -0
  43. package/core/errors.js +40 -0
  44. package/core/events.generated.js +84 -0
  45. package/core/ground.js +102 -0
  46. package/core/inputContext.js +69 -0
  47. package/core/inputDefaults.js +22 -0
  48. package/core/inputPad.js +35 -0
  49. package/core/inputPointer.js +48 -0
  50. package/core/inputTouch.js +48 -0
  51. package/core/lifecycle.js +68 -0
  52. package/core/lightWatch.js +36 -0
  53. package/core/loop.js +199 -0
  54. package/core/math.js +33 -0
  55. package/core/modules.js +182 -0
  56. package/core/movement.js +19 -0
  57. package/core/mulberry32.js +14 -0
  58. package/core/opsCheck.js +86 -0
  59. package/core/opsGuard.js +26 -0
  60. package/core/opsHistory.js +27 -0
  61. package/core/page.js +78 -0
  62. package/core/pureWorker.js +5 -0
  63. package/core/saveApply.js +128 -0
  64. package/core/saveFiles.js +139 -0
  65. package/core/saveIds.js +53 -0
  66. package/core/saveVersions.js +97 -0
  67. package/core/scatter.js +92 -0
  68. package/core/sceneMethods.js +125 -0
  69. package/core/screenToGround.js +39 -0
  70. package/core/session.js +171 -0
  71. package/core/shadowTypes.js +15 -0
  72. package/core/skip.js +104 -0
  73. package/core/startup.js +133 -0
  74. package/core/streamCells.js +24 -0
  75. package/core/streamSources.js +73 -0
  76. package/core/styleParts.js +96 -0
  77. package/core/targeting.js +64 -0
  78. package/core/thingOps.js +157 -0
  79. package/core/things.js +198 -0
  80. package/core/threadPure.js +120 -0
  81. package/core/threadServe.js +25 -0
  82. package/core/tier.js +11 -0
  83. package/core/validate.js +188 -0
  84. package/docs/AI.md +149 -0
  85. package/docs/API.md +84 -0
  86. package/docs/CODEMAP.md +335 -0
  87. package/docs/COMMANDS.md +96 -0
  88. package/docs/CONVENTIONS.md +134 -0
  89. package/docs/PERF.md +217 -0
  90. package/docs/THREE.md +86 -0
  91. package/docs/api/ambience.md +15 -0
  92. package/docs/api/assets.md +60 -0
  93. package/docs/api/audio.md +53 -0
  94. package/docs/api/budget.md +40 -0
  95. package/docs/api/cameraRig.md +120 -0
  96. package/docs/api/characters.md +142 -0
  97. package/docs/api/clock.md +7 -0
  98. package/docs/api/collision.md +35 -0
  99. package/docs/api/content.md +63 -0
  100. package/docs/api/debug.md +10 -0
  101. package/docs/api/dialogue.md +39 -0
  102. package/docs/api/engine.md +190 -0
  103. package/docs/api/entities.md +61 -0
  104. package/docs/api/events.md +91 -0
  105. package/docs/api/flow.md +27 -0
  106. package/docs/api/grids.md +11 -0
  107. package/docs/api/ground.md +16 -0
  108. package/docs/api/hlod.md +34 -0
  109. package/docs/api/hud.md +31 -0
  110. package/docs/api/i18n.md +10 -0
  111. package/docs/api/input.md +24 -0
  112. package/docs/api/interactions.md +31 -0
  113. package/docs/api/inventory.md +66 -0
  114. package/docs/api/jobs.md +10 -0
  115. package/docs/api/level.md +41 -0
  116. package/docs/api/lightPool.md +56 -0
  117. package/docs/api/music.md +34 -0
  118. package/docs/api/nav.md +26 -0
  119. package/docs/api/net.md +14 -0
  120. package/docs/api/openWorld.md +24 -0
  121. package/docs/api/particles.md +41 -0
  122. package/docs/api/photo.md +15 -0
  123. package/docs/api/post.md +9 -0
  124. package/docs/api/quests.md +36 -0
  125. package/docs/api/rays.md +26 -0
  126. package/docs/api/rigid.md +84 -0
  127. package/docs/api/saves.md +31 -0
  128. package/docs/api/settings.md +36 -0
  129. package/docs/api/sky.md +58 -0
  130. package/docs/api/stream.md +31 -0
  131. package/docs/api/style.md +134 -0
  132. package/docs/api/terrain.md +34 -0
  133. package/docs/api/timeline.md +39 -0
  134. package/docs/api/tools.md +55 -0
  135. package/docs/api/triggers.md +56 -0
  136. package/docs/api/vars.md +9 -0
  137. package/docs/api/vegetation.md +52 -0
  138. package/docs/api/water.md +48 -0
  139. package/docs/api/weather.md +29 -0
  140. package/docs/api/world.md +30 -0
  141. package/docs/recipes/01-new-game.md +148 -0
  142. package/docs/recipes/02-npc.md +151 -0
  143. package/docs/recipes/03-items-pickups.md +158 -0
  144. package/docs/recipes/04-quests.md +83 -0
  145. package/docs/recipes/05-props-bake.md +159 -0
  146. package/docs/recipes/06-clock-events.md +104 -0
  147. package/docs/recipes/07-flow-scenes-pause.md +128 -0
  148. package/docs/recipes/08-weather-sky.md +74 -0
  149. package/docs/recipes/09-style-pack.md +234 -0
  150. package/docs/recipes/10-blender-level.md +67 -0
  151. package/docs/recipes/11-vehicles.md +55 -0
  152. package/docs/recipes/12-navmesh.md +57 -0
  153. package/docs/recipes/13-animation.md +146 -0
  154. package/docs/recipes/14-custom-module.md +91 -0
  155. package/docs/recipes/15-perf.md +78 -0
  156. package/docs/recipes/16-dev-bridge.md +146 -0
  157. package/docs/recipes/18-world.md +185 -0
  158. package/docs/recipes/19-shooting-picking.md +76 -0
  159. package/docs/recipes/20-content-actions-save.md +176 -0
  160. package/docs/recipes/21-camera.md +104 -0
  161. package/docs/recipes/22-shop-gold.md +107 -0
  162. package/docs/recipes/23-ops.md +139 -0
  163. package/docs/recipes/26-ui-parts.md +138 -0
  164. package/docs/recipes/27-net.md +96 -0
  165. package/docs/recipes/28-terrain.md +80 -0
  166. package/docs/recipes/29-grid.md +87 -0
  167. package/docs/recipes/30-templates.md +131 -0
  168. package/docs/recipes/31-audio.md +126 -0
  169. package/docs/recipes/32-action-game.md +33 -0
  170. package/docs/recipes/33-stream-sources.md +37 -0
  171. package/docs/recipes/34-environment-lighting.md +35 -0
  172. package/docs/recipes/35-style-from-reference.md +89 -0
  173. package/docs/recipes/36-sky-ground-plant-looks.md +116 -0
  174. package/docs/recipes/37-terrain-look-hooks.md +97 -0
  175. package/docs/recipes/38-environment-look-hooks.md +81 -0
  176. package/docs/recipes/40-scene.md +79 -0
  177. package/docs/recipes/41-thing-registry.md +64 -0
  178. package/docs/recipes/42-terrain-shape.md +64 -0
  179. package/docs/recipes/43-shader-patches-surface-looks.md +118 -0
  180. package/docs/recipes/44-water-weather-look-hooks.md +133 -0
  181. package/docs/recipes/45-cascaded-shadows.md +51 -0
  182. package/docs/recipes/46-blender-art-route.md +92 -0
  183. package/docs/recipes/47-island-snow-backdrop.md +44 -0
  184. package/examples/action/DESIGN.md +3 -0
  185. package/examples/action/GAMEMAP.md +127 -0
  186. package/examples/action/content/actions.js +8 -0
  187. package/examples/action/content/audio.js +9 -0
  188. package/examples/action/content/index.js +9 -0
  189. package/examples/action/content/items.js +4 -0
  190. package/examples/action/content/places.js +4 -0
  191. package/examples/action/content/props.js +11 -0
  192. package/examples/action/content/templates.js +10 -0
  193. package/examples/action/look.js +5 -0
  194. package/examples/action/main.js +137 -0
  195. package/examples/action/models.js +25 -0
  196. package/examples/sheepisland/GAMEMAP.md +108 -0
  197. package/examples/sheepisland/content/index.js +6 -0
  198. package/examples/sheepisland/content/props.js +19 -0
  199. package/examples/sheepisland/content/templates.js +5 -0
  200. package/examples/sheepisland/content/vegetation.js +8 -0
  201. package/examples/sheepisland/main.js +71 -0
  202. package/examples/sheepisland/params.js +25 -0
  203. package/examples/sheepisland/style/index.js +79 -0
  204. package/examples/sheepisland/style/models.js +59 -0
  205. package/examples/sheepisland/views.js +9 -0
  206. package/examples/styletest/GAMEMAP.md +135 -0
  207. package/examples/styletest/content/index.js +9 -0
  208. package/examples/styletest/content/items.js +8 -0
  209. package/examples/styletest/content/npcs.js +8 -0
  210. package/examples/styletest/content/places.js +5 -0
  211. package/examples/styletest/content/props.js +16 -0
  212. package/examples/styletest/content/templates.js +9 -0
  213. package/examples/styletest/content/vegetation.js +31 -0
  214. package/examples/styletest/look.js +11 -0
  215. package/examples/styletest/main.js +95 -0
  216. package/examples/styletest/models.js +87 -0
  217. package/examples/styletest/overrides.js +33 -0
  218. package/examples/styletest/panel.js +135 -0
  219. package/examples/styletest/params.js +32 -0
  220. package/examples/styletest/views.js +31 -0
  221. package/examples/world/DESIGN.md +5 -0
  222. package/examples/world/GAMEMAP.md +171 -0
  223. package/examples/world/content/actions.js +8 -0
  224. package/examples/world/content/audio.js +25 -0
  225. package/examples/world/content/bodies.js +12 -0
  226. package/examples/world/content/containers.js +4 -0
  227. package/examples/world/content/dialogues.js +33 -0
  228. package/examples/world/content/index.js +17 -0
  229. package/examples/world/content/items.js +10 -0
  230. package/examples/world/content/npcs.js +14 -0
  231. package/examples/world/content/pickups.js +11 -0
  232. package/examples/world/content/places.js +6 -0
  233. package/examples/world/content/props.js +12 -0
  234. package/examples/world/content/quests.js +15 -0
  235. package/examples/world/content/rules.js +23 -0
  236. package/examples/world/content/templates.js +5 -0
  237. package/examples/world/content/vegetation.js +32 -0
  238. package/examples/world/main.js +168 -0
  239. package/examples/world/models.js +28 -0
  240. package/index.d.ts +279 -0
  241. package/index.js +120 -0
  242. package/llms.txt +56 -0
  243. package/modules/ambience/Ambience.js +183 -0
  244. package/modules/camera/FirstPersonCamera.js +133 -0
  245. package/modules/camera/FixedCamera.js +155 -0
  246. package/modules/camera/FollowCamera.js +85 -0
  247. package/modules/camera/RtsCamera.js +134 -0
  248. package/modules/camera/common.js +152 -0
  249. package/modules/camera/index.js +11 -0
  250. package/modules/characters/Character.js +223 -0
  251. package/modules/characters/NPC.js +242 -0
  252. package/modules/characters/assetModel.js +42 -0
  253. package/modules/characters/astar.js +59 -0
  254. package/modules/characters/behaviors.js +72 -0
  255. package/modules/characters/footsteps.js +13 -0
  256. package/modules/characters/index.js +212 -0
  257. package/modules/characters/moveHelpers.js +29 -0
  258. package/modules/characters/movers/common.js +62 -0
  259. package/modules/characters/movers/rapier.js +74 -0
  260. package/modules/characters/movers/simple.js +38 -0
  261. package/modules/characters/npcAvoid.js +129 -0
  262. package/modules/characters/npcSim.js +144 -0
  263. package/modules/characters/npcView.js +42 -0
  264. package/modules/characters/pathAsync.js +107 -0
  265. package/modules/characters/pathJob.js +61 -0
  266. package/modules/characters/pathWorker.js +7 -0
  267. package/modules/characters/playerStrings.js +12 -0
  268. package/modules/characters/proceduralRig.js +54 -0
  269. package/modules/collision/Collision.js +176 -0
  270. package/modules/collision/grid.js +63 -0
  271. package/modules/content/ids.js +95 -0
  272. package/modules/content/index.js +152 -0
  273. package/modules/content/loader.js +187 -0
  274. package/modules/content/models.js +69 -0
  275. package/modules/content/packs.js +69 -0
  276. package/modules/content/props.js +89 -0
  277. package/modules/content/rules.js +133 -0
  278. package/modules/content/templates.js +189 -0
  279. package/modules/debug/DebugPanel.js +168 -0
  280. package/modules/entities/Entities.js +239 -0
  281. package/modules/entities/build.js +25 -0
  282. package/modules/entities/index.js +4 -0
  283. package/modules/flow/index.js +98 -0
  284. package/modules/gameplay/Container.js +227 -0
  285. package/modules/gameplay/Containers.js +89 -0
  286. package/modules/gameplay/Dialogue.js +216 -0
  287. package/modules/gameplay/Interactions.js +243 -0
  288. package/modules/gameplay/Inventory.js +214 -0
  289. package/modules/gameplay/Quests.js +195 -0
  290. package/modules/gameplay/boxOps.js +60 -0
  291. package/modules/gameplay/dialogueBox.js +48 -0
  292. package/modules/gameplay/interactionPrompt.js +28 -0
  293. package/modules/gameplay/inventoryOps.js +137 -0
  294. package/modules/gameplay/pickups.js +113 -0
  295. package/modules/gameplay/questLog.js +54 -0
  296. package/modules/gameplay/questSave.js +71 -0
  297. package/modules/grid/Grid.js +184 -0
  298. package/modules/grid/Layer.js +142 -0
  299. package/modules/grid/index.js +236 -0
  300. package/modules/grid/ops.js +73 -0
  301. package/modules/grid/preview.js +85 -0
  302. package/modules/grid/tiles.js +75 -0
  303. package/modules/hlod/index.js +164 -0
  304. package/modules/hud/index.js +164 -0
  305. package/modules/hud/parts.js +80 -0
  306. package/modules/level/geometry.js +46 -0
  307. package/modules/level/heightfield.js +160 -0
  308. package/modules/level/index.js +231 -0
  309. package/modules/level/nodes.js +84 -0
  310. package/modules/lights/index.js +224 -0
  311. package/modules/music/Music.js +290 -0
  312. package/modules/music/index.js +2 -0
  313. package/modules/music/rules.js +28 -0
  314. package/modules/nav/index.js +154 -0
  315. package/modules/nav/navPath.js +17 -0
  316. package/modules/net/Client.js +136 -0
  317. package/modules/net/Host.js +117 -0
  318. package/modules/net/Net.js +49 -0
  319. package/modules/net/index.js +75 -0
  320. package/modules/net/sync.js +114 -0
  321. package/modules/net/transports.js +118 -0
  322. package/modules/particles/Particles.js +179 -0
  323. package/modules/particles/effect.js +112 -0
  324. package/modules/particles/shaders.js +28 -0
  325. package/modules/photo/Photo.js +143 -0
  326. package/modules/rigid/RigidBodies.js +262 -0
  327. package/modules/rigid/Vehicles.js +97 -0
  328. package/modules/rigid/sync.js +158 -0
  329. package/modules/settings/Settings.js +294 -0
  330. package/modules/settings/apply.js +20 -0
  331. package/modules/settings/index.js +3 -0
  332. package/modules/settings/sections.js +156 -0
  333. package/modules/settings/strings.js +53 -0
  334. package/modules/settings/view.js +65 -0
  335. package/modules/sky/Sky.js +257 -0
  336. package/modules/sky/calendar.js +80 -0
  337. package/modules/sky/cascades.js +125 -0
  338. package/modules/sky/clouds.js +79 -0
  339. package/modules/sky/domeLayers.js +33 -0
  340. package/modules/sky/environment.js +115 -0
  341. package/modules/sky/fog.js +136 -0
  342. package/modules/sky/frame.js +76 -0
  343. package/modules/sky/layers.js +69 -0
  344. package/modules/sky/look.js +50 -0
  345. package/modules/sky/schedule.js +80 -0
  346. package/modules/sky/shader.js +96 -0
  347. package/modules/sky/shadow.js +80 -0
  348. package/modules/sky/skyModule.js +59 -0
  349. package/modules/terrain/ChunkManager.js +291 -0
  350. package/modules/terrain/chunkJob.js +19 -0
  351. package/modules/terrain/chunkQueries.js +42 -0
  352. package/modules/terrain/chunkWorker.js +5 -0
  353. package/modules/terrain/index.js +110 -0
  354. package/modules/terrain/mountTerrain.js +32 -0
  355. package/modules/terrain/terrainColorMap.js +41 -0
  356. package/modules/terrain/terrainDefaults.js +39 -0
  357. package/modules/terrain/terrainEdit.js +139 -0
  358. package/modules/terrain/terrainGen.js +155 -0
  359. package/modules/terrain/terrainIsland.js +131 -0
  360. package/modules/terrain/terrainMesh.js +92 -0
  361. package/modules/terrain/terrainShape.js +108 -0
  362. package/modules/terrain/terrainShapeMain.js +41 -0
  363. package/modules/terrain/terrainTexture.js +44 -0
  364. package/modules/timeline/Timeline.js +249 -0
  365. package/modules/timeline/Tween.js +118 -0
  366. package/modules/timeline/letterbox.js +24 -0
  367. package/modules/timeline/shots.js +88 -0
  368. package/modules/triggers/index.js +261 -0
  369. package/modules/vegetation/Vegetation.js +255 -0
  370. package/modules/vegetation/groundChunks.js +177 -0
  371. package/modules/vegetation/index.js +40 -0
  372. package/modules/vegetation/modelGeometry.js +21 -0
  373. package/modules/water/Water.js +144 -0
  374. package/modules/water/surface.js +88 -0
  375. package/modules/weather/Weather.js +251 -0
  376. package/modules/weather/particles.js +92 -0
  377. package/modules/weather/shaders.js +49 -0
  378. package/modules/world/World.js +231 -0
  379. package/modules/world/cells.js +42 -0
  380. package/modules/world/index.js +64 -0
  381. package/modules/world/persist.js +107 -0
  382. package/modules/world/pos.js +20 -0
  383. package/modules/world/records.js +89 -0
  384. package/modules/world/sim.js +175 -0
  385. package/modules/world/simFar.js +82 -0
  386. package/modules/world/state.js +115 -0
  387. package/modules/world/views.js +182 -0
  388. package/package.json +66 -4
  389. package/presets.js +96 -0
  390. package/render/PostFX.js +243 -0
  391. package/render/detail.js +105 -0
  392. package/render/effects.js +142 -0
  393. package/render/engineUniforms.js +23 -0
  394. package/render/fuse.js +72 -0
  395. package/render/lighting.js +100 -0
  396. package/render/lights.js +16 -0
  397. package/render/materials.js +203 -0
  398. package/render/patches.js +252 -0
  399. package/render/surface.js +67 -0
  400. package/render/uniformDecl.js +29 -0
  401. package/types/common.d.ts +34 -0
  402. package/types/core.d.ts +1773 -0
  403. package/types/gameplay.d.ts +1812 -0
  404. package/types/generated/core/Audio.d.ts +200 -0
  405. package/types/generated/core/Batching.d.ts +47 -0
  406. package/types/generated/core/Budget.d.ts +90 -0
  407. package/types/generated/core/Commits.d.ts +31 -0
  408. package/types/generated/core/Events.d.ts +46 -0
  409. package/types/generated/core/I18n.d.ts +30 -0
  410. package/types/generated/core/Input.d.ts +118 -0
  411. package/types/generated/core/Jobs.d.ts +41 -0
  412. package/types/generated/core/Ops.d.ts +162 -0
  413. package/types/generated/core/Random.d.ts +49 -0
  414. package/types/generated/core/Rays.d.ts +49 -0
  415. package/types/generated/core/Saves.d.ts +161 -0
  416. package/types/generated/core/Stream.d.ts +93 -0
  417. package/types/generated/core/Threads.d.ts +82 -0
  418. package/types/generated/core/audioVoice.d.ts +47 -0
  419. package/types/generated/core/page.d.ts +18 -0
  420. package/types/generated/core/session.d.ts +48 -0
  421. package/types/generated/modules/ambience/Ambience.d.ts +48 -0
  422. package/types/generated/modules/debug/DebugPanel.d.ts +24 -0
  423. package/types/generated/modules/flow/index.d.ts +10 -0
  424. package/types/generated/modules/grid/Grid.d.ts +151 -0
  425. package/types/generated/modules/grid/Layer.d.ts +64 -0
  426. package/types/generated/modules/grid/index.d.ts +86 -0
  427. package/types/generated/modules/hlod/index.d.ts +11 -0
  428. package/types/generated/modules/hud/index.d.ts +10 -0
  429. package/types/generated/modules/lights/index.d.ts +13 -0
  430. package/types/generated/modules/music/Music.d.ts +111 -0
  431. package/types/generated/modules/net/Net.d.ts +34 -0
  432. package/types/generated/modules/net/index.d.ts +53 -0
  433. package/types/generated/modules/net/transports.d.ts +58 -0
  434. package/types/generated/modules/particles/Particles.d.ts +69 -0
  435. package/types/generated/modules/sky/Sky.d.ts +152 -0
  436. package/types/generated/modules/sky/skyModule.d.ts +10 -0
  437. package/types/generated/modules/timeline/Timeline.d.ts +51 -0
  438. package/types/generated/modules/water/Water.d.ts +29 -0
  439. package/types/generated/modules/weather/Weather.d.ts +72 -0
  440. package/types/generated/modules/world/World.d.ts +242 -0
  441. package/types/generated/modules/world/index.d.ts +15 -0
  442. package/types/generated/render/PostFX.d.ts +128 -0
  443. package/types/generated/render/materials.d.ts +90 -0
  444. package/types/generated/render/patches.d.ts +41 -0
  445. package/types/generated/ui/Focus.d.ts +11 -0
  446. package/types/generated/ui/LoadingScreen.d.ts +2 -0
  447. package/types/generated/ui/UI.d.ts +57 -0
  448. package/types/nav.d.ts +52 -0
  449. package/types/physics.d.ts +584 -0
  450. package/types/style.d.ts +628 -0
  451. package/types/worker.d.ts +11 -0
  452. package/types/world.d.ts +772 -0
  453. package/ui/Focus.js +51 -0
  454. package/ui/LoadingScreen.js +42 -0
  455. package/ui/Parts.js +195 -0
  456. package/ui/UI.js +167 -0
  457. package/ui/defaults.js +85 -0
  458. package/ui/theme.js +124 -0
  459. package/ui/touchPart.js +49 -0
@@ -0,0 +1,162 @@
1
+ // Generated by npm run map, do not edit by hand. Source: packages/engine/core/Ops.js (edit the JSDoc in the source, then run npm run map)
2
+ /**
3
+ * engine.ops: one entry point for the discrete things players and NPCs decide to do. define registers, run executes (sync, logged), can only asks, list says what exists / what is possible now, recent reads the log.
4
+ * Inside an op use ctx.actor (world record id, default engine.actor = 'player'), never engine.player: NPCs and network peers run the same op as themselves.
5
+ */
6
+ export class Ops {
7
+ set historySize(n: number);
8
+ /** History entries kept (ring, default 256); setting it clears the history */
9
+ get historySize(): number;
10
+ /**
11
+ * Register an op. Name it noun.verb. run changes state; can (optional) is read-only and returns true or a reason string; offers (optional) lists the arg sets possible now (for list / describe / the dev bridge `ops` command).
12
+ * args shape types: string number int bool position id any, suffix ? for optional. net: 'peer' lets remote players request it (default: host only);
13
+ * owner (optional, checked by net() for peer requests): args => world record id whose `owner` field must equal the requesting actor.
14
+ * @param {string} name
15
+ * @param {{ run: (e: any, args: any, ctx: OpContext) => any, can?: (e: any, args: any, ctx: OpContext) => true | string, args?: Record<string, string>, offers?: (e: any, ctx: OpContext) => object[], reasons?: Record<string, string>, desc?: string, undo?: (e: any, args: any, value: any) => void, net?: 'peer' | 'local', owner?: (args: any) => string }} def
16
+ * @returns {{ remove(): void }}
17
+ * @example
18
+ * const PRICE = { bread: 5 };
19
+ * engine.ops.define('shop.buy', {
20
+ * desc: 'Buy from a shop shelf',
21
+ * args: { shop: 'string', item: 'string', n: 'int?' },
22
+ * can(e, { shop, item, n = 1 }, ctx) {
23
+ * if (!e.inventory.container(shop).has(item, n)) return 'soldOut';
24
+ * if (e.inventory.container(ctx.actor).count('gold') < PRICE[item] * n) return 'noMoney';
25
+ * return true;
26
+ * },
27
+ * run(e, { shop, item, n = 1 }, ctx) {
28
+ * const got = e.inventory.transfer(shop, ctx.actor, item, n);
29
+ * e.inventory.container(ctx.actor).remove('gold', PRICE[item] * got);
30
+ * return got;
31
+ * },
32
+ * reasons: { soldOut: 'Shelf is empty', noMoney: 'Not enough gold' },
33
+ * });
34
+ */
35
+ define(name: string, def: {
36
+ run: (e: any, args: any, ctx: OpContext) => any;
37
+ can?: (e: any, args: any, ctx: OpContext) => true | string;
38
+ args?: Record<string, string>;
39
+ offers?: (e: any, ctx: OpContext) => object[];
40
+ reasons?: Record<string, string>;
41
+ desc?: string;
42
+ undo?: (e: any, args: any, value: any) => void;
43
+ net?: "peer" | "local";
44
+ owner?: (args: any) => string;
45
+ }): {
46
+ remove(): void;
47
+ };
48
+ /**
49
+ * Run an op now (synchronously): checks args (dev), calls can, then run, and logs it. Returns { ok: true, value } or { ok: false, reason }.
50
+ * Pass a fresh args object each call (it is kept in the history; in dev it is frozen). opts.source: 'player' | 'game' | 'bridge' | 'test' | 'replay' | 'net'
51
+ * (default: 'game' inside a fixed step, 'player' between steps); opts.actor: who does it (world record id, default engine.actor, which is 'player' unless the game hands control elsewhere).
52
+ * @param {string} name
53
+ * @param {object} [args]
54
+ * @param {{ source?: string, actor?: string }} [opts]
55
+ * @returns {{ ok: boolean, value?: any, reason?: string }}
56
+ * @example
57
+ * const r = engine.ops.run('shop.buy', { shop: 'bakery', item: 'bread' });
58
+ * if (!r.ok) showHint(engine.t('op.shop.buy.' + r.reason));
59
+ * // from a fixed step, for an input-driven action: e.ops.run('combat.roll', { dir }, { source: 'player' })
60
+ */
61
+ run(name: string, args?: object, opts?: {
62
+ source?: string;
63
+ actor?: string;
64
+ }): {
65
+ ok: boolean;
66
+ value?: any;
67
+ reason?: string;
68
+ };
69
+ /**
70
+ * Reverse a finished op with the undo(e, args, value) its definition declared: pass the same args and the value run returned.
71
+ * Returns { ok: true }, or { ok: false, reason: 'noUndo' } when the op did not declare undo. The undo runs as an op write (the dev guard stays quiet).
72
+ * @example const r = engine.ops.run('inventory.trade', { take: 'rusty_key', give: 'gold_key' }); engine.ops.undo('inventory.trade', { take: 'rusty_key', give: 'gold_key' }, r.value);
73
+ * @param {string} name
74
+ * @param {object} args
75
+ * @param {any} value
76
+ * @param {{ actor?: string }} [opts]
77
+ * @returns {{ ok: boolean, reason?: string }}
78
+ */
79
+ undo(name: string, args: object, value: any, opts?: {
80
+ actor?: string;
81
+ }): {
82
+ ok: boolean;
83
+ reason?: string;
84
+ };
85
+ /**
86
+ * Ask without doing: runs only can (no state change, no history). For greying out buttons and input buffers.
87
+ * @param {string} name
88
+ * @param {object} [args]
89
+ * @param {{ actor?: string, source?: string }} [opts]
90
+ * @returns {{ ok: boolean, reason?: string }}
91
+ * @example const { ok, reason } = engine.ops.can('shop.buy', { shop: 'bakery', item: 'bread' });
92
+ * button.disabled = !ok;
93
+ */
94
+ can(name: string, args?: object, opts?: {
95
+ actor?: string;
96
+ source?: string;
97
+ }): {
98
+ ok: boolean;
99
+ reason?: string;
100
+ };
101
+ /**
102
+ * What exists, or with { available: true } what is possible now: every arg set from each op's offers checked with can
103
+ * (an op with neither offers nor args is checked once with {}; one with args but no offers is skipped, since its args are free-form).
104
+ * @param {{ available?: boolean, actor?: string }} [opts]
105
+ * @returns {{ name: string, desc?: string, args?: any, ok?: boolean, reason?: string }[]}
106
+ * @example engine.ops.list({ available: true }); // [{ name: 'shop.buy', args: { shop: 'bakery', item: 'bread' }, ok: false, reason: 'noMoney' }, ...]
107
+ */
108
+ list({ available, actor }?: {
109
+ available?: boolean;
110
+ actor?: string;
111
+ }): {
112
+ name: string;
113
+ desc?: string;
114
+ args?: any;
115
+ ok?: boolean;
116
+ reason?: string;
117
+ }[];
118
+ /**
119
+ * Recent history (old -> new), optionally of one op: { seq, tick, phase: 'fixed' | 'between', name, args, source, actor, ok, reason, depth, count }.
120
+ * Consecutive identical failures (same actor, op and reason) merge into one entry with count.
121
+ * @param {string} [name]
122
+ * @returns {{ seq: number, tick: number, phase: string, name: string, args: any, source: string, actor: string, ok: boolean, reason: string | null, depth: number, count: number }[]}
123
+ * @example engine.ops.recent('shop.buy').at(-1); // { tick: 812, phase: 'between', ok: false, reason: 'noMoney', ... }
124
+ */
125
+ recent(name?: string): {
126
+ seq: number;
127
+ tick: number;
128
+ phase: string;
129
+ name: string;
130
+ args: any;
131
+ source: string;
132
+ actor: string;
133
+ ok: boolean;
134
+ reason: string | null;
135
+ depth: number;
136
+ count: number;
137
+ }[];
138
+ /**
139
+ * Dev guard for a module that owns saved gameplay state: call it at the top of every method that writes that state. In development it warns once per call site
140
+ * when the write happens outside a fixed step, an op or an allow() window (before ready everything is allowed); in a production build it is a no-op, so just call `engine.ops.guard(...)` (no DEV check needed).
141
+ * @experimental
142
+ * @example set(k, v) { this.engine.ops.guard('myStore.set'); this.data[k] = v; }
143
+ * @param {string} where label shown in the warning, e.g. 'vars.setFlag'
144
+ * @returns {void}
145
+ */
146
+ guard(where: string): void;
147
+ /**
148
+ * Run fn with guarded writes allowed (loading a save, applying a scenario, net sync); works for an async fn too (allowed until its Promise settles). Returns what fn returns.
149
+ * @experimental
150
+ * @example engine.ops.allow(() => store.load(data));
151
+ * @template T
152
+ * @param {() => T} fn
153
+ * @returns {T}
154
+ */
155
+ allow<T>(fn: () => T): T;
156
+ }
157
+ export type OpContext = {
158
+ source: string;
159
+ actor: string;
160
+ tick: number;
161
+ frozen: boolean;
162
+ };
@@ -0,0 +1,49 @@
1
+ // Generated by npm run map, do not edit by hand. Source: packages/engine/core/Random.js (edit the JSDoc in the source, then run npm run map)
2
+ /** engine.random is the seeded random generator. Gameplay randomness (auto weather, lightning, drops, spawning) uses it so step / tests are reproducible and the state is saved with the save. */
3
+ export class Random {
4
+ /** @param {number} [seed] Seed, default 1 */
5
+ constructor(seed?: number);
6
+ /**
7
+ * Reseed: the sequence afterwards is determined by seed.
8
+ * @param {number} seed
9
+ * @returns {this}
10
+ * @example engine.random.setSeed(42);
11
+ */
12
+ setSeed(seed: number): this;
13
+ seed: number;
14
+ state: number;
15
+ /** A number from 0 (inclusive) to 1 (exclusive) @returns {number} */
16
+ next(): number;
17
+ /** A decimal between a and b @param {number} a @param {number} b @returns {number} */
18
+ range(a: number, b: number): number;
19
+ /** An integer between a and b (inclusive) @param {number} a @param {number} b @returns {number} @example const dice = engine.random.int(1, 6); */
20
+ int(a: number, b: number): number;
21
+ /**
22
+ * Pick one element of the array at random (undefined for an empty array).
23
+ * @template T
24
+ * @param {readonly T[]} list
25
+ * @returns {T | undefined}
26
+ */
27
+ pick<T>(list: readonly T[]): T | undefined;
28
+ /** True with probability p (0-1) @param {number} p @returns {boolean} */
29
+ chance(p: number): boolean;
30
+ /**
31
+ * Create an independent deterministic generator: the same seed always gives the same sequence, without touching engine.random's state or the save.
32
+ * For placing world initial data (the same things must be laid out on every start, and loading a save must not overwrite them with the saved engine.random).
33
+ * Gameplay randomness (drops, lightning) still uses engine.random (saved with the save).
34
+ * @param {number} seed
35
+ * @returns {Random}
36
+ * @example const rnd = engine.random.seeded(7); const x = rnd.range(-20, 20);
37
+ */
38
+ seeded(seed: number): Random;
39
+ /** For saving: { seed, state } @returns {{ seed: number, state: number }} */
40
+ toJSON(): {
41
+ seed: number;
42
+ state: number;
43
+ };
44
+ /** For loading @param {{ seed: number, state: number } | null | undefined} d */
45
+ fromJSON(d: {
46
+ seed: number;
47
+ state: number;
48
+ } | null | undefined): void;
49
+ }
@@ -0,0 +1,49 @@
1
+ // Generated by npm run map, do not edit by hand. Source: packages/engine/core/Rays.js (edit the JSDoc in the source, then run npm run map)
2
+ /** engine.rays is the ray registry (engine.raycast hits whatever is registered here). */
3
+ export class Rays {
4
+ /** Registered mesh -> { refs: registration count, occ: camera-blocker registration count } @type {Map<THREE.Object3D, { refs: number, occ: number }>} */
5
+ statics: Map<THREE.Object3D, {
6
+ refs: number;
7
+ occ: number;
8
+ }>;
9
+ /** The three.js Raycaster (firstHitOnly is on) @type {any} */
10
+ ray: any;
11
+ /**
12
+ * Register a static object and every mesh under it (an array also works; meshes over 256 triangles get a BVH); occluder: true also blocks the camera. Returns a handle { remove() }.
13
+ * Only visible objects are hit; hiding that just swaps in something else on screen (such as the far-away hlod original) is marked userData.rayVisible = true and is still hit.
14
+ * Unregisters automatically on geometry dispose or engine.remove.
15
+ * @param {THREE.Object3D | THREE.Object3D[]} obj
16
+ * @param {{ occluder?: boolean }} [opts]
17
+ * @returns {Handle}
18
+ * @example engine.rays.addStatic(house, { occluder: true });
19
+ */
20
+ addStatic(obj: THREE.Object3D | THREE.Object3D[], opts?: {
21
+ occluder?: boolean;
22
+ }): Handle;
23
+ /** Unregister every mesh under the object (engine.remove calls this automatically) @param {THREE.Object3D} obj */
24
+ forget(obj: THREE.Object3D): void;
25
+ /** A module merges its own hits (rigid adds rigid bodies; asked only when targets is 'all'). Returns a handle { remove() } @param {RayProvider} fn @returns {Handle} */
26
+ addProvider(fn: RayProvider): Handle;
27
+ /**
28
+ * Cast a ray from origin along dir and return the nearest hit or null (same as engine.raycast).
29
+ * @param {Vec3Like} origin
30
+ * @param {Vec3Like} dir
31
+ * @param {RaycastOptions} [opts]
32
+ * @returns {RayHit | null}
33
+ */
34
+ cast(origin: Vec3Like, dir: Vec3Like, opts?: RaycastOptions): RayHit | null;
35
+ /**
36
+ * Cast from screen coordinates (-1..1) through the camera (same as engine.pick).
37
+ * @param {number} ndcX
38
+ * @param {number} ndcY
39
+ * @param {RaycastOptions} [opts]
40
+ * @returns {RayHit | null}
41
+ */
42
+ pick(ndcX: number, ndcY: number, opts?: RaycastOptions): RayHit | null;
43
+ }
44
+ import * as THREE from 'three';
45
+ import type { Handle } from '../../common';
46
+ import type { RayProvider } from '../../core';
47
+ import type { Vec3Like } from '../../common';
48
+ import type { RaycastOptions } from '../../core';
49
+ import type { RayHit } from '../../core';
@@ -0,0 +1,161 @@
1
+ // Generated by npm run map, do not edit by hand. Source: packages/engine/core/Saves.js (edit the JSDoc in the source, then run npm run map)
2
+ /** engine.saves handles saving. Each module registers "how to save and load"; supports multiple slots, autosave and export / import. */
3
+ export class Saves {
4
+ /** Save name prefix (start of the key names in the localStorage fallback, and of the IndexedDB database name) */
5
+ prefix: string;
6
+ /**
7
+ * Storage layer: saves in the IndexedDB slots store, attachments (by group, e.g. 'photo') in the blobs store; mode 'localStorage' without IndexedDB.
8
+ * @type {{ mode: 'idb' | 'localStorage', blobs(group?: string): Promise<{ group: string, id: string, at: number, blob: Blob, meta: any }[]>,
9
+ * putBlob(group: string, id: string, blob: Blob, meta?: any, at?: number): Promise<void>, deleteBlob(group: string, id: string): Promise<void> }}
10
+ */
11
+ store: {
12
+ mode: "idb" | "localStorage";
13
+ blobs(group?: string): Promise<{
14
+ group: string;
15
+ id: string;
16
+ at: number;
17
+ blob: Blob;
18
+ meta: any;
19
+ }[]>;
20
+ putBlob(group: string, id: string, blob: Blob, meta?: any, at?: number): Promise<void>;
21
+ deleteBlob(group: string, id: string): Promise<void>;
22
+ };
23
+ /** Has the save index been read into memory? (start() waits for it; game code rarely needs to care) */
24
+ ready: boolean;
25
+ /** Resolves once the save index is in memory; await it only to list / load before start() @type {Promise<void>} */
26
+ whenReady: Promise<void>;
27
+ /**
28
+ * Register "how to save and load"; key is this part's name in the save. Parts with first: true load first (the level); a load returning a Promise makes later
29
+ * parts wait.
30
+ * version (default 1): raise it by 1 whenever what save() returns changes shape, and add migrate[oldVersion] = data => newData; load sees only the current
31
+ * shape.
32
+ * A save whose part is newer than this build's version is refused as a whole (load returns false, the save is kept).
33
+ * A part registered after a save was loaded (a module installed later) is handed its data from that save at once.
34
+ * @param {string} key
35
+ * @param {SaveProvider} provider
36
+ * @example
37
+ * engine.saves.register('garden', { save: () => garden.toJSON(), load: d => garden.fromJSON(d) });
38
+ * // later the format gains beds: version 2, and a step that upgrades version-1 data
39
+ * engine.saves.register('garden', { version: 2, migrate: { 1: d => ({ ...d, beds: [] }) }, save: () => garden.toJSON(), load: d => garden.fromJSON(d) });
40
+ */
41
+ register(key: string, provider: SaveProvider): void;
42
+ /**
43
+ * The save versions this build reads, per part: { world: 1, clock: 1, ... }. A save whose part is newer is refused; an older one is migrated.
44
+ * @returns {Record<string, number>}
45
+ */
46
+ get versions(): Record<string, number>;
47
+ /**
48
+ * Queue a disk write (runs in call order once storage is ready; flush waits for it; used by attachments such as photos).
49
+ * @template T
50
+ * @param {() => Promise<T>} fn
51
+ * @returns {Promise<T>}
52
+ */
53
+ queue<T>(fn: () => Promise<T>): Promise<T>;
54
+ /** Wait for all queued disk writes to finish (for tests and before the page closes) @returns {Promise<void>} */
55
+ flush(): Promise<void>;
56
+ /**
57
+ * Collect the data of every part (does not write to the browser): { format, savedAt, versions, parts }.
58
+ * A part whose save() throws is left out and reported (engine.error in dev); save() instead refuses to write such a save.
59
+ * @returns {{ format: number, savedAt: number, versions: Record<string, number>, parts: Record<string, any> }}
60
+ */
61
+ collect(): {
62
+ format: number;
63
+ savedAt: number;
64
+ versions: Record<string, number>;
65
+ parts: Record<string, any>;
66
+ };
67
+ /**
68
+ * Can this slot be loaded? null when it can, else why not (checked without touching the game):
69
+ * 'missing' | 'corrupt' (unreadable) | 'tooNew' (a newer save format or part) | 'migrate' (an upgrade step is missing or throws).
70
+ * @param {string} [slot]
71
+ * @returns {null | 'missing' | 'corrupt' | 'tooNew' | 'migrate'}
72
+ * @example if (engine.saves.check('slot1') === 'tooNew') showUpdateHint();
73
+ */
74
+ check(slot?: string): null | "missing" | "corrupt" | "tooNew" | "migrate";
75
+ /**
76
+ * Apply a save's data (an object from collect(), or save text) onto the running game. Resolves true when every part loaded.
77
+ * Refused before anything changes (false, toast) when the data is corrupt, from a newer build or cannot be migrated.
78
+ * After every part loaded it runs the modules' afterLoad hooks (gameplay frozen until they resolve), for saves.load, session.newGame / quit and direct calls
79
+ * alike.
80
+ * If a part's load throws, the game is rolled back to how it was before (every part reloads its pre-load state) and it resolves false; the error goes through
81
+ * the error tiers.
82
+ * The state changes synchronously unless a part's load is async; only the result is a Promise.
83
+ * @param {any} data
84
+ * @param {string} [slot] for messages only
85
+ * @returns {Promise<boolean>}
86
+ */
87
+ apply(data: any, slot?: string): Promise<boolean>;
88
+ /**
89
+ * Save into a slot (default 'auto'). Returns Promise<boolean>
90
+ * (resolves after the write to IndexedDB: true on success, false with a toast and console error on failure).
91
+ * The in-memory save updates immediately, so a following load / list / export sees it at once; the 'save:written' event fires only after the write succeeds.
92
+ * If any part's save() throws, nothing is written and the slot keeps its previous save (false). A failed write keeps the previous save too.
93
+ * Show "saved" only after the result is true.
94
+ * @param {string} [slot]
95
+ * @returns {Promise<boolean>}
96
+ * @example if (await engine.saves.save('slot1')) toast(engine, 'Saved'); // on false the engine already showed why
97
+ */
98
+ save(slot?: string): Promise<boolean>;
99
+ /**
100
+ * Load a slot onto the running playthrough (a quick load: what the game added during play stays) and resolve true on success; the 'save:loaded' event fires
101
+ * on success.
102
+ * A missing slot resolves false; a corrupt / too new / unmigratable save resolves false with a toast and changes nothing; a part whose load throws rolls the
103
+ * game back.
104
+ * To continue or retry with nothing of the current playthrough left over, use engine.session.load(slot).
105
+ * @param {string} [slot]
106
+ * @returns {Promise<boolean>}
107
+ * @example if (!(await engine.saves.load('quick'))) toast(engine, 'No quick save');
108
+ */
109
+ load(slot?: string): Promise<boolean>;
110
+ /** All slots, newest first (synchronous, reads the in-memory index) @returns {{ slot: string, savedAt: number }[]} */
111
+ list(): {
112
+ slot: string;
113
+ savedAt: number;
114
+ }[];
115
+ /** Delete a slot. Returns a Promise (disk write done); awaiting is optional @param {string} slot @returns {Promise<void>} */
116
+ remove(slot: string): Promise<void>;
117
+ /** Export as a piece of text (can be copied as a backup; synchronous, without binary attachments) @param {string} [slot] @returns {string} */
118
+ export(slot?: string): string;
119
+ /**
120
+ * Import text from export() into a slot (default 'imported'); checked like importFile and written before it resolves.
121
+ * Resolves true once stored (save:imported fires), false when the text is not a save or the write failed. It does not load the slot.
122
+ * @param {string} text
123
+ * @param {string} [slot]
124
+ * @returns {Promise<boolean>}
125
+ */
126
+ import(text: string, slot?: string): Promise<boolean>;
127
+ /**
128
+ * Download a save file (.json): the save plus every binary attachment (as data: text, so the file is larger; { files: false } exports the save only).
129
+ * Restores everything when browser data is wiped on a phone. Returns Promise<boolean>.
130
+ * @param {string} [slot]
131
+ * @param {{ files?: boolean }} [opts]
132
+ * @returns {Promise<boolean>}
133
+ * @example engine.saves.exportFile('slot1');
134
+ */
135
+ exportFile(slot?: string, opts?: {
136
+ files?: boolean;
137
+ }): Promise<boolean>;
138
+ /**
139
+ * Restore from a save file into slot (default 'imported', so a shared file never overwrites 'auto'). file is a File / Blob; omit it to open a file picker.
140
+ * Everything is checked first (file marker and format, the save inside, attachments must be data: URLs: nothing is fetched).
141
+ * Returns the slot name on success, and null if cancelled, the file is invalid or the write failed (a toast was already shown). It restores the slot only and
142
+ * does not load it.
143
+ * @param {Blob} [file]
144
+ * @param {string} [slot]
145
+ * @returns {Promise<string | null>}
146
+ */
147
+ importFile(file?: Blob, slot?: string): Promise<string | null>;
148
+ /**
149
+ * Autosave into 'auto' every `minutes` minutes of play: counted in fixed seconds, so it waits while paused, frozen or in a menu that freezes the game,
150
+ * and it never saves while no playthrough runs (the title screen, during newGame / load / quit) or after a gameplay error. Returns a handle; remove() stops
151
+ * it.
152
+ * Calling it again replaces the previous autosave.
153
+ * @param {number} [minutes]
154
+ * @returns {{ remove(): void }}
155
+ * @example engine.saves.autosave(3); // once at boot: it waits by itself while no playthrough runs
156
+ */
157
+ autosave(minutes?: number): {
158
+ remove(): void;
159
+ };
160
+ }
161
+ import type { SaveProvider } from '../../core';
@@ -0,0 +1,93 @@
1
+ // Generated by npm run map, do not edit by hand. Source: packages/engine/core/Stream.js (edit the JSDoc in the source, then run npm run map)
2
+ /** engine.stream builds on demand by space: only entries near the focus get built. */
3
+ export class Stream {
4
+ /**
5
+ * Build radius in meters around each full-detail stream source (a source radius caps it); null = follow the terrain view distance (the fog distance
6
+ * engine.fogFar without terrain) @type {number | null}
7
+ */
8
+ radius: number | null;
9
+ /** Grid cell edge in meters, shared with hlod, default 64 */
10
+ cellSize: number;
11
+ /** Unload only beyond radius x this (walking back and forth does not rebuild), default 1.25 */
12
+ unloadFactor: number;
13
+ /** Built-in source at the gameplay anchor (world.anchor, else the player, else engine.focus): full detail and physics @type {StreamSource} */
14
+ player: StreamSource;
15
+ /** Built-in source at the camera focus engine.focus: full detail, no physics @type {StreamSource} */
16
+ camera: StreamSource;
17
+ /** The build radius actually in use, in meters @returns {number} */
18
+ get activeRadius(): number;
19
+ /**
20
+ * Register something to stream in (not built at once); an object returned by build with no parent is added to the scene automatically.
21
+ * @param {StreamEntryOptions} def
22
+ * @returns {StreamHandle}
23
+ * @example engine.stream.add({ position: [40, 0, 12], radius: 6, build: () => makeHouse() });
24
+ */
25
+ add(def: StreamEntryOptions): StreamHandle;
26
+ /** Set the build radius in meters @param {number} m */
27
+ setRadius(m: number): void;
28
+ /** Everything registered within radius is built (start() waits for it before the loading screen goes away) @returns {boolean} */
29
+ get ready(): boolean;
30
+ /** entries is the registered count, built the built count, queued the queued count @returns {{ entries: number, built: number, queued: number }} */
31
+ get stats(): {
32
+ entries: number;
33
+ built: number;
34
+ queued: number;
35
+ };
36
+ /**
37
+ * Add a stream source: the world around position is loaded (terrain chunks, colliders, nearby models, stream entries) until remove() or until.
38
+ * position may be live (an Object3D or Vector3 that moves) or a function. detail 'simple' loads only terrain and hlod proxies (a far view);
39
+ * physics defaults to true for 'full'; pass false for a camera that only needs a picture. radius caps every loader's range (default: each loader's own
40
+ * range).
41
+ * until: a Promise (removed when it settles) or a function checked every frame (removed when it returns true).
42
+ * @example const dest = engine.stream.source([800, 0, 300], { radius: 64 }); await dest.whenReady; engine.player.placeAt([800, 0, 300]); dest.remove();
43
+ * @example engine.stream.source(photoCam, { physics: false, until: () => !photoMode.active }); // follows a camera, no colliders
44
+ * @param {any} position
45
+ * @param {StreamSourceOptions} [opts]
46
+ * @returns {StreamSource}
47
+ * @experimental
48
+ */
49
+ source(position: any, opts?: StreamSourceOptions): StreamSource;
50
+ /**
51
+ * Load the destination first, then move: resolves after the player (engine.focus without one) is placed. Until the destination is ready
52
+ * (terrain chunks, collision, nearby models) the player stays where it is. move replaces the default placement (for a vehicle or a custom character).
53
+ * timeout (seconds of frame time, default 60; Infinity waits forever): when the destination is still not ready, the Promise rejects (code stream-timeout,
54
+ * naming the loaders still waiting) and the player is not moved.
55
+ * @example await engine.stream.teleport([800, 0, 300]);
56
+ * @example await engine.stream.teleport(door.target, { radius: 40, move: p => engine.player.placeAt(p) });
57
+ * @param {any} position
58
+ * @param {{ radius?: number, move?: (position: any) => void, timeout?: number }} [opts]
59
+ * @returns {Promise<void>}
60
+ * @experimental
61
+ */
62
+ teleport(position: any, opts?: {
63
+ radius?: number;
64
+ move?: (position: any) => void;
65
+ timeout?: number;
66
+ }): Promise<void>;
67
+ /**
68
+ * Register a readiness check for loaders: fn(source) returns whether this loader finished what that source asks for.
69
+ * For module authors whose loader reads stream sources; games only read source.ready.
70
+ * @example engine.stream.readyCheck('props', s => s.detail !== 'full' || props.queued === 0)
71
+ * @param {string} name
72
+ * @param {(source: StreamSource) => boolean} fn
73
+ * @returns {{ remove(): void }}
74
+ * @experimental
75
+ */
76
+ readyCheck(name: string, fn: (source: StreamSource) => boolean): {
77
+ remove(): void;
78
+ };
79
+ /**
80
+ * Sources with fresh positions, filtered: { detail: 'full' } for models and stream entries, { physics: true } for colliders, no filter for terrain
81
+ * @param {{ detail?: 'full' | 'simple', physics?: boolean }} [pick]
82
+ * @returns {StreamSource[]}
83
+ * @experimental
84
+ */
85
+ sources(pick?: {
86
+ detail?: "full" | "simple";
87
+ physics?: boolean;
88
+ }): StreamSource[];
89
+ }
90
+ import type { StreamSource } from '../../core';
91
+ import type { StreamEntryOptions } from '../../core';
92
+ import type { StreamHandle } from '../../core';
93
+ import type { StreamSourceOptions } from '../../core';
@@ -0,0 +1,82 @@
1
+ // Generated by npm run map, do not edit by hand. Source: packages/engine/core/Threads.js (edit the JSDoc in the source, then run npm run map)
2
+ /**
3
+ * engine.threads: worker pool behind createEngine({ threads }). Lanes start their workers lazily; size 0 means everything runs on the main thread.
4
+ * @experimental
5
+ */
6
+ export class Threads {
7
+ /** Workers per lane (0 = main thread only) */
8
+ size: number;
9
+ /** True when SharedArrayBuffer can be shared with workers (page is cross-origin isolated) */
10
+ shared: boolean;
11
+ /**
12
+ * A lane of workers running one script. create must contain the literal new Worker(new URL('./file.js', import.meta.url), { type: 'module' }) so bundlers find the file.
13
+ * local builds the same handler on the main thread (used when there are no workers).
14
+ * @param {{ create: () => Worker, local: () => (msg: any) => any, max?: number }} opts
15
+ * @returns {Lane}
16
+ * @example
17
+ * const lane = engine.threads.lane({ create: () => new Worker(new URL('./chunkWorker.js', import.meta.url), { type: 'module' }), local: chunkHandler });
18
+ * lane.run({ cx: 0, cz: 0 }).then(r => engine.commits ...);
19
+ */
20
+ lane(opts: {
21
+ create: () => Worker;
22
+ local: () => (msg: any) => any;
23
+ max?: number;
24
+ }): Lane;
25
+ /**
26
+ * A typed array other threads can read without a copy: on a SharedArrayBuffer when shared, else an ordinary one (postMessage then copies it).
27
+ * @template {Float32ArrayConstructor | Int32ArrayConstructor | Uint8ArrayConstructor | Uint16ArrayConstructor | Float64ArrayConstructor} T
28
+ * @param {T} Type
29
+ * @param {number} length
30
+ * @returns {InstanceType<T>}
31
+ * @example const heights = engine.threads.array(Float32Array, 256 * 256);
32
+ */
33
+ array<T extends Float32ArrayConstructor | Int32ArrayConstructor | Uint8ArrayConstructor | Uint16ArrayConstructor | Float64ArrayConstructor>(Type: T, length: number): InstanceType<T>;
34
+ /**
35
+ * Turn a self-contained function into one that can run in a worker. It is recompiled from its source text, so it sees only its parameters and globals like Math:
36
+ * a closure variable fails with a ReferenceError naming it, on the main thread too (threads on or off behave the same). Used by world.simulate(kind, { far, worker: true }).
37
+ * @param {Function} fn
38
+ * @param {string} label where it came from, used in error messages
39
+ * @returns {{ fn: Function, src: string, label: string }}
40
+ * @example const grow = engine.threads.pure((rec, dt) => { rec.growth = Math.min(1, rec.growth + dt / 600); }, "world.simulate('crop') far");
41
+ */
42
+ pure(fn: Function, label: string): {
43
+ fn: Function;
44
+ src: string;
45
+ label: string;
46
+ };
47
+ }
48
+ /**
49
+ * One kind of worker (one script), up to engine.threads.size instances. run() goes to the least busy one; with no workers the local handler answers on a microtask.
50
+ */
51
+ declare class Lane {
52
+ threads: any;
53
+ create: any;
54
+ local: any;
55
+ max: number;
56
+ /** @type {{ w: Worker, busy: number }[]} */ workers: {
57
+ w: Worker;
58
+ busy: number;
59
+ }[];
60
+ handler: any;
61
+ tasks: Map<any, any>;
62
+ bcast: Map<any, any>;
63
+ /** Workers actually running in this lane (0 = main thread) @returns {number} */
64
+ get size(): number;
65
+ /**
66
+ * Send a task; resolves with the handler's reply. Typed arrays you list in transfer move to the worker (unusable here afterwards);
67
+ * if that worker then crashes, the task rejects (code threads-transfer) instead of rerunning on the main thread with emptied buffers.
68
+ * @param {any} msg plain data
69
+ * @param {Transferable[]} [transfer]
70
+ * @returns {Promise<any>}
71
+ */
72
+ run(msg: any, transfer?: Transferable[]): Promise<any>;
73
+ /**
74
+ * Send setup data to every worker (no reply). With a key, a later broadcast of the same key replaces it for workers started afterwards.
75
+ * @param {any} msg
76
+ * @param {string} [key]
77
+ */
78
+ broadcast(msg: any, key?: string): void;
79
+ /** Stop the workers; open tasks never settle */
80
+ dispose(): void;
81
+ }
82
+ export {};
@@ -0,0 +1,47 @@
1
+ // Generated by npm run map, do not edit by hand. Source: packages/engine/core/audioVoice.js (edit the JSDoc in the source, then run npm run map)
2
+ /** Point the Web Audio listener where the camera is (only called while positional voices exist: zero cost otherwise) */
3
+ export function placeListener(ctx: any, camera: any): void;
4
+ /** Synth building block behind audio.noiseBurst: a burst of filtered noise */
5
+ export function synthNoise(audio: any, opts: any): void;
6
+ /** Synth building block behind audio.tone: a short enveloped tone */
7
+ export function synthTone(audio: any, opts: any): void;
8
+ /** audio.load body: decode a file once (cached), or load a sound name from an asset pack through engine.assets */
9
+ export function loadSound(audio: any, url: any): Promise<any>;
10
+ /** audio.play body: a file by path or asset name, no sounds entry needed */
11
+ export function playFile(audio: any, url: any, opts: any): Promise<SoundHandle>;
12
+ /** audio.sfx body: cooldown, voice limit, variant pick, jitter, then start the source */
13
+ export function playSound(audio: any, name: any, opts: any): SoundHandle;
14
+ /** A playing sound. engine.audio.sfx / play return one; the game keeps it to stop, fade or move the sound */
15
+ export class SoundHandle {
16
+ /** Sound name (sfx) or file path (play) */
17
+ name: any;
18
+ /** The voice's GainNode (volume of this one sound) @type {any} */
19
+ gain: any;
20
+ /** The PannerNode of a positional sound, else null @type {any} */
21
+ panner: any;
22
+ /** The AudioBufferSourceNode once a file started (null for synths and while loading) @type {any} */
23
+ source: any;
24
+ /** Still sounding (not stopped and not finished)? @returns {boolean} */
25
+ get playing(): boolean;
26
+ /**
27
+ * Move a positional sound: a position, or an Object3D to follow every frame (no effect on a non-positional sound)
28
+ * @param {any} at
29
+ * @returns {this}
30
+ */
31
+ setPosition(at: any): this;
32
+ /**
33
+ * Fade this sound's volume to `to` (0-1) over `seconds`; it keeps playing (use stop to end it)
34
+ * @param {number} to
35
+ * @param {number} [seconds]
36
+ * @returns {this}
37
+ * @example h.fade(0.2, 1.5);
38
+ */
39
+ fade(to: number, seconds?: number): this;
40
+ /**
41
+ * Stop, fading out over `fade` seconds (0 = at once)
42
+ * @param {number} [fade]
43
+ * @returns {void}
44
+ * @example const h = engine.audio.sfx('engine-hum', { loop: true }); h.stop(1);
45
+ */
46
+ stop(fade?: number): void;
47
+ }