@woosh/meep-engine 2.92.23 → 2.93.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/build/meep.cjs +99 -129
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +99 -129
- package/package.json +6 -4
- package/src/core/geom/Quaternion.d.ts +29 -14
- package/src/core/geom/Quaternion.d.ts.map +1 -1
- package/src/core/geom/Quaternion.js +63 -99
- package/src/core/math/spline/spline_hermite3.d.ts +4 -3
- package/src/core/math/spline/spline_hermite3.d.ts.map +1 -1
- package/src/core/math/spline/spline_hermite3.js +4 -3
- package/src/engine/animation/clip/AnimationClip.d.ts +4 -0
- package/src/engine/animation/clip/AnimationClip.d.ts.map +1 -0
- package/src/engine/animation/clip/AnimationClip.js +23 -0
- package/src/engine/animation/clip/AnimationClipBinding.d.ts +14 -0
- package/src/engine/animation/clip/AnimationClipBinding.d.ts.map +1 -0
- package/src/engine/animation/clip/AnimationClipBinding.js +94 -0
- package/src/engine/animation/clip/AnimationTrack.d.ts +45 -0
- package/src/engine/animation/clip/AnimationTrack.d.ts.map +1 -0
- package/src/engine/animation/clip/AnimationTrack.js +83 -0
- package/src/engine/animation/clip/AnimationTrackBinding.d.ts +25 -0
- package/src/engine/animation/clip/AnimationTrackBinding.d.ts.map +1 -0
- package/src/engine/animation/clip/AnimationTrackBinding.js +42 -0
- package/src/engine/animation/clip/ecd_bind_animation_curve.d.ts +9 -0
- package/src/engine/animation/clip/ecd_bind_animation_curve.d.ts.map +1 -0
- package/src/engine/animation/{curve → clip}/ecd_bind_animation_curve.js +28 -20
- package/src/engine/animation/curve/AnimationCurve.d.ts +31 -0
- package/src/engine/animation/curve/AnimationCurve.d.ts.map +1 -1
- package/src/engine/animation/curve/AnimationCurve.js +81 -23
- package/src/engine/animation/curve/AnimationCurve.spec.js +37 -2
- package/src/engine/animation/curve/Keyframe.d.ts +8 -0
- package/src/engine/animation/curve/Keyframe.d.ts.map +1 -1
- package/src/engine/animation/curve/Keyframe.js +53 -44
- package/src/engine/animation/curve/Keyframe.spec.d.ts +2 -0
- package/src/engine/animation/curve/Keyframe.spec.d.ts.map +1 -0
- package/src/engine/animation/curve/Keyframe.spec.js +31 -0
- package/src/engine/animation/curve/binding/BoundQuaternionWriter.d.ts.map +1 -0
- package/src/engine/animation/curve/binding/BoundValueWriter.d.ts +14 -0
- package/src/engine/animation/curve/binding/BoundValueWriter.d.ts.map +1 -0
- package/src/engine/animation/curve/binding/BoundValueWriter.js +19 -0
- package/src/engine/animation/curve/binding/BoundVector3Writer.d.ts.map +1 -0
- package/src/engine/graphics/ecs/mesh-v2/aggregate/SGMeshAnimationController.d.ts +2 -2
- package/src/engine/graphics/ecs/mesh-v2/aggregate/SGMeshAnimationControllerSystem.js +1 -1
- package/src/engine/graphics/texture/virtual/VirtualTextureUsageUpdater.d.ts.map +1 -1
- package/src/engine/graphics/texture/virtual/VirtualTextureUsageUpdater.js +5 -3
- package/src/engine/animation/curve/EntityNodeAnimationClip.d.ts +0 -4
- package/src/engine/animation/curve/EntityNodeAnimationClip.d.ts.map +0 -1
- package/src/engine/animation/curve/EntityNodeAnimationClip.js +0 -24
- package/src/engine/animation/curve/ecd_bind_animation_curve.d.ts +0 -8
- package/src/engine/animation/curve/ecd_bind_animation_curve.d.ts.map +0 -1
- package/src/engine/graphics/ecs/mesh-v2/aggregate/animation/AnimatedValueBinding.d.ts +0 -27
- package/src/engine/graphics/ecs/mesh-v2/aggregate/animation/AnimatedValueBinding.d.ts.map +0 -1
- package/src/engine/graphics/ecs/mesh-v2/aggregate/animation/AnimatedValueBinding.js +0 -61
- package/src/engine/graphics/ecs/mesh-v2/aggregate/animation/BoundQuaternionWriter.d.ts.map +0 -1
- package/src/engine/graphics/ecs/mesh-v2/aggregate/animation/BoundValueWriter.d.ts +0 -8
- package/src/engine/graphics/ecs/mesh-v2/aggregate/animation/BoundValueWriter.d.ts.map +0 -1
- package/src/engine/graphics/ecs/mesh-v2/aggregate/animation/BoundValueWriter.js +0 -10
- package/src/engine/graphics/ecs/mesh-v2/aggregate/animation/BoundVector3Writer.d.ts.map +0 -1
- /package/src/engine/{graphics/ecs/mesh-v2/aggregate/animation → animation/curve/binding}/BoundQuaternionWriter.d.ts +0 -0
- /package/src/engine/{graphics/ecs/mesh-v2/aggregate/animation → animation/curve/binding}/BoundQuaternionWriter.js +0 -0
- /package/src/engine/{graphics/ecs/mesh-v2/aggregate/animation → animation/curve/binding}/BoundVector3Writer.d.ts +0 -0
- /package/src/engine/{graphics/ecs/mesh-v2/aggregate/animation → animation/curve/binding}/BoundVector3Writer.js +0 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
const sample = new Float64Array(1024);
|
|
2
|
+
|
|
3
|
+
export class AnimationTrackBinding {
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* @type {BoundValueWriter|null}
|
|
7
|
+
*/
|
|
8
|
+
writer = null
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
*
|
|
12
|
+
* @type {AnimationTrack}
|
|
13
|
+
*/
|
|
14
|
+
track = null
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
*
|
|
18
|
+
* @param {BoundValueWriter} writer
|
|
19
|
+
* @param {AnimationTrack} track
|
|
20
|
+
* @returns {AnimationTrackBinding}
|
|
21
|
+
*/
|
|
22
|
+
static from(writer, track) {
|
|
23
|
+
|
|
24
|
+
const r = new AnimationTrackBinding();
|
|
25
|
+
|
|
26
|
+
r.writer = writer;
|
|
27
|
+
r.track = track;
|
|
28
|
+
|
|
29
|
+
return r;
|
|
30
|
+
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
*
|
|
35
|
+
* @param {number} time
|
|
36
|
+
*/
|
|
37
|
+
writeAt(time) {
|
|
38
|
+
this.track.sample(sample, 0, time);
|
|
39
|
+
|
|
40
|
+
this.writer.write(sample);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Three.js clip to internal representation
|
|
3
|
+
* @param {EntityNode} node
|
|
4
|
+
* @param {THREE.AnimationClip} clip
|
|
5
|
+
*/
|
|
6
|
+
export function convert_three_clip(node: EntityNode, clip: THREE.AnimationClip): AnimationClipBinding;
|
|
7
|
+
import { AnimationClip } from "./AnimationClip.js";
|
|
8
|
+
import { AnimationClipBinding } from "./AnimationClipBinding.js";
|
|
9
|
+
//# sourceMappingURL=ecd_bind_animation_curve.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ecd_bind_animation_curve.d.ts","sourceRoot":"","sources":["../../../../../src/engine/animation/clip/ecd_bind_animation_curve.js"],"names":[],"mappings":"AAmUA;;;;GAIG;AACH,2DAFW,mBAAmB,wBA6B7B;8BA5V6B,oBAAoB;qCACb,2BAA2B"}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import Name from "../../ecs/name/Name.js";
|
|
2
|
-
import { AnimatedValueBinding } from "../../graphics/ecs/mesh-v2/aggregate/animation/AnimatedValueBinding.js";
|
|
3
|
-
import { BoundQuaternionWriter } from "../../graphics/ecs/mesh-v2/aggregate/animation/BoundQuaternionWriter.js";
|
|
4
|
-
import { BoundValueWriter } from "../../graphics/ecs/mesh-v2/aggregate/animation/BoundValueWriter.js";
|
|
5
|
-
import { BoundVector3Writer } from "../../graphics/ecs/mesh-v2/aggregate/animation/BoundVector3Writer.js";
|
|
6
2
|
import { logger } from "../../logging/GlobalLogger.js";
|
|
7
|
-
import { AnimationCurve } from "
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
3
|
+
import { AnimationCurve } from "../curve/AnimationCurve.js";
|
|
4
|
+
import { BoundQuaternionWriter } from "../curve/binding/BoundQuaternionWriter.js";
|
|
5
|
+
import { BoundValueWriter } from "../curve/binding/BoundValueWriter.js";
|
|
6
|
+
import { BoundVector3Writer } from "../curve/binding/BoundVector3Writer.js";
|
|
7
|
+
import { Keyframe } from "../curve/Keyframe.js";
|
|
8
|
+
import { AnimationClip } from "./AnimationClip.js";
|
|
9
|
+
import { AnimationClipBinding } from "./AnimationClipBinding.js";
|
|
10
|
+
import { AnimationTrack } from "./AnimationTrack.js";
|
|
11
|
+
import { AnimationTrackBinding } from "./AnimationTrackBinding.js";
|
|
10
12
|
|
|
11
13
|
|
|
12
14
|
/**
|
|
@@ -305,44 +307,50 @@ function component_curve_from_track(curve, type, values, times, component_count,
|
|
|
305
307
|
*
|
|
306
308
|
* @param {THREE.KeyframeTrack} track
|
|
307
309
|
* @param {EntityNode} node
|
|
310
|
+
* @returns {AnimationTrack}
|
|
308
311
|
*/
|
|
309
312
|
function convert_three_track(track, node) {
|
|
310
313
|
|
|
311
314
|
|
|
312
315
|
const track_name = track.name;
|
|
313
316
|
|
|
314
|
-
const writer = bind_property_writer(node, track_name);
|
|
315
317
|
// last part is the property
|
|
316
318
|
const curves = convert_three_track_to_curves(track);
|
|
317
319
|
|
|
318
|
-
return
|
|
320
|
+
return AnimationTrack.from(curves, track_name);
|
|
321
|
+
|
|
319
322
|
}
|
|
320
323
|
|
|
321
324
|
/**
|
|
322
325
|
* Three.js clip to internal representation
|
|
323
326
|
* @param {EntityNode} node
|
|
324
|
-
* @param {AnimationClip} clip
|
|
327
|
+
* @param {THREE.AnimationClip} clip
|
|
325
328
|
*/
|
|
326
329
|
export function convert_three_clip(node, clip) {
|
|
327
330
|
const three_tracks = clip.tracks;
|
|
328
331
|
const track_count = three_tracks.length;
|
|
329
332
|
|
|
330
|
-
|
|
333
|
+
|
|
334
|
+
const clip_binding = new AnimationClipBinding();
|
|
335
|
+
const meep_clip = new AnimationClip();
|
|
336
|
+
|
|
337
|
+
meep_clip.name = clip.name;
|
|
338
|
+
|
|
339
|
+
clip_binding.clip = meep_clip;
|
|
331
340
|
|
|
332
341
|
for (let i = 0; i < track_count; i++) {
|
|
333
342
|
try {
|
|
334
|
-
const
|
|
335
|
-
|
|
343
|
+
const three_track = three_tracks[i];
|
|
344
|
+
const meep_track = convert_three_track(three_track, node);
|
|
345
|
+
|
|
346
|
+
const writer = bind_property_writer(node, three_track.name);
|
|
347
|
+
|
|
348
|
+
meep_clip.tracks.push(meep_track);
|
|
349
|
+
clip_binding.tracks.push(AnimationTrackBinding.from(writer, meep_track));
|
|
336
350
|
} catch (e) {
|
|
337
351
|
logger.error(`Failed to parse track[${i}]: ${e.message}`);
|
|
338
352
|
}
|
|
339
353
|
}
|
|
340
354
|
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
r.name = clip.name;
|
|
344
|
-
r.tracks = tracks;
|
|
345
|
-
r.duration = clip.duration;
|
|
346
|
-
|
|
347
|
-
return r;
|
|
355
|
+
return clip_binding;
|
|
348
356
|
}
|
|
@@ -9,6 +9,32 @@ export class AnimationCurve {
|
|
|
9
9
|
* @returns {AnimationCurve}
|
|
10
10
|
*/
|
|
11
11
|
static from(keys: Keyframe[]): AnimationCurve;
|
|
12
|
+
/**
|
|
13
|
+
*
|
|
14
|
+
* @param {number} timeStart
|
|
15
|
+
* @param {number} valueStart
|
|
16
|
+
* @param {number} timeEnd
|
|
17
|
+
* @param {number} valueEnd
|
|
18
|
+
* @return {AnimationCurve}
|
|
19
|
+
*/
|
|
20
|
+
static easeInOut(timeStart: number, valueStart: number, timeEnd: number, valueEnd: number): AnimationCurve;
|
|
21
|
+
/**
|
|
22
|
+
*
|
|
23
|
+
* @param {number} timeStart
|
|
24
|
+
* @param {number} timeEnd
|
|
25
|
+
* @param {number} value
|
|
26
|
+
* @return {AnimationCurve}
|
|
27
|
+
*/
|
|
28
|
+
static constant(timeStart: number, timeEnd: number, value: number): AnimationCurve;
|
|
29
|
+
/**
|
|
30
|
+
*
|
|
31
|
+
* @param {number} timeStart
|
|
32
|
+
* @param {number} valueStart
|
|
33
|
+
* @param {number} timeEnd
|
|
34
|
+
* @param {number} valueEnd
|
|
35
|
+
* @return {AnimationCurve}
|
|
36
|
+
*/
|
|
37
|
+
static linear(timeStart: number, valueStart: number, timeEnd: number, valueEnd: number): AnimationCurve;
|
|
12
38
|
/**
|
|
13
39
|
* @readonly
|
|
14
40
|
* @type {Keyframe[]}
|
|
@@ -40,6 +66,11 @@ export class AnimationCurve {
|
|
|
40
66
|
* @returns {number}
|
|
41
67
|
*/
|
|
42
68
|
get length(): number;
|
|
69
|
+
/**
|
|
70
|
+
* Time of the last chronological key in the curve
|
|
71
|
+
* @return {number}
|
|
72
|
+
*/
|
|
73
|
+
get duration(): number;
|
|
43
74
|
/**
|
|
44
75
|
*
|
|
45
76
|
* @param {number} t time in seconds
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AnimationCurve.d.ts","sourceRoot":"","sources":["../../../../../src/engine/animation/curve/AnimationCurve.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AnimationCurve.d.ts","sourceRoot":"","sources":["../../../../../src/engine/animation/curve/AnimationCurve.js"],"names":[],"mappings":"AAkBA;;;GAGG;AACH;IAiFI;;;;OAIG;IACH,kBAHW,QAAQ,EAAE,GACR,cAAc,CAU1B;IA6ID;;;;;;;OAOG;IACH,4BANW,MAAM,cACN,MAAM,WACN,MAAM,YACN,MAAM,GACL,cAAc,CAOzB;IAED;;;;;;OAMG;IACH,2BALW,MAAM,WACN,MAAM,SACN,MAAM,GACL,cAAc,CAOzB;IAED;;;;;;;OAOG;IACH,yBANW,MAAM,cACN,MAAM,WACN,MAAM,YACN,MAAM,GACL,cAAc,CASzB;IAtRD;;;OAGG;IACH,eAFU,QAAQ,EAAE,CAEV;IAEV;;;;OAIG;IACH,SAHW,QAAQ,GACN,MAAM,CA+BlB;IAED;;;OAGG;IACH,cAFW,QAAQ,EAAE,QAUpB;IAED;;;;OAIG;IACH,YAHW,QAAQ,GACN,OAAO,CAYnB;IAED;;OAEG;IACH,cAEC;IAiBD;;;OAGG;IACH,qBAEC;IAED;;;OAGG;IACH,uBAUC;IAED;;;;OAIG;IACH,YAHW,MAAM,GACL,MAAM,CAwCjB;IAED;;;OAGG;IACH,qBAFW,MAAM,QAoBhB;IAED;;;;OAIG;IACH,sBAHW,MAAM,UACN,MAAM,QAWhB;IAED,0BAKC;IAED;;MAIC;IAED;;aAeC;CA+CJ;yBAxSwB,eAAe"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { assert } from "../../../core/assert.js";
|
|
1
2
|
import { binarySearchHighIndex } from "../../../core/collection/array/binarySearchHighIndex.js";
|
|
2
3
|
import { inverseLerp } from "../../../core/math/inverseLerp.js";
|
|
3
4
|
import { lerp } from "../../../core/math/lerp.js";
|
|
@@ -5,24 +6,6 @@ import { spline_hermite3 } from "../../../core/math/spline/spline_hermite3.js";
|
|
|
5
6
|
import { invokeObjectToJSON } from "../../../core/model/object/invokeObjectToJSON.js";
|
|
6
7
|
import { Keyframe } from "./Keyframe.js";
|
|
7
8
|
|
|
8
|
-
/**
|
|
9
|
-
*
|
|
10
|
-
* @param {number} t interpolation value, between 0 and 1
|
|
11
|
-
* @param {Keyframe} keyframe0
|
|
12
|
-
* @param {Keyframe} keyframe1
|
|
13
|
-
* @return {number}
|
|
14
|
-
*/
|
|
15
|
-
function evaluate(t, keyframe0, keyframe1) {
|
|
16
|
-
const time_distance = keyframe1.time - keyframe0.time;
|
|
17
|
-
|
|
18
|
-
return spline_hermite3(
|
|
19
|
-
t,
|
|
20
|
-
keyframe0.value, keyframe1.value,
|
|
21
|
-
keyframe0.outTangent * time_distance,
|
|
22
|
-
keyframe1.inTangent * time_distance
|
|
23
|
-
);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
9
|
/**
|
|
27
10
|
*
|
|
28
11
|
* @param {number} time
|
|
@@ -50,6 +33,9 @@ export class AnimationCurve {
|
|
|
50
33
|
* @returns {number} key index
|
|
51
34
|
*/
|
|
52
35
|
add(key) {
|
|
36
|
+
assert.defined(key, 'key');
|
|
37
|
+
assert.notNull(key, 'key');
|
|
38
|
+
|
|
53
39
|
const keys = this.keys;
|
|
54
40
|
|
|
55
41
|
const key_count = keys.length;
|
|
@@ -82,6 +68,8 @@ export class AnimationCurve {
|
|
|
82
68
|
* @param {Keyframe[]} keys
|
|
83
69
|
*/
|
|
84
70
|
addMany(keys) {
|
|
71
|
+
assert.isArray(keys, 'keys');
|
|
72
|
+
|
|
85
73
|
const key_count = keys.length;
|
|
86
74
|
|
|
87
75
|
for (let i = 0; i < key_count; i++) {
|
|
@@ -136,6 +124,21 @@ export class AnimationCurve {
|
|
|
136
124
|
return this.keys.length;
|
|
137
125
|
}
|
|
138
126
|
|
|
127
|
+
/**
|
|
128
|
+
* Time of the last chronological key in the curve
|
|
129
|
+
* @return {number}
|
|
130
|
+
*/
|
|
131
|
+
get duration() {
|
|
132
|
+
const keys = this.keys;
|
|
133
|
+
const key_count = keys.length;
|
|
134
|
+
|
|
135
|
+
if (key_count === 0) {
|
|
136
|
+
return 0
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// keys are sorted, so we can rely on the last key's time
|
|
140
|
+
return keys[key_count - 1].time;
|
|
141
|
+
}
|
|
139
142
|
|
|
140
143
|
/**
|
|
141
144
|
*
|
|
@@ -159,13 +162,22 @@ export class AnimationCurve {
|
|
|
159
162
|
}
|
|
160
163
|
|
|
161
164
|
for (let i = 1; i < key_count; i++) {
|
|
162
|
-
const
|
|
165
|
+
const keyframe1 = keys[i];
|
|
163
166
|
|
|
164
|
-
if (t <
|
|
165
|
-
const
|
|
166
|
-
const kt = inverseLerp(f0.time, f1.time, t);
|
|
167
|
+
if (t < keyframe1.time) {
|
|
168
|
+
const keyframe0 = keys[i - 1];
|
|
167
169
|
|
|
168
|
-
|
|
170
|
+
// convert to 0..1 region
|
|
171
|
+
const normalized_time = inverseLerp(keyframe0.time, keyframe1.time, t);
|
|
172
|
+
|
|
173
|
+
const time_distance = keyframe1.time - keyframe0.time;
|
|
174
|
+
|
|
175
|
+
return spline_hermite3(
|
|
176
|
+
normalized_time,
|
|
177
|
+
keyframe0.value, keyframe1.value,
|
|
178
|
+
keyframe0.outTangent * time_distance,
|
|
179
|
+
keyframe1.inTangent * time_distance
|
|
180
|
+
);
|
|
169
181
|
}
|
|
170
182
|
}
|
|
171
183
|
|
|
@@ -242,4 +254,50 @@ export class AnimationCurve {
|
|
|
242
254
|
}
|
|
243
255
|
|
|
244
256
|
}
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
*
|
|
260
|
+
* @param {number} timeStart
|
|
261
|
+
* @param {number} valueStart
|
|
262
|
+
* @param {number} timeEnd
|
|
263
|
+
* @param {number} valueEnd
|
|
264
|
+
* @return {AnimationCurve}
|
|
265
|
+
*/
|
|
266
|
+
static easeInOut(timeStart, valueStart, timeEnd, valueEnd) {
|
|
267
|
+
return AnimationCurve.from([
|
|
268
|
+
Keyframe.from(timeStart, valueStart, 0, 0),
|
|
269
|
+
Keyframe.from(timeEnd, valueEnd, 0, 0)
|
|
270
|
+
]);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
*
|
|
275
|
+
* @param {number} timeStart
|
|
276
|
+
* @param {number} timeEnd
|
|
277
|
+
* @param {number} value
|
|
278
|
+
* @return {AnimationCurve}
|
|
279
|
+
*/
|
|
280
|
+
static constant(timeStart, timeEnd, value) {
|
|
281
|
+
return AnimationCurve.from([
|
|
282
|
+
Keyframe.from(timeStart, value, 0, 0),
|
|
283
|
+
Keyframe.from(timeEnd, value, 0, 0)
|
|
284
|
+
]);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
*
|
|
289
|
+
* @param {number} timeStart
|
|
290
|
+
* @param {number} valueStart
|
|
291
|
+
* @param {number} timeEnd
|
|
292
|
+
* @param {number} valueEnd
|
|
293
|
+
* @return {AnimationCurve}
|
|
294
|
+
*/
|
|
295
|
+
static linear(timeStart, valueStart, timeEnd, valueEnd) {
|
|
296
|
+
const tangent = valueEnd - valueStart;
|
|
297
|
+
|
|
298
|
+
return AnimationCurve.from([
|
|
299
|
+
Keyframe.from(timeStart, valueStart, 0, tangent),
|
|
300
|
+
Keyframe.from(timeEnd, valueEnd, tangent, 0)
|
|
301
|
+
]);
|
|
302
|
+
}
|
|
245
303
|
}
|
|
@@ -119,9 +119,10 @@ test("extreme tangent interpolation", () => {
|
|
|
119
119
|
const curve = new AnimationCurve();
|
|
120
120
|
|
|
121
121
|
curve.add(Keyframe.from(0, 1, 0, -1));
|
|
122
|
-
curve.add(Keyframe.from(1, 2, 1, 0));
|
|
122
|
+
curve.add(Keyframe.from(1, 2, -1, 0));
|
|
123
123
|
|
|
124
|
-
expect(curve.evaluate(0.
|
|
124
|
+
expect(curve.evaluate(0.1)).toBeLessThan(1);
|
|
125
|
+
expect(curve.evaluate(0.9)).toBeGreaterThan(2);
|
|
125
126
|
|
|
126
127
|
});
|
|
127
128
|
|
|
@@ -144,3 +145,37 @@ test("to/from JSON consistency", () => {
|
|
|
144
145
|
expect(first_key.inTangent).toBe(13);
|
|
145
146
|
expect(first_key.outTangent).toBe(-17);
|
|
146
147
|
});
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
test("static easeInOut constructor", () => {
|
|
151
|
+
|
|
152
|
+
const curve = AnimationCurve.easeInOut(1, 3, 5, 7);
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
expect(curve.evaluate(1.1)).toBeCloseTo(3, 0.1);
|
|
156
|
+
expect(curve.evaluate(4.9)).toBeCloseTo(7, 0.1);
|
|
157
|
+
|
|
158
|
+
expect(curve.evaluate(3)).toBeCloseTo(5, 0.01);
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
test("static linear constructor", () => {
|
|
162
|
+
|
|
163
|
+
const curve = AnimationCurve.linear(1, 3, 5, 7);
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
expect(curve.evaluate(1.1)).toBeCloseTo(3.1, 0.01);
|
|
167
|
+
expect(curve.evaluate(4.9)).toBeCloseTo(6.9, 0.01);
|
|
168
|
+
|
|
169
|
+
expect(curve.evaluate(3)).toBeCloseTo(5, 0.01);
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
test("static constant constructor", () => {
|
|
173
|
+
|
|
174
|
+
const curve = AnimationCurve.constant(1, 5, 7);
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
expect(curve.evaluate(1.1)).toBe(7);
|
|
178
|
+
expect(curve.evaluate(4.9)).toBe(7);
|
|
179
|
+
|
|
180
|
+
expect(curve.evaluate(3)).toBe(7);
|
|
181
|
+
});
|
|
@@ -28,6 +28,14 @@ export class Keyframe {
|
|
|
28
28
|
* @type {number}
|
|
29
29
|
*/
|
|
30
30
|
outTangent: number;
|
|
31
|
+
/**
|
|
32
|
+
*
|
|
33
|
+
* @param {number} time
|
|
34
|
+
* @param {number} value
|
|
35
|
+
* @param {number} inTangent
|
|
36
|
+
* @param {number} outTangent
|
|
37
|
+
*/
|
|
38
|
+
set(time: number, value: number, inTangent: number, outTangent: number): void;
|
|
31
39
|
toJSON(): {
|
|
32
40
|
value: number;
|
|
33
41
|
time: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Keyframe.d.ts","sourceRoot":"","sources":["../../../../../src/engine/animation/curve/Keyframe.js"],"names":[],"mappings":"AAEA;
|
|
1
|
+
{"version":3,"file":"Keyframe.d.ts","sourceRoot":"","sources":["../../../../../src/engine/animation/curve/Keyframe.js"],"names":[],"mappings":"AAEA;IAyBI;;;;;;;OAOG;IACH,kBANW,MAAM,SACN,MAAM,cACN,MAAM,eACN,MAAM,GACL,QAAQ,CAQnB;IAtCD;;;OAGG;IACH,OAFU,MAAM,CAEN;IAEV;;;OAGG;IACH,MAFU,MAAM,CAEP;IAET;;;OAGG;IACH,WAFU,MAAM,CAEF;IAEd;;;OAGG;IACH,YAFU,MAAM,CAED;IAkBf;;;;;;OAMG;IACH,UALW,MAAM,SACN,MAAM,aACN,MAAM,cACN,MAAM,QAmBhB;IAED;;;;;MAOC;IAED;;;;;aAQC;CAEJ"}
|
|
@@ -1,31 +1,29 @@
|
|
|
1
1
|
import { assert } from "../../../core/assert.js";
|
|
2
2
|
|
|
3
3
|
export class Keyframe {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
this.outTangent = 0;
|
|
28
|
-
}
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* @type {number}
|
|
7
|
+
*/
|
|
8
|
+
value = 0;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
*
|
|
12
|
+
* @type {number}
|
|
13
|
+
*/
|
|
14
|
+
time = 0;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
*
|
|
18
|
+
* @type {number}
|
|
19
|
+
*/
|
|
20
|
+
inTangent = 0;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
*
|
|
24
|
+
* @type {number}
|
|
25
|
+
*/
|
|
26
|
+
outTangent = 0;
|
|
29
27
|
|
|
30
28
|
/**
|
|
31
29
|
*
|
|
@@ -36,26 +34,37 @@ export class Keyframe {
|
|
|
36
34
|
* @return {Keyframe}
|
|
37
35
|
*/
|
|
38
36
|
static from(time, value, inTangent = 0, outTangent = 0) {
|
|
39
|
-
|
|
40
|
-
assert.notNaN(time,'time');
|
|
37
|
+
const r = new Keyframe();
|
|
41
38
|
|
|
42
|
-
|
|
43
|
-
assert.notNaN(value,'value');
|
|
39
|
+
r.set(time, value, inTangent, outTangent);
|
|
44
40
|
|
|
45
|
-
|
|
46
|
-
|
|
41
|
+
return r;
|
|
42
|
+
}
|
|
47
43
|
|
|
48
|
-
|
|
49
|
-
|
|
44
|
+
/**
|
|
45
|
+
*
|
|
46
|
+
* @param {number} time
|
|
47
|
+
* @param {number} value
|
|
48
|
+
* @param {number} inTangent
|
|
49
|
+
* @param {number} outTangent
|
|
50
|
+
*/
|
|
51
|
+
set(time, value, inTangent, outTangent) {
|
|
52
|
+
assert.isNumber(time, 'time');
|
|
53
|
+
assert.notNaN(time, 'time');
|
|
50
54
|
|
|
51
|
-
|
|
55
|
+
assert.isNumber(value, 'value');
|
|
56
|
+
assert.notNaN(value, 'value');
|
|
52
57
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
r.inTangent = inTangent;
|
|
56
|
-
r.outTangent = outTangent;
|
|
58
|
+
assert.isNumber(inTangent, 'inTangent');
|
|
59
|
+
assert.notNaN(inTangent, 'inTangent');
|
|
57
60
|
|
|
58
|
-
|
|
61
|
+
assert.isNumber(outTangent, 'outTangent');
|
|
62
|
+
assert.notNaN(outTangent, 'outTangent');
|
|
63
|
+
|
|
64
|
+
this.time = time;
|
|
65
|
+
this.value = value;
|
|
66
|
+
this.inTangent = inTangent;
|
|
67
|
+
this.outTangent = outTangent;
|
|
59
68
|
}
|
|
60
69
|
|
|
61
70
|
toJSON() {
|
|
@@ -68,13 +77,13 @@ export class Keyframe {
|
|
|
68
77
|
};
|
|
69
78
|
|
|
70
79
|
fromJSON({
|
|
71
|
-
value,
|
|
80
|
+
value,
|
|
81
|
+
time,
|
|
82
|
+
inTangent,
|
|
83
|
+
outTangent
|
|
72
84
|
}) {
|
|
73
85
|
|
|
74
|
-
this.value
|
|
75
|
-
this.time = time;
|
|
76
|
-
this.inTangent = inTangent;
|
|
77
|
-
this.outTangent = outTangent;
|
|
86
|
+
this.set(time, value, inTangent, outTangent);
|
|
78
87
|
}
|
|
79
88
|
|
|
80
89
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Keyframe.spec.d.ts","sourceRoot":"","sources":["../../../../../src/engine/animation/curve/Keyframe.spec.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Keyframe } from "./Keyframe.js";
|
|
2
|
+
|
|
3
|
+
test("toJSON", () => {
|
|
4
|
+
|
|
5
|
+
const k = Keyframe.from(1, 3, 5, 7);
|
|
6
|
+
|
|
7
|
+
expect(k.toJSON()).toEqual({
|
|
8
|
+
time: 1,
|
|
9
|
+
value: 3,
|
|
10
|
+
inTangent: 5,
|
|
11
|
+
outTangent: 7
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
test("fromJSON", () => {
|
|
16
|
+
|
|
17
|
+
const keyframe = new Keyframe();
|
|
18
|
+
|
|
19
|
+
keyframe.fromJSON({
|
|
20
|
+
time: 1,
|
|
21
|
+
value: 3,
|
|
22
|
+
inTangent: 5,
|
|
23
|
+
outTangent: 7
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
expect(keyframe.time).toEqual(1);
|
|
27
|
+
expect(keyframe.value).toEqual(3);
|
|
28
|
+
expect(keyframe.inTangent).toEqual(5);
|
|
29
|
+
expect(keyframe.outTangent).toEqual(7);
|
|
30
|
+
|
|
31
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BoundQuaternionWriter.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/animation/curve/binding/BoundQuaternionWriter.js"],"names":[],"mappings":"AAEA;IAOI,6BAIC;IAED,uBAGC;;CACJ;iCAnBgC,uBAAuB"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export class BoundValueWriter {
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
* @param {number[]|ArrayLike<number>|Float32Array|Float64Array} data
|
|
5
|
+
*/
|
|
6
|
+
write(data: number[] | ArrayLike<number> | Float32Array | Float64Array): void;
|
|
7
|
+
/**
|
|
8
|
+
* @template T
|
|
9
|
+
* @param {T} root
|
|
10
|
+
* @param {string[]} path
|
|
11
|
+
*/
|
|
12
|
+
bind<T>(root: T, path: string[]): void;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=BoundValueWriter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BoundValueWriter.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/animation/curve/binding/BoundValueWriter.js"],"names":[],"mappings":"AAAA;IAEI;;;OAGG;IACH,YAFW,MAAM,EAAE,GAAC,UAAU,MAAM,CAAC,GAAC,YAAY,GAAC,YAAY,QAI9D;IAED;;;;OAIG;IACH,uBAFW,MAAM,EAAE,QAIlB;CACJ"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export class BoundValueWriter {
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* @param {number[]|ArrayLike<number>|Float32Array|Float64Array} data
|
|
6
|
+
*/
|
|
7
|
+
write(data) {
|
|
8
|
+
throw new Error('Not Implemented');
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @template T
|
|
13
|
+
* @param {T} root
|
|
14
|
+
* @param {string[]} path
|
|
15
|
+
*/
|
|
16
|
+
bind(root, path) {
|
|
17
|
+
throw new Error('Not Implemented');
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BoundVector3Writer.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/animation/curve/binding/BoundVector3Writer.js"],"names":[],"mappings":"AAEA;IAOI,yBAIC;IAED,uBAEC;;CACJ;iCAlBgC,uBAAuB"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {AnimationClipBinding} from "../../../../animation/clip/AnimationClipBinding";
|
|
2
2
|
import {SGAnimationPlayback} from "./SGAnimationPlayback";
|
|
3
3
|
|
|
4
4
|
export class SGMeshAnimationController {
|
|
5
|
-
readonly bound:
|
|
5
|
+
readonly bound: AnimationClipBinding[]
|
|
6
6
|
|
|
7
7
|
start(name: string, loop?: boolean, time_offset?: number): SGAnimationPlayback
|
|
8
8
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Signal from "../../../../../core/events/signal/Signal.js";
|
|
2
2
|
import { ResourceAccessKind } from "../../../../../core/model/ResourceAccessKind.js";
|
|
3
3
|
import { ResourceAccessSpecification } from "../../../../../core/model/ResourceAccessSpecification.js";
|
|
4
|
-
import { convert_three_clip } from "../../../../animation/
|
|
4
|
+
import { convert_three_clip } from "../../../../animation/clip/ecd_bind_animation_curve.js";
|
|
5
5
|
import { System } from "../../../../ecs/System.js";
|
|
6
6
|
import { assetTypeByPath } from "../../mesh/assetTypeByPath.js";
|
|
7
7
|
import { SGMesh } from "./SGMesh.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VirtualTextureUsageUpdater.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/texture/virtual/VirtualTextureUsageUpdater.js"],"names":[],"mappings":"AA2EA;IAgBI;;;OAGG;IACH,uCAEC;IAVD,oCAEC;IA8CD,iCAEC;IAED,8BAEC;IAED,4BAEC;IASD;;;;;OAKG;IACH,iCAJW,MAAM,aACN,MAAM,cACN,MAAM,QAqBhB;IAED,0CAEC;IAED,4BAEC;IAiCD;;;;OAIG;IACH,yBAHW,MAAM,KACN,MAAM,QA+BhB;
|
|
1
|
+
{"version":3,"file":"VirtualTextureUsageUpdater.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/texture/virtual/VirtualTextureUsageUpdater.js"],"names":[],"mappings":"AA2EA;IAgBI;;;OAGG;IACH,uCAEC;IAVD,oCAEC;IA8CD,iCAEC;IAED,8BAEC;IAED,4BAEC;IASD;;;;;OAKG;IACH,iCAJW,MAAM,aACN,MAAM,cACN,MAAM,QAqBhB;IAED,0CAEC;IAED,4BAEC;IAiCD;;;;OAIG;IACH,yBAHW,MAAM,KACN,MAAM,QA+BhB;IA0BD;;;;;OAKG;IACH,yEAoDC;IAED,gBAEC;;CACJ;oCAlUmC,0BAA0B;0BADpC,yBAAyB"}
|