@luma.gl/engine 9.0.0-alpha.10 → 9.0.0-alpha.12

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.
Files changed (71) hide show
  1. package/dist/{lib → animation-loop}/animation-loop.d.ts +17 -15
  2. package/dist/animation-loop/animation-loop.d.ts.map +1 -0
  3. package/dist/{lib → animation-loop}/animation-loop.js +23 -23
  4. package/dist/animation-loop/animation-loop.js.map +1 -0
  5. package/dist/{lib → animation-loop}/animation-props.d.ts +0 -0
  6. package/dist/animation-loop/animation-props.d.ts.map +1 -0
  7. package/dist/{lib → animation-loop}/animation-props.js +0 -0
  8. package/dist/{lib → animation-loop}/animation-props.js.map +0 -0
  9. package/dist/animation-loop/make-animation-loop.d.ts +6 -0
  10. package/dist/animation-loop/make-animation-loop.d.ts.map +1 -0
  11. package/dist/animation-loop/make-animation-loop.js +34 -0
  12. package/dist/animation-loop/make-animation-loop.js.map +1 -0
  13. package/dist/animation-loop/render-loop.d.ts +23 -0
  14. package/dist/animation-loop/render-loop.d.ts.map +1 -0
  15. package/dist/animation-loop/render-loop.js +9 -0
  16. package/dist/animation-loop/render-loop.js.map +1 -0
  17. package/dist/geometries/cube-geometry.d.ts.map +1 -1
  18. package/dist/geometries/cube-geometry.js.map +1 -1
  19. package/dist/geometries/cylinder-geometry.d.ts.map +1 -1
  20. package/dist/geometries/cylinder-geometry.js.map +1 -1
  21. package/dist/geometries/ico-sphere-geometry.d.ts.map +1 -1
  22. package/dist/geometries/ico-sphere-geometry.js.map +1 -1
  23. package/dist/geometries/plane-geometry.d.ts.map +1 -1
  24. package/dist/geometries/plane-geometry.js.map +1 -1
  25. package/dist/geometries/sphere-geometry.d.ts.map +1 -1
  26. package/dist/geometries/sphere-geometry.js.map +1 -1
  27. package/dist/geometries/truncated-cone-geometry.d.ts.map +1 -1
  28. package/dist/geometries/truncated-cone-geometry.js.map +1 -1
  29. package/dist/geometry/geometry-utils.d.ts.map +1 -1
  30. package/dist/geometry/geometry-utils.js.map +1 -1
  31. package/dist/geometry/geometry.d.ts +13 -0
  32. package/dist/geometry/geometry.d.ts.map +1 -1
  33. package/dist/geometry/geometry.js +7 -0
  34. package/dist/geometry/geometry.js.map +1 -1
  35. package/dist/index.d.ts +9 -7
  36. package/dist/index.d.ts.map +1 -1
  37. package/dist/index.js +5 -4
  38. package/dist/index.js.map +1 -1
  39. package/dist/lib/model-utils.js +2 -2
  40. package/dist/lib/model-utils.js.map +1 -1
  41. package/dist/lib/model.d.ts +2 -2
  42. package/dist/lib/model.d.ts.map +1 -1
  43. package/dist/lib/model.js +1 -1
  44. package/dist/lib/model.js.map +1 -1
  45. package/dist/lib/pipeline-factory.d.ts.map +1 -1
  46. package/dist/lib/pipeline-factory.js.map +1 -1
  47. package/package.json +5 -5
  48. package/src/{lib → animation-loop}/animation-loop.ts +42 -39
  49. package/src/{lib → animation-loop}/animation-props.ts +0 -0
  50. package/src/animation-loop/make-animation-loop.ts +43 -0
  51. package/src/animation-loop/render-loop.ts +23 -0
  52. package/src/geometries/cube-geometry.ts +1 -1
  53. package/src/geometries/cylinder-geometry.ts +1 -1
  54. package/src/geometries/ico-sphere-geometry.ts +3 -3
  55. package/src/geometries/plane-geometry.ts +2 -2
  56. package/src/geometries/sphere-geometry.ts +1 -1
  57. package/src/geometries/truncated-cone-geometry.ts +1 -1
  58. package/src/geometry/geometry-utils.ts +2 -2
  59. package/src/geometry/geometry.ts +9 -7
  60. package/src/index.ts +14 -8
  61. package/src/lib/model-utils.ts +3 -2
  62. package/src/lib/model.ts +2 -2
  63. package/src/lib/pipeline-factory.ts +3 -3
  64. package/dist/lib/animation-loop.d.ts.map +0 -1
  65. package/dist/lib/animation-loop.js.map +0 -1
  66. package/dist/lib/animation-props.d.ts.map +0 -1
  67. package/dist/lib/render-loop.d.ts +0 -14
  68. package/dist/lib/render-loop.d.ts.map +0 -1
  69. package/dist/lib/render-loop.js +0 -49
  70. package/dist/lib/render-loop.js.map +0 -1
  71. package/src/lib/render-loop.ts +0 -58
@@ -1,53 +1,54 @@
1
- import {luma, Device, DeviceProps} from '@luma.gl/api';
1
+ // luma.gl, MIT license
2
+
3
+ import {luma, Device} from '@luma.gl/api';
2
4
  import {requestAnimationFrame, cancelAnimationFrame} from '@luma.gl/api';
3
5
  import {Timeline} from '../animation/timeline';
4
- import {AnimationProps} from '../lib/animation-props';
6
+ import {AnimationProps} from './animation-props';
5
7
  import {Stats, Stat} from '@probe.gl/stats';
6
- import {isBrowser} from '@probe.gl/env';
7
-
8
- const isPage = isBrowser() && typeof document !== 'undefined';
9
8
 
10
9
  let statIdCounter = 0;
11
10
 
12
- type ContextProps = DeviceProps;
13
-
14
11
  /** AnimationLoop properties */
15
12
  export type AnimationLoopProps = {
16
- onCreateDevice?: (props: DeviceProps) => Promise<Device>;
13
+ device: Device | Promise<Device>;
14
+
17
15
  onAddHTML?: (div: HTMLDivElement) => string; // innerHTML
18
- onInitialize?: (animationProps: AnimationProps) => void;
19
- onRender?: (animationProps: AnimationProps) => void;
16
+ onInitialize?: (animationProps: AnimationProps) => Promise<unknown>;
17
+ onRender?: (animationProps: AnimationProps) => unknown;
20
18
  onFinalize?: (animationProps: AnimationProps) => void;
21
19
  onError?: (reason: Error) => void;
22
20
 
23
- device?: Device | null;
24
- deviceProps?: DeviceProps;
25
21
  stats?: Stats;
26
22
 
27
- // view parameters
28
- debug?: boolean;
23
+ // view parameters - TODO move to CanvasContext?
29
24
  autoResizeViewport?: boolean;
30
25
  autoResizeDrawingBuffer?: boolean;
31
26
  useDevicePixels?: number | boolean;
32
27
  };
