@luma.gl/engine 9.0.0-beta.4 → 9.0.0-beta.6

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 (149) hide show
  1. package/dist/animation/key-frames.js +54 -54
  2. package/dist/animation/timeline.d.ts.map +1 -1
  3. package/dist/animation/timeline.js +95 -100
  4. package/dist/animation-loop/animation-loop-template.d.ts +1 -1
  5. package/dist/animation-loop/animation-loop-template.d.ts.map +1 -1
  6. package/dist/animation-loop/animation-loop-template.js +19 -5
  7. package/dist/animation-loop/animation-loop.d.ts +2 -2
  8. package/dist/animation-loop/animation-loop.d.ts.map +1 -1
  9. package/dist/animation-loop/animation-loop.js +433 -356
  10. package/dist/animation-loop/animation-props.d.ts +2 -2
  11. package/dist/animation-loop/animation-props.d.ts.map +1 -1
  12. package/dist/animation-loop/animation-props.js +0 -1
  13. package/dist/animation-loop/make-animation-loop.d.ts +2 -2
  14. package/dist/animation-loop/make-animation-loop.d.ts.map +1 -1
  15. package/dist/animation-loop/make-animation-loop.js +28 -24
  16. package/dist/debug/copy-texture-to-image.d.ts.map +1 -1
  17. package/dist/debug/copy-texture-to-image.js +41 -42
  18. package/dist/debug/debug-framebuffer.d.ts.map +1 -1
  19. package/dist/debug/debug-framebuffer.js +43 -40
  20. package/dist/debug/debug-shader-layout.js +24 -25
  21. package/dist/debug/pixel-data-utils.d.ts.map +1 -1
  22. package/dist/debug/pixel-data-utils.js +34 -36
  23. package/dist/dist.dev.js +3873 -8643
  24. package/dist/geometries/cone-geometry.d.ts +1 -1
  25. package/dist/geometries/cone-geometry.d.ts.map +1 -1
  26. package/dist/geometries/cone-geometry.js +11 -17
  27. package/dist/geometries/cube-geometry.d.ts +1 -1
  28. package/dist/geometries/cube-geometry.d.ts.map +1 -1
  29. package/dist/geometries/cube-geometry.js +190 -61
  30. package/dist/geometries/cylinder-geometry.d.ts +1 -1
  31. package/dist/geometries/cylinder-geometry.d.ts.map +1 -1
  32. package/dist/geometries/cylinder-geometry.js +9 -14
  33. package/dist/geometries/ico-sphere-geometry.d.ts +1 -1
  34. package/dist/geometries/ico-sphere-geometry.d.ts.map +1 -1
  35. package/dist/geometries/ico-sphere-geometry.js +141 -160
  36. package/dist/geometries/plane-geometry.d.ts +1 -1
  37. package/dist/geometries/plane-geometry.d.ts.map +1 -1
  38. package/dist/geometries/plane-geometry.js +92 -110
  39. package/dist/geometries/sphere-geometry.d.ts +1 -1
  40. package/dist/geometries/sphere-geometry.d.ts.map +1 -1
  41. package/dist/geometries/sphere-geometry.js +76 -95
  42. package/dist/geometries/truncated-cone-geometry.d.ts +1 -1
  43. package/dist/geometries/truncated-cone-geometry.d.ts.map +1 -1
  44. package/dist/geometries/truncated-cone-geometry.js +99 -117
  45. package/dist/geometry/geometry-table.d.ts.map +1 -1
  46. package/dist/geometry/geometry-table.js +3 -1
  47. package/dist/geometry/geometry-utils.js +35 -32
  48. package/dist/geometry/geometry.d.ts.map +1 -1
  49. package/dist/geometry/geometry.js +80 -71
  50. package/dist/geometry/gpu-geometry.d.ts +1 -1
  51. package/dist/geometry/gpu-geometry.d.ts.map +1 -1
  52. package/dist/geometry/gpu-geometry.js +80 -99
  53. package/dist/geometry/gpu-table.js +41 -1
  54. package/dist/index.cjs +241 -206
  55. package/dist/index.cjs.map +7 -0
  56. package/dist/index.d.ts +41 -40
  57. package/dist/index.d.ts.map +1 -1
  58. package/dist/index.js +5 -1
  59. package/dist/lib/clip-space.d.ts +1 -1
  60. package/dist/lib/clip-space.d.ts.map +1 -1
  61. package/dist/lib/clip-space.js +23 -28
  62. package/dist/lib/pipeline-factory.d.ts +1 -5
  63. package/dist/lib/pipeline-factory.d.ts.map +1 -1
  64. package/dist/lib/pipeline-factory.js +64 -68
  65. package/dist/lib/shader-factory.d.ts +17 -0
  66. package/dist/lib/shader-factory.d.ts.map +1 -0
  67. package/dist/lib/shader-factory.js +44 -0
  68. package/dist/model/model.d.ts +22 -10
  69. package/dist/model/model.d.ts.map +1 -1
  70. package/dist/model/model.js +562 -410
  71. package/dist/scenegraph/group-node.d.ts +1 -1
  72. package/dist/scenegraph/group-node.d.ts.map +1 -1
  73. package/dist/scenegraph/group-node.js +73 -83
  74. package/dist/scenegraph/model-node.d.ts +2 -2
  75. package/dist/scenegraph/model-node.d.ts.map +1 -1
  76. package/dist/scenegraph/model-node.js +31 -24
  77. package/dist/scenegraph/scenegraph-node.d.ts.map +1 -1
  78. package/dist/scenegraph/scenegraph-node.js +136 -124
  79. package/dist/shader-inputs.d.ts.map +1 -1
  80. package/dist/shader-inputs.js +99 -58
  81. package/dist/transform/buffer-transform.d.ts +1 -1
  82. package/dist/transform/buffer-transform.d.ts.map +1 -1
  83. package/dist/transform/buffer-transform.js +65 -57
  84. package/dist/transform/texture-transform.d.ts +1 -1
  85. package/dist/transform/texture-transform.d.ts.map +1 -1
  86. package/dist/transform/texture-transform.js +109 -114
  87. package/dist.min.js +2 -272
  88. package/package.json +10 -9
  89. package/src/animation/timeline.ts +20 -20
  90. package/src/animation-loop/animation-loop-template.ts +10 -8
  91. package/src/animation-loop/animation-loop.ts +20 -10
  92. package/src/animation-loop/animation-props.ts +1 -1
  93. package/src/animation-loop/make-animation-loop.ts +17 -8
  94. package/src/debug/copy-texture-to-image.ts +8 -6
  95. package/src/debug/debug-framebuffer.ts +16 -3
  96. package/src/debug/debug-shader-layout.ts +1 -1
  97. package/src/debug/pixel-data-utils.ts +3 -6
  98. package/src/geometries/cube-geometry.ts +17 -13
  99. package/src/geometries/ico-sphere-geometry.ts +1 -1
  100. package/src/geometries/plane-geometry.ts +1 -1
  101. package/src/geometries/sphere-geometry.ts +1 -1
  102. package/src/geometries/truncated-cone-geometry.ts +2 -1
  103. package/src/geometry/geometry-table.ts +9 -6
  104. package/src/geometry/geometry-utils.ts +1 -1
  105. package/src/geometry/geometry.ts +9 -6
  106. package/src/geometry/gpu-geometry.ts +14 -6
  107. package/src/index.ts +1 -0
  108. package/src/lib/clip-space.ts +14 -18
  109. package/src/lib/pipeline-factory.ts +12 -22
  110. package/src/lib/shader-factory.ts +55 -0
  111. package/src/model/model.ts +74 -42
  112. package/src/scenegraph/group-node.ts +14 -10
  113. package/src/scenegraph/model-node.ts +2 -2
  114. package/src/scenegraph/scenegraph-node.ts +2 -2
  115. package/src/shader-inputs.ts +19 -12
  116. package/src/transform/buffer-transform.ts +16 -8
  117. package/src/transform/texture-transform.ts +14 -15
  118. package/dist/animation/key-frames.js.map +0 -1
  119. package/dist/animation/timeline.js.map +0 -1
  120. package/dist/animation-loop/animation-loop-template.js.map +0 -1
  121. package/dist/animation-loop/animation-loop.js.map +0 -1
  122. package/dist/animation-loop/animation-props.js.map +0 -1
  123. package/dist/animation-loop/make-animation-loop.js.map +0 -1
  124. package/dist/debug/copy-texture-to-image.js.map +0 -1
  125. package/dist/debug/debug-framebuffer.js.map +0 -1
  126. package/dist/debug/debug-shader-layout.js.map +0 -1
  127. package/dist/debug/pixel-data-utils.js.map +0 -1
  128. package/dist/geometries/cone-geometry.js.map +0 -1
  129. package/dist/geometries/cube-geometry.js.map +0 -1
  130. package/dist/geometries/cylinder-geometry.js.map +0 -1
  131. package/dist/geometries/ico-sphere-geometry.js.map +0 -1
  132. package/dist/geometries/plane-geometry.js.map +0 -1
  133. package/dist/geometries/sphere-geometry.js.map +0 -1
  134. package/dist/geometries/truncated-cone-geometry.js.map +0 -1
  135. package/dist/geometry/geometry-table.js.map +0 -1
  136. package/dist/geometry/geometry-utils.js.map +0 -1
  137. package/dist/geometry/geometry.js.map +0 -1
  138. package/dist/geometry/gpu-geometry.js.map +0 -1
  139. package/dist/geometry/gpu-table.js.map +0 -1
  140. package/dist/index.js.map +0 -1
  141. package/dist/lib/clip-space.js.map +0 -1
  142. package/dist/lib/pipeline-factory.js.map +0 -1
  143. package/dist/model/model.js.map +0 -1
  144. package/dist/scenegraph/group-node.js.map +0 -1
  145. package/dist/scenegraph/model-node.js.map +0 -1
  146. package/dist/scenegraph/scenegraph-node.js.map +0 -1
  147. package/dist/shader-inputs.js.map +0 -1
  148. package/dist/transform/buffer-transform.js.map +0 -1
  149. package/dist/transform/texture-transform.js.map +0 -1
