Class: MeasurementTool
Enables Cognite3DViewer to perform a point to point measurement. This can be achieved by selecting a point on the 3D Object and drag the pointer to required point to get measurement of the distance. The tools default measurement is in "Meters" as supported in Reveal, but it also provides user to customise the measuring units based on their convinience with the callback.
Examples
const measurementTool = new MeasurementTool(viewer);
measurementTool.enterMeasurementMode();
// ...
measurementTool.exitMeasurementMode();
// detach the tool from the viewer
measurementTool.dispose();
const measurementTool = new MeasurementTool(viewer, {distanceToLabelCallback: (distanceInMeters) => {
// 1 meters = 3.281 feet
const distancesInFeet = distanceInMeters * 3.281;
return { distanceInMeters: distancesInFeet, units: 'ft'};
}});
measurementTool.enterMeasurementMode();
Extends
Constructors
new MeasurementTool()
new MeasurementTool(
viewer
,options
?):MeasurementTool
Parameters
• viewer: Cognite3DViewer
• options?: MeasurementOptions
Returns
Overrides
Cognite3DViewerToolBase
. constructor
Defined in
packages/tools/src/Measurement/MeasurementTool.ts:93
Accessors
isInMeasurementMode
get
isInMeasurementMode():boolean
Returns measurement mode state, is measurement mode started or ended.
Returns
boolean
Defined in
packages/tools/src/Measurement/MeasurementTool.ts:56
Methods
addMeasurement()
addMeasurement(
startPoint
,endPoint
):Measurement
Adds a measurement directly. E.g. to restore a previous state programatically
Parameters
• startPoint: Vector3
• endPoint: Vector3
Returns
Defined in
packages/tools/src/Measurement/MeasurementTool.ts:288
dispose()
dispose():
void
Dispose Measurement Tool.
Returns
void
Overrides
Cognite3DViewerToolBase
. dispose
Defined in
packages/tools/src/Measurement/MeasurementTool.ts:396
enterMeasurementMode()
enterMeasurementMode():
void
Enter into point to point measurement mode.
Returns
void
Defined in
packages/tools/src/Measurement/MeasurementTool.ts:237
exitMeasurementMode()
exitMeasurementMode():
void
Exit measurement mode.
Returns
void
Defined in
packages/tools/src/Measurement/MeasurementTool.ts:255
getAllMeasurements()
getAllMeasurements():
Measurement
[]
Get all measurements from Cognite3DViewer.
Returns
Array of Measurements containing Id, start point, end point & measured distance.
Defined in
packages/tools/src/Measurement/MeasurementTool.ts:375
off()
Unsubscribe to the Measurement event
Param
MeasurementEvents
event
Param
Callback to measurements events
off(event, callback)
off(
event
,callback
):void
Parameters
• event: "disposed"
• callback: DisposedDelegate
Returns
void
Overrides
Example
measurementTool.off('disposed', onMeasurementDispose);
Defined in
packages/tools/src/Measurement/MeasurementTool.ts:181
off(event, callback)
off(
event
,callback
):void
Parameters
• event: "added"
• callback: MeasurementAddedDelegate
Returns
void
Overrides
Cognite3DViewerToolBase.off
Example
measurementTool.off('added', onMeasurementAdded);