@vgai/engine 0.5.0 → 0.5.2

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 (538) hide show
  1. package/package.json +1 -1
  2. package/schemas/engine-capabilities.json +4 -4
  3. package/schemas/vgai-game.schema.json +2 -2
  4. package/src/adapter/authoring.ts +42 -0
  5. package/src/adapter/index.ts +3 -0
  6. package/src/adapter/ingest/overlay-apply.ts +50 -6
  7. package/src/adapter/ingest/scene-capture.ts +51 -2
  8. package/src/adapter/vgai-scene-game-adapter.ts +24 -0
  9. package/src/manifest/schema.ts +7 -3
  10. package/src/runtime/create-runtime.ts +97 -0
  11. package/src/runtime/game.ts +11 -1
  12. package/src/scene/asset-ref-check.ts +1 -1
  13. package/src/scene/scene-loader.ts +2 -2
  14. package/src/scene/user-data.ts +18 -0
  15. package/src/world3d-react/behavior.tsx +19 -11
  16. package/src/world3d-react/r3f-adapter.tsx +8 -0
  17. package/dist/adapter/adapter-surface.d.ts +0 -30
  18. package/dist/adapter/adapter-surface.d.ts.map +0 -1
  19. package/dist/adapter/adapter-surface.js +0 -18
  20. package/dist/adapter/authoring.d.ts +0 -461
  21. package/dist/adapter/authoring.d.ts.map +0 -1
  22. package/dist/adapter/authoring.js +0 -22
  23. package/dist/adapter/colyseus-networking-adapter.d.ts +0 -43
  24. package/dist/adapter/colyseus-networking-adapter.d.ts.map +0 -1
  25. package/dist/adapter/colyseus-networking-adapter.js +0 -38
  26. package/dist/adapter/first-party-systems.d.ts +0 -38
  27. package/dist/adapter/first-party-systems.d.ts.map +0 -1
  28. package/dist/adapter/first-party-systems.js +0 -77
  29. package/dist/adapter/game-adapter.d.ts +0 -133
  30. package/dist/adapter/game-adapter.d.ts.map +0 -1
  31. package/dist/adapter/game-adapter.js +0 -10
  32. package/dist/adapter/host-context.d.ts +0 -71
  33. package/dist/adapter/host-context.d.ts.map +0 -1
  34. package/dist/adapter/host-context.js +0 -16
  35. package/dist/adapter/index.d.ts +0 -22
  36. package/dist/adapter/index.d.ts.map +0 -1
  37. package/dist/adapter/index.js +0 -15
  38. package/dist/adapter/ingest/game-contract.d.ts +0 -53
  39. package/dist/adapter/ingest/game-contract.d.ts.map +0 -1
  40. package/dist/adapter/ingest/game-contract.js +0 -30
  41. package/dist/adapter/ingest/overlay-applier.d.ts +0 -118
  42. package/dist/adapter/ingest/overlay-applier.d.ts.map +0 -1
  43. package/dist/adapter/ingest/overlay-applier.js +0 -132
  44. package/dist/adapter/ingest/overlay-apply.d.ts +0 -60
  45. package/dist/adapter/ingest/overlay-apply.d.ts.map +0 -1
  46. package/dist/adapter/ingest/overlay-apply.js +0 -101
  47. package/dist/adapter/ingest/overlay-file.d.ts +0 -79
  48. package/dist/adapter/ingest/overlay-file.d.ts.map +0 -1
  49. package/dist/adapter/ingest/overlay-file.js +0 -66
  50. package/dist/adapter/ingest/overlay-report.d.ts +0 -113
  51. package/dist/adapter/ingest/overlay-report.d.ts.map +0 -1
  52. package/dist/adapter/ingest/overlay-report.js +0 -103
  53. package/dist/adapter/ingest/scene-capture.d.ts +0 -97
  54. package/dist/adapter/ingest/scene-capture.d.ts.map +0 -1
  55. package/dist/adapter/ingest/scene-capture.js +0 -248
  56. package/dist/adapter/ingest/upstream-pin.d.ts +0 -47
  57. package/dist/adapter/ingest/upstream-pin.d.ts.map +0 -1
  58. package/dist/adapter/ingest/upstream-pin.js +0 -50
  59. package/dist/adapter/loop-gate-report.d.ts +0 -34
  60. package/dist/adapter/loop-gate-report.d.ts.map +0 -1
  61. package/dist/adapter/loop-gate-report.js +0 -37
  62. package/dist/adapter/rapier-physics-adapter.d.ts +0 -12
  63. package/dist/adapter/rapier-physics-adapter.d.ts.map +0 -1
  64. package/dist/adapter/rapier-physics-adapter.js +0 -46
  65. package/dist/adapter/system-adapter.d.ts +0 -206
  66. package/dist/adapter/system-adapter.d.ts.map +0 -1
  67. package/dist/adapter/system-adapter.js +0 -13
  68. package/dist/adapter/transform.d.ts +0 -18
  69. package/dist/adapter/transform.d.ts.map +0 -1
  70. package/dist/adapter/transform.js +0 -1
  71. package/dist/adapter/vgai-scene-game-adapter.d.ts +0 -108
  72. package/dist/adapter/vgai-scene-game-adapter.d.ts.map +0 -1
  73. package/dist/adapter/vgai-scene-game-adapter.js +0 -762
  74. package/dist/ai/navigation.d.ts +0 -64
  75. package/dist/ai/navigation.d.ts.map +0 -1
  76. package/dist/ai/navigation.js +0 -133
  77. package/dist/animation/anim-graph-types.d.ts +0 -25
  78. package/dist/animation/anim-graph-types.d.ts.map +0 -1
  79. package/dist/animation/anim-graph-types.js +0 -1
  80. package/dist/animation/animation-clock.d.ts +0 -213
  81. package/dist/animation/animation-clock.d.ts.map +0 -1
  82. package/dist/animation/animation-clock.js +0 -301
  83. package/dist/animation/blend-node.d.ts +0 -22
  84. package/dist/animation/blend-node.d.ts.map +0 -1
  85. package/dist/animation/blend-node.js +0 -97
  86. package/dist/animation/camera-ownership.d.ts +0 -250
  87. package/dist/animation/camera-ownership.d.ts.map +0 -1
  88. package/dist/animation/camera-ownership.js +0 -169
  89. package/dist/animation/cinematic-cues.d.ts +0 -200
  90. package/dist/animation/cinematic-cues.d.ts.map +0 -1
  91. package/dist/animation/cinematic-cues.js +0 -213
  92. package/dist/animation/clip-map.d.ts +0 -12
  93. package/dist/animation/clip-map.d.ts.map +0 -1
  94. package/dist/animation/clip-map.js +0 -37
  95. package/dist/animation/gsap-registration.d.ts +0 -119
  96. package/dist/animation/gsap-registration.d.ts.map +0 -1
  97. package/dist/animation/gsap-registration.js +0 -92
  98. package/dist/animation/theatre-clock-binding.d.ts +0 -89
  99. package/dist/animation/theatre-clock-binding.d.ts.map +0 -1
  100. package/dist/animation/theatre-clock-binding.js +0 -29
  101. package/dist/animation/theatre-director.d.ts +0 -242
  102. package/dist/animation/theatre-director.d.ts.map +0 -1
  103. package/dist/animation/theatre-director.js +0 -235
  104. package/dist/animation/theatre-object-binding.d.ts +0 -305
  105. package/dist/animation/theatre-object-binding.d.ts.map +0 -1
  106. package/dist/animation/theatre-object-binding.js +0 -351
  107. package/dist/animation/xstate-animation-binding.d.ts +0 -56
  108. package/dist/animation/xstate-animation-binding.d.ts.map +0 -1
  109. package/dist/animation/xstate-animation-binding.js +0 -331
  110. package/dist/animation/xstate-animation-meta.d.ts +0 -266
  111. package/dist/animation/xstate-animation-meta.d.ts.map +0 -1
  112. package/dist/animation/xstate-animation-meta.js +0 -252
  113. package/dist/assets.d.ts +0 -26
  114. package/dist/assets.d.ts.map +0 -1
  115. package/dist/assets.js +0 -55
  116. package/dist/audio/index.d.ts +0 -4
  117. package/dist/audio/index.d.ts.map +0 -1
  118. package/dist/audio/index.js +0 -24
  119. package/dist/audio/tone-clock-binding.d.ts +0 -75
  120. package/dist/audio/tone-clock-binding.d.ts.map +0 -1
  121. package/dist/audio/tone-clock-binding.js +0 -29
  122. package/dist/audio/tone-context.d.ts +0 -114
  123. package/dist/audio/tone-context.d.ts.map +0 -1
  124. package/dist/audio/tone-context.js +0 -39
  125. package/dist/audio/tone-offline-render.d.ts +0 -90
  126. package/dist/audio/tone-offline-render.d.ts.map +0 -1
  127. package/dist/audio/tone-offline-render.js +0 -56
  128. package/dist/audio/wav-encode.d.ts +0 -38
  129. package/dist/audio/wav-encode.d.ts.map +0 -1
  130. package/dist/audio/wav-encode.js +0 -97
  131. package/dist/character/cloth-sim.d.ts +0 -179
  132. package/dist/character/cloth-sim.d.ts.map +0 -1
  133. package/dist/character/cloth-sim.js +0 -334
  134. package/dist/character/spring-chain.d.ts +0 -135
  135. package/dist/character/spring-chain.d.ts.map +0 -1
  136. package/dist/character/spring-chain.js +0 -165
  137. package/dist/core/game-loop.d.ts +0 -42
  138. package/dist/core/game-loop.d.ts.map +0 -1
  139. package/dist/core/game-loop.js +0 -167
  140. package/dist/core/seeded-random.d.ts +0 -69
  141. package/dist/core/seeded-random.d.ts.map +0 -1
  142. package/dist/core/seeded-random.js +0 -121
  143. package/dist/core/system-runner.d.ts +0 -120
  144. package/dist/core/system-runner.d.ts.map +0 -1
  145. package/dist/core/system-runner.js +0 -297
  146. package/dist/core/types.d.ts +0 -92
  147. package/dist/core/types.d.ts.map +0 -1
  148. package/dist/core/types.js +0 -25
  149. package/dist/data/data-asset.d.ts +0 -101
  150. package/dist/data/data-asset.d.ts.map +0 -1
  151. package/dist/data/data-asset.js +0 -122
  152. package/dist/data/data-check-core.d.ts +0 -110
  153. package/dist/data/data-check-core.d.ts.map +0 -1
  154. package/dist/data/data-check-core.js +0 -178
  155. package/dist/data/data-ref.d.ts +0 -79
  156. package/dist/data/data-ref.d.ts.map +0 -1
  157. package/dist/data/data-ref.js +0 -130
  158. package/dist/data/vite-plugin-data.d.ts +0 -79
  159. package/dist/data/vite-plugin-data.d.ts.map +0 -1
  160. package/dist/data/vite-plugin-data.js +0 -217
  161. package/dist/dev/console-bridge.d.ts +0 -22
  162. package/dist/dev/console-bridge.d.ts.map +0 -1
  163. package/dist/dev/console-bridge.js +0 -71
  164. package/dist/dev/debug-draw.d.ts +0 -24
  165. package/dist/dev/debug-draw.d.ts.map +0 -1
  166. package/dist/dev/debug-draw.js +0 -73
  167. package/dist/dev/logger.d.ts +0 -30
  168. package/dist/dev/logger.d.ts.map +0 -1
  169. package/dist/dev/logger.js +0 -90
  170. package/dist/dev/performance-profiler.d.ts +0 -60
  171. package/dist/dev/performance-profiler.d.ts.map +0 -1
  172. package/dist/dev/performance-profiler.js +0 -181
  173. package/dist/dev/webgl-gpu-timer.d.ts +0 -8
  174. package/dist/dev/webgl-gpu-timer.d.ts.map +0 -1
  175. package/dist/dev/webgl-gpu-timer.js +0 -52
  176. package/dist/ecs/component-manager.d.ts +0 -205
  177. package/dist/ecs/component-manager.d.ts.map +0 -1
  178. package/dist/ecs/component-manager.js +0 -706
  179. package/dist/ecs/game-component.d.ts +0 -146
  180. package/dist/ecs/game-component.d.ts.map +0 -1
  181. package/dist/ecs/game-component.js +0 -141
  182. package/dist/ecs/hmr-swap-report.d.ts +0 -53
  183. package/dist/ecs/hmr-swap-report.d.ts.map +0 -1
  184. package/dist/ecs/hmr-swap-report.js +0 -55
  185. package/dist/humanoid/bake.operation.d.ts +0 -119
  186. package/dist/humanoid/bake.operation.d.ts.map +0 -1
  187. package/dist/humanoid/bake.operation.js +0 -228
  188. package/dist/humanoid/body.d.ts +0 -101
  189. package/dist/humanoid/body.d.ts.map +0 -1
  190. package/dist/humanoid/body.js +0 -530
  191. package/dist/humanoid/clips.d.ts +0 -62
  192. package/dist/humanoid/clips.d.ts.map +0 -1
  193. package/dist/humanoid/clips.js +0 -121
  194. package/dist/humanoid/compose.d.ts +0 -75
  195. package/dist/humanoid/compose.d.ts.map +0 -1
  196. package/dist/humanoid/compose.js +0 -176
  197. package/dist/humanoid/generate.d.ts +0 -92
  198. package/dist/humanoid/generate.d.ts.map +0 -1
  199. package/dist/humanoid/generate.js +0 -124
  200. package/dist/humanoid/index.d.ts +0 -24
  201. package/dist/humanoid/index.d.ts.map +0 -1
  202. package/dist/humanoid/index.js +0 -18
  203. package/dist/humanoid/schema.d.ts +0 -35
  204. package/dist/humanoid/schema.d.ts.map +0 -1
  205. package/dist/humanoid/schema.js +0 -87
  206. package/dist/humanoid/skeleton.d.ts +0 -103
  207. package/dist/humanoid/skeleton.d.ts.map +0 -1
  208. package/dist/humanoid/skeleton.js +0 -289
  209. package/dist/index.d.ts +0 -37
  210. package/dist/index.d.ts.map +0 -1
  211. package/dist/index.js +0 -30
  212. package/dist/input/input-manager.d.ts +0 -945
  213. package/dist/input/input-manager.d.ts.map +0 -1
  214. package/dist/input/input-manager.js +0 -2207
  215. package/dist/input/input-types.d.ts +0 -174
  216. package/dist/input/input-types.d.ts.map +0 -1
  217. package/dist/input/input-types.js +0 -1
  218. package/dist/input/prompt-labels.d.ts +0 -21
  219. package/dist/input/prompt-labels.d.ts.map +0 -1
  220. package/dist/input/prompt-labels.js +0 -121
  221. package/dist/input/rebind-controller.d.ts +0 -59
  222. package/dist/input/rebind-controller.d.ts.map +0 -1
  223. package/dist/input/rebind-controller.js +0 -85
  224. package/dist/input/schema.d.ts +0 -16
  225. package/dist/input/schema.d.ts.map +0 -1
  226. package/dist/input/schema.js +0 -228
  227. package/dist/loader.d.ts +0 -43
  228. package/dist/loader.d.ts.map +0 -1
  229. package/dist/loader.js +0 -59
  230. package/dist/manifest/index.d.ts +0 -5
  231. package/dist/manifest/index.d.ts.map +0 -1
  232. package/dist/manifest/index.js +0 -8
  233. package/dist/manifest/load-file.d.ts +0 -4
  234. package/dist/manifest/load-file.d.ts.map +0 -1
  235. package/dist/manifest/load-file.js +0 -14
  236. package/dist/manifest/load.d.ts +0 -144
  237. package/dist/manifest/load.d.ts.map +0 -1
  238. package/dist/manifest/load.js +0 -273
  239. package/dist/manifest/schema.d.ts +0 -230
  240. package/dist/manifest/schema.d.ts.map +0 -1
  241. package/dist/manifest/schema.js +0 -394
  242. package/dist/physics/collision-system.d.ts +0 -41
  243. package/dist/physics/collision-system.d.ts.map +0 -1
  244. package/dist/physics/collision-system.js +0 -64
  245. package/dist/physics/physics-registry.d.ts +0 -45
  246. package/dist/physics/physics-registry.d.ts.map +0 -1
  247. package/dist/physics/physics-registry.js +0 -65
  248. package/dist/physics/transform-writer.d.ts +0 -16
  249. package/dist/physics/transform-writer.d.ts.map +0 -1
  250. package/dist/physics/transform-writer.js +0 -38
  251. package/dist/physics/trigger-dispatch.d.ts +0 -24
  252. package/dist/physics/trigger-dispatch.d.ts.map +0 -1
  253. package/dist/physics/trigger-dispatch.js +0 -80
  254. package/dist/react/game-state.d.ts +0 -156
  255. package/dist/react/game-state.d.ts.map +0 -1
  256. package/dist/react/game-state.js +0 -222
  257. package/dist/react/root-adapter.d.ts +0 -11
  258. package/dist/react/root-adapter.d.ts.map +0 -1
  259. package/dist/react/root-adapter.js +0 -41
  260. package/dist/react/unmanaged-root-detector.d.ts +0 -12
  261. package/dist/react/unmanaged-root-detector.d.ts.map +0 -1
  262. package/dist/react/unmanaged-root-detector.js +0 -45
  263. package/dist/react/use-data.d.ts +0 -60
  264. package/dist/react/use-data.d.ts.map +0 -1
  265. package/dist/react/use-data.js +0 -101
  266. package/dist/react/use-selection.d.ts +0 -75
  267. package/dist/react/use-selection.d.ts.map +0 -1
  268. package/dist/react/use-selection.js +0 -90
  269. package/dist/render/auto-batcher.d.ts +0 -34
  270. package/dist/render/auto-batcher.d.ts.map +0 -1
  271. package/dist/render/auto-batcher.js +0 -140
  272. package/dist/render/render-batch-system.d.ts +0 -33
  273. package/dist/render/render-batch-system.d.ts.map +0 -1
  274. package/dist/render/render-batch-system.js +0 -230
  275. package/dist/render/render-features.d.ts +0 -47
  276. package/dist/render/render-features.d.ts.map +0 -1
  277. package/dist/render/render-features.js +0 -105
  278. package/dist/render/render-settings.d.ts +0 -36
  279. package/dist/render/render-settings.d.ts.map +0 -1
  280. package/dist/render/render-settings.js +0 -51
  281. package/dist/runtime/create-runtime.d.ts +0 -249
  282. package/dist/runtime/create-runtime.d.ts.map +0 -1
  283. package/dist/runtime/create-runtime.js +0 -641
  284. package/dist/runtime/debug-bridge.d.ts +0 -257
  285. package/dist/runtime/debug-bridge.d.ts.map +0 -1
  286. package/dist/runtime/debug-bridge.js +0 -224
  287. package/dist/runtime/debug-registry.d.ts +0 -288
  288. package/dist/runtime/debug-registry.d.ts.map +0 -1
  289. package/dist/runtime/debug-registry.js +0 -513
  290. package/dist/runtime/frame-selector-cache.d.ts +0 -41
  291. package/dist/runtime/frame-selector-cache.d.ts.map +0 -1
  292. package/dist/runtime/frame-selector-cache.js +0 -65
  293. package/dist/runtime/game.d.ts +0 -496
  294. package/dist/runtime/game.d.ts.map +0 -1
  295. package/dist/runtime/game.js +0 -741
  296. package/dist/runtime/gameplay-rng-trap.d.ts +0 -48
  297. package/dist/runtime/gameplay-rng-trap.d.ts.map +0 -1
  298. package/dist/runtime/gameplay-rng-trap.js +0 -96
  299. package/dist/runtime/input-router.d.ts +0 -78
  300. package/dist/runtime/input-router.d.ts.map +0 -1
  301. package/dist/runtime/input-router.js +0 -171
  302. package/dist/runtime/mount-game.d.ts +0 -129
  303. package/dist/runtime/mount-game.d.ts.map +0 -1
  304. package/dist/runtime/mount-game.js +0 -152
  305. package/dist/runtime/mount-manifest.d.ts +0 -173
  306. package/dist/runtime/mount-manifest.d.ts.map +0 -1
  307. package/dist/runtime/mount-manifest.js +0 -297
  308. package/dist/runtime/render-audio-control.d.ts +0 -110
  309. package/dist/runtime/render-audio-control.d.ts.map +0 -1
  310. package/dist/runtime/render-audio-control.js +0 -111
  311. package/dist/runtime/render-control.d.ts +0 -291
  312. package/dist/runtime/render-control.d.ts.map +0 -1
  313. package/dist/runtime/render-control.js +0 -264
  314. package/dist/runtime/render-seed.d.ts +0 -57
  315. package/dist/runtime/render-seed.d.ts.map +0 -1
  316. package/dist/runtime/render-seed.js +0 -74
  317. package/dist/runtime/state-bridge.d.ts +0 -61
  318. package/dist/runtime/state-bridge.d.ts.map +0 -1
  319. package/dist/runtime/state-bridge.js +0 -63
  320. package/dist/runtime/types.d.ts +0 -253
  321. package/dist/runtime/types.d.ts.map +0 -1
  322. package/dist/runtime/types.js +0 -1
  323. package/dist/scene/asset-loaders.d.ts +0 -79
  324. package/dist/scene/asset-loaders.d.ts.map +0 -1
  325. package/dist/scene/asset-loaders.js +0 -141
  326. package/dist/scene/asset-paths.d.ts +0 -11
  327. package/dist/scene/asset-paths.d.ts.map +0 -1
  328. package/dist/scene/asset-paths.js +0 -108
  329. package/dist/scene/asset-ref-check.d.ts +0 -88
  330. package/dist/scene/asset-ref-check.d.ts.map +0 -1
  331. package/dist/scene/asset-ref-check.js +0 -214
  332. package/dist/scene/asset-registry.d.ts +0 -38
  333. package/dist/scene/asset-registry.d.ts.map +0 -1
  334. package/dist/scene/asset-registry.js +0 -66
  335. package/dist/scene/collider-dimensions.d.ts +0 -63
  336. package/dist/scene/collider-dimensions.d.ts.map +0 -1
  337. package/dist/scene/collider-dimensions.js +0 -98
  338. package/dist/scene/component-registry.d.ts +0 -22
  339. package/dist/scene/component-registry.d.ts.map +0 -1
  340. package/dist/scene/component-registry.js +0 -37
  341. package/dist/scene/defaults.d.ts +0 -252
  342. package/dist/scene/defaults.d.ts.map +0 -1
  343. package/dist/scene/defaults.js +0 -151
  344. package/dist/scene/geometries/index.d.ts +0 -8
  345. package/dist/scene/geometries/index.d.ts.map +0 -1
  346. package/dist/scene/geometries/index.js +0 -7
  347. package/dist/scene/geometries/terrain.d.ts +0 -2
  348. package/dist/scene/geometries/terrain.d.ts.map +0 -1
  349. package/dist/scene/geometries/terrain.js +0 -37
  350. package/dist/scene/geometry-registry.d.ts +0 -24
  351. package/dist/scene/geometry-registry.d.ts.map +0 -1
  352. package/dist/scene/geometry-registry.js +0 -20
  353. package/dist/scene/instance-registry.d.ts +0 -36
  354. package/dist/scene/instance-registry.d.ts.map +0 -1
  355. package/dist/scene/instance-registry.js +0 -55
  356. package/dist/scene/instancers/grid.d.ts +0 -2
  357. package/dist/scene/instancers/grid.d.ts.map +0 -1
  358. package/dist/scene/instancers/grid.js +0 -36
  359. package/dist/scene/instancers/index.d.ts +0 -8
  360. package/dist/scene/instancers/index.d.ts.map +0 -1
  361. package/dist/scene/instancers/index.js +0 -7
  362. package/dist/scene/light-camera-factory.d.ts +0 -23
  363. package/dist/scene/light-camera-factory.d.ts.map +0 -1
  364. package/dist/scene/light-camera-factory.js +0 -68
  365. package/dist/scene/material-factory.d.ts +0 -17
  366. package/dist/scene/material-factory.d.ts.map +0 -1
  367. package/dist/scene/material-factory.js +0 -197
  368. package/dist/scene/material-registry.d.ts +0 -40
  369. package/dist/scene/material-registry.d.ts.map +0 -1
  370. package/dist/scene/material-registry.js +0 -44
  371. package/dist/scene/materials/index.d.ts +0 -8
  372. package/dist/scene/materials/index.d.ts.map +0 -1
  373. package/dist/scene/materials/index.js +0 -7
  374. package/dist/scene/materials/water.d.ts +0 -2
  375. package/dist/scene/materials/water.d.ts.map +0 -1
  376. package/dist/scene/materials/water.js +0 -54
  377. package/dist/scene/parse.d.ts +0 -23
  378. package/dist/scene/parse.d.ts.map +0 -1
  379. package/dist/scene/parse.js +0 -179
  380. package/dist/scene/particles-factory.d.ts +0 -33
  381. package/dist/scene/particles-factory.d.ts.map +0 -1
  382. package/dist/scene/particles-factory.js +0 -282
  383. package/dist/scene/scene-apply.d.ts +0 -109
  384. package/dist/scene/scene-apply.d.ts.map +0 -1
  385. package/dist/scene/scene-apply.js +0 -370
  386. package/dist/scene/scene-diff-schema.d.ts +0 -285
  387. package/dist/scene/scene-diff-schema.d.ts.map +0 -1
  388. package/dist/scene/scene-diff-schema.js +0 -92
  389. package/dist/scene/scene-diff-types.d.ts +0 -40
  390. package/dist/scene/scene-diff-types.d.ts.map +0 -1
  391. package/dist/scene/scene-diff-types.js +0 -14
  392. package/dist/scene/scene-loader.d.ts +0 -167
  393. package/dist/scene/scene-loader.d.ts.map +0 -1
  394. package/dist/scene/scene-loader.js +0 -1211
  395. package/dist/scene/scene-query.d.ts +0 -11
  396. package/dist/scene/scene-query.d.ts.map +0 -1
  397. package/dist/scene/scene-query.js +0 -63
  398. package/dist/scene/scene-types.d.ts +0 -10
  399. package/dist/scene/scene-types.d.ts.map +0 -1
  400. package/dist/scene/scene-types.js +0 -8
  401. package/dist/scene/scene-version.d.ts +0 -26
  402. package/dist/scene/scene-version.d.ts.map +0 -1
  403. package/dist/scene/scene-version.js +0 -34
  404. package/dist/scene/schema/animation.d.ts +0 -8
  405. package/dist/scene/schema/animation.d.ts.map +0 -1
  406. package/dist/scene/schema/animation.js +0 -42
  407. package/dist/scene/schema/audio.d.ts +0 -13
  408. package/dist/scene/schema/audio.d.ts.map +0 -1
  409. package/dist/scene/schema/audio.js +0 -22
  410. package/dist/scene/schema/camera.d.ts +0 -28
  411. package/dist/scene/schema/camera.d.ts.map +0 -1
  412. package/dist/scene/schema/camera.js +0 -17
  413. package/dist/scene/schema/collider.d.ts +0 -40
  414. package/dist/scene/schema/collider.d.ts.map +0 -1
  415. package/dist/scene/schema/collider.js +0 -55
  416. package/dist/scene/schema/entity-ref.d.ts +0 -31
  417. package/dist/scene/schema/entity-ref.d.ts.map +0 -1
  418. package/dist/scene/schema/entity-ref.js +0 -61
  419. package/dist/scene/schema/entity.d.ts +0 -1036
  420. package/dist/scene/schema/entity.d.ts.map +0 -1
  421. package/dist/scene/schema/entity.js +0 -153
  422. package/dist/scene/schema/environment.d.ts +0 -425
  423. package/dist/scene/schema/environment.d.ts.map +0 -1
  424. package/dist/scene/schema/environment.js +0 -357
  425. package/dist/scene/schema/index.d.ts +0 -37
  426. package/dist/scene/schema/index.d.ts.map +0 -1
  427. package/dist/scene/schema/index.js +0 -19
  428. package/dist/scene/schema/instances.d.ts +0 -14
  429. package/dist/scene/schema/instances.d.ts.map +0 -1
  430. package/dist/scene/schema/instances.js +0 -28
  431. package/dist/scene/schema/joint.d.ts +0 -23
  432. package/dist/scene/schema/joint.d.ts.map +0 -1
  433. package/dist/scene/schema/joint.js +0 -23
  434. package/dist/scene/schema/light.d.ts +0 -38
  435. package/dist/scene/schema/light.d.ts.map +0 -1
  436. package/dist/scene/schema/light.js +0 -26
  437. package/dist/scene/schema/material.d.ts +0 -199
  438. package/dist/scene/schema/material.d.ts.map +0 -1
  439. package/dist/scene/schema/material.js +0 -103
  440. package/dist/scene/schema/mesh.d.ts +0 -48
  441. package/dist/scene/schema/mesh.d.ts.map +0 -1
  442. package/dist/scene/schema/mesh.js +0 -82
  443. package/dist/scene/schema/particles.d.ts +0 -2178
  444. package/dist/scene/schema/particles.d.ts.map +0 -1
  445. package/dist/scene/schema/particles.js +0 -321
  446. package/dist/scene/schema/physics.d.ts +0 -56
  447. package/dist/scene/schema/physics.d.ts.map +0 -1
  448. package/dist/scene/schema/physics.js +0 -37
  449. package/dist/scene/schema/scene-file.d.ts +0 -303
  450. package/dist/scene/schema/scene-file.d.ts.map +0 -1
  451. package/dist/scene/schema/scene-file.js +0 -256
  452. package/dist/scene/schema/shadow.d.ts +0 -28
  453. package/dist/scene/schema/shadow.d.ts.map +0 -1
  454. package/dist/scene/schema/shadow.js +0 -20
  455. package/dist/scene/schema/spline.d.ts +0 -25
  456. package/dist/scene/schema/spline.d.ts.map +0 -1
  457. package/dist/scene/schema/spline.js +0 -15
  458. package/dist/scene/schema/tuples.d.ts +0 -12
  459. package/dist/scene/schema/tuples.d.ts.map +0 -1
  460. package/dist/scene/schema/tuples.js +0 -14
  461. package/dist/scene/user-data.d.ts +0 -185
  462. package/dist/scene/user-data.d.ts.map +0 -1
  463. package/dist/scene/user-data.js +0 -144
  464. package/dist/setup/setup-audio.d.ts +0 -20
  465. package/dist/setup/setup-audio.d.ts.map +0 -1
  466. package/dist/setup/setup-audio.js +0 -41
  467. package/dist/setup/setup-particles.d.ts +0 -17
  468. package/dist/setup/setup-particles.d.ts.map +0 -1
  469. package/dist/setup/setup-particles.js +0 -16
  470. package/dist/setup/setup-physics.d.ts +0 -25
  471. package/dist/setup/setup-physics.d.ts.map +0 -1
  472. package/dist/setup/setup-physics.js +0 -51
  473. package/dist/setup/setup-renderer.d.ts +0 -69
  474. package/dist/setup/setup-renderer.d.ts.map +0 -1
  475. package/dist/setup/setup-renderer.js +0 -363
  476. package/dist/tools/define-tool.d.ts +0 -130
  477. package/dist/tools/define-tool.d.ts.map +0 -1
  478. package/dist/tools/define-tool.js +0 -96
  479. package/dist/world2d/authoring-2d.d.ts +0 -80
  480. package/dist/world2d/authoring-2d.d.ts.map +0 -1
  481. package/dist/world2d/authoring-2d.js +0 -195
  482. package/dist/world2d/capture-to-scene2d.d.ts +0 -5
  483. package/dist/world2d/capture-to-scene2d.d.ts.map +0 -1
  484. package/dist/world2d/capture-to-scene2d.js +0 -49
  485. package/dist/world2d/collision-2d.d.ts +0 -52
  486. package/dist/world2d/collision-2d.d.ts.map +0 -1
  487. package/dist/world2d/collision-2d.js +0 -70
  488. package/dist/world2d/components-2d.d.ts +0 -47
  489. package/dist/world2d/components-2d.d.ts.map +0 -1
  490. package/dist/world2d/components-2d.js +0 -77
  491. package/dist/world2d/index.d.ts +0 -34
  492. package/dist/world2d/index.d.ts.map +0 -1
  493. package/dist/world2d/index.js +0 -32
  494. package/dist/world2d/ingest-iframe-2d.d.ts +0 -82
  495. package/dist/world2d/ingest-iframe-2d.d.ts.map +0 -1
  496. package/dist/world2d/ingest-iframe-2d.js +0 -166
  497. package/dist/world2d/ingest2d.d.ts +0 -97
  498. package/dist/world2d/ingest2d.d.ts.map +0 -1
  499. package/dist/world2d/ingest2d.js +0 -40
  500. package/dist/world2d/physics2d-registry.d.ts +0 -24
  501. package/dist/world2d/physics2d-registry.d.ts.map +0 -1
  502. package/dist/world2d/physics2d-registry.js +0 -38
  503. package/dist/world2d/pixi-game-adapter.d.ts +0 -107
  504. package/dist/world2d/pixi-game-adapter.d.ts.map +0 -1
  505. package/dist/world2d/pixi-game-adapter.js +0 -210
  506. package/dist/world2d/pixi-surface.d.ts +0 -39
  507. package/dist/world2d/pixi-surface.d.ts.map +0 -1
  508. package/dist/world2d/pixi-surface.js +0 -47
  509. package/dist/world2d/scene-capture-2d.d.ts +0 -43
  510. package/dist/world2d/scene-capture-2d.d.ts.map +0 -1
  511. package/dist/world2d/scene-capture-2d.js +0 -92
  512. package/dist/world2d/scene2d-loader.d.ts +0 -27
  513. package/dist/world2d/scene2d-loader.d.ts.map +0 -1
  514. package/dist/world2d/scene2d-loader.js +0 -275
  515. package/dist/world2d/schema/entity2d.d.ts +0 -102
  516. package/dist/world2d/schema/entity2d.d.ts.map +0 -1
  517. package/dist/world2d/schema/entity2d.js +0 -119
  518. package/dist/world2d/schema/physics2d.d.ts +0 -46
  519. package/dist/world2d/schema/physics2d.d.ts.map +0 -1
  520. package/dist/world2d/schema/physics2d.js +0 -45
  521. package/dist/world2d/schema/sprite.d.ts +0 -42
  522. package/dist/world2d/schema/sprite.d.ts.map +0 -1
  523. package/dist/world2d/schema/sprite.js +0 -63
  524. package/dist/world2d/schema/tilemap.d.ts +0 -15
  525. package/dist/world2d/schema/tilemap.d.ts.map +0 -1
  526. package/dist/world2d/schema/tilemap.js +0 -19
  527. package/dist/world2d/schema/tuples2d.d.ts +0 -20
  528. package/dist/world2d/schema/tuples2d.d.ts.map +0 -1
  529. package/dist/world2d/schema/tuples2d.js +0 -19
  530. package/dist/world2d/system-adapters-2d.d.ts +0 -16
  531. package/dist/world2d/system-adapters-2d.d.ts.map +0 -1
  532. package/dist/world2d/system-adapters-2d.js +0 -37
  533. package/dist/world2d/transform-writer-2d.d.ts +0 -16
  534. package/dist/world2d/transform-writer-2d.d.ts.map +0 -1
  535. package/dist/world2d/transform-writer-2d.js +0 -22
  536. package/dist/world2d/types.d.ts +0 -59
  537. package/dist/world2d/types.d.ts.map +0 -1
  538. package/dist/world2d/types.js +0 -1
