noa.world - manages world data, chunks, voxels.

This module uses the following default options (from the options object passed to the Engine):

var defaultOptions = {
chunkSize: 24,
chunkAddDistance: [2, 2], // [horizontal, vertical]
chunkRemoveDistance: [3, 3], // [horizontal, vertical]
worldGenWhilePaused: false,
manuallyControlChunkLoading: false,
}

Events:

  • worldDataNeeded = (requestID, dataArr, x, y, z, worldName)
    Alerts client that a new chunk of world data is needed.
  • playerEnteredChunk => (i, j, k)
    Fires when player enters a new chunk
  • chunkAdded => (chunk)
    Fires after a new chunk object is added to the world
  • chunkBeingRemoved = (requestID, dataArr, userData)
    Fires before a chunk is removed from world

Hierarchy

Properties

chunkSortingDistFn: ((i, j, k) => number)

Type declaration

    • (i, j, k): number
    • Defining this function sets a custom order in which to create chunks. The function should look like:

        (i, j, k) => 1 // return a smaller number for chunks to process first
      

      Parameters

      • i: any
      • j: any
      • k: any

      Returns number

listenerCount: {
    (type): any;
    (emitter, type): any;
}

Type declaration

    • (type): any
    • Parameters

      • type: any

      Returns any

    • (emitter, type): any
    • Parameters

      • emitter: any
      • type: any

      Returns any

manuallyControlChunkLoading: boolean

Game clients should set this if they need to manually control which chunks to load and unload. When set, client should call noa.world.manuallyLoadChunk / manuallyUnloadChunk as needed.

maxChunksPendingCreation: number

Limit the size of internal chunk processing queues

maxChunksPendingMeshing: number

Limit the size of internal chunk processing queues

maxProcessingPerRender: number

Cutoff (in ms) of time spent each render

maxProcessingPerTick: number

Cutoff (in ms) of time spent each tick

minNeighborsToMesh: number

Set this higher to cause chunks not to mesh until they have some neighbors. Max legal value is 26 (each chunk will mesh only when all neighbors are present)

off: any
on: any
worldGenWhilePaused: boolean

When true, worldgen queues will keep running if engine is paused.

Methods

  • Parameters

    • chunk: any

    Returns void

  • Parameters

    • type: any
    • listener: any

    Returns any

  • Parameters

    • type: any
    • Rest ...args: any[]

    Returns boolean

  • Parameters

    • x: number = 0
    • y: number = 0
    • z: number = 0

    Returns any

  • Parameters

    • x: number = 0
    • y: number = 0
    • z: number = 0

    Returns any

  • Parameters

    • x: number = 0
    • y: number = 0
    • z: number = 0

    Returns any

  • Parameters

    • x: number = 0
    • y: number = 0
    • z: number = 0

    Returns any

  • Parameters

    • x: number = 0
    • y: number = 0
    • z: number = 0

    Returns boolean

  • Tells noa to discard voxel data within a given AABB (e.g. because the game client received updated data from a server). The engine will mark all affected chunks for removal, and will later emit new worldDataNeeded events (if the chunk is still in draw range).

    Parameters

    • box: any

    Returns void

  • Parameters

    • box: any

    Returns boolean

  • When manually controlling chunk loading, tells the engine that the chunk containing the specified (x,y,z) needs to be created and loaded.

    Note: throws unless noa.world.manuallyControlChunkLoading is set.

    Parameters

    • x: number = 0
    • y: number = 0
    • z: number = 0

    Returns void

  • When manually controlling chunk loading, tells the engine that the chunk containing the specified (x,y,z) needs to be unloaded and disposed.

    Note: throws unless noa.world.manuallyControlChunkLoading is set.

    Parameters

    • x: number = 0
    • y: number = 0
    • z: number = 0

    Returns void

  • Sets the distances within which to load new chunks, and beyond which to unload them. Generally you want the remove distance to be somewhat farther, so that moving back and forth across the same chunk border doesn't keep loading/unloading the same distant chunks.

    Both arguments can be numbers (number of voxels), or arrays like: [horiz, vert] specifying different horizontal and vertical distances.

    Parameters

    • addDist: number | number[] = 2
    • remDist: number | number[] = 3

    Returns void

  • Parameters

    • id: number = 0
    • x: number = 0
    • y: number = 0
    • z: number = 0

    Returns void

  • Clients should call this after creating a chunk's worth of data (as an ndarray)
    If userData is passed in it will be attached to the chunk

    Parameters

    • id: string

      the string specified when the chunk was requested

    • array: any

      an ndarray of voxel data

    • userData: any = null

      an arbitrary value for game client use

    • fillVoxelID: number = -1

      specify a voxel ID here if you want to signify that the entire chunk should be solidly filled with that voxel (e.g. 0 for air). If you do this, the voxel array data will be overwritten and the engine will take a fast path through some initialization steps.

    Returns void

Generated using TypeDoc