Overview
TheCylinder 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.getBrep()
Returns the B-Rep (Boundary Representation) data as a parsed JSON object.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 atcenter.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
Whenangle < 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
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

