PrimitiveMesh
Base for procedural primitives with one surface.
PrimitiveMesh generates one surface from concrete primitive parameters. Use BoxMesh, PlaneMesh, SphereMesh or another subclass for ordinary shapes; override _CreateMeshArray for a custom shape. Multiple MeshInstance3D instances can share one resource, so resource parameter changes affect all of them.
AddUV2 prepares a second UV channel without proving lighting was baked. See LightmapGI for Static mode, normals and suitable UV preparation. Consider ArrayMesh for multiple surfaces or arbitrary topology rather than simulating multiple surfaces in this class.
Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.
Constructors1
PrimitiveMeshConstructor
public PrimitiveMesh();Creates a base PrimitiveMesh resource, not a ready-made shape. Use BoxMesh, SphereMesh or another concrete primitive, or override _CreateMeshArray. The base class without vertices cannot produce a usable surface. AddUV2 and FlipFaces initially equal false; UV2Padding is 2.
Properties5
AddUV2Property
public bool AddUV2 { get; set; }Generate a second UV channel; defaults to false. Built-in primitives use their generator; for a custom array lacking UV2 the base fallback scales existing UV1 with padding. This is not an arbitrary-mesh unwrap: UV1 overlaps remain. Changing it updates geometry and the map size where supported by the specific primitive; rebake existing LightmapGI afterward.
CustomAabbProperty
public Aabb CustomAabb { get; set; }Custom mesh culling box; defaults to an empty Aabb. Does not move vertices or change the generated CPU-geometry bounds returned by GetAabb(). Useful for shader vertex displacement, for example; choose bounds covering the animation result.
FlipFacesProperty
public bool FlipFaces { get; set; }Invert indexed-triangle orientation. The base implementation negates normals and swaps the first two indices of each triangle when normals and indices are present. Defaults to false. Does not enable a double-sided material or replace cull-mode configuration.
MaterialProperty
public Material Material { get; set; }Material for the primitive single surface. Assignment changes the mesh resource and affects instances using it; this is not MeshInstance3D.MaterialOverride. Applies immediately when geometry exists, otherwise during generation. null clears the assignment. Returns a material reference, not an independent copy.
UV2PaddingProperty
public float UV2Padding { get; set; }UV2 padding, default 2. The specific generator combines it with map size and texel density. Changing it updates map size and geometry. The inspector hint 0…10 allows higher values and does not clamp the setter; use a finite nonnegative value. Large padding does not repair overlapping UVs or guarantee freedom from leaks.
Methods13
GetAddUV2bool
public bool GetAddUV2();Returns AddUV2. Generate a second UV channel; defaults to false. Built-in primitives use their generator; for a custom array lacking UV2 the base fallback scales existing UV1 with padding. This is not an arbitrary-mesh unwrap: UV1 overlaps remain. Changing it updates geometry and the map size where supported by the specific primitive; rebake existing LightmapGI afterward.
boolCurrent AddUV2 value.
GetCustomAabbAabb
public Aabb GetCustomAabb();Returns CustomAabb. Custom mesh culling box; defaults to an empty Aabb. Does not move vertices or change the generated CPU-geometry bounds returned by GetAabb(). Useful for shader vertex displacement, for example; choose bounds covering the animation result.
AabbCurrent CustomAabb value.
GetFlipFacesbool
public bool GetFlipFaces();Returns FlipFaces. Invert indexed-triangle orientation. The base implementation negates normals and swaps the first two indices of each triangle when normals and indices are present. Defaults to false. Does not enable a double-sided material or replace cull-mode configuration.
boolCurrent FlipFaces value.
GetMaterialMaterial
public Material GetMaterial();Returns Material. Material for the primitive single surface. Assignment changes the mesh resource and affects instances using it; this is not MeshInstance3D.MaterialOverride. Applies immediately when geometry exists, otherwise during generation. null clears the assignment. Returns a material reference, not an independent copy.
MaterialCurrent Material value.
GetMeshArraysReckfell.Collections.Array
public Reckfell.Collections.Array GetMeshArrays();Returns the channel array for the single surface 0, indexed by Mesh.ArrayType. Generates geometry first if needed. Slots may contain Nil when a channel is absent; do not expect a generated second UV channel with AddUV2 = false. Returned C# vertex arrays are copies; editing them does not upload new geometry into the resource. For a custom shape change its parameters and call RequestUpdate.
Reckfell.Collections.ArrayAn array of Mesh.ArrayType.Max slots containing surface channels.
GetUV2Paddingfloat
public float GetUV2Padding();Returns UV2Padding. UV2 padding, default 2. The specific generator combines it with map size and texel density. Changing it updates map size and geometry. The inspector hint 0…10 allows higher values and does not clamp the setter; use a finite nonnegative value. Large padding does not repair overlapping UVs or guarantee freedom from leaks.
floatCurrent UV2Padding value.
RequestUpdatevoid
public void RequestUpdate();Requests geometry rebuilding after a custom primitive parameter changes. When initial generation is pending it happens on the first surface/RID read. For existing geometry the call performs an update and emits Changed. Does not unwrap an imported mesh, run LightmapGI or automatically upload arbitrary edited C# arrays.
SetAddUV2void
public void SetAddUV2(bool addUV2);Sets AddUV2. Generate a second UV channel; defaults to false. Built-in primitives use their generator; for a custom array lacking UV2 the base fallback scales existing UV1 with padding. This is not an arbitrary-mesh unwrap: UV1 overlaps remain. Changing it updates geometry and the map size where supported by the specific primitive; rebake existing LightmapGI afterward.
| Name | Type | Default |
|---|---|---|
addUV2 | bool | — |
addUV2New AddUV2 value; follow the property usage rules.
SetCustomAabbvoid
public void SetCustomAabb(Aabb aabb);Sets CustomAabb. Custom mesh culling box; defaults to an empty Aabb. Does not move vertices or change the generated CPU-geometry bounds returned by GetAabb(). Useful for shader vertex displacement, for example; choose bounds covering the animation result.
| Name | Type | Default |
|---|---|---|
aabb | Aabb | — |
aabbNew CustomAabb value; follow the property usage rules.
SetFlipFacesvoid
public void SetFlipFaces(bool flipFaces);Sets FlipFaces. Invert indexed-triangle orientation. The base implementation negates normals and swaps the first two indices of each triangle when normals and indices are present. Defaults to false. Does not enable a double-sided material or replace cull-mode configuration.
| Name | Type | Default |
|---|---|---|
flipFaces | bool | — |
flipFacesNew FlipFaces value; follow the property usage rules.
SetMaterialvoid
public void SetMaterial(Material material);Sets Material. Material for the primitive single surface. Assignment changes the mesh resource and affects instances using it; this is not MeshInstance3D.MaterialOverride. Applies immediately when geometry exists, otherwise during generation. null clears the assignment. Returns a material reference, not an independent copy.
| Name | Type | Default |
|---|---|---|
material | Material | — |
materialNew Material value; follow the property usage rules.
SetUV2Paddingvoid
public void SetUV2Padding(float uV2Padding);Sets UV2Padding. UV2 padding, default 2. The specific generator combines it with map size and texel density. Changing it updates map size and geometry. The inspector hint 0…10 allows higher values and does not clamp the setter; use a finite nonnegative value. Large padding does not repair overlapping UVs or guarantee freedom from leaks.
| Name | Type | Default |
|---|---|---|
uV2Padding | float | — |
uV2PaddingNew UV2Padding value; follow the property usage rules.
_CreateMeshArrayReckfell.Collections.Array
public virtual Reckfell.Collections.Array _CreateMeshArray();Override to generate one surface. Return an Array of exactly Mesh.ArrayType.Max slots with a nonempty Vertex array; populate required normals, UVs, indices and other channels consistently. The base checks array size and vertices, not arbitrary topology validity. Use RequestUpdate after custom parameter changes rather than invoking the generator manually.
Indexed-triangle example with width validation; this illustrates the API rather than a finished showcase scene:
using System;
using Reckfell;
using Array = Reckfell.Collections.Array;
public partial class TrianglePrimitive : PrimitiveMesh
{
private float _width = 1f;
public TrianglePrimitive()
{
LightmapSizeHint = new Vector2I(32, 32);
}
public void SetWidth(float width)
{
if (!float.IsFinite(width) || width <= 0f)
throw new ArgumentOutOfRangeException(nameof(width));
_width = width;
RequestUpdate();
}
public override Array _CreateMeshArray()
{
var arrays = new Array();
arrays.Resize((int)Mesh.ArrayType.Max);
arrays[(int)Mesh.ArrayType.Vertex] = new Vector3[]
{ Vector3.Zero, new(_width, 0, 0), new(0, 0, 1) };
arrays[(int)Mesh.ArrayType.Normal] = new Vector3[]
{ Vector3.Up, Vector3.Up, Vector3.Up };
arrays[(int)Mesh.ArrayType.TexUV] = new Vector2[]
{ Vector2.Zero, Vector2.Right, Vector2.Down };
arrays[(int)Mesh.ArrayType.Index] = new int[] { 0, 2, 1 };
return arrays;
}
}Reckfell.Collections.ArrayChannel array for the new single surface.