Three.js offers many different ways to create geometries. You can use the standard Three.js objects, such as THREE.BoxGeometry
and THREE.SphereGeometry
, create geometries completely from scratch, or just load models created by external 3D modeling programs. In this recipe, we will show you another way to create geometries. This recipe shows you how to create geometries based on math formulas.
For this recipe, we'll be using the THREE.ParametricGeometry
object. As this is available from the standard Three.js distribution, there is no need to include additional JavaScript files.
To see the end result of this recipe, you can look at 02.10-create-parametric-geometries.html
, you'll see something similar to the following screenshot:
This figure shows you a Gray's Kleinbottle, which is rendered based on a couple of simple math formulas.