@vgai/engine 0.5.4 → 0.5.6

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 (448) hide show
  1. package/dist/adapter/adapter-surface.d.ts +30 -0
  2. package/dist/adapter/adapter-surface.d.ts.map +1 -0
  3. package/dist/adapter/adapter-surface.js +18 -0
  4. package/dist/adapter/authoring.d.ts +597 -0
  5. package/dist/adapter/authoring.d.ts.map +1 -0
  6. package/dist/adapter/authoring.js +22 -0
  7. package/dist/adapter/colyseus-networking-adapter.d.ts +77 -0
  8. package/dist/adapter/colyseus-networking-adapter.d.ts.map +1 -0
  9. package/dist/adapter/colyseus-networking-adapter.js +76 -0
  10. package/dist/adapter/first-party-systems.d.ts +23 -0
  11. package/dist/adapter/first-party-systems.d.ts.map +1 -0
  12. package/dist/adapter/first-party-systems.js +196 -0
  13. package/dist/adapter/host-context.d.ts +194 -0
  14. package/dist/adapter/host-context.d.ts.map +1 -0
  15. package/dist/adapter/host-context.js +80 -0
  16. package/dist/adapter/index.d.ts +33 -0
  17. package/dist/adapter/index.d.ts.map +1 -0
  18. package/dist/adapter/index.js +25 -0
  19. package/dist/adapter/ingest/game-contract.d.ts +53 -0
  20. package/dist/adapter/ingest/game-contract.d.ts.map +1 -0
  21. package/dist/adapter/ingest/game-contract.js +30 -0
  22. package/dist/adapter/ingest/scene-capture.d.ts +121 -0
  23. package/dist/adapter/ingest/scene-capture.d.ts.map +1 -0
  24. package/dist/adapter/ingest/scene-capture.js +270 -0
  25. package/dist/adapter/ingest/structural-ids.d.ts +64 -0
  26. package/dist/adapter/ingest/structural-ids.d.ts.map +1 -0
  27. package/dist/adapter/ingest/structural-ids.js +110 -0
  28. package/dist/adapter/ingest/upstream-pin.d.ts +44 -0
  29. package/dist/adapter/ingest/upstream-pin.d.ts.map +1 -0
  30. package/dist/adapter/ingest/upstream-pin.js +47 -0
  31. package/dist/adapter/loop-gate-report.d.ts +34 -0
  32. package/dist/adapter/loop-gate-report.d.ts.map +1 -0
  33. package/dist/adapter/loop-gate-report.js +37 -0
  34. package/dist/adapter/rapier-physics-adapter.d.ts +69 -0
  35. package/dist/adapter/rapier-physics-adapter.d.ts.map +1 -0
  36. package/dist/adapter/rapier-physics-adapter.js +135 -0
  37. package/dist/adapter/root-adapter.d.ts +195 -0
  38. package/dist/adapter/root-adapter.d.ts.map +1 -0
  39. package/dist/adapter/root-adapter.js +25 -0
  40. package/dist/adapter/setup-three-root-adapter.d.ts +87 -0
  41. package/dist/adapter/setup-three-root-adapter.d.ts.map +1 -0
  42. package/dist/adapter/setup-three-root-adapter.js +791 -0
  43. package/dist/adapter/system-adapter.d.ts +453 -0
  44. package/dist/adapter/system-adapter.d.ts.map +1 -0
  45. package/dist/adapter/system-adapter.js +13 -0
  46. package/dist/adapter/transform.d.ts +18 -0
  47. package/dist/adapter/transform.d.ts.map +1 -0
  48. package/dist/adapter/transform.js +1 -0
  49. package/dist/ai/navigation.d.ts +78 -0
  50. package/dist/ai/navigation.d.ts.map +1 -0
  51. package/dist/ai/navigation.js +152 -0
  52. package/dist/animation/anim-graph-types.d.ts +25 -0
  53. package/dist/animation/anim-graph-types.d.ts.map +1 -0
  54. package/dist/animation/anim-graph-types.js +1 -0
  55. package/dist/animation/animation-clock.d.ts +213 -0
  56. package/dist/animation/animation-clock.d.ts.map +1 -0
  57. package/dist/animation/animation-clock.js +301 -0
  58. package/dist/animation/blend-node.d.ts +22 -0
  59. package/dist/animation/blend-node.d.ts.map +1 -0
  60. package/dist/animation/blend-node.js +97 -0
  61. package/dist/animation/camera-ownership.d.ts +249 -0
  62. package/dist/animation/camera-ownership.d.ts.map +1 -0
  63. package/dist/animation/camera-ownership.js +169 -0
  64. package/dist/animation/cinematic-cues.d.ts +200 -0
  65. package/dist/animation/cinematic-cues.d.ts.map +1 -0
  66. package/dist/animation/cinematic-cues.js +213 -0
  67. package/dist/animation/clip-map.d.ts +12 -0
  68. package/dist/animation/clip-map.d.ts.map +1 -0
  69. package/dist/animation/clip-map.js +31 -0
  70. package/dist/animation/cubic-spline-interpolant.d.ts +54 -0
  71. package/dist/animation/cubic-spline-interpolant.d.ts.map +1 -0
  72. package/dist/animation/cubic-spline-interpolant.js +111 -0
  73. package/dist/animation/theatre-clock-binding.d.ts +89 -0
  74. package/dist/animation/theatre-clock-binding.d.ts.map +1 -0
  75. package/dist/animation/theatre-clock-binding.js +29 -0
  76. package/dist/animation/theatre-director.d.ts +277 -0
  77. package/dist/animation/theatre-director.d.ts.map +1 -0
  78. package/dist/animation/theatre-director.js +248 -0
  79. package/dist/animation/theatre-object-binding.d.ts +305 -0
  80. package/dist/animation/theatre-object-binding.d.ts.map +1 -0
  81. package/dist/animation/theatre-object-binding.js +351 -0
  82. package/dist/animation/xstate-animation-binding.d.ts +119 -0
  83. package/dist/animation/xstate-animation-binding.d.ts.map +1 -0
  84. package/dist/animation/xstate-animation-binding.js +349 -0
  85. package/dist/animation/xstate-animation-meta.d.ts +266 -0
  86. package/dist/animation/xstate-animation-meta.d.ts.map +1 -0
  87. package/dist/animation/xstate-animation-meta.js +252 -0
  88. package/dist/asset-formats/camera.d.ts +15 -0
  89. package/dist/asset-formats/camera.d.ts.map +1 -0
  90. package/dist/asset-formats/camera.js +15 -0
  91. package/dist/asset-formats/collider.d.ts +21 -0
  92. package/dist/asset-formats/collider.d.ts.map +1 -0
  93. package/dist/asset-formats/collider.js +53 -0
  94. package/dist/asset-formats/index.d.ts +46 -0
  95. package/dist/asset-formats/index.d.ts.map +1 -0
  96. package/dist/asset-formats/index.js +36 -0
  97. package/dist/asset-formats/instances.d.ts +17 -0
  98. package/dist/asset-formats/instances.d.ts.map +1 -0
  99. package/dist/asset-formats/instances.js +31 -0
  100. package/dist/asset-formats/light.d.ts +21 -0
  101. package/dist/asset-formats/light.d.ts.map +1 -0
  102. package/dist/asset-formats/light.js +35 -0
  103. package/dist/asset-formats/material.d.ts +129 -0
  104. package/dist/asset-formats/material.d.ts.map +1 -0
  105. package/dist/asset-formats/material.js +88 -0
  106. package/dist/asset-formats/mesh.d.ts +22 -0
  107. package/dist/asset-formats/mesh.d.ts.map +1 -0
  108. package/dist/asset-formats/mesh.js +64 -0
  109. package/dist/asset-formats/parse.d.ts +20 -0
  110. package/dist/asset-formats/parse.d.ts.map +1 -0
  111. package/dist/asset-formats/parse.js +34 -0
  112. package/dist/asset-formats/particles.d.ts +1390 -0
  113. package/dist/asset-formats/particles.d.ts.map +1 -0
  114. package/dist/asset-formats/particles.js +319 -0
  115. package/dist/asset-formats/render-env.d.ts +387 -0
  116. package/dist/asset-formats/render-env.d.ts.map +1 -0
  117. package/dist/asset-formats/render-env.js +300 -0
  118. package/dist/asset-formats/tuples.d.ts +12 -0
  119. package/dist/asset-formats/tuples.d.ts.map +1 -0
  120. package/dist/asset-formats/tuples.js +14 -0
  121. package/dist/asset-loaders.d.ts +97 -0
  122. package/dist/asset-loaders.d.ts.map +1 -0
  123. package/dist/asset-loaders.js +209 -0
  124. package/dist/asset-parse-error.d.ts +24 -0
  125. package/dist/asset-parse-error.d.ts.map +1 -0
  126. package/dist/asset-parse-error.js +29 -0
  127. package/dist/asset-registry.d.ts +38 -0
  128. package/dist/asset-registry.d.ts.map +1 -0
  129. package/dist/asset-registry.js +66 -0
  130. package/dist/assets.d.ts +26 -0
  131. package/dist/assets.d.ts.map +1 -0
  132. package/dist/assets.js +55 -0
  133. package/dist/audio/wav-encode.d.ts +38 -0
  134. package/dist/audio/wav-encode.d.ts.map +1 -0
  135. package/dist/audio/wav-encode.js +97 -0
  136. package/dist/canvas-react/engine-bridge.d.ts +45 -0
  137. package/dist/canvas-react/engine-bridge.d.ts.map +1 -0
  138. package/dist/canvas-react/engine-bridge.js +45 -0
  139. package/dist/canvas-react/index.d.ts +42 -0
  140. package/dist/canvas-react/index.d.ts.map +1 -0
  141. package/dist/canvas-react/index.js +41 -0
  142. package/dist/canvas-react/pixi-primitive.d.ts +85 -0
  143. package/dist/canvas-react/pixi-primitive.d.ts.map +1 -0
  144. package/dist/canvas-react/pixi-primitive.js +181 -0
  145. package/dist/canvas-react/pixi-react-adapter.d.ts +71 -0
  146. package/dist/canvas-react/pixi-react-adapter.d.ts.map +1 -0
  147. package/dist/canvas-react/pixi-react-adapter.js +229 -0
  148. package/dist/canvas-react/pixi-react-root-factory.d.ts +56 -0
  149. package/dist/canvas-react/pixi-react-root-factory.d.ts.map +1 -0
  150. package/dist/canvas-react/pixi-react-root-factory.js +73 -0
  151. package/dist/canvas-react/world-context.d.ts +88 -0
  152. package/dist/canvas-react/world-context.d.ts.map +1 -0
  153. package/dist/canvas-react/world-context.js +212 -0
  154. package/dist/config.d.ts +9 -0
  155. package/dist/config.d.ts.map +1 -0
  156. package/dist/config.js +8 -0
  157. package/dist/core/frame-pacing.d.ts +90 -0
  158. package/dist/core/frame-pacing.d.ts.map +1 -0
  159. package/dist/core/frame-pacing.js +89 -0
  160. package/dist/core/game-loop.d.ts +62 -0
  161. package/dist/core/game-loop.d.ts.map +1 -0
  162. package/dist/core/game-loop.js +189 -0
  163. package/dist/core/seeded-random.d.ts +69 -0
  164. package/dist/core/seeded-random.d.ts.map +1 -0
  165. package/dist/core/seeded-random.js +121 -0
  166. package/dist/core/sim-clock.d.ts +199 -0
  167. package/dist/core/sim-clock.d.ts.map +1 -0
  168. package/dist/core/sim-clock.js +291 -0
  169. package/dist/core/system-runner.d.ts +96 -0
  170. package/dist/core/system-runner.d.ts.map +1 -0
  171. package/dist/core/system-runner.js +253 -0
  172. package/dist/core/types.d.ts +111 -0
  173. package/dist/core/types.d.ts.map +1 -0
  174. package/dist/core/types.js +25 -0
  175. package/dist/data/data-asset.d.ts +101 -0
  176. package/dist/data/data-asset.d.ts.map +1 -0
  177. package/dist/data/data-asset.js +122 -0
  178. package/dist/data/data-check-core.d.ts +109 -0
  179. package/dist/data/data-check-core.d.ts.map +1 -0
  180. package/dist/data/data-check-core.js +177 -0
  181. package/dist/data/data-ref.d.ts +79 -0
  182. package/dist/data/data-ref.d.ts.map +1 -0
  183. package/dist/data/data-ref.js +130 -0
  184. package/dist/data/vite-plugin-data.d.ts +79 -0
  185. package/dist/data/vite-plugin-data.d.ts.map +1 -0
  186. package/dist/data/vite-plugin-data.js +217 -0
  187. package/dist/defaults.d.ts +233 -0
  188. package/dist/defaults.d.ts.map +1 -0
  189. package/dist/defaults.js +137 -0
  190. package/dist/dev/chrome-trace.d.ts +45 -0
  191. package/dist/dev/chrome-trace.d.ts.map +1 -0
  192. package/dist/dev/chrome-trace.js +114 -0
  193. package/dist/dev/console-bridge.d.ts +22 -0
  194. package/dist/dev/console-bridge.d.ts.map +1 -0
  195. package/dist/dev/console-bridge.js +71 -0
  196. package/dist/dev/debug-draw.d.ts +24 -0
  197. package/dist/dev/debug-draw.d.ts.map +1 -0
  198. package/dist/dev/debug-draw.js +73 -0
  199. package/dist/dev/instruments.d.ts +133 -0
  200. package/dist/dev/instruments.d.ts.map +1 -0
  201. package/dist/dev/instruments.js +231 -0
  202. package/dist/dev/logger.d.ts +30 -0
  203. package/dist/dev/logger.d.ts.map +1 -0
  204. package/dist/dev/logger.js +90 -0
  205. package/dist/dev/performance-profiler.d.ts +111 -0
  206. package/dist/dev/performance-profiler.d.ts.map +1 -0
  207. package/dist/dev/performance-profiler.js +215 -0
  208. package/dist/dev/render-debug-adapter.d.ts +57 -0
  209. package/dist/dev/render-debug-adapter.d.ts.map +1 -0
  210. package/dist/dev/render-debug-adapter.js +141 -0
  211. package/dist/dev/render-memory.d.ts +53 -0
  212. package/dist/dev/render-memory.d.ts.map +1 -0
  213. package/dist/dev/render-memory.js +190 -0
  214. package/dist/dev/webgl-frame-capture.d.ts +134 -0
  215. package/dist/dev/webgl-frame-capture.d.ts.map +1 -0
  216. package/dist/dev/webgl-frame-capture.js +270 -0
  217. package/dist/dev/webgl-gpu-timer.d.ts +8 -0
  218. package/dist/dev/webgl-gpu-timer.d.ts.map +1 -0
  219. package/dist/dev/webgl-gpu-timer.js +52 -0
  220. package/dist/ecs/scene-index.d.ts +179 -0
  221. package/dist/ecs/scene-index.d.ts.map +1 -0
  222. package/dist/ecs/scene-index.js +331 -0
  223. package/dist/ecs/scene-query.d.ts +6 -0
  224. package/dist/ecs/scene-query.d.ts.map +1 -0
  225. package/dist/ecs/scene-query.js +40 -0
  226. package/dist/ecs/user-data.d.ts +193 -0
  227. package/dist/ecs/user-data.d.ts.map +1 -0
  228. package/dist/ecs/user-data.js +145 -0
  229. package/dist/index.d.ts +35 -0
  230. package/dist/index.d.ts.map +1 -0
  231. package/dist/index.js +29 -0
  232. package/dist/input/input-manager.d.ts +944 -0
  233. package/dist/input/input-manager.d.ts.map +1 -0
  234. package/dist/input/input-manager.js +2209 -0
  235. package/dist/input/input-types.d.ts +174 -0
  236. package/dist/input/input-types.d.ts.map +1 -0
  237. package/dist/input/input-types.js +1 -0
  238. package/dist/input/prompt-labels.d.ts +21 -0
  239. package/dist/input/prompt-labels.d.ts.map +1 -0
  240. package/dist/input/prompt-labels.js +121 -0
  241. package/dist/input/rebind-controller.d.ts +59 -0
  242. package/dist/input/rebind-controller.d.ts.map +1 -0
  243. package/dist/input/rebind-controller.js +85 -0
  244. package/dist/input/schema.d.ts +16 -0
  245. package/dist/input/schema.d.ts.map +1 -0
  246. package/dist/input/schema.js +228 -0
  247. package/dist/loader.d.ts +76 -0
  248. package/dist/loader.d.ts.map +1 -0
  249. package/dist/loader.js +114 -0
  250. package/dist/manifest/editor-port.d.ts +53 -0
  251. package/dist/manifest/editor-port.d.ts.map +1 -0
  252. package/dist/manifest/editor-port.js +67 -0
  253. package/dist/manifest/filename.d.ts +14 -0
  254. package/dist/manifest/filename.d.ts.map +1 -0
  255. package/dist/manifest/filename.js +43 -0
  256. package/dist/manifest/index.d.ts +6 -0
  257. package/dist/manifest/index.d.ts.map +1 -0
  258. package/dist/manifest/index.js +9 -0
  259. package/dist/manifest/load-file.d.ts +7 -0
  260. package/dist/manifest/load-file.d.ts.map +1 -0
  261. package/dist/manifest/load-file.js +23 -0
  262. package/dist/manifest/load.d.ts +161 -0
  263. package/dist/manifest/load.d.ts.map +1 -0
  264. package/dist/manifest/load.js +269 -0
  265. package/dist/manifest/locate.d.ts +24 -0
  266. package/dist/manifest/locate.d.ts.map +1 -0
  267. package/dist/manifest/locate.js +48 -0
  268. package/dist/manifest/schema.d.ts +293 -0
  269. package/dist/manifest/schema.d.ts.map +1 -0
  270. package/dist/manifest/schema.js +633 -0
  271. package/dist/physics/collider-dimensions.d.ts +63 -0
  272. package/dist/physics/collider-dimensions.d.ts.map +1 -0
  273. package/dist/physics/collider-dimensions.js +98 -0
  274. package/dist/physics/collision-system.d.ts +41 -0
  275. package/dist/physics/collision-system.d.ts.map +1 -0
  276. package/dist/physics/collision-system.js +64 -0
  277. package/dist/physics/physics-registry.d.ts +45 -0
  278. package/dist/physics/physics-registry.d.ts.map +1 -0
  279. package/dist/physics/physics-registry.js +65 -0
  280. package/dist/physics/transform-writer.d.ts +16 -0
  281. package/dist/physics/transform-writer.d.ts.map +1 -0
  282. package/dist/physics/transform-writer.js +38 -0
  283. package/dist/pixi/authoring.d.ts +93 -0
  284. package/dist/pixi/authoring.d.ts.map +1 -0
  285. package/dist/pixi/authoring.js +207 -0
  286. package/dist/pixi/index.d.ts +16 -0
  287. package/dist/pixi/index.d.ts.map +1 -0
  288. package/dist/pixi/index.js +15 -0
  289. package/dist/pixi/ingest-iframe.d.ts +82 -0
  290. package/dist/pixi/ingest-iframe.d.ts.map +1 -0
  291. package/dist/pixi/ingest-iframe.js +166 -0
  292. package/dist/pixi/ingest.d.ts +97 -0
  293. package/dist/pixi/ingest.d.ts.map +1 -0
  294. package/dist/pixi/ingest.js +40 -0
  295. package/dist/pixi/physics-registry.d.ts +24 -0
  296. package/dist/pixi/physics-registry.d.ts.map +1 -0
  297. package/dist/pixi/physics-registry.js +38 -0
  298. package/dist/pixi/scene-capture.d.ts +43 -0
  299. package/dist/pixi/scene-capture.d.ts.map +1 -0
  300. package/dist/pixi/scene-capture.js +92 -0
  301. package/dist/pixi/system-adapters.d.ts +16 -0
  302. package/dist/pixi/system-adapters.d.ts.map +1 -0
  303. package/dist/pixi/system-adapters.js +37 -0
  304. package/dist/react/unmanaged-root-detector.d.ts +18 -0
  305. package/dist/react/unmanaged-root-detector.d.ts.map +1 -0
  306. package/dist/react/unmanaged-root-detector.js +70 -0
  307. package/dist/react/use-data.d.ts +60 -0
  308. package/dist/react/use-data.d.ts.map +1 -0
  309. package/dist/react/use-data.js +101 -0
  310. package/dist/react/use-selection.d.ts +54 -0
  311. package/dist/react/use-selection.d.ts.map +1 -0
  312. package/dist/react/use-selection.js +71 -0
  313. package/dist/react/world-state.d.ts +154 -0
  314. package/dist/react/world-state.d.ts.map +1 -0
  315. package/dist/react/world-state.js +220 -0
  316. package/dist/render/auto-batcher.d.ts +34 -0
  317. package/dist/render/auto-batcher.d.ts.map +1 -0
  318. package/dist/render/auto-batcher.js +140 -0
  319. package/dist/render/instance-mesh.d.ts +5 -0
  320. package/dist/render/instance-mesh.d.ts.map +1 -0
  321. package/dist/render/instance-mesh.js +19 -0
  322. package/dist/render/light-camera-factory.d.ts +24 -0
  323. package/dist/render/light-camera-factory.d.ts.map +1 -0
  324. package/dist/render/light-camera-factory.js +71 -0
  325. package/dist/render/lod.d.ts +13 -0
  326. package/dist/render/lod.d.ts.map +1 -0
  327. package/dist/render/lod.js +16 -0
  328. package/dist/render/material-factory.d.ts +15 -0
  329. package/dist/render/material-factory.d.ts.map +1 -0
  330. package/dist/render/material-factory.js +186 -0
  331. package/dist/render/mesh-shadow.d.ts +11 -0
  332. package/dist/render/mesh-shadow.d.ts.map +1 -0
  333. package/dist/render/mesh-shadow.js +19 -0
  334. package/dist/render/particles-factory.d.ts +99 -0
  335. package/dist/render/particles-factory.d.ts.map +1 -0
  336. package/dist/render/particles-factory.js +361 -0
  337. package/dist/render/render-batch-system.d.ts +33 -0
  338. package/dist/render/render-batch-system.d.ts.map +1 -0
  339. package/dist/render/render-batch-system.js +223 -0
  340. package/dist/render/render-features.d.ts +47 -0
  341. package/dist/render/render-features.d.ts.map +1 -0
  342. package/dist/render/render-features.js +105 -0
  343. package/dist/render/render-settings.d.ts +35 -0
  344. package/dist/render/render-settings.d.ts.map +1 -0
  345. package/dist/render/render-settings.js +51 -0
  346. package/dist/render/spark-renderer-lifecycle.d.ts +18 -0
  347. package/dist/render/spark-renderer-lifecycle.d.ts.map +1 -0
  348. package/dist/render/spark-renderer-lifecycle.js +57 -0
  349. package/dist/render/viewport-shading.d.ts +17 -0
  350. package/dist/render/viewport-shading.d.ts.map +1 -0
  351. package/dist/render/viewport-shading.js +87 -0
  352. package/dist/runtime/create-runtime.d.ts +259 -0
  353. package/dist/runtime/create-runtime.d.ts.map +1 -0
  354. package/dist/runtime/create-runtime.js +666 -0
  355. package/dist/runtime/debug-bridge.d.ts +288 -0
  356. package/dist/runtime/debug-bridge.d.ts.map +1 -0
  357. package/dist/runtime/debug-bridge.js +277 -0
  358. package/dist/runtime/debug-registry.d.ts +287 -0
  359. package/dist/runtime/debug-registry.d.ts.map +1 -0
  360. package/dist/runtime/debug-registry.js +528 -0
  361. package/dist/runtime/dev-layers.d.ts +34 -0
  362. package/dist/runtime/dev-layers.d.ts.map +1 -0
  363. package/dist/runtime/dev-layers.js +40 -0
  364. package/dist/runtime/frame-selector-cache.d.ts +41 -0
  365. package/dist/runtime/frame-selector-cache.d.ts.map +1 -0
  366. package/dist/runtime/frame-selector-cache.js +65 -0
  367. package/dist/runtime/game.d.ts +576 -0
  368. package/dist/runtime/game.d.ts.map +1 -0
  369. package/dist/runtime/game.js +1003 -0
  370. package/dist/runtime/gameplay-rng-trap.d.ts +47 -0
  371. package/dist/runtime/gameplay-rng-trap.d.ts.map +1 -0
  372. package/dist/runtime/gameplay-rng-trap.js +95 -0
  373. package/dist/runtime/input-router.d.ts +78 -0
  374. package/dist/runtime/input-router.d.ts.map +1 -0
  375. package/dist/runtime/input-router.js +171 -0
  376. package/dist/runtime/mount-game.d.ts +126 -0
  377. package/dist/runtime/mount-game.d.ts.map +1 -0
  378. package/dist/runtime/mount-game.js +159 -0
  379. package/dist/runtime/mount-manifest.d.ts +174 -0
  380. package/dist/runtime/mount-manifest.d.ts.map +1 -0
  381. package/dist/runtime/mount-manifest.js +304 -0
  382. package/dist/runtime/presentation.d.ts +85 -0
  383. package/dist/runtime/presentation.d.ts.map +1 -0
  384. package/dist/runtime/presentation.js +92 -0
  385. package/dist/runtime/render-audio-control.d.ts +126 -0
  386. package/dist/runtime/render-audio-control.d.ts.map +1 -0
  387. package/dist/runtime/render-audio-control.js +116 -0
  388. package/dist/runtime/render-control.d.ts +347 -0
  389. package/dist/runtime/render-control.d.ts.map +1 -0
  390. package/dist/runtime/render-control.js +317 -0
  391. package/dist/runtime/render-seed.d.ts +56 -0
  392. package/dist/runtime/render-seed.d.ts.map +1 -0
  393. package/dist/runtime/render-seed.js +73 -0
  394. package/dist/runtime/state-bridge.d.ts +60 -0
  395. package/dist/runtime/state-bridge.d.ts.map +1 -0
  396. package/dist/runtime/state-bridge.js +62 -0
  397. package/dist/runtime/types.d.ts +285 -0
  398. package/dist/runtime/types.d.ts.map +1 -0
  399. package/dist/runtime/types.js +1 -0
  400. package/dist/runtime/unexported-game-trap.d.ts +36 -0
  401. package/dist/runtime/unexported-game-trap.d.ts.map +1 -0
  402. package/dist/runtime/unexported-game-trap.js +80 -0
  403. package/dist/setup/setup-audio.d.ts +20 -0
  404. package/dist/setup/setup-audio.d.ts.map +1 -0
  405. package/dist/setup/setup-audio.js +41 -0
  406. package/dist/setup/setup-particles.d.ts +17 -0
  407. package/dist/setup/setup-particles.d.ts.map +1 -0
  408. package/dist/setup/setup-particles.js +16 -0
  409. package/dist/setup/setup-physics.d.ts +25 -0
  410. package/dist/setup/setup-physics.d.ts.map +1 -0
  411. package/dist/setup/setup-physics.js +51 -0
  412. package/dist/setup/setup-renderer.d.ts +82 -0
  413. package/dist/setup/setup-renderer.d.ts.map +1 -0
  414. package/dist/setup/setup-renderer.js +381 -0
  415. package/dist/world3d-react/engine-bridge.d.ts +47 -0
  416. package/dist/world3d-react/engine-bridge.d.ts.map +1 -0
  417. package/dist/world3d-react/engine-bridge.js +48 -0
  418. package/dist/world3d-react/index.d.ts +47 -0
  419. package/dist/world3d-react/index.d.ts.map +1 -0
  420. package/dist/world3d-react/index.js +46 -0
  421. package/dist/world3d-react/r3f-adapter.d.ts +51 -0
  422. package/dist/world3d-react/r3f-adapter.d.ts.map +1 -0
  423. package/dist/world3d-react/r3f-adapter.js +368 -0
  424. package/dist/world3d-react/r3f-root-factory.d.ts +62 -0
  425. package/dist/world3d-react/r3f-root-factory.d.ts.map +1 -0
  426. package/dist/world3d-react/r3f-root-factory.js +79 -0
  427. package/dist/world3d-react/rapier-physics-bridge.d.ts +76 -0
  428. package/dist/world3d-react/rapier-physics-bridge.d.ts.map +1 -0
  429. package/dist/world3d-react/rapier-physics-bridge.js +120 -0
  430. package/dist/world3d-react/renderer-config.d.ts +58 -0
  431. package/dist/world3d-react/renderer-config.d.ts.map +1 -0
  432. package/dist/world3d-react/renderer-config.js +96 -0
  433. package/dist/world3d-react/world-context.d.ts +123 -0
  434. package/dist/world3d-react/world-context.d.ts.map +1 -0
  435. package/dist/world3d-react/world-context.js +204 -0
  436. package/dist-config/config.js +303 -0
  437. package/dist-config/config.js.map +7 -0
  438. package/package.json +14 -3
  439. package/src/adapter/rapier-physics-adapter.ts +77 -34
  440. package/src/config.ts +8 -0
  441. package/src/core/frame-pacing.ts +26 -0
  442. package/src/core/game-loop.ts +4 -3
  443. package/src/dev/instruments.ts +302 -0
  444. package/src/runtime/mount-game.ts +6 -0
  445. package/src/runtime/unexported-game-trap.ts +82 -0
  446. package/src/setup/setup-renderer.ts +2 -0
  447. package/src/world3d-react/index.ts +9 -0
  448. package/src/world3d-react/rapier-physics-bridge.tsx +137 -0
