API Reference

Class List

Ray

An infinite ray.

// Create a new ray starting at the position of this entity and pointing down
// the entity's negative Z axis
const ray = new pc.Ray(this.entity.getPosition(), this.entity.forward);

Summary

Properties

direction

The direction of the ray.[read only]

origin

The starting point of the ray.[read only]

Methods

clone

Returns a clone of the Ray.

copy

Copies the contents of a source Ray.

set

Sets origin and direction to the supplied vector values.

Details

Constructor

Ray([origin], [direction])

Creates a new Ray instance. The ray is infinite, starting at a given origin and pointing in a given direction.

// Create a new ray starting at the position of this entity and pointing down
// the entity's negative Z axis
const ray = new pc.Ray(this.entity.getPosition(), this.entity.forward);

Parameters

originVec3

The starting point of the ray. The constructor copies this parameter. Defaults to the origin (0, 0, 0).

directionVec3

The direction of the ray. The constructor copies this parameter. Defaults to a direction down the world negative Z axis (0, 0, -1).

Properties

Vec3direction

The direction of the ray.

[read only]

Vec3origin

The starting point of the ray.

[read only]

Methods

clone()

Returns a clone of the Ray.

Returns

this

A duplicate Ray.

copy(src)

Copies the contents of a source Ray.

Parameters

srcRay

The Ray to copy from.

Returns

Ray

Self for chaining.

set(origin, direction)

Sets origin and direction to the supplied vector values.

Parameters

originVec3

The starting point of the ray.

directionVec3

The direction of the ray.

Returns

Ray

Self for chaining.