@luma.gl/engine 8.5.8 → 8.6.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/animation/key-frames.d.ts +18 -0
- package/dist/animation/key-frames.d.ts.map +1 -0
- package/dist/{esm/animation → animation}/key-frames.js +13 -6
- package/dist/animation/key-frames.js.map +1 -0
- package/dist/animation/timeline.d.ts +51 -0
- package/dist/animation/timeline.d.ts.map +1 -0
- package/dist/{esm/animation → animation}/timeline.js +10 -5
- package/dist/animation/timeline.js.map +1 -0
- package/dist/bundle.d.ts +2 -0
- package/dist/bundle.d.ts.map +1 -0
- package/dist/bundle.js +5 -0
- package/dist/bundle.js.map +1 -0
- package/dist/geometries/cone-geometry.d.ts +10 -0
- package/dist/geometries/cone-geometry.d.ts.map +1 -0
- package/dist/{esm/geometries → geometries}/cone-geometry.js +2 -2
- package/dist/geometries/cone-geometry.js.map +1 -0
- package/dist/geometries/cube-geometry.d.ts +9 -0
- package/dist/geometries/cube-geometry.d.ts.map +1 -0
- package/dist/{esm/geometries → geometries}/cube-geometry.js +18 -18
- package/dist/geometries/cube-geometry.js.map +1 -0
- package/dist/geometries/cylinder-geometry.d.ts +10 -0
- package/dist/geometries/cylinder-geometry.d.ts.map +1 -0
- package/dist/{esm/geometries → geometries}/cylinder-geometry.js +2 -2
- package/dist/geometries/cylinder-geometry.js.map +1 -0
- package/dist/geometries/ico-sphere-geometry.d.ts +11 -0
- package/dist/geometries/ico-sphere-geometry.d.ts.map +1 -0
- package/dist/{esm/geometries → geometries}/ico-sphere-geometry.js +2 -2
- package/dist/geometries/ico-sphere-geometry.js.map +1 -0
- package/dist/geometries/plane-geometry.d.ts +10 -0
- package/dist/geometries/plane-geometry.d.ts.map +1 -0
- package/dist/{esm/geometries → geometries}/plane-geometry.js +5 -5
- package/dist/geometries/plane-geometry.js.map +1 -0
- package/dist/geometries/sphere-geometry.d.ts +12 -0
- package/dist/geometries/sphere-geometry.d.ts.map +1 -0
- package/dist/{esm/geometries → geometries}/sphere-geometry.js +2 -9
- package/dist/geometries/sphere-geometry.js.map +1 -0
- package/dist/geometries/truncated-cone-geometry.d.ts +13 -0
- package/dist/geometries/truncated-cone-geometry.d.ts.map +1 -0
- package/dist/{esm/geometries → geometries}/truncated-cone-geometry.js +1 -1
- package/dist/geometries/truncated-cone-geometry.js.map +1 -0
- package/dist/geometry/geometry-utils.d.ts +2 -0
- package/dist/geometry/geometry-utils.d.ts.map +1 -0
- package/dist/{esm/geometry → geometry}/geometry-utils.js +0 -0
- package/dist/geometry/geometry-utils.js.map +1 -0
- package/dist/geometry/geometry.d.ts +44 -0
- package/dist/geometry/geometry.d.ts.map +1 -0
- package/dist/{esm/geometry → geometry}/geometry.js +28 -19
- package/dist/geometry/geometry.js.map +1 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/animation-loop.d.ts +149 -0
- package/dist/lib/animation-loop.d.ts.map +1 -0
- package/dist/{esm/lib → lib}/animation-loop.js +190 -143
- package/dist/lib/animation-loop.js.map +1 -0
- package/dist/lib/model-utils.d.ts +4 -0
- package/dist/lib/model-utils.d.ts.map +1 -0
- package/dist/{esm/lib → lib}/model-utils.js +3 -2
- package/dist/lib/model-utils.js.map +1 -0
- package/dist/lib/model.d.ts +109 -0
- package/dist/lib/model.d.ts.map +1 -0
- package/dist/{esm/lib → lib}/model.js +76 -20
- package/dist/lib/model.js.map +1 -0
- package/dist/lib/program-manager.d.ts +39 -0
- package/dist/lib/program-manager.d.ts.map +1 -0
- package/dist/{esm/lib → lib}/program-manager.js +29 -18
- package/dist/lib/program-manager.js.map +1 -0
- package/dist/lib/render-loop.d.ts +27 -0
- package/dist/lib/render-loop.d.ts.map +1 -0
- package/dist/lib/render-loop.js +56 -0
- package/dist/lib/render-loop.js.map +1 -0
- package/dist/transform/buffer-transform.d.ts +36 -0
- package/dist/transform/buffer-transform.d.ts.map +1 -0
- package/dist/{esm/transform → transform}/buffer-transform.js +15 -8
- package/dist/transform/buffer-transform.js.map +1 -0
- package/dist/transform/texture-transform.d.ts +57 -0
- package/dist/transform/texture-transform.d.ts.map +1 -0
- package/dist/{esm/transform → transform}/texture-transform.js +48 -16
- package/dist/transform/texture-transform.js.map +1 -0
- package/dist/transform/transform-shader-utils.d.ts +26 -0
- package/dist/transform/transform-shader-utils.d.ts.map +1 -0
- package/dist/{esm/transform → transform}/transform-shader-utils.js +38 -46
- package/dist/transform/transform-shader-utils.js.map +1 -0
- package/dist/transform/transform-types.d.ts +44 -0
- package/dist/transform/transform-types.d.ts.map +1 -0
- package/dist/transform/transform-types.js +2 -0
- package/dist/transform/transform-types.js.map +1 -0
- package/dist/transform/transform.d.ts +47 -0
- package/dist/transform/transform.d.ts.map +1 -0
- package/dist/{esm/transform → transform}/transform.js +63 -43
- package/dist/transform/transform.js.map +1 -0
- package/dist/utils/clip-space.d.ts +5 -0
- package/dist/utils/clip-space.d.ts.map +1 -0
- package/dist/{esm/utils → utils}/clip-space.js +3 -17
- package/dist/utils/clip-space.js.map +1 -0
- package/package.json +11 -11
- package/src/animation/{key-frames.js → key-frames.ts} +18 -16
- package/src/animation/{timeline.js → timeline.ts} +54 -18
- package/src/bundle.ts +4 -0
- package/src/geometries/{cone-geometry.js → cone-geometry.ts} +9 -3
- package/src/geometries/{cube-geometry.js → cube-geometry.ts} +17 -12
- package/src/geometries/cylinder-geometry.ts +20 -0
- package/src/geometries/{ico-sphere-geometry.js → ico-sphere-geometry.ts} +10 -3
- package/src/geometries/{plane-geometry.js → plane-geometry.ts} +11 -6
- package/src/geometries/{sphere-geometry.js → sphere-geometry.ts} +15 -11
- package/src/geometries/{truncated-cone-geometry.js → truncated-cone-geometry.ts} +14 -5
- package/src/geometry/{geometry-utils.js → geometry-utils.ts} +2 -0
- package/src/geometry/{geometry.js → geometry.ts} +47 -34
- package/src/index.ts +35 -0
- package/src/lib/animation-loop.ts +724 -0
- package/src/lib/{model-utils.js → model-utils.ts} +2 -2
- package/src/lib/{model.js → model.ts} +184 -66
- package/src/lib/{program-manager.js → program-manager.ts} +53 -34
- package/src/lib/render-loop.ts +56 -0
- package/src/transform/{buffer-transform.js → buffer-transform.ts} +42 -27
- package/src/transform/{texture-transform.js → texture-transform.ts} +35 -25
- package/src/transform/{transform-shader-utils.js → transform-shader-utils.ts} +55 -27
- package/src/transform/transform-types.ts +42 -0
- package/src/transform/transform.ts +189 -0
- package/src/utils/{clip-space.js → clip-space.ts} +4 -3
- package/dist/dist.js +0 -32403
- package/dist/dist.min.js +0 -1
- package/dist/es5/animation/key-frames.d.ts +0 -19
- package/dist/es5/animation/key-frames.js +0 -95
- package/dist/es5/animation/key-frames.js.map +0 -1
- package/dist/es5/animation/timeline.d.ts +0 -39
- package/dist/es5/animation/timeline.js +0 -211
- package/dist/es5/animation/timeline.js.map +0 -1
- package/dist/es5/bundle.js +0 -9
- package/dist/es5/bundle.js.map +0 -1
- package/dist/es5/geometries/cone-geometry.d.ts +0 -5
- package/dist/es5/geometries/cone-geometry.js +0 -59
- package/dist/es5/geometries/cone-geometry.js.map +0 -1
- package/dist/es5/geometries/cube-geometry.d.ts +0 -5
- package/dist/es5/geometries/cube-geometry.js +0 -75
- package/dist/es5/geometries/cube-geometry.js.map +0 -1
- package/dist/es5/geometries/cylinder-geometry.d.ts +0 -5
- package/dist/es5/geometries/cylinder-geometry.js +0 -55
- package/dist/es5/geometries/cylinder-geometry.js.map +0 -1
- package/dist/es5/geometries/ico-sphere-geometry.d.ts +0 -5
- package/dist/es5/geometries/ico-sphere-geometry.js +0 -217
- package/dist/es5/geometries/ico-sphere-geometry.js.map +0 -1
- package/dist/es5/geometries/index.d.ts +0 -7
- package/dist/es5/geometries/index.js +0 -64
- package/dist/es5/geometries/index.js.map +0 -1
- package/dist/es5/geometries/plane-geometry.d.ts +0 -5
- package/dist/es5/geometries/plane-geometry.js +0 -168
- package/dist/es5/geometries/plane-geometry.js.map +0 -1
- package/dist/es5/geometries/sphere-geometry.d.ts +0 -5
- package/dist/es5/geometries/sphere-geometry.js +0 -152
- package/dist/es5/geometries/sphere-geometry.js.map +0 -1
- package/dist/es5/geometries/truncated-cone-geometry.d.ts +0 -5
- package/dist/es5/geometries/truncated-cone-geometry.js +0 -171
- package/dist/es5/geometries/truncated-cone-geometry.js.map +0 -1
- package/dist/es5/geometry/geometry-utils.d.ts +0 -1
- package/dist/es5/geometry/geometry-utils.js +0 -49
- package/dist/es5/geometry/geometry-utils.js.map +0 -1
- package/dist/es5/geometry/geometry.d.ts +0 -25
- package/dist/es5/geometry/geometry.js +0 -150
- package/dist/es5/geometry/geometry.js.map +0 -1
- package/dist/es5/index.d.ts +0 -19
- package/dist/es5/index.js +0 -128
- package/dist/es5/index.js.map +0 -1
- package/dist/es5/lib/animation-loop.d.ts +0 -158
- package/dist/es5/lib/animation-loop.js +0 -642
- package/dist/es5/lib/animation-loop.js.map +0 -1
- package/dist/es5/lib/model-utils.d.ts +0 -3
- package/dist/es5/lib/model-utils.js +0 -110
- package/dist/es5/lib/model-utils.js.map +0 -1
- package/dist/es5/lib/model.d.ts +0 -214
- package/dist/es5/lib/model.js +0 -584
- package/dist/es5/lib/model.js.map +0 -1
- package/dist/es5/lib/program-manager.d.ts +0 -79
- package/dist/es5/lib/program-manager.js +0 -238
- package/dist/es5/lib/program-manager.js.map +0 -1
- package/dist/es5/transform/buffer-transform.d.ts +0 -13
- package/dist/es5/transform/buffer-transform.js +0 -294
- package/dist/es5/transform/buffer-transform.js.map +0 -1
- package/dist/es5/transform/resource-transform.d.ts +0 -16
- package/dist/es5/transform/texture-transform.d.ts +0 -16
- package/dist/es5/transform/texture-transform.js +0 -405
- package/dist/es5/transform/texture-transform.js.map +0 -1
- package/dist/es5/transform/transform-shader-utils.d.ts +0 -31
- package/dist/es5/transform/transform-shader-utils.js +0 -160
- package/dist/es5/transform/transform-shader-utils.js.map +0 -1
- package/dist/es5/transform/transform.d.ts +0 -33
- package/dist/es5/transform/transform.js +0 -274
- package/dist/es5/transform/transform.js.map +0 -1
- package/dist/es5/utils/clip-space.d.ts +0 -5
- package/dist/es5/utils/clip-space.js +0 -72
- package/dist/es5/utils/clip-space.js.map +0 -1
- package/dist/esm/animation/key-frames.d.ts +0 -19
- package/dist/esm/animation/key-frames.js.map +0 -1
- package/dist/esm/animation/timeline.d.ts +0 -39
- package/dist/esm/animation/timeline.js.map +0 -1
- package/dist/esm/bundle.js +0 -7
- package/dist/esm/bundle.js.map +0 -1
- package/dist/esm/geometries/cone-geometry.d.ts +0 -5
- package/dist/esm/geometries/cone-geometry.js.map +0 -1
- package/dist/esm/geometries/cube-geometry.d.ts +0 -5
- package/dist/esm/geometries/cube-geometry.js.map +0 -1
- package/dist/esm/geometries/cylinder-geometry.d.ts +0 -5
- package/dist/esm/geometries/cylinder-geometry.js.map +0 -1
- package/dist/esm/geometries/ico-sphere-geometry.d.ts +0 -5
- package/dist/esm/geometries/ico-sphere-geometry.js.map +0 -1
- package/dist/esm/geometries/index.d.ts +0 -7
- package/dist/esm/geometries/index.js +0 -8
- package/dist/esm/geometries/index.js.map +0 -1
- package/dist/esm/geometries/plane-geometry.d.ts +0 -5
- package/dist/esm/geometries/plane-geometry.js.map +0 -1
- package/dist/esm/geometries/sphere-geometry.d.ts +0 -5
- package/dist/esm/geometries/sphere-geometry.js.map +0 -1
- package/dist/esm/geometries/truncated-cone-geometry.d.ts +0 -5
- package/dist/esm/geometries/truncated-cone-geometry.js.map +0 -1
- package/dist/esm/geometry/geometry-utils.d.ts +0 -1
- package/dist/esm/geometry/geometry-utils.js.map +0 -1
- package/dist/esm/geometry/geometry.d.ts +0 -25
- package/dist/esm/geometry/geometry.js.map +0 -1
- package/dist/esm/index.d.ts +0 -19
- package/dist/esm/index.js +0 -16
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/lib/animation-loop.d.ts +0 -158
- package/dist/esm/lib/animation-loop.js.map +0 -1
- package/dist/esm/lib/model-utils.d.ts +0 -3
- package/dist/esm/lib/model-utils.js.map +0 -1
- package/dist/esm/lib/model.d.ts +0 -214
- package/dist/esm/lib/model.js.map +0 -1
- package/dist/esm/lib/program-manager.d.ts +0 -79
- package/dist/esm/lib/program-manager.js.map +0 -1
- package/dist/esm/transform/buffer-transform.d.ts +0 -13
- package/dist/esm/transform/buffer-transform.js.map +0 -1
- package/dist/esm/transform/resource-transform.d.ts +0 -16
- package/dist/esm/transform/texture-transform.d.ts +0 -16
- package/dist/esm/transform/texture-transform.js.map +0 -1
- package/dist/esm/transform/transform-shader-utils.d.ts +0 -31
- package/dist/esm/transform/transform-shader-utils.js.map +0 -1
- package/dist/esm/transform/transform.d.ts +0 -33
- package/dist/esm/transform/transform.js.map +0 -1
- package/dist/esm/utils/clip-space.d.ts +0 -5
- package/dist/esm/utils/clip-space.js.map +0 -1
- package/src/animation/key-frames.d.ts +0 -19
- package/src/animation/timeline.d.ts +0 -39
- package/src/bundle.js +0 -7
- package/src/geometries/cone-geometry.d.ts +0 -5
- package/src/geometries/cube-geometry.d.ts +0 -5
- package/src/geometries/cylinder-geometry.d.ts +0 -5
- package/src/geometries/cylinder-geometry.js +0 -14
- package/src/geometries/ico-sphere-geometry.d.ts +0 -5
- package/src/geometries/index.d.ts +0 -7
- package/src/geometries/index.js +0 -7
- package/src/geometries/plane-geometry.d.ts +0 -5
- package/src/geometries/sphere-geometry.d.ts +0 -5
- package/src/geometries/truncated-cone-geometry.d.ts +0 -5
- package/src/geometry/geometry-utils.d.ts +0 -1
- package/src/geometry/geometry.d.ts +0 -25
- package/src/index.d.ts +0 -19
- package/src/index.js +0 -22
- package/src/lib/animation-loop.d.ts +0 -158
- package/src/lib/animation-loop.js +0 -601
- package/src/lib/model-utils.d.ts +0 -3
- package/src/lib/model.d.ts +0 -214
- package/src/lib/program-manager.d.ts +0 -79
- package/src/transform/buffer-transform.d.ts +0 -13
- package/src/transform/resource-transform.d.ts +0 -16
- package/src/transform/texture-transform.d.ts +0 -16
- package/src/transform/transform-shader-utils.d.ts +0 -31
- package/src/transform/transform.d.ts +0 -33
- package/src/transform/transform.js +0 -177
- package/src/utils/clip-space.d.ts +0 -5
|
@@ -1,143 +1,181 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
import { luma } from '@luma.gl/api';
|
|
3
|
+
import { lumaStats, log } from '@luma.gl/api';
|
|
4
|
+
import { isWebGL, resetParameters } from '@luma.gl/webgl';
|
|
5
|
+
import { requestAnimationFrame, cancelAnimationFrame, Query, Framebuffer } from '@luma.gl/webgl';
|
|
6
|
+
import { isBrowser } from '@probe.gl/env';
|
|
4
7
|
const isPage = isBrowser() && typeof document !== 'undefined';
|
|
5
8
|
let statIdCounter = 0;
|
|
9
|
+
const DEFAULT_ANIMATION_LOOP_PROPS = {
|
|
10
|
+
onCreateDevice: props => luma.createDevice(props),
|
|
11
|
+
onCreateContext: null,
|
|
12
|
+
onAddHTML: null,
|
|
13
|
+
onInitialize: () => ({}),
|
|
14
|
+
onRender: () => {},
|
|
15
|
+
onFinalize: () => {},
|
|
16
|
+
onError: error => console.error(error),
|
|
17
|
+
device: null,
|
|
18
|
+
debug: false,
|
|
19
|
+
useDevicePixels: true,
|
|
20
|
+
autoResizeViewport: true,
|
|
21
|
+
autoResizeDrawingBuffer: true,
|
|
22
|
+
stats: lumaStats.get("animation-loop-".concat(statIdCounter++)),
|
|
23
|
+
gl: null,
|
|
24
|
+
glOptions: {},
|
|
25
|
+
createFramebuffer: false
|
|
26
|
+
};
|
|
6
27
|
export default class AnimationLoop {
|
|
7
28
|
constructor(props = {}) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
29
|
+
_defineProperty(this, "device", void 0);
|
|
30
|
+
|
|
31
|
+
_defineProperty(this, "canvas", void 0);
|
|
32
|
+
|
|
33
|
+
_defineProperty(this, "props", void 0);
|
|
34
|
+
|
|
35
|
+
_defineProperty(this, "animationProps", void 0);
|
|
36
|
+
|
|
37
|
+
_defineProperty(this, "framebuffer", null);
|
|
38
|
+
|
|
39
|
+
_defineProperty(this, "timeline", null);
|
|
40
|
+
|
|
41
|
+
_defineProperty(this, "stats", void 0);
|
|
42
|
+
|
|
43
|
+
_defineProperty(this, "cpuTime", void 0);
|
|
44
|
+
|
|
45
|
+
_defineProperty(this, "gpuTime", void 0);
|
|
46
|
+
|
|
47
|
+
_defineProperty(this, "frameRate", void 0);
|
|
48
|
+
|
|
49
|
+
_defineProperty(this, "display", void 0);
|
|
50
|
+
|
|
51
|
+
_defineProperty(this, "needsRedraw", 'initialized');
|
|
52
|
+
|
|
53
|
+
_defineProperty(this, "_initialized", false);
|
|
54
|
+
|
|
55
|
+
_defineProperty(this, "_running", false);
|
|
56
|
+
|
|
57
|
+
_defineProperty(this, "_animationFrameId", null);
|
|
58
|
+
|
|
59
|
+
_defineProperty(this, "_pageLoadPromise", null);
|
|
60
|
+
|
|
61
|
+
_defineProperty(this, "_nextFramePromise", null);
|
|
62
|
+
|
|
63
|
+
_defineProperty(this, "_resolveNextFrame", null);
|
|
64
|
+
|
|
65
|
+
_defineProperty(this, "_cpuStartTime", 0);
|
|
66
|
+
|
|
67
|
+
_defineProperty(this, "_gpuTimeQuery", null);
|
|
68
|
+
|
|
69
|
+
_defineProperty(this, "gl", void 0);
|
|
70
|
+
|
|
71
|
+
this.props = { ...DEFAULT_ANIMATION_LOOP_PROPS,
|
|
72
|
+
...props
|
|
73
|
+
};
|
|
74
|
+
props = this.props;
|
|
23
75
|
let {
|
|
24
76
|
useDevicePixels = true
|
|
25
|
-
} = props;
|
|
77
|
+
} = this.props;
|
|
26
78
|
|
|
27
79
|
if ('useDevicePixelRatio' in props) {
|
|
28
80
|
log.deprecated('useDevicePixelRatio', 'useDevicePixels')();
|
|
29
81
|
useDevicePixels = props.useDevicePixelRatio;
|
|
30
82
|
}
|
|
31
83
|
|
|
32
|
-
this.
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
onInitialize,
|
|
36
|
-
onRender,
|
|
37
|
-
onFinalize,
|
|
38
|
-
onError,
|
|
39
|
-
gl,
|
|
40
|
-
glOptions,
|
|
41
|
-
debug,
|
|
42
|
-
createFramebuffer
|
|
43
|
-
};
|
|
44
|
-
this.gl = gl;
|
|
45
|
-
this.needsRedraw = null;
|
|
46
|
-
this.timeline = null;
|
|
47
|
-
this.stats = stats;
|
|
84
|
+
this.device = props.device;
|
|
85
|
+
this.gl = this.device && this.device.gl || props.gl;
|
|
86
|
+
this.stats = props.stats;
|
|
48
87
|
this.cpuTime = this.stats.get('CPU Time');
|
|
49
88
|
this.gpuTime = this.stats.get('GPU Time');
|
|
50
89
|
this.frameRate = this.stats.get('Frame Rate');
|
|
51
|
-
this._initialized = false;
|
|
52
|
-
this._running = false;
|
|
53
|
-
this._animationFrameId = null;
|
|
54
|
-
this._nextFramePromise = null;
|
|
55
|
-
this._resolveNextFrame = null;
|
|
56
|
-
this._cpuStartTime = 0;
|
|
57
90
|
this.setProps({
|
|
58
|
-
autoResizeViewport,
|
|
59
|
-
autoResizeDrawingBuffer,
|
|
91
|
+
autoResizeViewport: props.autoResizeViewport,
|
|
92
|
+
autoResizeDrawingBuffer: props.autoResizeDrawingBuffer,
|
|
60
93
|
useDevicePixels
|
|
61
94
|
});
|
|
62
95
|
this.start = this.start.bind(this);
|
|
63
96
|
this.stop = this.stop.bind(this);
|
|
64
|
-
this._pageLoadPromise = null;
|
|
65
97
|
this._onMousemove = this._onMousemove.bind(this);
|
|
66
98
|
this._onMouseleave = this._onMouseleave.bind(this);
|
|
67
99
|
}
|
|
68
100
|
|
|
69
|
-
|
|
101
|
+
destroy() {
|
|
70
102
|
this.stop();
|
|
71
103
|
|
|
72
104
|
this._setDisplay(null);
|
|
73
105
|
}
|
|
74
106
|
|
|
107
|
+
delete() {
|
|
108
|
+
this.destroy();
|
|
109
|
+
}
|
|
110
|
+
|
|
75
111
|
setNeedsRedraw(reason) {
|
|
76
|
-
assert(typeof reason === 'string');
|
|
77
112
|
this.needsRedraw = this.needsRedraw || reason;
|
|
78
113
|
return this;
|
|
79
114
|
}
|
|
80
115
|
|
|
81
116
|
setProps(props) {
|
|
82
117
|
if ('autoResizeViewport' in props) {
|
|
83
|
-
this.autoResizeViewport = props.autoResizeViewport;
|
|
118
|
+
this.props.autoResizeViewport = props.autoResizeViewport;
|
|
84
119
|
}
|
|
85
120
|
|
|
86
121
|
if ('autoResizeDrawingBuffer' in props) {
|
|
87
|
-
this.autoResizeDrawingBuffer = props.autoResizeDrawingBuffer;
|
|
122
|
+
this.props.autoResizeDrawingBuffer = props.autoResizeDrawingBuffer;
|
|
88
123
|
}
|
|
89
124
|
|
|
90
125
|
if ('useDevicePixels' in props) {
|
|
91
|
-
this.useDevicePixels = props.useDevicePixels;
|
|
126
|
+
this.props.useDevicePixels = props.useDevicePixels;
|
|
92
127
|
}
|
|
93
128
|
|
|
94
129
|
return this;
|
|
95
130
|
}
|
|
96
131
|
|
|
97
132
|
start(opts = {}) {
|
|
133
|
+
this._start(opts);
|
|
134
|
+
|
|
135
|
+
return this;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
async _start(opts) {
|
|
98
139
|
if (this._running) {
|
|
99
140
|
return this;
|
|
100
141
|
}
|
|
101
142
|
|
|
102
143
|
this._running = true;
|
|
103
144
|
|
|
104
|
-
|
|
105
|
-
|
|
145
|
+
try {
|
|
146
|
+
await this._getPageLoadPromise();
|
|
147
|
+
|
|
148
|
+
if (!this._running) {
|
|
106
149
|
return null;
|
|
107
150
|
}
|
|
108
151
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
this._createFramebuffer();
|
|
152
|
+
let appContext;
|
|
112
153
|
|
|
113
|
-
this.
|
|
154
|
+
if (!this._initialized) {
|
|
155
|
+
this._initialized = true;
|
|
114
156
|
|
|
115
|
-
|
|
157
|
+
this._initialize(opts);
|
|
116
158
|
|
|
117
|
-
|
|
159
|
+
appContext = await this.onInitialize(this.animationProps);
|
|
118
160
|
|
|
119
|
-
|
|
161
|
+
this._addCallbackData(appContext || {});
|
|
162
|
+
}
|
|
120
163
|
|
|
121
|
-
this.
|
|
164
|
+
if (!this._running) {
|
|
165
|
+
return null;
|
|
166
|
+
}
|
|
122
167
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
return this.onInitialize(this.animationProps);
|
|
126
|
-
}).then(appContext => {
|
|
127
|
-
if (this._running) {
|
|
128
|
-
this._addCallbackData(appContext || {});
|
|
168
|
+
if (appContext !== false) {
|
|
169
|
+
this._cancelAnimationFrame();
|
|
129
170
|
|
|
130
|
-
|
|
131
|
-
this._startLoop();
|
|
132
|
-
}
|
|
171
|
+
this._requestAnimationFrame();
|
|
133
172
|
}
|
|
134
|
-
});
|
|
135
173
|
|
|
136
|
-
|
|
137
|
-
|
|
174
|
+
return this;
|
|
175
|
+
} catch (error) {
|
|
176
|
+
this.props.onError(error);
|
|
177
|
+
return null;
|
|
138
178
|
}
|
|
139
|
-
|
|
140
|
-
return this;
|
|
141
179
|
}
|
|
142
180
|
|
|
143
181
|
redraw() {
|
|
@@ -155,10 +193,6 @@ export default class AnimationLoop {
|
|
|
155
193
|
|
|
156
194
|
this._clearNeedsRedraw();
|
|
157
195
|
|
|
158
|
-
if (this.offScreen && this.gl.commit) {
|
|
159
|
-
this.gl.commit();
|
|
160
|
-
}
|
|
161
|
-
|
|
162
196
|
if (this._resolveNextFrame) {
|
|
163
197
|
this._resolveNextFrame(this);
|
|
164
198
|
|
|
@@ -175,11 +209,10 @@ export default class AnimationLoop {
|
|
|
175
209
|
if (this._running) {
|
|
176
210
|
this._finalizeCallbackData();
|
|
177
211
|
|
|
178
|
-
this._cancelAnimationFrame(
|
|
212
|
+
this._cancelAnimationFrame();
|
|
179
213
|
|
|
180
214
|
this._nextFramePromise = null;
|
|
181
215
|
this._resolveNextFrame = null;
|
|
182
|
-
this._animationFrameId = null;
|
|
183
216
|
this._running = false;
|
|
184
217
|
}
|
|
185
218
|
|
|
@@ -217,20 +250,24 @@ export default class AnimationLoop {
|
|
|
217
250
|
return this.gl.isContextLost();
|
|
218
251
|
}
|
|
219
252
|
|
|
220
|
-
|
|
221
|
-
return this.props.
|
|
253
|
+
onCreateDevice(deviceProps) {
|
|
254
|
+
return this.props.onCreateDevice(deviceProps);
|
|
222
255
|
}
|
|
223
256
|
|
|
224
|
-
onInitialize(
|
|
225
|
-
return this.props.onInitialize(
|
|
257
|
+
onInitialize(animationProps) {
|
|
258
|
+
return this.props.onInitialize(animationProps);
|
|
226
259
|
}
|
|
227
260
|
|
|
228
|
-
onRender(
|
|
229
|
-
return this.props.onRender(
|
|
261
|
+
onRender(animationProps) {
|
|
262
|
+
return this.props.onRender(animationProps);
|
|
230
263
|
}
|
|
231
264
|
|
|
232
|
-
onFinalize(
|
|
233
|
-
return this.props.onFinalize(
|
|
265
|
+
onFinalize(animationProps) {
|
|
266
|
+
return this.props.onFinalize(animationProps);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
onCreateContext(props) {
|
|
270
|
+
return this.props.onCreateContext(props);
|
|
234
271
|
}
|
|
235
272
|
|
|
236
273
|
getHTMLControlValue(id, defaultValue = 1) {
|
|
@@ -238,24 +275,22 @@ export default class AnimationLoop {
|
|
|
238
275
|
return element ? Number(element.value) : defaultValue;
|
|
239
276
|
}
|
|
240
277
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
return this;
|
|
244
|
-
}
|
|
278
|
+
_initialize(props) {
|
|
279
|
+
this._createDevice(props);
|
|
245
280
|
|
|
246
|
-
|
|
247
|
-
const renderFrame = () => {
|
|
248
|
-
if (!this._running) {
|
|
249
|
-
return;
|
|
250
|
-
}
|
|
281
|
+
this._createFramebuffer();
|
|
251
282
|
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
283
|
+
this._startEventHandling();
|
|
284
|
+
|
|
285
|
+
this._initializeCallbackData();
|
|
286
|
+
|
|
287
|
+
this._updateCallbackData();
|
|
255
288
|
|
|
256
|
-
this.
|
|
289
|
+
this._resizeCanvasDrawingBuffer();
|
|
290
|
+
|
|
291
|
+
this._resizeViewport();
|
|
257
292
|
|
|
258
|
-
this.
|
|
293
|
+
this._gpuTimeQuery = Query.isSupported(this.gl, ['timers']) ? new Query(this.gl) : null;
|
|
259
294
|
}
|
|
260
295
|
|
|
261
296
|
_getPageLoadPromise() {
|
|
@@ -288,34 +323,41 @@ export default class AnimationLoop {
|
|
|
288
323
|
this.display = display;
|
|
289
324
|
}
|
|
290
325
|
|
|
291
|
-
|
|
292
|
-
if (this.
|
|
293
|
-
return
|
|
326
|
+
_requestAnimationFrame() {
|
|
327
|
+
if (!this._running) {
|
|
328
|
+
return;
|
|
294
329
|
}
|
|
295
330
|
|
|
296
|
-
|
|
331
|
+
this._animationFrameId = requestAnimationFrame(this._animationFrame.bind(this));
|
|
297
332
|
}
|
|
298
333
|
|
|
299
|
-
|
|
300
|
-
if (this.
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
334
|
+
_cancelAnimationFrame() {
|
|
335
|
+
if (this._animationFrameId !== null) {
|
|
336
|
+
return;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
cancelAnimationFrame(this._animationFrameId);
|
|
340
|
+
this._animationFrameId = null;
|
|
341
|
+
}
|
|
304
342
|
|
|
305
|
-
|
|
343
|
+
_animationFrame() {
|
|
344
|
+
if (!this._running) {
|
|
345
|
+
return;
|
|
306
346
|
}
|
|
307
347
|
|
|
308
|
-
|
|
348
|
+
this.redraw();
|
|
349
|
+
|
|
350
|
+
this._requestAnimationFrame();
|
|
309
351
|
}
|
|
310
352
|
|
|
311
|
-
_renderFrame(
|
|
353
|
+
_renderFrame(props) {
|
|
312
354
|
if (this.display) {
|
|
313
|
-
this.display._renderFrame(
|
|
355
|
+
this.display._renderFrame(props);
|
|
314
356
|
|
|
315
357
|
return;
|
|
316
358
|
}
|
|
317
359
|
|
|
318
|
-
this.onRender(
|
|
360
|
+
this.onRender(props);
|
|
319
361
|
}
|
|
320
362
|
|
|
321
363
|
_clearNeedsRedraw() {
|
|
@@ -332,21 +374,24 @@ export default class AnimationLoop {
|
|
|
332
374
|
|
|
333
375
|
_initializeCallbackData() {
|
|
334
376
|
this.animationProps = {
|
|
377
|
+
device: this.device,
|
|
335
378
|
gl: this.gl,
|
|
336
379
|
stop: this.stop,
|
|
337
380
|
canvas: this.gl.canvas,
|
|
338
|
-
|
|
339
|
-
useDevicePixels: this.useDevicePixels,
|
|
381
|
+
useDevicePixels: this.props.useDevicePixels,
|
|
340
382
|
needsRedraw: null,
|
|
341
383
|
startTime: Date.now(),
|
|
342
384
|
engineTime: 0,
|
|
343
385
|
tick: 0,
|
|
344
386
|
tock: 0,
|
|
387
|
+
timeline: this.timeline,
|
|
388
|
+
animationLoop: this,
|
|
345
389
|
time: 0,
|
|
390
|
+
_mousePosition: null,
|
|
391
|
+
framebuffer: this.framebuffer,
|
|
346
392
|
_timeline: this.timeline,
|
|
347
393
|
_loop: this,
|
|
348
|
-
_animationLoop: this
|
|
349
|
-
_mousePosition: null
|
|
394
|
+
_animationLoop: this
|
|
350
395
|
};
|
|
351
396
|
}
|
|
352
397
|
|
|
@@ -378,7 +423,6 @@ export default class AnimationLoop {
|
|
|
378
423
|
this.animationProps.tick = Math.floor(this.animationProps.time / 1000 * 60);
|
|
379
424
|
this.animationProps.tock++;
|
|
380
425
|
this.animationProps.time = this.timeline ? this.timeline.getTime() : this.animationProps.engineTime;
|
|
381
|
-
this.animationProps._offScreen = this.offScreen;
|
|
382
426
|
}
|
|
383
427
|
|
|
384
428
|
_finalizeCallbackData() {
|
|
@@ -391,10 +435,13 @@ export default class AnimationLoop {
|
|
|
391
435
|
}
|
|
392
436
|
}
|
|
393
437
|
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
438
|
+
_createDevice(props) {
|
|
439
|
+
const deviceProps = { ...this.props,
|
|
440
|
+
...props,
|
|
441
|
+
...this.props.glOptions
|
|
442
|
+
};
|
|
443
|
+
this.device = this.onCreateDevice(deviceProps);
|
|
444
|
+
this.gl = this.device.gl;
|
|
398
445
|
|
|
399
446
|
if (!isWebGL(this.gl)) {
|
|
400
447
|
throw new Error('AnimationLoop.onCreateContext - illegal context returned');
|
|
@@ -448,30 +495,15 @@ export default class AnimationLoop {
|
|
|
448
495
|
}
|
|
449
496
|
|
|
450
497
|
_resizeViewport() {
|
|
451
|
-
if (this.autoResizeViewport) {
|
|
498
|
+
if (this.props.autoResizeViewport) {
|
|
452
499
|
this.gl.viewport(0, 0, this.gl.drawingBufferWidth, this.gl.drawingBufferHeight);
|
|
453
500
|
}
|
|
454
501
|
}
|
|
455
502
|
|
|
456
503
|
_resizeCanvasDrawingBuffer() {
|
|
457
|
-
if (this.autoResizeDrawingBuffer) {
|
|
458
|
-
|
|
459
|
-
useDevicePixels: this.useDevicePixels
|
|
460
|
-
});
|
|
461
|
-
}
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
_createFramebuffer() {
|
|
465
|
-
if (this.props.createFramebuffer) {
|
|
466
|
-
this.framebuffer = new Framebuffer(this.gl);
|
|
467
|
-
}
|
|
468
|
-
}
|
|
469
|
-
|
|
470
|
-
_resizeFramebuffer() {
|
|
471
|
-
if (this.framebuffer) {
|
|
472
|
-
this.framebuffer.resize({
|
|
473
|
-
width: this.gl.drawingBufferWidth,
|
|
474
|
-
height: this.gl.drawingBufferHeight
|
|
504
|
+
if (this.props.autoResizeDrawingBuffer) {
|
|
505
|
+
this.device.resize({
|
|
506
|
+
useDevicePixels: this.props.useDevicePixels
|
|
475
507
|
});
|
|
476
508
|
}
|
|
477
509
|
}
|
|
@@ -518,5 +550,20 @@ export default class AnimationLoop {
|
|
|
518
550
|
this.animationProps._mousePosition = null;
|
|
519
551
|
}
|
|
520
552
|
|
|
553
|
+
_createFramebuffer() {
|
|
554
|
+
if (this.props.createFramebuffer) {
|
|
555
|
+
this.framebuffer = new Framebuffer(this.gl);
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
_resizeFramebuffer() {
|
|
560
|
+
if (this.framebuffer) {
|
|
561
|
+
this.framebuffer.resize({
|
|
562
|
+
width: this.gl.drawingBufferWidth,
|
|
563
|
+
height: this.gl.drawingBufferHeight
|
|
564
|
+
});
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
|
|
521
568
|
}
|
|
522
569
|
//# sourceMappingURL=animation-loop.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/lib/animation-loop.ts"],"names":["luma","lumaStats","log","isWebGL","resetParameters","requestAnimationFrame","cancelAnimationFrame","Query","Framebuffer","isBrowser","isPage","document","statIdCounter","DEFAULT_ANIMATION_LOOP_PROPS","onCreateDevice","props","createDevice","onCreateContext","onAddHTML","onInitialize","onRender","onFinalize","onError","error","console","device","debug","useDevicePixels","autoResizeViewport","autoResizeDrawingBuffer","stats","get","gl","glOptions","createFramebuffer","AnimationLoop","constructor","deprecated","useDevicePixelRatio","cpuTime","gpuTime","frameRate","setProps","start","bind","stop","_onMousemove","_onMouseleave","destroy","_setDisplay","delete","setNeedsRedraw","reason","needsRedraw","opts","_start","_running","_getPageLoadPromise","appContext","_initialized","_initialize","animationProps","_addCallbackData","_cancelAnimationFrame","_requestAnimationFrame","redraw","isContextLost","_beginTimers","_setupFrame","_updateCallbackData","_renderFrame","_clearNeedsRedraw","_resolveNextFrame","_nextFramePromise","_endTimers","_finalizeCallbackData","attachTimeline","timeline","detachTimeline","waitForRender","Promise","resolve","toDataURL","canvas","deviceProps","getHTMLControlValue","id","defaultValue","element","getElementById","Number","value","_createDevice","_createFramebuffer","_startEventHandling","_initializeCallbackData","_resizeCanvasDrawingBuffer","_resizeViewport","_gpuTimeQuery","isSupported","_pageLoadPromise","reject","readyState","window","addEventListener","display","animationLoop","_animationFrameId","_animationFrame","_resizeFramebuffer","startTime","Date","now","engineTime","tick","tock","time","_mousePosition","framebuffer","_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","resize","timeEnd","timeStart","isResultAvailable","isTimerDisjoint","addTime","getTimerMilliseconds","beginTimeElapsedQuery","end","e","offsetX","offsetY"],"mappings":";AAAA,SAAQA,IAAR,QAA2B,cAA3B;AACA,SACEC,SADF,EAGEC,GAHF,QAKO,cALP;AAQA,SACEC,OADF,EAKEC,eALF,QAMO,gBANP;AASA,SACEC,qBADF,EAEEC,oBAFF,EAGEC,KAHF,EAKEC,WALF,QAMO,gBANP;AASA,SAAQC,SAAR,QAAwB,eAAxB;AAQA,MAAMC,MAAM,GAAGD,SAAS,MAAM,OAAOE,QAAP,KAAoB,WAAlD;AAEA,IAAIC,aAAa,GAAG,CAApB;AAqEA,MAAMC,4BAA0D,GAAG;AACjEC,EAAAA,cAAc,EAAGC,KAAD,IAAwBf,IAAI,CAACgB,YAAL,CAAkBD,KAAlB,CADyB;AAEjEE,EAAAA,eAAe,EAAE,IAFgD;AAGjEC,EAAAA,SAAS,EAAE,IAHsD;AAIjEC,EAAAA,YAAY,EAAE,OAAO,EAAP,CAJmD;AAKjEC,EAAAA,QAAQ,EAAE,MAAM,CAAE,CAL+C;AAMjEC,EAAAA,UAAU,EAAE,MAAM,CAAE,CAN6C;AAOjEC,EAAAA,OAAO,EAAGC,KAAD,IAAWC,OAAO,CAACD,KAAR,CAAcA,KAAd,CAP6C;AASjEE,EAAAA,MAAM,EAAE,IATyD;AAUjEC,EAAAA,KAAK,EAAE,KAV0D;AAajEC,EAAAA,eAAe,EAAE,IAbgD;AAcjEC,EAAAA,kBAAkB,EAAE,IAd6C;AAejEC,EAAAA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K3F,EAAL,CAAQmH;AAFM,OAAxB;AAID;AACF;;AA9kBgC","sourcesContent":["import {luma, Device} from '@luma.gl/api';\nimport {\n lumaStats,\n // TODO - remove dependency on framebuffer (bundle size impact)\n log,\n assert\n} from '@luma.gl/api';\nimport type {WebGLDeviceProps} from '@luma.gl/webgl'\nimport {WebGLDevice} from '@luma.gl/webgl';\nimport {\n isWebGL,\n // createGLContext,\n // instrumentGLContext,\n // resizeGLContext,\n resetParameters\n} from '@luma.gl/webgl';\n\n\nimport {\n requestAnimationFrame,\n cancelAnimationFrame,\n Query,\n // TODO - remove dependency on framebuffer (bundle size impact)\n Framebuffer\n} from '@luma.gl/webgl';\n\nimport { Stats, Stat } from '@probe.gl/stats'\nimport {isBrowser} from '@probe.gl/env';\n\nimport { Timeline } from '../animation/timeline'\n\n\ntype DeviceProps = WebGLDeviceProps;\ntype ContextProps = WebGLDeviceProps;\n\nconst isPage = isBrowser() && typeof document !== 'undefined';\n\nlet statIdCounter = 0;\n\n/** AnimationLoop properties */\nexport type AnimationLoopProps = {\n onCreateDevice?: (props: DeviceProps) => Device;\n onCreateContext?: (props: ContextProps) => WebGLRenderingContext; // TODO: signature from createGLContext\n onAddHTML?: (div: HTMLDivElement) => string; // innerHTML\n onInitialize?: (animationProps: AnimationProps) => {} | void;\n onRender?: (animationProps: AnimationProps) => void;\n onFinalize?: (animationProps: AnimationProps) => 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\n /** @deprecated Will be removed */\n createFramebuffer?: boolean;\n};\n\nexport type AnimationProps = {\n device: Device;\n\n stop: () => AnimationLoop\n canvas: HTMLCanvasElement | OffscreenCanvas\n // Initial values\n useDevicePixels: number | boolean\n needsRedraw?: string\n // Animation props\n startTime: number\n engineTime: number\n tick: number\n tock: number\n\n // Timeline time for back compatibility\n time: number\n\n width: number\n height: number\n aspect: number\n\n timeline: Timeline\n animationLoop: AnimationLoop\n\n // Experimental\n _mousePosition?: [number, number] // [offsetX, offsetY],\n\n /** @deprecated Will be removed, create your own Framebuffer */\n framebuffer: Framebuffer\n /** @deprecated Use .device */\n gl: WebGLRenderingContext\n\n /** @deprecated Use .timeline */\n _timeline: Timeline\n /** @deprecated Use .animationLoop */\n _loop: AnimationLoop\n /** @deprecated Use .animationLoop */\n _animationLoop: AnimationLoop\n}\n\nconst DEFAULT_ANIMATION_LOOP_PROPS: Required<AnimationLoopProps> = {\n onCreateDevice: (props: DeviceProps) => luma.createDevice(props),\n onCreateContext: null,\n onAddHTML: null,\n onInitialize: () => ({}),\n onRender: () => {},\n onFinalize: () => {},\n onError: (error) => console.error(error), // eslint-disable-line no-console\n\n device: null,\n debug: false,\n\n // view parameters\n useDevicePixels: true,\n autoResizeViewport: true,\n autoResizeDrawingBuffer: true,\n stats: lumaStats.get(`animation-loop-${statIdCounter++}`),\n\n // deprecated\n // onCreateContext: (opts) => createGLContext(opts),\n gl: null,\n glOptions: {},\n createFramebuffer: false\n};\n\n/** Convenient animation loop */\nexport default class AnimationLoop {\n device: Device;\n canvas: HTMLCanvasElement | OffscreenCanvas;\n\n props: Required<AnimationLoopProps>;\n animationProps: AnimationProps;\n framebuffer: Framebuffer = 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 = null;\n _pageLoadPromise: Promise<{}> | null = null;\n _nextFramePromise: Promise<AnimationLoop> | null = null;\n _resolveNextFrame: ((AnimationLoop) => void) | null = null;\n _cpuStartTime: number = 0;\n\n _gpuTimeQuery: Query | null = null;\n\n /** @deprecated */\n gl: WebGLRenderingContext;\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 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: AnimationLoopProps): 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 * @param {Object} context - contains frame specific info (E.g. tick, width, height, etc)\n */\n async _start(opts) {\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 this._initialize(opts);\n\n // Note: onIntialize can return a promise (in case app needs to load resources)\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<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() {\n this.setNeedsRedraw('toDataURL');\n\n await this.waitForRender();\n\n return this.gl.canvas.toDataURL();\n }\n\n isContextLost(): boolean {\n return this.gl.isContextLost();\n }\n\n onCreateDevice(deviceProps: DeviceProps) {\n return this.props.onCreateDevice(deviceProps);\n }\n\n onInitialize(animationProps: AnimationProps): {} | void {\n return this.props.onInitialize(animationProps);\n }\n\n onRender(animationProps: AnimationProps) {\n return this.props.onRender(animationProps);\n }\n\n onFinalize(animationProps: AnimationProps) {\n return this.props.onFinalize(animationProps);\n }\n\n // DEPRECATED/REMOVED METHODS\n\n /** @deprecated Use .onCreateDevice() */\n onCreateContext(props: ContextProps) {\n return this.props.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: AnimationLoopProps) {\n // Create the WebGL context\n this._createDevice(props);\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) {\n if (this.display) {\n this.display.delete();\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: AnimationProps) {\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 // Initialize the object that will be passed to app callbacks\n _initializeCallbackData() {\n // @ts-expect-error\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 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 _timeline: this.timeline,\n _loop: this,\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 _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 = this.onCreateDevice(deviceProps);\n // @ts-expect-error\n this.gl = this.device.gl;\n\n if (!isWebGL(this.gl)) {\n throw new Error('AnimationLoop.onCreateContext - illegal context returned');\n }\n\n // Reset the WebGL context.\n resetParameters(this.gl);\n\n this._createInfoDiv();\n }\n\n _createInfoDiv() {\n if (this.gl.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 wrapperDiv.appendChild(this.gl.canvas);\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 const {canvas} = this.gl;\n\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 as WebGLDevice).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 Framebuffer(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"],"file":"animation-loop.js"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Buffer } from '@luma.gl/webgl';
|
|
2
|
+
export declare function getBuffersFromGeometry(gl: WebGLRenderingContext, geometry: any, options?: any): Record<string, Buffer | [Buffer, {}]>;
|
|
3
|
+
export declare function inferAttributeAccessor(attributeName: any, attribute: any): void;
|
|
4
|
+
//# sourceMappingURL=model-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-utils.d.ts","sourceRoot":"","sources":["../../src/lib/model-utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,MAAM,EAAS,MAAM,gBAAgB,CAAC;AAY9C,wBAAgB,sBAAsB,CAAC,EAAE,EAAE,qBAAqB,EAAE,QAAQ,KAAA,EAAE,OAAO,CAAC,KAAA,yCA2CnF;AASD,wBAAgB,sBAAsB,CAAC,aAAa,KAAA,EAAE,SAAS,KAAA,QA8B9D"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import GL from '@luma.gl/constants';
|
|
1
2
|
import { Buffer, assert } from '@luma.gl/webgl';
|
|
2
3
|
const GLTF_TO_LUMA_ATTRIBUTE_MAP = {
|
|
3
4
|
POSITION: 'positions',
|
|
@@ -38,7 +39,7 @@ export function getBuffersFromGeometry(gl, geometry, options) {
|
|
|
38
39
|
};
|
|
39
40
|
buffers.indices = [new Buffer(gl, {
|
|
40
41
|
data,
|
|
41
|
-
target:
|
|
42
|
+
target: GL.ELEMENT_ARRAY_BUFFER
|
|
42
43
|
}), accessor];
|
|
43
44
|
}
|
|
44
45
|
|
|
@@ -85,6 +86,6 @@ export function inferAttributeAccessor(attributeName, attribute) {
|
|
|
85
86
|
default:
|
|
86
87
|
}
|
|
87
88
|
|
|
88
|
-
assert(Number.isFinite(attribute.size),
|
|
89
|
+
assert(Number.isFinite(attribute.size), "attribute ".concat(attributeName, " needs size"));
|
|
89
90
|
}
|
|
90
91
|
//# sourceMappingURL=model-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/lib/model-utils.ts"],"names":["GL","Buffer","assert","GLTF_TO_LUMA_ATTRIBUTE_MAP","POSITION","NORMAL","COLOR_0","TEXCOORD_0","TEXCOORD_1","TEXCOORD_2","getBuffersFromGeometry","gl","geometry","options","buffers","indices","name","attributes","attribute","remappedName","mapAttributeName","constant","value","typedArray","accessor","inferAttributeAccessor","data","Uint16Array","Uint32Array","size","isIndexed","undefined","target","ELEMENT_ARRAY_BUFFER","attributeMap","attributeName","category","Number","isFinite"],"mappings":"AAAA,OAAOA,EAAP,MAAe,oBAAf;AACA,SAAQC,MAAR,EAAgBC,MAAhB,QAA6B,gBAA7B;AAGA,MAAMC,0BAA0B,GAAG;AACjCC,EAAAA,QAAQ,EAAE,WADuB;AAEjCC,EAAAA,MAAM,EAAE,SAFyB;AAGjCC,EAAAA,OAAO,EAAE,QAHwB;AAIjCC,EAAAA,UAAU,EAAE,WAJqB;AAKjCC,EAAAA,UAAU,EAAE,YALqB;AAMjCC,EAAAA,UAAU,EAAE;AANqB,CAAnC;AASA,OAAO,SAASC,sBAAT,CAAgCC,EAAhC,EAA2DC,QAA3D,EAAqEC,OAArE,EAA+E;AACpF,QAAMC,OAA8C,GAAG,EAAvD;AACA,MAAIC,OAAO,GAAGH,QAAQ,CAACG,OAAvB;;AAEA,OAAK,MAAMC,IAAX,IAAmBJ,QAAQ,CAACK,UAA5B,EAAwC;AACtC,UAAMC,SAAS,GAAGN,QAAQ,CAACK,UAAT,CAAoBD,IAApB,CAAlB;AACA,UAAMG,YAAY,GAAGC,gBAAgB,CAACJ,IAAD,EAAOH,OAAP,CAArC;;AAEA,QAAIG,IAAI,KAAK,SAAb,EAAwB;AACtBD,MAAAA,OAAO,GAAGG,SAAV;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AASS,sBAAT,CAAgCU,aAAhC,EAA+CjB,SAA/C,EAA0D;AAC/D,MAAIkB,QAAJ;;AACA,UAAQD,aAAR;AACE,SAAK,WAAL;AACA,SAAK,WAAL;AACA,SAAK,WAAL;AACA,SAAK,WAAL;AACEC,MAAAA,QAAQ,GAAG,KAAX;AACA;;AACF,SAAK,UAAL;AACA,SAAK,WAAL;AACA,SAAK,SAAL;AACA,SAAK,eAAL;AACEA,MAAAA,QAAQ,GAAG,SAAX;AACA;;AACF;AAbF;;AAiBA,UAAQA,QAAR;AACE,SAAK,SAAL;AACElB,MAAAA,SAAS,CAACW,IAAV,GAAiBX,SAAS,CAACW,IAAV,IAAkB,CAAnC;AACA;;AACF,SAAK,KAAL;AACEX,MAAAA,SAAS,CAACW,IAAV,GAAiBX,SAAS,CAACW,IAAV,IAAkB,CAAnC;AACA;;AACF;AAPF;;AAUA3B,EAAAA,MAAM,CAACmC,MAAM,CAACC,QAAP,CAAgBpB,SAAS,CAACW,IAA1B,CAAD,sBAA+CM,aAA/C,iBAAN;AACD","sourcesContent":["import GL from '@luma.gl/constants';\nimport {Buffer, assert} from '@luma.gl/webgl';\n\n// Support for mapping new geometries with glTF attribute names to \"classic\" luma.gl shader names\nconst GLTF_TO_LUMA_ATTRIBUTE_MAP = {\n POSITION: 'positions',\n NORMAL: 'normals',\n COLOR_0: 'colors',\n TEXCOORD_0: 'texCoords',\n TEXCOORD_1: 'texCoords1',\n TEXCOORD_2: 'texCoords2'\n};\n\nexport function getBuffersFromGeometry(gl: WebGLRenderingContext, geometry, options?) {\n const buffers: Record<string, Buffer | [Buffer, {}]> = {};\n let indices = geometry.indices;\n\n for (const name in geometry.attributes) {\n const attribute = geometry.attributes[name];\n const remappedName = mapAttributeName(name, options);\n\n if (name === 'indices') {\n indices = attribute;\n } else if (attribute.constant) {\n buffers[remappedName] = attribute.value;\n } else {\n const typedArray = attribute.value;\n // Create accessor by copying the attribute and removing `value``\n const accessor = {...attribute};\n delete accessor.value;\n buffers[remappedName] = [new Buffer(gl, typedArray), accessor];\n\n inferAttributeAccessor(name, accessor);\n }\n }\n\n if (indices) {\n const data = indices.value || indices;\n assert(\n data instanceof Uint16Array || data instanceof Uint32Array,\n 'attribute array for \"indices\" must be of integer type'\n );\n const accessor = {\n size: 1,\n isIndexed: indices.isIndexed === undefined ? true : indices.isIndexed\n };\n buffers.indices = [\n new Buffer(gl, {\n data,\n target: GL.ELEMENT_ARRAY_BUFFER\n }),\n accessor\n ];\n }\n\n return buffers;\n}\n\nfunction mapAttributeName(name, options) {\n const {attributeMap = GLTF_TO_LUMA_ATTRIBUTE_MAP} = options || {};\n return (attributeMap && attributeMap[name]) || name;\n}\n\n// Check for well known attribute names\n// eslint-disable-next-line complexity\nexport function inferAttributeAccessor(attributeName, attribute) {\n let category;\n switch (attributeName) {\n case 'texCoords':\n case 'texCoord1':\n case 'texCoord2':\n case 'texCoord3':\n category = 'uvs';\n break;\n case 'vertices':\n case 'positions':\n case 'normals':\n case 'pickingColors':\n category = 'vectors';\n break;\n default:\n }\n\n // Check for categorys\n switch (category) {\n case 'vectors':\n attribute.size = attribute.size || 3;\n break;\n case 'uvs':\n attribute.size = attribute.size || 2;\n break;\n default:\n }\n\n assert(Number.isFinite(attribute.size), `attribute ${attributeName} needs size`);\n}\n"],"file":"model-utils.js"}
|