Optimizing 3D Collision Code

Im currently in the process of implementing collision and response into CopperLicht, the JavaScript 3D engine I recently released. It already works and you are able to walk around in a Quake 3 level in realtime, and it is also already possible to walk up and down stairs:

copperlicht collision test


The problem is that collision is quite a quite CPU-intensive task. Systems today don't have any problems calculating collisions against thousands of polygons per frame, but doing this in JavaScript is a more difficult task: JavaScript is incredibly slow.
I've used several tricks already (like you can see a bit on the lower left of the screenshot, CopperLicht automaticly created an OctTree for collision as it reports with the gray text) and it works very nice already in Chrome, which has an extremely fast JavaScript VM. But in FireFox, this is still not very usable, dropping down to about 5-10 frames per second.
But let's see, there is still room for improvement.

seven comments, already:

Using Firefox 3.6, your “not using a WebGL enabled Browser” message looks a little off: http://img682.imageshack.us/img682/2307/..
Marcus () (link) - 12 03 10 - 16:00

I know, going to make that box a bit bigger soon, thanks.
niko - 12 03 10 - 16:36

Just for interest’s sake, which Virtual Machine, Actionscript or Javascript, appears to be running faster processor wise?
Parallax - 12 03 10 - 16:37

I didn’t make any tests, but from my feeling JavaScript in the latest Chrome is as fast as ActionScript 3 in Flash. But flash still is faster than JavaScript in the other browsers. (Didn’t try opera, since it doesn’t do WebGL, but I guess Opera would be faster as well)
niko - 12 03 10 - 16:50

Cudos! I like that you’re always up to new stuff…I wouldn’t have even thought of doing 3d GFX + collision with JavaScript ;)
giggsy (link) - 12 03 10 - 19:22

how will you do sound effects? isn’t javascript also very limited in this regard?
horace - 12 03 10 - 23:30

you can do sound using HTML 5 audio. Tried it, works. Going to blog about it probably.
niko - 13 03 10 - 07:15


Name:  
Remember personal info?
yes
no
Email (optional):
URL (optional):
Enter "layered" (antispam):
Comment:Emoticons / Textile

  ( Register your username / Log in )

Notify: Yes, send me email when someone replies.  

Small print: All html tags except <b> and <i> will be removed from your comment. You can make links by just typing the url or mail-address.
Note: If you type in your email adress above, it will be visible to other visitors, although it will be hidden for bots using javaScript.