Class ScyllaPlaneShape
Parametric horizontal plane in the XZ plane with configurable width, depth, and optional
per-axis subdivisions for vertex displacement effects. Normals point up (+Y). UVs map the
full surface to (0,0)..(1,1). The plane is centered at local origin.
Inherited Members
Namespace: Scylla.Core.Util.Geom
Assembly: ScyllaCore.dll
Syntax
[AddComponentMenu("Scylla/Geometry/Plane")]
public sealed class ScyllaPlaneShape : ScyllaShapeBase3D
Remarks
Unlike Unity's built-in plane primitive (a fixed 10x10 unit mesh with 10x10
subdivisions), this shape defaults to a 1x1 single-quad mesh with no
subdivisions. Set Subdivisions to a value greater than 0 to introduce
intermediate vertices suitable for runtime vertex deformation (e.g. water surface,
procedural terrain patches).
Vertex count is (subdivisions + 2) ^ 2; triangle count is
(subdivisions + 1) ^ 2 * 2. The subdivision count is clamped to
[0, 128] in Build(Mesh, float, float, int, IFaceColorResolver).
When ColliderMode is MatchingPrimitive, a very thin UnityEngine.BoxCollider (0.001 units tall) matching the plane footprint is attached, which is more efficient than a UnityEngine.MeshCollider for flat surfaces that do not need exact mesh-shaped collision.
The whole plane is treated as a single logical face for per-face coloring purposes, so FaceColoringMode assigns one uniform color to all vertices regardless of subdivision count.
Properties
Depth
Plane size along the Z axis. Stored in Height of the backing
Scylla.Core.Util.Geom.ScyllaPlaneShape._size field. Values below 0.0001 are clamped when set and at build
time. Setting this triggers an immediate mesh rebuild and updates Size.
Declaration
public float Depth { get; set; }
Property Value
| Type | Description |
|---|---|
| float |
Size
Plane extent on the XZ plane as a Size2D. Width
maps to the X axis, Height maps to the Z axis. Components below
0.0001 are clamped when set and at build time. Setting this triggers an
immediate mesh rebuild.
Declaration
public Size2D Size { get; set; }
Property Value
| Type | Description |
|---|---|
| Size2D |
Subdivisions
Per-axis subdivision count. A value of 0 produces a single quad (4 vertices, 2
triangles). Higher values add rows and columns of intermediate vertices, useful for
runtime vertex displacement. Clamped to [0, 128] inside Build(Mesh, float, float, int, IFaceColorResolver).
Setting this triggers an immediate mesh rebuild.
Declaration
public int Subdivisions { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
Width
Plane size along the X axis. Values below 0.0001 are clamped when set and at
build time. Setting this triggers an immediate mesh rebuild and updates
Size.
Declaration
public float Width { get; set; }
Property Value
| Type | Description |
|---|---|
| float |
Methods
Build(Mesh, float, float, int, IFaceColorResolver)
Populates target with a flat plane mesh on the XZ plane, centered
at local origin. Existing mesh data is overwritten. The caller is responsible for
calling UnityEngine.Mesh.RecalculateBounds() if the mesh is meant to be rendered.
Declaration
public static void Build(Mesh target, float width, float depth, int subdivisions, IFaceColorResolver resolver = null)
Parameters
| Type | Name | Description |
|---|---|---|
| Mesh | target | Destination mesh. Must be non-null. |
| float | width | Plane size along the X axis, in local units. Clamped to a minimum of |
| float | depth | Plane size along the Z axis, in local units. Clamped to a minimum of |
| int | subdivisions | Number of subdivisions per axis. 0 produces a 4-vertex single quad; each additional
step adds one row and column of vertices. Clamped to |
| IFaceColorResolver | resolver | Optional per-face color resolver. When non-null, the entire plane is treated as face
index 0 of 1 and a single resolved color is broadcast to all vertices via the
per-vertex color channel. When |
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.