@luma.gl/engine 9.0.0-alpha.3 → 9.0.0-alpha.30

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 (148) hide show
  1. package/LICENSE +2 -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 +0 -20
  5. package/dist/animation/key-frames.js.map +1 -1
  6. package/dist/animation/timeline.d.ts +5 -5
  7. package/dist/animation/timeline.d.ts.map +1 -1
  8. package/dist/animation/timeline.js +0 -30
  9. package/dist/animation/timeline.js.map +1 -1
  10. package/dist/{lib → animation-loop}/animation-loop.d.ts +28 -29
  11. package/dist/animation-loop/animation-loop.d.ts.map +1 -0
  12. package/dist/{lib → animation-loop}/animation-loop.js +96 -175
  13. package/dist/animation-loop/animation-loop.js.map +1 -0
  14. package/dist/{lib → animation-loop}/animation-props.d.ts +7 -7
  15. package/dist/animation-loop/animation-props.d.ts.map +1 -0
  16. package/dist/animation-loop/animation-props.js.map +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 +28 -0
  20. package/dist/animation-loop/make-animation-loop.js.map +1 -0
  21. package/dist/animation-loop/render-loop.d.ts +23 -0
  22. package/dist/animation-loop/render-loop.d.ts.map +1 -0
  23. package/dist/animation-loop/render-loop.js +7 -0
  24. package/dist/animation-loop/render-loop.js.map +1 -0
  25. package/dist/dist.dev.js +14887 -0
  26. package/dist/geometries/cone-geometry.d.ts +1 -1
  27. package/dist/geometries/cone-geometry.d.ts.map +1 -1
  28. package/dist/geometries/cone-geometry.js +6 -5
  29. package/dist/geometries/cone-geometry.js.map +1 -1
  30. package/dist/geometries/cube-geometry.d.ts +2 -2
  31. package/dist/geometries/cube-geometry.d.ts.map +1 -1
  32. package/dist/geometries/cube-geometry.js +15 -8
  33. package/dist/geometries/cube-geometry.js.map +1 -1
  34. package/dist/geometries/cylinder-geometry.d.ts +1 -1
  35. package/dist/geometries/cylinder-geometry.d.ts.map +1 -1
  36. package/dist/geometries/cylinder-geometry.js +6 -5
  37. package/dist/geometries/cylinder-geometry.js.map +1 -1
  38. package/dist/geometries/ico-sphere-geometry.d.ts +2 -2
  39. package/dist/geometries/ico-sphere-geometry.d.ts.map +1 -1
  40. package/dist/geometries/ico-sphere-geometry.js +9 -18
  41. package/dist/geometries/ico-sphere-geometry.js.map +1 -1
  42. package/dist/geometries/plane-geometry.d.ts +2 -2
  43. package/dist/geometries/plane-geometry.d.ts.map +1 -1
  44. package/dist/geometries/plane-geometry.js +10 -19
  45. package/dist/geometries/plane-geometry.js.map +1 -1
  46. package/dist/geometries/sphere-geometry.d.ts +2 -2
  47. package/dist/geometries/sphere-geometry.d.ts.map +1 -1
  48. package/dist/geometries/sphere-geometry.js +9 -13
  49. package/dist/geometries/sphere-geometry.js.map +1 -1
  50. package/dist/geometries/truncated-cone-geometry.d.ts +2 -2
  51. package/dist/geometries/truncated-cone-geometry.d.ts.map +1 -1
  52. package/dist/geometries/truncated-cone-geometry.js +9 -14
  53. package/dist/geometries/truncated-cone-geometry.js.map +1 -1
  54. package/dist/geometry/geometry-table.d.ts +2 -2
  55. package/dist/geometry/geometry-table.d.ts.map +1 -1
  56. package/dist/geometry/geometry-table.js.map +1 -1
  57. package/dist/geometry/geometry-utils.d.ts.map +1 -1
  58. package/dist/geometry/geometry-utils.js +0 -9
  59. package/dist/geometry/geometry-utils.js.map +1 -1
  60. package/dist/geometry/geometry.d.ts +35 -58
  61. package/dist/geometry/geometry.d.ts.map +1 -1
  62. package/dist/geometry/geometry.js +26 -89
  63. package/dist/geometry/geometry.js.map +1 -1
  64. package/dist/geometry/primitive-utils.js.map +1 -1
  65. package/dist/index.cjs +2574 -0
  66. package/dist/index.d.ts +18 -9
  67. package/dist/index.d.ts.map +1 -1
  68. package/dist/index.js +20 -13
  69. package/dist/index.js.map +1 -1
  70. package/dist/lib/clip-space.d.ts +8 -0
  71. package/dist/lib/clip-space.d.ts.map +1 -1
  72. package/dist/lib/clip-space.js +36 -1
  73. package/dist/lib/clip-space.js.map +1 -1
  74. package/dist/lib/pipeline-factory.d.ts +19 -14
  75. package/dist/lib/pipeline-factory.d.ts.map +1 -1
  76. package/dist/lib/pipeline-factory.js +52 -63
  77. package/dist/lib/pipeline-factory.js.map +1 -1
  78. package/dist/{lib → model}/model-utils.d.ts +2 -2
  79. package/dist/model/model-utils.d.ts.map +1 -0
  80. package/dist/{lib → model}/model-utils.js +3 -8
  81. package/dist/model/model-utils.js.map +1 -0
  82. package/dist/model/model.d.ts +65 -0
  83. package/dist/model/model.d.ts.map +1 -0
  84. package/dist/{lib → model}/model.js +56 -75
  85. package/dist/model/model.js.map +1 -0
  86. package/dist/scenegraph/group-node.d.ts +21 -0
  87. package/dist/scenegraph/group-node.d.ts.map +1 -0
  88. package/dist/scenegraph/group-node.js +95 -0
  89. package/dist/scenegraph/group-node.js.map +1 -0
  90. package/dist/scenegraph/model-node.d.ts +18 -0
  91. package/dist/scenegraph/model-node.d.ts.map +1 -0
  92. package/dist/scenegraph/model-node.js +29 -0
  93. package/dist/scenegraph/model-node.js.map +1 -0
  94. package/dist/scenegraph/scenegraph-node.d.ts +56 -0
  95. package/dist/scenegraph/scenegraph-node.d.ts.map +1 -0
  96. package/dist/scenegraph/scenegraph-node.js +142 -0
  97. package/dist/scenegraph/scenegraph-node.js.map +1 -0
  98. package/dist/transform/transform.d.ts +98 -0
  99. package/dist/transform/transform.d.ts.map +1 -0
  100. package/dist/transform/transform.js +67 -0
  101. package/dist/transform/transform.js.map +1 -0
  102. package/dist.min.js +314 -0
  103. package/package.json +22 -12
  104. package/src/animation/timeline.ts +2 -2
  105. package/src/{lib → animation-loop}/animation-loop.ts +115 -97
  106. package/src/{lib → animation-loop}/animation-props.ts +6 -5
  107. package/src/animation-loop/make-animation-loop.ts +44 -0
  108. package/src/animation-loop/render-loop.ts +23 -0
  109. package/src/geometries/cone-geometry.ts +1 -1
  110. package/src/geometries/cube-geometry.ts +6 -3
  111. package/src/geometries/cylinder-geometry.ts +2 -2
  112. package/src/geometries/ico-sphere-geometry.ts +7 -6
  113. package/src/geometries/plane-geometry.ts +5 -4
  114. package/src/geometries/sphere-geometry.ts +4 -3
  115. package/src/geometries/truncated-cone-geometry.ts +4 -3
  116. package/src/geometry/geometry-table.ts +1 -1
  117. package/src/geometry/geometry-utils.ts +3 -3
  118. package/src/geometry/geometry.ts +72 -115
  119. package/src/index.ts +28 -12
  120. package/src/lib/clip-space.ts +17 -15
  121. package/src/lib/pipeline-factory.ts +60 -51
  122. package/src/{lib → model}/model-utils.ts +5 -4
  123. package/src/model/model.ts +226 -0
  124. package/src/scenegraph/group-node.ts +103 -0
  125. package/src/scenegraph/model-node.ts +50 -0
  126. package/src/scenegraph/scenegraph-node.ts +204 -0
  127. package/src/transform/transform.ts +246 -0
  128. package/dist/bundle.d.ts +0 -2
  129. package/dist/bundle.d.ts.map +0 -1
  130. package/dist/bundle.js +0 -5
  131. package/dist/bundle.js.map +0 -1
  132. package/dist/lib/animation-loop.d.ts.map +0 -1
  133. package/dist/lib/animation-loop.js.map +0 -1
  134. package/dist/lib/animation-props.d.ts.map +0 -1
  135. package/dist/lib/animation-props.js.map +0 -1
  136. package/dist/lib/model-utils.d.ts.map +0 -1
  137. package/dist/lib/model-utils.js.map +0 -1
  138. package/dist/lib/model.d.ts +0 -41
  139. package/dist/lib/model.d.ts.map +0 -1
  140. package/dist/lib/model.js.map +0 -1
  141. package/dist/lib/render-loop.d.ts +0 -14
  142. package/dist/lib/render-loop.d.ts.map +0 -1
  143. package/dist/lib/render-loop.js +0 -49
  144. package/dist/lib/render-loop.js.map +0 -1
  145. package/src/bundle.ts +0 -4
  146. package/src/lib/model.ts +0 -179
  147. package/src/lib/render-loop.ts +0 -58
  148. /package/dist/{lib → animation-loop}/animation-props.js +0 -0
