Show:

Matter.Bodies

The Matter.Bodies module contains factory methods for creating rigid body models with commonly used body configurations (such as rectangles, circles and other polygons).

See the included usage examples.

Methods

Matter.Bodies.circle

(x, y, radius, [options], [maxSides])
Body

Creates a new rigid body model with a circle hull. The options parameter is an object that specifies any properties you wish to override the defaults. See the properties section of the Matter.Body module for detailed information on what you can pass via the options object.

Parameters

Returns

Body

A new circle body

Matter.Bodies.fromVertices

(x, y, [[vector]], [options], [flagInternal=false], [removeCollinear=0.01], [minimumArea=10])
Body

Creates a body using the supplied vertices (or an array containing multiple sets of vertices). If the vertices are convex, they will pass through as supplied. Otherwise if the vertices are concave, they will be decomposed if poly-decomp.js is available. Note that this process is not guaranteed to support complex sets of vertices (e.g. those with holes may fail). By default the decomposition will discard collinear edges (to improve performance). It can also optionally discard any parts that have an area less than minimumArea. If the vertices can not be decomposed, the result will fall back to using the convex hull. The options parameter is an object that specifies any Matter.Body properties you wish to override the defaults. See the properties section of the Matter.Body module for detailed information on what you can pass via the options object.

Parameters

  • x Number
  • y Number
  • [[vector]] Object optional

    vertexSets

  • [options] Object optional
  • [flagInternal=false] Bool optional
  • [removeCollinear=0.01] Number optional
  • [minimumArea=10] Number optional

Returns

Matter.Bodies.polygon

(x, y, sides, radius, [options])
Body

Creates a new rigid body model with a regular polygon hull with the given number of sides. The options parameter is an object that specifies any properties you wish to override the defaults. See the properties section of the Matter.Body module for detailed information on what you can pass via the options object.

Parameters

Returns

Body

A new regular polygon body

Matter.Bodies.rectangle

(x, y, width, height, [options])
Body

Creates a new rigid body model with a rectangle hull. The options parameter is an object that specifies any properties you wish to override the defaults. See the properties section of the Matter.Body module for detailed information on what you can pass via the options object.

Parameters

Returns

Body

A new rectangle body

Matter.Bodies.trapezoid

(x, y, width, height, slope, [options])
Body

Creates a new rigid body model with a trapezoid hull. The options parameter is an object that specifies any properties you wish to override the defaults. See the properties section of the Matter.Body module for detailed information on what you can pass via the options object.

Parameters

Returns

Body

A new trapezoid body

0.13.0