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}
// }
예제
반환값
Object: bounding box of the geometry.
This page is generated from the comments in src/webgl/p5.Geometry.js . Please feel free to edit it and submit a pull request!
관련 레퍼런스
beginGeometry
Begins adding shapes to a new p5.Geometry object.
buildGeometry
Creates a custom p5.Geometry object from simpler 3D shapes.
endGeometry
Stops adding shapes to a new p5.Geometry object and returns the object.
freeGeometry
Clears a p5.Geometry object from the graphics processing unit (GPU) memory.