Adding Physics to OBJ Model in ThreeJS

975 Views Asked by At

I am trying to use PhysiJS with ThreeJS. I have an OBJ model that I exported from Blender. When I load it with OBJLoader, I see that it is a BufferGeometry. I also notice that it is missing a vertices property, which is what PhysiJS looks for.

My ThreeJS version is r101. I would appreciate any suggestions. If there is a more suitable library, I am open to that too. I am also happy to provide any clarifications.

1

There are 1 best solutions below

4
M - On BEST ANSWER

If you need to convert your BufferGeometry to Geometry, you can simply use the .fromBufferGeometry() method.

// Called when your obj finishes loading
onLoadComplete(obj) {
    var geom = new THREE.Geometry();
    geom.fromBufferGeometry(obj);

    // Now you'll have access to vertices
    console.log(geom.vertices);
}