Loading and Working with Textures
In Chapter 4, Working with Three.js Materials, we introduced you to the various materials that are available in Three.js. However, we didn’t discuss applying textures to the material that’s used when creating a mesh. In this chapter, we’ll look at that subject. Specifically, we’ll discuss the following topics:
- Loading textures in Three.js and applying them to a mesh
- Using bump, normal, and displacement maps to apply depth and detail to a mesh
- Creating fake shadows using a lightmap and an ambient occlusion map
- Using specular, metalness, and roughness maps to set the shininess of specific parts of a mesh
- Applying an alpha map for partial transparency of an object
- Adding detailed reflections to a material using an environment map
- Using the HTML5 Canvas and video element as input for a texture
Let’s start with a basic example, where we will show you how to load and apply a texture...