Tony Polinelli
Tarwin Stroh-Spijer

contact [at]

6/25 Easey Street
Collingwood, 3066
Vic, Australia

+61 3 8060 5321

Away3DLite haXe + Morphing

I recently started on a 3D Flash job and was chuffed to find that Cauê Waneck has been porting Away3DLite to haXe. Anyway, suffice to say I was super-happy that I didn't have to do any AS3.

What's there currently is a direct port of the Away3dLite library, but in haXe. It makes a big use of the AS3 (FP10) native Vector (Vectora<Float>) so it's quite fast, but not directly portable to platforms other than Flash 10 yet. As far as I can tell performance is the same as, or similar to the FP10 AS3 release, but Cauê has assured me that he's having fun optimizing it.

Away3DLite is missing some functionality that is in the full version, things that I need for my current project, including the Morpher and AnimatedBitmapMovieMaterial classes. The first I've ported myself and the second has been ported by Cauê (thanks mate!).

So, here's a demonstration of Morphing working: Morph Test and here's another: Mouth Morph Test.

And the Morpher.hx class.

I had a lot of trouble getting it working to start with but it's pretty easy once you get the ideas down. The main problem I had was the fact that neither the Collada object, nor the Object3D you get from it when doing .parseGeometry() has any vertices, so I got nothing when I passed it to the Morpher. What I'd missed is that I need to get one of the children from the Object3D that I get from the Collada .parseGeometry(). This is because, as Bartek Drozdz points out, "a Collada file represents a scene, not a single 3d object".

The next thing to know is that you should wait for the ParserEvent.PARSE_SUCCESS events dispatched from your Collada objects. When these are done you can use .getChildAt(0) on your .parseGeometry(colladaData) object to get a Mesh which you can then parse to your Morpher. In my example I have:

  1. m0 = cast c0.parseGeometry(daeData1); // used to restet Morpher to original state
  2. m1 = cast c1.parseGeometry(daeData1); // the model that I scene.addChild(m1) to
  3. m2 = cast c2.parseGeometry(daeData2); // the model to Morph to

As you should notice I'm using the same daeData for both m0 and m1. I make my new Morpher passing it m1, then on each enterFrame:

  1. mp.start();
  2. mp.mix(cast m2.getChildAt(0), (1 + Math.sin(Lib.getTimer() / 150)) / 3);
  3. mp.mix(cast m2.getChildAt(0), (1 + Math.cos(Lib.getTimer() / 250)) / 3);
  4. mp.finish(cast m0.getChildAt(0));

Hope that helps someone else, I was stuck for days :(

Yay my first post in months!


  1. Thanks for posting, that's a neat little demo. I've played a fair bit with Haxe and I was thinking about doing some 3D stuff.

    One question though - I notice from your demo's that you have what looks like a nice little pre-loader on your demo. I've done a bit of looking round and I thought getting preloaders to work in Haxe was a real pain. Could you explain on how you did it please?



  2. Preloaders are the same in haXe as they are in AS3/Flash. The only problem I came up against is I was targeting the output for my preloader for FP9, and trying to load FP10 content, which did cause massive problems!

  3. Actually - the confusion probably comes from the fact it's hard to make a pre-loader for single SWFs. Just make a container.swf that uses "Loader" to load a different SWF. Easy!

  4. #

    Yes it's true, That is certainly beneficial


Leave a Reply

Our Friends:

Powered by haXe / poko cms | Copyright 2008-09 TouchMyPixel