@woosh/meep-engine 2.92.24 → 2.93.2

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 (61) hide show
  1. package/build/meep.cjs +8 -41
  2. package/build/meep.min.js +1 -1
  3. package/build/meep.module.js +8 -41
  4. package/package.json +6 -4
  5. package/src/core/collection/map/HashMap.d.ts.map +1 -1
  6. package/src/core/collection/map/HashMap.js +8 -41
  7. package/src/core/collection/set/HashSet.spec.js +16 -0
  8. package/src/core/math/spline/spline_hermite3.d.ts +4 -3
  9. package/src/core/math/spline/spline_hermite3.d.ts.map +1 -1
  10. package/src/core/math/spline/spline_hermite3.js +4 -3
  11. package/src/engine/animation/clip/AnimationClip.d.ts +4 -0
  12. package/src/engine/animation/clip/AnimationClip.d.ts.map +1 -0
  13. package/src/engine/animation/clip/AnimationClip.js +23 -0
  14. package/src/engine/animation/clip/AnimationClipBinding.d.ts +14 -0
  15. package/src/engine/animation/clip/AnimationClipBinding.d.ts.map +1 -0
  16. package/src/engine/animation/clip/AnimationClipBinding.js +94 -0
  17. package/src/engine/animation/clip/AnimationTrack.d.ts +45 -0
  18. package/src/engine/animation/clip/AnimationTrack.d.ts.map +1 -0
  19. package/src/engine/animation/clip/AnimationTrack.js +83 -0
  20. package/src/engine/animation/clip/AnimationTrackBinding.d.ts +25 -0
  21. package/src/engine/animation/clip/AnimationTrackBinding.d.ts.map +1 -0
  22. package/src/engine/animation/clip/AnimationTrackBinding.js +42 -0
  23. package/src/engine/animation/clip/ecd_bind_animation_curve.d.ts +9 -0
  24. package/src/engine/animation/clip/ecd_bind_animation_curve.d.ts.map +1 -0
  25. package/src/engine/animation/{curve → clip}/ecd_bind_animation_curve.js +28 -20
  26. package/src/engine/animation/curve/AnimationCurve.d.ts +31 -0
  27. package/src/engine/animation/curve/AnimationCurve.d.ts.map +1 -1
  28. package/src/engine/animation/curve/AnimationCurve.js +81 -23
  29. package/src/engine/animation/curve/AnimationCurve.spec.js +34 -0
  30. package/src/engine/animation/curve/Keyframe.d.ts +8 -0
  31. package/src/engine/animation/curve/Keyframe.d.ts.map +1 -1
  32. package/src/engine/animation/curve/Keyframe.js +53 -44
  33. package/src/engine/animation/curve/Keyframe.spec.d.ts +2 -0
  34. package/src/engine/animation/curve/Keyframe.spec.d.ts.map +1 -0
  35. package/src/engine/animation/curve/Keyframe.spec.js +31 -0
  36. package/src/engine/animation/curve/binding/BoundQuaternionWriter.d.ts.map +1 -0
  37. package/src/engine/animation/curve/binding/BoundValueWriter.d.ts +14 -0
  38. package/src/engine/animation/curve/binding/BoundValueWriter.d.ts.map +1 -0
  39. package/src/engine/animation/curve/binding/BoundValueWriter.js +19 -0
  40. package/src/engine/animation/curve/binding/BoundVector3Writer.d.ts.map +1 -0
  41. package/src/engine/graphics/ecs/mesh-v2/aggregate/SGMeshAnimationController.d.ts +2 -2
  42. package/src/engine/graphics/ecs/mesh-v2/aggregate/SGMeshAnimationControllerSystem.js +1 -1
  43. package/src/engine/graphics/texture/virtual/VirtualTextureUsageUpdater.d.ts.map +1 -1
  44. package/src/engine/graphics/texture/virtual/VirtualTextureUsageUpdater.js +5 -3
  45. package/src/engine/animation/curve/EntityNodeAnimationClip.d.ts +0 -4
  46. package/src/engine/animation/curve/EntityNodeAnimationClip.d.ts.map +0 -1
  47. package/src/engine/animation/curve/EntityNodeAnimationClip.js +0 -24
  48. package/src/engine/animation/curve/ecd_bind_animation_curve.d.ts +0 -8
  49. package/src/engine/animation/curve/ecd_bind_animation_curve.d.ts.map +0 -1
  50. package/src/engine/graphics/ecs/mesh-v2/aggregate/animation/AnimatedValueBinding.d.ts +0 -27
  51. package/src/engine/graphics/ecs/mesh-v2/aggregate/animation/AnimatedValueBinding.d.ts.map +0 -1
  52. package/src/engine/graphics/ecs/mesh-v2/aggregate/animation/AnimatedValueBinding.js +0 -61
  53. package/src/engine/graphics/ecs/mesh-v2/aggregate/animation/BoundQuaternionWriter.d.ts.map +0 -1
  54. package/src/engine/graphics/ecs/mesh-v2/aggregate/animation/BoundValueWriter.d.ts +0 -8
  55. package/src/engine/graphics/ecs/mesh-v2/aggregate/animation/BoundValueWriter.d.ts.map +0 -1
  56. package/src/engine/graphics/ecs/mesh-v2/aggregate/animation/BoundValueWriter.js +0 -10
  57. package/src/engine/graphics/ecs/mesh-v2/aggregate/animation/BoundVector3Writer.d.ts.map +0 -1
  58. /package/src/engine/{graphics/ecs/mesh-v2/aggregate/animation → animation/curve/binding}/BoundQuaternionWriter.d.ts +0 -0
  59. /package/src/engine/{graphics/ecs/mesh-v2/aggregate/animation → animation/curve/binding}/BoundQuaternionWriter.js +0 -0
  60. /package/src/engine/{graphics/ecs/mesh-v2/aggregate/animation → animation/curve/binding}/BoundVector3Writer.d.ts +0 -0
  61. /package/src/engine/{graphics/ecs/mesh-v2/aggregate/animation → animation/curve/binding}/BoundVector3Writer.js +0 -0