@@ -1,641 +0,0 @@
1
- import * as THREE from 'three';
2
- import { assertNever } from '../adapter/adapter-surface';
3
- import { createAssetCache } from '../assets';
4
- import { createGameLoop } from '../core/game-loop';
5
- import { createHostRenderer } from '../setup/setup-renderer';
6
- import { createGame, createWorldInstance, isFirstPartyMounted, } from './game';
7
- import { createInputRouter, stackOrder } from './input-router';
8
- // Re-export the camera-precedence helper from its new home so existing importers
9
- // (`import { adoptSceneCamera } from '@engine/runtime/create-runtime'`) keep working.
10
- export { adoptSceneCamera } from '../adapter/vgai-scene-game-adapter';
11
- /**
12
- * Register a threejs world for a freshly-mounted game onto the Game shell.
13
- * Shared by `createGameRuntime` and every headless test harness
14
- * (`test/game-root.test.ts`, `test/frame-order.test.ts`,
15
- * `test/game-two-roots.test.ts`) so there is exactly one code path for this
16
- * wiring (T7.1 slice 1, id-generalized in slice 3 for the two-world proof —
17
- * `docs/GAME-ROOT-DESIGN.md` §8 stage 3) — `physics`/`collisions`/`camera`/
18
- * `frame` are populated from the mount's first-party `GameContext`/
19
- * `VgaiMountedGame` when available, left `undefined` otherwise (an external
20
- * adapter's mount has none of these first-party handles — `frame` in
21
- * particular is what makes `GameInternal.runFrame` (T7.1 slice 2) fall back
22
- * to a single opaque `mounted.update` call per substep for such a world).
23
- */
24
- function firstPartyExtras(mounted) {
25
- if (!isFirstPartyMounted(mounted))
26
- return {};
27
- return {
28
- physics: mounted.ctx.physics,
29
- collisions: mounted.ctx.collisions,
30
- camera: mounted.ctx.camera,
31
- frame: mounted.frame,
32
- };
33
- }
34
- /**
35
- * Register a threejs world onto the Game shell. `opts.id` defaults to
36
- * `'main'` — the single-world callers (`createGameRuntime`, slice-1/2 tests)
37
- * are unaffected; a second/third world (T7.1 slice 3's two-world proof, and
38
- * real multi-world manifests later) pass an explicit id. This is the ONE
39
- * registration code path for a threejs world, whatever its id.
40
- */
41
- export function registerThreeWorld(game, adapter, mounted, opts) {
42
- const world = createWorldInstance({
43
- id: opts?.id ?? 'main',
44
- kind: 'threejs',
45
- pausable: opts?.pausable ?? true,
46
- adapter,
47
- mounted,
48
- scene: mounted.scene,
49
- ...firstPartyExtras(mounted),
50
- });
51
- // T7.2 slice 2 — one-time world-wiring backfill (closes the KNOWN GAP
52
- // documented on `resolveWorldInstance` in `ecs/component-manager.ts`):
53
- // scene-authored components were attached by the scene loader DURING the
54
- // `mount()` call that just returned `mounted`, before this `WorldInstance`
55
- // existed — so `instance.world` was left `undefined` for every one of
56
- // them. `adoptWorld` backfills it now, once, for every already-attached
57
- // instance still missing a world. Attaches made AFTER this point (e.g.
58
- // runtime-spawned entities once the game is ticking) still resolve their
59
- // world directly at attach time, unaffected by this call.
60
- if (isFirstPartyMounted(mounted)) {
61
- mounted.ctx.components.adoptWorld(world);
62
- }
63
- game.registerWorld(world);
64
- return world;
65
- }
66
- /**
67
- * Register a pixijs world onto the Game shell — the pixi analog of
68
- * {@link registerThreeWorld}, mirroring the wiring
69
- * `world2d/pixi-game-adapter.ts`'s `createWorld2DRuntime` performs for its
70
- * OWN (separate) Game, and `test/game-three-plus-pixi.test.ts` performs by
71
- * hand onto a SHARED Game. `createGameRuntime`'s roots path
72
- * (T6.1 slice 1) is the first PRODUCTION caller that registers a pixijs
73
- * world alongside other roots on one Game; this is its one wiring code
74
- * path, so a second/third pixijs world (or a future caller) never
75
- * re-derives it. `adapter` is typed as the real {@link Pixi2DGameAdapter}
76
- * shape (T7.5 — previously the generic `GameAdapter`, which forced a cast at
77
- * every call site since a pixi adapter's `mount` takes a `World2DHost`, not
78
- * `HostContext`); `WorldInstance.adapter` itself only needs `.id`
79
- * (`AdapterHandle`, `runtime/game.ts`), so this passes through with zero cast.
80
- *
81
- * Section 7.4-5 (design-gap catalog), UPDATED by wave 2 (D-Y1,
82
- * docs/EXTERNAL-REACT-AND-MODULE-DESIGN.md §1/§4 slice S1): this guard used
83
- * to THROW for a non-first-party mount, reasoning "today this can never
84
- * actually fire (Pixi2DGameAdapter.mount is typed to always return a
85
- * MountedGame2D, whose ctx/physics2d/collisions2d/frame are all REQUIRED
86
- * fields, so there is no foreign-mount shape that could reach here)". Wave 2
87
- * proved that reasoning stale: a `kind: 'pixijs'` `{ module }` adapter's mount
88
- * result IS exactly such a foreign shape — `Pixi2DGameAdapter`'s TYPE promises
89
- * `MountedGame2D`, but `adapter-resolver.ts`'s `resolveAllWorlds` reaches it
90
- * only via `adapter as unknown as Pixi2DGameAdapter` (a custom module's actual
91
- * return value is merely `MountedPixiWorld`-shaped, T7.5's cross-kind union),
92
- * so the "never actually fire" premise no longer holds the moment a custom
93
- * pixi module world reaches the roots path. Rather than keep the throw (which
94
- * would re-create exactly the kind of dead end D-X6 named and D-Y1 exists to
95
- * remove), this now degrades EXACTLY like `registerThreeWorld`'s own foreign-
96
- * mount handling above (`firstPartyExtras`): `physics2d`/`collisions2d`/
97
- * `frame`/component-adoption are omitted for a non-first-party mount instead
98
- * of read from a `.ctx` that doesn't exist — `stage` (the one field every
99
- * `MountedPixiWorld`, first-party or not, actually carries) is always real.
100
- */
101
- function pixiFirstPartyExtras(mounted) {
102
- // Same structural check `firstPartyExtras`/`isFirstPartyMounted` use — see
103
- // this function's own doc comment (above `registerPixiWorld`) for why this
104
- // stays a plain boolean read rather than a type-guarded `isFirstPartyMounted`
105
- // call (that guard's threejs-shaped return type would narrow `mounted` to
106
- // `never` here).
107
- if (mounted.firstParty !== true)
108
- return {};
109
- return {
110
- physics2d: mounted.ctx.physics2d,
111
- collisions2d: mounted.ctx.collisions2d,
112
- frame: mounted.frame,
113
- };
114
- }
115
- export function registerPixiWorld(game, adapter, mounted, opts) {
116
- const id = opts?.id ?? 'main';
117
- const mountedIsFirstParty = mounted.firstParty === true;
118
- const world = createWorldInstance({
119
- id,
120
- kind: 'pixijs',
121
- pausable: opts?.pausable ?? true,
122
- adapter,
123
- mounted,
124
- stage: mounted.stage,
125
- ...pixiFirstPartyExtras(mounted),
126
- });
127
- // Mirrors `registerThreeWorld`'s adoptWorld backfill above — the pixi
128
- // world's scene-authored components attach during `mount()`, before this
129
- // `WorldInstance` exists. Skipped for a non-first-party mount (a foreign
130
- // `{ module }` adapter's `ComponentManager` doesn't exist to adopt into —
131
- // same "nothing for a custom adapter to backfill" reasoning
132
- // `registerReactWorld`'s doc comment records for react).
133
- if (mountedIsFirstParty)
134
- mounted.ctx.components.adoptWorld(world);
135
- game.registerWorld(world);
136
- return world;
137
- }
138
- /**
139
- * Register a react world onto the Game shell (T6.2 slice 1,
140
- * `docs/REACT-WORLD-DESIGN.md` §1.B) — the react analog of
141
- * {@link registerThreeWorld}/{@link registerPixiWorld}. A react world has no
142
- * `ComponentManager` to adopt (D8: react entities host no GameComponents —
143
- * there is nothing for `adoptWorld` to backfill, unlike the three/pixi
144
- * siblings above) and no `frame` hooks (react's own `createRoot` schedules
145
- * its commits; `GameInternal.runFrame` correctly leaves a world with no
146
- * `frame` untouched by its opaque-`update` fallback too, since
147
- * `MountedReactGame` declares no `update`). `adapter` is typed as the real
148
- * {@link ReactRootAdapter} shape (T7.5, same reasoning as
149
- * `registerPixiWorld`'s doc comment above) — `WorldInstance.adapter` only
150
- * needs `.id`, so this passes through with zero cast.
151
- */
152
- export function registerReactWorld(game, adapter, mounted, container, opts) {
153
- const world = createWorldInstance({
154
- id: opts?.id ?? 'main',
155
- kind: 'react',
156
- pausable: opts?.pausable ?? true,
157
- adapter,
158
- mounted,
159
- container,
160
- });
161
- game.registerWorld(world);
162
- return world;
163
- }
164
- /**
165
- * Bootstrap the game host and mount a game adapter.
166
- *
167
- * `createGameRuntime` is the universal HOST: it owns the root surfaces,
168
- * renderers, loop, and asset cache. Every game — including a one-root game —
169
- * uses the same explicit adapter-root path.
170
- */
171
- export async function createGameRuntime(config) {
172
- return createWorldsGameRuntime(config);
173
- }
174
- // ---------------------------------------------------------------------------
175
- // Worlds path (T6.1 slice 1 — docs/MULTI-WORLD-DESIGN.md §1.A/B/C)
176
- // ---------------------------------------------------------------------------
177
- /** A stand-in `THREE.WebGLRenderer` for headless (`headless:true`) threejs
178
- * roots — mirrors `VgaiSceneGameAdapter.mount`'s own `headlessComposer`
179
- * pattern (`adapter/vgai-scene-game-adapter.ts`): a headless first-party
180
- * mount never calls a render-phase method on `host.renderer` at all, so
181
- * this only needs to satisfy the handful of calls THIS file itself makes
182
- * (`setPixelRatio`/`setClearColor`/`setSize` at mount, `dispose`/
183
- * `forceContextLoss` at teardown) — never a real GL call. Node conformance
184
- * tests only; never used when `headless` is left `false`/absent. */
185
- function createHeadlessRendererStub() {
186
- return {
187
- setPixelRatio() { },
188
- setClearColor() { },
189
- setSize() { },
190
- dispose() { },
191
- forceContextLoss() { },
192
- };
193
- }
194
- /**
195
- * Derive a REAL default `hitTest` for a pixijs world from its own mounted
196
- * stage (D5 §2a/COMPOSITION-DESIGN.md proof item 2: "pixi `EventBoundary
197
- * .hitTest`") — used only when the caller's `WorldMountSpec` didn't declare
198
- * an explicit `hitTest`. `(x, y)` are container-relative pixels, matching
199
- * the coordinates the pixi surface renders at (the stage itself carries no
200
- * pan/zoom — that lives on `pixi-surface.ts`'s child `world` container, per
201
- * its own doc comment), so this is a correct global hit test with no extra
202
- * coordinate mapping. Duck-typed against `mounted.ctx.app` (never a
203
- * value-import of `pixi.js`) so this file stays type-only w.r.t. Pixi;
204
- * returns `undefined` (no default claim) if the mount's `app`/event
205
- * boundary isn't shaped as expected — degrade to "does not claim" rather
206
- * than throw. A non-first-party mount (D-Y1, wave 2 — same finding
207
- * `registerPixiWorld`'s doc comment records: a `{ module }` adapter's mount
208
- * has no `.ctx` at all) has nothing to duck-type here either, so this checks
209
- * the SAME `firstParty` brand FIRST and degrades identically — never claims,
210
- * never throws.
211
- */
212
- function derivePixiHitTest(mounted) {
213
- if (mounted.firstParty !== true)
214
- return undefined;
215
- const app = mounted.ctx.app;
216
- const rootBoundary = app?.renderer?.events?.rootBoundary;
217
- if (!rootBoundary || typeof rootBoundary.hitTest !== 'function')
218
- return undefined;
219
- // Pixi assigns `rootTarget` lazily on the first render. Pointer movement
220
- // can reach the host router during that small window (or while a world is
221
- // tearing down); EventBoundary.hitTest dereferences it unconditionally.
222
- // An unready boundary cannot claim input, so degrade to no hit instead of
223
- // surfacing Pixi's internal `undefined.eventMode` exception.
224
- return (x, y) => rootBoundary.rootTarget != null && rootBoundary.hitTest(x, y) != null;
225
- }
226
- /** Mount one threejs `WorldMountSpec` (canvas + renderer construction, per
227
- * D5 §1/§4, then `registerThreeWorld`). Split out of
228
- * `createWorldsGameRuntime` purely to keep that function's own branching
229
- * simple — see `mountOnePixiWorld` for the pixijs sibling. */
230
- async function mountOneThreeWorld(spec, ctx) {
231
- const { game, canvas, w, h, dpr, isBottom, headless, loopHandle, assets } = ctx;
232
- const renderer = headless
233
- ? createHeadlessRendererStub()
234
- : createHostRenderer(canvas, w, h, undefined, {
235
- alpha: !isBottom,
236
- preserveDrawingBuffer: true,
237
- });
238
- renderer.setSize(w, h, false); // backing resolution only — CSS stacking owns layout size
239
- // Defect E4.R1 (Fable review): `createHostRenderer`'s OWN construction-time
240
- // `setSize` call (`setup-renderer.ts`, `updateStyle` defaulting `true` —
241
- // unchanged there on purpose, see below) stamps `canvas.style.width`/
242
- // `.height` to literal `${w}px`/`${h}px` the moment the renderer is built,
243
- // OVERWRITING the container-relative `100%`/`100%` the surface-stacking
244
- // loop above just set. The `renderer.setSize(w, h, false)` line right above
245
- // this comment does NOT undo that stamp (updateStyle:false only skips
246
- // TOUCHING style, it can't un-stamp a previous call) — so without this
247
- // re-assertion, every roots-path threejs canvas' on-screen size was
248
- // permanently pinned to whatever `w`/`h` it happened to mount at (usually
249
- // the manifest's `resolution`, since standalone builds mount before a real
250
- // container size is known — see `mount-manifest.ts`). Re-asserting here
251
- // makes the CSS layout size and the render-buffer resolution fully
252
- // independent, exactly like the react DOM world layer already is: this
253
- // fixes the template-standalone bug (broken at any viewport other than the
254
- // manifest's `resolution`, which is also Playwright's DEFAULT viewport —
255
- // why it went unnoticed) and, for free, tri-world's pre-existing
256
- // resize-staleness (the roots-path `resize()` below always calls
257
- // `setSize(rw, rh, false)`, so nothing else was ever going to update this
258
- // canvas' CSS after mount). `createHostRenderer`'s own default
259
- // (`updateStyle:true`) is intentionally left alone — the LEGACY
260
- // single-canvas path (editor play-mode's non-multi-world branch) still
261
- // relies on that construction-time stamp + its own later `updateStyle:true`
262
- // resizes for byte-identical behavior; this fix touches only the
263
- // roots-path canvas, after the fact.
264
- canvas.style.width = '100%';
265
- canvas.style.height = '100%';
266
- renderer.setPixelRatio(dpr);
267
- if (!isBottom)
268
- renderer.setClearColor(0x000000, 0); // D5 §1: alpha-clear above the bottom layer
269
- const host = {
270
- three: THREE,
271
- surface: { canvas, width: w, height: h },
272
- renderer,
273
- loop: loopHandle,
274
- assets,
275
- headless,
276
- game,
277
- requestSystem: () => null,
278
- };
279
- const mounted = await spec.adapter.mount(host);
280
- registerThreeWorld(game, spec.adapter, mounted, { id: spec.id, pausable: spec.pausable });
281
- return {
282
- mountedEntry: { id: spec.id, kind: 'threejs', element: canvas, mounted, renderer },
283
- routerEntry: { id: spec.id, zOrder: spec.zOrder ?? 0, canvas, hitTest: spec.hitTest },
284
- };
285
- }
286
- /** Mount one pixijs `WorldMountSpec` (via its own `World2DHost`, per D5
287
- * §1/§3/§4, then `registerPixiWorld`) — the pixi sibling of
288
- * `mountOneThreeWorld` above. Derives a real default `hitTest` from the
289
- * mounted stage when the spec didn't declare one (see `derivePixiHitTest`).
290
- *
291
- * Unlike `mountOneThreeWorld`, this needs no explicit `canvas.style.width`/
292
- * `.height` re-assertion (E4.R1). `pixi-surface.ts` constructs its
293
- * `Application` with `autoDensity: true`, which makes PIXI ITSELF re-stamp
294
- * `canvas.style.width`/`.height` (real CSS px, matching the LOGICAL
295
- * width/height passed to `resize()`) on every `app.renderer.resize()` call —
296
- * including the one this world's `mounted.resize?.()` triggers from the
297
- * roots-path `resize()` below. So while a pixi world's canvas can start
298
- * pinned to the mount-time `w`/`h` (same as threejs, until PIXI's own
299
- * construction-time resize runs), it self-heals the moment ANY real
300
- * `session.resize(rw, rh)` fires — every shipped standalone entry
301
- * (`packages/editor/template/src/main.ts`, `examples/tri-world/src/main.ts`)
302
- * already calls `session.resize()` unconditionally right after mount, so
303
- * this never surfaces as a lasting bug the way threejs' buffer-only resize
304
- * did (never self-healing, by design — see above). */
305
- async function mountOnePixiWorld(spec, ctx) {
306
- const { game, canvas, w, h, dpr, isBottom } = ctx;
307
- const pixiHost = {
308
- canvas,
309
- width: w,
310
- height: h,
311
- game,
312
- dpr,
313
- transparent: !isBottom,
314
- preserveDrawingBuffer: true,
315
- };
316
- const mounted = await spec.adapter.mount(pixiHost);
317
- registerPixiWorld(game, spec.adapter, mounted, {
318
- id: spec.id,
319
- pausable: spec.pausable,
320
- });
321
- return {
322
- mountedEntry: {
323
- id: spec.id,
324
- kind: 'pixijs',
325
- element: canvas,
326
- mounted,
327
- renderer: undefined,
328
- },
329
- routerEntry: {
330
- id: spec.id,
331
- zOrder: spec.zOrder ?? 0,
332
- canvas,
333
- hitTest: spec.hitTest ?? derivePixiHitTest(mounted),
334
- },
335
- };
336
- }
337
- /**
338
- * Mount one react `WorldMountSpec` (T6.2 slice 1, `docs/REACT-WORLD-DESIGN.md`
339
- * §1.B/§1.C) — the react sibling of `mountOneThreeWorld`/`mountOnePixiWorld`.
340
- * Unlike its canvas-backed siblings this returns NO `routerEntry`: a react
341
- * world's DOM-root layer participates in D5's z-order/box stacking (the
342
- * caller still creates and positions its `<div>` exactly like a canvas — see
343
- * `createWorldsGameRuntime`'s stack-building loop) but needs no entry in the
344
- * delegating router's hit-test loop (§1.C — "DOM layers need no entry in the
345
- * router's hit-test loop"): the layer's own `pointer-events` discipline
346
- * (this file sets `none` on the layer by default; the mounted React tree opts specific elements back
347
- * in with `pointer-events:auto`) is what lets its interactive elements claim
348
- * events NATIVELY, via the real DOM, with zero router involvement — and lets
349
- * a click over its non-interactive (transparent) area fall through to the
350
- * canvas below it via the SAME native DOM hit-testing (a `pointer-events:none`
351
- * element is invisible to hit-testing entirely, so the click lands on
352
- * whatever real DOM element is beneath it — the router's normal
353
- * canvas-vs-canvas forwarding, unaffected by this layer's presence).
354
- */
355
- async function mountOneReactWorld(spec, game,
356
- /** The ALREADY-created, already-stacked (position/z-index set, appended to
357
- * `container`) DOM-root layer for this world — see
358
- * `createWorldsGameRuntime`'s surface-stack loop, which builds a `<div>`
359
- * for every react-kind spec up front, in the SAME pass that builds every
360
- * other world's canvas. This function must reuse that exact element (never
361
- * create its own) so `WorldInstance.reactRoot()` returns the SAME node
362
- * that is actually positioned in the stack. */
363
- layer) {
364
- layer.style.pointerEvents = 'none';
365
- // An absolutely-positioned layer with no width/height collapses to zero
366
- // content size, so a child's
367
- // own position:absolute offsets resolve against a degenerate containing
368
- // block (found by the T6.2 slice-3 e2e — clicks landed outside the game).
369
- layer.style.width = '100%';
370
- layer.style.height = '100%';
371
- const reactHost = { container: layer, game };
372
- const mounted = await spec.adapter.mount(reactHost);
373
- registerReactWorld(game, spec.adapter, mounted, layer, {
374
- id: spec.id,
375
- pausable: spec.pausable,
376
- });
377
- return {
378
- mountedEntry: {
379
- id: spec.id,
380
- kind: 'react',
381
- element: layer,
382
- mounted,
383
- renderer: undefined,
384
- },
385
- };
386
- }
387
- /**
388
- * The roots-path implementer behind {@link createGameRuntime} (T6.1 slice
389
- * 1; react roots added T6.2 slice 1). Builds ONE surface per world — a
390
- * canvas for threejs/pixijs, a DOM-root `<div>` layer for react — stacked
391
- * per COMPOSITION-DESIGN D5 §1, z-order/ties exactly matching
392
- * `manifest/load.ts`'s sort, ONE `Game`, and registers every world onto it
393
- * via `registerThreeWorld`/`registerPixiWorld`/`registerReactWorld` — the
394
- * SAME wiring `test/game-three-plus-pixi.test.ts` proves by hand for the
395
- * three/pixi pair. Worlds MOUNT in `roots` ARRAY order (GAME-ROOT-DESIGN §4's
396
- * "manifest declaration order" — the frame/registration axis), independent of
397
- * `zOrder` (the canvas-stacking/rendering axis) — the two orders can differ
398
- * and both are honored correctly.
399
- */
400
- /**
401
- * Dev/e2e-only `window.__vgaiScene`/`__vgaiCamera` exposure for the roots
402
- * path's DEFAULT world (E4) — split out of `createWorldsGameRuntime` purely
403
- * to keep that function's own cyclomatic complexity down. Mirrors the
404
- * legacy single-world path's identical exposure (above, in this same file),
405
- * using the SAME "first threejs world, else none" default-world rule the
406
- * `GameSession.scene`/`.camera` getters alias (`Game.defaultWorld`): a
407
- * non-threejs default world (or none at all) publishes neither global,
408
- * exactly like those getters return `undefined` in that case. Returns a
409
- * retraction callback — identity-guarded (a newer session's globals must
410
- * never be clobbered by an older session's stop, same reason the legacy
411
- * path's own cleanup guards it) — that is a no-op when nothing was
412
- * published (non-DEV build, or non-threejs default world).
413
- */
414
- function installDefaultWorldDevGlobals(game) {
415
- if (!import.meta.env?.DEV)
416
- return () => { };
417
- const defaultMounted = game.defaultWorld.mounted;
418
- if (defaultMounted.kind !== 'threejs')
419
- return () => { };
420
- const scene = defaultMounted.scene;
421
- const camera = defaultMounted.camera;
422
- const w = window;
423
- w['__vgaiScene'] = scene;
424
- w['__vgaiCamera'] = camera;
425
- return () => {
426
- if (w['__vgaiScene'] === scene)
427
- delete w['__vgaiScene'];
428
- if (w['__vgaiCamera'] === camera)
429
- delete w['__vgaiCamera'];
430
- };
431
- }
432
- /**
433
- * Mount + register every world spec, in ARRAY (declaration) order — split
434
- * out of `createWorldsGameRuntime` purely to keep that function's own
435
- * cyclomatic complexity down (E4, same reason `mountOneThreeWorld`/
436
- * `mountOnePixiWorld` are already split out). React roots contribute NO
437
- * router entry (docs/REACT-WORLD-DESIGN.md §1.C — "DOM layers need no entry
438
- * in the router's hit-test loop"): their layer's own `pointer-events`
439
- * discipline handles claim/fall-through natively, with zero router
440
- * involvement (see `mountOneReactWorld`'s doc comment).
441
- */
442
- async function mountAllWorldSpecs(mountSpecs, bottomId, inputs) {
443
- const { surfacesById, ...shared } = inputs;
444
- const mountedEntries = [];
445
- const routerEntries = [];
446
- for (const spec of mountSpecs) {
447
- const isBottom = spec.id === bottomId;
448
- if (spec.kind === 'react') {
449
- const layer = surfacesById.get(spec.id);
450
- const { mountedEntry } = await mountOneReactWorld(spec, shared.game, layer);
451
- mountedEntries.push(mountedEntry);
452
- continue;
453
- }
454
- const canvas = surfacesById.get(spec.id);
455
- const oneCtx = { ...shared, canvas, isBottom };
456
- let mountedEntry;
457
- let routerEntry;
458
- if (spec.kind === 'threejs') {
459
- ({ mountedEntry, routerEntry } = await mountOneThreeWorld(spec, oneCtx));
460
- }
461
- else if (spec.kind === 'pixijs') {
462
- ({ mountedEntry, routerEntry } = await mountOnePixiWorld(spec, oneCtx));
463
- }
464
- else {
465
- // Exhaustiveness guard (§7.4-2): 'react' was already handled by the
466
- // early `continue` above, so only a hypothetical 4th `AdapterSurface` can
467
- // reach here — fail loudly rather than silently defaulting. `spec`
468
- // itself (not `spec.kind`) is what TS has narrowed to `never`, since
469
- // `WorldMountSpec` is a discriminated union at the object level.
470
- assertNever(spec, 'create-runtime mount loop');
471
- }
472
- mountedEntries.push(mountedEntry);
473
- routerEntries.push(routerEntry);
474
- }
475
- return { mountedEntries, routerEntries };
476
- }
477
- async function createWorldsGameRuntime(config) {
478
- const { container, roots: specs, width, height, headless = false, seed } = config;
479
- if (specs.length === 0) {
480
- throw new Error('createGameRuntime: `roots` must contain at least one root.');
481
- }
482
- const mountSpecs = specs;
483
- const w = Math.max(1, width ?? container.clientWidth ?? 0);
484
- const h = Math.max(1, height ?? container.clientHeight ?? 0);
485
- const dpr = headless
486
- ? 1
487
- : Math.min(typeof window !== 'undefined' ? window.devicePixelRatio || 1 : 1, 2);
488
- if (!container.style.position)
489
- container.style.position = 'relative';
490
- // --- Surface stack (D5 §1): DOM/z-order follows zOrder, ties -> array
491
- // order — computed FIRST (bottom -> top) so both the z-index assignment
492
- // below and the router's default-claim rule share one definition. A react
493
- // world's DOM-root layer shares this SAME stacking pass (T6.2 slice 1,
494
- // docs/REACT-WORLD-DESIGN.md §1.B — "one stacking model, no special case")
495
- // even though it is a `<div>`, not a canvas, and carries no `hitTest` (the
496
- // router never sees react entries at all — see the dispatch loop below). ---
497
- const stacked = stackOrder(mountSpecs.map((spec) => ({ id: spec.id, zOrder: spec.zOrder ?? 0, hitTest: spec.hitTest })));
498
- const bottomId = stacked[0]?.id;
499
- const kindById = new Map(mountSpecs.map((spec) => [spec.id, spec.kind]));
500
- const surfacesById = new Map();
501
- stacked.forEach((entry, i) => {
502
- const isReact = kindById.get(entry.id) === 'react';
503
- const surface = document.createElement(isReact ? 'div' : 'canvas');
504
- if (!isReact) {
505
- const canvas = surface;
506
- canvas.width = w;
507
- canvas.height = h;
508
- }
509
- // Defect E4.R1 (Fable review): layout size is ALWAYS container-relative
510
- // (`width:100%;height:100%`), fully decoupled from the surface's
511
- // intrinsic buffer resolution (`w`/`h`, set on the canvas element's
512
- // `width`/`height` ATTRIBUTES above — a device-pixel/render-resolution
513
- // concern only). Without this, a canvas with no CSS size falls back to
514
- // its `width`/`height` attribute as its CSS layout size too, so whatever
515
- // stamped those attributes (`createHostRenderer`'s construction-time
516
- // `setSize`, `mountOneThreeWorld` below) pins the ON-SCREEN size — see
517
- // that function's doc comment for the concrete bug this caused (template
518
- // standalone at any viewport ≠ the manifest resolution). Setting it HERE
519
- // too (not just in `mountOneThreeWorld`) means every surface, whatever
520
- // kind, starts container-relative from its very first paint, before any
521
- // per-kind mount work has even run.
522
- // `contain:layout paint` makes each surface the CONTAINING BLOCK for
523
- // `position:fixed` descendants (and clips overflow to the world's
524
- // rectangle): full-screen game UI written the natural way (`fixed;
525
- // inset:0`) then fills the WORLD, not the page. Without it, `fixed` UI
526
- // looks correct standalone (surface == window) but escapes over the
527
- // editor chrome whenever the surface is a sub-rectangle of the page —
528
- // and toggles behavior when any ancestor gains a transform (e.g. the
529
- // editor's space-pan). Dogfooded 2026-07-12 via a react shell world.
530
- surface.style.cssText = `position:absolute;top:0;left:0;width:100%;height:100%;z-index:${i + 1};contain:layout paint;`;
531
- container.appendChild(surface);
532
- surfacesById.set(entry.id, surface);
533
- });
534
- const assets = createAssetCache();
535
- const extraUpdaters = new Set();
536
- const loopHandle = {
537
- onUpdate(fn) {
538
- extraUpdaters.add(fn);
539
- return () => extraUpdaters.delete(fn);
540
- },
541
- };
542
- let started = false;
543
- const loop = createGameLoop({
544
- fixedTimestep: 1 / 60,
545
- maxSubSteps: 8,
546
- update: (dt) => {
547
- if (started)
548
- game.runFrame(dt);
549
- for (const fn of extraUpdaters)
550
- fn(dt);
551
- },
552
- });
553
- const game = createGame({ loop, assets, seed });
554
- // --- Mount + register every world, in ARRAY (declaration) order. ---
555
- // Split out into its own top-level function purely to keep
556
- // `createWorldsGameRuntime`'s own cyclomatic complexity down (E4) — same
557
- // reason `mountOneThreeWorld`/`mountOnePixiWorld` are already split out
558
- // below.
559
- const { mountedEntries, routerEntries } = await mountAllWorldSpecs(mountSpecs, bottomId, {
560
- game,
561
- surfacesById,
562
- w,
563
- h,
564
- dpr,
565
- headless,
566
- loopHandle,
567
- assets,
568
- });
569
- // --- Delegating input router (D5 §2a) ---
570
- const router = createInputRouter(container, routerEntries);
571
- started = true;
572
- loop.start();
573
- // Expose scene & camera for dev tools / e2e tests — mirrors the legacy
574
- // single-world path's identical dev-only exposure above, generalized to
575
- // the roots path's DEFAULT world (E4, docs/unified-world-editor/
576
- // 27-visual-react-editing.md §7 E4): `mountGameFromManifest`/
577
- // `mountManifestWorlds` route every caller (including a single-threejs-
578
- // world scaffold project) through THIS path, so a caller migrating off
579
- // the legacy `{canvas, adapter}` call must not silently lose
580
- // `window.__vgaiScene`/`__vgaiCamera` — real e2e/dev tooling depends on
581
- // them (`packages/editor/e2e/tests/04-standalone-game.spec.ts`). Split
582
- // into its own top-level helper (with its retraction counterpart below)
583
- // purely to keep this function's own cyclomatic complexity down.
584
- const retractDevGlobals = installDefaultWorldDevGlobals(game);
585
- function fullCleanup() {
586
- loop.stop();
587
- router.dispose();
588
- for (const entry of mountedEntries) {
589
- entry.mounted.dispose();
590
- entry.renderer?.dispose();
591
- entry.renderer?.forceContextLoss();
592
- container.removeChild(entry.element);
593
- }
594
- retractDevGlobals();
595
- }
596
- return {
597
- stop: fullCleanup,
598
- // D10/T7.6: `Game.play` fans out per-world pausable/loop-gate/audio-gate
599
- // semantics itself now (see the legacy path's identical comment above) —
600
- // a `pausable: false` world (a menu/HUD world) keeps ticking while every
601
- // other world freezes, which the old blind `for (const entry of
602
- // mountedEntries) entry.mounted.setPaused?.(true)` fan-out (with no
603
- // `pausable` check at all) could never express.
604
- pause() {
605
- game.play.pause();
606
- },
607
- resume() {
608
- game.play.resume();
609
- },
610
- step() {
611
- game.play.step();
612
- },
613
- resize(rw, rh) {
614
- const safeWidth = Math.max(1, rw);
615
- const safeHeight = Math.max(1, rh);
616
- for (const entry of mountedEntries) {
617
- entry.renderer?.setSize(safeWidth, safeHeight, false);
618
- entry.mounted.resize?.(safeWidth, safeHeight);
619
- }
620
- },
621
- // `GameSession.scene`/`.camera`/`.mounted` alias `Game.defaultWorld` (T6.1
622
- // slice 1's "first threejs world, else first world" rule) — a legacy
623
- // convenience shaped for the threejs-only past. T7.5 narrows the read via
624
- // the `kind` discriminant instead of a blind `.scene`/`.camera` cast
625
- // through a nonexistent property (identical behavior to before: still
626
- // `undefined` for a roots-path session whose default world isn't
627
- // threejs — real per-world surface routing for that case is T7.6's).
628
- get scene() {
629
- const m = game.defaultWorld.mounted;
630
- return (m.kind === 'threejs' ? m.scene : undefined);
631
- },
632
- get camera() {
633
- const m = game.defaultWorld.mounted;
634
- return (m.kind === 'threejs' ? m.camera : undefined);
635
- },
636
- get mounted() {
637
- return game.defaultWorld.mounted;
638
- },
639
- game,
640
- };
641
- }