Skip to main content
Version: Next

Class: ClosestGeometryFinder<T>

Defined in: packages/utilities/src/ClosestGeometryFinder.ts:12

Beta

A utility class to find and store the closest geometry to a given origin point.

Type Parameters​

T​

T

The type of the geometry.

Constructors​

Constructor​

new ClosestGeometryFinder<T>(origin): ClosestGeometryFinder<T>

Defined in: packages/utilities/src/ClosestGeometryFinder.ts:22

Beta

Creates an instance of ClosestGeometryFinder.

Parameters​

origin​

Vector3

The origin point from which distances are measured.

Returns​

ClosestGeometryFinder<T>

Accessors​

minDistance​

Get Signature​

get minDistance(): number

Defined in: packages/utilities/src/ClosestGeometryFinder.ts:41

Beta

Gets the minimum distance to the closest geometry.

Returns​

number

The minimum distance.

Set Signature​

set minDistance(value): void

Defined in: packages/utilities/src/ClosestGeometryFinder.ts:32

Beta

Sets the minimum distance to the closest geometry.

Parameters​
value​

number

The minimum distance.

Returns​

void

Methods​

add()​

add(point, geometry): boolean

Defined in: packages/utilities/src/ClosestGeometryFinder.ts:93

Beta

Adds a geometry if the given point is closer to the origin than the current closest geometry.

Parameters​

point​

Vector3

The point associated with the geometry.

geometry​

T

The geometry to add.

Returns​

boolean

True if the geometry was added, false otherwise.


addLazy()​

addLazy(point, geometryCreator): boolean

Defined in: packages/utilities/src/ClosestGeometryFinder.ts:108

Beta

Lazily adds a geometry if the given point is closer to the origin than the current closest geometry.

Parameters​

point​

Vector3

The point associated with the geometry.

geometryCreator​

() => T

A function that creates the geometry to add.

Returns​

boolean

True if the geometry was added, false otherwise.


clear()​

clear(): void

Defined in: packages/utilities/src/ClosestGeometryFinder.ts:81

Beta

Clears the closest geometry and resets the minimum distance.

Returns​

void


getClosestGeometry()​

getClosestGeometry(): T | undefined

Defined in: packages/utilities/src/ClosestGeometryFinder.ts:50

Beta

Gets the closest geometry found so far.

Returns​

T | undefined

The closest geometry or undefined if no geometry has been added.


isClosest()​

isClosest(point): boolean

Defined in: packages/utilities/src/ClosestGeometryFinder.ts:69

Beta

Checks if a given point is closer to the origin than the current closest geometry.

Parameters​

point​

Vector3

The point to check.

Returns​

boolean

True if the point is closer, false otherwise.


setClosestGeometry()​

setClosestGeometry(geometry): void

Defined in: packages/utilities/src/ClosestGeometryFinder.ts:59

Beta

Sets the closest geometry.

Parameters​

geometry​

T

The geometry to set as the closest.

Returns​

void