CapsuleGeometry - Verge3D 用户手册 - Soft8Soft
Description: 了解如何在使用 Verge3D 制作的交互式 3D 应用程序中使用 CapsuleGeometry

BufferGeometry → LatheGeometry →

# CapsuleGeometry

CapsuleGeometry is a geometry class for a capsule with given radii and height. It is constructed using a lathe.

## Code Example

`const geometry = new v3d.CapsuleGeometry(1, 1, 4, 8); const material = new v3d.MeshBasicMaterial({color: 0x00ff00}); const capsule = new v3d.Mesh(geometry, material); app.scene.add(capsule);`

## Constructor

### CapsuleGeometry(radius : Float, length : Float, capSubdivisions : Integer, radialSegments : Integer)

- radius — radius of the capsule. Optional; defaults to `1`.
- length — length of the middle section. Optional; defaults to `1`.
- capSegments — number of curve segments used to build the caps. Optional; defaults to `4`.
- radialSegments — number of segmented faces around the circumference of the capsule. Optional; defaults to `8`.

Procedural geometry is fun. However, in real life applications this feature is rarely needed. It would be more efficient do design capsules in the preferred modelling suite and export/load to Verge3D via glTF.

## Properties

See the base BufferGeometry class for common properties.

### # .parameters : Object

An object with a property for each of the constructor parameters. Any modification after instantiation does not change the geometry.

## Methods

See the base BufferGeometry class for common methods.

## Puzzles

The create object puzzle can be used to create capsules in a code-less manner.

## 源代码

关于如何获取此模块的源代码，请查看 本页。