This demo doesn’t do much in terms of interaction, you walk around and explore a strange environment which has spinning teapots, but it does demonstrate the power of the library. It took very few lines to write it, less than 130 lines, most of which is initialization and only a handful that actually deal with any 3D math. This means anyone who has even a basic understanding of Javascript should not have a hard time writing a demo like this one.
Another interesting thing about this demo is the use of a basic Skybox. That’s not all that interesting until you start thinking that this can probably be added to the library. Therefore about 30 lines which is needed to create a set of flat planes and texture them can probably be reduced to just a couple to create the Skybox and give it the position of the camera. This will make creating 3D environments that much easier.
I’ve fixed a bunch of obvious javascript performance problems (memory allocated for no good reason).
Now Im at the point where I need to see the difference in a real app, because further fixes won’t be as obvious. Will someone please put a testmain that uses models into svn? Don’t worry about making it pretty, just give me something to start from. If you insist on being picky – just email it to me.
The cube renderer is a pretty disgusting function and could use a lot of fixing, but I think we’re getting rid of Cube anyway, so I won’t do much to it.
It has been awhile since I last posted. I have been busy on working with the Flickr API and how to get pictures from it. The demo I was asked to work on next is taking random pictures from Flickr and add them to an object in a scene in canvas 3d. This was already done by Philip over at Mozilla Labs . His demo broke after an update to the Canvas3D extension. His demo is found here.
I decided to take it a little further and I want a demo where I can add photos to cubes in the scene but allow the user to rotate any cube by clicking on it and dragging. Then if the user double clicks on the cube, the camera will zoom in on the cube and if the user double clicks again the camera will go back to it original position.
I have all the individual parts working, I just need to combine it and pretty it up just a tad. I will be releasing it next week.
We get a gerk every 10 seconds on the 4 cubes sample. This happens when firefox accumulates about 10M of memory marked for garbage collection.
By selectively commenting out code I’ve come to the conclusion all that memory is used for objects allocated with ‘new’. There may be some little bit used for local variables and maybe even plain function calls, but it’s negligible considering the scope of the problem I’m fixing.
I didn’t even bother looking for a way to fix the garbage collector, I assume any such attempt is futile from javascript and a hacky way to make our code match what the garbage collector does will just kick us in the ass when the Firefox garbage collection algorithm is updated (if you don’t want it to happen, it surely will).
But seing how most of the memory is allocated for new Vectors and Matrixes I’ve taking a simpler approach to solving the garbage collector troubles – don’t allocate memory in the first place.
From the very start I’ve been wondering (I’ve even found a wtf comment saying so) why we allocate new Vectors and Matrixes when we just need to modify existing ones. Now I’ll go through the code and make sure we don’t. So far I haven’t seen any reason to worry that won’t be good enough. We’ll see.
Of course changing such fundamentals as how variables are [re]allocated will break all the unit tests. This is the fate of those who choose to write them, and I’ll just have to fix them when I’m done. In the meantime don’t freak out if all the unit tests fail, but please do let me know if some real functionality gets broken.
P.S. have you noticed how the cubes have been skewed while spinning since about 2 weeks ago? I fixed that, and don’t even know how 