@soonspacejs/plugin-measuring
Version:
Measuring plugin for SoonSpace.js
118 lines (117 loc) • 3.51 kB
TypeScript
import SoonSpace, { PoiNode } from 'soonspacejs';
import { BufferGeometry, Camera, Line, LineBasicMaterial, Mesh, MeshBasicMaterial, Object3D, Scene, Sprite, SpriteMaterial, Vector3 } from 'three';
import { Options } from './utils/ProjectSettingsDef';
export declare enum MeasuringMode {
Distance = "Distance",
Area = "Area",
Angle = "Angle"
}
/**
* MeasuringPlugin
*/
declare class MeasuringPlugin {
readonly ssp: SoonSpace;
static LINE_MATERIAL: LineBasicMaterial;
static MESH_MATERIAL: MeshBasicMaterial;
static MAX_DISTANCE: number;
static OBJ_NAME: string;
static LABEL_NAME: string;
mode: MeasuringMode | null;
protected options: Required<Options>;
protected scene: Scene;
protected camera: Camera;
protected spriteMaterial?: SpriteMaterial;
objectsStore: Set<Object3D<import("three").Object3DEventMap>>;
onCancel: () => void;
onDone: () => void;
protected pointMarkers: Sprite[];
protected polyline?: Line;
protected faces?: Mesh;
protected curve?: Line;
protected labels: PoiNode[];
protected pointArray: Vector3[];
protected tempPointMarker?: Sprite;
protected tempLine?: Line;
protected tempLabel?: PoiNode;
protected lastClickTime?: number;
constructor(ssp: SoonSpace);
get domElement(): HTMLDivElement;
/**
* Starts the measurement
*/
start(mode?: MeasuringMode, options?: Options): void;
/**
* Ends the measurement
*/
close(): void;
cancel(): void;
clear(): void;
/**
* Initializes point marker material
*/
initPointMarkerMaterial(): void;
/**
* Creates point marker
*/
private createPointMarker;
/**
* Creates Line
*/
private createLine;
/**
* Creates Mesh
*/
private createFaces;
/**
* Draw completed
*/
done(): void;
mousemove: (e: MouseEvent) => void;
dblclick: (e: MouseEvent) => void;
click: (e: MouseEvent) => void;
keydown: (e: KeyboardEvent) => void;
/**
* The the closest intersection
* @param e
*/
getClosestIntersection: (e: MouseEvent) => Vector3 | null | undefined;
/**
* Adds or update temp label and position
*/
addOrUpdateTempLabel(label: string, position: Vector3): void;
/**
* Creates label
*/
createLabel(text: string): PoiNode;
/**
* Creates the arc curve to indicate the angle in degree
*/
createCurve(p0: Vector3, p1: Vector3, p2: Vector3): Line<BufferGeometry<import("three").NormalBufferAttributes, import("three").BufferGeometryEventMap>, LineBasicMaterial, import("three").Object3DEventMap>;
/**
* Calculates area
* TODO: for concave polygon, the value doesn't right, need to fix it
* @param points
*/
calculateArea(points: Vector3[]): number;
/**
* Gets included angle of two lines in degree
*/
calculateAngle(startPoint: Vector3, middlePoint: Vector3, endPoint: Vector3): number;
/**
* Gets angle bisector of two lines
*/
getAngleBisector(startPoint: Vector3, middlePoint: Vector3, endPoint: Vector3): Vector3;
/**
* Get the barycenter of points
*/
getBarycenter(points: Vector3[]): Vector3;
/**
* Gets unit string for distance, area or angle
*/
getUnitString(): string;
/**
* Converts a number to a string with proper fraction digits
*/
numberToString(num: number): string;
}
export default MeasuringPlugin;