This module has now been replaced by Matter.Composite.

All usage should be migrated to the equivalent functions found on Matter.Composite. For example World.add(world, body) now becomes Composite.add(world, body).

The property world.gravity has been moved to engine.gravity.

For back-compatibility purposes this module will remain as a direct alias to Matter.Composite in the short term during migration. Eventually this alias module will be marked as deprecated and then later removed in a future release.

Hierarchy

  • default

Constructors

Properties

add: ((composite, object) => IComposite) = Composite.add

Type declaration

    • (composite, object): IComposite
    • Generic single or multi-add function. Adds a single or an array of body(s), constraint(s) or composite(s) to the given composite. Triggers beforeAdd and afterAdd events on the composite.

      Parameters

      Returns IComposite

      The original composite with the objects added

      Method

      add

addBody: ((composite, body) => IComposite) = Composite.addBody

Type declaration

    • (composite, body): IComposite
    • Adds a body to the given composite.

      Parameters

      Returns IComposite

      The original composite with the body added

      Method

      addBody

addComposite: ((compositeA, compositeB) => IComposite) = Composite.addComposite

Type declaration

    • (compositeA, compositeB): IComposite
    • Adds a composite to the given composite.

      Parameters

      Returns IComposite

      The original compositeA with the objects from compositeB added

      Method

      addComposite

addConstraint: ((composite, constraint) => IComposite) = Composite.addConstraint

Type declaration

    • (composite, constraint): IComposite
    • Adds a constraint to the given composite.

      Parameters

      Returns IComposite

      The original composite with the constraint added

      Method

      addConstraint

clear: ((composite, keepStatic, deep?) => IComposite) = Composite.clear

Type declaration

    • (composite, keepStatic, deep?): IComposite
    • Removes all bodies, constraints and composites from the given composite. Optionally clearing its children recursively.

      Parameters

      • composite: IComposite
      • keepStatic: boolean
      • deep: boolean = false

      Returns IComposite

      Method

      clear

create: ((options?) => IComposite) = Composite.create

Type declaration

    • (options?): IComposite
    • See above, aliases for back compatibility only

      Parameters

      • options: {
            bodies?: IBody[];
            cache?: { allBodies?: IBody[] | null | undefined; allConstraints?: IConstraint[] | null | undefined; allComposites?: IComposite[] | null | undefined; };
            composites?: IComposite[];
            constraints?: IConstraint[];
            events?: { beforeAdd?: Function[] | undefined; afterAdd?: Function[] | undefined; beforeRemove?: Function[] | undefined; afterRemove?: Function[] | undefined; };
            gravity?: { x?: number | undefined; y?: number | undefined; scale?: number | undefined; };
            id?: number;
            isModified?: boolean;
            label?: string;
            parent?: null | ({ id?: number | undefined; type?: "composite" | undefined; label?: string | undefined; isModified?: boolean | undefined; parent?: ... | null | undefined; bodies?: IBody[] | undefined; ... 5 more ...; gravity?: { ...; } | undefined; });
            plugin?: ({}) | ({ name?: string | undefined; version?: string | undefined; for?: string | undefined; uses?: string[] | undefined; install?: { apply?: {} | undefined; call?: {} | undefined; bind?: {} | undefined; ... 6 more ...; [Symbol.hasInstance]?: {} | undefined; } | undefined; _warned?: boolean | undefined; });
            type?: "composite";
        } = {}
        • Optional bodies?: IBody[]

          An array of Body that are direct children of this composite. To add or remove bodies you should use Composite.add and Composite.remove methods rather than directly modifying this property. If you wish to recursively find all descendants, you should use the Composite.allBodies method.

          Default

          []
          
        • Optional cache?: { allBodies?: IBody[] | null | undefined; allConstraints?: IConstraint[] | null | undefined; allComposites?: IComposite[] | null | undefined; }

          An object used for storing cached results for performance reasons. This is used internally only and is automatically managed.

        • Optional composites?: IComposite[]

          An array of Composite that are direct children of this composite. To add or remove composites you should use Composite.add and Composite.remove methods rather than directly modifying this property. If you wish to recursively find all descendants, you should use the Composite.allComposites method.

          Default

          []
          
        • Optional constraints?: IConstraint[]

          An array of Constraint that are direct children of this composite. To add or remove constraints you should use Composite.add and Composite.remove methods rather than directly modifying this property. If you wish to recursively find all descendants, you should use the Composite.allConstraints method.

          Default

          []
          
        • Optional events?: { beforeAdd?: Function[] | undefined; afterAdd?: Function[] | undefined; beforeRemove?: Function[] | undefined; afterRemove?: Function[] | undefined; }
        • Optional gravity?: { x?: number | undefined; y?: number | undefined; scale?: number | undefined; }
        • Optional id?: number

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

        • Optional isModified?: boolean

          A flag that specifies whether the composite has been modified during the current step. This is automatically managed when bodies, constraints or composites are added or removed.

          Default

          false
          
        • Optional label?: string

          An arbitrary String name to help the user identify and manage composites.

          Default

          "Composite"
          
        • Optional parent?: null | ({ id?: number | undefined; type?: "composite" | undefined; label?: string | undefined; isModified?: boolean | undefined; parent?: ... | null | undefined; bodies?: IBody[] | undefined; ... 5 more ...; gravity?: { ...; } | undefined; })

          The Composite that is the parent of this composite. It is automatically managed by the Matter.Composite methods.

          Default

          null
          
        • Optional plugin?: ({}) | ({ name?: string | undefined; version?: string | undefined; for?: string | undefined; uses?: string[] | undefined; install?: { apply?: {} | undefined; call?: {} | undefined; bind?: {} | undefined; ... 6 more ...; [Symbol.hasInstance]?: {} | undefined; } | undefined; _warned?: boolean | undefined; })

          An object reserved for storing plugin-specific properties.

          Default

          {}
          
        • Optional type?: "composite"

          A String denoting the type of object.

      Returns IComposite

remove: ((composite, object, deep?) => IComposite) = Composite.remove

Type declaration

    • (composite, object, deep?): IComposite
    • Generic remove function. Removes one or many body(s), constraint(s) or a composite(s) to the given composite. Optionally searching its children recursively. Triggers beforeRemove and afterRemove events on the composite.

      Parameters

      Returns IComposite

      The original composite with the objects removed

      Method

      remove

Generated using TypeDoc