Create new Nodes
The Node is the central data storing and data processing element within the Spatial Toolbox. You can define new nodes that your hardware Interface and your spatial Tool can use. Each Node needs to have a specific structure to function.
Folder Structure
Your node-addon should be stored in the addons/nodes/[yourNodeAddon]/ folder, and it requires two files as a default:
index.js
stores all the logic for your Node.gui/index.html
This stores the visible appearance for the Node
generalProperties
generalProperties
(Object) defines the data parameters for the new Node.name
(String) The name for the NodeprivateData
(Object) Use this Object to define private data. The Spatial Toolbox can only write content to this Object but it can not read content.publicData
(Object) Use this Object to define additional data types that your Node requires. Keys need to be defined in this Object so that the Spatial Toolbox can access them.type
(String) Type should match the folder name.
setup(object, tool, node, thisNode)
object
(String)tool
(String)node
(String)thisNode
(Object)
render(object, tool, node, thisNode, callback)
object
(String) Currently processed Object UUIDtool
(String) Currently processed Tool UUIDnode
(String) Currently processed Node UUIDthisNode
(Object) Reference to the node Objectcallback
(Object) callback for when the data flow processing engine should continue.- Returns
object
(String) Currently processed Object UUID - Returns
tool
(String) Currently processed Tool UUID - Returns
node
(String) Currently processed Node UUID - Returns
thisNode
(Object) Reference to the node Object
The Edge Server will call this function on any tick. It will provide the Object, Tool, node UUIDs as well the entire node Object as ReferenceReference. In case you want your Node to act as an input and output, you must call the callback function so that an output event is triggered. You can call this callback asynchronous at any time.
All in all, the node logic has four parts:
- generalProperties act as a data storage
- setup executes a single time
- render is called by the edge server whenever a new tick triggers trough the logic.
- spatial data that is saved by the Edge Server and edited via the Spatial Toolbox. This spatial data is accessible via
thisNode
reference.
Example of a delay node:
var generalProperties = {
name: 'delay',
privateData: {},
publicData: {delayTime: 1000},
type: 'delay'
};
exports.properties = generalProperties;
exports.setup = function (object, tool, node, nodeProperties) {
// add code here that should be executed once.
};
exports.render = function (object, tool, node, thisNode, callback) {
var delayedValue = thisNode.data.value;
setTimeout(function() {
thisNode.processedData.value = delayedValue;
callback(object, tool, node, thisNode);
}, thisNode.publicData.delayTime);
};