@woosh/meep-engine 2.92.6 → 2.92.8

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 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.6",
8
+ "version": "2.92.8",
9
9
  "main": "build/meep.module.js",
10
10
  "module": "build/meep.module.js",
11
11
  "exports": {
@@ -1 +1 @@
1
- {"version":3,"file":"ecd_bind_animation_curve.d.ts","sourceRoot":"","sources":["../../../../../src/engine/animation/curve/ecd_bind_animation_curve.js"],"names":[],"mappings":"AAwRA;;;;GAIG;AACH,mGAaC;wCApSuC,8BAA8B"}
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"}
@@ -3,10 +3,60 @@ import { AnimatedValueBinding } from "../../graphics/ecs/mesh-v2/aggregate/anima
3
3
  import { BoundQuaternionWriter } from "../../graphics/ecs/mesh-v2/aggregate/animation/BoundQuaternionWriter.js";
4
4
  import { BoundValueWriter } from "../../graphics/ecs/mesh-v2/aggregate/animation/BoundValueWriter.js";
5
5
  import { BoundVector3Writer } from "../../graphics/ecs/mesh-v2/aggregate/animation/BoundVector3Writer.js";
6
+ import { logger } from "../../logging/GlobalLogger.js";
6
7
  import { AnimationCurve } from "./AnimationCurve.js";
7
8
  import { EntityNodeAnimationClip } from "./EntityNodeAnimationClip.js";
8
9
  import { Keyframe } from "./Keyframe.js";
9
10
 
11
+
12
+ /**
13
+ *
14
+ * @param {EntityNode} node
15
+ * @returns {String}
16
+ */
17
+ function get_node_name(node) {
18
+ /**
19
+ * @type {Name}
20
+ */
21
+ const name = node.entity.getComponentSafe(Name);
22
+
23
+ return name.getValue();
24
+ }
25
+
26
+ /**
27
+ * Following THREE.js PropertyBinding.findNode implementation
28
+ * @param {EntityNode} root
29
+ * @param {string} nodeName
30
+ * @returns {EntityNode|undefined}
31
+ */
32
+ function find_node(root, nodeName) {
33
+
34
+ const root_name = get_node_name(root);
35
+
36
+ if (root_name === nodeName) {
37
+ return root;
38
+ }
39
+
40
+ // search into node subtree.
41
+ const children = root.children;
42
+
43
+ const child_count = children.length;
44
+
45
+
46
+ for (let j = 0; j < child_count; j++) {
47
+ /**
48
+ * @type {EntityNode}
49
+ */
50
+ const child = children[j];
51
+
52
+ const subtree_result = find_node(child, nodeName);
53
+
54
+ if (subtree_result !== undefined) {
55
+ return subtree_result;
56
+ }
57
+ }
58
+ }
59
+
10
60
  /**
11
61
  *
12
62
  * @param {EntityNode} root
@@ -16,30 +66,20 @@ function entity_node_resolve_path(root, path_parts) {
16
66
 
17
67
  let node = root;
18
68
 
19
- main:for (let i = 0; i < path_parts.length; i++) {
69
+ const part_count = path_parts.length;
70
+ for (let i = 0; i < part_count; i++) {
20
71
 
21
72
  const part = path_parts[i];
22
73
 
23
- const children = node.children;
24
-
25
- const child_count = children.length;
26
-
74
+ const sub_node = find_node(node, part);
27
75
 
28
- for (let j = 0; j < child_count; j++) {
29
- /**
30
- * @type {EntityNode}
31
- */
32
- const child = children[j];
76
+ if (sub_node === undefined) {
33
77
 
34
- const name = child.entity.getComponentSafe(Name);
78
+ throw new Error(`Child '${part}' not found, at index ${i} of [${path_parts.join(', ')}]. Valid names at this level: [${node.children.map(get_node_name)}]`);
35
79
 
36
- if (name.getValue() === part) {
37
- node = child;
38
- continue main;
39
- }
40
80
  }
41
81
 
42
- throw new Error(`Child '${part}' not found, at index ${i} of [${path_parts.join(', ')}]`);
82
+ node = sub_node;
43
83
  }
44
84
 
45
85
  return node;
@@ -285,9 +325,18 @@ function convert_three_track(track, node) {
285
325
  */
286
326
  export function convert_three_clip(node, clip) {
287
327
  const three_tracks = clip.tracks;
328
+ const track_count = three_tracks.length;
288
329
 
289
- const tracks = three_tracks.map(t => convert_three_track(t, node));
330
+ const tracks = [];
290
331
 
332
+ for (let i = 0; i < track_count; i++) {
333
+ try {
334
+ const engine_track = convert_three_track(three_tracks[i], node);
335
+ tracks.push(engine_track);
336
+ } catch (e) {
337
+ logger.error(`Failed to parse track[${i}]: ${e.message}`);
338
+ }
339
+ }
291
340
 
292
341
  const r = new EntityNodeAnimationClip();
293
342
 
@@ -37,10 +37,8 @@ async function main(engine) {
37
37
  pitch: 0.030000000000008027,
38
38
  yaw: 3.123185307179593,
39
39
  });
40
-
41
- const controller = new SGMeshAnimationController();
42
-
43
- [
40
+ //
41
+ make_sample('data/models/samples/InterpolationTest.glb',[
44
42
  'Step Scale',
45
43
  'Linear Scale',
46
44
  'CubicSpline Scale',
@@ -50,23 +48,45 @@ async function main(engine) {
50
48
  'Step Translation',
51
49
  'CubicSpline Translation',
52
50
  'Linear Translation'
53
- ].forEach(name => {
51
+ ],engine.entityManager.dataset);
52
+ //
53
+ // make_sample('data/models/samples/BoxAnimated.glb',[
54
+ // 'animation_01'
55
+ // ],engine.entityManager.dataset);
56
+ //
57
+ // make_sample('data/models/samples/animatedbox1.gltf', [
58
+ // 'All Animations'
59
+ // ], engine.entityManager.dataset);
60
+ }
61
+
62
+ /**
63
+ *
64
+ * @param {string} path
65
+ * @param {string[]} animations
66
+ * @param {EntityComponentDataset} ecd
67
+ */
68
+ function make_sample(path, animations, ecd) {
69
+
70
+ const controller = new SGMeshAnimationController();
71
+
72
+ animations.forEach(name => {
54
73
 
55
- controller.start(name,true);
74
+ controller.start(name, true);
56
75
 
57
76
  })
58
77
 
59
78
  new Entity()
60
- .add(SGMesh.fromURL('data/models/samples/InterpolationTest.glb'))
79
+ .add(SGMesh.fromURL(path))
61
80
  .add(controller)
62
81
  .add(new Transform())
63
- .build(engine.entityManager.dataset);
64
-
82
+ .build(ecd);
65
83
  }
66
84
 
67
85
  harness.initialize({
68
86
  configuration(config, engine) {
69
- config.addLoader(GameAssetType.ModelGLTF, new GLTFAssetLoader());
87
+ const gltfAssetLoader = new GLTFAssetLoader();
88
+ config.addLoader(GameAssetType.ModelGLTF, gltfAssetLoader);
89
+ config.addLoader(GameAssetType.ModelGLTF_JSON, gltfAssetLoader);
70
90
  config.addSystem(new SGMeshAnimationControllerSystem(engine));
71
91
  config.addSystem(new SGMeshSystem(engine));
72
92
  config.addSystem(new ShadedGeometrySystem(engine));