@luma.gl/engine 8.6.0-alpha.1 → 8.6.0-alpha.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +8 -1
- package/dist/index.d.ts +17 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -7
- package/dist/index.js.map +1 -1
- package/dist/lib/animation-loop.d.ts +57 -28
- package/dist/lib/animation-loop.d.ts.map +1 -1
- package/dist/lib/animation-loop.js +71 -62
- package/dist/lib/animation-loop.js.map +1 -1
- package/dist/lib/model.d.ts +18 -4
- package/dist/lib/model.d.ts.map +1 -1
- package/dist/lib/model.js +15 -9
- package/dist/lib/model.js.map +1 -1
- package/dist/lib/program-manager.d.ts +6 -5
- package/dist/lib/program-manager.d.ts.map +1 -1
- package/dist/lib/program-manager.js +8 -9
- package/dist/lib/program-manager.js.map +1 -1
- 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.map +1 -1
- package/dist/transform/buffer-transform.js +2 -3
- package/dist/transform/buffer-transform.js.map +1 -1
- package/dist/transform/texture-transform.d.ts.map +1 -1
- package/dist/transform/texture-transform.js.map +1 -1
- package/dist/transform/transform-types.d.ts +1 -0
- package/dist/transform/transform-types.d.ts.map +1 -1
- package/dist/transform/transform.d.ts +21 -2
- package/dist/transform/transform.d.ts.map +1 -1
- package/dist/transform/transform.js +26 -11
- package/dist/transform/transform.js.map +1 -1
- package/package.json +7 -7
- package/src/index.ts +18 -13
- package/src/lib/animation-loop.ts +141 -125
- package/src/lib/model.ts +44 -15
- package/src/lib/program-manager.ts +12 -13
- package/src/lib/render-loop.ts +56 -0
- package/src/transform/buffer-transform.ts +2 -3
- package/src/transform/texture-transform.ts +2 -3
- package/src/transform/transform-types.ts +1 -0
- package/src/transform/transform.ts +38 -22
package/LICENSE
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
|
+
Copyright (c) 2020 Urban Computing Foundation
|
|
2
|
+
|
|
3
|
+
This software includes parts initially developed by Uber and open sourced under MIT license.
|
|
1
4
|
Copyright (c) 2015 Uber Technologies, Inc.
|
|
2
5
|
|
|
3
6
|
This software includes parts of PhiloGL (https://github.com/philogb/philogl)
|
|
4
7
|
under MIT license. PhiloGL parts Copyright © 2013 Sencha Labs.
|
|
5
8
|
|
|
6
|
-
This software includes adaptations of postprocessing code from
|
|
9
|
+
This software includes adaptations of some postprocessing code from
|
|
10
|
+
THREE.js (https://github.com/mrdoob/three.js/) under MIT license.
|
|
11
|
+
THREE.js parts Copyright © 2010-2018 three.js authors.
|
|
12
|
+
|
|
13
|
+
Additional attribution given in specific source files.
|
|
7
14
|
|
|
8
15
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
9
16
|
of this software and associated documentation files (the "Software"), to deal
|
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,25 @@
|
|
|
1
|
+
export type { AnimationLoopProps, AnimationProps } from './lib/animation-loop';
|
|
1
2
|
export { default as AnimationLoop } from './lib/animation-loop';
|
|
3
|
+
export { RenderLoop } from './lib/render-loop';
|
|
4
|
+
export type { ModelProps } from './lib/model';
|
|
2
5
|
export { default as Model } from './lib/model';
|
|
3
6
|
export { default as ProgramManager } from './lib/program-manager';
|
|
4
7
|
export { default as Transform } from './transform/transform';
|
|
5
8
|
export { default as Geometry } from './geometry/geometry';
|
|
6
|
-
export {
|
|
7
|
-
export {
|
|
8
|
-
export {
|
|
9
|
-
export {
|
|
10
|
-
export {
|
|
11
|
-
export {
|
|
12
|
-
export {
|
|
9
|
+
export type { ConeGeometryProps } from './geometries/cone-geometry';
|
|
10
|
+
export { ConeGeometry } from './geometries/cone-geometry';
|
|
11
|
+
export type { CubeGeometryProps } from './geometries/cube-geometry';
|
|
12
|
+
export { CubeGeometry } from './geometries/cube-geometry';
|
|
13
|
+
export type { CylinderGeometryProps } from './geometries/cylinder-geometry';
|
|
14
|
+
export { CylinderGeometry } from './geometries/cylinder-geometry';
|
|
15
|
+
export type { IcoSphereGeometryProps } from './geometries/ico-sphere-geometry';
|
|
16
|
+
export { IcoSphereGeometry } from './geometries/ico-sphere-geometry';
|
|
17
|
+
export type { PlaneGeometryProps } from './geometries/plane-geometry';
|
|
18
|
+
export { PlaneGeometry } from './geometries/plane-geometry';
|
|
19
|
+
export type { SphereGeometryProps } from './geometries/sphere-geometry';
|
|
20
|
+
export { SphereGeometry } from './geometries/sphere-geometry';
|
|
21
|
+
export type { TruncatedConeGeometryProps } from './geometries/truncated-cone-geometry';
|
|
22
|
+
export { TruncatedConeGeometry } from './geometries/truncated-cone-geometry';
|
|
13
23
|
export { Timeline } from './animation/timeline';
|
|
14
24
|
export { KeyFrames } from './animation/key-frames';
|
|
15
25
|
export { default as ClipSpace } from './utils/clip-space';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,OAAO,IAAI,aAAa,EAAC,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAC,OAAO,IAAI,KAAK,EAAC,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAC,OAAO,IAAI,cAAc,EAAC,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAC,OAAO,IAAI,SAAS,EAAC,MAAM,uBAAuB,CAAC;AAG3D,OAAO,EAAC,OAAO,IAAI,QAAQ,EAAC,MAAM,qBAAqB,CAAC;AAGxD,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EAAC,kBAAkB,EAAE,cAAc,EAAC,MAAM,sBAAsB,CAAC;AAC7E,OAAO,EAAC,OAAO,IAAI,aAAa,EAAC,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAC,UAAU,EAAC,MAAM,mB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.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
export { default as AnimationLoop } from './lib/animation-loop';
|
|
2
|
+
export { RenderLoop } from './lib/render-loop';
|
|
2
3
|
export { default as Model } from './lib/model';
|
|
3
4
|
export { default as ProgramManager } from './lib/program-manager';
|
|
4
5
|
export { default as Transform } from './transform/transform';
|
|
5
6
|
export { default as Geometry } from './geometry/geometry';
|
|
6
|
-
export { ConeGeometry
|
|
7
|
-
export { CubeGeometry
|
|
8
|
-
export { CylinderGeometry
|
|
9
|
-
export { IcoSphereGeometry
|
|
10
|
-
export { PlaneGeometry
|
|
11
|
-
export { SphereGeometry
|
|
12
|
-
export { TruncatedConeGeometry
|
|
7
|
+
export { ConeGeometry } from './geometries/cone-geometry';
|
|
8
|
+
export { CubeGeometry } from './geometries/cube-geometry';
|
|
9
|
+
export { CylinderGeometry } from './geometries/cylinder-geometry';
|
|
10
|
+
export { IcoSphereGeometry } from './geometries/ico-sphere-geometry';
|
|
11
|
+
export { PlaneGeometry } from './geometries/plane-geometry';
|
|
12
|
+
export { SphereGeometry } from './geometries/sphere-geometry';
|
|
13
|
+
export { TruncatedConeGeometry } from './geometries/truncated-cone-geometry';
|
|
13
14
|
export { Timeline } from './animation/timeline';
|
|
14
15
|
export { KeyFrames } from './animation/key-frames';
|
|
15
16
|
export { default as ClipSpace } from './utils/clip-space';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"names":["default","AnimationLoop","Model","ProgramManager","Transform","Geometry","ConeGeometry","
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":["default","AnimationLoop","RenderLoop","Model","ProgramManager","Transform","Geometry","ConeGeometry","CubeGeometry","CylinderGeometry","IcoSphereGeometry","PlaneGeometry","SphereGeometry","TruncatedConeGeometry","Timeline","KeyFrames","ClipSpace"],"mappings":"AAEA,SAAQA,OAAO,IAAIC,aAAnB,QAAuC,sBAAvC;AACA,SAAQC,UAAR,QAAyB,mBAAzB;AAGA,SAAQF,OAAO,IAAIG,KAAnB,QAA+B,aAA/B;AACA,SAAQH,OAAO,IAAII,cAAnB,QAAwC,uBAAxC;AACA,SAAQJ,OAAO,IAAIK,SAAnB,QAAmC,uBAAnC;AAGA,SAAQL,OAAO,IAAIM,QAAnB,QAAkC,qBAAlC;AAIA,SAAQC,YAAR,QAA2B,4BAA3B;AAEA,SAAQC,YAAR,QAA2B,4BAA3B;AAEA,SAAQC,gBAAR,QAA+B,gCAA/B;AAEA,SAAQC,iBAAR,QAAgC,kCAAhC;AAEA,SAAQC,aAAR,QAA4B,6BAA5B;AAEA,SAAQC,cAAR,QAA6B,8BAA7B;AAEA,SAAQC,qBAAR,QAAoC,sCAApC;AAGA,SAAQC,QAAR,QAAuB,sBAAvB;AACA,SAAQC,SAAR,QAAwB,wBAAxB;AAGA,SAAQf,OAAO,IAAIgB,SAAnB,QAAmC,oBAAnC","sourcesContent":["// CORE\nexport type {AnimationLoopProps, AnimationProps} from './lib/animation-loop';\nexport {default as AnimationLoop} from './lib/animation-loop';\nexport {RenderLoop} from './lib/render-loop';\n\nexport type {ModelProps} from './lib/model';\nexport {default as Model} from './lib/model';\nexport {default as ProgramManager} from './lib/program-manager';\nexport {default as Transform} from './transform/transform';\n\n// Geometries\nexport {default as Geometry} from './geometry/geometry';\n\n// Primitives\nexport type {ConeGeometryProps} from './geometries/cone-geometry';\nexport {ConeGeometry} from './geometries/cone-geometry';\nexport type {CubeGeometryProps} from './geometries/cube-geometry';\nexport {CubeGeometry} from './geometries/cube-geometry';\nexport type {CylinderGeometryProps} from './geometries/cylinder-geometry';\nexport {CylinderGeometry} from './geometries/cylinder-geometry';\nexport type {IcoSphereGeometryProps} from './geometries/ico-sphere-geometry';\nexport {IcoSphereGeometry} from './geometries/ico-sphere-geometry';\nexport type {PlaneGeometryProps} from './geometries/plane-geometry';\nexport {PlaneGeometry} from './geometries/plane-geometry';\nexport type {SphereGeometryProps} from './geometries/sphere-geometry';\nexport {SphereGeometry} from './geometries/sphere-geometry';\nexport type {TruncatedConeGeometryProps} from './geometries/truncated-cone-geometry';\nexport {TruncatedConeGeometry} from './geometries/truncated-cone-geometry';\n\n// Animation\nexport {Timeline} from './animation/timeline';\nexport {KeyFrames} from './animation/key-frames';\n\n// Utils\nexport {default as ClipSpace} from './utils/clip-space';\n"],"file":"index.js"}
|
|
@@ -1,31 +1,36 @@
|
|
|
1
1
|
/// <reference types="offscreencanvas" />
|
|
2
|
+
import { Device } from '@luma.gl/api';
|
|
3
|
+
import type { WebGLDeviceProps } from '@luma.gl/webgl';
|
|
2
4
|
import { Query, Framebuffer } from '@luma.gl/webgl';
|
|
3
|
-
import { Stats } from 'probe.gl';
|
|
5
|
+
import { Stats, Stat } from '@probe.gl/stats';
|
|
4
6
|
import { Timeline } from '../animation/timeline';
|
|
5
|
-
|
|
7
|
+
declare type DeviceProps = WebGLDeviceProps;
|
|
8
|
+
declare type ContextProps = WebGLDeviceProps;
|
|
6
9
|
/** AnimationLoop properties */
|
|
7
10
|
export declare type AnimationLoopProps = {
|
|
8
|
-
|
|
11
|
+
onCreateDevice?: (props: DeviceProps) => Device;
|
|
12
|
+
onCreateContext?: (props: ContextProps) => WebGLRenderingContext;
|
|
9
13
|
onAddHTML?: (div: HTMLDivElement) => string;
|
|
10
|
-
onInitialize?: (
|
|
14
|
+
onInitialize?: (animationProps: AnimationProps) => {} | void;
|
|
11
15
|
onRender?: (animationProps: AnimationProps) => void;
|
|
12
16
|
onFinalize?: (animationProps: AnimationProps) => void;
|
|
13
17
|
onError?: (reason: any) => void;
|
|
14
18
|
stats?: Stats;
|
|
15
|
-
|
|
16
|
-
glOptions?:
|
|
19
|
+
device?: Device;
|
|
20
|
+
glOptions?: ContextProps;
|
|
17
21
|
debug?: boolean;
|
|
18
22
|
autoResizeViewport?: boolean;
|
|
19
23
|
autoResizeDrawingBuffer?: boolean;
|
|
20
24
|
useDevicePixels?: number | boolean;
|
|
21
|
-
/** @deprecated */
|
|
25
|
+
/** @deprecated Use .device */
|
|
26
|
+
gl?: WebGLRenderingContext;
|
|
27
|
+
/** @deprecated Will be removed */
|
|
22
28
|
createFramebuffer?: boolean;
|
|
23
29
|
};
|
|
24
30
|
export declare type AnimationProps = {
|
|
25
|
-
|
|
31
|
+
device: Device;
|
|
26
32
|
stop: () => AnimationLoop;
|
|
27
33
|
canvas: HTMLCanvasElement | OffscreenCanvas;
|
|
28
|
-
framebuffer: Framebuffer;
|
|
29
34
|
useDevicePixels: number | boolean;
|
|
30
35
|
needsRedraw?: string;
|
|
31
36
|
startTime: number;
|
|
@@ -36,24 +41,32 @@ export declare type AnimationProps = {
|
|
|
36
41
|
width: number;
|
|
37
42
|
height: number;
|
|
38
43
|
aspect: number;
|
|
44
|
+
timeline: Timeline;
|
|
45
|
+
animationLoop: AnimationLoop;
|
|
46
|
+
_mousePosition?: [number, number];
|
|
47
|
+
/** @deprecated Will be removed, create your own Framebuffer */
|
|
48
|
+
framebuffer: Framebuffer;
|
|
49
|
+
/** @deprecated Use .device */
|
|
50
|
+
gl: WebGLRenderingContext;
|
|
51
|
+
/** @deprecated Use .timeline */
|
|
39
52
|
_timeline: Timeline;
|
|
53
|
+
/** @deprecated Use .animationLoop */
|
|
40
54
|
_loop: AnimationLoop;
|
|
55
|
+
/** @deprecated Use .animationLoop */
|
|
41
56
|
_animationLoop: AnimationLoop;
|
|
42
|
-
_mousePosition?: [number, number];
|
|
43
|
-
_offScreen: boolean;
|
|
44
57
|
};
|
|
58
|
+
/** Convenient animation loop */
|
|
45
59
|
export default class AnimationLoop {
|
|
46
|
-
|
|
47
|
-
props: Required<AnimationLoopProps>;
|
|
48
|
-
gl: WebGLRenderingContext;
|
|
60
|
+
device: Device;
|
|
49
61
|
canvas: HTMLCanvasElement | OffscreenCanvas;
|
|
62
|
+
props: Required<AnimationLoopProps>;
|
|
63
|
+
animationProps: AnimationProps;
|
|
50
64
|
framebuffer: Framebuffer;
|
|
51
65
|
timeline: Timeline;
|
|
52
66
|
stats: Stats;
|
|
53
|
-
cpuTime:
|
|
54
|
-
gpuTime:
|
|
55
|
-
frameRate:
|
|
56
|
-
offScreen: boolean;
|
|
67
|
+
cpuTime: Stat;
|
|
68
|
+
gpuTime: Stat;
|
|
69
|
+
frameRate: Stat;
|
|
57
70
|
display: any;
|
|
58
71
|
needsRedraw: string | null;
|
|
59
72
|
_initialized: boolean;
|
|
@@ -64,7 +77,11 @@ export default class AnimationLoop {
|
|
|
64
77
|
_resolveNextFrame: ((AnimationLoop: any) => void) | null;
|
|
65
78
|
_cpuStartTime: number;
|
|
66
79
|
_gpuTimeQuery: Query | null;
|
|
80
|
+
/** @deprecated */
|
|
81
|
+
gl: WebGLRenderingContext;
|
|
67
82
|
constructor(props?: AnimationLoopProps);
|
|
83
|
+
destroy(): void;
|
|
84
|
+
/** @deprecated Use .destroy() */
|
|
68
85
|
delete(): void;
|
|
69
86
|
setNeedsRedraw(reason: string): this;
|
|
70
87
|
setProps(props: AnimationLoopProps): this;
|
|
@@ -81,40 +98,52 @@ export default class AnimationLoop {
|
|
|
81
98
|
waitForRender(): Promise<AnimationLoop>;
|
|
82
99
|
toDataURL(): Promise<string>;
|
|
83
100
|
isContextLost(): boolean;
|
|
84
|
-
|
|
85
|
-
onInitialize(
|
|
86
|
-
onRender(
|
|
87
|
-
onFinalize(
|
|
101
|
+
onCreateDevice(deviceProps: DeviceProps): Device;
|
|
102
|
+
onInitialize(animationProps: AnimationProps): {} | void;
|
|
103
|
+
onRender(animationProps: AnimationProps): void;
|
|
104
|
+
onFinalize(animationProps: AnimationProps): void;
|
|
105
|
+
/** @deprecated Use .onCreateDevice() */
|
|
106
|
+
onCreateContext(props: ContextProps): WebGLRenderingContext;
|
|
107
|
+
/** @deprecated */
|
|
88
108
|
getHTMLControlValue(id: any, defaultValue?: number): number;
|
|
89
|
-
|
|
90
|
-
_initialize(opts: any): void;
|
|
109
|
+
_initialize(props: AnimationLoopProps): void;
|
|
91
110
|
_getPageLoadPromise(): Promise<{}>;
|
|
92
111
|
_setDisplay(display: any): void;
|
|
93
112
|
_requestAnimationFrame(): void;
|
|
94
113
|
_cancelAnimationFrame(): void;
|
|
95
114
|
_animationFrame(): void;
|
|
96
|
-
_renderFrame(
|
|
115
|
+
_renderFrame(props: AnimationProps): void;
|
|
97
116
|
_clearNeedsRedraw(): void;
|
|
98
117
|
_setupFrame(): void;
|
|
99
118
|
_initializeCallbackData(): void;
|
|
100
119
|
_updateCallbackData(): void;
|
|
101
120
|
_finalizeCallbackData(): void;
|
|
121
|
+
/** Add application's data to the app context object */
|
|
102
122
|
_addCallbackData(appContext: any): void;
|
|
103
|
-
|
|
123
|
+
/** Either uses supplied or existing context, or calls provided callback to create one */
|
|
124
|
+
_createDevice(props: DeviceProps): void;
|
|
104
125
|
_createInfoDiv(): void;
|
|
105
126
|
_getSizeAndAspect(): {
|
|
106
127
|
width: number;
|
|
107
128
|
height: number;
|
|
108
129
|
aspect: number;
|
|
109
130
|
};
|
|
131
|
+
/** Default viewport setup */
|
|
110
132
|
_resizeViewport(): void;
|
|
133
|
+
/**
|
|
134
|
+
* Resize the render buffer of the canvas to match canvas client size
|
|
135
|
+
* Optionally multiplying with devicePixel ratio
|
|
136
|
+
*/
|
|
111
137
|
_resizeCanvasDrawingBuffer(): void;
|
|
112
|
-
_createFramebuffer(): void;
|
|
113
|
-
_resizeFramebuffer(): void;
|
|
114
138
|
_beginTimers(): void;
|
|
115
139
|
_endTimers(): void;
|
|
116
140
|
_startEventHandling(): void;
|
|
117
141
|
_onMousemove(e: any): void;
|
|
118
142
|
_onMouseleave(e: any): void;
|
|
143
|
+
/** @deprecated */
|
|
144
|
+
_createFramebuffer(): void;
|
|
145
|
+
/** @deprecated */
|
|
146
|
+
_resizeFramebuffer(): void;
|
|
119
147
|
}
|
|
148
|
+
export {};
|
|
120
149
|
//# sourceMappingURL=animation-loop.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"animation-loop.d.ts","sourceRoot":"","sources":["../../src/lib/animation-loop.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"animation-loop.d.ts","sourceRoot":"","sources":["../../src/lib/animation-loop.ts"],"names":[],"mappings":";AAAA,OAAO,EAAO,MAAM,EAAC,MAAM,cAAc,CAAC;AAO1C,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,gBAAgB,CAAA;AAWpD,OAAO,EAGL,KAAK,EAEL,WAAW,EACZ,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAA;AAG7C,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAGhD,aAAK,WAAW,GAAG,gBAAgB,CAAC;AACpC,aAAK,YAAY,GAAG,gBAAgB,CAAC;AAMrC,+BAA+B;AAC/B,oBAAY,kBAAkB,GAAG;IAC/B,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,MAAM,CAAC;IAChD,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,qBAAqB,CAAC;IACjE,SAAS,CAAC,EAAE,CAAC,GAAG,EAAE,cAAc,KAAK,MAAM,CAAC;IAC5C,YAAY,CAAC,EAAE,CAAC,cAAc,EAAE,cAAc,KAAK,EAAE,GAAG,IAAI,CAAC;IAC7D,QAAQ,CAAC,EAAE,CAAC,cAAc,EAAE,cAAc,KAAK,IAAI,CAAC;IACpD,UAAU,CAAC,EAAE,CAAC,cAAc,EAAE,cAAc,KAAK,IAAI,CAAC;IACtD,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI,CAAC;IAEhC,KAAK,CAAC,EAAE,KAAK,CAAC;IAEd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,YAAY,CAAC;IACzB,KAAK,CAAC,EAAE,OAAO,CAAC;IAGhB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,uBAAuB,CAAC,EAAE,OAA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,IAAI;IAIvD,QAAQ,CAAC,cAAc,EAAE,cAAc;IAIvC,UAAU,CAAC,cAAc,EAAE,cAAc;IAMzC,wCAAwC;IACxC,eAAe,CAAC,KAAK,EAAE,YAAY;IAInC,kBAAkB;IAClB,mBAAmB,CAAC,EAAE,KAAA,EAAE,YAAY,SAAI;IAQxC,WAAW,CAAC,KAAK,EAAE,kBAAkB;IAiBrC,mBAAmB;IAiBnB,WAAW,CAAC,OAAO,KAAA;IAcnB,sBAAsB;IActB,qBAAqB;IAerB,eAAe;IAUf,YAAY,CAAC,KAAK,EAAE,cAAc;IAYlC,iBAAiB;IAIjB,WAAW;IAOX,uBAAuB;IAqCvB,mBAAmB;IA+BnB,qBAAqB;IAMrB,uDAAuD;IACvD,gBAAgB,CAAC,UAAU,KAAA;IAM3B,yFAAyF;IACzF,aAAa,CAAC,KAAK,EAAE,WAAW;IAqBhC,cAAc;IAoBd,iBAAiB;;;;;IAkBjB,6BAA6B;IAC7B,eAAe;IAMf;;;OAGG;IACH,0BAA0B;IAM1B,YAAY;IAuBZ,UAAU;IAWV,mBAAmB;IAQnB,YAAY,CAAC,CAAC,KAAA;IAGd,aAAa,CAAC,CAAC,KAAA;IAMf,kBAAkB;IAClB,kBAAkB;IAOlB,kBAAkB;IAClB,kBAAkB;CAQnB"}
|
|
@@ -1,34 +1,38 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
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';
|
|
5
7
|
const isPage = isBrowser() && typeof document !== 'undefined';
|
|
6
8
|
let statIdCounter = 0;
|
|
7
9
|
const DEFAULT_ANIMATION_LOOP_PROPS = {
|
|
8
|
-
|
|
10
|
+
onCreateDevice: props => luma.createDevice(props),
|
|
11
|
+
onCreateContext: null,
|
|
9
12
|
onAddHTML: null,
|
|
10
13
|
onInitialize: () => ({}),
|
|
11
14
|
onRender: () => {},
|
|
12
15
|
onFinalize: () => {},
|
|
13
16
|
onError: error => console.error(error),
|
|
14
|
-
|
|
15
|
-
glOptions: {},
|
|
17
|
+
device: null,
|
|
16
18
|
debug: false,
|
|
17
|
-
createFramebuffer: false,
|
|
18
19
|
useDevicePixels: true,
|
|
19
20
|
autoResizeViewport: true,
|
|
20
21
|
autoResizeDrawingBuffer: true,
|
|
21
|
-
stats: lumaStats.get("animation-loop-".concat(statIdCounter++))
|
|
22
|
+
stats: lumaStats.get("animation-loop-".concat(statIdCounter++)),
|
|
23
|
+
gl: null,
|
|
24
|
+
glOptions: {},
|
|
25
|
+
createFramebuffer: false
|
|
22
26
|
};
|
|
23
27
|
export default class AnimationLoop {
|
|
24
28
|
constructor(props = {}) {
|
|
25
|
-
_defineProperty(this, "
|
|
29
|
+
_defineProperty(this, "device", void 0);
|
|
26
30
|
|
|
27
|
-
_defineProperty(this, "
|
|
31
|
+
_defineProperty(this, "canvas", void 0);
|
|
28
32
|
|
|
29
|
-
_defineProperty(this, "
|
|
33
|
+
_defineProperty(this, "props", void 0);
|
|
30
34
|
|
|
31
|
-
_defineProperty(this, "
|
|
35
|
+
_defineProperty(this, "animationProps", void 0);
|
|
32
36
|
|
|
33
37
|
_defineProperty(this, "framebuffer", null);
|
|
34
38
|
|
|
@@ -42,8 +46,6 @@ export default class AnimationLoop {
|
|
|
42
46
|
|
|
43
47
|
_defineProperty(this, "frameRate", void 0);
|
|
44
48
|
|
|
45
|
-
_defineProperty(this, "offScreen", void 0);
|
|
46
|
-
|
|
47
49
|
_defineProperty(this, "display", void 0);
|
|
48
50
|
|
|
49
51
|
_defineProperty(this, "needsRedraw", 'initialized');
|
|
@@ -64,6 +66,8 @@ export default class AnimationLoop {
|
|
|
64
66
|
|
|
65
67
|
_defineProperty(this, "_gpuTimeQuery", null);
|
|
66
68
|
|
|
69
|
+
_defineProperty(this, "gl", void 0);
|
|
70
|
+
|
|
67
71
|
this.props = { ...DEFAULT_ANIMATION_LOOP_PROPS,
|
|
68
72
|
...props
|
|
69
73
|
};
|
|
@@ -77,7 +81,8 @@ export default class AnimationLoop {
|
|
|
77
81
|
useDevicePixels = props.useDevicePixelRatio;
|
|
78
82
|
}
|
|
79
83
|
|
|
80
|
-
this.
|
|
84
|
+
this.device = props.device;
|
|
85
|
+
this.gl = this.device && this.device.gl || props.gl;
|
|
81
86
|
this.stats = props.stats;
|
|
82
87
|
this.cpuTime = this.stats.get('CPU Time');
|
|
83
88
|
this.gpuTime = this.stats.get('GPU Time');
|
|
@@ -93,12 +98,16 @@ export default class AnimationLoop {
|
|
|
93
98
|
this._onMouseleave = this._onMouseleave.bind(this);
|
|
94
99
|
}
|
|
95
100
|
|
|
96
|
-
|
|
101
|
+
destroy() {
|
|
97
102
|
this.stop();
|
|
98
103
|
|
|
99
104
|
this._setDisplay(null);
|
|
100
105
|
}
|
|
101
106
|
|
|
107
|
+
delete() {
|
|
108
|
+
this.destroy();
|
|
109
|
+
}
|
|
110
|
+
|
|
102
111
|
setNeedsRedraw(reason) {
|
|
103
112
|
this.needsRedraw = this.needsRedraw || reason;
|
|
104
113
|
return this;
|
|
@@ -184,10 +193,6 @@ export default class AnimationLoop {
|
|
|
184
193
|
|
|
185
194
|
this._clearNeedsRedraw();
|
|
186
195
|
|
|
187
|
-
if (this.offScreen && this.gl.commit) {
|
|
188
|
-
this.gl.commit();
|
|
189
|
-
}
|
|
190
|
-
|
|
191
196
|
if (this._resolveNextFrame) {
|
|
192
197
|
this._resolveNextFrame(this);
|
|
193
198
|
|
|
@@ -245,20 +250,24 @@ export default class AnimationLoop {
|
|
|
245
250
|
return this.gl.isContextLost();
|
|
246
251
|
}
|
|
247
252
|
|
|
248
|
-
|
|
249
|
-
return this.props.
|
|
253
|
+
onCreateDevice(deviceProps) {
|
|
254
|
+
return this.props.onCreateDevice(deviceProps);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
onInitialize(animationProps) {
|
|
258
|
+
return this.props.onInitialize(animationProps);
|
|
250
259
|
}
|
|
251
260
|
|
|
252
|
-
|
|
253
|
-
return this.props.
|
|
261
|
+
onRender(animationProps) {
|
|
262
|
+
return this.props.onRender(animationProps);
|
|
254
263
|
}
|
|
255
264
|
|
|
256
|
-
|
|
257
|
-
return this.props.
|
|
265
|
+
onFinalize(animationProps) {
|
|
266
|
+
return this.props.onFinalize(animationProps);
|
|
258
267
|
}
|
|
259
268
|
|
|
260
|
-
|
|
261
|
-
return this.props.
|
|
269
|
+
onCreateContext(props) {
|
|
270
|
+
return this.props.onCreateContext(props);
|
|
262
271
|
}
|
|
263
272
|
|
|
264
273
|
getHTMLControlValue(id, defaultValue = 1) {
|
|
@@ -266,13 +275,8 @@ export default class AnimationLoop {
|
|
|
266
275
|
return element ? Number(element.value) : defaultValue;
|
|
267
276
|
}
|
|
268
277
|
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
return this;
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
_initialize(opts) {
|
|
275
|
-
this._createWebGLContext(opts);
|
|
278
|
+
_initialize(props) {
|
|
279
|
+
this._createDevice(props);
|
|
276
280
|
|
|
277
281
|
this._createFramebuffer();
|
|
278
282
|
|
|
@@ -346,14 +350,14 @@ export default class AnimationLoop {
|
|
|
346
350
|
this._requestAnimationFrame();
|
|
347
351
|
}
|
|
348
352
|
|
|
349
|
-
_renderFrame(
|
|
353
|
+
_renderFrame(props) {
|
|
350
354
|
if (this.display) {
|
|
351
|
-
this.display._renderFrame(
|
|
355
|
+
this.display._renderFrame(props);
|
|
352
356
|
|
|
353
357
|
return;
|
|
354
358
|
}
|
|
355
359
|
|
|
356
|
-
this.onRender(
|
|
360
|
+
this.onRender(props);
|
|
357
361
|
}
|
|
358
362
|
|
|
359
363
|
_clearNeedsRedraw() {
|
|
@@ -370,21 +374,24 @@ export default class AnimationLoop {
|
|
|
370
374
|
|
|
371
375
|
_initializeCallbackData() {
|
|
372
376
|
this.animationProps = {
|
|
377
|
+
device: this.device,
|
|
373
378
|
gl: this.gl,
|
|
374
379
|
stop: this.stop,
|
|
375
380
|
canvas: this.gl.canvas,
|
|
376
|
-
framebuffer: this.framebuffer,
|
|
377
381
|
useDevicePixels: this.props.useDevicePixels,
|
|
378
382
|
needsRedraw: null,
|
|
379
383
|
startTime: Date.now(),
|
|
380
384
|
engineTime: 0,
|
|
381
385
|
tick: 0,
|
|
382
386
|
tock: 0,
|
|
387
|
+
timeline: this.timeline,
|
|
388
|
+
animationLoop: this,
|
|
383
389
|
time: 0,
|
|
390
|
+
_mousePosition: null,
|
|
391
|
+
framebuffer: this.framebuffer,
|
|
384
392
|
_timeline: this.timeline,
|
|
385
393
|
_loop: this,
|
|
386
|
-
_animationLoop: this
|
|
387
|
-
_mousePosition: null
|
|
394
|
+
_animationLoop: this
|
|
388
395
|
};
|
|
389
396
|
}
|
|
390
397
|
|
|
@@ -416,7 +423,6 @@ export default class AnimationLoop {
|
|
|
416
423
|
this.animationProps.tick = Math.floor(this.animationProps.time / 1000 * 60);
|
|
417
424
|
this.animationProps.tock++;
|
|
418
425
|
this.animationProps.time = this.timeline ? this.timeline.getTime() : this.animationProps.engineTime;
|
|
419
|
-
this.animationProps._offScreen = this.offScreen;
|
|
420
426
|
}
|
|
421
427
|
|
|
422
428
|
_finalizeCallbackData() {
|
|
@@ -429,10 +435,13 @@ export default class AnimationLoop {
|
|
|
429
435
|
}
|
|
430
436
|
}
|
|
431
437
|
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
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;
|
|
436
445
|
|
|
437
446
|
if (!isWebGL(this.gl)) {
|
|
438
447
|
throw new Error('AnimationLoop.onCreateContext - illegal context returned');
|
|
@@ -493,27 +502,12 @@ export default class AnimationLoop {
|
|
|
493
502
|
|
|
494
503
|
_resizeCanvasDrawingBuffer() {
|
|
495
504
|
if (this.props.autoResizeDrawingBuffer) {
|
|
496
|
-
|
|
505
|
+
this.device.resize({
|
|
497
506
|
useDevicePixels: this.props.useDevicePixels
|
|
498
507
|
});
|
|
499
508
|
}
|
|
500
509
|
}
|
|
501
510
|
|
|
502
|
-
_createFramebuffer() {
|
|
503
|
-
if (this.props.createFramebuffer) {
|
|
504
|
-
this.framebuffer = new Framebuffer(this.gl);
|
|
505
|
-
}
|
|
506
|
-
}
|
|
507
|
-
|
|
508
|
-
_resizeFramebuffer() {
|
|
509
|
-
if (this.framebuffer) {
|
|
510
|
-
this.framebuffer.resize({
|
|
511
|
-
width: this.gl.drawingBufferWidth,
|
|
512
|
-
height: this.gl.drawingBufferHeight
|
|
513
|
-
});
|
|
514
|
-
}
|
|
515
|
-
}
|
|
516
|
-
|
|
517
511
|
_beginTimers() {
|
|
518
512
|
this.frameRate.timeEnd();
|
|
519
513
|
this.frameRate.timeStart();
|
|
@@ -556,5 +550,20 @@ export default class AnimationLoop {
|
|
|
556
550
|
this.animationProps._mousePosition = null;
|
|
557
551
|
}
|
|
558
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
|
+
|
|
559
568
|
}
|
|
560
569
|
//# sourceMappingURL=animation-loop.js.map
|