Skip to content

Instantly share code, notes, and snippets.

@garganurag893
Created November 16, 2019 11:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save garganurag893/c617ac5512479b2243e6dc4d95be0dc7 to your computer and use it in GitHub Desktop.
Save garganurag893/c617ac5512479b2243e6dc4d95be0dc7 to your computer and use it in GitHub Desktop.
import Plane from '../components/Plane';
import Matter from 'matter-js';
Matter.Common.isElement = () => false; //-- Overriding this function because the original references HTMLElement
export default restart => {
//-- Cleanup existing entities..
if (restart) {
Matter.Engine.clear(restart.physics.engine);
}
let engine = Matter.Engine.create({enableSleeping: false});
let world = engine.world;
world.gravity.y = 0.25;
const boxSize = 50;
return {
physics: {engine: engine, world: world},
Plane: Plane(
world,
'pink',
{x: 220, y: 400},
{height: boxSize, width: boxSize},
),
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment