Improve distance3D (issue : Invalid Line make distance function to crash)