@luma.gl/engine 9.0.0-alpha.8 → 9.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (191) 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 +6 -27
  5. package/dist/animation/key-frames.js.map +1 -1
  6. package/dist/animation/timeline.d.ts +8 -8
  7. package/dist/animation/timeline.d.ts.map +1 -1
  8. package/dist/animation/timeline.js +18 -49
  9. package/dist/animation/timeline.js.map +1 -1
  10. package/dist/animation-loop/animation-loop-template.d.ts +23 -0
  11. package/dist/animation-loop/animation-loop-template.d.ts.map +1 -0
  12. package/dist/animation-loop/animation-loop-template.js +7 -0
  13. package/dist/animation-loop/animation-loop-template.js.map +1 -0
  14. package/dist/{lib → animation-loop}/animation-loop.d.ts +30 -22
  15. package/dist/animation-loop/animation-loop.d.ts.map +1 -0
  16. package/dist/{lib → animation-loop}/animation-loop.js +77 -192
  17. package/dist/animation-loop/animation-loop.js.map +1 -0
  18. package/dist/{lib → animation-loop}/animation-props.d.ts +2 -3
  19. package/dist/animation-loop/animation-props.d.ts.map +1 -0
  20. package/dist/animation-loop/animation-props.js.map +1 -0
  21. package/dist/animation-loop/make-animation-loop.d.ts +6 -0
  22. package/dist/animation-loop/make-animation-loop.d.ts.map +1 -0
  23. package/dist/animation-loop/make-animation-loop.js +28 -0
  24. package/dist/animation-loop/make-animation-loop.js.map +1 -0
  25. package/dist/debug/copy-texture-to-image.d.ts +26 -0
  26. package/dist/debug/copy-texture-to-image.d.ts.map +1 -0
  27. package/dist/debug/copy-texture-to-image.js +46 -0
  28. package/dist/debug/copy-texture-to-image.js.map +1 -0
  29. package/dist/debug/debug-framebuffer.d.ts +11 -0
  30. package/dist/debug/debug-framebuffer.d.ts.map +1 -0
  31. package/dist/debug/debug-framebuffer.js +43 -0
  32. package/dist/debug/debug-framebuffer.js.map +1 -0
  33. package/dist/debug/debug-shader-layout.d.ts +9 -0
  34. package/dist/debug/debug-shader-layout.d.ts.map +1 -0
  35. package/dist/debug/debug-shader-layout.js +28 -0
  36. package/dist/debug/debug-shader-layout.js.map +1 -0
  37. package/dist/debug/pixel-data-utils.d.ts +24 -0
  38. package/dist/debug/pixel-data-utils.d.ts.map +1 -0
  39. package/dist/debug/pixel-data-utils.js +41 -0
  40. package/dist/debug/pixel-data-utils.js.map +1 -0
  41. package/dist/dist.dev.js +10081 -0
  42. package/dist/geometries/cone-geometry.d.ts +1 -1
  43. package/dist/geometries/cone-geometry.d.ts.map +1 -1
  44. package/dist/geometries/cone-geometry.js +6 -5
  45. package/dist/geometries/cone-geometry.js.map +1 -1
  46. package/dist/geometries/cube-geometry.d.ts +2 -2
  47. package/dist/geometries/cube-geometry.d.ts.map +1 -1
  48. package/dist/geometries/cube-geometry.js +16 -10
  49. package/dist/geometries/cube-geometry.js.map +1 -1
  50. package/dist/geometries/cylinder-geometry.d.ts +1 -1
  51. package/dist/geometries/cylinder-geometry.d.ts.map +1 -1
  52. package/dist/geometries/cylinder-geometry.js +6 -5
  53. package/dist/geometries/cylinder-geometry.js.map +1 -1
  54. package/dist/geometries/ico-sphere-geometry.d.ts +2 -2
  55. package/dist/geometries/ico-sphere-geometry.d.ts.map +1 -1
  56. package/dist/geometries/ico-sphere-geometry.js +10 -19
  57. package/dist/geometries/ico-sphere-geometry.js.map +1 -1
  58. package/dist/geometries/plane-geometry.d.ts +2 -2
  59. package/dist/geometries/plane-geometry.d.ts.map +1 -1
  60. package/dist/geometries/plane-geometry.js +14 -23
  61. package/dist/geometries/plane-geometry.js.map +1 -1
  62. package/dist/geometries/sphere-geometry.d.ts +2 -2
  63. package/dist/geometries/sphere-geometry.d.ts.map +1 -1
  64. package/dist/geometries/sphere-geometry.js +9 -13
  65. package/dist/geometries/sphere-geometry.js.map +1 -1
  66. package/dist/geometries/truncated-cone-geometry.d.ts +2 -4
  67. package/dist/geometries/truncated-cone-geometry.d.ts.map +1 -1
  68. package/dist/geometries/truncated-cone-geometry.js +9 -25
  69. package/dist/geometries/truncated-cone-geometry.js.map +1 -1
  70. package/dist/geometry/geometry-table.d.ts +2 -2
  71. package/dist/geometry/geometry-table.d.ts.map +1 -1
  72. package/dist/geometry/geometry-table.js.map +1 -1
  73. package/dist/geometry/geometry-utils.d.ts.map +1 -1
  74. package/dist/geometry/geometry-utils.js +0 -9
  75. package/dist/geometry/geometry-utils.js.map +1 -1
  76. package/dist/geometry/geometry.d.ts +43 -43
  77. package/dist/geometry/geometry.d.ts.map +1 -1
  78. package/dist/geometry/geometry.js +20 -82
  79. package/dist/geometry/geometry.js.map +1 -1
  80. package/dist/geometry/gpu-geometry.d.ts +37 -0
  81. package/dist/geometry/gpu-geometry.d.ts.map +1 -0
  82. package/dist/geometry/gpu-geometry.js +110 -0
  83. package/dist/geometry/gpu-geometry.js.map +1 -0
  84. package/dist/geometry/gpu-table.d.ts +1 -0
  85. package/dist/geometry/gpu-table.d.ts.map +1 -0
  86. package/dist/geometry/gpu-table.js +2 -0
  87. package/dist/geometry/gpu-table.js.map +1 -0
  88. package/dist/index.cjs +3128 -0
  89. package/dist/index.d.ts +24 -8
  90. package/dist/index.d.ts.map +1 -1
  91. package/dist/index.js +23 -14
  92. package/dist/index.js.map +1 -1
  93. package/dist/lib/clip-space.d.ts +8 -0
  94. package/dist/lib/clip-space.d.ts.map +1 -1
  95. package/dist/lib/clip-space.js +47 -0
  96. package/dist/lib/clip-space.js.map +1 -1
  97. package/dist/lib/pipeline-factory.d.ts +12 -45
  98. package/dist/lib/pipeline-factory.d.ts.map +1 -1
  99. package/dist/lib/pipeline-factory.js +42 -168
  100. package/dist/lib/pipeline-factory.js.map +1 -1
  101. package/dist/model/model.d.ts +206 -0
  102. package/dist/model/model.d.ts.map +1 -0
  103. package/dist/model/model.js +435 -0
  104. package/dist/model/model.js.map +1 -0
  105. package/dist/scenegraph/group-node.d.ts +21 -0
  106. package/dist/scenegraph/group-node.d.ts.map +1 -0
  107. package/dist/scenegraph/group-node.js +94 -0
  108. package/dist/scenegraph/group-node.js.map +1 -0
  109. package/dist/scenegraph/model-node.d.ts +18 -0
  110. package/dist/scenegraph/model-node.d.ts.map +1 -0
  111. package/dist/scenegraph/model-node.js +28 -0
  112. package/dist/scenegraph/model-node.js.map +1 -0
  113. package/dist/scenegraph/scenegraph-node.d.ts +56 -0
  114. package/dist/scenegraph/scenegraph-node.d.ts.map +1 -0
  115. package/dist/scenegraph/scenegraph-node.js +141 -0
  116. package/dist/scenegraph/scenegraph-node.js.map +1 -0
  117. package/dist/shader-inputs.d.ts +63 -0
  118. package/dist/shader-inputs.d.ts.map +1 -0
  119. package/dist/shader-inputs.js +66 -0
  120. package/dist/shader-inputs.js.map +1 -0
  121. package/dist/transform/buffer-transform.d.ts +35 -0
  122. package/dist/transform/buffer-transform.d.ts.map +1 -0
  123. package/dist/transform/buffer-transform.js +62 -0
  124. package/dist/transform/buffer-transform.js.map +1 -0
  125. package/dist/transform/texture-transform.d.ts +57 -0
  126. package/dist/transform/texture-transform.d.ts.map +1 -0
  127. package/dist/transform/texture-transform.js +122 -0
  128. package/dist/transform/texture-transform.js.map +1 -0
  129. package/dist.min.js +293 -0
  130. package/package.json +21 -12
  131. package/src/animation/timeline.ts +15 -14
  132. package/src/animation-loop/animation-loop-template.ts +23 -0
  133. package/src/{lib → animation-loop}/animation-loop.ts +99 -88
  134. package/src/{lib → animation-loop}/animation-props.ts +1 -1
  135. package/src/animation-loop/make-animation-loop.ts +44 -0
  136. package/src/debug/copy-texture-to-image.ts +72 -0
  137. package/src/debug/debug-framebuffer.ts +57 -0
  138. package/src/debug/debug-shader-layout.ts +38 -0
  139. package/src/debug/pixel-data-utils.ts +57 -0
  140. package/src/geometries/cone-geometry.ts +1 -1
  141. package/src/geometries/cube-geometry.ts +47 -45
  142. package/src/geometries/cylinder-geometry.ts +2 -2
  143. package/src/geometries/ico-sphere-geometry.ts +6 -5
  144. package/src/geometries/plane-geometry.ts +5 -4
  145. package/src/geometries/sphere-geometry.ts +4 -3
  146. package/src/geometries/truncated-cone-geometry.ts +4 -13
  147. package/src/geometry/geometry-table.ts +1 -1
  148. package/src/geometry/geometry-utils.ts +3 -3
  149. package/src/geometry/geometry.ts +65 -110
  150. package/src/geometry/gpu-geometry.ts +125 -0
  151. package/src/geometry/gpu-table.ts +41 -0
  152. package/src/index.ts +34 -10
  153. package/src/lib/clip-space.ts +22 -21
  154. package/src/lib/pipeline-factory.ts +51 -168
  155. package/src/model/model.ts +726 -0
  156. package/src/scenegraph/group-node.ts +103 -0
  157. package/src/scenegraph/model-node.ts +50 -0
  158. package/src/scenegraph/scenegraph-node.ts +204 -0
  159. package/src/shader-inputs.ts +150 -0
  160. package/src/transform/buffer-transform.ts +94 -0
  161. package/src/transform/texture-transform.ts +169 -0
  162. package/dist/bundle.d.ts +0 -2
  163. package/dist/bundle.d.ts.map +0 -1
  164. package/dist/bundle.js +0 -5
  165. package/dist/bundle.js.map +0 -1
  166. package/dist/geometry/primitive-utils.d.ts +0 -1
  167. package/dist/geometry/primitive-utils.d.ts.map +0 -1
  168. package/dist/geometry/primitive-utils.js +0 -2
  169. package/dist/geometry/primitive-utils.js.map +0 -1
  170. package/dist/lib/animation-loop.d.ts.map +0 -1
  171. package/dist/lib/animation-loop.js.map +0 -1
  172. package/dist/lib/animation-props.d.ts.map +0 -1
  173. package/dist/lib/animation-props.js.map +0 -1
  174. package/dist/lib/model-utils.d.ts +0 -5
  175. package/dist/lib/model-utils.d.ts.map +0 -1
  176. package/dist/lib/model-utils.js +0 -45
  177. package/dist/lib/model-utils.js.map +0 -1
  178. package/dist/lib/model.d.ts +0 -41
  179. package/dist/lib/model.d.ts.map +0 -1
  180. package/dist/lib/model.js +0 -182
  181. package/dist/lib/model.js.map +0 -1
  182. package/dist/lib/render-loop.d.ts +0 -14
  183. package/dist/lib/render-loop.d.ts.map +0 -1
  184. package/dist/lib/render-loop.js +0 -49
  185. package/dist/lib/render-loop.js.map +0 -1
  186. package/src/bundle.ts +0 -4
  187. package/src/geometry/primitive-utils.ts +0 -30
  188. package/src/lib/model-utils.ts +0 -124
  189. package/src/lib/model.ts +0 -183
  190. package/src/lib/render-loop.ts +0 -58
  191. /package/dist/{lib → animation-loop}/animation-props.js +0 -0
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";
2
1
  export class KeyFrames {
3
2
  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
-
3
+ this.startIndex = -1;
4
+ this.endIndex = -1;
5
+ this.factor = 0;
6
+ this.times = [];
7
+ this.values = [];
8
+ this._lastTime = -1;
16
9
  this.setKeyFrames(keyFrames);
17
10
  this.setTime(0);
18
11
  }
