import type { Five } from '@realsee/five'; import * as THREE from 'three'; import { PointSelector } from '../shared-utils'; import { MeasureMesh } from './utils/MeasureMesh'; import { Subscribe } from '../shared-utils/Subscribe'; import type { MeasurePluginConfig } from '.'; export type MeasureEndReason = 'enter' | 'escape' | 'polygon' | 'mode_change' | 'pano_move' | 'floor_change' | 'points_insufficient' | 'external'; /** Current actions available to a measurement UI. */ export type MeasureInteractionState = Readonly<{ phase: 'idle' | 'drawing' | 'holding' | 'editing'; measurementCount: number; pointCount: number; result?: 'confirmed' | 'cancelled'; }>; export type MeasurePluginEventMap = { measureEnd: (reason: MeasureEndReason, points: THREE.Vector3[]) => void; undo: () => void; interactionChange: (state: MeasureInteractionState) => void; }; export declare class MeasureController extends Subscribe { readonly name = "MeasurePlugin"; currentMeasureMesh?: MeasureMesh | null; /** 双击快速测量结束后,用命中点继续下一段测量(由当前测量会话提供) */ protected continueMeasureFrom?: (end: THREE.Vector3) => void; private five; private group; private currentEndReason; private repositioningState; private longPressIndicator; private cleanupPendingPress?; private cleanupRepositioningListeners?; private endpointPointerElement?; private endpointPressHandlers; private interactionPhase; private interactionResult?; get interactionState(): MeasureInteractionState; private publishInteraction; get pointSelector(): PointSelector; private _pointSelector; /** 放大镜用户开关,默认开启;关闭后选点流程不变,只是不显示放大镜 */ private _magnifierEnabled; get magnifierEnabled(): boolean; /** * 开关放大镜(用户可见的「开启放大器」)。 * 运行时生效,也在下次创建选点器时沿用,不需要重新开始测量。 */ setMagnifierEnabled(enabled: boolean): void; protected createPointSelector(): PointSelector; private get fiveDomEvents(); private _fiveDomEvents; private get cursor(); private _cursor; get config(): MeasurePluginConfig; set config(config: MeasurePluginConfig); private _config?; private lineStyle; private polygonStyle; constructor(five: Five, config?: MeasurePluginConfig); /** * @description Initialize event listeners for all existing meshes */ initEventListeners: () => void; /** * 取消所有测量结果的选中态。 * 组内还并存着预览用的临时对象(点 / 线 / 多边形),它们没有选中态,需要跳过。 */ private unselectAllMeasureMeshes; /** * @description 开始测量 */ measure: () => void; /** * @description 结束测量 */ endMeasure: () => void; /** * @description 通过Enter键结束测量 */ private endMeasureByEnter; /** * @description 通过模式改变结束测量 */ private endMeasureByModeChange; /** * @description 通过全景移动结束测量 */ private endMeasureByPanoMove; /** * @description 通过楼层改变结束测量 */ private endMeasureByFloorChange; /** * Enable or disable the display of length measurements * @param enable - Whether to display length measurements */ setLengthEnable: (enable: boolean) => void; /** * Switch the measurement unit without resetting the plugin * @param unit - The new unit to use ('m' for metric, 'ft' for imperial, or 'mm' for millimeters) */ setUnit: (unit: 'm' | 'ft' | 'mm') => void; /** * Set the precision for length measurements * @param precision - For metric (`m`): decimal places. For imperial (`ft`): inch fraction denominator (1 | 4 | 8 | 16). * Area measurements remain at fixed 2 decimal places. */ setPrecision: (precision: number) => void; /** * @description 取消本次测量 */ cancel: () => void; /** * @description 撤销上一步 */ undo: () => void; /** * @description 清空正在测量的内容 */ clearCurrentMeasure: () => void; /** * @description 清空所有测量内容 */ clear: () => void; dispose: () => void; private listener; private onMoveToPano; private onModeChange; private onClick; private onHover; private onUnHover; private deleteSelectedMesh; private removeMeshEventListeners; private removeEndpointLongPressListeners; private updateSelectAdsorbedHelper; private addMeshEventListeners; private onEndpointPointerDown; private addEndpointLongPressListeners; /** * @description Load measurement data from external source * @param data Array of point data for measurements */ load: (data: { points: THREE.Vector3[]; }[]) => void; /** * Start repositioning an endpoint */ private startRepositioning; /** * Helper method to safely update polygon points while maintaining closure */ private updatePolygonPoints; /** * Handle mouse movement during repositioning */ private onRepositioningMove; /** * Confirm repositioning with click */ private onRepositioningConfirm; /** * Confirm repositioning when drag ends (mouse up after long press drag) */ private confirmRepositioningOnDragEnd; /** * Cancel repositioning (restore original position) */ private cancelRepositioning; /** * Apply or remove repositioning preview styling */ private applyRepositioningStyle; /** Track one editing pointer; hover and other pointers cannot move its endpoint. */ private enableGlobalPointerTracking; /** * Show long press visual feedback circle */ private showLongPressIndicator; /** * Hide long press visual feedback circle */ private hideLongPressIndicator; /** * Prevent Five canvas gestures during repositioning */ private preventFiveGestures; /** * Clean up repositioning state and event listeners */ private cleanupRepositioning; }