當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript makerjs.model類代碼示例

本文整理匯總了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;
}
開發者ID:forresto,項目名稱:sketch,代碼行數:25,代碼來源:labyrinth-03.maker.ts

示例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);
            }
開發者ID:Microsoft,項目名稱:maker.js,代碼行數:23,代碼來源:export-worker.ts

示例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);
開發者ID:forresto,項目名稱:sketch,代碼行數:30,代碼來源:labyrinth-03.maker.ts


注:本文中的makerjs.model類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。