mrdoob/three.js — Issue #934: Question about jigLib Triangle Mesh enigma
Author: seacloud9
Created: 2011-12-18 23:52:16+00:00
State: open

I have also reviewed this previous issue https://github.com/mrdoob/three.js/issues/602 which seems very similar to my issue.
PasteBin Code http://pastebin.com/G8Q7TqXQ
http://i-create.org/JavaScript/jiglib/ -> page in question.

In short the trianglemesh does not appears to be reacting to the boxes and spheres that are dropped on it they simply pass right threw.

Other items are colliding just not the world geometry have been looking at this for days any guidence or advice would be greatly appreciated.

I am using cobbpg version of http://brokstuk.com/jiglibjs2/

I may be missing something simple just really stuck thanks in advance for any advice.

Island TriangleMesh Creation Code highlights / Code most likely in question:

function createScene( geometry ) {
//console.log(geometry)
island = new THREE.Mesh( geometry, new THREE.MeshFaceMaterial() );
island.overdraw = true;
island.matrixAutoUpdate = false;
island.geometry.dynamic = true;
island.geometry.__dirtyVertices = true;
island.autoUpdateMatrix = false;

scene.add( island );

var triangleMesh = getPhysicalBody(island.geometry,[island.position.x,island.position.y,island.position.z,0]);
triangleMesh.set_movable(false);
triangleMesh.set_mass(500);
triangleMesh.set_friction(0.2);
triangleMesh.set_restitution(0.9);
system.addBody(triangleMesh);
island.rigidBody = triangleMesh;

}
/// Create the Triangle Mesh and Return in

function getPhysicalBody(threeGeometry,initPos)
{
var vertices = [];
var indices = [];

for (i = 0; i < threeGeometry.vertices.length; i++) {
var vert_x = threeGeometry.vertices[i].position.x;
var vert_y = threeGeometry.vertices[i].position.y;
var vert_z = threeGeometry.vertices[i].position.z;
vertices.push(new Vector3D(island.position.x,island.position.y,island.position.z,0 ));
}

/*for (i = 0; i < 4; i++) {
var x = threeGeometry.faces[i];
for (j = 0; j < 4; j++)
{
var t = { i0: x.a };
t.i1 = x.b;
t.i2 = x.c;
t.i3 = x.d;
indices.push(t);
}
}*/
for (i = 0; i < threeGeometry.faces.length; i++) {
var face = threeGeometry.faces[ i ];
var t = {i0:0, i1:0};
if ( face instanceof THREE.Face3 ) {
t.i0 = face.a;
t.i1 = face.b;
t.i2 = face.c;
indices.push( t );
} else if ( face instanceof THREE.Face4 ) {
t.i0 = face.a;
t.i1 = face.b;
t.i2 = face.d;
indices.push( t );
t.i0 = face.b;
t.i1 = face.c;
t.i2 = face.d;
indices.push( t );
}
}
var skin = { vertices: vertices, indices: indices };
var pos = new Vector3D(island.position.x,island.position.y,island.position.z,0 );
var rot = new jiglib.Matrix3D();
var body = new jiglib.JTriangleMesh(skin, pos, rot, 200, 10);
return body;
}

//// initJiglib

function init_jiglib(){
system = jiglib.PhysicsSystem.getInstance();
system.setGravity([0,-5200,0, 0]);//-120
system.setCollisionSystem(true, 200000, 200000, 200000, 200000, 200000, 200000, 200000, 200000, 200000); // CollisionSystemGrid
system.setSolverType('FAST');//FAST, NORMAL, ACCUMULATED

startGame();
}