#new Texture()
1 messages · Page 1 of 1 (latest)
I think the syntax is
id: "texture",
width: 64,
height: 32,
})```
Correct me if I'm wrong, I still need to check this
Hmm, it still does not work for me.
Actually, I should create UV template for it as well.
The important thing when creating a texture is that it is initialized with image data. You can do this via fromFile or fromPath, but if you are creating it from scratch, the best option is fromDataURL:
First, create a HTML canvas, set the size, and draw something on it. Then, get the data URL and use it to create a texture:
let data_url = canvas.toDataURL()
new Texture({name: 'tex'}).fromDataURL(data_url).add()
I thought that there is a function that specifically generates these textures that I could use in the plugin.
I currently have this code for generating the texture, but it fills it with just red color...
const canvas = document.createElement('canvas');
canvas.width = 64;
canvas.height = 32;
const ctx = canvas.getContext('2d');
ctx.fillStyle = 'red';
ctx.fillRect(0, 0, 64, 32);
// do I really need this?
const dataURL = canvas.toDataURL();
let texture = new Texture({ name: 'cape_texture' }).fromDataURL(dataURL).add(true);
What is your goal?
My goal is to create appropriately sized texture and assign it to the model. I would love the texture to have different colors on each face, just as it is when creating a texture from scratch in BB.
^
So a full on template, but based on the existing UV data?