new OBB(center, halfSizes, rotation)
Constructs a new OBB with the given values.
Parameters:
| Name | Type | Description | 
|---|---|---|
center | 
            
            Vector3 | The center of this OBB.  | 
        
halfSizes | 
            
            Vector3 | The half sizes of the OBB (defines its width, height and depth).  | 
        
rotation | 
            
            Matrix3 | The rotation of this OBB.  | 
        
Members
- 
center :Vector3
 - 
    
    
The center of this OBB.
 - 
halfSizes :Vector3
 - 
    
    
The half sizes of the OBB (defines its width, height and depth).
 - 
rotation :Matrix3
 - 
    
    
The rotation of this OBB.
 
Methods
- 
    
        
clampPoint(point, result) → {Vector3}
 - 
    
    
Ensures the given point is inside this OBB and stores the result in the given vector.
Reference: Closest Point on OBB to Point in Real-Time Collision Detection by Christer Ericson (chapter 5.1.4)
Parameters:
Name Type Description pointVector3 A point in 3D space.
resultVector3 The result vector.
 - 
    
        
clone() → {OBB}
 - 
    
    
Creates a new OBB and copies all values from this OBB.
 - 
    
        
containsPoint(point) → {Boolean}
 - 
    
    
Returns true if the given point is inside this OBB.
Parameters:
Name Type Description pointVector3 A point in 3D space.
Returns:
Boolean -Whether the given point is inside this OBB or not.
 - 
    
        
copy(obb) → {OBB}
 - 
    
    
Copies all values from the given OBB to this OBB.
Parameters:
Name Type Description obbOBB The OBB to copy.
 - 
    
        
equals(obb) → {Boolean}
 - 
    
    
Returns true if the given OBB is deep equal with this OBB.
Parameters:
Name Type Description obbOBB The OBB to test.
Returns:
Boolean -The result of the equality test.
 - 
    
        
fromAABB(aabb) → {OBB}
 - 
    
    
Computes the OBB from an AABB.
Parameters:
Name Type Description aabbAABB The AABB.
 - 
    
        
fromJSON(json) → {OBB}
 - 
    
    
Restores this instance from the given JSON object.
Parameters:
Name Type Description jsonObject The JSON object.
 - 
    
        
fromPoints(points) → {OBB}
 - 
    
    
Computes the minimum enclosing OBB for the given set of points. The method is an implementation of Collision Queries using Oriented Bounding Boxes by Stefan Gottschalk. According to the dissertation, the quality of the fitting process varies from the respective input. This method uses the best approach by computing the covariance matrix based on the triangles of the convex hull (chapter 3.4.3).
However, the implementation is susceptible to regular polygons like cubes or spheres. For such shapes, it's recommended to verify the quality of the produced OBB. Consider to use an AABB or bounding sphere if the result is not satisfying.
Parameters:
Name Type Description pointsArray.<Vector3> An array of 3D vectors representing points in 3D space.
 - 
    
        
getSize(result) → {Vector3}
 - 
    
    
Computes the size (width, height, depth) of this OBB and stores it into the given vector.
Parameters:
Name Type Description resultVector3 The result vector.
 - 
    
        
intersectsAABB(aabb) → {Boolean}
 - 
    
    
Returns true if the given AABB intersects this OBB.
Parameters:
Name Type Description aabbAABB The AABB to test.
Returns:
Boolean -The result of the intersection test.
 - 
    
        
intersectsBoundingSphere(sphere) → {Boolean}
 - 
    
    
Returns true if the given bounding sphere intersects this OBB.
Parameters:
Name Type Description sphereBoundingSphere The bounding sphere to test.
Returns:
Boolean -The result of the intersection test.
 - 
    
        
intersectsOBB(obb, epsilon) → {Boolean}
 - 
    
    
Returns true if the given OBB intersects this OBB.
Reference: OBB-OBB Intersection in Real-Time Collision Detection by Christer Ericson (chapter 4.4.1)
Parameters:
Name Type Description obbOBB The OBB to test.
epsilonNumber The epsilon (tolerance) value.
Returns:
Boolean -The result of the intersection test.
 - 
    
        
intersectsPlane(plane) → {Boolean}
 - 
    
    
Returns true if the given plane intersects this OBB.
Reference: Testing Box Against Plane in Real-Time Collision Detection by Christer Ericson (chapter 5.2.3)
Parameters:
Name Type Description planePlane The plane to test.
Returns:
Boolean -The result of the intersection test.
 - 
    
        
set(center, halfSizes, rotation) → {OBB}
 - 
    
    
Sets the given values to this OBB.
Parameters:
Name Type Description centerVector3 The center of this OBB
halfSizesVector3 The half sizes of the OBB (defines its width, height and depth).
rotationMatrix3 The rotation of this OBB.
 - 
    
        
toJSON() → {Object}
 - 
    
    
Transforms this instance into a JSON object.
Returns:
Object -The JSON object.