All examples · Meshes and 3D · As Markdown, for AIs

Click what you see

What this example shows

Click a piece to pick it up, and click the felt to put it down.

No physics here. screenToRay turns the pointer into a ray from the camera, and castRay says what that ray meets among the models, as they are drawn: the nearest first, with the point where it touched. It reaches the coins too, which are instances of one mesh, and says which one. What is under the pointer is drawn a little brighter.

To put a piece down, rayOnPlane finds where the same ray crosses the table's top, a flat plane, and the piece goes there.

Starting
Starting
—