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
Overrides
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
Parameter | Type | Description |
---|---|---|
mesh | Mesh <BufferGeometry <NormalBufferAttributes >, Material | Material [], Object3DEventMap > | InstancedMesh <BufferGeometry <NormalBufferAttributes >, Material | Material []> | The mesh to get the face from. It must be indexed. |
triangleIndex | number | The index of the triangle within the mesh. |
instance ? | number | The 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
Parameter | Type | Description |
---|---|---|
mesh | Mesh <BufferGeometry <NormalBufferAttributes >, Material | Material [], Object3DEventMap > | InstancedMesh <BufferGeometry <NormalBufferAttributes >, Material | Material []> | The mesh to get the face from. It must be indexed. |
faceIndex | number | The index of the face within the mesh. |
instance | undefined | number | The 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
Parameter | Type | Description |
---|---|---|
frags | FragmentIdMap | A 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
Parameter | Type | Description |
---|---|---|
meshes | Mesh <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
isDisposeable()
isDisposeable():
this is Disposable
Whether is component is Disposable.
Returns
this is Disposable
Inherited from
isHideable()
isHideable():
this is Hideable
Whether is component is Hideable.
Returns
this is Hideable
Inherited from
isResizeable()
isResizeable():
this is Resizeable
Whether is component is Resizeable.
Returns
this is Resizeable
Inherited from
isUpdateable()
isUpdateable():
this is Updateable
Whether is component is Updateable.
Returns
this is Updateable
Inherited from
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
Parameter | Type | Description |
---|---|---|
vector | Vector3 | The 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
Parameter | Type | Default value | Description |
---|---|---|---|
point | Vector3 | undefined | The point from which to calculate the distance. |
lineStart | Vector3 | undefined | The start point of the line segment. |
lineEnd | Vector3 | undefined | The end point of the line segment. |
clamp | boolean | false | If true, the distance will be clamped to the line segment's length. |
Returns
number
The distance from the point to the line segment.