33
28
 
29
+ export type MutableAnimationLoopProps = {
30
+ // view parameters
31
+ autoResizeViewport?: boolean;
32
+ autoResizeDrawingBuffer?: boolean;
33
+ useDevicePixels?: number | boolean;
34
+ }
35
+
36
+
34
37
  const DEFAULT_ANIMATION_LOOP_PROPS: Required<AnimationLoopProps> = {
35
- onCreateDevice: (props: DeviceProps): Promise<Device> => luma.createDevice(props),
38
+ device: null!,
39
+
36
40
  onAddHTML: () => '',
37
- onInitialize: () => ({}),
41
+ onInitialize: async () => { return null; },
38
42
  onRender: () => {},
39
43
  onFinalize: () => {},
40
44
  onError: (error) => console.error(error), // eslint-disable-line no-console
41
45
 
42
- device: null,
43
- deviceProps: {},
44
- debug: false,
45
46
  stats: luma.stats.get(`animation-loop-${statIdCounter++}`),
46
47
 
47
48
  // view parameters
48
49
  useDevicePixels: true,
49
- autoResizeViewport: true,
50
- autoResizeDrawingBuffer: true,
50
+ autoResizeViewport: false,
51
+ autoResizeDrawingBuffer: false,
51
52
  };
52
53
 
53
54
  /** Convenient animation loop */
