2
0

separate_vector_node.ts 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. type separate_vector_node_t = {
  2. base?: logic_node_t;
  3. };
  4. function separate_vector_node_create(arg: any): separate_vector_node_t {
  5. let n: separate_vector_node_t = {};
  6. n.base = logic_node_create();
  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])._any;
  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: zui_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. {
  34. id: 0,
  35. node_id: 0,
  36. name: _tr("Vector"),
  37. type: "VECTOR",
  38. color: 0xff6363c7,
  39. default_value: f32_array_create_xyz(0.0, 0.0, 0.0),
  40. min: 0.0,
  41. max: 1.0,
  42. precision: 100,
  43. display: 0
  44. }
  45. ],
  46. outputs: [
  47. {
  48. id: 0,
  49. node_id: 0,
  50. name: _tr("X"),
  51. type: "VALUE",
  52. color: 0xffa1a1a1,
  53. default_value: f32_array_create_x(0.0),
  54. min: 0.0,
  55. max: 1.0,
  56. precision: 100,
  57. display: 0
  58. },
  59. {
  60. id: 0,
  61. node_id: 0,
  62. name: _tr("Y"),
  63. type: "VALUE",
  64. color: 0xffa1a1a1,
  65. default_value: f32_array_create_x(0.0),
  66. min: 0.0,
  67. max: 1.0,
  68. precision: 100,
  69. display: 0
  70. },
  71. {
  72. id: 0,
  73. node_id: 0,
  74. name: _tr("Z"),
  75. type: "VALUE",
  76. color: 0xffa1a1a1,
  77. default_value: f32_array_create_x(0.0),
  78. min: 0.0,
  79. max: 1.0,
  80. precision: 100,
  81. display: 0
  82. }
  83. ],
  84. buttons: [],
  85. width: 0
  86. };