MeshObject is one such extending class. It extends BaseObject to provide the necessary resources to hold and manipulate a 3D object.
Click here to see the Actionscript source code for MeshObject.as
Again this is a very simple class. The one property, model, is used to hold a Papervision 3D model, which we initialize in the startupMeshObject function. It’s also in this function that we add the model to the Papervision scene. The shutdown function removes the model from the scene and sets the property to null. The enterFrame function has been overridden to rotate the model by a small amount every frame.
The model is loaded from a Collada file. Collada is an open 3D definition format designed to be a common ground amongst 3D applications (http://www.khronos.org/collada/). Collada is based on an XML format, which makes it easy to work with.
Papervision can parse a Collada file either from a separate file, or from an ActionScript XML object. I have generally found it easier to embed the assets for an application in the final SWF file (it means the end product is one file as opposed to a SWF file with many accompanying asset files) using the Embed keyword. Unfortunately while Flex offers a very simple way of embedding images, animations and sounds, you can’t use the Embed keyword directly with an XML file. When embedding an unrecognised format Flex exposes the embedded class as a ByteArray object. Fortunately we can work around this limitation and convert the ByteArray into an XML object. This allows us to embed the Collada XML model definition in the final SWF file using the Embed keyword, and then convert the resulting ByteArray into an XML object which is supplied to the Collada constructor.
The ResourceManager class is used to hold the embedded classes, and also the objects that use the embedded classes to expose the data they contain in a format that is useable by Papervision.