Ray

Source: Ray.ts:36

Ray class.


Constructor

new Ray(options?: Object): Ray

Parameters

  • options (Object, optional) — Options:
    • options.startPosition (Vec3 | Array.<number>, optional) — Ray start point position.
    • options.endPosition (Vec3 | Array.<number>, optional) — Ray end point position.
    • options.startColor (Vec3 | Array.<number>, optional) — Ray start point color.
    • options.endColor (Vec3 | Array.<number>, optional) — Ray end point color.
    • options.opacity (number, optional, default: "1.0") — Ray opacity multiplier.
    • options.visibility (boolean, optional) — Visibility.

Instance Methods

setStartPosition(x: number, y: number, z: number)

Sets ray start position.

Parameters

  • x (number) — X coordinate.
  • y (number) — Y coordinate.
  • z (number) — Z coordinate.

setSrc(src: string)

Sets image template url source.

Parameters

  • src (string) — Image url.

setImage(image: Object)

Sets image template object.

Parameters

  • image (Object) — JavaScript image object.

setStartPosition3v(position: Vec3)

Sets ray start position.

Parameters

  • position (Vec3) — Cartesian coordinates.

setEndPosition(x: number, y: number, z: number)

Sets ray end position.

Parameters

  • x (number) — X coordinate.
  • y (number) — Y coordinate.
  • z (number) — Z coordinate.

setEndPosition3v(position: Vec3)

Sets ray end position.

Parameters

  • position (Vec3) — Cartesian coordinates.

getStartPosition(): Vec3

Returns ray start position.

Returns

getEndPosition(): Vec3

Returns ray end position.

Returns

setVisibility(visibility: boolean)

Sets visibility.

Parameters

  • visibility (boolean) — Visibility flag.

setOpacity(opacity: number)

Sets ray opacity.

Parameters

  • opacity (number) — Opacity value in range [0..1].

getOpacity(): number

Returns ray opacity multiplier.

Returns

  • number

getVisibility(): boolean

Returns visibility.

Returns

  • boolean

remove()

Remove from handler.

setPickingColor3v(color: Vec3)

Sets picking color.

Parameters

  • color (Vec3) — Picking color.

set(origin: Vec3, direction: Vec3): Ray

Sets a ray parameters.

Parameters

  • origin (Vec3) — The origin of the ray.
  • direction (Vec3) — The direction of the ray.

Returns

getPoint(distance: number): Vec3

Returns a point on the ray at the given distance.

Parameters

  • distance (number) — Distance from the origin along the ray.

Returns

  • Vec3 — The point at the given distance.

hitTriangleRes(v0: Vec3, v1: Vec3, v2: Vec3, res: Vec3): number

Returns ray hit a triangle result.

Parameters

  • v0 (Vec3) — First triangle corner coordinate.
  • v1 (Vec3) — Second triangle corner coordinate.
  • v2 (Vec3) — Third triangle corner coordinate.
  • res (Vec3) — Hit point object pointer that stores hit result.

Returns

  • number

hitPlaneRes(plane: Plane, res: Vec3): number

Finds the intersection of the ray with a plane.

Parameters

  • plane (Plane) — The plane to intersect with.
  • res (Vec3) — Output intersection point when result is Ray.INSIDE.

Returns

  • number — Intersection status: Ray.INSIDE, Ray.OUTSIDE, or Ray.AWAY.

hitSphere(sphere: Sphere): Vec3

Returns a ray hit sphere coordinates. If there isn't hit returns null.

Parameters

  • sphere (Sphere) — Sphere object.

Returns

Other

OUTSIDE

static
Ray.ts:37

INSIDE

static
Ray.ts:42

INPLANE

static
Ray.ts:47

AWAY

static
Ray.ts:52