Skip to main content

Overview

The Cylinder class creates 3D cylindrical shapes. Cylinders are created on the XZ plane and extruded along the Y-axis. They support partial angles for creating cylindrical sections and customizable segment counts for geometry resolution.

Constructor

ICylinderOptions

string
Unique identifier for the cylinder. Auto-generated if not provided.
Vector3
required
Center point of the cylinder in 3D space.
number
required
Radius of the cylinder base.
number
required
Height of the cylinder along the Y-axis.
number
required
Number of segments around the cylinder circumference. Higher values create smoother cylinders.
number
required
Sweep angle in radians. Use 2 * Math.PI for a complete cylinder.
number
required
Hexadecimal color value for the cylinder.

Methods

setConfig()

Updates the cylinder configuration and regenerates geometry.
Example:

getBrep()

Returns the B-Rep (Boundary Representation) data as a parsed JSON object.
Example:

generateGeometry()

Regenerates the THREE.js geometry from the current configuration. Called automatically after setConfig().

discardGeometry()

Disposes of the current geometry to free memory.

Properties

string
Unique identifier for the cylinder instance.
ICylinderOptions
Current cylinder configuration.
number
Get or set the cylinder radius. Setting triggers geometry regeneration.
number
Get or set the cylinder color.
boolean
Enable or disable outline rendering.

Usage Examples

Basic Cylinder

Half Cylinder (Partial Angle)

High-Resolution Cylinder

Updating Cylinder Dynamically

Implementation Details

Geometry Generation

Cylinders are generated by creating a circular base on the XZ plane and extruding it along the Y-axis. The base circle is centered at center.y - height/2, and the top is at center.y + height/2. Rust Implementation: /workspace/source/main/opengeometry/src/primitives/cylinder.rs:90-134

Material Configuration

Cylinders use MeshStandardMaterial with transparency for better visual integration: Source: /workspace/source/main/opengeometry/src/shapes/cylinder.ts:98-102

Partial Cylinders

When angle < 2π, an additional center vertex is added to the base circle to properly close the cylindrical section. Source: /workspace/source/main/opengeometry/src/primitives/cylinder.rs:108-115

Best Practices

Segment Count: Use 32 segments for general purposes. Increase to 64+ for close-up views or precision modeling. Reduce to 16-24 for distant objects to improve performance.
Angle Range: The angle parameter should be between 0 and 2 * Math.PI. Values outside this range may produce unexpected results.
Outline Performance: Enabling outlines adds line geometry. For scenes with many cylinders, consider toggling outlines based on selection or zoom level.

Live Demo

Cylinder Demo

Try the Cylinder shape in the browser

See Also

Sweep

Custom profile extrusions

Sphere

Spherical shapes

Cuboid

Rectangular boxes
Last modified on March 14, 2026