pub struct VoxelChunk {
pub asset_id: AssetId,
pub palette: Vec<AssetId>,
pub dim: [u32; 3],
pub block_size: f32,
pub blocks: Vec<u32>,
pub lod_levels: u32,
pub lod_distances: Vec<f32>,
pub locator: Option<PayloadLocator>,
}Expand description
A voxel grid that compiles into a single mesh.
A dense grid of blocks compiled into a single mesh at build time. Use one
chunk per region of a voxel/Minecraft-style world; reference it from a
Prop’s mesh field. Hidden faces between two solid blocks are
dropped, so a fully filled chunk contributes zero triangles to its interior.
The palette must contain at least one entry whose BlockType has
solid: false (typically named air); cells whose palette entry is
non-solid emit no faces. Faces are only emitted between a solid block and
either an empty neighbour or the outside of the chunk.
Fields§
§asset_id: AssetIdAsset identity; injected via inject_name. Not part of args.
palette: Vec<AssetId>BlockType asset names. blocks[i] is an index into this list.
dim: [u32; 3]Chunk dimensions [dx, dy, dz] in blocks.
block_size: f32World units per block edge.
blocks: Vec<u32>Flat block array, length dx*dy*dz. Index = x + y*dx + z*dx*dy.
lod_levels: u32Number of level-of-detail versions to generate, including the original.
1 (the default) generates none.
lod_distances: Vec<f32>Camera distances at which to switch to each lower-detail version; empty lets the build choose defaults.
locator: Option<PayloadLocator>Injected at load time from the compiled blob payload.
Trait Implementations§
Source§impl Clone for VoxelChunk
impl Clone for VoxelChunk
Source§fn clone(&self) -> VoxelChunk
fn clone(&self) -> VoxelChunk
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Component for VoxelChunk
impl Component for VoxelChunk
Source§const NAME: &'static str = "VoxelChunk"
const NAME: &'static str = "VoxelChunk"
Source§fn inject_locator(&mut self, locator: PayloadLocator)
fn inject_locator(&mut self, locator: PayloadLocator)
Source§fn inject_name(&mut self, id: AssetId)
fn inject_name(&mut self, id: AssetId)
Source§fn from_baked(bytes: &[u8]) -> Result<Self, CnResult>
fn from_baked(bytes: &[u8]) -> Result<Self, CnResult>
Source§impl ComponentSlot for VoxelChunk
impl ComponentSlot for VoxelChunk
Source§const DISCRIMINANT: u8
const DISCRIMINANT: u8
ComponentId.