From 2d37b60512972cf7ea454dcc73d1ca4701c36e37 Mon Sep 17 00:00:00 2001
From: Amanda Ghassaei <amandaghassaei@gmail.com>
Date: Fri, 16 Jan 2015 20:06:04 -0500
Subject: [PATCH] dimensions change for orientation

---
 js/models/fillGeometry.js | 18 ++++--------------
 js/views/importView.js    | 10 ++++------
 2 files changed, 8 insertions(+), 20 deletions(-)

diff --git a/js/models/fillGeometry.js b/js/models/fillGeometry.js
index a856292b..f445eebf 100644
--- a/js/models/fillGeometry.js
+++ b/js/models/fillGeometry.js
@@ -33,8 +33,8 @@ FillGeometry = Backbone.Model.extend({
     buildNewMesh:function(){
 
         if (this.previous("mesh")) three.scene.remove(this.previous("mesh"));//remove current mesh from scene
-        this.set(_.omit(this.defaults, ["geometry", "material"]), {silent:true});//restore defaults
-        var mesh = new THREE.Mesh(this.get("geometry"), this.get("material"))
+        this.set({scale:this.defaults.scale, orientation:this.defaults.orientation}, {silent:true});//restore defaults
+        var mesh = new THREE.Mesh(this.get("geometry"), this.get("material"));
         three.scene.add(mesh);
         this.set({mesh: mesh});
 
@@ -45,7 +45,6 @@ FillGeometry = Backbone.Model.extend({
     },
 
     getBounds: function(){//bounds is the bounding box of the mesh geometry (before scaling)
-//        this.get("bounds").setFromObject(this.get("mesh"));
         this.get("mesh").geometry.computeBoundingBox();
         this.set("bounds", this.get("geometry").boundingBox.clone());
     },
@@ -55,21 +54,12 @@ FillGeometry = Backbone.Model.extend({
         this.set("boundingBoxHelper", helper);
         helper.update();
         three.scene.add(helper.object);
-        console.log(helper.box);
+        this.trigger("change:boundingBoxHelper");
     },
 
     updateBoundingBox: function(){
         this.get("boundingBoxHelper").update();
-        console.log(helper.box);
-
-//        var boundingBox = this.get("geometry").boundingBox;
-//        if (!boundingBox){
-//            console.log("no bb");
-//        }
-    },
-
-    updateBoundingBox:function(){
-
+        this.trigger("change:boundingBoxHelper");
     },
 
     render: function(){
diff --git a/js/views/importView.js b/js/views/importView.js
index 91bc2318..3fe0c7a4 100644
--- a/js/views/importView.js
+++ b/js/views/importView.js
@@ -18,7 +18,7 @@ ImportView = Backbone.View.extend({
     initialize: function(){
 
         _.bindAll(this, "render", "onMeshLoad");
-        this.model.bind("change", this.render);
+        this.model.bind("change:filename change:boundingBoxHelper", this.render);//boundingBoxHelper covers orientation/scale
 
         this.render();
     },
@@ -66,11 +66,9 @@ ImportView = Backbone.View.extend({
     },
 
     makeDimensionString: function(){
-        //todo add in orientation effects
-        var scale = this.model.get("scale");
-        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);
+        var bounds = this.model.get("boundingBoxHelper").box;
+        return (bounds.max.x - bounds.min.x).toFixed(1) + " x " +
+            (bounds.max.y - bounds.min.y).toFixed(1) + " x " + (bounds.max.z - bounds.min.z).toFixed(1);
     },
 
     rotate: function(e){
-- 
GitLab