@luma.gl/engine 10.0.0-alpha.8 → 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/dist.dev.js +277 -291
- package/dist/dist.min.js +58 -58
- 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/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 +1 -1
- package/dist/graph/tables/index.cjs.map +1 -1
- package/dist/index.cjs +3 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/model/gpu-vector-bindings.cjs +10 -3
- 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 +12 -3
- package/dist/model/gpu-vector-bindings.js.map +1 -1
- package/dist/model/gpu-vector-draw-batches.cjs +4 -3
- 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 +4 -3
- package/dist/model/gpu-vector-draw-batches.js.map +1 -1
- package/dist/model/gpu-vector-model.cjs +22 -14
- package/dist/model/gpu-vector-model.d.ts +8 -2
- package/dist/model/gpu-vector-model.d.ts.map +1 -1
- package/dist/model/gpu-vector-model.js +28 -14
- package/dist/model/gpu-vector-model.js.map +1 -1
- package/dist/model/model.d.ts +1 -1
- package/dist/model/model.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/package.json +6 -6
- 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/geometry/gpu-vector-geometry-adapter.ts +19 -1
- package/src/geometry/gpu-vector-geometry.ts +3 -0
- 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/index.ts +2 -0
- package/src/model/gpu-vector-bindings.ts +11 -3
- package/src/model/gpu-vector-draw-batches.ts +12 -10
- package/src/model/gpu-vector-model.ts +54 -16
- package/src/model/model.ts +1 -1
- package/src/splats/README.md +46 -0
- package/src/splats/splat-data.ts +53 -45
package/dist/dist.dev.js
CHANGED
|
@@ -145,6 +145,7 @@ var __exports__ = (() => {
|
|
|
145
145
|
makeAnimationLoop: () => makeAnimationLoop,
|
|
146
146
|
makeEdgeGeometry: () => makeEdgeGeometry,
|
|
147
147
|
makeEdgeGeometryFromGeometries: () => makeEdgeGeometryFromGeometries,
|
|
148
|
+
makeGPUVectorGeometry: () => makeGPUVectorGeometry,
|
|
148
149
|
makeInterleavedGeometry: () => makeInterleavedGeometry,
|
|
149
150
|
makeMaterialAnimationBinding: () => makeMaterialAnimationBinding,
|
|
150
151
|
makeNodeAnimationBinding: () => makeNodeAnimationBinding,
|
|
@@ -5731,184 +5732,6 @@ var __exports__ = (() => {
|
|
|
5731
5732
|
return typeof value;
|
|
5732
5733
|
}
|
|
5733
5734
|
|
|
5734
|
-
// ../shaders/src/module-injectors.ts
|
|
5735
|
-
var MODULE_INJECTORS_VS = (
|
|
5736
|
-
/* glsl */
|
|
5737
|
-
`#ifdef MODULE_LOGDEPTH
|
|
5738
|
-
logdepth_adjustPosition(gl_Position);
|
|
5739
|
-
#endif
|
|
5740
|
-
`
|
|
5741
|
-
);
|
|
5742
|
-
var MODULE_INJECTORS_FS = (
|
|
5743
|
-
/* glsl */
|
|
5744
|
-
`#ifdef MODULE_MATERIAL
|
|
5745
|
-
fragColor = material_filterColor(fragColor);
|
|
5746
|
-
#endif
|
|
5747
|
-
|
|
5748
|
-
#ifdef MODULE_LIGHTING
|
|
5749
|
-
fragColor = lighting_filterColor(fragColor);
|
|
5750
|
-
#endif
|
|
5751
|
-
|
|
5752
|
-
#ifdef MODULE_FOG
|
|
5753
|
-
fragColor = fog_filterColor(fragColor);
|
|
5754
|
-
#endif
|
|
5755
|
-
|
|
5756
|
-
#ifdef MODULE_PICKING
|
|
5757
|
-
fragColor = picking_filterHighlightColor(fragColor);
|
|
5758
|
-
fragColor = picking_filterPickingColor(fragColor);
|
|
5759
|
-
#endif
|
|
5760
|
-
|
|
5761
|
-
#ifdef MODULE_LOGDEPTH
|
|
5762
|
-
logdepth_setFragDepth();
|
|
5763
|
-
#endif
|
|
5764
|
-
`
|
|
5765
|
-
);
|
|
5766
|
-
|
|
5767
|
-
// ../shaders/src/lib/shader-assembly/shader-injections.ts
|
|
5768
|
-
var MODULE_INJECTORS = {
|
|
5769
|
-
vertex: MODULE_INJECTORS_VS,
|
|
5770
|
-
fragment: MODULE_INJECTORS_FS
|
|
5771
|
-
};
|
|
5772
|
-
var REGEX_START_OF_MAIN = /void\s+main\s*\([^)]*\)\s*\{\n?/;
|
|
5773
|
-
var REGEX_END_OF_MAIN = /}\n?[^{}]*$/;
|
|
5774
|
-
var fragments = [];
|
|
5775
|
-
var DECLARATION_INJECT_MARKER = "__LUMA_INJECT_DECLARATIONS__";
|
|
5776
|
-
function normalizeInjections(injections) {
|
|
5777
|
-
const result = { vertex: {}, fragment: {} };
|
|
5778
|
-
for (const hook in injections) {
|
|
5779
|
-
let injection = injections[hook];
|
|
5780
|
-
const stage = getHookStage(hook);
|
|
5781
|
-
if (typeof injection === "string") {
|
|
5782
|
-
injection = {
|
|
5783
|
-
order: 0,
|
|
5784
|
-
injection
|
|
5785
|
-
};
|
|
5786
|
-
}
|
|
5787
|
-
result[stage][hook] = injection;
|
|
5788
|
-
}
|
|
5789
|
-
return result;
|
|
5790
|
-
}
|
|
5791
|
-
function getHookStage(hook) {
|
|
5792
|
-
const type = hook.slice(0, 2);
|
|
5793
|
-
switch (type) {
|
|
5794
|
-
case "vs":
|
|
5795
|
-
return "vertex";
|
|
5796
|
-
case "fs":
|
|
5797
|
-
return "fragment";
|
|
5798
|
-
default:
|
|
5799
|
-
throw new Error(type);
|
|
5800
|
-
}
|
|
5801
|
-
}
|
|
5802
|
-
function injectShader(source4, stage, inject, injectStandardStubs = false, language = "glsl", entryPoints = {}) {
|
|
5803
|
-
const isVertex = stage === "vertex";
|
|
5804
|
-
for (const key in inject) {
|
|
5805
|
-
const fragmentData = inject[key];
|
|
5806
|
-
fragmentData.sort((a, b) => a.order - b.order);
|
|
5807
|
-
fragments.length = fragmentData.length;
|
|
5808
|
-
for (let i = 0, len2 = fragmentData.length; i < len2; ++i) {
|
|
5809
|
-
fragments[i] = fragmentData[i].injection;
|
|
5810
|
-
}
|
|
5811
|
-
const fragmentString = `${fragments.join("\n")}
|
|
5812
|
-
`;
|
|
5813
|
-
switch (key) {
|
|
5814
|
-
// declarations are injected before the main function
|
|
5815
|
-
case "vs:#decl":
|
|
5816
|
-
if (language === "wgsl" || isVertex) {
|
|
5817
|
-
source4 = source4.replace(DECLARATION_INJECT_MARKER, fragmentString);
|
|
5818
|
-
}
|
|
5819
|
-
break;
|
|
5820
|
-
// inject code at the beginning of the main function
|
|
5821
|
-
case "vs:#main-start":
|
|
5822
|
-
if (language === "wgsl" || isVertex) {
|
|
5823
|
-
source4 = language === "wgsl" ? injectWGSLStageMain(source4, "vertex", fragmentString, "start", entryPoints.vertex) : source4.replace(REGEX_START_OF_MAIN, (match) => match + fragmentString);
|
|
5824
|
-
}
|
|
5825
|
-
break;
|
|
5826
|
-
// inject code at the end of main function
|
|
5827
|
-
case "vs:#main-end":
|
|
5828
|
-
if (language === "wgsl" || isVertex) {
|
|
5829
|
-
source4 = language === "wgsl" ? injectWGSLStageMain(source4, "vertex", fragmentString, "end", entryPoints.vertex) : source4.replace(REGEX_END_OF_MAIN, (match) => fragmentString + match);
|
|
5830
|
-
}
|
|
5831
|
-
break;
|
|
5832
|
-
// declarations are injected before the main function
|
|
5833
|
-
case "fs:#decl":
|
|
5834
|
-
if (language === "wgsl" || !isVertex) {
|
|
5835
|
-
source4 = source4.replace(DECLARATION_INJECT_MARKER, fragmentString);
|
|
5836
|
-
}
|
|
5837
|
-
break;
|
|
5838
|
-
// inject code at the beginning of the main function
|
|
5839
|
-
case "fs:#main-start":
|
|
5840
|
-
if (language === "wgsl" || !isVertex) {
|
|
5841
|
-
source4 = language === "wgsl" ? injectWGSLStageMain(
|
|
5842
|
-
source4,
|
|
5843
|
-
"fragment",
|
|
5844
|
-
fragmentString,
|
|
5845
|
-
"start",
|
|
5846
|
-
entryPoints.fragment
|
|
5847
|
-
) : source4.replace(REGEX_START_OF_MAIN, (match) => match + fragmentString);
|
|
5848
|
-
}
|
|
5849
|
-
break;
|
|
5850
|
-
// inject code at the end of main function
|
|
5851
|
-
case "fs:#main-end":
|
|
5852
|
-
if (language === "wgsl" || !isVertex) {
|
|
5853
|
-
source4 = language === "wgsl" ? injectWGSLStageMain(source4, "fragment", fragmentString, "end", entryPoints.fragment) : source4.replace(REGEX_END_OF_MAIN, (match) => fragmentString + match);
|
|
5854
|
-
}
|
|
5855
|
-
break;
|
|
5856
|
-
default:
|
|
5857
|
-
source4 = source4.replace(key, (match) => match + fragmentString);
|
|
5858
|
-
}
|
|
5859
|
-
}
|
|
5860
|
-
source4 = source4.replace(DECLARATION_INJECT_MARKER, "");
|
|
5861
|
-
if (injectStandardStubs) {
|
|
5862
|
-
source4 = source4.replace(/\}\s*$/, (match) => match + MODULE_INJECTORS[stage]);
|
|
5863
|
-
}
|
|
5864
|
-
return source4;
|
|
5865
|
-
}
|
|
5866
|
-
function injectWGSLStageMain(source4, stage, fragmentString, position, entryPoint) {
|
|
5867
|
-
const bodyRange = getWGSLStageFunctionBodyRange(source4, stage, entryPoint);
|
|
5868
|
-
if (!bodyRange) {
|
|
5869
|
-
return source4;
|
|
5870
|
-
}
|
|
5871
|
-
if (position === "start") {
|
|
5872
|
-
const insertionIndex = bodyRange.openBraceIndex + 1;
|
|
5873
|
-
return `${source4.slice(0, insertionIndex)}
|
|
5874
|
-
${fragmentString}${source4.slice(insertionIndex)}`;
|
|
5875
|
-
}
|
|
5876
|
-
return `${source4.slice(0, bodyRange.closeBraceIndex)}${fragmentString}${source4.slice(
|
|
5877
|
-
bodyRange.closeBraceIndex
|
|
5878
|
-
)}`;
|
|
5879
|
-
}
|
|
5880
|
-
function getWGSLStageFunctionBodyRange(source4, stage, entryPoint) {
|
|
5881
|
-
const stageAttribute = stage === "vertex" ? "@vertex" : "@fragment";
|
|
5882
|
-
const stageIndex = source4.indexOf(stageAttribute);
|
|
5883
|
-
if (stageIndex < 0) {
|
|
5884
|
-
return null;
|
|
5885
|
-
}
|
|
5886
|
-
const functionIndex = entryPoint ? source4.search(new RegExp(`\\bfn\\s+${escapeRegExp(entryPoint)}\\s*\\(`)) : source4.indexOf("fn", stageIndex);
|
|
5887
|
-
if (functionIndex < 0) {
|
|
5888
|
-
return null;
|
|
5889
|
-
}
|
|
5890
|
-
const openBraceIndex = source4.indexOf("{", functionIndex);
|
|
5891
|
-
if (openBraceIndex < 0) {
|
|
5892
|
-
return null;
|
|
5893
|
-
}
|
|
5894
|
-
let braceDepth = 0;
|
|
5895
|
-
for (let index = openBraceIndex; index < source4.length; index++) {
|
|
5896
|
-
const character = source4[index];
|
|
5897
|
-
if (character === "{") {
|
|
5898
|
-
braceDepth++;
|
|
5899
|
-
} else if (character === "}") {
|
|
5900
|
-
braceDepth--;
|
|
5901
|
-
if (braceDepth === 0) {
|
|
5902
|
-
return { openBraceIndex, closeBraceIndex: index };
|
|
5903
|
-
}
|
|
5904
|
-
}
|
|
5905
|
-
}
|
|
5906
|
-
return null;
|
|
5907
|
-
}
|
|
5908
|
-
function escapeRegExp(value) {
|
|
5909
|
-
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
5910
|
-
}
|
|
5911
|
-
|
|
5912
5735
|
// ../shaders/src/lib/shader-module/shader-module.ts
|
|
5913
5736
|
function initializeShaderModules(modules) {
|
|
5914
5737
|
modules.map((module) => initializeShaderModule(module));
|
|
@@ -5918,15 +5741,10 @@ ${fragmentString}${source4.slice(insertionIndex)}`;
|
|
|
5918
5741
|
return;
|
|
5919
5742
|
}
|
|
5920
5743
|
initializeShaderModules(module.dependencies || []);
|
|
5921
|
-
const {
|
|
5922
|
-
propTypes = {},
|
|
5923
|
-
deprecations = [],
|
|
5924
|
-
// defines = {},
|
|
5925
|
-
inject = {}
|
|
5926
|
-
} = module;
|
|
5744
|
+
const { propTypes = {}, deprecations = [] } = module;
|
|
5927
5745
|
const instance = {
|
|
5928
|
-
|
|
5929
|
-
|
|
5746
|
+
parsedDeprecations: parseDeprecationDefinitions(deprecations),
|
|
5747
|
+
normalizedInjections: { vertex: {}, fragment: {} }
|
|
5930
5748
|
};
|
|
5931
5749
|
if (propTypes) {
|
|
5932
5750
|
instance.propValidators = makePropValidators(propTypes);
|
|
@@ -6099,11 +5917,10 @@ ${fragmentString}${source4.slice(insertionIndex)}`;
|
|
|
6099
5917
|
}
|
|
6100
5918
|
/**
|
|
6101
5919
|
* Register a shader hook
|
|
6102
|
-
* @param hook
|
|
6103
|
-
* @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.
|
|
6104
5921
|
*/
|
|
6105
|
-
addShaderHook(hook
|
|
6106
|
-
this._hookFunctions.push(
|
|
5922
|
+
addShaderHook(hook) {
|
|
5923
|
+
this._hookFunctions.push(hook);
|
|
6107
5924
|
}
|
|
6108
5925
|
/**
|
|
6109
5926
|
* Remove all registered shader hooks, for example before re-registering hooks for a new
|
|
@@ -6139,6 +5956,181 @@ ${fragmentString}${source4.slice(insertionIndex)}`;
|
|
|
6139
5956
|
}
|
|
6140
5957
|
};
|
|
6141
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
|
+
|
|
6142
6134
|
// ../shaders/src/lib/shader-module/shader-module-uniform-layout.ts
|
|
6143
6135
|
var GLSL_UNIFORM_BLOCK_FIELD_REGEXP = /^(?:uniform\s+)?(?:(?:lowp|mediump|highp)\s+)?[A-Za-z0-9_]+(?:<[^>]+>)?\s+([A-Za-z0-9_]+)(?:\s*\[[^\]]+\])?\s*;/;
|
|
6144
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;
|
|
@@ -6415,8 +6407,10 @@ ${DECLARATION_INJECT_MARKER}
|
|
|
6415
6407
|
let result = "";
|
|
6416
6408
|
for (const hookName in hookFunctions) {
|
|
6417
6409
|
const hookFunction = hookFunctions[hookName];
|
|
6418
|
-
const
|
|
6419
|
-
|
|
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} {
|
|
6420
6414
|
`;
|
|
6421
6415
|
if (hookFunction.header) {
|
|
6422
6416
|
result += ` ${hookFunction.header}`;
|
|
@@ -6436,23 +6430,24 @@ ${DECLARATION_INJECT_MARKER}
|
|
|
6436
6430
|
}
|
|
6437
6431
|
return result;
|
|
6438
6432
|
}
|
|
6439
|
-
function normalizeShaderHooks(hookFunctions, pluginHooks = [], language) {
|
|
6433
|
+
function normalizeShaderHooks(hookFunctions, pluginHooks = [], language = "glsl") {
|
|
6440
6434
|
const result = { vertex: {}, fragment: {} };
|
|
6441
|
-
for (const
|
|
6442
|
-
const
|
|
6443
|
-
|
|
6444
|
-
|
|
6445
|
-
|
|
6446
|
-
|
|
6447
|
-
|
|
6448
|
-
|
|
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
|
+
}
|
|
6449
6444
|
}
|
|
6450
6445
|
for (const hook of pluginHooks) {
|
|
6451
|
-
const
|
|
6446
|
+
const selected = normalizeShaderHooks([hook], [], language);
|
|
6452
6447
|
for (const stage of ["vertex", "fragment"]) {
|
|
6453
|
-
for (const [name, declaration] of Object.entries(
|
|
6448
|
+
for (const [name, declaration] of Object.entries(selected[stage])) {
|
|
6454
6449
|
const existing = result[stage][name];
|
|
6455
|
-
if (existing && existing.signature !== declaration.signature) {
|
|
6450
|
+
if (existing && (existing.signature !== declaration.signature || (existing.returnType || "void") !== (declaration.returnType || "void"))) {
|
|
6456
6451
|
throw new Error(`Conflicting ShaderPlugin hook ${name}`);
|
|
6457
6452
|
}
|
|
6458
6453
|
result[stage][name] = existing || declaration;
|
|
@@ -6481,30 +6476,6 @@ ${DECLARATION_INJECT_MARKER}
|
|
|
6481
6476
|
}
|
|
6482
6477
|
}
|
|
6483
6478
|
}
|
|
6484
|
-
function addShaderHookToRegistry(registry, hookFunction) {
|
|
6485
|
-
const options = typeof hookFunction === "string" ? {} : hookFunction;
|
|
6486
|
-
const hook = (typeof hookFunction === "string" ? hookFunction : hookFunction.hook).trim();
|
|
6487
|
-
const stageSeparatorIndex = hook.indexOf(":");
|
|
6488
|
-
const shaderStage = hook.slice(0, stageSeparatorIndex);
|
|
6489
|
-
const signature = hook.slice(stageSeparatorIndex + 1);
|
|
6490
|
-
const name = hook.split("(")[0].trim();
|
|
6491
|
-
const normalizedHook = {
|
|
6492
|
-
hook: name,
|
|
6493
|
-
signature,
|
|
6494
|
-
header: options.header || "",
|
|
6495
|
-
footer: options.footer || ""
|
|
6496
|
-
};
|
|
6497
|
-
switch (shaderStage) {
|
|
6498
|
-
case "vs":
|
|
6499
|
-
registry.vertex[name] = normalizedHook;
|
|
6500
|
-
break;
|
|
6501
|
-
case "fs":
|
|
6502
|
-
registry.fragment[name] = normalizedHook;
|
|
6503
|
-
break;
|
|
6504
|
-
default:
|
|
6505
|
-
throw new Error(shaderStage);
|
|
6506
|
-
}
|
|
6507
|
-
}
|
|
6508
6479
|
|
|
6509
6480
|
// ../shaders/src/lib/glsl-utils/get-shader-info.ts
|
|
6510
6481
|
function getShaderInfo(source4, defaultName) {
|
|
@@ -7761,8 +7732,11 @@ ${getApplicationDefines(allDefines)}
|
|
|
7761
7732
|
const declInjections = {};
|
|
7762
7733
|
const mainInjections = {};
|
|
7763
7734
|
appendInjections(pluginInjections, hookInjections, declInjections, mainInjections);
|
|
7764
|
-
|
|
7765
|
-
|
|
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];
|
|
7766
7740
|
const match = /^(v|f)s:(#)?([\w-]+)$/.exec(key);
|
|
7767
7741
|
if (match) {
|
|
7768
7742
|
const hash = match[2];
|
|
@@ -7807,19 +7781,6 @@ ${getApplicationDefines(allDefines)}
|
|
|
7807
7781
|
}
|
|
7808
7782
|
const moduleSource = getShaderModuleSource(module, stage, log8);
|
|
7809
7783
|
assembledSource += moduleSource;
|
|
7810
|
-
const injections = module.instance?.normalizedInjections[stage] || {};
|
|
7811
|
-
for (const key in injections) {
|
|
7812
|
-
const match = /^(v|f)s:#([\w-]+)$/.exec(key);
|
|
7813
|
-
if (match) {
|
|
7814
|
-
const name = match[2];
|
|
7815
|
-
const injectionType = name === "decl" ? declInjections : mainInjections;
|
|
7816
|
-
injectionType[key] = injectionType[key] || [];
|
|
7817
|
-
injectionType[key].push(injections[key]);
|
|
7818
|
-
} else {
|
|
7819
|
-
hookInjections[key] = hookInjections[key] || [];
|
|
7820
|
-
hookInjections[key].push(injections[key]);
|
|
7821
|
-
}
|
|
7822
|
-
}
|
|
7823
7784
|
}
|
|
7824
7785
|
validateShaderHookInjections(hookFunctionMap, hookInjections, stage);
|
|
7825
7786
|
assembledSource += "// ----- MAIN SHADER SOURCE -------------------------";
|
|
@@ -8697,8 +8658,11 @@ ${getApplicationDefines(allDefines)}
|
|
|
8697
8658
|
const declInjections = {};
|
|
8698
8659
|
const mainInjections = {};
|
|
8699
8660
|
appendInjections(pluginInjections, hookInjections, declInjections, mainInjections);
|
|
8700
|
-
|
|
8701
|
-
|
|
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];
|
|
8702
8666
|
const match = /^(v|f)s:(#)?([\w-]+)$/.exec(key);
|
|
8703
8667
|
if (match) {
|
|
8704
8668
|
const hash = match[2];
|
|
@@ -8752,19 +8716,6 @@ ${getApplicationDefines(allDefines)}
|
|
|
8752
8716
|
checkShaderModuleDeprecations(module, coreSource, log8);
|
|
8753
8717
|
}
|
|
8754
8718
|
assembledSource += moduleSource;
|
|
8755
|
-
const injections = getWGSLModuleInjections(module);
|
|
8756
|
-
for (const key in injections) {
|
|
8757
|
-
const match = /^(v|f)s:#([\w-]+)$/.exec(key);
|
|
8758
|
-
if (match) {
|
|
8759
|
-
const name = match[2];
|
|
8760
|
-
const injectionType = name === "decl" ? declInjections : mainInjections;
|
|
8761
|
-
injectionType[key] = injectionType[key] || [];
|
|
8762
|
-
injectionType[key].push(injections[key]);
|
|
8763
|
-
} else if (isShaderHookRegistered(hookFunctionMap, key)) {
|
|
8764
|
-
hookInjections[key] = hookInjections[key] || [];
|
|
8765
|
-
hookInjections[key].push(injections[key]);
|
|
8766
|
-
}
|
|
8767
|
-
}
|
|
8768
8719
|
}
|
|
8769
8720
|
assembledSource += INJECT_SHADER_DECLARATIONS;
|
|
8770
8721
|
assembledSource = injectShader(
|
|
@@ -8824,12 +8775,6 @@ ${getApplicationDefines(allDefines)}
|
|
|
8824
8775
|
});
|
|
8825
8776
|
}
|
|
8826
8777
|
}
|
|
8827
|
-
function getWGSLModuleInjections(module) {
|
|
8828
|
-
return {
|
|
8829
|
-
...module.instance?.normalizedInjections.vertex || {},
|
|
8830
|
-
...module.instance?.normalizedInjections.fragment || {}
|
|
8831
|
-
};
|
|
8832
|
-
}
|
|
8833
8778
|
function getWGSLDeclarationInjections(declarationInjections) {
|
|
8834
8779
|
const unifiedDeclarations = [
|
|
8835
8780
|
...declarationInjections["vs:#decl"] || [],
|
|
@@ -9720,7 +9665,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
9720
9665
|
}
|
|
9721
9666
|
|
|
9722
9667
|
// src/model/gpu-vector-draw-batches.ts
|
|
9723
|
-
function drawGPUVectorGroups(model, geometry, attributes, syncBindings, draw) {
|
|
9668
|
+
function drawGPUVectorGroups(model, geometry, attributes, syncBindings, draw, inferDrawCount) {
|
|
9724
9669
|
const geometryInputs = geometry.inputs;
|
|
9725
9670
|
const attributeInputs = attributes.inputs;
|
|
9726
9671
|
const geometryLayouts = geometry.sourceLayouts;
|
|
@@ -9758,16 +9703,17 @@ ${getApplicationDefines(allDefines)}
|
|
|
9758
9703
|
);
|
|
9759
9704
|
syncBindings();
|
|
9760
9705
|
const vertexOffset = geometry.rowCount !== void 0 ? geometryOffsets[geometryBatchIndex] : attributes.vertexCount !== void 0 ? attributeOffsets[attributeBatchIndex] : 0;
|
|
9761
|
-
|
|
9762
|
-
|
|
9763
|
-
|
|
9764
|
-
|
|
9765
|
-
|
|
9766
|
-
|
|
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
|
+
)
|
|
9767
9714
|
)
|
|
9768
|
-
)
|
|
9769
|
-
)
|
|
9770
|
-
if (attributes.instanceCount !== void 0)
|
|
9715
|
+
);
|
|
9716
|
+
if (inferDrawCount === "instance" && attributes.instanceCount !== void 0)
|
|
9771
9717
|
model.setInstanceCount(
|
|
9772
9718
|
Math.max(
|
|
9773
9719
|
0,
|
|
@@ -9825,8 +9771,14 @@ ${getApplicationDefines(allDefines)}
|
|
|
9825
9771
|
vertexCount;
|
|
9826
9772
|
instanceCount;
|
|
9827
9773
|
constantBuffers = {};
|
|
9828
|
-
setInputs(columns, explicitLayouts, stepMode) {
|
|
9829
|
-
|
|
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
|
+
}
|
|
9830
9782
|
this.claimedNames.clear();
|
|
9831
9783
|
this.inputs = columns;
|
|
9832
9784
|
this.sourceLayouts = explicitLayouts;
|
|
@@ -9852,7 +9804,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
9852
9804
|
if (!column) continue;
|
|
9853
9805
|
if (!isConstant(column) && !Array.isArray(column.data))
|
|
9854
9806
|
throw new TypeError(`Expected a GPU vector or constant for ${name}`);
|
|
9855
|
-
if (!isConstant(column)) {
|
|
9807
|
+
if (!isConstant(column) && enforceMatchingVectorLengths) {
|
|
9856
9808
|
const layout = layouts.find(
|
|
9857
9809
|
(layout2) => layout2.name === name || layout2.attributes?.some((attribute) => attribute.attribute === name)
|
|
9858
9810
|
);
|
|
@@ -13421,7 +13373,8 @@ ${getApplicationDefines(allDefines)}
|
|
|
13421
13373
|
}
|
|
13422
13374
|
static defaultProps = {
|
|
13423
13375
|
...import_core14.RenderPipeline.defaultProps,
|
|
13424
|
-
|
|
13376
|
+
inferDrawCount: "no",
|
|
13377
|
+
enforceMatchingVectorLengths: true,
|
|
13425
13378
|
geometry: null,
|
|
13426
13379
|
attributeVectors: void 0,
|
|
13427
13380
|
source: void 0,
|
|
@@ -13872,20 +13825,27 @@ ${getApplicationDefines(allDefines)}
|
|
|
13872
13825
|
/** Replaces per-vertex mesh vectors while preserving supplemental attributes. */
|
|
13873
13826
|
setGeometryVectors(vectors, bufferLayouts) {
|
|
13874
13827
|
bufferLayouts ??= this.getExplicitVectorLayouts(vectors) ?? this.getExplicitVectorLayouts(vectors, this.geometryVectorBindings.sourceLayouts);
|
|
13875
|
-
|
|
13876
|
-
if (
|
|
13828
|
+
this.validateVectorLengthPolicy();
|
|
13829
|
+
if (this.props.enforceMatchingVectorLengths) validateGPUVectorBatchStructure(vectors);
|
|
13830
|
+
if (this.props.enforceMatchingVectorLengths && (!this.isInstanced || this.attributeVectorBindings.vertexCount !== void 0))
|
|
13877
13831
|
validateGPUVectorBatchStructure([
|
|
13878
13832
|
...Object.values(vectors),
|
|
13879
13833
|
...Object.values(this.attributeVectorBindings.inputs)
|
|
13880
13834
|
]);
|
|
13881
|
-
this.geometryVectorBindings.setInputs(
|
|
13835
|
+
this.geometryVectorBindings.setInputs(
|
|
13836
|
+
vectors,
|
|
13837
|
+
bufferLayouts,
|
|
13838
|
+
"vertex",
|
|
13839
|
+
this.props.enforceMatchingVectorLengths
|
|
13840
|
+
);
|
|
13882
13841
|
this.claimVectorLayouts(this.geometryVectorBindings);
|
|
13883
13842
|
this.syncVectorBindings();
|
|
13884
13843
|
const rowCount = this.geometryVectorBindings.rowCount;
|
|
13885
13844
|
(0, import_core14.assert)(
|
|
13886
13845
|
rowCount === void 0 || this.attributeVectorBindings.vertexCount === void 0 || rowCount === this.attributeVectorBindings.vertexCount
|
|
13887
13846
|
);
|
|
13888
|
-
|
|
13847
|
+
if (this.props.inferDrawCount === "vertex")
|
|
13848
|
+
this.setVertexCount(rowCount ?? this.attributeVectorBindings.vertexCount ?? 0);
|
|
13889
13849
|
}
|
|
13890
13850
|
/** Replaces supplemental vectors; instanced models default these inputs to instance step mode. */
|
|
13891
13851
|
setAttributeVectors(vectors, bufferLayouts) {
|
|
@@ -13899,7 +13859,8 @@ ${getApplicationDefines(allDefines)}
|
|
|
13899
13859
|
(layout) => layout.name === name || layout.attributes?.some((attribute) => attribute.attribute === name)
|
|
13900
13860
|
)?.stepMode ?? vector.bufferLayout?.stepMode) === "vertex"
|
|
13901
13861
|
);
|
|
13902
|
-
|
|
13862
|
+
this.validateVectorLengthPolicy();
|
|
13863
|
+
if (usesVertexRows && this.props.enforceMatchingVectorLengths)
|
|
13903
13864
|
validateGPUVectorBatchStructure([
|
|
13904
13865
|
...Object.values(this.geometryVectorBindings.inputs),
|
|
13905
13866
|
...Object.values(vectors)
|
|
@@ -13907,14 +13868,15 @@ ${getApplicationDefines(allDefines)}
|
|
|
13907
13868
|
this.attributeVectorBindings.setInputs(
|
|
13908
13869
|
vectors,
|
|
13909
13870
|
bufferLayouts,
|
|
13910
|
-
this.isInstanced ? "instance" : "vertex"
|
|
13871
|
+
this.isInstanced ? "instance" : "vertex",
|
|
13872
|
+
this.props.enforceMatchingVectorLengths
|
|
13911
13873
|
);
|
|
13912
13874
|
this.claimVectorLayouts(this.attributeVectorBindings);
|
|
13913
13875
|
this.syncVectorBindings();
|
|
13914
|
-
if (this.attributeVectorBindings.instanceCount !== void 0)
|
|
13876
|
+
if (this.props.inferDrawCount === "instance" && this.attributeVectorBindings.instanceCount !== void 0)
|
|
13915
13877
|
this.setInstanceCount(this.attributeVectorBindings.instanceCount);
|
|
13916
13878
|
const vertexCount = this.attributeVectorBindings.vertexCount;
|
|
13917
|
-
if (vertexCount !== void 0) {
|
|
13879
|
+
if (vertexCount !== void 0 && this.props.inferDrawCount === "vertex") {
|
|
13918
13880
|
const geometryRowCount = this.geometryVectorBindings.rowCount;
|
|
13919
13881
|
(0, import_core14.assert)(geometryRowCount === void 0 || geometryRowCount === vertexCount);
|
|
13920
13882
|
if (geometryRowCount === void 0) this.setVertexCount(vertexCount);
|
|
@@ -14030,7 +13992,8 @@ ${getApplicationDefines(allDefines)}
|
|
|
14030
13992
|
this.geometryVectorBindings,
|
|
14031
13993
|
this.attributeVectorBindings,
|
|
14032
13994
|
() => this.syncVectorBindings(),
|
|
14033
|
-
() => _GPUVectorModel.prototype.draw.call(this, renderPass)
|
|
13995
|
+
() => _GPUVectorModel.prototype.draw.call(this, renderPass),
|
|
13996
|
+
this.props.inferDrawCount
|
|
14034
13997
|
);
|
|
14035
13998
|
if (success) {
|
|
14036
13999
|
this._lastDrawTimestamp = this.device.timestamp;
|
|
@@ -14131,7 +14094,10 @@ ${getApplicationDefines(allDefines)}
|
|
|
14131
14094
|
}
|
|
14132
14095
|
);
|
|
14133
14096
|
}
|
|
14134
|
-
|
|
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) {
|
|
14135
14101
|
if (count === "instance") {
|
|
14136
14102
|
this.setInstanceCount(rowCount);
|
|
14137
14103
|
} else if (count === "vertex") {
|
|
@@ -14159,13 +14125,19 @@ ${getApplicationDefines(allDefines)}
|
|
|
14159
14125
|
const attributes = this.attributeVectorBindings;
|
|
14160
14126
|
const geometryLayouts = this.getExplicitVectorLayouts(geometry.inputs) ?? geometry.sourceLayouts;
|
|
14161
14127
|
const attributeLayouts = this.getExplicitVectorLayouts(attributes.inputs) ?? attributes.sourceLayouts;
|
|
14162
|
-
geometry.setInputs(
|
|
14128
|
+
geometry.setInputs(
|
|
14129
|
+
geometry.inputs,
|
|
14130
|
+
geometryLayouts,
|
|
14131
|
+
"vertex",
|
|
14132
|
+
this.props.enforceMatchingVectorLengths
|
|
14133
|
+
);
|
|
14163
14134
|
attributes.setInputs(
|
|
14164
14135
|
attributes.inputs,
|
|
14165
14136
|
attributeLayouts,
|
|
14166
|
-
this.isInstanced ? "instance" : "vertex"
|
|
14137
|
+
this.isInstanced ? "instance" : "vertex",
|
|
14138
|
+
this.props.enforceMatchingVectorLengths
|
|
14167
14139
|
);
|
|
14168
|
-
if (!this.isInstanced || attributes.vertexCount !== void 0)
|
|
14140
|
+
if (this.props.enforceMatchingVectorLengths && (!this.isInstanced || attributes.vertexCount !== void 0))
|
|
14169
14141
|
validateGPUVectorBatchStructure([
|
|
14170
14142
|
...Object.values(geometry.inputs),
|
|
14171
14143
|
...Object.values(attributes.inputs)
|
|
@@ -14807,6 +14779,9 @@ ${getApplicationDefines(allDefines)}
|
|
|
14807
14779
|
topology;
|
|
14808
14780
|
vertexCount;
|
|
14809
14781
|
bufferLayout;
|
|
14782
|
+
/** Releases resources owned by uploaded geometry; borrowed vectors remain caller-owned. */
|
|
14783
|
+
destroy() {
|
|
14784
|
+
}
|
|
14810
14785
|
constructor(props) {
|
|
14811
14786
|
this.attributes = props.attributes;
|
|
14812
14787
|
this.indices = props.indices ?? null;
|
|
@@ -14818,6 +14793,17 @@ ${getApplicationDefines(allDefines)}
|
|
|
14818
14793
|
|
|
14819
14794
|
// src/geometry/gpu-vector-geometry-adapter.ts
|
|
14820
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
|
+
}
|
|
14821
14807
|
function makeGPUVectorGeometryFromGPUGeometry(geometry) {
|
|
14822
14808
|
const attributes = {};
|
|
14823
14809
|
for (const [name, buffer2] of Object.entries(geometry.attributes)) {
|