liabru / matter-js

a 2D rigid body physics engine for the web ▲● ■
MIT License
16.71k stars 1.96k forks source link

Force Fields, Infinite Planes and Real circles #511

Open FoxSamu opened 6 years ago

FoxSamu commented 6 years ago

Is there a way to implement force fields. I visited many physics engines, but neither of them have force fields. If this one has that feature, you are one of the first. I'm programming a physics engine right now, and that is going to support force fields too.

I have a set of force fields I wanted to use:

I have also a set of force fields that can be applied to bodies:

Another thing I see in most physics engines, is an infinite plane shape. This is an infinite plane: schermafbeelding 2017-10-19 om 17 28 13 kopie

And at last, I noticed circles are just Regular Polygons with many edges, not just circles ( I just haven't checked this in v0.13.0 ). Your implementation works nicely, but circles are just better:

This is only a feature idea, and I appreciate answers with ways to implement this ideas with the current MatterJS version too.

P.S. An infinite plane is NOT implemented with a big rectangle!

liabru commented 6 years ago

Is there a way to implement force fields.

Check out matter-attractors which I think actually does some of the things you need. Much of your other ideas can be implemented through custom attractor functions.

Another thing I see in most physics engines, is an infinite plane shape

Would be a pretty nice addition, will try it out.

And at last, I noticed circles are just Regular Polygons with many edges, not just circles ( I just haven't checked this in v0.13.0 ). Your implementation works nicely, but circles are just better

Actually I do have an implementation of this that I really should finish up!

FoxSamu commented 6 years ago

Nice to know that you have an implementation of circles. I looked at matter-attractors, it seems really nice, but does not exactly what I was looking for, except newtonian gravity. But as I saw matter-attractors is a plugin, I think I can write a "matter-forcefields" too. Maybe a thing to try for me.

Qriva commented 6 years ago

@liabru I got one question about real circles, can you tell us when we can expect new implementation? Can you more or less estimate it will be 1 month or 3 months or more?