Skip to content

Commit

Permalink
zooming kinda
Browse files Browse the repository at this point in the history
  • Loading branch information
LilyMakesThings committed Oct 9, 2024
1 parent 9d343f3 commit 7e61476
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/Drawable.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,11 @@ class Drawable {
this._position[0] = Math.round(position[0]);
this._position[1] = Math.round(position[1]);
}

const cameraState = this._renderer.cameraState;

Check failure on line 219 in src/Drawable.js

View workflow job for this annotation

GitHub Actions / build

'cameraState' is assigned a value but never used. Allowed unused vars must match /^_/u
// this._position[0] /= cameraState.zoom;
// this._position[1] /= cameraState.zoom;

this._renderer.dirty = true;
this.setTransformDirty();
}
Expand Down
6 changes: 3 additions & 3 deletions src/RenderWebGL.js
Original file line number Diff line number Diff line change
Expand Up @@ -1559,14 +1559,14 @@ class RenderWebGL extends EventEmitter {

this._doExitDrawRegion();

const nativeCenterX = this._nativeSize[0] * 0.5;
const nativeCenterY = this._nativeSize[1] * 0.5;
const nativeCenterX = (this._nativeSize[0] / this.cameraState.zoom) * 0.5;
const nativeCenterY = (this._nativeSize[1] / this.cameraState.zoom) * 0.5;

const scratchBounds = drawable.getFastBounds();

const canvas = this.canvas;
// Ratio of the screen-space scale of the stage's canvas to the "native size" of the stage
const scaleFactor = canvas.width / this._nativeSize[0];
const scaleFactor = (canvas.width / this._nativeSize[0]) * this.cameraState.zoom;

// Bounds of the extracted drawable, in "canvas pixel space"
// (origin is 0, 0, destination is the canvas width, height).
Expand Down

0 comments on commit 7e61476

Please sign in to comment.