drawTriangles and projectVectors for 3D

I’m trying to render a 3D model in flash. I don’t want to use Stage3D or an external library. What I’m currently doing is:
[LIST]
[]Defining a perspective matrix using PerspectiveProjection
[/LIST]
[LIST]
[
]Defining another matrix for the camera
[/LIST]
[LIST]
[*]I set the camera matrix to identity, append translation and rotation, append the projection matrix so it’s not orthographic, and use projectVectors from Utils3D to convert the geometry to 2D points for drawTriangles.
[/LIST]This works fine when it comes to rendering the geometry, but when my camera moves close or beyond the geometry, it gets really screwed up, and I tend to see an inverted version of the geometry.

Here’s the swf (use the play in fullscreen button to see more clearly)

Here the camera moves forward continuously past the cube, but the geometry goes all over the place when you are near it and you see an inverted cube when you pass it.

I’m not that great when it comes to 3D rendering. I would greatly appreciate any help with this.