Local Coordinates
Let’s try to build the Moon. We won’t add it to the scene yet—just build it at first. Add the following below the code that adds the Earth to the scene:
| var texture = new THREE.TextureLoader().load("/textures/moon.png"); |
| var cover = new THREE.MeshPhongMaterial({map: texture, specular: 'black'}); |
| var shape = new THREE.SphereGeometry(15, 32, 16); |
| var moon = new THREE.Mesh(shape, cover); |
| moon.position.set(0, 0, 100); |
| moon.rotation.set(0, Math.PI/2, 0); |
That’s similar to what we did with the Earth, but with a few changes. Obviously, we use an image of the Moon instead of the Earth for the mapped texture. We also make the specular color black because the Moon has almost no shininess. It’s smaller than ...
Get 3D Game Programming for Kids, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.