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