This function returns true if the given ray intersects the XY plane centered at the origin of the world coordinates. It returns a PVector object contaning the coordinates of the interesection between the ray and the plane. The ray can be automatically computed from the screen coordinates:
void draw() { // ... PVector p = intersectsPlane(mouseX, mouseY); // ... } A ray with arbitrary origin and direction can also be provided:
void draw() { PVector origin = new PVector(0, 0, 0); PVector direction = new PVector(0, 0, 1); PVector p = intersectsPlane(origin, direction); // ... }