1 | import { BufferGeometry } from "../core/BufferGeometry.js";
|
2 |
|
3 | /**
|
4 | * A class for generating sphere geometries.
|
5 | * @example
|
6 | * ```typescript
|
7 | * const geometry = new THREE.SphereGeometry(15, 32, 16);
|
8 | * const material = new THREE.MeshBasicMaterial({
|
9 | * color: 0xffff00
|
10 | * });
|
11 | * const sphere = new THREE.Mesh(geometry, material);
|
12 | * scene.add(sphere);
|
13 | * ```
|
14 | * @see {@link https://threejs.org/docs/index.html#api/en/geometries/SphereGeometry | Official Documentation}
|
15 | * @see {@link https://github.com/mrdoob/three.js/blob/master/src/geometries/SphereGeometry.js | Source}
|
16 | */
|
17 | export class SphereGeometry extends BufferGeometry {
|
18 | /**
|
19 | * Create a new instance of {@link SphereGeometry}
|
20 | * @remarks
|
21 | * The geometry is created by sweeping and calculating vertexes
|
22 | * around the **Y** axis (horizontal sweep) and the **Z** axis (vertical sweep)
|
23 | * Thus, incomplete spheres (akin to `'sphere slices'`) can be created
|
24 | * through the use of different values of {@link phiStart}, {@link phiLength}, {@link thetaStart} and {@link thetaLength},
|
25 | * in order to define the points in which we start (or end) calculating those vertices.
|
26 | * @param radius Sphere radius. Expects a `Float`. Default `1`
|
27 | * @param widthSegments Number of horizontal segments. Minimum value is 3, and the Expects a `Integer`. Default `32`
|
28 | * @param heightSegments Number of vertical segments. Minimum value is 2, and the Expects a `Integer`. Default `16`
|
29 | * @param phiStart Specify horizontal starting angle. Expects a `Float`. Default `0`
|
30 | * @param phiLength Specify horizontal sweep angle size. Expects a `Float`. Default `Math.PI * 2`
|
31 | * @param thetaStart Specify vertical starting angle. Expects a `Float`. Default `0`
|
32 | * @param thetaLength Specify vertical sweep angle size. Expects a `Float`. Default `Math.PI`
|
33 | */
|
34 | constructor(
|
35 | radius?: number,
|
36 | widthSegments?: number,
|
37 | heightSegments?: number,
|
38 | phiStart?: number,
|
39 | phiLength?: number,
|
40 | thetaStart?: number,
|
41 | thetaLength?: number,
|
42 | );
|
43 |
|
44 | /**
|
45 | * A Read-only _string_ to check if `this` object type.
|
46 | * @remarks Sub-classes will update this value.
|
47 | * @defaultValue `SphereGeometry`
|
48 | */
|
49 | override readonly type: string | "SphereGeometry";
|
50 |
|
51 | /**
|
52 | * An object with a property for each of the constructor parameters.
|
53 | * @remarks Any modification after instantiation does not change the geometry.
|
54 | */
|
55 | readonly parameters: {
|
56 | readonly radius: number;
|
57 | readonly widthSegments: number;
|
58 | readonly heightSegments: number;
|
59 | readonly phiStart: number;
|
60 | readonly phiLength: number;
|
61 | readonly thetaStart: number;
|
62 | readonly thetaLength: number;
|
63 | };
|
64 |
|
65 | /** @internal */
|
66 | static fromJSON(data: {}): SphereGeometry;
|
67 | }
|