API Docs for: 0.7.1
Show:

Ray Class

有起始点和结束点的线,用来相交形状。例子参见 World.raycast

构造器

Ray

(
  • [options]
)

参数:

  • [options] Object 可选
    • [from] Array 可选
    • [to] Array 可选
    • [checkCollisionResponse=true] Boolean 可选
    • [skipBackfaces=false] Boolean 可选
    • [collisionMask=-1] Number 可选
    • [collisionGroup=-1] Number 可选
    • [mode=Ray.ANY] Number 可选
    • [callback] Number 可选

Methods

getAABB

(
  • aabb
)

获取射线的包围盒

参数:

intersectBodies

(
  • bodies
)

参数:

  • bodies Array

    包含刚体对象的数组

intersectBody

(
  • body
)
private

Shoot a ray at a body, get back information about the hit.

参数:

intersectShape

(
  • shape
  • angle
  • position
  • body
)
private

参数:

  • shape Shape
  • angle Number
  • position Array
  • body Body

reportIntersection

(
  • fraction
  • normal
  • [faceIndex=-1]
)
Boolean private

参数:

  • fraction Number
  • normal Array
  • [faceIndex=-1] Number 可选

Returns:

Boolean:

True if the intersections should continue

update

()

当你改变起始或终止点时应调用

Properties

ALL

Number static

将遍历所有的交叉点和执行每一个回调的投射模式

ANY

Number static

将在找到第一个相交点时停止射线的投射模式

callback

Function

当前用户提供的结果回调,如果模式为 Ray.ALL时将被使用

checkCollisionResponse

Boolean

如果你想要让射线将.collisionResponse 标识算进刚体和形状中,将其设置为true

CLOSEST

Number static

将通过所有的交叉点并只返回最接近的一个的投射模式

collisionGroup

Number

Default: -1

collisionMask

Number

Default: -1

direction

Array

from

Array

射线起点

length

Number

射线长度

mode

Number

投射模式,应为Ray.ANY, Ray.ALL or Ray.CLOSEST之一.

skipBackfaces

Boolean

如果设置为true, 射线会跳过所有与法向量小于0的点的碰撞

to

Array

射线终点