Reference beginGeometry()

beginGeometry()

Begins adding shapes to a new p5.Geometry object.

The beginGeometry() and endGeometry() functions help with creating complex 3D shapes from simpler ones such as sphere(). beginGeometry() begins adding shapes to a custom p5.Geometry object and endGeometry() stops adding them.

beginGeometry() and endGeometry() can help to make sketches more performant. For example, if a complex 3D shape doesn’t change while a sketch runs, then it can be created with beginGeometry() and endGeometry(). Creating a p5.Geometry object once and then drawing it will run faster than repeatedly drawing the individual pieces.

See buildGeometry() for another way to build 3D shapes.

Note: beginGeometry() can only be used in WebGL mode.

Examples

Notice any errors or typos? Please let us know. Please feel free to edit src/webgl/3d_primitives.js and open a pull request!

Related References