@luma.gl/engine 9.0.0-alpha.14 → 9.0.0-alpha.16
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/dist/animation/key-frames.d.ts +1 -1
- package/dist/animation/key-frames.d.ts.map +1 -1
- package/dist/animation/key-frames.js +51 -72
- package/dist/animation/timeline.d.ts +4 -4
- package/dist/animation/timeline.d.ts.map +1 -1
- package/dist/animation/timeline.js +94 -131
- package/dist/animation-loop/animation-loop.d.ts +2 -3
- package/dist/animation-loop/animation-loop.d.ts.map +1 -1
- package/dist/animation-loop/animation-loop.js +414 -473
- package/dist/animation-loop/animation-props.d.ts +1 -2
- package/dist/animation-loop/animation-props.d.ts.map +1 -1
- package/dist/animation-loop/animation-props.js +0 -1
- package/dist/animation-loop/make-animation-loop.d.ts +1 -1
- package/dist/animation-loop/make-animation-loop.d.ts.map +1 -1
- package/dist/animation-loop/make-animation-loop.js +26 -31
- package/dist/animation-loop/render-loop.js +17 -7
- package/dist/bundle.js +2 -2
- package/dist/dist.min.js +31 -0
- package/dist/es5/animation/key-frames.js +84 -0
- package/dist/es5/animation/key-frames.js.map +1 -0
- package/dist/es5/animation/timeline.js +183 -0
- package/dist/es5/animation/timeline.js.map +1 -0
- package/dist/es5/animation-loop/animation-loop.js +534 -0
- package/dist/es5/animation-loop/animation-loop.js.map +1 -0
- package/dist/es5/animation-loop/animation-props.js +2 -0
- package/dist/es5/animation-loop/animation-props.js.map +1 -0
- package/dist/es5/animation-loop/make-animation-loop.js +53 -0
- package/dist/es5/animation-loop/make-animation-loop.js.map +1 -0
- package/dist/es5/animation-loop/render-loop.js +39 -0
- package/dist/es5/animation-loop/render-loop.js.map +1 -0
- package/dist/es5/bundle.js +6 -0
- package/dist/es5/bundle.js.map +1 -0
- package/dist/es5/geometries/cone-geometry.js +43 -0
- package/dist/es5/geometries/cone-geometry.js.map +1 -0
- package/dist/es5/geometries/cube-geometry.js +84 -0
- package/dist/es5/geometries/cube-geometry.js.map +1 -0
- package/dist/es5/geometries/cylinder-geometry.js +39 -0
- package/dist/es5/geometries/cylinder-geometry.js.map +1 -0
- package/dist/es5/geometries/ico-sphere-geometry.js +185 -0
- package/dist/es5/geometries/ico-sphere-geometry.js.map +1 -0
- package/dist/es5/geometries/plane-geometry.js +137 -0
- package/dist/es5/geometries/plane-geometry.js.map +1 -0
- package/dist/es5/geometries/sphere-geometry.js +120 -0
- package/dist/es5/geometries/sphere-geometry.js.map +1 -0
- package/dist/es5/geometries/truncated-cone-geometry.js +160 -0
- package/dist/es5/geometries/truncated-cone-geometry.js.map +1 -0
- package/dist/es5/geometry/geometry-table.js +2 -0
- package/dist/es5/geometry/geometry-table.js.map +1 -0
- package/dist/es5/geometry/geometry-utils.js +39 -0
- package/dist/es5/geometry/geometry-utils.js.map +1 -0
- package/dist/es5/geometry/geometry.js +150 -0
- package/dist/es5/geometry/geometry.js.map +1 -0
- package/dist/es5/geometry/primitive-utils.js +2 -0
- package/dist/es5/geometry/primitive-utils.js.map +1 -0
- package/dist/es5/index.js +112 -0
- package/dist/es5/index.js.map +1 -0
- package/dist/es5/lib/clip-space.js +2 -0
- package/dist/es5/lib/clip-space.js.map +1 -0
- package/dist/es5/lib/model-utils.js +52 -0
- package/dist/es5/lib/model-utils.js.map +1 -0
- package/dist/es5/lib/model.js +173 -0
- package/dist/es5/lib/model.js.map +1 -0
- package/dist/es5/lib/pipeline-factory.js +244 -0
- package/dist/es5/lib/pipeline-factory.js.map +1 -0
- package/dist/esm/animation/key-frames.js +57 -0
- package/dist/esm/animation/key-frames.js.map +1 -0
- package/dist/esm/animation/timeline.js +113 -0
- package/dist/esm/animation/timeline.js.map +1 -0
- package/dist/esm/animation-loop/animation-loop.js +367 -0
- package/dist/esm/animation-loop/animation-loop.js.map +1 -0
- package/dist/esm/animation-loop/animation-props.js +2 -0
- package/dist/esm/animation-loop/animation-props.js.map +1 -0
- package/dist/esm/animation-loop/make-animation-loop.js +28 -0
- package/dist/esm/animation-loop/make-animation-loop.js.map +1 -0
- package/dist/esm/animation-loop/render-loop.js +7 -0
- package/dist/esm/animation-loop/render-loop.js.map +1 -0
- package/dist/esm/bundle.js +4 -0
- package/dist/esm/bundle.js.map +1 -0
- package/dist/esm/geometries/cone-geometry.js +21 -0
- package/dist/esm/geometries/cone-geometry.js.map +1 -0
- package/dist/esm/geometries/cube-geometry.js +67 -0
- package/dist/esm/geometries/cube-geometry.js.map +1 -0
- package/dist/esm/geometries/cylinder-geometry.js +18 -0
- package/dist/esm/geometries/cylinder-geometry.js.map +1 -0
- package/dist/esm/geometries/ico-sphere-geometry.js +170 -0
- package/dist/esm/geometries/ico-sphere-geometry.js.map +1 -0
- package/dist/esm/geometries/plane-geometry.js +119 -0
- package/dist/esm/geometries/plane-geometry.js.map +1 -0
- package/dist/esm/geometries/sphere-geometry.js +102 -0
- package/dist/esm/geometries/sphere-geometry.js.map +1 -0
- package/dist/esm/geometries/truncated-cone-geometry.js +136 -0
- package/dist/esm/geometries/truncated-cone-geometry.js.map +1 -0
- package/dist/esm/geometry/geometry-table.js +2 -0
- package/dist/esm/geometry/geometry-table.js.map +1 -0
- package/dist/esm/geometry/geometry-utils.js +37 -0
- package/dist/esm/geometry/geometry-utils.js.map +1 -0
- package/dist/esm/geometry/geometry.js +119 -0
- package/dist/esm/geometry/geometry.js.map +1 -0
- package/dist/esm/geometry/primitive-utils.js +2 -0
- package/dist/esm/geometry/primitive-utils.js.map +1 -0
- package/dist/esm/index.js +16 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/lib/clip-space.js +2 -0
- package/dist/esm/lib/clip-space.js.map +1 -0
- package/dist/esm/lib/model-utils.js +40 -0
- package/dist/esm/lib/model-utils.js.map +1 -0
- package/dist/esm/lib/model.js +146 -0
- package/dist/esm/lib/model.js.map +1 -0
- package/dist/esm/lib/pipeline-factory.js +180 -0
- package/dist/esm/lib/pipeline-factory.js.map +1 -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 +12 -17
- package/dist/geometries/cube-geometry.d.ts +1 -1
- package/dist/geometries/cube-geometry.d.ts.map +1 -1
- package/dist/geometries/cube-geometry.js +187 -56
- 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 +10 -14
- package/dist/geometries/ico-sphere-geometry.d.ts +1 -1
- package/dist/geometries/ico-sphere-geometry.d.ts.map +1 -1
- package/dist/geometries/ico-sphere-geometry.js +141 -170
- package/dist/geometries/plane-geometry.d.ts +1 -1
- package/dist/geometries/plane-geometry.d.ts.map +1 -1
- package/dist/geometries/plane-geometry.js +93 -121
- package/dist/geometries/sphere-geometry.d.ts +1 -1
- package/dist/geometries/sphere-geometry.d.ts.map +1 -1
- package/dist/geometries/sphere-geometry.js +76 -100
- package/dist/geometries/truncated-cone-geometry.d.ts +1 -1
- package/dist/geometries/truncated-cone-geometry.d.ts.map +1 -1
- package/dist/geometries/truncated-cone-geometry.js +104 -131
- package/dist/geometry/geometry-table.d.ts +1 -1
- package/dist/geometry/geometry-table.d.ts.map +1 -1
- package/dist/geometry/geometry-table.js +0 -1
- package/dist/geometry/geometry-utils.js +22 -41
- package/dist/geometry/geometry.d.ts +4 -4
- package/dist/geometry/geometry.d.ts.map +1 -1
- package/dist/geometry/geometry.js +96 -142
- package/dist/geometry/primitive-utils.js +30 -1
- package/dist/index.js +20 -16
- package/dist/lib/clip-space.js +50 -1
- package/dist/lib/model-utils.js +97 -29
- package/dist/lib/model.d.ts +1 -1
- package/dist/lib/model.d.ts.map +1 -1
- package/dist/lib/model.js +122 -166
- package/dist/lib/pipeline-factory.d.ts +3 -3
- package/dist/lib/pipeline-factory.d.ts.map +1 -1
- package/dist/lib/pipeline-factory.js +136 -204
- package/package.json +12 -11
- package/dist/animation/key-frames.js.map +0 -1
- package/dist/animation/timeline.js.map +0 -1
- package/dist/animation-loop/animation-loop.js.map +0 -1
- package/dist/animation-loop/animation-props.js.map +0 -1
- package/dist/animation-loop/make-animation-loop.js.map +0 -1
- package/dist/animation-loop/render-loop.js.map +0 -1
- package/dist/bundle.js.map +0 -1
- package/dist/geometries/cone-geometry.js.map +0 -1
- package/dist/geometries/cube-geometry.js.map +0 -1
- package/dist/geometries/cylinder-geometry.js.map +0 -1
- package/dist/geometries/ico-sphere-geometry.js.map +0 -1
- package/dist/geometries/plane-geometry.js.map +0 -1
- package/dist/geometries/sphere-geometry.js.map +0 -1
- package/dist/geometries/truncated-cone-geometry.js.map +0 -1
- package/dist/geometry/geometry-table.js.map +0 -1
- package/dist/geometry/geometry-utils.js.map +0 -1
- package/dist/geometry/geometry.js.map +0 -1
- package/dist/geometry/primitive-utils.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lib/clip-space.js.map +0 -1
- package/dist/lib/model-utils.js.map +0 -1
- package/dist/lib/model.js.map +0 -1
- package/dist/lib/pipeline-factory.js.map +0 -1
|
@@ -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
|
-
|
|
1
|
+
/** Holds a list of key frames (timestamped values) */
|
|
2
2
|
export class KeyFrames {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
_defineProperty(this, "values", []);
|
|
13
|
-
|
|
14
|
-
_defineProperty(this, "_lastTime", -1);
|
|
15
|
-
|
|
16
|
-
this.setKeyFrames(keyFrames);
|
|
17
|
-
this.setTime(0);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
setKeyFrames(keyFrames) {
|
|
21
|
-
const numKeys = keyFrames.length;
|
|
22
|
-
this.times.length = numKeys;
|
|
23
|
-
this.values.length = numKeys;
|
|
24
|
-
|
|
25
|
-
for (let i = 0; i < numKeys; ++i) {
|
|
26
|
-
this.times[i] = keyFrames[i][0];
|
|
27
|
-
this.values[i] = keyFrames[i][1];
|
|
3
|
+
constructor(keyFrames) {
|
|
4
|
+
this.startIndex = -1;
|
|
5
|
+
this.endIndex = -1;
|
|
6
|
+
this.factor = 0;
|
|
7
|
+
this.times = [];
|
|
8
|
+
this.values = [];
|
|
9
|
+
this._lastTime = -1;
|
|
10
|
+
this.setKeyFrames(keyFrames);
|
|
11
|
+
this.setTime(0);
|
|
28
12
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
this._lastTime = time;
|
|
13
|
+
setKeyFrames(keyFrames) {
|
|
14
|
+
const numKeys = keyFrames.length;
|
|
15
|
+
this.times.length = numKeys;
|
|
16
|
+
this.values.length = numKeys;
|
|
17
|
+
for (let i = 0; i < numKeys; ++i) {
|
|
18
|
+
this.times[i] = keyFrames[i][0];
|
|
19
|
+
this.values[i] = keyFrames[i][1];
|
|
20
|
+
}
|
|
21
|
+
this._calculateKeys(this._lastTime);
|
|
40
22
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
23
|
+
setTime(time) {
|
|
24
|
+
time = Math.max(0, time);
|
|
25
|
+
if (time !== this._lastTime) {
|
|
26
|
+
this._calculateKeys(time);
|
|
27
|
+
this._lastTime = time;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
getStartTime() {
|
|
31
|
+
return this.times[this.startIndex];
|
|
32
|
+
}
|
|
33
|
+
getEndTime() {
|
|
34
|
+
return this.times[this.endIndex];
|
|
35
|
+
}
|
|
36
|
+
getStartData() {
|
|
37
|
+
return this.values[this.startIndex];
|
|
38
|
+
}
|
|
39
|
+
getEndData() {
|
|
40
|
+
return this.values[this.endIndex];
|
|
41
|
+
}
|
|
42
|
+
_calculateKeys(time) {
|
|
43
|
+
let index = 0;
|
|
44
|
+
const numKeys = this.times.length;
|
|
45
|
+
for (index = 0; index < numKeys - 2; ++index) {
|
|
46
|
+
if (this.times[index + 1] > time) {
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
this.startIndex = index;
|
|
51
|
+
this.endIndex = index + 1;
|
|
52
|
+
const startTime = this.times[this.startIndex];
|
|
53
|
+
const endTime = this.times[this.endIndex];
|
|
54
|
+
this.factor = Math.min(Math.max(0, (time - startTime) / (endTime - startTime)), 1);
|
|
67
55
|
}
|
|
68
|
-
|
|
69
|
-
this.startIndex = index;
|
|
70
|
-
this.endIndex = index + 1;
|
|
71
|
-
const startTime = this.times[this.startIndex];
|
|
72
|
-
const endTime = this.times[this.endIndex];
|
|
73
|
-
this.factor = Math.min(Math.max(0, (time - startTime) / (endTime - startTime)), 1);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
56
|
}
|
|
77
|
-
//# sourceMappingURL=key-frames.js.map
|
|
@@ -5,23 +5,23 @@
|
|
|
5
5
|
* @param rate = 1
|
|
6
6
|
* @param repeat = 1
|
|
7
7
|
*/
|
|
8
|
-
export
|
|
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;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timeline.d.ts","sourceRoot":"","sources":["../../src/animation/timeline.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACF,
|
|
1
|
+
{"version":3,"file":"timeline.d.ts","sourceRoot":"","sources":["../../src/animation/timeline.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACF,MAAM,MAAM,cAAc,GAAG;IAC5B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,EAAE,MAAM,GAAG,IAAI;IAUhC,eAAe,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI;CAWtD"}
|
|
@@ -1,143 +1,106 @@
|
|
|
1
|
-
|
|
1
|
+
// luma.gl, MIT license
|
|
2
2
|
let channelHandles = 1;
|
|
3
3
|
let animationHandles = 1;
|
|
4
4
|
export class Timeline {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
_defineProperty(this, "playing", false);
|
|
13
|
-
|
|
14
|
-
_defineProperty(this, "lastEngineTime", -1);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
addChannel(props) {
|
|
18
|
-
const {
|
|
19
|
-
delay = 0,
|
|
20
|
-
duration = Number.POSITIVE_INFINITY,
|
|
21
|
-
rate = 1,
|
|
22
|
-
repeat = 1
|
|
23
|
-
} = props;
|
|
24
|
-
const handle = channelHandles++;
|
|
25
|
-
const channel = {
|
|
26
|
-
time: 0,
|
|
27
|
-
delay,
|
|
28
|
-
duration,
|
|
29
|
-
rate,
|
|
30
|
-
repeat
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
this._setChannelTime(channel, this.time);
|
|
34
|
-
|
|
35
|
-
this.channels.set(handle, channel);
|
|
36
|
-
return handle;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
removeChannel(handle) {
|
|
40
|
-
this.channels.delete(handle);
|
|
41
|
-
|
|
42
|
-
for (const [animationHandle, animation] of this.animations) {
|
|
43
|
-
if (animation.channel === handle) {
|
|
44
|
-
this.detachAnimation(animationHandle);
|
|
45
|
-
}
|
|
5
|
+
constructor() {
|
|
6
|
+
this.time = 0;
|
|
7
|
+
this.channels = new Map();
|
|
8
|
+
this.animations = new Map();
|
|
9
|
+
this.playing = false;
|
|
10
|
+
this.lastEngineTime = -1;
|
|
46
11
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
12
|
+
addChannel(props) {
|
|
13
|
+
const { delay = 0, duration = Number.POSITIVE_INFINITY, rate = 1, repeat = 1 } = props;
|
|
14
|
+
const handle = channelHandles++;
|
|
15
|
+
const channel = {
|
|
16
|
+
time: 0,
|
|
17
|
+
delay,
|
|
18
|
+
duration,
|
|
19
|
+
rate,
|
|
20
|
+
repeat
|
|
21
|
+
};
|
|
22
|
+
this._setChannelTime(channel, this.time);
|
|
23
|
+
this.channels.set(handle, channel);
|
|
24
|
+
return handle;
|
|
54
25
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
26
|
+
removeChannel(handle) {
|
|
27
|
+
this.channels.delete(handle);
|
|
28
|
+
for (const [animationHandle, animation] of this.animations) {
|
|
29
|
+
if (animation.channel === handle) {
|
|
30
|
+
this.detachAnimation(animationHandle);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
62
33
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
34
|
+
isFinished(handle) {
|
|
35
|
+
const channel = this.channels.get(handle);
|
|
36
|
+
if (channel === undefined) {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
return this.time >= channel.delay + channel.duration * channel.repeat;
|
|
68
40
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
this._setChannelTime(channel, this.time);
|
|
41
|
+
getTime(handle) {
|
|
42
|
+
if (handle === undefined) {
|
|
43
|
+
return this.time;
|
|
44
|
+
}
|
|
45
|
+
const channel = this.channels.get(handle);
|
|
46
|
+
if (channel === undefined) {
|
|
47
|
+
return -1;
|
|
48
|
+
}
|
|
49
|
+
return channel.time;
|
|
79
50
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
51
|
+
setTime(time) {
|
|
52
|
+
this.time = Math.max(0, time);
|
|
53
|
+
const channels = this.channels.values();
|
|
54
|
+
for (const channel of channels) {
|
|
55
|
+
this._setChannelTime(channel, this.time);
|
|
56
|
+
}
|
|
57
|
+
const animations = this.animations.values();
|
|
58
|
+
for (const animationData of animations) {
|
|
59
|
+
const { animation, channel } = animationData;
|
|
60
|
+
animation.setTime(this.getTime(channel));
|
|
61
|
+
}
|
|
89
62
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
play() {
|
|
93
|
-
this.playing = true;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
pause() {
|
|
97
|
-
this.playing = false;
|
|
98
|
-
this.lastEngineTime = -1;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
reset() {
|
|
102
|
-
this.setTime(0);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
attachAnimation(animation, channelHandle) {
|
|
106
|
-
const animationHandle = animationHandles++;
|
|
107
|
-
this.animations.set(animationHandle, {
|
|
108
|
-
animation,
|
|
109
|
-
channel: channelHandle
|
|
110
|
-
});
|
|
111
|
-
animation.setTime(this.getTime(channelHandle));
|
|
112
|
-
return animationHandle;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
detachAnimation(handle) {
|
|
116
|
-
this.animations.delete(handle);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
update(engineTime) {
|
|
120
|
-
if (this.playing) {
|
|
121
|
-
if (this.lastEngineTime === -1) {
|
|
122
|
-
this.lastEngineTime = engineTime;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
this.setTime(this.time + (engineTime - this.lastEngineTime));
|
|
126
|
-
this.lastEngineTime = engineTime;
|
|
63
|
+
play() {
|
|
64
|
+
this.playing = true;
|
|
127
65
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
66
|
+
pause() {
|
|
67
|
+
this.playing = false;
|
|
68
|
+
this.lastEngineTime = -1;
|
|
69
|
+
}
|
|
70
|
+
reset() {
|
|
71
|
+
this.setTime(0);
|
|
72
|
+
}
|
|
73
|
+
attachAnimation(animation, channelHandle) {
|
|
74
|
+
const animationHandle = animationHandles++;
|
|
75
|
+
this.animations.set(animationHandle, {
|
|
76
|
+
animation,
|
|
77
|
+
channel: channelHandle
|
|
78
|
+
});
|
|
79
|
+
animation.setTime(this.getTime(channelHandle));
|
|
80
|
+
return animationHandle;
|
|
81
|
+
}
|
|
82
|
+
detachAnimation(handle) {
|
|
83
|
+
this.animations.delete(handle);
|
|
84
|
+
}
|
|
85
|
+
update(engineTime) {
|
|
86
|
+
if (this.playing) {
|
|
87
|
+
if (this.lastEngineTime === -1) {
|
|
88
|
+
this.lastEngineTime = engineTime;
|
|
89
|
+
}
|
|
90
|
+
this.setTime(this.time + (engineTime - this.lastEngineTime));
|
|
91
|
+
this.lastEngineTime = engineTime;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
_setChannelTime(channel, time) {
|
|
95
|
+
const offsetTime = time - channel.delay;
|
|
96
|
+
const totalDuration = channel.duration * channel.repeat;
|
|
97
|
+
// Note(Tarek): Don't loop on final repeat.
|
|
98
|
+
if (offsetTime >= totalDuration) {
|
|
99
|
+
channel.time = channel.duration * channel.rate;
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
channel.time = Math.max(0, offsetTime) % channel.duration;
|
|
103
|
+
channel.time *= channel.rate;
|
|
104
|
+
}
|
|
139
105
|
}
|
|
140
|
-
}
|
|
141
|
-
|
|
142
106
|
}
|
|
143
|
-
//# sourceMappingURL=timeline.js.map
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
/// <reference types="offscreencanvas" />
|
|
2
1
|
import { Device } from '@luma.gl/api';
|
|
3
2
|
import { Timeline } from '../animation/timeline';
|
|
4
3
|
import { AnimationProps } from './animation-props';
|
|
5
4
|
import { Stats, Stat } from '@probe.gl/stats';
|
|
6
5
|
/** AnimationLoop properties */
|
|
7
|
-
export
|
|
6
|
+
export type AnimationLoopProps = {
|
|
8
7
|
device: Device | Promise<Device>;
|
|
9
8
|
onAddHTML?: (div: HTMLDivElement) => string;
|
|
10
9
|
onInitialize?: (animationProps: AnimationProps) => Promise<unknown>;
|
|
@@ -16,7 +15,7 @@ export declare type AnimationLoopProps = {
|
|
|
16
15
|
autoResizeDrawingBuffer?: boolean;
|
|
17
16
|
useDevicePixels?: number | boolean;
|
|
18
17
|
};
|
|
19
|
-
export
|
|
18
|
+
export type MutableAnimationLoopProps = {
|
|
20
19
|
autoResizeViewport?: boolean;
|
|
21
20
|
autoResizeDrawingBuffer?: boolean;
|
|
22
21
|
useDevicePixels?: number | boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"animation-loop.d.ts","sourceRoot":"","sources":["../../src/animation-loop/animation-loop.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"animation-loop.d.ts","sourceRoot":"","sources":["../../src/animation-loop/animation-loop.ts"],"names":[],"mappings":"AAEA,OAAO,EAAO,MAAM,EAAC,MAAM,cAAc,CAAC;AAE1C,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,E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