Always fun to try out another framework.
Papervision.
A while back we were commissioned to build a 3D game of Mahjong.
Nothing particularly challenging, simply blocks (or tiles as they are known) moving between players at a table.
At the time however, there were no actionscript 3 based 3D frameworks, so we hacked together a simple 3D API, the bare minimum needed for this particular project. This was fun, but wasn’t going to be much use for more demanding 3D based projects.
A few months down the line and Papervision comes along.
This is an open-source actionscript 3 based 3D framework (in case you haven’t heard of it).
Now, Papervision isn’t the only as3 3D framework out there, but it is surely the most heard of and most actively developed, and hence worthy of a Encore workout.
We were lucky enough to be asked to quickly knock out a mapping widget for a page in one of our sister companies, Creative Jar, contracts.
As we have a great deal of swf based mapping experience (statmap, maplecorft maps) and some good old 3D maths experience, we took the opportunity to take Papervision for a ride.
We needed to create a stylized, yet fairly accurate, globe of planet Earth, with locators placed at various longitude and latitude coordinates.
So we’re talking a sphere and then wrapping an image onto it. Parsing some XML with the data to map, in this case some hotspots/locators, that when rolled over display some location specific text. Each locator needed to be positioned on the globe via its longitude and latitude coordinates. The globe also needed to be rotated via mouse dragging.
So, Rob at CJ supplied an image of how the thing should look. Our challenge was to replicate the look, get all the interaction in, and do it in a day or so! Oh yes, and make sure it was fast and a small download.
Now, the first gripe with Papervision was interactivity. This can only be achieved by adding listeners to interactive materials. This, in our opinion is unintuitive. We would expect to simply say “this object should be interactive” and then the object emits mouse and keyboard events upon user interaction.
When loading a Collada file into Papervision however, you have to iterate the loaded objects loaded materials (and only when they are done loading) and set them as interactive. This is a shame and is a common gotcha for many new users to Papervision. Anyway, we write what’s required and off we go.
Next… We quickly found that by using all the available run-time shaders and lighting, rotating the globe was seriously slow. We quickly realized that this runtime shading/lighting (and there was lots due to Rob’s fancy design) was simply not needed and could be mimicked, so we got a very sharp speed increase from faking it. Of course in an ideal world, Papervision would be clever with its rendering and work out that the lighting and shading didn’t need to be reapplied to the globe on every render, but equally we didn’t need to apply it in the first case.
This wasn’t a Papervision bug, more a simple hack to get render speed, and in 3D programming, its all about the hacks – ask any 3D game programmer!
The final gripe (although gripe sounds a little too strong) was that of the development of the framework itself.
There are lots of check-ins to the source code repository, and over a few days, we found one check-in breaking functionality somewhere else. Really there just seemed to be no QA on the check-ins. For example changing a rotation attribute with a range of 0-100 to 0-1 for example, therefore breaking the API and any other component expecting 0-100, was this really needed? Was it not possible to delay the check-in until sufficient testing uncovers any bugs introduced from an API change?
The upside of this attitude to allowing check-ins with minimal testing, is that development moves very quickly, the downside breaking compatibility.
I doubt we could checkout the latest Papervision (lets say because it had some new piece of functionality we wanted to make use of), build our mapping widget and expect it to work without change and hunting out what change in Papervision caused the breakage.
We have worked with (and contribute to) a number of open-source projects, and the most friendly for end user developers are the ones well coordinated, so an API breaker, would be thoroughly discussed and tested before being committed.
Now this is not a knock Papervision rant, as in our opinion, Papervision is a superb piece of work from some very talented people.
They have brought a fantastic framework to the community of as3 developers.
My round-up would simply be, with a little QA, this could become far more developer friendly and hence uptake would be even greater than it is now.
For anyone interested, here is the resut of this particular experiment.