Bright Hub
 
Matthew Casperson's Hubfolio

Away3D Programming Tutorials - 3D Text

Article by Matthew Casperson (227,413 pts )
Published on Sep 20, 2009

Learn how to add 3D text to a scene in Away3D.

Introduction

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.

Code Documentation

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]

Final Words

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

Related Files

Images

Screenshot

Search More About:

Comments

Mar 10, 2010 9:00 PM
Edward Wang
TestField3D object problem
Hi
I have a problem about TestField3D object displaying ,
the problem is that when I set the visible property to false,
the TestField3D object still visible on the scene!!
Could you help me to solve the problem?
many thanks!!
 
Follow Matthew Casperson
Receive weekly updates from Matthew Casperson
 
Bright Hub - Science & Technology Articles, Buyer's Guides, How-To Tips and Software Reviews
About Bright Hub | Contact Us | Advertise with Us | Become a Writer | RSS | Site Map | Terms of Use | Privacy Policy | Copyright Policy
©2010 Bright Hub Inc. All rights reserved. Page copy protected against web site content infringement by Copyscape