mirror of
https://github.com/Doodle3D/Doodle3D-Slicer.git
synced 2024-11-26 07:24:57 +01:00
properly check for undefined
This commit is contained in:
parent
b4b6e59807
commit
55b63ac8ad
@ -32,9 +32,9 @@ export default function createLines(geometry, settings, openClosed) {
|
||||
|
||||
// only add unique lines
|
||||
// returns index of said line
|
||||
const indexA = lookupA !== undefined ? lookupA : addLine(geometry, lineLookup, lines, face.a, face.b);
|
||||
const indexB = lookupB !== undefined ? lookupB : addLine(geometry, lineLookup, lines, face.b, face.c);
|
||||
const indexC = lookupC !== undefined ? lookupC : addLine(geometry, lineLookup, lines, face.c, face.a);
|
||||
const indexA = typeof lookupA !== 'undefined' ? lookupA : addLine(geometry, lineLookup, lines, face.a, face.b);
|
||||
const indexB = typeof lookupB !== 'undefined' ? lookupB : addLine(geometry, lineLookup, lines, face.b, face.c);
|
||||
const indexC = typeof lookupC !== 'undefined' ? lookupC : addLine(geometry, lineLookup, lines, face.c, face.a);
|
||||
|
||||
// set connecting lines (based on face)
|
||||
lines[indexA].connects.push(indexB, indexC);
|
||||
|
@ -17,7 +17,7 @@ export default function intersectionsToShapes(layerIntersectionIndexes, layerInt
|
||||
for (let i = 0; i < intersectionIndexes.length; i ++) {
|
||||
let index = intersectionIndexes[i];
|
||||
|
||||
if (intersectionPoints[index] === undefined) continue;
|
||||
if (typeof intersectionPoints[index] === 'undefined') continue;
|
||||
|
||||
const shape = [];
|
||||
|
||||
@ -46,7 +46,7 @@ export default function intersectionsToShapes(layerIntersectionIndexes, layerInt
|
||||
}
|
||||
|
||||
// Check if index has an intersection or is already used
|
||||
if (intersectionPoints[index] !== undefined) {
|
||||
if (typeof intersectionPoints[index] !== 'undefined') {
|
||||
const faceNormal = faceNormals[Math.floor(i / 2)];
|
||||
|
||||
const a = new THREE.Vector2(intersection.x, intersection.y);
|
||||
@ -99,7 +99,7 @@ export default function intersectionsToShapes(layerIntersectionIndexes, layerInt
|
||||
for (let i = 0; i < connects.length; i ++) {
|
||||
index = connects[i];
|
||||
|
||||
if (intersectionPoints[index] !== undefined) {
|
||||
if (typeof intersectionPoints[index] !== 'undefined') {
|
||||
break;
|
||||
} else {
|
||||
index = -1;
|
||||
|
@ -9,7 +9,7 @@ export default function optimizePaths(slices, settings) {
|
||||
for (let layer = 0; layer < slices.length; layer ++) {
|
||||
const slice = slices[layer];
|
||||
|
||||
if (slice.brim !== undefined && slice.brim.paths.length > 0) {
|
||||
if (typeof slice.brim !== 'undefined' && slice.brim.paths.length > 0) {
|
||||
slice.brim = optimizeShape(slice.brim, start);
|
||||
start.copy(slice.brim.lastPoint(true));
|
||||
}
|
||||
@ -73,7 +73,7 @@ export default function optimizePaths(slices, settings) {
|
||||
|
||||
slice.parts = parts;
|
||||
|
||||
if (slice.support !== undefined && slice.support.length > 0) {
|
||||
if (typeof slice.support !== 'undefined' && slice.support.length > 0) {
|
||||
slice.support = optimizeShape(slice.support, start);
|
||||
start.copy(slice.support.lastPoint(true));
|
||||
}
|
||||
|
@ -24,10 +24,10 @@ export default function removePrecision(slices) {
|
||||
}
|
||||
}
|
||||
|
||||
if (slice.support !== undefined) {
|
||||
if (typeof slice.support !== 'undefined') {
|
||||
slice.support.scaleDown(inversePrecision);
|
||||
}
|
||||
if (slice.brim !== undefined) {
|
||||
if (typeof slice.brim !== 'undefined') {
|
||||
slice.brim.scaleDown(inversePrecision);
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ export default function slicesToGCode(slices, settings) {
|
||||
gcode.bottom = false;
|
||||
}
|
||||
|
||||
if (slice.brim !== undefined) {
|
||||
if (typeof slice.brim !== 'undefined') {
|
||||
pathToGCode(gcode, slice.brim, true, true, layer, 'brim');
|
||||
}
|
||||
|
||||
@ -30,12 +30,12 @@ export default function slicesToGCode(slices, settings) {
|
||||
|
||||
pathToGCode(gcode, part.fill, true, false, layer, 'fill');
|
||||
} else {
|
||||
const retract = !(slice.parts.length === 1 && slice.support === undefined);
|
||||
const retract = !(slice.parts.length === 1 && typeof slice.support === 'undefined');
|
||||
pathToGCode(gcode, part.shape, retract, retract, layer, 'outerLine');
|
||||
}
|
||||
}
|
||||
|
||||
if (slice.support !== undefined) {
|
||||
if (typeof slice.support !== 'undefined') {
|
||||
pathToGCode(gcode, slice.support, true, true, layer, 'support');
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user