Exciting release!Introducing "safe npm". Learn more
Socket
Log inDemoInstall

three-to-cannon

Package Overview
Dependencies
1
Maintainers
1
Versions
24
Issues
File Explorer

Advanced tools

three-to-cannon

Convert a THREE.Mesh to a CANNON.Shape.

    4.3.0latest
    GitHub

Version published
Maintainers
1
Weekly downloads
545
decreased by-27.81%

Weekly downloads

Readme

Source

three-to-cannon

Latest NPM release Minzipped size License Build Status Coverage

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: */ // ES6 import { threeToCannon, ShapeType } from 'three-to-cannon'; // CommonJS const { threeToCannon, ShapeType } = require('three-to-cannon'); /**************************************** * Generate a CANNON.Shape: */ // Automatic (Usually an AABB, except obvious cases like THREE.SphereGeometry). const result = threeToCannon(object3D); // Bounding box (AABB). const result = threeToCannon(object3D, {type: ShapeType.BOX}); // Bounding sphere. const result = threeToCannon(object3D, {type: ShapeType.SPHERE}); // Cylinder. const result = threeToCannon(object3D, {type: ShapeType.CYLINDER}); // Convex hull. const result = threeToCannon(object3D, {type: ShapeType.HULL}); // Mesh (Not recommended — limitations: https://github.com/pmndrs/cannon-es/issues/21). 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; // Add the shape to a CANNON.Body. body.addShape(shape, offset, orientation);

See further documentation on the CANNON.Shape class.

Keywords

FAQs

Last updated on 25 Oct 2022

Did you know?

Socket installs a Github app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.

Install Socket
Socket
support@socket.devSocket SOC 2 Logo

Product

  • Package Issues
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc