Rendering 3D formulas as 3D geometries

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.

Getting ready

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 ...

Get Three.js Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.