@luma.gl/engine 10.0.0-alpha.6 → 10.0.0-alpha.8

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 (316) hide show
  1. package/README.md +2 -2
  2. package/dist/arrow/arrow-geometry.cjs +1 -1
  3. package/dist/arrow/arrow-geometry.js +1 -1
  4. package/dist/arrow/arrow-picking.cjs +1 -1
  5. package/dist/arrow/arrow-picking.d.ts +1 -1
  6. package/dist/arrow/arrow-picking.js +1 -1
  7. package/dist/arrow/renderers/path/conversion/arrow-path-gpu-vectors.cjs +5 -5
  8. package/dist/arrow/renderers/path/conversion/arrow-path-gpu-vectors.d.ts +2 -2
  9. package/dist/arrow/renderers/path/conversion/arrow-path-gpu-vectors.js +5 -5
  10. package/dist/arrow/renderers/path/conversion/arrow-path-storage-gpu-vectors.cjs +3 -3
  11. package/dist/arrow/renderers/path/conversion/arrow-path-storage-gpu-vectors.js +3 -3
  12. package/dist/arrow/renderers/path/source/arrow-path-source-mapping.cjs +1 -1
  13. package/dist/arrow/renderers/path/source/arrow-path-source-mapping.js +1 -1
  14. package/dist/arrow/renderers/path/transforms/close-arrow-paths.cjs +5 -5
  15. package/dist/arrow/renderers/path/transforms/close-arrow-paths.d.ts +1 -1
  16. package/dist/arrow/renderers/path/transforms/close-arrow-paths.js +5 -5
  17. package/dist/arrow/renderers/path/transforms/gpu-path-float64-deltas.cjs +3 -3
  18. package/dist/arrow/renderers/path/transforms/gpu-path-float64-deltas.d.ts +1 -1
  19. package/dist/arrow/renderers/path/transforms/gpu-path-float64-deltas.js +3 -3
  20. package/dist/arrow/renderers/path/transforms/path-view-origins.cjs +1 -1
  21. package/dist/arrow/renderers/path/transforms/path-view-origins.d.ts +1 -1
  22. package/dist/arrow/renderers/path/transforms/path-view-origins.js +1 -1
  23. package/dist/arrow/renderers/polygon/conversion/arrow-polygon-gpu-vectors.cjs +1 -1
  24. package/dist/arrow/renderers/polygon/conversion/arrow-polygon-gpu-vectors.d.ts +1 -1
  25. package/dist/arrow/renderers/polygon/conversion/arrow-polygon-gpu-vectors.js +1 -1
  26. package/dist/arrow/renderers/polygon/renderers/arrow-polygon-renderer.cjs +4 -4
  27. package/dist/arrow/renderers/polygon/renderers/arrow-polygon-renderer.js +4 -4
  28. package/dist/arrow/renderers/polygon/source/arrow-polygon-source-mapping.cjs +1 -1
  29. package/dist/arrow/renderers/polygon/source/arrow-polygon-source-mapping.js +1 -1
  30. package/dist/arrow/renderers/splats/conversion/make-gpu-splat-data-from-arrow.cjs +1 -1
  31. package/dist/arrow/renderers/splats/conversion/make-gpu-splat-data-from-arrow.js +1 -1
  32. package/dist/arrow/renderers/text/conversion/convert-arrow-text-to-attribute.cjs +1 -1
  33. package/dist/arrow/renderers/text/conversion/convert-arrow-text-to-attribute.d.ts +1 -1
  34. package/dist/arrow/renderers/text/conversion/convert-arrow-text-to-attribute.js +1 -1
  35. package/dist/arrow/renderers/text/conversion/convert-arrow-text-vectors.cjs +5 -5
  36. package/dist/arrow/renderers/text/conversion/convert-arrow-text-vectors.d.ts +1 -1
  37. package/dist/arrow/renderers/text/conversion/convert-arrow-text-vectors.js +5 -5
  38. package/dist/arrow/renderers/text/conversion/make-gpu-text-data-from-arrow.cjs +1 -1
  39. package/dist/arrow/renderers/text/conversion/make-gpu-text-data-from-arrow.js +1 -1
  40. package/dist/arrow/renderers/text/renderers/arrow-text-picking.cjs +1 -1
  41. package/dist/arrow/renderers/text/renderers/arrow-text-picking.js +1 -1
  42. package/dist/arrow/renderers/text/renderers/arrow-text-renderer.cjs +5 -5
  43. package/dist/arrow/renderers/text/renderers/arrow-text-renderer.js +5 -5
  44. package/dist/arrow/renderers/text/source/arrow-text-source-mapping.cjs +1 -1
  45. package/dist/arrow/renderers/text/source/arrow-text-source-mapping.js +1 -1
  46. package/dist/compute/computation.cjs +5 -2
  47. package/dist/compute/computation.d.ts +1 -1
  48. package/dist/compute/computation.d.ts.map +1 -1
  49. package/dist/compute/computation.js +5 -2
  50. package/dist/compute/computation.js.map +1 -1
  51. package/dist/compute/texture-transform.d.ts +2 -2
  52. package/dist/compute/texture-transform.d.ts.map +1 -1
  53. package/dist/compute/texture-transform.js.map +1 -1
  54. package/dist/dist.dev.js +889 -597
  55. package/dist/dist.min.js +64 -59
  56. package/dist/experimental/materials/emissive-material.cjs +1 -1
  57. package/dist/experimental/materials/emissive-material.d.ts +1 -1
  58. package/dist/experimental/materials/emissive-material.d.ts.map +1 -1
  59. package/dist/experimental/materials/emissive-material.js +1 -1
  60. package/dist/experimental/materials/emissive-material.js.map +1 -1
  61. package/dist/experimental/materials/glass-material.cjs +1 -1
  62. package/dist/experimental/materials/glass-material.d.ts +1 -1
  63. package/dist/experimental/materials/glass-material.d.ts.map +1 -1
  64. package/dist/experimental/materials/glass-material.js +1 -1
  65. package/dist/experimental/materials/glass-material.js.map +1 -1
  66. package/dist/experimental/materials/glass-transmission.cjs +1 -1
  67. package/dist/experimental/materials/glass-transmission.d.ts +1 -1
  68. package/dist/experimental/materials/glass-transmission.d.ts.map +1 -1
  69. package/dist/experimental/materials/glass-transmission.js +1 -1
  70. package/dist/experimental/materials/glass-transmission.js.map +1 -1
  71. package/dist/experimental/materials/index.cjs.map +1 -1
  72. package/dist/experimental/materials/optical-caustics.cjs +1 -1
  73. package/dist/experimental/materials/optical-caustics.d.ts +1 -1
  74. package/dist/experimental/materials/optical-caustics.d.ts.map +1 -1
  75. package/dist/experimental/materials/optical-caustics.js +1 -1
  76. package/dist/experimental/materials/optical-caustics.js.map +1 -1
  77. package/dist/experimental/materials/optical-point-lights.cjs +1 -1
  78. package/dist/experimental/materials/optical-point-lights.d.ts +1 -1
  79. package/dist/experimental/materials/optical-point-lights.d.ts.map +1 -1
  80. package/dist/experimental/materials/optical-point-lights.js +1 -1
  81. package/dist/experimental/materials/optical-point-lights.js.map +1 -1
  82. package/dist/experimental/materials/reflective-material.cjs +1 -1
  83. package/dist/experimental/materials/reflective-material.d.ts +1 -1
  84. package/dist/experimental/materials/reflective-material.d.ts.map +1 -1
  85. package/dist/experimental/materials/reflective-material.js +1 -1
  86. package/dist/experimental/materials/reflective-material.js.map +1 -1
  87. package/dist/geometry/gpu-geometry.cjs +1 -1
  88. package/dist/geometry/gpu-geometry.d.ts.map +1 -1
  89. package/dist/geometry/gpu-geometry.js +1 -1
  90. package/dist/geometry/gpu-geometry.js.map +1 -1
  91. package/dist/gltf/gltf/gltf-extension-support.cjs +25 -5
  92. package/dist/gltf/gltf/gltf-extension-support.d.ts.map +1 -1
  93. package/dist/gltf/gltf/gltf-extension-support.js +27 -5
  94. package/dist/gltf/gltf/gltf-extension-support.js.map +1 -1
  95. package/dist/gltf/gltf/gltf-lod.cjs +21 -6
  96. package/dist/gltf/gltf/gltf-lod.d.ts.map +1 -1
  97. package/dist/gltf/gltf/gltf-lod.js +20 -4
  98. package/dist/gltf/gltf/gltf-lod.js.map +1 -1
  99. package/dist/gltf/index.cjs.map +1 -1
  100. package/dist/gltf/types/gltf-json-schema.d.ts +37 -37
  101. package/dist/gltf/types/gltf-json-schema.d.ts.map +1 -1
  102. package/dist/gltf/types/gltf-postprocessed-schema.d.ts +28 -28
  103. package/dist/gltf/types/gltf-postprocessed-schema.d.ts.map +1 -1
  104. package/dist/graph/models/index.cjs.map +3 -3
  105. package/dist/graph/models/path/path-attribute-model.cjs +2 -2
  106. package/dist/graph/models/path/path-attribute-model.d.ts +2 -2
  107. package/dist/graph/models/path/path-attribute-model.js +2 -2
  108. package/dist/graph/models/path/path-storage-model.cjs +1 -1
  109. package/dist/graph/models/path/path-storage-model.d.ts +1 -1
  110. package/dist/graph/models/path/path-storage-model.js +1 -1
  111. package/dist/graph/models/path/path-trips-storage-model.d.ts +2 -2
  112. package/dist/graph/models/polygon/polygon-attribute-model.cjs +2 -2
  113. package/dist/graph/models/polygon/polygon-attribute-model.js +2 -2
  114. package/dist/graph/models/polygon/polygon-storage-model.cjs +2 -2
  115. package/dist/graph/models/polygon/polygon-storage-model.js +2 -2
  116. package/dist/graph/physics/index.cjs +3 -0
  117. package/dist/graph/physics/index.cjs.map +3 -3
  118. package/dist/graph/physics/index.d.ts +2 -0
  119. package/dist/graph/physics/index.d.ts.map +1 -1
  120. package/dist/graph/physics/index.js +1 -0
  121. package/dist/graph/physics/index.js.map +1 -1
  122. package/dist/graph/physics/physics-controller-geometry.cjs +203 -0
  123. package/dist/graph/physics/physics-controller-geometry.d.ts +6 -0
  124. package/dist/graph/physics/physics-controller-geometry.d.ts.map +1 -0
  125. package/dist/graph/physics/physics-controller-geometry.js +205 -0
  126. package/dist/graph/physics/physics-controller-geometry.js.map +1 -0
  127. package/dist/graph/physics/physics-controller.cjs +277 -0
  128. package/dist/graph/physics/physics-controller.d.ts +90 -0
  129. package/dist/graph/physics/physics-controller.d.ts.map +1 -0
  130. package/dist/graph/physics/physics-controller.js +266 -0
  131. package/dist/graph/physics/physics-controller.js.map +1 -0
  132. package/dist/graph/physics/scenegraph-instance.cjs +11 -2
  133. package/dist/graph/physics/scenegraph-instance.d.ts +3 -1
  134. package/dist/graph/physics/scenegraph-instance.d.ts.map +1 -1
  135. package/dist/graph/physics/scenegraph-instance.js +11 -0
  136. package/dist/graph/physics/scenegraph-instance.js.map +1 -1
  137. package/dist/graph/physics/scenegraph-motion.cjs +3 -3
  138. package/dist/graph/physics/scenegraph-motion.d.ts +5 -1
  139. package/dist/graph/physics/scenegraph-motion.d.ts.map +1 -1
  140. package/dist/graph/physics/scenegraph-motion.js +3 -3
  141. package/dist/graph/physics/scenegraph-motion.js.map +1 -1
  142. package/dist/graph/physics/scenegraph-publication.cjs +13 -3
  143. package/dist/graph/physics/scenegraph-publication.d.ts +4 -2
  144. package/dist/graph/physics/scenegraph-publication.d.ts.map +1 -1
  145. package/dist/graph/physics/scenegraph-publication.js +14 -3
  146. package/dist/graph/physics/scenegraph-publication.js.map +1 -1
  147. package/dist/graph/physics/scenegraph-session.cjs +11 -1
  148. package/dist/graph/physics/scenegraph-session.d.ts +11 -2
  149. package/dist/graph/physics/scenegraph-session.d.ts.map +1 -1
  150. package/dist/graph/physics/scenegraph-session.js +13 -1
  151. package/dist/graph/physics/scenegraph-session.js.map +1 -1
  152. package/dist/graph/tables/gpu-table-model.cjs +1 -1
  153. package/dist/graph/tables/gpu-table-model.js +1 -1
  154. package/dist/graph/tables/gpu-table-transform.cjs +2 -2
  155. package/dist/graph/tables/gpu-table-transform.d.ts +1 -1
  156. package/dist/graph/tables/gpu-table-transform.js +2 -2
  157. package/dist/graph/tables/index.cjs.map +3 -3
  158. package/dist/index.cjs +3 -0
  159. package/dist/index.cjs.map +3 -3
  160. package/dist/index.d.ts +2 -0
  161. package/dist/index.d.ts.map +1 -1
  162. package/dist/index.js +1 -0
  163. package/dist/index.js.map +1 -1
  164. package/dist/model/batch-uniform-buffer.cjs +70 -0
  165. package/dist/model/batch-uniform-buffer.d.ts +21 -0
  166. package/dist/model/batch-uniform-buffer.d.ts.map +1 -0
  167. package/dist/model/batch-uniform-buffer.js +48 -0
  168. package/dist/model/batch-uniform-buffer.js.map +1 -0
  169. package/dist/model/gpu-vector-bindings.cjs +57 -16
  170. package/dist/model/gpu-vector-bindings.d.ts.map +1 -1
  171. package/dist/model/gpu-vector-bindings.js +65 -15
  172. package/dist/model/gpu-vector-bindings.js.map +1 -1
  173. package/dist/model/gpu-vector-draw-batches.cjs +4 -2
  174. package/dist/model/gpu-vector-draw-batches.d.ts.map +1 -1
  175. package/dist/model/gpu-vector-draw-batches.js +5 -2
  176. package/dist/model/gpu-vector-draw-batches.js.map +1 -1
  177. package/dist/model/gpu-vector-model-batches.d.ts +5 -0
  178. package/dist/model/gpu-vector-model-batches.d.ts.map +1 -1
  179. package/dist/model/gpu-vector-model-batches.js.map +1 -1
  180. package/dist/model/gpu-vector-model.cjs +144 -81
  181. package/dist/model/gpu-vector-model.d.ts +9 -2
  182. package/dist/model/gpu-vector-model.d.ts.map +1 -1
  183. package/dist/model/gpu-vector-model.js +173 -100
  184. package/dist/model/gpu-vector-model.js.map +1 -1
  185. package/dist/model/model.cjs +8 -0
  186. package/dist/model/model.d.ts +3 -0
  187. package/dist/model/model.d.ts.map +1 -1
  188. package/dist/model/model.js +8 -0
  189. package/dist/model/model.js.map +1 -1
  190. package/dist/scenegraph/geometry-node.cjs +47 -0
  191. package/dist/scenegraph/geometry-node.d.ts +13 -0
  192. package/dist/scenegraph/geometry-node.d.ts.map +1 -0
  193. package/dist/scenegraph/geometry-node.js +26 -0
  194. package/dist/scenegraph/geometry-node.js.map +1 -0
  195. package/dist/scenegraph/group-node.cjs +42 -0
  196. package/dist/scenegraph/group-node.d.ts +8 -0
  197. package/dist/scenegraph/group-node.d.ts.map +1 -1
  198. package/dist/scenegraph/group-node.js +47 -1
  199. package/dist/scenegraph/group-node.js.map +1 -1
  200. package/dist/scenegraph/transform-source.cjs +15 -0
  201. package/dist/scenegraph/transform-source.d.ts +24 -0
  202. package/dist/scenegraph/transform-source.d.ts.map +1 -0
  203. package/dist/scenegraph/transform-source.js +5 -0
  204. package/dist/scenegraph/transform-source.js.map +1 -0
  205. package/dist/splats/gpu-splat-graph-renderer.d.ts +1 -1
  206. package/dist/splats/gpu-splat-graph-renderer.d.ts.map +1 -1
  207. package/dist/splats/index.cjs.map +1 -1
  208. package/dist/splats/splat-data.cjs +1 -1
  209. package/dist/splats/splat-data.d.ts +1 -1
  210. package/dist/splats/splat-data.js +1 -1
  211. package/dist/splats/splat-renderer.cjs +7 -2
  212. package/dist/splats/splat-renderer.d.ts +3 -0
  213. package/dist/splats/splat-renderer.d.ts.map +1 -1
  214. package/dist/splats/splat-renderer.js +7 -2
  215. package/dist/splats/splat-renderer.js.map +1 -1
  216. package/dist/splats/splat-sort.d.ts +1 -1
  217. package/dist/splats/splat-sort.d.ts.map +1 -1
  218. package/dist/text/experimental.cjs +151 -3
  219. package/dist/text/experimental.d.ts +1 -1
  220. package/dist/text/experimental.d.ts.map +1 -1
  221. package/dist/text/experimental.js +1 -1
  222. package/dist/text/experimental.js.map +1 -1
  223. package/dist/text/index.cjs +41 -3
  224. package/dist/text/index.d.ts +1 -1
  225. package/dist/text/index.d.ts.map +1 -1
  226. package/dist/text/index.js +1 -1
  227. package/dist/text/index.js.map +1 -1
  228. package/dist/text/text-2d/experimental.cjs +128 -18
  229. package/dist/text/text-2d/experimental.d.ts +8 -8
  230. package/dist/text/text-2d/experimental.d.ts.map +1 -1
  231. package/dist/text/text-2d/experimental.js +7 -8
  232. package/dist/text/text-2d/experimental.js.map +1 -1
  233. package/dist/text/text-2d/model-utils/text-model-props.d.ts +1 -1
  234. package/dist/text/text-2d/models/text-attribute-model.cjs +1 -1
  235. package/dist/text/text-2d/models/text-attribute-model.js +1 -1
  236. package/dist/utils/deep-equal.cjs +3 -1
  237. package/dist/utils/deep-equal.d.ts +1 -1
  238. package/dist/utils/deep-equal.d.ts.map +1 -1
  239. package/dist/utils/deep-equal.js +3 -1
  240. package/dist/utils/deep-equal.js.map +1 -1
  241. package/dist/utils/get-platform-info.cjs +9 -3
  242. package/dist/utils/get-platform-info.d.ts +1 -1
  243. package/dist/utils/get-platform-info.d.ts.map +1 -1
  244. package/dist/utils/get-platform-info.js +1 -1
  245. package/dist/utils/get-platform-info.js.map +1 -1
  246. package/package.json +8 -9
  247. package/src/arrow/arrow-geometry.ts +1 -1
  248. package/src/arrow/arrow-picking.ts +2 -2
  249. package/src/arrow/renderers/path/conversion/arrow-path-gpu-vectors.ts +9 -9
  250. package/src/arrow/renderers/path/conversion/arrow-path-storage-gpu-vectors.ts +4 -4
  251. package/src/arrow/renderers/path/source/arrow-path-source-mapping.ts +1 -1
  252. package/src/arrow/renderers/path/transforms/close-arrow-paths.ts +5 -5
  253. package/src/arrow/renderers/path/transforms/gpu-path-float64-deltas.ts +3 -3
  254. package/src/arrow/renderers/path/transforms/path-view-origins.ts +2 -2
  255. package/src/arrow/renderers/polygon/conversion/arrow-polygon-gpu-vectors.ts +1 -1
  256. package/src/arrow/renderers/polygon/renderers/arrow-polygon-renderer.ts +4 -4
  257. package/src/arrow/renderers/polygon/source/arrow-polygon-source-mapping.ts +1 -1
  258. package/src/arrow/renderers/splats/conversion/make-gpu-splat-data-from-arrow.ts +1 -1
  259. package/src/arrow/renderers/text/conversion/convert-arrow-text-to-attribute.ts +2 -2
  260. package/src/arrow/renderers/text/conversion/convert-arrow-text-to-storage.ts +1 -1
  261. package/src/arrow/renderers/text/conversion/convert-arrow-text-vectors.ts +6 -6
  262. package/src/arrow/renderers/text/conversion/make-gpu-text-data-from-arrow.ts +1 -1
  263. package/src/arrow/renderers/text/renderers/arrow-text-picking.ts +1 -1
  264. package/src/arrow/renderers/text/renderers/arrow-text-renderer.ts +5 -5
  265. package/src/arrow/renderers/text/source/arrow-text-source-mapping.ts +1 -1
  266. package/src/compute/computation.ts +8 -3
  267. package/src/compute/texture-transform.ts +2 -2
  268. package/src/experimental/materials/emissive-material.ts +1 -1
  269. package/src/experimental/materials/glass-material.ts +1 -1
  270. package/src/experimental/materials/glass-transmission.ts +1 -1
  271. package/src/experimental/materials/optical-caustics.ts +1 -1
  272. package/src/experimental/materials/optical-point-lights.ts +1 -1
  273. package/src/experimental/materials/reflective-material.ts +1 -1
  274. package/src/experimental/textures/rgba-decoder.ts +1 -1
  275. package/src/geometry/gpu-geometry.ts +1 -4
  276. package/src/gltf/gltf/gltf-extension-support.ts +27 -5
  277. package/src/gltf/gltf/gltf-lod.ts +22 -4
  278. package/src/gltf/physics/README.md +1 -1
  279. package/src/gltf/types/gltf-json-schema.ts +37 -37
  280. package/src/gltf/types/gltf-postprocessed-schema.ts +28 -28
  281. package/src/graph/models/path/path-attribute-model.ts +3 -3
  282. package/src/graph/models/path/path-storage-model.ts +2 -2
  283. package/src/graph/models/path/path-trips-storage-model.ts +2 -2
  284. package/src/graph/models/polygon/polygon-attribute-model.ts +2 -2
  285. package/src/graph/models/polygon/polygon-storage-model.ts +2 -2
  286. package/src/graph/physics/index.ts +10 -0
  287. package/src/graph/physics/physics-controller-geometry.ts +264 -0
  288. package/src/graph/physics/physics-controller.ts +348 -0
  289. package/src/graph/physics/scenegraph-instance.ts +12 -1
  290. package/src/graph/physics/scenegraph-motion.ts +14 -3
  291. package/src/graph/physics/scenegraph-publication.ts +24 -4
  292. package/src/graph/physics/scenegraph-session.ts +35 -3
  293. package/src/graph/tables/gpu-table-model.ts +1 -1
  294. package/src/graph/tables/gpu-table-transform.ts +3 -3
  295. package/src/index.ts +6 -0
  296. package/src/model/batch-uniform-buffer.ts +51 -0
  297. package/src/model/gpu-vector-bindings.ts +77 -19
  298. package/src/model/gpu-vector-draw-batches.ts +5 -2
  299. package/src/model/gpu-vector-model-batches.ts +5 -0
  300. package/src/model/gpu-vector-model.ts +194 -122
  301. package/src/model/model.ts +10 -0
  302. package/src/scenegraph/geometry-node.ts +31 -0
  303. package/src/scenegraph/group-node.ts +54 -1
  304. package/src/scenegraph/transform-source.ts +30 -0
  305. package/src/splats/gpu-splat-graph-renderer.ts +1 -1
  306. package/src/splats/splat-data.ts +1 -1
  307. package/src/splats/splat-renderer.ts +10 -2
  308. package/src/splats/splat-sort.ts +1 -1
  309. package/src/text/README.md +1 -1
  310. package/src/text/experimental.ts +122 -1
  311. package/src/text/index.ts +40 -1
  312. package/src/text/text-2d/experimental.ts +104 -8
  313. package/src/text/text-2d/model-utils/text-model-props.ts +1 -1
  314. package/src/text/text-2d/models/text-attribute-model.ts +1 -1
  315. package/src/utils/deep-equal.ts +4 -2
  316. package/src/utils/get-platform-info.ts +1 -1
