Class Octree<T>
Type parameters
-
T
Hierarchy
- Octree
Index
Constructors
Properties
Methods
Constructors
constructor
-
Creates a octree
Parameters
-
creationFunc: (entry: T, block: OctreeBlock<T>) => void
function to be used to instatiate the octree
-
-
Parameters
-
entry: T
-
block: OctreeBlock<T>
Returns void
-
-
-
-
Optional maxBlockCapacity: number
defines the maximum number of meshes you want on your octree's leaves (default: 64)
-
Optional maxDepth: number
defines the maximum depth (sub-levels) for your octree. Default value is 2, which means 8 8 8 = 512 blocks :) (This parameter takes precedence over capacity.)
Returns Octree
-
Properties
blocksSearch playground for blocks
Blocks within the octree containing objects
dynamic ContentSearch playground for dynamicContent
Content stored in the octree
max DepthSearch playground for maxDepth
Defines the maximum depth (sub-levels) for your octree. Default value is 2, which means 8 8 8 = 512 blocks :) (This parameter takes precedence over capacity.)
Static Creation Func For MeshesSearch playground for CreationFuncForMeshes
Adds a mesh into the octree block if it intersects the block
Type declaration
-
-
Parameters
-
entry: AbstractMesh
-
block: OctreeBlock<AbstractMesh>
Returns void
-
-
Static Creation Func For Sub MeshesSearch playground for CreationFuncForSubMeshes
Adds a submesh into the octree block if it intersects the block
Type declaration
-
-
Parameters
-
entry: SubMesh
-
block: OctreeBlock<SubMesh>
Returns void
-
-
Methods
add MeshSearch playground for addMesh
-
Adds a mesh to the octree
Parameters
-
entry: T
Mesh to add to the octree
Returns void
-
intersectsSearch playground for intersects
-
Test if the octree 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
-
Optional allowDuplicate: boolean
defines if the selection array can contains duplicated entries
Returns SmartArray<T>
an array of objects that intersect the sphere
-
intersects RaySearch playground for intersectsRay
-
Test if the octree intersect with the given ray and if yes, then add its content to resulting array
Parameters
-
ray: Ray
defines the ray to test with
Returns SmartArray<T>
array of intersected objects
-
remove MeshSearch playground for removeMesh
-
Remove an element from the octree
Parameters
-
entry: T
defines the element to remove
Returns void
-
selectSearch playground for select
-
Selects an array of meshes within the frustum
Parameters
-
frustumPlanes: Plane[]
The frustum planes to use which will select all meshes within it
-
Optional allowDuplicate: boolean
If duplicate objects are allowed in the resulting object array
Returns SmartArray<T>
array of meshes within the frustum
-
updateSearch playground for update
-
Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
Parameters
-
worldMin: Vector3
worldMin for the octree blocks var blockSize = new Vector3((worldMax.x - worldMin.x) / 2, (worldMax.y - worldMin.y) / 2, (worldMax.z - worldMin.z) / 2);
-
worldMax: Vector3
worldMax for the octree blocks var blockSize = new Vector3((worldMax.x - worldMin.x) / 2, (worldMax.y - worldMin.y) / 2, (worldMax.z - worldMin.z) / 2);
-
entries: T[]
meshes to be added to the octree blocks
Returns void
-
Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees