本文整理匯總了TypeScript中makerjs.model類的典型用法代碼示例。如果您正苦於以下問題:TypeScript model類的具體用法?TypeScript model怎麽用?TypeScript model使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了model類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: pathToMaker
function pathToMaker(path: AbsPath): MakerJs.IModel {
const length = path.length;
const lines = path.reduce(function(last, current, index, array) {
const line = new MakerJs.paths.Line(current, array[(index + 1) % length]);
const scaled = MakerJs.path.scale(line, SCALE);
last['line' + index] = scaled;
return last;
}, {});
const output: MakerJs.IModel = {paths: lines};
MakerJs.model.findChains(output, function(chains, loose, layer) {
const chain = chains[0];
const fillets = MakerJs.chain.fillet(chain, RADIUS);
output.models = {fillets};
});
// MakerJs.model.move(output, [SCALE / 2, SCALE / 2]);
// Mirror Y to normalize coordinate system
// const mirrored = MakerJs.model.mirror(output, false, true);
// mirrored.units = MakerJs.unitType.Millimeter;
// MakerJs.model.move(mirrored, [0, 0 - BOARD]);
return output;
}
示例2: toStl
function toStl(model: MakerJs.IModel, options: MakerJs.exporter.IJscadCsgOptions) {
if (!deps[MakerJsPlaygroundExport.ExportFormat.Stl]) {
importScripts(
'../../../external/jscad/csg.js',
'../../../external/jscad/stl-serializer.js'
);
deps[MakerJsPlaygroundExport.ExportFormat.Stl] = true;
}
//make sure size is in mm for STL
model = makerjs.model.convertUnits(model, makerjs.unitType.Millimeter);
const { CAG }: { CAG: typeof jscad.CAG } = require('@jscad/csg');
const stlSerializer: jscad.StlSerializer = require('@jscad/stl-serializer');
options.statusCallback = function (status) {
result.percentComplete = status.progress;
postMessage(result);
}
return makerjs.exporter.toJscadSTL(CAG, stlSerializer, model, options);
}
示例3:
// const expanded = MakerJs.model.expandPaths(makerPath, STROKE);
const points = [
[0, 0],
[0, BOARD - SCALE],
[BOARD - SCALE, 0],
[BOARD - SCALE, BOARD - SCALE],
[(BOARD - SCALE) / 2, (BOARD - SCALE) / 2]
// [-SCALE / 2, SCALE / 2],
// [BOARD - SCALE * 3/2, SCALE / 2],
// [-SCALE/2, -BOARD + SCALE * 3/2],
// [BOARD - SCALE * 3/2, -BOARD + SCALE * 3/2],
];
const holes: MakerJs.IModel = new MakerJs.models.Holes(2, points);
MakerJs.model.move(holes, [0 - SCALE / 2, 0 - SCALE / 2]);
/*
The Stack To Cut
stacked paper with approx semicircular path
*/
const expanded = {};
const layerOptions = {};
const MARGIN = 12;
const COLS = 3;
for (let i = 0; i < PAGES; i++) {
const depth = THICKNESS * (PAGES - i - 1);