vScriptValRaycastToMesh
Casts a ray from each point and moves it to the nearest mesh vertex that the ray passes close to.

vScriptValRaycastToMesh takes an array of XYZ points and a mesh, shoots a ray from each point, and outputs the mesh vertex that the ray hits first. Ray Mode picks a fixed direction, a target point or a direction per point.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
| Direction Array | DATATYPE | — | Direction per point for Dir Array mode. The port is shown only in that mode. |
| Ray Mode | Dropdown | Global Dir | Global Dir (default), Target Point or Dir Array. |
| Direction X | Float | 0 | X of the ray direction in Global Dir mode. Default 0. |
| Direction Y | Float | -1 | Y of the ray direction in Global Dir mode. Default -1. |
| Direction Z | Float | 0 | Z of the ray direction in Global Dir mode. Default 0. |
+9 more parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
| Target X | Float | 0 | X of the target in Target Point mode. Default 0. |
| Target Y | Float | 0 | Y of the target in Target Point mode. Default 0. |
| Target Z | Float | 0 | Z of the target in Target Point mode. Default 0. |
| Miss Behavior | Dropdown | Pass Through | Pass Through (default) keeps the point when the ray misses. Drop Point removes it. |
| Affect X | Float | 1 | X comes from the hit when checked (default), otherwise it keeps the input value. |
| Affect Y | Float | 1 | Y comes from the hit when checked (default), otherwise it keeps the input value. |
| Affect Z | Float | 1 | Z comes from the hit when checked (default), otherwise it keeps the input value. |
| Points | DATATYPE | — | Point positions. |
| Mesh Points | DATATYPE | — | Points of the mesh that the input is compared with. |
Read the full description
Each ray starts at a point. In Global Dir the direction is Direction X, Y, Z (default 0, -1, 0). In Target Point it runs toward Target X, Y, Z. In Dir Array it comes from the Direction Array input, one direction per point. Directions are made unit length.
A mesh vertex is a hit when it is ahead of the point and its distance from the ray line is at most the average spacing of the mesh vertices. The nearest hit along the ray gives the output, which is that vertex, for the checked axes of Affect X, Y and Z. On a miss, Pass Through (default) keeps the point and Drop Point removes it. The check compares every vertex for every point.
Example Connections
- Drop a grid onto a loaded mesh and draw
- Aim rays with a direction array
vScriptValPointsOnGrid.Output -> vScriptValRaycastToMesh.ArrayPoints
vScriptValFromOBJ.Points -> vScriptValRaycastToMesh.MeshPoints
vScriptValRaycastToMesh.Output -> vScriptValCameraProjection.ArrayA
vScriptValCameraProjection.Output -> vScriptValShapeRender.ArrayPoint
Background.Output -> vScriptValShapeRender.Input
vScriptValPointsOnGrid.Output -> vScriptValRaycastToMesh.ArrayPoints
vScriptValLookAt.Output -> vScriptValRaycastToMesh.DirArray
vScriptValFromOBJ.Points -> vScriptValRaycastToMesh.MeshPoints
vScriptValRaycastToMesh.Output -> vScriptValTranslate.Input