@luma.gl/engine 9.0.0-alpha.9 → 9.0.0-beta.10

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 (187) hide show
  1. package/LICENSE +3 -1
  2. package/dist/animation/key-frames.d.ts +1 -1
  3. package/dist/animation/key-frames.d.ts.map +1 -1
  4. package/dist/animation/key-frames.js +51 -72
  5. package/dist/animation/timeline.d.ts +8 -8
  6. package/dist/animation/timeline.d.ts.map +1 -1
  7. package/dist/animation/timeline.js +95 -131
  8. package/dist/animation-loop/animation-loop-template.d.ts +23 -0
  9. package/dist/animation-loop/animation-loop-template.d.ts.map +1 -0
  10. package/dist/animation-loop/animation-loop-template.js +21 -0
  11. package/dist/{lib → animation-loop}/animation-loop.d.ts +31 -23
  12. package/dist/animation-loop/animation-loop.d.ts.map +1 -0
  13. package/dist/animation-loop/animation-loop.js +442 -0
  14. package/dist/{lib → animation-loop}/animation-props.d.ts +4 -5
  15. package/dist/animation-loop/animation-props.d.ts.map +1 -0
  16. package/dist/animation-loop/animation-props.js +1 -0
  17. package/dist/animation-loop/make-animation-loop.d.ts +6 -0
  18. package/dist/animation-loop/make-animation-loop.d.ts.map +1 -0
  19. package/dist/animation-loop/make-animation-loop.js +32 -0
  20. package/dist/computation.d.ts +95 -0
  21. package/dist/computation.d.ts.map +1 -0
  22. package/dist/computation.js +248 -0
  23. package/dist/debug/copy-texture-to-image.d.ts +26 -0
  24. package/dist/debug/copy-texture-to-image.d.ts.map +1 -0
  25. package/dist/debug/copy-texture-to-image.js +43 -0
  26. package/dist/debug/debug-framebuffer.d.ts +11 -0
  27. package/dist/debug/debug-framebuffer.d.ts.map +1 -0
  28. package/dist/debug/debug-framebuffer.js +46 -0
  29. package/dist/debug/debug-shader-layout.d.ts +9 -0
  30. package/dist/debug/debug-shader-layout.d.ts.map +1 -0
  31. package/dist/debug/debug-shader-layout.js +27 -0
  32. package/dist/debug/pixel-data-utils.d.ts +24 -0
  33. package/dist/debug/pixel-data-utils.d.ts.map +1 -0
  34. package/dist/debug/pixel-data-utils.js +39 -0
  35. package/dist/dist.dev.js +9592 -0
  36. package/dist/dist.min.js +102 -0
  37. package/dist/geometries/cone-geometry.d.ts +2 -2
  38. package/dist/geometries/cone-geometry.d.ts.map +1 -1
  39. package/dist/geometries/cone-geometry.js +13 -18
  40. package/dist/geometries/cube-geometry.d.ts +2 -2
  41. package/dist/geometries/cube-geometry.d.ts.map +1 -1
  42. package/dist/geometries/cube-geometry.js +192 -57
  43. package/dist/geometries/cylinder-geometry.d.ts +2 -2
  44. package/dist/geometries/cylinder-geometry.d.ts.map +1 -1
  45. package/dist/geometries/cylinder-geometry.js +11 -15
  46. package/dist/geometries/ico-sphere-geometry.d.ts +2 -2
  47. package/dist/geometries/ico-sphere-geometry.d.ts.map +1 -1
  48. package/dist/geometries/ico-sphere-geometry.js +143 -171
  49. package/dist/geometries/plane-geometry.d.ts +2 -2
  50. package/dist/geometries/plane-geometry.d.ts.map +1 -1
  51. package/dist/geometries/plane-geometry.js +95 -122
  52. package/dist/geometries/sphere-geometry.d.ts +2 -2
  53. package/dist/geometries/sphere-geometry.d.ts.map +1 -1
  54. package/dist/geometries/sphere-geometry.js +78 -101
  55. package/dist/geometries/truncated-cone-geometry.d.ts +2 -4
  56. package/dist/geometries/truncated-cone-geometry.d.ts.map +1 -1
  57. package/dist/geometries/truncated-cone-geometry.js +100 -134
  58. package/dist/geometry/geometry-table.d.ts +2 -2
  59. package/dist/geometry/geometry-table.d.ts.map +1 -1
  60. package/dist/geometry/geometry-table.js +3 -1
  61. package/dist/geometry/geometry-utils.d.ts.map +1 -1
  62. package/dist/geometry/geometry-utils.js +35 -41
  63. package/dist/geometry/geometry.d.ts +43 -43
  64. package/dist/geometry/geometry.d.ts.map +1 -1
  65. package/dist/geometry/geometry.js +82 -139
  66. package/dist/geometry/gpu-geometry.d.ts +37 -0
  67. package/dist/geometry/gpu-geometry.d.ts.map +1 -0
  68. package/dist/geometry/gpu-geometry.js +90 -0
  69. package/dist/geometry/gpu-table.d.ts +1 -0
  70. package/dist/geometry/gpu-table.d.ts.map +1 -0
  71. package/dist/geometry/gpu-table.js +42 -0
  72. package/dist/index.cjs +3444 -0
  73. package/dist/index.cjs.map +7 -0
  74. package/dist/index.d.ts +43 -24
  75. package/dist/index.d.ts.map +1 -1
  76. package/dist/index.js +29 -15
  77. package/dist/lib/clip-space.d.ts +8 -0
  78. package/dist/lib/clip-space.d.ts.map +1 -1
  79. package/dist/lib/clip-space.js +43 -2
  80. package/dist/lib/pipeline-factory.d.ts +17 -51
  81. package/dist/lib/pipeline-factory.d.ts.map +1 -1
  82. package/dist/lib/pipeline-factory.js +84 -209
  83. package/dist/lib/shader-factory.d.ts +17 -0
  84. package/dist/lib/shader-factory.d.ts.map +1 -0
  85. package/dist/lib/shader-factory.js +46 -0
  86. package/dist/model/model.d.ts +219 -0
  87. package/dist/model/model.d.ts.map +1 -0
  88. package/dist/model/model.js +659 -0
  89. package/dist/scenegraph/group-node.d.ts +21 -0
  90. package/dist/scenegraph/group-node.d.ts.map +1 -0
  91. package/dist/scenegraph/group-node.js +84 -0
  92. package/dist/scenegraph/model-node.d.ts +18 -0
  93. package/dist/scenegraph/model-node.d.ts.map +1 -0
  94. package/dist/scenegraph/model-node.js +35 -0
  95. package/dist/scenegraph/scenegraph-node.d.ts +56 -0
  96. package/dist/scenegraph/scenegraph-node.d.ts.map +1 -0
  97. package/dist/scenegraph/scenegraph-node.js +153 -0
  98. package/dist/shader-inputs.d.ts +63 -0
  99. package/dist/shader-inputs.d.ts.map +1 -0
  100. package/dist/shader-inputs.js +107 -0
  101. package/dist/transform/buffer-transform.d.ts +35 -0
  102. package/dist/transform/buffer-transform.d.ts.map +1 -0
  103. package/dist/transform/buffer-transform.js +70 -0
  104. package/dist/transform/texture-transform.d.ts +57 -0
  105. package/dist/transform/texture-transform.d.ts.map +1 -0
  106. package/dist/transform/texture-transform.js +117 -0
  107. package/dist.min.js +25 -0
  108. package/package.json +24 -14
  109. package/src/animation/timeline.ts +35 -34
  110. package/src/animation-loop/animation-loop-template.ts +25 -0
  111. package/src/{lib → animation-loop}/animation-loop.ts +114 -93
  112. package/src/{lib → animation-loop}/animation-props.ts +2 -2
  113. package/src/animation-loop/make-animation-loop.ts +53 -0
  114. package/src/computation.ts +346 -0
  115. package/src/debug/copy-texture-to-image.ts +70 -0
  116. package/src/debug/debug-framebuffer.ts +70 -0
  117. package/src/debug/debug-shader-layout.ts +38 -0
  118. package/src/debug/pixel-data-utils.ts +54 -0
  119. package/src/geometries/cone-geometry.ts +1 -1
  120. package/src/geometries/cube-geometry.ts +62 -56
  121. package/src/geometries/cylinder-geometry.ts +2 -2
  122. package/src/geometries/ico-sphere-geometry.ts +6 -5
  123. package/src/geometries/plane-geometry.ts +5 -4
  124. package/src/geometries/sphere-geometry.ts +4 -3
  125. package/src/geometries/truncated-cone-geometry.ts +6 -14
  126. package/src/geometry/geometry-table.ts +10 -7
  127. package/src/geometry/geometry-utils.ts +19 -3
  128. package/src/geometry/geometry.ts +68 -110
  129. package/src/geometry/gpu-geometry.ts +132 -0
  130. package/src/geometry/gpu-table.ts +41 -0
  131. package/src/index.ts +37 -10
  132. package/src/lib/clip-space.ts +32 -34
  133. package/src/lib/pipeline-factory.ts +83 -193
  134. package/src/lib/shader-factory.ts +57 -0
  135. package/src/model/model.ts +835 -0
  136. package/src/scenegraph/group-node.ts +107 -0
  137. package/src/scenegraph/model-node.ts +50 -0
  138. package/src/scenegraph/scenegraph-node.ts +204 -0
  139. package/src/shader-inputs.ts +157 -0
  140. package/src/transform/buffer-transform.ts +102 -0
  141. package/src/transform/texture-transform.ts +168 -0
  142. package/dist/animation/key-frames.js.map +0 -1
  143. package/dist/animation/timeline.js.map +0 -1
  144. package/dist/bundle.d.ts +0 -2
  145. package/dist/bundle.d.ts.map +0 -1
  146. package/dist/bundle.js +0 -5
  147. package/dist/bundle.js.map +0 -1
  148. package/dist/geometries/cone-geometry.js.map +0 -1
  149. package/dist/geometries/cube-geometry.js.map +0 -1
  150. package/dist/geometries/cylinder-geometry.js.map +0 -1
  151. package/dist/geometries/ico-sphere-geometry.js.map +0 -1
  152. package/dist/geometries/plane-geometry.js.map +0 -1
  153. package/dist/geometries/sphere-geometry.js.map +0 -1
  154. package/dist/geometries/truncated-cone-geometry.js.map +0 -1
  155. package/dist/geometry/geometry-table.js.map +0 -1
  156. package/dist/geometry/geometry-utils.js.map +0 -1
  157. package/dist/geometry/geometry.js.map +0 -1
  158. package/dist/geometry/primitive-utils.d.ts +0 -1
  159. package/dist/geometry/primitive-utils.d.ts.map +0 -1
  160. package/dist/geometry/primitive-utils.js +0 -2
  161. package/dist/geometry/primitive-utils.js.map +0 -1
  162. package/dist/index.js.map +0 -1
  163. package/dist/lib/animation-loop.d.ts.map +0 -1
  164. package/dist/lib/animation-loop.js +0 -480
  165. package/dist/lib/animation-loop.js.map +0 -1
  166. package/dist/lib/animation-props.d.ts.map +0 -1
  167. package/dist/lib/animation-props.js +0 -2
  168. package/dist/lib/animation-props.js.map +0 -1
  169. package/dist/lib/clip-space.js.map +0 -1
  170. package/dist/lib/model-utils.d.ts +0 -5
  171. package/dist/lib/model-utils.d.ts.map +0 -1
  172. package/dist/lib/model-utils.js +0 -45
  173. package/dist/lib/model-utils.js.map +0 -1
  174. package/dist/lib/model.d.ts +0 -41
  175. package/dist/lib/model.d.ts.map +0 -1
  176. package/dist/lib/model.js +0 -182
  177. package/dist/lib/model.js.map +0 -1
  178. package/dist/lib/pipeline-factory.js.map +0 -1
  179. package/dist/lib/render-loop.d.ts +0 -14
  180. package/dist/lib/render-loop.d.ts.map +0 -1
  181. package/dist/lib/render-loop.js +0 -49
  182. package/dist/lib/render-loop.js.map +0 -1
  183. package/src/bundle.ts +0 -4
  184. package/src/geometry/primitive-utils.ts +0 -30
  185. package/src/lib/model-utils.ts +0 -124
  186. package/src/lib/model.ts +0 -183
  187. package/src/lib/render-loop.ts +0 -58
