mirror of
https://github.com/Doodle3D/Doodle3D-Slicer.git
synced 2024-11-19 04:27:55 +01:00
cleaned up code
This commit is contained in:
parent
b6884b6266
commit
5015d31bce
@ -61,21 +61,23 @@ var geometry = new THREE.TorusGeometry(20, 10, 10, 10);
|
||||
var mesh = new THREE.Mesh(geometry, material);
|
||||
scene.add(mesh);
|
||||
|
||||
var slicer = new D3D.Slicer().setGeometry(geometry);
|
||||
//var slices = slicer.slice(200, 0.2);
|
||||
var slices = slicer.slice(1, 1);
|
||||
(function () {
|
||||
var slicer = new D3D.Slicer().setGeometry(geometry);
|
||||
var slices = slicer.slice(200, 0.2);
|
||||
//var slices = slicer.slice(1, 1);
|
||||
|
||||
CAL.Scene.setCanvas(document.getElementById("canvas"));
|
||||
CAL.Scene.setCanvas(document.getElementById("canvas"));
|
||||
|
||||
//error at layer 0;
|
||||
//maybe because of geomety
|
||||
var layer = 4;
|
||||
|
||||
var shapes = [];
|
||||
var shapes = [];
|
||||
|
||||
for (var layer = 0; layer < slices.length; layer ++) {
|
||||
var slice = slices[layer];
|
||||
|
||||
for (var i = 0; i < slice.length; i ++) {
|
||||
var shape = new CAL.Shape({shapeColor: false});
|
||||
CAL.Scene.add(shape);
|
||||
shapes.push(shape);
|
||||
|
||||
for (var j = 0; j < slice[i].length; j ++) {
|
||||
@ -83,22 +85,21 @@ for (var layer = 0; layer < slices.length; layer ++) {
|
||||
shape.addPoint(new CAL.Vector((point.x-100) * 5 + 200, (point.y-100) * 5 + 200));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CAL.Scene.draw();
|
||||
for (var i = 0; i < shapes.length; i ++) {
|
||||
var shape = shapes[i];
|
||||
|
||||
CAL.Scene.context.strokeStyle = "#FF0000";
|
||||
shape.draw(CAL.Scene.context);
|
||||
CAL.Scene.context.strokeStyle = "#FF0000";
|
||||
|
||||
for (var i = 0; i < shapes.length; i ++) {
|
||||
var shape = shapes[i];
|
||||
for (var j = 0; j < shape.points.length; j ++) {
|
||||
var normal = shape.getNormal(j).scale(20);
|
||||
var point = shape.points[j];
|
||||
|
||||
for (var j = 0; j < shape.points.length; j ++) {
|
||||
var normal = shape.getNormal(j).scale(20);
|
||||
var point = shape.points[j];
|
||||
|
||||
normal.draw(CAL.Scene.context, point.x, point.y);
|
||||
normal.draw(CAL.Scene.context, point.x, point.y);
|
||||
}
|
||||
}
|
||||
}
|
||||
})();
|
||||
|
||||
(function animate () {
|
||||
requestAnimationFrame(animate);
|
||||
|
@ -87,7 +87,6 @@ D3D.Slicer.prototype.slice = function (height, step) {
|
||||
var plane = new THREE.Plane();
|
||||
|
||||
for (var z = 0; z < height; z += step) {
|
||||
z += 1;
|
||||
plane.set(new THREE.Vector3(0, -1, 0), z);
|
||||
|
||||
var slice = [];
|
||||
@ -133,7 +132,7 @@ D3D.Slicer.prototype.slice = function (height, step) {
|
||||
var normal = new THREE.Vector2().copy(intersection).sub(intersections[index]).normal().normalize();
|
||||
var faceNormal = faceNormals[j];
|
||||
|
||||
if (normal.dot(faceNormal) < 0) {
|
||||
if (normal.dot(faceNormal) > 0) {
|
||||
break;
|
||||
}
|
||||
else {
|
||||
|
Loading…
Reference in New Issue
Block a user