Taos API Reference
    Preparing search index...

    Class Chunk

    A 16x16x16 cube of blocks with axis convention X = width, Y = height (vertical), Z = depth.

    Owns the raw block array, tracks per-category block counts, and generates both terrain (generateBlocks) and renderable vertex meshes (generateVertices). Chunks are positioned in world space by globalPosition, which is the min-corner of the chunk.

    Index

    Constructors

    • Creates an empty chunk anchored at the given world-space min corner.

      Parameters

      • px: number

        world X of the chunk min corner

      • py: number

        world Y of the chunk min corner

      • pz: number

        world Z of the chunk min corner

      Returns Chunk

    Properties

    CHUNK_WIDTH: number = 16

    Chunk size in blocks along the X axis.

    CHUNK_HEIGHT: number = 16

    Chunk size in blocks along the vertical Y axis.

    CHUNK_DEPTH: number = 16

    Chunk size in blocks along the Z axis.

    SEA_LEVEL: number = 15

    Global Y level at which oceans and lakes are filled with water.

    OCEAN_DEPTH: number = 30

    Depth (in blocks below SEA_LEVEL) of the floor of a fully-deep ocean basin. The seabed lands near SEA_LEVEL - OCEAN_DEPTH (plus a few blocks of relief), so the default puts the deepest seabed around y = -15.

    CUBE_VERTS: Float32Array<ArrayBuffer> = ...

    Unit-cube vertex positions for 6 faces × 6 verts = 36 verts, ordered back/front/left/right/bottom/top.

    blocks: Uint16Array<ArrayBuffer> = ...
    globalPosition: Vec3 = ...
    opaqueIndex: number = -1
    transparentIndex: number = -1
    waterIndex: number = -1
    drawCommandIndex: number = -1
    chunkDataIndex: number = -1
    aabbTreeIndex: number = -1
    aliveBlocks: number = 0
    opaqueBlocks: number = 0
    transparentBlocks: number = 0
    waterBlocks: number = 0
    lightBlocks: number = 0
    isDeleted: boolean = false

    Methods

    • Builds opaque, semi-transparent, water, and prop vertex buffers for the chunk.

      Uses greedy meshing across X/Y/Z for cube faces and a padded copy of the block grid (with one layer of neighbor data) so boundary checks have no per-axis branching in the hot loop. Vertex layout is [x, y, z, normal(0-5 or 6 for billboard), blockType].

      Parameters

      • Optionalneighbors: ChunkNeighbors

        optional block arrays of the six neighbor chunks for face culling

      Returns ChunkMesh

      the populated ChunkMesh

    • Populates the chunk's blocks via 3D Perlin terrain, biome selection, caves, and a second pass that places trees and props.

      Parameters

      • seed: number

        world seed driving all noise

      • OptionalgetErosion: (gx: number, gz: number) => number

        optional per-column hydraulic erosion displacement sampler

      Returns void

    • Continentalness in [0, 1] for a world column: 0 = dry land, 1 = deep ocean, with a smooth continental-shelf ramp between the coast and the deep-water threshold. Driven by a single low-frequency noise so oceans form large coherent basins rather than scattered ponds.

      Parameters

      • gx: number

        world X

      • gz: number

        world Z

      • seed: number

        world seed

      Returns number

    • Parameters

      • gx: number
      • gz: number
      • seed: number

      Returns { t: number; h: number; s: number }

    • Sets the block at local coordinates and updates per-category counts.

      Out-of-bounds coordinates are silently ignored.

      Parameters

      • x: number

        local X in [0, CHUNK_WIDTH)

      • y: number

        local Y in [0, CHUNK_HEIGHT)

      • z: number

        local Z in [0, CHUNK_DEPTH)

      • blockId: number

        new block type

      Returns void

    • Returns the block at local coordinates, or BlockType.NONE if out of bounds.

      Parameters

      • x: number

        local X

      • y: number

        local Y

      • z: number

        local Z

      Returns number

    • Returns the flat index into blocks for local coordinates, or -1 if out of bounds.

      Parameters

      • x: number

        local X

      • y: number

        local Y

      • z: number

        local Z

      Returns number

    • Parameters

      • gx: number
      • gz: number
      • seed: number
      • OptionalgetErosion: (gx: number, gz: number) => number

      Returns ColumnTerrain

    • Parameters

      • gx: number
      • gy: number
      • gz: number
      • seed: number
      • heightMult: number
      • flatness: number
      • erosion: number
      • oceanity: number
      • oceanFloor: number

      Returns number

    • Parameters

      • gx: number
      • gz: number
      • seed: number
      • ct: ColumnTerrain

      Returns number | null

    • Parameters

      • gx: number
      • gz: number
      • seed: number

      Returns number

    • Parameters

      • p_x: number
      • p_y: number
      • p_z: number
      • treeHeight: number
      • trunk: BlockType
      • leaves: BlockType
      • shape: TreeShape

      Returns void

    • Parameters

      • p_x: number
      • p_y: number
      • p_z: number
      • p_gX: number
      • p_gY: number
      • p_gZ: number
      • seed: number
      • biome: BiomeType

      Returns void

    • Parameters

      • gx: number
      • gy: number
      • gz: number
      • seed: number
      • depthBelowSurface: number

      Returns boolean

    • Ore distribution within underground stone. Each ore is an independent 3D noise field; the block becomes ore where that field exceeds a threshold and the column is at least minDepth blocks below the surface. Smaller scale and higher threshold yield smaller, rarer veins. Ores are tested rarest first so a deep-and-rich noise hit wins over a common one when veins overlap.

      Parameters

      • gx: number

        world X of the stone block

      • gy: number

        world Y of the stone block

      • gz: number

        world Z of the stone block

      • seed: number

        world seed

      • depthBelowSurface: number

        blocks between this position and the surface

      Returns BlockType

      the ore BlockType, or NONE to leave plain stone