Skip to content

Commit

Permalink
constant gizmo size on canvas resize (#6028)
Browse files Browse the repository at this point in the history
  • Loading branch information
kpal81xd authored and Martin Valigursky committed Feb 2, 2024
1 parent e0e2281 commit a6077e2
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion extras/gizmo/gizmo.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit a6077e2

Please sign in to comment.