O'Reilly logo

Three.js Essentials by Jos Dirksen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Adding basic textures to the globe

In this step, we're going to add two different textures. First, we're going to add a satellite image of the earth, and to make it look more realistic, we'll also add a couple of clouds. Let's first look at the texture of the earth that we'll use. This is shown in the following image:

Adding basic textures to the globe

To use this image as a texture in Three.js, we need to change the way we create the material. For readability, we have moved the material creation code to a separate function. This is described in the following code:

function createEarthMaterial() { // 4096 is the maximum width for maps var earthTexture = THREE.ImageUtils.loadTexture("../assets/textures/planets/earthmap4k.jpg"); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required