19
-
20
12
  setKeyFrames(keyFrames) {
21
13
  const numKeys = keyFrames.length;
22
14
  this.times.length = numKeys;
23
15
  this.values.length = numKeys;
24
-
25
16
  for (let i = 0; i < numKeys; ++i) {
26
17
  this.times[i] = keyFrames[i][0];
27
18
  this.values[i] = keyFrames[i][1];
28
19
  }
29
-
30
20
  this._calculateKeys(this._lastTime);
31
21
  }
32
-
33
22
  setTime(time) {
34
23
  time = Math.max(0, time);
35
-
36
24
  if (time !== this._lastTime) {
37
25
  this._calculateKeys(time);
38
-
39
26
  this._lastTime = time;
40
27
  }
41
28
  }
42
-
43
29
  getStartTime() {
44
30
  return this.times[this.startIndex];
45
31
  }
46
-
47
32
  getEndTime() {
48
33
  return this.times[this.endIndex];
49
34
  }
50
-
51
35
  getStartData() {
52
36
  return this.values[this.startIndex];
53
37
  }
54
-
55
38
  getEndData() {
56
39
  return this.values[this.endIndex];
57
40
  }
58
-
59
41
  _calculateKeys(time) {
60
42
  let index = 0;
61
43
  const numKeys = this.times.length;
62
-
63
44
  for (index = 0; index < numKeys - 2; ++index) {
64
45
  if (this.times[index + 1] > time) {
65
46
  break;
66
47
  }
67
48
  }
68
-
69
49
  this.startIndex = index;
70
50
  this.endIndex = index + 1;
71
51
  const startTime = this.times[this.startIndex];
72
52
  const endTime = this.times[this.endIndex];
73
53
  this.factor = Math.min(Math.max(0, (time - startTime) / (endTime - startTime)), 1);
74
54
  }
