Mesh2shape Class

Module: Physics

Mesh2shape is used to convert ThreeJS objects to CannonJS shapes.

It is based on the original Mesh2Shape converted by @donmccurdy.

Methods

createBoundingBoxShape

(
  • geometry
)
CANNON.Box

Bounding box needs to be computed with the entire mesh, not just geometry.

Parameters:

  • geometry Geometry

Returns:

CANNON.Box:

shape

createBoundingCylinderShape

(
  • object
)
CANNON.Cylinder

Create cylinder shape from bounding cylinder calculated from bounding box and bouding sphere.

Parameters:

Returns:

CANNON.Cylinder:

shape

createBoundingSphereShape

(
  • geometry
)
CANNON.Sphere

Sphere shape from bouding sphere.

Parameters:

  • geometry Geometry

Returns:

CANNON.Sphere:

shape

createBoxShape

(
  • geometry
)
CANNON.Box

Create box shape from geometry.

Parameters:

  • geometry Geometry

Returns:

CANNON.Box:

shape

createConvexPolyhedron

(
  • geometry
)
CANNON.Shape

Computes 3D convex hull as a CANNON.ConvexPolyhedron.

Parameters:

  • geometry ConvexPolyhedron

Returns:

CANNON.Shape:

shape

createCylinderShape

(
  • geometry
)
CANNON.Cylinder

Create cylinder shape from geometry.

Parameters:

  • geometry Geometry

Returns:

CANNON.Cylinder:

shape

createPlaneShape

(
  • geometry
)
CANNON.Box

Plane shape from geometry.

Parameters:

  • geometry Geometry

Returns:

CANNON.Box:

shape

createShape

(
  • object
  • type
)
CANNON.Shape

Given a Object3D instance, creates a corresponding CANNON shape.

Parameters:

  • object Object3D
  • type String

    Mesh2shape.Type

Returns:

CANNON.Shape:

shape

createSphereShape

(
  • geometry
)
CANNON.Sphere

Sphere shape from geometry.

Parameters:

  • geometry Geometry

Returns:

CANNON.Sphere:

shape

createTrimeshShape

(
  • geometry
)
CANNON.Trimesh

Trimesh shape from geometry.

Parameters:

  • geometry Geometry

Returns:

CANNON.Trimesh:

shape

createTubeShape

(
  • geometry
)
CANNON.Trimesh

Sphere shape from bouding sphere.

Parameters:

  • geometry Geometry

Returns:

CANNON.Trimesh:

shape

getGeometry

(
  • object
)
Geometry

Returns a single geometry for the given object.

If the object is compound, its geometries are automatically merged.

Parameters:

Returns:

Geometry:

Geometry that contains all merger geometry

getMeshes

(
  • object
)
Array

Returns a array of THREE.Mesh instances from the given object.

If nested transformations are found, they are applied to child meshes as mesh.userData.matrix, so that each mesh has its position/rotation/scale independently of all of its parents except the top-level object.

Parameters:

Returns:

Array:

meshes found inside the Object3D

getVertices

(
  • geometry
)
Array

Get geometry vertices.

Parameters:

  • geometry Geometry

Returns:

Array:

array

Attributes

Type

Object

Type is used to indentify the type of cannonjs:

  • BOX
  • CYLINDER
  • SPHERE
  • HULL