geometry.sphere¶
Summary¶
geometry.sphere creates an indexed UV sphere centered at the origin. Radius defaults to 0.5, with 32 longitudinal and 16 latitudinal segments. Both segment counts must be positive integers.
Syntax¶
WasmGPU.geometry.sphere(radius?: number, widthSegments?: number, heightSegments?: number): Geometry
const result = wgpu.geometry.sphere(radius, widthSegments, heightSegments);
Parameters¶
| Name | Type | Required | Description |
|---|---|---|---|
radius |
number |
No | Radius value used by circular/spherical primitives. |
widthSegments |
number |
No | Number of longitudinal subdivisions. |
heightSegments |
number |
No | Number of latitudinal subdivisions. |
Returns¶
Geometry - Indexed UV-sphere geometry with normals, UVs, and computed bounds.
Example¶
const canvas = document.querySelector("canvas");
const wgpu = await WasmGPU.create(canvas);
const radius = 1;
const widthSegments = 32;
const heightSegments = 16;
const result = wgpu.geometry.sphere(radius, widthSegments, heightSegments);
console.log(result);