1

I'm looking for the best way to update a texture in threejs with data loaded from an image ? loadTextture will create a new texture every time and i can't find a way to pass on an image object.

I've created the amount of textures needed with loadTexture, now every time i need to load a new image i just want to update my current textures with their data

Appreciate any help

user3570683
  • 21
  • 1
  • 4

1 Answers1

2

This code should be of some help?

var image = document.createElement( 'img' );
var texture = new THREE.Texture( image );

image.onload = function () {

    texture.needsUpdate = true;

};

image.src = 'image.png';
mrdoob
  • 19,334
  • 4
  • 63
  • 62