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

Summary

In this chapter, we saw a lot of examples and code you can use to create your own geometries. This can be done either by creating them from scratch or using an external library. To create a geometry, you first have to specify its vertices and its faces. First you create the vertices, and based on these vertices, you can create the faces. When you define the faces, remember that Three.js only supports triangles as face. So when you create a face, use the THREE.Face3 object.

For correct behavior, we also have to set the normal on the face. Three.js uses this information to determine how to color a face based on the available lighting. The easiest way to do this is to just let Three.js calculate the normal by calling computeFaceNormals()

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