max123 Posted October 12, 2017 Share Posted October 12, 2017 So, which one to choose? Which one is more performant? Which one has most features? Which one is better documented? Quote Link to comment Share on other sites More sharing options...
BitOfGold Posted October 12, 2017 Share Posted October 12, 2017 In short: every javascript 3D physics engine lacks something important. Or not performant, or both. I'm using Cannon js now (not using babylon's physics plugins because I need physics bodies on sprites, continous collision detection, trigger objects, collision events, separate fixed-time game logic/physics step and a lot more) Even Cannon DOES not have a good capsule collider. I think it is not the best performance, but every other lacks something i need (Oimo is faster, but has no heightmaps, no collision events, no trigger objects etc) Cannon is easy to use, hard to master (to provide a stabile and smooth simulation without hiccups, vibrations or jumps, it needs many tweaking) I think I see where Cannon js's bottleneck is: it has a single axis broadphase separation, but no working grid or octree based broadphase. And it is written in a non-performant object oriented "textbook" way. Maybe Energy js will be more performant (transpiled from C++), but from the documentation It maybe will miss important elements in a game like collision events and trigger (collision only) bodies. Maybe someone has other engine suggestions!? max123 1 Quote Link to comment Share on other sites More sharing options...
BitOfGold Posted October 12, 2017 Share Posted October 12, 2017 Just one more thing: there is also ammo.js, which is the javascript port of Bullet. It has everything - but the APi is so horrible. Maybe it is the best choice.https://github.com/kripken/ammo.js/ Quote Link to comment Share on other sites More sharing options...
brianzinn Posted October 12, 2017 Share Posted October 12, 2017 I am using cannon as well. I started out using both interchangeably and was always having trouble with Oimo not working as I would expect. I am very happy with cannon and looking forward adding the new physics lockstep integration where I can ensure the deterministic behaviour across different devices. Here is the post by santarcade: max123 1 Quote Link to comment Share on other sites More sharing options...
gregmax17 Posted October 12, 2017 Share Posted October 12, 2017 There is CannonJS, Oimo, AmmoJS, and Goblin Physics, to name a few. And like BitOfGold said, each one has their own unique pros and cons. Oimo performs the best, but there are no event callbacks and proper documentation (just examples). Goblin Physics doesn't have callbacks either. AmmoJS is suppose to be the best, and its what PlayCanvas uses - but its documentation is horrible. Maybe you can use the PlayCanvas engine on GitHub and work with that? I really want Oimo to have more, its runs so smooth. CannonJS is what I ended using as well. Its not the best performance, but it has something I need: documentation and event callbacks. It was a hassle setting up callbacks to get the desired results, some ugly collision mask filtering, but it does the job. Just make sure you download the files from GitHub and build locally, don't just grab the latest build files on the GitHub page - they are out of date. There isn't much else for 3d physic engines. max123 1 Quote Link to comment Share on other sites More sharing options...
Samuel Girardin Posted October 13, 2017 Share Posted October 13, 2017 @BitOfGold Hi, sometimes my english is bad, could you be more precise and explain me this : 'It maybe will miss important elements in a game like collision events and trigger (collision only) bodies' . Are you talking about object callback when collision occurs ? thx sam Quote Link to comment Share on other sites More sharing options...
BitOfGold Posted October 13, 2017 Share Posted October 13, 2017 @Samuel Girardin Hi! Yes, I need to have a collision callback when a body collides with another body. Cannon has this event registration like this: physicsBody.addEventListener("collide", function (ev) { var otherBody = ev.body; ... } And i also need objects that register this collision event, but do not modify any physics parameter. (I think they call it trigger objects in other game engines) Cannon has the .collisionResponse = 0; for this. I said "It maybe will miss important elements" because I do not know yet, I'm looking forward and excited to see it! I'm waiting to use Energy js, and if it has everything I need, and it is more performant than cannon (I'm sure it will be more faster!) I will try re-working my engine. I searched ODE documentation for callback, but only found this: void dBodySetMovedCallback (dBodyID, void (*callback)(dBodyID)); Quote Link to comment Share on other sites More sharing options...
max123 Posted October 13, 2017 Author Share Posted October 13, 2017 Hey lads, thanks for the input! Energy.js (http://www.visualiser.fr/page.php?id=Energy.js) looked promising, but it seems the project is in limbo.. I suppose I'll have to go with Cannon or Ammo. What bothers me in most demos I've seen so far is that it appears the engines have hard time settling objects (finding rest position), e.g. if you have a bunch of stacked boxes, they keep trembling and shaking indefinitely without coming to rest. I used physics engine in Softimage XSI - what a joy it was!! Ah well... Quote Link to comment Share on other sites More sharing options...
BitOfGold Posted October 13, 2017 Share Posted October 13, 2017 This is how I set up Cannon (low restitution and more solver iterations lower the vibrations that you mentioned): Theese are kind of optimal settings for Cannon.js (copied from here and there) Maybe this helps someone. this.world = new CANNON.World(); this.world.defaultContactMaterial.contactEquationStiffness = 1e6; this.world.defaultContactMaterial.contactEquationRegularizationTime = 3; this.world.solver.iterations = 20; this.world.gravity.set(this.gravity.x, this.gravity.y, this.gravity.z); this.world.allowSleep = true; this.world.broadphase = new CANNON.SAPBroadphase(this.world); On bodies, I set: body.allowSleep = true; body.sleepSpeedLimit = 0.01; body.sleepTimeLimit = 1.0; On the material: mass: 100 (or about the mass of the object in kilograms) friction: 0.1 restitution: 0.3 max123 1 Quote Link to comment Share on other sites More sharing options...
max123 Posted October 13, 2017 Author Share Posted October 13, 2017 That's a nice summary, @BitOfGold Quote Link to comment Share on other sites More sharing options...
jerome Posted October 13, 2017 Share Posted October 13, 2017 not really in limbo : Samuel Girardin and BitOfGold 2 Quote Link to comment Share on other sites More sharing options...
max123 Posted October 13, 2017 Author Share Posted October 13, 2017 Yes, as I said, energy-js looks very promising, but I personally would wait till it gets some traction: currently, the port is developed by just one(?) person, which is kinda risky for production use Quote Link to comment Share on other sites More sharing options...
Raggar Posted October 13, 2017 Share Posted October 13, 2017 I'm looking forward to trying out EnergyJS as well. For the time being, I'm using CannonJS. OimoJS certainly has better performance, but lacks in features. I originally chose CannonJS due to the heightfields, as I wasn't quite satisfied with the way OimoJS handles that. The collisionResponse feature is another thing I think is important in a physics engine, as it allows easy implementation of waypoints, pickups etc. Another way of doing these might be possible, but with CannonJS, you simply won't have to implement other means of doing so. Another reason is, that CannonJS runs well on NodeJS, with only minor issues having to do with heightfields. max123 1 Quote Link to comment Share on other sites More sharing options...
RaananW Posted October 16, 2017 Share Posted October 16, 2017 My 2 cents - I like cannon better than Oimo. Mainly due to features, but I also think that the calculations are more realistic (well, this is subjective, i guess) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.