lo-th / Oimo.js

Lightweight 3d physics engine for javascript
http://lo-th.github.io/Oimo.js
MIT License
3.05k stars 301 forks source link

Does Oimo.js has Fixed Joints, Collision Events or Collision Flag? #71

Open jefersonla opened 6 years ago

jefersonla commented 6 years ago

Hi, first of all, Oimo.js is awesome, and if I can, I really wanna help you in release the documentation as soon as possible!

I'm developing a Quadruped Robot, and because I'm a Computer Science student, I'm really interested in make a reallystic physic model of this, to develop an AI which will learn how to walk.

The quadruped robot that i'm developing is a fork of the Q1 which is available at Thingiverse (https://www.thingiverse.com/thing:2311678), the second objective of this project is the proccess of animate the movements of this robot since this proccess is very complex and non intuitive, so as this gonna be an smartphone app in Cordova or Ionic, my application (https://jefersonla.github.io/THREE.js-Experiments/) need to be suitable for smartphones, and Oimo.js is is the best choice.

My doubt is, is it possible to define a Fixed Joint like this (https://youtu.be/7jwqXgdBM_g?t=2m10s)? And if it's not possible, is there any event or flag which inform if a collision is occuring? Since I can disable the movement of a mesh if a body has a flag marking a collision. If there are no flag or event, can I make groups of bodies like THREE.Group? which is an empty object3d that we can put other objects inside.

Thanks, for the good work and I'll send you a message.

Cobertos commented 6 years ago

It does have collision events, see this example. You have to use world.getContact( b1, b2 ); where b1 and b2 are two bodies.

Collision flags are also a thing, though I haven't used them yet. RigidBodies have a belongsTo and a collidesWith property which are bitmasks of the collision group. See this documentation for a little more information. I took the following out of the built library:

            //From ShapeConfig
            // bits of the collision groups to which the shape belongs.
        this.belongsTo = 1;
        // bits of the collision groups with which the shape collides.
        this.collidesWith = 0xffffffff;

Fixed joints (I've also heard them called welds), seem to be supported? I've also not used this, but check out the joint documentation. There seems to be a jointdistance which I think is what you're looking for.