hello_node_brush.js 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. let plugin = plugin_create();
  2. let category_name = "My Nodes";
  3. let node_name = "Hello World";
  4. let node_type = "HELLO_WORLD";
  5. // Create new node category
  6. let categories = nodes_brush_categories;
  7. categories.push(category_name);
  8. // Create new node
  9. let nodes = [
  10. {
  11. id: 0,
  12. name: node_name,
  13. type: node_type,
  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. nodes_brush_list.push(nodes);
  43. // Brush node
  44. parser_logic_custom_nodes.set(node_type, function(node, from) {
  45. return Math.sin(time_time() * node.inputs[0].get(0));
  46. });
  47. // Cleanup
  48. plugin.delete = function() {
  49. parser_logic_custom_nodes.delete(node_type);
  50. nodes_brush_list.splice(nodes_brush_list.indexOf(nodes), 1);
  51. categories.splice(categories.indexOf(category_name), 1);
  52. };