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.