UNPKG

1.94 kBTypeScriptView Raw
1import { BufferGeometry } from "../core/BufferGeometry.js";
2
3/**
4 * {@link CapsuleGeometry} is a geometry class for a capsule with given radii and height
5 * @remarks It is constructed using a lathe.
6 * @example
7 * ```typescript
8 * const geometry = new THREE.CapsuleGeometry(1, 1, 4, 8);
9 * const material = new THREE.MeshBasicMaterial({
10 * color: 0x00ff00
11 * });
12 * const capsule = new THREE.Mesh(geometry, material);
13 * scene.add(capsule);
14 * ```
15 * @see {@link https://threejs.org/docs/index.html#api/en/geometries/CapsuleGeometry | Official Documentation}
16 * @see {@link https://github.com/mrdoob/three.js/blob/master/src/geometries/CapsuleGeometry.js | Source}
17 */
18export class CapsuleGeometry extends BufferGeometry {
19 /**
20 * Create a new instance of {@link CapsuleGeometry}
21 * @param radius Radius of the capsule. Expects a `Float`. Default `1`
22 * @param length Length of the middle section. Expects a `Float`. Default `1`
23 * @param capSegments Number of curve segments used to build the caps. Expects a `Integer`. Default `4`
24 * @param radialSegments Number of segmented faces around the circumference of the capsule. Expects a `Integer`. Default `8`
25 */
26 constructor(radius?: number, length?: number, capSegments?: number, radialSegments?: number);
27
28 /**
29 * A Read-only _string_ to check if `this` object type.
30 * @remarks Sub-classes will update this value.
31 * @defaultValue `CapsuleGeometry`
32 */
33 override readonly type: string | "CapsuleGeometry";
34
35 /**
36 * An object with a property for each of the constructor parameters.
37 * @remarks Any modification after instantiation does not change the geometry.
38 */
39 readonly parameters: {
40 readonly radius: number;
41 readonly length: number;
42 readonly capSegments: number;
43 readonly radialSegments: number;
44 };
45
46 /** @internal */
47 static fromJSON(data: {}): CapsuleGeometry;
48}