import { Line2, Vector2, type Box2 } from '../math'; import type { SnapConfig } from '../configs/types'; import type { VFXItem } from '@galacean/effects'; import type { GizmoOwner } from '../gizmo-owner'; /** 位移吸附结果。 */ export type TranslationSnapResult = { /** x 方向吸附距离 */ x?: number; /** y 方向吸附距离 */ y?: number; /** x 方向点吸附信息 */ xPoints?: TranslationPointSnapTarget[]; /** y 方向点吸附信息 */ yPoints?: TranslationPointSnapTarget[]; }; /** 平移点吸附信息。 */ export type TranslationPointSnapTarget = { /** 包围盒点 */ point: Vector2; /** 吸附点 */ targets: Vector2[]; }; /** * 画布吸附管理器。 * * 由交互宿主持有,行为经 GizmoOwner 访问。负责吸附求解、目标缓存结果与临时 * snapping visualizations,不参与 Gizmo 派发、命中或 capture;visualizations * 由宿主的统一 overlay 渲染入口绘制。 */ export declare class SnapManager { /** 当前吸附结果。 */ result: TranslationSnapResult; private readonly _owner; /** 吸附对齐结果(对齐线集合)。 */ private results; /** 当前拖拽会话缓存的吸附目标。 */ private targetBoxes; constructor(owner: GizmoOwner); get enabled(): boolean; get config(): Readonly; /** * 为一次选区交互缓存吸附目标。目标过滤沿用原有 MoveSelection 规则; * 行为只提供场景 items 与当前选区,后续求解直接消费本缓存。 */ cacheSnapTargetsForSelection(items: readonly VFXItem[], selectedItems: readonly VFXItem[], containerSize: Vector2): void; /** 直接缓存已经投影到视图空间的吸附目标包围盒。 */ cacheSnapTargetBoxes(boxes: readonly Box2[]): void; /** 清空当前拖拽会话的吸附目标缓存。 */ clearCache(): void; /** 当前缓存包围盒的只读视图。 */ getSnapTargetBoxes(): readonly Box2[]; /** 当前缓存目标的角点与中心点,用于手柄点吸附。 */ getSnapTargetPoints(): Vector2[]; /** * 包围盒位移吸附功能。 * @param shift 偏移值 * @param box 目标包围盒 * @param otherBoxes 吸附包围盒 * @param xEnabled 是否进行 x 轴吸附 * @param yEnabled 是否进行 y 轴吸附 */ prepareBox(shift: Vector2, box: Box2, otherBoxes?: readonly Box2[], xEnabled?: boolean, yEnabled?: boolean): void; /** * 点位移吸附功能。 * @param shift 偏移值 * @param point 目标点 * @param otherPoints 吸附点集合 */ preparePoint(shift: Vector2, point: Vector2, otherPoints?: readonly Vector2[], xEnabled?: boolean, yEnabled?: boolean): void; /** * 获取点吸附结果。 * @param point 目标点 * @param other 吸附点 */ private _considerPointSnap; /** * 刷新吸附结果。 * @param point 目标点 * @param other 吸附点 * @param direction 吸附方向 */ private _updatePointSnapResult; /** 基于吸附结果生成对齐结果。 */ private update; /** 返回当前 snapping visualizations(视图坐标)。 */ getSnappingVisualizations(): readonly Line2[]; /** 清空吸附修正量与临时 visualizations,保留本次会话的目标缓存。 */ clearSnappingVisualizations(): void; /** 清空目标缓存、吸附结果与临时 visualizations。 */ reset(): void; }