StaticaddGeneric add function. Adds one or many body(s), constraint(s) or a composite(s) to the given composite.
Triggers beforeAdd and afterAdd events on the composite.
The original composite with the objects added
StaticallReturns all bodies in the given composite, including all bodies in its children, recursively.
All the bodies
StaticallReturns all composites in the given composite, including all composites in its children, recursively.
All the composites
StaticallReturns all constraints in the given composite, including all constraints in its children, recursively.
All the constraints
StaticclearRemoves all bodies, constraints and composites from the given composite. Optionally clearing its children recursively.
Optionaldeep: booleanStaticcreateCreates a new composite. The options parameter is an object that specifies any properties you wish to override the defaults.
See the properites section below for detailed information on what you can pass via the options object.
Optionaloptions: MatterJS.ICompositeDefinitionA new composite
StaticgetSearches the composite recursively for an object matching the type and id supplied, null if not found.
The requested object, if found
StaticmoveMoves the given object(s) from compositeA to compositeB (equal to a remove followed by an add).
Returns compositeA
StaticrebaseAssigns new ids for all objects in the composite, recursively.
Returns composite
StaticremoveGeneric 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.
Optionaldeep: booleanThe original composite with the objects removed
StaticrotateRotates all children in the composite by a given angle about the given point, without imparting any angular velocity.
Optionalrecursive: booleanStaticscaleScales all children in the composite, including updating physical properties (mass, area, axes, inertia), from a world-space point.
Optionalrecursive: booleanStaticsetSets the composite's isModified flag.
If updateParents is true, all parents will be set (default: false).
If updateChildren is true, all children will be set (default: false).
OptionalupdateParents: booleanOptionalupdateChildren: booleanStatictranslateTranslates all children in the composite by a given vector relative to their current positions, without imparting any velocity.
Optionalrecursive: boolean
The
Matter.Compositemodule contains methods for creating and manipulating composite bodies. A composite body is a collection ofMatter.Body,Matter.Constraintand otherMatter.Composite, therefore composites form a tree structure. It is important to use the functions in this module to modify composites, rather than directly modifying their properties. Note that theMatter.Worldobject is also a type ofMatter.Compositeand as such all composite methods here can also operate on aMatter.World.See the included usage examples.
Composite