Class ScyllaIcoSphereShape
Parametric icosphere built by recursively subdividing an icosahedron and projecting each new vertex onto the unit sphere. Distinct from ScyllaSphereShape: the UV sphere has dense vertex packing at the poles and sparse packing at the equator, while the icosphere has near-uniform triangle size everywhere on its surface, which gives better silhouettes for organic blockouts, cleaner shading under low-key lighting, and more predictable per-vertex cost per unit of surface area.
Inherited Members
Namespace: Scylla.Core.Util.Geom
Assembly: ScyllaCore.dll
Syntax
[AddComponentMenu("Scylla/Geometry/Ico Sphere")]
public sealed class ScyllaIcoSphereShape : ScyllaShapeBase3D
Remarks
The base icosahedron is constructed from 12 vertices and 20 triangles using mutually perpendicular golden rectangles in each axis plane; all vertices are pre-normalized to the unit sphere. Each subdivision level replaces every triangle with four smaller triangles by inserting midpoints on each edge and projecting them back to the unit sphere. Edge midpoints shared between adjacent faces are cached so no vertex is duplicated.
Vertex and triangle counts grow rapidly: 12 / 20 at subdivision 0, then each level
multiplies the triangle count by 4. Level 5 produces 10,242 vertices and 20,480
triangles. Subdivisions is clamped to [0, 5]; level 6 would
produce approximately 41,000 vertices, which is excessive for a single editor-time
mesh and approaches the UInt16 index limit. At subdivision level 5, the builder
automatically switches the mesh index format to UInt32.
UVs use the standard spherical projection (longitude maps to u, latitude maps to v). This introduces a one-triangle seam at the back of the sphere where longitude wraps. Solid-tint and vertex-color rendering are unaffected; texture-mapped usage will show a thin seam artifact on the back face.
Per-face coloring uses per-vertex dispatch: Resolve(int, int, Vector3) is called once per vertex (passing the vertex index as the face index) rather than once per logical triangle region. Under GradientByY this produces a smooth vertical gradient; under Cycle or Hash it produces per-vertex color variation. See IFaceColorResolver for the full dispatch contract.
Properties
Radius
Icosphere radius in local units. Values below 0.0001 are clamped when set and at
build time. Setting this property triggers an immediate mesh rebuild via Rebuild().
Declaration
public float Radius { get; set; }
Property Value
| Type | Description |
|---|---|
| float | The radius of the icosphere. Default is |
Subdivisions
Number of recursive subdivision levels applied to the base icosahedron. Each level
multiplies the triangle count by four. The value is clamped to [0, 5] when set and at
build time. Setting this property triggers an immediate mesh rebuild via
Rebuild().
Declaration
public int Subdivisions { get; set; }
Property Value
| Type | Description |
|---|---|
| int | Subdivision level in the range |
Methods
Build(Mesh, float, int, IFaceColorResolver)
Populates target with a parametric icosphere mesh. Existing mesh
data is overwritten. subdivisions is clamped to [0, 5].
Declaration
public static void Build(Mesh target, float radius, int subdivisions, IFaceColorResolver resolver = null)
Parameters
| Type | Name | Description |
|---|---|---|
| Mesh | target | Destination mesh. Must be non-null. |
| float | radius | Icosphere radius in local units. Clamped to a minimum of |
| int | subdivisions | Number of recursive subdivision levels applied to the base icosahedron. Clamped to
|
| IFaceColorResolver | resolver | Optional per-vertex color resolver. Uses per-vertex dispatch: called once per
vertex with the vertex index as the face index and the vertex's local position as the
face center. Under GradientByY this produces a smooth
vertical gradient; under Cycle or
Hash it produces per-vertex color variation. Pass
|
Remarks
This static method is the pure mesh-data entry point and may be called without a ScyllaIcoSphereShape component - for example, to bake an icosphere mesh into a procedural asset at editor time. The component's Rebuild() delegates to this method automatically.
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.