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,592 @@
1
+ // Collision, real physics, camera.
2
+ import type { Object3D, Vector3, DirXZ, Vec3Like, Ease, Handle, PositionLike } from './common';
3
+ import type { Engine, ModuleDef } from './core';
4
+ import type { Input } from './generated/core/Input';
5
+ import type { Character } from './gameplay';
6
+
7
+ // ======================================================================
8
+ // Lightweight collision collision() → engine.collision
9
+ // ======================================================================
10
+
11
+ export interface CollisionOptions {
12
+ /** Max walkable slope (height difference / horizontal distance), default 1.1 */
13
+ maxClimb?: number;
14
+ /** A camera above this height (meters) is not considered blocked by trees, default 5 */
15
+ canopyHeight?: number;
16
+ /** Margin between the camera and obstacles (meters), default 0.5 */
17
+ cameraPad?: number;
18
+ /** Nearest camera distance (meters), default 1.5 */
19
+ cameraMin?: number;
20
+ /** Height above the water surface (meters) at which it counts as walkable, default 0.2 */
21
+ walkableWaterMargin?: number;
22
+ /** What camera occlusion checks: 'colliders' (default) | 'meshes' registered static meshes (engine.rays) | 'both' */
23
+ cameraOcclusion?: 'colliders' | 'meshes' | 'both';
24
+ }
25
+ /** Circle collider: center x/z, radius r, height h (meters) */
26
+ export interface CircleCollider { x: number; z: number; r: number; h: number }
27
+ /** Box collider: center x/z, half width hw, half depth hd, rotation around Y rot (radians), height h, bottom height y (meters) */
28
+ export interface BoxCollider { x: number; z: number; hw: number; hd: number; rot: number; h: number; y?: number; [k: string]: any }
29
+
30
+ /** Parameters of addCircle() (meters) */
31
+ export interface CircleColliderOptions {
32
+ /** Radius, default 0.5 */
33
+ radius?: number;
34
+ /** Height, default 6 */
35
+ height?: number;
36
+ }
37
+ /** Parameters of addBox() (meters, radians) */
38
+ export interface BoxColliderOptions {
39
+ /** Half width (X direction), default 1 */
40
+ halfWidth?: number;
41
+ /** Half depth (Z direction), default 1 */
42
+ halfDepth?: number;
43
+ /** Rotation around the Y axis (radians), default 0 */
44
+ rotation?: number;
45
+ /** Height, default 6 */
46
+ height?: number;
47
+ /** Bottom height of the box; if omitted it sits on the ground (give it for walls placed on platforms in a level) */
48
+ y?: number;
49
+ }
50
+
51
+ /** engine.collision (lightweight collision: no walking through things, the camera is not blocked). Real physics is a separate module, engine.rigid */
52
+ export interface Collision {
53
+ maxClimb: number;
54
+ canopyHeight: number;
55
+ cameraPad: number;
56
+ cameraMin: number;
57
+ walkableWaterMargin: number;
58
+ /** What camera occlusion checks (see CollisionOptions.cameraOcclusion) */
59
+ cameraOcclusion: 'colliders' | 'meshes' | 'both';
60
+ /** Circle colliders added by hand */
61
+ circles: CircleCollider[];
62
+ /** Box colliders added by hand */
63
+ boxes: BoxCollider[];
64
+ /** +1 each time a static collider is added or removed */
65
+ version: number;
66
+ /** Add a circle collider (pillar, campfire): position is the center, e.g. addCircle(mesh, { radius: 1 }). Returns a handle { remove() } */
67
+ addCircle(position: PositionLike, opts?: CircleColliderOptions): Handle;
68
+ /** Add a box collider (house, fence): position is the center, e.g. addBox(house, { halfWidth: 3, halfDepth: 2, rotation: 0.3 }). Returns a handle { remove() } */
69
+ addBox(position: PositionLike, opts?: BoxColliderOptions): Handle;
70
+ /** Add a thin wall along a -> b (fence). Options: thickness (default 0.3), height, y. A gap between segments is a gate. Returns a handle { remove() } */
71
+ addSegment(a: PositionLike, b: PositionLike, opts?: { thickness?: number; height?: number; y?: number }): Handle;
72
+ /** Mark ground impassable where fn(x, z) is true (river, lava); fn must be pure. bounds skips fn outside it. Returns a handle { remove() } */
73
+ addBlocked(fn: (x: number, z: number) => boolean, opts?: { bounds?: { minX: number; maxX: number; minZ: number; maxZ: number } }): Handle;
74
+ /** Is a character of this radius touching addBlocked ground at (x, z) */
75
+ blockedAt(x: number, z: number, radius?: number): boolean;
76
+ /** Add a collider from an object's bounding box, pad expands outward (meters). Returns a handle { remove() } */
77
+ addObject(obj: Object3D, opts?: { pad?: number }): Handle;
78
+ /** Iterate all static colliders added by hand */
79
+ forEachStatic(fn: (type: 'box' | 'circle', data: any) => void): void;
80
+ /** Whether someone can stand at this position (for pathfinding): not in water, not too steep, not inside an obstacle. radius is the character radius (meters, default engine.movement.radius) */
81
+ walkable(position: PositionLike, opts?: { radius?: number }): boolean;
82
+ /** walkable with plain numbers, allocating nothing (A* inner loops); radius defaults to engine.movement.radius */
83
+ walkableAt(x: number, z: number, radius?: number): boolean;
84
+ /** Line of sight with height: is the 3D segment a -> b free of boxes, circles and terrain trees? radius fattens the line; addBlocked water is ignored. Give eye heights in a / b */
85
+ lineClear(a: PositionLike, b: PositionLike, opts?: { radius?: number }): boolean;
86
+ }
87
+
88
+ // ======================================================================
89
+ // Real physics rigid() → engine.rigid
90
+ // ======================================================================
91
+
92
+ export interface RigidOptions {
93
+ /** Gravity (m/s², negative points down), default -9.81 */
94
+ gravity?: number;
95
+ /** How many rings of chunks around the player get terrain colliders, default 1 */
96
+ terrainRing?: number;
97
+ /** Whether there is buoyancy, default true */
98
+ buoyancy?: boolean;
99
+ /** Buoyancy strength (1 = just floats), default 1.6 */
100
+ buoyancyForce?: number;
101
+ /** Drag in water, default 2.5 */
102
+ waterDrag?: number;
103
+ /** Buoyancy "waterline": an object starts floating when its center is this many meters below the water surface, default 0.3 */
104
+ floatLine?: number;
105
+ /** Buoyancy reaches its maximum this many meters further down, default 0.8 */
106
+ floatDepth?: number;
107
+ /** Height (meters) of vegetation collision pillars (tree trunks), default 6 */
108
+ treeColliderHeight?: number;
109
+ /** Trunks get collision cylinders only in chunks within this many meters of the player or a moving rigid body (the rest are covered by engine.collision for characters), default 16 */
110
+ treeRadius?: number;
111
+ /** Player capsule size (meters), default computed from engine.movement radius / height */
112
+ playerCapsule?: { halfHeight: number; radius: number };
113
+ }
114
+ /** Parameters for adding a physics body */
115
+ export interface RigidBodyOptions {
116
+ /** Mass (kilograms), default 1 */
117
+ mass?: number;
118
+ /** Friction, default 0.7 */
119
+ friction?: number;
120
+ /** Restitution 0–1, default 0.1 */
121
+ restitution?: number;
122
+ /** Linear damping, default 0.05 */
123
+ damping?: number;
124
+ /** Angular damping, default 0.1 */
125
+ angularDamping?: number;
126
+ /** Fixed in place (only blocks other things) */
127
+ fixed?: boolean;
128
+ }
129
+ /** Parameters of addBox() */
130
+ export interface RigidBoxOptions extends RigidBodyOptions {
131
+ /** Size [width, height, depth] (meters); if omitted, taken from the model's bounding box */
132
+ size?: number[];
133
+ }
134
+ /** Parameters of addBall() */
135
+ export interface RigidBallOptions extends RigidBodyOptions {
136
+ /** Radius (meters); if omitted, taken from the model's bounding box */
137
+ radius?: number;
138
+ }
139
+ /** A physics body (the handle returned by addBox / addBall / addHull) */
140
+ export interface RigidEntry extends Handle {
141
+ /** Rapier rigid body (translation(), mass(), setLinvel()…) */
142
+ body: any;
143
+ /** Rapier collider */
144
+ collider: any;
145
+ /** The matching three.js model (position is written by physics every step) */
146
+ mesh: Object3D;
147
+ /** Same as mesh (the name consistent with player.object, ent.object) */
148
+ object: Object3D;
149
+ /** Whether it is being simulated (frozen when too far from the player) */
150
+ enabled: boolean;
151
+ /** Volume (cubic meters, used for buoyancy) */
152
+ volume: number;
153
+ damping: number;
154
+ angularDamping: number;
155
+ wet?: boolean;
156
+ /** Remove this rigid body (the model was passed in by you and is not deleted; call engine.remove(entry.object) when done). Casting / receiving shadows follows the model's own castShadow / receiveShadow */
157
+ remove(): void;
158
+ }
159
+
160
+ /** engine.rigid (real physics; bodies can only be added after start(), or in the engine:ready event) */
161
+ export interface RigidBodies {
162
+ /** Is the physics engine ready (downloaded and initialized at start()) */
163
+ readonly ready: boolean;
164
+ /** All physics bodies */
165
+ bodies: RigidEntry[];
166
+ gravity: number;
167
+ terrainRing: number;
168
+ buoyancy: boolean;
169
+ buoyancyForce: number;
170
+ waterDrag: number;
171
+ floatLine: number; floatDepth: number; treeColliderHeight: number; treeRadius: number;
172
+ /** Rapier library */
173
+ R: any;
174
+ /** Rapier world */
175
+ world: any;
176
+ /** Add a box (crate). Returns null if not ready */
177
+ addBox(mesh: Object3D, opts?: RigidBoxOptions): RigidEntry | null;
178
+ /** Add a ball */
179
+ addBall(mesh: Object3D, opts?: RigidBallOptions): RigidEntry | null;
180
+ /** Add a convex hull (irregular objects such as rocks and barrels) */
181
+ addHull(mesh: Object3D, opts?: RigidBodyOptions): RigidEntry | null;
182
+ /** Give it a push: impulse vector impulse (Vector3 / [x, y, z] / { x, y, z }), e.g. impulse(ball, [0, 3, 5]) */
183
+ impulse(entry: RigidEntry, impulse: Vec3Like): void;
184
+ /** Teleport to position (velocity is zeroed) */
185
+ setPosition(entry: RigidEntry, position: PositionLike): void;
186
+ /** The player's Rapier kinematic body and capsule collider (follow the player position every step; used for collision when mover: 'rapier'; the capsule is off while driving) */
187
+ playerBody: any;
188
+ playerCollider: any;
189
+ /** Player capsule size (meters) */
190
+ playerCapsule: { halfHeight: number; radius: number };
191
+ /** Is the physics ground under position built (always true without chunked terrain; with mover: 'rapier' and not yet built, 'simple' is used temporarily) */
192
+ groundReady(position: PositionLike): boolean;
193
+ /** All vehicles */
194
+ vehicles: Vehicle[];
195
+ /** Turn a model into a drivable car (Rapier vehicle controller); remove it with vehicle.remove() (anyone inside gets out first). Returns null if not ready */
196
+ addVehicle(mesh: Object3D, opts: VehicleOptions): Vehicle | null;
197
+ /** Statistics */
198
+ readonly stats: { bodies: number; active: number; colliders: number };
199
+ }
200
+
201
+ // ---------- Vehicles ----------
202
+ /** A wheel: position relative to the body (meters), radius (meters), steer can steer, drive is powered, object is the wheel model that spins */
203
+ export interface VehicleWheel { position: Vec3Like; radius: number; steer?: boolean; drive?: boolean; object?: Object3D }
204
+ /** Parameters of rigid.addVehicle() */
205
+ export interface VehicleOptions {
206
+ /** Stable id (default 'vehicle1', 'vehicle2'... in creation order): saves name the player's vehicle by it; give one when the creation order varies */
207
+ id?: string;
208
+ /** Wheels (at least 3) */
209
+ wheels: VehicleWheel[];
210
+ /** Mass (kilograms) */
211
+ mass?: number;
212
+ /** Throttle force, default 800 */
213
+ engineForce?: number;
214
+ /** Brake force, default 20 */
215
+ brakeForce?: number;
216
+ /** Max steering angle (radians), default 0.5 */
217
+ maxSteer?: number;
218
+ /** Suspension: rest natural length (meters), stiffness, damping */
219
+ suspension?: { rest?: number; stiffness?: number; damping?: number };
220
+ /** Seat (relative to the body, meters): the player gets out beside it */
221
+ seat?: Vec3Like;
222
+ /** Camera distance and height while driving (meters) */
223
+ camera?: { distance?: number; height?: number };
224
+ /** Body collision box size [width, height, depth] (meters); if omitted, taken from the model's bounding box (wheels excluded) */
225
+ size?: number[];
226
+ /** Tire grip, default 1.5 */
227
+ friction?: number;
228
+ /** Distance from the side of the body when getting out (meters), default 0.8 */
229
+ exitOffset?: number;
230
+ }
231
+ /** A vehicle (returned by rigid.addVehicle, faces the model's +Z). player.enter(vehicle) gets in; with interactions installed, press the interact key nearby to get in / out */
232
+ export interface Vehicle extends RigidEntry {
233
+ /** Stable id (rigid.addVehicle({ id })); saves name the player's vehicle by it */
234
+ readonly id: string;
235
+ /** Body model (the mesh you passed in) */
236
+ object: Object3D;
237
+ /** Rapier rigid body */
238
+ body: any;
239
+ /** Rapier vehicle controller (DynamicRayCastVehicleController) */
240
+ controller: any;
241
+ wheels: VehicleWheel[];
242
+ /** Current speed (m/s) */
243
+ readonly speed: number;
244
+ /** Who is driving (null if nobody) */
245
+ driver: Character | null;
246
+ /** Camera parameters while driving */
247
+ camera?: { distance?: number; height?: number };
248
+ /** Controls: throttle -1..1, steer -1..1 (right is positive), brake 0–1 */
249
+ drive(throttle: number, steer: number, brake?: number): void;
250
+ /** World position of the seat */
251
+ seatPosition(): Vector3;
252
+ /** Where to get out (outside the door on the driver's side, world coordinates) */
253
+ exitPosition(): Vector3;
254
+ }
255
+
256
+ // ======================================================================
257
+ // Skeletal animation state machine Animator (returned by engine.assets.animate)
258
+ // ======================================================================
259
+
260
+ /** An animation state: clip is the clip name; or blend is a blend tree (blends several clips by the param parameter); loop: false is a one-shot clip */
261
+ export interface AnimatorState {
262
+ /** Clip name (the clip name in the glTF) */
263
+ clip?: string;
264
+ /** Blend tree: at the parameter value at it is fully this clip, in between they blend proportionally, e.g. [{ clip: 'Walk', at: 1.5 }, { clip: 'Run', at: 6 }] */
265
+ blend?: { clip: string; at: number }[];
266
+ /** Which parameter the blend tree reads (set by anim.set), default 'speed' */
267
+ param?: string;
268
+ /** Align the strides of blended clips, default true */
269
+ sync?: boolean;
270
+ /** Loop, default true; with false the anim:end event fires when it finishes */
271
+ loop?: boolean;
272
+ /** Which state a one-shot clip goes to when it finishes */
273
+ then?: string;
274
+ /** go() cannot interrupt it while playing */
275
+ lock?: boolean;
276
+ /**
277
+ * For sync(): gameplay seconds -> clip seconds. A number = the gameplay length the whole clip is stretched over;
278
+ * [[gameT, clipT], ...] = piecewise linear (land the swing on the hit phase). Without it clip seconds = t
279
+ */
280
+ timing?: number | [number, number][];
281
+ }
282
+ /** What an Animator is showing (anim.describe(), describe().player.anim) */
283
+ export interface AnimatorInfo {
284
+ state: string | null;
285
+ /** Clip name as written in the state */
286
+ clip: string | null;
287
+ /** Clip seconds */
288
+ time: number;
289
+ /** 0-1 through the clip */
290
+ progress: number;
291
+ /** true while sync() drives it */
292
+ driven: boolean;
293
+ /** Last gameplay t passed to sync (only while driven) */
294
+ t?: number;
295
+ /** Share of each fading state (sums to 1) */
296
+ weights: Record<string, number>;
297
+ }
298
+ /** Animation state machine parameters */
299
+ export interface AnimatorOptions {
300
+ /** Default transition seconds, default 0.25 (style pack style.character.animation.fade) */
301
+ fade?: number;
302
+ /** States: name → state */
303
+ states?: Record<string, AnimatorState>;
304
+ /** Transition seconds for specific pairs: { 'jump>fall': 0.1, '*>idle': 0.3 } */
305
+ transitions?: Record<string, number>;
306
+ /** Initial parameter values */
307
+ params?: Record<string, number>;
308
+ }
309
+ /** Skeletal animation state machine (returned by engine.assets.animate(model, config)) */
310
+ export declare class Animator {
311
+ constructor(engine: Engine, root: Object3D, opts?: AnimatorOptions);
312
+ /** three.js AnimationMixer */
313
+ mixer: any;
314
+ /** clip name → three.js AnimationAction */
315
+ actions: Map<string, any>;
316
+ /** Current state name */
317
+ state: string | null;
318
+ /** State configuration (states can be added directly) */
319
+ states: Record<string, AnimatorState>;
320
+ /** Parameters (used by blend trees) */
321
+ params: Record<string, number>;
322
+ /** Set a parameter, e.g. set('speed', 3) */
323
+ set(param: string, value: number): this;
324
+ /** Switch to a state (fade is the transition seconds); null (dev warning) if there is no such state / clip; ignored while sync() drives a state */
325
+ go(state: string, fade?: number): any;
326
+ /** One-shot clip: state name or clip name, returns to then or the previous state when done; go() cannot interrupt it while playing */
327
+ action(name: string, fade?: number): any;
328
+ /**
329
+ * Gameplay drives the clock: show state at gameplay time t (fixed-step seconds) through its timing.
330
+ * The clip never advances or ends by itself and go() leaves it alone; sync(null) hands control back
331
+ */
332
+ sync(state: string | null, t?: number): any;
333
+ /** What is showing: state, clip, clip time, progress, driven, weights */
334
+ describe(): AnimatorInfo;
335
+ /**
336
+ * Check the mapping against the action names the game plays: each problem as text with its fix ([] = all will play).
337
+ * @example anim.check(['idle', 'walk', 'attack', 'hurt'])
338
+ */
339
+ check(actions?: string[]): string[];
340
+ /** Stop the per-frame update when no longer needed */
341
+ dispose(): void;
342
+ }
343
+
344
+ // ======================================================================
345
+ // Camera → engine.cameraRig (install one kind, switch at runtime with engine.setCamera)
346
+ // ======================================================================
347
+
348
+ /** Camera kinds: 'follow' third person | 'firstPerson' first person | 'fixed' fixed shot | 'rts' strategy top-down */
349
+ export type CameraKind = 'follow' | 'firstPerson' | 'fixed' | 'rts';
350
+
351
+ /** Interface shared by all cameras */
352
+ export interface CameraRigBase {
353
+ engine: Engine;
354
+ /** Current kind (the first argument of engine.setCamera) */
355
+ kind: CameraKind;
356
+ /** The object being followed */
357
+ target: Object3D | null;
358
+ /** Follow someone (called automatically when the player is created), null to cancel. opts temporarily changes distance / height (used while driving), restored when the target changes */
359
+ follow(obj: Object3D | null, opts?: { distance?: number; height?: number }): void;
360
+ /** The "forward" direction on the horizontal plane (player movement is relative to it) */
361
+ forward(): DirXZ;
362
+ /** The "right" direction on the horizontal plane */
363
+ right(): DirXZ;
364
+ /** Where the world loads around */
365
+ focusPoint(): Vector3;
366
+ /** Update the camera every frame */
367
+ update(dt: number, input: Input): void;
368
+ /** Called when a cutscene takeover starts / ends */
369
+ onOverride?(on: boolean): void;
370
+ /** Called when this camera is switched in (switched: switched at runtime) */
371
+ onEnter?(switched?: boolean): void;
372
+ /** Called when this camera is switched out */
373
+ onExit?(): void;
374
+ }
375
+
376
+ export interface FollowCameraOptions {
377
+ /** Which side of the focus the camera sits on (radians), default 0.8: camera = focus + (sin yaw, cos yaw) × distance, it looks along forward() = -(sin yaw, cos yaw). Behind a character facing f: yaw = f + PI */
378
+ yaw?: number;
379
+ /** Pitch angle (radians), default 0.42 */
380
+ pitch?: number;
381
+ /** Distance (meters), default 13 */
382
+ distance?: number;
383
+ /** Zoom range (meters) */
384
+ minDistance?: number;
385
+ maxDistance?: number;
386
+ /** How high above the character to look at (meters), default 1.4 */
387
+ height?: number;
388
+ /** Follow smoothing, default 10 */
389
+ smoothing?: number;
390
+ /** Drag sensitivity, default 1 */
391
+ sensitivity?: number;
392
+ /** Pitch range (radians) */
393
+ minPitch?: number;
394
+ maxPitch?: number;
395
+ /** Zoom ratio per wheel notch, default 0.1 */
396
+ zoomStep?: number;
397
+ /** Minimum camera height above the ground (meters), default 1.2 */
398
+ groundClearance?: number;
399
+ /** Invert vertical */
400
+ invertY?: boolean;
401
+ /** Lock the pitch angle (top-down games) */
402
+ lockPitch?: boolean;
403
+ /** Over-the-shoulder offset: meters to the right of the target the camera aims (negative = left shoulder), default 0 */
404
+ shoulder?: number;
405
+ /** Click locks the mouse; mouse motion turns the view without dragging (Esc releases), default false */
406
+ pointerLock?: boolean;
407
+ /** The press that locks the mouse is not delivered as Mouse0 / a click (default true); false delivers it too */
408
+ swallowLockClick?: boolean;
409
+ }
410
+ /** Third-person follow camera */
411
+ export interface FollowCamera extends CameraRigBase, Required<Omit<FollowCameraOptions, 'lockPitch'>> {
412
+ /** Smoothed follow point */
413
+ focus: Vector3;
414
+ lockPitch?: boolean;
415
+ /** false: no occlusion handling */
416
+ avoidOcclusion?: boolean;
417
+ /** Lock-on framing set by frame() */
418
+ framing: { target: Object3D | Vec3Like; strength: number } | null;
419
+ /** Lock-on framing: turn yaw each frame toward "behind the followed object, looking at target"; mouse yaw is ignored meanwhile; null hands yaw back. strength default 6 (1/s) */
420
+ frame(target: Object3D | Vec3Like | null, opts?: { strength?: number }): void;
421
+ }
422
+
423
+ export interface FirstPersonCameraOptions {
424
+ /** Eye height above the feet (meters), default 1.6 */
425
+ height?: number;
426
+ /** Mouse sensitivity, default 1 */
427
+ sensitivity?: number;
428
+ /** Field of view (degrees); unchanged if omitted */
429
+ fov?: number | null;
430
+ /** Walking bob amplitude (meters), 0 off, default 0.04 */
431
+ headBob?: number;
432
+ /** Bobs per meter */
433
+ bobFrequency?: number;
434
+ /** Hide the character itself (its shadow remains), default true */
435
+ hideTarget?: boolean;
436
+ /** Layer number used for hiding 0–31 */
437
+ hideLayer?: number;
438
+ /** Click to lock the mouse, default true */
439
+ pointerLock?: boolean;
440
+ /** The press that locks the mouse is not delivered as Mouse0 / a click (default true); false delivers it too */
441
+ swallowLockClick?: boolean;
442
+ /** Initial heading (radians) */
443
+ yaw?: number;
444
+ pitch?: number;
445
+ /** Look down / up limit (radians) */
446
+ minPitch?: number;
447
+ maxPitch?: number;
448
+ /** Turn range left / right [min, max] (radians), unlimited by default */
449
+ yawLimits?: number[] | null;
450
+ /** Smoothing of the camera following the body */
451
+ smoothing?: number;
452
+ /** Invert vertical */
453
+ invertY?: boolean;
454
+ }
455
+ /** First-person camera */
456
+ export interface FirstPersonCamera extends CameraRigBase, Required<Omit<FirstPersonCameraOptions, 'fov'>> {
457
+ /** Eye position */
458
+ eye: Vector3;
459
+ /** Turn toward a world position (Vector3 / object / [x, y, z] / { x, y, z }) */
460
+ lookAt(position: PositionLike): void;
461
+ }
462
+
463
+ /** Fixed shot */
464
+ export interface CameraShot {
465
+ /** Camera position */
466
+ position: Vec3Like;
467
+ /** Fixed point to look at (if omitted, it turns its head with the player) */
468
+ lookAt?: Vec3Like;
469
+ /** Turn its head with the player */
470
+ track?: boolean;
471
+ /** Field of view (degrees) */
472
+ fov?: number;
473
+ /** Position used to judge the "nearest shot", defaults to position */
474
+ at?: Vec3Like;
475
+ /** How high above the character to look at (meters) */
476
+ trackHeight?: number;
477
+ }
478
+ export interface FixedCameraOptions {
479
+ /** Shots: name → shot */
480
+ shots?: Record<string, CameraShot>;
481
+ /** Initial shot name */
482
+ start?: string | null;
483
+ /** Automatic switching: false | 'nearest' (pick the one nearest to the player) */
484
+ auto?: false | 'nearest';
485
+ /** Check interval for automatic switching (seconds) */
486
+ autoInterval?: number;
487
+ /** How many meters closer a new shot must be to switch (prevents flipping back and forth) */
488
+ hysteresis?: number;
489
+ /** Transition seconds for trigger-zone switches (0 = hard cut) */
490
+ triggerBlend?: number;
491
+ /** How high above the character a track shot looks (meters) */
492
+ trackHeight?: number;
493
+ /** Head-follow smoothing */
494
+ trackSmoothing?: number;
495
+ /** Keep the direction when switching shots until the direction key is released */
496
+ holdDirection?: boolean;
497
+ /** Transition easing */
498
+ ease?: Ease;
499
+ }
500
+ /** Fixed-shot camera */
501
+ export interface FixedCamera extends CameraRigBase {
502
+ /** All shots */
503
+ shots: Record<string, any>;
504
+ /** Current shot name */
505
+ current: string | null;
506
+ auto: false | 'nearest';
507
+ autoInterval: number;
508
+ hysteresis: number;
509
+ triggerBlend: number;
510
+ trackHeight: number;
511
+ trackSmoothing: number;
512
+ holdDirection: boolean;
513
+ ease: Ease;
514
+ /** Add / replace a shot */
515
+ add(name: string, shot: CameraShot): this;
516
+ /** Cut to a shot immediately */
517
+ cut(name: string): void;
518
+ /** Transition smoothly to a shot (over seconds seconds); the Promise resolves when done */
519
+ blend(name: string, seconds?: number, ease?: Ease): Promise<void>;
520
+ /** Name of the shot nearest to a point */
521
+ nearest(p: Vector3): string | null;
522
+ }
523
+
524
+ export interface RtsCameraOptions {
525
+ /** Camera height above the focus (meters), default 30 */
526
+ height?: number;
527
+ /** Zoom range (meters) */
528
+ minHeight?: number;
529
+ maxHeight?: number;
530
+ /** Pitch down angle (radians, π/2 = straight down), default 0.95 */
531
+ angle?: number;
532
+ /** Initial horizontal heading (radians) */
533
+ yaw?: number;
534
+ /** Pan speed multiplier */
535
+ panSpeed?: number;
536
+ /** Drag with the mouse to pan, default true */
537
+ dragPan?: boolean;
538
+ /** Pan at the screen edge, default false */
539
+ edgePan?: boolean;
540
+ /** Edge width (fraction of the screen) */
541
+ edgeSize?: number;
542
+ /** Focus range (meters) */
543
+ bounds?: { minX?: number; maxX?: number; minZ?: number; maxZ?: number } | null;
544
+ /** Rotate keys, false turns rotation off */
545
+ rotateKeys?: { left?: string[]; right?: string[] } | false;
546
+ /** Rotation speed (radians/second) */
547
+ rotateSpeed?: number;
548
+ /** Zoom ratio per wheel notch */
549
+ zoomStep?: number;
550
+ /** Smoothing */
551
+ smoothing?: number;
552
+ /** Field of view (degrees); unchanged if omitted */
553
+ fov?: number | null;
554
+ /** Manual panning is not allowed while following */
555
+ followLock?: boolean;
556
+ /** Initial focus (position) */
557
+ start?: PositionLike | null;
558
+ }
559
+ /** Strategy top-down camera */
560
+ export interface RtsCamera extends CameraRigBase, Required<Omit<RtsCameraOptions, 'rotateKeys' | 'fov' | 'start'>> {
561
+ /** Is it following target */
562
+ following: boolean;
563
+ /** Focus (on the ground) */
564
+ focus: Vector3;
565
+ /** Can it rotate */
566
+ rotate: boolean;
567
+ /** Move the view to position (instant: true skips smoothing) */
568
+ moveTo(position: PositionLike, opts?: { instant?: boolean }): void;
569
+ /** Screen coordinates (-1..1) → a point on the ground, null if nothing is hit */
570
+ screenToGround(ndcX: number, ndcY: number): Vector3 | null;
571
+ }
572
+
573
+ /**
574
+ * engine.cameraRig: one of four cameras. The shared methods (follow, forward, right) always work;
575
+ * properties specific to one camera (distance, cut(), moveTo()…) only exist when that camera is installed.
576
+ */
577
+ export type CameraRig = CameraRigBase
578
+ & Partial<Omit<FollowCamera, keyof CameraRigBase>>
579
+ & Partial<Omit<FirstPersonCamera, keyof CameraRigBase | 'height' | 'smoothing'>>
580
+ & Partial<Omit<FixedCamera, keyof CameraRigBase | 'trackHeight' | 'add' | 'ease' | 'auto'>>
581
+ & Partial<Omit<RtsCamera, keyof CameraRigBase | 'height' | 'smoothing' | 'focus'>>
582
+ & {
583
+ /** Fixed shot: add a shot */
584
+ add?(name: string, shot: CameraShot): any;
585
+ ease?: Ease;
586
+ auto?: false | 'nearest';
587
+ };
588
+
589
+ /** Fixed-shot switch event */
590
+ export interface CameraShotEvent { name: string }
591
+
592
+ export type CameraModule = ModuleDef<CameraRig>;