PhysicsShape

lumin. PhysicsShape

A shape that can be added to a PhysicsRigidBody. While the PhysicsRigidBody defines how the
body moves, due to its mass, PhysicsShapes define the actual shape of the body. PhysicsShapes
come in two general types: primitive, and mesh. Primitive shapes are plane, sphere, capsule,
and box; they are defined by parameters such as radius and length. Mesh shapes are convex and
open; they are defined by mesh data similar to a 3d mesh for rendering.

NOTE: mesh shapes are currently not supported.

A shape can have one of two behaviors: collision or trigger. A collision shape will collide
with other collision shapes and generally act as expected in a physics simulation. A trigger
shape does not collide with other shapes. However, if a collision shape enters or exits the
bounds of a trigger shape, a PhysicsEventData server event will be generated with a kTriggerEnter
or kTriggerExit type. Note a trigger shape interacting with another trigger shape does not
generate an event.

Multiple shapes can be added to a PhysicsRigidBody. The localPosition and localRotation of the
shape sets its position relative to the position of the body.

A shape may not be added to or removed from a PhysicsRigidBody once the body has been added to a Prism.

A plane or open mesh shape cannot be added to a dynamic PhysicsRigidBody.

Note that PhysicsShape have no setters for its data. If you want to modify a shape, you must
create a new one.

Methods

getBoxSides() → {vec3}

Returns the side lengths of a box shape.

Returns:

The lengths, or undefined if the shape isn't a box.

Type
vec3

getCapsuleLength() → {number}

Returns the length of a capsule shape. The length is for the cylinder part of the shape,
it does not include the caps.

Returns:

The length, or undefined if the shape isn't a capsule.

Type
number

getCapsuleRadius() → {number}

Returns the radius of a capsule shape.

Returns:

The radius, or undefined if the shape isn't a capsule.

Type
number

getMaterial() → {lumin.PhysicsMaterial}

Returns the PhysicsMaterial for this shape.

Returns:

the material

Type
lumin.PhysicsMaterial

getShapeBehavior() → {lumin.physics.ShapeBehavior}

Returns the shape behavior.

Returns:

the behavior

Type
lumin.physics.ShapeBehavior

getShapeType() → {lumin.physics.ShapeType}

Returns the shape type.

Returns:

the type

Type
lumin.physics.ShapeType

getSphereRadius() → {number}

Returns the radius of a sphere shape.

Returns:

The radius, or undefined if the shape isn't a sphere.

Type
number

setMaterial(material)

Sets the PhysicsMaterial for the shape.

Parameters:
Name Type Description
material lumin.PhysicsMaterial

The Material