mirror of
https://github.com/Doodle3D/Doodle3D-Slicer.git
synced 2024-12-22 19:13:50 +01:00
improved variable names
This commit is contained in:
parent
f24e96c5ac
commit
f2327d3a21
@ -10,6 +10,7 @@
|
||||
"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)",
|
||||
"printer.type": "ultimaker"
|
||||
}
|
||||
|
@ -1,18 +1,18 @@
|
||||
{
|
||||
"printer.retraction.speed": 50,
|
||||
"printer.retraction.minDistance": 5,
|
||||
"printer.retraction.amount": 3,
|
||||
"printer.retraction.enabled": true,
|
||||
"printer.speed": 50,
|
||||
"printer.wallThickness": 0.4,
|
||||
"printer.layerHeight": 0.3,
|
||||
"printer.normalFlowRate": 1.0,
|
||||
"printer.bottomFlowRate": 2.0,
|
||||
"printer.bottomLayerSpeed": 35,
|
||||
"printer.bottomThickness": 0.4,
|
||||
"printer.topThickness": 0.8,
|
||||
"printer.shellThickness": 0.4,
|
||||
"printer.temperature": 230,
|
||||
"printer.travelSpeed": 200,
|
||||
"printer.fillSize": 5,
|
||||
"printer.firstLayerSlow": true,
|
||||
"printer.bottomLayerSpeed": 35,
|
||||
"printer.bottomFlowRate": 1.0
|
||||
"printer.layerHeight": 0.2,
|
||||
"printer.retraction.amount": 3,
|
||||
"printer.retraction.enabled": false,
|
||||
"printer.retraction.speed": 50,
|
||||
"printer.retraction.minDistance": 5,
|
||||
"printer.shellThickness": 0.4,
|
||||
"printer.speed": 50,
|
||||
"printer.temperature": 230,
|
||||
"printer.topThickness": 0.8,
|
||||
"printer.travelSpeed": 200
|
||||
}
|
@ -26,22 +26,23 @@ canvas {border: 1px solid black;}
|
||||
<canvas id="canvas" width="400" height="400"></canvas>
|
||||
|
||||
<script>
|
||||
var USER_SETTINGS, PRINTER_SETTINGS;
|
||||
|
||||
var USER_SETTINGS, PRINTER_SETTINGS, doodleBox, gcode;
|
||||
|
||||
function init () {
|
||||
"use strict";
|
||||
var scene = createScene();
|
||||
|
||||
var localIp = location.hash.substring(1);
|
||||
var doodleBox = new D3D.Box(localIp);
|
||||
doodleBox = new D3D.Box(localIp);
|
||||
|
||||
var printer = new D3D.Printer(USER_SETTINGS, PRINTER_SETTINGS);
|
||||
var printer = new D3D.Printer(USER_SETTINGS, PRINTER_SETTINGS["ultimaker"]);
|
||||
|
||||
var loader = new THREE.STLLoader();
|
||||
loader.load("models/pikachu.stl", function (geometry) {
|
||||
loader.load("models/diamond.stl", function (geometry) {
|
||||
//var geometry = new THREE.BoxGeometry(10, 10, 10, 1, 1, 1);
|
||||
//var geometry = new THREE.SphereGeometry(10, 10, 10);
|
||||
//var geometry = new THREE.TorusGeometry(20, 10, 30, 30);
|
||||
var geometry = new THREE.TorusGeometry(20, 10, 30, 30);
|
||||
/*
|
||||
var geometry = (function () {
|
||||
"use strict";
|
||||
@ -67,26 +68,27 @@ function init () {
|
||||
return geometry;
|
||||
})();
|
||||
*/
|
||||
var material = new THREE.MeshPhongMaterial({color: 0x00ff00});
|
||||
var material = new THREE.MeshPhongMaterial({color: 0x00ff00, wireframe: true});
|
||||
var mesh = new THREE.Mesh(geometry, material);
|
||||
|
||||
mesh.rotation.x = -Math.PI/2;
|
||||
//mesh.rotation.z = Math.PI;
|
||||
mesh.scale.x = mesh.scale.y = mesh.scale.z = 1;
|
||||
mesh.position.x = 100;
|
||||
mesh.position.z = 100;
|
||||
|
||||
//scene.add(mesh);
|
||||
|
||||
var slicer = new D3D.Slicer().setMesh(mesh);
|
||||
|
||||
var mesh = new THREE.Mesh(slicer.geometry, material);
|
||||
scene.add(mesh);
|
||||
|
||||
/*(var slicer = new D3D.Slicer().setMesh(mesh);
|
||||
|
||||
|
||||
var canvas = document.getElementById("canvas");
|
||||
var context = canvas.getContext("2d");
|
||||
|
||||
var img = slicer.drawPaths(printer, 0, 1);
|
||||
context.drawImage(img, 0, 0);
|
||||
|
||||
gcode = slicer.getGcode(printer);*/
|
||||
gcode = slicer.getGcode(printer);
|
||||
});
|
||||
}
|
||||
|
||||
@ -107,13 +109,6 @@ function createScene () {
|
||||
|
||||
applyMouseControls(renderer, camera, new THREE.Vector3(100, 0, 100), 1000);
|
||||
|
||||
(function animate () {
|
||||
"use strict";
|
||||
|
||||
requestAnimationFrame(animate);
|
||||
renderer.render(scene, camera);
|
||||
})();
|
||||
|
||||
function applyMouseControls (renderer, camera, center, maxDistance) {
|
||||
var distance = 20;
|
||||
var rotX = 0;
|
||||
@ -156,6 +151,11 @@ function createScene () {
|
||||
updateCamera();
|
||||
}
|
||||
|
||||
(function animate () {
|
||||
requestAnimationFrame(animate);
|
||||
renderer.render(scene, camera);
|
||||
})();
|
||||
|
||||
return scene;
|
||||
}
|
||||
|
||||
@ -165,7 +165,7 @@ function createScene () {
|
||||
function loaded () {
|
||||
loadedItems ++;
|
||||
if (loadedItems === 2) {
|
||||
init();
|
||||
//init();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
* Path
|
||||
*
|
||||
* Abstraction layer for annoying clipper js
|
||||
* ! inherrits from Array !
|
||||
*
|
||||
******************************************************/
|
||||
|
||||
|
@ -101,23 +101,23 @@ D3D.Slicer.prototype.createLines = function () {
|
||||
}
|
||||
}
|
||||
};
|
||||
D3D.Slicer.prototype.slice = function (height, step) {
|
||||
D3D.Slicer.prototype.slice = function (layerHeight, height) {
|
||||
"use strict";
|
||||
|
||||
var layersIntersections = [];
|
||||
|
||||
for (var i = 0; i < this.lines.length; i ++) {
|
||||
var line = this.lines[i];
|
||||
for (var lineIndex = 0; lineIndex < this.lines.length; lineIndex ++) {
|
||||
var line = this.lines[lineIndex];
|
||||
|
||||
var min = Math.ceil(Math.min(line.line.start.y, line.line.end.y) / step);
|
||||
var max = Math.floor(Math.max(line.line.start.y, line.line.end.y) / step);
|
||||
var min = Math.ceil(Math.min(line.line.start.y, line.line.end.y) / layerHeight);
|
||||
var max = Math.floor(Math.max(line.line.start.y, line.line.end.y) / layerHeight);
|
||||
|
||||
for (var layerIndex = min; layerIndex <= max; layerIndex ++) {
|
||||
if (layerIndex >= 0) {
|
||||
if (layersIntersections[layerIndex] === undefined) {
|
||||
layersIntersections[layerIndex] = [];
|
||||
}
|
||||
layersIntersections[layerIndex].push(i);
|
||||
layersIntersections[layerIndex].push(lineIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -129,7 +129,7 @@ D3D.Slicer.prototype.slice = function (height, step) {
|
||||
for (var layer = 1; layer < layersIntersections.length-1; layer ++) {
|
||||
//for (var layer = 0; layer < layersIntersections.length; layer ++) {
|
||||
var layerIntersections = layersIntersections[layer];
|
||||
var y = layer*step;
|
||||
var y = layer*layerHeight;
|
||||
|
||||
var intersections = [];
|
||||
for (var i = 0; i < layerIntersections.length; i ++) {
|
||||
@ -248,7 +248,7 @@ D3D.Slicer.prototype.slicesToData = function (slices, printer) {
|
||||
|
||||
var layerHeight = printer.config["printer.layerHeight"] * scale;
|
||||
var dimensionsZ = printer.config["printer.dimensions.z"] * scale;
|
||||
var wallThickness = printer.config["printer.wallThickness"] * scale / 2;
|
||||
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;
|
||||
@ -257,6 +257,7 @@ D3D.Slicer.prototype.slicesToData = function (slices, printer) {
|
||||
|
||||
var bottomSkinCount = Math.ceil(bottomThickness/layerHeight);
|
||||
var topSkinCount = Math.ceil(topThickness/layerHeight);
|
||||
var nozzleRadius = nozzleDiameter / 2;
|
||||
|
||||
var start = new THREE.Vector2(0, 0);
|
||||
|
||||
@ -296,21 +297,19 @@ D3D.Slicer.prototype.slicesToData = function (slices, printer) {
|
||||
var part = slice[i];
|
||||
|
||||
//var outerLayer = part.clone();
|
||||
var outerLayer = part.clone().scaleUp(scale).offset(-wallThickness/2);
|
||||
var outerLayer = part.clone().scaleUp(scale).offset(-nozzleRadius);
|
||||
|
||||
if (outerLayer.length > 0) {
|
||||
var insets = new D3D.Paths([], true);
|
||||
for (var offset = wallThickness; offset <= shellThickness; offset += wallThickness) {
|
||||
for (var offset = nozzleDiameter; offset <= shellThickness; offset += nozzleDiameter) {
|
||||
var inset = outerLayer.offset(-offset);
|
||||
|
||||
insets.join(inset);
|
||||
}
|
||||
|
||||
var fillArea = (inset || outerLayer).offset(-wallThickness/2);
|
||||
var fillArea = (inset || outerLayer).offset(-nozzleRadius);
|
||||
//var fillArea = (inset || outerLayer).clone();
|
||||
|
||||
var highFillArea = fillArea.difference(surroundingLayer);
|
||||
|
||||
var lowFillArea = fillArea.difference(highFillArea);
|
||||
|
||||
var fill = new D3D.Paths([], false);
|
||||
@ -322,10 +321,10 @@ D3D.Slicer.prototype.slicesToData = function (slices, printer) {
|
||||
if (highFillArea.length > 0) {
|
||||
var bounds = highFillArea.bounds();
|
||||
var even = (layer % 2 === 0);
|
||||
var highFillTemplate = this.getFillTemplate(bounds, wallThickness, even, !even);
|
||||
var highFillTemplate = this.getFillTemplate(bounds, nozzleDiameter, even, !even);
|
||||
fill.join(highFillTemplate.intersect(highFillArea));
|
||||
}
|
||||
|
||||
|
||||
outerLayer = outerLayer.optimizePath(start);
|
||||
if (insets.length > 0) {
|
||||
insets = insets.optimizePath(outerLayer.lastPoint());
|
||||
@ -344,7 +343,7 @@ D3D.Slicer.prototype.slicesToData = function (slices, printer) {
|
||||
else {
|
||||
start = outerLayer.lastPoint();
|
||||
}
|
||||
|
||||
|
||||
layerData.push({
|
||||
outerLayer: outerLayer.scaleDown(scale),
|
||||
fill: fill.scaleDown(scale),
|
||||
@ -383,9 +382,10 @@ D3D.Slicer.prototype.dataToGcode = function (data, printer) {
|
||||
var bottomSpeed = printer.config["printer.bottomLayerSpeed"];
|
||||
var firstLayerSlow = printer.config["printer.firstLayerSlow"];
|
||||
var bottomFlowRate = printer.config["printer.bottomFlowRate"];
|
||||
var normalFlowRate = printer.config["printer.normalFlowRate"];
|
||||
var travelSpeed = printer.config["printer.travelSpeed"];
|
||||
var filamentThickness = printer.config["printer.filamentThickness"];
|
||||
var wallThickness = printer.config["printer.wallThickness"];
|
||||
var nozzleDiameter = printer.config["printer.nozzleDiameter"];
|
||||
var enableTraveling = printer.config["printer.enableTraveling"];
|
||||
var retractionEnabled = printer.config["printer.retraction.enabled"];
|
||||
var retractionSpeed = printer.config["printer.retraction.speed"];
|
||||
@ -435,7 +435,7 @@ D3D.Slicer.prototype.dataToGcode = function (data, printer) {
|
||||
var b = new THREE.Vector2(previousPoint.X, previousPoint.Y);
|
||||
var lineLength = a.distanceTo(b);
|
||||
|
||||
extruder += lineLength * wallThickness * layerHeight / filamentSurfaceArea * flowRate;
|
||||
extruder += lineLength * nozzleDiameter * layerHeight / filamentSurfaceArea * flowRate;
|
||||
|
||||
gcode.push([
|
||||
"G1",
|
||||
@ -462,11 +462,11 @@ D3D.Slicer.prototype.dataToGcode = function (data, printer) {
|
||||
for (var layer = 0; layer < data.length; layer ++) {
|
||||
var slice = data[layer];
|
||||
|
||||
//turn on fan on layer 2
|
||||
if (layer === 2) {
|
||||
//turn on fan on layer 1
|
||||
if (layer === 1) {
|
||||
gcode.push("M106");
|
||||
speed = (normalSpeed*60).toFixed(3);
|
||||
flowRate = 1;
|
||||
flowRate = normalFlowRate;
|
||||
}
|
||||
|
||||
var z = ((layer + 1) * layerHeight).toFixed(3);
|
||||
@ -491,7 +491,7 @@ D3D.Slicer.prototype.drawPaths = function (printer, min, max) {
|
||||
var layerHeight = printer.config["printer.layerHeight"];
|
||||
var dimensionsZ = printer.config["printer.dimensions.z"];
|
||||
|
||||
var slices = this.slice(dimensionsZ, layerHeight);
|
||||
var slices = this.slice(layerHeight, dimensionsZ);
|
||||
|
||||
var data = this.slicesToData(slices, printer);
|
||||
|
||||
@ -521,18 +521,18 @@ D3D.Slicer.prototype.getGcode = function (printer) {
|
||||
var dimensionsZ = printer.config["printer.dimensions.z"];
|
||||
|
||||
var start = new Date().getTime();
|
||||
var slices = this.slice(dimensionsZ, layerHeight);
|
||||
var slices = this.slice(layerHeight, dimensionsZ);
|
||||
var end = new Date().getTime();
|
||||
console.log("Slicing: " + (end - start) + "ms");
|
||||
|
||||
var start = new Date().getTime();
|
||||
start = new Date().getTime();
|
||||
var data = this.slicesToData(slices, printer);
|
||||
var end = new Date().getTime();
|
||||
end = new Date().getTime();
|
||||
console.log("Data: " + (end - start) + "ms");
|
||||
|
||||
var start = new Date().getTime();
|
||||
start = new Date().getTime();
|
||||
var gcode = this.dataToGcode(data, printer);
|
||||
var end = new Date().getTime();
|
||||
end = new Date().getTime();
|
||||
console.log("Gcode: " + (end - start) + "ms");
|
||||
|
||||
return gcode;
|
||||
|
Loading…
Reference in New Issue
Block a user