PhysicsGenerator Class
Physics generator is used to create Cannon.js shapes from three.js geometries.
Can be used with any object that contains a geometry.
It is based on the original Mesh2Shape converted by @donmccurdy.
Item Index
Methods
Attributes
Methods
createBoundingBoxShape
-
object
Bounding box needs to be computed with the entire mesh, not just geometry.
Parameters:
-
object
Object3D
Returns:
shape
createBoundingCylinderShape
-
object
Create cylinder shape from bounding cylinder calculated from bounding box and bouding sphere.
Parameters:
-
object
Object3D
Returns:
shape
createBoundingSphereShape
-
geometry
Sphere shape from bouding sphere.
Parameters:
-
geometry
Geometry
Returns:
shape
createBoxShape
-
geometry
Create box shape from geometry.
Parameters:
-
geometry
Geometry
Returns:
shape
createConvexPolyhedron
-
object
Computes 3D convex hull as a ConvexPolyhedron.
A convex hull is a convex geometry that contain all the geometry points inside.
Parameters:
-
object
Object3DObject to calculate the convex hull.
Returns:
Convex polyhedron calculated from thr object meshes.
createCylinderShape
-
geometry
Create cylinder shape from geometry.
Parameters:
-
geometry
Geometry
Returns:
shape
createPlaneShape
-
geometry
Plane shape from geometry.
Parameters:
-
geometry
Geometry
Returns:
shape
createShape
-
object
-
type
Given a Object3D instance, creates a corresponding CANNON shape.
Parameters:
-
object
Object3D -
type
StringPhysicsGenerator.Type
Returns:
shape
createSphereShape
-
geometry
Sphere shape from geometry.
Parameters:
-
geometry
Geometry
Returns:
shape
createTrimeshShape
-
geometry
Trimesh shape from geometry. Trimesh objects represent the object exactly with all the triangles that compose the original geometry
This type of physics shape should be avoided as much as possible since it is a lot slower that other available types.
Parameters:
-
geometry
Geometry
Returns:
shape
createTubeShape
-
geometry
Cylinder shape from bounding sphere.
Parameters:
-
geometry
Geometry
Returns:
shape
getGeometry
-
object
Returns a single geometry for the given object.
If the object is compound, its geometries are automatically merged.
Parameters:
-
object
Object3D
Returns:
Geometry that contains all merger geometry
getMeshes
-
object
Returns a array of 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:
-
object
Object3D
Returns:
meshes found inside the Object3D
getVertices
-
geometry
Get geometry vertices.
Parameters:
-
geometry
Geometry
Returns:
array