Convert a THREE.Mesh to a CANNON.Shape, and optional optimizations with simplified shapes.
Installation:
npm install --save three-to-cannon
Import:
// ES6
import { threeToCannon } from 'three-to-cannon';
// CommonJS
threeToCannon = require('three-to-cannon').threeToCannon;
Use:
// Automatic.
const shape = threeToCannon(object3D);
// Bounding box (AABB).
const shape = threeToCannon(object3D, {type: threeToCannon.Type.BOX});
// Bounding sphere.
const shape = threeToCannon(object3D, {type: threeToCannon.Type.SPHERE});
// Cylinder.
const shape = threeToCannon(object3D, {type: threeToCannon.Type.CYLINDER});
// Convex hull.
const shape = threeToCannon(object3D, {type: threeToCannon.Type.HULL});
// Mesh (not recommended).
const shape = threeToCannon(object3D, {type: threeToCannon.Type.MESH});