Skip to content

Documentation / scene / OctreeNodeChunk

Class: OctreeNodeChunk ​

Defined in: libs/scene/src/scene/octree.ts:362

A grid of octree nodes at a specific level of detail.

Remarks ​

  • Each chunk represents a uniform grid of (d x d x d) nodes, where (d = 2^{level}).
  • Chunks are linked as a hierarchy from coarse (root) to fine (leaf) via prev/next.
  • Nodes are created lazily and indexed by a linear index.

Constructors ​

Constructor ​

new OctreeNodeChunk(octree): OctreeNodeChunk

Defined in: libs/scene/src/scene/octree.ts:382

Create a chunk for the given octree.

Parameters ​

octree ​

Octree

Owning octree.

Returns ​

OctreeNodeChunk

Methods ​

getNode() ​

getNode(index): OctreeNode

Defined in: libs/scene/src/scene/octree.ts:402

Get an octree node by linear index.

Parameters ​

index ​

number

Linear index within this chunk.

Returns ​

OctreeNode

The OctreeNode at the index, or null if absent.


getOrCreateNode() ​

getOrCreateNode(index): OctreeNode

Defined in: libs/scene/src/scene/octree.ts:412

Get or create an octree node by linear index.

Parameters ​

index ​

number

Linear index within this chunk.

Returns ​

OctreeNode

The existing or newly created OctreeNode.


getOrCreateNodeChain() ​

getOrCreateNodeChain(index): OctreeNode

Defined in: libs/scene/src/scene/octree.ts:429

Ensure the node chain (this level and all parents) exists for a given index.

Parameters ​

index ​

number

Linear index at this level.

Returns ​

OctreeNode

The OctreeNode at this level; parent nodes are created as needed.


clearNodes() ​

clearNodes(): void

Defined in: libs/scene/src/scene/octree.ts:442

Remove and clear all nodes in this chunk.

Returns ​

void

Remarks ​

Also detaches all scene nodes held by each OctreeNode.


getChildIndex() ​

getChildIndex(index, placement): number

Defined in: libs/scene/src/scene/octree.ts:456

Compute the child index in the next chunk for a given parent index and placement.

Parameters ​

index ​

number

Parent node index in this chunk.

placement ​

OctreePlacement

Child octant placement.

Returns ​

number

The linear index of the child in the next chunk.


getParentIndex() ​

getParentIndex(index): number

Defined in: libs/scene/src/scene/octree.ts:504

Compute the parent index in the previous chunk for a given child index.

Parameters ​

index ​

number

Child node index in this chunk.

Returns ​

number

The linear index of the parent in the previous chunk.


getNodeSize() ​

getNodeSize(): number

Defined in: libs/scene/src/scene/octree.ts:520

Node size at this chunk level.

Returns ​

number

The world-space edge length per cell in this chunk.

Remarks ​

Represents the world-space edge length for a cell at this level.


getWorldSize() ​

getWorldSize(): number

Defined in: libs/scene/src/scene/octree.ts:531

Root world size of the octree.

Returns ​

number

The root world size (edge length) of the octree.

Remarks ​

Same across all chunks; used to convert between world coordinates and indices.


getDimension() ​

getDimension(): number

Defined in: libs/scene/src/scene/octree.ts:542

Dimension of this chunk (number of cells per axis).

Returns ​

number

The dimension (cells per axis) for this chunk.

Remarks ​

Equals (2^{level}).


getLevel() ​

getLevel(): number

Defined in: libs/scene/src/scene/octree.ts:550

Level index of this chunk (0 = root/coarsest).

Returns ​

number

The level index of this chunk.


empty() ​

empty(): boolean

Defined in: libs/scene/src/scene/octree.ts:558

Whether this chunk currently has no created nodes.

Returns ​

boolean

True if the chunk has no nodes; otherwise false.


getNext() ​

getNext(): OctreeNodeChunk

Defined in: libs/scene/src/scene/octree.ts:566

Next (finer) chunk in the hierarchy, or null if this is the finest.

Returns ​

OctreeNodeChunk

The next OctreeNodeChunk, or null if none.


getPrev() ​

getPrev(): OctreeNodeChunk

Defined in: libs/scene/src/scene/octree.ts:574

Previous (coarser) chunk in the hierarchy, or null if this is the root.

Returns ​

OctreeNodeChunk

The previous OctreeNodeChunk, or null if none.


getOctree() ​

getOctree(): Octree

Defined in: libs/scene/src/scene/octree.ts:582

The octree that owns this chunk.

Returns ​

Octree

The owning Octree instance.


setLevel() ​

setLevel(level): void

Defined in: libs/scene/src/scene/octree.ts:590

Set the level index.

Parameters ​

level ​

number

Level index for this chunk.

Returns ​

void


setDimension() ​

setDimension(dimension): void

Defined in: libs/scene/src/scene/octree.ts:598

Set the dimension (cells per axis).

Parameters ​

dimension ​

number

Dimension for this chunk (typically (2^{level})).

Returns ​

void


setNodeSize() ​

setNodeSize(size): void

Defined in: libs/scene/src/scene/octree.ts:606

Set the node size at this level.

Parameters ​

size ​

number

World-space edge length per cell.

Returns ​

void


setNext() ​

setNext(chunk): void

Defined in: libs/scene/src/scene/octree.ts:614

Link to the next (finer) chunk.

Parameters ​

chunk ​

OctreeNodeChunk

The next chunk.

Returns ​

void


setPrev() ​

setPrev(chunk): void

Defined in: libs/scene/src/scene/octree.ts:622

Link to the previous (coarser) chunk.

Parameters ​

chunk ​

OctreeNodeChunk

The previous chunk.

Returns ​

void

Released under the MIT License.