@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.
- package/LICENSE +3 -1
- package/dist/animation/key-frames.d.ts +1 -1
- package/dist/animation/key-frames.d.ts.map +1 -1
- package/dist/animation/key-frames.js +6 -27
- package/dist/animation/key-frames.js.map +1 -1
- package/dist/animation/timeline.d.ts +8 -8
- package/dist/animation/timeline.d.ts.map +1 -1
- package/dist/animation/timeline.js +18 -49
- package/dist/animation/timeline.js.map +1 -1
- package/dist/animation-loop/animation-loop-template.d.ts +23 -0
- package/dist/animation-loop/animation-loop-template.d.ts.map +1 -0
- package/dist/animation-loop/animation-loop-template.js +7 -0
- package/dist/animation-loop/animation-loop-template.js.map +1 -0
- package/dist/{lib → animation-loop}/animation-loop.d.ts +30 -22
- package/dist/animation-loop/animation-loop.d.ts.map +1 -0
- package/dist/{lib → animation-loop}/animation-loop.js +77 -192
- package/dist/animation-loop/animation-loop.js.map +1 -0
- package/dist/{lib → animation-loop}/animation-props.d.ts +2 -3
- package/dist/animation-loop/animation-props.d.ts.map +1 -0
- package/dist/animation-loop/animation-props.js.map +1 -0
- package/dist/animation-loop/make-animation-loop.d.ts +6 -0
- package/dist/animation-loop/make-animation-loop.d.ts.map +1 -0
- package/dist/animation-loop/make-animation-loop.js +28 -0
- package/dist/animation-loop/make-animation-loop.js.map +1 -0
- package/dist/debug/copy-texture-to-image.d.ts +26 -0
- package/dist/debug/copy-texture-to-image.d.ts.map +1 -0
- package/dist/debug/copy-texture-to-image.js +46 -0
- package/dist/debug/copy-texture-to-image.js.map +1 -0
- package/dist/debug/debug-framebuffer.d.ts +11 -0
- package/dist/debug/debug-framebuffer.d.ts.map +1 -0
- package/dist/debug/debug-framebuffer.js +43 -0
- package/dist/debug/debug-framebuffer.js.map +1 -0
- package/dist/debug/debug-shader-layout.d.ts +9 -0
- package/dist/debug/debug-shader-layout.d.ts.map +1 -0
- package/dist/debug/debug-shader-layout.js +28 -0
- package/dist/debug/debug-shader-layout.js.map +1 -0
- package/dist/debug/pixel-data-utils.d.ts +24 -0
- package/dist/debug/pixel-data-utils.d.ts.map +1 -0
- package/dist/debug/pixel-data-utils.js +41 -0
- package/dist/debug/pixel-data-utils.js.map +1 -0
- package/dist/dist.dev.js +10081 -0
- package/dist/geometries/cone-geometry.d.ts +1 -1
- package/dist/geometries/cone-geometry.d.ts.map +1 -1
- package/dist/geometries/cone-geometry.js +6 -5
- package/dist/geometries/cone-geometry.js.map +1 -1
- package/dist/geometries/cube-geometry.d.ts +2 -2
- package/dist/geometries/cube-geometry.d.ts.map +1 -1
- package/dist/geometries/cube-geometry.js +16 -10
- package/dist/geometries/cube-geometry.js.map +1 -1
- package/dist/geometries/cylinder-geometry.d.ts +1 -1
- package/dist/geometries/cylinder-geometry.d.ts.map +1 -1
- package/dist/geometries/cylinder-geometry.js +6 -5
- package/dist/geometries/cylinder-geometry.js.map +1 -1
- package/dist/geometries/ico-sphere-geometry.d.ts +2 -2
- package/dist/geometries/ico-sphere-geometry.d.ts.map +1 -1
- package/dist/geometries/ico-sphere-geometry.js +10 -19
- package/dist/geometries/ico-sphere-geometry.js.map +1 -1
- package/dist/geometries/plane-geometry.d.ts +2 -2
- package/dist/geometries/plane-geometry.d.ts.map +1 -1
- package/dist/geometries/plane-geometry.js +14 -23
- package/dist/geometries/plane-geometry.js.map +1 -1
- package/dist/geometries/sphere-geometry.d.ts +2 -2
- package/dist/geometries/sphere-geometry.d.ts.map +1 -1
- package/dist/geometries/sphere-geometry.js +9 -13
- package/dist/geometries/sphere-geometry.js.map +1 -1
- package/dist/geometries/truncated-cone-geometry.d.ts +2 -4
- package/dist/geometries/truncated-cone-geometry.d.ts.map +1 -1
- package/dist/geometries/truncated-cone-geometry.js +9 -25
- package/dist/geometries/truncated-cone-geometry.js.map +1 -1
- package/dist/geometry/geometry-table.d.ts +2 -2
- package/dist/geometry/geometry-table.d.ts.map +1 -1
- package/dist/geometry/geometry-table.js.map +1 -1
- package/dist/geometry/geometry-utils.d.ts.map +1 -1
- package/dist/geometry/geometry-utils.js +0 -9
- package/dist/geometry/geometry-utils.js.map +1 -1
- package/dist/geometry/geometry.d.ts +43 -43
- package/dist/geometry/geometry.d.ts.map +1 -1
- package/dist/geometry/geometry.js +20 -82
- package/dist/geometry/geometry.js.map +1 -1
- package/dist/geometry/gpu-geometry.d.ts +37 -0
- package/dist/geometry/gpu-geometry.d.ts.map +1 -0
- package/dist/geometry/gpu-geometry.js +110 -0
- package/dist/geometry/gpu-geometry.js.map +1 -0
- package/dist/geometry/gpu-table.d.ts +1 -0
- package/dist/geometry/gpu-table.d.ts.map +1 -0
- package/dist/geometry/gpu-table.js +2 -0
- package/dist/geometry/gpu-table.js.map +1 -0
- package/dist/index.cjs +3128 -0
- package/dist/index.d.ts +24 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +23 -14
- package/dist/index.js.map +1 -1
- package/dist/lib/clip-space.d.ts +8 -0
- package/dist/lib/clip-space.d.ts.map +1 -1
- package/dist/lib/clip-space.js +47 -0
- package/dist/lib/clip-space.js.map +1 -1
- package/dist/lib/pipeline-factory.d.ts +12 -45
- package/dist/lib/pipeline-factory.d.ts.map +1 -1
- package/dist/lib/pipeline-factory.js +42 -168
- package/dist/lib/pipeline-factory.js.map +1 -1
- package/dist/model/model.d.ts +206 -0
- package/dist/model/model.d.ts.map +1 -0
- package/dist/model/model.js +435 -0
- package/dist/model/model.js.map +1 -0
- package/dist/scenegraph/group-node.d.ts +21 -0
- package/dist/scenegraph/group-node.d.ts.map +1 -0
- package/dist/scenegraph/group-node.js +94 -0
- package/dist/scenegraph/group-node.js.map +1 -0
- package/dist/scenegraph/model-node.d.ts +18 -0
- package/dist/scenegraph/model-node.d.ts.map +1 -0
- package/dist/scenegraph/model-node.js +28 -0
- package/dist/scenegraph/model-node.js.map +1 -0
- package/dist/scenegraph/scenegraph-node.d.ts +56 -0
- package/dist/scenegraph/scenegraph-node.d.ts.map +1 -0
- package/dist/scenegraph/scenegraph-node.js +141 -0
- package/dist/scenegraph/scenegraph-node.js.map +1 -0
- package/dist/shader-inputs.d.ts +63 -0
- package/dist/shader-inputs.d.ts.map +1 -0
- package/dist/shader-inputs.js +66 -0
- package/dist/shader-inputs.js.map +1 -0
- package/dist/transform/buffer-transform.d.ts +35 -0
- package/dist/transform/buffer-transform.d.ts.map +1 -0
- package/dist/transform/buffer-transform.js +62 -0
- package/dist/transform/buffer-transform.js.map +1 -0
- package/dist/transform/texture-transform.d.ts +57 -0
- package/dist/transform/texture-transform.d.ts.map +1 -0
- package/dist/transform/texture-transform.js +122 -0
- package/dist/transform/texture-transform.js.map +1 -0
- package/dist.min.js +293 -0
- package/package.json +21 -12
- package/src/animation/timeline.ts +15 -14
- package/src/animation-loop/animation-loop-template.ts +23 -0
- package/src/{lib → animation-loop}/animation-loop.ts +99 -88
- package/src/{lib → animation-loop}/animation-props.ts +1 -1
- package/src/animation-loop/make-animation-loop.ts +44 -0
- package/src/debug/copy-texture-to-image.ts +72 -0
- package/src/debug/debug-framebuffer.ts +57 -0
- package/src/debug/debug-shader-layout.ts +38 -0
- package/src/debug/pixel-data-utils.ts +57 -0
- package/src/geometries/cone-geometry.ts +1 -1
- package/src/geometries/cube-geometry.ts +47 -45
- package/src/geometries/cylinder-geometry.ts +2 -2
- package/src/geometries/ico-sphere-geometry.ts +6 -5
- package/src/geometries/plane-geometry.ts +5 -4
- package/src/geometries/sphere-geometry.ts +4 -3
- package/src/geometries/truncated-cone-geometry.ts +4 -13
- package/src/geometry/geometry-table.ts +1 -1
- package/src/geometry/geometry-utils.ts +3 -3
- package/src/geometry/geometry.ts +65 -110
- package/src/geometry/gpu-geometry.ts +125 -0
- package/src/geometry/gpu-table.ts +41 -0
- package/src/index.ts +34 -10
- package/src/lib/clip-space.ts +22 -21
- package/src/lib/pipeline-factory.ts +51 -168
- package/src/model/model.ts +726 -0
- package/src/scenegraph/group-node.ts +103 -0
- package/src/scenegraph/model-node.ts +50 -0
- package/src/scenegraph/scenegraph-node.ts +204 -0
- package/src/shader-inputs.ts +150 -0
- package/src/transform/buffer-transform.ts +94 -0
- package/src/transform/texture-transform.ts +169 -0
- package/dist/bundle.d.ts +0 -2
- package/dist/bundle.d.ts.map +0 -1
- package/dist/bundle.js +0 -5
- package/dist/bundle.js.map +0 -1
- package/dist/geometry/primitive-utils.d.ts +0 -1
- package/dist/geometry/primitive-utils.d.ts.map +0 -1
- package/dist/geometry/primitive-utils.js +0 -2
- package/dist/geometry/primitive-utils.js.map +0 -1
- package/dist/lib/animation-loop.d.ts.map +0 -1
- package/dist/lib/animation-loop.js.map +0 -1
- package/dist/lib/animation-props.d.ts.map +0 -1
- package/dist/lib/animation-props.js.map +0 -1
- package/dist/lib/model-utils.d.ts +0 -5
- package/dist/lib/model-utils.d.ts.map +0 -1
- package/dist/lib/model-utils.js +0 -45
- package/dist/lib/model-utils.js.map +0 -1
- package/dist/lib/model.d.ts +0 -41
- package/dist/lib/model.d.ts.map +0 -1
- package/dist/lib/model.js +0 -182
- package/dist/lib/model.js.map +0 -1
- package/dist/lib/render-loop.d.ts +0 -14
- package/dist/lib/render-loop.d.ts.map +0 -1
- package/dist/lib/render-loop.js +0 -49
- package/dist/lib/render-loop.js.map +0 -1
- package/src/bundle.ts +0 -4
- package/src/geometry/primitive-utils.ts +0 -30
- package/src/lib/model-utils.ts +0 -124
- package/src/lib/model.ts +0 -183
- package/src/lib/render-loop.ts +0 -58
- /package/dist/{lib → animation-loop}/animation-props.js +0 -0
package/LICENSE
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"key-frames.d.ts","sourceRoot":"","sources":["../../src/animation/key-frames.ts"],"names":[],"mappings":"AACA,
|
|
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
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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,"
|
|
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,CAACK,IAAY,EAAQ;IAC1BA,IAAI,GAAGC,IAAI,CAACC,GAAG,CAAC,CAAC,EAAEF,IAAI,CAAC;IAExB,IAAIA,IAAI,KAAK,IAAI,CAACP,SAAS,EAAE;MAC3B,IAAI,CAACM,cAAc,CAACC,IAAI,CAAC;MACzB,IAAI,CAACP,SAAS,GAAGO,IAAI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8
|
-
export
|
|
8
|
+
export type ChannelOptions = {
|
|
9
9
|
delay?: number;
|
|
10
10
|
duration?: number;
|
|
11
11
|
rate?: number;
|
|
12
12
|
repeat?: number;
|
|
13
13
|
};
|
|
14
|
-
export
|
|
14
|
+
export type AnimationOptions = {
|
|
15
15
|
setTime: (time: number) => void;
|
|
16
16
|
};
|
|
17
|
-
|
|
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
|
-
|
|
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(
|
|
39
|
-
isFinished(
|
|
40
|
-
getTime(
|
|
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(
|
|
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":"
|
|
1
|
+
{"version":3,"file":"timeline.d.ts","sourceRoot":"","sources":["../../src/animation/timeline.ts"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,KAA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AE,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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
|
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
|
-
|
|
36
|
-
return handle;
|
|
27
|
+
this.channels.set(channelId, channel);
|
|
28
|
+
return channelId;
|
|
37
29
|
}
|
|
38
|
-
|
|
39
|
-
|
|
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 ===
|
|
33
|
+
if (animation.channel === channelId) {
|
|
44
34
|
this.detachAnimation(animationHandle);
|
|
45
35
|
}
|
|
46
36
|
}
|
|
47
37
|
}
|
|
48
|
-
|
|
49
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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,"
|
|
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,CAAC,GAAGN,KAAK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AI,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 @@
|
|
|
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
|
-
|
|
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 '
|
|
3
|
+
import { AnimationProps } from './animation-props';
|
|
5
4
|
import { Stats, Stat } from '@probe.gl/stats';
|
|
6
5
|
/** AnimationLoop properties */
|
|
7
|
-
export
|
|
8
|
-
|
|
6
|
+
export type AnimationLoopProps = {
|
|
7
|
+
device: Device | Promise<Device>;
|
|
9
8
|
onAddHTML?: (div: HTMLDivElement) => string;
|
|
10
|
-
onInitialize?: (animationProps: AnimationProps) =>
|
|
11
|
-
onRender?: (animationProps: AnimationProps) =>
|
|
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
|
-
|
|
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: ((
|
|
40
|
+
_resolveNextFrame: ((animationLoop: AnimationLoop) => void) | null;
|
|
40
41
|
_cpuStartTime: number;
|
|
41
|
-
constructor(props
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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(
|
|
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
|
-
/**
|
|
68
|
-
|
|
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
|
-
|
|
83
|
-
|
|
90
|
+
_beginFrameTimers(): void;
|
|
91
|
+
_endFrameTimers(): void;
|
|
84
92
|
_startEventHandling(): void;
|
|
85
|
-
_onMousemove(
|
|
86
|
-
_onMouseleave(
|
|
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,C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