संदर्भ calculateBoundingBox()

calculateBoundingBox()

Calculates the position and size of the smallest box that contains the geometry.

A bounding box is the smallest rectangular prism that contains the entire geometry. It's defined by the box's minimum and maximum coordinates along each axis, as well as the size (length) and offset (center).

Calling myGeometry.calculateBoundingBox() returns an object with four properties that describe the bounding box:

// Get myGeometry's bounding box.
let bbox = myGeometry.calculateBoundingBox();

// Print the bounding box to the console.
console.log(bbox);

// {
//  // The minimum coordinate along each axis.
//  min: { x: -1, y: -2, z: -3 },
//
//  // The maximum coordinate along each axis.
//  max: { x: 1, y: 2, z: 3},
//
//  // The size (length) along each axis.
//  size: { x: 2, y: 4, z: 6},
//
//  // The offset (center) along each axis.
//  offset: { x: 0, y: 0, z: 0}
// }

उदाहरण

Returns

Object: bounding box of the geometry.
Notice any errors or typos? Please let us know. Please feel free to edit src/webgl/p5.Geometry.js and open a pull request!

संबंधित संदर्भ