Shaku

Shaku JS

Back To Table of Content

Ray

Ray

A 3D ray.

Kind: global class

new Ray(origin, direction)

Create the Ray.

Param Type Description
origin Vector3 Ray origin point.
direction Vector3 Ray 3d direction.

ray.set(origin, direction) ⇒ Plane

Set the ray components.

Kind: instance method of Ray
Returns: Plane - Self.

Param Type Description
origin Vector3 Ray origin point.
direction Vector3 Ray 3d direction.

ray.copy(ray) ⇒ Ray

Copy values from another ray.

Kind: instance method of Ray
Returns: Ray - Self.

Param Type Description
ray Ray Ray to copy.

ray.equals(ray) ⇒ Boolean

Check if this ray equals another ray.

Kind: instance method of Ray
Returns: Boolean - True if equal, false otherwise.

Param Type Description
ray Ray Other ray to compare to.

ray.at(distance) ⇒ Vector3

Get the 3d point on the ray by distance from origin.

Kind: instance method of Ray
Returns: Vector3 - Point on ray from origin.

Param Type Description
distance Number Distance from origin to travel.

ray.distanceToPoint(point) ⇒ Number

Calculate distance to a 3d point.

Kind: instance method of Ray
Returns: Number - Distance to point.

Param Type Description
point Vector3 Point to calculate distance to.

ray.distanceToPointSquared(point) ⇒ Number

Calculate squared distance to a 3d point.

Kind: instance method of Ray
Returns: Number - Squared distance to point.

Param Type Description
point Vector3 Point to calculate distance to.

ray.collideSphere(sphere) ⇒ Boolean

Check if this ray collides with a sphere.

Kind: instance method of Ray
Returns: Boolean - True if collide with sphere, false otherwise.

Param Type Description
sphere Sphere Sphere to test collision with.

ray.collideBox(box) ⇒ Boolean

Check if this ray collides with a box.

Kind: instance method of Ray
Returns: Boolean - True if collide with box, false otherwise.

Param Type Description
box Box Box to test collision with.

ray.findColliionPointWithBox(box) ⇒ Vector3 | null

Return the collision point between the ray and a box, or null if they don’t collide.

Kind: instance method of Ray
Returns: Vector3 | null - Collision point or null.

Param Type Description
box Box Box to get collision with.

ray.clone() ⇒ Ray

Clone this ray.

Kind: instance method of Ray
Returns: Ray - Cloned ray.