Configuration object for generating the sphere geometry.
Optionalcenter?: Vec3A 3D point (array of 3 numbers) indicating the center position of the sphere. Defaults to [0, 0, 0].
OptionalheightSegments?: numberThe number of latitudinal segments (bands from top to bottom). Default is 24.
Optionalradius?: numberThe radius of the sphere. Default is 1.
OptionalwidthSegments?: numberThe number of longitudinal segments (bands around the sphere). Default is 18.
Returns a SceneGeometry object containing the sphere geometry with the necessary positions, normals, UV coordinates, and indices for rendering.
const sphereGeometryResult = buildSphereGeometry({
radius: 2,
heightSegments: 24,
widthSegments: 18,
center: [0, 0, 0]
});
if (sphereGeometryResult.ok) {
const sphereGeometry = sphereGeometryResult.value;
// Use sphereGeometry here
} else {
console.error("Error creating sphere geometry:", sphereGeometryResult.error);
}
@returns {SDKResult
Creates a sphere-shaped geometry.
This function generates a sphere geometry by calculating the positions of vertices based on the specified parameters. The sphere is defined by its radius and the number of latitudinal and longitudinal segments. The resulting geometry includes the positions, normals, UVs, and indices necessary to render the sphere.
Usage
To create a sphere geometry, call the function with the desired configuration. For example:
This creates a sphere with a radius of 2 units, 24 latitudinal segments, 18 longitudinal segments, centered at
[0, 0, 0].Parameters: