- 등고선 위를 지나거나 고른 직후 커서 옆에 자물쇠 단추(캔버스 위 DOM · aria-pressed · 호버 판정 = 집기와 같은 hitPreparedLayer) - 잠긴 동안 빈 곳 · 다른 가닥을 눌러도 고른 것 그대로 · 잠긴 높이 위에서만 눌린 단추가 떠 풂 - 높이값으로 쥠 — 분석 지형을 바꿔도 같은 높이 가닥을 다시 짚음 · 페이지 동안만(저장 안 함) - 새 파일 logic/B05_Profile_ContourLock(규칙) · UI_RouteEdit_ContourLock(단추) · 모양 css · RouteEdit.ts 는 고르기 · 지형 바꿈 두 줄 + 세우기만(700줄) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Se7ytqbohmBQnfYpwYFnYf
40 lines
1.9 KiB
TypeScript
40 lines
1.9 KiB
TypeScript
/* =============================================================================
|
|
* B05_Profile/logic/B05_Profile_ContourLock.ts
|
|
* 평면 등고선 고정(353-2) — 고른 높이 하나를 쥐고, 잠긴 동안 다른 지정을 막는 규칙.
|
|
*
|
|
* 높이값으로 쥔다(가닥 번호는 지형을 바꾸면 달라짐) · 페이지 동안만(저장 안 함).
|
|
* 순수 계산 — 화면 · three · fetch · sessionStorage 없음. 단추는 `B05_Profile_UI_RouteEdit_ContourLock`.
|
|
* ========================================================================== */
|
|
|
|
/** 가닥마다 높이(모르면 null). */
|
|
export type ContourLevels = ReadonlyArray<number | null>;
|
|
|
|
/** 자물쇠 단추 — 보일지 · 눌린 모양인지. */
|
|
export interface LockButtonState {
|
|
visible: boolean;
|
|
pressed: boolean;
|
|
}
|
|
|
|
/** 그 높이의 첫 가닥 번호 — 없으면 -1(지형을 바꾼 뒤 잠근 높이 다시 짚기). */
|
|
export function featureOfLevel(levels: ContourLevels, level: number | null): number {
|
|
if (level === null) return -1;
|
|
return levels.findIndex((value) => value === level);
|
|
}
|
|
|
|
/** 커서 아래 가닥 높이 · 잠근 높이 → 단추 — 안 잠김 = 높이 있는 가닥 위에서 · 잠김 = 그 높이 위에서만. */
|
|
export function lockButtonState(
|
|
hoverLevel: number | null,
|
|
lockedLevel: number | null,
|
|
): LockButtonState {
|
|
if (lockedLevel !== null) return { visible: hoverLevel === lockedLevel, pressed: true };
|
|
return { visible: hoverLevel !== null, pressed: false };
|
|
}
|
|
|
|
/** 단추 누름 — 잠김이면 풂(null) · 아니면 그 가닥 높이로 잠금. */
|
|
export function toggleLock(lockedLevel: number | null, targetLevel: number | null): number | null {
|
|
return lockedLevel !== null ? null : targetLevel;
|
|
}
|
|
|
|
/** 잠긴 동안은 고른 가닥이 안 바뀜(다른 가닥 · 빈 곳 눌러도). */
|
|
export const canPickContour = (lockedLevel: number | null): boolean => lockedLevel === null;
|