Skip to content
Snippets Groups Projects
Commit f30b3a41 authored by Alexander Rose's avatar Alexander Rose
Browse files

init camera for fly mode

- like for pointer-lock
parent c440ba2d
No related branches found
No related tags found
No related merge requests found
......@@ -380,8 +380,8 @@ namespace TrackballControls {
const moveEye = Vec3();
function moveCamera(deltaT: number) {
const minDistance = Math.max(camera.state.minNear, p.minDistance);
Vec3.sub(moveEye, camera.position, camera.target);
const minDistance = Math.max(camera.state.minNear, p.minDistance);
Vec3.setMagnitude(moveEye, moveEye, minDistance);
const moveSpeed = deltaT * (60 / 1000) * p.moveSpeed * (keyState.boostMove === 1 ? p.boostMoveFactor : 1);
......@@ -710,11 +710,16 @@ namespace TrackballControls {
}
}
function initCameraMove() {
Vec3.sub(moveEye, camera.position, camera.target);
const minDistance = Math.max(camera.state.minNear, p.minDistance);
Vec3.setMagnitude(moveEye, moveEye, minDistance);
Vec3.sub(camera.target, camera.position, moveEye);
}
function onLock(isLocked: boolean) {
if (isLocked) {
Vec3.sub(moveEye, camera.position, camera.target);
Vec3.setMagnitude(moveEye, moveEye, camera.state.minNear);
Vec3.sub(camera.target, camera.position, moveEye);
initCameraMove();
}
}
......@@ -806,6 +811,9 @@ namespace TrackballControls {
if (props.animate?.name === 'rock' && p.animate.name !== 'rock') {
resetRock(); // start rocking from the center
}
if (props.flyMode && !p.flyMode) {
initCameraMove();
}
Object.assign(p, props);
Object.assign(b, props.bindings);
},
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment