Blog

Multiline WordWrap DynamicText3D in FIVe3D

June 23, 2009 by Devin Reimer

FIVe3D Word Wrap Screenshot

For those of you that have never heard of FIVe3D, it is a lightweight vector based 3D library now written in AS3. You can check it out for yourself, http://five3d.mathieu-badimon.com.

In working on a small project using FIVe3D I discovered that while the 3D text part of the library is awesome it did not support multiline word wrap. I had seen examples of people using muliple DynamicText3D objects to fake text being multiline, but I wanted the text to be able to support dynamically word wrapping.

So I created a class called DynamicText3DMultiline which works the exact same way as the normal DynamicText3D class, but adds multiline wordwrap functionality. To use wordwrapping, simply set the width of the object and then set wordwrap equal to true.

var dynText:DynamicText3DMultiline;
dynText = new DynamicText3DMultiline(HelveticaMedium);
dynText.width = 200;
dynText.size = 14;
dynText.wordWrap = true;

There is next to no overhead in using this class instead of the DynamicText3D class when you don’t need the word wrapping feature, so as in my example this is now my standard text rendering class. Also it does have the added benefit have having a textHeight function.

To play the demo click here.

To get the demo source and the new DynamicText3DMultiline class click here.

Source Requirements: You will need both FIVe3D 2.1.2 and TweenMax to compile the demo source.

Update: I have been informed that people have not been able to get this class to work with their own generated typography files. I have discovered the issue, it turns out there is a small bug in the Typography Generator. Luckly the solution is easy. Once you create a new typography AS file, open it up and go to line 15. Change the variable ‘__heights’ to ‘__height’, and word wrapping will work.

Update 2: A new version of the DynamicText3DMultline class has been released with new features. Please check out the new post.

Update 3: I have released a new version that now supports the newest versions of FIVe3D. To go to the new post click here.

7 Responses to "Multiline WordWrap DynamicText3D in FIVe3D"

  1. nathan says:

    any way to integrate this with papervision3d with the addition of the new vector and text3d libraries?

  2. Devin Reimer says:

    I’ve only played around with VectorVision (Papervision3D vector component) a little bit. I’m sure something could be wrote to do something similar in Papervision3D. That being said in my opinion when it comes to 3d text FIVe3D wins hands down.

  3. Lach says:

    Hi Devin. Thanks for posting this code. Great stuff. Saved me a few hours, I can tell you. It doesn’t seem to be compatible with the latest version of Five3D however, so I made a couple of slight modifications. Let me know if you’d like me to send you the updates. Cheers.

  4. Eric Miner says:

    @Lach’
    I Sure could a copy of a working as3 version…

  5. Eric Miner says:

    Never Mind I got It!

  6. Devin Reimer says:

    @Lach
    I started work on an updated version of this class that will work with the newest version. It should be up on my blog next week. :)

Leave a response