Primitive Shapes

The engine can generate procedural meshes for common 3D shapes without requiring external model files. Each primitive is centered at the origin with exact user-specified dimensions. Position, rotation, and scale are handled by the Transform component.

Available Shapes

Box

A six-faced cuboid with per-face normals.

int meshId = NativeBridge.CreateBoxMesh(2f, 1f, 3f, new Color(0.8f, 0.2f, 0.2f));
ParameterDescription
w, h, lWidth (X), height (Y), length (Z)
Color cVertex color

Sphere

A UV sphere with outward-pointing normals.

int meshId = NativeBridge.CreateSphereMesh(0.5f, 32, 16, new Color(0.2f, 0.8f, 0.2f));
ParameterDescription
radiusSphere radius
segmentsHorizontal subdivisions (longitude)
ringsVertical subdivisions (latitude)
Color cVertex color

Plane

A flat quad on the XZ plane at Y=0, with normal pointing up.

int meshId = NativeBridge.CreatePlaneMesh(10f, 10f, new Color(0.3f, 0.8f, 0.3f));
ParameterDescription
w, hWidth (X) and depth (Z)
Color cVertex color

Cylinder

A capped cylinder aligned along the Y axis.

int meshId = NativeBridge.CreateCylinderMesh(0.4f, 1f, 32, new Color(0.2f, 0.2f, 0.8f));
ParameterDescription
radiusCylinder radius
heightTotal height
segmentsNumber of sides
Color cVertex color

Capsule

A cylinder with hemisphere caps. Total height = height + 2 * radius.

int meshId = NativeBridge.CreateCapsuleMesh(0.3f, 0.6f, 32, 16, new Color(0.9f, 0.8f, 0.2f));
ParameterDescription
radiusRadius of caps and cylinder
heightLength of the cylinder portion
segmentsHorizontal subdivisions
ringsVertical subdivisions per hemisphere
Color cVertex color

Convenience Overloads

Every shape has a short form that uses default color (grey 0.7) and default tessellation (32 segments, 16 rings):

int box    = NativeBridge.CreateBoxMesh(1f, 1f, 1f);
int sphere = NativeBridge.CreateSphereMesh(0.5f);
int plane  = NativeBridge.CreatePlaneMesh(10f, 10f);
int cyl    = NativeBridge.CreateCylinderMesh(0.4f, 1f);
int cap    = NativeBridge.CreateCapsuleMesh(0.3f, 0.6f);

Usage with ECS

Primitive meshes work exactly like glTF meshes. The returned mesh ID can be shared across multiple entities:

int boxMesh = NativeBridge.CreateBoxMesh(1f, 1f, 1f, new Color(0.8f, 0.2f, 0.2f));

// Spawn an entity with the box
int box = world.SpawnMeshEntity(boxMesh, new Transform {
    Position = new Vec3(0f, 0.5f, 0f)
});
Note

Unlike glTF meshes, procedural primitives are not auto-centered or auto-scaled. They are generated at the exact dimensions you specify, centered at the origin.