@woosh/meep-engine 2.44.0 → 2.44.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.
@@ -3,6 +3,8 @@ import List from "../../collection/list/List.js";
3
3
  import IdPool from "../../IdPool.js";
4
4
  import { Connection } from "./Connection.js";
5
5
  import { NodeInstance } from "./node/NodeInstance.js";
6
+ import { array_push_if_unique } from "../../collection/array/array_push_if_unique.js";
7
+ import { array_remove_first } from "../../collection/array/array_remove_first.js";
6
8
 
7
9
  export class NodeGraph {
8
10
  constructor() {
@@ -59,6 +61,22 @@ export class NodeGraph {
59
61
  this.connections.forEach(visitor, thisArg);
60
62
  }
61
63
 
64
+ /**
65
+ * Returns an array of all node instances, note that this array is a copy
66
+ * @return {NodeInstance[]}
67
+ */
68
+ getNodes() {
69
+ return this.nodes.data.slice();
70
+ }
71
+
72
+ /**
73
+ * Returns an array of all connections, note that this array is a copy
74
+ * @return {Connection[]}
75
+ */
76
+ getConnections() {
77
+ return this.connections.data.slice();
78
+ }
79
+
62
80
  /**
63
81
  *
64
82
  * @param {number} id
@@ -247,6 +265,9 @@ export class NodeGraph {
247
265
  sourceNodeInstance.connections.addUnique(connection);
248
266
  targetNodeInstance.connections.addUnique(connection);
249
267
 
268
+ array_push_if_unique(sourceEndpoint.connections, connection);
269
+ array_push_if_unique(targetEndpoint.connections, connection);
270
+
250
271
  return id;
251
272
  }
252
273
 
@@ -266,8 +287,14 @@ export class NodeGraph {
266
287
  this.connections.removeOneOf(connection);
267
288
 
268
289
  // remove from end-point nodes
269
- connection.source.instance.connections.removeOneOf(connection);
270
- connection.target.instance.connections.removeOneOf(connection);
290
+ const sourceEndpoint = connection.source;
291
+ const targetEndpoint = connection.target;
292
+
293
+ sourceEndpoint.instance.connections.removeOneOf(connection);
294
+ targetEndpoint.instance.connections.removeOneOf(connection);
295
+
296
+ array_remove_first(sourceEndpoint.connections, connection);
297
+ array_remove_first(targetEndpoint.connections, connection);
271
298
 
272
299
  return true;
273
300
  }
@@ -2,6 +2,7 @@ import { assert } from "../../../assert.js";
2
2
  import { NodeParameterDataType } from "./parameter/NodeParameterDataType.js";
3
3
  import { NodeParameterDescription } from "./parameter/NodeParameterDescription.js";
4
4
  import { Port } from "./Port.js";
5
+ import { PortDirection } from "./PortDirection.js";
5
6
 
6
7
 
7
8
  /**
@@ -192,6 +193,34 @@ export class NodeDescription {
192
193
  return undefined;
193
194
  }
194
195
 
196
+ /**
197
+ *
198
+ * @param {PortDirection} direction
199
+ * @return {Port[]}
200
+ */
201
+ getPortsByDirection(direction) {
202
+ assert.enum(direction, PortDirection, 'direction');
203
+
204
+ /**
205
+ *
206
+ * @type {Port[]}
207
+ */
208
+ const result = [];
209
+
210
+ const ports = this.ports;
211
+ const port_count = ports.length;
212
+
213
+ for (let i = 0; i < port_count; i++) {
214
+ const port = ports[i];
215
+
216
+ if (port.direction === direction) {
217
+ result.push(port)
218
+ }
219
+ }
220
+
221
+ return result;
222
+ }
223
+
195
224
  /**
196
225
  *
197
226
  * @returns {Port[]}
@@ -20,15 +20,24 @@ export class NodeInstancePortReference {
20
20
  this.id = id_counter++;
21
21
 
22
22
  /**
23
- *
23
+ * @readonly
24
24
  * @type {NodeInstance}
25
25
  */
26
26
  this.instance = null;
27
+
27
28
  /**
28
- *
29
+ * @readonly
29
30
  * @type {Port}
30
31
  */
31
32
  this.port = null;
33
+
34
+ /**
35
+ * Attached connections
36
+ * NOTE: Maintained by NodeGraph, do not modify
37
+ * @readonly
38
+ * @type {Connection[]}
39
+ */
40
+ this.connections = [];
32
41
  }
33
42
 
34
43
 
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "productName": "Meep",
6
6
  "description": "production-ready JavaScript game engine based on Entity Component System Architecture",
7
7
  "author": "Alexander Goldring",
8
- "version": "2.44.0",
8
+ "version": "2.44.2",
9
9
  "dependencies": {
10
10
  "gl-matrix": "3.4.3",
11
11
  "fast-levenshtein": "2.0.6",