Skip to content

Commit

Permalink
started using world.addBody instead of the deprecated world.add
Browse files Browse the repository at this point in the history
  • Loading branch information
schteppe committed Apr 24, 2015
1 parent 7da9c64 commit 6e0d352
Show file tree
Hide file tree
Showing 44 changed files with 221 additions and 221 deletions.
6 changes: 3 additions & 3 deletions demos/bodyTypes.html
Expand Up @@ -40,7 +40,7 @@
position: new CANNON.Vec3(0, 0, 0.5*size)
});
b1.addShape(boxShape);
world.add(b1);
world.addBody(b1);
demo.addVisual(b1);

// To control the box movement we must set its velocity
Expand All @@ -59,7 +59,7 @@
});
b2.addShape(sphereShape);
b2.position.set(0,0,3*size);
world.add(b2);
world.addBody(b2);
demo.addVisual(b2);
});

Expand All @@ -82,7 +82,7 @@
mass: mass,
});
groundBody.addShape(groundShape);
world.add(groundBody);
world.addBody(groundBody);
demo.addVisual(groundBody);

return world;
Expand Down
8 changes: 4 additions & 4 deletions demos/bounce.html
Expand Up @@ -33,7 +33,7 @@
var groundShape = new CANNON.Plane();
var groundBody = new CANNON.Body({ mass: 0, material: groundMaterial });
groundBody.addShape(groundShape);
world.add(groundBody);
world.addBody(groundBody);
demo.addVisual(groundBody);

var mass = 10;
Expand All @@ -45,23 +45,23 @@
shapeBody1.addShape(sphereShape);
shapeBody1.position.set(3*size, size, height);
shapeBody1.linearDamping = damping;
world.add(shapeBody1);
world.addBody(shapeBody1);
demo.addVisual(shapeBody1);

var mat2 = new CANNON.Material();
var shapeBody2 = new CANNON.Body({ mass: mass, material: mat2 });
shapeBody2.addShape(sphereShape);
shapeBody2.position.set(0 , size , height);
shapeBody2.linearDamping = damping;
world.add(shapeBody2);
world.addBody(shapeBody2);
demo.addVisual(shapeBody2);

var mat3 = new CANNON.Material();
var shapeBody3 = new CANNON.Body({ mass: mass, material: mat3 });
shapeBody3.addShape(sphereShape);
shapeBody3.position.set(-3*size , size , height);
shapeBody3.linearDamping = damping;
world.add(shapeBody3);
world.addBody(shapeBody3);
demo.addVisual(shapeBody3);

// Create contact material behaviour
Expand Down
4 changes: 2 additions & 2 deletions demos/bunny.html
Expand Up @@ -66,15 +66,15 @@
var z180 = new CANNON.Quaternion();
z180.setFromAxisAngle(new CANNON.Vec3(0,0,1),Math.PI);
bunnyBody.quaternion = z180.mult(bunnyBody.quaternion);
world.add(bunnyBody);
world.addBody(bunnyBody);
demo.addVisual(bunnyBody);

// ground plane
var groundShape = new CANNON.Plane();
var groundBody = new CANNON.Body({ mass: 0 });
groundBody.addShape(groundShape);
groundBody.position.set(0,0,-5);
world.add(groundBody);
world.addBody(groundBody);
demo.addVisual(groundBody);

});
Expand Down
4 changes: 2 additions & 2 deletions demos/callbacks.html
Expand Up @@ -58,8 +58,8 @@
}

// We add the objects to the world to simulate them
world.add(moon);
world.add(planet);
world.addBody(moon);
world.addBody(planet);

// And we add them to the demo to make them visible
demo.addVisual(moon);
Expand Down
6 changes: 3 additions & 3 deletions demos/collisionFilter.html
Expand Up @@ -66,9 +66,9 @@
cylinderBody.collisionFilterMask = GROUP1; // It can only collide with group 1 (the sphere)

// Add everything to the world and demo
world.add(sphereBody);
world.add(boxBody);
world.add(cylinderBody);
world.addBody(sphereBody);
world.addBody(boxBody);
world.addBody(cylinderBody);
demo.addVisual(sphereBody);
demo.addVisual(boxBody);
demo.addVisual(cylinderBody);
Expand Down
16 changes: 8 additions & 8 deletions demos/collisions.html
Expand Up @@ -32,7 +32,7 @@
b1.position.set(5,0,0);
b1.velocity.set(-5,0,0);
b1.linearDamping = 0;
world.add(b1);
world.addBody(b1);
demo.addVisual(b1);

