RayPick won't Capture polygon that shares two axes

I cant save a PG right now for some reason but here:

var createScene = function () {
   
    var scene = new BABYLON.Scene(engine);
    var camera = new BABYLON.FreeCamera("camera1", new BABYLON.Vector3(0, 5, -10), scene);
    camera.setTarget(BABYLON.Vector3.Zero());
    camera.attachControl(canvas, true);
    var light = new BABYLON.HemisphericLight("light", new BABYLON.Vector3(0, 1, 0), scene);
    light.intensity = 0.7;

    var ground = BABYLON.MeshBuilder.CreateGround("ground", {width: 6, height: 6}, scene);

    var ray = new BABYLON.Ray(new BABYLON.Vector3(4, 0, 0), new BABYLON.Vector3(-1, 0, 0), 4)
    new BABYLON.RayHelper.CreateAndShow(ray, scene, BABYLON.Color3.Red())
    let pick = scene.pickWithRay( ray, ( mesh )=>{
        return true
    })
    
    console.log(pick)

    return scene;

};

This would ideally still capture a hit, I am wondering why it is not detecting the ground plane.

There is no intersection as the ground does not have depth. You may have to angle your ray a bit. Are you wanting to know the distance to the ground?

No, I think I am just going to do a simple SAT algo and test a single axis against the other SAT shapes.

1 Like