Driving Demo using Ammo.js

Link to the Driving Demo:
http://moygen.rf.gd/world/world.htm

This driving demo uses Ammo.js,
https://github.com/kripken/ammo.js/
Alon Zakai’s port of bullet physics to javascript via Emscripten
https://github.com/kripken/emscripten

6 vehicles drive around a simple world, from point to point. A dat.gui
interface allows adjustment of the raycast vehicle parameters. The user can also drive around.

Screenshot:

25 Likes

This is FANTASTIC! EXCELLENT job! :slight_smile: I think if you add slope angle collision, it would bring a totally new dimension to the game!

Keep up the EXCELLENT work! <3

1 Like

I’m also working on a similar game project using threejs. I must say you have achieved a really good performance result.

If you can improve the terrain realism and slopes, it will be a great boost for you demo.

I agree with @Atul_Mourya! :slight_smile:

Do you mean a world model with slopes? If so, yes, slopes would make driving easier, but also require more vertices, which would lower fps. I will test out some slopey models anyway. Thank you for the feedback.

I am seeing fps hovering in the mid to high 50s with sometimes a solid 60, but I can only get those numbers with lower poly models. I will experiment with some sloping terrains anyway. Thanks for the feedback.

Perhaps you can use heightMaps and generate terrain from it. As from my experience, you may need to keep the terrain resolution (length and width) low in order to keep the polycounts lower.

Further, you can also try to create low poly trees and populate it on the terrain using instance geometry.
You can also use DecalGeometry to create tracks if you need to.

Thanks for the pointers. I have research to do. I am particularly interested in geometry instancing, since I am loading a grid of 9 world models, and usually drawing more than one per tick.

This is FANTASTIC! EXCELLENT job! :slight_smile: I think if you add slope angle collision, it would bring a totally new dimension to the game! Keep up the EXCELLENT work! <3

This is a lot of fun already, the mechanic is really good !

I’m not shocked by the low-poly terrain, people don’t care that a game doesn’t look realistic as long as it is fun. Maybe you should avoid flat surfaces, like on the top of the slopes and the floor of the valleys, and that’s it. The low-poly make the thing hard and a little bit surprising, which is good I think. Some obstacles could add something however, or maybe some ramps or boost tiles or dangerous things to attempt shortcuts.

But the ground’s texture is horrible… I’d rather have a plastic-looking texture without normal map than this., sorry :sweat_smile:

great job !

Thanks for your honest impression. I do not know why I love that wood texture, especially with the shininess on the bump map of it. It is almost my favorite part. Maybe it has grown on me. I do not think I will do much more with this little demo. The code is not such as to be built upon. But if I found a way to keep fps at 60 all the time, I would just rewrite it and keep building.

I just love it.
Thank you for this demo.

I realy love your game :slight_smile: Amazing

So fun! Nice job!

how did you optimize memory allocation with ammo.js, i have been trying to build some sort of a terrain simulation but it keeps running out of memory and crashing :pensive:

With Ammo, you need to handle garbage collection yourself. Variables you create with ‘new’, such as:
var downRayDir=new Ammo.btVector3(0,0,0);
are not removed automatically by javascript. You need to say:
Ammo.destroy(downRayDir);
as soon as you no longer need the variable.
I also say:
downRayDir=null;
but I lazily never bothered to find out if that is necessary.
I also reuse an Ammo.btVector3 variable in some cases, instead of creating new ones all the time.
You can use Chrome’s task manager to check your memory usage, and make sure it is not growing.
I was also using the Memory tab in Chrome’s Developer Tools, but it has been a while and I do not recall how I was using that.
I hope I am steering you correctly. I am only a tinkerer. Please chime in anybody who knows better.

3 Likes

I have been playing for ever and i LOVE how you can edit them and make them “fly” among other things. but you NEED to add a bus and maybe a APC that would be cool. :grin: