2016-10-11 64 views
0

我想添加到我的中心球體(地球)的紋理,但是當我嘗試物體消失。我可以有一些指導我去哪裏錯了。謝謝 以下是我的jsbin http://jsbin.com/cabape/edit?html,output的鏈接。我打算讓月球繞着地球旋轉如何將紋理添加到three.js中的對象?

// earth var loader = new THREE.TextureLoader(); Loader.load方法( 'http://simpletruthsforhealthyliving.com/js/earth.jpg',函數(紋理){

var center = new THREE.SphereGeometry(20,20,20); 
var materialShereCenter = new THREE.MeshPhongMaterial({ ambient: 0xee0011, color:0xff0000, specular: 0xee0000, shininess: 70,wireframe: false, map: texture }); 
centralSphere = new THREE.Mesh(center, materialShereCenter); 
centralSphere.position.z  = 0; 
centralSphere.position.x  = 0; 
centralSphere.position.y  = 0; 

scene.add(centralSphere); 

}); 

回答

0

這需要添加以及

變種紋理=新THREE.Texture(); VAR裝載機=新THREE.ImageLoader ();

loader.addEventListener('load', function (event) { 
      Texture1.image = event.content; 
      Texture1.needsUpdate = true; 
    }); 

    loader.load('http://simpletruthsforhealthyliving.com/js/earth.jpg');