Skip to main content

vJSONRaycastToMesh

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

AdvancedMograph / JSONJSONArrayScriptVal
vJSONRaycastToMesh node

vJSONRaycastToMesh 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​

ParameterTypeDefaultDescription
Direction ArrayDATATYPE—Direction per point for Dir Array mode. The port is shown only in that mode.
Ray ModeDropdownGlobal DirGlobal Dir (default), Target Point or Dir Array.
Direction XFloat0X of the ray direction in Global Dir mode. Default 0.
Direction YFloat-1Y of the ray direction in Global Dir mode. Default -1.
Direction ZFloat0Z of the ray direction in Global Dir mode. Default 0.
+9 more parameters
ParameterTypeDefaultDescription
Target XFloat0X of the target in Target Point mode. Default 0.
Target YFloat0Y of the target in Target Point mode. Default 0.
Target ZFloat0Z of the target in Target Point mode. Default 0.
Miss BehaviorDropdownPass ThroughPass Through (default) keeps the point when the ray misses. Drop Point removes it.
Affect XFloat1X comes from the hit when checked (default), otherwise it keeps the input value.
Affect YFloat1Y comes from the hit when checked (default), otherwise it keeps the input value.
Affect ZFloat1Z comes from the hit when checked (default), otherwise it keeps the input value.
PointsDATATYPE—Point positions.
Mesh PointsDATATYPE—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​

vJSONPointsOnGrid.Output -> vJSONRaycastToMesh.ArrayPoints
vJSONFromOBJ.Points -> vJSONRaycastToMesh.MeshPoints
vJSONRaycastToMesh.Output -> vJSONCameraProjection.ArrayA
vJSONCameraProjection.Output -> vJSONShapeRender.ArrayPoint
Background.Output -> vJSONShapeRender.Input