← Back to Docs
  • index.html
  • Clayground
  • Clayground.Canvas3D
  • DynamicVoxelMap
  • Clayground 2025.2
  • DynamicVoxelMap QML Type

    Voxel map optimized for frequent updates using GPU instancing. More...

    Import Statement: import Clayground.Canvas3D
    Inherits:

    VoxelMap

    Properties

    Detailed Description

    DynamicVoxelMap renders each voxel as a separate GPU instance, making it efficient to update individual voxels without regenerating the entire mesh. This is ideal for voxel structures that change frequently, such as destructible terrain or building systems.

    For large, static voxel structures, use StaticVoxelMap instead for better rendering performance.

    Example usage:

    import Clayground.Canvas3D
    
    DynamicVoxelMap {
        id: voxels
        voxelCountX: 20
        voxelCountY: 20
        voxelCountZ: 20
        voxelSize: 1.0
    
        Timer {
            running: true
            interval: 100
            repeat: true
            onTriggered: {
                var x = Math.floor(Math.random() * 20)
                var y = Math.floor(Math.random() * 20)
                var z = Math.floor(Math.random() * 20)
                voxels.set(x, y, z, Qt.rgba(Math.random(), Math.random(), Math.random(), 1))
            }
        }
    }

    See also StaticVoxelMap and VoxelMapInstancing.

    Property Documentation

    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.