package/LICENSE CHANGED
@@ -1,4 +1,5 @@
1
- Copyright (c) 2020 Urban Computing Foundation
1
+ Copyright (c) 2020 OpenJS Foundation
2
+ Copyright (c) 2020 vis.gl contributors
2
3
 
3
4
  This software includes parts initially developed by Uber and open sourced under MIT license.
4
5
  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"}
@@ -2,76 +2,56 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
2
  export class KeyFrames {
3
3
  constructor(keyFrames) {
4
4
  _defineProperty(this, "startIndex", -1);
5
-
6
5
  _defineProperty(this, "endIndex", -1);
7
-
8
6
  _defineProperty(this, "factor", 0);
9
-
10
7
  _defineProperty(this, "times", []);
11
-
12
8
  _defineProperty(this, "values", []);
13
-
14
9
  _defineProperty(this, "_lastTime", -1);
15
-
16
10
  this.setKeyFrames(keyFrames);
17
11
  this.setTime(0);
18
12
  }
19
-
20
13
  setKeyFrames(keyFrames) {
21
14
  const numKeys = keyFrames.length;
22
15
  this.times.length = numKeys;
23
16
  this.values.length = numKeys;
24
-
25
17
  for (let i = 0; i < numKeys; ++i) {
26
18
  this.times[i] = keyFrames[i][0];
27
19
  this.values[i] = keyFrames[i][1];
28
20
  }
29
-
30
21
  this._calculateKeys(this._lastTime);
31
22
  }
32
-
33
23
  setTime(time) {
34
24
  time = Math.max(0, time);
35
-
36
25
  if (time !== this._lastTime) {
37
26
  this._calculateKeys(time);
38
-
39
27
  this._lastTime = time;
40
28
  }
41
29
  }
42
-
43
30
  getStartTime() {
44
31
  return this.times[this.startIndex];
45
32
  }
46
-
47
33
  getEndTime() {
48
34
  return this.times[this.endIndex];
49
35
  }
50
-
51
36
  getStartData() {
52
37
  return this.values[this.startIndex];
53
38
  }
54
-
55
39
  getEndData() {
56
40
  return this.values[this.endIndex];
57
41
  }
58
-
59
42
  _calculateKeys(time) {
60
43
  let index = 0;
61
44
  const numKeys = this.times.length;
62
-
63
45
  for (index = 0; index < numKeys - 2; ++index) {
64
46
  if (this.times[index + 1] > time) {
65
47
  break;
66
48
  }
67
49
  }
68
-
69
50
  this.startIndex = index;
70
51
  this.endIndex = index + 1;
71
52
  const startTime = this.times[this.startIndex];
72
53
  const endTime = this.times[this.endIndex];
73
54
  this.factor = Math.min(Math.max(0, (time - startTime) / (endTime - startTime)), 1);
74
55
  }
75
-
76
56
  }
