@luma.gl/engine 9.4.0-alpha.1 → 9.4.0-alpha.3
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/dist.dev.js +138 -64
- package/dist/dist.min.js +30 -30
- package/dist/index.cjs +130 -70
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/model/model.d.ts +1 -1
- package/dist/model/model.d.ts.map +1 -1
- package/dist/passes/shader-pass-renderer.d.ts +13 -1
- package/dist/passes/shader-pass-renderer.d.ts.map +1 -1
- package/dist/passes/shader-pass-renderer.js +33 -13
- package/dist/passes/shader-pass-renderer.js.map +1 -1
- package/dist/scenegraph/group-node.d.ts +17 -1
- package/dist/scenegraph/group-node.d.ts.map +1 -1
- package/dist/scenegraph/group-node.js +29 -23
- package/dist/scenegraph/group-node.js.map +1 -1
- package/dist/scenegraph/model-node.d.ts +8 -2
- package/dist/scenegraph/model-node.d.ts.map +1 -1
- package/dist/scenegraph/model-node.js +15 -1
- package/dist/scenegraph/model-node.js.map +1 -1
- package/dist/scenegraph/scenegraph-bounds.d.ts +7 -0
- package/dist/scenegraph/scenegraph-bounds.d.ts.map +1 -0
- package/dist/scenegraph/scenegraph-bounds.js +25 -0
- package/dist/scenegraph/scenegraph-bounds.js.map +1 -0
- package/package.json +4 -4
- package/src/index.ts +6 -0
- package/src/model/model.ts +1 -1
- package/src/passes/shader-pass-renderer.ts +45 -13
- package/src/scenegraph/group-node.ts +63 -26
- package/src/scenegraph/model-node.ts +32 -3
- package/src/scenegraph/scenegraph-bounds.ts +48 -0
package/dist/dist.dev.js
CHANGED
|
@@ -7507,13 +7507,47 @@ void main(void) {
|
|
|
7507
7507
|
};
|
|
7508
7508
|
|
|
7509
7509
|
// src/scenegraph/group-node.ts
|
|
7510
|
-
var
|
|
7510
|
+
var import_core21 = __toESM(require_core(), 1);
|
|
7511
|
+
|
|
7512
|
+
// src/scenegraph/scenegraph-bounds.ts
|
|
7513
|
+
function makeEmptyScenegraphBounds() {
|
|
7514
|
+
return [
|
|
7515
|
+
[Infinity, Infinity, Infinity],
|
|
7516
|
+
[-Infinity, -Infinity, -Infinity]
|
|
7517
|
+
];
|
|
7518
|
+
}
|
|
7519
|
+
function expandScenegraphBounds(targetBounds, sourceBounds, transform) {
|
|
7520
|
+
const transformMatrix = new Matrix4(transform);
|
|
7521
|
+
for (let cornerIndex = 0; cornerIndex < 8; cornerIndex++) {
|
|
7522
|
+
const corner = new Vector3(
|
|
7523
|
+
sourceBounds[cornerIndex & 1 ? 1 : 0][0],
|
|
7524
|
+
sourceBounds[cornerIndex & 2 ? 1 : 0][1],
|
|
7525
|
+
sourceBounds[cornerIndex & 4 ? 1 : 0][2]
|
|
7526
|
+
);
|
|
7527
|
+
transformMatrix.transformAsPoint(corner, corner);
|
|
7528
|
+
for (let componentIndex = 0; componentIndex < 3; componentIndex++) {
|
|
7529
|
+
targetBounds[0][componentIndex] = Math.min(
|
|
7530
|
+
targetBounds[0][componentIndex],
|
|
7531
|
+
corner[componentIndex]
|
|
7532
|
+
);
|
|
7533
|
+
targetBounds[1][componentIndex] = Math.max(
|
|
7534
|
+
targetBounds[1][componentIndex],
|
|
7535
|
+
corner[componentIndex]
|
|
7536
|
+
);
|
|
7537
|
+
}
|
|
7538
|
+
}
|
|
7539
|
+
}
|
|
7540
|
+
function areScenegraphBoundsDefined(bounds) {
|
|
7541
|
+
return Number.isFinite(bounds[0][0]);
|
|
7542
|
+
}
|
|
7543
|
+
|
|
7544
|
+
// src/scenegraph/group-node.ts
|
|
7511
7545
|
var GroupNode = class extends ScenegraphNode {
|
|
7512
7546
|
children;
|
|
7513
7547
|
constructor(props = {}) {
|
|
7514
7548
|
props = Array.isArray(props) ? { children: props } : props;
|
|
7515
7549
|
const { children = [] } = props;
|
|
7516
|
-
|
|
7550
|
+
import_core21.log.assert(
|
|
7517
7551
|
children.every((child) => child instanceof ScenegraphNode),
|
|
7518
7552
|
"every child must an instance of ScenegraphNode"
|
|
7519
7553
|
);
|
|
@@ -7521,32 +7555,16 @@ void main(void) {
|
|
|
7521
7555
|
this.children = children;
|
|
7522
7556
|
}
|
|
7523
7557
|
getBounds() {
|
|
7524
|
-
const result =
|
|
7525
|
-
[Infinity, Infinity, Infinity],
|
|
7526
|
-
[-Infinity, -Infinity, -Infinity]
|
|
7527
|
-
];
|
|
7558
|
+
const result = makeEmptyScenegraphBounds();
|
|
7528
7559
|
this.traverse((node, { worldMatrix }) => {
|
|
7529
7560
|
const bounds = node.getBounds();
|
|
7530
7561
|
if (!bounds) {
|
|
7531
7562
|
return;
|
|
7532
7563
|
}
|
|
7533
|
-
const
|
|
7534
|
-
|
|
7535
|
-
worldMatrix.transformAsPoint(center, center);
|
|
7536
|
-
const halfSize = new Vector3(max).subtract(min).divide([2, 2, 2]);
|
|
7537
|
-
worldMatrix.transformAsVector(halfSize, halfSize);
|
|
7538
|
-
for (let v = 0; v < 8; v++) {
|
|
7539
|
-
const position = new Vector3(v & 1 ? -1 : 1, v & 2 ? -1 : 1, v & 4 ? -1 : 1).multiply(halfSize).add(center);
|
|
7540
|
-
for (let i = 0; i < 3; i++) {
|
|
7541
|
-
result[0][i] = Math.min(result[0][i], position[i]);
|
|
7542
|
-
result[1][i] = Math.max(result[1][i], position[i]);
|
|
7543
|
-
}
|
|
7544
|
-
}
|
|
7564
|
+
const nodeWorldMatrix = new Matrix4(worldMatrix).multiplyRight(node.matrix);
|
|
7565
|
+
expandScenegraphBounds(result, bounds, nodeWorldMatrix);
|
|
7545
7566
|
});
|
|
7546
|
-
|
|
7547
|
-
return null;
|
|
7548
|
-
}
|
|
7549
|
-
return result;
|
|
7567
|
+
return areScenegraphBoundsDefined(result) ? result : null;
|
|
7550
7568
|
}
|
|
7551
7569
|
destroy() {
|
|
7552
7570
|
this.children.forEach((child) => child.destroy());
|
|
@@ -7586,6 +7604,33 @@ void main(void) {
|
|
|
7586
7604
|
}
|
|
7587
7605
|
}
|
|
7588
7606
|
}
|
|
7607
|
+
/** Visits leaf nodes ordered by the camera-space centers of their aggregate bounds. */
|
|
7608
|
+
traverseDepthSorted(visitor, { viewMatrix, worldMatrix = new Matrix4(), order = "back-to-front" }) {
|
|
7609
|
+
const cameraMatrix = new Matrix4(viewMatrix);
|
|
7610
|
+
const nodes = [];
|
|
7611
|
+
this.traverse(
|
|
7612
|
+
(node, context) => {
|
|
7613
|
+
const bounds = node.getBounds();
|
|
7614
|
+
const center = bounds ? new Vector3(bounds[0]).add(bounds[1]).divide([2, 2, 2]) : new Vector3();
|
|
7615
|
+
const nodeWorldMatrix = new Matrix4(context.worldMatrix).multiplyRight(node.matrix);
|
|
7616
|
+
nodeWorldMatrix.transformAsPoint(center, center);
|
|
7617
|
+
cameraMatrix.transformAsPoint(center, center);
|
|
7618
|
+
nodes.push({
|
|
7619
|
+
node,
|
|
7620
|
+
context: { worldMatrix: nodeWorldMatrix, bounds, depth: -center[2] },
|
|
7621
|
+
index: nodes.length
|
|
7622
|
+
});
|
|
7623
|
+
},
|
|
7624
|
+
{ worldMatrix: new Matrix4(worldMatrix) }
|
|
7625
|
+
);
|
|
7626
|
+
const direction = order === "back-to-front" ? -1 : 1;
|
|
7627
|
+
nodes.sort(
|
|
7628
|
+
(first, second) => direction * (first.context.depth - second.context.depth) || first.index - second.index
|
|
7629
|
+
);
|
|
7630
|
+
for (const { node, context } of nodes) {
|
|
7631
|
+
visitor(node, context);
|
|
7632
|
+
}
|
|
7633
|
+
}
|
|
7589
7634
|
preorderTraversal(visitor, { worldMatrix = new Matrix4() } = {}) {
|
|
7590
7635
|
const modelMatrix = new Matrix4(worldMatrix).multiplyRight(this.matrix);
|
|
7591
7636
|
visitor(this, { worldMatrix: modelMatrix });
|
|
@@ -7602,6 +7647,7 @@ void main(void) {
|
|
|
7602
7647
|
// src/scenegraph/model-node.ts
|
|
7603
7648
|
var ModelNode = class extends ScenegraphNode {
|
|
7604
7649
|
model;
|
|
7650
|
+
instanceMatrices;
|
|
7605
7651
|
bounds = null;
|
|
7606
7652
|
managedResources;
|
|
7607
7653
|
// TODO - is this used? override callbacks to make sure we call them with this
|
|
@@ -7612,7 +7658,8 @@ void main(void) {
|
|
|
7612
7658
|
super(props);
|
|
7613
7659
|
this.model = props.model;
|
|
7614
7660
|
this.managedResources = props.managedResources || [];
|
|
7615
|
-
this.
|
|
7661
|
+
this.instanceMatrices = props.instanceMatrices || null;
|
|
7662
|
+
this.bounds = props.bounds ? this.instanceMatrices ? getInstancedScenegraphBounds(props.bounds, this.instanceMatrices) : props.bounds : null;
|
|
7616
7663
|
this.setProps(props);
|
|
7617
7664
|
}
|
|
7618
7665
|
destroy() {
|
|
@@ -7631,6 +7678,13 @@ void main(void) {
|
|
|
7631
7678
|
return this.model.draw(renderPass);
|
|
7632
7679
|
}
|
|
7633
7680
|
};
|
|
7681
|
+
function getInstancedScenegraphBounds(bounds, instanceMatrices) {
|
|
7682
|
+
const instancedBounds = makeEmptyScenegraphBounds();
|
|
7683
|
+
for (const instanceMatrix of instanceMatrices) {
|
|
7684
|
+
expandScenegraphBounds(instancedBounds, bounds, instanceMatrix);
|
|
7685
|
+
}
|
|
7686
|
+
return areScenegraphBoundsDefined(instancedBounds) ? instancedBounds : null;
|
|
7687
|
+
}
|
|
7634
7688
|
|
|
7635
7689
|
// src/geometries/cube-geometry.ts
|
|
7636
7690
|
var CubeGeometry = class extends Geometry {
|
|
@@ -8624,7 +8678,7 @@ void main(void) {
|
|
|
8624
8678
|
}
|
|
8625
8679
|
|
|
8626
8680
|
// src/dynamic-texture/video-texture.ts
|
|
8627
|
-
var
|
|
8681
|
+
var import_core23 = __toESM(require_core(), 1);
|
|
8628
8682
|
var VideoTexture = class {
|
|
8629
8683
|
/** Device used to create copied and native external texture bindings. */
|
|
8630
8684
|
device;
|
|
@@ -8673,7 +8727,7 @@ void main(void) {
|
|
|
8673
8727
|
* @param props Live video source and copied texture options.
|
|
8674
8728
|
*/
|
|
8675
8729
|
constructor(device, props) {
|
|
8676
|
-
(0,
|
|
8730
|
+
(0, import_core23.assert)(isHTMLVideoElementSource(props?.source) || isVideoFrameSource(props?.source));
|
|
8677
8731
|
this.device = device;
|
|
8678
8732
|
this.id = props.id || uid("video-texture");
|
|
8679
8733
|
this._source = props.source;
|
|
@@ -8687,7 +8741,7 @@ void main(void) {
|
|
|
8687
8741
|
* @param source Next caller-owned video source to follow.
|
|
8688
8742
|
*/
|
|
8689
8743
|
setSource(source4) {
|
|
8690
|
-
(0,
|
|
8744
|
+
(0, import_core23.assert)(isHTMLVideoElementSource(source4) || isVideoFrameSource(source4));
|
|
8691
8745
|
this._destroyExternalTexture();
|
|
8692
8746
|
this._source = source4;
|
|
8693
8747
|
this._sourceVersion++;
|
|
@@ -8765,7 +8819,7 @@ void main(void) {
|
|
|
8765
8819
|
width: size.width,
|
|
8766
8820
|
height: size.height,
|
|
8767
8821
|
format: "rgba8unorm",
|
|
8768
|
-
usage:
|
|
8822
|
+
usage: import_core23.Texture.SAMPLE | import_core23.Texture.COPY_DST,
|
|
8769
8823
|
mipLevels: 1,
|
|
8770
8824
|
sampler: this._sampler
|
|
8771
8825
|
});
|
|
@@ -8800,7 +8854,7 @@ void main(void) {
|
|
|
8800
8854
|
*/
|
|
8801
8855
|
_getResolvedSize() {
|
|
8802
8856
|
const size = getVideoTextureSourceSize(this._source);
|
|
8803
|
-
(0,
|
|
8857
|
+
(0, import_core23.assert)(size.width > 0 && size.height > 0);
|
|
8804
8858
|
return size;
|
|
8805
8859
|
}
|
|
8806
8860
|
/** Observes current source readiness and frame identity before binding resolution. */
|
|
@@ -8865,11 +8919,11 @@ void main(void) {
|
|
|
8865
8919
|
}
|
|
8866
8920
|
|
|
8867
8921
|
// src/passes/shader-pass-renderer.ts
|
|
8868
|
-
var
|
|
8922
|
+
var import_core25 = __toESM(require_core(), 1);
|
|
8869
8923
|
var import_shadertools5 = __toESM(require_shadertools(), 1);
|
|
8870
8924
|
|
|
8871
8925
|
// src/compute/swap.ts
|
|
8872
|
-
var
|
|
8926
|
+
var import_core24 = __toESM(require_core(), 1);
|
|
8873
8927
|
var Swap = class {
|
|
8874
8928
|
id;
|
|
8875
8929
|
/** The current resource - usually the source for renders or computations */
|
|
@@ -8901,7 +8955,7 @@ void main(void) {
|
|
|
8901
8955
|
(colorAttachment) => typeof colorAttachment !== "string" ? colorAttachment : device.createTexture({
|
|
8902
8956
|
id: `${props.id}-texture-0`,
|
|
8903
8957
|
format: colorAttachment,
|
|
8904
|
-
usage:
|
|
8958
|
+
usage: import_core24.Texture.SAMPLE | import_core24.Texture.RENDER | import_core24.Texture.COPY_SRC | import_core24.Texture.COPY_DST,
|
|
8905
8959
|
width,
|
|
8906
8960
|
height
|
|
8907
8961
|
})
|
|
@@ -8911,7 +8965,7 @@ void main(void) {
|
|
|
8911
8965
|
(colorAttachment) => typeof colorAttachment !== "string" ? colorAttachment : device.createTexture({
|
|
8912
8966
|
id: `${props.id}-texture-1`,
|
|
8913
8967
|
format: colorAttachment,
|
|
8914
|
-
usage:
|
|
8968
|
+
usage: import_core24.Texture.SAMPLE | import_core24.Texture.RENDER | import_core24.Texture.COPY_SRC | import_core24.Texture.COPY_DST,
|
|
8915
8969
|
width,
|
|
8916
8970
|
height
|
|
8917
8971
|
})
|
|
@@ -9177,14 +9231,22 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
|
|
|
9177
9231
|
}
|
|
9178
9232
|
}
|
|
9179
9233
|
renderToScreen(options) {
|
|
9180
|
-
|
|
9234
|
+
return this.encodeToScreen(this.device.commandEncoder, options);
|
|
9235
|
+
}
|
|
9236
|
+
/**
|
|
9237
|
+
* Records the shader-pass chain and presentation into a caller-owned command encoder.
|
|
9238
|
+
* The encoder must belong to this renderer's device and have no active pass. This method does
|
|
9239
|
+
* not finish or submit the encoder.
|
|
9240
|
+
*/
|
|
9241
|
+
encodeToScreen(commandEncoder, options) {
|
|
9242
|
+
const outputTexture = this.encodeToTexture(commandEncoder, options);
|
|
9181
9243
|
if (!outputTexture) {
|
|
9182
9244
|
return false;
|
|
9183
9245
|
}
|
|
9184
9246
|
const framebuffer = this.device.getDefaultCanvasContext().getCurrentFramebuffer({ depthStencilFormat: false });
|
|
9185
9247
|
this.textureModel.setProps({ backgroundTexture: outputTexture });
|
|
9186
|
-
this.textureModel.predraw(
|
|
9187
|
-
const renderPass =
|
|
9248
|
+
this.textureModel.predraw(commandEncoder);
|
|
9249
|
+
const renderPass = commandEncoder.beginRenderPass({
|
|
9188
9250
|
id: "shader-pass-renderer-to-screen",
|
|
9189
9251
|
framebuffer,
|
|
9190
9252
|
clearDepth: false
|
|
@@ -9197,6 +9259,17 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
|
|
|
9197
9259
|
* @returns null if the the sourceTexture has not yet been loaded
|
|
9198
9260
|
*/
|
|
9199
9261
|
renderToTexture(options) {
|
|
9262
|
+
return this.encodeToTexture(this.device.commandEncoder, options);
|
|
9263
|
+
}
|
|
9264
|
+
/**
|
|
9265
|
+
* Records the shader-pass chain into a caller-owned command encoder.
|
|
9266
|
+
* The encoder must belong to this renderer's device and have no active pass. This method does
|
|
9267
|
+
* not finish or submit the encoder.
|
|
9268
|
+
*/
|
|
9269
|
+
encodeToTexture(commandEncoder, options) {
|
|
9270
|
+
if (commandEncoder.device !== this.device) {
|
|
9271
|
+
throw new Error("ShaderPassRenderer command encoder must belong to the renderer device");
|
|
9272
|
+
}
|
|
9200
9273
|
const { sourceTexture } = options;
|
|
9201
9274
|
if (sourceTexture instanceof DynamicTexture && !sourceTexture.isReady) {
|
|
9202
9275
|
return null;
|
|
@@ -9209,9 +9282,9 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
|
|
|
9209
9282
|
this.resetHistory();
|
|
9210
9283
|
}
|
|
9211
9284
|
this.textureModel.setProps({ backgroundTexture: originalTexture });
|
|
9212
|
-
this.textureModel.predraw(
|
|
9285
|
+
this.textureModel.predraw(commandEncoder);
|
|
9213
9286
|
const sourceFramebuffer = getSeedFramebuffer(this.swapFramebuffers, originalTexture);
|
|
9214
|
-
const seedRenderPass =
|
|
9287
|
+
const seedRenderPass = commandEncoder.beginRenderPass({
|
|
9215
9288
|
id: "shader-pass-renderer-seed-source",
|
|
9216
9289
|
framebuffer: sourceFramebuffer,
|
|
9217
9290
|
clearColor: [0, 0, 0, 1],
|
|
@@ -9224,7 +9297,7 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
|
|
|
9224
9297
|
let frameSucceeded = false;
|
|
9225
9298
|
try {
|
|
9226
9299
|
for (const passRenderer of this.passRenderers) {
|
|
9227
|
-
passRenderer.initializeHistoryTargets(originalTexture, this.textureModel);
|
|
9300
|
+
passRenderer.initializeHistoryTargets(originalTexture, this.textureModel, commandEncoder);
|
|
9228
9301
|
for (const execution of passRenderer.subPassExecutions) {
|
|
9229
9302
|
const outputName = execution.output || "previous";
|
|
9230
9303
|
const outputFramebuffer = outputName === "previous" ? getNextPreviousFramebuffer(this.swapFramebuffers, previousFramebuffer) : passRenderer.getOutputFramebuffer(outputName);
|
|
@@ -9242,7 +9315,7 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
|
|
|
9242
9315
|
options.uniforms || {}
|
|
9243
9316
|
);
|
|
9244
9317
|
execution.subPassRenderer.prepare({
|
|
9245
|
-
commandEncoder
|
|
9318
|
+
commandEncoder,
|
|
9246
9319
|
bindings: resolvedBindings,
|
|
9247
9320
|
textureScale: calculateTextureScale(
|
|
9248
9321
|
resolvedBindings["sourceTexture"] || previousTexture,
|
|
@@ -9250,7 +9323,7 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
|
|
|
9250
9323
|
),
|
|
9251
9324
|
uniforms: resolvedUniforms
|
|
9252
9325
|
});
|
|
9253
|
-
const renderPass =
|
|
9326
|
+
const renderPass = commandEncoder.beginRenderPass({
|
|
9254
9327
|
id: "shader-pass-renderer-run-pass",
|
|
9255
9328
|
framebuffer: outputFramebuffer,
|
|
9256
9329
|
clearColor: [0, 0, 0, 1],
|
|
@@ -9315,7 +9388,7 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
|
|
|
9315
9388
|
renderTarget.writtenThisFrame = false;
|
|
9316
9389
|
}
|
|
9317
9390
|
}
|
|
9318
|
-
initializeHistoryTargets(originalTexture, textureModel) {
|
|
9391
|
+
initializeHistoryTargets(originalTexture, textureModel, commandEncoder) {
|
|
9319
9392
|
for (const renderTarget of Object.values(this.renderTargets)) {
|
|
9320
9393
|
if (renderTarget.spec.lifetime !== "history" || renderTarget.historyInitialized) {
|
|
9321
9394
|
continue;
|
|
@@ -9326,8 +9399,8 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
|
|
|
9326
9399
|
};
|
|
9327
9400
|
if (initialize === "original") {
|
|
9328
9401
|
textureModel.setProps({ backgroundTexture: originalTexture });
|
|
9329
|
-
textureModel.predraw(
|
|
9330
|
-
const renderPass =
|
|
9402
|
+
textureModel.predraw(commandEncoder);
|
|
9403
|
+
const renderPass = commandEncoder.beginRenderPass({
|
|
9331
9404
|
id: `${renderTarget.name}-initialize-history`,
|
|
9332
9405
|
framebuffer: historyFramebuffer,
|
|
9333
9406
|
clearColor: [0, 0, 0, 0],
|
|
@@ -9336,7 +9409,7 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
|
|
|
9336
9409
|
textureModel.draw(renderPass);
|
|
9337
9410
|
renderPass.end();
|
|
9338
9411
|
} else {
|
|
9339
|
-
const renderPass =
|
|
9412
|
+
const renderPass = commandEncoder.beginRenderPass({
|
|
9340
9413
|
id: `${renderTarget.name}-clear-history`,
|
|
9341
9414
|
framebuffer: historyFramebuffer,
|
|
9342
9415
|
clearColor: initialize.clearColor,
|
|
@@ -9628,7 +9701,8 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
|
|
|
9628
9701
|
width: targetSize[0],
|
|
9629
9702
|
height: targetSize[1],
|
|
9630
9703
|
format: spec.format || device.preferredColorFormat,
|
|
9631
|
-
usage:
|
|
9704
|
+
usage: import_core25.Texture.SAMPLE | import_core25.Texture.RENDER | import_core25.Texture.COPY_SRC | import_core25.Texture.COPY_DST,
|
|
9705
|
+
...spec.sampler ? { sampler: spec.sampler } : {}
|
|
9632
9706
|
});
|
|
9633
9707
|
const framebuffer = device.createFramebuffer({
|
|
9634
9708
|
id: `${name}-framebuffer`,
|
|
@@ -9682,7 +9756,7 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
|
|
|
9682
9756
|
}
|
|
9683
9757
|
|
|
9684
9758
|
// src/compute/computation.ts
|
|
9685
|
-
var
|
|
9759
|
+
var import_core26 = __toESM(require_core(), 1);
|
|
9686
9760
|
var import_shadertools6 = __toESM(require_shadertools(), 1);
|
|
9687
9761
|
var LOG_DRAW_PRIORITY2 = 2;
|
|
9688
9762
|
var LOG_DRAW_TIMEOUT2 = 1e4;
|
|
@@ -9736,8 +9810,8 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
|
|
|
9736
9810
|
const modules = mergeShaderModules(this.props.modules, this.shaderInputs?.getModules());
|
|
9737
9811
|
const defines = { ...resolvedPlugins.defines, ...this.props.defines };
|
|
9738
9812
|
this.props.shaderLayout = mergeShaderModuleBindingsIntoLayout(this.props.shaderLayout, modules) || null;
|
|
9739
|
-
this.pipelineFactory = props.pipelineFactory ||
|
|
9740
|
-
this.shaderFactory = props.shaderFactory ||
|
|
9813
|
+
this.pipelineFactory = props.pipelineFactory || import_core26.PipelineFactory.getDefaultPipelineFactory(this.device);
|
|
9814
|
+
this.shaderFactory = props.shaderFactory || import_core26.ShaderFactory.getDefaultShaderFactory(this.device);
|
|
9741
9815
|
const { source: source4, getUniforms: getUniforms2 } = this.props.shaderAssembler.assembleWGSLShader({
|
|
9742
9816
|
platformInfo,
|
|
9743
9817
|
...this.props,
|
|
@@ -9801,7 +9875,7 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
|
|
|
9801
9875
|
}
|
|
9802
9876
|
setShaderInputs(shaderInputs) {
|
|
9803
9877
|
this.shaderInputs = shaderInputs;
|
|
9804
|
-
this._uniformStore = new
|
|
9878
|
+
this._uniformStore = new import_core26.UniformStore(this.device, this.shaderInputs.modules);
|
|
9805
9879
|
for (const [moduleName, module] of Object.entries(this.shaderInputs.modules)) {
|
|
9806
9880
|
if (shaderModuleHasUniforms(module)) {
|
|
9807
9881
|
const uniformBuffer = this._uniformStore.getManagedUniformBuffer(moduleName);
|
|
@@ -9846,7 +9920,7 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
|
|
|
9846
9920
|
if (this._pipelineNeedsUpdate) {
|
|
9847
9921
|
let prevShader = null;
|
|
9848
9922
|
if (this.pipeline) {
|
|
9849
|
-
|
|
9923
|
+
import_core26.log.log(
|
|
9850
9924
|
1,
|
|
9851
9925
|
`Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`
|
|
9852
9926
|
)();
|
|
@@ -9873,33 +9947,33 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
|
|
|
9873
9947
|
_lastLogTime = 0;
|
|
9874
9948
|
_logOpen = false;
|
|
9875
9949
|
_logDrawCallStart() {
|
|
9876
|
-
const logDrawTimeout =
|
|
9877
|
-
if (
|
|
9950
|
+
const logDrawTimeout = import_core26.log.level > 3 ? 0 : LOG_DRAW_TIMEOUT2;
|
|
9951
|
+
if (import_core26.log.level < 2 || Date.now() - this._lastLogTime < logDrawTimeout) {
|
|
9878
9952
|
return;
|
|
9879
9953
|
}
|
|
9880
9954
|
this._lastLogTime = Date.now();
|
|
9881
9955
|
this._logOpen = true;
|
|
9882
|
-
|
|
9956
|
+
import_core26.log.group(LOG_DRAW_PRIORITY2, `>>> DRAWING MODEL ${this.id}`, { collapsed: import_core26.log.level <= 2 })();
|
|
9883
9957
|
}
|
|
9884
9958
|
_logDrawCallEnd() {
|
|
9885
9959
|
if (this._logOpen) {
|
|
9886
9960
|
const uniformTable = this.shaderInputs.getDebugTable();
|
|
9887
|
-
|
|
9888
|
-
|
|
9961
|
+
import_core26.log.table(LOG_DRAW_PRIORITY2, uniformTable)();
|
|
9962
|
+
import_core26.log.groupEnd(LOG_DRAW_PRIORITY2)();
|
|
9889
9963
|
this._logOpen = false;
|
|
9890
9964
|
}
|
|
9891
9965
|
}
|
|
9892
9966
|
_drawCount = 0;
|
|
9893
9967
|
// TODO - fix typing of luma data types
|
|
9894
9968
|
_getBufferOrConstantValues(attribute, dataType) {
|
|
9895
|
-
const TypedArrayConstructor =
|
|
9896
|
-
const typedArray = attribute instanceof
|
|
9969
|
+
const TypedArrayConstructor = import_core26.dataTypeDecoder.getTypedArrayConstructor(dataType);
|
|
9970
|
+
const typedArray = attribute instanceof import_core26.Buffer ? new TypedArrayConstructor(attribute.debugData) : attribute;
|
|
9897
9971
|
return typedArray.toString();
|
|
9898
9972
|
}
|
|
9899
9973
|
};
|
|
9900
9974
|
var Computation = _Computation;
|
|
9901
9975
|
__publicField(Computation, "defaultProps", {
|
|
9902
|
-
...
|
|
9976
|
+
...import_core26.ComputePipeline.defaultProps,
|
|
9903
9977
|
id: "unnamed",
|
|
9904
9978
|
handle: void 0,
|
|
9905
9979
|
userData: {},
|
|
@@ -9927,7 +10001,7 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
|
|
|
9927
10001
|
}
|
|
9928
10002
|
|
|
9929
10003
|
// src/modules/picking/picking-manager.ts
|
|
9930
|
-
var
|
|
10004
|
+
var import_core27 = __toESM(require_core(), 1);
|
|
9931
10005
|
|
|
9932
10006
|
// src/modules/picking/picking-uniforms.ts
|
|
9933
10007
|
var DEFAULT_HIGHLIGHT_COLOR = [0, 1, 1, 1];
|
|
@@ -10183,13 +10257,13 @@ layout(std140) uniform pickingUniforms {
|
|
|
10183
10257
|
format: "rgba8unorm",
|
|
10184
10258
|
width: 1,
|
|
10185
10259
|
height: 1,
|
|
10186
|
-
usage:
|
|
10260
|
+
usage: import_core27.Texture.RENDER_ATTACHMENT
|
|
10187
10261
|
});
|
|
10188
10262
|
const pickingTexture = this.device.createTexture({
|
|
10189
10263
|
format: "rg32sint",
|
|
10190
10264
|
width: 1,
|
|
10191
10265
|
height: 1,
|
|
10192
|
-
usage:
|
|
10266
|
+
usage: import_core27.Texture.RENDER_ATTACHMENT | import_core27.Texture.COPY_SRC
|
|
10193
10267
|
});
|
|
10194
10268
|
return this.device.createFramebuffer({
|
|
10195
10269
|
colorAttachments: [colorTexture, pickingTexture],
|
|
@@ -10201,7 +10275,7 @@ layout(std140) uniform pickingUniforms {
|
|
|
10201
10275
|
format: "rgba8unorm",
|
|
10202
10276
|
width: 1,
|
|
10203
10277
|
height: 1,
|
|
10204
|
-
usage:
|
|
10278
|
+
usage: import_core27.Texture.RENDER_ATTACHMENT | import_core27.Texture.COPY_SRC
|
|
10205
10279
|
});
|
|
10206
10280
|
return this.device.createFramebuffer({
|
|
10207
10281
|
colorAttachments: [pickingTexture],
|
|
@@ -10223,7 +10297,7 @@ layout(std140) uniform pickingUniforms {
|
|
|
10223
10297
|
const layout = pickTexture.computeMemoryLayout({ width: 1, height: 1 });
|
|
10224
10298
|
const readBuffer = this.device.createBuffer({
|
|
10225
10299
|
byteLength: layout.byteLength,
|
|
10226
|
-
usage:
|
|
10300
|
+
usage: import_core27.Buffer.COPY_DST | import_core27.Buffer.MAP_READ
|
|
10227
10301
|
});
|
|
10228
10302
|
try {
|
|
10229
10303
|
pickTexture.readBuffer(
|
|
@@ -10259,7 +10333,7 @@ layout(std140) uniform pickingUniforms {
|
|
|
10259
10333
|
const layout = pickTexture.computeMemoryLayout({ width: 1, height: 1 });
|
|
10260
10334
|
const readBuffer = this.device.createBuffer({
|
|
10261
10335
|
byteLength: layout.byteLength,
|
|
10262
|
-
usage:
|
|
10336
|
+
usage: import_core27.Buffer.COPY_DST | import_core27.Buffer.MAP_READ
|
|
10263
10337
|
});
|
|
10264
10338
|
try {
|
|
10265
10339
|
pickTexture.readBuffer(
|