image_texture_node.ts 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. type image_texture_node_t = {
  2. base?: logic_node_t;
  3. file?: string;
  4. color_space?: string;
  5. };
  6. function image_texture_node_create(arg: any): image_texture_node_t {
  7. let n: image_texture_node_t = {};
  8. n.base = logic_node_create();
  9. n.base.get_as_image = image_texture_node_get_as_image;
  10. n.base.get_cached_image = image_texture_node_get_cached_image;
  11. return n;
  12. }
  13. function image_texture_node_get_as_image(self: image_texture_node_t, from: i32): image_t {
  14. let index = array_index_of(project_asset_names, self.file);
  15. let asset = project_assets[index];
  16. return project_get_image(asset);
  17. }
  18. function image_texture_node_get_cached_image(self: image_texture_node_t): image_t {
  19. let image: image_t = self.base.get_as_image(self, 0);
  20. return image;
  21. }
  22. let image_texture_node_def: zui_node_t = {
  23. id: 0,
  24. name: _tr("Image Texture"),
  25. type: "image_texture_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: "RGBA",
  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. };