diff --git a/js/models/fillGeometry.js b/js/models/fillGeometry.js index a856292b9bf86bf0682e131adaf099a209437d0e..f445eebf4cc022836da746546e4e0b9c8a5d13cd 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 91bc2318d61a87144579dcf04465a0a27f18a3d4..3fe0c7a4103db5c0e91152ce20abd0a7002d5c94 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){