mirror of
https://github.com/Doodle3D/Doodle3D-Slicer.git
synced 2024-12-23 03:23:48 +01:00
fixed look up function
This commit is contained in:
parent
d33f0d336c
commit
d7dfdb62d9
@ -16,7 +16,7 @@ doodleBox.onload = function () {
|
||||
var geometry = new THREE.TorusGeometry(40, 20, 10, 10);
|
||||
|
||||
var slicer = new D3D.Slicer().setGeometry(geometry);
|
||||
var gcode = slicer.getGcode(doodlBox.printer);
|
||||
var gcode = slicer.getGcode(doodleBox.printer);
|
||||
|
||||
doodleBox.print(gcode);
|
||||
};
|
||||
|
@ -25,15 +25,17 @@ canvas {border: 1px solid black;}
|
||||
<canvas id="canvas" width="400" height="400"></canvas>
|
||||
|
||||
<script>
|
||||
//nieuwe config
|
||||
//geimplimenteerd worden in de doodlebox?
|
||||
var printerConfig = {
|
||||
"printer.baudrate": "115200",
|
||||
"printer.baudrate": "115200", //wat is dit?
|
||||
"printer.bed.temperature": 70,
|
||||
"printer.bottomFlowRate": 1.0,
|
||||
"printer.bottomLayerSpeed": 35,
|
||||
"printer.dimensions.x": 200,
|
||||
"printer.dimensions.y": 200,
|
||||
"printer.dimensions.z": 200,
|
||||
"printer.enableTraveling": true,
|
||||
"printer.enableTraveling": true, //wat is dit?
|
||||
"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)",
|
||||
"printer.filamentThickness": 2.89,
|
||||
"printer.firstLayerSlow": true,
|
||||
@ -52,8 +54,15 @@ var printerConfig = {
|
||||
"printer.temperature": 230,
|
||||
"printer.travelSpeed": 200,
|
||||
"printer.type": "ultimaker",
|
||||
"printer.useSubLayers": true,
|
||||
"printer.wallThickness": 0.5
|
||||
"printer.useSubLayers": true, //wat is dit?
|
||||
"printer.wallThickness": 0.4,
|
||||
|
||||
//variabele toevoegen;
|
||||
//overleg met rick;
|
||||
//-snelheid, retraction etc voor verschillende types (outerlayer, innerlayer, fill)
|
||||
"printer.shellThickness": 0.8,
|
||||
"printer.fillSize": 5, //dit is het raster aan de binnen kant van de geometry
|
||||
"printer.brimOffset": 5
|
||||
};
|
||||
var printer = new D3D.Printer(printerConfig);
|
||||
|
||||
@ -94,8 +103,8 @@ var geometry = (function () {
|
||||
})();
|
||||
|
||||
var material = new THREE.MeshLambertMaterial({color: 0x000000, wireframe: true});
|
||||
//var geometry = new THREE.TorusGeometry(40, 20, 10, 10);
|
||||
var geometry = new THREE.BoxGeometry(20, 10, 20, 1, 1, 1);
|
||||
var geometry = new THREE.TorusGeometry(20, 10, 10, 10);
|
||||
//var geometry = new THREE.BoxGeometry(20, 5, 20, 1, 1, 1);
|
||||
//var geometry = new THREE.SphereGeometry(10, 10, 10);
|
||||
var mesh = new THREE.Mesh(geometry, material);
|
||||
scene.add(mesh);
|
||||
@ -110,7 +119,8 @@ var slicer = new D3D.Slicer().setGeometry(geometry);
|
||||
|
||||
var gcode = slicer.getGcode(printer);
|
||||
|
||||
/*var canvas = document.getElementById("canvas");
|
||||
/*
|
||||
var canvas = document.getElementById("canvas");
|
||||
var context = canvas.getContext("2d");
|
||||
|
||||
function drawPolygons (paths, color) {
|
||||
@ -123,26 +133,33 @@ function drawPolygons (paths, color) {
|
||||
for (var i = 0; i < paths.length; i ++) {
|
||||
var path = paths[i];
|
||||
|
||||
context.moveTo((path[0].X- 100) * 8.0 + 200, (path[0].Y- 100) * 8.0 + 200);
|
||||
context.moveTo((path[0].X- 100) * 6.0 + 200, (path[0].Y- 100) * 6.0 + 200);
|
||||
|
||||
for (var j = 0; j < path.length; j ++) {
|
||||
var point = path[j];
|
||||
context.lineTo((point.X- 100) * 8.0 + 200, (point.Y- 100) * 8.0 + 200);
|
||||
context.lineTo((point.X- 100) * 6.0 + 200, (point.Y- 100) * 6.0 + 200);
|
||||
}
|
||||
context.closePath();
|
||||
}
|
||||
context.stroke();
|
||||
}
|
||||
|
||||
for (var layer = 0; layer < gcode.length; layer ++) {
|
||||
var layer = 0;
|
||||
setInterval(function () {
|
||||
context.clearRect(0, 0, 400, 400);
|
||||
//for (var layer = 0; layer < gcode.length; layer ++) {
|
||||
//var layer = 31;
|
||||
var slice = gcode[layer];
|
||||
var slice = gcode[layer % gcode.length];
|
||||
|
||||
drawPolygons(slice.outerLayer, "red");
|
||||
drawPolygons(slice.innerLayer, "green");
|
||||
//drawPolygons(slice.outerLayer, "red");
|
||||
//drawPolygons(slice.innerLayer, "green");
|
||||
drawPolygons(slice.fill, "blue");
|
||||
}*/
|
||||
|
||||
context.fillText("layer: " + layer, 10, 10);
|
||||
//}
|
||||
layer ++;
|
||||
}, 100);
|
||||
*/
|
||||
|
||||
(function animate () {
|
||||
"use strict";
|
||||
|
@ -199,26 +199,24 @@ D3D.Slicer.prototype.getFillTemplate = function (dimension, size, even, uneven)
|
||||
D3D.Slicer.prototype.slicesToData = function (slices, printer) {
|
||||
"use strict";
|
||||
|
||||
var data = [];
|
||||
|
||||
//scale because of clipper crap
|
||||
var scale = 100;
|
||||
|
||||
var layerHeight = printer.config["printer.layerHeight"] * scale;
|
||||
var dimensionsZ = printer.config["printer.dimensions.z"] * scale;
|
||||
//variables should come from config
|
||||
//aan rick voorleggen
|
||||
var nozzleSize = 0.4 * scale;
|
||||
var shellThickness = 0.8 * scale;
|
||||
var fillSize = 5 * scale;
|
||||
var brimOffset = 5 * scale;
|
||||
var wallThickness = printer.config["printer.wallThickness"] * scale;
|
||||
var shellThickness = printer.config["printer.shellThickness"] * scale;
|
||||
var fillSize = printer.config["printer.fillSize"] * scale;
|
||||
var brimOffset = printer.config["printer.brimOffset"] * scale;
|
||||
|
||||
var data = [];
|
||||
|
||||
var lowFillTemplate = this.getFillTemplate(dimensionsZ, fillSize, true, true);
|
||||
|
||||
|
||||
for (var layer = 0; layer < slices.length; layer ++) {
|
||||
var slice = slices[layer];
|
||||
var highFillTemplate = this.getFillTemplate(dimensionsZ, nozzleSize, (layer % 2 === 0), (layer % 2 === 1));
|
||||
|
||||
var highFillTemplate = this.getFillTemplate(dimensionsZ, wallThickness, (layer % 2 === 0), (layer % 2 === 1));
|
||||
|
||||
//var outerLayer = ClipperLib.JS.Clean(slice, 1.0);
|
||||
var outerLayer = slice.clone();
|
||||
@ -226,17 +224,17 @@ D3D.Slicer.prototype.slicesToData = function (slices, printer) {
|
||||
|
||||
var innerLayer = [];
|
||||
|
||||
for (var i = nozzleSize; i < shellThickness; i += nozzleSize) {
|
||||
for (var i = wallThickness; i < shellThickness; i += wallThickness) {
|
||||
var inset = this.getInset(outerLayer, i);
|
||||
|
||||
innerLayer = innerLayer.concat(inset);
|
||||
}
|
||||
|
||||
var fillArea = this.getInset((inset || outerLayer), nozzleSize);
|
||||
var fillArea = this.getInset((inset || outerLayer), wallThickness);
|
||||
|
||||
var highFill;
|
||||
|
||||
var fillAbove;
|
||||
var fillAbove = undefined;
|
||||
for (var i = 1; i < shellThickness/layerHeight; i ++) {
|
||||
var newLayer = ClipperLib.JS.Clone(slices[layer + i]);
|
||||
ClipperLib.JS.ScaleUpPaths(newLayer, scale);
|
||||
@ -247,21 +245,16 @@ D3D.Slicer.prototype.slicesToData = function (slices, printer) {
|
||||
break;
|
||||
}
|
||||
else if (fillAbove === undefined) {
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
}
|
||||
|
||||
if (fillAbove === undefined) {
|
||||
fillAbove = newLayer;
|
||||
}
|
||||
else {
|
||||
// var c = new ClipperLib.Clipper();
|
||||
// var solution = new ClipperLib.Paths();
|
||||
// c.AddPaths(fillArea, ClipperLib.PolyType.ptSubject, true);
|
||||
// c.AddPaths(fillAbove, ClipperLib.PolyType.ptClip, true);
|
||||
// c.Execute(ClipperLib.ClipType.ctDifference, solution);
|
||||
var c = new ClipperLib.Clipper();
|
||||
var solution = new ClipperLib.Paths();
|
||||
c.AddPaths(fillArea, ClipperLib.PolyType.ptSubject, true);
|
||||
c.AddPaths(fillAbove, ClipperLib.PolyType.ptClip, true);
|
||||
c.Execute(ClipperLib.ClipType.ctIntersection, solution);
|
||||
|
||||
fillAbove = solution;
|
||||
}
|
||||
}
|
||||
//kijkt alleen nog naar boven
|
||||
|
Loading…
Reference in New Issue
Block a user