Thursday, March 15, 2007

FLEX and 3D is it possible?

While I was digging the web trying to answer that question I must say I already had an assumption about it. Well these suspicions were mainly because Adobe Flex is based on Action Script 3.0 and Adobe Flash which is... let’s say the technology which had a big influence on the new child of Adobe, is mostly AS ver. 2.0. And as I have already seen some 3D solutions in Flash AS2, so it was very possible that it is the same with Flex, however it had to be checked.
So by simply typing “Flex 3D” in google I started looking for existing solutions. Well it turned out that there are not many, to be honest just a few. One of the best and very interesting Flex Apps is located here :
http://flexarena.blogspot.com/2006/10/3d-wireframe-renderer-for-flex.html
by Anjali Bhardwaj.
It consists of a wireframe renderer which loads 3Dmax ASE format and XML mesh models from the server side, however it is very primitive and simple, without textures and so on.. but that’s not the point here. By simply watching this example we are in some sort of way assured that it is possible to render and load objects which is really important from our point of view... in which, in the future we would like to use that kind of solution as a basis for our GIS 3D object oriented system. After digging some more, I have to say that it is really little done in 3D and Flex at the moment, and there are several reasons why.
First of all – why do something that is already done. Well as I said before Flash and Flex have more similarities than differences. Main difference is that the source file for Flash is a binary FLA which is compiled among with AS classes in Flash IDE to swf file which is later hosted on a server. Flex can deploy MXML(XML based) files and AS classes on the server which is generating swf files at runtime, that’s cool. Not having source in binary format is also important because it gives Flex ability to do for example ver. control on files. Well there are much more differences in server-client communication structure but my point here is that we should look for some really good 3D solutions for Flash and find out if they are able to take a leap to Flex environment.
Ok. Finding 3D solutions was quite easy. There are already some commercial products and also some open source approaches. Well 3D in Flash requires a bit more explanation because Adobe doesn’t support native 3D – no OpenGL or DirectX. There are some gossips saying that they are working really hard on it. Well these gossips could not be certified until I could get in touch with Adobe team, heh and I don’t think they would share their plans with me. So let’s pause on this thread for a second.
In the meantime let’s look at some non-native 3D solutiuons - software only. First is so called pre-rendered sprite approach. You create object with software such as Maya, Blender, Max or other.. then you render it from several angles and place it in Flash. It’s completely fake 3D. You can create really marvellous and vivid sites with that, because the only limit you get is the one with your software. However interaction is really limited so this is no good for our GIS purposes. Another approach is a real 3D engine, there are several at the moment and they differ on the ways of rendering. After taking a closer look at these beauties – documentation, license, source, examples, features and so on. I specified two possible candidates with are fully open source so that we can mess with the code. The names are Papervision3D (http://www.papervision3d.org) and Sandy3D (http://www.flashsandy.org). PV3D has a great advantage of being already implemented in AS3 what makes him much faster than Sandy. Ok now let’s invoke the thread that we paused before.
In this point a question arises... If the gossips about Adobe and its native 3D are true, is that a proper way that we’re going to follow with open source engines? Huh, well that’s a really good question because in that case most of the existing 3D engines will have to revise again their main goals, because if Adobe would release 3D engine it would probably wipe out all the existing ones. But, we are not sure at the moment what adobe plans right now... and in the other hand I truly doubt that hardware supporting engine for Flash would be such a good move for Adobe, in some way they would lost their platform independence. So, fake 3D engines can live. Especially bearing in mind that their performance is based on CPU speed, which is increasing these days month by month. At the moment PV3D engine based on AS3 is able to view 20.000 polygons per second which gives us 1000 in 20FPS. That is a really nice result and I think it should be enough for our GIS 3D project.
Ok, so now the answer... so Yes it is possible to render 3D environment in Flex. However there are some limitations which we should always keep in mind. Our goal here is to create simplicity, just like google maps or ArcWeb Explorer are using vector representation our priority is also to keep it as simple as possible while supporting many ways of evolution for future purposes.

1 comment:

Unknown said...

Great Post,
I also looking for something in 3D, but its more close to image map, with the Z-value showing only as gradient colors.

I will see if the PaperVision or Sandy can help me.

See ya