update add brim code

This commit is contained in:
casperlamboo 2017-05-26 17:35:30 +02:00 committed by Simon Voordouw
parent 4825222b09
commit b4b6e59807

View File

@ -1,9 +1,9 @@
import Shape from 'Doodle3D/clipper-js';
import * as THREE from 'three.js'; import * as THREE from 'three.js';
import { PRECISION } from '../constants.js'; import { PRECISION } from '../constants.js';
const offsetOptions = { const offsetOptions = {
jointType: 'jtSquare', jointType: 'jtRound',
endType: 'etClosedPolygon',
miterLimit: 2.0, miterLimit: 2.0,
roundPrecision: 0.25 roundPrecision: 0.25
}; };
@ -14,8 +14,13 @@ export default function addBrim(slices, settings) {
let { brimOffset } = settings.config; let { brimOffset } = settings.config;
brimOffset /= PRECISION; brimOffset /= PRECISION;
const fistLayer = slices[0]; const [fistLayer] = slices;
fistLayer.brim = fistLayer
.getOutline() fistLayer.brim = fistLayer.parts.reduce((brim, { shape }) => {
.offset(brimOffset, offsetOptions); brim.join(shape.offset(brimOffset, {
...offsetOptions,
endType: shape.closed ? 'etClosedPolygon' : 'etOpenRound'
}));
return brim;
}, new Shape([], true)).simplify('pftNonZero');
} }