Planet = function() 4 { 5 Sim.Object.call(this); 6 } 7 8 Planet.prototype = new Sim.Object(); 9 10 Planet.prototype.init = function(param) 11 { 12 param = param || {}; planetOrbitGroup = .setObject3D(planetOrbitGroup);planetGroup = new THREE.Object3D(); 22 var distance = param.distance || 0; 23 var distsquared = distance * distance; planetOrbitGroup.add(planetGroup);.planetGroup = planetGroup; 28 var size = param.size || 1; map = param.map;.createGlobe(map);.animateOrbit = param.animateOrbit;.period = param.period;.revolutionSpeed = param.revolutionSpeed ? param.revolutionSpeed : Planet.REVOLUTION_Y;} 38 39 Planet.prototype.createGlobe = function(map) 40 { geometry = texture = new THREE.TextureLoader().load(map); material = new THREE.MeshPhongMaterial( {map: texture} ); 49 var globeMesh = new THREE.Mesh( geometry, material ); .planetGroup.add(globeMesh);.globeMesh = globeMesh; 56 } Planet.prototype.update = { (this.animateOrbit) 63 { 64 this.object3D.rotation.y += this.revolutionSpeed / this.period; 65 } 66 67 Sim.Object.prototype.update.call(this); 68 } 69 70 Planet.REVOLUTION_Y = 0.003;
最终效果: