diff --git a/library/clipper.js b/library/clipper.js index b0420e9..cccf9ac 100755 --- a/library/clipper.js +++ b/library/clipper.js @@ -6596,7 +6596,7 @@ } catch (err) { - console.warn(err.message); + //console.warn(err.message); } }; // --------------------------------- diff --git a/slice_test.html b/slice_test.html index 8f66ec4..4b7ff2b 100644 --- a/slice_test.html +++ b/slice_test.html @@ -56,7 +56,7 @@ var printerConfig = { "printer.useSubLayers": true, //wat is dit? "printer.wallThickness": 0.4, //nozzle - "printer.layerHeight": 0.3, + "printer.layerHeight": 0.2, //variabele toevoegen; //-snelheid, retraction etc voor verschillende types (outerlayer, innerlayer, fill) @@ -77,18 +77,18 @@ var renderer = new THREE.WebGLRenderer({canvas: document.getElementById("3d-prev renderer.setClearColor(0xffffff, 1); var camera = new THREE.PerspectiveCamera(75, renderer.domElement.width/renderer.domElement.height, 1, 10000); +scene.add(camera); var light = new THREE.AmbientLight(0x404040); -scene.add(light ); +scene.add(light); -var directionalLight = new THREE.DirectionalLight(0xffffff, 0.5); -directionalLight.position.set(0, 1, 1); -scene.add(directionalLight); +var directionalLight = new THREE.PointLight(0xffffff, 0.5); +camera.add(directionalLight); applyMouseControls(renderer, camera, new THREE.Vector3(100, 0, 100), 1000); var loader = new THREE.STLLoader(); -loader.load("models/stanford_bunny.stl", function (geometry) { +loader.load("models/pikachu.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); @@ -134,7 +134,7 @@ loader.load("models/stanford_bunny.stl", function (geometry) { var canvas = document.getElementById("canvas"); var context = canvas.getContext("2d"); - var img = slicer.drawPaths(printer, 0, 1); + var img = slicer.drawPaths(printer, 5, 6); context.drawImage(img, 0, 0); gcode = slicer.getGcode(printer); diff --git a/src/slicer.js b/src/slicer.js index d82ee9c..af9a758 100644 --- a/src/slicer.js +++ b/src/slicer.js @@ -124,6 +124,8 @@ D3D.Slicer.prototype.slice = function (height, step) { 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-1; layer ++) { //for (var layer = 0; layer < layersIntersections.length; layer ++) { var layerIntersections = layersIntersections[layer]; @@ -257,10 +259,10 @@ D3D.Slicer.prototype.slicesToData = function (slices, printer) { var data = []; var lowFillTemplate = this.getFillTemplate({ - left: 0, - top: 0, - right: dimensionsZ, - bottom: dimensionsZ + left: this.geometry.boundingBox.min.z * scale, + top: this.geometry.boundingBox.min.x * scale, + right: this.geometry.boundingBox.max.z * scale, + bottom: this.geometry.boundingBox.max.x * scale }, fillSize, true, true); for (var layer = 0; layer < slices.length; layer ++) { @@ -283,7 +285,7 @@ D3D.Slicer.prototype.slicesToData = function (slices, printer) { upSkin.join(downLayer[i]); } } - var surroundingLayer = upSkin.intersect(downSkin).clone().scaleUp(scale); + var surroundingLayer = upSkin.intersect(downSkin).scaleUp(scale); var sliceData = []; for (var i = 0; i < slice.length; i ++) { @@ -514,22 +516,16 @@ D3D.Slicer.prototype.getGcode = function (printer) { var start = new Date().getTime(); var slices = this.slice(dimensionsZ, layerHeight); var end = new Date().getTime(); - console.log("Slicing: " + (end - start) + "ms"); - //still error in first layer, so remove first layer - //see https://github.com/Doodle3D/Doodle3D-Slicer/issues/1 - var start = new Date().getTime(); var data = this.slicesToData(slices, printer); var end = new Date().getTime(); - console.log("Data: " + (end - start) + "ms"); var start = new Date().getTime(); var gcode = this.dataToGcode(data, printer); var end = new Date().getTime(); - console.log("Gcode: " + (end - start) + "ms"); return gcode; diff --git a/src/utils.js b/src/utils.js index 396fcc7..a67aac1 100644 --- a/src/utils.js +++ b/src/utils.js @@ -71,11 +71,11 @@ function getAPI (url, callback) { function downloadFile (file, data) { "use strict"; - - $(document.createElement("a")).attr({ - download: file, - href: "data:text/plain," + data - })[0].click(); + + var button = document.createElement("a"); + button.download = file; + button.href = "data:text/plain," + data; + button.click(); } Array.prototype.clone = function () {