2012-08-26 88 views
1

我需要轉換的瑪雅js的簡單模型,紋理 做工精細,但顯示沒有紋理 我的代碼: VAR裝載機=新THREE.JSONLoader();顯示紋理 - 瑪雅three.js所

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

你有紋理傳遞到材質的對象之一。使用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); 
    }); 
} 
+0

我需要從js文件中加載紋理 –