Ray
Source: Ray.ts:38
Ray class.
Constructor
new Ray(options?: Object): RayParameters
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.
updateRTCPosition()
Recomputes the start and end positions relative to the handler relative center.
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.
getThickness(): number
Returns ray thickness.
Returns
number
getStartColor(): Vec4
Returns a copy of the start point color, without the opacity multiplier.
Returns
getEndColor(): Vec4
Returns a copy of the end point color, without the opacity multiplier.
Returns
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
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 isRay.INSIDE.
Returns
number— Intersection status:Ray.INSIDE,Ray.OUTSIDE, orRay.AWAY.
hitSphere(sphere: Sphere): Vec3
Returns a ray hit sphere coordinates. If there isn't hit returns null.
Parameters
sphere(Sphere) — Sphere object.
Returns
hitSphereDistance(sphere: Sphere): number
Returns the distance along the ray to where it enters the sphere, in lengths of the direction vector: 0 when the origin is inside the sphere, Infinity when the ray misses it or the sphere is behind the origin. Allocates nothing.
Parameters
sphere(Sphere) — Sphere object.
Returns
number
hitTriangleDistance(
v0: Vec3,
v1: Vec3,
v2: Vec3,
margin?: number,
): number
Returns the distance along the ray to the triangle, hit from either side, in lengths of the direction vector. Infinity when the ray misses the triangle, the triangle is behind the origin, the ray is parallel to it, or the triangle has no area. Allocates nothing.
Parameters
v0(Vec3) — First triangle corner coordinate.v1(Vec3) — Second triangle corner coordinate.v2(Vec3) — Third triangle corner coordinate.margin(number, optional, default: 0) — How far outside of the triangle, in barycentric coordinates, it is still hit.
Returns
number