// Sphere 2
Expand All @@ -41,7 +41,7 @@
b2.linearDamping = 0;
b2.position.set(-5,0,0);
b2.velocity.set(5,0,0);
world.add(b2);
world.addBody(b2);
demo.addVisual(b2);
});

Expand All @@ -58,7 +58,7 @@
b1.position.set(5,0,0);
b1.velocity.set(-5,0,0);
b1.linearDamping = 0;
world.add(b1);
world.addBody(b1);
demo.addVisual(b1);

// Sphere
Expand All @@ -67,7 +67,7 @@
b2.position.set(-5,0,0);
b2.velocity.set(5,0,0);
b2.linearDamping = 0;
world.add(b2);
world.addBody(b2);
demo.addVisual(b2);
});

Expand All @@ -86,7 +86,7 @@
var q = new CANNON.Quaternion();
q.setFromAxisAngle(new CANNON.Vec3(0,0,1),Math.PI*0.25);
b1.quaternion.set(q.x,q.y,q.z,q.w);
world.add(b1);
world.addBody(b1);
demo.addVisual(b1);

// Sphere
Expand All @@ -95,7 +95,7 @@
b2.position.set(-5,0,0);
b2.velocity.set(5,0,0);
b2.linearDamping = 0;
world.add(b2);
world.addBody(b2);
demo.addVisual(b2);
});

Expand All @@ -117,7 +117,7 @@
q2.setFromAxisAngle(new CANNON.Vec3(0,1,0),Math.PI*0.25);
var q = q1.mult(q2);
b1.quaternion.set(q.x,q.y,q.z,q.w);
world.add(b1);
world.addBody(b1);
demo.addVisual(b1);

// Sphere
Expand All @@ -126,7 +126,7 @@
b2.position.set(-5,0,0);
b2.velocity.set(5,0,0);
b2.linearDamping = 0;
world.add(b2);
world.addBody(b2);
demo.addVisual(b2);
});

Expand Down
6 changes: 3 additions & 3 deletions demos/compound.html
Expand Up @@ -56,7 +56,7 @@
body.addShape(shape, new CANNON.Vec3( 0, 0,-s));
body.addShape(shape, new CANNON.Vec3( 0, 0, s));

world.add(body);
world.addBody(body);
demo.addVisual(body);

});
Expand All @@ -77,7 +77,7 @@

body.position.set(0,0,6);
body.quaternion.set(0,1,0,0.1);
world.add(body);
world.addBody(body);
demo.addVisual(body);

});
Expand All @@ -92,7 +92,7 @@
var groundShape = new CANNON.Plane();
var groundBody = new CANNON.Body({ mass: 0 });
groundBody.addShape(groundShape);
world.add(groundBody);
world.addBody(groundBody);
demo.addVisual(groundBody);

return world;
Expand Down
24 changes: 12 additions & 12 deletions demos/constraints.html
Expand Up @@ -42,7 +42,7 @@
shape: boxShape,
position: new CANNON.Vec3((N-i-N/2)*(size*2+2*space), 0, size*6+space)
});
world.add(boxbody);
world.addBody(boxbody);
demo.addVisual(boxbody);

if(last){
Expand All @@ -61,15 +61,15 @@
shape: boxShape,
position: new CANNON.Vec3((-N/2+1)*(size*2+2*space), 0, size*3)
});
world.add(bodyA);
world.addBody(bodyA);
demo.addVisual(bodyA);

var bodyB = new CANNON.Body({
mass: 0,
shape: boxShape,
position: new CANNON.Vec3((N/2)*(size*2+2*space), 0, size*3)
});
world.add(bodyB);
world.addBody(bodyB);
demo.addVisual(bodyB);
});

Expand All @@ -90,7 +90,7 @@
boxbody.position.set(0,0,(N-i)*(size*2+2*space) + size*2+space);
boxbody.linearDamping=0.01; // Damping makes the movement slow down with time
boxbody.angularDamping=0.01;
world.add(boxbody);
world.addBody(boxbody);
demo.addVisual(boxbody);

if(i!=0){
Expand Down Expand Up @@ -127,7 +127,7 @@
body.addShape(new CANNON.Particle());
body.position.set((i-Ncols*0.5)*dist,(j-Nrows*0.5)*dist,5);
bodies[i+" "+j] = body;
world.add(body);
world.addBody(body);
demo.addVisual(body);
}
}
Expand All @@ -148,7 +148,7 @@
var body = new CANNON.Body({ mass: 0 });
body.addShape(sphere);
body.position.set(0,0,3.5);
world.add(body);
world.addBody(body);
demo.addVisual(body);
});

