@luma.gl/engine 10.0.0-alpha.7 → 10.0.0-alpha.9
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.
- package/dist/arrow/index.cjs +5 -0
- package/dist/arrow/index.cjs.map +3 -3
- package/dist/arrow/index.d.ts +1 -0
- package/dist/arrow/index.d.ts.map +1 -1
- package/dist/arrow/index.js +1 -0
- package/dist/arrow/index.js.map +1 -1
- package/dist/arrow/renderers/splats/conversion/make-gpu-splat-data-from-gltf.cjs +162 -0
- package/dist/arrow/renderers/splats/conversion/make-gpu-splat-data-from-gltf.d.ts +34 -0
- package/dist/arrow/renderers/splats/conversion/make-gpu-splat-data-from-gltf.d.ts.map +1 -0
- package/dist/arrow/renderers/splats/conversion/make-gpu-splat-data-from-gltf.js +159 -0
- package/dist/arrow/renderers/splats/conversion/make-gpu-splat-data-from-gltf.js.map +1 -0
- package/dist/arrow/renderers/text/renderers/arrow-text-renderer.d.ts +1 -1
- package/dist/arrow/renderers/text/renderers/arrow-text-renderer.d.ts.map +1 -1
- package/dist/arrow/renderers/text/renderers/arrow-text-renderer.js.map +1 -1
- package/dist/arrow/renderers/text/renderers/arrow-text-shaders.cjs +10 -1
- package/dist/arrow/renderers/text/renderers/arrow-text-shaders.d.ts.map +1 -1
- package/dist/arrow/renderers/text/renderers/arrow-text-shaders.js +10 -3
- package/dist/arrow/renderers/text/renderers/arrow-text-shaders.js.map +1 -1
- package/dist/compute/computation.cjs +3 -0
- package/dist/compute/computation.d.ts.map +1 -1
- package/dist/compute/computation.js +3 -0
- package/dist/compute/computation.js.map +1 -1
- package/dist/dist.dev.js +706 -501
- package/dist/dist.min.js +63 -63
- package/dist/geometry/gpu-vector-geometry-adapter.cjs +14 -0
- package/dist/geometry/gpu-vector-geometry-adapter.d.ts +7 -0
- package/dist/geometry/gpu-vector-geometry-adapter.d.ts.map +1 -1
- package/dist/geometry/gpu-vector-geometry-adapter.js +17 -0
- package/dist/geometry/gpu-vector-geometry-adapter.js.map +1 -1
- package/dist/geometry/gpu-vector-geometry.cjs +3 -0
- package/dist/geometry/gpu-vector-geometry.d.ts +2 -0
- package/dist/geometry/gpu-vector-geometry.d.ts.map +1 -1
- package/dist/geometry/gpu-vector-geometry.js +2 -0
- package/dist/geometry/gpu-vector-geometry.js.map +1 -1
- package/dist/gltf/gltf/gltf-extension-support.cjs +25 -5
- package/dist/gltf/gltf/gltf-extension-support.d.ts.map +1 -1
- package/dist/gltf/gltf/gltf-extension-support.js +27 -5
- package/dist/gltf/gltf/gltf-extension-support.js.map +1 -1
- package/dist/gltf/index.cjs.map +1 -1
- package/dist/gltf/index.d.ts +1 -1
- package/dist/gltf/index.d.ts.map +1 -1
- package/dist/gltf/parsers/parse-gltf.cjs +19 -13
- package/dist/gltf/parsers/parse-gltf.d.ts +2 -0
- package/dist/gltf/parsers/parse-gltf.d.ts.map +1 -1
- package/dist/gltf/parsers/parse-gltf.js +18 -13
- package/dist/gltf/parsers/parse-gltf.js.map +1 -1
- package/dist/gltf/parsers/post-process-gltf.cjs +1 -0
- package/dist/gltf/parsers/post-process-gltf.d.ts.map +1 -1
- package/dist/gltf/parsers/post-process-gltf.js +1 -0
- package/dist/gltf/parsers/post-process-gltf.js.map +1 -1
- package/dist/gltf/types/gltf-postprocessed-schema.d.ts +2 -0
- package/dist/gltf/types/gltf-postprocessed-schema.d.ts.map +1 -1
- package/dist/gltf/types/gltf-types.d.ts +19 -0
- package/dist/gltf/types/gltf-types.d.ts.map +1 -1
- package/dist/graph/models/index.cjs.map +3 -3
- package/dist/graph/physics/index.cjs +3 -0
- package/dist/graph/physics/index.cjs.map +3 -3
- package/dist/graph/physics/index.d.ts +2 -0
- package/dist/graph/physics/index.d.ts.map +1 -1
- package/dist/graph/physics/index.js +1 -0
- package/dist/graph/physics/index.js.map +1 -1
- package/dist/graph/physics/physics-controller-geometry.cjs +203 -0
- package/dist/graph/physics/physics-controller-geometry.d.ts +6 -0
- package/dist/graph/physics/physics-controller-geometry.d.ts.map +1 -0
- package/dist/graph/physics/physics-controller-geometry.js +205 -0
- package/dist/graph/physics/physics-controller-geometry.js.map +1 -0
- package/dist/graph/physics/physics-controller.cjs +277 -0
- package/dist/graph/physics/physics-controller.d.ts +90 -0
- package/dist/graph/physics/physics-controller.d.ts.map +1 -0
- package/dist/graph/physics/physics-controller.js +266 -0
- package/dist/graph/physics/physics-controller.js.map +1 -0
- package/dist/graph/physics/scenegraph-instance.cjs +11 -2
- package/dist/graph/physics/scenegraph-instance.d.ts +3 -1
- package/dist/graph/physics/scenegraph-instance.d.ts.map +1 -1
- package/dist/graph/physics/scenegraph-instance.js +11 -0
- package/dist/graph/physics/scenegraph-instance.js.map +1 -1
- package/dist/graph/physics/scenegraph-motion.cjs +3 -3
- package/dist/graph/physics/scenegraph-motion.d.ts +5 -1
- package/dist/graph/physics/scenegraph-motion.d.ts.map +1 -1
- package/dist/graph/physics/scenegraph-motion.js +3 -3
- package/dist/graph/physics/scenegraph-motion.js.map +1 -1
- package/dist/graph/physics/scenegraph-publication.cjs +13 -3
- package/dist/graph/physics/scenegraph-publication.d.ts +4 -2
- package/dist/graph/physics/scenegraph-publication.d.ts.map +1 -1
- package/dist/graph/physics/scenegraph-publication.js +14 -3
- package/dist/graph/physics/scenegraph-publication.js.map +1 -1
- package/dist/graph/physics/scenegraph-session.cjs +11 -1
- package/dist/graph/physics/scenegraph-session.d.ts +11 -2
- package/dist/graph/physics/scenegraph-session.d.ts.map +1 -1
- package/dist/graph/physics/scenegraph-session.js +13 -1
- package/dist/graph/physics/scenegraph-session.js.map +1 -1
- package/dist/graph/tables/index.cjs.map +3 -3
- package/dist/index.cjs +6 -0
- package/dist/index.cjs.map +3 -3
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/model/batch-uniform-buffer.cjs +70 -0
- package/dist/model/batch-uniform-buffer.d.ts +21 -0
- package/dist/model/batch-uniform-buffer.d.ts.map +1 -0
- package/dist/model/batch-uniform-buffer.js +48 -0
- package/dist/model/batch-uniform-buffer.js.map +1 -0
- package/dist/model/gpu-vector-bindings.cjs +67 -19
- package/dist/model/gpu-vector-bindings.d.ts +1 -1
- package/dist/model/gpu-vector-bindings.d.ts.map +1 -1
- package/dist/model/gpu-vector-bindings.js +77 -18
- package/dist/model/gpu-vector-bindings.js.map +1 -1
- package/dist/model/gpu-vector-draw-batches.cjs +8 -5
- package/dist/model/gpu-vector-draw-batches.d.ts +1 -1
- package/dist/model/gpu-vector-draw-batches.d.ts.map +1 -1
- package/dist/model/gpu-vector-draw-batches.js +9 -5
- package/dist/model/gpu-vector-draw-batches.js.map +1 -1
- package/dist/model/gpu-vector-model-batches.d.ts +5 -0
- package/dist/model/gpu-vector-model-batches.d.ts.map +1 -1
- package/dist/model/gpu-vector-model-batches.js.map +1 -1
- package/dist/model/gpu-vector-model.cjs +63 -17
- package/dist/model/gpu-vector-model.d.ts +16 -3
- package/dist/model/gpu-vector-model.d.ts.map +1 -1
- package/dist/model/gpu-vector-model.js +72 -16
- package/dist/model/gpu-vector-model.js.map +1 -1
- package/dist/model/model.cjs +8 -0
- package/dist/model/model.d.ts +4 -1
- package/dist/model/model.d.ts.map +1 -1
- package/dist/model/model.js +8 -0
- package/dist/model/model.js.map +1 -1
- package/dist/scenegraph/geometry-node.cjs +47 -0
- package/dist/scenegraph/geometry-node.d.ts +13 -0
- package/dist/scenegraph/geometry-node.d.ts.map +1 -0
- package/dist/scenegraph/geometry-node.js +26 -0
- package/dist/scenegraph/geometry-node.js.map +1 -0
- package/dist/scenegraph/group-node.cjs +42 -0
- package/dist/scenegraph/group-node.d.ts +8 -0
- package/dist/scenegraph/group-node.d.ts.map +1 -1
- package/dist/scenegraph/group-node.js +47 -1
- package/dist/scenegraph/group-node.js.map +1 -1
- package/dist/scenegraph/transform-source.cjs +15 -0
- package/dist/scenegraph/transform-source.d.ts +24 -0
- package/dist/scenegraph/transform-source.d.ts.map +1 -0
- package/dist/scenegraph/transform-source.js +5 -0
- package/dist/scenegraph/transform-source.js.map +1 -0
- package/dist/splats/gpu-splat-graph-renderer.d.ts +1 -1
- package/dist/splats/gpu-splat-graph-renderer.d.ts.map +1 -1
- package/dist/splats/index.cjs.map +1 -1
- package/dist/splats/splat-data.cjs +34 -23
- package/dist/splats/splat-data.d.ts.map +1 -1
- package/dist/splats/splat-data.js +34 -22
- package/dist/splats/splat-data.js.map +1 -1
- package/dist/splats/splat-renderer.cjs +6 -1
- package/dist/splats/splat-renderer.d.ts +3 -0
- package/dist/splats/splat-renderer.d.ts.map +1 -1
- package/dist/splats/splat-renderer.js +6 -1
- package/dist/splats/splat-renderer.js.map +1 -1
- package/dist/splats/splat-sort.d.ts +1 -1
- package/dist/splats/splat-sort.d.ts.map +1 -1
- package/package.json +8 -8
- package/src/arrow/index.ts +6 -0
- package/src/arrow/renderers/splats/conversion/make-gpu-splat-data-from-gltf.ts +220 -0
- package/src/arrow/renderers/text/renderers/arrow-text-renderer.ts +1 -0
- package/src/arrow/renderers/text/renderers/arrow-text-shaders.ts +12 -5
- package/src/compute/computation.ts +3 -0
- package/src/geometry/gpu-vector-geometry-adapter.ts +19 -1
- package/src/geometry/gpu-vector-geometry.ts +3 -0
- package/src/gltf/gltf/gltf-extension-support.ts +27 -5
- package/src/gltf/index.ts +1 -0
- package/src/gltf/parsers/parse-gltf.ts +21 -14
- package/src/gltf/parsers/post-process-gltf.ts +1 -0
- package/src/gltf/types/gltf-postprocessed-schema.ts +2 -0
- package/src/gltf/types/gltf-types.ts +20 -0
- package/src/graph/physics/index.ts +10 -0
- package/src/graph/physics/physics-controller-geometry.ts +264 -0
- package/src/graph/physics/physics-controller.ts +348 -0
- package/src/graph/physics/scenegraph-instance.ts +12 -1
- package/src/graph/physics/scenegraph-motion.ts +14 -3
- package/src/graph/physics/scenegraph-publication.ts +24 -4
- package/src/graph/physics/scenegraph-session.ts +35 -3
- package/src/index.ts +8 -0
- package/src/model/batch-uniform-buffer.ts +51 -0
- package/src/model/gpu-vector-bindings.ts +88 -22
- package/src/model/gpu-vector-draw-batches.ts +17 -12
- package/src/model/gpu-vector-model-batches.ts +5 -0
- package/src/model/gpu-vector-model.ts +101 -18
- package/src/model/model.ts +11 -1
- package/src/scenegraph/geometry-node.ts +31 -0
- package/src/scenegraph/group-node.ts +54 -1
- package/src/scenegraph/transform-source.ts +30 -0
- package/src/splats/README.md +46 -0
- package/src/splats/gpu-splat-graph-renderer.ts +1 -1
- package/src/splats/splat-data.ts +53 -45
- package/src/splats/splat-renderer.ts +9 -1
- package/src/splats/splat-sort.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,
|
|
@@ -144,6 +145,7 @@ var __exports__ = (() => {
|
|
|
144
145
|
makeAnimationLoop: () => makeAnimationLoop,
|
|
145
146
|
makeEdgeGeometry: () => makeEdgeGeometry,
|
|
146
147
|
makeEdgeGeometryFromGeometries: () => makeEdgeGeometryFromGeometries,
|
|
148
|
+
makeGPUVectorGeometry: () => makeGPUVectorGeometry,
|
|
147
149
|
makeInterleavedGeometry: () => makeInterleavedGeometry,
|
|
148
150
|
makeMaterialAnimationBinding: () => makeMaterialAnimationBinding,
|
|
149
151
|
makeNodeAnimationBinding: () => makeNodeAnimationBinding,
|
|
@@ -5669,7 +5671,7 @@ var __exports__ = (() => {
|
|
|
5669
5671
|
}
|
|
5670
5672
|
|
|
5671
5673
|
// src/model/gpu-vector-model.ts
|
|
5672
|
-
var
|
|
5674
|
+
var import_core14 = __toESM(require_core(), 1);
|
|
5673
5675
|
var import_shaders3 = __toESM(require_shaders(), 1);
|
|
5674
5676
|
|
|
5675
5677
|
// ../shaders/src/lib/utils/assert.ts
|
|
@@ -5730,184 +5732,6 @@ var __exports__ = (() => {
|
|
|
5730
5732
|
return typeof value;
|
|
5731
5733
|
}
|
|
5732
5734
|
|
|
5733
|
-
// ../shaders/src/module-injectors.ts
|
|
5734
|
-
var MODULE_INJECTORS_VS = (
|
|
5735
|
-
/* glsl */
|
|
5736
|
-
`#ifdef MODULE_LOGDEPTH
|
|
5737
|
-
logdepth_adjustPosition(gl_Position);
|
|
5738
|
-
#endif
|
|
5739
|
-
`
|
|
5740
|
-
);
|
|
5741
|
-
var MODULE_INJECTORS_FS = (
|
|
5742
|
-
/* glsl */
|
|
5743
|
-
`#ifdef MODULE_MATERIAL
|
|
5744
|
-
fragColor = material_filterColor(fragColor);
|
|
5745
|
-
#endif
|
|
5746
|
-
|
|
5747
|
-
#ifdef MODULE_LIGHTING
|
|
5748
|
-
fragColor = lighting_filterColor(fragColor);
|
|
5749
|
-
#endif
|
|
5750
|
-
|
|
5751
|
-
#ifdef MODULE_FOG
|
|
5752
|
-
fragColor = fog_filterColor(fragColor);
|
|
5753
|
-
#endif
|
|
5754
|
-
|
|
5755
|
-
#ifdef MODULE_PICKING
|
|
5756
|
-
fragColor = picking_filterHighlightColor(fragColor);
|
|
5757
|
-
fragColor = picking_filterPickingColor(fragColor);
|
|
5758
|
-
#endif
|
|
5759
|
-
|
|
5760
|
-
#ifdef MODULE_LOGDEPTH
|
|
5761
|
-
logdepth_setFragDepth();
|
|
5762
|
-
#endif
|
|
5763
|
-
`
|
|
5764
|
-
);
|
|
5765
|
-
|
|
5766
|
-
// ../shaders/src/lib/shader-assembly/shader-injections.ts
|
|
5767
|
-
var MODULE_INJECTORS = {
|
|
5768
|
-
vertex: MODULE_INJECTORS_VS,
|
|
5769
|
-
fragment: MODULE_INJECTORS_FS
|
|
5770
|
-
};
|
|
5771
|
-
var REGEX_START_OF_MAIN = /void\s+main\s*\([^)]*\)\s*\{\n?/;
|
|
5772
|
-
var REGEX_END_OF_MAIN = /}\n?[^{}]*$/;
|
|
5773
|
-
var fragments = [];
|
|
5774
|
-
var DECLARATION_INJECT_MARKER = "__LUMA_INJECT_DECLARATIONS__";
|
|
5775
|
-
function normalizeInjections(injections) {
|
|
5776
|
-
const result = { vertex: {}, fragment: {} };
|
|
5777
|
-
for (const hook in injections) {
|
|
5778
|
-
let injection = injections[hook];
|
|
5779
|
-
const stage = getHookStage(hook);
|
|
5780
|
-
if (typeof injection === "string") {
|
|
5781
|
-
injection = {
|
|
5782
|
-
order: 0,
|
|
5783
|
-
injection
|
|
5784
|
-
};
|
|
5785
|
-
}
|
|
5786
|
-
result[stage][hook] = injection;
|
|
5787
|
-
}
|
|
5788
|
-
return result;
|
|
5789
|
-
}
|
|
5790
|
-
function getHookStage(hook) {
|
|
5791
|
-
const type = hook.slice(0, 2);
|
|
5792
|
-
switch (type) {
|
|
5793
|
-
case "vs":
|
|
5794
|
-
return "vertex";
|
|
5795
|
-
case "fs":
|
|
5796
|
-
return "fragment";
|
|
5797
|
-
default:
|
|
5798
|
-
throw new Error(type);
|
|
5799
|
-
}
|
|
5800
|
-
}
|
|
5801
|
-
function injectShader(source4, stage, inject, injectStandardStubs = false, language = "glsl", entryPoints = {}) {
|
|
5802
|
-
const isVertex = stage === "vertex";
|
|
5803
|
-
for (const key in inject) {
|
|
5804
|
-
const fragmentData = inject[key];
|
|
5805
|
-
fragmentData.sort((a, b) => a.order - b.order);
|
|
5806
|
-
fragments.length = fragmentData.length;
|
|
5807
|
-
for (let i = 0, len2 = fragmentData.length; i < len2; ++i) {
|
|
5808
|
-
fragments[i] = fragmentData[i].injection;
|
|
5809
|
-
}
|
|
5810
|
-
const fragmentString = `${fragments.join("\n")}
|
|
5811
|
-
`;
|
|
5812
|
-
switch (key) {
|
|
5813
|
-
// declarations are injected before the main function
|
|
5814
|
-
case "vs:#decl":
|
|
5815
|
-
if (language === "wgsl" || isVertex) {
|
|
5816
|
-
source4 = source4.replace(DECLARATION_INJECT_MARKER, fragmentString);
|
|
5817
|
-
}
|
|
5818
|
-
break;
|
|
5819
|
-
// inject code at the beginning of the main function
|
|
5820
|
-
case "vs:#main-start":
|
|
5821
|
-
if (language === "wgsl" || isVertex) {
|
|
5822
|
-
source4 = language === "wgsl" ? injectWGSLStageMain(source4, "vertex", fragmentString, "start", entryPoints.vertex) : source4.replace(REGEX_START_OF_MAIN, (match) => match + fragmentString);
|
|
5823
|
-
}
|
|
5824
|
-
break;
|
|
5825
|
-
// inject code at the end of main function
|
|
5826
|
-
case "vs:#main-end":
|
|
5827
|
-
if (language === "wgsl" || isVertex) {
|
|
5828
|
-
source4 = language === "wgsl" ? injectWGSLStageMain(source4, "vertex", fragmentString, "end", entryPoints.vertex) : source4.replace(REGEX_END_OF_MAIN, (match) => fragmentString + match);
|
|
5829
|
-
}
|
|
5830
|
-
break;
|
|
5831
|
-
// declarations are injected before the main function
|
|
5832
|
-
case "fs:#decl":
|
|
5833
|
-
if (language === "wgsl" || !isVertex) {
|
|
5834
|
-
source4 = source4.replace(DECLARATION_INJECT_MARKER, fragmentString);
|
|
5835
|
-
}
|
|
5836
|
-
break;
|
|
5837
|
-
// inject code at the beginning of the main function
|
|
5838
|
-
case "fs:#main-start":
|
|
5839
|
-
if (language === "wgsl" || !isVertex) {
|
|
5840
|
-
source4 = language === "wgsl" ? injectWGSLStageMain(
|
|
5841
|
-
source4,
|
|
5842
|
-
"fragment",
|
|
5843
|
-
fragmentString,
|
|
5844
|
-
"start",
|
|
5845
|
-
entryPoints.fragment
|
|
5846
|
-
) : source4.replace(REGEX_START_OF_MAIN, (match) => match + fragmentString);
|
|
5847
|
-
}
|
|
5848
|
-
break;
|
|
5849
|
-
// inject code at the end of main function
|
|
5850
|
-
case "fs:#main-end":
|
|
5851
|
-
if (language === "wgsl" || !isVertex) {
|
|
5852
|
-
source4 = language === "wgsl" ? injectWGSLStageMain(source4, "fragment", fragmentString, "end", entryPoints.fragment) : source4.replace(REGEX_END_OF_MAIN, (match) => fragmentString + match);
|
|
5853
|
-
}
|
|
5854
|
-
break;
|
|
5855
|
-
default:
|
|
5856
|
-
source4 = source4.replace(key, (match) => match + fragmentString);
|
|
5857
|
-
}
|
|
5858
|
-
}
|
|
5859
|
-
source4 = source4.replace(DECLARATION_INJECT_MARKER, "");
|
|
5860
|
-
if (injectStandardStubs) {
|
|
5861
|
-
source4 = source4.replace(/\}\s*$/, (match) => match + MODULE_INJECTORS[stage]);
|
|
5862
|
-
}
|
|
5863
|
-
return source4;
|
|
5864
|
-
}
|
|
5865
|
-
function injectWGSLStageMain(source4, stage, fragmentString, position, entryPoint) {
|
|
5866
|
-
const bodyRange = getWGSLStageFunctionBodyRange(source4, stage, entryPoint);
|
|
5867
|
-
if (!bodyRange) {
|
|
5868
|
-
return source4;
|
|
5869
|
-
}
|
|
5870
|
-
if (position === "start") {
|
|
5871
|
-
const insertionIndex = bodyRange.openBraceIndex + 1;
|
|
5872
|
-
return `${source4.slice(0, insertionIndex)}
|
|
5873
|
-
${fragmentString}${source4.slice(insertionIndex)}`;
|
|
5874
|
-
}
|
|
5875
|
-
return `${source4.slice(0, bodyRange.closeBraceIndex)}${fragmentString}${source4.slice(
|
|
5876
|
-
bodyRange.closeBraceIndex
|
|
5877
|
-
)}`;
|
|
5878
|
-
}
|
|
5879
|
-
function getWGSLStageFunctionBodyRange(source4, stage, entryPoint) {
|
|
5880
|
-
const stageAttribute = stage === "vertex" ? "@vertex" : "@fragment";
|
|
5881
|
-
const stageIndex = source4.indexOf(stageAttribute);
|
|
5882
|
-
if (stageIndex < 0) {
|
|
5883
|
-
return null;
|
|
5884
|
-
}
|
|
5885
|
-
const functionIndex = entryPoint ? source4.search(new RegExp(`\\bfn\\s+${escapeRegExp(entryPoint)}\\s*\\(`)) : source4.indexOf("fn", stageIndex);
|
|
5886
|
-
if (functionIndex < 0) {
|
|
5887
|
-
return null;
|
|
5888
|
-
}
|
|
5889
|
-
const openBraceIndex = source4.indexOf("{", functionIndex);
|
|
5890
|
-
if (openBraceIndex < 0) {
|
|
5891
|
-
return null;
|
|
5892
|
-
}
|
|
5893
|
-
let braceDepth = 0;
|
|
5894
|
-
for (let index = openBraceIndex; index < source4.length; index++) {
|
|
5895
|
-
const character = source4[index];
|
|
5896
|
-
if (character === "{") {
|
|
5897
|
-
braceDepth++;
|
|
5898
|
-
} else if (character === "}") {
|
|
5899
|
-
braceDepth--;
|
|
5900
|
-
if (braceDepth === 0) {
|
|
5901
|
-
return { openBraceIndex, closeBraceIndex: index };
|
|
5902
|
-
}
|
|
5903
|
-
}
|
|
5904
|
-
}
|
|
5905
|
-
return null;
|
|
5906
|
-
}
|
|
5907
|
-
function escapeRegExp(value) {
|
|
5908
|
-
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
5909
|
-
}
|
|
5910
|
-
|
|
5911
5735
|
// ../shaders/src/lib/shader-module/shader-module.ts
|
|
5912
5736
|
function initializeShaderModules(modules) {
|
|
5913
5737
|
modules.map((module) => initializeShaderModule(module));
|
|
@@ -5917,15 +5741,10 @@ ${fragmentString}${source4.slice(insertionIndex)}`;
|
|
|
5917
5741
|
return;
|
|
5918
5742
|
}
|
|
5919
5743
|
initializeShaderModules(module.dependencies || []);
|
|
5920
|
-
const {
|
|
5921
|
-
propTypes = {},
|
|
5922
|
-
deprecations = [],
|
|
5923
|
-
// defines = {},
|
|
5924
|
-
inject = {}
|
|
5925
|
-
} = module;
|
|
5744
|
+
const { propTypes = {}, deprecations = [] } = module;
|
|
5926
5745
|
const instance = {
|
|
5927
|
-
|
|
5928
|
-
|
|
5746
|
+
parsedDeprecations: parseDeprecationDefinitions(deprecations),
|
|
5747
|
+
normalizedInjections: { vertex: {}, fragment: {} }
|
|
5929
5748
|
};
|
|
5930
5749
|
if (propTypes) {
|
|
5931
5750
|
instance.propValidators = makePropValidators(propTypes);
|
|
@@ -6098,11 +5917,10 @@ ${fragmentString}${source4.slice(insertionIndex)}`;
|
|
|
6098
5917
|
}
|
|
6099
5918
|
/**
|
|
6100
5919
|
* Register a shader hook
|
|
6101
|
-
* @param hook
|
|
6102
|
-
* @param options Optional hook metadata such as always-on header and footer source.
|
|
5920
|
+
* @param hook Shared stage and name with language-specific parameters, return type, and source.
|
|
6103
5921
|
*/
|
|
6104
|
-
addShaderHook(hook
|
|
6105
|
-
this._hookFunctions.push(
|
|
5922
|
+
addShaderHook(hook) {
|
|
5923
|
+
this._hookFunctions.push(hook);
|
|
6106
5924
|
}
|
|
6107
5925
|
/**
|
|
6108
5926
|
* Remove all registered shader hooks, for example before re-registering hooks for a new
|
|
@@ -6138,6 +5956,181 @@ ${fragmentString}${source4.slice(insertionIndex)}`;
|
|
|
6138
5956
|
}
|
|
6139
5957
|
};
|
|
6140
5958
|
|
|
5959
|
+
// ../shaders/src/module-injectors.ts
|
|
5960
|
+
var MODULE_INJECTORS_VS = (
|
|
5961
|
+
/* glsl */
|
|
5962
|
+
`#ifdef MODULE_LOGDEPTH
|
|
5963
|
+
logdepth_adjustPosition(gl_Position);
|
|
5964
|
+
#endif
|
|
5965
|
+
`
|
|
5966
|
+
);
|
|
5967
|
+
var MODULE_INJECTORS_FS = (
|
|
5968
|
+
/* glsl */
|
|
5969
|
+
`#ifdef MODULE_MATERIAL
|
|
5970
|
+
fragColor = material_filterColor(fragColor);
|
|
5971
|
+
#endif
|
|
5972
|
+
|
|
5973
|
+
#ifdef MODULE_LIGHTING
|
|
5974
|
+
fragColor = lighting_filterColor(fragColor);
|
|
5975
|
+
#endif
|
|
5976
|
+
|
|
5977
|
+
#ifdef MODULE_FOG
|
|
5978
|
+
fragColor = fog_filterColor(fragColor);
|
|
5979
|
+
#endif
|
|
5980
|
+
|
|
5981
|
+
#ifdef MODULE_PICKING
|
|
5982
|
+
fragColor = picking_filterHighlightColor(fragColor);
|
|
5983
|
+
fragColor = picking_filterPickingColor(fragColor);
|
|
5984
|
+
#endif
|
|
5985
|
+
|
|
5986
|
+
#ifdef MODULE_LOGDEPTH
|
|
5987
|
+
logdepth_setFragDepth();
|
|
5988
|
+
#endif
|
|
5989
|
+
`
|
|
5990
|
+
);
|
|
5991
|
+
|
|
5992
|
+
// ../shaders/src/lib/shader-assembly/shader-injections.ts
|
|
5993
|
+
var MODULE_INJECTORS = {
|
|
5994
|
+
vertex: MODULE_INJECTORS_VS,
|
|
5995
|
+
fragment: MODULE_INJECTORS_FS
|
|
5996
|
+
};
|
|
5997
|
+
var REGEX_START_OF_MAIN = /void\s+main\s*\([^)]*\)\s*\{\n?/;
|
|
5998
|
+
var REGEX_END_OF_MAIN = /}\n?[^{}]*$/;
|
|
5999
|
+
var fragments = [];
|
|
6000
|
+
var DECLARATION_INJECT_MARKER = "__LUMA_INJECT_DECLARATIONS__";
|
|
6001
|
+
function resolveShaderInjections(declarations, language, pluginName) {
|
|
6002
|
+
const resolved = {};
|
|
6003
|
+
for (const declaration of declarations) {
|
|
6004
|
+
const source4 = declaration[language];
|
|
6005
|
+
if (source4 === void 0) continue;
|
|
6006
|
+
if (declaration.stage !== "vertex" && declaration.stage !== "fragment" || declaration.target.includes(":")) {
|
|
6007
|
+
throw new Error("Shader injection targets require an explicit stage and unqualified target");
|
|
6008
|
+
}
|
|
6009
|
+
const target = `${declaration.stage === "vertex" ? "vs" : "fs"}:${declaration.target}`;
|
|
6010
|
+
if (!/^(vs|fs):(?:#(?:decl|main-start|main-end)|[A-Za-z_][A-Za-z0-9_]*)$/.test(target)) {
|
|
6011
|
+
throw new Error(`Shader injection target "${target}" must be a named shader anchor or hook`);
|
|
6012
|
+
}
|
|
6013
|
+
resolved[target] ||= [];
|
|
6014
|
+
resolved[target].push({
|
|
6015
|
+
injection: source4,
|
|
6016
|
+
order: declaration.order ?? 0,
|
|
6017
|
+
...pluginName ? { pluginName } : {}
|
|
6018
|
+
});
|
|
6019
|
+
}
|
|
6020
|
+
return resolved;
|
|
6021
|
+
}
|
|
6022
|
+
function injectShader(source4, stage, inject, injectStandardStubs = false, language = "glsl", entryPoints = {}) {
|
|
6023
|
+
const isVertex = stage === "vertex";
|
|
6024
|
+
for (const key in inject) {
|
|
6025
|
+
const fragmentData = inject[key];
|
|
6026
|
+
fragmentData.sort(
|
|
6027
|
+
(a, b) => a.order - b.order
|
|
6028
|
+
);
|
|
6029
|
+
fragments.length = fragmentData.length;
|
|
6030
|
+
for (let i = 0, len2 = fragmentData.length; i < len2; ++i) {
|
|
6031
|
+
fragments[i] = fragmentData[i].injection;
|
|
6032
|
+
}
|
|
6033
|
+
const fragmentString = `${fragments.join("\n")}
|
|
6034
|
+
`;
|
|
6035
|
+
switch (key) {
|
|
6036
|
+
// declarations are injected before the main function
|
|
6037
|
+
case "vs:#decl":
|
|
6038
|
+
if (language === "wgsl" || isVertex) {
|
|
6039
|
+
source4 = source4.replace(DECLARATION_INJECT_MARKER, fragmentString);
|
|
6040
|
+
}
|
|
6041
|
+
break;
|
|
6042
|
+
// inject code at the beginning of the main function
|
|
6043
|
+
case "vs:#main-start":
|
|
6044
|
+
if (language === "wgsl" || isVertex) {
|
|
6045
|
+
source4 = language === "wgsl" ? injectWGSLStageMain(source4, "vertex", fragmentString, "start", entryPoints.vertex) : source4.replace(REGEX_START_OF_MAIN, (match) => match + fragmentString);
|
|
6046
|
+
}
|
|
6047
|
+
break;
|
|
6048
|
+
// inject code at the end of main function
|
|
6049
|
+
case "vs:#main-end":
|
|
6050
|
+
if (language === "wgsl" || isVertex) {
|
|
6051
|
+
source4 = language === "wgsl" ? injectWGSLStageMain(source4, "vertex", fragmentString, "end", entryPoints.vertex) : source4.replace(REGEX_END_OF_MAIN, (match) => fragmentString + match);
|
|
6052
|
+
}
|
|
6053
|
+
break;
|
|
6054
|
+
// declarations are injected before the main function
|
|
6055
|
+
case "fs:#decl":
|
|
6056
|
+
if (language === "wgsl" || !isVertex) {
|
|
6057
|
+
source4 = source4.replace(DECLARATION_INJECT_MARKER, fragmentString);
|
|
6058
|
+
}
|
|
6059
|
+
break;
|
|
6060
|
+
// inject code at the beginning of the main function
|
|
6061
|
+
case "fs:#main-start":
|
|
6062
|
+
if (language === "wgsl" || !isVertex) {
|
|
6063
|
+
source4 = language === "wgsl" ? injectWGSLStageMain(
|
|
6064
|
+
source4,
|
|
6065
|
+
"fragment",
|
|
6066
|
+
fragmentString,
|
|
6067
|
+
"start",
|
|
6068
|
+
entryPoints.fragment
|
|
6069
|
+
) : source4.replace(REGEX_START_OF_MAIN, (match) => match + fragmentString);
|
|
6070
|
+
}
|
|
6071
|
+
break;
|
|
6072
|
+
// inject code at the end of main function
|
|
6073
|
+
case "fs:#main-end":
|
|
6074
|
+
if (language === "wgsl" || !isVertex) {
|
|
6075
|
+
source4 = language === "wgsl" ? injectWGSLStageMain(source4, "fragment", fragmentString, "end", entryPoints.fragment) : source4.replace(REGEX_END_OF_MAIN, (match) => fragmentString + match);
|
|
6076
|
+
}
|
|
6077
|
+
break;
|
|
6078
|
+
default:
|
|
6079
|
+
source4 = source4.replace(key, (match) => match + fragmentString);
|
|
6080
|
+
}
|
|
6081
|
+
}
|
|
6082
|
+
source4 = source4.replace(DECLARATION_INJECT_MARKER, "");
|
|
6083
|
+
if (injectStandardStubs) {
|
|
6084
|
+
source4 = source4.replace(/\}\s*$/, (match) => match + MODULE_INJECTORS[stage]);
|
|
6085
|
+
}
|
|
6086
|
+
return source4;
|
|
6087
|
+
}
|
|
6088
|
+
function injectWGSLStageMain(source4, stage, fragmentString, position, entryPoint) {
|
|
6089
|
+
const bodyRange = getWGSLStageFunctionBodyRange(source4, stage, entryPoint);
|
|
6090
|
+
if (!bodyRange) {
|
|
6091
|
+
return source4;
|
|
6092
|
+
}
|
|
6093
|
+
if (position === "start") {
|
|
6094
|
+
const insertionIndex = bodyRange.openBraceIndex + 1;
|
|
6095
|
+
return `${source4.slice(0, insertionIndex)}
|
|
6096
|
+
${fragmentString}${source4.slice(insertionIndex)}`;
|
|
6097
|
+
}
|
|
6098
|
+
return `${source4.slice(0, bodyRange.closeBraceIndex)}${fragmentString}${source4.slice(
|
|
6099
|
+
bodyRange.closeBraceIndex
|
|
6100
|
+
)}`;
|
|
6101
|
+
}
|
|
6102
|
+
function getWGSLStageFunctionBodyRange(source4, stage, entryPoint) {
|
|
6103
|
+
const stageAttribute = stage === "vertex" ? "@vertex" : "@fragment";
|
|
6104
|
+
const stageIndex = source4.indexOf(stageAttribute);
|
|
6105
|
+
if (stageIndex < 0) {
|
|
6106
|
+
return null;
|
|
6107
|
+
}
|
|
6108
|
+
const functionIndex = entryPoint ? source4.search(new RegExp(`\\bfn\\s+${escapeRegExp(entryPoint)}\\s*\\(`)) : source4.indexOf("fn", stageIndex);
|
|
6109
|
+
if (functionIndex < 0) {
|
|
6110
|
+
return null;
|
|
6111
|
+
}
|
|
6112
|
+
const openBraceIndex = source4.indexOf("{", functionIndex);
|
|
6113
|
+
if (openBraceIndex < 0) {
|
|
6114
|
+
return null;
|
|
6115
|
+
}
|
|
6116
|
+
let braceDepth = 0;
|
|
6117
|
+
for (let index = openBraceIndex; index < source4.length; index++) {
|
|
6118
|
+
const character = source4[index];
|
|
6119
|
+
if (character === "{") {
|
|
6120
|
+
braceDepth++;
|
|
6121
|
+
} else if (character === "}") {
|
|
6122
|
+
braceDepth--;
|
|
6123
|
+
if (braceDepth === 0) {
|
|
6124
|
+
return { openBraceIndex, closeBraceIndex: index };
|
|
6125
|
+
}
|
|
6126
|
+
}
|
|
6127
|
+
}
|
|
6128
|
+
return null;
|
|
6129
|
+
}
|
|
6130
|
+
function escapeRegExp(value) {
|
|
6131
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
6132
|
+
}
|
|
6133
|
+
|
|
6141
6134
|
// ../shaders/src/lib/shader-module/shader-module-uniform-layout.ts
|
|
6142
6135
|
var GLSL_UNIFORM_BLOCK_FIELD_REGEXP = /^(?:uniform\s+)?(?:(?:lowp|mediump|highp)\s+)?[A-Za-z0-9_]+(?:<[^>]+>)?\s+([A-Za-z0-9_]+)(?:\s*\[[^\]]+\])?\s*;/;
|
|
6143
6136
|
var GLSL_UNIFORM_BLOCK_REGEXP = /((?:layout\s*\([^)]*\)\s*)*)uniform\s+([A-Za-z_][A-Za-z0-9_]*)\s*\{([\s\S]*?)\}\s*([A-Za-z_][A-Za-z0-9_]*)?\s*;/g;
|
|
@@ -6414,8 +6407,10 @@ ${DECLARATION_INJECT_MARKER}
|
|
|
6414
6407
|
let result = "";
|
|
6415
6408
|
for (const hookName in hookFunctions) {
|
|
6416
6409
|
const hookFunction = hookFunctions[hookName];
|
|
6417
|
-
const
|
|
6418
|
-
|
|
6410
|
+
const returnType = hookFunction.returnType || "void";
|
|
6411
|
+
const functionPrefix = shaderLanguage === "wgsl" ? "fn" : returnType;
|
|
6412
|
+
const returnSuffix = shaderLanguage === "wgsl" && returnType !== "void" ? ` -> ${returnType}` : "";
|
|
6413
|
+
result += `${functionPrefix} ${hookFunction.signature}${returnSuffix} {
|
|
6419
6414
|
`;
|
|
6420
6415
|
if (hookFunction.header) {
|
|
6421
6416
|
result += ` ${hookFunction.header}`;
|
|
@@ -6435,10 +6430,29 @@ ${DECLARATION_INJECT_MARKER}
|
|
|
6435
6430
|
}
|
|
6436
6431
|
return result;
|
|
6437
6432
|
}
|
|
6438
|
-
function normalizeShaderHooks(hookFunctions) {
|
|
6433
|
+
function normalizeShaderHooks(hookFunctions, pluginHooks = [], language = "glsl") {
|
|
6439
6434
|
const result = { vertex: {}, fragment: {} };
|
|
6440
|
-
for (const
|
|
6441
|
-
|
|
6435
|
+
for (const hook of hookFunctions) {
|
|
6436
|
+
const implementation = hook[language];
|
|
6437
|
+
if (implementation) {
|
|
6438
|
+
const prefix = hook.stage === "vertex" ? "vs" : "fs";
|
|
6439
|
+
result[hook.stage][`${prefix}:${hook.name}`] = {
|
|
6440
|
+
...implementation,
|
|
6441
|
+
signature: `${hook.name}(${implementation.parameters})`
|
|
6442
|
+
};
|
|
6443
|
+
}
|
|
6444
|
+
}
|
|
6445
|
+
for (const hook of pluginHooks) {
|
|
6446
|
+
const selected = normalizeShaderHooks([hook], [], language);
|
|
6447
|
+
for (const stage of ["vertex", "fragment"]) {
|
|
6448
|
+
for (const [name, declaration] of Object.entries(selected[stage])) {
|
|
6449
|
+
const existing = result[stage][name];
|
|
6450
|
+
if (existing && (existing.signature !== declaration.signature || (existing.returnType || "void") !== (declaration.returnType || "void"))) {
|
|
6451
|
+
throw new Error(`Conflicting ShaderPlugin hook ${name}`);
|
|
6452
|
+
}
|
|
6453
|
+
result[stage][name] = existing || declaration;
|
|
6454
|
+
}
|
|
6455
|
+
}
|
|
6442
6456
|
}
|
|
6443
6457
|
return result;
|
|
6444
6458
|
}
|
|
@@ -6462,30 +6476,6 @@ ${DECLARATION_INJECT_MARKER}
|
|
|
6462
6476
|
}
|
|
6463
6477
|
}
|
|
6464
6478
|
}
|
|
6465
|
-
function addShaderHookToRegistry(registry, hookFunction) {
|
|
6466
|
-
const options = typeof hookFunction === "string" ? {} : hookFunction;
|
|
6467
|
-
const hook = (typeof hookFunction === "string" ? hookFunction : hookFunction.hook).trim();
|
|
6468
|
-
const stageSeparatorIndex = hook.indexOf(":");
|
|
6469
|
-
const shaderStage = hook.slice(0, stageSeparatorIndex);
|
|
6470
|
-
const signature = hook.slice(stageSeparatorIndex + 1);
|
|
6471
|
-
const name = hook.replace(/\(.+/, "");
|
|
6472
|
-
const normalizedHook = {
|
|
6473
|
-
hook: name,
|
|
6474
|
-
signature,
|
|
6475
|
-
header: options.header || "",
|
|
6476
|
-
footer: options.footer || ""
|
|
6477
|
-
};
|
|
6478
|
-
switch (shaderStage) {
|
|
6479
|
-
case "vs":
|
|
6480
|
-
registry.vertex[name] = normalizedHook;
|
|
6481
|
-
break;
|
|
6482
|
-
case "fs":
|
|
6483
|
-
registry.fragment[name] = normalizedHook;
|
|
6484
|
-
break;
|
|
6485
|
-
default:
|
|
6486
|
-
throw new Error(shaderStage);
|
|
6487
|
-
}
|
|
6488
|
-
}
|
|
6489
6479
|
|
|
6490
6480
|
// ../shaders/src/lib/glsl-utils/get-shader-info.ts
|
|
6491
6481
|
function getShaderInfo(source4, defaultName) {
|
|
@@ -7737,13 +7727,16 @@ ${getApplicationDefines(allDefines)}
|
|
|
7737
7727
|
`;
|
|
7738
7728
|
break;
|
|
7739
7729
|
}
|
|
7740
|
-
const hookFunctionMap = normalizeShaderHooks(hookFunctions);
|
|
7730
|
+
const hookFunctionMap = normalizeShaderHooks(hookFunctions, options.pluginHooks, "glsl");
|
|
7741
7731
|
const hookInjections = {};
|
|
7742
7732
|
const declInjections = {};
|
|
7743
7733
|
const mainInjections = {};
|
|
7744
7734
|
appendInjections(pluginInjections, hookInjections, declInjections, mainInjections);
|
|
7745
|
-
|
|
7746
|
-
|
|
7735
|
+
const applicationInjections = Array.isArray(inject) ? resolveShaderInjections(inject, "glsl") : {};
|
|
7736
|
+
appendInjections(applicationInjections, hookInjections, declInjections, mainInjections);
|
|
7737
|
+
const injectionMap = Array.isArray(inject) ? {} : inject;
|
|
7738
|
+
for (const key in injectionMap) {
|
|
7739
|
+
const injection = typeof injectionMap[key] === "string" ? { injection: injectionMap[key], order: 0 } : injectionMap[key];
|
|
7747
7740
|
const match = /^(v|f)s:(#)?([\w-]+)$/.exec(key);
|
|
7748
7741
|
if (match) {
|
|
7749
7742
|
const hash = match[2];
|
|
@@ -7788,19 +7781,6 @@ ${getApplicationDefines(allDefines)}
|
|
|
7788
7781
|
}
|
|
7789
7782
|
const moduleSource = getShaderModuleSource(module, stage, log8);
|
|
7790
7783
|
assembledSource += moduleSource;
|
|
7791
|
-
const injections = module.instance?.normalizedInjections[stage] || {};
|
|
7792
|
-
for (const key in injections) {
|
|
7793
|
-
const match = /^(v|f)s:#([\w-]+)$/.exec(key);
|
|
7794
|
-
if (match) {
|
|
7795
|
-
const name = match[2];
|
|
7796
|
-
const injectionType = name === "decl" ? declInjections : mainInjections;
|
|
7797
|
-
injectionType[key] = injectionType[key] || [];
|
|
7798
|
-
injectionType[key].push(injections[key]);
|
|
7799
|
-
} else {
|
|
7800
|
-
hookInjections[key] = hookInjections[key] || [];
|
|
7801
|
-
hookInjections[key].push(injections[key]);
|
|
7802
|
-
}
|
|
7803
|
-
}
|
|
7804
7784
|
}
|
|
7805
7785
|
validateShaderHookInjections(hookFunctionMap, hookInjections, stage);
|
|
7806
7786
|
assembledSource += "// ----- MAIN SHADER SOURCE -------------------------";
|
|
@@ -8673,13 +8653,16 @@ ${getApplicationDefines(allDefines)}
|
|
|
8673
8653
|
);
|
|
8674
8654
|
const coreSource = pluginVaryingAssembly.source;
|
|
8675
8655
|
let assembledSource = "";
|
|
8676
|
-
const hookFunctionMap = normalizeShaderHooks(hookFunctions);
|
|
8656
|
+
const hookFunctionMap = normalizeShaderHooks(hookFunctions, options.pluginHooks, "wgsl");
|
|
8677
8657
|
const hookInjections = {};
|
|
8678
8658
|
const declInjections = {};
|
|
8679
8659
|
const mainInjections = {};
|
|
8680
8660
|
appendInjections(pluginInjections, hookInjections, declInjections, mainInjections);
|
|
8681
|
-
|
|
8682
|
-
|
|
8661
|
+
const applicationInjections = Array.isArray(inject) ? resolveShaderInjections(inject, "wgsl") : {};
|
|
8662
|
+
appendInjections(applicationInjections, hookInjections, declInjections, mainInjections);
|
|
8663
|
+
const injectionMap = Array.isArray(inject) ? {} : inject;
|
|
8664
|
+
for (const key in injectionMap) {
|
|
8665
|
+
const injection = typeof injectionMap[key] === "string" ? { injection: injectionMap[key], order: 0 } : injectionMap[key];
|
|
8683
8666
|
const match = /^(v|f)s:(#)?([\w-]+)$/.exec(key);
|
|
8684
8667
|
if (match) {
|
|
8685
8668
|
const hash = match[2];
|
|
@@ -8733,19 +8716,6 @@ ${getApplicationDefines(allDefines)}
|
|
|
8733
8716
|
checkShaderModuleDeprecations(module, coreSource, log8);
|
|
8734
8717
|
}
|
|
8735
8718
|
assembledSource += moduleSource;
|
|
8736
|
-
const injections = getWGSLModuleInjections(module);
|
|
8737
|
-
for (const key in injections) {
|
|
8738
|
-
const match = /^(v|f)s:#([\w-]+)$/.exec(key);
|
|
8739
|
-
if (match) {
|
|
8740
|
-
const name = match[2];
|
|
8741
|
-
const injectionType = name === "decl" ? declInjections : mainInjections;
|
|
8742
|
-
injectionType[key] = injectionType[key] || [];
|
|
8743
|
-
injectionType[key].push(injections[key]);
|
|
8744
|
-
} else if (isShaderHookRegistered(hookFunctionMap, key)) {
|
|
8745
|
-
hookInjections[key] = hookInjections[key] || [];
|
|
8746
|
-
hookInjections[key].push(injections[key]);
|
|
8747
|
-
}
|
|
8748
|
-
}
|
|
8749
8719
|
}
|
|
8750
8720
|
assembledSource += INJECT_SHADER_DECLARATIONS;
|
|
8751
8721
|
assembledSource = injectShader(
|
|
@@ -8805,12 +8775,6 @@ ${getApplicationDefines(allDefines)}
|
|
|
8805
8775
|
});
|
|
8806
8776
|
}
|
|
8807
8777
|
}
|
|
8808
|
-
function getWGSLModuleInjections(module) {
|
|
8809
|
-
return {
|
|
8810
|
-
...module.instance?.normalizedInjections.vertex || {},
|
|
8811
|
-
...module.instance?.normalizedInjections.fragment || {}
|
|
8812
|
-
};
|
|
8813
|
-
}
|
|
8814
8778
|
function getWGSLDeclarationInjections(declarationInjections) {
|
|
8815
8779
|
const unifiedDeclarations = [
|
|
8816
8780
|
...declarationInjections["vs:#decl"] || [],
|
|
@@ -9207,6 +9171,50 @@ ${getApplicationDefines(allDefines)}
|
|
|
9207
9171
|
}
|
|
9208
9172
|
};
|
|
9209
9173
|
|
|
9174
|
+
// src/model/batch-uniform-buffer.ts
|
|
9175
|
+
var import_core7 = __toESM(require_core(), 1);
|
|
9176
|
+
var BatchUniformBuffer = class {
|
|
9177
|
+
constructor(device) {
|
|
9178
|
+
this.device = device;
|
|
9179
|
+
}
|
|
9180
|
+
device;
|
|
9181
|
+
buffer;
|
|
9182
|
+
byteOffset = 0;
|
|
9183
|
+
/** Reserves the entire call before drawing, so growth cannot invalidate an earlier batch. */
|
|
9184
|
+
prepare(byteLength) {
|
|
9185
|
+
if (!this.buffer || this.buffer.byteLength < byteLength) {
|
|
9186
|
+
const capacity = Math.max(1024, (this.buffer?.byteLength ?? 0) * 2, byteLength);
|
|
9187
|
+
const buffer = this.device.createBuffer({
|
|
9188
|
+
id: "batch-uniforms",
|
|
9189
|
+
byteLength: capacity,
|
|
9190
|
+
usage: import_core7.Buffer.UNIFORM | import_core7.Buffer.COPY_DST
|
|
9191
|
+
});
|
|
9192
|
+
this.buffer?.destroy();
|
|
9193
|
+
this.buffer = buffer;
|
|
9194
|
+
}
|
|
9195
|
+
this.byteOffset = 0;
|
|
9196
|
+
}
|
|
9197
|
+
/** Returns the aligned slot size required for a uniform block. */
|
|
9198
|
+
getAlignedByteLength(byteLength) {
|
|
9199
|
+
const alignment = this.device.limits.minUniformBufferOffsetAlignment || 1;
|
|
9200
|
+
return Math.ceil(byteLength / alignment) * alignment;
|
|
9201
|
+
}
|
|
9202
|
+
/** Writes one slot without overwriting earlier batches in this call. */
|
|
9203
|
+
write(data) {
|
|
9204
|
+
(0, import_core7.assert)(this.buffer && this.byteOffset + data.byteLength <= this.buffer.byteLength);
|
|
9205
|
+
const binding = { buffer: this.buffer, offset: this.byteOffset, size: data.byteLength };
|
|
9206
|
+
this.buffer.write(data, binding.offset);
|
|
9207
|
+
this.byteOffset += this.getAlignedByteLength(data.byteLength);
|
|
9208
|
+
return binding;
|
|
9209
|
+
}
|
|
9210
|
+
/** Releases the model-owned allocation. */
|
|
9211
|
+
destroy() {
|
|
9212
|
+
this.buffer?.destroy();
|
|
9213
|
+
this.buffer = void 0;
|
|
9214
|
+
this.byteOffset = 0;
|
|
9215
|
+
}
|
|
9216
|
+
};
|
|
9217
|
+
|
|
9210
9218
|
// src/debug/debug-shader-layout.ts
|
|
9211
9219
|
function getDebugTableForShaderLayout(layout, name) {
|
|
9212
9220
|
const table = {};
|
|
@@ -9371,7 +9379,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
9371
9379
|
}
|
|
9372
9380
|
|
|
9373
9381
|
// src/utils/buffer-layout-helper.ts
|
|
9374
|
-
var
|
|
9382
|
+
var import_core8 = __toESM(require_core(), 1);
|
|
9375
9383
|
var BufferLayoutHelper = class {
|
|
9376
9384
|
bufferLayouts;
|
|
9377
9385
|
constructor(bufferLayouts) {
|
|
@@ -9382,7 +9390,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
9382
9390
|
}
|
|
9383
9391
|
/** Get attribute names from a BufferLayout */
|
|
9384
9392
|
getAttributeNamesForBuffer(bufferLayout) {
|
|
9385
|
-
return (0,
|
|
9393
|
+
return (0, import_core8.getBufferLayoutAttributeNames)(bufferLayout);
|
|
9386
9394
|
}
|
|
9387
9395
|
mergeBufferLayouts(bufferLayouts1, bufferLayouts2) {
|
|
9388
9396
|
const mergedLayouts = [...bufferLayouts1];
|
|
@@ -9399,16 +9407,16 @@ ${getApplicationDefines(allDefines)}
|
|
|
9399
9407
|
};
|
|
9400
9408
|
|
|
9401
9409
|
// src/utils/buffer-layout-order.ts
|
|
9402
|
-
var
|
|
9410
|
+
var import_core9 = __toESM(require_core(), 1);
|
|
9403
9411
|
function sortedBufferLayoutByShaderSourceLocations(shaderLayout, bufferLayout) {
|
|
9404
|
-
const shaderLayoutMap = (0,
|
|
9412
|
+
const shaderLayoutMap = (0, import_core9.getShaderAttributeLocationMap)(shaderLayout);
|
|
9405
9413
|
const sortedLayout = bufferLayout.slice();
|
|
9406
9414
|
sortedLayout.sort((a, b) => {
|
|
9407
|
-
const minLocationA = (0,
|
|
9408
|
-
(0,
|
|
9415
|
+
const minLocationA = (0, import_core9.getMinimumAttributeLocation)(
|
|
9416
|
+
(0, import_core9.getBufferLayoutAttributeNames)(a).map((attributeName) => shaderLayoutMap[attributeName])
|
|
9409
9417
|
);
|
|
9410
|
-
const minLocationB = (0,
|
|
9411
|
-
(0,
|
|
9418
|
+
const minLocationB = (0, import_core9.getMinimumAttributeLocation)(
|
|
9419
|
+
(0, import_core9.getBufferLayoutAttributeNames)(b).map((attributeName) => shaderLayoutMap[attributeName])
|
|
9412
9420
|
);
|
|
9413
9421
|
return minLocationA - minLocationB;
|
|
9414
9422
|
});
|
|
@@ -9571,7 +9579,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
9571
9579
|
}
|
|
9572
9580
|
|
|
9573
9581
|
// src/model/gpu-vector-model-batches.ts
|
|
9574
|
-
var
|
|
9582
|
+
var import_core10 = __toESM(require_core(), 1);
|
|
9575
9583
|
function validateGPUVectorModelLayouts(ownerName, vectors, bufferLayouts) {
|
|
9576
9584
|
for (const [name, vector] of Object.entries(vectors)) {
|
|
9577
9585
|
if (!vector) continue;
|
|
@@ -9635,33 +9643,35 @@ ${getApplicationDefines(allDefines)}
|
|
|
9635
9643
|
if (format.includes("<")) {
|
|
9636
9644
|
throw new Error(`${ownerName} GPUVector "${name}" requires a fixed-width scalar format`);
|
|
9637
9645
|
}
|
|
9638
|
-
return
|
|
9646
|
+
return import_core10.vertexFormatDecoder.getVertexFormatInfo(format);
|
|
9639
9647
|
}
|
|
9640
9648
|
|
|
9641
9649
|
// src/utils/gpu-vector-batch-structure.ts
|
|
9642
|
-
var
|
|
9650
|
+
var import_core11 = __toESM(require_core(), 1);
|
|
9643
9651
|
function validateGPUVectorBatchStructure(vectors) {
|
|
9644
9652
|
let reference;
|
|
9645
9653
|
for (const vector of Object.values(vectors)) {
|
|
9646
9654
|
if (!vector || "isConstant" in vector) continue;
|
|
9647
9655
|
let rowCount = 0;
|
|
9648
9656
|
for (const chunk of vector.data) rowCount += chunk.length;
|
|
9649
|
-
(0,
|
|
9657
|
+
(0, import_core11.assert)(rowCount === vector.length);
|
|
9650
9658
|
if (reference) {
|
|
9651
|
-
(0,
|
|
9659
|
+
(0, import_core11.assert)(vector.length === reference.length && vector.data.length === reference.data.length);
|
|
9652
9660
|
for (let batchIndex = 0; batchIndex < vector.data.length; batchIndex++) {
|
|
9653
|
-
(0,
|
|
9661
|
+
(0, import_core11.assert)(vector.data[batchIndex].length === reference.data[batchIndex].length);
|
|
9654
9662
|
}
|
|
9655
9663
|
} else reference = vector;
|
|
9656
9664
|
}
|
|
9657
9665
|
}
|
|
9658
9666
|
|
|
9659
9667
|
// src/model/gpu-vector-draw-batches.ts
|
|
9660
|
-
function drawGPUVectorGroups(model, geometry, attributes, syncBindings, draw) {
|
|
9668
|
+
function drawGPUVectorGroups(model, geometry, attributes, syncBindings, draw, inferDrawCount) {
|
|
9661
9669
|
const geometryInputs = geometry.inputs;
|
|
9662
9670
|
const attributeInputs = attributes.inputs;
|
|
9663
9671
|
const geometryLayouts = geometry.sourceLayouts;
|
|
9664
9672
|
const attributeLayouts = attributes.sourceLayouts;
|
|
9673
|
+
const geometryBatchLayouts = geometry.layouts;
|
|
9674
|
+
const attributeBatchLayouts = attributes.layouts;
|
|
9665
9675
|
const attributeStepMode = attributes.stepMode;
|
|
9666
9676
|
const geometryBatchCount = geometry.batchCount;
|
|
9667
9677
|
const attributeBatchCount = attributes.batchCount;
|
|
@@ -9685,24 +9695,25 @@ ${getApplicationDefines(allDefines)}
|
|
|
9685
9695
|
for (let batchIndex = 0; batchIndex < drawCount; batchIndex++) {
|
|
9686
9696
|
const geometryBatchIndex = independentInstances ? Math.floor(batchIndex / attributeBatchCount) : Math.min(batchIndex, geometryBatchCount - 1);
|
|
9687
9697
|
const attributeBatchIndex = independentInstances ? batchIndex % attributeBatchCount : Math.min(batchIndex, attributeBatchCount - 1);
|
|
9688
|
-
geometry.setInputs(geometryBatches[geometryBatchIndex],
|
|
9698
|
+
geometry.setInputs(geometryBatches[geometryBatchIndex], geometryBatchLayouts, "vertex");
|
|
9689
9699
|
attributes.setInputs(
|
|
9690
9700
|
attributeBatches[attributeBatchIndex],
|
|
9691
|
-
|
|
9701
|
+
attributeBatchLayouts,
|
|
9692
9702
|
attributeStepMode
|
|
9693
9703
|
);
|
|
9694
9704
|
syncBindings();
|
|
9695
9705
|
const vertexOffset = geometry.rowCount !== void 0 ? geometryOffsets[geometryBatchIndex] : attributes.vertexCount !== void 0 ? attributeOffsets[attributeBatchIndex] : 0;
|
|
9696
|
-
|
|
9697
|
-
|
|
9698
|
-
|
|
9699
|
-
|
|
9700
|
-
|
|
9701
|
-
|
|
9706
|
+
if (inferDrawCount === "vertex")
|
|
9707
|
+
model.setVertexCount(
|
|
9708
|
+
Math.max(
|
|
9709
|
+
0,
|
|
9710
|
+
Math.min(
|
|
9711
|
+
geometry.rowCount ?? attributes.vertexCount ?? vertexCount,
|
|
9712
|
+
vertexCount - vertexOffset
|
|
9713
|
+
)
|
|
9702
9714
|
)
|
|
9703
|
-
)
|
|
9704
|
-
)
|
|
9705
|
-
if (attributes.instanceCount !== void 0)
|
|
9715
|
+
);
|
|
9716
|
+
if (inferDrawCount === "instance" && attributes.instanceCount !== void 0)
|
|
9706
9717
|
model.setInstanceCount(
|
|
9707
9718
|
Math.max(
|
|
9708
9719
|
0,
|
|
@@ -9740,7 +9751,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
9740
9751
|
}
|
|
9741
9752
|
|
|
9742
9753
|
// src/model/gpu-vector-bindings.ts
|
|
9743
|
-
var
|
|
9754
|
+
var import_core12 = __toESM(require_core(), 1);
|
|
9744
9755
|
var GPUVectorBindings = class {
|
|
9745
9756
|
constructor(device, id) {
|
|
9746
9757
|
this.device = device;
|
|
@@ -9760,8 +9771,14 @@ ${getApplicationDefines(allDefines)}
|
|
|
9760
9771
|
vertexCount;
|
|
9761
9772
|
instanceCount;
|
|
9762
9773
|
constantBuffers = {};
|
|
9763
|
-
setInputs(columns, explicitLayouts, stepMode) {
|
|
9764
|
-
|
|
9774
|
+
setInputs(columns, explicitLayouts, stepMode, enforceMatchingVectorLengths = true) {
|
|
9775
|
+
if (enforceMatchingVectorLengths) {
|
|
9776
|
+
validateGPUVectorBatchStructure(columns);
|
|
9777
|
+
} else {
|
|
9778
|
+
for (const column of Object.values(columns)) {
|
|
9779
|
+
if (column && !isConstant(column)) (0, import_core12.assert)(column.data.length === 1);
|
|
9780
|
+
}
|
|
9781
|
+
}
|
|
9765
9782
|
this.claimedNames.clear();
|
|
9766
9783
|
this.inputs = columns;
|
|
9767
9784
|
this.sourceLayouts = explicitLayouts;
|
|
@@ -9772,35 +9789,31 @@ ${getApplicationDefines(allDefines)}
|
|
|
9772
9789
|
const providedLayouts = explicitLayouts ?? Object.entries(columns).flatMap(
|
|
9773
9790
|
([name, column]) => column && !isConstant(column) && column.bufferLayout ? [{ ...column.bufferLayout, name }] : []
|
|
9774
9791
|
);
|
|
9775
|
-
const
|
|
9776
|
-
|
|
9777
|
-
|
|
9778
|
-
|
|
9779
|
-
|
|
9780
|
-
|
|
9781
|
-
|
|
9782
|
-
|
|
9783
|
-
|
|
9784
|
-
|
|
9785
|
-
|
|
9786
|
-
{ name, stepMode, byteStride, attributes: [{ attribute: name, format, byteOffset: 0 }] }
|
|
9787
|
-
];
|
|
9788
|
-
})
|
|
9789
|
-
];
|
|
9792
|
+
const inferredLayouts = Object.entries(columns).flatMap(([name, column]) => {
|
|
9793
|
+
if (!column || providedLayouts.some(
|
|
9794
|
+
(layout) => layout.name === name || layout.attributes?.some((attribute) => attribute.attribute === name)
|
|
9795
|
+
))
|
|
9796
|
+
return [];
|
|
9797
|
+
(0, import_core12.assert)(column.format);
|
|
9798
|
+
const format = column.format;
|
|
9799
|
+
const byteStride = isConstant(column) ? 0 : column.byteStride;
|
|
9800
|
+
return [{ name, stepMode, byteStride, attributes: [{ attribute: name, format, byteOffset: 0 }] }];
|
|
9801
|
+
});
|
|
9802
|
+
const layouts = [...providedLayouts, ...consolidateInferredLayouts(columns, inferredLayouts)];
|
|
9790
9803
|
for (const [name, column] of Object.entries(columns)) {
|
|
9791
9804
|
if (!column) continue;
|
|
9792
9805
|
if (!isConstant(column) && !Array.isArray(column.data))
|
|
9793
9806
|
throw new TypeError(`Expected a GPU vector or constant for ${name}`);
|
|
9794
|
-
if (!isConstant(column)) {
|
|
9807
|
+
if (!isConstant(column) && enforceMatchingVectorLengths) {
|
|
9795
9808
|
const layout = layouts.find(
|
|
9796
9809
|
(layout2) => layout2.name === name || layout2.attributes?.some((attribute) => attribute.attribute === name)
|
|
9797
9810
|
);
|
|
9798
9811
|
const mode = layout?.stepMode ?? stepMode;
|
|
9799
9812
|
if (mode === "instance") {
|
|
9800
|
-
(0,
|
|
9813
|
+
(0, import_core12.assert)(this.instanceCount === void 0 || this.instanceCount === column.length);
|
|
9801
9814
|
this.instanceCount = column.length;
|
|
9802
9815
|
} else {
|
|
9803
|
-
(0,
|
|
9816
|
+
(0, import_core12.assert)(this.vertexCount === void 0 || this.vertexCount === column.length);
|
|
9804
9817
|
this.vertexCount = column.length;
|
|
9805
9818
|
}
|
|
9806
9819
|
this.rowCount = stepMode === "instance" ? this.instanceCount : this.vertexCount;
|
|
@@ -9845,7 +9858,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
9845
9858
|
for (const definition of definitions) {
|
|
9846
9859
|
const column = columns[definition.attribute] ?? (definition.attribute === layout.name ? columns[layout.name] : void 0);
|
|
9847
9860
|
if (!column) continue;
|
|
9848
|
-
(0,
|
|
9861
|
+
(0, import_core12.assert)(column.format === void 0 || column.format === definition.format);
|
|
9849
9862
|
if (isConstant(column)) {
|
|
9850
9863
|
this.constants[definition.attribute] = getShaderConstant(column);
|
|
9851
9864
|
constantByteLength = Math.max(
|
|
@@ -9872,7 +9885,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
9872
9885
|
buffer = this.device.createBuffer({
|
|
9873
9886
|
id: `${this.id}-${layout.name}-constant`,
|
|
9874
9887
|
byteLength: bytes.byteLength,
|
|
9875
|
-
usage:
|
|
9888
|
+
usage: import_core12.Buffer.VERTEX | import_core12.Buffer.COPY_DST | import_core12.Buffer.COPY_SRC
|
|
9876
9889
|
});
|
|
9877
9890
|
this.constantBuffers[layout.name] = buffer;
|
|
9878
9891
|
}
|
|
@@ -9909,7 +9922,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
9909
9922
|
const chunk = vector.data[0];
|
|
9910
9923
|
if (!chunk) return;
|
|
9911
9924
|
const byteOffset = chunk.byteOffset - layoutOffset;
|
|
9912
|
-
(0,
|
|
9925
|
+
(0, import_core12.assert)(byteOffset >= 0);
|
|
9913
9926
|
this.buffers[name] = chunk.buffer;
|
|
9914
9927
|
this.byteOffsets[name] = byteOffset;
|
|
9915
9928
|
}
|
|
@@ -9918,7 +9931,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
9918
9931
|
return Boolean(column && "isConstant" in column && column.isConstant);
|
|
9919
9932
|
}
|
|
9920
9933
|
function getShaderConstant(column) {
|
|
9921
|
-
const information =
|
|
9934
|
+
const information = import_core12.vertexFormatDecoder.getVertexFormatInfo(column.format);
|
|
9922
9935
|
if (column.format === "unorm10-10-10-2") {
|
|
9923
9936
|
const word = column.value[0];
|
|
9924
9937
|
return new Float32Array([
|
|
@@ -9943,9 +9956,52 @@ ${getApplicationDefines(allDefines)}
|
|
|
9943
9956
|
return information.signed ? new Int32Array(values) : new Uint32Array(values);
|
|
9944
9957
|
return new Float32Array(values);
|
|
9945
9958
|
}
|
|
9959
|
+
function consolidateInferredLayouts(columns, layouts) {
|
|
9960
|
+
const result = [];
|
|
9961
|
+
let constantLayout;
|
|
9962
|
+
let constantByteLength = 0;
|
|
9963
|
+
const sortedLayouts = [...layouts].sort((left, right) => {
|
|
9964
|
+
const leftColumn = columns[left.name];
|
|
9965
|
+
const rightColumn = columns[right.name];
|
|
9966
|
+
return (leftColumn && !isConstant(leftColumn) ? leftColumn.data[0]?.byteOffset ?? 0 : 0) - (rightColumn && !isConstant(rightColumn) ? rightColumn.data[0]?.byteOffset ?? 0 : 0);
|
|
9967
|
+
});
|
|
9968
|
+
for (const layout of sortedLayouts) {
|
|
9969
|
+
const column = columns[layout.name];
|
|
9970
|
+
const attribute = layout.attributes[0];
|
|
9971
|
+
if (isConstant(column)) {
|
|
9972
|
+
if (!constantLayout) {
|
|
9973
|
+
constantLayout = { ...layout, attributes: [] };
|
|
9974
|
+
result.push(constantLayout);
|
|
9975
|
+
}
|
|
9976
|
+
const alignment = Math.min(4, column.byteLength);
|
|
9977
|
+
constantByteLength = Math.ceil(constantByteLength / alignment) * alignment;
|
|
9978
|
+
constantLayout.attributes.push({ ...attribute, byteOffset: constantByteLength });
|
|
9979
|
+
constantByteLength += column.byteLength;
|
|
9980
|
+
continue;
|
|
9981
|
+
}
|
|
9982
|
+
const sharedLayout = result.find((candidate) => {
|
|
9983
|
+
const primary = columns[candidate.name];
|
|
9984
|
+
if (!primary || isConstant(primary) || !primary.data.length || !column.data.length)
|
|
9985
|
+
return false;
|
|
9986
|
+
const offset = column.data[0].byteOffset - primary.data[0].byteOffset;
|
|
9987
|
+
return candidate.stepMode === layout.stepMode && candidate.byteStride === layout.byteStride && offset >= 0 && offset + column.rowByteLength <= column.byteStride && column.data.every((chunk, index) => {
|
|
9988
|
+
const primaryChunk = primary.data[index];
|
|
9989
|
+
return chunk.buffer === primaryChunk.buffer && chunk.byteStride === primaryChunk.byteStride && chunk.byteOffset - primaryChunk.byteOffset === offset;
|
|
9990
|
+
});
|
|
9991
|
+
});
|
|
9992
|
+
if (sharedLayout) {
|
|
9993
|
+
const primary = columns[sharedLayout.name];
|
|
9994
|
+
sharedLayout.attributes.push({
|
|
9995
|
+
...attribute,
|
|
9996
|
+
byteOffset: column.data[0].byteOffset - primary.data[0].byteOffset
|
|
9997
|
+
});
|
|
9998
|
+
} else result.push({ ...layout, attributes: [...layout.attributes] });
|
|
9999
|
+
}
|
|
10000
|
+
return result;
|
|
10001
|
+
}
|
|
9946
10002
|
|
|
9947
10003
|
// src/shader-inputs.ts
|
|
9948
|
-
var
|
|
10004
|
+
var import_core13 = __toESM(require_core(), 1);
|
|
9949
10005
|
var import_shaders2 = __toESM(require_shaders(), 1);
|
|
9950
10006
|
|
|
9951
10007
|
// src/model/split-uniforms-and-bindings.ts
|
|
@@ -9995,7 +10051,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
9995
10051
|
for (const resolvedModule of resolvedModules) {
|
|
9996
10052
|
modules[resolvedModule.name] = resolvedModule;
|
|
9997
10053
|
}
|
|
9998
|
-
|
|
10054
|
+
import_core13.log.log(1, "Creating ShaderInputs with modules", Object.keys(modules))();
|
|
9999
10055
|
this.modules = modules;
|
|
10000
10056
|
this.moduleUniforms = {};
|
|
10001
10057
|
this.moduleBindings = {};
|
|
@@ -10003,7 +10059,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
10003
10059
|
if (module) {
|
|
10004
10060
|
this._addModule(module);
|
|
10005
10061
|
if (module.name && name !== module.name && !this.options.disableWarnings) {
|
|
10006
|
-
|
|
10062
|
+
import_core13.log.warn(`Module name: ${name} vs ${module.name}`)();
|
|
10007
10063
|
}
|
|
10008
10064
|
}
|
|
10009
10065
|
}
|
|
@@ -10027,7 +10083,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
10027
10083
|
const module = this.modules[moduleName];
|
|
10028
10084
|
if (!module) {
|
|
10029
10085
|
if (!this.options.disableWarnings) {
|
|
10030
|
-
|
|
10086
|
+
import_core13.log.warn(`Module ${name} not found`)();
|
|
10031
10087
|
}
|
|
10032
10088
|
} else {
|
|
10033
10089
|
const oldUniforms = this.moduleUniforms[moduleName];
|
|
@@ -10222,7 +10278,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
10222
10278
|
var VERSION = true ? "5.0.0" : "untranspiled source";
|
|
10223
10279
|
|
|
10224
10280
|
// ../../node_modules/probe.gl/dist/log/utils/assert.js
|
|
10225
|
-
function
|
|
10281
|
+
function assert7(condition, message) {
|
|
10226
10282
|
if (!condition) {
|
|
10227
10283
|
throw new Error(message || "Assertion failed");
|
|
10228
10284
|
}
|
|
@@ -10244,7 +10300,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
10244
10300
|
default:
|
|
10245
10301
|
return 0;
|
|
10246
10302
|
}
|
|
10247
|
-
|
|
10303
|
+
assert7(Number.isFinite(resolvedLevel) && resolvedLevel >= 0);
|
|
10248
10304
|
return resolvedLevel;
|
|
10249
10305
|
}
|
|
10250
10306
|
function normalizeArguments(opts) {
|
|
@@ -10270,7 +10326,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
10270
10326
|
opts.message = opts.message();
|
|
10271
10327
|
}
|
|
10272
10328
|
const messageType = typeof opts.message;
|
|
10273
|
-
|
|
10329
|
+
assert7(messageType === "string" || messageType === "object");
|
|
10274
10330
|
return Object.assign(opts, { args }, opts.opts);
|
|
10275
10331
|
}
|
|
10276
10332
|
|
|
@@ -10686,7 +10742,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
10686
10742
|
}
|
|
10687
10743
|
_emit(_type, normalized2) {
|
|
10688
10744
|
const method = normalized2.method;
|
|
10689
|
-
|
|
10745
|
+
assert7(method);
|
|
10690
10746
|
normalized2.total = this.getTotal();
|
|
10691
10747
|
normalized2.delta = this.getDelta();
|
|
10692
10748
|
this._deltaTs = probe.getHighResolutionTimer();
|
|
@@ -11112,7 +11168,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
11112
11168
|
}
|
|
11113
11169
|
|
|
11114
11170
|
// ../core/src/api/adapter/resources/buffer.ts
|
|
11115
|
-
var
|
|
11171
|
+
var Buffer4 = class _Buffer extends Resource {
|
|
11116
11172
|
/** Index buffer */
|
|
11117
11173
|
static INDEX = 16;
|
|
11118
11174
|
/** Vertex buffer */
|
|
@@ -11494,6 +11550,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
11494
11550
|
"pvrtc-rgb2unorm-webgl": { f: texture_compression_pvrtc_webgl },
|
|
11495
11551
|
"pvrtc-rgba2unorm-webgl": { f: texture_compression_pvrtc_webgl },
|
|
11496
11552
|
// WEBGL_compressed_texture_etc1
|
|
11553
|
+
"etc1-rgb-unorm-webgl": { f: texture_compression_etc1_webgl },
|
|
11497
11554
|
"etc1-rbg-unorm-webgl": { f: texture_compression_etc1_webgl },
|
|
11498
11555
|
// WEBGL_compressed_texture_atc
|
|
11499
11556
|
"atc-rgb-unorm-webgl": { f: texture_compression_atc_webgl },
|
|
@@ -12293,7 +12350,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
12293
12350
|
}
|
|
12294
12351
|
|
|
12295
12352
|
// ../core/src/dynamic/dynamic-buffer/dynamic-buffer.ts
|
|
12296
|
-
var DEFAULT_MAX_DEBUG_DATA_BYTE_LENGTH =
|
|
12353
|
+
var DEFAULT_MAX_DEBUG_DATA_BYTE_LENGTH = Buffer4.DEBUG_DATA_MAX_LENGTH;
|
|
12297
12354
|
var DynamicBuffer = class {
|
|
12298
12355
|
/** Device that owns the backing buffer. */
|
|
12299
12356
|
device;
|
|
@@ -12360,7 +12417,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
12360
12417
|
usage: bufferProps.usage ?? adoptedBuffer?.usage,
|
|
12361
12418
|
indexType: bufferProps.indexType ?? adoptedBuffer?.indexType
|
|
12362
12419
|
};
|
|
12363
|
-
if ((normalizedBufferProps.usage || 0) &
|
|
12420
|
+
if ((normalizedBufferProps.usage || 0) & Buffer4.INDEX && !normalizedBufferProps.indexType) {
|
|
12364
12421
|
if (bufferProps.data instanceof Uint32Array) {
|
|
12365
12422
|
normalizedBufferProps.indexType = "uint32";
|
|
12366
12423
|
} else if (bufferProps.data instanceof Uint16Array) {
|
|
@@ -12930,7 +12987,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
12930
12987
|
const layout = this.texture.computeMemoryLayout({ width, height, depthOrArrayLayers });
|
|
12931
12988
|
const buffer = this.device.createBuffer({
|
|
12932
12989
|
byteLength: layout.byteLength,
|
|
12933
|
-
usage:
|
|
12990
|
+
usage: Buffer4.COPY_DST | Buffer4.MAP_READ
|
|
12934
12991
|
});
|
|
12935
12992
|
this.texture.readBuffer(
|
|
12936
12993
|
{
|
|
@@ -13294,13 +13351,13 @@ ${getApplicationDefines(allDefines)}
|
|
|
13294
13351
|
var GPUVectorModel = class _GPUVectorModel {
|
|
13295
13352
|
/** Creates a model while allowing the backend to compile its render pipeline asynchronously. */
|
|
13296
13353
|
static async createAsync(device, props) {
|
|
13297
|
-
const ownsCompilation = !
|
|
13298
|
-
const asyncCompilation = ownsCompilation ?
|
|
13354
|
+
const ownsCompilation = !import_core14.PipelineFactory.getAsyncCompilation(device);
|
|
13355
|
+
const asyncCompilation = ownsCompilation ? import_core14.PipelineFactory.beginAsyncCompilation(device) : import_core14.PipelineFactory.getAsyncCompilation(device);
|
|
13299
13356
|
let model;
|
|
13300
13357
|
try {
|
|
13301
13358
|
model = new this(device, props);
|
|
13302
13359
|
} finally {
|
|
13303
|
-
if (ownsCompilation)
|
|
13360
|
+
if (ownsCompilation) import_core14.PipelineFactory.endAsyncCompilation(device, asyncCompilation);
|
|
13304
13361
|
}
|
|
13305
13362
|
try {
|
|
13306
13363
|
if (ownsCompilation) {
|
|
@@ -13315,8 +13372,9 @@ ${getApplicationDefines(allDefines)}
|
|
|
13315
13372
|
}
|
|
13316
13373
|
}
|
|
13317
13374
|
static defaultProps = {
|
|
13318
|
-
...
|
|
13319
|
-
|
|
13375
|
+
...import_core14.RenderPipeline.defaultProps,
|
|
13376
|
+
inferDrawCount: "no",
|
|
13377
|
+
enforceMatchingVectorLengths: true,
|
|
13320
13378
|
geometry: null,
|
|
13321
13379
|
attributeVectors: void 0,
|
|
13322
13380
|
source: void 0,
|
|
@@ -13413,6 +13471,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
13413
13471
|
_uniformStore;
|
|
13414
13472
|
_attributeInfos = {};
|
|
13415
13473
|
props;
|
|
13474
|
+
batchUniformBuffer;
|
|
13416
13475
|
geometryVectorBindings;
|
|
13417
13476
|
attributeVectorBindings;
|
|
13418
13477
|
explicitBufferLayout = [];
|
|
@@ -13497,7 +13556,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
13497
13556
|
const isWebGPU = this.device.type === "webgpu";
|
|
13498
13557
|
if (isWebGPU && this.props.source) {
|
|
13499
13558
|
const shaderAssembler = this.props.shaderAssembler;
|
|
13500
|
-
(0,
|
|
13559
|
+
(0, import_core14.assert)(isShaderAssemblerForLanguage(shaderAssembler, "wgsl"));
|
|
13501
13560
|
const {
|
|
13502
13561
|
source: source4,
|
|
13503
13562
|
getUniforms: getUniforms2,
|
|
@@ -13509,6 +13568,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
13509
13568
|
...this.props,
|
|
13510
13569
|
modules,
|
|
13511
13570
|
defines,
|
|
13571
|
+
pluginHooks: resolvedPlugins.hooks,
|
|
13512
13572
|
pluginInjections: resolvedPlugins.injections,
|
|
13513
13573
|
pluginVertexInputs: resolvedPlugins.vertexInputs,
|
|
13514
13574
|
pluginInterStageVariables: resolvedPlugins.interStageVariables
|
|
@@ -13533,12 +13593,13 @@ ${getApplicationDefines(allDefines)}
|
|
|
13533
13593
|
this.props.shaderLayout = mergeShaderModuleBindingsIntoLayout(shaderLayout || null, modules) || null;
|
|
13534
13594
|
} else {
|
|
13535
13595
|
const shaderAssembler = this.props.shaderAssembler;
|
|
13536
|
-
(0,
|
|
13596
|
+
(0, import_core14.assert)(isShaderAssemblerForLanguage(shaderAssembler, "glsl"));
|
|
13537
13597
|
const { vs: vs4, fs: fs4, getUniforms: getUniforms2 } = shaderAssembler.assembleGLSLShaderPair({
|
|
13538
13598
|
platformInfo,
|
|
13539
13599
|
...this.props,
|
|
13540
13600
|
modules,
|
|
13541
13601
|
defines,
|
|
13602
|
+
pluginHooks: resolvedPlugins.hooks,
|
|
13542
13603
|
pluginInjections: resolvedPlugins.injections,
|
|
13543
13604
|
pluginVertexInputs: resolvedPlugins.vertexInputs,
|
|
13544
13605
|
pluginInterStageVariables: resolvedPlugins.interStageVariables
|
|
@@ -13548,9 +13609,9 @@ ${getApplicationDefines(allDefines)}
|
|
|
13548
13609
|
this._getModuleUniforms = getUniforms2;
|
|
13549
13610
|
this._bindingTable = [];
|
|
13550
13611
|
}
|
|
13551
|
-
this.pipelineFactory = props.pipelineFactory ||
|
|
13552
|
-
this.shaderFactory = props.shaderFactory ||
|
|
13553
|
-
const asyncCompilation =
|
|
13612
|
+
this.pipelineFactory = props.pipelineFactory || import_core14.PipelineFactory.getDefaultPipelineFactory(this.device);
|
|
13613
|
+
this.shaderFactory = props.shaderFactory || import_core14.ShaderFactory.getDefaultShaderFactory(this.device);
|
|
13614
|
+
const asyncCompilation = import_core14.PipelineFactory.getAsyncCompilation(this.device);
|
|
13554
13615
|
if (asyncCompilation) {
|
|
13555
13616
|
this._pipelineInitialization = this._initializePipelineAsync(props);
|
|
13556
13617
|
asyncCompilation.push(this._pipelineInitialization);
|
|
@@ -13620,6 +13681,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
13620
13681
|
this.geometryVectorBindings.destroy();
|
|
13621
13682
|
this.attributeVectorBindings.destroy();
|
|
13622
13683
|
this._uniformStore?.destroy();
|
|
13684
|
+
this.batchUniformBuffer?.destroy();
|
|
13623
13685
|
this._destroyed = true;
|
|
13624
13686
|
}
|
|
13625
13687
|
}
|
|
@@ -13667,12 +13729,12 @@ ${getApplicationDefines(allDefines)}
|
|
|
13667
13729
|
return this.drawVectorGroups(renderPass);
|
|
13668
13730
|
}
|
|
13669
13731
|
if (this._drawBlockedReason && !this._pipelineNeedsUpdate) {
|
|
13670
|
-
|
|
13732
|
+
import_core14.log.info(LOG_DRAW_PRIORITY, `>>> DRAWING ABORTED ${this.id}: ${this._drawBlockedReason}`)();
|
|
13671
13733
|
return false;
|
|
13672
13734
|
}
|
|
13673
13735
|
const loadingBinding = this._areBindingsLoading();
|
|
13674
13736
|
if (loadingBinding) {
|
|
13675
|
-
|
|
13737
|
+
import_core14.log.info(LOG_DRAW_PRIORITY, `>>> DRAWING ABORTED ${this.id}: ${loadingBinding} not loaded`)();
|
|
13676
13738
|
return false;
|
|
13677
13739
|
}
|
|
13678
13740
|
this._syncAttachmentFormats(renderPass);
|
|
@@ -13696,7 +13758,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
13696
13758
|
this.pipeline = this._updatePipeline();
|
|
13697
13759
|
pipelineErrored = this.pipeline.isErrored;
|
|
13698
13760
|
if (pipelineErrored) {
|
|
13699
|
-
|
|
13761
|
+
import_core14.log.info(
|
|
13700
13762
|
LOG_DRAW_PRIORITY,
|
|
13701
13763
|
`>>> DRAWING ABORTED ${this.id}: ${PIPELINE_INITIALIZATION_FAILED}`
|
|
13702
13764
|
)();
|
|
@@ -13704,7 +13766,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
13704
13766
|
} else {
|
|
13705
13767
|
const drawValidationError = this.vertexArray.getDrawValidationError();
|
|
13706
13768
|
if (drawValidationError) {
|
|
13707
|
-
|
|
13769
|
+
import_core14.log.info(LOG_DRAW_PRIORITY, `>>> DRAWING ABORTED ${this.id}: ${drawValidationError}`)();
|
|
13708
13770
|
this._drawBlockedReason = drawValidationError;
|
|
13709
13771
|
drawSuccess = false;
|
|
13710
13772
|
} else {
|
|
@@ -13763,20 +13825,27 @@ ${getApplicationDefines(allDefines)}
|
|
|
13763
13825
|
/** Replaces per-vertex mesh vectors while preserving supplemental attributes. */
|
|
13764
13826
|
setGeometryVectors(vectors, bufferLayouts) {
|
|
13765
13827
|
bufferLayouts ??= this.getExplicitVectorLayouts(vectors) ?? this.getExplicitVectorLayouts(vectors, this.geometryVectorBindings.sourceLayouts);
|
|
13766
|
-
|
|
13767
|
-
if (
|
|
13828
|
+
this.validateVectorLengthPolicy();
|
|
13829
|
+
if (this.props.enforceMatchingVectorLengths) validateGPUVectorBatchStructure(vectors);
|
|
13830
|
+
if (this.props.enforceMatchingVectorLengths && (!this.isInstanced || this.attributeVectorBindings.vertexCount !== void 0))
|
|
13768
13831
|
validateGPUVectorBatchStructure([
|
|
13769
13832
|
...Object.values(vectors),
|
|
13770
13833
|
...Object.values(this.attributeVectorBindings.inputs)
|
|
13771
13834
|
]);
|
|
13772
|
-
this.geometryVectorBindings.setInputs(
|
|
13835
|
+
this.geometryVectorBindings.setInputs(
|
|
13836
|
+
vectors,
|
|
13837
|
+
bufferLayouts,
|
|
13838
|
+
"vertex",
|
|
13839
|
+
this.props.enforceMatchingVectorLengths
|
|
13840
|
+
);
|
|
13773
13841
|
this.claimVectorLayouts(this.geometryVectorBindings);
|
|
13774
13842
|
this.syncVectorBindings();
|
|
13775
13843
|
const rowCount = this.geometryVectorBindings.rowCount;
|
|
13776
|
-
(0,
|
|
13844
|
+
(0, import_core14.assert)(
|
|
13777
13845
|
rowCount === void 0 || this.attributeVectorBindings.vertexCount === void 0 || rowCount === this.attributeVectorBindings.vertexCount
|
|
13778
13846
|
);
|
|
13779
|
-
|
|
13847
|
+
if (this.props.inferDrawCount === "vertex")
|
|
13848
|
+
this.setVertexCount(rowCount ?? this.attributeVectorBindings.vertexCount ?? 0);
|
|
13780
13849
|
}
|
|
13781
13850
|
/** Replaces supplemental vectors; instanced models default these inputs to instance step mode. */
|
|
13782
13851
|
setAttributeVectors(vectors, bufferLayouts) {
|
|
@@ -13790,7 +13859,8 @@ ${getApplicationDefines(allDefines)}
|
|
|
13790
13859
|
(layout) => layout.name === name || layout.attributes?.some((attribute) => attribute.attribute === name)
|
|
13791
13860
|
)?.stepMode ?? vector.bufferLayout?.stepMode) === "vertex"
|
|
13792
13861
|
);
|
|
13793
|
-
|
|
13862
|
+
this.validateVectorLengthPolicy();
|
|
13863
|
+
if (usesVertexRows && this.props.enforceMatchingVectorLengths)
|
|
13794
13864
|
validateGPUVectorBatchStructure([
|
|
13795
13865
|
...Object.values(this.geometryVectorBindings.inputs),
|
|
13796
13866
|
...Object.values(vectors)
|
|
@@ -13798,16 +13868,17 @@ ${getApplicationDefines(allDefines)}
|
|
|
13798
13868
|
this.attributeVectorBindings.setInputs(
|
|
13799
13869
|
vectors,
|
|
13800
13870
|
bufferLayouts,
|
|
13801
|
-
this.isInstanced ? "instance" : "vertex"
|
|
13871
|
+
this.isInstanced ? "instance" : "vertex",
|
|
13872
|
+
this.props.enforceMatchingVectorLengths
|
|
13802
13873
|
);
|
|
13803
13874
|
this.claimVectorLayouts(this.attributeVectorBindings);
|
|
13804
13875
|
this.syncVectorBindings();
|
|
13805
|
-
if (this.attributeVectorBindings.instanceCount !== void 0)
|
|
13876
|
+
if (this.props.inferDrawCount === "instance" && this.attributeVectorBindings.instanceCount !== void 0)
|
|
13806
13877
|
this.setInstanceCount(this.attributeVectorBindings.instanceCount);
|
|
13807
13878
|
const vertexCount = this.attributeVectorBindings.vertexCount;
|
|
13808
|
-
if (vertexCount !== void 0) {
|
|
13879
|
+
if (vertexCount !== void 0 && this.props.inferDrawCount === "vertex") {
|
|
13809
13880
|
const geometryRowCount = this.geometryVectorBindings.rowCount;
|
|
13810
|
-
(0,
|
|
13881
|
+
(0, import_core14.assert)(geometryRowCount === void 0 || geometryRowCount === vertexCount);
|
|
13811
13882
|
if (geometryRowCount === void 0) this.setVertexCount(vertexCount);
|
|
13812
13883
|
}
|
|
13813
13884
|
}
|
|
@@ -13818,9 +13889,9 @@ ${getApplicationDefines(allDefines)}
|
|
|
13818
13889
|
/** Replaces the borrowed contiguous uint16/uint32 index vector. */
|
|
13819
13890
|
setIndexVector(vector) {
|
|
13820
13891
|
if (vector) {
|
|
13821
|
-
(0,
|
|
13822
|
-
(0,
|
|
13823
|
-
(0,
|
|
13892
|
+
(0, import_core14.assert)(vector.format === "uint8" || vector.format === "uint16" || vector.format === "uint32");
|
|
13893
|
+
(0, import_core14.assert)(vector.data.length <= 1);
|
|
13894
|
+
(0, import_core14.assert)(
|
|
13824
13895
|
vector.byteStride === (vector.format === "uint32" ? 4 : vector.format === "uint16" ? 2 : 1)
|
|
13825
13896
|
);
|
|
13826
13897
|
}
|
|
@@ -13832,7 +13903,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
13832
13903
|
const chunk = vector?.data[0];
|
|
13833
13904
|
if (chunk && this.indexVector) {
|
|
13834
13905
|
const buffer = chunk.buffer instanceof DynamicBuffer ? chunk.buffer.buffer : chunk.buffer;
|
|
13835
|
-
(0,
|
|
13906
|
+
(0, import_core14.assert)(
|
|
13836
13907
|
buffer.indexType === this.indexVector.format && chunk.byteOffset % this.indexVector.byteStride === 0
|
|
13837
13908
|
);
|
|
13838
13909
|
}
|
|
@@ -13906,7 +13977,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
13906
13977
|
/** Binds contiguous borrowed vectors; use drawBatches() for multi-chunk inputs. */
|
|
13907
13978
|
setGPUVectors(vectors, options) {
|
|
13908
13979
|
const batches = getGPUVectorModelBatches(this.id, vectors);
|
|
13909
|
-
(0,
|
|
13980
|
+
(0, import_core14.assert)(batches.length <= 1);
|
|
13910
13981
|
validateGPUVectorModelLayouts(this.id, vectors, this.bufferLayout);
|
|
13911
13982
|
if (batches[0]) this.setGPUData(batches[0].data);
|
|
13912
13983
|
this.setBatchDrawCount(batches[0]?.rowCount ?? 0, options?.count);
|
|
@@ -13921,7 +13992,8 @@ ${getApplicationDefines(allDefines)}
|
|
|
13921
13992
|
this.geometryVectorBindings,
|
|
13922
13993
|
this.attributeVectorBindings,
|
|
13923
13994
|
() => this.syncVectorBindings(),
|
|
13924
|
-
() => _GPUVectorModel.prototype.draw.call(this, renderPass)
|
|
13995
|
+
() => _GPUVectorModel.prototype.draw.call(this, renderPass),
|
|
13996
|
+
this.props.inferDrawCount
|
|
13925
13997
|
);
|
|
13926
13998
|
if (success) {
|
|
13927
13999
|
this._lastDrawTimestamp = this.device.timestamp;
|
|
@@ -13933,12 +14005,18 @@ ${getApplicationDefines(allDefines)}
|
|
|
13933
14005
|
this.drawingVectorBatches = drawingVectorBatches;
|
|
13934
14006
|
}
|
|
13935
14007
|
}
|
|
13936
|
-
/**
|
|
14008
|
+
/**
|
|
14009
|
+
* Draws each aligned physical chunk without taking ownership of input vectors.
|
|
14010
|
+
* Each batch uses a separate aligned slot for managed shader-input uniforms set by
|
|
14011
|
+
* `onBatch`. Slots are reused on each call: submit previous draws before changing their
|
|
14012
|
+
* values or growing the allocation. Explicit buffers remain caller-managed. Vector
|
|
14013
|
+
* lengths and physical chunk boundaries must match.
|
|
14014
|
+
*/
|
|
13937
14015
|
drawBatches(renderPass, { vectors, onBatch }) {
|
|
13938
14016
|
const batches = getGPUVectorModelBatches(this.id, vectors);
|
|
13939
14017
|
validateGPUVectorModelLayouts(this.id, vectors, this.bufferLayout);
|
|
13940
14018
|
for (const name of Object.keys(vectors)) {
|
|
13941
|
-
(0,
|
|
14019
|
+
(0, import_core14.assert)(!vectors[name] || this.currentAttributes[name]);
|
|
13942
14020
|
}
|
|
13943
14021
|
const previousAttributes = { ...this.currentAttributes };
|
|
13944
14022
|
const previousAttributeByteOffsets = { ...this.currentAttributeByteOffsets };
|
|
@@ -13948,6 +14026,17 @@ ${getApplicationDefines(allDefines)}
|
|
|
13948
14026
|
const previousIsInstanced = this.isInstanced;
|
|
13949
14027
|
const previousVertexCountSet = this._vertexCountSet;
|
|
13950
14028
|
const drawingVectorBatches = this.drawingVectorBatches;
|
|
14029
|
+
const batchUniformStore = this.device.type === "webgpu" && batches.length ? new import_core14.UniformStore(this.device, this.shaderInputs.modules) : void 0;
|
|
14030
|
+
if (batchUniformStore && this._uniformStore.uniformBuffers.size) {
|
|
14031
|
+
this.batchUniformBuffer ??= new BatchUniformBuffer(this.device);
|
|
14032
|
+
let batchByteLength = 0;
|
|
14033
|
+
for (const moduleName of this._uniformStore.uniformBuffers.keys()) {
|
|
14034
|
+
batchByteLength += this.batchUniformBuffer.getAlignedByteLength(
|
|
14035
|
+
batchUniformStore.getUniformBufferData(moduleName).byteLength
|
|
14036
|
+
);
|
|
14037
|
+
}
|
|
14038
|
+
this.batchUniformBuffer.prepare(batchByteLength * batches.length);
|
|
14039
|
+
}
|
|
13951
14040
|
this.drawingVectorBatches = true;
|
|
13952
14041
|
let drawSuccess = true;
|
|
13953
14042
|
try {
|
|
@@ -13955,9 +14044,28 @@ ${getApplicationDefines(allDefines)}
|
|
|
13955
14044
|
this.setGPUData(batch.data);
|
|
13956
14045
|
this.setBatchDrawCount(batch.rowCount);
|
|
13957
14046
|
onBatch?.(batch);
|
|
13958
|
-
|
|
14047
|
+
const managedBindings = {};
|
|
14048
|
+
try {
|
|
14049
|
+
if (batchUniformStore) {
|
|
14050
|
+
batchUniformStore.setUniforms(this.shaderInputs.getUniformValues());
|
|
14051
|
+
for (const [moduleName, buffer] of this._uniformStore.uniformBuffers) {
|
|
14052
|
+
const bindingName = `${moduleName}Uniforms`;
|
|
14053
|
+
if (this.bindings[bindingName] !== buffer) continue;
|
|
14054
|
+
managedBindings[bindingName] = buffer;
|
|
14055
|
+
this.setBindings({
|
|
14056
|
+
[bindingName]: this.batchUniformBuffer.write(
|
|
14057
|
+
batchUniformStore.getUniformBufferData(moduleName)
|
|
14058
|
+
)
|
|
14059
|
+
});
|
|
14060
|
+
}
|
|
14061
|
+
}
|
|
14062
|
+
drawSuccess = _GPUVectorModel.prototype.draw.call(this, renderPass) && drawSuccess;
|
|
14063
|
+
} finally {
|
|
14064
|
+
this.setBindings(managedBindings);
|
|
14065
|
+
}
|
|
13959
14066
|
}
|
|
13960
14067
|
} finally {
|
|
14068
|
+
batchUniformStore?.destroy();
|
|
13961
14069
|
this.setAttributes(previousAttributes, { byteOffsets: previousAttributeByteOffsets });
|
|
13962
14070
|
for (const name of Object.keys(this.bindings)) {
|
|
13963
14071
|
if (!(name in previousBindings)) delete this.bindings[name];
|
|
@@ -13979,14 +14087,17 @@ ${getApplicationDefines(allDefines)}
|
|
|
13979
14087
|
Object.entries(data).map(([name, chunk]) => {
|
|
13980
14088
|
const layout = this.bufferLayout.find((layout2) => layout2.name === name);
|
|
13981
14089
|
const byteOffset = chunk.byteOffset - (layout?.attributes?.[0]?.byteOffset ?? 0);
|
|
13982
|
-
(0,
|
|
14090
|
+
(0, import_core14.assert)(byteOffset >= 0);
|
|
13983
14091
|
return [name, byteOffset];
|
|
13984
14092
|
})
|
|
13985
14093
|
)
|
|
13986
14094
|
}
|
|
13987
14095
|
);
|
|
13988
14096
|
}
|
|
13989
|
-
|
|
14097
|
+
validateVectorLengthPolicy() {
|
|
14098
|
+
(0, import_core14.assert)(this.props.enforceMatchingVectorLengths !== false || this.props.inferDrawCount === "no");
|
|
14099
|
+
}
|
|
14100
|
+
setBatchDrawCount(rowCount, count = this.props.inferDrawCount === "no" ? "none" : this.props.inferDrawCount) {
|
|
13990
14101
|
if (count === "instance") {
|
|
13991
14102
|
this.setInstanceCount(rowCount);
|
|
13992
14103
|
} else if (count === "vertex") {
|
|
@@ -14014,13 +14125,19 @@ ${getApplicationDefines(allDefines)}
|
|
|
14014
14125
|
const attributes = this.attributeVectorBindings;
|
|
14015
14126
|
const geometryLayouts = this.getExplicitVectorLayouts(geometry.inputs) ?? geometry.sourceLayouts;
|
|
14016
14127
|
const attributeLayouts = this.getExplicitVectorLayouts(attributes.inputs) ?? attributes.sourceLayouts;
|
|
14017
|
-
geometry.setInputs(
|
|
14128
|
+
geometry.setInputs(
|
|
14129
|
+
geometry.inputs,
|
|
14130
|
+
geometryLayouts,
|
|
14131
|
+
"vertex",
|
|
14132
|
+
this.props.enforceMatchingVectorLengths
|
|
14133
|
+
);
|
|
14018
14134
|
attributes.setInputs(
|
|
14019
14135
|
attributes.inputs,
|
|
14020
14136
|
attributeLayouts,
|
|
14021
|
-
this.isInstanced ? "instance" : "vertex"
|
|
14137
|
+
this.isInstanced ? "instance" : "vertex",
|
|
14138
|
+
this.props.enforceMatchingVectorLengths
|
|
14022
14139
|
);
|
|
14023
|
-
if (!this.isInstanced || attributes.vertexCount !== void 0)
|
|
14140
|
+
if (this.props.enforceMatchingVectorLengths && (!this.isInstanced || attributes.vertexCount !== void 0))
|
|
14024
14141
|
validateGPUVectorBatchStructure([
|
|
14025
14142
|
...Object.values(geometry.inputs),
|
|
14026
14143
|
...Object.values(attributes.inputs)
|
|
@@ -14101,7 +14218,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
14101
14218
|
/** Set the shader inputs */
|
|
14102
14219
|
setShaderInputs(shaderInputs) {
|
|
14103
14220
|
this.shaderInputs = shaderInputs;
|
|
14104
|
-
this._uniformStore = new
|
|
14221
|
+
this._uniformStore = new import_core14.UniformStore(this.device, this.shaderInputs.modules);
|
|
14105
14222
|
for (const [moduleName, module] of Object.entries(this.shaderInputs.modules)) {
|
|
14106
14223
|
if (shaderModuleHasUniforms(module) && this._usesManagedUniformBuffer(moduleName)) {
|
|
14107
14224
|
const uniformBuffer = this._uniformStore.getManagedUniformBuffer(moduleName);
|
|
@@ -14172,7 +14289,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
14172
14289
|
this._drawBlockedReason = false;
|
|
14173
14290
|
const disableWarnings = options?.disableWarnings ?? this.props.disableWarnings;
|
|
14174
14291
|
if (buffers["indices"]) {
|
|
14175
|
-
|
|
14292
|
+
import_core14.log.warn(
|
|
14176
14293
|
`Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`
|
|
14177
14294
|
)();
|
|
14178
14295
|
}
|
|
@@ -14186,7 +14303,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
14186
14303
|
const bufferLayout = bufferLayoutHelper.getBufferLayout(bufferName);
|
|
14187
14304
|
if (!bufferLayout) {
|
|
14188
14305
|
if (!disableWarnings) {
|
|
14189
|
-
|
|
14306
|
+
import_core14.log.warn(`Model(${this.id}): Missing layout for buffer "${bufferName}".`)();
|
|
14190
14307
|
}
|
|
14191
14308
|
continue;
|
|
14192
14309
|
}
|
|
@@ -14198,7 +14315,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
14198
14315
|
const bufferSlot = this.device.type === "webgpu" ? this.vertexArray.getBufferSlot(attributeInfo.bufferName) : attributeInfo.location;
|
|
14199
14316
|
if (bufferSlot === null) {
|
|
14200
14317
|
if (!disableWarnings) {
|
|
14201
|
-
|
|
14318
|
+
import_core14.log.warn(
|
|
14202
14319
|
`Model(${this.id}): Missing vertex array slot for buffer "${attributeInfo.bufferName}".`
|
|
14203
14320
|
)();
|
|
14204
14321
|
}
|
|
@@ -14219,7 +14336,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
14219
14336
|
}
|
|
14220
14337
|
}
|
|
14221
14338
|
if (!set2 && !disableWarnings) {
|
|
14222
|
-
|
|
14339
|
+
import_core14.log.warn(
|
|
14223
14340
|
`Model(${this.id}): Ignoring buffer "${resolvedBuffer.id}" for unknown attribute "${bufferName}"`
|
|
14224
14341
|
)();
|
|
14225
14342
|
}
|
|
@@ -14240,7 +14357,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
14240
14357
|
if (attributeInfo) {
|
|
14241
14358
|
this.vertexArray.setConstantWebGL(attributeInfo.location, value);
|
|
14242
14359
|
} else if (!(options?.disableWarnings ?? this.props.disableWarnings)) {
|
|
14243
|
-
|
|
14360
|
+
import_core14.log.warn(
|
|
14244
14361
|
`Model "${this.id}: Ignoring constant supplied for unknown attribute "${attributeName}"`
|
|
14245
14362
|
)();
|
|
14246
14363
|
}
|
|
@@ -14277,7 +14394,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
14277
14394
|
* @param bindings GPUVectorModel bindings already resolved for this draw preparation.
|
|
14278
14395
|
*/
|
|
14279
14396
|
_getBindGroups(shaderLayout = this._getCurrentShaderLayout(), bindings = this._getBindings(shaderLayout)) {
|
|
14280
|
-
return shaderLayout.bindings.length ? (0,
|
|
14397
|
+
return shaderLayout.bindings.length ? (0, import_core14.normalizeBindingsByGroup)(shaderLayout, bindings) : { 0: bindings };
|
|
14281
14398
|
}
|
|
14282
14399
|
_getBindGroupCacheKeys() {
|
|
14283
14400
|
return {};
|
|
@@ -14292,9 +14409,9 @@ ${getApplicationDefines(allDefines)}
|
|
|
14292
14409
|
timestamp = Math.max(timestamp, entry.source.updateTimestamp);
|
|
14293
14410
|
}
|
|
14294
14411
|
for (const binding of Object.values(this.bindings)) {
|
|
14295
|
-
if (binding instanceof
|
|
14412
|
+
if (binding instanceof import_core14.TextureView) {
|
|
14296
14413
|
timestamp = Math.max(timestamp, binding.texture.updateTimestamp);
|
|
14297
|
-
} else if (binding instanceof
|
|
14414
|
+
} else if (binding instanceof import_core14.Buffer || binding instanceof import_core14.Texture || binding instanceof import_core14.ExternalTexture) {
|
|
14298
14415
|
timestamp = Math.max(timestamp, binding.updateTimestamp);
|
|
14299
14416
|
} else if (binding instanceof DynamicBuffer) {
|
|
14300
14417
|
timestamp = Math.max(timestamp, binding.updateTimestamp);
|
|
@@ -14353,7 +14470,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
14353
14470
|
const previousVertexShader = this.pipeline?.vs ?? null;
|
|
14354
14471
|
const previousFragmentShader = this.pipeline?.fs ?? null;
|
|
14355
14472
|
if (this.pipeline) {
|
|
14356
|
-
|
|
14473
|
+
import_core14.log.log(
|
|
14357
14474
|
1,
|
|
14358
14475
|
`GPUVectorModel ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`
|
|
14359
14476
|
)();
|
|
@@ -14403,7 +14520,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
14403
14520
|
};
|
|
14404
14521
|
}
|
|
14405
14522
|
_finishPipelineUpdate(update) {
|
|
14406
|
-
this._attributeInfos = (0,
|
|
14523
|
+
this._attributeInfos = (0, import_core14.getAttributeInfosFromLayouts)(
|
|
14407
14524
|
this.pipeline.shaderLayout,
|
|
14408
14525
|
this.bufferLayout
|
|
14409
14526
|
);
|
|
@@ -14419,24 +14536,24 @@ ${getApplicationDefines(allDefines)}
|
|
|
14419
14536
|
_lastLogTime = 0;
|
|
14420
14537
|
_logOpen = false;
|
|
14421
14538
|
_logDrawCallStart() {
|
|
14422
|
-
const logDrawTimeout =
|
|
14423
|
-
if (
|
|
14539
|
+
const logDrawTimeout = import_core14.log.level > 3 ? 0 : LOG_DRAW_TIMEOUT;
|
|
14540
|
+
if (import_core14.log.level < 2 || Date.now() - this._lastLogTime < logDrawTimeout) {
|
|
14424
14541
|
return;
|
|
14425
14542
|
}
|
|
14426
14543
|
this._lastLogTime = Date.now();
|
|
14427
14544
|
this._logOpen = true;
|
|
14428
|
-
|
|
14545
|
+
import_core14.log.group(LOG_DRAW_PRIORITY, `>>> DRAWING MODEL ${this.id}`, { collapsed: import_core14.log.level <= 2 })();
|
|
14429
14546
|
}
|
|
14430
14547
|
_logDrawCallEnd() {
|
|
14431
14548
|
if (this._logOpen) {
|
|
14432
14549
|
const shaderLayoutTable = getDebugTableForShaderLayout(this.pipeline.shaderLayout, this.id);
|
|
14433
|
-
|
|
14550
|
+
import_core14.log.table(LOG_DRAW_PRIORITY, shaderLayoutTable)();
|
|
14434
14551
|
const uniformTable = this.shaderInputs.getDebugTable();
|
|
14435
|
-
|
|
14552
|
+
import_core14.log.table(LOG_DRAW_PRIORITY, uniformTable)();
|
|
14436
14553
|
const attributeTable = this._getAttributeDebugTable();
|
|
14437
|
-
|
|
14438
|
-
|
|
14439
|
-
|
|
14554
|
+
import_core14.log.table(LOG_DRAW_PRIORITY, this._attributeInfos)();
|
|
14555
|
+
import_core14.log.table(LOG_DRAW_PRIORITY, attributeTable)();
|
|
14556
|
+
import_core14.log.groupEnd(LOG_DRAW_PRIORITY)();
|
|
14440
14557
|
this._logOpen = false;
|
|
14441
14558
|
}
|
|
14442
14559
|
}
|
|
@@ -14476,8 +14593,8 @@ ${getApplicationDefines(allDefines)}
|
|
|
14476
14593
|
}
|
|
14477
14594
|
// TODO - fix typing of luma data types
|
|
14478
14595
|
_getBufferOrConstantValues(attribute, dataType) {
|
|
14479
|
-
const TypedArrayConstructor =
|
|
14480
|
-
const typedArray = attribute instanceof
|
|
14596
|
+
const TypedArrayConstructor = import_core14.dataTypeDecoder.getTypedArrayConstructor(dataType);
|
|
14597
|
+
const typedArray = attribute instanceof import_core14.Buffer ? new TypedArrayConstructor(attribute.debugData) : attribute;
|
|
14481
14598
|
return typedArray.toString();
|
|
14482
14599
|
}
|
|
14483
14600
|
/** Returns the current reflected shader layout or the pre-reflection empty layout. */
|
|
@@ -14561,7 +14678,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
14561
14678
|
}
|
|
14562
14679
|
|
|
14563
14680
|
// src/geometry/gpu-geometry.ts
|
|
14564
|
-
var
|
|
14681
|
+
var import_core15 = __toESM(require_core(), 1);
|
|
14565
14682
|
var GPUGeometry = class {
|
|
14566
14683
|
/** Application-provided or generated identifier. */
|
|
14567
14684
|
id;
|
|
@@ -14586,7 +14703,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
14586
14703
|
this.vertexCount = props.vertexCount;
|
|
14587
14704
|
this.bufferLayout = props.bufferLayout || [];
|
|
14588
14705
|
if (this.indices) {
|
|
14589
|
-
if (!(this.indices.usage &
|
|
14706
|
+
if (!(this.indices.usage & import_core15.Buffer.INDEX)) {
|
|
14590
14707
|
throw new Error("Index buffer must have INDEX usage");
|
|
14591
14708
|
}
|
|
14592
14709
|
}
|
|
@@ -14635,7 +14752,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
14635
14752
|
return void 0;
|
|
14636
14753
|
}
|
|
14637
14754
|
const data = geometry.indices.value;
|
|
14638
|
-
return device.createBuffer({ usage:
|
|
14755
|
+
return device.createBuffer({ usage: import_core15.Buffer.INDEX, data });
|
|
14639
14756
|
}
|
|
14640
14757
|
function getAttributeBuffersFromGeometry(device, geometry) {
|
|
14641
14758
|
const attributes = {};
|
|
@@ -14662,6 +14779,9 @@ ${getApplicationDefines(allDefines)}
|
|
|
14662
14779
|
topology;
|
|
14663
14780
|
vertexCount;
|
|
14664
14781
|
bufferLayout;
|
|
14782
|
+
/** Releases resources owned by uploaded geometry; borrowed vectors remain caller-owned. */
|
|
14783
|
+
destroy() {
|
|
14784
|
+
}
|
|
14665
14785
|
constructor(props) {
|
|
14666
14786
|
this.attributes = props.attributes;
|
|
14667
14787
|
this.indices = props.indices ?? null;
|
|
@@ -14672,13 +14792,24 @@ ${getApplicationDefines(allDefines)}
|
|
|
14672
14792
|
};
|
|
14673
14793
|
|
|
14674
14794
|
// src/geometry/gpu-vector-geometry-adapter.ts
|
|
14675
|
-
var
|
|
14795
|
+
var import_core16 = __toESM(require_core(), 1);
|
|
14796
|
+
function makeGPUVectorGeometry(device, geometry) {
|
|
14797
|
+
const gpuGeometry = makeGPUGeometry(device, geometry);
|
|
14798
|
+
try {
|
|
14799
|
+
const vectorGeometry = makeGPUVectorGeometryFromGPUGeometry(gpuGeometry);
|
|
14800
|
+
vectorGeometry.destroy = () => gpuGeometry.destroy();
|
|
14801
|
+
return vectorGeometry;
|
|
14802
|
+
} catch (error) {
|
|
14803
|
+
gpuGeometry.destroy();
|
|
14804
|
+
throw error;
|
|
14805
|
+
}
|
|
14806
|
+
}
|
|
14676
14807
|
function makeGPUVectorGeometryFromGPUGeometry(geometry) {
|
|
14677
14808
|
const attributes = {};
|
|
14678
14809
|
for (const [name, buffer2] of Object.entries(geometry.attributes)) {
|
|
14679
14810
|
const bufferLayout = geometry.bufferLayout.find((layout) => layout.name === name);
|
|
14680
14811
|
const format = bufferLayout?.format;
|
|
14681
|
-
const byteStride2 = bufferLayout?.byteStride ?? (format ?
|
|
14812
|
+
const byteStride2 = bufferLayout?.byteStride ?? (format ? import_core16.vertexFormatDecoder.getVertexFormatInfo(format).byteLength : 0);
|
|
14682
14813
|
const length5 = geometry.indices && byteStride2 ? Math.floor(buffer2.byteLength / byteStride2) : geometry.vertexCount;
|
|
14683
14814
|
attributes[name] = {
|
|
14684
14815
|
name,
|
|
@@ -14740,6 +14871,10 @@ ${getApplicationDefines(allDefines)}
|
|
|
14740
14871
|
...GPUVectorModel.defaultProps,
|
|
14741
14872
|
material: void 0
|
|
14742
14873
|
};
|
|
14874
|
+
/** Borrowed source geometry, retained for scene adapters such as physics cooking. */
|
|
14875
|
+
get sourceGeometry() {
|
|
14876
|
+
return this.sourceGeometryValue;
|
|
14877
|
+
}
|
|
14743
14878
|
constructor(device, props) {
|
|
14744
14879
|
const sourceGeometry = props.geometry === void 0 ? new.target.defaultProps.geometry : props.geometry;
|
|
14745
14880
|
const gpuGeometry = sourceGeometry && !(sourceGeometry instanceof GPUVectorGeometry) ? makeGPUGeometry(device, sourceGeometry) : null;
|
|
@@ -14755,11 +14890,13 @@ ${getApplicationDefines(allDefines)}
|
|
|
14755
14890
|
throw error;
|
|
14756
14891
|
}
|
|
14757
14892
|
this._gpuGeometry = gpuGeometry;
|
|
14893
|
+
this.sourceGeometryValue = sourceGeometry;
|
|
14758
14894
|
if (gpuGeometry) this.setIndexCount(this.props.indexCount);
|
|
14759
14895
|
}
|
|
14760
14896
|
_initializeProps(props) {
|
|
14761
14897
|
this.material = props.material || null;
|
|
14762
14898
|
this._gpuGeometry = null;
|
|
14899
|
+
this.sourceGeometryValue = null;
|
|
14763
14900
|
super._initializeProps(props);
|
|
14764
14901
|
}
|
|
14765
14902
|
_initializeAttributes() {
|
|
@@ -14770,6 +14907,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
14770
14907
|
super.destroy();
|
|
14771
14908
|
this._gpuGeometry?.destroy();
|
|
14772
14909
|
this._gpuGeometry = null;
|
|
14910
|
+
this.sourceGeometryValue = null;
|
|
14773
14911
|
}
|
|
14774
14912
|
/** Adapts CPU and legacy buffer geometry into the GPU vector geometry API. */
|
|
14775
14913
|
setGeometry(geometry) {
|
|
@@ -14778,6 +14916,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
14778
14916
|
const vectorGeometry = this._gpuGeometry ? makeGPUVectorGeometryFromGPUGeometry(this._gpuGeometry) : geometry;
|
|
14779
14917
|
super.setGeometry(vectorGeometry instanceof GPUVectorGeometry ? vectorGeometry : null);
|
|
14780
14918
|
if (!(geometry instanceof GPUVectorGeometry)) super.setIndexCount(this.indexCountOverride);
|
|
14919
|
+
this.sourceGeometryValue = geometry;
|
|
14781
14920
|
}
|
|
14782
14921
|
setIndexCount(indexCount) {
|
|
14783
14922
|
this.indexCountOverride = indexCount;
|
|
@@ -14833,7 +14972,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
14833
14972
|
};
|
|
14834
14973
|
|
|
14835
14974
|
// src/material/material.ts
|
|
14836
|
-
var
|
|
14975
|
+
var import_core17 = __toESM(require_core(), 1);
|
|
14837
14976
|
|
|
14838
14977
|
// src/material/material-factory.ts
|
|
14839
14978
|
var MATERIAL_BIND_GROUP = 3;
|
|
@@ -14935,7 +15074,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
14935
15074
|
])
|
|
14936
15075
|
);
|
|
14937
15076
|
this.shaderInputs = props.shaderInputs || new ShaderInputs(moduleMap);
|
|
14938
|
-
this._uniformStore = new
|
|
15077
|
+
this._uniformStore = new import_core17.UniformStore(this.device, this.shaderInputs.modules);
|
|
14939
15078
|
for (const [moduleName, module] of Object.entries(this.shaderInputs.modules)) {
|
|
14940
15079
|
if (this.ownsModule(moduleName) && shaderModuleHasUniforms(module)) {
|
|
14941
15080
|
const uniformBuffer = this._uniformStore.getManagedUniformBuffer(moduleName);
|
|
@@ -15049,9 +15188,9 @@ ${getApplicationDefines(allDefines)}
|
|
|
15049
15188
|
getBindingsUpdateTimestamp() {
|
|
15050
15189
|
let timestamp = 0;
|
|
15051
15190
|
for (const binding of Object.values(this.bindings)) {
|
|
15052
|
-
if (binding instanceof
|
|
15191
|
+
if (binding instanceof import_core17.TextureView) {
|
|
15053
15192
|
timestamp = Math.max(timestamp, binding.texture.updateTimestamp);
|
|
15054
|
-
} else if (binding instanceof
|
|
15193
|
+
} else if (binding instanceof import_core17.Buffer || binding instanceof import_core17.Texture || binding instanceof import_core17.ExternalTexture) {
|
|
15055
15194
|
timestamp = Math.max(timestamp, binding.updateTimestamp);
|
|
15056
15195
|
} else if (binding instanceof DynamicBuffer) {
|
|
15057
15196
|
timestamp = Math.max(timestamp, binding.updateTimestamp);
|
|
@@ -15119,7 +15258,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
15119
15258
|
}
|
|
15120
15259
|
|
|
15121
15260
|
// src/compute/buffer-transform.ts
|
|
15122
|
-
var
|
|
15261
|
+
var import_core18 = __toESM(require_core(), 1);
|
|
15123
15262
|
var import_shaders4 = __toESM(require_shaders(), 1);
|
|
15124
15263
|
var GL_INTERLEAVED_ATTRIBS = 35980;
|
|
15125
15264
|
var GL_SEPARATE_ATTRIBS = 35981;
|
|
@@ -15193,14 +15332,14 @@ ${getApplicationDefines(allDefines)}
|
|
|
15193
15332
|
/** Binds borrowed output ranges without taking ownership or repacking vector chunks. */
|
|
15194
15333
|
setOutputVectors(vectors) {
|
|
15195
15334
|
const batches = getGPUVectorModelBatches(this.model.id, vectors);
|
|
15196
|
-
(0,
|
|
15197
|
-
(0,
|
|
15335
|
+
(0, import_core18.assert)(batches.length === 0 || this.model.pipeline.props.bufferMode !== GL_INTERLEAVED_ATTRIBS);
|
|
15336
|
+
(0, import_core18.assert)(batches.length <= 1);
|
|
15198
15337
|
this.outputVectorBindings = vectors;
|
|
15199
15338
|
this.transformFeedback.setBuffers({
|
|
15200
15339
|
...this.outputBuffers,
|
|
15201
15340
|
...Object.fromEntries(
|
|
15202
15341
|
Object.entries(batches[0]?.data ?? {}).map(([name, data]) => {
|
|
15203
|
-
(0,
|
|
15342
|
+
(0, import_core18.assert)(data.byteStride === data.rowByteLength);
|
|
15204
15343
|
return [
|
|
15205
15344
|
name,
|
|
15206
15345
|
{
|
|
@@ -15224,7 +15363,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
15224
15363
|
if (!result) {
|
|
15225
15364
|
throw new Error("BufferTransform#getBuffer");
|
|
15226
15365
|
}
|
|
15227
|
-
if (result instanceof
|
|
15366
|
+
if (result instanceof import_core18.Buffer) {
|
|
15228
15367
|
return result.readAsync();
|
|
15229
15368
|
}
|
|
15230
15369
|
const { buffer, byteOffset = 0, byteLength = buffer.byteLength } = result;
|
|
@@ -16173,7 +16312,7 @@ void main(void) {
|
|
|
16173
16312
|
};
|
|
16174
16313
|
|
|
16175
16314
|
// src/scenegraph/scenegraph-node.ts
|
|
16176
|
-
function
|
|
16315
|
+
function assert10(condition, message) {
|
|
16177
16316
|
if (!condition) {
|
|
16178
16317
|
throw new Error(message);
|
|
16179
16318
|
}
|
|
@@ -16209,17 +16348,17 @@ void main(void) {
|
|
|
16209
16348
|
return `{type: ScenegraphNode, id: ${this.id})}`;
|
|
16210
16349
|
}
|
|
16211
16350
|
setPosition(position) {
|
|
16212
|
-
|
|
16351
|
+
assert10(position.length === 3, "setPosition requires vector argument");
|
|
16213
16352
|
this.position = position;
|
|
16214
16353
|
return this;
|
|
16215
16354
|
}
|
|
16216
16355
|
setRotation(rotation) {
|
|
16217
|
-
|
|
16356
|
+
assert10(rotation.length === 3 || rotation.length === 4, "setRotation requires vector argument");
|
|
16218
16357
|
this.rotation = rotation;
|
|
16219
16358
|
return this;
|
|
16220
16359
|
}
|
|
16221
16360
|
setScale(scale5) {
|
|
16222
|
-
|
|
16361
|
+
assert10(scale5.length === 3, "setScale requires vector argument");
|
|
16223
16362
|
this.scale = scale5;
|
|
16224
16363
|
return this;
|
|
16225
16364
|
}
|
|
@@ -16329,7 +16468,7 @@ void main(void) {
|
|
|
16329
16468
|
};
|
|
16330
16469
|
|
|
16331
16470
|
// src/scenegraph/group-node.ts
|
|
16332
|
-
var
|
|
16471
|
+
var import_core23 = __toESM(require_core(), 1);
|
|
16333
16472
|
|
|
16334
16473
|
// src/scenegraph/scenegraph-bounds.ts
|
|
16335
16474
|
function makeEmptyScenegraphBounds() {
|
|
@@ -16366,15 +16505,18 @@ void main(void) {
|
|
|
16366
16505
|
// src/scenegraph/group-node.ts
|
|
16367
16506
|
var GroupNode = class _GroupNode extends ScenegraphNode {
|
|
16368
16507
|
children;
|
|
16508
|
+
/** Optional evaluated GPU poses; authored matrices remain unchanged. */
|
|
16509
|
+
transformSource;
|
|
16369
16510
|
constructor(props = {}) {
|
|
16370
16511
|
props = Array.isArray(props) ? { children: props } : props;
|
|
16371
16512
|
const { children = [] } = props;
|
|
16372
|
-
|
|
16513
|
+
import_core23.log.assert(
|
|
16373
16514
|
children.every((child) => child instanceof ScenegraphNode),
|
|
16374
16515
|
"every child must an instance of ScenegraphNode"
|
|
16375
16516
|
);
|
|
16376
16517
|
super(props);
|
|
16377
16518
|
this.children = children;
|
|
16519
|
+
this.transformSource = props.transformSource ?? null;
|
|
16378
16520
|
}
|
|
16379
16521
|
getBounds() {
|
|
16380
16522
|
const result = makeEmptyScenegraphBounds();
|
|
@@ -16416,6 +16558,45 @@ void main(void) {
|
|
|
16416
16558
|
this.children = [];
|
|
16417
16559
|
return this;
|
|
16418
16560
|
}
|
|
16561
|
+
/** Resolve one exact ID or path. Missing nodes return undefined; ambiguous paths throw. */
|
|
16562
|
+
findNode(path) {
|
|
16563
|
+
const matches = this.findNodes(path);
|
|
16564
|
+
if (matches.length > 1) {
|
|
16565
|
+
throw new Error(`Ambiguous scenegraph path: ${path} (${matches.length} matches)`);
|
|
16566
|
+
}
|
|
16567
|
+
return matches[0];
|
|
16568
|
+
}
|
|
16569
|
+
/** Find structural matches in preorder, including hidden nodes and the search root. */
|
|
16570
|
+
findNodes(path) {
|
|
16571
|
+
const anchored = path.startsWith("/");
|
|
16572
|
+
const segments = path === "/" ? [] : (anchored ? path.slice(1) : path).split("/").map((segment) => {
|
|
16573
|
+
if (!segment || /~(?![01])/.test(segment)) {
|
|
16574
|
+
throw new Error(`Invalid scenegraph path: ${path}`);
|
|
16575
|
+
}
|
|
16576
|
+
return segment.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
16577
|
+
});
|
|
16578
|
+
const matches = [];
|
|
16579
|
+
const ancestors = [];
|
|
16580
|
+
const visited = /* @__PURE__ */ new Set();
|
|
16581
|
+
const pending = [{ node: this, depth: 0 }];
|
|
16582
|
+
while (pending.length) {
|
|
16583
|
+
const { node, depth } = pending.pop();
|
|
16584
|
+
(0, import_core23.assert)(!visited.has(node));
|
|
16585
|
+
visited.add(node);
|
|
16586
|
+
ancestors.length = depth;
|
|
16587
|
+
ancestors.push(node.id);
|
|
16588
|
+
const offset = ancestors.length - segments.length;
|
|
16589
|
+
if ((anchored ? offset === 1 : offset >= 0) && segments.every((segment, index) => segment === ancestors[offset + index])) {
|
|
16590
|
+
matches.push(node);
|
|
16591
|
+
}
|
|
16592
|
+
if (node instanceof _GroupNode) {
|
|
16593
|
+
for (let index = node.children.length - 1; index >= 0; index--) {
|
|
16594
|
+
pending.push({ node: node.children[index], depth: depth + 1 });
|
|
16595
|
+
}
|
|
16596
|
+
}
|
|
16597
|
+
}
|
|
16598
|
+
return matches;
|
|
16599
|
+
}
|
|
16419
16600
|
traverse(visitor, { worldMatrix = new Matrix4() } = {}) {
|
|
16420
16601
|
if (!this.display) {
|
|
16421
16602
|
return;
|
|
@@ -16472,6 +16653,27 @@ void main(void) {
|
|
|
16472
16653
|
}
|
|
16473
16654
|
};
|
|
16474
16655
|
|
|
16656
|
+
// src/scenegraph/geometry-node.ts
|
|
16657
|
+
var GeometryNode = class extends ScenegraphNode {
|
|
16658
|
+
geometry;
|
|
16659
|
+
constructor(props) {
|
|
16660
|
+
super(props);
|
|
16661
|
+
this.geometry = props.geometry;
|
|
16662
|
+
}
|
|
16663
|
+
getBounds() {
|
|
16664
|
+
const positions = this.geometry.attributes["POSITION"];
|
|
16665
|
+
if (!positions || positions.size !== 3 || !positions.value.length) return null;
|
|
16666
|
+
const minimum = [Infinity, Infinity, Infinity];
|
|
16667
|
+
const maximum = [-Infinity, -Infinity, -Infinity];
|
|
16668
|
+
for (let index = 0; index < positions.value.length; index++) {
|
|
16669
|
+
const axis = index % 3;
|
|
16670
|
+
minimum[axis] = Math.min(minimum[axis], positions.value[index]);
|
|
16671
|
+
maximum[axis] = Math.max(maximum[axis], positions.value[index]);
|
|
16672
|
+
}
|
|
16673
|
+
return [minimum, maximum];
|
|
16674
|
+
}
|
|
16675
|
+
};
|
|
16676
|
+
|
|
16475
16677
|
// src/scenegraph/model-node.ts
|
|
16476
16678
|
var ModelNode = class extends ScenegraphNode {
|
|
16477
16679
|
model;
|
|
@@ -16515,12 +16717,12 @@ void main(void) {
|
|
|
16515
16717
|
}
|
|
16516
16718
|
|
|
16517
16719
|
// src/geometry/edge-geometry.ts
|
|
16518
|
-
var
|
|
16720
|
+
var import_core24 = __toESM(require_core(), 1);
|
|
16519
16721
|
function makeEdgeGeometry(geometry, options = {}) {
|
|
16520
16722
|
const { angleThreshold = 30, weldTolerance = 0, positionAttribute = "POSITION" } = options;
|
|
16521
16723
|
const positions = getTrianglePositions(geometry, positionAttribute);
|
|
16522
|
-
(0,
|
|
16523
|
-
(0,
|
|
16724
|
+
(0, import_core24.assert)(Number.isFinite(weldTolerance) && weldTolerance >= 0);
|
|
16725
|
+
(0, import_core24.assert)(Number.isFinite(angleThreshold) && angleThreshold >= 0 && angleThreshold <= 180);
|
|
16524
16726
|
const sourceIndices = geometry.indices?.value;
|
|
16525
16727
|
const sourceCount = positions.value.length / 3;
|
|
16526
16728
|
const representatives = /* @__PURE__ */ new Map();
|
|
@@ -16539,9 +16741,9 @@ void main(void) {
|
|
|
16539
16741
|
function weldPosition(index) {
|
|
16540
16742
|
const cached = representatives.get(index);
|
|
16541
16743
|
if (cached !== void 0) return cached;
|
|
16542
|
-
(0,
|
|
16744
|
+
(0, import_core24.assert)(Number.isInteger(index) && index >= 0 && index < sourceCount);
|
|
16543
16745
|
const position = readPosition(index);
|
|
16544
|
-
(0,
|
|
16746
|
+
(0, import_core24.assert)(position.every(Number.isFinite));
|
|
16545
16747
|
const cell = weldTolerance > 0 ? position.map((value) => Math.floor(value / weldTolerance)) : position;
|
|
16546
16748
|
const radius = weldTolerance > 0 ? 1 : 0;
|
|
16547
16749
|
for (let east = -radius; east <= radius; east++) {
|
|
@@ -16615,11 +16817,11 @@ void main(void) {
|
|
|
16615
16817
|
});
|
|
16616
16818
|
}
|
|
16617
16819
|
function makeEdgeGeometryFromGeometries(geometries, options = {}) {
|
|
16618
|
-
(0,
|
|
16820
|
+
(0, import_core24.assert)(geometries.length > 0);
|
|
16619
16821
|
const positionAttribute = options.positionAttribute ?? "POSITION";
|
|
16620
16822
|
const attributes = geometries.map((geometry) => getTrianglePositions(geometry, positionAttribute));
|
|
16621
16823
|
const firstAttribute = attributes[0];
|
|
16622
|
-
(0,
|
|
16824
|
+
(0, import_core24.assert)(
|
|
16623
16825
|
attributes.every(
|
|
16624
16826
|
(attribute) => attribute.value.constructor === firstAttribute.value.constructor && Boolean(attribute["normalized"]) === Boolean(firstAttribute["normalized"])
|
|
16625
16827
|
)
|
|
@@ -16638,7 +16840,7 @@ void main(void) {
|
|
|
16638
16840
|
positions.set(attribute.value, positionOffset);
|
|
16639
16841
|
for (let offset = 0; offset < geometry.vertexCount; offset++) {
|
|
16640
16842
|
const index = geometry.indices?.value[offset] ?? offset;
|
|
16641
|
-
(0,
|
|
16843
|
+
(0, import_core24.assert)(Number.isInteger(index) && index >= 0 && index < attribute.value.length / 3);
|
|
16642
16844
|
indices[indexOffset++] = index + positionOffset / 3;
|
|
16643
16845
|
}
|
|
16644
16846
|
positionOffset += attribute.value.length;
|
|
@@ -16655,26 +16857,26 @@ void main(void) {
|
|
|
16655
16857
|
}
|
|
16656
16858
|
function getTrianglePositions(geometry, positionAttribute) {
|
|
16657
16859
|
const positions = geometry.attributes[positionAttribute];
|
|
16658
|
-
(0,
|
|
16659
|
-
(0,
|
|
16660
|
-
(0,
|
|
16860
|
+
(0, import_core24.assert)(geometry.topology === "triangle-list" && positions?.size === 3);
|
|
16861
|
+
(0, import_core24.assert)(positions.value.length % 3 === 0 && geometry.vertexCount % 3 === 0);
|
|
16862
|
+
(0, import_core24.assert)(
|
|
16661
16863
|
!positions["byteStride"] || positions["byteStride"] === positions.value.BYTES_PER_ELEMENT * 3
|
|
16662
16864
|
);
|
|
16663
|
-
(0,
|
|
16865
|
+
(0, import_core24.assert)(
|
|
16664
16866
|
geometry.vertexCount >= 0 && geometry.vertexCount <= (geometry.indices?.value.length ?? positions.value.length / 3)
|
|
16665
16867
|
);
|
|
16666
16868
|
return positions;
|
|
16667
16869
|
}
|
|
16668
16870
|
|
|
16669
16871
|
// src/geometry/stroke-geometry.ts
|
|
16670
|
-
var
|
|
16872
|
+
var import_core25 = __toESM(require_core(), 1);
|
|
16671
16873
|
function makeStrokeGeometry(path, options = {}) {
|
|
16672
16874
|
const { width = 1, cap = "butt", join = "miter", miterLimit = 4, roundSegments = 16 } = options;
|
|
16673
|
-
(0,
|
|
16674
|
-
(0,
|
|
16875
|
+
(0, import_core25.assert)(Number.isFinite(width) && width >= 0 && Number.isFinite(miterLimit) && miterLimit >= 1);
|
|
16876
|
+
(0, import_core25.assert)(Number.isInteger(roundSegments) && roundSegments >= 2 && roundSegments <= 256);
|
|
16675
16877
|
const points = [];
|
|
16676
16878
|
for (const position of path) {
|
|
16677
|
-
(0,
|
|
16879
|
+
(0, import_core25.assert)(
|
|
16678
16880
|
Number.isFinite(position[0]) && Number.isFinite(position[1]) && Number.isFinite(position[2] ?? 0)
|
|
16679
16881
|
);
|
|
16680
16882
|
const previous = points.at(-1);
|
|
@@ -16834,12 +17036,12 @@ void main(void) {
|
|
|
16834
17036
|
}
|
|
16835
17037
|
|
|
16836
17038
|
// src/geometry/mesh-simplification.ts
|
|
16837
|
-
var
|
|
17039
|
+
var import_core26 = __toESM(require_core(), 1);
|
|
16838
17040
|
var QUADRIC_COMPONENTS = 10;
|
|
16839
17041
|
var BOUNDARY_COLLINEAR_TOLERANCE = 1e-10;
|
|
16840
17042
|
function simplifyMesh(options) {
|
|
16841
17043
|
const { positions, indices, attributes = [], preserveBoundary = true } = options;
|
|
16842
|
-
(0,
|
|
17044
|
+
(0, import_core26.assert)(indices.length % 3 === 0 && positions.length % 3 === 0);
|
|
16843
17045
|
const targetIndexCount = Math.max(
|
|
16844
17046
|
0,
|
|
16845
17047
|
Math.min(
|
|
@@ -16932,7 +17134,7 @@ void main(void) {
|
|
|
16932
17134
|
const firstVertex = indices[indexOffset2];
|
|
16933
17135
|
const secondVertex = indices[indexOffset2 + 1];
|
|
16934
17136
|
const thirdVertex = indices[indexOffset2 + 2];
|
|
16935
|
-
(0,
|
|
17137
|
+
(0, import_core26.assert)(firstVertex < vertexCount && secondVertex < vertexCount && thirdVertex < vertexCount);
|
|
16936
17138
|
const triangle = {
|
|
16937
17139
|
vertices: [firstVertex, secondVertex, thirdVertex],
|
|
16938
17140
|
active: false
|
|
@@ -17267,7 +17469,7 @@ void main(void) {
|
|
|
17267
17469
|
}
|
|
17268
17470
|
|
|
17269
17471
|
// src/dynamic-texture/video-texture.ts
|
|
17270
|
-
var
|
|
17472
|
+
var import_core27 = __toESM(require_core(), 1);
|
|
17271
17473
|
var VideoTexture = class {
|
|
17272
17474
|
/** Device used to create copied and native external texture bindings. */
|
|
17273
17475
|
device;
|
|
@@ -17316,7 +17518,7 @@ void main(void) {
|
|
|
17316
17518
|
* @param props Live video source and copied texture options.
|
|
17317
17519
|
*/
|
|
17318
17520
|
constructor(device, props) {
|
|
17319
|
-
(0,
|
|
17521
|
+
(0, import_core27.assert)(isHTMLVideoElementSource(props?.source) || isVideoFrameSource(props?.source));
|
|
17320
17522
|
this.device = device;
|
|
17321
17523
|
this.id = props.id || uid("video-texture");
|
|
17322
17524
|
this._source = props.source;
|
|
@@ -17330,7 +17532,7 @@ void main(void) {
|
|
|
17330
17532
|
* @param source Next caller-owned video source to follow.
|
|
17331
17533
|
*/
|
|
17332
17534
|
setSource(source4) {
|
|
17333
|
-
(0,
|
|
17535
|
+
(0, import_core27.assert)(isHTMLVideoElementSource(source4) || isVideoFrameSource(source4));
|
|
17334
17536
|
this._destroyExternalTexture();
|
|
17335
17537
|
this._source = source4;
|
|
17336
17538
|
this._sourceVersion++;
|
|
@@ -17408,7 +17610,7 @@ void main(void) {
|
|
|
17408
17610
|
width: size.width,
|
|
17409
17611
|
height: size.height,
|
|
17410
17612
|
format: "rgba8unorm",
|
|
17411
|
-
usage:
|
|
17613
|
+
usage: import_core27.Texture.SAMPLE | import_core27.Texture.COPY_DST,
|
|
17412
17614
|
mipLevels: 1,
|
|
17413
17615
|
sampler: this._sampler
|
|
17414
17616
|
});
|
|
@@ -17443,7 +17645,7 @@ void main(void) {
|
|
|
17443
17645
|
*/
|
|
17444
17646
|
_getResolvedSize() {
|
|
17445
17647
|
const size = getVideoTextureSourceSize(this._source);
|
|
17446
|
-
(0,
|
|
17648
|
+
(0, import_core27.assert)(size.width > 0 && size.height > 0);
|
|
17447
17649
|
return size;
|
|
17448
17650
|
}
|
|
17449
17651
|
/** Observes current source readiness and frame identity before binding resolution. */
|
|
@@ -17508,11 +17710,11 @@ void main(void) {
|
|
|
17508
17710
|
}
|
|
17509
17711
|
|
|
17510
17712
|
// src/passes/shader-pass-renderer.ts
|
|
17511
|
-
var
|
|
17713
|
+
var import_core30 = __toESM(require_core(), 1);
|
|
17512
17714
|
var import_shaders7 = __toESM(require_shaders(), 1);
|
|
17513
17715
|
|
|
17514
17716
|
// src/compute/swap.ts
|
|
17515
|
-
var
|
|
17717
|
+
var import_core28 = __toESM(require_core(), 1);
|
|
17516
17718
|
var Swap = class {
|
|
17517
17719
|
id;
|
|
17518
17720
|
/** The current resource - usually the source for renders or computations */
|
|
@@ -17544,7 +17746,7 @@ void main(void) {
|
|
|
17544
17746
|
(colorAttachment) => typeof colorAttachment !== "string" ? colorAttachment : device.createTexture({
|
|
17545
17747
|
id: `${props.id}-texture-0`,
|
|
17546
17748
|
format: colorAttachment,
|
|
17547
|
-
usage:
|
|
17749
|
+
usage: import_core28.Texture.SAMPLE | import_core28.Texture.RENDER | import_core28.Texture.COPY_SRC | import_core28.Texture.COPY_DST,
|
|
17548
17750
|
width,
|
|
17549
17751
|
height
|
|
17550
17752
|
})
|
|
@@ -17554,7 +17756,7 @@ void main(void) {
|
|
|
17554
17756
|
(colorAttachment) => typeof colorAttachment !== "string" ? colorAttachment : device.createTexture({
|
|
17555
17757
|
id: `${props.id}-texture-1`,
|
|
17556
17758
|
format: colorAttachment,
|
|
17557
|
-
usage:
|
|
17759
|
+
usage: import_core28.Texture.SAMPLE | import_core28.Texture.RENDER | import_core28.Texture.COPY_SRC | import_core28.Texture.COPY_DST,
|
|
17558
17760
|
width,
|
|
17559
17761
|
height
|
|
17560
17762
|
})
|
|
@@ -17618,7 +17820,7 @@ void main(void) {
|
|
|
17618
17820
|
};
|
|
17619
17821
|
|
|
17620
17822
|
// src/compute/computation.ts
|
|
17621
|
-
var
|
|
17823
|
+
var import_core29 = __toESM(require_core(), 1);
|
|
17622
17824
|
var import_shaders6 = __toESM(require_shaders(), 1);
|
|
17623
17825
|
var LOG_DRAW_PRIORITY2 = 2;
|
|
17624
17826
|
var LOG_DRAW_TIMEOUT2 = 1e4;
|
|
@@ -17630,13 +17832,13 @@ void main(void) {
|
|
|
17630
17832
|
* constructor remains the synchronous compatibility path.
|
|
17631
17833
|
*/
|
|
17632
17834
|
static async createAsync(device, props) {
|
|
17633
|
-
const ownsCompilation = !
|
|
17634
|
-
const asyncCompilation = ownsCompilation ?
|
|
17835
|
+
const ownsCompilation = !import_core29.PipelineFactory.getAsyncCompilation(device);
|
|
17836
|
+
const asyncCompilation = ownsCompilation ? import_core29.PipelineFactory.beginAsyncCompilation(device) : import_core29.PipelineFactory.getAsyncCompilation(device);
|
|
17635
17837
|
let computation;
|
|
17636
17838
|
try {
|
|
17637
17839
|
computation = new _Computation(device, props);
|
|
17638
17840
|
} finally {
|
|
17639
|
-
if (ownsCompilation)
|
|
17841
|
+
if (ownsCompilation) import_core29.PipelineFactory.endAsyncCompilation(device, asyncCompilation);
|
|
17640
17842
|
}
|
|
17641
17843
|
try {
|
|
17642
17844
|
if (ownsCompilation) {
|
|
@@ -17651,7 +17853,7 @@ void main(void) {
|
|
|
17651
17853
|
}
|
|
17652
17854
|
}
|
|
17653
17855
|
static defaultProps = {
|
|
17654
|
-
...
|
|
17856
|
+
...import_core29.ComputePipeline.defaultProps,
|
|
17655
17857
|
id: "unnamed",
|
|
17656
17858
|
handle: void 0,
|
|
17657
17859
|
userData: {},
|
|
@@ -17705,6 +17907,9 @@ void main(void) {
|
|
|
17705
17907
|
Object.assign(this.userData, props.userData);
|
|
17706
17908
|
const platformInfo = getPlatformInfo(device);
|
|
17707
17909
|
const resolvedPlugins = (0, import_shaders6.resolveShaderPlugins)(this.props.plugins, platformInfo.shaderLanguage);
|
|
17910
|
+
if (resolvedPlugins.hooks.length > 0) {
|
|
17911
|
+
throw new Error("Computation does not support ShaderPlugin render hooks");
|
|
17912
|
+
}
|
|
17708
17913
|
if (Object.keys(resolvedPlugins.vertexInputs).length > 0 || Object.keys(resolvedPlugins.interStageVariables).length > 0) {
|
|
17709
17914
|
throw new Error(
|
|
17710
17915
|
"Computation does not support ShaderPlugin vertex inputs or interStageVariables"
|
|
@@ -17723,10 +17928,10 @@ void main(void) {
|
|
|
17723
17928
|
const modules = mergeShaderModules(this.props.modules, this.shaderInputs?.getModules());
|
|
17724
17929
|
const defines = { ...resolvedPlugins.defines, ...this.props.defines };
|
|
17725
17930
|
this.props.shaderLayout = mergeShaderModuleBindingsIntoLayout(this.props.shaderLayout, modules) || null;
|
|
17726
|
-
this.pipelineFactory = props.pipelineFactory ||
|
|
17727
|
-
this.shaderFactory = props.shaderFactory ||
|
|
17931
|
+
this.pipelineFactory = props.pipelineFactory || import_core29.PipelineFactory.getDefaultPipelineFactory(this.device);
|
|
17932
|
+
this.shaderFactory = props.shaderFactory || import_core29.ShaderFactory.getDefaultShaderFactory(this.device);
|
|
17728
17933
|
const shaderAssembler = this.props.shaderAssembler;
|
|
17729
|
-
(0,
|
|
17934
|
+
(0, import_core29.assert)(shaderAssembler instanceof WGSLShaderAssembler);
|
|
17730
17935
|
const {
|
|
17731
17936
|
source: source4,
|
|
17732
17937
|
getUniforms: getUniforms2,
|
|
@@ -17750,7 +17955,7 @@ void main(void) {
|
|
|
17750
17955
|
this.props.shaderLayout || inferredShaderLayout || null,
|
|
17751
17956
|
modules
|
|
17752
17957
|
) || null;
|
|
17753
|
-
const asyncCompilation =
|
|
17958
|
+
const asyncCompilation = import_core29.PipelineFactory.getAsyncCompilation(this.device);
|
|
17754
17959
|
if (asyncCompilation) {
|
|
17755
17960
|
this._pipelineInitialization = this._updatePipelineAsync();
|
|
17756
17961
|
asyncCompilation.push(this._pipelineInitialization);
|
|
@@ -17817,7 +18022,7 @@ void main(void) {
|
|
|
17817
18022
|
}
|
|
17818
18023
|
setShaderInputs(shaderInputs) {
|
|
17819
18024
|
this.shaderInputs = shaderInputs;
|
|
17820
|
-
this._uniformStore = new
|
|
18025
|
+
this._uniformStore = new import_core29.UniformStore(this.device, this.shaderInputs.modules);
|
|
17821
18026
|
for (const [moduleName, module] of Object.entries(this.shaderInputs.modules)) {
|
|
17822
18027
|
if (shaderModuleHasUniforms(module)) {
|
|
17823
18028
|
const uniformBuffer = this._uniformStore.getManagedUniformBuffer(moduleName);
|
|
@@ -17886,7 +18091,7 @@ void main(void) {
|
|
|
17886
18091
|
if (!this._pipelineNeedsUpdate) return null;
|
|
17887
18092
|
const previousShader = this.pipeline ? this.shader : null;
|
|
17888
18093
|
if (this.pipeline) {
|
|
17889
|
-
|
|
18094
|
+
import_core29.log.log(1, `Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)();
|
|
17890
18095
|
}
|
|
17891
18096
|
this._pipelineNeedsUpdate = false;
|
|
17892
18097
|
this.shader = this.shaderFactory.createShader({
|
|
@@ -17904,27 +18109,27 @@ void main(void) {
|
|
|
17904
18109
|
_lastLogTime = 0;
|
|
17905
18110
|
_logOpen = false;
|
|
17906
18111
|
_logDrawCallStart() {
|
|
17907
|
-
const logDrawTimeout =
|
|
17908
|
-
if (
|
|
18112
|
+
const logDrawTimeout = import_core29.log.level > 3 ? 0 : LOG_DRAW_TIMEOUT2;
|
|
18113
|
+
if (import_core29.log.level < 2 || Date.now() - this._lastLogTime < logDrawTimeout) {
|
|
17909
18114
|
return;
|
|
17910
18115
|
}
|
|
17911
18116
|
this._lastLogTime = Date.now();
|
|
17912
18117
|
this._logOpen = true;
|
|
17913
|
-
|
|
18118
|
+
import_core29.log.group(LOG_DRAW_PRIORITY2, `>>> DRAWING MODEL ${this.id}`, { collapsed: import_core29.log.level <= 2 })();
|
|
17914
18119
|
}
|
|
17915
18120
|
_logDrawCallEnd() {
|
|
17916
18121
|
if (this._logOpen) {
|
|
17917
18122
|
const uniformTable = this.shaderInputs.getDebugTable();
|
|
17918
|
-
|
|
17919
|
-
|
|
18123
|
+
import_core29.log.table(LOG_DRAW_PRIORITY2, uniformTable)();
|
|
18124
|
+
import_core29.log.groupEnd(LOG_DRAW_PRIORITY2)();
|
|
17920
18125
|
this._logOpen = false;
|
|
17921
18126
|
}
|
|
17922
18127
|
}
|
|
17923
18128
|
_drawCount = 0;
|
|
17924
18129
|
// TODO - fix typing of luma data types
|
|
17925
18130
|
_getBufferOrConstantValues(attribute, dataType) {
|
|
17926
|
-
const TypedArrayConstructor =
|
|
17927
|
-
const typedArray = attribute instanceof
|
|
18131
|
+
const TypedArrayConstructor = import_core29.dataTypeDecoder.getTypedArrayConstructor(dataType);
|
|
18132
|
+
const typedArray = attribute instanceof import_core29.Buffer ? new TypedArrayConstructor(attribute.debugData) : attribute;
|
|
17928
18133
|
return typedArray.toString();
|
|
17929
18134
|
}
|
|
17930
18135
|
};
|
|
@@ -18481,7 +18686,7 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
|
|
|
18481
18686
|
this.parameterBuffer = device.createBuffer({
|
|
18482
18687
|
id: `${optimization.name}-parameters`,
|
|
18483
18688
|
byteLength: Math.max(Math.ceil(optimization.uniformNames.length / 4) * 16, 16),
|
|
18484
|
-
usage:
|
|
18689
|
+
usage: import_core30.Buffer.UNIFORM | import_core30.Buffer.COPY_DST
|
|
18485
18690
|
});
|
|
18486
18691
|
const outputBindings = Object.entries(optimization.outputs).map(
|
|
18487
18692
|
([bindingName, targetName], outputIndex) => ({
|
|
@@ -18766,7 +18971,7 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
|
|
|
18766
18971
|
width: targetSize[0],
|
|
18767
18972
|
height: targetSize[1],
|
|
18768
18973
|
format: spec.format || device.preferredColorFormat,
|
|
18769
|
-
usage:
|
|
18974
|
+
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),
|
|
18770
18975
|
...spec.sampler ? { sampler: spec.sampler } : {}
|
|
18771
18976
|
});
|
|
18772
18977
|
const framebuffer = device.createFramebuffer({
|
|
@@ -18821,7 +19026,7 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
|
|
|
18821
19026
|
}
|
|
18822
19027
|
|
|
18823
19028
|
// src/modules/picking/picking-manager.ts
|
|
18824
|
-
var
|
|
19029
|
+
var import_core31 = __toESM(require_core(), 1);
|
|
18825
19030
|
|
|
18826
19031
|
// src/modules/picking/picking-uniforms.ts
|
|
18827
19032
|
var DEFAULT_HIGHLIGHT_COLOR = [0, 1, 1, 1];
|
|
@@ -19085,13 +19290,13 @@ layout(std140) uniform pickingUniforms {
|
|
|
19085
19290
|
format: "rgba8unorm",
|
|
19086
19291
|
width: 1,
|
|
19087
19292
|
height: 1,
|
|
19088
|
-
usage:
|
|
19293
|
+
usage: import_core31.Texture.RENDER_ATTACHMENT
|
|
19089
19294
|
});
|
|
19090
19295
|
const pickingTexture = this.device.createTexture({
|
|
19091
19296
|
format: "rg32sint",
|
|
19092
19297
|
width: 1,
|
|
19093
19298
|
height: 1,
|
|
19094
|
-
usage:
|
|
19299
|
+
usage: import_core31.Texture.RENDER_ATTACHMENT | import_core31.Texture.COPY_SRC
|
|
19095
19300
|
});
|
|
19096
19301
|
return this.device.createFramebuffer({
|
|
19097
19302
|
colorAttachments: [colorTexture, pickingTexture],
|
|
@@ -19103,7 +19308,7 @@ layout(std140) uniform pickingUniforms {
|
|
|
19103
19308
|
format: "rgba8unorm",
|
|
19104
19309
|
width: 1,
|
|
19105
19310
|
height: 1,
|
|
19106
|
-
usage:
|
|
19311
|
+
usage: import_core31.Texture.RENDER_ATTACHMENT | import_core31.Texture.COPY_SRC
|
|
19107
19312
|
});
|
|
19108
19313
|
return this.device.createFramebuffer({
|
|
19109
19314
|
colorAttachments: [pickingTexture],
|
|
@@ -19125,7 +19330,7 @@ layout(std140) uniform pickingUniforms {
|
|
|
19125
19330
|
const layout = pickTexture.computeMemoryLayout({ width: 1, height: 1 });
|
|
19126
19331
|
const readBuffer = this.device.createBuffer({
|
|
19127
19332
|
byteLength: layout.byteLength,
|
|
19128
|
-
usage:
|
|
19333
|
+
usage: import_core31.Buffer.COPY_DST | import_core31.Buffer.MAP_READ
|
|
19129
19334
|
});
|
|
19130
19335
|
try {
|
|
19131
19336
|
pickTexture.readBuffer(
|
|
@@ -19161,7 +19366,7 @@ layout(std140) uniform pickingUniforms {
|
|
|
19161
19366
|
const layout = pickTexture.computeMemoryLayout({ width: 1, height: 1 });
|
|
19162
19367
|
const readBuffer = this.device.createBuffer({
|
|
19163
19368
|
byteLength: layout.byteLength,
|
|
19164
|
-
usage:
|
|
19369
|
+
usage: import_core31.Buffer.COPY_DST | import_core31.Buffer.MAP_READ
|
|
19165
19370
|
});
|
|
19166
19371
|
try {
|
|
19167
19372
|
pickTexture.readBuffer(
|
|
@@ -19843,7 +20048,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
19843
20048
|
}
|
|
19844
20049
|
|
|
19845
20050
|
// src/scenegraph/controllers/skin-controller.ts
|
|
19846
|
-
var
|
|
20051
|
+
var import_core32 = __toESM(require_core(), 1);
|
|
19847
20052
|
var SkinController = class {
|
|
19848
20053
|
bindings;
|
|
19849
20054
|
scenes;
|
|
@@ -19874,7 +20079,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
19874
20079
|
target: binding.jointMatrices
|
|
19875
20080
|
});
|
|
19876
20081
|
if (binding.skinJointMatrices) {
|
|
19877
|
-
if (binding.skinJointMatrices instanceof
|
|
20082
|
+
if (binding.skinJointMatrices instanceof import_core32.Buffer) {
|
|
19878
20083
|
binding.skinJointMatrices.write(binding.jointMatrices);
|
|
19879
20084
|
} else {
|
|
19880
20085
|
binding.skinJointMatrices.writeData(binding.jointMatrices, {
|
|
@@ -19906,7 +20111,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
19906
20111
|
return device.createBuffer({
|
|
19907
20112
|
id: `${id}-skin-joint-matrices`,
|
|
19908
20113
|
byteLength: jointMatrices.byteLength,
|
|
19909
|
-
usage:
|
|
20114
|
+
usage: import_core32.Buffer.STORAGE | import_core32.Buffer.COPY_DST
|
|
19910
20115
|
});
|
|
19911
20116
|
}
|
|
19912
20117
|
const width = jointMatrices.length / 4;
|
|
@@ -19918,7 +20123,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
19918
20123
|
format: "rgba32float",
|
|
19919
20124
|
width,
|
|
19920
20125
|
height: 1,
|
|
19921
|
-
usage:
|
|
20126
|
+
usage: import_core32.Texture.SAMPLE | import_core32.Texture.COPY_DST,
|
|
19922
20127
|
sampler: { minFilter: "nearest", magFilter: "nearest", mipmapFilter: "nearest" }
|
|
19923
20128
|
});
|
|
19924
20129
|
}
|
|
@@ -19961,7 +20166,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
19961
20166
|
};
|
|
19962
20167
|
|
|
19963
20168
|
// src/scenegraph/controllers/billboard-controller.ts
|
|
19964
|
-
var
|
|
20169
|
+
var import_core34 = __toESM(require_core(), 1);
|
|
19965
20170
|
var BillboardController = class {
|
|
19966
20171
|
scenes;
|
|
19967
20172
|
bindings = /* @__PURE__ */ new Map();
|
|
@@ -19972,8 +20177,8 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
19972
20177
|
const { definition } = binding;
|
|
19973
20178
|
const forward = new Vector3(definition.viewDirection || [0, 0, 1]);
|
|
19974
20179
|
const up = new Vector3(definition.up || [0, 1, 0]);
|
|
19975
|
-
(0,
|
|
19976
|
-
(0,
|
|
20180
|
+
(0, import_core34.assert)(forward.magnitude() > 0 && up.magnitude() > 0);
|
|
20181
|
+
(0, import_core34.assert)(
|
|
19977
20182
|
new Vector3(forward).normalize().cross(new Vector3(up).normalize()).magnitude() > 1e-6
|
|
19978
20183
|
);
|
|
19979
20184
|
this.bindings.set(binding.node, binding);
|
|
@@ -19983,7 +20188,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
19983
20188
|
getDrawEntries(options) {
|
|
19984
20189
|
const { sceneIndex = 0, cameraId = "default" } = options;
|
|
19985
20190
|
const scene = this.scenes[sceneIndex];
|
|
19986
|
-
(0,
|
|
20191
|
+
(0, import_core34.assert)(scene);
|
|
19987
20192
|
const viewMatrix = new Matrix4(options.viewMatrix);
|
|
19988
20193
|
const cameraMatrix = new Matrix4(viewMatrix).invert();
|
|
19989
20194
|
const cameraPosition = new Vector3(cameraMatrix.getTranslation());
|
|
@@ -20092,7 +20297,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
20092
20297
|
}
|
|
20093
20298
|
|
|
20094
20299
|
// src/scenegraph/controllers/area-light-controller.ts
|
|
20095
|
-
var
|
|
20300
|
+
var import_core36 = __toESM(require_core(), 1);
|
|
20096
20301
|
var AreaLightController = class {
|
|
20097
20302
|
scenes;
|
|
20098
20303
|
matrixAuthoredNodes = /* @__PURE__ */ new Set();
|
|
@@ -20102,11 +20307,11 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
20102
20307
|
for (const node of matrixNodes) this.matrixAuthoredNodes.add(node);
|
|
20103
20308
|
for (const { node, definition, matrixAuthored } of bindings) {
|
|
20104
20309
|
if (matrixAuthored) this.matrixAuthoredNodes.add(node);
|
|
20105
|
-
(0,
|
|
20106
|
-
(0,
|
|
20107
|
-
(0,
|
|
20108
|
-
(0,
|
|
20109
|
-
(0,
|
|
20310
|
+
(0, import_core36.assert)(definition && (definition.type === "rect" || definition.type === "disk"));
|
|
20311
|
+
(0, import_core36.assert)(Number.isFinite(definition.height ?? 1) && (definition.height ?? 1) > 0);
|
|
20312
|
+
(0, import_core36.assert)(Number.isFinite(definition.intensity ?? 1e3) && (definition.intensity ?? 1e3) > 0);
|
|
20313
|
+
(0, import_core36.assert)(Number.isFinite(definition.width ?? 1) && (definition.width ?? 1) > 0);
|
|
20314
|
+
(0, import_core36.assert)(
|
|
20110
20315
|
(definition.color || [1, 1, 1]).every(
|
|
20111
20316
|
(component) => Number.isFinite(component) && component >= 0
|
|
20112
20317
|
)
|
|
@@ -20172,17 +20377,17 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
20172
20377
|
function getMatrixRotation(matrix) {
|
|
20173
20378
|
const horizontal = new Vector3(matrix[0], matrix[1], matrix[2]);
|
|
20174
20379
|
const vertical = new Vector3(matrix[4], matrix[5], matrix[6]);
|
|
20175
|
-
(0,
|
|
20380
|
+
(0, import_core36.assert)(horizontal.magnitude() > 0 && vertical.magnitude() > 0);
|
|
20176
20381
|
horizontal.normalize();
|
|
20177
20382
|
vertical.normalize();
|
|
20178
20383
|
vertical.subtract(new Vector3(horizontal).scale(vertical.dot(horizontal)));
|
|
20179
|
-
(0,
|
|
20384
|
+
(0, import_core36.assert)(vertical.magnitude() > 1e-8);
|
|
20180
20385
|
vertical.normalize();
|
|
20181
20386
|
const forward = new Vector3(horizontal).cross(vertical).normalize();
|
|
20182
20387
|
const authoredForward = new Vector3(matrix[8], matrix[9], matrix[10]);
|
|
20183
|
-
(0,
|
|
20388
|
+
(0, import_core36.assert)(authoredForward.magnitude() > 0);
|
|
20184
20389
|
authoredForward.normalize();
|
|
20185
|
-
(0,
|
|
20390
|
+
(0, import_core36.assert)(Math.abs(forward.dot(authoredForward)) > 1e-8);
|
|
20186
20391
|
if (forward.dot(authoredForward) < 0) forward.negate();
|
|
20187
20392
|
return new Matrix4([
|
|
20188
20393
|
horizontal[0],
|
|
@@ -20740,15 +20945,15 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
20740
20945
|
};
|
|
20741
20946
|
|
|
20742
20947
|
// src/audio/audio-graph.ts
|
|
20743
|
-
var
|
|
20948
|
+
var import_core38 = __toESM(require_core(), 1);
|
|
20744
20949
|
var AudioGraph = class {
|
|
20745
20950
|
constructor(definition, context, destination, getEmitterInputs) {
|
|
20746
20951
|
this.definition = definition;
|
|
20747
20952
|
for (const node of definition.nodes)
|
|
20748
|
-
(0,
|
|
20953
|
+
(0, import_core38.assert)(!node.bypass || node.kind !== "splitter" && node.kind !== "channelmerger");
|
|
20749
20954
|
const validateEndpoint = (index, port = 0) => {
|
|
20750
|
-
(0,
|
|
20751
|
-
(0,
|
|
20955
|
+
(0, import_core38.assert)(Number.isInteger(index) && Boolean(definition.nodes[index]));
|
|
20956
|
+
(0, import_core38.assert)(Number.isInteger(port) && port >= 0);
|
|
20752
20957
|
};
|
|
20753
20958
|
for (const edge of definition.connections) {
|
|
20754
20959
|
validateEndpoint(edge.from.node, edge.from.output);
|
|
@@ -20756,16 +20961,16 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
20756
20961
|
}
|
|
20757
20962
|
for (const input of definition.inputs || []) {
|
|
20758
20963
|
validateEndpoint(input.node, input.input);
|
|
20759
|
-
(0,
|
|
20964
|
+
(0, import_core38.assert)(Number.isInteger(input.source) && input.source >= 0);
|
|
20760
20965
|
}
|
|
20761
20966
|
for (const output of definition.outputs || []) {
|
|
20762
20967
|
validateEndpoint(output.node, output.output);
|
|
20763
|
-
(0,
|
|
20968
|
+
(0, import_core38.assert)(Number.isInteger(output.emitter) && output.emitter >= 0);
|
|
20764
20969
|
}
|
|
20765
20970
|
const visiting = /* @__PURE__ */ new Set();
|
|
20766
20971
|
const visited = /* @__PURE__ */ new Set();
|
|
20767
20972
|
const visit = (index) => {
|
|
20768
|
-
(0,
|
|
20973
|
+
(0, import_core38.assert)(definition.nodes[index] && !visiting.has(index));
|
|
20769
20974
|
if (visited.has(index)) return;
|
|
20770
20975
|
visiting.add(index);
|
|
20771
20976
|
for (const edge of definition.connections) if (edge.from.node === index) visit(edge.to.node);
|
|
@@ -20826,7 +21031,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
20826
21031
|
/** Apply a scene-driven gain change using the authored transition shape. */
|
|
20827
21032
|
setGain(index, gain, time = this.nodes[index].context.currentTime) {
|
|
20828
21033
|
const definition = this.definition.nodes[index];
|
|
20829
|
-
(0,
|
|
21034
|
+
(0, import_core38.assert)(definition.kind === "gain" && !definition.bypass && gain >= 0);
|
|
20830
21035
|
const parameter = this.nodes[index].gain;
|
|
20831
21036
|
const duration = definition.params.duration ?? 0;
|
|
20832
21037
|
const initialGain = parameter.value;
|
|
@@ -20836,7 +21041,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
20836
21041
|
parameter.setValueAtTime(gain, time);
|
|
20837
21042
|
} else if (definition.params.interpolation === "custom") {
|
|
20838
21043
|
const curve = definition.params.curve;
|
|
20839
|
-
(0,
|
|
21044
|
+
(0, import_core38.assert)(curve && curve.length >= 2 && curve.every((value) => value >= 0 && value <= 1));
|
|
20840
21045
|
parameter.setValueCurveAtTime(
|
|
20841
21046
|
Float32Array.from(curve, (value) => value * gain),
|
|
20842
21047
|
time,
|
|
@@ -20921,7 +21126,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
20921
21126
|
}
|
|
20922
21127
|
|
|
20923
21128
|
// src/audio/audio-environment.ts
|
|
20924
|
-
var
|
|
21129
|
+
var import_core40 = __toESM(require_core(), 1);
|
|
20925
21130
|
function selectAudioEnvironmentZone(zones, position) {
|
|
20926
21131
|
let selected;
|
|
20927
21132
|
for (const zone of zones) {
|
|
@@ -21014,7 +21219,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
21014
21219
|
}
|
|
21015
21220
|
};
|
|
21016
21221
|
function createParametricAudioResponse(context, parameters) {
|
|
21017
|
-
(0,
|
|
21222
|
+
(0, import_core40.assert)((parameters.density ?? 1) === 1 && (parameters.diffusion ?? 1) === 1);
|
|
21018
21223
|
const presets = {
|
|
21019
21224
|
generic: [1.49, 0.83, 7e-3, 0.011],
|
|
21020
21225
|
smallRoom: [0.4, 0.83, 2e-3, 3e-3],
|
|
@@ -21031,12 +21236,12 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
21031
21236
|
underwater: [1.49, 0.1, 7e-3, 0.011]
|
|
21032
21237
|
};
|
|
21033
21238
|
const preset = parameters.preset ? presets[parameters.preset] : void 0;
|
|
21034
|
-
(0,
|
|
21239
|
+
(0, import_core40.assert)(!parameters.preset || preset);
|
|
21035
21240
|
const decay = parameters.decayTime ?? preset?.[0] ?? 1.5;
|
|
21036
21241
|
const highFrequencyDecay = decay * (parameters.decayHFRatio ?? preset?.[1] ?? 0.83);
|
|
21037
21242
|
const earlyDelay = parameters.reflectionsDelay ?? preset?.[2] ?? 0.02;
|
|
21038
21243
|
const tailDelay = earlyDelay + (parameters.reverbDelay ?? preset?.[3] ?? 0.04);
|
|
21039
|
-
(0,
|
|
21244
|
+
(0, import_core40.assert)(decay > 0 && highFrequencyDecay > 0 && earlyDelay >= 0 && tailDelay >= earlyDelay);
|
|
21040
21245
|
const response = context.createBuffer(
|
|
21041
21246
|
2,
|
|
21042
21247
|
Math.ceil((tailDelay + Math.max(decay, highFrequencyDecay)) * context.sampleRate),
|
|
@@ -21060,7 +21265,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
21060
21265
|
}
|
|
21061
21266
|
|
|
21062
21267
|
// src/audio/audio-controller.ts
|
|
21063
|
-
var
|
|
21268
|
+
var import_core41 = __toESM(require_core(), 1);
|
|
21064
21269
|
var AudioController = class {
|
|
21065
21270
|
gain;
|
|
21066
21271
|
definition;
|
|
@@ -21170,25 +21375,25 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
21170
21375
|
/** Change a graph gain using its authored interpolation and duration. */
|
|
21171
21376
|
setGraphGain(graphIndex, nodeIndex, gain) {
|
|
21172
21377
|
const graph = this.graphs.get(graphIndex);
|
|
21173
|
-
(0,
|
|
21378
|
+
(0, import_core41.assert)(!this.destroyed && graph);
|
|
21174
21379
|
graph.setGain(nodeIndex, gain);
|
|
21175
21380
|
}
|
|
21176
21381
|
startSource(sourceIndex, startTime, autoplayOnly, connect) {
|
|
21177
21382
|
const definition = this.definition.sources[sourceIndex];
|
|
21178
|
-
(0,
|
|
21383
|
+
(0, import_core41.assert)(definition);
|
|
21179
21384
|
if (autoplayOnly && !definition.autoPlay) return;
|
|
21180
21385
|
const context = this.options.audioContext;
|
|
21181
21386
|
const extended = definition.graph;
|
|
21182
21387
|
const oscillator = extended?.oscillator;
|
|
21183
|
-
(0,
|
|
21388
|
+
(0, import_core41.assert)(!(definition.audio !== void 0 && oscillator));
|
|
21184
21389
|
let source4;
|
|
21185
21390
|
if (oscillator) {
|
|
21186
21391
|
const node = context.createOscillator();
|
|
21187
21392
|
node.frequency.value = oscillator.frequency ?? 440;
|
|
21188
21393
|
node.detune.value = oscillator.detune ?? 0;
|
|
21189
|
-
(0,
|
|
21394
|
+
(0, import_core41.assert)(oscillator.pulseWidth === void 0 || oscillator.pulseWidth === 0.5);
|
|
21190
21395
|
if (oscillator.type === "custom") {
|
|
21191
|
-
(0,
|
|
21396
|
+
(0, import_core41.assert)(oscillator.periodicWave);
|
|
21192
21397
|
node.setPeriodicWave(
|
|
21193
21398
|
context.createPeriodicWave(
|
|
21194
21399
|
new Float32Array(oscillator.periodicWave.real),
|
|
@@ -21199,7 +21404,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
21199
21404
|
source4 = node;
|
|
21200
21405
|
} else {
|
|
21201
21406
|
const node = context.createBufferSource();
|
|
21202
|
-
(0,
|
|
21407
|
+
(0, import_core41.assert)(definition.audio !== void 0);
|
|
21203
21408
|
node.buffer = this.buffers.get(definition.audio);
|
|
21204
21409
|
node.loop = definition.loop ?? false;
|
|
21205
21410
|
node.loopStart = extended?.loopStart ?? 0;
|
|
@@ -21344,15 +21549,15 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
21344
21549
|
}
|
|
21345
21550
|
addEmitter(index, node) {
|
|
21346
21551
|
const definition = this.definition.emitters[index];
|
|
21347
|
-
(0,
|
|
21552
|
+
(0, import_core41.assert)(
|
|
21348
21553
|
definition && (definition.type === "global" || definition.type === "positional" && node)
|
|
21349
21554
|
);
|
|
21350
|
-
(0,
|
|
21555
|
+
(0, import_core41.assert)(
|
|
21351
21556
|
!definition.positional?.shapeType || ["cone", "omnidirectional"].includes(definition.positional.shapeType)
|
|
21352
21557
|
);
|
|
21353
21558
|
for (const sourceIndex of this.graphEmitters.has(index) ? [] : definition.sources || []) {
|
|
21354
21559
|
const source4 = this.definition.sources[sourceIndex];
|
|
21355
|
-
(0,
|
|
21560
|
+
(0, import_core41.assert)(
|
|
21356
21561
|
source4 && (source4.audio !== void 0 ? this.definition.audio[source4.audio] : source4.graph?.oscillator)
|
|
21357
21562
|
);
|
|
21358
21563
|
}
|
|
@@ -21397,7 +21602,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
21397
21602
|
const audioIndices = new Set(
|
|
21398
21603
|
[...sourceIndices].map((index) => {
|
|
21399
21604
|
const source4 = this.definition.sources[index];
|
|
21400
|
-
(0,
|
|
21605
|
+
(0, import_core41.assert)(
|
|
21401
21606
|
source4 && (source4.audio !== void 0 ? this.definition.audio[source4.audio] : source4.graph?.oscillator)
|
|
21402
21607
|
);
|
|
21403
21608
|
return source4.audio;
|
|
@@ -21434,7 +21639,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
21434
21639
|
const reverb = environment.reverb;
|
|
21435
21640
|
if (!reverb) return;
|
|
21436
21641
|
const response = reverb.type === "impulseResponse" ? this.buffers.get(reverb.audio) : createParametricAudioResponse(audioContext, reverb);
|
|
21437
|
-
(0,
|
|
21642
|
+
(0, import_core41.assert)(response);
|
|
21438
21643
|
const bus = new AudioReverbBus(audioContext, response, this.gain, {
|
|
21439
21644
|
...reverb,
|
|
21440
21645
|
normalize: reverb.type === "impulseResponse" ? reverb.normalize : false
|
|
@@ -21543,7 +21748,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
21543
21748
|
var legacyColorPicking = import_shaders8.picking;
|
|
21544
21749
|
|
|
21545
21750
|
// src/geometry/ring-geometry.ts
|
|
21546
|
-
var
|
|
21751
|
+
var import_core43 = __toESM(require_core(), 1);
|
|
21547
21752
|
var RingGeometry = class extends Geometry2 {
|
|
21548
21753
|
constructor(props = {}) {
|
|
21549
21754
|
const {
|
|
@@ -21554,7 +21759,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
21554
21759
|
startAngle = 0,
|
|
21555
21760
|
angle: angle2 = Math.PI * 2
|
|
21556
21761
|
} = props;
|
|
21557
|
-
(0,
|
|
21762
|
+
(0, import_core43.assert)(
|
|
21558
21763
|
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
|
|
21559
21764
|
);
|
|
21560
21765
|
const halfHeight = height / 2;
|
|
@@ -21738,7 +21943,7 @@ struct PublishedTransforms {bodyIndex:i32,viewProjection:mat4x4f}
|
|
|
21738
21943
|
};
|
|
21739
21944
|
|
|
21740
21945
|
// src/scenegraph/controllers/morph-controller.ts
|
|
21741
|
-
var
|
|
21946
|
+
var import_core46 = __toESM(require_core(), 1);
|
|
21742
21947
|
function setMorphWeights(node, weights) {
|
|
21743
21948
|
node.userData["morphWeights"] = [...weights];
|
|
21744
21949
|
const meshes = node.userData["morphMeshes"] || [];
|
|
@@ -21765,7 +21970,7 @@ struct PublishedTransforms {bodyIndex:i32,viewProjection:mat4x4f}
|
|
|
21765
21970
|
function updateMorphWeights(state, weights) {
|
|
21766
21971
|
state.values.fill(0);
|
|
21767
21972
|
state.values.set(weights.slice(0, state.values.length));
|
|
21768
|
-
if (state.data instanceof
|
|
21973
|
+
if (state.data instanceof import_core46.Buffer) {
|
|
21769
21974
|
state.data.write(state.values);
|
|
21770
21975
|
} else {
|
|
21771
21976
|
state.data.writeData(state.values, { width: state.packedTargetCount, height: 1 });
|