shmoov zoomin

This commit is contained in:
Luca Conte 2025-04-25 19:46:50 +02:00
parent 7f3e1da3b9
commit 5a0cbe6e35
1 changed files with 4 additions and 1 deletions

View File

@ -34,6 +34,7 @@ let virtualRealInterpolation = 1;
let cameraPitch = 0.565;
let cameraYaw = 0.375;
let cameraDistance = 4;
let smoothCameraDistance = 4;
let mouseDragging = false;
@ -434,6 +435,8 @@ async function draw() {
virtualRealInterpolation = Math.max(virtualRealInterpolation - deltaTime * 2, 0);
}
smoothCameraDistance += (cameraDistance - smoothCameraDistance) / 8;
updateStats(deltaTime);
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
@ -448,7 +451,7 @@ async function draw() {
mat4BuildPerspective(realProjectionMatrix, 90.0 / 180.0 * Math.PI, cv.width / cv.height, 0.1, 30);
let realViewMatrix = [];
let realCameraPosition = [Math.cos(cameraYaw) * cameraDistance * Math.cos(cameraPitch), Math.sin(cameraPitch) * cameraDistance, Math.sin(cameraYaw) * cameraDistance * Math.cos(cameraPitch)];
let realCameraPosition = [Math.cos(cameraYaw) * smoothCameraDistance * Math.cos(cameraPitch), Math.sin(cameraPitch) * smoothCameraDistance, Math.sin(cameraYaw) * smoothCameraDistance * Math.cos(cameraPitch)];
let realCameraLookAt = [0, 0, 0];
let realCameraUp = [0, 1, 0];
// if (cameraPitch > -0.1) {