Base type for voxel-based 3D structures. More...
| Import Statement: | import Clayground.Canvas3D |
| Inherited By: |
VoxelMap is the abstract base type for StaticVoxelMap and DynamicVoxelMap. It provides common properties and methods for working with voxel grids, including edge rendering, toon shading, and shape filling operations.
Use StaticVoxelMap for large, unchanging voxel structures, or DynamicVoxelMap for voxels that change frequently.
See also StaticVoxelMap and DynamicVoxelMap.
autoCommit : bool |
Whether to automatically commit changes.
Defaults to true.
depth : real |
Total depth of the voxel map in world units.
edgeColorFactor : real |
Darkening factor for edges.
Defaults to 1.0.
edgeThickness : real |
Thickness of grid edge lines.
Defaults to 0.05.
height : real |
Total height of the voxel map in world units.
model : var |
The underlying voxel data model.
showEdges : bool |
Whether to render voxel grid lines.
Defaults to true.
spacing : real |
Gap between adjacent voxels in world units.
Defaults to 0.0 for solid voxel structures.
useToonShading : bool |
Enables cartoon-style rendering.
Creates a Minecraft-like aesthetic with distinct light/shadow boundaries. Works best with strong directional light shadows.
voxelCountX : int |
Number of voxels along the X axis.
voxelCountY : int |
Number of voxels along the Y axis (height).
voxelCountZ : int |
Number of voxels along the Z axis.
voxelOffset : vector3d |
Offset applied to voxel edge calculations.
voxelSize : real |
Size of each voxel cube in world units.
Defaults to 1.0.
width : real |
Total width of the voxel map in world units.
Computed as: voxelCountX * (voxelSize + spacing) - spacing
void fill(var shapes) |
Fills the voxel map with shapes.
Accepts a single shape or an array of shapes. Each shape can be specified as an object or array with type and parameters.
Supported shapes: "sphere", "cylinder", "box"
Example:
fill([
{ sphere: { pos: Qt.vector3d(5,5,5), radius: 3, colors: ["red"] } },
["box", [0, 0, 0, 10, 1, 10, "green"]]
])
color get(int x, int y, int z) |
Returns the color of the voxel at the specified coordinates.
void load(string path) |
Loads voxel data from a file.
void save(string path) |
Saves voxel data to a file.
void set(int x, int y, int z, color color) |
Sets the color of the voxel at the specified coordinates.