75
-
76
55
  }
77
56
  //# sourceMappingURL=key-frames.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/animation/key-frames.ts"],"names":["KeyFrames","constructor","keyFrames","setKeyFrames","setTime","numKeys","length","times","values","i","_calculateKeys","_lastTime","time","Math","max","getStartTime","startIndex","getEndTime","endIndex","getStartData","getEndData","index","startTime","endTime","factor","min"],"mappings":";AAIA,OAAO,MAAMA,SAAN,CAA4B;AAQjCC,EAAAA,WAAW,CAACC,SAAD,EAA2B;AAAA,wCAPjB,CAAC,CAOgB;;AAAA,sCANnB,CAAC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KAAKU,QAAjB,CAAP;AACD;;AAEDR,EAAAA,cAAc,CAACE,IAAD,EAAqB;AACjC,QAAIS,KAAK,GAAG,CAAZ;AACA,UAAMhB,OAAO,GAAG,KAAKE,KAAL,CAAWD,MAA3B;;AAEA,SAAKe,KAAK,GAAG,CAAb,EAAgBA,KAAK,GAAGhB,OAAO,GAAG,CAAlC,EAAqC,EAAEgB,KAAvC,EAA8C;AAC5C,UAAI,KAAKd,KAAL,CAAWc,KAAK,GAAG,CAAnB,IAAwBT,IAA5B,EAAkC;AAChC;AACD;AACF;;AAED,SAAKI,UAAL,GAAkBK,KAAlB;AACA,SAAKH,QAAL,GAAgBG,KAAK,GAAG,CAAxB;AAEA,UAAMC,SAAS,GAAG,KAAKf,KAAL,CAAW,KAAKS,UAAhB,CAAlB;AACA,UAAMO,OAAO,GAAG,KAAKhB,KAAL,CAAW,KAAKW,QAAhB,CAAhB;AACA,SAAKM,MAAL,GAAcX,IAAI,CAACY,GAAL,CAASZ,IAAI,CAACC,GAAL,CAAS,CAAT,EAAY,CAACF,IAAI,GAAGU,SAAR,KAAsBC,OAAO,GAAGD,SAAhC,CAAZ,CAAT,EAAkE,CAAlE,CAAd;AACD;;AAnEgC","sourcesContent":["// keyframes\nexport type KeyFrame<T> = [number, T];\n\n/** Holds a list of key frames (timestamped values) */\nexport class KeyFrames<T = number> {\n startIndex: number = -1;\n endIndex: number = -1;\n factor: number = 0;\n times: number[] = [];\n values: T[] = [];\n private _lastTime = -1;\n\n constructor(keyFrames: KeyFrame<T>[]) {\n this.setKeyFrames(keyFrames);\n this.setTime(0);\n }\n\n setKeyFrames(keyFrames: KeyFrame<T>[]): void {\n const numKeys = keyFrames.length;\n this.times.length = numKeys;\n this.values.length = numKeys;\n\n for (let i = 0; i < numKeys; ++i) {\n this.times[i] = keyFrames[i][0];\n this.values[i] = keyFrames[i][1];\n }\n\n this._calculateKeys(this._lastTime);\n }\n\n setTime(time: number): void {\n time = Math.max(0, time);\n\n if (time !== this._lastTime) {\n this._calculateKeys(time);\n this._lastTime = time;\n }\n }\n\n getStartTime(): number {\n return this.times[this.startIndex];\n }\n\n getEndTime(): number {\n return this.times[this.endIndex];\n }\n\n getStartData(): T {\n return this.values[this.startIndex];\n }\n\n getEndData(): T {\n return this.values[this.endIndex];\n }\n\n _calculateKeys(time: number): void {\n let index = 0;\n const numKeys = this.times.length;\n\n for (index = 0; index < numKeys - 2; ++index) {\n if (this.times[index + 1] > time) {\n break;\n }\n }\n\n this.startIndex = index;\n this.endIndex = index + 1;\n\n const startTime = this.times[this.startIndex];\n const endTime = this.times[this.endIndex];\n this.factor = Math.min(Math.max(0, (time - startTime) / (endTime - startTime)), 1);\n }\n}\n"],"file":"key-frames.js"}
