@luma.gl/test-utils 9.0.0-alpha.21 → 9.0.0-alpha.24
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/engine/classic-animation-loop.d.ts +135 -0
- package/dist/engine/classic-animation-loop.d.ts.map +1 -0
- package/dist/engine/classic-animation-loop.js +435 -0
- package/dist/engine/classic-animation-loop.js.map +1 -0
- package/dist/index.cjs +461 -14
- package/dist/performance-test-runner.d.ts +1 -1
- package/dist/performance-test-runner.d.ts.map +1 -1
- package/dist/snapshot-test-runner.d.ts +2 -3
- package/dist/snapshot-test-runner.d.ts.map +1 -1
- package/dist/snapshot-test-runner.js +0 -2
- package/dist/snapshot-test-runner.js.map +1 -1
- package/dist/test-runner.d.ts +13 -7
- package/dist/test-runner.d.ts.map +1 -1
- package/dist/test-runner.js +16 -9
- package/dist/test-runner.js.map +1 -1
- package/package.json +9 -5
- package/src/engine/classic-animation-loop.ts +714 -0
- package/src/snapshot-test-runner.ts +2 -1
- package/src/test-runner.ts +30 -17
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { Device, DeviceProps } from '@luma.gl/api';
|
|
2
|
+
import { Timeline, AnimationProps } from '@luma.gl/engine';
|
|
3
|
+
import { Stats, Stat } from '@probe.gl/stats';
|
|
4
|
+
type ContextProps = DeviceProps;
|
|
5
|
+
/**
|
|
6
|
+
* Classic Animation Props.
|
|
7
|
+
* Contain a number of deprecated fields
|
|
8
|
+
* @deprecated Use new AnimationLoop in `@luma.gl/engine`
|
|
9
|
+
*/
|
|
10
|
+
export type ClassicAnimationProps = AnimationProps & {
|
|
11
|
+
animationLoop: ClassicAnimationLoop;
|
|
12
|
+
/** @deprecated Use .device */
|
|
13
|
+
stop: () => ClassicAnimationLoop;
|
|
14
|
+
/** @deprecated Use .device */
|
|
15
|
+
gl: WebGLRenderingContext;
|
|
16
|
+
/** @deprecated Will be removed */
|
|
17
|
+
framebuffer: unknown;
|
|
18
|
+
/** @deprecated Use .timeline */
|
|
19
|
+
_timeline: Timeline;
|
|
20
|
+
/** @deprecated Use .animationLoop */
|
|
21
|
+
_loop: ClassicAnimationLoop;
|
|
22
|
+
/** @deprecated Use .animationLoop */
|
|
23
|
+
_animationLoop: ClassicAnimationLoop;
|
|
24
|
+
};
|
|
25
|
+
/** ClassicAnimationLoop properties */
|
|
26
|
+
export type ClassicAnimationLoopProps = {
|
|
27
|
+
onCreateDevice?: (props: DeviceProps) => Promise<Device>;
|
|
28
|
+
onCreateContext?: (props: ContextProps) => WebGLRenderingContext;
|
|
29
|
+
onAddHTML?: (div: HTMLDivElement) => string;
|
|
30
|
+
onInitialize?: (animationProps: ClassicAnimationProps) => {} | void | Promise<{} | void>;
|
|
31
|
+
onRender?: (animationProps: ClassicAnimationProps) => void;
|
|
32
|
+
onFinalize?: (animationProps: ClassicAnimationProps) => void;
|
|
33
|
+
onError?: (reason: any) => void;
|
|
34
|
+
stats?: Stats;
|
|
35
|
+
device?: Device;
|
|
36
|
+
glOptions?: ContextProps;
|
|
37
|
+
autoResizeViewport?: boolean;
|
|
38
|
+
autoResizeDrawingBuffer?: boolean;
|
|
39
|
+
useDevicePixels?: number | boolean;
|
|
40
|
+
/** @deprecated Use .device */
|
|
41
|
+
gl?: WebGLRenderingContext | null;
|
|
42
|
+
/** @deprecated Will be removed */
|
|
43
|
+
createFramebuffer?: boolean;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Convenient animation loop
|
|
47
|
+
* @deprecated Use `@luma.gl/engine` AnimationLoop
|
|
48
|
+
*/
|
|
49
|
+
export declare class ClassicAnimationLoop {
|
|
50
|
+
device: Device;
|
|
51
|
+
canvas?: HTMLCanvasElement | OffscreenCanvas;
|
|
52
|
+
props: Required<ClassicAnimationLoopProps>;
|
|
53
|
+
animationProps: ClassicAnimationProps;
|
|
54
|
+
timeline: Timeline;
|
|
55
|
+
stats: Stats;
|
|
56
|
+
cpuTime: Stat;
|
|
57
|
+
gpuTime: Stat;
|
|
58
|
+
frameRate: Stat;
|
|
59
|
+
display: any;
|
|
60
|
+
needsRedraw: string | null;
|
|
61
|
+
_initialized: boolean;
|
|
62
|
+
_running: boolean;
|
|
63
|
+
_animationFrameId: any;
|
|
64
|
+
_pageLoadPromise: Promise<{}> | null;
|
|
65
|
+
_nextFramePromise: Promise<ClassicAnimationLoop> | null;
|
|
66
|
+
_resolveNextFrame: ((loop: ClassicAnimationLoop) => void) | null;
|
|
67
|
+
_cpuStartTime: number;
|
|
68
|
+
/** @deprecated */
|
|
69
|
+
gl: WebGLRenderingContext;
|
|
70
|
+
constructor(props?: ClassicAnimationLoopProps);
|
|
71
|
+
destroy(): void;
|
|
72
|
+
/** @deprecated Use .destroy() */
|
|
73
|
+
delete(): void;
|
|
74
|
+
setNeedsRedraw(reason: string): this;
|
|
75
|
+
setProps(props: ClassicAnimationLoopProps): this;
|
|
76
|
+
start(opts?: {}): this;
|
|
77
|
+
/** Starts a render loop if not already running */
|
|
78
|
+
_start(props: any): Promise<this>;
|
|
79
|
+
/** Explicitly draw a frame */
|
|
80
|
+
redraw(): this;
|
|
81
|
+
stop(): this;
|
|
82
|
+
attachTimeline(timeline: Timeline): Timeline;
|
|
83
|
+
detachTimeline(): void;
|
|
84
|
+
waitForRender(): Promise<ClassicAnimationLoop>;
|
|
85
|
+
toDataURL(): Promise<string>;
|
|
86
|
+
isContextLost(): boolean;
|
|
87
|
+
onCreateDevice(deviceProps: DeviceProps): Promise<Device>;
|
|
88
|
+
onInitialize(animationProps: ClassicAnimationProps): {} | void;
|
|
89
|
+
onRender(animationProps: ClassicAnimationProps): void;
|
|
90
|
+
onFinalize(animationProps: ClassicAnimationProps): void;
|
|
91
|
+
/** @deprecated Use .onCreateDevice() */
|
|
92
|
+
onCreateContext(props: ContextProps): WebGLRenderingContext;
|
|
93
|
+
/** @deprecated */
|
|
94
|
+
getHTMLControlValue(id: any, defaultValue?: number): number;
|
|
95
|
+
_initialize(props: ClassicAnimationLoopProps): void;
|
|
96
|
+
_getPageLoadPromise(): Promise<{}>;
|
|
97
|
+
_setDisplay(display: any): void;
|
|
98
|
+
_requestAnimationFrame(): void;
|
|
99
|
+
_cancelAnimationFrame(): void;
|
|
100
|
+
_animationFrame(): void;
|
|
101
|
+
_renderFrame(props: ClassicAnimationProps): void;
|
|
102
|
+
_clearNeedsRedraw(): void;
|
|
103
|
+
_setupFrame(): void;
|
|
104
|
+
_initializeCallbackData(): void;
|
|
105
|
+
_updateCallbackData(): void;
|
|
106
|
+
_finalizeCallbackData(): void;
|
|
107
|
+
/** Add application's data to the app context object */
|
|
108
|
+
_addCallbackData(appContext: any): void;
|
|
109
|
+
/** Either uses supplied or existing context, or calls provided callback to create one */
|
|
110
|
+
_createDevice(props: DeviceProps): Promise<void>;
|
|
111
|
+
_createInfoDiv(): void;
|
|
112
|
+
_getSizeAndAspect(): {
|
|
113
|
+
width: number;
|
|
114
|
+
height: number;
|
|
115
|
+
aspect: number;
|
|
116
|
+
};
|
|
117
|
+
/** Default viewport setup */
|
|
118
|
+
_resizeViewport(): void;
|
|
119
|
+
/**
|
|
120
|
+
* Resize the render buffer of the canvas to match canvas client size
|
|
121
|
+
* Optionally multiplying with devicePixel ratio
|
|
122
|
+
*/
|
|
123
|
+
_resizeCanvasDrawingBuffer(): void;
|
|
124
|
+
_beginTimers(): void;
|
|
125
|
+
_endTimers(): void;
|
|
126
|
+
_startEventHandling(): void;
|
|
127
|
+
_onMousemove(e: any): void;
|
|
128
|
+
_onMouseleave(e: any): void;
|
|
129
|
+
/** @deprecated */
|
|
130
|
+
_createFramebuffer(): void;
|
|
131
|
+
/** @deprecated */
|
|
132
|
+
_resizeFramebuffer(): void;
|
|
133
|
+
}
|
|
134
|
+
export {};
|
|
135
|
+
//# sourceMappingURL=classic-animation-loop.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"classic-animation-loop.d.ts","sourceRoot":"","sources":["../../src/engine/classic-animation-loop.ts"],"names":[],"mappings":"AAEA,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WV,mBAAmB;IAQnB,YAAY,CAAC,CAAC,KAAA;IAGd,aAAa,CAAC,CAAC,KAAA;IAMf,kBAAkB;IAClB,kBAAkB;IAOlB,kBAAkB;IAClB,kBAAkB;CAQnB"}
|
|
@@ -0,0 +1,435 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
import { luma, log, requestAnimationFrame, cancelAnimationFrame } from '@luma.gl/api';
|
|
3
|
+
import { isBrowser } from '@probe.gl/env';
|
|
4
|
+
import { isWebGL, resetParameters } from '@luma.gl/webgl';
|
|
5
|
+
const isPage = isBrowser() && typeof document !== 'undefined';
|
|
6
|
+
function getHTMLCanvasElement(canvas) {
|
|
7
|
+
return typeof HTMLCanvasElement !== 'undefined' && canvas instanceof HTMLCanvasElement ? canvas : null;
|
|
8
|
+
}
|
|
9
|
+
let statIdCounter = 0;
|
|
10
|
+
const DEFAULT_CLASSIC_ANIMATION_LOOP_PROPS = {
|
|
11
|
+
onCreateDevice: props => luma.createDevice(props),
|
|
12
|
+
onCreateContext: undefined,
|
|
13
|
+
onAddHTML: undefined,
|
|
14
|
+
onInitialize: () => ({}),
|
|
15
|
+
onRender: () => {},
|
|
16
|
+
onFinalize: () => {},
|
|
17
|
+
onError: error => console.error(error),
|
|
18
|
+
device: null,
|
|
19
|
+
useDevicePixels: true,
|
|
20
|
+
autoResizeViewport: true,
|
|
21
|
+
autoResizeDrawingBuffer: true,
|
|
22
|
+
stats: luma.stats.get("animation-loop-".concat(statIdCounter++)),
|
|
23
|
+
gl: undefined,
|
|
24
|
+
glOptions: {},
|
|
25
|
+
createFramebuffer: false
|
|
26
|
+
};
|
|
27
|
+
export class ClassicAnimationLoop {
|
|
28
|
+
constructor() {
|
|
29
|
+
let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
30
|
+
_defineProperty(this, "device", void 0);
|
|
31
|
+
_defineProperty(this, "canvas", void 0);
|
|
32
|
+
_defineProperty(this, "props", void 0);
|
|
33
|
+
_defineProperty(this, "animationProps", void 0);
|
|
34
|
+
_defineProperty(this, "timeline", null);
|
|
35
|
+
_defineProperty(this, "stats", void 0);
|
|
36
|
+
_defineProperty(this, "cpuTime", void 0);
|
|
37
|
+
_defineProperty(this, "gpuTime", void 0);
|
|
38
|
+
_defineProperty(this, "frameRate", void 0);
|
|
39
|
+
_defineProperty(this, "display", void 0);
|
|
40
|
+
_defineProperty(this, "needsRedraw", 'initialized');
|
|
41
|
+
_defineProperty(this, "_initialized", false);
|
|
42
|
+
_defineProperty(this, "_running", false);
|
|
43
|
+
_defineProperty(this, "_animationFrameId", null);
|
|
44
|
+
_defineProperty(this, "_pageLoadPromise", null);
|
|
45
|
+
_defineProperty(this, "_nextFramePromise", null);
|
|
46
|
+
_defineProperty(this, "_resolveNextFrame", null);
|
|
47
|
+
_defineProperty(this, "_cpuStartTime", 0);
|
|
48
|
+
_defineProperty(this, "gl", void 0);
|
|
49
|
+
this.props = {
|
|
50
|
+
...DEFAULT_CLASSIC_ANIMATION_LOOP_PROPS,
|
|
51
|
+
...props
|
|
52
|
+
};
|
|
53
|
+
props = this.props;
|
|
54
|
+
let {
|
|
55
|
+
useDevicePixels = true
|
|
56
|
+
} = this.props;
|
|
57
|
+
if ('useDevicePixelRatio' in props) {
|
|
58
|
+
log.deprecated('useDevicePixelRatio', 'useDevicePixels')();
|
|
59
|
+
useDevicePixels = props.useDevicePixelRatio;
|
|
60
|
+
}
|
|
61
|
+
this.device = props.device;
|
|
62
|
+
this.gl = this.device && this.device.gl || props.gl;
|
|
63
|
+
this.stats = props.stats;
|
|
64
|
+
this.cpuTime = this.stats.get('CPU Time');
|
|
65
|
+
this.gpuTime = this.stats.get('GPU Time');
|
|
66
|
+
this.frameRate = this.stats.get('Frame Rate');
|
|
67
|
+
this.setProps({
|
|
68
|
+
autoResizeViewport: props.autoResizeViewport,
|
|
69
|
+
autoResizeDrawingBuffer: props.autoResizeDrawingBuffer,
|
|
70
|
+
useDevicePixels
|
|
71
|
+
});
|
|
72
|
+
this.start = this.start.bind(this);
|
|
73
|
+
this.stop = this.stop.bind(this);
|
|
74
|
+
this._onMousemove = this._onMousemove.bind(this);
|
|
75
|
+
this._onMouseleave = this._onMouseleave.bind(this);
|
|
76
|
+
}
|
|
77
|
+
destroy() {
|
|
78
|
+
this.stop();
|
|
79
|
+
this._setDisplay(null);
|
|
80
|
+
}
|
|
81
|
+
delete() {
|
|
82
|
+
this.destroy();
|
|
83
|
+
}
|
|
84
|
+
setNeedsRedraw(reason) {
|
|
85
|
+
this.needsRedraw = this.needsRedraw || reason;
|
|
86
|
+
return this;
|
|
87
|
+
}
|
|
88
|
+
setProps(props) {
|
|
89
|
+
if ('autoResizeViewport' in props) {
|
|
90
|
+
this.props.autoResizeViewport = props.autoResizeViewport;
|
|
91
|
+
}
|
|
92
|
+
if ('autoResizeDrawingBuffer' in props) {
|
|
93
|
+
this.props.autoResizeDrawingBuffer = props.autoResizeDrawingBuffer;
|
|
94
|
+
}
|
|
95
|
+
if ('useDevicePixels' in props) {
|
|
96
|
+
this.props.useDevicePixels = props.useDevicePixels;
|
|
97
|
+
}
|
|
98
|
+
return this;
|
|
99
|
+
}
|
|
100
|
+
start() {
|
|
101
|
+
let opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
102
|
+
this._start(opts);
|
|
103
|
+
return this;
|
|
104
|
+
}
|
|
105
|
+
async _start(props) {
|
|
106
|
+
if (this._running) {
|
|
107
|
+
return this;
|
|
108
|
+
}
|
|
109
|
+
this._running = true;
|
|
110
|
+
try {
|
|
111
|
+
await this._getPageLoadPromise();
|
|
112
|
+
if (!this._running) {
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
let appContext;
|
|
116
|
+
if (!this._initialized) {
|
|
117
|
+
this._initialized = true;
|
|
118
|
+
await this._createDevice(props);
|
|
119
|
+
this._initialize(props);
|
|
120
|
+
appContext = await this.onInitialize(this.animationProps);
|
|
121
|
+
this._addCallbackData(appContext || {});
|
|
122
|
+
}
|
|
123
|
+
if (!this._running) {
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
if (appContext !== false) {
|
|
127
|
+
this._cancelAnimationFrame();
|
|
128
|
+
this._requestAnimationFrame();
|
|
129
|
+
}
|
|
130
|
+
return this;
|
|
131
|
+
} catch (error) {
|
|
132
|
+
this.props.onError(error);
|
|
133
|
+
return null;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
redraw() {
|
|
137
|
+
if (this.isContextLost()) {
|
|
138
|
+
return this;
|
|
139
|
+
}
|
|
140
|
+
this._beginTimers();
|
|
141
|
+
this._setupFrame();
|
|
142
|
+
this._updateCallbackData();
|
|
143
|
+
this._renderFrame(this.animationProps);
|
|
144
|
+
this._clearNeedsRedraw();
|
|
145
|
+
if (this._resolveNextFrame) {
|
|
146
|
+
this._resolveNextFrame(this);
|
|
147
|
+
this._nextFramePromise = null;
|
|
148
|
+
this._resolveNextFrame = null;
|
|
149
|
+
}
|
|
150
|
+
this._endTimers();
|
|
151
|
+
return this;
|
|
152
|
+
}
|
|
153
|
+
stop() {
|
|
154
|
+
if (this._running) {
|
|
155
|
+
this._finalizeCallbackData();
|
|
156
|
+
this._cancelAnimationFrame();
|
|
157
|
+
this._nextFramePromise = null;
|
|
158
|
+
this._resolveNextFrame = null;
|
|
159
|
+
this._running = false;
|
|
160
|
+
}
|
|
161
|
+
return this;
|
|
162
|
+
}
|
|
163
|
+
attachTimeline(timeline) {
|
|
164
|
+
this.timeline = timeline;
|
|
165
|
+
return this.timeline;
|
|
166
|
+
}
|
|
167
|
+
detachTimeline() {
|
|
168
|
+
this.timeline = null;
|
|
169
|
+
}
|
|
170
|
+
waitForRender() {
|
|
171
|
+
this.setNeedsRedraw('waitForRender');
|
|
172
|
+
if (!this._nextFramePromise) {
|
|
173
|
+
this._nextFramePromise = new Promise(resolve => {
|
|
174
|
+
this._resolveNextFrame = resolve;
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
return this._nextFramePromise;
|
|
178
|
+
}
|
|
179
|
+
async toDataURL() {
|
|
180
|
+
var _getHTMLCanvasElement;
|
|
181
|
+
this.setNeedsRedraw('toDataURL');
|
|
182
|
+
await this.waitForRender();
|
|
183
|
+
return (_getHTMLCanvasElement = getHTMLCanvasElement(this.gl.canvas)) === null || _getHTMLCanvasElement === void 0 ? void 0 : _getHTMLCanvasElement.toDataURL();
|
|
184
|
+
}
|
|
185
|
+
isContextLost() {
|
|
186
|
+
return this.gl.isContextLost();
|
|
187
|
+
}
|
|
188
|
+
onCreateDevice(deviceProps) {
|
|
189
|
+
const {
|
|
190
|
+
onCreateDevice
|
|
191
|
+
} = this.props;
|
|
192
|
+
return onCreateDevice(deviceProps);
|
|
193
|
+
}
|
|
194
|
+
onInitialize(animationProps) {
|
|
195
|
+
const {
|
|
196
|
+
onInitialize
|
|
197
|
+
} = this.props;
|
|
198
|
+
return onInitialize(animationProps);
|
|
199
|
+
}
|
|
200
|
+
onRender(animationProps) {
|
|
201
|
+
const {
|
|
202
|
+
onRender
|
|
203
|
+
} = this.props;
|
|
204
|
+
return onRender(animationProps);
|
|
205
|
+
}
|
|
206
|
+
onFinalize(animationProps) {
|
|
207
|
+
const {
|
|
208
|
+
onFinalize
|
|
209
|
+
} = this.props;
|
|
210
|
+
return onFinalize(animationProps);
|
|
211
|
+
}
|
|
212
|
+
onCreateContext(props) {
|
|
213
|
+
const {
|
|
214
|
+
onCreateContext
|
|
215
|
+
} = this.props;
|
|
216
|
+
return onCreateContext(props);
|
|
217
|
+
}
|
|
218
|
+
getHTMLControlValue(id) {
|
|
219
|
+
let defaultValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
220
|
+
const element = document.getElementById(id);
|
|
221
|
+
return element ? Number(element.value) : defaultValue;
|
|
222
|
+
}
|
|
223
|
+
_initialize(props) {
|
|
224
|
+
this._createFramebuffer();
|
|
225
|
+
this._startEventHandling();
|
|
226
|
+
this._initializeCallbackData();
|
|
227
|
+
this._updateCallbackData();
|
|
228
|
+
this._resizeCanvasDrawingBuffer();
|
|
229
|
+
this._resizeViewport();
|
|
230
|
+
}
|
|
231
|
+
_getPageLoadPromise() {
|
|
232
|
+
if (!this._pageLoadPromise) {
|
|
233
|
+
this._pageLoadPromise = isPage ? new Promise((resolve, reject) => {
|
|
234
|
+
if (isPage && document.readyState === 'complete') {
|
|
235
|
+
resolve(document);
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
window.addEventListener('load', () => {
|
|
239
|
+
resolve(document);
|
|
240
|
+
});
|
|
241
|
+
}) : Promise.resolve({});
|
|
242
|
+
}
|
|
243
|
+
return this._pageLoadPromise;
|
|
244
|
+
}
|
|
245
|
+
_setDisplay(display) {
|
|
246
|
+
if (this.display) {
|
|
247
|
+
this.display.destroy();
|
|
248
|
+
this.display.animationLoop = null;
|
|
249
|
+
}
|
|
250
|
+
if (display) {
|
|
251
|
+
display.animationLoop = this;
|
|
252
|
+
}
|
|
253
|
+
this.display = display;
|
|
254
|
+
}
|
|
255
|
+
_requestAnimationFrame() {
|
|
256
|
+
if (!this._running) {
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
this._animationFrameId = requestAnimationFrame(this._animationFrame.bind(this));
|
|
260
|
+
}
|
|
261
|
+
_cancelAnimationFrame() {
|
|
262
|
+
if (this._animationFrameId !== null) {
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
cancelAnimationFrame(this._animationFrameId);
|
|
266
|
+
this._animationFrameId = null;
|
|
267
|
+
}
|
|
268
|
+
_animationFrame() {
|
|
269
|
+
if (!this._running) {
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
this.redraw();
|
|
273
|
+
this._requestAnimationFrame();
|
|
274
|
+
}
|
|
275
|
+
_renderFrame(props) {
|
|
276
|
+
if (this.display) {
|
|
277
|
+
this.display._renderFrame(props);
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
this.onRender(props);
|
|
281
|
+
}
|
|
282
|
+
_clearNeedsRedraw() {
|
|
283
|
+
this.needsRedraw = null;
|
|
284
|
+
}
|
|
285
|
+
_setupFrame() {
|
|
286
|
+
this._resizeCanvasDrawingBuffer();
|
|
287
|
+
this._resizeViewport();
|
|
288
|
+
this._resizeFramebuffer();
|
|
289
|
+
}
|
|
290
|
+
_initializeCallbackData() {
|
|
291
|
+
this.animationProps = {
|
|
292
|
+
device: this.device,
|
|
293
|
+
gl: this.gl,
|
|
294
|
+
stop: this.stop,
|
|
295
|
+
canvas: this.gl.canvas,
|
|
296
|
+
useDevicePixels: this.props.useDevicePixels,
|
|
297
|
+
needsRedraw: null,
|
|
298
|
+
startTime: Date.now(),
|
|
299
|
+
engineTime: 0,
|
|
300
|
+
tick: 0,
|
|
301
|
+
tock: 0,
|
|
302
|
+
timeline: this.timeline,
|
|
303
|
+
animationLoop: this,
|
|
304
|
+
time: 0,
|
|
305
|
+
_mousePosition: null,
|
|
306
|
+
_timeline: this.timeline,
|
|
307
|
+
_loop: this,
|
|
308
|
+
_animationLoop: this
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
_updateCallbackData() {
|
|
312
|
+
const {
|
|
313
|
+
width,
|
|
314
|
+
height,
|
|
315
|
+
aspect
|
|
316
|
+
} = this._getSizeAndAspect();
|
|
317
|
+
if (width !== this.animationProps.width || height !== this.animationProps.height) {
|
|
318
|
+
this.setNeedsRedraw('drawing buffer resized');
|
|
319
|
+
}
|
|
320
|
+
if (aspect !== this.animationProps.aspect) {
|
|
321
|
+
this.setNeedsRedraw('drawing buffer aspect changed');
|
|
322
|
+
}
|
|
323
|
+
this.animationProps.width = width;
|
|
324
|
+
this.animationProps.height = height;
|
|
325
|
+
this.animationProps.aspect = aspect;
|
|
326
|
+
this.animationProps.needsRedraw = this.needsRedraw;
|
|
327
|
+
this.animationProps.engineTime = Date.now() - this.animationProps.startTime;
|
|
328
|
+
if (this.timeline) {
|
|
329
|
+
this.timeline.update(this.animationProps.engineTime);
|
|
330
|
+
}
|
|
331
|
+
this.animationProps.tick = Math.floor(this.animationProps.time / 1000 * 60);
|
|
332
|
+
this.animationProps.tock++;
|
|
333
|
+
this.animationProps.time = this.timeline ? this.timeline.getTime() : this.animationProps.engineTime;
|
|
334
|
+
}
|
|
335
|
+
_finalizeCallbackData() {
|
|
336
|
+
this.onFinalize(this.animationProps);
|
|
337
|
+
}
|
|
338
|
+
_addCallbackData(appContext) {
|
|
339
|
+
if (typeof appContext === 'object' && appContext !== null) {
|
|
340
|
+
this.animationProps = Object.assign({}, this.animationProps, appContext);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
async _createDevice(props) {
|
|
344
|
+
const deviceProps = {
|
|
345
|
+
...this.props,
|
|
346
|
+
...props,
|
|
347
|
+
...this.props.glOptions
|
|
348
|
+
};
|
|
349
|
+
this.device = await this.onCreateDevice(deviceProps);
|
|
350
|
+
this.gl = this.device.gl;
|
|
351
|
+
if (!isWebGL(this.gl)) {
|
|
352
|
+
throw new Error('ClassicAnimationLoop.onCreateContext - illegal context returned');
|
|
353
|
+
}
|
|
354
|
+
resetParameters(this.gl);
|
|
355
|
+
this._createInfoDiv();
|
|
356
|
+
}
|
|
357
|
+
_createInfoDiv() {
|
|
358
|
+
const canvas = getHTMLCanvasElement(this.gl.canvas);
|
|
359
|
+
if (canvas && this.props.onAddHTML) {
|
|
360
|
+
const wrapperDiv = document.createElement('div');
|
|
361
|
+
document.body.appendChild(wrapperDiv);
|
|
362
|
+
wrapperDiv.style.position = 'relative';
|
|
363
|
+
const div = document.createElement('div');
|
|
364
|
+
div.style.position = 'absolute';
|
|
365
|
+
div.style.left = '10px';
|
|
366
|
+
div.style.bottom = '10px';
|
|
367
|
+
div.style.width = '300px';
|
|
368
|
+
div.style.background = 'white';
|
|
369
|
+
if (canvas) {
|
|
370
|
+
wrapperDiv.appendChild(canvas);
|
|
371
|
+
}
|
|
372
|
+
wrapperDiv.appendChild(div);
|
|
373
|
+
const html = this.props.onAddHTML(div);
|
|
374
|
+
if (html) {
|
|
375
|
+
div.innerHTML = html;
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
_getSizeAndAspect() {
|
|
380
|
+
const width = this.gl.drawingBufferWidth;
|
|
381
|
+
const height = this.gl.drawingBufferHeight;
|
|
382
|
+
let aspect = 1;
|
|
383
|
+
const canvas = getHTMLCanvasElement(this.gl.canvas);
|
|
384
|
+
if (canvas && canvas.clientHeight) {
|
|
385
|
+
aspect = canvas.clientWidth / canvas.clientHeight;
|
|
386
|
+
} else if (width > 0 && height > 0) {
|
|
387
|
+
aspect = width / height;
|
|
388
|
+
}
|
|
389
|
+
return {
|
|
390
|
+
width,
|
|
391
|
+
height,
|
|
392
|
+
aspect
|
|
393
|
+
};
|
|
394
|
+
}
|
|
395
|
+
_resizeViewport() {
|
|
396
|
+
if (this.props.autoResizeViewport) {
|
|
397
|
+
this.gl.viewport(0, 0, this.gl.drawingBufferWidth, this.gl.drawingBufferHeight);
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
_resizeCanvasDrawingBuffer() {
|
|
401
|
+
if (this.props.autoResizeDrawingBuffer) {
|
|
402
|
+
this.device.canvasContext.resize({
|
|
403
|
+
useDevicePixels: this.props.useDevicePixels
|
|
404
|
+
});
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
_beginTimers() {
|
|
408
|
+
this.frameRate.timeEnd();
|
|
409
|
+
this.frameRate.timeStart();
|
|
410
|
+
this.cpuTime.timeStart();
|
|
411
|
+
}
|
|
412
|
+
_endTimers() {
|
|
413
|
+
this.cpuTime.timeEnd();
|
|
414
|
+
}
|
|
415
|
+
_startEventHandling() {
|
|
416
|
+
const {
|
|
417
|
+
canvas
|
|
418
|
+
} = this.gl;
|
|
419
|
+
if (canvas) {
|
|
420
|
+
canvas.addEventListener('mousemove', this._onMousemove);
|
|
421
|
+
canvas.addEventListener('mouseleave', this._onMouseleave);
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
_onMousemove(e) {
|
|
425
|
+
this.animationProps._mousePosition = [e.offsetX, e.offsetY];
|
|
426
|
+
}
|
|
427
|
+
_onMouseleave(e) {
|
|
428
|
+
this.animationProps._mousePosition = null;
|
|
429
|
+
}
|
|
430
|
+
_createFramebuffer() {
|
|
431
|
+
if (this.props.createFramebuffer) {}
|
|
432
|
+
}
|
|
433
|
+
_resizeFramebuffer() {}
|
|
434
|
+
}
|
|
435
|
+
//# sourceMappingURL=classic-animation-loop.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"classic-animation-loop.js","names":["luma","log","requestAnimationFrame","cancelAnimationFrame","isBrowser","isWebGL","resetParameters","isPage","document","getHTMLCanvasElement","canvas","HTMLCanvasElement","statIdCounter","DEFAULT_CLASSIC_ANIMATION_LOOP_PROPS","onCreateDevice","props","createDevice","onCreateContext","undefined","onAddHTML","onInitialize","onRender","onFinalize","onError","error","console","device","useDevicePixels","autoResizeViewport","autoResizeDrawingBuffer","stats","get","concat","gl","glOptions","createFramebuffer","ClassicAnimationLoop","constructor","arguments","length","_defineProperty","deprecated","useDevicePixelRatio","cpuTime","gpuTime","frameRate","setProps","start","bind","stop","_onMousemove","_onMouseleave","destroy","_setDisplay","delete","setNeedsRedraw","reason","needsRedraw","opts","_start","_running","_getPageLoadPromise","appContext","_initialized","_createDevice","_initialize","animationProps","_addCallbackData","_cancelAnimationFrame","_requestAnimationFrame","redraw","isContextLost","_beginTimers","_setupFrame","_updateCallbackData","_renderFrame","_clearNeedsRedraw","_resolveNextFrame","_nextFramePromise","_endTimers","_finalizeCallbackData","attachTimeline","timeline","detachTimeline","waitForRender","Promise","resolve","toDataURL","_getHTMLCanvasElement","deviceProps","getHTMLControlValue","id","defaultValue","element","getElementById","Number","value","_createFramebuffer","_startEventHandling","_initializeCallbackData","_resizeCanvasDrawingBuffer","_resizeViewport","_pageLoadPromise","reject","readyState","window","addEventListener","display","animationLoop","_animationFrameId","_animationFrame","_resizeFramebuffer","startTime","Date","now","engineTime","tick","tock","time","_mousePosition","_timeline","_loop","_animationLoop","width","height","aspect","_getSizeAndAspect","update","Math","floor","getTime","Object","assign","Error","_createInfoDiv","wrapperDiv","createElement","body","appendChild","style","position","div","left","bottom","background","html","innerHTML","drawingBufferWidth","drawingBufferHeight","clientHeight","clientWidth","viewport","canvasContext","resize","timeEnd","timeStart","e","offsetX","offsetY"],"sources":["../../src/engine/classic-animation-loop.ts"],"sourcesContent":["// TODO - replace createGLContext, instrumentGLContext, resizeGLContext?\n// TODO - remove dependency on framebuffer (bundle size impact)\nimport {\n luma,\n Device,\n DeviceProps,\n log,\n requestAnimationFrame,\n cancelAnimationFrame\n} from '@luma.gl/api';\nimport {Timeline, AnimationProps} from '@luma.gl/engine';\nimport {Stats, Stat} from '@probe.gl/stats';\nimport {isBrowser} from '@probe.gl/env';\n\nimport {isWebGL, resetParameters} from '@luma.gl/webgl';\n// import {default as Query} from '../classic/query';\n// import {ClassicFramebuffer} from '../classic/framebuffer';\n\ntype ContextProps = DeviceProps;\n\nconst isPage = isBrowser() && typeof document !== 'undefined';\nfunction getHTMLCanvasElement(\n canvas: HTMLCanvasElement | OffscreenCanvas\n): HTMLCanvasElement | null {\n return typeof HTMLCanvasElement !== 'undefined' && canvas instanceof HTMLCanvasElement\n ? canvas\n : null;\n}\n\nlet statIdCounter = 0;\n\n/**\n * Classic Animation Props.\n * Contain a number of deprecated fields\n * @deprecated Use new AnimationLoop in `@luma.gl/engine`\n */\nexport type ClassicAnimationProps = AnimationProps & {\n animationLoop: ClassicAnimationLoop;\n\n /** @deprecated Use .device */\n stop: () => ClassicAnimationLoop;\n\n /** @deprecated Use .device */\n gl: WebGLRenderingContext;\n /** @deprecated Will be removed */\n framebuffer: unknown;\n\n /** @deprecated Use .timeline */\n _timeline: Timeline;\n /** @deprecated Use .animationLoop */\n _loop: ClassicAnimationLoop;\n /** @deprecated Use .animationLoop */\n _animationLoop: ClassicAnimationLoop;\n};\n\n/** ClassicAnimationLoop properties */\nexport type ClassicAnimationLoopProps = {\n onCreateDevice?: (props: DeviceProps) => Promise<Device>;\n onCreateContext?: (props: ContextProps) => WebGLRenderingContext; // TODO: signature from createGLContext\n onAddHTML?: (div: HTMLDivElement) => string; // innerHTML\n onInitialize?: (animationProps: ClassicAnimationProps) => {} | void | Promise<{} | void>;\n onRender?: (animationProps: ClassicAnimationProps) => void;\n onFinalize?: (animationProps: ClassicAnimationProps) => void;\n onError?: (reason: any) => void;\n\n stats?: Stats;\n\n device?: Device;\n glOptions?: ContextProps; // createGLContext options\n // debug?: boolean;\n\n // view parameters\n autoResizeViewport?: boolean;\n autoResizeDrawingBuffer?: boolean;\n useDevicePixels?: number | boolean;\n\n /** @deprecated Use .device */\n gl?: WebGLRenderingContext | null;\n /** @deprecated Will be removed */\n createFramebuffer?: boolean;\n};\n\nconst DEFAULT_CLASSIC_ANIMATION_LOOP_PROPS: Required<ClassicAnimationLoopProps> = {\n onCreateDevice: (props: DeviceProps) => luma.createDevice(props),\n onCreateContext: undefined,\n onAddHTML: undefined,\n onInitialize: () => ({}),\n onRender: () => {},\n onFinalize: () => {},\n onError: (error) => console.error(error), // eslint-disable-line no-console\n\n device: null,\n // debug: true,\n\n // view parameters\n useDevicePixels: true,\n autoResizeViewport: true,\n autoResizeDrawingBuffer: true,\n stats: luma.stats.get(`animation-loop-${statIdCounter++}`),\n\n // deprecated\n // onCreateContext: (opts) => createGLContext(opts),\n gl: undefined,\n glOptions: {},\n createFramebuffer: false\n};\n\n/**\n * Convenient animation loop\n * @deprecated Use `@luma.gl/engine` AnimationLoop\n */\nexport class ClassicAnimationLoop {\n device: Device;\n canvas?: HTMLCanvasElement | OffscreenCanvas;\n\n props: Required<ClassicAnimationLoopProps>;\n animationProps: ClassicAnimationProps;\n // framebuffer: ClassicFramebuffer = null;\n timeline: Timeline = null;\n stats: Stats;\n cpuTime: Stat;\n gpuTime: Stat;\n frameRate: Stat;\n\n display: any;\n\n needsRedraw: string | null = 'initialized';\n\n _initialized: boolean = false;\n _running: boolean = false;\n _animationFrameId: any = null;\n _pageLoadPromise: Promise<{}> | null = null;\n _nextFramePromise: Promise<ClassicAnimationLoop> | null = null;\n _resolveNextFrame: ((loop: ClassicAnimationLoop) => void) | null = null;\n _cpuStartTime: number = 0;\n\n // _gpuTimeQuery: Query | null = null;\n\n /** @deprecated */\n gl: WebGLRenderingContext;\n\n /*\n */\n constructor(props: ClassicAnimationLoopProps = {}) {\n this.props = {...DEFAULT_CLASSIC_ANIMATION_LOOP_PROPS, ...props};\n props = this.props;\n\n let {useDevicePixels = true} = this.props;\n\n if ('useDevicePixelRatio' in props) {\n log.deprecated('useDevicePixelRatio', 'useDevicePixels')();\n // @ts-expect-error\n useDevicePixels = props.useDevicePixelRatio;\n }\n\n // state\n this.device = props.device;\n // @ts-expect-error\n this.gl = (this.device && this.device.gl) || props.gl;\n\n this.stats = props.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 setProps(props: ClassicAnimationLoopProps): this {\n if ('autoResizeViewport' in props) {\n this.props.autoResizeViewport = props.autoResizeViewport;\n }\n if ('autoResizeDrawingBuffer' in props) {\n this.props.autoResizeDrawingBuffer = props.autoResizeDrawingBuffer;\n }\n if ('useDevicePixels' in props) {\n this.props.useDevicePixels = props.useDevicePixels;\n }\n return this;\n }\n\n start(opts = {}) {\n this._start(opts);\n return this;\n }\n\n /** Starts a render loop if not already running */\n async _start(props) {\n if (this._running) {\n return this;\n }\n this._running = true;\n\n // console.debug(`Starting ${this.constructor.name}`);\n // Wait for start promise before rendering frame\n try {\n await this._getPageLoadPromise();\n\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._createDevice(props);\n this._initialize(props);\n\n // Note: onIntialize can return a promise (in case app needs to load resources)\n // eslint-disable-next-line @typescript-eslint/await-thenable\n appContext = await this.onInitialize(this.animationProps);\n this._addCallbackData(appContext || {});\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 (error) {\n this.props.onError(error);\n // this._running = false; // TODO\n return null;\n }\n }\n\n /** Explicitly draw a frame */\n redraw(): this {\n if (this.isContextLost()) {\n return this;\n }\n\n this._beginTimers();\n\n this._setupFrame();\n this._updateCallbackData();\n\n this._renderFrame(this.animationProps);\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 this._finalizeCallbackData();\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<ClassicAnimationLoop> {\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() {\n this.setNeedsRedraw('toDataURL');\n\n await this.waitForRender();\n\n return getHTMLCanvasElement(this.gl.canvas)?.toDataURL();\n }\n\n isContextLost(): boolean {\n return this.gl.isContextLost();\n }\n\n onCreateDevice(deviceProps: DeviceProps): Promise<Device> {\n const {onCreateDevice} = this.props;\n return onCreateDevice(deviceProps);\n }\n\n onInitialize(animationProps: ClassicAnimationProps): {} | void {\n const {onInitialize} = this.props;\n return onInitialize(animationProps);\n }\n\n onRender(animationProps: ClassicAnimationProps) {\n const {onRender} = this.props;\n return onRender(animationProps);\n }\n\n onFinalize(animationProps: ClassicAnimationProps) {\n const {onFinalize} = this.props;\n return onFinalize(animationProps);\n }\n\n // DEPRECATED/REMOVED METHODS\n\n /** @deprecated Use .onCreateDevice() */\n onCreateContext(props: ContextProps) {\n const {onCreateContext} = this.props;\n return onCreateContext(props);\n }\n\n /** @deprecated */\n getHTMLControlValue(id, defaultValue = 1) {\n const element = document.getElementById(id);\n // @ts-expect-error Not all html elements have value\n return element ? Number(element.value) : defaultValue;\n }\n\n // PRIVATE METHODS\n\n _initialize(props: ClassicAnimationLoopProps) {\n this._createFramebuffer();\n this._startEventHandling();\n\n // Initialize the callback data\n this._initializeCallbackData();\n this._updateCallbackData();\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 _getPageLoadPromise() {\n if (!this._pageLoadPromise) {\n this._pageLoadPromise = isPage\n ? new Promise((resolve, reject) => {\n if (isPage && document.readyState === 'complete') {\n resolve(document);\n return;\n }\n window.addEventListener('load', () => {\n resolve(document);\n });\n })\n : Promise.resolve({});\n }\n return this._pageLoadPromise;\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(props: ClassicAnimationProps) {\n // Allow e.g. VR display to render multiple frames.\n if (this.display) {\n this.display._renderFrame(props);\n return;\n }\n\n // call callback\n this.onRender(props);\n // end callback\n }\n\n _clearNeedsRedraw() {\n this.needsRedraw = null;\n }\n\n _setupFrame() {\n this._resizeCanvasDrawingBuffer();\n this._resizeViewport();\n this._resizeFramebuffer();\n }\n\n /* eslint-disable @typescript-eslint/unbound-method */\n\n // Initialize the object that will be passed to app callbacks\n _initializeCallbackData() {\n this.animationProps = {\n device: this.device,\n gl: this.gl,\n\n stop: this.stop,\n canvas: this.gl.canvas,\n\n // Initial values\n useDevicePixels: this.props.useDevicePixels,\n needsRedraw: null,\n\n // Animation props\n startTime: Date.now(),\n engineTime: 0,\n tick: 0,\n tock: 0,\n\n timeline: this.timeline,\n // @ts-ignore\n animationLoop: this,\n\n // Timeline time for back compatibility\n time: 0,\n\n // Experimental\n _mousePosition: null, // Event props\n\n /** @deprecated */\n // framebuffer: this.framebuffer,\n /** @deprecated */\n _timeline: this.timeline,\n /** @deprecated */\n _loop: this,\n /** @deprecated */\n _animationLoop: this\n };\n }\n\n // Update the context object that will be passed to app callbacks\n _updateCallbackData() {\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 _finalizeCallbackData() {\n // call callback\n this.onFinalize(this.animationProps);\n // end callback\n }\n\n /** Add application's data to the app context object */\n _addCallbackData(appContext) {\n if (typeof appContext === 'object' && appContext !== null) {\n this.animationProps = Object.assign({}, this.animationProps, appContext);\n }\n }\n\n /** Either uses supplied or existing context, or calls provided callback to create one */\n async _createDevice(props: DeviceProps) {\n const deviceProps = {...this.props, ...props, ...this.props.glOptions};\n\n // TODO - support this.onCreateContext\n // Create the WebGL context if necessary\n // this.gl = this.props.gl ? instrumentGLContext(this.props.gl, deviceProps) : this.onCreateContext(deviceProps);\n\n this.device = await this.onCreateDevice(deviceProps);\n // @ts-expect-error\n this.gl = this.device.gl;\n\n if (!isWebGL(this.gl)) {\n throw new Error('ClassicAnimationLoop.onCreateContext - illegal context returned');\n }\n\n // Reset the WebGL context.\n resetParameters(this.gl);\n\n this._createInfoDiv();\n }\n\n _createInfoDiv() {\n const canvas = getHTMLCanvasElement(this.gl.canvas)\n if (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 (canvas) {\n wrapperDiv.appendChild(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() {\n // https://webglfundamentals.org/webgl/lessons/webgl-resizing-the-canvas.html\n const width = this.gl.drawingBufferWidth;\n const height = this.gl.drawingBufferHeight;\n\n // https://webglfundamentals.org/webgl/lessons/webgl-anti-patterns.html\n let aspect = 1;\n\n const canvas = getHTMLCanvasElement(this.gl.canvas);\n if (canvas && canvas.clientHeight) {\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 if (this.props.autoResizeViewport) {\n this.gl.viewport(0, 0, this.gl.drawingBufferWidth, this.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 const {canvas} = this.gl;\n if (canvas) {\n canvas.addEventListener('mousemove', this._onMousemove);\n canvas.addEventListener('mouseleave', this._onMouseleave);\n }\n }\n\n _onMousemove(e) {\n this.animationProps._mousePosition = [e.offsetX, e.offsetY];\n }\n _onMouseleave(e) {\n this.animationProps._mousePosition = null;\n }\n\n // Deprecated\n\n /** @deprecated */\n _createFramebuffer() {\n // Setup default framebuffer\n if (this.props.createFramebuffer) {\n // this.framebuffer = new ClassicFramebuffer(this.gl);\n }\n }\n\n /** @deprecated */\n _resizeFramebuffer() {\n // if (this.framebuffer) {\n // this.framebuffer.resize({\n // width: this.gl.drawingBufferWidth,\n // height: this.gl.drawingBufferHeight\n // });\n // }\n }\n}\n"],"mappings":";AAEA,SACEA,IAAI,EAGJC,GAAG,EACHC,qBAAqB,EACrBC,oBAAoB,QACf,cAAc;AAGrB,SAAQC,SAAS,QAAO,eAAe;AAEvC,SAAQC,OAAO,EAAEC,eAAe,QAAO,gBAAgB;AAMvD,MAAMC,MAAM,GAAGH,SAAS,EAAE,IAAI,OAAOI,QAAQ,KAAK,WAAW;AAC7D,SAASC,oBAAoBA,CAC3BC,MAA2C,EACjB;EAC1B,OAAO,OAAOC,iBAAiB,KAAK,WAAW,IAAID,MAAM,YAAYC,iBAAiB,GAClFD,MAAM,GACN,IAAI;AACV;AAEA,IAAIE,aAAa,GAAG,CAAC;AAqDrB,MAAMC,oCAAyE,GAAG;EAChFC,cAAc,EAAGC,KAAkB,IAAKf,IAAI,CAACgB,YAAY,CAACD,KAAK,CAAC;EAChEE,eAAe,EAAEC,SAAS;EAC1BC,SAAS,EAAED,SAAS;EACpBE,YAAY,EAAEA,CAAA,MAAO,C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