1

我需要将 Maya 转换为 js,以便具有纹理的简单模型可以正常工作,但在没有纹理的情况下显示我的代码: var loader = new THREE.JSONLoader();

loader.load( "models/t2.js", function(geometry) {
var part1 = new THREE.Mesh( geometry, new THREE.MeshFaceMaterial() );
    mesh =new THREE.Object3D();
    mesh.add( part1 );
    //var mesh = new THREE.Mesh(geometry, material);
    mesh.position.set(0,0,0);
    mesh.rotation.set(0,0,0);
    mesh.scale.set(30,30,30);
    scene.add( mesh );
});

在线演示: http: //mika.ir/virtual-exhibition/ 下载代码: http: //mika.ir/virtual-exhibition/virtual-exhibition.rar

4

1 回答 1

0

您必须将纹理传递给其中一个材质对象。使用 MeshLambertMaterial 或 MeshPhongMaterial 并传入 THREE.Texture。您首先必须加载纹理并传递回调。如果您要加载的纹理是“path/texture.png”,我会执行以下操作:

var modelTexture = THREE.ImageUtils.loadTexture('path/texture.png', false, loadModel);

function loadModel() {
    loader.load( "models/t2.js", function(geometry) {
    var part1 = new THREE.Mesh( geometry, new THREE.MeshPhongMaterial({ map: modelTexture });
        mesh =new THREE.Object3D();
        mesh.add( part1 );
        //var mesh = new THREE.Mesh(geometry, material);
        mesh.position.set(0,0,0);
        mesh.rotation.set(0,0,0);
        mesh.scale.set(30,30,30);
        scene.add( mesh );
    });
}
于 2012-08-27T03:22:50.720 回答