hello_node_brush.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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 node_list = [
  7. {
  8. id: 0,
  9. name: node_name,
  10. type: node_type,
  11. x: 0,
  12. y: 0,
  13. color: 0xffb34f5a,
  14. inputs: [
  15. {
  16. id: 0,
  17. node_id: 0,
  18. name: "Scale",
  19. type: "VALUE",
  20. color: 0xffa1a1a1,
  21. default_value__f32: [1.0],
  22. min__f32: 0.0,
  23. max__f32: 5.0,
  24. precision__f32: 100.0,
  25. display: 0
  26. }
  27. ],
  28. outputs: [
  29. {
  30. id: 0,
  31. node_id: 0,
  32. name: "Value",
  33. type: "VALUE",
  34. color: 0xffc7c729,
  35. default_value__f32: [1.0],
  36. min__f32: 0.0,
  37. max__f32: 5.0,
  38. precision__f32: 100.0,
  39. display: 0
  40. }
  41. ],
  42. buttons: [],
  43. width: 0,
  44. flags: 0
  45. }
  46. ];
  47. nodes_brush_category_add(category_name, armpack_encode(node_list));
  48. // Brush node
  49. parser_logic_custom_nodes_set(node_type, function(node, from) {
  50. return Math.sin(sys_time() * node.inputs[0].get(0));
  51. });
  52. // Cleanup
  53. plugin_notify_on_delete(plugin, function() {
  54. parser_logic_custom_nodes_delete(node_type);
  55. nodes_brush_category_remove(category_name);
  56. });