Overview
TheSweep class creates 3D shapes by sweeping a 2D profile along a 3D path. This powerful technique enables creation of pipes, tubes, rails, and complex extruded forms that follow custom trajectories.
Constructor
ISweepOptions
Unique identifier for the sweep. Auto-generated if not provided.
Array of points defining the 3D path along which the profile is swept. Minimum 2 points required.
Array of points defining the 2D profile to be swept. Minimum 3 points required. Profile should be defined on a plane perpendicular to the initial path direction.
Hexadecimal color value for the swept shape.
Whether to add a cap (face) at the start of the sweep.
Whether to add a cap (face) at the end of the sweep.
Methods
setConfig()
Updates the sweep configuration with path and profile, using default caps (both true).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
Unique identifier for the sweep instance.
Current sweep configuration including path, profile, color, and cap settings.
Get or set the sweep color.
Enable or disable outline rendering for the sweep edges.
Usage Examples
Simple Pipe
Curved Tube
Handrail
Open-Ended Sweep
Architectural Molding
Implementation Details
Sweep Algorithm
The sweep operation positions the profile at each path point and connects adjacent profiles: Rust Implementation:/workspace/source/main/opengeometry/src/primitives/sweep.rs:92-99
Material Configuration
Sweeps use MeshStandardMaterial with transparency: Source:/workspace/source/main/opengeometry/src/shapes/sweep.ts:123-127
Validation
The sweep validates path and profile requirements: Source:/workspace/source/main/opengeometry/src/shapes/sweep.ts:75-87
Cap Generation
WhencapStart or capEnd is true, the sweep operation adds triangulated faces at the ends:
Source: /workspace/source/main/opengeometry/src/shapes/sweep.ts:95-96
Best Practices
Profile Complexity: Complex profiles with many points will generate more geometry. Balance profile detail with performance requirements.
Performance Considerations
Vertex Count
Total vertices ≈path_points × profile_points
Face Count
Total faces ≈(path_points - 1) × profile_points × 2 + cap_faces
Optimization Tips
- Reduce Path Points: Use fewer points for distant or less important sweeps
- Simplify Profiles: Use simpler profiles (fewer vertices) when high detail isn’t needed
- Disable Caps: Set
capStartandcapEndtofalsefor open-ended shapes - Outline Toggle: Only enable outlines when needed for debugging or emphasis
Live Demo
Sweep Demo
Try the Sweep shape in the browser
See Also
Cylinder
Simple straight extrusions
Polygon
Custom 2D profiles
Cuboid
Rectangular extrusions

