@woosh/meep-engine 2.44.1 → 2.44.3

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() {
@@ -263,6 +265,9 @@ export class NodeGraph {
263
265
  sourceNodeInstance.connections.addUnique(connection);
264
266
  targetNodeInstance.connections.addUnique(connection);
265
267
 
268
+ array_push_if_unique(sourceEndpoint.connections, connection);
269
+ array_push_if_unique(targetEndpoint.connections, connection);
270
+
266
271
  return id;
267
272
  }
268
273
 
@@ -282,8 +287,14 @@ export class NodeGraph {
282
287
  this.connections.removeOneOf(connection);
283
288
 
284
289
  // remove from end-point nodes
285
- connection.source.instance.connections.removeOneOf(connection);
286
- 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);
287
298
 
288
299
  return true;
289
300
  }
@@ -80,6 +80,23 @@ export class NodeInstance {
80
80
  return count;
81
81
  }
82
82
 
83
+ /**
84
+ * Outgoing connections from this node
85
+ * @return {Connection[]}
86
+ */
87
+ get outConnections() {
88
+ return this.connections.filter(c => c.source.instance === this);
89
+ }
90
+
91
+ /**
92
+ *
93
+ * Incoming connections to this node
94
+ * @return {Connection[]}
95
+ */
96
+ get inConnections() {
97
+ return this.connections.filter(c => c.target.instance === this);
98
+ }
99
+
83
100
  /**
84
101
  *
85
102
  * @param {number} id
@@ -20,15 +20,40 @@ 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 = [];
41
+ }
42
+
43
+ /**
44
+ * Outgoing connections
45
+ * @return {Connection[]}
46
+ */
47
+ get outConnections() {
48
+ return this.connections.filter(c => c.source === this);
49
+ }
50
+
51
+ /**
52
+ * Incoming connections
53
+ * @return {Connection[]}
54
+ */
55
+ get inConnections() {
56
+ return this.connections.filter(c => c.target === this);
32
57
  }
33
58
 
34
59
 
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.1",
8
+ "version": "2.44.3",
9
9
  "dependencies": {
10
10
  "gl-matrix": "3.4.3",
11
11
  "fast-levenshtein": "2.0.6",