@@ -60511,54 +60511,21 @@ class HashMap {
60511
60511
  *
60512
60512
  * @returns {Iterator<V>}
60513
60513
  */
60514
- values() {
60515
- const entryIterator = this[Symbol.iterator]();
60516
-
60517
- return {
60518
- next() {
60519
- const n = entryIterator.next();
60520
-
60521
- if (n.done) {
60522
- return {
60523
- done: true,
60524
- value: undefined
60525
- };
60526
- } else {
60527
- return {
60528
- done: false,
60529
- value: n.value[1]
60530
- };
60531
- }
60514
+ * values() {
60532
60515
 
60533
- }
60534
- };
60516
+ for (const [k, v] of this) {
60517
+ yield v;
60518
+ }
60535
60519
  }
60536
60520
 
60537
60521
  /**
60538
60522
  *
60539
60523
  * @returns {Iterator<K>}
60540
60524
  */
60541
- keys() {
60542
- const entryIterator = this[Symbol.iterator]();
60543
-
60544
- return {
60545
- next() {
60546
- const n = entryIterator.next();
60547
-
60548
- if (n.done) {
60549
- return {
60550
- done: true,
60551
- value: undefined
60552
- };
60553
- } else {
60554
- return {
60555
- done: false,
60556
- value: n.value[0]
60557
- };
60558
- }
60559
-
60560
- }
60561
- };
60525
+ * keys() {
60526
+ for (const [k, v] of this) {
60527
+ yield k;
60528
+ }
60562
60529
  }
60563
60530
  }
60564
60531
 
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.92.24",
8
+ "version": "2.93.2",
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 +1 @@
1
- {"version":3,"file":"HashMap.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/map/HashMap.js"],"names":[],"mappings":"AAiBA;;;;;;;;;;;;GAYG;AACH,uFAIC;AAsHD;;;;;;;GAOG;AACH;IA2DI;;;;;;OAMG;IACH,4FALuB,MAAM,EAsC5B;IAlBG;;;;;OAKG;IACH,iCAAsC;IACtC;;;;;OAKG;IACH,qCAA8C;IAOlD,mBAEC;IAED;;;OAGG;IACH,kBAFa,MAAM,CAIlB;IA2HD;;;;OAIG;IACH,SAHW,CAAC,SACD,CAAC,QAoEX;IAED;;;;OAIG;IACH,SAHW,CAAC,GACC,CAAC,GAAC,SAAS,CA+BvB;IAED;;;;;;;;OAQG;IACH,kBALW,CAAC,kBACQ,CAAC,KAAE,CAAC,0BAEZ,CAAC,CAcZ;IAED;;;;;OAKG;IACH,cAJW,CAAC,SACD,CAAC,GACA,CAAC,CAYZ;IAuBD;;;;OAIG;IACH,YAHW,CAAC,GACC,OAAO,CA+CnB;IAED;;;;;OAKG;IACH,4CAFa,OAAO,CA+BnB;IAOD;;OAEG;IACH,gBAkDC;IAmBD,2CAwBC;IAED;;;;OAIG;IACH,SAHW,CAAC,GACC,OAAO,CAInB;IAED;;OAEG;IACH,cA6BC;IA+BD;;;OAGG;IACH,UAFa,SAAS,CAAC,CAAC,CAuBvB;IAED;;;OAGG;IACH,QAFa,SAAS,CAAC,CAAC,CAuBvB;IAjFD,yDA2BC;;CAuDJ"}
1
+ {"version":3,"file":"HashMap.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/map/HashMap.js"],"names":[],"mappings":"AAiBA;;;;;;;;;;;;GAYG;AACH,uFAIC;AAsHD;;;;;;;GAOG;AACH;IA2DI;;;;;;OAMG;IACH,4FALuB,MAAM,EAsC5B;IAlBG;;;;;OAKG;IACH,iCAAsC;IACtC;;;;;OAKG;IACH,qCAA8C;IAOlD,mBAEC;IAED;;;OAGG;IACH,kBAFa,MAAM,CAIlB;IA2HD;;;;OAIG;IACH,SAHW,CAAC,SACD,CAAC,QAoEX;IAED;;;;OAIG;IACH,SAHW,CAAC,GACC,CAAC,GAAC,SAAS,CA+BvB;IAED;;;;;;;;OAQG;IACH,kBALW,CAAC,kBACQ,CAAC,KAAE,CAAC,0BAEZ,CAAC,CAcZ;IAED;;;;;OAKG;IACH,cAJW,CAAC,SACD,CAAC,GACA,CAAC,CAYZ;IAuBD;;;;OAIG;IACH,YAHW,CAAC,GACC,OAAO,CA+CnB;IAED;;;;;OAKG;IACH,4CAFa,OAAO,CA+BnB;IAOD;;OAEG;IACH,gBAkDC;IAmBD,2CAwBC;IAED;;;;OAIG;IACH,SAHW,CAAC,GACC,OAAO,CAInB;IAED;;OAEG;IACH,cA6BC;IA+BD;;;OAGG;IACH,UAFa,SAAS,CAAC,CAAC,CAOvB;IAED;;;OAGG;IACH,QAFa,SAAS,CAAC,CAAC,CAMvB;IAhDD,yDA2BC;;CAsBJ"}
@@ -831,53 +831,20 @@ export class HashMap {
831
831
  *
832
832
  * @returns {Iterator<V>}
833
833
  */
834
- values() {
835
- const entryIterator = this[Symbol.iterator]();
836
-
837
- return {
838
- next() {
839
- const n = entryIterator.next();
840
-
841
- if (n.done) {
842
- return {
843
- done: true,
844
- value: undefined
845
- };
846
- } else {
847
- return {
848
- done: false,
849
- value: n.value[1]
850
- };
851
- }
834
+ * values() {
852
835
 
853
- }
854
- };
836
+ for (const [k, v] of this) {
837
+ yield v;
838
+ }
855
839
  }
856
840
 
857
841
  /**
858
842
  *
859
843
  * @returns {Iterator<K>}
860
844
  */
861
- keys() {
862
- const entryIterator = this[Symbol.iterator]();
863
-
864
- return {
865
- next() {
866
- const n = entryIterator.next();
867
-
868
- if (n.done) {
869
- return {
870
- done: true,
871
- value: undefined
872
- };
873
- } else {
874
- return {
875
- done: false,
876
- value: n.value[0]
877
- };
878
- }
879
-
880
- }
881
- };
845
+ * keys() {
846
+ for (const [k, v] of this) {
847
+ yield k;
848
+ }
882
849
  }
883
850
  }
@@ -20,4 +20,20 @@ test("add same element twice", () => {
20
20
  set.add("a");
21
21
 
22
22
  expect(set.size).toBe(1);
23
+ });
24
+
25
+ test("iterator symbol",()=>{
26
+
27
+ const set = new HashSet({
28
+ keyHashFunction: computeStringHash,
29
+ keyEqualityFunction: strictEquals
30
+ });
31
+
32
+ set.add("a");
33
+
34
+ const iterator = set[Symbol.iterator]();
35
+ expect(iterator.next()).toEqual({
36
+ done:false,
37
+ value: "a"
38
+ });
23
39
  });
@@ -1,10 +1,11 @@
1
1
  /**
2
2
  * Perform cubic hermite interpolation
3
- * @param {number} t normalized interpolation position (0..1)
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;;;;;;;;GAQG;AACH,mCAPW,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,GACL,MAAM,CAajB"}
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
- * @param {number} t normalized interpolation position (0..1)
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,4 @@
1
+ export class AnimationClip {
2
+ name: string
3
+ readonly duration: number
4
+ }
@@ -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,14 @@
1
+ import {AnimationClip} from "./AnimationClip";
2
+
3
+ export class AnimationClipBinding {
4
+ /**
5
+ * @deprecated
6
+ */
7
+ readonly name: string
8
+ /**
9
+ * @deprecated
10
+ */
11
+ readonly duration: number
12
+
13
+ clip: AnimationClip
14
+ }
@@ -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 "./AnimationCurve.js";
8
- import { EntityNodeAnimationClip } from "./EntityNodeAnimationClip.js";
9
- import { Keyframe } from "./Keyframe.js";
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 AnimatedValueBinding.from(writer, curves);
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
- const tracks = [];
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 engine_track = convert_three_track(three_tracks[i], node);
335
- tracks.push(engine_track);
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
- const r = new EntityNodeAnimationClip();
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
  }