mirror of
https://github.com/Doodle3D/Doodle3D-Slicer.git
synced 2025-04-03 10:23:23 +02:00
25 lines
606 B
JavaScript
25 lines
606 B
JavaScript
import Shape from 'Doodle3D/clipper-js';
|
|
import { PRECISION } from '../constants.js';
|
|
|
|
const offsetOptions = {
|
|
jointType: 'jtRound',
|
|
miterLimit: 2.0,
|
|
roundPrecision: 0.25
|
|
};
|
|
|
|
export default function addBrim(slices, settings) {
|
|
let {
|
|
brim: { offset: brimOffset }
|
|
} = settings;
|
|
brimOffset /= PRECISION;
|
|
|
|
const [firstLayer] = slices;
|
|
|
|
firstLayer.brim = firstLayer.parts.reduce((brim, { shape }) => (
|
|
brim.join(shape.offset(brimOffset, {
|
|
...offsetOptions,
|
|
endType: shape.closed ? 'etClosedPolygon' : 'etOpenRound'
|
|
}))
|
|
), new Shape([], true)).simplify('pftNonZero');
|
|
}
|