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.
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
let half_height = self.height / 2.0;let mut start_angle: f64 = 0.0;let angle_step = self.angle / self.segments as f64;for _ in 0..segment_count { let x = self.center.x + self.radius * start_angle.cos(); let y = self.center.y - half_height; let z = self.center.z + self.radius * start_angle.sin(); // ...}
Cylinders use MeshStandardMaterial with transparency for better visual integration:Source:/workspace/source/main/opengeometry/src/shapes/cylinder.ts:98-102
const material = new THREE.MeshStandardMaterial({ color: this.options.color, transparent: true, opacity: 0.6,});
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
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.