Constructor
new Octree(threshold, maxDepth)
- Source:
Properties:
Name | Type | Description |
---|---|---|
threshold |
number | A threshold indicating whether or not a further subdivision is needed based on the number of data points in the current node. |
maxDepth |
number | A maximum depth of the octree. |
points |
Object | An object storing the points belonging to each node indexed by the location id of the node. |
aabbs |
Object | An object storing the axis-aligned bounding boxes belonging to each node indexed by the location id of the node. |
Parameters:
Name | Type | Description |
---|---|---|
threshold |
number | A threshold indicating whether or not a further subdivision is needed based on the number of data points in the current node. |
maxDepth |
number | A maximum depth of the octree. |
Methods
(static) clone(original) → {Lore.Octree}
- Source:
Clones an octree.
Parameters:
Name | Type | Description |
---|---|---|
original |
Lore.Octree | The octree to be cloned. |
Returns:
The cloned octree.
- Type
- Lore.Octree
(static) concatTypedArrays(a, b) → {Array}
- Source:
Concatenates the two typed arrays a and b and returns a new array. The two arrays have to be of the same type. Due to performance reasons, there is no check whether the types match.
Parameters:
Name | Type | Description |
---|---|---|
a |
Array | The first array. |
b |
Array | The second array. |
Returns:
The concatenated array.
- Type
- Array
(static) mergeCellDistances(a, b) → {Object}
- Source:
Merges the two arrays (locCodes and distancesSq) in the cell distances object.
Parameters:
Name | Type | Description |
---|---|---|
a |
Object | The first cell distances object. |
b |
Object | The second cell distances object. |
Returns:
The concatenated cell distances object.
- Type
- Object
(static) mergePointDistances(a, b) → {Object}
- Source:
Merges the two arrays (indices and distancesSq) in the point distances object.
Parameters:
Name | Type | Description |
---|---|---|
a |
Object | The first point distances object. |
b |
Object | The second point distances object. |
Returns:
The concatenated point distances object.
- Type
- Object
build(pointIndices, vertices, aabb, locCode)
- Source:
Builds the octree by assigning the indices of data points and axis-aligned bounding boxes to assoziative arrays indexed by the location code.
Parameters:
Name | Type | Description |
---|---|---|
pointIndices |
Uint32Array | An set of points that are either sub-divided into sub nodes or assigned to the current node. |
vertices |
Float32Array | An array containing the positions of all the vertices. |
aabb |
PLOTTER.AABB | The bounding box of the current node. |
locCode |
number | A binary code encoding the id and the level of the current node. |
cellDistancesSq(x, y, z, locCode) → {Object}
- Source:
Returns a list of the cells neighbouring the cell with the provided locCode and the point specified by x, y and z.
Parameters:
Name | Type | Description |
---|---|---|
x |
number | The x-value of the coordinate. |
y |
number | The y-value of the coordinate. |
z |
number | The z-value of the coordinate. |
locCode |
number | The number of the axis-aligned bounding box. |
Returns:
An object containing arrays for the locCodes and the squred distances.
- Type
- Object
expandNeighbourhood(x, y, z, locCode, cellDistances) → {number}
- Source:
Expands the current neighbourhood around the cell where the point specified by x, y, z is in.
Parameters:
Name | Type | Description |
---|---|---|
x |
number | The x-value of the coordinate. |
y |
number | The y-value of the coordinate. |
z |
number | The z-value of the coordinate. |
locCode |
number | The location code of the cell containing the point. |
cellDistances |
Object | The object containing location codes and distances. |
Returns:
The number of added location codes.
- Type
- number
generateLocCode(The, The) → {number}
- Source:
Generates a location code for a node based on the full code of the parent and the code of the current node.
Parameters:
Name | Type | Description |
---|---|---|
The |
number | full location code of the parent node. |
The |
number | 3 bit code of the current node. |
Returns:
The full location code for the current node.
- Type
- number
getCellDistancesToPoint(x, y, z, locCode) → {Object}
- Source:
Calculates the distances from a given point to all of the cells containing points
Parameters:
Name | Type | Description |
---|---|---|
x |
number | The x-value of the coordinate. |
y |
number | The y-value of the coordinate. |
z |
number | The z-value of the coordinate. |
locCode |
number | The location code of the cell containing the point. |
Returns:
An object containing arrays for the locCodes and the squred distances.
- Type
- Object
getCenters() → {Array}
- Source:
Returns an array containing all the centers of the axis-aligned bounding boxes in this octree that have points associated with them.
Returns:
An array containing the centers as Lore.Vector3f objects.
- Type
- Array
getClosestBox(point, threshold, locCode) → {Lore.AABB}
- Source:
This function returns the closest box in the octree to the point given as an argument.
Parameters:
Name | Type | Description |
---|---|---|
point |
Lore.Vector3f | The point. |
threshold |
number | The minimum number of points an axis-aligned bounding box should contain to count as a hit. |
locCode |
number | The starting locCode, if not set, starts at the root. |
Returns:
The closest axis-aligned bounding box to the input point.
- Type
- Lore.AABB
getClosestBoxFromCenter(point, threshold, locCode) → {Lore.AABB}
- Source:
This function returns the closest box in the octree to the point given as an argument. The distance measured is to the box center.
Parameters:
Name | Type | Description |
---|---|---|
point |
Lore.Vector3f | The point. |
threshold |
number | The minimum number of points an axis-aligned bounding box should contain to count as a hit. |
locCode |
number | The starting locCode, if not set, starts at the root. |
Returns:
The closest axis-aligned bounding box to the input point.
- Type
- Lore.AABB
getClosestPoint(point, positions, threshold, locCode) → {Lore.Vector3f}
- Source:
Finds the closest point inside the octree to the point provided as an argument.
Parameters:
Name | Type | Description |
---|---|---|
point |
Lore.Vector3f | The point. |
positions |
Float32Array | An array containing the positions of the points. |
threshold |
number | Only consider points inside a axis-aligned bounding box with a minimum of [threshold] points. |
locCode |
number | If specified, the axis-aligned bounding box in which the point is searched for. If not set, all boxes are searched. |
Returns:
The position of the closest point.
- Type
- Lore.Vector3f
getDepth(locCode) → {number}
- Source:
Calculates the depth of the node from its location code.
Parameters:
Name | Type | Description |
---|---|---|
locCode |
number | A binary code encoding the id and the level of the current node. |
Returns:
The depth of the node with the provided location code.
- Type
- number
getFarthestBox(point, threshold, locCode) → {Lore.AABB}
- Source:
This function returns the farthest box in the octree to the point given as an argument.
Parameters:
Name | Type | Description |
---|---|---|
point |
Lore.Vector3f | The point. |
threshold |
number | The minimum number of points an axis-aligned bounding box should contain to count as a hit. |
locCode |
number | The starting locCode, if not set, starts at the root. |
Returns:
The farthest axis-aligned bounding box to the input point.
- Type
- Lore.AABB
getFarthestPoint(point, positions, threshold, locCode) → {Lore.Vector3f}
- Source:
Finds the farthest point inside the octree to the point provided as an argument.
Parameters:
Name | Type | Description |
---|---|---|
point |
Lore.Vector3f | The point. |
positions |
Float32Array | An array containing the positions of the points. |
threshold |
number | Only consider points inside a axis-aligned bounding box with a minimum of [threshold] points. |
locCode |
number | If specified, the axis-aligned bounding box in which the point is searched for. If not set, all boxes are searched. |
Returns:
The position of the farthest point.
- Type
- Lore.Vector3f
getLocCodes()
- Source:
Returns an array containing the location codes of all the axis-aligned bounding boxes inside this octree.
getNeighbours(locCode) → {Array}
- Source:
Find neighbouring axis-aligned bounding boxes.
Parameters:
Name | Type | Description |
---|---|---|
locCode |
number | The location code of the axis-aligned bounding box whose neighbours will be returned |
Returns:
An array of location codes of the neighbouring axis-aligned bounding boxes.
- Type
- Array
getParent(locCode)
- Source:
Returns the parent of a given location code by simply shifting it to the right by tree, removing the current code.
Parameters:
Name | Type | Description |
---|---|---|
locCode |
number | The location code of a node. |
kNearestNeighbours(k, point, locCode, positions, kNNCallback)
- Source:
Returns the k-nearest neighbours of a vertex.
Parameters:
Name | Type | Description |
---|---|---|
k |
number | The number of nearest neighbours to return. |
point |
number | The index of a vertex or a vertex. |
locCode |
number | The location code of the axis-aligned bounding box containing the vertex. If not set, the box is searched for. |
positions |
Float32Array | The position information for the points indexed in this octree. |
kNNCallback |
PLOTTER.Plot~kNNCallback | The callback that is called after the k-nearest neighbour search has finished. |
pointDistancesSq(x, y, z, locCode, positions) → {Object}
- Source:
Returns a list of the the squared distances of the points contained in the axis-aligned bounding box to the provided coordinates.
Parameters:
Name | Type | Description |
---|---|---|
x |
number | The x-value of the coordinate. |
y |
number | The y-value of the coordinate. |
z |
number | The z-value of the coordinate. |
locCode |
number | The number of the axis-aligned bounding box. |
positions |
Float32Array | The array containing the vertex coordinates. |
Returns:
An object containing arrays for the indices and distances.
- Type
- Object
raySearch(raycaster) → {Array}
- Source:
Searches for octree nodes that are intersected by the ray and returns all the points associated with those nodes.
Parameters:
Name | Type | Description |
---|---|---|
raycaster |
Lore.Raycaster | The raycaster used for checking for intersects. |
Returns:
A set of points which are associated with octree nodes intersected by the ray.
- Type
- Array
traverse(traverseCallback, locCode)
- Source:
Traverses the octree depth-first.
Parameters:
Name | Type | Description |
---|---|---|
traverseCallback |
PLOTTER.Octree~traverseCallback | Is called for each node where a axis-aligned bounding box exists. |
locCode |
number | The location code of the node that serves as the starting node for the traversion. |
traverseIf(traverseIfCallback, conditionCallback, locCode)
- Source:
Traverses the octree depth-first, does not visit nodes / subtrees if a condition is not met.
Parameters:
Name | Type | Description |
---|---|---|
traverseIfCallback |
PLOTTER.Octree~traverseIfCallback | Is called for each node where a axis-aligned bounding box exists and returns either true or false, with false stopping further exploration of the subtree. |
conditionCallback |
PLOTTER.Octree~conditionCallback | Is called to test whether or not a subtree should be explored. |
locCode |
number | The location code of the node that serves as the starting node for the traversion. |