All Projects → donmccurdy → three-to-cannon

donmccurdy / three-to-cannon

Licence: other
Convert a THREE.Mesh to a CANNON.Shape.

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects

Projects that are alternatives of or similar to three-to-cannon

cannon-es-debugger
Wireframe debugger for use with cannon-es https://github.com/react-spring/cannon-es
Stars: ✭ 69 (-66.67%)
Mutual labels:  threejs, physics, cannonjs
Agamari
🍙 Katamari × Agar.io
Stars: ✭ 46 (-77.78%)
Mutual labels:  threejs, cannonjs
WebGL-Billiards
ThreeJS based 8-ball pool
Stars: ✭ 28 (-86.47%)
Mutual labels:  threejs, cannonjs
Aframe Physics System
Physics system for A-Frame VR, built on CANNON.js.
Stars: ✭ 371 (+79.23%)
Mutual labels:  threejs, physics
Webxr Physics
Adds physics to WebXR
Stars: ✭ 18 (-91.3%)
Mutual labels:  threejs, physics
apate-ar
Framwork for environment aware AR with occlusion, lighting PBR rendering, physics support (cannon.js), based on three.js
Stars: ✭ 77 (-62.8%)
Mutual labels:  threejs, cannonjs
use-ammojs
ammo.js physics for use with react-three-fiber
Stars: ✭ 16 (-92.27%)
Mutual labels:  threejs, physics
encounter
Remaking the classic C64 game in WebGL.
Stars: ✭ 45 (-78.26%)
Mutual labels:  threejs, physics
spark-ar-physics
A helper module for connecting Spark AR with physics libraries
Stars: ✭ 28 (-86.47%)
Mutual labels:  physics, cannonjs
annihilate
js action game
Stars: ✭ 49 (-76.33%)
Mutual labels:  threejs, cannonjs
billiards
billiards physics
Stars: ✭ 37 (-82.13%)
Mutual labels:  threejs, physics
codrops-texture-projection
Article about Texture Projection in Three.js
Stars: ✭ 75 (-63.77%)
Mutual labels:  threejs
icosa-viewer
3D Viewer component for Tilt Brush / Open Brush, Google Blocks files and their derivatives
Stars: ✭ 24 (-88.41%)
Mutual labels:  threejs
Photo-Sphere-Viewer
A JavaScript library to display Photo Sphere panoramas.
Stars: ✭ 1,198 (+478.74%)
Mutual labels:  threejs
mujoco
Multi-Joint dynamics with Contact. A general purpose physics simulator.
Stars: ✭ 4,685 (+2163.29%)
Mutual labels:  physics
Big-Data-Demo
基于Vue、three.js、echarts,数据可视化展示项目,包含三维模型导入交互、三维模型标注等功能
Stars: ✭ 146 (-29.47%)
Mutual labels:  threejs
Physics
experimenting with physics simulation
Stars: ✭ 53 (-74.4%)
Mutual labels:  physics
react-with-threejs-example
An example project integrating React with three.js
Stars: ✭ 27 (-86.96%)
Mutual labels:  threejs
racing-game-cljs
A 3D racing game built with ClojureScript, React and ThreeJS
Stars: ✭ 209 (+0.97%)
Mutual labels:  threejs
three-mithril-ts
THREE.js, Mithril.js, TypeScript starter project
Stars: ✭ 34 (-83.57%)
Mutual labels:  threejs

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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].