Files
armorpaint/armorlab/Sources/nodes/image_texture_node.ts
T

100 lines
2.0 KiB
TypeScript
Raw Normal View History

2024-03-14 23:58:24 +01:00
type image_texture_node_t = {
base?: logic_node_t;
file?: string;
color_space?: string;
};
2024-03-21 21:06:41 +01:00
function image_texture_node_create(arg: any): image_texture_node_t {
2024-03-14 23:58:24 +01:00
let n: image_texture_node_t = {};
n.base = logic_node_create();
n.base.get_as_image = image_texture_node_get_as_image;
n.base.get_cached_image = image_texture_node_get_cached_image;
return n;
}
2024-04-02 15:45:49 +02:00
function image_texture_node_get_as_image(self: image_texture_node_t, from: i32): image_t {
2024-03-20 16:13:54 +01:00
let index = array_index_of(project_asset_names, self.file);
2024-03-14 23:58:24 +01:00
let asset = project_assets[index];
2024-04-02 15:45:49 +02:00
return project_get_image(asset);
2024-03-14 23:58:24 +01:00
}
function image_texture_node_get_cached_image(self: image_texture_node_t): image_t {
2024-04-02 15:45:49 +02:00
let image: image_t = self.base.get_as_image(self, 0);
2024-03-14 23:58:24 +01:00
return image;
}
let image_texture_node_def: zui_node_t = {
id: 0,
name: _tr("Image Texture"),
type: "image_texture_node",
x: 0,
y: 0,
color: 0xff4982a0,
inputs: [
{
id: 0,
node_id: 0,
name: _tr("Vector"),
type: "VECTOR",
color: 0xff6363c7,
2024-04-10 19:39:17 +02:00
default_value: f32_array_create_xyz(0.0, 0.0, 0.0),
min: 0.0,
max: 1.0,
precision: 100,
display: 0
2024-03-14 23:58:24 +01:00
}
],
outputs: [
{
id: 0,
node_id: 0,
name: _tr("Color"),
type: "RGBA",
color: 0xffc7c729,
2024-04-10 19:39:17 +02:00
default_value: f32_array_create_xyzw(0.0, 0.0, 0.0, 1.0),
min: 0.0,
max: 1.0,
precision: 100,
display: 0
2024-03-14 23:58:24 +01:00
},
{
id: 0,
node_id: 0,
name: _tr("Alpha"),
type: "VALUE",
color: 0xffa1a1a1,
2024-04-24 12:14:47 +02:00
default_value: f32_array_create_x(1.0),
2024-04-10 19:39:17 +02:00
min: 0.0,
max: 1.0,
precision: 100,
display: 0
2024-03-14 23:58:24 +01:00
}
],
buttons: [
{
name: _tr("file"),
type: "ENUM",
2024-04-10 19:39:17 +02:00
output: -1,
2024-04-24 12:14:47 +02:00
default_value: f32_array_create_x(0),
data: u8_array_create_from_string(""),
2024-04-10 19:39:17 +02:00
min: 0.0,
max: 1.0,
precision: 100,
height: 0
2024-03-14 23:58:24 +01:00
},
{
name: _tr("color_space"),
type: "ENUM",
2024-04-10 19:39:17 +02:00
output: -1,
2024-04-24 12:14:47 +02:00
default_value: f32_array_create_x(0),
data: u8_array_create_from_string("linear\0srgb"),
2024-04-10 19:39:17 +02:00
min: 0.0,
max: 1.0,
precision: 100,
height: 0
2024-03-14 23:58:24 +01:00
}
2024-04-10 19:39:17 +02:00
],
width: 0
2024-03-14 23:58:24 +01:00
};