@bitbybit-dev/manifold-worker
Version:
Bit By Bit Developers Manifold Based CAD Library to Program Geometry Via WebWorker
139 lines (138 loc) • 4.87 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 Solid meshes from Manifold library https://github.com/elalish/manifold
* Thanks Manifold community for developing this kernel
*/
export class MeshEvaluate {
constructor(manifoldWorkerManager) {
this.manifoldWorkerManager = manifoldWorkerManager;
}
/**
* Get position on mesh vertex index
* @param inputs mesh
* @returns point
* @group basic
* @shortname position
* @drawable true
*/
position(inputs) {
return __awaiter(this, void 0, void 0, function* () {
return this.manifoldWorkerManager.genericCallToWorkerPromise("mesh.evaluate.position", inputs);
});
}
/**
* Gets the three vertex indices of this triangle in CCW order.
* @param inputs mesh
* @returns verts
* @group basic
* @shortname verts
* @drawable false
*/
verts(inputs) {
return __awaiter(this, void 0, void 0, function* () {
return this.manifoldWorkerManager.genericCallToWorkerPromise("mesh.evaluate.verts", inputs);
});
}
/**
* Gets the tangent vector starting at verts(tri)[j] pointing to the next
* Bezier point along the CCW edge. The fourth value is its weight.
* @param inputs mesh
* @returns tangent
* @group basic
* @shortname tangent
* @drawable true
*/
tangent(inputs) {
return __awaiter(this, void 0, void 0, function* () {
return this.manifoldWorkerManager.genericCallToWorkerPromise("mesh.evaluate.tangent", inputs);
});
}
/**
* Gets any other properties associated with this vertex.
* @param inputs mesh
* @returns extras
* @group basic
* @shortname extras
* @drawable false
*/
extras(inputs) {
return __awaiter(this, void 0, void 0, function* () {
return this.manifoldWorkerManager.genericCallToWorkerPromise("mesh.evaluate.extras", inputs);
});
}
/**
* Gets the column-major 4x4 matrix transform from the original mesh to these
* related triangles.
* @param inputs mesh
* @returns transform matrix
* @group basic
* @shortname transform 4x4 matrix
* @drawable false
*/
transform(inputs) {
return __awaiter(this, void 0, void 0, function* () {
return this.manifoldWorkerManager.genericCallToWorkerPromise("mesh.evaluate.transform", inputs);
});
}
/**
* Number of properties per vertex, always >= 3.
* @param inputs mesh
* @returns number of properties
* @group basic
* @shortname number props
* @drawable false
*/
numProp(inputs) {
return __awaiter(this, void 0, void 0, function* () {
return this.manifoldWorkerManager.genericCallToWorkerPromise("mesh.evaluate.numProp", inputs);
});
}
/**
* Number of property vertices
* @param inputs mesh
* @returns number of vertices
* @group basic
* @shortname number vertices
* @drawable false
*/
numVert(inputs) {
return __awaiter(this, void 0, void 0, function* () {
return this.manifoldWorkerManager.genericCallToWorkerPromise("mesh.evaluate.numVert", inputs);
});
}
/**
* Get number of triangles on mesh
* @param inputs mesh
* @returns number of triangles
* @group basic
* @shortname number triangles
* @drawable false
*/
numTri(inputs) {
return __awaiter(this, void 0, void 0, function* () {
return this.manifoldWorkerManager.genericCallToWorkerPromise("mesh.evaluate.numTri", inputs);
});
}
/**
* Number of triangle runs. Each triangle run is a set of consecutive
* triangles that all come from the same instance of the same input mesh.
* @param inputs mesh
* @returns number of runs
* @group basic
* @shortname number runs
* @drawable false
*/
numRun(inputs) {
return __awaiter(this, void 0, void 0, function* () {
return this.manifoldWorkerManager.genericCallToWorkerPromise("mesh.evaluate.numRun", inputs);
});
}
}