@luma.gl/engine 10.0.0-alpha.9 → 10.0.0-beta.1

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 (381) hide show
  1. package/LICENSE +4 -4
  2. package/THIRD-PARTY-NOTICES.md +185 -0
  3. package/dist/animation/node-animation-binding.cjs +10 -0
  4. package/dist/animation/node-animation-binding.d.ts +1 -1
  5. package/dist/animation/node-animation-binding.d.ts.map +1 -1
  6. package/dist/animation/node-animation-binding.js +10 -0
  7. package/dist/animation/node-animation-binding.js.map +1 -1
  8. package/dist/arrow/index.cjs.map +2 -2
  9. package/dist/arrow/renderers/splats/conversion/make-gpu-splat-data-from-gltf.cjs +12 -13
  10. package/dist/arrow/renderers/splats/conversion/make-gpu-splat-data-from-gltf.d.ts.map +1 -1
  11. package/dist/arrow/renderers/splats/conversion/make-gpu-splat-data-from-gltf.js +22 -17
  12. package/dist/arrow/renderers/splats/conversion/make-gpu-splat-data-from-gltf.js.map +1 -1
  13. package/dist/arrow/renderers/text/renderers/arrow-text-shaders.cjs +1 -1
  14. package/dist/arrow/renderers/text/renderers/arrow-text-shaders.js +1 -1
  15. package/dist/arrow/renderers/text/renderers/arrow-text-shaders.js.map +1 -1
  16. package/dist/compute/computation.cjs +1 -1
  17. package/dist/compute/computation.js +1 -1
  18. package/dist/compute/computation.js.map +1 -1
  19. package/dist/compute/swap.d.ts +2 -2
  20. package/dist/compute/swap.d.ts.map +1 -1
  21. package/dist/compute/swap.js.map +1 -1
  22. package/dist/dist.dev.js +887 -381
  23. package/dist/dist.min.js +74 -67
  24. package/dist/dynamic-texture/video-texture.cjs +1 -1
  25. package/dist/dynamic-texture/video-texture.d.ts +3 -3
  26. package/dist/dynamic-texture/video-texture.d.ts.map +1 -1
  27. package/dist/dynamic-texture/video-texture.js +1 -1
  28. package/dist/dynamic-texture/video-texture.js.map +1 -1
  29. package/dist/effects/index.cjs.map +1 -1
  30. package/dist/effects/passes/postprocessing/fxaa/fxaa.d.ts.map +1 -1
  31. package/dist/effects/passes/postprocessing/fxaa/fxaa.js +2 -1
  32. package/dist/effects/passes/postprocessing/fxaa/fxaa.js.map +1 -1
  33. package/dist/effects/passes/postprocessing/image-adjust-filters/brightnesscontrast.d.ts.map +1 -1
  34. package/dist/effects/passes/postprocessing/image-adjust-filters/brightnesscontrast.js +2 -0
  35. package/dist/effects/passes/postprocessing/image-adjust-filters/brightnesscontrast.js.map +1 -1
  36. package/dist/effects/passes/postprocessing/image-adjust-filters/denoise.d.ts.map +1 -1
  37. package/dist/effects/passes/postprocessing/image-adjust-filters/denoise.js +2 -0
  38. package/dist/effects/passes/postprocessing/image-adjust-filters/denoise.js.map +1 -1
  39. package/dist/effects/passes/postprocessing/image-adjust-filters/huesaturation.d.ts.map +1 -1
  40. package/dist/effects/passes/postprocessing/image-adjust-filters/huesaturation.js +2 -0
  41. package/dist/effects/passes/postprocessing/image-adjust-filters/huesaturation.js.map +1 -1
  42. package/dist/effects/passes/postprocessing/image-adjust-filters/noise.d.ts.map +1 -1
  43. package/dist/effects/passes/postprocessing/image-adjust-filters/noise.js +2 -0
  44. package/dist/effects/passes/postprocessing/image-adjust-filters/noise.js.map +1 -1
  45. package/dist/effects/passes/postprocessing/image-adjust-filters/sepia.d.ts.map +1 -1
  46. package/dist/effects/passes/postprocessing/image-adjust-filters/sepia.js +2 -0
  47. package/dist/effects/passes/postprocessing/image-adjust-filters/sepia.js.map +1 -1
  48. package/dist/effects/passes/postprocessing/image-adjust-filters/vibrance.d.ts.map +1 -1
  49. package/dist/effects/passes/postprocessing/image-adjust-filters/vibrance.js +2 -0
  50. package/dist/effects/passes/postprocessing/image-adjust-filters/vibrance.js.map +1 -1
  51. package/dist/effects/passes/postprocessing/image-adjust-filters/vignette.d.ts.map +1 -1
  52. package/dist/effects/passes/postprocessing/image-adjust-filters/vignette.js +2 -0
  53. package/dist/effects/passes/postprocessing/image-adjust-filters/vignette.js.map +1 -1
  54. package/dist/gltf/gltf/animations/animations.d.ts +1 -1
  55. package/dist/gltf/gltf/animations/animations.d.ts.map +1 -1
  56. package/dist/gltf/gltf/create-gltf-model.cjs +3 -0
  57. package/dist/gltf/gltf/create-gltf-model.d.ts.map +1 -1
  58. package/dist/gltf/gltf/create-gltf-model.js +4 -0
  59. package/dist/gltf/gltf/create-gltf-model.js.map +1 -1
  60. package/dist/gltf/gltf/create-scenegraph-from-gltf.cjs +80 -12
  61. package/dist/gltf/gltf/create-scenegraph-from-gltf.d.ts +8 -1
  62. package/dist/gltf/gltf/create-scenegraph-from-gltf.d.ts.map +1 -1
  63. package/dist/gltf/gltf/create-scenegraph-from-gltf.js +82 -14
  64. package/dist/gltf/gltf/create-scenegraph-from-gltf.js.map +1 -1
  65. package/dist/gltf/gltf/gltf-billboard.cjs +6 -1
  66. package/dist/gltf/gltf/gltf-billboard.d.ts.map +1 -1
  67. package/dist/gltf/gltf/gltf-billboard.js +6 -1
  68. package/dist/gltf/gltf/gltf-billboard.js.map +1 -1
  69. package/dist/gltf/gltf/gltf-extension-support.cjs +2 -2
  70. package/dist/gltf/gltf/gltf-extension-support.js +2 -2
  71. package/dist/gltf/gltf/gltf-extension-support.js.map +1 -1
  72. package/dist/gltf/index.cjs +2 -0
  73. package/dist/gltf/index.cjs.map +3 -3
  74. package/dist/gltf/index.d.ts +1 -1
  75. package/dist/gltf/index.d.ts.map +1 -1
  76. package/dist/gltf/index.js +1 -1
  77. package/dist/gltf/index.js.map +1 -1
  78. package/dist/gltf/parsers/parse-gltf-animations.cjs +8 -5
  79. package/dist/gltf/parsers/parse-gltf-animations.js +20 -5
  80. package/dist/gltf/parsers/parse-gltf-animations.js.map +1 -1
  81. package/dist/gltf/parsers/parse-gltf-lights.cjs +36 -72
  82. package/dist/gltf/parsers/parse-gltf-lights.d.ts +6 -2
  83. package/dist/gltf/parsers/parse-gltf-lights.d.ts.map +1 -1
  84. package/dist/gltf/parsers/parse-gltf-lights.js +34 -91
  85. package/dist/gltf/parsers/parse-gltf-lights.js.map +1 -1
  86. package/dist/gltf/parsers/parse-gltf-metadata.cjs +60 -0
  87. package/dist/gltf/parsers/parse-gltf-metadata.d.ts +5 -0
  88. package/dist/gltf/parsers/parse-gltf-metadata.d.ts.map +1 -0
  89. package/dist/gltf/parsers/parse-gltf-metadata.js +39 -0
  90. package/dist/gltf/parsers/parse-gltf-metadata.js.map +1 -0
  91. package/dist/gltf/parsers/parse-gltf.cjs +4 -1
  92. package/dist/gltf/parsers/parse-gltf.d.ts +10 -2
  93. package/dist/gltf/parsers/parse-gltf.d.ts.map +1 -1
  94. package/dist/gltf/parsers/parse-gltf.js +3 -0
  95. package/dist/gltf/parsers/parse-gltf.js.map +1 -1
  96. package/dist/gltf/parsers/parse-pbr-material.cjs +13 -3
  97. package/dist/gltf/parsers/parse-pbr-material.d.ts +7 -2
  98. package/dist/gltf/parsers/parse-pbr-material.d.ts.map +1 -1
  99. package/dist/gltf/parsers/parse-pbr-material.js +17 -5
  100. package/dist/gltf/parsers/parse-pbr-material.js.map +1 -1
  101. package/dist/gltf/pbr/pbr-environment.cjs +21 -3
  102. package/dist/gltf/pbr/pbr-environment.d.ts +3 -0
  103. package/dist/gltf/pbr/pbr-environment.d.ts.map +1 -1
  104. package/dist/gltf/pbr/pbr-environment.js +19 -1
  105. package/dist/gltf/pbr/pbr-environment.js.map +1 -1
  106. package/dist/gltf/pbr/pbr-material.d.ts +3 -3
  107. package/dist/gltf/pbr/pbr-material.d.ts.map +1 -1
  108. package/dist/gltf/types/gltf-json-schema.d.ts.map +1 -1
  109. package/dist/gltf/types/gltf-json-schema.js +1 -0
  110. package/dist/gltf/types/gltf-json-schema.js.map +1 -1
  111. package/dist/gltf/types/gltf-postprocessed-schema.d.ts.map +1 -1
  112. package/dist/gltf/types/gltf-postprocessed-schema.js +1 -0
  113. package/dist/gltf/types/gltf-postprocessed-schema.js.map +1 -1
  114. package/dist/graph/models/index.cjs.map +1 -1
  115. package/dist/graph/models/path/path-attribute-model.cjs +4 -1
  116. package/dist/graph/models/path/path-attribute-model.d.ts +3 -1
  117. package/dist/graph/models/path/path-attribute-model.d.ts.map +1 -1
  118. package/dist/graph/models/path/path-attribute-model.js +6 -1
  119. package/dist/graph/models/path/path-attribute-model.js.map +1 -1
  120. package/dist/graph/models/path/path-storage-model.cjs +4 -1
  121. package/dist/graph/models/path/path-storage-model.d.ts +3 -1
  122. package/dist/graph/models/path/path-storage-model.d.ts.map +1 -1
  123. package/dist/graph/models/path/path-storage-model.js +6 -1
  124. package/dist/graph/models/path/path-storage-model.js.map +1 -1
  125. package/dist/graph/physics/index.cjs.map +2 -2
  126. package/dist/graph/physics/physics-controller.cjs +42 -0
  127. package/dist/graph/physics/physics-controller.d.ts +12 -1
  128. package/dist/graph/physics/physics-controller.d.ts.map +1 -1
  129. package/dist/graph/physics/physics-controller.js +41 -0
  130. package/dist/graph/physics/physics-controller.js.map +1 -1
  131. package/dist/graph/physics/scenegraph-instance.cjs +7 -0
  132. package/dist/graph/physics/scenegraph-instance.d.ts.map +1 -1
  133. package/dist/graph/physics/scenegraph-instance.js +8 -0
  134. package/dist/graph/physics/scenegraph-instance.js.map +1 -1
  135. package/dist/graph/tables/gpu-table-model.cjs +2 -2
  136. package/dist/graph/tables/gpu-table-model.d.ts +2 -1
  137. package/dist/graph/tables/gpu-table-model.d.ts.map +1 -1
  138. package/dist/graph/tables/gpu-table-model.js +2 -2
  139. package/dist/graph/tables/gpu-table-model.js.map +1 -1
  140. package/dist/graph/tables/index.cjs.map +1 -1
  141. package/dist/index.cjs +13 -0
  142. package/dist/index.cjs.map +3 -3
  143. package/dist/index.d.ts +5 -0
  144. package/dist/index.d.ts.map +1 -1
  145. package/dist/index.js +3 -0
  146. package/dist/index.js.map +1 -1
  147. package/dist/lighting/ambient-occlusion-pass.cjs +126 -0
  148. package/dist/lighting/ambient-occlusion-pass.d.ts +31 -0
  149. package/dist/lighting/ambient-occlusion-pass.d.ts.map +1 -0
  150. package/dist/lighting/ambient-occlusion-pass.js +108 -0
  151. package/dist/lighting/ambient-occlusion-pass.js.map +1 -0
  152. package/dist/lighting/clustered-light-grid.cjs +378 -0
  153. package/dist/lighting/clustered-light-grid.d.ts +94 -0
  154. package/dist/lighting/clustered-light-grid.d.ts.map +1 -0
  155. package/dist/lighting/clustered-light-grid.js +370 -0
  156. package/dist/lighting/clustered-light-grid.js.map +1 -0
  157. package/dist/lighting/contact-shadow-composite.cjs +80 -0
  158. package/dist/lighting/contact-shadow-composite.d.ts +6 -0
  159. package/dist/lighting/contact-shadow-composite.d.ts.map +1 -0
  160. package/dist/lighting/contact-shadow-composite.js +59 -0
  161. package/dist/lighting/contact-shadow-composite.js.map +1 -0
  162. package/dist/lighting/contact-shadow-pass.cjs +102 -0
  163. package/dist/lighting/contact-shadow-pass.d.ts +23 -0
  164. package/dist/lighting/contact-shadow-pass.d.ts.map +1 -0
  165. package/dist/lighting/contact-shadow-pass.js +85 -0
  166. package/dist/lighting/contact-shadow-pass.js.map +1 -0
  167. package/dist/lighting/index.cjs +128 -0
  168. package/dist/lighting/index.cjs.map +6 -0
  169. package/dist/lighting/index.d.ts +35 -0
  170. package/dist/lighting/index.d.ts.map +1 -0
  171. package/dist/lighting/index.js +22 -0
  172. package/dist/lighting/index.js.map +1 -0
  173. package/dist/lighting/lightmap-atlas.cjs +246 -0
  174. package/dist/lighting/lightmap-atlas.d.ts +53 -0
  175. package/dist/lighting/lightmap-atlas.d.ts.map +1 -0
  176. package/dist/lighting/lightmap-atlas.js +279 -0
  177. package/dist/lighting/lightmap-atlas.js.map +1 -0
  178. package/dist/lighting/lightmap-baker.cjs +238 -0
  179. package/dist/lighting/lightmap-baker.d.ts +62 -0
  180. package/dist/lighting/lightmap-baker.d.ts.map +1 -0
  181. package/dist/lighting/lightmap-baker.js +236 -0
  182. package/dist/lighting/lightmap-baker.js.map +1 -0
  183. package/dist/lighting/lightmap-data.cjs +117 -0
  184. package/dist/lighting/lightmap-data.d.ts +20 -0
  185. package/dist/lighting/lightmap-data.d.ts.map +1 -0
  186. package/dist/lighting/lightmap-data.js +110 -0
  187. package/dist/lighting/lightmap-data.js.map +1 -0
  188. package/dist/lighting/lightmap-environment.cjs +61 -0
  189. package/dist/lighting/lightmap-environment.d.ts +18 -0
  190. package/dist/lighting/lightmap-environment.d.ts.map +1 -0
  191. package/dist/lighting/lightmap-environment.js +46 -0
  192. package/dist/lighting/lightmap-environment.js.map +1 -0
  193. package/dist/lighting/pbr-environment.cjs +45 -0
  194. package/dist/lighting/pbr-environment.d.ts +25 -0
  195. package/dist/lighting/pbr-environment.d.ts.map +1 -0
  196. package/dist/lighting/pbr-environment.js +30 -0
  197. package/dist/lighting/pbr-environment.js.map +1 -0
  198. package/dist/lighting/pbr-material.cjs +75 -0
  199. package/dist/lighting/pbr-material.d.ts +33 -0
  200. package/dist/lighting/pbr-material.d.ts.map +1 -0
  201. package/dist/lighting/pbr-material.js +52 -0
  202. package/dist/lighting/pbr-material.js.map +1 -0
  203. package/dist/lighting/pbr-model.cjs +579 -0
  204. package/dist/lighting/pbr-model.d.ts +45 -0
  205. package/dist/lighting/pbr-model.d.ts.map +1 -0
  206. package/dist/lighting/pbr-model.js +545 -0
  207. package/dist/lighting/pbr-model.js.map +1 -0
  208. package/dist/lighting/pbr-surface-pass.cjs +116 -0
  209. package/dist/lighting/pbr-surface-pass.d.ts +35 -0
  210. package/dist/lighting/pbr-surface-pass.d.ts.map +1 -0
  211. package/dist/lighting/pbr-surface-pass.js +98 -0
  212. package/dist/lighting/pbr-surface-pass.js.map +1 -0
  213. package/dist/lighting/prefiltered-environment.cjs +275 -0
  214. package/dist/lighting/prefiltered-environment.d.ts +56 -0
  215. package/dist/lighting/prefiltered-environment.d.ts.map +1 -0
  216. package/dist/lighting/prefiltered-environment.js +264 -0
  217. package/dist/lighting/prefiltered-environment.js.map +1 -0
  218. package/dist/lighting/reflection-probe.cjs +321 -0
  219. package/dist/lighting/reflection-probe.d.ts +77 -0
  220. package/dist/lighting/reflection-probe.d.ts.map +1 -0
  221. package/dist/lighting/reflection-probe.js +298 -0
  222. package/dist/lighting/reflection-probe.js.map +1 -0
  223. package/dist/lighting/shadow-map-renderer.cjs +631 -0
  224. package/dist/lighting/shadow-map-renderer.d.ts +92 -0
  225. package/dist/lighting/shadow-map-renderer.d.ts.map +1 -0
  226. package/dist/lighting/shadow-map-renderer.js +622 -0
  227. package/dist/lighting/shadow-map-renderer.js.map +1 -0
  228. package/dist/lighting/shadow-quality.cjs +58 -0
  229. package/dist/lighting/shadow-quality.d.ts +13 -0
  230. package/dist/lighting/shadow-quality.d.ts.map +1 -0
  231. package/dist/lighting/shadow-quality.js +37 -0
  232. package/dist/lighting/shadow-quality.js.map +1 -0
  233. package/dist/material/material.cjs +3 -0
  234. package/dist/material/material.d.ts +2 -0
  235. package/dist/material/material.d.ts.map +1 -1
  236. package/dist/material/material.js +3 -0
  237. package/dist/material/material.js.map +1 -1
  238. package/dist/model/gpu-vector-model.cjs +20 -3
  239. package/dist/model/gpu-vector-model.d.ts +20 -2
  240. package/dist/model/gpu-vector-model.d.ts.map +1 -1
  241. package/dist/model/gpu-vector-model.js +21 -3
  242. package/dist/model/gpu-vector-model.js.map +1 -1
  243. package/dist/models/light-model-utils.cjs +2 -2
  244. package/dist/models/light-model-utils.d.ts +2 -1
  245. package/dist/models/light-model-utils.d.ts.map +1 -1
  246. package/dist/models/light-model-utils.js +2 -2
  247. package/dist/models/light-model-utils.js.map +1 -1
  248. package/dist/scenegraph/controllers/punctual-light-controller.cjs +121 -0
  249. package/dist/scenegraph/controllers/punctual-light-controller.d.ts +31 -0
  250. package/dist/scenegraph/controllers/punctual-light-controller.d.ts.map +1 -0
  251. package/dist/scenegraph/controllers/punctual-light-controller.js +117 -0
  252. package/dist/scenegraph/controllers/punctual-light-controller.js.map +1 -0
  253. package/dist/scenegraph/scene-metadata.cjs +43 -0
  254. package/dist/scenegraph/scene-metadata.d.ts +9 -0
  255. package/dist/scenegraph/scene-metadata.d.ts.map +1 -0
  256. package/dist/scenegraph/scene-metadata.js +21 -0
  257. package/dist/scenegraph/scene-metadata.js.map +1 -0
  258. package/dist/scenegraph/scenegraph-interaction.cjs +99 -0
  259. package/dist/scenegraph/scenegraph-interaction.d.ts +47 -0
  260. package/dist/scenegraph/scenegraph-interaction.d.ts.map +1 -0
  261. package/dist/scenegraph/scenegraph-interaction.js +79 -0
  262. package/dist/scenegraph/scenegraph-interaction.js.map +1 -0
  263. package/dist/scenegraph/scenegraph-node.cjs +10 -0
  264. package/dist/scenegraph/scenegraph-node.d.ts +10 -0
  265. package/dist/scenegraph/scenegraph-node.d.ts.map +1 -1
  266. package/dist/scenegraph/scenegraph-node.js +10 -0
  267. package/dist/scenegraph/scenegraph-node.js.map +1 -1
  268. package/dist/text/experimental.cjs.map +1 -1
  269. package/dist/text/fonts/atlas/text-utils.cjs +1 -1
  270. package/dist/text/fonts/atlas/text-utils.js +1 -1
  271. package/dist/text/fonts/atlas/text-utils.js.map +1 -1
  272. package/dist/text/fonts/index.cjs.map +1 -1
  273. package/dist/text/index.cjs +2 -0
  274. package/dist/text/index.cjs.map +2 -2
  275. package/dist/text/index.d.ts +1 -1
  276. package/dist/text/index.d.ts.map +1 -1
  277. package/dist/text/index.js +1 -1
  278. package/dist/text/index.js.map +1 -1
  279. package/dist/text/text-2d/index.cjs +3 -0
  280. package/dist/text/text-2d/index.d.ts +1 -0
  281. package/dist/text/text-2d/index.d.ts.map +1 -1
  282. package/dist/text/text-2d/index.js +1 -0
  283. package/dist/text/text-2d/index.js.map +1 -1
  284. package/dist/text/text-2d/model-utils/text-code-point-source.cjs +41 -0
  285. package/dist/text/text-2d/model-utils/text-code-point-source.d.ts +8 -0
  286. package/dist/text/text-2d/model-utils/text-code-point-source.d.ts.map +1 -0
  287. package/dist/text/text-2d/model-utils/text-code-point-source.js +23 -0
  288. package/dist/text/text-2d/model-utils/text-code-point-source.js.map +1 -0
  289. package/dist/text/text-2d/models/text-attribute-model.cjs +4 -1
  290. package/dist/text/text-2d/models/text-attribute-model.d.ts +3 -1
  291. package/dist/text/text-2d/models/text-attribute-model.d.ts.map +1 -1
  292. package/dist/text/text-2d/models/text-attribute-model.js +6 -1
  293. package/dist/text/text-2d/models/text-attribute-model.js.map +1 -1
  294. package/dist/text/text-2d/models/text-dictionary-model.cjs +4 -1
  295. package/dist/text/text-2d/models/text-dictionary-model.d.ts +3 -1
  296. package/dist/text/text-2d/models/text-dictionary-model.d.ts.map +1 -1
  297. package/dist/text/text-2d/models/text-dictionary-model.js +6 -1
  298. package/dist/text/text-2d/models/text-dictionary-model.js.map +1 -1
  299. package/dist/text/text-2d/models/text-storage-model.cjs +4 -1
  300. package/dist/text/text-2d/models/text-storage-model.d.ts +3 -1
  301. package/dist/text/text-2d/models/text-storage-model.d.ts.map +1 -1
  302. package/dist/text/text-2d/models/text-storage-model.js +6 -1
  303. package/dist/text/text-2d/models/text-storage-model.js.map +1 -1
  304. package/licenses/cesium.txt +207 -0
  305. package/licenses/deck-community.txt +19 -0
  306. package/licenses/deck.txt +19 -0
  307. package/licenses/glfx.txt +19 -0
  308. package/licenses/gltf-loader-ts.txt +21 -0
  309. package/licenses/magenta-font.txt +13 -0
  310. package/licenses/nvidia-fxaa.txt +25 -0
  311. package/licenses/philogl.txt +19 -0
  312. package/licenses/spark.txt +21 -0
  313. package/licenses/three.txt +21 -0
  314. package/package.json +17 -9
  315. package/src/animation/node-animation-binding.ts +18 -1
  316. package/src/arrow/renderers/splats/conversion/make-gpu-splat-data-from-gltf.ts +23 -19
  317. package/src/arrow/renderers/text/renderers/arrow-text-shaders.ts +1 -1
  318. package/src/compute/computation.ts +1 -1
  319. package/src/compute/swap.ts +2 -2
  320. package/src/dynamic-texture/video-texture.ts +9 -3
  321. package/src/effects/passes/postprocessing/fxaa/fxaa.ts +2 -1
  322. package/src/effects/passes/postprocessing/image-adjust-filters/brightnesscontrast.ts +2 -0
  323. package/src/effects/passes/postprocessing/image-adjust-filters/denoise.ts +2 -0
  324. package/src/effects/passes/postprocessing/image-adjust-filters/huesaturation.ts +2 -0
  325. package/src/effects/passes/postprocessing/image-adjust-filters/noise.ts +2 -0
  326. package/src/effects/passes/postprocessing/image-adjust-filters/sepia.ts +2 -0
  327. package/src/effects/passes/postprocessing/image-adjust-filters/vibrance.ts +2 -0
  328. package/src/effects/passes/postprocessing/image-adjust-filters/vignette.ts +2 -0
  329. package/src/gltf/gltf/animations/animations.ts +8 -1
  330. package/src/gltf/gltf/create-gltf-model.ts +4 -0
  331. package/src/gltf/gltf/create-scenegraph-from-gltf.ts +98 -17
  332. package/src/gltf/gltf/gltf-billboard.ts +6 -1
  333. package/src/gltf/gltf/gltf-extension-support.ts +2 -2
  334. package/src/gltf/index.ts +1 -0
  335. package/src/gltf/parsers/parse-gltf-animations.ts +22 -8
  336. package/src/gltf/parsers/parse-gltf-lights.ts +42 -130
  337. package/src/gltf/parsers/parse-gltf-metadata.ts +40 -0
  338. package/src/gltf/parsers/parse-gltf.ts +11 -2
  339. package/src/gltf/parsers/parse-pbr-material.ts +35 -7
  340. package/src/gltf/pbr/pbr-environment.ts +27 -1
  341. package/src/gltf/pbr/pbr-material.ts +8 -3
  342. package/src/gltf/types/gltf-json-schema.ts +1 -0
  343. package/src/gltf/types/gltf-postprocessed-schema.ts +1 -0
  344. package/src/graph/models/path/path-attribute-model.ts +10 -1
  345. package/src/graph/models/path/path-storage-model.ts +10 -1
  346. package/src/graph/physics/physics-controller.ts +55 -1
  347. package/src/graph/physics/scenegraph-instance.ts +10 -0
  348. package/src/graph/tables/gpu-table-model.ts +3 -2
  349. package/src/index.ts +17 -0
  350. package/src/lighting/ambient-occlusion-pass.ts +130 -0
  351. package/src/lighting/clustered-light-grid.ts +481 -0
  352. package/src/lighting/contact-shadow-composite.ts +67 -0
  353. package/src/lighting/contact-shadow-pass.ts +107 -0
  354. package/src/lighting/index.ts +125 -0
  355. package/src/lighting/lightmap-atlas.ts +348 -0
  356. package/src/lighting/lightmap-baker.ts +306 -0
  357. package/src/lighting/lightmap-data.ts +138 -0
  358. package/src/lighting/lightmap-environment.ts +70 -0
  359. package/src/lighting/pbr-environment.ts +55 -0
  360. package/src/lighting/pbr-material.ts +85 -0
  361. package/src/lighting/pbr-model.ts +608 -0
  362. package/src/lighting/pbr-surface-pass.ts +122 -0
  363. package/src/lighting/prefiltered-environment.ts +354 -0
  364. package/src/lighting/reflection-probe.ts +360 -0
  365. package/src/lighting/shadow-map-renderer.ts +918 -0
  366. package/src/lighting/shadow-quality.ts +50 -0
  367. package/src/material/material.ts +3 -0
  368. package/src/model/gpu-vector-model.ts +42 -4
  369. package/src/models/light-model-utils.ts +3 -2
  370. package/src/scenegraph/controllers/punctual-light-controller.ts +172 -0
  371. package/src/scenegraph/scene-metadata.ts +23 -0
  372. package/src/scenegraph/scenegraph-interaction.ts +131 -0
  373. package/src/scenegraph/scenegraph-node.ts +12 -0
  374. package/src/splats/README.md +1 -1
  375. package/src/text/fonts/atlas/text-utils.ts +1 -1
  376. package/src/text/index.ts +1 -0
  377. package/src/text/text-2d/index.ts +1 -0
  378. package/src/text/text-2d/model-utils/text-code-point-source.ts +34 -0
  379. package/src/text/text-2d/models/text-attribute-model.ts +10 -1
  380. package/src/text/text-2d/models/text-dictionary-model.ts +10 -1
  381. package/src/text/text-2d/models/text-storage-model.ts +10 -1
