@luma.gl/engine 8.5.7 → 8.6.0-alpha.1
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 +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/animation-loop.d.ts +120 -0
- package/dist/lib/animation-loop.d.ts.map +1 -0
- package/dist/{esm/lib → lib}/animation-loop.js +135 -97
- 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 +97 -0
- package/dist/lib/model.d.ts.map +1 -0
- package/dist/{esm/lib → lib}/model.js +63 -13
- package/dist/lib/model.js.map +1 -0
- package/dist/lib/program-manager.d.ts +38 -0
- package/dist/lib/program-manager.d.ts.map +1 -0
- package/dist/{esm/lib → lib}/program-manager.js +22 -10
- package/dist/lib/program-manager.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 +13 -5
- 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 +43 -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 +28 -0
- package/dist/transform/transform.d.ts.map +1 -0
- package/dist/{esm/transform → transform}/transform.js +39 -34
- 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 +10 -10
- 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 +30 -0
- package/src/lib/{animation-loop.js → animation-loop.ts} +237 -130
- package/src/lib/{model-utils.js → model-utils.ts} +2 -2
- package/src/lib/{model.js → model.ts} +148 -57
- package/src/lib/{program-manager.js → program-manager.ts} +46 -26
- package/src/transform/{buffer-transform.js → buffer-transform.ts} +40 -24
- package/src/transform/{texture-transform.js → texture-transform.ts} +34 -23
- package/src/transform/{transform-shader-utils.js → transform-shader-utils.ts} +55 -27
- package/src/transform/transform-types.ts +41 -0
- package/src/transform/{transform.js → transform.ts} +45 -49
- package/src/utils/{clip-space.js → clip-space.ts} +4 -3
- package/dist/dist.js +0 -32248
- 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/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/utils/clip-space.d.ts +0 -5
|
@@ -1,67 +1,94 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
1
2
|
import { isWebGL, createGLContext, instrumentGLContext, resizeGLContext, resetParameters } from '@luma.gl/gltools';
|
|
2
|
-
import { requestAnimationFrame, cancelAnimationFrame, Query, lumaStats, Framebuffer, log
|
|
3
|
+
import { requestAnimationFrame, cancelAnimationFrame, Query, lumaStats, Framebuffer, log } from '@luma.gl/webgl';
|
|
3
4
|
import { isBrowser } from 'probe.gl/env';
|
|
4
5
|
const isPage = isBrowser() && typeof document !== 'undefined';
|
|
5
6
|
let statIdCounter = 0;
|
|
7
|
+
const DEFAULT_ANIMATION_LOOP_PROPS = {
|
|
8
|
+
onCreateContext: opts => createGLContext(opts),
|
|
9
|
+
onAddHTML: null,
|
|
10
|
+
onInitialize: () => ({}),
|
|
11
|
+
onRender: () => {},
|
|
12
|
+
onFinalize: () => {},
|
|
13
|
+
onError: error => console.error(error),
|
|
14
|
+
gl: null,
|
|
15
|
+
glOptions: {},
|
|
16
|
+
debug: false,
|
|
17
|
+
createFramebuffer: false,
|
|
18
|
+
useDevicePixels: true,
|
|
19
|
+
autoResizeViewport: true,
|
|
20
|
+
autoResizeDrawingBuffer: true,
|
|
21
|
+
stats: lumaStats.get("animation-loop-".concat(statIdCounter++))
|
|
22
|
+
};
|
|
6
23
|
export default class AnimationLoop {
|
|
7
24
|
constructor(props = {}) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
25
|
+
_defineProperty(this, "animationProps", void 0);
|
|
26
|
+
|
|
27
|
+
_defineProperty(this, "props", void 0);
|
|
28
|
+
|
|
29
|
+
_defineProperty(this, "gl", void 0);
|
|
30
|
+
|
|
31
|
+
_defineProperty(this, "canvas", void 0);
|
|
32
|
+
|
|
33
|
+
_defineProperty(this, "framebuffer", null);
|
|
34
|
+
|
|
35
|
+
_defineProperty(this, "timeline", null);
|
|
36
|
+
|
|
37
|
+
_defineProperty(this, "stats", void 0);
|
|
38
|
+
|
|
39
|
+
_defineProperty(this, "cpuTime", void 0);
|
|
40
|
+
|
|
41
|
+
_defineProperty(this, "gpuTime", void 0);
|
|
42
|
+
|
|
43
|
+
_defineProperty(this, "frameRate", void 0);
|
|
44
|
+
|
|
45
|
+
_defineProperty(this, "offScreen", void 0);
|
|
46
|
+
|
|
47
|
+
_defineProperty(this, "display", void 0);
|
|
48
|
+
|
|
49
|
+
_defineProperty(this, "needsRedraw", 'initialized');
|
|
50
|
+
|
|
51
|
+
_defineProperty(this, "_initialized", false);
|
|
52
|
+
|
|
53
|
+
_defineProperty(this, "_running", false);
|
|
54
|
+
|
|
55
|
+
_defineProperty(this, "_animationFrameId", null);
|
|
56
|
+
|
|
57
|
+
_defineProperty(this, "_pageLoadPromise", null);
|
|
58
|
+
|
|
59
|
+
_defineProperty(this, "_nextFramePromise", null);
|
|
60
|
+
|
|
61
|
+
_defineProperty(this, "_resolveNextFrame", null);
|
|
62
|
+
|
|
63
|
+
_defineProperty(this, "_cpuStartTime", 0);
|
|
64
|
+
|
|
65
|
+
_defineProperty(this, "_gpuTimeQuery", null);
|
|
66
|
+
|
|
67
|
+
this.props = { ...DEFAULT_ANIMATION_LOOP_PROPS,
|
|
68
|
+
...props
|
|
69
|
+
};
|
|
70
|
+
props = this.props;
|
|
23
71
|
let {
|
|
24
72
|
useDevicePixels = true
|
|
25
|
-
} = props;
|
|
73
|
+
} = this.props;
|
|
26
74
|
|
|
27
75
|
if ('useDevicePixelRatio' in props) {
|
|
28
76
|
log.deprecated('useDevicePixelRatio', 'useDevicePixels')();
|
|
29
77
|
useDevicePixels = props.useDevicePixelRatio;
|
|
30
78
|
}
|
|
31
79
|
|
|
32
|
-
this.
|
|
33
|
-
|
|
34
|
-
onAddHTML,
|
|
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;
|
|
80
|
+
this.gl = props.gl;
|
|
81
|
+
this.stats = props.stats;
|
|
48
82
|
this.cpuTime = this.stats.get('CPU Time');
|
|
49
83
|
this.gpuTime = this.stats.get('GPU Time');
|
|
50
84
|
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
85
|
this.setProps({
|
|
58
|
-
autoResizeViewport,
|
|
59
|
-
autoResizeDrawingBuffer,
|
|
86
|
+
autoResizeViewport: props.autoResizeViewport,
|
|
87
|
+
autoResizeDrawingBuffer: props.autoResizeDrawingBuffer,
|
|
60
88
|
useDevicePixels
|
|
61
89
|
});
|
|
62
90
|
this.start = this.start.bind(this);
|
|
63
91
|
this.stop = this.stop.bind(this);
|
|
64
|
-
this._pageLoadPromise = null;
|
|
65
92
|
this._onMousemove = this._onMousemove.bind(this);
|
|
66
93
|
this._onMouseleave = this._onMouseleave.bind(this);
|
|
67
94
|
}
|
|
@@ -73,71 +100,73 @@ export default class AnimationLoop {
|
|
|
73
100
|
}
|
|
74
101
|
|
|
75
102
|
setNeedsRedraw(reason) {
|
|
76
|
-
assert(typeof reason === 'string');
|
|
77
103
|
this.needsRedraw = this.needsRedraw || reason;
|
|
78
104
|
return this;
|
|
79
105
|
}
|
|
80
106
|
|
|
81
107
|
setProps(props) {
|
|
82
108
|
if ('autoResizeViewport' in props) {
|
|
83
|
-
this.autoResizeViewport = props.autoResizeViewport;
|
|
109
|
+
this.props.autoResizeViewport = props.autoResizeViewport;
|
|
84
110
|
}
|
|
85
111
|
|
|
86
112
|
if ('autoResizeDrawingBuffer' in props) {
|
|
87
|
-
this.autoResizeDrawingBuffer = props.autoResizeDrawingBuffer;
|
|
113
|
+
this.props.autoResizeDrawingBuffer = props.autoResizeDrawingBuffer;
|
|
88
114
|
}
|
|
89
115
|
|
|
90
116
|
if ('useDevicePixels' in props) {
|
|
91
|
-
this.useDevicePixels = props.useDevicePixels;
|
|
117
|
+
this.props.useDevicePixels = props.useDevicePixels;
|
|
92
118
|
}
|
|
93
119
|
|
|
94
120
|
return this;
|
|
95
121
|
}
|
|
96
122
|
|
|
97
123
|
start(opts = {}) {
|
|
124
|
+
this._start(opts);
|
|
125
|
+
|
|
126
|
+
return this;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
async _start(opts) {
|
|
98
130
|
if (this._running) {
|
|
99
131
|
return this;
|
|
100
132
|
}
|
|
101
133
|
|
|
102
134
|
this._running = true;
|
|
103
135
|
|
|
104
|
-
|
|
105
|
-
|
|
136
|
+
try {
|
|
137
|
+
await this._getPageLoadPromise();
|
|
138
|
+
|
|
139
|
+
if (!this._running) {
|
|
106
140
|
return null;
|
|
107
141
|
}
|
|
108
142
|
|
|
109
|
-
|
|
143
|
+
let appContext;
|
|
110
144
|
|
|
111
|
-
this.
|
|
145
|
+
if (!this._initialized) {
|
|
146
|
+
this._initialized = true;
|
|
112
147
|
|
|
113
|
-
|
|
148
|
+
this._initialize(opts);
|
|
114
149
|
|
|
115
|
-
|
|
150
|
+
appContext = await this.onInitialize(this.animationProps);
|
|
116
151
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
this._resizeCanvasDrawingBuffer();
|
|
152
|
+
this._addCallbackData(appContext || {});
|
|
153
|
+
}
|
|
120
154
|
|
|
121
|
-
this.
|
|
155
|
+
if (!this._running) {
|
|
156
|
+
return null;
|
|
157
|
+
}
|
|
122
158
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
return this.onInitialize(this.animationProps);
|
|
126
|
-
}).then(appContext => {
|
|
127
|
-
if (this._running) {
|
|
128
|
-
this._addCallbackData(appContext || {});
|
|
159
|
+
if (appContext !== false) {
|
|
160
|
+
this._cancelAnimationFrame();
|
|
129
161
|
|
|
130
|
-
|
|
131
|
-
this._startLoop();
|
|
132
|
-
}
|
|
162
|
+
this._requestAnimationFrame();
|
|
133
163
|
}
|
|
134
|
-
});
|
|
135
164
|
|
|
136
|
-
|
|
137
|
-
|
|
165
|
+
return this;
|
|
166
|
+
} catch (error) {
|
|
167
|
+
this.props.onError(error);
|
|
168
|
+
return null;
|
|
138
169
|
}
|
|
139
|
-
|
|
140
|
-
return this;
|
|
141
170
|
}
|
|
142
171
|
|
|
143
172
|
redraw() {
|
|
@@ -175,11 +204,10 @@ export default class AnimationLoop {
|
|
|
175
204
|
if (this._running) {
|
|
176
205
|
this._finalizeCallbackData();
|
|
177
206
|
|
|
178
|
-
this._cancelAnimationFrame(
|
|
207
|
+
this._cancelAnimationFrame();
|
|
179
208
|
|
|
180
209
|
this._nextFramePromise = null;
|
|
181
210
|
this._resolveNextFrame = null;
|
|
182
|
-
this._animationFrameId = null;
|
|
183
211
|
this._running = false;
|
|
184
212
|
}
|
|
185
213
|
|
|
@@ -243,19 +271,22 @@ export default class AnimationLoop {
|
|
|
243
271
|
return this;
|
|
244
272
|
}
|
|
245
273
|
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
if (!this._running) {
|
|
249
|
-
return;
|
|
250
|
-
}
|
|
274
|
+
_initialize(opts) {
|
|
275
|
+
this._createWebGLContext(opts);
|
|
251
276
|
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
277
|
+
this._createFramebuffer();
|
|
278
|
+
|
|
279
|
+
this._startEventHandling();
|
|
255
280
|
|
|
256
|
-
this.
|
|
281
|
+
this._initializeCallbackData();
|
|
257
282
|
|
|
258
|
-
this.
|
|
283
|
+
this._updateCallbackData();
|
|
284
|
+
|
|
285
|
+
this._resizeCanvasDrawingBuffer();
|
|
286
|
+
|
|
287
|
+
this._resizeViewport();
|
|
288
|
+
|
|
289
|
+
this._gpuTimeQuery = Query.isSupported(this.gl, ['timers']) ? new Query(this.gl) : null;
|
|
259
290
|
}
|
|
260
291
|
|
|
261
292
|
_getPageLoadPromise() {
|
|
@@ -288,24 +319,31 @@ export default class AnimationLoop {
|
|
|
288
319
|
this.display = display;
|
|
289
320
|
}
|
|
290
321
|
|
|
291
|
-
|
|
292
|
-
if (this.
|
|
293
|
-
return
|
|
322
|
+
_requestAnimationFrame() {
|
|
323
|
+
if (!this._running) {
|
|
324
|
+
return;
|
|
294
325
|
}
|
|
295
326
|
|
|
296
|
-
|
|
327
|
+
this._animationFrameId = requestAnimationFrame(this._animationFrame.bind(this));
|
|
297
328
|
}
|
|
298
329
|
|
|
299
|
-
|
|
300
|
-
if (this.
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
330
|
+
_cancelAnimationFrame() {
|
|
331
|
+
if (this._animationFrameId !== null) {
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
cancelAnimationFrame(this._animationFrameId);
|
|
336
|
+
this._animationFrameId = null;
|
|
337
|
+
}
|
|
304
338
|
|
|
305
|
-
|
|
339
|
+
_animationFrame() {
|
|
340
|
+
if (!this._running) {
|
|
341
|
+
return;
|
|
306
342
|
}
|
|
307
343
|
|
|
308
|
-
|
|
344
|
+
this.redraw();
|
|
345
|
+
|
|
346
|
+
this._requestAnimationFrame();
|
|
309
347
|
}
|
|
310
348
|
|
|
311
349
|
_renderFrame(...args) {
|
|
@@ -336,7 +374,7 @@ export default class AnimationLoop {
|
|
|
336
374
|
stop: this.stop,
|
|
337
375
|
canvas: this.gl.canvas,
|
|
338
376
|
framebuffer: this.framebuffer,
|
|
339
|
-
useDevicePixels: this.useDevicePixels,
|
|
377
|
+
useDevicePixels: this.props.useDevicePixels,
|
|
340
378
|
needsRedraw: null,
|
|
341
379
|
startTime: Date.now(),
|
|
342
380
|
engineTime: 0,
|
|
@@ -448,15 +486,15 @@ export default class AnimationLoop {
|
|
|
448
486
|
}
|
|
449
487
|
|
|
450
488
|
_resizeViewport() {
|
|
451
|
-
if (this.autoResizeViewport) {
|
|
489
|
+
if (this.props.autoResizeViewport) {
|
|
452
490
|
this.gl.viewport(0, 0, this.gl.drawingBufferWidth, this.gl.drawingBufferHeight);
|
|
453
491
|
}
|
|
454
492
|
}
|
|
455
493
|
|
|
456
494
|
_resizeCanvasDrawingBuffer() {
|
|
457
|
-
if (this.autoResizeDrawingBuffer) {
|
|
495
|
+
if (this.props.autoResizeDrawingBuffer) {
|
|
458
496
|
resizeGLContext(this.gl, {
|
|
459
|
-
useDevicePixels: this.useDevicePixels
|
|
497
|
+
useDevicePixels: this.props.useDevicePixels
|
|
460
498
|
});
|
|
461
499
|
}
|
|
462
500
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/lib/animation-loop.ts"],"names":["isWebGL","createGLContext","instrumentGLContext","resizeGLContext","resetParameters","requestAnimationFrame","cancelAnimationFrame","Query","lumaStats","Framebuffer","log","isBrowser","isPage","document","statIdCounter","DEFAULT_ANIMATION_LOOP_PROPS","onCreateContext","opts","onAddHTML","onInitialize","onRender","onFinalize","onError","error","console","gl","glOptions","debug","createFramebuffer","useDevicePixels","autoResizeViewport","autoResizeDrawingBuffer","stats","get","AnimationLoop","constructor","props","deprecated","useDevicePixelRatio","cpuTime","gpuTime","frameRate","setProps","start","bind","stop","_onMousemove","_onMouseleave","delete","_setDisplay","setNeedsRedraw","reason","needsRedraw","_start","_running","_getPageLoadPromise","appContext","_initialized","_initialize","animationProps","_addCallbackData","_cancelAnimationFrame","_requestAnimationFrame","redraw","isContextLost","_beginTimers","_setupFrame","_updateCallbackData","_renderFrame","_clearNeedsRedraw","offScreen","commit","_resolveNextFrame","_nextFramePromise","_endTimers","_finalizeCallbackData","attachTimeline","timeline","detachTimeline","waitForRender","Promise","resolve","toDataURL","canvas","args","getHTMLControlValue","id","defaultValue","element","getElementById","Number","value","setViewParameters","removed","_createWebGLContext","_createFramebuffer","_startEventHandling","_initializeCallbackData","_resizeCanvasDrawingBuffer","_resizeViewport","_gpuTimeQuery","isSupported","_pageLoadPromise","reject","readyState","window","addEventListener","display","animationLoop","_animationFrameId","_animationFrame","_resizeFramebuffer","framebuffer","startTime","Date","now","engineTime","tick","tock","time","_timeline","_loop","_animationLoop","_mousePosition","width","height","aspect","_getSizeAndAspect","update","Math","floor","getTime","_offScreen","Object","assign","OffscreenCanvas","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,SACEA,OADF,EAEEC,eAFF,EAGEC,mBAHF,EAIEC,eAJF,EAKEC,eALF,QAMO,kBANP;AAQA,SACEC,qBADF,EAEEC,oBAFF,EAGEC,KAHF,EAIEC,SAJF,EAMEC,WANF,EAOEC,GAPF,QASO,gBATP;AAgBA,SAAQC,SAAR,QAAwB,cAAxB;AAGA,MAAMC,MAAM,GAAGD,SAAS,MAAM,OAAOE,QAAP,KAAoB,WAAlD;AAEA,IAAIC,aAAa,GAAG,CAApB;AAuEA,MAAMC,4BAA0D,GAAG;AACjEC,EAAAA,eAAe,EAAGC,IAAD,IAAUhB,eAAe,CAACgB,IAAD,CADuB;AAEjEC,EAAAA,SAAS,EAAE,IAFsD;AAGjEC,EAAAA,YAAY,EAAE,OAAO,EAAP,CAHmD;AAIjEC,EAAAA,QAAQ,EAAE,MAAM,CAAE,CAJ+C;AAKjEC,EAAAA,UAAU,EAAE,MAAM,CAAE,CAL6C;AAOjEC,EAAAA,OAAO,EAAGC,KAAD,IAAWC,OAAO,CAACD,KAAR,CAAcA,KAAd,CAP6C;AASjEE,EAAAA,EAAE,EAAE,IAT6D;AAUjEC,E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AAP,CAAwB,YAAxB,EAAsC,KAAK3D,aAA3C;AACD;AACF;;AAEDD,EAAAA,YAAY,CAACsH,CAAD,EAAI;AACd,SAAKzG,cAAL,CAAoBgE,cAApB,GAAqC,CAACyC,CAAC,CAACC,OAAH,EAAYD,CAAC,CAACE,OAAd,CAArC;AACD;;AACDvH,EAAAA,aAAa,CAACqH,CAAD,EAAI;AACf,SAAKzG,cAAL,CAAoBgE,cAApB,GAAqC,IAArC;AACD;;AAxkBgC","sourcesContent":["import {\n isWebGL,\n createGLContext,\n instrumentGLContext,\n resizeGLContext,\n resetParameters\n} from '@luma.gl/gltools';\n\nimport {\n requestAnimationFrame,\n cancelAnimationFrame,\n Query,\n lumaStats,\n // TODO - remove dependency on framebuffer (bundle size impact)\n Framebuffer,\n log,\n assert\n} from '@luma.gl/webgl';\n\nimport { Stats } from 'probe.gl'\nimport { Timeline } from '../animation/timeline'\n\nimport type {GLContextOptions} from '@luma.gl/gltools'\n\nimport {isBrowser} from 'probe.gl/env';\n\n\nconst isPage = isBrowser() && typeof document !== 'undefined';\n\nlet statIdCounter = 0;\n\n/** AnimationLoop properties */\nexport type AnimationLoopProps = {\n onCreateContext?: (opts: GLContextOptions) => WebGLRenderingContext; // TODO: signature from createGLContext\n onAddHTML?: (div: HTMLDivElement) => string; // innerHTML\n onInitialize?: ((animationProps: AnimationProps) => {}) | ((animationProps: AnimationProps) => {});\n onRender?: (animationProps: AnimationProps) => void;\n onFinalize?: (animationProps: AnimationProps) => void;\n onError?: (reason: any) => void;\n\n stats?: Stats;\n\n gl?: WebGLRenderingContext\n glOptions?: GLContextOptions // createGLContext options\n debug?: boolean;\n\n // view parameters\n autoResizeViewport?: boolean;\n autoResizeDrawingBuffer?: boolean;\n useDevicePixels?: number | boolean;\n\n /** @deprecated */\n createFramebuffer?: boolean;\n};\n\nexport type AnimationProps = {\n gl: WebGLRenderingContext\n\n stop: () => AnimationLoop\n canvas: HTMLCanvasElement | OffscreenCanvas\n framebuffer: Framebuffer\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 // Experimental\n _timeline: Timeline\n _loop: AnimationLoop\n _animationLoop: AnimationLoop\n _mousePosition?: [number, number] // [offsetX, offsetY]\n _offScreen: boolean\n}\n\n/* instance of parameters after construction\ntype AnimationLoopPropsInternal = {\n onCreateContext: (opts: GLContextOptions) => WebGLRenderingContext // TODO: signature from createGLContext\n onAddHTML?: (div: HTMLDivElement) => string // innerHTML\n onInitialize: (animationProps: AnimationProps) => AnimationProps | Promise<AnimationProps>\n onRender: (animationProps: AnimationProps) => void\n onFinalize: (animationProps: AnimationProps) => void\n onError: (reason: any) => PromiseLike<never>\n gl?: WebGLRenderingContext\n glOptions: GLContextOptions // createGLContext options\n debug: boolean\n createFramebuffer: boolean\n}\n*/\n\nconst DEFAULT_ANIMATION_LOOP_PROPS: Required<AnimationLoopProps> = {\n onCreateContext: (opts) => createGLContext(opts),\n onAddHTML: null,\n onInitialize: () => ({}),\n onRender: () => {},\n onFinalize: () => {},\n // eslint-disable-next-line no-console\n onError: (error) => console.error(error),\n\n gl: null,\n glOptions: {},\n debug: false,\n\n createFramebuffer: false,\n\n // view parameters\n useDevicePixels: true,\n autoResizeViewport: true,\n autoResizeDrawingBuffer: true,\n stats: lumaStats.get(`animation-loop-${statIdCounter++}`)\n};\n\nexport default class AnimationLoop {\n animationProps: AnimationProps;\n props: Required<AnimationLoopProps>;\n gl: WebGLRenderingContext;\n canvas: HTMLCanvasElement | OffscreenCanvas;\n framebuffer: Framebuffer = null;\n timeline: Timeline = null;\n stats: Stats;\n cpuTime: Stats;\n gpuTime: Stats;\n frameRate: Stats;\n offScreen: boolean;\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 /*\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-ignore\n useDevicePixels = props.useDevicePixelRatio;\n }\n\n // state\n this.gl = props.gl;\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\n this._onMousemove = this._onMousemove.bind(this);\n this._onMouseleave = this._onMouseleave.bind(this);\n }\n\n delete(): void {\n this.stop();\n this._setDisplay(null);\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 // Offscreen Canvas Support: Commit the frame\n // https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/commit\n // Chrome's offscreen canvas does not require gl.commit\n // @ts-expect-error gl.commit is not officially part of WebGLRenderingContext\n if (this.offScreen && this.gl.commit) {\n // @ts-expect-error gl.commit is not officially part of WebGLRenderingContext\n this.gl.commit();\n }\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() {\n return this.gl.isContextLost();\n }\n\n onCreateContext(...args) {\n // @ts-expect-error\n return this.props.onCreateContext(...args);\n }\n\n onInitialize(...args) {\n // @ts-expect-error\n return this.props.onInitialize(...args);\n }\n\n onRender(...args) {\n // @ts-expect-error\n return this.props.onRender(...args);\n }\n\n onFinalize(...args) {\n // @ts-expect-error\n return this.props.onFinalize(...args);\n }\n\n // DEPRECATED/REMOVED METHODS\n\n getHTMLControlValue(id, defaultValue = 1) {\n const element = document.getElementById(id);\n // @ts-ignore Not all html elements have value\n return element ? Number(element.value) : defaultValue;\n }\n\n // Update parameters\n setViewParameters() {\n log.removed('AnimationLoop.setViewParameters', 'AnimationLoop.setProps')();\n return this;\n }\n\n // PRIVATE METHODS\n\n _initialize(opts) {\n // Create the WebGL context\n this._createWebGLContext(opts);\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(...args) {\n // Allow e.g. VR display to render multiple frames.\n if (this.display) {\n this.display._renderFrame(...args);\n return;\n }\n\n // call callback\n this.onRender(...args);\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 gl: this.gl,\n\n stop: this.stop,\n canvas: this.gl.canvas,\n framebuffer: this.framebuffer,\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 time for back compatibility\n time: 0,\n\n // Experimental\n _timeline: this.timeline,\n _loop: this,\n _animationLoop: this,\n _mousePosition: null // Event props\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 // experimental\n this.animationProps._offScreen = this.offScreen;\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 _createWebGLContext(opts) {\n this.offScreen =\n opts.canvas &&\n typeof OffscreenCanvas !== 'undefined' &&\n opts.canvas instanceof OffscreenCanvas;\n\n // Create the WebGL context if necessary\n opts = Object.assign({}, opts, this.props.glOptions);\n this.gl = this.props.gl ? instrumentGLContext(this.props.gl, opts) : this.onCreateContext(opts);\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 // Resize the render buffer of the canvas to match canvas client size\n // Optionally multiplying with devicePixel ratio\n _resizeCanvasDrawingBuffer() {\n if (this.props.autoResizeDrawingBuffer) {\n resizeGLContext(this.gl, {useDevicePixels: this.props.useDevicePixels});\n }\n }\n\n // TBD - deprecated?\n _createFramebuffer() {\n // Setup default framebuffer\n if (this.props.createFramebuffer) {\n this.framebuffer = new Framebuffer(this.gl);\n }\n }\n\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 _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"],"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,C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vC,QAAM;AAACqB,IAAAA,YAAY,GAAG/B;AAAhB,MAA8CU,OAAO,IAAI,EAA/D;AACA,SAAQqB,YAAY,IAAIA,YAAY,CAAClB,IAAD,CAA7B,IAAwCA,IAA/C;AACD;;AAID,OAAO,SAASS,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"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { ProgramProps } from '@luma.gl/webgl';
|
|
2
|
+
import { Program, VertexArray, TransformFeedback } from '@luma.gl/webgl';
|
|
3
|
+
import ProgramManager from './program-manager';
|
|
4
|
+
export declare type ModelProps = ProgramProps & {
|
|
5
|
+
id?: string;
|
|
6
|
+
moduleSettings?: object;
|
|
7
|
+
attributes?: object;
|
|
8
|
+
uniforms?: object;
|
|
9
|
+
geometry?: object;
|
|
10
|
+
vertexCount?: number;
|
|
11
|
+
drawMode?: number;
|
|
12
|
+
isInstanced?: boolean;
|
|
13
|
+
instanceCount?: number;
|
|
14
|
+
programManager?: ProgramManager;
|
|
15
|
+
onBeforeRender?: () => void;
|
|
16
|
+
onAfterRender?: () => void;
|
|
17
|
+
_feedbackBuffers?: object;
|
|
18
|
+
isIndexed?: boolean;
|
|
19
|
+
indexType?: any;
|
|
20
|
+
indexOffset?: number;
|
|
21
|
+
vertexArrayInstanced?: boolean;
|
|
22
|
+
};
|
|
23
|
+
export declare type ModelDrawOptions = {
|
|
24
|
+
moduleSettings?: any;
|
|
25
|
+
framebuffer?: any;
|
|
26
|
+
uniforms?: any;
|
|
27
|
+
attributes?: any;
|
|
28
|
+
transformFeedback?: any;
|
|
29
|
+
parameters?: any;
|
|
30
|
+
vertexArray?: any;
|
|
31
|
+
};
|
|
32
|
+
export default class Model {
|
|
33
|
+
readonly id: string;
|
|
34
|
+
readonly gl: WebGLRenderingContext;
|
|
35
|
+
readonly animated: boolean;
|
|
36
|
+
programManager: ProgramManager;
|
|
37
|
+
vertexCount: number;
|
|
38
|
+
lastLogTime: number;
|
|
39
|
+
props: ModelProps;
|
|
40
|
+
userData: Record<string, any>;
|
|
41
|
+
needsRedraw: boolean;
|
|
42
|
+
attributes: Record<string, any>;
|
|
43
|
+
_attributes: Record<string, any>;
|
|
44
|
+
uniforms: Record<string, any>;
|
|
45
|
+
drawMode: any;
|
|
46
|
+
instanceCount: number;
|
|
47
|
+
pickable: boolean;
|
|
48
|
+
programProps: ProgramProps & {
|
|
49
|
+
program?: Program;
|
|
50
|
+
modules: any;
|
|
51
|
+
inject: any;
|
|
52
|
+
defines: any;
|
|
53
|
+
varyings: any;
|
|
54
|
+
bufferMode: any;
|
|
55
|
+
transpileToGLSL100: any;
|
|
56
|
+
};
|
|
57
|
+
vertexArray: VertexArray;
|
|
58
|
+
program: Program;
|
|
59
|
+
transformFeedback: TransformFeedback | undefined;
|
|
60
|
+
_programDirty: boolean;
|
|
61
|
+
_programManagerState: any;
|
|
62
|
+
_managedProgram: any;
|
|
63
|
+
geometryBuffers: {};
|
|
64
|
+
isInstanced: boolean;
|
|
65
|
+
geometry: {};
|
|
66
|
+
constructor(gl: any, props?: ModelProps);
|
|
67
|
+
initialize(props: any): void;
|
|
68
|
+
setProps(props: any): void;
|
|
69
|
+
delete(): void;
|
|
70
|
+
getDrawMode(): any;
|
|
71
|
+
getVertexCount(): number;
|
|
72
|
+
getInstanceCount(): number;
|
|
73
|
+
getAttributes(): Record<string, any>;
|
|
74
|
+
getProgram(): Program;
|
|
75
|
+
setProgram(props: any): void;
|
|
76
|
+
getUniforms(): Record<string, any>;
|
|
77
|
+
setDrawMode(drawMode: any): this;
|
|
78
|
+
setVertexCount(vertexCount: any): this;
|
|
79
|
+
setInstanceCount(instanceCount: any): this;
|
|
80
|
+
setGeometry(geometry: any): this;
|
|
81
|
+
setAttributes(attributes?: {}): this;
|
|
82
|
+
setUniforms(uniforms?: {}): this;
|
|
83
|
+
getModuleUniforms(opts?: any): any;
|
|
84
|
+
updateModuleSettings(opts?: any): this;
|
|
85
|
+
clear(opts: any): this;
|
|
86
|
+
draw(opts?: ModelDrawOptions): boolean;
|
|
87
|
+
transform(opts?: ModelDrawOptions): this;
|
|
88
|
+
render(uniforms?: {}): boolean;
|
|
89
|
+
_setModelProps(props: any): void;
|
|
90
|
+
_checkProgram(): void;
|
|
91
|
+
_deleteGeometryBuffers(): void;
|
|
92
|
+
_setAnimationProps(animationProps: any): void;
|
|
93
|
+
_setFeedbackBuffers(feedbackBuffers?: {}): this;
|
|
94
|
+
_logDrawCallStart(logLevel: number): number;
|
|
95
|
+
_logDrawCallEnd(logLevel: any, vertexArray: any, uniforms: any, framebuffer?: any): void;
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.d.ts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