https://webgl2fundamentals.org/webgl/lessons/webgl-3d-textures.html
In the link above, I have to create a new image and after loading I have to send it to the buffer.
var image = new Image();
image.src = "resource/1.png";
image.onload = ()=>{
gl.bindTexture(gl.TEXTURE_2D, texture);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image);
gl.generateMipmap(gl.TEXTURE_2D);
}
How to preload an image and use it?
var image = "data";
gl.bindTexture(gl.TEXTURE_2D, texture);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image);
gl.generateMipmap(gl.TEXTURE_2D);