addTexture
Adds a new texture/image to the model, and returns its id.
addTexture(
image: TextureData | Blob
): Promise<string>Parameters
Description
Type
image
Object containing the ArrayBuffer, width and height of the texture to be set.
Usage:
// Working with Canvas and ImageData
const img = new Image();
img.onload = async () => {
canvas.width = img.width;
canvas.height = img.height;
ctx.drawImage(img, 0, 0, img.width, img.height);
const imgData = ctx.getImageData(0, 0, img.width, img.height);
newTextureId = await modelApi.addTexture({
image: imgData.data,
width: imgData.width,
height: imgData.height
});
};
img.src = "{your_image_url}"Return value:
Last updated