Does Oimo.js 'friction' work correctly?

Hi Babylon team.

I am attempting to use Oimo.js in a non-Babylon project. I became aware of Oimo.js because of its inclusion in Babylon.js.

In my project, I have noticed that ‘friction’ doesn’t really behave as you would expect, and it seems to maybe not work at all. This has been reported by other users to the Oimo.js repo:


In these examples, they are talking about Sphere and plane collision which I understand a sphere may not respect friction. However, in my examples, I am doing Box-Plane collisions.

I have discussed with the maintainer of Oimo.js and they suggest it could be a bug and broken:

There are no tests on Oimo.js to prove or disprove its correctness. The examples don’t use any friction. Additionally, there is barely any documentation to demonstrate how to use it.

I’m opening this topic thread because I’m wondering if there are any Oimo-Babylon examples that actually use friction so I can confirm if it works or not. I highly respect Babylon and assuming that the inclusion of Oimo.js was because its legit.

Hi kevzettler, welcome to the new forum.

https://www.babylonjs-playground.com/#15AFCG#38

There ya go. Arrow keys apply impulses to the player-box.

Looks like it is working, here. Line 19 shows we’re using Oimo.

Line 26… I have a myfriction variable set… used for both ground and player box physics impostors.

Set it to 0.1… we get “slippery”. Set it to 5.0, and the ground/box become fly-paper-grade sticky, and then box only tumbles, never slides.

Down at the bottom, I’m dumping some values to console. Everything looks good… EXCEPT that mass = 64; Line 50 dictates that the mass should be 1. hmm.

Also, I didn’t expect the mass property to be located upon a different object than friction and restitution. Mass is on the physicsBody, and friction/restitution is on the SHAPE object. hmm.

I’ve seen some similar over-mass values with another Oimo issue that we’re working-on:

https://playground.babylonjs.com/indexStable.html#5W5B6W#50

Big playground, sorry. Line 1564 dictates that the mass on the pretty-colored “wheel”… should be 10.

Line 1583 reports that the wheel has a mass of 5235+. Not looking healthy, in that respect.

And as you can see, our Oimo setMotor for Oimo joints… is not working good when maxForce is set low. We are currently working that issue… or at least I am. You can change line 1590 maxForce value from 13541… to 13542, and the joint starts rolling just fine. Go fig. It has been seen long ago, rotating fine with a value of 6.

Got questions? Just holler. But no questions about why mass is wrong or why our setMotor is broken. We (I) don’t know the answers to those questions, yet. :slight_smile: Stay in touch, and please tell us things you learn. We’ll do the same.

IMPORTANT EXTRA: Remember to avoid using rolling spheres for friction testing, because they don’t have enough surface contact with ground… to show friction effects/affects. For slowing-the-roll of spheres, we use either Oimo-provided damping features, or we constantly multiply the sphere’s physicsBody angular or linear velocity * 0.98… which burns-off a little speed each frame/physics-step.

PG - lines 72-74… show some slight linearDamping. I think either linearDamping OR angularDamping will work for slowing the spheres. All in all, spheres are not a good place to test for friction. Billiard balls roll across sandpaper… with hardly a notice. :slight_smile:

1 Like

Thanks for the thorough response @Wingnut. Another Question. Is Babylon.js using the latest version of Oimo.js? Looks like there might be some minified oimoi.js code commited to the repo?

Just wondering if there is a regression in later versions Oimo

:slight_smile: Sorry for the slow replies, KZ. I’m scared to answer that question. heh. I was hoping someone who was in-the-know… would jump-in and give us ALL… an informed reply.

Have you read the “Frozen Motor” thread? link

I’m an emotional mess over there… wondering about the answer to your same question. Personally, I don’t know what we’re running from moment to moment. Sorry. @trevordev, @RaananW, @Deltakosh, @JohnK, we’ll ping 'em all… see if anyone has version info.

I don’t think we ran a minified version of Oimo… until about 10 days ago. Our REVISION number is 1.0.9, I think… but yeah, it could easily be a slightly-modified version of 1.0.9… before the minify.

I’m scared. I could easily say wrong things, here. Let’s listen for more-informed folk. :slight_smile:

You can test out a limited use of friction at Use Forces - Babylon.js Documentation in the playground in that section switch to Oimo (lines 37 to 39) and try different friction values (both non zero) and contact points and direct the impulse along x axis see if the box reacts as you want it to.

Not absolutely sure. I am assuming it is the minified version from the Oimo repo Oimo.js/build at gh-pages · lo-th/Oimo.js · GitHub but have not compared the two files.

1 Like

Ok guys I think false alarm from me. I have Oimo behaving better now that I added some debugging tools to render the actual rigid bodies.

Still, looking around the Omio codebase seeing things commented out and debugging code left in, and that ‘Frozen Motor’ thread Wingnut linked give further reasons to be suspicious…

1 Like

Babylon is definitely using the latest Oimo as I pushed it on their repo at the same time as ours :slight_smile:

Side note, you should update to the latest of oimo from the dist/preview release/ folder of babylon as there were some naughty issues with uglify js I fixed today by switching to terser.