Skip to content

editorGlobalsOBB

Class: OBB

file A 3D arbitrarily oriented bounding box.

This data structure represents a box in 3D space. The local axes of @ box can be arbitrarily oriented/rotated with respect to the global world coordinate system. This allows OBBs to more tightly bound objects than AABBs do, which always align with the world space axes. This flexibility has the drawback that the geometry tests and operations involving OBBs are more costly, and representing an OBB in memory takes more space.

Reference:

This file is a JavaScript/three.js implementation of the MathGeoLib by Jukka Jylänki. The prototype does not contain the entire logic of the original source.

https://github.com/juj/MathGeoLib/blob/master/src/Geometry/OBB.h https://github.com/juj/MathGeoLib/blob/master/src/Geometry/OBB.cpp

author Human Interactive

Hierarchy

  • OBB

Index

Constructors

Properties

Methods

Constructors

constructor

+ new OBB(position?: Vector3, halfSizes?: Vector3, basis?: Matrix4): OBB

Defined in src/model/data/PhysicalObject/OBB.ts:45

Creates the OBB.

Parameters:

Name Type Description
position? Vector3 The center position of the OBB.
halfSizes? Vector3 Stores half-sizes to x, y and z directions in the local space of the OBB.
basis? Matrix4 Specifies normalized direction vectors for the local axes.

Returns: OBB

Properties

Private basis

basis: Matrix4 = new Matrix4()

Defined in src/model/data/PhysicalObject/OBB.ts:40


Private cachedBoxGeometry

cachedBoxGeometry: BoxBufferGeometry | null = null

Defined in src/model/data/PhysicalObject/OBB.ts:43


Private cachedPoints

cachedPoints: Vector3[] | null = null

Defined in src/model/data/PhysicalObject/OBB.ts:44


Private cachedVolume

cachedVolume: number | null = null

Defined in src/model/data/PhysicalObject/OBB.ts:45


Private epsilon

epsilon: number = 0.001

Defined in src/model/data/PhysicalObject/OBB.ts:38


Private halfSizes

halfSizes: Vector3 = new Vector3()

Defined in src/model/data/PhysicalObject/OBB.ts:39


Private position

position: Vector3 = new Vector3()

Defined in src/model/data/PhysicalObject/OBB.ts:41

Methods

Private _resetCache

_resetCache(): void

Defined in src/model/data/PhysicalObject/OBB.ts:614

Returns: void


clone

clone(): OBB

Defined in src/model/data/PhysicalObject/OBB.ts:543

Creates a new instance from the current OBB.

Returns: OBB

The new OBB.


closestPoint

closestPoint(point: Vector3): Vector3

Defined in src/model/data/PhysicalObject/OBB.ts:130

Computes the closest point inside the OBB to the given point.

Parameters:

Name Type Description
point Vector3 The target point.

Returns: Vector3

: The closest point inside the OBB.


copy

copy(obb: OBB): this

Defined in src/model/data/PhysicalObject/OBB.ts:530

Copies the values of a given OBB to the current OBB.

Parameters:

Name Type Description
obb OBB The OBB to copy.

Returns: this

The reference to the OBB.


getArea

getArea(): number

Defined in src/model/data/PhysicalObject/OBB.ts:547

Returns: number


getBasis

getBasis(): Matrix4‹›

Defined in src/model/data/PhysicalObject/OBB.ts:587

Returns: Matrix4‹›


getBoxGeometry

getBoxGeometry(): BoxBufferGeometry

Defined in src/model/data/PhysicalObject/OBB.ts:578

Returns: BoxBufferGeometry


getHalfSizes

getHalfSizes(): Vector3‹›

Defined in src/model/data/PhysicalObject/OBB.ts:595

Returns: Vector3‹›


getPoints

getPoints(): Vector3[]

Defined in src/model/data/PhysicalObject/OBB.ts:558

Returns: Vector3[]


getPosition

getPosition(): Vector3‹›

Defined in src/model/data/PhysicalObject/OBB.ts:591

Returns: Vector3‹›


getVolume

getVolume(): number

Defined in src/model/data/PhysicalObject/OBB.ts:551

Returns: number


intersectRay

intersectRay(ray: Ray): Vector3

Defined in src/model/data/PhysicalObject/OBB.ts:453

Calculates the intersection point between @ OBB and the given ray.

Parameters:

Name Type Description
ray Ray The ray to test.

Returns: Vector3

The intersection point.


intersectSphere

intersectSphere(sphere: Sphere): Vector3

Defined in src/model/data/PhysicalObject/OBB.ts:485

