Learn how to add 3D text to a scene in Away3D.
A new feature to Away3D 3.4 is the ability to create 3D text. The 3D Text screensaver for Windows is a good example of this effect. This ability actually comes from the swfvector library, which the Away3D TextField3D class uses to create a 3D model from a font definition. The TextExtrude class can then be used to create characters with depth.
ResourceManager.as
In order for the 3D text to be created, we first need a base font definition to start with. This is in the form of a SWF with embedded fonts, which in turn is embedded in our application. [code]
ApplicationManager.as
In order to build a vector based font, the VectorText class first needs to be given the font that will be used. These fonts come from the embedded SWF file from the ResourceManager. We call the extractFont function, and supply a new instance of the embedded SWF file. [code]
There are 2 parts to a 3D text mesh. The first is the text itself, without any depth. This is created by the TextField3D class. We create a new instance of the TextField3D class, supplying the font name (from the embedded SWF file) in the constructor. [code]
The material property defines the material that will be applied to the text. Here we use a coloured wireframe material. [code]
The text that will be displayed is set through the text property. [code]
The size and textWidth properties define the final dimensions of the text. [code]
In order for the text to have depth we use the TextExtrude class. This creates a new mesh that forms the sides of the text. [code]
Because the final 3D text is made up of two meshes, we combine them in a ObjectContainer3D. This allows us to modify the ObjectContainer3D, which in turn will modify both the meshes that make up the 3D text. [code]
The ObjectContainer3D is repositioned in the middle of the screen. [code]
The pivotPoint of the ObjectContainer3D is set to the middle of the text. This way when we rotate the text we will rotate it around the centre of the text, and not the edge. [code]
This ObjectContainer3D is added to the scene with a MeshObject. [code]
The TextField3D and TextExtrude classes give the developer the ability to add text based on any font into a 3D scene with relative ease.
Go back to Away3D Tutorials