1
1
mirror of https://github.com/kokonect-link/cherrypick synced 2024-12-11 13:18:54 +09:00
This commit is contained in:
Xeltica 2020-07-12 00:39:45 +09:00 committed by GitHub
parent 9b73e897df
commit a0ea5776ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -516,8 +516,8 @@ export class Room {
if (this.isTransformMode) return; if (this.isTransformMode) return;
const rect = (ev.target as HTMLElement).getBoundingClientRect(); const rect = (ev.target as HTMLElement).getBoundingClientRect();
const x = (((ev.clientX * window.devicePixelRatio) - rect.left) / this.canvas.width) * 2 - 1; const x = ((ev.clientX - rect.left) / rect.width) * 2 - 1;
const y = -(((ev.clientY * window.devicePixelRatio) - rect.top) / this.canvas.height) * 2 + 1; const y = -((ev.clientY - rect.top) / rect.height) * 2 + 1;
const pos = new THREE.Vector2(x, y); const pos = new THREE.Vector2(x, y);
this.camera.updateMatrixWorld(); this.camera.updateMatrixWorld();
@ -553,8 +553,8 @@ export class Room {
if (ev.target !== this.canvas || ev.button !== 0) return; if (ev.target !== this.canvas || ev.button !== 0) return;
const rect = (ev.target as HTMLElement).getBoundingClientRect(); const rect = (ev.target as HTMLElement).getBoundingClientRect();
const x = (((ev.clientX * window.devicePixelRatio) - rect.left) / this.canvas.width) * 2 - 1; const x = ((ev.clientX - rect.left) / rect.width) * 2 - 1;
const y = -(((ev.clientY * window.devicePixelRatio) - rect.top) / this.canvas.height) * 2 + 1; const y = -((ev.clientY - rect.top) / rect.height) * 2 + 1;
const pos = new THREE.Vector2(x, y); const pos = new THREE.Vector2(x, y);
this.camera.updateMatrixWorld(); this.camera.updateMatrixWorld();