update add brim code

This commit is contained in:
casperlamboo 2017-05-26 17:35:30 +02:00
parent 8bf771b0f9
commit 68f1cd847d

View File

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