forked from phenom/healer-man
Release Healer Man 0.1.49
This commit is contained in:
1 parent
39425f2494
commit
612170afd0
91 files changed
+2278
-263
No files matched your search
@@ -7,6 +7,8 @@ export interface SpectatorCameraAxes {
|
||||
}
|
||||
|
||||
const MAX_CAMERA_FRAME_SECONDS = 0.1;
|
||||
const KEYBOARD_YAW_RADIANS_PER_SECOND = 2.25;
|
||||
const KEYBOARD_PITCH_RADIANS_PER_SECOND = 1.55;
|
||||
|
||||
function held(codes: ReadonlySet<string>, ...candidates: readonly string[]): number {
|
||||
return Number(candidates.some((code) => codes.has(code)));
|
||||
@@ -24,6 +26,20 @@ export function spectatorCameraBoosted(codes: ReadonlySet<string>): boolean {
|
||||
return codes.has("ShiftLeft") || codes.has("ShiftRight");
|
||||
}
|
||||
|
||||
/** Returns frame-bounded arrow-key look deltas in the same orientation as mouse look. */
|
||||
export function spectatorKeyboardLookDelta(
|
||||
codes: ReadonlySet<string>,
|
||||
deltaSeconds: number,
|
||||
): readonly [horizontal: number, vertical: number] {
|
||||
const seconds = Number.isFinite(deltaSeconds)
|
||||
? Math.max(0, Math.min(MAX_CAMERA_FRAME_SECONDS, deltaSeconds))
|
||||
: 0;
|
||||
return [
|
||||
(held(codes, "ArrowRight") - held(codes, "ArrowLeft")) * seconds * KEYBOARD_YAW_RADIANS_PER_SECOND,
|
||||
(held(codes, "ArrowDown") - held(codes, "ArrowUp")) * seconds * KEYBOARD_PITCH_RADIANS_PER_SECOND,
|
||||
];
|
||||
}
|
||||
|
||||
/** Returns a bounded, normalized free-flight translation for one render frame. */
|
||||
export function spectatorCameraTranslation(
|
||||
yaw: number,
|
||||
@@ -36,8 +52,10 @@ export function spectatorCameraTranslation(
|
||||
const forwardX = Math.sin(yaw) * Math.cos(pitch);
|
||||
const forwardY = Math.sin(pitch);
|
||||
const forwardZ = Math.cos(yaw) * Math.cos(pitch);
|
||||
const rightX = Math.cos(yaw);
|
||||
const rightZ = -Math.sin(yaw);
|
||||
// With Three's +Z-forward camera convention, screen-right is -X at zero
|
||||
// yaw. Keep this basis aligned with cameraRelativeMovement.
|
||||
const rightX = -Math.cos(yaw);
|
||||
const rightZ = Math.sin(yaw);
|
||||
let x = forwardX * axes.forward + rightX * axes.right;
|
||||
let y = forwardY * axes.forward + axes.vertical;
|
||||
let z = forwardZ * axes.forward + rightZ * axes.right;
|
||||
|
||||
Reference in new issue
Block a user