Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

three-to-cannon

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

three-to-cannon - npm Package Compare versions

Comparing version 1.4.1 to 2.0.0

dist/three-pathfinding.js

12

index.js

@@ -1,3 +0,3 @@

var CANNON = require('cannon'),
quickhull = require('./lib/THREE.quickhull');
import * as CANNON from 'cannon';
import { quickhull } from './lib/THREE.quickhull';

@@ -19,3 +19,3 @@ var PI_2 = Math.PI / 2;

*/
var mesh2shape = function (object, options) {
export const threeToCannon = function (object, options) {
options = options || {};

@@ -37,3 +37,3 @@

} else if (options.type) {
throw new Error('[CANNON.mesh2shape] Invalid type "%s".', options.type);
throw new Error('[CANNON.threeToCannon] Invalid type "%s".', options.type);
}

@@ -71,6 +71,4 @@

mesh2shape.Type = Type;
threeToCannon.Type = Type;
module.exports = CANNON.mesh2shape = mesh2shape;
/******************************************************************************

@@ -77,0 +75,0 @@ * Shape construction

@@ -41,3 +41,3 @@ /**

module.exports = (function(){
export const quickhull = (function(){

@@ -44,0 +44,0 @@

{
"name": "three-to-cannon",
"version": "1.4.1",
"version": "2.0.0",
"description": "Convert a THREE.Mesh to a CANNON.Shape.",
"main": "index.js",
"main": "dist/three-pathfinding.js",
"module": "dist/three-pathfinding.module.js",
"source": "index.js",
"scripts": {
"test": "node test/index.js",
"preversion": "npm run test",
"dist": "microbundle --target browser",
"version": "npm run dist && git add -A dist",
"postversion": "git push && git push --tags && npm publish"

@@ -34,2 +38,3 @@ },

"cannon": "github:donmccurdy/cannon.js#v0.6.2-dev1",
"microbundle": "^0.6.0",
"tape": "^4.9.0",

@@ -36,0 +41,0 @@ "three": "^0.89.0"

@@ -9,26 +9,38 @@ # three-to-cannon

```javascript
Installation:
```js
npm install --save three-to-cannon
```
Import:
```js
// ES6
import { threeToCannon } from 'three-to-cannon';
// CommonJS
threeToCannon = require('three-to-cannon').threeToCannon;
```
mesh2shape = require('three-to-cannon');
Use:
```js
// Automatic.
var shape = mesh2shape(object3D);
const shape = threeToCannon(object3D);
// Bounding box (AABB).
var shape = mesh2shape(object3D, {type: mesh2shape.Type.BOX});
const shape = threeToCannon(object3D, {type: threeToCannon.Type.BOX});
// Bounding sphere.
var shape = mesh2shape(object3D, {type: mesh2shape.Type.SPHERE});
const shape = threeToCannon(object3D, {type: threeToCannon.Type.SPHERE});
// Cylinder.
var shape = mesh2shape(object3D, {type: mesh2shape.Type.CYLINDER});
const shape = threeToCannon(object3D, {type: threeToCannon.Type.CYLINDER});
// Convex hull.
var shape = mesh2shape(object3D, {type: mesh2shape.Type.HULL});
const shape = threeToCannon(object3D, {type: threeToCannon.Type.HULL});
// Mesh (not recommended).
var shape = mesh2shape(object3D, {type: mesh2shape.Type.MESH});
const shape = threeToCannon(object3D, {type: threeToCannon.Type.MESH});
```
const test = require('tape');
const THREE = global.THREE = require('three');
const mesh2shape = require('../');
const threeToCannon = require('../').threeToCannon;

@@ -20,3 +20,3 @@ const ShapeType = {

test('shape - box', function (t) {
var box = mesh2shape(object, {type: mesh2shape.Type.BOX});
var box = threeToCannon(object, {type: threeToCannon.Type.BOX});

@@ -32,3 +32,3 @@ t.equal( box.type, ShapeType.BOX, 'box.type' );

test('shape - sphere', function (t) {
const sphere = mesh2shape(object, {type: mesh2shape.Type.SPHERE});
const sphere = threeToCannon(object, {type: threeToCannon.Type.SPHERE});

@@ -42,3 +42,3 @@ t.equal( sphere.type, ShapeType.SPHERE, 'sphere.type' );

test('shape - cylinder', function (t) {
const cylinder = mesh2shape(object, {type: mesh2shape.Type.CYLINDER});
const cylinder = threeToCannon(object, {type: threeToCannon.Type.CYLINDER});

@@ -58,3 +58,3 @@ t.equal( cylinder.type, ShapeType.CYLINDER, 'cylinder.type' );

test('shape - hull', function (t) {
const hull = mesh2shape(object, {type: mesh2shape.Type.HULL});
const hull = threeToCannon(object, {type: threeToCannon.Type.HULL});

@@ -67,3 +67,3 @@ t.equal( hull.type, ShapeType.HULL, 'hull.type' );

test('shape - mesh', function (t) {
const mesh = mesh2shape(object, {type: mesh2shape.Type.MESH});
const mesh = threeToCannon(object, {type: threeToCannon.Type.MESH});

@@ -84,3 +84,3 @@ t.equal( mesh.type, ShapeType.MESH, 'mesh.type' );

const box = mesh2shape(object);
const box = threeToCannon(object);

@@ -87,0 +87,0 @@ t.equal( box.type, ShapeType.BOX, 'box.type' );

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc