From f2f5a267298d065f56ea10b82ee1053a660b4ea1 Mon Sep 17 00:00:00 2001 From: leca Date: Fri, 1 Dec 2023 14:42:42 +0300 Subject: [PATCH] Fixed zoom-dependent rotation --- view/controls.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/view/controls.js b/view/controls.js index 4d2ffbd..6e7afa3 100644 --- a/view/controls.js +++ b/view/controls.js @@ -1,16 +1,15 @@ import { Euler, MathUtils, Quaternion, Vector3 } from "three"; import { getDistance, setDistance, getCameraPosition, setCameraPostion, rotateCamera, getCanvasSize, getCameraRotation, getCameraQuaternion } from "./graphics.js"; -let r = 5 let isMousePressed = false let angle = 0; const updateCameraPosition = (horizontal, vertical) => { - let ratio = 2 * Math.PI * r / getCanvasSize().width; + let ratio = 4 * Math.PI / getCanvasSize().width; let distance = getDistance(); - let alpha = (360 * (horizontal * ratio / (2 * Math.PI * distance))) ; + let alpha = (360 * (horizontal * ratio / (2 * Math.PI))) ; let betta = MathUtils.degToRad(angle); let x = Math.cos(betta) * distance; let z = Math.sin(betta) * distance;