ammo.js performance in Google Chrome

1.5k views Asked by At

A friend and I are developing a game using WebGL and after looking for some physics engines I discovered ammo.js which is a port or the bullet physics library. We implemented a simple example and quickly discovered that the framerate on google Chrome is horrible compared to Firefox or Safari. I'm talking chrome gets 10 FPS where firefox gets to quite constant 60 FPS.

After researching a lot I discovered this blog expliaining exactly what problem has Chrome with the library. (tl;dr: ammo.js uses dictionary objects which chrome discourages)

So my questions are: Is there a port of this library without using dictionaries? If not, is it worth it (or even feasible) to modify the original C++ bullet code and re-port it? If none of the previous options are possible what physics engine in javascript would you recommend?

I know the choices are pretty limited here but I think it's worth the question.

Thanks.

1

There are 1 answers

0
schteppe On BEST ANSWER

I doubt it is possible to port the code to JavaScript and not using objects, when the original C++ code is object oriented.

If you want to "modify" the Bullet code before porting, I believe that you would have to rewrite it so it uses something that has an advantage in JavaScript: typed arrays. I guess you would have to rewrite most of the code to get it that way. And in that case, it would be more convenient to write the JavaScript directly.

I don't have any good recommendations for you beside ammo.js. However, cannon.js is a newly started project that may satisfy your needs when its code gets stable. Perhaps you would like to contribute to it?

Another way to go may be FireBreath. It is a browser plugin development framework. It can help you make native JavaScript functions. If Bullet is compiled into such plugin, and bindings are made to the JavaScript, then you have your C++ physics engine ready to use in JavaScript. Of course, the end user will have to download the plugin first.