@luma.gl/engine 9.0.0-beta.3 → 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.
Files changed (81) hide show
  1. package/dist/animation/key-frames.js +54 -54
  2. package/dist/animation/timeline.js +95 -100
  3. package/dist/animation-loop/animation-loop-template.js +17 -5
  4. package/dist/animation-loop/animation-loop.js +425 -356
  5. package/dist/animation-loop/animation-props.js +0 -1
  6. package/dist/animation-loop/make-animation-loop.js +27 -25
  7. package/dist/debug/copy-texture-to-image.js +39 -43
  8. package/dist/debug/debug-framebuffer.js +43 -39
  9. package/dist/debug/debug-shader-layout.js +24 -25
  10. package/dist/debug/pixel-data-utils.js +33 -36
  11. package/dist/dist.dev.js +3784 -8642
  12. package/dist/geometries/cone-geometry.js +12 -18
  13. package/dist/geometries/cube-geometry.js +189 -62
  14. package/dist/geometries/cylinder-geometry.js +10 -15
  15. package/dist/geometries/ico-sphere-geometry.js +142 -161
  16. package/dist/geometries/plane-geometry.js +94 -112
  17. package/dist/geometries/sphere-geometry.js +77 -96
  18. package/dist/geometries/truncated-cone-geometry.js +100 -118
  19. package/dist/geometry/geometry-table.js +0 -1
  20. package/dist/geometry/geometry-utils.js +35 -32
  21. package/dist/geometry/geometry.js +77 -71
  22. package/dist/geometry/gpu-geometry.js +80 -99
  23. package/dist/geometry/gpu-table.js +41 -1
  24. package/dist/index.cjs +81 -127
  25. package/dist/index.cjs.map +7 -0
  26. package/dist/index.js +27 -24
  27. package/dist/lib/clip-space.d.ts +1 -1
  28. package/dist/lib/clip-space.d.ts.map +1 -1
  29. package/dist/lib/clip-space.js +26 -30
  30. package/dist/lib/pipeline-factory.d.ts +1 -5
  31. package/dist/lib/pipeline-factory.d.ts.map +1 -1
  32. package/dist/lib/pipeline-factory.js +61 -68
  33. package/dist/model/model.d.ts +2 -2
  34. package/dist/model/model.d.ts.map +1 -1
  35. package/dist/model/model.js +539 -413
  36. package/dist/scenegraph/group-node.js +69 -84
  37. package/dist/scenegraph/model-node.js +32 -25
  38. package/dist/scenegraph/scenegraph-node.js +136 -124
  39. package/dist/shader-inputs.js +96 -58
  40. package/dist/transform/buffer-transform.js +65 -58
  41. package/dist/transform/texture-transform.d.ts.map +1 -1
  42. package/dist/transform/texture-transform.js +108 -115
  43. package/dist.min.js +3 -271
  44. package/package.json +10 -9
  45. package/src/lib/clip-space.ts +2 -1
  46. package/src/lib/pipeline-factory.ts +8 -21
  47. package/src/model/model.ts +5 -5
  48. package/src/transform/buffer-transform.ts +3 -3
  49. package/src/transform/texture-transform.ts +0 -2
  50. package/dist/animation/key-frames.js.map +0 -1
  51. package/dist/animation/timeline.js.map +0 -1
  52. package/dist/animation-loop/animation-loop-template.js.map +0 -1
  53. package/dist/animation-loop/animation-loop.js.map +0 -1
  54. package/dist/animation-loop/animation-props.js.map +0 -1
  55. package/dist/animation-loop/make-animation-loop.js.map +0 -1
  56. package/dist/debug/copy-texture-to-image.js.map +0 -1
  57. package/dist/debug/debug-framebuffer.js.map +0 -1
  58. package/dist/debug/debug-shader-layout.js.map +0 -1
  59. package/dist/debug/pixel-data-utils.js.map +0 -1
  60. package/dist/geometries/cone-geometry.js.map +0 -1
  61. package/dist/geometries/cube-geometry.js.map +0 -1
  62. package/dist/geometries/cylinder-geometry.js.map +0 -1
  63. package/dist/geometries/ico-sphere-geometry.js.map +0 -1
  64. package/dist/geometries/plane-geometry.js.map +0 -1
  65. package/dist/geometries/sphere-geometry.js.map +0 -1
  66. package/dist/geometries/truncated-cone-geometry.js.map +0 -1
  67. package/dist/geometry/geometry-table.js.map +0 -1
  68. package/dist/geometry/geometry-utils.js.map +0 -1
  69. package/dist/geometry/geometry.js.map +0 -1
  70. package/dist/geometry/gpu-geometry.js.map +0 -1
  71. package/dist/geometry/gpu-table.js.map +0 -1
  72. package/dist/index.js.map +0 -1
  73. package/dist/lib/clip-space.js.map +0 -1
  74. package/dist/lib/pipeline-factory.js.map +0 -1
  75. package/dist/model/model.js.map +0 -1
  76. package/dist/scenegraph/group-node.js.map +0 -1
  77. package/dist/scenegraph/model-node.js.map +0 -1
  78. package/dist/scenegraph/scenegraph-node.js.map +0 -1
  79. package/dist/shader-inputs.js.map +0 -1
  80. package/dist/transform/buffer-transform.js.map +0 -1
  81. 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
