A 3D box with customizable dimensions, edge rendering, and toon shading. More...
| Import Statement: | import Clayground.Canvas3D |
| Inherited By: |
Box3D provides a convenient way to create 3D boxes with cartoon-style edge rendering and optional toon shading. The box origin is at the bottom center, making it easy to place objects on ground planes.
Example usage:
import QtQuick3D import Clayground.Canvas3D Box3D { width: 100 height: 150 depth: 100 color: "red" useToonShading: true showEdges: true edgeColorFactor: 0.4 }
See also Box3DGeometry.
allEdges : int |
Convenience constant for showing all edges.
bevel : real |
Chamfers every edge and corner, as a fraction of the box's shortest edge. 0 (the default) is a hard box.
Rounds the shape without rounding the cost: 44 triangles instead of 12 and the same single draw call, which is the only budget that matters here. The outline is unaffected - it is drawn from the face UVs rather than from the triangulation, and the chamfers are given a flat UV so the shader skips them.
Not for use with edgeMode: Triangles, which draws lines along the triangulation itself and will outline every chamfer seam.
See also Box3DGeometry::bevel.
color : color |
The base color of the box.
Defaults to red.
depth : real |
Depth of the box along the Z axis.
Defaults to width (creating a cube by default).
edgeColor : color |
The edge color, as an absolute color rather than a factor.
Wins over edgeColorFactor as soon as it has a visible alpha, which is what counts as set here - a fully transparent edge has no meaning, so it serves as the unset sentinel and leaves opaque black reachable.
Box3D { color: "#e6d2f2" edgeColor: "#2f3437" // dark grey edges on a light face }
edgeColorFactor : real |
Darkening factor for edges (0-1).
Lower values create darker edges. Ignored once edgeColor is set.
edgeMask : int |
edgeMode : enumeration |
Which lines showEdges draws.
| Constant | Description |
|---|---|
Box3D.FaceBorders | The twelve borders of the six faces - a box drawn as a box. The default. |
Box3D.Triangles | The box's actual triangulation, so every face also shows the diagonal splitting it into two triangles. For showing how the mesh is built rather than what it depicts. |
edgeMask selects among the face borders and applies to FaceBorders only; in Triangles mode every triangle edge is drawn and the mask is ignored.
Box3D { color: "#0f9d9a" edgeMode: Box3D.Triangles edgeColor: "#101820" edgeThickness: 2 }
See also Box3DGeometry::edgeMode.
edgeThickness : real |
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 for the selected face.
See also Box3DGeometry::faceScale.
height : real |
Height of the box along the Y axis.
Defaults to width (creating a cube by default).
scaledFace : enumeration |
Which face of the box should be scaled.
Use with faceScale to create pyramids, trapezoids, etc.
See also Box3DGeometry::scaledFace.
showEdges : bool |
Whether to render dark edge lines.
Defaults to true.
useToonShading : bool |
Enables cartoon-style rendering.
When enabled, uses half-lambert lighting for softer shadows, disables specular highlights and IBL. Works best with strong directional light shadows.
width : real |
Width of the box along the X axis.
Defaults to 1.0.