package/dist/dist.dev.js CHANGED
@@ -87,6 +87,7 @@ var __exports__ = (() => {
87
87
  GPUVectorGeometry: () => GPUVectorGeometry,
88
88
  GPUVectorModel: () => GPUVectorModel,
89
89
  Geometry: () => Geometry2,
90
+ GeometryNode: () => GeometryNode,
90
91
  GroupNode: () => GroupNode,
91
92
  IcoSphereGeometry: () => IcoSphereGeometry2,
92
93
  Interactivity: () => Interactivity,
@@ -5669,7 +5670,7 @@ var __exports__ = (() => {
5669
5670
  }
5670
5671
 
5671
5672
  // src/model/gpu-vector-model.ts
5672
- var import_core13 = __toESM(require_core(), 1);
5673
+ var import_core14 = __toESM(require_core(), 1);
5673
5674
  var import_shaders3 = __toESM(require_shaders(), 1);
5674
5675
 
5675
5676
  // ../shaders/src/lib/utils/assert.ts
@@ -6435,10 +6436,28 @@ ${DECLARATION_INJECT_MARKER}
6435
6436
  }
6436
6437
  return result;
6437
6438
  }
6438
- function normalizeShaderHooks(hookFunctions) {
6439
+ function normalizeShaderHooks(hookFunctions, pluginHooks = [], language) {
6439
6440
  const result = { vertex: {}, fragment: {} };
6440
6441
  for (const hookFunction of hookFunctions) {
6441
- addShaderHookToRegistry(result, hookFunction);
6442
+ const text = typeof hookFunction === "string" ? hookFunction : hookFunction.hook;
6443
+ const qualified = /^(glsl|wgsl):([\s\S]+)$/.exec(text);
6444
+ if (qualified && qualified[1] !== language) continue;
6445
+ addShaderHookToRegistry(
6446
+ result,
6447
+ qualified ? typeof hookFunction === "string" ? qualified[2] : { ...hookFunction, hook: qualified[2] } : hookFunction
6448
+ );
6449
+ }
6450
+ for (const hook of pluginHooks) {
6451
+ const normalized2 = normalizeShaderHooks([hook]);
6452
+ for (const stage of ["vertex", "fragment"]) {
6453
+ for (const [name, declaration] of Object.entries(normalized2[stage])) {
6454
+ const existing = result[stage][name];
6455
+ if (existing && existing.signature !== declaration.signature) {
6456
+ throw new Error(`Conflicting ShaderPlugin hook ${name}`);
6457
+ }
6458
+ result[stage][name] = existing || declaration;
6459
+ }
6460
+ }
6442
6461
  }
6443
6462
  return result;
6444
6463
  }
@@ -6453,7 +6472,12 @@ ${DECLARATION_INJECT_MARKER}
6453
6472
  continue;
6454
6473
  }
6455
6474
  if (!isShaderHookRegistered(registry, hookName)) {
6456
- throw new Error(`Unknown shader hook ${hookName}`);
6475
+ const pluginNames = [
6476
+ ...new Set(hookInjections[hookName].map((injection) => injection.pluginName).filter(Boolean))
6477
+ ];
6478
+ throw new Error(
6479
+ `Unknown shader hook ${hookName}${pluginNames.length ? ` (plugins: ${pluginNames.join(", ")})` : ""}`
6480
+ );
6457
6481
  }
6458
6482
  }
6459
6483
  }
@@ -6463,7 +6487,7 @@ ${DECLARATION_INJECT_MARKER}
6463
6487
  const stageSeparatorIndex = hook.indexOf(":");
6464
6488
  const shaderStage = hook.slice(0, stageSeparatorIndex);
6465
6489
  const signature = hook.slice(stageSeparatorIndex + 1);