1
+ {"version":3,"file":"key-frames.js","names":["KeyFrames","constructor","keyFrames","startIndex","endIndex","factor","times","values","_lastTime","setKeyFrames","setTime","numKeys","length","i","_calculateKeys","time","Math","max","getStartTime","getEndTime","getStartData","getEndData","index","startTime","endTime","min"],"sources":["../../src/animation/key-frames.ts"],"sourcesContent":["// keyframes\nexport type KeyFrame<T> = [number, T];\n\n/** Holds a list of key frames (timestamped values) */\nexport class KeyFrames<T = number> {\n startIndex: number = -1;\n endIndex: number = -1;\n factor: number = 0;\n times: number[] = [];\n values: T[] = [];\n private _lastTime = -1;\n\n constructor(keyFrames: KeyFrame<T>[]) {\n this.setKeyFrames(keyFrames);\n this.setTime(0);\n }\n\n setKeyFrames(keyFrames: KeyFrame<T>[]): void {\n const numKeys = keyFrames.length;\n this.times.length = numKeys;\n this.values.length = numKeys;\n\n for (let i = 0; i < numKeys; ++i) {\n this.times[i] = keyFrames[i][0];\n this.values[i] = keyFrames[i][1];\n }\n\n this._calculateKeys(this._lastTime);\n }\n\n setTime(time: number): void {\n time = Math.max(0, time);\n\n if (time !== this._lastTime) {\n this._calculateKeys(time);\n this._lastTime = time;\n }\n }\n\n getStartTime(): number {\n return this.times[this.startIndex];\n }\n\n getEndTime(): number {\n return this.times[this.endIndex];\n }\n\n getStartData(): T {\n return this.values[this.startIndex];\n }\n\n getEndData(): T {\n return this.values[this.endIndex];\n }\n\n _calculateKeys(time: number): void {\n let index = 0;\n const numKeys = this.times.length;\n\n for (index = 0; index < numKeys - 2; ++index) {\n if (this.times[index + 1] > time) {\n break;\n }\n }\n\n this.startIndex = index;\n this.endIndex = index + 1;\n\n const startTime = this.times[this.startIndex];\n const endTime = this.times[this.endIndex];\n this.factor = Math.min(Math.max(0, (time - startTime) / (endTime - startTime)), 1);\n }\n}\n"],"mappings":"AAIA,OAAO,MAAMA,SAAS,CAAa;EAQjCC,WAAWA,CAACC,SAAwB,EAAE;IAAA,KAPtCC,UAAU,GAAW,CAAC,CAAC;IAAA,KACvBC,QAAQ,GAAW,CAAC,CAAC;IAAA,KACrBC,MAAM,GAAW,CAAC;IAAA,KAClBC,KAAK,GAAa,EAAE;IAAA,KACpBC,MAAM,GAAQ,EAAE;IAAA,KACRC,SAAS,GAAG,CAAC,CAAC;IAGpB,IAAI,CAACC,YAAY,CAACP,SAAS,CAAC;IAC5B,IAAI,CAACQ,OAAO,CAAC,CAAC,CAAC;EACjB;EAEAD,YAAYA,CAACP,SAAwB,EAAQ;IAC3C,MAAMS,OAAO,GAAGT,SAAS,CAACU,MAAM;IAChC,IAAI,CAACN,KAAK,CAACM,MAAM,GAAGD,OAAO;IAC3B,IAAI,CAACJ,MAAM,CAACK,MAAM,GAAGD,OAAO;IAE5B,KAAK,IAAIE,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGF,OAAO,EAAE,EAAEE,CAAC,EAAE;MAChC,IAAI,CAACP,KAAK,CAACO,CAAC,CAAC,GAAGX,SAAS,CAACW,CAAC,CAAC,CAAC,CAAC,CAAC;MAC/B,IAAI,CAACN,MAAM,CAACM,CAAC,CAAC,GAAGX,SAAS,CAACW,CAAC,CAAC,CAAC,CAAC,CAAC;IAClC;IAEA,IAAI,CAACC,cAAc,CAAC,IAAI,CAACN,SAAS,CAAC;EACrC;EAEAE,OAAOA,CAAC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,GAAG,CAAC,CAAC,EAAE,CAACF,IAAI,GAAGQ,SAAS,KAAKC,OAAO,GAAGD,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC;EACpF;AACF"}
@@ -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,CAAC,EAAE,MAAM,CAAA;IACb,MAAM,CAAC,EAAE,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a,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,19 +1,13 @@
1
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
1
  let channelHandles = 1;
