Release v0.1.6 2026-07-12
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
DEFAULT_CAMERA_PITCH,
|
||||
MAX_CAMERA_PITCH,
|
||||
MIN_CAMERA_PITCH,
|
||||
setCameraRelativeMovement,
|
||||
updateCameraOrbit,
|
||||
} from "./cameraOrbit";
|
||||
|
||||
describe("third-person camera orbit", () => {
|
||||
it("rotates horizontal movement with camera yaw", () => {
|
||||
const movement = { x: 0, z: 0 };
|
||||
|
||||
setCameraRelativeMovement(movement, 0, -1, 0);
|
||||
expect(movement.x).toBeCloseTo(0);
|
||||
expect(movement.z).toBeCloseTo(-1);
|
||||
|
||||
setCameraRelativeMovement(movement, 0, -1, Math.PI / 2);
|
||||
expect(movement.x).toBeCloseTo(-1);
|
||||
expect(movement.z).toBeCloseTo(0);
|
||||
});
|
||||
|
||||
it("applies look input and clamps vertical orbit", () => {
|
||||
const orbit = { yaw: 0, pitch: DEFAULT_CAMERA_PITCH };
|
||||
|
||||
updateCameraOrbit(orbit, 1, 0, 1);
|
||||
expect(orbit.yaw).toBeCloseTo(-2.25);
|
||||
|
||||
updateCameraOrbit(orbit, 0, 1, 10);
|
||||
expect(orbit.pitch).toBe(MAX_CAMERA_PITCH);
|
||||
|
||||
updateCameraOrbit(orbit, 0, -1, 10);
|
||||
expect(orbit.pitch).toBe(MIN_CAMERA_PITCH);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user