// a triangle that can remember if it has been clicked, and can shrink on request class Triangle { Vector3d a,b,c; boolean clicked = false; Triangle() { this.a = new Vector3d(); this.b = new Vector3d(); this.c = new Vector3d(); } // NB: will never stop shrinking, which is silly. void shrink() { Vector3d av = new Vector3d((a.x+b.x+c.x)/3.0,(a.y+b.y+c.y)/3.0,(a.z+b.z+c.z)/3.0); a.x += (av.x-a.x)/5.0; a.y += (av.y-a.y)/5.0; a.z += (av.z-a.z)/5.0; b.x += (av.x-b.x)/5.0; b.y += (av.y-b.y)/5.0; b.z += (av.z-b.z)/5.0; c.x += (av.x-c.x)/5.0; c.y += (av.y-c.y)/5.0; c.z += (av.z-c.z)/5.0; } }