replace vars with const and let

This commit is contained in:
casperlamboo 2016-04-22 21:14:21 +02:00
parent 6891e09b54
commit 1cddce9e69

View File

@ -19,34 +19,32 @@ export default function generateInfills(slices, settings) {
nozzleDiameter *= scale; nozzleDiameter *= scale;
infillOverlap *= scale; infillOverlap *= scale;
var bottomSkinCount = Math.ceil(bottomThickness/layerHeight); const bottomSkinCount = Math.ceil(bottomThickness/layerHeight);
var topSkinCount = Math.ceil(topThickness/layerHeight); const topSkinCount = Math.ceil(topThickness/layerHeight);
var nozzleRadius = nozzleDiameter / 2; const nozzleRadius = nozzleDiameter / 2;
var hightemplateSize = Math.sqrt(2 * Math.pow(nozzleDiameter, 2)); const hightemplateSize = Math.sqrt(2 * Math.pow(nozzleDiameter, 2));
for (var layer = 0; layer < slices.length; layer ++) { for (let layer = 0; layer < slices.length; layer ++) {
var slice = slices[layer]; const slice = slices[layer];
let surroundingLayer;
if (layer - bottomSkinCount >= 0 && layer + topSkinCount < slices.length) { if (layer - bottomSkinCount >= 0 && layer + topSkinCount < slices.length) {
var downSkin = slices[layer - bottomSkinCount].getOutline(); const downSkin = slices[layer - bottomSkinCount].getOutline();
var upSkin = slices[layer + topSkinCount].getOutline(); const upSkin = slices[layer + topSkinCount].getOutline();
var surroundingLayer = upSkin.intersect(downSkin); surroundingLayer = upSkin.intersect(downSkin);
}
else {
var surroundingLayer = false;
} }
for (var i = 0; i < slice.parts.length; i ++) { for (let i = 0; i < slice.parts.length; i ++) {
var part = slice.parts[i]; const part = slice.parts[i];
if (!part.shape.closed) { if (!part.shape.closed) {
continue; continue;
} }
var outerLine = part.outerLine; const outerLine = part.outerLine;
if (outerLine.paths.length > 0) { if (outerLine.paths.length > 0) {
var inset = (part.innerLines.length > 0) ? part.innerLines[part.innerLines.length - 1] : outerLine; const inset = (part.innerLines.length > 0) ? part.innerLines[part.innerLines.length - 1] : outerLine;
const fillArea = inset.offset(-nozzleRadius); const fillArea = inset.offset(-nozzleRadius);
let lowFillArea; let lowFillArea;
@ -67,16 +65,16 @@ export default function generateInfills(slices, settings) {
} }
if (lowFillArea && lowFillArea.paths.length > 0) { if (lowFillArea && lowFillArea.paths.length > 0) {
var bounds = lowFillArea.shapeBounds(); const bounds = lowFillArea.shapeBounds();
var lowFillTemplate = getFillTemplate(bounds, fillGridSize, true, true); const lowFillTemplate = getFillTemplate(bounds, fillGridSize, true, true);
part.fill.join(lowFillTemplate.intersect(lowFillArea)); part.fill.join(lowFillTemplate.intersect(lowFillArea));
} }
if (highFillArea.paths.length > 0) { if (highFillArea.paths.length > 0) {
var bounds = highFillArea.shapeBounds(); const bounds = highFillArea.shapeBounds();
var even = (layer % 2 === 0); const even = (layer % 2 === 0);
var highFillTemplate = getFillTemplate(bounds, hightemplateSize, even, !even); const highFillTemplate = getFillTemplate(bounds, hightemplateSize, even, !even);
part.fill.join(highFillTemplate.intersect(highFillArea)); part.fill.join(highFillTemplate.intersect(highFillArea));
} }