Skip to content
Snippets Groups Projects
Commit c462c38d authored by Amanda Ghassaei's avatar Amanda Ghassaei
Browse files

dimensions added back in

parent 2ceb0dc7
No related branches found
No related tags found
No related merge requests found
...@@ -8,7 +8,7 @@ $(function(){ ...@@ -8,7 +8,7 @@ $(function(){
three = Three(); three = Three();
//init models and views //init models and views
window.fillGeometry = new FillGeometry();//init a singleton, add to global scope fillGeometry = new FillGeometry();//init a singleton, add to global scope
new ImportView({model: window.fillGeometry}); new ImportView({model: window.fillGeometry});
......
...@@ -15,7 +15,7 @@ FillGeometry = Backbone.Model.extend({ ...@@ -15,7 +15,7 @@ FillGeometry = Backbone.Model.extend({
side:THREE.DoubleSide}), side:THREE.DoubleSide}),
geometry: new THREE.BoxGeometry(100, 100, 100), geometry: new THREE.BoxGeometry(100, 100, 100),
filename: "Cube", filename: "Cube",
orientation: "", orientation: [0,0,0]
}, },
initialize: function(){ initialize: function(){
...@@ -53,11 +53,14 @@ FillGeometry = Backbone.Model.extend({ ...@@ -53,11 +53,14 @@ FillGeometry = Backbone.Model.extend({
makeBoundingBoxHelper: function(){ makeBoundingBoxHelper: function(){
var helper = new THREE.BoundingBoxHelper(this.get("mesh"), 0x000000); var helper = new THREE.BoundingBoxHelper(this.get("mesh"), 0x000000);
this.set("boundingBoxHelper", helper); this.set("boundingBoxHelper", helper);
helper.update();
three.scene.add(helper.object); three.scene.add(helper.object);
console.log(helper.box);
}, },
updateBoundingBox: function(){ updateBoundingBox: function(){
this.get("boundingBoxHelper").update(); this.get("boundingBoxHelper").update();
console.log(helper.box);
// var boundingBox = this.get("geometry").boundingBox; // var boundingBox = this.get("geometry").boundingBox;
// if (!boundingBox){ // if (!boundingBox){
...@@ -75,14 +78,19 @@ FillGeometry = Backbone.Model.extend({ ...@@ -75,14 +78,19 @@ FillGeometry = Backbone.Model.extend({
}, },
rotate: function(axis){ rotate: function(axis){
var orientation = this.get("orientation");
var mesh = this.get("mesh"); var mesh = this.get("mesh");
if (axis == "x"){ if (axis == "x"){
mesh.rotateX(Math.PI/2); mesh.rotateX(Math.PI/2);
orientation[0] += Math.PI/2;
} else if (axis == "y"){ } else if (axis == "y"){
mesh.rotateX(Math.PI/2); mesh.rotateX(Math.PI/2);
orientation[1] += Math.PI/2;
} else { } else {
mesh.rotateX(Math.PI/2); mesh.rotateX(Math.PI/2);
orientation[2] += Math.PI/2;
} }
this.trigger("change:orientation");
} }
}); });
......
...@@ -80,10 +80,11 @@ $(function(){ ...@@ -80,10 +80,11 @@ $(function(){
$("#STLFilename").html("Current file loaded:&nbsp&nbsp"+name); $("#STLFilename").html("Current file loaded:&nbsp&nbsp"+name);
} }
function showDimensions(scale){ function showDimensions(scale, orintation){
var boundingBox = modelMesh.geometry.boundingBox; //todo add in orientation effects
$("#meshDimensions").html("Dimensions: " + ((boundingBox.max.x - boundingBox.min.x)*scale).toFixed(1) + " x " + var bounds = this.model.get("bounds");
((boundingBox.max.y - boundingBox.min.y)*scale).toFixed(1) + " x " + ((boundingBox.max.z - boundingBox.min.z)*scale).toFixed(1)); $("#meshDimensions").html("Dimensions: " + ((bounds.max.x - bounds.min.x)*scale).toFixed(1) + " x " +
((bounds.max.y - bounds.min.y)*scale).toFixed(1) + " x " + ((bounds.max.z - bounds.min.z)*scale).toFixed(1));
} }
$("#stlRotateX").click(function(e){ $("#stlRotateX").click(function(e){
......
...@@ -66,9 +66,11 @@ ImportView = Backbone.View.extend({ ...@@ -66,9 +66,11 @@ ImportView = Backbone.View.extend({
}, },
makeDimensionString: function(){ makeDimensionString: function(){
// var boundingBox = this.model.get("boundingBox"); //todo add in orientation effects
// return ((boundingBox.max.x - boundingBox.min.x)*scale).toFixed(1) + " x " + var scale = this.model.get("scale");
// ((boundingBox.max.y - boundingBox.min.y)*scale).toFixed(1) + " x " + ((boundingBox.max.z - boundingBox.min.z)*scale).toFixed(1); var bounds = this.model.get("bounds");
return ((bounds.max.x - bounds.min.x)*scale).toFixed(1) + " x " +
((bounds.max.y - bounds.min.y)*scale).toFixed(1) + " x " + ((bounds.max.z - bounds.min.z)*scale).toFixed(1);
}, },
rotate: function(e){ rotate: function(e){
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment