tex_image_node.ts 1.8 KB

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