Skip to content

Class: BoundingBoxHelper ​

Defined in: utils/BoundingBox.ts:7

Calculate bounding box and optimal camera position for a surface

Constructors ​

Constructor ​

ts
new BoundingBoxHelper(): BoundingBoxHelper;

Returns ​

BoundingBoxHelper

Methods ​

calculateBounds() ​

ts
static calculateBounds(vertices): object;

Defined in: utils/BoundingBox.ts:11

Calculate the bounding box of a surface geometry

Parameters ​

vertices ​

ArrayLike<number>

Returns ​

object

min ​
ts
min: Vector3;
max ​
ts
max: Vector3;
center ​
ts
center: Vector3;
size ​
ts
size: Vector3;
radius ​
ts
radius: number;

calculateCameraDistance() ​

ts
static calculateCameraDistance(
   boundingRadius, 
   fov, 
   aspectRatio
): number;

Defined in: utils/BoundingBox.ts:58

Calculate optimal camera distance for a given field of view

Parameters ​

boundingRadius ​

number

fov ​

number

aspectRatio ​

number

Returns ​

number


fitCameraToSurfaces() ​

ts
static fitCameraToSurfaces(
   camera, 
   surfaces, 
   controls?
): void;

Defined in: utils/BoundingBox.ts:82

Fit camera to view all surfaces

Parameters ​

camera ​

PerspectiveCamera

surfaces ​

object[]

controls? ​

any

Returns ​

void


computeInitialZoom() ​

ts
static computeInitialZoom(
   radius, 
   fov, 
   aspectRatio, 
   padding?
): number;

Defined in: utils/BoundingBox.ts:144

Compute camera distance to fit a bounding sphere with optional padding.

Parameters ​

radius ​

number

fov ​

number

aspectRatio ​

number

padding? ​

number = 1.2

Returns ​

number


fitCameraToGeometry() ​

ts
static fitCameraToGeometry(geometry, options?): object;

Defined in: utils/BoundingBox.ts:159

Pure helper to compute position/target for an arbitrary BufferGeometry or vertices array.

Parameters ​

geometry ​

| BufferGeometry<NormalBufferAttributes, BufferGeometryEventMap> | { attributes?: { position?: { array: ArrayLike<number>; }; }; } | { vertices: ArrayLike<number>; }

options? ​
fov ​

number

aspect ​

number

padding? ​

number

Returns ​

object

center ​
ts
center: Vector3;
distance ​
ts
distance: number;
position ​
ts
position: Vector3;

Released under the MIT License.