@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
+
5
+ import {Matrix4} from '@math.gl/core';
6
+ import type {InteractivityPropertyAdapter} from '../../index';
7
+ import type {GPURigidBodyWorld, GPURigidBodyParameters} from '@luma.gl/graph/gpu-physics';
8
+ import type {GPURigidBodyGeneralConstraint} from '@luma.gl/graph/gpu-physics';
9
+
10
+ export type PhysicsPropertyTarget =
11
+ | {
12
+ type: 'motion';
13
+ body: number;
14
+ property: keyof GPURigidBodyParameters;
15
+ transform?: readonly number[];
16
+ }
17
+ | {
18
+ type: 'material';
19
+ colliders: readonly number[];
20
+ property: 'staticFriction' | 'dynamicFriction' | 'restitution';
21
+ }
22
+ | {
23
+ type: 'shape';
24
+ colliders: readonly {
25
+ index: number;
26
+ scale: readonly number[];
27
+ scaleAxes?: readonly number[];
28
+ }[];
29
+ property:
30
+ | 'radius'
31
+ | 'halfExtents'
32
+ | 'height'
33
+ | 'radiusBottom'
34
+ | 'radiusTop'
35
+ | 'sizeX'
36
+ | 'sizeZ'
37
+ | 'doubleSided';
38
+ }
39
+ | {
40
+ type: 'joint';
41
+ joints: readonly number[];
42
+ property:
43
+ | 'minimum'
44
+ | 'maximum'
45
+ | 'stiffness'
46
+ | 'damping'
47
+ | 'positionTarget'
48
+ | 'velocityTarget'
49
+ | 'maximumForce'
50
+ | 'collideConnected';
51
+ drive?: boolean;
52
+ };
53
+
54
+ /** Resolved property bindings shared by authored behavior and programmatic controls. */
55
+ export class ScenegraphPhysicsProperties implements InteractivityPropertyAdapter {
56
+ constructor(
57
+ readonly world: GPURigidBodyWorld,
58
+ readonly targets: ReadonlyMap<string, PhysicsPropertyTarget>,
59
+ readonly constants: ReadonlyMap<string, readonly unknown[]> = new Map()
60
+ ) {}
61
+
62
+ get(pointer: string): unknown[] | undefined {
63
+ const target = this.targets.get(pointer);
64
+ if (!target) {
65
+ const component = this.resolveComponent(pointer);
66
+ if (component) return [component.values[component.index]];
67
+ const constant = this.constants.get(pointer);
68
+ return constant ? [...constant] : undefined;
69
+ }
70
+ if (target.type === 'motion') {
71
+ const parameters = this.world.getBodyParameters(target.body);
72
+ if (target.property === 'mode') return [this.world.getBodyMode(target.body) === 'kinematic'];
73
+ const value = parameters[target.property];
74
+ let components: number[] = Array.isArray(value)
75
+ ? [...value]
76
+ : typeof value === 'number'
77
+ ? [value]
78
+ : target.property === 'inertiaOrientation'
79
+ ? [0, 0, 0, 1]
80
+ : ['velocity', 'angularVelocity', 'centerOfMass'].includes(target.property)
81
+ ? [0, 0, 0]
82
+ : [1];
83
+ if (target.transform)
84
+ components = Array.from(
85
+ new Matrix4(target.transform).invert().transformAsVector(components)
86
+ );
87
+ return components;
88
+ }
89
+ if (target.type === 'material') {
90
+ const value = this.world.getColliderMaterial(target.colliders[0])[target.property];
91
+ return [value ?? (target.property === 'restitution' ? 0.1 : 0.6)];
92
+ }
93
+ if (target.type === 'shape') {
94
+ const collider = target.colliders[0];
95
+ const shape = this.world.getColliderShape(collider.index);
96
+ const value = Reflect.get(shape, target.property);
97
+ if (typeof value === 'boolean') return [value];
98
+ if (value === undefined) return undefined;
99
+ return (Array.isArray(value) ? value : [value]).map(
100
+ (component, index) =>
101
+ component /
102
+ (collider.scale[index] *
103
+ (collider.scaleAxes
104
+ ? this.world.getColliderShapeScale(collider.index)[collider.scaleAxes[index]]
105
+ : 1))
106
+ );
107
+ }
108
+ const joint = this.world.getJointParameters(target.joints[0]);
109
+ if (target.property === 'collideConnected') return [joint.collideConnected ?? false];
110
+ if (joint.type !== 'general') throw new Error('Property requires a general constraint');
111
+ const values = target.drive ? joint.drive : joint;
112
+ const fallback =
113
+ target.property === 'minimum'
114
+ ? -3.402823466e38
115
+ : ['maximum', 'maximumForce'].includes(target.property) ||
116
+ (target.property === 'stiffness' && !target.drive)
117
+ ? 3.402823466e38
118
+ : 0;
119
+ return [values?.[target.property as keyof typeof values] ?? fallback];
120
+ }
121
+
122
+ /** Component pointers address a declared vector; they cannot create absent fields. */
123
+ private resolveComponent(pointer: string) {
124
+ const match = /^(.*)\/(0|[1-9]\d*)$/.exec(pointer);
125
+ if (!match || !this.targets.has(match[1])) return undefined;
126
+ const values = this.get(match[1]);
127
+ const index = Number(match[2]);
128
+ if (!values || values.length < 2 || index >= values.length) return undefined;
129
+ return {pointer: match[1], values, index};
130
+ }
131
+
132
+ set(pointer: string, value: unknown[]): boolean {
133
+ const target = this.targets.get(pointer);
134
+ if (!target) {
135
+ const component = this.resolveComponent(pointer);
136
+ if (!component) return false;
137
+ if (value.length !== 1) throw new Error('Expected one property component');
138
+ const values = [...component.values];
139
+ values[component.index] = value[0];
140
+ return this.set(component.pointer, values);
141
+ }
142
+ if (target.type === 'shape') {
143
+ const boolean = target.property === 'doubleSided';
144
+ const size = target.property === 'halfExtents' ? 3 : 1;
145
+ if (
146
+ value.length !== size ||
147
+ !value.every(component =>
148
+ boolean
149
+ ? typeof component === 'boolean'
150
+ : typeof component === 'number' && Number.isFinite(component)
151
+ )
152
+ )
153
+ throw new Error('Invalid shape property');
154
+ this.world.setColliderShapes(
155
+ target.colliders.map(collider => {
156
+ const shape = this.world.getColliderShape(collider.index);
157
+ if (
158
+ !(target.property in shape) &&
159
+ !(shape.type === 'plane' && ['sizeX', 'sizeZ', 'doubleSided'].includes(target.property))
160
+ )
161
+ throw new Error('Incompatible shape property');
162
+ const components = value.map((component, index) =>
163
+ boolean
164
+ ? component
165
+ : Number(component) *
166
+ collider.scale[index] *
167
+ (collider.scaleAxes
168
+ ? this.world.getColliderShapeScale(collider.index)[collider.scaleAxes[index]]
169
+ : 1)
170
+ );
171
+ Reflect.set(shape, target.property, size === 1 ? components[0] : components);
172
+ return {collider: collider.index, shape};
173
+ })
174
+ );
175
+ return true;
176
+ }
177
+ if (target.type === 'motion' && target.property === 'mode') {
178
+ if (value.length !== 1 || typeof value[0] !== 'boolean')
179
+ throw new Error('Expected kinematic boolean');
180
+ this.world.setBodyParameters(target.body, {mode: value[0] ? 'kinematic' : 'dynamic'});
181
+ return true;
182
+ }
183
+ if (target.type === 'joint' && target.property === 'collideConnected') {
184
+ if (value.length !== 1 || typeof value[0] !== 'boolean')
185
+ throw new Error('Expected collision boolean');
186
+ this.world.setJointParameterEdits(
187
+ target.joints.map(index => ({
188
+ index,
189
+ parameters: {
190
+ ...this.world.getJointParameters(index),
191
+ collideConnected: value[0] as boolean
192
+ }
193
+ }))
194
+ );
195
+ return true;
196
+ }
197
+ if (!value.every(component => typeof component === 'number' && Number.isFinite(component)))
198
+ throw new Error('Expected finite physics property');
199
+ const components = value as number[];
200
+ if (target.type === 'motion') {
201
+ const size =
202
+ target.property === 'inertiaOrientation'
203
+ ? 4
204
+ : ['velocity', 'angularVelocity', 'centerOfMass', 'inertiaDiagonal'].includes(
205
+ target.property
206
+ )
207
+ ? 3
208
+ : 1;
209
+ if (components.length !== size) throw new Error('Invalid motion property arity');
210
+ const transformed = target.transform
211
+ ? new Matrix4(target.transform).transformAsVector(components)
212
+ : components;
213
+ this.world.setBodyParameters(target.body, {
214
+ [target.property]: size === 1 ? transformed[0] : transformed
215
+ });
216
+ } else {
217
+ if (components.length !== 1) throw new Error('Expected scalar physics property');
218
+ if (target.type === 'material') {
219
+ const edits = target.colliders.map(collider => ({
220
+ collider,
221
+ material: {
222
+ ...this.world.getColliderMaterial(collider),
223
+ [target.property]: components[0]
224
+ }
225
+ }));
226
+ for (const edit of edits) this.world.setColliderMaterial(edit.collider, edit.material);
227
+ } else
228
+ this.world.setJointParameterEdits(
229
+ target.joints.map(index => {
230
+ const joint = this.world.getJointParameters(index);
231
+ if (joint.type !== 'general') throw new Error('Property requires a general constraint');
232
+ const parameters: GPURigidBodyGeneralConstraint = target.drive
233
+ ? {...joint, drive: {...joint.drive, [target.property]: components[0]}}
234
+ : {...joint, [target.property]: components[0]};
235
+ return {index, parameters: {...joint, ...parameters}};
236
+ })
237
+ );
238
+ }
239
+ return true;
240
+ }
241
+ }
@@ -0,0 +1,116 @@
1
+ // luma.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
4
+
5
+ import {Matrix4} from '@math.gl/core';
6
+ import {GroupNode, decomposePhysicsTransform, type ScenegraphNode} from '../../index';
7
+ import type {GPURigidBodyWorld} from '@luma.gl/graph/gpu-physics';
8
+ import type {GPURigidBodyBounds} from '@luma.gl/graph/gpu-physics';
9
+
10
+ export type ScenegraphPhysicsRenderBinding = {
11
+ body: number;
12
+ /** Mesh-to-body-node transform; multiply after the published GPU body matrix. */
13
+ localMatrix: Matrix4;
14
+ visible: boolean;
15
+ };
16
+
17
+ /** Authoring transforms feed GPU publication metadata; simulated poses never come back. */
18
+ export class ScenegraphPhysicsPublication {
19
+ readonly bindings = new Map<ScenegraphNode, ScenegraphPhysicsRenderBinding>();
20
+ private boundsKey = '';
21
+ constructor(
22
+ readonly world: GPURigidBodyWorld,
23
+ readonly roots: readonly ScenegraphNode[],
24
+ readonly bodies: ReadonlyMap<ScenegraphNode, number>
25
+ ) {
26
+ if (!world.poseMatrices || !world.poseBounds)
27
+ throw new Error('Scene publication requires pose and bounds buffers');
28
+ this.update();
29
+ }
30
+
31
+ get matrices() {
32
+ return this.world.poseMatrices!;
33
+ }
34
+ get bounds() {
35
+ return this.world.poseBounds!;
36
+ }
37
+
38
+ /** Include instance/deformation bounds supplied by the engine renderer. */
39
+ update(): void {
40
+ const bounds: [number[], number[]][] = Array.from({length: this.world.count}, () => [
41
+ [Infinity, Infinity, Infinity],
42
+ [-Infinity, -Infinity, -Infinity]
43
+ ]);
44
+ const bindings = new Map<ScenegraphNode, ScenegraphPhysicsRenderBinding>();
45
+ const seen = new Set<ScenegraphNode>();
46
+ const visit = (
47
+ node: ScenegraphNode,
48
+ parent: Matrix4,
49
+ inheritedBody?: number,
50
+ inheritedInverse?: Matrix4,
51
+ visible = true
52
+ ) => {
53
+ if (seen.has(node)) throw new Error('Physics publication scene must be a tree');
54
+ seen.add(node);
55
+ const matrix = new Matrix4(parent).multiplyRight(node.matrix);
56
+ const body = this.bodies.get(node) ?? inheritedBody;
57
+ let inverse = inheritedInverse;
58
+ if (this.bodies.has(node)) {
59
+ const transform = decomposePhysicsTransform(matrix);
60
+ inverse = new Matrix4()
61
+ .translate(transform.position)
62
+ .multiplyRight(new Matrix4().fromQuaternion(transform.rotation))
63
+ .invert();
64
+ }
65
+ const displayed = visible && node.display;
66
+ if (body !== undefined && inverse) {
67
+ const localMatrix = new Matrix4(inverse).multiplyRight(matrix);
68
+ if (!Number.isInteger(body) || body < 0 || body >= this.world.count)
69
+ throw new Error('Invalid publication body');
70
+ bindings.set(node, {body, localMatrix, visible: displayed});
71
+ // Group bounds include descendants, which may belong to independent child bodies.
72
+ const localBounds = node instanceof GroupNode ? null : node.getBounds();
73
+ if (
74
+ localBounds &&
75
+ (localBounds.length !== 2 ||
76
+ localBounds.some(vector => vector.length !== 3 || !vector.every(Number.isFinite)))
77
+ )
78
+ throw new Error('Invalid scene bounds');
79
+ if (localBounds)
80
+ for (let corner = 0; corner < 8; corner++) {
81
+ const point = localMatrix.transformAsPoint([
82
+ localBounds[corner & 1][0],
83
+ localBounds[(corner >> 1) & 1][1],
84
+ localBounds[(corner >> 2) & 1][2]
85
+ ]);
86
+ for (let axis = 0; axis < 3; axis++) {
87
+ bounds[body][0][axis] = Math.min(bounds[body][0][axis], point[axis]);
88
+ bounds[body][1][axis] = Math.max(bounds[body][1][axis], point[axis]);
89
+ }
90
+ }
91
+ }
92
+ if (node instanceof GroupNode)
93
+ for (const child of node.children) visit(child, matrix, body, inverse, displayed);
94
+ };
95
+ for (const root of this.roots) visit(root, new Matrix4());
96
+
97
+ const publicationBounds: GPURigidBodyBounds[] = bounds.map(([minimum, maximum]) =>
98
+ Number.isFinite(minimum[0])
99
+ ? [
100
+ [minimum[0], minimum[1], minimum[2]],
101
+ [maximum[0], maximum[1], maximum[2]]
102
+ ]
103
+ : [
104
+ [0, 0, 0],
105
+ [0, 0, 0]
106
+ ]
107
+ );
108
+ const key = JSON.stringify(publicationBounds);
109
+ if (key !== this.boundsKey) {
110
+ this.world.setPublicationBounds(publicationBounds);
111
+ this.boundsKey = key;
112
+ }
113
+ this.bindings.clear();
114
+ for (const [node, binding] of bindings) this.bindings.set(node, binding);
115
+ }
116
+ }
@@ -0,0 +1,317 @@
1
+ // luma.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
4
+
5
+ import type {Device} from '@luma.gl/core';
6
+ import {GroupNode, type ScenegraphNode} from '../../index';
7
+ import {
8
+ ScenegraphPhysicsInstance,
9
+ type ScenegraphPhysicsDefinition,
10
+ type ScenegraphPhysicsCapture
11
+ } from './scenegraph-instance';
12
+ import {ScenegraphPhysicsMotion, type ScenegraphPhysicsColliderTarget} from './scenegraph-motion';
13
+ import {ScenegraphPhysicsPublication} from './scenegraph-publication';
14
+ import {ScenegraphPhysicsProperties} from './scenegraph-properties';
15
+ import {
16
+ ScenegraphPhysicsBehaviors,
17
+ type ScenegraphPhysicsBehaviorProps
18
+ } from './scenegraph-behaviors';
19
+ import type {GPURigidBodyWorld} from '@luma.gl/graph/gpu-physics';
20
+
21
+ export type ScenegraphPhysicsScene = {
22
+ roots: readonly ScenegraphNode[];
23
+ definition: ScenegraphPhysicsDefinition;
24
+ colliders?: readonly ScenegraphPhysicsColliderTarget[];
25
+ properties?: (world: GPURigidBodyWorld) => ScenegraphPhysicsProperties;
26
+ behaviors?: ScenegraphPhysicsBehaviorProps;
27
+ };
28
+ type NodeState = {
29
+ node: ScenegraphNode;
30
+ matrix: number[];
31
+ position: number[];
32
+ rotation: number[];
33
+ scale: number[];
34
+ display: boolean;
35
+ children?: ScenegraphNode[];
36
+ };
37
+ export type ScenegraphPhysicsSessionCapture = {
38
+ physics: ScenegraphPhysicsCapture;
39
+ scene: ScenegraphPhysicsScene;
40
+ authored: NodeState[];
41
+ ownership: ReturnType<ScenegraphPhysicsMotion['captureOwnership']>;
42
+ nodes: NodeState[];
43
+ };
44
+
45
+ /** Coordinates borrowed engine scenes and owned GPU worlds across edits and asynchronous work. */
46
+ export class ScenegraphPhysicsSession {
47
+ private pending?: Promise<unknown>;
48
+ private closing = false;
49
+ private revisionValue = 0;
50
+ private authored: NodeState[];
51
+ motion: ScenegraphPhysicsMotion;
52
+ publication: ScenegraphPhysicsPublication;
53
+ properties: ScenegraphPhysicsProperties;
54
+ behaviors?: ScenegraphPhysicsBehaviors;
55
+
56
+ private constructor(
57
+ readonly device: Device,
58
+ private scene: ScenegraphPhysicsScene,
59
+ private instance: ScenegraphPhysicsInstance
60
+ ) {
61
+ this.authored = snapshotNodes(scene.roots);
62
+ const bindings = this.makeBindings();
63
+ this.motion = bindings.motion;
64
+ this.publication = bindings.publication;
65
+ this.properties = bindings.properties;
66
+ this.behaviors = bindings.behaviors;
67
+ }
68
+ static async create(
69
+ device: Device,
70
+ scene: ScenegraphPhysicsScene
71
+ ): Promise<ScenegraphPhysicsSession> {
72
+ snapshotNodes(scene.roots);
73
+ const instance = await ScenegraphPhysicsInstance.create(
74
+ device,
75
+ withPublication(scene.definition)
76
+ );
77
+ try {
78
+ const session = new ScenegraphPhysicsSession(device, scene, instance);
79
+ await instance.publish();
80
+ return session;
81
+ } catch (error) {
82
+ await instance.destroy();
83
+ throw error;
84
+ }
85
+ }
86
+ get world() {
87
+ return this.instance.world;
88
+ }
89
+ get graph() {
90
+ return this.instance.graph;
91
+ }
92
+ /** Renderer/event bindings are borrowed for exactly one revision. */
93
+ get revision() {
94
+ return this.revisionValue;
95
+ }
96
+
97
+ private makeBindings(world = this.world, scene = this.scene) {
98
+ return {
99
+ motion: new ScenegraphPhysicsMotion(
100
+ world,
101
+ scene.roots,
102
+ scene.definition.bodies,
103
+ scene.colliders
104
+ ),
105
+ publication: new ScenegraphPhysicsPublication(world, scene.roots, scene.definition.bodies),
106
+ properties: scene.properties?.(world) ?? new ScenegraphPhysicsProperties(world, new Map()),
107
+ behaviors: scene.behaviors
108
+ ? new ScenegraphPhysicsBehaviors(world, scene.behaviors)
109
+ : undefined
110
+ };
111
+ }
112
+ private refreshBindings(bindings: ReturnType<ScenegraphPhysicsSession['makeBindings']>) {
113
+ this.motion = bindings.motion;
114
+ this.publication = bindings.publication;
115
+ this.properties = bindings.properties;
116
+ this.behaviors = bindings.behaviors;
117
+ this.revisionValue++;
118
+ }
119
+ private async exclusive<T>(operation: () => Promise<T>): Promise<T> {
120
+ if (this.pending || this.closing) throw new Error('Physics session is busy or closed');
121
+ const pending = Promise.resolve().then(operation);
122
+ this.pending = pending;
123
+ try {
124
+ return await pending;
125
+ } finally {
126
+ this.pending = undefined;
127
+ }
128
+ }
129
+
130
+ /** Sample/blend first; declare active transform tracks, including paused tracks, explicitly. */
131
+ async step(
132
+ animatedNodes: ReadonlySet<ScenegraphNode> = new Set(),
133
+ sample?: () => void,
134
+ encode?: Parameters<ScenegraphPhysicsInstance['advance']>[1]
135
+ ): Promise<void> {
136
+ return this.exclusive(() =>
137
+ this.instance.advance(() => {
138
+ sample?.();
139
+ this.motion.setAnimatedNodes(animatedNodes);
140
+ this.motion.update();
141
+ this.publication.update();
142
+ }, encode)
143
+ );
144
+ }
145
+ /** Queries and their continuations cannot outlive the world revision they borrow. */
146
+ async withWorld<T>(operation: (world: GPURigidBodyWorld) => Promise<T>): Promise<T> {
147
+ return this.exclusive(() => this.instance.withWorld(operation));
148
+ }
149
+ async capture(): Promise<ScenegraphPhysicsSessionCapture> {
150
+ return this.exclusive(async () => ({
151
+ physics: await this.instance.capture(),
152
+ scene: this.scene,
153
+ authored: this.authored.map(state => ({
154
+ ...state,
155
+ matrix: [...state.matrix],
156
+ position: [...state.position],
157
+ rotation: [...state.rotation],
158
+ scale: [...state.scale],
159
+ children: state.children ? [...state.children] : undefined
160
+ })),
161
+ ownership: this.motion.captureOwnership(),
162
+ nodes: snapshotNodes(this.scene.roots)
163
+ }));
164
+ }
165
+ async restore(capture: ScenegraphPhysicsSessionCapture): Promise<void> {
166
+ return this.exclusive(async () => {
167
+ validateNodes(capture.nodes, capture.scene.roots);
168
+ validateNodes(capture.authored, capture.scene.roots);
169
+ await this.replaceBindings(
170
+ capture.nodes,
171
+ prepare => this.instance.restore(capture.physics, prepare),
172
+ capture.scene,
173
+ bindings => bindings.motion.restoreOwnership(capture.ownership)
174
+ );
175
+ this.authored = capture.authored;
176
+ });
177
+ }
178
+ /** Restore authored physics and scene transforms, leaving external cameras alone. */
179
+ async reset(): Promise<void> {
180
+ return this.exclusive(() =>
181
+ this.replaceBindings(this.authored, prepare => this.instance.reset(prepare))
182
+ );
183
+ }
184
+ private async replaceBindings(
185
+ nodes: NodeState[],
186
+ replace: (prepare: (world: GPURigidBodyWorld) => void) => Promise<void>,
187
+ scene = this.scene,
188
+ prepareBindings?: (bindings: ReturnType<ScenegraphPhysicsSession['makeBindings']>) => void
189
+ ) {
190
+ const previousNodes = snapshotNodes(this.scene.roots);
191
+ await this.behaviors?.destroy();
192
+ let bindings: ReturnType<ScenegraphPhysicsSession['makeBindings']> | undefined;
193
+ try {
194
+ restoreNodes(nodes);
195
+ await replace(world => {
196
+ bindings = this.makeBindings(world, scene);
197
+ prepareBindings?.(bindings);
198
+ });
199
+ this.scene = scene;
200
+ this.refreshBindings(bindings!);
201
+ } catch (error) {
202
+ restoreNodes(previousNodes);
203
+ this.behaviors = this.scene.behaviors
204
+ ? new ScenegraphPhysicsBehaviors(this.world, this.scene.behaviors)
205
+ : undefined;
206
+ throw error;
207
+ }
208
+ }
209
+ /** Explicit cooking boundary for mesh, skin, morph, topology and arbitrary scene edits. */
210
+ async rebuild(cook: () => Promise<ScenegraphPhysicsScene>, preserveState = true): Promise<void> {
211
+ return this.exclusive(async () => {
212
+ const previousNodes = snapshotNodes(this.scene.roots);
213
+ try {
214
+ const scene = await cook();
215
+ const authored = snapshotNodes(scene.roots);
216
+ await this.replaceBindings(
217
+ authored,
218
+ prepare =>
219
+ this.instance.rebuild(withPublication(scene.definition), preserveState, prepare),
220
+ scene
221
+ );
222
+ this.authored = authored;
223
+ } catch (error) {
224
+ restoreNodes(previousNodes);
225
+ throw error;
226
+ }
227
+ });
228
+ }
229
+ async destroy(): Promise<void> {
230
+ this.closing = true;
231
+ try {
232
+ await this.pending;
233
+ } catch {
234
+ /* Rejected edits retain an owned instance. */
235
+ }
236
+ await this.behaviors?.destroy();
237
+ await this.instance.destroy();
238
+ }
239
+ }
240
+
241
+ function withPublication(definition: ScenegraphPhysicsDefinition): ScenegraphPhysicsDefinition {
242
+ return {
243
+ ...definition,
244
+ world: {
245
+ ...definition.world,
246
+ publicationBounds:
247
+ definition.world.publicationBounds ??
248
+ definition.world.bodies.map(() => [
249
+ [0, 0, 0],
250
+ [0, 0, 0]
251
+ ])
252
+ }
253
+ };
254
+ }
255
+ function snapshotNodes(roots: readonly ScenegraphNode[]): NodeState[] {
256
+ const result: NodeState[] = [];
257
+ const seen = new Set<ScenegraphNode>();
258
+ const visit = (node: ScenegraphNode) => {
259
+ if (seen.has(node)) throw new Error('Physics session scene must be a tree');
260
+ seen.add(node);
261
+ result.push({
262
+ node,
263
+ matrix: Array.from(node.matrix),
264
+ position: Array.from(node.position),
265
+ rotation: Array.from(node.rotation),
266
+ scale: Array.from(node.scale),
267
+ children: node instanceof GroupNode ? [...node.children] : undefined,
268
+ display: node.display
269
+ });
270
+ if (node instanceof GroupNode) for (const child of node.children) visit(child);
271
+ };
272
+ roots.forEach(visit);
273
+ return result;
274
+ }
275
+ function validateNodes(states: readonly NodeState[], roots: readonly ScenegraphNode[]) {
276
+ const nodes = new Map(states.map(state => [state.node, state]));
277
+ if (
278
+ nodes.size !== states.length ||
279
+ states.some(
280
+ state =>
281
+ state.matrix.length !== 16 ||
282
+ state.position.length !== 3 ||
283
+ state.scale.length !== 3 ||
284
+ ![3, 4].includes(state.rotation.length) ||
285
+ typeof state.display !== 'boolean' ||
286
+ [...state.matrix, ...state.position, ...state.rotation, ...state.scale].some(
287
+ value => !Number.isFinite(value)
288
+ ) ||
289
+ (state.node instanceof GroupNode ? !state.children : state.children !== undefined)
290
+ )
291
+ )
292
+ throw new Error('Incompatible scene capture');
293
+ const visited = new Set<ScenegraphNode>();
294
+ const visit = (node: ScenegraphNode) => {
295
+ const state = nodes.get(node);
296
+ if (!state || visited.has(node)) throw new Error('Incompatible captured hierarchy');
297
+ visited.add(node);
298
+ state.children?.forEach(visit);
299
+ };
300
+ roots.forEach(visit);
301
+ if (visited.size !== nodes.size) throw new Error('Detached captured node');
302
+ }
303
+
304
+ function restoreNodes(states: readonly NodeState[]) {
305
+ for (const state of states) {
306
+ state.node.setMatrixComponents({
307
+ position: [...state.position],
308
+ rotation: [...state.rotation],
309
+ scale: [...state.scale],
310
+ update: false
311
+ });
312
+ state.node.setMatrix(state.matrix);
313
+ state.node.display = state.display;
314
+ if (state.node instanceof GroupNode && state.children)
315
+ state.node.children = [...state.children];
316
+ }
317
+ }