@luma.gl/engine 9.3.0-alpha.4 → 9.3.0-alpha.6
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 +8 -4
- package/dist/animation-loop/animation-loop.d.ts.map +1 -1
- package/dist/animation-loop/animation-loop.js +70 -43
- package/dist/animation-loop/animation-loop.js.map +1 -1
- package/dist/animation-loop/make-animation-loop.js +7 -1
- package/dist/animation-loop/make-animation-loop.js.map +1 -1
- package/dist/animation-loop/request-animation-frame.d.ts.map +1 -1
- package/dist/animation-loop/request-animation-frame.js +23 -6
- package/dist/animation-loop/request-animation-frame.js.map +1 -1
- package/dist/dist.dev.js +679 -927
- package/dist/dist.min.js +39 -240
- package/dist/dynamic-texture/dynamic-texture.d.ts +3 -3
- package/dist/dynamic-texture/dynamic-texture.d.ts.map +1 -1
- package/dist/dynamic-texture/dynamic-texture.js +170 -52
- package/dist/dynamic-texture/dynamic-texture.js.map +1 -1
- package/dist/dynamic-texture/texture-data.d.ts +4 -0
- package/dist/dynamic-texture/texture-data.d.ts.map +1 -1
- package/dist/dynamic-texture/texture-data.js +8 -0
- package/dist/dynamic-texture/texture-data.js.map +1 -1
- package/dist/factories/pipeline-factory.d.ts +7 -5
- package/dist/factories/pipeline-factory.d.ts.map +1 -1
- package/dist/factories/pipeline-factory.js +71 -36
- package/dist/factories/pipeline-factory.js.map +1 -1
- package/dist/factories/shader-factory.d.ts +0 -3
- package/dist/factories/shader-factory.d.ts.map +1 -1
- package/dist/factories/shader-factory.js +13 -19
- package/dist/factories/shader-factory.js.map +1 -1
- package/dist/geometries/cone-geometry.d.ts +3 -1
- package/dist/geometries/cone-geometry.d.ts.map +1 -1
- package/dist/geometries/cone-geometry.js.map +1 -1
- package/dist/geometries/cylinder-geometry.d.ts +2 -1
- package/dist/geometries/cylinder-geometry.d.ts.map +1 -1
- package/dist/geometries/cylinder-geometry.js.map +1 -1
- package/dist/index.cjs +683 -922
- package/dist/index.cjs.map +4 -4
- package/dist/model/model.d.ts +3 -1
- package/dist/model/model.d.ts.map +1 -1
- package/dist/model/model.js +11 -9
- package/dist/model/model.js.map +1 -1
- package/dist/models/billboard-texture-model.d.ts.map +1 -1
- package/dist/models/billboard-texture-model.js +10 -8
- package/dist/models/billboard-texture-model.js.map +1 -1
- package/dist/models/clip-space.js +7 -7
- package/dist/modules/picking/index-picking.d.ts +1 -1
- package/dist/modules/picking/index-picking.d.ts.map +1 -1
- package/dist/modules/picking/index-picking.js +0 -6
- package/dist/modules/picking/index-picking.js.map +1 -1
- package/dist/passes/get-fragment-shader.js +11 -30
- package/dist/passes/get-fragment-shader.js.map +1 -1
- package/dist/passes/shader-pass-renderer.d.ts +0 -2
- package/dist/passes/shader-pass-renderer.d.ts.map +1 -1
- package/dist/passes/shader-pass-renderer.js +4 -31
- package/dist/passes/shader-pass-renderer.js.map +1 -1
- package/dist/scenegraph/group-node.d.ts +5 -0
- package/dist/scenegraph/group-node.d.ts.map +1 -1
- package/dist/scenegraph/group-node.js +12 -0
- package/dist/scenegraph/group-node.js.map +1 -1
- package/dist/scenegraph/model-node.d.ts +2 -2
- package/dist/scenegraph/model-node.d.ts.map +1 -1
- package/dist/scenegraph/model-node.js.map +1 -1
- package/dist/scenegraph/scenegraph-node.d.ts +1 -1
- package/dist/scenegraph/scenegraph-node.d.ts.map +1 -1
- package/dist/scenegraph/scenegraph-node.js +23 -15
- package/dist/scenegraph/scenegraph-node.js.map +1 -1
- package/package.json +2 -2
- package/src/animation-loop/animation-loop.ts +75 -46
- package/src/animation-loop/make-animation-loop.ts +13 -5
- package/src/animation-loop/request-animation-frame.ts +32 -6
- package/src/dynamic-texture/dynamic-texture.ts +226 -65
- package/src/dynamic-texture/texture-data.ts +14 -0
- package/src/factories/pipeline-factory.ts +87 -46
- package/src/factories/shader-factory.ts +16 -20
- package/src/geometries/cone-geometry.ts +6 -1
- package/src/geometries/cylinder-geometry.ts +5 -1
- package/src/model/model.ts +14 -10
- package/src/models/billboard-texture-model.ts +10 -8
- package/src/models/clip-space.ts +7 -7
- package/src/modules/picking/index-picking.ts +0 -6
- package/src/passes/get-fragment-shader.ts +11 -30
- package/src/passes/shader-pass-renderer.ts +4 -33
- package/src/scenegraph/group-node.ts +16 -0
- package/src/scenegraph/model-node.ts +2 -2
- package/src/scenegraph/scenegraph-node.ts +27 -16
- package/dist/dynamic-texture/mipmaps.d.ts +0 -6
- package/dist/dynamic-texture/mipmaps.d.ts.map +0 -1
- package/dist/dynamic-texture/mipmaps.js +0 -441
- package/dist/dynamic-texture/mipmaps.js.map +0 -1
- package/src/dynamic-texture/mipmaps.ts +0 -517
|
@@ -4,11 +4,11 @@ import { Model } from "../model/model.js";
|
|
|
4
4
|
export type ModelNodeProps = ScenegraphNodeProps & {
|
|
5
5
|
model: Model;
|
|
6
6
|
managedResources?: any[];
|
|
7
|
-
bounds?: [number
|
|
7
|
+
bounds?: [[number, number, number], [number, number, number]];
|
|
8
8
|
};
|
|
9
9
|
export declare class ModelNode extends ScenegraphNode {
|
|
10
10
|
readonly model: Model;
|
|
11
|
-
bounds: [number
|
|
11
|
+
bounds: [[number, number, number], [number, number, number]] | null;
|
|
12
12
|
managedResources: any[];
|
|
13
13
|
constructor(props: ModelNodeProps);
|
|
14
14
|
destroy(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-node.d.ts","sourceRoot":"","sources":["../../src/scenegraph/model-node.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,UAAU,EAAC,MAAM,eAAe,CAAC;AACzC,OAAO,EAAC,cAAc,EAAE,mBAAmB,EAAC,6BAA0B;AACtE,OAAO,EAAC,KAAK,EAAC,0BAAuB;AAErC,MAAM,MAAM,cAAc,GAAG,mBAAmB,GAAG;IACjD,KAAK,EAAE,KAAK,CAAC;IACb,gBAAgB,CAAC,EAAE,GAAG,EAAE,CAAC;IACzB,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;CAC/
|
|
1
|
+
{"version":3,"file":"model-node.d.ts","sourceRoot":"","sources":["../../src/scenegraph/model-node.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,UAAU,EAAC,MAAM,eAAe,CAAC;AACzC,OAAO,EAAC,cAAc,EAAE,mBAAmB,EAAC,6BAA0B;AACtE,OAAO,EAAC,KAAK,EAAC,0BAAuB;AAErC,MAAM,MAAM,cAAc,GAAG,mBAAmB,GAAG;IACjD,KAAK,EAAE,KAAK,CAAC;IACb,gBAAgB,CAAC,EAAE,GAAG,EAAE,CAAC;IACzB,MAAM,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CAC/D,CAAC;AAEF,qBAAa,SAAU,SAAQ,cAAc;IAC3C,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IACtB,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,IAAI,CAAQ;IAC3E,gBAAgB,EAAE,GAAG,EAAE,CAAC;gBAOZ,KAAK,EAAE,cAAc;IAUxB,OAAO,IAAI,IAAI;IAUf,SAAS,IAAI,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,CAAC,GAAG,IAAI;IAKjD,IAAI,CAAC,UAAU,EAAE,UAAU;CAI5B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-node.js","sourceRoot":"","sources":["../../src/scenegraph/model-node.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAGpC,OAAO,EAAC,cAAc,EAAsB,6BAA0B;AAStE,MAAM,OAAO,SAAU,SAAQ,cAAc;IAClC,KAAK,CAAQ;IACtB,MAAM,
|
|
1
|
+
{"version":3,"file":"model-node.js","sourceRoot":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C,QAAQ,CAAC,KAAK,EAAE,GAAG,GAAG,IAAI;IAM1B,SAAS,CAAC,MAAM,EAAE,GAAG,EAAE,UAAU,GAAE,OAAc,GAAG,IAAI;IAQxD,mBAAmB,CAAC,UAAU,EAAE;QAC9B,QAAQ,CAAC,EAAE,GAAG,CAAC;QACf,QAAQ,CAAC,EAAE,GAAG,CAAC;QACf,KAAK,CAAC,EAAE,GAAG,CAAC;QACZ,MAAM,CAAC,EAAE,OAAO,CAAC;KAClB,GAAG,IAAI;IAiBR,YAAY,IAAI,IAAI;IAcpB,MAAM,CAAC,EAAC,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAC,GAAE;QAAC,QAAQ,CAAC,EAAE,GAAG,CAAC;QAAC,QAAQ,CAAC,EAAE,GAAG,CAAC;QAAC,KAAK,CAAC,EAAE,GAAG,CAAA;KAAM,GAAG,IAAI;IAgB7F,qBAAqB,CACnB,UAAU,EAAE,GAAG,EACf,WAAW,CAAC,EAAE,GAAG,GAChB;QACD,UAAU,EAAE,GAAG,CAAC;QAChB,WAAW,EAAE,GAAG,CAAC;QACjB,YAAY,EAAE,GAAG,CAAC;QAClB,WAAW,EAAE,GAAG,CAAC;QACjB,kBAAkB,EAAE,GAAG,CAAC;QACxB,2BAA2B,EAAE,GAAG,CAAC;KAClC;IA0CD,uBAAuB,CAAC,KAAK,EAAE,mBAAmB,GAAG,IAAI;CAwB1D"}
|
|
@@ -3,6 +3,11 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
import { Vector3, Matrix4 } from '@math.gl/core';
|
|
5
5
|
import { uid } from "../utils/uid.js";
|
|
6
|
+
function assert(condition, message) {
|
|
7
|
+
if (!condition) {
|
|
8
|
+
throw new Error(message);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
6
11
|
export class ScenegraphNode {
|
|
7
12
|
id;
|
|
8
13
|
matrix = new Matrix4();
|
|
@@ -33,17 +38,17 @@ export class ScenegraphNode {
|
|
|
33
38
|
return `{type: ScenegraphNode, id: ${this.id})}`;
|
|
34
39
|
}
|
|
35
40
|
setPosition(position) {
|
|
36
|
-
|
|
41
|
+
assert(position.length === 3, 'setPosition requires vector argument');
|
|
37
42
|
this.position = position;
|
|
38
43
|
return this;
|
|
39
44
|
}
|
|
40
45
|
setRotation(rotation) {
|
|
41
|
-
|
|
46
|
+
assert(rotation.length === 3 || rotation.length === 4, 'setRotation requires vector argument');
|
|
42
47
|
this.rotation = rotation;
|
|
43
48
|
return this;
|
|
44
49
|
}
|
|
45
50
|
setScale(scale) {
|
|
46
|
-
|
|
51
|
+
assert(scale.length === 3, 'setScale requires vector argument');
|
|
47
52
|
this.scale = scale;
|
|
48
53
|
return this;
|
|
49
54
|
}
|
|
@@ -72,17 +77,19 @@ export class ScenegraphNode {
|
|
|
72
77
|
return this;
|
|
73
78
|
}
|
|
74
79
|
updateMatrix() {
|
|
75
|
-
const pos = this.position;
|
|
76
|
-
const rot = this.rotation;
|
|
77
|
-
const scale = this.scale;
|
|
78
80
|
this.matrix.identity();
|
|
79
|
-
this.matrix.translate(
|
|
80
|
-
this.
|
|
81
|
-
|
|
81
|
+
this.matrix.translate(this.position);
|
|
82
|
+
if (this.rotation.length === 4) {
|
|
83
|
+
const rotationMatrix = new Matrix4().fromQuaternion(this.rotation);
|
|
84
|
+
this.matrix.multiplyRight(rotationMatrix);
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
this.matrix.rotateXYZ(this.rotation);
|
|
88
|
+
}
|
|
89
|
+
this.matrix.scale(this.scale);
|
|
82
90
|
return this;
|
|
83
91
|
}
|
|
84
|
-
update(
|
|
85
|
-
const { position, rotation, scale } = options;
|
|
92
|
+
update({ position, rotation, scale } = {}) {
|
|
86
93
|
if (position) {
|
|
87
94
|
this.setPosition(position);
|
|
88
95
|
}
|
|
@@ -138,17 +145,18 @@ export class ScenegraphNode {
|
|
|
138
145
|
// if ('display' in props) {
|
|
139
146
|
// this.display = props.display;
|
|
140
147
|
// }
|
|
141
|
-
if (
|
|
148
|
+
if (props?.position) {
|
|
142
149
|
this.setPosition(props.position);
|
|
143
150
|
}
|
|
144
|
-
if (
|
|
151
|
+
if (props?.rotation) {
|
|
145
152
|
this.setRotation(props.rotation);
|
|
146
153
|
}
|
|
147
|
-
if (
|
|
154
|
+
if (props?.scale) {
|
|
148
155
|
this.setScale(props.scale);
|
|
149
156
|
}
|
|
157
|
+
this.updateMatrix();
|
|
150
158
|
// Matrix overwrites other props
|
|
151
|
-
if (
|
|
159
|
+
if (props?.matrix) {
|
|
152
160
|
this.setMatrix(props.matrix);
|
|
153
161
|
}
|
|
154
162
|
Object.assign(this.props, props);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scenegraph-node.js","sourceRoot":"","sources":["../../src/scenegraph/scenegraph-node.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAEpC,OAAO,EAAC,OAAO,EAAE,OAAO,EAAe,MAAM,eAAe,CAAC;AAC7D,OAAO,EAAC,GAAG,EAAC,wBAAqB;
|
|
1
|
+
{"version":3,"file":"scenegraph-node.js","sourceRoot":"","sources":["../../src/scenegraph/scenegraph-node.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAEpC,OAAO,EAAC,OAAO,EAAE,OAAO,EAAe,MAAM,eAAe,CAAC;AAC7D,OAAO,EAAC,GAAG,EAAC,wBAAqB;AAEjC,SAAS,MAAM,CAAC,SAAkB,EAAE,OAAgB;IAClD,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;IAC3B,CAAC;AACH,CAAC;AAcD,MAAM,OAAO,cAAc;IAChB,EAAE,CAAS;IACpB,MAAM,GAAY,IAAI,OAAO,EAAE,CAAC;IAEhC,OAAO,GAAG,IAAI,CAAC;IACf,QAAQ,GAAG,IAAI,OAAO,EAAE,CAAC;IACzB,QAAQ,GAAG,IAAI,OAAO,EAA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AC,CAAC;QACnC,CAAC;QACD,IAAI,KAAK,EAAE,QAAQ,EAAE,CAAC;YACpB,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QACnC,CAAC;QACD,IAAI,KAAK,EAAE,KAAK,EAAE,CAAC;YACjB,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC7B,CAAC;QAED,IAAI,CAAC,YAAY,EAAE,CAAC;QAEpB,gCAAgC;QAChC,IAAI,KAAK,EAAE,MAAM,EAAE,CAAC;YAClB,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAC/B,CAAC;QAED,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IACnC,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@luma.gl/engine",
|
|
3
|
-
"version": "9.3.0-alpha.
|
|
3
|
+
"version": "9.3.0-alpha.6",
|
|
4
4
|
"description": "3D Engine Components for luma.gl",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -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": "59fda5480c4d0bb3d64545d4621175221f2b6c7c"
|
|
53
53
|
}
|
|
@@ -12,6 +12,7 @@ import {AnimationProps} from './animation-props';
|
|
|
12
12
|
import {Stats, Stat} from '@probe.gl/stats';
|
|
13
13
|
|
|
14
14
|
let statIdCounter = 0;
|
|
15
|
+
const ANIMATION_LOOP_STATS = 'Animation Loop';
|
|
15
16
|
|
|
16
17
|
/** AnimationLoop properties */
|
|
17
18
|
export type AnimationLoopProps = {
|
|
@@ -45,7 +46,7 @@ export class AnimationLoop {
|
|
|
45
46
|
onFinalize: () => {},
|
|
46
47
|
onError: error => console.error(error), // eslint-disable-line no-console
|
|
47
48
|
|
|
48
|
-
stats:
|
|
49
|
+
stats: undefined!,
|
|
49
50
|
|
|
50
51
|
// view parameters
|
|
51
52
|
autoResizeViewport: false
|
|
@@ -58,6 +59,7 @@ export class AnimationLoop {
|
|
|
58
59
|
animationProps: AnimationProps | null = null;
|
|
59
60
|
timeline: Timeline | null = null;
|
|
60
61
|
stats: Stats;
|
|
62
|
+
sharedStats: Stats;
|
|
61
63
|
cpuTime: Stat;
|
|
62
64
|
gpuTime: Stat;
|
|
63
65
|
frameRate: Stat;
|
|
@@ -73,8 +75,7 @@ export class AnimationLoop {
|
|
|
73
75
|
_resolveNextFrame: ((animationLoop: AnimationLoop) => void) | null = null;
|
|
74
76
|
_cpuStartTime: number = 0;
|
|
75
77
|
_error: Error | null = null;
|
|
76
|
-
|
|
77
|
-
// _gpuTimeQuery: Query | null = null;
|
|
78
|
+
_lastFrameTime: number = 0;
|
|
78
79
|
|
|
79
80
|
/*
|
|
80
81
|
* @param {HTMLCanvasElement} canvas - if provided, width and height will be passed to context
|
|
@@ -88,10 +89,12 @@ export class AnimationLoop {
|
|
|
88
89
|
}
|
|
89
90
|
|
|
90
91
|
// state
|
|
91
|
-
this.stats = props.stats || new Stats({id:
|
|
92
|
+
this.stats = props.stats || new Stats({id: `animation-loop-${statIdCounter++}`});
|
|
93
|
+
this.sharedStats = luma.stats.get(ANIMATION_LOOP_STATS);
|
|
94
|
+
this.frameRate = this.stats.get('Frame Rate');
|
|
95
|
+
this.frameRate.setSampleSize(1);
|
|
92
96
|
this.cpuTime = this.stats.get('CPU Time');
|
|
93
97
|
this.gpuTime = this.stats.get('GPU Time');
|
|
94
|
-
this.frameRate = this.stats.get('Frame Rate');
|
|
95
98
|
|
|
96
99
|
this.setProps({autoResizeViewport: props.autoResizeViewport});
|
|
97
100
|
|
|
@@ -106,6 +109,7 @@ export class AnimationLoop {
|
|
|
106
109
|
destroy(): void {
|
|
107
110
|
this.stop();
|
|
108
111
|
this._setDisplay(null);
|
|
112
|
+
this.device?._disableDebugGPUTime();
|
|
109
113
|
}
|
|
110
114
|
|
|
111
115
|
/** @deprecated Use .destroy() */
|
|
@@ -192,17 +196,18 @@ export class AnimationLoop {
|
|
|
192
196
|
this._nextFramePromise = null;
|
|
193
197
|
this._resolveNextFrame = null;
|
|
194
198
|
this._running = false;
|
|
199
|
+
this._lastFrameTime = 0;
|
|
195
200
|
}
|
|
196
201
|
return this;
|
|
197
202
|
}
|
|
198
203
|
|
|
199
204
|
/** Explicitly draw a frame */
|
|
200
|
-
redraw(): this {
|
|
205
|
+
redraw(time?: number): this {
|
|
201
206
|
if (this.device?.isLost || this._error) {
|
|
202
207
|
return this;
|
|
203
208
|
}
|
|
204
209
|
|
|
205
|
-
this._beginFrameTimers();
|
|
210
|
+
this._beginFrameTimers(time);
|
|
206
211
|
|
|
207
212
|
this._setupFrame();
|
|
208
213
|
this._updateAnimationProps();
|
|
@@ -268,7 +273,7 @@ export class AnimationLoop {
|
|
|
268
273
|
// Default viewport setup, in case onInitialize wants to render
|
|
269
274
|
this._resizeViewport();
|
|
270
275
|
|
|
271
|
-
|
|
276
|
+
this.device?._enableDebugGPUTime();
|
|
272
277
|
}
|
|
273
278
|
|
|
274
279
|
_setDisplay(display: any): void {
|
|
@@ -314,11 +319,11 @@ export class AnimationLoop {
|
|
|
314
319
|
this._animationFrameId = null;
|
|
315
320
|
}
|
|
316
321
|
|
|
317
|
-
_animationFrame(): void {
|
|
322
|
+
_animationFrame(time: number): void {
|
|
318
323
|
if (!this._running) {
|
|
319
324
|
return;
|
|
320
325
|
}
|
|
321
|
-
this.redraw();
|
|
326
|
+
this.redraw(time);
|
|
322
327
|
this._requestAnimationFrame();
|
|
323
328
|
}
|
|
324
329
|
|
|
@@ -467,20 +472,10 @@ export class AnimationLoop {
|
|
|
467
472
|
if (!this.device) {
|
|
468
473
|
return {width: 1, height: 1, aspect: 1};
|
|
469
474
|
}
|
|
470
|
-
//
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
let aspect = 1;
|
|
475
|
-
const canvas = this.device?.getDefaultCanvasContext().canvas;
|
|
476
|
-
|
|
477
|
-
// @ts-expect-error
|
|
478
|
-
if (canvas && canvas.clientHeight) {
|
|
479
|
-
// @ts-expect-error
|
|
480
|
-
aspect = canvas.clientWidth / canvas.clientHeight;
|
|
481
|
-
} else if (width > 0 && height > 0) {
|
|
482
|
-
aspect = width / height;
|
|
483
|
-
}
|
|
475
|
+
// Match projection setup to the actual render target dimensions, which may
|
|
476
|
+
// differ from the CSS size when device-pixel scaling or backend clamping applies.
|
|
477
|
+
const [width, height] = this.device.getDefaultCanvasContext().getDrawingBufferSize();
|
|
478
|
+
const aspect = width > 0 && height > 0 ? width / height : 1;
|
|
484
479
|
|
|
485
480
|
return {width, height, aspect};
|
|
486
481
|
}
|
|
@@ -502,36 +497,70 @@ export class AnimationLoop {
|
|
|
502
497
|
}
|
|
503
498
|
}
|
|
504
499
|
|
|
505
|
-
_beginFrameTimers() {
|
|
506
|
-
|
|
507
|
-
this.
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
// this._gpuTimeQuery.isResultAvailable() &&
|
|
515
|
-
// !this._gpuTimeQuery.isTimerDisjoint()
|
|
516
|
-
// ) {
|
|
517
|
-
// this.stats.get('GPU Time').addTime(this._gpuTimeQuery.getTimerMilliseconds());
|
|
518
|
-
// }
|
|
500
|
+
_beginFrameTimers(time?: number) {
|
|
501
|
+
const now = time ?? (typeof performance !== 'undefined' ? performance.now() : Date.now());
|
|
502
|
+
if (this._lastFrameTime) {
|
|
503
|
+
const frameTime = now - this._lastFrameTime;
|
|
504
|
+
if (frameTime > 0) {
|
|
505
|
+
this.frameRate.addTime(frameTime);
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
this._lastFrameTime = now;
|
|
519
509
|
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
// }
|
|
510
|
+
if (this.device?._isDebugGPUTimeEnabled()) {
|
|
511
|
+
this._consumeEncodedGpuTime();
|
|
512
|
+
}
|
|
524
513
|
|
|
525
514
|
this.cpuTime.timeStart();
|
|
526
515
|
}
|
|
527
516
|
|
|
528
517
|
_endFrameTimers() {
|
|
518
|
+
if (this.device?._isDebugGPUTimeEnabled()) {
|
|
519
|
+
this._consumeEncodedGpuTime();
|
|
520
|
+
}
|
|
521
|
+
|
|
529
522
|
this.cpuTime.timeEnd();
|
|
523
|
+
this._updateSharedStats();
|
|
524
|
+
}
|
|
530
525
|
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
526
|
+
_consumeEncodedGpuTime(): void {
|
|
527
|
+
if (!this.device) {
|
|
528
|
+
return;
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
const gpuTimeMs = this.device.commandEncoder._gpuTimeMs;
|
|
532
|
+
if (gpuTimeMs !== undefined) {
|
|
533
|
+
this.gpuTime.addTime(gpuTimeMs);
|
|
534
|
+
this.device.commandEncoder._gpuTimeMs = undefined;
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
_updateSharedStats(): void {
|
|
539
|
+
if (this.stats === this.sharedStats) {
|
|
540
|
+
return;
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
for (const name of Object.keys(this.sharedStats.stats)) {
|
|
544
|
+
if (!this.stats.stats[name]) {
|
|
545
|
+
delete this.sharedStats.stats[name];
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
this.stats.forEach(sourceStat => {
|
|
550
|
+
const targetStat = this.sharedStats.get(sourceStat.name, sourceStat.type);
|
|
551
|
+
targetStat.sampleSize = sourceStat.sampleSize;
|
|
552
|
+
targetStat.time = sourceStat.time;
|
|
553
|
+
targetStat.count = sourceStat.count;
|
|
554
|
+
targetStat.samples = sourceStat.samples;
|
|
555
|
+
targetStat.lastTiming = sourceStat.lastTiming;
|
|
556
|
+
targetStat.lastSampleTime = sourceStat.lastSampleTime;
|
|
557
|
+
targetStat.lastSampleCount = sourceStat.lastSampleCount;
|
|
558
|
+
targetStat._count = sourceStat._count;
|
|
559
|
+
targetStat._time = sourceStat._time;
|
|
560
|
+
targetStat._samples = sourceStat._samples;
|
|
561
|
+
targetStat._startTime = sourceStat._startTime;
|
|
562
|
+
targetStat._timerPending = sourceStat._timerPending;
|
|
563
|
+
});
|
|
535
564
|
}
|
|
536
565
|
|
|
537
566
|
// Event handling
|
|
@@ -36,14 +36,14 @@ export function makeAnimationLoop(
|
|
|
36
36
|
device,
|
|
37
37
|
|
|
38
38
|
async onInitialize(animationProps: AnimationProps): Promise<unknown> {
|
|
39
|
-
clearError(animationProps.animationLoop.device
|
|
39
|
+
clearError(animationProps.animationLoop.device);
|
|
40
40
|
try {
|
|
41
41
|
// @ts-expect-error abstract to prevent instantiation
|
|
42
42
|
renderLoop = new AnimationLoopTemplateCtor(animationProps);
|
|
43
43
|
// Any async loading can be handled here
|
|
44
44
|
return await renderLoop?.onInitialize(animationProps);
|
|
45
45
|
} catch (error) {
|
|
46
|
-
setError(animationProps.animationLoop.device
|
|
46
|
+
setError(animationProps.animationLoop.device, error as Error);
|
|
47
47
|
return null;
|
|
48
48
|
}
|
|
49
49
|
},
|
|
@@ -63,8 +63,12 @@ export function makeAnimationLoop(
|
|
|
63
63
|
return animationLoop;
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
function setError(device: Device, error: Error): void {
|
|
67
|
-
|
|
66
|
+
function setError(device: Device | null, error: Error): void {
|
|
67
|
+
if (!device) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const canvas = device.getDefaultCanvasContext().canvas;
|
|
68
72
|
if (canvas instanceof HTMLCanvasElement) {
|
|
69
73
|
canvas.style.overflow = 'visible';
|
|
70
74
|
let errorDiv = document.getElementById('animation-loop-error');
|
|
@@ -82,7 +86,11 @@ function setError(device: Device, error: Error): void {
|
|
|
82
86
|
}
|
|
83
87
|
}
|
|
84
88
|
|
|
85
|
-
function clearError(device: Device): void {
|
|
89
|
+
function clearError(device: Device | null): void {
|
|
90
|
+
if (!device) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
|
|
86
94
|
const errorDiv = document.getElementById('animation-loop-error');
|
|
87
95
|
if (errorDiv) {
|
|
88
96
|
errorDiv.remove();
|
|
@@ -7,14 +7,40 @@
|
|
|
7
7
|
/** Node.js polyfill for requestAnimationFrame */
|
|
8
8
|
// / <reference types="@types/node" />
|
|
9
9
|
export function requestAnimationFramePolyfill(callback: (time?: any) => void): any {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
const browserRequestAnimationFrame =
|
|
11
|
+
typeof window !== 'undefined'
|
|
12
|
+
? window.requestAnimationFrame ||
|
|
13
|
+
(window as Window & {webkitRequestAnimationFrame?: (cb: FrameRequestCallback) => number})
|
|
14
|
+
.webkitRequestAnimationFrame ||
|
|
15
|
+
(window as Window & {mozRequestAnimationFrame?: (cb: FrameRequestCallback) => number})
|
|
16
|
+
.mozRequestAnimationFrame
|
|
17
|
+
: null;
|
|
18
|
+
|
|
19
|
+
if (browserRequestAnimationFrame) {
|
|
20
|
+
return browserRequestAnimationFrame.call(window, callback);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return setTimeout(
|
|
24
|
+
() => callback(typeof performance !== 'undefined' ? performance.now() : Date.now()),
|
|
25
|
+
1000 / 60
|
|
26
|
+
);
|
|
13
27
|
}
|
|
14
28
|
|
|
15
29
|
/** Node.js polyfill for cancelAnimationFrame */
|
|
16
30
|
export function cancelAnimationFramePolyfill(timerId: any): void {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
31
|
+
const browserCancelAnimationFrame =
|
|
32
|
+
typeof window !== 'undefined'
|
|
33
|
+
? window.cancelAnimationFrame ||
|
|
34
|
+
(window as Window & {webkitCancelAnimationFrame?: (handle: number) => void})
|
|
35
|
+
.webkitCancelAnimationFrame ||
|
|
36
|
+
(window as Window & {mozCancelAnimationFrame?: (handle: number) => void})
|
|
37
|
+
.mozCancelAnimationFrame
|
|
38
|
+
: null;
|
|
39
|
+
|
|
40
|
+
if (browserCancelAnimationFrame) {
|
|
41
|
+
browserCancelAnimationFrame.call(window, timerId);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
clearTimeout(timerId);
|
|
20
46
|
}
|