Navigation Menu

Skip to content

Commit

Permalink
make actual canvas dimension depend on the simulation. TODO: works on…
Browse files Browse the repository at this point in the history
…y on load
  • Loading branch information
SillyFreak committed Sep 11, 2020
1 parent 6c18b79 commit 360bc30
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/components/ide/Simulator/simulation/Simulation.js
Expand Up @@ -182,13 +182,19 @@ export default class Simulation {
mount(canvas: HTMLCanvasElement) {
this.unmount();

const dimension = {};
if (this.bounds !== null) {
dimension.width = this.bounds.max.x - this.bounds.min.x;
dimension.height = this.bounds.max.y - this.bounds.min.y;
}

// TODO creating a Render instance with a running Engine will error,
// as the Engine's internal state is recursive.
// mount() can therefore not be called after initially starting the simulation
this.render = Matter.Render.create({
canvas,
engine: this.engine,
options: { width: 600, height: 400, wireframes: false, background: '#eeeeee' },
options: { ...dimension, wireframes: false, background: '#eeeeee' },
});
if (this.bounds !== null) Matter.Render.lookAt(this.render, this.bounds);
}
Expand Down

0 comments on commit 360bc30

Please sign in to comment.