NodeGraph
Classes
Graph of nodes, implements node-based programming pattern Notable contemporary examples include:
- SideFX Houdini
- Blender - geometry nodes, shaders
- Unreal Engine - blueprints
- Grasshopper
Members
-
nodeAdded :
Signal.<NodeInstance, number> -
nodeRemoved :
Signal.<NodeInstance, number> -
connectionAdded :
Signal.<Connection, number> -
connectionRemoved :
Signal.<Connection, number>
NodeGraph
Graph of nodes, implements node-based programming pattern Notable contemporary examples include:
- SideFX Houdini
- Blender - geometry nodes, shaders
- Unreal Engine - blueprints
- Grasshopper
Kind: global class
See: https://en.wikipedia.org/wiki/Node_graph_architecture
- NodeGraph
- .version ⇒
number - .on
- .isNodeGraph :
boolean - .reset()
- .copy(other)
- .clone() ⇒
NodeGraph - .merge(other) ⇒
Object - .mergeFragment(nodes, [connections]) ⇒
Object - .traverseNodes(visitor, [thisArg])
- .traverseConnections(visitor, [thisArg])
- .getNodes() ⇒
Array.<NodeInstance> - .getConnections() ⇒
Array.<Connection> - .hasNode(node) ⇒
boolean - .getNodesByDescription(description) ⇒
Array.<NodeInstance> - .getNodesByDescriptionClass(Klass) ⇒
Array.<NodeInstance> - .getNode(id) ⇒
NodeInstance|undefined - .getNodeSafe(id) ⇒
NodeInstance - .getConnection(id) ⇒
Connection|undefined - .getConnectionEndpoint(node_id, port_id) ⇒
NodeInstancePortReference|undefined - .createNode(node) ⇒
number - .addNode(node)
- .deleteNode(id) ⇒
boolean - .createConnectionByPortName(sourceNode, sourcePort, targetNode, targetPort) ⇒
number - .createConnection(sourceNode, sourcePort, targetNode, targetPort) ⇒
number - .deleteConnection(id) ⇒
boolean - .getConnectionsAttachedToNode(id, result) ⇒
number
- .version ⇒
nodeGraph.version ⇒ number
Gets incremented every time structure of the graph changes, meaning nodes or connections are added/removed Unsigned integer value
Kind: instance property of NodeGraph
Read only: true
nodeGraph.on
Kind: instance property of NodeGraph
Read only: true
nodeGraph.isNodeGraph : boolean
Useful for type checks
Kind: instance property of NodeGraph
Read only: true
Example
if(graph.isNodeGraph === true){
// yep, that's a NodeGraph alright!
}
nodeGraph.reset()
Clear out all data from the graph
Kind: instance method of NodeGraph
nodeGraph.copy(other)
Perform a deep copy
Kind: instance method of NodeGraph
| Param | Type |
|---|---|
| other | NodeGraph |
nodeGraph.clone() ⇒ NodeGraph
Kind: instance method of NodeGraph
nodeGraph.merge(other) ⇒ Object
Merge another graph into this one Supplied graph does not change as a result
Kind: instance method of NodeGraph
See: #mergeFragment
| Param | Type |
|---|---|
| other | NodeGraph |
nodeGraph.mergeFragment(nodes, [connections]) ⇒ Object
Merge foreign nodes and associated connections into this graph New node instances and connections will be created to reflect these inside this graph NOTE: parameters on merged nodes are shallow copies NOTE: if IDs are available - copied nodes will have the same IDs as the originals
Kind: instance method of NodeGraph
Returns: Object - local created instances
| Param | Type |
|---|---|
| nodes | Array.<NodeInstance> |
| [connections] | Array.<Connection> |
nodeGraph.traverseNodes(visitor, [thisArg])
Kind: instance method of NodeGraph
| Param | Type |
|---|---|
| visitor | function |
| [thisArg] |
nodeGraph.traverseConnections(visitor, [thisArg])
Kind: instance method of NodeGraph
| Param | Type |
|---|---|
| visitor | function |
| [thisArg] |
nodeGraph.getNodes() ⇒ Array.<NodeInstance>
Returns an array of all node instances NOTE: this array is a copy
Kind: instance method of NodeGraph
nodeGraph.getConnections() ⇒ Array.<Connection>
Returns an array of all connections NOTE: this array is a copy
Kind: instance method of NodeGraph
nodeGraph.hasNode(node) ⇒ boolean
Kind: instance method of NodeGraph
| Param | Type |
|---|---|
| node | NodeInstance |
nodeGraph.getNodesByDescription(description) ⇒ Array.<NodeInstance>
Kind: instance method of NodeGraph
| Param | Type |
|---|---|
| description | NodeDescription |
nodeGraph.getNodesByDescriptionClass(Klass) ⇒ Array.<NodeInstance>
Kind: instance method of NodeGraph
| Param | Type |
|---|---|
| Klass | Type.<NodeDescription> |
nodeGraph.getNode(id) ⇒ NodeInstance | undefined
Kind: instance method of NodeGraph
| Param | Type |
|---|---|
| id | number |
nodeGraph.getNodeSafe(id) ⇒ NodeInstance
Same as getNode but throw exception when node doesn't exist
Kind: instance method of NodeGraph
Throws:
- if node doesn't exist
| Param | Type |
|---|---|
| id | number |
nodeGraph.getConnection(id) ⇒ Connection | undefined
Kind: instance method of NodeGraph
| Param | Type |
|---|---|
| id | number |
nodeGraph.getConnectionEndpoint(node_id, port_id) ⇒ NodeInstancePortReference | undefined
Kind: instance method of NodeGraph
| Param | Type |
|---|---|
| node_id | number |
| port_id | number |
nodeGraph.createNode(node) ⇒ number
Kind: instance method of NodeGraph
Returns: number - ID of the new node
| Param | Type |
|---|---|
| node | NodeDescription |
nodeGraph.addNode(node)
Kind: instance method of NodeGraph
| Param | Type |
|---|---|
| node | NodeInstance |
nodeGraph.deleteNode(id) ⇒ boolean
Kind: instance method of NodeGraph
Returns: boolean - True if deleted, false if node was not found
| Param | Type |
|---|---|
| id | number |
nodeGraph.createConnectionByPortName(sourceNode, sourcePort, targetNode, targetPort) ⇒ number
Utility method to help in creation of connections Same as #createConnection, but ports are identified by their named instead
Kind: instance method of NodeGraph
Returns: number - connection ID
| Param | Type |
|---|---|
| sourceNode | number |
| sourcePort | string |
| targetNode | number |
| targetPort | string |
nodeGraph.createConnection(sourceNode, sourcePort, targetNode, targetPort) ⇒ number
Kind: instance method of NodeGraph
Returns: number - ID of created or already existing connection
Throws:
- if any node or port are not found
| Param | Type |
|---|---|
| sourceNode | number |
| sourcePort | number |
| targetNode | number |
| targetPort | number |
nodeGraph.deleteConnection(id) ⇒ boolean
Kind: instance method of NodeGraph
Returns: boolean - True if deleted, false if connection was not found
| Param | Type |
|---|---|
| id | number |
nodeGraph.getConnectionsAttachedToNode(id, result) ⇒ number
Kind: instance method of NodeGraph
Returns: number - number of found connections
| Param | Type | Description |
|---|---|---|
| id | number | |
| result | Array.<number> | IDs of attached connections |
nodeAdded : Signal.<NodeInstance, number>
Kind: global variable
Read only: true
nodeRemoved : Signal.<NodeInstance, number>
Kind: global variable
Read only: true
connectionAdded : Signal.<Connection, number>
Kind: global variable
Read only: true
connectionRemoved : Signal.<Connection, number>
Kind: global variable
Read only: true