Options
All
  • Public
  • Public/Protected
  • All
Menu

Octrees are a really powerful data structure that can quickly select entities based on space coordinates.

see

https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees

Type parameters

  • T

Hierarchy

  • Octree

Index

Constructors

  • new Octree<T>(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number, maxDepth?: number): Octree<T>
  • Type parameters

    • T

    Parameters

    • creationFunc: (entry: T, block: OctreeBlock<T>) => void

      function to be used to instantiate the octree

    • 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<T>

Properties

blocks: OctreeBlock<T>[]

Blocks within the octree containing objects

dynamicContent: T[]

Content stored in the octree

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.)

CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void

Type declaration

CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void

Type declaration

Methods

  • addMesh(entry: T): void
  • Adds a mesh to the octree

    Parameters

    • entry: T

      Mesh to add to the octree

    Returns void

  • intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>
  • 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

  • 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

  • removeMesh(entry: T): void
  • Remove an element from the octree

    Parameters

    • entry: T

      defines the element to remove

    Returns void

  • 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

  • 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

Legend

  • Constructor
  • Property
  • Method
  • Property
  • Method
  • Static property
  • Static method
  • Inherited constructor

Settings

Theme