@luma.gl/engine 9.0.0-alpha.3 → 9.0.0-alpha.31
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/LICENSE +2 -1
- package/dist/animation/key-frames.d.ts +1 -1
- package/dist/animation/key-frames.d.ts.map +1 -1
- package/dist/animation/key-frames.js +0 -20
- package/dist/animation/key-frames.js.map +1 -1
- package/dist/animation/timeline.d.ts +5 -5
- package/dist/animation/timeline.d.ts.map +1 -1
- package/dist/animation/timeline.js +0 -30
- package/dist/animation/timeline.js.map +1 -1
- package/dist/{lib → animation-loop}/animation-loop.d.ts +28 -29
- package/dist/animation-loop/animation-loop.d.ts.map +1 -0
- package/dist/{lib → animation-loop}/animation-loop.js +96 -175
- package/dist/animation-loop/animation-loop.js.map +1 -0
- package/dist/{lib → animation-loop}/animation-props.d.ts +7 -7
- package/dist/animation-loop/animation-props.d.ts.map +1 -0
- package/dist/animation-loop/animation-props.js.map +1 -0
- package/dist/animation-loop/make-animation-loop.d.ts +6 -0
- package/dist/animation-loop/make-animation-loop.d.ts.map +1 -0
- package/dist/animation-loop/make-animation-loop.js +28 -0
- package/dist/animation-loop/make-animation-loop.js.map +1 -0
- package/dist/animation-loop/render-loop.d.ts +23 -0
- package/dist/animation-loop/render-loop.d.ts.map +1 -0
- package/dist/animation-loop/render-loop.js +7 -0
- package/dist/animation-loop/render-loop.js.map +1 -0
- package/dist/dist.dev.js +14977 -0
- package/dist/geometries/cone-geometry.d.ts +1 -1
- package/dist/geometries/cone-geometry.d.ts.map +1 -1
- package/dist/geometries/cone-geometry.js +6 -5
- package/dist/geometries/cone-geometry.js.map +1 -1
- package/dist/geometries/cube-geometry.d.ts +2 -2
- package/dist/geometries/cube-geometry.d.ts.map +1 -1
- package/dist/geometries/cube-geometry.js +15 -8
- package/dist/geometries/cube-geometry.js.map +1 -1
- package/dist/geometries/cylinder-geometry.d.ts +1 -1
- package/dist/geometries/cylinder-geometry.d.ts.map +1 -1
- package/dist/geometries/cylinder-geometry.js +6 -5
- package/dist/geometries/cylinder-geometry.js.map +1 -1
- package/dist/geometries/ico-sphere-geometry.d.ts +2 -2
- package/dist/geometries/ico-sphere-geometry.d.ts.map +1 -1
- package/dist/geometries/ico-sphere-geometry.js +9 -18
- package/dist/geometries/ico-sphere-geometry.js.map +1 -1
- package/dist/geometries/plane-geometry.d.ts +2 -2
- package/dist/geometries/plane-geometry.d.ts.map +1 -1
- package/dist/geometries/plane-geometry.js +10 -19
- package/dist/geometries/plane-geometry.js.map +1 -1
- package/dist/geometries/sphere-geometry.d.ts +2 -2
- package/dist/geometries/sphere-geometry.d.ts.map +1 -1
- package/dist/geometries/sphere-geometry.js +9 -13
- package/dist/geometries/sphere-geometry.js.map +1 -1
- package/dist/geometries/truncated-cone-geometry.d.ts +2 -2
- package/dist/geometries/truncated-cone-geometry.d.ts.map +1 -1
- package/dist/geometries/truncated-cone-geometry.js +9 -14
- package/dist/geometries/truncated-cone-geometry.js.map +1 -1
- package/dist/geometry/geometry-table.d.ts +2 -2
- package/dist/geometry/geometry-table.d.ts.map +1 -1
- package/dist/geometry/geometry-table.js.map +1 -1
- package/dist/geometry/geometry-utils.d.ts.map +1 -1
- package/dist/geometry/geometry-utils.js +0 -9
- package/dist/geometry/geometry-utils.js.map +1 -1
- package/dist/geometry/geometry.d.ts +35 -58
- package/dist/geometry/geometry.d.ts.map +1 -1
- package/dist/geometry/geometry.js +26 -89
- package/dist/geometry/geometry.js.map +1 -1
- package/dist/geometry/primitive-utils.js.map +1 -1
- package/dist/index.cjs +2576 -0
- package/dist/index.d.ts +18 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +20 -13
- package/dist/index.js.map +1 -1
- package/dist/lib/clip-space.d.ts +8 -0
- package/dist/lib/clip-space.d.ts.map +1 -1
- package/dist/lib/clip-space.js +36 -1
- package/dist/lib/clip-space.js.map +1 -1
- package/dist/lib/pipeline-factory.d.ts +19 -14
- package/dist/lib/pipeline-factory.d.ts.map +1 -1
- package/dist/lib/pipeline-factory.js +52 -63
- package/dist/lib/pipeline-factory.js.map +1 -1
- package/dist/{lib → model}/model-utils.d.ts +2 -2
- package/dist/model/model-utils.d.ts.map +1 -0
- package/dist/{lib → model}/model-utils.js +3 -8
- package/dist/model/model-utils.js.map +1 -0
- package/dist/model/model.d.ts +67 -0
- package/dist/model/model.d.ts.map +1 -0
- package/dist/{lib → model}/model.js +59 -76
- package/dist/model/model.js.map +1 -0
- package/dist/scenegraph/group-node.d.ts +21 -0
- package/dist/scenegraph/group-node.d.ts.map +1 -0
- package/dist/scenegraph/group-node.js +95 -0
- package/dist/scenegraph/group-node.js.map +1 -0
- package/dist/scenegraph/model-node.d.ts +18 -0
- package/dist/scenegraph/model-node.d.ts.map +1 -0
- package/dist/scenegraph/model-node.js +29 -0
- package/dist/scenegraph/model-node.js.map +1 -0
- package/dist/scenegraph/scenegraph-node.d.ts +56 -0
- package/dist/scenegraph/scenegraph-node.d.ts.map +1 -0
- package/dist/scenegraph/scenegraph-node.js +142 -0
- package/dist/scenegraph/scenegraph-node.js.map +1 -0
- package/dist/transform/transform.d.ts +98 -0
- package/dist/transform/transform.d.ts.map +1 -0
- package/dist/transform/transform.js +67 -0
- package/dist/transform/transform.js.map +1 -0
- package/dist.min.js +314 -0
- package/package.json +22 -12
- package/src/animation/timeline.ts +2 -2
- package/src/{lib → animation-loop}/animation-loop.ts +115 -97
- package/src/{lib → animation-loop}/animation-props.ts +6 -5
- package/src/animation-loop/make-animation-loop.ts +44 -0
- package/src/animation-loop/render-loop.ts +23 -0
- package/src/geometries/cone-geometry.ts +1 -1
- package/src/geometries/cube-geometry.ts +6 -3
- package/src/geometries/cylinder-geometry.ts +2 -2
- package/src/geometries/ico-sphere-geometry.ts +7 -6
- package/src/geometries/plane-geometry.ts +5 -4
- package/src/geometries/sphere-geometry.ts +4 -3
- package/src/geometries/truncated-cone-geometry.ts +4 -3
- package/src/geometry/geometry-table.ts +1 -1
- package/src/geometry/geometry-utils.ts +3 -3
- package/src/geometry/geometry.ts +72 -115
- package/src/index.ts +28 -12
- package/src/lib/clip-space.ts +17 -15
- package/src/lib/pipeline-factory.ts +60 -50
- package/src/{lib → model}/model-utils.ts +5 -4
- package/src/model/model.ts +230 -0
- package/src/scenegraph/group-node.ts +103 -0
- package/src/scenegraph/model-node.ts +50 -0
- package/src/scenegraph/scenegraph-node.ts +204 -0
- package/src/transform/transform.ts +246 -0
- package/dist/bundle.d.ts +0 -2
- package/dist/bundle.d.ts.map +0 -1
- package/dist/bundle.js +0 -5
- package/dist/bundle.js.map +0 -1
- package/dist/lib/animation-loop.d.ts.map +0 -1
- package/dist/lib/animation-loop.js.map +0 -1
- package/dist/lib/animation-props.d.ts.map +0 -1
- package/dist/lib/animation-props.js.map +0 -1
- package/dist/lib/model-utils.d.ts.map +0 -1
- package/dist/lib/model-utils.js.map +0 -1
- package/dist/lib/model.d.ts +0 -41
- package/dist/lib/model.d.ts.map +0 -1
- package/dist/lib/model.js.map +0 -1
- package/dist/lib/render-loop.d.ts +0 -14
- package/dist/lib/render-loop.d.ts.map +0 -1
- package/dist/lib/render-loop.js +0 -49
- package/dist/lib/render-loop.js.map +0 -1
- package/src/bundle.ts +0 -4
- package/src/lib/model.ts +0 -179
- package/src/lib/render-loop.ts +0 -58
- /package/dist/{lib → animation-loop}/animation-props.js +0 -0
|
@@ -1,70 +1,55 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
-
import { luma } from '@luma.gl/
|
|
3
|
-
import { requestAnimationFrame, cancelAnimationFrame } from '@luma.gl/
|
|
4
|
-
import {
|
|
5
|
-
const isPage = isBrowser() && typeof document !== 'undefined';
|
|
2
|
+
import { luma } from '@luma.gl/core';
|
|
3
|
+
import { requestAnimationFrame, cancelAnimationFrame } from '@luma.gl/core';
|
|
4
|
+
import { Stats } from '@probe.gl/stats';
|
|
6
5
|
let statIdCounter = 0;
|
|
7
6
|
const DEFAULT_ANIMATION_LOOP_PROPS = {
|
|
8
|
-
|
|
9
|
-
onAddHTML:
|
|
10
|
-
onInitialize: () =>
|
|
7
|
+
device: null,
|
|
8
|
+
onAddHTML: () => '',
|
|
9
|
+
onInitialize: async () => {
|
|
10
|
+
return null;
|
|
11
|
+
},
|
|
11
12
|
onRender: () => {},
|
|
12
13
|
onFinalize: () => {},
|
|
13
14
|
onError: error => console.error(error),
|
|
14
|
-
device: undefined,
|
|
15
|
-
deviceProps: {},
|
|
16
|
-
debug: false,
|
|
17
15
|
stats: luma.stats.get("animation-loop-".concat(statIdCounter++)),
|
|
18
16
|
useDevicePixels: true,
|
|
19
|
-
autoResizeViewport:
|
|
20
|
-
autoResizeDrawingBuffer:
|
|
17
|
+
autoResizeViewport: false,
|
|
18
|
+
autoResizeDrawingBuffer: false
|
|
21
19
|
};
|
|
22
|
-
export
|
|
23
|
-
constructor(props
|
|
24
|
-
_defineProperty(this, "device",
|
|
25
|
-
|
|
26
|
-
_defineProperty(this, "canvas", void 0);
|
|
27
|
-
|
|
20
|
+
export class AnimationLoop {
|
|
21
|
+
constructor(props) {
|
|
22
|
+
_defineProperty(this, "device", null);
|
|
23
|
+
_defineProperty(this, "canvas", null);
|
|
28
24
|
_defineProperty(this, "props", void 0);
|
|
29
|
-
|
|
30
|
-
_defineProperty(this, "animationProps", void 0);
|
|
31
|
-
|
|
25
|
+
_defineProperty(this, "animationProps", null);
|
|
32
26
|
_defineProperty(this, "timeline", null);
|
|
33
|
-
|
|
34
27
|
_defineProperty(this, "stats", void 0);
|
|
35
|
-
|
|
36
28
|
_defineProperty(this, "cpuTime", void 0);
|
|
37
|
-
|
|
38
29
|
_defineProperty(this, "gpuTime", void 0);
|
|
39
|
-
|
|
40
30
|
_defineProperty(this, "frameRate", void 0);
|
|
41
|
-
|
|
42
31
|
_defineProperty(this, "display", void 0);
|
|
43
|
-
|
|
44
32
|
_defineProperty(this, "needsRedraw", 'initialized');
|
|
45
|
-
|
|
46
33
|
_defineProperty(this, "_initialized", false);
|
|
47
|
-
|
|
48
34
|
_defineProperty(this, "_running", false);
|
|
49
|
-
|
|
50
35
|
_defineProperty(this, "_animationFrameId", null);
|
|
51
|
-
|
|
52
36
|
_defineProperty(this, "_nextFramePromise", null);
|
|
53
|
-
|
|
54
37
|
_defineProperty(this, "_resolveNextFrame", null);
|
|
55
|
-
|
|
56
38
|
_defineProperty(this, "_cpuStartTime", 0);
|
|
57
|
-
|
|
58
|
-
|
|
39
|
+
this.props = {
|
|
40
|
+
...DEFAULT_ANIMATION_LOOP_PROPS,
|
|
59
41
|
...props
|
|
60
42
|
};
|
|
61
43
|
props = this.props;
|
|
62
|
-
|
|
44
|
+
if (!props.device) {
|
|
45
|
+
throw new Error('No device provided');
|
|
46
|
+
}
|
|
47
|
+
const {
|
|
63
48
|
useDevicePixels = true
|
|
64
49
|
} = this.props;
|
|
65
|
-
this.
|
|
66
|
-
|
|
67
|
-
|
|
50
|
+
this.stats = props.stats || new Stats({
|
|
51
|
+
id: 'animation-loop-stats'
|
|
52
|
+
});
|
|
68
53
|
this.cpuTime = this.stats.get('CPU Time');
|
|
69
54
|
this.gpuTime = this.stats.get('GPU Time');
|
|
70
55
|
this.frameRate = this.stats.get('Frame Rate');
|
|
@@ -78,71 +63,52 @@ export default class AnimationLoop {
|
|
|
78
63
|
this._onMousemove = this._onMousemove.bind(this);
|
|
79
64
|
this._onMouseleave = this._onMouseleave.bind(this);
|
|
80
65
|
}
|
|
81
|
-
|
|
82
66
|
destroy() {
|
|
83
67
|
this.stop();
|
|
84
|
-
|
|
85
68
|
this._setDisplay(null);
|
|
86
69
|
}
|
|
87
|
-
|
|
88
70
|
delete() {
|
|
89
71
|
this.destroy();
|
|
90
72
|
}
|
|
91
|
-
|
|
92
73
|
setNeedsRedraw(reason) {
|
|
93
74
|
this.needsRedraw = this.needsRedraw || reason;
|
|
94
75
|
return this;
|
|
95
76
|
}
|
|
96
|
-
|
|
97
77
|
setProps(props) {
|
|
98
78
|
if ('autoResizeViewport' in props) {
|
|
99
|
-
this.props.autoResizeViewport = props.autoResizeViewport;
|
|
79
|
+
this.props.autoResizeViewport = props.autoResizeViewport || false;
|
|
100
80
|
}
|
|
101
|
-
|
|
102
81
|
if ('autoResizeDrawingBuffer' in props) {
|
|
103
|
-
this.props.autoResizeDrawingBuffer = props.autoResizeDrawingBuffer;
|
|
82
|
+
this.props.autoResizeDrawingBuffer = props.autoResizeDrawingBuffer || false;
|
|
104
83
|
}
|
|
105
|
-
|
|
106
84
|
if ('useDevicePixels' in props) {
|
|
107
|
-
this.props.useDevicePixels = props.useDevicePixels;
|
|
85
|
+
this.props.useDevicePixels = props.useDevicePixels || false;
|
|
108
86
|
}
|
|
109
|
-
|
|
110
87
|
return this;
|
|
111
88
|
}
|
|
112
|
-
|
|
113
89
|
async start() {
|
|
114
90
|
if (this._running) {
|
|
115
91
|
return this;
|
|
116
92
|
}
|
|
117
|
-
|
|
118
93
|
this._running = true;
|
|
119
|
-
|
|
120
94
|
try {
|
|
121
95
|
if (!this._running) {
|
|
122
96
|
return null;
|
|
123
97
|
}
|
|
124
|
-
|
|
125
98
|
let appContext;
|
|
126
|
-
|
|
127
99
|
if (!this._initialized) {
|
|
128
100
|
this._initialized = true;
|
|
129
|
-
await this.
|
|
130
|
-
|
|
101
|
+
await this._initDevice();
|
|
131
102
|
this._initialize();
|
|
132
|
-
|
|
133
|
-
await this.onInitialize(this.animationProps);
|
|
103
|
+
await this.props.onInitialize(this._getAnimationProps());
|
|
134
104
|
}
|
|
135
|
-
|
|
136
105
|
if (!this._running) {
|
|
137
106
|
return null;
|
|
138
107
|
}
|
|
139
|
-
|
|
140
108
|
if (appContext !== false) {
|
|
141
109
|
this._cancelAnimationFrame();
|
|
142
|
-
|
|
143
110
|
this._requestAnimationFrame();
|
|
144
111
|
}
|
|
145
|
-
|
|
146
112
|
return this;
|
|
147
113
|
} catch (err) {
|
|
148
114
|
const error = err instanceof Error ? err : new Error('Unknown error');
|
|
@@ -150,171 +116,124 @@ export default class AnimationLoop {
|
|
|
150
116
|
throw error;
|
|
151
117
|
}
|
|
152
118
|
}
|
|
153
|
-
|
|
154
119
|
redraw() {
|
|
155
|
-
|
|
120
|
+
var _this$device;
|
|
121
|
+
if ((_this$device = this.device) !== null && _this$device !== void 0 && _this$device.isLost) {
|
|
156
122
|
return this;
|
|
157
123
|
}
|
|
158
|
-
|
|
159
124
|
this._beginTimers();
|
|
160
|
-
|
|
161
125
|
this._setupFrame();
|
|
162
|
-
|
|
163
|
-
this.
|
|
164
|
-
|
|
165
|
-
this._renderFrame(this.animationProps);
|
|
166
|
-
|
|
126
|
+
this._updateAnimationProps();
|
|
127
|
+
this._renderFrame(this._getAnimationProps());
|
|
167
128
|
this._clearNeedsRedraw();
|
|
168
|
-
|
|
169
129
|
if (this._resolveNextFrame) {
|
|
170
130
|
this._resolveNextFrame(this);
|
|
171
|
-
|
|
172
131
|
this._nextFramePromise = null;
|
|
173
132
|
this._resolveNextFrame = null;
|
|
174
133
|
}
|
|
175
|
-
|
|
176
134
|
this._endTimers();
|
|
177
|
-
|
|
178
135
|
return this;
|
|
179
136
|
}
|
|
180
|
-
|
|
181
137
|
stop() {
|
|
182
138
|
if (this._running) {
|
|
183
|
-
|
|
184
|
-
|
|
139
|
+
if (this.animationProps) {
|
|
140
|
+
this.props.onFinalize(this.animationProps);
|
|
141
|
+
}
|
|
185
142
|
this._cancelAnimationFrame();
|
|
186
|
-
|
|
187
143
|
this._nextFramePromise = null;
|
|
188
144
|
this._resolveNextFrame = null;
|
|
189
145
|
this._running = false;
|
|
190
146
|
}
|
|
191
|
-
|
|
192
147
|
return this;
|
|
193
148
|
}
|
|
194
|
-
|
|
195
149
|
attachTimeline(timeline) {
|
|
196
150
|
this.timeline = timeline;
|
|
197
151
|
return this.timeline;
|
|
198
152
|
}
|
|
199
|
-
|
|
200
153
|
detachTimeline() {
|
|
201
154
|
this.timeline = null;
|
|
202
155
|
}
|
|
203
|
-
|
|
204
156
|
waitForRender() {
|
|
205
157
|
this.setNeedsRedraw('waitForRender');
|
|
206
|
-
|
|
207
158
|
if (!this._nextFramePromise) {
|
|
208
159
|
this._nextFramePromise = new Promise(resolve => {
|
|
209
160
|
this._resolveNextFrame = resolve;
|
|
210
161
|
});
|
|
211
162
|
}
|
|
212
|
-
|
|
213
163
|
return this._nextFramePromise;
|
|
214
164
|
}
|
|
215
|
-
|
|
216
165
|
async toDataURL() {
|
|
217
166
|
this.setNeedsRedraw('toDataURL');
|
|
218
167
|
await this.waitForRender();
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
return this.props.onCreateDevice(deviceProps);
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
onInitialize(animationProps) {
|
|
227
|
-
return this.props.onInitialize(animationProps);
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
onRender(animationProps) {
|
|
231
|
-
return this.props.onRender(animationProps);
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
onFinalize(animationProps) {
|
|
235
|
-
return this.props.onFinalize(animationProps);
|
|
168
|
+
if (this.canvas instanceof HTMLCanvasElement) {
|
|
169
|
+
return this.canvas.toDataURL();
|
|
170
|
+
}
|
|
171
|
+
throw new Error('OffscreenCanvas');
|
|
236
172
|
}
|
|
237
|
-
|
|
238
173
|
_initialize() {
|
|
239
174
|
this._startEventHandling();
|
|
240
|
-
|
|
241
|
-
this.
|
|
242
|
-
|
|
243
|
-
this._updateCallbackData();
|
|
244
|
-
|
|
175
|
+
this._initializeAnimationProps();
|
|
176
|
+
this._updateAnimationProps();
|
|
245
177
|
this._resizeCanvasDrawingBuffer();
|
|
246
|
-
|
|
247
178
|
this._resizeViewport();
|
|
248
179
|
}
|
|
249
|
-
|
|
250
180
|
_setDisplay(display) {
|
|
251
181
|
if (this.display) {
|
|
252
|
-
this.display.
|
|
182
|
+
this.display.destroy();
|
|
253
183
|
this.display.animationLoop = null;
|
|
254
184
|
}
|
|
255
|
-
|
|
256
185
|
if (display) {
|
|
257
186
|
display.animationLoop = this;
|
|
258
187
|
}
|
|
259
|
-
|
|
260
188
|
this.display = display;
|
|
261
189
|
}
|
|
262
|
-
|
|
263
190
|
_requestAnimationFrame() {
|
|
264
191
|
if (!this._running) {
|
|
265
192
|
return;
|
|
266
193
|
}
|
|
267
|
-
|
|
268
194
|
this._animationFrameId = requestAnimationFrame(this._animationFrame.bind(this));
|
|
269
195
|
}
|
|
270
|
-
|
|
271
196
|
_cancelAnimationFrame() {
|
|
272
197
|
if (this._animationFrameId !== null) {
|
|
273
198
|
return;
|
|
274
199
|
}
|
|
275
|
-
|
|
276
200
|
cancelAnimationFrame(this._animationFrameId);
|
|
277
201
|
this._animationFrameId = null;
|
|
278
202
|
}
|
|
279
|
-
|
|
280
203
|
_animationFrame() {
|
|
281
204
|
if (!this._running) {
|
|
282
205
|
return;
|
|
283
206
|
}
|
|
284
|
-
|
|
285
207
|
this.redraw();
|
|
286
|
-
|
|
287
208
|
this._requestAnimationFrame();
|
|
288
209
|
}
|
|
289
|
-
|
|
290
|
-
_renderFrame(props) {
|
|
210
|
+
_renderFrame(animationProps) {
|
|
291
211
|
if (this.display) {
|
|
292
|
-
this.display._renderFrame(
|
|
293
|
-
|
|
212
|
+
this.display._renderFrame(animationProps);
|
|
294
213
|
return;
|
|
295
214
|
}
|
|
296
|
-
|
|
297
|
-
this.onRender(props);
|
|
215
|
+
this.props.onRender(this._getAnimationProps());
|
|
298
216
|
}
|
|
299
|
-
|
|
300
217
|
_clearNeedsRedraw() {
|
|
301
|
-
this.needsRedraw =
|
|
218
|
+
this.needsRedraw = false;
|
|
302
219
|
}
|
|
303
|
-
|
|
304
220
|
_setupFrame() {
|
|
305
221
|
this._resizeCanvasDrawingBuffer();
|
|
306
|
-
|
|
307
222
|
this._resizeViewport();
|
|
308
223
|
}
|
|
309
|
-
|
|
310
|
-
|
|
224
|
+
_initializeAnimationProps() {
|
|
225
|
+
var _this$device2;
|
|
226
|
+
if (!this.device) {
|
|
227
|
+
throw new Error('loop');
|
|
228
|
+
}
|
|
311
229
|
this.animationProps = {
|
|
312
230
|
animationLoop: this,
|
|
313
231
|
device: this.device,
|
|
314
|
-
canvas: this.device.canvasContext.canvas,
|
|
232
|
+
canvas: (_this$device2 = this.device) === null || _this$device2 === void 0 || (_this$device2 = _this$device2.canvasContext) === null || _this$device2 === void 0 ? void 0 : _this$device2.canvas,
|
|
233
|
+
renderPass: this.device.getDefaultRenderPass(),
|
|
315
234
|
timeline: this.timeline,
|
|
316
235
|
useDevicePixels: this.props.useDevicePixels,
|
|
317
|
-
needsRedraw:
|
|
236
|
+
needsRedraw: false,
|
|
318
237
|
width: 1,
|
|
319
238
|
height: 1,
|
|
320
239
|
aspect: 1,
|
|
@@ -326,47 +245,48 @@ export default class AnimationLoop {
|
|
|
326
245
|
_mousePosition: null
|
|
327
246
|
};
|
|
328
247
|
}
|
|
329
|
-
|
|
330
|
-
|
|
248
|
+
_getAnimationProps() {
|
|
249
|
+
if (!this.animationProps) {
|
|
250
|
+
throw new Error('animationProps');
|
|
251
|
+
}
|
|
252
|
+
return this.animationProps;
|
|
253
|
+
}
|
|
254
|
+
_updateAnimationProps() {
|
|
255
|
+
if (!this.animationProps) {
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
this.animationProps.renderPass = this.device.getDefaultRenderPass();
|
|
331
259
|
const {
|
|
332
260
|
width,
|
|
333
261
|
height,
|
|
334
262
|
aspect
|
|
335
263
|
} = this._getSizeAndAspect();
|
|
336
|
-
|
|
337
264
|
if (width !== this.animationProps.width || height !== this.animationProps.height) {
|
|
338
265
|
this.setNeedsRedraw('drawing buffer resized');
|
|
339
266
|
}
|
|
340
|
-
|
|
341
267
|
if (aspect !== this.animationProps.aspect) {
|
|
342
268
|
this.setNeedsRedraw('drawing buffer aspect changed');
|
|
343
269
|
}
|
|
344
|
-
|
|
345
270
|
this.animationProps.width = width;
|
|
346
271
|
this.animationProps.height = height;
|
|
347
272
|
this.animationProps.aspect = aspect;
|
|
348
273
|
this.animationProps.needsRedraw = this.needsRedraw;
|
|
349
274
|
this.animationProps.engineTime = Date.now() - this.animationProps.startTime;
|
|
350
|
-
|
|
351
275
|
if (this.timeline) {
|
|
352
276
|
this.timeline.update(this.animationProps.engineTime);
|
|
353
277
|
}
|
|
354
|
-
|
|
355
278
|
this.animationProps.tick = Math.floor(this.animationProps.time / 1000 * 60);
|
|
356
279
|
this.animationProps.tock++;
|
|
357
280
|
this.animationProps.time = this.timeline ? this.timeline.getTime() : this.animationProps.engineTime;
|
|
358
281
|
}
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
this.canvas = this.device.canvasContext.canvas;
|
|
366
|
-
|
|
367
|
-
this._createInfoDiv();
|
|
282
|
+
async _initDevice() {
|
|
283
|
+
var _this$device$canvasCo;
|
|
284
|
+
this.device = await this.props.device;
|
|
285
|
+
if (!this.device) {
|
|
286
|
+
throw new Error('No device provided');
|
|
287
|
+
}
|
|
288
|
+
this.canvas = ((_this$device$canvasCo = this.device.canvasContext) === null || _this$device$canvasCo === void 0 ? void 0 : _this$device$canvasCo.canvas) || null;
|
|
368
289
|
}
|
|
369
|
-
|
|
370
290
|
_createInfoDiv() {
|
|
371
291
|
if (this.canvas && this.props.onAddHTML) {
|
|
372
292
|
const wrapperDiv = document.createElement('div');
|
|
@@ -378,71 +298,72 @@ export default class AnimationLoop {
|
|
|
378
298
|
div.style.bottom = '10px';
|
|
379
299
|
div.style.width = '300px';
|
|
380
300
|
div.style.background = 'white';
|
|
381
|
-
|
|
301
|
+
if (this.canvas instanceof HTMLCanvasElement) {
|
|
302
|
+
wrapperDiv.appendChild(this.canvas);
|
|
303
|
+
}
|
|
382
304
|
wrapperDiv.appendChild(div);
|
|
383
305
|
const html = this.props.onAddHTML(div);
|
|
384
|
-
|
|
385
306
|
if (html) {
|
|
386
307
|
div.innerHTML = html;
|
|
387
308
|
}
|
|
388
309
|
}
|
|
389
310
|
}
|
|
390
|
-
|
|
391
311
|
_getSizeAndAspect() {
|
|
392
|
-
|
|
312
|
+
var _this$device3, _this$device4;
|
|
313
|
+
if (!this.device) {
|
|
314
|
+
return {
|
|
315
|
+
width: 1,
|
|
316
|
+
height: 1,
|
|
317
|
+
aspect: 1
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
const [width, height] = ((_this$device3 = this.device) === null || _this$device3 === void 0 || (_this$device3 = _this$device3.canvasContext) === null || _this$device3 === void 0 ? void 0 : _this$device3.getPixelSize()) || [1, 1];
|
|
393
321
|
let aspect = 1;
|
|
394
|
-
const canvas = this.device.canvasContext.canvas;
|
|
395
|
-
|
|
322
|
+
const canvas = (_this$device4 = this.device) === null || _this$device4 === void 0 || (_this$device4 = _this$device4.canvasContext) === null || _this$device4 === void 0 ? void 0 : _this$device4.canvas;
|
|
396
323
|
if (canvas && canvas.clientHeight) {
|
|
397
324
|
aspect = canvas.clientWidth / canvas.clientHeight;
|
|
398
325
|
} else if (width > 0 && height > 0) {
|
|
399
326
|
aspect = width / height;
|
|
400
327
|
}
|
|
401
|
-
|
|
402
328
|
return {
|
|
403
329
|
width,
|
|
404
330
|
height,
|
|
405
331
|
aspect
|
|
406
332
|
};
|
|
407
333
|
}
|
|
408
|
-
|
|
409
334
|
_resizeViewport() {
|
|
410
335
|
if (this.props.autoResizeViewport && this.device.gl) {
|
|
411
336
|
this.device.gl.viewport(0, 0, this.device.gl.drawingBufferWidth, this.device.gl.drawingBufferHeight);
|
|
412
337
|
}
|
|
413
338
|
}
|
|
414
|
-
|
|
415
339
|
_resizeCanvasDrawingBuffer() {
|
|
416
340
|
if (this.props.autoResizeDrawingBuffer) {
|
|
417
|
-
|
|
341
|
+
var _this$device5;
|
|
342
|
+
(_this$device5 = this.device) === null || _this$device5 === void 0 || (_this$device5 = _this$device5.canvasContext) === null || _this$device5 === void 0 ? void 0 : _this$device5.resize({
|
|
418
343
|
useDevicePixels: this.props.useDevicePixels
|
|
419
344
|
});
|
|
420
345
|
}
|
|
421
346
|
}
|
|
422
|
-
|
|
423
347
|
_beginTimers() {
|
|
424
348
|
this.frameRate.timeEnd();
|
|
425
349
|
this.frameRate.timeStart();
|
|
426
350
|
}
|
|
427
|
-
|
|
428
351
|
_endTimers() {
|
|
429
352
|
this.cpuTime.timeEnd();
|
|
430
353
|
}
|
|
431
|
-
|
|
432
354
|
_startEventHandling() {
|
|
433
355
|
if (this.canvas) {
|
|
434
|
-
this.canvas.addEventListener('mousemove', this._onMousemove);
|
|
435
|
-
this.canvas.addEventListener('mouseleave', this._onMouseleave);
|
|
356
|
+
this.canvas.addEventListener('mousemove', this._onMousemove.bind(this));
|
|
357
|
+
this.canvas.addEventListener('mouseleave', this._onMouseleave.bind(this));
|
|
436
358
|
}
|
|
437
359
|
}
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
360
|
+
_onMousemove(event) {
|
|
361
|
+
if (event instanceof MouseEvent) {
|
|
362
|
+
this._getAnimationProps()._mousePosition = [event.offsetX, event.offsetY];
|
|
363
|
+
}
|
|
441
364
|
}
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
this.animationProps._mousePosition = null;
|
|
365
|
+
_onMouseleave(event) {
|
|
366
|
+
this._getAnimationProps()._mousePosition = null;
|
|
445
367
|
}
|
|
446
|
-
|
|
447
368
|
}
|
|
448
369
|
//# sourceMappingURL=animation-loop.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"animation-loop.js","names":["luma","requestAnimationFrame","cancelAnimationFrame","Stats","statIdCounter","DEFAULT_ANIMATION_LOOP_PROPS","device","onAddHTML","onInitialize","onRender","onFinalize","onError","error","console","stats","get","concat","useDevicePixels","autoResizeViewport","autoResizeDrawingBuffer","AnimationLoop","constructor","props","_defineProperty","Error","id","cpuTime","gpuTime","frameRate","setProps","start","bind","stop","_onMousemove","_onMouseleave","destroy","_setDisplay","delete","setNeedsRedraw","reason","needsRedraw","_running","appContext","_initialized","_initDevice","_initialize","_getAnimationProps","_cancelAnimationFrame","_requestAnimationFrame","err","redraw","_this$device","isLost","_beginTimers","_setupFrame","_updateAnimationProps","_renderFrame","_clearNeedsRedraw","_resolveNextFrame","_nextFramePromise","_endTimers","animationProps","attachTimeline","timeline","detachTimeline","waitForRender","Promise","resolve","toDataURL","canvas","HTMLCanvasElement","_startEventHandling","_initializeAnimationProps","_resizeCanvasDrawingBuffer","_resizeViewport","display","animationLoop","_animationFrameId","_animationFrame","_this$device2","canvasContext","renderPass","getDefaultRenderPass","width","height","aspect","time","startTime","Date","now","engineTime","tick","tock","_mousePosition","_getSizeAndAspect","update","Math","floor","getTime","_this$device$canvasCo","_createInfoDiv","wrapperDiv","document","createElement","body","appendChild","style","position","div","left","bottom","background","html","innerHTML","_this$device3","_this$device4","getPixelSize","clientHeight","clientWidth","gl","viewport","drawingBufferWidth","drawingBufferHeight","_this$device5","resize","timeEnd","timeStart","addEventListener","event","MouseEvent","offsetX","offsetY"],"sources":["../../src/animation-loop/animation-loop.ts"],"sourcesContent":["// luma.gl, MIT license\n\nimport {luma, Device} from '@luma.gl/core';\nimport {requestAnimationFrame, cancelAnimationFrame} from '@luma.gl/core';\nimport {Timeline} from '../animation/timeline';\nimport {AnimationProps} from './animation-props';\nimport {Stats, Stat} from '@probe.gl/stats';\n\nlet statIdCounter = 0;\n\n/** AnimationLoop properties */\nexport type AnimationLoopProps = {\n device: Device | Promise<Device>;\n\n onAddHTML?: (div: HTMLDivElement) => string; // innerHTML\n onInitialize?: (animationProps: AnimationProps) => Promise<unknown>;\n onRender?: (animationProps: AnimationProps) => unknown;\n onFinalize?: (animationProps: AnimationProps) => void;\n onError?: (reason: Error) => void;\n\n stats?: Stats;\n\n // view parameters - TODO move to CanvasContext?\n autoResizeViewport?: boolean;\n autoResizeDrawingBuffer?: boolean;\n useDevicePixels?: number | boolean;\n};\n\nexport type MutableAnimationLoopProps = {\n // view parameters\n autoResizeViewport?: boolean;\n autoResizeDrawingBuffer?: boolean;\n useDevicePixels?: number | boolean;\n}\n\n\nconst DEFAULT_ANIMATION_LOOP_PROPS: Required<AnimationLoopProps> = {\n device: null!,\n\n onAddHTML: () => '',\n onInitialize: async () => { return null; },\n onRender: () => {},\n onFinalize: () => {},\n onError: (error) => console.error(error), // eslint-disable-line no-console\n\n stats: luma.stats.get(`animation-loop-${statIdCounter++}`),\n\n // view parameters\n useDevicePixels: true,\n autoResizeViewport: false,\n autoResizeDrawingBuffer: false,\n};\n\n/** Convenient animation loop */\nexport class AnimationLoop {\n device: Device | null = null;\n canvas: HTMLCanvasElement | OffscreenCanvas | null = null;\n\n props: Required<AnimationLoopProps>;\n animationProps: AnimationProps | null = null;\n timeline: Timeline | null = null;\n stats: Stats;\n cpuTime: Stat;\n gpuTime: Stat;\n frameRate: Stat;\n\n display: any;\n\n needsRedraw: string | false = 'initialized';\n\n _initialized: boolean = false;\n _running: boolean = false;\n _animationFrameId: any = null;\n _nextFramePromise: Promise<AnimationLoop> | null = null;\n _resolveNextFrame: ((animationLoop: AnimationLoop) => void) | null = null;\n _cpuStartTime: number = 0;\n\n // _gpuTimeQuery: Query | null = null;\n\n /*\n * @param {HTMLCanvasElement} canvas - if provided, width and height will be passed to context\n */\n constructor(props: AnimationLoopProps) {\n this.props = {...DEFAULT_ANIMATION_LOOP_PROPS, ...props};\n props = this.props;\n\n if (!props.device) {\n throw new Error('No device provided');\n }\n\n const {useDevicePixels = true} = this.props;\n\n // state\n this.stats = props.stats || new Stats({id: 'animation-loop-stats'});\n this.cpuTime = this.stats.get('CPU Time');\n this.gpuTime = this.stats.get('GPU Time');\n this.frameRate = this.stats.get('Frame Rate');\n\n this.setProps({\n autoResizeViewport: props.autoResizeViewport,\n autoResizeDrawingBuffer: props.autoResizeDrawingBuffer,\n useDevicePixels\n });\n\n // Bind methods\n this.start = this.start.bind(this);\n this.stop = this.stop.bind(this);\n\n this._onMousemove = this._onMousemove.bind(this);\n this._onMouseleave = this._onMouseleave.bind(this);\n }\n\n destroy(): void {\n this.stop();\n this._setDisplay(null);\n }\n\n /** @deprecated Use .destroy() */\n delete(): void {\n this.destroy();\n }\n\n setNeedsRedraw(reason: string): this {\n this.needsRedraw = this.needsRedraw || reason;\n return this;\n }\n\n // TODO - move to CanvasContext\n setProps(props: MutableAnimationLoopProps): this {\n if ('autoResizeViewport' in props) {\n this.props.autoResizeViewport = props.autoResizeViewport || false;\n }\n if ('autoResizeDrawingBuffer' in props) {\n this.props.autoResizeDrawingBuffer = props.autoResizeDrawingBuffer || false;\n }\n if ('useDevicePixels' in props) {\n this.props.useDevicePixels = props.useDevicePixels || false;\n }\n return this;\n }\n\n /** Starts a render loop if not already running */\n async start() {\n if (this._running) {\n return this;\n }\n this._running = true;\n\n try {\n // check that we haven't been stopped\n if (!this._running) {\n return null;\n }\n\n let appContext;\n if (!this._initialized) {\n this._initialized = true;\n // Create the WebGL context\n await this._initDevice();\n this._initialize();\n\n // Note: onIntialize can return a promise (e.g. in case app needs to load resources)\n await this.props.onInitialize(this._getAnimationProps());\n }\n\n // check that we haven't been stopped\n if (!this._running) {\n return null;\n }\n\n // Start the loop\n if (appContext !== false) {\n // cancel any pending renders to ensure only one loop can ever run\n this._cancelAnimationFrame();\n this._requestAnimationFrame();\n }\n\n return this;\n } catch (err: unknown) {\n const error = err instanceof Error ? err : new Error('Unknown error')\n this.props.onError(error);\n // this._running = false; // TODO\n throw error;\n }\n }\n\n /** Explicitly draw a frame */\n redraw(): this {\n if (this.device?.isLost) {\n return this;\n }\n\n this._beginTimers();\n\n this._setupFrame();\n this._updateAnimationProps();\n\n this._renderFrame(this._getAnimationProps());\n\n // clear needsRedraw flag\n this._clearNeedsRedraw();\n\n if (this._resolveNextFrame) {\n this._resolveNextFrame(this);\n this._nextFramePromise = null;\n this._resolveNextFrame = null;\n }\n\n this._endTimers();\n\n return this;\n }\n\n // Stops a render loop if already running, finalizing\n stop() {\n // console.debug(`Stopping ${this.constructor.name}`);\n if (this._running) {\n // call callback\n // If stop is called immediately, we can end up in a state where props haven't been initialized...\n if (this.animationProps) {\n this.props.onFinalize(this.animationProps);\n }\n\n this._cancelAnimationFrame();\n this._nextFramePromise = null;\n this._resolveNextFrame = null;\n this._running = false;\n }\n return this;\n }\n\n attachTimeline(timeline: Timeline): Timeline {\n this.timeline = timeline;\n return this.timeline;\n }\n\n detachTimeline(): void {\n this.timeline = null;\n }\n\n waitForRender(): Promise<AnimationLoop> {\n this.setNeedsRedraw('waitForRender');\n\n if (!this._nextFramePromise) {\n this._nextFramePromise = new Promise((resolve) => {\n this._resolveNextFrame = resolve;\n });\n }\n return this._nextFramePromise;\n }\n\n async toDataURL(): Promise<string> {\n this.setNeedsRedraw('toDataURL');\n await this.waitForRender();\n if (this.canvas instanceof HTMLCanvasElement) {\n return this.canvas.toDataURL();\n }\n throw new Error('OffscreenCanvas');\n }\n\n // PRIVATE METHODS\n\n _initialize() {\n this._startEventHandling();\n\n // Initialize the callback data\n this._initializeAnimationProps();\n this._updateAnimationProps();\n\n // Default viewport setup, in case onInitialize wants to render\n this._resizeCanvasDrawingBuffer();\n this._resizeViewport();\n\n // this._gpuTimeQuery = Query.isSupported(this.gl, ['timers']) ? new Query(this.gl) : null;\n }\n\n _setDisplay(display: any) {\n if (this.display) {\n this.display.destroy();\n this.display.animationLoop = null;\n }\n\n // store animation loop on the display\n if (display) {\n display.animationLoop = this;\n }\n\n this.display = display;\n }\n\n _requestAnimationFrame() {\n if (!this._running) {\n return;\n }\n\n // VR display has a separate animation frame to sync with headset\n // TODO WebVR API discontinued, replaced by WebXR: https://immersive-web.github.io/webxr/\n // See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/requestAnimationFrame\n // if (this.display && this.display.requestAnimationFrame) {\n // this._animationFrameId = this.display.requestAnimationFrame(this._animationFrame.bind(this));\n // }\n this._animationFrameId = requestAnimationFrame(this._animationFrame.bind(this));\n }\n\n _cancelAnimationFrame() {\n if (this._animationFrameId !== null) {\n return;\n }\n\n // VR display has a separate animation frame to sync with headset\n // TODO WebVR API discontinued, replaced by WebXR: https://immersive-web.github.io/webxr/\n // See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/requestAnimationFrame\n // if (this.display && this.display.cancelAnimationFrame) {\n // this.display.cancelAnimationFrame(this._animationFrameId);\n // }\n cancelAnimationFrame(this._animationFrameId);\n this._animationFrameId = null;\n }\n\n _animationFrame() {\n if (!this._running) {\n return;\n }\n this.redraw();\n this._requestAnimationFrame();\n }\n\n // Called on each frame, can be overridden to call onRender multiple times\n // to support e.g. stereoscopic rendering\n _renderFrame(animationProps: AnimationProps) {\n // Allow e.g. VR display to render multiple frames.\n if (this.display) {\n this.display._renderFrame(animationProps);\n return;\n }\n\n // call callback\n this.props.onRender(this._getAnimationProps());\n // end callback\n }\n\n _clearNeedsRedraw() {\n this.needsRedraw = false;\n }\n\n _setupFrame() {\n this._resizeCanvasDrawingBuffer();\n this._resizeViewport();\n }\n\n // Initialize the object that will be passed to app callbacks\n _initializeAnimationProps() {\n if (!this.device) {\n throw new Error('loop');\n }\n this.animationProps = {\n animationLoop: this,\n\n device: this.device,\n canvas: this.device?.canvasContext?.canvas,\n renderPass: this.device.getDefaultRenderPass(),\n timeline: this.timeline,\n\n // Initial values\n useDevicePixels: this.props.useDevicePixels,\n needsRedraw: false,\n\n // Placeholders\n width: 1,\n height: 1,\n aspect: 1,\n\n // Animation props\n time: 0,\n startTime: Date.now(),\n engineTime: 0,\n tick: 0,\n tock: 0,\n\n // Experimental\n _mousePosition: null // Event props\n };\n }\n\n _getAnimationProps(): AnimationProps {\n if (!this.animationProps) {\n throw new Error('animationProps');\n }\n return this.animationProps;\n }\n\n // Update the context object that will be passed to app callbacks\n _updateAnimationProps(): void {\n if (!this.animationProps) {\n return;\n }\n\n this.animationProps.renderPass = this.device.getDefaultRenderPass();\n\n const {width, height, aspect} = this._getSizeAndAspect();\n if (width !== this.animationProps.width || height !== this.animationProps.height) {\n this.setNeedsRedraw('drawing buffer resized');\n }\n if (aspect !== this.animationProps.aspect) {\n this.setNeedsRedraw('drawing buffer aspect changed');\n }\n\n this.animationProps.width = width;\n this.animationProps.height = height;\n this.animationProps.aspect = aspect;\n\n this.animationProps.needsRedraw = this.needsRedraw;\n\n // Update time properties\n this.animationProps.engineTime = Date.now() - this.animationProps.startTime;\n\n if (this.timeline) {\n this.timeline.update(this.animationProps.engineTime);\n }\n\n this.animationProps.tick = Math.floor((this.animationProps.time / 1000) * 60);\n this.animationProps.tock++;\n\n // For back compatibility\n this.animationProps.time = this.timeline\n ? this.timeline.getTime()\n : this.animationProps.engineTime;\n }\n\n /** Wait for supplied device */\n async _initDevice() {\n this.device = await this.props.device;\n if (!this.device) {\n throw new Error('No device provided');\n }\n this.canvas = this.device.canvasContext?.canvas || null;\n // this._createInfoDiv();\n }\n\n _createInfoDiv() {\n if (this.canvas && this.props.onAddHTML) {\n const wrapperDiv = document.createElement('div');\n document.body.appendChild(wrapperDiv);\n wrapperDiv.style.position = 'relative';\n const div = document.createElement('div');\n div.style.position = 'absolute';\n div.style.left = '10px';\n div.style.bottom = '10px';\n div.style.width = '300px';\n div.style.background = 'white';\n if (this.canvas instanceof HTMLCanvasElement) {\n wrapperDiv.appendChild(this.canvas);\n }\n wrapperDiv.appendChild(div);\n const html = this.props.onAddHTML(div);\n if (html) {\n div.innerHTML = html;\n }\n }\n }\n\n _getSizeAndAspect(): {width: number; height: number; aspect: number} {\n if (!this.device) {\n return {width: 1, height: 1, aspect: 1};\n }\n // https://webglfundamentals.org/webgl/lessons/webgl-resizing-the-canvas.html\n const [width, height] = this.device?.canvasContext?.getPixelSize() || [1, 1];\n\n // https://webglfundamentals.org/webgl/lessons/webgl-anti-patterns.html\n let aspect = 1;\n const canvas = this.device?.canvasContext?.canvas;\n\n // @ts-expect-error\n if (canvas && canvas.clientHeight) {\n // @ts-expect-error\n aspect = canvas.clientWidth / canvas.clientHeight;\n } else if (width > 0 && height > 0) {\n aspect = width / height;\n }\n\n return {width, height, aspect};\n }\n\n /** Default viewport setup */\n _resizeViewport() {\n // @ts-expect-error Expose on canvasContext\n if (this.props.autoResizeViewport && this.device.gl) {\n // @ts-expect-error Expose canvasContext\n this.device.gl.viewport(0, 0, this.device.gl.drawingBufferWidth, this.device.gl.drawingBufferHeight);\n }\n }\n\n /**\n * Resize the render buffer of the canvas to match canvas client size\n * Optionally multiplying with devicePixel ratio\n */\n _resizeCanvasDrawingBuffer() {\n if (this.props.autoResizeDrawingBuffer) {\n this.device?.canvasContext?.resize({useDevicePixels: this.props.useDevicePixels});\n }\n }\n\n _beginTimers() {\n this.frameRate.timeEnd();\n this.frameRate.timeStart();\n\n // Check if timer for last frame has completed.\n // GPU timer results are never available in the same\n // frame they are captured.\n // if (\n // this._gpuTimeQuery &&\n // this._gpuTimeQuery.isResultAvailable() &&\n // !this._gpuTimeQuery.isTimerDisjoint()\n // ) {\n // this.stats.get('GPU Time').addTime(this._gpuTimeQuery.getTimerMilliseconds());\n // }\n\n // if (this._gpuTimeQuery) {\n // // GPU time query start\n // this._gpuTimeQuery.beginTimeElapsedQuery();\n // }\n\n // this.cpuTime.timeStart();\n }\n\n _endTimers() {\n this.cpuTime.timeEnd();\n\n // if (this._gpuTimeQuery) {\n // // GPU time query end. Results will be available on next frame.\n // this._gpuTimeQuery.end();\n // }\n }\n\n // Event handling\n\n _startEventHandling() {\n if (this.canvas) {\n this.canvas.addEventListener('mousemove', this._onMousemove.bind(this));\n this.canvas.addEventListener('mouseleave', this._onMouseleave.bind(this));\n }\n }\n\n _onMousemove(event: Event) {\n if (event instanceof MouseEvent) {\n this._getAnimationProps()._mousePosition = [event.offsetX, event.offsetY];\n }\n }\n\n _onMouseleave(event: Event) {\n this._getAnimationProps()._mousePosition = null;\n }\n}\n"],"mappings":";AAEA,SAAQA,IAAI,QAAe,eAAe;AAC1C,SAAQC,qBAAqB,EAAEC,oBAAoB,QAAO,eAAe;AAGzE,SAAQC,KAAK,QAAa,iBAAiB;AAE3C,IAAIC,aAAa,GAAG,CAAC;AA4BrB,MAAMC,4BAA0D,GAAG;EACjEC,MAAM,EAAE,IAAK;EAEbC,SAAS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AG;IACpB,IAAI,IAAI,CAACF,MAAM,EAAE;MACf,IAAI,CAACA,MAAM,CAAC0D,gBAAgB,CAAC,WAAW,EAAE,IAAI,CAAC9F,YAAY,CAACF,IAAI,CAAC,IAAI,CAAC,CAAC;MACvE,IAAI,CAACsC,MAAM,CAAC0D,gBAAgB,CAAC,YAAY,EAAE,IAAI,CAAC7F,aAAa,CAACH,IAAI,CAAC,IAAI,CAAC,CAAC;IAC3E;EACF;EAEAE,YAAYA,CAAC+F,KAAY,EAAE;IACzB,IAAIA,KAAK,YAAYC,UAAU,EAAE;MAC/B,IAAI,CAACnF,kBAAkB,CAAC,CAAC,CAAC+C,cAAc,GAAG,CAACmC,KAAK,CAACE,OAAO,EAAEF,KAAK,CAACG,OAAO,CAAC;IAC3E;EACF;EAEAjG,aAAaA,CAAC8F,KAAY,EAAE;IAC1B,IAAI,CAAClF,kBAAkB,CAAC,CAAC,CAAC+C,cAAc,GAAG,IAAI;EACjD;AACF"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
import { Device } from '@luma.gl/api';
|
|
1
|
+
import { Device, RenderPass } from '@luma.gl/core';
|
|
3
2
|
import { Timeline } from '../animation/timeline';
|
|
4
|
-
import type AnimationLoop from './animation-loop';
|
|
3
|
+
import type { AnimationLoop } from './animation-loop';
|
|
5
4
|
/** Properties passed to every render frame */
|
|
6
|
-
export
|
|
5
|
+
export type AnimationProps = {
|
|
7
6
|
device: Device;
|
|
7
|
+
renderPass: RenderPass;
|
|
8
8
|
animationLoop: AnimationLoop;
|
|
9
9
|
/** @todo Should be canvasContext */
|
|
10
10
|
canvas: HTMLCanvasElement | OffscreenCanvas;
|
|
@@ -17,8 +17,8 @@ export declare type AnimationProps = {
|
|
|
17
17
|
engineTime: number;
|
|
18
18
|
tick: number;
|
|
19
19
|
tock: number;
|
|
20
|
-
needsRedraw?: string;
|
|
21
|
-
timeline: Timeline;
|
|
22
|
-
_mousePosition?: [number, number];
|
|
20
|
+
needsRedraw?: string | false;
|
|
21
|
+
timeline: Timeline | null;
|
|
22
|
+
_mousePosition?: [number, number] | null;
|
|
23
23
|
};
|
|
24
24
|
//# sourceMappingURL=animation-props.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"animation-props.d.ts","sourceRoot":"","sources":["../../src/animation-loop/animation-props.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAE,UAAU,EAAC,MAAM,eAAe,CAAC;AACjD,OAAO,EAAC,QAAQ,EAAC,MAAM,uBAAuB,CAAA;AAC9C,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,kBAAkB,CAAC;AAEpD,+CAA+C;AAC/C,MAAM,MAAM,cAAc,GAAG;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,UAAU,CAAC;IACvB,aAAa,EAAE,aAAa,CAAC;IAE7B,oCAAoC;IACpC,MAAM,EAAE,iBAAiB,GAAG,eAAe,CAAC;IAC5C,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IAGf,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IAGb,WAAW,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IAE7B,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAC;IAG1B,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC;CAC1C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"animation-props.js","names":[],"sources":["../../src/animation-loop/animation-props.ts"],"sourcesContent":["import {Device, RenderPass} from '@luma.gl/core';\nimport {Timeline} from '../animation/timeline'\nimport type {AnimationLoop} from './animation-loop';\n\n/** Properties passed to every render frame */\nexport type AnimationProps = {\n device: Device;\n renderPass: RenderPass;\n animationLoop: AnimationLoop;\n\n /** @todo Should be canvasContext */\n canvas: HTMLCanvasElement | OffscreenCanvas;\n useDevicePixels: number | boolean;\n width: number;\n height: number;\n aspect: number;\n\n // Animation props\n time: number;\n startTime: number;\n engineTime: number;\n tick: number;\n tock: number;\n\n // Initial values\n needsRedraw?: string | false;\n\n timeline: Timeline | null;\n\n // Experimental\n _mousePosition?: [number, number] | null; // [offsetX, offsetY],\n};\n"],"mappings":""}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { AnimationLoopTemplate } from './render-loop';
|
|
2
|
+
import { AnimationLoop, AnimationLoopProps } from './animation-loop';
|
|
3
|
+
export type MakeAnimationLoopProps = Omit<AnimationLoopProps, 'onCreateDevice' | 'onInitialize' | 'onRedraw' | 'onFinalize'>;
|
|
4
|
+
/** Instantiates and runs the render loop */
|
|
5
|
+
export declare function makeAnimationLoop(AnimationLoopTemplateCtor: typeof AnimationLoopTemplate, props?: MakeAnimationLoopProps): AnimationLoop;
|
|
6
|
+
//# sourceMappingURL=make-animation-loop.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"make-animation-loop.d.ts","sourceRoot":"","sources":["../../src/animation-loop/make-animation-loop.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,qBAAqB,EAAC,MAAM,eAAe,CAAA;AACnD,OAAO,EAAC,aAAa,EAAE,kBAAkB,EAAC,MAAM,kBAAkB,CAAA;AAGlE,MAAM,MAAM,sBAAsB,GAAG,IAAI,CAAC,kBAAkB,EAAE,gBAAgB,GAAG,cAAc,GAAG,UAAU,GAAG,YAAY,CAAC,CAAC;AAE7H,4CAA4C;AAC5C,wBAAgB,iBAAiB,CAAC,yBAAyB,EAAE,OAAO,qBAAqB,EAAE,KAAK,CAAC,EAAE,sBAAsB,GAAG,aAAa,CAkCxI"}
|