feat(rotation): implement rotation utilities and enhance angle input handling

This commit is contained in:
alam00000
2026-05-09 14:21:07 +05:30
parent bef12f1d23
commit 7a6cd61286
4 changed files with 170 additions and 51 deletions
+17
View File
@@ -0,0 +1,17 @@
export const ROTATION_MIN = -360;
export const ROTATION_MAX = 360;
export const ROTATION_STEP = 0.1;
export function clampRotation(value: number): number {
return Math.max(ROTATION_MIN, Math.min(ROTATION_MAX, value));
}
export function roundToStep(value: number): number {
return Math.round(value * 10) / 10;
}
export function parseAngleInput(raw: string, fallback = 0): number {
const parsed = parseFloat(raw);
if (!Number.isFinite(parsed)) return fallback;
return clampRotation(roundToStep(parsed));
}