From a0ea5776abfac250ff6d9aab6cb78ef5e361df5a Mon Sep 17 00:00:00 2001 From: Xeltica <7106976+Xeltica@users.noreply.github.com> Date: Sun, 12 Jul 2020 00:39:45 +0900 Subject: [PATCH] fix #6335 (#6507) --- src/client/scripts/room/room.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/client/scripts/room/room.ts b/src/client/scripts/room/room.ts index e73a951342..45ccd59b70 100644 --- a/src/client/scripts/room/room.ts +++ b/src/client/scripts/room/room.ts @@ -516,8 +516,8 @@ export class Room { if (this.isTransformMode) return; const rect = (ev.target as HTMLElement).getBoundingClientRect(); - const x = (((ev.clientX * window.devicePixelRatio) - rect.left) / this.canvas.width) * 2 - 1; - const y = -(((ev.clientY * window.devicePixelRatio) - rect.top) / this.canvas.height) * 2 + 1; + const x = ((ev.clientX - rect.left) / rect.width) * 2 - 1; + const y = -((ev.clientY - rect.top) / rect.height) * 2 + 1; const pos = new THREE.Vector2(x, y); this.camera.updateMatrixWorld(); @@ -553,8 +553,8 @@ export class Room { if (ev.target !== this.canvas || ev.button !== 0) return; const rect = (ev.target as HTMLElement).getBoundingClientRect(); - const x = (((ev.clientX * window.devicePixelRatio) - rect.left) / this.canvas.width) * 2 - 1; - const y = -(((ev.clientY * window.devicePixelRatio) - rect.top) / this.canvas.height) * 2 + 1; + const x = ((ev.clientX - rect.left) / rect.width) * 2 - 1; + const y = -((ev.clientY - rect.top) / rect.height) * 2 + 1; const pos = new THREE.Vector2(x, y); this.camera.updateMatrixWorld();