Class: SurfaceBuilder

SurfaceBuilder is a factory class that provides static methods for constructing surfaces from curves, points, and other geometric inputs. Like CurveBuilder, you never instantiate it -- just call its static methods directly (e.g., SurfaceBuilder.loft(...), SurfaceBuilder.revolve(...)).

When to use SurfaceBuilder

Use SurfaceBuilder when you need to create a surface from scratch:

  • Extruding a curve in a direction to form a flat or ruled surface
  • Revolving a profile curve around an axis to create surfaces of revolution
  • Lofting between multiple cross-section curves for smooth transitions
  • Sweeping profiles along a spine curve (single rail or two rails)
  • Building surfaces from points, edges, or curve networks
  • Creating primitives like rectangular or circular planar surfaces
  • Piping a curve with a constant or variable radius

Once created, the resulting Surface objects can be further manipulated using the methods on the Surface class (fillet, offset, boolean operations, paneling, etc.).

Ask AI about this page
ChatGPT

Quick start

// Extrude a line into a flat surface
const line = CurveBuilder.line(new Vector(0, 0, 0), new Vector(10, 0, 0));
const extruded = SurfaceBuilder.extrudePoint(line, new Vector(0, 5, 0));

// Revolve a profile curve around the Y axis
const profile = CurveBuilder.arc(new Vector(5, 0, 0), 2, 0, Math.PI);
const revolved = SurfaceBuilder.revolve(
  profile,
  new Vector(0, 0, 0),    // axis origin
  new Vector(0, 1, 0),    // axis direction
  Math.PI * 2             // full revolution
);

// Loft between two circles at different heights
const bottom = CurveBuilder.circle(new Vector(0, 0, 0), 5);
const top = CurveBuilder.circle(new Vector(0, 0, 10), 3);
const lofted = SurfaceBuilder.loft([bottom, top], 3);

// Pipe a curve with a given radius
const spine = CurveBuilder.bSplineCurve(
  [new Vector(0, 0, 0), new Vector(5, 5, 0), new Vector(10, 0, 0)], 3, false
);
const piped = SurfaceBuilder.pipe(spine, 1);

Key methods

MethodDescription
extrudePoint(curve, direction)Extrude a curve in a direction
extrudeAlong(base, profile)Extrude a base curve along a profile curve
revolve(curve, origin, dir, angle)Revolve a curve around an axis
loft(curves, degree)Loft a smooth surface through cross-section curves
sweep(profiles, spine)Sweep profiles along a single spine curve
sweep2(profiles, rail1, rail2)Sweep profiles along two rail curves
pipe(curve, radius)Create a pipe surface around a curve
pipeVariable(curve, radii, params)Pipe with variable radius along the curve
surface4Pnt(p1, p2, p3, p4)Surface defined by four corner points
circleSurface(origin, radius)Planar circular surface
rectangularSurface(origin, w, l)Planar rectangular surface
surfaceFromCurves(curveList)Surface from a network of curves
surfaceFromPoints(pointList)Surface interpolating through points
surfaceByEdges(curveList)Surface by lofting between edge curves
mesh(pA, pB, pC)Triangular mesh face from three points
delaunayMesh(points)Delaunay triangulation mesh from points
sumSrf(crv1, crv2)Sum surface of two curves

Static Method: surface4Pnt

Creates a surface based on four given points.

Parameters

  • point1 (IVector): The first point.
  • point2 (IVector): The second point.
  • point3 (IVector): The third point.
  • point4 (IVector): The fourth point.

Returns

A new Surface object representing the created surface.

Example

const point1 = new Vector(1, 1, 1);
const point2 = new Vector(1, 1, 1);
const point3 = new Vector(1, 1, 1);
const point4 = new Vector(1, 1, 1);
SurfaceBuilder.surface4Pnt(point1, point2, point3, point4);

Static Method: loft

Creates a lofted surface from the given curves.

Parameters

  • curves (ICurve[]): The curves to loft.
  • degree (number): The degree of the lofted surface.

Returns

A new Surface object representing the lofted surface.

Example

const curves = /* specify a curves */;
const degree = 0.5;
SurfaceBuilder.loft(curves, degree);

Static Method: extrudePoint

Extrudes a curve in a specified direction.

Parameters

  • curve (ICurve): The curve to extrude the point along.
  • direction (IVector): The direction in which to extrude the point.

Returns

A new Surface object representing the extruded surface.

Example

const curve = CurveBuilder.line(new Vector(0, 0, 0), new Vector(1, 1, 1));
const direction = new Vector(1, 1, 1);
SurfaceBuilder.extrudePoint(curve, direction);

Static Method: extrudeAlong

Extrudes a base curve along a profile curve to create a surface.

Parameters

  • base (ICurve): No description
  • profileCurve (ICurve): No description

Returns

The resulting surface.

Example

const base = CurveBuilder.line(new Vector(0, 0, 0), new Vector(1, 1, 1));
const profileCurve = CurveBuilder.line(new Vector(0, 0, 0), new Vector(1, 1, 1));
SurfaceBuilder.extrudeAlong(base, profileCurve);

Static Method: sweep

Creates a swept surface by sweeping a set of profiles along a spine curve.

Parameters

  • profiles (ICurve[]): An array of curves representing the profiles to be swept.
  • spine (ICurve): The spine curve along which the profiles will be swept.

Returns

A new Surface object representing the swept surface.

Example

