Skip to content

Commit f1c6ae6

Browse files
authored
Merge pull request #84 from DrLex0/clean-up-previous-model
Clean up data of previous model when loading new one
2 parents 3148993 + 6354f3c commit f1c6ae6

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

js/Worker.js

+4-5
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,10 @@
130130
var type;
131131
var printTimeAdd=0;
132132
// var moveTime=0;
133+
// Clean up data from previous model
134+
speedsByLayer = {extrude: {}, retract: {}, move: {}};
135+
volSpeedsByLayer = {};
136+
extrusionSpeedsByLayer = {};
133137

134138
for(i=0;i<model.length;i++){
135139
cmds = model[i];
@@ -241,11 +245,6 @@
241245
extrusionSpeedsByLayer[cmds[j].prevZ] = [];
242246
}
243247
if(extrusionSpeedsByLayer[cmds[j].prevZ].indexOf(extrusionSpeed) === -1){
244-
// Array elements will NOT necessarily be set to undefined when
245-
// assigning beyond the current array length, so do it explicitly.
246-
for(var k=extrusionSpeedsByLayer[cmds[j].prevZ].length; k<volIndex; k++) {
247-
extrusionSpeedsByLayer[cmds[j].prevZ].push(undefined);
248-
}
249248
extrusionSpeedsByLayer[cmds[j].prevZ][volIndex] = extrusionSpeed;
250249
}
251250
}

0 commit comments

Comments
 (0)