From c462c38d21abf780280db94e6206c032ded5403a Mon Sep 17 00:00:00 2001 From: Amanda Ghassaei <amandaghassaei@gmail.com> Date: Fri, 16 Jan 2015 19:51:17 -0500 Subject: [PATCH] dimensions added back in --- js/main.js | 2 +- js/models/fillGeometry.js | 10 +++++++++- js/views/importMenu.js | 9 +++++---- js/views/importView.js | 8 +++++--- 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/js/main.js b/js/main.js index 277bebf3..d1ce6d60 100644 --- a/js/main.js +++ b/js/main.js @@ -8,7 +8,7 @@ $(function(){ three = Three(); //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}); diff --git a/js/models/fillGeometry.js b/js/models/fillGeometry.js index 1fd53849..a856292b 100644 --- a/js/models/fillGeometry.js +++ b/js/models/fillGeometry.js @@ -15,7 +15,7 @@ FillGeometry = Backbone.Model.extend({ side:THREE.DoubleSide}), geometry: new THREE.BoxGeometry(100, 100, 100), filename: "Cube", - orientation: "", + orientation: [0,0,0] }, initialize: function(){ @@ -53,11 +53,14 @@ FillGeometry = Backbone.Model.extend({ makeBoundingBoxHelper: function(){ var helper = new THREE.BoundingBoxHelper(this.get("mesh"), 0x000000); this.set("boundingBoxHelper", helper); + helper.update(); three.scene.add(helper.object); + console.log(helper.box); }, updateBoundingBox: function(){ this.get("boundingBoxHelper").update(); + console.log(helper.box); // var boundingBox = this.get("geometry").boundingBox; // if (!boundingBox){ @@ -75,14 +78,19 @@ FillGeometry = Backbone.Model.extend({ }, rotate: function(axis){ + var orientation = this.get("orientation"); var mesh = this.get("mesh"); if (axis == "x"){ mesh.rotateX(Math.PI/2); + orientation[0] += Math.PI/2; } else if (axis == "y"){ mesh.rotateX(Math.PI/2); + orientation[1] += Math.PI/2; } else { mesh.rotateX(Math.PI/2); + orientation[2] += Math.PI/2; } + this.trigger("change:orientation"); } }); diff --git a/js/views/importMenu.js b/js/views/importMenu.js index 3713ff3d..8c8c102a 100644 --- a/js/views/importMenu.js +++ b/js/views/importMenu.js @@ -80,10 +80,11 @@ $(function(){ $("#STLFilename").html("Current file loaded:  "+name); } - function showDimensions(scale){ - var boundingBox = modelMesh.geometry.boundingBox; - $("#meshDimensions").html("Dimensions: " + ((boundingBox.max.x - boundingBox.min.x)*scale).toFixed(1) + " x " + - ((boundingBox.max.y - boundingBox.min.y)*scale).toFixed(1) + " x " + ((boundingBox.max.z - boundingBox.min.z)*scale).toFixed(1)); + function showDimensions(scale, orintation){ + //todo add in orientation effects + var bounds = this.model.get("bounds"); + $("#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){ diff --git a/js/views/importView.js b/js/views/importView.js index 940723c3..91bc2318 100644 --- a/js/views/importView.js +++ b/js/views/importView.js @@ -66,9 +66,11 @@ ImportView = Backbone.View.extend({ }, makeDimensionString: function(){ -// var boundingBox = this.model.get("boundingBox"); -// return ((boundingBox.max.x - boundingBox.min.x)*scale).toFixed(1) + " x " + -// ((boundingBox.max.y - boundingBox.min.y)*scale).toFixed(1) + " x " + ((boundingBox.max.z - boundingBox.min.z)*scale).toFixed(1); + //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); }, rotate: function(e){ -- GitLab