A coordinate wrapping plugin for matter.js. See the readme for usage and examples.
Updates the engine by wrapping bodies and composites inside engine.world.
This is called automatically by the plugin.
- Matter.Engine engine The engine to update.
- No return value.
Returns a translation vector that wraps the objectBounds inside the bounds.
- Matter.Bounds objectBounds The bounds of the object to wrap inside the bounds.
- Matter.Bounds bounds The bounds to wrap the body inside.
- Matter.Vector A translation vector (only if wrapping is required).
Wraps the body position such that it always stays within the given bounds.
Upon crossing a boundary the body will appear on the opposite side of the bounds,
while maintaining its velocity.
This is called automatically by the plugin.
- Matter.Body body The body to wrap.
- Matter.Bounds bounds The bounds to wrap the body inside.
- Matter.Vector The translation vector that was applied (only if wrapping was required).
Returns the union of the bounds of all of the composite's bodies (not accounting for constraints).
- Matter.Composite composite The composite.
- Matter.Bounds The composite bounds.
Wraps the composite position such that it always stays within the given bounds.
Upon crossing a boundary the composite will appear on the opposite side of the bounds,
while maintaining its velocity.
This is called automatically by the plugin.
- Matter.Composite composite The composite to wrap.
- Matter.Bounds bounds The bounds to wrap the composite inside.
- Matter.Vector The translation vector that was applied (only if wrapping was required).
See: http://brm.io/matter-js/docs/classes/Body.html
This plugin adds a new property body.plugin.wrap to instances of Matter.Body.
This is a Matter.Bounds instance that specifies the wrapping region.
- Matter.Bounds body.plugin.wrap
This plugin adds a new property composite.plugin.wrap to instances of Matter.Composite.
This is a Matter.Bounds instance that specifies the wrapping region.
- Matter.Bounds composite.plugin.wrap