UNPKG

@bitbybit-dev/manifold

Version:

Bit By Bit Developers Manifold based CAD Library to Program Geometry

29 lines (28 loc) 1.07 kB
import { Manifold } from "./services/manifold/manifold"; import { CrossSection } from "./services/cross-section/cross-section"; import { Mesh } from "./services/mesh/mesh"; // Worker make an instance of this class itself export class ManifoldService { constructor(wasm) { this.crossSection = new CrossSection(wasm); this.manifold = new Manifold(wasm); this.mesh = new Mesh(wasm); } decomposeManifoldOrCrossSection(inputs) { if (inputs.manifoldOrCrossSection.getMesh) { return inputs.manifoldOrCrossSection.getMesh(inputs.normalIdx); } else { return inputs.manifoldOrCrossSection.toPolygons(); } } decomposeManifoldsOrCrossSections(inputs) { return inputs.manifoldsOrCrossSections.map((manifoldOrCrossSection, index) => { const normalIdx = inputs.normalIdx ? inputs.normalIdx[index] : undefined; return this.decomposeManifoldOrCrossSection({ manifoldOrCrossSection, normalIdx }); }); } }