我需要将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
答案 0 :(得分: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 );
});
}