const profiles = /* specify a profiles */;
const spine = CurveBuilder.line(new Vector(0, 0, 0), new Vector(1, 1, 1));
SurfaceBuilder.sweep(profiles, spine);

Static Method: sweep2

Creates a swept surface by sweeping profiles along two rails.

Parameters

  • profiles (ICurve[]): An array of curves representing the profiles to be swept.
  • rail1 (ICurve): The first rail curve.
  • rail2 (ICurve): The second rail curve.

Returns

A Surface object representing the swept surface.

Example

const profiles = /* specify a profiles */;
const rail1 = CurveBuilder.line(new Vector(0, 0, 0), new Vector(1, 1, 1));
const rail2 = CurveBuilder.line(new Vector(0, 0, 0), new Vector(1, 1, 1));
SurfaceBuilder.sweep2(profiles, rail1, rail2);

Static Method: sumSrf

Calculates the sum surface of two curves.

Parameters

  • crv1 (ICurve): The first curve.
  • crv2 (ICurve): The second curve.

Returns

A new Surface object representing the sum surface of the two curves.

Example

const crv1 = CurveBuilder.line(new Vector(0, 0, 0), new Vector(1, 1, 1));
const crv2 = CurveBuilder.line(new Vector(0, 0, 0), new Vector(1, 1, 1));
SurfaceBuilder.sumSrf(crv1, crv2);

Static Method: revolve

Revolves a curve around an axis to create a surface.

Parameters

  • curve (ICurve): The curve to revolve.
  • origin (IVector): The origin point of the axis.
  • direction (IVector): The direction vector of the axis.
  • angle (number): The angle of revolution in radians.

Returns

A new Surface object representing the revolved surface.

Example

const curve = CurveBuilder.line(new Vector(0, 0, 0), new Vector(1, 1, 1));
const origin = new Vector(1, 1, 1);
const direction = new Vector(1, 1, 1);
const angle = 0.5;
SurfaceBuilder.revolve(curve, origin, direction, angle);

Static Method: pipe

Creates a pipe surface based on the given curve and radius.

Parameters

  • curve (ICurve): The curve to create the pipe from.
  • radius (number): The radius of the pipe.

Returns

A new Surface object representing the pipe surface.

Example

const curve = CurveBuilder.line(new Vector(0, 0, 0), new Vector(1, 1, 1));
const radius = 10;
SurfaceBuilder.pipe(curve, radius);

Static Method: pipeVariable

Builds a pipe surface by extruding a curve along a set of radii and parameters.

Parameters

  • curve (ICurve): The curve to be extruded.
  • radii (number[]): An array of radii corresponding to each parameter.
  • parameters (number[]): An array of parameters specifying the position along the curve for each radius.

Returns

A new Surface object representing the resulting pipe surface.

Example

const curve = CurveBuilder.line(new Vector(0, 0, 0), new Vector(1, 1, 1));
const radii = /* specify a radii */;
const parameters = /* specify a parameters */;
SurfaceBuilder.pipeVariable(curve, radii, parameters);

Static Method: circleSurface

Creates a circular surface with the given origin and radius.

Parameters

  • origin (IVector): The origin point of the circle.
  • radius (number): The radius of the circle.

Returns

A Surface object representing the circular surface.

Example

const origin = new Vector(1, 1, 1);
const radius = 10;
SurfaceBuilder.circleSurface(origin, radius);

Static Method: rectangularSurface

Creates a rectangular surface with the specified origin, width, and length.

Parameters

  • origin (IVector): The origin point of the surface.
  • width (number): The width of the surface.
  • length (number): The length of the surface.

Returns

A Surface object representing the rectangular surface.

Example

const origin = new Vector(1, 1, 1);
const width = 0.5;
const length = 10;
SurfaceBuilder.rectangularSurface(origin, width, length);

Static Method: surfaceByEdges

Builds a surface by creating a loft between the given curves.

Parameters

  • curveList (ICurve[]): The list of curves to create the surface from.

Returns

A Surface object representing the constructed surface.

Example

const curveList = /* specify a curveList */;
SurfaceBuilder.surfaceByEdges(curveList);

Static Method: surfaceFromCurves

Creates a surface from a list of curves.

Parameters

  • curveList (ICurve[]): The list of curves to create the surface from.

Returns

A Surface object representing the created surface.

Example

const curveList = /* specify a curveList */;
SurfaceBuilder.surfaceFromCurves(curveList);

Static Method: surfaceFromPoints

Creates a surface from a list of points.

Parameters

  • pointList (IVector[]): The list of points to create the surface from.

Returns

A Surface object representing the created surface.

Example

const pointList = /* specify a pointList */;
SurfaceBuilder.surfaceFromPoints(pointList);

Static Method: mesh

Creates a mesh surface from three given points.

Parameters

  • pointA (IVector): The first point of the mesh.
  • pointB (IVector): The second point of the mesh.
  • pointC (IVector): The third point of the mesh.

Returns

A Surface object representing the mesh surface.

Example

const pointA = new Vector(0, 0, 0);
const pointB = new Vector(1, 1, 1);
const pointC = new Vector(1, 1, 1);
SurfaceBuilder.mesh(pointA, pointB, pointC);

Static Method: delaunayMesh

Generates a Delaunay mesh from the given points.

Parameters

  • points (IVector[]): An array of Vector points.

Returns

An array of Surface objects representing the Delaunay mesh.

Example

const points = /* specify a points */;
SurfaceBuilder.delaunayMesh(points);