is there any way to find the distance a ray had to travel unitl collision with a mesh object using rapierjs and typescript?
this is what i do to find out if a ray hits a mesh:
const rindices = Object.values(customMesh.getIndices())
const rpositions = Object.values(
customMesh.getVerticesData(VertexBuffer.PositionKind)!
) as any as ArrayBufferLike
const rnormals = Object.values(customMesh.getVerticesData(VertexBuffer.NormalKind)!)
console.log(rindices, rpositions, rnormals)
const world = new RAPIER.World({ x: 0, y: 0, z: 0 })
const trimesh = RAPIER.ColliderDesc.trimesh(
new Float32Array(rpositions),
new Uint32Array(indices)
)
world.createCollider(trimesh)
const ray = new RAPIER.Ray({ x: 0.5, y: 0.5, z: 0.5 }, { x: 0, y: -1, z: 0 })
world.step()
const hit = world.castRayAndGetNormal(ray, 10000, false)
but it does not tell me how far the hit point is away, not even where the hit point is. only that there is one.
any idea what to do to find the distance?
Thanks a lot!