如何在three.js中添加纹理到对象?

时间:2016-10-11 03:16:38

标签: javascript three.js

我正在尝试将纹理添加到我的中心球体(地球),但是当我尝试对象消失时。我可以找一些指导我出错的地方。谢谢 这是我的jsbin http://jsbin.com/cabape/edit?html,output的链接。我要让月亮围绕地球旋转

//大地    var loader = new THREE.TextureLoader();             loader.load('http://simpletruthsforhealthyliving.com/js/earth.jpg',function(texture){

  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);

});

1 个答案:

答案 0 :(得分:0)

这也需要添加

var texture = new THREE.Texture();         var loader = new THREE.ImageLoader();

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

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