From 7e61476e16ba3e8419bcd238290e4efc6cfc2048 Mon Sep 17 00:00:00 2001 From: LilyMakesThings Date: Wed, 9 Oct 2024 02:41:56 +0100 Subject: [PATCH] zooming kinda --- src/Drawable.js | 5 +++++ src/RenderWebGL.js | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Drawable.js b/src/Drawable.js index d9a2355f4..2aada21ac 100644 --- a/src/Drawable.js +++ b/src/Drawable.js @@ -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; + // this._position[0] /= cameraState.zoom; + // this._position[1] /= cameraState.zoom; + this._renderer.dirty = true; this.setTransformDirty(); } diff --git a/src/RenderWebGL.js b/src/RenderWebGL.js index a0a2f8822..e508a15b6 100644 --- a/src/RenderWebGL.js +++ b/src/RenderWebGL.js @@ -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).