Class: Ray

Ray

new Ray(params)

射线

Name Type Description
params Object optional
Name Type Default Description
origin Vector3 new Vector3(0, 0, 0) optional

原点

direction Vector3 new Vector3(0, 0, -1) optional

方向

Example
var ray = new Hilo3d.Ray();
ray.fromCamera(camera, 10, 10, stage.width, stage.height);

Members Show Inherited

Name Type Default Description
className String Ray

类名

isRay Boolean true

是否是射线

origin Vector3

原点

direction Vector3

方向

Methods Show Inherited

set(origin, direction){Ray}

set

Name Type Description
origin Vector3
direction Vector3
Returns:
Type Description
Ray this

copy(other){Ray}

copy

Name Type Description
other Vector3
Returns:
Type Description
Ray

clone(){Ray}

clone

Returns:
Type Description
Ray

fromCamera(camera, x, y, width, height)

从摄像机设置

Name Type Description
camera Camera
x Number

屏幕x

y Number

屏幕y

width Number

屏幕宽

height Number

屏幕高

transformMat4(mat4)

Transforms the ray with a mat4

Name Type Description
mat4 Matrix4

sortPoints(points, pointName)

排序碰撞点

Name Type Default Description
points Array.<Vector3> | Array.<raycastInfo>
pointName String '' optional

squaredDistance(point){Number}

squaredDistance

Name Type Description
point Vector3
Returns:
Type Description
Number

distance(point){Number}

distance

Name Type Description
point Vector3
Returns:
Type Description
Number

intersectsSphere(center, radius){Vector3}

intersectsSphere

Name Type Description
center Array.<Number>

[x, y, z]

radius Number
Returns:
Type Description
Vector3 碰撞点,如果没有碰撞返回 null

intersectsPlane(normal, distance){Vector3}

intersectsPlane

Name Type Description
normal Array.<Numer>

[x, y, z]

distance Number
Returns:
Type Description
Vector3 碰撞点,如果没有碰撞返回 null

intersectsTriangle(triangle){Vector3}

intersectsTriangle

Name Type Description
triangle Array

[[a.x, a.y, a.z], [b.x, b.y, b.z],[c.x, c.y, c.z]]

Returns:
Type Description
Vector3 碰撞点,如果没有碰撞返回 null

intersectsBox(aabb){Vector3}

intersectsBox

Name Type Description
aabb Array

[[min.x, min.y, min.z], [max.x, max.y, max.z]]

Returns:
Type Description
Vector3 碰撞点,如果没有碰撞返回 null

intersectsTriangleCell(cell, positions){Vector3}

intersectsTriangleCell

Name Type Description
cell Array
positions Array
Returns:
Type Description
Vector3 碰撞点,如果没有碰撞返回 null