Finally just over 1 week after the beta release of Molehill and Flash Player 11, I have finally managed to spend some time to play with the new version of Away3D. So my intention today was to just get a model loaded and running, and firstly I was absolutely amazed at what a fantastic job the Away3D team have done with the new version of the engine, if you have ever done any AS3 programming with either Papervision or Away3D previously you will have no problem with this and even if you haven’t it is easy to pick up as the whole process has become a lot easier. Creating materials has been stream lined, in the example I have put together I am just using a simple ColorMaterial and simply by changing the ambient and specular amounts you can easily get very different effects. My materials are simply added like so:
- material = new ColorMaterial(currentColour, 1);
- material.specular = currentSpecular;
- material.ambient = currentAmbient;
- material.ambientColor = 0x555555;
- material.diffuseMethod = new BasicDiffuseMethod();
- material.lights = [pl, pl2];
- mesh.material = material;
with currentColour, currentSpecular & currentAmbient being values assigned by my components in this example, you can of course put your own variables and of course your own values. The rest of the example is pretty straight forward and just involves a View3D as you would expect a couple of PointLights and of course an enter frame event loop to render the scene each frame. I have also lifted the HoverDragController class from the Away3D examples.
What is most impressive about all of this is how smoothly it all runs. Even running the examples on my crappy Dell laptop with its measly ATI Radeon graphics card, most of the examples run perfectly at about 30 – 40 fps. I know there seems to be a bit of a WebGL vs Molehill thing going on at the moment, hey there is always a ‘something’ vs Flash thing going on – but I have never managed to get any WebGL example to run past 12 fps and most won’t run at all, so in my book that says a lot about how beautiful the the Molehill API is.
Next I want to have a play with getting some 2D objects running via Molehill which seems a really exciting prospect considering the popularity of frameworks such as Cocos2D for game dev…
If you want to download the source from my example you can get it here.