Reference buildGeometry()

buildGeometry()

Creates a custom p5.Geometry object from simpler 3D shapes.

buildGeometry() helps with creating complex 3D shapes from simpler ones such as sphere(). It 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 buildGeometry(). Creating a p5.Geometry object once and then drawing it will run faster than repeatedly drawing the individual pieces.

The parameter, callback, is a function with the drawing instructions for the new p5.Geometry object. It will be called once to create the new 3D shape.

See beginGeometry() and endGeometry() for another way to build 3D shapes.

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

Examples

Syntax

buildGeometry(callback)

Parameters

callback

function that draws the shape.

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