Class Ray

A line in 3D space that intersects bodies and return points.

Constructors

  • Parameters

    Returns Ray

Properties

callback: RaycastCallback

User-provided result callback. Will be used if mode is Ray.ALL.

checkCollisionResponse: boolean

Set to false if you don't want the Ray to take collisionResponse flags into account on bodies and shapes.

Default

true
collisionFilterGroup: number

collisionFilterGroup

Default

-1
collisionFilterMask: number

collisionFilterMask

Default

-1
direction: Vec3

direction

from: Vec3

from

hasHit: boolean

Will be set to true during intersectWorld() if the ray hit anything.

mode: number

The intersection mode. Should be Ray.ANY, Ray.ALL or Ray.CLOSEST.

Default

RAY.ANY
precision: number

The precision of the ray. Used when checking parallelity etc.

Default

0.0001

Current result object.

skipBackfaces: boolean

If set to true, the ray skips any hits with normal.dot(rayDirection) < 0.

Default

false
to: Vec3

to

ALL: 4

ALL

ANY: 2

ANY

CLOSEST: 1

CLOSEST

Accessors

  • get 1(): ((sphere, quat, position, body, reportedShape) => void)
  • Returns ((sphere, quat, position, body, reportedShape) => void)

      • (sphere, quat, position, body, reportedShape): void
      • Parameters

        Returns void

  • get 128(): ((shape, quat, position, body, reportedShape, options?) => void)
  • Returns ((shape, quat, position, body, reportedShape, options?) => void)

      • (shape, quat, position, body, reportedShape, options?): void
      • Parameters

        Returns void

  • get 16(): ((shape, quat, position, body, reportedShape, options?) => void)
  • Returns ((shape, quat, position, body, reportedShape, options?) => void)

      • (shape, quat, position, body, reportedShape, options?): void
      • Parameters

        Returns void

  • get 2(): ((shape, quat, position, body, reportedShape) => void)
  • Returns ((shape, quat, position, body, reportedShape) => void)

      • (shape, quat, position, body, reportedShape): void
      • Parameters

        Returns void

  • get 256(): ((mesh, quat, position, body, reportedShape, options?) => void)
  • Returns ((mesh, quat, position, body, reportedShape, options?) => void)

      • (mesh, quat, position, body, reportedShape, options?): void
      • Parameters

        Returns void

  • get 32(): ((shape, quat, position, body, reportedShape) => void)
  • Returns ((shape, quat, position, body, reportedShape) => void)

  • get 4(): ((box, quat, position, body, reportedShape) => void)
  • Returns ((box, quat, position, body, reportedShape) => void)

      • (box, quat, position, body, reportedShape): void
      • Parameters

        Returns void

Methods

  • Parameters

    Returns void

  • Parameters

    Returns void

  • Parameters

    Returns void

  • Parameters

    Returns void

  • Parameters

    Returns void

  • Parameters

    Returns void

    Todo

    Optimize by transforming the world to local space first.

    Todo

    Use Octree lookup

  • Get the world AABB of the ray.

    Parameters

    Returns void

  • Shoot a ray at an array bodies, get back information about the hit.

    Parameters

    • bodies: Body[]

      An array of Body objects.

    • Optional result: RaycastResult

      set the result property of the Ray instead.

    Returns void

    Deprecated

  • Shoot a ray at a body, get back information about the hit.

    Parameters

    Returns void

    Deprecated

  • Do itersection against all bodies in the given World.

    Parameters

    Returns boolean

    True if the ray hit anything, otherwise false.

  • As per "Barycentric Technique" as named here but without the division

    Parameters

    Returns boolean