Skip to main content

MeasurementUtils

Utility component for performing measurements on 3D meshes by providing methods for measuring distances between edges and faces. 📘 API.

Extends

Properties

enabled

enabled: boolean = true

Component.enabled

Overrides

Component . enabled


uuid

static uuid: string = "267ca032-672f-4cb0-afa9-d24e904f39d6"

A unique identifier for the component. This UUID is used to register the component within the Components system.

Methods

getItemsVolume()

getItemsVolume(modelIdMap): Promise<number>

Calculates the total volume of items for a given map of model IDs to local IDs.

Parameters

ParameterTypeDescription
modelIdMapModelIdMapA map where the key is the model ID and the value is an array of local IDs.

Returns

Promise<number>

A promise that resolves to the total volume of the specified items.


getVolumeFromFragments()

getVolumeFromFragments(modelIdMap): Promise<number>

Parameters

ParameterType
modelIdMapModelIdMap

Returns

Promise<number>

Deprecated

Use getItemsVolume instead.

Calculates the volume of a set of items.


isConfigurable()

isConfigurable(): this is Configurable<any, any>

Whether is component is Configurable.

Returns

this is Configurable<any, any>

Inherited from

Component . isConfigurable


isDisposeable()

isDisposeable(): this is Disposable

Whether is component is Disposable.

Returns

this is Disposable

Inherited from

Component . isDisposeable


isHideable()

isHideable(): this is Hideable

Whether is component is Hideable.

Returns

this is Hideable

Inherited from

Component . isHideable


isResizeable()

isResizeable(): this is Resizeable

Whether is component is Resizeable.

Returns

this is Resizeable

Inherited from

Component . isResizeable


isUpdateable()

isUpdateable(): this is Updateable

Whether is component is Updateable.

Returns

this is Updateable

Inherited from

Component . isUpdateable


round()

round(vector): void

Method to round the vector's components to a specified number of decimal places. This is used to ensure numerical precision in edge detection.

Parameters

ParameterTypeDescription
vectorVector3The vector to round.

Returns

void

The vector with rounded components.


convertUnits()

static convertUnits(value, fromUnit, toUnit, precision): number

Converts a value from one unit to another for length, area, or volume without using external libraries.

Parameters

ParameterTypeDefault valueDescription
valuenumberundefinedThe value to convert.
fromUnitstringundefinedThe unit of the input value (e.g., "m", "cm", "mm" for lengths; "m2", "cm2" for areas; "m3", "cm3" for volumes).
toUnitstringundefinedThe unit to convert to (e.g., "cm", "mm", "m" for lengths; "cm2", "m2" for areas; "cm3", "m3" for volumes).
precisionnumber2The number of decimal places to round the result to, as number between 0 and 5. (default is 2).

Returns

number

The converted value rounded to the specified precision.

Throws

If the rounding value is not a valid integer or is out of range (0-5).


distanceFromPointToLine()

static distanceFromPointToLine(point, lineStart, lineEnd, clamp): number

Utility method to calculate the distance from a point to a line segment.

Parameters

ParameterTypeDefault valueDescription
pointVector3undefinedThe point from which to calculate the distance.
lineStartVector3undefinedThe start point of the line segment.
lineEndVector3undefinedThe end point of the line segment.
clampbooleanfalseIf true, the distance will be clamped to the line segment's length.

Returns

number

The distance from the point to the line segment.