Skip to main content

TerrainQuadTree

Manages hierarchical quad-tree of terrain chunks with dynamic LOD.

Constructor

Parameters:
  • config - Optional configuration overrides
Returns: TerrainQuadTree instance Example:

Methods

setListener

Sets the listener for geometry generation/destruction events. Parameters:
  • listener - Object implementing QuadTreeListener interface
Example:

update

Main update method - call every frame or when player moves significantly. Parameters:
  • playerX - Player world X coordinate
  • playerZ - Player world Z coordinate
Returns: true if tree structure changed, false otherwise Example:

getFinalNodes

Gets all leaf nodes that currently have (or need) visual geometry. Returns: Array of TerrainQuadNode instances Example:

dispose

Destroys all chunks and resets state. Example:

Properties

totalNodeCount

Total number of nodes in the tree (for debug stats). Example:

visualChunkCount

Number of nodes with active visual geometry (for debug stats). Example:

TerrainQuadNode

Individual node in the terrain quad-tree.

Properties

Methods

check

Checks if node should split/unsplit based on camera distance.

update

Updates terrain generation requests for this node and children.

setNeighbours

Sets neighbor nodes in cardinal directions. Parameters:
  • n - North neighbor
  • e - East neighbor
  • s - South neighbor
  • w - West neighbor

isInside

Checks if a point is inside this node’s bounding box. Parameters:
  • x - World X coordinate
  • z - World Z coordinate
Returns: true if point is inside, false otherwise

getDeepestNodeAt

Gets the deepest (most subdivided) node containing a point. Parameters:
  • x - World X coordinate
  • z - World Z coordinate
Returns: Deepest node containing point, or null if not found

QuadTreeListener

Interface for receiving quad-tree events.

onNodeNeedsGeometry

Called when a node needs terrain geometry generated. Parameters:
  • node - Node that needs geometry
Implementation:

onNodeDestroyGeometry

Called when a node’s geometry should be destroyed. Parameters:
  • node - Node whose geometry should be destroyed
Implementation:

QuadTreeConfig

Configuration for terrain quad-tree LOD system.

Fields

Example


Type Definitions

QuadPosition

Position of a child node within its parent.

CardinalDirection

Cardinal direction for neighbor relationships.

Biome API

BiomeType enum and tree configuration API

Tree Instancing API

GLBTreeBatchedInstancer API reference

Terrain System

TerrainSystem API for height queries

World API

World class and system management