Class ScyllaCrateShape
Parametric crate: a box with each of its six outer faces split into a mitered picture-frame rim around a recessed inset panel. The rim is built from four trapezoidal strips, the panel is a single inner quad pushed inward by TrimDepth, and four step walls close the recess so the solid is watertight.
Inherited Members
Namespace: Scylla.Core.Util.Geom
Assembly: ScyllaCore.dll
Syntax
[AddComponentMenu("Scylla/Geometry/Crate")]
public sealed class ScyllaCrateShape : ScyllaShapeBase3D
Remarks
The crate exposes two per-face color granularities controlled by ColoringMode:
-
Frame + panels (default,
FrameAndPanels): two resolver indices for the
whole crate. Index
0covers the framing (all 24 rim panels and 24 step walls across the six sides), index1covers the inset panels (all six). Produces the realistic "darker recessed panel against a wood frame" look with no per-side color juggling. -
Per-side (PerSide): six resolver indices,
one per side, in the order
+Z, -Z, +Y, -Y, +X, -X. All nine mesh quads on a side share that side's color. Cleaner readout when the palette has few entries.
TrimInset is the in-plane offset between the outer face perimeter and the rim's inner edge (i.e., the frame width). TrimDepth is the perpendicular offset between the rim plane and the recessed inset panel. Both are clamped: the inset is capped at just under half the smaller face dimension (so the rim never collapses to zero), and the depth is non-negative.
When TrimDepth is zero the crate degenerates to a regular box with extra vertices; TrimInset is then visually inert. Both parameters defaulting to non-zero values produces the classic wooden-crate panel look.
Properties
ColoringMode
Selects the per-face color granularity used when a IFaceColorResolver is active. FrameAndPanels (default) emits 2 resolver indices for the entire crate; PerSide emits 6 (one per side). Geometry is identical in all modes; only the per-vertex color assignment changes. Setting this property triggers an immediate mesh rebuild.
Declaration
public CrateColoringMode ColoringMode { get; set; }
Property Value
| Type | Description |
|---|---|
| CrateColoringMode |
Size
Outer crate dimensions as a Size3D. Each axis is independent. Setting this property triggers an immediate mesh rebuild.
Declaration
public Size3D Size { get; set; }
Property Value
| Type | Description |
|---|---|
| Size3D |
TrimDepth
Perpendicular depth by which each inset panel is recessed below the rim plane, in mesh
units. Clamped to non-negative when set and at build time. Set to 0 for a flat-face box with
visible frame divisions but no visible recess. Setting this property triggers an
immediate mesh rebuild.
Declaration
public float TrimDepth { get; set; }
Property Value
| Type | Description |
|---|---|
| float |
TrimInset
In-plane width of the picture-frame rim around each face's inset panel, in mesh units. Clamped at build time to a small positive minimum and capped at just under half the smaller face dimension so the rim never collapses to zero. Setting this property triggers an immediate mesh rebuild.
Declaration
public float TrimInset { get; set; }
Property Value
| Type | Description |
|---|---|
| float |
Methods
Build(Mesh, float, float, float, float, float, CrateColoringMode, IFaceColorResolver)
Populates target with a parametric crate mesh sized to
width × height × depth.
Existing mesh data is overwritten.
Declaration
public static void Build(Mesh target, float width, float height, float depth, float trimInset, float trimDepth, CrateColoringMode coloringMode = CrateColoringMode.FrameAndPanels, IFaceColorResolver resolver = null)
Parameters
| Type | Name | Description |
|---|---|---|
| Mesh | target | Destination mesh. Must be non-null. |
| float | width | Size along the X axis. |
| float | height | Size along the Y axis. |
| float | depth | Size along the Z axis. |
| float | trimInset | Width of the rim frame around each inset panel, in mesh units. Clamped to a small positive value and capped at just under half the smaller face dimension so the rim never collapses to zero. |
| float | trimDepth | Depth of the recessed inset panel below the rim plane, in mesh units. Clamped to non-negative; zero produces a flat box (the rim is still emitted but contributes no visible recess). |
| CrateColoringMode | coloringMode | Selects how the resolver indices are assigned. FrameAndPanels
(the default) uses two indices total - |
| IFaceColorResolver | resolver | Optional per-face color resolver. When non-null, a per-vertex color channel is emitted with one solid color per logical face. When null, no color channel is written. |
BuildMesh(Mesh)
Subclass extension point: write vertex / triangle / normal / uv data into
target from the shape's serialized parameters. The base class
calls Clear(bool) before invoking this method and
UnityEngine.Mesh.RecalculateBounds() afterwards, so subclasses should not invoke
either themselves.
Declaration
protected override void BuildMesh(Mesh target)
Parameters
| Type | Name | Description |
|---|---|---|
| Mesh | target | The owned mesh to populate. Already cleared by the base class. |
Overrides
GetMeshName()
Returns the shape's mesh name as it should appear on the generated mesh asset. Defaults to the subclass type name; override to provide a friendlier label.
Declaration
protected override string GetMeshName()
Returns
| Type | Description |
|---|---|
| string | A short identifier for the generated mesh, used as UnityEngine.Object.name. |
Overrides
TryAttachPrimitiveCollider()
Subclass extension point: when ColliderMode is
MatchingPrimitive, obtain the appropriate primitive
collider through GetOrAddManagedCollider<T>(), size it to the current
parameters, and return true. Return false to let the base class fall
back to UnityEngine.MeshCollider.
Declaration
protected override bool TryAttachPrimitiveCollider()
Returns
| Type | Description |
|---|---|
| bool |
|
Overrides
Remarks
Runs on every rebuild. Always go through GetOrAddManagedCollider<T>()
rather than AddComponent: it reuses the collider from the previous rebuild,
so the override only has to update its size and center. A collider added directly
is not tracked by the shape and a new one would be added on every rebuild.