A Voxelize world handles the chunk loading and rendering, as well as any 3D objects.
This class extends the ThreeJS Scene class.
This means that you can add any ThreeJS objects to the world, and they will be rendered. The world
also implements NetIntercept, which means it intercepts chunk-related packets from the server
and constructs chunk meshes from them.
There are a couple components that are by default created by the world that holds data:
- World.registry: A block registry that handles block textures and block instances.
- World.chunks: A chunk manager that stores all the chunks in the world.
- World.physics: A physics engine that handles voxel AABB physics simulation of client-side physics.
- World.loader: An asset loader that handles loading textures and other assets.
- World.sky: A sky that can render the sky and the sun.
- World.clouds: A clouds that renders the cubical clouds.
One thing to keep in mind that there are no specific setters like setVoxelByVoxel or setVoxelRotationByVoxel.
This is because, instead, you should use updateVoxel and updateVoxels to update voxels.
Example
const world = new VOXELIZE.World();
// Update the voxel at `(0, 0, 0)` to a voxel type `12` in the world across the network.
world.updateVoxel(0, 0, 0, 12)
// Register the interceptor with the network.
network.register(world);
// Register an image to block sides.
world.applyBlockTexture("Test", VOXELIZE.ALL_FACES, "https://example.com/test.png");
// Update the world every frame.
world.update(controls.position);