3
2
  let animationHandles = 1;
4
3
  export class Timeline {
5
4
  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);
5
+ this.time = 0;
6
+ this.channels = new Map();
7
+ this.animations = new Map();
8
+ this.playing = false;
9
+ this.lastEngineTime = -1;
15
10
  }
16
-
17
11
  addChannel(props) {
18
12
  const {
19
13
  delay = 0,
@@ -21,7 +15,7 @@ export class Timeline {
21
15
  rate = 1,
22
16
  repeat = 1
23
17
  } = props;
24
- const handle = channelHandles++;
18
+ const channelId = channelHandles++;
25
19
  const channel = {
26
20
  time: 0,
27
21
  delay,
@@ -29,57 +23,42 @@ export class Timeline {
29
23
  rate,
30
24
  repeat
31
25
  };
32
-
33
26
  this._setChannelTime(channel, this.time);
34
-
35
- this.channels.set(handle, channel);
36
- return handle;
27
+ this.channels.set(channelId, channel);
28
+ return channelId;
37
29
  }
38
-
39
- removeChannel(handle) {
40
- this.channels.delete(handle);
41
-
30
+ removeChannel(channelId) {
31
+ this.channels.delete(channelId);
42
32
  for (const [animationHandle, animation] of this.animations) {
43
- if (animation.channel === handle) {
33
+ if (animation.channel === channelId) {
44
34
  this.detachAnimation(animationHandle);
45
35
  }
46
36
  }
47
37
  }
48
-
49
- isFinished(handle) {
50
- const channel = this.channels.get(handle);
51
-
38
+ isFinished(channelId) {
39
+ const channel = this.channels.get(channelId);
52
40
  if (channel === undefined) {
53
41
  return false;
54
42
  }
55
-
56
43
  return this.time >= channel.delay + channel.duration * channel.repeat;
57
44
  }
58
-
59
- getTime(handle) {
60
- if (handle === undefined) {
45
+ getTime(channelId) {
46
+ if (channelId === undefined) {
61
47
  return this.time;
62
48
  }
63
-
64
- const channel = this.channels.get(handle);
65
-
49
+ const channel = this.channels.get(channelId);
66
50
  if (channel === undefined) {
67
51
  return -1;
68
52
  }
69
-
70
53
  return channel.time;
71
54
  }
72
-
73
55
  setTime(time) {
74
56
  this.time = Math.max(0, time);
75
57
  const channels = this.channels.values();
76
-
77
58
  for (const channel of channels) {
78
59
  this._setChannelTime(channel, this.time);
79
60
  }
80
-
81
61
  const animations = this.animations.values();
82
-
83
62
  for (const animationData of animations) {
84
63
  const {
85
64
  animation,
@@ -88,20 +67,16 @@ export class Timeline {
88
67
  animation.setTime(this.getTime(channel));
89
68
  }
90
69
  }
91
-
92
70
  play() {
93
71
  this.playing = true;
94
72
  }
95
-
96
73
  pause() {
97
74
  this.playing = false;
98
75
  this.lastEngineTime = -1;
99
76
  }
100
-
101
77
  reset() {
102
78
  this.setTime(0);
103
79
  }
104
-
105
80
  attachAnimation(animation, channelHandle) {
106
81
  const animationHandle = animationHandles++;
107
82
  this.animations.set(animationHandle, {
@@ -111,26 +86,21 @@ export class Timeline {
111
86
  animation.setTime(this.getTime(channelHandle));
112
87
  return animationHandle;
113
88
  }
114
-
115
- detachAnimation(handle) {
116
- this.animations.delete(handle);
89
+ detachAnimation(channelId) {
90
+ this.animations.delete(channelId);
117
91
  }
118
-
119
92
  update(engineTime) {
120
93
  if (this.playing) {
121
94
  if (this.lastEngineTime === -1) {
122
95
  this.lastEngineTime = engineTime;
123
96
  }
124
-
125
97
  this.setTime(this.time + (engineTime - this.lastEngineTime));
126
98
  this.lastEngineTime = engineTime;
127
99
  }
128
100
  }
129
-
130
101
  _setChannelTime(channel, time) {
131
102
  const offsetTime = time - channel.delay;
132
103
  const totalDuration = channel.duration * channel.repeat;
133
-
134
104
  if (offsetTime >= totalDuration) {
135
105
  channel.time = channel.duration * channel.rate;
136
106
  } else {
@@ -138,6 +108,5 @@ export class Timeline {
138
108
  channel.time *= channel.rate;
139
109
  }
140
110
  }
141
-
142
111
  }
143
112
  //# sourceMappingURL=timeline.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/animation/timeline.ts"],"names":["channelHandles","animationHandles","Timeline","constructor","Map","addChannel","props","delay","duration","Number","POSITIVE_INFINITY","rate","repeat","handle","channel","time","_setChannelTime","channels","set","removeChannel","delete","animationHandle","animation","animations","detachAnimation","isFinished","get","undefined","getTime","setTime","Math","max","values","animationData","play","playing","pause","lastEngineTime","reset","attachAnimation","channelHandle","update","engineTime","offsetTime","totalDuration"],"mappings":";AAmCA,IAAIA,cAAc,GAAG,CAArB;AACA,IAAIC,gBAAgB,GAAG,CAAvB;AAEA,OAAO,MAAMC,QAAN,CAAe;AAOpBC,EAAAA,WAAW,GAAG;AAAA,kCANC,CAMD;;AAAA,sCALH,IAAIC,GAAJ,EAKG;;AAAA,wCAJD,IAAIA,GAAJ,EAIC;;AAAA,qCAHK,KAGL;;AAAA,4CAFW,CAAC,CAEZ;AACb;;AAEDC,EAAAA,UAAU,CAACC,KAAD,EAAgC;AACxC,UAAM;AAACC,MAAAA,KAAK,GAAG,CAAT;AAAYC,MAAAA,QAAQ,GAAGC,MAAM,CAACC,iBAA9B;AAAiDC,MAAAA,IAAI,GAAG,CAAxD;AAA2DC,MAAAA,MAAM,GAAG;AAApE,QAAyEN,KAA/E;AAEA,UAAMO,MAAM,GAAGb,cAAc,EAA7B;AACA,UAAMc,OAAgB,GAAG;AACvBC,MAAAA,IAAI,EAAE,CADiB;AAEvBR,MAAAA,KAFuB;AAGvBC,MAAAA,QAHuB;AAIvBG,MAAAA,IAJuB;AAKvBC,MAAAA;AALuB,KAAzB;;AAOA,SAAKI,eAAL,CAAqBF,OAArB,EAA8B,KAAKC,IAAnC;;AACA,SAAKE,QA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AmBC,IAAnB,EAAuC;AACpD,UAAM4B,UAAU,GAAG5B,IAAI,GAAGD,OAAO,CAACP,KAAlC;AACA,UAAMqC,aAAa,GAAG9B,OAAO,CAACN,QAAR,GAAmBM,OAAO,CAACF,MAAjD;;AAEA,QAAI+B,UAAU,IAAIC,aAAlB,EAAiC;AAC/B9B,MAAAA,OAAO,CAACC,IAAR,GAAeD,OAAO,CAACN,QAAR,GAAmBM,OAAO,CAACH,IAA1C;AACD,KAFD,MAEO;AACLG,MAAAA,OAAO,CAACC,IAAR,GAAee,IAAI,CAACC,GAAL,CAAS,CAAT,EAAYY,UAAZ,IAA0B7B,OAAO,CAACN,QAAjD;AACAM,MAAAA,OAAO,CAACC,IAAR,IAAgBD,OAAO,CAACH,IAAxB;AACD;AACF;;AA7HmB","sourcesContent":["// luma.gl, MIT license\n\n/**\n * Timeline channel properties\n * @param delay = 0;\n * @param duration = Number.POSITIVE_INFINITY;\n * @param rate = 1\n * @param repeat = 1\n */\n export type ChannelOptions = {\n delay?: number\n duration?: number\n rate?: number\n repeat?: number\n}\n\nexport type AnimationOptions = {\n setTime: (time: number) => void\n}\n\n type Channel = {\n time: number\n delay: number\n duration: number\n rate: number\n repeat: number\n}\n\ntype Animation = {\n channel?: number;\n animation: {\n setTime: (time: number) => void\n }\n}\n\nlet channelHandles = 1;\nlet animationHandles = 1;\n\nexport class Timeline {\n time: number = 0;\n channels = new Map<number, Channel>();\n animations = new Map<number, Animation>();\n playing: boolean = false;\n lastEngineTime: number = -1;\n\n constructor() {\n }\n\n addChannel(props: ChannelOptions): number {\n const {delay = 0, duration = Number.POSITIVE_INFINITY, rate = 1, repeat = 1} = props;\n\n const handle = channelHandles++;\n const channel: Channel = {\n time: 0,\n delay,\n duration,\n rate,\n repeat\n };\n this._setChannelTime(channel, this.time);\n this.channels.set(handle, channel);\n\n return handle;\n }\n\n removeChannel(handle: number): void {\n this.channels.delete(handle);\n\n for (const [animationHandle, animation] of this.animations) {\n if (animation.channel === handle) {\n this.detachAnimation(animationHandle);\n }\n }\n }\n\n isFinished(handle: number): boolean {\n const channel = this.channels.get(handle);\n if (channel === undefined) {\n return false;\n }\n\n return this.time >= channel.delay + channel.duration * channel.repeat;\n }\n\n getTime(handle?: number): number {\n if (handle === undefined) {\n return this.time;\n }\n\n const channel = this.channels.get(handle);\n\n if (channel === undefined) {\n return -1;\n }\n\n return channel.time;\n }\n\n setTime(time: number): void {\n this.time = Math.max(0, time);\n\n const channels = this.channels.values();\n for (const channel of channels) {\n this._setChannelTime(channel, this.time);\n }\n\n const animations = this.animations.values();\n for (const animationData of animations) {\n const {animation, channel} = animationData;\n animation.setTime(this.getTime(channel));\n }\n }\n\n play(): void {\n this.playing = true;\n }\n\n pause(): void {\n this.playing = false;\n this.lastEngineTime = -1;\n }\n\n reset(): void {\n this.setTime(0);\n }\n\n attachAnimation(animation: AnimationOptions, channelHandle?: number): number {\n const animationHandle = animationHandles++;\n\n this.animations.set(animationHandle, {\n animation,\n channel: channelHandle\n });\n\n animation.setTime(this.getTime(channelHandle));\n\n return animationHandle;\n }\n\n detachAnimation(handle: number): void {\n this.animations.delete(handle);\n }\n\n update(engineTime: number): void {\n if (this.playing) {\n if (this.lastEngineTime === -1) {\n this.lastEngineTime = engineTime;\n }\n this.setTime(this.time + (engineTime - this.lastEngineTime));\n this.lastEngineTime = engineTime;\n }\n }\n\n _setChannelTime(channel: Channel, time: number): void {\n const offsetTime = time - channel.delay;\n const totalDuration = channel.duration * channel.repeat;\n // Note(Tarek): Don't loop on final repeat.\n if (offsetTime >= totalDuration) {\n channel.time = channel.duration * channel.rate;\n } else {\n channel.time = Math.max(0, offsetTime) % channel.duration;\n channel.time *= channel.rate;\n }\n }\n}\n"],"file":"timeline.js"}
1
+ {"version":3,"file":"timeline.js","names":["channelHandles","animationHandles","Timeline","constructor","time","channels","Map","animations","playing","lastEngineTime","addChannel","props","delay","duration","Number","POSITIVE_INFINITY","rate","repeat","channelId","channel","_setChannelTime","set","removeChannel","delete","animationHandle","animation","detachAnimation","isFinished","get","undefined","getTime","setTime","Math","max","values","animationData","play","pause","reset","attachAnimation","channelHandle","update","engineTime","offsetTime","totalDuration"],"sources":["../../src/animation/timeline.ts"],"sourcesContent":["// luma.gl, MIT license\n// Copyright (c) vis.gl contributors\n\n/**\n * Timeline channel properties\n * @param delay = 0;\n * @param duration = Number.POSITIVE_INFINITY;\n * @param rate = 1\n * @param repeat = 1\n */\nexport type ChannelOptions = {\n delay?: number\n duration?: number\n rate?: number\n repeat?: number\n}\n\nexport type AnimationOptions = {\n setTime: (time: number) => void\n}\n\n type Channel = {\n time: number\n delay: number\n duration: number\n rate: number\n repeat: number\n}\n\ntype Animation = {\n channel?: number;\n animation: {\n setTime: (time: number) => void\n }\n}\n\nlet channelHandles = 1;\nlet animationHandles = 1;\n\nexport class Timeline {\n time: number = 0;\n channels = new Map<number, Channel>();\n animations = new Map<number, Animation>();\n playing: boolean = false;\n lastEngineTime: number = -1;\n\n constructor() {\n }\n\n addChannel(props: ChannelOptions): number {\n const {delay = 0, duration = Number.POSITIVE_INFINITY, rate = 1, repeat = 1} = props;\n\n const channelId = channelHandles++;\n const channel: Channel = {\n time: 0,\n delay,\n duration,\n rate,\n repeat\n };\n this._setChannelTime(channel, this.time);\n this.channels.set(channelId, channel);\n\n return channelId;\n }\n\n removeChannel(channelId: number): void {\n this.channels.delete(channelId);\n\n for (const [animationHandle, animation] of this.animations) {\n if (animation.channel === channelId) {\n this.detachAnimation(animationHandle);\n }\n }\n }\n\n isFinished(channelId: number): boolean {\n const channel = this.channels.get(channelId);\n if (channel === undefined) {\n return false;\n }\n\n return this.time >= channel.delay + channel.duration * channel.repeat;\n }\n\n getTime(channelId?: number): number {\n if (channelId === undefined) {\n return this.time;\n }\n\n const channel = this.channels.get(channelId);\n\n if (channel === undefined) {\n return -1;\n }\n\n return channel.time;\n }\n\n setTime(time: number): void {\n this.time = Math.max(0, time);\n\n const channels = this.channels.values();\n for (const channel of channels) {\n this._setChannelTime(channel, this.time);\n }\n\n const animations = this.animations.values();\n for (const animationData of animations) {\n const {animation, channel} = animationData;\n animation.setTime(this.getTime(channel));\n }\n }\n\n play(): void {\n this.playing = true;\n }\n\n pause(): void {\n this.playing = false;\n this.lastEngineTime = -1;\n }\n\n reset(): void {\n this.setTime(0);\n }\n\n attachAnimation(animation: AnimationOptions, channelHandle?: number): number {\n const animationHandle = animationHandles++;\n\n this.animations.set(animationHandle, {\n animation,\n channel: channelHandle\n });\n\n animation.setTime(this.getTime(channelHandle));\n\n return animationHandle;\n }\n\n detachAnimation(channelId: number): void {\n this.animations.delete(channelId);\n }\n\n update(engineTime: number): void {\n if (this.playing) {\n if (this.lastEngineTime === -1) {\n this.lastEngineTime = engineTime;\n }\n this.setTime(this.time + (engineTime - this.lastEngineTime));\n this.lastEngineTime = engineTime;\n }\n }\n\n _setChannelTime(channel: Channel, time: number): void {\n const offsetTime = time - channel.delay;\n const totalDuration = channel.duration * channel.repeat;\n // Note(Tarek): Don't loop on final repeat.\n if (offsetTime >= totalDuration) {\n channel.time = channel.duration * channel.rate;\n } else {\n channel.time = Math.max(0, offsetTime) % channel.duration;\n channel.time *= channel.rate;\n }\n }\n}\n"],"mappings":"AAoCA,IAAIA,cAAc,GAAG,CAAC;AACtB,IAAIC,gBAAgB,GAAG,CAAC;AAExB,OAAO,MAAMC,QAAQ,CAAC;EAOpBC,WAAWA,CAAA,EAAG;IAAA,KANdC,IAAI,GAAW,CAAC;IAAA,KAChBC,QAAQ,GAAG,IAAIC,GAAG,CAAkB,CAAC;IAAA,KACrCC,UAAU,GAAG,IAAID,GAAG,CAAoB,CAAC;IAAA,KACzCE,OAAO,GAAY,KAAK;IAAA,KACxBC,cAAc,GAAW,CAAC,CAAC;EAG3B;EAEAC,UAAUA,CAACC,KAAqB,EAAU;IACxC,MAAM;MAACC,KAAK,GAAG,CAAC;MAAEC,QAAQ,GAAGC,MAAM,CAACC,iBAAiB;MAAEC,IAAI,GAAG,CAAC;MAAEC,MAAM,GAAG;IAAC,C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;IAC/B,IAAI,IAAI,CAAClC,OAAO,EAAE;MAChB,IAAI,IAAI,CAACC,cAAc,KAAK,CAAC,CAAC,EAAE;QAC9B,IAAI,CAACA,cAAc,GAAGiC,UAAU;MAClC;MACA,IAAI,CAACX,OAAO,CAAC,IAAI,CAAC3B,IAAI,IAAIsC,UAAU,GAAG,IAAI,CAACjC,cAAc,CAAC,CAAC;MAC5D,IAAI,CAACA,cAAc,GAAGiC,UAAU;IAClC;EACF;EAEAtB,eAAeA,CAACD,OAAgB,EAAEf,IAAY,EAAQ;IACpD,MAAMuC,UAAU,GAAGvC,IAAI,GAAGe,OAAO,CAACP,KAAK;IACvC,MAAMgC,aAAa,GAAGzB,OAAO,CAACN,QAAQ,GAAGM,OAAO,CAACF,MAAM;IAEvD,IAAI0B,UAAU,IAAIC,aAAa,EAAE;MAC/BzB,OAAO,CAACf,IAAI,GAAGe,OAAO,CAACN,QAAQ,GAAGM,OAAO,CAACH,IAAI;IAChD,CAAC,MAAM;MACLG,OAAO,CAACf,IAAI,GAAG4B,IAAI,CAACC,GAAG,CAAC,CAAC,EAAEU,UAAU,CAAC,GAAGxB,OAAO,CAACN,QAAQ;MACzDM,OAAO,CAACf,IAAI,IAAIe,OAAO,CAACH,IAAI;IAC9B;EACF;AACF"}
@@ -0,0 +1,23 @@
1
+ import type { AnimationProps } from './animation-props';
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,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"}
@@ -0,0 +1,7 @@
1
+ export class AnimationLoopTemplate {
2
+ constructor(animationProps) {}
3
+ async onInitialize(animationProps) {
4
+ return null;
5
+ }
6
+ }
7
+ //# sourceMappingURL=animation-loop-template.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"animation-loop-template.js","names":["AnimationLoopTemplate","constructor","animationProps","onInitialize"],"sources":["../../src/animation-loop/animation-loop-template.ts"],"sourcesContent":["import type {AnimationProps} from './animation-props';\n\n/**\n * Minimal class that represents a \"componentized\" rendering life cycle\n * (resource construction, repeated rendering, resource destruction)\n * \n * @note A motivation for this class compared to the raw animation loop is \n * that it simplifies TypeScript code by allowing resources to be typed unconditionally \n * since they are allocated in the constructor rather than in onInitialized\n * \n * @note Introduced in luma.gl v9\n * \n * @example AnimationLoopTemplate is intended to be subclassed, \n * but the subclass should not be instantiated directly. Instead the subclass\n * (i.e. the constructor of the subclass) should be used \n * as an argument to create an AnimationLoop.\n */\nexport abstract class AnimationLoopTemplate {\n constructor(animationProps?: AnimationProps) {}\n async onInitialize(animationProps: AnimationProps): Promise<unknown> { return null; }\n abstract onRender(animationProps: AnimationProps): unknown;\n abstract onFinalize(animationProps: AnimationProps): void;\n}\n"],"mappings":"AAiBA,OAAO,MAAeA,qBAAqB,CAAC;EAC1CC,WAAWA,CAACC,cAA+B,EAAE,CAAC;EAC9C,MAAMC,YAAYA,CAACD,cAA8B,EAAoB;IAAE,OAAO,IAAI;EAAE;AAGtF"}
@@ -1,20 +1,21 @@
1
- /// <reference types="offscreencanvas" />
2
- import { Device, DeviceProps } from '@luma.gl/api';
1
+ import { Device } from '@luma.gl/core';
3
2
  import { Timeline } from '../animation/timeline';
4
- import { AnimationProps } from '../lib/animation-props';
3
+ import { AnimationProps } from './animation-props';
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":"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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