Giter VIP home page Giter VIP logo

Comments (3)

lo-th avatar lo-th commented on July 4, 2024

hi thank's, no there is no event, i have to look best way to do that.
but ShapeConfig have a extra function i don't explaine: the collision filtering.
var sc = new OIMO.ShapeConfig();
var group1 = 1 << 0;
var group3 = 1 << 2;
var all = 0xffffffff;

sc.belongsTo = group1;
sc.collidesWith = all & group3;
i have to make demo on that

from oimo.js.

Canta avatar Canta commented on July 4, 2024

Oh... i will have to take a look at collidesWith then, thank you. Didn't saw it before.

For the record, while asking here, i was making a slightly modified Oimo.js version implementing some degree of a EventEmmiter pattern. I don't plan to publish that, it's just for my own use. But the strategy is simple: in World's constructor, after World instances CollisionDetectors, i set a reference to the world instance inside every detector instance, by using a simple loop. Then, in the detector code, when there's a collision, i add a call to one of the world reference's (also added by me) method: the "emit()" function.
So, calling world.emit("collision", pair) would trigger any event handler attached to the world for the "collision" event, and would take the pair of objects as parameter. And then it's just an application problem to properly set those event handlers as necessary.

It's kinda trivial to implement events that way, i just need to take the time to read and understand Oimo to know where to put the "emit" call and what to pass as parameter.

There are a few NPM packages for nodejs that gives a ready to use EventEmmiter class, in case you would like to take a look at it:
https://www.npmjs.org/package/event-emitter
https://www.npmjs.org/package/tiny-eventemitter
etc.

Cheers.

from oimo.js.

lo-th avatar lo-th commented on July 4, 2024

great i add new function to world you can see in test_moving.html

you can assign name to rigidBody and test if two name is on collision or not
world.checkContact('paddle', 'sphere') return true or false

only on dev version

from oimo.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.