Ray
Cast rays and detect collisions with geometry.
What it does
Ray casts one or more rays from a point and finds where they first touch input geometry. Each ray reports a hit position, surface normal, distance, and a reflection direction, for driving particles, lasers, line-of-sight checks, or procedural bounce patterns. With Geometry unwired, rays collide with whatever else is visible in the scene.
Rays can fan out, as a flat 2D fan or a 3D cone or sphere of rays around one direction, and can ricochet off what they hit for a number of bounces, losing energy each time. Render Mode set to None returns the collision data with no visible ray.
When to use it
A laser, line-of-sight check, or ricochet effect
The point where a straight line from an origin first touches geometry, with its normal, distance, or reflection direction
A fan or spray of rays (2D fan, or 3D cone or sphere) sampling a scene
One ray per point in a points collection rather than a single scalar origin
| Parameter | Type | Default |
|---|---|---|
geometry | OneOf([Collection]) | — |
source_points | OneOf([Collection, Vec3Array]) | — |
origin | Vec3 | (0, 0, 0) |
direction | Vec3 | (1, 0, 0) |
max_length | Number | 1000 |
angle_offset | Number | 0 |
offset | Number | 0 |
max_bounces | Number | 0 |
bounce_energy_loss | Number | 0 |
ray_count | Number | 1 |
spread_angle | Number | 360 |
ray_pattern | String | "Fan" |
max_steps | Number | 1 |
hit_mode | String | "First Hit" |
render_mode | String | "Tube" |
stroke_width | Number | 1 |
color | Color | rgba(1.00, 1.00, 1.00, 1.00) |
miss_color | Color | rgba(0.50, 0.50, 0.50, 1.00) |
analytical | Boolean | true |
opacity | Number | 1 |
Gotchas
Max Steps, the distance-field ray-march step count, currently has no effect. Leave it at the default.
With Geometry left unwired, rays collide against last frame's scene. That keeps the graph free of same-frame cycles, and it means a shape added this frame is not hit until the next frame.
Wiring Source Points overrides the Origin parameter and casts one ray per point using the scalar Direction. Ray Count, the fan, and Spread Angle are all ignored in that mode.
Set Bounces to 0 for a first-hit ray. Raise Bounce Energy Loss toward 1 to make bounces die out quickly, or keep it near 0 for a near-perfect mirror ricochet.
Worked example
Add a Ray. Set Origin and Direction, or wire Source Points to cast one ray per point instead.
Wire a shape or mesh into Geometry, or leave it unwired to collide with the rest of the scene.
Raise Ray Count and Spread Angle to fan the ray into a spray; switch Ray Pattern to Sphere for a 3D cone instead of a flat fan.
Raise Bounces above 0 to have the ray ricochet off what it hits, and use Bounce Energy Loss to fade it out over successive bounces.
Read Hit Points, Hit Normals, or Reflected downstream to drive particles, or set Render Mode to None if you only need the collision data.