meta data for this page
  •  

Center

Shapes can be centered about the X, Y or Z axis, or centered relative to a given point.

Note: The center of a shape is calculated as the midpoint between minimum and maximum points.

Defaults:

  • axes : [true, true, true]
  • relativeTo : [0, 0, 0]
const myshape = sphere({radius: 5})
let newshape = center({}, myshape)  // center the shape across all axes
newshape = center({axes: [true, true, false]}, myshape)  // center the object across only X and Y axis
newshape = center({relativeTo: [5, 6, 7]}, myshape)  // center the shape relative to the given point

There are also simple versions of this function to center the shape about the origin.

const myshape = sphere({radius: 5})
let newshape = centerX(myshape)
newshape = centerY(newshape)
newshape = centerZ(newshape)