Flash 3D Backface Culling

This particular example uses Flash MX2004 Actionscript 2.0 but can be adapted to
Actionscript 1.0. Go to the page describing the Vector3D(v3d) class
before attempting this tutorial. I will be using functions from the Vector class that will save heaps of time and
typing. This tutorial was adapted from a
C++ tutorial by Simon Brown .

Bacface Culling entails not rendering faces on 2D models that will not be visible. They are behind other faces.
It saves time and processing power.
Make sure that your points are ordered clockwise in your face.
Let's go! Type this into your actionscript panel..

Now assume that our Point Of View (POV) is (0,0,0). We could calculate it from the position of our
camera if we had one. This POV vector goes to our model , so we choose point 1 arbitrarilly.

// -------- STEP 6
//compute a vector from the camera(OR pov(0,0,0))to our triangle
// i.e point 1 of our triangle
// if we had a camera it would be ( point 1 - camPoint )
var camVector = p1;
trace(camVector.toString()+" = camvector");

The dot product can now be calculated to give us the
cosine of the angle between the two vectors.
Therefore if the angle is either less than 90 degrees or
more than 270 degrees, then the triangle is facing away
and the cosine of the angle will be positive.
So all we need to do is compute the dot product and
cull triangles where the result is positive.