@vgai/engine 0.5.21 → 0.5.23

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 (339) hide show
  1. package/README.md +6 -3
  2. package/dist/adapter/adapter-module.d.ts.map +1 -1
  3. package/dist/adapter/adapter-module.js +2 -4
  4. package/dist/adapter/adapter-surface.d.ts +1 -1
  5. package/dist/adapter/adapter-surface.js +1 -1
  6. package/dist/adapter/authoring.d.ts +19 -21
  7. package/dist/adapter/authoring.d.ts.map +1 -1
  8. package/dist/adapter/authoring.js +2 -2
  9. package/dist/adapter/binding.d.ts +341 -0
  10. package/dist/adapter/binding.d.ts.map +1 -0
  11. package/dist/adapter/binding.js +148 -0
  12. package/dist/adapter/colyseus-networking-adapter.d.ts.map +1 -1
  13. package/dist/adapter/colyseus-networking-adapter.js +23 -4
  14. package/dist/adapter/entrypoint-selection-readers.d.ts +24 -0
  15. package/dist/adapter/entrypoint-selection-readers.d.ts.map +1 -0
  16. package/dist/adapter/entrypoint-selection-readers.js +63 -0
  17. package/dist/adapter/entrypoint-selection-source.d.ts.map +1 -1
  18. package/dist/adapter/entrypoint-selection-source.js +1 -44
  19. package/dist/adapter/finders/scenes-from-entrypoint-selection.d.ts.map +1 -1
  20. package/dist/adapter/finders/scenes-from-entrypoint-selection.js +1 -52
  21. package/dist/adapter/host-context.d.ts +46 -15
  22. package/dist/adapter/host-context.d.ts.map +1 -1
  23. package/dist/adapter/host-context.js +2 -9
  24. package/dist/adapter/index.d.ts +11 -12
  25. package/dist/adapter/index.d.ts.map +1 -1
  26. package/dist/adapter/index.js +9 -10
  27. package/dist/adapter/ingest/game-contract.d.ts +0 -3
  28. package/dist/adapter/ingest/game-contract.d.ts.map +1 -1
  29. package/dist/adapter/ingest/game-contract.js +0 -3
  30. package/dist/adapter/ingest/scene-capture.d.ts +19 -23
  31. package/dist/adapter/ingest/scene-capture.d.ts.map +1 -1
  32. package/dist/adapter/ingest/scene-capture.js +143 -17
  33. package/dist/adapter/ingest/visible-capture-window.d.ts +34 -0
  34. package/dist/adapter/ingest/visible-capture-window.d.ts.map +1 -1
  35. package/dist/adapter/manifest-interpreter.d.ts +59 -0
  36. package/dist/adapter/manifest-interpreter.d.ts.map +1 -0
  37. package/dist/adapter/manifest-interpreter.js +50 -0
  38. package/dist/adapter/native-debug-module.d.ts +71 -3
  39. package/dist/adapter/native-debug-module.d.ts.map +1 -1
  40. package/dist/adapter/native-debug-module.js +146 -10
  41. package/dist/adapter/rapier-physics-adapter.d.ts +31 -1
  42. package/dist/adapter/rapier-physics-adapter.d.ts.map +1 -1
  43. package/dist/adapter/rapier-physics-adapter.js +50 -36
  44. package/dist/adapter/renderer-config.d.ts +3 -3
  45. package/dist/adapter/renderer-config.js +3 -3
  46. package/dist/adapter/root-adapter.d.ts +7 -7
  47. package/dist/adapter/root-adapter.js +4 -4
  48. package/dist/adapter/system-adapter.d.ts +45 -7
  49. package/dist/adapter/system-adapter.d.ts.map +1 -1
  50. package/dist/adapter/system-seam-contract.d.ts +3 -3
  51. package/dist/adapter/system-seam-contract.js +3 -3
  52. package/dist/adapter/system-slot.d.ts +168 -0
  53. package/dist/adapter/system-slot.d.ts.map +1 -0
  54. package/dist/adapter/system-slot.js +229 -0
  55. package/dist/adapter/transform.d.ts +11 -1
  56. package/dist/adapter/transform.d.ts.map +1 -1
  57. package/dist/ai/navigation.d.ts +17 -1
  58. package/dist/ai/navigation.d.ts.map +1 -1
  59. package/dist/ai/navigation.js +26 -5
  60. package/dist/animation/anim-graph-types.d.ts +11 -3
  61. package/dist/animation/anim-graph-types.d.ts.map +1 -1
  62. package/dist/animation/theatre-clock-binding.d.ts +4 -4
  63. package/dist/animation/theatre-clock-binding.js +4 -4
  64. package/dist/animation/xstate-animation-binding.d.ts.map +1 -1
  65. package/dist/animation/xstate-animation-binding.js +2 -2
  66. package/dist/animation/xstate-animation-meta.d.ts +13 -0
  67. package/dist/animation/xstate-animation-meta.d.ts.map +1 -1
  68. package/dist/animation/xstate-animation-meta.js +14 -0
  69. package/dist/asset-formats/index.d.ts +4 -7
  70. package/dist/asset-formats/index.d.ts.map +1 -1
  71. package/dist/asset-formats/index.js +4 -7
  72. package/dist/asset-formats/render-env.d.ts +5 -8
  73. package/dist/asset-formats/render-env.d.ts.map +1 -1
  74. package/dist/asset-formats/render-env.js +3 -6
  75. package/dist/asset-parse-error.d.ts +2 -5
  76. package/dist/asset-parse-error.d.ts.map +1 -1
  77. package/dist/asset-parse-error.js +2 -5
  78. package/dist/audio/bus-mixer.d.ts +101 -0
  79. package/dist/audio/bus-mixer.d.ts.map +1 -0
  80. package/dist/audio/bus-mixer.js +115 -0
  81. package/dist/canvas-react/index.d.ts +5 -12
  82. package/dist/canvas-react/index.d.ts.map +1 -1
  83. package/dist/canvas-react/index.js +5 -12
  84. package/dist/canvas-react/pixi-react-root-factory.d.ts +34 -21
  85. package/dist/canvas-react/pixi-react-root-factory.d.ts.map +1 -1
  86. package/dist/canvas-react/pixi-react-root-factory.js +274 -36
  87. package/dist/core/countdown-timer.d.ts +118 -0
  88. package/dist/core/countdown-timer.d.ts.map +1 -0
  89. package/dist/core/countdown-timer.js +137 -0
  90. package/dist/core/deferred-commands.d.ts +127 -0
  91. package/dist/core/deferred-commands.d.ts.map +1 -0
  92. package/dist/core/deferred-commands.js +132 -0
  93. package/dist/core/frame-pacing.d.ts +1 -1
  94. package/dist/core/frame-pacing.js +2 -2
  95. package/dist/core/game-loop.d.ts +1 -3
  96. package/dist/core/game-loop.d.ts.map +1 -1
  97. package/dist/core/game-loop.js +1 -3
  98. package/dist/core/seeded-random.d.ts +1 -1
  99. package/dist/core/sim-clock.d.ts +19 -8
  100. package/dist/core/sim-clock.d.ts.map +1 -1
  101. package/dist/core/sim-clock.js +18 -7
  102. package/dist/core/types.d.ts +1 -3
  103. package/dist/core/types.d.ts.map +1 -1
  104. package/dist/defaults.d.ts +6 -14
  105. package/dist/defaults.d.ts.map +1 -1
  106. package/dist/defaults.js +6 -14
  107. package/dist/dev/instruments.d.ts +38 -11
  108. package/dist/dev/instruments.d.ts.map +1 -1
  109. package/dist/dev/instruments.js +81 -11
  110. package/dist/dev/register-render-vitals.d.ts +1 -4
  111. package/dist/dev/register-render-vitals.d.ts.map +1 -1
  112. package/dist/dev/register-render-vitals.js +1 -4
  113. package/dist/dev/render-debug-adapter.d.ts +2 -3
  114. package/dist/dev/render-debug-adapter.d.ts.map +1 -1
  115. package/dist/dev/render-debug-adapter.js +2 -3
  116. package/dist/dev/render-vitals.d.ts +3 -3
  117. package/dist/dev/render-vitals.js +3 -3
  118. package/dist/dev/webgl-frame-capture.d.ts +1 -1
  119. package/dist/dev/webgl-frame-capture.js +1 -1
  120. package/dist/index.d.ts +2 -5
  121. package/dist/index.d.ts.map +1 -1
  122. package/dist/index.js +2 -4
  123. package/dist/input/host-pointer.d.ts +122 -0
  124. package/dist/input/host-pointer.d.ts.map +1 -0
  125. package/dist/input/host-pointer.js +160 -0
  126. package/dist/input/input-manager.d.ts +33 -5
  127. package/dist/input/input-manager.d.ts.map +1 -1
  128. package/dist/input/input-manager.js +48 -13
  129. package/dist/input/rebind-controller.d.ts.map +1 -1
  130. package/dist/input/rebind-controller.js +6 -8
  131. package/dist/input/schema.d.ts.map +1 -1
  132. package/dist/input/schema.js +56 -28
  133. package/dist/manifest/filename.d.ts.map +1 -1
  134. package/dist/manifest/filename.js +8 -12
  135. package/dist/manifest/load.d.ts +10 -10
  136. package/dist/manifest/load.d.ts.map +1 -1
  137. package/dist/manifest/load.js +9 -6
  138. package/dist/manifest/schema.d.ts +17 -21
  139. package/dist/manifest/schema.d.ts.map +1 -1
  140. package/dist/manifest/schema.js +45 -35
  141. package/dist/physics/collider-dimensions.d.ts +8 -12
  142. package/dist/physics/collider-dimensions.d.ts.map +1 -1
  143. package/dist/physics/collider-dimensions.js +8 -12
  144. package/dist/pixi/scene-capture.d.ts +11 -13
  145. package/dist/pixi/scene-capture.d.ts.map +1 -1
  146. package/dist/react/world-state.d.ts +1 -1
  147. package/dist/react/world-state.d.ts.map +1 -1
  148. package/dist/render/directional-shadow-fit.d.ts +88 -0
  149. package/dist/render/directional-shadow-fit.d.ts.map +1 -0
  150. package/dist/render/directional-shadow-fit.js +133 -0
  151. package/dist/render/environment-capture.d.ts +68 -0
  152. package/dist/render/environment-capture.d.ts.map +1 -0
  153. package/dist/render/environment-capture.js +90 -0
  154. package/dist/render/ibl-override-material.d.ts +97 -0
  155. package/dist/render/ibl-override-material.d.ts.map +1 -0
  156. package/dist/render/ibl-override-material.js +114 -0
  157. package/dist/render/light-camera-factory.d.ts +5 -7
  158. package/dist/render/light-camera-factory.d.ts.map +1 -1
  159. package/dist/render/light-camera-factory.js +8 -11
  160. package/dist/render/material-factory.js +1 -1
  161. package/dist/render/render-batch-system.d.ts.map +1 -1
  162. package/dist/render/render-features.d.ts +17 -6
  163. package/dist/render/render-features.d.ts.map +1 -1
  164. package/dist/render/render-features.js +0 -28
  165. package/dist/runtime/create-runtime.d.ts +34 -25
  166. package/dist/runtime/create-runtime.d.ts.map +1 -1
  167. package/dist/runtime/create-runtime.js +218 -93
  168. package/dist/runtime/debug-registry.d.ts +77 -8
  169. package/dist/runtime/debug-registry.d.ts.map +1 -1
  170. package/dist/runtime/debug-registry.js +3 -3
  171. package/dist/runtime/dev-build.d.ts +2 -2
  172. package/dist/runtime/dev-build.js +2 -2
  173. package/dist/runtime/game-input-seams.d.ts +51 -0
  174. package/dist/runtime/game-input-seams.d.ts.map +1 -0
  175. package/dist/runtime/game-input-seams.js +86 -0
  176. package/dist/runtime/game.d.ts +104 -40
  177. package/dist/runtime/game.d.ts.map +1 -1
  178. package/dist/runtime/game.js +119 -61
  179. package/dist/runtime/mount-game.d.ts +0 -16
  180. package/dist/runtime/mount-game.d.ts.map +1 -1
  181. package/dist/runtime/mount-game.js +26 -41
  182. package/dist/runtime/mount-manifest.d.ts +22 -14
  183. package/dist/runtime/mount-manifest.d.ts.map +1 -1
  184. package/dist/runtime/mount-manifest.js +22 -20
  185. package/dist/runtime/playtest.d.ts +22 -0
  186. package/dist/runtime/playtest.d.ts.map +1 -0
  187. package/dist/runtime/playtest.js +12 -0
  188. package/dist/runtime/state-bridge.d.ts +2 -3
  189. package/dist/runtime/state-bridge.d.ts.map +1 -1
  190. package/dist/runtime/state-bridge.js +1 -0
  191. package/dist/setup/setup-audio.d.ts +12 -0
  192. package/dist/setup/setup-audio.d.ts.map +1 -1
  193. package/dist/setup/setup-audio.js +9 -10
  194. package/dist/setup/setup-renderer.d.ts +2 -25
  195. package/dist/setup/setup-renderer.d.ts.map +1 -1
  196. package/dist/setup/setup-renderer.js +2 -31
  197. package/dist/world3d-react/index.d.ts +15 -25
  198. package/dist/world3d-react/index.d.ts.map +1 -1
  199. package/dist/world3d-react/index.js +15 -25
  200. package/dist/world3d-react/r3f-root-factory.d.ts +28 -34
  201. package/dist/world3d-react/r3f-root-factory.d.ts.map +1 -1
  202. package/dist/world3d-react/r3f-root-factory.js +403 -57
  203. package/dist/world3d-react/rapier-physics-bridge.d.ts +30 -17
  204. package/dist/world3d-react/rapier-physics-bridge.d.ts.map +1 -1
  205. package/dist/world3d-react/rapier-physics-bridge.js +143 -58
  206. package/package.json +1 -1
  207. package/schemas/engine-capabilities.json +16 -14
  208. package/schemas/vgai-project.schema.json +35 -26
  209. package/src/adapter/adapter-module.ts +2 -4
  210. package/src/adapter/adapter-surface.ts +1 -1
  211. package/src/adapter/authoring.ts +19 -21
  212. package/src/adapter/binding.ts +468 -0
  213. package/src/adapter/colyseus-networking-adapter.ts +20 -5
  214. package/src/adapter/entrypoint-selection-readers.ts +66 -0
  215. package/src/adapter/entrypoint-selection-source.ts +1 -40
  216. package/src/adapter/finders/scenes-from-entrypoint-selection.ts +1 -48
  217. package/src/adapter/host-context.ts +45 -15
  218. package/src/adapter/index.ts +23 -11
  219. package/src/adapter/ingest/game-contract.ts +0 -3
  220. package/src/adapter/ingest/scene-capture.ts +190 -39
  221. package/src/adapter/ingest/visible-capture-window.ts +35 -0
  222. package/src/adapter/manifest-interpreter.ts +64 -0
  223. package/src/adapter/native-debug-module.ts +248 -15
  224. package/src/adapter/rapier-physics-adapter.ts +76 -20
  225. package/src/adapter/renderer-config.ts +3 -3
  226. package/src/adapter/root-adapter.ts +7 -7
  227. package/src/adapter/system-adapter.ts +43 -8
  228. package/src/adapter/system-seam-contract.ts +3 -3
  229. package/src/adapter/system-slot.ts +291 -0
  230. package/src/adapter/transform.ts +18 -1
  231. package/src/ai/navigation.ts +30 -3
  232. package/src/animation/anim-graph-types.ts +11 -3
  233. package/src/animation/theatre-clock-binding.ts +4 -4
  234. package/src/animation/xstate-animation-binding.ts +2 -2
  235. package/src/animation/xstate-animation-meta.ts +16 -0
  236. package/src/asset-formats/index.ts +4 -7
  237. package/src/asset-formats/render-env.ts +3 -6
  238. package/src/asset-parse-error.ts +2 -5
  239. package/src/audio/bus-mixer.ts +161 -0
  240. package/src/canvas-react/index.ts +5 -21
  241. package/src/canvas-react/pixi-react-root-factory.tsx +301 -39
  242. package/src/core/countdown-timer.ts +188 -0
  243. package/src/core/deferred-commands.ts +174 -0
  244. package/src/core/frame-pacing.ts +2 -2
  245. package/src/core/game-loop.ts +1 -3
  246. package/src/core/seeded-random.ts +1 -1
  247. package/src/core/sim-clock.ts +19 -8
  248. package/src/core/types.ts +1 -3
  249. package/src/defaults.ts +6 -14
  250. package/src/dev/instruments.ts +108 -11
  251. package/src/dev/register-render-vitals.ts +1 -4
  252. package/src/dev/render-debug-adapter.ts +2 -3
  253. package/src/dev/render-vitals.ts +3 -3
  254. package/src/dev/webgl-frame-capture.ts +1 -1
  255. package/src/index.ts +2 -5
  256. package/src/input/host-pointer.ts +230 -0
  257. package/src/input/input-manager.ts +49 -13
  258. package/src/input/input-types.ts +1 -1
  259. package/src/input/rebind-controller.ts +6 -8
  260. package/src/input/schema.ts +216 -188
  261. package/src/manifest/filename.ts +8 -12
  262. package/src/manifest/load.ts +17 -13
  263. package/src/manifest/schema.ts +55 -47
  264. package/src/physics/collider-dimensions.ts +8 -12
  265. package/src/pixi/scene-capture.ts +12 -15
  266. package/src/react/world-state.tsx +1 -1
  267. package/src/render/directional-shadow-fit.ts +156 -0
  268. package/src/render/environment-capture.ts +102 -0
  269. package/src/render/ibl-override-material.ts +170 -0
  270. package/src/render/light-camera-factory.ts +8 -11
  271. package/src/render/material-factory.ts +1 -1
  272. package/src/render/render-batch-system.ts +14 -6
  273. package/src/render/render-features.ts +17 -35
  274. package/src/runtime/create-runtime.ts +270 -108
  275. package/src/runtime/debug-registry.ts +84 -8
  276. package/src/runtime/dev-build.ts +2 -2
  277. package/src/runtime/game-input-seams.ts +108 -0
  278. package/src/runtime/game.ts +231 -85
  279. package/src/runtime/mount-game.ts +31 -57
  280. package/src/runtime/mount-manifest.ts +47 -36
  281. package/src/runtime/playtest.ts +22 -0
  282. package/src/runtime/state-bridge.ts +3 -3
  283. package/src/setup/setup-audio.ts +21 -11
  284. package/src/setup/setup-renderer.ts +2 -61
  285. package/src/world3d-react/index.ts +15 -31
  286. package/src/world3d-react/r3f-root-factory.tsx +451 -60
  287. package/src/world3d-react/rapier-physics-bridge.tsx +154 -58
  288. package/dist/adapter/setup-three-root-adapter.d.ts +0 -86
  289. package/dist/adapter/setup-three-root-adapter.d.ts.map +0 -1
  290. package/dist/adapter/setup-three-root-adapter.js +0 -908
  291. package/dist/animation/clip-map.d.ts +0 -12
  292. package/dist/animation/clip-map.d.ts.map +0 -1
  293. package/dist/animation/clip-map.js +0 -31
  294. package/dist/asset-registry.d.ts +0 -38
  295. package/dist/asset-registry.d.ts.map +0 -1
  296. package/dist/asset-registry.js +0 -66
  297. package/dist/canvas-react/engine-bridge.d.ts +0 -45
  298. package/dist/canvas-react/engine-bridge.d.ts.map +0 -1
  299. package/dist/canvas-react/engine-bridge.js +0 -45
  300. package/dist/canvas-react/pixi-react-adapter.d.ts +0 -77
  301. package/dist/canvas-react/pixi-react-adapter.d.ts.map +0 -1
  302. package/dist/canvas-react/pixi-react-adapter.js +0 -294
  303. package/dist/canvas-react/world-context.d.ts +0 -98
  304. package/dist/canvas-react/world-context.d.ts.map +0 -1
  305. package/dist/canvas-react/world-context.js +0 -173
  306. package/dist/dev/debug-draw.d.ts +0 -24
  307. package/dist/dev/debug-draw.d.ts.map +0 -1
  308. package/dist/dev/debug-draw.js +0 -73
  309. package/dist/render/auto-batcher.d.ts +0 -34
  310. package/dist/render/auto-batcher.d.ts.map +0 -1
  311. package/dist/render/auto-batcher.js +0 -140
  312. package/dist/render/lod.d.ts +0 -13
  313. package/dist/render/lod.d.ts.map +0 -1
  314. package/dist/render/lod.js +0 -16
  315. package/dist/runtime/types.d.ts +0 -303
  316. package/dist/runtime/types.d.ts.map +0 -1
  317. package/dist/runtime/types.js +0 -1
  318. package/dist/world3d-react/engine-bridge.d.ts +0 -47
  319. package/dist/world3d-react/engine-bridge.d.ts.map +0 -1
  320. package/dist/world3d-react/engine-bridge.js +0 -73
  321. package/dist/world3d-react/r3f-adapter.d.ts +0 -58
  322. package/dist/world3d-react/r3f-adapter.d.ts.map +0 -1
  323. package/dist/world3d-react/r3f-adapter.js +0 -634
  324. package/dist/world3d-react/world-context.d.ts +0 -182
  325. package/dist/world3d-react/world-context.d.ts.map +0 -1
  326. package/dist/world3d-react/world-context.js +0 -235
  327. package/src/adapter/setup-three-root-adapter.ts +0 -1032
  328. package/src/animation/clip-map.ts +0 -34
  329. package/src/asset-registry.ts +0 -89
  330. package/src/canvas-react/engine-bridge.ts +0 -59
  331. package/src/canvas-react/pixi-react-adapter.tsx +0 -356
  332. package/src/canvas-react/world-context.ts +0 -253
  333. package/src/dev/debug-draw.ts +0 -80
  334. package/src/render/auto-batcher.ts +0 -168
  335. package/src/render/lod.ts +0 -17
  336. package/src/runtime/types.ts +0 -328
  337. package/src/world3d-react/engine-bridge.ts +0 -86
  338. package/src/world3d-react/r3f-adapter.tsx +0 -717
  339. package/src/world3d-react/world-context.ts +0 -358
