This post is the first in a series of quick guides for programmers new to Flash and ActionScript development.
While much of what is covered will probably be familiar ground to many ActionScript developers, for Flash newbies these guides will hopefully offer a good introduction to the code libraries available for use in your projects. This one will focus on the range of 3D engines that are now available for Flash, highlighting the key features of each engine and hopefully help make it a little bit easier to choose one to use.
Papervision3D – http://blog.papervision3d.org/
The most popular and widely used of the current 3D engines for Flash is also the first one to have a book released about it. I’ve used it on a couple of projects now, and have always found it very simple and easy to use. It may not have all the advanced features and effects of some of the other engines featured here, but it does provide a smoother learning curve for those that are new to 3D, with a logical and well structured API, excellent documentation and an abundance of tutorials. Papervision also has a great development community, with a real focus on helping those who are just starting out with 3D in Flash. To see the range of projects that already use this engine take a look at the Papervision Showcase site, for some great demos and tutorials check out pv3d.org.
Away3D – http://away3d.com/
Some would say that Away3D has a better feature set and is much more powerful than any other open source AS3 3D engine currently available, and that may well be the case judging by the amazing demos that get featured on the project’s home page. Another plus is it’s great level of Flash Player 10 support, which not only provides a major speed increase but also some new features like Pixel Shader support and HDR lighting. However, with all these extra features comes larger file sizes, a more complex API, and a much steeper learning curve, although some of this is now being addressed by the very impressive Away3DLite project.
Sandy3D – http://www.flashsandy.org/
Another great 3D engine for Flash, this time with added support for both AS2 and AS3, as well as a HaXe version. It also offers unique features like integration with the WOW physics engine and some rather nice colored lighting effects that remind me of Quake 2 and the early days of 3DFX video cards.
Alternativa3D – http://alternativaplatform.com/en/alternativa3d/
This engine looks to be very much geared towards high quality visuals and seems to have been heavily optimized for use as a first person perspective engine. It has some truly amazing first person demos which showcase its advanced rendering features, but until recently I’d only seen the demos rather than finished sites. However this stunning new Golf GTI racing game really proves Alternativa3D to be an excellent platform for 3D Flash development.
Five3D – http://five3d.mathieu-badimon.com/
An excellent lightweight vector based alternative to the 3D engines above. I’ve used it on a couple of projects at work and have found it very easy to use as it builds upon existing AS3 classes like Sprite in much the same way as the new 3D API does in Flash Player 10. If you just want to add some 3D perspective and animation to shapes created with the 2D drawing API then this is the 3D library to use.
ND3D – http://www.nulldesign.de/projects/nd3d-as3-3d-engine/
With a compiled size of around 10k, this engine is aimed at speed and simplicity in a similar way to Five3D and Away3DLite. It also has some great built in features that you can use straight out of the box including: depth of field effects, additive blending and interactive meshes. Check out the demos on the project home page to see what it can do, this is definitely one to watch in the near future.
ZedBox – http://code.google.com/p/zedbox/
This new engine addresses the limitations of Flash Player 10’s native 3D rendering -mainly the pixel aliasing issues caused by bitmap caching when 3D transforms are used – by offering a lightweight alternative. It only features flat ‘billboard’ style graphics, but it runs fast and appears to be very easy to use.
Yogurt3D – http://www.yogurt3d.com
Yogurt3D is a new engine primarily aimed at making 3D games in Flash. Not that much is known about the engine right now, but the website says that it will which feature a core API named ‘SwiftGL’ that should be familiar to developers who already know OpenGL.
So apart from using one of these excellent open source libraries, what else could you do to get 3D graphics running in your Flash websites and games? Well there’s always Flash Player 10 and it’s built in 3D support. I’ve recently been trying out Flex 4 and had a go at using the new 3D features such as drawTriangles, and while it is definitely simple and easy to, requiring very little maths, the visual quality wasn’t quite what I’d hoped for when compared to Papervision3D and Five3D. Saying that, the real potential of native 3D in Flash Player 10 is in the new 3D utility classes, which along with pixel bender and alchemy are being used to improve many of the current Flash 9 3D engines.
Of course, there’s always the option of making your own 3D engine using the standard drawing API and a bit of maths, or even trying something a bit more ambitious like ray tracing or voxels, it’s all possible in AS3. One great example of this ‘home made’ approach is the incredibly fast Sharikura3D engine by Roxik. This engine was used for Eco Zoo, which won the FWA 2008 Site of the Year award, and has some of the best graphics and the smoothest frame rate I’ve seen in any 3D Flash website.
If any of this has inspired you to find out more about writing your own 3D engine in AS3, then Keith Peters legendary book – Foundation AS3 Animation: Making Things Move – is definitely the place to start. The book covers the basics of setting up a vector based 3D engine in AS3 and includes shading, backface culling and 3D meshes, along with loads of other graphics and animation concepts. In fact, even if you’ve no intention of writing a 3D engine from scratch, it is still well worth a read as it really helps you understand the basics of how 3D in Flash actually works.