diff --git a/src/box.js b/src/box.js index cbc450e..4b15095 100644 --- a/src/box.js +++ b/src/box.js @@ -74,7 +74,7 @@ D3D.Box.prototype.init = function () { } } - scope.updateLoop(); + scope.updateState(); }); }); @@ -88,7 +88,7 @@ D3D.Box.prototype.updateLoop = function () { //Bij error wordt gelijk zelfde data opnieuw gestuurd //Als DoodleBox ontkoppeld wordt komt er een error in de loop waardoor pagina breekt en ververst moet worden - if (this.printBatches.length > 0 && (this.status["buffered_lines"] + this.batches[0].length) <= this.maxBufferedLines) { + if (this.printBatches.length > 0 && (this.status["buffered_lines"] + this.printBatches[0].length) <= this.maxBufferedLines) { //if (this.printBatches.length > 0 ) { this.printBatch(); } diff --git a/src/gcode.js b/src/gcode.js index a36fa19..2cf5955 100644 --- a/src/gcode.js +++ b/src/gcode.js @@ -19,9 +19,9 @@ D3D.GCode = function () { this.bottom = true; this.isRetracted = false; this.isFanOn = false; - this.nozzlePosition = new THREE.Vector2(0, 0); + this._nozzlePosition = new THREE.Vector2(0, 0); }; -D3D.GCode.prototype.addGCode = function (command) { +D3D.GCode.prototype._addGCode = function (command) { "use strict"; var str = []; @@ -62,7 +62,7 @@ D3D.GCode.prototype.turnFanOn = function (fanSpeed) { gcode["S"] = fanSpeed; } - this.addGCode(gcode); + this._addGCode(gcode); return this; }; @@ -71,7 +71,7 @@ D3D.GCode.prototype.turnFanOff = function () { this.isFanOn = false; - this.addGCode({ + this._addGCode({ "M": 107 }); @@ -86,13 +86,13 @@ D3D.GCode.prototype.moveTo = function (x, y, layer) { var z = (layer + 1) * layerHeight; var speed = travelSpeed * 60; - this.addGCode({ + this._addGCode({ "G": 0, "X": x.toFixed(3), "Y": y.toFixed(3), "Z": z.toFixed(3), "F": speed.toFixed(3) }); - this.nozzlePosition.set(x, y); + this._nozzlePosition.set(x, y); return this; }; @@ -112,19 +112,19 @@ D3D.GCode.prototype.lineTo = function (x, y, layer, type) { var flowRate = profile["flowRate"]; var z = (layer + 1) * layerHeight; - var lineLength = this.nozzlePosition.distanceTo(newNozzlePosition); + var lineLength = this._nozzlePosition.distanceTo(newNozzlePosition); var filamentSurfaceArea = Math.pow((filamentThickness/2), 2) * Math.PI; this.extruder += lineLength * nozzleDiameter * layerHeight / filamentSurfaceArea * flowRate; - this.addGCode({ + this._addGCode({ "G": 1, "X": x.toFixed(3), "Y": y.toFixed(3), "Z": z.toFixed(3), "F": speed.toFixed(3), "E": this.extruder.toFixed(3) }); - this.nozzlePosition.copy(newNozzlePosition); + this._nozzlePosition.copy(newNozzlePosition); return this; }; @@ -141,7 +141,7 @@ D3D.GCode.prototype.unRetract = function () { var speed = retractionSpeed * 60; if (this.extruder > retractionMinDistance) { - this.addGCode({ + this._addGCode({ "G": 0, "E": this.extruder.toFixed(3), "F": speed.toFixed(3) @@ -165,7 +165,7 @@ D3D.GCode.prototype.retract = function () { var speed = retractionSpeed * 60; if (this.extruder > retractionMinDistance && retractionEnabled) { - this.addGCode({ + this._addGCode({ "G": 0, "E": (this.extruder - retractionAmount).toFixed(3), "F": speed.toFixed(3) diff --git a/src/slicer.js b/src/slicer.js index 1d1ddf4..8205bd1 100644 --- a/src/slicer.js +++ b/src/slicer.js @@ -129,12 +129,9 @@ D3D.Slicer.prototype.slice = function (layerHeight, height) { var slices = []; - //still error in first layer, so remove first layer & last layer - //see https://github.com/Doodle3D/Doodle3D-Slicer/issues/1 for (var layer = 1; layer < layersIntersections.length; layer ++) { var layerIntersections = layersIntersections[layer]; - //why have a slice with only support? if (layerIntersections.length > 0) { var y = layer * layerHeight; @@ -205,7 +202,6 @@ D3D.Slicer.prototype.slice = function (layerHeight, height) { } } - //think this check is not nescesary, always higher as 0 if (shape.length > 1) { var part = new D3D.Paths([shape]).clean(0.01); sliceParts.push(part); @@ -451,7 +447,7 @@ D3D.Slicer.prototype.getFillTemplate = function (bounds, size, even, uneven) { return paths; }; -D3D.Slicer.prototype.dataToGCode = function (data, printer) { +D3D.Slicer.prototype.dataToGCode = function (slices, printer) { "use strict"; var gcode = new D3D.GCode().setSettings(printer); @@ -484,8 +480,8 @@ D3D.Slicer.prototype.dataToGCode = function (data, printer) { } } - for (var layer = 0; layer < data.length; layer ++) { - var slice = data[layer]; + for (var layer = 0; layer < slices.length; layer ++) { + var slice = slices[layer]; if (layer === 1) { gcode.turnFanOn();