- constructor(keyFrames) {
3
- this.startIndex = -1;
4
- this.endIndex = -1;
5
- this.factor = 0;
6
- this.times = [];
7
- this.values = [];
8
- this._lastTime = -1;
9
- this.setKeyFrames(keyFrames);
10
- this.setTime(0);
11
- }
12
- setKeyFrames(keyFrames) {
13
- const numKeys = keyFrames.length;
14
- this.times.length = numKeys;
15
- this.values.length = numKeys;
16
- for (let i = 0; i < numKeys; ++i) {
17
- this.times[i] = keyFrames[i][0];
18
- this.values[i] = keyFrames[i][1];
19
- }
20
- this._calculateKeys(this._lastTime);
21
- }
22
- setTime(time) {
23
- time = Math.max(0, time);
24
- if (time !== this._lastTime) {
25
- this._calculateKeys(time);
26
- this._lastTime = time;
27
- }
28
- }
29
- getStartTime() {
30
- return this.times[this.startIndex];
31
- }
32
- getEndTime() {
33
- return this.times[this.endIndex];
34
- }
35
- getStartData() {
36
- return this.values[this.startIndex];
37
- }
38
- getEndData() {
39
- return this.values[this.endIndex];
40
- }
41
- _calculateKeys(time) {
42
- let index = 0;
43
- const numKeys = this.times.length;
44
- for (index = 0; index < numKeys - 2; ++index) {
45
- if (this.times[index + 1] > time) {
46
- break;
47
- }
48
- }
49
- this.startIndex = index;
50
- this.endIndex = index + 1;
51
- const startTime = this.times[this.startIndex];
52
- const endTime = this.times[this.endIndex];
53
- this.factor = Math.min(Math.max(0, (time - startTime) / (endTime - startTime)), 1);
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
- constructor() {
5
- this.time = 0;
6
- this.channels = new Map();
7
- this.animations = new Map();
8
- this.playing = false;
9
- this.lastEngineTime = -1;
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
- isFinished(channelId) {
39
- const channel = this.channels.get(channelId);
40
- if (channel === undefined) {
41
- return false;
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
- return this.time >= channel.delay + channel.duration * channel.repeat;
44
- }
45
- getTime(channelId) {
46
- if (channelId === undefined) {
47
- return this.time;
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
- const channel = this.channels.get(channelId);
50
- if (channel === undefined) {
51
- return -1;
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
- return channel.time;
54
- }
55
- setTime(time) {
56
- this.time = Math.max(0, time);
57
- const channels = this.channels.values();
58
- for (const channel of channels) {
59
- this._setChannelTime(channel, this.time);
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
- const animations = this.animations.values();
62
- for (const animationData of animations) {
63
- const {
64
- animation,
65
- channel
66
- } = animationData;
67
- animation.setTime(this.getTime(channel));
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
- play() {
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
- _setChannelTime(channel, time) {
102
- const offsetTime = time - channel.delay;
103
- const totalDuration = channel.duration * channel.repeat;
104
- if (offsetTime >= totalDuration) {
105
- channel.time = channel.duration * channel.rate;
106
- } else {
107
- channel.time = Math.max(0, offsetTime) % channel.duration;
108
- channel.time *= channel.rate;
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
- constructor(animationProps) {}
3
- async onInitialize(animationProps) {
4
- return null;
5
- }
17
+ constructor(animationProps) { }
18
+ async onInitialize(animationProps) { return null; }
6
19
  }
7
- //# sourceMappingURL=animation-loop-template.js.map