mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-28 21:19:52 +01:00
fix: doubled range
This commit is contained in:
1 parent
b65c3c1d93
commit
7c29046390
1 file changed
+7
-6
@@ -38,14 +38,15 @@ export function applyPitchYawLimits(
|
|||||||
const range = degToRad(pitchLimits.back.range);
|
const range = degToRad(pitchLimits.back.range);
|
||||||
const yawRotatedAbs = Math.abs(normalizeAngleRad(newYaw - Math.PI));
|
const yawRotatedAbs = Math.abs(normalizeAngleRad(newYaw - Math.PI));
|
||||||
|
|
||||||
if (yawRotatedAbs <= range + transition) {
|
if (yawRotatedAbs <= range / 2 + transition) {
|
||||||
if (yawRotatedAbs <= range) {
|
if (yawRotatedAbs <= range / 2) {
|
||||||
// inside range
|
// inside range
|
||||||
lowerPitch = -degToRad(pitchLimits.back.max);
|
lowerPitch = -degToRad(pitchLimits.back.max);
|
||||||
upperPitch = -degToRad(pitchLimits.back.min);
|
upperPitch = -degToRad(pitchLimits.back.min);
|
||||||
} else {
|
} else {
|
||||||
// inside transition
|
// inside transition
|
||||||
const transitionProgress = (yawRotatedAbs - range) / transition;
|
const transitionProgress = (yawRotatedAbs - range / 2) / transition;
|
||||||
|
// console.log(transitionProgress);
|
||||||
const maxInterpolatedPitch =
|
const maxInterpolatedPitch =
|
||||||
(1 - transitionProgress) * pitchLimits.back.max +
|
(1 - transitionProgress) * pitchLimits.back.max +
|
||||||
transitionProgress * pitchLimits.max;
|
transitionProgress * pitchLimits.max;
|
||||||
@@ -63,14 +64,14 @@ export function applyPitchYawLimits(
|
|||||||
const range = degToRad(pitchLimits.front.range);
|
const range = degToRad(pitchLimits.front.range);
|
||||||
const yawAbs = Math.abs(normalizeAngleRad(newYaw));
|
const yawAbs = Math.abs(normalizeAngleRad(newYaw));
|
||||||
|
|
||||||
if (yawAbs <= range + transition) {
|
if (yawAbs <= range / 2 + transition) {
|
||||||
if (yawAbs <= range) {
|
if (yawAbs <= range / 2) {
|
||||||
// inside range
|
// inside range
|
||||||
lowerPitch = -degToRad(pitchLimits.front.max);
|
lowerPitch = -degToRad(pitchLimits.front.max);
|
||||||
upperPitch = -degToRad(pitchLimits.front.min);
|
upperPitch = -degToRad(pitchLimits.front.min);
|
||||||
} else {
|
} else {
|
||||||
// inside transition
|
// inside transition
|
||||||
const transitionProgress = (yawAbs - range) / transition;
|
const transitionProgress = (yawAbs - range / 2) / transition;
|
||||||
const maxInterpolatedPitch =
|
const maxInterpolatedPitch =
|
||||||
(1 - transitionProgress) * pitchLimits.front.max +
|
(1 - transitionProgress) * pitchLimits.front.max +
|
||||||
transitionProgress * pitchLimits.max;
|
transitionProgress * pitchLimits.max;
|
||||||
|
|||||||
Reference in new issue
Block a user