Skip to content

MignonBelongie/three-to-cannon

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

62 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%