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. You can optionally disable this by setting shouldGenerateChunkMeshes
to false
in the options.
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
chunks
• chunks: Chunks
The manager that holds all chunk-related data, such as chunk meshes and voxel data.
clouds
• clouds: Clouds
The clouds that renders the cubical clouds.
isInitialized
• isInitialized: boolean
= false
Whether or not this world is connected to the server and initialized with data from the server.
loader
• loader: Loader
An asset loader to load in things like textures, images, GIFs and audio buffers.
options
• options: WorldOptions
The options to create the world.
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.
sky
• sky: Sky
The sky that renders the sky and the sun.
Accessors
deleteRadius
• get
deleteRadius(): number
Returns
number
renderRadius
• get
renderRadius(): number
Returns
number
• set
renderRadius(radius
): void
Parameters
Name | Type |
---|---|
radius | number |
Returns
void
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