An infinite ray. Rays are commonly used for picking, raycasting and intersection tests.
A ray is an origin and a direction. It performs no intersection itself: pass it
to the intersectsRay method of a BoundingBox, BoundingSphere,
OrientedBox, Plane or Tri. Keep the direction normalized, as those tests
require it. The constructor copies the vectors it is given, and set updates both in
place.
Example
// A ray from the camera through a screen position constray = newRay(); entity.camera.screenToWorld(x, y, entity.camera.nearClip, ray.origin); entity.camera.screenToWorld(x, y, entity.camera.farClip, ray.direction); ray.direction.sub(ray.origin).normalize();
// Create a new ray starting at the position of this entity and pointing down // the entity's negative Z axis constray = newRay(this.entity.getPosition(), this.entity.forward);
An infinite ray. Rays are commonly used for picking, raycasting and intersection tests.
A ray is an origin and a direction. It performs no intersection itself: pass it to the
intersectsRaymethod of a BoundingBox, BoundingSphere, OrientedBox, Plane or Tri. Keep the direction normalized, as those tests require it. The constructor copies the vectors it is given, and set updates both in place.Example