@woosh/meep-engine 2.92.7 → 2.92.9

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.
@@ -65751,7 +65751,7 @@ function bvh32_from_indexed_geometry(bvh, vertices, indices) {
65751
65751
  */
65752
65752
  function bvh32_from_unindexed_geometry(bvh, vertices) {
65753
65753
 
65754
- const triangle_count = indices.length / 3;
65754
+ const triangle_count = vertices.length / 3;
65755
65755
 
65756
65756
  bvh.setLeafCount(triangle_count);
65757
65757
  bvh.initialize_structure();
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.7",
8
+ "version": "2.92.9",
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":"AAuSA;;;;GAIG;AACH,mGAaC;wCAnTuC,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,6 +3,7 @@ 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";
@@ -22,6 +23,40 @@ function get_node_name(node) {
22
23
  return name.getValue();
23
24
  }
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
+
25
60
  /**
26
61
  *
27
62
  * @param {EntityNode} root
@@ -31,30 +66,20 @@ function entity_node_resolve_path(root, path_parts) {
31
66
 
32
67
  let node = root;
33
68
 
34
- 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++) {
35
71
 
36
72
  const part = path_parts[i];
37
73
 
38
- const children = node.children;
74
+ const sub_node = find_node(node, part);
39
75
 
40
- const child_count = children.length;
76
+ if (sub_node === undefined) {
41
77
 
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)}]`);
42
79
 
43
- for (let j = 0; j < child_count; j++) {
44
- /**
45
- * @type {EntityNode}
46
- */
47
- const child = children[j];
48
-
49
- const name = get_node_name(child);
50
-
51
- if (name === part) {
52
- node = child;
53
- continue main;
54
- }
55
80
  }
56
81
 
57
- throw new Error(`Child '${part}' not found, at index ${i} of [${path_parts.join(', ')}]. Valid names at this level: [${children.map(get_node_name)}]`);
82
+ node = sub_node;
58
83
  }
59
84
 
60
85
  return node;
@@ -300,9 +325,18 @@ function convert_three_track(track, node) {
300
325
  */
301
326
  export function convert_three_clip(node, clip) {
302
327
  const three_tracks = clip.tracks;
328
+ const track_count = three_tracks.length;
303
329
 
304
- const tracks = three_tracks.map(t => convert_three_track(t, node));
330
+ const tracks = [];
305
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
+ }
306
340
 
307
341
  const r = new EntityNodeAnimationClip();
308
342
 
@@ -37,36 +37,56 @@ async function main(engine) {
37
37
  pitch: 0.030000000000008027,
38
38
  yaw: 3.123185307179593,
39
39
  });
40
+ //
41
+ // make_sample('data/models/samples/InterpolationTest.glb',[
42
+ // 'Step Scale',
43
+ // 'Linear Scale',
44
+ // 'CubicSpline Scale',
45
+ // 'Step Rotation',
46
+ // 'CubicSpline Rotation',
47
+ // 'Linear Rotation',
48
+ // 'Step Translation',
49
+ // 'CubicSpline Translation',
50
+ // 'Linear Translation'
51
+ // ],engine.entityManager.dataset);
52
+ //
53
+ make_sample('data/models/samples/BoxAnimated.glb',[
54
+ 'animation_0'
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) {
40
69
 
41
70
  const controller = new SGMeshAnimationController();
42
71
 
43
- [
44
- 'Step Scale',
45
- 'Linear Scale',
46
- 'CubicSpline Scale',
47
- 'Step Rotation',
48
- 'CubicSpline Rotation',
49
- 'Linear Rotation',
50
- 'Step Translation',
51
- 'CubicSpline Translation',
52
- 'Linear Translation'
53
- ].forEach(name => {
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));
@@ -7,7 +7,7 @@ import { bvh32_set_leaf_from_triangle } from "./bvh32_set_leaf_from_triangle.js"
7
7
  */
8
8
  export function bvh32_from_unindexed_geometry(bvh, vertices) {
9
9
 
10
- const triangle_count = indices.length / 3;
10
+ const triangle_count = vertices.length / 3;
11
11
 
12
12
  bvh.setLeafCount(triangle_count);
13
13
  bvh.initialize_structure();
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=bvh32_from_unindexed_geometry.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bvh32_from_unindexed_geometry.spec.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/graphics/geometry/bvh/buffered/bvh32_from_unindexed_geometry.spec.js"],"names":[],"mappings":""}
@@ -0,0 +1,16 @@
1
+ import { BinaryUint32BVH } from "../../../../../core/bvh2/binary/2/BinaryUint32BVH.js";
2
+ import { bvh32_from_unindexed_geometry } from "./bvh32_from_unindexed_geometry.js";
3
+
4
+ test("1 triangle geometry", () => {
5
+ const bvh = new BinaryUint32BVH();
6
+
7
+ bvh32_from_unindexed_geometry(bvh, new Float32Array([1, 2, 3]));
8
+
9
+ const address = bvh.getNodeAddress(0);
10
+
11
+ const bounds = [];
12
+
13
+ bvh.readBounds(address, bounds, 0);
14
+
15
+ expect(bounds).toEqual([1, 2, 3, 1, 2, 3]);
16
+ });