Skip to content

SphereGeometry

Generates a sphere geometry assignable to any mesh.

[SphereGeometry](/reference/geometries/sphere_geometry) creates a UV sphere composed of triangles, configurable via radius, width segments (longitude), and height segments (latitude). It’s useful for rendering planets, lighting probes, collision volumes, or decorative primitives.

cpp
auto geometry = vglx::SphereGeometry::Create({
    .radius = 1.5f,
    .width_segments = 48,
    .height_segments = 24
});

auto mesh = vglx::Mesh::Create(geometry, UnlitMaterial::Create(0x049EF4));
my_scene->Add(mesh);

INFO

Derives from Geometry and inherits all public properties and methods.

Construction

Constructors


SphereGeometry()

cpp
vglx::SphereGeometry::SphereGeometry(const Parameters &params)
ParameterDescription
paramsSphereGeometry::Parameters

Constructs a SphereGeometry object.

Factories preferred


SphereGeometry::Create() auto

cpp
static auto vglx::SphereGeometry::Create()

Creates a shared pointer to a SphereGeometry object with default parameters.

SphereGeometry::Create() auto

cpp
static auto vglx::SphereGeometry::Create(const Parameters &params)
ParameterDescription
paramsSphereGeometry::Parameters

Creates a shared pointer to a SphereGeometry object.

Types

SphereGeometry::Parameters struct

Parameters for constructing a SphereGeometry object.

NameTypeDescription
height_segmentsunsignedSubdivisions along the height.
radiusfloatRadius of the sphere.
width_segmentsunsignedSubdivisions along the width.

Released under the MIT License.