I set the length of the ray to 20. However, among the hitpoints, there are points with a distance greater than 20. I visualized it with rayHelper. But I couldn’t figure out the cause.
rays.forEach((ray_) => {
let ray = new Ray(
body?.position!,
Vector3.TransformCoordinates(ray_.ray, rotMatrix).normalize(),
20
);
let hit = scene.pickWithRay(ray, (mesh) => {
const meta = mesh.metadata;
if (!meta) {
return false;
}
return meta.isWorld === true;
});
if (!hit) {
return;
}
if (hit.pickedPoint) {
if (hit.distance > 20) {
console.log(ray.length, ray);
console.log(hit.distance, hit);
}
}
});