Custom geometry for 3D boxes with edge rendering support. More...
| Import Statement: | import Clayground.Canvas3D |
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.
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.
| Constant | Description |
|---|---|
Box3DGeometry.AllEdges | Show all edges (0xFF) |
Box3DGeometry.TopEdges | Show only top face edges |
Box3DGeometry.BottomEdges | Show only bottom face edges |
Box3DGeometry.FrontEdges | Show only front face edges |
Box3DGeometry.BackEdges | Show only back face edges |
Box3DGeometry.LeftEdges | Show only left face edges |
Box3DGeometry.RightEdges | Show only right face edges |
edgeMode : enumeration |
Which lines showEdges draws.
| Constant | Description |
|---|---|
Box3DGeometry.FaceBorders | The twelve borders of the six faces - a box drawn as a box. The default, and what edgeMask selects from. |
Box3DGeometry.Triangles | The 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.
| Constant | Description |
|---|---|
Box3DGeometry.NoFace | No face scaling (default) |
Box3DGeometry.TopFace | Scale the top face |
Box3DGeometry.BottomFace | Scale the bottom face |
Box3DGeometry.FrontFace | Scale the front face |
Box3DGeometry.BackFace | Scale the back face |
Box3DGeometry.LeftFace | Scale the left face |
Box3DGeometry.RightFace | Scale 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).