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.
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..! 🙂