A node-based editor built with vanilla js.
- Create a new script in the components folder.
- Create your node class, extending from
Node - Create the node's inputs, outputs and data in the class constructor
- Define an update function to run when any connections are updated
- In
ContextMenu.jsimport your new node. - Add a new event for it in the
ContextMenu's constructor (see example)
Example: AddNode
AddNode class
importNodefrom"../core/Node.js";classAddNodeextendsNode{constructor(){super("Add");//Node nameconsta=this.addInput("A");constb=this.addInput("B");consto=this.addOutput("Output");}update(){this.outputs["Output"].value=Number(this.inputs["A"].value)+Number(this.inputs["B"].value);}}exportdefaultAddNode;Defining event in ContextMenu
constevents=[newContextMenuItem("Add",(e)=>{this.createNewNode(e,newAddNode())})]Visible connectionsRemove/edit connectionsDelete nodes- Duplicate nodes
- Iterative nodes
Context menus disappear on exit hover
