Away3D 4.0 Gold: AS3 and three.js exporters

Last year I began messing around with the AS3 exporter for Away3D 3.6.0. After writing a few test scenes and resolving a few issues with it, I went on to see whether I could write a three.js exporter, and experienced some positive results.

Lots of things have changed since last September, the biggest of those being the complete rewrite of the Away3D engine to support the Stage3D APIs. One thing that hasn’t changed though is my particular interest in writing exporters for Away3D. The current “Gold” release of Away3D doesn’t yet support serialization; the old code obviously became defunct with the rewrite, and the Away team have no doubt been focused on code which is more pivotal to the engine’s success over recent months.

It just so happened that I needed at least a basic working Away3D exporter for a project I’m working on, so I decided to write a new one. If you’d like to see what I’ve added here are the commit details to my fork of away3d-core-fp11. If you’d like to run the few simple tests I’ve create for yourself, you can download them from my blog repo on github. Note: To run the experiments, you’ll also need a copy of my away3d-core-fp11 fork which contains the Away3D updates. Alternatively, you can view the same examples in your browser here.

As per the Away3D 3.6.0 -> three.js exporter, you’ll notice in the examples that the X-Axis is inverted. Other than this though, the results are pretty similar. I’ve decided not to try and rectify the differences below between the Away3D and three.js scenes, as they are all a result of how the engines “naturally” render their primitives and scene. For instance, I could have flipped the three.js Wireframe Plane and Torus primitives to match their Away3D counterparts, though this added code could cause confusion later if the developer expected the transform of the object to be the same as it was in ActionScript.


I’ve also tried to make the ActionScript and JavaScript outputted by the Serializer as neat and as similar to one another as possible. Here’s an excerpt from the ActionScript and JavaScript output created by the Primitives scene:


As you can see, three.js needs to use a slightly different geometry and material in this instance, but the resultant meshes both access these objects using their position in an array, which contains only that type of object.

Hopefully that gives a reasonable overview of the Serializer code as it stands, I’ll submit it to the Away team and keep my fingers crossed that it’ll be accepted..! 🙂

This entry was posted in Away3D, Flash, HTML5, Three JS and tagged , , , , . Bookmark the permalink.

3 Responses to Away3D 4.0 Gold: AS3 and three.js exporters

  1. If you need your project to run in both Away and ThreeJs. You might want to try Prefab3D 2. It does export to TJS out of the box for you. With the right transforms, materials & lights with a ready to be used, basic but functional html project.

  2. Pingback: Cadet Editor « Rob Silverton

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s