MignonBelongie / three-to-cannon

Convert a THREE.Mesh to a CANNON.Shape.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

three-to-cannon

Latest NPM release Minzipped size License Build Status

Convert a THREE.Mesh to a CANNON.Shape, and optional optimizations with simplified shapes.

Usage

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

About

Convert a THREE.Mesh to a CANNON.Shape.


Languages

Language:JavaScript 100.0%