Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed duplicated code. Function "createTetra" no longer needed. #206

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 6 additions & 23 deletions demos/shapes.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,6 @@
var demo = new CANNON.Demo();
var mass = 1, size = 1;


function createTetra(){
var verts = [new CANNON.Vec3(0,0,0),
new CANNON.Vec3(2,0,0),
new CANNON.Vec3(0,2,0),
new CANNON.Vec3(0,0,2)];
var offset = -0.35;
for(var i=0; i<verts.length; i++){
var v = verts[i];
v.x += offset;
v.y += offset;
v.z += offset;
}
return new CANNON.ConvexPolyhedron(verts,
[
[0,3,2], // -x
[0,1,3], // -y
[0,2,1], // -z
[1,2,3], // +xyz
]);
}

demo.addScene("all shapes",function(){
var world = setupWorld(demo);

Expand Down Expand Up @@ -120,7 +98,12 @@
v.y += offset;
v.z += offset;
}
var polyhedronShape = createTetra();
var polyhedronShape = new CANNON.ConvexPolyhedron(verts, [
[0,3,2], // -x
[0,1,3], // -y
[0,2,1], // -z
[1,2,3], // +xyz
]);
var polyhedronBody = new CANNON.Body({ mass: mass });
polyhedronBody.addShape(polyhedronShape);
polyhedronBody.position.set(size*2,-size*2,size+1);
Expand Down