package/LICENSE CHANGED
@@ -1,4 +1,6 @@
1
- Copyright (c) 2020 Urban Computing Foundation
1
+ luma.gl is provided under the MIT license
2
+
3
+ Copyright (c) 2020 vis.gl contributors
2
4
 
3
5
  This software includes parts initially developed by Uber and open sourced under MIT license.
4
6
  Copyright (c) 2015 Uber Technologies, Inc.
@@ -1,4 +1,4 @@
1
- export declare type KeyFrame<T> = [number, T];
1
+ export type KeyFrame<T> = [number, T];
2
2
  /** Holds a list of key frames (timestamped values) */
3
3
  export declare class KeyFrames<T = number> {
4
4
  startIndex: number;
@@ -1 +1 @@
1
- {"version":3,"file":"key-frames.d.ts","sourceRoot":"","sources":["../../src/animation/key-frames.ts"],"names":[],"mappings":"AACA,oBAAY,QAAQ,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;AAEtC,sDAAsD;AACtD,qBAAa,SAAS,CAAC,CAAC,GAAG,MAAM;IAC/B,UAAU,EAAE,MAAM,CAAM;IACxB,QAAQ,EAAE,MAAM,CAAM;IACtB,MAAM,EAAE,MAAM,CAAK;IACnB,KAAK,EAAE,MAAM,EAAE,CAAM;IACrB,MAAM,EAAE,CAAC,EAAE,CAAM;IACjB,OAAO,CAAC,SAAS,CAAM;gBAEX,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE;IAKpC,YAAY,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI;IAa5C,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAS3B,YAAY,IAAI,MAAM;IAItB,UAAU,IAAI,MAAM;IAIpB,YAAY,IAAI,CAAC;IAIjB,UAAU,IAAI,CAAC;IAIf,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;CAiBnC"}
1
+ {"version":3,"file":"key-frames.d.ts","sourceRoot":"","sources":["../../src/animation/key-frames.ts"],"names":[],"mappings":"AACA,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;AAEtC,sDAAsD;AACtD,qBAAa,SAAS,CAAC,CAAC,GAAG,MAAM;IAC/B,UAAU,EAAE,MAAM,CAAM;IACxB,QAAQ,EAAE,MAAM,CAAM;IACtB,MAAM,EAAE,MAAM,CAAK;IACnB,KAAK,EAAE,MAAM,EAAE,CAAM;IACrB,MAAM,EAAE,CAAC,EAAE,CAAM;IACjB,OAAO,CAAC,SAAS,CAAM;gBAEX,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE;IAKpC,YAAY,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI;IAa5C,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAS3B,YAAY,IAAI,MAAM;IAItB,UAAU,IAAI,MAAM;IAIpB,YAAY,IAAI,CAAC;IAIjB,UAAU,IAAI,CAAC;IAIf,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;CAiBnC"}
@@ -1,77 +1,56 @@
1
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
1
+ /** Holds a list of key frames (timestamped values) */
2
2
  export class KeyFrames {
3
- constructor(keyFrames) {
4
- _defineProperty(this, "startIndex", -1);
5
-
6
- _defineProperty(this, "endIndex", -1);
7
-
8
- _defineProperty(this, "factor", 0);
9
-
10
- _defineProperty(this, "times", []);
11
-
12
- _defineProperty(this, "values", []);
13
-
14
- _defineProperty(this, "_lastTime", -1);
15
-
16
- this.setKeyFrames(keyFrames);
17
- this.setTime(0);
18
- }
19
-
20
- setKeyFrames(keyFrames) {
21
- const numKeys = keyFrames.length;
22
- this.times.length = numKeys;
23
- this.values.length = numKeys;
24
-
25
- for (let i = 0; i < numKeys; ++i) {
26
- this.times[i] = keyFrames[i][0];
27
- this.values[i] = keyFrames[i][1];
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);
28
12
  }
29
-
30
- this._calculateKeys(this._lastTime);
31
- }
32
-
33
- setTime(time) {
34
- time = Math.max(0, time);
35
-
36
- if (time !== this._lastTime) {
37
- this._calculateKeys(time);
38
-
39
- this._lastTime = time;
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);
40
22
  }
41
- }
42
-
43
- getStartTime() {
44
- return this.times[this.startIndex];
45
- }
46
-
47
- getEndTime() {
48
- return this.times[this.endIndex];
49
- }
50
-
51
- getStartData() {
52
- return this.values[this.startIndex];
53
- }
54
-
55
- getEndData() {
56
- return this.values[this.endIndex];
57
- }
58
-
59
- _calculateKeys(time) {
60
- let index = 0;
61
- const numKeys = this.times.length;
62
-
63
- for (index = 0; index < numKeys - 2; ++index) {
64
- if (this.times[index + 1] > time) {
65
- break;
66
- }
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);
67
55
  }
