@luma.gl/engine 9.0.0-beta.4 → 9.0.0-beta.5
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.js +54 -54
- package/dist/animation/timeline.js +95 -100
- package/dist/animation-loop/animation-loop-template.js +17 -5
- package/dist/animation-loop/animation-loop.js +425 -356
- package/dist/animation-loop/animation-props.js +0 -1
- package/dist/animation-loop/make-animation-loop.js +27 -25
- package/dist/debug/copy-texture-to-image.js +39 -43
- package/dist/debug/debug-framebuffer.js +43 -39
- package/dist/debug/debug-shader-layout.js +24 -25
- package/dist/debug/pixel-data-utils.js +33 -36
- package/dist/dist.dev.js +3784 -8643
- package/dist/geometries/cone-geometry.js +12 -18
- package/dist/geometries/cube-geometry.js +189 -62
- package/dist/geometries/cylinder-geometry.js +10 -15
- package/dist/geometries/ico-sphere-geometry.js +142 -161
- package/dist/geometries/plane-geometry.js +94 -112
- package/dist/geometries/sphere-geometry.js +77 -96
- package/dist/geometries/truncated-cone-geometry.js +100 -118
- package/dist/geometry/geometry-table.js +0 -1
- package/dist/geometry/geometry-utils.js +35 -32
- package/dist/geometry/geometry.js +77 -71
- package/dist/geometry/gpu-geometry.js +80 -99
- package/dist/geometry/gpu-table.js +41 -1
- package/dist/index.cjs +80 -127
- package/dist/index.cjs.map +7 -0
- package/dist/index.js +27 -24
- package/dist/lib/clip-space.js +25 -30
- package/dist/lib/pipeline-factory.d.ts +1 -5
- package/dist/lib/pipeline-factory.d.ts.map +1 -1
- package/dist/lib/pipeline-factory.js +61 -68
- package/dist/model/model.d.ts +2 -2
- package/dist/model/model.d.ts.map +1 -1
- package/dist/model/model.js +539 -413
- package/dist/scenegraph/group-node.js +69 -84
- package/dist/scenegraph/model-node.js +32 -25
- package/dist/scenegraph/scenegraph-node.js +136 -124
- package/dist/shader-inputs.js +96 -58
- package/dist/transform/buffer-transform.js +65 -58
- package/dist/transform/texture-transform.d.ts.map +1 -1
- package/dist/transform/texture-transform.js +108 -115
- package/dist.min.js +2 -272
- package/package.json +10 -9
- package/src/lib/pipeline-factory.ts +8 -21
- package/src/model/model.ts +5 -5
- package/src/transform/buffer-transform.ts +3 -3
- package/src/transform/texture-transform.ts +0 -2
- package/dist/animation/key-frames.js.map +0 -1
- package/dist/animation/timeline.js.map +0 -1
- package/dist/animation-loop/animation-loop-template.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/debug/copy-texture-to-image.js.map +0 -1
- package/dist/debug/debug-framebuffer.js.map +0 -1
- package/dist/debug/debug-shader-layout.js.map +0 -1
- package/dist/debug/pixel-data-utils.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/gpu-geometry.js.map +0 -1
- package/dist/geometry/gpu-table.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lib/clip-space.js.map +0 -1
- package/dist/lib/pipeline-factory.js.map +0 -1
- package/dist/model/model.js.map +0 -1
- package/dist/scenegraph/group-node.js.map +0 -1
- package/dist/scenegraph/model-node.js.map +0 -1
- package/dist/scenegraph/scenegraph-node.js.map +0 -1
- package/dist/shader-inputs.js.map +0 -1
- package/dist/transform/buffer-transform.js.map +0 -1
- package/dist/transform/texture-transform.js.map +0 -1
|
@@ -1,56 +1,56 @@
|
|
|
1
|
+
/** Holds a list of key frames (timestamped values) */
|
|
1
2
|
export class KeyFrames {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
3
|
+
startIndex = -1;
|
|
4
|
+
endIndex = -1;
|
|
5
|
+
factor = 0;
|
|
6
|
+
times = [];
|
|
7
|
+
values = [];
|
|
8
|
+
_lastTime = -1;
|
|
9
|
+
constructor(keyFrames) {
|
|
10
|
+
this.setKeyFrames(keyFrames);
|
|
11
|
+
this.setTime(0);
|
|
12
|
+
}
|
|
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);
|
|
22
|
+
}
|
|
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);
|
|
55
|
+
}
|
|
55
56
|
}
|
|
56
|
-
//# sourceMappingURL=key-frames.js.map
|
|
@@ -1,112 +1,107 @@
|
|
|
1
|
+
// luma.gl, MIT license
|
|
2
|
+
// Copyright (c) vis.gl contributors
|
|
1
3
|
let channelHandles = 1;
|
|
2
4
|
let animationHandles = 1;
|
|
3
5
|
export class Timeline {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
addChannel(props) {
|
|
12
|
-
const {
|
|
13
|
-
delay = 0,
|
|
14
|
-
duration = Number.POSITIVE_INFINITY,
|
|
15
|
-
rate = 1,
|
|
16
|
-
repeat = 1
|
|
17
|
-
} = props;
|
|
18
|
-
const channelId = channelHandles++;
|
|
19
|
-
const channel = {
|
|
20
|
-
time: 0,
|
|
21
|
-
delay,
|
|
22
|
-
duration,
|
|
23
|
-
rate,
|
|
24
|
-
repeat
|
|
25
|
-
};
|
|
26
|
-
this._setChannelTime(channel, this.time);
|
|
27
|
-
this.channels.set(channelId, channel);
|
|
28
|
-
return channelId;
|
|
29
|
-
}
|
|
30
|
-
removeChannel(channelId) {
|
|
31
|
-
this.channels.delete(channelId);
|
|
32
|
-
for (const [animationHandle, animation] of this.animations) {
|
|
33
|
-
if (animation.channel === channelId) {
|
|
34
|
-
this.detachAnimation(animationHandle);
|
|
35
|
-
}
|
|
6
|
+
time = 0;
|
|
7
|
+
channels = new Map();
|
|
8
|
+
animations = new Map();
|
|
9
|
+
playing = false;
|
|
10
|
+
lastEngineTime = -1;
|
|
11
|
+
constructor() {
|
|
36
12
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
13
|
+
addChannel(props) {
|
|
14
|
+
const { delay = 0, duration = Number.POSITIVE_INFINITY, rate = 1, repeat = 1 } = props;
|
|
15
|
+
const channelId = channelHandles++;
|
|
16
|
+
const channel = {
|
|
17
|
+
time: 0,
|
|
18
|
+
delay,
|
|
19
|
+
duration,
|
|
20
|
+
rate,
|
|
21
|
+
repeat
|
|
22
|
+
};
|
|
23
|
+
this._setChannelTime(channel, this.time);
|
|
24
|
+
this.channels.set(channelId, channel);
|
|
25
|
+
return channelId;
|
|
42
26
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
27
|
+
removeChannel(channelId) {
|
|
28
|
+
this.channels.delete(channelId);
|
|
29
|
+
for (const [animationHandle, animation] of this.animations) {
|
|
30
|
+
if (animation.channel === channelId) {
|
|
31
|
+
this.detachAnimation(animationHandle);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
48
34
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
35
|
+
isFinished(channelId) {
|
|
36
|
+
const channel = this.channels.get(channelId);
|
|
37
|
+
if (channel === undefined) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
return this.time >= channel.delay + channel.duration * channel.repeat;
|
|
52
41
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
42
|
+
getTime(channelId) {
|
|
43
|
+
if (channelId === undefined) {
|
|
44
|
+
return this.time;
|
|
45
|
+
}
|
|
46
|
+
const channel = this.channels.get(channelId);
|
|
47
|
+
if (channel === undefined) {
|
|
48
|
+
return -1;
|
|
49
|
+
}
|
|
50
|
+
return channel.time;
|
|
60
51
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
52
|
+
setTime(time) {
|
|
53
|
+
this.time = Math.max(0, time);
|
|
54
|
+
const channels = this.channels.values();
|
|
55
|
+
for (const channel of channels) {
|
|
56
|
+
this._setChannelTime(channel, this.time);
|
|
57
|
+
}
|
|
58
|
+
const animations = this.animations.values();
|
|
59
|
+
for (const animationData of animations) {
|
|
60
|
+
const { animation, channel } = animationData;
|
|
61
|
+
animation.setTime(this.getTime(channel));
|
|
62
|
+
}
|
|
68
63
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
this.playing = true;
|
|
72
|
-
}
|
|
73
|
-
pause() {
|
|
74
|
-
this.playing = false;
|
|
75
|
-
this.lastEngineTime = -1;
|
|
76
|
-
}
|
|
77
|
-
reset() {
|
|
78
|
-
this.setTime(0);
|
|
79
|
-
}
|
|
80
|
-
attachAnimation(animation, channelHandle) {
|
|
81
|
-
const animationHandle = animationHandles++;
|
|
82
|
-
this.animations.set(animationHandle, {
|
|
83
|
-
animation,
|
|
84
|
-
channel: channelHandle
|
|
85
|
-
});
|
|
86
|
-
animation.setTime(this.getTime(channelHandle));
|
|
87
|
-
return animationHandle;
|
|
88
|
-
}
|
|
89
|
-
detachAnimation(channelId) {
|
|
90
|
-
this.animations.delete(channelId);
|
|
91
|
-
}
|
|
92
|
-
update(engineTime) {
|
|
93
|
-
if (this.playing) {
|
|
94
|
-
if (this.lastEngineTime === -1) {
|
|
95
|
-
this.lastEngineTime = engineTime;
|
|
96
|
-
}
|
|
97
|
-
this.setTime(this.time + (engineTime - this.lastEngineTime));
|
|
98
|
-
this.lastEngineTime = engineTime;
|
|
64
|
+
play() {
|
|
65
|
+
this.playing = true;
|
|
99
66
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
|
|
67
|
+
pause() {
|
|
68
|
+
this.playing = false;
|
|
69
|
+
this.lastEngineTime = -1;
|
|
70
|
+
}
|
|
71
|
+
reset() {
|
|
72
|
+
this.setTime(0);
|
|
73
|
+
}
|
|
74
|
+
attachAnimation(animation, channelHandle) {
|
|
75
|
+
const animationHandle = animationHandles++;
|
|
76
|
+
this.animations.set(animationHandle, {
|
|
77
|
+
animation,
|
|
78
|
+
channel: channelHandle
|
|
79
|
+
});
|
|
80
|
+
animation.setTime(this.getTime(channelHandle));
|
|
81
|
+
return animationHandle;
|
|
82
|
+
}
|
|
83
|
+
detachAnimation(channelId) {
|
|
84
|
+
this.animations.delete(channelId);
|
|
85
|
+
}
|
|
86
|
+
update(engineTime) {
|
|
87
|
+
if (this.playing) {
|
|
88
|
+
if (this.lastEngineTime === -1) {
|
|
89
|
+
this.lastEngineTime = engineTime;
|
|
90
|
+
}
|
|
91
|
+
this.setTime(this.time + (engineTime - this.lastEngineTime));
|
|
92
|
+
this.lastEngineTime = engineTime;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
_setChannelTime(channel, time) {
|
|
96
|
+
const offsetTime = time - channel.delay;
|
|
97
|
+
const totalDuration = channel.duration * channel.repeat;
|
|
98
|
+
// Note(Tarek): Don't loop on final repeat.
|
|
99
|
+
if (offsetTime >= totalDuration) {
|
|
100
|
+
channel.time = channel.duration * channel.rate;
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
channel.time = Math.max(0, offsetTime) % channel.duration;
|
|
104
|
+
channel.time *= channel.rate;
|
|
105
|
+
}
|
|
109
106
|
}
|
|
110
|
-
}
|
|
111
107
|
}
|
|
112
|
-
//# sourceMappingURL=timeline.js.map
|
|
@@ -1,7 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal class that represents a "componentized" rendering life cycle
|
|
3
|
+
* (resource construction, repeated rendering, resource destruction)
|
|
4
|
+
*
|
|
5
|
+
* @note A motivation for this class compared to the raw animation loop is
|
|
6
|
+
* that it simplifies TypeScript code by allowing resources to be typed unconditionally
|
|
7
|
+
* since they are allocated in the constructor rather than in onInitialized
|
|
8
|
+
*
|
|
9
|
+
* @note Introduced in luma.gl v9
|
|
10
|
+
*
|
|
11
|
+
* @example AnimationLoopTemplate is intended to be subclassed,
|
|
12
|
+
* but the subclass should not be instantiated directly. Instead the subclass
|
|
13
|
+
* (i.e. the constructor of the subclass) should be used
|
|
14
|
+
* as an argument to create an AnimationLoop.
|
|
15
|
+
*/
|
|
1
16
|
export class AnimationLoopTemplate {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
return null;
|
|
5
|
-
}
|
|
17
|
+
constructor(animationProps) { }
|
|
18
|
+
async onInitialize(animationProps) { return null; }
|
|
6
19
|
}
|
|
7
|
-
//# sourceMappingURL=animation-loop-template.js.map
|