@luma.gl/engine 10.0.0-alpha.4 → 10.0.0-alpha.5

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 (605) hide show
  1. package/README.md +9 -0
  2. package/dist/animation/animation-clip.cjs +36 -0
  3. package/dist/animation/animation-interpolation.cjs +115 -0
  4. package/dist/animation/animation-mixer.cjs +302 -0
  5. package/dist/animation/animation-track.cjs +55 -0
  6. package/dist/animation/animator.cjs +75 -0
  7. package/dist/animation/deform-positions.cjs +69 -0
  8. package/dist/animation/deform-positions.d.ts +13 -0
  9. package/dist/animation/deform-positions.d.ts.map +1 -0
  10. package/dist/animation/deform-positions.js +49 -0
  11. package/dist/animation/deform-positions.js.map +1 -0
  12. package/dist/animation/key-frames.cjs +81 -0
  13. package/dist/animation/morph-targets.cjs +162 -0
  14. package/dist/animation/node-animation-binding.cjs +67 -0
  15. package/dist/animation/node-animation-binding.d.ts +9 -0
  16. package/dist/animation/node-animation-binding.d.ts.map +1 -0
  17. package/dist/animation/node-animation-binding.js +45 -0
  18. package/dist/animation/node-animation-binding.js.map +1 -0
  19. package/dist/animation/property-animation-binding.cjs +159 -0
  20. package/dist/animation/property-animation-binding.d.ts +29 -0
  21. package/dist/animation/property-animation-binding.d.ts.map +1 -0
  22. package/dist/animation/property-animation-binding.js +138 -0
  23. package/dist/animation/property-animation-binding.js.map +1 -0
  24. package/dist/animation/scenegraph-animator.cjs +122 -0
  25. package/dist/animation/scenegraph-animator.d.ts +37 -0
  26. package/dist/animation/scenegraph-animator.d.ts.map +1 -0
  27. package/dist/animation/scenegraph-animator.js +99 -0
  28. package/dist/animation/scenegraph-animator.js.map +1 -0
  29. package/dist/animation/skin.cjs +49 -0
  30. package/dist/animation/texture-transform.cjs +41 -0
  31. package/dist/animation/texture-transform.d.ts +8 -0
  32. package/dist/animation/texture-transform.d.ts.map +1 -0
  33. package/dist/animation/texture-transform.js +17 -0
  34. package/dist/animation/texture-transform.js.map +1 -0
  35. package/dist/animation/timeline.cjs +129 -0
  36. package/dist/animation-loop/animation-loop-template.cjs +33 -0
  37. package/dist/animation-loop/animation-loop.cjs +498 -0
  38. package/dist/animation-loop/animation-loop.d.ts +2 -1
  39. package/dist/animation-loop/animation-loop.d.ts.map +1 -1
  40. package/dist/animation-loop/animation-loop.js +9 -3
  41. package/dist/animation-loop/animation-loop.js.map +1 -1
  42. package/dist/animation-loop/animation-props.cjs +15 -0
  43. package/dist/animation-loop/make-animation-loop.cjs +104 -0
  44. package/dist/animation-loop/request-animation-frame.cjs +43 -0
  45. package/dist/application-utils/load-file.cjs +77 -0
  46. package/dist/application-utils/random.cjs +38 -0
  47. package/dist/audio/audio-controller.cjs +429 -0
  48. package/dist/audio/audio-controller.d.ts +146 -0
  49. package/dist/audio/audio-controller.d.ts.map +1 -0
  50. package/dist/audio/audio-controller.js +445 -0
  51. package/dist/audio/audio-controller.js.map +1 -0
  52. package/dist/audio/audio-environment.cjs +157 -0
  53. package/dist/audio/audio-environment.d.ts +49 -0
  54. package/dist/audio/audio-environment.d.ts.map +1 -0
  55. package/dist/audio/audio-environment.js +148 -0
  56. package/dist/audio/audio-environment.js.map +1 -0
  57. package/dist/audio/audio-graph.cjs +182 -0
  58. package/dist/audio/audio-graph.d.ts +58 -0
  59. package/dist/audio/audio-graph.d.ts.map +1 -0
  60. package/dist/audio/audio-graph.js +181 -0
  61. package/dist/audio/audio-graph.js.map +1 -0
  62. package/dist/compute/buffer-transform.cjs +146 -0
  63. package/dist/compute/buffer-transform.d.ts +15 -5
  64. package/dist/compute/buffer-transform.d.ts.map +1 -1
  65. package/dist/compute/buffer-transform.js +56 -12
  66. package/dist/compute/buffer-transform.js.map +1 -1
  67. package/dist/compute/computation.cjs +331 -0
  68. package/dist/compute/computation.d.ts +2 -4
  69. package/dist/compute/computation.d.ts.map +1 -1
  70. package/dist/compute/computation.js +3 -14
  71. package/dist/compute/computation.js.map +1 -1
  72. package/dist/compute/swap.cjs +132 -0
  73. package/dist/compute/texture-transform.cjs +142 -0
  74. package/dist/compute/texture-transform.d.ts +11 -7
  75. package/dist/compute/texture-transform.d.ts.map +1 -1
  76. package/dist/compute/texture-transform.js +16 -6
  77. package/dist/compute/texture-transform.js.map +1 -1
  78. package/dist/controls/orbit-controls.cjs +283 -0
  79. package/dist/controls/orbit-controls.d.ts +2 -0
  80. package/dist/controls/orbit-controls.d.ts.map +1 -1
  81. package/dist/controls/orbit-controls.js +2 -1
  82. package/dist/controls/orbit-controls.js.map +1 -1
  83. package/dist/debug/copy-texture-to-image.cjs +84 -0
  84. package/dist/debug/debug-framebuffer.cjs +113 -0
  85. package/dist/debug/debug-shader-layout.cjs +45 -0
  86. package/dist/debug/pixel-data-utils.cjs +54 -0
  87. package/dist/dist.dev.js +11756 -5632
  88. package/dist/dist.min.js +39 -35
  89. package/dist/dynamic-buffer/dynamic-buffer.cjs +39 -0
  90. package/dist/dynamic-buffer/dynamic-buffer.d.ts +1 -170
  91. package/dist/dynamic-buffer/dynamic-buffer.d.ts.map +1 -1
  92. package/dist/dynamic-buffer/dynamic-buffer.js +2 -312
  93. package/dist/dynamic-buffer/dynamic-buffer.js.map +1 -1
  94. package/dist/dynamic-texture/dynamic-texture.cjs +27 -0
  95. package/dist/dynamic-texture/dynamic-texture.d.ts +1 -114
  96. package/dist/dynamic-texture/dynamic-texture.d.ts.map +1 -1
  97. package/dist/dynamic-texture/dynamic-texture.js +2 -584
  98. package/dist/dynamic-texture/dynamic-texture.js.map +1 -1
  99. package/dist/dynamic-texture/texture-binding-source.cjs +31 -0
  100. package/dist/dynamic-texture/texture-binding-source.d.ts +1 -54
  101. package/dist/dynamic-texture/texture-binding-source.d.ts.map +1 -1
  102. package/dist/dynamic-texture/texture-binding-source.js +2 -51
  103. package/dist/dynamic-texture/texture-binding-source.js.map +1 -1
  104. package/dist/dynamic-texture/texture-data.cjs +53 -0
  105. package/dist/dynamic-texture/texture-data.d.ts +1 -145
  106. package/dist/dynamic-texture/texture-data.d.ts.map +1 -1
  107. package/dist/dynamic-texture/texture-data.js +2 -209
  108. package/dist/dynamic-texture/texture-data.js.map +1 -1
  109. package/dist/dynamic-texture/video-texture.cjs +269 -0
  110. package/dist/dynamic-texture/video-texture.d.ts +1 -1
  111. package/dist/dynamic-texture/video-texture.d.ts.map +1 -1
  112. package/dist/experimental/controls/comparison-splitter.cjs +231 -0
  113. package/dist/experimental/controls/comparison-splitter.d.ts +54 -0
  114. package/dist/experimental/controls/comparison-splitter.d.ts.map +1 -0
  115. package/dist/experimental/controls/comparison-splitter.js +215 -0
  116. package/dist/experimental/controls/comparison-splitter.js.map +1 -0
  117. package/dist/experimental/controls/flat-controller.cjs +301 -0
  118. package/dist/experimental/controls/flat-controller.d.ts +80 -0
  119. package/dist/experimental/controls/flat-controller.d.ts.map +1 -0
  120. package/dist/experimental/controls/flat-controller.js +295 -0
  121. package/dist/experimental/controls/flat-controller.js.map +1 -0
  122. package/dist/experimental/controls/index.cjs +35 -0
  123. package/dist/experimental/controls/index.cjs.map +6 -0
  124. package/dist/experimental/controls/index.d.ts +7 -0
  125. package/dist/experimental/controls/index.d.ts.map +1 -0
  126. package/dist/experimental/controls/index.js +7 -0
  127. package/dist/experimental/controls/index.js.map +1 -0
  128. package/dist/experimental/controls/orbit-controls.cjs +27 -0
  129. package/dist/experimental/controls/orbit-controls.d.ts +3 -0
  130. package/dist/experimental/controls/orbit-controls.d.ts.map +1 -0
  131. package/dist/experimental/controls/orbit-controls.js +5 -0
  132. package/dist/experimental/controls/orbit-controls.js.map +1 -0
  133. package/dist/experimental/materials/emissive-material.cjs +126 -0
  134. package/dist/experimental/materials/emissive-material.d.ts +38 -0
  135. package/dist/experimental/materials/emissive-material.d.ts.map +1 -0
  136. package/dist/experimental/materials/emissive-material.js +100 -0
  137. package/dist/experimental/materials/emissive-material.js.map +1 -0
  138. package/dist/experimental/materials/glass-material.cjs +570 -0
  139. package/dist/experimental/materials/glass-material.d.ts +107 -0
  140. package/dist/experimental/materials/glass-material.d.ts.map +1 -0
  141. package/dist/experimental/materials/glass-material.js +544 -0
  142. package/dist/experimental/materials/glass-material.js.map +1 -0
  143. package/dist/experimental/materials/glass-transmission.cjs +954 -0
  144. package/dist/experimental/materials/glass-transmission.d.ts +193 -0
  145. package/dist/experimental/materials/glass-transmission.d.ts.map +1 -0
  146. package/dist/experimental/materials/glass-transmission.js +928 -0
  147. package/dist/experimental/materials/glass-transmission.js.map +1 -0
  148. package/dist/experimental/materials/index.cjs +61 -0
  149. package/dist/experimental/materials/index.cjs.map +6 -0
  150. package/dist/experimental/materials/index.d.ts +14 -0
  151. package/dist/experimental/materials/index.d.ts.map +1 -0
  152. package/dist/experimental/materials/index.js +11 -0
  153. package/dist/experimental/materials/index.js.map +1 -0
  154. package/dist/experimental/materials/optical-caustics.cjs +201 -0
  155. package/dist/experimental/materials/optical-caustics.d.ts +69 -0
  156. package/dist/experimental/materials/optical-caustics.d.ts.map +1 -0
  157. package/dist/experimental/materials/optical-caustics.js +180 -0
  158. package/dist/experimental/materials/optical-caustics.js.map +1 -0
  159. package/dist/experimental/materials/optical-lighting.cjs +169 -0
  160. package/dist/experimental/materials/optical-lighting.d.ts +7 -0
  161. package/dist/experimental/materials/optical-lighting.d.ts.map +1 -0
  162. package/dist/experimental/materials/optical-lighting.js +144 -0
  163. package/dist/experimental/materials/optical-lighting.js.map +1 -0
  164. package/dist/experimental/materials/optical-point-lights.cjs +258 -0
  165. package/dist/experimental/materials/optical-point-lights.d.ts +68 -0
  166. package/dist/experimental/materials/optical-point-lights.d.ts.map +1 -0
  167. package/dist/experimental/materials/optical-point-lights.js +237 -0
  168. package/dist/experimental/materials/optical-point-lights.js.map +1 -0
  169. package/dist/experimental/materials/reflective-material.cjs +216 -0
  170. package/dist/experimental/materials/reflective-material.d.ts +46 -0
  171. package/dist/experimental/materials/reflective-material.d.ts.map +1 -0
  172. package/dist/experimental/materials/reflective-material.js +190 -0
  173. package/dist/experimental/materials/reflective-material.js.map +1 -0
  174. package/dist/experimental/textures/html-texture.cjs +221 -0
  175. package/dist/experimental/textures/html-texture.d.ts +85 -0
  176. package/dist/experimental/textures/html-texture.d.ts.map +1 -0
  177. package/dist/experimental/textures/html-texture.js +206 -0
  178. package/dist/experimental/textures/html-texture.js.map +1 -0
  179. package/dist/experimental/textures/index.cjs +33 -0
  180. package/dist/experimental/textures/index.cjs.map +6 -0
  181. package/dist/experimental/textures/index.d.ts +5 -0
  182. package/dist/experimental/textures/index.d.ts.map +1 -0
  183. package/dist/experimental/textures/index.js +7 -0
  184. package/dist/experimental/textures/index.js.map +1 -0
  185. package/dist/experimental/textures/packed-pixels.cjs +248 -0
  186. package/dist/experimental/textures/packed-pixels.d.ts +17 -0
  187. package/dist/experimental/textures/packed-pixels.d.ts.map +1 -0
  188. package/dist/experimental/textures/packed-pixels.js +237 -0
  189. package/dist/experimental/textures/packed-pixels.js.map +1 -0
  190. package/dist/experimental/textures/rgba-decoder.cjs +60 -0
  191. package/dist/experimental/textures/rgba-decoder.d.ts +29 -0
  192. package/dist/experimental/textures/rgba-decoder.d.ts.map +1 -0
  193. package/dist/experimental/textures/rgba-decoder.js +43 -0
  194. package/dist/experimental/textures/rgba-decoder.js.map +1 -0
  195. package/dist/experimental/webxr/index.cjs +38 -0
  196. package/dist/experimental/webxr/index.cjs.map +6 -0
  197. package/dist/experimental/webxr/index.d.ts +9 -0
  198. package/dist/experimental/webxr/index.d.ts.map +1 -0
  199. package/dist/experimental/webxr/index.js +8 -0
  200. package/dist/experimental/webxr/index.js.map +1 -0
  201. package/dist/experimental/webxr/webxr-animation-frame-provider.cjs +38 -0
  202. package/dist/experimental/webxr/webxr-animation-frame-provider.d.ts +9 -0
  203. package/dist/experimental/webxr/webxr-animation-frame-provider.d.ts.map +1 -0
  204. package/dist/experimental/webxr/webxr-animation-frame-provider.js +17 -0
  205. package/dist/experimental/webxr/webxr-animation-frame-provider.js.map +1 -0
  206. package/dist/experimental/webxr/webxr-camera-texture.cjs +157 -0
  207. package/dist/experimental/webxr/webxr-camera-texture.d.ts +48 -0
  208. package/dist/experimental/webxr/webxr-camera-texture.d.ts.map +1 -0
  209. package/dist/experimental/webxr/webxr-camera-texture.js +144 -0
  210. package/dist/experimental/webxr/webxr-camera-texture.js.map +1 -0
  211. package/dist/experimental/webxr/webxr-input.cjs +93 -0
  212. package/dist/experimental/webxr/webxr-input.d.ts +24 -0
  213. package/dist/experimental/webxr/webxr-input.d.ts.map +1 -0
  214. package/dist/experimental/webxr/webxr-input.js +70 -0
  215. package/dist/experimental/webxr/webxr-input.js.map +1 -0
  216. package/dist/experimental/webxr/webxr-manager.cjs +356 -0
  217. package/dist/experimental/webxr/webxr-manager.d.ts +91 -0
  218. package/dist/experimental/webxr/webxr-manager.d.ts.map +1 -0
  219. package/dist/experimental/webxr/webxr-manager.js +354 -0
  220. package/dist/experimental/webxr/webxr-manager.js.map +1 -0
  221. package/dist/experimental/webxr/webxr-types.cjs +15 -0
  222. package/dist/experimental/webxr/webxr-types.d.ts +152 -0
  223. package/dist/experimental/webxr/webxr-types.d.ts.map +1 -0
  224. package/dist/experimental/webxr/webxr-types.js +5 -0
  225. package/dist/experimental/webxr/webxr-types.js.map +1 -0
  226. package/dist/geometry/edge-geometry.cjs +171 -0
  227. package/dist/geometry/geometry-primitives.cjs +189 -0
  228. package/dist/geometry/geometry-primitives.d.ts +6 -0
  229. package/dist/geometry/geometry-primitives.d.ts.map +1 -1
  230. package/dist/geometry/geometry-primitives.js +8 -0
  231. package/dist/geometry/geometry-primitives.js.map +1 -1
  232. package/dist/geometry/geometry-table.cjs +15 -0
  233. package/dist/geometry/geometry-utils.cjs +147 -0
  234. package/dist/geometry/geometry.cjs +90 -0
  235. package/dist/geometry/gpu-geometry.cjs +130 -0
  236. package/dist/geometry/gpu-vector-geometry-adapter.cjs +88 -0
  237. package/dist/geometry/gpu-vector-geometry-adapter.d.ts +5 -0
  238. package/dist/geometry/gpu-vector-geometry-adapter.d.ts.map +1 -0
  239. package/dist/geometry/gpu-vector-geometry-adapter.js +73 -0
  240. package/dist/geometry/gpu-vector-geometry-adapter.js.map +1 -0
  241. package/dist/geometry/gpu-vector-geometry.cjs +40 -0
  242. package/dist/geometry/gpu-vector-geometry.d.ts +21 -0
  243. package/dist/geometry/gpu-vector-geometry.d.ts.map +1 -0
  244. package/dist/geometry/gpu-vector-geometry.js +19 -0
  245. package/dist/geometry/gpu-vector-geometry.js.map +1 -0
  246. package/dist/geometry/mesh-simplification.cjs +385 -0
  247. package/dist/geometry/ring-geometry.cjs +104 -0
  248. package/dist/geometry/ring-geometry.d.ts +17 -0
  249. package/dist/geometry/ring-geometry.d.ts.map +1 -0
  250. package/dist/geometry/ring-geometry.js +94 -0
  251. package/dist/geometry/ring-geometry.js.map +1 -0
  252. package/dist/geometry/stroke-geometry.cjs +171 -0
  253. package/dist/graph/models/index.cjs +66 -0
  254. package/dist/graph/models/index.cjs.map +6 -0
  255. package/dist/graph/models/index.d.ts +7 -0
  256. package/dist/graph/models/index.d.ts.map +1 -0
  257. package/dist/graph/models/index.js +10 -0
  258. package/dist/graph/models/index.js.map +1 -0
  259. package/dist/graph/models/path/path-attribute-model.cjs +421 -0
  260. package/dist/graph/models/path/path-attribute-model.d.ts +142 -0
  261. package/dist/graph/models/path/path-attribute-model.d.ts.map +1 -0
  262. package/dist/graph/models/path/path-attribute-model.js +409 -0
  263. package/dist/graph/models/path/path-attribute-model.js.map +1 -0
  264. package/dist/graph/models/path/path-storage-model.cjs +711 -0
  265. package/dist/graph/models/path/path-storage-model.d.ts +174 -0
  266. package/dist/graph/models/path/path-storage-model.d.ts.map +1 -0
  267. package/dist/graph/models/path/path-storage-model.js +720 -0
  268. package/dist/graph/models/path/path-storage-model.js.map +1 -0
  269. package/dist/graph/models/path/path-trips-storage-model.cjs +271 -0
  270. package/dist/graph/models/path/path-trips-storage-model.d.ts +58 -0
  271. package/dist/graph/models/path/path-trips-storage-model.d.ts.map +1 -0
  272. package/dist/graph/models/path/path-trips-storage-model.js +248 -0
  273. package/dist/graph/models/path/path-trips-storage-model.js.map +1 -0
  274. package/dist/graph/models/polygon/polygon-attribute-model.cjs +117 -0
  275. package/dist/graph/models/polygon/polygon-attribute-model.d.ts +53 -0
  276. package/dist/graph/models/polygon/polygon-attribute-model.d.ts.map +1 -0
  277. package/dist/graph/models/polygon/polygon-attribute-model.js +101 -0
  278. package/dist/graph/models/polygon/polygon-attribute-model.js.map +1 -0
  279. package/dist/graph/models/polygon/polygon-shaders.cjs +283 -0
  280. package/dist/graph/models/polygon/polygon-shaders.d.ts +77 -0
  281. package/dist/graph/models/polygon/polygon-shaders.d.ts.map +1 -0
  282. package/dist/graph/models/polygon/polygon-shaders.js +242 -0
  283. package/dist/graph/models/polygon/polygon-shaders.js.map +1 -0
  284. package/dist/graph/models/polygon/polygon-storage-model.cjs +111 -0
  285. package/dist/graph/models/polygon/polygon-storage-model.d.ts +53 -0
  286. package/dist/graph/models/polygon/polygon-storage-model.d.ts.map +1 -0
  287. package/dist/graph/models/polygon/polygon-storage-model.js +92 -0
  288. package/dist/graph/models/polygon/polygon-storage-model.js.map +1 -0
  289. package/dist/graph/physics/index.cjs +50 -0
  290. package/dist/graph/physics/index.cjs.map +6 -0
  291. package/dist/graph/physics/index.d.ts +12 -0
  292. package/dist/graph/physics/index.d.ts.map +1 -0
  293. package/dist/graph/physics/index.js +12 -0
  294. package/dist/graph/physics/index.js.map +1 -0
  295. package/dist/graph/physics/physics-scenegraph.cjs +92 -0
  296. package/dist/graph/physics/physics-scenegraph.d.ts +35 -0
  297. package/dist/graph/physics/physics-scenegraph.d.ts.map +1 -0
  298. package/dist/graph/physics/physics-scenegraph.js +80 -0
  299. package/dist/graph/physics/physics-scenegraph.js.map +1 -0
  300. package/dist/graph/physics/scenegraph-behaviors.cjs +164 -0
  301. package/dist/graph/physics/scenegraph-behaviors.d.ts +37 -0
  302. package/dist/graph/physics/scenegraph-behaviors.d.ts.map +1 -0
  303. package/dist/graph/physics/scenegraph-behaviors.js +145 -0
  304. package/dist/graph/physics/scenegraph-behaviors.js.map +1 -0
  305. package/dist/graph/physics/scenegraph-instance.cjs +246 -0
  306. package/dist/graph/physics/scenegraph-instance.d.ts +59 -0
  307. package/dist/graph/physics/scenegraph-instance.d.ts.map +1 -0
  308. package/dist/graph/physics/scenegraph-instance.js +241 -0
  309. package/dist/graph/physics/scenegraph-instance.js.map +1 -0
  310. package/dist/graph/physics/scenegraph-joints.cjs +51 -0
  311. package/dist/graph/physics/scenegraph-joints.d.ts +5 -0
  312. package/dist/graph/physics/scenegraph-joints.d.ts.map +1 -0
  313. package/dist/graph/physics/scenegraph-joints.js +31 -0
  314. package/dist/graph/physics/scenegraph-joints.js.map +1 -0
  315. package/dist/graph/physics/scenegraph-motion.cjs +177 -0
  316. package/dist/graph/physics/scenegraph-motion.d.ts +37 -0
  317. package/dist/graph/physics/scenegraph-motion.d.ts.map +1 -0
  318. package/dist/graph/physics/scenegraph-motion.js +168 -0
  319. package/dist/graph/physics/scenegraph-motion.js.map +1 -0
  320. package/dist/graph/physics/scenegraph-properties.cjs +170 -0
  321. package/dist/graph/physics/scenegraph-properties.d.ts +37 -0
  322. package/dist/graph/physics/scenegraph-properties.d.ts.map +1 -0
  323. package/dist/graph/physics/scenegraph-properties.js +186 -0
  324. package/dist/graph/physics/scenegraph-properties.js.map +1 -0
  325. package/dist/graph/physics/scenegraph-publication.cjs +112 -0
  326. package/dist/graph/physics/scenegraph-publication.d.ts +23 -0
  327. package/dist/graph/physics/scenegraph-publication.d.ts.map +1 -0
  328. package/dist/graph/physics/scenegraph-publication.js +99 -0
  329. package/dist/graph/physics/scenegraph-publication.js.map +1 -0
  330. package/dist/graph/physics/scenegraph-session.cjs +256 -0
  331. package/dist/graph/physics/scenegraph-session.d.ts +68 -0
  332. package/dist/graph/physics/scenegraph-session.d.ts.map +1 -0
  333. package/dist/graph/physics/scenegraph-session.js +249 -0
  334. package/dist/graph/physics/scenegraph-session.js.map +1 -0
  335. package/dist/graph/tables/gpu-table-geometry.cjs +84 -0
  336. package/dist/graph/tables/gpu-table-geometry.d.ts +32 -0
  337. package/dist/graph/tables/gpu-table-geometry.d.ts.map +1 -0
  338. package/dist/graph/tables/gpu-table-geometry.js +67 -0
  339. package/dist/graph/tables/gpu-table-geometry.js.map +1 -0
  340. package/dist/graph/tables/gpu-table-model.cjs +459 -0
  341. package/dist/graph/tables/gpu-table-model.d.ts +67 -0
  342. package/dist/graph/tables/gpu-table-model.d.ts.map +1 -0
  343. package/dist/graph/tables/gpu-table-model.js +457 -0
  344. package/dist/graph/tables/gpu-table-model.js.map +1 -0
  345. package/dist/graph/tables/gpu-table-transform.cjs +341 -0
  346. package/dist/graph/tables/gpu-table-transform.d.ts +61 -0
  347. package/dist/graph/tables/gpu-table-transform.d.ts.map +1 -0
  348. package/dist/graph/tables/gpu-table-transform.js +333 -0
  349. package/dist/graph/tables/gpu-table-transform.js.map +1 -0
  350. package/dist/graph/tables/index.cjs +33 -0
  351. package/dist/graph/tables/index.cjs.map +6 -0
  352. package/dist/graph/tables/index.d.ts +4 -0
  353. package/dist/graph/tables/index.d.ts.map +1 -0
  354. package/dist/graph/tables/index.js +7 -0
  355. package/dist/graph/tables/index.js.map +1 -0
  356. package/dist/index.cjs +303 -9569
  357. package/dist/index.cjs.map +3 -3
  358. package/dist/index.d.ts +32 -5
  359. package/dist/index.d.ts.map +1 -1
  360. package/dist/index.js +26 -3
  361. package/dist/index.js.map +1 -1
  362. package/dist/interactivity/interactivity.cjs +570 -0
  363. package/dist/interactivity/interactivity.d.ts +107 -0
  364. package/dist/interactivity/interactivity.d.ts.map +1 -0
  365. package/dist/interactivity/interactivity.js +575 -0
  366. package/dist/interactivity/interactivity.js.map +1 -0
  367. package/dist/interactivity/physics.cjs +15 -0
  368. package/dist/interactivity/physics.d.ts +12 -0
  369. package/dist/interactivity/physics.d.ts.map +1 -0
  370. package/dist/interactivity/physics.js +5 -0
  371. package/dist/interactivity/physics.js.map +1 -0
  372. package/dist/material/material-factory.cjs +99 -0
  373. package/dist/material/material-factory.d.ts +1 -1
  374. package/dist/material/material-factory.d.ts.map +1 -1
  375. package/dist/material/material.cjs +239 -0
  376. package/dist/material/material.d.ts +2 -2
  377. package/dist/material/material.d.ts.map +1 -1
  378. package/dist/material/material.js +2 -2
  379. package/dist/material/material.js.map +1 -1
  380. package/dist/model/gpu-vector-bindings.cjs +226 -0
  381. package/dist/model/gpu-vector-bindings.d.ts +36 -0
  382. package/dist/model/gpu-vector-bindings.d.ts.map +1 -0
  383. package/dist/model/gpu-vector-bindings.js +217 -0
  384. package/dist/model/gpu-vector-bindings.js.map +1 -0
  385. package/dist/model/gpu-vector-draw-batches.cjs +82 -0
  386. package/dist/model/gpu-vector-draw-batches.d.ts +5 -0
  387. package/dist/model/gpu-vector-draw-batches.d.ts.map +1 -0
  388. package/dist/model/gpu-vector-draw-batches.js +73 -0
  389. package/dist/model/gpu-vector-draw-batches.js.map +1 -0
  390. package/dist/model/gpu-vector-model-batches.cjs +94 -0
  391. package/dist/model/gpu-vector-model-batches.d.ts +41 -0
  392. package/dist/model/gpu-vector-model-batches.d.ts.map +1 -0
  393. package/dist/model/gpu-vector-model-batches.js +77 -0
  394. package/dist/model/gpu-vector-model-batches.js.map +1 -0
  395. package/dist/model/gpu-vector-model.cjs +1264 -0
  396. package/dist/model/gpu-vector-model.d.ts +352 -0
  397. package/dist/model/gpu-vector-model.d.ts.map +1 -0
  398. package/dist/model/gpu-vector-model.js +1375 -0
  399. package/dist/model/gpu-vector-model.js.map +1 -0
  400. package/dist/model/model.cjs +134 -0
  401. package/dist/model/model.d.ts +21 -305
  402. package/dist/model/model.d.ts.map +1 -1
  403. package/dist/model/model.js +68 -1092
  404. package/dist/model/model.js.map +1 -1
  405. package/dist/model/split-uniforms-and-bindings.cjs +44 -0
  406. package/dist/model/split-uniforms-and-bindings.d.ts +1 -1
  407. package/dist/model/split-uniforms-and-bindings.d.ts.map +1 -1
  408. package/dist/model/split-uniforms-and-bindings.js +5 -2
  409. package/dist/model/split-uniforms-and-bindings.js.map +1 -1
  410. package/dist/models/billboard-texture-model.cjs +167 -0
  411. package/dist/models/billboard-texture-model.d.ts +1 -1
  412. package/dist/models/billboard-texture-model.d.ts.map +1 -1
  413. package/dist/models/billboard-texture-model.js +1 -1
  414. package/dist/models/billboard-texture-model.js.map +1 -1
  415. package/dist/models/billboard-texture-module.cjs +61 -0
  416. package/dist/models/clip-space.cjs +103 -0
  417. package/dist/models/directional-light-model.cjs +45 -0
  418. package/dist/models/light-model-utils.cjs +426 -0
  419. package/dist/models/point-light-model.cjs +44 -0
  420. package/dist/models/spot-light-model.cjs +45 -0
  421. package/dist/modules/picking/color-picking.cjs +209 -0
  422. package/dist/modules/picking/color-picking.d.ts +1 -1
  423. package/dist/modules/picking/index-color-picking.cjs +230 -0
  424. package/dist/modules/picking/index-color-picking.d.ts +1 -1
  425. package/dist/modules/picking/index-picking.cjs +201 -0
  426. package/dist/modules/picking/index-picking.d.ts +1 -1
  427. package/dist/modules/picking/legacy-color-picking.cjs +28 -0
  428. package/dist/modules/picking/legacy-color-picking.d.ts +1 -1
  429. package/dist/modules/picking/legacy-picking-manager.cjs +92 -0
  430. package/dist/modules/picking/picking-manager.cjs +360 -0
  431. package/dist/modules/picking/picking-uniforms.cjs +140 -0
  432. package/dist/modules/picking/picking-uniforms.d.ts +1 -1
  433. package/dist/modules/picking/picking-uniforms.d.ts.map +1 -1
  434. package/dist/modules/picking/picking.cjs +43 -0
  435. package/dist/modules/picking/picking.d.ts +1 -1
  436. package/dist/passes/get-fragment-shader.cjs +119 -0
  437. package/dist/passes/shader-pass-renderer.cjs +722 -0
  438. package/dist/passes/shader-pass-renderer.d.ts +2 -2
  439. package/dist/passes/shader-pass-renderer.d.ts.map +1 -1
  440. package/dist/passes/shader-pass-renderer.js +1 -1
  441. package/dist/passes/shader-pass-renderer.js.map +1 -1
  442. package/dist/passes/texture-transform-module.cjs +78 -0
  443. package/dist/scenegraph/controllers/area-light-controller.cjs +143 -0
  444. package/dist/scenegraph/controllers/area-light-controller.d.ts +31 -0
  445. package/dist/scenegraph/controllers/area-light-controller.d.ts.map +1 -0
  446. package/dist/scenegraph/controllers/area-light-controller.js +130 -0
  447. package/dist/scenegraph/controllers/area-light-controller.js.map +1 -0
  448. package/dist/scenegraph/controllers/billboard-controller.cjs +156 -0
  449. package/dist/scenegraph/controllers/billboard-controller.d.ts +45 -0
  450. package/dist/scenegraph/controllers/billboard-controller.d.ts.map +1 -0
  451. package/dist/scenegraph/controllers/billboard-controller.js +156 -0
  452. package/dist/scenegraph/controllers/billboard-controller.js.map +1 -0
  453. package/dist/scenegraph/controllers/joint-controller.cjs +71 -0
  454. package/dist/scenegraph/controllers/joint-controller.d.ts +30 -0
  455. package/dist/scenegraph/controllers/joint-controller.d.ts.map +1 -0
  456. package/dist/scenegraph/controllers/joint-controller.js +53 -0
  457. package/dist/scenegraph/controllers/joint-controller.js.map +1 -0
  458. package/dist/scenegraph/controllers/material-variants.cjs +61 -0
  459. package/dist/scenegraph/controllers/material-variants.d.ts +42 -0
  460. package/dist/scenegraph/controllers/material-variants.d.ts.map +1 -0
  461. package/dist/scenegraph/controllers/material-variants.js +40 -0
  462. package/dist/scenegraph/controllers/material-variants.js.map +1 -0
  463. package/dist/scenegraph/controllers/morph-controller.cjs +61 -0
  464. package/dist/scenegraph/controllers/morph-controller.d.ts +19 -0
  465. package/dist/scenegraph/controllers/morph-controller.d.ts.map +1 -0
  466. package/dist/scenegraph/controllers/morph-controller.js +41 -0
  467. package/dist/scenegraph/controllers/morph-controller.js.map +1 -0
  468. package/dist/scenegraph/controllers/skin-controller.cjs +111 -0
  469. package/dist/scenegraph/controllers/skin-controller.d.ts +36 -0
  470. package/dist/scenegraph/controllers/skin-controller.d.ts.map +1 -0
  471. package/dist/scenegraph/controllers/skin-controller.js +90 -0
  472. package/dist/scenegraph/controllers/skin-controller.js.map +1 -0
  473. package/dist/scenegraph/group-node.cjs +129 -0
  474. package/dist/scenegraph/model-node.cjs +68 -0
  475. package/dist/scenegraph/physics-transforms.cjs +95 -0
  476. package/dist/scenegraph/physics-transforms.d.ts +13 -0
  477. package/dist/scenegraph/physics-transforms.d.ts.map +1 -0
  478. package/dist/scenegraph/physics-transforms.js +72 -0
  479. package/dist/scenegraph/physics-transforms.js.map +1 -0
  480. package/dist/scenegraph/published-transforms.cjs +37 -0
  481. package/dist/scenegraph/published-transforms.d.ts +17 -0
  482. package/dist/scenegraph/published-transforms.d.ts.map +1 -0
  483. package/dist/scenegraph/published-transforms.js +16 -0
  484. package/dist/scenegraph/published-transforms.js.map +1 -0
  485. package/dist/scenegraph/scenegraph-bounds.cjs +51 -0
  486. package/dist/scenegraph/scenegraph-node.cjs +182 -0
  487. package/dist/shader-inputs.cjs +231 -0
  488. package/dist/shader-inputs.d.ts +1 -1
  489. package/dist/shader-inputs.d.ts.map +1 -1
  490. package/dist/utils/buffer-layout-helper.cjs +52 -0
  491. package/dist/utils/buffer-layout-order.cjs +37 -0
  492. package/dist/utils/deep-equal.cjs +65 -0
  493. package/dist/utils/get-platform-info.cjs +21 -0
  494. package/dist/utils/get-platform-info.d.ts +2 -0
  495. package/dist/utils/get-platform-info.d.ts.map +1 -0
  496. package/dist/utils/get-platform-info.js +5 -0
  497. package/dist/utils/get-platform-info.js.map +1 -0
  498. package/dist/utils/gpu-vector-batch-structure.cjs +45 -0
  499. package/dist/utils/gpu-vector-batch-structure.d.ts +12 -0
  500. package/dist/utils/gpu-vector-batch-structure.d.ts.map +1 -0
  501. package/dist/utils/gpu-vector-batch-structure.js +27 -0
  502. package/dist/utils/gpu-vector-batch-structure.js.map +1 -0
  503. package/dist/utils/shader-module-utils.cjs +148 -0
  504. package/dist/utils/uid.cjs +32 -0
  505. package/package.json +45 -7
  506. package/src/animation/deform-positions.ts +62 -0
  507. package/src/animation/node-animation-binding.ts +54 -0
  508. package/src/animation/property-animation-binding.ts +212 -0
  509. package/src/animation/scenegraph-animator.ts +117 -0
  510. package/src/animation/texture-transform.ts +59 -0
  511. package/src/animation-loop/animation-loop.ts +10 -3
  512. package/src/audio/audio-controller.ts +583 -0
  513. package/src/audio/audio-environment.ts +202 -0
  514. package/src/audio/audio-graph.ts +253 -0
  515. package/src/compute/buffer-transform.ts +71 -16
  516. package/src/compute/computation.ts +4 -19
  517. package/src/compute/texture-transform.ts +25 -12
  518. package/src/controls/orbit-controls.ts +4 -1
  519. package/src/dynamic-buffer/dynamic-buffer.ts +15 -449
  520. package/src/dynamic-texture/dynamic-texture.ts +5 -760
  521. package/src/dynamic-texture/texture-binding-source.ts +8 -90
  522. package/src/dynamic-texture/texture-data.ts +31 -340
  523. package/src/dynamic-texture/video-texture.ts +1 -1
  524. package/src/experimental/controls/comparison-splitter.ts +269 -0
  525. package/src/experimental/controls/flat-controller.ts +403 -0
  526. package/src/experimental/controls/index.ts +16 -0
  527. package/src/experimental/controls/orbit-controls.ts +6 -0
  528. package/src/experimental/materials/emissive-material.ts +120 -0
  529. package/src/experimental/materials/glass-material.ts +607 -0
  530. package/src/experimental/materials/glass-transmission.ts +1023 -0
  531. package/src/experimental/materials/index.ts +49 -0
  532. package/src/experimental/materials/optical-caustics.ts +234 -0
  533. package/src/experimental/materials/optical-lighting.ts +148 -0
  534. package/src/experimental/materials/optical-point-lights.ts +288 -0
  535. package/src/experimental/materials/reflective-material.ts +214 -0
  536. package/src/experimental/textures/html-texture.ts +285 -0
  537. package/src/experimental/textures/index.ts +8 -0
  538. package/src/experimental/textures/packed-pixels.ts +351 -0
  539. package/src/experimental/textures/rgba-decoder.ts +79 -0
  540. package/src/experimental/webxr/index.ts +21 -0
  541. package/src/experimental/webxr/webxr-animation-frame-provider.ts +22 -0
  542. package/src/experimental/webxr/webxr-camera-texture.ts +195 -0
  543. package/src/experimental/webxr/webxr-input.ts +117 -0
  544. package/src/experimental/webxr/webxr-manager.ts +524 -0
  545. package/src/experimental/webxr/webxr-types.ts +192 -0
  546. package/src/geometry/geometry-primitives.ts +11 -0
  547. package/src/geometry/gpu-vector-geometry-adapter.ts +78 -0
  548. package/src/geometry/gpu-vector-geometry.ts +33 -0
  549. package/src/geometry/ring-geometry.ts +117 -0
  550. package/src/graph/models/index.ts +45 -0
  551. package/src/graph/models/path/path-attribute-model.ts +563 -0
  552. package/src/graph/models/path/path-storage-model.ts +996 -0
  553. package/src/graph/models/path/path-trips-storage-model.ts +286 -0
  554. package/src/graph/models/polygon/polygon-attribute-model.ts +165 -0
  555. package/src/graph/models/polygon/polygon-shaders.ts +279 -0
  556. package/src/graph/models/polygon/polygon-storage-model.ts +146 -0
  557. package/src/graph/physics/index.ts +24 -0
  558. package/src/graph/physics/physics-scenegraph.ts +112 -0
  559. package/src/graph/physics/scenegraph-behaviors.ts +169 -0
  560. package/src/graph/physics/scenegraph-instance.ts +296 -0
  561. package/src/graph/physics/scenegraph-joints.ts +37 -0
  562. package/src/graph/physics/scenegraph-motion.ts +175 -0
  563. package/src/graph/physics/scenegraph-properties.ts +241 -0
  564. package/src/graph/physics/scenegraph-publication.ts +116 -0
  565. package/src/graph/physics/scenegraph-session.ts +317 -0
  566. package/src/graph/tables/gpu-table-geometry.ts +88 -0
  567. package/src/graph/tables/gpu-table-model.ts +661 -0
  568. package/src/graph/tables/gpu-table-transform.ts +497 -0
  569. package/src/graph/tables/index.ts +18 -0
  570. package/src/index.ts +130 -13
  571. package/src/interactivity/interactivity.ts +670 -0
  572. package/src/interactivity/physics.ts +19 -0
  573. package/src/material/material-factory.ts +1 -1
  574. package/src/material/material.ts +2 -2
  575. package/src/model/gpu-vector-bindings.ts +276 -0
  576. package/src/model/gpu-vector-draw-batches.ts +116 -0
  577. package/src/model/gpu-vector-model-batches.ts +142 -0
  578. package/src/model/gpu-vector-model.ts +1819 -0
  579. package/src/model/model.ts +91 -1444
  580. package/src/model/split-uniforms-and-bindings.ts +6 -3
  581. package/src/models/billboard-texture-model.ts +1 -1
  582. package/src/modules/picking/legacy-picking-manager.ts +1 -1
  583. package/src/modules/picking/picking-uniforms.ts +1 -1
  584. package/src/passes/shader-pass-renderer.ts +2 -2
  585. package/src/scenegraph/controllers/area-light-controller.ts +152 -0
  586. package/src/scenegraph/controllers/billboard-controller.ts +204 -0
  587. package/src/scenegraph/controllers/joint-controller.ts +81 -0
  588. package/src/scenegraph/controllers/material-variants.ts +70 -0
  589. package/src/scenegraph/controllers/morph-controller.ts +61 -0
  590. package/src/scenegraph/controllers/skin-controller.ts +125 -0
  591. package/src/scenegraph/physics-transforms.ts +82 -0
  592. package/src/scenegraph/published-transforms.ts +18 -0
  593. package/src/shader-inputs.ts +1 -1
  594. package/src/utils/get-platform-info.ts +5 -0
  595. package/src/utils/gpu-vector-batch-structure.ts +36 -0
  596. package/dist/compute/kernel.d.ts +0 -54
  597. package/dist/compute/kernel.d.ts.map +0 -1
  598. package/dist/compute/kernel.js +0 -103
  599. package/dist/compute/kernel.js.map +0 -1
  600. package/dist/compute/render-kernel.d.ts +0 -65
  601. package/dist/compute/render-kernel.d.ts.map +0 -1
  602. package/dist/compute/render-kernel.js +0 -129
  603. package/dist/compute/render-kernel.js.map +0 -1
  604. package/src/compute/kernel.ts +0 -146
  605. package/src/compute/render-kernel.ts +0 -192
