mirror of
https://github.com/Doodle3D/Doodle3D-Slicer.git
synced 2024-11-04 21:53:25 +01:00
move THREE normal function to utils
This commit is contained in:
parent
d9c11112e4
commit
3141440c42
@ -1578,18 +1578,6 @@ THREE.Vector2.prototype = {
|
|||||||
|
|
||||||
return new THREE.Vector2( this.x, this.y );
|
return new THREE.Vector2( this.x, this.y );
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
normal : function () {
|
|
||||||
|
|
||||||
var x = this.y;
|
|
||||||
var y = -this.x;
|
|
||||||
|
|
||||||
this.x = x;
|
|
||||||
this.y = y;
|
|
||||||
|
|
||||||
return this;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
"dimensionsX": 120,
|
"dimensionsX": 120,
|
||||||
"dimensionsY": 120,
|
"dimensionsY": 120,
|
||||||
"dimensionsZ": 115,
|
"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",
|
"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 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,
|
"filamentThickness": 2.85,
|
||||||
"heatedBed": false,
|
"heatedBed": false,
|
||||||
"heatupBedTemperature": 70,
|
"heatupBedTemperature": 70,
|
||||||
|
@ -82,6 +82,7 @@ D3D.Box.prototype.init = function () {
|
|||||||
};
|
};
|
||||||
D3D.Box.prototype._updateLoop = function () {
|
D3D.Box.prototype._updateLoop = function () {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
console.log("loop", this.status["buffered_lines"]);
|
||||||
var scope = this;
|
var scope = this;
|
||||||
//TODO
|
//TODO
|
||||||
//Code is zo op gezet dat maar api call te gelijk is
|
//Code is zo op gezet dat maar api call te gelijk is
|
||||||
|
@ -66,7 +66,7 @@ D3D.Paths.prototype.offset = function (offset) {
|
|||||||
|
|
||||||
var solution = new ClipperLib.Paths();
|
var solution = new ClipperLib.Paths();
|
||||||
var co = new ClipperLib.ClipperOffset(1, 1);
|
var co = new ClipperLib.ClipperOffset(1, 1);
|
||||||
co.AddPaths(this, ClipperLib.JoinType.jtMiter, ClipperLib.EndType.etClosedPolygon);
|
co.AddPaths(this, ClipperLib.JoinType.jtSquare, ClipperLib.EndType.etClosedPolygon);
|
||||||
co.Execute(solution, offset);
|
co.Execute(solution, offset);
|
||||||
|
|
||||||
return new D3D.Paths(solution);
|
return new D3D.Paths(solution);
|
||||||
|
@ -8,12 +8,13 @@ D3D.Slicer = function () {
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
this.progress = {
|
this.progress = {
|
||||||
totalFaces: 0,
|
createdLines: false,
|
||||||
currentFace: 0,
|
sliced: false,
|
||||||
totalLayers: 0,
|
generatedInnerLines: false,
|
||||||
sliceLayer: 0,
|
generatedInfills: false,
|
||||||
dataLayer: 0,
|
generatedSupport: false,
|
||||||
gcodeLayer: 0
|
optimizedPaths: false,
|
||||||
|
generatedGCode: false
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
D3D.Slicer.prototype.setMesh = function (geometry, matrix) {
|
D3D.Slicer.prototype.setMesh = function (geometry, matrix) {
|
||||||
@ -76,24 +77,28 @@ D3D.Slicer.prototype.getGCode = function (printer) {
|
|||||||
};
|
};
|
||||||
D3D.Slicer.prototype._updateProgress = function () {
|
D3D.Slicer.prototype._updateProgress = function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var faces = this.progress.currentFace / (this.progress.totalFaces - 1);
|
|
||||||
var slice = this.progress.sliceLayer / (this.progress.totalLayers - 1);
|
|
||||||
var data = this.progress.dataLayer / (this.progress.totalLayers - 2);
|
|
||||||
var gcode = this.progress.gcodeLayer / (this.progress.totalLayers - 2);
|
|
||||||
|
|
||||||
this.progress.procent = (faces + slice + data + gcode) / 4;
|
var progress = {};
|
||||||
|
|
||||||
|
var procent = 0;
|
||||||
|
var length = 0;
|
||||||
|
for (var i in this.progress) {
|
||||||
|
progress[i] = this.progress[i];
|
||||||
|
procent += this.progress[i] ? 1 : 0;
|
||||||
|
length ++;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(procent, length);
|
||||||
|
progress.procent = procent / length;
|
||||||
|
|
||||||
if (this.onProgress !== undefined) {
|
if (this.onProgress !== undefined) {
|
||||||
|
|
||||||
this.onProgress(this.progress);
|
this.onProgress(progress);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
D3D.Slicer.prototype._createLines = function () {
|
D3D.Slicer.prototype._createLines = function () {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
this.progress.totalFaces = this.geometry.faces.length;
|
|
||||||
|
|
||||||
this._lines = [];
|
this._lines = [];
|
||||||
var lineLookup = {};
|
var lineLookup = {};
|
||||||
|
|
||||||
@ -136,10 +141,10 @@ D3D.Slicer.prototype._createLines = function () {
|
|||||||
this._lines[b].normals.push(normal);
|
this._lines[b].normals.push(normal);
|
||||||
this._lines[c].normals.push(normal);
|
this._lines[c].normals.push(normal);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.progress.currentFace = i;
|
|
||||||
this._updateProgress();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.progress.createdLines = true;
|
||||||
|
this._updateProgress();
|
||||||
};
|
};
|
||||||
D3D.Slicer.prototype._slice = function (layerHeight, height) {
|
D3D.Slicer.prototype._slice = function (layerHeight, height) {
|
||||||
"use strict";
|
"use strict";
|
||||||
@ -287,13 +292,13 @@ D3D.Slicer.prototype._slice = function (layerHeight, height) {
|
|||||||
pathData: slice.parts
|
pathData: slice.parts
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
this.progress.sliceLayer = layer;
|
|
||||||
this._updateProgress();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(JSON.stringify(testData));
|
//console.log(JSON.stringify(testData));
|
||||||
|
|
||||||
|
this.progress.sliced = true;
|
||||||
|
this._updateProgress();
|
||||||
|
|
||||||
return slices;
|
return slices;
|
||||||
};
|
};
|
||||||
@ -316,7 +321,7 @@ D3D.Slicer.prototype._generateInnerLines = function (slices, printer) {
|
|||||||
for (var i = 0; i < slice.parts.length; i ++) {
|
for (var i = 0; i < slice.parts.length; i ++) {
|
||||||
var part = slice.parts[i];
|
var part = slice.parts[i];
|
||||||
|
|
||||||
var outerLine = part.intersect.clone().scaleUp(scale).offset(-nozzleRadius);
|
var outerLine = part.intersect.clone().scaleUp(scale);
|
||||||
|
|
||||||
if (outerLine.length > 0) {
|
if (outerLine.length > 0) {
|
||||||
part.outerLine = outerLine;
|
part.outerLine = outerLine;
|
||||||
@ -334,6 +339,9 @@ D3D.Slicer.prototype._generateInnerLines = function (slices, printer) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.progress.generatedInnerLines = true;
|
||||||
|
this._updateProgress();
|
||||||
};
|
};
|
||||||
D3D.Slicer.prototype._generateInfills = function (slices, printer) {
|
D3D.Slicer.prototype._generateInfills = function (slices, printer) {
|
||||||
"use strict";
|
"use strict";
|
||||||
@ -401,10 +409,10 @@ D3D.Slicer.prototype._generateInfills = function (slices, printer) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.progress.dataLayer = layer;
|
|
||||||
this._updateProgress();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.progress.generatedInfills = true;
|
||||||
|
this._updateProgress();
|
||||||
};
|
};
|
||||||
D3D.Slicer.prototype._generateSupport = function (slices, printer) {
|
D3D.Slicer.prototype._generateSupport = function (slices, printer) {
|
||||||
"use strict";
|
"use strict";
|
||||||
@ -466,6 +474,10 @@ D3D.Slicer.prototype._generateSupport = function (slices, printer) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.progress.generatedSupport = true;
|
||||||
|
this._updateProgress();
|
||||||
|
|
||||||
};
|
};
|
||||||
D3D.Slicer.prototype._optimizePaths = function (slices, printer) {
|
D3D.Slicer.prototype._optimizePaths = function (slices, printer) {
|
||||||
"use strict";
|
"use strict";
|
||||||
@ -506,6 +518,10 @@ D3D.Slicer.prototype._optimizePaths = function (slices, printer) {
|
|||||||
slice.brim.scaleDown(scale);
|
slice.brim.scaleDown(scale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.progress.optimizedPaths = true;
|
||||||
|
this._updateProgress();
|
||||||
|
|
||||||
}
|
}
|
||||||
D3D.Slicer.prototype._getFillTemplate = function (bounds, size, even, uneven) {
|
D3D.Slicer.prototype._getFillTemplate = function (bounds, size, even, uneven) {
|
||||||
"use strict";
|
"use strict";
|
||||||
@ -599,10 +615,11 @@ D3D.Slicer.prototype._slicesToGCode = function (slices, printer) {
|
|||||||
if (slice.support !== undefined) {
|
if (slice.support !== undefined) {
|
||||||
pathToGCode(slice.support, true, true, "support");
|
pathToGCode(slice.support, true, true, "support");
|
||||||
}
|
}
|
||||||
|
|
||||||
this.progress.gcodeLayer = layer;
|
|
||||||
this._updateProgress();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.progress.generatedGCode = true;
|
||||||
|
this._updateProgress();
|
||||||
|
|
||||||
|
|
||||||
return gcode.getGCode();
|
return gcode.getGCode();
|
||||||
};
|
};
|
12
src/utils.js
12
src/utils.js
@ -11,6 +11,18 @@ var D3D = {
|
|||||||
'contact': 'develop@doodle3d.com'
|
'contact': 'develop@doodle3d.com'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
THREE.Vector2.prototype.normal = function () {
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
var x = this.y;
|
||||||
|
var y = -this.x;
|
||||||
|
|
||||||
|
this.x = x;
|
||||||
|
this.y = y;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
function sendAPI (url, data, callback) {
|
function sendAPI (url, data, callback) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user