Replies: 2 comments
-
Hey, I think there might be something wrong in the render logic. I tried to recreate your example using the testbed: <!-- index.html -->
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" type="text/css" href="style.css">
<meta charset="utf-8" />
</head>
<body>
<script src="https://cdn.jsdelivr.net/npm/planck-js@0.3.27/dist/planck-with-testbed.js"></script>
<script src="b2.js"></script>
<script src="sketch.js"></script>
</body>
</html> // sketch.js
//fixed no-collision problem, but why do shapes overlap?
function setup() {
// createCanvas(400, 300);
world = b2newWorld(30, b2V(0, 10));
new b2Body('polygon', true, b2V(200, 200), [b2V(20, 0), b2V(-20, 0), b2V(0, 30)]);
var b = new b2Body('circle', true, b2V(200, 100), b2V(20, 20));
b.addTo('box', b2V(0, 15), b2V(20, 10));
//var c=new b2Body('edge', false, b2V(width/2, height-4), [b2V(-width/2, 0), b2V(width/2, 0)]);
new b2Body('box', false, b2V(400/2, 300-4), b2V(400, 50),10,0.5,0.2,0);
new b2Body('polygon', true, b2V(30, 100), [b2V(20, 0), b2V(-20, 0), b2V(0, 30)]); b2world.step(1 / 60);
return world
}
planck.testbed(testbed => {
return setup()
}) The Bodys seem to collide correctly here. Maybe p5.js takes other origins for the shapes as box2d? |
Beta Was this translation helpful? Give feedback.
0 replies
-
Oh, I think I found the problem: You just have to fix the rotation of the bodies (the rotation does not get rendered)
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I recently found your box2d js port, which is the only one that tracks box2d.
I am converting my p5 easy-to-use-box2d library to planck.
My start is online here
https://editor.p5js.org/Bobcook47/sketches/uCG516KAe
The problem is that my dynamic objects pass though the edge.
for simplicity, i create all edges as chains
even when i use the edge code directly from the planck example, there is still pass through
any help will be appreciated
Beta Was this translation helpful? Give feedback.
All reactions