Skip to main content

Overview

The Sweep 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

ogid
string
Unique identifier for the sweep. Auto-generated if not provided.
path
Vector3[]
required
Array of points defining the 3D path along which the profile is swept. Minimum 2 points required.
profile
Vector3[]
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.
color
number
required
Hexadecimal color value for the swept shape.
capStart
boolean
default:"true"
Whether to add a cap (face) at the start of the sweep.
capEnd
boolean
default:"true"
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).
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

ogid
string
Unique identifier for the sweep instance.
options
ISweepOptions
Current sweep configuration including path, profile, color, and cap settings.
color
number
Get or set the sweep color.
outline
boolean
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

When capStart 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 Orientation: Define the profile on a plane perpendicular to the initial path direction. For paths starting along the Y-axis, define profiles on the XZ plane.
Path Smoothness: Sharp angles in the path may cause geometry artifacts. For smoother results, use more path points with gradual direction changes.
Profile Complexity: Complex profiles with many points will generate more geometry. Balance profile detail with performance requirements.
Closed Profiles: For hollow tubes, ensure the profile forms a closed loop by making the first and last points identical.

Performance Considerations

Vertex Count

Total vertices ≈ path_points × profile_points

Face Count

Total faces ≈ (path_points - 1) × profile_points × 2 + cap_faces

Optimization Tips

  1. Reduce Path Points: Use fewer points for distant or less important sweeps
  2. Simplify Profiles: Use simpler profiles (fewer vertices) when high detail isn’t needed
  3. Disable Caps: Set capStart and capEnd to false for open-ended shapes
  4. 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
Last modified on March 14, 2026