Book Image

Learning Three.js - the JavaScript 3D Library for WebGL

By : Jos Dirksen
Book Image

Learning Three.js - the JavaScript 3D Library for WebGL

By: Jos Dirksen

Overview of this book

Table of Contents (20 chapters)
Learning Three.js – the JavaScript 3D Library for WebGL Second Edition
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
8
Creating and Loading Advanced Meshes and Geometries
Index

Chapter 10. 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. In that chapter, however, we didn't talk about applying textures to meshes. In this chapter, we'll look at that subject. More specifically, in this chapter, we'll discuss the following topics:

  • Loading textures in Three.js and applying them to a mesh

  • Using bump and normal maps to apply depth and detail to a mesh

  • Creating fake shadows using a light map

  • Adding detailed reflection to a material using an environment map

  • Using a specular map to set the shininess of specific parts of a mesh

  • Fine-tuning and customizing the UV mapping of a mesh

  • Using the HTML5 canvas and video element as input for a texture

Let's start with the most basic example, where we show you how to load and apply a texture.