Hitpoints longer than the length of the ray are detected.

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);
          }
        }
      });

Welcome aboard!

Would you be able to setup a repro in the Playground? That way it will be easier to help. Thanks!

2 Likes