Optimizing 3D Collision Code

Posted on:March 12 2010

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:


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.





Comments:


Using Firefox 3.6, your "not using a WebGL enabled Browser" message looks a little off: http://img682.imageshack.us/img682/2307/ff36off.png
Marcus
Quote
2010-03-12 16:00:00


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


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


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
Quote
2010-03-12 16:50:00


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
Quote
2010-03-12 19:22:00


how will you do sound effects? isn't javascript also very limited in this regard?
horace
Quote
2010-03-12 23:30:00


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


Add comment:


Posted by:


Enter the missing letter in: "Internatio?al"


Text:

 

  

Possible Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons