hello_node_brush.js 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. let plugin = new arm.Plugin();
  2. let categoryName = "My Nodes";
  3. let nodeName = "Hello World";
  4. let nodeType = "HELLO_WORLD";
  5. // Create new node category
  6. let categories = arm.NodesBrush.categories;
  7. categories.push(categoryName);
  8. // Create new node
  9. let nodes = [
  10. {
  11. id: 0,
  12. name: nodeName,
  13. type: nodeType,
  14. x: 0,
  15. y: 0,
  16. color: 0xffb34f5a,
  17. inputs: [
  18. {
  19. id: 0,
  20. node_id: 0,
  21. name: "Scale",
  22. type: "VALUE",
  23. color: 0xffa1a1a1,
  24. default_value: 1.0,
  25. min: 0.0,
  26. max: 5.0
  27. }
  28. ],
  29. outputs: [
  30. {
  31. id: 0,
  32. node_id: 0,
  33. name: "Value",
  34. type: "VALUE",
  35. color: 0xffc7c729,
  36. default_value: 1.0
  37. }
  38. ],
  39. buttons: []
  40. }
  41. ];
  42. arm.NodesBrush.list.push(nodes);
  43. // Brush node
  44. arm.Brush.customNodes.set(nodeType, function(node, from) {
  45. return Math.sin(iron.Time.time() * node.inputs[0].get(0));
  46. });
  47. // Cleanup
  48. plugin.delete = function() {
  49. arm.Brush.customNodes.delete(nodeType);
  50. arm.NodesBrush.list.splice(arm.NodesBrush.list.indexOf(nodes), 1);
  51. categories.splice(categories.indexOf(categoryName), 1);
  52. };