@woosh/meep-engine 2.44.4 → 2.44.6
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/core/model/node-graph/Connection.d.ts +12 -0
- package/core/model/node-graph/NodeGraph.js +48 -0
- package/core/model/node-graph/node/NodeDescription.d.ts +3 -0
- package/core/model/node-graph/node/NodeInstance.d.ts +14 -0
- package/core/model/node-graph/node/NodeInstance.js +2 -0
- package/core/model/node-graph/node/NodeInstancePortReference.d.ts +3 -0
- package/package.json +1 -1
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import {NodeInstancePortReference} from "./node/NodeInstancePortReference";
|
|
2
|
+
|
|
3
|
+
export class Connection {
|
|
4
|
+
readonly id: number
|
|
5
|
+
|
|
6
|
+
readonly source: NodeInstancePortReference
|
|
7
|
+
readonly target: NodeInstancePortReference
|
|
8
|
+
|
|
9
|
+
setSource(endpoint: NodeInstancePortReference): void
|
|
10
|
+
|
|
11
|
+
setTarget(endpoint: NodeInstancePortReference): void
|
|
12
|
+
}
|
|
@@ -83,6 +83,8 @@ export class NodeGraph {
|
|
|
83
83
|
* @returns {NodeInstance|undefined}
|
|
84
84
|
*/
|
|
85
85
|
getNode(id) {
|
|
86
|
+
assert.isNonNegativeInteger(id, 'id');
|
|
87
|
+
|
|
86
88
|
const nodes = this.nodes;
|
|
87
89
|
const n = nodes.length;
|
|
88
90
|
|
|
@@ -98,6 +100,21 @@ export class NodeGraph {
|
|
|
98
100
|
return undefined;
|
|
99
101
|
}
|
|
100
102
|
|
|
103
|
+
/**
|
|
104
|
+
* Same as getNode but throw exception when node doesn't exist
|
|
105
|
+
* @param {number} id
|
|
106
|
+
* @returns {NodeInstance}
|
|
107
|
+
*/
|
|
108
|
+
getNodeSafe(id) {
|
|
109
|
+
const result = this.getNode(id);
|
|
110
|
+
|
|
111
|
+
if (result === undefined) {
|
|
112
|
+
throw new Error(`Node ${id} not found`);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return result;
|
|
116
|
+
}
|
|
117
|
+
|
|
101
118
|
/**
|
|
102
119
|
*
|
|
103
120
|
* @param {number} id
|
|
@@ -209,6 +226,37 @@ export class NodeGraph {
|
|
|
209
226
|
return true;
|
|
210
227
|
}
|
|
211
228
|
|
|
229
|
+
/**
|
|
230
|
+
* Same as {@link #createConnection}, but ports are identified by their named instead
|
|
231
|
+
* @param {number} sourceNode
|
|
232
|
+
* @param {string} sourcePort
|
|
233
|
+
* @param {number} targetNode
|
|
234
|
+
* @param {string} targetPort
|
|
235
|
+
* @returns {number} connection ID
|
|
236
|
+
*/
|
|
237
|
+
createConnectionByPortName(
|
|
238
|
+
sourceNode, sourcePort,
|
|
239
|
+
targetNode, targetPort) {
|
|
240
|
+
const source_node_instance = this.getNodeSafe(sourceNode);
|
|
241
|
+
const target_node_instance = this.getNodeSafe(targetNode);
|
|
242
|
+
|
|
243
|
+
const source_port_object = source_node_instance.description.getPortByName(sourcePort);
|
|
244
|
+
const target_port_object = target_node_instance.description.getPortByName(targetPort);
|
|
245
|
+
|
|
246
|
+
if (source_port_object === undefined) {
|
|
247
|
+
throw new Error(`Source port '${sourcePort}' not found`);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
if (target_port_object === undefined) {
|
|
251
|
+
throw new Error(`Target port '${targetPort}' not found`);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
return this.createConnection(
|
|
255
|
+
sourceNode, source_port_object.id,
|
|
256
|
+
targetNode, target_port_object.id,
|
|
257
|
+
);
|
|
258
|
+
}
|
|
259
|
+
|
|
212
260
|
/**
|
|
213
261
|
*
|
|
214
262
|
* @param {number} sourceNode
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import {NodeDescription} from "./NodeDescription";
|
|
2
|
+
import {NodeInstancePortReference} from "./NodeInstancePortReference";
|
|
3
|
+
import List from "../../../collection/list/List";
|
|
4
|
+
import {Connection} from "../Connection";
|
|
5
|
+
|
|
6
|
+
export class NodeInstance {
|
|
7
|
+
readonly id: number
|
|
8
|
+
|
|
9
|
+
readonly description: NodeDescription
|
|
10
|
+
|
|
11
|
+
readonly endpoints: NodeInstancePortReference[]
|
|
12
|
+
|
|
13
|
+
readonly connections: List<Connection>
|
|
14
|
+
}
|
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.6",
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"gl-matrix": "3.4.3",
|
|
11
11
|
"fast-levenshtein": "2.0.6",
|