ImageUtils.loadTexture,在Canvas渲染器中具有回调功能

Jaa*_*son 7 javascript canvas webgl three.js

我正在使用three.js修订版53

在Canvas Renderer(Win7上的IE)中加载纹理并为onLoad事件添加回调时,纹理不会显示.当我删除回调函数时,纹理将按预期显示:

//不使用回调添加

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 );
Run Code Online (Sandbox Code Playgroud)

//没有回调的工作

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 );
Run Code Online (Sandbox Code Playgroud)

在WebGL渲染器(FF,WIn7上的Chrome)中运行相同的代码时,两个示例都可以正常工作.

也许有人可以指出我在这里做的错误.

非常感谢.

Wes*_*ley 14

试试这个:

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

  • 优秀!将THREE.UVMapping()添加为映射时可以正常工作. (2认同)