@woosh/meep-engine 2.47.33 → 2.47.34

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.47.33",
8
+ "version": "2.47.34",
9
9
  "main": "build/meep.module.js",
10
10
  "module": "build/meep.module.js",
11
11
  "exports": {
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Matrix-transform an array of 3d direction vectors
3
+ * Code is inlined for speed
4
+ * @param {number[]|Float32Array|Float64Array} source
5
+ * @param {number} source_offset
6
+ * @param {number[]|Float32Array|Float64Array} destination
7
+ * @param {number} destination_offset
8
+ * @param {number} vertex_count
9
+ * @param {mat4|number[]|Float32Array} mat4
10
+ */
11
+ export function apply_mat4_transform_to_direction_v3_array(source, source_offset, destination, destination_offset, vertex_count, mat4) {
12
+
13
+ const a0 = mat4[0];
14
+ const a1 = mat4[1];
15
+ const a2 = mat4[2];
16
+
17
+ const b0 = mat4[4];
18
+ const b1 = mat4[5];
19
+ const b2 = mat4[6];
20
+
21
+ const c0 = mat4[8];
22
+ const c1 = mat4[9];
23
+ const c2 = mat4[10];
24
+
25
+ for (let i = 0; i < vertex_count; i++) {
26
+ const i3 = i * 3;
27
+
28
+ const source_vertex_address = source_offset + i3;
29
+
30
+ const _x = source[source_vertex_address];
31
+ const _y = source[source_vertex_address + 1];
32
+ const _z = source[source_vertex_address + 2];
33
+
34
+ const x = a0 * _x + b0 * _y + c0 * _z;
35
+ const y = a1 * _x + b1 * _y + c1 * _z;
36
+ const z = a2 * _x + b2 * _y + c2 * _z;
37
+
38
+ const normal_multiplier = 1 / Math.hypot(x, y, z);
39
+
40
+ const destination_vertex_address = destination_offset + i3;
41
+
42
+ destination[destination_vertex_address] = x * normal_multiplier;
43
+ destination[destination_vertex_address + 1] = y * normal_multiplier;
44
+ destination[destination_vertex_address + 2] = z * normal_multiplier;
45
+
46
+
47
+ }
48
+
49
+ }
@@ -5,10 +5,10 @@
5
5
  * @param {number} source_offset
6
6
  * @param {number[]|Float32Array|Float64Array} destination
7
7
  * @param {number} destination_offset
8
- * @param {number} count
8
+ * @param {number} vertex_count
9
9
  * @param {mat4|number[]|Float32Array} mat4
10
10
  */
11
- export function apply_mat4_transform_to_v3_array(source, source_offset, destination, destination_offset, count, mat4) {
11
+ export function apply_mat4_transform_to_v3_array(source, source_offset, destination, destination_offset, vertex_count, mat4) {
12
12
 
13
13
  const a0 = mat4[0];
14
14
  const a1 = mat4[1];
@@ -26,7 +26,7 @@ export function apply_mat4_transform_to_v3_array(source, source_offset, destinat
26
26
  const d1 = mat4[13];
27
27
  const d2 = mat4[14];
28
28
 
29
- for (let i = 0; i < count; i++) {
29
+ for (let i = 0; i < vertex_count; i++) {
30
30
  const i3 = i * 3;
31
31
 
32
32
  const source_vertex_address = source_offset + i3;
@@ -49,3 +49,4 @@ export function apply_mat4_transform_to_v3_array(source, source_offset, destinat
49
49
  }
50
50
 
51
51
  }
52
+
@@ -83,6 +83,15 @@ export class NodeDescription {
83
83
  };
84
84
  }
85
85
 
86
+ /**
87
+ * Perform additional processing on the node instance
88
+ * This gives us an opportunity to add/change ports based on current state of a specific node instance
89
+ * @param {NodeInstance} instance
90
+ */
91
+ configureNode(instance){
92
+ // override in subclasses as necessary
93
+ }
94
+
86
95
  /**
87
96
  * Output ports
88
97
  * @returns {Port[]}
@@ -32,7 +32,6 @@ export class NodeInstance {
32
32
  */
33
33
  this.endpoints = [];
34
34
 
35
-
36
35
  /**
37
36
  * Internal instance data
38
37
  * @type {Object}
@@ -51,6 +50,14 @@ export class NodeInstance {
51
50
  */
52
51
  this.connections = new List();
53
52
 
53
+ /**
54
+ * Extra ports that are present just on this instance, these exist in addition to ports from the description
55
+ * IDs of these ports must not collide with IDs of ports on the description
56
+ * @protected
57
+ * @type {Port[]}
58
+ */
59
+ this.dynamicPorts = [];
60
+
54
61
  /**
55
62
  * @readonly
56
63
  */
@@ -254,6 +261,8 @@ export class NodeInstance {
254
261
  setDescription(node) {
255
262
  this.description = node;
256
263
 
264
+ node.configureNode(this);
265
+
257
266
  //generate endpoints
258
267
  this.endpoints = node.getPorts().map((port, port_index) => {
259
268
  const endpoint = new NodeInstancePortReference();