How to use the matter-js.World.add function in matter-js

To help you get started, we’ve selected a few matter-js examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github GraphQLCollege / graphql-college / components / Burger.js View on Github external
...selectPatty(this.props.burger),
            bottomBun
          ]);
        }
      } else {
        if (this.props.burger.bun) {
          bodies = bodies.concat([selectTopBun(this.props.burger), bottomBun]);
        }
      }
    }

    Render.stop(this.matterRender);
    World.clear(this.matterEngine.world);
    Engine.clear(this.matterEngine);

    World.add(this.matterEngine.world, bodies);

    Engine.run(this.matterEngine);

    Render.run(this.matterRender);
  };
  render() {
github vibertthio / runn / src / renderer / physic.js View on Github external
const newBlock = Bodies.rectangle(x, y, w, h, {
          isStatic: true,
          label,
          collisionFilter: {
            category: categories[2],
          },
        });
        if (isLast) {
          this.lastBlockChord = newBlock;
        }
        objects.push(newBlock);
      })
    }


    World.add(this.engine.world, objects);
    this.boxPositions = positions;
    this.unit = unit;
    this.hUnit = hUnit;
    this.progress = 0;
    this.resetAvatar();
  }
github krzema12 / hypergravity / src / GravityAnimationModel.js View on Github external
_addPhysicsBodies(physicsEngine, boundingBox, elements) {
    const walls = this._createWalls(boundingBox);
    const animatableBodies = this._createAnimatableBodies(elements);
    PhysicsWorld.add(physicsEngine.world, [...walls, ...animatableBodies]);
  }
github redbadger / website-honestly / site / pages / our-work / case-study / camden-market / shapes / index.js View on Github external
isStatic: true,
      render: transparentOpts,
    });
    const rightSide = Bodies.rectangle(window.innerWidth - 10, height / 2, 10, height + 10, {
      isStatic: true,
      render: transparentOpts,
    });

    window.onresize = () => {
      engine.render.canvas.width = window.innerWidth;
      Body.set(rightSide, 'position', { x: window.innerWidth, y: height });
      Body.set(ground, 'position', { x: window.innerWidth / 2, y: height + 10 });
      Body.set(ground, 'width', window.innerWidth);
    };

    World.add(engine.world, [ground, ceil, leftSide, rightSide, ...loadSvgs(), ...loadSvgs()]);

    const mouseConstraint = MouseConstraint.create(engine, {
      constraint: {
        render: { visible: false },
      },
    });

    mouseConstraint.mouse.element.removeEventListener(
      'mousewheel',
      mouseConstraint.mouse.mousewheel,
    );
    mouseConstraint.mouse.element.removeEventListener(
      'DOMMouseScroll',
      mouseConstraint.mouse.mousewheel,
    );
    World.add(engine.world, mouseConstraint);
github redbadger / website-honestly / site / pages / our-work / case-study / camden-market / shapes / index.js View on Github external
const mouseConstraint = MouseConstraint.create(engine, {
      constraint: {
        render: { visible: false },
      },
    });

    mouseConstraint.mouse.element.removeEventListener(
      'mousewheel',
      mouseConstraint.mouse.mousewheel,
    );
    mouseConstraint.mouse.element.removeEventListener(
      'DOMMouseScroll',
      mouseConstraint.mouse.mousewheel,
    );
    World.add(engine.world, mouseConstraint);

    Shapes.throwShapes(engine);
  }
github cyclegtx / colyseus-iog-state-sync / IOGStateSync / Entities / RectBodyEntity.ts View on Github external
createBody(){
        this.body = Bodies.rectangle(this.x, this.y, this.width, this.height, this.physicsOptions);
        this.body['entity_id'] = this.id;
        World.add(this.room.engine.world, this.body);
    }