← Back to Docs
  • index.html
  • Clayground
  • Clayground.Canvas3D
  • Box3DGeometry
  • Clayground 2026.7
  • Box3DGeometry QML Type

    Custom geometry for 3D boxes with edge rendering support. More...

    Import Statement: import Clayground.Canvas3D

    Properties

    Detailed Description

    Box3DGeometry provides the geometry data for rendering 3D boxes with customizable dimensions, face scaling, and edge rendering. It is typically used internally by the Box3D QML component.

    The geometry is centered on the X and Z axes, with the origin at the bottom center (Y=0 is the floor).

    Example usage:

    import QtQuick3D
    import Clayground.Canvas3D
    
    Model {
        geometry: Box3DGeometry {
            size: Qt.vector3d(2, 3, 2)
            showEdges: true
            edgeThickness: 0.05
        }
        materials: DefaultMaterial { diffuseColor: "red" }
    }

    See also Box3D.

    Property Documentation

    edgeColor : color

    The edge color, as an absolute color rather than a factor.

    Takes precedence over edgeColorFactor as soon as it has a visible alpha, which is what "set" means here - a fully transparent edge has no meaning, so it serves as the unset sentinel and leaves opaque black reachable. Defaults to transparent, so edgeColorFactor keeps deciding.


    edgeColorFactor : real

    Darkening factor for edge colors.

    A value between 0 and 1 that determines how dark the edges appear relative to the base color. Lower values create darker edges. Defaults to 0.4.

    Ignored once edgeColor is set.


    edgeMask : int

    Bitmask controlling which edges are visible.

    Use the EdgeFlags enum values combined with bitwise OR to select specific edges. Defaults to AllEdges.

    ConstantDescription
    Box3DGeometry.AllEdgesShow all edges (0xFF)
    Box3DGeometry.TopEdgesShow only top face edges
    Box3DGeometry.BottomEdgesShow only bottom face edges
    Box3DGeometry.FrontEdgesShow only front face edges
    Box3DGeometry.BackEdgesShow only back face edges
    Box3DGeometry.LeftEdgesShow only left face edges
    Box3DGeometry.RightEdgesShow only right face edges

    edgeMode : enumeration

    Which lines showEdges draws.

    ConstantDescription
    Box3DGeometry.FaceBordersThe twelve borders of the six faces - a box drawn as a box. The default, and what edgeMask selects from.
    Box3DGeometry.TrianglesThe box's actual triangulation, so every face also shows the diagonal that splits it into two triangles. For showing how the mesh is built rather than what it depicts.

    edgeMask applies to FaceBorders only. In Triangles mode every triangle edge is drawn and the mask is ignored, because a triangulation with parts of it missing is not a triangulation.

    Switching modes costs a uniform write, not a rebuild: the barycentric coordinates Triangles needs sit in the vertex buffer either way.


    edgeThickness : real

    The thickness of edge lines in pixels.

    Screen-space, so an edge keeps its weight as the camera moves - and the same width VoxelMap::edgeThickness produces, not just the same unit. A line straddles the boundary it marks and each surface draws half of it, so a box border and a voxel map's border come out equal at the same setting; a voxel map's interior grid lines sit entirely on one face and so draw the full width.

    Defaults to 0.03, which is thinner than one pixel - set it to a few pixels to see anything.


    faceScale : vector2d

    Scale factor applied to the selected face.

    When scaledFace is set to a specific face, this vector determines how much that face is scaled in its local X and Y dimensions. Useful for creating pyramids, trapezoids, and other non-uniform shapes.

    Defaults to (1, 1).


    scaledFace : enumeration

    Which face of the box should be scaled.

    ConstantDescription
    Box3DGeometry.NoFaceNo face scaling (default)
    Box3DGeometry.TopFaceScale the top face
    Box3DGeometry.BottomFaceScale the bottom face
    Box3DGeometry.FrontFaceScale the front face
    Box3DGeometry.BackFaceScale the back face
    Box3DGeometry.LeftFaceScale the left face
    Box3DGeometry.RightFaceScale the right face

    showEdges : bool

    Whether to render edge lines on the box.

    When true, dark lines are drawn along the edges of the box for a cartoon-style appearance. Defaults to true.


    size : vector3d

    The dimensions of the box as a 3D vector (width, height, depth).

    Defaults to (1, 1, 1).