77
57
  //# 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,CAMkB;;AAAA,oCALrB,CAKqB;;AAAA,mCAJpB,EAIoB;;AAAA,oCAHxB,EAGwB;;AAAA,uCAFlB,CAAC,CAEiB;;AACpC,SAAKC,YAAL,CAAkBD,SAAlB;AACA,SAAKE,OAAL,CAAa,CAAb;AACD;;AAEDD,EAAAA,YAAY,CAACD,SAAD,EAAiC;AAC3C,UAAMG,OAAO,GAAGH,SAAS,CAACI,MAA1B;AACA,SAAKC,KAAL,CAAWD,MAAX,GAAoBD,OAApB;A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AAwBT,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","_defineProperty","setKeyFrames","setTime","numKeys","length","times","values","i","_calculateKeys","_lastTime","time","Math","max","getStartTime","startIndex","getEndTime","endIndex","getStartData","getEndData","index","startTime","endTime","factor","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)), 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,CAAA,EAAW;IACnB,OAAO,IAAI,CAACV,KAAK,CAAC,IAAI,CAACW,QAAQ,CAAC;EAClC;EAEAC,YAAYA,CAAA,EAAM;IAChB,OAAO,IAAI,CAACX,MAAM,CAAC,IAAI,CAACQ,UAAU,CAAC;EACrC;EAEAI,UAAUA,CAAA,EAAM;IACd,OAAO,IAAI,CAACZ,MAAM,CAAC,IAAI,CAACU,QAAQ,CAAC;EACnC;EAEAR,cAAcA,CAACE,IAAY,EAAQ;IACjC,IAAIS,KAAK,GAAG,CAAC;IACb,MAAMhB,OAAO,GAAG,IAAI,CAACE,KAAK,CAACD,MAAM;IAEjC,KAAKe,KAAK,GAAG,CAAC,EAAEA,KAAK,GAAGhB,OAAO,GAAG,CAAC,EAAE,EAAEgB,KAAK,EAAE;MAC5C,IAAI,IAAI,CAACd,KAAK,CAACc,KAAK,GAAG,CAAC,CAAC,GAAGT,IAAI,EAAE;QAChC;MACF;IACF;IAEA,IAAI,CAACI,UAAU,GAAGK,KAAK;IACvB,IAAI,CAACH,QAAQ,GAAGG,KAAK,GAAG,CAAC;IAEzB,MAAMC,SAAS,GAAG,IAAI,CAACf,KAAK,CAAC,IAAI,CAACS,UAAU,CAAC;IAC7C,MAAMO,OAAO,GAAG,IAAI,CAAChB,KAAK,CAAC,IAAI,CAACW,QAAQ,CAAC;IACzC,IAAI,CAACM,MAAM,GAAGX,IAAI,CAACY,GAAG,CAACZ,IAAI,CAACC,GAAG,CAAC,CAAC,EAAE,CAACF,IAAI,GAAGU,SAAS,KAAKC,OAAO,GAAGD,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC;EACpF;AACF"}
