Since the comments made clear you're looking for a general solution, I'll describe that process here. Note the code is to show the principle, you will need to translate it to the framework you're using. I also assume you are familiar with projection, view and world matrices- and their role in 3D graphics.
3D Mouse picking
The idea is to create a ray from the mouse (screen) towards the distance.
A Ray is basically a line with one startpoint and a direction:
Ray r = new Ray(startpoint, directionVector);
Now let's create a ray from the mouse pointer. To do this, we consider a 'near' and a 'far' plane. The line is from the screen towards the horizon- however we only need the direction, so it does not really matter if the far point is actually near the horizon.
Vector3 nearPlaneMousePointer = new Vector3(mouseX, mouseY, 0);
Vector3 farPlaneMousePointer = new Vector3(mouseX, mouseY, 1);
Now we have two coordinates in the 3D space- in relation of the screen- the viewport.
To convert the coordinates in the worldspace, we actually need to "unproject" (inverse of the projection) to get the correct coordinates.
Most frameworks have a 'Viewport.Unproject()' method- using the projection and view matrices, to calculate a given point to it's original unprojected object space.
Vector3 nearPlanePoint = Viewport.Unproject(nearPlaneMousePointer, _projection, _view, Matrix.Identity);
Vector3 nearPlanePoint = Viewport.Unproject(farPlaneMousePointer, _projection, _view, Matrix.Identity);
With these two points you can now get the direction and construct the ray:
Vector3 rayDirection = farPoint - nearPoint;
Ray r = new Ray(nearPoint, rayDirection);
Now we have a ray that is in the object space.
We can still not use it to do the ray picking. Why? Because the object space does not take the world matrices into account. If you only have AABBs or the worldspace is static, this step may not be needed. I'll provide the theory anyway in the event you plan to move things around a bit more and use world matrix.
So translate the ray into world space. To do this, use the inversion of the world matrix.
Matrix inverted = _world.Invert();
Ray worldRay = new Ray(Vector3.Transform(r.Origin, inverted),
If the target quads are also transformed to world space, a ray-triangle intersection test will provide your answer. Loop through the quads and check is the quad is hit. Some frameworks have a hit test function for rays and quads or triangles.
The result of the hit test can also be checked for distance from the ray's origin: this way you can select the first quad that is hit- if the viewpoint has overlapping quads.
You can optimise this part als by checking only quads that were in the viewport (use the same culling mechanism as you would in drawing the world).