Raycast
Static methods for casting rays into a scene: from a point, from the camera, or along a node’s axes. All return RaycastHit or null (or a list of hits for fromPointAll variants). Use the hit object to read node and geometry info.
From point
Section titled “From point”Raycast.fromPoint(scene, ox, oy, oz, dx, dy, dz)
Section titled “Raycast.fromPoint(scene, ox, oy, oz, dx, dy, dz)”Returns: RaycastHit or null — First hit along the ray, or null if nothing was hit.
Parameters:
scene(Scene) — Scene to cast against.ox,oy,oz(Num) — Ray origin in world space.dx,dy,dz(Num) — Ray direction (need not be normalized; implementation may normalize).
Raycast.fromPointMaxDist(scene, ox, oy, oz, dx, dy, dz, maxDist)
Section titled “Raycast.fromPointMaxDist(scene, ox, oy, oz, dx, dy, dz, maxDist)”Returns: RaycastHit or null — First hit within maxDist, or null.
Parameters: Same as fromPoint, plus:
maxDist(Num) — Maximum distance along the ray to consider.
Raycast.fromPointAll(scene, ox, oy, oz, dx, dy, dz)
Section titled “Raycast.fromPointAll(scene, ox, oy, oz, dx, dy, dz)”Returns: List of RaycastHit — All hits along the ray (order may be by distance).
Raycast.fromPointAllMaxDist(scene, ox, oy, oz, dx, dy, dz, maxDist)
Section titled “Raycast.fromPointAllMaxDist(scene, ox, oy, oz, dx, dy, dz, maxDist)”Returns: List of RaycastHit — All hits within maxDist.
From camera
Section titled “From camera”Raycast.fromCamera(scene, camera, screenX, screenY, viewportWidth, viewportHeight)
Section titled “Raycast.fromCamera(scene, camera, screenX, screenY, viewportWidth, viewportHeight)”Returns: RaycastHit or null — First hit along the ray from the camera through the screen point, or null if nothing hit or point is behind the camera.
Parameters:
scene(Scene) — Scene to cast against.camera(Camera) — Camera to cast from.screenX,screenY(Num) — Screen coordinates (e.g. fromInput.mouseX(),Input.mouseY()).viewportWidth,viewportHeight(Num) — Viewport size (e.g.Window.getWidth(),Window.getHeight()).
Typical use: mouse picking. Cast from the camera through the mouse position to find what the user clicked.
var hit = Raycast.fromCamera(_scene, _camera, Input.mouseX(), Input.mouseY(), Window.getWidth(), Window.getHeight())if (hit != null) { var nodeName = hit.getNodeName() var point = hit.getPoint() // handle click on nodeName}From node direction
Section titled “From node direction”Raycast.forward(scene, node, length) / Raycast.backward(...) / Raycast.left(...) / Raycast.right(...) / Raycast.up(...) / Raycast.down(...)
Section titled “Raycast.forward(scene, node, length) / Raycast.backward(...) / Raycast.left(...) / Raycast.right(...) / Raycast.up(...) / Raycast.down(...)”Returns: RaycastHit or null — First hit along the node’s forward, backward, left, right, up, or down direction for the given length.
Parameters:
scene(Scene) — Scene to cast against.node(Node) — Node whose position and orientation define the ray origin and direction.length(Num) — Maximum ray length.
var hit = Raycast.forward(_scene, _playerNode, 10)if (hit != null) { // something in front of the player within 10 units}RaycastHit
Section titled “RaycastHit”Result of a raycast. Use it to get the hit node and geometry.
getNodeId() / getNodeName()
Section titled “getNodeId() / getNodeName()”Returns: Node ID or name (String or implementation-defined type) — Identifier or name of the hit node. Useful for matching to Blender object names or script node IDs.
getPoint()
Section titled “getPoint()”Returns: List of three numbers [x, y, z] — World-space position of the hit.
getNormal()
Section titled “getNormal()”Returns: List of three numbers [x, y, z] — World-space normal at the hit (unit length).
getDistance()
Section titled “getDistance()”Returns: Num — Distance from the ray origin to the hit point.