Texture

This all looks pretty amazing. But we can still do one more thing to make it even better. Above the code for the ground, we’ll load a “texture” image. Then, just after the cover is created, we assign that texture to the cover’s map property.

»​var​ texture = ​new​ THREE.TextureLoader().load(​"/textures/hardwood.png"​);
​ ​var​ shape = ​new​ THREE.PlaneGeometry(1000, 1000, 10, 10);
​ ​var​ cover = ​new​ THREE.MeshPhongMaterial();
»cover.map = texture;
​ ​var​ ground = ​new​ THREE.Mesh(shape, cover);
​ ground.rotation.x = -Math.PI/2;
​ ground.receiveShadow = ​true​;
​ scene.add(ground);

That makes a very pretty wooden floor for our scene.

Calling the property “map” might seem ...

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.