UNPKG

@achirita/blox

Version:

A CAD library for building 3D models in the browser.

95 lines (94 loc) 3.23 kB
import { Vector, Plane } from '../math'; import { Face, Wire } from '../modeling'; export class Sketch { /** * Creates a new Sketch on the given plane. * @param {Plane} [plane=Plane.XY] - The sketch plane. */ constructor(plane?: Plane); /** * Returns the array of edges in the sketch. * @returns {Array} The sketch edges. */ get edges(): any[]; /** * Returns the current pointer position. * @returns {Vector} The pointer position. */ get pointer(): Vector; /** * Moves the pointer to a given point (only if no edges exist). * @param {Vector} point - The new pointer position. * @returns {Sketch} The current `Sketch` instance. */ movePointerTo(point: Vector): Sketch; /** * Adds a line from the current pointer to the given point. * @param {Vector} point - The end point of the line. * @returns {Sketch} The current `Sketch` instance. */ lineTo(point: Vector): Sketch; /** * Adds a line from the pointer by the given offset. * @param {Vector} offset - The offset vector. * @returns {Sketch} The current `Sketch` instance. */ line(offset: Vector): Sketch; /** * Adds a line at a given angle and length from the pointer. * @param {Object} params - Parameters. * @param {number} params.length - The line length. * @param {number} params.angle - The angle in radians. * @returns {Sketch} The current `Sketch` instance. */ lineAtAngle({ length, angle }: { length: number; angle: number; }): Sketch; /** * Adds a line tangent to the last edge, with the given length. * @param {number} length - The tangent line length. * @returns {Sketch} The current `Sketch` instance. */ tangentLine(length: number): Sketch; /** * Adds a tangent arc from the last edge to the given point. * @param {Vector} point - The arc end point. * @returns {Sketch} The current `Sketch` instance. */ tangentArcTo(point: Vector): Sketch; /** * Adds a tangent arc from the pointer by the given offset. * @param {Vector} offset - The offset vector. * @returns {Sketch} The current `Sketch` instance. */ tangentArc(offset: Vector): Sketch; /** * Adds a three-point arc from the pointer, through a point, to an end point. * @param {Object} params - Parameters. * @param {Vector} params.through - The through point. * @param {Vector} params.end - The arc end point. * @returns {Sketch} The current `Sketch` instance. */ threePointsArcTo({ through, end }: { through: Vector; end: Vector; }): Sketch; /** * Adds a Bezier curve from the pointer through the given points. * @param {Vector[]} points - Control points (excluding start). * @returns {Sketch} The current `Sketch` instance. */ bezierCurveTo(points: Vector[]): Sketch; /** * Converts the sketch to a planar face. * @returns {Face} The resulting `Face`. */ toFace(): Face; /** * Converts the sketch to a Wire. * @returns {Wire} The resulting `Wire`. */ toWire(): Wire; #private; }