Comments (4)
If I change yPivotOffset
of the first body from 0 to -1, then it also exhibits erratic behaviour sometimes, but not quite as easily.
It certainly seems that there is something wrong whenever the pivot is anywhere other than the centre of mass.
from matter-js.
I have found a solution: https://incoherency.co.uk/matterjs-test-case/fixed.html
I needed to leave the two balls as separate bodies and constrain their locations with constraints, instead of trying to turn them into oen body.
It seems like this is a bug in compound bodies, since to my mind the two methods should give the same outcome.
from matter-js.
I seem to be running into this bug as well:
https://jsfiddle.net/Oli414/2gapbwoq/
@jes did you notice a performance difference with your solution compared to using a compound? I'd expect there to be some extra overhead. I'm a bit concerned about using your solution at a larger scale.
from matter-js.
I've been trying to dig a bit deeper, I might have found the underlying issue. But for now the best I've got is a better temporary solution.
First of all some discoveries regarding this bug:
-
It works at certain scales, this smaller example doesn't seem to have any issues:
https://jsfiddle.net/Oli414/q5p0hzfg/ -
It works if the compound only consists of 1 part:
https://jsfiddle.net/Oli414/4a7ywgmf/
With that in mind I ended up cloning the repo to see if I could figure out what was going on, focusing on a single iteration of the constraint solver. I found that there was a discrepancy in the inertia value between single-part bodies and multi-part bodies.
A compound consisting of 3 squares (3 times 64x64, forming a 192x64 rectangle) has an inertia of 33554.432 as opposed to a single rectangle having an inertia of 167772.16 (1 time 192x64), 5 times that of the 3 separate squares.
You can manually set the compound's inertia to the correct value and the constraint starts to behave identically to a constraint with a non-compound body.
https://jsfiddle.net/Oli414/dw8zf3yn/
I'm don't know enough about the inner workings of this physics engine to make a bugfix, but something seems off about the way the inertia is calculated for compound bodies.
from matter-js.
Related Issues (20)
- Why when i using poly-decomp - Bodies.fromVertices return undefined? HOT 1
- How can set predefine path ? HOT 1
- Had a Fatal Error, reason unknown: vertexA is undefined HOT 4
- Objects are not repelled when restitution: 1, friction, frictionAir and frictionStatic is 0
- rendering composite bodies HOT 2
- Mass/density has no effect on fall speed HOT 2
- Explode!
- Calculate velocity to jump to the target HOT 2
- Slingshot example with Keys and Constraint, instead of MouseConstraint and Mouse
- Render canvas object HOT 5
- Energy loss, despite air friction 0 HOT 1
- Rigid connection between two bodies
- the bodies do not collide and do not stop, but tremble
- Nothing showing in the matter.js canvas HOT 1
- `Body.create` ignores given velocity
- `Body.create` ignores `anglePrev`, `area`, `mass` and `inertia` when they are 0.
- Platformer character sticking to walls instead of sliding down HOT 5
- convert text to matter component like a bridge but Uncaught TypeError: Cannot read properties of undefined (reading 'max')
- support and documentation for vitejs please :( HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from matter-js.