@@ -1,56 +1,56 @@
1
+ /** Holds a list of key frames (timestamped values) */
1
2
  export class KeyFrames {
2
- constructor(keyFrames) {
3
- this.startIndex = -1;
4
- this.endIndex = -1;
5
- this.factor = 0;
6
- this.times = [];
7
- this.values = [];
8
- this._lastTime = -1;
9
- this.setKeyFrames(keyFrames);
10
- this.setTime(0);
11
- }
12
- setKeyFrames(keyFrames) {
13
- const numKeys = keyFrames.length;
14
- this.times.length = numKeys;
15
- this.values.length = numKeys;
16
- for (let i = 0; i < numKeys; ++i) {
17
- this.times[i] = keyFrames[i][0];
18
- this.values[i] = keyFrames[i][1];
19
- }
20
- this._calculateKeys(this._lastTime);
21
- }
22
- setTime(time) {
23
- time = Math.max(0, time);
24
- if (time !== this._lastTime) {
25
- this._calculateKeys(time);
26
- this._lastTime = time;
27
- }
28
- }
29
- getStartTime() {
30
- return this.times[this.startIndex];
31
- }
32
- getEndTime() {
33
- return this.times[this.endIndex];
34
- }
35
- getStartData() {
36
- return this.values[this.startIndex];
37
- }
38
- getEndData() {
39
- return this.values[this.endIndex];
40
- }
41
- _calculateKeys(time) {
42
- let index = 0;
43
- const numKeys = this.times.length;
44
- for (index = 0; index < numKeys - 2; ++index) {
45
- if (this.times[index + 1] > time) {
46
- break;
47
- }
48
- }
49
- this.startIndex = index;
50
- this.endIndex = index + 1;
51
- const startTime = this.times[this.startIndex];
52
- const endTime = this.times[this.endIndex];
53
- this.factor = Math.min(Math.max(0, (time - startTime) / (endTime - startTime)), 1);
54
- }
3
+ startIndex = -1;
4
+ endIndex = -1;
5
+ factor = 0;
6
+ times = [];
7
+ values = [];
8
+ _lastTime = -1;
9
+ constructor(keyFrames) {
10
+ this.setKeyFrames(keyFrames);
11
+ this.setTime(0);
12
+ }
13
+ setKeyFrames(keyFrames) {
14
+ const numKeys = keyFrames.length;
15
+ this.times.length = numKeys;
16
+ this.values.length = numKeys;
17
+ for (let i = 0; i < numKeys; ++i) {
18
+ this.times[i] = keyFrames[i][0];
19
+ this.values[i] = keyFrames[i][1];
20
+ }
21
+ this._calculateKeys(this._lastTime);
22
+ }
23
+ setTime(time) {
24
+ time = Math.max(0, time);
25
+ if (time !== this._lastTime) {
26
+ this._calculateKeys(time);
27
+ this._lastTime = time;
28
+ }
29
+ }
30
+ getStartTime() {
31
+ return this.times[this.startIndex];
32
+ }
33
+ getEndTime() {
34
+ return this.times[this.endIndex];
35
+ }
36
+ getStartData() {
37
+ return this.values[this.startIndex];
38
+ }
39
+ getEndData() {
40
+ return this.values[this.endIndex];
41
+ }
42
+ _calculateKeys(time) {
43
+ let index = 0;
44
+ const numKeys = this.times.length;
45
+ for (index = 0; index < numKeys - 2; ++index) {
46
+ if (this.times[index + 1] > time) {
47
+ break;
48
+ }
49
+ }
50
+ this.startIndex = index;
51
+ this.endIndex = index + 1;
52
+ const startTime = this.times[this.startIndex];
53
+ const endTime = this.times[this.endIndex];
54
+ this.factor = Math.min(Math.max(0, (time - startTime) / (endTime - startTime)), 1);
55
+ }
55
56
  }
