API Docs for: 2.7.3
Show:

ObjectHelper.collision Class

Module: Helpers
Parent Module: Wanaplan

Collision checking.

Constructor

ObjectHelper.collision

() static

Methods

AABBtoAABB

(
  • box
  • box
)

Tests the collision between two Axis Aligned Bounding Boxes

Parameters:

  • box AABB

    1st Axis Aligned Bounding Box

  • box AABB

    2nd Axis Aligned Bounding Box

Returns:

false if there is no collision, true if there is

AABBtoOBB

(
  • box
  • box
)

Tests the collision between an Axis Aligned Bounding Box and an Oriented Bounding Box

Parameters:

  • box AABB

    the Axis Aligned Bounding Box

  • box OBB

    the Oriented Bounding Box

Returns:

false if there is no collision, true if there is

AABBtoOyBB

(
  • box
  • box
)

Tests the collision between an Axis Aligned Bounding Box and a Bounding Box Oriented along y axis

Parameters:

  • box AABB

    the Axis Aligned Bounding Box

  • box OyBB

    the Bounding Box Oriented along Y axis

Returns:

false if there is no collision, true if there is

interval

(
  • a1
  • b1
  • a2
  • b2
)

Tests the collision in one dimension between two intervals [a1,b1] , [a2,b2]

a1------b1 a2------------b2

without numeric imprecision is a2 < b1 == a1 < b2

Parameters:

  • a1 Number

    the min of the 1st interval

  • b1 Number

    the max of the 1st interval

  • a2 Number

    the min of the 2nd interval

  • b2 Number

    the max of the 2nd interval

Returns:

false if there is no collision, true if there is

MeshToAABB

(
  • worldMatrix
  • positions
  • indices
  • box
)

Tests the collision between a mesh and an Axis Aligned Bounding Box. /!\ This method has a high impact on performance, use with caution.

Parameters:

  • worldMatrix BABYLON.Matrix

    the transformation matrix of the mesh

  • positions Number[]

    indices of the mesh vertices, as returned by babylon.Mesh.getVertexBuffer ( ie vertices coordinates concatenated in an array )

  • indices Number[]

    indices of the face vertices, as returned by babylon.Mesh.getVertexBuffer ( ie faces indices concatenated in an array )

  • box AABB

    the Axis Aligned Bounding Box

Returns:

false if there is no collision, true if there is

OBBtoOBB

(
  • box
  • box
)

Tests the collision between two Oriented Bounding Boxes

Parameters:

  • box OBB

    1st Oriented Bounding Box

  • box OBB

    2nd Oriented Bounding Box

Returns:

false if there is no collision, true if there is

rayToAABB

(
  • o
  • v
  • box
)

Tests the collision between a ray and an Axis Aligned Bounding Box

Parameters:

  • o BABYLON.Vector3

    the origin of the ray

  • v BABYLON.Vector3

    the direction of the ray

  • box AABB

    the Axis Aligned Bounding Box

Returns:

false if there is no collision, else return a number t such that o+v*t is the point where the ray first collides the box, /!\ t can be 0 ( beware of untyped test )

triangleToAABB

(
  • trianglesPoints
  • box
)

Tests the collision between a triangle and an Axis Aligned Bounding Box

Parameters:

  • trianglesPoints BABYLON.Vector3

    three points which are the vertices of the triangle

  • box AABB

    the Axis Aligned Bounding Box

Returns:

false if there is no collision, true if there is