mirror of
https://github.com/Doodle3D/Doodle3D-Slicer.git
synced 2024-11-16 11:07:57 +01:00
updated slicing
moved add line to create lines; makes line lookup private
This commit is contained in:
parent
3d34c59514
commit
948865fc07
@ -81,18 +81,18 @@ var geometry = (function () {
|
||||
"use strict";
|
||||
|
||||
var circle = new THREE.Shape();
|
||||
circle.absarc(0, 0, 20, 0, Math.PI*2, false);
|
||||
circle.absarc(0, 0, 10, 0, Math.PI*2, false);
|
||||
|
||||
var hole = new THREE.Path();
|
||||
hole.absarc(0, 0, 10, 0, Math.PI*2, true );
|
||||
hole.absarc(0, 0, 5, 0, Math.PI*2, true );
|
||||
|
||||
circle.holes.push(hole);
|
||||
//circle.holes.push(hole);
|
||||
|
||||
var matrix = new THREE.Matrix4();
|
||||
matrix.makeRotationX(Math.PI*1.5);
|
||||
|
||||
var geometry = new THREE.ExtrudeGeometry(circle, {
|
||||
amount: 10,
|
||||
amount: 3,
|
||||
bevelEnabled: false,
|
||||
steps: 1
|
||||
});
|
||||
@ -102,7 +102,7 @@ var geometry = (function () {
|
||||
})();
|
||||
|
||||
var material = new THREE.MeshLambertMaterial({color: 0x000000, wireframe: true});
|
||||
var geometry = new THREE.TorusGeometry(20, 10, 10, 10);
|
||||
//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);
|
||||
@ -120,7 +120,7 @@ var gcode = slicer.getGcode(printer);
|
||||
var canvas = document.getElementById("canvas");
|
||||
var context = canvas.getContext("2d");
|
||||
|
||||
var layer = 90;
|
||||
var layer = 9;
|
||||
var img = slicer.drawPaths(printer, layer, layer + 1);
|
||||
context.drawImage(img, 0, 0);
|
||||
|
||||
|
@ -18,7 +18,6 @@ D3D.Slicer = function () {
|
||||
this.geometry;
|
||||
|
||||
this.lines = [];
|
||||
this.lineLookup = {};
|
||||
};
|
||||
D3D.Slicer.prototype.setGeometry = function (geometry) {
|
||||
"use strict";
|
||||
@ -30,30 +29,32 @@ D3D.Slicer.prototype.setGeometry = function (geometry) {
|
||||
|
||||
return this;
|
||||
};
|
||||
D3D.Slicer.prototype.addLine = function (a, b) {
|
||||
"use strict";
|
||||
|
||||
//think lookup can only be b_a, a_b is only possible when face is flipped
|
||||
var index = this.lineLookup[a + "_" + b] || this.lineLookup[b + "_" + a];
|
||||
|
||||
if (index === undefined) {
|
||||
index = this.lines.length;
|
||||
this.lineLookup[a + "_" + b] = index;
|
||||
|
||||
this.lines.push({
|
||||
line: new THREE.Line3(this.geometry.vertices[a], this.geometry.vertices[b]),
|
||||
connects: [],
|
||||
normals: []
|
||||
});
|
||||
}
|
||||
|
||||
return index;
|
||||
};
|
||||
D3D.Slicer.prototype.createLines = function () {
|
||||
"use strict";
|
||||
|
||||
this.lines = [];
|
||||
this.lineLookup = {};
|
||||
var lineLookup = {};
|
||||
|
||||
var self = this;
|
||||
function addLine (a, b) {
|
||||
"use strict";
|
||||
|
||||
//think lookup can only be b_a, a_b is only possible when face is flipped
|
||||
var index = lineLookup[a + "_" + b] || lineLookup[b + "_" + a];
|
||||
|
||||
if (index === undefined) {
|
||||
index = self.lines.length;
|
||||
lineLookup[a + "_" + b] = index;
|
||||
|
||||
self.lines.push({
|
||||
line: new THREE.Line3(self.geometry.vertices[a], self.geometry.vertices[b]),
|
||||
connects: [],
|
||||
normals: []
|
||||
});
|
||||
}
|
||||
|
||||
return index;
|
||||
};
|
||||
|
||||
for (var i = 0; i < this.geometry.faces.length; i ++) {
|
||||
var face = this.geometry.faces[i];
|
||||
@ -61,9 +62,9 @@ D3D.Slicer.prototype.createLines = function () {
|
||||
|
||||
//check for only adding unique lines
|
||||
//returns index of said line
|
||||
var a = this.addLine(face.a, face.b);
|
||||
var b = this.addLine(face.b, face.c);
|
||||
var c = this.addLine(face.c, face.a);
|
||||
var a = addLine(face.a, face.b);
|
||||
var b = addLine(face.b, face.c);
|
||||
var c = addLine(face.c, face.a);
|
||||
|
||||
//set connecting lines (based on face)
|
||||
|
||||
@ -228,6 +229,7 @@ D3D.Slicer.prototype.slicesToData = function (slices, printer) {
|
||||
innerLayer = innerLayer.concat(inset);
|
||||
}
|
||||
|
||||
//moet fillArea wel kleiner?
|
||||
var fillArea = this.getInset((inset || outerLayer), wallThickness);
|
||||
|
||||
var fillAbove = false;
|
||||
|
Loading…
Reference in New Issue
Block a user