Class ScyllaTorusShape
Parametric torus (donut) shape with configurable major radius, minor radius, ring
segments, and tube segments, centered on the origin in the XZ plane. Normals are
smooth around both axes; UVs map the ring angle to u and the tube angle to v.
Inherited Members
Namespace: Scylla.Core.Util.Geom
Assembly: ScyllaCore.dll
Syntax
[AddComponentMenu("Scylla/Geometry/Torus")]
public sealed class ScyllaTorusShape : ScyllaShapeBase3D
Remarks
The major radius (MajorRadius) is the distance from the torus center to the center of the tube. The minor radius (MinorRadius) is the radius of the tube cross-section. The torus lies in the XZ plane and is centered at the origin; the tube sweeps a full 360 degrees around the Y axis.
Both segment counts are clamped to [3, 256]. Vertex count is
(ringSegments + 1) * (tubeSegments + 1) and triangle index count is
ringSegments * tubeSegments * 6. Vertices on opposite seam edges are
duplicated so that UVs wrap cleanly without a discontinuity artifact.
Per-vertex coloring (see FaceColoringMode) uses per-vertex dispatch: the resolver is called once per vertex with the vertex index and local position. This produces smooth spatial gradients under GradientByY (which varies the color by tube elevation) and per-vertex variation under Cycle or Hash.
The static Build(Mesh, float, float, int, int, IFaceColorResolver) method can be called directly to populate any UnityEngine.Mesh without attaching a component, which is useful for procedural mesh pipelines.
Properties
MajorRadius
Distance from the torus center to the center of the tube cross-section, 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 MajorRadius { get; set; }
Property Value
| Type | Description |
|---|---|
| float |
MinorRadius
Radius of the tube cross-section 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 MinorRadius { get; set; }
Property Value
| Type | Description |
|---|---|
| float |
RingSegments
Number of subdivisions around the main ring. Clamped to [3, 256] when set and
at build time. Setting this property triggers an immediate mesh rebuild via
Rebuild().
Declaration
public int RingSegments { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
TubeSegments
Number of subdivisions around the tube cross-section. Clamped to [3, 256]
when set and at build time. Setting this property triggers an immediate mesh rebuild via
Rebuild().
Declaration
public int TubeSegments { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
Methods
Build(Mesh, float, float, int, int, IFaceColorResolver)
Populates target with a parametric torus mesh. Existing mesh data
is overwritten. Both segment counts are clamped to [3, 256].
Declaration
public static void Build(Mesh target, float majorRadius, float minorRadius, int ringSegments, int tubeSegments, IFaceColorResolver resolver = null)
Parameters
| Type | Name | Description |
|---|---|---|
| Mesh | target | Destination mesh. Must be non-null. |
| float | majorRadius | Distance from the torus center to the tube center in local units. Determines the
overall diameter of the donut. Clamped to a minimum of |
| float | minorRadius | Radius of the tube cross-section in local units. Determines the thickness of the
donut ring. Values larger than |
| int | ringSegments | Number of subdivisions around the main ring (around the Y axis). Clamped to
|
| int | tubeSegments | Number of subdivisions around the tube cross-section. Clamped to |
| IFaceColorResolver | resolver | Optional per-vertex color resolver. Uses per-vertex dispatch: when non-null, a
per-vertex color channel is emitted where the resolver is called once per vertex
with the vertex index and local position. Yields smooth gradients under
GradientByY and per-vertex speckle under
Cycle or Hash.
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. |