Friday 9 March 2007

Ajax3D experiment

Years ago I used to do MUD development as a hobby. The direction we were heading was to define the text based game world in 3D in order to have a continuous world rather than room based as was the standard. The long term goal was to have a simple 3D editor to streamline world building. Luckily one of the other programmers, Brian Behlendorf, was a doer and he put his head down and came up with a prototype. A VRML viewer for the game world. It took advantage of the fact that our MUD had an integrated web server, which could be used to fetch the static world data, and used Javascript to make a VRML plugin (Cosmo Player) fetch that data from it.

Nowadays I have a hobby project I need to visualise. There are easy ways to do this like PyOpenGL or PyGame, but taking the direction behind Brian's VRML viewer and extending it for the latest trends like AJAX (which I assumed could be used to establish a bidirectional channel) has a lot more advantages. It is in my best interest to educate myself about the latest web development techniques like AJAX and the end goal of having an X3D based browser client is an interesting project in and of itself.

The first step was to learn what AJAX was and to get it working with a web server. I encountered Pyjamas which looked promising, but the problem was that it had been a long time since I last did Javascript programming and given that it replaces that with Python, it looked like it would get in the way of the learning process. Next were the various Javascript frameworks and as interesting as they looked, it also looked like I needed to learn Javascript before I could benefit from what they offered. In fact it looked like the approach I needed to take in order to achieve what I wanted and to ensure I understood how it all worked from the ground up was to build it from the ground up.

Interestingly the people behind my X3D plugin of choice (Flux Player) have started Ajax3D.org in order to forward the use of AJAX with X3D. Although the examples it provides are just simple client based AJAX and none go to the extent of establishing bidirectional communication.

Anyway AJAX led to JSON and I ended up using BaseHTTPServer with simplejson on the server side and JSON in Javascript on the client side with Flux Player embedded. And this is the point I am at now, learning X3D and how to use it, especially controlled by browser based Javascript. One setback however, is the fact that Flux Player seems crash prone. When you combine that with Firefox's saving of tabs, what you get is a browser which
continually crashes every time it restarts unless you are willing to throw away whatever else is in your other tabs. In theory Flux Player is open source but it looks like releases of the latest source code have trailed off years ago, so debugging this myself is out of the question. Oh well, will see how it goes.

1 comment:

  1. Flux Studio and Flux Player are now on their new homepage: http://mediamachines.wordpress.com/flux-player-and-flux-studio/

    ReplyDelete