Expand All @@ -165,13 +165,13 @@
spherebody.velocity.set(5,0,0);
spherebody.linearDamping=0;
spherebody.angularDamping=0;
world.add(spherebody);
world.addBody(spherebody);
demo.addVisual(spherebody);

var spherebody2 = new CANNON.Body({ mass: 0 });
spherebody2.addShape(sphereShape);
spherebody2.position.set(0,0,size*7);
world.add(spherebody2);
world.addBody(spherebody2);
demo.addVisual(spherebody2);

// Connect this body to the last one
Expand All @@ -196,7 +196,7 @@
spherebody.addShape(sphereShape);
spherebody.position.set(0,0,(N-i)*dist);
spherebody.velocity.x = i;
world.add(spherebody);
world.addBody(spherebody);
demo.addVisual(spherebody);

// Connect this body to the last one added
Expand Down Expand Up @@ -229,7 +229,7 @@
body.position.set(i*dist,0,j*dist+5);
body.velocity.set(0, 3*(Math.sin(i*0.1)+Math.sin(j*0.1)),0);
bodies[i+" "+j] = body;
world.add(body);
world.addBody(body);
demo.addVisual(body);
}
}
Expand Down Expand Up @@ -262,7 +262,7 @@
body.position.set(i*dist,j*dist, k*dist + Nz*dist*0.3+1);
body.velocity.set(0, 30*(Math.sin(i*0.1)+Math.sin(j*0.1)),0);
bodies[i+" "+j+" "+k] = body;
world.add(body);
world.addBody(body);
demo.addVisual(body);
}
}
Expand Down Expand Up @@ -319,7 +319,7 @@
var groundBody = new CANNON.Body({ mass: 0 });
groundBody.addShape(groundShape);
groundBody.position.set(0,0,1);
world.add(groundBody);
world.addBody(groundBody);
demo.addVisual(groundBody);

world.quatNormalizeFast = false;
Expand Down
12 changes: 6 additions & 6 deletions demos/container.html
Expand Up @@ -65,7 +65,7 @@
var groundShape = new CANNON.Plane();
var groundBody = new CANNON.Body({ mass: 0, material: stone });
groundBody.addShape(groundShape);
world.add(groundBody);
world.addBody(groundBody);
demo.addVisual(groundBody);

// plane -x
Expand All @@ -74,31 +74,31 @@
planeXmin.addShape(planeShapeXmin);
planeXmin.quaternion.setFromAxisAngle(new CANNON.Vec3(0,1,0),Math.PI/2);
planeXmin.position.set(-5,0,0);
world.add(planeXmin);
world.addBody(planeXmin);

// Plane +x
var planeShapeXmax = new CANNON.Plane();
var planeXmax = new CANNON.Body({ mass: 0, material: stone });
planeXmax.addShape(planeShapeXmax);
planeXmax.quaternion.setFromAxisAngle(new CANNON.Vec3(0,1,0),-Math.PI/2);
planeXmax.position.set(5,0,0);
world.add(planeXmax);
world.addBody(planeXmax);

// Plane -y
var planeShapeYmin = new CANNON.Plane();
var planeYmin = new CANNON.Body({ mass: 0, material: stone });
planeYmin.addShape(planeShapeYmin);
planeYmin.quaternion.setFromAxisAngle(new CANNON.Vec3(1,0,0),-Math.PI/2);
planeYmin.position.set(0,-5,0);
world.add(planeYmin);
world.addBody(planeYmin);

// Plane +y
var planeShapeYmax = new CANNON.Plane();
var planeYmax = new CANNON.Body({ mass: 0, material: stone });
planeYmax.addShape(planeShapeYmax);
planeYmax.quaternion.setFromAxisAngle(new CANNON.Vec3(1,0,0),Math.PI/2);
planeYmax.position.set(0,5,0);
world.add(planeYmax);
world.addBody(planeYmax);

// Create spheres
var rand = 0.1;
Expand All @@ -119,7 +119,7 @@
sphereBody.sleepSpeedLimit = 1;
sphereBody.sleepTimeLimit = 5;

world.add(sphereBody);
world.addBody(sphereBody);
demo.addVisual(sphereBody);
}
}
Expand Down

0 comments on commit 6e0d352

Please sign in to comment.