@@ -5,24 +5,24 @@
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 = {
25
- channel: number;
24
+ type Animation = {
25
+ channel?: number;
26
26
  animation: {
27
27
  setTime: (time: number) => void;
28
28
  };
@@ -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,MAAM,CAAA;CAChB,CAAA;AAED,oBAAY,gBAAgB,GAAG;IAC7B,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;CAChC,CAAA;AAEA,aAAK,OAAO,GAAG;IACd,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;CACf,CAAA;AAED,aAAK,SAAS,GAAG;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE;QACT,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;KAChC,CAAA;CACF,CAAA;AAKD,qBAAa,QAAQ;IACnB,IAAI,EAAE,MAAM,CAAK;IACjB,QAAQ,uBAA8B;IACtC,UAAU,yBAAgC;IAC1C,OAAO,EAAE,OAAO,CAAS;IACzB,cAAc,EAAE,MAAM,CAAM;;IAK5B,UAAU,CAAC,KAAK,EAAE,cAAc,GAAG,MAAM;IAiBzC,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAUnC,UAAU,CAAC,MAAM,EAAE,MAAM,GAA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Q,uBAA8B;IACtC,UAAU,yBAAgC;IAC1C,OAAO,EAAE,OAAO,CAAS;IACzB,cAAc,EAAE,MAAM,CAAM;;IAK5B,UAAU,CAAC,KAAK,EAAE,cAAc,GAAG,MAAM;IAiBzC,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAUnC,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;IASnC,OAAO,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM;IAchC,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAe3B,IAAI,IAAI,IAAI;IAIZ,KAAK,IAAI,IAAI;IAKb,KAAK,IAAI,IAAI;IAIb,eAAe,CAAC,SAAS,EAAE,gBAAgB,EAAE,aAAa,CAAC,EAAE,MAAM,GAAG,MAAM;IAa5E,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAIrC,MAAM,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAUhC,eAAe,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI;CAWtD"}
@@ -4,16 +4,11 @@ let animationHandles = 1;
4
4
  export class Timeline {
5
5
  constructor() {
6
6
  _defineProperty(this, "time", 0);
7
-
8
7
  _defineProperty(this, "channels", new Map());
9
-
10
8
  _defineProperty(this, "animations", new Map());
11
-
12
9
  _defineProperty(this, "playing", false);
13
-
14
10
  _defineProperty(this, "lastEngineTime", -1);
15
11
  }
16
-
17
12
  addChannel(props) {
18
13
  const {
19
14
  delay = 0,
@@ -29,57 +24,42 @@ export class Timeline {
29
24
  rate,
30
25
  repeat
31
26
  };
32
-
33
27
  this._setChannelTime(channel, this.time);
34
-
35
28
  this.channels.set(handle, channel);
36
29
  return handle;
37
30
  }
38
-
39
31
  removeChannel(handle) {
40
32
  this.channels.delete(handle);
41
-
42
33
  for (const [animationHandle, animation] of this.animations) {
43
34
  if (animation.channel === handle) {
44
35
  this.detachAnimation(animationHandle);
45
36
  }
46
37
  }
47
38
  }
48
-
49
39
  isFinished(handle) {
50
40
  const channel = this.channels.get(handle);
51
-
52
41
  if (channel === undefined) {
53
42
  return false;
54
43
  }
55
-
56
44
  return this.time >= channel.delay + channel.duration * channel.repeat;
57
45
  }
58
-
59
46
  getTime(handle) {
60
47
  if (handle === undefined) {
61
48
  return this.time;
62
49
  }
63
-
64
50
  const channel = this.channels.get(handle);
65
-
66
51
  if (channel === undefined) {
67
52
  return -1;
68
53
  }
69
-
70
54
  return channel.time;
71
55
  }
72
-
73
56
  setTime(time) {
74
57
  this.time = Math.max(0, time);
75
58
  const channels = this.channels.values();
76
-
77
59
  for (const channel of channels) {
78
60
  this._setChannelTime(channel, this.time);
79
61
  }
80
-
81
62
  const animations = this.animations.values();
82
-
83
63
  for (const animationData of animations) {
84
64
  const {
85
65
  animation,
@@ -88,20 +68,16 @@ export class Timeline {
88
68
  animation.setTime(this.getTime(channel));
89
69
  }
90
70
  }
91
-
92
71
  play() {
93
72
  this.playing = true;
94
73
  }
95
-
96
74
  pause() {
97
75
  this.playing = false;
98
76
  this.lastEngineTime = -1;
99
77
  }
100
-
101
78
  reset() {
102
79
  this.setTime(0);
103
80
  }
104
-
105
81
  attachAnimation(animation, channelHandle) {
106
82
  const animationHandle = animationHandles++;
107
83
  this.animations.set(animationHandle, {
@@ -111,26 +87,21 @@ export class Timeline {
111
87
  animation.setTime(this.getTime(channelHandle));
112
88
  return animationHandle;
113
89
  }
114
-
115
90
  detachAnimation(handle) {
116
91
  this.animations.delete(handle);
117
92
  }
118
-
119
93
  update(engineTime) {
120
94
  if (this.playing) {
121
95
  if (this.lastEngineTime === -1) {
122
96
  this.lastEngineTime = engineTime;
123
97
  }
124
-
125
98
  this.setTime(this.time + (engineTime - this.lastEngineTime));
126
99
  this.lastEngineTime = engineTime;
127
100
  }
128
101
  }
129
-
130
102
  _setChannelTime(channel, time) {
131
103
  const offsetTime = time - channel.delay;
132
104
  const totalDuration = channel.duration * channel.repeat;
133
-
134
105
  if (offsetTime >= totalDuration) {
135
106
  channel.time = channel.duration * channel.rate;
136
107
  } else {
@@ -138,6 +109,5 @@ export class Timeline {
138
109
  channel.time *= channel.rate;
139
110
  }
140
111
  }
141
-
142
112
  }
143
113
  //# 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,QAAL,CAAcC,GAAd,CAAkBL,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,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","_defineProperty","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"],"sources":["../../src/animation/timeline.ts"],"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 */\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 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"],"mappings":";AAmCA,IAAIA,cAAc,GAAG,CAAC;AACtB,IAAIC,gBAAgB,GAAG,CAAC;AAExB,OAAO,MAAMC,QAAQ,CAAC;EAOpBC,WAAWA,CAAA,EAAG;IAAAC,eAAA,eANC,CAAC;IAAAA,eAAA,mBACL,IAAIC,GAAG,CAAkB,CAAC;IAAAD,eAAA,qBACxB,IAAIC,GAAG,CAAoB,CAAC;IAAAD,eAAA,kBACtB,KAAK;IAAAA,eAAA,yBACC,CAAC,CAAC;EAG3B;EAEAE,UAAUA,CAACC,KAAqB,EAAU;IACxC,MAAM;MAACC,KAAK,GAAG,CAAC;MAAEC,QAAQ,GAAGC,MAAM,CAACC,iBAAiB;MAAEC,IAAI,GAAG,CAAC;MAAEC,MAAM,GAAG;IAAC,CAAC,GAAGN,KAAK;IAEpF,MAAMO,MAAM,GAAGd,cAAc,EAAE;IAC/B,MAAMe,OAAgB,GAAG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AAGK,UAAU;MAClC;MACA,IAAI,CAACb,OAAO,CAAC,IAAI,CAACd,IAAI,IAAI2B,UAAU,GAAG,IAAI,CAACL,cAAc,CAAC,CAAC;MAC5D,IAAI,CAACA,cAAc,GAAGK,UAAU;IAClC;EACF;EAEA1B,eAAeA,CAACF,OAAgB,EAAEC,IAAY,EAAQ;IACpD,MAAM4B,UAAU,GAAG5B,IAAI,GAAGD,OAAO,CAACP,KAAK;IACvC,MAAMqC,aAAa,GAAG9B,OAAO,CAACN,QAAQ,GAAGM,OAAO,CAACF,MAAM;IAEvD,IAAI+B,UAAU,IAAIC,aAAa,EAAE;MAC/B9B,OAAO,CAACC,IAAI,GAAGD,OAAO,CAACN,QAAQ,GAAGM,OAAO,CAACH,IAAI;IAChD,CAAC,MAAM;MACLG,OAAO,CAACC,IAAI,GAAGe,IAAI,CAACC,GAAG,CAAC,CAAC,EAAEY,UAAU,CAAC,GAAG7B,OAAO,CAACN,QAAQ;MACzDM,OAAO,CAACC,IAAI,IAAID,OAAO,CAACH,IAAI;IAC9B;EACF;AACF"}
@@ -1,48 +1,50 @@
1
- import { Device, DeviceProps } from '@luma.gl/api';
1
+ import { Device } from '@luma.gl/core';
2
2
  import { Timeline } from '../animation/timeline';
3
- import { AnimationProps } from '../lib/animation-props';
3
+ import { AnimationProps } from './animation-props';
4
4
  import { Stats, Stat } from '@probe.gl/stats';
5
5
  /** AnimationLoop properties */
6
- export declare type AnimationLoopProps = {
7
- onCreateDevice?: (props: DeviceProps) => Promise<Device>;
6
+ export type AnimationLoopProps = {
7
+ device: Device | Promise<Device>;
8
8
  onAddHTML?: (div: HTMLDivElement) => string;
9
- onInitialize?: (animationProps: AnimationProps) => void;
10
- onRender?: (animationProps: AnimationProps) => void;
9
+ onInitialize?: (animationProps: AnimationProps) => Promise<unknown>;
10
+ onRender?: (animationProps: AnimationProps) => unknown;
11
11
  onFinalize?: (animationProps: AnimationProps) => void;
12
12
  onError?: (reason: Error) => void;
13
- device?: Device;
14
- deviceProps?: DeviceProps;
15
13
  stats?: Stats;
16
- debug?: boolean;
14
+ autoResizeViewport?: boolean;
15
+ autoResizeDrawingBuffer?: boolean;
16
+ useDevicePixels?: number | boolean;
17
+ };
18
+ export type MutableAnimationLoopProps = {
17
19
  autoResizeViewport?: boolean;
18
20
  autoResizeDrawingBuffer?: boolean;
19
21
  useDevicePixels?: number | boolean;
20
22
  };
21
23
  /** Convenient animation loop */
22
- export default class AnimationLoop {
23
- device: Device;
24
- canvas: HTMLCanvasElement;
24
+ export declare class AnimationLoop {
25
+ device: Device | null;
26
+ canvas: HTMLCanvasElement | OffscreenCanvas | null;
25
27
  props: Required<AnimationLoopProps>;
26
- animationProps: AnimationProps;
27
- timeline: Timeline;
28
+ animationProps: AnimationProps | null;
29
+ timeline: Timeline | null;
28
30
  stats: Stats;
29
31
  cpuTime: Stat;
30
32
  gpuTime: Stat;
31
33
  frameRate: Stat;
32
34
  display: any;
33
- needsRedraw: string | null;
35
+ needsRedraw: string | false;
34
36
  _initialized: boolean;
35
37
  _running: boolean;
36
38
  _animationFrameId: any;
37
39
  _nextFramePromise: Promise<AnimationLoop> | null;
38
- _resolveNextFrame: ((AnimationLoop: any) => void) | null;
40
+ _resolveNextFrame: ((animationLoop: AnimationLoop) => void) | null;
39
41
  _cpuStartTime: number;
40
- constructor(props?: AnimationLoopProps);
42
+ constructor(props: AnimationLoopProps);
41
43
  destroy(): void;
42
44
  /** @deprecated Use .destroy() */
43
45
  delete(): void;
44
46
  setNeedsRedraw(reason: string): this;
45
- setProps(props: AnimationLoopProps): this;
47
+ setProps(props: MutableAnimationLoopProps): this;
46
48
  /** Starts a render loop if not already running */
47
49
  start(): Promise<this>;
48
50
  /** Explicitly draw a frame */
@@ -52,22 +54,19 @@ export default class AnimationLoop {
52
54
  detachTimeline(): void;
53
55
  waitForRender(): Promise<AnimationLoop>;
54
56
  toDataURL(): Promise<string>;
55
- onCreateDevice(deviceProps: DeviceProps): Promise<Device>;
56
- onInitialize(animationProps: AnimationProps): {} | void;
57
- onRender(animationProps: AnimationProps): void;
58
- onFinalize(animationProps: AnimationProps): void;
59
57
  _initialize(): void;
60
58
  _setDisplay(display: any): void;
61
59
  _requestAnimationFrame(): void;
62
60
  _cancelAnimationFrame(): void;
63
61
  _animationFrame(): void;
64
- _renderFrame(props: AnimationProps): void;
62
+ _renderFrame(animationProps: AnimationProps): void;
65
63
  _clearNeedsRedraw(): void;
66
64
  _setupFrame(): void;
67
- _initializeCallbackData(): void;
68
- _updateCallbackData(): void;
69
- /** Either uses supplied or existing context, or calls provided callback to create one */
70
- _createDevice(): Promise<void>;
65
+ _initializeAnimationProps(): void;
66
+ _getAnimationProps(): AnimationProps;
67
+ _updateAnimationProps(): void;
68
+ /** Wait for supplied device */
69
+ _initDevice(): Promise<void>;
71
70
  _createInfoDiv(): void;
72
71
  _getSizeAndAspect(): {
73
72
  width: number;
@@ -84,7 +83,7 @@ export default class AnimationLoop {
84
83
  _beginTimers(): void;
85
84
  _endTimers(): void;
86
85
  _startEventHandling(): void;
87
- _onMousemove(e: any): void;
88
- _onMouseleave(e: any): void;
86
+ _onMousemove(event: Event): void;
87
+ _onMouseleave(event: Event): void;
89
88
  }
90
89
  //# 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":"AAEA,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,E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