@@ -79,13 +79,34 @@ export class NavMeshManager {
79
79
  hasNavMesh() {
80
80
  return this.navMesh !== null;
81
81
  }
82
- /** Find a straight path between two world positions. Returns [] if no path. */
82
+ /**
83
+ * Find a straight path between two world positions.
84
+ *
85
+ * THREE OUTCOMES, and only one of them is an empty array:
86
+ *
87
+ * - **No pathfinder.** No navmesh has been built, so there is nothing to
88
+ * query. THROWS, the same way {@link createCrowd} does — `[]` here would
89
+ * say "I searched and there is no route between these points", which is a
90
+ * claim about the level rather than about this manager's state. Callers
91
+ * that can be in this position gate on {@link hasNavMesh} first.
92
+ * - **The query failed.** recast answered `success: false` WITH an error
93
+ * (bad half-extents, no polygon near an endpoint, a status code). THROWS,
94
+ * naming recast's own error — a failed search is not a searched-and-empty
95
+ * one, and the editor's probe already surfaces this separately from "no
96
+ * path found".
97
+ * - **Genuinely no route.** The query ran and found nothing. `[]`.
98
+ */
83
99
  findPath(start, end) {
84
- if (!this.query)
85
- return [];
100
+ if (!this.query) {
101
+ throw new Error('NavMeshManager.findPath: no navmesh has been built, so no path can be queried. ' +
102
+ 'Build one first (buildFromMeshes/importNavMesh) — gate on hasNavMesh() if the ' +
103
+ 'caller can run before a bake.');
104
+ }
86
105
  const result = this.query.computePath(start, end);
87
- if (!result.success)
88
- return [];
106
+ if (!result.success && result.error) {
107
+ throw new Error(`NavMeshManager.findPath: recast could not complete the query (${result.error.name}` +
108
+ `${result.error.status === undefined ? '' : `, status ${result.error.status}`}).`);
109
+ }
89
110
  return result.path;
90
111
  }
91
112
  /** Create a crowd with up to maxAgents agents. */
@@ -10,16 +10,24 @@
10
10
  * the old `.animgraph.json` format) was deleted with the runtime that read