Calculates the intersection point between @ OBB and the given sphere.

Parameters:

Name Type Description
sphere Sphere The sphere to test.

Returns: Vector3

The intersection point.


intersectsOBB

intersectsOBB(obb: OBB): boolean

Defined in src/model/data/PhysicalObject/OBB.ts:270

Tests whether @ OBB and the given OBB intersect.

Parameters:

Name Type Description
obb OBB OBB to test.

Returns: boolean

Is there an intersection between the given OBB and the OBB?


intersectsPlane

intersectsPlane(plane: Plane): boolean

Defined in src/model/data/PhysicalObject/OBB.ts:415

Tests whether @ OBB and the given plane intersect.

Parameters:

Name Type Description
plane Plane The plane to test.

Returns: boolean

Is there an intersection between the given plane and the OBB?


intersectsRay

intersectsRay(ray: Ray): boolean

Defined in src/model/data/PhysicalObject/OBB.ts:441

Tests whether @ OBB and the given ray intersect.

Parameters:

Name Type Description
ray Ray The ray to test.

Returns: boolean

Is there an intersection between the given ray and the OBB?


intersectsSphere

intersectsSphere(sphere: Sphere): boolean

Defined in src/model/data/PhysicalObject/OBB.ts:260

Tests whether @ OBB and the given sphere intersect.

Parameters:

Name Type Description
sphere Sphere The sphere to test.

Returns: boolean

Is there an intersection between the given sphere and the OBB?


isAABBContained

isAABBContained(aabb: Box3): boolean

Defined in src/model/data/PhysicalObject/OBB.ts:195

Tests if the given AABB is fully contained inside the OBB.

Parameters:

Name Type Description
aabb Box3 The AABB to test.

Returns: boolean

Is the AABB fully contained inside the OBB?


isLineContained

isLineContained(line: Line3): boolean

Defined in src/model/data/PhysicalObject/OBB.ts:235

Tests if the given line segment is fully contained inside the OBB.

Parameters:

Name Type Description
line Line3 The line segment to test.

Returns: boolean

Is the line segment contained inside the OBB?


isPointContained

isPointContained(point: Vector3): boolean

Defined in src/model/data/PhysicalObject/OBB.ts:169

Tests if the given point is fully contained inside the OBB.

Parameters:

Name Type Description
point Vector3 The point to test.

Returns: boolean

Is the point contained inside the OBB?


isTriangleContained

isTriangleContained(triangle: Triangle): boolean

Defined in src/model/data/PhysicalObject/OBB.ts:247

Tests if the given triangle is fully contained inside the OBB.

Parameters:

Name Type Description
triangle Triangle The triangle to test.

Returns: boolean

Is the triangle contained inside the OBB?


setBasis

setBasis(basis: Matrix4): void

Defined in src/model/data/PhysicalObject/OBB.ts:599

Parameters:

Name Type
basis Matrix4

Returns: void


setFromObject

setFromObject(object: Mesh): this

Defined in src/model/data/PhysicalObject/OBB.ts:82

Sets the OBB from a mesh.

The basis of the objects world matrix is assumed to be orthogonal, which means no projection or shear is allowed. Additionally, the matrix must contain only uniform scaling.

Parameters:

Name Type Description
object Mesh The mesh object to convert to an OBB.

Returns: this

The reference to the OBB.


setFromSphere

setFromSphere(sphere: Sphere): this

Defined in src/model/data/PhysicalObject/OBB.ts:115

Sets the OBB from a bounding sphere.

Parameters:

Name Type Description
sphere Sphere The bounding sphere to convert to an OBB.

Returns: this

The reference to the OBB.


setHalfSizes

setHalfSizes(halfSizes: Vector3): void

Defined in src/model/data/PhysicalObject/OBB.ts:609

Parameters:

Name Type
halfSizes Vector3

Returns: void


setPosition

setPosition(position: Vector3): void

Defined in src/model/data/PhysicalObject/OBB.ts:604

Parameters:

Name Type
position Vector3

Returns: void


size

size(optionalTarget?: Vector3): Vector3

Defined in src/model/data/PhysicalObject/OBB.ts:503

Gets the size of the OBB.

Parameters:

Name Type Description
optionalTarget? Vector3 An optional target for the operation.

Returns: Vector3

The size of the OBB.


translate

translate(offset: Vector3): this

Defined in src/model/data/PhysicalObject/OBB.ts:517

Translates the OBB in world space.

Parameters:

Name Type Description
offset Vector3 The amount of displacement to apply to @ OBB, in world space coordinates.

Returns: this

The reference to the OBB.