Skip to content

Commit

Permalink
fix wrong usage of Matter.Composite in Robot
Browse files Browse the repository at this point in the history
  • Loading branch information
SillyFreak committed Sep 15, 2020
1 parent bca0b57 commit 75a8404
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
8 changes: 3 additions & 5 deletions src/components/ide/Simulator/simulation/Robot.js
Expand Up @@ -26,7 +26,7 @@ export default class Robot {
drive: DifferentialDrive;
servoArms: ServoArm[];

bodies: Matter.Body[];
robot: Matter.Composite;

constructor() {
this.initBody();
Expand Down Expand Up @@ -208,14 +208,12 @@ export default class Robot {
// new ServoArm(this.controller, 1, mainBody, pivotAnchorRight, rightGrabber, pivotArm, 30),
];

const bot = Matter.Composite.create({
parts: [this.body],
this.robot = Matter.Composite.create({
bodies: [this.body],
// parts: [this.body, leftGrabber, rightGrabber],
constraints: [...this.servoArms.flatMap(arm => [arm.pivotConstraint, arm.controlConstraint])],
label: 'bot',
});

this.bodies = [bot, ...bot.parts];
}

setPose({ x, y, angle }: Pose) {
Expand Down
2 changes: 1 addition & 1 deletion src/components/ide/Simulator/simulation/Simulation.js
Expand Up @@ -235,7 +235,7 @@ export default class Simulation {

addRobot(name: string, robot: Robot) {
this.robots.set(name, robot);
this.add(robot.bodies);
this.add(robot.robot);
}

// this method has to be called after adding one or more robots to the
Expand Down

0 comments on commit 75a8404

Please sign in to comment.