Away3D can take an amazing number of tasks and make them fairly simple to set up. But surprisingly displaying text isn’t one of them. Not that it’s hard. It’s just a bit verbose.
You have to:
- Embed the font in a SWF.
- Load the SWF into Flash.
- Use ByteArray to extract the font from the SWF
- Create a Material to use on the font face.
- Create the TextField3D.
- Create another Materialfor the Extrusion.
- Extrude the TextField3D – assuming you want the text to pop in 3D
- Away3D 101 : Basics
- Away3D 101 : Coordinates
- Away3D 101 : View3D and Camera3D
- Away3D 101 : Nesting
- Away3D 101 : Camera Orbit
- Away3D 101 : TargetCamera3D
- Away3D 101 : HoverCamera3D
- Away3D 101 : Walkabout
- Away3D 101 : Primitives
- Away3D 101 : Postcards
- Away3D 101 : Segments
- Away3D 101 : Loading Models
- Away3D 101 : Apply BitmapMaterial to Model
- Away3D 101 : Sprite3D
- Away3D 101 : Materials
- Away3D 101 : Lights
- Away3D 101 : PointLight Explorer
- Away3D 101 : DirectionalLight Explorer
- Away3D 101 : MovieMaterial
- Away3D 101 : Text
- Away3D 101 : Vector Shapes
- Away3D 101 : Filters
- Using AS3Exporter in Away3D
// Font embedded in a SWFYou’re out of luck if you want to change the depth that the font is extruded by. That’s hard coded to 100 pixels. No idea why. Doesn’t seem to be fully baked. Hopefully in Away3D 4.0 text will get revisited and improved.
[ Embed( source="assets/verdana.swf",
mimeType="application/octet-stream" ) ]
private var VerdanaSWF : Class;
...
var font : ByteArray = new VerdanaSWF() as ByteArray;
VectorText.extractFont( font );
var faceMaterial : WireColorMaterial = new WireColorMaterial();
faceMaterial.color = 0xFFFFFF;
faceMaterial.wireColor = 0x000000;
var text3D : TextField3D = new TextField3D( 'Verdana' );
text3D.text = "Away3D ROCKS!";
text3D.size = 100;
text3D.leading = 20;
text3D.width = 600;
text3D.material = faceMaterial;
_view.scene.addChild( text3D );
var exMaterial : WireColorMaterial = new WireColorMaterial();
exMaterial.color = 0xFF0000;
exMaterial.wireColor = 0x000000;
var extrusion : TextExtrusion = new TextExtrusion( text3D );
extrusion.bothsides = true;
extrusion.material = exMaterial;
extrusion.back = exMaterial;
_view.scene.addChild( extrusion );
view source and select t_Text.mxml from the left navigation. |
0 comments:
Post a Comment