↩ Index page

3D polygon sampler

Creating a polygon

A polygon is created from a list of vertices. Each vertex is given either in coordinates or as a Point3D element. The vertices that are created from coordinates are styled according to the vertices attribute. The edges of the polygon are styled according to the borders attribute.

To make the layout of the vertices easier to see, I’ve set the view’s depthOrderPoints attribute to true.

Mixing coordinates and Point3D elements

This example shows how you can mix coordinates and Point3D elements in a polygon’s vertex list.

Filling a polygon

You can set the fill and opacity of a 3D polygon just like you would with a 2D polygon. I recommend only filling polygons that are guaranteed to stay planar. In this example, the polygons are always planar because they’re triangles.

The pitalls of filling a non-planar polygon

Make the polygon below non-planar by dragging its vertices. This will probably make the fill look really weird from certain angles.