@@ -0,0 +1,381 @@
1
+ /// <reference path="../types-n8ao.d.ts" />
2
+ import { N8AOPostPass } from 'n8ao';
3
+ import { BloomEffect, BrightnessContrastEffect, ChromaticAberrationEffect, ColorDepthEffect, DepthOfFieldEffect, DotScreenEffect, EffectComposer, EffectPass, GlitchEffect, GodRaysEffect, GridEffect, HueSaturationEffect, LensDistortionEffect, NoiseEffect, NormalPass, OutlineEffect, PixelationEffect, RenderPass, ScanlineEffect, SepiaEffect, ShockWaveEffect, SMAAEffect, SMAAPreset, SSAOEffect, TiltShiftEffect, VignetteEffect, } from 'postprocessing';
4
+ import * as THREE from 'three';
5
+ import { MotionBlurEffect, SSGIEffect, SSREffect, VelocityDepthNormalPass, } from '../../vendor/realism-effects/dist/index.js';
6
+ import { DEFAULTS } from '../defaults';
7
+ import { detectKtx2Support } from '../loader';
8
+ import { resolveRenderSettings } from '../render/render-settings';
9
+ /**
10
+ * Apply the live renderer-level render settings (shadows, resolution scale) from
11
+ * the resolved cascade. `antialias`/`backend` are reload-only (renderer re-init)
12
+ * and are handled at construction, not here. Pass the scene `rendering` scope
13
+ * (e.g. `env.rendering`); absent values fall back to the registry defaults so
14
+ * behavior is unchanged when a scene omits `rendering`.
15
+ *
16
+ * `basePixelRatio` is the call-site's native pixel-ratio policy (the runtime caps
17
+ * at 2; the editor uses the raw devicePixelRatio); `resolutionScale` multiplies it.
18
+ */
19
+ export function applyRendererSettings(renderer, rendering, basePixelRatio = Math.min(window.devicePixelRatio, 2)) {
20
+ const settings = resolveRenderSettings(rendering);
21
+ renderer.shadowMap.enabled = Boolean(settings['shadows']);
22
+ const scale = Number(settings['resolutionScale']) || 1;
23
+ renderer.setPixelRatio(basePixelRatio * scale);
24
+ }
25
+ /**
26
+ * Create ONLY the WebGL renderer. The HOST owns the renderer (see
27
+ * `ThreeHostContext.renderer`); the game/adapter owns the scene/camera/composer it
28
+ * renders into. Split out of `setupRenderer` for the adapter inversion.
29
+ *
30
+ * `rendering` is the scene-level render scope (`env.rendering`); it seeds the
31
+ * reload-only `antialias` option at construction and the live shadow/resolution
32
+ * settings (via {@link applyRendererSettings}). Absent → registry defaults.
33
+ *
34
+ * `opts` is additive (T6.1 slice 1, D5 §1/§4): omitted
35
+ * entirely, construction is byte-identical to before (no `alpha`/
36
+ * `preserveDrawingBuffer` keys at all) — the legacy single-canvas host never
37
+ * passes it. The roots path passes `alpha:true` for every stacked canvas
38
+ * above the bottom one (so its clear-alpha-0 shows the layer below through
39
+ * it) and `preserveDrawingBuffer:true` for every stacked canvas (the
40
+ * recorded capture-tier cost, paid once here rather than re-derived later).
41
+ */
42
+ export function createHostRenderer(canvas, width = window.innerWidth, height = window.innerHeight, rendering, opts) {
43
+ // A newly-shown editor tab can report 0x0 for one layout frame. WebGL render
44
+ // targets cannot have zero-sized attachments, so boot at the smallest valid
45
+ // backing size and let the normal resize path apply the real dimensions.
46
+ const safeWidth = Math.max(1, width);
47
+ const safeHeight = Math.max(1, height);
48
+ const settings = resolveRenderSettings(rendering);
49
+ const renderer = new THREE.WebGLRenderer({
50
+ canvas,
51
+ antialias: Boolean(settings['antialias']),
52
+ powerPreference: 'high-performance',
53
+ ...(opts?.alpha ? { alpha: true } : {}),
54
+ ...(opts?.preserveDrawingBuffer ? { preserveDrawingBuffer: true } : {}),
55
+ });
56
+ renderer.setSize(safeWidth, safeHeight);
57
+ applyRendererSettings(renderer, rendering);
58
+ renderer.shadowMap.type = THREE.PCFSoftShadowMap;
59
+ renderer.toneMapping = toneMappingModes[DEFAULTS.toneMapping.mode] ?? THREE.ACESFilmicToneMapping;
60
+ renderer.toneMappingExposure = DEFAULTS.toneMapping.exposure;
61
+ // The shared KTX2Loader cannot transcode a KHR_texture_basisu texture until
62
+ // some renderer has told it which compressed formats this GPU accepts.
63
+ // Idempotent — see `detectKtx2Support`.
64
+ detectKtx2Support(renderer);
65
+ return renderer;
66
+ }
67
+ /**
68
+ * Create the scene, camera, and postprocessing composer that a first-party game
69
+ * renders into, given a host-provided renderer. The GPU-only `composer` is
70
+ * created here; a headless host (no GPU) skips this entirely.
71
+ */
72
+ export function createSceneView(renderer, width = window.innerWidth, height = window.innerHeight) {
73
+ const safeWidth = Math.max(1, width);
74
+ const safeHeight = Math.max(1, height);
75
+ const scene = new THREE.Scene();
76
+ scene.background = new THREE.Color(0x1a1a2e);
77
+ const camera = new THREE.PerspectiveCamera(DEFAULTS.camera.fov, safeWidth / safeHeight, DEFAULTS.camera.near, DEFAULTS.camera.far);
78
+ camera.position.set(0, 5, 10);
79
+ camera.lookAt(0, 0, 0);
80
+ const composer = new EffectComposer(renderer);
81
+ composer.addPass(new RenderPass(scene, camera));
82
+ composer.addPass(new EffectPass(camera, new BloomEffect({ luminanceThreshold: DEFAULTS.postProcessing.bloom.luminanceThreshold })));
83
+ return { scene, camera, composer };
84
+ }
85
+ /**
86
+ * Creates the Three.js renderer, scene, camera, and postprocessing pipeline.
87
+ *
88
+ * This is direct Three.js setup — no abstraction. Edit freely. (Now a thin
89
+ * combination of {@link createHostRenderer} + {@link createSceneView}.)
90
+ */
91
+ export function setupRenderer(canvas, width = window.innerWidth, height = window.innerHeight) {
92
+ const renderer = createHostRenderer(canvas, width, height);
93
+ const { scene, camera, composer } = createSceneView(renderer, width, height);
94
+ return { renderer, scene, camera, composer };
95
+ }
96
+ const toneMappingModes = {
97
+ none: THREE.NoToneMapping,
98
+ linear: THREE.LinearToneMapping,
99
+ reinhard: THREE.ReinhardToneMapping,
100
+ cineon: THREE.CineonToneMapping,
101
+ aces: THREE.ACESFilmicToneMapping,
102
+ agx: THREE.AgXToneMapping,
103
+ };
104
+ const smaaPresets = {
105
+ low: SMAAPreset.LOW,
106
+ medium: SMAAPreset.MEDIUM,
107
+ high: SMAAPreset.HIGH,
108
+ ultra: SMAAPreset.ULTRA,
109
+ };
110
+ /**
111
+ * Rebuild composer passes from scene environment settings.
112
+ * Scenes without toneMapping default to ACES (the runtime default).
113
+ * Code can further modify the composer after this call.
114
+ *
115
+ * Pass objectMap to enable entity-referencing effects (godRays, outline).
116
+ * Pass entities to resolve tag-based references (outline).
117
+ */
118
+ export function applyScenePostProcessing(composer, renderer, scene, camera, env, objectMap, entityTags) {
119
+ // Dispose the existing passes before discarding them — removeAllPasses() just
120
+ // drops the references, so their GPU render targets would otherwise leak on
121
+ // every env edit / scene switch.
122
+ for (const pass of composer.passes) {
123
+ pass.dispose?.();
124
+ }
125
+ composer.removeAllPasses();
126
+ composer.addPass(new RenderPass(scene, camera));
127
+ // ── Tone mapping ──────────────────────────────────────────────────────
128
+ const tm = env?.toneMapping;
129
+ renderer.toneMapping =
130
+ toneMappingModes[tm?.mode ?? DEFAULTS.toneMapping.mode] ?? THREE.ACESFilmicToneMapping;
131
+ renderer.toneMappingExposure = tm?.exposure ?? DEFAULTS.toneMapping.exposure;
132
+ // ── Master switch ─────────────────────────────────────────────────────
133
+ // When post-processing is disabled at the scene/engine level, render the
134
+ // plain scene (the RenderPass added above) and skip every effect pass. The
135
+ // per-effect `enabled` flags below still apply when the master switch is on.
136
+ if (!resolveRenderSettings(env?.rendering)['postProcessing'])
137
+ return;
138
+ const pp = env?.postProcessing;
139
+ const d = DEFAULTS.postProcessing;
140
+ // ── Prerequisite passes ───────────────────────────────────────────────
141
+ // NormalPass — needed by SSAO
142
+ let normalPass;
143
+ if (pp?.ssao?.enabled) {
144
+ normalPass = new NormalPass(scene, camera);
145
+ composer.addPass(normalPass);
146
+ }
147
+ // VelocityDepthNormalPass — needed by SSR, SSGI, MotionBlur
148
+ let velocityPass;
149
+ if (pp?.ssr?.enabled || pp?.ssgi?.enabled || pp?.motionBlur?.enabled) {
150
+ velocityPass = new VelocityDepthNormalPass(scene, camera);
151
+ composer.addPass(velocityPass);
152
+ }
153
+ // N8AOPostPass — separate Pass, not an Effect
154
+ if (pp?.n8ao?.enabled) {
155
+ const n8aoPass = new N8AOPostPass(scene, camera);
156
+ const cfg = n8aoPass.configuration;
157
+ cfg.aoSamples = pp.n8ao.aoSamples ?? d.n8ao.aoSamples;
158
+ cfg.aoRadius = pp.n8ao.aoRadius ?? d.n8ao.aoRadius;
159
+ cfg.intensity = pp.n8ao.intensity ?? d.n8ao.intensity;
160
+ cfg.denoiseSamples = pp.n8ao.denoiseSamples ?? d.n8ao.denoiseSamples;
161
+ cfg.denoiseRadius = pp.n8ao.denoiseRadius ?? d.n8ao.denoiseRadius;
162
+ cfg.distanceFalloff = pp.n8ao.distanceFalloff ?? d.n8ao.distanceFalloff;
163
+ if (pp.n8ao.screenSpaceRadius !== undefined)
164
+ cfg.screenSpaceRadius = pp.n8ao.screenSpaceRadius;
165
+ if (pp.n8ao.halfRes !== undefined)
166
+ cfg.halfRes = pp.n8ao.halfRes;
167
+ if (pp.n8ao.color)
168
+ cfg.color = new THREE.Color(pp.n8ao.color);
169
+ composer.addPass(n8aoPass);
170
+ }
171
+ // ── Collect Effect instances ──────────────────────────────────────────
172
+ const effects = [];
173
+ // Anti-aliasing
174
+ if (pp?.smaa?.enabled) {
175
+ const preset = smaaPresets[pp.smaa.preset ?? d.smaa.preset] ?? SMAAPreset.HIGH;
176
+ effects.push(new SMAAEffect({ preset }));
177
+ }
178
+ // Ambient occlusion
179
+ if (pp?.ssao?.enabled && normalPass) {
180
+ effects.push(new SSAOEffect(camera, normalPass.texture, {
181
+ radius: pp.ssao.radius ?? d.ssao.radius,
182
+ intensity: pp.ssao.intensity ?? d.ssao.intensity,
183
+ bias: pp.ssao.bias ?? d.ssao.bias,
184
+ samples: pp.ssao.samples ?? d.ssao.samples,
185
+ rings: pp.ssao.rings ?? d.ssao.rings,
186
+ fade: pp.ssao.fade ?? d.ssao.fade,
187
+ ...(pp.ssao.color ? { color: new THREE.Color(pp.ssao.color) } : {}),
188
+ }));
189
+ }
190
+ // SSR (realism-effects)
191
+ if (pp?.ssr?.enabled && velocityPass) {
192
+ effects.push(new SSREffect(scene, camera, velocityPass, {
193
+ intensity: pp.ssr.intensity ?? d.ssr.intensity,
194
+ exponent: pp.ssr.exponent ?? d.ssr.exponent,
195
+ distance: pp.ssr.distance ?? d.ssr.distance,
196
+ thickness: pp.ssr.thickness ?? d.ssr.thickness,
197
+ maxRoughness: pp.ssr.maxRoughness ?? d.ssr.maxRoughness,
198
+ }));
199
+ }
200
+ // SSGI (realism-effects)
201
+ if (pp?.ssgi?.enabled && velocityPass) {
202
+ effects.push(new SSGIEffect(scene, camera, velocityPass, {
203
+ intensity: pp.ssgi.intensity ?? d.ssgi.intensity,
204
+ distance: pp.ssgi.distance ?? d.ssgi.distance,
205
+ thickness: pp.ssgi.thickness ?? d.ssgi.thickness,
206
+ maxRoughness: pp.ssgi.maxRoughness ?? d.ssgi.maxRoughness,
207
+ }));
208
+ }
209
+ // Motion blur (realism-effects)
210
+ if (pp?.motionBlur?.enabled && velocityPass) {
211
+ effects.push(new MotionBlurEffect(velocityPass, {
212
+ intensity: pp.motionBlur.intensity ?? d.motionBlur.intensity,
213
+ jitter: pp.motionBlur.jitter ?? d.motionBlur.jitter,
214
+ samples: pp.motionBlur.samples ?? d.motionBlur.samples,
215
+ }));
216
+ }
217
+ // Bloom
218
+ if (pp?.bloom?.enabled) {
219
+ effects.push(new BloomEffect({
220
+ intensity: pp.bloom.intensity ?? d.bloom.intensity,
221
+ luminanceThreshold: pp.bloom.luminanceThreshold ?? d.bloom.luminanceThreshold,
222
+ luminanceSmoothing: pp.bloom.luminanceSmoothing ?? d.bloom.luminanceSmoothing,
223
+ }));
224
+ }
225
+ // Depth of field
226
+ if (pp?.depthOfField?.enabled) {
227
+ effects.push(new DepthOfFieldEffect(camera, {
228
+ worldFocusDistance: pp.depthOfField.worldFocusDistance ?? d.depthOfField.worldFocusDistance,
229
+ worldFocusRange: pp.depthOfField.worldFocusRange ?? d.depthOfField.worldFocusRange,
230
+ bokehScale: pp.depthOfField.bokehScale ?? d.depthOfField.bokehScale,
231
+ focalLength: pp.depthOfField.focalLength ?? d.depthOfField.focalLength,
232
+ }));
233
+ }
234
+ // Tilt shift
235
+ if (pp?.tiltShift?.enabled) {
236
+ effects.push(new TiltShiftEffect({
237
+ offset: pp.tiltShift.offset ?? d.tiltShift.offset,
238
+ rotation: pp.tiltShift.rotation ?? d.tiltShift.rotation,
239
+ focusArea: pp.tiltShift.focusArea ?? d.tiltShift.focusArea,
240
+ feather: pp.tiltShift.feather ?? d.tiltShift.feather,
241
+ }));
242
+ }
243
+ // God rays (needs entity reference)
244
+ if (pp?.godRays?.enabled && pp.godRays.sourceEntity && objectMap) {
245
+ const lightObj = objectMap.get(pp.godRays.sourceEntity);
246
+ if (lightObj instanceof THREE.Mesh || lightObj instanceof THREE.Points) {
247
+ effects.push(new GodRaysEffect(camera, lightObj, {
248
+ density: pp.godRays.density ?? d.godRays.density,
249
+ decay: pp.godRays.decay ?? d.godRays.decay,
250
+ weight: pp.godRays.weight ?? d.godRays.weight,
251
+ exposure: pp.godRays.exposure ?? d.godRays.exposure,
252
+ samples: pp.godRays.samples ?? d.godRays.samples,
253
+ }));
254
+ }
255
+ }
256
+ // Outline (needs entity tag references)
257
+ if (pp?.outline?.enabled && objectMap) {
258
+ const outlineEffect = new OutlineEffect(scene, camera, {
259
+ edgeStrength: pp.outline.edgeStrength ?? d.outline.edgeStrength,
260
+ pulseSpeed: pp.outline.pulseSpeed ?? d.outline.pulseSpeed,
261
+ visibleEdgeColor: pp.outline.visibleEdgeColor
262
+ ? new THREE.Color(pp.outline.visibleEdgeColor).getHex()
263
+ : new THREE.Color(d.outline.visibleEdgeColor).getHex(),
264
+ hiddenEdgeColor: pp.outline.hiddenEdgeColor
265
+ ? new THREE.Color(pp.outline.hiddenEdgeColor).getHex()
266
+ : new THREE.Color(d.outline.hiddenEdgeColor).getHex(),
267
+ xRay: pp.outline.xRay ?? false,
268
+ });
269
+ // Add entities matching tags to selection
270
+ const tags = pp.outline.tags ?? [];
271
+ if (tags.length > 0 && entityTags) {
272
+ for (const [entityId, eTags] of entityTags) {
273
+ if (tags.some((t) => eTags.includes(t))) {
274
+ const obj = objectMap.get(entityId);
275
+ if (obj)
276
+ outlineEffect.selection.add(obj);
277
+ }
278
+ }
279
+ }
280
+ effects.push(outlineEffect);
281
+ }
282
+ // Chromatic aberration
283
+ if (pp?.chromaticAberration?.enabled) {
284
+ effects.push(new ChromaticAberrationEffect({
285
+ offset: new THREE.Vector2(pp.chromaticAberration.offsetX ?? d.chromaticAberration.offsetX, pp.chromaticAberration.offsetY ?? d.chromaticAberration.offsetY),
286
+ radialModulation: pp.chromaticAberration.radialModulation ?? false,
287
+ modulationOffset: pp.chromaticAberration.modulationOffset ?? d.chromaticAberration.modulationOffset,
288
+ }));
289
+ }
290
+ // Lens distortion
291
+ if (pp?.lensDistortion?.enabled) {
292
+ effects.push(new LensDistortionEffect({
293
+ distortion: new THREE.Vector2(pp.lensDistortion.distortionX ?? d.lensDistortion.distortionX, pp.lensDistortion.distortionY ?? d.lensDistortion.distortionY),
294
+ principalPoint: new THREE.Vector2(0, 0),
295
+ focalLength: new THREE.Vector2(pp.lensDistortion.focalLengthX ?? d.lensDistortion.focalLengthX, pp.lensDistortion.focalLengthY ?? d.lensDistortion.focalLengthY),
296
+ skew: pp.lensDistortion.skew ?? d.lensDistortion.skew,
297
+ }));
298
+ }
299
+ // Shock wave
300
+ if (pp?.shockWave?.enabled) {
301
+ effects.push(new ShockWaveEffect(camera, new THREE.Vector3(pp.shockWave.positionX ?? 0, pp.shockWave.positionY ?? 0, pp.shockWave.positionZ ?? 0), {
302
+ speed: pp.shockWave.speed ?? d.shockWave.speed,
303
+ maxRadius: pp.shockWave.maxRadius ?? d.shockWave.maxRadius,
304
+ waveSize: pp.shockWave.waveSize ?? d.shockWave.waveSize,
305
+ amplitude: pp.shockWave.amplitude ?? d.shockWave.amplitude,
306
+ }));
307
+ }
308
+ // Color adjustments
309
+ if (pp?.brightnessContrast?.enabled) {
310
+ effects.push(new BrightnessContrastEffect({
311
+ brightness: pp.brightnessContrast.brightness ?? d.brightnessContrast.brightness,
312
+ contrast: pp.brightnessContrast.contrast ?? d.brightnessContrast.contrast,
313
+ }));
314
+ }
315
+ if (pp?.hueSaturation?.enabled) {
316
+ effects.push(new HueSaturationEffect({
317
+ hue: pp.hueSaturation.hue ?? d.hueSaturation.hue,
318
+ saturation: pp.hueSaturation.saturation ?? d.hueSaturation.saturation,
319
+ }));
320
+ }
321
+ if (pp?.sepia?.enabled) {
322
+ effects.push(new SepiaEffect({ intensity: pp.sepia.intensity ?? d.sepia.intensity }));
323
+ }
324
+ if (pp?.colorDepth?.enabled) {
325
+ effects.push(new ColorDepthEffect({ bits: pp.colorDepth.bits ?? d.colorDepth.bits }));
326
+ }
327
+ // Film / retro
328
+ if (pp?.noise?.enabled) {
329
+ effects.push(new NoiseEffect({ premultiply: pp.noise.premultiply ?? d.noise.premultiply }));
330
+ }
331
+ if (pp?.scanline?.enabled) {
332
+ effects.push(new ScanlineEffect({ density: pp.scanline.density ?? d.scanline.density }));
333
+ }
334
+ if (pp?.dotScreen?.enabled) {
335
+ effects.push(new DotScreenEffect({
336
+ angle: pp.dotScreen.angle ?? d.dotScreen.angle,
337
+ scale: pp.dotScreen.scale ?? d.dotScreen.scale,
338
+ }));
339
+ }
340
+ if (pp?.grid?.enabled) {
341
+ effects.push(new GridEffect({
342
+ scale: pp.grid.scale ?? d.grid.scale,
343
+ lineWidth: pp.grid.lineWidth ?? d.grid.lineWidth,
344
+ }));
345
+ }
346
+ if (pp?.pixelation?.enabled) {
347
+ effects.push(new PixelationEffect(pp.pixelation.granularity ?? d.pixelation.granularity));
348
+ }
349
+ if (pp?.glitch?.enabled) {
350
+ effects.push(new GlitchEffect({
351
+ delay: new THREE.Vector2(pp.glitch.delayX ?? d.glitch.delayX, pp.glitch.delayY ?? d.glitch.delayY),
352
+ duration: new THREE.Vector2(pp.glitch.durationX ?? d.glitch.durationX, pp.glitch.durationY ?? d.glitch.durationY),
353
+ strength: new THREE.Vector2(pp.glitch.strengthX ?? d.glitch.strengthX, pp.glitch.strengthY ?? d.glitch.strengthY),
354
+ columns: pp.glitch.columns ?? d.glitch.columns,
355
+ ratio: pp.glitch.ratio ?? d.glitch.ratio,
356
+ }));
357
+ }
358
+ // Vignette (last color effect)
359
+ if (pp?.vignette?.enabled) {
360
+ effects.push(new VignetteEffect({
361
+ darkness: pp.vignette.darkness ?? d.vignette.darkness,
362
+ offset: pp.vignette.offset ?? d.vignette.offset,
363
+ }));
364
+ }
365
+ // ── Merge all effects into a single EffectPass ────────────────────────
366
+ if (effects.length > 0) {
367
+ composer.addPass(new EffectPass(camera, ...effects));
368
+ }
369
+ }
370
+ /**
371
+ * Apply every authored scene-level renderer setting through one path.
372
+ *
373
+ * Tone mapping is part of the scene environment, not conditional on the
374
+ * presence of post-processing effects. Keeping renderer settings and the
375
+ * composer rebuild together prevents editor/runtime drift for scenes that
376
+ * only author exposure or a tone-mapping mode.
377
+ */
378
+ export function applySceneRenderPipeline(composer, renderer, scene, camera, env, options) {
379
+ applyRendererSettings(renderer, env?.rendering, options?.basePixelRatio);
380
+ applyScenePostProcessing(composer, renderer, scene, camera, env, options?.objectMap, options?.entityTags);
381
+ }
@@ -0,0 +1,47 @@
1
+ /**
2
+ * `@engine/world3d-react` — the React context that carries this R3F world's
3
+ * engine runtime into its fiber tree: the world's `R3FGameContext`, read
4
+ * with {@link useGameContext}.
5
+ *
6
+ * Upstreamed from `examples/r3f-first-party/src/engine-bridge.ts` (R4).
7
+ * The bridge value
8
+ * is built by `createR3FAdapter`'s `mount()` (./r3f-adapter.tsx): a real
9
+ * `createSystemRunner` whose phases the adapter's `update(dt)` runs under the
10
+ * HOST loop — so registered systems tick in engine phase order, pause included
11
+ * (no update while the world is frozen).
12
+ *
13
+ * Behavior in an R3F world is components and hooks: `useGameContext` is how a
14
+ * component reaches engine services.
15
+ */
16
+ import type { R3FGameContext } from './world-context';
17
+ export interface EngineBridgeValue {
18
+ /** This root's context — `input`, `debug`, `random`, `game`, `roots`, … .
19
+ * Present so ordinary components can reach engine services with a HOOK
20
+ * (see {@link useGameContext}). */
21
+ readonly ctx?: R3FGameContext | undefined;
22
+ }
23
+ export declare const EngineBridge: import("react").Context<EngineBridgeValue | null>;
24
+ /**
25
+ * This R3F root's context, for use inside any component in the tree — an
26
+ * {@link R3FGameContext}, which is exactly the subsystems an R3F world builds.
27
+ * The ones it does not build are absent from the type, so reaching for one is
28
+ * a compile error at the call site; that type's doc comment says what to reach
29
+ * for instead.
30
+ *
31
+ * An ordinary component does what a model would write:
32
+ *
33
+ * ```tsx
34
+ * function Player({ speed = 4.5 }) {
35
+ * const { input } = useGameContext();
36
+ * const ref = useRef<THREE.Group>(null);
37
+ * useFrame((_, dt) => { if (input.isPressed('move_forward')) … });
38
+ * return <group ref={ref}><PlayerCharacter /></group>;
39
+ * }
40
+ * ```
41
+ *
42
+ * Throws when called outside an R3F root mounted by `createR3FAdapter` —
43
+ * absent context is a wiring bug, and a silent `null` would surface as a
44
+ * mystery `undefined` deep in a frame callback.
45
+ */
46
+ export declare function useGameContext(): R3FGameContext;
47
+ //# sourceMappingURL=engine-bridge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"engine-bridge.d.ts","sourceRoot":"","sources":["../../src/world3d-react/engine-bridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEtD,MAAM,WAAW,iBAAiB;IAChC;;wCAEoC;IACpC,QAAQ,CAAC,GAAG,CAAC,EAAE,cAAc,GAAG,SAAS,CAAC;CAC3C;AAED,eAAO,MAAM,YAAY,mDAAgD,CAAC;AAE1E;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,cAAc,IAAI,cAAc,CAU/C"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * `@engine/world3d-react` — the React context that carries this R3F world's
3
+ * engine runtime into its fiber tree: the world's `R3FGameContext`, read
4
+ * with {@link useGameContext}.
5
+ *
6
+ * Upstreamed from `examples/r3f-first-party/src/engine-bridge.ts` (R4).
7
+ * The bridge value
8
+ * is built by `createR3FAdapter`'s `mount()` (./r3f-adapter.tsx): a real
9
+ * `createSystemRunner` whose phases the adapter's `update(dt)` runs under the
10
+ * HOST loop — so registered systems tick in engine phase order, pause included
11
+ * (no update while the world is frozen).
12
+ *
13
+ * Behavior in an R3F world is components and hooks: `useGameContext` is how a
14
+ * component reaches engine services.
15
+ */
16
+ import { createContext, useContext } from 'react';
17
+ export const EngineBridge = createContext(null);
18
+ /**
19
+ * This R3F root's context, for use inside any component in the tree — an
20
+ * {@link R3FGameContext}, which is exactly the subsystems an R3F world builds.
21
+ * The ones it does not build are absent from the type, so reaching for one is
22
+ * a compile error at the call site; that type's doc comment says what to reach
23
+ * for instead.
24
+ *
25
+ * An ordinary component does what a model would write:
26
+ *
27
+ * ```tsx
28
+ * function Player({ speed = 4.5 }) {
29
+ * const { input } = useGameContext();
30
+ * const ref = useRef<THREE.Group>(null);
31
+ * useFrame((_, dt) => { if (input.isPressed('move_forward')) … });
32
+ * return <group ref={ref}><PlayerCharacter /></group>;
33
+ * }
34
+ * ```
35
+ *
36
+ * Throws when called outside an R3F root mounted by `createR3FAdapter` —
37
+ * absent context is a wiring bug, and a silent `null` would surface as a
38
+ * mystery `undefined` deep in a frame callback.
39
+ */
40
+ export function useGameContext() {
41
+ const bridge = useContext(EngineBridge);
42
+ if (!bridge?.ctx) {
43
+ throw new Error('useGameContext(): no engine root context. This hook only works inside an R3F ' +
44
+ 'root mounted by createR3FAdapter (@engine/world3d-react) — check that the ' +
45
+ 'component is rendered inside your world entry, not in a standalone <Canvas>.');
46
+ }
47
+ return bridge.ctx;
48
+ }
@@ -0,0 +1,47 @@
1
+ /**
2
+ * world3d-react — the react-three-fiber bridge for vgai's three surface
3
+ * (`@engine/world3d-react`).
4
+ *
5
+ * An OPT-IN module, upstreamed
6
+ * from the live-proven `examples/r3f-first-party` project copies (R4;
7
+ * decision D24 — R3F TSX is the blessed three.js authoring path). Mirrors how
8
+ * `pixi/` is the PixiJS surface's opt-in home: a peer surface module the engine
9
+ * CORE never imports (enforced by
10
+ * `packages/engine/test/react-core-import-ban.test.ts` — this directory is an
11
+ * allowed react-importing entry alongside `react/`, and core files may not
12
+ * import it).
13
+ *
14
+ * Peer contract: an importing PROJECT already depends on `react`,
15
+ * `@react-three/fiber`, and `three` (fiber's three must be deduped to the
16
+ * host's single instance — `resolve.dedupe: ['three', 'react', 'react-dom']`
17
+ * in the project's Vite config; see `createR3FAdapter`'s header). The engine
18
+ * package deliberately declares no hard dependency on fiber: only projects
19
+ * that already mount through fiber ever import this module.
20
+ *
21
+ * Surface:
22
+ * - `createR3FAdapter({ id, content })` — mount an R3F tree as a first-party
23
+ * `kind: "three"` world under the host's gated loop.
24
+ * - `useGameContext()` — this root's `R3FGameContext` (`input`, `debug`,
25
+ * `random`, `game`, `roots`, …) from inside any component in the tree. This
26
+ * is how an R3F world reaches engine services: behavior is components +
27
+ * hooks (D26b), not a class under a string key. The subsystems an R3F world
28
+ * does not build are absent from that type — see its doc comment for what
29
+ * to use instead.
30
+ * - `EngineBridge` / `EngineBridgeValue` — the context contract, exported
31
+ * for advanced adopters building their own bridge.
32
+ *
33
+ * Deliberately NOT re-exported here: `<RapierPhysicsBridge>`
34
+ * (`@engine/world3d-react/rapier-physics-bridge`), which registers an R3F
35
+ * world's `@react-three/rapier` physics as the game's
36
+ * `SystemAdapters.physics` — so the dev menu's colliders instrument and the
37
+ * editor's transform coordination can see it. It imports
38
+ * `@react-three/rapier`, and only a world that already depends on that library
39
+ * should pull it into its graph; a deep import keeps this barrel's peer
40
+ * contract to `react`/`@react-three/fiber`/`three` alone.
41
+ */
42
+ export { EngineBridge, type EngineBridgeValue, useGameContext } from './engine-bridge';
43
+ export { type CreateR3FAdapterOptions, createR3FAdapter } from './r3f-adapter';
44
+ export { r3fRootFactory, resolveR3FEntryAdapter } from './r3f-root-factory';
45
+ export { applyWorldRendererConfig, type WorldOutputColorSpace, type WorldRendererConfig, type WorldToneMapping, } from './renderer-config';
46
+ export { createR3FRootContext, DEFAULT_INPUT_MAP_PATH, type R3FGameContext, type R3FRootContextOptions, type R3FRootRuntime, } from './world-context';
47
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/world3d-react/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAEH,OAAO,EAAE,YAAY,EAAE,KAAK,iBAAiB,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACvF,OAAO,EAAE,KAAK,uBAAuB,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAC/E,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC5E,OAAO,EACL,wBAAwB,EACxB,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,GACtB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,oBAAoB,EACpB,sBAAsB,EACtB,KAAK,cAAc,EACnB,KAAK,qBAAqB,EAC1B,KAAK,cAAc,GACpB,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * world3d-react — the react-three-fiber bridge for vgai's three surface
3
+ * (`@engine/world3d-react`).
4
+ *
5
+ * An OPT-IN module, upstreamed
6
+ * from the live-proven `examples/r3f-first-party` project copies (R4;
7
+ * decision D24 — R3F TSX is the blessed three.js authoring path). Mirrors how
8
+ * `pixi/` is the PixiJS surface's opt-in home: a peer surface module the engine
9
+ * CORE never imports (enforced by
10
+ * `packages/engine/test/react-core-import-ban.test.ts` — this directory is an
11
+ * allowed react-importing entry alongside `react/`, and core files may not
12
+ * import it).
13
+ *
14
+ * Peer contract: an importing PROJECT already depends on `react`,
15
+ * `@react-three/fiber`, and `three` (fiber's three must be deduped to the
16
+ * host's single instance — `resolve.dedupe: ['three', 'react', 'react-dom']`
17
+ * in the project's Vite config; see `createR3FAdapter`'s header). The engine
18
+ * package deliberately declares no hard dependency on fiber: only projects
19
+ * that already mount through fiber ever import this module.
20
+ *
21
+ * Surface:
22
+ * - `createR3FAdapter({ id, content })` — mount an R3F tree as a first-party
23
+ * `kind: "three"` world under the host's gated loop.
24
+ * - `useGameContext()` — this root's `R3FGameContext` (`input`, `debug`,
25
+ * `random`, `game`, `roots`, …) from inside any component in the tree. This
26
+ * is how an R3F world reaches engine services: behavior is components +
27
+ * hooks (D26b), not a class under a string key. The subsystems an R3F world
28
+ * does not build are absent from that type — see its doc comment for what
29
+ * to use instead.
30
+ * - `EngineBridge` / `EngineBridgeValue` — the context contract, exported
31
+ * for advanced adopters building their own bridge.
32
+ *
33
+ * Deliberately NOT re-exported here: `<RapierPhysicsBridge>`
34
+ * (`@engine/world3d-react/rapier-physics-bridge`), which registers an R3F
35
+ * world's `@react-three/rapier` physics as the game's
36
+ * `SystemAdapters.physics` — so the dev menu's colliders instrument and the
37
+ * editor's transform coordination can see it. It imports
38
+ * `@react-three/rapier`, and only a world that already depends on that library
39
+ * should pull it into its graph; a deep import keeps this barrel's peer
40
+ * contract to `react`/`@react-three/fiber`/`three` alone.
41
+ */
42
+ export { EngineBridge, useGameContext } from './engine-bridge';
43
+ export { createR3FAdapter } from './r3f-adapter';
44
+ export { r3fRootFactory, resolveR3FEntryAdapter } from './r3f-root-factory';
45
+ export { applyWorldRendererConfig, } from './renderer-config';
46
+ export { createR3FRootContext, DEFAULT_INPUT_MAP_PATH, } from './world-context';
@@ -0,0 +1,51 @@
1
+ /**
2
+ * `createR3FAdapter` — wraps a react-three-fiber tree as a first-party
3
+ * `RootAdapter` so an R3F scene mounts as an ordinary `kind: "three"`
4
+ * world: the engine hands `mount()` a `ThreeHostContext` (ITS OWN renderer +
5
+ * canvas + gated loop, per `../adapter/host-context.ts`); this returns a
6
+ * `MountedThreeRoot` (`../adapter/root-adapter.ts`) whose `scene`/`camera`
7
+ * are fiber's REAL `THREE.Scene`/`THREE.Camera` instances.
8
+ *
9
+ * Upstreamed from `examples/r3f-first-party/src/r3f-adapter.tsx` (R4 — the
10
+ * `@engine/world3d-react` opt-in module, mirroring how `pixi/` is the
11
+ * PixiJS surface's opt-in home). The mount semantics
12
+ * are byte-for-byte the example's live-proven Phase-1 bridge. External adopters
13
+ * (alien-stories-style) keep the exact same calling contract.
14
+ *
15
+ * three.js identity: this module never imports `three` itself for scene objects
16
+ * — fiber's internal `import * as THREE from 'three'` must resolve to the SAME
17
+ * instance the engine's `ThreeHostContext.three` points at, which the importing
18
+ * project guarantees via its Vite `resolve.dedupe: ['three', 'react',
19
+ * 'react-dom']` (see `examples/r3f-first-party/vite.config.ts`).
20
+ */
21
+ import { type ReactNode } from 'react';
22
+ import type { RootAdapter } from '../adapter';
23
+ import { type WorldRendererConfig } from './renderer-config';
24
+ /** What {@link createR3FAdapter} needs to build one `RootAdapter`. */
25
+ export interface CreateR3FAdapterOptions {
26
+ /** Stable id (telemetry/registry/conformance) — `RootAdapter.id`. */
27
+ readonly id: string;
28
+ /** The R3F scene tree to mount — drei helpers, `useFrame` hooks, etc. all
29
+ * work unchanged (design §1.C: "drei works unchanged (it is fiber-context
30
+ * userland)"). */
31
+ readonly content: ReactNode;
32
+ /** Input map loaded through the game-owned `Game.loadInputMap` (load-once
33
+ * across roots). Defaults to the classic adapter's conventional path,
34
+ * `/inputmaps/default.inputmap.json`; `null` opts out (a world with no
35
+ * actions). A missing/invalid map degrades loudly without failing the
36
+ * mount — see `world-context.ts`. */
37
+ readonly inputMapPath?: string | null | undefined;
38
+ /** The colour pipeline this world was AUTHORED for, applied to the host's renderer for the life
39
+ * of the mount and restored on dispose. Omit it (every world here does) to keep the host's own
40
+ * defaults; declare it when the world's colours were picked against a different engine's
41
+ * pipeline — see `./renderer-config.ts`. */
42
+ readonly renderer?: WorldRendererConfig | undefined;
43
+ }
44
+ /**
45
+ * Build a `RootAdapter` that mounts `options.content` through
46
+ * react-three-fiber, gated entirely by the host's own loop and rendering
47
+ * through the host's own `WebGLRenderer` — never a second renderer, never a
48
+ * second `requestAnimationFrame` loop (design §1.C).
49
+ */
50
+ export declare function createR3FAdapter(options: CreateR3FAdapterOptions): RootAdapter;
51
+ //# sourceMappingURL=r3f-adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"r3f-adapter.d.ts","sourceRoot":"","sources":["../../src/world3d-react/r3f-adapter.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AASH,OAAO,EAAiB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AACtD,OAAO,KAAK,EAAoB,WAAW,EAAoB,MAAM,YAAY,CAAC;AAGlF,OAAO,EAA4B,KAAK,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAGvF,sEAAsE;AACtE,MAAM,WAAW,uBAAuB;IACtC,qEAAqE;IACrE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB;;uBAEmB;IACnB,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAC;IAC5B;;;;0CAIsC;IACtC,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAClD;;;iDAG6C;IAC7C,QAAQ,CAAC,QAAQ,CAAC,EAAE,mBAAmB,GAAG,SAAS,CAAC;CACrD;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,uBAAuB,GAAG,WAAW,CA2W9E"}