Skip to main content

MeasurementUtils

Utility component for performing measurements on 3D meshes by providing methods for measuring distances between edges and faces. 📕 Tutorial. 📘 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

getFace()

getFace(mesh, triangleIndex, instance?): null | object

Method to get the face of a mesh that contains a given triangle index. It also returns the edges of the found face and their indices.

Parameters

ParameterTypeDescription
meshMesh<BufferGeometry<NormalBufferAttributes>, Material | Material[], Object3DEventMap> | InstancedMesh<BufferGeometry<NormalBufferAttributes>, Material | Material[]>The mesh to get the face from. It must be indexed.
triangleIndexnumberThe index of the triangle within the mesh.
instance?numberThe instance of the mesh (optional).

Returns

null | object

An object containing the edges of the found face and their indices, or null if no face was found.


getVerticesAndNormal()

getVerticesAndNormal(mesh, faceIndex, instance): object

Method to get the vertices and normal of a mesh face at a given index. It also applies instance transformation if provided.

Parameters

ParameterTypeDescription
meshMesh<BufferGeometry<NormalBufferAttributes>, Material | Material[], Object3DEventMap> | InstancedMesh<BufferGeometry<NormalBufferAttributes>, Material | Material[]>The mesh to get the face from. It must be indexed.
faceIndexnumberThe index of the face within the mesh.
instanceundefined | numberThe instance of the mesh (optional).

Returns

object

An object containing the vertices and normal of the face.

faceNormal

faceNormal: Vector3

p1

p1: Vector3

p2

p2: Vector3

p3

p3: Vector3

Throws

Will throw an error if the geometry is not indexed.


getVolumeFromFragments()

getVolumeFromFragments(frags): number

Calculates the volume of a set of fragments.

Parameters

ParameterTypeDescription
fragsFragmentIdMapA map of fragment IDs to their corresponding item IDs.

Returns

number

The total volume of the fragments and the bounding sphere.

Remarks

This method creates a set of instanced meshes from the given fragments and item IDs. It then calculates the volume of each mesh and returns the total volume and its bounding sphere.

Throws

Will throw an error if the geometry of the meshes is not indexed.

Throws

Will throw an error if the fragment manager is not available.


getVolumeFromMeshes()

getVolumeFromMeshes(meshes): number

Calculates the total volume of a set of meshes.

Parameters

ParameterTypeDescription
meshesMesh<BufferGeometry<NormalBufferAttributes>, Material | Material[], Object3DEventMap>[] | InstancedMesh<BufferGeometry<NormalBufferAttributes>, Material | Material[]>[]An array of meshes or instanced meshes to calculate the volume from.

Returns

number

The total volume of the meshes and the bounding sphere.

Remarks

This method calculates the volume of each mesh in the provided array and returns the total volume and its bounding sphere.


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.


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.