move THREE normal function to utils

This commit is contained in:
casperlamboo 2015-07-01 14:51:41 +02:00 committed by Simon Voordouw
parent d9c11112e4
commit 3141440c42
6 changed files with 61 additions and 43 deletions

View File

@ -1578,18 +1578,6 @@ THREE.Vector2.prototype = {
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;
}
};

View File

@ -36,7 +36,7 @@
"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",
"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,
"heatedBed": false,
"heatupBedTemperature": 70,

View File

@ -82,6 +82,7 @@ D3D.Box.prototype.init = function () {
};
D3D.Box.prototype._updateLoop = function () {
"use strict";
console.log("loop", this.status["buffered_lines"]);
var scope = this;
//TODO
//Code is zo op gezet dat maar api call te gelijk is

View File

@ -66,7 +66,7 @@ D3D.Paths.prototype.offset = function (offset) {
var solution = new ClipperLib.Paths();
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);
return new D3D.Paths(solution);

View File

@ -8,12 +8,13 @@ D3D.Slicer = function () {
"use strict";
this.progress = {
totalFaces: 0,
currentFace: 0,
totalLayers: 0,
sliceLayer: 0,
dataLayer: 0,
gcodeLayer: 0
createdLines: false,
sliced: false,
generatedInnerLines: false,
generatedInfills: false,
generatedSupport: false,
optimizedPaths: false,
generatedGCode: false
};
};
D3D.Slicer.prototype.setMesh = function (geometry, matrix) {
@ -76,24 +77,28 @@ D3D.Slicer.prototype.getGCode = function (printer) {
};
D3D.Slicer.prototype._updateProgress = function () {
'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) {
this.onProgress(this.progress);
this.onProgress(progress);
}
};
D3D.Slicer.prototype._createLines = function () {
"use strict";
this.progress.totalFaces = this.geometry.faces.length;
this._lines = [];
var lineLookup = {};
@ -136,10 +141,10 @@ D3D.Slicer.prototype._createLines = function () {
this._lines[b].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) {
"use strict";
@ -287,13 +292,13 @@ D3D.Slicer.prototype._slice = function (layerHeight, height) {
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;
};
@ -316,7 +321,7 @@ D3D.Slicer.prototype._generateInnerLines = function (slices, printer) {
for (var i = 0; i < slice.parts.length; 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) {
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) {
"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) {
"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) {
"use strict";
@ -506,6 +518,10 @@ D3D.Slicer.prototype._optimizePaths = function (slices, printer) {
slice.brim.scaleDown(scale);
}
}
this.progress.optimizedPaths = true;
this._updateProgress();
}
D3D.Slicer.prototype._getFillTemplate = function (bounds, size, even, uneven) {
"use strict";
@ -599,10 +615,11 @@ D3D.Slicer.prototype._slicesToGCode = function (slices, printer) {
if (slice.support !== undefined) {
pathToGCode(slice.support, true, true, "support");
}
this.progress.gcodeLayer = layer;
this._updateProgress();
}
this.progress.generatedGCode = true;
this._updateProgress();
return gcode.getGCode();
};

View File

@ -11,6 +11,18 @@ var D3D = {
'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) {
'use strict';