@@ -0,0 +1,241 @@
1
+ // luma.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
4
+ import { Vector3 } from '@math.gl/core';
5
+ import { GPUCommandGraph } from '@luma.gl/graph/gpu-core';
6
+ import { GPURigidBodyWorld } from '@luma.gl/graph/gpu-physics';
7
+ import { rotateRigidBodyVector } from '@luma.gl/graph/gpu-physics';
8
+ /** Owns one independent simulation instance and transactional geometry/topology rebuilds. */
9
+ export class ScenegraphPhysicsInstance {
10
+ device;
11
+ definition;
12
+ execution;
13
+ pending;
14
+ destroying = false;
15
+ destroyed = false;
16
+ /** Changes on reset/rebuild. Borrowed render buffers and event identities belong to one revision. */
17
+ revision = 0;
18
+ constructor(device, definition, execution) {
19
+ this.device = device;
20
+ this.definition = definition;
21
+ this.execution = execution;
22
+ }
23
+ static async create(device, definition) {
24
+ validateDefinition(definition);
25
+ const saved = cloneDefinition(definition);
26
+ const instance = new ScenegraphPhysicsInstance(device, saved, await compile(device, saved.world));
27
+ try {
28
+ await instance.publish();
29
+ return instance;
30
+ }
31
+ catch (error) {
32
+ await instance.destroy();
33
+ throw error;
34
+ }
35
+ }
36
+ get world() {
37
+ return this.execution.world;
38
+ }
39
+ get graph() {
40
+ return this.execution.graph;
41
+ }
42
+ get bodies() {
43
+ return this.definition.bodies;
44
+ }
45
+ /** Track queries/readbacks so reset, rebuild and destruction cannot invalidate their buffers. */
46
+ async withWorld(operation) {
47
+ return this.exclusive(() => operation(this.world));
48
+ }
49
+ /** Explicit editing/debugging readback; never part of advance(). Includes authored reset state. */
50
+ async capture() {
51
+ return this.exclusive(async () => {
52
+ await this.finishSubmission();
53
+ return {
54
+ version: 1,
55
+ authored: cloneDefinition(this.definition),
56
+ state: await this.world.captureState()
57
+ };
58
+ });
59
+ }
60
+ /** Atomically restore live state, commands, caches and events, retaining the captured reset state. */
61
+ async restore(capture, prepare) {
62
+ if (capture.version !== 1)
63
+ throw new Error('Unsupported scene physics capture');
64
+ validateDefinition(capture.authored);
65
+ const authored = cloneDefinition(capture.authored);
66
+ const state = structuredClone(capture.state);
67
+ if (state.props.bodies.length !== authored.world.bodies.length)
68
+ throw new Error('Invalid captured scene bindings');
69
+ return this.exclusive(async () => {
70
+ await this.finishSubmission();
71
+ const replacement = await compile(this.device, state.props);
72
+ try {
73
+ replacement.world.restoreState(state);
74
+ prepare?.(replacement.world);
75
+ replacement.world.publishPoses();
76
+ await this.finishSubmission();
77
+ }
78
+ catch (error) {
79
+ replacement.graph.destroy();
80
+ replacement.world.destroy();
81
+ throw error;
82
+ }
83
+ const previous = this.execution;
84
+ this.execution = replacement;
85
+ this.definition = authored;
86
+ this.revision++;
87
+ previous.graph.destroy();
88
+ previous.world.destroy();
89
+ });
90
+ }
91
+ /** Publish current poses and bounds without advancing simulation time. */
92
+ async publish() {
93
+ return this.exclusive(async () => {
94
+ this.world.publishPoses();
95
+ await this.finishSubmission();
96
+ });
97
+ }
98
+ /** Advance one fixed step; state remains on GPU and only submission completion is awaited. */
99
+ async advance(beforeStep, encode) {
100
+ return this.exclusive(async () => {
101
+ beforeStep?.(this.world);
102
+ const encoder = this.device.createCommandEncoder();
103
+ if (encode)
104
+ encode(this.graph, encoder);
105
+ else
106
+ this.graph.encode(encoder, { parameters: undefined });
107
+ this.device.submit(encoder.finish());
108
+ await this.finishSubmission();
109
+ });
110
+ }
111
+ /** Restore this instance's authored state. Does not modify scene nodes or the camera. */
112
+ async reset(prepare) {
113
+ return this.replace(this.definition, false, false, prepare);
114
+ }
115
+ /** Re-cook upstream first, then atomically install the resulting geometry and bindings.
116
+ * Preserves dynamic node poses and velocities by object identity. New/static/kinematic
117
+ * nodes use the new authored state. Contact caches and event histories start a new revision.
118
+ */
119
+ async rebuild(definition, preserveState = true, prepare) {
120
+ return this.replace(definition, preserveState, true, prepare);
121
+ }
122
+ async replace(definition, preserveState, updateAuthored, prepare) {
123
+ // Validate and snapshot caller-owned data before accepting an asynchronous operation.
124
+ validateDefinition(definition);
125
+ const authored = cloneDefinition(definition);
126
+ return this.exclusive(async () => {
127
+ await this.finishSubmission();
128
+ const props = structuredClone(authored.world);
129
+ if (preserveState) {
130
+ // Rebuilds are explicit editing operations, not a per-frame simulation bridge.
131
+ const states = await this.world.readState();
132
+ const bodies = [...props.bodies];
133
+ for (const [node, index] of authored.bodies) {
134
+ const previous = this.definition.bodies.get(node);
135
+ const body = bodies[index];
136
+ const mode = body.mode ?? ((body.mass ?? 1) === 0 ? 'static' : 'dynamic');
137
+ if (previous === undefined ||
138
+ mode !== 'dynamic' ||
139
+ this.world.getBodyMode(previous) !== 'dynamic')
140
+ continue;
141
+ const state = states[previous];
142
+ const offset = rotateRigidBodyVector(state.orientation, this.world.getBodyParameters(previous).centerOfMass ?? [0, 0, 0]);
143
+ bodies[index] = {
144
+ ...body,
145
+ position: [
146
+ state.position[0] - offset[0],
147
+ state.position[1] - offset[1],
148
+ state.position[2] - offset[2]
149
+ ],
150
+ orientation: state.orientation,
151
+ velocity: new Vector3(state.velocity)
152
+ .add(new Vector3(state.angularVelocity).cross(new Vector3(rotateRigidBodyVector(state.orientation, body.centerOfMass ?? [0, 0, 0])).subtract(offset)))
153
+ .toArray(),
154
+ angularVelocity: state.angularVelocity
155
+ };
156
+ }
157
+ props.bodies = bodies;
158
+ }
159
+ const replacement = await compile(this.device, props);
160
+ try {
161
+ prepare?.(replacement.world);
162
+ replacement.world.publishPoses();
163
+ await this.finishSubmission();
164
+ }
165
+ catch (error) {
166
+ replacement.graph.destroy();
167
+ replacement.world.destroy();
168
+ throw error;
169
+ }
170
+ const previous = this.execution;
171
+ this.execution = replacement;
172
+ if (updateAuthored)
173
+ this.definition = authored;
174
+ this.revision++;
175
+ previous.graph.destroy();
176
+ previous.world.destroy();
177
+ });
178
+ }
179
+ async exclusive(operation) {
180
+ if (this.pending || this.destroying || this.destroyed)
181
+ throw new Error('Physics instance is busy or destroyed');
182
+ // Claim the lifetime before invoking caller code, including synchronous re-entry.
183
+ const pending = Promise.resolve().then(operation);
184
+ this.pending = pending;
185
+ try {
186
+ return await pending;
187
+ }
188
+ finally {
189
+ this.pending = undefined;
190
+ }
191
+ }
192
+ async finishSubmission() {
193
+ const fence = this.device.createFence();
194
+ try {
195
+ await fence.signaled;
196
+ }
197
+ finally {
198
+ fence.destroy();
199
+ }
200
+ }
201
+ /** Wait for this instance's pending operation and submissions before releasing resources. */
202
+ async destroy() {
203
+ if (this.destroyed)
204
+ return;
205
+ this.destroying = true;
206
+ try {
207
+ await this.pending;
208
+ }
209
+ catch {
210
+ /* A rejected edit still leaves an owned live execution. */
211
+ }
212
+ await this.finishSubmission();
213
+ if (this.destroyed)
214
+ return;
215
+ this.destroyed = true;
216
+ this.execution.graph.destroy();
217
+ this.execution.world.destroy();
218
+ }
219
+ }
220
+ function cloneDefinition(definition) {
221
+ return { world: structuredClone(definition.world), bodies: new Map(definition.bodies) };
222
+ }
223
+ function validateDefinition(definition) {
224
+ const indices = [...definition.bodies.values()];
225
+ if (new Set(indices).size !== indices.length ||
226
+ indices.some(index => !Number.isInteger(index) || index < 0 || index >= definition.world.bodies.length))
227
+ throw new Error('Invalid scene body bindings');
228
+ }
229
+ async function compile(device, props) {
230
+ const world = new GPURigidBodyWorld(props);
231
+ try {
232
+ const definition = new GPUCommandGraph(device);
233
+ world.addToGraph(definition);
234
+ return { world, graph: await definition.compileAsync() };
235
+ }
236
+ catch (error) {
237
+ world.destroy();
238
+ throw error;
239
+ }
240
+ }
241
+ //# sourceMappingURL=scenegraph-instance.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scenegraph-instance.js","sourceRoot":"","sources":["../../../src/graph/physics/scenegraph-instance.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,4DAA4D;AAG5D,OAAO,EAAC,OAAO,EAAC,MAAM,eAAe,CAAC;AAEtC,OAAO,EAAC,eAAe,EAAC,MAAM,yBAAyB,CAAC;AACxD,OAAO,EACL,iBAAiB,EAGlB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAC,qBAAqB,EAAC,MAAM,4BAA4B,CAAC;AAkBjE,6FAA6F;AAC7F,MAAM,OAAO,yBAAyB;IAOjB;IACT;IACA;IARF,OAAO,CAA+B;IACtC,UAAU,GAAG,KAAK,CAAC;IACnB,SAAS,GAAG,KAAK,CAAC;IAC1B,qGAAqG;IACrG,QAAQ,GAAG,CAAC,CAAC;IACb,YACmB,MAAc,EACvB,UAAuC,EACvC,SAAoB;QAFX,WAAM,GAAN,MAAM,CAAQ;QACvB,eAAU,GAAV,UAAU,CAA6B;QACvC,cAAS,GAAT,SAAS,CAAW;IAC3B,CAAC;IAEJ,MAAM,CAAC,KAAK,CAAC,MAAM,CACjB,MAAc,EACd,UAAuC;QAEvC,kBAAkB,CAAC,UAAU,CAAC,CAAC;QAC/B,MAAM,KAAK,GAAG,eAAe,CAAC,UAAU,CAAC,CAAC;QAC1C,MAAM,QAAQ,G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YAAY,EAAE,EAAC,CAAC;IACzD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,KAAK,CAAC,OAAO,EAAE,CAAC;QAChB,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC"}
@@ -0,0 +1,51 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var scenegraph_joints_exports = {};
19
+ __export(scenegraph_joints_exports, {
20
+ makeRigidBodyJointsFromScenegraph: () => makeRigidBodyJointsFromScenegraph
21
+ });
22
+ module.exports = __toCommonJS(scenegraph_joints_exports);
23
+ function makeRigidBodyJointsFromScenegraph(resolved, bodyIndices, fixedWorldBody) {
24
+ const bodyIndex = (body) => {
25
+ const index = body ? bodyIndices.get(body) : fixedWorldBody;
26
+ if (index === void 0)
27
+ throw new Error("Missing physics body for joint attachment");
28
+ return index;
29
+ };
30
+ const base = {
31
+ type: "general",
32
+ first: bodyIndex(resolved.first.body),
33
+ second: bodyIndex(resolved.second.body),
34
+ firstFrame: { position: resolved.first.position, orientation: resolved.first.orientation },
35
+ secondFrame: { position: resolved.second.position, orientation: resolved.second.orientation },
36
+ enabled: resolved.joint.enabled,
37
+ collideConnected: resolved.joint.collideConnected
38
+ };
39
+ const constraints = (resolved.joint.limits ?? []).map((limit) => ({
40
+ ...base,
41
+ ...limit
42
+ }));
43
+ for (const { axis, angular, ...drive } of resolved.joint.drives ?? []) {
44
+ constraints.push({ ...base, axes: [axis], angular, drive });
45
+ }
46
+ return constraints.length ? constraints : [{ ...base, axes: [0] }];
47
+ }
48
+ // Annotate the CommonJS export names for ESM import in node:
49
+ 0 && (module.exports = {
50
+ makeRigidBodyJointsFromScenegraph
51
+ });
@@ -0,0 +1,5 @@
1
+ import type { ResolvedScenegraphJoint, ScenegraphNode } from "../../index.js";
2
+ import type { GPURigidBodyJoint } from '@luma.gl/graph/gpu-physics';
3
+ /** Compile shared scene attachments into backend rows; no glTF dependency or parsing. */
4
+ export declare function makeRigidBodyJointsFromScenegraph(resolved: ResolvedScenegraphJoint, bodyIndices: ReadonlyMap<ScenegraphNode, number>, fixedWorldBody?: number): GPURigidBodyJoint[];
5
+ //# sourceMappingURL=scenegraph-joints.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scenegraph-joints.d.ts","sourceRoot":"","sources":["../../../src/graph/physics/scenegraph-joints.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,uBAAuB,EAAE,cAAc,EAAC,uBAAoB;AACzE,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,4BAA4B,CAAC;AAElE,yFAAyF;AACzF,wBAAgB,iCAAiC,CAC/C,QAAQ,EAAE,uBAAuB,EACjC,WAAW,EAAE,WAAW,CAAC,cAAc,EAAE,MAAM,CAAC,EAChD,cAAc,CAAC,EAAE,MAAM,GACtB,iBAAiB,EAAE,CAwBrB"}
@@ -0,0 +1,31 @@
1
+ // luma.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
4
+ /** Compile shared scene attachments into backend rows; no glTF dependency or parsing. */
5
+ export function makeRigidBodyJointsFromScenegraph(resolved, bodyIndices, fixedWorldBody) {
6
+ const bodyIndex = (body) => {
7
+ const index = body ? bodyIndices.get(body) : fixedWorldBody;
8
+ if (index === undefined)
9
+ throw new Error('Missing physics body for joint attachment');
10
+ return index;
11
+ };
12
+ const base = {
13
+ type: 'general',
14
+ first: bodyIndex(resolved.first.body),
15
+ second: bodyIndex(resolved.second.body),
16
+ firstFrame: { position: resolved.first.position, orientation: resolved.first.orientation },
17
+ secondFrame: { position: resolved.second.position, orientation: resolved.second.orientation },
18
+ enabled: resolved.joint.enabled,
19
+ collideConnected: resolved.joint.collideConnected
20
+ };
21
+ const constraints = (resolved.joint.limits ?? []).map(limit => ({
22
+ ...base,
23
+ ...limit
24
+ }));
25
+ for (const { axis, angular, ...drive } of resolved.joint.drives ?? []) {
26
+ constraints.push({ ...base, axes: [axis], angular, drive });
27
+ }
28
+ // A joint without rows still governs connected collision filtering.
29
+ return constraints.length ? constraints : [{ ...base, axes: [0] }];
30
+ }
31
+ //# sourceMappingURL=scenegraph-joints.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scenegraph-joints.js","sourceRoot":"","sources":["../../../src/graph/physics/scenegraph-joints.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,4DAA4D;AAK5D,yFAAyF;AACzF,MAAM,UAAU,iCAAiC,CAC/C,QAAiC,EACjC,WAAgD,EAChD,cAAuB;IAEvB,MAAM,SAAS,GAAG,CAAC,IAA2B,EAAE,EAAE;QAChD,MAAM,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC;QAC5D,IAAI,KAAK,KAAK,SAAS;YAAE,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;QACtF,OAAO,KAAK,CAAC;IACf,CAAC,CAAC;IACF,MAAM,IAAI,GAAG;QACX,IAAI,EAAE,SAAkB;QACxB,KAAK,EAAE,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC;QACrC,MAAM,EAAE,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC;QACvC,UAAU,EAAE,EAAC,QAAQ,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,WAAW,EAAE,QAAQ,CAAC,KAAK,CAAC,WAAW,EAAC;QACxF,WAAW,EAAE,EAAC,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,QAAQ,EAAE,WAAW,EAAE,QAAQ,CAAC,MAAM,CAAC,WAAW,EAAC;QAC3F,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,OAAO;QAC/B,gBAAgB,EAAE,QAAQ,CAAC,KAAK,CAAC,gBAAgB;KAClD,CAAC;IACF,MAAM,WAAW,GAAwB,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACnF,GAAG,IAAI;QACP,GAAG,KAAK;KACT,CAAC,CAAC,CAAC;IACJ,KAAK,MAAM,EAAC,IAAI,EAAE,OAAO,EAAE,GAAG,KAAK,EAAC,IAAI,QAAQ,CAAC,KAAK,CAAC,MAAM,IAAI,EAAE,EAAE,CAAC;QACpE,WAAW,CAAC,IAAI,CAAC,EAAC,GAAG,IAAI,EAAE,IAAI,EAAE,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,KAAK,EAAC,CAAC,CAAC;IAC5D,CAAC;IACD,oEAAoE;IACpE,OAAO,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,EAAC,GAAG,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAC,CAAC,CAAC;AACnE,CAAC"}
@@ -0,0 +1,177 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var scenegraph_motion_exports = {};
19
+ __export(scenegraph_motion_exports, {
20
+ ScenegraphPhysicsMotion: () => ScenegraphPhysicsMotion
21
+ });
22
+ module.exports = __toCommonJS(scenegraph_motion_exports);
23
+ var import_core = require("@math.gl/core");
24
+ var import__ = require("../../index.cjs");
25
+ var import_gpu_physics = require("@luma.gl/graph/gpu-physics");
26
+ class ScenegraphPhysicsMotion {
27
+ world;
28
+ roots;
29
+ targets;
30
+ colliders;
31
+ colliderScales = /* @__PURE__ */ new Map();
32
+ activeTargets;
33
+ colliderFrames = /* @__PURE__ */ new Map();
34
+ releasedModes = /* @__PURE__ */ new Map();
35
+ inverseBodyFrames = /* @__PURE__ */ new Map();
36
+ constructor(world, roots, targets, colliders = []) {
37
+ this.world = world;
38
+ this.roots = roots;
39
+ this.targets = targets;
40
+ this.colliders = colliders;
41
+ const matrices = this.collectWorldMatrices();
42
+ for (const collider of colliders) {
43
+ const matrix = matrices.get(collider.node);
44
+ if (!matrix)
45
+ throw new Error("Detached collider animation target");
46
+ const local = new import_core.Matrix4(matrix);
47
+ if (collider.localMatrix)
48
+ local.multiplyRight(collider.localMatrix);
49
+ this.colliderScales.set(collider.index, (0, import__.decomposePhysicsTransform)(local).scale.map(Math.abs));
50
+ }
51
+ }
52
+ /** Resolve already-blended animation ownership. Animated ancestors own descendant body poses.
53
+ * Paused actions should remain in this set; stopped actions should be removed. On release,
54
+ * physics retains the last accepted pose and kinematic velocity rather than snapping to authoring.
55
+ */
56
+ setAnimatedNodes(nodes) {
57
+ const active = /* @__PURE__ */ new Set();
58
+ const visit = (node, inherited) => {
59
+ const animated = inherited || nodes.has(node);
60
+ if (animated && this.targets.has(node))
61
+ active.add(node);
62
+ if (node instanceof import__.GroupNode)
63
+ for (const child of node.children)
64
+ visit(child, animated);
65
+ };
66
+ if (nodes.size)
67
+ for (const root of this.roots)
68
+ visit(root, false);
69
+ for (const [node, body] of this.targets) {
70
+ if (active.has(node)) {
71
+ if (!this.releasedModes.has(body) || this.world.getBodyMode(body) !== "kinematic")
72
+ this.releasedModes.set(body, this.world.getBodyMode(body));
73
+ if (this.world.getBodyMode(body) !== "kinematic")
74
+ this.world.setBodyParameters(body, { mode: "kinematic" });
75
+ } else if (this.releasedModes.has(body)) {
76
+ this.world.setBodyParameters(body, { mode: this.releasedModes.get(body) });
77
+ this.releasedModes.delete(body);
78
+ }
79
+ }
80
+ this.activeTargets = active;
81
+ }
82
+ captureOwnership() {
83
+ return { active: [...this.activeTargets ?? []], releasedModes: [...this.releasedModes] };
84
+ }
85
+ restoreOwnership(state) {
86
+ if (state.active.some((node) => !this.targets.has(node)) || state.releasedModes.some(([body, mode]) => ![...this.targets.values()].includes(body) || !["static", "dynamic", "kinematic"].includes(mode)))
87
+ throw new Error("Invalid animation ownership capture");
88
+ this.activeTargets = new Set(state.active);
89
+ this.releasedModes.clear();
90
+ for (const [body, mode] of state.releasedModes)
91
+ this.releasedModes.set(body, mode);
92
+ }
93
+ collectWorldMatrices() {
94
+ const matrices = /* @__PURE__ */ new Map();
95
+ const visit = (node, parent) => {
96
+ if (matrices.has(node))
97
+ throw new Error("Physics motion scene must be a tree");
98
+ const matrix = new import_core.Matrix4(parent).multiplyRight(node.matrix);
99
+ matrices.set(node, matrix);
100
+ if (node instanceof import__.GroupNode)
101
+ for (const child of node.children)
102
+ visit(child, matrix);
103
+ };
104
+ for (const root of this.roots)
105
+ visit(root, new import_core.Matrix4());
106
+ return matrices;
107
+ }
108
+ /** Call after sampling animation, before submitting the corresponding fixed physics step. */
109
+ update() {
110
+ var _a;
111
+ const currentMatrices = this.collectWorldMatrices();
112
+ const scaleChanges = this.colliders.flatMap((collider) => {
113
+ const matrix = currentMatrices.get(collider.node);
114
+ if (!matrix)
115
+ throw new Error("Detached collider animation target");
116
+ const local = new import_core.Matrix4(matrix);
117
+ if (collider.localMatrix)
118
+ local.multiplyRight(collider.localMatrix);
119
+ const scale = (0, import__.decomposePhysicsTransform)(local).scale.map(Math.abs);
120
+ const previous = this.colliderScales.get(collider.index);
121
+ if (scale.every((value, index) => Math.abs(value - previous[index]) < 1e-7))
122
+ return [];
123
+ return [
124
+ {
125
+ collider: collider.index,
126
+ scale,
127
+ shapeScale: this.world.getColliderShapeScale(collider.index).map((value, index) => value * scale[index] / previous[index]),
128
+ shape: (0, import_gpu_physics.scaleRigidBodyShape)(this.world.getColliderShape(collider.index), scale.map((value, index) => value / previous[index]))
129
+ }
130
+ ];
131
+ });
132
+ if (scaleChanges.length) {
133
+ this.world.setColliderShapes(scaleChanges);
134
+ for (const change of scaleChanges)
135
+ this.colliderScales.set(change.collider, change.scale);
136
+ }
137
+ this.inverseBodyFrames.clear();
138
+ for (const [node, body] of this.targets) {
139
+ if (this.activeTargets && !this.activeTargets.has(node))
140
+ continue;
141
+ if (this.activeTargets && this.world.getBodyMode(body) !== "kinematic") {
142
+ this.releasedModes.set(body, this.world.getBodyMode(body));
143
+ this.world.setBodyParameters(body, { mode: "kinematic" });
144
+ }
145
+ const matrix = currentMatrices.get(node);
146
+ if (!matrix)
147
+ throw new Error("Detached physics motion target");
148
+ const transform = (0, import__.decomposePhysicsTransform)(matrix);
149
+ this.world.setKinematicTarget(body, transform.position, transform.rotation);
150
+ this.inverseBodyFrames.set(body, new import_core.Matrix4().translate(transform.position).multiplyRight(new import_core.Matrix4().fromQuaternion(transform.rotation)).invert());
151
+ }
152
+ for (const collider of this.colliders) {
153
+ const matrix = currentMatrices.get(collider.node);
154
+ const bodyMatrix = currentMatrices.get(collider.body);
155
+ if (!matrix || !bodyMatrix)
156
+ throw new Error("Detached collider animation target");
157
+ const body = (0, import__.decomposePhysicsTransform)(bodyMatrix);
158
+ const inverse = new import_core.Matrix4().translate(body.position).multiplyRight(new import_core.Matrix4().fromQuaternion(body.rotation)).invert();
159
+ const colliderMatrix = inverse.multiplyRight(matrix);
160
+ if (collider.localMatrix)
161
+ colliderMatrix.multiplyRight(collider.localMatrix);
162
+ const transform = (0, import__.decomposePhysicsTransform)(colliderMatrix);
163
+ const frame = [...transform.position, ...transform.rotation];
164
+ const previousFrame = this.colliderFrames.get(collider.index);
165
+ if (!previousFrame || frame.some((value, index) => Math.abs(value - previousFrame[index]) > 1e-7)) {
166
+ this.world.setColliderTransform(collider.index, transform.position, transform.rotation);
167
+ this.colliderFrames.set(collider.index, frame);
168
+ }
169
+ }
170
+ if (this.inverseBodyFrames.size !== (((_a = this.activeTargets) == null ? void 0 : _a.size) ?? this.targets.size))
171
+ throw new Error("Detached physics motion target");
172
+ }
173
+ }
174
+ // Annotate the CommonJS export names for ESM import in node:
175
+ 0 && (module.exports = {
176
+ ScenegraphPhysicsMotion
177
+ });
@@ -0,0 +1,37 @@
1
+ import { Matrix4 } from '@math.gl/core';
2
+ import { type ScenegraphNode } from "../../index.js";
3
+ import type { GPURigidBodyWorld } from '@luma.gl/graph/gpu-physics';
4
+ export type ScenegraphPhysicsColliderTarget = {
5
+ node: ScenegraphNode;
6
+ index: number;
7
+ body: ScenegraphNode;
8
+ /** Cooked collider frame relative to its scene node, before node scale. */
9
+ localMatrix?: readonly number[];
10
+ };
11
+ /** Animation owns declared kinematic nodes; physics publishes their accepted poses for rendering. */
12
+ export declare class ScenegraphPhysicsMotion {
13
+ readonly world: GPURigidBodyWorld;
14
+ readonly roots: readonly ScenegraphNode[];
15
+ readonly targets: ReadonlyMap<ScenegraphNode, number>;
16
+ readonly colliders: readonly ScenegraphPhysicsColliderTarget[];
17
+ private readonly colliderScales;
18
+ private activeTargets?;
19
+ private readonly colliderFrames;
20
+ private readonly releasedModes;
21
+ readonly inverseBodyFrames: Map<number, Matrix4>;
22
+ constructor(world: GPURigidBodyWorld, roots: readonly ScenegraphNode[], targets: ReadonlyMap<ScenegraphNode, number>, colliders?: readonly ScenegraphPhysicsColliderTarget[]);
23
+ /** Resolve already-blended animation ownership. Animated ancestors own descendant body poses.
24
+ * Paused actions should remain in this set; stopped actions should be removed. On release,
25
+ * physics retains the last accepted pose and kinematic velocity rather than snapping to authoring.
26
+ */
27
+ setAnimatedNodes(nodes: ReadonlySet<ScenegraphNode>): void;
28
+ captureOwnership(): {
29
+ active: ScenegraphNode[];
30
+ releasedModes: [number, 'static' | 'dynamic' | 'kinematic'][];
31
+ };
32
+ restoreOwnership(state: ReturnType<ScenegraphPhysicsMotion['captureOwnership']>): void;
33
+ private collectWorldMatrices;
34
+ /** Call after sampling animation, before submitting the corresponding fixed physics step. */
35
+ update(): void;
36
+ }
37
+ //# sourceMappingURL=scenegraph-motion.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scenegraph-motion.d.ts","sourceRoot":"","sources":["../../../src/graph/physics/scenegraph-motion.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,OAAO,EAAC,MAAM,eAAe,CAAC;AACtC,OAAO,EAAuC,KAAK,cAAc,EAAC,uBAAoB;AAEtF,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,4BAA4B,CAAC;AAElE,MAAM,MAAM,+BAA+B,GAAG;IAC5C,IAAI,EAAE,cAAc,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,cAAc,CAAC;IACrB,2EAA2E;IAC3E,WAAW,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACjC,CAAC;AAEF,qGAAqG;AACrG,qBAAa,uBAAuB;IAOhC,QAAQ,CAAC,KAAK,EAAE,iBAAiB;IACjC,QAAQ,CAAC,KAAK,EAAE,SAAS,cAAc,EAAE;IACzC,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC,cAAc,EAAE,MAAM,CAAC;IAC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