deglitched rotations

feature-faces
Mike Lynch 2023-07-28 10:47:33 +10:00
parent 766b3b8e6e
commit 183e6becb2
1 changed files with 12 additions and 11 deletions

23
main.js
View File

@ -173,28 +173,29 @@ const dragK = 0.005;
let theta = 0; let theta = 0;
let psi = 0; let psi = 0;
let startX = 0; let theta0 = 0;
let startY = 0; let psi0 = 0;
let startX0 = 0; let dragx0 = 0;
let startY0 = 0; let dragy0 = 0;
renderer.domElement.addEventListener("mousedown", (event) => { renderer.domElement.addEventListener("mousedown", (event) => {
if( event.buttons === 1 ) { if( event.buttons === 1 ) {
startX = event.clientX; theta0 = theta;
startY = event.clientY; psi0 = psi;
startX0 = theta / dragK; dragx0 = event.clientX;
startY0 = theta / dragK; dragy0 = event.clientY;
} }
}) })
renderer.domElement.addEventListener("mousemove", (event) => { renderer.domElement.addEventListener("mousemove", (event) => {
if( event.buttons === 1 ) { if( event.buttons === 1 ) {
theta = (event.clientX - startX + startX0) * dragK; theta = theta0 + (event.clientX - dragx0) * dragK;
psi = (event.clientY - startY + startY0) * dragK; psi = psi0 + (event.clientY - dragy0) * dragK;
} }
}) })
// set up GUI // set up GUI
const gui = new GUI(); const gui = new GUI();