tex_image_node.ts 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. type tex_image_node_t = {
  2. base?: logic_node_t;
  3. raw?: ui_node_t;
  4. };
  5. function tex_image_node_create(raw: ui_node_t, args: f32_array_t): tex_image_node_t {
  6. let n: tex_image_node_t = {};
  7. n.base = logic_node_create(n);
  8. n.base.get = tex_image_node_get;
  9. n.raw = raw;
  10. return n;
  11. }
  12. function tex_image_node_get(self: tex_image_node_t, from: i32): logic_node_value_t {
  13. let ar: string[] = ui_nodes_enum_texts(self.raw.type);
  14. let i: i32 = self.raw.buttons[0].default_value[0];
  15. let file: string = ar[i];
  16. if (from == 0) {
  17. let v: logic_node_value_t = { _str: file + ".rgb" };
  18. return v;
  19. }
  20. else {
  21. let v: logic_node_value_t = { _str: file + ".a" };
  22. return v;
  23. }
  24. }
  25. let tex_image_node_def: ui_node_t = {
  26. id: 0,
  27. name: _tr("Image Texture"),
  28. // type: "tex_image_node",
  29. type: "TEX_IMAGE",
  30. x: 0,
  31. y: 0,
  32. color: 0xff4982a0,
  33. inputs: [
  34. {
  35. id: 0,
  36. node_id: 0,
  37. name: _tr("Vector"),
  38. type: "VECTOR",
  39. color: 0xff6363c7,
  40. default_value: f32_array_create_xyz(0.0, 0.0, 0.0),
  41. min: 0.0,
  42. max: 1.0,
  43. precision: 100,
  44. display: 0
  45. }
  46. ],
  47. outputs: [
  48. {
  49. id: 0,
  50. node_id: 0,
  51. name: _tr("Color"),
  52. type: "VALUE", // Match brush output socket type
  53. color: 0xffc7c729,
  54. default_value: f32_array_create_xyzw(0.0, 0.0, 0.0, 1.0),
  55. min: 0.0,
  56. max: 1.0,
  57. precision: 100,
  58. display: 0
  59. },
  60. {
  61. id: 0,
  62. node_id: 0,
  63. name: _tr("Alpha"),
  64. type: "VALUE",
  65. color: 0xffa1a1a1,
  66. default_value: f32_array_create_x(1.0),
  67. min: 0.0,
  68. max: 1.0,
  69. precision: 100,
  70. display: 0
  71. }
  72. ],
  73. buttons: [
  74. {
  75. name: _tr("file"),
  76. type: "ENUM",
  77. output: -1,
  78. default_value: f32_array_create_x(0),
  79. data: u8_array_create_from_string(""),
  80. min: 0.0,
  81. max: 1.0,
  82. precision: 100,
  83. height: 0
  84. },
  85. {
  86. name: _tr("color_space"),
  87. type: "ENUM",
  88. output: -1,
  89. default_value: f32_array_create_x(0),
  90. data: u8_array_create_from_string("linear\nsrgb"),
  91. min: 0.0,
  92. max: 1.0,
  93. precision: 100,
  94. height: 0
  95. }
  96. ],
  97. width: 0
  98. };