56
- //# sourceMappingURL=key-frames.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"timeline.d.ts","sourceRoot":"","sources":["../../src/animation/timeline.ts"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,MAAM,MAAM,gBAAgB,GAAG;IAC7B,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;CAChC,CAAA;AAEA,KAAK,OAAO,GAAG;IACd,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,MAAM,CAAA;IA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 // luma.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
1
4
  let channelHandles = 1;
2
5
  let animationHandles = 1;
3
6
  export class Timeline {
4
- constructor() {
5
- this.time = 0;
6
- this.channels = new Map();
7
- this.animations = new Map();
8
- this.playing = false;
9
- this.lastEngineTime = -1;
10
- }
11
- addChannel(props) {
12
- const {
13
- delay = 0,
14
- duration = Number.POSITIVE_INFINITY,
15
- rate = 1,
16
- repeat = 1
17
- } = props;
18
- const channelId = channelHandles++;
19
- const channel = {
20
- time: 0,
21
- delay,
22
- duration,
23
- rate,
24
- repeat
25
- };
26
- this._setChannelTime(channel, this.time);
27
- this.channels.set(channelId, channel);
28
- return channelId;
29
- }
30
- removeChannel(channelId) {
31
- this.channels.delete(channelId);
32
- for (const [animationHandle, animation] of this.animations) {
33
- if (animation.channel === channelId) {
34
- this.detachAnimation(animationHandle);
35
- }
7
+ time = 0;
8
+ channels = new Map();
9
+ animations = new Map();
10
+ playing = false;
11
+ lastEngineTime = -1;
12
+ constructor() { }
13
+ addChannel(props) {
14
+ const { delay = 0, duration = Number.POSITIVE_INFINITY, rate = 1, repeat = 1 } = props;
15
+ const channelId = channelHandles++;
16
+ const channel = {
17
+ time: 0,
18
+ delay,
19
+ duration,
20
+ rate,
21
+ repeat
22
+ };
23
+ this._setChannelTime(channel, this.time);
24
+ this.channels.set(channelId, channel);
25
+ return channelId;
36
26
  }
37
- }
38
- isFinished(channelId) {
39
- const channel = this.channels.get(channelId);
40
- if (channel === undefined) {
41
- return false;
27
+ removeChannel(channelId) {
28
+ this.channels.delete(channelId);
29
+ for (const [animationHandle, animation] of this.animations) {
30
+ if (animation.channel === channelId) {
31
+ this.detachAnimation(animationHandle);
32
+ }
33
+ }
42
34
  }
43
- return this.time >= channel.delay + channel.duration * channel.repeat;
44
- }
45
- getTime(channelId) {
46
- if (channelId === undefined) {
47
- return this.time;
35
+ isFinished(channelId) {
36
+ const channel = this.channels.get(channelId);
37
+ if (channel === undefined) {
38
+ return false;
39
+ }
40
+ return this.time >= channel.delay + channel.duration * channel.repeat;
48
41
  }
49
- const channel = this.channels.get(channelId);
50
- if (channel === undefined) {
51
- return -1;
42
+ getTime(channelId) {
43
+ if (channelId === undefined) {
44
+ return this.time;
45
+ }
46
+ const channel = this.channels.get(channelId);
47
+ if (channel === undefined) {
48
+ return -1;
49
+ }
50
+ return channel.time;
52
51
  }
53
- return channel.time;
54
- }
55
- setTime(time) {
56
- this.time = Math.max(0, time);
57
- const channels = this.channels.values();
58
- for (const channel of channels) {
59
- this._setChannelTime(channel, this.time);
52
+ setTime(time) {
53
+ this.time = Math.max(0, time);
54
+ const channels = this.channels.values();
55
+ for (const channel of channels) {
56
+ this._setChannelTime(channel, this.time);
57
+ }
58
+ const animations = this.animations.values();
59
+ for (const animationData of animations) {
60
+ const { animation, channel } = animationData;
61
+ animation.setTime(this.getTime(channel));
62
+ }
60
63
  }
61
- const animations = this.animations.values();
62
- for (const animationData of animations) {
63
- const {
64
- animation,
65
- channel
66
- } = animationData;
67
- animation.setTime(this.getTime(channel));
64
+ play() {
65
+ this.playing = true;
68
66
  }
69
- }
70
- play() {
71
- this.playing = true;
72
- }
73
- pause() {
74
- this.playing = false;
75
- this.lastEngineTime = -1;
76
- }
77
- reset() {
78
- this.setTime(0);
79
- }
80
- attachAnimation(animation, channelHandle) {
81
- const animationHandle = animationHandles++;
82
- this.animations.set(animationHandle, {
83
- animation,
84
- channel: channelHandle
85
- });
86
- animation.setTime(this.getTime(channelHandle));
87
- return animationHandle;
88
- }
89
- detachAnimation(channelId) {
90
- this.animations.delete(channelId);
91
- }
92
- update(engineTime) {
93
- if (this.playing) {
94
- if (this.lastEngineTime === -1) {
95
- this.lastEngineTime = engineTime;
96
- }
97
- this.setTime(this.time + (engineTime - this.lastEngineTime));
98
- this.lastEngineTime = engineTime;
67
+ pause() {
68
+ this.playing = false;
69
+ this.lastEngineTime = -1;
99
70
  }
100
- }
101
- _setChannelTime(channel, time) {
102
- const offsetTime = time - channel.delay;
103
- const totalDuration = channel.duration * channel.repeat;
104
- if (offsetTime >= totalDuration) {
105
- channel.time = channel.duration * channel.rate;
106
- } else {
107
- channel.time = Math.max(0, offsetTime) % channel.duration;
108
- channel.time *= channel.rate;
71
+ reset() {
72
+ this.setTime(0);
73
+ }
74
+ attachAnimation(animation, channelHandle) {
75
+ const animationHandle = animationHandles++;
76
+ this.animations.set(animationHandle, {
77
+ animation,
78
+ channel: channelHandle
79
+ });
80
+ animation.setTime(this.getTime(channelHandle));
81
+ return animationHandle;
82
+ }
83
+ detachAnimation(channelId) {
84
+ this.animations.delete(channelId);
85
+ }
86
+ update(engineTime) {
87
+ if (this.playing) {
88
+ if (this.lastEngineTime === -1) {
89
+ this.lastEngineTime = engineTime;
90
+ }
91
+ this.setTime(this.time + (engineTime - this.lastEngineTime));
92
+ this.lastEngineTime = engineTime;
93
+ }
94
+ }
95
+ _setChannelTime(channel, time) {
96
+ const offsetTime = time - channel.delay;
97
+ const totalDuration = channel.duration * channel.repeat;
98
+ // Note(Tarek): Don't loop on final repeat.
99
+ if (offsetTime >= totalDuration) {
100
+ channel.time = channel.duration * channel.rate;
101
+ }
102
+ else {
103
+ channel.time = Math.max(0, offsetTime) % channel.duration;
104
+ channel.time *= channel.rate;
105
+ }
109
106
  }
110
- }
111
107
  }
112
- //# sourceMappingURL=timeline.js.map
@@ -1,4 +1,4 @@
1
- import type { AnimationProps } from './animation-props';
1
+ import type { AnimationProps } from "./animation-props.js";
2
2
  /**
3
3
  * Minimal class that represents a "componentized" rendering life cycle
4
4
  * (resource construction, repeated rendering, resource destruction)
@@ -1 +1 @@
1
- {"version":3,"file":"animation-loop-template.d.ts","sourceRoot":"","sources":["../../src/animation-loop/animation-loop-template.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,mBAAmB,CAAC;AAEtD;;;;;;;;;;;;;;GAcG;AACH,8BAAsB,qBAAqB;gBAC7B,cAAc,CAAC,EAAE,cAAc;IACrC,YAAY,CAAC,cAAc,EAAE,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC;IACpE,QAAQ,CAAC,QAAQ,CAAC,cAAc,EAAE,cAAc,GAAG,OAAO;IAC1D,QAAQ,CAAC,UAAU,CAAC,cAAc,EAAE,cAAc,GAAG,IAAI;CAC1D"}
1
+ {"version":3,"file":"animation-loop-template.d.ts","sourceRoot":"","sources":["../../src/animation-loop/animation-loop-template.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,cAAc,EAAC,6BAA0B;AAEtD;;;;;;;;;;;;;;GAcG;AACH,8BAAsB,qBAAqB;gBAC7B,cAAc,CAAC,EAAE,cAAc;IACrC,YAAY,CAAC,cAAc,EAAE,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC;IAGpE,QAAQ,CAAC,QAAQ,CAAC,cAAc,EAAE,cAAc,GAAG,OAAO;IAC1D,QAAQ,CAAC,UAAU,CAAC,cAAc,EAAE,cAAc,GAAG,IAAI;CAC1D"}
@@ -1,7 +1,21 @@
1
+ /**
2
+ * Minimal class that represents a "componentized" rendering life cycle
3
+ * (resource construction, repeated rendering, resource destruction)
4
+ *
5
+ * @note A motivation for this class compared to the raw animation loop is
6
+ * that it simplifies TypeScript code by allowing resources to be typed unconditionally
7
+ * since they are allocated in the constructor rather than in onInitialized
8
+ *
9
+ * @note Introduced in luma.gl v9
10
+ *
11
+ * @example AnimationLoopTemplate is intended to be subclassed,
12
+ * but the subclass should not be instantiated directly. Instead the subclass
13
+ * (i.e. the constructor of the subclass) should be used
14
+ * as an argument to create an AnimationLoop.
15
+ */
1
16
  export class AnimationLoopTemplate {
2
- constructor(animationProps) {}
3
- async onInitialize(animationProps) {
4
- return null;
5
- }
17
+ constructor(animationProps) { }
18
+ async onInitialize(animationProps) {
19
+ return null;
20
+ }
6
21
  }
7
- //# sourceMappingURL=animation-loop-template.js.map
@@ -1,6 +1,6 @@
1
1
  import { Device } from '@luma.gl/core';
2
- import { Timeline } from '../animation/timeline';
3
- import { AnimationProps } from './animation-props';
2
+ import { Timeline } from "../animation/timeline.js";
3
+ import { AnimationProps } from "./animation-props.js";
4
4
  import { Stats, Stat } from '@probe.gl/stats';
5
5
  /** AnimationLoop properties */
6
6
  export type AnimationLoopProps = {
@@ -1 +1 @@
1
- {"version":3,"file":"animation-loop.d.ts","sourceRoot":"","sources":["../../src/animation-loop/animation-loop.ts"],"names":[],"mappings":"AAGA,OAAO,EAAO,MAAM,EAAC,MAAM,eAAe,CAAC;AAE3C,OAAO,EAAC,QAAQ,EAAC,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAC,cAAc,EAAC,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAC,KAAK,EAAE,IAAI,EAAC,MAAM,iBAAiB,CAAC;AAI5C,+BAA+B;AAC/B,MAAM,MAAM,kBAAkB,GAAG;IAC/B,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAEjC,SAAS,CAAC,EAAE,CAAC,GAAG,EAAE,cAAc,KAAK,MAAM,CAAC;IAC5C,YAAY,CAAC,EAAE,CAAC,cAAc,EAAE,cAAc,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IACpE,QAAQ,CAAC,EAAE,CAAC,cAAc,EAAE,cAAc,KAAK,OAAO,CAAC;IACvD,UAAU,CAAC,EAAE,CAAC,cAAc,EAAE,cAAc,KAAK,IAAI,CAAC;IACtD,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,KAAK,KAAK,IAAI,CAAC;IAElC,KAAK,CAAC,EAAE,KAAK,CAAC;IAGd,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,eAAe,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CACpC,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG;IAEtC,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,eAA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