Daniel Hong
Daniel Hong

Reputation: 93

Adding Physics to OBJ Model in ThreeJS

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.

Upvotes: 2

Views: 1028

Answers (1)

M -
M -

Reputation: 28482

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);
}

Upvotes: 2

Related Questions