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> = {}
isInitialized
• isInitialized: boolean = false
Whether or not this world is connected to the server and initialized with data from the server.
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.
physics
• physics: Engine
The voxel physics engine using @voxelize/physics-engine.
regionArenas
• regionArenas: ChunkRegionArenas = null
Region buffer arenas batching the shared-opaque bucket, one
BatchedMesh per region; null until the first opaque section lands or
when WorldClientOptions.regionArenas disables batching.
registry
• registry: Registry
The block registry that holds all block data, such as texture and block properties.
sky
• sky: Sky
The sky that renders the sky and the sun.
swayProfileTable
• Readonly swayProfileTable: Uniform<any>
Flat vec4-pair table behind the shared cutout buckets' sway shader; see createSwayTableShader. Slot 0 stays zeroed as the "no sway" profile.
waterOptics
• waterOptics: WaterOptics
The camera-driven underwater optics state, updated via World.updateWaterOptics.
Accessors
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
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 |
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
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> | 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): CustomChunkShaderMaterial
Parameters
| Name | Type |
|---|---|
idOrName | string | number |
faceName | string |
source | string | Color | Texture<unknown> | 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> | HTMLImageElement |
Returns
any
applyTextureGroups
▸ applyTextureGroups(data): Promise<any[]>
Parameters
| Name | Type |
|---|---|
data | { groupName: string ; source: string | Color | Texture<unknown> | HTMLImageElement }[] |
Returns
Promise<any[]>
benchmarkMeshTransfer
▸ benchmarkMeshTransfer(options): Promise<MeshTransferBenchmarkResult>
Parameters
| Name | Type |
|---|---|
options | MeshTransferBenchmarkOptions |
Returns
Promise<MeshTransferBenchmarkResult>
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 ; range: UV ; textureGroup: string }[] ; isTransparent: [boolean, boolean, boolean, boolean, boolean, boolean] } |
Returns
void
customizeMaterialShaders
▸ customizeMaterialShaders(idOrName, faceName?, data?): CustomChunkShaderMaterial
Parameters
| Name | Type | Default value |
|---|---|---|
idOrName | string | number | undefined |
faceName | string | null |
data | Object | undefined |
data.fragmentShader | string | undefined |
data.uniforms? | Object | undefined |
data.vertexShader | string | undefined |
Returns
dispose
▸ dispose(): void
Returns
void
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[]