Socket
Socket
Sign inDemoInstall

three-to-cannon

Package Overview
Dependencies
3
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 4.0.0 to 4.0.1

2

package.json
{
"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.
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc