Creating a geometry by extruding a 2D shape
Three.js provides a way in which we can extrude a 2D shape into a 3D shape. By extruding, we mean stretching out a 2D shape along its z axis to convert it to 3D. For instance, if we extrude THREE.CircleGeometry
, we get a shape that looks like a cylinder, and if we extrude THREE.PlaneGeometry
, we get a cube-like shape. The most versatile way of extruding a shape is using THREE.ExtrudeGeometry
.
THREE.ExtrudeGeometry
With THREE.ExtrudeGeometry
, you can create a 3D object from a 2D shape. Before we dive into the details of this geometry, let’s first look at an example, extrude-geometry.html
. The following screenshot taken from the example shows this geometry:
Figure 6.6 – Creating a 3D geometry from a 2D shape
In this example, we took the 2D shape we created in the 2D geometries section in Chapter 5, and used THREE.ExtrudeGeometry
to convert it to 3D. As you can see in the preceding screenshot...