Three-Dimensional Graphics Directives

In three dimensions, just as in two dimensions, you can give various graphics directives to specify how the different elements in a graphics object should be rendered.

All the graphics directives for two dimensions also work in three dimensions. There are, however, some additional directives in three dimensions.

Just as in two dimensions, you can use the directives (RefLink[PointSize, paclet:ref/PointSize]), (RefLink[Thickness, paclet:ref/Thickness]), and (RefLink[Dashing, paclet:ref/Dashing]) to tell the Wolfram System how to render (RefLink[Point, paclet:ref/Point]) and (RefLink[Line, paclet:ref/Line]) elements. Note that in three dimensions, the lengths that appear in these directives are measured as fractions of the total width of the display area for your plot.

This generates a list of 20 random points in three dimensions:

pts=Table[Point[Table[RandomReal[],{3}]],{20}];

This displays the points, with each one being a circle whose diameter is 5% of the display area width:

Graphics3D[{PointSize[0.05],pts}]

As in two dimensions, you can use (RefLink[AbsolutePointSize, paclet:ref/AbsolutePointSize]), (RefLink[AbsoluteThickness, paclet:ref/AbsoluteThickness]), and (RefLink[AbsoluteDashing, paclet:ref/AbsoluteDashing]) if you want to measure length in absolute units.

This generates a line through 10 random points in three dimensions:

line=Line[Table[RandomReal[],{10},{3}]];

This shows the line dashed, with a thickness of two printer's points:

Graphics3D[{AbsoluteThickness[2],AbsoluteDashing[{5,5}],line}]

For (RefLink[Point, paclet:ref/Point]) and (RefLink[Line, paclet:ref/Line]) objects, the color specification directives also work the same in three dimensions as in two dimensions. For (RefLink[Polygon, paclet:ref/Polygon]) objects, however, they can work differently.

In two dimensions, polygons are always assumed to have an intrinsic color, specified directly by graphics directives such as (RefLink[RGBColor, paclet:ref/RGBColor]) and (RefLink[Opacity, paclet:ref/Opacity]). In three dimensions, however, the Wolfram System generates colors for polygons using a more physical approach based on simulated illumination. Polygons continue to have an intrinsic color defined by color directives, but the final color observed when rendering the graphic may be different based upon the values of the lights shining on the polygon. Polygons are intrinsically white by default.

Some schemes for coloring polygons in three dimensions.

This draws an icosahedron with default lighting. The intrinsic color value of the polygons is white:

PolyhedronData["Icosahedron"]

This draws the icosahedron using the same lighting parameters, but defines the intrinsic color value of the polygons to be gray:

Graphics3D[{Gray,PolyhedronData["Icosahedron","GraphicsComplex"]}]

The intrinsic color value of the polygons becomes more obvious when using the "Neutral" lighting scheme:

Graphics3D[{Gray,PolyhedronData["Icosahedron","GraphicsComplex"]},Lighting->"Neutral"]

This applies the gray color only to the line, which is not affected by the lights:

Graphics3D[{PolyhedronData["Icosahedron","GraphicsComplex"],Gray,Thickness[0.1],Line[{{0,0,-2},{0,0,2}}]}]

As with two-dimensional directives, the color directive can be scoped to the line by using a sublist:

Graphics3D[{{Gray,Thickness[0.1],Line[{{0,0,-2},{0,0,2}}]},PolyhedronData["Icosahedron","GraphicsComplex"]}]

Giving graphics directives for all the edges of polygons.

When you render a three-dimensional graphics object in the Wolfram System, there are two kinds of lines that can appear. The first kind is lines from explicit (RefLink[Line, paclet:ref/Line]) primitives that you included in the graphics object. The second kind is lines that were generated as the edges of polygons.

You can tell the Wolfram System how to render all lines of the second kind by giving a list of graphics directives inside (RefLink[EdgeForm, paclet:ref/EdgeForm]).

This renders a dodecahedron with its edges shown as thick gray lines:

Graphics3D[{EdgeForm[{GrayLevel[0.5],Thickness[0.02]}],PolyhedronData["Dodecahedron","GraphicsComplex"]}]

Rendering the fronts and backs of polygons differently.

An important aspect of polygons in three dimensions is that they have both front and back faces. The Wolfram System uses the following convention to define the "front face" of a polygon: if you look at a polygon from the front, then the corners of the polygon will appear counterclockwise, when taken in the order that you specified them.

This makes the front (outside) face of each polygon mostly transparent, and the back (inside) face fully opaque:

Graphics3D[{FaceForm[{Opacity[0.3]},White],PolyhedronData["Cube","GraphicsComplex"]}]