@bitbybit-dev/manifold-worker
Version:
Bit By Bit Developers Manifold Based CAD Library to Program Geometry Via WebWorker
110 lines (109 loc) • 4.33 kB
JavaScript
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 transforming cross section from Manifold library https://github.com/elalish/manifold
* Thanks Manifold community for developing this kernel
*/
export class CrossSectionTransforms {
constructor(manifoldWorkerManager) {
this.manifoldWorkerManager = manifoldWorkerManager;
}
/**
* Scales a cross section shape with 2D vector
* @param inputs cross section and scale vector
* @returns Scaled cross section shape
* @group transforms
* @shortname scale 2d
* @drawable true
*/
scale2D(inputs) {
return __awaiter(this, void 0, void 0, function* () {
return this.manifoldWorkerManager.genericCallToWorkerPromise("crossSection.transforms.scale2D", inputs);
});
}
/**
* Scales a cross section shape with single factor
* @param inputs cross section and scale factor
* @returns Scaled cross section shape
* @group transforms
* @shortname scale uniform
* @drawable true
*/
scale(inputs) {
return __awaiter(this, void 0, void 0, function* () {
return this.manifoldWorkerManager.genericCallToWorkerPromise("crossSection.transforms.scale", inputs);
});
}
/**
* Mirrors a cross section shape over a plane defined by a normal vector
* @param inputs cross section and normal vector
* @returns Mirrored cross section shape
* @group transforms
* @shortname mirror
* @drawable true
*/
mirror(inputs) {
return __awaiter(this, void 0, void 0, function* () {
return this.manifoldWorkerManager.genericCallToWorkerPromise("crossSection.transforms.mirror", inputs);
});
}
/**
* Translates a cross section shape along the vector
* @param inputs cross section and trnaslation vector
* @returns Translated cross section shape
* @group transforms
* @shortname translate
* @drawable true
*/
translate(inputs) {
return __awaiter(this, void 0, void 0, function* () {
return this.manifoldWorkerManager.genericCallToWorkerPromise("crossSection.transforms.translate", inputs);
});
}
/**
* Translates a cross section shape along x, y
* @param inputs cross section and trnaslation coordinates
* @returns Translated cross section shape
* @group transforms
* @shortname translate xy
* @drawable true
*/
translateXY(inputs) {
return __awaiter(this, void 0, void 0, function* () {
return this.manifoldWorkerManager.genericCallToWorkerPromise("crossSection.transforms.translateXY", inputs);
});
}
/**
* Rotates a cross section shape along the containing degrees
* @param inputs cross section and rotation degrees
* @returns Rotated cross section shape
* @group transforms
* @shortname rotate
* @drawable true
*/
rotate(inputs) {
return __awaiter(this, void 0, void 0, function* () {
return this.manifoldWorkerManager.genericCallToWorkerPromise("crossSection.transforms.rotate", inputs);
});
}
/**
* Transforms a cross section shape by using the 3x3 transformation matrix
* @param inputs cross section and transformation matrix
* @returns Transformed cross section shape
* @group matrix
* @shortname transform
* @drawable true
*/
transform(inputs) {
return __awaiter(this, void 0, void 0, function* () {
return this.manifoldWorkerManager.genericCallToWorkerPromise("crossSection.transforms.transform", inputs);
});
}
}