From a6077e2483a9886d648cbe86325acc4e31d623fc Mon Sep 17 00:00:00 2001 From: KPal <48248865+kpal81xd@users.noreply.github.com> Date: Tue, 30 Jan 2024 18:45:08 +0000 Subject: [PATCH] constant gizmo size on canvas resize (#6028) --- extras/gizmo/gizmo.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/extras/gizmo/gizmo.js b/extras/gizmo/gizmo.js index 092821fe78a..ec370ac121f 100644 --- a/extras/gizmo/gizmo.js +++ b/extras/gizmo/gizmo.js @@ -18,6 +18,7 @@ const xdir = new Vec3(); // constants const MIN_GIZMO_SCALE = 1e-4; const PERS_SCALE_RATIO = 0.3; +const PERS_CANVAS_RATIO = 1300; const ORTHO_SCALE_RATIO = 0.32; /** @@ -362,7 +363,11 @@ class Gizmo extends EventHandler { _updateScale() { if (this._camera.projection === PROJECTION_PERSPECTIVE) { - this._scale = this._getProjFrustumWidth() * PERS_SCALE_RATIO; + let canvasMult = 1; + if (this._device.width > 0 && this._device.height > 0) { + canvasMult = PERS_CANVAS_RATIO / Math.min(this._device.width, this._device.height); + } + this._scale = this._getProjFrustumWidth() * canvasMult * PERS_SCALE_RATIO; } else { this._scale = this._camera.orthoHeight * ORTHO_SCALE_RATIO; }