feat(npcs): free rotate overlays and drop session zoom tools
Drag the top-edge handle to rotate the whole frame with the avatar; remove unused zoom controls from the session NPC window. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -5,6 +5,8 @@ export type NpcsOverlayLayout = {
|
||||
cx: number;
|
||||
cy: number;
|
||||
scale: number;
|
||||
/** Свободный угол поворота, градусы. */
|
||||
rotationDeg: number;
|
||||
};
|
||||
|
||||
export type NpcsZoomTool = 'zoomIn' | 'zoomOut' | null;
|
||||
@@ -24,6 +26,7 @@ export const DEFAULT_NPCS_OVERLAY_LAYOUT: NpcsOverlayLayout = {
|
||||
cx: 0.5,
|
||||
cy: 0.5,
|
||||
scale: 1,
|
||||
rotationDeg: 0,
|
||||
};
|
||||
|
||||
export type NpcsOverlayEvent =
|
||||
@@ -34,11 +37,19 @@ export type NpcsOverlayEvent =
|
||||
| { kind: 'zoomTool.set'; tool: NpcsZoomTool }
|
||||
| { kind: 'zoomAt'; nx: number; ny: number; npcId?: NpcId };
|
||||
|
||||
/** Нормализация угла в диапазон [0, 360). */
|
||||
export function normalizeNpcsRotation(deg: number): number {
|
||||
if (!Number.isFinite(deg)) return 0;
|
||||
const n = deg % 360;
|
||||
return n < 0 ? n + 360 : n;
|
||||
}
|
||||
|
||||
export function clampNpcsLayout(layout: NpcsOverlayLayout): NpcsOverlayLayout {
|
||||
return {
|
||||
cx: Math.min(1.2, Math.max(-0.2, layout.cx)),
|
||||
cy: Math.min(1.2, Math.max(-0.2, layout.cy)),
|
||||
scale: Math.min(8, Math.max(0.15, layout.scale)),
|
||||
rotationDeg: normalizeNpcsRotation(layout.rotationDeg ?? 0),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user