Unable to clone () Texture

Mostly,

it works:

var expl1 = new THREE.ImageUtils.loadTexture( 'images/explodes/expl1.png' ); this.material = new THREE.MeshBasicMaterial({ map: expl1, transparent:true, blending:THREE.AdditiveBlending }); 

And that is not ...

 var expl1 = new THREE.ImageUtils.loadTexture( 'images/explodes/expl1.png' ); this.material = new THREE.MeshBasicMaterial({ map: expl1.clone(), transparent:true, blending:THREE.AdditiveBlending }); 

The problem is that I have several objects with this texture. I want to be able to change the texture offsets of one of the objects without changing the others. That's why I need a clone, but the cloned texture seems empty.

 var expl1 = new THREE.ImageUtils.loadTexture( 'images/explodes/expl1.png' ); 

it only loads once into a global variable. I can load a new texture every time I create a new object, but since it is 700 KB, it creates a lag when loading an image.

+4
source share
1 answer

EDIT: THREE.ImageUtils.loadTexture() been replaced by loader = new THREE.TextureLoader(); loader.load() loader = new THREE.TextureLoader(); loader.load() .


Most likely, because new THREE.TextureLoader().load() sets the needsUpdate flag for you, but cloning doesn't.

Do it instead

 var texture2 = texture1.clone(); texture2.needsUpdate = true; material = new THREE.MeshBasicMaterial( { map: texture2, ... } ); 

three.js r.75

+14
source

Source: https://habr.com/ru/post/1482302/


All Articles