@woosh/meep-engine 2.44.6 → 2.44.7
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.
|
@@ -127,6 +127,10 @@ export class Connection {
|
|
|
127
127
|
^ (target_hash)
|
|
128
128
|
;
|
|
129
129
|
}
|
|
130
|
+
|
|
131
|
+
toString() {
|
|
132
|
+
return `Connection{ id = ${this.id}, source=${this.source !== null ? this.source.id : 'null'}, target=${this.target !== null ? this.target.id : 'null'} }`
|
|
133
|
+
}
|
|
130
134
|
}
|
|
131
135
|
|
|
132
136
|
|
|
@@ -5,6 +5,7 @@ import { Connection } from "./Connection.js";
|
|
|
5
5
|
import { NodeInstance } from "./node/NodeInstance.js";
|
|
6
6
|
import { array_push_if_unique } from "../../collection/array/array_push_if_unique.js";
|
|
7
7
|
import { array_remove_first } from "../../collection/array/array_remove_first.js";
|
|
8
|
+
import { PortDirection } from "./node/PortDirection.js";
|
|
8
9
|
|
|
9
10
|
export class NodeGraph {
|
|
10
11
|
constructor() {
|
|
@@ -227,6 +228,7 @@ export class NodeGraph {
|
|
|
227
228
|
}
|
|
228
229
|
|
|
229
230
|
/**
|
|
231
|
+
* Utility method to help in creation of connections
|
|
230
232
|
* Same as {@link #createConnection}, but ports are identified by their named instead
|
|
231
233
|
* @param {number} sourceNode
|
|
232
234
|
* @param {string} sourcePort
|
|
@@ -236,12 +238,26 @@ export class NodeGraph {
|
|
|
236
238
|
*/
|
|
237
239
|
createConnectionByPortName(
|
|
238
240
|
sourceNode, sourcePort,
|
|
239
|
-
targetNode, targetPort
|
|
241
|
+
targetNode, targetPort
|
|
242
|
+
) {
|
|
240
243
|
const source_node_instance = this.getNodeSafe(sourceNode);
|
|
241
244
|
const target_node_instance = this.getNodeSafe(targetNode);
|
|
242
245
|
|
|
243
|
-
const
|
|
244
|
-
|
|
246
|
+
const source_ports = source_node_instance.description.getPortsByName(sourcePort).filter(p => p.direction === PortDirection.Out);
|
|
247
|
+
|
|
248
|
+
if (source_ports.length > 1) {
|
|
249
|
+
throw new Error(`Multiple source ports match name '${sourcePort}'`);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
const source_port_object = source_ports[0];
|
|
253
|
+
|
|
254
|
+
const target_ports = target_node_instance.description.getPortsByName(targetPort).filter(p => p.direction === PortDirection.In);
|
|
255
|
+
|
|
256
|
+
if (target_ports.length > 1) {
|
|
257
|
+
throw new Error(`Multiple target ports match name '${targetPort}'`);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
const target_port_object = target_ports[0];
|
|
245
261
|
|
|
246
262
|
if (source_port_object === undefined) {
|
|
247
263
|
throw new Error(`Source port '${sourcePort}' not found`);
|
|
@@ -177,20 +177,31 @@ export class NodeDescription {
|
|
|
177
177
|
|
|
178
178
|
/**
|
|
179
179
|
*
|
|
180
|
-
* @param name
|
|
181
|
-
* @return {Port
|
|
180
|
+
* @param {string} name
|
|
181
|
+
* @return {Port[]}
|
|
182
182
|
*/
|
|
183
|
-
|
|
183
|
+
getPortsByName(name) {
|
|
184
184
|
assert.isString(name, 'name');
|
|
185
185
|
|
|
186
|
-
|
|
186
|
+
/**
|
|
187
|
+
*
|
|
188
|
+
* @type {Port[]}
|
|
189
|
+
*/
|
|
190
|
+
const result = [];
|
|
191
|
+
|
|
192
|
+
const ports = this.ports;
|
|
193
|
+
const port_count = ports.length;
|
|
194
|
+
|
|
195
|
+
for (let i = 0; i < port_count; i++) {
|
|
196
|
+
const port = ports[i];
|
|
197
|
+
|
|
187
198
|
if (port.name === name) {
|
|
188
|
-
|
|
199
|
+
result.push(port);
|
|
189
200
|
}
|
|
201
|
+
|
|
190
202
|
}
|
|
191
203
|
|
|
192
|
-
|
|
193
|
-
return undefined;
|
|
204
|
+
return result;
|
|
194
205
|
}
|
|
195
206
|
|
|
196
207
|
/**
|
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.
|
|
8
|
+
"version": "2.44.7",
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"gl-matrix": "3.4.3",
|
|
11
11
|
"fast-levenshtein": "2.0.6",
|