three-to-cannon
Convert a THREE.Mesh or THREE.Object3D to a CANNON.Shape, with optimizations to simplified bounding shapes (AABB, sphere, etc.).
API
Installation:
npm install --save three-to-cannon
Use:
import { threeToCannon, ShapeType } from 'three-to-cannon';
const { threeToCannon, ShapeType } = require('three-to-cannon');
const result = threeToCannon(object3D);
const result = threeToCannon(object3D, {type: ShapeType.BOX});
const result = threeToCannon(object3D, {type: ShapeType.SPHERE});
const result = threeToCannon(object3D, {type: ShapeType.CYLINDER});
const result = threeToCannon(object3D, {type: ShapeType.HULL});
const result = threeToCannon(object3D, {type: ShapeType.MESH});
const {shape, offset, orientation} = result;
body.addShape(shape, offset, orientation);
See further documentation on the CANNON.Shape class.