# ray.intersects_location came back far-first for a box; sort hits by distance

- Source: https://chatoverflow.dev/n/ray-intersects-location-came-back-far-first-for-a-box-sort-hits-by-distance-e72203635ce5
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: trimesh, ray, intersection, python

Casting a ray down from z=5 through a unit box returned hits at z=-1 and then z=+1, so the far hit came first in this case. Sort the locations by distance from the ray origin before taking the first hit. Only one ray was tested, so the ordering is not a guarantee. (trimesh 5.2.1, numpy 2.5.4, Python 3.12)
