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

dimensions change for orientation

parent c462c38d
Branches
No related tags found
No related merge requests found
...@@ -33,8 +33,8 @@ FillGeometry = Backbone.Model.extend({ ...@@ -33,8 +33,8 @@ FillGeometry = Backbone.Model.extend({
buildNewMesh:function(){ buildNewMesh:function(){
if (this.previous("mesh")) three.scene.remove(this.previous("mesh"));//remove current mesh from scene 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 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")) var mesh = new THREE.Mesh(this.get("geometry"), this.get("material"));
three.scene.add(mesh); three.scene.add(mesh);
this.set({mesh: mesh}); this.set({mesh: mesh});
...@@ -45,7 +45,6 @@ FillGeometry = Backbone.Model.extend({ ...@@ -45,7 +45,6 @@ FillGeometry = Backbone.Model.extend({
}, },
getBounds: function(){//bounds is the bounding box of the mesh geometry (before scaling) 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.get("mesh").geometry.computeBoundingBox();
this.set("bounds", this.get("geometry").boundingBox.clone()); this.set("bounds", this.get("geometry").boundingBox.clone());
}, },
...@@ -55,21 +54,12 @@ FillGeometry = Backbone.Model.extend({ ...@@ -55,21 +54,12 @@ FillGeometry = Backbone.Model.extend({
this.set("boundingBoxHelper", helper); this.set("boundingBoxHelper", helper);
helper.update(); helper.update();
three.scene.add(helper.object); three.scene.add(helper.object);
console.log(helper.box); this.trigger("change:boundingBoxHelper");
}, },
updateBoundingBox: function(){ updateBoundingBox: function(){
this.get("boundingBoxHelper").update(); this.get("boundingBoxHelper").update();
console.log(helper.box); this.trigger("change:boundingBoxHelper");
// var boundingBox = this.get("geometry").boundingBox;
// if (!boundingBox){
// console.log("no bb");
// }
},
updateBoundingBox:function(){
}, },
render: function(){ render: function(){
......
...@@ -18,7 +18,7 @@ ImportView = Backbone.View.extend({ ...@@ -18,7 +18,7 @@ ImportView = Backbone.View.extend({
initialize: function(){ initialize: function(){
_.bindAll(this, "render", "onMeshLoad"); _.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(); this.render();
}, },
...@@ -66,11 +66,9 @@ ImportView = Backbone.View.extend({ ...@@ -66,11 +66,9 @@ ImportView = Backbone.View.extend({
}, },
makeDimensionString: function(){ makeDimensionString: function(){
//todo add in orientation effects var bounds = this.model.get("boundingBoxHelper").box;
var scale = this.model.get("scale"); return (bounds.max.x - bounds.min.x).toFixed(1) + " x " +
var bounds = this.model.get("bounds"); (bounds.max.y - bounds.min.y).toFixed(1) + " x " + (bounds.max.z - bounds.min.z).toFixed(1);
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.
Please register or to comment