P2Component

P2Component

P2 physics component.
P2 supports convex and primitive shapes.
See also P2System

Constructor

new P2Component(optionsopt)

Parameters:
Name Type Attributes Description
options Object <optional>

The options object can contain the following properties:

Properties
Name Type Attributes Default Description
mass number <optional>
0

Mass of the body. 0 means immovable.

linearDamping number <optional>
0

Movement damping.

angularDamping number <optional>
0

Rotational damping.

shapes Array <optional>
[]

Collision shapes.

scale number <optional>
1

Scale to apply from physics to rendering.

offsetX number <optional>
0

Offset from physics to rendering.

offsetY number <optional>
0
offsetZ number <optional>
0
offsetAngleX number <optional>
0

Angular offset from physics to rendering.

offsetAngleY number <optional>
0
offsetAngleZ number <optional>
0
Example
var entity = sumerian.world.createEntity(new Box());
var p2comp = new P2Component({
    shapes:[{
        type: 'circle',
        radius: 1
    }],
});
entity.setComponent(p2comp);