Capítulo 579 de 859

Chapter 579: OBB

Core Idea

Represents an oriented bounding box (OBB) in 3D space.

Key Concepts

  • center : Vector3: The center of the OBB.
  • halfSize : Vector3: Positive halfwidth extents of the OBB along each axis.
  • rotation : Matrix3: The rotation of the OBB.

Code Examples

import { OBB } from 'three/addons/math/OBB.js';
  • What it demonstrates: Typical usage of OBB.

Reference Tables

Constructor

Signature
new OBB( center : Vector3, halfSize : Vector3, rotation : Matrix3 )

Properties

PropertyDescription
.center : Vector3The center of the OBB.
.halfSize : Vector3Positive halfwidth extents of the OBB along each axis.
.rotation : Matrix3The rotation of the OBB.

Methods

MethodDescription
.applyMatrix4( matrix : Matrix4 ) : OBBApplies the given transformation matrix to this OBB. This method can be used to transform the bounding volume with the world matrix of a 3D object in order to keep both entities in sync.
.clampPoint( point : Vector3, target : Vector3 ) : Vector3Clamps the given point within the bounds of this OBB.
.clone() : OBBReturns a new OBB with copied values from this instance.
.containsPoint( point : Vector3 ) : booleanReturns true if the given point lies within this OBB.
.copy( obb : OBB ) : OBBCopies the values of the given OBB to this instance.
.equals( obb : OBB ) : booleanReturns true if the given OBB is equal to this OBB.
.fromBox3( box3 : Box3 ) : OBBDefines an OBB based on the given AABB.
.getSize( target : Vector3 ) : Vector3Returns the size of this OBB.
.intersectRay( ray : Ray, target : Vector3 ) : Vector3Performs a ray/OBB intersection test and stores the intersection point in the given 3D vector.
.intersectsBox3( box3 : Box3 ) : booleanReturns true if the given AABB intersects this OBB.
.intersectsOBB( obb : OBB, epsilon : number ) : booleanReturns true if the given OBB intersects this OBB.
.intersectsPlane( plane : Plane ) : booleanReturns true if the given plane intersects this OBB.
.intersectsRay( ray : Ray ) : booleanReturns true if the given ray intersects this OBB.
.intersectsSphere( sphere : Sphere ) : booleanReturns true if the given bounding sphere intersects this OBB.
.set( center : Vector3, halfSize : Vector3, rotation : Matrix3 ) : OBBSets the OBBs components to the given values.

Key Takeaways

  1. Most relevant properties: center, halfSize, rotation.
  2. Key methods: applyMatrix4, clampPoint, clone, containsPoint.

Connects To