THREE.js在加载时更改纹理

时间:2013-11-30 20:30:31

标签: javascript three.js textures

我们正在加载在Blender中创建的对象,我们想要更改纹理,而不必更改加载对象时引用的.mtl文件。

//load in all pieces
var board = this;
var loadComplete = 0;
this.loader.load('myobj1.obj', 'myobj1.mtl', function (object){
    board.obj2 = object;
    board.loader.load('myobj2.obj', 'myobj2.mtl', function(object){
        board.obj2 = object;
        board.obj2.material = new THREE.ImageUtils.loadTexture( 'Models/textures/blackmarble1.jpg' );
        board.loader.load('myobj3.obj', 'myobj3.mtl', function(object){
            board.obj3 = object;
    });
 });
});

所以在这张卡片中,我们试图改变obj2的纹理。但是,它只是加载mtl中的任何内容。我们想要在某些情况下,而不是在其他情况下。

尝试这些方法也不会做任何事情:

var blackTex = THREE.ImageUtils.loadTexture('Models/textures/blackmarble1.jpg');
obj2.material = new THREE.MeshLambertMaterial({ map: blackTex});


obj2.material.uniforms.texture = blackTex;

1 个答案:

答案 0 :(得分:0)

想出来。加载器会使网格变小。

piece.children[0].children[0].material = new THREE.MeshLambertMaterial({ map: blackTex});