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

74 lines
1.3 KiB
TypeScript
Raw Normal View History

2023-02-16 14:19:00 +01:00
2023-02-08 14:51:54 +01:00
class ImageTextureNode extends LogicNode {
2024-01-17 18:53:31 +01:00
file: string;
color_space: string;
2023-02-08 14:51:54 +01:00
2024-01-17 18:53:31 +01:00
constructor() {
2023-12-12 14:57:44 +01:00
super();
2023-02-08 14:51:54 +01:00
}
2024-02-05 20:57:20 +01:00
override getAsImage = (from: i32, done: (img: image_t)=>void) => {
2024-01-26 22:09:49 +01:00
let index = Project.assetNames.indexOf(this.file);
2024-01-17 18:53:31 +01:00
let asset = Project.assets[index];
2023-02-08 14:51:54 +01:00
done(Project.getImage(asset));
}
2024-02-05 20:57:20 +01:00
override getCachedImage = (): image_t => {
let image: image_t;
this.getAsImage(0, (img: image_t) => { image = img; });
2023-02-08 14:51:54 +01:00
return image;
}
2023-02-22 19:52:02 +01:00
2024-02-06 19:32:21 +01:00
static def: zui_node_t = {
2023-02-22 19:52:02 +01:00
id: 0,
name: _tr("Image Texture"),
type: "ImageTextureNode",
x: 0,
y: 0,
color: 0xff4982a0,
inputs: [
{
id: 0,
node_id: 0,
name: _tr("Vector"),
type: "VECTOR",
color: 0xff6363c7,
2024-01-20 10:58:12 +01:00
default_value: new Float32Array([0.0, 0.0, 0.0])
2023-02-22 19:52:02 +01:00
}
],
outputs: [
{
id: 0,
node_id: 0,
name: _tr("Color"),
type: "RGBA",
color: 0xffc7c729,
2024-01-20 10:58:12 +01:00
default_value: new Float32Array([0.0, 0.0, 0.0, 1.0])
2023-02-22 19:52:02 +01:00
},
{
id: 0,
node_id: 0,
name: _tr("Alpha"),
type: "VALUE",
color: 0xffa1a1a1,
default_value: 1.0
}
],
buttons: [
{
name: _tr("file"),
type: "ENUM",
default_value: 0,
data: ""
},
{
name: _tr("color_space"),
type: "ENUM",
default_value: 0,
data: ["linear", "srgb"]
}
]
};
2023-02-08 14:51:54 +01:00
}