Module: core/intersections

Compute/test intersection between different objects.
Source:

Methods

(static) aabbPlane(aabb, plane) → {Array.<Vector3>|boolean}

Compute intersection between oriented bounding box and a plane. Returns intersection in plane's space. Should return at least 3 intersections. If not, the plane and the box do not intersect.
Parameters:
Name Type Description
aabb Object Axe Aligned Bounding Box representation.
Properties
Name Type Description
halfDimensions Vector3 Half dimensions of the box.
center Vector3 Center of the box.
toAABB Matrix4 Transform to go from plane space to box space.
plane Object Plane representation
Properties
Name Type Description
position Vector3 position of normal which describes the plane.
direction Vector3 Direction of normal which describes the plane.
Source:
Returns:
  • List of all intersections in plane's space.
    Type
    Array.<Vector3>
  • false is invalid input provided.
    Type
    boolean
Example
//Returns array with intersection N intersections
let aabb = {
  center: new Vector3(150, 150, 150),
  halfDimensions: new Vector3(50, 60, 70),
  toAABB: new Matrix4()
}
let plane = {
  position: new Vector3(110, 120, 130),
  direction: new Vector3(1, 0, 0)
}

let intersections = CoreIntersections.aabbPlane(aabb, plane);
// intersections ==
//[ { x : 110, y : 90,  z : 80 },
//  { x : 110, y : 210, z : 220 },
//  { x : 110, y : 210, z : 80 },
//  { x : 110, y : 90,  z : 220 } ]

//Returns empty array with 0 intersections
let aabb = {

}
let plane = {

}

let intersections = VJS.Core.Validators.matrix4(new Vector3());

//Returns false if invalid input?

(static) findIntersection(myintersection)

Find intersection in array
Parameters:
Name Type Description
myintersection *
Source:

(static) inBBox(point, bbox) → {Boolean}

Is point in box.
Parameters:
Name Type Description
point Object
bbox Object
Source:
Returns:
Type
Boolean

(static) rayBox(ray, box) → {Array}

Compute intersection between a ray and a box
Parameters:
Name Type Description
ray Object
box Object
Source:
Returns:
Type
Array

(static) rayPlaneInBBox(ray, planeAABB, bbox, intersections)

Intersection between ray and a plane that are in a box.
Parameters:
Name Type Description
ray *
planeAABB *
bbox *
intersections *
Source: