Interface PhysicsOptions

For configuring the phyisical properties of GameObjects in a scene

PhysicsOptions

interface PhysicsOptions {
    anglarVelocity?: number;
    angle?: number;
    angularSpeed?: number;
    area?: string;
    axes?: Vertex;
    bounds?: Bounds;
    collisionFileter?: {
        category?: number;
        group?: number;
        mask?: number;
    };
    deltaTime?: number;
    density?: number;
    force?: Vertex;
    friction?: number;
    frictionAir?: number;
    frictionStatic?: number;
    id?: number;
    inertia?: number;
    inverseInertia?: number;
    inverseMass?: number;
    isSensor?: boolean;
    isSleeping?: boolean;
    isStatic?: boolean;
    label?: string;
    mass?: number;
    motion?: number;
    parent?: Object;
    parts?: Object[];
    position?: Vertex;
    restitution?: number;
    sleepThreshold?: number;
    slop?: number;
    speed?: number;
    timeScale?: number;
    torque?: number;
    type?: string;
    velocity?: Vertex;
    vertices?: Vertex[];
}

Properties

anglarVelocity?: number

Read only. Use Body.setAngularVelocity to set. default is 0. Gets the current rotational velocity of the body.

angle?: number

A Number specifying the angle of the body, in radians. default is 0

angularSpeed?: number

Read only. Use GameObject.body.setAngularSpeed to set. default is 0. The current rotational speed of the body.

area?: string

Read only. Calculated automatically when vertices are set. A Number that measures the area of the body's convex hull.

axes?: Vertex

Read only. Calculated automatically when vertices are set. An array of unique axis vectors (edge normals) used for collision detection. These are automatically calculated when vertices are set. They are constantly updated by Body.update during the simulation.

bounds?: Bounds

A Bounds object that defines the AABB region for the body. It is automatically calculated when vertices are set and constantly updated by Body.update during simulation.

collisionFileter?: {
    category?: number;
    group?: number;
    mask?: number;
}

An Object that specifies the collision filtering properties of this body. See https://brm.io/matter-js/docs/classes/Body.html#property_collisionFilter

Type declaration

  • Optional category?: number
  • Optional group?: number
  • Optional mask?: number
deltaTime?: number

Read only. Updated during engine update. A Number that records the last delta time value used to update this body. Used to calculate speed and velocity. default is 1000 / 60

density?: number

Read only. Use GameObject.body.setDensity to set. A Number that defines the density of the body (mass per unit area). Mass will also be updated when set. default is 0.001

force?: Vertex

A Vector that accumulates the total force applied to the body for a single update. Force is zeroed after every Engine.update, so constant forces should be applied for every update they are needed. Apply force with GameObject.body.applyForce (https://brm.io/matter-js/docs/classes/Body.html#method_applyForce)

friction?: number

A Number that defines the friction of the body. The value is always positive and is in the range (0, 1). A value of 0 means that the body may slide indefinitely. A value of 1 means the body may come to a stop almost instantly after a force is applied. The effects of the value may be non-linear. High values may be unstable depending on the body. The engine uses a Coulomb friction model including static and kinetic friction. Note that collision response is based on pairs of bodies, and that friction values are combined with the following formula: Math.min(bodyA.friction, bodyB.friction). default is 0.1

frictionAir?: number

A Number that defines the air friction of the body (air resistance). A value of 0 means the body will never slow as it moves through space. The higher the value, the faster a body slows when moving through space. The effects of the value are non-linear. default is 0.01

frictionStatic?: number

A Number that defines the static friction of the body (in the Coulomb friction model). A value of 0 means the body will never 'stick' when it is nearly stationary and only dynamic friction is used. The higher the value (e.g. 10), the more force it will take to initially get the body moving when nearly stationary. This value is multiplied with the friction property to make it easier to change friction and maintain an appropriate amount of static friction. default is 0.5

id?: number

An integer Number uniquely identifying number generated in Body.create by Common.nextId.

inertia?: number

Read only. Automatically calculated when vertices, mass or density are set or set through GameObject.body.setInertia. A Number that defines the moment of inertia of the body. This is the second moment of area in two dimensions. Can be manually set to Infinity to prevent rotation of the body. See https://brm.io/matter-js/docs/classes/Body.html#method_setInertia.

inverseInertia?: number

Read only. Automatically calculated when vertices, mass or density are set or calculated by Body.setInertia. A Number that defines the inverse moment of inertia of the body (1 / inertia).

inverseMass?: number

Read only. Use GameObject.body.setMass to set. A Number that defines the inverse mass of the body (1 / mass).

isSensor?: boolean

A flag that indicates whether a body is a sensor. Sensor triggers collision events, but doesn't react with colliding body physically. False by default.

isSleeping?: boolean

Read only. Use Matter.Sleeping.set to set. A flag that indicates whether the body is considered sleeping. A sleeping body acts similar to a static body, except it is only temporary and can be awoken. False by default.

isStatic?: boolean

Read only. Use GameObject.body.setStatic to set. A flag that indicates whether a body is considered static. A static body can never change position or angle and is completely fixed. False by default.

label?: string

A String that defines the label property of the body. See https://brm.io/matter-js/docs/classes/Body.html#property_label

mass?: number

Read only. Use GameObject.body.setMass to set. Calculated automatically from object properties

motion?: number

Read only. Calculated during engine update only when sleeping is enabled. A Number that loosely measures the amount of movement a body currently has. Derived from body.speed^2 + body.angularSpeed^2. See Sleeping.update. 0 by default.

parent?: Object

Read only. Updated by GameObject.body.setParts. A reference to the body that this is a part of. See body.parts. This is a self reference if the body is not a part of another body.

parts?: Object[]

Read only. Use Body.setParts to set. An array of bodies that make up this body. The first body in the array must always be a self reference to the current body instance. All bodies in the parts array together form a single rigid compound body. Parts are allowed to overlap, have gaps or holes or even form concave bodies. Parts themselves should never be added to a World, only the parent body should be. Use Body.setParts when setting parts to ensure correct updates of all properties.

position?: Vertex

Read only. Use GameObject.body.setPosition to set. A Vector that specifies the current world-space position of the body. Default is { x: 0, y: 0 }

restitution?: number

A Number that defines the restitution (elasticity) of the body. The value is always positive and is in the range (0, 1). A value of 0 means collisions may be perfectly inelastic and no bouncing may occur. A value of 0.8 means the body may bounce back with approximately 80% of its kinetic energy. Note that collision response is based on pairs of bodies, and that restitution values are combined with the following formula: Math.max(bodyA.restitution, bodyB.restitution). 0 by default.

sleepThreshold?: number

A Number that defines the length of time during which this body must have near-zero velocity before it is set as sleeping by the Matter.Sleeping module (if sleeping is enabled by the engine). Default is 60.

slop?: number

A Number that specifies a thin boundary around the body where it is allowed to slightly sink into other bodies. This is required for proper collision response, including friction and restitution effects. The default should generally suffice in most cases. You may need to decrease this value for very small bodies that are nearing the default value in scale. Default is 0.05.

speed?: number

Read only. Use GameObject.body.setVelocity to set. A Number that specifies the speed of the body. This value is always positive, representing the magnitude of velocity. 0 by default.

timeScale?: number

A Number that specifies per-body time scaling. Defualt is 1.... to make time slower relative to other objects in the scene, set to a number less than 1. To make time faster relative to other objects in the scene, set to a number greater than 1.

torque?: number

A Number that accumulates the total torque (turning force) applied to the body for a single update. See also Body.applyForce. Torque is zeroed after every Matter.Engine.update (Scene.engine), so constant torques should be applied for every update they are needed. Torques result in angular acceleration on every update, which depends on body inertia and the engine update delta. 0 by default.

type?: string
velocity?: Vertex

Read only. Use GameObject.body.setVelocity to set. A Vector that specifies the current world-space velocity of the body. Default is { x: 0, y: 0 }

vertices?: Vertex[]

Generated using TypeDoc