Files
Aislo/B07_DesignDetail/openwebcad/src/helpers/pick-radius.ts
T

23 lines
865 B
TypeScript

/**
* 집기 반경 — 화면에서 몇 픽셀 안쪽을 "그 객체를 가리킨 것"으로 볼지.
* 상수는 화면 픽셀이므로 월드 거리로 쓰려면 확대율로 나눠야 한다. 나누지 않으면
* 확대할수록 반경이 같이 커져서(2000%에서 15 → 300px 넘음) 엉뚱한 객체가 잡힌다.
* 손가락으로 누른 동안은 접촉 크기(최소 24px)까지 넓힘(기기대응 4-4 · `input-touch.ts` 가 정함).
*/
import { HIGHLIGHT_ENTITY_DISTANCE } from '../App.consts';
import { getScreenCanvasDrawController } from '../state';
let touchPickPx = 0;
/** 0 = 마우스(원래 반경) */
export function setTouchPickPx(px: number): void {
touchPickPx = px;
}
export function pickRadius(): number {
return (
Math.max(HIGHLIGHT_ENTITY_DISTANCE, touchPickPx) /
getScreenCanvasDrawController().getScreenScale()
);
}