three-to-cannon
Advanced tools
Comparing version 4.0.0 to 4.0.1
{ | ||
"name": "three-to-cannon", | ||
"version": "4.0.0", | ||
"version": "4.0.1", | ||
"description": "Convert a THREE.Mesh to a CANNON.Shape.", | ||
@@ -5,0 +5,0 @@ "main": "dist/three-to-cannon.js", |
@@ -8,5 +8,5 @@ # three-to-cannon | ||
Convert a THREE.Mesh to a CANNON.Shape, and optional optimizations with simplified shapes. | ||
Convert a [THREE.Mesh](https://threejs.org/docs/?q=mesh#api/en/objects/Mesh) or [THREE.Object3D](https://threejs.org/docs/?q=object3d#api/en/core/Object3D) to a [CANNON.Shape](https://pmndrs.github.io/cannon-es/docs/classes/shape.html), with optimizations to simplified bounding shapes (AABB, sphere, etc.). | ||
## Usage | ||
## API | ||
@@ -19,34 +19,46 @@ Installation: | ||
Import: | ||
Use: | ||
```js | ||
/**************************************** | ||
* Import: | ||
*/ | ||
// ES6 | ||
import { threeToCannon } from 'three-to-cannon'; | ||
import { threeToCannon, ShapeType } from 'three-to-cannon'; | ||
// CommonJS | ||
const { threeToCannon } = require('three-to-cannon'); | ||
``` | ||
const { threeToCannon, ShapeType } = require('three-to-cannon'); | ||
Use: | ||
/**************************************** | ||
* Generate a CANNON.Shape: | ||
*/ | ||
```js | ||
import { threeToCannon, ShapeType } from 'three-to-cannon'; | ||
// Automatic. | ||
const shape = threeToCannon(object3D); | ||
const result = threeToCannon(object3D); | ||
// Bounding box (AABB). | ||
const shape = threeToCannon(object3D, {type: ShapeType.BOX}); | ||
const result = threeToCannon(object3D, {type: ShapeType.BOX}); | ||
// Bounding sphere. | ||
const shape = threeToCannon(object3D, {type: ShapeType.SPHERE}); | ||
const result = threeToCannon(object3D, {type: ShapeType.SPHERE}); | ||
// Cylinder. | ||
const shape = threeToCannon(object3D, {type: ShapeType.CYLINDER}); | ||
const result = threeToCannon(object3D, {type: ShapeType.CYLINDER}); | ||
// Convex hull. | ||
const shape = threeToCannon(object3D, {type: ShapeType.HULL}); | ||
const result = threeToCannon(object3D, {type: ShapeType.HULL}); | ||
// Mesh (not recommended). | ||
const shape = threeToCannon(object3D, {type: ShapeType.MESH}); | ||
const result = threeToCannon(object3D, {type: ShapeType.MESH}); | ||
/**************************************** | ||
* Using the result: | ||
*/ | ||
// Result object includes a CANNON.Shape instance, and (optional) | ||
// an offset or quaternion for that shape. | ||
const {shape, offset, quaternion} = result; | ||
``` | ||
See further documentation on the [CANNON.Shape](https://pmndrs.github.io/cannon-es/docs/classes/shape.html) class. |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
257424
62
0