11
11
  * them (`anim-graph.ts`).
12
12
  */
13
+ /**
14
+ * The optional fields spell `| undefined` explicitly because the repo compiles
15
+ * with `exactOptionalPropertyTypes`, and the one producer of these values is
16
+ * `xstate-animation-meta.ts`'s Zod schema, whose `.optional()` infers
17
+ * `?: T | undefined`. Without the explicit union the parsed value is not
18
+ * assignable here and the call site needs a cast — which is exactly what used
19
+ * to hide field drift between the two declarations (see `asBlendTreeDef`).
20
+ */
13
21
  export interface BlendTreeDef {
14
22
  type: '1D' | '2D' | 'direct';
15
23
  parameter: string;
16
- parameterY?: string;
24
+ parameterY?: string | undefined;
17
25
  children: BlendChild[];
18
26
  }
19
27
  export interface BlendChild {
20
28
  clip: string;
21
29
  threshold: number;
22
- thresholdY?: number;
23
- weight?: number;
30
+ thresholdY?: number | undefined;
31
+ weight?: number | undefined;
24
32
  }
25
33
  //# sourceMappingURL=anim-graph-types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"anim-graph-types.d.ts","sourceRoot":"","sources":["../../src/animation/anim-graph-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,IAAI,GAAG,IAAI,GAAG,QAAQ,CAAC;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,UAAU,EAAE,CAAC;CACxB;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB"}
