@woosh/meep-engine 2.92.24 → 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/package.json +6 -4
- 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 +34 -0
- 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
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"description": "Fully featured ECS game engine written in JavaScript",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"author": "Alexander Goldring",
|
|
8
|
-
"version": "2.
|
|
8
|
+
"version": "2.93.1",
|
|
9
9
|
"main": "build/meep.module.js",
|
|
10
10
|
"module": "build/meep.module.js",
|
|
11
11
|
"exports": {
|
|
@@ -37,9 +37,6 @@
|
|
|
37
37
|
"package.json",
|
|
38
38
|
"README.md"
|
|
39
39
|
],
|
|
40
|
-
"optionalDependencies": {
|
|
41
|
-
"three": "0.136.0"
|
|
42
|
-
},
|
|
43
40
|
"dependencies": {
|
|
44
41
|
"fastest-levenshtein": "1.0.16",
|
|
45
42
|
"gl-matrix": "3.4.3",
|
|
@@ -51,6 +48,11 @@
|
|
|
51
48
|
"peerDependencies": {
|
|
52
49
|
"three": ">=0.135.0"
|
|
53
50
|
},
|
|
51
|
+
"peerDependenciesMeta": {
|
|
52
|
+
"three": {
|
|
53
|
+
"optional": true
|
|
54
|
+
}
|
|
55
|
+
},
|
|
54
56
|
"devDependencies": {
|
|
55
57
|
"@babel/core": "7.22.15",
|
|
56
58
|
"@babel/preset-env": "7.22.15",
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Perform cubic hermite interpolation
|
|
3
|
-
* @
|
|
3
|
+
* @see https://en.wikipedia.org/wiki/Cubic_Hermite_spline
|
|
4
|
+
* @param {number} t normalized interpolation position in interval [0,1]
|
|
4
5
|
* @param {number} p0 first value
|
|
5
6
|
* @param {number} p1 second value
|
|
6
|
-
* @param {number} m0 first tangent
|
|
7
|
-
* @param {number} m1 second tangent
|
|
7
|
+
* @param {number} m0 first tangent (tangent existing from first value)
|
|
8
|
+
* @param {number} m1 second tangent (tangent entering into second value)
|
|
8
9
|
* @return {number}
|
|
9
10
|
*/
|
|
10
11
|
export function spline_hermite3(t: number, p0: number, p1: number, m0: number, m1: number): number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spline_hermite3.d.ts","sourceRoot":"","sources":["../../../../../src/core/math/spline/spline_hermite3.js"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"spline_hermite3.d.ts","sourceRoot":"","sources":["../../../../../src/core/math/spline/spline_hermite3.js"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,mCAPW,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,GACL,MAAM,CAajB"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Perform cubic hermite interpolation
|
|
3
|
-
* @
|
|
3
|
+
* @see https://en.wikipedia.org/wiki/Cubic_Hermite_spline
|
|
4
|
+
* @param {number} t normalized interpolation position in interval [0,1]
|
|
4
5
|
* @param {number} p0 first value
|
|
5
6
|
* @param {number} p1 second value
|
|
6
|
-
* @param {number} m0 first tangent
|
|
7
|
-
* @param {number} m1 second tangent
|
|
7
|
+
* @param {number} m0 first tangent (tangent existing from first value)
|
|
8
|
+
* @param {number} m1 second tangent (tangent entering into second value)
|
|
8
9
|
* @return {number}
|
|
9
10
|
*/
|
|
10
11
|
export function spline_hermite3(t, p0, p1, m0, m1) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AnimationClip.d.ts","sourceRoot":"","sources":["../../../../../src/engine/animation/clip/AnimationClip.js"],"names":[],"mappings":"AAEA;IACI,aAAS;IACT;;;OAGG;IACH,QAFU,gBAAgB,CAEf;IAEX,uBAWC;CACJ"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { max2 } from "../../../core/math/max2.js";
|
|
2
|
+
|
|
3
|
+
export class AnimationClip {
|
|
4
|
+
name = ""
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
* @type {AnimationTrack[]}
|
|
8
|
+
*/
|
|
9
|
+
tracks = []
|
|
10
|
+
|
|
11
|
+
get duration() {
|
|
12
|
+
let r = 0;
|
|
13
|
+
|
|
14
|
+
const tracks = this.tracks;
|
|
15
|
+
const track_count = tracks.length;
|
|
16
|
+
for (let i = 0; i < track_count; i++) {
|
|
17
|
+
const track = tracks[i];
|
|
18
|
+
r = max2(r, track.duration)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return r;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AnimationClipBinding.d.ts","sourceRoot":"","sources":["../../../../../src/engine/animation/clip/AnimationClipBinding.js"],"names":[],"mappings":"AAGA;IA8BI,+EAQC;IApCD;;OAEG;IACH,oBAAI;IAGJ;;;OAGG;IACH,QAFU,qBAAqB,EAAE,CAEtB;IAEX;;;OAGG;IACH,mBAEC;IAED;;;OAGG;IACH,uBAEC;IAYD;;;;OAIG;IACH,8CA6BC;IAED;;;OAGG;IACH,cAFW,MAAM,QAWhB;CACJ;sCA5FqC,4BAA4B"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { assert } from "../../../core/assert.js";
|
|
2
|
+
import { AnimationTrackBinding } from "./AnimationTrackBinding.js";
|
|
3
|
+
|
|
4
|
+
export class AnimationClipBinding {
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @type {AnimationClip}
|
|
8
|
+
*/
|
|
9
|
+
clip
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
*
|
|
14
|
+
* @type {AnimationTrackBinding[]}
|
|
15
|
+
*/
|
|
16
|
+
tracks = []
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @deprecated use `clip.name` directly instead
|
|
20
|
+
* @return {string}
|
|
21
|
+
*/
|
|
22
|
+
get name() {
|
|
23
|
+
return this.clip.name
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* @deprecated use `clip.duration` directly instead
|
|
28
|
+
* @return {number}
|
|
29
|
+
*/
|
|
30
|
+
get duration() {
|
|
31
|
+
return this.clip.duration;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
static from(clip, root, binding_registry) {
|
|
35
|
+
const r = new AnimationClipBinding();
|
|
36
|
+
|
|
37
|
+
r.clip = clip;
|
|
38
|
+
|
|
39
|
+
r.bind(root, binding_registry);
|
|
40
|
+
|
|
41
|
+
return r;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* @template T
|
|
46
|
+
* @param {T} root
|
|
47
|
+
* @param {Object<Type<BoundValueWriter>>} binding_registry
|
|
48
|
+
*/
|
|
49
|
+
bind(root, binding_registry) {
|
|
50
|
+
const bound_tracks = this.tracks;
|
|
51
|
+
|
|
52
|
+
if (bound_tracks.length > 0) {
|
|
53
|
+
// clear out existing
|
|
54
|
+
bound_tracks.splice(0, bound_tracks.length);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const clip = this.clip;
|
|
58
|
+
|
|
59
|
+
const tracks = clip.tracks;
|
|
60
|
+
const track_count = tracks.length;
|
|
61
|
+
for (let i = 0; i < track_count; i++) {
|
|
62
|
+
const track = tracks[i];
|
|
63
|
+
|
|
64
|
+
const WriterClass = binding_registry[track.type];
|
|
65
|
+
|
|
66
|
+
if (WriterClass === undefined) {
|
|
67
|
+
throw new Error(`No binding class in registry for track type '${track.type}'`);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
assert.isFunction(WriterClass, 'WriterClass');
|
|
71
|
+
|
|
72
|
+
const writer = new WriterClass();
|
|
73
|
+
|
|
74
|
+
writer.bind(root, track.path);
|
|
75
|
+
|
|
76
|
+
bound_tracks[i] = AnimationTrackBinding.from(writer, track);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
*
|
|
82
|
+
* @param {number} time time in seconds
|
|
83
|
+
*/
|
|
84
|
+
writeAt(time) {
|
|
85
|
+
const tracks = this.tracks;
|
|
86
|
+
const track_count = tracks.length;
|
|
87
|
+
|
|
88
|
+
for (let i = 0; i < track_count; i++) {
|
|
89
|
+
const track = tracks[i];
|
|
90
|
+
|
|
91
|
+
track.writeAt(time);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export class AnimationTrack {
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
* @param {AnimationCurve[]} curves
|
|
5
|
+
* @param {string} [name]
|
|
6
|
+
* @return {AnimationTrack}
|
|
7
|
+
*/
|
|
8
|
+
static from(curves?: AnimationCurve[], name?: string): AnimationTrack;
|
|
9
|
+
/**
|
|
10
|
+
* Human-readable label
|
|
11
|
+
* @type {string}
|
|
12
|
+
*/
|
|
13
|
+
name: string;
|
|
14
|
+
/**
|
|
15
|
+
* What property are we animating?
|
|
16
|
+
* @type {string[]}
|
|
17
|
+
*/
|
|
18
|
+
path: string[];
|
|
19
|
+
/**
|
|
20
|
+
*
|
|
21
|
+
* @type {AnimationCurve[]}
|
|
22
|
+
*/
|
|
23
|
+
curves: AnimationCurve[];
|
|
24
|
+
/**
|
|
25
|
+
* Special designator to help with interpolation
|
|
26
|
+
* For example, quaternion tracks will require sampled value to be normalized
|
|
27
|
+
* Based on this value, different bindings will be used
|
|
28
|
+
* @type {string}
|
|
29
|
+
*/
|
|
30
|
+
type: string;
|
|
31
|
+
/**
|
|
32
|
+
* Time duration of the longest curve, in seconds
|
|
33
|
+
* @return {number}
|
|
34
|
+
*/
|
|
35
|
+
get duration(): number;
|
|
36
|
+
get curveCount(): number;
|
|
37
|
+
/**
|
|
38
|
+
*
|
|
39
|
+
* @param {number[]|Float32Array|Float64Array} output
|
|
40
|
+
* @param {number} output_offset
|
|
41
|
+
* @param {number} time
|
|
42
|
+
*/
|
|
43
|
+
sample(output: number[] | Float32Array | Float64Array, output_offset: number, time: number): void;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=AnimationTrack.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AnimationTrack.d.ts","sourceRoot":"","sources":["../../../../../src/engine/animation/clip/AnimationTrack.js"],"names":[],"mappings":"AAEA;IAkEI;;;;;OAKG;IACH,qBAJW,gBAAgB,SAChB,MAAM,GACL,cAAc,CASzB;IA9ED;;;OAGG;IACH,MAFU,MAAM,CAEP;IAET;;;OAGG;IACH,MAFU,MAAM,EAAE,CAET;IAET;;;OAGG;IACH,QAFU,gBAAgB,CAEf;IAEX;;;;;OAKG;IACH,MAFU,MAAM,CAEP;IAET;;;OAGG;IACH,uBAYC;IAED,yBAEC;IAED;;;;;OAKG;IACH,eAJW,MAAM,EAAE,GAAC,YAAY,GAAC,YAAY,iBAClC,MAAM,QACN,MAAM,QAWhB;CAgBJ"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { max2 } from "../../../core/math/max2.js";
|
|
2
|
+
|
|
3
|
+
export class AnimationTrack {
|
|
4
|
+
/**
|
|
5
|
+
* Human-readable label
|
|
6
|
+
* @type {string}
|
|
7
|
+
*/
|
|
8
|
+
name = ""
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* What property are we animating?
|
|
12
|
+
* @type {string[]}
|
|
13
|
+
*/
|
|
14
|
+
path = []
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
*
|
|
18
|
+
* @type {AnimationCurve[]}
|
|
19
|
+
*/
|
|
20
|
+
curves = []
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Special designator to help with interpolation
|
|
24
|
+
* For example, quaternion tracks will require sampled value to be normalized
|
|
25
|
+
* Based on this value, different bindings will be used
|
|
26
|
+
* @type {string}
|
|
27
|
+
*/
|
|
28
|
+
type = ""
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Time duration of the longest curve, in seconds
|
|
32
|
+
* @return {number}
|
|
33
|
+
*/
|
|
34
|
+
get duration() {
|
|
35
|
+
const curves = this.curves;
|
|
36
|
+
const curve_count = curves.length;
|
|
37
|
+
|
|
38
|
+
let r = 0;
|
|
39
|
+
for (let i = 0; i < curve_count; i++) {
|
|
40
|
+
const curve = curves[i];
|
|
41
|
+
|
|
42
|
+
r = max2(r, curve.duration);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return r;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
get curveCount() {
|
|
49
|
+
return this.curves.length;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
*
|
|
54
|
+
* @param {number[]|Float32Array|Float64Array} output
|
|
55
|
+
* @param {number} output_offset
|
|
56
|
+
* @param {number} time
|
|
57
|
+
*/
|
|
58
|
+
sample(output, output_offset, time) {
|
|
59
|
+
const curves = this.curves;
|
|
60
|
+
const curve_count = curves.length;
|
|
61
|
+
|
|
62
|
+
for (let i = 0; i < curve_count; i++) {
|
|
63
|
+
const curve = curves[i];
|
|
64
|
+
|
|
65
|
+
output[output_offset + i] = curve.evaluate(time)
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
*
|
|
71
|
+
* @param {AnimationCurve[]} curves
|
|
72
|
+
* @param {string} [name]
|
|
73
|
+
* @return {AnimationTrack}
|
|
74
|
+
*/
|
|
75
|
+
static from(curves = [], name = "") {
|
|
76
|
+
const r = new AnimationTrack();
|
|
77
|
+
|
|
78
|
+
r.curves = curves;
|
|
79
|
+
r.name = name;
|
|
80
|
+
|
|
81
|
+
return r;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export class AnimationTrackBinding {
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
* @param {BoundValueWriter} writer
|
|
5
|
+
* @param {AnimationTrack} track
|
|
6
|
+
* @returns {AnimationTrackBinding}
|
|
7
|
+
*/
|
|
8
|
+
static from(writer: BoundValueWriter, track: AnimationTrack): AnimationTrackBinding;
|
|
9
|
+
/**
|
|
10
|
+
*
|
|
11
|
+
* @type {BoundValueWriter|null}
|
|
12
|
+
*/
|
|
13
|
+
writer: BoundValueWriter | null;
|
|
14
|
+
/**
|
|
15
|
+
*
|
|
16
|
+
* @type {AnimationTrack}
|
|
17
|
+
*/
|
|
18
|
+
track: AnimationTrack;
|
|
19
|
+
/**
|
|
20
|
+
*
|
|
21
|
+
* @param {number} time
|
|
22
|
+
*/
|
|
23
|
+
writeAt(time: number): void;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=AnimationTrackBinding.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AnimationTrackBinding.d.ts","sourceRoot":"","sources":["../../../../../src/engine/animation/clip/AnimationTrackBinding.js"],"names":[],"mappings":"AAEA;IAaI;;;;;OAKG;IACH,8DAFa,qBAAqB,CAWjC;IA3BD;;;OAGG;IACH,QAFU,mBAAiB,IAAI,CAElB;IAEb;;;OAGG;IACH,sBAAY;IAmBZ;;;OAGG;IACH,cAFW,MAAM,QAMhB;CACJ"}
|
|
@@ -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
|
}
|
|
@@ -145,3 +145,37 @@ test("to/from JSON consistency", () => {
|
|
|
145
145
|
expect(first_key.inTangent).toBe(13);
|
|
146
146
|
expect(first_key.outTangent).toBe(-17);
|
|
147
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"}
|
|
@@ -83,7 +83,7 @@ export class VirtualTextureUsageUpdater {
|
|
|
83
83
|
*/
|
|
84
84
|
#frame_jitter_offsets = new Float32Array([0, 0]);
|
|
85
85
|
#frame_jitter_samples = 1;
|
|
86
|
-
#frame_jitter_enabled =
|
|
86
|
+
#frame_jitter_enabled = true;
|
|
87
87
|
|
|
88
88
|
get frame_jitter_enabled() {
|
|
89
89
|
return this.#frame_jitter_enabled;
|
|
@@ -264,8 +264,10 @@ export class VirtualTextureUsageUpdater {
|
|
|
264
264
|
// apply jitter to projection matrix
|
|
265
265
|
const jitter_index = this.#frame_index % this.#frame_jitter_samples;
|
|
266
266
|
|
|
267
|
-
const
|
|
268
|
-
|
|
267
|
+
const jitter_index_2 = jitter_index * 2;
|
|
268
|
+
|
|
269
|
+
const jitter_offset_x = this.#frame_jitter_offsets[jitter_index_2];
|
|
270
|
+
const jitter_offset_y = this.#frame_jitter_offsets[jitter_index_2 + 1];
|
|
269
271
|
|
|
270
272
|
camera_projection_matrix[8] = jitter_offset_x / usage_buffer.width;
|
|
271
273
|
camera_projection_matrix[9] = jitter_offset_y / usage_buffer.height;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"EntityNodeAnimationClip.d.ts","sourceRoot":"","sources":["../../../../../src/engine/animation/curve/EntityNodeAnimationClip.js"],"names":[],"mappings":"AAAA;IACI,aAAS;IACT;;;OAGG;IACH,QAFU,sBAAsB,CAErB;IACX,iBAAY;IAEZ;;;OAGG;IACH,cAFW,MAAM,QAWhB;CACJ"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
export class EntityNodeAnimationClip {
|
|
2
|
-
name = ""
|
|
3
|
-
/**
|
|
4
|
-
*
|
|
5
|
-
* @type {AnimatedValueBinding[]}
|
|
6
|
-
*/
|
|
7
|
-
tracks = []
|
|
8
|
-
duration = 0
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
*
|
|
12
|
-
* @param {number} time time in seconds
|
|
13
|
-
*/
|
|
14
|
-
writeAt(time) {
|
|
15
|
-
const tracks = this.tracks;
|
|
16
|
-
const track_count = tracks.length;
|
|
17
|
-
|
|
18
|
-
for (let i = 0; i < track_count; i++) {
|
|
19
|
-
const track = tracks[i];
|
|
20
|
-
|
|
21
|
-
track.writeAt(time);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Three.js clip to internal representation
|
|
3
|
-
* @param {EntityNode} node
|
|
4
|
-
* @param {AnimationClip} clip
|
|
5
|
-
*/
|
|
6
|
-
export function convert_three_clip(node: EntityNode, clip: AnimationClip): EntityNodeAnimationClip;
|
|
7
|
-
import { EntityNodeAnimationClip } from "./EntityNodeAnimationClip.js";
|
|
8
|
-
//# sourceMappingURL=ecd_bind_animation_curve.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ecd_bind_animation_curve.d.ts","sourceRoot":"","sources":["../../../../../src/engine/animation/curve/ecd_bind_animation_curve.js"],"names":[],"mappings":"AAgUA;;;;GAIG;AACH,mGAsBC;wCApVuC,8BAA8B"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
export class AnimatedValueBinding {
|
|
2
|
-
/**
|
|
3
|
-
*
|
|
4
|
-
* @param {BoundValueWriter} writer
|
|
5
|
-
* @param {AnimationCurve[]} curves
|
|
6
|
-
* @returns {AnimatedValueBinding}
|
|
7
|
-
*/
|
|
8
|
-
static from(writer: BoundValueWriter, curves: AnimationCurve[]): AnimatedValueBinding;
|
|
9
|
-
constructor(itemSize: any);
|
|
10
|
-
/**
|
|
11
|
-
*
|
|
12
|
-
* @type {BoundValueWriter|null}
|
|
13
|
-
*/
|
|
14
|
-
writer: BoundValueWriter | null;
|
|
15
|
-
/**
|
|
16
|
-
*
|
|
17
|
-
* @type {AnimationCurve[]}
|
|
18
|
-
*/
|
|
19
|
-
curves: AnimationCurve[];
|
|
20
|
-
/**
|
|
21
|
-
*
|
|
22
|
-
* @param {number} time
|
|
23
|
-
*/
|
|
24
|
-
writeAt(time: number): void;
|
|
25
|
-
#private;
|
|
26
|
-
}
|
|
27
|
-
//# sourceMappingURL=AnimatedValueBinding.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AnimatedValueBinding.d.ts","sourceRoot":"","sources":["../../../../../../../../src/engine/graphics/ecs/mesh-v2/aggregate/animation/AnimatedValueBinding.js"],"names":[],"mappings":"AAAA;IAoBI;;;;;OAKG;IACH,8CAHW,gBAAgB,GACd,oBAAoB,CAWhC;IArBD,2BAIC;IAjBD;;;OAGG;IACH,QAFU,mBAAiB,IAAI,CAElB;IAEb;;;OAGG;IACH,QAFU,gBAAgB,CAEf;IAkCX;;;OAGG;IACH,cAFW,MAAM,QAYhB;;CACJ"}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
export class AnimatedValueBinding {
|
|
2
|
-
/**
|
|
3
|
-
*
|
|
4
|
-
* @type {BoundValueWriter|null}
|
|
5
|
-
*/
|
|
6
|
-
writer = null
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
*
|
|
10
|
-
* @type {AnimationCurve[]}
|
|
11
|
-
*/
|
|
12
|
-
curves = []
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
constructor(itemSize) {
|
|
16
|
-
this.#itemSize = itemSize;
|
|
17
|
-
|
|
18
|
-
this.#sample = new Float32Array(itemSize);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
*
|
|
23
|
-
* @param {BoundValueWriter} writer
|
|
24
|
-
* @param {AnimationCurve[]} curves
|
|
25
|
-
* @returns {AnimatedValueBinding}
|
|
26
|
-
*/
|
|
27
|
-
static from(writer, curves) {
|
|
28
|
-
|
|
29
|
-
const r = new AnimatedValueBinding(curves.length);
|
|
30
|
-
|
|
31
|
-
r.writer = writer;
|
|
32
|
-
r.curves = curves;
|
|
33
|
-
|
|
34
|
-
return r;
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
#itemSize = 1;
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
*
|
|
42
|
-
* @type {Float32Array|null}
|
|
43
|
-
*/
|
|
44
|
-
#sample = null;
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
*
|
|
48
|
-
* @param {number} time
|
|
49
|
-
*/
|
|
50
|
-
writeAt(time) {
|
|
51
|
-
|
|
52
|
-
for (let i = 0; i < this.#itemSize; i++) {
|
|
53
|
-
const curve = this.curves[i];
|
|
54
|
-
|
|
55
|
-
this.#sample[i] = curve.evaluate(time)
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
this.writer.write(this.#sample);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BoundQuaternionWriter.d.ts","sourceRoot":"","sources":["../../../../../../../../src/engine/graphics/ecs/mesh-v2/aggregate/animation/BoundQuaternionWriter.js"],"names":[],"mappings":"AAEA;IAOI,6BAIC;IAED,uBAGC;;CACJ;iCAnBgC,uBAAuB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BoundValueWriter.d.ts","sourceRoot":"","sources":["../../../../../../../../src/engine/graphics/ecs/mesh-v2/aggregate/animation/BoundValueWriter.js"],"names":[],"mappings":"AAAA;IAEI;;;OAGG;IACH,YAFW,MAAM,EAAE,QAIlB;CACJ"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BoundVector3Writer.d.ts","sourceRoot":"","sources":["../../../../../../../../src/engine/graphics/ecs/mesh-v2/aggregate/animation/BoundVector3Writer.js"],"names":[],"mappings":"AAEA;IAOI,yBAIC;IAED,uBAEC;;CACJ;iCAlBgC,uBAAuB"}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|