Hi, I’ve been trying to export a RawTexture image through code but haven’t been able to manage yet. Could anyone give me a push into the right direction or have an example of this? Thanks!
Hello! Where are you getting your RawTexture from? If it’s from an array of data, you could try to export this array instead. Or you could draw this texture in a canvas, get the image data from there, and then export it.
My main source is an array of 0-255. I transform this into a red/black texture using the raw texture as such:
const texture = new RawTexture( new Uint8Array(ARRAY_OF_0-255_VALUES), this.size.width, this.size.height, Engine.TEXTUREFORMAT_R, this.scene, false, false, Texture.TRILINEAR_SAMPLINGMODE, )
How exactly would I be able to draw this onto a canvas for example?
You can use the Canvas API methods for that. Here’s an example: Saving img data | Babylon.js Playground (babylonjs.com)
Perfect, exactly what I was looking for, thank you!