@luma.gl/engine 9.3.6 → 9.4.0-alpha.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/animator.d.ts +42 -0
- package/dist/animation/animator.d.ts.map +1 -0
- package/dist/animation/animator.js +53 -0
- package/dist/animation/animator.js.map +1 -0
- package/dist/animation-loop/animation-loop.d.ts +14 -2
- package/dist/animation-loop/animation-loop.d.ts.map +1 -1
- package/dist/animation-loop/animation-loop.js +40 -22
- package/dist/animation-loop/animation-loop.js.map +1 -1
- package/dist/animation-loop/animation-props.d.ts +2 -0
- package/dist/animation-loop/animation-props.d.ts.map +1 -1
- package/dist/animation-loop/make-animation-loop.d.ts +1 -0
- package/dist/animation-loop/make-animation-loop.d.ts.map +1 -1
- package/dist/animation-loop/make-animation-loop.js +3 -0
- package/dist/animation-loop/make-animation-loop.js.map +1 -1
- package/dist/application-utils/load-file.d.ts +2 -0
- package/dist/application-utils/load-file.d.ts.map +1 -1
- package/dist/application-utils/load-file.js +31 -5
- package/dist/application-utils/load-file.js.map +1 -1
- package/dist/compute/buffer-transform.d.ts +5 -1
- package/dist/compute/buffer-transform.d.ts.map +1 -1
- package/dist/compute/buffer-transform.js +7 -3
- package/dist/compute/buffer-transform.js.map +1 -1
- package/dist/compute/computation.d.ts +20 -8
- package/dist/compute/computation.d.ts.map +1 -1
- package/dist/compute/computation.js +34 -13
- package/dist/compute/computation.js.map +1 -1
- package/dist/compute/swap.d.ts.map +1 -1
- package/dist/compute/swap.js +17 -0
- package/dist/compute/swap.js.map +1 -1
- package/dist/dist.dev.js +4190 -2014
- package/dist/dist.min.js +288 -42
- package/dist/dynamic-buffer/dynamic-buffer.d.ts +171 -0
- package/dist/dynamic-buffer/dynamic-buffer.d.ts.map +1 -0
- package/dist/dynamic-buffer/dynamic-buffer.js +316 -0
- package/dist/dynamic-buffer/dynamic-buffer.js.map +1 -0
- package/dist/dynamic-texture/dynamic-texture.d.ts +14 -1
- package/dist/dynamic-texture/dynamic-texture.d.ts.map +1 -1
- package/dist/dynamic-texture/dynamic-texture.js +31 -2
- package/dist/dynamic-texture/dynamic-texture.js.map +1 -1
- package/dist/dynamic-texture/texture-binding-source.d.ts +55 -0
- package/dist/dynamic-texture/texture-binding-source.d.ts.map +1 -0
- package/dist/dynamic-texture/texture-binding-source.js +55 -0
- package/dist/dynamic-texture/texture-binding-source.js.map +1 -0
- package/dist/dynamic-texture/texture-data.d.ts +5 -3
- package/dist/dynamic-texture/texture-data.d.ts.map +1 -1
- package/dist/dynamic-texture/texture-data.js +5 -0
- package/dist/dynamic-texture/texture-data.js.map +1 -1
- package/dist/dynamic-texture/video-texture.d.ts +101 -0
- package/dist/dynamic-texture/video-texture.d.ts.map +1 -0
- package/dist/dynamic-texture/video-texture.js +272 -0
- package/dist/dynamic-texture/video-texture.js.map +1 -0
- package/dist/geometries/cube-geometry.d.ts +1 -0
- package/dist/geometries/cube-geometry.d.ts.map +1 -1
- package/dist/geometries/cube-geometry.js +22 -2
- package/dist/geometries/cube-geometry.js.map +1 -1
- package/dist/geometries/plane-geometry.d.ts +10 -0
- package/dist/geometries/plane-geometry.d.ts.map +1 -1
- package/dist/geometries/plane-geometry.js.map +1 -1
- package/dist/geometry/geometry-utils.d.ts +36 -1
- package/dist/geometry/geometry-utils.d.ts.map +1 -1
- package/dist/geometry/geometry-utils.js +137 -2
- package/dist/geometry/geometry-utils.js.map +1 -1
- package/dist/geometry/geometry.d.ts +52 -33
- package/dist/geometry/geometry.d.ts.map +1 -1
- package/dist/geometry/geometry.js +70 -19
- package/dist/geometry/geometry.js.map +1 -1
- package/dist/geometry/gpu-geometry.d.ts +37 -4
- package/dist/geometry/gpu-geometry.d.ts.map +1 -1
- package/dist/geometry/gpu-geometry.js +44 -36
- package/dist/geometry/gpu-geometry.js.map +1 -1
- package/dist/index.cjs +4045 -1975
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +22 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -5
- package/dist/index.js.map +1 -1
- package/dist/material/material-factory.d.ts +2 -1
- package/dist/material/material-factory.d.ts.map +1 -1
- package/dist/material/material-factory.js.map +1 -1
- package/dist/material/material.d.ts +29 -10
- package/dist/material/material.d.ts.map +1 -1
- package/dist/material/material.js +84 -21
- package/dist/material/material.js.map +1 -1
- package/dist/model/model.d.ts +81 -23
- package/dist/model/model.d.ts.map +1 -1
- package/dist/model/model.js +312 -78
- package/dist/model/model.js.map +1 -1
- package/dist/model/split-uniforms-and-bindings.d.ts +5 -2
- package/dist/model/split-uniforms-and-bindings.d.ts.map +1 -1
- package/dist/model/split-uniforms-and-bindings.js.map +1 -1
- package/dist/models/billboard-texture-model.d.ts +5 -2
- package/dist/models/billboard-texture-model.d.ts.map +1 -1
- package/dist/models/billboard-texture-model.js +28 -10
- package/dist/models/billboard-texture-model.js.map +1 -1
- package/dist/modules/picking/index-color-picking.d.ts +24 -0
- package/dist/modules/picking/index-color-picking.d.ts.map +1 -0
- package/dist/modules/picking/index-color-picking.js +205 -0
- package/dist/modules/picking/index-color-picking.js.map +1 -0
- package/dist/modules/picking/index-picking.d.ts +3 -3
- package/dist/modules/picking/index-picking.d.ts.map +1 -1
- package/dist/modules/picking/index-picking.js +23 -6
- package/dist/modules/picking/index-picking.js.map +1 -1
- package/dist/modules/picking/picking-manager.d.ts +21 -0
- package/dist/modules/picking/picking-manager.d.ts.map +1 -1
- package/dist/modules/picking/picking-manager.js +100 -0
- package/dist/modules/picking/picking-manager.js.map +1 -1
- package/dist/modules/picking/picking-uniforms.d.ts +4 -4
- package/dist/modules/picking/picking-uniforms.d.ts.map +1 -1
- package/dist/modules/picking/picking-uniforms.js +3 -0
- package/dist/modules/picking/picking-uniforms.js.map +1 -1
- package/dist/modules/picking/picking.d.ts +5 -1
- package/dist/modules/picking/picking.d.ts.map +1 -1
- package/dist/modules/picking/picking.js +6 -0
- package/dist/modules/picking/picking.js.map +1 -1
- package/dist/passes/get-fragment-shader.js +4 -4
- package/dist/passes/shader-pass-renderer.d.ts +92 -25
- package/dist/passes/shader-pass-renderer.d.ts.map +1 -1
- package/dist/passes/shader-pass-renderer.js +467 -72
- package/dist/passes/shader-pass-renderer.js.map +1 -1
- package/dist/passes/texture-transform-module.d.ts +10 -0
- package/dist/passes/texture-transform-module.d.ts.map +1 -0
- package/dist/passes/texture-transform-module.js +50 -0
- package/dist/passes/texture-transform-module.js.map +1 -0
- 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/dist/shader-inputs.d.ts +33 -16
- package/dist/shader-inputs.d.ts.map +1 -1
- package/dist/shader-inputs.js +42 -12
- package/dist/shader-inputs.js.map +1 -1
- package/dist/utils/buffer-layout-helper.d.ts +0 -1
- package/dist/utils/buffer-layout-helper.d.ts.map +1 -1
- package/dist/utils/buffer-layout-helper.js +2 -11
- package/dist/utils/buffer-layout-helper.js.map +1 -1
- package/dist/utils/buffer-layout-order.d.ts.map +1 -1
- package/dist/utils/buffer-layout-order.js +4 -15
- package/dist/utils/buffer-layout-order.js.map +1 -1
- package/dist/utils/shader-module-utils.d.ts +2 -0
- package/dist/utils/shader-module-utils.d.ts.map +1 -1
- package/dist/utils/shader-module-utils.js +64 -3
- package/dist/utils/shader-module-utils.js.map +1 -1
- package/package.json +4 -4
- package/src/animation/animator.ts +79 -0
- package/src/animation-loop/animation-loop.ts +56 -22
- package/src/animation-loop/animation-props.ts +2 -0
- package/src/animation-loop/make-animation-loop.ts +4 -0
- package/src/application-utils/load-file.ts +38 -5
- package/src/compute/buffer-transform.ts +14 -5
- package/src/compute/computation.ts +53 -21
- package/src/compute/swap.ts +19 -0
- package/src/dynamic-buffer/dynamic-buffer.ts +453 -0
- package/src/dynamic-texture/dynamic-texture.ts +36 -3
- package/src/dynamic-texture/texture-binding-source.ts +94 -0
- package/src/dynamic-texture/texture-data.ts +12 -4
- package/src/dynamic-texture/video-texture.ts +334 -0
- package/src/geometries/cube-geometry.ts +24 -2
- package/src/geometries/plane-geometry.ts +10 -0
- package/src/geometry/geometry-utils.ts +209 -4
- package/src/geometry/geometry.ts +113 -36
- package/src/geometry/gpu-geometry.ts +61 -41
- package/src/index.ts +56 -14
- package/src/material/material-factory.ts +5 -1
- package/src/material/material.ts +123 -27
- package/src/model/model.ts +441 -102
- package/src/model/split-uniforms-and-bindings.ts +7 -3
- package/src/models/billboard-texture-model.ts +33 -12
- package/src/modules/picking/index-color-picking.ts +212 -0
- package/src/modules/picking/index-picking.ts +23 -6
- package/src/modules/picking/picking-manager.ts +141 -0
- package/src/modules/picking/picking-uniforms.ts +7 -4
- package/src/modules/picking/picking.ts +8 -0
- package/src/passes/get-fragment-shader.ts +4 -4
- package/src/passes/shader-pass-renderer.ts +692 -89
- package/src/passes/texture-transform-module.ts +52 -0
- 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/src/shader-inputs.ts +65 -17
- package/src/utils/buffer-layout-helper.ts +2 -14
- package/src/utils/buffer-layout-order.ts +14 -24
- package/src/utils/shader-module-utils.ts +109 -3
- package/dist/geometry/gpu-table.d.ts +0 -1
- package/dist/geometry/gpu-table.d.ts.map +0 -1
- package/dist/geometry/gpu-table.js +0 -46
- package/dist/geometry/gpu-table.js.map +0 -1
- package/src/dynamic-texture/texture-data.ts.disabled +0 -296
- package/src/geometry/gpu-table.ts +0 -45
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shader-inputs.js","sourceRoot":"","sources":["../src/shader-inputs.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAGpC,OAAO,EAAC,GAAG,EAAC,MAAM,eAAe,CAAC;AAClC,2HAA2H;AAC3H,OAAO,EACL,2BAA2B,EAG5B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAC,wBAAwB,EAAC,+CAA4C;
|
|
1
|
+
{"version":3,"file":"shader-inputs.js","sourceRoot":"","sources":["../src/shader-inputs.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAGpC,OAAO,EAAC,GAAG,EAAC,MAAM,eAAe,CAAC;AAClC,2HAA2H;AAC3H,OAAO,EACL,2BAA2B,EAG5B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAC,wBAAwB,EAAC,+CAA4C;AAsB7E;;;;;;GAMG;AACH,MAAM,OAAO,YAAY;IAKvB,OAAO,GAAkC;QACvC,eAAe,EAAE,KAAK;KACvB,CAAC;IAEF,kEAAkE;IAClE,yBAAyB;IACzB,OAAO,CAA4D;IAEnE,gDAAgD;IAChD,cAAc,CAAuE;IACrF,gDAAgD;IAChD,cAAc,CAAiE;IAC/E,6EAA6E;IAC7E,cAAc,GAAuC,EAAE,CAAC;IACxD,sCAAsC;IACtC,qEAAqE;IAErE;;;;OAIG;IACH;IACE,yBAAyB;IACzB,OAAyD,EACzD,OAA6B;QAE7B,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAErC,oCAAoC;QACpC,MAAM,eAAe,GAAG,2BAA2B,CACjD,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,oCAAoC,CAAC,CACpE,CAAC;QACF,KAAK,MAAM,cAAc,IAAI,eAAe,EAAE,CAAC;YAC7C,aAAa;YACb,OAAO,CAAC,cAAc,CAAC,IAAI,CAA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M,KAAK,CAAC,IAAI,OAAO,KAAK,CAAC,CAAC,CAAC,KAAK,QAAQ,CAAC,CAAC,CAC/E,CAAC;AACJ,CAAC;AAED,SAAS,oBAAoB,CAC3B,KAAc;IAEd,OAAO,CACL,OAAO,CAAC,KAAK,CAAC;QACd,OAAO,KAAK,KAAK,QAAQ;QACzB,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QACrB,CAAC,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,CAC3B,CAAC;AACJ,CAAC;AAED,SAAS,oCAAoC,CAC3C,MAAsC;IAEtC,OAAO,OAAO,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;AACvC,CAAC"}
|
|
@@ -7,6 +7,5 @@ export declare class BufferLayoutHelper {
|
|
|
7
7
|
/** Get attribute names from a BufferLayout */
|
|
8
8
|
getAttributeNamesForBuffer(bufferLayout: BufferLayout): string[];
|
|
9
9
|
mergeBufferLayouts(bufferLayouts1: BufferLayout[], bufferLayouts2: BufferLayout[]): BufferLayout[];
|
|
10
|
-
getBufferIndex(bufferName: string): number;
|
|
11
10
|
}
|
|
12
11
|
//# sourceMappingURL=buffer-layout-helper.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buffer-layout-helper.d.ts","sourceRoot":"","sources":["../../src/utils/buffer-layout-helper.ts"],"names":[],"mappings":"AAIA,OAAO,
|
|
1
|
+
{"version":3,"file":"buffer-layout-helper.d.ts","sourceRoot":"","sources":["../../src/utils/buffer-layout-helper.ts"],"names":[],"mappings":"AAIA,OAAO,EAAgC,KAAK,YAAY,EAAC,MAAM,eAAe,CAAC;AAE/E,4FAA4F;AAC5F,qBAAa,kBAAkB;IAC7B,aAAa,EAAE,YAAY,EAAE,CAAC;gBAElB,aAAa,EAAE,YAAY,EAAE;IAIzC,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,GAAG,IAAI;IAIlD,8CAA8C;IAC9C,0BAA0B,CAAC,YAAY,EAAE,YAAY,GAAG,MAAM,EAAE;IAIhE,kBAAkB,CAChB,cAAc,EAAE,YAAY,EAAE,EAC9B,cAAc,EAAE,YAAY,EAAE,GAC7B,YAAY,EAAE;CAYlB"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// luma.gl
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
|
-
import {
|
|
4
|
+
import { getBufferLayoutAttributeNames } from '@luma.gl/core';
|
|
5
5
|
/** BufferLayoutHelper is a helper class that should not be used directly by applications */
|
|
6
6
|
export class BufferLayoutHelper {
|
|
7
7
|
bufferLayouts;
|
|
@@ -13,9 +13,7 @@ export class BufferLayoutHelper {
|
|
|
13
13
|
}
|
|
14
14
|
/** Get attribute names from a BufferLayout */
|
|
15
15
|
getAttributeNamesForBuffer(bufferLayout) {
|
|
16
|
-
return bufferLayout
|
|
17
|
-
? bufferLayout.attributes?.map(layout => layout.attribute)
|
|
18
|
-
: [bufferLayout.name];
|
|
16
|
+
return getBufferLayoutAttributeNames(bufferLayout);
|
|
19
17
|
}
|
|
20
18
|
mergeBufferLayouts(bufferLayouts1, bufferLayouts2) {
|
|
21
19
|
const mergedLayouts = [...bufferLayouts1];
|
|
@@ -30,12 +28,5 @@ export class BufferLayoutHelper {
|
|
|
30
28
|
}
|
|
31
29
|
return mergedLayouts;
|
|
32
30
|
}
|
|
33
|
-
getBufferIndex(bufferName) {
|
|
34
|
-
const bufferIndex = this.bufferLayouts.findIndex(layout => layout.name === bufferName);
|
|
35
|
-
if (bufferIndex === -1) {
|
|
36
|
-
log.warn(`BufferLayout: Missing buffer for "${bufferName}".`)();
|
|
37
|
-
}
|
|
38
|
-
return bufferIndex;
|
|
39
|
-
}
|
|
40
31
|
}
|
|
41
32
|
//# sourceMappingURL=buffer-layout-helper.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buffer-layout-helper.js","sourceRoot":"","sources":["../../src/utils/buffer-layout-helper.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAEpC,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"buffer-layout-helper.js","sourceRoot":"","sources":["../../src/utils/buffer-layout-helper.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAEpC,OAAO,EAAC,6BAA6B,EAAoB,MAAM,eAAe,CAAC;AAE/E,4FAA4F;AAC5F,MAAM,OAAO,kBAAkB;IAC7B,aAAa,CAAiB;IAE9B,YAAY,aAA6B;QACvC,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;IACrC,CAAC;IAED,eAAe,CAAC,IAAY;QAC1B,OAAO,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,IAAI,CAAC;IACzE,CAAC;IAED,8CAA8C;IAC9C,0BAA0B,CAAC,YAA0B;QACnD,OAAO,6BAA6B,CAAC,YAAY,CAAC,CAAC;IACrD,CAAC;IAED,kBAAkB,CAChB,cAA8B,EAC9B,cAA8B;QAE9B,MAAM,aAAa,GAAG,CAAC,GAAG,cAAc,CAAC,CAAC;QAC1C,KAAK,MAAM,SAAS,IAAI,cAAc,EAAE,CAAC;YACvC,MAAM,KAAK,GAAG,aAAa,CAAC,SAAS,CAAC,UAAU,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,KAAK,SAAS,CAAC,IAAI,CAAC,CAAC;YACxF,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;gBACd,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YAChC,CAAC;iBAAM,CAAC;gBACN,aAAa,CAAC,KAAK,CAAC,GAAG,SAAS,CAAC;YACnC,CAAC;QACH,CAAC;QACD,OAAO,aAAa,CAAC;IACvB,CAAC;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buffer-layout-order.d.ts","sourceRoot":"","sources":["../../src/utils/buffer-layout-order.ts"],"names":[],"mappings":"AAIA,OAAO,
|
|
1
|
+
{"version":3,"file":"buffer-layout-order.d.ts","sourceRoot":"","sources":["../../src/utils/buffer-layout-order.ts"],"names":[],"mappings":"AAIA,OAAO,EAIL,KAAK,YAAY,EACjB,KAAK,YAAY,EAClB,MAAM,eAAe,CAAC;AAEvB,wBAAgB,yCAAyC,CACvD,YAAY,EAAE,YAAY,EAC1B,YAAY,EAAE,YAAY,EAAE,GAC3B,YAAY,EAAE,CAgBhB"}
|
|
@@ -1,24 +1,13 @@
|
|
|
1
1
|
// luma.gl
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
|
-
|
|
5
|
-
let minLocation = Infinity;
|
|
6
|
-
for (const name of attributeNames) {
|
|
7
|
-
const location = shaderLayoutMap[name];
|
|
8
|
-
if (location !== undefined) {
|
|
9
|
-
minLocation = Math.min(minLocation, location);
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
return minLocation;
|
|
13
|
-
}
|
|
4
|
+
import { getBufferLayoutAttributeNames, getMinimumAttributeLocation, getShaderAttributeLocationMap } from '@luma.gl/core';
|
|
14
5
|
export function sortedBufferLayoutByShaderSourceLocations(shaderLayout, bufferLayout) {
|
|
15
|
-
const shaderLayoutMap =
|
|
6
|
+
const shaderLayoutMap = getShaderAttributeLocationMap(shaderLayout);
|
|
16
7
|
const sortedLayout = bufferLayout.slice();
|
|
17
8
|
sortedLayout.sort((a, b) => {
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
const minLocationA = getMinLocation(attributeNamesA, shaderLayoutMap);
|
|
21
|
-
const minLocationB = getMinLocation(attributeNamesB, shaderLayoutMap);
|
|
9
|
+
const minLocationA = getMinimumAttributeLocation(getBufferLayoutAttributeNames(a).map(attributeName => shaderLayoutMap[attributeName]));
|
|
10
|
+
const minLocationB = getMinimumAttributeLocation(getBufferLayoutAttributeNames(b).map(attributeName => shaderLayoutMap[attributeName]));
|
|
22
11
|
return minLocationA - minLocationB;
|
|
23
12
|
});
|
|
24
13
|
return sortedLayout;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buffer-layout-order.js","sourceRoot":"","sources":["../../src/utils/buffer-layout-order.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;
|
|
1
|
+
{"version":3,"file":"buffer-layout-order.js","sourceRoot":"","sources":["../../src/utils/buffer-layout-order.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAEpC,OAAO,EACL,6BAA6B,EAC7B,2BAA2B,EAC3B,6BAA6B,EAG9B,MAAM,eAAe,CAAC;AAEvB,MAAM,UAAU,yCAAyC,CACvD,YAA0B,EAC1B,YAA4B;IAE5B,MAAM,eAAe,GAAG,6BAA6B,CAAC,YAAY,CAAC,CAAC;IAEpE,MAAM,YAAY,GAAG,YAAY,CAAC,KAAK,EAAE,CAAC;IAC1C,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QACzB,MAAM,YAAY,GAAG,2BAA2B,CAC9C,6BAA6B,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,CAAC,eAAe,CAAC,aAAa,CAAC,CAAC,CACtF,CAAC;QACF,MAAM,YAAY,GAAG,2BAA2B,CAC9C,6BAA6B,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,CAAC,eAAe,CAAC,aAAa,CAAC,CAAC,CACtF,CAAC;QAEF,OAAO,YAAY,GAAG,YAAY,CAAC;IACrC,CAAC,CAAC,CAAC;IAEH,OAAO,YAAY,CAAC;AACtB,CAAC"}
|
|
@@ -2,6 +2,8 @@ import type { ComputeShaderLayout, ShaderLayout } from '@luma.gl/core';
|
|
|
2
2
|
import type { ShaderModule } from '@luma.gl/shadertools';
|
|
3
3
|
type AnyShaderLayout = ShaderLayout | ComputeShaderLayout;
|
|
4
4
|
export declare function mergeShaderModuleBindingsIntoLayout<TShaderLayout extends AnyShaderLayout>(shaderLayout: TShaderLayout | null | undefined, modules: ShaderModule[]): TShaderLayout | null | undefined;
|
|
5
|
+
export declare function mergeInferredShaderLayout(shaderLayout: ShaderLayout | null | undefined, inferredShaderLayout: ShaderLayout | null | undefined, inferredAttributeNames?: readonly string[]): ShaderLayout | null | undefined;
|
|
5
6
|
export declare function shaderModuleHasUniforms(module: ShaderModule): boolean;
|
|
7
|
+
export declare function mergeShaderModules(explicitModules: ShaderModule[] | undefined, shaderInputModules: ShaderModule[] | undefined): ShaderModule[];
|
|
6
8
|
export {};
|
|
7
9
|
//# sourceMappingURL=shader-module-utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shader-module-utils.d.ts","sourceRoot":"","sources":["../../src/utils/shader-module-utils.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,mBAAmB,EAAE,YAAY,EAAC,MAAM,eAAe,CAAC;AACrE,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,sBAAsB,CAAC;AAEvD,KAAK,eAAe,GAAG,YAAY,GAAG,mBAAmB,CAAC;AAE1D,wBAAgB,mCAAmC,CAAC,aAAa,SAAS,eAAe,EACvF,YAAY,EAAE,aAAa,GAAG,IAAI,GAAG,SAAS,EAC9C,OAAO,EAAE,YAAY,EAAE,GACtB,aAAa,GAAG,IAAI,GAAG,SAAS,
|
|
1
|
+
{"version":3,"file":"shader-module-utils.d.ts","sourceRoot":"","sources":["../../src/utils/shader-module-utils.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,mBAAmB,EAAE,YAAY,EAAC,MAAM,eAAe,CAAC;AACrE,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,sBAAsB,CAAC;AAEvD,KAAK,eAAe,GAAG,YAAY,GAAG,mBAAmB,CAAC;AAE1D,wBAAgB,mCAAmC,CAAC,aAAa,SAAS,eAAe,EACvF,YAAY,EAAE,aAAa,GAAG,IAAI,GAAG,SAAS,EAC9C,OAAO,EAAE,YAAY,EAAE,GACtB,aAAa,GAAG,IAAI,GAAG,SAAS,CA+BlC;AAED,wBAAgB,yBAAyB,CACvC,YAAY,EAAE,YAAY,GAAG,IAAI,GAAG,SAAS,EAC7C,oBAAoB,EAAE,YAAY,GAAG,IAAI,GAAG,SAAS,EACrD,sBAAsB,GAAE,SAAS,MAAM,EAAO,GAC7C,YAAY,GAAG,IAAI,GAAG,SAAS,CAoBjC;AAED,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAErE;AAED,wBAAgB,kBAAkB,CAChC,eAAe,EAAE,YAAY,EAAE,GAAG,SAAS,EAC3C,kBAAkB,EAAE,YAAY,EAAE,GAAG,SAAS,GAC7C,YAAY,EAAE,CAYhB"}
|
|
@@ -19,14 +19,43 @@ export function mergeShaderModuleBindingsIntoLayout(shaderLayout, modules) {
|
|
|
19
19
|
if (binding?.group === 0) {
|
|
20
20
|
binding.group = bindingLayout.group;
|
|
21
21
|
}
|
|
22
|
+
if (binding && bindingLayout.visibility !== undefined) {
|
|
23
|
+
binding.visibility = bindingLayout.visibility;
|
|
24
|
+
}
|
|
22
25
|
}
|
|
23
26
|
}
|
|
24
27
|
}
|
|
25
28
|
return mergedLayout;
|
|
26
29
|
}
|
|
30
|
+
export function mergeInferredShaderLayout(shaderLayout, inferredShaderLayout, inferredAttributeNames = []) {
|
|
31
|
+
if (!shaderLayout) {
|
|
32
|
+
return inferredShaderLayout;
|
|
33
|
+
}
|
|
34
|
+
if (!inferredShaderLayout) {
|
|
35
|
+
return shaderLayout;
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
...shaderLayout,
|
|
39
|
+
attributes: shaderLayout.attributes.length
|
|
40
|
+
? mergeAttributeLayouts(shaderLayout.attributes, inferredShaderLayout.attributes.filter(attribute => inferredAttributeNames.includes(attribute.name)))
|
|
41
|
+
: inferredShaderLayout.attributes,
|
|
42
|
+
bindings: mergeBindingLayouts(shaderLayout.bindings, inferredShaderLayout.bindings)
|
|
43
|
+
};
|
|
44
|
+
}
|
|
27
45
|
export function shaderModuleHasUniforms(module) {
|
|
28
46
|
return Boolean(module.uniformTypes && !isObjectEmpty(module.uniformTypes));
|
|
29
47
|
}
|
|
48
|
+
export function mergeShaderModules(explicitModules, shaderInputModules) {
|
|
49
|
+
const modules = [];
|
|
50
|
+
const moduleNames = new Set();
|
|
51
|
+
for (const module of [...(explicitModules || []), ...(shaderInputModules || [])]) {
|
|
52
|
+
if (!moduleNames.has(module.name)) {
|
|
53
|
+
moduleNames.add(module.name);
|
|
54
|
+
modules.push(module);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return modules;
|
|
58
|
+
}
|
|
30
59
|
/** Returns binding-name aliases that should share the module-declared bind group. */
|
|
31
60
|
function getRelatedBindingNames(bindingName) {
|
|
32
61
|
const bindingNames = new Set([bindingName, `${bindingName}Uniforms`]);
|
|
@@ -36,11 +65,43 @@ function getRelatedBindingNames(bindingName) {
|
|
|
36
65
|
return [...bindingNames];
|
|
37
66
|
}
|
|
38
67
|
function isObjectEmpty(obj) {
|
|
39
|
-
|
|
40
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
41
|
-
for (const key in obj) {
|
|
68
|
+
for (const _key in obj) {
|
|
42
69
|
return false;
|
|
43
70
|
}
|
|
44
71
|
return true;
|
|
45
72
|
}
|
|
73
|
+
function mergeBindingLayouts(explicitBindings, inferredBindings) {
|
|
74
|
+
const mergedBindings = explicitBindings.map(binding => ({ ...binding }));
|
|
75
|
+
const explicitBindingNames = new Set(explicitBindings.map(binding => binding.name));
|
|
76
|
+
const explicitBindingLocations = new Set(explicitBindings.map(binding => `${binding.group}:${binding.location}`));
|
|
77
|
+
for (const inferredBinding of inferredBindings) {
|
|
78
|
+
const inferredBindingLocation = `${inferredBinding.group}:${inferredBinding.location}`;
|
|
79
|
+
if (!explicitBindingNames.has(inferredBinding.name) &&
|
|
80
|
+
!explicitBindingLocations.has(inferredBindingLocation)) {
|
|
81
|
+
mergedBindings.push({ ...inferredBinding });
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return mergedBindings;
|
|
85
|
+
}
|
|
86
|
+
function mergeAttributeLayouts(explicitAttributes, inferredAttributes) {
|
|
87
|
+
const mergedAttributes = explicitAttributes.map(attribute => ({ ...attribute }));
|
|
88
|
+
const explicitAttributesByName = new Map(explicitAttributes.map(attribute => [attribute.name, attribute]));
|
|
89
|
+
const explicitAttributesByLocation = new Map(explicitAttributes.map(attribute => [attribute.location, attribute]));
|
|
90
|
+
for (const inferredAttribute of inferredAttributes) {
|
|
91
|
+
const explicitByName = explicitAttributesByName.get(inferredAttribute.name);
|
|
92
|
+
if (explicitByName) {
|
|
93
|
+
if (explicitByName.type !== inferredAttribute.type ||
|
|
94
|
+
explicitByName.location !== inferredAttribute.location) {
|
|
95
|
+
throw new Error(`Shader attribute "${inferredAttribute.name}" conflicts with its inferred type or location`);
|
|
96
|
+
}
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
const explicitByLocation = explicitAttributesByLocation.get(inferredAttribute.location);
|
|
100
|
+
if (explicitByLocation) {
|
|
101
|
+
throw new Error(`Shader attributes "${explicitByLocation.name}" and "${inferredAttribute.name}" both use location ${inferredAttribute.location}`);
|
|
102
|
+
}
|
|
103
|
+
mergedAttributes.push({ ...inferredAttribute });
|
|
104
|
+
}
|
|
105
|
+
return mergedAttributes;
|
|
106
|
+
}
|
|
46
107
|
//# sourceMappingURL=shader-module-utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shader-module-utils.js","sourceRoot":"","sources":["../../src/utils/shader-module-utils.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAOpC,MAAM,UAAU,mCAAmC,CACjD,YAA8C,EAC9C,OAAuB;IAEvB,IAAI,CAAC,YAAY,IAAI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I,cAAc,EAAE,CAAC;YACnB,IACE,cAAc,CAAC,IAAI,KAAK,iBAAiB,CAAC,IAAI;gBAC9C,cAAc,CAAC,QAAQ,KAAK,iBAAiB,CAAC,QAAQ,EACtD,CAAC;gBACD,MAAM,IAAI,KAAK,CACb,qBAAqB,iBAAiB,CAAC,IAAI,gDAAgD,CAC5F,CAAC;YACJ,CAAC;YACD,SAAS;QACX,CAAC;QAED,MAAM,kBAAkB,GAAG,4BAA4B,CAAC,GAAG,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC;QACxF,IAAI,kBAAkB,EAAE,CAAC;YACvB,MAAM,IAAI,KAAK,CACb,sBAAsB,kBAAkB,CAAC,IAAI,UAAU,iBAAiB,CAAC,IAAI,uBAAuB,iBAAiB,CAAC,QAAQ,EAAE,CACjI,CAAC;QACJ,CAAC;QAED,gBAAgB,CAAC,IAAI,CAAC,EAAC,GAAG,iBAAiB,EAAC,CAAC,CAAC;IAChD,CAAC;IAED,OAAO,gBAAgB,CAAC;AAC1B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@luma.gl/engine",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.4.0-alpha.2",
|
|
4
4
|
"description": "3D Engine Components for luma.gl",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
"prepublishOnly": "npm run build-minified-bundle && npm run build-dev-bundle"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
|
-
"@luma.gl/core": "~9.
|
|
44
|
-
"@luma.gl/shadertools": "~9.
|
|
43
|
+
"@luma.gl/core": "~9.4.0-alpha.1",
|
|
44
|
+
"@luma.gl/shadertools": "~9.4.0-alpha.1"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@math.gl/core": "^4.1.0",
|
|
@@ -49,5 +49,5 @@
|
|
|
49
49
|
"@probe.gl/log": "^4.1.1",
|
|
50
50
|
"@probe.gl/stats": "^4.1.1"
|
|
51
51
|
},
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "90db20dd6c21a47e9b880c0e30d93bd5dd041c9e"
|
|
53
53
|
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import {log} from '@luma.gl/core';
|
|
6
|
+
|
|
7
|
+
/** Construction props shared by all animation clip controllers. */
|
|
8
|
+
export type AnimationClipControllerProps = {
|
|
9
|
+
/** Application-visible clip name. */
|
|
10
|
+
name?: string;
|
|
11
|
+
/** Start time in seconds relative to wall-clock playback time. */
|
|
12
|
+
startTime?: number;
|
|
13
|
+
/** Whether playback is active. */
|
|
14
|
+
playing?: boolean;
|
|
15
|
+
/** Playback speed multiplier. */
|
|
16
|
+
speed?: number;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
/** Generic playback controller for one animation clip. */
|
|
20
|
+
export abstract class AnimationClipController {
|
|
21
|
+
/** Application-visible clip name. */
|
|
22
|
+
name: string;
|
|
23
|
+
/** Whether playback is currently enabled. */
|
|
24
|
+
playing: boolean = true;
|
|
25
|
+
/** Playback speed multiplier. */
|
|
26
|
+
speed: number = 1;
|
|
27
|
+
/** Start time in seconds relative to wall-clock playback time. */
|
|
28
|
+
startTime: number = 0;
|
|
29
|
+
|
|
30
|
+
constructor(props: AnimationClipControllerProps = {}) {
|
|
31
|
+
this.name = props.name || 'unnamed';
|
|
32
|
+
Object.assign(this, props);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** Advances the clip to the supplied wall-clock time in milliseconds. */
|
|
36
|
+
setTime(timeMs: number): void {
|
|
37
|
+
if (!this.playing) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const absoluteTimeSeconds = timeMs / 1000;
|
|
42
|
+
const localTimeSeconds = (absoluteTimeSeconds - this.startTime) * this.speed;
|
|
43
|
+
this.applyTime(localTimeSeconds);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** Applies the resolved local clip time in seconds. */
|
|
47
|
+
protected abstract applyTime(localTimeSeconds: number): void;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** Generic manager for a set of time-driven animation clips. */
|
|
51
|
+
export class Animator<TClip extends AnimationClipController> {
|
|
52
|
+
/** Managed clip list. */
|
|
53
|
+
readonly clips: TClip[];
|
|
54
|
+
/** Compatibility alias for clip list. */
|
|
55
|
+
readonly animations: TClip[];
|
|
56
|
+
|
|
57
|
+
constructor(clips: TClip[]) {
|
|
58
|
+
this.clips = clips;
|
|
59
|
+
this.animations = clips;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** @deprecated Use .setTime(). */
|
|
63
|
+
animate(timeMs: number): void {
|
|
64
|
+
log.warn(
|
|
65
|
+
`${this.constructor.name}#animate is deprecated. Use ${this.constructor.name}#setTime instead`
|
|
66
|
+
)();
|
|
67
|
+
this.setTime(timeMs);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** Advances every clip to the supplied wall-clock time in milliseconds. */
|
|
71
|
+
setTime(timeMs: number): void {
|
|
72
|
+
this.clips.forEach(clip => clip.setTime(timeMs));
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** Returns the managed animation clips. */
|
|
76
|
+
getAnimations(): TClip[] {
|
|
77
|
+
return this.clips;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -14,6 +14,20 @@ import {Stats, Stat} from '@probe.gl/stats';
|
|
|
14
14
|
let statIdCounter = 0;
|
|
15
15
|
const ANIMATION_LOOP_STATS = 'Animation Loop';
|
|
16
16
|
|
|
17
|
+
/** Experimental v10 callback shape for browser or custom animation frames. */
|
|
18
|
+
export type AnimationFrameCallback = (time: DOMHighResTimeStamp, animationFrame?: unknown) => void;
|
|
19
|
+
|
|
20
|
+
/** Experimental v10 work-in-progress animation frame source. */
|
|
21
|
+
export interface AnimationFrameProvider {
|
|
22
|
+
requestAnimationFrame(callback: AnimationFrameCallback): number;
|
|
23
|
+
cancelAnimationFrame(animationFrameId: number): void;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const defaultAnimationFrameProvider: AnimationFrameProvider = {
|
|
27
|
+
requestAnimationFrame: callback => requestAnimationFramePolyfill(callback),
|
|
28
|
+
cancelAnimationFrame: animationFrameId => cancelAnimationFramePolyfill(animationFrameId)
|
|
29
|
+
};
|
|
30
|
+
|
|
17
31
|
/** AnimationLoop properties */
|
|
18
32
|
export type AnimationLoopProps = {
|
|
19
33
|
device: Device | Promise<Device>;
|
|
@@ -28,11 +42,15 @@ export type AnimationLoopProps = {
|
|
|
28
42
|
|
|
29
43
|
// view parameters - TODO move to CanvasContext?
|
|
30
44
|
autoResizeViewport?: boolean;
|
|
45
|
+
/** Experimental v10 work-in-progress frame source. */
|
|
46
|
+
animationFrameProvider?: AnimationFrameProvider;
|
|
31
47
|
};
|
|
32
48
|
|
|
33
49
|
export type MutableAnimationLoopProps = {
|
|
34
50
|
// view parameters
|
|
35
51
|
autoResizeViewport?: boolean;
|
|
52
|
+
/** Experimental v10 work-in-progress frame source. */
|
|
53
|
+
animationFrameProvider?: AnimationFrameProvider;
|
|
36
54
|
};
|
|
37
55
|
|
|
38
56
|
/** Convenient animation loop */
|
|
@@ -44,12 +62,16 @@ export class AnimationLoop {
|
|
|
44
62
|
onInitialize: async () => null,
|
|
45
63
|
onRender: () => {},
|
|
46
64
|
onFinalize: () => {},
|
|
47
|
-
onError: error =>
|
|
65
|
+
onError: error => {
|
|
66
|
+
// biome-ignore lint/suspicious/noConsole: default fallback error reporting for app loops.
|
|
67
|
+
console.error(error);
|
|
68
|
+
},
|
|
48
69
|
|
|
49
70
|
stats: undefined!,
|
|
50
71
|
|
|
51
72
|
// view parameters
|
|
52
|
-
autoResizeViewport: false
|
|
73
|
+
autoResizeViewport: false,
|
|
74
|
+
animationFrameProvider: defaultAnimationFrameProvider
|
|
53
75
|
} as const satisfies Readonly<Required<AnimationLoopProps>>;
|
|
54
76
|
|
|
55
77
|
device: Device | null = null;
|
|
@@ -96,7 +118,10 @@ export class AnimationLoop {
|
|
|
96
118
|
this.cpuTime = this.stats.get('CPU Time');
|
|
97
119
|
this.gpuTime = this.stats.get('GPU Time');
|
|
98
120
|
|
|
99
|
-
this.setProps({
|
|
121
|
+
this.setProps({
|
|
122
|
+
autoResizeViewport: props.autoResizeViewport,
|
|
123
|
+
animationFrameProvider: props.animationFrameProvider
|
|
124
|
+
});
|
|
100
125
|
|
|
101
126
|
// Bind methods
|
|
102
127
|
this.start = this.start.bind(this);
|
|
@@ -139,6 +164,19 @@ export class AnimationLoop {
|
|
|
139
164
|
if ('autoResizeViewport' in props) {
|
|
140
165
|
this.props.autoResizeViewport = props.autoResizeViewport || false;
|
|
141
166
|
}
|
|
167
|
+
if ('animationFrameProvider' in props) {
|
|
168
|
+
const animationFrameProvider = props.animationFrameProvider || defaultAnimationFrameProvider;
|
|
169
|
+
if (animationFrameProvider !== this.props.animationFrameProvider) {
|
|
170
|
+
const animationFrameWasScheduled = this._animationFrameId !== null;
|
|
171
|
+
if (animationFrameWasScheduled) {
|
|
172
|
+
this._cancelAnimationFrame();
|
|
173
|
+
}
|
|
174
|
+
this.props.animationFrameProvider = animationFrameProvider;
|
|
175
|
+
if (animationFrameWasScheduled) {
|
|
176
|
+
this._requestAnimationFrame();
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
142
180
|
return this;
|
|
143
181
|
}
|
|
144
182
|
|
|
@@ -205,7 +243,7 @@ export class AnimationLoop {
|
|
|
205
243
|
}
|
|
206
244
|
|
|
207
245
|
/** Explicitly draw a frame */
|
|
208
|
-
redraw(time?: number): this {
|
|
246
|
+
redraw(time?: number, animationFrame: unknown | null = null): this {
|
|
209
247
|
if (this.device?.isLost || this._error) {
|
|
210
248
|
return this;
|
|
211
249
|
}
|
|
@@ -213,6 +251,9 @@ export class AnimationLoop {
|
|
|
213
251
|
this._beginFrameTimers(time);
|
|
214
252
|
|
|
215
253
|
this._setupFrame();
|
|
254
|
+
if (this.animationProps) {
|
|
255
|
+
this.animationProps.animationFrame = animationFrame;
|
|
256
|
+
}
|
|
216
257
|
this._updateAnimationProps();
|
|
217
258
|
|
|
218
259
|
this._renderFrame(this._getAnimationProps());
|
|
@@ -298,13 +339,9 @@ export class AnimationLoop {
|
|
|
298
339
|
return;
|
|
299
340
|
}
|
|
300
341
|
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
// if (this.display && this.display.requestAnimationFrame) {
|
|
305
|
-
// this._animationFrameId = this.display.requestAnimationFrame(this._animationFrame.bind(this));
|
|
306
|
-
// }
|
|
307
|
-
this._animationFrameId = requestAnimationFramePolyfill(this._animationFrame.bind(this));
|
|
342
|
+
this._animationFrameId = this.props.animationFrameProvider.requestAnimationFrame(
|
|
343
|
+
this._animationFrame.bind(this)
|
|
344
|
+
);
|
|
308
345
|
}
|
|
309
346
|
|
|
310
347
|
_cancelAnimationFrame(): void {
|
|
@@ -312,21 +349,15 @@ export class AnimationLoop {
|
|
|
312
349
|
return;
|
|
313
350
|
}
|
|
314
351
|
|
|
315
|
-
|
|
316
|
-
// TODO WebVR API discontinued, replaced by WebXR: https://immersive-web.github.io/webxr/
|
|
317
|
-
// See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/requestAnimationFrame
|
|
318
|
-
// if (this.display && this.display.cancelAnimationFramePolyfill) {
|
|
319
|
-
// this.display.cancelAnimationFrame(this._animationFrameId);
|
|
320
|
-
// }
|
|
321
|
-
cancelAnimationFramePolyfill(this._animationFrameId);
|
|
352
|
+
this.props.animationFrameProvider.cancelAnimationFrame(this._animationFrameId);
|
|
322
353
|
this._animationFrameId = null;
|
|
323
354
|
}
|
|
324
355
|
|
|
325
|
-
_animationFrame(time: number): void {
|
|
356
|
+
_animationFrame(time: number, animationFrame?: unknown): void {
|
|
326
357
|
if (!this._running) {
|
|
327
358
|
return;
|
|
328
359
|
}
|
|
329
|
-
this.redraw(time);
|
|
360
|
+
this.redraw(time, animationFrame ?? null);
|
|
330
361
|
this._requestAnimationFrame();
|
|
331
362
|
}
|
|
332
363
|
|
|
@@ -343,8 +374,10 @@ export class AnimationLoop {
|
|
|
343
374
|
this.props.onRender(this._getAnimationProps());
|
|
344
375
|
// end callback
|
|
345
376
|
|
|
346
|
-
// Submit commands (necessary on WebGPU)
|
|
347
|
-
this.device
|
|
377
|
+
// Submit commands (necessary on WebGPU).
|
|
378
|
+
if (this.device) {
|
|
379
|
+
this.device.submit();
|
|
380
|
+
}
|
|
348
381
|
}
|
|
349
382
|
|
|
350
383
|
_clearNeedsRedraw(): void {
|
|
@@ -391,6 +424,7 @@ export class AnimationLoop {
|
|
|
391
424
|
tock: 0,
|
|
392
425
|
|
|
393
426
|
// Experimental
|
|
427
|
+
animationFrame: null,
|
|
394
428
|
_mousePosition: null // Event props
|
|
395
429
|
};
|
|
396
430
|
}
|
|
@@ -29,5 +29,7 @@ export type AnimationProps = {
|
|
|
29
29
|
timeline: Timeline | null;
|
|
30
30
|
|
|
31
31
|
// Experimental
|
|
32
|
+
/** Experimental v10 work-in-progress frame payload from a custom animation frame provider. */
|
|
33
|
+
animationFrame: unknown | null;
|
|
32
34
|
_mousePosition?: [number, number] | null; // [offsetX, offsetY],
|
|
33
35
|
};
|
|
@@ -7,6 +7,7 @@ import {AnimationLoopTemplate} from './animation-loop-template';
|
|
|
7
7
|
import {AnimationLoop, AnimationLoopProps} from './animation-loop';
|
|
8
8
|
import type {AnimationProps} from './animation-props';
|
|
9
9
|
|
|
10
|
+
/** Props accepted while constructing an animation loop from a template. */
|
|
10
11
|
export type MakeAnimationLoopProps = Omit<
|
|
11
12
|
AnimationLoopProps,
|
|
12
13
|
'onCreateDevice' | 'onInitialize' | 'onRedraw' | 'onFinalize'
|
|
@@ -43,8 +44,11 @@ export function makeAnimationLoop(
|
|
|
43
44
|
// Any async loading can be handled here
|
|
44
45
|
return await renderLoop?.onInitialize(animationProps);
|
|
45
46
|
} catch (error) {
|
|
47
|
+
// biome-ignore lint/suspicious/noConsole: fallback logging before rendering the in-canvas error banner.
|
|
46
48
|
console.error(error);
|
|
49
|
+
renderLoop = null;
|
|
47
50
|
setError(animationProps.animationLoop.device, error as Error);
|
|
51
|
+
animationProps.animationLoop.stop();
|
|
48
52
|
return null;
|
|
49
53
|
}
|
|
50
54
|
},
|
|
@@ -11,6 +11,11 @@ export function setPathPrefix(prefix: string) {
|
|
|
11
11
|
pathPrefix = prefix;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
+
/** @internal */
|
|
15
|
+
export function _resolveLoadFileUrl(url: string): string {
|
|
16
|
+
return isAbsoluteLoadFileUrl(url) ? url : pathPrefix + url;
|
|
17
|
+
}
|
|
18
|
+
|
|
14
19
|
/**
|
|
15
20
|
* Loads ImageBitmap asynchronously. Respects setPathPrefix.
|
|
16
21
|
* image.crossOrigin can be set via opts.crossOrigin, default to 'anonymous'
|
|
@@ -21,10 +26,21 @@ export async function loadImageBitmap(
|
|
|
21
26
|
opts?: {crossOrigin?: string} & ImageBitmapOptions
|
|
22
27
|
): Promise<ImageBitmap> {
|
|
23
28
|
const image = new Image();
|
|
29
|
+
const resolvedUrl = _resolveLoadFileUrl(url);
|
|
24
30
|
image.crossOrigin = opts?.crossOrigin || 'anonymous';
|
|
25
|
-
image.src =
|
|
26
|
-
|
|
27
|
-
|
|
31
|
+
image.src = resolvedUrl;
|
|
32
|
+
|
|
33
|
+
try {
|
|
34
|
+
await image.decode();
|
|
35
|
+
} catch (error) {
|
|
36
|
+
throw createImageBitmapLoadError('decode', resolvedUrl, error);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
try {
|
|
40
|
+
return opts ? await createImageBitmap(image, opts) : await createImageBitmap(image);
|
|
41
|
+
} catch (error) {
|
|
42
|
+
throw createImageBitmapLoadError('create', resolvedUrl, error);
|
|
43
|
+
}
|
|
28
44
|
}
|
|
29
45
|
|
|
30
46
|
/**
|
|
@@ -40,12 +56,29 @@ export async function loadImage(
|
|
|
40
56
|
return await new Promise((resolve, reject) => {
|
|
41
57
|
try {
|
|
42
58
|
const image = new Image();
|
|
59
|
+
const resolvedUrl = _resolveLoadFileUrl(url);
|
|
43
60
|
image.onload = () => resolve(image);
|
|
44
|
-
image.onerror = () => reject(new Error(`Could not load image ${
|
|
61
|
+
image.onerror = () => reject(new Error(`Could not load image ${resolvedUrl}.`));
|
|
45
62
|
image.crossOrigin = opts?.crossOrigin || 'anonymous';
|
|
46
|
-
image.src =
|
|
63
|
+
image.src = resolvedUrl;
|
|
47
64
|
} catch (error) {
|
|
48
65
|
reject(error);
|
|
49
66
|
}
|
|
50
67
|
});
|
|
51
68
|
}
|
|
69
|
+
|
|
70
|
+
function createImageBitmapLoadError(
|
|
71
|
+
phase: 'decode' | 'create',
|
|
72
|
+
resolvedUrl: string,
|
|
73
|
+
error: unknown
|
|
74
|
+
): Error {
|
|
75
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
76
|
+
const message =
|
|
77
|
+
phase === 'decode'
|
|
78
|
+
? `Could not decode source image "${resolvedUrl}": ${reason}`
|
|
79
|
+
: `Could not create ImageBitmap from decoded image "${resolvedUrl}": ${reason}`;
|
|
80
|
+
return new Error(message, {cause: error});
|
|
81
|
+
}
|
|
82
|
+
function isAbsoluteLoadFileUrl(url: string): boolean {
|
|
83
|
+
return url.startsWith('/') || /^[a-z][a-z\d+\-.]*:/i.test(url);
|
|
84
|
+
}
|