@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/index.cjs
CHANGED
|
@@ -5087,44 +5087,53 @@ var ScenegraphNode = class {
|
|
|
5087
5087
|
};
|
|
5088
5088
|
|
|
5089
5089
|
// dist/scenegraph/group-node.js
|
|
5090
|
+
var import_core20 = require("@math.gl/core");
|
|
5091
|
+
var import_core21 = require("@luma.gl/core");
|
|
5092
|
+
|
|
5093
|
+
// dist/scenegraph/scenegraph-bounds.js
|
|
5090
5094
|
var import_core19 = require("@math.gl/core");
|
|
5091
|
-
|
|
5095
|
+
function makeEmptyScenegraphBounds() {
|
|
5096
|
+
return [
|
|
5097
|
+
[Infinity, Infinity, Infinity],
|
|
5098
|
+
[-Infinity, -Infinity, -Infinity]
|
|
5099
|
+
];
|
|
5100
|
+
}
|
|
5101
|
+
function expandScenegraphBounds(targetBounds, sourceBounds, transform) {
|
|
5102
|
+
const transformMatrix = new import_core19.Matrix4(transform);
|
|
5103
|
+
for (let cornerIndex = 0; cornerIndex < 8; cornerIndex++) {
|
|
5104
|
+
const corner = new import_core19.Vector3(sourceBounds[cornerIndex & 1 ? 1 : 0][0], sourceBounds[cornerIndex & 2 ? 1 : 0][1], sourceBounds[cornerIndex & 4 ? 1 : 0][2]);
|
|
5105
|
+
transformMatrix.transformAsPoint(corner, corner);
|
|
5106
|
+
for (let componentIndex = 0; componentIndex < 3; componentIndex++) {
|
|
5107
|
+
targetBounds[0][componentIndex] = Math.min(targetBounds[0][componentIndex], corner[componentIndex]);
|
|
5108
|
+
targetBounds[1][componentIndex] = Math.max(targetBounds[1][componentIndex], corner[componentIndex]);
|
|
5109
|
+
}
|
|
5110
|
+
}
|
|
5111
|
+
}
|
|
5112
|
+
function areScenegraphBoundsDefined(bounds) {
|
|
5113
|
+
return Number.isFinite(bounds[0][0]);
|
|
5114
|
+
}
|
|
5115
|
+
|
|
5116
|
+
// dist/scenegraph/group-node.js
|
|
5092
5117
|
var GroupNode = class extends ScenegraphNode {
|
|
5093
5118
|
children;
|
|
5094
5119
|
constructor(props = {}) {
|
|
5095
5120
|
props = Array.isArray(props) ? { children: props } : props;
|
|
5096
5121
|
const { children = [] } = props;
|
|
5097
|
-
|
|
5122
|
+
import_core21.log.assert(children.every((child) => child instanceof ScenegraphNode), "every child must an instance of ScenegraphNode");
|
|
5098
5123
|
super(props);
|
|
5099
5124
|
this.children = children;
|
|
5100
5125
|
}
|
|
5101
5126
|
getBounds() {
|
|
5102
|
-
const result =
|
|
5103
|
-
[Infinity, Infinity, Infinity],
|
|
5104
|
-
[-Infinity, -Infinity, -Infinity]
|
|
5105
|
-
];
|
|
5127
|
+
const result = makeEmptyScenegraphBounds();
|
|
5106
5128
|
this.traverse((node, { worldMatrix }) => {
|
|
5107
5129
|
const bounds = node.getBounds();
|
|
5108
5130
|
if (!bounds) {
|
|
5109
5131
|
return;
|
|
5110
5132
|
}
|
|
5111
|
-
const
|
|
5112
|
-
|
|
5113
|
-
worldMatrix.transformAsPoint(center, center);
|
|
5114
|
-
const halfSize = new import_core19.Vector3(max).subtract(min).divide([2, 2, 2]);
|
|
5115
|
-
worldMatrix.transformAsVector(halfSize, halfSize);
|
|
5116
|
-
for (let v = 0; v < 8; v++) {
|
|
5117
|
-
const position = new import_core19.Vector3(v & 1 ? -1 : 1, v & 2 ? -1 : 1, v & 4 ? -1 : 1).multiply(halfSize).add(center);
|
|
5118
|
-
for (let i = 0; i < 3; i++) {
|
|
5119
|
-
result[0][i] = Math.min(result[0][i], position[i]);
|
|
5120
|
-
result[1][i] = Math.max(result[1][i], position[i]);
|
|
5121
|
-
}
|
|
5122
|
-
}
|
|
5133
|
+
const nodeWorldMatrix = new import_core20.Matrix4(worldMatrix).multiplyRight(node.matrix);
|
|
5134
|
+
expandScenegraphBounds(result, bounds, nodeWorldMatrix);
|
|
5123
5135
|
});
|
|
5124
|
-
|
|
5125
|
-
return null;
|
|
5126
|
-
}
|
|
5127
|
-
return result;
|
|
5136
|
+
return areScenegraphBoundsDefined(result) ? result : null;
|
|
5128
5137
|
}
|
|
5129
5138
|
destroy() {
|
|
5130
5139
|
this.children.forEach((child) => child.destroy());
|
|
@@ -5154,8 +5163,8 @@ var GroupNode = class extends ScenegraphNode {
|
|
|
5154
5163
|
this.children = [];
|
|
5155
5164
|
return this;
|
|
5156
5165
|
}
|
|
5157
|
-
traverse(visitor, { worldMatrix = new
|
|
5158
|
-
const modelMatrix = new
|
|
5166
|
+
traverse(visitor, { worldMatrix = new import_core20.Matrix4() } = {}) {
|
|
5167
|
+
const modelMatrix = new import_core20.Matrix4(worldMatrix).multiplyRight(this.matrix);
|
|
5159
5168
|
for (const child of this.children) {
|
|
5160
5169
|
if (child instanceof GroupNode) {
|
|
5161
5170
|
child.traverse(visitor, { worldMatrix: modelMatrix });
|
|
@@ -5164,8 +5173,30 @@ var GroupNode = class extends ScenegraphNode {
|
|
|
5164
5173
|
}
|
|
5165
5174
|
}
|
|
5166
5175
|
}
|
|
5167
|
-
|
|
5168
|
-
|
|
5176
|
+
/** Visits leaf nodes ordered by the camera-space centers of their aggregate bounds. */
|
|
5177
|
+
traverseDepthSorted(visitor, { viewMatrix, worldMatrix = new import_core20.Matrix4(), order = "back-to-front" }) {
|
|
5178
|
+
const cameraMatrix = new import_core20.Matrix4(viewMatrix);
|
|
5179
|
+
const nodes = [];
|
|
5180
|
+
this.traverse((node, context) => {
|
|
5181
|
+
const bounds = node.getBounds();
|
|
5182
|
+
const center = bounds ? new import_core20.Vector3(bounds[0]).add(bounds[1]).divide([2, 2, 2]) : new import_core20.Vector3();
|
|
5183
|
+
const nodeWorldMatrix = new import_core20.Matrix4(context.worldMatrix).multiplyRight(node.matrix);
|
|
5184
|
+
nodeWorldMatrix.transformAsPoint(center, center);
|
|
5185
|
+
cameraMatrix.transformAsPoint(center, center);
|
|
5186
|
+
nodes.push({
|
|
5187
|
+
node,
|
|
5188
|
+
context: { worldMatrix: nodeWorldMatrix, bounds, depth: -center[2] },
|
|
5189
|
+
index: nodes.length
|
|
5190
|
+
});
|
|
5191
|
+
}, { worldMatrix: new import_core20.Matrix4(worldMatrix) });
|
|
5192
|
+
const direction = order === "back-to-front" ? -1 : 1;
|
|
5193
|
+
nodes.sort((first, second) => direction * (first.context.depth - second.context.depth) || first.index - second.index);
|
|
5194
|
+
for (const { node, context } of nodes) {
|
|
5195
|
+
visitor(node, context);
|
|
5196
|
+
}
|
|
5197
|
+
}
|
|
5198
|
+
preorderTraversal(visitor, { worldMatrix = new import_core20.Matrix4() } = {}) {
|
|
5199
|
+
const modelMatrix = new import_core20.Matrix4(worldMatrix).multiplyRight(this.matrix);
|
|
5169
5200
|
visitor(this, { worldMatrix: modelMatrix });
|
|
5170
5201
|
for (const child of this.children) {
|
|
5171
5202
|
if (child instanceof GroupNode) {
|
|
@@ -5180,6 +5211,7 @@ var GroupNode = class extends ScenegraphNode {
|
|
|
5180
5211
|
// dist/scenegraph/model-node.js
|
|
5181
5212
|
var ModelNode = class extends ScenegraphNode {
|
|
5182
5213
|
model;
|
|
5214
|
+
instanceMatrices;
|
|
5183
5215
|
bounds = null;
|
|
5184
5216
|
managedResources;
|
|
5185
5217
|
// TODO - is this used? override callbacks to make sure we call them with this
|
|
@@ -5190,7 +5222,8 @@ var ModelNode = class extends ScenegraphNode {
|
|
|
5190
5222
|
super(props);
|
|
5191
5223
|
this.model = props.model;
|
|
5192
5224
|
this.managedResources = props.managedResources || [];
|
|
5193
|
-
this.
|
|
5225
|
+
this.instanceMatrices = props.instanceMatrices || null;
|
|
5226
|
+
this.bounds = props.bounds ? this.instanceMatrices ? getInstancedScenegraphBounds(props.bounds, this.instanceMatrices) : props.bounds : null;
|
|
5194
5227
|
this.setProps(props);
|
|
5195
5228
|
}
|
|
5196
5229
|
destroy() {
|
|
@@ -5209,6 +5242,13 @@ var ModelNode = class extends ScenegraphNode {
|
|
|
5209
5242
|
return this.model.draw(renderPass);
|
|
5210
5243
|
}
|
|
5211
5244
|
};
|
|
5245
|
+
function getInstancedScenegraphBounds(bounds, instanceMatrices) {
|
|
5246
|
+
const instancedBounds = makeEmptyScenegraphBounds();
|
|
5247
|
+
for (const instanceMatrix of instanceMatrices) {
|
|
5248
|
+
expandScenegraphBounds(instancedBounds, bounds, instanceMatrix);
|
|
5249
|
+
}
|
|
5250
|
+
return areScenegraphBoundsDefined(instancedBounds) ? instancedBounds : null;
|
|
5251
|
+
}
|
|
5212
5252
|
|
|
5213
5253
|
// dist/geometries/cube-geometry.js
|
|
5214
5254
|
var CubeGeometry = class extends Geometry {
|
|
@@ -5899,7 +5939,7 @@ var CylinderGeometry = class extends TruncatedConeGeometry {
|
|
|
5899
5939
|
};
|
|
5900
5940
|
|
|
5901
5941
|
// dist/geometries/ico-sphere-geometry.js
|
|
5902
|
-
var
|
|
5942
|
+
var import_core22 = require("@math.gl/core");
|
|
5903
5943
|
var ICO_POSITIONS = [-1, 0, 0, 0, 1, 0, 0, 0, -1, 0, 0, 1, 0, -1, 0, 1, 0, 0];
|
|
5904
5944
|
var ICO_INDICES = [3, 4, 5, 3, 5, 1, 3, 1, 0, 3, 0, 4, 4, 0, 2, 4, 2, 5, 2, 0, 1, 5, 2, 1];
|
|
5905
5945
|
var IcoSphereGeometry = class extends Geometry {
|
|
@@ -5999,7 +6039,7 @@ function tesselateIcosaHedron(props) {
|
|
|
5999
6039
|
const u3 = 1 - phi3 / PI2;
|
|
6000
6040
|
const vec1 = [x3 - x2, y3 - y2, z3 - z2];
|
|
6001
6041
|
const vec2 = [x1 - x2, y1 - y2, z1 - z2];
|
|
6002
|
-
const normal = new
|
|
6042
|
+
const normal = new import_core22.Vector3(vec1).cross(vec2).normalize();
|
|
6003
6043
|
let newIndex;
|
|
6004
6044
|
if ((u1 === 0 || u2 === 0 || u3 === 0) && (u1 === 0 || u1 > 0.5) && (u2 === 0 || u2 > 0.5) && (u3 === 0 || u3 > 0.5)) {
|
|
6005
6045
|
positions.push(positions[in1 + 0], positions[in1 + 1], positions[in1 + 2]);
|
|
@@ -6201,7 +6241,7 @@ function isAbsoluteLoadFileUrl(url) {
|
|
|
6201
6241
|
}
|
|
6202
6242
|
|
|
6203
6243
|
// dist/dynamic-texture/video-texture.js
|
|
6204
|
-
var
|
|
6244
|
+
var import_core23 = require("@luma.gl/core");
|
|
6205
6245
|
var VideoTexture = class {
|
|
6206
6246
|
/** Device used to create copied and native external texture bindings. */
|
|
6207
6247
|
device;
|
|
@@ -6250,7 +6290,7 @@ var VideoTexture = class {
|
|
|
6250
6290
|
* @param props Live video source and copied texture options.
|
|
6251
6291
|
*/
|
|
6252
6292
|
constructor(device, props) {
|
|
6253
|
-
(0,
|
|
6293
|
+
(0, import_core23.assert)(isHTMLVideoElementSource(props == null ? void 0 : props.source) || isVideoFrameSource(props == null ? void 0 : props.source));
|
|
6254
6294
|
this.device = device;
|
|
6255
6295
|
this.id = props.id || uid("video-texture");
|
|
6256
6296
|
this._source = props.source;
|
|
@@ -6264,7 +6304,7 @@ var VideoTexture = class {
|
|
|
6264
6304
|
* @param source Next caller-owned video source to follow.
|
|
6265
6305
|
*/
|
|
6266
6306
|
setSource(source4) {
|
|
6267
|
-
(0,
|
|
6307
|
+
(0, import_core23.assert)(isHTMLVideoElementSource(source4) || isVideoFrameSource(source4));
|
|
6268
6308
|
this._destroyExternalTexture();
|
|
6269
6309
|
this._source = source4;
|
|
6270
6310
|
this._sourceVersion++;
|
|
@@ -6344,7 +6384,7 @@ var VideoTexture = class {
|
|
|
6344
6384
|
width: size.width,
|
|
6345
6385
|
height: size.height,
|
|
6346
6386
|
format: "rgba8unorm",
|
|
6347
|
-
usage:
|
|
6387
|
+
usage: import_core23.Texture.SAMPLE | import_core23.Texture.COPY_DST,
|
|
6348
6388
|
mipLevels: 1,
|
|
6349
6389
|
sampler: this._sampler
|
|
6350
6390
|
});
|
|
@@ -6380,7 +6420,7 @@ var VideoTexture = class {
|
|
|
6380
6420
|
*/
|
|
6381
6421
|
_getResolvedSize() {
|
|
6382
6422
|
const size = getVideoTextureSourceSize(this._source);
|
|
6383
|
-
(0,
|
|
6423
|
+
(0, import_core23.assert)(size.width > 0 && size.height > 0);
|
|
6384
6424
|
return size;
|
|
6385
6425
|
}
|
|
6386
6426
|
/** Observes current source readiness and frame identity before binding resolution. */
|
|
@@ -6445,11 +6485,11 @@ function getVideoTextureSourceFrameToken(source4, sourceVersion) {
|
|
|
6445
6485
|
}
|
|
6446
6486
|
|
|
6447
6487
|
// dist/passes/shader-pass-renderer.js
|
|
6448
|
-
var
|
|
6488
|
+
var import_core25 = require("@luma.gl/core");
|
|
6449
6489
|
var import_shadertools5 = require("@luma.gl/shadertools");
|
|
6450
6490
|
|
|
6451
6491
|
// dist/compute/swap.js
|
|
6452
|
-
var
|
|
6492
|
+
var import_core24 = require("@luma.gl/core");
|
|
6453
6493
|
var Swap = class {
|
|
6454
6494
|
id;
|
|
6455
6495
|
/** The current resource - usually the source for renders or computations */
|
|
@@ -6482,7 +6522,7 @@ var SwapFramebuffers = class extends Swap {
|
|
|
6482
6522
|
let colorAttachments = (_a = props.colorAttachments) == null ? void 0 : _a.map((colorAttachment) => typeof colorAttachment !== "string" ? colorAttachment : device.createTexture({
|
|
6483
6523
|
id: `${props.id}-texture-0`,
|
|
6484
6524
|
format: colorAttachment,
|
|
6485
|
-
usage:
|
|
6525
|
+
usage: import_core24.Texture.SAMPLE | import_core24.Texture.RENDER | import_core24.Texture.COPY_SRC | import_core24.Texture.COPY_DST,
|
|
6486
6526
|
width,
|
|
6487
6527
|
height
|
|
6488
6528
|
}));
|
|
@@ -6490,7 +6530,7 @@ var SwapFramebuffers = class extends Swap {
|
|
|
6490
6530
|
colorAttachments = (_b = props.colorAttachments) == null ? void 0 : _b.map((colorAttachment) => typeof colorAttachment !== "string" ? colorAttachment : device.createTexture({
|
|
6491
6531
|
id: `${props.id}-texture-1`,
|
|
6492
6532
|
format: colorAttachment,
|
|
6493
|
-
usage:
|
|
6533
|
+
usage: import_core24.Texture.SAMPLE | import_core24.Texture.RENDER | import_core24.Texture.COPY_SRC | import_core24.Texture.COPY_DST,
|
|
6494
6534
|
width,
|
|
6495
6535
|
height
|
|
6496
6536
|
}));
|
|
@@ -6750,14 +6790,22 @@ var ShaderPassRenderer = class {
|
|
|
6750
6790
|
}
|
|
6751
6791
|
}
|
|
6752
6792
|
renderToScreen(options) {
|
|
6753
|
-
|
|
6793
|
+
return this.encodeToScreen(this.device.commandEncoder, options);
|
|
6794
|
+
}
|
|
6795
|
+
/**
|
|
6796
|
+
* Records the shader-pass chain and presentation into a caller-owned command encoder.
|
|
6797
|
+
* The encoder must belong to this renderer's device and have no active pass. This method does
|
|
6798
|
+
* not finish or submit the encoder.
|
|
6799
|
+
*/
|
|
6800
|
+
encodeToScreen(commandEncoder, options) {
|
|
6801
|
+
const outputTexture = this.encodeToTexture(commandEncoder, options);
|
|
6754
6802
|
if (!outputTexture) {
|
|
6755
6803
|
return false;
|
|
6756
6804
|
}
|
|
6757
6805
|
const framebuffer = this.device.getDefaultCanvasContext().getCurrentFramebuffer({ depthStencilFormat: false });
|
|
6758
6806
|
this.textureModel.setProps({ backgroundTexture: outputTexture });
|
|
6759
|
-
this.textureModel.predraw(
|
|
6760
|
-
const renderPass =
|
|
6807
|
+
this.textureModel.predraw(commandEncoder);
|
|
6808
|
+
const renderPass = commandEncoder.beginRenderPass({
|
|
6761
6809
|
id: "shader-pass-renderer-to-screen",
|
|
6762
6810
|
framebuffer,
|
|
6763
6811
|
clearDepth: false
|
|
@@ -6770,6 +6818,17 @@ var ShaderPassRenderer = class {
|
|
|
6770
6818
|
* @returns null if the the sourceTexture has not yet been loaded
|
|
6771
6819
|
*/
|
|
6772
6820
|
renderToTexture(options) {
|
|
6821
|
+
return this.encodeToTexture(this.device.commandEncoder, options);
|
|
6822
|
+
}
|
|
6823
|
+
/**
|
|
6824
|
+
* Records the shader-pass chain into a caller-owned command encoder.
|
|
6825
|
+
* The encoder must belong to this renderer's device and have no active pass. This method does
|
|
6826
|
+
* not finish or submit the encoder.
|
|
6827
|
+
*/
|
|
6828
|
+
encodeToTexture(commandEncoder, options) {
|
|
6829
|
+
if (commandEncoder.device !== this.device) {
|
|
6830
|
+
throw new Error("ShaderPassRenderer command encoder must belong to the renderer device");
|
|
6831
|
+
}
|
|
6773
6832
|
const { sourceTexture } = options;
|
|
6774
6833
|
if (sourceTexture instanceof DynamicTexture && !sourceTexture.isReady) {
|
|
6775
6834
|
return null;
|
|
@@ -6782,9 +6841,9 @@ var ShaderPassRenderer = class {
|
|
|
6782
6841
|
this.resetHistory();
|
|
6783
6842
|
}
|
|
6784
6843
|
this.textureModel.setProps({ backgroundTexture: originalTexture });
|
|
6785
|
-
this.textureModel.predraw(
|
|
6844
|
+
this.textureModel.predraw(commandEncoder);
|
|
6786
6845
|
const sourceFramebuffer = getSeedFramebuffer(this.swapFramebuffers, originalTexture);
|
|
6787
|
-
const seedRenderPass =
|
|
6846
|
+
const seedRenderPass = commandEncoder.beginRenderPass({
|
|
6788
6847
|
id: "shader-pass-renderer-seed-source",
|
|
6789
6848
|
framebuffer: sourceFramebuffer,
|
|
6790
6849
|
clearColor: [0, 0, 0, 1],
|
|
@@ -6797,7 +6856,7 @@ var ShaderPassRenderer = class {
|
|
|
6797
6856
|
let frameSucceeded = false;
|
|
6798
6857
|
try {
|
|
6799
6858
|
for (const passRenderer of this.passRenderers) {
|
|
6800
|
-
passRenderer.initializeHistoryTargets(originalTexture, this.textureModel);
|
|
6859
|
+
passRenderer.initializeHistoryTargets(originalTexture, this.textureModel, commandEncoder);
|
|
6801
6860
|
for (const execution of passRenderer.subPassExecutions) {
|
|
6802
6861
|
const outputName = execution.output || "previous";
|
|
6803
6862
|
const outputFramebuffer = outputName === "previous" ? getNextPreviousFramebuffer(this.swapFramebuffers, previousFramebuffer) : passRenderer.getOutputFramebuffer(outputName);
|
|
@@ -6811,12 +6870,12 @@ var ShaderPassRenderer = class {
|
|
|
6811
6870
|
});
|
|
6812
6871
|
const resolvedUniforms = resolveExecutionUniforms(this.shaderInputs, execution, options.uniforms || {});
|
|
6813
6872
|
execution.subPassRenderer.prepare({
|
|
6814
|
-
commandEncoder
|
|
6873
|
+
commandEncoder,
|
|
6815
6874
|
bindings: resolvedBindings,
|
|
6816
6875
|
textureScale: calculateTextureScale(resolvedBindings["sourceTexture"] || previousTexture, outputTexture),
|
|
6817
6876
|
uniforms: resolvedUniforms
|
|
6818
6877
|
});
|
|
6819
|
-
const renderPass =
|
|
6878
|
+
const renderPass = commandEncoder.beginRenderPass({
|
|
6820
6879
|
id: "shader-pass-renderer-run-pass",
|
|
6821
6880
|
framebuffer: outputFramebuffer,
|
|
6822
6881
|
clearColor: [0, 0, 0, 1],
|
|
@@ -6879,7 +6938,7 @@ var PassRenderer = class {
|
|
|
6879
6938
|
renderTarget.writtenThisFrame = false;
|
|
6880
6939
|
}
|
|
6881
6940
|
}
|
|
6882
|
-
initializeHistoryTargets(originalTexture, textureModel) {
|
|
6941
|
+
initializeHistoryTargets(originalTexture, textureModel, commandEncoder) {
|
|
6883
6942
|
for (const renderTarget of Object.values(this.renderTargets)) {
|
|
6884
6943
|
if (renderTarget.spec.lifetime !== "history" || renderTarget.historyInitialized) {
|
|
6885
6944
|
continue;
|
|
@@ -6890,8 +6949,8 @@ var PassRenderer = class {
|
|
|
6890
6949
|
};
|
|
6891
6950
|
if (initialize === "original") {
|
|
6892
6951
|
textureModel.setProps({ backgroundTexture: originalTexture });
|
|
6893
|
-
textureModel.predraw(
|
|
6894
|
-
const renderPass =
|
|
6952
|
+
textureModel.predraw(commandEncoder);
|
|
6953
|
+
const renderPass = commandEncoder.beginRenderPass({
|
|
6895
6954
|
id: `${renderTarget.name}-initialize-history`,
|
|
6896
6955
|
framebuffer: historyFramebuffer,
|
|
6897
6956
|
clearColor: [0, 0, 0, 0],
|
|
@@ -6900,7 +6959,7 @@ var PassRenderer = class {
|
|
|
6900
6959
|
textureModel.draw(renderPass);
|
|
6901
6960
|
renderPass.end();
|
|
6902
6961
|
} else {
|
|
6903
|
-
const renderPass =
|
|
6962
|
+
const renderPass = commandEncoder.beginRenderPass({
|
|
6904
6963
|
id: `${renderTarget.name}-clear-history`,
|
|
6905
6964
|
framebuffer: historyFramebuffer,
|
|
6906
6965
|
clearColor: initialize.clearColor,
|
|
@@ -7168,7 +7227,8 @@ function createTargetResources(device, name, spec, targetSize) {
|
|
|
7168
7227
|
width: targetSize[0],
|
|
7169
7228
|
height: targetSize[1],
|
|
7170
7229
|
format: spec.format || device.preferredColorFormat,
|
|
7171
|
-
usage:
|
|
7230
|
+
usage: import_core25.Texture.SAMPLE | import_core25.Texture.RENDER | import_core25.Texture.COPY_SRC | import_core25.Texture.COPY_DST,
|
|
7231
|
+
...spec.sampler ? { sampler: spec.sampler } : {}
|
|
7172
7232
|
});
|
|
7173
7233
|
const framebuffer = device.createFramebuffer({
|
|
7174
7234
|
id: `${name}-framebuffer`,
|
|
@@ -7223,7 +7283,7 @@ function calculateTextureScale(sourceTexture, outputTexture) {
|
|
|
7223
7283
|
}
|
|
7224
7284
|
|
|
7225
7285
|
// dist/compute/computation.js
|
|
7226
|
-
var
|
|
7286
|
+
var import_core26 = require("@luma.gl/core");
|
|
7227
7287
|
var import_shadertools6 = require("@luma.gl/shadertools");
|
|
7228
7288
|
var import_types2 = require("@math.gl/types");
|
|
7229
7289
|
var LOG_DRAW_PRIORITY2 = 2;
|
|
@@ -7276,8 +7336,8 @@ var _Computation = class {
|
|
|
7276
7336
|
const modules = mergeShaderModules(this.props.modules, (_a = this.shaderInputs) == null ? void 0 : _a.getModules());
|
|
7277
7337
|
const defines = { ...resolvedPlugins.defines, ...this.props.defines };
|
|
7278
7338
|
this.props.shaderLayout = mergeShaderModuleBindingsIntoLayout(this.props.shaderLayout, modules) || null;
|
|
7279
|
-
this.pipelineFactory = props.pipelineFactory ||
|
|
7280
|
-
this.shaderFactory = props.shaderFactory ||
|
|
7339
|
+
this.pipelineFactory = props.pipelineFactory || import_core26.PipelineFactory.getDefaultPipelineFactory(this.device);
|
|
7340
|
+
this.shaderFactory = props.shaderFactory || import_core26.ShaderFactory.getDefaultShaderFactory(this.device);
|
|
7281
7341
|
const { source: source4, getUniforms: getUniforms2 } = this.props.shaderAssembler.assembleWGSLShader({
|
|
7282
7342
|
platformInfo,
|
|
7283
7343
|
...this.props,
|
|
@@ -7338,7 +7398,7 @@ var _Computation = class {
|
|
|
7338
7398
|
}
|
|
7339
7399
|
setShaderInputs(shaderInputs) {
|
|
7340
7400
|
this.shaderInputs = shaderInputs;
|
|
7341
|
-
this._uniformStore = new
|
|
7401
|
+
this._uniformStore = new import_core26.UniformStore(this.device, this.shaderInputs.modules);
|
|
7342
7402
|
for (const [moduleName, module2] of Object.entries(this.shaderInputs.modules)) {
|
|
7343
7403
|
if (shaderModuleHasUniforms(module2)) {
|
|
7344
7404
|
const uniformBuffer = this._uniformStore.getManagedUniformBuffer(moduleName);
|
|
@@ -7383,7 +7443,7 @@ var _Computation = class {
|
|
|
7383
7443
|
if (this._pipelineNeedsUpdate) {
|
|
7384
7444
|
let prevShader = null;
|
|
7385
7445
|
if (this.pipeline) {
|
|
7386
|
-
|
|
7446
|
+
import_core26.log.log(1, `Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)();
|
|
7387
7447
|
prevShader = this.shader;
|
|
7388
7448
|
}
|
|
7389
7449
|
this._pipelineNeedsUpdate = false;
|
|
@@ -7407,33 +7467,33 @@ var _Computation = class {
|
|
|
7407
7467
|
_lastLogTime = 0;
|
|
7408
7468
|
_logOpen = false;
|
|
7409
7469
|
_logDrawCallStart() {
|
|
7410
|
-
const logDrawTimeout =
|
|
7411
|
-
if (
|
|
7470
|
+
const logDrawTimeout = import_core26.log.level > 3 ? 0 : LOG_DRAW_TIMEOUT2;
|
|
7471
|
+
if (import_core26.log.level < 2 || Date.now() - this._lastLogTime < logDrawTimeout) {
|
|
7412
7472
|
return;
|
|
7413
7473
|
}
|
|
7414
7474
|
this._lastLogTime = Date.now();
|
|
7415
7475
|
this._logOpen = true;
|
|
7416
|
-
|
|
7476
|
+
import_core26.log.group(LOG_DRAW_PRIORITY2, `>>> DRAWING MODEL ${this.id}`, { collapsed: import_core26.log.level <= 2 })();
|
|
7417
7477
|
}
|
|
7418
7478
|
_logDrawCallEnd() {
|
|
7419
7479
|
if (this._logOpen) {
|
|
7420
7480
|
const uniformTable = this.shaderInputs.getDebugTable();
|
|
7421
|
-
|
|
7422
|
-
|
|
7481
|
+
import_core26.log.table(LOG_DRAW_PRIORITY2, uniformTable)();
|
|
7482
|
+
import_core26.log.groupEnd(LOG_DRAW_PRIORITY2)();
|
|
7423
7483
|
this._logOpen = false;
|
|
7424
7484
|
}
|
|
7425
7485
|
}
|
|
7426
7486
|
_drawCount = 0;
|
|
7427
7487
|
// TODO - fix typing of luma data types
|
|
7428
7488
|
_getBufferOrConstantValues(attribute, dataType) {
|
|
7429
|
-
const TypedArrayConstructor =
|
|
7430
|
-
const typedArray = attribute instanceof
|
|
7489
|
+
const TypedArrayConstructor = import_core26.dataTypeDecoder.getTypedArrayConstructor(dataType);
|
|
7490
|
+
const typedArray = attribute instanceof import_core26.Buffer ? new TypedArrayConstructor(attribute.debugData) : attribute;
|
|
7431
7491
|
return typedArray.toString();
|
|
7432
7492
|
}
|
|
7433
7493
|
};
|
|
7434
7494
|
var Computation = _Computation;
|
|
7435
7495
|
__publicField(Computation, "defaultProps", {
|
|
7436
|
-
...
|
|
7496
|
+
...import_core26.ComputePipeline.defaultProps,
|
|
7437
7497
|
id: "unnamed",
|
|
7438
7498
|
handle: void 0,
|
|
7439
7499
|
userData: {},
|
|
@@ -7461,7 +7521,7 @@ function getPlatformInfo2(device) {
|
|
|
7461
7521
|
}
|
|
7462
7522
|
|
|
7463
7523
|
// dist/modules/picking/picking-manager.js
|
|
7464
|
-
var
|
|
7524
|
+
var import_core27 = require("@luma.gl/core");
|
|
7465
7525
|
|
|
7466
7526
|
// dist/modules/picking/picking-uniforms.js
|
|
7467
7527
|
var DEFAULT_HIGHLIGHT_COLOR = [0, 1, 1, 1];
|
|
@@ -7712,13 +7772,13 @@ var _PickingManager = class {
|
|
|
7712
7772
|
format: "rgba8unorm",
|
|
7713
7773
|
width: 1,
|
|
7714
7774
|
height: 1,
|
|
7715
|
-
usage:
|
|
7775
|
+
usage: import_core27.Texture.RENDER_ATTACHMENT
|
|
7716
7776
|
});
|
|
7717
7777
|
const pickingTexture = this.device.createTexture({
|
|
7718
7778
|
format: "rg32sint",
|
|
7719
7779
|
width: 1,
|
|
7720
7780
|
height: 1,
|
|
7721
|
-
usage:
|
|
7781
|
+
usage: import_core27.Texture.RENDER_ATTACHMENT | import_core27.Texture.COPY_SRC
|
|
7722
7782
|
});
|
|
7723
7783
|
return this.device.createFramebuffer({
|
|
7724
7784
|
colorAttachments: [colorTexture, pickingTexture],
|
|
@@ -7730,7 +7790,7 @@ var _PickingManager = class {
|
|
|
7730
7790
|
format: "rgba8unorm",
|
|
7731
7791
|
width: 1,
|
|
7732
7792
|
height: 1,
|
|
7733
|
-
usage:
|
|
7793
|
+
usage: import_core27.Texture.RENDER_ATTACHMENT | import_core27.Texture.COPY_SRC
|
|
7734
7794
|
});
|
|
7735
7795
|
return this.device.createFramebuffer({
|
|
7736
7796
|
colorAttachments: [pickingTexture],
|
|
@@ -7754,7 +7814,7 @@ var _PickingManager = class {
|
|
|
7754
7814
|
const layout = pickTexture.computeMemoryLayout({ width: 1, height: 1 });
|
|
7755
7815
|
const readBuffer = this.device.createBuffer({
|
|
7756
7816
|
byteLength: layout.byteLength,
|
|
7757
|
-
usage:
|
|
7817
|
+
usage: import_core27.Buffer.COPY_DST | import_core27.Buffer.MAP_READ
|
|
7758
7818
|
});
|
|
7759
7819
|
try {
|
|
7760
7820
|
pickTexture.readBuffer({
|
|
@@ -7788,7 +7848,7 @@ var _PickingManager = class {
|
|
|
7788
7848
|
const layout = pickTexture.computeMemoryLayout({ width: 1, height: 1 });
|
|
7789
7849
|
const readBuffer = this.device.createBuffer({
|
|
7790
7850
|
byteLength: layout.byteLength,
|
|
7791
|
-
usage:
|
|
7851
|
+
usage: import_core27.Buffer.COPY_DST | import_core27.Buffer.MAP_READ
|
|
7792
7852
|
});
|
|
7793
7853
|
try {
|
|
7794
7854
|
pickTexture.readBuffer({
|