Mouse picking in JMECanvas

Hello there!

Please, help, I'm stucked here and no idea about where is the problem. The thing is I have a JMECanvas embedded in a swing-based application. I'm trying just to display a scene so you see it from the top (the camera direction is (0,-1,0) and it is located at (0,h,0), where h>0 && h varies when you move the mouse wheel). Therefore what you see is the XZ plane. What I just want to do is pick (x,z) positions on the plane y=0 using the mouse. I've followed the instructions in the forum so the code I got is:

            public void mouseClicked (MouseEvent arg0){

         Vector3f worldCoord1 = cam.getLocation();

         Vector3f worldCoord2 = DisplaySystem.getDisplaySystem()
                     new Vector2f(arg0.getX(), (height - arg0.getY())),

         Ray mouseRay = new Ray(worldCoord1, worldCoord2

         float lambda = -mouseRay.getOrigin().y / mouseRay.getDirection().y;
         float x = lambda * mouseRay.getDirection().x
               + mouseRay.getOrigin().x;
         float z = lambda * mouseRay.getDirection().z
               + mouseRay.getOrigin().z;

The thing is the accuracy of the position x,z I get heavily depends on the distance between the point I'm clicking and the center of the screen. That is, when the point I click is on the center (alligned with the camera) the position is ok, if you click far away from the center the position returned is not correct.

Any ideas about what I'm missing?

Any help much appreaciated, really