ImageUtils.loadTexture with callback in Canvas Renderer

筅森魡賤 提交于 2019-12-10 13:07:00

问题


i'm using three.js revision 53

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

// NOT WORKING with callback added

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 );

// WORKING without 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 just fine.

Maybe someone can point me to the mistake i'm obviously doing here.

Thanks a lot.


回答1:


Try this:

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


来源:https://stackoverflow.com/questions/13980889/imageutils-loadtexture-with-callback-in-canvas-renderer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!