@@ -71,7 +72,7 @@ export class AnimationLoop {
71
72
  _running: boolean = false;
72
73
  _animationFrameId: any = null;
73
74
  _nextFramePromise: Promise<AnimationLoop> | null = null;
74
- _resolveNextFrame: ((AnimationLoop) => void) | null = null;
75
+ _resolveNextFrame: ((animationLoop: AnimationLoop) => void) | null = null;
75
76
  _cpuStartTime: number = 0;
76
77
 
77
78
  // _gpuTimeQuery: Query | null = null;
@@ -79,17 +80,17 @@ export class AnimationLoop {
79
80
  /*
80
81
  * @param {HTMLCanvasElement} canvas - if provided, width and height will be passed to context
81
82
  */
82
- constructor(props: AnimationLoopProps = {}) {
83
+ constructor(props: AnimationLoopProps) {
83
84
  this.props = {...DEFAULT_ANIMATION_LOOP_PROPS, ...props};
84
85
  props = this.props;
85
86
 
87
+ if (!props.device) {
88
+ throw new Error('No device provided');
89
+ }
90
+
86
91
  let {useDevicePixels = true} = this.props;
87
92
 
88
93
  // state
89
- this.device = props.device || null;
90
- // @ts-expect-error
91
- this.gl = (this.device && this.device.gl) || props.gl;
92
-
93
94
  this.stats = props.stats || new Stats({id: 'animation-loop-stats'});
94
95
  this.cpuTime = this.stats.get('CPU Time');
95
96
  this.gpuTime = this.stats.get('GPU Time');
@@ -125,7 +126,7 @@ export class AnimationLoop {
125
126
  }
126
127
 
127
128
  // TODO - move to CanvasContext
128
- setProps(props: AnimationLoopProps): this {
129
+ setProps(props: MutableAnimationLoopProps): this {
129
130
  if ('autoResizeViewport' in props) {
130
131
  this.props.autoResizeViewport = props.autoResizeViewport || false;
131
132
  }
@@ -155,7 +156,7 @@ export class AnimationLoop {
155
156
  if (!this._initialized) {
156
157
  this._initialized = true;
157
158
  // Create the WebGL context
158
- await this._createDevice();
159
+ await this._initDevice();
159
160
  this._initialize();
160
161
 
161
162
  // Note: onIntialize can return a promise (e.g. in case app needs to load resources)
@@ -273,7 +274,7 @@ export class AnimationLoop {
273
274
  // this._gpuTimeQuery = Query.isSupported(this.gl, ['timers']) ? new Query(this.gl) : null;
274
275
  }
275
276
 
276
- _setDisplay(display) {
277
+ _setDisplay(display: any) {
277
278
  if (this.display) {
278
279
  this.display.delete();
279
280
  this.display.animationLoop = null;
@@ -326,15 +327,15 @@ export class AnimationLoop {
326
327
 
327
328
  // Called on each frame, can be overridden to call onRender multiple times
328
329
  // to support e.g. stereoscopic rendering
329
- _renderFrame(props: AnimationProps) {
330
+ _renderFrame(animationProps: AnimationProps) {
330
331
  // Allow e.g. VR display to render multiple frames.
331
332
  if (this.display) {
332
- this.display._renderFrame(props);
333
+ this.display._renderFrame(animationProps);
333
334
  return;
334
335
  }
335
336
 
336
337
  // call callback
337
- this.props.onRender(props);
338
+ this.props.onRender(this._getAnimationProps());
338
339
  // end callback
339
340
  }
340
341
 
@@ -422,12 +423,14 @@ export class AnimationLoop {
422
423
  : this.animationProps.engineTime;
423
424
  }
424
425
 
425
- /** Either uses supplied or existing context, or calls provided callback to create one */
426
- async _createDevice() {
427
- const deviceProps = {...this.props, ...this.props.deviceProps};
428
- this.device = await this.props.onCreateDevice(deviceProps);
429
- this.canvas = this.device.canvasContext?.canvas!;
430
- this._createInfoDiv();
426
+ /** Wait for supplied device */
427
+ async _initDevice() {
428
+ this.device = await this.props.device;
429
+ if (!this.device) {
430
+ throw new Error('No device provided');
431
+ }
432
+ this.canvas = this.device.canvasContext?.canvas || null;
433
+ // this._createInfoDiv();
431
434
  }
432
435
 
433
436
  _createInfoDiv() {
File without changes
@@ -0,0 +1,43 @@
1
+ // luma.gl, MIT license
2
+ import {luma} from '@luma.gl/api';
3
+ import {AnimationLoopTemplate} from './render-loop'
4
+ import {AnimationLoop, AnimationLoopProps} from './animation-loop'
5
+ import type {AnimationProps} from './animation-props';
6
+
7
+ export type MakeAnimationLoopProps = Omit<AnimationLoopProps, 'onCreateDevice' | 'onInitialize' | 'onRedraw' | 'onFinalize'>;
8
+
9
+ /** Instantiates and runs the render loop */
10
+ export function makeAnimationLoop(AnimationLoopTemplateCtor: typeof AnimationLoopTemplate, props?: MakeAnimationLoopProps): AnimationLoop {
11
+ let renderLoop: AnimationLoopTemplate | null = null;
12
+
13
+ const device = props?.device || luma.createDevice();
14
+
15
+ // Create an animation loop;
16
+ const animationLoop = new AnimationLoop({
17
+ ... props,
18
+
19
+ device,
20
+
21
+ async onInitialize(animationProps: AnimationProps): Promise<unknown> {
22
+ // @ts-expect-error abstract to prevent instantiation
23
+ renderLoop = new AnimationLoopTemplateCtor(animationProps);
24
+ // Any async loading can be handled here
25
+ return await renderLoop?.onInitialize(animationProps);
26
+ },
27
+
28
+ onRender: (animationProps: AnimationProps) => renderLoop?.onRender(animationProps),
29
+
30
+ onFinalize: (animationProps: AnimationProps) => renderLoop?.onFinalize(animationProps)
31
+ });
32
+
33
+ // @ts-expect-error Hack: adds info for the website to find
34
+ animationLoop.getInfo = () => {
35
+ // @ts-ignore
36
+ return this.AnimationLoopTemplateCtor.info;
37
+ }
38
+
39
+ // Start the loop automatically
40
+ // animationLoop.start();
41
+
42
+ return animationLoop;
43
+ }
@@ -0,0 +1,23 @@
1
+ import type {AnimationProps} from './animation-props';
2
+
3
+ /**
4
+ * Minimal class that represents a "componentized" rendering life cycle
5
+ * (resource construction, repeated rendering, resource destruction)
6
+ *
7
+ * @note A motivation for this class compared to the raw animation loop is
8
+ * that it simplifies TypeScript code by allowing resources to be typed unconditionally
9
+ * since they are allocated in the constructor rather than in onInitialized
10
+ *
11
+ * @note Introduced in luma.gl v9
12
+ *
13
+ * @example AnimationLoopTemplate is intended to be subclassed,
14
+ * but the subclass should not be instantiated directly. Instead the subclass
15
+ * (i.e. the constructor of the subclass) should be used
16
+ * as an argument to create an AnimationLoop.
17
+ */
18
+ export abstract class AnimationLoopTemplate {
19
+ constructor(animationProps?: AnimationProps) {}
20
+ async onInitialize(animationProps: AnimationProps): Promise<unknown> { return null; }
21
+ abstract onRender(animationProps: AnimationProps): unknown;
22
+ abstract onFinalize(animationProps: AnimationProps): void;
23
+ }
@@ -5,7 +5,7 @@ import Geometry from '../geometry/geometry';
5
5
  export type CubeGeometryProps = {
6
6
  id?: string;
7
7
  indices?: boolean;
8
- attributes?;
8
+ attributes?: any;
9
9
  };
10
10
 
11
11
  export class CubeGeometry extends Geometry {
@@ -4,7 +4,7 @@ import {TruncatedConeGeometry} from './truncated-cone-geometry';
4
4
  export type CylinderGeometryProps = {
5
5
  id?: string;
6
6
  radius?: number;
7
- attributes?
7
+ attributes?: any;
8
8
  };
9
9
 
10
10
  export class CylinderGeometry extends TruncatedConeGeometry {
@@ -11,7 +11,7 @@ export type IcoSphereGeometryProps = {
11
11
  id?: string;
12
12
  radius?: number;
13
13
  iterations?: number;
14
- attributes?
14
+ attributes?: any
15
15
  };
16
16
 
17
17
  export class IcoSphereGeometry extends Geometry {
@@ -40,9 +40,9 @@ function tesselateIcosaHedron(props: IcoSphereGeometryProps) {
40
40
  indices.push();
41
41
 
42
42
  const getMiddlePoint = (() => {
43
- const pointMemo = {};
43
+ const pointMemo: Record<string, number> = {};
44
44
 
45
- return (i1, i2) => {
45
+ return (i1: number, i2: number) => {
46
46
  i1 *= 3;
47
47
  i2 *= 3;
48
48
  const mini = i1 < i2 ? i1 : i2;
@@ -5,7 +5,7 @@ import {unpackIndexedGeometry} from '../geometry/geometry-utils';
5
5
  export type PlaneGeometryProps = {
6
6
  id?: string;
7
7
  radius?: number;
8
- attributes?
8
+ attributes?: any
9
9
  };
10
10
 
11
11
  // Primitives inspired by TDL http://code.google.com/p/webglsamples/,
@@ -26,7 +26,7 @@ export class PlaneGeometry extends Geometry {
26
26
  }
27
27
 
28
28
  /* eslint-disable complexity, max-statements */
29
- function tesselatePlane(props) {
29
+ function tesselatePlane(props: any) {
30
30
  const {type = 'x,y', offset = 0, flipCull = false, unpack = false} = props;
31
31
 
32
32
  const coords = type.split(',');
@@ -6,7 +6,7 @@ export type SphereGeometryProps = {
6
6
  radius?: number;
7
7
  nlat?: number;
8
8
  nlong?: number;
9
- attributes?
9
+ attributes?: any
10
10
  };
11
11
 
12
12
  // Primitives inspired by TDL http://code.google.com/p/webglsamples/,
@@ -34,7 +34,7 @@ export function makeTruncatedConeGeometry(props?: TruncatedConeGeometryProps): G
34
34
  }
35
35
 
36
36
  export class TruncatedConeGeometry extends Geometry {
37
- constructor(props: TruncatedConeGeometryProps & {id?: string; attributes?} = {}) {
37
+ constructor(props: TruncatedConeGeometryProps & {id?: string; attributes?: any} = {}) {
38
38
  const {id = uid('truncated-code-geometry')} = props;
39
39
  const {indices, attributes} = tesselateTruncatedCone(props);
40
40
  super({
@@ -1,13 +1,13 @@
1
1
  // import type Geometry from './geometry';
2
2
 
3
- export function unpackIndexedGeometry(geometry) {
3
+ export function unpackIndexedGeometry(geometry: any) {
4
4
  const {indices, attributes} = geometry;
5
5
  if (!indices) {
6
6
  return geometry;
7
7
  }
8
8
 
9
9
  const vertexCount = indices.value.length;
10
- const unpackedAttributes = {};
10
+ const unpackedAttributes: Record<string, any> = {};
11
11
 
12
12
  for (const attributeName in attributes) {
13
13
  const attribute = attributes[attributeName];
@@ -68,6 +68,7 @@ export default class Geometry {
68
68
  NORMAL: GeometryAttribute,
69
69
  TEXCOORD_0: GeometryAttribute,
70
70
  COLOR_0?: GeometryAttribute,
71
+ [key: string]: GeometryAttribute | undefined
71
72
  };
72
73
  readonly indices?: Uint16Array | Uint32Array;
73
74
 
@@ -109,8 +110,8 @@ export default class Geometry {
109
110
  // Move indices to separate field
110
111
  if (attributeName === 'indices') {
111
112
  assert(!this.indices);
112
- // @ts-expect-error
113
- this.indices = attribute;
113
+ // @ts-expect-error
114
+ this.indices = attribute;
114
115
  } else {
115
116
  this.attributes[attributeName] = attribute;
116
117
  }
@@ -136,9 +137,10 @@ export default class Geometry {
136
137
  }
137
138
 
138
139
  // Return an object with all attributes plus indices added as a field.
139
- // getAttributes(): GeometryAttributes {
140
- // return this.indices ? {indices: this.indices, ...this.attributes} : this.attributes;
141
- // }
140
+ getAttributes(): GeometryAttributes {
141
+ // @ts-expect-error Geometry types are a mess
142
+ return this.indices ? {indices: this.indices, ...this.attributes} : this.attributes;
143
+ }
142
144
 
143
145
  // PRIVATE
144
146
 
@@ -151,12 +153,12 @@ export default class Geometry {
151
153
  // type: indices, vertices, uvs
152
154
  // size: elements per vertex
153
155
  // target: WebGL buffer type (string or constant)
154
- _setAttributes(attributes: Record<string, GeometryAttribute>, indices): this {
156
+ _setAttributes(attributes: Record<string, GeometryAttribute>, indices: any): this {
155
157
 
156
158
  return this;
157
159
  }
158
160
 
159
- _calculateVertexCount(attributes, indices): number {
161
+ _calculateVertexCount(attributes: any, indices: any): number {
160
162
  if (indices) {
161
163
  return indices.value.length;
162
164
  }
package/src/index.ts CHANGED
@@ -1,16 +1,22 @@
1
1
  // luma.gl Engine API
2
- export type {AnimationProps} from './lib/animation-props';
3
- export type {AnimationLoopProps} from './lib/animation-loop';
4
- export {AnimationLoop} from './lib/animation-loop';
5
- export {RenderLoop} from './lib/render-loop';
6
- export type {ModelProps} from './lib/model';
7
- export {default as Model} from './lib/model';
8
-
9
- export {PipelineFactory} from './lib/pipeline-factory';
10
2
 
11
3
  // Animation
12
4
  export {Timeline} from './animation/timeline';
13
5
  export {KeyFrames} from './animation/key-frames';
6
+ export type {AnimationProps} from './animation-loop/animation-props';
7
+
8
+ export {AnimationLoopTemplate} from './animation-loop/render-loop';
9
+
10
+ export type {AnimationLoopProps} from './animation-loop/animation-loop';
11
+ export {AnimationLoop} from './animation-loop/animation-loop';
12
+
13
+ export type {MakeAnimationLoopProps} from './animation-loop/make-animation-loop';
14
+ export {makeAnimationLoop} from './animation-loop/make-animation-loop';
15
+
16
+ export type {ModelProps} from './lib/model';
17
+ export {Model} from './lib/model';
18
+
19
+ export {PipelineFactory} from './lib/pipeline-factory';
14
20
 
15
21
  // Utils
16
22
  // export {default as ClipSpace} from './lib/clip-space';
@@ -72,10 +72,10 @@ export function getAttributeBuffersFromGeometry(device: Device, geometry: Geomet
72
72
 
73
73
  for (const [name, attribute] of Object.entries(geometry.attributes)) {
74
74
  const remappedName = mapAttributeName(name);
75
- if (attribute.constant) {
75
+ if (attribute?.constant) {
76
76
  throw new Error('constant attributes not supported');
77
77
  } else {
78
- const typedArray = attribute.value;
78
+ const typedArray = attribute?.value;
79
79
  buffers[remappedName] = device.createBuffer({data: typedArray, id: `${remappedName}-buffer`});
80
80
  }
81
81
  }
@@ -84,6 +84,7 @@ export function getAttributeBuffersFromGeometry(device: Device, geometry: Geomet
84
84
  }
85
85
 
86
86
  function mapAttributeName(name: string): string {
87
+ // @ts-ignore-error
87
88
  return GLTF_TO_LUMA_ATTRIBUTE_MAP[name] || name;
88
89
  }
89
90
 
package/src/lib/model.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  // luma.gl, MIT license
2
2
 
3
3
  import type {Device, Buffer, RenderPipelineProps, RenderPass, Binding, PrimitiveTopology} from '@luma.gl/api';
4
- import {RenderPipeline, Shader, cast} from '@luma.gl/api';
4
+ import {RenderPipeline} from '@luma.gl/api';
5
5
  import type { ShaderModule } from '@luma.gl/shadertools';
6
6
  import type Geometry from '../geometry/geometry';
7
7
  import {getAttributeBuffersFromGeometry, getIndexBufferFromGeometry} from './model-utils';
@@ -29,7 +29,7 @@ const DEFAULT_MODEL_PROPS: Required<ModelProps> = {
29
29
  };
30
30
 
31
31
  /** v9 API */
32
- export default class Model {
32
+ export class Model {
33
33
  readonly device: Device;
34
34
  readonly pipeline: RenderPipeline;
35
35
  readonly id: string;
@@ -1,5 +1,5 @@
1
- import type {RenderPipelineProps, RenderPipelineParameters, PrimitiveTopology, ShaderLayout} from '@luma.gl/api';
2
- import {Device, RenderPipeline, ComputePipeline} from '@luma.gl/api/';
1
+ import type {RenderPipelineParameters, PrimitiveTopology, ShaderLayout} from '@luma.gl/api';
2
+ import {Device, RenderPipeline} from '@luma.gl/api/';
3
3
  import type { ShaderModule } from '@luma.gl/shadertools';
4
4
  import {assembleShaders} from '@luma.gl/shadertools';
5
5
 
@@ -89,7 +89,7 @@ export class PipelineFactory {
89
89
  this.stateHash++;
90
90
  }
91
91
 
92
- addShaderHook(hook: string, opts?): void {
92
+ addShaderHook(hook: string, opts?: any): void {
93
93
  if (opts) {
94
94
  hook = Object.assign(opts, {hook});
95
95
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"animation-loop.d.ts","sourceRoot":"","sources":["../../src/lib/animation-loop.ts"],"names":[],"mappings":";AAAA,OAAO,EAAO,MAAM,EAAE,WAAW,EAAC,MAAM,cAAc,CAAC;AAEvD,OAAO,EAAC,QAAQ,EAAC,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAC,cAAc,EAAC,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAC,KAAK,EAAE,IAAI,EAAC,MAAM,iBAAiB,CAAC;AAS5C,+BAA+B;AAC/B,oBAAY,kBAAkB,GAAG;IAC/B,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IACzD,SAAS,CAAC,EAAE,CAAC,GAAG,EAAE,cAAc,KAAK,MAAM,CAAC;IAC5C,YAAY,CAAC,EAAE,CAAC,cAAc,EAAE,cAAc,KAAK,IAAI,CAAC;IACxD,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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AC,KAAK,EAAE,kBAAkB,GAAG,IAAI;IAazC,kDAAkD;IAC5C,KAAK;IA4CX,8BAA8B;IAC9B,MAAM,IAAI,IAAI;IA2Bd,IAAI;IAiBJ,cAAc,CAAC,QAAQ,EAAE,QAAQ,GAAG,QAAQ;IAK5C,cAAc,IAAI,IAAI;IAItB,aAAa,IAAI,OAAO,CAAC,aAAa,CAAC;IAWjC,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC;IAWlC,WAAW;IAcX,WAAW,CAAC,OAAO,KAAA;IAcnB,sBAAsB;IActB,qBAAqB;IAerB,eAAe;IAUf,YAAY,CAAC,KAAK,EAAE,cAAc;IAYlC,iBAAiB;IAIjB,WAAW;IAMX,yBAAyB;IA+BzB,kBAAkB,IAAI,cAAc;IAQpC,qBAAqB,IAAI,IAAI;IAmC7B,yFAAyF;IACnF,aAAa;IAOnB,cAAc;IAsBd,iBAAiB,IAAI;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAC;IAsBpE,6BAA6B;IAC7B,eAAe;IAQf;;;OAGG;IACH,0BAA0B;IAM1B,YAAY;IAuBZ,UAAU;IAWV,mBAAmB;IAOnB,YAAY,CAAC,KAAK,EAAE,KAAK;IAMzB,aAAa,CAAC,KAAK,EAAE,KAAK;CAG3B"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/lib/animation-loop.ts"],"names":["luma","requestAnimationFrame","cancelAnimationFrame","Stats","isBrowser","isPage","document","statIdCounter","DEFAULT_ANIMATION_LOOP_PROPS","onCreateDevice","props","createDevice","onAddHTML","onInitialize","onRender","onFinalize","onError","error","console","device","deviceProps","debug","stats","get","useDevicePixels","autoResizeViewport","autoResizeDrawingBuffer","AnimationLoop","constructor","gl","id","cpuTime","gpuTime","frameRate","setProps","start","bind","stop","_onMousemove","_onMouseleave","destroy","_setDisplay","delete","setNeedsRedraw","reason","needsRedraw","_running","appContext","_initialized","_createDevice","_initialize","_getAnimationProps","_cancelAnimationFrame","_requestAnimationFrame","err","Error","redraw","isLost","_beginTimers","_setupFrame","_updateAnimationProps","_renderFrame","_clearNeedsRedraw","_resolveNextFrame","_nextFramePromise","_endTimers","animationProps","attachTimeline","timeline","detachTimeline","waitForRender","Promise","resolve","toDataURL","canvas","HTMLCanvasElement","_startEventHandling","_initializeAnimationProps","_resizeCanvasDrawingBuffer","_resizeViewport","display","animationLoop","_animationFrameId","_animationFrame","canvasContext","width","height","aspect","time","startTime","Date","now","engineTime","tick","tock","_mousePosition","_getSizeAndAspect","update","Math","floor","getTime","_createInfoDiv","wrapperDiv","createElement","body","appendChild","style","position","div","left","bottom","background","html","innerHTML","getPixelSize","clientHeight","clientWidth","viewport","drawingBufferWidth","drawingBufferHeight","resize","timeEnd","timeStart","addEventListener","event","MouseEvent","offsetX","offsetY"],"mappings":";AAAA,SAAQA,IAAR,QAAwC,cAAxC;AACA,SAAQC,qBAAR,EAA+BC,oBAA/B,QAA0D,cAA1D;AAGA,SAAQC,KAAR,QAA0B,iBAA1B;AACA,SAAQC,SAAR,QAAwB,eAAxB;AAEA,MAAMC,MAAM,GAAGD,SAAS,MAAM,OAAOE,QAAP,KAAoB,WAAlD;AAEA,IAAIC,aAAa,GAAG,CAApB;AAwBA,MAAMC,4BAA0D,GAAG;AACjEC,EAAAA,cAAc,EAAGC,KAAD,IAAyCV,IAAI,CAACW,YAAL,CAAkBD,KAAlB,CADQ;AAEjEE,EAAAA,SAAS,EAAE,MAAM,EAFgD;AAGjEC,EAAAA,YAAY,EAAE,OAAO,EAAP,CAHmD;AAIjEC,EAAAA,QAAQ,EAAE,MAAM,CAAE,CAJ+C;AAKjEC,EAAAA,UAAU,EAAE,MAAM,CAAE,CAL6C;AAMjEC,EAAAA,OAAO,EAAGC,KAAD,IAAWC,OAAO,CAACD,KAAR,CAAcA,KAAd,CAN6C;AAQjEE,EAAAA,MAAM,EAAE,IARyD;AASjEC,EAAAA,WAAW,EAAE,E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zB,QAAIA,KAAK,YAAYC,UAArB,EAAiC;AAC/B,WAAK1E,kBAAL,GAA0B4C,cAA1B,GAA2C,CAAC6B,KAAK,CAACE,OAAP,EAAgBF,KAAK,CAACG,OAAtB,CAA3C;AACD;AACF;;AAEDxF,EAAAA,aAAa,CAACqF,KAAD,EAAe;AAC1B,SAAKzE,kBAAL,GAA0B4C,cAA1B,GAA2C,IAA3C;AACD;;AA3ewB","sourcesContent":["import {luma, Device, DeviceProps} from '@luma.gl/api';\nimport {requestAnimationFrame, cancelAnimationFrame} from '@luma.gl/api';\nimport {Timeline} from '../animation/timeline';\nimport {AnimationProps} from '../lib/animation-props';\nimport {Stats, Stat} from '@probe.gl/stats';\nimport {isBrowser} from '@probe.gl/env';\n\nconst isPage = isBrowser() && typeof document !== 'undefined';\n\nlet statIdCounter = 0;\n\ntype ContextProps = DeviceProps;\n\n/** AnimationLoop properties */\nexport type AnimationLoopProps = {\n onCreateDevice?: (props: DeviceProps) => Promise<Device>;\n onAddHTML?: (div: HTMLDivElement) => string; // innerHTML\n onInitialize?: (animationProps: AnimationProps) => void;\n onRender?: (animationProps: AnimationProps) => void;\n onFinalize?: (animationProps: AnimationProps) => void;\n onError?: (reason: Error) => void;\n\n device?: Device | null;\n deviceProps?: DeviceProps;\n stats?: Stats;\n\n // view parameters\n debug?: boolean;\n autoResizeViewport?: boolean;\n autoResizeDrawingBuffer?: boolean;\n useDevicePixels?: number | boolean;\n};\n\nconst DEFAULT_ANIMATION_LOOP_PROPS: Required<AnimationLoopProps> = {\n onCreateDevice: (props: DeviceProps): Promise<Device> => luma.createDevice(props),\n onAddHTML: () => '',\n onInitialize: () => ({}),\n onRender: () => {},\n onFinalize: () => {},\n onError: (error) => console.error(error), // eslint-disable-line no-console\n\n device: null,\n deviceProps: {},\n debug: false,\n stats: luma.stats.get(`animation-loop-${statIdCounter++}`),\n\n // view parameters\n useDevicePixels: true,\n autoResizeViewport: true,\n autoResizeDrawingBuffer: true,\n};\n\n/** Convenient animation loop */\nexport class AnimationLoop {\n device: Device | null = null;\n canvas: HTMLCanvasElement | OffscreenCanvas | null = null;\n\n props: Required<AnimationLoopProps>;\n animationProps: AnimationProps | null = null;\n timeline: Timeline | null = null;\n stats: Stats;\n cpuTime: Stat;\n gpuTime: Stat;\n frameRate: Stat;\n\n display: any;\n\n needsRedraw: string | false = 'initialized';\n\n _initialized: boolean = false;\n _running: boolean = false;\n _animationFrameId: any = null;\n _nextFramePromise: Promise<AnimationLoop> | null = null;\n _resolveNextFrame: ((AnimationLoop) => 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 // state\n this.device = props.device || null;\n // @ts-expect-error\n this.gl = (this.device && this.device.gl) || props.gl;\n\n this.stats = props.stats || new Stats({id: 'animation-loop-stats'});\n this.cpuTime = this.stats.get('CPU Time');\n this.gpuTime = this.stats.get('GPU Time');\n this.frameRate = this.stats.get('Frame Rate');\n\n this.setProps({\n autoResizeViewport: props.autoResizeViewport,\n autoResizeDrawingBuffer: props.autoResizeDrawingBuffer,\n useDevicePixels\n });\n\n // Bind methods\n this.start = this.start.bind(this);\n this.stop = this.stop.bind(this);\n\n this._onMousemove = this._onMousemove.bind(this);\n this._onMouseleave = this._onMouseleave.bind(this);\n }\n\n destroy(): void {\n this.stop();\n this._setDisplay(null);\n }\n\n /** @deprecated Use .destroy() */\n delete(): void {\n this.destroy();\n }\n\n setNeedsRedraw(reason: string): this {\n this.needsRedraw = this.needsRedraw || reason;\n return this;\n }\n\n // TODO - move to CanvasContext\n setProps(props: AnimationLoopProps): this {\n if ('autoResizeViewport' in props) {\n this.props.autoResizeViewport = props.autoResizeViewport || false;\n }\n if ('autoResizeDrawingBuffer' in props) {\n this.props.autoResizeDrawingBuffer = props.autoResizeDrawingBuffer || false;\n }\n if ('useDevicePixels' in props) {\n this.props.useDevicePixels = props.useDevicePixels || false;\n }\n return this;\n }\n\n /** Starts a render loop if not already running */\n async start() {\n if (this._running) {\n return this;\n }\n this._running = true;\n\n try {\n // check that we haven't been stopped\n if (!this._running) {\n return null;\n }\n\n let appContext;\n if (!this._initialized) {\n this._initialized = true;\n // Create the WebGL context\n await this._createDevice();\n this._initialize();\n\n // Note: onIntialize can return a promise (e.g. in case app needs to load resources)\n await this.props.onInitialize(this._getAnimationProps());\n }\n\n // check that we haven't been stopped\n if (!this._running) {\n return null;\n }\n\n // Start the loop\n if (appContext !== false) {\n // cancel any pending renders to ensure only one loop can ever run\n this._cancelAnimationFrame();\n this._requestAnimationFrame();\n }\n\n return this;\n } catch (err: unknown) {\n const error = err instanceof Error ? err : new Error('Unknown error')\n this.props.onError(error);\n // this._running = false; // TODO\n throw error;\n }\n }\n\n /** Explicitly draw a frame */\n redraw(): this {\n if (this.device?.isLost) {\n return this;\n }\n\n this._beginTimers();\n\n this._setupFrame();\n this._updateAnimationProps();\n\n this._renderFrame(this._getAnimationProps());\n\n // clear needsRedraw flag\n this._clearNeedsRedraw();\n\n if (this._resolveNextFrame) {\n this._resolveNextFrame(this);\n this._nextFramePromise = null;\n this._resolveNextFrame = null;\n }\n\n this._endTimers();\n\n return this;\n }\n\n // Stops a render loop if already running, finalizing\n stop() {\n // console.debug(`Stopping ${this.constructor.name}`);\n if (this._running) {\n // call callback\n // If stop is called immediately, we can end up in a state where props haven't been initialized...\n if (this.animationProps) {\n this.props.onFinalize(this.animationProps);\n }\n\n this._cancelAnimationFrame();\n this._nextFramePromise = null;\n this._resolveNextFrame = null;\n this._running = false;\n }\n return this;\n }\n\n attachTimeline(timeline: Timeline): Timeline {\n this.timeline = timeline;\n return this.timeline;\n }\n\n detachTimeline(): void {\n this.timeline = null;\n }\n\n waitForRender(): Promise<AnimationLoop> {\n this.setNeedsRedraw('waitForRender');\n\n if (!this._nextFramePromise) {\n this._nextFramePromise = new Promise((resolve) => {\n this._resolveNextFrame = resolve;\n });\n }\n return this._nextFramePromise;\n }\n\n async toDataURL(): Promise<string> {\n this.setNeedsRedraw('toDataURL');\n await this.waitForRender();\n if (this.canvas instanceof HTMLCanvasElement) {\n return this.canvas.toDataURL();\n }\n throw new Error('OffscreenCanvas');\n }\n\n // PRIVATE METHODS\n\n _initialize() {\n this._startEventHandling();\n\n // Initialize the callback data\n this._initializeAnimationProps();\n this._updateAnimationProps();\n\n // Default viewport setup, in case onInitialize wants to render\n this._resizeCanvasDrawingBuffer();\n this._resizeViewport();\n\n // this._gpuTimeQuery = Query.isSupported(this.gl, ['timers']) ? new Query(this.gl) : null;\n }\n\n _setDisplay(display) {\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.props.onRender(props);\n // end callback\n }\n\n _clearNeedsRedraw() {\n this.needsRedraw = false;\n }\n\n _setupFrame() {\n this._resizeCanvasDrawingBuffer();\n this._resizeViewport();\n }\n\n // Initialize the object that will be passed to app callbacks\n _initializeAnimationProps() {\n if (!this.device) {\n throw new Error('loop');\n }\n this.animationProps = {\n animationLoop: this,\n device: this.device,\n canvas: this.device?.canvasContext?.canvas!,\n timeline: this.timeline,\n\n // Initial values\n useDevicePixels: this.props.useDevicePixels,\n needsRedraw: false,\n\n // Placeholders\n width: 1,\n height: 1,\n aspect: 1,\n\n // Animation props\n time: 0,\n startTime: Date.now(),\n engineTime: 0,\n tick: 0,\n tock: 0,\n\n // Experimental\n _mousePosition: null // Event props\n };\n }\n\n _getAnimationProps(): AnimationProps {\n if (!this.animationProps) {\n throw new Error('animationProps');\n }\n return this.animationProps;\n }\n\n // Update the context object that will be passed to app callbacks\n _updateAnimationProps(): void {\n if (!this.animationProps) {\n return;\n }\n\n 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 /** Either uses supplied or existing context, or calls provided callback to create one */\n async _createDevice() {\n const deviceProps = {...this.props, ...this.props.deviceProps};\n this.device = await this.props.onCreateDevice(deviceProps);\n this.canvas = this.device.canvasContext?.canvas!;\n this._createInfoDiv();\n }\n\n _createInfoDiv() {\n if (this.canvas && this.props.onAddHTML) {\n const wrapperDiv = document.createElement('div');\n document.body.appendChild(wrapperDiv);\n wrapperDiv.style.position = 'relative';\n const div = document.createElement('div');\n div.style.position = 'absolute';\n div.style.left = '10px';\n div.style.bottom = '10px';\n div.style.width = '300px';\n div.style.background = 'white';\n if (this.canvas instanceof HTMLCanvasElement) {\n wrapperDiv.appendChild(this.canvas);\n }\n wrapperDiv.appendChild(div);\n const html = this.props.onAddHTML(div);\n if (html) {\n div.innerHTML = html;\n }\n }\n }\n\n _getSizeAndAspect(): {width: number; height: number; aspect: number} {\n if (!this.device) {\n return {width: 1, height: 1, aspect: 1};\n }\n // https://webglfundamentals.org/webgl/lessons/webgl-resizing-the-canvas.html\n const [width, height] = this.device?.canvasContext?.getPixelSize() || [1, 1];\n\n // https://webglfundamentals.org/webgl/lessons/webgl-anti-patterns.html\n let aspect = 1;\n const canvas = this.device?.canvasContext?.canvas;\n\n // @ts-expect-error\n if (canvas && canvas.clientHeight) {\n // @ts-expect-error\n aspect = canvas.clientWidth / canvas.clientHeight;\n } else if (width > 0 && height > 0) {\n aspect = width / height;\n }\n\n return {width, height, aspect};\n }\n\n /** Default viewport setup */\n _resizeViewport() {\n // @ts-expect-error Expose on canvasContext\n if (this.props.autoResizeViewport && this.device.gl) {\n // @ts-expect-error Expose canvasContext\n this.device.gl.viewport(0, 0, this.device.gl.drawingBufferWidth, this.device.gl.drawingBufferHeight);\n }\n }\n\n /**\n * Resize the render buffer of the canvas to match canvas client size\n * Optionally multiplying with devicePixel ratio\n */\n _resizeCanvasDrawingBuffer() {\n if (this.props.autoResizeDrawingBuffer) {\n this.device?.canvasContext?.resize({useDevicePixels: this.props.useDevicePixels});\n }\n }\n\n _beginTimers() {\n this.frameRate.timeEnd();\n this.frameRate.timeStart();\n\n // Check if timer for last frame has completed.\n // GPU timer results are never available in the same\n // frame they are captured.\n // if (\n // this._gpuTimeQuery &&\n // this._gpuTimeQuery.isResultAvailable() &&\n // !this._gpuTimeQuery.isTimerDisjoint()\n // ) {\n // this.stats.get('GPU Time').addTime(this._gpuTimeQuery.getTimerMilliseconds());\n // }\n\n // if (this._gpuTimeQuery) {\n // // GPU time query start\n // this._gpuTimeQuery.beginTimeElapsedQuery();\n // }\n\n // this.cpuTime.timeStart();\n }\n\n _endTimers() {\n this.cpuTime.timeEnd();\n\n // if (this._gpuTimeQuery) {\n // // GPU time query end. Results will be available on next frame.\n // this._gpuTimeQuery.end();\n // }\n }\n\n // Event handling\n\n _startEventHandling() {\n if (this.canvas) {\n this.canvas.addEventListener('mousemove', this._onMousemove);\n this.canvas.addEventListener('mouseleave', this._onMouseleave);\n }\n }\n\n _onMousemove(event: Event) {\n if (event instanceof MouseEvent) {\n this._getAnimationProps()._mousePosition = [event.offsetX, event.offsetY];\n }\n }\n\n _onMouseleave(event: Event) {\n this._getAnimationProps()._mousePosition = null;\n }\n}\n"],"file":"animation-loop.js"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"animation-props.d.ts","sourceRoot":"","sources":["../../src/lib/animation-props.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,cAAc,CAAC;AACpC,OAAO,EAAC,QAAQ,EAAC,MAAM,uBAAuB,CAAA;AAC9C,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,kBAAkB,CAAC;AAEpD,+CAA+C;AAC/C,oBAAY,cAAc,GAAG;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,aAAa,CAAC;IAE7B,oCAAoC;IACpC,MAAM,EAAE,iBAAiB,GAAG,eAAe,CAAC;IAC5C,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IAGf,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IAGb,WAAW,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IAE7B,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAC;IAG1B,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC;CAC1C,CAAC"}
@@ -1,14 +0,0 @@
1
- import type { DeviceProps } from '@luma.gl/api';
2
- import type { AnimationProps } from '../lib/animation-props';
3
- import { AnimationLoop } from './animation-loop';
4
- /**
5
- * Minimal animation loop that initializes models in constructor
6
- * Simplifying type management
7
- * v9 API
8
- */
9
- export declare abstract class RenderLoop {
10
- constructor(animationProps?: AnimationProps);
11
- /** Instantiates and runs the render loop */
12
- static run(RenderLoopConstructor: typeof RenderLoop, deviceProps?: DeviceProps): AnimationLoop;
13
- }
14
- //# sourceMappingURL=render-loop.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"render-loop.d.ts","sourceRoot":"","sources":["../../src/lib/render-loop.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAC,aAAa,EAAC,MAAM,kBAAkB,CAAC;AAE/C;;;;GAIG;AACH,8BAAsB,UAAU;gBAClB,cAAc,CAAC,EAAE,cAAc;IAE3C,4CAA4C;IAC5C,MAAM,CAAC,GAAG,CAAC,qBAAqB,EAAE,OAAO,UAAU,EAAE,WAAW,CAAC,EAAE,WAAW,GAAG,aAAa;CAS/F"}
@@ -1,49 +0,0 @@
1
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
- import { AnimationLoop } from './animation-loop';
3
- export class RenderLoop {
4
- constructor(animationProps) {}
5
-
6
- static run(RenderLoopConstructor, deviceProps) {
7
- const animationLoop = new SyncInitAnimationLoop(RenderLoopConstructor, deviceProps);
8
- return animationLoop;
9
- }
10
-
11
- }
12
-
13
- class SyncInitAnimationLoop extends AnimationLoop {
14
- getInfo() {
15
- return this.RenderLoopConstructor.info;
16
- }
17
-
18
- constructor(RenderLoopConstructor, deviceProps) {
19
- super({
20
- deviceProps
21
- });
22
-
23
- _defineProperty(this, "RenderLoopConstructor", void 0);
24
-
25
- _defineProperty(this, "renderLoop", null);
26
-
27
- this.RenderLoopConstructor = RenderLoopConstructor;
28
- }
29
-
30
- onInitialize(animationProps) {
31
- this.renderLoop = new this.RenderLoopConstructor(animationProps);
32
- }
33
-
34
- onRender(animationProps) {
35
- var _this$renderLoop, _this$renderLoop$onRe, _this$renderLoop2, _this$renderLoop2$fra;
36
-
37
- (_this$renderLoop = this.renderLoop) === null || _this$renderLoop === void 0 ? void 0 : (_this$renderLoop$onRe = _this$renderLoop.onRender) === null || _this$renderLoop$onRe === void 0 ? void 0 : _this$renderLoop$onRe.call(_this$renderLoop, animationProps);
38
- (_this$renderLoop2 = this.renderLoop) === null || _this$renderLoop2 === void 0 ? void 0 : (_this$renderLoop2$fra = _this$renderLoop2.frame) === null || _this$renderLoop2$fra === void 0 ? void 0 : _this$renderLoop2$fra.call(_this$renderLoop2, animationProps);
39
- }
40
-
41
- onFinalize(animationProps) {
42
- var _this$renderLoop3, _this$renderLoop3$onF, _this$renderLoop4, _this$renderLoop4$des;
43
-
44
- (_this$renderLoop3 = this.renderLoop) === null || _this$renderLoop3 === void 0 ? void 0 : (_this$renderLoop3$onF = _this$renderLoop3.onFinalize) === null || _this$renderLoop3$onF === void 0 ? void 0 : _this$renderLoop3$onF.call(_this$renderLoop3, animationProps);
45
- (_this$renderLoop4 = this.renderLoop) === null || _this$renderLoop4 === void 0 ? void 0 : (_this$renderLoop4$des = _this$renderLoop4.destroy) === null || _this$renderLoop4$des === void 0 ? void 0 : _this$renderLoop4$des.call(_this$renderLoop4, animationProps);
46
- }
47
-
48
- }
49
- //# sourceMappingURL=render-loop.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/lib/render-loop.ts"],"names":["AnimationLoop","RenderLoop","constructor","animationProps","run","RenderLoopConstructor","deviceProps","animationLoop","SyncInitAnimationLoop","getInfo","info","onInitialize","renderLoop","onRender","frame","onFinalize","destroy"],"mappings":";AAEA,SAAQA,aAAR,QAA4B,kBAA5B;AAOA,OAAO,MAAeC,UAAf,CAA0B;AAC/BC,EAAAA,WAAW,CAACC,cAAD,EAAkC,CAAE;;AAGrC,SAAHC,GAAG,CAACC,qBAAD,EAA2CC,WAA3C,EAAqF;AAE7F,UAAMC,aAAa,GAAG,IAAIC,qBAAJ,CAA0BH,qBAA1B,EAAiDC,WAAjD,CAAtB;AAKA,WAAOC,aAAP;AACD;;AAZ8B;;AAgBjC,MAAMC,qBAAN,SAAoCR,aAApC,CAAkD;AAIhDS,EAAAA,OAAO,GAAG;AAER,WAAO,KAAKJ,qBAAL,CAA2BK,IAAlC;AACD;;AAEDR,EAAAA,WAAW,CAACG,qBAAD,EAA2CC,WAA3C,EAAsE;AAC/E,UAAM;AAACA,MAAAA;AAAD,KAAN;;AAD+E;;AAAA,wCAPjD,IAOiD;;AAE/E,SAAKD,qBAAL,GAA6BA,qBAA7B;AACD;;AAEDM,EAAAA,YAAY,CAACR,cAAD,EAAiC;AAE3C,SAAKS,UAAL,GAAkB,IAAI,KAAKP,qBAAT,CAA+BF,cAA/B,CAAlB;AACD;;AAEDU,EAAAA,QAAQ,CAACV,cAAD,EAAiC;AAAA;;AAEvC,6BAAKS,UAAL,+FAAiBC,QAAjB,uGAA4BV,cAA5B;AAEA,8BAAKS,UAAL,iGAAiBE,KAAjB,wGAAyBX,cAAzB;AACD;;AAEDY,EAAAA,UAAU,CAACZ,cAAD,EAAiC;AAAA;;AAEzC,8BAAKS,UAAL,iGAAiBG,UAAjB,wGAA8BZ,cAA9B;AAEA,8BAAKS,UAAL,iGAAiBI,OAAjB,wGAA2Bb,cAA3B;AACD;;AA/B+C","sourcesContent":["import type {DeviceProps} from '@luma.gl/api';\nimport type {AnimationProps} from '../lib/animation-props';\nimport {AnimationLoop} from './animation-loop';\n\n/**\n * Minimal animation loop that initializes models in constructor\n * Simplifying type management\n * v9 API\n */\nexport abstract class RenderLoop {\n constructor(animationProps?: AnimationProps) {}\n\n /** Instantiates and runs the render loop */\n static run(RenderLoopConstructor: typeof RenderLoop, deviceProps?: DeviceProps): AnimationLoop {\n // Create an animation loop;\n const animationLoop = new SyncInitAnimationLoop(RenderLoopConstructor, deviceProps);\n\n // Start the loop automatically\n // animationLoop.start();\n\n return animationLoop;\n }\n}\n\n/** Instantiates the RenderLoop once the device is created */\nclass SyncInitAnimationLoop extends AnimationLoop {\n RenderLoopConstructor: typeof RenderLoop;\n renderLoop: RenderLoop | null = null;\n\n getInfo() {\n // @ts-ignore\n return this.RenderLoopConstructor.info;\n }\n\n constructor(RenderLoopConstructor: typeof RenderLoop, deviceProps?: DeviceProps) {\n super({deviceProps});\n this.RenderLoopConstructor = RenderLoopConstructor;\n }\n\n onInitialize(animationProps: AnimationProps) {\n // @ts-expect-error abstract to prevent instantiation\n this.renderLoop = new this.RenderLoopConstructor(animationProps);\n }\n\n onRender(animationProps: AnimationProps) {\n // @ts-expect-error API still TBD\n this.renderLoop?.onRender?.(animationProps);\n // @ts-expect-error API still TBD\n this.renderLoop?.frame?.(animationProps);\n }\n\n onFinalize(animationProps: AnimationProps) {\n // @ts-expect-error API still TBD\n this.renderLoop?.onFinalize?.(animationProps);\n // @ts-expect-error API still TBD\n this.renderLoop?.destroy?.(animationProps);\n }\n}\n"],"file":"render-loop.js"}