Socket
Socket
Sign inDemoInstall

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 2.1.0 to 3.0.0

dist/three-to-cannon.js

35

index.js

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

import { Box, ConvexPolyhedron, Cylinder, Shape, Sphere, Quaternion, Trimesh, Vec3 } from 'cannon-es';
import { quickhull } from './lib/THREE.quickhull';
import { Box, ConvexPolyhedron, Cylinder, Shape, Sphere, Quaternion as CQuaternion, Trimesh, Vec3 } from 'cannon-es';
import { ConvexHull } from 'three/examples/jsm/math/ConvexHull.js';
import { Box3, BufferGeometry, Geometry, Math as _Math, Matrix4, Mesh, Quaternion, Vector3 } from 'three';

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

var shape, localPosition,
box = new THREE.Box3();
box = new Box3();

@@ -117,3 +118,3 @@ var clone = object.clone();

localPosition = box.translate(clone.position.negate()).getCenter(new THREE.Vector3());
localPosition = box.translate(clone.position.negate()).getCenter(new Vector3());
if (localPosition.lengthSq()) {

@@ -146,3 +147,3 @@ shape.offset = localPosition;

// Compute the 3D convex hull.
hull = quickhull(geometry);
hull = new ConvexHull().setFromObject(new Mesh(geometry));

@@ -187,4 +188,4 @@ // Convert from THREE.Vector3 to Vec3.

shape.orientation = new Quaternion();
shape.orientation.setFromEuler(THREE.Math.degToRad(90), 0, 0, 'XYZ').normalize();
shape.orientation = new CQuaternion();
shape.orientation.setFromEuler(_Math.degToRad(90), 0, 0, 'XYZ').normalize();
return shape;

@@ -199,3 +200,3 @@ }

var shape, height, radius,
box = new THREE.Box3(),
box = new Box3(),
axes = ['x', 'y', 'z'],

@@ -226,3 +227,3 @@ majorAxis = options.cylinderAxis || 'y',

shape.orientation = new Quaternion();
shape.orientation = new CQuaternion();
shape.orientation.setFromEuler(

@@ -303,4 +304,4 @@ majorAxis === 'y' ? PI_2 : 0,

meshes = getMeshes(object),
tmp = new THREE.Geometry(),
combined = new THREE.Geometry();
tmp = new Geometry(),
combined = new Geometry();

@@ -311,5 +312,5 @@ if (meshes.length === 0) return null;

if (meshes.length === 1) {
var position = new THREE.Vector3(),
quaternion = new THREE.Quaternion(),
scale = new THREE.Vector3();
var position = new Vector3(),
quaternion = new Quaternion(),
scale = new Vector3();
if (meshes[0].geometry.isBufferGeometry) {

@@ -335,3 +336,3 @@ if (meshes[0].geometry.attributes.position

&& mesh.geometry.attributes.position.itemSize > 2) {
var tmpGeom = new THREE.Geometry();
var tmpGeom = new Geometry();
tmpGeom.fromBufferGeometry(mesh.geometry);

@@ -346,3 +347,3 @@ combined.merge(tmpGeom, mesh.matrixWorld);

matrix = new THREE.Matrix4();
matrix = new Matrix4();
matrix.scale(object.scale);

@@ -359,3 +360,3 @@ combined.applyMatrix(matrix);

if (!geometry.attributes) {
geometry = new THREE.BufferGeometry().fromGeometry(geometry);
geometry = new BufferGeometry().fromGeometry(geometry);
}

@@ -362,0 +363,0 @@ return (geometry.attributes.position || {}).array || [];

{
"name": "three-to-cannon",
"version": "2.1.0",
"version": "3.0.0",
"description": "Convert a THREE.Mesh to a CANNON.Shape.",
"main": "dist/three-pathfinding.js",
"module": "dist/three-pathfinding.module.js",
"main": "dist/three-to-cannon.js",
"module": "dist/three-to-cannon.module.js",
"source": "index.js",
"scripts": {
"test": "tape test/index.js | tap-spec",
"preversion": "npm run test",
"dist": "microbundle",
"version": "npm run dist && git add -A dist",
"preversion": "npm run dist && npm test",
"dev": "microbundle watch --globals three=THREE --external three",
"dist": "microbundle --globals three=THREE --external three",
"version": "git add -A dist",
"postversion": "git push && git push --tags && npm publish"

@@ -34,7 +35,9 @@ },

"peerDependencies": {
"cannon-es": "^0.9.1"
"cannon-es": "^0.9.1",
"three": "^0.115.0"
},
"devDependencies": {
"cannon-es": "^0.9.1",
"microbundle": "^0.11.0",
"esm": "^3.2.25",
"microbundle": "^0.12.0",
"tap-spec": "^5.0.0",

@@ -41,0 +44,0 @@ "tape": "^4.9.0",

@@ -1,2 +0,5 @@

// See https://github.com/react-spring/cannon-es/issues/23.
// See: https://github.com/substack/tape/issues/514
require = require('esm')(module);
// See: https://github.com/react-spring/cannon-es/issues/23
const {performance} = require('perf_hooks');

@@ -3,0 +6,0 @@ global.performance = performance;

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