@luma.gl/engine 10.0.0-rc.1 → 10.0.0-rc.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (437) hide show
  1. package/THIRD-PARTY-NOTICES.md +82 -0
  2. package/dist/animation/animation-track.d.ts +7 -0
  3. package/dist/animation/animation-track.d.ts.map +1 -1
  4. package/dist/animation/animation-track.js.map +1 -1
  5. package/dist/animation/node-animation-binding.cjs +1 -0
  6. package/dist/animation/node-animation-binding.d.ts +2 -1
  7. package/dist/animation/node-animation-binding.d.ts.map +1 -1
  8. package/dist/animation/node-animation-binding.js +6 -0
  9. package/dist/animation/node-animation-binding.js.map +1 -1
  10. package/dist/animation/scenegraph-gpu-animation-layout.cjs +99 -0
  11. package/dist/animation/scenegraph-gpu-animation-layout.d.ts +69 -0
  12. package/dist/animation/scenegraph-gpu-animation-layout.d.ts.map +1 -0
  13. package/dist/animation/scenegraph-gpu-animation-layout.js +90 -0
  14. package/dist/animation/scenegraph-gpu-animation-layout.js.map +1 -0
  15. package/dist/animation/scenegraph-gpu-animation.cjs +281 -0
  16. package/dist/animation/scenegraph-gpu-animation.d.ts +54 -0
  17. package/dist/animation/scenegraph-gpu-animation.d.ts.map +1 -0
  18. package/dist/animation/scenegraph-gpu-animation.js +274 -0
  19. package/dist/animation/scenegraph-gpu-animation.js.map +1 -0
  20. package/dist/arrow/arrow-picking.cjs +4 -3
  21. package/dist/arrow/arrow-picking.d.ts +15 -5
  22. package/dist/arrow/arrow-picking.d.ts.map +1 -1
  23. package/dist/arrow/arrow-picking.js +16 -5
  24. package/dist/arrow/arrow-picking.js.map +1 -1
  25. package/dist/arrow/index.cjs.map +1 -1
  26. package/dist/dist.dev.js +1671 -1105
  27. package/dist/dist.min.js +69 -70
  28. package/dist/effects/glfx-effects.cjs +261 -0
  29. package/dist/effects/glfx-effects.d.ts +959 -0
  30. package/dist/effects/glfx-effects.d.ts.map +1 -0
  31. package/dist/effects/glfx-effects.js +200 -0
  32. package/dist/effects/glfx-effects.js.map +1 -0
  33. package/dist/effects/graph/gpu-effect-operation.cjs +402 -0
  34. package/dist/effects/graph/gpu-effect-operation.d.ts +101 -0
  35. package/dist/effects/graph/gpu-effect-operation.d.ts.map +1 -0
  36. package/dist/effects/graph/gpu-effect-operation.js +410 -0
  37. package/dist/effects/graph/gpu-effect-operation.js.map +1 -0
  38. package/dist/effects/graph/temporal-graph-history.cjs +48 -0
  39. package/dist/effects/graph/temporal-graph-history.d.ts +17 -0
  40. package/dist/effects/graph/temporal-graph-history.d.ts.map +1 -0
  41. package/dist/effects/graph/temporal-graph-history.js +30 -0
  42. package/dist/effects/graph/temporal-graph-history.js.map +1 -0
  43. package/dist/effects/index.cjs +117 -30
  44. package/dist/effects/index.cjs.map +3 -3
  45. package/dist/effects/index.d.ts +34 -18
  46. package/dist/effects/index.d.ts.map +1 -1
  47. package/dist/effects/index.js +31 -18
  48. package/dist/effects/index.js.map +1 -1
  49. package/dist/effects/passes/postprocessing/fxaa/fxaa.cjs +9 -2
  50. package/dist/effects/passes/postprocessing/fxaa/fxaa.d.ts +19 -0
  51. package/dist/effects/passes/postprocessing/fxaa/fxaa.d.ts.map +1 -1
  52. package/dist/effects/passes/postprocessing/fxaa/fxaa.js +6 -0
  53. package/dist/effects/passes/postprocessing/fxaa/fxaa.js.map +1 -1
  54. package/dist/effects/passes/postprocessing/image-adjust-filters/tone-mapping.cjs +9 -2
  55. package/dist/effects/passes/postprocessing/image-adjust-filters/tone-mapping.d.ts +41 -0
  56. package/dist/effects/passes/postprocessing/image-adjust-filters/tone-mapping.d.ts.map +1 -1
  57. package/dist/effects/passes/postprocessing/image-adjust-filters/tone-mapping.js +6 -0
  58. package/dist/effects/passes/postprocessing/image-adjust-filters/tone-mapping.js.map +1 -1
  59. package/dist/effects/passes/postprocessing/image-blur-filters/bloom-composite-shader-pass.cjs +200 -13
  60. package/dist/effects/passes/postprocessing/image-blur-filters/bloom-composite-shader-pass.d.ts +992 -6
  61. package/dist/effects/passes/postprocessing/image-blur-filters/bloom-composite-shader-pass.d.ts.map +1 -1
  62. package/dist/effects/passes/postprocessing/image-blur-filters/bloom-composite-shader-pass.js +199 -10
  63. package/dist/effects/passes/postprocessing/image-blur-filters/bloom-composite-shader-pass.js.map +1 -1
  64. package/dist/effects/passes/postprocessing/image-blur-filters/bloom-compute-pyramid.d.ts +3 -3
  65. package/dist/effects/passes/postprocessing/image-blur-filters/bloom-compute-pyramid.d.ts.map +1 -1
  66. package/dist/effects/passes/postprocessing/image-blur-filters/bloom-compute-pyramid.js.map +1 -1
  67. package/dist/effects/passes/screen-space/camera-reprojection-temporal-antialiasing.cjs +41 -40
  68. package/dist/effects/passes/screen-space/camera-reprojection-temporal-antialiasing.d.ts +116 -8
  69. package/dist/effects/passes/screen-space/camera-reprojection-temporal-antialiasing.d.ts.map +1 -1
  70. package/dist/effects/passes/screen-space/camera-reprojection-temporal-antialiasing.js +38 -37
  71. package/dist/effects/passes/screen-space/camera-reprojection-temporal-antialiasing.js.map +1 -1
  72. package/dist/effects/passes/screen-space/clustered-volumetric-lighting.cjs +83 -66
  73. package/dist/effects/passes/screen-space/clustered-volumetric-lighting.d.ts +470 -2
  74. package/dist/effects/passes/screen-space/clustered-volumetric-lighting.d.ts.map +1 -1
  75. package/dist/effects/passes/screen-space/clustered-volumetric-lighting.js +80 -62
  76. package/dist/effects/passes/screen-space/clustered-volumetric-lighting.js.map +1 -1
  77. package/dist/effects/passes/screen-space/copy-pass.cjs +7 -0
  78. package/dist/effects/passes/screen-space/copy-pass.d.ts +1 -0
  79. package/dist/effects/passes/screen-space/copy-pass.d.ts.map +1 -1
  80. package/dist/effects/passes/screen-space/copy-pass.js +4 -0
  81. package/dist/effects/passes/screen-space/copy-pass.js.map +1 -1
  82. package/dist/effects/passes/screen-space/depth-aware-blur.cjs +14 -5
  83. package/dist/effects/passes/screen-space/depth-aware-blur.d.ts +125 -17
  84. package/dist/effects/passes/screen-space/depth-aware-blur.d.ts.map +1 -1
  85. package/dist/effects/passes/screen-space/depth-aware-blur.js +11 -3
  86. package/dist/effects/passes/screen-space/depth-aware-blur.js.map +1 -1
  87. package/dist/effects/passes/screen-space/dof.cjs +19 -3
  88. package/dist/effects/passes/screen-space/dof.d.ts +181 -0
  89. package/dist/effects/passes/screen-space/dof.d.ts.map +1 -1
  90. package/dist/effects/passes/screen-space/dof.js +17 -3
  91. package/dist/effects/passes/screen-space/dof.js.map +1 -1
  92. package/dist/effects/passes/screen-space/gtao.cjs +82 -62
  93. package/dist/effects/passes/screen-space/gtao.d.ts +608 -3
  94. package/dist/effects/passes/screen-space/gtao.d.ts.map +1 -1
  95. package/dist/effects/passes/screen-space/gtao.js +83 -60
  96. package/dist/effects/passes/screen-space/gtao.js.map +1 -1
  97. package/dist/effects/passes/screen-space/hdr-auto-exposure.cjs +103 -79
  98. package/dist/effects/passes/screen-space/hdr-auto-exposure.d.ts +225 -3
  99. package/dist/effects/passes/screen-space/hdr-auto-exposure.d.ts.map +1 -1
  100. package/dist/effects/passes/screen-space/hdr-auto-exposure.js +102 -77
  101. package/dist/effects/passes/screen-space/hdr-auto-exposure.js.map +1 -1
  102. package/dist/effects/passes/screen-space/height-fog.cjs +14 -0
  103. package/dist/effects/passes/screen-space/height-fog.d.ts +71 -0
  104. package/dist/effects/passes/screen-space/height-fog.d.ts.map +1 -1
  105. package/dist/effects/passes/screen-space/height-fog.js +16 -3
  106. package/dist/effects/passes/screen-space/height-fog.js.map +1 -1
  107. package/dist/effects/passes/screen-space/motion-blur.cjs +7 -8
  108. package/dist/effects/passes/screen-space/motion-blur.d.ts +41 -2
  109. package/dist/effects/passes/screen-space/motion-blur.d.ts.map +1 -1
  110. package/dist/effects/passes/screen-space/motion-blur.js +6 -6
  111. package/dist/effects/passes/screen-space/motion-blur.js.map +1 -1
  112. package/dist/effects/passes/screen-space/outlines.cjs +143 -18
  113. package/dist/effects/passes/screen-space/outlines.d.ts +162 -3
  114. package/dist/effects/passes/screen-space/outlines.d.ts.map +1 -1
  115. package/dist/effects/passes/screen-space/outlines.js +137 -15
  116. package/dist/effects/passes/screen-space/outlines.js.map +1 -1
  117. package/dist/effects/passes/screen-space/screen-space-global-illumination.cjs +70 -61
  118. package/dist/effects/passes/screen-space/screen-space-global-illumination.d.ts +309 -2
  119. package/dist/effects/passes/screen-space/screen-space-global-illumination.d.ts.map +1 -1
  120. package/dist/effects/passes/screen-space/screen-space-global-illumination.js +69 -59
  121. package/dist/effects/passes/screen-space/screen-space-global-illumination.js.map +1 -1
  122. package/dist/effects/passes/screen-space/screen-space-reflections.cjs +151 -83
  123. package/dist/effects/passes/screen-space/screen-space-reflections.d.ts +778 -7
  124. package/dist/effects/passes/screen-space/screen-space-reflections.d.ts.map +1 -1
  125. package/dist/effects/passes/screen-space/screen-space-reflections.js +148 -79
  126. package/dist/effects/passes/screen-space/screen-space-reflections.js.map +1 -1
  127. package/dist/effects/passes/screen-space/selection-outline.cjs +12 -2
  128. package/dist/effects/passes/screen-space/selection-outline.d.ts +44 -0
  129. package/dist/effects/passes/screen-space/selection-outline.d.ts.map +1 -1
  130. package/dist/effects/passes/screen-space/selection-outline.js +9 -0
  131. package/dist/effects/passes/screen-space/selection-outline.js.map +1 -1
  132. package/dist/effects/passes/screen-space/ssao.cjs +66 -43
  133. package/dist/effects/passes/screen-space/ssao.d.ts +647 -2
  134. package/dist/effects/passes/screen-space/ssao.d.ts.map +1 -1
  135. package/dist/effects/passes/screen-space/ssao.js +64 -41
  136. package/dist/effects/passes/screen-space/ssao.js.map +1 -1
  137. package/dist/effects/passes/screen-space/temporal-antialiasing.cjs +42 -30
  138. package/dist/effects/passes/screen-space/temporal-antialiasing.d.ts +107 -6
  139. package/dist/effects/passes/screen-space/temporal-antialiasing.d.ts.map +1 -1
  140. package/dist/effects/passes/screen-space/temporal-antialiasing.js +40 -27
  141. package/dist/effects/passes/screen-space/temporal-antialiasing.js.map +1 -1
  142. package/dist/effects/passes/screen-space/temporal-frame.cjs +34 -0
  143. package/dist/effects/passes/screen-space/temporal-frame.d.ts +23 -0
  144. package/dist/effects/passes/screen-space/temporal-frame.d.ts.map +1 -0
  145. package/dist/effects/passes/screen-space/temporal-frame.js +16 -0
  146. package/dist/effects/passes/screen-space/temporal-frame.js.map +1 -0
  147. package/dist/effects/passes/screen-space/volumetric-fog.cjs +25 -22
  148. package/dist/effects/passes/screen-space/volumetric-fog.d.ts +161 -2
  149. package/dist/effects/passes/screen-space/volumetric-fog.d.ts.map +1 -1
  150. package/dist/effects/passes/screen-space/volumetric-fog.js +27 -21
  151. package/dist/effects/passes/screen-space/volumetric-fog.js.map +1 -1
  152. package/dist/effects/temporal-upscale/index.cjs +40 -0
  153. package/dist/effects/temporal-upscale/index.d.ts +5 -0
  154. package/dist/effects/temporal-upscale/index.d.ts.map +1 -0
  155. package/dist/effects/temporal-upscale/index.js +6 -0
  156. package/dist/effects/temporal-upscale/index.js.map +1 -0
  157. package/dist/effects/temporal-upscale/temporal-math.cjs +202 -0
  158. package/dist/effects/temporal-upscale/temporal-math.d.ts +101 -0
  159. package/dist/effects/temporal-upscale/temporal-math.d.ts.map +1 -0
  160. package/dist/effects/temporal-upscale/temporal-math.js +202 -0
  161. package/dist/effects/temporal-upscale/temporal-math.js.map +1 -0
  162. package/dist/effects/temporal-upscale/temporal-upscale-shaders.cjs +353 -0
  163. package/dist/effects/temporal-upscale/temporal-upscale-shaders.d.ts +7 -0
  164. package/dist/effects/temporal-upscale/temporal-upscale-shaders.d.ts.map +1 -0
  165. package/dist/effects/temporal-upscale/temporal-upscale-shaders.js +321 -0
  166. package/dist/effects/temporal-upscale/temporal-upscale-shaders.js.map +1 -0
  167. package/dist/effects/temporal-upscale/temporal-upscaler.cjs +392 -0
  168. package/dist/effects/temporal-upscale/temporal-upscaler.d.ts +143 -0
  169. package/dist/effects/temporal-upscale/temporal-upscaler.d.ts.map +1 -0
  170. package/dist/effects/temporal-upscale/temporal-upscaler.js +385 -0
  171. package/dist/effects/temporal-upscale/temporal-upscaler.js.map +1 -0
  172. package/dist/gltf/gltf/create-gltf-model.cjs +34 -71
  173. package/dist/gltf/gltf/create-gltf-model.d.ts +3 -0
  174. package/dist/gltf/gltf/create-gltf-model.d.ts.map +1 -1
  175. package/dist/gltf/gltf/create-gltf-model.js +40 -74
  176. package/dist/gltf/gltf/create-gltf-model.js.map +1 -1
  177. package/dist/gltf/gltf/create-scenegraph-from-gltf.cjs +46 -4
  178. package/dist/gltf/gltf/create-scenegraph-from-gltf.d.ts +9 -1
  179. package/dist/gltf/gltf/create-scenegraph-from-gltf.d.ts.map +1 -1
  180. package/dist/gltf/gltf/create-scenegraph-from-gltf.js +54 -4
  181. package/dist/gltf/gltf/create-scenegraph-from-gltf.js.map +1 -1
  182. package/dist/gltf/gltf/gltf-animated-crowd.cjs +25 -136
  183. package/dist/gltf/gltf/gltf-animated-crowd.d.ts +4 -8
  184. package/dist/gltf/gltf/gltf-animated-crowd.d.ts.map +1 -1
  185. package/dist/gltf/gltf/gltf-animated-crowd.js +27 -139
  186. package/dist/gltf/gltf/gltf-animated-crowd.js.map +1 -1
  187. package/dist/gltf/gltf/gltf-animation-nodes.cjs +84 -0
  188. package/dist/gltf/gltf/gltf-animation-nodes.d.ts +11 -0
  189. package/dist/gltf/gltf/gltf-animation-nodes.d.ts.map +1 -0
  190. package/dist/gltf/gltf/gltf-animation-nodes.js +62 -0
  191. package/dist/gltf/gltf/gltf-animation-nodes.js.map +1 -0
  192. package/dist/gltf/gltf/gltf-animator.cjs +8 -2
  193. package/dist/gltf/gltf/gltf-animator.d.ts +6 -1
  194. package/dist/gltf/gltf/gltf-animator.d.ts.map +1 -1
  195. package/dist/gltf/gltf/gltf-animator.js +10 -2
  196. package/dist/gltf/gltf/gltf-animator.js.map +1 -1
  197. package/dist/gltf/gltf/gltf-gpu-animation-controller.cjs +81 -0
  198. package/dist/gltf/gltf/gltf-gpu-animation-controller.d.ts +9 -0
  199. package/dist/gltf/gltf/gltf-gpu-animation-controller.d.ts.map +1 -0
  200. package/dist/gltf/gltf/gltf-gpu-animation-controller.js +67 -0
  201. package/dist/gltf/gltf/gltf-gpu-animation-controller.js.map +1 -0
  202. package/dist/gltf/gltf/gltf-gpu-animation.cjs +33 -28
  203. package/dist/gltf/gltf/gltf-gpu-animation.d.ts +7 -26
  204. package/dist/gltf/gltf/gltf-gpu-animation.d.ts.map +1 -1
  205. package/dist/gltf/gltf/gltf-gpu-animation.js +29 -28
  206. package/dist/gltf/gltf/gltf-gpu-animation.js.map +1 -1
  207. package/dist/gltf/index.cjs.map +3 -3
  208. package/dist/gltf/index.d.ts +2 -2
  209. package/dist/gltf/index.d.ts.map +1 -1
  210. package/dist/gltf/index.js.map +1 -1
  211. package/dist/gltf/parsers/parse-gltf.cjs +4 -2
  212. package/dist/gltf/parsers/parse-gltf.d.ts +3 -0
  213. package/dist/gltf/parsers/parse-gltf.d.ts.map +1 -1
  214. package/dist/gltf/parsers/parse-gltf.js +7 -2
  215. package/dist/gltf/parsers/parse-gltf.js.map +1 -1
  216. package/dist/graph/models/index.cjs.map +2 -2
  217. package/dist/graph/physics/index.cjs +5 -0
  218. package/dist/graph/physics/index.cjs.map +3 -3
  219. package/dist/graph/physics/index.d.ts +1 -0
  220. package/dist/graph/physics/index.d.ts.map +1 -1
  221. package/dist/graph/physics/index.js +1 -0
  222. package/dist/graph/physics/index.js.map +1 -1
  223. package/dist/graph/physics/physics-controller-geometry.cjs +21 -0
  224. package/dist/graph/physics/physics-controller-geometry.d.ts +8 -1
  225. package/dist/graph/physics/physics-controller-geometry.d.ts.map +1 -1
  226. package/dist/graph/physics/physics-controller-geometry.js +22 -0
  227. package/dist/graph/physics/physics-controller-geometry.js.map +1 -1
  228. package/dist/graph/physics/scenegraph-session.d.ts +1 -1
  229. package/dist/graph/physics/scenegraph-session.d.ts.map +1 -1
  230. package/dist/graph/tables/index.cjs.map +2 -2
  231. package/dist/index.cjs +16 -0
  232. package/dist/index.cjs.map +3 -3
  233. package/dist/index.d.ts +6 -0
  234. package/dist/index.d.ts.map +1 -1
  235. package/dist/index.js +4 -0
  236. package/dist/index.js.map +1 -1
  237. package/dist/lighting/ambient-occlusion-pass.cjs +47 -28
  238. package/dist/lighting/ambient-occlusion-pass.d.ts +12 -0
  239. package/dist/lighting/ambient-occlusion-pass.d.ts.map +1 -1
  240. package/dist/lighting/ambient-occlusion-pass.js +45 -26
  241. package/dist/lighting/ambient-occlusion-pass.js.map +1 -1
  242. package/dist/lighting/clustered-light-grid.cjs +71 -20
  243. package/dist/lighting/clustered-light-grid.d.ts +37 -0
  244. package/dist/lighting/clustered-light-grid.d.ts.map +1 -1
  245. package/dist/lighting/clustered-light-grid.js +68 -18
  246. package/dist/lighting/clustered-light-grid.js.map +1 -1
  247. package/dist/lighting/contact-shadow-composite.cjs +72 -51
  248. package/dist/lighting/contact-shadow-composite.d.ts +274 -3
  249. package/dist/lighting/contact-shadow-composite.d.ts.map +1 -1
  250. package/dist/lighting/contact-shadow-composite.js +72 -50
  251. package/dist/lighting/contact-shadow-composite.js.map +1 -1
  252. package/dist/lighting/contact-shadow-pass.cjs +50 -39
  253. package/dist/lighting/contact-shadow-pass.d.ts +8 -0
  254. package/dist/lighting/contact-shadow-pass.d.ts.map +1 -1
  255. package/dist/lighting/contact-shadow-pass.js +47 -37
  256. package/dist/lighting/contact-shadow-pass.js.map +1 -1
  257. package/dist/lighting/cortao/cortao-occluder-lookup-table.cjs +96 -0
  258. package/dist/lighting/cortao/cortao-occluder-lookup-table.d.ts +41 -0
  259. package/dist/lighting/cortao/cortao-occluder-lookup-table.d.ts.map +1 -0
  260. package/dist/lighting/cortao/cortao-occluder-lookup-table.js +94 -0
  261. package/dist/lighting/cortao/cortao-occluder-lookup-table.js.map +1 -0
  262. package/dist/lighting/cortao/cortao-parameters.cjs +127 -0
  263. package/dist/lighting/cortao/cortao-parameters.d.ts +95 -0
  264. package/dist/lighting/cortao/cortao-parameters.d.ts.map +1 -0
  265. package/dist/lighting/cortao/cortao-parameters.js +122 -0
  266. package/dist/lighting/cortao/cortao-parameters.js.map +1 -0
  267. package/dist/lighting/cortao/cortao-pass.cjs +100 -0
  268. package/dist/lighting/cortao/cortao-pass.d.ts +33 -0
  269. package/dist/lighting/cortao/cortao-pass.d.ts.map +1 -0
  270. package/dist/lighting/cortao/cortao-pass.js +84 -0
  271. package/dist/lighting/cortao/cortao-pass.js.map +1 -0
  272. package/dist/lighting/cortao/cortao-passes.cjs +42 -0
  273. package/dist/lighting/cortao/cortao-passes.d.ts +38 -0
  274. package/dist/lighting/cortao/cortao-passes.d.ts.map +1 -0
  275. package/dist/lighting/cortao/cortao-passes.js +19 -0
  276. package/dist/lighting/cortao/cortao-passes.js.map +1 -0
  277. package/dist/lighting/cortao/cortao-shaders-wgsl.cjs +606 -0
  278. package/dist/lighting/cortao/cortao-shaders-wgsl.d.ts +49 -0
  279. package/dist/lighting/cortao/cortao-shaders-wgsl.d.ts.map +1 -0
  280. package/dist/lighting/cortao/cortao-shaders-wgsl.js +610 -0
  281. package/dist/lighting/cortao/cortao-shaders-wgsl.js.map +1 -0
  282. package/dist/lighting/cortao/cortao-shaders.cjs +667 -0
  283. package/dist/lighting/cortao/cortao-shaders.d.ts +118 -0
  284. package/dist/lighting/cortao/cortao-shaders.d.ts.map +1 -0
  285. package/dist/lighting/cortao/cortao-shaders.js +657 -0
  286. package/dist/lighting/cortao/cortao-shaders.js.map +1 -0
  287. package/dist/lighting/cortao/cortao-upsample.cjs +191 -0
  288. package/dist/lighting/cortao/cortao-upsample.d.ts +16 -0
  289. package/dist/lighting/cortao/cortao-upsample.d.ts.map +1 -0
  290. package/dist/lighting/cortao/cortao-upsample.js +159 -0
  291. package/dist/lighting/cortao/cortao-upsample.js.map +1 -0
  292. package/dist/lighting/cortao/cortao-webgl-passes.cjs +229 -0
  293. package/dist/lighting/cortao/cortao-webgl-passes.d.ts +28 -0
  294. package/dist/lighting/cortao/cortao-webgl-passes.d.ts.map +1 -0
  295. package/dist/lighting/cortao/cortao-webgl-passes.js +212 -0
  296. package/dist/lighting/cortao/cortao-webgl-passes.js.map +1 -0
  297. package/dist/lighting/cortao/cortao-webgpu-passes.cjs +348 -0
  298. package/dist/lighting/cortao/cortao-webgpu-passes.d.ts +31 -0
  299. package/dist/lighting/cortao/cortao-webgpu-passes.d.ts.map +1 -0
  300. package/dist/lighting/cortao/cortao-webgpu-passes.js +335 -0
  301. package/dist/lighting/cortao/cortao-webgpu-passes.js.map +1 -0
  302. package/dist/lighting/index.cjs +13 -2
  303. package/dist/lighting/index.cjs.map +3 -3
  304. package/dist/lighting/index.d.ts +11 -6
  305. package/dist/lighting/index.d.ts.map +1 -1
  306. package/dist/lighting/index.js +6 -5
  307. package/dist/lighting/index.js.map +1 -1
  308. package/dist/lighting/shadow-map-renderer.cjs +40 -37
  309. package/dist/lighting/shadow-map-renderer.d.ts +15 -0
  310. package/dist/lighting/shadow-map-renderer.d.ts.map +1 -1
  311. package/dist/lighting/shadow-map-renderer.js +37 -35
  312. package/dist/lighting/shadow-map-renderer.js.map +1 -1
  313. package/dist/model/gpu-vector-model.cjs +39 -16
  314. package/dist/model/gpu-vector-model.d.ts +8 -0
  315. package/dist/model/gpu-vector-model.d.ts.map +1 -1
  316. package/dist/model/gpu-vector-model.js +46 -18
  317. package/dist/model/gpu-vector-model.js.map +1 -1
  318. package/dist/passes/effect-renderer.cjs +155 -0
  319. package/dist/passes/effect-renderer.d.ts +158 -0
  320. package/dist/passes/effect-renderer.d.ts.map +1 -0
  321. package/dist/passes/effect-renderer.js +143 -0
  322. package/dist/passes/effect-renderer.js.map +1 -0
  323. package/dist/passes/scene-capture-pass.cjs +42 -0
  324. package/dist/passes/scene-capture-pass.d.ts +29 -0
  325. package/dist/passes/scene-capture-pass.d.ts.map +1 -0
  326. package/dist/passes/scene-capture-pass.js +21 -0
  327. package/dist/passes/scene-capture-pass.js.map +1 -0
  328. package/dist/passes/shader-pass-renderer.cjs +94 -68
  329. package/dist/passes/shader-pass-renderer.d.ts +32 -15
  330. package/dist/passes/shader-pass-renderer.d.ts.map +1 -1
  331. package/dist/passes/shader-pass-renderer.js +104 -76
  332. package/dist/passes/shader-pass-renderer.js.map +1 -1
  333. package/dist/scenegraph/model-node.cjs +2 -0
  334. package/dist/scenegraph/model-node.d.ts +4 -0
  335. package/dist/scenegraph/model-node.d.ts.map +1 -1
  336. package/dist/scenegraph/model-node.js +2 -0
  337. package/dist/scenegraph/model-node.js.map +1 -1
  338. package/dist/splats/gpu-paged-splat-renderer.cjs +52 -8
  339. package/dist/splats/gpu-paged-splat-renderer.d.ts +16 -3
  340. package/dist/splats/gpu-paged-splat-renderer.d.ts.map +1 -1
  341. package/dist/splats/gpu-paged-splat-renderer.js +55 -9
  342. package/dist/splats/gpu-paged-splat-renderer.js.map +1 -1
  343. package/dist/splats/gpu-paged-splat-shaders.cjs +3 -1
  344. package/dist/splats/gpu-paged-splat-shaders.d.ts.map +1 -1
  345. package/dist/splats/gpu-paged-splat-shaders.js +3 -1
  346. package/dist/splats/gpu-paged-splat-shaders.js.map +1 -1
  347. package/dist/splats/index.cjs.map +2 -2
  348. package/dist/text/fonts/atlas/browser-font-atlas.cjs +10 -1
  349. package/dist/text/fonts/atlas/browser-font-atlas.d.ts +3 -1
  350. package/dist/text/fonts/atlas/browser-font-atlas.d.ts.map +1 -1
  351. package/dist/text/fonts/atlas/browser-font-atlas.js +10 -2
  352. package/dist/text/fonts/atlas/browser-font-atlas.js.map +1 -1
  353. package/dist/text/fonts/atlas/lru-cache.cjs +4 -0
  354. package/dist/text/fonts/atlas/lru-cache.d.ts +3 -1
  355. package/dist/text/fonts/atlas/lru-cache.d.ts.map +1 -1
  356. package/dist/text/fonts/atlas/lru-cache.js +4 -0
  357. package/dist/text/fonts/atlas/lru-cache.js.map +1 -1
  358. package/dist/text/fonts/index.cjs +2 -0
  359. package/dist/text/fonts/index.cjs.map +1 -1
  360. package/dist/text/fonts/index.d.ts +1 -1
  361. package/dist/text/fonts/index.d.ts.map +1 -1
  362. package/dist/text/fonts/index.js +1 -1
  363. package/dist/text/fonts/index.js.map +1 -1
  364. package/dist/text/index.cjs.map +1 -1
  365. package/package.json +8 -8
  366. package/src/animation/animation-track.ts +5 -0
  367. package/src/animation/node-animation-binding.ts +9 -8
  368. package/src/animation/scenegraph-gpu-animation-layout.ts +195 -0
  369. package/src/animation/scenegraph-gpu-animation.ts +340 -0
  370. package/src/arrow/arrow-picking.ts +23 -11
  371. package/src/effects/README.md +38 -14
  372. package/src/effects/glfx-effects.ts +227 -0
  373. package/src/effects/graph/gpu-effect-operation.ts +601 -0
  374. package/src/effects/graph/temporal-graph-history.ts +46 -0
  375. package/src/effects/index.ts +81 -19
  376. package/src/effects/passes/postprocessing/fxaa/fxaa.ts +8 -0
  377. package/src/effects/passes/postprocessing/image-adjust-filters/tone-mapping.ts +8 -0
  378. package/src/effects/passes/postprocessing/image-blur-filters/bloom-composite-shader-pass.ts +219 -19
  379. package/src/effects/passes/postprocessing/image-blur-filters/bloom-compute-pyramid.ts +6 -6
  380. package/src/effects/passes/screen-space/camera-reprojection-temporal-antialiasing.ts +45 -45
  381. package/src/effects/passes/screen-space/clustered-volumetric-lighting.ts +88 -68
  382. package/src/effects/passes/screen-space/copy-pass.ts +4 -0
  383. package/src/effects/passes/screen-space/depth-aware-blur.ts +13 -3
  384. package/src/effects/passes/screen-space/dof.ts +20 -3
  385. package/src/effects/passes/screen-space/gtao.ts +91 -65
  386. package/src/effects/passes/screen-space/hdr-auto-exposure.ts +109 -84
  387. package/src/effects/passes/screen-space/height-fog.ts +18 -3
  388. package/src/effects/passes/screen-space/motion-blur.ts +8 -7
  389. package/src/effects/passes/screen-space/outlines.ts +143 -17
  390. package/src/effects/passes/screen-space/screen-space-global-illumination.ts +75 -64
  391. package/src/effects/passes/screen-space/screen-space-reflections.ts +158 -95
  392. package/src/effects/passes/screen-space/selection-outline.ts +11 -0
  393. package/src/effects/passes/screen-space/ssao.ts +76 -45
  394. package/src/effects/passes/screen-space/temporal-antialiasing.ts +43 -33
  395. package/src/effects/passes/screen-space/temporal-frame.ts +33 -0
  396. package/src/effects/passes/screen-space/volumetric-fog.ts +30 -24
  397. package/src/effects/temporal-upscale/index.ts +20 -0
  398. package/src/effects/temporal-upscale/temporal-math.ts +308 -0
  399. package/src/effects/temporal-upscale/temporal-upscale-shaders.ts +326 -0
  400. package/src/effects/temporal-upscale/temporal-upscaler.ts +538 -0
  401. package/src/gltf/gltf/create-gltf-model.ts +59 -90
  402. package/src/gltf/gltf/create-scenegraph-from-gltf.ts +71 -5
  403. package/src/gltf/gltf/gltf-animated-crowd.ts +30 -177
  404. package/src/gltf/gltf/gltf-animation-nodes.ts +82 -0
  405. package/src/gltf/gltf/gltf-animator.ts +15 -4
  406. package/src/gltf/gltf/gltf-gpu-animation-controller.ts +88 -0
  407. package/src/gltf/gltf/gltf-gpu-animation.ts +53 -60
  408. package/src/gltf/index.ts +5 -0
  409. package/src/gltf/parsers/parse-gltf.ts +12 -2
  410. package/src/graph/physics/index.ts +4 -0
  411. package/src/graph/physics/physics-controller-geometry.ts +33 -1
  412. package/src/index.ts +25 -0
  413. package/src/lighting/ambient-occlusion-pass.ts +62 -28
  414. package/src/lighting/clustered-light-grid.ts +87 -30
  415. package/src/lighting/contact-shadow-composite.ts +80 -52
  416. package/src/lighting/contact-shadow-pass.ts +59 -39
  417. package/src/lighting/cortao/cortao-occluder-lookup-table.ts +138 -0
  418. package/src/lighting/cortao/cortao-parameters.ts +218 -0
  419. package/src/lighting/cortao/cortao-pass.ts +136 -0
  420. package/src/lighting/cortao/cortao-passes.ts +50 -0
  421. package/src/lighting/cortao/cortao-shaders-wgsl.ts +633 -0
  422. package/src/lighting/cortao/cortao-shaders.ts +674 -0
  423. package/src/lighting/cortao/cortao-upsample.ts +177 -0
  424. package/src/lighting/cortao/cortao-webgl-passes.ts +284 -0
  425. package/src/lighting/cortao/cortao-webgpu-passes.ts +430 -0
  426. package/src/lighting/index.ts +12 -3
  427. package/src/lighting/shadow-map-renderer.ts +57 -43
  428. package/src/model/gpu-vector-model.ts +47 -18
  429. package/src/passes/effect-renderer.ts +332 -0
  430. package/src/passes/scene-capture-pass.ts +51 -0
  431. package/src/passes/shader-pass-renderer.ts +164 -115
  432. package/src/scenegraph/model-node.ts +5 -0
  433. package/src/splats/gpu-paged-splat-renderer.ts +77 -9
  434. package/src/splats/gpu-paged-splat-shaders.ts +7 -1
  435. package/src/text/fonts/atlas/browser-font-atlas.ts +12 -2
  436. package/src/text/fonts/atlas/lru-cache.ts +6 -1
  437. package/src/text/fonts/index.ts +1 -0
package/dist/dist.dev.js CHANGED
@@ -83,6 +83,7 @@ var __exports__ = (() => {
83
83
  DirectionalLightModel: () => DirectionalLightModel,
84
84
  DynamicBuffer: () => DynamicBuffer,
85
85
  DynamicTexture: () => DynamicTexture,
86
+ EffectRenderer: () => EffectRenderer,
86
87
  GPUGeometry: () => GPUGeometry,
87
88
  GPUVectorGeometry: () => GPUVectorGeometry,
88
89
  GPUVectorModel: () => GPUVectorModel,
@@ -108,6 +109,7 @@ var __exports__ = (() => {
108
109
  RingGeometry: () => RingGeometry,
109
110
  SceneMetadata: () => SceneMetadata,
110
111
  ScenegraphAnimator: () => ScenegraphAnimator,
112
+ ScenegraphGPUAnimationResources: () => ScenegraphGPUAnimationResources,
111
113
  ScenegraphInteractionManager: () => ScenegraphInteractionManager,
112
114
  ScenegraphNode: () => ScenegraphNode,
113
115
  ShaderInputs: () => ShaderInputs,
@@ -125,6 +127,7 @@ var __exports__ = (() => {
125
127
  VideoTexture: () => VideoTexture,
126
128
  _resolveLoadFileUrl: () => _resolveLoadFileUrl,
127
129
  applyMorphTargets: () => applyMorphTargets,
130
+ bakeScenegraphGPUAnimation: () => bakeScenegraphGPUAnimation,
128
131
  cancelAnimationFramePolyfill: () => cancelAnimationFramePolyfill,
129
132
  colorPicking: () => picking,
130
133
  createAreaLightLTCTextures: () => createAreaLightLTCTextures,
@@ -133,11 +136,13 @@ var __exports__ = (() => {
133
136
  decodeMorphTargetAttribute: () => decodeMorphTargetAttribute,
134
137
  decomposePhysicsTransform: () => decomposePhysicsTransform,
135
138
  deformPositions: () => deformPositions,
139
+ encodeSceneCapturePass: () => encodeSceneCapturePass,
136
140
  evaluateAnimationSampler: () => evaluateAnimationSampler,
137
141
  getFirstScenegraphInteractionHit: () => getFirstScenegraphInteractionHit,
138
142
  getGPUVectorModelBatches: () => getGPUVectorModelBatches,
139
143
  getIndexPickingModule: () => getIndexPickingModule,
140
144
  getPlatformInfo: () => getPlatformInfo,
145
+ getScenegraphGPUPlaybackClip: () => getScenegraphGPUPlaybackClip,
141
146
  getTextureTransformDeltaMatrix: () => getTextureTransformDeltaMatrix,
142
147
  getTextureTransformMatrix: () => getTextureTransformMatrix,
143
148
  indexColorPicking: () => picking2,
@@ -160,6 +165,7 @@ var __exports__ = (() => {
160
165
  makeStrokeGeometry: () => makeStrokeGeometry,
161
166
  makeTextureTransformAnimationBinding: () => makeTextureTransformAnimationBinding,
162
167
  picking: () => picking4,
168
+ planScenegraphGPUAnimation: () => planScenegraphGPUAnimation,
163
169
  publishedTransforms: () => publishedTransforms,
164
170
  readPhysicsRotation: () => readPhysicsRotation,
165
171
  readPhysicsVector: () => readPhysicsVector,
@@ -658,99 +664,79 @@ var __exports__ = (() => {
658
664
  }
659
665
  };
660
666
 
661
- // ../../node_modules/@math.gl/core/dist/types/typed-array-brand.js
662
- var typedArrayTagGetter = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Uint8Array.prototype), Symbol.toStringTag).get;
663
- function getTypedArrayName(value) {
664
- return ArrayBuffer.isView(value) ? typedArrayTagGetter.call(value) : void 0;
665
- }
666
-
667
- // ../../node_modules/@math.gl/core/dist/types/is-array.js
668
- function isTypedArray(value) {
669
- const name = getTypedArrayName(value);
670
- return name !== void 0 && name !== "BigInt64Array" && name !== "BigUint64Array";
671
- }
672
-
673
- // ../../node_modules/@math.gl/geometry/dist/lib/geometry.js
674
- var geometryId = 0;
675
- var Geometry = class {
676
- constructor(props) {
677
- this.userData = {};
678
- this.id = props.id || `geometry-${++geometryId}`;
679
- this.topology = props.topology;
680
- this.attributes = {};
681
- let indices = props.indices ? normalizeAttribute(props.indices) : void 0;
682
- for (const [name, input] of Object.entries(props.attributes || {})) {
683
- const attribute = normalizeAttribute(input);
684
- if (name === "POSITION" || name === "positions") {
685
- attribute.size || (attribute.size = 3);
686
- }
687
- if (name === "indices") {
688
- if (indices)
689
- throw new Error("Geometry has multiple index attributes");
690
- indices = attribute;
691
- } else {
692
- this.attributes[name] = attribute;
693
- }
694
- }
695
- if (indices) {
696
- if (!(indices.value instanceof Uint16Array || indices.value instanceof Uint32Array)) {
697
- throw new Error("Geometry indices must be a Uint16Array or Uint32Array");
698
- }
699
- indices.size = 1;
700
- this.indices = indices;
701
- validateIndices(indices, this.attributes);
702
- }
703
- this.vertexCount = props.vertexCount ?? calculateVertexCount(this.attributes, this.indices);
704
- if (!Number.isInteger(this.vertexCount) || this.vertexCount < 0) {
705
- throw new Error("Geometry vertexCount must be a non-negative integer");
706
- }
707
- }
708
- getVertexCount() {
709
- return this.vertexCount;
667
+ // src/animation/scenegraph-gpu-animation-layout.ts
668
+ function planScenegraphGPUAnimation(timings, primitives, options = {}, device) {
669
+ const reject = (fallbackReason, estimatedByteLength2 = 0) => ({ layout: null, estimatedByteLength: estimatedByteLength2, fallbackReason });
670
+ if (options.enabled === false) {
671
+ return reject("disabled");
710
672
  }
711
- getAttributes() {
712
- return this.indices ? { indices: this.indices, ...this.attributes } : this.attributes;
673
+ if (!timings.length) {
674
+ return reject("no-animations");
713
675
  }
714
- };
715
- function normalizeAttribute(input) {
716
- const attribute = isTypedArray(input) ? { value: input } : { ...input };
717
- if (!isTypedArray(attribute.value)) {
718
- throw new Error("Geometry attributes must contain a typed-array value");
676
+ const sampleRate = options.sampleRate ?? 30;
677
+ const maxFrames = options.maxFrames ?? 8192;
678
+ const maxBytes = options.maxBytes ?? 64 * 1024 * 1024;
679
+ if (!Number.isFinite(sampleRate) || sampleRate <= 0 || !Number.isSafeInteger(maxFrames) || maxFrames <= 0 || !Number.isSafeInteger(maxBytes) || maxBytes <= 0) {
680
+ return reject("invalid-options");
719
681
  }
720
- if (attribute.size !== void 0 && (!Number.isInteger(attribute.size) || attribute.size < 1)) {
721
- throw new Error("Geometry attribute size must be a positive integer");
682
+ if (new Set(timings.map((timing) => timing.name)).size !== timings.length) {
683
+ return reject("unsupported-scene");
722
684
  }
723
- if (attribute.size && attribute.value.length % attribute.size !== 0) {
724
- throw new Error("Geometry attribute length must be divisible by its size");
685
+ let frameCount = 0;
686
+ const clips = [];
687
+ for (const { name, duration } of timings) {
688
+ if (!Number.isFinite(duration) || duration < 0) {
689
+ return reject("invalid-animation");
690
+ }
691
+ const clipFrameCount = Math.max(1, Math.ceil(duration * sampleRate) + 1);
692
+ if (!Number.isSafeInteger(clipFrameCount) || frameCount + clipFrameCount > maxFrames) {
693
+ return reject("frame-budget");
694
+ }
695
+ clips.push({
696
+ name,
697
+ duration,
698
+ frameOffset: frameCount,
699
+ frameCount: clipFrameCount
700
+ });
701
+ frameCount += clipFrameCount;
725
702
  }
726
- return attribute;
727
- }
728
- function validateIndices(indices, attributes) {
729
- let maximumIndex = -1;
730
- for (const index of indices.value)
731
- maximumIndex = Math.max(maximumIndex, Number(index));
732
- for (const [name, attribute] of Object.entries(attributes)) {
733
- if (!attribute.constant && attribute.size) {
734
- const attributeVertexCount = attribute.value.length / attribute.size;
735
- if (maximumIndex >= attributeVertexCount) {
736
- throw new Error(`Geometry index ${maximumIndex} exceeds ${name} vertex count ${attributeVertexCount}`);
737
- }
703
+ let estimatedByteLength = 0;
704
+ let maximumAtlasByteLength = 0;
705
+ let maximumFrameStride = 0;
706
+ for (const { jointCount, morphTargetCount, count = 1 } of primitives) {
707
+ if (!Number.isSafeInteger(jointCount) || jointCount < 0 || !Number.isSafeInteger(morphTargetCount) || morphTargetCount < 0 || !Number.isSafeInteger(count) || count < 1) {
708
+ return reject("invalid-options");
738
709
  }
710
+ const frameStride = getScenegraphGPUAnimationFrameStride(jointCount, morphTargetCount);
711
+ const atlasByteLength = frameCount * frameStride * 16;
712
+ maximumFrameStride = Math.max(maximumFrameStride, frameStride);
713
+ maximumAtlasByteLength = Math.max(maximumAtlasByteLength, atlasByteLength);
714
+ estimatedByteLength += atlasByteLength * count;
739
715
  }
740
- }
741
- function calculateVertexCount(attributes, indices) {
742
- if (indices)
743
- return indices.value.length;
744
- let count = Infinity;
745
- for (const attribute of Object.values(attributes)) {
746
- if (!attribute.constant && attribute.size) {
747
- count = Math.min(count, attribute.value.length / attribute.size);
716
+ if (!Number.isSafeInteger(estimatedByteLength) || estimatedByteLength > maxBytes) {
717
+ return reject("byte-budget", estimatedByteLength);
718
+ }
719
+ if (device?.type === "webgpu") {
720
+ if (maximumAtlasByteLength > Math.min(device.limits.maxBufferSize, device.limits.maxStorageBufferBindingSize)) {
721
+ return reject("buffer-limit", estimatedByteLength);
748
722
  }
723
+ } else if (device && (maximumFrameStride > device.limits.maxTextureDimension2D || frameCount > device.limits.maxTextureDimension2D)) {
724
+ return reject("texture-limit", estimatedByteLength);
749
725
  }
750
- if (!Number.isFinite(count))
751
- throw new Error("Geometry has no countable attributes");
752
- return count;
726
+ return { layout: { sampleRate, frameCount, clips }, estimatedByteLength };
727
+ }
728
+ function getScenegraphGPUAnimationFrameStride(jointCount, morphTargetCount) {
729
+ return 4 + jointCount * 4 + morphTargetCount;
753
730
  }
731
+ function getScenegraphGPUAnimationFrames(clip, time, sampleRate) {
732
+ const frame = Math.min(Math.max(time, 0) * sampleRate, clip.frameCount - 1);
733
+ const firstFrame = Math.floor(frame);
734
+ const secondFrame = Math.min(firstFrame + 1, clip.frameCount - 1);
735
+ return [clip.frameOffset + firstFrame, clip.frameOffset + secondFrame, frame - firstFrame];
736
+ }
737
+
738
+ // src/animation/scenegraph-gpu-animation.ts
739
+ var import_core6 = __toESM(require_core(), 1);
754
740
 
755
741
  // ../../node_modules/@math.gl/core/dist/lib/common.js
756
742
  var RADIANS_TO_DEGREES = 1 / Math.PI * 180;
@@ -2426,6 +2412,54 @@ var __exports__ = (() => {
2426
2412
  return out;
2427
2413
  }
2428
2414
  var ortho = orthoNO;
2415
+ function lookAtXAxis(out, upx, upy, upz, r0, r1, r2, z0, z1, z2) {
2416
+ if (!r0 && !r1 && !r2 || !upx && !upy && !upz) {
2417
+ return normalizeAxis(out, 0, 0, 0);
2418
+ }
2419
+ if (upy * r2 - upz * r1 !== 0 || upz * r0 - upx * r2 !== 0 || upx * r1 - upy * r0 !== 0) {
2420
+ normalizeAxis(out, upy * z2 - upz * z1, upz * z0 - upx * z2, upx * z1 - upy * z0);
2421
+ if (out[0] || out[1] || out[2]) {
2422
+ return out;
2423
+ }
2424
+ }
2425
+ const a0 = Math.abs(z0);
2426
+ const a1 = Math.abs(z1);
2427
+ const a2 = Math.abs(z2);
2428
+ const sign = a0 >= a1 && a0 >= a2 ? Math.sign(upx) * Math.sign(z0) : a1 >= a2 ? Math.sign(upy) * Math.sign(z1) : Math.sign(upz) * Math.sign(z2);
2429
+ if (a2 <= a0 && a2 <= a1) {
2430
+ return normalizeAxis(out, sign * z1, -sign * z0, 0);
2431
+ }
2432
+ if (a0 <= a1) {
2433
+ return normalizeAxis(out, 0, sign * z2, -sign * z1);
2434
+ }
2435
+ return normalizeAxis(out, -sign * z2, 0, sign * z0);
2436
+ }
2437
+ function normalizeAxis(out, x0, x1, x2) {
2438
+ let len2 = x0 * x0 + x1 * x1 + x2 * x2;
2439
+ if (len2 === 0 || len2 === Infinity) {
2440
+ const max = Math.max(Math.abs(x0), Math.abs(x1), Math.abs(x2));
2441
+ if (!max || max === Infinity) {
2442
+ len2 = 0;
2443
+ } else {
2444
+ x0 /= max;
2445
+ x1 /= max;
2446
+ x2 /= max;
2447
+ len2 = x0 * x0 + x1 * x1 + x2 * x2;
2448
+ }
2449
+ }
2450
+ if (len2 > 0) {
2451
+ len2 = 1 / Math.sqrt(len2);
2452
+ out[0] = x0 * len2;
2453
+ out[1] = x1 * len2;
2454
+ out[2] = x2 * len2;
2455
+ } else {
2456
+ out[0] = 0;
2457
+ out[1] = 0;
2458
+ out[2] = 0;
2459
+ }
2460
+ return out;
2461
+ }
2462
+ var lookAtAxis = [0, 0, 0];
2429
2463
  function lookAt(out, eye, center, up) {
2430
2464
  let len2;
2431
2465
  let x0;
@@ -2452,24 +2486,14 @@ var __exports__ = (() => {
2452
2486
  z0 = eyex - centerx;
2453
2487
  z1 = eyey - centery;
2454
2488
  z2 = eyez - centerz;
2489
+ const r0 = z0;
2490
+ const r1 = z1;
2491
+ const r2 = z2;
2455
2492
  len2 = 1 / Math.sqrt(z0 * z0 + z1 * z1 + z2 * z2);
2456
2493
  z0 *= len2;
2457
2494
  z1 *= len2;
2458
2495
  z2 *= len2;
2459
- x0 = upy * z2 - upz * z1;
2460
- x1 = upz * z0 - upx * z2;
2461
- x2 = upx * z1 - upy * z0;
2462
- len2 = Math.sqrt(x0 * x0 + x1 * x1 + x2 * x2);
2463
- if (!len2) {
2464
- x0 = 0;
2465
- x1 = 0;
2466
- x2 = 0;
2467
- } else {
2468
- len2 = 1 / len2;
2469
- x0 *= len2;
2470
- x1 *= len2;
2471
- x2 *= len2;
2472
- }
2496
+ [x0, x1, x2] = lookAtXAxis(lookAtAxis, upx, upy, upz, r0, r1, r2, z0, z1, z2);
2473
2497
  y0 = z1 * x2 - z2 * x1;
2474
2498
  y1 = z2 * x0 - z0 * x2;
2475
2499
  y2 = z0 * x1 - z1 * x0;
@@ -3565,118 +3589,614 @@ var __exports__ = (() => {
3565
3589
  }
3566
3590
  };
3567
3591
 
3568
- // ../../node_modules/@math.gl/geometry/dist/geometries/geometry-helpers.js
3569
- function assertPositive(value, name) {
3570
- if (!Number.isFinite(value) || value <= 0)
3571
- throw new Error(`${name} must be greater than zero`);
3572
- }
3573
- function assertNonNegative(value, name) {
3574
- if (!Number.isFinite(value) || value < 0)
3575
- throw new Error(`${name} must be non-negative`);
3576
- }
3577
- function assertSegments(value, name, minimum = 1) {
3578
- if (!Number.isInteger(value) || value < minimum)
3579
- throw new Error(`${name} must be an integer >= ${minimum}`);
3580
- }
3581
- function makeIndices(vertexCount, values) {
3582
- return vertexCount > 65535 ? new Uint32Array(values) : new Uint16Array(values);
3592
+ // src/scenegraph/group-node.ts
3593
+ var import_core2 = __toESM(require_core(), 1);
3594
+
3595
+ // src/utils/uid.ts
3596
+ var uidCounters = {};
3597
+ function uid(id = "id") {
3598
+ uidCounters[id] = uidCounters[id] || 1;
3599
+ const count = uidCounters[id]++;
3600
+ return `${id}-${count}`;
3583
3601
  }
3584
3602
 
3585
- // ../../node_modules/@math.gl/geometry/dist/geometries/box-geometry.js
3586
- var BoxGeometry = class extends Geometry {
3587
- constructor(props = {}) {
3588
- const size = props.size || [1, 1, 1];
3589
- assertPositive(size[0], "size[0]");
3590
- assertPositive(size[1], "size[1]");
3591
- assertPositive(size[2], "size[2]");
3592
- const half = [size[0] / 2, size[1] / 2, size[2] / 2];
3593
- const positions = [];
3594
- const normals = [];
3595
- const texCoords = [];
3596
- const indices = [];
3597
- const faces = [
3598
- { n: [1, 0, 0], u: [0, 0, -1], v: [0, 1, 0], h1: half[2], h2: half[1] },
3599
- { n: [-1, 0, 0], u: [0, 0, 1], v: [0, 1, 0], h1: half[2], h2: half[1] },
3600
- { n: [0, 1, 0], u: [1, 0, 0], v: [0, 0, -1], h1: half[0], h2: half[2] },
3601
- { n: [0, -1, 0], u: [1, 0, 0], v: [0, 0, 1], h1: half[0], h2: half[2] },
3602
- { n: [0, 0, 1], u: [1, 0, 0], v: [0, 1, 0], h1: half[0], h2: half[1] },
3603
- { n: [0, 0, -1], u: [-1, 0, 0], v: [0, 1, 0], h1: half[0], h2: half[1] }
3604
- ];
3605
- for (const face of faces) {
3606
- const base = positions.length / 3;
3607
- for (const [s, t, u, v] of [
3608
- [-1, -1, 0, 0],
3609
- [1, -1, 1, 0],
3610
- [1, 1, 1, 1],
3611
- [-1, 1, 0, 1]
3612
- ]) {
3613
- positions.push(face.n[0] * half[0] + face.u[0] * face.h1 * s + face.v[0] * face.h2 * t, face.n[1] * half[1] + face.u[1] * face.h1 * s + face.v[1] * face.h2 * t, face.n[2] * half[2] + face.u[2] * face.h1 * s + face.v[2] * face.h2 * t);
3614
- normals.push(...face.n);
3615
- texCoords.push(u, v);
3616
- }
3617
- indices.push(base, base + 1, base + 2, base, base + 2, base + 3);
3618
- }
3619
- super({
3620
- id: props.id,
3621
- topology: "triangle-list",
3622
- indices: makeIndices(24, indices),
3623
- attributes: {
3624
- POSITION: { size: 3, value: new Float32Array(positions) },
3625
- NORMAL: { size: 3, value: new Float32Array(normals) },
3626
- TEXCOORD_0: { size: 2, value: new Float32Array(texCoords) },
3627
- ...props.attributes
3628
- }
3629
- });
3603
+ // src/scenegraph/scenegraph-node.ts
3604
+ function assert2(condition, message) {
3605
+ if (!condition) {
3606
+ throw new Error(message);
3630
3607
  }
3631
- };
3632
- var CubeGeometry = class extends BoxGeometry {
3608
+ }
3609
+ var ScenegraphNode = class {
3610
+ id;
3611
+ matrix = new Matrix4();
3612
+ display = true;
3613
+ /** Local selection eligibility, independent of visibility. */
3614
+ selectable = true;
3615
+ /** Local hover eligibility, independent of visibility. */
3616
+ hoverable = true;
3617
+ position = new Vector3();
3618
+ rotation = new Vector3();
3619
+ scale = new Vector3(1, 1, 1);
3620
+ /** Structured metadata associated with this scene node. */
3621
+ metadata = {};
3622
+ userData = {};
3623
+ props = {};
3633
3624
  constructor(props = {}) {
3634
- const size = props.size ?? 1;
3635
- super({ ...props, size: [size, size, size] });
3625
+ const { id } = props;
3626
+ this.id = id || uid(this.constructor.name);
3627
+ this._setScenegraphNodeProps(props);
3636
3628
  }
3637
- };
3638
-
3639
- // ../../node_modules/@math.gl/geometry/dist/geometries/surface-of-revolution.js
3640
- function makeSurfaceOfRevolution(rings, nradial) {
3641
- const positions = [];
3642
- const normals = [];
3643
- const texCoords = [];
3644
- const indices = [];
3645
- const stride = nradial + 1;
3646
- for (let ringIndex = 0; ringIndex < rings.length; ringIndex++) {
3647
- const ring = rings[ringIndex];
3648
- for (let radial = 0; radial <= nradial; radial++) {
3649
- const u = radial / nradial;
3650
- const angle2 = u * Math.PI * 2;
3651
- const sin = Math.sin(angle2);
3652
- const cos = Math.cos(angle2);
3653
- positions.push(sin * ring.radius, ring.y, cos * ring.radius);
3654
- normals.push(sin * ring.normalRadius, ring.normalY, cos * ring.normalRadius);
3655
- texCoords.push(u, ringIndex / (rings.length - 1));
3656
- }
3629
+ getBounds() {
3630
+ return null;
3657
3631
  }
3658
- for (let ring = 0; ring < rings.length - 1; ring++) {
3659
- for (let radial = 0; radial < nradial; radial++) {
3660
- const a = ring * stride + radial;
3661
- const b = a + 1;
3662
- const c = a + stride;
3663
- const d = c + 1;
3664
- indices.push(a, b, d, a, d, c);
3665
- }
3632
+ destroy() {
3666
3633
  }
3667
- return {
3668
- ...{ positions, normals, texCoords, indices },
3669
- indexArray: makeIndices(positions.length / 3, indices)
3670
- };
3671
- }
3672
-
3673
- // ../../node_modules/@math.gl/geometry/dist/geometries/truncated-cone-geometry.js
3674
- var TruncatedConeGeometry = class extends Geometry {
3675
- constructor(props = {}) {
3676
- const { topRadius = 0, bottomRadius = 0, topCap = false, bottomCap = false, height = 1, nradial = 10, nvertical = 1, verticalAxis = "y" } = props;
3677
- assertNonNegative(topRadius, "topRadius");
3678
- assertNonNegative(bottomRadius, "bottomRadius");
3679
- if (topRadius === 0 && bottomRadius === 0)
3634
+ /** @deprecated use .destroy() */
3635
+ delete() {
3636
+ this.destroy();
3637
+ }
3638
+ setProps(props) {
3639
+ this._setScenegraphNodeProps(props);
3640
+ return this;
3641
+ }
3642
+ toString() {
3643
+ return `{type: ScenegraphNode, id: ${this.id})}`;
3644
+ }
3645
+ setPosition(position) {
3646
+ assert2(position.length === 3, "setPosition requires vector argument");
3647
+ this.position = position;
3648
+ return this;
3649
+ }
3650
+ setRotation(rotation) {
3651
+ assert2(rotation.length === 3 || rotation.length === 4, "setRotation requires vector argument");
3652
+ this.rotation = rotation;
3653
+ return this;
3654
+ }
3655
+ setScale(scale5) {
3656
+ assert2(scale5.length === 3, "setScale requires vector argument");
3657
+ this.scale = scale5;
3658
+ return this;
3659
+ }
3660
+ setMatrix(matrix, copyMatrix = true) {
3661
+ if (copyMatrix) {
3662
+ this.matrix.copy(matrix);
3663
+ } else {
3664
+ this.matrix = matrix;
3665
+ }
3666
+ }
3667
+ setMatrixComponents(components2) {
3668
+ const { position, rotation, scale: scale5, update = true } = components2;
3669
+ if (position) {
3670
+ this.setPosition(position);
3671
+ }
3672
+ if (rotation) {
3673
+ this.setRotation(rotation);
3674
+ }
3675
+ if (scale5) {
3676
+ this.setScale(scale5);
3677
+ }
3678
+ if (update) {
3679
+ this.updateMatrix();
3680
+ }
3681
+ return this;
3682
+ }
3683
+ updateMatrix() {
3684
+ this.matrix.identity();
3685
+ this.matrix.translate(this.position);
3686
+ if (this.rotation.length === 4) {
3687
+ const rotationMatrix = new Matrix4().fromQuaternion(this.rotation);
3688
+ this.matrix.multiplyRight(rotationMatrix);
3689
+ } else {
3690
+ this.matrix.rotateXYZ(this.rotation);
3691
+ }
3692
+ this.matrix.scale(this.scale);
3693
+ return this;
3694
+ }
3695
+ update({ position, rotation, scale: scale5 } = {}) {
3696
+ if (position) {
3697
+ this.setPosition(position);
3698
+ }
3699
+ if (rotation) {
3700
+ this.setRotation(rotation);
3701
+ }
3702
+ if (scale5) {
3703
+ this.setScale(scale5);
3704
+ }
3705
+ this.updateMatrix();
3706
+ return this;
3707
+ }
3708
+ getCoordinateUniforms(viewMatrix, modelMatrix) {
3709
+ modelMatrix = modelMatrix || this.matrix;
3710
+ const worldMatrix = new Matrix4(viewMatrix).multiplyRight(modelMatrix);
3711
+ const worldInverse = worldMatrix.invert();
3712
+ const worldInverseTranspose = worldInverse.transpose();
3713
+ return {
3714
+ viewMatrix,
3715
+ modelMatrix,
3716
+ objectMatrix: modelMatrix,
3717
+ worldMatrix,
3718
+ worldInverseMatrix: worldInverse,
3719
+ worldInverseTransposeMatrix: worldInverseTranspose
3720
+ };
3721
+ }
3722
+ // TODO - copied code, not yet vetted
3723
+ /*
3724
+ transform() {
3725
+ if (!this.parent) {
3726
+ this.endPosition.set(this.position);
3727
+ this.endRotation.set(this.rotation);
3728
+ this.endScale.set(this.scale);
3729
+ } else {
3730
+ const parent = this.parent;
3731
+ this.endPosition.set(this.position.add(parent.endPosition));
3732
+ this.endRotation.set(this.rotation.add(parent.endRotation));
3733
+ this.endScale.set(this.scale.add(parent.endScale));
3734
+ }
3735
+
3736
+ const ch = this.children;
3737
+ for (let i = 0; i < ch.length; ++i) {
3738
+ ch[i].transform();
3739
+ }
3740
+
3741
+ return this;
3742
+ }
3743
+ */
3744
+ _setScenegraphNodeProps(props) {
3745
+ if (props.selectable !== void 0) this.selectable = props.selectable;
3746
+ if (props.hoverable !== void 0) this.hoverable = props.hoverable;
3747
+ if (props.display !== void 0) {
3748
+ this.display = props.display;
3749
+ }
3750
+ if (props?.position) {
3751
+ this.setPosition(props.position);
3752
+ }
3753
+ if (props?.rotation) {
3754
+ this.setRotation(props.rotation);
3755
+ }
3756
+ if (props?.scale) {
3757
+ this.setScale(props.scale);
3758
+ }
3759
+ this.updateMatrix();
3760
+ if (props?.matrix) {
3761
+ this.setMatrix(props.matrix);
3762
+ }
3763
+ Object.assign(this.props, props);
3764
+ }
3765
+ };
3766
+
3767
+ // src/scenegraph/scenegraph-bounds.ts
3768
+ function makeEmptyScenegraphBounds() {
3769
+ return [
3770
+ [Infinity, Infinity, Infinity],
3771
+ [-Infinity, -Infinity, -Infinity]
3772
+ ];
3773
+ }
3774
+ function expandScenegraphBounds(targetBounds, sourceBounds, transform) {
3775
+ const transformMatrix = new Matrix4(transform);
3776
+ for (let cornerIndex = 0; cornerIndex < 8; cornerIndex++) {
3777
+ const corner = new Vector3(
3778
+ sourceBounds[cornerIndex & 1 ? 1 : 0][0],
3779
+ sourceBounds[cornerIndex & 2 ? 1 : 0][1],
3780
+ sourceBounds[cornerIndex & 4 ? 1 : 0][2]
3781
+ );
3782
+ transformMatrix.transformAsPoint(corner, corner);
3783
+ for (let componentIndex = 0; componentIndex < 3; componentIndex++) {
3784
+ targetBounds[0][componentIndex] = Math.min(
3785
+ targetBounds[0][componentIndex],
3786
+ corner[componentIndex]
3787
+ );
3788
+ targetBounds[1][componentIndex] = Math.max(
3789
+ targetBounds[1][componentIndex],
3790
+ corner[componentIndex]
3791
+ );
3792
+ }
3793
+ }
3794
+ }
3795
+ function areScenegraphBoundsDefined(bounds) {
3796
+ return Number.isFinite(bounds[0][0]);
3797
+ }
3798
+
3799
+ // src/scenegraph/group-node.ts
3800
+ var GroupNode = class _GroupNode extends ScenegraphNode {
3801
+ children;
3802
+ /** Optional evaluated GPU poses; authored matrices remain unchanged. */
3803
+ transformSource;
3804
+ constructor(props = {}) {
3805
+ props = Array.isArray(props) ? { children: props } : props;
3806
+ const { children = [] } = props;
3807
+ import_core2.log.assert(
3808
+ children.every((child) => child instanceof ScenegraphNode),
3809
+ "every child must an instance of ScenegraphNode"
3810
+ );
3811
+ super(props);
3812
+ this.children = children;
3813
+ this.transformSource = props.transformSource ?? null;
3814
+ }
3815
+ getBounds() {
3816
+ const result = makeEmptyScenegraphBounds();
3817
+ this.traverse((node, { worldMatrix }) => {
3818
+ const bounds = node.getBounds();
3819
+ if (!bounds) {
3820
+ return;
3821
+ }
3822
+ const nodeWorldMatrix = new Matrix4(worldMatrix).multiplyRight(node.matrix);
3823
+ expandScenegraphBounds(result, bounds, nodeWorldMatrix);
3824
+ });
3825
+ return areScenegraphBoundsDefined(result) ? result : null;
3826
+ }
3827
+ destroy() {
3828
+ this.children.forEach((child) => child.destroy());
3829
+ this.removeAll();
3830
+ super.destroy();
3831
+ }
3832
+ // Unpacks arrays and nested arrays of children
3833
+ add(...children) {
3834
+ for (const child of children) {
3835
+ if (Array.isArray(child)) {
3836
+ this.add(...child);
3837
+ } else {
3838
+ this.children.push(child);
3839
+ }
3840
+ }
3841
+ return this;
3842
+ }
3843
+ remove(child) {
3844
+ const children = this.children;
3845
+ const indexOf = children.indexOf(child);
3846
+ if (indexOf > -1) {
3847
+ children.splice(indexOf, 1);
3848
+ }
3849
+ return this;
3850
+ }
3851
+ removeAll() {
3852
+ this.children = [];
3853
+ return this;
3854
+ }
3855
+ /** Resolve one exact ID or path. Missing nodes return undefined; ambiguous paths throw. */
3856
+ findNode(path) {
3857
+ const matches = this.findNodes(path);
3858
+ if (matches.length > 1) {
3859
+ throw new Error(`Ambiguous scenegraph path: ${path} (${matches.length} matches)`);
3860
+ }
3861
+ return matches[0];
3862
+ }
3863
+ /** Find structural matches in preorder, including hidden nodes and the search root. */
3864
+ findNodes(path) {
3865
+ const anchored = path.startsWith("/");
3866
+ const segments = path === "/" ? [] : (anchored ? path.slice(1) : path).split("/").map((segment) => {
3867
+ if (!segment || /~(?![01])/.test(segment)) {
3868
+ throw new Error(`Invalid scenegraph path: ${path}`);
3869
+ }
3870
+ return segment.replace(/~1/g, "/").replace(/~0/g, "~");
3871
+ });
3872
+ const matches = [];
3873
+ const ancestors = [];
3874
+ const visited = /* @__PURE__ */ new Set();
3875
+ const pending = [{ node: this, depth: 0 }];
3876
+ while (pending.length) {
3877
+ const { node, depth } = pending.pop();
3878
+ (0, import_core2.assert)(!visited.has(node));
3879
+ visited.add(node);
3880
+ ancestors.length = depth;
3881
+ ancestors.push(node.id);
3882
+ const offset = ancestors.length - segments.length;
3883
+ if ((anchored ? offset === 1 : offset >= 0) && segments.every((segment, index) => segment === ancestors[offset + index])) {
3884
+ matches.push(node);
3885
+ }
3886
+ if (node instanceof _GroupNode) {
3887
+ for (let index = node.children.length - 1; index >= 0; index--) {
3888
+ pending.push({ node: node.children[index], depth: depth + 1 });
3889
+ }
3890
+ }
3891
+ }
3892
+ return matches;
3893
+ }
3894
+ traverse(visitor, { worldMatrix = new Matrix4() } = {}) {
3895
+ if (!this.display) {
3896
+ return;
3897
+ }
3898
+ const modelMatrix = new Matrix4(worldMatrix).multiplyRight(this.matrix);
3899
+ for (const child of this.children) {
3900
+ if (!child.display) {
3901
+ continue;
3902
+ }
3903
+ if (child instanceof _GroupNode) {
3904
+ child.traverse(visitor, { worldMatrix: modelMatrix });
3905
+ } else {
3906
+ visitor(child, { worldMatrix: modelMatrix });
3907
+ }
3908
+ }
3909
+ }
3910
+ /** Visits leaf nodes ordered by the camera-space centers of their aggregate bounds. */
3911
+ traverseDepthSorted(visitor, { viewMatrix, worldMatrix = new Matrix4(), order = "back-to-front" }) {
3912
+ const cameraMatrix = new Matrix4(viewMatrix);
3913
+ const nodes = [];
3914
+ this.traverse(
3915
+ (node, context) => {
3916
+ const bounds = node.getBounds();
3917
+ const center = bounds ? new Vector3(bounds[0]).add(bounds[1]).divide([2, 2, 2]) : new Vector3();
3918
+ const nodeWorldMatrix = new Matrix4(context.worldMatrix).multiplyRight(node.matrix);
3919
+ nodeWorldMatrix.transformAsPoint(center, center);
3920
+ cameraMatrix.transformAsPoint(center, center);
3921
+ nodes.push({
3922
+ node,
3923
+ context: { worldMatrix: nodeWorldMatrix, bounds, depth: -center[2] },
3924
+ index: nodes.length
3925
+ });
3926
+ },
3927
+ { worldMatrix: new Matrix4(worldMatrix) }
3928
+ );
3929
+ const direction = order === "back-to-front" ? -1 : 1;
3930
+ nodes.sort(
3931
+ (first, second) => direction * (first.context.depth - second.context.depth) || first.index - second.index
3932
+ );
3933
+ for (const { node, context } of nodes) {
3934
+ visitor(node, context);
3935
+ }
3936
+ }
3937
+ preorderTraversal(visitor, { worldMatrix = new Matrix4() } = {}) {
3938
+ const modelMatrix = new Matrix4(worldMatrix).multiplyRight(this.matrix);
3939
+ visitor(this, { worldMatrix: modelMatrix });
3940
+ for (const child of this.children) {
3941
+ if (child instanceof _GroupNode) {
3942
+ child.preorderTraversal(visitor, { worldMatrix: modelMatrix });
3943
+ } else {
3944
+ visitor(child, { worldMatrix: modelMatrix });
3945
+ }
3946
+ }
3947
+ }
3948
+ };
3949
+
3950
+ // src/scenegraph/model-node.ts
3951
+ var ModelNode = class extends ScenegraphNode {
3952
+ model;
3953
+ gpuAnimation;
3954
+ instanceMatrices;
3955
+ bounds = null;
3956
+ managedResources;
3957
+ // TODO - is this used? override callbacks to make sure we call them with this
3958
+ // onBeforeRender = null;
3959
+ // onAfterRender = null;
3960
+ // AfterRender = null;
3961
+ constructor(props) {
3962
+ super(props);
3963
+ this.model = props.model;
3964
+ this.gpuAnimation = props.gpuAnimation;
3965
+ this.managedResources = props.managedResources || [];
3966
+ this.instanceMatrices = props.instanceMatrices || null;
3967
+ this.bounds = props.bounds ? this.instanceMatrices ? getInstancedScenegraphBounds(props.bounds, this.instanceMatrices) : props.bounds : null;
3968
+ this.setProps(props);
3969
+ }
3970
+ destroy() {
3971
+ if (this.model) {
3972
+ this.model.destroy();
3973
+ this.model = null;
3974
+ }
3975
+ this.managedResources.forEach((resource) => resource.destroy());
3976
+ this.managedResources = [];
3977
+ }
3978
+ getBounds() {
3979
+ return this.bounds;
3980
+ }
3981
+ // Expose model methods
3982
+ draw(renderPass) {
3983
+ return this.model.draw(renderPass);
3984
+ }
3985
+ };
3986
+ function getInstancedScenegraphBounds(bounds, instanceMatrices) {
3987
+ const instancedBounds = makeEmptyScenegraphBounds();
3988
+ for (const instanceMatrix of instanceMatrices) {
3989
+ expandScenegraphBounds(instancedBounds, bounds, instanceMatrix);
3990
+ }
3991
+ return areScenegraphBoundsDefined(instancedBounds) ? instancedBounds : null;
3992
+ }
3993
+
3994
+ // ../../node_modules/@math.gl/core/dist/types/typed-array-brand.js
3995
+ var typedArrayTagGetter = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Uint8Array.prototype), Symbol.toStringTag).get;
3996
+ function getTypedArrayName(value) {
3997
+ return ArrayBuffer.isView(value) ? typedArrayTagGetter.call(value) : void 0;
3998
+ }
3999
+
4000
+ // ../../node_modules/@math.gl/core/dist/types/is-array.js
4001
+ function isTypedArray(value) {
4002
+ const name = getTypedArrayName(value);
4003
+ return name !== void 0 && name !== "BigInt64Array" && name !== "BigUint64Array";
4004
+ }
4005
+
4006
+ // ../../node_modules/@math.gl/geometry/dist/lib/geometry.js
4007
+ var geometryId = 0;
4008
+ var Geometry = class {
4009
+ constructor(props) {
4010
+ this.userData = {};
4011
+ this.id = props.id || `geometry-${++geometryId}`;
4012
+ this.topology = props.topology;
4013
+ this.attributes = {};
4014
+ let indices = props.indices ? normalizeAttribute(props.indices) : void 0;
4015
+ for (const [name, input] of Object.entries(props.attributes || {})) {
4016
+ const attribute = normalizeAttribute(input);
4017
+ if (name === "POSITION" || name === "positions") {
4018
+ attribute.size || (attribute.size = 3);
4019
+ }
4020
+ if (name === "indices") {
4021
+ if (indices)
4022
+ throw new Error("Geometry has multiple index attributes");
4023
+ indices = attribute;
4024
+ } else {
4025
+ this.attributes[name] = attribute;
4026
+ }
4027
+ }
4028
+ if (indices) {
4029
+ if (!(indices.value instanceof Uint16Array || indices.value instanceof Uint32Array)) {
4030
+ throw new Error("Geometry indices must be a Uint16Array or Uint32Array");
4031
+ }
4032
+ indices.size = 1;
4033
+ this.indices = indices;
4034
+ validateIndices(indices, this.attributes);
4035
+ }
4036
+ this.vertexCount = props.vertexCount ?? calculateVertexCount(this.attributes, this.indices);
4037
+ if (!Number.isInteger(this.vertexCount) || this.vertexCount < 0) {
4038
+ throw new Error("Geometry vertexCount must be a non-negative integer");
4039
+ }
4040
+ }
4041
+ getVertexCount() {
4042
+ return this.vertexCount;
4043
+ }
4044
+ getAttributes() {
4045
+ return this.indices ? { indices: this.indices, ...this.attributes } : this.attributes;
4046
+ }
4047
+ };
4048
+ function normalizeAttribute(input) {
4049
+ const attribute = isTypedArray(input) ? { value: input } : { ...input };
4050
+ if (!isTypedArray(attribute.value)) {
4051
+ throw new Error("Geometry attributes must contain a typed-array value");
4052
+ }
4053
+ if (attribute.size !== void 0 && (!Number.isInteger(attribute.size) || attribute.size < 1)) {
4054
+ throw new Error("Geometry attribute size must be a positive integer");
4055
+ }
4056
+ if (attribute.size && attribute.value.length % attribute.size !== 0) {
4057
+ throw new Error("Geometry attribute length must be divisible by its size");
4058
+ }
4059
+ return attribute;
4060
+ }
4061
+ function validateIndices(indices, attributes) {
4062
+ let maximumIndex = -1;
4063
+ for (const index of indices.value)
4064
+ maximumIndex = Math.max(maximumIndex, Number(index));
4065
+ for (const [name, attribute] of Object.entries(attributes)) {
4066
+ if (!attribute.constant && attribute.size) {
4067
+ const attributeVertexCount = attribute.value.length / attribute.size;
4068
+ if (maximumIndex >= attributeVertexCount) {
4069
+ throw new Error(`Geometry index ${maximumIndex} exceeds ${name} vertex count ${attributeVertexCount}`);
4070
+ }
4071
+ }
4072
+ }
4073
+ }
4074
+ function calculateVertexCount(attributes, indices) {
4075
+ if (indices)
4076
+ return indices.value.length;
4077
+ let count = Infinity;
4078
+ for (const attribute of Object.values(attributes)) {
4079
+ if (!attribute.constant && attribute.size) {
4080
+ count = Math.min(count, attribute.value.length / attribute.size);
4081
+ }
4082
+ }
4083
+ if (!Number.isFinite(count))
4084
+ throw new Error("Geometry has no countable attributes");
4085
+ return count;
4086
+ }
4087
+
4088
+ // ../../node_modules/@math.gl/geometry/dist/geometries/geometry-helpers.js
4089
+ function assertPositive(value, name) {
4090
+ if (!Number.isFinite(value) || value <= 0)
4091
+ throw new Error(`${name} must be greater than zero`);
4092
+ }
4093
+ function assertNonNegative(value, name) {
4094
+ if (!Number.isFinite(value) || value < 0)
4095
+ throw new Error(`${name} must be non-negative`);
4096
+ }
4097
+ function assertSegments(value, name, minimum = 1) {
4098
+ if (!Number.isInteger(value) || value < minimum)
4099
+ throw new Error(`${name} must be an integer >= ${minimum}`);
4100
+ }
4101
+ function makeIndices(vertexCount, values) {
4102
+ return vertexCount > 65535 ? new Uint32Array(values) : new Uint16Array(values);
4103
+ }
4104
+
4105
+ // ../../node_modules/@math.gl/geometry/dist/geometries/box-geometry.js
4106
+ var BoxGeometry = class extends Geometry {
4107
+ constructor(props = {}) {
4108
+ const size = props.size || [1, 1, 1];
4109
+ assertPositive(size[0], "size[0]");
4110
+ assertPositive(size[1], "size[1]");
4111
+ assertPositive(size[2], "size[2]");
4112
+ const half = [size[0] / 2, size[1] / 2, size[2] / 2];
4113
+ const positions = [];
4114
+ const normals = [];
4115
+ const texCoords = [];
4116
+ const indices = [];
4117
+ const faces = [
4118
+ { n: [1, 0, 0], u: [0, 0, -1], v: [0, 1, 0], h1: half[2], h2: half[1] },
4119
+ { n: [-1, 0, 0], u: [0, 0, 1], v: [0, 1, 0], h1: half[2], h2: half[1] },
4120
+ { n: [0, 1, 0], u: [1, 0, 0], v: [0, 0, -1], h1: half[0], h2: half[2] },
4121
+ { n: [0, -1, 0], u: [1, 0, 0], v: [0, 0, 1], h1: half[0], h2: half[2] },
4122
+ { n: [0, 0, 1], u: [1, 0, 0], v: [0, 1, 0], h1: half[0], h2: half[1] },
4123
+ { n: [0, 0, -1], u: [-1, 0, 0], v: [0, 1, 0], h1: half[0], h2: half[1] }
4124
+ ];
4125
+ for (const face of faces) {
4126
+ const base = positions.length / 3;
4127
+ for (const [s, t, u, v] of [
4128
+ [-1, -1, 0, 0],
4129
+ [1, -1, 1, 0],
4130
+ [1, 1, 1, 1],
4131
+ [-1, 1, 0, 1]
4132
+ ]) {
4133
+ positions.push(face.n[0] * half[0] + face.u[0] * face.h1 * s + face.v[0] * face.h2 * t, face.n[1] * half[1] + face.u[1] * face.h1 * s + face.v[1] * face.h2 * t, face.n[2] * half[2] + face.u[2] * face.h1 * s + face.v[2] * face.h2 * t);
4134
+ normals.push(...face.n);
4135
+ texCoords.push(u, v);
4136
+ }
4137
+ indices.push(base, base + 1, base + 2, base, base + 2, base + 3);
4138
+ }
4139
+ super({
4140
+ id: props.id,
4141
+ topology: "triangle-list",
4142
+ indices: makeIndices(24, indices),
4143
+ attributes: {
4144
+ POSITION: { size: 3, value: new Float32Array(positions) },
4145
+ NORMAL: { size: 3, value: new Float32Array(normals) },
4146
+ TEXCOORD_0: { size: 2, value: new Float32Array(texCoords) },
4147
+ ...props.attributes
4148
+ }
4149
+ });
4150
+ }
4151
+ };
4152
+ var CubeGeometry = class extends BoxGeometry {
4153
+ constructor(props = {}) {
4154
+ const size = props.size ?? 1;
4155
+ super({ ...props, size: [size, size, size] });
4156
+ }
4157
+ };
4158
+
4159
+ // ../../node_modules/@math.gl/geometry/dist/geometries/surface-of-revolution.js
4160
+ function makeSurfaceOfRevolution(rings, nradial) {
4161
+ const positions = [];
4162
+ const normals = [];
4163
+ const texCoords = [];
4164
+ const indices = [];
4165
+ const stride = nradial + 1;
4166
+ for (let ringIndex = 0; ringIndex < rings.length; ringIndex++) {
4167
+ const ring = rings[ringIndex];
4168
+ for (let radial = 0; radial <= nradial; radial++) {
4169
+ const u = radial / nradial;
4170
+ const angle2 = u * Math.PI * 2;
4171
+ const sin = Math.sin(angle2);
4172
+ const cos = Math.cos(angle2);
4173
+ positions.push(sin * ring.radius, ring.y, cos * ring.radius);
4174
+ normals.push(sin * ring.normalRadius, ring.normalY, cos * ring.normalRadius);
4175
+ texCoords.push(u, ringIndex / (rings.length - 1));
4176
+ }
4177
+ }
4178
+ for (let ring = 0; ring < rings.length - 1; ring++) {
4179
+ for (let radial = 0; radial < nradial; radial++) {
4180
+ const a = ring * stride + radial;
4181
+ const b = a + 1;
4182
+ const c = a + stride;
4183
+ const d = c + 1;
4184
+ indices.push(a, b, d, a, d, c);
4185
+ }
4186
+ }
4187
+ return {
4188
+ ...{ positions, normals, texCoords, indices },
4189
+ indexArray: makeIndices(positions.length / 3, indices)
4190
+ };
4191
+ }
4192
+
4193
+ // ../../node_modules/@math.gl/geometry/dist/geometries/truncated-cone-geometry.js
4194
+ var TruncatedConeGeometry = class extends Geometry {
4195
+ constructor(props = {}) {
4196
+ const { topRadius = 0, bottomRadius = 0, topCap = false, bottomCap = false, height = 1, nradial = 10, nvertical = 1, verticalAxis = "y" } = props;
4197
+ assertNonNegative(topRadius, "topRadius");
4198
+ assertNonNegative(bottomRadius, "bottomRadius");
4199
+ if (topRadius === 0 && bottomRadius === 0)
3680
4200
  throw new Error("At least one radius must be greater than zero");
3681
4201
  assertPositive(height, "height");
3682
4202
  assertSegments(nradial, "nradial", 3);
@@ -4118,7 +4638,7 @@ var __exports__ = (() => {
4118
4638
  };
4119
4639
 
4120
4640
  // src/geometry/geometry.ts
4121
- var import_core2 = __toESM(require_core(), 1);
4641
+ var import_core3 = __toESM(require_core(), 1);
4122
4642
  var Geometry2 = class extends Geometry {
4123
4643
  bufferLayout;
4124
4644
  constructor(props) {
@@ -4171,14 +4691,14 @@ var __exports__ = (() => {
4171
4691
  }
4172
4692
  bufferLayout.push({
4173
4693
  name: getGeometryShaderAttributeName(attributeName),
4174
- format: import_core2.vertexFormatDecoder.getVertexFormatFromAttribute(value, size, normalized2)
4694
+ format: import_core3.vertexFormatDecoder.getVertexFormatFromAttribute(value, size, normalized2)
4175
4695
  });
4176
4696
  }
4177
4697
  return bufferLayout;
4178
4698
  }
4179
4699
 
4180
4700
  // src/geometry/geometry-utils.ts
4181
- var import_core3 = __toESM(require_core(), 1);
4701
+ var import_core4 = __toESM(require_core(), 1);
4182
4702
 
4183
4703
  // ../../node_modules/@math.gl/geometry/dist/lib/geometry-utils.js
4184
4704
  function unpackIndexedGeometry(geometry) {
@@ -4230,8 +4750,8 @@ var __exports__ = (() => {
4230
4750
  if (size === void 0) {
4231
4751
  throw new Error(`Attribute ${sourceName} is missing a size`);
4232
4752
  }
4233
- const format = import_core3.vertexFormatDecoder.getVertexFormatFromAttribute(value, size, normalized2);
4234
- const vertexFormatInfo = import_core3.vertexFormatDecoder.getVertexFormatInfo(format);
4753
+ const format = import_core4.vertexFormatDecoder.getVertexFormatFromAttribute(value, size, normalized2);
4754
+ const vertexFormatInfo = import_core4.vertexFormatDecoder.getVertexFormatInfo(format);
4235
4755
  byteOffset = alignTo(byteOffset, minAttributeAlignment);
4236
4756
  interleavedAttributes.push({
4237
4757
  sourceName,
@@ -4424,50 +4944,395 @@ var __exports__ = (() => {
4424
4944
  const value = values[componentIndex];
4425
4945
  encoded[componentIndex] = attribute["normalized"] && maximum ? Math.round(Math.max(signed ? -1 : 0, Math.min(1, value)) * maximum) : value;
4426
4946
  }
4427
- return encoded;
4947
+ return encoded;
4948
+ }
4949
+ function getNormalizedAttributeMaximum(values) {
4950
+ if (values instanceof Int8Array) return 127;
4951
+ if (values instanceof Uint8Array || values instanceof Uint8ClampedArray) return 255;
4952
+ if (values instanceof Int16Array) return 32767;
4953
+ if (values instanceof Uint16Array) return 65535;
4954
+ if (values instanceof Int32Array) return 2147483647;
4955
+ if (values instanceof Uint32Array) return 4294967295;
4956
+ return 0;
4957
+ }
4958
+ function normalizeMorphDirections(values, componentCount) {
4959
+ for (let offset = 0; offset < values.length; offset += componentCount) {
4960
+ const length4 = Math.hypot(values[offset], values[offset + 1], values[offset + 2]);
4961
+ if (length4 > 0) {
4962
+ values[offset] /= length4;
4963
+ values[offset + 1] /= length4;
4964
+ values[offset + 2] /= length4;
4965
+ }
4966
+ }
4967
+ }
4968
+
4969
+ // src/scenegraph/controllers/morph-controller.ts
4970
+ var import_core5 = __toESM(require_core(), 1);
4971
+ function setMorphWeights(node, weights) {
4972
+ node.userData["morphWeights"] = [...weights];
4973
+ const meshes = node.userData["morphMeshes"] || [];
4974
+ for (const mesh of meshes) {
4975
+ mesh.preorderTraversal((child) => {
4976
+ if (!(child instanceof ModelNode)) {
4977
+ return;
4978
+ }
4979
+ const state = child.userData["morphTargets"];
4980
+ if (!state) {
4981
+ return;
4982
+ }
4983
+ const gpuWeights = child.userData["morphWeightTransport"];
4984
+ if (gpuWeights) {
4985
+ updateMorphWeights(gpuWeights, weights);
4986
+ child.userData["morphWeights"] = [...weights];
4987
+ return;
4988
+ }
4989
+ updateMorphTargetBuffers(child.model, state.geometry, state.targets, weights);
4990
+ child.userData["morphWeights"] = [...weights];
4991
+ });
4992
+ }
4993
+ }
4994
+ function updateMorphWeights(state, weights) {
4995
+ state.values.fill(0);
4996
+ state.values.set(weights.slice(0, state.values.length));
4997
+ if (state.data instanceof import_core5.Buffer) {
4998
+ state.data.write(state.values);
4999
+ } else {
5000
+ state.data.writeData(state.values, { width: state.packedTargetCount, height: 1 });
5001
+ }
5002
+ }
5003
+
5004
+ // src/animation/node-animation-binding.ts
5005
+ function makeNodeAnimationBinding(node, property, options = {}) {
5006
+ return {
5007
+ id: options.id,
5008
+ ...property === "translation" || property === "rotation" || property === "scale" || property === "weights" ? { poseTarget: { node, property } } : {},
5009
+ getValue: () => {
5010
+ switch (property) {
5011
+ case "translation":
5012
+ return Array.from(node.position);
5013
+ case "rotation":
5014
+ return Array.from(node.rotation);
5015
+ case "scale":
5016
+ return Array.from(node.scale);
5017
+ case "weights":
5018
+ return Array.from(node.userData["morphWeights"] ?? []);
5019
+ case "visibility":
5020
+ return [node.display ? 1 : 0];
5021
+ case "selectable":
5022
+ return [node.selectable ? 1 : 0];
5023
+ case "hoverable":
5024
+ return [node.hoverable ? 1 : 0];
5025
+ }
5026
+ },
5027
+ setValue: (value) => {
5028
+ switch (property) {
5029
+ case "translation":
5030
+ node.setPosition(value).updateMatrix();
5031
+ break;
5032
+ case "rotation":
5033
+ node.setRotation(value).updateMatrix();
5034
+ break;
5035
+ case "scale":
5036
+ node.setScale(value).updateMatrix();
5037
+ break;
5038
+ case "weights":
5039
+ setMorphWeights(node, value);
5040
+ break;
5041
+ case "selectable":
5042
+ node.setProps({ selectable: value[0] !== 0 });
5043
+ break;
5044
+ case "hoverable":
5045
+ node.setProps({ hoverable: value[0] !== 0 });
5046
+ break;
5047
+ case "visibility":
5048
+ node.setProps({ display: value[0] !== 0 });
5049
+ options.onVisibilityChange?.();
5050
+ break;
5051
+ }
5052
+ }
5053
+ };
5054
+ }
5055
+
5056
+ // src/animation/skin.ts
5057
+ function updateSkinJointMatrices(props) {
5058
+ const { joints, meshNode, worldMatrices, inverseBindMatrices, target } = props;
5059
+ const matrixCount = joints.length;
5060
+ const jointMatrices = target && target.length === matrixCount * 16 ? target : new Float32Array(matrixCount * 16);
5061
+ const meshWorldMatrix = meshNode ? worldMatrices.get(meshNode) || meshNode.matrix : void 0;
5062
+ const inverseMeshMatrix = meshWorldMatrix ? new Matrix4(meshWorldMatrix).invert() : null;
5063
+ for (let jointIndex = 0; jointIndex < matrixCount; jointIndex++) {
5064
+ const jointNode = joints[jointIndex];
5065
+ const jointWorldMatrix = worldMatrices.get(jointNode) || jointNode.matrix;
5066
+ const jointMatrix = inverseMeshMatrix ? new Matrix4(inverseMeshMatrix).multiplyRight(jointWorldMatrix) : new Matrix4(jointWorldMatrix);
5067
+ const offset = jointIndex * 16;
5068
+ if (inverseBindMatrices && inverseBindMatrices.length >= offset + 16) {
5069
+ const inverseBindMatrix = new Matrix4();
5070
+ for (let componentIndex = 0; componentIndex < 16; componentIndex++) {
5071
+ inverseBindMatrix[componentIndex] = inverseBindMatrices[offset + componentIndex];
5072
+ }
5073
+ jointMatrix.multiplyRight(inverseBindMatrix);
5074
+ }
5075
+ jointMatrices.set(jointMatrix, offset);
5076
+ }
5077
+ return jointMatrices;
5078
+ }
5079
+
5080
+ // src/animation/scenegraph-gpu-animation.ts
5081
+ var ScenegraphGPUAnimationResources = class {
5082
+ constructor(device, layout, animationJointCount, morphTargetCount, capacity = 1, id = "scenegraph-animation") {
5083
+ this.layout = layout;
5084
+ this.animationJointCount = animationJointCount;
5085
+ this.morphTargetCount = morphTargetCount;
5086
+ this.animationFrameStride = getScenegraphGPUAnimationFrameStride(
5087
+ animationJointCount,
5088
+ morphTargetCount
5089
+ );
5090
+ this.animationFrameValues = new Float32Array(layout.frameCount * this.animationFrameStride * 4);
5091
+ this.animationParameters = new Float32Array(capacity * 4);
5092
+ this.animationBlend = new Float32Array(capacity * 4);
5093
+ this.animationFrames = createScenegraphGPUAnimationStorage(
5094
+ device,
5095
+ `${id}-frames`,
5096
+ this.animationFrameValues,
5097
+ this.animationFrameStride,
5098
+ layout.frameCount
5099
+ );
5100
+ try {
5101
+ this.animationParameterBuffer = device.createBuffer({
5102
+ id: `${id}-instanceAnimationFrames`,
5103
+ data: this.animationParameters,
5104
+ usage: import_core6.Buffer.VERTEX | import_core6.Buffer.COPY_DST
5105
+ });
5106
+ try {
5107
+ this.animationBlendBuffer = device.createBuffer({
5108
+ id: `${id}-instanceAnimationBlend`,
5109
+ data: this.animationBlend,
5110
+ usage: import_core6.Buffer.VERTEX | import_core6.Buffer.COPY_DST
5111
+ });
5112
+ } catch (error) {
5113
+ this.animationParameterBuffer.destroy();
5114
+ throw error;
5115
+ }
5116
+ } catch (error) {
5117
+ this.animationFrames.destroy();
5118
+ throw error;
5119
+ }
5120
+ }
5121
+ layout;
5122
+ animationJointCount;
5123
+ morphTargetCount;
5124
+ animationFrames;
5125
+ animationFrameValues;
5126
+ animationFrameStride;
5127
+ animationParameters;
5128
+ animationParameterBuffer;
5129
+ animationBlend;
5130
+ animationBlendBuffer;
5131
+ /** Shader options for the shared GPU animation module. */
5132
+ get defines() {
5133
+ return {
5134
+ HAS_GPU_CROWD_ANIMATION: true,
5135
+ CROWD_ANIMATION_FRAME_STRIDE: this.animationFrameStride
5136
+ };
5137
+ }
5138
+ get bindings() {
5139
+ return { gpuAnimationFrames: this.animationFrames };
5140
+ }
5141
+ /** Vertex attributes consumed by the GPU animation shader module. */
5142
+ get attributes() {
5143
+ return {
5144
+ instanceAnimationFrames: this.animationParameterBuffer,
5145
+ instanceAnimationBlend: this.animationBlendBuffer
5146
+ };
5147
+ }
5148
+ get bufferLayout() {
5149
+ return [
5150
+ { name: "instanceAnimationFrames", format: "float32x4", stepMode: "instance" },
5151
+ { name: "instanceAnimationBlend", format: "float32x4", stepMode: "instance" }
5152
+ ];
5153
+ }
5154
+ /** Uploads the baked atlas after sampling has finished. */
5155
+ upload() {
5156
+ if (this.animationFrames instanceof import_core6.Buffer) {
5157
+ this.animationFrames.write(this.animationFrameValues);
5158
+ } else {
5159
+ this.animationFrames.writeData(this.animationFrameValues, {
5160
+ width: this.animationFrameStride,
5161
+ height: this.layout.frameCount
5162
+ });
5163
+ }
5164
+ }
5165
+ destroy() {
5166
+ this.animationParameterBuffer.destroy();
5167
+ this.animationBlendBuffer.destroy();
5168
+ this.animationFrames.destroy();
5169
+ }
5170
+ };
5171
+ function createScenegraphGPUAnimationStorage(device, id, values, width, height) {
5172
+ if (device.type === "webgpu") {
5173
+ return device.createBuffer({ id, data: values, usage: import_core6.Buffer.STORAGE | import_core6.Buffer.COPY_DST });
5174
+ }
5175
+ const texture = device.createTexture({
5176
+ id,
5177
+ format: "rgba32float",
5178
+ width,
5179
+ height,
5180
+ usage: import_core6.Texture.SAMPLE | import_core6.Texture.COPY_DST,
5181
+ sampler: { minFilter: "nearest", magFilter: "nearest", mipmapFilter: "nearest" }
5182
+ });
5183
+ try {
5184
+ texture.writeData(values, { width, height });
5185
+ return texture;
5186
+ } catch (error) {
5187
+ texture.destroy();
5188
+ throw error;
5189
+ }
4428
5190
  }
4429
- function getNormalizedAttributeMaximum(values) {
4430
- if (values instanceof Int8Array) return 127;
4431
- if (values instanceof Uint8Array || values instanceof Uint8ClampedArray) return 255;
4432
- if (values instanceof Int16Array) return 32767;
4433
- if (values instanceof Uint16Array) return 65535;
4434
- if (values instanceof Int32Array) return 2147483647;
4435
- if (values instanceof Uint32Array) return 4294967295;
4436
- return 0;
5191
+ function getScenegraphGPUPlaybackClip(clip) {
5192
+ return new AnimationClip({
5193
+ name: clip.name,
5194
+ duration: clip.duration,
5195
+ tracks: clip.tracks.filter((track) => !track.binding.poseTarget)
5196
+ });
4437
5197
  }
4438
- function normalizeMorphDirections(values, componentCount) {
4439
- for (let offset = 0; offset < values.length; offset += componentCount) {
4440
- const length4 = Math.hypot(values[offset], values[offset + 1], values[offset + 2]);
4441
- if (length4 > 0) {
4442
- values[offset] /= length4;
4443
- values[offset + 1] /= length4;
4444
- values[offset + 2] /= length4;
5198
+ function bakeScenegraphGPUAnimation({
5199
+ scenes,
5200
+ clips,
5201
+ layout,
5202
+ targets,
5203
+ skins = []
5204
+ }) {
5205
+ const poseNodes = /* @__PURE__ */ new Map();
5206
+ const clone2 = (source4) => {
5207
+ const existing = poseNodes.get(source4);
5208
+ if (existing) return existing;
5209
+ const pose = new GroupNode({ id: source4.id });
5210
+ poseNodes.set(source4, pose);
5211
+ resetPose(source4, pose);
5212
+ for (const child of source4.children) {
5213
+ if (child instanceof GroupNode) pose.add(clone2(child));
5214
+ }
5215
+ return pose;
5216
+ };
5217
+ const poseScenes = scenes.map(clone2);
5218
+ const bindMatrices = collectWorldMatrices(poseScenes);
5219
+ const poseTargets = targets.map(({ node, resources: resources2, relativeToBindPose }) => {
5220
+ const pose = poseNodes.get(node);
5221
+ (0, import_core6.assert)(pose && resources2.layout === layout);
5222
+ const skin = skins.find((candidate) => candidate.node === node);
5223
+ (0, import_core6.assert)(
5224
+ !skin || !resources2.animationJointCount || skin.joints.length <= resources2.animationJointCount
5225
+ );
5226
+ const joints = skin?.joints.map(clone2);
5227
+ return {
5228
+ pose,
5229
+ resources: resources2,
5230
+ inverseBind: relativeToBindPose ? new Matrix4(bindMatrices.get(pose)).invert() : null,
5231
+ joints,
5232
+ inverseBindMatrices: skin?.inverseBindMatrices
5233
+ };
5234
+ });
5235
+ try {
5236
+ const mixer = new AnimationMixer();
5237
+ const bindings = /* @__PURE__ */ new Map();
5238
+ for (const clip of layout.clips) {
5239
+ mixer.stopAllAction();
5240
+ for (const [source4, pose] of poseNodes) resetPose(source4, pose);
5241
+ const sourceClip = clips.find((candidate) => candidate.name === clip.name);
5242
+ (0, import_core6.assert)(sourceClip);
5243
+ const tracks = sourceClip.tracks.flatMap((track) => {
5244
+ const target = track.binding.poseTarget;
5245
+ const pose = target && poseNodes.get(target.node);
5246
+ if (!pose || !target) return [];
5247
+ let binding = bindings.get(track.binding);
5248
+ if (!binding) {
5249
+ binding = makeNodeAnimationBinding(pose, target.property, { id: track.binding.id });
5250
+ bindings.set(track.binding, binding);
5251
+ }
5252
+ return [new AnimationTrack({ ...track, binding })];
5253
+ });
5254
+ const action = mixer.clipAction(
5255
+ new AnimationClip({
5256
+ name: clip.name,
5257
+ duration: clip.duration,
5258
+ tracks
5259
+ })
5260
+ ).setLoop("once", 1).play();
5261
+ for (let frame = 0; frame < clip.frameCount; frame++) {
5262
+ action.setTime(Math.min(frame / layout.sampleRate, clip.duration));
5263
+ mixer.update(0);
5264
+ const matrices = collectWorldMatrices(poseScenes);
5265
+ for (const { pose, resources: resources2, inverseBind, joints, inverseBindMatrices } of poseTargets) {
5266
+ const offset = (clip.frameOffset + frame) * resources2.animationFrameStride * 4;
5267
+ const values = resources2.animationFrameValues;
5268
+ const world = matrices.get(pose);
5269
+ values.set(inverseBind ? new Matrix4(inverseBind).multiplyRight(world) : world, offset);
5270
+ if (joints && resources2.animationJointCount) {
5271
+ updateSkinJointMatrices({
5272
+ joints,
5273
+ meshNode: pose,
5274
+ worldMatrices: matrices,
5275
+ inverseBindMatrices,
5276
+ target: values.subarray(offset + 16, offset + 16 + joints.length * 16)
5277
+ });
5278
+ }
5279
+ const weights = pose.userData["morphWeights"];
5280
+ const weightOffset = offset + 16 + resources2.animationJointCount * 16;
5281
+ for (let index = 0; index < resources2.morphTargetCount; index++) {
5282
+ values[weightOffset + index * 4] = weights?.[index] ?? 0;
5283
+ }
5284
+ }
5285
+ }
4445
5286
  }
5287
+ for (const { resources: resources2 } of targets) resources2.upload();
5288
+ } finally {
5289
+ for (const pose of poseNodes.values()) pose.destroy();
5290
+ }
5291
+ const resources = targets.map((target) => target.resources);
5292
+ const clipsByName = new Map(layout.clips.map((clip) => [clip.name, clip]));
5293
+ return (animator) => updateScenegraphGPUAnimation(animator, layout, clipsByName, resources);
5294
+ }
5295
+ function updateScenegraphGPUAnimation(animator, layout, clipsByName, resources) {
5296
+ const actions = animator.getAnimations().filter((animation) => animation.action.shouldApply && animation.action.weight > 0);
5297
+ (0, import_core6.assert)(actions.length <= 2);
5298
+ const primary = actions.find((animation) => animation.name === animator.activeClip) || actions[0];
5299
+ const primaryLayout = primary && clipsByName.get(primary.name) || layout.clips[0];
5300
+ const secondary = actions.find((animation) => animation !== primary);
5301
+ const secondaryLayout = secondary && clipsByName.get(secondary.name);
5302
+ const frames = getScenegraphGPUAnimationFrames(
5303
+ primaryLayout,
5304
+ primary?.action.time || 0,
5305
+ layout.sampleRate
5306
+ );
5307
+ const secondaryFrames = secondaryLayout && secondary ? getScenegraphGPUAnimationFrames(secondaryLayout, secondary.action.time, layout.sampleRate) : [0, 0, 0];
5308
+ const totalWeight = (primary?.action.weight || 0) + (secondary?.action.weight || 0);
5309
+ for (const resource of resources) {
5310
+ resource.animationParameters.set([...frames, primary?.action.weight || 1]);
5311
+ resource.animationBlend.set([
5312
+ ...secondaryFrames,
5313
+ secondaryLayout && secondary && totalWeight > 0 ? secondary.action.weight / totalWeight : 0
5314
+ ]);
5315
+ resource.animationParameterBuffer.write(resource.animationParameters);
5316
+ resource.animationBlendBuffer.write(resource.animationBlend);
4446
5317
  }
4447
5318
  }
4448
-
4449
- // src/animation/skin.ts
4450
- function updateSkinJointMatrices(props) {
4451
- const { joints, meshNode, worldMatrices, inverseBindMatrices, target } = props;
4452
- const matrixCount = joints.length;
4453
- const jointMatrices = target && target.length === matrixCount * 16 ? target : new Float32Array(matrixCount * 16);
4454
- const meshWorldMatrix = meshNode ? worldMatrices.get(meshNode) || meshNode.matrix : void 0;
4455
- const inverseMeshMatrix = meshWorldMatrix ? new Matrix4(meshWorldMatrix).invert() : null;
4456
- for (let jointIndex = 0; jointIndex < matrixCount; jointIndex++) {
4457
- const jointNode = joints[jointIndex];
4458
- const jointWorldMatrix = worldMatrices.get(jointNode) || jointNode.matrix;
4459
- const jointMatrix = inverseMeshMatrix ? new Matrix4(inverseMeshMatrix).multiplyRight(jointWorldMatrix) : new Matrix4(jointWorldMatrix);
4460
- const offset = jointIndex * 16;
4461
- if (inverseBindMatrices && inverseBindMatrices.length >= offset + 16) {
4462
- const inverseBindMatrix = new Matrix4();
4463
- for (let componentIndex = 0; componentIndex < 16; componentIndex++) {
4464
- inverseBindMatrix[componentIndex] = inverseBindMatrices[offset + componentIndex];
4465
- }
4466
- jointMatrix.multiplyRight(inverseBindMatrix);
4467
- }
4468
- jointMatrices.set(jointMatrix, offset);
5319
+ function resetPose(source4, target) {
5320
+ target.setProps({
5321
+ position: Array.from(source4.position),
5322
+ rotation: Array.from(source4.rotation),
5323
+ scale: Array.from(source4.scale),
5324
+ matrix: Array.from(source4.matrix)
5325
+ });
5326
+ target.userData["morphWeights"] = source4.userData["morphWeights"];
5327
+ }
5328
+ function collectWorldMatrices(scenes) {
5329
+ const matrices = /* @__PURE__ */ new Map();
5330
+ for (const scene of scenes) {
5331
+ scene.preorderTraversal((node, { worldMatrix }) => {
5332
+ if (node instanceof GroupNode) matrices.set(node, worldMatrix);
5333
+ });
4469
5334
  }
4470
- return jointMatrices;
5335
+ return matrices;
4471
5336
  }
4472
5337
 
4473
5338
  // src/animation/timeline.ts
@@ -4642,7 +5507,7 @@ var __exports__ = (() => {
4642
5507
  };
4643
5508
 
4644
5509
  // src/animation-loop/animation-loop.ts
4645
- var import_core4 = __toESM(require_core(), 1);
5510
+ var import_core7 = __toESM(require_core(), 1);
4646
5511
 
4647
5512
  // src/animation-loop/request-animation-frame.ts
4648
5513
  function requestAnimationFramePolyfill(callback) {
@@ -4912,7 +5777,7 @@ var __exports__ = (() => {
4912
5777
  throw new Error("No device provided");
4913
5778
  }
4914
5779
  this.stats = props.stats || new Stats({ id: `animation-loop-${statIdCounter++}` });
4915
- this.sharedStats = import_core4.luma.stats.get(ANIMATION_LOOP_STATS);
5780
+ this.sharedStats = import_core7.luma.stats.get(ANIMATION_LOOP_STATS);
4916
5781
  this.frameRate = this.stats.get("Frame Rate");
4917
5782
  this.frameRate.setSampleSize(1);
4918
5783
  this.cpuTime = this.stats.get("CPU Time");
@@ -5324,10 +6189,10 @@ var __exports__ = (() => {
5324
6189
  };
5325
6190
 
5326
6191
  // src/animation-loop/make-animation-loop.ts
5327
- var import_core5 = __toESM(require_core(), 1);
6192
+ var import_core8 = __toESM(require_core(), 1);
5328
6193
  function makeAnimationLoop(AnimationLoopTemplateCtor, props) {
5329
6194
  let renderLoop = null;
5330
- const device = props?.device || import_core5.luma.createDevice({
6195
+ const device = props?.device || import_core8.luma.createDevice({
5331
6196
  id: "animation-loop",
5332
6197
  adapters: props?.adapters,
5333
6198
  createCanvasContext: true
@@ -5685,14 +6550,14 @@ var __exports__ = (() => {
5685
6550
  }
5686
6551
 
5687
6552
  // src/model/gpu-vector-model.ts
5688
- var import_core13 = __toESM(require_core(), 1);
6553
+ var import_core16 = __toESM(require_core(), 1);
5689
6554
  var import_shaders3 = __toESM(require_shaders(), 1);
5690
6555
 
5691
6556
  // ../shaders/src/lib/utils/assert.ts
5692
- function assert2(condition, message) {
6557
+ function assert5(condition, message) {
5693
6558
  if (!condition) {
5694
6559
  const error = new Error(message || "shaders: assertion failed.");
5695
- Error.captureStackTrace?.(error, assert2);
6560
+ Error.captureStackTrace?.(error, assert5);
5696
6561
  throw error;
5697
6562
  }
5698
6563
  }
@@ -5847,7 +6712,7 @@ var __exports__ = (() => {
5847
6712
  const interfaceProviders = /* @__PURE__ */ new Set();
5848
6713
  for (const module of result) {
5849
6714
  if (module.implements !== void 0) {
5850
- assert2(!interfaceProviders.has(module.implements));
6715
+ assert5(!interfaceProviders.has(module.implements));
5851
6716
  interfaceProviders.add(module.implements);
5852
6717
  }
5853
6718
  }
@@ -5875,7 +6740,7 @@ var __exports__ = (() => {
5875
6740
  _transpileShader(props, modules, source4, stage) {
5876
6741
  const sourceLanguage = props.sourceLanguage || this.shaderLanguage;
5877
6742
  if (sourceLanguage === this.shaderLanguage) {
5878
- assert2(
6743
+ assert5(
5879
6744
  !getShaderModuleDependencies(modules).some(
5880
6745
  (module) => module.sourceLanguage && module.sourceLanguage !== this.shaderLanguage
5881
6746
  )
@@ -5883,9 +6748,9 @@ var __exports__ = (() => {
5883
6748
  return { code: source4 || "", modules };
5884
6749
  }
5885
6750
  const transpiler = this._shaderTranspilers.get(sourceLanguage);
5886
- assert2(transpiler);
6751
+ assert5(transpiler);
5887
6752
  const dependencies = getShaderModuleDependencies(modules);
5888
- assert2(
6753
+ assert5(
5889
6754
  !dependencies.some(
5890
6755
  (module) => module.sourceLanguage && module.sourceLanguage !== sourceLanguage && module.sourceLanguage !== this.shaderLanguage
5891
6756
  )
@@ -6191,7 +7056,7 @@ ${fragmentString}${source4.slice(insertionIndex)}`;
6191
7056
  const message = formatShaderModuleUniformLayoutError(validationResult);
6192
7057
  options.log?.error?.(message, validationResult)();
6193
7058
  if (options.throwOnError !== false) {
6194
- assert2(false, message);
7059
+ assert5(false, message);
6195
7060
  }
6196
7061
  return validationResult;
6197
7062
  }
@@ -6229,17 +7094,16 @@ ${fragmentString}${source4.slice(insertionIndex)}`;
6229
7094
  return nonStd140Blocks;
6230
7095
  }
6231
7096
  function extractShaderUniformBlockFieldNames(shaderSource, language, uniformBlockName) {
6232
- const sourceBody = language === "wgsl" ? extractWGSLStructBody(shaderSource, uniformBlockName) : extractGLSLUniformBlockBody(shaderSource, uniformBlockName);
7097
+ const uncommentedSource = stripShaderComments(shaderSource);
7098
+ const sourceBody = language === "wgsl" ? extractWGSLStructBody(uncommentedSource, uniformBlockName) : extractGLSLUniformBlockBody(uncommentedSource, uniformBlockName);
6233
7099
  if (!sourceBody) {
6234
7100
  return null;
6235
7101
  }
6236
7102
  const fieldNames = [];
6237
- for (const sourceLine of sourceBody.split("\n")) {
6238
- const line = sourceLine.replace(/\/\/.*$/, "").trim();
6239
- if (!line || line.startsWith("#")) {
6240
- continue;
6241
- }
6242
- const fieldMatch = language === "wgsl" ? line.match(/^([A-Za-z0-9_]+)\s*:/) : line.match(GLSL_UNIFORM_BLOCK_FIELD_REGEXP);
7103
+ const declarations = language === "wgsl" ? sourceBody.split(/;|,(?=\s*[A-Za-z0-9_]+\s*:)/) : sourceBody.replace(/^\s*#.*$/gm, "").split(";");
7104
+ for (const declaration of declarations) {
7105
+ const line = declaration.replace(/\s+/g, " ").trim();
7106
+ const fieldMatch = language === "wgsl" ? line.match(/^([A-Za-z0-9_]+)\s*:/) : `${line};`.match(GLSL_UNIFORM_BLOCK_FIELD_REGEXP);
6243
7107
  if (fieldMatch) {
6244
7108
  fieldNames.push(fieldMatch[1]);
6245
7109
  }
@@ -6399,7 +7263,7 @@ ${DECLARATION_INJECT_MARKER}
6399
7263
  moduleSource = module.source || "";
6400
7264
  break;
6401
7265
  default:
6402
- assert2(false);
7266
+ assert5(false);
6403
7267
  }
6404
7268
  if (!module.name) {
6405
7269
  throw new Error("Shader module must have a name");
@@ -7723,7 +8587,7 @@ return ${outputName};
7723
8587
  prologue = true,
7724
8588
  log: log8
7725
8589
  } = options;
7726
- assert2(typeof source4 === "string", "shader source must be a string");
8590
+ assert5(typeof source4 === "string", "shader source must be a string");
7727
8591
  const sourceVersion = language === "glsl" ? getShaderInfo(source4).version : -1;
7728
8592
  const targetVersion = platformInfo.shaderLanguageVersion;
7729
8593
  const sourceVersionDirective = sourceVersion === 100 ? "#version 100" : "#version 300 es";
@@ -8564,7 +9428,7 @@ ${declarations.join("\n")}`).match(
8564
9428
  if (masked[end] === "{") depth++;
8565
9429
  if (masked[end] === "}") depth--;
8566
9430
  }
8567
- assert2(bodyStart >= 0 && depth === 0);
9431
+ assert5(bodyStart >= 0 && depth === 0);
8568
9432
  const name = match[2];
8569
9433
  const nameStart = match.index + match[0].lastIndexOf(name);
8570
9434
  const calls = Array.from(
@@ -8805,7 +9669,7 @@ ${declarations.join("\n")}`).match(
8805
9669
  fragmentEntryPoint = "fragmentMain",
8806
9670
  log: log8
8807
9671
  } = options;
8808
- assert2(typeof source4 === "string", "shader source must be a string");
9672
+ assert5(typeof source4 === "string", "shader source must be a string");
8809
9673
  const preprocessedSource = preprocess(source4, { defines });
8810
9674
  const pluginVertexInputAssembly = assembleShaderPluginVertexInputsWGSL(
8811
9675
  preprocessedSource,
@@ -9370,7 +10234,7 @@ ${declarations.join("\n")}`).match(
9370
10234
  };
9371
10235
 
9372
10236
  // src/model/batch-uniform-buffer.ts
9373
- var import_core6 = __toESM(require_core(), 1);
10237
+ var import_core9 = __toESM(require_core(), 1);
9374
10238
  var BatchUniformBuffer = class {
9375
10239
  constructor(device) {
9376
10240
  this.device = device;
@@ -9385,7 +10249,7 @@ ${declarations.join("\n")}`).match(
9385
10249
  const buffer = this.device.createBuffer({
9386
10250
  id: "batch-uniforms",
9387
10251
  byteLength: capacity,
9388
- usage: import_core6.Buffer.UNIFORM | import_core6.Buffer.COPY_DST
10252
+ usage: import_core9.Buffer.UNIFORM | import_core9.Buffer.COPY_DST
9389
10253
  });
9390
10254
  this.buffer?.destroy();
9391
10255
  this.buffer = buffer;
@@ -9399,7 +10263,7 @@ ${declarations.join("\n")}`).match(
9399
10263
  }
9400
10264
  /** Writes one slot without overwriting earlier batches in this call. */
9401
10265
  write(data) {
9402
- (0, import_core6.assert)(this.buffer && this.byteOffset + data.byteLength <= this.buffer.byteLength);
10266
+ (0, import_core9.assert)(this.buffer && this.byteOffset + data.byteLength <= this.buffer.byteLength);
9403
10267
  const binding = { buffer: this.buffer, offset: this.byteOffset, size: data.byteLength };
9404
10268
  this.buffer.write(data, binding.offset);
9405
10269
  this.byteOffset += this.getAlignedByteLength(data.byteLength);
@@ -9577,7 +10441,7 @@ ${declarations.join("\n")}`).match(
9577
10441
  }
9578
10442
 
9579
10443
  // src/utils/buffer-layout-helper.ts
9580
- var import_core7 = __toESM(require_core(), 1);
10444
+ var import_core10 = __toESM(require_core(), 1);
9581
10445
  var BufferLayoutHelper = class {
9582
10446
  bufferLayouts;
9583
10447
  constructor(bufferLayouts) {
@@ -9588,7 +10452,7 @@ ${declarations.join("\n")}`).match(
9588
10452
  }
9589
10453
  /** Get attribute names from a BufferLayout */
9590
10454
  getAttributeNamesForBuffer(bufferLayout) {
9591
- return (0, import_core7.getBufferLayoutAttributeNames)(bufferLayout);
10455
+ return (0, import_core10.getBufferLayoutAttributeNames)(bufferLayout);
9592
10456
  }
9593
10457
  mergeBufferLayouts(bufferLayouts1, bufferLayouts2) {
9594
10458
  const mergedLayouts = [...bufferLayouts1];
@@ -9605,16 +10469,16 @@ ${declarations.join("\n")}`).match(
9605
10469
  };
9606
10470
 
9607
10471
  // src/utils/buffer-layout-order.ts
9608
- var import_core8 = __toESM(require_core(), 1);
10472
+ var import_core11 = __toESM(require_core(), 1);
9609
10473
  function sortedBufferLayoutByShaderSourceLocations(shaderLayout, bufferLayout) {
9610
- const shaderLayoutMap = (0, import_core8.getShaderAttributeLocationMap)(shaderLayout);
10474
+ const shaderLayoutMap = (0, import_core11.getShaderAttributeLocationMap)(shaderLayout);
9611
10475
  const sortedLayout = bufferLayout.slice();
9612
10476
  sortedLayout.sort((a, b) => {
9613
- const minLocationA = (0, import_core8.getMinimumAttributeLocation)(
9614
- (0, import_core8.getBufferLayoutAttributeNames)(a).map((attributeName) => shaderLayoutMap[attributeName])
10477
+ const minLocationA = (0, import_core11.getMinimumAttributeLocation)(
10478
+ (0, import_core11.getBufferLayoutAttributeNames)(a).map((attributeName) => shaderLayoutMap[attributeName])
9615
10479
  );
9616
- const minLocationB = (0, import_core8.getMinimumAttributeLocation)(
9617
- (0, import_core8.getBufferLayoutAttributeNames)(b).map((attributeName) => shaderLayoutMap[attributeName])
10480
+ const minLocationB = (0, import_core11.getMinimumAttributeLocation)(
10481
+ (0, import_core11.getBufferLayoutAttributeNames)(b).map((attributeName) => shaderLayoutMap[attributeName])
9618
10482
  );
9619
10483
  return minLocationA - minLocationB;
9620
10484
  });
@@ -9768,16 +10632,8 @@ ${declarations.join("\n")}`).match(
9768
10632
  };
9769
10633
  }
9770
10634
 
9771
- // src/utils/uid.ts
9772
- var uidCounters = {};
9773
- function uid(id = "id") {
9774
- uidCounters[id] = uidCounters[id] || 1;
9775
- const count = uidCounters[id]++;
9776
- return `${id}-${count}`;
9777
- }
9778
-
9779
10635
  // src/model/gpu-vector-model-batches.ts
9780
- var import_core9 = __toESM(require_core(), 1);
10636
+ var import_core12 = __toESM(require_core(), 1);
9781
10637
  function validateGPUVectorModelLayouts(ownerName, vectors, bufferLayouts) {
9782
10638
  for (const [name, vector] of Object.entries(vectors)) {
9783
10639
  if (!vector) continue;
@@ -9841,22 +10697,22 @@ ${declarations.join("\n")}`).match(
9841
10697
  if (format.includes("<")) {
9842
10698
  throw new Error(`${ownerName} GPUVector "${name}" requires a fixed-width scalar format`);
9843
10699
  }
9844
- return import_core9.vertexFormatDecoder.getVertexFormatInfo(format);
10700
+ return import_core12.vertexFormatDecoder.getVertexFormatInfo(format);
9845
10701
  }
9846
10702
 
9847
10703
  // src/utils/gpu-vector-batch-structure.ts
9848
- var import_core10 = __toESM(require_core(), 1);
10704
+ var import_core13 = __toESM(require_core(), 1);
9849
10705
  function validateGPUVectorBatchStructure(vectors) {
9850
10706
  let reference;
9851
10707
  for (const vector of Object.values(vectors)) {
9852
10708
  if (!vector || "isConstant" in vector) continue;
9853
10709
  let rowCount = 0;
9854
10710
  for (const chunk of vector.data) rowCount += chunk.length;
9855
- (0, import_core10.assert)(rowCount === vector.length);
10711
+ (0, import_core13.assert)(rowCount === vector.length);
9856
10712
  if (reference) {
9857
- (0, import_core10.assert)(vector.length === reference.length && vector.data.length === reference.data.length);
10713
+ (0, import_core13.assert)(vector.length === reference.length && vector.data.length === reference.data.length);
9858
10714
  for (let batchIndex = 0; batchIndex < vector.data.length; batchIndex++) {
9859
- (0, import_core10.assert)(vector.data[batchIndex].length === reference.data[batchIndex].length);
10715
+ (0, import_core13.assert)(vector.data[batchIndex].length === reference.data[batchIndex].length);
9860
10716
  }
9861
10717
  } else reference = vector;
9862
10718
  }
@@ -9949,7 +10805,7 @@ ${declarations.join("\n")}`).match(
9949
10805
  }
9950
10806
 
9951
10807
  // src/model/gpu-vector-bindings.ts
9952
- var import_core11 = __toESM(require_core(), 1);
10808
+ var import_core14 = __toESM(require_core(), 1);
9953
10809
  var GPUVectorBindings = class {
9954
10810
  constructor(device, id) {
9955
10811
  this.device = device;
@@ -9974,7 +10830,7 @@ ${declarations.join("\n")}`).match(
9974
10830
  validateGPUVectorBatchStructure(columns);
9975
10831
  } else {
9976
10832
  for (const column of Object.values(columns)) {
9977
- if (column && !isConstant(column)) (0, import_core11.assert)(column.data.length === 1);
10833
+ if (column && !isConstant(column)) (0, import_core14.assert)(column.data.length === 1);
9978
10834
  }
9979
10835
  }
9980
10836
  this.claimedNames.clear();
@@ -9992,7 +10848,7 @@ ${declarations.join("\n")}`).match(
9992
10848
  (layout) => layout.name === name || layout.attributes?.some((attribute) => attribute.attribute === name)
9993
10849
  ))
9994
10850
  return [];
9995
- (0, import_core11.assert)(column.format);
10851
+ (0, import_core14.assert)(column.format);
9996
10852
  const format = column.format;
9997
10853
  const byteStride = isConstant(column) ? 0 : column.byteStride;
9998
10854
  return [{ name, stepMode, byteStride, attributes: [{ attribute: name, format, byteOffset: 0 }] }];
@@ -10008,10 +10864,10 @@ ${declarations.join("\n")}`).match(
10008
10864
  );
10009
10865
  const mode = layout?.stepMode ?? stepMode;
10010
10866
  if (mode === "instance") {
10011
- (0, import_core11.assert)(this.instanceCount === void 0 || this.instanceCount === column.length);
10867
+ (0, import_core14.assert)(this.instanceCount === void 0 || this.instanceCount === column.length);
10012
10868
  this.instanceCount = column.length;
10013
10869
  } else {
10014
- (0, import_core11.assert)(this.vertexCount === void 0 || this.vertexCount === column.length);
10870
+ (0, import_core14.assert)(this.vertexCount === void 0 || this.vertexCount === column.length);
10015
10871
  this.vertexCount = column.length;
10016
10872
  }
10017
10873
  this.rowCount = stepMode === "instance" ? this.instanceCount : this.vertexCount;
@@ -10056,7 +10912,7 @@ ${declarations.join("\n")}`).match(
10056
10912
  for (const definition of definitions) {
10057
10913
  const column = columns[definition.attribute] ?? (definition.attribute === layout.name ? columns[layout.name] : void 0);
10058
10914
  if (!column) continue;
10059
- (0, import_core11.assert)(column.format === void 0 || column.format === definition.format);
10915
+ (0, import_core14.assert)(column.format === void 0 || column.format === definition.format);
10060
10916
  if (isConstant(column)) {
10061
10917
  this.constants[definition.attribute] = getShaderConstant(column);
10062
10918
  constantByteLength = Math.max(
@@ -10083,7 +10939,7 @@ ${declarations.join("\n")}`).match(
10083
10939
  buffer = this.device.createBuffer({
10084
10940
  id: `${this.id}-${layout.name}-constant`,
10085
10941
  byteLength: bytes.byteLength,
10086
- usage: import_core11.Buffer.VERTEX | import_core11.Buffer.COPY_DST | import_core11.Buffer.COPY_SRC
10942
+ usage: import_core14.Buffer.VERTEX | import_core14.Buffer.COPY_DST | import_core14.Buffer.COPY_SRC
10087
10943
  });
10088
10944
  this.constantBuffers[layout.name] = buffer;
10089
10945
  }
@@ -10120,7 +10976,7 @@ ${declarations.join("\n")}`).match(
10120
10976
  const chunk = vector.data[0];
10121
10977
  if (!chunk) return;
10122
10978
  const byteOffset = chunk.byteOffset - layoutOffset;
10123
- (0, import_core11.assert)(byteOffset >= 0);
10979
+ (0, import_core14.assert)(byteOffset >= 0);
10124
10980
  this.buffers[name] = chunk.buffer;
10125
10981
  this.byteOffsets[name] = byteOffset;
10126
10982
  }
@@ -10129,7 +10985,7 @@ ${declarations.join("\n")}`).match(
10129
10985
  return Boolean(column && "isConstant" in column && column.isConstant);
10130
10986
  }
10131
10987
  function getShaderConstant(column) {
10132
- const information = import_core11.vertexFormatDecoder.getVertexFormatInfo(column.format);
10988
+ const information = import_core14.vertexFormatDecoder.getVertexFormatInfo(column.format);
10133
10989
  if (column.format === "unorm10-10-10-2") {
10134
10990
  const word = column.value[0];
10135
10991
  return new Float32Array([
@@ -10199,7 +11055,7 @@ ${declarations.join("\n")}`).match(
10199
11055
  }
10200
11056
 
10201
11057
  // src/shader-inputs.ts
10202
- var import_core12 = __toESM(require_core(), 1);
11058
+ var import_core15 = __toESM(require_core(), 1);
10203
11059
  var import_shaders2 = __toESM(require_shaders(), 1);
10204
11060
 
10205
11061
  // src/model/split-uniforms-and-bindings.ts
@@ -10249,7 +11105,7 @@ ${declarations.join("\n")}`).match(
10249
11105
  for (const resolvedModule of resolvedModules) {
10250
11106
  modules[resolvedModule.name] = resolvedModule;
10251
11107
  }
10252
- import_core12.log.log(1, "Creating ShaderInputs with modules", Object.keys(modules))();
11108
+ import_core15.log.log(1, "Creating ShaderInputs with modules", Object.keys(modules))();
10253
11109
  this.modules = modules;
10254
11110
  this.moduleUniforms = {};
10255
11111
  this.moduleBindings = {};
@@ -10257,7 +11113,7 @@ ${declarations.join("\n")}`).match(
10257
11113
  if (module) {
10258
11114
  this._addModule(module);
10259
11115
  if (module.name && name !== module.name && !this.options.disableWarnings) {
10260
- import_core12.log.warn(`Module name: ${name} vs ${module.name}`)();
11116
+ import_core15.log.warn(`Module name: ${name} vs ${module.name}`)();
10261
11117
  }
10262
11118
  }
10263
11119
  }
@@ -10281,7 +11137,7 @@ ${declarations.join("\n")}`).match(
10281
11137
  const module = this.modules[moduleName];
10282
11138
  if (!module) {
10283
11139
  if (!this.options.disableWarnings) {
10284
- import_core12.log.warn(`Module ${name} not found`)();
11140
+ import_core15.log.warn(`Module ${name} not found`)();
10285
11141
  }
10286
11142
  } else {
10287
11143
  const oldUniforms = this.moduleUniforms[moduleName];
@@ -10476,7 +11332,7 @@ ${declarations.join("\n")}`).match(
10476
11332
  var VERSION = true ? "5.0.0" : "untranspiled source";
10477
11333
 
10478
11334
  // ../../node_modules/probe.gl/dist/log/utils/assert.js
10479
- function assert7(condition, message) {
11335
+ function assert10(condition, message) {
10480
11336
  if (!condition) {
10481
11337
  throw new Error(message || "Assertion failed");
10482
11338
  }
@@ -10498,7 +11354,7 @@ ${declarations.join("\n")}`).match(
10498
11354
  default:
10499
11355
  return 0;
10500
11356
  }
10501
- assert7(Number.isFinite(resolvedLevel) && resolvedLevel >= 0);
11357
+ assert10(Number.isFinite(resolvedLevel) && resolvedLevel >= 0);
10502
11358
  return resolvedLevel;
10503
11359
  }
10504
11360
  function normalizeArguments(opts) {
@@ -10524,7 +11380,7 @@ ${declarations.join("\n")}`).match(
10524
11380
  opts.message = opts.message();
10525
11381
  }
10526
11382
  const messageType = typeof opts.message;
10527
- assert7(messageType === "string" || messageType === "object");
11383
+ assert10(messageType === "string" || messageType === "object");
10528
11384
  return Object.assign(opts, { args }, opts.opts);
10529
11385
  }
10530
11386
 
@@ -10940,7 +11796,7 @@ ${declarations.join("\n")}`).match(
10940
11796
  }
10941
11797
  _emit(_type, normalized2) {
10942
11798
  const method = normalized2.method;
10943
- assert7(method);
11799
+ assert10(method);
10944
11800
  normalized2.total = this.getTotal();
10945
11801
  normalized2.delta = this.getDelta();
10946
11802
  this._deltaTs = probe.getHighResolutionTimer();
@@ -10986,10 +11842,10 @@ ${declarations.join("\n")}`).match(
10986
11842
  }
10987
11843
 
10988
11844
  // ../../node_modules/probe.gl/dist/log/index.js
10989
- var log3 = new ProbeLog({ id: "@probe.gl/log" });
11845
+ var log4 = new ProbeLog({ id: "@probe.gl/log" });
10990
11846
 
10991
11847
  // ../core/src/api/utils/log.ts
10992
- var log4 = new ProbeLog({ id: "luma.gl" });
11848
+ var log5 = new ProbeLog({ id: "luma.gl" });
10993
11849
 
10994
11850
  // ../core/src/api/utils/uid.ts
10995
11851
  var uidCounters2 = {};
@@ -11000,10 +11856,10 @@ ${declarations.join("\n")}`).match(
11000
11856
  }
11001
11857
 
11002
11858
  // ../core/src/api/utils/assert.ts
11003
- function assert8(condition, message) {
11859
+ function assert11(condition, message) {
11004
11860
  if (!condition) {
11005
11861
  const error = new Error(message ?? "luma.gl assertion failed.");
11006
- Error.captureStackTrace?.(error, assert8);
11862
+ Error.captureStackTrace?.(error, assert11);
11007
11863
  throw error;
11008
11864
  }
11009
11865
  }
@@ -11029,11 +11885,11 @@ ${declarations.join("\n")}`).match(
11029
11885
  }
11030
11886
  /** Transfer exclusive ownership, or return lifetime responsibility to the caller with null. */
11031
11887
  transferOwnershipTo(owner) {
11032
- assert8(this._state === "live" && !this._destroyingOwnedResources);
11033
- assert8(!this._owner || this._owner.canChangeOwnership());
11034
- assert8(!owner || owner.canChangeOwnership());
11888
+ assert11(this._state === "live" && !this._destroyingOwnedResources);
11889
+ assert11(!this._owner || this._owner.canChangeOwnership());
11890
+ assert11(!owner || owner.canChangeOwnership());
11035
11891
  for (let ancestor = owner; ancestor; ancestor = ancestor._owner) {
11036
- assert8(ancestor !== this);
11892
+ assert11(ancestor !== this);
11037
11893
  }
11038
11894
  if (owner !== this._owner) {
11039
11895
  this._owner?._ownedResources.delete(this);
@@ -11463,7 +12319,7 @@ ${declarations.join("\n")}`).match(
11463
12319
  }
11464
12320
 
11465
12321
  // ../core/src/api/adapter/resources/buffer.ts
11466
- var Buffer4 = class _Buffer extends DeviceResource {
12322
+ var Buffer6 = class _Buffer extends DeviceResource {
11467
12323
  /** Index buffer */
11468
12324
  static INDEX = 16;
11469
12325
  /** Vertex buffer */
@@ -12171,7 +13027,7 @@ ${declarations.join("\n")}`).match(
12171
13027
  "cube-array": "2d",
12172
13028
  "3d": "3d"
12173
13029
  };
12174
- var Texture = class _Texture extends DeviceResource {
13030
+ var Texture3 = class _Texture extends DeviceResource {
12175
13031
  /** The texture can be bound for use as a sampled texture in a shader */
12176
13032
  static SAMPLE = 4;
12177
13033
  /** The texture can be bound for use as a storage texture in a shader */
@@ -12240,7 +13096,7 @@ ${declarations.join("\n")}`).match(
12240
13096
  this.width = 1;
12241
13097
  this.height = 1;
12242
13098
  if (this.props.width === void 0 || this.props.height === void 0) {
12243
- log4.warn(
13099
+ log5.warn(
12244
13100
  `${this} created with undefined width or height. This is deprecated. Use DynamicTexture instead.`
12245
13101
  )();
12246
13102
  }
@@ -12652,13 +13508,13 @@ ${declarations.join("\n")}`).match(
12652
13508
  (binding) => binding.name === bindingName || aliasName !== void 0 && binding.name.toLowerCase() === aliasName
12653
13509
  );
12654
13510
  if (!bindingLayout && !options?.ignoreWarnings) {
12655
- log4.warn(`Binding ${bindingName} not set: Not found in shader layout.`)();
13511
+ log5.warn(`Binding ${bindingName} not set: Not found in shader layout.`)();
12656
13512
  }
12657
13513
  return bindingLayout || null;
12658
13514
  }
12659
13515
 
12660
13516
  // ../core/src/dynamic/dynamic-buffer/dynamic-buffer.ts
12661
- var DEFAULT_MAX_DEBUG_DATA_BYTE_LENGTH = Buffer4.DEBUG_DATA_MAX_LENGTH;
13517
+ var DEFAULT_MAX_DEBUG_DATA_BYTE_LENGTH = Buffer6.DEBUG_DATA_MAX_LENGTH;
12662
13518
  var DynamicBuffer = class {
12663
13519
  /** Device that owns the backing buffer. */
12664
13520
  device;
@@ -12725,7 +13581,7 @@ ${declarations.join("\n")}`).match(
12725
13581
  usage: bufferProps.usage ?? adoptedBuffer?.usage,
12726
13582
  indexType: bufferProps.indexType ?? adoptedBuffer?.indexType
12727
13583
  };
12728
- if ((normalizedBufferProps.usage || 0) & Buffer4.INDEX && !normalizedBufferProps.indexType) {
13584
+ if ((normalizedBufferProps.usage || 0) & Buffer6.INDEX && !normalizedBufferProps.indexType) {
12729
13585
  if (bufferProps.data instanceof Uint32Array) {
12730
13586
  normalizedBufferProps.indexType = "uint32";
12731
13587
  } else if (bufferProps.data instanceof Uint16Array) {
@@ -13221,11 +14077,11 @@ ${declarations.join("\n")}`).match(
13221
14077
  data: void 0
13222
14078
  };
13223
14079
  if (this.device.isTextureFormatCompressed(resolvedFormat) && !userProvidedUsage) {
13224
- baseTextureProps.usage = Texture.SAMPLE | Texture.COPY_DST;
14080
+ baseTextureProps.usage = Texture3.SAMPLE | Texture3.COPY_DST;
13225
14081
  }
13226
14082
  const shouldGenerateMipmaps = this.props.mipmaps && !textureData.hasExplicitMipChain && !this.device.isTextureFormatCompressed(resolvedFormat);
13227
14083
  if (this.device.type === "webgpu" && shouldGenerateMipmaps) {
13228
- const requiredUsage = this.props.dimension === "3d" ? Texture.SAMPLE | Texture.STORAGE | Texture.COPY_DST | Texture.COPY_SRC : Texture.SAMPLE | Texture.RENDER | Texture.COPY_DST | Texture.COPY_SRC;
14084
+ const requiredUsage = this.props.dimension === "3d" ? Texture3.SAMPLE | Texture3.STORAGE | Texture3.COPY_DST | Texture3.COPY_SRC : Texture3.SAMPLE | Texture3.RENDER | Texture3.COPY_DST | Texture3.COPY_SRC;
13229
14085
  baseTextureProps.usage |= requiredUsage;
13230
14086
  }
13231
14087
  const maxMips = this.device.getMipLevelCount(baseTextureProps.width, baseTextureProps.height);
@@ -13239,14 +14095,14 @@ ${declarations.join("\n")}`).match(
13239
14095
  this._setTextureSubresources(textureData.subresources);
13240
14096
  }
13241
14097
  if (this.props.mipmaps && !textureData.hasExplicitMipChain && !shouldGenerateMipmaps) {
13242
- log4.warn(`${this} skipping auto-generated mipmaps for compressed texture format`)();
14098
+ log5.warn(`${this} skipping auto-generated mipmaps for compressed texture format`)();
13243
14099
  }
13244
14100
  if (shouldGenerateMipmaps) {
13245
14101
  this.generateMipmaps();
13246
14102
  }
13247
14103
  this.isReady = true;
13248
14104
  this.resolveReady(this.texture);
13249
- log4.info(1, `${this} created`)();
14105
+ log5.info(1, `${this} created`)();
13250
14106
  } catch (e) {
13251
14107
  const err = e instanceof Error ? e : new Error(String(e));
13252
14108
  this.rejectReady(err);
@@ -13270,7 +14126,7 @@ ${declarations.join("\n")}`).match(
13270
14126
  this.device.generateMipmapsWebGPU(this.texture);
13271
14127
  this._touch();
13272
14128
  } else {
13273
- log4.warn(`${this} mipmaps not supported on ${this.device.type}`);
14129
+ log5.warn(`${this} mipmaps not supported on ${this.device.type}`);
13274
14130
  }
13275
14131
  }
13276
14132
  /** Set sampler or create one from props */
@@ -13295,7 +14151,7 @@ ${declarations.join("\n")}`).match(
13295
14151
  const layout = this.texture.computeMemoryLayout({ width, height, depthOrArrayLayers });
13296
14152
  const buffer = this.device.createBuffer({
13297
14153
  byteLength: layout.byteLength,
13298
- usage: Buffer4.COPY_DST | Buffer4.MAP_READ
14154
+ usage: Buffer6.COPY_DST | Buffer6.MAP_READ
13299
14155
  });
13300
14156
  this.texture.readBuffer(
13301
14157
  {
@@ -13340,7 +14196,7 @@ ${declarations.join("\n")}`).match(
13340
14196
  this._view = this.texture.view;
13341
14197
  prev.destroy();
13342
14198
  this._touchGeneration();
13343
- log4.info(`${this} resized`);
14199
+ log5.info(`${this} resized`);
13344
14200
  return true;
13345
14201
  }
13346
14202
  /** Convert cube face label to texture slice index. Index can be used with `setTexture2DData()`. */
@@ -13446,12 +14302,12 @@ ${declarations.join("\n")}`).match(
13446
14302
  }
13447
14303
  _checkNotDestroyed() {
13448
14304
  if (this.destroyed) {
13449
- log4.warn(`${this} already destroyed`);
14305
+ log5.warn(`${this} already destroyed`);
13450
14306
  }
13451
14307
  }
13452
14308
  _checkReady() {
13453
14309
  if (!this.isReady) {
13454
- log4.warn(`${this} Cannot perform this operation before ready`);
14310
+ log5.warn(`${this} Cannot perform this operation before ready`);
13455
14311
  }
13456
14312
  }
13457
14313
  _touch() {
@@ -13462,7 +14318,7 @@ ${declarations.join("\n")}`).match(
13462
14318
  this._touch();
13463
14319
  }
13464
14320
  static defaultProps = {
13465
- ...Texture.defaultProps,
14321
+ ...Texture3.defaultProps,
13466
14322
  dimension: "2d",
13467
14323
  data: null,
13468
14324
  mipmaps: false
@@ -13659,13 +14515,13 @@ ${declarations.join("\n")}`).match(
13659
14515
  var GPUVectorModel = class _GPUVectorModel {
13660
14516
  /** Creates a model while allowing the backend to compile its render pipeline asynchronously. */
13661
14517
  static async createAsync(device, props) {
13662
- const ownsCompilation = !import_core13.PipelineFactory.getAsyncCompilation(device);
13663
- const asyncCompilation = ownsCompilation ? import_core13.PipelineFactory.beginAsyncCompilation(device) : import_core13.PipelineFactory.getAsyncCompilation(device);
14518
+ const ownsCompilation = !import_core16.PipelineFactory.getAsyncCompilation(device);
14519
+ const asyncCompilation = ownsCompilation ? import_core16.PipelineFactory.beginAsyncCompilation(device) : import_core16.PipelineFactory.getAsyncCompilation(device);
13664
14520
  let model;
13665
14521
  try {
13666
14522
  model = new this(device, props);
13667
14523
  } finally {
13668
- if (ownsCompilation) import_core13.PipelineFactory.endAsyncCompilation(device, asyncCompilation);
14524
+ if (ownsCompilation) import_core16.PipelineFactory.endAsyncCompilation(device, asyncCompilation);
13669
14525
  }
13670
14526
  try {
13671
14527
  if (ownsCompilation) {
@@ -13680,7 +14536,7 @@ ${declarations.join("\n")}`).match(
13680
14536
  }
13681
14537
  }
13682
14538
  static defaultProps = {
13683
- ...import_core13.RenderPipeline.defaultProps,
14539
+ ...import_core16.RenderPipeline.defaultProps,
13684
14540
  inferDrawCount: "no",
13685
14541
  enforceMatchingVectorLengths: true,
13686
14542
  geometry: null,
@@ -13864,7 +14720,7 @@ ${declarations.join("\n")}`).match(
13864
14720
  const isWebGPU = this.device.type === "webgpu";
13865
14721
  if (isWebGPU && this.props.source) {
13866
14722
  const shaderAssembler = this.props.shaderAssembler;
13867
- (0, import_core13.assert)(isShaderAssemblerForLanguage(shaderAssembler, "wgsl"));
14723
+ (0, import_core16.assert)(isShaderAssemblerForLanguage(shaderAssembler, "wgsl"));
13868
14724
  const {
13869
14725
  source: source4,
13870
14726
  getUniforms: getUniforms2,
@@ -13901,7 +14757,7 @@ ${declarations.join("\n")}`).match(
13901
14757
  this.props.shaderLayout = mergeShaderModuleBindingsIntoLayout(shaderLayout || null, modules) || null;
13902
14758
  } else {
13903
14759
  const shaderAssembler = this.props.shaderAssembler;
13904
- (0, import_core13.assert)(isShaderAssemblerForLanguage(shaderAssembler, "glsl"));
14760
+ (0, import_core16.assert)(isShaderAssemblerForLanguage(shaderAssembler, "glsl"));
13905
14761
  const { vs: vs4, fs: fs4, getUniforms: getUniforms2 } = shaderAssembler.assembleGLSLShaderPair({
13906
14762
  platformInfo,
13907
14763
  ...this.props,
@@ -13917,9 +14773,9 @@ ${declarations.join("\n")}`).match(
13917
14773
  this._getModuleUniforms = getUniforms2;
13918
14774
  this._bindingTable = [];
13919
14775
  }
13920
- this.pipelineFactory = props.pipelineFactory || import_core13.PipelineFactory.getDefaultPipelineFactory(this.device);
13921
- this.shaderFactory = props.shaderFactory || import_core13.ShaderFactory.getDefaultShaderFactory(this.device);
13922
- const asyncCompilation = import_core13.PipelineFactory.getAsyncCompilation(this.device);
14776
+ this.pipelineFactory = props.pipelineFactory || import_core16.PipelineFactory.getDefaultPipelineFactory(this.device);
14777
+ this.shaderFactory = props.shaderFactory || import_core16.ShaderFactory.getDefaultShaderFactory(this.device);
14778
+ const asyncCompilation = import_core16.PipelineFactory.getAsyncCompilation(this.device);
13923
14779
  if (asyncCompilation) {
13924
14780
  this._pipelineInitialization = this._initializePipelineAsync(props);
13925
14781
  asyncCompilation.push(this._pipelineInitialization);
@@ -14044,22 +14900,38 @@ ${declarations.join("\n")}`).match(
14044
14900
  renderPass.setParameters(state);
14045
14901
  }
14046
14902
  }
14047
- _draw(renderPass) {
14903
+ /**
14904
+ * Draws one caller-owned WebGPU indirect record in the open pass. The active index buffer
14905
+ * selects the indexed (20-byte) or non-indexed (16-byte) layout. The record supplies all
14906
+ * counts and offsets for this call. Subsequent direct draws use the model's own counts.
14907
+ * @param byteOffset Four-byte-aligned start of the record in a buffer with INDIRECT usage.
14908
+ * @returns Whether the draw completed using the same readiness rules as draw().
14909
+ */
14910
+ drawIndirect(renderPass, buffer, byteOffset = 0) {
14911
+ (0, import_core16.assert)(this.device.type === "webgpu" && (buffer.usage & import_core16.Buffer.INDIRECT) !== 0);
14912
+ return this._draw(renderPass, buffer, byteOffset);
14913
+ }
14914
+ _draw(renderPass, indirectBuffer, byteOffset = 0) {
14048
14915
  if (this.indexVector?.length === 0) {
14049
14916
  this._lastDrawTimestamp = this.device.timestamp;
14050
14917
  this._needsRedraw = false;
14051
14918
  return true;
14052
14919
  }
14053
14920
  if (!this.drawingVectorBatches && (this.geometryVectorBindings.batchCount !== 1 || this.attributeVectorBindings.batchCount !== 1)) {
14921
+ if (indirectBuffer) {
14922
+ (0, import_core16.assert)(
14923
+ this.geometryVectorBindings.batchCount <= 1 && this.attributeVectorBindings.batchCount <= 1
14924
+ );
14925
+ }
14054
14926
  return this.drawVectorGroups(renderPass);
14055
14927
  }
14056
14928
  if (this._drawBlockedReason && !this._pipelineNeedsUpdate) {
14057
- import_core13.log.info(LOG_DRAW_PRIORITY, `>>> DRAWING ABORTED ${this.id}: ${this._drawBlockedReason}`)();
14929
+ import_core16.log.info(LOG_DRAW_PRIORITY, `>>> DRAWING ABORTED ${this.id}: ${this._drawBlockedReason}`)();
14058
14930
  return false;
14059
14931
  }
14060
14932
  const loadingBinding = this._areBindingsLoading();
14061
14933
  if (loadingBinding) {
14062
- import_core13.log.info(LOG_DRAW_PRIORITY, `>>> DRAWING ABORTED ${this.id}: ${loadingBinding} not loaded`)();
14934
+ import_core16.log.info(LOG_DRAW_PRIORITY, `>>> DRAWING ABORTED ${this.id}: ${loadingBinding} not loaded`)();
14063
14935
  return false;
14064
14936
  }
14065
14937
  this._syncAttachmentFormats(renderPass);
@@ -14083,7 +14955,7 @@ ${declarations.join("\n")}`).match(
14083
14955
  this.pipeline = this._updatePipeline();
14084
14956
  pipelineErrored = this.pipeline.isErrored;
14085
14957
  if (pipelineErrored) {
14086
- import_core13.log.info(
14958
+ import_core16.log.info(
14087
14959
  LOG_DRAW_PRIORITY,
14088
14960
  `>>> DRAWING ABORTED ${this.id}: ${PIPELINE_INITIALIZATION_FAILED}`
14089
14961
  )();
@@ -14091,7 +14963,7 @@ ${declarations.join("\n")}`).match(
14091
14963
  } else {
14092
14964
  const drawValidationError = this.vertexArray.getDrawValidationError();
14093
14965
  if (drawValidationError) {
14094
- import_core13.log.info(LOG_DRAW_PRIORITY, `>>> DRAWING ABORTED ${this.id}: ${drawValidationError}`)();
14966
+ import_core16.log.info(LOG_DRAW_PRIORITY, `>>> DRAWING ABORTED ${this.id}: ${drawValidationError}`)();
14095
14967
  this._drawBlockedReason = drawValidationError;
14096
14968
  drawSuccess = false;
14097
14969
  } else {
@@ -14105,21 +14977,30 @@ ${declarations.join("\n")}`).match(
14105
14977
  _bindGroupCacheKeys: this._getBindGroupCacheKeys()
14106
14978
  });
14107
14979
  renderPass.setVertexArray(this.vertexArray);
14108
- const hasNoInstances = this.isInstanced === true && this.instanceCount === 0;
14109
- drawSuccess = hasNoInstances ? true : renderPass.draw({
14110
- isInstanced: this.isInstanced,
14111
- vertexCount: this.vertexCount,
14112
- instanceCount: this.isInstanced ? this.instanceCount : void 0,
14113
- indexCount,
14114
- firstVertex: this.firstVertex,
14115
- firstIndex: this.firstIndex,
14116
- transformFeedback: this.transformFeedback || void 0,
14117
- uniforms: this.props.uniforms,
14118
- // WebGL shares underlying cached programs even for models that have different
14119
- // parameters and topology, so those compatibility overrides remain per draw.
14120
- parameters: this.parameters,
14121
- topology: this.topology
14122
- });
14980
+ if (indirectBuffer) {
14981
+ if (indexBuffer) {
14982
+ renderPass.drawIndexedIndirect(indirectBuffer, byteOffset);
14983
+ } else {
14984
+ renderPass.drawIndirect(indirectBuffer, byteOffset);
14985
+ }
14986
+ drawSuccess = true;
14987
+ } else {
14988
+ const hasNoInstances = this.isInstanced === true && this.instanceCount === 0;
14989
+ drawSuccess = hasNoInstances ? true : renderPass.draw({
14990
+ isInstanced: this.isInstanced,
14991
+ vertexCount: this.vertexCount,
14992
+ instanceCount: this.isInstanced ? this.instanceCount : void 0,
14993
+ indexCount,
14994
+ firstVertex: this.firstVertex,
14995
+ firstIndex: this.firstIndex,
14996
+ transformFeedback: this.transformFeedback || void 0,
14997
+ uniforms: this.props.uniforms,
14998
+ // WebGL shares underlying cached programs even for models that have different
14999
+ // parameters and topology, so those compatibility overrides remain per draw.
15000
+ parameters: this.parameters,
15001
+ topology: this.topology
15002
+ });
15003
+ }
14123
15004
  }
14124
15005
  }
14125
15006
  } finally {
@@ -14166,7 +15047,7 @@ ${declarations.join("\n")}`).match(
14166
15047
  this.claimVectorLayouts(this.geometryVectorBindings);
14167
15048
  this.syncVectorBindings();
14168
15049
  const rowCount = this.geometryVectorBindings.rowCount;
14169
- (0, import_core13.assert)(
15050
+ (0, import_core16.assert)(
14170
15051
  rowCount === void 0 || this.attributeVectorBindings.vertexCount === void 0 || rowCount === this.attributeVectorBindings.vertexCount
14171
15052
  );
14172
15053
  if (this.props.inferDrawCount === "vertex")
@@ -14203,7 +15084,7 @@ ${declarations.join("\n")}`).match(
14203
15084
  const vertexCount = this.attributeVectorBindings.vertexCount;
14204
15085
  if (vertexCount !== void 0 && this.props.inferDrawCount === "vertex") {
14205
15086
  const geometryRowCount = this.geometryVectorBindings.rowCount;
14206
- (0, import_core13.assert)(geometryRowCount === void 0 || geometryRowCount === vertexCount);
15087
+ (0, import_core16.assert)(geometryRowCount === void 0 || geometryRowCount === vertexCount);
14207
15088
  if (geometryRowCount === void 0) this.setVertexCount(vertexCount);
14208
15089
  }
14209
15090
  }
@@ -14214,9 +15095,9 @@ ${declarations.join("\n")}`).match(
14214
15095
  /** Replaces the borrowed contiguous uint16/uint32 index vector. */
14215
15096
  setIndexVector(vector) {
14216
15097
  if (vector) {
14217
- (0, import_core13.assert)(vector.format === "uint8" || vector.format === "uint16" || vector.format === "uint32");
14218
- (0, import_core13.assert)(vector.data.length <= 1);
14219
- (0, import_core13.assert)(
15098
+ (0, import_core16.assert)(vector.format === "uint8" || vector.format === "uint16" || vector.format === "uint32");
15099
+ (0, import_core16.assert)(vector.data.length <= 1);
15100
+ (0, import_core16.assert)(
14220
15101
  vector.byteStride === (vector.format === "uint32" ? 4 : vector.format === "uint16" ? 2 : 1)
14221
15102
  );
14222
15103
  }
@@ -14228,7 +15109,7 @@ ${declarations.join("\n")}`).match(
14228
15109
  const chunk = vector?.data[0];
14229
15110
  if (chunk && this.indexVector) {
14230
15111
  const buffer = chunk.buffer instanceof DynamicBuffer ? chunk.buffer.buffer : chunk.buffer;
14231
- (0, import_core13.assert)(
15112
+ (0, import_core16.assert)(
14232
15113
  buffer.indexType === this.indexVector.format && chunk.byteOffset % this.indexVector.byteStride === 0
14233
15114
  );
14234
15115
  }
@@ -14302,7 +15183,7 @@ ${declarations.join("\n")}`).match(
14302
15183
  /** Binds contiguous borrowed vectors; use drawBatches() for multi-chunk inputs. */
14303
15184
  setGPUVectors(vectors, options) {
14304
15185
  const batches = getGPUVectorModelBatches(this.id, vectors);
14305
- (0, import_core13.assert)(batches.length <= 1);
15186
+ (0, import_core16.assert)(batches.length <= 1);
14306
15187
  validateGPUVectorModelLayouts(this.id, vectors, this.bufferLayout);
14307
15188
  if (batches[0]) this.setGPUData(batches[0].data);
14308
15189
  this.setBatchDrawCount(batches[0]?.rowCount ?? 0, options?.count);
@@ -14341,7 +15222,7 @@ ${declarations.join("\n")}`).match(
14341
15222
  const batches = getGPUVectorModelBatches(this.id, vectors);
14342
15223
  validateGPUVectorModelLayouts(this.id, vectors, this.bufferLayout);
14343
15224
  for (const name of Object.keys(vectors)) {
14344
- (0, import_core13.assert)(!vectors[name] || this.currentAttributes[name]);
15225
+ (0, import_core16.assert)(!vectors[name] || this.currentAttributes[name]);
14345
15226
  }
14346
15227
  const previousAttributes = { ...this.currentAttributes };
14347
15228
  const previousAttributeByteOffsets = { ...this.currentAttributeByteOffsets };
@@ -14351,7 +15232,7 @@ ${declarations.join("\n")}`).match(
14351
15232
  const previousIsInstanced = this.isInstanced;
14352
15233
  const previousVertexCountSet = this._vertexCountSet;
14353
15234
  const drawingVectorBatches = this.drawingVectorBatches;
14354
- const batchUniformStore = this.device.type === "webgpu" && batches.length ? new import_core13.UniformStore(this.device, this.shaderInputs.modules) : void 0;
15235
+ const batchUniformStore = this.device.type === "webgpu" && batches.length ? new import_core16.UniformStore(this.device, this.shaderInputs.modules) : void 0;
14355
15236
  if (batchUniformStore && this._uniformStore.uniformBuffers.size) {
14356
15237
  this.batchUniformBuffer ??= new BatchUniformBuffer(this.device);
14357
15238
  let batchByteLength = 0;
@@ -14412,7 +15293,7 @@ ${declarations.join("\n")}`).match(
14412
15293
  Object.entries(data).map(([name, chunk]) => {
14413
15294
  const layout = this.bufferLayout.find((layout2) => layout2.name === name);
14414
15295
  const byteOffset = chunk.byteOffset - (layout?.attributes?.[0]?.byteOffset ?? 0);
14415
- (0, import_core13.assert)(byteOffset >= 0);
15296
+ (0, import_core16.assert)(byteOffset >= 0);
14416
15297
  return [name, byteOffset];
14417
15298
  })
14418
15299
  )
@@ -14420,7 +15301,7 @@ ${declarations.join("\n")}`).match(
14420
15301
  );
14421
15302
  }
14422
15303
  validateVectorLengthPolicy() {
14423
- (0, import_core13.assert)(this.props.enforceMatchingVectorLengths !== false || this.props.inferDrawCount === "no");
15304
+ (0, import_core16.assert)(this.props.enforceMatchingVectorLengths !== false || this.props.inferDrawCount === "no");
14424
15305
  }
14425
15306
  setBatchDrawCount(rowCount, count = this.props.inferDrawCount === "no" ? "none" : this.props.inferDrawCount) {
14426
15307
  if (count === "instance") {
@@ -14543,7 +15424,7 @@ ${declarations.join("\n")}`).match(
14543
15424
  /** Set the shader inputs */
14544
15425
  setShaderInputs(shaderInputs) {
14545
15426
  this.shaderInputs = shaderInputs;
14546
- this._uniformStore = new import_core13.UniformStore(this.device, this.shaderInputs.modules);
15427
+ this._uniformStore = new import_core16.UniformStore(this.device, this.shaderInputs.modules);
14547
15428
  for (const [moduleName, module] of Object.entries(this.shaderInputs.modules)) {
14548
15429
  if (shaderModuleHasUniforms(module) && this._usesManagedUniformBuffer(moduleName)) {
14549
15430
  const uniformBuffer = this._uniformStore.getManagedUniformBuffer(moduleName);
@@ -14614,7 +15495,7 @@ ${declarations.join("\n")}`).match(
14614
15495
  this._drawBlockedReason = false;
14615
15496
  const disableWarnings = options?.disableWarnings ?? this.props.disableWarnings;
14616
15497
  if (buffers["indices"]) {
14617
- import_core13.log.warn(
15498
+ import_core16.log.warn(
14618
15499
  `Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`
14619
15500
  )();
14620
15501
  }
@@ -14628,7 +15509,7 @@ ${declarations.join("\n")}`).match(
14628
15509
  const bufferLayout = bufferLayoutHelper.getBufferLayout(bufferName);
14629
15510
  if (!bufferLayout) {
14630
15511
  if (!disableWarnings) {
14631
- import_core13.log.warn(`Model(${this.id}): Missing layout for buffer "${bufferName}".`)();
15512
+ import_core16.log.warn(`Model(${this.id}): Missing layout for buffer "${bufferName}".`)();
14632
15513
  }
14633
15514
  continue;
14634
15515
  }
@@ -14640,7 +15521,7 @@ ${declarations.join("\n")}`).match(
14640
15521
  const bufferSlot = this.device.type === "webgpu" ? this.vertexArray.getBufferSlot(attributeInfo.bufferName) : attributeInfo.location;
14641
15522
  if (bufferSlot === null) {
14642
15523
  if (!disableWarnings) {
14643
- import_core13.log.warn(
15524
+ import_core16.log.warn(
14644
15525
  `Model(${this.id}): Missing vertex array slot for buffer "${attributeInfo.bufferName}".`
14645
15526
  )();
14646
15527
  }
@@ -14661,7 +15542,7 @@ ${declarations.join("\n")}`).match(
14661
15542
  }
14662
15543
  }
14663
15544
  if (!set2 && !disableWarnings) {
14664
- import_core13.log.warn(
15545
+ import_core16.log.warn(
14665
15546
  `Model(${this.id}): Ignoring buffer "${resolvedBuffer.id}" for unknown attribute "${bufferName}"`
14666
15547
  )();
14667
15548
  }
@@ -14682,7 +15563,7 @@ ${declarations.join("\n")}`).match(
14682
15563
  if (attributeInfo) {
14683
15564
  this.vertexArray.setConstantWebGL(attributeInfo.location, value);
14684
15565
  } else if (!(options?.disableWarnings ?? this.props.disableWarnings)) {
14685
- import_core13.log.warn(
15566
+ import_core16.log.warn(
14686
15567
  `Model "${this.id}: Ignoring constant supplied for unknown attribute "${attributeName}"`
14687
15568
  )();
14688
15569
  }
@@ -14719,7 +15600,7 @@ ${declarations.join("\n")}`).match(
14719
15600
  * @param bindings GPUVectorModel bindings already resolved for this draw preparation.
14720
15601
  */
14721
15602
  _getBindGroups(shaderLayout = this._getCurrentShaderLayout(), bindings = this._getBindings(shaderLayout)) {
14722
- return shaderLayout.bindings.length ? (0, import_core13.normalizeBindingsByGroup)(shaderLayout, bindings) : { 0: bindings };
15603
+ return shaderLayout.bindings.length ? (0, import_core16.normalizeBindingsByGroup)(shaderLayout, bindings) : { 0: bindings };
14723
15604
  }
14724
15605
  _getBindGroupCacheKeys() {
14725
15606
  return {};
@@ -14734,9 +15615,9 @@ ${declarations.join("\n")}`).match(
14734
15615
  timestamp = Math.max(timestamp, entry.source.updateTimestamp);
14735
15616
  }
14736
15617
  for (const binding of Object.values(this.bindings)) {
14737
- if (binding instanceof import_core13.TextureView) {
15618
+ if (binding instanceof import_core16.TextureView) {
14738
15619
  timestamp = Math.max(timestamp, binding.texture.updateTimestamp);
14739
- } else if (binding instanceof import_core13.Buffer || binding instanceof import_core13.Texture || binding instanceof import_core13.ExternalTexture) {
15620
+ } else if (binding instanceof import_core16.Buffer || binding instanceof import_core16.Texture || binding instanceof import_core16.ExternalTexture) {
14740
15621
  timestamp = Math.max(timestamp, binding.updateTimestamp);
14741
15622
  } else if (binding instanceof DynamicBuffer) {
14742
15623
  timestamp = Math.max(timestamp, binding.updateTimestamp);
@@ -14795,7 +15676,7 @@ ${declarations.join("\n")}`).match(
14795
15676
  const previousVertexShader = this.pipeline?.vs ?? null;
14796
15677
  const previousFragmentShader = this.pipeline?.fs ?? null;
14797
15678
  if (this.pipeline) {
14798
- import_core13.log.log(
15679
+ import_core16.log.log(
14799
15680
  1,
14800
15681
  `GPUVectorModel ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`
14801
15682
  )();
@@ -14845,7 +15726,7 @@ ${declarations.join("\n")}`).match(
14845
15726
  };
14846
15727
  }
14847
15728
  _finishPipelineUpdate(update) {
14848
- this._attributeInfos = (0, import_core13.getAttributeInfosFromLayouts)(
15729
+ this._attributeInfos = (0, import_core16.getAttributeInfosFromLayouts)(
14849
15730
  this.pipeline.shaderLayout,
14850
15731
  this.bufferLayout
14851
15732
  );
@@ -14861,24 +15742,24 @@ ${declarations.join("\n")}`).match(
14861
15742
  _lastLogTime = 0;
14862
15743
  _logOpen = false;
14863
15744
  _logDrawCallStart() {
14864
- const logDrawTimeout = import_core13.log.level > 3 ? 0 : LOG_DRAW_TIMEOUT;
14865
- if (import_core13.log.level < 2 || Date.now() - this._lastLogTime < logDrawTimeout) {
15745
+ const logDrawTimeout = import_core16.log.level > 3 ? 0 : LOG_DRAW_TIMEOUT;
15746
+ if (import_core16.log.level < 2 || Date.now() - this._lastLogTime < logDrawTimeout) {
14866
15747
  return;
14867
15748
  }
14868
15749
  this._lastLogTime = Date.now();
14869
15750
  this._logOpen = true;
14870
- import_core13.log.group(LOG_DRAW_PRIORITY, `>>> DRAWING MODEL ${this.id}`, { collapsed: import_core13.log.level <= 2 })();
15751
+ import_core16.log.group(LOG_DRAW_PRIORITY, `>>> DRAWING MODEL ${this.id}`, { collapsed: import_core16.log.level <= 2 })();
14871
15752
  }
14872
15753
  _logDrawCallEnd() {
14873
15754
  if (this._logOpen) {
14874
15755
  const shaderLayoutTable = getDebugTableForShaderLayout(this.pipeline.shaderLayout, this.id);
14875
- import_core13.log.table(LOG_DRAW_PRIORITY, shaderLayoutTable)();
15756
+ import_core16.log.table(LOG_DRAW_PRIORITY, shaderLayoutTable)();
14876
15757
  const uniformTable = this.shaderInputs.getDebugTable();
14877
- import_core13.log.table(LOG_DRAW_PRIORITY, uniformTable)();
15758
+ import_core16.log.table(LOG_DRAW_PRIORITY, uniformTable)();
14878
15759
  const attributeTable = this._getAttributeDebugTable();
14879
- import_core13.log.table(LOG_DRAW_PRIORITY, this._attributeInfos)();
14880
- import_core13.log.table(LOG_DRAW_PRIORITY, attributeTable)();
14881
- import_core13.log.groupEnd(LOG_DRAW_PRIORITY)();
15760
+ import_core16.log.table(LOG_DRAW_PRIORITY, this._attributeInfos)();
15761
+ import_core16.log.table(LOG_DRAW_PRIORITY, attributeTable)();
15762
+ import_core16.log.groupEnd(LOG_DRAW_PRIORITY)();
14882
15763
  this._logOpen = false;
14883
15764
  }
14884
15765
  }
@@ -14918,8 +15799,8 @@ ${declarations.join("\n")}`).match(
14918
15799
  }
14919
15800
  // TODO - fix typing of luma data types
14920
15801
  _getBufferOrConstantValues(attribute, dataType) {
14921
- const TypedArrayConstructor = import_core13.dataTypeDecoder.getTypedArrayConstructor(dataType);
14922
- const typedArray = attribute instanceof import_core13.Buffer ? new TypedArrayConstructor(attribute.debugData) : attribute;
15802
+ const TypedArrayConstructor = import_core16.dataTypeDecoder.getTypedArrayConstructor(dataType);
15803
+ const typedArray = attribute instanceof import_core16.Buffer ? new TypedArrayConstructor(attribute.debugData) : attribute;
14923
15804
  return typedArray.toString();
14924
15805
  }
14925
15806
  /** Returns the current reflected shader layout or the pre-reflection empty layout. */
@@ -15005,7 +15886,7 @@ ${declarations.join("\n")}`).match(
15005
15886
  }
15006
15887
 
15007
15888
  // src/geometry/gpu-geometry.ts
15008
- var import_core14 = __toESM(require_core(), 1);
15889
+ var import_core17 = __toESM(require_core(), 1);
15009
15890
  var GPUGeometry = class {
15010
15891
  /** Application-provided or generated identifier. */
15011
15892
  id;
@@ -15030,7 +15911,7 @@ ${declarations.join("\n")}`).match(
15030
15911
  this.vertexCount = props.vertexCount;
15031
15912
  this.bufferLayout = props.bufferLayout || [];
15032
15913
  if (this.indices) {
15033
- if (!(this.indices.usage & import_core14.Buffer.INDEX)) {
15914
+ if (!(this.indices.usage & import_core17.Buffer.INDEX)) {
15034
15915
  throw new Error("Index buffer must have INDEX usage");
15035
15916
  }
15036
15917
  }
@@ -15079,7 +15960,7 @@ ${declarations.join("\n")}`).match(
15079
15960
  return void 0;
15080
15961
  }
15081
15962
  const data = geometry.indices.value;
15082
- return device.createBuffer({ usage: import_core14.Buffer.INDEX, data });
15963
+ return device.createBuffer({ usage: import_core17.Buffer.INDEX, data });
15083
15964
  }
15084
15965
  function getAttributeBuffersFromGeometry(device, geometry) {
15085
15966
  const attributes = {};
@@ -15119,7 +16000,7 @@ ${declarations.join("\n")}`).match(
15119
16000
  };
15120
16001
 
15121
16002
  // src/geometry/gpu-vector-geometry-adapter.ts
15122
- var import_core15 = __toESM(require_core(), 1);
16003
+ var import_core18 = __toESM(require_core(), 1);
15123
16004
  function makeGPUVectorGeometry(device, geometry) {
15124
16005
  const gpuGeometry = makeGPUGeometry(device, geometry);
15125
16006
  try {
@@ -15136,7 +16017,7 @@ ${declarations.join("\n")}`).match(
15136
16017
  for (const [name, buffer2] of Object.entries(geometry.attributes)) {
15137
16018
  const bufferLayout = geometry.bufferLayout.find((layout) => layout.name === name);
15138
16019
  const format = bufferLayout?.format;
15139
- const byteStride2 = bufferLayout?.byteStride ?? (format ? import_core15.vertexFormatDecoder.getVertexFormatInfo(format).byteLength : 0);
16020
+ const byteStride2 = bufferLayout?.byteStride ?? (format ? import_core18.vertexFormatDecoder.getVertexFormatInfo(format).byteLength : 0);
15140
16021
  const length5 = geometry.indices && byteStride2 ? Math.floor(buffer2.byteLength / byteStride2) : geometry.vertexCount;
15141
16022
  attributes[name] = {
15142
16023
  name,
@@ -15299,7 +16180,7 @@ ${declarations.join("\n")}`).match(
15299
16180
  };
15300
16181
 
15301
16182
  // src/material/material.ts
15302
- var import_core16 = __toESM(require_core(), 1);
16183
+ var import_core19 = __toESM(require_core(), 1);
15303
16184
 
15304
16185
  // src/material/material-factory.ts
15305
16186
  var MATERIAL_BIND_GROUP = 3;
@@ -15403,7 +16284,7 @@ ${declarations.join("\n")}`).match(
15403
16284
  ])
15404
16285
  );
15405
16286
  this.shaderInputs = props.shaderInputs || new ShaderInputs(moduleMap);
15406
- this._uniformStore = new import_core16.UniformStore(this.device, this.shaderInputs.modules);
16287
+ this._uniformStore = new import_core19.UniformStore(this.device, this.shaderInputs.modules);
15407
16288
  for (const [moduleName, module] of Object.entries(this.shaderInputs.modules)) {
15408
16289
  if (this.ownsModule(moduleName) && shaderModuleHasUniforms(module)) {
15409
16290
  const uniformBuffer = this._uniformStore.getManagedUniformBuffer(moduleName);
@@ -15518,9 +16399,9 @@ ${declarations.join("\n")}`).match(
15518
16399
  getBindingsUpdateTimestamp() {
15519
16400
  let timestamp = 0;
15520
16401
  for (const binding of Object.values(this.bindings)) {
15521
- if (binding instanceof import_core16.TextureView) {
16402
+ if (binding instanceof import_core19.TextureView) {
15522
16403
  timestamp = Math.max(timestamp, binding.texture.updateTimestamp);
15523
- } else if (binding instanceof import_core16.Buffer || binding instanceof import_core16.Texture || binding instanceof import_core16.ExternalTexture) {
16404
+ } else if (binding instanceof import_core19.Buffer || binding instanceof import_core19.Texture || binding instanceof import_core19.ExternalTexture) {
15524
16405
  timestamp = Math.max(timestamp, binding.updateTimestamp);
15525
16406
  } else if (binding instanceof DynamicBuffer) {
15526
16407
  timestamp = Math.max(timestamp, binding.updateTimestamp);
@@ -15588,7 +16469,7 @@ ${declarations.join("\n")}`).match(
15588
16469
  }
15589
16470
 
15590
16471
  // src/compute/buffer-transform.ts
15591
- var import_core17 = __toESM(require_core(), 1);
16472
+ var import_core20 = __toESM(require_core(), 1);
15592
16473
  var import_shaders4 = __toESM(require_shaders(), 1);
15593
16474
  var GL_INTERLEAVED_ATTRIBS = 35980;
15594
16475
  var GL_SEPARATE_ATTRIBS = 35981;
@@ -15662,14 +16543,14 @@ ${declarations.join("\n")}`).match(
15662
16543
  /** Binds borrowed output ranges without taking ownership or repacking vector chunks. */
15663
16544
  setOutputVectors(vectors) {
15664
16545
  const batches = getGPUVectorModelBatches(this.model.id, vectors);
15665
- (0, import_core17.assert)(batches.length === 0 || this.model.pipeline.props.bufferMode !== GL_INTERLEAVED_ATTRIBS);
15666
- (0, import_core17.assert)(batches.length <= 1);
16546
+ (0, import_core20.assert)(batches.length === 0 || this.model.pipeline.props.bufferMode !== GL_INTERLEAVED_ATTRIBS);
16547
+ (0, import_core20.assert)(batches.length <= 1);
15667
16548
  this.outputVectorBindings = vectors;
15668
16549
  this.transformFeedback.setBuffers({
15669
16550
  ...this.outputBuffers,
15670
16551
  ...Object.fromEntries(
15671
16552
  Object.entries(batches[0]?.data ?? {}).map(([name, data]) => {
15672
- (0, import_core17.assert)(data.byteStride === data.rowByteLength);
16553
+ (0, import_core20.assert)(data.byteStride === data.rowByteLength);
15673
16554
  return [
15674
16555
  name,
15675
16556
  {
@@ -15693,7 +16574,7 @@ ${declarations.join("\n")}`).match(
15693
16574
  if (!result) {
15694
16575
  throw new Error("BufferTransform#getBuffer");
15695
16576
  }
15696
- if (result instanceof import_core17.Buffer) {
16577
+ if (result instanceof import_core20.Buffer) {
15697
16578
  return result.readAsync();
15698
16579
  }
15699
16580
  const { buffer, byteOffset = 0, byteLength = buffer.byteLength } = result;
@@ -16616,192 +17497,28 @@ void main(void) {
16616
17497
  anchorMode: "apex",
16617
17498
  buildInstanceData: buildSpotLightInstanceData,
16618
17499
  geometry: SPOT_LIGHT_GEOMETRY,
16619
- idPrefix: "spot-light-model",
16620
- sizePropNames: ["spotLightLength"]
16621
- });
16622
- }
16623
- };
16624
-
16625
- // src/models/directional-light-model.ts
16626
- var DIRECTIONAL_LIGHT_GEOMETRY = new ConeGeometry({
16627
- cap: true,
16628
- nradial: 12,
16629
- nvertical: 1,
16630
- radius: 1
16631
- });
16632
- var DirectionalLightModel = class extends BaseLightModel {
16633
- constructor(device, props) {
16634
- super(device, props, {
16635
- anchorMode: "apex",
16636
- buildInstanceData: buildDirectionalLightInstanceData,
16637
- geometry: DIRECTIONAL_LIGHT_GEOMETRY,
16638
- idPrefix: "directional-light-model",
16639
- sizePropNames: ["directionalLightLength"]
16640
- });
16641
- }
16642
- };
16643
-
16644
- // src/scenegraph/scenegraph-node.ts
16645
- function assert11(condition, message) {
16646
- if (!condition) {
16647
- throw new Error(message);
16648
- }
16649
- }
16650
- var ScenegraphNode = class {
16651
- id;
16652
- matrix = new Matrix4();
16653
- display = true;
16654
- /** Local selection eligibility, independent of visibility. */
16655
- selectable = true;
16656
- /** Local hover eligibility, independent of visibility. */
16657
- hoverable = true;
16658
- position = new Vector3();
16659
- rotation = new Vector3();
16660
- scale = new Vector3(1, 1, 1);
16661
- /** Structured metadata associated with this scene node. */
16662
- metadata = {};
16663
- userData = {};
16664
- props = {};
16665
- constructor(props = {}) {
16666
- const { id } = props;
16667
- this.id = id || uid(this.constructor.name);
16668
- this._setScenegraphNodeProps(props);
16669
- }
16670
- getBounds() {
16671
- return null;
16672
- }
16673
- destroy() {
16674
- }
16675
- /** @deprecated use .destroy() */
16676
- delete() {
16677
- this.destroy();
16678
- }
16679
- setProps(props) {
16680
- this._setScenegraphNodeProps(props);
16681
- return this;
16682
- }
16683
- toString() {
16684
- return `{type: ScenegraphNode, id: ${this.id})}`;
16685
- }
16686
- setPosition(position) {
16687
- assert11(position.length === 3, "setPosition requires vector argument");
16688
- this.position = position;
16689
- return this;
16690
- }
16691
- setRotation(rotation) {
16692
- assert11(rotation.length === 3 || rotation.length === 4, "setRotation requires vector argument");
16693
- this.rotation = rotation;
16694
- return this;
16695
- }
16696
- setScale(scale5) {
16697
- assert11(scale5.length === 3, "setScale requires vector argument");
16698
- this.scale = scale5;
16699
- return this;
16700
- }
16701
- setMatrix(matrix, copyMatrix = true) {
16702
- if (copyMatrix) {
16703
- this.matrix.copy(matrix);
16704
- } else {
16705
- this.matrix = matrix;
16706
- }
16707
- }
16708
- setMatrixComponents(components2) {
16709
- const { position, rotation, scale: scale5, update = true } = components2;
16710
- if (position) {
16711
- this.setPosition(position);
16712
- }
16713
- if (rotation) {
16714
- this.setRotation(rotation);
16715
- }
16716
- if (scale5) {
16717
- this.setScale(scale5);
16718
- }
16719
- if (update) {
16720
- this.updateMatrix();
16721
- }
16722
- return this;
16723
- }
16724
- updateMatrix() {
16725
- this.matrix.identity();
16726
- this.matrix.translate(this.position);
16727
- if (this.rotation.length === 4) {
16728
- const rotationMatrix = new Matrix4().fromQuaternion(this.rotation);
16729
- this.matrix.multiplyRight(rotationMatrix);
16730
- } else {
16731
- this.matrix.rotateXYZ(this.rotation);
16732
- }
16733
- this.matrix.scale(this.scale);
16734
- return this;
16735
- }
16736
- update({ position, rotation, scale: scale5 } = {}) {
16737
- if (position) {
16738
- this.setPosition(position);
16739
- }
16740
- if (rotation) {
16741
- this.setRotation(rotation);
16742
- }
16743
- if (scale5) {
16744
- this.setScale(scale5);
16745
- }
16746
- this.updateMatrix();
16747
- return this;
16748
- }
16749
- getCoordinateUniforms(viewMatrix, modelMatrix) {
16750
- modelMatrix = modelMatrix || this.matrix;
16751
- const worldMatrix = new Matrix4(viewMatrix).multiplyRight(modelMatrix);
16752
- const worldInverse = worldMatrix.invert();
16753
- const worldInverseTranspose = worldInverse.transpose();
16754
- return {
16755
- viewMatrix,
16756
- modelMatrix,
16757
- objectMatrix: modelMatrix,
16758
- worldMatrix,
16759
- worldInverseMatrix: worldInverse,
16760
- worldInverseTransposeMatrix: worldInverseTranspose
16761
- };
17500
+ idPrefix: "spot-light-model",
17501
+ sizePropNames: ["spotLightLength"]
17502
+ });
16762
17503
  }
16763
- // TODO - copied code, not yet vetted
16764
- /*
16765
- transform() {
16766
- if (!this.parent) {
16767
- this.endPosition.set(this.position);
16768
- this.endRotation.set(this.rotation);
16769
- this.endScale.set(this.scale);
16770
- } else {
16771
- const parent = this.parent;
16772
- this.endPosition.set(this.position.add(parent.endPosition));
16773
- this.endRotation.set(this.rotation.add(parent.endRotation));
16774
- this.endScale.set(this.scale.add(parent.endScale));
16775
- }
16776
-
16777
- const ch = this.children;
16778
- for (let i = 0; i < ch.length; ++i) {
16779
- ch[i].transform();
16780
- }
16781
-
16782
- return this;
16783
- }
16784
- */
16785
- _setScenegraphNodeProps(props) {
16786
- if (props.selectable !== void 0) this.selectable = props.selectable;
16787
- if (props.hoverable !== void 0) this.hoverable = props.hoverable;
16788
- if (props.display !== void 0) {
16789
- this.display = props.display;
16790
- }
16791
- if (props?.position) {
16792
- this.setPosition(props.position);
16793
- }
16794
- if (props?.rotation) {
16795
- this.setRotation(props.rotation);
16796
- }
16797
- if (props?.scale) {
16798
- this.setScale(props.scale);
16799
- }
16800
- this.updateMatrix();
16801
- if (props?.matrix) {
16802
- this.setMatrix(props.matrix);
16803
- }
16804
- Object.assign(this.props, props);
17504
+ };
17505
+
17506
+ // src/models/directional-light-model.ts
17507
+ var DIRECTIONAL_LIGHT_GEOMETRY = new ConeGeometry({
17508
+ cap: true,
17509
+ nradial: 12,
17510
+ nvertical: 1,
17511
+ radius: 1
17512
+ });
17513
+ var DirectionalLightModel = class extends BaseLightModel {
17514
+ constructor(device, props) {
17515
+ super(device, props, {
17516
+ anchorMode: "apex",
17517
+ buildInstanceData: buildDirectionalLightInstanceData,
17518
+ geometry: DIRECTIONAL_LIGHT_GEOMETRY,
17519
+ idPrefix: "directional-light-model",
17520
+ sizePropNames: ["directionalLightLength"]
17521
+ });
16805
17522
  }
16806
17523
  };
16807
17524
 
@@ -16865,213 +17582,27 @@ void main(void) {
16865
17582
  emitPath(type, hit, first, controllerIndex) {
16866
17583
  const { path } = hit;
16867
17584
  const target = path[path.length - 1];
16868
- for (let index = path.length - 1; index >= first; index--) {
16869
- this.onEvent({ type, target, currentTarget: path[index], controllerIndex, hit });
16870
- }
16871
- }
16872
- };
16873
-
16874
- // src/scenegraph/scene-metadata.ts
16875
- var SceneMetadata = class {
16876
- entries = /* @__PURE__ */ new Map();
16877
- /** Associates metadata with a resource category and its source index. */
16878
- set(category, index, metadata) {
16879
- let categoryEntries = this.entries.get(category);
16880
- if (!categoryEntries) {
16881
- categoryEntries = /* @__PURE__ */ new Map();
16882
- this.entries.set(category, categoryEntries);
16883
- }
16884
- categoryEntries.set(index, metadata);
16885
- }
16886
- /** Returns metadata for a resource, or undefined when none was supplied. */
16887
- get(category, index = 0) {
16888
- return this.entries.get(category)?.get(index);
16889
- }
16890
- };
16891
-
16892
- // src/scenegraph/group-node.ts
16893
- var import_core18 = __toESM(require_core(), 1);
16894
-
16895
- // src/scenegraph/scenegraph-bounds.ts
16896
- function makeEmptyScenegraphBounds() {
16897
- return [
16898
- [Infinity, Infinity, Infinity],
16899
- [-Infinity, -Infinity, -Infinity]
16900
- ];
16901
- }
16902
- function expandScenegraphBounds(targetBounds, sourceBounds, transform) {
16903
- const transformMatrix = new Matrix4(transform);
16904
- for (let cornerIndex = 0; cornerIndex < 8; cornerIndex++) {
16905
- const corner = new Vector3(
16906
- sourceBounds[cornerIndex & 1 ? 1 : 0][0],
16907
- sourceBounds[cornerIndex & 2 ? 1 : 0][1],
16908
- sourceBounds[cornerIndex & 4 ? 1 : 0][2]
16909
- );
16910
- transformMatrix.transformAsPoint(corner, corner);
16911
- for (let componentIndex = 0; componentIndex < 3; componentIndex++) {
16912
- targetBounds[0][componentIndex] = Math.min(
16913
- targetBounds[0][componentIndex],
16914
- corner[componentIndex]
16915
- );
16916
- targetBounds[1][componentIndex] = Math.max(
16917
- targetBounds[1][componentIndex],
16918
- corner[componentIndex]
16919
- );
16920
- }
16921
- }
16922
- }
16923
- function areScenegraphBoundsDefined(bounds) {
16924
- return Number.isFinite(bounds[0][0]);
16925
- }
16926
-
16927
- // src/scenegraph/group-node.ts
16928
- var GroupNode = class _GroupNode extends ScenegraphNode {
16929
- children;
16930
- /** Optional evaluated GPU poses; authored matrices remain unchanged. */
16931
- transformSource;
16932
- constructor(props = {}) {
16933
- props = Array.isArray(props) ? { children: props } : props;
16934
- const { children = [] } = props;
16935
- import_core18.log.assert(
16936
- children.every((child) => child instanceof ScenegraphNode),
16937
- "every child must an instance of ScenegraphNode"
16938
- );
16939
- super(props);
16940
- this.children = children;
16941
- this.transformSource = props.transformSource ?? null;
16942
- }
16943
- getBounds() {
16944
- const result = makeEmptyScenegraphBounds();
16945
- this.traverse((node, { worldMatrix }) => {
16946
- const bounds = node.getBounds();
16947
- if (!bounds) {
16948
- return;
16949
- }
16950
- const nodeWorldMatrix = new Matrix4(worldMatrix).multiplyRight(node.matrix);
16951
- expandScenegraphBounds(result, bounds, nodeWorldMatrix);
16952
- });
16953
- return areScenegraphBoundsDefined(result) ? result : null;
16954
- }
16955
- destroy() {
16956
- this.children.forEach((child) => child.destroy());
16957
- this.removeAll();
16958
- super.destroy();
16959
- }
16960
- // Unpacks arrays and nested arrays of children
16961
- add(...children) {
16962
- for (const child of children) {
16963
- if (Array.isArray(child)) {
16964
- this.add(...child);
16965
- } else {
16966
- this.children.push(child);
16967
- }
16968
- }
16969
- return this;
16970
- }
16971
- remove(child) {
16972
- const children = this.children;
16973
- const indexOf = children.indexOf(child);
16974
- if (indexOf > -1) {
16975
- children.splice(indexOf, 1);
16976
- }
16977
- return this;
16978
- }
16979
- removeAll() {
16980
- this.children = [];
16981
- return this;
16982
- }
16983
- /** Resolve one exact ID or path. Missing nodes return undefined; ambiguous paths throw. */
16984
- findNode(path) {
16985
- const matches = this.findNodes(path);
16986
- if (matches.length > 1) {
16987
- throw new Error(`Ambiguous scenegraph path: ${path} (${matches.length} matches)`);
16988
- }
16989
- return matches[0];
16990
- }
16991
- /** Find structural matches in preorder, including hidden nodes and the search root. */
16992
- findNodes(path) {
16993
- const anchored = path.startsWith("/");
16994
- const segments = path === "/" ? [] : (anchored ? path.slice(1) : path).split("/").map((segment) => {
16995
- if (!segment || /~(?![01])/.test(segment)) {
16996
- throw new Error(`Invalid scenegraph path: ${path}`);
16997
- }
16998
- return segment.replace(/~1/g, "/").replace(/~0/g, "~");
16999
- });
17000
- const matches = [];
17001
- const ancestors = [];
17002
- const visited = /* @__PURE__ */ new Set();
17003
- const pending = [{ node: this, depth: 0 }];
17004
- while (pending.length) {
17005
- const { node, depth } = pending.pop();
17006
- (0, import_core18.assert)(!visited.has(node));
17007
- visited.add(node);
17008
- ancestors.length = depth;
17009
- ancestors.push(node.id);
17010
- const offset = ancestors.length - segments.length;
17011
- if ((anchored ? offset === 1 : offset >= 0) && segments.every((segment, index) => segment === ancestors[offset + index])) {
17012
- matches.push(node);
17013
- }
17014
- if (node instanceof _GroupNode) {
17015
- for (let index = node.children.length - 1; index >= 0; index--) {
17016
- pending.push({ node: node.children[index], depth: depth + 1 });
17017
- }
17018
- }
17019
- }
17020
- return matches;
17021
- }
17022
- traverse(visitor, { worldMatrix = new Matrix4() } = {}) {
17023
- if (!this.display) {
17024
- return;
17025
- }
17026
- const modelMatrix = new Matrix4(worldMatrix).multiplyRight(this.matrix);
17027
- for (const child of this.children) {
17028
- if (!child.display) {
17029
- continue;
17030
- }
17031
- if (child instanceof _GroupNode) {
17032
- child.traverse(visitor, { worldMatrix: modelMatrix });
17033
- } else {
17034
- visitor(child, { worldMatrix: modelMatrix });
17035
- }
17036
- }
17037
- }
17038
- /** Visits leaf nodes ordered by the camera-space centers of their aggregate bounds. */
17039
- traverseDepthSorted(visitor, { viewMatrix, worldMatrix = new Matrix4(), order = "back-to-front" }) {
17040
- const cameraMatrix = new Matrix4(viewMatrix);
17041
- const nodes = [];
17042
- this.traverse(
17043
- (node, context) => {
17044
- const bounds = node.getBounds();
17045
- const center = bounds ? new Vector3(bounds[0]).add(bounds[1]).divide([2, 2, 2]) : new Vector3();
17046
- const nodeWorldMatrix = new Matrix4(context.worldMatrix).multiplyRight(node.matrix);
17047
- nodeWorldMatrix.transformAsPoint(center, center);
17048
- cameraMatrix.transformAsPoint(center, center);
17049
- nodes.push({
17050
- node,
17051
- context: { worldMatrix: nodeWorldMatrix, bounds, depth: -center[2] },
17052
- index: nodes.length
17053
- });
17054
- },
17055
- { worldMatrix: new Matrix4(worldMatrix) }
17056
- );
17057
- const direction = order === "back-to-front" ? -1 : 1;
17058
- nodes.sort(
17059
- (first, second) => direction * (first.context.depth - second.context.depth) || first.index - second.index
17060
- );
17061
- for (const { node, context } of nodes) {
17062
- visitor(node, context);
17585
+ for (let index = path.length - 1; index >= first; index--) {
17586
+ this.onEvent({ type, target, currentTarget: path[index], controllerIndex, hit });
17063
17587
  }
17064
17588
  }
17065
- preorderTraversal(visitor, { worldMatrix = new Matrix4() } = {}) {
17066
- const modelMatrix = new Matrix4(worldMatrix).multiplyRight(this.matrix);
17067
- visitor(this, { worldMatrix: modelMatrix });
17068
- for (const child of this.children) {
17069
- if (child instanceof _GroupNode) {
17070
- child.preorderTraversal(visitor, { worldMatrix: modelMatrix });
17071
- } else {
17072
- visitor(child, { worldMatrix: modelMatrix });
17073
- }
17589
+ };
17590
+
17591
+ // src/scenegraph/scene-metadata.ts
17592
+ var SceneMetadata = class {
17593
+ entries = /* @__PURE__ */ new Map();
17594
+ /** Associates metadata with a resource category and its source index. */
17595
+ set(category, index, metadata) {
17596
+ let categoryEntries = this.entries.get(category);
17597
+ if (!categoryEntries) {
17598
+ categoryEntries = /* @__PURE__ */ new Map();
17599
+ this.entries.set(category, categoryEntries);
17074
17600
  }
17601
+ categoryEntries.set(index, metadata);
17602
+ }
17603
+ /** Returns metadata for a resource, or undefined when none was supplied. */
17604
+ get(category, index = 0) {
17605
+ return this.entries.get(category)?.get(index);
17075
17606
  }
17076
17607
  };
17077
17608
 
@@ -17096,55 +17627,13 @@ void main(void) {
17096
17627
  }
17097
17628
  };
17098
17629
 
17099
- // src/scenegraph/model-node.ts
17100
- var ModelNode = class extends ScenegraphNode {
17101
- model;
17102
- instanceMatrices;
17103
- bounds = null;
17104
- managedResources;
17105
- // TODO - is this used? override callbacks to make sure we call them with this
17106
- // onBeforeRender = null;
17107
- // onAfterRender = null;
17108
- // AfterRender = null;
17109
- constructor(props) {
17110
- super(props);
17111
- this.model = props.model;
17112
- this.managedResources = props.managedResources || [];
17113
- this.instanceMatrices = props.instanceMatrices || null;
17114
- this.bounds = props.bounds ? this.instanceMatrices ? getInstancedScenegraphBounds(props.bounds, this.instanceMatrices) : props.bounds : null;
17115
- this.setProps(props);
17116
- }
17117
- destroy() {
17118
- if (this.model) {
17119
- this.model.destroy();
17120
- this.model = null;
17121
- }
17122
- this.managedResources.forEach((resource) => resource.destroy());
17123
- this.managedResources = [];
17124
- }
17125
- getBounds() {
17126
- return this.bounds;
17127
- }
17128
- // Expose model methods
17129
- draw(renderPass) {
17130
- return this.model.draw(renderPass);
17131
- }
17132
- };
17133
- function getInstancedScenegraphBounds(bounds, instanceMatrices) {
17134
- const instancedBounds = makeEmptyScenegraphBounds();
17135
- for (const instanceMatrix of instanceMatrices) {
17136
- expandScenegraphBounds(instancedBounds, bounds, instanceMatrix);
17137
- }
17138
- return areScenegraphBoundsDefined(instancedBounds) ? instancedBounds : null;
17139
- }
17140
-
17141
17630
  // src/geometry/edge-geometry.ts
17142
- var import_core19 = __toESM(require_core(), 1);
17631
+ var import_core21 = __toESM(require_core(), 1);
17143
17632
  function makeEdgeGeometry(geometry, options = {}) {
17144
17633
  const { angleThreshold = 30, weldTolerance = 0, positionAttribute = "POSITION" } = options;
17145
17634
  const positions = getTrianglePositions(geometry, positionAttribute);
17146
- (0, import_core19.assert)(Number.isFinite(weldTolerance) && weldTolerance >= 0);
17147
- (0, import_core19.assert)(Number.isFinite(angleThreshold) && angleThreshold >= 0 && angleThreshold <= 180);
17635
+ (0, import_core21.assert)(Number.isFinite(weldTolerance) && weldTolerance >= 0);
17636
+ (0, import_core21.assert)(Number.isFinite(angleThreshold) && angleThreshold >= 0 && angleThreshold <= 180);
17148
17637
  const sourceIndices = geometry.indices?.value;
17149
17638
  const sourceCount = positions.value.length / 3;
17150
17639
  const representatives = /* @__PURE__ */ new Map();
@@ -17163,9 +17652,9 @@ void main(void) {
17163
17652
  function weldPosition(index) {
17164
17653
  const cached = representatives.get(index);
17165
17654
  if (cached !== void 0) return cached;
17166
- (0, import_core19.assert)(Number.isInteger(index) && index >= 0 && index < sourceCount);
17655
+ (0, import_core21.assert)(Number.isInteger(index) && index >= 0 && index < sourceCount);
17167
17656
  const position = readPosition(index);
17168
- (0, import_core19.assert)(position.every(Number.isFinite));
17657
+ (0, import_core21.assert)(position.every(Number.isFinite));
17169
17658
  const cell = weldTolerance > 0 ? position.map((value) => Math.floor(value / weldTolerance)) : position;
17170
17659
  const radius = weldTolerance > 0 ? 1 : 0;
17171
17660
  for (let east = -radius; east <= radius; east++) {
@@ -17239,11 +17728,11 @@ void main(void) {
17239
17728
  });
17240
17729
  }
17241
17730
  function makeEdgeGeometryFromGeometries(geometries, options = {}) {
17242
- (0, import_core19.assert)(geometries.length > 0);
17731
+ (0, import_core21.assert)(geometries.length > 0);
17243
17732
  const positionAttribute = options.positionAttribute ?? "POSITION";
17244
17733
  const attributes = geometries.map((geometry) => getTrianglePositions(geometry, positionAttribute));
17245
17734
  const firstAttribute = attributes[0];
17246
- (0, import_core19.assert)(
17735
+ (0, import_core21.assert)(
17247
17736
  attributes.every(
17248
17737
  (attribute) => attribute.value.constructor === firstAttribute.value.constructor && Boolean(attribute["normalized"]) === Boolean(firstAttribute["normalized"])
17249
17738
  )
@@ -17262,7 +17751,7 @@ void main(void) {
17262
17751
  positions.set(attribute.value, positionOffset);
17263
17752
  for (let offset = 0; offset < geometry.vertexCount; offset++) {
17264
17753
  const index = geometry.indices?.value[offset] ?? offset;
17265
- (0, import_core19.assert)(Number.isInteger(index) && index >= 0 && index < attribute.value.length / 3);
17754
+ (0, import_core21.assert)(Number.isInteger(index) && index >= 0 && index < attribute.value.length / 3);
17266
17755
  indices[indexOffset++] = index + positionOffset / 3;
17267
17756
  }
17268
17757
  positionOffset += attribute.value.length;
@@ -17279,26 +17768,26 @@ void main(void) {
17279
17768
  }
17280
17769
  function getTrianglePositions(geometry, positionAttribute) {
17281
17770
  const positions = geometry.attributes[positionAttribute];
17282
- (0, import_core19.assert)(geometry.topology === "triangle-list" && positions?.size === 3);
17283
- (0, import_core19.assert)(positions.value.length % 3 === 0 && geometry.vertexCount % 3 === 0);
17284
- (0, import_core19.assert)(
17771
+ (0, import_core21.assert)(geometry.topology === "triangle-list" && positions?.size === 3);
17772
+ (0, import_core21.assert)(positions.value.length % 3 === 0 && geometry.vertexCount % 3 === 0);
17773
+ (0, import_core21.assert)(
17285
17774
  !positions["byteStride"] || positions["byteStride"] === positions.value.BYTES_PER_ELEMENT * 3
17286
17775
  );
17287
- (0, import_core19.assert)(
17776
+ (0, import_core21.assert)(
17288
17777
  geometry.vertexCount >= 0 && geometry.vertexCount <= (geometry.indices?.value.length ?? positions.value.length / 3)
17289
17778
  );
17290
17779
  return positions;
17291
17780
  }
17292
17781
 
17293
17782
  // src/geometry/stroke-geometry.ts
17294
- var import_core20 = __toESM(require_core(), 1);
17783
+ var import_core22 = __toESM(require_core(), 1);
17295
17784
  function makeStrokeGeometry(path, options = {}) {
17296
17785
  const { width = 1, cap = "butt", join = "miter", miterLimit = 4, roundSegments = 16 } = options;
17297
- (0, import_core20.assert)(Number.isFinite(width) && width >= 0 && Number.isFinite(miterLimit) && miterLimit >= 1);
17298
- (0, import_core20.assert)(Number.isInteger(roundSegments) && roundSegments >= 2 && roundSegments <= 256);
17786
+ (0, import_core22.assert)(Number.isFinite(width) && width >= 0 && Number.isFinite(miterLimit) && miterLimit >= 1);
17787
+ (0, import_core22.assert)(Number.isInteger(roundSegments) && roundSegments >= 2 && roundSegments <= 256);
17299
17788
  const points = [];
17300
17789
  for (const position of path) {
17301
- (0, import_core20.assert)(
17790
+ (0, import_core22.assert)(
17302
17791
  Number.isFinite(position[0]) && Number.isFinite(position[1]) && Number.isFinite(position[2] ?? 0)
17303
17792
  );
17304
17793
  const previous = points.at(-1);
@@ -17458,12 +17947,12 @@ void main(void) {
17458
17947
  }
17459
17948
 
17460
17949
  // src/geometry/mesh-simplification.ts
17461
- var import_core21 = __toESM(require_core(), 1);
17950
+ var import_core23 = __toESM(require_core(), 1);
17462
17951
  var QUADRIC_COMPONENTS = 10;
17463
17952
  var BOUNDARY_COLLINEAR_TOLERANCE = 1e-10;
17464
17953
  function simplifyMesh(options) {
17465
17954
  const { positions, indices, attributes = [], preserveBoundary = true } = options;
17466
- (0, import_core21.assert)(indices.length % 3 === 0 && positions.length % 3 === 0);
17955
+ (0, import_core23.assert)(indices.length % 3 === 0 && positions.length % 3 === 0);
17467
17956
  const targetIndexCount = Math.max(
17468
17957
  0,
17469
17958
  Math.min(
@@ -17556,7 +18045,7 @@ void main(void) {
17556
18045
  const firstVertex = indices[indexOffset2];
17557
18046
  const secondVertex = indices[indexOffset2 + 1];
17558
18047
  const thirdVertex = indices[indexOffset2 + 2];
17559
- (0, import_core21.assert)(firstVertex < vertexCount && secondVertex < vertexCount && thirdVertex < vertexCount);
18048
+ (0, import_core23.assert)(firstVertex < vertexCount && secondVertex < vertexCount && thirdVertex < vertexCount);
17560
18049
  const triangle = {
17561
18050
  vertices: [firstVertex, secondVertex, thirdVertex],
17562
18051
  active: false
@@ -17891,7 +18380,7 @@ void main(void) {
17891
18380
  }
17892
18381
 
17893
18382
  // src/dynamic-texture/video-texture.ts
17894
- var import_core22 = __toESM(require_core(), 1);
18383
+ var import_core24 = __toESM(require_core(), 1);
17895
18384
  var VideoTexture = class {
17896
18385
  /** Device used to create copied and native external texture bindings. */
17897
18386
  device;
@@ -17940,7 +18429,7 @@ void main(void) {
17940
18429
  * @param props Live video source and copied texture options.
17941
18430
  */
17942
18431
  constructor(device, props) {
17943
- (0, import_core22.assert)(isHTMLVideoElementSource(props?.source) || isVideoFrameSource(props?.source));
18432
+ (0, import_core24.assert)(isHTMLVideoElementSource(props?.source) || isVideoFrameSource(props?.source));
17944
18433
  this.device = device;
17945
18434
  this.id = props.id || uid("video-texture");
17946
18435
  this._source = props.source;
@@ -17954,7 +18443,7 @@ void main(void) {
17954
18443
  * @param source Next caller-owned video source to follow.
17955
18444
  */
17956
18445
  setSource(source4) {
17957
- (0, import_core22.assert)(isHTMLVideoElementSource(source4) || isVideoFrameSource(source4));
18446
+ (0, import_core24.assert)(isHTMLVideoElementSource(source4) || isVideoFrameSource(source4));
17958
18447
  this._destroyExternalTexture();
17959
18448
  this._source = source4;
17960
18449
  this._sourceVersion++;
@@ -18032,7 +18521,7 @@ void main(void) {
18032
18521
  width: size.width,
18033
18522
  height: size.height,
18034
18523
  format: "rgba8unorm",
18035
- usage: import_core22.Texture.SAMPLE | import_core22.Texture.COPY_DST,
18524
+ usage: import_core24.Texture.SAMPLE | import_core24.Texture.COPY_DST,
18036
18525
  mipLevels: 1,
18037
18526
  sampler: this._sampler
18038
18527
  });
@@ -18067,7 +18556,7 @@ void main(void) {
18067
18556
  */
18068
18557
  _getResolvedSize() {
18069
18558
  const size = getVideoTextureSourceSize(this._source);
18070
- (0, import_core22.assert)(size.width > 0 && size.height > 0);
18559
+ (0, import_core24.assert)(size.width > 0 && size.height > 0);
18071
18560
  return size;
18072
18561
  }
18073
18562
  /** Observes current source readiness and frame identity before binding resolution. */
@@ -18132,11 +18621,11 @@ void main(void) {
18132
18621
  }
18133
18622
 
18134
18623
  // src/passes/shader-pass-renderer.ts
18135
- var import_core25 = __toESM(require_core(), 1);
18624
+ var import_core27 = __toESM(require_core(), 1);
18136
18625
  var import_shaders7 = __toESM(require_shaders(), 1);
18137
18626
 
18138
18627
  // src/compute/swap.ts
18139
- var import_core23 = __toESM(require_core(), 1);
18628
+ var import_core25 = __toESM(require_core(), 1);
18140
18629
  var Swap = class {
18141
18630
  id;
18142
18631
  /** The current resource - usually the source for renders or computations */
@@ -18168,7 +18657,7 @@ void main(void) {
18168
18657
  (colorAttachment) => typeof colorAttachment !== "string" ? colorAttachment : device.createTexture({
18169
18658
  id: `${props.id}-texture-0`,
18170
18659
  format: colorAttachment,
18171
- usage: import_core23.Texture.SAMPLE | import_core23.Texture.RENDER | import_core23.Texture.COPY_SRC | import_core23.Texture.COPY_DST,
18660
+ usage: import_core25.Texture.SAMPLE | import_core25.Texture.RENDER | import_core25.Texture.COPY_SRC | import_core25.Texture.COPY_DST,
18172
18661
  width,
18173
18662
  height
18174
18663
  })
@@ -18178,7 +18667,7 @@ void main(void) {
18178
18667
  (colorAttachment) => typeof colorAttachment !== "string" ? colorAttachment : device.createTexture({
18179
18668
  id: `${props.id}-texture-1`,
18180
18669
  format: colorAttachment,
18181
- usage: import_core23.Texture.SAMPLE | import_core23.Texture.RENDER | import_core23.Texture.COPY_SRC | import_core23.Texture.COPY_DST,
18670
+ usage: import_core25.Texture.SAMPLE | import_core25.Texture.RENDER | import_core25.Texture.COPY_SRC | import_core25.Texture.COPY_DST,
18182
18671
  width,
18183
18672
  height
18184
18673
  })
@@ -18242,7 +18731,7 @@ void main(void) {
18242
18731
  };
18243
18732
 
18244
18733
  // src/compute/computation.ts
18245
- var import_core24 = __toESM(require_core(), 1);
18734
+ var import_core26 = __toESM(require_core(), 1);
18246
18735
  var import_shaders6 = __toESM(require_shaders(), 1);
18247
18736
  var LOG_DRAW_PRIORITY2 = 2;
18248
18737
  var LOG_DRAW_TIMEOUT2 = 1e4;
@@ -18254,13 +18743,13 @@ void main(void) {
18254
18743
  * constructor remains the synchronous compatibility path.
18255
18744
  */
18256
18745
  static async createAsync(device, props) {
18257
- const ownsCompilation = !import_core24.PipelineFactory.getAsyncCompilation(device);
18258
- const asyncCompilation = ownsCompilation ? import_core24.PipelineFactory.beginAsyncCompilation(device) : import_core24.PipelineFactory.getAsyncCompilation(device);
18746
+ const ownsCompilation = !import_core26.PipelineFactory.getAsyncCompilation(device);
18747
+ const asyncCompilation = ownsCompilation ? import_core26.PipelineFactory.beginAsyncCompilation(device) : import_core26.PipelineFactory.getAsyncCompilation(device);
18259
18748
  let computation;
18260
18749
  try {
18261
18750
  computation = new _Computation(device, props);
18262
18751
  } finally {
18263
- if (ownsCompilation) import_core24.PipelineFactory.endAsyncCompilation(device, asyncCompilation);
18752
+ if (ownsCompilation) import_core26.PipelineFactory.endAsyncCompilation(device, asyncCompilation);
18264
18753
  }
18265
18754
  try {
18266
18755
  if (ownsCompilation) {
@@ -18275,7 +18764,7 @@ void main(void) {
18275
18764
  }
18276
18765
  }
18277
18766
  static defaultProps = {
18278
- ...import_core24.ComputePipeline.defaultProps,
18767
+ ...import_core26.ComputePipeline.defaultProps,
18279
18768
  id: "unnamed",
18280
18769
  handle: void 0,
18281
18770
  userData: {},
@@ -18350,10 +18839,10 @@ void main(void) {
18350
18839
  const modules = mergeShaderModules(this.props.modules, this.shaderInputs?.getModules());
18351
18840
  const defines = { ...resolvedPlugins.defines, ...this.props.defines };
18352
18841
  this.props.shaderLayout = mergeShaderModuleBindingsIntoLayout(this.props.shaderLayout, modules) || null;
18353
- this.pipelineFactory = props.pipelineFactory || import_core24.PipelineFactory.getDefaultPipelineFactory(this.device);
18354
- this.shaderFactory = props.shaderFactory || import_core24.ShaderFactory.getDefaultShaderFactory(this.device);
18842
+ this.pipelineFactory = props.pipelineFactory || import_core26.PipelineFactory.getDefaultPipelineFactory(this.device);
18843
+ this.shaderFactory = props.shaderFactory || import_core26.ShaderFactory.getDefaultShaderFactory(this.device);
18355
18844
  const shaderAssembler = this.props.shaderAssembler;
18356
- (0, import_core24.assert)(shaderAssembler instanceof WGSLShaderAssembler);
18845
+ (0, import_core26.assert)(shaderAssembler instanceof WGSLShaderAssembler);
18357
18846
  const {
18358
18847
  source: source4,
18359
18848
  getUniforms: getUniforms2,
@@ -18377,7 +18866,7 @@ void main(void) {
18377
18866
  this.props.shaderLayout || inferredShaderLayout || null,
18378
18867
  modules
18379
18868
  ) || null;
18380
- const asyncCompilation = import_core24.PipelineFactory.getAsyncCompilation(this.device);
18869
+ const asyncCompilation = import_core26.PipelineFactory.getAsyncCompilation(this.device);
18381
18870
  if (asyncCompilation) {
18382
18871
  this._pipelineInitialization = this._updatePipelineAsync();
18383
18872
  asyncCompilation.push(this._pipelineInitialization);
@@ -18444,7 +18933,7 @@ void main(void) {
18444
18933
  }
18445
18934
  setShaderInputs(shaderInputs) {
18446
18935
  this.shaderInputs = shaderInputs;
18447
- this._uniformStore = new import_core24.UniformStore(this.device, this.shaderInputs.modules);
18936
+ this._uniformStore = new import_core26.UniformStore(this.device, this.shaderInputs.modules);
18448
18937
  for (const [moduleName, module] of Object.entries(this.shaderInputs.modules)) {
18449
18938
  if (shaderModuleHasUniforms(module)) {
18450
18939
  const uniformBuffer = this._uniformStore.getManagedUniformBuffer(moduleName);
@@ -18513,7 +19002,7 @@ void main(void) {
18513
19002
  if (!this._pipelineNeedsUpdate) return null;
18514
19003
  const previousShader = this.pipeline ? this.shader : null;
18515
19004
  if (this.pipeline) {
18516
- import_core24.log.log(1, `Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)();
19005
+ import_core26.log.log(1, `Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)();
18517
19006
  }
18518
19007
  this._pipelineNeedsUpdate = false;
18519
19008
  this.shader = this.shaderFactory.createShader({
@@ -18531,27 +19020,27 @@ void main(void) {
18531
19020
  _lastLogTime = 0;
18532
19021
  _logOpen = false;
18533
19022
  _logDrawCallStart() {
18534
- const logDrawTimeout = import_core24.log.level > 3 ? 0 : LOG_DRAW_TIMEOUT2;
18535
- if (import_core24.log.level < 2 || Date.now() - this._lastLogTime < logDrawTimeout) {
19023
+ const logDrawTimeout = import_core26.log.level > 3 ? 0 : LOG_DRAW_TIMEOUT2;
19024
+ if (import_core26.log.level < 2 || Date.now() - this._lastLogTime < logDrawTimeout) {
18536
19025
  return;
18537
19026
  }
18538
19027
  this._lastLogTime = Date.now();
18539
19028
  this._logOpen = true;
18540
- import_core24.log.group(LOG_DRAW_PRIORITY2, `>>> DRAWING MODEL ${this.id}`, { collapsed: import_core24.log.level <= 2 })();
19029
+ import_core26.log.group(LOG_DRAW_PRIORITY2, `>>> DRAWING MODEL ${this.id}`, { collapsed: import_core26.log.level <= 2 })();
18541
19030
  }
18542
19031
  _logDrawCallEnd() {
18543
19032
  if (this._logOpen) {
18544
19033
  const uniformTable = this.shaderInputs.getDebugTable();
18545
- import_core24.log.table(LOG_DRAW_PRIORITY2, uniformTable)();
18546
- import_core24.log.groupEnd(LOG_DRAW_PRIORITY2)();
19034
+ import_core26.log.table(LOG_DRAW_PRIORITY2, uniformTable)();
19035
+ import_core26.log.groupEnd(LOG_DRAW_PRIORITY2)();
18547
19036
  this._logOpen = false;
18548
19037
  }
18549
19038
  }
18550
19039
  _drawCount = 0;
18551
19040
  // TODO - fix typing of luma data types
18552
19041
  _getBufferOrConstantValues(attribute, dataType) {
18553
- const TypedArrayConstructor = import_core24.dataTypeDecoder.getTypedArrayConstructor(dataType);
18554
- const typedArray = attribute instanceof import_core24.Buffer ? new TypedArrayConstructor(attribute.debugData) : attribute;
19042
+ const TypedArrayConstructor = import_core26.dataTypeDecoder.getTypedArrayConstructor(dataType);
19043
+ const typedArray = attribute instanceof import_core26.Buffer ? new TypedArrayConstructor(attribute.debugData) : attribute;
18555
19044
  return typedArray.toString();
18556
19045
  }
18557
19046
  };
@@ -18771,7 +19260,12 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
18771
19260
  if (!outputTexture) {
18772
19261
  return false;
18773
19262
  }
18774
- const framebuffer = this.device.getDefaultCanvasContext().getCurrentFramebuffer({ depthStencilFormat: false });
19263
+ this.drawOutput(commandEncoder, outputTexture, null);
19264
+ return true;
19265
+ }
19266
+ /** @internal Records presentation of a completed effect output. */
19267
+ drawOutput(commandEncoder, outputTexture, target) {
19268
+ const framebuffer = target ?? this.device.getDefaultCanvasContext().getCurrentFramebuffer({ depthStencilFormat: false });
18775
19269
  this.textureModel.setProps({ backgroundTexture: outputTexture });
18776
19270
  this.textureModel.predraw(commandEncoder);
18777
19271
  const renderPass = commandEncoder.beginRenderPass({
@@ -18779,9 +19273,11 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
18779
19273
  framebuffer,
18780
19274
  clearDepth: false
18781
19275
  });
18782
- this.textureModel.draw(renderPass);
18783
- renderPass.end();
18784
- return true;
19276
+ try {
19277
+ this.textureModel.draw(renderPass);
19278
+ } finally {
19279
+ renderPass.end();
19280
+ }
18785
19281
  }
18786
19282
  /** Runs the shaderPasses in sequence on the sourceTexture and returns a texture with the results.
18787
19283
  * @returns null if the the sourceTexture has not yet been loaded
@@ -18896,28 +19392,28 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
18896
19392
  if (isCompositeShaderPass(passDefinition)) {
18897
19393
  validateRenderTargetNames(passDefinition.name, passDefinition.renderTargets || {});
18898
19394
  this.renderTargets = createManagedRenderTargets(device, passDefinition.renderTargets || {});
18899
- if (supportsComputeOptimization(device, passDefinition)) {
18900
- this.computeRenderer = new CompositeShaderPassComputeRenderer(
19395
+ const { compute, passes } = planFullscreenPasses(device, passDefinition);
19396
+ if (compute) {
19397
+ this.computeRenderer = new FullscreenComputePass(
18901
19398
  device,
18902
- passDefinition.compute,
18903
- this.renderTargets,
18904
- shaderInputs
19399
+ compute,
19400
+ Object.fromEntries(
19401
+ Object.entries(this.renderTargets).map(([name, target]) => [
19402
+ name,
19403
+ target.texture.format
19404
+ ])
19405
+ )
18905
19406
  );
18906
19407
  }
18907
- const executableSteps = this.computeRenderer ? passDefinition.steps.filter(
18908
- (step) => !passDefinition.compute.replacedPasses.includes(step.shaderPass.name)
18909
- ) : passDefinition.steps;
18910
- this.subPassExecutions = executableSteps.flatMap(
18911
- (step) => this.createStepExecutions(passDefinition, step, flipY)
18912
- );
19408
+ this.subPassExecutions = this.createPassExecutions(passes, flipY);
18913
19409
  return;
18914
19410
  }
18915
19411
  validateShaderPassDoesNotOwnRenderTargets(passDefinition, passDefinition.name);
18916
19412
  this.renderTargets = {};
18917
- this.subPassExecutions = this.createPassExecutions(passDefinition, {
18918
- ownerName: passDefinition.name,
19413
+ this.subPassExecutions = this.createPassExecutions(
19414
+ planShaderSubpasses(passDefinition, passDefinition.name),
18919
19415
  flipY
18920
- });
19416
+ );
18921
19417
  }
18922
19418
  destroy() {
18923
19419
  this.computeRenderer?.destroy();
@@ -18938,8 +19434,23 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
18938
19434
  options.originalTexture,
18939
19435
  options.previousTexture
18940
19436
  );
18941
- this.computeRenderer.encode(options.commandEncoder, sourceTexture, options.runtimeUniforms);
18942
- for (const targetName of Object.values(this.computeRenderer.optimization.outputs)) {
19437
+ const { optimization } = this.computeRenderer;
19438
+ const outputs = Object.fromEntries(
19439
+ Object.entries(optimization.outputs).map(([binding, targetName]) => [
19440
+ binding,
19441
+ this.renderTargets[targetName].texture.view
19442
+ ])
19443
+ );
19444
+ this.computeRenderer.prepare(options.commandEncoder, sourceTexture.view, outputs, {
19445
+ ...this.shaderInputs.getUniformValues()[optimization.uniformModule],
19446
+ ...optimization.uniforms,
19447
+ ...options.runtimeUniforms[optimization.uniformModule]
19448
+ });
19449
+ const target = this.renderTargets[Object.values(optimization.outputs)[0]].texture;
19450
+ const pass = options.commandEncoder.beginComputePass({ id: optimization.name });
19451
+ this.computeRenderer.dispatch(pass, target.width, target.height);
19452
+ pass.end();
19453
+ for (const targetName of Object.values(optimization.outputs)) {
18943
19454
  this.markTargetWritten(targetName);
18944
19455
  }
18945
19456
  }
@@ -19045,34 +19556,12 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
19045
19556
  }
19046
19557
  return resolvedBindings;
19047
19558
  }
19048
- createStepExecutions(compositeShaderPass, step, flipY) {
19049
- validateShaderPassDoesNotOwnRenderTargets(
19050
- step.shaderPass,
19051
- `${compositeShaderPass.name}/${step.shaderPass.name}`
19052
- );
19053
- return this.createPassExecutions(step.shaderPass, {
19054
- ownerName: `${compositeShaderPass.name}/${step.shaderPass.name}`,
19055
- firstInputs: step.inputs,
19056
- lastOutput: step.output,
19057
- uniformOverrides: step.uniforms,
19058
- flipY
19059
- });
19060
- }
19061
- createPassExecutions(shaderPass, options) {
19062
- const subPasses = shaderPass.passes || [];
19063
- return subPasses.map((subPass, index) => {
19064
- const isFirstSubPass = index === 0;
19065
- const isLastSubPass = index === subPasses.length - 1;
19066
- const inputs = isFirstSubPass && options.firstInputs !== void 0 ? options.firstInputs : subPass.inputs;
19067
- const output = isLastSubPass && options.lastOutput !== void 0 ? options.lastOutput : subPass.output;
19068
- validateSubPassRouting(options.ownerName, inputs, output, this.renderTargets);
19559
+ createPassExecutions(passes, flipY) {
19560
+ return passes.map(({ subPass, ...pass }) => {
19561
+ validateSubPassRouting(pass.ownerName, pass.inputs, pass.output, this.renderTargets);
19069
19562
  return {
19070
- ownerName: options.ownerName,
19071
- shaderPass,
19072
- subPassRenderer: new SubPassRenderer(this.device, shaderPass, subPass, options.flipY),
19073
- inputs,
19074
- output,
19075
- uniforms: mergeUniforms(options.uniformOverrides, subPass.uniforms)
19563
+ ...pass,
19564
+ subPassRenderer: new SubPassRenderer(this.device, pass.shaderPass, subPass, flipY)
19076
19565
  };
19077
19566
  });
19078
19567
  }
@@ -19095,20 +19584,16 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
19095
19584
  return this.passDefinition.name;
19096
19585
  }
19097
19586
  };
19098
- var CompositeShaderPassComputeRenderer = class {
19587
+ var FullscreenComputePass = class {
19099
19588
  optimization;
19100
- renderTargets;
19101
- shaderInputs;
19102
19589
  computation;
19103
19590
  parameterBuffer;
19104
- constructor(device, optimization, renderTargets, shaderInputs) {
19591
+ constructor(device, optimization, outputFormats) {
19105
19592
  this.optimization = optimization;
19106
- this.renderTargets = renderTargets;
19107
- this.shaderInputs = shaderInputs;
19108
19593
  this.parameterBuffer = device.createBuffer({
19109
19594
  id: `${optimization.name}-parameters`,
19110
19595
  byteLength: Math.max(Math.ceil(optimization.uniformNames.length / 4) * 16, 16),
19111
- usage: import_core25.Buffer.UNIFORM | import_core25.Buffer.COPY_DST
19596
+ usage: import_core27.Buffer.UNIFORM | import_core27.Buffer.COPY_DST
19112
19597
  });
19113
19598
  const outputBindings = Object.entries(optimization.outputs).map(
19114
19599
  ([bindingName, targetName], outputIndex) => ({
@@ -19117,7 +19602,7 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
19117
19602
  group: 0,
19118
19603
  location: outputIndex + 2,
19119
19604
  access: "write-only",
19120
- format: renderTargets[targetName].texture.format
19605
+ format: outputFormats[targetName]
19121
19606
  })
19122
19607
  );
19123
19608
  try {
@@ -19143,12 +19628,8 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
19143
19628
  throw error;
19144
19629
  }
19145
19630
  }
19146
- encode(commandEncoder, sourceTexture, runtimeUniforms) {
19147
- const effectiveUniforms = {
19148
- ...this.shaderInputs.getUniformValues()[this.optimization.uniformModule] || {},
19149
- ...this.optimization.uniforms,
19150
- ...runtimeUniforms[this.optimization.uniformModule] || {}
19151
- };
19631
+ /** Binds the current graph or renderer resources and records its uniform upload. */
19632
+ prepare(commandEncoder, source4, outputs, effectiveUniforms) {
19152
19633
  const uniformValues = new Float32Array(
19153
19634
  Math.max(Math.ceil(this.optimization.uniformNames.length / 4) * 4, 4)
19154
19635
  );
@@ -19156,26 +19637,26 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
19156
19637
  const value = effectiveUniforms[uniformName];
19157
19638
  uniformValues[uniformIndex] = typeof value === "number" ? value : 0;
19158
19639
  }
19159
- this.parameterBuffer.write(uniformValues);
19160
- const outputEntries = Object.entries(this.optimization.outputs);
19161
- const bindings = {
19640
+ this.parameterBuffer.device.writeBufferViaCommandEncoder(
19641
+ commandEncoder,
19642
+ this.parameterBuffer,
19643
+ uniformValues
19644
+ );
19645
+ this.computation.setBindings({
19162
19646
  [this.optimization.uniformBinding]: this.parameterBuffer,
19163
- sourceTexture: sourceTexture.view
19164
- };
19165
- for (const [bindingName, targetName] of outputEntries) {
19166
- bindings[bindingName] = this.renderTargets[targetName].texture.view;
19167
- }
19168
- this.computation.setBindings(bindings);
19647
+ sourceTexture: source4,
19648
+ ...outputs
19649
+ });
19169
19650
  this.computation.predraw(commandEncoder);
19170
- const dispatchTarget = this.renderTargets[outputEntries[0][1]].texture;
19171
- const computePass = commandEncoder.beginComputePass({ id: this.optimization.name });
19651
+ }
19652
+ /** Dispatches against the dimensions of the first declared storage output. */
19653
+ dispatch(pass, width, height) {
19172
19654
  this.computation.dispatch(
19173
- computePass,
19174
- Math.ceil(dispatchTarget.width / this.optimization.workgroupSize[0]),
19175
- Math.ceil(dispatchTarget.height / this.optimization.workgroupSize[1]),
19655
+ pass,
19656
+ Math.ceil(width / this.optimization.workgroupSize[0]),
19657
+ Math.ceil(height / this.optimization.workgroupSize[1]),
19176
19658
  1
19177
19659
  );
19178
- computePass.end();
19179
19660
  }
19180
19661
  destroy() {
19181
19662
  this.computation.destroy();
@@ -19188,6 +19669,7 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
19188
19669
  subPass;
19189
19670
  flipY;
19190
19671
  constructor(device, shaderPass, subPass, flipY) {
19672
+ (0, import_shaders7.initializeShaderModule)(shaderPass);
19191
19673
  this.shaderPass = shaderPass;
19192
19674
  this.subPass = subPass;
19193
19675
  this.flipY = flipY;
@@ -19228,16 +19710,42 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
19228
19710
  this.model.draw(renderPass);
19229
19711
  }
19230
19712
  };
19713
+ function planFullscreenPasses(device, effect, options = {}) {
19714
+ const fallback = effect.initialPasses?.fragment ?? [];
19715
+ const compute = options.allowCompute !== false && supportsComputeOptimization(device, effect, options.colorFormat) ? effect.initialPasses ? effect.initialPasses.compute : effect.compute : void 0;
19716
+ const steps = effect.initialPasses ? [...compute ? [] : fallback, ...effect.steps] : compute ? effect.steps.filter((step) => !effect.compute.replacedPasses.includes(step.shaderPass.name)) : effect.steps;
19717
+ return {
19718
+ compute,
19719
+ passes: steps.flatMap((step) => {
19720
+ const ownerName = effect.name + "/" + step.shaderPass.name;
19721
+ validateShaderPassDoesNotOwnRenderTargets(step.shaderPass, ownerName);
19722
+ return planShaderSubpasses(step.shaderPass, ownerName, step);
19723
+ })
19724
+ };
19725
+ }
19726
+ function planShaderSubpasses(shaderPass, ownerName, step) {
19727
+ const subPasses = shaderPass.passes ?? [];
19728
+ return subPasses.map((subPass, index) => ({
19729
+ ownerName,
19730
+ shaderPass,
19731
+ subPass,
19732
+ inputs: (index === 0 ? step?.inputs : void 0) ?? subPass.inputs,
19733
+ output: (index === subPasses.length - 1 ? step?.output : void 0) ?? subPass.output,
19734
+ uniforms: mergeUniforms(step?.uniforms, subPass.uniforms)
19735
+ }));
19736
+ }
19231
19737
  function getExecutableShaderPasses(shaderPasses) {
19232
19738
  return shaderPasses.flatMap(
19233
- (shaderPass) => isCompositeShaderPass(shaderPass) ? shaderPass.steps.map((step) => step.shaderPass) : [shaderPass]
19739
+ (shaderPass) => isCompositeShaderPass(shaderPass) ? [...shaderPass.initialPasses?.fragment ?? [], ...shaderPass.steps].map(
19740
+ (step) => step.shaderPass
19741
+ ) : [shaderPass]
19234
19742
  );
19235
19743
  }
19236
19744
  function isCompositeShaderPass(shaderPass) {
19237
19745
  return "steps" in shaderPass;
19238
19746
  }
19239
- function supportsComputeOptimization(device, compositeShaderPass) {
19240
- const optimization = compositeShaderPass.compute;
19747
+ function supportsComputeOptimization(device, compositeShaderPass, colorFormat = device.preferredColorFormat) {
19748
+ const optimization = compositeShaderPass.initialPasses ? compositeShaderPass.initialPasses.compute : compositeShaderPass.compute;
19241
19749
  if (!optimization || device.type !== "webgpu") {
19242
19750
  return false;
19243
19751
  }
@@ -19250,7 +19758,7 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
19250
19758
  if (!target?.storage) {
19251
19759
  return false;
19252
19760
  }
19253
- const format = target.format || device.preferredColorFormat;
19761
+ const format = target.format || colorFormat;
19254
19762
  return device.getTextureFormatCapabilities(format).store;
19255
19763
  });
19256
19764
  }
@@ -19393,7 +19901,7 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
19393
19901
  width: targetSize[0],
19394
19902
  height: targetSize[1],
19395
19903
  format: spec.format || device.preferredColorFormat,
19396
- usage: import_core25.Texture.SAMPLE | import_core25.Texture.RENDER | import_core25.Texture.COPY_SRC | import_core25.Texture.COPY_DST | (spec.storage && device.type === "webgpu" && device.getTextureFormatCapabilities(spec.format || device.preferredColorFormat).store ? import_core25.Texture.STORAGE : 0),
19904
+ usage: import_core27.Texture.SAMPLE | import_core27.Texture.RENDER | import_core27.Texture.COPY_SRC | import_core27.Texture.COPY_DST | (spec.storage && device.type === "webgpu" && device.getTextureFormatCapabilities(spec.format || device.preferredColorFormat).store ? import_core27.Texture.STORAGE : 0),
19397
19905
  ...spec.sampler ? { sampler: spec.sampler } : {}
19398
19906
  });
19399
19907
  const framebuffer = device.createFramebuffer({
@@ -19447,8 +19955,152 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
19447
19955
  return [sourceAspect / outputAspect, 1];
19448
19956
  }
19449
19957
 
19958
+ // src/passes/effect-renderer.ts
19959
+ function resolveEffectOptions(effect, options) {
19960
+ if ("configure" in effect) return effect.configure(options);
19961
+ const {
19962
+ scaleResources,
19963
+ variants,
19964
+ optionDefaults,
19965
+ optionUniforms,
19966
+ optionInputs,
19967
+ historyClearOptions
19968
+ } = effect;
19969
+ const overrides = options;
19970
+ const defaults = optionDefaults;
19971
+ const readOption = (key) => overrides?.[key] ?? defaults[key];
19972
+ const readValue = (mapping) => {
19973
+ const option = readOption(mapping.option);
19974
+ if (!mapping.values) return option;
19975
+ const key = String(option);
19976
+ return Object.hasOwn(mapping.values, key) ? mapping.values[key] : void 0;
19977
+ };
19978
+ const value = variants && String(readOption(variants.option));
19979
+ const variant = variants && value !== void 0 && Object.hasOwn(variants.values, value) ? variants.values[value] : void 0;
19980
+ const resolved = { ...effect, ...variant };
19981
+ const resources = { ...resolved.resources };
19982
+ if (scaleResources) {
19983
+ const scale5 = readValue(scaleResources) ?? (scaleResources.fallback && readValue(scaleResources.fallback)) ?? scaleResources.defaultScale;
19984
+ if (typeof scale5 !== "number" || !Number.isFinite(scale5) || scale5 <= 0 && !scaleResources.minimum) {
19985
+ throw new Error(effect.name + ": resource scale must be a finite positive number");
19986
+ }
19987
+ for (const name of scaleResources.targets) {
19988
+ const resource = resources[name];
19989
+ if (!resource?.scale) continue;
19990
+ const factor = scaleResources.factors?.[name] ?? 1;
19991
+ const size = Math.max(scale5, scaleResources.minimum ?? 0) * factor;
19992
+ resources[name] = { ...resource, scale: [size, size] };
19993
+ }
19994
+ }
19995
+ for (const name of Object.keys(historyClearOptions ?? {})) {
19996
+ const mapping = historyClearOptions?.[name];
19997
+ const resource = resources[name];
19998
+ const initial = resource?.initialize;
19999
+ if (!mapping || !initial || initial === "original") continue;
20000
+ const value2 = readOption(mapping.option);
20001
+ if (typeof value2 === "number" && Number.isFinite(value2)) {
20002
+ const [, green, blue, alpha] = initial.clearColor;
20003
+ resources[name] = {
20004
+ ...resource,
20005
+ initialize: {
20006
+ clearColor: [Math.max(value2, mapping.minimum ?? -Infinity), green, blue, alpha]
20007
+ }
20008
+ };
20009
+ }
20010
+ }
20011
+ const passes = resolved.passes.map((pass) => {
20012
+ const moduleName = pass.kind === "fullscreen" ? pass.shaderPass.name : pass.module.name;
20013
+ const uniformOptions = optionUniforms?.[moduleName];
20014
+ const inputOptions = optionInputs?.[moduleName];
20015
+ if (!uniformOptions && !inputOptions) return pass;
20016
+ const uniforms = { ...pass.uniforms };
20017
+ const inputs = { ...pass.inputs };
20018
+ for (const [name, mapping] of Object.entries(uniformOptions ?? {})) {
20019
+ const value2 = readValue(mapping);
20020
+ if (value2 !== void 0) uniforms[name] = value2;
20021
+ }
20022
+ for (const [name, mapping] of Object.entries(inputOptions ?? {})) {
20023
+ const value2 = readValue(mapping);
20024
+ if (typeof value2 === "string") inputs[name] = value2;
20025
+ }
20026
+ return { ...pass, uniforms, ...inputOptions ? { inputs } : {} };
20027
+ });
20028
+ return { ...resolved, resources, passes };
20029
+ }
20030
+ function resolveEffect(effect) {
20031
+ return {
20032
+ name: effect.name,
20033
+ renderTargets: effect.resources,
20034
+ initialPasses: effect.initialPasses && {
20035
+ ...effect.initialPasses,
20036
+ fragment: effect.initialPasses.fragment.map(lowerEffectPass)
20037
+ },
20038
+ steps: effect.passes.map(lowerEffectPass)
20039
+ };
20040
+ }
20041
+ function lowerEffectPass(pass) {
20042
+ if (pass.kind === "fullscreen") return pass;
20043
+ const { kind, module, ...routing } = pass;
20044
+ return { ...routing, shaderPass: { ...module, passes: [{ action: kind }] } };
20045
+ }
20046
+ function resolveEffectEntries(effects) {
20047
+ return effects.map((entry) => {
20048
+ if (!("effect" in entry)) return resolveEffect(entry);
20049
+ const { effect } = entry;
20050
+ if ("configure" in effect && effect.configure || "optionDefaults" in effect) {
20051
+ return resolveEffect(
20052
+ resolveEffectOptions(effect, entry.options)
20053
+ );
20054
+ }
20055
+ return resolveEffect(effect);
20056
+ });
20057
+ }
20058
+ var EffectRenderer = class extends ShaderPassRenderer {
20059
+ constructor(device, { effects, ...props }) {
20060
+ super(device, {
20061
+ ...props,
20062
+ shaderPasses: resolveEffectEntries(effects)
20063
+ });
20064
+ }
20065
+ render({
20066
+ target,
20067
+ commandEncoder = this.device.commandEncoder,
20068
+ ...frame
20069
+ }) {
20070
+ if (target && target.device !== this.device) {
20071
+ throw new Error("EffectRenderer target must belong to the renderer device");
20072
+ }
20073
+ const output = this.encodeToTexture(commandEncoder, frame);
20074
+ if (target === void 0) {
20075
+ return output;
20076
+ }
20077
+ if (!output) {
20078
+ return false;
20079
+ }
20080
+ this.drawOutput(commandEncoder, output, target);
20081
+ return true;
20082
+ }
20083
+ };
20084
+
20085
+ // src/passes/scene-capture-pass.ts
20086
+ function encodeSceneCapturePass(definition, options) {
20087
+ const { commandEncoder, frame } = options;
20088
+ definition.prepare?.(commandEncoder, frame);
20089
+ const renderPass = commandEncoder.beginRenderPass({
20090
+ ...definition.pass,
20091
+ ...definition.getPassProps?.(frame),
20092
+ id: options.id ?? definition.name,
20093
+ framebuffer: options.framebuffers[definition.target]
20094
+ });
20095
+ try {
20096
+ return definition.draw(renderPass, frame);
20097
+ } finally {
20098
+ renderPass.end();
20099
+ }
20100
+ }
20101
+
19450
20102
  // src/modules/picking/picking-manager.ts
19451
- var import_core26 = __toESM(require_core(), 1);
20103
+ var import_core28 = __toESM(require_core(), 1);
19452
20104
 
19453
20105
  // src/modules/picking/picking-uniforms.ts
19454
20106
  var DEFAULT_HIGHLIGHT_COLOR = [0, 1, 1, 1];
@@ -19712,13 +20364,13 @@ layout(std140) uniform pickingUniforms {
19712
20364
  format: "rgba8unorm",
19713
20365
  width: 1,
19714
20366
  height: 1,
19715
- usage: import_core26.Texture.RENDER_ATTACHMENT
20367
+ usage: import_core28.Texture.RENDER_ATTACHMENT
19716
20368
  });
19717
20369
  const pickingTexture = this.device.createTexture({
19718
20370
  format: "rg32sint",
19719
20371
  width: 1,
19720
20372
  height: 1,
19721
- usage: import_core26.Texture.RENDER_ATTACHMENT | import_core26.Texture.COPY_SRC
20373
+ usage: import_core28.Texture.RENDER_ATTACHMENT | import_core28.Texture.COPY_SRC
19722
20374
  });
19723
20375
  return this.device.createFramebuffer({
19724
20376
  colorAttachments: [colorTexture, pickingTexture],
@@ -19730,7 +20382,7 @@ layout(std140) uniform pickingUniforms {
19730
20382
  format: "rgba8unorm",
19731
20383
  width: 1,
19732
20384
  height: 1,
19733
- usage: import_core26.Texture.RENDER_ATTACHMENT | import_core26.Texture.COPY_SRC
20385
+ usage: import_core28.Texture.RENDER_ATTACHMENT | import_core28.Texture.COPY_SRC
19734
20386
  });
19735
20387
  return this.device.createFramebuffer({
19736
20388
  colorAttachments: [pickingTexture],
@@ -19752,7 +20404,7 @@ layout(std140) uniform pickingUniforms {
19752
20404
  const layout = pickTexture.computeMemoryLayout({ width: 1, height: 1 });
19753
20405
  const readBuffer = this.device.createBuffer({
19754
20406
  byteLength: layout.byteLength,
19755
- usage: import_core26.Buffer.COPY_DST | import_core26.Buffer.MAP_READ
20407
+ usage: import_core28.Buffer.COPY_DST | import_core28.Buffer.MAP_READ
19756
20408
  });
19757
20409
  try {
19758
20410
  pickTexture.readBuffer(
@@ -19788,7 +20440,7 @@ layout(std140) uniform pickingUniforms {
19788
20440
  const layout = pickTexture.computeMemoryLayout({ width: 1, height: 1 });
19789
20441
  const readBuffer = this.device.createBuffer({
19790
20442
  byteLength: layout.byteLength,
19791
- usage: import_core26.Buffer.COPY_DST | import_core26.Buffer.MAP_READ
20443
+ usage: import_core28.Buffer.COPY_DST | import_core28.Buffer.MAP_READ
19792
20444
  });
19793
20445
  try {
19794
20446
  pickTexture.readBuffer(
@@ -20470,7 +21122,7 @@ vec4 picking_filterColor(vec4 color) {
20470
21122
  }
20471
21123
 
20472
21124
  // src/scenegraph/controllers/skin-controller.ts
20473
- var import_core27 = __toESM(require_core(), 1);
21125
+ var import_core29 = __toESM(require_core(), 1);
20474
21126
  var SkinController = class {
20475
21127
  bindings;
20476
21128
  /** Palettes owned by a GPU producer for the duration of their binding. */
@@ -20504,7 +21156,7 @@ vec4 picking_filterColor(vec4 color) {
20504
21156
  target: binding.jointMatrices
20505
21157
  });
20506
21158
  if (binding.skinJointMatrices) {
20507
- if (binding.skinJointMatrices instanceof import_core27.Buffer) {
21159
+ if (binding.skinJointMatrices instanceof import_core29.Buffer) {
20508
21160
  binding.skinJointMatrices.write(binding.jointMatrices);
20509
21161
  } else {
20510
21162
  binding.skinJointMatrices.writeData(binding.jointMatrices, {
@@ -20522,7 +21174,7 @@ vec4 picking_filterColor(vec4 color) {
20522
21174
  }
20523
21175
  /** Borrow a WebGPU storage palette and suspend CPU writes until the lease is released. */
20524
21176
  claimGPUPalette(binding) {
20525
- if (!this.bindings.includes(binding) || !(binding.skinJointMatrices instanceof import_core27.Buffer))
21177
+ if (!this.bindings.includes(binding) || !(binding.skinJointMatrices instanceof import_core29.Buffer))
20526
21178
  throw new Error("GPU skinning requires an owned storage palette");
20527
21179
  if (this.gpuDriven.has(binding)) throw new Error("Skin palette already has a GPU producer");
20528
21180
  this.gpuDriven.add(binding);
@@ -20549,7 +21201,7 @@ vec4 picking_filterColor(vec4 color) {
20549
21201
  return device.createBuffer({
20550
21202
  id: `${id}-skin-joint-matrices`,
20551
21203
  byteLength: jointMatrices.byteLength,
20552
- usage: import_core27.Buffer.STORAGE | import_core27.Buffer.COPY_DST
21204
+ usage: import_core29.Buffer.STORAGE | import_core29.Buffer.COPY_DST
20553
21205
  });
20554
21206
  }
20555
21207
  const width = jointMatrices.length / 4;
@@ -20561,7 +21213,7 @@ vec4 picking_filterColor(vec4 color) {
20561
21213
  format: "rgba32float",
20562
21214
  width,
20563
21215
  height: 1,
20564
- usage: import_core27.Texture.SAMPLE | import_core27.Texture.COPY_DST,
21216
+ usage: import_core29.Texture.SAMPLE | import_core29.Texture.COPY_DST,
20565
21217
  sampler: { minFilter: "nearest", magFilter: "nearest", mipmapFilter: "nearest" }
20566
21218
  });
20567
21219
  }
@@ -20604,7 +21256,7 @@ vec4 picking_filterColor(vec4 color) {
20604
21256
  };
20605
21257
 
20606
21258
  // src/scenegraph/controllers/billboard-controller.ts
20607
- var import_core28 = __toESM(require_core(), 1);
21259
+ var import_core30 = __toESM(require_core(), 1);
20608
21260
  var BillboardController = class {
20609
21261
  scenes;
20610
21262
  bindings = /* @__PURE__ */ new Map();
@@ -20615,8 +21267,8 @@ vec4 picking_filterColor(vec4 color) {
20615
21267
  const { definition } = binding;
20616
21268
  const forward = new Vector3(definition.viewDirection || [0, 0, 1]);
20617
21269
  const up = new Vector3(definition.up || [0, 1, 0]);
20618
- (0, import_core28.assert)(forward.magnitude() > 0 && up.magnitude() > 0);
20619
- (0, import_core28.assert)(
21270
+ (0, import_core30.assert)(forward.magnitude() > 0 && up.magnitude() > 0);
21271
+ (0, import_core30.assert)(
20620
21272
  new Vector3(forward).normalize().cross(new Vector3(up).normalize()).magnitude() > 1e-6
20621
21273
  );
20622
21274
  this.bindings.set(binding.node, binding);
@@ -20626,7 +21278,7 @@ vec4 picking_filterColor(vec4 color) {
20626
21278
  getDrawEntries(options) {
20627
21279
  const { sceneIndex = 0, cameraId = "default" } = options;
20628
21280
  const scene = this.scenes[sceneIndex];
20629
- (0, import_core28.assert)(scene);
21281
+ (0, import_core30.assert)(scene);
20630
21282
  const viewMatrix = new Matrix4(options.viewMatrix);
20631
21283
  const cameraMatrix = new Matrix4(viewMatrix).invert();
20632
21284
  const cameraPosition = new Vector3(cameraMatrix.getTranslation());
@@ -20826,7 +21478,7 @@ vec4 picking_filterColor(vec4 color) {
20826
21478
  }
20827
21479
 
20828
21480
  // src/scenegraph/controllers/area-light-controller.ts
20829
- var import_core29 = __toESM(require_core(), 1);
21481
+ var import_core31 = __toESM(require_core(), 1);
20830
21482
  var AreaLightController = class {
20831
21483
  scenes;
20832
21484
  matrixAuthoredNodes = /* @__PURE__ */ new Set();
@@ -20836,11 +21488,11 @@ vec4 picking_filterColor(vec4 color) {
20836
21488
  for (const node of matrixNodes) this.matrixAuthoredNodes.add(node);
20837
21489
  for (const { node, definition, matrixAuthored } of bindings) {
20838
21490
  if (matrixAuthored) this.matrixAuthoredNodes.add(node);
20839
- (0, import_core29.assert)(definition && (definition.type === "rect" || definition.type === "disk"));
20840
- (0, import_core29.assert)(Number.isFinite(definition.height ?? 1) && (definition.height ?? 1) > 0);
20841
- (0, import_core29.assert)(Number.isFinite(definition.intensity ?? 1e3) && (definition.intensity ?? 1e3) > 0);
20842
- (0, import_core29.assert)(Number.isFinite(definition.width ?? 1) && (definition.width ?? 1) > 0);
20843
- (0, import_core29.assert)(
21491
+ (0, import_core31.assert)(definition && (definition.type === "rect" || definition.type === "disk"));
21492
+ (0, import_core31.assert)(Number.isFinite(definition.height ?? 1) && (definition.height ?? 1) > 0);
21493
+ (0, import_core31.assert)(Number.isFinite(definition.intensity ?? 1e3) && (definition.intensity ?? 1e3) > 0);
21494
+ (0, import_core31.assert)(Number.isFinite(definition.width ?? 1) && (definition.width ?? 1) > 0);
21495
+ (0, import_core31.assert)(
20844
21496
  (definition.color || [1, 1, 1]).every(
20845
21497
  (component) => Number.isFinite(component) && component >= 0
20846
21498
  )
@@ -20906,17 +21558,17 @@ vec4 picking_filterColor(vec4 color) {
20906
21558
  function getMatrixRotation(matrix) {
20907
21559
  const horizontal = new Vector3(matrix[0], matrix[1], matrix[2]);
20908
21560
  const vertical = new Vector3(matrix[4], matrix[5], matrix[6]);
20909
- (0, import_core29.assert)(horizontal.magnitude() > 0 && vertical.magnitude() > 0);
21561
+ (0, import_core31.assert)(horizontal.magnitude() > 0 && vertical.magnitude() > 0);
20910
21562
  horizontal.normalize();
20911
21563
  vertical.normalize();
20912
21564
  vertical.subtract(new Vector3(horizontal).scale(vertical.dot(horizontal)));
20913
- (0, import_core29.assert)(vertical.magnitude() > 1e-8);
21565
+ (0, import_core31.assert)(vertical.magnitude() > 1e-8);
20914
21566
  vertical.normalize();
20915
21567
  const forward = new Vector3(horizontal).cross(vertical).normalize();
20916
21568
  const authoredForward = new Vector3(matrix[8], matrix[9], matrix[10]);
20917
- (0, import_core29.assert)(authoredForward.magnitude() > 0);
21569
+ (0, import_core31.assert)(authoredForward.magnitude() > 0);
20918
21570
  authoredForward.normalize();
20919
- (0, import_core29.assert)(Math.abs(forward.dot(authoredForward)) > 1e-8);
21571
+ (0, import_core31.assert)(Math.abs(forward.dot(authoredForward)) > 1e-8);
20920
21572
  if (forward.dot(authoredForward) < 0) forward.negate();
20921
21573
  return new Matrix4([
20922
21574
  horizontal[0],
@@ -21474,7 +22126,7 @@ vec4 picking_filterColor(vec4 color) {
21474
22126
  };
21475
22127
 
21476
22128
  // src/audio/audio-graph.ts
21477
- var import_core30 = __toESM(require_core(), 1);
22129
+ var import_core32 = __toESM(require_core(), 1);
21478
22130
  var AudioGraph = class {
21479
22131
  constructor(definition, context, destination, getEmitterInputs) {
21480
22132
  this.definition = definition;
@@ -21482,10 +22134,10 @@ vec4 picking_filterColor(vec4 color) {
21482
22134
  this.destination = destination;
21483
22135
  this.getEmitterInputs = getEmitterInputs;
21484
22136
  for (const node of definition.nodes)
21485
- (0, import_core30.assert)(!node.bypass || node.kind !== "splitter" && node.kind !== "channelmerger");
22137
+ (0, import_core32.assert)(!node.bypass || node.kind !== "splitter" && node.kind !== "channelmerger");
21486
22138
  const validateEndpoint = (index, port = 0) => {
21487
- (0, import_core30.assert)(Number.isInteger(index) && Boolean(definition.nodes[index]));
21488
- (0, import_core30.assert)(Number.isInteger(port) && port >= 0);
22139
+ (0, import_core32.assert)(Number.isInteger(index) && Boolean(definition.nodes[index]));
22140
+ (0, import_core32.assert)(Number.isInteger(port) && port >= 0);
21489
22141
  };
21490
22142
  for (const edge of definition.connections) {
21491
22143
  validateEndpoint(edge.from.node, edge.from.output);
@@ -21493,16 +22145,16 @@ vec4 picking_filterColor(vec4 color) {
21493
22145
  }
21494
22146
  for (const input of definition.inputs || []) {
21495
22147
  validateEndpoint(input.node, input.input);
21496
- (0, import_core30.assert)(Number.isInteger(input.source) && input.source >= 0);
22148
+ (0, import_core32.assert)(Number.isInteger(input.source) && input.source >= 0);
21497
22149
  }
21498
22150
  for (const output of definition.outputs || []) {
21499
22151
  validateEndpoint(output.node, output.output);
21500
- (0, import_core30.assert)(Number.isInteger(output.emitter) && output.emitter >= 0);
22152
+ (0, import_core32.assert)(Number.isInteger(output.emitter) && output.emitter >= 0);
21501
22153
  }
21502
22154
  const visiting = /* @__PURE__ */ new Set();
21503
22155
  const visited = /* @__PURE__ */ new Set();
21504
22156
  const visit = (index) => {
21505
- (0, import_core30.assert)(definition.nodes[index] && !visiting.has(index));
22157
+ (0, import_core32.assert)(definition.nodes[index] && !visiting.has(index));
21506
22158
  if (visited.has(index)) return;
21507
22159
  visiting.add(index);
21508
22160
  for (const edge of definition.connections) if (edge.from.node === index) visit(edge.to.node);
@@ -21582,7 +22234,7 @@ vec4 picking_filterColor(vec4 color) {
21582
22234
  /** Apply a scene-driven gain change using the authored transition shape. */
21583
22235
  setGain(index, gain, time = this.nodes[index].context.currentTime) {
21584
22236
  const definition = this.definition.nodes[index];
21585
- (0, import_core30.assert)(definition.kind === "gain" && !definition.bypass && gain >= 0);
22237
+ (0, import_core32.assert)(definition.kind === "gain" && !definition.bypass && gain >= 0);
21586
22238
  const parameter = this.nodes[index].gain;
21587
22239
  const duration = definition.params.duration ?? 0;
21588
22240
  const initialGain = parameter.value;
@@ -21592,7 +22244,7 @@ vec4 picking_filterColor(vec4 color) {
21592
22244
  parameter.setValueAtTime(gain, time);
21593
22245
  } else if (definition.params.interpolation === "custom") {
21594
22246
  const curve = definition.params.curve;
21595
- (0, import_core30.assert)(curve && curve.length >= 2 && curve.every((value) => value >= 0 && value <= 1));
22247
+ (0, import_core32.assert)(curve && curve.length >= 2 && curve.every((value) => value >= 0 && value <= 1));
21596
22248
  parameter.setValueCurveAtTime(
21597
22249
  Float32Array.from(curve, (value) => value * gain),
21598
22250
  time,
@@ -21678,7 +22330,7 @@ vec4 picking_filterColor(vec4 color) {
21678
22330
  }
21679
22331
 
21680
22332
  // src/audio/audio-environment.ts
21681
- var import_core31 = __toESM(require_core(), 1);
22333
+ var import_core33 = __toESM(require_core(), 1);
21682
22334
  function selectAudioEnvironmentZone(zones, position) {
21683
22335
  let selected;
21684
22336
  for (const zone of zones) {
@@ -21771,7 +22423,7 @@ vec4 picking_filterColor(vec4 color) {
21771
22423
  }
21772
22424
  };
21773
22425
  function createParametricAudioResponse(context, parameters) {
21774
- (0, import_core31.assert)((parameters.density ?? 1) === 1 && (parameters.diffusion ?? 1) === 1);
22426
+ (0, import_core33.assert)((parameters.density ?? 1) === 1 && (parameters.diffusion ?? 1) === 1);
21775
22427
  const presets = {
21776
22428
  generic: [1.49, 0.83, 7e-3, 0.011],
21777
22429
  smallRoom: [0.4, 0.83, 2e-3, 3e-3],
@@ -21788,12 +22440,12 @@ vec4 picking_filterColor(vec4 color) {
21788
22440
  underwater: [1.49, 0.1, 7e-3, 0.011]
21789
22441
  };
21790
22442
  const preset = parameters.preset ? presets[parameters.preset] : void 0;
21791
- (0, import_core31.assert)(!parameters.preset || preset);
22443
+ (0, import_core33.assert)(!parameters.preset || preset);
21792
22444
  const decay = parameters.decayTime ?? preset?.[0] ?? 1.5;
21793
22445
  const highFrequencyDecay = decay * (parameters.decayHFRatio ?? preset?.[1] ?? 0.83);
21794
22446
  const earlyDelay = parameters.reflectionsDelay ?? preset?.[2] ?? 0.02;
21795
22447
  const tailDelay = earlyDelay + (parameters.reverbDelay ?? preset?.[3] ?? 0.04);
21796
- (0, import_core31.assert)(decay > 0 && highFrequencyDecay > 0 && earlyDelay >= 0 && tailDelay >= earlyDelay);
22448
+ (0, import_core33.assert)(decay > 0 && highFrequencyDecay > 0 && earlyDelay >= 0 && tailDelay >= earlyDelay);
21797
22449
  const response = context.createBuffer(
21798
22450
  2,
21799
22451
  Math.ceil((tailDelay + Math.max(decay, highFrequencyDecay)) * context.sampleRate),
@@ -21817,7 +22469,7 @@ vec4 picking_filterColor(vec4 color) {
21817
22469
  }
21818
22470
 
21819
22471
  // src/audio/audio-controller.ts
21820
- var import_core32 = __toESM(require_core(), 1);
22472
+ var import_core34 = __toESM(require_core(), 1);
21821
22473
  var AudioController = class {
21822
22474
  gain;
21823
22475
  definition;
@@ -21927,25 +22579,25 @@ vec4 picking_filterColor(vec4 color) {
21927
22579
  /** Change a graph gain using its authored interpolation and duration. */
21928
22580
  setGraphGain(graphIndex, nodeIndex, gain) {
21929
22581
  const graph = this.graphs.get(graphIndex);
21930
- (0, import_core32.assert)(!this.destroyed && graph);
22582
+ (0, import_core34.assert)(!this.destroyed && graph);
21931
22583
  graph.setGain(nodeIndex, gain);
21932
22584
  }
21933
22585
  startSource(sourceIndex, startTime, autoplayOnly, connect) {
21934
22586
  const definition = this.definition.sources[sourceIndex];
21935
- (0, import_core32.assert)(definition);
22587
+ (0, import_core34.assert)(definition);
21936
22588
  if (autoplayOnly && !definition.autoPlay) return;
21937
22589
  const context = this.options.audioContext;
21938
22590
  const extended = definition.graph;
21939
22591
  const oscillator = extended?.oscillator;
21940
- (0, import_core32.assert)(!(definition.audio !== void 0 && oscillator));
22592
+ (0, import_core34.assert)(!(definition.audio !== void 0 && oscillator));
21941
22593
  let source4;
21942
22594
  if (oscillator) {
21943
22595
  const node = context.createOscillator();
21944
22596
  node.frequency.value = oscillator.frequency ?? 440;
21945
22597
  node.detune.value = oscillator.detune ?? 0;
21946
- (0, import_core32.assert)(oscillator.pulseWidth === void 0 || oscillator.pulseWidth === 0.5);
22598
+ (0, import_core34.assert)(oscillator.pulseWidth === void 0 || oscillator.pulseWidth === 0.5);
21947
22599
  if (oscillator.type === "custom") {
21948
- (0, import_core32.assert)(oscillator.periodicWave);
22600
+ (0, import_core34.assert)(oscillator.periodicWave);
21949
22601
  node.setPeriodicWave(
21950
22602
  context.createPeriodicWave(
21951
22603
  new Float32Array(oscillator.periodicWave.real),
@@ -21956,7 +22608,7 @@ vec4 picking_filterColor(vec4 color) {
21956
22608
  source4 = node;
21957
22609
  } else {
21958
22610
  const node = context.createBufferSource();
21959
- (0, import_core32.assert)(definition.audio !== void 0);
22611
+ (0, import_core34.assert)(definition.audio !== void 0);
21960
22612
  node.buffer = this.buffers.get(definition.audio);
21961
22613
  node.loop = definition.loop ?? false;
21962
22614
  node.loopStart = extended?.loopStart ?? 0;
@@ -22104,15 +22756,15 @@ vec4 picking_filterColor(vec4 color) {
22104
22756
  }
22105
22757
  addEmitter(index, node) {
22106
22758
  const definition = this.definition.emitters[index];
22107
- (0, import_core32.assert)(
22759
+ (0, import_core34.assert)(
22108
22760
  definition && (definition.type === "global" || definition.type === "positional" && node)
22109
22761
  );
22110
- (0, import_core32.assert)(
22762
+ (0, import_core34.assert)(
22111
22763
  !definition.positional?.shapeType || ["cone", "omnidirectional"].includes(definition.positional.shapeType)
22112
22764
  );
22113
22765
  for (const sourceIndex of this.graphEmitters.has(index) ? [] : definition.sources || []) {
22114
22766
  const source4 = this.definition.sources[sourceIndex];
22115
- (0, import_core32.assert)(
22767
+ (0, import_core34.assert)(
22116
22768
  source4 && (source4.audio !== void 0 ? this.definition.audio[source4.audio] : source4.graph?.oscillator)
22117
22769
  );
22118
22770
  }
@@ -22157,7 +22809,7 @@ vec4 picking_filterColor(vec4 color) {
22157
22809
  const audioIndices = new Set(
22158
22810
  [...sourceIndices].map((index) => {
22159
22811
  const source4 = this.definition.sources[index];
22160
- (0, import_core32.assert)(
22812
+ (0, import_core34.assert)(
22161
22813
  source4 && (source4.audio !== void 0 ? this.definition.audio[source4.audio] : source4.graph?.oscillator)
22162
22814
  );
22163
22815
  return source4.audio;
@@ -22194,7 +22846,7 @@ vec4 picking_filterColor(vec4 color) {
22194
22846
  const reverb = environment.reverb;
22195
22847
  if (!reverb) return;
22196
22848
  const response = reverb.type === "impulseResponse" ? this.buffers.get(reverb.audio) : createParametricAudioResponse(audioContext, reverb);
22197
- (0, import_core32.assert)(response);
22849
+ (0, import_core34.assert)(response);
22198
22850
  const bus = new AudioReverbBus(audioContext, response, this.gain, {
22199
22851
  ...reverb,
22200
22852
  normalize: reverb.type === "impulseResponse" ? reverb.normalize : false
@@ -22303,7 +22955,7 @@ vec4 picking_filterColor(vec4 color) {
22303
22955
  var legacyColorPicking = import_shaders9.picking;
22304
22956
 
22305
22957
  // src/geometry/ring-geometry.ts
22306
- var import_core33 = __toESM(require_core(), 1);
22958
+ var import_core35 = __toESM(require_core(), 1);
22307
22959
  var RingGeometry = class extends Geometry2 {
22308
22960
  constructor(props = {}) {
22309
22961
  const {
@@ -22314,7 +22966,7 @@ vec4 picking_filterColor(vec4 color) {
22314
22966
  startAngle = 0,
22315
22967
  angle: angle2 = Math.PI * 2
22316
22968
  } = props;
22317
- (0, import_core33.assert)(
22969
+ (0, import_core35.assert)(
22318
22970
  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
22319
22971
  );
22320
22972
  const halfHeight = height / 2;
@@ -22497,92 +23149,6 @@ struct PublishedTransforms {bodyIndex:i32,viewProjection:mat4x4f}
22497
23149
  bindingLayout: [{ name: "publishedBodyMatrices", group: 0 }]
22498
23150
  };
22499
23151
 
22500
- // src/scenegraph/controllers/morph-controller.ts
22501
- var import_core34 = __toESM(require_core(), 1);
22502
- function setMorphWeights(node, weights) {
22503
- node.userData["morphWeights"] = [...weights];
22504
- const meshes = node.userData["morphMeshes"] || [];
22505
- for (const mesh of meshes) {
22506
- mesh.preorderTraversal((child) => {
22507
- if (!(child instanceof ModelNode)) {
22508
- return;
22509
- }
22510
- const state = child.userData["morphTargets"];
22511
- if (!state) {
22512
- return;
22513
- }
22514
- const gpuWeights = child.userData["morphWeightTransport"];
22515
- if (gpuWeights) {
22516
- updateMorphWeights(gpuWeights, weights);
22517
- child.userData["morphWeights"] = [...weights];
22518
- return;
22519
- }
22520
- updateMorphTargetBuffers(child.model, state.geometry, state.targets, weights);
22521
- child.userData["morphWeights"] = [...weights];
22522
- });
22523
- }
22524
- }
22525
- function updateMorphWeights(state, weights) {
22526
- state.values.fill(0);
22527
- state.values.set(weights.slice(0, state.values.length));
22528
- if (state.data instanceof import_core34.Buffer) {
22529
- state.data.write(state.values);
22530
- } else {
22531
- state.data.writeData(state.values, { width: state.packedTargetCount, height: 1 });
22532
- }
22533
- }
22534
-
22535
- // src/animation/node-animation-binding.ts
22536
- function makeNodeAnimationBinding(node, property, options = {}) {
22537
- return {
22538
- id: options.id,
22539
- getValue: () => {
22540
- switch (property) {
22541
- case "translation":
22542
- return Array.from(node.position);
22543
- case "rotation":
22544
- return Array.from(node.rotation);
22545
- case "scale":
22546
- return Array.from(node.scale);
22547
- case "weights":
22548
- return Array.from(node.userData["morphWeights"] ?? []);
22549
- case "visibility":
22550
- return [node.display ? 1 : 0];
22551
- case "selectable":
22552
- return [node.selectable ? 1 : 0];
22553
- case "hoverable":
22554
- return [node.hoverable ? 1 : 0];
22555
- }
22556
- },
22557
- setValue: (value) => {
22558
- switch (property) {
22559
- case "translation":
22560
- node.setPosition(value).updateMatrix();
22561
- break;
22562
- case "rotation":
22563
- node.setRotation(value).updateMatrix();
22564
- break;
22565
- case "scale":
22566
- node.setScale(value).updateMatrix();
22567
- break;
22568
- case "weights":
22569
- setMorphWeights(node, value);
22570
- break;
22571
- case "selectable":
22572
- node.setProps({ selectable: value[0] !== 0 });
22573
- break;
22574
- case "hoverable":
22575
- node.setProps({ hoverable: value[0] !== 0 });
22576
- break;
22577
- case "visibility":
22578
- node.setProps({ display: value[0] !== 0 });
22579
- options.onVisibilityChange?.();
22580
- break;
22581
- }
22582
- }
22583
- };
22584
- }
22585
-
22586
23152
  // src/animation/scenegraph-animator.ts
22587
23153
  var ScenegraphAnimator = class extends Animator {
22588
23154
  mixer;