Configuration object for generating the torus geometry.
Optionalarc?: numberThe length of the arc in radians, where Math.PI*2 represents a full circle. Default is a full circle.
Returns a SceneGeometry object containing the torus geometry with the necessary positions, indices, and optional normals and UV coordinates for rendering.
const torusGeometry = buildTorusGeometry({
    radius: 1.5,
    tube: 0.4,
    radialSegments: 24,
    tubeSegments: 16,
    arc: Math.PI * 2,
    center: [0, 0, 0]
});
Math.PI * 2, and any smaller value creates a partial torus.Optionalcenter?: number[]A 3D point (array of 3 numbers) indicating the center position of the torus. Defaults to [0, 0, 0].
OptionalradialSegments?: numberThe number of radial segments (segments along the circular cross-section). Default is 32.
Optionalradius?: numberThe overall radius of the torus. This controls the distance from the center to the tube's center. Default is 1.
Optionaltube?: numberThe radius of the tube that makes up the torus. Default is 0.3.
OptionaltubeSegments?: numberThe number of tubular segments (segments around the tube). Default is 24.
The geometry data for the torus, including positions, normals, and indices for rendering.
Creates a torus-shaped SceneGeometry.
This function generates a torus (doughnut shape) geometry by calculating the positions of vertices based on the specified parameters. It also calculates the normals and UV coordinates for each vertex. The resulting geometry can be used to render a torus mesh in 3D environments.
Usage
To create a torus geometry, call the function with the desired configuration. For example:
This creates a torus with a radius of 2 units, a tube radius of 0.5 units, 36 radial segments, and 24 tubular segments, with a full circle arc.
Parameters: