From 9aef506a4a70d6d531c6c7072930891a42a573eb Mon Sep 17 00:00:00 2001 From: casperlamboo Date: Thu, 11 Jun 2015 15:42:38 +0200 Subject: [PATCH] changed format settings --- settings/printer_settings.json | 81 ++++++++++++------------ settings/user_settings.json | 64 ++++++++++++------- slice_test.html | 2 +- src/gcode.js | 109 ++++++++++++++++----------------- src/printer.js | 20 +++--- src/slicer.js | 54 ++++++++-------- webworker_test.html | 4 +- 7 files changed, 173 insertions(+), 161 deletions(-) diff --git a/settings/printer_settings.json b/settings/printer_settings.json index a2761c1..40dd728 100644 --- a/settings/printer_settings.json +++ b/settings/printer_settings.json @@ -1,47 +1,50 @@ { "ultimaker": { - "printer.baudrate": "115200", - "printer.dimensions.x": 200, - "printer.dimensions.y": 200, - "printer.dimensions.z": 200, - "printer.endcode": "M107 ;fan off\nG91 ;relative positioning\nG1 E-1 F300 ;retract the filament a bit before lifting the nozzle, to release some of the pressure\nG1 Z+0.5 E-5 X-20 Y-20 F9000 ;move Z up a bit and retract filament even more\nG28 X0 Y0 ;move X/Y to min endstops, so the head is out of the way\nM84 ;disable axes / steppers\nG90 ;absolute positioning\nM104 S{preheatTemp}\n{if heatedBed}M140 S{preheatBedTemp}\nM117 Done ;display message (20 characters to clear whole screen)\n", - "printer.filamentThickness": 2.85, - "printer.heatedbed": false, - "printer.heatup.bed.temperature": 70, - "printer.heatup.enabled": true, - "printer.heatup.temperature": 180, - "printer.nozzleDiameter": 0.4, - "printer.startcode": ";Generated with Doodle3D (default)\nM109 S{printingTemp} ;set target temperature \n{if heatedBed}M190 S{printingBedTemp} ;set target bed temperature\nG21 ;metric values\nG91 ;relative positioning\nM107 ;start with the fan off\nG28 X0 Y0 ;move X/Y to min endstops\nG28 Z0 ;move Z to min endstops\nG1 Z15 F9000 ;move the platform down 15mm\nG92 E0 ;zero the extruded length\nG1 F200 E10 ;extrude 10mm of feed stock\nG92 E0 ;zero the extruded length again\nG92 E0 ;zero the extruded length again\nG1 F9000\nG90 ;absolute positioning\nM117 Printing Doodle... ;display message (20 characters to clear whole screen)\n", - "printer.type": "ultimaker" + "baudrate": "115200", + "dimensionsX": 200, + "dimensionsY": 200, + "dimensionsZ": 200, + "endCode": "M107 ;fan off\nG91 ;relative positioning\nG1 E-1 F300 ;retract the filament a bit before lifting the nozzle, to release some of the pressure\nG1 Z+0.5 E-5 X-20 Y-20 F9000 ;move Z up a bit and retract filament even more\nG28 X0 Y0 ;move X/Y to min endstops, so the head is out of the way\nM84 ;disable axes / steppers\nG90 ;absolute positioning\nM104 S{preheatTemp}\n{if heatedBed}M140 S{preheatBedTemp}\nM117 Done ;display message (20 characters to clear whole screen)\n", + "filamentThickness": 2.85, + "heatedBed": false, + "heatupBedTemperature": 70, + "heatupEnabled": true, + "heatupTemperature": 180, + "nozzleDiameter": 0.4, + "startCode": ";Generated with Doodle3D (default)\nM109 S{printingTemp} ;set target temperature \n{if heatedBed}M190 S{printingBedTemp} ;set target bed temperature\nG21 ;metric values\nG91 ;relative positioning\nM107 ;start with the fan off\nG28 X0 Y0 ;move X/Y to min endstops\nG28 Z0 ;move Z to min endstops\nG1 Z15 F9000 ;move the platform down 15mm\nG92 E0 ;zero the extruded length\nG1 F200 E10 ;extrude 10mm of feed stock\nG92 E0 ;zero the extruded length again\nG92 E0 ;zero the extruded length again\nG1 F9000\nG90 ;absolute positioning\nM117 Printing Doodle... ;display message (20 characters to clear whole screen)\n", + "temperature": 210.0, + "type": "ultimaker" }, "ultimaker2": { - "printer.baudrate": "115200", - "printer.dimensions.x": 223, - "printer.dimensions.y": 223, - "printer.dimensions.z": 205, - "printer.endcode": "M107 ;fan off\nG91 ;relative positioning\nG1 E-1 F300 ;retract the filament a bit before lifting the nozzle, to release some of the pressure\nG1 Z+5.5 E-5 X-20 Y-20 F9000 ;move Z up a bit and retract filament even more\nG28 ;home the printer\nM84 ;disable axes / steppers\nG90 ;absolute positioning\nM104 S{preheatTemp}\n{if heatedBed}M140 S{preheatBedTemp}\nM117 Done ;display message (20 characters to clear whole screen)\n", - "printer.filamentThickness": 2.85, - "printer.heatedbed": true, - "printer.heatup.bed.temperature": 70, - "printer.heatup.enabled": true, - "printer.heatup.temperature": 180, - "printer.nozzleDiameter": 0.4, - "printer.startcode": ";Generated with Doodle3D (ultimaker2)\nM109 S{printingTemp} ;set target temperature \n{if heatedBed}M190 S{printingBedTemp} ;set target bed temperature\nG21 ;metric values\nG90 ;absolute positioning\nM107 ;start with the fan off\nG28 ; home to endstops\nG1 Z15 F9000 ;move the platform down 15mm\nG92 E0 ;zero the extruded length\nG1 F200 E10 ;extrude 10mm of feed stock\nG92 E0 ;zero the extruded length again\nG1 F9000\nM117 Printing Doodle... ;display message (20 characters to clear whole screen)\n", - "printer.type": "ultimaker2" + "baudrate": "115200", + "dimensionsX": 223, + "dimensionsY": 223, + "dimensionsZ": 205, + "endCode": "M107 ;fan off\nG91 ;relative positioning\nG1 E-1 F300 ;retract the filament a bit before lifting the nozzle, to release some of the pressure\nG1 Z+5.5 E-5 X-20 Y-20 F9000 ;move Z up a bit and retract filament even more\nG28 ;home the printer\nM84 ;disable axes / steppers\nG90 ;absolute positioning\nM104 S{preheatTemp}\n{if heatedBed}M140 S{preheatBedTemp}\nM117 Done ;display message (20 characters to clear whole screen)\n", + "filamentThickness": 2.85, + "heatedBed": true, + "heatupBedTemperature": 70, + "heatupEnabled": true, + "heatupTemperature": 180, + "nozzleDiameter": 0.4, + "startCode": ";Generated with Doodle3D (ultimaker2)\nM109 S{printingTemp} ;set target temperature \n{if heatedBed}M190 S{printingBedTemp} ;set target bed temperature\nG21 ;metric values\nG90 ;absolute positioning\nM107 ;start with the fan off\nG28 ; home to endstops\nG1 Z15 F9000 ;move the platform down 15mm\nG92 E0 ;zero the extruded length\nG1 F200 E10 ;extrude 10mm of feed stock\nG92 E0 ;zero the extruded length again\nG1 F9000\nM117 Printing Doodle... ;display message (20 characters to clear whole screen)\n", + "temperature": 210.0, + "type": "ultimaker2" }, "ultimaker2go": { - "printer.baudrate": "115200", - "printer.dimensions.x": 120, - "printer.dimensions.y": 120, - "printer.dimensions.z": 115, - "printer.endcode": "M107 ;fan off\nG91 ;relative positioning\nG1 E-1 F300 ;retract the filament a bit before lifting the nozzle, to release some of the pressure\nG1 Z+5.5 E-5 X-20 Y-20 F9000 ;move Z up a bit and retract filament even more\nG28 ;home the printer\nM84 ;disable axes / steppers\nG90 ;absolute positioning\nM104 S{preheatTemp}\n{if heatedBed}M140 S{preheatBedTemp}\nM117 Done ;display message (20 characters to clear whole screen)\n", - "printer.filamentThickness": 2.85, - "printer.heatedbed": false, - "printer.heatup.bed.temperature": 70, - "printer.heatup.enabled": true, - "printer.heatup.temperature": 20, - "printer.nozzleDiameter": 0.4, - "printer.startcode": ";Generated with Doodle3D (ultimaker2)\nM109 S{printingTemp} ;set target temperature \n{if heatedBed}M190 S{printingBedTemp} ;set target bed temperature\nG21 ;metric values\nG90 ;absolute positioning\nM107 ;start with the fan off\nG28 ; home to endstops\nG1 Z15 F9000 ;move the platform down 15mm\nG92 E0 ;zero the extruded length\nG1 F200 E10 ;extrude 10mm of feed stock\nG92 E0 ;zero the extruded length again\nG1 F9000\nM117 Printing Doodle... ;display message (20 characters to clear whole screen)\n", - "printer.type": "ultimaker2g0" + "baudrate": "115200", + "dimensionsX": 120, + "dimensionsY": 120, + "dimensionsZ": 115, + "endCode": "M107 ;fan off\nG91 ;relative positioning\nG1 E-1 F300 ;retract the filament a bit before lifting the nozzle, to release some of the pressure\nG1 Z+5.5 E-5 X-20 Y-20 F9000 ;move Z up a bit and retract filament even more\nG28 ;home the printer\nM84 ;disable axes / steppers\nG90 ;absolute positioning\nM104 S{preheatTemp}\n{if heatedBed}M140 S{preheatBedTemp}\nM117 Done ;display message (20 characters to clear whole screen)\n", + "filamentThickness": 2.85, + "heatedBed": false, + "heatupBedTemperature": 70, + "heatupEnabled": true, + "heatupTemperature": 20, + "nozzleDiameter": 0.4, + "startCode": ";Generated with Doodle3D (ultimaker2)\nM109 S{printingTemp} ;set target temperature \n{if heatedBed}M190 S{printingBedTemp} ;set target bed temperature\nG21 ;metric values\nG90 ;absolute positioning\nM107 ;start with the fan off\nG28 ; home to endstops\nG1 Z15 F9000 ;move the platform down 15mm\nG92 E0 ;zero the extruded length\nG1 F200 E10 ;extrude 10mm of feed stock\nG92 E0 ;zero the extruded length again\nG1 F9000\nM117 Printing Doodle... ;display message (20 characters to clear whole screen)\n", + "temperature": 210.0, + "type": "ultimaker2g0" } } \ No newline at end of file diff --git a/settings/user_settings.json b/settings/user_settings.json index 3994c88..addb0f4 100644 --- a/settings/user_settings.json +++ b/settings/user_settings.json @@ -1,25 +1,43 @@ { - "printer.normalFlowRate": 1.0, - "printer.bottomFlowRate": 2.0, - "printer.bottomLayerSpeed": 35.0, - "printer.bottomThickness": 0.4, - "printer.fillSize": 5.0, - "printer.firstLayerSlow": true, - "printer.layerHeight": 0.2, - "printer.retraction.amount": 3.0, - "printer.retraction.enabled": true, - "printer.retraction.speed": 50, - "printer.retraction.minDistance": 5.0, - "printer.shellThickness": 0.4, - "printer.speed": 50.0, - "printer.brimOffset": 5.0, - "printer.temperature": 210.0, - "printer.topThickness": 0.8, - "printer.travelSpeed": 200.0, - "printer.support.accaptanceMargin": 1.5, - "printer.support.distanceY": 0.4, - "printer.support.use": true, - "printer.support.gritSize": 6.0, - "printer.support.margin": 2.0, - "printer.support.plateSize": 4.0 + "layerHeight": 0.2, + "bottomThickness": 0.4, + "topThickness": 0.8, + "shellThickness": 0.4, + "brimOffset": 5.0, + "fillGritSize": 5.0, + "travelSpeed": 200.0, + "retractionAmount": 3.0, + "retractionEnabled": true, + "retractionSpeed": 50.0, + "retractionMinDistance": 5.0, + "supportAccaptanceMargin": 1.5, + "supportDistanceY": 0.4, + "supportUse": true, + "supportGritSize": 6.0, + "supportMargin": 2.0, + "supportPlateSize": 4.0, + "outerLine": { + "flowRate": 1.0, + "speed": 50.0 + }, + "innerLine": { + "flowRate": 1.0, + "speed": 80.0 + }, + "fill": { + "flowRate": 1.0, + "speed": 80.0 + }, + "brim": { + "flowRate": 1.0, + "speed": 50.0 + }, + "support": { + "flowRate": 0.2, + "speed": 100.0 + }, + "bottom": { + "flowRate": 2.0, + "speed": 30.0 + } } \ No newline at end of file diff --git a/slice_test.html b/slice_test.html index 66bcf44..d0fd7c1 100644 --- a/slice_test.html +++ b/slice_test.html @@ -37,7 +37,7 @@ function init () { var printer = new D3D.Printer().updateConfig(USER_SETTINGS).updateConfig(PRINTER_SETTINGS["ultimaker"]); var loader = new THREE.STLLoader(); - loader.load('models/pokemon/pikachu.stl', function (geometry) { + loader.load('models/support_test.stl', function (geometry) { //var geometry = new THREE.BoxGeometry(10, 10, 10, 1, 1, 1); //var geometry = new THREE.SphereGeometry(10, 20, 10); //var geometry = new THREE.TorusGeometry(20, 10, 30, 30); diff --git a/src/gcode.js b/src/gcode.js index 3e0fc6e..5dba303 100644 --- a/src/gcode.js +++ b/src/gcode.js @@ -76,73 +76,70 @@ D3D.GCode.prototype.turnFanOff = function () { return this; }; -D3D.GCode.prototype.moveTo = function (extrude, x, y, layer) { +D3D.GCode.prototype.moveTo = function (x, y, layer) { "use strict"; - var layerHeight = this.settings.config["printer.layerHeight"]; - var firstLayerSlow = this.settings.config["printer.firstLayerSlow"]; - var normalSpeed = this.settings.config["printer.speed"]; - var bottomSpeed = this.settings.config["printer.bottomLayerSpeed"]; - var normalSpeed = this.settings.config["printer.speed"]; - var bottomSpeed = this.settings.config["printer.bottomLayerSpeed"]; - var nozzleDiameter = this.settings.config["printer.nozzleDiameter"]; - var filamentThickness = this.settings.config["printer.filamentThickness"]; - var bottomFlowRate = this.settings.config["printer.bottomFlowRate"]; - var normalFlowRate = this.settings.config["printer.normalFlowRate"]; - var travelSpeed = this.settings.config["printer.travelSpeed"]; + var layerHeight = this.settings.config["layerHeight"]; + var travelSpeed = this.settings.config["travelSpeed"]; + + var z = (layer + 1) * layerHeight; + var speed = travelSpeed * 60; - if (this.bottom) { - var speed = bottomSpeed * 60; - var flowRate = bottomFlowRate; - } - else { - var speed = normalSpeed * 60; - var flowRate = normalFlowRate; - } + 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); + + return this; +}; +D3D.GCode.prototype.lineTo = function (x, y, layer, type) { + "use strict"; + + var newNozzlePosition = new THREE.Vector2(x, y); + + var layerHeight = this.settings.config["layerHeight"]; + var nozzleDiameter = this.settings.config["nozzleDiameter"]; + var filamentThickness = this.settings.config["filamentThickness"]; + var travelSpeed = this.settings.config["travelSpeed"]; + + var profile = this.settings.config[(this.bottom ? "bottom" : type)]; + + var speed = profile["speed"] * 60; + var flowRate = profile["flowRate"]; var z = (layer + 1) * layerHeight; - if (extrude) { - var lineLength = this.nozzlePosition.distanceTo(new THREE.Vector2(x, y)); + var lineLength = this.nozzlePosition.distanceTo(newNozzlePosition); - var filamentSurfaceArea = Math.pow((filamentThickness/2), 2) * Math.PI; - this.extruder += lineLength * nozzleDiameter * layerHeight / filamentSurfaceArea * flowRate; + var filamentSurfaceArea = Math.pow((filamentThickness/2), 2) * Math.PI; + this.extruder += lineLength * nozzleDiameter * layerHeight / filamentSurfaceArea * flowRate; - 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) - }); - } - else { - var speed = travelSpeed * 60; + 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.addGCode({ - "G": 0, - "X": x.toFixed(3), "Y": y.toFixed(3), "Z": z.toFixed(3), - "F": speed.toFixed(3) - }); - - } - - this.nozzlePosition = new THREE.Vector2(x, y); + this.nozzlePosition.copy(newNozzlePosition); return this; }; D3D.GCode.prototype.unRetract = function () { "use strict"; - if (this.isRetracted) { - this.isRetracted = false; + var retractionEnabled = this.settings.config["retractionEnabled"]; + var retractionMinDistance = this.settings.config["retractionMinDistance"]; + var retractionSpeed = this.settings.config["retractionSpeed"]; - var retractionAmount = this.settings.config["printer.retraction.amount"]; - var retractionEnabled = this.settings.config["printer.retraction.enabled"]; - var retractionMinDistance = this.settings.config["printer.retraction.minDistance"]; - var retractionSpeed = this.settings.config["printer.retraction.speed"]; + if (this.isRetracted && retractionEnabled) { + this.isRetracted = false; var speed = retractionSpeed * 60; - if (this.extruder > retractionMinDistance && retractionEnabled) { + if (this.extruder > retractionMinDistance) { this.addGCode({ "G": 0, "E": this.extruder.toFixed(3), @@ -156,14 +153,14 @@ D3D.GCode.prototype.unRetract = function () { D3D.GCode.prototype.retract = function () { "use strict"; - if (!this.isRetracted) { + var retractionAmount = this.settings.config["retractionAmount"]; + var retractionEnabled = this.settings.config["retractionEnabled"]; + var retractionMinDistance = this.settings.config["retractionMinDistance"]; + var retractionSpeed = this.settings.config["retractionSpeed"]; + + if (!this.isRetracted && retractionEnabled) { this.isRetracted = true; - - var retractionAmount = this.settings.config["printer.retraction.amount"]; - var retractionEnabled = this.settings.config["printer.retraction.enabled"]; - var retractionMinDistance = this.settings.config["printer.retraction.minDistance"]; - var retractionSpeed = this.settings.config["printer.retraction.speed"]; - + var speed = retractionSpeed * 60; if (this.extruder > retractionMinDistance && retractionEnabled) { diff --git a/src/printer.js b/src/printer.js index efad2e6..a3efb37 100644 --- a/src/printer.js +++ b/src/printer.js @@ -14,9 +14,7 @@ D3D.Printer.prototype.updateConfig = function (config) { "use strict"; for (var i in config) { - if (i.indexOf("printer") === 0) { - this.config[i] = config[i]; - } + this.config[i] = config[i]; } return this; @@ -24,7 +22,7 @@ D3D.Printer.prototype.updateConfig = function (config) { D3D.Printer.prototype.getStartCode = function () { "use strict"; - var gcode = this.config["printer.startcode"]; + var gcode = this.config["startCode"]; gcode = this.subsituteVariables(gcode); return gcode; @@ -32,7 +30,7 @@ D3D.Printer.prototype.getStartCode = function () { D3D.Printer.prototype.getEndCode = function () { "use strict"; - var gcode = this.config["printer.endcode"]; + var gcode = this.config["endCode"]; gcode = this.subsituteVariables(gcode); @@ -41,12 +39,12 @@ D3D.Printer.prototype.getEndCode = function () { D3D.Printer.prototype.subsituteVariables = function (gcode) { "use strict"; - var temperature = this.config["printer.temperature"]; - var bedTemperature = this.config["printer.bed.temperature"]; - var preheatTemperature = this.config["printer.heatup.temperature"]; - var preheatBedTemperature = this.config["printer.heatup.bed.temperature"]; - var printerType = this.config["printer.type"]; - var heatedbed = this.config["printer.heatedbed"]; + var temperature = this.config["temperature"]; + var bedTemperature = this.config["bedTemperature"]; + var preheatTemperature = this.config["heatupTemperature"]; + var preheatBedTemperature = this.config["heatupBedTemperature"]; + var printerType = this.config["type"]; + var heatedbed = this.config["heatedbed"]; switch (printerType) { case "makerbot_replicator2": printerType = "r2"; break; diff --git a/src/slicer.js b/src/slicer.js index 83b817c..a3276fa 100644 --- a/src/slicer.js +++ b/src/slicer.js @@ -150,7 +150,6 @@ D3D.Slicer.prototype.slice = function (layerHeight, height) { var y = layer * layerHeight; var intersections = []; - var log = []; for (var i = 0; i < layerIntersections.length; i ++) { var index = layerIntersections[i]; var line = this.lines[index].line; @@ -166,7 +165,6 @@ D3D.Slicer.prototype.slice = function (layerHeight, height) { } intersections[index] = new THREE.Vector2(z, x); - log.push({x: z, y: x, index: index, connects: this.lines[index].connects}); } var done = []; @@ -194,8 +192,6 @@ D3D.Slicer.prototype.slice = function (layerHeight, height) { var faceNormal = faceNormals[Math.floor(j/2)]; - console.log(); - if (a.distanceTo(b) === 0 || faceNormal.equals(new THREE.Vector2(0, 0))) { connects = connects.concat(this.lines[index].connects); faceNormals = faceNormals.concat(this.lines[index].normals); @@ -280,20 +276,20 @@ D3D.Slicer.prototype.slicesToData = function (slices, printer) { var scale = 100; - var layerHeight = printer.config["printer.layerHeight"]; - var nozzleDiameter = printer.config["printer.nozzleDiameter"] * scale; - var shellThickness = printer.config["printer.shellThickness"] * scale; - var fillSize = printer.config["printer.fillSize"] * scale; - var brimOffset = printer.config["printer.brimOffset"] * scale; - var bottomThickness = printer.config["printer.bottomThickness"]; - var topThickness = printer.config["printer.topThickness"]; - var useSupport = printer.config["printer.support.use"]; - var supportGritSize = printer.config["printer.support.gritSize"] * scale; - var supportAccaptanceMargin = printer.config["printer.support.accaptanceMargin"] * scale; - var supportMargin = printer.config["printer.support.margin"] * scale; - var plateSize = printer.config["printer.support.plateSize"] * scale; - var supportDistanceY = printer.config["printer.support.distanceY"]; - var brimOffset = printer.config["printer.brimOffset"] * scale; + var layerHeight = printer.config["layerHeight"]; + var nozzleDiameter = printer.config["nozzleDiameter"] * scale; + var shellThickness = printer.config["shellThickness"] * scale; + var fillGritSize = printer.config["fillGritSize"] * scale; + var brimOffset = printer.config["brimOffset"] * scale; + var bottomThickness = printer.config["bottomThickness"]; + var topThickness = printer.config["topThickness"]; + var useSupport = printer.config["supportUse"]; + var supportGritSize = printer.config["supportGritSize"] * scale; + var supportAccaptanceMargin = printer.config["supportAccaptanceMargin"] * scale; + var supportMargin = printer.config["supportMargin"] * scale; + var plateSize = printer.config["supportPlateSize"] * scale; + var supportDistanceY = printer.config["supportDistanceY"]; + var brimOffset = printer.config["brimOffset"] * scale; var supportDistanceLayers = Math.ceil(supportDistanceY / layerHeight); var bottomSkinCount = Math.ceil(bottomThickness/layerHeight); @@ -305,7 +301,7 @@ D3D.Slicer.prototype.slicesToData = function (slices, printer) { top: this.geometry.boundingBox.min.x * scale, right: this.geometry.boundingBox.max.z * scale, bottom: this.geometry.boundingBox.max.x * scale - }, fillSize, true, true); + }, fillGritSize, true, true); console.log("generating outer lines and inner lines"); for (var layer = 0; layer < slices.length; layer ++) { @@ -487,7 +483,7 @@ D3D.Slicer.prototype.dataToGCode = function (data, printer) { var gcode = new D3D.GCode().setSettings(printer); - function sliceToGCode (path, retract, unRetract) { + function sliceToGCode (path, retract, unRetract, type) { for (var i = 0; i < path.length; i ++) { var shape = path[i]; @@ -497,14 +493,14 @@ D3D.Slicer.prototype.dataToGCode = function (data, printer) { var point = shape[j % shape.length]; if (j === 0) { - gcode.moveTo(false, point.X, point.Y, layer); + gcode.moveTo(point.X, point.Y, layer); if (unRetract) { gcode.unRetract(); } } else { - gcode.moveTo(true, point.X, point.Y, layer); + gcode.lineTo(point.X, point.Y, layer, type); } } } @@ -523,22 +519,22 @@ D3D.Slicer.prototype.dataToGCode = function (data, printer) { } if (slice.brim !== undefined) { - sliceToGCode(slice.brim, true, true); + sliceToGCode(slice.brim, true, true, "brim"); } for (var i = 0; i < slice.parts.length; i ++) { var part = slice.parts[i]; - sliceToGCode(part.outerLine, false, true); + sliceToGCode(part.outerLine, false, true, "outerLine"); for (var j = 0; j < part.innerLines.length; j ++) { var innerLine = part.innerLines[j]; - sliceToGCode(innerLine, false, false); + sliceToGCode(innerLine, false, false, "innerLine"); } - sliceToGCode(part.fill, true, false); + sliceToGCode(part.fill, true, false, "fill"); } if (slice.support !== undefined) { - sliceToGCode(slice.support, true, true); + sliceToGCode(slice.support, true, true, "support"); } this.progress.gcodeLayer = layer; @@ -550,8 +546,8 @@ D3D.Slicer.prototype.dataToGCode = function (data, printer) { D3D.Slicer.prototype.getGCode = function (printer) { "use strict"; - var layerHeight = printer.config["printer.layerHeight"]; - var dimensionsZ = printer.config["printer.dimensions.z"]; + var layerHeight = printer.config["layerHeight"]; + var dimensionsZ = printer.config["dimensionsZ"]; this.progress.totalLayers = Math.floor(Math.min(this.geometry.boundingBox.max.y, dimensionsZ) / layerHeight); this.progress.sliceLayer = 0; diff --git a/webworker_test.html b/webworker_test.html index 7dc8ffa..5368d14 100644 --- a/webworker_test.html +++ b/webworker_test.html @@ -91,7 +91,7 @@ function init () { }; var loader = new THREE.STLLoader(); - loader.load('models/pokemon/pikachu.stl', function (geometry) { + loader.load('models/support_test.stl', function (geometry) { //var geometry = new THREE.TorusGeometry(20, 10, 30, 30).clone(); var material = new THREE.MeshPhongMaterial({color: 0x00ff00, wireframe: false}); @@ -99,7 +99,7 @@ function init () { var mesh = new THREE.Mesh(geometry, material); mesh.rotation.x = -Math.PI/2; - mesh.scale.x = mesh.scale.y = mesh.scale.z = 0.5; + mesh.scale.x = mesh.scale.y = mesh.scale.z = 1; mesh.position.y = -0.1; mesh.position.x = 60; mesh.position.z = 60;