本文整理汇总了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);