Large worlds · function

cellIdFrom

Pack grid coordinates into one identifier.

Explained in Coordinates and units.

function cellIdFrom(cx: number, cy: number, cz: number): number
import { cellIdFrom } from '@driftengine/core';

Parameters

ParameterTypeDescription
cxnumber
cynumber
cznumber

In depth

Out of range throws rather than wrapping, and the reason is what wrapping does: a coordinate past the bias produces an identifier belonging to a different, real cell, so two distant places in the world silently become the same cell. That is a corruption with no symptom near where it happened. This is a streaming-time path, not a per-vertex one, so the check costs nothing that matters.