World & Chunk Management
advanced scriptingVoxel Play 3 · Scripting / API
VoxelPlayEnvironment. Access via VoxelPlayEnvironment.instance.
Singleton Access
static VoxelPlayEnvironment instance { get; }Returns the global Voxel Play API instance. This is the entry point for all API calls.
World Operations
void ReloadWorld(bool keepWorldChanges = true)Reloads the entire world. Optionally preserves player-made changes.
- keepWorldChanges
- If true, voxel modifications by the player are retained after reload.
void DestroyAllVoxels()Clears all chunks and reinitializes world structures. Use with caution — all voxel data is lost.
void Redraw(bool reloadWorldTextures = false)Forces a full redraw of all rendered chunks. Optionally reloads world textures from disk.
void NotifyCameraMove()Notifies the engine that the camera or anchor has moved. Forces immediate chunk visibility checks. Useful when teleporting the camera.
Chunk Visibility
bool ChunksToggle()Toggles visibility of all chunks. Returns the new visibility state.
void ChunksToggle(bool visible)Sets visibility of all chunks to the specified state.
void ChunksExport()Exports all currently rendered chunks as regular GameObjects. Useful for baking or external processing.
Chunk Access
bool GetChunk(Vector3d position, out VoxelChunk chunk, bool forceCreation = false)Gets the chunk at the given world position. Returns true if found.
- position
- World position to query.
- chunk
- Output: the chunk at that position.
- forceCreation
- If true, creates the chunk if it does not exist yet.
VoxelChunk GetChunk(Vector3d position, bool forceCreation = false)Returns the chunk at the given position, or null if not found.
VoxelChunk GetChunkUnpopulated(Vector3d position)Returns an unpopulated chunk at the given position without invoking the terrain generator. Useful for manually filling chunks.
VoxelChunk GetChunkUnpopulated(int chunkX, int chunkY, int chunkZ)Returns an unpopulated chunk by chunk grid coordinates.
VoxelChunk GetCurrentChunk()Returns the chunk where the camera or player is currently located.
Vector3d GetChunkPosition(Vector3d position)Converts a world position to its chunk's origin position (snapped to chunk grid).
void GetChunks(List<VoxelChunk> chunks, ChunkModifiedFilter modifiedFilter = ChunkModifiedFilter.All)Fills a list with all currently created chunks, optionally filtered by modification status.
void GetChunks(Boundsd bounds, List<VoxelChunk> chunks)Gets all chunks within the specified world bounds.
void GetChunksPositions(Boundsd bounds, List<Vector3d> chunksPositions)Gets the positions of all chunks within the specified bounds.
void ChunkCheckArea(Vector3d position, Vector3 chunkExtents, bool renderChunks = false)Ensures chunks are created (and optionally rendered) within the specified area around a position.
Chunk Destruction
bool ChunkDestroy(Vector3d position)Destroys the chunk at the given world position. Returns true if a chunk was found and destroyed.
bool ChunkDestroy(VoxelChunk chunk)Destroys the specified chunk object.
Chunk Queries
bool ChunkHasNavMeshReady(VoxelChunk chunk)Returns true if the chunk has a NavMesh surface generated and ready for pathfinding.
bool ChunkIsInFrustum(VoxelChunk chunk)Returns true if the chunk is currently within the camera frustum.
Chunk Redraw
void ChunkRedraw(VoxelChunk chunk, bool includeNeighbors = false, bool refreshLightmap = true, bool refreshMesh = true)Refreshes the mesh and/or lightmap for a specific chunk.
- chunk
- The chunk to refresh.
- includeNeighbors
- Also refresh adjacent chunks (needed for seamless borders).
- refreshLightmap
- Recalculate lighting for the chunk.
- refreshMesh
- Rebuild the chunk's geometry mesh.
void ChunkRedraw(Boundsd bounds, bool refreshLightmap = true, bool refreshMesh = true, bool ignoreFrustum = false)Creates and renders all chunks within a bounds region, even if they are outside the visible distance. Useful for forcing terrain generation when the camera is far from the terrain surface.
- bounds
- World-space bounds defining the region to redraw.
- ignoreFrustum
- If true, chunks outside the camera frustum are also rendered.
void ChunkRedrawAll(bool refreshLightmap = true, bool refreshMesh = true)Refreshes all chunks within visible distance.
Runtime Properties
bool captureChunkChanges { get; set; }Enables or disables chunk modification tracking. When enabled, modified chunks can be saved and restored.
int chunksCreatedTotal number of chunks created since initialization.
int chunksUsedNumber of chunks currently in active use.
int chunksInRenderQueueCountNumber of chunks currently waiting in the render queue.
int chunksDrawnNumber of chunks drawn in the last frame.
Suggest an improvement
Help us improve this documentation page.