import { RenderManagerBase } from './RenderManagerBase'; import { InstancedMesh, Line, Mesh, Plane, Vector3 } from 'three'; export declare enum PickerIntersectionType { None = "line", Face = "face", Point = "point", Line = "line" } interface PickerIntersectionFace { a: Vector3; b: Vector3; c: Vector3; normal: Vector3; } interface PickerIntersection { type: PickerIntersectionType; point: Vector3; distance: number; face?: PickerIntersectionFace; elNum?: number; } /** * A Tool for manual user picking points on faces and vertices and finding their coordinates and normal. */ export declare class Picker { private renderManager; private helperSnap; private helper; private isActive; private messageContainer; private readonly viewerElement; /** * Additional objects with picking capability. */ additionalObjects: Set; /** * Whether the selection of elements during picking is locked or not. */ isBlockSelection: boolean; /** * The point on vertex or face from the picking ray. */ rayPoint: Vector3; /** * The normal of the face on which the {@link rayPoint} is located. */ rayFaceNormal: Vector3; /** * The type of active intersection. */ intersectionType: PickerIntersectionType; /** * Is there a intersection with picking ray and vertex or face. */ hasIntersection: boolean; private isStopAtClick; /** Defer heavy raycast to once per animation frame while hovering. */ private needsPickerHoverUpdate; private snapToPoints; private snapToLines; private snapToWorkPlane; workPlane: Plane | null; private pickCallback; private endCallback; private beforeEndCallback; private message; /** * @param renderManager - {@link RenderManagerBase} instance. * @param viewerElement - viewer HTML element. */ constructor(renderManager: RenderManagerBase, viewerElement: HTMLElement); private onKeyDown; private onClick; /** * Add callback for 'pick' event. Callback stores only for one picking session called by {@link startPicking}. If callback returns false then 'end' event will chanceled. * @param callback - Callback function. */ onPick(callback: (intersectionType: PickerIntersectionType, rayPoint: Vector3, rayFaceNormal: Vector3) => void): this; private updateMessageContainer; /** * Set optional message for user during the picking process. The message is active only for one picking session called by {@link startPicking}. * @param message - Hint message. */ setMessage(message: string): this; /** * Set optional work plane to allow picking point in empty space. * @param plane - Work plane */ setWorkPlane(plane: Plane | null): this; /** * Add callback for end picking event. Callback stores only for one picking session called by {@link startPicking}. * @param callback - Callback function. */ onEnd(callback: (isCanceled: boolean) => void): this; /** * Add callback for end picking event. Callback stores only for one picking session called by {@link startPicking}. * @param callback - Callback function. The callback must return true, false, or undefined. If the callback returns false, the "end picking" operation will be aborted and the picker will remain active. */ onBeforeEnd(callback: (isCanceled: boolean) => boolean | void): this; /** * Starts picking action. * @param blockSelection - Block selection of elements during picking or not. * @param stopAtClick - Stop picking after the first click or continue onward. * @param snapToPoints - Snap to vertices or on faces. * @param snapToLines - Snap to vertices on lines. * @param snapToWorkPlane - Snap to work plane in empty space. * @returns Picker instance if picking started successfully or undefined if not. */ startPicking(blockSelection?: boolean, stopAtClick?: boolean, snapToPoints?: boolean, snapToLines?: boolean, snapToWorkPlane?: boolean): Picker | undefined; /** * End picking action. * @param isCanceled - Action result. Will be passed to the callbacks. * @return True if picking has been ended successfully. */ endPicking(isCanceled?: boolean): boolean; private onResize; render(): void; /** * Run from the render loop: applies deferred hover picking at most once per frame. */ update(): void; private onMouseWheel; private onMouseMove; private findClosestVertexOnFace; private calculateThresholdFromPoint; private intersectObject; private intersectAdditionalObjects; private intersectOutlineObjects; private intersectSceneObjects; /** * Returns the ray–surface intersection point for a specific element. * Traverses the BVH of all meshes, filtering triangles by the _elementnum attribute. * Occlusion by other elements is ignored. * Returns null if the ray does not hit the element's geometry. */ getElementSurfacePoint(targetElNum: number): Vector3 | null; private intersectSceneObjectsForElement; /** * BVH traversal filtered by targetElNum via the _elementnum attribute. * Triangles belonging to other elements are skipped without intersection testing. * All triangles of the target element are tested regardless of occlusion. */ private intersectObjectForElement; /** * A Get intersection with scene object below mouse coords. */ getSceneIntersection(): PickerIntersection[]; private updateHelperPos; private updateHelperScale; /** * Destroy picker and release all events. */ dispose(): void; } export {};