1
+ {"version":3,"file":"anim-graph-types.d.ts","sourceRoot":"","sources":["../../src/animation/anim-graph-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH;;;;;;;GAOG;AACH,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,IAAI,GAAG,IAAI,GAAG,QAAQ,CAAC;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,QAAQ,EAAE,UAAU,EAAE,CAAC;CACxB;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC7B"}
@@ -74,10 +74,10 @@ export interface TheatreClockBinding {
74
74
  /**
75
75
  * Subscribe `sequence.position = clock.time` to every crossing of `clock` in
76
76
  * the given phase (default `'animation'`). Returns a disposer; call it to
77
- * stop driving the sequence (e.g. on `GameCleanup.dispose()` or before
78
- * rebinding on hot reload — this is what keeps HMR from accumulating
79
- * duplicate listeners, since re-running `setup()` disposes the old binding
80
- * before creating a new one).
77
+ * stop driving the sequence (e.g. in the owning component's unmount cleanup,
78
+ * or before rebinding on hot reload — this is what keeps HMR from
79
+ * accumulating duplicate listeners: dispose the old binding before creating
80
+ * a new one).
81
81
  *
82
82
  * Multiple sheets/sequences can each get their own binding with no shared
83
83
  * mutable state on VGAI's side — collision avoidance for the underlying
@@ -1,10 +1,10 @@
1
1
  /**
2
2
  * Subscribe `sequence.position = clock.time` to every crossing of `clock` in
3
3
  * the given phase (default `'animation'`). Returns a disposer; call it to
4
- * stop driving the sequence (e.g. on `GameCleanup.dispose()` or before
5
- * rebinding on hot reload — this is what keeps HMR from accumulating
6
- * duplicate listeners, since re-running `setup()` disposes the old binding
7
- * before creating a new one).
4
+ * stop driving the sequence (e.g. in the owning component's unmount cleanup,
5
+ * or before rebinding on hot reload — this is what keeps HMR from
6
+ * accumulating duplicate listeners: dispose the old binding before creating
7
+ * a new one).
8
8
  *
9
9
  * Multiple sheets/sequences can each get their own binding with no shared
10
10
  * mutable state on VGAI's side — collision avoidance for the underlying
@@ -1 +1 @@
1
- {"version":3,"file":"xstate-animation-binding.d.ts","sourceRoot":"","sources":["../../src/animation/xstate-animation-binding.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAQhE,OAAO,EACL,KAAK,iBAAiB,EA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CAAgC,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAGjF;AAED,6EAA6E;AAC7E,wBAAgB,iCAAiC,IAAI,MAAM,CAE1D;AAqGD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,oBAAoB,EAC3B,KAAK,EAAE,KAAK,CAAC,cAAc,EAC3B,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,aAAa,CAAC,EACvC,OAAO,GAAE,6BAAkC,GAC1C,sBAAsB,CA+axB"}
@@ -2,7 +2,7 @@ import * as THREE from 'three';
2
2
  import { deleteUserData, getUserData, setUserData } from '../ecs/user-data';
3
3
  import { evaluateBlendTree } from './blend-node';
4
4
  import { attachAnimationRuntimeInspection, } from './runtime-inspection';
5
- import { clipNamesOf, collectMachineAnimationMeta, isBlendTreeAnimationMeta, } from './xstate-animation-meta';
5
+ import { asBlendTreeDef, clipNamesOf, collectMachineAnimationMeta, isBlendTreeAnimationMeta, } from './xstate-animation-meta';
6
6
  /** A binding-time problem such as a missing clip, bone, or ambiguous layer. */
7
7
  export class AnimationBindingError extends Error {
8
8
  stateId;
@@ -188,7 +188,7 @@ export function bindXStateAnimation(actor, mixer, clips, options = {}) {
188
188
  }
189
189
  function weightsOf(stateId, meta, context) {
190
190
  const weights = isBlendTreeAnimationMeta(meta)
191
- ? evaluateBlendTree(meta.blendTree, readParameters(context))
191
+ ? evaluateBlendTree(asBlendTreeDef(meta.blendTree), readParameters(context))
192
192
  : [{ clip: meta.clip, weight: 1 }];
193
193
  return weights.map(({ clip, weight }) => ({
194
194
  clip,
@@ -1,4 +1,5 @@
1
1
  import { z } from 'zod';
2
+ import type { BlendTreeDef } from './anim-graph-types';
2
3
  /**
3
4
  * E1 — Zod/TypeScript metadata attached to XState state `meta.animation`
4
5
  * (spec §11 E1, §5.6, §3.3).
@@ -69,6 +70,18 @@ export declare const AnimationBlendTreeSchema: z.ZodDiscriminatedUnion<[z.ZodObj
69
70
  }, z.core.$strict>>;
70
71
  }, z.core.$strict>], "type">;
71
72
  export type AnimationBlendTree = z.infer<typeof AnimationBlendTreeSchema>;
73
+ /**
74
+ * The structural-identity claim in this file's header, made COMPILER-CHECKED.
75
+ *
76
+ * `evaluateBlendTree` takes `anim-graph-types.ts`'s `BlendTreeDef`, and the
77
+ * whole reason this schema mirrors that shape field-for-field is so a parsed
78
+ * value can be handed over with zero conversion. The binding used to spell that
79
+ * hand-over `as unknown as BlendTreeDef` — a double cast that would have gone on
80
+ * compiling if either declaration drifted, silently feeding the blend math a
81
+ * shape it does not describe. This identity function is the assignability
82
+ * assertion instead: drift here is a type error at the seam that claims it.
83
+ */
84
+ export declare function asBlendTreeDef(tree: AnimationBlendTree): BlendTreeDef;
72
85
  declare const AnimationCrossfadeMetaSchema: z.ZodObject<{
73
86
  duration: z.ZodDefault<z.ZodNumber>;
74
87
  warp: z.ZodDefault<z.ZodBoolean>;
@@ -1 +1 @@
1
- {"version":3,"file":"xstate-animation-meta.d.ts","sourceRoot":"","sources":["../../src/animation/xstate-animation-meta.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAMH,QAAA,MAAM,yBAAyB;;;;;kBAcpB,CAAC;AAEZ,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAwC5E,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;4BAInC,CAAC;AAEH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAM1E,QAAA,MAAM,4BAA4B;;;kBAmBkC,CAAC;AAErE,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAC;AAElF,QAAA,MAAM,uBAAuB;;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D,4EAA4E;AAC5E,MAAM,WAAW,0BAA0B;IACzC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACzD,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,0BAA0B,CAAC,CAAC;CACrD;AAED,MAAM,WAAW,yBAAyB;IACxC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,kBAAkB,CAAC;CAC1B;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,2BAA2B,CACzC,IAAI,EAAE,0BAA0B,GAC/B,yBAAyB,EAAE,CAU7B;AAED,sGAAsG;AACtG,wBAAgB,WAAW,CAAC,IAAI,EAAE,kBAAkB,GAAG,MAAM,EAAE,CAE9D"}
@@ -90,6 +90,20 @@ export const AnimationBlendTreeSchema = z.discriminatedUnion('type', [
90
90
  AnimationBlendTree2DSchema,
91
91
  AnimationBlendTreeDirectSchema,
92
92
  ]);
93
+ /**
94
+ * The structural-identity claim in this file's header, made COMPILER-CHECKED.
95
+ *
96
+ * `evaluateBlendTree` takes `anim-graph-types.ts`'s `BlendTreeDef`, and the
97
+ * whole reason this schema mirrors that shape field-for-field is so a parsed
98
+ * value can be handed over with zero conversion. The binding used to spell that
99
+ * hand-over `as unknown as BlendTreeDef` — a double cast that would have gone on
100
+ * compiling if either declaration drifted, silently feeding the blend math a
101
+ * shape it does not describe. This identity function is the assignability
102
+ * assertion instead: drift here is a type error at the seam that claims it.
103
+ */
104
+ export function asBlendTreeDef(tree) {
105
+ return tree;
106
+ }
93
107
  // ---------------------------------------------------------------------------
94
108
  // Crossfade / blend-in-out metadata (shared by clip and blend-tree states)
95
109
  // ---------------------------------------------------------------------------
@@ -1,9 +1,8 @@
1
1
  /**
2
2
  * The engine's runtime descriptor schemas.
3
3
  *
4
- * WO-8 deleted the `.vscn.json` scene format and everything under
5
- * `engine/src/scene/`. What survived is here, and each module is here because a
6
- * real runtime reader still consumes it:
4
+ * Each module is here because a real runtime READER consumes it — nothing in
5
+ * this directory exists as documentation of a format:
7
6
  *
8
7
  * - `material.ts` — the inline material descriptor `render/material-factory.ts` reads
9
8
  * - `mesh.ts` — the geometry descriptor `render/material-factory.ts`'s `createGeometry` reads
@@ -16,10 +15,8 @@
16
15
  * - `tuples.ts` — the shared Vec3/Quat/Transform tuples the above build on
17
16
  *
18
17
  * These are DESCRIPTORS, not documents: each names a slice of authored data a
19
- * render/physics factory reads, and none of them is a scene. They carried a
20
- * `Scene*` prefix until WO-9 task #6 renamed them to `*Descriptor` — the prefix
21
- * was a leftover of the deleted `.vscn.json` format, not a statement about what
22
- * they describe.
18
+ * render/physics factory reads, and none of them is a scene which is why
19
+ * every one of them is named `*Descriptor`.
23
20
  */
24
21
  export type { CameraDescriptor } from './camera';
25
22
  export { CameraDescriptorSchema } from './camera';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/asset-formats/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,YAAY,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAClD,YAAY,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AACtD,YAAY,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAChD,YAAY,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AACtD,YAAY,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAC7C,OAAO,EAAE,oBAAoB,EAAE,MAAM,QAAQ,CAAC;AAC9C,YAAY,EAAE,mBAAm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GAC5B,MAAM,cAAc,CAAC;AACtB,YAAY,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC"}
@@ -1,9 +1,8 @@
1
1
  /**
2
2
  * The engine's runtime descriptor schemas.
3
3
  *
4
- * WO-8 deleted the `.vscn.json` scene format and everything under
5
- * `engine/src/scene/`. What survived is here, and each module is here because a
6
- * real runtime reader still consumes it:
4
+ * Each module is here because a real runtime READER consumes it — nothing in
5
+ * this directory exists as documentation of a format:
7
6
  *
8
7
  * - `material.ts` — the inline material descriptor `render/material-factory.ts` reads
9
8
  * - `mesh.ts` — the geometry descriptor `render/material-factory.ts`'s `createGeometry` reads
@@ -16,10 +15,8 @@
16
15
  * - `tuples.ts` — the shared Vec3/Quat/Transform tuples the above build on
17
16
  *
18
17
  * These are DESCRIPTORS, not documents: each names a slice of authored data a
19
- * render/physics factory reads, and none of them is a scene. They carried a
20
- * `Scene*` prefix until WO-9 task #6 renamed them to `*Descriptor` — the prefix
21
- * was a leftover of the deleted `.vscn.json` format, not a statement about what
22
- * they describe.
18
+ * render/physics factory reads, and none of them is a scene which is why
19
+ * every one of them is named `*Descriptor`.
23
20
  */
24
21
  export { CameraDescriptorSchema } from './camera';
25
22
  export { ColliderDescriptorSchema } from './collider';
@@ -2,12 +2,9 @@
2
2
  * Render settings — the tone-mapping / post-processing / render-feature scope
3
3
  * the engine's renderer setup reads (`setup/setup-renderer.ts`).
4
4
  *
5
- * This used to be the `environment` block of the retired `.vscn.json` scene
6
- * format (WO-8). The format is gone; these three scopes stayed because
7
- * `setup-renderer.ts` genuinely reads every field and builds the
8
- * postprocessing chain from them. Everything that was `.vscn`-only (`skybox`,
9
- * `fog`, `ambient`, `background`, `envMapIntensity`, `navigation`, `physics`)
10
- * went with the format.
5
+ * Exactly THREE scopes, and each is here because `setup-renderer.ts` reads
6
+ * every one of its fields to build the postprocessing chain. A setting with
7
+ * no such reader does not belong in this descriptor.
11
8
  */
12
9
  import { z } from 'zod';
13
10
  export declare const ToneMappingDescriptorSchema: z.ZodObject<{
@@ -128,8 +125,8 @@ export declare const PostProcessingDescriptorSchema: z.ZodObject<{
128
125
  enabled: z.ZodOptional<z.ZodBoolean>;
129
126
  preset: z.ZodOptional<z.ZodEnum<{
130
127
  high: "high";
131
- low: "low";
132
128
  medium: "medium";
129
+ low: "low";
133
130
  ultra: "ultra";
134
131
  }>>;
135
132
  }, z.core.$strip>>;
@@ -314,8 +311,8 @@ export declare const RenderEnvironmentSchema: z.ZodObject<{
314
311
  enabled: z.ZodOptional<z.ZodBoolean>;
315
312
  preset: z.ZodOptional<z.ZodEnum<{
316
313
  high: "high";
317
- low: "low";
318
314
  medium: "medium";
315
+ low: "low";
319
316
  ultra: "ultra";
320
317
  }>>;
321
318
  }, z.core.$strip>>;
@@ -1 +1 @@
1
- {"version":3,"file":"render-env.d.ts","sourceRoot":"","sources":["../../src/asset-formats/render-env.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,2BAA2B;;;;;;;;;;iBAQC,CAAC;AAE1C,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAEhF,eAAO,MAAM,8BAA8B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAoRL,CAAC;AAEvC,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,8BAA8B,CAAC,CAAC;AAEtF,eAAO,MAAM,uBAAuB;;;;;;;;;;;;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,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC"}
@@ -2,12 +2,9 @@
2
2
  * Render settings — the tone-mapping / post-processing / render-feature scope
3
3
  * the engine's renderer setup reads (`setup/setup-renderer.ts`).
4
4
  *
5
- * This used to be the `environment` block of the retired `.vscn.json` scene
6
- * format (WO-8). The format is gone; these three scopes stayed because
7
- * `setup-renderer.ts` genuinely reads every field and builds the
8
- * postprocessing chain from them. Everything that was `.vscn`-only (`skybox`,
9
- * `fog`, `ambient`, `background`, `envMapIntensity`, `navigation`, `physics`)
10
- * went with the format.
5
+ * Exactly THREE scopes, and each is here because `setup-renderer.ts` reads
6
+ * every one of its fields to build the postprocessing chain. A setting with
7
+ * no such reader does not belong in this descriptor.
11
8
  */
12
9
  import { z } from 'zod';
13
10
  import { buildRenderingZod } from '../render/render-features';
@@ -7,11 +7,8 @@
7
7
  * every caller (currently the input-map loader in `input/input-manager.ts`)
8
8
  * does not have to reach into an unrelated subsystem for it.
9
9
  *
10
- * It was called `SceneParseError` until WO-9 task #6. The extraction that gave
11
- * this file its name deliberately deferred the class rename ("extraction, not
12
- * redesign"); with `.vscn` gone the old name described nothing — an
13
- * `.inputmap.json` failure is not a scene failure — so the class and its
14
- * message header now say `asset`.
10
+ * The name says ASSET, not scene: an `.inputmap.json` failure is not a scene
11
+ * failure, and the class covers every structured fetched asset.
15
12
  */
16
13
  import type { ZodIssue } from 'zod';
17
14
  export declare class AssetParseError extends Error {
@@ -1 +1 @@
1
- {"version":3,"file":"asset-parse-error.d.ts","sourceRoot":"","sources":["../src/asset-parse-error.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;AAEpC,qBAAa,eAAgB,SAAQ,KAAK;IACxC,QAAQ,CAAC,MAAM,EAAE,QAAQ,EAAE,CAAC;IAC5B,sEAAsE;IACtE,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;gBAE3B,MAAM,EAAE,QAAQ,EAAE,EAAE,QAAQ,CAAC,EAAE,MAAM;CAQlD"}
1
+ {"version":3,"file":"asset-parse-error.d.ts","sourceRoot":"","sources":["../src/asset-parse-error.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;AAEpC,qBAAa,eAAgB,SAAQ,KAAK;IACxC,QAAQ,CAAC,MAAM,EAAE,QAAQ,EAAE,CAAC;IAC5B,sEAAsE;IACtE,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;gBAE3B,MAAM,EAAE,QAAQ,EAAE,EAAE,QAAQ,CAAC,EAAE,MAAM;CAQlD"}
@@ -7,11 +7,8 @@
7
7
  * every caller (currently the input-map loader in `input/input-manager.ts`)
8
8
  * does not have to reach into an unrelated subsystem for it.
9
9
  *
10
- * It was called `SceneParseError` until WO-9 task #6. The extraction that gave
11
- * this file its name deliberately deferred the class rename ("extraction, not
12
- * redesign"); with `.vscn` gone the old name described nothing — an
13
- * `.inputmap.json` failure is not a scene failure — so the class and its
14
- * message header now say `asset`.
10
+ * The name says ASSET, not scene: an `.inputmap.json` failure is not a scene
11
+ * failure, and the class covers every structured fetched asset.
15
12
  */
16
13
  export class AssetParseError extends Error {
17
14
  issues;
@@ -0,0 +1,101 @@
1
+ /**
2
+ * A named-bus mixer over Web Audio: buses created on demand, routed into each
3
+ * other by name, and set in DECIBELS.
4
+ *
5
+ * Every mixer a game reaches for is this shape — Unity's `AudioMixerGroup`,
6
+ * Godot's bus layout, FMOD's VCAs, and the `music`/`sfx`/`voice` trio
7
+ * `setup/setup-audio.ts` hands a first-party three world. What they share is
8
+ * not the protocol (that part is genuinely per-ecosystem and stays with the
9
+ * lane that speaks it) but the machinery underneath: a `GainNode` per bus, a
10
+ * name → node map, a parent to route into, and the one conversion below. This
11
+ * file owns exactly that, and nothing that names an ecosystem.
12
+ *
13
+ * ## dB is not a gain, and the mistake is silent
14
+ *
15
+ * `GainNode.gain` is a LINEAR amplitude multiplier; every mixer's authored
16
+ * volume is logarithmic dB, where 0 dB is unity and −80 dB is silence. Writing
17
+ * the dB number straight onto `gain.value` gives you a gain of −80 (a phase
18
+ * inversion at 80x) where the author asked for silence, and it does not throw,
19
+ * warn, or look wrong in a debugger — it is just loud. {@link dbToLinear} is
20
+ * the one conversion, `10^(dB/20)`, which is both Godot's `db_to_linear`
21
+ * (`core/math/math_funcs.h`: `exp(db * 0.11512925464970228…)`, the same
22
+ * function written in base e) and Unity's mixer volume curve.
23
+ *
24
+ * It deliberately does NOT clamp. A mixer's RANGE is protocol — Unity's
25
+ * exposed parameters saturate at its slider's ends, Godot's `volume_db` does
26
+ * not — so the lane that knows the range applies it before calling here, and
27
+ * this file cannot silently mute or silently boost anyone's authored value.
28
+ *
29
+ * ## Create-on-demand, and why it is the contract rather than a convenience
30
+ *
31
+ * {@link AudioBusMixer.bus} MINTS a bus the first time it is named and returns
32
+ * the SAME node forever after. The identity is the contract, not the minting:
33
+ * a source connects to a bus long before anything sets that bus's volume, and
34
+ * a parent is usually named by its child before anyone asks for it directly
35
+ * (`bus('music', 'master')` builds `master` too, and the later `bus('master')`
36
+ * must be that same node). A `bus()` that minted per call would hand the
37
+ * volume control a SECOND node — the sources would keep feeding the first one,
38
+ * every later write would land on a node nothing plays through, and nothing
39
+ * would throw or look wrong. So the map is authoritative, and the only way a
40
+ * name stops resolving to its node is {@link AudioBusMixer.remove} or
41
+ * {@link AudioBusMixer.disconnect}.
42
+ *
43
+ * A re-ask that names a DIFFERENT parent throws by name. Routing is decided at
44
+ * creation (the node is already connected by then), so honouring the second
45
+ * parent would mean silently re-routing live audio and ignoring it would mean
46
+ * silently keeping the first — a loud error is the only reading that is not a
47
+ * lie.
48
+ *
49
+ * ## RESOURCE OWNERSHIP
50
+ *
51
+ * No module-scoped state: {@link createAudioBusMixer} is a factory and the
52
+ * OWNER of an instance is whoever called it (a `setupAudio` graph, one
53
+ * translated port's mixer store). What an instance ALLOCATES is one `GainNode`
54
+ * per named bus, and disconnecting those is the whole of its teardown
55
+ * obligation — {@link AudioBusMixer.disconnect}, called once by that same
56
+ * owner. The `context` and the `destination` node are NOT its own: they are
57
+ * passed in, shared with everything else hanging off the same graph, and this
58
+ * file never creates, closes, suspends or disconnects either one.
59
+ */
60
+ /**
61
+ * The graph an {@link AudioBusMixer} hangs off, as the two members it touches.
62
+ *
63
+ * Narrow on purpose: `createGain` is all it needs from the context, so a real
64
+ * `AudioContext`, an `OfflineAudioContext` and a headless stand-in are all
65
+ * acceptable without a cast.
66
+ */
67
+ export interface AudioBusMixerOptions {
68
+ readonly context: {
69
+ createGain(): GainNode;
70
+ };
71
+ /** The node every parentless bus feeds. Usually a master gain or the context's destination. */
72
+ readonly destination: AudioNode;
73
+ }
74
+ export interface AudioBusMixer {
75
+ /**
76
+ * The bus named `name`, created on the first ask and connected to `parent`
77
+ * (itself created on demand) or to the destination.
78
+ *
79
+ * The returned node is the real `GainNode` — set `gain.value`, schedule
80
+ * automation on `gain`, connect sources to it. Nothing here stands between a
81
+ * caller and Web Audio's own API.
82
+ */
83
+ bus(name: string, parent?: string): GainNode;
84
+ /** The bus named `name` if it EXISTS, else null. Never mints one. */
85
+ find(name: string): GainNode | null;
86
+ /** Set this bus's gain from decibels, creating it if absent. Clamp before calling — see the header. */
87
+ setDb(name: string, db: number, parent?: string): void;
88
+ /**
89
+ * Disconnect one bus and forget its name, so a later {@link bus} mints a
90
+ * fresh node. Buses that named it as their parent are NOT re-routed — they
91
+ * keep feeding the removed node, which now reaches nothing.
92
+ */
93
+ remove(name: string): void;
94
+ /** Disconnect every bus and forget them all. The owner's ONE teardown. */
95
+ disconnect(): void;
96
+ }
97
+ /** dB → linear amplitude: `10^(dB/20)`. 0 dB is 1, −6 dB is ~0.5, −80 dB is ~0.0001. Never clamps. */
98
+ export declare function dbToLinear(db: number): number;
99
+ /** Create one named-bus mixer. See the header for what owns the instance and what it allocates. */
100
+ export declare function createAudioBusMixer(options: AudioBusMixerOptions): AudioBusMixer;
101
+ //# sourceMappingURL=bus-mixer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bus-mixer.d.ts","sourceRoot":"","sources":["../../src/audio/bus-mixer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DG;AAEH;;;;;;GAMG;AACH,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,OAAO,EAAE;QAAE,UAAU,IAAI,QAAQ,CAAA;KAAE,CAAC;IAC7C,+FAA+F;IAC/F,QAAQ,CAAC,WAAW,EAAE,SAAS,CAAC;CACjC;AAED,MAAM,WAAW,aAAa;IAC5B;;;;;;;OAOG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,QAAQ,CAAC;IAC7C,qEAAqE;IACrE,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,GAAG,IAAI,CAAC;IACpC,uGAAuG;IACvG,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvD;;;;OAIG;IACH,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,0EAA0E;IAC1E,UAAU,IAAI,IAAI,CAAC;CACpB;AAED,sGAAsG;AACtG,wBAAgB,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAE7C;AAeD,mGAAmG;AACnG,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,oBAAoB,GAAG,aAAa,CA4ChF"}
@@ -0,0 +1,115 @@
1
+ /**
2
+ * A named-bus mixer over Web Audio: buses created on demand, routed into each
3
+ * other by name, and set in DECIBELS.
4
+ *
5
+ * Every mixer a game reaches for is this shape — Unity's `AudioMixerGroup`,
6
+ * Godot's bus layout, FMOD's VCAs, and the `music`/`sfx`/`voice` trio
7
+ * `setup/setup-audio.ts` hands a first-party three world. What they share is
8
+ * not the protocol (that part is genuinely per-ecosystem and stays with the
9
+ * lane that speaks it) but the machinery underneath: a `GainNode` per bus, a
10
+ * name → node map, a parent to route into, and the one conversion below. This
11
+ * file owns exactly that, and nothing that names an ecosystem.
12
+ *
13
+ * ## dB is not a gain, and the mistake is silent
14
+ *
15
+ * `GainNode.gain` is a LINEAR amplitude multiplier; every mixer's authored
16
+ * volume is logarithmic dB, where 0 dB is unity and −80 dB is silence. Writing
17
+ * the dB number straight onto `gain.value` gives you a gain of −80 (a phase
18
+ * inversion at 80x) where the author asked for silence, and it does not throw,
19
+ * warn, or look wrong in a debugger — it is just loud. {@link dbToLinear} is
20
+ * the one conversion, `10^(dB/20)`, which is both Godot's `db_to_linear`
21
+ * (`core/math/math_funcs.h`: `exp(db * 0.11512925464970228…)`, the same
22
+ * function written in base e) and Unity's mixer volume curve.
23
+ *
24
+ * It deliberately does NOT clamp. A mixer's RANGE is protocol — Unity's
25
+ * exposed parameters saturate at its slider's ends, Godot's `volume_db` does
26
+ * not — so the lane that knows the range applies it before calling here, and
27
+ * this file cannot silently mute or silently boost anyone's authored value.
28
+ *
29
+ * ## Create-on-demand, and why it is the contract rather than a convenience
30
+ *
31
+ * {@link AudioBusMixer.bus} MINTS a bus the first time it is named and returns
32
+ * the SAME node forever after. The identity is the contract, not the minting:
33
+ * a source connects to a bus long before anything sets that bus's volume, and
34
+ * a parent is usually named by its child before anyone asks for it directly
35
+ * (`bus('music', 'master')` builds `master` too, and the later `bus('master')`
36
+ * must be that same node). A `bus()` that minted per call would hand the
37
+ * volume control a SECOND node — the sources would keep feeding the first one,
38
+ * every later write would land on a node nothing plays through, and nothing
39
+ * would throw or look wrong. So the map is authoritative, and the only way a
40
+ * name stops resolving to its node is {@link AudioBusMixer.remove} or
41
+ * {@link AudioBusMixer.disconnect}.
42
+ *
43
+ * A re-ask that names a DIFFERENT parent throws by name. Routing is decided at
44
+ * creation (the node is already connected by then), so honouring the second
45
+ * parent would mean silently re-routing live audio and ignoring it would mean
46
+ * silently keeping the first — a loud error is the only reading that is not a
47
+ * lie.
48
+ *
49
+ * ## RESOURCE OWNERSHIP
50
+ *
51
+ * No module-scoped state: {@link createAudioBusMixer} is a factory and the
52
+ * OWNER of an instance is whoever called it (a `setupAudio` graph, one
53
+ * translated port's mixer store). What an instance ALLOCATES is one `GainNode`
54
+ * per named bus, and disconnecting those is the whole of its teardown
55
+ * obligation — {@link AudioBusMixer.disconnect}, called once by that same
56
+ * owner. The `context` and the `destination` node are NOT its own: they are
57
+ * passed in, shared with everything else hanging off the same graph, and this
58
+ * file never creates, closes, suspends or disconnects either one.
59
+ */
60
+ /** dB → linear amplitude: `10^(dB/20)`. 0 dB is 1, −6 dB is ~0.5, −80 dB is ~0.0001. Never clamps. */
61
+ export function dbToLinear(db) {
62
+ return 10 ** (db / 20);
63
+ }
64
+ function safeDisconnect(node) {
65
+ try {
66
+ node.disconnect();
67
+ }
68
+ catch {
69
+ // already disconnected
70
+ }
71
+ }
72
+ /** Create one named-bus mixer. See the header for what owns the instance and what it allocates. */
73
+ export function createAudioBusMixer(options) {
74
+ const { context, destination } = options;
75
+ const buses = new Map();
76
+ function bus(name, parent) {
77
+ const existing = buses.get(name);
78
+ if (existing !== undefined) {
79
+ if (parent !== undefined && parent !== existing.parent) {
80
+ throw new Error(`audio bus ${JSON.stringify(name)} already routes into ` +
81
+ `${existing.parent === undefined ? 'the destination' : JSON.stringify(existing.parent)}` +
82
+ `; it cannot also route into ${JSON.stringify(parent)}. Routing is decided when a bus ` +
83
+ 'is created (see packages/engine/src/audio/bus-mixer.ts).');
84
+ }
85
+ return existing.node;
86
+ }
87
+ // The parent is resolved (and minted, recursively) before this bus is
88
+ // seated, so a conflicting-parent throw upstream leaves nothing half-built.
89
+ const into = parent === undefined ? destination : bus(parent);
90
+ const node = context.createGain();
91
+ node.gain.value = 1;
92
+ node.connect(into);
93
+ buses.set(name, { node, parent });
94
+ return node;
95
+ }
96
+ return {
97
+ bus,
98
+ find: (name) => buses.get(name)?.node ?? null,
99
+ setDb: (name, db, parent) => {
100
+ bus(name, parent).gain.value = dbToLinear(db);
101
+ },
102
+ remove: (name) => {
103
+ const record = buses.get(name);
104
+ if (record === undefined)
105
+ return;
106
+ buses.delete(name);
107
+ safeDisconnect(record.node);
108
+ },
109
+ disconnect: () => {
110
+ for (const record of buses.values())
111
+ safeDisconnect(record.node);
112
+ buses.clear();
113
+ },
114
+ };
115
+ }
@@ -15,28 +15,21 @@
15
15
  * or the Pixi reconciler.
16
16
  *
17
17
  * Surface:
18
- * - `createPixiReactAdapter({ id, content })` — mount a `@pixi/react` tree as
19
- * a first-party `surface: "canvas"` root under the host's gated loop.
20
18
  * - `pixiReactRootFactory` / `resolveCanvasEntryAdapter` — what a canvas entry
21
- * module MEANS: a default-exported component (or an explicit `adapter`).
19
+ * module MEANS: a default-exported component, mounted as a first-party
20
+ * `surface: "canvas"` root under the host's gated loop. The world's vgai
21
+ * surface is its entry module's static exports
22
+ * (`export { debug, systems } from './commands'`), connected by the host at
23
+ * mount.
22
24
  * - `PixiPrimitive` / `adoptNow` — the canvas surface's `<primitive object={…}>`:
23
25
  * render a container the game already owns, and place a spawn in the
24
26
  * display tree ahead of the commit that renders it.
25
- * - `useGameContext()` — this root's `CanvasGameContext` (`input`, `debug`,
26
- * `random`, `clock`, `game`, `roots`) from inside any component in the tree.
27
- * Behavior in a canvas world is components + hooks, never a class under a
28
- * string key.
29
- * - `EngineBridge` / `EngineBridgeValue` — the context contract, exported for
30
- * adopters building their own bridge.
31
27
  *
32
28
  * The Pixi runtime itself is NOT re-exported here. A component reaches the live
33
29
  * `Application` (and therefore `stage`, `renderer`, `ticker`) with
34
30
  * `@pixi/react`'s own `useApplication()`, ticks with its `useTick()`, and loads
35
31
  * assets with Pixi's own `Assets` — the library's API, not a second one.
36
32
  */
37
- export { EngineBridge, type EngineBridgeValue, useGameContext } from './engine-bridge';
38
33
  export { adoptNow, PixiPrimitive, type PixiPrimitiveProps } from './pixi-primitive';
39
- export { type CreatePixiReactAdapterOptions, createPixiReactAdapter, } from './pixi-react-adapter';
40
34
  export { pixiReactRootFactory, resolveCanvasEntryAdapter } from './pixi-react-root-factory';
41
- export { type CanvasGameContext, type CanvasRootContextOptions, type CanvasRootRuntime, createCanvasRootContext, DEFAULT_INPUT_MAP_PATH, } from './world-context';
42
35
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/canvas-react/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,OAAO,EAAE,YAAY,EAAE,KAAK,iBAAiB,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACvF,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,KAAK,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACpF,OAAO,EACL,KAAK,6BAA6B,EAClC,sBAAsB,GACvB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AAC5F,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,wBAAwB,EAC7B,KAAK,iBAAiB,EACtB,uBAAuB,EACvB,sBAAsB,GACvB,MAAM,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/canvas-react/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,KAAK,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACpF,OAAO,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC"}