Create CANNON.RigidBody from THREE.Mesh or THREE.Geometry

前端 未结 2 1733
孤独总比滥情好
孤独总比滥情好 2021-01-18 21:11

I am creating a THREE.Mesh object using a THREE.JSONLoader object like so:

// Create castle.
loader.load(\'/Meshes/CastleTower.js\'         


        
2条回答
  •  一个人的身影
    2021-01-18 21:54

    I had a similar issue and created the necessary "points" and "faces" (as described in Cannon docs) from the THREE.Geometry (called geometry here) with these two functions:

    cannonPoints = geometry.vertices.map(function(v) {
        return new CANNON.Vec3( v.x, v.y, v.z )
    })
    
    cannonFaces = geometry.faces.map(function(f) {
        return [f.a, f.b, f.c]
    })
    

提交回复
热议问题