@luma.gl/engine 9.4.0 → 9.4.2
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/animation-loop/animation-loop.d.ts.map +1 -1
- package/dist/animation-loop/animation-loop.js +19 -6
- package/dist/animation-loop/animation-loop.js.map +1 -1
- package/dist/animation-loop/make-animation-loop.d.ts.map +1 -1
- package/dist/animation-loop/make-animation-loop.js +3 -1
- package/dist/animation-loop/make-animation-loop.js.map +1 -1
- package/dist/dist.dev.js +26 -9
- package/dist/dist.min.js +5 -5
- package/dist/index.cjs +26 -9
- package/dist/index.cjs.map +1 -1
- package/dist/model/model.d.ts +3 -2
- package/dist/model/model.d.ts.map +1 -1
- package/dist/model/model.js +9 -2
- package/dist/model/model.js.map +1 -1
- package/package.json +2 -2
- package/src/animation-loop/animation-loop.ts +20 -7
- package/src/animation-loop/make-animation-loop.ts +3 -1
- package/src/model/model.ts +10 -3
package/dist/index.cjs
CHANGED
|
@@ -1251,8 +1251,11 @@ var AnimationLoop = class _AnimationLoop {
|
|
|
1251
1251
|
this.destroy();
|
|
1252
1252
|
}
|
|
1253
1253
|
reportError(error) {
|
|
1254
|
-
this.props.onError(error);
|
|
1255
1254
|
this._error = error;
|
|
1255
|
+
this.props.onError(error);
|
|
1256
|
+
if (this.props.onError === _AnimationLoop.defaultAnimationLoopProps.onError && typeof window !== "undefined" && typeof ErrorEvent !== "undefined") {
|
|
1257
|
+
window.dispatchEvent(new ErrorEvent("error", { error, message: error.message }));
|
|
1258
|
+
}
|
|
1256
1259
|
}
|
|
1257
1260
|
/** Flags this animation loop as needing redraw */
|
|
1258
1261
|
setNeedsRedraw(reason) {
|
|
@@ -1318,14 +1321,15 @@ var AnimationLoop = class _AnimationLoop {
|
|
|
1318
1321
|
/** Stops a render loop if already running, finalizing */
|
|
1319
1322
|
stop() {
|
|
1320
1323
|
if (this._running) {
|
|
1321
|
-
|
|
1322
|
-
this.props.onFinalize(this.animationProps);
|
|
1323
|
-
}
|
|
1324
|
+
const animationProps = this.animationProps;
|
|
1324
1325
|
this._cancelAnimationFrame();
|
|
1325
1326
|
this._nextFramePromise = null;
|
|
1326
1327
|
this._resolveNextFrame = null;
|
|
1327
1328
|
this._running = false;
|
|
1328
1329
|
this._lastFrameTime = 0;
|
|
1330
|
+
if (animationProps) {
|
|
1331
|
+
this.props.onFinalize(animationProps);
|
|
1332
|
+
}
|
|
1329
1333
|
}
|
|
1330
1334
|
return this;
|
|
1331
1335
|
}
|
|
@@ -1415,8 +1419,14 @@ var AnimationLoop = class _AnimationLoop {
|
|
|
1415
1419
|
if (!this._running) {
|
|
1416
1420
|
return;
|
|
1417
1421
|
}
|
|
1418
|
-
|
|
1419
|
-
|
|
1422
|
+
try {
|
|
1423
|
+
this.redraw(time, animationFrame ?? null);
|
|
1424
|
+
this._requestAnimationFrame();
|
|
1425
|
+
} catch (error) {
|
|
1426
|
+
const renderError = error instanceof Error ? error : new Error(String(error));
|
|
1427
|
+
this.reportError(renderError);
|
|
1428
|
+
this.stop();
|
|
1429
|
+
}
|
|
1420
1430
|
}
|
|
1421
1431
|
// Called on each frame, can be overridden to call onRender multiple times
|
|
1422
1432
|
// to support e.g. stereoscopic rendering
|
|
@@ -1645,7 +1655,9 @@ function makeAnimationLoop(AnimationLoopTemplateCtor, props) {
|
|
|
1645
1655
|
} catch (error) {
|
|
1646
1656
|
console.error(error);
|
|
1647
1657
|
renderLoop = null;
|
|
1648
|
-
|
|
1658
|
+
const initializationError = error instanceof Error ? error : new Error(String(error));
|
|
1659
|
+
setError(animationProps.animationLoop.device, initializationError);
|
|
1660
|
+
animationProps.animationLoop.reportError(initializationError);
|
|
1649
1661
|
animationProps.animationLoop.stop();
|
|
1650
1662
|
return null;
|
|
1651
1663
|
}
|
|
@@ -2932,7 +2944,7 @@ var Model = class _Model {
|
|
|
2932
2944
|
instanceCount = 0;
|
|
2933
2945
|
/** Vertex count */
|
|
2934
2946
|
vertexCount;
|
|
2935
|
-
/** Indexed draw count override. Undefined
|
|
2947
|
+
/** Indexed draw count override. Undefined uses vertexCount, then the full bound index buffer. */
|
|
2936
2948
|
indexCount;
|
|
2937
2949
|
/** First vertex byte offset for WebGL indexed draws or first vertex for non-indexed draws. */
|
|
2938
2950
|
firstVertex;
|
|
@@ -2973,6 +2985,7 @@ var Model = class _Model {
|
|
|
2973
2985
|
_needsRedraw = "initializing";
|
|
2974
2986
|
_drawBlockedReason = false;
|
|
2975
2987
|
_destroyed = false;
|
|
2988
|
+
_vertexCountSet = false;
|
|
2976
2989
|
/** "Time" of last draw. Monotonically increasing timestamp */
|
|
2977
2990
|
_lastDrawTimestamp = -1;
|
|
2978
2991
|
_bindingTable = [];
|
|
@@ -2985,11 +2998,13 @@ var Model = class _Model {
|
|
|
2985
2998
|
constructor(device, props) {
|
|
2986
2999
|
var _a;
|
|
2987
3000
|
const defaultShaderAssembler = _Model.defaultProps.shaderAssembler;
|
|
3001
|
+
const vertexCountSet = props.vertexCount !== void 0;
|
|
2988
3002
|
this.props = {
|
|
2989
3003
|
..._Model.defaultProps,
|
|
2990
3004
|
...props,
|
|
2991
3005
|
shaderAssembler: props.shaderAssembler ?? (isShaderAssemblerForLanguage(defaultShaderAssembler, device.info.shadingLanguage) ? defaultShaderAssembler : import_shadertools3.ShaderAssembler.getDefaultShaderAssembler(device.info.shadingLanguage))
|
|
2992
3006
|
};
|
|
3007
|
+
this._vertexCountSet = vertexCountSet;
|
|
2993
3008
|
props = this.props;
|
|
2994
3009
|
this.id = props.id || uid("model");
|
|
2995
3010
|
this.device = device;
|
|
@@ -3190,7 +3205,7 @@ var Model = class _Model {
|
|
|
3190
3205
|
const syncBindings = this._getBindings(shaderLayout);
|
|
3191
3206
|
const syncBindGroups = this._getBindGroups(shaderLayout, syncBindings);
|
|
3192
3207
|
const { indexBuffer } = this.vertexArray;
|
|
3193
|
-
const indexCount = indexBuffer ? this.indexCount ?? indexBuffer.byteLength / (indexBuffer.indexType === "uint32" ? 4 : 2) : void 0;
|
|
3208
|
+
const indexCount = indexBuffer ? this.indexCount ?? (this._vertexCountSet ? this.vertexCount : indexBuffer.byteLength / (indexBuffer.indexType === "uint32" ? 4 : 2)) : void 0;
|
|
3194
3209
|
renderPass.setPipeline(this.pipeline);
|
|
3195
3210
|
renderPass.setBindings(syncBindGroups, {
|
|
3196
3211
|
_bindGroupCacheKeys: this._getBindGroupCacheKeys()
|
|
@@ -3311,6 +3326,7 @@ var Model = class _Model {
|
|
|
3311
3326
|
*/
|
|
3312
3327
|
setVertexCount(vertexCount) {
|
|
3313
3328
|
this.vertexCount = vertexCount;
|
|
3329
|
+
this._vertexCountSet = true;
|
|
3314
3330
|
this.setNeedsRedraw("vertexCount");
|
|
3315
3331
|
}
|
|
3316
3332
|
/** Updates the indexed draw count override. */
|
|
@@ -3544,6 +3560,7 @@ var Model = class _Model {
|
|
|
3544
3560
|
}
|
|
3545
3561
|
}
|
|
3546
3562
|
this.vertexCount = gpuGeometry.vertexCount;
|
|
3563
|
+
this._vertexCountSet = true;
|
|
3547
3564
|
this.setIndexBuffer(gpuGeometry.indices || null);
|
|
3548
3565
|
this.setAttributes(gpuGeometry.attributes, { disableWarnings: true });
|
|
3549
3566
|
this.setAttributes(attributes, { disableWarnings: this.props.disableWarnings });
|