fix preparing for sketching

This commit is contained in:
Val Erastov 2014-09-29 22:00:06 -07:00
parent a69f9c2c04
commit 71ff96b98e
2 changed files with 20 additions and 4 deletions

View file

@ -301,7 +301,7 @@ TCAD.Polygon.prototype.shift = function(target) {
};
TCAD.Polygon.prototype.triangulate = function() {
TCAD.Polygon.prototype.to2D = function() {
var _3dTransformation = new TCAD.Matrix().setBasis(TCAD.geom.someBasis(this.shell, this.normal));
var _2dTransformation = _3dTransformation.invert();
@ -310,7 +310,7 @@ TCAD.Polygon.prototype.triangulate = function() {
var shell = [];
var holes = [];
for (i = 0; i < this.shell.length; ++i) {
shell[i] = _2dTransformation.apply(this.shell[i]).three();
shell[i] = _2dTransformation.apply(this.shell[i]);
}
for (h = 0; h < this.holes.length; ++h) {
holes[h] = [];
@ -318,7 +318,23 @@ TCAD.Polygon.prototype.triangulate = function() {
holes[h][i] = _2dTransformation.apply(this.holes[h][i]);
}
}
return THREE.Shape.utils.triangulateShape( shell, holes );
return {shell: shell, holes: holes};
};
TCAD.Polygon.prototype.triangulate = function() {
var i, h;
var f2d = this.to2D();
for (i = 0; i < f2d.shell.length; ++i) {
f2d.shell[i] = f2d.shell[i].three();
}
for (h = 0; h < f2d.holes.length; ++h) {
for (i = 0; i < f2d.holes[h].length; ++i) {
f2d.holes[h][i] = f2d.holes[h][i].three();
}
}
return THREE.Shape.utils.triangulateShape( f2d.shell, f2d.holes );
};

View file

@ -35,7 +35,7 @@ TCAD.App.prototype.sketchFace = function() {
} else {
data = JSON.parse(savedFace);
}
data.boundary = polyFace.polygon;
data.boundary = polyFace.polygon.to2D();
localStorage.setItem(faceStorageKey, JSON.stringify(data));
window.open("http://localhost:8080/canvas.html#" + faceStorageKey.substring(14), "Edit Sketch", "height=700,width=700");