Class OctreeBlock<T>
Type Parameters
- T
Constructors
constructor
-
new OctreeBlock<T>(
minPoint: Vector3,
maxPoint: Vector3,
capacity: number,
depth: number,
maxDepth: number,
creationFunc: (entry: T, block: OctreeBlock<T>) => void,
): OctreeBlock<T>Creates a new block
Type Parameters
- T
Parameters
- minPoint: Vector3
defines the minimum vector (in world space) of the block's bounding box
- maxPoint: Vector3
defines the maximum vector (in world space) of the block's bounding box
- capacity: number
defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
- depth: number
defines the current depth of this block in the octree
- maxDepth: number
defines the maximal depth allowed (beyond this value, the capacity is ignored)
- creationFunc: (entry: T, block: OctreeBlock<T>) => void
defines a callback to call when an element is added to the block
Returns OctreeBlock<T>
Accessors
capacity
-
get capacity(): number
Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
Returns number
max Point
-
Gets the maximum vector (in world space) of the block's bounding box
Returns Vector3
min Point
-
Gets the minimum vector (in world space) of the block's bounding box
Returns Vector3
Methods
add Entries
-
Add an array of elements to this block
Parameters
- entries: T[]
defines the array of elements to add
Returns void
- entries: T[]
add Entry
create Inner Blocks
-
Subdivide the content into child blocks (this block will then be empty)
Returns void
intersects
-
intersects(
sphereCenter: Vector3,
sphereRadius: number,
selection: SmartArrayNoDuplicate<T>,
allowDuplicate?: boolean,
): voidTest if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
Parameters
- sphereCenter: Vector3
defines the bounding sphere center
- sphereRadius: number
defines the bounding sphere radius
- selection: SmartArrayNoDuplicate<T>
defines the array to store current content if selection is positive
OptionalallowDuplicate: booleandefines if the selection array can contains duplicated entries
Returns void
- sphereCenter: Vector3
intersects Ray
-
Test if the current block intersect with the given ray and if yes, then add its content to the selection array
Parameters
- ray: Ray
defines the ray to test with
- selection: SmartArrayNoDuplicate<T>
defines the array to store current content if selection is positive
Returns void
- ray: Ray
remove Entry
select
-
select(
frustumPlanes: Plane[],
selection: SmartArrayNoDuplicate<T>,
allowDuplicate?: boolean,
): voidTest if the current block intersects the frustum planes and if yes, then add its content to the selection array
Parameters
- frustumPlanes: Plane[]
defines the frustum planes to test
- selection: SmartArrayNoDuplicate<T>
defines the array to store current content if selection is positive
OptionalallowDuplicate: booleandefines if the selection array can contains duplicated entries
Returns void
- frustumPlanes: Plane[]
Class used to store a cell in an octree
See
https://doc.babylonjs.com/features/featuresDeepDive/scene/optimizeOctrees