Fixed zoom-dependent rotation
This commit is contained in:
parent
07ef091ae1
commit
f2f5a26729
|
@ -1,16 +1,15 @@
|
||||||
import { Euler, MathUtils, Quaternion, Vector3 } from "three";
|
import { Euler, MathUtils, Quaternion, Vector3 } from "three";
|
||||||
import { getDistance, setDistance, getCameraPosition, setCameraPostion, rotateCamera, getCanvasSize, getCameraRotation, getCameraQuaternion } from "./graphics.js";
|
import { getDistance, setDistance, getCameraPosition, setCameraPostion, rotateCamera, getCanvasSize, getCameraRotation, getCameraQuaternion } from "./graphics.js";
|
||||||
|
|
||||||
let r = 5
|
|
||||||
let isMousePressed = false
|
let isMousePressed = false
|
||||||
|
|
||||||
let angle = 0;
|
let angle = 0;
|
||||||
|
|
||||||
const updateCameraPosition = (horizontal, vertical) => {
|
const updateCameraPosition = (horizontal, vertical) => {
|
||||||
let ratio = 2 * Math.PI * r / getCanvasSize().width;
|
let ratio = 4 * Math.PI / getCanvasSize().width;
|
||||||
let distance = getDistance();
|
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 betta = MathUtils.degToRad(angle);
|
||||||
let x = Math.cos(betta) * distance;
|
let x = Math.cos(betta) * distance;
|
||||||
let z = Math.sin(betta) * distance;
|
let z = Math.sin(betta) * distance;
|
||||||
|
|
Loading…
Reference in New Issue