package/dist/dist.dev.js CHANGED
@@ -104,8 +104,11 @@ var __exports__ = (() => {
104
104
  PickingManager: () => PickingManager,
105
105
  PlaneGeometry: () => PlaneGeometry2,
106
106
  PointLightModel: () => PointLightModel,
107
+ PunctualLightController: () => PunctualLightController,
107
108
  RingGeometry: () => RingGeometry,
109
+ SceneMetadata: () => SceneMetadata,
108
110
  ScenegraphAnimator: () => ScenegraphAnimator,
111
+ ScenegraphInteractionManager: () => ScenegraphInteractionManager,
109
112
  ScenegraphNode: () => ScenegraphNode,
110
113
  ShaderInputs: () => ShaderInputs,
111
114
  ShaderPassRenderer: () => ShaderPassRenderer,
@@ -131,6 +134,7 @@ var __exports__ = (() => {
131
134
  decomposePhysicsTransform: () => decomposePhysicsTransform,
132
135
  deformPositions: () => deformPositions,
133
136
  evaluateAnimationSampler: () => evaluateAnimationSampler,
137
+ getFirstScenegraphInteractionHit: () => getFirstScenegraphInteractionHit,
134
138
  getGPUVectorModelBatches: () => getGPUVectorModelBatches,
135
139
  getIndexPickingModule: () => getIndexPickingModule,
136
140
  getPlatformInfo: () => getPlatformInfo,
@@ -138,6 +142,7 @@ var __exports__ = (() => {
138
142
  getTextureTransformMatrix: () => getTextureTransformMatrix,
139
143
  indexColorPicking: () => picking2,
140
144
  indexPicking: () => picking3,
145
+ isScenegraphInteractionEnabled: () => isScenegraphInteractionEnabled,
141
146
  legacyColorPicking: () => legacyColorPicking,
142
147
  loadImage: () => loadImage,
143
148
  loadImageBitmap: () => loadImageBitmap,
@@ -1698,18 +1703,6 @@ var __exports__ = (() => {
1698
1703
  }
1699
1704
 
1700
1705
  // ../../node_modules/@math.gl/core/dist/classes/matrix3.js
1701
- var INDICES;
1702
- (function(INDICES3) {
1703
- INDICES3[INDICES3["COL0ROW0"] = 0] = "COL0ROW0";
1704
- INDICES3[INDICES3["COL0ROW1"] = 1] = "COL0ROW1";
1705
- INDICES3[INDICES3["COL0ROW2"] = 2] = "COL0ROW2";
1706
- INDICES3[INDICES3["COL1ROW0"] = 3] = "COL1ROW0";
1707
- INDICES3[INDICES3["COL1ROW1"] = 4] = "COL1ROW1";
1708
- INDICES3[INDICES3["COL1ROW2"] = 5] = "COL1ROW2";
1709
- INDICES3[INDICES3["COL2ROW0"] = 6] = "COL2ROW0";
1710
- INDICES3[INDICES3["COL2ROW1"] = 7] = "COL2ROW1";
1711
- INDICES3[INDICES3["COL2ROW2"] = 8] = "COL2ROW2";
1712
- })(INDICES || (INDICES = {}));
1713
1706
  var IDENTITY_MATRIX = Object.freeze([1, 0, 0, 0, 1, 0, 0, 0, 1]);
1714
1707
  var Matrix3 = class extends Matrix {
1715
1708
  static get IDENTITY() {
@@ -1724,9 +1717,6 @@ var __exports__ = (() => {
1724
1717
  get RANK() {
1725
1718
  return 3;
1726
1719
  }
1727
- get INDICES() {
1728
- return INDICES;
1729
- }
1730
1720
  constructor(array) {
1731
1721
  super(-0, -0, -0, -0, -0, -0, -0, -0, -0);
1732
1722
  if (arguments.length === 1 && Array.isArray(array)) {
@@ -2502,6 +2492,35 @@ var __exports__ = (() => {
2502
2492
  out[15] = 1;
2503
2493
  return out;
2504
2494
  }
2495
+ function affineComponents(matrix) {
2496
+ if (matrix.length !== 16 || Array.from(matrix).some((x) => !Number.isFinite(x)) || matrix[3] !== 0 || matrix[7] !== 0 || matrix[11] !== 0 || matrix[15] !== 1) {
2497
+ throw new RangeError("Expected a finite affine matrix");
2498
+ }
2499
+ const scale5 = [
2500
+ Math.hypot(matrix[0], matrix[1], matrix[2]),
2501
+ Math.hypot(matrix[4], matrix[5], matrix[6]),
2502
+ Math.hypot(matrix[8], matrix[9], matrix[10])
2503
+ ];
2504
+ if (scale5.some((x) => x === 0 || !Number.isFinite(x)))
2505
+ throw new RangeError("Singular transform");
2506
+ const rotation = Array.from({ length: 9 }, (_, i) => matrix[Math.floor(i / 3) * 4 + i % 3] / scale5[Math.floor(i / 3)]);
2507
+ for (const [a, b] of [
2508
+ [0, 3],
2509
+ [0, 6],
2510
+ [3, 6]
2511
+ ]) {
2512
+ if (Math.abs(rotation[a] * rotation[b] + rotation[a + 1] * rotation[b + 1] + rotation[a + 2] * rotation[b + 2]) > 1e-7) {
2513
+ throw new RangeError("Sheared transforms do not have a TRS decomposition");
2514
+ }
2515
+ }
2516
+ const determinant3 = rotation[0] * (rotation[4] * rotation[8] - rotation[5] * rotation[7]) - rotation[3] * (rotation[1] * rotation[8] - rotation[2] * rotation[7]) + rotation[6] * (rotation[1] * rotation[5] - rotation[2] * rotation[4]);
2517
+ if (determinant3 < 0) {
2518
+ scale5[0] = -scale5[0];
2519
+ for (let i = 0; i < 3; i++)
2520
+ rotation[i] = -rotation[i];
2521
+ }
2522
+ return { rotation, scale: scale5, translation: [matrix[12], matrix[13], matrix[14]] };
2523
+ }
2505
2524
 
2506
2525
  // ../../node_modules/@math.gl/core/dist/gl-matrix/vec4.js
2507
2526
  function add(out, a, b) {
@@ -2574,25 +2593,6 @@ var __exports__ = (() => {
2574
2593
  }
2575
2594
 
2576
2595
  // ../../node_modules/@math.gl/core/dist/classes/matrix4.js
2577
- var INDICES2;
2578
- (function(INDICES3) {
2579
- INDICES3[INDICES3["COL0ROW0"] = 0] = "COL0ROW0";
2580
- INDICES3[INDICES3["COL0ROW1"] = 1] = "COL0ROW1";
2581
- INDICES3[INDICES3["COL0ROW2"] = 2] = "COL0ROW2";
2582
- INDICES3[INDICES3["COL0ROW3"] = 3] = "COL0ROW3";
2583
- INDICES3[INDICES3["COL1ROW0"] = 4] = "COL1ROW0";
2584
- INDICES3[INDICES3["COL1ROW1"] = 5] = "COL1ROW1";
2585
- INDICES3[INDICES3["COL1ROW2"] = 6] = "COL1ROW2";
2586
- INDICES3[INDICES3["COL1ROW3"] = 7] = "COL1ROW3";
2587
- INDICES3[INDICES3["COL2ROW0"] = 8] = "COL2ROW0";
2588
- INDICES3[INDICES3["COL2ROW1"] = 9] = "COL2ROW1";
2589
- INDICES3[INDICES3["COL2ROW2"] = 10] = "COL2ROW2";
2590
- INDICES3[INDICES3["COL2ROW3"] = 11] = "COL2ROW3";
2591
- INDICES3[INDICES3["COL3ROW0"] = 12] = "COL3ROW0";
2592
- INDICES3[INDICES3["COL3ROW1"] = 13] = "COL3ROW1";
2593
- INDICES3[INDICES3["COL3ROW2"] = 14] = "COL3ROW2";
2594
- INDICES3[INDICES3["COL3ROW3"] = 15] = "COL3ROW3";
2595
- })(INDICES2 || (INDICES2 = {}));
2596
2596
  var DEFAULT_FOVY = 45 * Math.PI / 180;
2597
2597
  var DEFAULT_ASPECT = 1;
2598
2598
  var DEFAULT_NEAR = 0.1;
@@ -2611,9 +2611,6 @@ var __exports__ = (() => {
2611
2611
  get RANK() {
2612
2612
  return 4;
2613
2613
  }
2614
- get INDICES() {
2615
- return INDICES2;
2616
- }
2617
2614
  constructor(array) {
2618
2615
  super(-0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0);
2619
2616
  if (arguments.length === 1 && Array.isArray(array)) {
@@ -2853,27 +2850,15 @@ var __exports__ = (() => {
2853
2850
  * @returns self
2854
2851
  */
2855
2852
  getRotation(result, scaleResult) {
2856
- result = result || [-0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0];
2857
- scaleResult = scaleResult || [-0, -0, -0];
2858
- const scale5 = this.getScale(scaleResult);
2859
- const inverseScale0 = 1 / scale5[0];
2860
- const inverseScale1 = 1 / scale5[1];
2861
- const inverseScale2 = 1 / scale5[2];
2862
- result[0] = this[0] * inverseScale0;
2863
- result[1] = this[1] * inverseScale1;
2864
- result[2] = this[2] * inverseScale2;
2865
- result[3] = 0;
2866
- result[4] = this[4] * inverseScale0;
2867
- result[5] = this[5] * inverseScale1;
2868
- result[6] = this[6] * inverseScale2;
2869
- result[7] = 0;
2870
- result[8] = this[8] * inverseScale0;
2871
- result[9] = this[9] * inverseScale1;
2872
- result[10] = this[10] * inverseScale2;
2873
- result[11] = 0;
2874
- result[12] = 0;
2875
- result[13] = 0;
2876
- result[14] = 0;
2853
+ const { rotation, scale: scale5 } = affineComponents(this);
2854
+ result = result || new Array(16);
2855
+ if (scaleResult)
2856
+ for (let i = 0; i < 3; i++)
2857
+ scaleResult[i] = scale5[i];
2858
+ for (let i = 0; i < 16; i++)
2859
+ result[i] = 0;
2860
+ for (let i = 0; i < 9; i++)
2861
+ result[Math.floor(i / 3) * 4 + i % 3] = rotation[i];
2877
2862
  result[15] = 1;
2878
2863
  return result;
2879
2864
  }
@@ -2884,21 +2869,13 @@ var __exports__ = (() => {
2884
2869
  * @returns self
2885
2870
  */
2886
2871
  getRotationMatrix3(result, scaleResult) {
2887
- result = result || [-0, -0, -0, -0, -0, -0, -0, -0, -0];
2888
- scaleResult = scaleResult || [-0, -0, -0];
2889
- const scale5 = this.getScale(scaleResult);
2890
- const inverseScale0 = 1 / scale5[0];
2891
- const inverseScale1 = 1 / scale5[1];
2892
- const inverseScale2 = 1 / scale5[2];
2893
- result[0] = this[0] * inverseScale0;
2894
- result[1] = this[1] * inverseScale1;
2895
- result[2] = this[2] * inverseScale2;
2896
- result[3] = this[4] * inverseScale0;
2897
- result[4] = this[5] * inverseScale1;
2898
- result[5] = this[6] * inverseScale2;
2899
- result[6] = this[8] * inverseScale0;
2900
- result[7] = this[9] * inverseScale1;
2901
- result[8] = this[10] * inverseScale2;
2872
+ const { rotation, scale: scale5 } = affineComponents(this);
2873
+ result = result || new Array(9);
2874
+ if (scaleResult)
2875
+ for (let i = 0; i < 3; i++)
2876
+ scaleResult[i] = scale5[i];
2877
+ for (let i = 0; i < 9; i++)
2878
+ result[i] = rotation[i];
2902
2879
  return result;
2903
2880
  }
2904
2881
  // Modifiers
@@ -3291,6 +3268,28 @@ var __exports__ = (() => {
3291
3268
  return normalize3(out, out);
3292
3269
  };
3293
3270
  })();
3271
+ function rotateTowards(out, a, b, step) {
3272
+ if (a.length !== 4 || b.length !== 4 || [...Array.from(a), ...Array.from(b), step].some((x) => !Number.isFinite(x))) {
3273
+ throw new RangeError("Expected finite quaternions and step");
3274
+ }
3275
+ if (a.length !== 4 || step < 0)
3276
+ throw new RangeError("Expected quaternions and a nonnegative step");
3277
+ const aScale = Math.max(...Array.from(a, Math.abs)), bScale = Math.max(...Array.from(b, Math.abs));
3278
+ if (!aScale || !bScale)
3279
+ throw new RangeError("Zero quaternion");
3280
+ const an = Array.from(a, (x) => x / aScale), bn = Array.from(b, (x) => x / bScale);
3281
+ const al = Math.hypot(...an), bl = Math.hypot(...bn);
3282
+ for (let i = 0; i < 4; i++) {
3283
+ an[i] /= al;
3284
+ bn[i] /= bl;
3285
+ }
3286
+ const dot4 = an.reduce((sum, x, i) => sum + x * bn[i], 0);
3287
+ const angle2 = 2 * Math.acos(Math.min(1, Math.abs(dot4)));
3288
+ if (out.length < 4)
3289
+ throw new RangeError("Result buffer is too short");
3290
+ slerp(out, an, bn, angle2 === 0 ? 0 : Math.min(1, step / angle2));
3291
+ return out;
3292
+ }
3294
3293
 
3295
3294
  // ../../node_modules/@math.gl/core/dist/classes/quaternion.js
3296
3295
  var Quaternion = class extends MathArray {
@@ -3363,6 +3362,9 @@ var __exports__ = (() => {
3363
3362
  return this.check();
3364
3363
  }
3365
3364
  /** Set a quat to the identity quaternion */
3365
+ rotateTowards(target, step) {
3366
+ return rotateTowards(this, this, target, step);
3367
+ }
3366
3368
  identity() {
3367
3369
  identity2(this);
3368
3370
  return this.check();
@@ -5846,7 +5848,7 @@ var __exports__ = (() => {
5846
5848
  /** Compilers registered by the application, isolated to this assembler. */
5847
5849
  _shaderTranspilers = /* @__PURE__ */ new Map();
5848
5850
  /** Hook functions */
5849
- _hookFunctions = [];
5851
+ _injectionTargets = [];
5850
5852
  /** Shader modules */
5851
5853
  _defaultModules = [];
5852
5854
  /** Register or replace the compiler for one input language. */
@@ -5916,18 +5918,18 @@ var __exports__ = (() => {
5916
5918
  this._defaultModules = this._defaultModules.filter((m) => m.name !== moduleName);
5917
5919
  }
5918
5920
  /**
5919
- * Register a shader hook
5920
- * @param hook Shared stage and name with language-specific parameters, return type, and source.
5921
+ * Register a shader injection target
5922
+ * @param injectionTarget Shared stage and name with language-specific parameters, return type, and source.
5921
5923
  */
5922
- addShaderHook(hook) {
5923
- this._hookFunctions.push(hook);
5924
+ addShaderInjectionTarget(injectionTarget) {
5925
+ this._injectionTargets.push(injectionTarget);
5924
5926
  }
5925
5927
  /**
5926
- * Remove all registered shader hooks, for example before re-registering hooks for a new
5928
+ * Remove all registered shader injection targets, for example before re-registering targets for a new
5927
5929
  * application configuration. Default modules are not affected.
5928
5930
  */
5929
- resetShaderHooks() {
5930
- this._hookFunctions.length = 0;
5931
+ resetShaderInjectionTargets() {
5932
+ this._injectionTargets.length = 0;
5931
5933
  }
5932
5934
  /**
5933
5935
  * Dedupe and combine with default modules
@@ -6008,7 +6010,9 @@ var __exports__ = (() => {
6008
6010
  }
6009
6011
  const target = `${declaration.stage === "vertex" ? "vs" : "fs"}:${declaration.target}`;
6010
6012
  if (!/^(vs|fs):(?:#(?:decl|main-start|main-end)|[A-Za-z_][A-Za-z0-9_]*)$/.test(target)) {
6011
- throw new Error(`Shader injection target "${target}" must be a named shader anchor or hook`);
6013
+ throw new Error(
6014
+ `Shader injection target "${target}" must be a named shader injection target`
6015
+ );
6012
6016
  }
6013
6017
  resolved[target] ||= [];
6014
6018
  resolved[target].push({
@@ -6355,13 +6359,13 @@ ${DECLARATION_INJECT_MARKER}
6355
6359
  return uniforms;
6356
6360
  };
6357
6361
  }
6358
- function appendInjections(injections, hookInjections, declInjections, mainInjections) {
6362
+ function appendInjections(injections, targetInjections, declInjections, mainInjections) {
6359
6363
  for (const key in injections) {
6360
6364
  const match = /^(v|f)s:(#)?([\w-]+)$/.exec(key);
6361
6365
  if (match) {
6362
6366
  const hash = match[2];
6363
6367
  const name = match[3];
6364
- const injectionType = hash ? name === "decl" ? declInjections : mainInjections : hookInjections;
6368
+ const injectionType = hash ? name === "decl" ? declInjections : mainInjections : targetInjections;
6365
6369
  injectionType[key] = injectionType[key] || [];
6366
6370
  injectionType[key].push(...injections[key]);
6367
6371
  } else {
@@ -6402,53 +6406,53 @@ ${DECLARATION_INJECT_MARKER}
6402
6406
  return source4;
6403
6407
  }
6404
6408
 
6405
- // ../shaders/src/lib/shader-assembly/shader-hooks.ts
6406
- function getShaderHooks(hookFunctions, hookInjections, shaderLanguage = "glsl") {
6409
+ // ../shaders/src/lib/shader-assembly/shader-injection-targets.ts
6410
+ function getShaderInjectionTargets(injectionTargets, targetInjections, shaderLanguage = "glsl") {
6407
6411
  let result = "";
6408
- for (const hookName in hookFunctions) {
6409
- const hookFunction = hookFunctions[hookName];
6410
- const returnType = hookFunction.returnType || "void";
6412
+ for (const targetName in injectionTargets) {
6413
+ const targetFunction = injectionTargets[targetName];
6414
+ const returnType = targetFunction.returnType || "void";
6411
6415
  const functionPrefix = shaderLanguage === "wgsl" ? "fn" : returnType;
6412
6416
  const returnSuffix = shaderLanguage === "wgsl" && returnType !== "void" ? ` -> ${returnType}` : "";
6413
- result += `${functionPrefix} ${hookFunction.signature}${returnSuffix} {
6417
+ result += `${functionPrefix} ${targetFunction.signature}${returnSuffix} {
6414
6418
  `;
6415
- if (hookFunction.header) {
6416
- result += ` ${hookFunction.header}`;
6419
+ if (targetFunction.header) {
6420
+ result += ` ${targetFunction.header}`;
6417
6421
  }
6418
- if (hookInjections[hookName]) {
6419
- const injections = hookInjections[hookName];
6422
+ if (targetInjections[targetName]) {
6423
+ const injections = targetInjections[targetName];
6420
6424
  injections.sort((a, b) => a.order - b.order);
6421
6425
  for (const injection of injections) {
6422
6426
  result += ` ${injection.injection}
6423
6427
  `;
6424
6428
  }
6425
6429
  }
6426
- if (hookFunction.footer) {
6427
- result += ` ${hookFunction.footer}`;
6430
+ if (targetFunction.footer) {
6431
+ result += ` ${targetFunction.footer}`;
6428
6432
  }
6429
6433
  result += "}\n";
6430
6434
  }
6431
6435
  return result;
6432
6436
  }
6433
- function normalizeShaderHooks(hookFunctions, pluginHooks = [], language = "glsl") {
6437
+ function normalizeShaderInjectionTargets(injectionTargets, pluginInjectionTargets = [], language = "glsl") {
6434
6438
  const result = { vertex: {}, fragment: {} };
6435
- for (const hook of hookFunctions) {
6436
- const implementation = hook[language];
6439
+ for (const injectionTarget of injectionTargets) {
6440
+ const implementation = injectionTarget[language];
6437
6441
  if (implementation) {
6438
- const prefix = hook.stage === "vertex" ? "vs" : "fs";
6439
- result[hook.stage][`${prefix}:${hook.name}`] = {
6442
+ const prefix = injectionTarget.stage === "vertex" ? "vs" : "fs";
6443
+ result[injectionTarget.stage][`${prefix}:${injectionTarget.name}`] = {
6440
6444
  ...implementation,
6441
- signature: `${hook.name}(${implementation.parameters})`
6445
+ signature: `${injectionTarget.name}(${implementation.parameters})`
6442
6446
  };
6443
6447
  }
6444
6448
  }
6445
- for (const hook of pluginHooks) {
6446
- const selected = normalizeShaderHooks([hook], [], language);
6449
+ for (const injectionTarget of pluginInjectionTargets) {
6450
+ const selected = normalizeShaderInjectionTargets([injectionTarget], [], language);
6447
6451
  for (const stage of ["vertex", "fragment"]) {
6448
6452
  for (const [name, declaration] of Object.entries(selected[stage])) {
6449
6453
  const existing = result[stage][name];
6450
6454
  if (existing && (existing.signature !== declaration.signature || (existing.returnType || "void") !== (declaration.returnType || "void"))) {
6451
- throw new Error(`Conflicting ShaderPlugin hook ${name}`);
6455
+ throw new Error(`Conflicting ShaderPlugin injection target ${name}`);
6452
6456
  }
6453
6457
  result[stage][name] = existing || declaration;
6454
6458
  }
@@ -6456,22 +6460,24 @@ ${DECLARATION_INJECT_MARKER}
6456
6460
  }
6457
6461
  return result;
6458
6462
  }
6459
- function isShaderHookRegistered(registry, hookName) {
6460
- const stageRegistry = hookName.startsWith("vs:") ? registry.vertex : registry.fragment;
6461
- return Boolean(stageRegistry[hookName]);
6463
+ function isShaderInjectionTargetRegistered(registry, targetName) {
6464
+ const stageRegistry = targetName.startsWith("vs:") ? registry.vertex : registry.fragment;
6465
+ return Boolean(stageRegistry[targetName]);
6462
6466
  }
6463
- function validateShaderHookInjections(registry, hookInjections, stage) {
6467
+ function validateShaderInjectionTargetInjections(registry, targetInjections, stage) {
6464
6468
  const stagePrefix = stage === "vertex" ? "vs:" : stage === "fragment" ? "fs:" : null;
6465
- for (const hookName in hookInjections) {
6466
- if (stagePrefix && !hookName.startsWith(stagePrefix)) {
6469
+ for (const targetName in targetInjections) {
6470
+ if (stagePrefix && !targetName.startsWith(stagePrefix)) {
6467
6471
  continue;
6468
6472
  }
6469
- if (!isShaderHookRegistered(registry, hookName)) {
6473
+ if (!isShaderInjectionTargetRegistered(registry, targetName)) {
6470
6474
  const pluginNames = [
6471
- ...new Set(hookInjections[hookName].map((injection) => injection.pluginName).filter(Boolean))
6475
+ ...new Set(
6476
+ targetInjections[targetName].map((injection) => injection.pluginName).filter(Boolean)
6477
+ )
6472
6478
  ];
6473
6479
  throw new Error(
6474
- `Unknown shader hook ${hookName}${pluginNames.length ? ` (plugins: ${pluginNames.join(", ")})` : ""}`
6480
+ `Unknown shader injection target ${targetName}${pluginNames.length ? ` (plugins: ${pluginNames.join(", ")})` : ""}`
6475
6481
  );
6476
6482
  }
6477
6483
  }
@@ -6569,8 +6575,13 @@ ${DECLARATION_INJECT_MARKER}
6569
6575
  }
6570
6576
  return decoded;
6571
6577
  }
6578
+ var attributeShaderTypeInfoCache = /* @__PURE__ */ new Map();
6572
6579
  function getAttributeShaderTypeInfo(attributeType) {
6573
6580
  const resolvedAttributeType = resolveAttributeShaderTypeAlias(attributeType);
6581
+ const cached = attributeShaderTypeInfoCache.get(resolvedAttributeType);
6582
+ if (cached) {
6583
+ return cached;
6584
+ }
6574
6585
  const decoded = TYPE_INFO[resolvedAttributeType];
6575
6586
  if (!decoded) {
6576
6587
  throw new Error(`Unsupported attribute shader type: ${attributeType}`);
@@ -6579,13 +6590,15 @@ ${DECLARATION_INJECT_MARKER}
6579
6590
  const integer = primitiveType === "i32" || primitiveType === "u32";
6580
6591
  const signed = primitiveType !== "u32";
6581
6592
  const byteLength = PRIMITIVE_TYPE_SIZES[primitiveType] * components2;
6582
- return {
6593
+ const result = Object.freeze({
6583
6594
  primitiveType,
6584
6595
  components: components2,
6585
6596
  byteLength,
6586
6597
  integer,
6587
6598
  signed
6588
- };
6599
+ });
6600
+ attributeShaderTypeInfoCache.set(resolvedAttributeType, result);
6601
+ return result;
6589
6602
  }
6590
6603
  var ShaderTypeDecoder = class {
6591
6604
  getVariableShaderTypeInfo(format) {
@@ -6694,6 +6707,9 @@ ${DECLARATION_INJECT_MARKER}
6694
6707
  "mat4x3<u32>": { type: "u32", components: 12 },
6695
6708
  "mat4x4<u32>": { type: "u32", components: 16 }
6696
6709
  };
6710
+ for (const info of Object.values(UNIFORM_FORMATS)) {
6711
+ Object.freeze(info);
6712
+ }
6697
6713
  var WGSL_ATTRIBUTE_TYPE_ALIAS_MAP = {
6698
6714
  vec2i: "vec2<i32>",
6699
6715
  vec3i: "vec3<i32>",
@@ -7687,7 +7703,7 @@ return ${outputName};
7687
7703
  language = "glsl",
7688
7704
  modules,
7689
7705
  defines = {},
7690
- hookFunctions = [],
7706
+ injectionTargets = [],
7691
7707
  inject = {},
7692
7708
  pluginInjections = {},
7693
7709
  pluginVertexInputs = {},
@@ -7727,13 +7743,17 @@ ${getApplicationDefines(allDefines)}
7727
7743
  `;
7728
7744
  break;
7729
7745
  }
7730
- const hookFunctionMap = normalizeShaderHooks(hookFunctions, options.pluginHooks, "glsl");
7731
- const hookInjections = {};
7746
+ const injectionTargetMap = normalizeShaderInjectionTargets(
7747
+ injectionTargets,
7748
+ options.pluginInjectionTargets,
7749
+ "glsl"
7750
+ );
7751
+ const targetInjections = {};
7732
7752
  const declInjections = {};
7733
7753
  const mainInjections = {};
7734
- appendInjections(pluginInjections, hookInjections, declInjections, mainInjections);
7754
+ appendInjections(pluginInjections, targetInjections, declInjections, mainInjections);
7735
7755
  const applicationInjections = Array.isArray(inject) ? resolveShaderInjections(inject, "glsl") : {};
7736
- appendInjections(applicationInjections, hookInjections, declInjections, mainInjections);
7756
+ appendInjections(applicationInjections, targetInjections, declInjections, mainInjections);
7737
7757
  const injectionMap = Array.isArray(inject) ? {} : inject;
7738
7758
  for (const key in injectionMap) {
7739
7759
  const injection = typeof injectionMap[key] === "string" ? { injection: injectionMap[key], order: 0 } : injectionMap[key];
@@ -7748,7 +7768,7 @@ ${getApplicationDefines(allDefines)}
7748
7768
  mainInjections[key] = [...mainInjections[key] || [], injection];
7749
7769
  }
7750
7770
  } else {
7751
- hookInjections[key] = [...hookInjections[key] || [], injection];
7771
+ targetInjections[key] = [...targetInjections[key] || [], injection];
7752
7772
  }
7753
7773
  } else {
7754
7774
  mainInjections[key] = [...mainInjections[key] || [], injection];
@@ -7782,11 +7802,11 @@ ${getApplicationDefines(allDefines)}
7782
7802
  const moduleSource = getShaderModuleSource(module, stage, log8);
7783
7803
  assembledSource += moduleSource;
7784
7804
  }
7785
- validateShaderHookInjections(hookFunctionMap, hookInjections, stage);
7805
+ validateShaderInjectionTargetInjections(injectionTargetMap, targetInjections, stage);
7786
7806
  assembledSource += "// ----- MAIN SHADER SOURCE -------------------------";
7787
7807
  assembledSource += INJECT_SHADER_DECLARATIONS;
7788
7808
  assembledSource = injectShader(assembledSource, stage, declInjections);
7789
- assembledSource += getShaderHooks(hookFunctionMap[stage], hookInjections);
7809
+ assembledSource += getShaderInjectionTargets(injectionTargetMap[stage], targetInjections);
7790
7810
  assembledSource += coreSource;
7791
7811
  assembledSource = injectShader(assembledSource, stage, mainInjections);
7792
7812
  if (language === "glsl" && sourceVersion !== targetVersion) {
@@ -7819,7 +7839,7 @@ ${getApplicationDefines(allDefines)}
7819
7839
  */
7820
7840
  assembleGLSLShaderPair(props) {
7821
7841
  const modules = this._getModuleList(props.modules);
7822
- const hookFunctions = [...this._hookFunctions, ...props.hookFunctions || []];
7842
+ const injectionTargets = [...this._injectionTargets, ...props.injectionTargets || []];
7823
7843
  const vertex = this._transpileShader(props, modules, props.vs, "vertex");
7824
7844
  const fragment = this._transpileShader(props, modules, props.fs, "fragment");
7825
7845
  const assembled = assembleGLSLShaderPair({
@@ -7827,7 +7847,7 @@ ${getApplicationDefines(allDefines)}
7827
7847
  vs: vertex.code,
7828
7848
  fs: props.fs == null ? void 0 : fragment.code,
7829
7849
  modules: vertex.modules,
7830
- hookFunctions
7850
+ injectionTargets
7831
7851
  });
7832
7852
  return { ...assembled, modules };
7833
7853
  }
@@ -8491,6 +8511,141 @@ ${getApplicationDefines(allDefines)}
8491
8511
  return match?.[1];
8492
8512
  }
8493
8513
 
8514
+ // ../shaders/src/lib/shader-assembly/wgsl-injection-target-names.ts
8515
+ function getWGSLInjectionTargetNames(targets, source4 = "") {
8516
+ const names = /* @__PURE__ */ new Map();
8517
+ const declarations = Object.values(targets).flatMap(
8518
+ (stage) => Object.entries(stage).map(
8519
+ ([key, target]) => `${key.slice(3)}
8520
+ ${target.signature}
8521
+ ${target.header || ""}
8522
+ ${target.footer || ""}`
8523
+ )
8524
+ );
8525
+ const usedNames = new Set(
8526
+ maskWGSLComments(`${source4}
8527
+ ${declarations.join("\n")}`).match(
8528
+ /[_\p{XID_Start}][\p{XID_Continue}]*/gu
8529
+ )
8530
+ );
8531
+ for (const key of Object.keys(targets.vertex)) {
8532
+ const name = key.slice(3);
8533
+ if (targets.fragment[`fs:${name}`]) {
8534
+ names.set(name, {
8535
+ vertex: allocateName(`_luma_vertex_target_${name}`, usedNames),
8536
+ fragment: allocateName(`_luma_fragment_target_${name}`, usedNames)
8537
+ });
8538
+ }
8539
+ }
8540
+ return names;
8541
+ }
8542
+ function resolveWGSLInjectionTargetNames(source4, targets, targetNames = getWGSLInjectionTargetNames(targets)) {
8543
+ if (!targetNames.size) return source4;
8544
+ const masked = maskWGSLComments(source4);
8545
+ const functions = /* @__PURE__ */ new Map();
8546
+ const pattern = /((?:@\w+(?:\([^)]*\))?\s*)*)\bfn\s+([_\p{XID_Start}][\p{XID_Continue}]*)\s*\(/gu;
8547
+ for (let match = pattern.exec(masked); match; match = pattern.exec(masked)) {
8548
+ const bodyStart = masked.indexOf("{", pattern.lastIndex);
8549
+ let end = bodyStart + 1;
8550
+ let depth = 1;
8551
+ for (; end < masked.length && depth; end++) {
8552
+ if (masked[end] === "{") depth++;
8553
+ if (masked[end] === "}") depth--;
8554
+ }
8555
+ assert2(bodyStart >= 0 && depth === 0);
8556
+ const name = match[2];
8557
+ const nameStart = match.index + match[0].lastIndexOf(name);
8558
+ const calls = Array.from(
8559
+ masked.slice(bodyStart + 1, end - 1).matchAll(/([_\p{XID_Start}][\p{XID_Continue}]*)\s*\(/gu),
8560
+ (call) => call[1]
8561
+ );
8562
+ functions.set(name, {
8563
+ name,
8564
+ start: match.index,
8565
+ end,
8566
+ nameStart,
8567
+ bodyStart,
8568
+ calls,
8569
+ stages: /* @__PURE__ */ new Set(),
8570
+ entryStage: /@vertex\b/.test(match[1]) ? "vertex" : /@fragment\b/.test(match[1]) ? "fragment" : void 0
8571
+ });
8572
+ pattern.lastIndex = end;
8573
+ }
8574
+ function visit(name, stage) {
8575
+ const shaderFunction = functions.get(name);
8576
+ if (!shaderFunction || shaderFunction.stages.has(stage)) return;
8577
+ shaderFunction.stages.add(stage);
8578
+ for (const call of shaderFunction.calls) {
8579
+ visit(targetNames.get(call)?.[stage] || call, stage);
8580
+ }
8581
+ }
8582
+ for (const shaderFunction of functions.values()) {
8583
+ if (shaderFunction.entryStage) visit(shaderFunction.name, shaderFunction.entryStage);
8584
+ }
8585
+ for (const stage of ["vertex", "fragment"]) {
8586
+ for (const key of Object.keys(targets[stage])) {
8587
+ const name = key.slice(3);
8588
+ visit(targetNames.get(name)?.[stage] || name, stage);
8589
+ }
8590
+ }
8591
+ const affected = /* @__PURE__ */ new Set();
8592
+ let changed = true;
8593
+ while (changed) {
8594
+ changed = false;
8595
+ for (const shaderFunction of functions.values()) {
8596
+ if (!affected.has(shaderFunction.name) && shaderFunction.calls.some((call) => targetNames.has(call) || affected.has(call))) {
8597
+ affected.add(shaderFunction.name);
8598
+ changed = true;
8599
+ }
8600
+ }
8601
+ }
8602
+ const helperNames = /* @__PURE__ */ new Map();
8603
+ const usedNames = new Set(masked.match(/[_\p{XID_Start}][\p{XID_Continue}]*/gu));
8604
+ for (const name of affected) {
8605
+ if (functions.get(name)?.stages.size === 2) {
8606
+ helperNames.set(name, {
8607
+ vertex: allocateName(`_luma_vertex_helper_${name}`, usedNames),
8608
+ fragment: allocateName(`_luma_fragment_helper_${name}`, usedNames)
8609
+ });
8610
+ }
8611
+ }
8612
+ function getCallName(name, stage) {
8613
+ const targetName = targetNames.get(name)?.[stage];
8614
+ if (targetName) return targetName;
8615
+ return helperNames.get(name)?.[stage] || name;
8616
+ }
8617
+ for (const shaderFunction of [...functions.values()].reverse()) {
8618
+ if (!affected.has(shaderFunction.name)) continue;
8619
+ if (!shaderFunction.stages.size) {
8620
+ throw new Error(`Cannot infer WGSL target stage in ${shaderFunction.name}`);
8621
+ }
8622
+ const variants = [];
8623
+ const start = shaderFunction.start;
8624
+ for (const stage of shaderFunction.stages) {
8625
+ let text = source4.slice(start, shaderFunction.end);
8626
+ const body = masked.slice(shaderFunction.bodyStart + 1, shaderFunction.end - 1);
8627
+ const calls = [...body.matchAll(/([_\p{XID_Start}][\p{XID_Continue}]*)\s*\(/gu)];
8628
+ for (const call of calls.reverse()) {
8629
+ const offset2 = shaderFunction.bodyStart + 1 + call.index - start;
8630
+ const replacement = getCallName(call[1], stage);
8631
+ text = text.slice(0, offset2) + replacement + text.slice(offset2 + call[1].length);
8632
+ }
8633
+ const offset = shaderFunction.nameStart - start;
8634
+ text = text.slice(0, offset) + getCallName(shaderFunction.name, stage) + text.slice(offset + shaderFunction.name.length);
8635
+ variants.push(text);
8636
+ }
8637
+ source4 = source4.slice(0, start) + variants.join("\n") + source4.slice(shaderFunction.end);
8638
+ }
8639
+ return source4;
8640
+ }
8641
+ function allocateName(baseName, usedNames) {
8642
+ let name = baseName;
8643
+ let suffix = 0;
8644
+ while (usedNames.has(name)) name = `${baseName}_${++suffix}`;
8645
+ usedNames.add(name);
8646
+ return name;
8647
+ }
8648
+
8494
8649
  // ../shaders/src/lib/preprocessor/preprocessor.ts
8495
8650
  var DEFINE_NAME_PATTERN = "([a-zA-Z_][a-zA-Z0-9_]*)";
8496
8651
  var IF_REGEXP = /^\s*\#\s*if\s+(.+?)\s*(?:\/\/.*)?$/;
@@ -8629,7 +8784,7 @@ ${getApplicationDefines(allDefines)}
8629
8784
  modules,
8630
8785
  // defines = {},
8631
8786
  defines = {},
8632
- hookFunctions = [],
8787
+ injectionTargets = [],
8633
8788
  inject = {},
8634
8789
  pluginInjections = {},
8635
8790
  pluginVertexInputs = {},
@@ -8653,13 +8808,17 @@ ${getApplicationDefines(allDefines)}
8653
8808
  );
8654
8809
  const coreSource = pluginVaryingAssembly.source;
8655
8810
  let assembledSource = "";
8656
- const hookFunctionMap = normalizeShaderHooks(hookFunctions, options.pluginHooks, "wgsl");
8657
- const hookInjections = {};
8811
+ const injectionTargetMap = normalizeShaderInjectionTargets(
8812
+ injectionTargets,
8813
+ options.pluginInjectionTargets,
8814
+ "wgsl"
8815
+ );
8816
+ const targetInjections = {};
8658
8817
  const declInjections = {};
8659
8818
  const mainInjections = {};
8660
- appendInjections(pluginInjections, hookInjections, declInjections, mainInjections);
8819
+ appendInjections(pluginInjections, targetInjections, declInjections, mainInjections);
8661
8820
  const applicationInjections = Array.isArray(inject) ? resolveShaderInjections(inject, "wgsl") : {};
8662
- appendInjections(applicationInjections, hookInjections, declInjections, mainInjections);
8821
+ appendInjections(applicationInjections, targetInjections, declInjections, mainInjections);
8663
8822
  const injectionMap = Array.isArray(inject) ? {} : inject;
8664
8823
  for (const key in injectionMap) {
8665
8824
  const injection = typeof injectionMap[key] === "string" ? { injection: injectionMap[key], order: 0 } : injectionMap[key];
@@ -8674,7 +8833,7 @@ ${getApplicationDefines(allDefines)}
8674
8833
  mainInjections[key] = [...mainInjections[key] || [], injection];
8675
8834
  }
8676
8835
  } else {
8677
- hookInjections[key] = [...hookInjections[key] || [], injection];
8836
+ targetInjections[key] = [...targetInjections[key] || [], injection];
8678
8837
  }
8679
8838
  } else {
8680
8839
  mainInjections[key] = [...mainInjections[key] || [], injection];
@@ -8687,7 +8846,7 @@ ${getApplicationDefines(allDefines)}
8687
8846
  mainInjections
8688
8847
  );
8689
8848
  appendGeneratedVaryingInjections(pluginVaryingAssembly, declInjections, mainInjections);
8690
- validateShaderHookInjections(hookFunctionMap, hookInjections);
8849
+ validateShaderInjectionTargetInjections(injectionTargetMap, targetInjections);
8691
8850
  const modulesToInject = modules.map((module) => ({
8692
8851
  module,
8693
8852
  source: preprocess(getShaderModuleSource(module, "wgsl", log8), { defines })
@@ -8726,13 +8885,31 @@ ${getApplicationDefines(allDefines)}
8726
8885
  "wgsl",
8727
8886
  { vertex: vertexEntryPoint, fragment: fragmentEntryPoint }
8728
8887
  );
8729
- assembledSource += getWGSLShaderHooks(hookFunctionMap, hookInjections);
8888
+ const targetNames = getWGSLInjectionTargetNames(
8889
+ injectionTargetMap,
8890
+ [
8891
+ assembledSource,
8892
+ applicationRelocation.source,
8893
+ ...Object.values(targetInjections).flat().map((injection) => injection.injection),
8894
+ ...Object.values(mainInjections).flat().map((injection) => injection.injection)
8895
+ ].join("\n")
8896
+ );
8897
+ assembledSource += getWGSLShaderInjectionTargets(
8898
+ injectionTargetMap,
8899
+ targetInjections,
8900
+ targetNames
8901
+ );
8730
8902
  assembledSource += formatWGSLBindingAssignmentComments(bindingAssignments);
8731
8903
  assembledSource += applicationRelocation.source;
8732
8904
  assembledSource = injectShader(assembledSource, stage, mainInjections, false, "wgsl", {
8733
8905
  vertex: vertexEntryPoint,
8734
8906
  fragment: fragmentEntryPoint
8735
8907
  });
8908
+ assembledSource = resolveWGSLInjectionTargetNames(
8909
+ assembledSource,
8910
+ injectionTargetMap,
8911
+ targetNames
8912
+ );
8736
8913
  assertNoUnresolvedAutoBindings(assembledSource);
8737
8914
  return { source: assembledSource, bindingAssignments };
8738
8915
  }
@@ -8782,8 +8959,17 @@ ${getApplicationDefines(allDefines)}
8782
8959
  ];
8783
8960
  return unifiedDeclarations.length ? { "vs:#decl": unifiedDeclarations } : {};
8784
8961
  }
8785
- function getWGSLShaderHooks(hookFunctionMap, hookInjections) {
8786
- return getShaderHooks(hookFunctionMap.vertex, hookInjections, "wgsl") + getShaderHooks(hookFunctionMap.fragment, hookInjections, "wgsl");
8962
+ function getWGSLShaderInjectionTargets(injectionTargetMap, targetInjections, names = getWGSLInjectionTargetNames(injectionTargetMap)) {
8963
+ return ["vertex", "fragment"].map((stage) => {
8964
+ const targets = Object.fromEntries(
8965
+ Object.entries(injectionTargetMap[stage]).map(([key, target]) => {
8966
+ const name = key.slice(3);
8967
+ const emittedName = names.get(name)?.[stage] || name;
8968
+ return [key, { ...target, signature: emittedName + target.signature.slice(name.length) }];
8969
+ })
8970
+ );
8971
+ return getShaderInjectionTargets(targets, targetInjections, "wgsl");
8972
+ }).join("");
8787
8973
  }
8788
8974
  function getUsedBindingsByGroupFromApplicationWGSL(source4) {
8789
8975
  const usedBindingsByGroup = /* @__PURE__ */ new Map();
@@ -9105,7 +9291,7 @@ ${getApplicationDefines(allDefines)}
9105
9291
  */
9106
9292
  assembleWGSLShader(props) {
9107
9293
  const modules = this._getModuleList(props.modules);
9108
- const hookFunctions = [...this._hookFunctions, ...props.hookFunctions || []];
9294
+ const injectionTargets = [...this._injectionTargets, ...props.injectionTargets || []];
9109
9295
  const translated = this._transpileShader(
9110
9296
  props,
9111
9297
  modules,
@@ -9131,7 +9317,7 @@ ${getApplicationDefines(allDefines)}
9131
9317
  defines,
9132
9318
  _bindingRegistry: this._wgslBindingRegistry,
9133
9319
  modules: translated.modules,
9134
- hookFunctions
9320
+ injectionTargets
9135
9321
  });
9136
9322
  const preprocessedSource = props.platformInfo.shaderLanguage === "wgsl" ? preprocess(assembledSource, { defines }) : assembledSource;
9137
9323
  return {
@@ -10801,7 +10987,148 @@ ${getApplicationDefines(allDefines)}
10801
10987
  return `${id}-${count}`;
10802
10988
  }
10803
10989
 
10990
+ // ../core/src/api/utils/assert.ts
10991
+ function assert8(condition, message) {
10992
+ if (!condition) {
10993
+ const error = new Error(message ?? "luma.gl assertion failed.");
10994
+ Error.captureStackTrace?.(error, assert8);
10995
+ throw error;
10996
+ }
10997
+ }
10998
+
10804
10999
  // ../core/src/api/adapter/resources/resource.ts
11000
+ var Resource = class {
11001
+ _owner = null;
11002
+ _ownedResources = /* @__PURE__ */ new Set();
11003
+ _state = "live";
11004
+ _destroyingOwnedResources = false;
11005
+ _destroyRequested = false;
11006
+ /** The resource responsible for destroying this resource, or null for caller-managed lifetime. */
11007
+ get owner() {
11008
+ return this._owner;
11009
+ }
11010
+ /** A snapshot of this resource's children. Mutating the snapshot cannot change ownership. */
11011
+ get ownedResources() {
11012
+ return Array.from(this._ownedResources);
11013
+ }
11014
+ /** Whether destruction has completed, including when cleanup reported an error. */
11015
+ get destroyed() {
11016
+ return this._state === "destroyed";
11017
+ }
11018
+ /** Transfer exclusive ownership, or return lifetime responsibility to the caller with null. */
11019
+ transferOwnershipTo(owner) {
11020
+ assert8(this._state === "live" && !this._destroyingOwnedResources);
11021
+ assert8(!this._owner || this._owner.canChangeOwnership());
11022
+ assert8(!owner || owner.canChangeOwnership());
11023
+ for (let ancestor = owner; ancestor; ancestor = ancestor._owner) {
11024
+ assert8(ancestor !== this);
11025
+ }
11026
+ if (owner !== this._owner) {
11027
+ this._owner?._ownedResources.delete(this);
11028
+ this._owner = owner;
11029
+ owner?._ownedResources.add(this);
11030
+ }
11031
+ return this;
11032
+ }
11033
+ /** Destroy children before this resource. Subclasses implement hooks instead of overriding. */
11034
+ destroy() {
11035
+ if (this._state !== "live") {
11036
+ return;
11037
+ }
11038
+ if (this._destroyingOwnedResources) {
11039
+ this._destroyRequested = true;
11040
+ return;
11041
+ }
11042
+ this._destroyRequested = false;
11043
+ this._state = "destroying";
11044
+ this._owner?._ownedResources.delete(this);
11045
+ this._owner = null;
11046
+ const errors = [];
11047
+ try {
11048
+ try {
11049
+ this.onBeforeDestroy();
11050
+ } catch (error) {
11051
+ errors.push(error);
11052
+ }
11053
+ this.destroyChildren(errors);
11054
+ try {
11055
+ this.onDestroy();
11056
+ } catch (error) {
11057
+ errors.push(error);
11058
+ }
11059
+ } finally {
11060
+ this._state = "destroyed";
11061
+ }
11062
+ if (errors.length) {
11063
+ throw new AggregateError(errors, "Resource cleanup failed");
11064
+ }
11065
+ }
11066
+ /** @deprecated Use destroy(). */
11067
+ delete() {
11068
+ this.destroy();
11069
+ return this;
11070
+ }
11071
+ /** @deprecated Use resource.transferOwnershipTo(this). */
11072
+ attachResource(resource) {
11073
+ resource.transferOwnershipTo(this);
11074
+ }
11075
+ /** @deprecated Use resource.transferOwnershipTo(null). Only detaches a child owned by this. */
11076
+ detachResource(resource) {
11077
+ if (resource._owner === this) {
11078
+ resource.transferOwnershipTo(null);
11079
+ }
11080
+ }
11081
+ /** @deprecated Check resource.owner and call resource.destroy(). */
11082
+ destroyAttachedResource(resource) {
11083
+ if (resource._owner === this) {
11084
+ resource.destroy();
11085
+ }
11086
+ }
11087
+ /** @deprecated Destroy individually owned resources, or destroy the owner. */
11088
+ destroyAttachedResources() {
11089
+ if (this._state !== "live" || this._destroyingOwnedResources) {
11090
+ return;
11091
+ }
11092
+ const errors = [];
11093
+ this.destroyChildren(errors);
11094
+ if (this._destroyRequested) {
11095
+ try {
11096
+ this.destroy();
11097
+ } catch (error) {
11098
+ errors.push(error);
11099
+ }
11100
+ }
11101
+ if (errors.length) {
11102
+ throw new AggregateError(errors, "Resource cleanup failed");
11103
+ }
11104
+ }
11105
+ /** Stop activity before children are destroyed. Errors are collected; this hook cannot veto cleanup. */
11106
+ onBeforeDestroy() {
11107
+ }
11108
+ /** Release this resource's own state after its children have been destroyed. */
11109
+ onDestroy() {
11110
+ }
11111
+ canChangeOwnership() {
11112
+ return this._state === "live" && !this._destroyingOwnedResources;
11113
+ }
11114
+ destroyChildren(errors) {
11115
+ this._destroyingOwnedResources = true;
11116
+ try {
11117
+ for (const resource of this._ownedResources) {
11118
+ try {
11119
+ resource.destroy();
11120
+ } catch (error) {
11121
+ errors.push(error);
11122
+ }
11123
+ }
11124
+ } finally {
11125
+ this._ownedResources.clear();
11126
+ this._destroyingOwnedResources = false;
11127
+ }
11128
+ }
11129
+ };
11130
+
11131
+ // ../core/src/api/adapter/resources/device-resource.ts
10805
11132
  var CPU_HOTSPOT_PROFILER_MODULE = "cpu-hotspot-profiler";
10806
11133
  var RESOURCE_COUNTS_STATS = "GPU Resource Counts";
10807
11134
  var LEGACY_RESOURCE_COUNTS_STATS = "Resource Counts";
@@ -10857,7 +11184,7 @@ ${getApplicationDefines(allDefines)}
10857
11184
  ]);
10858
11185
  var ORDERED_STATS_CACHE = /* @__PURE__ */ new WeakMap();
10859
11186
  var ORDERED_STAT_NAME_SET_CACHE = /* @__PURE__ */ new WeakMap();
10860
- var Resource = class {
11187
+ var DeviceResource = class extends Resource {
10861
11188
  /** Default properties for resource */
10862
11189
  static defaultProps = {
10863
11190
  id: "undefined",
@@ -10880,14 +11207,10 @@ ${getApplicationDefines(allDefines)}
10880
11207
  userData = {};
10881
11208
  /** The device that this resource is associated with - TODO can we remove this dup? */
10882
11209
  _device;
10883
- /** Whether this resource has been destroyed */
10884
- destroyed = false;
10885
11210
  /** For resources that allocate GPU memory */
10886
11211
  allocatedBytes = 0;
10887
11212
  /** Stats bucket currently holding the tracked allocation */
10888
11213
  allocatedBytesName = null;
10889
- /** Attached resources will be destroyed when this resource is destroyed. Tracks auto-created "sub" resources. */
10890
- _attachedResources = /* @__PURE__ */ new Set();
10891
11214
  /** Whether luma.gl created and owns the underlying resource handle. */
10892
11215
  get ownsHandle() {
10893
11216
  return (this.props.handle === void 0 || this.props.handle === null) && !this.isHandleBorrowed;
@@ -10897,9 +11220,10 @@ ${getApplicationDefines(allDefines)}
10897
11220
  return Boolean(this.props._isHandleBorrowed);
10898
11221
  }
10899
11222
  /**
10900
- * Create a new Resource. Called from Subclass
11223
+ * Create a new DeviceResource. Called from Subclass
10901
11224
  */
10902
11225
  constructor(device, props, defaultProps) {
11226
+ super();
10903
11227
  if (!device) {
10904
11228
  throw new Error("no device");
10905
11229
  }
@@ -10911,20 +11235,6 @@ ${getApplicationDefines(allDefines)}
10911
11235
  this.userData = this.props.userData || {};
10912
11236
  this.addStats();
10913
11237
  }
10914
- /**
10915
- * destroy can be called on any resource to release it before it is garbage collected.
10916
- */
10917
- destroy() {
10918
- if (this.destroyed) {
10919
- return;
10920
- }
10921
- this.destroyResource();
10922
- }
10923
- /** @deprecated Use destroy() */
10924
- delete() {
10925
- this.destroy();
10926
- return this;
10927
- }
10928
11238
  /**
10929
11239
  * Combines a map of user props and default props, only including props from defaultProps
10930
11240
  * @returns returns a map of overridden default props
@@ -10932,46 +11242,19 @@ ${getApplicationDefines(allDefines)}
10932
11242
  getProps() {
10933
11243
  return this.props;
10934
11244
  }
10935
- // ATTACHED RESOURCES
10936
- /**
10937
- * Attaches a resource. Attached resources are auto destroyed when this resource is destroyed
10938
- * Called automatically when sub resources are auto created but can be called by application
10939
- */
10940
- attachResource(resource) {
10941
- this._attachedResources.add(resource);
10942
- }
10943
- /**
10944
- * Detach an attached resource. The resource will no longer be auto-destroyed when this resource is destroyed.
10945
- */
10946
- detachResource(resource) {
10947
- this._attachedResources.delete(resource);
10948
- }
10949
- /**
10950
- * Destroys a resource (only if owned), and removes from the owned (auto-destroy) list for this resource.
10951
- */
10952
- destroyAttachedResource(resource) {
10953
- if (this._attachedResources.delete(resource)) {
10954
- resource.destroy();
10955
- }
10956
- }
10957
- /** Destroy all owned resources. Make sure the resources are no longer needed before calling. */
10958
- destroyAttachedResources() {
10959
- for (const resource of this._attachedResources) {
10960
- resource.destroy();
10961
- }
10962
- this._attachedResources = /* @__PURE__ */ new Set();
11245
+ /** Backend cleanup. Override this instead of destroy(); children are already destroyed. */
11246
+ destroyHandle() {
10963
11247
  }
10964
- // PROTECTED METHODS
10965
- /** Perform all destroy steps. Can be called by derived resources when overriding destroy() */
10966
- destroyResource() {
10967
- if (this.destroyed) {
10968
- return;
11248
+ /** Complete device bookkeeping even when backend cleanup fails. */
11249
+ onDestroy() {
11250
+ try {
11251
+ this.destroyHandle();
11252
+ } finally {
11253
+ this.trackDeallocatedMemory();
11254
+ this.removeStats();
10969
11255
  }
10970
- this.destroyAttachedResources();
10971
- this.removeStats();
10972
- this.destroyed = true;
10973
11256
  }
10974
- /** Called by .destroy() to track object destruction. Subclass must call if overriding destroy() */
11257
+ /** Track object destruction after backend cleanup. */
10975
11258
  removeStats() {
10976
11259
  const profiler = getCpuHotspotProfiler(this._device);
10977
11260
  const startTime = profiler ? getTimestamp() : 0;
@@ -11149,7 +11432,7 @@ ${getApplicationDefines(allDefines)}
11149
11432
  let prototype = Object.getPrototypeOf(resource);
11150
11433
  while (prototype) {
11151
11434
  const parentPrototype = Object.getPrototypeOf(prototype);
11152
- if (!parentPrototype || parentPrototype === Resource.prototype) {
11435
+ if (!parentPrototype || parentPrototype === DeviceResource.prototype) {
11153
11436
  return getPrototypeToStringTag(prototype) || resource[Symbol.toStringTag] || resource.constructor.name;
11154
11437
  }
11155
11438
  prototype = parentPrototype;
@@ -11168,7 +11451,7 @@ ${getApplicationDefines(allDefines)}
11168
11451
  }
11169
11452
 
11170
11453
  // ../core/src/api/adapter/resources/buffer.ts
11171
- var Buffer4 = class _Buffer extends Resource {
11454
+ var Buffer4 = class _Buffer extends DeviceResource {
11172
11455
  /** Index buffer */
11173
11456
  static INDEX = 16;
11174
11457
  /** Vertex buffer */
@@ -11249,7 +11532,7 @@ ${getApplicationDefines(allDefines)}
11249
11532
  }
11250
11533
  }
11251
11534
  static defaultProps = {
11252
- ...Resource.defaultProps,
11535
+ ...DeviceResource.defaultProps,
11253
11536
  handle: void 0,
11254
11537
  usage: 0,
11255
11538
  // Buffer.COPY_DST | Buffer.COPY_SRC
@@ -11271,7 +11554,19 @@ ${getApplicationDefines(allDefines)}
11271
11554
  }
11272
11555
 
11273
11556
  // ../core/src/shadertypes/data-types/decode-data-types.ts
11557
+ var dataTypeInfoCache = /* @__PURE__ */ new Map();
11274
11558
  function getDataTypeInfo(type) {
11559
+ const cached = dataTypeInfoCache.get(type);
11560
+ if (cached) {
11561
+ return cached;
11562
+ }
11563
+ const decoded = Object.freeze(decodeDataTypeInfo(type));
11564
+ if (Object.hasOwn(NORMALIZED_TYPE_MAP, type)) {
11565
+ dataTypeInfoCache.set(type, decoded);
11566
+ }
11567
+ return decoded;
11568
+ }
11569
+ function decodeDataTypeInfo(type) {
11275
11570
  const normalized2 = type.includes("norm");
11276
11571
  const integer = !normalized2 && !type.startsWith("float");
11277
11572
  const signed = type.startsWith("s");
@@ -11612,40 +11907,33 @@ ${getApplicationDefines(allDefines)}
11612
11907
  return this.isCompressed(format) && !format.endsWith("-webgl") ? WEBGPU_CREATE_FILTER2 : 0;
11613
11908
  }
11614
11909
  /** Computes the memory layout for a texture, in particular including row byte alignment */
11615
- computeMemoryLayout(opts) {
11616
- return computeTextureMemoryLayout(opts);
11910
+ computeMemoryLayout(opts, result) {
11911
+ return computeTextureMemoryLayout(opts, result);
11617
11912
  }
11618
11913
  };
11619
11914
  var textureFormatDecoder = new TextureFormatDecoder();
11620
- function computeTextureMemoryLayout({
11621
- format,
11622
- width,
11623
- height,
11624
- depth,
11625
- byteAlignment
11626
- }) {
11915
+ function computeTextureMemoryLayout({ format, width, height, depth, byteAlignment }, result = {}) {
11627
11916
  const formatInfo = textureFormatDecoder.getInfo(format);
11917
+ const { bytesPerPixel, blockHeight = 1, compressed = false } = formatInfo;
11918
+ const bytesPerRow = getTextureBytesPerRow(formatInfo, width, byteAlignment);
11919
+ const rowsPerImage = compressed ? Math.ceil(height / blockHeight) : height;
11920
+ result.bytesPerPixel = bytesPerPixel;
11921
+ result.bytesPerRow = bytesPerRow;
11922
+ result.rowsPerImage = rowsPerImage;
11923
+ result.depthOrArrayLayers = depth;
11924
+ result.bytesPerImage = bytesPerRow * rowsPerImage;
11925
+ result.byteLength = result.bytesPerImage * depth;
11926
+ return result;
11927
+ }
11928
+ function getTextureBytesPerRow(formatInfo, width, byteAlignment) {
11628
11929
  const {
11629
11930
  bytesPerPixel,
11630
11931
  bytesPerBlock = bytesPerPixel,
11631
11932
  blockWidth = 1,
11632
- blockHeight = 1,
11633
11933
  compressed = false
11634
11934
  } = formatInfo;
11635
11935
  const blockColumns = compressed ? Math.ceil(width / blockWidth) : width;
11636
- const blockRows = compressed ? Math.ceil(height / blockHeight) : height;
11637
- const unpaddedBytesPerRow = blockColumns * bytesPerBlock;
11638
- const bytesPerRow = Math.ceil(unpaddedBytesPerRow / byteAlignment) * byteAlignment;
11639
- const rowsPerImage = blockRows;
11640
- const byteLength = bytesPerRow * rowsPerImage * depth;
11641
- return {
11642
- bytesPerPixel,
11643
- bytesPerRow,
11644
- rowsPerImage,
11645
- depthOrArrayLayers: depth,
11646
- bytesPerImage: bytesPerRow * rowsPerImage,
11647
- byteLength
11648
- };
11936
+ return Math.ceil(blockColumns * bytesPerBlock / byteAlignment) * byteAlignment;
11649
11937
  }
11650
11938
  function getTextureFormatCapabilities(format) {
11651
11939
  const info = getTextureFormatDefinition(format);
@@ -11667,7 +11955,18 @@ ${getApplicationDefines(allDefines)}
11667
11955
  formatCapabilities.filter &&= !isDepthStencil && !isSigned && !isInteger && !isWebGLSpecific;
11668
11956
  return formatCapabilities;
11669
11957
  }
11958
+ var textureFormatInfoCache = /* @__PURE__ */ new Map();
11670
11959
  function getTextureFormatInfo(format) {
11960
+ let formatInfo = textureFormatInfoCache.get(format);
11961
+ if (!formatInfo) {
11962
+ const decoded = decodeTextureFormatInfo(format);
11963
+ decoded.bitsPerChannel = Object.freeze([...decoded.bitsPerChannel]);
11964
+ formatInfo = Object.freeze(decoded);
11965
+ textureFormatInfoCache.set(format, formatInfo);
11966
+ }
11967
+ return formatInfo;
11968
+ }
11969
+ function decodeTextureFormatInfo(format) {
11671
11970
  let formatInfo = getTextureFormatInfoUsingTable(format);
11672
11971
  if (textureFormatDecoder.isCompressed(format)) {
11673
11972
  formatInfo.channels = "rgb";
@@ -11807,9 +12106,9 @@ ${getApplicationDefines(allDefines)}
11807
12106
  }
11808
12107
 
11809
12108
  // ../core/src/api/adapter/resources/sampler.ts
11810
- var Sampler = class _Sampler extends Resource {
12109
+ var Sampler = class _Sampler extends DeviceResource {
11811
12110
  static defaultProps = {
11812
- ...Resource.defaultProps,
12111
+ ...DeviceResource.defaultProps,
11813
12112
  type: "color-sampler",
11814
12113
  addressModeU: "clamp-to-edge",
11815
12114
  addressModeV: "clamp-to-edge",
@@ -11834,8 +12133,24 @@ ${getApplicationDefines(allDefines)}
11834
12133
  return props;
11835
12134
  }
11836
12135
  };
12136
+ function setTextureSampler(texture, sampler) {
12137
+ const nextSampler = sampler instanceof Sampler ? sampler : texture.device.createSampler(sampler);
12138
+ if (nextSampler === texture.sampler) {
12139
+ return;
12140
+ }
12141
+ if (!(sampler instanceof Sampler)) {
12142
+ nextSampler.transferOwnershipTo(texture);
12143
+ }
12144
+ const previousSampler = texture.sampler;
12145
+ texture.sampler = nextSampler;
12146
+ if (previousSampler?.owner === texture) {
12147
+ previousSampler.destroy();
12148
+ }
12149
+ }
11837
12150
 
11838
12151
  // ../core/src/api/adapter/resources/texture.ts
12152
+ var textureLayoutScratchPool = [];
12153
+ var emptyTextureReadOptions = Object.freeze({});
11839
12154
  var BASE_DIMENSIONS = {
11840
12155
  "1d": "1d",
11841
12156
  "2d": "2d",
@@ -11844,7 +12159,7 @@ ${getApplicationDefines(allDefines)}
11844
12159
  "cube-array": "2d",
11845
12160
  "3d": "3d"
11846
12161
  };
11847
- var Texture = class _Texture extends Resource {
12162
+ var Texture = class _Texture extends DeviceResource {
11848
12163
  /** The texture can be bound for use as a sampled texture in a shader */
11849
12164
  static SAMPLE = 4;
11850
12165
  /** The texture can be bound for use as a storage texture in a shader */
@@ -11932,7 +12247,7 @@ ${getApplicationDefines(allDefines)}
11932
12247
  }
11933
12248
  /** Set sampler props associated with this texture */
11934
12249
  setSampler(sampler) {
11935
- this.sampler = sampler instanceof Sampler ? sampler : this.device.createSampler(sampler);
12250
+ setTextureSampler(this, sampler);
11936
12251
  }
11937
12252
  /**
11938
12253
  * Copy raw image data (bytes) into the texture.
@@ -11954,17 +12269,24 @@ ${getApplicationDefines(allDefines)}
11954
12269
  * Calculates the memory layout of the texture, required when reading and writing data.
11955
12270
  * @return the backend-aligned linear layout, in particular bytesPerRow which includes any required padding for buffer copy/read paths
11956
12271
  */
11957
- computeMemoryLayout(options_ = {}) {
11958
- const options = this._normalizeTextureReadOptions(options_);
11959
- const { width = this.width, height = this.height, depthOrArrayLayers = this.depth } = options;
11960
- const { format, byteAlignment } = this;
11961
- return textureFormatDecoder.computeMemoryLayout({
11962
- format,
11963
- width,
11964
- height,
11965
- depth: depthOrArrayLayers,
11966
- byteAlignment
11967
- });
12272
+ /** The optional result is caller-owned; internal scratch never escapes this call. */
12273
+ computeMemoryLayout(options_ = emptyTextureReadOptions, result) {
12274
+ const scratch = textureLayoutScratchPool.pop() || {
12275
+ readOptions: {},
12276
+ layoutOptions: {}
12277
+ };
12278
+ try {
12279
+ const options = this._normalizeTextureReadOptions(options_, scratch.readOptions);
12280
+ const layoutOptions = scratch.layoutOptions;
12281
+ layoutOptions.format = this.format;
12282
+ layoutOptions.width = options.width;
12283
+ layoutOptions.height = options.height;
12284
+ layoutOptions.depth = options.depthOrArrayLayers;
12285
+ layoutOptions.byteAlignment = this.byteAlignment;
12286
+ return textureFormatDecoder.computeMemoryLayout(layoutOptions, result);
12287
+ } finally {
12288
+ textureLayoutScratchPool.push(scratch);
12289
+ }
11968
12290
  }
11969
12291
  /**
11970
12292
  * Read the contents of a texture into a GPU Buffer.
@@ -12073,59 +12395,57 @@ ${getApplicationDefines(allDefines)}
12073
12395
  });
12074
12396
  }
12075
12397
  }
12076
- _normalizeCopyImageDataOptions(options_) {
12077
- const { data, depth, ...writeOptions } = options_;
12078
- const options = this._normalizeTextureWriteOptions({
12079
- ...writeOptions,
12080
- depthOrArrayLayers: writeOptions.depthOrArrayLayers ?? depth
12081
- });
12082
- return { data, depth: options.depthOrArrayLayers, ...options };
12398
+ /** The optional result is caller-owned scratch storage; every result field is overwritten. */
12399
+ _normalizeCopyImageDataOptions(options_, result = {}) {
12400
+ const { data, depth, depthOrArrayLayers } = options_;
12401
+ this._normalizeTextureWriteOptions(options_, result);
12402
+ if (depthOrArrayLayers === void 0 && depth !== void 0) {
12403
+ const mipDepth = this.dimension === "3d" ? Math.max(1, this.depth >> result.mipLevel) : this.depth;
12404
+ result.depthOrArrayLayers = Math.min(depth, mipDepth - result.z);
12405
+ }
12406
+ result.data = data;
12407
+ result.depth = result.depthOrArrayLayers;
12408
+ return result;
12083
12409
  }
12084
- _normalizeCopyExternalImageOptions(options_) {
12085
- const optionsWithoutUndefined = _Texture._omitUndefined(options_);
12086
- const mipLevel = optionsWithoutUndefined.mipLevel ?? 0;
12087
- const mipLevelSize = this._getMipLevelSize(mipLevel);
12410
+ _normalizeCopyExternalImageOptions(options_, result = {}) {
12411
+ const { width, height } = options_;
12088
12412
  const size = this.device.getExternalImageSize(options_.image);
12089
- const options = {
12090
- ..._Texture.defaultCopyExternalImageOptions,
12091
- ...mipLevelSize,
12092
- ...size,
12093
- ...optionsWithoutUndefined
12094
- };
12095
- options.width = Math.min(options.width, mipLevelSize.width - options.x);
12096
- options.height = Math.min(options.height, mipLevelSize.height - options.y);
12097
- options.depth = Math.min(options.depth, mipLevelSize.depthOrArrayLayers - options.z);
12413
+ const options = _Texture._normalizeOptions(
12414
+ options_,
12415
+ _Texture.defaultCopyExternalImageOptions,
12416
+ result
12417
+ );
12418
+ const mipWidth = Math.max(1, this.width >> options.mipLevel);
12419
+ const mipHeight = this.baseDimension === "1d" ? 1 : Math.max(1, this.height >> options.mipLevel);
12420
+ const mipDepth = this.dimension === "3d" ? Math.max(1, this.depth >> options.mipLevel) : this.depth;
12421
+ options.width = Math.min(width ?? size.width, mipWidth - options.x);
12422
+ options.height = Math.min(height ?? size.height, mipHeight - options.y);
12423
+ options.depth = Math.min(options.depth, mipDepth - options.z);
12098
12424
  return options;
12099
12425
  }
12100
- _normalizeCopyElementImageOptions(options_) {
12101
- const optionsWithoutUndefined = _Texture._omitUndefined(options_);
12102
- const mipLevel = optionsWithoutUndefined.mipLevel ?? 0;
12103
- const mipLevelSize = this._getMipLevelSize(mipLevel);
12104
- const options = {
12105
- ..._Texture.defaultCopyElementImageOptions,
12106
- ...mipLevelSize,
12107
- ...optionsWithoutUndefined
12108
- };
12109
- options.width = Math.min(options.width, mipLevelSize.width - options.x);
12110
- options.height = Math.min(options.height, mipLevelSize.height - options.y);
12111
- options.depth = Math.min(options.depth, mipLevelSize.depthOrArrayLayers - options.z);
12426
+ _normalizeCopyElementImageOptions(options_, result = {}) {
12427
+ const options = _Texture._normalizeOptions(
12428
+ options_,
12429
+ _Texture.defaultCopyElementImageOptions,
12430
+ result
12431
+ );
12432
+ const mipWidth = Math.max(1, this.width >> options.mipLevel);
12433
+ const mipHeight = this.baseDimension === "1d" ? 1 : Math.max(1, this.height >> options.mipLevel);
12434
+ const mipDepth = this.dimension === "3d" ? Math.max(1, this.depth >> options.mipLevel) : this.depth;
12435
+ options.width = Math.min(options.width ?? mipWidth, mipWidth - options.x);
12436
+ options.height = Math.min(options.height ?? mipHeight, mipHeight - options.y);
12437
+ options.depth = Math.min(options.depth, mipDepth - options.z);
12112
12438
  return options;
12113
12439
  }
12114
- _normalizeTextureReadOptions(options_) {
12115
- const optionsWithoutUndefined = _Texture._omitUndefined(options_);
12116
- const mipLevel = optionsWithoutUndefined.mipLevel ?? 0;
12117
- const mipLevelSize = this._getMipLevelSize(mipLevel);
12118
- const options = {
12119
- ..._Texture.defaultTextureReadOptions,
12120
- ...mipLevelSize,
12121
- ...optionsWithoutUndefined
12122
- };
12123
- options.width = Math.min(options.width, mipLevelSize.width - options.x);
12124
- options.height = Math.min(options.height, mipLevelSize.height - options.y);
12125
- options.depthOrArrayLayers = Math.min(
12126
- options.depthOrArrayLayers,
12127
- mipLevelSize.depthOrArrayLayers - options.z
12128
- );
12440
+ _normalizeTextureReadOptions(options_, result = {}) {
12441
+ const { depthOrArrayLayers } = options_;
12442
+ const options = _Texture._normalizeOptions(options_, _Texture.defaultTextureReadOptions, result);
12443
+ const mipWidth = Math.max(1, this.width >> options.mipLevel);
12444
+ const mipHeight = this.baseDimension === "1d" ? 1 : Math.max(1, this.height >> options.mipLevel);
12445
+ const mipDepth = this.dimension === "3d" ? Math.max(1, this.depth >> options.mipLevel) : this.depth;
12446
+ options.width = Math.min(options.width ?? mipWidth, mipWidth - options.x);
12447
+ options.height = Math.min(options.height ?? mipHeight, mipHeight - options.y);
12448
+ options.depthOrArrayLayers = Math.min(depthOrArrayLayers ?? mipDepth, mipDepth - options.z);
12129
12449
  return options;
12130
12450
  }
12131
12451
  /**
@@ -12180,31 +12500,15 @@ ${getApplicationDefines(allDefines)}
12180
12500
  throw new Error(`${this} color readback does not support format ${this.format}`);
12181
12501
  }
12182
12502
  }
12183
- _normalizeTextureWriteOptions(options_) {
12184
- const optionsWithoutUndefined = _Texture._omitUndefined(options_);
12185
- const mipLevel = optionsWithoutUndefined.mipLevel ?? 0;
12186
- const mipLevelSize = this._getMipLevelSize(mipLevel);
12187
- const options = {
12188
- ..._Texture.defaultTextureWriteOptions,
12189
- ...mipLevelSize,
12190
- ...optionsWithoutUndefined
12191
- };
12192
- options.width = Math.min(options.width, mipLevelSize.width - options.x);
12193
- options.height = Math.min(options.height, mipLevelSize.height - options.y);
12194
- options.depthOrArrayLayers = Math.min(
12195
- options.depthOrArrayLayers,
12196
- mipLevelSize.depthOrArrayLayers - options.z
12197
- );
12198
- const layout = textureFormatDecoder.computeMemoryLayout({
12199
- format: this.format,
12200
- width: options.width,
12201
- height: options.height,
12202
- depth: options.depthOrArrayLayers,
12203
- byteAlignment: this.byteAlignment
12204
- });
12205
- const minimumBytesPerRow = layout.bytesPerPixel * options.width;
12206
- options.bytesPerRow = optionsWithoutUndefined.bytesPerRow ?? layout.bytesPerRow;
12207
- options.rowsPerImage = optionsWithoutUndefined.rowsPerImage ?? options.height;
12503
+ _normalizeTextureWriteOptions(options_, result = {}) {
12504
+ const { byteOffset = 0, bytesPerRow, rowsPerImage } = options_;
12505
+ this._normalizeTextureReadOptions(options_, result);
12506
+ const options = result;
12507
+ options.byteOffset = byteOffset;
12508
+ const formatInfo = this.device.getTextureFormatInfo(this.format);
12509
+ const minimumBytesPerRow = formatInfo.bytesPerPixel * options.width;
12510
+ options.bytesPerRow = bytesPerRow ?? getTextureBytesPerRow(formatInfo, options.width, this.byteAlignment);
12511
+ options.rowsPerImage = rowsPerImage ?? options.height;
12208
12512
  if (options.bytesPerRow < minimumBytesPerRow) {
12209
12513
  throw new Error(
12210
12514
  `bytesPerRow (${options.bytesPerRow}) must be at least ${minimumBytesPerRow} for ${this.format}`
@@ -12215,7 +12519,7 @@ ${getApplicationDefines(allDefines)}
12215
12519
  `rowsPerImage (${options.rowsPerImage}) must be at least ${options.height} for ${this.format}`
12216
12520
  );
12217
12521
  }
12218
- const bytesPerPixel = this.device.getTextureFormatInfo(this.format).bytesPerPixel;
12522
+ const { bytesPerPixel } = formatInfo;
12219
12523
  if (bytesPerPixel && options.bytesPerRow % bytesPerPixel !== 0) {
12220
12524
  throw new Error(
12221
12525
  `bytesPerRow (${options.bytesPerRow}) must be a multiple of bytesPerPixel (${bytesPerPixel}) for ${this.format}`
@@ -12243,13 +12547,15 @@ ${getApplicationDefines(allDefines)}
12243
12547
  }
12244
12548
  return allocatedByteLength * this.samples;
12245
12549
  }
12246
- static _omitUndefined(options) {
12247
- return Object.fromEntries(
12248
- Object.entries(options).filter(([, value]) => value !== void 0)
12249
- );
12550
+ /** Fill every declared field, resetting stale scratch values without allocating entries or spreads. */
12551
+ static _normalizeOptions(options, defaults, result) {
12552
+ for (const key in defaults) {
12553
+ result[key] = options[key] === void 0 ? defaults[key] : options[key];
12554
+ }
12555
+ return result;
12250
12556
  }
12251
12557
  static defaultProps = {
12252
- ...Resource.defaultProps,
12558
+ ...DeviceResource.defaultProps,
12253
12559
  data: null,
12254
12560
  dimension: "2d",
12255
12561
  format: "rgba8unorm",
@@ -12323,19 +12629,6 @@ ${getApplicationDefines(allDefines)}
12323
12629
  mipLevel: 0,
12324
12630
  aspect: "all"
12325
12631
  };
12326
- static defaultTextureWriteOptions = {
12327
- byteOffset: 0,
12328
- bytesPerRow: void 0,
12329
- rowsPerImage: void 0,
12330
- x: 0,
12331
- y: 0,
12332
- z: 0,
12333
- width: void 0,
12334
- height: void 0,
12335
- depthOrArrayLayers: 1,
12336
- mipLevel: 0,
12337
- aspect: "all"
12338
- };
12339
12632
  };
12340
12633
 
12341
12634
  // ../core/src/api/adapter-utils/bind-groups.ts
@@ -13568,7 +13861,7 @@ ${getApplicationDefines(allDefines)}
13568
13861
  ...this.props,
13569
13862
  modules,
13570
13863
  defines,
13571
- pluginHooks: resolvedPlugins.hooks,
13864
+ pluginInjectionTargets: resolvedPlugins.injectionTargets,
13572
13865
  pluginInjections: resolvedPlugins.injections,
13573
13866
  pluginVertexInputs: resolvedPlugins.vertexInputs,
13574
13867
  pluginInterStageVariables: resolvedPlugins.interStageVariables
@@ -13599,7 +13892,7 @@ ${getApplicationDefines(allDefines)}
13599
13892
  ...this.props,
13600
13893
  modules,
13601
13894
  defines,
13602
- pluginHooks: resolvedPlugins.hooks,
13895
+ pluginInjectionTargets: resolvedPlugins.injectionTargets,
13603
13896
  pluginInjections: resolvedPlugins.injections,
13604
13897
  pluginVertexInputs: resolvedPlugins.vertexInputs,
13605
13898
  pluginInterStageVariables: resolvedPlugins.interStageVariables
@@ -13717,9 +14010,26 @@ ${getApplicationDefines(allDefines)}
13717
14010
  /**
13718
14011
  * Issue one draw call.
13719
14012
  * @param renderPass - render pass to draw into
14013
+ * @param options - Optional dynamic parameters restored after drawing, including on errors.
13720
14014
  * @returns `true` if the draw call was executed, `false` if resources were not ready.
13721
14015
  */
13722
- draw(renderPass) {
14016
+ draw(renderPass, options) {
14017
+ if (options?.parameters) {
14018
+ return this._withDrawParameters(renderPass, options.parameters, () => this._draw(renderPass));
14019
+ }
14020
+ return this._draw(renderPass);
14021
+ }
14022
+ /** Applies draw overrides around the complete model batch, including failure paths. */
14023
+ _withDrawParameters(renderPass, parameters, draw) {
14024
+ const state = renderPass.getParameters();
14025
+ try {
14026
+ renderPass.setParameters(parameters);
14027
+ return draw();
14028
+ } finally {
14029
+ renderPass.setParameters(state);
14030
+ }
14031
+ }
14032
+ _draw(renderPass) {
13723
14033
  if (this.indexVector?.length === 0) {
13724
14034
  this._lastDrawTimestamp = this.device.timestamp;
13725
14035
  this._needsRedraw = false;
@@ -15050,6 +15360,8 @@ ${getApplicationDefines(allDefines)}
15050
15360
  var Material = class {
15051
15361
  /** Application-provided identifier. */
15052
15362
  id;
15363
+ /** Structured metadata associated with this material. */
15364
+ metadata = {};
15053
15365
  /** Device that owns the material resources. */
15054
15366
  device;
15055
15367
  /** Factory that defines the material schema. */
@@ -15106,6 +15418,7 @@ ${getApplicationDefines(allDefines)}
15106
15418
  if (props.moduleProps) {
15107
15419
  material.setProps(props.moduleProps);
15108
15420
  }
15421
+ material.metadata = { ...this.metadata };
15109
15422
  material.updateShaderInputs();
15110
15423
  return material;
15111
15424
  }
@@ -15925,11 +16238,11 @@ void main(void) {
15925
16238
  destroyManagedInstanceBuffers(this._managedBuffers);
15926
16239
  this._managedBuffers = {};
15927
16240
  }
15928
- draw(renderPass) {
16241
+ draw(renderPass, options) {
15929
16242
  if (this.instanceCount === 0) {
15930
16243
  return true;
15931
16244
  }
15932
- return super.draw(renderPass);
16245
+ return super.draw(renderPass, options);
15933
16246
  }
15934
16247
  setProps(props) {
15935
16248
  this.lightModelProps = { ...this.lightModelProps, ...props };
@@ -16312,7 +16625,7 @@ void main(void) {
16312
16625
  };
16313
16626
 
16314
16627
  // src/scenegraph/scenegraph-node.ts
16315
- function assert10(condition, message) {
16628
+ function assert11(condition, message) {
16316
16629
  if (!condition) {
16317
16630
  throw new Error(message);
16318
16631
  }
@@ -16321,9 +16634,15 @@ void main(void) {
16321
16634
  id;
16322
16635
  matrix = new Matrix4();
16323
16636
  display = true;
16637
+ /** Local selection eligibility, independent of visibility. */
16638
+ selectable = true;
16639
+ /** Local hover eligibility, independent of visibility. */
16640
+ hoverable = true;
16324
16641
  position = new Vector3();
16325
16642
  rotation = new Vector3();
16326
16643
  scale = new Vector3(1, 1, 1);
16644
+ /** Structured metadata associated with this scene node. */
16645
+ metadata = {};
16327
16646
  userData = {};
16328
16647
  props = {};
16329
16648
  constructor(props = {}) {
@@ -16348,17 +16667,17 @@ void main(void) {
16348
16667
  return `{type: ScenegraphNode, id: ${this.id})}`;
16349
16668
  }
16350
16669
  setPosition(position) {
16351
- assert10(position.length === 3, "setPosition requires vector argument");
16670
+ assert11(position.length === 3, "setPosition requires vector argument");
16352
16671
  this.position = position;
16353
16672
  return this;
16354
16673
  }
16355
16674
  setRotation(rotation) {
16356
- assert10(rotation.length === 3 || rotation.length === 4, "setRotation requires vector argument");
16675
+ assert11(rotation.length === 3 || rotation.length === 4, "setRotation requires vector argument");
16357
16676
  this.rotation = rotation;
16358
16677
  return this;
16359
16678
  }
16360
16679
  setScale(scale5) {
16361
- assert10(scale5.length === 3, "setScale requires vector argument");
16680
+ assert11(scale5.length === 3, "setScale requires vector argument");
16362
16681
  this.scale = scale5;
16363
16682
  return this;
16364
16683
  }
@@ -16447,6 +16766,8 @@ void main(void) {
16447
16766
  }
16448
16767
  */
16449
16768
  _setScenegraphNodeProps(props) {
16769
+ if (props.selectable !== void 0) this.selectable = props.selectable;
16770
+ if (props.hoverable !== void 0) this.hoverable = props.hoverable;
16450
16771
  if (props.display !== void 0) {
16451
16772
  this.display = props.display;
16452
16773
  }
@@ -16467,6 +16788,90 @@ void main(void) {
16467
16788
  }
16468
16789
  };
16469
16790
 
16791
+ // src/scenegraph/scenegraph-interaction.ts
16792
+ function isScenegraphInteractionEnabled(path, kind) {
16793
+ return path.length > 0 && path.every((node) => kind === "select" ? node.selectable : node.hoverable);
16794
+ }
16795
+ function getFirstScenegraphInteractionHit(hits, kind) {
16796
+ return hits.find((hit) => isScenegraphInteractionEnabled(hit.path, kind));
16797
+ }
16798
+ var ScenegraphInteractionManager = class {
16799
+ hoveredHits = /* @__PURE__ */ new Map();
16800
+ pendingHover = /* @__PURE__ */ new Map();
16801
+ onEvent;
16802
+ /** Creates a controller that reports bubbled selection and hover events. */
16803
+ constructor(onEvent) {
16804
+ this.onEvent = onEvent;
16805
+ }
16806
+ /** Selects the first eligible nearest-first hit and bubbles from target to root. */
16807
+ select(hits, controllerIndex = 0) {
16808
+ const hit = getFirstScenegraphInteractionHit(hits, "select");
16809
+ if (!hit) return void 0;
16810
+ this.emitPath("select", hit, 0, controllerIndex);
16811
+ return hit;
16812
+ }
16813
+ /** Updates hover from current hits; call after pointer, camera, object, or flag changes. */
16814
+ updateHover(hits, controllerIndex = 0) {
16815
+ const hit = getFirstScenegraphInteractionHit(hits, "hover");
16816
+ const queuedHit = hit ? { ...hit, path: [...hit.path] } : void 0;
16817
+ const activeQueue = this.pendingHover.get(controllerIndex);
16818
+ if (activeQueue) {
16819
+ activeQueue.push(queuedHit);
16820
+ return hit;
16821
+ }
16822
+ const queue = [queuedHit];
16823
+ this.pendingHover.set(controllerIndex, queue);
16824
+ try {
16825
+ while (queue.length) {
16826
+ const next = queue.shift();
16827
+ const previous = this.hoveredHits.get(controllerIndex);
16828
+ const previousPath = previous?.path || [];
16829
+ const nextPath = next?.path || [];
16830
+ let shared = 0;
16831
+ while (shared < previousPath.length && shared < nextPath.length && previousPath[shared] === nextPath[shared])
16832
+ shared++;
16833
+ if (next) this.hoveredHits.set(controllerIndex, next);
16834
+ else this.hoveredHits.delete(controllerIndex);
16835
+ if (previous) this.emitPath("hover-out", previous, shared, controllerIndex);
16836
+ if (next) this.emitPath("hover-in", next, shared, controllerIndex);
16837
+ }
16838
+ } finally {
16839
+ this.pendingHover.delete(controllerIndex);
16840
+ }
16841
+ return hit;
16842
+ }
16843
+ /** Emits exits for one controller and drops its tracked hover path. */
16844
+ clearHover(controllerIndex = 0) {
16845
+ this.updateHover([], controllerIndex);
16846
+ }
16847
+ /** Emits events from the target towards the first ancestor outside the shared subtree. */
16848
+ emitPath(type, hit, first, controllerIndex) {
16849
+ const { path } = hit;
16850
+ const target = path[path.length - 1];
16851
+ for (let index = path.length - 1; index >= first; index--) {
16852
+ this.onEvent({ type, target, currentTarget: path[index], controllerIndex, hit });
16853
+ }
16854
+ }
16855
+ };
16856
+
16857
+ // src/scenegraph/scene-metadata.ts
16858
+ var SceneMetadata = class {
16859
+ entries = /* @__PURE__ */ new Map();
16860
+ /** Associates metadata with a resource category and its source index. */
16861
+ set(category, index, metadata) {
16862
+ let categoryEntries = this.entries.get(category);
16863
+ if (!categoryEntries) {
16864
+ categoryEntries = /* @__PURE__ */ new Map();
16865
+ this.entries.set(category, categoryEntries);
16866
+ }
16867
+ categoryEntries.set(index, metadata);
16868
+ }
16869
+ /** Returns metadata for a resource, or undefined when none was supplied. */
16870
+ get(category, index = 0) {
16871
+ return this.entries.get(category)?.get(index);
16872
+ }
16873
+ };
16874
+
16470
16875
  // src/scenegraph/group-node.ts
16471
16876
  var import_core23 = __toESM(require_core(), 1);
16472
16877
 
@@ -17503,7 +17908,7 @@ void main(void) {
17503
17908
  this._observeSource();
17504
17909
  return this._updateTimestamp;
17505
17910
  }
17506
- /** Resource label used by debug output. */
17911
+ /** DeviceResource label used by debug output. */
17507
17912
  get [Symbol.toStringTag]() {
17508
17913
  return "VideoTexture";
17509
17914
  }
@@ -17907,7 +18312,7 @@ void main(void) {
17907
18312
  Object.assign(this.userData, props.userData);
17908
18313
  const platformInfo = getPlatformInfo(device);
17909
18314
  const resolvedPlugins = (0, import_shaders6.resolveShaderPlugins)(this.props.plugins, platformInfo.shaderLanguage);
17910
- if (resolvedPlugins.hooks.length > 0) {
18315
+ if (resolvedPlugins.injectionTargets.length > 0) {
17911
18316
  throw new Error("Computation does not support ShaderPlugin render hooks");
17912
18317
  }
17913
18318
  if (Object.keys(resolvedPlugins.vertexInputs).length > 0 || Object.keys(resolvedPlugins.interStageVariables).length > 0) {
@@ -20296,8 +20701,99 @@ vec4 picking_filterColor(vec4 color) {
20296
20701
  ]);
20297
20702
  }
20298
20703
 
20704
+ // src/scenegraph/controllers/punctual-light-controller.ts
20705
+ var import_shaders8 = __toESM(require_shaders(), 1);
20706
+ var PunctualLightController = class {
20707
+ constructor(bindings, useByteColors = true) {
20708
+ this.bindings = bindings;
20709
+ this.useByteColors = useByteColors;
20710
+ this.update();
20711
+ }
20712
+ bindings;
20713
+ useByteColors;
20714
+ lights = [];
20715
+ /** Refreshes the stable light array after node or light properties change. */
20716
+ update() {
20717
+ this.lights.length = 0;
20718
+ for (const { path, definition } of this.bindings) {
20719
+ if (!path.length || path.some((node) => !node.display)) continue;
20720
+ const worldMatrix = new Matrix4();
20721
+ for (const node of path) worldMatrix.multiplyRight(node.matrix);
20722
+ const light = makePunctualLight(definition, worldMatrix, this.useByteColors);
20723
+ if (light) this.lights.push(light);
20724
+ }
20725
+ }
20726
+ };
20727
+ function makePunctualLight(definition, worldMatrix, useByteColors) {
20728
+ const color = normalizePunctualLightColor(definition.color || [1, 1, 1], useByteColors);
20729
+ const intensity = definition.intensity ?? 1;
20730
+ switch (definition.type) {
20731
+ case "directional":
20732
+ return makeDirectionalLight(worldMatrix, color, intensity);
20733
+ case "point":
20734
+ return makePointLight(worldMatrix, color, intensity, definition.range);
20735
+ case "spot":
20736
+ return makeSpotLight(worldMatrix, color, intensity, definition.range, definition.spot);
20737
+ default:
20738
+ return void 0;
20739
+ }
20740
+ }
20741
+ function normalizePunctualLightColor(color, useByteColors) {
20742
+ if (useByteColors) {
20743
+ return color.map((component) => component * 255);
20744
+ }
20745
+ return (0, import_shaders8.normalizeByteColor3)(color, false);
20746
+ }
20747
+ function makePointLight(worldMatrix, color, intensity, range) {
20748
+ const position = getLightPosition(worldMatrix);
20749
+ let attenuation = [1, 0, 0];
20750
+ if (range !== void 0 && range > 0) {
20751
+ attenuation = [1, 0, 1 / (range * range)];
20752
+ }
20753
+ return {
20754
+ type: "point",
20755
+ position,
20756
+ color,
20757
+ intensity,
20758
+ attenuation
20759
+ };
20760
+ }
20761
+ function makeDirectionalLight(worldMatrix, color, intensity) {
20762
+ const direction = getLightDirection(worldMatrix);
20763
+ return {
20764
+ type: "directional",
20765
+ direction,
20766
+ color,
20767
+ intensity
20768
+ };
20769
+ }
20770
+ function makeSpotLight(worldMatrix, color, intensity, range, spot = {}) {
20771
+ const position = getLightPosition(worldMatrix);
20772
+ const direction = getLightDirection(worldMatrix);
20773
+ let attenuation = [1, 0, 0];
20774
+ if (range !== void 0 && range > 0) {
20775
+ attenuation = [1, 0, 1 / (range * range)];
20776
+ }
20777
+ return {
20778
+ type: "spot",
20779
+ position,
20780
+ direction,
20781
+ color,
20782
+ intensity,
20783
+ attenuation,
20784
+ innerConeAngle: spot.innerConeAngle ?? 0,
20785
+ outerConeAngle: spot.outerConeAngle ?? Math.PI / 4
20786
+ };
20787
+ }
20788
+ function getLightPosition(worldMatrix) {
20789
+ return worldMatrix.transformAsPoint([0, 0, 0]);
20790
+ }
20791
+ function getLightDirection(worldMatrix) {
20792
+ return worldMatrix.transformAsVector([0, 0, -1]);
20793
+ }
20794
+
20299
20795
  // src/scenegraph/controllers/area-light-controller.ts
20300
- var import_core36 = __toESM(require_core(), 1);
20796
+ var import_core37 = __toESM(require_core(), 1);
20301
20797
  var AreaLightController = class {
20302
20798
  scenes;
20303
20799
  matrixAuthoredNodes = /* @__PURE__ */ new Set();
@@ -20307,11 +20803,11 @@ vec4 picking_filterColor(vec4 color) {
20307
20803
  for (const node of matrixNodes) this.matrixAuthoredNodes.add(node);
20308
20804
  for (const { node, definition, matrixAuthored } of bindings) {
20309
20805
  if (matrixAuthored) this.matrixAuthoredNodes.add(node);
20310
- (0, import_core36.assert)(definition && (definition.type === "rect" || definition.type === "disk"));
20311
- (0, import_core36.assert)(Number.isFinite(definition.height ?? 1) && (definition.height ?? 1) > 0);
20312
- (0, import_core36.assert)(Number.isFinite(definition.intensity ?? 1e3) && (definition.intensity ?? 1e3) > 0);
20313
- (0, import_core36.assert)(Number.isFinite(definition.width ?? 1) && (definition.width ?? 1) > 0);
20314
- (0, import_core36.assert)(
20806
+ (0, import_core37.assert)(definition && (definition.type === "rect" || definition.type === "disk"));
20807
+ (0, import_core37.assert)(Number.isFinite(definition.height ?? 1) && (definition.height ?? 1) > 0);
20808
+ (0, import_core37.assert)(Number.isFinite(definition.intensity ?? 1e3) && (definition.intensity ?? 1e3) > 0);
20809
+ (0, import_core37.assert)(Number.isFinite(definition.width ?? 1) && (definition.width ?? 1) > 0);
20810
+ (0, import_core37.assert)(
20315
20811
  (definition.color || [1, 1, 1]).every(
20316
20812
  (component) => Number.isFinite(component) && component >= 0
20317
20813
  )
@@ -20377,17 +20873,17 @@ vec4 picking_filterColor(vec4 color) {
20377
20873
  function getMatrixRotation(matrix) {
20378
20874
  const horizontal = new Vector3(matrix[0], matrix[1], matrix[2]);
20379
20875
  const vertical = new Vector3(matrix[4], matrix[5], matrix[6]);
20380
- (0, import_core36.assert)(horizontal.magnitude() > 0 && vertical.magnitude() > 0);
20876
+ (0, import_core37.assert)(horizontal.magnitude() > 0 && vertical.magnitude() > 0);
20381
20877
  horizontal.normalize();
20382
20878
  vertical.normalize();
20383
20879
  vertical.subtract(new Vector3(horizontal).scale(vertical.dot(horizontal)));
20384
- (0, import_core36.assert)(vertical.magnitude() > 1e-8);
20880
+ (0, import_core37.assert)(vertical.magnitude() > 1e-8);
20385
20881
  vertical.normalize();
20386
20882
  const forward = new Vector3(horizontal).cross(vertical).normalize();
20387
20883
  const authoredForward = new Vector3(matrix[8], matrix[9], matrix[10]);
20388
- (0, import_core36.assert)(authoredForward.magnitude() > 0);
20884
+ (0, import_core37.assert)(authoredForward.magnitude() > 0);
20389
20885
  authoredForward.normalize();
20390
- (0, import_core36.assert)(Math.abs(forward.dot(authoredForward)) > 1e-8);
20886
+ (0, import_core37.assert)(Math.abs(forward.dot(authoredForward)) > 1e-8);
20391
20887
  if (forward.dot(authoredForward) < 0) forward.negate();
20392
20888
  return new Matrix4([
20393
20889
  horizontal[0],
@@ -20945,15 +21441,15 @@ vec4 picking_filterColor(vec4 color) {
20945
21441
  };
20946
21442
 
20947
21443
  // src/audio/audio-graph.ts
20948
- var import_core38 = __toESM(require_core(), 1);
21444
+ var import_core39 = __toESM(require_core(), 1);
20949
21445
  var AudioGraph = class {
20950
21446
  constructor(definition, context, destination, getEmitterInputs) {
20951
21447
  this.definition = definition;
20952
21448
  for (const node of definition.nodes)
20953
- (0, import_core38.assert)(!node.bypass || node.kind !== "splitter" && node.kind !== "channelmerger");
21449
+ (0, import_core39.assert)(!node.bypass || node.kind !== "splitter" && node.kind !== "channelmerger");
20954
21450
  const validateEndpoint = (index, port = 0) => {
20955
- (0, import_core38.assert)(Number.isInteger(index) && Boolean(definition.nodes[index]));
20956
- (0, import_core38.assert)(Number.isInteger(port) && port >= 0);
21451
+ (0, import_core39.assert)(Number.isInteger(index) && Boolean(definition.nodes[index]));
21452
+ (0, import_core39.assert)(Number.isInteger(port) && port >= 0);
20957
21453
  };
20958
21454
  for (const edge of definition.connections) {
20959
21455
  validateEndpoint(edge.from.node, edge.from.output);
@@ -20961,16 +21457,16 @@ vec4 picking_filterColor(vec4 color) {
20961
21457
  }
20962
21458
  for (const input of definition.inputs || []) {
20963
21459
  validateEndpoint(input.node, input.input);
20964
- (0, import_core38.assert)(Number.isInteger(input.source) && input.source >= 0);
21460
+ (0, import_core39.assert)(Number.isInteger(input.source) && input.source >= 0);
20965
21461
  }
20966
21462
  for (const output of definition.outputs || []) {
20967
21463
  validateEndpoint(output.node, output.output);
20968
- (0, import_core38.assert)(Number.isInteger(output.emitter) && output.emitter >= 0);
21464
+ (0, import_core39.assert)(Number.isInteger(output.emitter) && output.emitter >= 0);
20969
21465
  }
20970
21466
  const visiting = /* @__PURE__ */ new Set();
20971
21467
  const visited = /* @__PURE__ */ new Set();
20972
21468
  const visit = (index) => {
20973
- (0, import_core38.assert)(definition.nodes[index] && !visiting.has(index));
21469
+ (0, import_core39.assert)(definition.nodes[index] && !visiting.has(index));
20974
21470
  if (visited.has(index)) return;
20975
21471
  visiting.add(index);
20976
21472
  for (const edge of definition.connections) if (edge.from.node === index) visit(edge.to.node);
@@ -21031,7 +21527,7 @@ vec4 picking_filterColor(vec4 color) {
21031
21527
  /** Apply a scene-driven gain change using the authored transition shape. */
21032
21528
  setGain(index, gain, time = this.nodes[index].context.currentTime) {
21033
21529
  const definition = this.definition.nodes[index];
21034
- (0, import_core38.assert)(definition.kind === "gain" && !definition.bypass && gain >= 0);
21530
+ (0, import_core39.assert)(definition.kind === "gain" && !definition.bypass && gain >= 0);
21035
21531
  const parameter = this.nodes[index].gain;
21036
21532
  const duration = definition.params.duration ?? 0;
21037
21533
  const initialGain = parameter.value;
@@ -21041,7 +21537,7 @@ vec4 picking_filterColor(vec4 color) {
21041
21537
  parameter.setValueAtTime(gain, time);
21042
21538
  } else if (definition.params.interpolation === "custom") {
21043
21539
  const curve = definition.params.curve;
21044
- (0, import_core38.assert)(curve && curve.length >= 2 && curve.every((value) => value >= 0 && value <= 1));
21540
+ (0, import_core39.assert)(curve && curve.length >= 2 && curve.every((value) => value >= 0 && value <= 1));
21045
21541
  parameter.setValueCurveAtTime(
21046
21542
  Float32Array.from(curve, (value) => value * gain),
21047
21543
  time,
@@ -21126,7 +21622,7 @@ vec4 picking_filterColor(vec4 color) {
21126
21622
  }
21127
21623
 
21128
21624
  // src/audio/audio-environment.ts
21129
- var import_core40 = __toESM(require_core(), 1);
21625
+ var import_core41 = __toESM(require_core(), 1);
21130
21626
  function selectAudioEnvironmentZone(zones, position) {
21131
21627
  let selected;
21132
21628
  for (const zone of zones) {
@@ -21219,7 +21715,7 @@ vec4 picking_filterColor(vec4 color) {
21219
21715
  }
21220
21716
  };
21221
21717
  function createParametricAudioResponse(context, parameters) {
21222
- (0, import_core40.assert)((parameters.density ?? 1) === 1 && (parameters.diffusion ?? 1) === 1);
21718
+ (0, import_core41.assert)((parameters.density ?? 1) === 1 && (parameters.diffusion ?? 1) === 1);
21223
21719
  const presets = {
21224
21720
  generic: [1.49, 0.83, 7e-3, 0.011],
21225
21721
  smallRoom: [0.4, 0.83, 2e-3, 3e-3],
@@ -21236,12 +21732,12 @@ vec4 picking_filterColor(vec4 color) {
21236
21732
  underwater: [1.49, 0.1, 7e-3, 0.011]
21237
21733
  };
21238
21734
  const preset = parameters.preset ? presets[parameters.preset] : void 0;
21239
- (0, import_core40.assert)(!parameters.preset || preset);
21735
+ (0, import_core41.assert)(!parameters.preset || preset);
21240
21736
  const decay = parameters.decayTime ?? preset?.[0] ?? 1.5;
21241
21737
  const highFrequencyDecay = decay * (parameters.decayHFRatio ?? preset?.[1] ?? 0.83);
21242
21738
  const earlyDelay = parameters.reflectionsDelay ?? preset?.[2] ?? 0.02;
21243
21739
  const tailDelay = earlyDelay + (parameters.reverbDelay ?? preset?.[3] ?? 0.04);
21244
- (0, import_core40.assert)(decay > 0 && highFrequencyDecay > 0 && earlyDelay >= 0 && tailDelay >= earlyDelay);
21740
+ (0, import_core41.assert)(decay > 0 && highFrequencyDecay > 0 && earlyDelay >= 0 && tailDelay >= earlyDelay);
21245
21741
  const response = context.createBuffer(
21246
21742
  2,
21247
21743
  Math.ceil((tailDelay + Math.max(decay, highFrequencyDecay)) * context.sampleRate),
@@ -21265,7 +21761,7 @@ vec4 picking_filterColor(vec4 color) {
21265
21761
  }
21266
21762
 
21267
21763
  // src/audio/audio-controller.ts
21268
- var import_core41 = __toESM(require_core(), 1);
21764
+ var import_core42 = __toESM(require_core(), 1);
21269
21765
  var AudioController = class {
21270
21766
  gain;
21271
21767
  definition;
@@ -21375,25 +21871,25 @@ vec4 picking_filterColor(vec4 color) {
21375
21871
  /** Change a graph gain using its authored interpolation and duration. */
21376
21872
  setGraphGain(graphIndex, nodeIndex, gain) {
21377
21873
  const graph = this.graphs.get(graphIndex);
21378
- (0, import_core41.assert)(!this.destroyed && graph);
21874
+ (0, import_core42.assert)(!this.destroyed && graph);
21379
21875
  graph.setGain(nodeIndex, gain);
21380
21876
  }
21381
21877
  startSource(sourceIndex, startTime, autoplayOnly, connect) {
21382
21878
  const definition = this.definition.sources[sourceIndex];
21383
- (0, import_core41.assert)(definition);
21879
+ (0, import_core42.assert)(definition);
21384
21880
  if (autoplayOnly && !definition.autoPlay) return;
21385
21881
  const context = this.options.audioContext;
21386
21882
  const extended = definition.graph;
21387
21883
  const oscillator = extended?.oscillator;
21388
- (0, import_core41.assert)(!(definition.audio !== void 0 && oscillator));
21884
+ (0, import_core42.assert)(!(definition.audio !== void 0 && oscillator));
21389
21885
  let source4;
21390
21886
  if (oscillator) {
21391
21887
  const node = context.createOscillator();
21392
21888
  node.frequency.value = oscillator.frequency ?? 440;
21393
21889
  node.detune.value = oscillator.detune ?? 0;
21394
- (0, import_core41.assert)(oscillator.pulseWidth === void 0 || oscillator.pulseWidth === 0.5);
21890
+ (0, import_core42.assert)(oscillator.pulseWidth === void 0 || oscillator.pulseWidth === 0.5);
21395
21891
  if (oscillator.type === "custom") {
21396
- (0, import_core41.assert)(oscillator.periodicWave);
21892
+ (0, import_core42.assert)(oscillator.periodicWave);
21397
21893
  node.setPeriodicWave(
21398
21894
  context.createPeriodicWave(
21399
21895
  new Float32Array(oscillator.periodicWave.real),
@@ -21404,7 +21900,7 @@ vec4 picking_filterColor(vec4 color) {
21404
21900
  source4 = node;
21405
21901
  } else {
21406
21902
  const node = context.createBufferSource();
21407
- (0, import_core41.assert)(definition.audio !== void 0);
21903
+ (0, import_core42.assert)(definition.audio !== void 0);
21408
21904
  node.buffer = this.buffers.get(definition.audio);
21409
21905
  node.loop = definition.loop ?? false;
21410
21906
  node.loopStart = extended?.loopStart ?? 0;
@@ -21549,15 +22045,15 @@ vec4 picking_filterColor(vec4 color) {
21549
22045
  }
21550
22046
  addEmitter(index, node) {
21551
22047
  const definition = this.definition.emitters[index];
21552
- (0, import_core41.assert)(
22048
+ (0, import_core42.assert)(
21553
22049
  definition && (definition.type === "global" || definition.type === "positional" && node)
21554
22050
  );
21555
- (0, import_core41.assert)(
22051
+ (0, import_core42.assert)(
21556
22052
  !definition.positional?.shapeType || ["cone", "omnidirectional"].includes(definition.positional.shapeType)
21557
22053
  );
21558
22054
  for (const sourceIndex of this.graphEmitters.has(index) ? [] : definition.sources || []) {
21559
22055
  const source4 = this.definition.sources[sourceIndex];
21560
- (0, import_core41.assert)(
22056
+ (0, import_core42.assert)(
21561
22057
  source4 && (source4.audio !== void 0 ? this.definition.audio[source4.audio] : source4.graph?.oscillator)
21562
22058
  );
21563
22059
  }
@@ -21602,7 +22098,7 @@ vec4 picking_filterColor(vec4 color) {
21602
22098
  const audioIndices = new Set(
21603
22099
  [...sourceIndices].map((index) => {
21604
22100
  const source4 = this.definition.sources[index];
21605
- (0, import_core41.assert)(
22101
+ (0, import_core42.assert)(
21606
22102
  source4 && (source4.audio !== void 0 ? this.definition.audio[source4.audio] : source4.graph?.oscillator)
21607
22103
  );
21608
22104
  return source4.audio;
@@ -21639,7 +22135,7 @@ vec4 picking_filterColor(vec4 color) {
21639
22135
  const reverb = environment.reverb;
21640
22136
  if (!reverb) return;
21641
22137
  const response = reverb.type === "impulseResponse" ? this.buffers.get(reverb.audio) : createParametricAudioResponse(audioContext, reverb);
21642
- (0, import_core41.assert)(response);
22138
+ (0, import_core42.assert)(response);
21643
22139
  const bus = new AudioReverbBus(audioContext, response, this.gain, {
21644
22140
  ...reverb,
21645
22141
  normalize: reverb.type === "impulseResponse" ? reverb.normalize : false
@@ -21744,11 +22240,11 @@ vec4 picking_filterColor(vec4 color) {
21744
22240
  };
21745
22241
 
21746
22242
  // src/modules/picking/legacy-color-picking.ts
21747
- var import_shaders8 = __toESM(require_shaders(), 1);
21748
- var legacyColorPicking = import_shaders8.picking;
22243
+ var import_shaders9 = __toESM(require_shaders(), 1);
22244
+ var legacyColorPicking = import_shaders9.picking;
21749
22245
 
21750
22246
  // src/geometry/ring-geometry.ts
21751
- var import_core43 = __toESM(require_core(), 1);
22247
+ var import_core44 = __toESM(require_core(), 1);
21752
22248
  var RingGeometry = class extends Geometry2 {
21753
22249
  constructor(props = {}) {
21754
22250
  const {
@@ -21759,7 +22255,7 @@ vec4 picking_filterColor(vec4 color) {
21759
22255
  startAngle = 0,
21760
22256
  angle: angle2 = Math.PI * 2
21761
22257
  } = props;
21762
- (0, import_core43.assert)(
22258
+ (0, import_core44.assert)(
21763
22259
  Number.isFinite(innerRadius) && innerRadius >= 0 && Number.isFinite(outerRadius) && outerRadius > innerRadius && Number.isFinite(height) && height > 0 && Number.isFinite(startAngle) && Number.isFinite(angle2) && angle2 > 0 && angle2 <= Math.PI * 2 && Number.isInteger(segments) && segments >= 3
21764
22260
  );
21765
22261
  const halfHeight = height / 2;
@@ -21943,7 +22439,7 @@ struct PublishedTransforms {bodyIndex:i32,viewProjection:mat4x4f}
21943
22439
  };
21944
22440
 
21945
22441
  // src/scenegraph/controllers/morph-controller.ts
21946
- var import_core46 = __toESM(require_core(), 1);
22442
+ var import_core47 = __toESM(require_core(), 1);
21947
22443
  function setMorphWeights(node, weights) {
21948
22444
  node.userData["morphWeights"] = [...weights];
21949
22445
  const meshes = node.userData["morphMeshes"] || [];
@@ -21970,7 +22466,7 @@ struct PublishedTransforms {bodyIndex:i32,viewProjection:mat4x4f}
21970
22466
  function updateMorphWeights(state, weights) {
21971
22467
  state.values.fill(0);
21972
22468
  state.values.set(weights.slice(0, state.values.length));
21973
- if (state.data instanceof import_core46.Buffer) {
22469
+ if (state.data instanceof import_core47.Buffer) {
21974
22470
  state.data.write(state.values);
21975
22471
  } else {
21976
22472
  state.data.writeData(state.values, { width: state.packedTargetCount, height: 1 });
@@ -21993,6 +22489,10 @@ struct PublishedTransforms {bodyIndex:i32,viewProjection:mat4x4f}
21993
22489
  return Array.from(node.userData["morphWeights"] ?? []);
21994
22490
  case "visibility":
21995
22491
  return [node.display ? 1 : 0];
22492
+ case "selectable":
22493
+ return [node.selectable ? 1 : 0];
22494
+ case "hoverable":
22495
+ return [node.hoverable ? 1 : 0];
21996
22496
  }
21997
22497
  },
21998
22498
  setValue: (value) => {
@@ -22009,6 +22509,12 @@ struct PublishedTransforms {bodyIndex:i32,viewProjection:mat4x4f}
22009
22509
  case "weights":
22010
22510
  setMorphWeights(node, value);
22011
22511
  break;
22512
+ case "selectable":
22513
+ node.setProps({ selectable: value[0] !== 0 });
22514
+ break;
22515
+ case "hoverable":
22516
+ node.setProps({ hoverable: value[0] !== 0 });
22517
+ break;
22012
22518
  case "visibility":
22013
22519
  node.setProps({ display: value[0] !== 0 });
22014
22520
  options.onVisibilityChange?.();
@@ -22326,7 +22832,7 @@ struct PublishedTransforms {bodyIndex:i32,viewProjection:mat4x4f}
22326
22832
  }
22327
22833
 
22328
22834
  // src/lighting/ltc-textures.ts
22329
- var import_shaders9 = __toESM(require_shaders(), 1);
22835
+ var import_shaders10 = __toESM(require_shaders(), 1);
22330
22836
 
22331
22837
  // src/lighting/ltc-data.ts
22332
22838
  var LTC_MATRIX_DATA = [
@@ -55109,7 +55615,7 @@ struct PublishedTransforms {bodyIndex:i32,viewProjection:mat4x4f}
55109
55615
  width: 64,
55110
55616
  height: 64,
55111
55617
  format: "rgba16float",
55112
- data: Uint16Array.from(data, import_shaders9.toHalfFloat),
55618
+ data: Uint16Array.from(data, import_shaders10.toHalfFloat),
55113
55619
  mipLevels: 1,
55114
55620
  sampler: { minFilter: "nearest", magFilter: "nearest" }
55115
55621
  });