0
0
Fork 0
mirror of https://github.com/liabru/matter-js.git synced 2024-11-23 09:26:51 -05:00

fixed various constraints in examples

This commit is contained in:
liabru 2017-06-28 00:21:17 +01:00
parent 837c43bdb5
commit ac67ef8e5c
3 changed files with 13 additions and 17 deletions

View file

@ -43,7 +43,7 @@ Example.chains = function() {
return Bodies.rectangle(x, y, 50, 20, { collisionFilter: { group: group } });
});
Composites.chain(ropeA, 0.5, 0, -0.5, 0, { stiffness: 0.8, length: 2 });
Composites.chain(ropeA, 0.5, 0, -0.5, 0, { stiffness: 0.8, length: 2, render: { type: 'line' } });
Composite.add(ropeA, Constraint.create({
bodyB: ropeA.bodies[0],
pointB: { x: -25, y: 0 },
@ -57,7 +57,7 @@ Example.chains = function() {
return Bodies.circle(x, y, 20, { collisionFilter: { group: group } });
});
Composites.chain(ropeB, 0.5, 0, -0.5, 0, { stiffness: 0.8, length: 2 });
Composites.chain(ropeB, 0.5, 0, -0.5, 0, { stiffness: 0.8, length: 2, render: { type: 'line' } });
Composite.add(ropeB, Constraint.create({
bodyB: ropeB.bodies[0],
pointB: { x: -20, y: 0 },

View file

@ -42,7 +42,7 @@ Example.doublePendulum = function() {
length = 200,
width = 25;
var pendulum = Composites.stack(350, 160, 2, 1, 0, 0, function(x, y) {
var pendulum = Composites.stack(350, 160, 2, 1, -20, 0, function(x, y) {
return Bodies.rectangle(x, y, length, width, {
collisionFilter: { group: group },
frictionAir: 0,
@ -56,24 +56,26 @@ Example.doublePendulum = function() {
pendulum.bodies[0].render.strokeStyle = '#4a485b';
pendulum.bodies[1].render.strokeStyle = '#4a485b';
world.gravity.scale = 0.002;
Composites.chain(pendulum, 0.5, 0, -0.5, 0, {
Composites.chain(pendulum, 0.45, 0, -0.45, 0, {
stiffness: 1,
length: 0,
angularStiffness: 0.7,
render: {
lineWidth: 0
strokeStyle: '#4a485b'
}
});
Composite.add(pendulum, Constraint.create({
bodyB: pendulum.bodies[0],
pointB: { x: -length * 0.5, y: 0 },
pointA: { x: pendulum.bodies[0].position.x - length * 0.5, y: pendulum.bodies[0].position.y },
pointB: { x: -length * 0.42, y: 0 },
pointA: { x: pendulum.bodies[0].position.x - length * 0.42, y: pendulum.bodies[0].position.y },
stiffness: 1,
length: 0,
render: {
lineWidth: 0
strokeStyle: '#4a485b'
}
}));

View file

@ -274,10 +274,7 @@ var Bodies = require('./Bodies');
pointB: { x: wheelAOffset, y: wheelYOffset },
bodyA: wheelA,
stiffness: 1,
length: 0,
render: {
lineWidth: 0
}
length: 0
});
var axelB = Constraint.create({
@ -285,10 +282,7 @@ var Bodies = require('./Bodies');
pointB: { x: wheelBOffset, y: wheelYOffset },
bodyA: wheelB,
stiffness: 1,
length: 0,
render: {
lineWidth: 0
}
length: 0
});
Composite.addBody(car, body);
@ -317,7 +311,7 @@ var Bodies = require('./Bodies');
*/
Composites.softBody = function(xx, yy, columns, rows, columnGap, rowGap, crossBrace, particleRadius, particleOptions, constraintOptions) {
particleOptions = Common.extend({ inertia: Infinity }, particleOptions);
constraintOptions = Common.extend({ stiffness: 0.2 }, constraintOptions);
constraintOptions = Common.extend({ stiffness: 0.2, render: { type: 'line', anchors: false } }, constraintOptions);
var softBody = Composites.stack(xx, yy, columns, rows, columnGap, rowGap, function(x, y) {
return Bodies.circle(x, y, particleRadius, particleOptions);