68
-
69
- this.startIndex = index;
70
- this.endIndex = index + 1;
71
- const startTime = this.times[this.startIndex];
72
- const endTime = this.times[this.endIndex];
73
- this.factor = Math.min(Math.max(0, (time - startTime) / (endTime - startTime)), 1);
74
- }
75
-
76
56
  }
77
- //# sourceMappingURL=key-frames.js.map
@@ -5,23 +5,23 @@
5
5
  * @param rate = 1
6
6
  * @param repeat = 1
7
7
  */
8
- export declare type ChannelOptions = {
8
+ export type ChannelOptions = {
9
9
  delay?: number;
10
10
  duration?: number;
11
11
  rate?: number;
12
12
  repeat?: number;
13
13
  };
14
- export declare type AnimationOptions = {
14
+ export type AnimationOptions = {
15
15
  setTime: (time: number) => void;
16
16
  };
17
- declare type Channel = {
17
+ type Channel = {
18
18
  time: number;
19
19
  delay: number;
20
20
  duration: number;
21
21
  rate: number;
22
22
  repeat: number;
23
23
  };
24
- declare type Animation = {
24
+ type Animation = {
25
25
  channel?: number;
26
26
  animation: {
27
27
  setTime: (time: number) => void;
@@ -35,15 +35,15 @@ export declare class Timeline {
35
35
  lastEngineTime: number;
36
36
  constructor();
37
37
  addChannel(props: ChannelOptions): number;
38
- removeChannel(handle: number): void;
39
- isFinished(handle: number): boolean;
40
- getTime(handle?: number): number;
38
+ removeChannel(channelId: number): void;
39
+ isFinished(channelId: number): boolean;
40
+ getTime(channelId?: number): number;
41
41
  setTime(time: number): void;
42
42
  play(): void;
43
43
  pause(): void;
44
44
  reset(): void;
45
45
  attachAnimation(animation: AnimationOptions, channelHandle?: number): number;
46
- detachAnimation(handle: number): void;
46
+ detachAnimation(channelId: number): void;
47
47
  update(engineTime: number): void;
48
48
  _setChannelTime(channel: Channel, time: number): void;
49
49
  }
@@ -1 +1 @@
1
- {"version":3,"file":"timeline.d.ts","sourceRoot":"","sources":["../../src/animation/timeline.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACF,oBAAY,cAAc,GAAG;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,IAAI,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IAIb,eAAe,CAAC,SAAS,EAAE,gBAAgB,EAAE,aAAa,CAAC,EAAE,MAAM,GAAG,MAAM;IAa5E,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAIxC,MAAM,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAUhC,eAAe,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI;CAWtD"}
@@ -1,143 +1,107 @@
1
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
1
+ // luma.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
2
4
  let channelHandles = 1;
3
5
  let animationHandles = 1;
4
6
  export class Timeline {
5
- constructor() {
6
- _defineProperty(this, "time", 0);
7
-
8
- _defineProperty(this, "channels", new Map());
9
-
10
- _defineProperty(this, "animations", new Map());
11
-
12
- _defineProperty(this, "playing", false);
13
-
14
- _defineProperty(this, "lastEngineTime", -1);
15
- }
16
-
17
- addChannel(props) {
18
- const {
19
- delay = 0,
20
- duration = Number.POSITIVE_INFINITY,
21
- rate = 1,
22
- repeat = 1
23
- } = props;
24
- const handle = channelHandles++;
25
- const channel = {
26
- time: 0,
27
- delay,
28
- duration,
29
- rate,
30
- repeat
31
- };
32
-
33
- this._setChannelTime(channel, this.time);
34
-
35
- this.channels.set(handle, channel);
36
- return handle;
37
- }
38
-
39
- removeChannel(handle) {
40
- this.channels.delete(handle);
41
-
42
- for (const [animationHandle, animation] of this.animations) {
43
- if (animation.channel === handle) {
44
- this.detachAnimation(animationHandle);
45
- }
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;
46
26
  }
47
- }
48
-
49
- isFinished(handle) {
50
- const channel = this.channels.get(handle);
51
-
52
- if (channel === undefined) {
53
- 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
+ }
54
34
  }
55
-
56
- return this.time >= channel.delay + channel.duration * channel.repeat;
57
- }
58
-
59
- getTime(handle) {
60
- if (handle === undefined) {
61
- 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;
62
41
  }
63
-
64
- const channel = this.channels.get(handle);
65
-
66
- if (channel === undefined) {
67
- 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;
68
51
  }
69
-
70
- return channel.time;
71
- }
72
-
73
- setTime(time) {
74
- this.time = Math.max(0, time);
75
- const channels = this.channels.values();
76
-
77
- for (const channel of channels) {
78
- 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
+ }
79
63
  }
80
-
81
- const animations = this.animations.values();
82
-
83
- for (const animationData of animations) {
84
- const {
85
- animation,
86
- channel
87
- } = animationData;
88
- animation.setTime(this.getTime(channel));
64
+ play() {
65
+ this.playing = true;
89
66
  }
90
- }
91
-
92
- play() {
93
- this.playing = true;
94
- }
95
-
96
- pause() {
97
- this.playing = false;
98
- this.lastEngineTime = -1;
99
- }
100
-
101
- reset() {
102
- this.setTime(0);
103
- }
104
-
105
- attachAnimation(animation, channelHandle) {
106
- const animationHandle = animationHandles++;
107
- this.animations.set(animationHandle, {
108
- animation,
109
- channel: channelHandle
110
- });
111
- animation.setTime(this.getTime(channelHandle));
112
- return animationHandle;
113
- }
114
-
115
- detachAnimation(handle) {
116
- this.animations.delete(handle);
117
- }
118
-
119
- update(engineTime) {
120
- if (this.playing) {
121
- if (this.lastEngineTime === -1) {
122
- this.lastEngineTime = engineTime;
123
- }
124
-
125
- this.setTime(this.time + (engineTime - this.lastEngineTime));
126
- this.lastEngineTime = engineTime;
67
+ pause() {
68
+ this.playing = false;
69
+ this.lastEngineTime = -1;
127
70
  }
128
- }
129
-
130
- _setChannelTime(channel, time) {
131
- const offsetTime = time - channel.delay;
132
- const totalDuration = channel.duration * channel.repeat;
133
-
134
- if (offsetTime >= totalDuration) {
135
- channel.time = channel.duration * channel.rate;
136
- } else {
137
- channel.time = Math.max(0, offsetTime) % channel.duration;
138
- 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
+ }
139
106
  }
140
- }
141
-
142
107
  }
143
- //# sourceMappingURL=timeline.js.map
@@ -0,0 +1,23 @@
1
+ import type { AnimationProps } from "./animation-props.js";
2
+ /**
3
+ * Minimal class that represents a "componentized" rendering life cycle
4
+ * (resource construction, repeated rendering, resource destruction)
5
+ *
6
+ * @note A motivation for this class compared to the raw animation loop is
7
+ * that it simplifies TypeScript code by allowing resources to be typed unconditionally
8
+ * since they are allocated in the constructor rather than in onInitialized
9
+ *
10
+ * @note Introduced in luma.gl v9
11
+ *
12
+ * @example AnimationLoopTemplate is intended to be subclassed,
13
+ * but the subclass should not be instantiated directly. Instead the subclass
14
+ * (i.e. the constructor of the subclass) should be used
15
+ * as an argument to create an AnimationLoop.
16
+ */
17
+ export declare abstract class AnimationLoopTemplate {
18
+ constructor(animationProps?: AnimationProps);
19
+ onInitialize(animationProps: AnimationProps): Promise<unknown>;
20
+ abstract onRender(animationProps: AnimationProps): unknown;
21
+ abstract onFinalize(animationProps: AnimationProps): void;
22
+ }
23
+ //# sourceMappingURL=animation-loop-template.d.ts.map
@@ -0,0 +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,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"}
@@ -0,0 +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
+ */
16
+ export class AnimationLoopTemplate {
17
+ constructor(animationProps) { }
18
+ async onInitialize(animationProps) {
19
+ return null;
20
+ }
21
+ }
@@ -1,20 +1,21 @@
1
- /// <reference types="offscreencanvas" />
2
- import { Device, DeviceProps } from '@luma.gl/api';
3
- import { Timeline } from '../animation/timeline';
4
- import { AnimationProps } from '../lib/animation-props';
1
+ import { Device } from '@luma.gl/core';
2
+ import { Timeline } from "../animation/timeline.js";
3
+ import { AnimationProps } from "./animation-props.js";
5
4
  import { Stats, Stat } from '@probe.gl/stats';
6
5
  /** AnimationLoop properties */
7
- export declare type AnimationLoopProps = {
8
- onCreateDevice?: (props: DeviceProps) => Promise<Device>;
6
+ export type AnimationLoopProps = {
7
+ device: Device | Promise<Device>;
9
8
  onAddHTML?: (div: HTMLDivElement) => string;
10
- onInitialize?: (animationProps: AnimationProps) => void;
11
- onRender?: (animationProps: AnimationProps) => void;
9
+ onInitialize?: (animationProps: AnimationProps) => Promise<unknown>;
10
+ onRender?: (animationProps: AnimationProps) => unknown;
12
11
  onFinalize?: (animationProps: AnimationProps) => void;
13
12
  onError?: (reason: Error) => void;
14
- device?: Device | null;
15
- deviceProps?: DeviceProps;
16
13
  stats?: Stats;
17
- debug?: boolean;
14
+ autoResizeViewport?: boolean;
15
+ autoResizeDrawingBuffer?: boolean;
16
+ useDevicePixels?: number | boolean;
17
+ };
18
+ export type MutableAnimationLoopProps = {
18
19
  autoResizeViewport?: boolean;
19
20
  autoResizeDrawingBuffer?: boolean;
20
21
  useDevicePixels?: number | boolean;
@@ -36,36 +37,43 @@ export declare class AnimationLoop {
36
37
  _running: boolean;
37
38
  _animationFrameId: any;
38
39
  _nextFramePromise: Promise<AnimationLoop> | null;
39
- _resolveNextFrame: ((AnimationLoop: any) => void) | null;
40
+ _resolveNextFrame: ((animationLoop: AnimationLoop) => void) | null;
40
41
  _cpuStartTime: number;
41
- constructor(props?: AnimationLoopProps);
42
+ constructor(props: AnimationLoopProps);
42
43
  destroy(): void;
43
44
  /** @deprecated Use .destroy() */
44
45
  delete(): void;
46
+ /** Flags this animation loop as needing redraw */
45
47
  setNeedsRedraw(reason: string): this;
46
- setProps(props: AnimationLoopProps): this;
48
+ /** TODO - move these props to CanvasContext? */
49
+ setProps(props: MutableAnimationLoopProps): this;
47
50
  /** Starts a render loop if not already running */
48
- start(): Promise<this | null>;
51
+ start(): Promise<this>;
52
+ /** Stops a render loop if already running, finalizing */
53
+ stop(): this;
49
54
  /** Explicitly draw a frame */
50
55
  redraw(): this;
51
- stop(): this;
56
+ /** Add a timeline, it will be automatically updated by the animation loop. */
52
57
  attachTimeline(timeline: Timeline): Timeline;
58
+ /** Remove a timeline */
53
59
  detachTimeline(): void;
60
+ /** Wait until a render completes */
54
61
  waitForRender(): Promise<AnimationLoop>;
62
+ /** TODO - should use device.deviceContext */
55
63
  toDataURL(): Promise<string>;
56
64
  _initialize(): void;
57
65
  _setDisplay(display: any): void;
58
66
  _requestAnimationFrame(): void;
59
67
  _cancelAnimationFrame(): void;
60
68
  _animationFrame(): void;
61
- _renderFrame(props: AnimationProps): void;
69
+ _renderFrame(animationProps: AnimationProps): void;
62
70
  _clearNeedsRedraw(): void;
63
71
  _setupFrame(): void;
64
72
  _initializeAnimationProps(): void;
65
73
  _getAnimationProps(): AnimationProps;
66
74
  _updateAnimationProps(): void;
67
- /** Either uses supplied or existing context, or calls provided callback to create one */
68
- _createDevice(): Promise<void>;
75
+ /** Wait for supplied device */
76
+ _initDevice(): Promise<void>;
69
77
  _createInfoDiv(): void;
70
78
  _getSizeAndAspect(): {
71
79
  width: number;
@@ -79,10 +87,10 @@ export declare class AnimationLoop {
79
87
  * Optionally multiplying with devicePixel ratio
80
88
  */
81
89
  _resizeCanvasDrawingBuffer(): void;
82
- _beginTimers(): void;
83
- _endTimers(): void;
90
+ _beginFrameTimers(): void;
91
+ _endFrameTimers(): void;
84
92
  _startEventHandling(): void;
85
- _onMousemove(e: any): void;
86
- _onMouseleave(e: any): void;
93
+ _onMousemove(event: Event): void;
94
+ _onMouseleave(event: Event): void;
87
95
  }
88
96
  //# sourceMappingURL=animation-loop.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"animation-loop.d.ts","sourceRoot":"","sources":["../../src/animation-loop/animation-loop.ts"],"names":[],"mappings":"AAIA,OAAO,EAAO,MAAM,EAAC,MAAM,eAAe,CAAC;AAE3C,OAAO,EAAC,QAAQ,EAAC,iCAA8B;AAC/C,OAAO,EAAC,cAAc,EAAC,6BAA0B;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,e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