ImageUtils.loadTexture with callback in Canvas Renderer

I am using version three.js 53

when loading a texture in a Canvas Renderer (IE on Win7) and adding a callback for the onLoad event, the texture does not appear. When I remove the callback function, the texture is displayed as expected:

// DOES NOT WORK with adding callback

var material = new THREE.MeshBasicMaterial({ map: THREE.ImageUtils.loadTexture('text_build.png', {}, function() { //do something }) }); var plane = new THREE.Mesh(new THREE.PlaneGeometry(135, 135), material); plane .overdraw = true; scene.add(plane ); 

// WORK without a callback

 var material = new THREE.MeshBasicMaterial({ map: THREE.ImageUtils.loadTexture('text_build.png') }); var plane = new THREE.Mesh(new THREE.PlaneGeometry(135, 135), material); plane .overdraw = true; scene.add(plane ); 

When running the same code in WebGL Renderer (FF, Chrome on WIn7), both examples work fine.

Maybe someone can point me to the mistake that I am obviously making here.

Many thanks.

+7
source share
1 answer

Try the following:

 var material = new THREE.MeshBasicMaterial({ map: THREE.ImageUtils.loadTexture( 'text_build.png', new THREE.UVMapping(), function() { ... } ) }); 
+14
source

All Articles