separate_vector_node.ts 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. type separate_vector_node_t = {
  2. base?: logic_node_t;
  3. };
  4. function separate_vector_node_create(raw: ui_node_t, args: f32_array_t): separate_vector_node_t {
  5. let n: separate_vector_node_t = {};
  6. n.base = logic_node_create(n);
  7. n.base.get = separate_vector_node_get;
  8. return n;
  9. }
  10. function separate_vector_node_get(self: separate_vector_node_t, from: i32): logic_node_value_t {
  11. let vector: vec4_t = logic_node_input_get(self.base.inputs[0])._vec4;
  12. if (from == 0) {
  13. let v: logic_node_value_t = {_f32 : vector.x};
  14. return v;
  15. }
  16. else if (from == 1) {
  17. let v: logic_node_value_t = {_f32 : vector.y};
  18. return v;
  19. }
  20. else {
  21. let v: logic_node_value_t = {_f32 : vector.z};
  22. return v;
  23. }
  24. }
  25. let separate_vector_node_def: ui_node_t = {
  26. id : 0,
  27. name : _tr("Separate Vector"),
  28. type : "separate_vector_node",
  29. x : 0,
  30. y : 0,
  31. color : 0xff4982a0,
  32. inputs : [ {
  33. id : 0,
  34. node_id : 0,
  35. name : _tr("Vector"),
  36. type : "VECTOR",
  37. color : 0xff6363c7,
  38. default_value : f32_array_create_xyz(0.0, 0.0, 0.0),
  39. min : 0.0,
  40. max : 1.0,
  41. precision : 100,
  42. display : 0
  43. } ],
  44. outputs : [
  45. {
  46. id : 0,
  47. node_id : 0,
  48. name : _tr("X"),
  49. type : "VALUE",
  50. color : 0xffa1a1a1,
  51. default_value : f32_array_create_x(0.0),
  52. min : 0.0,
  53. max : 1.0,
  54. precision : 100,
  55. display : 0
  56. },
  57. {
  58. id : 0,
  59. node_id : 0,
  60. name : _tr("Y"),
  61. type : "VALUE",
  62. color : 0xffa1a1a1,
  63. default_value : f32_array_create_x(0.0),
  64. min : 0.0,
  65. max : 1.0,
  66. precision : 100,
  67. display : 0
  68. },
  69. {
  70. id : 0,
  71. node_id : 0,
  72. name : _tr("Z"),
  73. type : "VALUE",
  74. color : 0xffa1a1a1,
  75. default_value : f32_array_create_x(0.0),
  76. min : 0.0,
  77. max : 1.0,
  78. precision : 100,
  79. display : 0
  80. }
  81. ],
  82. buttons : [],
  83. width : 0,
  84. flags : 0
  85. };