@luma.gl/engine 10.0.0-alpha.7 → 10.0.0-alpha.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +441 -222
- package/dist/dist.min.js +59 -59
- 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/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 +3 -0
- package/dist/index.cjs.map +3 -3
- package/dist/index.d.ts +2 -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/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 +57 -16
- package/dist/model/gpu-vector-bindings.d.ts.map +1 -1
- package/dist/model/gpu-vector-bindings.js +65 -15
- package/dist/model/gpu-vector-bindings.js.map +1 -1
- package/dist/model/gpu-vector-draw-batches.cjs +4 -2
- package/dist/model/gpu-vector-draw-batches.d.ts.map +1 -1
- package/dist/model/gpu-vector-draw-batches.js +5 -2
- 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 +41 -3
- package/dist/model/gpu-vector-model.d.ts +8 -1
- package/dist/model/gpu-vector-model.d.ts.map +1 -1
- package/dist/model/gpu-vector-model.js +44 -2
- package/dist/model/gpu-vector-model.js.map +1 -1
- package/dist/model/model.cjs +8 -0
- package/dist/model/model.d.ts +3 -0
- 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-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/compute/computation.ts +3 -0
- package/src/gltf/gltf/gltf-extension-support.ts +27 -5
- 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 +6 -0
- package/src/model/batch-uniform-buffer.ts +51 -0
- package/src/model/gpu-vector-bindings.ts +77 -19
- package/src/model/gpu-vector-draw-batches.ts +5 -2
- package/src/model/gpu-vector-model-batches.ts +5 -0
- package/src/model/gpu-vector-model.ts +47 -2
- package/src/model/model.ts +10 -0
- 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/gpu-splat-graph-renderer.ts +1 -1
- 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,
|
|
@@ -5669,7 +5670,7 @@ var __exports__ = (() => {
|
|
|
5669
5670
|
}
|
|
5670
5671
|
|
|
5671
5672
|
// src/model/gpu-vector-model.ts
|
|
5672
|
-
var
|
|
5673
|
+
var import_core14 = __toESM(require_core(), 1);
|
|
5673
5674
|
var import_shaders3 = __toESM(require_shaders(), 1);
|
|
5674
5675
|
|
|
5675
5676
|
// ../shaders/src/lib/utils/assert.ts
|
|
@@ -6435,10 +6436,28 @@ ${DECLARATION_INJECT_MARKER}
|
|
|
6435
6436
|
}
|
|
6436
6437
|
return result;
|
|
6437
6438
|
}
|
|
6438
|
-
function normalizeShaderHooks(hookFunctions) {
|
|
6439
|
+
function normalizeShaderHooks(hookFunctions, pluginHooks = [], language) {
|
|
6439
6440
|
const result = { vertex: {}, fragment: {} };
|
|
6440
6441
|
for (const hookFunction of hookFunctions) {
|
|
6441
|
-
|
|
6442
|
+
const text = typeof hookFunction === "string" ? hookFunction : hookFunction.hook;
|
|
6443
|
+
const qualified = /^(glsl|wgsl):([\s\S]+)$/.exec(text);
|
|
6444
|
+
if (qualified && qualified[1] !== language) continue;
|
|
6445
|
+
addShaderHookToRegistry(
|
|
6446
|
+
result,
|
|
6447
|
+
qualified ? typeof hookFunction === "string" ? qualified[2] : { ...hookFunction, hook: qualified[2] } : hookFunction
|
|
6448
|
+
);
|
|
6449
|
+
}
|
|
6450
|
+
for (const hook of pluginHooks) {
|
|
6451
|
+
const normalized2 = normalizeShaderHooks([hook]);
|
|
6452
|
+
for (const stage of ["vertex", "fragment"]) {
|
|
6453
|
+
for (const [name, declaration] of Object.entries(normalized2[stage])) {
|
|
6454
|
+
const existing = result[stage][name];
|
|
6455
|
+
if (existing && existing.signature !== declaration.signature) {
|
|
6456
|
+
throw new Error(`Conflicting ShaderPlugin hook ${name}`);
|
|
6457
|
+
}
|
|
6458
|
+
result[stage][name] = existing || declaration;
|
|
6459
|
+
}
|
|
6460
|
+
}
|
|
6442
6461
|
}
|
|
6443
6462
|
return result;
|
|
6444
6463
|
}
|
|
@@ -6468,7 +6487,7 @@ ${DECLARATION_INJECT_MARKER}
|
|
|
6468
6487
|
const stageSeparatorIndex = hook.indexOf(":");
|
|
6469
6488
|
const shaderStage = hook.slice(0, stageSeparatorIndex);
|
|
6470
6489
|
const signature = hook.slice(stageSeparatorIndex + 1);
|
|
6471
|
-
const name = hook.
|
|
6490
|
+
const name = hook.split("(")[0].trim();
|
|
6472
6491
|
const normalizedHook = {
|
|
6473
6492
|
hook: name,
|
|
6474
6493
|
signature,
|
|
@@ -7737,7 +7756,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
7737
7756
|
`;
|
|
7738
7757
|
break;
|
|
7739
7758
|
}
|
|
7740
|
-
const hookFunctionMap = normalizeShaderHooks(hookFunctions);
|
|
7759
|
+
const hookFunctionMap = normalizeShaderHooks(hookFunctions, options.pluginHooks, "glsl");
|
|
7741
7760
|
const hookInjections = {};
|
|
7742
7761
|
const declInjections = {};
|
|
7743
7762
|
const mainInjections = {};
|
|
@@ -8673,7 +8692,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
8673
8692
|
);
|
|
8674
8693
|
const coreSource = pluginVaryingAssembly.source;
|
|
8675
8694
|
let assembledSource = "";
|
|
8676
|
-
const hookFunctionMap = normalizeShaderHooks(hookFunctions);
|
|
8695
|
+
const hookFunctionMap = normalizeShaderHooks(hookFunctions, options.pluginHooks, "wgsl");
|
|
8677
8696
|
const hookInjections = {};
|
|
8678
8697
|
const declInjections = {};
|
|
8679
8698
|
const mainInjections = {};
|
|
@@ -9207,6 +9226,50 @@ ${getApplicationDefines(allDefines)}
|
|
|
9207
9226
|
}
|
|
9208
9227
|
};
|
|
9209
9228
|
|
|
9229
|
+
// src/model/batch-uniform-buffer.ts
|
|
9230
|
+
var import_core7 = __toESM(require_core(), 1);
|
|
9231
|
+
var BatchUniformBuffer = class {
|
|
9232
|
+
constructor(device) {
|
|
9233
|
+
this.device = device;
|
|
9234
|
+
}
|
|
9235
|
+
device;
|
|
9236
|
+
buffer;
|
|
9237
|
+
byteOffset = 0;
|
|
9238
|
+
/** Reserves the entire call before drawing, so growth cannot invalidate an earlier batch. */
|
|
9239
|
+
prepare(byteLength) {
|
|
9240
|
+
if (!this.buffer || this.buffer.byteLength < byteLength) {
|
|
9241
|
+
const capacity = Math.max(1024, (this.buffer?.byteLength ?? 0) * 2, byteLength);
|
|
9242
|
+
const buffer = this.device.createBuffer({
|
|
9243
|
+
id: "batch-uniforms",
|
|
9244
|
+
byteLength: capacity,
|
|
9245
|
+
usage: import_core7.Buffer.UNIFORM | import_core7.Buffer.COPY_DST
|
|
9246
|
+
});
|
|
9247
|
+
this.buffer?.destroy();
|
|
9248
|
+
this.buffer = buffer;
|
|
9249
|
+
}
|
|
9250
|
+
this.byteOffset = 0;
|
|
9251
|
+
}
|
|
9252
|
+
/** Returns the aligned slot size required for a uniform block. */
|
|
9253
|
+
getAlignedByteLength(byteLength) {
|
|
9254
|
+
const alignment = this.device.limits.minUniformBufferOffsetAlignment || 1;
|
|
9255
|
+
return Math.ceil(byteLength / alignment) * alignment;
|
|
9256
|
+
}
|
|
9257
|
+
/** Writes one slot without overwriting earlier batches in this call. */
|
|
9258
|
+
write(data) {
|
|
9259
|
+
(0, import_core7.assert)(this.buffer && this.byteOffset + data.byteLength <= this.buffer.byteLength);
|
|
9260
|
+
const binding = { buffer: this.buffer, offset: this.byteOffset, size: data.byteLength };
|
|
9261
|
+
this.buffer.write(data, binding.offset);
|
|
9262
|
+
this.byteOffset += this.getAlignedByteLength(data.byteLength);
|
|
9263
|
+
return binding;
|
|
9264
|
+
}
|
|
9265
|
+
/** Releases the model-owned allocation. */
|
|
9266
|
+
destroy() {
|
|
9267
|
+
this.buffer?.destroy();
|
|
9268
|
+
this.buffer = void 0;
|
|
9269
|
+
this.byteOffset = 0;
|
|
9270
|
+
}
|
|
9271
|
+
};
|
|
9272
|
+
|
|
9210
9273
|
// src/debug/debug-shader-layout.ts
|
|
9211
9274
|
function getDebugTableForShaderLayout(layout, name) {
|
|
9212
9275
|
const table = {};
|
|
@@ -9371,7 +9434,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
9371
9434
|
}
|
|
9372
9435
|
|
|
9373
9436
|
// src/utils/buffer-layout-helper.ts
|
|
9374
|
-
var
|
|
9437
|
+
var import_core8 = __toESM(require_core(), 1);
|
|
9375
9438
|
var BufferLayoutHelper = class {
|
|
9376
9439
|
bufferLayouts;
|
|
9377
9440
|
constructor(bufferLayouts) {
|
|
@@ -9382,7 +9445,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
9382
9445
|
}
|
|
9383
9446
|
/** Get attribute names from a BufferLayout */
|
|
9384
9447
|
getAttributeNamesForBuffer(bufferLayout) {
|
|
9385
|
-
return (0,
|
|
9448
|
+
return (0, import_core8.getBufferLayoutAttributeNames)(bufferLayout);
|
|
9386
9449
|
}
|
|
9387
9450
|
mergeBufferLayouts(bufferLayouts1, bufferLayouts2) {
|
|
9388
9451
|
const mergedLayouts = [...bufferLayouts1];
|
|
@@ -9399,16 +9462,16 @@ ${getApplicationDefines(allDefines)}
|
|
|
9399
9462
|
};
|
|
9400
9463
|
|
|
9401
9464
|
// src/utils/buffer-layout-order.ts
|
|
9402
|
-
var
|
|
9465
|
+
var import_core9 = __toESM(require_core(), 1);
|
|
9403
9466
|
function sortedBufferLayoutByShaderSourceLocations(shaderLayout, bufferLayout) {
|
|
9404
|
-
const shaderLayoutMap = (0,
|
|
9467
|
+
const shaderLayoutMap = (0, import_core9.getShaderAttributeLocationMap)(shaderLayout);
|
|
9405
9468
|
const sortedLayout = bufferLayout.slice();
|
|
9406
9469
|
sortedLayout.sort((a, b) => {
|
|
9407
|
-
const minLocationA = (0,
|
|
9408
|
-
(0,
|
|
9470
|
+
const minLocationA = (0, import_core9.getMinimumAttributeLocation)(
|
|
9471
|
+
(0, import_core9.getBufferLayoutAttributeNames)(a).map((attributeName) => shaderLayoutMap[attributeName])
|
|
9409
9472
|
);
|
|
9410
|
-
const minLocationB = (0,
|
|
9411
|
-
(0,
|
|
9473
|
+
const minLocationB = (0, import_core9.getMinimumAttributeLocation)(
|
|
9474
|
+
(0, import_core9.getBufferLayoutAttributeNames)(b).map((attributeName) => shaderLayoutMap[attributeName])
|
|
9412
9475
|
);
|
|
9413
9476
|
return minLocationA - minLocationB;
|
|
9414
9477
|
});
|
|
@@ -9571,7 +9634,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
9571
9634
|
}
|
|
9572
9635
|
|
|
9573
9636
|
// src/model/gpu-vector-model-batches.ts
|
|
9574
|
-
var
|
|
9637
|
+
var import_core10 = __toESM(require_core(), 1);
|
|
9575
9638
|
function validateGPUVectorModelLayouts(ownerName, vectors, bufferLayouts) {
|
|
9576
9639
|
for (const [name, vector] of Object.entries(vectors)) {
|
|
9577
9640
|
if (!vector) continue;
|
|
@@ -9635,22 +9698,22 @@ ${getApplicationDefines(allDefines)}
|
|
|
9635
9698
|
if (format.includes("<")) {
|
|
9636
9699
|
throw new Error(`${ownerName} GPUVector "${name}" requires a fixed-width scalar format`);
|
|
9637
9700
|
}
|
|
9638
|
-
return
|
|
9701
|
+
return import_core10.vertexFormatDecoder.getVertexFormatInfo(format);
|
|
9639
9702
|
}
|
|
9640
9703
|
|
|
9641
9704
|
// src/utils/gpu-vector-batch-structure.ts
|
|
9642
|
-
var
|
|
9705
|
+
var import_core11 = __toESM(require_core(), 1);
|
|
9643
9706
|
function validateGPUVectorBatchStructure(vectors) {
|
|
9644
9707
|
let reference;
|
|
9645
9708
|
for (const vector of Object.values(vectors)) {
|
|
9646
9709
|
if (!vector || "isConstant" in vector) continue;
|
|
9647
9710
|
let rowCount = 0;
|
|
9648
9711
|
for (const chunk of vector.data) rowCount += chunk.length;
|
|
9649
|
-
(0,
|
|
9712
|
+
(0, import_core11.assert)(rowCount === vector.length);
|
|
9650
9713
|
if (reference) {
|
|
9651
|
-
(0,
|
|
9714
|
+
(0, import_core11.assert)(vector.length === reference.length && vector.data.length === reference.data.length);
|
|
9652
9715
|
for (let batchIndex = 0; batchIndex < vector.data.length; batchIndex++) {
|
|
9653
|
-
(0,
|
|
9716
|
+
(0, import_core11.assert)(vector.data[batchIndex].length === reference.data[batchIndex].length);
|
|
9654
9717
|
}
|
|
9655
9718
|
} else reference = vector;
|
|
9656
9719
|
}
|
|
@@ -9662,6 +9725,8 @@ ${getApplicationDefines(allDefines)}
|
|
|
9662
9725
|
const attributeInputs = attributes.inputs;
|
|
9663
9726
|
const geometryLayouts = geometry.sourceLayouts;
|
|
9664
9727
|
const attributeLayouts = attributes.sourceLayouts;
|
|
9728
|
+
const geometryBatchLayouts = geometry.layouts;
|
|
9729
|
+
const attributeBatchLayouts = attributes.layouts;
|
|
9665
9730
|
const attributeStepMode = attributes.stepMode;
|
|
9666
9731
|
const geometryBatchCount = geometry.batchCount;
|
|
9667
9732
|
const attributeBatchCount = attributes.batchCount;
|
|
@@ -9685,10 +9750,10 @@ ${getApplicationDefines(allDefines)}
|
|
|
9685
9750
|
for (let batchIndex = 0; batchIndex < drawCount; batchIndex++) {
|
|
9686
9751
|
const geometryBatchIndex = independentInstances ? Math.floor(batchIndex / attributeBatchCount) : Math.min(batchIndex, geometryBatchCount - 1);
|
|
9687
9752
|
const attributeBatchIndex = independentInstances ? batchIndex % attributeBatchCount : Math.min(batchIndex, attributeBatchCount - 1);
|
|
9688
|
-
geometry.setInputs(geometryBatches[geometryBatchIndex],
|
|
9753
|
+
geometry.setInputs(geometryBatches[geometryBatchIndex], geometryBatchLayouts, "vertex");
|
|
9689
9754
|
attributes.setInputs(
|
|
9690
9755
|
attributeBatches[attributeBatchIndex],
|
|
9691
|
-
|
|
9756
|
+
attributeBatchLayouts,
|
|
9692
9757
|
attributeStepMode
|
|
9693
9758
|
);
|
|
9694
9759
|
syncBindings();
|
|
@@ -9740,7 +9805,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
9740
9805
|
}
|
|
9741
9806
|
|
|
9742
9807
|
// src/model/gpu-vector-bindings.ts
|
|
9743
|
-
var
|
|
9808
|
+
var import_core12 = __toESM(require_core(), 1);
|
|
9744
9809
|
var GPUVectorBindings = class {
|
|
9745
9810
|
constructor(device, id) {
|
|
9746
9811
|
this.device = device;
|
|
@@ -9772,21 +9837,17 @@ ${getApplicationDefines(allDefines)}
|
|
|
9772
9837
|
const providedLayouts = explicitLayouts ?? Object.entries(columns).flatMap(
|
|
9773
9838
|
([name, column]) => column && !isConstant(column) && column.bufferLayout ? [{ ...column.bufferLayout, name }] : []
|
|
9774
9839
|
);
|
|
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
|
-
];
|
|
9840
|
+
const inferredLayouts = Object.entries(columns).flatMap(([name, column]) => {
|
|
9841
|
+
if (!column || providedLayouts.some(
|
|
9842
|
+
(layout) => layout.name === name || layout.attributes?.some((attribute) => attribute.attribute === name)
|
|
9843
|
+
))
|
|
9844
|
+
return [];
|
|
9845
|
+
(0, import_core12.assert)(column.format);
|
|
9846
|
+
const format = column.format;
|
|
9847
|
+
const byteStride = isConstant(column) ? 0 : column.byteStride;
|
|
9848
|
+
return [{ name, stepMode, byteStride, attributes: [{ attribute: name, format, byteOffset: 0 }] }];
|
|
9849
|
+
});
|
|
9850
|
+
const layouts = [...providedLayouts, ...consolidateInferredLayouts(columns, inferredLayouts)];
|
|
9790
9851
|
for (const [name, column] of Object.entries(columns)) {
|
|
9791
9852
|
if (!column) continue;
|
|
9792
9853
|
if (!isConstant(column) && !Array.isArray(column.data))
|
|
@@ -9797,10 +9858,10 @@ ${getApplicationDefines(allDefines)}
|
|
|
9797
9858
|
);
|
|
9798
9859
|
const mode = layout?.stepMode ?? stepMode;
|
|
9799
9860
|
if (mode === "instance") {
|
|
9800
|
-
(0,
|
|
9861
|
+
(0, import_core12.assert)(this.instanceCount === void 0 || this.instanceCount === column.length);
|
|
9801
9862
|
this.instanceCount = column.length;
|
|
9802
9863
|
} else {
|
|
9803
|
-
(0,
|
|
9864
|
+
(0, import_core12.assert)(this.vertexCount === void 0 || this.vertexCount === column.length);
|
|
9804
9865
|
this.vertexCount = column.length;
|
|
9805
9866
|
}
|
|
9806
9867
|
this.rowCount = stepMode === "instance" ? this.instanceCount : this.vertexCount;
|
|
@@ -9845,7 +9906,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
9845
9906
|
for (const definition of definitions) {
|
|
9846
9907
|
const column = columns[definition.attribute] ?? (definition.attribute === layout.name ? columns[layout.name] : void 0);
|
|
9847
9908
|
if (!column) continue;
|
|
9848
|
-
(0,
|
|
9909
|
+
(0, import_core12.assert)(column.format === void 0 || column.format === definition.format);
|
|
9849
9910
|
if (isConstant(column)) {
|
|
9850
9911
|
this.constants[definition.attribute] = getShaderConstant(column);
|
|
9851
9912
|
constantByteLength = Math.max(
|
|
@@ -9872,7 +9933,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
9872
9933
|
buffer = this.device.createBuffer({
|
|
9873
9934
|
id: `${this.id}-${layout.name}-constant`,
|
|
9874
9935
|
byteLength: bytes.byteLength,
|
|
9875
|
-
usage:
|
|
9936
|
+
usage: import_core12.Buffer.VERTEX | import_core12.Buffer.COPY_DST | import_core12.Buffer.COPY_SRC
|
|
9876
9937
|
});
|
|
9877
9938
|
this.constantBuffers[layout.name] = buffer;
|
|
9878
9939
|
}
|
|
@@ -9909,7 +9970,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
9909
9970
|
const chunk = vector.data[0];
|
|
9910
9971
|
if (!chunk) return;
|
|
9911
9972
|
const byteOffset = chunk.byteOffset - layoutOffset;
|
|
9912
|
-
(0,
|
|
9973
|
+
(0, import_core12.assert)(byteOffset >= 0);
|
|
9913
9974
|
this.buffers[name] = chunk.buffer;
|
|
9914
9975
|
this.byteOffsets[name] = byteOffset;
|
|
9915
9976
|
}
|
|
@@ -9918,7 +9979,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
9918
9979
|
return Boolean(column && "isConstant" in column && column.isConstant);
|
|
9919
9980
|
}
|
|
9920
9981
|
function getShaderConstant(column) {
|
|
9921
|
-
const information =
|
|
9982
|
+
const information = import_core12.vertexFormatDecoder.getVertexFormatInfo(column.format);
|
|
9922
9983
|
if (column.format === "unorm10-10-10-2") {
|
|
9923
9984
|
const word = column.value[0];
|
|
9924
9985
|
return new Float32Array([
|
|
@@ -9943,9 +10004,52 @@ ${getApplicationDefines(allDefines)}
|
|
|
9943
10004
|
return information.signed ? new Int32Array(values) : new Uint32Array(values);
|
|
9944
10005
|
return new Float32Array(values);
|
|
9945
10006
|
}
|
|
10007
|
+
function consolidateInferredLayouts(columns, layouts) {
|
|
10008
|
+
const result = [];
|
|
10009
|
+
let constantLayout;
|
|
10010
|
+
let constantByteLength = 0;
|
|
10011
|
+
const sortedLayouts = [...layouts].sort((left, right) => {
|
|
10012
|
+
const leftColumn = columns[left.name];
|
|
10013
|
+
const rightColumn = columns[right.name];
|
|
10014
|
+
return (leftColumn && !isConstant(leftColumn) ? leftColumn.data[0]?.byteOffset ?? 0 : 0) - (rightColumn && !isConstant(rightColumn) ? rightColumn.data[0]?.byteOffset ?? 0 : 0);
|
|
10015
|
+
});
|
|
10016
|
+
for (const layout of sortedLayouts) {
|
|
10017
|
+
const column = columns[layout.name];
|
|
10018
|
+
const attribute = layout.attributes[0];
|
|
10019
|
+
if (isConstant(column)) {
|
|
10020
|
+
if (!constantLayout) {
|
|
10021
|
+
constantLayout = { ...layout, attributes: [] };
|
|
10022
|
+
result.push(constantLayout);
|
|
10023
|
+
}
|
|
10024
|
+
const alignment = Math.min(4, column.byteLength);
|
|
10025
|
+
constantByteLength = Math.ceil(constantByteLength / alignment) * alignment;
|
|
10026
|
+
constantLayout.attributes.push({ ...attribute, byteOffset: constantByteLength });
|
|
10027
|
+
constantByteLength += column.byteLength;
|
|
10028
|
+
continue;
|
|
10029
|
+
}
|
|
10030
|
+
const sharedLayout = result.find((candidate) => {
|
|
10031
|
+
const primary = columns[candidate.name];
|
|
10032
|
+
if (!primary || isConstant(primary) || !primary.data.length || !column.data.length)
|
|
10033
|
+
return false;
|
|
10034
|
+
const offset = column.data[0].byteOffset - primary.data[0].byteOffset;
|
|
10035
|
+
return candidate.stepMode === layout.stepMode && candidate.byteStride === layout.byteStride && offset >= 0 && offset + column.rowByteLength <= column.byteStride && column.data.every((chunk, index) => {
|
|
10036
|
+
const primaryChunk = primary.data[index];
|
|
10037
|
+
return chunk.buffer === primaryChunk.buffer && chunk.byteStride === primaryChunk.byteStride && chunk.byteOffset - primaryChunk.byteOffset === offset;
|
|
10038
|
+
});
|
|
10039
|
+
});
|
|
10040
|
+
if (sharedLayout) {
|
|
10041
|
+
const primary = columns[sharedLayout.name];
|
|
10042
|
+
sharedLayout.attributes.push({
|
|
10043
|
+
...attribute,
|
|
10044
|
+
byteOffset: column.data[0].byteOffset - primary.data[0].byteOffset
|
|
10045
|
+
});
|
|
10046
|
+
} else result.push({ ...layout, attributes: [...layout.attributes] });
|
|
10047
|
+
}
|
|
10048
|
+
return result;
|
|
10049
|
+
}
|
|
9946
10050
|
|
|
9947
10051
|
// src/shader-inputs.ts
|
|
9948
|
-
var
|
|
10052
|
+
var import_core13 = __toESM(require_core(), 1);
|
|
9949
10053
|
var import_shaders2 = __toESM(require_shaders(), 1);
|
|
9950
10054
|
|
|
9951
10055
|
// src/model/split-uniforms-and-bindings.ts
|
|
@@ -9995,7 +10099,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
9995
10099
|
for (const resolvedModule of resolvedModules) {
|
|
9996
10100
|
modules[resolvedModule.name] = resolvedModule;
|
|
9997
10101
|
}
|
|
9998
|
-
|
|
10102
|
+
import_core13.log.log(1, "Creating ShaderInputs with modules", Object.keys(modules))();
|
|
9999
10103
|
this.modules = modules;
|
|
10000
10104
|
this.moduleUniforms = {};
|
|
10001
10105
|
this.moduleBindings = {};
|
|
@@ -10003,7 +10107,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
10003
10107
|
if (module) {
|
|
10004
10108
|
this._addModule(module);
|
|
10005
10109
|
if (module.name && name !== module.name && !this.options.disableWarnings) {
|
|
10006
|
-
|
|
10110
|
+
import_core13.log.warn(`Module name: ${name} vs ${module.name}`)();
|
|
10007
10111
|
}
|
|
10008
10112
|
}
|
|
10009
10113
|
}
|
|
@@ -10027,7 +10131,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
10027
10131
|
const module = this.modules[moduleName];
|
|
10028
10132
|
if (!module) {
|
|
10029
10133
|
if (!this.options.disableWarnings) {
|
|
10030
|
-
|
|
10134
|
+
import_core13.log.warn(`Module ${name} not found`)();
|
|
10031
10135
|
}
|
|
10032
10136
|
} else {
|
|
10033
10137
|
const oldUniforms = this.moduleUniforms[moduleName];
|
|
@@ -10222,7 +10326,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
10222
10326
|
var VERSION = true ? "5.0.0" : "untranspiled source";
|
|
10223
10327
|
|
|
10224
10328
|
// ../../node_modules/probe.gl/dist/log/utils/assert.js
|
|
10225
|
-
function
|
|
10329
|
+
function assert7(condition, message) {
|
|
10226
10330
|
if (!condition) {
|
|
10227
10331
|
throw new Error(message || "Assertion failed");
|
|
10228
10332
|
}
|
|
@@ -10244,7 +10348,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
10244
10348
|
default:
|
|
10245
10349
|
return 0;
|
|
10246
10350
|
}
|
|
10247
|
-
|
|
10351
|
+
assert7(Number.isFinite(resolvedLevel) && resolvedLevel >= 0);
|
|
10248
10352
|
return resolvedLevel;
|
|
10249
10353
|
}
|
|
10250
10354
|
function normalizeArguments(opts) {
|
|
@@ -10270,7 +10374,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
10270
10374
|
opts.message = opts.message();
|
|
10271
10375
|
}
|
|
10272
10376
|
const messageType = typeof opts.message;
|
|
10273
|
-
|
|
10377
|
+
assert7(messageType === "string" || messageType === "object");
|
|
10274
10378
|
return Object.assign(opts, { args }, opts.opts);
|
|
10275
10379
|
}
|
|
10276
10380
|
|
|
@@ -10686,7 +10790,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
10686
10790
|
}
|
|
10687
10791
|
_emit(_type, normalized2) {
|
|
10688
10792
|
const method = normalized2.method;
|
|
10689
|
-
|
|
10793
|
+
assert7(method);
|
|
10690
10794
|
normalized2.total = this.getTotal();
|
|
10691
10795
|
normalized2.delta = this.getDelta();
|
|
10692
10796
|
this._deltaTs = probe.getHighResolutionTimer();
|
|
@@ -11112,7 +11216,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
11112
11216
|
}
|
|
11113
11217
|
|
|
11114
11218
|
// ../core/src/api/adapter/resources/buffer.ts
|
|
11115
|
-
var
|
|
11219
|
+
var Buffer4 = class _Buffer extends Resource {
|
|
11116
11220
|
/** Index buffer */
|
|
11117
11221
|
static INDEX = 16;
|
|
11118
11222
|
/** Vertex buffer */
|
|
@@ -11494,6 +11598,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
11494
11598
|
"pvrtc-rgb2unorm-webgl": { f: texture_compression_pvrtc_webgl },
|
|
11495
11599
|
"pvrtc-rgba2unorm-webgl": { f: texture_compression_pvrtc_webgl },
|
|
11496
11600
|
// WEBGL_compressed_texture_etc1
|
|
11601
|
+
"etc1-rgb-unorm-webgl": { f: texture_compression_etc1_webgl },
|
|
11497
11602
|
"etc1-rbg-unorm-webgl": { f: texture_compression_etc1_webgl },
|
|
11498
11603
|
// WEBGL_compressed_texture_atc
|
|
11499
11604
|
"atc-rgb-unorm-webgl": { f: texture_compression_atc_webgl },
|
|
@@ -12293,7 +12398,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
12293
12398
|
}
|
|
12294
12399
|
|
|
12295
12400
|
// ../core/src/dynamic/dynamic-buffer/dynamic-buffer.ts
|
|
12296
|
-
var DEFAULT_MAX_DEBUG_DATA_BYTE_LENGTH =
|
|
12401
|
+
var DEFAULT_MAX_DEBUG_DATA_BYTE_LENGTH = Buffer4.DEBUG_DATA_MAX_LENGTH;
|
|
12297
12402
|
var DynamicBuffer = class {
|
|
12298
12403
|
/** Device that owns the backing buffer. */
|
|
12299
12404
|
device;
|
|
@@ -12360,7 +12465,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
12360
12465
|
usage: bufferProps.usage ?? adoptedBuffer?.usage,
|
|
12361
12466
|
indexType: bufferProps.indexType ?? adoptedBuffer?.indexType
|
|
12362
12467
|
};
|
|
12363
|
-
if ((normalizedBufferProps.usage || 0) &
|
|
12468
|
+
if ((normalizedBufferProps.usage || 0) & Buffer4.INDEX && !normalizedBufferProps.indexType) {
|
|
12364
12469
|
if (bufferProps.data instanceof Uint32Array) {
|
|
12365
12470
|
normalizedBufferProps.indexType = "uint32";
|
|
12366
12471
|
} else if (bufferProps.data instanceof Uint16Array) {
|
|
@@ -12930,7 +13035,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
12930
13035
|
const layout = this.texture.computeMemoryLayout({ width, height, depthOrArrayLayers });
|
|
12931
13036
|
const buffer = this.device.createBuffer({
|
|
12932
13037
|
byteLength: layout.byteLength,
|
|
12933
|
-
usage:
|
|
13038
|
+
usage: Buffer4.COPY_DST | Buffer4.MAP_READ
|
|
12934
13039
|
});
|
|
12935
13040
|
this.texture.readBuffer(
|
|
12936
13041
|
{
|
|
@@ -13294,13 +13399,13 @@ ${getApplicationDefines(allDefines)}
|
|
|
13294
13399
|
var GPUVectorModel = class _GPUVectorModel {
|
|
13295
13400
|
/** Creates a model while allowing the backend to compile its render pipeline asynchronously. */
|
|
13296
13401
|
static async createAsync(device, props) {
|
|
13297
|
-
const ownsCompilation = !
|
|
13298
|
-
const asyncCompilation = ownsCompilation ?
|
|
13402
|
+
const ownsCompilation = !import_core14.PipelineFactory.getAsyncCompilation(device);
|
|
13403
|
+
const asyncCompilation = ownsCompilation ? import_core14.PipelineFactory.beginAsyncCompilation(device) : import_core14.PipelineFactory.getAsyncCompilation(device);
|
|
13299
13404
|
let model;
|
|
13300
13405
|
try {
|
|
13301
13406
|
model = new this(device, props);
|
|
13302
13407
|
} finally {
|
|
13303
|
-
if (ownsCompilation)
|
|
13408
|
+
if (ownsCompilation) import_core14.PipelineFactory.endAsyncCompilation(device, asyncCompilation);
|
|
13304
13409
|
}
|
|
13305
13410
|
try {
|
|
13306
13411
|
if (ownsCompilation) {
|
|
@@ -13315,7 +13420,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
13315
13420
|
}
|
|
13316
13421
|
}
|
|
13317
13422
|
static defaultProps = {
|
|
13318
|
-
...
|
|
13423
|
+
...import_core14.RenderPipeline.defaultProps,
|
|
13319
13424
|
gpuVectorCount: "instance",
|
|
13320
13425
|
geometry: null,
|
|
13321
13426
|
attributeVectors: void 0,
|
|
@@ -13413,6 +13518,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
13413
13518
|
_uniformStore;
|
|
13414
13519
|
_attributeInfos = {};
|
|
13415
13520
|
props;
|
|
13521
|
+
batchUniformBuffer;
|
|
13416
13522
|
geometryVectorBindings;
|
|
13417
13523
|
attributeVectorBindings;
|
|
13418
13524
|
explicitBufferLayout = [];
|
|
@@ -13497,7 +13603,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
13497
13603
|
const isWebGPU = this.device.type === "webgpu";
|
|
13498
13604
|
if (isWebGPU && this.props.source) {
|
|
13499
13605
|
const shaderAssembler = this.props.shaderAssembler;
|
|
13500
|
-
(0,
|
|
13606
|
+
(0, import_core14.assert)(isShaderAssemblerForLanguage(shaderAssembler, "wgsl"));
|
|
13501
13607
|
const {
|
|
13502
13608
|
source: source4,
|
|
13503
13609
|
getUniforms: getUniforms2,
|
|
@@ -13509,6 +13615,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
13509
13615
|
...this.props,
|
|
13510
13616
|
modules,
|
|
13511
13617
|
defines,
|
|
13618
|
+
pluginHooks: resolvedPlugins.hooks,
|
|
13512
13619
|
pluginInjections: resolvedPlugins.injections,
|
|
13513
13620
|
pluginVertexInputs: resolvedPlugins.vertexInputs,
|
|
13514
13621
|
pluginInterStageVariables: resolvedPlugins.interStageVariables
|
|
@@ -13533,12 +13640,13 @@ ${getApplicationDefines(allDefines)}
|
|
|
13533
13640
|
this.props.shaderLayout = mergeShaderModuleBindingsIntoLayout(shaderLayout || null, modules) || null;
|
|
13534
13641
|
} else {
|
|
13535
13642
|
const shaderAssembler = this.props.shaderAssembler;
|
|
13536
|
-
(0,
|
|
13643
|
+
(0, import_core14.assert)(isShaderAssemblerForLanguage(shaderAssembler, "glsl"));
|
|
13537
13644
|
const { vs: vs4, fs: fs4, getUniforms: getUniforms2 } = shaderAssembler.assembleGLSLShaderPair({
|
|
13538
13645
|
platformInfo,
|
|
13539
13646
|
...this.props,
|
|
13540
13647
|
modules,
|
|
13541
13648
|
defines,
|
|
13649
|
+
pluginHooks: resolvedPlugins.hooks,
|
|
13542
13650
|
pluginInjections: resolvedPlugins.injections,
|
|
13543
13651
|
pluginVertexInputs: resolvedPlugins.vertexInputs,
|
|
13544
13652
|
pluginInterStageVariables: resolvedPlugins.interStageVariables
|
|
@@ -13548,9 +13656,9 @@ ${getApplicationDefines(allDefines)}
|
|
|
13548
13656
|
this._getModuleUniforms = getUniforms2;
|
|
13549
13657
|
this._bindingTable = [];
|
|
13550
13658
|
}
|
|
13551
|
-
this.pipelineFactory = props.pipelineFactory ||
|
|
13552
|
-
this.shaderFactory = props.shaderFactory ||
|
|
13553
|
-
const asyncCompilation =
|
|
13659
|
+
this.pipelineFactory = props.pipelineFactory || import_core14.PipelineFactory.getDefaultPipelineFactory(this.device);
|
|
13660
|
+
this.shaderFactory = props.shaderFactory || import_core14.ShaderFactory.getDefaultShaderFactory(this.device);
|
|
13661
|
+
const asyncCompilation = import_core14.PipelineFactory.getAsyncCompilation(this.device);
|
|
13554
13662
|
if (asyncCompilation) {
|
|
13555
13663
|
this._pipelineInitialization = this._initializePipelineAsync(props);
|
|
13556
13664
|
asyncCompilation.push(this._pipelineInitialization);
|
|
@@ -13620,6 +13728,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
13620
13728
|
this.geometryVectorBindings.destroy();
|
|
13621
13729
|
this.attributeVectorBindings.destroy();
|
|
13622
13730
|
this._uniformStore?.destroy();
|
|
13731
|
+
this.batchUniformBuffer?.destroy();
|
|
13623
13732
|
this._destroyed = true;
|
|
13624
13733
|
}
|
|
13625
13734
|
}
|
|
@@ -13667,12 +13776,12 @@ ${getApplicationDefines(allDefines)}
|
|
|
13667
13776
|
return this.drawVectorGroups(renderPass);
|
|
13668
13777
|
}
|
|
13669
13778
|
if (this._drawBlockedReason && !this._pipelineNeedsUpdate) {
|
|
13670
|
-
|
|
13779
|
+
import_core14.log.info(LOG_DRAW_PRIORITY, `>>> DRAWING ABORTED ${this.id}: ${this._drawBlockedReason}`)();
|
|
13671
13780
|
return false;
|
|
13672
13781
|
}
|
|
13673
13782
|
const loadingBinding = this._areBindingsLoading();
|
|
13674
13783
|
if (loadingBinding) {
|
|
13675
|
-
|
|
13784
|
+
import_core14.log.info(LOG_DRAW_PRIORITY, `>>> DRAWING ABORTED ${this.id}: ${loadingBinding} not loaded`)();
|
|
13676
13785
|
return false;
|
|
13677
13786
|
}
|
|
13678
13787
|
this._syncAttachmentFormats(renderPass);
|
|
@@ -13696,7 +13805,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
13696
13805
|
this.pipeline = this._updatePipeline();
|
|
13697
13806
|
pipelineErrored = this.pipeline.isErrored;
|
|
13698
13807
|
if (pipelineErrored) {
|
|
13699
|
-
|
|
13808
|
+
import_core14.log.info(
|
|
13700
13809
|
LOG_DRAW_PRIORITY,
|
|
13701
13810
|
`>>> DRAWING ABORTED ${this.id}: ${PIPELINE_INITIALIZATION_FAILED}`
|
|
13702
13811
|
)();
|
|
@@ -13704,7 +13813,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
13704
13813
|
} else {
|
|
13705
13814
|
const drawValidationError = this.vertexArray.getDrawValidationError();
|
|
13706
13815
|
if (drawValidationError) {
|
|
13707
|
-
|
|
13816
|
+
import_core14.log.info(LOG_DRAW_PRIORITY, `>>> DRAWING ABORTED ${this.id}: ${drawValidationError}`)();
|
|
13708
13817
|
this._drawBlockedReason = drawValidationError;
|
|
13709
13818
|
drawSuccess = false;
|
|
13710
13819
|
} else {
|
|
@@ -13773,7 +13882,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
13773
13882
|
this.claimVectorLayouts(this.geometryVectorBindings);
|
|
13774
13883
|
this.syncVectorBindings();
|
|
13775
13884
|
const rowCount = this.geometryVectorBindings.rowCount;
|
|
13776
|
-
(0,
|
|
13885
|
+
(0, import_core14.assert)(
|
|
13777
13886
|
rowCount === void 0 || this.attributeVectorBindings.vertexCount === void 0 || rowCount === this.attributeVectorBindings.vertexCount
|
|
13778
13887
|
);
|
|
13779
13888
|
this.setVertexCount(rowCount ?? this.attributeVectorBindings.vertexCount ?? 0);
|
|
@@ -13807,7 +13916,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
13807
13916
|
const vertexCount = this.attributeVectorBindings.vertexCount;
|
|
13808
13917
|
if (vertexCount !== void 0) {
|
|
13809
13918
|
const geometryRowCount = this.geometryVectorBindings.rowCount;
|
|
13810
|
-
(0,
|
|
13919
|
+
(0, import_core14.assert)(geometryRowCount === void 0 || geometryRowCount === vertexCount);
|
|
13811
13920
|
if (geometryRowCount === void 0) this.setVertexCount(vertexCount);
|
|
13812
13921
|
}
|
|
13813
13922
|
}
|
|
@@ -13818,9 +13927,9 @@ ${getApplicationDefines(allDefines)}
|
|
|
13818
13927
|
/** Replaces the borrowed contiguous uint16/uint32 index vector. */
|
|
13819
13928
|
setIndexVector(vector) {
|
|
13820
13929
|
if (vector) {
|
|
13821
|
-
(0,
|
|
13822
|
-
(0,
|
|
13823
|
-
(0,
|
|
13930
|
+
(0, import_core14.assert)(vector.format === "uint8" || vector.format === "uint16" || vector.format === "uint32");
|
|
13931
|
+
(0, import_core14.assert)(vector.data.length <= 1);
|
|
13932
|
+
(0, import_core14.assert)(
|
|
13824
13933
|
vector.byteStride === (vector.format === "uint32" ? 4 : vector.format === "uint16" ? 2 : 1)
|
|
13825
13934
|
);
|
|
13826
13935
|
}
|
|
@@ -13832,7 +13941,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
13832
13941
|
const chunk = vector?.data[0];
|
|
13833
13942
|
if (chunk && this.indexVector) {
|
|
13834
13943
|
const buffer = chunk.buffer instanceof DynamicBuffer ? chunk.buffer.buffer : chunk.buffer;
|
|
13835
|
-
(0,
|
|
13944
|
+
(0, import_core14.assert)(
|
|
13836
13945
|
buffer.indexType === this.indexVector.format && chunk.byteOffset % this.indexVector.byteStride === 0
|
|
13837
13946
|
);
|
|
13838
13947
|
}
|
|
@@ -13906,7 +14015,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
13906
14015
|
/** Binds contiguous borrowed vectors; use drawBatches() for multi-chunk inputs. */
|
|
13907
14016
|
setGPUVectors(vectors, options) {
|
|
13908
14017
|
const batches = getGPUVectorModelBatches(this.id, vectors);
|
|
13909
|
-
(0,
|
|
14018
|
+
(0, import_core14.assert)(batches.length <= 1);
|
|
13910
14019
|
validateGPUVectorModelLayouts(this.id, vectors, this.bufferLayout);
|
|
13911
14020
|
if (batches[0]) this.setGPUData(batches[0].data);
|
|
13912
14021
|
this.setBatchDrawCount(batches[0]?.rowCount ?? 0, options?.count);
|
|
@@ -13933,12 +14042,18 @@ ${getApplicationDefines(allDefines)}
|
|
|
13933
14042
|
this.drawingVectorBatches = drawingVectorBatches;
|
|
13934
14043
|
}
|
|
13935
14044
|
}
|
|
13936
|
-
/**
|
|
14045
|
+
/**
|
|
14046
|
+
* Draws each aligned physical chunk without taking ownership of input vectors.
|
|
14047
|
+
* Each batch uses a separate aligned slot for managed shader-input uniforms set by
|
|
14048
|
+
* `onBatch`. Slots are reused on each call: submit previous draws before changing their
|
|
14049
|
+
* values or growing the allocation. Explicit buffers remain caller-managed. Vector
|
|
14050
|
+
* lengths and physical chunk boundaries must match.
|
|
14051
|
+
*/
|
|
13937
14052
|
drawBatches(renderPass, { vectors, onBatch }) {
|
|
13938
14053
|
const batches = getGPUVectorModelBatches(this.id, vectors);
|
|
13939
14054
|
validateGPUVectorModelLayouts(this.id, vectors, this.bufferLayout);
|
|
13940
14055
|
for (const name of Object.keys(vectors)) {
|
|
13941
|
-
(0,
|
|
14056
|
+
(0, import_core14.assert)(!vectors[name] || this.currentAttributes[name]);
|
|
13942
14057
|
}
|
|
13943
14058
|
const previousAttributes = { ...this.currentAttributes };
|
|
13944
14059
|
const previousAttributeByteOffsets = { ...this.currentAttributeByteOffsets };
|
|
@@ -13948,6 +14063,17 @@ ${getApplicationDefines(allDefines)}
|
|
|
13948
14063
|
const previousIsInstanced = this.isInstanced;
|
|
13949
14064
|
const previousVertexCountSet = this._vertexCountSet;
|
|
13950
14065
|
const drawingVectorBatches = this.drawingVectorBatches;
|
|
14066
|
+
const batchUniformStore = this.device.type === "webgpu" && batches.length ? new import_core14.UniformStore(this.device, this.shaderInputs.modules) : void 0;
|
|
14067
|
+
if (batchUniformStore && this._uniformStore.uniformBuffers.size) {
|
|
14068
|
+
this.batchUniformBuffer ??= new BatchUniformBuffer(this.device);
|
|
14069
|
+
let batchByteLength = 0;
|
|
14070
|
+
for (const moduleName of this._uniformStore.uniformBuffers.keys()) {
|
|
14071
|
+
batchByteLength += this.batchUniformBuffer.getAlignedByteLength(
|
|
14072
|
+
batchUniformStore.getUniformBufferData(moduleName).byteLength
|
|
14073
|
+
);
|
|
14074
|
+
}
|
|
14075
|
+
this.batchUniformBuffer.prepare(batchByteLength * batches.length);
|
|
14076
|
+
}
|
|
13951
14077
|
this.drawingVectorBatches = true;
|
|
13952
14078
|
let drawSuccess = true;
|
|
13953
14079
|
try {
|
|
@@ -13955,9 +14081,28 @@ ${getApplicationDefines(allDefines)}
|
|
|
13955
14081
|
this.setGPUData(batch.data);
|
|
13956
14082
|
this.setBatchDrawCount(batch.rowCount);
|
|
13957
14083
|
onBatch?.(batch);
|
|
13958
|
-
|
|
14084
|
+
const managedBindings = {};
|
|
14085
|
+
try {
|
|
14086
|
+
if (batchUniformStore) {
|
|
14087
|
+
batchUniformStore.setUniforms(this.shaderInputs.getUniformValues());
|
|
14088
|
+
for (const [moduleName, buffer] of this._uniformStore.uniformBuffers) {
|
|
14089
|
+
const bindingName = `${moduleName}Uniforms`;
|
|
14090
|
+
if (this.bindings[bindingName] !== buffer) continue;
|
|
14091
|
+
managedBindings[bindingName] = buffer;
|
|
14092
|
+
this.setBindings({
|
|
14093
|
+
[bindingName]: this.batchUniformBuffer.write(
|
|
14094
|
+
batchUniformStore.getUniformBufferData(moduleName)
|
|
14095
|
+
)
|
|
14096
|
+
});
|
|
14097
|
+
}
|
|
14098
|
+
}
|
|
14099
|
+
drawSuccess = _GPUVectorModel.prototype.draw.call(this, renderPass) && drawSuccess;
|
|
14100
|
+
} finally {
|
|
14101
|
+
this.setBindings(managedBindings);
|
|
14102
|
+
}
|
|
13959
14103
|
}
|
|
13960
14104
|
} finally {
|
|
14105
|
+
batchUniformStore?.destroy();
|
|
13961
14106
|
this.setAttributes(previousAttributes, { byteOffsets: previousAttributeByteOffsets });
|
|
13962
14107
|
for (const name of Object.keys(this.bindings)) {
|
|
13963
14108
|
if (!(name in previousBindings)) delete this.bindings[name];
|
|
@@ -13979,7 +14124,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
13979
14124
|
Object.entries(data).map(([name, chunk]) => {
|
|
13980
14125
|
const layout = this.bufferLayout.find((layout2) => layout2.name === name);
|
|
13981
14126
|
const byteOffset = chunk.byteOffset - (layout?.attributes?.[0]?.byteOffset ?? 0);
|
|
13982
|
-
(0,
|
|
14127
|
+
(0, import_core14.assert)(byteOffset >= 0);
|
|
13983
14128
|
return [name, byteOffset];
|
|
13984
14129
|
})
|
|
13985
14130
|
)
|
|
@@ -14101,7 +14246,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
14101
14246
|
/** Set the shader inputs */
|
|
14102
14247
|
setShaderInputs(shaderInputs) {
|
|
14103
14248
|
this.shaderInputs = shaderInputs;
|
|
14104
|
-
this._uniformStore = new
|
|
14249
|
+
this._uniformStore = new import_core14.UniformStore(this.device, this.shaderInputs.modules);
|
|
14105
14250
|
for (const [moduleName, module] of Object.entries(this.shaderInputs.modules)) {
|
|
14106
14251
|
if (shaderModuleHasUniforms(module) && this._usesManagedUniformBuffer(moduleName)) {
|
|
14107
14252
|
const uniformBuffer = this._uniformStore.getManagedUniformBuffer(moduleName);
|
|
@@ -14172,7 +14317,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
14172
14317
|
this._drawBlockedReason = false;
|
|
14173
14318
|
const disableWarnings = options?.disableWarnings ?? this.props.disableWarnings;
|
|
14174
14319
|
if (buffers["indices"]) {
|
|
14175
|
-
|
|
14320
|
+
import_core14.log.warn(
|
|
14176
14321
|
`Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`
|
|
14177
14322
|
)();
|
|
14178
14323
|
}
|
|
@@ -14186,7 +14331,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
14186
14331
|
const bufferLayout = bufferLayoutHelper.getBufferLayout(bufferName);
|
|
14187
14332
|
if (!bufferLayout) {
|
|
14188
14333
|
if (!disableWarnings) {
|
|
14189
|
-
|
|
14334
|
+
import_core14.log.warn(`Model(${this.id}): Missing layout for buffer "${bufferName}".`)();
|
|
14190
14335
|
}
|
|
14191
14336
|
continue;
|
|
14192
14337
|
}
|
|
@@ -14198,7 +14343,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
14198
14343
|
const bufferSlot = this.device.type === "webgpu" ? this.vertexArray.getBufferSlot(attributeInfo.bufferName) : attributeInfo.location;
|
|
14199
14344
|
if (bufferSlot === null) {
|
|
14200
14345
|
if (!disableWarnings) {
|
|
14201
|
-
|
|
14346
|
+
import_core14.log.warn(
|
|
14202
14347
|
`Model(${this.id}): Missing vertex array slot for buffer "${attributeInfo.bufferName}".`
|
|
14203
14348
|
)();
|
|
14204
14349
|
}
|
|
@@ -14219,7 +14364,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
14219
14364
|
}
|
|
14220
14365
|
}
|
|
14221
14366
|
if (!set2 && !disableWarnings) {
|
|
14222
|
-
|
|
14367
|
+
import_core14.log.warn(
|
|
14223
14368
|
`Model(${this.id}): Ignoring buffer "${resolvedBuffer.id}" for unknown attribute "${bufferName}"`
|
|
14224
14369
|
)();
|
|
14225
14370
|
}
|
|
@@ -14240,7 +14385,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
14240
14385
|
if (attributeInfo) {
|
|
14241
14386
|
this.vertexArray.setConstantWebGL(attributeInfo.location, value);
|
|
14242
14387
|
} else if (!(options?.disableWarnings ?? this.props.disableWarnings)) {
|
|
14243
|
-
|
|
14388
|
+
import_core14.log.warn(
|
|
14244
14389
|
`Model "${this.id}: Ignoring constant supplied for unknown attribute "${attributeName}"`
|
|
14245
14390
|
)();
|
|
14246
14391
|
}
|
|
@@ -14277,7 +14422,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
14277
14422
|
* @param bindings GPUVectorModel bindings already resolved for this draw preparation.
|
|
14278
14423
|
*/
|
|
14279
14424
|
_getBindGroups(shaderLayout = this._getCurrentShaderLayout(), bindings = this._getBindings(shaderLayout)) {
|
|
14280
|
-
return shaderLayout.bindings.length ? (0,
|
|
14425
|
+
return shaderLayout.bindings.length ? (0, import_core14.normalizeBindingsByGroup)(shaderLayout, bindings) : { 0: bindings };
|
|
14281
14426
|
}
|
|
14282
14427
|
_getBindGroupCacheKeys() {
|
|
14283
14428
|
return {};
|
|
@@ -14292,9 +14437,9 @@ ${getApplicationDefines(allDefines)}
|
|
|
14292
14437
|
timestamp = Math.max(timestamp, entry.source.updateTimestamp);
|
|
14293
14438
|
}
|
|
14294
14439
|
for (const binding of Object.values(this.bindings)) {
|
|
14295
|
-
if (binding instanceof
|
|
14440
|
+
if (binding instanceof import_core14.TextureView) {
|
|
14296
14441
|
timestamp = Math.max(timestamp, binding.texture.updateTimestamp);
|
|
14297
|
-
} else if (binding instanceof
|
|
14442
|
+
} else if (binding instanceof import_core14.Buffer || binding instanceof import_core14.Texture || binding instanceof import_core14.ExternalTexture) {
|
|
14298
14443
|
timestamp = Math.max(timestamp, binding.updateTimestamp);
|
|
14299
14444
|
} else if (binding instanceof DynamicBuffer) {
|
|
14300
14445
|
timestamp = Math.max(timestamp, binding.updateTimestamp);
|
|
@@ -14353,7 +14498,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
14353
14498
|
const previousVertexShader = this.pipeline?.vs ?? null;
|
|
14354
14499
|
const previousFragmentShader = this.pipeline?.fs ?? null;
|
|
14355
14500
|
if (this.pipeline) {
|
|
14356
|
-
|
|
14501
|
+
import_core14.log.log(
|
|
14357
14502
|
1,
|
|
14358
14503
|
`GPUVectorModel ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`
|
|
14359
14504
|
)();
|
|
@@ -14403,7 +14548,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
14403
14548
|
};
|
|
14404
14549
|
}
|
|
14405
14550
|
_finishPipelineUpdate(update) {
|
|
14406
|
-
this._attributeInfos = (0,
|
|
14551
|
+
this._attributeInfos = (0, import_core14.getAttributeInfosFromLayouts)(
|
|
14407
14552
|
this.pipeline.shaderLayout,
|
|
14408
14553
|
this.bufferLayout
|
|
14409
14554
|
);
|
|
@@ -14419,24 +14564,24 @@ ${getApplicationDefines(allDefines)}
|
|
|
14419
14564
|
_lastLogTime = 0;
|
|
14420
14565
|
_logOpen = false;
|
|
14421
14566
|
_logDrawCallStart() {
|
|
14422
|
-
const logDrawTimeout =
|
|
14423
|
-
if (
|
|
14567
|
+
const logDrawTimeout = import_core14.log.level > 3 ? 0 : LOG_DRAW_TIMEOUT;
|
|
14568
|
+
if (import_core14.log.level < 2 || Date.now() - this._lastLogTime < logDrawTimeout) {
|
|
14424
14569
|
return;
|
|
14425
14570
|
}
|
|
14426
14571
|
this._lastLogTime = Date.now();
|
|
14427
14572
|
this._logOpen = true;
|
|
14428
|
-
|
|
14573
|
+
import_core14.log.group(LOG_DRAW_PRIORITY, `>>> DRAWING MODEL ${this.id}`, { collapsed: import_core14.log.level <= 2 })();
|
|
14429
14574
|
}
|
|
14430
14575
|
_logDrawCallEnd() {
|
|
14431
14576
|
if (this._logOpen) {
|
|
14432
14577
|
const shaderLayoutTable = getDebugTableForShaderLayout(this.pipeline.shaderLayout, this.id);
|
|
14433
|
-
|
|
14578
|
+
import_core14.log.table(LOG_DRAW_PRIORITY, shaderLayoutTable)();
|
|
14434
14579
|
const uniformTable = this.shaderInputs.getDebugTable();
|
|
14435
|
-
|
|
14580
|
+
import_core14.log.table(LOG_DRAW_PRIORITY, uniformTable)();
|
|
14436
14581
|
const attributeTable = this._getAttributeDebugTable();
|
|
14437
|
-
|
|
14438
|
-
|
|
14439
|
-
|
|
14582
|
+
import_core14.log.table(LOG_DRAW_PRIORITY, this._attributeInfos)();
|
|
14583
|
+
import_core14.log.table(LOG_DRAW_PRIORITY, attributeTable)();
|
|
14584
|
+
import_core14.log.groupEnd(LOG_DRAW_PRIORITY)();
|
|
14440
14585
|
this._logOpen = false;
|
|
14441
14586
|
}
|
|
14442
14587
|
}
|
|
@@ -14476,8 +14621,8 @@ ${getApplicationDefines(allDefines)}
|
|
|
14476
14621
|
}
|
|
14477
14622
|
// TODO - fix typing of luma data types
|
|
14478
14623
|
_getBufferOrConstantValues(attribute, dataType) {
|
|
14479
|
-
const TypedArrayConstructor =
|
|
14480
|
-
const typedArray = attribute instanceof
|
|
14624
|
+
const TypedArrayConstructor = import_core14.dataTypeDecoder.getTypedArrayConstructor(dataType);
|
|
14625
|
+
const typedArray = attribute instanceof import_core14.Buffer ? new TypedArrayConstructor(attribute.debugData) : attribute;
|
|
14481
14626
|
return typedArray.toString();
|
|
14482
14627
|
}
|
|
14483
14628
|
/** Returns the current reflected shader layout or the pre-reflection empty layout. */
|
|
@@ -14561,7 +14706,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
14561
14706
|
}
|
|
14562
14707
|
|
|
14563
14708
|
// src/geometry/gpu-geometry.ts
|
|
14564
|
-
var
|
|
14709
|
+
var import_core15 = __toESM(require_core(), 1);
|
|
14565
14710
|
var GPUGeometry = class {
|
|
14566
14711
|
/** Application-provided or generated identifier. */
|
|
14567
14712
|
id;
|
|
@@ -14586,7 +14731,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
14586
14731
|
this.vertexCount = props.vertexCount;
|
|
14587
14732
|
this.bufferLayout = props.bufferLayout || [];
|
|
14588
14733
|
if (this.indices) {
|
|
14589
|
-
if (!(this.indices.usage &
|
|
14734
|
+
if (!(this.indices.usage & import_core15.Buffer.INDEX)) {
|
|
14590
14735
|
throw new Error("Index buffer must have INDEX usage");
|
|
14591
14736
|
}
|
|
14592
14737
|
}
|
|
@@ -14635,7 +14780,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
14635
14780
|
return void 0;
|
|
14636
14781
|
}
|
|
14637
14782
|
const data = geometry.indices.value;
|
|
14638
|
-
return device.createBuffer({ usage:
|
|
14783
|
+
return device.createBuffer({ usage: import_core15.Buffer.INDEX, data });
|
|
14639
14784
|
}
|
|
14640
14785
|
function getAttributeBuffersFromGeometry(device, geometry) {
|
|
14641
14786
|
const attributes = {};
|
|
@@ -14672,13 +14817,13 @@ ${getApplicationDefines(allDefines)}
|
|
|
14672
14817
|
};
|
|
14673
14818
|
|
|
14674
14819
|
// src/geometry/gpu-vector-geometry-adapter.ts
|
|
14675
|
-
var
|
|
14820
|
+
var import_core16 = __toESM(require_core(), 1);
|
|
14676
14821
|
function makeGPUVectorGeometryFromGPUGeometry(geometry) {
|
|
14677
14822
|
const attributes = {};
|
|
14678
14823
|
for (const [name, buffer2] of Object.entries(geometry.attributes)) {
|
|
14679
14824
|
const bufferLayout = geometry.bufferLayout.find((layout) => layout.name === name);
|
|
14680
14825
|
const format = bufferLayout?.format;
|
|
14681
|
-
const byteStride2 = bufferLayout?.byteStride ?? (format ?
|
|
14826
|
+
const byteStride2 = bufferLayout?.byteStride ?? (format ? import_core16.vertexFormatDecoder.getVertexFormatInfo(format).byteLength : 0);
|
|
14682
14827
|
const length5 = geometry.indices && byteStride2 ? Math.floor(buffer2.byteLength / byteStride2) : geometry.vertexCount;
|
|
14683
14828
|
attributes[name] = {
|
|
14684
14829
|
name,
|
|
@@ -14740,6 +14885,10 @@ ${getApplicationDefines(allDefines)}
|
|
|
14740
14885
|
...GPUVectorModel.defaultProps,
|
|
14741
14886
|
material: void 0
|
|
14742
14887
|
};
|
|
14888
|
+
/** Borrowed source geometry, retained for scene adapters such as physics cooking. */
|
|
14889
|
+
get sourceGeometry() {
|
|
14890
|
+
return this.sourceGeometryValue;
|
|
14891
|
+
}
|
|
14743
14892
|
constructor(device, props) {
|
|
14744
14893
|
const sourceGeometry = props.geometry === void 0 ? new.target.defaultProps.geometry : props.geometry;
|
|
14745
14894
|
const gpuGeometry = sourceGeometry && !(sourceGeometry instanceof GPUVectorGeometry) ? makeGPUGeometry(device, sourceGeometry) : null;
|
|
@@ -14755,11 +14904,13 @@ ${getApplicationDefines(allDefines)}
|
|
|
14755
14904
|
throw error;
|
|
14756
14905
|
}
|
|
14757
14906
|
this._gpuGeometry = gpuGeometry;
|
|
14907
|
+
this.sourceGeometryValue = sourceGeometry;
|
|
14758
14908
|
if (gpuGeometry) this.setIndexCount(this.props.indexCount);
|
|
14759
14909
|
}
|
|
14760
14910
|
_initializeProps(props) {
|
|
14761
14911
|
this.material = props.material || null;
|
|
14762
14912
|
this._gpuGeometry = null;
|
|
14913
|
+
this.sourceGeometryValue = null;
|
|
14763
14914
|
super._initializeProps(props);
|
|
14764
14915
|
}
|
|
14765
14916
|
_initializeAttributes() {
|
|
@@ -14770,6 +14921,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
14770
14921
|
super.destroy();
|
|
14771
14922
|
this._gpuGeometry?.destroy();
|
|
14772
14923
|
this._gpuGeometry = null;
|
|
14924
|
+
this.sourceGeometryValue = null;
|
|
14773
14925
|
}
|
|
14774
14926
|
/** Adapts CPU and legacy buffer geometry into the GPU vector geometry API. */
|
|
14775
14927
|
setGeometry(geometry) {
|
|
@@ -14778,6 +14930,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
14778
14930
|
const vectorGeometry = this._gpuGeometry ? makeGPUVectorGeometryFromGPUGeometry(this._gpuGeometry) : geometry;
|
|
14779
14931
|
super.setGeometry(vectorGeometry instanceof GPUVectorGeometry ? vectorGeometry : null);
|
|
14780
14932
|
if (!(geometry instanceof GPUVectorGeometry)) super.setIndexCount(this.indexCountOverride);
|
|
14933
|
+
this.sourceGeometryValue = geometry;
|
|
14781
14934
|
}
|
|
14782
14935
|
setIndexCount(indexCount) {
|
|
14783
14936
|
this.indexCountOverride = indexCount;
|
|
@@ -14833,7 +14986,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
14833
14986
|
};
|
|
14834
14987
|
|
|
14835
14988
|
// src/material/material.ts
|
|
14836
|
-
var
|
|
14989
|
+
var import_core17 = __toESM(require_core(), 1);
|
|
14837
14990
|
|
|
14838
14991
|
// src/material/material-factory.ts
|
|
14839
14992
|
var MATERIAL_BIND_GROUP = 3;
|
|
@@ -14935,7 +15088,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
14935
15088
|
])
|
|
14936
15089
|
);
|
|
14937
15090
|
this.shaderInputs = props.shaderInputs || new ShaderInputs(moduleMap);
|
|
14938
|
-
this._uniformStore = new
|
|
15091
|
+
this._uniformStore = new import_core17.UniformStore(this.device, this.shaderInputs.modules);
|
|
14939
15092
|
for (const [moduleName, module] of Object.entries(this.shaderInputs.modules)) {
|
|
14940
15093
|
if (this.ownsModule(moduleName) && shaderModuleHasUniforms(module)) {
|
|
14941
15094
|
const uniformBuffer = this._uniformStore.getManagedUniformBuffer(moduleName);
|
|
@@ -15049,9 +15202,9 @@ ${getApplicationDefines(allDefines)}
|
|
|
15049
15202
|
getBindingsUpdateTimestamp() {
|
|
15050
15203
|
let timestamp = 0;
|
|
15051
15204
|
for (const binding of Object.values(this.bindings)) {
|
|
15052
|
-
if (binding instanceof
|
|
15205
|
+
if (binding instanceof import_core17.TextureView) {
|
|
15053
15206
|
timestamp = Math.max(timestamp, binding.texture.updateTimestamp);
|
|
15054
|
-
} else if (binding instanceof
|
|
15207
|
+
} else if (binding instanceof import_core17.Buffer || binding instanceof import_core17.Texture || binding instanceof import_core17.ExternalTexture) {
|
|
15055
15208
|
timestamp = Math.max(timestamp, binding.updateTimestamp);
|
|
15056
15209
|
} else if (binding instanceof DynamicBuffer) {
|
|
15057
15210
|
timestamp = Math.max(timestamp, binding.updateTimestamp);
|
|
@@ -15119,7 +15272,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
15119
15272
|
}
|
|
15120
15273
|
|
|
15121
15274
|
// src/compute/buffer-transform.ts
|
|
15122
|
-
var
|
|
15275
|
+
var import_core18 = __toESM(require_core(), 1);
|
|
15123
15276
|
var import_shaders4 = __toESM(require_shaders(), 1);
|
|
15124
15277
|
var GL_INTERLEAVED_ATTRIBS = 35980;
|
|
15125
15278
|
var GL_SEPARATE_ATTRIBS = 35981;
|
|
@@ -15193,14 +15346,14 @@ ${getApplicationDefines(allDefines)}
|
|
|
15193
15346
|
/** Binds borrowed output ranges without taking ownership or repacking vector chunks. */
|
|
15194
15347
|
setOutputVectors(vectors) {
|
|
15195
15348
|
const batches = getGPUVectorModelBatches(this.model.id, vectors);
|
|
15196
|
-
(0,
|
|
15197
|
-
(0,
|
|
15349
|
+
(0, import_core18.assert)(batches.length === 0 || this.model.pipeline.props.bufferMode !== GL_INTERLEAVED_ATTRIBS);
|
|
15350
|
+
(0, import_core18.assert)(batches.length <= 1);
|
|
15198
15351
|
this.outputVectorBindings = vectors;
|
|
15199
15352
|
this.transformFeedback.setBuffers({
|
|
15200
15353
|
...this.outputBuffers,
|
|
15201
15354
|
...Object.fromEntries(
|
|
15202
15355
|
Object.entries(batches[0]?.data ?? {}).map(([name, data]) => {
|
|
15203
|
-
(0,
|
|
15356
|
+
(0, import_core18.assert)(data.byteStride === data.rowByteLength);
|
|
15204
15357
|
return [
|
|
15205
15358
|
name,
|
|
15206
15359
|
{
|
|
@@ -15224,7 +15377,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
15224
15377
|
if (!result) {
|
|
15225
15378
|
throw new Error("BufferTransform#getBuffer");
|
|
15226
15379
|
}
|
|
15227
|
-
if (result instanceof
|
|
15380
|
+
if (result instanceof import_core18.Buffer) {
|
|
15228
15381
|
return result.readAsync();
|
|
15229
15382
|
}
|
|
15230
15383
|
const { buffer, byteOffset = 0, byteLength = buffer.byteLength } = result;
|
|
@@ -16173,7 +16326,7 @@ void main(void) {
|
|
|
16173
16326
|
};
|
|
16174
16327
|
|
|
16175
16328
|
// src/scenegraph/scenegraph-node.ts
|
|
16176
|
-
function
|
|
16329
|
+
function assert10(condition, message) {
|
|
16177
16330
|
if (!condition) {
|
|
16178
16331
|
throw new Error(message);
|
|
16179
16332
|
}
|
|
@@ -16209,17 +16362,17 @@ void main(void) {
|
|
|
16209
16362
|
return `{type: ScenegraphNode, id: ${this.id})}`;
|
|
16210
16363
|
}
|
|
16211
16364
|
setPosition(position) {
|
|
16212
|
-
|
|
16365
|
+
assert10(position.length === 3, "setPosition requires vector argument");
|
|
16213
16366
|
this.position = position;
|
|
16214
16367
|
return this;
|
|
16215
16368
|
}
|
|
16216
16369
|
setRotation(rotation) {
|
|
16217
|
-
|
|
16370
|
+
assert10(rotation.length === 3 || rotation.length === 4, "setRotation requires vector argument");
|
|
16218
16371
|
this.rotation = rotation;
|
|
16219
16372
|
return this;
|
|
16220
16373
|
}
|
|
16221
16374
|
setScale(scale5) {
|
|
16222
|
-
|
|
16375
|
+
assert10(scale5.length === 3, "setScale requires vector argument");
|
|
16223
16376
|
this.scale = scale5;
|
|
16224
16377
|
return this;
|
|
16225
16378
|
}
|
|
@@ -16329,7 +16482,7 @@ void main(void) {
|
|
|
16329
16482
|
};
|
|
16330
16483
|
|
|
16331
16484
|
// src/scenegraph/group-node.ts
|
|
16332
|
-
var
|
|
16485
|
+
var import_core23 = __toESM(require_core(), 1);
|
|
16333
16486
|
|
|
16334
16487
|
// src/scenegraph/scenegraph-bounds.ts
|
|
16335
16488
|
function makeEmptyScenegraphBounds() {
|
|
@@ -16366,15 +16519,18 @@ void main(void) {
|
|
|
16366
16519
|
// src/scenegraph/group-node.ts
|
|
16367
16520
|
var GroupNode = class _GroupNode extends ScenegraphNode {
|
|
16368
16521
|
children;
|
|
16522
|
+
/** Optional evaluated GPU poses; authored matrices remain unchanged. */
|
|
16523
|
+
transformSource;
|
|
16369
16524
|
constructor(props = {}) {
|
|
16370
16525
|
props = Array.isArray(props) ? { children: props } : props;
|
|
16371
16526
|
const { children = [] } = props;
|
|
16372
|
-
|
|
16527
|
+
import_core23.log.assert(
|
|
16373
16528
|
children.every((child) => child instanceof ScenegraphNode),
|
|
16374
16529
|
"every child must an instance of ScenegraphNode"
|
|
16375
16530
|
);
|
|
16376
16531
|
super(props);
|
|
16377
16532
|
this.children = children;
|
|
16533
|
+
this.transformSource = props.transformSource ?? null;
|
|
16378
16534
|
}
|
|
16379
16535
|
getBounds() {
|
|
16380
16536
|
const result = makeEmptyScenegraphBounds();
|
|
@@ -16416,6 +16572,45 @@ void main(void) {
|
|
|
16416
16572
|
this.children = [];
|
|
16417
16573
|
return this;
|
|
16418
16574
|
}
|
|
16575
|
+
/** Resolve one exact ID or path. Missing nodes return undefined; ambiguous paths throw. */
|
|
16576
|
+
findNode(path) {
|
|
16577
|
+
const matches = this.findNodes(path);
|
|
16578
|
+
if (matches.length > 1) {
|
|
16579
|
+
throw new Error(`Ambiguous scenegraph path: ${path} (${matches.length} matches)`);
|
|
16580
|
+
}
|
|
16581
|
+
return matches[0];
|
|
16582
|
+
}
|
|
16583
|
+
/** Find structural matches in preorder, including hidden nodes and the search root. */
|
|
16584
|
+
findNodes(path) {
|
|
16585
|
+
const anchored = path.startsWith("/");
|
|
16586
|
+
const segments = path === "/" ? [] : (anchored ? path.slice(1) : path).split("/").map((segment) => {
|
|
16587
|
+
if (!segment || /~(?![01])/.test(segment)) {
|
|
16588
|
+
throw new Error(`Invalid scenegraph path: ${path}`);
|
|
16589
|
+
}
|
|
16590
|
+
return segment.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
16591
|
+
});
|
|
16592
|
+
const matches = [];
|
|
16593
|
+
const ancestors = [];
|
|
16594
|
+
const visited = /* @__PURE__ */ new Set();
|
|
16595
|
+
const pending = [{ node: this, depth: 0 }];
|
|
16596
|
+
while (pending.length) {
|
|
16597
|
+
const { node, depth } = pending.pop();
|
|
16598
|
+
(0, import_core23.assert)(!visited.has(node));
|
|
16599
|
+
visited.add(node);
|
|
16600
|
+
ancestors.length = depth;
|
|
16601
|
+
ancestors.push(node.id);
|
|
16602
|
+
const offset = ancestors.length - segments.length;
|
|
16603
|
+
if ((anchored ? offset === 1 : offset >= 0) && segments.every((segment, index) => segment === ancestors[offset + index])) {
|
|
16604
|
+
matches.push(node);
|
|
16605
|
+
}
|
|
16606
|
+
if (node instanceof _GroupNode) {
|
|
16607
|
+
for (let index = node.children.length - 1; index >= 0; index--) {
|
|
16608
|
+
pending.push({ node: node.children[index], depth: depth + 1 });
|
|
16609
|
+
}
|
|
16610
|
+
}
|
|
16611
|
+
}
|
|
16612
|
+
return matches;
|
|
16613
|
+
}
|
|
16419
16614
|
traverse(visitor, { worldMatrix = new Matrix4() } = {}) {
|
|
16420
16615
|
if (!this.display) {
|
|
16421
16616
|
return;
|
|
@@ -16472,6 +16667,27 @@ void main(void) {
|
|
|
16472
16667
|
}
|
|
16473
16668
|
};
|
|
16474
16669
|
|
|
16670
|
+
// src/scenegraph/geometry-node.ts
|
|
16671
|
+
var GeometryNode = class extends ScenegraphNode {
|
|
16672
|
+
geometry;
|
|
16673
|
+
constructor(props) {
|
|
16674
|
+
super(props);
|
|
16675
|
+
this.geometry = props.geometry;
|
|
16676
|
+
}
|
|
16677
|
+
getBounds() {
|
|
16678
|
+
const positions = this.geometry.attributes["POSITION"];
|
|
16679
|
+
if (!positions || positions.size !== 3 || !positions.value.length) return null;
|
|
16680
|
+
const minimum = [Infinity, Infinity, Infinity];
|
|
16681
|
+
const maximum = [-Infinity, -Infinity, -Infinity];
|
|
16682
|
+
for (let index = 0; index < positions.value.length; index++) {
|
|
16683
|
+
const axis = index % 3;
|
|
16684
|
+
minimum[axis] = Math.min(minimum[axis], positions.value[index]);
|
|
16685
|
+
maximum[axis] = Math.max(maximum[axis], positions.value[index]);
|
|
16686
|
+
}
|
|
16687
|
+
return [minimum, maximum];
|
|
16688
|
+
}
|
|
16689
|
+
};
|
|
16690
|
+
|
|
16475
16691
|
// src/scenegraph/model-node.ts
|
|
16476
16692
|
var ModelNode = class extends ScenegraphNode {
|
|
16477
16693
|
model;
|
|
@@ -16515,12 +16731,12 @@ void main(void) {
|
|
|
16515
16731
|
}
|
|
16516
16732
|
|
|
16517
16733
|
// src/geometry/edge-geometry.ts
|
|
16518
|
-
var
|
|
16734
|
+
var import_core24 = __toESM(require_core(), 1);
|
|
16519
16735
|
function makeEdgeGeometry(geometry, options = {}) {
|
|
16520
16736
|
const { angleThreshold = 30, weldTolerance = 0, positionAttribute = "POSITION" } = options;
|
|
16521
16737
|
const positions = getTrianglePositions(geometry, positionAttribute);
|
|
16522
|
-
(0,
|
|
16523
|
-
(0,
|
|
16738
|
+
(0, import_core24.assert)(Number.isFinite(weldTolerance) && weldTolerance >= 0);
|
|
16739
|
+
(0, import_core24.assert)(Number.isFinite(angleThreshold) && angleThreshold >= 0 && angleThreshold <= 180);
|
|
16524
16740
|
const sourceIndices = geometry.indices?.value;
|
|
16525
16741
|
const sourceCount = positions.value.length / 3;
|
|
16526
16742
|
const representatives = /* @__PURE__ */ new Map();
|
|
@@ -16539,9 +16755,9 @@ void main(void) {
|
|
|
16539
16755
|
function weldPosition(index) {
|
|
16540
16756
|
const cached = representatives.get(index);
|
|
16541
16757
|
if (cached !== void 0) return cached;
|
|
16542
|
-
(0,
|
|
16758
|
+
(0, import_core24.assert)(Number.isInteger(index) && index >= 0 && index < sourceCount);
|
|
16543
16759
|
const position = readPosition(index);
|
|
16544
|
-
(0,
|
|
16760
|
+
(0, import_core24.assert)(position.every(Number.isFinite));
|
|
16545
16761
|
const cell = weldTolerance > 0 ? position.map((value) => Math.floor(value / weldTolerance)) : position;
|
|
16546
16762
|
const radius = weldTolerance > 0 ? 1 : 0;
|
|
16547
16763
|
for (let east = -radius; east <= radius; east++) {
|
|
@@ -16615,11 +16831,11 @@ void main(void) {
|
|
|
16615
16831
|
});
|
|
16616
16832
|
}
|
|
16617
16833
|
function makeEdgeGeometryFromGeometries(geometries, options = {}) {
|
|
16618
|
-
(0,
|
|
16834
|
+
(0, import_core24.assert)(geometries.length > 0);
|
|
16619
16835
|
const positionAttribute = options.positionAttribute ?? "POSITION";
|
|
16620
16836
|
const attributes = geometries.map((geometry) => getTrianglePositions(geometry, positionAttribute));
|
|
16621
16837
|
const firstAttribute = attributes[0];
|
|
16622
|
-
(0,
|
|
16838
|
+
(0, import_core24.assert)(
|
|
16623
16839
|
attributes.every(
|
|
16624
16840
|
(attribute) => attribute.value.constructor === firstAttribute.value.constructor && Boolean(attribute["normalized"]) === Boolean(firstAttribute["normalized"])
|
|
16625
16841
|
)
|
|
@@ -16638,7 +16854,7 @@ void main(void) {
|
|
|
16638
16854
|
positions.set(attribute.value, positionOffset);
|
|
16639
16855
|
for (let offset = 0; offset < geometry.vertexCount; offset++) {
|
|
16640
16856
|
const index = geometry.indices?.value[offset] ?? offset;
|
|
16641
|
-
(0,
|
|
16857
|
+
(0, import_core24.assert)(Number.isInteger(index) && index >= 0 && index < attribute.value.length / 3);
|
|
16642
16858
|
indices[indexOffset++] = index + positionOffset / 3;
|
|
16643
16859
|
}
|
|
16644
16860
|
positionOffset += attribute.value.length;
|
|
@@ -16655,26 +16871,26 @@ void main(void) {
|
|
|
16655
16871
|
}
|
|
16656
16872
|
function getTrianglePositions(geometry, positionAttribute) {
|
|
16657
16873
|
const positions = geometry.attributes[positionAttribute];
|
|
16658
|
-
(0,
|
|
16659
|
-
(0,
|
|
16660
|
-
(0,
|
|
16874
|
+
(0, import_core24.assert)(geometry.topology === "triangle-list" && positions?.size === 3);
|
|
16875
|
+
(0, import_core24.assert)(positions.value.length % 3 === 0 && geometry.vertexCount % 3 === 0);
|
|
16876
|
+
(0, import_core24.assert)(
|
|
16661
16877
|
!positions["byteStride"] || positions["byteStride"] === positions.value.BYTES_PER_ELEMENT * 3
|
|
16662
16878
|
);
|
|
16663
|
-
(0,
|
|
16879
|
+
(0, import_core24.assert)(
|
|
16664
16880
|
geometry.vertexCount >= 0 && geometry.vertexCount <= (geometry.indices?.value.length ?? positions.value.length / 3)
|
|
16665
16881
|
);
|
|
16666
16882
|
return positions;
|
|
16667
16883
|
}
|
|
16668
16884
|
|
|
16669
16885
|
// src/geometry/stroke-geometry.ts
|
|
16670
|
-
var
|
|
16886
|
+
var import_core25 = __toESM(require_core(), 1);
|
|
16671
16887
|
function makeStrokeGeometry(path, options = {}) {
|
|
16672
16888
|
const { width = 1, cap = "butt", join = "miter", miterLimit = 4, roundSegments = 16 } = options;
|
|
16673
|
-
(0,
|
|
16674
|
-
(0,
|
|
16889
|
+
(0, import_core25.assert)(Number.isFinite(width) && width >= 0 && Number.isFinite(miterLimit) && miterLimit >= 1);
|
|
16890
|
+
(0, import_core25.assert)(Number.isInteger(roundSegments) && roundSegments >= 2 && roundSegments <= 256);
|
|
16675
16891
|
const points = [];
|
|
16676
16892
|
for (const position of path) {
|
|
16677
|
-
(0,
|
|
16893
|
+
(0, import_core25.assert)(
|
|
16678
16894
|
Number.isFinite(position[0]) && Number.isFinite(position[1]) && Number.isFinite(position[2] ?? 0)
|
|
16679
16895
|
);
|
|
16680
16896
|
const previous = points.at(-1);
|
|
@@ -16834,12 +17050,12 @@ void main(void) {
|
|
|
16834
17050
|
}
|
|
16835
17051
|
|
|
16836
17052
|
// src/geometry/mesh-simplification.ts
|
|
16837
|
-
var
|
|
17053
|
+
var import_core26 = __toESM(require_core(), 1);
|
|
16838
17054
|
var QUADRIC_COMPONENTS = 10;
|
|
16839
17055
|
var BOUNDARY_COLLINEAR_TOLERANCE = 1e-10;
|
|
16840
17056
|
function simplifyMesh(options) {
|
|
16841
17057
|
const { positions, indices, attributes = [], preserveBoundary = true } = options;
|
|
16842
|
-
(0,
|
|
17058
|
+
(0, import_core26.assert)(indices.length % 3 === 0 && positions.length % 3 === 0);
|
|
16843
17059
|
const targetIndexCount = Math.max(
|
|
16844
17060
|
0,
|
|
16845
17061
|
Math.min(
|
|
@@ -16932,7 +17148,7 @@ void main(void) {
|
|
|
16932
17148
|
const firstVertex = indices[indexOffset2];
|
|
16933
17149
|
const secondVertex = indices[indexOffset2 + 1];
|
|
16934
17150
|
const thirdVertex = indices[indexOffset2 + 2];
|
|
16935
|
-
(0,
|
|
17151
|
+
(0, import_core26.assert)(firstVertex < vertexCount && secondVertex < vertexCount && thirdVertex < vertexCount);
|
|
16936
17152
|
const triangle = {
|
|
16937
17153
|
vertices: [firstVertex, secondVertex, thirdVertex],
|
|
16938
17154
|
active: false
|
|
@@ -17267,7 +17483,7 @@ void main(void) {
|
|
|
17267
17483
|
}
|
|
17268
17484
|
|
|
17269
17485
|
// src/dynamic-texture/video-texture.ts
|
|
17270
|
-
var
|
|
17486
|
+
var import_core27 = __toESM(require_core(), 1);
|
|
17271
17487
|
var VideoTexture = class {
|
|
17272
17488
|
/** Device used to create copied and native external texture bindings. */
|
|
17273
17489
|
device;
|
|
@@ -17316,7 +17532,7 @@ void main(void) {
|
|
|
17316
17532
|
* @param props Live video source and copied texture options.
|
|
17317
17533
|
*/
|
|
17318
17534
|
constructor(device, props) {
|
|
17319
|
-
(0,
|
|
17535
|
+
(0, import_core27.assert)(isHTMLVideoElementSource(props?.source) || isVideoFrameSource(props?.source));
|
|
17320
17536
|
this.device = device;
|
|
17321
17537
|
this.id = props.id || uid("video-texture");
|
|
17322
17538
|
this._source = props.source;
|
|
@@ -17330,7 +17546,7 @@ void main(void) {
|
|
|
17330
17546
|
* @param source Next caller-owned video source to follow.
|
|
17331
17547
|
*/
|
|
17332
17548
|
setSource(source4) {
|
|
17333
|
-
(0,
|
|
17549
|
+
(0, import_core27.assert)(isHTMLVideoElementSource(source4) || isVideoFrameSource(source4));
|
|
17334
17550
|
this._destroyExternalTexture();
|
|
17335
17551
|
this._source = source4;
|
|
17336
17552
|
this._sourceVersion++;
|
|
@@ -17408,7 +17624,7 @@ void main(void) {
|
|
|
17408
17624
|
width: size.width,
|
|
17409
17625
|
height: size.height,
|
|
17410
17626
|
format: "rgba8unorm",
|
|
17411
|
-
usage:
|
|
17627
|
+
usage: import_core27.Texture.SAMPLE | import_core27.Texture.COPY_DST,
|
|
17412
17628
|
mipLevels: 1,
|
|
17413
17629
|
sampler: this._sampler
|
|
17414
17630
|
});
|
|
@@ -17443,7 +17659,7 @@ void main(void) {
|
|
|
17443
17659
|
*/
|
|
17444
17660
|
_getResolvedSize() {
|
|
17445
17661
|
const size = getVideoTextureSourceSize(this._source);
|
|
17446
|
-
(0,
|
|
17662
|
+
(0, import_core27.assert)(size.width > 0 && size.height > 0);
|
|
17447
17663
|
return size;
|
|
17448
17664
|
}
|
|
17449
17665
|
/** Observes current source readiness and frame identity before binding resolution. */
|
|
@@ -17508,11 +17724,11 @@ void main(void) {
|
|
|
17508
17724
|
}
|
|
17509
17725
|
|
|
17510
17726
|
// src/passes/shader-pass-renderer.ts
|
|
17511
|
-
var
|
|
17727
|
+
var import_core30 = __toESM(require_core(), 1);
|
|
17512
17728
|
var import_shaders7 = __toESM(require_shaders(), 1);
|
|
17513
17729
|
|
|
17514
17730
|
// src/compute/swap.ts
|
|
17515
|
-
var
|
|
17731
|
+
var import_core28 = __toESM(require_core(), 1);
|
|
17516
17732
|
var Swap = class {
|
|
17517
17733
|
id;
|
|
17518
17734
|
/** The current resource - usually the source for renders or computations */
|
|
@@ -17544,7 +17760,7 @@ void main(void) {
|
|
|
17544
17760
|
(colorAttachment) => typeof colorAttachment !== "string" ? colorAttachment : device.createTexture({
|
|
17545
17761
|
id: `${props.id}-texture-0`,
|
|
17546
17762
|
format: colorAttachment,
|
|
17547
|
-
usage:
|
|
17763
|
+
usage: import_core28.Texture.SAMPLE | import_core28.Texture.RENDER | import_core28.Texture.COPY_SRC | import_core28.Texture.COPY_DST,
|
|
17548
17764
|
width,
|
|
17549
17765
|
height
|
|
17550
17766
|
})
|
|
@@ -17554,7 +17770,7 @@ void main(void) {
|
|
|
17554
17770
|
(colorAttachment) => typeof colorAttachment !== "string" ? colorAttachment : device.createTexture({
|
|
17555
17771
|
id: `${props.id}-texture-1`,
|
|
17556
17772
|
format: colorAttachment,
|
|
17557
|
-
usage:
|
|
17773
|
+
usage: import_core28.Texture.SAMPLE | import_core28.Texture.RENDER | import_core28.Texture.COPY_SRC | import_core28.Texture.COPY_DST,
|
|
17558
17774
|
width,
|
|
17559
17775
|
height
|
|
17560
17776
|
})
|
|
@@ -17618,7 +17834,7 @@ void main(void) {
|
|
|
17618
17834
|
};
|
|
17619
17835
|
|
|
17620
17836
|
// src/compute/computation.ts
|
|
17621
|
-
var
|
|
17837
|
+
var import_core29 = __toESM(require_core(), 1);
|
|
17622
17838
|
var import_shaders6 = __toESM(require_shaders(), 1);
|
|
17623
17839
|
var LOG_DRAW_PRIORITY2 = 2;
|
|
17624
17840
|
var LOG_DRAW_TIMEOUT2 = 1e4;
|
|
@@ -17630,13 +17846,13 @@ void main(void) {
|
|
|
17630
17846
|
* constructor remains the synchronous compatibility path.
|
|
17631
17847
|
*/
|
|
17632
17848
|
static async createAsync(device, props) {
|
|
17633
|
-
const ownsCompilation = !
|
|
17634
|
-
const asyncCompilation = ownsCompilation ?
|
|
17849
|
+
const ownsCompilation = !import_core29.PipelineFactory.getAsyncCompilation(device);
|
|
17850
|
+
const asyncCompilation = ownsCompilation ? import_core29.PipelineFactory.beginAsyncCompilation(device) : import_core29.PipelineFactory.getAsyncCompilation(device);
|
|
17635
17851
|
let computation;
|
|
17636
17852
|
try {
|
|
17637
17853
|
computation = new _Computation(device, props);
|
|
17638
17854
|
} finally {
|
|
17639
|
-
if (ownsCompilation)
|
|
17855
|
+
if (ownsCompilation) import_core29.PipelineFactory.endAsyncCompilation(device, asyncCompilation);
|
|
17640
17856
|
}
|
|
17641
17857
|
try {
|
|
17642
17858
|
if (ownsCompilation) {
|
|
@@ -17651,7 +17867,7 @@ void main(void) {
|
|
|
17651
17867
|
}
|
|
17652
17868
|
}
|
|
17653
17869
|
static defaultProps = {
|
|
17654
|
-
...
|
|
17870
|
+
...import_core29.ComputePipeline.defaultProps,
|
|
17655
17871
|
id: "unnamed",
|
|
17656
17872
|
handle: void 0,
|
|
17657
17873
|
userData: {},
|
|
@@ -17705,6 +17921,9 @@ void main(void) {
|
|
|
17705
17921
|
Object.assign(this.userData, props.userData);
|
|
17706
17922
|
const platformInfo = getPlatformInfo(device);
|
|
17707
17923
|
const resolvedPlugins = (0, import_shaders6.resolveShaderPlugins)(this.props.plugins, platformInfo.shaderLanguage);
|
|
17924
|
+
if (resolvedPlugins.hooks.length > 0) {
|
|
17925
|
+
throw new Error("Computation does not support ShaderPlugin render hooks");
|
|
17926
|
+
}
|
|
17708
17927
|
if (Object.keys(resolvedPlugins.vertexInputs).length > 0 || Object.keys(resolvedPlugins.interStageVariables).length > 0) {
|
|
17709
17928
|
throw new Error(
|
|
17710
17929
|
"Computation does not support ShaderPlugin vertex inputs or interStageVariables"
|
|
@@ -17723,10 +17942,10 @@ void main(void) {
|
|
|
17723
17942
|
const modules = mergeShaderModules(this.props.modules, this.shaderInputs?.getModules());
|
|
17724
17943
|
const defines = { ...resolvedPlugins.defines, ...this.props.defines };
|
|
17725
17944
|
this.props.shaderLayout = mergeShaderModuleBindingsIntoLayout(this.props.shaderLayout, modules) || null;
|
|
17726
|
-
this.pipelineFactory = props.pipelineFactory ||
|
|
17727
|
-
this.shaderFactory = props.shaderFactory ||
|
|
17945
|
+
this.pipelineFactory = props.pipelineFactory || import_core29.PipelineFactory.getDefaultPipelineFactory(this.device);
|
|
17946
|
+
this.shaderFactory = props.shaderFactory || import_core29.ShaderFactory.getDefaultShaderFactory(this.device);
|
|
17728
17947
|
const shaderAssembler = this.props.shaderAssembler;
|
|
17729
|
-
(0,
|
|
17948
|
+
(0, import_core29.assert)(shaderAssembler instanceof WGSLShaderAssembler);
|
|
17730
17949
|
const {
|
|
17731
17950
|
source: source4,
|
|
17732
17951
|
getUniforms: getUniforms2,
|
|
@@ -17750,7 +17969,7 @@ void main(void) {
|
|
|
17750
17969
|
this.props.shaderLayout || inferredShaderLayout || null,
|
|
17751
17970
|
modules
|
|
17752
17971
|
) || null;
|
|
17753
|
-
const asyncCompilation =
|
|
17972
|
+
const asyncCompilation = import_core29.PipelineFactory.getAsyncCompilation(this.device);
|
|
17754
17973
|
if (asyncCompilation) {
|
|
17755
17974
|
this._pipelineInitialization = this._updatePipelineAsync();
|
|
17756
17975
|
asyncCompilation.push(this._pipelineInitialization);
|
|
@@ -17817,7 +18036,7 @@ void main(void) {
|
|
|
17817
18036
|
}
|
|
17818
18037
|
setShaderInputs(shaderInputs) {
|
|
17819
18038
|
this.shaderInputs = shaderInputs;
|
|
17820
|
-
this._uniformStore = new
|
|
18039
|
+
this._uniformStore = new import_core29.UniformStore(this.device, this.shaderInputs.modules);
|
|
17821
18040
|
for (const [moduleName, module] of Object.entries(this.shaderInputs.modules)) {
|
|
17822
18041
|
if (shaderModuleHasUniforms(module)) {
|
|
17823
18042
|
const uniformBuffer = this._uniformStore.getManagedUniformBuffer(moduleName);
|
|
@@ -17886,7 +18105,7 @@ void main(void) {
|
|
|
17886
18105
|
if (!this._pipelineNeedsUpdate) return null;
|
|
17887
18106
|
const previousShader = this.pipeline ? this.shader : null;
|
|
17888
18107
|
if (this.pipeline) {
|
|
17889
|
-
|
|
18108
|
+
import_core29.log.log(1, `Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)();
|
|
17890
18109
|
}
|
|
17891
18110
|
this._pipelineNeedsUpdate = false;
|
|
17892
18111
|
this.shader = this.shaderFactory.createShader({
|
|
@@ -17904,27 +18123,27 @@ void main(void) {
|
|
|
17904
18123
|
_lastLogTime = 0;
|
|
17905
18124
|
_logOpen = false;
|
|
17906
18125
|
_logDrawCallStart() {
|
|
17907
|
-
const logDrawTimeout =
|
|
17908
|
-
if (
|
|
18126
|
+
const logDrawTimeout = import_core29.log.level > 3 ? 0 : LOG_DRAW_TIMEOUT2;
|
|
18127
|
+
if (import_core29.log.level < 2 || Date.now() - this._lastLogTime < logDrawTimeout) {
|
|
17909
18128
|
return;
|
|
17910
18129
|
}
|
|
17911
18130
|
this._lastLogTime = Date.now();
|
|
17912
18131
|
this._logOpen = true;
|
|
17913
|
-
|
|
18132
|
+
import_core29.log.group(LOG_DRAW_PRIORITY2, `>>> DRAWING MODEL ${this.id}`, { collapsed: import_core29.log.level <= 2 })();
|
|
17914
18133
|
}
|
|
17915
18134
|
_logDrawCallEnd() {
|
|
17916
18135
|
if (this._logOpen) {
|
|
17917
18136
|
const uniformTable = this.shaderInputs.getDebugTable();
|
|
17918
|
-
|
|
17919
|
-
|
|
18137
|
+
import_core29.log.table(LOG_DRAW_PRIORITY2, uniformTable)();
|
|
18138
|
+
import_core29.log.groupEnd(LOG_DRAW_PRIORITY2)();
|
|
17920
18139
|
this._logOpen = false;
|
|
17921
18140
|
}
|
|
17922
18141
|
}
|
|
17923
18142
|
_drawCount = 0;
|
|
17924
18143
|
// TODO - fix typing of luma data types
|
|
17925
18144
|
_getBufferOrConstantValues(attribute, dataType) {
|
|
17926
|
-
const TypedArrayConstructor =
|
|
17927
|
-
const typedArray = attribute instanceof
|
|
18145
|
+
const TypedArrayConstructor = import_core29.dataTypeDecoder.getTypedArrayConstructor(dataType);
|
|
18146
|
+
const typedArray = attribute instanceof import_core29.Buffer ? new TypedArrayConstructor(attribute.debugData) : attribute;
|
|
17928
18147
|
return typedArray.toString();
|
|
17929
18148
|
}
|
|
17930
18149
|
};
|
|
@@ -18481,7 +18700,7 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
|
|
|
18481
18700
|
this.parameterBuffer = device.createBuffer({
|
|
18482
18701
|
id: `${optimization.name}-parameters`,
|
|
18483
18702
|
byteLength: Math.max(Math.ceil(optimization.uniformNames.length / 4) * 16, 16),
|
|
18484
|
-
usage:
|
|
18703
|
+
usage: import_core30.Buffer.UNIFORM | import_core30.Buffer.COPY_DST
|
|
18485
18704
|
});
|
|
18486
18705
|
const outputBindings = Object.entries(optimization.outputs).map(
|
|
18487
18706
|
([bindingName, targetName], outputIndex) => ({
|
|
@@ -18766,7 +18985,7 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
|
|
|
18766
18985
|
width: targetSize[0],
|
|
18767
18986
|
height: targetSize[1],
|
|
18768
18987
|
format: spec.format || device.preferredColorFormat,
|
|
18769
|
-
usage:
|
|
18988
|
+
usage: import_core30.Texture.SAMPLE | import_core30.Texture.RENDER | import_core30.Texture.COPY_SRC | import_core30.Texture.COPY_DST | (spec.storage && device.type === "webgpu" && device.getTextureFormatCapabilities(spec.format || device.preferredColorFormat).store ? import_core30.Texture.STORAGE : 0),
|
|
18770
18989
|
...spec.sampler ? { sampler: spec.sampler } : {}
|
|
18771
18990
|
});
|
|
18772
18991
|
const framebuffer = device.createFramebuffer({
|
|
@@ -18821,7 +19040,7 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
|
|
|
18821
19040
|
}
|
|
18822
19041
|
|
|
18823
19042
|
// src/modules/picking/picking-manager.ts
|
|
18824
|
-
var
|
|
19043
|
+
var import_core31 = __toESM(require_core(), 1);
|
|
18825
19044
|
|
|
18826
19045
|
// src/modules/picking/picking-uniforms.ts
|
|
18827
19046
|
var DEFAULT_HIGHLIGHT_COLOR = [0, 1, 1, 1];
|
|
@@ -19085,13 +19304,13 @@ layout(std140) uniform pickingUniforms {
|
|
|
19085
19304
|
format: "rgba8unorm",
|
|
19086
19305
|
width: 1,
|
|
19087
19306
|
height: 1,
|
|
19088
|
-
usage:
|
|
19307
|
+
usage: import_core31.Texture.RENDER_ATTACHMENT
|
|
19089
19308
|
});
|
|
19090
19309
|
const pickingTexture = this.device.createTexture({
|
|
19091
19310
|
format: "rg32sint",
|
|
19092
19311
|
width: 1,
|
|
19093
19312
|
height: 1,
|
|
19094
|
-
usage:
|
|
19313
|
+
usage: import_core31.Texture.RENDER_ATTACHMENT | import_core31.Texture.COPY_SRC
|
|
19095
19314
|
});
|
|
19096
19315
|
return this.device.createFramebuffer({
|
|
19097
19316
|
colorAttachments: [colorTexture, pickingTexture],
|
|
@@ -19103,7 +19322,7 @@ layout(std140) uniform pickingUniforms {
|
|
|
19103
19322
|
format: "rgba8unorm",
|
|
19104
19323
|
width: 1,
|
|
19105
19324
|
height: 1,
|
|
19106
|
-
usage:
|
|
19325
|
+
usage: import_core31.Texture.RENDER_ATTACHMENT | import_core31.Texture.COPY_SRC
|
|
19107
19326
|
});
|
|
19108
19327
|
return this.device.createFramebuffer({
|
|
19109
19328
|
colorAttachments: [pickingTexture],
|
|
@@ -19125,7 +19344,7 @@ layout(std140) uniform pickingUniforms {
|
|
|
19125
19344
|
const layout = pickTexture.computeMemoryLayout({ width: 1, height: 1 });
|
|
19126
19345
|
const readBuffer = this.device.createBuffer({
|
|
19127
19346
|
byteLength: layout.byteLength,
|
|
19128
|
-
usage:
|
|
19347
|
+
usage: import_core31.Buffer.COPY_DST | import_core31.Buffer.MAP_READ
|
|
19129
19348
|
});
|
|
19130
19349
|
try {
|
|
19131
19350
|
pickTexture.readBuffer(
|
|
@@ -19161,7 +19380,7 @@ layout(std140) uniform pickingUniforms {
|
|
|
19161
19380
|
const layout = pickTexture.computeMemoryLayout({ width: 1, height: 1 });
|
|
19162
19381
|
const readBuffer = this.device.createBuffer({
|
|
19163
19382
|
byteLength: layout.byteLength,
|
|
19164
|
-
usage:
|
|
19383
|
+
usage: import_core31.Buffer.COPY_DST | import_core31.Buffer.MAP_READ
|
|
19165
19384
|
});
|
|
19166
19385
|
try {
|
|
19167
19386
|
pickTexture.readBuffer(
|
|
@@ -19843,7 +20062,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
19843
20062
|
}
|
|
19844
20063
|
|
|
19845
20064
|
// src/scenegraph/controllers/skin-controller.ts
|
|
19846
|
-
var
|
|
20065
|
+
var import_core32 = __toESM(require_core(), 1);
|
|
19847
20066
|
var SkinController = class {
|
|
19848
20067
|
bindings;
|
|
19849
20068
|
scenes;
|
|
@@ -19874,7 +20093,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
19874
20093
|
target: binding.jointMatrices
|
|
19875
20094
|
});
|
|
19876
20095
|
if (binding.skinJointMatrices) {
|
|
19877
|
-
if (binding.skinJointMatrices instanceof
|
|
20096
|
+
if (binding.skinJointMatrices instanceof import_core32.Buffer) {
|
|
19878
20097
|
binding.skinJointMatrices.write(binding.jointMatrices);
|
|
19879
20098
|
} else {
|
|
19880
20099
|
binding.skinJointMatrices.writeData(binding.jointMatrices, {
|
|
@@ -19906,7 +20125,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
19906
20125
|
return device.createBuffer({
|
|
19907
20126
|
id: `${id}-skin-joint-matrices`,
|
|
19908
20127
|
byteLength: jointMatrices.byteLength,
|
|
19909
|
-
usage:
|
|
20128
|
+
usage: import_core32.Buffer.STORAGE | import_core32.Buffer.COPY_DST
|
|
19910
20129
|
});
|
|
19911
20130
|
}
|
|
19912
20131
|
const width = jointMatrices.length / 4;
|
|
@@ -19918,7 +20137,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
19918
20137
|
format: "rgba32float",
|
|
19919
20138
|
width,
|
|
19920
20139
|
height: 1,
|
|
19921
|
-
usage:
|
|
20140
|
+
usage: import_core32.Texture.SAMPLE | import_core32.Texture.COPY_DST,
|
|
19922
20141
|
sampler: { minFilter: "nearest", magFilter: "nearest", mipmapFilter: "nearest" }
|
|
19923
20142
|
});
|
|
19924
20143
|
}
|
|
@@ -19961,7 +20180,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
19961
20180
|
};
|
|
19962
20181
|
|
|
19963
20182
|
// src/scenegraph/controllers/billboard-controller.ts
|
|
19964
|
-
var
|
|
20183
|
+
var import_core34 = __toESM(require_core(), 1);
|
|
19965
20184
|
var BillboardController = class {
|
|
19966
20185
|
scenes;
|
|
19967
20186
|
bindings = /* @__PURE__ */ new Map();
|
|
@@ -19972,8 +20191,8 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
19972
20191
|
const { definition } = binding;
|
|
19973
20192
|
const forward = new Vector3(definition.viewDirection || [0, 0, 1]);
|
|
19974
20193
|
const up = new Vector3(definition.up || [0, 1, 0]);
|
|
19975
|
-
(0,
|
|
19976
|
-
(0,
|
|
20194
|
+
(0, import_core34.assert)(forward.magnitude() > 0 && up.magnitude() > 0);
|
|
20195
|
+
(0, import_core34.assert)(
|
|
19977
20196
|
new Vector3(forward).normalize().cross(new Vector3(up).normalize()).magnitude() > 1e-6
|
|
19978
20197
|
);
|
|
19979
20198
|
this.bindings.set(binding.node, binding);
|
|
@@ -19983,7 +20202,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
19983
20202
|
getDrawEntries(options) {
|
|
19984
20203
|
const { sceneIndex = 0, cameraId = "default" } = options;
|
|
19985
20204
|
const scene = this.scenes[sceneIndex];
|
|
19986
|
-
(0,
|
|
20205
|
+
(0, import_core34.assert)(scene);
|
|
19987
20206
|
const viewMatrix = new Matrix4(options.viewMatrix);
|
|
19988
20207
|
const cameraMatrix = new Matrix4(viewMatrix).invert();
|
|
19989
20208
|
const cameraPosition = new Vector3(cameraMatrix.getTranslation());
|
|
@@ -20092,7 +20311,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
20092
20311
|
}
|
|
20093
20312
|
|
|
20094
20313
|
// src/scenegraph/controllers/area-light-controller.ts
|
|
20095
|
-
var
|
|
20314
|
+
var import_core36 = __toESM(require_core(), 1);
|
|
20096
20315
|
var AreaLightController = class {
|
|
20097
20316
|
scenes;
|
|
20098
20317
|
matrixAuthoredNodes = /* @__PURE__ */ new Set();
|
|
@@ -20102,11 +20321,11 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
20102
20321
|
for (const node of matrixNodes) this.matrixAuthoredNodes.add(node);
|
|
20103
20322
|
for (const { node, definition, matrixAuthored } of bindings) {
|
|
20104
20323
|
if (matrixAuthored) this.matrixAuthoredNodes.add(node);
|
|
20105
|
-
(0,
|
|
20106
|
-
(0,
|
|
20107
|
-
(0,
|
|
20108
|
-
(0,
|
|
20109
|
-
(0,
|
|
20324
|
+
(0, import_core36.assert)(definition && (definition.type === "rect" || definition.type === "disk"));
|
|
20325
|
+
(0, import_core36.assert)(Number.isFinite(definition.height ?? 1) && (definition.height ?? 1) > 0);
|
|
20326
|
+
(0, import_core36.assert)(Number.isFinite(definition.intensity ?? 1e3) && (definition.intensity ?? 1e3) > 0);
|
|
20327
|
+
(0, import_core36.assert)(Number.isFinite(definition.width ?? 1) && (definition.width ?? 1) > 0);
|
|
20328
|
+
(0, import_core36.assert)(
|
|
20110
20329
|
(definition.color || [1, 1, 1]).every(
|
|
20111
20330
|
(component) => Number.isFinite(component) && component >= 0
|
|
20112
20331
|
)
|
|
@@ -20172,17 +20391,17 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
20172
20391
|
function getMatrixRotation(matrix) {
|
|
20173
20392
|
const horizontal = new Vector3(matrix[0], matrix[1], matrix[2]);
|
|
20174
20393
|
const vertical = new Vector3(matrix[4], matrix[5], matrix[6]);
|
|
20175
|
-
(0,
|
|
20394
|
+
(0, import_core36.assert)(horizontal.magnitude() > 0 && vertical.magnitude() > 0);
|
|
20176
20395
|
horizontal.normalize();
|
|
20177
20396
|
vertical.normalize();
|
|
20178
20397
|
vertical.subtract(new Vector3(horizontal).scale(vertical.dot(horizontal)));
|
|
20179
|
-
(0,
|
|
20398
|
+
(0, import_core36.assert)(vertical.magnitude() > 1e-8);
|
|
20180
20399
|
vertical.normalize();
|
|
20181
20400
|
const forward = new Vector3(horizontal).cross(vertical).normalize();
|
|
20182
20401
|
const authoredForward = new Vector3(matrix[8], matrix[9], matrix[10]);
|
|
20183
|
-
(0,
|
|
20402
|
+
(0, import_core36.assert)(authoredForward.magnitude() > 0);
|
|
20184
20403
|
authoredForward.normalize();
|
|
20185
|
-
(0,
|
|
20404
|
+
(0, import_core36.assert)(Math.abs(forward.dot(authoredForward)) > 1e-8);
|
|
20186
20405
|
if (forward.dot(authoredForward) < 0) forward.negate();
|
|
20187
20406
|
return new Matrix4([
|
|
20188
20407
|
horizontal[0],
|
|
@@ -20740,15 +20959,15 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
20740
20959
|
};
|
|
20741
20960
|
|
|
20742
20961
|
// src/audio/audio-graph.ts
|
|
20743
|
-
var
|
|
20962
|
+
var import_core38 = __toESM(require_core(), 1);
|
|
20744
20963
|
var AudioGraph = class {
|
|
20745
20964
|
constructor(definition, context, destination, getEmitterInputs) {
|
|
20746
20965
|
this.definition = definition;
|
|
20747
20966
|
for (const node of definition.nodes)
|
|
20748
|
-
(0,
|
|
20967
|
+
(0, import_core38.assert)(!node.bypass || node.kind !== "splitter" && node.kind !== "channelmerger");
|
|
20749
20968
|
const validateEndpoint = (index, port = 0) => {
|
|
20750
|
-
(0,
|
|
20751
|
-
(0,
|
|
20969
|
+
(0, import_core38.assert)(Number.isInteger(index) && Boolean(definition.nodes[index]));
|
|
20970
|
+
(0, import_core38.assert)(Number.isInteger(port) && port >= 0);
|
|
20752
20971
|
};
|
|
20753
20972
|
for (const edge of definition.connections) {
|
|
20754
20973
|
validateEndpoint(edge.from.node, edge.from.output);
|
|
@@ -20756,16 +20975,16 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
20756
20975
|
}
|
|
20757
20976
|
for (const input of definition.inputs || []) {
|
|
20758
20977
|
validateEndpoint(input.node, input.input);
|
|
20759
|
-
(0,
|
|
20978
|
+
(0, import_core38.assert)(Number.isInteger(input.source) && input.source >= 0);
|
|
20760
20979
|
}
|
|
20761
20980
|
for (const output of definition.outputs || []) {
|
|
20762
20981
|
validateEndpoint(output.node, output.output);
|
|
20763
|
-
(0,
|
|
20982
|
+
(0, import_core38.assert)(Number.isInteger(output.emitter) && output.emitter >= 0);
|
|
20764
20983
|
}
|
|
20765
20984
|
const visiting = /* @__PURE__ */ new Set();
|
|
20766
20985
|
const visited = /* @__PURE__ */ new Set();
|
|
20767
20986
|
const visit = (index) => {
|
|
20768
|
-
(0,
|
|
20987
|
+
(0, import_core38.assert)(definition.nodes[index] && !visiting.has(index));
|
|
20769
20988
|
if (visited.has(index)) return;
|
|
20770
20989
|
visiting.add(index);
|
|
20771
20990
|
for (const edge of definition.connections) if (edge.from.node === index) visit(edge.to.node);
|
|
@@ -20826,7 +21045,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
20826
21045
|
/** Apply a scene-driven gain change using the authored transition shape. */
|
|
20827
21046
|
setGain(index, gain, time = this.nodes[index].context.currentTime) {
|
|
20828
21047
|
const definition = this.definition.nodes[index];
|
|
20829
|
-
(0,
|
|
21048
|
+
(0, import_core38.assert)(definition.kind === "gain" && !definition.bypass && gain >= 0);
|
|
20830
21049
|
const parameter = this.nodes[index].gain;
|
|
20831
21050
|
const duration = definition.params.duration ?? 0;
|
|
20832
21051
|
const initialGain = parameter.value;
|
|
@@ -20836,7 +21055,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
20836
21055
|
parameter.setValueAtTime(gain, time);
|
|
20837
21056
|
} else if (definition.params.interpolation === "custom") {
|
|
20838
21057
|
const curve = definition.params.curve;
|
|
20839
|
-
(0,
|
|
21058
|
+
(0, import_core38.assert)(curve && curve.length >= 2 && curve.every((value) => value >= 0 && value <= 1));
|
|
20840
21059
|
parameter.setValueCurveAtTime(
|
|
20841
21060
|
Float32Array.from(curve, (value) => value * gain),
|
|
20842
21061
|
time,
|
|
@@ -20921,7 +21140,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
20921
21140
|
}
|
|
20922
21141
|
|
|
20923
21142
|
// src/audio/audio-environment.ts
|
|
20924
|
-
var
|
|
21143
|
+
var import_core40 = __toESM(require_core(), 1);
|
|
20925
21144
|
function selectAudioEnvironmentZone(zones, position) {
|
|
20926
21145
|
let selected;
|
|
20927
21146
|
for (const zone of zones) {
|
|
@@ -21014,7 +21233,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
21014
21233
|
}
|
|
21015
21234
|
};
|
|
21016
21235
|
function createParametricAudioResponse(context, parameters) {
|
|
21017
|
-
(0,
|
|
21236
|
+
(0, import_core40.assert)((parameters.density ?? 1) === 1 && (parameters.diffusion ?? 1) === 1);
|
|
21018
21237
|
const presets = {
|
|
21019
21238
|
generic: [1.49, 0.83, 7e-3, 0.011],
|
|
21020
21239
|
smallRoom: [0.4, 0.83, 2e-3, 3e-3],
|
|
@@ -21031,12 +21250,12 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
21031
21250
|
underwater: [1.49, 0.1, 7e-3, 0.011]
|
|
21032
21251
|
};
|
|
21033
21252
|
const preset = parameters.preset ? presets[parameters.preset] : void 0;
|
|
21034
|
-
(0,
|
|
21253
|
+
(0, import_core40.assert)(!parameters.preset || preset);
|
|
21035
21254
|
const decay = parameters.decayTime ?? preset?.[0] ?? 1.5;
|
|
21036
21255
|
const highFrequencyDecay = decay * (parameters.decayHFRatio ?? preset?.[1] ?? 0.83);
|
|
21037
21256
|
const earlyDelay = parameters.reflectionsDelay ?? preset?.[2] ?? 0.02;
|
|
21038
21257
|
const tailDelay = earlyDelay + (parameters.reverbDelay ?? preset?.[3] ?? 0.04);
|
|
21039
|
-
(0,
|
|
21258
|
+
(0, import_core40.assert)(decay > 0 && highFrequencyDecay > 0 && earlyDelay >= 0 && tailDelay >= earlyDelay);
|
|
21040
21259
|
const response = context.createBuffer(
|
|
21041
21260
|
2,
|
|
21042
21261
|
Math.ceil((tailDelay + Math.max(decay, highFrequencyDecay)) * context.sampleRate),
|
|
@@ -21060,7 +21279,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
21060
21279
|
}
|
|
21061
21280
|
|
|
21062
21281
|
// src/audio/audio-controller.ts
|
|
21063
|
-
var
|
|
21282
|
+
var import_core41 = __toESM(require_core(), 1);
|
|
21064
21283
|
var AudioController = class {
|
|
21065
21284
|
gain;
|
|
21066
21285
|
definition;
|
|
@@ -21170,25 +21389,25 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
21170
21389
|
/** Change a graph gain using its authored interpolation and duration. */
|
|
21171
21390
|
setGraphGain(graphIndex, nodeIndex, gain) {
|
|
21172
21391
|
const graph = this.graphs.get(graphIndex);
|
|
21173
|
-
(0,
|
|
21392
|
+
(0, import_core41.assert)(!this.destroyed && graph);
|
|
21174
21393
|
graph.setGain(nodeIndex, gain);
|
|
21175
21394
|
}
|
|
21176
21395
|
startSource(sourceIndex, startTime, autoplayOnly, connect) {
|
|
21177
21396
|
const definition = this.definition.sources[sourceIndex];
|
|
21178
|
-
(0,
|
|
21397
|
+
(0, import_core41.assert)(definition);
|
|
21179
21398
|
if (autoplayOnly && !definition.autoPlay) return;
|
|
21180
21399
|
const context = this.options.audioContext;
|
|
21181
21400
|
const extended = definition.graph;
|
|
21182
21401
|
const oscillator = extended?.oscillator;
|
|
21183
|
-
(0,
|
|
21402
|
+
(0, import_core41.assert)(!(definition.audio !== void 0 && oscillator));
|
|
21184
21403
|
let source4;
|
|
21185
21404
|
if (oscillator) {
|
|
21186
21405
|
const node = context.createOscillator();
|
|
21187
21406
|
node.frequency.value = oscillator.frequency ?? 440;
|
|
21188
21407
|
node.detune.value = oscillator.detune ?? 0;
|
|
21189
|
-
(0,
|
|
21408
|
+
(0, import_core41.assert)(oscillator.pulseWidth === void 0 || oscillator.pulseWidth === 0.5);
|
|
21190
21409
|
if (oscillator.type === "custom") {
|
|
21191
|
-
(0,
|
|
21410
|
+
(0, import_core41.assert)(oscillator.periodicWave);
|
|
21192
21411
|
node.setPeriodicWave(
|
|
21193
21412
|
context.createPeriodicWave(
|
|
21194
21413
|
new Float32Array(oscillator.periodicWave.real),
|
|
@@ -21199,7 +21418,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
21199
21418
|
source4 = node;
|
|
21200
21419
|
} else {
|
|
21201
21420
|
const node = context.createBufferSource();
|
|
21202
|
-
(0,
|
|
21421
|
+
(0, import_core41.assert)(definition.audio !== void 0);
|
|
21203
21422
|
node.buffer = this.buffers.get(definition.audio);
|
|
21204
21423
|
node.loop = definition.loop ?? false;
|
|
21205
21424
|
node.loopStart = extended?.loopStart ?? 0;
|
|
@@ -21344,15 +21563,15 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
21344
21563
|
}
|
|
21345
21564
|
addEmitter(index, node) {
|
|
21346
21565
|
const definition = this.definition.emitters[index];
|
|
21347
|
-
(0,
|
|
21566
|
+
(0, import_core41.assert)(
|
|
21348
21567
|
definition && (definition.type === "global" || definition.type === "positional" && node)
|
|
21349
21568
|
);
|
|
21350
|
-
(0,
|
|
21569
|
+
(0, import_core41.assert)(
|
|
21351
21570
|
!definition.positional?.shapeType || ["cone", "omnidirectional"].includes(definition.positional.shapeType)
|
|
21352
21571
|
);
|
|
21353
21572
|
for (const sourceIndex of this.graphEmitters.has(index) ? [] : definition.sources || []) {
|
|
21354
21573
|
const source4 = this.definition.sources[sourceIndex];
|
|
21355
|
-
(0,
|
|
21574
|
+
(0, import_core41.assert)(
|
|
21356
21575
|
source4 && (source4.audio !== void 0 ? this.definition.audio[source4.audio] : source4.graph?.oscillator)
|
|
21357
21576
|
);
|
|
21358
21577
|
}
|
|
@@ -21397,7 +21616,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
21397
21616
|
const audioIndices = new Set(
|
|
21398
21617
|
[...sourceIndices].map((index) => {
|
|
21399
21618
|
const source4 = this.definition.sources[index];
|
|
21400
|
-
(0,
|
|
21619
|
+
(0, import_core41.assert)(
|
|
21401
21620
|
source4 && (source4.audio !== void 0 ? this.definition.audio[source4.audio] : source4.graph?.oscillator)
|
|
21402
21621
|
);
|
|
21403
21622
|
return source4.audio;
|
|
@@ -21434,7 +21653,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
21434
21653
|
const reverb = environment.reverb;
|
|
21435
21654
|
if (!reverb) return;
|
|
21436
21655
|
const response = reverb.type === "impulseResponse" ? this.buffers.get(reverb.audio) : createParametricAudioResponse(audioContext, reverb);
|
|
21437
|
-
(0,
|
|
21656
|
+
(0, import_core41.assert)(response);
|
|
21438
21657
|
const bus = new AudioReverbBus(audioContext, response, this.gain, {
|
|
21439
21658
|
...reverb,
|
|
21440
21659
|
normalize: reverb.type === "impulseResponse" ? reverb.normalize : false
|
|
@@ -21543,7 +21762,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
21543
21762
|
var legacyColorPicking = import_shaders8.picking;
|
|
21544
21763
|
|
|
21545
21764
|
// src/geometry/ring-geometry.ts
|
|
21546
|
-
var
|
|
21765
|
+
var import_core43 = __toESM(require_core(), 1);
|
|
21547
21766
|
var RingGeometry = class extends Geometry2 {
|
|
21548
21767
|
constructor(props = {}) {
|
|
21549
21768
|
const {
|
|
@@ -21554,7 +21773,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
21554
21773
|
startAngle = 0,
|
|
21555
21774
|
angle: angle2 = Math.PI * 2
|
|
21556
21775
|
} = props;
|
|
21557
|
-
(0,
|
|
21776
|
+
(0, import_core43.assert)(
|
|
21558
21777
|
Number.isFinite(innerRadius) && innerRadius >= 0 && Number.isFinite(outerRadius) && outerRadius > innerRadius && Number.isFinite(height) && height > 0 && Number.isFinite(startAngle) && Number.isFinite(angle2) && angle2 > 0 && angle2 <= Math.PI * 2 && Number.isInteger(segments) && segments >= 3
|
|
21559
21778
|
);
|
|
21560
21779
|
const halfHeight = height / 2;
|
|
@@ -21738,7 +21957,7 @@ struct PublishedTransforms {bodyIndex:i32,viewProjection:mat4x4f}
|
|
|
21738
21957
|
};
|
|
21739
21958
|
|
|
21740
21959
|
// src/scenegraph/controllers/morph-controller.ts
|
|
21741
|
-
var
|
|
21960
|
+
var import_core46 = __toESM(require_core(), 1);
|
|
21742
21961
|
function setMorphWeights(node, weights) {
|
|
21743
21962
|
node.userData["morphWeights"] = [...weights];
|
|
21744
21963
|
const meshes = node.userData["morphMeshes"] || [];
|
|
@@ -21765,7 +21984,7 @@ struct PublishedTransforms {bodyIndex:i32,viewProjection:mat4x4f}
|
|
|
21765
21984
|
function updateMorphWeights(state, weights) {
|
|
21766
21985
|
state.values.fill(0);
|
|
21767
21986
|
state.values.set(weights.slice(0, state.values.length));
|
|
21768
|
-
if (state.data instanceof
|
|
21987
|
+
if (state.data instanceof import_core46.Buffer) {
|
|
21769
21988
|
state.data.write(state.values);
|
|
21770
21989
|
} else {
|
|
21771
21990
|
state.data.writeData(state.values, { width: state.packedTargetCount, height: 1 });
|