Skip to content

Documentation / scene / OctreeNode

Class: OctreeNode

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

A single node (cell) within the octree hierarchy.

Remarks

  • Holds scene graph nodes that spatially belong to the node's region.
  • Computes tight and loosed AABBs on demand.
  • Provides navigation to parent/children based on placement.

Constructors

Constructor

new OctreeNode(): OctreeNode

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

Create an empty octree node.

Returns

OctreeNode

Remarks

Nodes are created and wired by OctreeNodeChunk.

Methods

getNodes()

getNodes(): GraphNode[]

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

Get all scene nodes contained in this octree node.

Returns

GraphNode[]

An array of scene nodes currently held by this octree node.

Remarks

The returned array is owned by the node and may be mutated internally.


getLevel()

getLevel(): number

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

Get the hierarchical level index of this node.

Returns

number

The level index of this octree node.

Remarks

Level 0 is the root chunk; higher levels are finer subdivisions.


addNode()

addNode(node): void

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

Add a scene node to this octree node.

Parameters

node

GraphNode

Scene node to add.

Returns

void


removeNode()

removeNode(node): void

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

Remove a scene node from this octree node.

Parameters

node

GraphNode

Scene node to remove.

Returns

void


clearNodes()

clearNodes(): void

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

Remove all scene nodes from this octree node.

Returns

void


setChunk()

setChunk(chunk): void

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

Assign the chunk that owns this node.

Parameters

chunk

OctreeNodeChunk

Owning chunk.

Returns

void


getChunk()

getChunk(): OctreeNodeChunk

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

Get the chunk that owns this node.

Returns

OctreeNodeChunk

The OctreeNodeChunk that owns this node.


setPosition()

setPosition(index): void

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

Set the node's linear position index within the owning chunk.

Parameters

index

number

Position index.

Returns

void


getPosition()

getPosition(): number

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

Get the node's linear position index within the owning chunk.

Returns

number

The linear position index of this node.


getBox()

getBox(): AABB

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

Get the tight AABB of this node, computed from its existing children.

Returns

AABB

The tight AABB of this node, or null if unavailable.

Remarks

  • Computed lazily by merging all child boxes from the next chunk level.
  • Returns null if no child contributes a valid box.

getBoxLoosed()

getBoxLoosed(): AABB

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

Get the loosed AABB of this node.

Returns

AABB

The loosed AABB of this node.

Remarks

The loosed AABB expands the node by half a node size in each direction, forming a conservative region used for stable placement.


getMinPoint()

getMinPoint(): Vector3

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

Get the minimum (tight) corner point of this node in world space.

Returns

Vector3

The minimum corner as a Vector3.


getMaxPoint()

getMaxPoint(): Vector3

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

Get the maximum (tight) corner point of this node in world space.

Returns

Vector3

The maximum corner as a Vector3.


getMinPointLoosed()

getMinPointLoosed(): Vector3

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

Get the loosed minimum corner point of this node in world space.

Returns

Vector3

The loosed minimum corner as a Vector3.


getMaxPointLoosed()

getMaxPointLoosed(): Vector3

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

Get the loosed maximum corner point of this node in world space.

Returns

Vector3

The loosed maximum corner as a Vector3.


getChild()

getChild(placement): OctreeNode

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

Get a child node by placement from the next (finer) chunk.

Parameters

placement

OctreePlacement

Child octant placement.

Returns

OctreeNode

The child OctreeNode, or null if not present.

Remarks

Returns null if the next chunk does not exist or the child is absent.


getOrCreateChild()

getOrCreateChild(placement): OctreeNode

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

Get or create a child node by placement from the next (finer) chunk.

Parameters

placement

OctreePlacement

Child octant placement.

Returns

OctreeNode

The existing or newly created child OctreeNode, or null if creation is not possible.

Remarks

Returns null if the next chunk does not exist.


getParent()

getParent(): OctreeNode

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

Get the parent node from the previous (coarser) chunk.

Returns

OctreeNode

The parent OctreeNode, or null if not present.

Remarks

Returns null if the previous chunk does not exist or the parent is absent.


getOrCreateParent()

getOrCreateParent(): OctreeNode

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

Get or create the parent node from the previous (coarser) chunk.

Returns

OctreeNode

The existing or newly created parent OctreeNode, or null if creation is not possible.

Remarks

Returns null if the previous chunk does not exist.


createChildren()

createChildren(): void

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

Create all eight children for this node in the next (finer) chunk.

Returns

void

Remarks

No-op when the next chunk does not exist.


traverse()

traverse(v): void

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

Traverse this node and existing children in pre-order.

Parameters

v

Visitor<OctreeNode>

Visitor invoked on each node; if it returns true, traversal continues into children.

Returns

void

Remarks

Children are visited in octant order [PPP, PPN, PNP, PNN, NPP, NPN, NNP, NNN].

Released under the MIT License.