6466
- const name = hook.replace(/\(.+/, "");
6490
+ const name = hook.split("(")[0].trim();
6467
6491
  const normalizedHook = {
6468
6492
  hook: name,
6469
6493
  signature,
@@ -7007,11 +7031,186 @@ ${DECLARATION_INJECT_MARKER}
7007
7031
  return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
7008
7032
  }
7009
7033
 
7034
+ // ../shaders/src/lib/shader-assembly/wgsl-binding-scan.ts
7035
+ var WGSL_BINDABLE_VARIABLE_PATTERN = "(?:var<\\s*(uniform|storage(?:\\s*,\\s*[A-Za-z_][A-Za-z0-9_]*)?)\\s*>|var)\\s+([A-Za-z_][A-Za-z0-9_]*)";
7036
+ var WGSL_BINDING_DECLARATION_SEPARATOR_PATTERN = "\\s*";
7037
+ var MODULE_WGSL_BINDING_DECLARATION_REGEXES = [
7038
+ new RegExp(
7039
+ `@binding\\(\\s*(auto|\\d+)\\s*\\)${WGSL_BINDING_DECLARATION_SEPARATOR_PATTERN}@group\\(\\s*(\\d+)\\s*\\)${WGSL_BINDING_DECLARATION_SEPARATOR_PATTERN}${WGSL_BINDABLE_VARIABLE_PATTERN}`,
7040
+ "g"
7041
+ ),
7042
+ new RegExp(
7043
+ `@group\\(\\s*(\\d+)\\s*\\)${WGSL_BINDING_DECLARATION_SEPARATOR_PATTERN}@binding\\(\\s*(auto|\\d+)\\s*\\)${WGSL_BINDING_DECLARATION_SEPARATOR_PATTERN}${WGSL_BINDABLE_VARIABLE_PATTERN}`,
7044
+ "g"
7045
+ )
7046
+ ];
7047
+ var WGSL_BINDING_DECLARATION_REGEXES = [
7048
+ new RegExp(
7049
+ `@binding\\(\\s*(auto|\\d+)\\s*\\)${WGSL_BINDING_DECLARATION_SEPARATOR_PATTERN}@group\\(\\s*(\\d+)\\s*\\)${WGSL_BINDING_DECLARATION_SEPARATOR_PATTERN}${WGSL_BINDABLE_VARIABLE_PATTERN}`,
7050
+ "g"
7051
+ ),
7052
+ new RegExp(
7053
+ `@group\\(\\s*(\\d+)\\s*\\)${WGSL_BINDING_DECLARATION_SEPARATOR_PATTERN}@binding\\(\\s*(auto|\\d+)\\s*\\)${WGSL_BINDING_DECLARATION_SEPARATOR_PATTERN}${WGSL_BINDABLE_VARIABLE_PATTERN}`,
7054
+ "g"
7055
+ )
7056
+ ];
7057
+ var WGSL_EXPLICIT_BINDING_DECLARATION_REGEXES = [
7058
+ new RegExp(
7059
+ `@binding\\(\\s*(\\d+)\\s*\\)${WGSL_BINDING_DECLARATION_SEPARATOR_PATTERN}@group\\(\\s*(\\d+)\\s*\\)${WGSL_BINDING_DECLARATION_SEPARATOR_PATTERN}${WGSL_BINDABLE_VARIABLE_PATTERN}`,
7060
+ "g"
7061
+ ),
7062
+ new RegExp(
7063
+ `@group\\(\\s*(\\d+)\\s*\\)${WGSL_BINDING_DECLARATION_SEPARATOR_PATTERN}@binding\\(\\s*(\\d+)\\s*\\)${WGSL_BINDING_DECLARATION_SEPARATOR_PATTERN}${WGSL_BINDABLE_VARIABLE_PATTERN}`,
7064
+ "g"
7065
+ )
7066
+ ];
7067
+ var WGSL_AUTO_BINDING_DECLARATION_REGEXES = [
7068
+ new RegExp(
7069
+ `@binding\\(\\s*(auto)\\s*\\)\\s*@group\\(\\s*(\\d+)\\s*\\)\\s*${WGSL_BINDABLE_VARIABLE_PATTERN}`,
7070
+ "g"
7071
+ ),
7072
+ new RegExp(
7073
+ `@group\\(\\s*(\\d+)\\s*\\)\\s*@binding\\(\\s*(auto)\\s*\\)\\s*${WGSL_BINDABLE_VARIABLE_PATTERN}`,
7074
+ "g"
7075
+ ),
7076
+ new RegExp(
7077
+ `@binding\\(\\s*(auto)\\s*\\)\\s*@group\\(\\s*(\\d+)\\s*\\)(?:[\\s\\n\\r]*@[A-Za-z_][^\\n\\r]*)*[\\s\\n\\r]*${WGSL_BINDABLE_VARIABLE_PATTERN}`,
7078
+ "g"
7079
+ ),
7080
+ new RegExp(
7081
+ `@group\\(\\s*(\\d+)\\s*\\)\\s*@binding\\(\\s*(auto)\\s*\\)(?:[\\s\\n\\r]*@[A-Za-z_][^\\n\\r]*)*[\\s\\n\\r]*${WGSL_BINDABLE_VARIABLE_PATTERN}`,
7082
+ "g"
7083
+ )
7084
+ ];
7085
+ function maskWGSLComments(source4) {
7086
+ const maskedCharacters = source4.split("");
7087
+ let index = 0;
7088
+ let blockCommentDepth = 0;
7089
+ let inLineComment = false;
7090
+ let inString = false;
7091
+ let isEscaped = false;
7092
+ while (index < source4.length) {
7093
+ const character = source4[index];
7094
+ const nextCharacter = source4[index + 1];
7095
+ if (inString) {
7096
+ if (isEscaped) {
7097
+ isEscaped = false;
7098
+ } else if (character === "\\") {
7099
+ isEscaped = true;
7100
+ } else if (character === '"') {
7101
+ inString = false;
7102
+ }
7103
+ index++;
7104
+ continue;
7105
+ }
7106
+ if (inLineComment) {
7107
+ if (character === "\n" || character === "\r") {
7108
+ inLineComment = false;
7109
+ } else {
7110
+ maskedCharacters[index] = " ";
7111
+ }
7112
+ index++;
7113
+ continue;
7114
+ }
7115
+ if (blockCommentDepth > 0) {
7116
+ if (character === "/" && nextCharacter === "*") {
7117
+ maskedCharacters[index] = " ";
7118
+ maskedCharacters[index + 1] = " ";
7119
+ blockCommentDepth++;
7120
+ index += 2;
7121
+ continue;
7122
+ }
7123
+ if (character === "*" && nextCharacter === "/") {
7124
+ maskedCharacters[index] = " ";
7125
+ maskedCharacters[index + 1] = " ";
7126
+ blockCommentDepth--;
7127
+ index += 2;
7128
+ continue;
7129
+ }
7130
+ if (character !== "\n" && character !== "\r") {
7131
+ maskedCharacters[index] = " ";
7132
+ }
7133
+ index++;
7134
+ continue;
7135
+ }
7136
+ if (character === '"') {
7137
+ inString = true;
7138
+ index++;
7139
+ continue;
7140
+ }
7141
+ if (character === "/" && nextCharacter === "/") {
7142
+ maskedCharacters[index] = " ";
7143
+ maskedCharacters[index + 1] = " ";
7144
+ inLineComment = true;
7145
+ index += 2;
7146
+ continue;
7147
+ }
7148
+ if (character === "/" && nextCharacter === "*") {
7149
+ maskedCharacters[index] = " ";
7150
+ maskedCharacters[index + 1] = " ";
7151
+ blockCommentDepth = 1;
7152
+ index += 2;
7153
+ continue;
7154
+ }
7155
+ index++;
7156
+ }
7157
+ return maskedCharacters.join("");
7158
+ }
7159
+ function getWGSLBindingDeclarationMatches(source4, regexes) {
7160
+ const maskedSource = maskWGSLComments(source4);
7161
+ const matches = [];
7162
+ for (const regex of regexes) {
7163
+ regex.lastIndex = 0;
7164
+ let match;
7165
+ match = regex.exec(maskedSource);
7166
+ while (match) {
7167
+ const isBindingFirst = regex === regexes[0];
7168
+ const index = match.index;
7169
+ const length4 = match[0].length;
7170
+ matches.push({
7171
+ match: source4.slice(index, index + length4),
7172
+ index,
7173
+ length: length4,
7174
+ bindingToken: match[isBindingFirst ? 1 : 2],
7175
+ groupToken: match[isBindingFirst ? 2 : 1],
7176
+ accessDeclaration: match[3]?.trim(),
7177
+ name: match[4]
7178
+ });
7179
+ match = regex.exec(maskedSource);
7180
+ }
7181
+ }
7182
+ return matches.sort((left, right) => left.index - right.index);
7183
+ }
7184
+ function replaceWGSLBindingDeclarationMatches(source4, regexes, replacer) {
7185
+ const matches = getWGSLBindingDeclarationMatches(source4, regexes);
7186
+ if (!matches.length) {
7187
+ return source4;
7188
+ }
7189
+ let relocatedSource = "";
7190
+ let lastIndex = 0;
7191
+ for (const match of matches) {
7192
+ relocatedSource += source4.slice(lastIndex, match.index);
7193
+ relocatedSource += replacer(match);
7194
+ lastIndex = match.index + match.length;
7195
+ }
7196
+ relocatedSource += source4.slice(lastIndex);
7197
+ return relocatedSource;
7198
+ }
7199
+ function hasWGSLAutoBinding(source4) {
7200
+ return /@binding\(\s*auto\s*\)/.test(maskWGSLComments(source4));
7201
+ }
7202
+ function getFirstWGSLAutoBindingDeclarationMatch(source4, regexes) {
7203
+ const autoBindingRegexes = regexes === MODULE_WGSL_BINDING_DECLARATION_REGEXES || regexes === WGSL_BINDING_DECLARATION_REGEXES ? WGSL_AUTO_BINDING_DECLARATION_REGEXES : regexes;
7204
+ return getWGSLBindingDeclarationMatches(source4, autoBindingRegexes).find(
7205
+ (declarationMatch) => declarationMatch.bindingToken === "auto"
7206
+ );
7207
+ }
7208
+
7010
7209
  // ../shaders/src/lib/shader-assembly/shader-plugin-varyings.ts
7011
- function assembleShaderPluginVaryingsGLSL(source4, stage, varyings) {
7210
+ function assembleShaderPluginInterStageVariablesGLSL(source4, stage, interStageVariables) {
7012
7211
  const declarations = [];
7013
7212
  const initialization = [];
7014
- for (const [name, varying] of Object.entries(varyings)) {
7213
+ for (const [name, varying] of Object.entries(interStageVariables)) {
7015
7214
  assertGLSLVaryingIsNew(source4, name);
7016
7215
  const qualifier = varying.interpolation === "flat" ? "flat " : "";
7017
7216
  const direction = stage === "vertex" ? "out" : "in";
@@ -7022,8 +7221,8 @@ ${DECLARATION_INJECT_MARKER}
7022
7221
  }
7023
7222
  return { declarations: declarations.join("\n"), initialization: initialization.join("\n") };
7024
7223
  }
7025
- function assembleShaderPluginVaryingsWGSL(source4, vertexEntryPoint, fragmentEntryPoint, varyings) {
7026
- const entries = Object.entries(varyings);
7224
+ function assembleShaderPluginInterStageVariablesWGSL(source4, vertexEntryPoint, fragmentEntryPoint, interStageVariables) {
7225
+ const entries = Object.entries(interStageVariables);
7027
7226
  if (entries.length === 0) {
7028
7227
  return {
7029
7228
  source: source4,
@@ -7038,18 +7237,20 @@ ${DECLARATION_INJECT_MARKER}
7038
7237
  let fragmentFunction = getWGSLFunctionRange(transformedSource, fragmentEntryPoint, "fragment");
7039
7238
  const fragmentInput = getWGSLFragmentStructInput(transformedSource, fragmentFunction);
7040
7239
  const vertexOutputStruct = getWGSLStructRange(transformedSource, vertexOutputType);
7041
- const fragmentInputStruct = getWGSLStructRange(transformedSource, fragmentInput.type);
7240
+ const fragmentInputStruct = fragmentInput ? getWGSLStructRange(transformedSource, fragmentInput.type) : null;
7042
7241
  const interfaceNames = /* @__PURE__ */ new Set([
7043
7242
  ...getWGSLDeclaredNames2(vertexFunction.parameters),
7044
7243
  ...getWGSLDeclaredNames2(vertexOutputStruct.body),
7045
7244
  ...getWGSLDeclaredNames2(fragmentFunction.parameters),
7046
- ...getWGSLDeclaredNames2(fragmentInputStruct.body)
7245
+ ...getWGSLDeclaredNames2(fragmentInputStruct?.body || "")
7047
7246
  ]);
7048
7247
  const usedLocations = /* @__PURE__ */ new Set([
7049
7248
  ...getWGSLLocations2(vertexOutputStruct.body),
7050
- ...getWGSLLocations2(fragmentInputStruct.body)
7249
+ ...getWGSLLocations2(fragmentInputStruct?.body || ""),
7250
+ ...getWGSLLocations2(fragmentFunction.parameters)
7051
7251
  ]);
7052
7252
  const fields = [];
7253
+ const fragmentParameters = [];
7053
7254
  const declarations = [];
7054
7255
  const vertexInitialization = [];
7055
7256
  const fragmentInitialization = [];
@@ -7065,7 +7266,20 @@ ${DECLARATION_INJECT_MARKER}
7065
7266
  fields.push(` @location(${location})${interpolation} ${name}: ${varying.type},`);
7066
7267
  declarations.push(`var<private> ${name}: ${varying.type};`);
7067
7268
  vertexInitialization.push(`${name} = ${getWGSLZeroValue(varying.type)};`);
7068
- fragmentInitialization.push(`${name} = ${fragmentInput.name}.${name};`);
7269
+ if (fragmentInput) {
7270
+ fragmentInitialization.push(`${name} = ${fragmentInput.name}.${name};`);
7271
+ } else {
7272
+ const parameterName = `_luma_${name}`;
7273
+ if (interfaceNames.has(parameterName)) {
7274
+ throw new Error(
7275
+ `ShaderPlugin varying "${name}" conflicts with a generated fragment parameter`
7276
+ );
7277
+ }
7278
+ fragmentParameters.push(
7279
+ `@location(${location})${interpolation} ${parameterName}: ${varying.type}`
7280
+ );
7281
+ fragmentInitialization.push(`${name} = ${parameterName};`);
7282
+ }
7069
7283
  }
7070
7284
  assertWGSLStructConstructorsAreLocal(
7071
7285
  transformedSource,
@@ -7085,16 +7299,21 @@ ${DECLARATION_INJECT_MARKER}
7085
7299
  vertexFunction,
7086
7300
  entries.map(([name]) => name)
7087
7301
  );
7088
- const structNames = vertexOutputType === fragmentInput.type ? [vertexOutputType] : [vertexOutputType, fragmentInput.type];
7302
+ const structNames = !fragmentInput || vertexOutputType === fragmentInput.type ? [vertexOutputType] : [vertexOutputType, fragmentInput.type];
7089
7303
  const structInsertions = structNames.map((structName) => getWGSLStructRange(transformedSource, structName).closeBrace).sort((left, right) => right - left);
7090
7304
  for (const insertionIndex of structInsertions) {
7091
7305
  transformedSource = transformedSource.slice(0, insertionIndex) + `${fields.join("\n")}
7092
7306
  ` + transformedSource.slice(insertionIndex);
7093
7307
  }
7094
7308
  fragmentFunction = getWGSLFunctionRange(transformedSource, fragmentEntryPoint, "fragment");
7095
- const fragmentInputPattern = new RegExp(`\\b${escapeRegExp3(fragmentInput.name)}\\s*:`);
7096
- if (!fragmentInputPattern.test(fragmentFunction.parameters)) {
7097
- throw new Error(`Unable to preserve WGSL fragment input "${fragmentInput.name}"`);
7309
+ if (fragmentParameters.length) {
7310
+ let parameters = fragmentFunction.parameters;
7311
+ const parameterTokens = maskWGSLComments(parameters).trimEnd();
7312
+ if (parameterTokens.trim() && !parameterTokens.endsWith(",")) {
7313
+ const insertionIndex = parameterTokens.length;
7314
+ parameters = `${parameters.slice(0, insertionIndex)},${parameters.slice(insertionIndex)}`;
7315
+ }
7316
+ transformedSource = transformedSource.slice(0, fragmentFunction.openParenthesis + 1) + parameters + "\n " + fragmentParameters.join(",\n ") + "\n" + transformedSource.slice(fragmentFunction.closeParenthesis);
7098
7317
  }
7099
7318
  return {
7100
7319
  source: transformedSource,
@@ -7107,7 +7326,9 @@ ${DECLARATION_INJECT_MARKER}
7107
7326
  const functionPattern = new RegExp(`\\bfn\\s+${escapeRegExp3(entryPoint)}\\s*\\(`, "g");
7108
7327
  const match = functionPattern.exec(source4);
7109
7328
  if (!match) {
7110
- throw new Error(`ShaderPlugin varyings require WGSL ${stage} entry point "${entryPoint}"`);
7329
+ throw new Error(
7330
+ `ShaderPlugin interStageVariables require WGSL ${stage} entry point "${entryPoint}"`
7331
+ );
7111
7332
  }
7112
7333
  const openParenthesis = source4.indexOf("(", match.index);
7113
7334
  const closeParenthesis = findMatchingDelimiter2(source4, openParenthesis, "(", ")");
@@ -7129,14 +7350,14 @@ ${DECLARATION_INJECT_MARKER}
7129
7350
  const match = /->\s*([A-Za-z_][\w]*)\s*$/.exec(resultSource.trim());
7130
7351
  if (!match || getWGSLStructRangeOrNull(source4, match[1]) === null) {
7131
7352
  throw new Error(
7132
- "ShaderPlugin varyings require the WGSL vertex entry point to return a named struct"
7353
+ "ShaderPlugin interStageVariables require the WGSL vertex entry point to return a named struct"
7133
7354
  );
7134
7355
  }
7135
7356
  return match[1];
7136
7357
  }
7137
7358
  function getWGSLFragmentStructInput(source4, functionRange) {
7138
7359
  const candidates = [];
7139
- for (const parameter of splitTopLevel(functionRange.parameters, ",")) {
7360
+ for (const parameter of splitTopLevel(maskWGSLComments(functionRange.parameters), ",")) {
7140
7361
  const match = /(?:@[A-Za-z_][\w]*(?:\([^)]*\))?\s*)*([A-Za-z_][\w]*)\s*:\s*([A-Za-z_][\w]*)\s*$/.exec(
7141
7362
  parameter.trim()
7142
7363
  );
@@ -7144,12 +7365,12 @@ ${DECLARATION_INJECT_MARKER}
7144
7365
  candidates.push({ name: match[1], type: match[2] });
7145
7366
  }
7146
7367
  }
7147
- if (candidates.length !== 1) {
7368
+ if (candidates.length > 1) {
7148
7369
  throw new Error(
7149
- `ShaderPlugin varyings require exactly one named WGSL fragment input struct; found ${candidates.length}`
7370
+ `ShaderPlugin interStageVariables require exactly one named WGSL fragment input struct; found ${candidates.length}`
7150
7371
  );
7151
7372
  }
7152
- return candidates[0];
7373
+ return candidates[0] || null;
7153
7374
  }
7154
7375
  function getWGSLStructRange(source4, structName) {
7155
7376
  const range = getWGSLStructRangeOrNull(source4, structName);
@@ -7499,7 +7720,7 @@ return ${outputName};
7499
7720
  inject = {},
7500
7721
  pluginInjections = {},
7501
7722
  pluginVertexInputs = {},
7502
- pluginVaryings = {},
7723
+ pluginInterStageVariables = {},
7503
7724
  prologue = true,
7504
7725
  log: log8
7505
7726
  } = options;
@@ -7535,7 +7756,7 @@ ${getApplicationDefines(allDefines)}
7535
7756
  `;
7536
7757
  break;
7537
7758
  }
7538
- const hookFunctionMap = normalizeShaderHooks(hookFunctions);
7759
+ const hookFunctionMap = normalizeShaderHooks(hookFunctions, options.pluginHooks, "glsl");
7539
7760
  const hookInjections = {};
7540
7761
  const declInjections = {};
7541
7762
  const mainInjections = {};
@@ -7548,35 +7769,30 @@ ${getApplicationDefines(allDefines)}
7548
7769
  const name = match[3];
7549
7770
  if (hash) {
7550
7771
  if (name === "decl") {
7551
- declInjections[key] = [injection];
7772
+ declInjections[key] = [...declInjections[key] || [], injection];
7552
7773
  } else {
7553
- mainInjections[key] = [injection];
7774
+ mainInjections[key] = [...mainInjections[key] || [], injection];
7554
7775
  }
7555
7776
  } else {
7556
- hookInjections[key] = [injection];
7777
+ hookInjections[key] = [...hookInjections[key] || [], injection];
7557
7778
  }
7558
7779
  } else {
7559
- mainInjections[key] = [injection];
7780
+ mainInjections[key] = [...mainInjections[key] || [], injection];
7560
7781
  }
7561
7782
  }
7562
7783
  if (stage === "vertex") {
7563
7784
  const declarations = getShaderPluginVertexInputDeclarationsGLSL(coreSource, pluginVertexInputs);
7564
- if (declarations) {
7565
- declInjections["vs:#decl"] = declInjections["vs:#decl"] || [];
7566
- declInjections["vs:#decl"].push({
7567
- injection: declarations,
7568
- order: Number.MIN_SAFE_INTEGER
7569
- });
7570
- }
7785
+ if (declarations) assembledSource += `${declarations}
7786
+ `;
7571
7787
  }
7572
- const pluginVaryingAssembly = assembleShaderPluginVaryingsGLSL(coreSource, stage, pluginVaryings);
7788
+ const pluginVaryingAssembly = assembleShaderPluginInterStageVariablesGLSL(
7789
+ coreSource,
7790
+ stage,
7791
+ pluginInterStageVariables
7792
+ );
7573
7793
  if (pluginVaryingAssembly.declarations) {
7574
- const declarationTarget = stage === "vertex" ? "vs:#decl" : "fs:#decl";
7575
- declInjections[declarationTarget] = declInjections[declarationTarget] || [];
7576
- declInjections[declarationTarget].push({
7577
- injection: pluginVaryingAssembly.declarations,
7578
- order: Number.MIN_SAFE_INTEGER
7579
- });
7794
+ assembledSource += `${pluginVaryingAssembly.declarations}
7795
+ `;
7580
7796
  }
7581
7797
  if (pluginVaryingAssembly.initialization) {
7582
7798
  mainInjections["vs:#main-start"] = mainInjections["vs:#main-start"] || [];
@@ -7589,247 +7805,72 @@ ${getApplicationDefines(allDefines)}
7589
7805
  if (log8) {
7590
7806
  checkShaderModuleDeprecations(module, coreSource, log8);
7591
7807
  }
7592
- const moduleSource = getShaderModuleSource(module, stage, log8);
7593
- assembledSource += moduleSource;
7594
- const injections = module.instance?.normalizedInjections[stage] || {};
7595
- for (const key in injections) {
7596
- const match = /^(v|f)s:#([\w-]+)$/.exec(key);
7597
- if (match) {
7598
- const name = match[2];
7599
- const injectionType = name === "decl" ? declInjections : mainInjections;
7600
- injectionType[key] = injectionType[key] || [];
7601
- injectionType[key].push(injections[key]);
7602
- } else {
7603
- hookInjections[key] = hookInjections[key] || [];
7604
- hookInjections[key].push(injections[key]);
7605
- }
7606
- }
7607
- }
7608
- validateShaderHookInjections(hookFunctionMap, hookInjections, stage);
7609
- assembledSource += "// ----- MAIN SHADER SOURCE -------------------------";
7610
- assembledSource += INJECT_SHADER_DECLARATIONS;
7611
- assembledSource = injectShader(assembledSource, stage, declInjections);
7612
- assembledSource += getShaderHooks(hookFunctionMap[stage], hookInjections);
7613
- assembledSource += coreSource;
7614
- assembledSource = injectShader(assembledSource, stage, mainInjections);
7615
- if (language === "glsl" && sourceVersion !== targetVersion) {
7616
- assembledSource = transpileGLSLShader(assembledSource, stage);
7617
- }
7618
- if (language === "glsl") {
7619
- warnIfGLSLUniformBlocksAreNotStd140(assembledSource, stage, log8);
7620
- }
7621
- return assembledSource.trim();
7622
- }
7623
- function getApplicationDefines(defines = {}) {
7624
- let sourceText = "";
7625
- for (const define in defines) {
7626
- const value = defines[define];
7627
- if (value || Number.isFinite(value)) {
7628
- sourceText += `#define ${define.toUpperCase()} ${defines[define]}
7629
- `;
7630
- }
7631
- }
7632
- return sourceText;
7633
- }
7634
-
7635
- // ../shaders/src/lib/glsl-shader-assembler.ts
7636
- var GLSLShaderAssembler = class extends ShaderAssembler {
7637
- shaderLanguage = "glsl";
7638
- /**
7639
- * Assemble a pair of shaders into a single shader program.
7640
- * @param props GLSL vertex and fragment source, platform information, shader modules, defines, and injections.
7641
- * @returns Assembled GLSL source, resolved modules, and combined uniform getter.
7642
- */
7643
- assembleGLSLShaderPair(props) {
7644
- const modules = this._getModuleList(props.modules);
7645
- const hookFunctions = this._hookFunctions;
7646
- const vertex = this._transpileShader(props, modules, props.vs, "vertex");
7647
- const fragment = this._transpileShader(props, modules, props.fs, "fragment");
7648
- const assembled = assembleGLSLShaderPair({
7649
- ...props,
7650
- vs: vertex.code,
7651
- fs: props.fs == null ? void 0 : fragment.code,
7652
- modules: vertex.modules,
7653
- hookFunctions
7654
- });
7655
- return { ...assembled, modules };
7656
- }
7657
- };
7658
-
7659
- // ../shaders/src/lib/shader-assembly/wgsl-binding-scan.ts
7660
- var WGSL_BINDABLE_VARIABLE_PATTERN = "(?:var<\\s*(uniform|storage(?:\\s*,\\s*[A-Za-z_][A-Za-z0-9_]*)?)\\s*>|var)\\s+([A-Za-z_][A-Za-z0-9_]*)";
7661
- var WGSL_BINDING_DECLARATION_SEPARATOR_PATTERN = "\\s*";
7662
- var MODULE_WGSL_BINDING_DECLARATION_REGEXES = [
7663
- new RegExp(
7664
- `@binding\\(\\s*(auto|\\d+)\\s*\\)${WGSL_BINDING_DECLARATION_SEPARATOR_PATTERN}@group\\(\\s*(\\d+)\\s*\\)${WGSL_BINDING_DECLARATION_SEPARATOR_PATTERN}${WGSL_BINDABLE_VARIABLE_PATTERN}`,
7665
- "g"
7666
- ),
7667
- new RegExp(
7668
- `@group\\(\\s*(\\d+)\\s*\\)${WGSL_BINDING_DECLARATION_SEPARATOR_PATTERN}@binding\\(\\s*(auto|\\d+)\\s*\\)${WGSL_BINDING_DECLARATION_SEPARATOR_PATTERN}${WGSL_BINDABLE_VARIABLE_PATTERN}`,
7669
- "g"
7670
- )
7671
- ];
7672
- var WGSL_BINDING_DECLARATION_REGEXES = [
7673
- new RegExp(
7674
- `@binding\\(\\s*(auto|\\d+)\\s*\\)${WGSL_BINDING_DECLARATION_SEPARATOR_PATTERN}@group\\(\\s*(\\d+)\\s*\\)${WGSL_BINDING_DECLARATION_SEPARATOR_PATTERN}${WGSL_BINDABLE_VARIABLE_PATTERN}`,
7675
- "g"
7676
- ),
7677
- new RegExp(
7678
- `@group\\(\\s*(\\d+)\\s*\\)${WGSL_BINDING_DECLARATION_SEPARATOR_PATTERN}@binding\\(\\s*(auto|\\d+)\\s*\\)${WGSL_BINDING_DECLARATION_SEPARATOR_PATTERN}${WGSL_BINDABLE_VARIABLE_PATTERN}`,
7679
- "g"
7680
- )
7681
- ];
7682
- var WGSL_EXPLICIT_BINDING_DECLARATION_REGEXES = [
7683
- new RegExp(
7684
- `@binding\\(\\s*(\\d+)\\s*\\)${WGSL_BINDING_DECLARATION_SEPARATOR_PATTERN}@group\\(\\s*(\\d+)\\s*\\)${WGSL_BINDING_DECLARATION_SEPARATOR_PATTERN}${WGSL_BINDABLE_VARIABLE_PATTERN}`,
7685
- "g"
7686
- ),
7687
- new RegExp(
7688
- `@group\\(\\s*(\\d+)\\s*\\)${WGSL_BINDING_DECLARATION_SEPARATOR_PATTERN}@binding\\(\\s*(\\d+)\\s*\\)${WGSL_BINDING_DECLARATION_SEPARATOR_PATTERN}${WGSL_BINDABLE_VARIABLE_PATTERN}`,
7689
- "g"
7690
- )
7691
- ];
7692
- var WGSL_AUTO_BINDING_DECLARATION_REGEXES = [
7693
- new RegExp(
7694
- `@binding\\(\\s*(auto)\\s*\\)\\s*@group\\(\\s*(\\d+)\\s*\\)\\s*${WGSL_BINDABLE_VARIABLE_PATTERN}`,
7695
- "g"
7696
- ),
7697
- new RegExp(
7698
- `@group\\(\\s*(\\d+)\\s*\\)\\s*@binding\\(\\s*(auto)\\s*\\)\\s*${WGSL_BINDABLE_VARIABLE_PATTERN}`,
7699
- "g"
7700
- ),
7701
- new RegExp(
7702
- `@binding\\(\\s*(auto)\\s*\\)\\s*@group\\(\\s*(\\d+)\\s*\\)(?:[\\s\\n\\r]*@[A-Za-z_][^\\n\\r]*)*[\\s\\n\\r]*${WGSL_BINDABLE_VARIABLE_PATTERN}`,
7703
- "g"
7704
- ),
7705
- new RegExp(
7706
- `@group\\(\\s*(\\d+)\\s*\\)\\s*@binding\\(\\s*(auto)\\s*\\)(?:[\\s\\n\\r]*@[A-Za-z_][^\\n\\r]*)*[\\s\\n\\r]*${WGSL_BINDABLE_VARIABLE_PATTERN}`,
7707
- "g"
7708
- )
7709
- ];
7710
- function maskWGSLComments(source4) {
7711
- const maskedCharacters = source4.split("");
7712
- let index = 0;
7713
- let blockCommentDepth = 0;
7714
- let inLineComment = false;
7715
- let inString = false;
7716
- let isEscaped = false;
7717
- while (index < source4.length) {
7718
- const character = source4[index];
7719
- const nextCharacter = source4[index + 1];
7720
- if (inString) {
7721
- if (isEscaped) {
7722
- isEscaped = false;
7723
- } else if (character === "\\") {
7724
- isEscaped = true;
7725
- } else if (character === '"') {
7726
- inString = false;
7727
- }
7728
- index++;
7729
- continue;
7730
- }
7731
- if (inLineComment) {
7732
- if (character === "\n" || character === "\r") {
7733
- inLineComment = false;
7734
- } else {
7735
- maskedCharacters[index] = " ";
7736
- }
7737
- index++;
7738
- continue;
7739
- }
7740
- if (blockCommentDepth > 0) {
7741
- if (character === "/" && nextCharacter === "*") {
7742
- maskedCharacters[index] = " ";
7743
- maskedCharacters[index + 1] = " ";
7744
- blockCommentDepth++;
7745
- index += 2;
7746
- continue;
7747
- }
7748
- if (character === "*" && nextCharacter === "/") {
7749
- maskedCharacters[index] = " ";
7750
- maskedCharacters[index + 1] = " ";
7751
- blockCommentDepth--;
7752
- index += 2;
7753
- continue;
7754
- }
7755
- if (character !== "\n" && character !== "\r") {
7756
- maskedCharacters[index] = " ";
7757
- }
7758
- index++;
7759
- continue;
7760
- }
7761
- if (character === '"') {
7762
- inString = true;
7763
- index++;
7764
- continue;
7765
- }
7766
- if (character === "/" && nextCharacter === "/") {
7767
- maskedCharacters[index] = " ";
7768
- maskedCharacters[index + 1] = " ";
7769
- inLineComment = true;
7770
- index += 2;
7771
- continue;
7772
- }
7773
- if (character === "/" && nextCharacter === "*") {
7774
- maskedCharacters[index] = " ";
7775
- maskedCharacters[index + 1] = " ";
7776
- blockCommentDepth = 1;
7777
- index += 2;
7778
- continue;
7808
+ const moduleSource = getShaderModuleSource(module, stage, log8);
7809
+ assembledSource += moduleSource;
7810
+ const injections = module.instance?.normalizedInjections[stage] || {};
7811
+ for (const key in injections) {
7812
+ const match = /^(v|f)s:#([\w-]+)$/.exec(key);
7813
+ if (match) {
7814
+ const name = match[2];
7815
+ const injectionType = name === "decl" ? declInjections : mainInjections;
7816
+ injectionType[key] = injectionType[key] || [];
7817
+ injectionType[key].push(injections[key]);
7818
+ } else {
7819
+ hookInjections[key] = hookInjections[key] || [];
7820
+ hookInjections[key].push(injections[key]);
7821
+ }
7779
7822
  }
7780
- index++;
7781
7823
  }
7782
- return maskedCharacters.join("");
7824
+ validateShaderHookInjections(hookFunctionMap, hookInjections, stage);
7825
+ assembledSource += "// ----- MAIN SHADER SOURCE -------------------------";
7826
+ assembledSource += INJECT_SHADER_DECLARATIONS;
7827
+ assembledSource = injectShader(assembledSource, stage, declInjections);
7828
+ assembledSource += getShaderHooks(hookFunctionMap[stage], hookInjections);
7829
+ assembledSource += coreSource;
7830
+ assembledSource = injectShader(assembledSource, stage, mainInjections);
7831
+ if (language === "glsl" && sourceVersion !== targetVersion) {
7832
+ assembledSource = transpileGLSLShader(assembledSource, stage);
7833
+ }
7834
+ if (language === "glsl") {
7835
+ warnIfGLSLUniformBlocksAreNotStd140(assembledSource, stage, log8);
7836
+ }
7837
+ return assembledSource.trim();
7783
7838
  }
7784
- function getWGSLBindingDeclarationMatches(source4, regexes) {
7785
- const maskedSource = maskWGSLComments(source4);
7786
- const matches = [];
7787
- for (const regex of regexes) {
7788
- regex.lastIndex = 0;
7789
- let match;
7790
- match = regex.exec(maskedSource);
7791
- while (match) {
7792
- const isBindingFirst = regex === regexes[0];
7793
- const index = match.index;
7794
- const length4 = match[0].length;
7795
- matches.push({
7796
- match: source4.slice(index, index + length4),
7797
- index,
7798
- length: length4,
7799
- bindingToken: match[isBindingFirst ? 1 : 2],
7800
- groupToken: match[isBindingFirst ? 2 : 1],
7801
- accessDeclaration: match[3]?.trim(),
7802
- name: match[4]
7803
- });
7804
- match = regex.exec(maskedSource);
7839
+ function getApplicationDefines(defines = {}) {
7840
+ let sourceText = "";
7841
+ for (const define in defines) {
7842
+ const value = defines[define];
7843
+ if (value || Number.isFinite(value)) {
7844
+ sourceText += `#define ${define.toUpperCase()} ${defines[define]}
7845
+ `;
7805
7846
  }
7806
7847
  }
7807
- return matches.sort((left, right) => left.index - right.index);
7848
+ return sourceText;
7808
7849
  }
7809
- function replaceWGSLBindingDeclarationMatches(source4, regexes, replacer) {
7810
- const matches = getWGSLBindingDeclarationMatches(source4, regexes);
7811
- if (!matches.length) {
7812
- return source4;
7813
- }
7814
- let relocatedSource = "";
7815
- let lastIndex = 0;
7816
- for (const match of matches) {
7817
- relocatedSource += source4.slice(lastIndex, match.index);
7818
- relocatedSource += replacer(match);
7819
- lastIndex = match.index + match.length;
7850
+
7851
+ // ../shaders/src/lib/glsl-shader-assembler.ts
7852
+ var GLSLShaderAssembler = class extends ShaderAssembler {
7853
+ shaderLanguage = "glsl";
7854
+ /**
7855
+ * Assemble a pair of shaders into a single shader program.
7856
+ * @param props GLSL vertex and fragment source, platform information, shader modules, defines, and injections.
7857
+ * @returns Assembled GLSL source, resolved modules, and combined uniform getter.
7858
+ */
7859
+ assembleGLSLShaderPair(props) {
7860
+ const modules = this._getModuleList(props.modules);
7861
+ const hookFunctions = [...this._hookFunctions, ...props.hookFunctions || []];
7862
+ const vertex = this._transpileShader(props, modules, props.vs, "vertex");
7863
+ const fragment = this._transpileShader(props, modules, props.fs, "fragment");
7864
+ const assembled = assembleGLSLShaderPair({
7865
+ ...props,
7866
+ vs: vertex.code,
7867
+ fs: props.fs == null ? void 0 : fragment.code,
7868
+ modules: vertex.modules,
7869
+ hookFunctions
7870
+ });
7871
+ return { ...assembled, modules };
7820
7872
  }
7821
- relocatedSource += source4.slice(lastIndex);
7822
- return relocatedSource;
7823
- }
7824
- function hasWGSLAutoBinding(source4) {
7825
- return /@binding\(\s*auto\s*\)/.test(maskWGSLComments(source4));
7826
- }
7827
- function getFirstWGSLAutoBindingDeclarationMatch(source4, regexes) {
7828
- const autoBindingRegexes = regexes === MODULE_WGSL_BINDING_DECLARATION_REGEXES || regexes === WGSL_BINDING_DECLARATION_REGEXES ? WGSL_AUTO_BINDING_DECLARATION_REGEXES : regexes;
7829
- return getWGSLBindingDeclarationMatches(source4, autoBindingRegexes).find(
7830
- (declarationMatch) => declarationMatch.bindingToken === "auto"
7831
- );
7832
- }
7873
+ };
7833
7874
 
7834
7875
  // ../shaders/src/lib/shader-assembly/wgsl-interface-scan.ts
7835
7876
  function scanWGSLInterface(source4, options = {}) {
@@ -8557,6 +8598,29 @@ ${getApplicationDefines(allDefines)}
8557
8598
  if (trimmedExpression === "false") {
8558
8599
  return false;
8559
8600
  }
8601
+ const operandPattern = "(?:[A-Za-z_][A-Za-z0-9_]*|[+-]?\\d+(?:\\.\\d+)?)";
8602
+ const comparison = trimmedExpression.match(
8603
+ new RegExp(`^(${operandPattern})\\s*(==|!=|<=|>=|<|>)\\s*(${operandPattern})$`)
8604
+ );
8605
+ if (comparison) {
8606
+ const resolveOperand = (operand) => /^[A-Za-z_]/.test(operand) ? Number(defines[operand] ?? 0) : Number(operand);
8607
+ const left = resolveOperand(comparison[1]);
8608
+ const right = resolveOperand(comparison[3]);
8609
+ switch (comparison[2]) {
8610
+ case "==":
8611
+ return left === right;
8612
+ case "!=":
8613
+ return left !== right;
8614
+ case "<=":
8615
+ return left <= right;
8616
+ case ">=":
8617
+ return left >= right;
8618
+ case "<":
8619
+ return left < right;
8620
+ case ">":
8621
+ return left > right;
8622
+ }
8623
+ }
8560
8624
  const negatedDefineMatch = trimmedExpression.match(new RegExp(`^!\\s*${DEFINE_NAME_PATTERN}$`));
8561
8625
  if (negatedDefineMatch) {
8562
8626
  return !Boolean(defines[negatedDefineMatch[1]]);
@@ -8608,7 +8672,7 @@ ${getApplicationDefines(allDefines)}
8608
8672
  inject = {},
8609
8673
  pluginInjections = {},
8610
8674
  pluginVertexInputs = {},
8611
- pluginVaryings = {},
8675
+ pluginInterStageVariables = {},
8612
8676
  vertexEntryPoint = "vertexMain",
8613
8677
  fragmentEntryPoint = "fragmentMain",
8614
8678
  log: log8
@@ -8620,15 +8684,15 @@ ${getApplicationDefines(allDefines)}
8620
8684
  vertexEntryPoint,
8621
8685
  pluginVertexInputs
8622
8686
  );
8623
- const pluginVaryingAssembly = assembleShaderPluginVaryingsWGSL(
8687
+ const pluginVaryingAssembly = assembleShaderPluginInterStageVariablesWGSL(
8624
8688
  pluginVertexInputAssembly.source,
8625
8689
  vertexEntryPoint,
8626
8690
  fragmentEntryPoint,
8627
- pluginVaryings
8691
+ pluginInterStageVariables
8628
8692
  );
8629
8693
  const coreSource = pluginVaryingAssembly.source;
8630
8694
  let assembledSource = "";
8631
- const hookFunctionMap = normalizeShaderHooks(hookFunctions);
8695
+ const hookFunctionMap = normalizeShaderHooks(hookFunctions, options.pluginHooks, "wgsl");
8632
8696
  const hookInjections = {};
8633
8697
  const declInjections = {};
8634
8698
  const mainInjections = {};
@@ -8641,15 +8705,15 @@ ${getApplicationDefines(allDefines)}
8641
8705
  const name = match[3];
8642
8706
  if (hash) {
8643
8707
  if (name === "decl") {
8644
- declInjections[key] = [injection];
8708
+ declInjections[key] = [...declInjections[key] || [], injection];
8645
8709
  } else {
8646
- mainInjections[key] = [injection];
8710
+ mainInjections[key] = [...mainInjections[key] || [], injection];
8647
8711
  }
8648
8712
  } else {
8649
- hookInjections[key] = [injection];
8713
+ hookInjections[key] = [...hookInjections[key] || [], injection];
8650
8714
  }
8651
8715
  } else {
8652
- mainInjections[key] = [injection];
8716
+ mainInjections[key] = [...mainInjections[key] || [], injection];
8653
8717
  }
8654
8718
  }
8655
8719
  appendGeneratedVertexInputInjections(
@@ -9096,7 +9160,7 @@ ${getApplicationDefines(allDefines)}
9096
9160
  */
9097
9161
  assembleWGSLShader(props) {
9098
9162
  const modules = this._getModuleList(props.modules);
9099
- const hookFunctions = this._hookFunctions;
9163
+ const hookFunctions = [...this._hookFunctions, ...props.hookFunctions || []];
9100
9164
  const translated = this._transpileShader(
9101
9165
  props,
9102
9166
  modules,
@@ -9162,6 +9226,50 @@ ${getApplicationDefines(allDefines)}
9162
9226
  }
9163
9227
  };
9164
9228
 
9229
+ // src/model/batch-uniform-buffer.ts
9230
+ var import_core7 = __toESM(require_core(), 1);
9231
+ var BatchUniformBuffer = class {
9232
+ constructor(device) {
9233
+ this.device = device;
9234
+ }
9235
+ device;
9236
+ buffer;
9237
+ byteOffset = 0;
9238
+ /** Reserves the entire call before drawing, so growth cannot invalidate an earlier batch. */
9239
+ prepare(byteLength) {
9240
+ if (!this.buffer || this.buffer.byteLength < byteLength) {
9241
+ const capacity = Math.max(1024, (this.buffer?.byteLength ?? 0) * 2, byteLength);
9242
+ const buffer = this.device.createBuffer({
9243
+ id: "batch-uniforms",
9244
+ byteLength: capacity,
9245
+ usage: import_core7.Buffer.UNIFORM | import_core7.Buffer.COPY_DST
9246
+ });
9247
+ this.buffer?.destroy();
9248
+ this.buffer = buffer;
9249
+ }
9250
+ this.byteOffset = 0;
9251
+ }
9252
+ /** Returns the aligned slot size required for a uniform block. */
9253
+ getAlignedByteLength(byteLength) {
9254
+ const alignment = this.device.limits.minUniformBufferOffsetAlignment || 1;
9255
+ return Math.ceil(byteLength / alignment) * alignment;
9256
+ }
9257
+ /** Writes one slot without overwriting earlier batches in this call. */
9258
+ write(data) {
9259
+ (0, import_core7.assert)(this.buffer && this.byteOffset + data.byteLength <= this.buffer.byteLength);
9260
+ const binding = { buffer: this.buffer, offset: this.byteOffset, size: data.byteLength };
9261
+ this.buffer.write(data, binding.offset);
9262
+ this.byteOffset += this.getAlignedByteLength(data.byteLength);
9263
+ return binding;
9264
+ }
9265
+ /** Releases the model-owned allocation. */
9266
+ destroy() {
9267
+ this.buffer?.destroy();
9268
+ this.buffer = void 0;
9269
+ this.byteOffset = 0;
9270
+ }
9271
+ };
9272
+
9165
9273
  // src/debug/debug-shader-layout.ts
9166
9274
  function getDebugTableForShaderLayout(layout, name) {
9167
9275
  const table = {};
@@ -9305,6 +9413,8 @@ ${getApplicationDefines(allDefines)}
9305
9413
  return false;
9306
9414
  }
9307
9415
  if (typeof a === "object" && typeof b === "object") {
9416
+ const aObject = a;
9417
+ const bObject = b;
9308
9418
  const aKeys = Object.keys(a);
9309
9419
  const bKeys = Object.keys(b);
9310
9420
  if (aKeys.length !== bKeys.length) {
@@ -9314,7 +9424,7 @@ ${getApplicationDefines(allDefines)}
9314
9424
  if (!b.hasOwnProperty(key)) {
9315
9425
  return false;
9316
9426
  }
9317
- if (!deepEqual(a[key], b[key], depth - 1)) {
9427
+ if (!deepEqual(aObject[key], bObject[key], depth - 1)) {
9318
9428
  return false;
9319
9429
  }
9320
9430
  }
@@ -9324,7 +9434,7 @@ ${getApplicationDefines(allDefines)}
9324
9434
  }
9325
9435
 
9326
9436
  // src/utils/buffer-layout-helper.ts
9327
- var import_core7 = __toESM(require_core(), 1);
9437
+ var import_core8 = __toESM(require_core(), 1);
9328
9438
  var BufferLayoutHelper = class {
9329
9439
  bufferLayouts;
9330
9440
  constructor(bufferLayouts) {
@@ -9335,7 +9445,7 @@ ${getApplicationDefines(allDefines)}
9335
9445
  }
9336
9446
  /** Get attribute names from a BufferLayout */
9337
9447
  getAttributeNamesForBuffer(bufferLayout) {
9338
- return (0, import_core7.getBufferLayoutAttributeNames)(bufferLayout);
9448
+ return (0, import_core8.getBufferLayoutAttributeNames)(bufferLayout);
9339
9449
  }
9340
9450
  mergeBufferLayouts(bufferLayouts1, bufferLayouts2) {
9341
9451
  const mergedLayouts = [...bufferLayouts1];
@@ -9352,16 +9462,16 @@ ${getApplicationDefines(allDefines)}
9352
9462
  };
9353
9463
 
9354
9464
  // src/utils/buffer-layout-order.ts
9355
- var import_core8 = __toESM(require_core(), 1);
9465
+ var import_core9 = __toESM(require_core(), 1);
9356
9466
  function sortedBufferLayoutByShaderSourceLocations(shaderLayout, bufferLayout) {
9357
- const shaderLayoutMap = (0, import_core8.getShaderAttributeLocationMap)(shaderLayout);
9467
+ const shaderLayoutMap = (0, import_core9.getShaderAttributeLocationMap)(shaderLayout);
9358
9468
  const sortedLayout = bufferLayout.slice();
9359
9469
  sortedLayout.sort((a, b) => {
9360
- const minLocationA = (0, import_core8.getMinimumAttributeLocation)(
9361
- (0, import_core8.getBufferLayoutAttributeNames)(a).map((attributeName) => shaderLayoutMap[attributeName])
9470
+ const minLocationA = (0, import_core9.getMinimumAttributeLocation)(
9471
+ (0, import_core9.getBufferLayoutAttributeNames)(a).map((attributeName) => shaderLayoutMap[attributeName])
9362
9472
  );
9363
- const minLocationB = (0, import_core8.getMinimumAttributeLocation)(
9364
- (0, import_core8.getBufferLayoutAttributeNames)(b).map((attributeName) => shaderLayoutMap[attributeName])
9473
+ const minLocationB = (0, import_core9.getMinimumAttributeLocation)(
9474
+ (0, import_core9.getBufferLayoutAttributeNames)(b).map((attributeName) => shaderLayoutMap[attributeName])
9365
9475
  );
9366
9476
  return minLocationA - minLocationB;
9367
9477
  });
@@ -9502,7 +9612,7 @@ ${getApplicationDefines(allDefines)}
9502
9612
  return mergedAttributes;
9503
9613
  }
9504
9614
 
9505
- // ../gpgpu/src/execution/utils/get-platform-info.ts
9615
+ // ../graph/src/execution/utils/get-platform-info.ts
9506
9616
  function getPlatformInfo(device) {
9507
9617
  return {
9508
9618
  type: device.type,
@@ -9524,7 +9634,7 @@ ${getApplicationDefines(allDefines)}
9524
9634
  }
9525
9635
 
9526
9636
  // src/model/gpu-vector-model-batches.ts
9527
- var import_core9 = __toESM(require_core(), 1);
9637
+ var import_core10 = __toESM(require_core(), 1);
9528
9638
  function validateGPUVectorModelLayouts(ownerName, vectors, bufferLayouts) {
9529
9639
  for (const [name, vector] of Object.entries(vectors)) {
9530
9640
  if (!vector) continue;
@@ -9588,22 +9698,22 @@ ${getApplicationDefines(allDefines)}
9588
9698
  if (format.includes("<")) {
9589
9699
  throw new Error(`${ownerName} GPUVector "${name}" requires a fixed-width scalar format`);
9590
9700
  }
9591
- return import_core9.vertexFormatDecoder.getVertexFormatInfo(format);
9701
+ return import_core10.vertexFormatDecoder.getVertexFormatInfo(format);
9592
9702
  }
9593
9703
 
9594
9704
  // src/utils/gpu-vector-batch-structure.ts
9595
- var import_core10 = __toESM(require_core(), 1);
9705
+ var import_core11 = __toESM(require_core(), 1);
9596
9706
  function validateGPUVectorBatchStructure(vectors) {
9597
9707
  let reference;
9598
9708
  for (const vector of Object.values(vectors)) {
9599
9709
  if (!vector || "isConstant" in vector) continue;
9600
9710
  let rowCount = 0;
9601
9711
  for (const chunk of vector.data) rowCount += chunk.length;
9602
- (0, import_core10.assert)(rowCount === vector.length);
9712
+ (0, import_core11.assert)(rowCount === vector.length);
9603
9713
  if (reference) {
9604
- (0, import_core10.assert)(vector.length === reference.length && vector.data.length === reference.data.length);
9714
+ (0, import_core11.assert)(vector.length === reference.length && vector.data.length === reference.data.length);
9605
9715
  for (let batchIndex = 0; batchIndex < vector.data.length; batchIndex++) {
9606
- (0, import_core10.assert)(vector.data[batchIndex].length === reference.data[batchIndex].length);
9716
+ (0, import_core11.assert)(vector.data[batchIndex].length === reference.data[batchIndex].length);
9607
9717
  }
9608
9718
  } else reference = vector;
9609
9719
  }
@@ -9615,6 +9725,8 @@ ${getApplicationDefines(allDefines)}
9615
9725
  const attributeInputs = attributes.inputs;
9616
9726
  const geometryLayouts = geometry.sourceLayouts;
9617
9727
  const attributeLayouts = attributes.sourceLayouts;
9728
+ const geometryBatchLayouts = geometry.layouts;
9729
+ const attributeBatchLayouts = attributes.layouts;
9618
9730
  const attributeStepMode = attributes.stepMode;
9619
9731
  const geometryBatchCount = geometry.batchCount;
9620
9732
  const attributeBatchCount = attributes.batchCount;
@@ -9638,10 +9750,10 @@ ${getApplicationDefines(allDefines)}
9638
9750
  for (let batchIndex = 0; batchIndex < drawCount; batchIndex++) {
9639
9751
  const geometryBatchIndex = independentInstances ? Math.floor(batchIndex / attributeBatchCount) : Math.min(batchIndex, geometryBatchCount - 1);
9640
9752
  const attributeBatchIndex = independentInstances ? batchIndex % attributeBatchCount : Math.min(batchIndex, attributeBatchCount - 1);
9641
- geometry.setInputs(geometryBatches[geometryBatchIndex], geometryLayouts, "vertex");
9753
+ geometry.setInputs(geometryBatches[geometryBatchIndex], geometryBatchLayouts, "vertex");
9642
9754
  attributes.setInputs(
9643
9755
  attributeBatches[attributeBatchIndex],
9644
- attributeLayouts,
9756
+ attributeBatchLayouts,
9645
9757
  attributeStepMode
9646
9758
  );
9647
9759
  syncBindings();
@@ -9693,7 +9805,7 @@ ${getApplicationDefines(allDefines)}
9693
9805
  }
9694
9806
 
9695
9807
  // src/model/gpu-vector-bindings.ts
9696
- var import_core11 = __toESM(require_core(), 1);
9808
+ var import_core12 = __toESM(require_core(), 1);
9697
9809
  var GPUVectorBindings = class {
9698
9810
  constructor(device, id) {
9699
9811
  this.device = device;
@@ -9725,21 +9837,17 @@ ${getApplicationDefines(allDefines)}
9725
9837
  const providedLayouts = explicitLayouts ?? Object.entries(columns).flatMap(
9726
9838
  ([name, column]) => column && !isConstant(column) && column.bufferLayout ? [{ ...column.bufferLayout, name }] : []
9727
9839
  );
9728
- const layouts = [
9729
- ...providedLayouts,
9730
- ...Object.entries(columns).flatMap(([name, column]) => {
9731
- if (!column || providedLayouts.some(
9732
- (layout) => layout.name === name || layout.attributes?.some((attribute) => attribute.attribute === name)
9733
- ))
9734
- return [];
9735
- (0, import_core11.assert)(column.format);
9736
- const format = column.format;
9737
- const byteStride = isConstant(column) ? 0 : column.byteStride;
9738
- return [
9739
- { name, stepMode, byteStride, attributes: [{ attribute: name, format, byteOffset: 0 }] }
9740
- ];
9741
- })
9742
- ];
9840
+ const inferredLayouts = Object.entries(columns).flatMap(([name, column]) => {
9841
+ if (!column || providedLayouts.some(
9842
+ (layout) => layout.name === name || layout.attributes?.some((attribute) => attribute.attribute === name)
9843
+ ))
9844
+ return [];
9845
+ (0, import_core12.assert)(column.format);
9846
+ const format = column.format;
9847
+ const byteStride = isConstant(column) ? 0 : column.byteStride;
9848
+ return [{ name, stepMode, byteStride, attributes: [{ attribute: name, format, byteOffset: 0 }] }];
9849
+ });
9850
+ const layouts = [...providedLayouts, ...consolidateInferredLayouts(columns, inferredLayouts)];
9743
9851
  for (const [name, column] of Object.entries(columns)) {
9744
9852
  if (!column) continue;
9745
9853
  if (!isConstant(column) && !Array.isArray(column.data))
@@ -9750,10 +9858,10 @@ ${getApplicationDefines(allDefines)}
9750
9858
  );
9751
9859
  const mode = layout?.stepMode ?? stepMode;
9752
9860
  if (mode === "instance") {
9753
- (0, import_core11.assert)(this.instanceCount === void 0 || this.instanceCount === column.length);
9861
+ (0, import_core12.assert)(this.instanceCount === void 0 || this.instanceCount === column.length);
9754
9862
  this.instanceCount = column.length;
9755
9863
  } else {
9756
- (0, import_core11.assert)(this.vertexCount === void 0 || this.vertexCount === column.length);
9864
+ (0, import_core12.assert)(this.vertexCount === void 0 || this.vertexCount === column.length);
9757
9865
  this.vertexCount = column.length;
9758
9866
  }
9759
9867
  this.rowCount = stepMode === "instance" ? this.instanceCount : this.vertexCount;
@@ -9798,7 +9906,7 @@ ${getApplicationDefines(allDefines)}
9798
9906
  for (const definition of definitions) {
9799
9907
  const column = columns[definition.attribute] ?? (definition.attribute === layout.name ? columns[layout.name] : void 0);
9800
9908
  if (!column) continue;
9801
- (0, import_core11.assert)(column.format === void 0 || column.format === definition.format);
9909
+ (0, import_core12.assert)(column.format === void 0 || column.format === definition.format);
9802
9910
  if (isConstant(column)) {
9803
9911
  this.constants[definition.attribute] = getShaderConstant(column);
9804
9912
  constantByteLength = Math.max(
@@ -9825,7 +9933,7 @@ ${getApplicationDefines(allDefines)}
9825
9933
  buffer = this.device.createBuffer({
9826
9934
  id: `${this.id}-${layout.name}-constant`,
9827
9935
  byteLength: bytes.byteLength,
9828
- usage: import_core11.Buffer.VERTEX | import_core11.Buffer.COPY_DST | import_core11.Buffer.COPY_SRC
9936
+ usage: import_core12.Buffer.VERTEX | import_core12.Buffer.COPY_DST | import_core12.Buffer.COPY_SRC
9829
9937
  });
9830
9938
  this.constantBuffers[layout.name] = buffer;
9831
9939
  }
@@ -9862,7 +9970,7 @@ ${getApplicationDefines(allDefines)}
9862
9970
  const chunk = vector.data[0];
9863
9971
  if (!chunk) return;
9864
9972
  const byteOffset = chunk.byteOffset - layoutOffset;
9865
- (0, import_core11.assert)(byteOffset >= 0);
9973
+ (0, import_core12.assert)(byteOffset >= 0);
9866
9974
  this.buffers[name] = chunk.buffer;
9867
9975
  this.byteOffsets[name] = byteOffset;
9868
9976
  }
@@ -9871,7 +9979,7 @@ ${getApplicationDefines(allDefines)}
9871
9979
  return Boolean(column && "isConstant" in column && column.isConstant);
9872
9980
  }
9873
9981
  function getShaderConstant(column) {
9874
- const information = import_core11.vertexFormatDecoder.getVertexFormatInfo(column.format);
9982
+ const information = import_core12.vertexFormatDecoder.getVertexFormatInfo(column.format);
9875
9983
  if (column.format === "unorm10-10-10-2") {
9876
9984
  const word = column.value[0];
9877
9985
  return new Float32Array([
@@ -9896,9 +10004,52 @@ ${getApplicationDefines(allDefines)}
9896
10004
  return information.signed ? new Int32Array(values) : new Uint32Array(values);
9897
10005
  return new Float32Array(values);
9898
10006
  }
10007
+ function consolidateInferredLayouts(columns, layouts) {
10008
+ const result = [];
10009
+ let constantLayout;
10010
+ let constantByteLength = 0;
10011
+ const sortedLayouts = [...layouts].sort((left, right) => {
10012
+ const leftColumn = columns[left.name];
10013
+ const rightColumn = columns[right.name];
10014
+ return (leftColumn && !isConstant(leftColumn) ? leftColumn.data[0]?.byteOffset ?? 0 : 0) - (rightColumn && !isConstant(rightColumn) ? rightColumn.data[0]?.byteOffset ?? 0 : 0);
10015
+ });
10016
+ for (const layout of sortedLayouts) {
10017
+ const column = columns[layout.name];
10018
+ const attribute = layout.attributes[0];
10019
+ if (isConstant(column)) {
10020
+ if (!constantLayout) {
10021
+ constantLayout = { ...layout, attributes: [] };
10022
+ result.push(constantLayout);
10023
+ }
10024
+ const alignment = Math.min(4, column.byteLength);
10025
+ constantByteLength = Math.ceil(constantByteLength / alignment) * alignment;
10026
+ constantLayout.attributes.push({ ...attribute, byteOffset: constantByteLength });
10027
+ constantByteLength += column.byteLength;
10028
+ continue;
10029
+ }
10030
+ const sharedLayout = result.find((candidate) => {
10031
+ const primary = columns[candidate.name];
10032
+ if (!primary || isConstant(primary) || !primary.data.length || !column.data.length)
10033
+ return false;
10034
+ const offset = column.data[0].byteOffset - primary.data[0].byteOffset;
10035
+ return candidate.stepMode === layout.stepMode && candidate.byteStride === layout.byteStride && offset >= 0 && offset + column.rowByteLength <= column.byteStride && column.data.every((chunk, index) => {
10036
+ const primaryChunk = primary.data[index];
10037
+ return chunk.buffer === primaryChunk.buffer && chunk.byteStride === primaryChunk.byteStride && chunk.byteOffset - primaryChunk.byteOffset === offset;
10038
+ });
10039
+ });
10040
+ if (sharedLayout) {
10041
+ const primary = columns[sharedLayout.name];
10042
+ sharedLayout.attributes.push({
10043
+ ...attribute,
10044
+ byteOffset: column.data[0].byteOffset - primary.data[0].byteOffset
10045
+ });
10046
+ } else result.push({ ...layout, attributes: [...layout.attributes] });
10047
+ }
10048
+ return result;
10049
+ }
9899
10050
 
9900
10051
  // src/shader-inputs.ts
9901
- var import_core12 = __toESM(require_core(), 1);
10052
+ var import_core13 = __toESM(require_core(), 1);
9902
10053
  var import_shaders2 = __toESM(require_shaders(), 1);
9903
10054
 
9904
10055
  // src/model/split-uniforms-and-bindings.ts
@@ -9948,7 +10099,7 @@ ${getApplicationDefines(allDefines)}
9948
10099
  for (const resolvedModule of resolvedModules) {
9949
10100
  modules[resolvedModule.name] = resolvedModule;
9950
10101
  }
9951
- import_core12.log.log(1, "Creating ShaderInputs with modules", Object.keys(modules))();
10102
+ import_core13.log.log(1, "Creating ShaderInputs with modules", Object.keys(modules))();
9952
10103
  this.modules = modules;
9953
10104
  this.moduleUniforms = {};
9954
10105
  this.moduleBindings = {};
@@ -9956,7 +10107,7 @@ ${getApplicationDefines(allDefines)}
9956
10107
  if (module) {
9957
10108
  this._addModule(module);
9958
10109
  if (module.name && name !== module.name && !this.options.disableWarnings) {
9959
- import_core12.log.warn(`Module name: ${name} vs ${module.name}`)();
10110
+ import_core13.log.warn(`Module name: ${name} vs ${module.name}`)();
9960
10111
  }
9961
10112
  }
9962
10113
  }
@@ -9980,7 +10131,7 @@ ${getApplicationDefines(allDefines)}
9980
10131
  const module = this.modules[moduleName];
9981
10132
  if (!module) {
9982
10133
  if (!this.options.disableWarnings) {
9983
- import_core12.log.warn(`Module ${name} not found`)();
10134
+ import_core13.log.warn(`Module ${name} not found`)();
9984
10135
  }
9985
10136
  } else {
9986
10137
  const oldUniforms = this.moduleUniforms[moduleName];
@@ -10175,7 +10326,7 @@ ${getApplicationDefines(allDefines)}
10175
10326
  var VERSION = true ? "5.0.0" : "untranspiled source";
10176
10327
 
10177
10328
  // ../../node_modules/probe.gl/dist/log/utils/assert.js
10178
- function assert6(condition, message) {
10329
+ function assert7(condition, message) {
10179
10330
  if (!condition) {
10180
10331
  throw new Error(message || "Assertion failed");
10181
10332
  }
@@ -10197,7 +10348,7 @@ ${getApplicationDefines(allDefines)}
10197
10348
  default:
10198
10349
  return 0;
10199
10350
  }
10200
- assert6(Number.isFinite(resolvedLevel) && resolvedLevel >= 0);
10351
+ assert7(Number.isFinite(resolvedLevel) && resolvedLevel >= 0);
10201
10352
  return resolvedLevel;
10202
10353
  }
10203
10354
  function normalizeArguments(opts) {
@@ -10223,7 +10374,7 @@ ${getApplicationDefines(allDefines)}
10223
10374
  opts.message = opts.message();
10224
10375
  }
10225
10376
  const messageType = typeof opts.message;
10226
- assert6(messageType === "string" || messageType === "object");
10377
+ assert7(messageType === "string" || messageType === "object");
10227
10378
  return Object.assign(opts, { args }, opts.opts);
10228
10379
  }
10229
10380
 
@@ -10639,7 +10790,7 @@ ${getApplicationDefines(allDefines)}
10639
10790
  }
10640
10791
  _emit(_type, normalized2) {
10641
10792
  const method = normalized2.method;
10642
- assert6(method);
10793
+ assert7(method);
10643
10794
  normalized2.total = this.getTotal();
10644
10795
  normalized2.delta = this.getDelta();
10645
10796
  this._deltaTs = probe.getHighResolutionTimer();
@@ -11065,7 +11216,7 @@ ${getApplicationDefines(allDefines)}
11065
11216
  }
11066
11217
 
11067
11218
  // ../core/src/api/adapter/resources/buffer.ts
11068
- var Buffer3 = class _Buffer extends Resource {
11219
+ var Buffer4 = class _Buffer extends Resource {
11069
11220
  /** Index buffer */
11070
11221
  static INDEX = 16;
11071
11222
  /** Vertex buffer */
@@ -11447,6 +11598,7 @@ ${getApplicationDefines(allDefines)}
11447
11598
  "pvrtc-rgb2unorm-webgl": { f: texture_compression_pvrtc_webgl },
11448
11599
  "pvrtc-rgba2unorm-webgl": { f: texture_compression_pvrtc_webgl },
11449
11600
  // WEBGL_compressed_texture_etc1
11601
+ "etc1-rgb-unorm-webgl": { f: texture_compression_etc1_webgl },
11450
11602
  "etc1-rbg-unorm-webgl": { f: texture_compression_etc1_webgl },
11451
11603
  // WEBGL_compressed_texture_atc
11452
11604
  "atc-rgb-unorm-webgl": { f: texture_compression_atc_webgl },
@@ -12246,7 +12398,7 @@ ${getApplicationDefines(allDefines)}
12246
12398
  }
12247
12399
 
12248
12400
  // ../core/src/dynamic/dynamic-buffer/dynamic-buffer.ts
12249
- var DEFAULT_MAX_DEBUG_DATA_BYTE_LENGTH = Buffer3.DEBUG_DATA_MAX_LENGTH;
12401
+ var DEFAULT_MAX_DEBUG_DATA_BYTE_LENGTH = Buffer4.DEBUG_DATA_MAX_LENGTH;
12250
12402
  var DynamicBuffer = class {
12251
12403
  /** Device that owns the backing buffer. */
12252
12404
  device;
@@ -12313,7 +12465,7 @@ ${getApplicationDefines(allDefines)}
12313
12465
  usage: bufferProps.usage ?? adoptedBuffer?.usage,
12314
12466
  indexType: bufferProps.indexType ?? adoptedBuffer?.indexType
12315
12467
  };
12316
- if ((normalizedBufferProps.usage || 0) & Buffer3.INDEX && !normalizedBufferProps.indexType) {
12468
+ if ((normalizedBufferProps.usage || 0) & Buffer4.INDEX && !normalizedBufferProps.indexType) {
12317
12469
  if (bufferProps.data instanceof Uint32Array) {
12318
12470
  normalizedBufferProps.indexType = "uint32";
12319
12471
  } else if (bufferProps.data instanceof Uint16Array) {
@@ -12883,7 +13035,7 @@ ${getApplicationDefines(allDefines)}
12883
13035
  const layout = this.texture.computeMemoryLayout({ width, height, depthOrArrayLayers });
12884
13036
  const buffer = this.device.createBuffer({
12885
13037
  byteLength: layout.byteLength,
12886
- usage: Buffer3.COPY_DST | Buffer3.MAP_READ
13038
+ usage: Buffer4.COPY_DST | Buffer4.MAP_READ
12887
13039
  });
12888
13040
  this.texture.readBuffer(
12889
13041
  {
@@ -13247,13 +13399,13 @@ ${getApplicationDefines(allDefines)}
13247
13399
  var GPUVectorModel = class _GPUVectorModel {
13248
13400
  /** Creates a model while allowing the backend to compile its render pipeline asynchronously. */
13249
13401
  static async createAsync(device, props) {
13250
- const ownsCompilation = !import_core13.PipelineFactory.getAsyncCompilation(device);
13251
- const asyncCompilation = ownsCompilation ? import_core13.PipelineFactory.beginAsyncCompilation(device) : import_core13.PipelineFactory.getAsyncCompilation(device);
13402
+ const ownsCompilation = !import_core14.PipelineFactory.getAsyncCompilation(device);
13403
+ const asyncCompilation = ownsCompilation ? import_core14.PipelineFactory.beginAsyncCompilation(device) : import_core14.PipelineFactory.getAsyncCompilation(device);
13252
13404
  let model;
13253
13405
  try {
13254
13406
  model = new this(device, props);
13255
13407
  } finally {
13256
- if (ownsCompilation) import_core13.PipelineFactory.endAsyncCompilation(device, asyncCompilation);
13408
+ if (ownsCompilation) import_core14.PipelineFactory.endAsyncCompilation(device, asyncCompilation);
13257
13409
  }
13258
13410
  try {
13259
13411
  if (ownsCompilation) {
@@ -13268,7 +13420,7 @@ ${getApplicationDefines(allDefines)}
13268
13420
  }
13269
13421
  }
13270
13422
  static defaultProps = {
13271
- ...import_core13.RenderPipeline.defaultProps,
13423
+ ...import_core14.RenderPipeline.defaultProps,
13272
13424
  gpuVectorCount: "instance",
13273
13425
  geometry: null,
13274
13426
  attributeVectors: void 0,
@@ -13366,6 +13518,7 @@ ${getApplicationDefines(allDefines)}
13366
13518
  _uniformStore;
13367
13519
  _attributeInfos = {};
13368
13520
  props;
13521
+ batchUniformBuffer;
13369
13522
  geometryVectorBindings;
13370
13523
  attributeVectorBindings;
13371
13524
  explicitBufferLayout = [];
@@ -13427,88 +13580,98 @@ ${getApplicationDefines(allDefines)}
13427
13580
  this.explicitBufferLayout = this.bufferLayout;
13428
13581
  this.geometryVectorBindings = new GPUVectorBindings(device, `${this.id}-geometry`);
13429
13582
  this.attributeVectorBindings = new GPUVectorBindings(device, `${this.id}-attributes`);
13430
- this._initializeProps(props);
13431
- const platformInfo = getPlatformInfo(device);
13432
- const resolvedPlugins = (0, import_shaders3.resolveShaderPlugins)(this.props.plugins, platformInfo.shaderLanguage);
13433
- const shaderInputModules = (0, import_shaders3.mergeShaderPluginModules)(
13434
- this.props.modules,
13435
- resolvedPlugins.modules
13436
- );
13437
- const moduleMap = Object.fromEntries(shaderInputModules.map((module) => [module.name, module]));
13438
- const shaderInputs = props.shaderInputs || new ShaderInputs(moduleMap, { disableWarnings: this.props.disableWarnings });
13439
- if (props.shaderInputs && resolvedPlugins.modules.length > 0) {
13440
- shaderInputs.addModules(resolvedPlugins.modules);
13441
- }
13442
- this.setShaderInputs(shaderInputs);
13443
- const modules = mergeShaderModules(this.props.modules, shaderInputs.getModules());
13444
- const defines = { ...resolvedPlugins.defines, ...this.props.defines };
13445
- if (this.device.type === "webgl") {
13446
- this.props._uniformBlockLayouts = getShaderModuleUniformBlockLayouts(modules);
13447
- }
13448
- this.props.shaderLayout = mergeShaderModuleBindingsIntoLayout(this.props.shaderLayout, modules) || null;
13449
- const isWebGPU = this.device.type === "webgpu";
13450
- if (isWebGPU && this.props.source) {
13451
- const shaderAssembler = this.props.shaderAssembler;
13452
- (0, import_core13.assert)(isShaderAssemblerForLanguage(shaderAssembler, "wgsl"));
13453
- const {
13454
- source: source4,
13455
- getUniforms: getUniforms2,
13456
- bindingTable,
13457
- entryPoints = {},
13458
- shaderLayout: assembledShaderLayout
13459
- } = shaderAssembler.assembleWGSLShader({
13460
- platformInfo,
13461
- ...this.props,
13462
- modules,
13463
- defines,
13464
- pluginInjections: resolvedPlugins.injections,
13465
- pluginVertexInputs: resolvedPlugins.vertexInputs,
13466
- pluginVaryings: resolvedPlugins.varyings
13467
- });
13468
- this.source = source4;
13469
- this.props.vertexEntryPoint = entryPoints.vertex || this.props.vertexEntryPoint;
13470
- this.props.fragmentEntryPoint = entryPoints.fragment || this.props.fragmentEntryPoint;
13471
- this._getModuleUniforms = getUniforms2;
13472
- this._bindingTable = bindingTable;
13473
- const scannedOrReflectedShaderLayout = assembledShaderLayout ?? device.getShaderLayout?.(
13474
- this.source
13475
- );
13476
- const inferredShaderLayout = normalizeShaderPluginAttributeNames(
13477
- scannedOrReflectedShaderLayout,
13478
- resolvedPlugins.vertexInputs
13479
- );
13480
- const shaderLayout = mergeInferredShaderLayout(
13481
- this.props.shaderLayout,
13482
- inferredShaderLayout,
13483
- Object.keys(resolvedPlugins.vertexInputs)
13583
+ try {
13584
+ this._initializeProps(props);
13585
+ const platformInfo = getPlatformInfo(device);
13586
+ const resolvedPlugins = (0, import_shaders3.resolveShaderPlugins)(this.props.plugins, platformInfo.shaderLanguage);
13587
+ const shaderInputModules = (0, import_shaders3.mergeShaderPluginModules)(
13588
+ this.props.modules,
13589
+ resolvedPlugins.modules
13484
13590
  );
13485
- this.props.shaderLayout = mergeShaderModuleBindingsIntoLayout(shaderLayout || null, modules) || null;
13486
- } else {
13487
- const shaderAssembler = this.props.shaderAssembler;
13488
- (0, import_core13.assert)(isShaderAssemblerForLanguage(shaderAssembler, "glsl"));
13489
- const { vs: vs4, fs: fs4, getUniforms: getUniforms2 } = shaderAssembler.assembleGLSLShaderPair({
13490
- platformInfo,
13491
- ...this.props,
13492
- modules,
13493
- defines,
13494
- pluginInjections: resolvedPlugins.injections,
13495
- pluginVertexInputs: resolvedPlugins.vertexInputs,
13496
- pluginVaryings: resolvedPlugins.varyings
13497
- });
13498
- this.vs = vs4;
13499
- this.fs = fs4;
13500
- this._getModuleUniforms = getUniforms2;
13501
- this._bindingTable = [];
13502
- }
13503
- this.pipelineFactory = props.pipelineFactory || import_core13.PipelineFactory.getDefaultPipelineFactory(this.device);
13504
- this.shaderFactory = props.shaderFactory || import_core13.ShaderFactory.getDefaultShaderFactory(this.device);
13505
- const asyncCompilation = import_core13.PipelineFactory.getAsyncCompilation(this.device);
13506
- if (asyncCompilation) {
13507
- this._pipelineInitialization = this._initializePipelineAsync(props);
13508
- asyncCompilation.push(this._pipelineInitialization);
13509
- } else {
13510
- this.pipeline = this._updatePipeline();
13511
- this._initializePipelineResources(props);
13591
+ const moduleMap = Object.fromEntries(shaderInputModules.map((module) => [module.name, module]));
13592
+ const shaderInputs = props.shaderInputs || new ShaderInputs(moduleMap, { disableWarnings: this.props.disableWarnings });
13593
+ if (props.shaderInputs && resolvedPlugins.modules.length > 0) {
13594
+ shaderInputs.addModules(resolvedPlugins.modules);
13595
+ }
13596
+ this.setShaderInputs(shaderInputs);
13597
+ const modules = mergeShaderModules(this.props.modules, shaderInputs.getModules());
13598
+ const defines = { ...resolvedPlugins.defines, ...this.props.defines };
13599
+ if (this.device.type === "webgl") {
13600
+ this.props._uniformBlockLayouts = getShaderModuleUniformBlockLayouts(modules);
13601
+ }
13602
+ this.props.shaderLayout = mergeShaderModuleBindingsIntoLayout(this.props.shaderLayout, modules) || null;
13603
+ const isWebGPU = this.device.type === "webgpu";
13604
+ if (isWebGPU && this.props.source) {
13605
+ const shaderAssembler = this.props.shaderAssembler;
13606
+ (0, import_core14.assert)(isShaderAssemblerForLanguage(shaderAssembler, "wgsl"));
13607
+ const {
13608
+ source: source4,
13609
+ getUniforms: getUniforms2,
13610
+ bindingTable,
13611
+ entryPoints = {},
13612
+ shaderLayout: assembledShaderLayout
13613
+ } = shaderAssembler.assembleWGSLShader({
13614
+ platformInfo,
13615
+ ...this.props,
13616
+ modules,
13617
+ defines,
13618
+ pluginHooks: resolvedPlugins.hooks,
13619
+ pluginInjections: resolvedPlugins.injections,
13620
+ pluginVertexInputs: resolvedPlugins.vertexInputs,
13621
+ pluginInterStageVariables: resolvedPlugins.interStageVariables
13622
+ });
13623
+ this.source = source4;
13624
+ this.props.vertexEntryPoint = entryPoints.vertex || this.props.vertexEntryPoint;
13625
+ this.props.fragmentEntryPoint = entryPoints.fragment || this.props.fragmentEntryPoint;
13626
+ this._getModuleUniforms = getUniforms2;
13627
+ this._bindingTable = bindingTable;
13628
+ const scannedOrReflectedShaderLayout = assembledShaderLayout ?? device.getShaderLayout?.(
13629
+ this.source
13630
+ );
13631
+ const inferredShaderLayout = normalizeShaderPluginAttributeNames(
13632
+ scannedOrReflectedShaderLayout,
13633
+ resolvedPlugins.vertexInputs
13634
+ );
13635
+ const shaderLayout = mergeInferredShaderLayout(
13636
+ this.props.shaderLayout,
13637
+ inferredShaderLayout,
13638
+ Object.keys(resolvedPlugins.vertexInputs)
13639
+ );
13640
+ this.props.shaderLayout = mergeShaderModuleBindingsIntoLayout(shaderLayout || null, modules) || null;
13641
+ } else {
13642
+ const shaderAssembler = this.props.shaderAssembler;
13643
+ (0, import_core14.assert)(isShaderAssemblerForLanguage(shaderAssembler, "glsl"));
13644
+ const { vs: vs4, fs: fs4, getUniforms: getUniforms2 } = shaderAssembler.assembleGLSLShaderPair({
13645
+ platformInfo,
13646
+ ...this.props,
13647
+ modules,
13648
+ defines,
13649
+ pluginHooks: resolvedPlugins.hooks,
13650
+ pluginInjections: resolvedPlugins.injections,
13651
+ pluginVertexInputs: resolvedPlugins.vertexInputs,
13652
+ pluginInterStageVariables: resolvedPlugins.interStageVariables
13653
+ });
13654
+ this.vs = vs4;
13655
+ this.fs = fs4;
13656
+ this._getModuleUniforms = getUniforms2;
13657
+ this._bindingTable = [];
13658
+ }
13659
+ this.pipelineFactory = props.pipelineFactory || import_core14.PipelineFactory.getDefaultPipelineFactory(this.device);
13660
+ this.shaderFactory = props.shaderFactory || import_core14.ShaderFactory.getDefaultShaderFactory(this.device);
13661
+ const asyncCompilation = import_core14.PipelineFactory.getAsyncCompilation(this.device);
13662
+ if (asyncCompilation) {
13663
+ this._pipelineInitialization = this._initializePipelineAsync(props);
13664
+ asyncCompilation.push(this._pipelineInitialization);
13665
+ } else {
13666
+ this.pipeline = this._updatePipeline();
13667
+ this._initializePipelineResources(props);
13668
+ }
13669
+ } catch (error) {
13670
+ try {
13671
+ _GPUVectorModel.prototype.destroy.call(this);
13672
+ } finally {
13673
+ throw error;
13674
+ }
13512
13675
  }
13513
13676
  }
13514
13677
  /** Initializes subclass input policies before shader and pipeline creation. */
@@ -13561,9 +13724,11 @@ ${getApplicationDefines(allDefines)}
13561
13724
  this.shaderFactory.release(this.pipeline.fs);
13562
13725
  }
13563
13726
  }
13727
+ this.vertexArray?.destroy();
13564
13728
  this.geometryVectorBindings.destroy();
13565
13729
  this.attributeVectorBindings.destroy();
13566
- this._uniformStore.destroy();
13730
+ this._uniformStore?.destroy();
13731
+ this.batchUniformBuffer?.destroy();
13567
13732
  this._destroyed = true;
13568
13733
  }
13569
13734
  }
@@ -13611,12 +13776,12 @@ ${getApplicationDefines(allDefines)}
13611
13776
  return this.drawVectorGroups(renderPass);
13612
13777
  }
13613
13778
  if (this._drawBlockedReason && !this._pipelineNeedsUpdate) {
13614
- import_core13.log.info(LOG_DRAW_PRIORITY, `>>> DRAWING ABORTED ${this.id}: ${this._drawBlockedReason}`)();
13779
+ import_core14.log.info(LOG_DRAW_PRIORITY, `>>> DRAWING ABORTED ${this.id}: ${this._drawBlockedReason}`)();
13615
13780
  return false;
13616
13781
  }
13617
13782
  const loadingBinding = this._areBindingsLoading();
13618
13783
  if (loadingBinding) {
13619
- import_core13.log.info(LOG_DRAW_PRIORITY, `>>> DRAWING ABORTED ${this.id}: ${loadingBinding} not loaded`)();
13784
+ import_core14.log.info(LOG_DRAW_PRIORITY, `>>> DRAWING ABORTED ${this.id}: ${loadingBinding} not loaded`)();
13620
13785
  return false;
13621
13786
  }
13622
13787
  this._syncAttachmentFormats(renderPass);
@@ -13640,7 +13805,7 @@ ${getApplicationDefines(allDefines)}
13640
13805
  this.pipeline = this._updatePipeline();
13641
13806
  pipelineErrored = this.pipeline.isErrored;
13642
13807
  if (pipelineErrored) {
13643
- import_core13.log.info(
13808
+ import_core14.log.info(
13644
13809
  LOG_DRAW_PRIORITY,
13645
13810
  `>>> DRAWING ABORTED ${this.id}: ${PIPELINE_INITIALIZATION_FAILED}`
13646
13811
  )();
@@ -13648,7 +13813,7 @@ ${getApplicationDefines(allDefines)}
13648
13813
  } else {
13649
13814
  const drawValidationError = this.vertexArray.getDrawValidationError();
13650
13815
  if (drawValidationError) {
13651
- import_core13.log.info(LOG_DRAW_PRIORITY, `>>> DRAWING ABORTED ${this.id}: ${drawValidationError}`)();
13816
+ import_core14.log.info(LOG_DRAW_PRIORITY, `>>> DRAWING ABORTED ${this.id}: ${drawValidationError}`)();
13652
13817
  this._drawBlockedReason = drawValidationError;
13653
13818
  drawSuccess = false;
13654
13819
  } else {
@@ -13717,7 +13882,7 @@ ${getApplicationDefines(allDefines)}
13717
13882
  this.claimVectorLayouts(this.geometryVectorBindings);
13718
13883
  this.syncVectorBindings();
13719
13884
  const rowCount = this.geometryVectorBindings.rowCount;
13720
- (0, import_core13.assert)(
13885
+ (0, import_core14.assert)(
13721
13886
  rowCount === void 0 || this.attributeVectorBindings.vertexCount === void 0 || rowCount === this.attributeVectorBindings.vertexCount
13722
13887
  );
13723
13888
  this.setVertexCount(rowCount ?? this.attributeVectorBindings.vertexCount ?? 0);
@@ -13751,7 +13916,7 @@ ${getApplicationDefines(allDefines)}
13751
13916
  const vertexCount = this.attributeVectorBindings.vertexCount;
13752
13917
  if (vertexCount !== void 0) {
13753
13918
  const geometryRowCount = this.geometryVectorBindings.rowCount;
13754
- (0, import_core13.assert)(geometryRowCount === void 0 || geometryRowCount === vertexCount);
13919
+ (0, import_core14.assert)(geometryRowCount === void 0 || geometryRowCount === vertexCount);
13755
13920
  if (geometryRowCount === void 0) this.setVertexCount(vertexCount);
13756
13921
  }
13757
13922
  }
@@ -13762,9 +13927,9 @@ ${getApplicationDefines(allDefines)}
13762
13927
  /** Replaces the borrowed contiguous uint16/uint32 index vector. */
13763
13928
  setIndexVector(vector) {
13764
13929
  if (vector) {
13765
- (0, import_core13.assert)(vector.format === "uint8" || vector.format === "uint16" || vector.format === "uint32");
13766
- (0, import_core13.assert)(vector.data.length <= 1);
13767
- (0, import_core13.assert)(
13930
+ (0, import_core14.assert)(vector.format === "uint8" || vector.format === "uint16" || vector.format === "uint32");
13931
+ (0, import_core14.assert)(vector.data.length <= 1);
13932
+ (0, import_core14.assert)(
13768
13933
  vector.byteStride === (vector.format === "uint32" ? 4 : vector.format === "uint16" ? 2 : 1)
13769
13934
  );
13770
13935
  }
@@ -13776,7 +13941,7 @@ ${getApplicationDefines(allDefines)}
13776
13941
  const chunk = vector?.data[0];
13777
13942
  if (chunk && this.indexVector) {
13778
13943
  const buffer = chunk.buffer instanceof DynamicBuffer ? chunk.buffer.buffer : chunk.buffer;
13779
- (0, import_core13.assert)(
13944
+ (0, import_core14.assert)(
13780
13945
  buffer.indexType === this.indexVector.format && chunk.byteOffset % this.indexVector.byteStride === 0
13781
13946
  );
13782
13947
  }
@@ -13850,7 +14015,7 @@ ${getApplicationDefines(allDefines)}
13850
14015
  /** Binds contiguous borrowed vectors; use drawBatches() for multi-chunk inputs. */
13851
14016
  setGPUVectors(vectors, options) {
13852
14017
  const batches = getGPUVectorModelBatches(this.id, vectors);
13853
- (0, import_core13.assert)(batches.length <= 1);
14018
+ (0, import_core14.assert)(batches.length <= 1);
13854
14019
  validateGPUVectorModelLayouts(this.id, vectors, this.bufferLayout);
13855
14020
  if (batches[0]) this.setGPUData(batches[0].data);
13856
14021
  this.setBatchDrawCount(batches[0]?.rowCount ?? 0, options?.count);
@@ -13877,12 +14042,18 @@ ${getApplicationDefines(allDefines)}
13877
14042
  this.drawingVectorBatches = drawingVectorBatches;
13878
14043
  }
13879
14044
  }
13880
- /** Draws each aligned physical chunk without retaining or taking ownership of input vectors. */
14045
+ /**
14046
+ * Draws each aligned physical chunk without taking ownership of input vectors.
14047
+ * Each batch uses a separate aligned slot for managed shader-input uniforms set by
14048
+ * `onBatch`. Slots are reused on each call: submit previous draws before changing their
14049
+ * values or growing the allocation. Explicit buffers remain caller-managed. Vector
14050
+ * lengths and physical chunk boundaries must match.
14051
+ */
13881
14052
  drawBatches(renderPass, { vectors, onBatch }) {
13882
14053
  const batches = getGPUVectorModelBatches(this.id, vectors);
13883
14054
  validateGPUVectorModelLayouts(this.id, vectors, this.bufferLayout);
13884
14055
  for (const name of Object.keys(vectors)) {
13885
- (0, import_core13.assert)(!vectors[name] || this.currentAttributes[name]);
14056
+ (0, import_core14.assert)(!vectors[name] || this.currentAttributes[name]);
13886
14057
  }
13887
14058
  const previousAttributes = { ...this.currentAttributes };
13888
14059
  const previousAttributeByteOffsets = { ...this.currentAttributeByteOffsets };
@@ -13892,6 +14063,17 @@ ${getApplicationDefines(allDefines)}
13892
14063
  const previousIsInstanced = this.isInstanced;
13893
14064
  const previousVertexCountSet = this._vertexCountSet;
13894
14065
  const drawingVectorBatches = this.drawingVectorBatches;
14066
+ const batchUniformStore = this.device.type === "webgpu" && batches.length ? new import_core14.UniformStore(this.device, this.shaderInputs.modules) : void 0;
14067
+ if (batchUniformStore && this._uniformStore.uniformBuffers.size) {
14068
+ this.batchUniformBuffer ??= new BatchUniformBuffer(this.device);
14069
+ let batchByteLength = 0;
14070
+ for (const moduleName of this._uniformStore.uniformBuffers.keys()) {
14071
+ batchByteLength += this.batchUniformBuffer.getAlignedByteLength(
14072
+ batchUniformStore.getUniformBufferData(moduleName).byteLength
14073
+ );
14074
+ }
14075
+ this.batchUniformBuffer.prepare(batchByteLength * batches.length);
14076
+ }
13895
14077
  this.drawingVectorBatches = true;
13896
14078
  let drawSuccess = true;
13897
14079
  try {
@@ -13899,9 +14081,28 @@ ${getApplicationDefines(allDefines)}
13899
14081
  this.setGPUData(batch.data);
13900
14082
  this.setBatchDrawCount(batch.rowCount);
13901
14083
  onBatch?.(batch);
13902
- drawSuccess = _GPUVectorModel.prototype.draw.call(this, renderPass) && drawSuccess;
14084
+ const managedBindings = {};
14085
+ try {
14086
+ if (batchUniformStore) {
14087
+ batchUniformStore.setUniforms(this.shaderInputs.getUniformValues());
14088
+ for (const [moduleName, buffer] of this._uniformStore.uniformBuffers) {
14089
+ const bindingName = `${moduleName}Uniforms`;
14090
+ if (this.bindings[bindingName] !== buffer) continue;
14091
+ managedBindings[bindingName] = buffer;
14092
+ this.setBindings({
14093
+ [bindingName]: this.batchUniformBuffer.write(
14094
+ batchUniformStore.getUniformBufferData(moduleName)
14095
+ )
14096
+ });
14097
+ }
14098
+ }
14099
+ drawSuccess = _GPUVectorModel.prototype.draw.call(this, renderPass) && drawSuccess;
14100
+ } finally {
14101
+ this.setBindings(managedBindings);
14102
+ }
13903
14103
  }
13904
14104
  } finally {
14105
+ batchUniformStore?.destroy();
13905
14106
  this.setAttributes(previousAttributes, { byteOffsets: previousAttributeByteOffsets });
13906
14107
  for (const name of Object.keys(this.bindings)) {
13907
14108
  if (!(name in previousBindings)) delete this.bindings[name];
@@ -13923,7 +14124,7 @@ ${getApplicationDefines(allDefines)}
13923
14124
  Object.entries(data).map(([name, chunk]) => {
13924
14125
  const layout = this.bufferLayout.find((layout2) => layout2.name === name);
13925
14126
  const byteOffset = chunk.byteOffset - (layout?.attributes?.[0]?.byteOffset ?? 0);
13926
- (0, import_core13.assert)(byteOffset >= 0);
14127
+ (0, import_core14.assert)(byteOffset >= 0);
13927
14128
  return [name, byteOffset];
13928
14129
  })
13929
14130
  )
@@ -13984,10 +14185,12 @@ ${getApplicationDefines(allDefines)}
13984
14185
  this.bufferLayout = nextBufferLayout;
13985
14186
  this._setPipelineNeedsUpdate("bufferLayout");
13986
14187
  this.pipeline = this._updatePipeline();
14188
+ const previousVertexArray = this.vertexArray;
13987
14189
  this.vertexArray = this.device.createVertexArray({
13988
14190
  shaderLayout: this.pipeline.shaderLayout,
13989
14191
  bufferLayout: this.pipeline.bufferLayout
13990
14192
  });
14193
+ previousVertexArray.destroy();
13991
14194
  this._dynamicAttributeBufferSources = {};
13992
14195
  this.applyVectorAttributes();
13993
14196
  if (this.indexBuffer) this.vertexArray.setIndexBuffer(this.indexBuffer);
@@ -14043,7 +14246,7 @@ ${getApplicationDefines(allDefines)}
14043
14246
  /** Set the shader inputs */
14044
14247
  setShaderInputs(shaderInputs) {
14045
14248
  this.shaderInputs = shaderInputs;
14046
- this._uniformStore = new import_core13.UniformStore(this.device, this.shaderInputs.modules);
14249
+ this._uniformStore = new import_core14.UniformStore(this.device, this.shaderInputs.modules);
14047
14250
  for (const [moduleName, module] of Object.entries(this.shaderInputs.modules)) {
14048
14251
  if (shaderModuleHasUniforms(module) && this._usesManagedUniformBuffer(moduleName)) {
14049
14252
  const uniformBuffer = this._uniformStore.getManagedUniformBuffer(moduleName);
@@ -14114,7 +14317,7 @@ ${getApplicationDefines(allDefines)}
14114
14317
  this._drawBlockedReason = false;
14115
14318
  const disableWarnings = options?.disableWarnings ?? this.props.disableWarnings;
14116
14319
  if (buffers["indices"]) {
14117
- import_core13.log.warn(
14320
+ import_core14.log.warn(
14118
14321
  `Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`
14119
14322
  )();
14120
14323
  }
@@ -14128,7 +14331,7 @@ ${getApplicationDefines(allDefines)}
14128
14331
  const bufferLayout = bufferLayoutHelper.getBufferLayout(bufferName);
14129
14332
  if (!bufferLayout) {
14130
14333
  if (!disableWarnings) {
14131
- import_core13.log.warn(`Model(${this.id}): Missing layout for buffer "${bufferName}".`)();
14334
+ import_core14.log.warn(`Model(${this.id}): Missing layout for buffer "${bufferName}".`)();
14132
14335
  }
14133
14336
  continue;
14134
14337
  }
@@ -14140,7 +14343,7 @@ ${getApplicationDefines(allDefines)}
14140
14343
  const bufferSlot = this.device.type === "webgpu" ? this.vertexArray.getBufferSlot(attributeInfo.bufferName) : attributeInfo.location;
14141
14344
  if (bufferSlot === null) {
14142
14345
  if (!disableWarnings) {
14143
- import_core13.log.warn(
14346
+ import_core14.log.warn(
14144
14347
  `Model(${this.id}): Missing vertex array slot for buffer "${attributeInfo.bufferName}".`
14145
14348
  )();
14146
14349
  }
@@ -14161,7 +14364,7 @@ ${getApplicationDefines(allDefines)}
14161
14364
  }
14162
14365
  }
14163
14366
  if (!set2 && !disableWarnings) {
14164
- import_core13.log.warn(
14367
+ import_core14.log.warn(
14165
14368
  `Model(${this.id}): Ignoring buffer "${resolvedBuffer.id}" for unknown attribute "${bufferName}"`
14166
14369
  )();
14167
14370
  }
@@ -14182,7 +14385,7 @@ ${getApplicationDefines(allDefines)}
14182
14385
  if (attributeInfo) {
14183
14386
  this.vertexArray.setConstantWebGL(attributeInfo.location, value);
14184
14387
  } else if (!(options?.disableWarnings ?? this.props.disableWarnings)) {
14185
- import_core13.log.warn(
14388
+ import_core14.log.warn(
14186
14389
  `Model "${this.id}: Ignoring constant supplied for unknown attribute "${attributeName}"`
14187
14390
  )();
14188
14391
  }
@@ -14219,7 +14422,7 @@ ${getApplicationDefines(allDefines)}
14219
14422
  * @param bindings GPUVectorModel bindings already resolved for this draw preparation.
14220
14423
  */
14221
14424
  _getBindGroups(shaderLayout = this._getCurrentShaderLayout(), bindings = this._getBindings(shaderLayout)) {
14222
- return shaderLayout.bindings.length ? (0, import_core13.normalizeBindingsByGroup)(shaderLayout, bindings) : { 0: bindings };
14425
+ return shaderLayout.bindings.length ? (0, import_core14.normalizeBindingsByGroup)(shaderLayout, bindings) : { 0: bindings };
14223
14426
  }
14224
14427
  _getBindGroupCacheKeys() {
14225
14428
  return {};
@@ -14234,9 +14437,9 @@ ${getApplicationDefines(allDefines)}
14234
14437
  timestamp = Math.max(timestamp, entry.source.updateTimestamp);
14235
14438
  }
14236
14439
  for (const binding of Object.values(this.bindings)) {
14237
- if (binding instanceof import_core13.TextureView) {
14440
+ if (binding instanceof import_core14.TextureView) {
14238
14441
  timestamp = Math.max(timestamp, binding.texture.updateTimestamp);
14239
- } else if (binding instanceof import_core13.Buffer || binding instanceof import_core13.Texture || binding instanceof import_core13.ExternalTexture) {
14442
+ } else if (binding instanceof import_core14.Buffer || binding instanceof import_core14.Texture || binding instanceof import_core14.ExternalTexture) {
14240
14443
  timestamp = Math.max(timestamp, binding.updateTimestamp);
14241
14444
  } else if (binding instanceof DynamicBuffer) {
14242
14445
  timestamp = Math.max(timestamp, binding.updateTimestamp);
@@ -14264,7 +14467,13 @@ ${getApplicationDefines(allDefines)}
14264
14467
  _updatePipeline() {
14265
14468
  const update = this._preparePipelineUpdate();
14266
14469
  if (update) {
14267
- this.pipeline = this.pipelineFactory.createRenderPipeline(update.props);
14470
+ try {
14471
+ this.pipeline = this.pipelineFactory.createRenderPipeline(update.props);
14472
+ } catch (error) {
14473
+ this._releasePipelineShaders(update.vertexShader, update.fragmentShader);
14474
+ this._pipelineNeedsUpdate = "pipeline creation failed";
14475
+ throw error;
14476
+ }
14268
14477
  this._finishPipelineUpdate(update);
14269
14478
  }
14270
14479
  return this.pipeline;
@@ -14289,28 +14498,35 @@ ${getApplicationDefines(allDefines)}
14289
14498
  const previousVertexShader = this.pipeline?.vs ?? null;
14290
14499
  const previousFragmentShader = this.pipeline?.fs ?? null;
14291
14500
  if (this.pipeline) {
14292
- import_core13.log.log(
14501
+ import_core14.log.log(
14293
14502
  1,
14294
14503
  `GPUVectorModel ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`
14295
14504
  )();
14296
14505
  }
14297
14506
  this._pipelineNeedsUpdate = false;
14298
- const vertexShader = this.shaderFactory.createShader({
14299
- id: `${this.id}-vertex`,
14300
- stage: "vertex",
14301
- source: this.source || this.vs,
14302
- debugShaders: this.props.debugShaders
14303
- });
14507
+ let vertexShader = null;
14304
14508
  let fragmentShader = null;
14305
- if (this.source) {
14306
- fragmentShader = vertexShader;
14307
- } else if (this.fs) {
14308
- fragmentShader = this.shaderFactory.createShader({
14309
- id: `${this.id}-fragment`,
14310
- stage: "fragment",
14311
- source: this.fs,
14509
+ try {
14510
+ vertexShader = this.shaderFactory.createShader({
14511
+ id: `${this.id}-vertex`,
14512
+ stage: "vertex",
14513
+ source: this.source || this.vs,
14312
14514
  debugShaders: this.props.debugShaders
14313
14515
  });
14516
+ if (this.source) {
14517
+ fragmentShader = vertexShader;
14518
+ } else if (this.fs) {
14519
+ fragmentShader = this.shaderFactory.createShader({
14520
+ id: `${this.id}-fragment`,
14521
+ stage: "fragment",
14522
+ source: this.fs,
14523
+ debugShaders: this.props.debugShaders
14524
+ });
14525
+ }
14526
+ } catch (error) {
14527
+ this._releasePipelineShaders(vertexShader, fragmentShader);
14528
+ this._pipelineNeedsUpdate = "shader creation failed";
14529
+ throw error;
14314
14530
  }
14315
14531
  return {
14316
14532
  props: {
@@ -14332,7 +14548,7 @@ ${getApplicationDefines(allDefines)}
14332
14548
  };
14333
14549
  }
14334
14550
  _finishPipelineUpdate(update) {
14335
- this._attributeInfos = (0, import_core13.getAttributeInfosFromLayouts)(
14551
+ this._attributeInfos = (0, import_core14.getAttributeInfosFromLayouts)(
14336
14552
  this.pipeline.shaderLayout,
14337
14553
  this.bufferLayout
14338
14554
  );
@@ -14348,24 +14564,24 @@ ${getApplicationDefines(allDefines)}
14348
14564
  _lastLogTime = 0;
14349
14565
  _logOpen = false;
14350
14566
  _logDrawCallStart() {
14351
- const logDrawTimeout = import_core13.log.level > 3 ? 0 : LOG_DRAW_TIMEOUT;
14352
- if (import_core13.log.level < 2 || Date.now() - this._lastLogTime < logDrawTimeout) {
14567
+ const logDrawTimeout = import_core14.log.level > 3 ? 0 : LOG_DRAW_TIMEOUT;
14568
+ if (import_core14.log.level < 2 || Date.now() - this._lastLogTime < logDrawTimeout) {
14353
14569
  return;
14354
14570
  }
14355
14571
  this._lastLogTime = Date.now();
14356
14572
  this._logOpen = true;
14357
- import_core13.log.group(LOG_DRAW_PRIORITY, `>>> DRAWING MODEL ${this.id}`, { collapsed: import_core13.log.level <= 2 })();
14573
+ import_core14.log.group(LOG_DRAW_PRIORITY, `>>> DRAWING MODEL ${this.id}`, { collapsed: import_core14.log.level <= 2 })();
14358
14574
  }
14359
14575
  _logDrawCallEnd() {
14360
14576
  if (this._logOpen) {
14361
14577
  const shaderLayoutTable = getDebugTableForShaderLayout(this.pipeline.shaderLayout, this.id);
14362
- import_core13.log.table(LOG_DRAW_PRIORITY, shaderLayoutTable)();
14578
+ import_core14.log.table(LOG_DRAW_PRIORITY, shaderLayoutTable)();
14363
14579
  const uniformTable = this.shaderInputs.getDebugTable();
14364
- import_core13.log.table(LOG_DRAW_PRIORITY, uniformTable)();
14580
+ import_core14.log.table(LOG_DRAW_PRIORITY, uniformTable)();
14365
14581
  const attributeTable = this._getAttributeDebugTable();
14366
- import_core13.log.table(LOG_DRAW_PRIORITY, this._attributeInfos)();
14367
- import_core13.log.table(LOG_DRAW_PRIORITY, attributeTable)();
14368
- import_core13.log.groupEnd(LOG_DRAW_PRIORITY)();
14582
+ import_core14.log.table(LOG_DRAW_PRIORITY, this._attributeInfos)();
14583
+ import_core14.log.table(LOG_DRAW_PRIORITY, attributeTable)();
14584
+ import_core14.log.groupEnd(LOG_DRAW_PRIORITY)();
14369
14585
  this._logOpen = false;
14370
14586
  }
14371
14587
  }
@@ -14405,8 +14621,8 @@ ${getApplicationDefines(allDefines)}
14405
14621
  }
14406
14622
  // TODO - fix typing of luma data types
14407
14623
  _getBufferOrConstantValues(attribute, dataType) {
14408
- const TypedArrayConstructor = import_core13.dataTypeDecoder.getTypedArrayConstructor(dataType);
14409
- const typedArray = attribute instanceof import_core13.Buffer ? new TypedArrayConstructor(attribute.debugData) : attribute;
14624
+ const TypedArrayConstructor = import_core14.dataTypeDecoder.getTypedArrayConstructor(dataType);
14625
+ const typedArray = attribute instanceof import_core14.Buffer ? new TypedArrayConstructor(attribute.debugData) : attribute;
14410
14626
  return typedArray.toString();
14411
14627
  }
14412
14628
  /** Returns the current reflected shader layout or the pre-reflection empty layout. */
@@ -14490,7 +14706,7 @@ ${getApplicationDefines(allDefines)}
14490
14706
  }
14491
14707
 
14492
14708
  // src/geometry/gpu-geometry.ts
14493
- var import_core14 = __toESM(require_core(), 1);
14709
+ var import_core15 = __toESM(require_core(), 1);
14494
14710
  var GPUGeometry = class {
14495
14711
  /** Application-provided or generated identifier. */
14496
14712
  id;
@@ -14515,7 +14731,7 @@ ${getApplicationDefines(allDefines)}
14515
14731
  this.vertexCount = props.vertexCount;
14516
14732
  this.bufferLayout = props.bufferLayout || [];
14517
14733
  if (this.indices) {
14518
- if (!(this.indices.usage & import_core14.Buffer.INDEX)) {
14734
+ if (!(this.indices.usage & import_core15.Buffer.INDEX)) {
14519
14735
  throw new Error("Index buffer must have INDEX usage");
14520
14736
  }
14521
14737
  }
@@ -14564,7 +14780,7 @@ ${getApplicationDefines(allDefines)}
14564
14780
  return void 0;
14565
14781
  }
14566
14782
  const data = geometry.indices.value;
14567
- return device.createBuffer({ usage: import_core14.Buffer.INDEX, data });
14783
+ return device.createBuffer({ usage: import_core15.Buffer.INDEX, data });
14568
14784
  }
14569
14785
  function getAttributeBuffersFromGeometry(device, geometry) {
14570
14786
  const attributes = {};
@@ -14601,13 +14817,13 @@ ${getApplicationDefines(allDefines)}
14601
14817
  };
14602
14818
 
14603
14819
  // src/geometry/gpu-vector-geometry-adapter.ts
14604
- var import_core15 = __toESM(require_core(), 1);
14820
+ var import_core16 = __toESM(require_core(), 1);
14605
14821
  function makeGPUVectorGeometryFromGPUGeometry(geometry) {
14606
14822
  const attributes = {};
14607
14823
  for (const [name, buffer2] of Object.entries(geometry.attributes)) {
14608
14824
  const bufferLayout = geometry.bufferLayout.find((layout) => layout.name === name);
14609
14825
  const format = bufferLayout?.format;
14610
- const byteStride2 = bufferLayout?.byteStride ?? (format ? import_core15.vertexFormatDecoder.getVertexFormatInfo(format).byteLength : 0);
14826
+ const byteStride2 = bufferLayout?.byteStride ?? (format ? import_core16.vertexFormatDecoder.getVertexFormatInfo(format).byteLength : 0);
14611
14827
  const length5 = geometry.indices && byteStride2 ? Math.floor(buffer2.byteLength / byteStride2) : geometry.vertexCount;
14612
14828
  attributes[name] = {
14613
14829
  name,
@@ -14669,6 +14885,10 @@ ${getApplicationDefines(allDefines)}
14669
14885
  ...GPUVectorModel.defaultProps,
14670
14886
  material: void 0
14671
14887
  };
14888
+ /** Borrowed source geometry, retained for scene adapters such as physics cooking. */
14889
+ get sourceGeometry() {
14890
+ return this.sourceGeometryValue;
14891
+ }
14672
14892
  constructor(device, props) {
14673
14893
  const sourceGeometry = props.geometry === void 0 ? new.target.defaultProps.geometry : props.geometry;
14674
14894
  const gpuGeometry = sourceGeometry && !(sourceGeometry instanceof GPUVectorGeometry) ? makeGPUGeometry(device, sourceGeometry) : null;
@@ -14684,11 +14904,13 @@ ${getApplicationDefines(allDefines)}
14684
14904
  throw error;
14685
14905
  }
14686
14906
  this._gpuGeometry = gpuGeometry;
14907
+ this.sourceGeometryValue = sourceGeometry;
14687
14908
  if (gpuGeometry) this.setIndexCount(this.props.indexCount);
14688
14909
  }
14689
14910
  _initializeProps(props) {
14690
14911
  this.material = props.material || null;
14691
14912
  this._gpuGeometry = null;
14913
+ this.sourceGeometryValue = null;
14692
14914
  super._initializeProps(props);
14693
14915
  }
14694
14916
  _initializeAttributes() {
@@ -14699,6 +14921,7 @@ ${getApplicationDefines(allDefines)}
14699
14921
  super.destroy();
14700
14922
  this._gpuGeometry?.destroy();
14701
14923
  this._gpuGeometry = null;
14924
+ this.sourceGeometryValue = null;
14702
14925
  }
14703
14926
  /** Adapts CPU and legacy buffer geometry into the GPU vector geometry API. */
14704
14927
  setGeometry(geometry) {
@@ -14707,6 +14930,7 @@ ${getApplicationDefines(allDefines)}
14707
14930
  const vectorGeometry = this._gpuGeometry ? makeGPUVectorGeometryFromGPUGeometry(this._gpuGeometry) : geometry;
14708
14931
  super.setGeometry(vectorGeometry instanceof GPUVectorGeometry ? vectorGeometry : null);
14709
14932
  if (!(geometry instanceof GPUVectorGeometry)) super.setIndexCount(this.indexCountOverride);
14933
+ this.sourceGeometryValue = geometry;
14710
14934
  }
14711
14935
  setIndexCount(indexCount) {
14712
14936
  this.indexCountOverride = indexCount;
@@ -14762,7 +14986,7 @@ ${getApplicationDefines(allDefines)}
14762
14986
  };
14763
14987
 
14764
14988
  // src/material/material.ts
14765
- var import_core16 = __toESM(require_core(), 1);
14989
+ var import_core17 = __toESM(require_core(), 1);
14766
14990
 
14767
14991
  // src/material/material-factory.ts
14768
14992
  var MATERIAL_BIND_GROUP = 3;
@@ -14864,7 +15088,7 @@ ${getApplicationDefines(allDefines)}
14864
15088
  ])
14865
15089
  );
14866
15090
  this.shaderInputs = props.shaderInputs || new ShaderInputs(moduleMap);
14867
- this._uniformStore = new import_core16.UniformStore(this.device, this.shaderInputs.modules);
15091
+ this._uniformStore = new import_core17.UniformStore(this.device, this.shaderInputs.modules);
14868
15092
  for (const [moduleName, module] of Object.entries(this.shaderInputs.modules)) {
14869
15093
  if (this.ownsModule(moduleName) && shaderModuleHasUniforms(module)) {
14870
15094
  const uniformBuffer = this._uniformStore.getManagedUniformBuffer(moduleName);
@@ -14978,9 +15202,9 @@ ${getApplicationDefines(allDefines)}
14978
15202
  getBindingsUpdateTimestamp() {
14979
15203
  let timestamp = 0;
14980
15204
  for (const binding of Object.values(this.bindings)) {
14981
- if (binding instanceof import_core16.TextureView) {
15205
+ if (binding instanceof import_core17.TextureView) {
14982
15206
  timestamp = Math.max(timestamp, binding.texture.updateTimestamp);
14983
- } else if (binding instanceof import_core16.Buffer || binding instanceof import_core16.Texture || binding instanceof import_core16.ExternalTexture) {
15207
+ } else if (binding instanceof import_core17.Buffer || binding instanceof import_core17.Texture || binding instanceof import_core17.ExternalTexture) {
14984
15208
  timestamp = Math.max(timestamp, binding.updateTimestamp);
14985
15209
  } else if (binding instanceof DynamicBuffer) {
14986
15210
  timestamp = Math.max(timestamp, binding.updateTimestamp);
@@ -15048,7 +15272,7 @@ ${getApplicationDefines(allDefines)}
15048
15272
  }
15049
15273
 
15050
15274
  // src/compute/buffer-transform.ts
15051
- var import_core17 = __toESM(require_core(), 1);
15275
+ var import_core18 = __toESM(require_core(), 1);
15052
15276
  var import_shaders4 = __toESM(require_shaders(), 1);
15053
15277
  var GL_INTERLEAVED_ATTRIBS = 35980;
15054
15278
  var GL_SEPARATE_ATTRIBS = 35981;
@@ -15122,14 +15346,14 @@ ${getApplicationDefines(allDefines)}
15122
15346
  /** Binds borrowed output ranges without taking ownership or repacking vector chunks. */
15123
15347
  setOutputVectors(vectors) {
15124
15348
  const batches = getGPUVectorModelBatches(this.model.id, vectors);
15125
- (0, import_core17.assert)(batches.length === 0 || this.model.pipeline.props.bufferMode !== GL_INTERLEAVED_ATTRIBS);
15126
- (0, import_core17.assert)(batches.length <= 1);
15349
+ (0, import_core18.assert)(batches.length === 0 || this.model.pipeline.props.bufferMode !== GL_INTERLEAVED_ATTRIBS);
15350
+ (0, import_core18.assert)(batches.length <= 1);
15127
15351
  this.outputVectorBindings = vectors;
15128
15352
  this.transformFeedback.setBuffers({
15129
15353
  ...this.outputBuffers,
15130
15354
  ...Object.fromEntries(
15131
15355
  Object.entries(batches[0]?.data ?? {}).map(([name, data]) => {
15132
- (0, import_core17.assert)(data.byteStride === data.rowByteLength);
15356
+ (0, import_core18.assert)(data.byteStride === data.rowByteLength);
15133
15357
  return [
15134
15358
  name,
15135
15359
  {
@@ -15153,7 +15377,7 @@ ${getApplicationDefines(allDefines)}
15153
15377
  if (!result) {
15154
15378
  throw new Error("BufferTransform#getBuffer");
15155
15379
  }
15156
- if (result instanceof import_core17.Buffer) {
15380
+ if (result instanceof import_core18.Buffer) {
15157
15381
  return result.readAsync();
15158
15382
  }
15159
15383
  const { buffer, byteOffset = 0, byteLength = buffer.byteLength } = result;
@@ -16102,7 +16326,7 @@ void main(void) {
16102
16326
  };
16103
16327
 
16104
16328
  // src/scenegraph/scenegraph-node.ts
16105
- function assert9(condition, message) {
16329
+ function assert10(condition, message) {
16106
16330
  if (!condition) {
16107
16331
  throw new Error(message);
16108
16332
  }
@@ -16138,17 +16362,17 @@ void main(void) {
16138
16362
  return `{type: ScenegraphNode, id: ${this.id})}`;
16139
16363
  }
16140
16364
  setPosition(position) {
16141
- assert9(position.length === 3, "setPosition requires vector argument");
16365
+ assert10(position.length === 3, "setPosition requires vector argument");
16142
16366
  this.position = position;
16143
16367
  return this;
16144
16368
  }
16145
16369
  setRotation(rotation) {
16146
- assert9(rotation.length === 3 || rotation.length === 4, "setRotation requires vector argument");
16370
+ assert10(rotation.length === 3 || rotation.length === 4, "setRotation requires vector argument");
16147
16371
  this.rotation = rotation;
16148
16372
  return this;
16149
16373
  }
16150
16374
  setScale(scale5) {
16151
- assert9(scale5.length === 3, "setScale requires vector argument");
16375
+ assert10(scale5.length === 3, "setScale requires vector argument");
16152
16376
  this.scale = scale5;
16153
16377
  return this;
16154
16378
  }
@@ -16258,7 +16482,7 @@ void main(void) {
16258
16482
  };
16259
16483
 
16260
16484
  // src/scenegraph/group-node.ts
16261
- var import_core22 = __toESM(require_core(), 1);
16485
+ var import_core23 = __toESM(require_core(), 1);
16262
16486
 
16263
16487
  // src/scenegraph/scenegraph-bounds.ts
16264
16488
  function makeEmptyScenegraphBounds() {
@@ -16295,15 +16519,18 @@ void main(void) {
16295
16519
  // src/scenegraph/group-node.ts
16296
16520
  var GroupNode = class _GroupNode extends ScenegraphNode {
16297
16521
  children;
16522
+ /** Optional evaluated GPU poses; authored matrices remain unchanged. */
16523
+ transformSource;
16298
16524
  constructor(props = {}) {
16299
16525
  props = Array.isArray(props) ? { children: props } : props;
16300
16526
  const { children = [] } = props;
16301
- import_core22.log.assert(
16527
+ import_core23.log.assert(
16302
16528
  children.every((child) => child instanceof ScenegraphNode),
16303
16529
  "every child must an instance of ScenegraphNode"
16304
16530
  );
16305
16531
  super(props);
16306
16532
  this.children = children;
16533
+ this.transformSource = props.transformSource ?? null;
16307
16534
  }
16308
16535
  getBounds() {
16309
16536
  const result = makeEmptyScenegraphBounds();
@@ -16345,6 +16572,45 @@ void main(void) {
16345
16572
  this.children = [];
16346
16573
  return this;
16347
16574
  }
16575
+ /** Resolve one exact ID or path. Missing nodes return undefined; ambiguous paths throw. */
16576
+ findNode(path) {
16577
+ const matches = this.findNodes(path);
16578
+ if (matches.length > 1) {
16579
+ throw new Error(`Ambiguous scenegraph path: ${path} (${matches.length} matches)`);
16580
+ }
16581
+ return matches[0];
16582
+ }
16583
+ /** Find structural matches in preorder, including hidden nodes and the search root. */
16584
+ findNodes(path) {
16585
+ const anchored = path.startsWith("/");
16586
+ const segments = path === "/" ? [] : (anchored ? path.slice(1) : path).split("/").map((segment) => {
16587
+ if (!segment || /~(?![01])/.test(segment)) {
16588
+ throw new Error(`Invalid scenegraph path: ${path}`);
16589
+ }
16590
+ return segment.replace(/~1/g, "/").replace(/~0/g, "~");
16591
+ });
16592
+ const matches = [];
16593
+ const ancestors = [];
16594
+ const visited = /* @__PURE__ */ new Set();
16595
+ const pending = [{ node: this, depth: 0 }];
16596
+ while (pending.length) {
16597
+ const { node, depth } = pending.pop();
16598
+ (0, import_core23.assert)(!visited.has(node));
16599
+ visited.add(node);
16600
+ ancestors.length = depth;
16601
+ ancestors.push(node.id);
16602
+ const offset = ancestors.length - segments.length;
16603
+ if ((anchored ? offset === 1 : offset >= 0) && segments.every((segment, index) => segment === ancestors[offset + index])) {
16604
+ matches.push(node);
16605
+ }
16606
+ if (node instanceof _GroupNode) {
16607
+ for (let index = node.children.length - 1; index >= 0; index--) {
16608
+ pending.push({ node: node.children[index], depth: depth + 1 });
16609
+ }
16610
+ }
16611
+ }
16612
+ return matches;
16613
+ }
16348
16614
  traverse(visitor, { worldMatrix = new Matrix4() } = {}) {
16349
16615
  if (!this.display) {
16350
16616
  return;
@@ -16401,6 +16667,27 @@ void main(void) {
16401
16667
  }
16402
16668
  };
16403
16669
 
16670
+ // src/scenegraph/geometry-node.ts
16671
+ var GeometryNode = class extends ScenegraphNode {
16672
+ geometry;
16673
+ constructor(props) {
16674
+ super(props);
16675
+ this.geometry = props.geometry;
16676
+ }
16677
+ getBounds() {
16678
+ const positions = this.geometry.attributes["POSITION"];
16679
+ if (!positions || positions.size !== 3 || !positions.value.length) return null;
16680
+ const minimum = [Infinity, Infinity, Infinity];
16681
+ const maximum = [-Infinity, -Infinity, -Infinity];
16682
+ for (let index = 0; index < positions.value.length; index++) {
16683
+ const axis = index % 3;
16684
+ minimum[axis] = Math.min(minimum[axis], positions.value[index]);
16685
+ maximum[axis] = Math.max(maximum[axis], positions.value[index]);
16686
+ }
16687
+ return [minimum, maximum];
16688
+ }
16689
+ };
16690
+
16404
16691
  // src/scenegraph/model-node.ts
16405
16692
  var ModelNode = class extends ScenegraphNode {
16406
16693
  model;
@@ -16444,12 +16731,12 @@ void main(void) {
16444
16731
  }
16445
16732
 
16446
16733
  // src/geometry/edge-geometry.ts
16447
- var import_core23 = __toESM(require_core(), 1);
16734
+ var import_core24 = __toESM(require_core(), 1);
16448
16735
  function makeEdgeGeometry(geometry, options = {}) {
16449
16736
  const { angleThreshold = 30, weldTolerance = 0, positionAttribute = "POSITION" } = options;
16450
16737
  const positions = getTrianglePositions(geometry, positionAttribute);
16451
- (0, import_core23.assert)(Number.isFinite(weldTolerance) && weldTolerance >= 0);
16452
- (0, import_core23.assert)(Number.isFinite(angleThreshold) && angleThreshold >= 0 && angleThreshold <= 180);
16738
+ (0, import_core24.assert)(Number.isFinite(weldTolerance) && weldTolerance >= 0);
16739
+ (0, import_core24.assert)(Number.isFinite(angleThreshold) && angleThreshold >= 0 && angleThreshold <= 180);
16453
16740
  const sourceIndices = geometry.indices?.value;
16454
16741
  const sourceCount = positions.value.length / 3;
16455
16742
  const representatives = /* @__PURE__ */ new Map();
@@ -16468,9 +16755,9 @@ void main(void) {
16468
16755
  function weldPosition(index) {
16469
16756
  const cached = representatives.get(index);
16470
16757
  if (cached !== void 0) return cached;
16471
- (0, import_core23.assert)(Number.isInteger(index) && index >= 0 && index < sourceCount);
16758
+ (0, import_core24.assert)(Number.isInteger(index) && index >= 0 && index < sourceCount);
16472
16759
  const position = readPosition(index);
16473
- (0, import_core23.assert)(position.every(Number.isFinite));
16760
+ (0, import_core24.assert)(position.every(Number.isFinite));
16474
16761
  const cell = weldTolerance > 0 ? position.map((value) => Math.floor(value / weldTolerance)) : position;
16475
16762
  const radius = weldTolerance > 0 ? 1 : 0;
16476
16763
  for (let east = -radius; east <= radius; east++) {
@@ -16544,11 +16831,11 @@ void main(void) {
16544
16831
  });
16545
16832
  }
16546
16833
  function makeEdgeGeometryFromGeometries(geometries, options = {}) {
16547
- (0, import_core23.assert)(geometries.length > 0);
16834
+ (0, import_core24.assert)(geometries.length > 0);
16548
16835
  const positionAttribute = options.positionAttribute ?? "POSITION";
16549
16836
  const attributes = geometries.map((geometry) => getTrianglePositions(geometry, positionAttribute));
16550
16837
  const firstAttribute = attributes[0];
16551
- (0, import_core23.assert)(
16838
+ (0, import_core24.assert)(
16552
16839
  attributes.every(
16553
16840
  (attribute) => attribute.value.constructor === firstAttribute.value.constructor && Boolean(attribute["normalized"]) === Boolean(firstAttribute["normalized"])
16554
16841
  )
@@ -16567,7 +16854,7 @@ void main(void) {
16567
16854
  positions.set(attribute.value, positionOffset);
16568
16855
  for (let offset = 0; offset < geometry.vertexCount; offset++) {
16569
16856
  const index = geometry.indices?.value[offset] ?? offset;
16570
- (0, import_core23.assert)(Number.isInteger(index) && index >= 0 && index < attribute.value.length / 3);
16857
+ (0, import_core24.assert)(Number.isInteger(index) && index >= 0 && index < attribute.value.length / 3);
16571
16858
  indices[indexOffset++] = index + positionOffset / 3;
16572
16859
  }
16573
16860
  positionOffset += attribute.value.length;
@@ -16584,26 +16871,26 @@ void main(void) {
16584
16871
  }
16585
16872
  function getTrianglePositions(geometry, positionAttribute) {
16586
16873
  const positions = geometry.attributes[positionAttribute];
16587
- (0, import_core23.assert)(geometry.topology === "triangle-list" && positions?.size === 3);
16588
- (0, import_core23.assert)(positions.value.length % 3 === 0 && geometry.vertexCount % 3 === 0);
16589
- (0, import_core23.assert)(
16874
+ (0, import_core24.assert)(geometry.topology === "triangle-list" && positions?.size === 3);
16875
+ (0, import_core24.assert)(positions.value.length % 3 === 0 && geometry.vertexCount % 3 === 0);
16876
+ (0, import_core24.assert)(
16590
16877
  !positions["byteStride"] || positions["byteStride"] === positions.value.BYTES_PER_ELEMENT * 3
16591
16878
  );
16592
- (0, import_core23.assert)(
16879
+ (0, import_core24.assert)(
16593
16880
  geometry.vertexCount >= 0 && geometry.vertexCount <= (geometry.indices?.value.length ?? positions.value.length / 3)
16594
16881
  );
16595
16882
  return positions;
16596
16883
  }
16597
16884
 
16598
16885
  // src/geometry/stroke-geometry.ts
16599
- var import_core24 = __toESM(require_core(), 1);
16886
+ var import_core25 = __toESM(require_core(), 1);
16600
16887
  function makeStrokeGeometry(path, options = {}) {
16601
16888
  const { width = 1, cap = "butt", join = "miter", miterLimit = 4, roundSegments = 16 } = options;
16602
- (0, import_core24.assert)(Number.isFinite(width) && width >= 0 && Number.isFinite(miterLimit) && miterLimit >= 1);
16603
- (0, import_core24.assert)(Number.isInteger(roundSegments) && roundSegments >= 2 && roundSegments <= 256);
16889
+ (0, import_core25.assert)(Number.isFinite(width) && width >= 0 && Number.isFinite(miterLimit) && miterLimit >= 1);
16890
+ (0, import_core25.assert)(Number.isInteger(roundSegments) && roundSegments >= 2 && roundSegments <= 256);
16604
16891
  const points = [];
16605
16892
  for (const position of path) {
16606
- (0, import_core24.assert)(
16893
+ (0, import_core25.assert)(
16607
16894
  Number.isFinite(position[0]) && Number.isFinite(position[1]) && Number.isFinite(position[2] ?? 0)
16608
16895
  );
16609
16896
  const previous = points.at(-1);
@@ -16763,12 +17050,12 @@ void main(void) {
16763
17050
  }
16764
17051
 
16765
17052
  // src/geometry/mesh-simplification.ts
16766
- var import_core25 = __toESM(require_core(), 1);
17053
+ var import_core26 = __toESM(require_core(), 1);
16767
17054
  var QUADRIC_COMPONENTS = 10;
16768
17055
  var BOUNDARY_COLLINEAR_TOLERANCE = 1e-10;
16769
17056
  function simplifyMesh(options) {
16770
17057
  const { positions, indices, attributes = [], preserveBoundary = true } = options;
16771
- (0, import_core25.assert)(indices.length % 3 === 0 && positions.length % 3 === 0);
17058
+ (0, import_core26.assert)(indices.length % 3 === 0 && positions.length % 3 === 0);
16772
17059
  const targetIndexCount = Math.max(
16773
17060
  0,
16774
17061
  Math.min(
@@ -16861,7 +17148,7 @@ void main(void) {
16861
17148
  const firstVertex = indices[indexOffset2];
16862
17149
  const secondVertex = indices[indexOffset2 + 1];
16863
17150
  const thirdVertex = indices[indexOffset2 + 2];
16864
- (0, import_core25.assert)(firstVertex < vertexCount && secondVertex < vertexCount && thirdVertex < vertexCount);
17151
+ (0, import_core26.assert)(firstVertex < vertexCount && secondVertex < vertexCount && thirdVertex < vertexCount);
16865
17152
  const triangle = {
16866
17153
  vertices: [firstVertex, secondVertex, thirdVertex],
16867
17154
  active: false
@@ -17196,7 +17483,7 @@ void main(void) {
17196
17483
  }
17197
17484
 
17198
17485
  // src/dynamic-texture/video-texture.ts
17199
- var import_core26 = __toESM(require_core(), 1);
17486
+ var import_core27 = __toESM(require_core(), 1);
17200
17487
  var VideoTexture = class {
17201
17488
  /** Device used to create copied and native external texture bindings. */
17202
17489
  device;
@@ -17245,7 +17532,7 @@ void main(void) {
17245
17532
  * @param props Live video source and copied texture options.
17246
17533
  */
17247
17534
  constructor(device, props) {
17248
- (0, import_core26.assert)(isHTMLVideoElementSource(props?.source) || isVideoFrameSource(props?.source));
17535
+ (0, import_core27.assert)(isHTMLVideoElementSource(props?.source) || isVideoFrameSource(props?.source));
17249
17536
  this.device = device;
17250
17537
  this.id = props.id || uid("video-texture");
17251
17538
  this._source = props.source;
@@ -17259,7 +17546,7 @@ void main(void) {
17259
17546
  * @param source Next caller-owned video source to follow.
17260
17547
  */
17261
17548
  setSource(source4) {
17262
- (0, import_core26.assert)(isHTMLVideoElementSource(source4) || isVideoFrameSource(source4));
17549
+ (0, import_core27.assert)(isHTMLVideoElementSource(source4) || isVideoFrameSource(source4));
17263
17550
  this._destroyExternalTexture();
17264
17551
  this._source = source4;
17265
17552
  this._sourceVersion++;
@@ -17337,7 +17624,7 @@ void main(void) {
17337
17624
  width: size.width,
17338
17625
  height: size.height,
17339
17626
  format: "rgba8unorm",
17340
- usage: import_core26.Texture.SAMPLE | import_core26.Texture.COPY_DST,
17627
+ usage: import_core27.Texture.SAMPLE | import_core27.Texture.COPY_DST,
17341
17628
  mipLevels: 1,
17342
17629
  sampler: this._sampler
17343
17630
  });
@@ -17372,7 +17659,7 @@ void main(void) {
17372
17659
  */
17373
17660
  _getResolvedSize() {
17374
17661
  const size = getVideoTextureSourceSize(this._source);
17375
- (0, import_core26.assert)(size.width > 0 && size.height > 0);
17662
+ (0, import_core27.assert)(size.width > 0 && size.height > 0);
17376
17663
  return size;
17377
17664
  }
17378
17665
  /** Observes current source readiness and frame identity before binding resolution. */
@@ -17437,11 +17724,11 @@ void main(void) {
17437
17724
  }
17438
17725
 
17439
17726
  // src/passes/shader-pass-renderer.ts
17440
- var import_core29 = __toESM(require_core(), 1);
17727
+ var import_core30 = __toESM(require_core(), 1);
17441
17728
  var import_shaders7 = __toESM(require_shaders(), 1);
17442
17729
 
17443
17730
  // src/compute/swap.ts
17444
- var import_core27 = __toESM(require_core(), 1);
17731
+ var import_core28 = __toESM(require_core(), 1);
17445
17732
  var Swap = class {
17446
17733
  id;
17447
17734
  /** The current resource - usually the source for renders or computations */
@@ -17473,7 +17760,7 @@ void main(void) {
17473
17760
  (colorAttachment) => typeof colorAttachment !== "string" ? colorAttachment : device.createTexture({
17474
17761
  id: `${props.id}-texture-0`,
17475
17762
  format: colorAttachment,
17476
- usage: import_core27.Texture.SAMPLE | import_core27.Texture.RENDER | import_core27.Texture.COPY_SRC | import_core27.Texture.COPY_DST,
17763
+ usage: import_core28.Texture.SAMPLE | import_core28.Texture.RENDER | import_core28.Texture.COPY_SRC | import_core28.Texture.COPY_DST,
17477
17764
  width,
17478
17765
  height
17479
17766
  })
@@ -17483,7 +17770,7 @@ void main(void) {
17483
17770
  (colorAttachment) => typeof colorAttachment !== "string" ? colorAttachment : device.createTexture({
17484
17771
  id: `${props.id}-texture-1`,
17485
17772
  format: colorAttachment,
17486
- usage: import_core27.Texture.SAMPLE | import_core27.Texture.RENDER | import_core27.Texture.COPY_SRC | import_core27.Texture.COPY_DST,
17773
+ usage: import_core28.Texture.SAMPLE | import_core28.Texture.RENDER | import_core28.Texture.COPY_SRC | import_core28.Texture.COPY_DST,
17487
17774
  width,
17488
17775
  height
17489
17776
  })
@@ -17547,7 +17834,7 @@ void main(void) {
17547
17834
  };
17548
17835
 
17549
17836
  // src/compute/computation.ts
17550
- var import_core28 = __toESM(require_core(), 1);
17837
+ var import_core29 = __toESM(require_core(), 1);
17551
17838
  var import_shaders6 = __toESM(require_shaders(), 1);
17552
17839
  var LOG_DRAW_PRIORITY2 = 2;
17553
17840
  var LOG_DRAW_TIMEOUT2 = 1e4;
@@ -17559,13 +17846,13 @@ void main(void) {
17559
17846
  * constructor remains the synchronous compatibility path.
17560
17847
  */
17561
17848
  static async createAsync(device, props) {
17562
- const ownsCompilation = !import_core28.PipelineFactory.getAsyncCompilation(device);
17563
- const asyncCompilation = ownsCompilation ? import_core28.PipelineFactory.beginAsyncCompilation(device) : import_core28.PipelineFactory.getAsyncCompilation(device);
17849
+ const ownsCompilation = !import_core29.PipelineFactory.getAsyncCompilation(device);
17850
+ const asyncCompilation = ownsCompilation ? import_core29.PipelineFactory.beginAsyncCompilation(device) : import_core29.PipelineFactory.getAsyncCompilation(device);
17564
17851
  let computation;
17565
17852
  try {
17566
17853
  computation = new _Computation(device, props);
17567
17854
  } finally {
17568
- if (ownsCompilation) import_core28.PipelineFactory.endAsyncCompilation(device, asyncCompilation);
17855
+ if (ownsCompilation) import_core29.PipelineFactory.endAsyncCompilation(device, asyncCompilation);
17569
17856
  }
17570
17857
  try {
17571
17858
  if (ownsCompilation) {
@@ -17580,7 +17867,7 @@ void main(void) {
17580
17867
  }
17581
17868
  }
17582
17869
  static defaultProps = {
17583
- ...import_core28.ComputePipeline.defaultProps,
17870
+ ...import_core29.ComputePipeline.defaultProps,
17584
17871
  id: "unnamed",
17585
17872
  handle: void 0,
17586
17873
  userData: {},
@@ -17634,8 +17921,13 @@ void main(void) {
17634
17921
  Object.assign(this.userData, props.userData);
17635
17922
  const platformInfo = getPlatformInfo(device);
17636
17923
  const resolvedPlugins = (0, import_shaders6.resolveShaderPlugins)(this.props.plugins, platformInfo.shaderLanguage);
17637
- if (Object.keys(resolvedPlugins.vertexInputs).length > 0 || Object.keys(resolvedPlugins.varyings).length > 0) {
17638
- throw new Error("Computation does not support ShaderPlugin vertex inputs or varyings");
17924
+ if (resolvedPlugins.hooks.length > 0) {
17925
+ throw new Error("Computation does not support ShaderPlugin render hooks");
17926
+ }
17927
+ if (Object.keys(resolvedPlugins.vertexInputs).length > 0 || Object.keys(resolvedPlugins.interStageVariables).length > 0) {
17928
+ throw new Error(
17929
+ "Computation does not support ShaderPlugin vertex inputs or interStageVariables"
17930
+ );
17639
17931
  }
17640
17932
  const shaderInputModules = (0, import_shaders6.mergeShaderPluginModules)(
17641
17933
  this.props.modules,
@@ -17650,10 +17942,10 @@ void main(void) {
17650
17942
  const modules = mergeShaderModules(this.props.modules, this.shaderInputs?.getModules());
17651
17943
  const defines = { ...resolvedPlugins.defines, ...this.props.defines };
17652
17944
  this.props.shaderLayout = mergeShaderModuleBindingsIntoLayout(this.props.shaderLayout, modules) || null;
17653
- this.pipelineFactory = props.pipelineFactory || import_core28.PipelineFactory.getDefaultPipelineFactory(this.device);
17654
- this.shaderFactory = props.shaderFactory || import_core28.ShaderFactory.getDefaultShaderFactory(this.device);
17945
+ this.pipelineFactory = props.pipelineFactory || import_core29.PipelineFactory.getDefaultPipelineFactory(this.device);
17946
+ this.shaderFactory = props.shaderFactory || import_core29.ShaderFactory.getDefaultShaderFactory(this.device);
17655
17947
  const shaderAssembler = this.props.shaderAssembler;
17656
- (0, import_core28.assert)(shaderAssembler instanceof WGSLShaderAssembler);
17948
+ (0, import_core29.assert)(shaderAssembler instanceof WGSLShaderAssembler);
17657
17949
  const {
17658
17950
  source: source4,
17659
17951
  getUniforms: getUniforms2,
@@ -17677,7 +17969,7 @@ void main(void) {
17677
17969
  this.props.shaderLayout || inferredShaderLayout || null,
17678
17970
  modules
17679
17971
  ) || null;
17680
- const asyncCompilation = import_core28.PipelineFactory.getAsyncCompilation(this.device);
17972
+ const asyncCompilation = import_core29.PipelineFactory.getAsyncCompilation(this.device);
17681
17973
  if (asyncCompilation) {
17682
17974
  this._pipelineInitialization = this._updatePipelineAsync();
17683
17975
  asyncCompilation.push(this._pipelineInitialization);
@@ -17744,7 +18036,7 @@ void main(void) {
17744
18036
  }
17745
18037
  setShaderInputs(shaderInputs) {
17746
18038
  this.shaderInputs = shaderInputs;
17747
- this._uniformStore = new import_core28.UniformStore(this.device, this.shaderInputs.modules);
18039
+ this._uniformStore = new import_core29.UniformStore(this.device, this.shaderInputs.modules);
17748
18040
  for (const [moduleName, module] of Object.entries(this.shaderInputs.modules)) {
17749
18041
  if (shaderModuleHasUniforms(module)) {
17750
18042
  const uniformBuffer = this._uniformStore.getManagedUniformBuffer(moduleName);
@@ -17813,7 +18105,7 @@ void main(void) {
17813
18105
  if (!this._pipelineNeedsUpdate) return null;
17814
18106
  const previousShader = this.pipeline ? this.shader : null;
17815
18107
  if (this.pipeline) {
17816
- import_core28.log.log(1, `Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)();
18108
+ import_core29.log.log(1, `Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)();
17817
18109
  }
17818
18110
  this._pipelineNeedsUpdate = false;
17819
18111
  this.shader = this.shaderFactory.createShader({
@@ -17831,27 +18123,27 @@ void main(void) {
17831
18123
  _lastLogTime = 0;
17832
18124
  _logOpen = false;
17833
18125
  _logDrawCallStart() {
17834
- const logDrawTimeout = import_core28.log.level > 3 ? 0 : LOG_DRAW_TIMEOUT2;
17835
- if (import_core28.log.level < 2 || Date.now() - this._lastLogTime < logDrawTimeout) {
18126
+ const logDrawTimeout = import_core29.log.level > 3 ? 0 : LOG_DRAW_TIMEOUT2;
18127
+ if (import_core29.log.level < 2 || Date.now() - this._lastLogTime < logDrawTimeout) {
17836
18128
  return;
17837
18129
  }
17838
18130
  this._lastLogTime = Date.now();
17839
18131
  this._logOpen = true;
17840
- import_core28.log.group(LOG_DRAW_PRIORITY2, `>>> DRAWING MODEL ${this.id}`, { collapsed: import_core28.log.level <= 2 })();
18132
+ import_core29.log.group(LOG_DRAW_PRIORITY2, `>>> DRAWING MODEL ${this.id}`, { collapsed: import_core29.log.level <= 2 })();
17841
18133
  }
17842
18134
  _logDrawCallEnd() {
17843
18135
  if (this._logOpen) {
17844
18136
  const uniformTable = this.shaderInputs.getDebugTable();
17845
- import_core28.log.table(LOG_DRAW_PRIORITY2, uniformTable)();
17846
- import_core28.log.groupEnd(LOG_DRAW_PRIORITY2)();
18137
+ import_core29.log.table(LOG_DRAW_PRIORITY2, uniformTable)();
18138
+ import_core29.log.groupEnd(LOG_DRAW_PRIORITY2)();
17847
18139
  this._logOpen = false;
17848
18140
  }
17849
18141
  }
17850
18142
  _drawCount = 0;
17851
18143
  // TODO - fix typing of luma data types
17852
18144
  _getBufferOrConstantValues(attribute, dataType) {
17853
- const TypedArrayConstructor = import_core28.dataTypeDecoder.getTypedArrayConstructor(dataType);
17854
- const typedArray = attribute instanceof import_core28.Buffer ? new TypedArrayConstructor(attribute.debugData) : attribute;
18145
+ const TypedArrayConstructor = import_core29.dataTypeDecoder.getTypedArrayConstructor(dataType);
18146
+ const typedArray = attribute instanceof import_core29.Buffer ? new TypedArrayConstructor(attribute.debugData) : attribute;
17855
18147
  return typedArray.toString();
17856
18148
  }
17857
18149
  };
@@ -18408,7 +18700,7 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
18408
18700
  this.parameterBuffer = device.createBuffer({
18409
18701
  id: `${optimization.name}-parameters`,
18410
18702
  byteLength: Math.max(Math.ceil(optimization.uniformNames.length / 4) * 16, 16),
18411
- usage: import_core29.Buffer.UNIFORM | import_core29.Buffer.COPY_DST
18703
+ usage: import_core30.Buffer.UNIFORM | import_core30.Buffer.COPY_DST
18412
18704
  });
18413
18705
  const outputBindings = Object.entries(optimization.outputs).map(
18414
18706
  ([bindingName, targetName], outputIndex) => ({
@@ -18693,7 +18985,7 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
18693
18985
  width: targetSize[0],
18694
18986
  height: targetSize[1],
18695
18987
  format: spec.format || device.preferredColorFormat,
18696
- usage: import_core29.Texture.SAMPLE | import_core29.Texture.RENDER | import_core29.Texture.COPY_SRC | import_core29.Texture.COPY_DST | (spec.storage && device.type === "webgpu" && device.getTextureFormatCapabilities(spec.format || device.preferredColorFormat).store ? import_core29.Texture.STORAGE : 0),
18988
+ usage: import_core30.Texture.SAMPLE | import_core30.Texture.RENDER | import_core30.Texture.COPY_SRC | import_core30.Texture.COPY_DST | (spec.storage && device.type === "webgpu" && device.getTextureFormatCapabilities(spec.format || device.preferredColorFormat).store ? import_core30.Texture.STORAGE : 0),
18697
18989
  ...spec.sampler ? { sampler: spec.sampler } : {}
18698
18990
  });
18699
18991
  const framebuffer = device.createFramebuffer({
@@ -18748,7 +19040,7 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
18748
19040
  }
18749
19041
 
18750
19042
  // src/modules/picking/picking-manager.ts
18751
- var import_core30 = __toESM(require_core(), 1);
19043
+ var import_core31 = __toESM(require_core(), 1);
18752
19044
 
18753
19045
  // src/modules/picking/picking-uniforms.ts
18754
19046
  var DEFAULT_HIGHLIGHT_COLOR = [0, 1, 1, 1];
@@ -19012,13 +19304,13 @@ layout(std140) uniform pickingUniforms {
19012
19304
  format: "rgba8unorm",
19013
19305
  width: 1,
19014
19306
  height: 1,
19015
- usage: import_core30.Texture.RENDER_ATTACHMENT
19307
+ usage: import_core31.Texture.RENDER_ATTACHMENT
19016
19308
  });
19017
19309
  const pickingTexture = this.device.createTexture({
19018
19310
  format: "rg32sint",
19019
19311
  width: 1,
19020
19312
  height: 1,
19021
- usage: import_core30.Texture.RENDER_ATTACHMENT | import_core30.Texture.COPY_SRC
19313
+ usage: import_core31.Texture.RENDER_ATTACHMENT | import_core31.Texture.COPY_SRC
19022
19314
  });
19023
19315
  return this.device.createFramebuffer({
19024
19316
  colorAttachments: [colorTexture, pickingTexture],
@@ -19030,7 +19322,7 @@ layout(std140) uniform pickingUniforms {
19030
19322
  format: "rgba8unorm",
19031
19323
  width: 1,
19032
19324
  height: 1,
19033
- usage: import_core30.Texture.RENDER_ATTACHMENT | import_core30.Texture.COPY_SRC
19325
+ usage: import_core31.Texture.RENDER_ATTACHMENT | import_core31.Texture.COPY_SRC
19034
19326
  });
19035
19327
  return this.device.createFramebuffer({
19036
19328
  colorAttachments: [pickingTexture],
@@ -19052,7 +19344,7 @@ layout(std140) uniform pickingUniforms {
19052
19344
  const layout = pickTexture.computeMemoryLayout({ width: 1, height: 1 });
19053
19345
  const readBuffer = this.device.createBuffer({
19054
19346
  byteLength: layout.byteLength,
19055
- usage: import_core30.Buffer.COPY_DST | import_core30.Buffer.MAP_READ
19347
+ usage: import_core31.Buffer.COPY_DST | import_core31.Buffer.MAP_READ
19056
19348
  });
19057
19349
  try {
19058
19350
  pickTexture.readBuffer(
@@ -19088,7 +19380,7 @@ layout(std140) uniform pickingUniforms {
19088
19380
  const layout = pickTexture.computeMemoryLayout({ width: 1, height: 1 });
19089
19381
  const readBuffer = this.device.createBuffer({
19090
19382
  byteLength: layout.byteLength,
19091
- usage: import_core30.Buffer.COPY_DST | import_core30.Buffer.MAP_READ
19383
+ usage: import_core31.Buffer.COPY_DST | import_core31.Buffer.MAP_READ
19092
19384
  });
19093
19385
  try {
19094
19386
  pickTexture.readBuffer(
@@ -19770,7 +20062,7 @@ vec4 picking_filterColor(vec4 color) {
19770
20062
  }
19771
20063
 
19772
20064
  // src/scenegraph/controllers/skin-controller.ts
19773
- var import_core31 = __toESM(require_core(), 1);
20065
+ var import_core32 = __toESM(require_core(), 1);
19774
20066
  var SkinController = class {
19775
20067
  bindings;
19776
20068
  scenes;
@@ -19801,7 +20093,7 @@ vec4 picking_filterColor(vec4 color) {
19801
20093
  target: binding.jointMatrices
19802
20094
  });
19803
20095
  if (binding.skinJointMatrices) {
19804
- if (binding.skinJointMatrices instanceof import_core31.Buffer) {
20096
+ if (binding.skinJointMatrices instanceof import_core32.Buffer) {
19805
20097
  binding.skinJointMatrices.write(binding.jointMatrices);
19806
20098
  } else {
19807
20099
  binding.skinJointMatrices.writeData(binding.jointMatrices, {
@@ -19833,7 +20125,7 @@ vec4 picking_filterColor(vec4 color) {
19833
20125
  return device.createBuffer({
19834
20126
  id: `${id}-skin-joint-matrices`,
19835
20127
  byteLength: jointMatrices.byteLength,
19836
- usage: import_core31.Buffer.STORAGE | import_core31.Buffer.COPY_DST
20128
+ usage: import_core32.Buffer.STORAGE | import_core32.Buffer.COPY_DST
19837
20129
  });
19838
20130
  }
19839
20131
  const width = jointMatrices.length / 4;
@@ -19845,7 +20137,7 @@ vec4 picking_filterColor(vec4 color) {
19845
20137
  format: "rgba32float",
19846
20138
  width,
19847
20139
  height: 1,
19848
- usage: import_core31.Texture.SAMPLE | import_core31.Texture.COPY_DST,
20140
+ usage: import_core32.Texture.SAMPLE | import_core32.Texture.COPY_DST,
19849
20141
  sampler: { minFilter: "nearest", magFilter: "nearest", mipmapFilter: "nearest" }
19850
20142
  });
19851
20143
  }
@@ -19888,7 +20180,7 @@ vec4 picking_filterColor(vec4 color) {
19888
20180
  };
19889
20181
 
19890
20182
  // src/scenegraph/controllers/billboard-controller.ts
19891
- var import_core33 = __toESM(require_core(), 1);
20183
+ var import_core34 = __toESM(require_core(), 1);
19892
20184
  var BillboardController = class {
19893
20185
  scenes;
19894
20186
  bindings = /* @__PURE__ */ new Map();
@@ -19899,8 +20191,8 @@ vec4 picking_filterColor(vec4 color) {
19899
20191
  const { definition } = binding;
19900
20192
  const forward = new Vector3(definition.viewDirection || [0, 0, 1]);
19901
20193
  const up = new Vector3(definition.up || [0, 1, 0]);
19902
- (0, import_core33.assert)(forward.magnitude() > 0 && up.magnitude() > 0);
19903
- (0, import_core33.assert)(
20194
+ (0, import_core34.assert)(forward.magnitude() > 0 && up.magnitude() > 0);
20195
+ (0, import_core34.assert)(
19904
20196
  new Vector3(forward).normalize().cross(new Vector3(up).normalize()).magnitude() > 1e-6
19905
20197
  );
19906
20198
  this.bindings.set(binding.node, binding);
@@ -19910,7 +20202,7 @@ vec4 picking_filterColor(vec4 color) {
19910
20202
  getDrawEntries(options) {
19911
20203
  const { sceneIndex = 0, cameraId = "default" } = options;
19912
20204
  const scene = this.scenes[sceneIndex];
19913
- (0, import_core33.assert)(scene);
20205
+ (0, import_core34.assert)(scene);
19914
20206
  const viewMatrix = new Matrix4(options.viewMatrix);
19915
20207
  const cameraMatrix = new Matrix4(viewMatrix).invert();
19916
20208
  const cameraPosition = new Vector3(cameraMatrix.getTranslation());
@@ -20019,7 +20311,7 @@ vec4 picking_filterColor(vec4 color) {
20019
20311
  }
20020
20312
 
20021
20313
  // src/scenegraph/controllers/area-light-controller.ts
20022
- var import_core35 = __toESM(require_core(), 1);
20314
+ var import_core36 = __toESM(require_core(), 1);
20023
20315
  var AreaLightController = class {
20024
20316
  scenes;
20025
20317
  matrixAuthoredNodes = /* @__PURE__ */ new Set();
@@ -20029,11 +20321,11 @@ vec4 picking_filterColor(vec4 color) {
20029
20321
  for (const node of matrixNodes) this.matrixAuthoredNodes.add(node);
20030
20322
  for (const { node, definition, matrixAuthored } of bindings) {
20031
20323
  if (matrixAuthored) this.matrixAuthoredNodes.add(node);
20032
- (0, import_core35.assert)(definition && (definition.type === "rect" || definition.type === "disk"));
20033
- (0, import_core35.assert)(Number.isFinite(definition.height ?? 1) && (definition.height ?? 1) > 0);
20034
- (0, import_core35.assert)(Number.isFinite(definition.intensity ?? 1e3) && (definition.intensity ?? 1e3) > 0);
20035
- (0, import_core35.assert)(Number.isFinite(definition.width ?? 1) && (definition.width ?? 1) > 0);
20036
- (0, import_core35.assert)(
20324
+ (0, import_core36.assert)(definition && (definition.type === "rect" || definition.type === "disk"));
20325
+ (0, import_core36.assert)(Number.isFinite(definition.height ?? 1) && (definition.height ?? 1) > 0);
20326
+ (0, import_core36.assert)(Number.isFinite(definition.intensity ?? 1e3) && (definition.intensity ?? 1e3) > 0);
20327
+ (0, import_core36.assert)(Number.isFinite(definition.width ?? 1) && (definition.width ?? 1) > 0);
20328
+ (0, import_core36.assert)(
20037
20329
  (definition.color || [1, 1, 1]).every(
20038
20330
  (component) => Number.isFinite(component) && component >= 0
20039
20331
  )
@@ -20099,17 +20391,17 @@ vec4 picking_filterColor(vec4 color) {
20099
20391
  function getMatrixRotation(matrix) {
20100
20392
  const horizontal = new Vector3(matrix[0], matrix[1], matrix[2]);
20101
20393
  const vertical = new Vector3(matrix[4], matrix[5], matrix[6]);
20102
- (0, import_core35.assert)(horizontal.magnitude() > 0 && vertical.magnitude() > 0);
20394
+ (0, import_core36.assert)(horizontal.magnitude() > 0 && vertical.magnitude() > 0);
20103
20395
  horizontal.normalize();
20104
20396
  vertical.normalize();
20105
20397
  vertical.subtract(new Vector3(horizontal).scale(vertical.dot(horizontal)));
20106
- (0, import_core35.assert)(vertical.magnitude() > 1e-8);
20398
+ (0, import_core36.assert)(vertical.magnitude() > 1e-8);
20107
20399
  vertical.normalize();
20108
20400
  const forward = new Vector3(horizontal).cross(vertical).normalize();
20109
20401
  const authoredForward = new Vector3(matrix[8], matrix[9], matrix[10]);
20110
- (0, import_core35.assert)(authoredForward.magnitude() > 0);
20402
+ (0, import_core36.assert)(authoredForward.magnitude() > 0);
20111
20403
  authoredForward.normalize();
20112
- (0, import_core35.assert)(Math.abs(forward.dot(authoredForward)) > 1e-8);
20404
+ (0, import_core36.assert)(Math.abs(forward.dot(authoredForward)) > 1e-8);
20113
20405
  if (forward.dot(authoredForward) < 0) forward.negate();
20114
20406
  return new Matrix4([
20115
20407
  horizontal[0],
@@ -20667,15 +20959,15 @@ vec4 picking_filterColor(vec4 color) {
20667
20959
  };
20668
20960
 
20669
20961
  // src/audio/audio-graph.ts
20670
- var import_core37 = __toESM(require_core(), 1);
20962
+ var import_core38 = __toESM(require_core(), 1);
20671
20963
  var AudioGraph = class {
20672
20964
  constructor(definition, context, destination, getEmitterInputs) {
20673
20965
  this.definition = definition;
20674
20966
  for (const node of definition.nodes)
20675
- (0, import_core37.assert)(!node.bypass || node.kind !== "splitter" && node.kind !== "channelmerger");
20967
+ (0, import_core38.assert)(!node.bypass || node.kind !== "splitter" && node.kind !== "channelmerger");
20676
20968
  const validateEndpoint = (index, port = 0) => {
20677
- (0, import_core37.assert)(Number.isInteger(index) && Boolean(definition.nodes[index]));
20678
- (0, import_core37.assert)(Number.isInteger(port) && port >= 0);
20969
+ (0, import_core38.assert)(Number.isInteger(index) && Boolean(definition.nodes[index]));
20970
+ (0, import_core38.assert)(Number.isInteger(port) && port >= 0);
20679
20971
  };
20680
20972
  for (const edge of definition.connections) {
20681
20973
  validateEndpoint(edge.from.node, edge.from.output);
@@ -20683,16 +20975,16 @@ vec4 picking_filterColor(vec4 color) {
20683
20975
  }
20684
20976
  for (const input of definition.inputs || []) {
20685
20977
  validateEndpoint(input.node, input.input);
20686
- (0, import_core37.assert)(Number.isInteger(input.source) && input.source >= 0);
20978
+ (0, import_core38.assert)(Number.isInteger(input.source) && input.source >= 0);
20687
20979
  }
20688
20980
  for (const output of definition.outputs || []) {
20689
20981
  validateEndpoint(output.node, output.output);
20690
- (0, import_core37.assert)(Number.isInteger(output.emitter) && output.emitter >= 0);
20982
+ (0, import_core38.assert)(Number.isInteger(output.emitter) && output.emitter >= 0);
20691
20983
  }
20692
20984
  const visiting = /* @__PURE__ */ new Set();
20693
20985
  const visited = /* @__PURE__ */ new Set();
20694
20986
  const visit = (index) => {
20695
- (0, import_core37.assert)(definition.nodes[index] && !visiting.has(index));
20987
+ (0, import_core38.assert)(definition.nodes[index] && !visiting.has(index));
20696
20988
  if (visited.has(index)) return;
20697
20989
  visiting.add(index);
20698
20990
  for (const edge of definition.connections) if (edge.from.node === index) visit(edge.to.node);
@@ -20753,7 +21045,7 @@ vec4 picking_filterColor(vec4 color) {
20753
21045
  /** Apply a scene-driven gain change using the authored transition shape. */
20754
21046
  setGain(index, gain, time = this.nodes[index].context.currentTime) {
20755
21047
  const definition = this.definition.nodes[index];
20756
- (0, import_core37.assert)(definition.kind === "gain" && !definition.bypass && gain >= 0);
21048
+ (0, import_core38.assert)(definition.kind === "gain" && !definition.bypass && gain >= 0);
20757
21049
  const parameter = this.nodes[index].gain;
20758
21050
  const duration = definition.params.duration ?? 0;
20759
21051
  const initialGain = parameter.value;
@@ -20763,7 +21055,7 @@ vec4 picking_filterColor(vec4 color) {
20763
21055
  parameter.setValueAtTime(gain, time);
20764
21056
  } else if (definition.params.interpolation === "custom") {
20765
21057
  const curve = definition.params.curve;
20766
- (0, import_core37.assert)(curve && curve.length >= 2 && curve.every((value) => value >= 0 && value <= 1));
21058
+ (0, import_core38.assert)(curve && curve.length >= 2 && curve.every((value) => value >= 0 && value <= 1));
20767
21059
  parameter.setValueCurveAtTime(
20768
21060
  Float32Array.from(curve, (value) => value * gain),
20769
21061
  time,
@@ -20848,7 +21140,7 @@ vec4 picking_filterColor(vec4 color) {
20848
21140
  }
20849
21141
 
20850
21142
  // src/audio/audio-environment.ts
20851
- var import_core39 = __toESM(require_core(), 1);
21143
+ var import_core40 = __toESM(require_core(), 1);
20852
21144
  function selectAudioEnvironmentZone(zones, position) {
20853
21145
  let selected;
20854
21146
  for (const zone of zones) {
@@ -20941,7 +21233,7 @@ vec4 picking_filterColor(vec4 color) {
20941
21233
  }
20942
21234
  };
20943
21235
  function createParametricAudioResponse(context, parameters) {
20944
- (0, import_core39.assert)((parameters.density ?? 1) === 1 && (parameters.diffusion ?? 1) === 1);
21236
+ (0, import_core40.assert)((parameters.density ?? 1) === 1 && (parameters.diffusion ?? 1) === 1);
20945
21237
  const presets = {
20946
21238
  generic: [1.49, 0.83, 7e-3, 0.011],
20947
21239
  smallRoom: [0.4, 0.83, 2e-3, 3e-3],
@@ -20958,12 +21250,12 @@ vec4 picking_filterColor(vec4 color) {
20958
21250
  underwater: [1.49, 0.1, 7e-3, 0.011]
20959
21251
  };
20960
21252
  const preset = parameters.preset ? presets[parameters.preset] : void 0;
20961
- (0, import_core39.assert)(!parameters.preset || preset);
21253
+ (0, import_core40.assert)(!parameters.preset || preset);
20962
21254
  const decay = parameters.decayTime ?? preset?.[0] ?? 1.5;
20963
21255
  const highFrequencyDecay = decay * (parameters.decayHFRatio ?? preset?.[1] ?? 0.83);
20964
21256
  const earlyDelay = parameters.reflectionsDelay ?? preset?.[2] ?? 0.02;
20965
21257
  const tailDelay = earlyDelay + (parameters.reverbDelay ?? preset?.[3] ?? 0.04);
20966
- (0, import_core39.assert)(decay > 0 && highFrequencyDecay > 0 && earlyDelay >= 0 && tailDelay >= earlyDelay);
21258
+ (0, import_core40.assert)(decay > 0 && highFrequencyDecay > 0 && earlyDelay >= 0 && tailDelay >= earlyDelay);
20967
21259
  const response = context.createBuffer(
20968
21260
  2,
20969
21261
  Math.ceil((tailDelay + Math.max(decay, highFrequencyDecay)) * context.sampleRate),
@@ -20987,7 +21279,7 @@ vec4 picking_filterColor(vec4 color) {
20987
21279
  }
20988
21280
 
20989
21281
  // src/audio/audio-controller.ts
20990
- var import_core40 = __toESM(require_core(), 1);
21282
+ var import_core41 = __toESM(require_core(), 1);
20991
21283
  var AudioController = class {
20992
21284
  gain;
20993
21285
  definition;
@@ -21097,25 +21389,25 @@ vec4 picking_filterColor(vec4 color) {
21097
21389
  /** Change a graph gain using its authored interpolation and duration. */
21098
21390
  setGraphGain(graphIndex, nodeIndex, gain) {
21099
21391
  const graph = this.graphs.get(graphIndex);
21100
- (0, import_core40.assert)(!this.destroyed && graph);
21392
+ (0, import_core41.assert)(!this.destroyed && graph);
21101
21393
  graph.setGain(nodeIndex, gain);
21102
21394
  }
21103
21395
  startSource(sourceIndex, startTime, autoplayOnly, connect) {
21104
21396
  const definition = this.definition.sources[sourceIndex];
21105
- (0, import_core40.assert)(definition);
21397
+ (0, import_core41.assert)(definition);
21106
21398
  if (autoplayOnly && !definition.autoPlay) return;
21107
21399
  const context = this.options.audioContext;
21108
21400
  const extended = definition.graph;
21109
21401
  const oscillator = extended?.oscillator;
21110
- (0, import_core40.assert)(!(definition.audio !== void 0 && oscillator));
21402
+ (0, import_core41.assert)(!(definition.audio !== void 0 && oscillator));
21111
21403
  let source4;
21112
21404
  if (oscillator) {
21113
21405
  const node = context.createOscillator();
21114
21406
  node.frequency.value = oscillator.frequency ?? 440;
21115
21407
  node.detune.value = oscillator.detune ?? 0;
21116
- (0, import_core40.assert)(oscillator.pulseWidth === void 0 || oscillator.pulseWidth === 0.5);
21408
+ (0, import_core41.assert)(oscillator.pulseWidth === void 0 || oscillator.pulseWidth === 0.5);
21117
21409
  if (oscillator.type === "custom") {
21118
- (0, import_core40.assert)(oscillator.periodicWave);
21410
+ (0, import_core41.assert)(oscillator.periodicWave);
21119
21411
  node.setPeriodicWave(
21120
21412
  context.createPeriodicWave(
21121
21413
  new Float32Array(oscillator.periodicWave.real),
@@ -21126,7 +21418,7 @@ vec4 picking_filterColor(vec4 color) {
21126
21418
  source4 = node;
21127
21419
  } else {
21128
21420
  const node = context.createBufferSource();
21129
- (0, import_core40.assert)(definition.audio !== void 0);
21421
+ (0, import_core41.assert)(definition.audio !== void 0);
21130
21422
  node.buffer = this.buffers.get(definition.audio);
21131
21423
  node.loop = definition.loop ?? false;
21132
21424
  node.loopStart = extended?.loopStart ?? 0;
@@ -21271,15 +21563,15 @@ vec4 picking_filterColor(vec4 color) {
21271
21563
  }
21272
21564
  addEmitter(index, node) {
21273
21565
  const definition = this.definition.emitters[index];
21274
- (0, import_core40.assert)(
21566
+ (0, import_core41.assert)(
21275
21567
  definition && (definition.type === "global" || definition.type === "positional" && node)
21276
21568
  );
21277
- (0, import_core40.assert)(
21569
+ (0, import_core41.assert)(
21278
21570
  !definition.positional?.shapeType || ["cone", "omnidirectional"].includes(definition.positional.shapeType)
21279
21571
  );
21280
21572
  for (const sourceIndex of this.graphEmitters.has(index) ? [] : definition.sources || []) {
21281
21573
  const source4 = this.definition.sources[sourceIndex];
21282
- (0, import_core40.assert)(
21574
+ (0, import_core41.assert)(
21283
21575
  source4 && (source4.audio !== void 0 ? this.definition.audio[source4.audio] : source4.graph?.oscillator)
21284
21576
  );
21285
21577
  }
@@ -21324,7 +21616,7 @@ vec4 picking_filterColor(vec4 color) {
21324
21616
  const audioIndices = new Set(
21325
21617
  [...sourceIndices].map((index) => {
21326
21618
  const source4 = this.definition.sources[index];
21327
- (0, import_core40.assert)(
21619
+ (0, import_core41.assert)(
21328
21620
  source4 && (source4.audio !== void 0 ? this.definition.audio[source4.audio] : source4.graph?.oscillator)
21329
21621
  );
21330
21622
  return source4.audio;
@@ -21361,7 +21653,7 @@ vec4 picking_filterColor(vec4 color) {
21361
21653
  const reverb = environment.reverb;
21362
21654
  if (!reverb) return;
21363
21655
  const response = reverb.type === "impulseResponse" ? this.buffers.get(reverb.audio) : createParametricAudioResponse(audioContext, reverb);
21364
- (0, import_core40.assert)(response);
21656
+ (0, import_core41.assert)(response);
21365
21657
  const bus = new AudioReverbBus(audioContext, response, this.gain, {
21366
21658
  ...reverb,
21367
21659
  normalize: reverb.type === "impulseResponse" ? reverb.normalize : false
@@ -21470,7 +21762,7 @@ vec4 picking_filterColor(vec4 color) {
21470
21762
  var legacyColorPicking = import_shaders8.picking;
21471
21763
 
21472
21764
  // src/geometry/ring-geometry.ts
21473
- var import_core42 = __toESM(require_core(), 1);
21765
+ var import_core43 = __toESM(require_core(), 1);
21474
21766
  var RingGeometry = class extends Geometry2 {
21475
21767
  constructor(props = {}) {
21476
21768
  const {
@@ -21481,7 +21773,7 @@ vec4 picking_filterColor(vec4 color) {
21481
21773
  startAngle = 0,
21482
21774
  angle: angle2 = Math.PI * 2
21483
21775
  } = props;
21484
- (0, import_core42.assert)(
21776
+ (0, import_core43.assert)(
21485
21777
  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
21486
21778
  );
21487
21779
  const halfHeight = height / 2;
@@ -21665,7 +21957,7 @@ struct PublishedTransforms {bodyIndex:i32,viewProjection:mat4x4f}
21665
21957
  };
21666
21958
 
21667
21959
  // src/scenegraph/controllers/morph-controller.ts
21668
- var import_core45 = __toESM(require_core(), 1);
21960
+ var import_core46 = __toESM(require_core(), 1);
21669
21961
  function setMorphWeights(node, weights) {
21670
21962
  node.userData["morphWeights"] = [...weights];
21671
21963
  const meshes = node.userData["morphMeshes"] || [];
@@ -21692,7 +21984,7 @@ struct PublishedTransforms {bodyIndex:i32,viewProjection:mat4x4f}
21692
21984
  function updateMorphWeights(state, weights) {
21693
21985
  state.values.fill(0);
21694
21986
  state.values.set(weights.slice(0, state.values.length));
21695
- if (state.data instanceof import_core45.Buffer) {
21987
+ if (state.data instanceof import_core46.Buffer) {
21696
21988
  state.data.write(state.values);
21697
21989
  } else {
21698
21990
  state.data.writeData(state.values, { width: state.packedTargetCount, height: 1 });