UNPKG

@bitbybit-dev/manifold-worker

Version:

Bit By Bit Developers Manifold Based CAD Library to Program Geometry Via WebWorker

74 lines (73 loc) 2.9 kB
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; /** * Contains various functions for making shapes Manifold library https://github.com/elalish/manifold * Thanks Manifold community for developing this kernel */ export class CrossSectionShapes { constructor(manifoldWorkerManager) { this.manifoldWorkerManager = manifoldWorkerManager; } /** * Create a 2d cross-section from a set of contours (complex polygons). A * boolean union operation (with Positive filling rule by default) is * performed to combine overlapping polygons and ensure the resulting * CrossSection is free of intersections. * @param inputs polygons and fill rule * @returns cross section * @group base * @shortname create * @drawable true */ create(inputs) { return __awaiter(this, void 0, void 0, function* () { return this.manifoldWorkerManager.genericCallToWorkerPromise("crossSection.shapes.create", inputs); }); } /** * Create a 2D square cross section * @param inputs Square parameters * @returns square cross section * @group primitives * @shortname square * @drawable true */ square(inputs) { return __awaiter(this, void 0, void 0, function* () { return this.manifoldWorkerManager.genericCallToWorkerPromise("crossSection.shapes.square", inputs); }); } /** * Create a 2D circle cross section * @param inputs Circle parameters * @returns circle cross section * @group primitives * @shortname circle * @drawable true */ circle(inputs) { return __awaiter(this, void 0, void 0, function* () { return this.manifoldWorkerManager.genericCallToWorkerPromise("crossSection.shapes.circle", inputs); }); } /** * Create a 2D rectangle cross section * @param inputs Rectangle parameters * @returns rectangle cross section * @group primitives * @shortname rectangle * @drawable true */ rectangle(inputs) { return __awaiter(this, void 0, void 0, function* () { return this.manifoldWorkerManager.genericCallToWorkerPromise("crossSection.shapes.rectangle", inputs); }); } }