Skip to main content

vArraySortByDistance

Re-order vArray elements by their spatial proximity — essential for nearest-neighbour connections, path optimisation, and proximity-based effects.

IntermediateMograph / ArrayArrayScriptValJSON
vArraySortByDistance node

vArraySortByDistance reorders the elements in a vArray from nearest to farthest based on inter-point distances. Use it before vArrayShapeRender to draw connections in spatially optimised order, or before vArrayBuffer to record proximity-sorted trails.

Parameters​

ParameterTypeDefaultDescription
Smallest DistanceInteger0.01Minimum distance threshold. Point pairs closer than this value are treated as coincident and their relative order is preserved. Increase to loosen large-scale sorting.
Show InputCheckbox0Reveals the Array input port on the node in the Fusion node graph.
ArrayFloat—The vArray of XYZ point positions to sort by spatial proximity.
Read the full description

vArraySortByDistance performs a spatial sort on a vArray, reordering elements so that each consecutive point is the nearest unvisited neighbour of the previous one. This greedy nearest-neighbour traversal produces a path through the point cloud that minimises jump distances — useful for line-drawing effects where you want continuous connected strokes rather than random teleports across the frame.

Smallest Distance sets a proximity threshold. Points closer together than this value are treated as coincident and their relative order is left unchanged. Increasing this threshold loosens the sort, allowing short-range clusters to remain in their original order while only sorting at larger scales.

A common application is connecting scattered OBJ vertices with vArrayShapeRender's edge mode after sorting — the result looks like a hand-drawn path tracing through a point cloud rather than randomly ordered segments. Pair with vArrayBuffer to record the sorted path over time for trail effects that trace the proximity order across frames.

Example Connections​

vArrayFromOBJ.Points -> vArraySortByDistance.Array
vArraySortByDistance.Output -> vArrayCameraProjection.ArrayA
vArrayCameraProjection.Output -> vArrayShapeRender.ArrayPoint