schteppe / p2.js

JavaScript 2D physics library
Other
2.63k stars 330 forks source link

Shape position changed when added to a body #356

Open dooxe opened 4 years ago

dooxe commented 4 years ago

Hello,

I have a problem positionning a shape in a body. My code is pretty simple:

var body = new p2.Body({
    mass: 0
});
var box = new p2.Box({
    position: [50, 50],
    width: 50,
    height: 50
});
console.log(box.position);
body.addShape(box);
console.log(body.shapes[0].position);

(avalable in this codepen: https://codepen.io/dooxe-the-reactor/pen/WNQwVQE )

The first console.log display well the position of the shape: [50, 50], But the second log display [0 , 0].

Is that an intended behavior ? If so could you explain me how to position shape in a body ?

Thanks a lot