Type parameters
| Name | Type |
|---|---|
T | any |
Hierarchy
-
Scene↳
World
Implements
Constructors
constructor
• new World<T>(options?): World<T>
Create a new Voxelize world.
Type parameters
| Name | Type |
|---|---|
T | any |
Parameters
| Name | Type | Description |
|---|---|---|
options | Partial<WorldOptions> | The options to create the world. |
Returns
World<T>
Overrides
Scene.constructor
Properties
blockAnimations
• blockAnimations: BlockAnimations
How animated blocks (Block.isAnimated: doors, and whatever else moves
between its states) swing from one state's geometry into the next. The
game registers a BlockAnimation per block name; the engine
tracks each such voxel's mesh across remeshes and drives the motion.
blockTextureGeneration
• blockTextureGeneration: number = 0
How many times a block texture has been written, bumped by every texture API. Every atlas slot starts life as the magenta-and-black unknown checker, and painting is spread over the load (image loads resolve whenever they resolve), so anything that samples the atlas into its own table has to be able to tell that its table predates the paint. Compare this against the value read when the table was built; unequal means rebuild.
chunkPipeline
• chunkPipeline: ChunkPipeline
Pipeline for chunk lifecycle state machine (request -> processing -> loaded).
chunkRenderer
• chunkRenderer: ChunkRenderer
Chunk rendering state (materials, uniforms).
clouds
• clouds: Clouds
The clouds that renders the cubical clouds.
csmRenderer
• csmRenderer: CSMRenderer = null
The CSM (Cascaded Shadow Map) renderer for shader-based lighting.
extraInitData
• extraInitData: Record<string, unknown> = {}
farTerrain
• farTerrain: FarTerrain
Coarse terrain past the loaded chunks, drawn from server-sampled tiles
when the world serves them (farTerrain in the INIT options) and
farTerrainDistance is above 0. See FarTerrain.
isInitialized
• isInitialized: boolean = false
Whether or not this world is connected to the server and initialized with data from the server.
isRegistryLoaded
• isRegistryLoaded: boolean = false
Whether the block registry, its chunk materials and the worker
registries are in place: from initialize, or earlier from
preloadRegistry. Texture and material work (the apply* and
customize* calls) needs only this, not the server's INIT.
items
• items: ItemRegistry
The item registry that holds all item definitions and provides utility methods for item operations.
lightCones
• lightCones: LightCones
Shared dynamic spot-cone lighting (flashlights, vehicle headlights). The game rebuilds the cone list every frame; chunk materials bind these uniforms at creation.
loader
• loader: Loader
An asset loader to load in things like textures, images, GIFs and audio buffers.
localLights
• localLights: LocalLights
Local light emitters: block-anchored sources scanned out of chunks plus game-registered dynamic sources, clustered into the chunk shaders. The game declares semantic block profiles and dynamic lights; the engine owns scanning, selection, culling, and GPU representation.
meshApplyStats
• meshApplyStats: MeshApplyStats
Running cost of applying mesh results on the main thread; see MeshApplyStats.
meshPipeline
• meshPipeline: MeshPipeline
Pipeline for mesh generation with ordering guarantees.
meshTransfer
• Readonly meshTransfer: Object
Configure and inspect mesh worker buffer transfer (transfer vs SharedArrayBuffer).
Type declaration
| Name | Type |
|---|---|
benchmark | (options: MeshTransferBenchmarkOptions) => Promise<MeshTransferBenchmarkResult> |
configure | (config: { mode?: WorkerTransferMode }) => void |
getMode | () => WorkerTransferMode |
getStats | () => MeshWorkerTransferStats | Record<WorkerTransferStrategy, MeshWorkerTransferStats> |
getStatus | () => { isCrossOriginIsolated: boolean ; isSharedArrayBufferAvailable: boolean ; mode: WorkerTransferMode ; pool: ChunkSharedPoolStats ; stats: MeshWorkerTransferStats | Record<WorkerTransferStrategy, MeshWorkerTransferStats> ; strategy: WorkerTransferStrategy } |
getStrategy | () => WorkerTransferStrategy |
isSharedArrayBufferAvailable | () => boolean |
resetStats | () => void |
setStrategy | (strategy: "transfer" | "shared") => void |
options
• options: WorldOptions
The options to create the world.
orderIndependent
• orderIndependent: OrderIndependentTransparency = null
The blended layers' accumulation, when
WorldClientOptions.orderIndependentTransparency is set; null
draws the sorted pipeline.
physics
• physics: Engine
The voxel physics engine using @voxelize/physics-engine.
registry
• registry: Registry
The block registry that holds all block data, such as texture and block properties.
shaderClock
• Readonly shaderClock: ShaderClock
The clock chunk shaders animate on (waves, sway, flicker, animated atlas frames): the shared clock, slewed and wrapped for the GPU, so every player sees the same wave at the same moment.
sky
• sky: Sky
The sky that renders the sky and the sun.
swayProfileTable
• Readonly swayProfileTable: ArrayUniform<Vector4, "vec4">
The vec4-pair table the shared cutout buckets sway by (params: speed, amplitude, scale, yScale; flags: rooted, cross shading), indexed by each vertex's sway profile (its quantized position's fourth lane, vertex-layout.ts). Slot 0 stays zeroed as the "no sway" profile.
volumetricClouds
• volumetricClouds: VolumetricClouds = null
The volumetric cloud deck, when the host asked for one (World.setVolumetricClouds).
waterOptics
• waterOptics: WaterOptics
The camera-driven underwater optics state, updated via World.updateWaterOptics.
waterOpticsFluidFilter
• waterOpticsFluidFilter: (block: Block) => boolean = null
Which fluid blocks count as water for the camera's underwater optics.
null (the default) treats every fluid as water. A game with other
fluids (lava) returns false for them, so a camera inside one does not
get water fog, sky fade and the backside water surface.
Type declaration
▸ (block): boolean
Parameters
| Name | Type |
|---|---|
block | Block |
Returns
boolean
Accessors
atmosphere
• get atmosphere(): SkyFogInputs
The world's atmosphere as every fogged surface reads it: the chunk uniforms' sky fog, glow and camera water, with the beam's share.
Returns
day
• get day(): number
Days the world clock has completed. With World.time it forms World.sharedClock; on its own it is what a moon phase or a "day N" readout would count.
Returns
number
deleteRadius
• get deleteRadius(): number
Returns
number
disposed
• get disposed(): boolean
Whether dispose has run. A disposed world is a corpse: its workers are gone and its chunks released, and anything still holding it is holding the whole scene graph in memory for nothing.
Returns
boolean
farTerrainDistance
• get farTerrainDistance(): number
How far the far-terrain layer reaches past the viewer, in blocks; 0
turns it off. Takes effect only in a world that serves far terrain.
The fog range follows it. See WorldOptions.farTerrainDistance.
Returns
number
• set farTerrainDistance(distance): void
Parameters
| Name | Type |
|---|---|
distance | number |
Returns
void
fogDistance
• get fogDistance(): number
A fixed fog distance in blocks, independent of renderRadius; null
when fog is still derived from the radius. See
WorldOptions.fogDistance.
Returns
number
• set fogDistance(distance): void
Parameters
| Name | Type |
|---|---|
distance | number |
Returns
void
preloadedRegistryDigest
• get preloadedRegistryDigest(): string
The digest of the registry preloadRegistry loaded, if any.
Returns
string
regionArenaMaterials
• get regionArenaMaterials(): ChunkMaterial[]
The materials the region arenas draw with, one per batched bucket.
Returns
regionArenaStats
• get regionArenaStats(): RegionArenaStats
The region arenas' live regions, their pages (one draw each) and the sections slotted into them, in all and per batched bucket.
Returns
renderRadius
• get renderRadius(): number
Returns
number
• set renderRadius(radius): void
Parameters
| Name | Type |
|---|---|
radius | number |
Returns
void
sectionVisibilityStats
• get sectionVisibilityStats(): Object
Returns
Object
| Name | Type |
|---|---|
constrained | number |
isComplete | boolean |
reached | number |
sections | number |
visible | number |
walks | number |
shadingInputs
• get shadingInputs(): ChunkShadingInputs
What every chunk material of this world reads alike: its uniforms, the sun's cascades, the cones, the clustered lights and the sway table, as TSL nodes. Made once, after the renderers they come from.
Returns
sharedClock
• get sharedClock(): number
Seconds since the world's clock began: day * timePerDay + time. Unlike
World.time it never wraps at midnight, and every client of a
world agrees on it to within the STATS sync threshold, which makes it
the clock for cosmetic motion all players must see alike — cloud drift,
the shooting-star schedule. A /time jump moves it within the current
day, so those effects jump with the sky rather than diverging from it.
A world whose clock is frozen (doesTickTime false) has no shared game
clock at all, so the wall clock stands in: clients agree to within their
NTP skew, which is all a cosmetic schedule needs.
Returns
number
time
• get time(): number
Returns
number
• set time(time): void
Parameters
| Name | Type |
|---|---|
time | number |
Returns
void
Methods
addBlockEntityUpdateListener
▸ addBlockEntityUpdateListener(listener): () => void
Parameters
| Name | Type |
|---|---|
listener | BlockEntityUpdateListener<T> |
Returns
fn
▸ (): void
Returns
void
addBlockUpdateListener
▸ addBlockUpdateListener(listener): () => void
Parameters
| Name | Type |
|---|---|
listener | BlockUpdateListener |
Returns
fn
▸ (): void
Returns
void
addChunkInitListener
▸ addChunkInitListener(coords, listener): () => void
Parameters
| Name | Type |
|---|---|
coords | Coords2 |
listener | (chunk: Chunk) => void |
Returns
fn
▸ (): void
Returns
void
adoptOrderIndependentMaterials
▸ adoptOrderIndependentMaterials(materials): Material<MaterialEventMap>[]
Adopts every material in materials that can accumulate, and makes the
texel forks of the see-through chunk materials among them, so a warmup
compiles the programs play draws with (a material adopted after it
compiled compiles again). Returns the forks: no scene holds them until
a mesh's textures call for one, so a warmup has to draw them itself.
Parameters
| Name | Type |
|---|---|
materials | Iterable<Material<MaterialEventMap>, any, any> |
Returns
Material<MaterialEventMap>[]
applyBlockFrames
▸ applyBlockFrames(idOrName, faceNames, keyframes, fadeFrames?): Promise<void>
Apply a set of keyframes to a block. This will load the keyframes from the sources and start the animation to play the keyframes on the block's texture atlas.
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
idOrName | string | number | undefined | The ID or name of the block. |
faceNames | string | string[] | undefined | The face name or names to apply the texture to. |
keyframes | [number, string | Color | HTMLImageElement][] | undefined | The keyframes to apply to the texture. |
fadeFrames | number | 0 | The number of frames to fade between each keyframe. |
Returns
Promise<void>
applyBlockGif
▸ applyBlockGif(idOrName, faceNames, source, interval?): Promise<void>
Apply a GIF animation to a block. This will load the GIF from the source and start the animation using applyBlockFrames internally.
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
idOrName | string | undefined | The ID or name of the block. |
faceNames | string | string[] | undefined | The face name or names to apply the texture to. |
source | string | undefined | The source of the GIF. Note that this must be a GIF file ending with .gif. |
interval | number | 66.666667 | The interval between each frame of the GIF in milliseconds. Defaults to 66.666667ms. |
Returns
Promise<void>
applyBlockTexture
▸ applyBlockTexture(idOrName, faceNames, source): void
Apply a texture to a face or faces of a block. This will automatically load the image from the source and draw it onto the block's texture atlas.
An isolated face, whose pixels belong to a voxel, takes this as its default — what the face looks like where there is no voxel to ask, which is every display mesh: a held block, a drop, an inventory thumbnail. applyBlockTextureAt still overrides it per voxel.
Parameters
| Name | Type | Description |
|---|---|---|
idOrName | string | number | The ID or name of the block. |
faceNames | string | string[] | The face names to apply the texture to. |
source | string | Color | Texture<unknown, TextureEventMap> | HTMLImageElement | The source of the texture. |
Returns
void
Deprecated
When applying the same texture to multiple faces, use texture groups instead for better atlas efficiency. Define texture_group on the server-side block faces and use applyTextureGroup or applyTextureGroups on the client.
applyBlockTextureAt
▸ applyBlockTextureAt(idOrName, faceName, source, voxel): ChunkMaterial
Parameters
| Name | Type |
|---|---|
idOrName | string | number |
faceName | string |
source | string | Color | Texture<unknown, TextureEventMap> | HTMLImageElement |
voxel | Coords3 |
Returns
applyBlockTextures
▸ applyBlockTextures(data): Promise<void[]>
Apply multiple block textures at once. See applyBlockTexture for more information.
Parameters
| Name | Type | Description |
|---|---|---|
data | { faceNames: string | string[] ; idOrName: string | number ; source: string | Color }[] | The data to apply the block textures. |
Returns
Promise<void[]>
A promise that resolves when all the textures are applied.
Deprecated
When applying the same texture to multiple faces, use texture groups instead for better atlas efficiency. Define texture_group on the server-side block faces and use applyTextureGroup or applyTextureGroups on the client.
applyTextureGroup
▸ applyTextureGroup(groupName, source): any
Parameters
| Name | Type |
|---|---|
groupName | string |
source | string | Color | Texture<unknown, TextureEventMap> | HTMLImageElement |
Returns
any
applyTextureGroups
▸ applyTextureGroups(data): Promise<any[]>
Parameters
| Name | Type |
|---|---|
data | { groupName: string ; source: string | Color | Texture<unknown, TextureEventMap> | HTMLImageElement }[] |
Returns
Promise<any[]>
auditLightCones
▸ auditLightCones(): LightConeAuditEntry[]
Every drawn mesh in the world whose material neither takes the light cones nor is exempt from them: what a flashlight would leave dark. Empty when every lighting path is covered; the in-world gate for it.
Returns
benchmarkMeshTransfer
▸ benchmarkMeshTransfer(options): Promise<MeshTransferBenchmarkResult>
Parameters
| Name | Type |
|---|---|
options | MeshTransferBenchmarkOptions |
Returns
Promise<MeshTransferBenchmarkResult>
compileLocalShadowPrograms
▸ compileLocalShadowPrograms(renderer, casters?): Promise<void>
Builds the local-light shadow frame's pipelines during a load warmup:
the atlas cell clear, and the depth draws of the world's static casters
around casters.around and of casters.entities, so the first torch to
cast a shadow builds nothing in its frame. Once asked, the world also
compiles the torch draw of each GPU terrain bucket made afterwards (a
rare block's, met later) before that bucket shows.
Parameters
| Name | Type | Description |
|---|---|---|
renderer | Renderer | - |
casters | Object | - |
casters.always? | Object3D<Object3DEventMap>[] | Casters drawn wherever a light is, hidden or not (GPU buckets). |
casters.around? | Object | - |
casters.around.x | number | - |
casters.around.y | number | - |
casters.around.z | number | - |
casters.entities? | Object3D<Object3DEventMap>[] | - |
casters.pools? | Object3D<Object3DEventMap>[] | Instanced pools, drawn with their own depth materials. |
casters.reach? | number | - |
Returns
Promise<void>
compilePasses
▸ compilePasses(target): Object
The passes this world's frame draws in for a scene drawn into target
(renderFrame): the scene pass, the blended accumulation (null when
the world draws its layers sorted) and a shadow cascade, each as the
target bound and the outputs laid over it (a cascade also with the
camera and scenes it draws in). A pipeline is built for the pass it
draws in, so a warmup compiles each material for each of these.
Parameters
| Name | Type |
|---|---|
target | RenderTarget<Texture<unknown, TextureEventMap>, RenderTargetEventMap> |
Returns
Object
| Name | Type |
|---|---|
blended | { mrt: MRTNode ; target: RenderTarget<Texture<unknown, TextureEventMap>, RenderTargetEventMap> } |
blended.mrt | MRTNode |
blended.target | RenderTarget<Texture<unknown, TextureEventMap>, RenderTargetEventMap> |
isBlended | (material: Material<MaterialEventMap>) => boolean |
main | { mrt: any = null; target: RenderTarget<Texture<unknown, TextureEventMap>, RenderTargetEventMap> } |
main.mrt | any |
main.target | RenderTarget<Texture<unknown, TextureEventMap>, RenderTargetEventMap> |
shadow | { mrt: any = null; target: RenderTarget<Texture<unknown, TextureEventMap>, RenderTargetEventMap> ; view: { camera: OrthographicCamera ; casterScene: Scene<Object3DEventMap> } } |
shadow.mrt | any |
shadow.target | RenderTarget<Texture<unknown, TextureEventMap>, RenderTargetEventMap> |
shadow.view | { camera: OrthographicCamera ; casterScene: Scene<Object3DEventMap> } |
shadow.view.camera | OrthographicCamera |
shadow.view.casterScene | Scene<Object3DEventMap> |
compileWaterDepthPrograms
▸ compileWaterDepthPrograms(renderer, camera): Promise<void>
Links the water depth pass's programs for every fluid chunk material,
so a fluid whose water first loads in play does not link them in a
frame (see WaterDepthPass.compileFor). Call it in the load, once the
chunk materials are made.
Parameters
| Name | Type |
|---|---|
renderer | Renderer |
camera | Camera |
Returns
Promise<void>
countGpuTerrainTriangles
▸ countGpuTerrainTriangles(camera): number
Triangles of terrain the GPU-driven buckets draw for camera, counted
on the CPU. The renderer's own tallies (info.render.triangles) miss
them: those draws are indirect, their counts made on the GPU. A stats
call: it tests every section's bounds, so keep it off the frame loop.
Parameters
| Name | Type |
|---|---|
camera | Camera |
Returns
number
customizeBlockDynamic
▸ customizeBlockDynamic(idOrName, fn): void
Parameters
| Name | Type |
|---|---|
idOrName | string | number |
fn | (pos: Coords3) => { aabbs: AABB[] ; faces: { corners: { pos: [number, number, number] ; uv: number[] }[] ; dir: [number, number, number] ; emissive?: number ; independent: boolean ; isolated: boolean ; name: string ; pigmentMask?: number ; range: UV ; regionalTint?: boolean ; stageTintMask?: number ; textureGroup: string }[] ; isTransparent: [boolean, boolean, boolean, boolean, boolean, boolean] } |
Returns
void
customizeMaterial
▸ customizeMaterial(idOrName, faceName?, customization?): ChunkMaterial
Give a block (or one of its faces) a shading of its own: a fixed sway
baked into its program (customShaders.sway), a different kind (a
fluid drawn as a see-through surface), or hooks that remap its texture
or replace its lit colour (ChunkShadingHooks). The block leaves any
shared bucket for its own material; meshes keep that material and pick
the new program up on their next draw.
Parameters
| Name | Type | Default value |
|---|---|---|
idOrName | string | number | undefined |
faceName | string | null |
customization | Partial<ChunkMaterialOptions> | {} |
Returns
dispose
▸ dispose(): void
Returns
void
Overrides
Scene.dispose
expandCoupledUpdates
▸ expandCoupledUpdates(updates): BlockUpdate[]
Expand a batch of updates so every coupled unit it touches changes
whole — the mirror of the server's update intake, run on every batch
updateVoxels receives. Exposed so a caller can learn the outcome of a
placement before committing to it (an anchor whose partner voxel is
occupied expands to nothing); the result is idempotent, so it can be
handed straight back to World.updateVoxels. See
expandCoupledUpdates.
Parameters
| Name | Type |
|---|---|
updates | BlockUpdate[] |
Returns
fillUnpaintedSurfaces
▸ fillUnpaintedSurfaces(options?): TextureFillResult
Dress every surface still on the unknown checker: an isolated face in
its default if that has landed, everything else in
options.unpaintedFallbackColor. The census keeps reporting them as
fallback, so a stage made presentable this way does not pass for a
finished one.
Parameters
| Name | Type |
|---|---|
options | Object |
options.color? | string |
Returns
floodLight
▸ floodLight(queue, color, min?, max?): void
Propagate light nodes outward through the loaded chunks. The algorithm itself lives in "./lighting" and senses the world through the VoxelLightVolume slice this class satisfies.
Parameters
| Name | Type |
|---|---|
queue | LightNode[] |
color | LightColor |
min? | Coords3 |
max? | Coords3 |
Returns
void
getAABBOverride
▸ getAABBOverride(voxel): AABB[]
Parameters
| Name | Type |
|---|---|
voxel | Coords3 |
Returns
AABB[]
getAABBOverrideOwner
▸ getAABBOverrideOwner(voxel): Coords3
The block voxel an override cell answers for, when it has one.
Parameters
| Name | Type |
|---|---|
voxel | Coords3 |
Returns
getBarrierTopAt
▸ getBarrierTopAt(vx, vy, vz): number
World-space height the server's bodies find the voxel at vx, vy, vz
standing to (its block's barrierHeight above the voxel's floor), or
-Infinity where its block has no barrier or no chunk is loaded. The
client's own body collides with getCollisionAABBsAt alone; the
physics engine reads this so automatic moves never carry it over.
Parameters
| Name | Type |
|---|---|
vx | number |
vy | number |
vz | number |
Returns
number
getBaseFogRange
▸ getBaseFogRange(): WorldFogRange
Returns
getBlockAABBsAt
▸ getBlockAABBsAt(vx, vy, vz): AABB[]
Parameters
| Name | Type |
|---|---|
vx | number |
vy | number |
vz | number |
Returns
AABB[]
getBlockAABBsByIdAt
▸ getBlockAABBsByIdAt(id, vx, vy, vz): AABB[]
Parameters
| Name | Type |
|---|---|
id | number |
vx | number |
vy | number |
vz | number |
Returns
AABB[]
getBlockAABBsForDynamicPatterns
▸ getBlockAABBsForDynamicPatterns(vx, vy, vz, dynamicPatterns): { aabb: AABB ; worldSpace: boolean }[]
Parameters
| Name | Type |
|---|---|
vx | number |
vy | number |
vz | number |
dynamicPatterns | BlockDynamicPattern[] |
Returns
{ aabb: AABB ; worldSpace: boolean }[]
getBlockAt
▸ getBlockAt(px, py, pz): Block
Get the block type data by a 3D world position.
Parameters
| Name | Type | Description |
|---|---|---|
px | number | The x coordinate of the position. |
py | number | The y coordinate of the position. |
pz | number | The z coordinate of the position. |
Returns
The block at the given position, or null if it does not exist.
getBlockById
▸ getBlockById(id): Block
Get the block type data by a block id. Unknown ids resolve to air (logged once per id) so a server/client registry gap can never take down meshing, lighting, or the agent bridge.
Parameters
| Name | Type | Description |
|---|---|---|
id | number | The block id. |
Returns
The block data for the given id, or air if it is unknown.
getBlockByIdSafe
▸ getBlockByIdSafe(id): Block
Parameters
| Name | Type |
|---|---|
id | number |
Returns
getBlockByName
▸ getBlockByName(name): Block
Get the block type data by a block name.
Parameters
| Name | Type | Description |
|---|---|---|
name | string | The block name. |
Returns
The block data for the given name, or null if it does not exist.
getBlockEntityDataAt
▸ getBlockEntityDataAt(px, py, pz): T
Parameters
| Name | Type |
|---|---|
px | number |
py | number |
pz | number |
Returns
T
getBlockEntityIdAt
▸ getBlockEntityIdAt(px, py, pz): string
Parameters
| Name | Type |
|---|---|
px | number |
py | number |
pz | number |
Returns
string
getBlockFaceMaterial
▸ getBlockFaceMaterial(idOrName, faceName?, voxel?): ChunkMaterial
Parameters
| Name | Type |
|---|---|
idOrName | string | number |
faceName? | string |
voxel? | Coords3 |
Returns
getBlockFacesByFaceNames
▸ getBlockFacesByFaceNames(id, faceNames, warnUnknown?): { corners: { pos: [number, number, number] ; uv: number[] }[] ; dir: [number, number, number] ; emissive?: number ; independent: boolean ; isolated: boolean ; name: string ; pigmentMask?: number ; range: UV ; regionalTint?: boolean ; stageTintMask?: number ; textureGroup: string }[]
Parameters
| Name | Type | Default value |
|---|---|---|
id | number | undefined |
faceNames | string | RegExp | string[] | undefined |
warnUnknown | boolean | false |
Returns
{ corners: { pos: [number, number, number] ; uv: number[] }[] ; dir: [number, number, number] ; emissive?: number ; independent: boolean ; isolated: boolean ; name: string ; pigmentMask?: number ; range: UV ; regionalTint?: boolean ; stageTintMask?: number ; textureGroup: string }[]
getBlockFacesForDynamicPatterns
▸ getBlockFacesForDynamicPatterns(blockId, dynamicPatterns): { corners: { pos: [number, number, number] ; uv: number[] }[] ; dir: [number, number, number] ; emissive?: number ; independent: boolean ; isolated: boolean ; name: string ; pigmentMask?: number ; range: UV ; regionalTint?: boolean ; stageTintMask?: number ; textureGroup: string }[]
Parameters
| Name | Type |
|---|---|
blockId | number |
dynamicPatterns | BlockDynamicPattern[] |
Returns
{ corners: { pos: [number, number, number] ; uv: number[] }[] ; dir: [number, number, number] ; emissive?: number ; independent: boolean ; isolated: boolean ; name: string ; pigmentMask?: number ; range: UV ; regionalTint?: boolean ; stageTintMask?: number ; textureGroup: string }[]
getBlockOf
▸ getBlockOf(idOrName): Block
Parameters
| Name | Type |
|---|---|
idOrName | string | number |
Returns
getBlockPassableForDynamicPatterns
▸ getBlockPassableForDynamicPatterns(vx, vy, vz, dynamicPatterns, defaultPassable): boolean
Parameters
| Name | Type |
|---|---|
vx | number |
vy | number |
vz | number |
dynamicPatterns | BlockDynamicPattern[] |
defaultPassable | boolean |
Returns
boolean
getBranchAABBsAt
▸ getBranchAABBsAt(block, vx, vy, vz): AABB[]
The boxes the branch voxel of block at vx, vy, vz is drawn and
collides as, in blocks of the voxel: a one-voxel branch or fin's core
and arms, or a wide section cell's slice of its core's tube (see
branch.ts). Empty for a block that is not a branch, a cut core and a
shell whose core is gone.
Parameters
| Name | Type |
|---|---|
block | Block |
vx | number |
vy | number |
vz | number |
Returns
AABB[]
getChunkByCoords
▸ getChunkByCoords(cx, cz): Chunk
Get a chunk by its 2D coordinates.
Parameters
| Name | Type | Description |
|---|---|---|
cx | number | The x coordinate of the chunk. |
cz | number | The z coordinate of the chunk. |
Returns
The chunk at the given coordinates, or undefined if it does not exist.
getChunkByName
▸ getChunkByName(name): Chunk
Get a chunk by its name.
Parameters
| Name | Type | Description |
|---|---|---|
name | string | The name of the chunk to get. |
Returns
The chunk with the given name, or undefined if it does not exist.
getChunkByPosition
▸ getChunkByPosition(px, py, pz): Chunk
Get a chunk that contains a given position.
Parameters
| Name | Type | Description |
|---|---|---|
px | number | The x coordinate of the position. |
py | number | The y coordinate of the position. |
pz | number | The z coordinate of the position. |
Returns
The chunk that contains the position at the given position, or undefined if it does not exist.
getChunkStatus
▸ getChunkStatus(cx, cz): "requested" | "processing" | "loaded" | "to request"
Get the status of a chunk.
Parameters
| Name | Type | Description |
|---|---|---|
cx | number | The x 2D coordinate of the chunk. |
cz | number | The z 2D coordinate of the chunk. |
Returns
"requested" | "processing" | "loaded" | "to request"
The status of the chunk.
getCollisionAABBsAt
▸ getCollisionAABBsAt(vx, vy, vz): AABB[]
The boxes a rigid body collides with in the voxel at vx, vy, vz, in
world space: exactly what the physics engine stands bodies on. Empty
where no chunk is loaded, and for passable blocks and fluids.
Parameters
| Name | Type |
|---|---|
vx | number |
vy | number |
vz | number |
Returns
AABB[]
getIsolatedBlockMaterialAt
▸ getIsolatedBlockMaterialAt(voxel, faceName, defaultDimension?): ChunkMaterial
Parameters
| Name | Type |
|---|---|
voxel | Coords3 |
faceName | string |
defaultDimension? | number |
Returns
getLightColorAt
▸ getLightColorAt(vx, vy, vz): Color
Get a color instance that represents what an object would be like if it were rendered at the given 3D voxel coordinate. This is useful to dynamically shade objects based on their position in the world. Also used in LightShined.
Parameters
| Name | Type | Description |
|---|---|---|
vx | number | The voxel's X position. |
vy | number | The voxel's Y position. |
vz | number | The voxel's Z position. |
Returns
Color
The voxel's light color at the given coordinate.
getLightValuesAt
▸ getLightValuesAt(vx, vy, vz): Object
Parameters
| Name | Type |
|---|---|
vx | number |
vy | number |
vz | number |
Returns
Object
| Name | Type |
|---|---|
blue | number |
green | number |
red | number |
sunlight | number |
getMaxHeightAt
▸ getMaxHeightAt(px, pz): number
Get the highest block at a x/z position. Highest block means the first block counting downwards that
isn't empty (isEmpty).
Parameters
| Name | Type | Description |
|---|---|---|
px | number | The x coordinate of the position. |
pz | number | The z coordinate of the position. |
Returns
number
The highest block at the given position, or 0 if it does not exist.
getMemoryCounters
▸ getMemoryCounters(): WorldMemoryCounters
Live sizes of every queue and in-flight set in the voxel update -> relight -> remesh pipeline, plus the bytes of serialized chunk payloads parked in worker queues. This is the memory-pressure dashboard for debugging update-flood OOMs (mass terrain edits): sample it while carving and watch which stage balloons.
Returns
getPreviousValueAt
▸ getPreviousValueAt(px, py, pz, count?): number
Get the previous value of a voxel by a 3D world position.
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
px | number | undefined | The x coordinate of the position. |
py | number | undefined | The y coordinate of the position. |
pz | number | undefined | The z coordinate of the position. |
count | number | 1 | By how much to look back in the history. Defaults to 1. |
Returns
number
getRawVoxelAt
▸ getRawVoxelAt(px, py, pz): number
The whole packed voxel word at a 3D world position — id, rotation,
stage and waterlogging together — or 0 where no chunk is loaded. For
callers that compare voxel states as a unit; getVoxelAt and its
siblings unpack one field each.
Parameters
| Name | Type |
|---|---|
px | number |
py | number |
pz | number |
Returns
number
getSunlightAt
▸ getSunlightAt(px, py, pz): number
Get a voxel sunlight by a 3D world position.
Parameters
| Name | Type | Description |
|---|---|---|
px | number | The x coordinate of the position. |
py | number | The y coordinate of the position. |
pz | number | The z coordinate of the position. |
Returns
number
The voxel sunlight at the given position, or 0 if it does not exist.
getTextureInfo
▸ getTextureInfo(): Object
Returns
Object
| Name | Type |
|---|---|
sharedAtlas | { canvas: HTMLCanvasElement ; countPerSide: number } |
sharedAtlas.canvas | HTMLCanvasElement |
sharedAtlas.countPerSide | number |
textures | TextureInfo[] |
getTorchLightAt
▸ getTorchLightAt(px, py, pz, color): number
Get a voxel torch light by a 3D world position.
Parameters
| Name | Type | Description |
|---|---|---|
px | number | The x coordinate of the position. |
py | number | The y coordinate of the position. |
pz | number | The z coordinate of the position. |
color | LightColor | The color of the torch light. |
Returns
number
The voxel torchlight at the given position, or 0 if it does not exist.
getVoxelAt
▸ getVoxelAt(px, py, pz): number
Get a voxel by a 3D world position.
Parameters
| Name | Type | Description |
|---|---|---|
px | number | The x coordinate of the position. |
py | number | The y coordinate of the position. |
pz | number | The z coordinate of the position. |
Returns
number
The voxel at the given position, or 0 if it does not exist.
getVoxelRotationAt
▸ getVoxelRotationAt(px, py, pz): BlockRotation
Get a voxel rotation by a 3D world position.
Parameters
| Name | Type | Description |
|---|---|---|
px | number | The x coordinate of the position. |
py | number | The y coordinate of the position. |
pz | number | The z coordinate of the position. |
Returns
The voxel rotation at the given position, or the default rotation if it does not exist.
getVoxelStageAt
▸ getVoxelStageAt(px, py, pz): number
Get a voxel stage by a 3D world position.
Parameters
| Name | Type | Description |
|---|---|---|
px | number | The x coordinate of the position. |
py | number | The y coordinate of the position. |
pz | number | The z coordinate of the position. |
Returns
number
The voxel stage at the given position, or 0 if it does not exist.
getVoxelWaterlogLevelAt
▸ getVoxelWaterlogLevelAt(px, py, pz): number
The level of waterlogging fluid held by the voxel at a 3D world position.
Parameters
| Name | Type | Description |
|---|---|---|
px | number | The x coordinate of the position. |
py | number | The y coordinate of the position. |
pz | number | The z coordinate of the position. |
Returns
number
getVoxelWaterloggedAt
▸ getVoxelWaterloggedAt(px, py, pz): boolean
Whether the voxel at a 3D world position holds the world's waterlogging fluid alongside its block.
Parameters
| Name | Type | Description |
|---|---|---|
px | number | The x coordinate of the position. |
py | number | The y coordinate of the position. |
pz | number | The z coordinate of the position. |
Returns
boolean
hasCustomBlockMaterial
▸ hasCustomBlockMaterial(id): boolean
Parameters
| Name | Type |
|---|---|
id | number |
Returns
boolean
initialize
▸ initialize(): Promise<void>
Initialize the world with the data received from the server. This includes populating the registry, setting the options, and creating the texture atlas.
Returns
Promise<void>
invalidateShadowMaps
▸ invalidateShadowMaps(): void
Throws away every cached shadow map, the sun's cascades and the local lights' faces alike, so the next shadow pass draws them all again: for a caller whose earlier passes left casters out on purpose.
Returns
void
isAreaMeshed
▸ isAreaMeshed(cx, cz, radius): boolean
Whether every chunk within radius chunks of (cx, cz) is loaded
and every one of its sections has had a mesh applied (an empty one
counts once its empty mesh landed). What a game waits on before it
shows the world, so the land around the camera does not build itself
in view: chunk data arrives well before the meshes made from it.
Parameters
| Name | Type |
|---|---|
cx | number |
cz | number |
radius | number |
Returns
boolean
isCameraSubmerged
▸ isCameraSubmerged(): boolean
Whether the camera is under water, by the same smoothed submersion the
water shaders read: which side of the water a see-through layer in the
camera's medium draws on (TRANSPARENT_SORT).
Returns
boolean
isChunkInView
▸ isChunkInView(center, target, direction, threshold): boolean
Parameters
| Name | Type |
|---|---|
center | Coords2 |
target | Coords2 |
direction | Vector3 |
threshold | number |
Returns
boolean