Culling

Culling is the process that determines which surfaces of a three-dimensional object the renderer should not render because they are hidden from the current viewpoint. In 3D space, the surface on the “back” of a three-dimensional object is hidden from the viewpoint:
The back of a 3D object is hidden from the viewpoint.

A.
viewpoint

B.
3D object

C.
the back of a three dimensional object

Inherently all triangles are always rendered no matter their size, shape, or position. Culling insures that Flash Player or AIR renders your 3D object correctly. In addition, to save on rendering cycles, sometimes you want some triangles to be skipped by the render. Consider a cube rotating in space. At any given time, you'll never see more than three sides of that cube since the sides not in view would be facing the other direction on the other side of the cube. Since those sides are not going to be seen, the renderer shouldn't draw them. Without culling, Flash Player or AIR renders both the front and back sides.

A cube has sides not visible from the current viewpoint

So, the Graphics.drawTriangles() method has a fourth parameter to establish a culling value:

public function drawTriangles(vertices:Vector.<Number>, indices:Vector.<int> = null, uvtData:Vector.<Number> = null, culling:String = "none"):void

The culling parameter is a value from the TriangleCulling enumeration class: TriangleCulling.NONE , TriangleCulling.POSITIVE , and TriangleCulling.NEGATIVE . These values are dependent upon the direction of the triangle path defining the surface of the object. The ActionScript API for determining the culling assumes that all out-facing triangles of a 3D shape are drawn with the same path direction. Once a triangle face is turned around, the path direction also changes. At that point, the triangle can be culled (removed from rendering).

So, a TriangleCulling value of POSITIVE removes triangles with positive path direction (clockwise). A TriangleCulling value of NEGATIVE removes triangles with a negative (counterclockwise) path direction. In the case of a cube, while the front facing surfaces have a positive path direction, the back facing surfaces have a negative path direction:

A cube “unwrapped” to show the path direction. When “wrapped”, the back side path direction is reversed.

To see how culling works, start with the earlier example from UV mapping, set the culling parameter of the drawTriangles() method to TriangleCulling.NEGATIVE :

container.graphics.drawTriangles(vertices, indices, uvtData, TriangleCulling.NEGATIVE);

Notice the “back” side of the image is not rendered as the object rotates.