Skip to content

Class: BoundingBoxHelper

Defined in: src/utils/BoundingBox.ts:6

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: src/utils/BoundingBox.ts:10

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: src/utils/BoundingBox.ts:51

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: src/utils/BoundingBox.ts:75

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: src/utils/BoundingBox.ts:137

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: src/utils/BoundingBox.ts:152

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.