From 3b32f145147b9fe6f6316f780266c3051f19e43d Mon Sep 17 00:00:00 2001 From: Amanda Ghassaei <amandaghassaei@gmail.com> Date: Fri, 16 Jan 2015 20:18:25 -0500 Subject: [PATCH] lattice model --- js/models/fillGeometry.js | 7 +++---- js/models/lattice.js | 20 ++++++++++++++++++++ js/views/importView.js | 15 +++++++-------- main.html | 8 ++++---- 4 files changed, 34 insertions(+), 16 deletions(-) create mode 100644 js/models/lattice.js diff --git a/js/models/fillGeometry.js b/js/models/fillGeometry.js index f445eebf..7ca06180 100644 --- a/js/models/fillGeometry.js +++ b/js/models/fillGeometry.js @@ -6,7 +6,6 @@ FillGeometry = Backbone.Model.extend({ defaults: { - scale: 1.0, material: new THREE.MeshLambertMaterial( {color:0xffa500, shading: THREE.FlatShading, @@ -23,9 +22,9 @@ FillGeometry = Backbone.Model.extend({ //bind events this.on("change:mesh", this.getBounds); this.on("change:mesh", this.makeBoundingBoxHelper); - this.on("change:scale change:orientation", this.updateBoundingBox); + this.on("change:orientation", this.updateBoundingBox); this.on("change:geometry", this.buildNewMesh); - this.on("change:mesh change:scale change:orientation", this.render); + this.on("change:mesh change:orientation", this.render); this.buildNewMesh(); }, @@ -33,7 +32,7 @@ FillGeometry = Backbone.Model.extend({ buildNewMesh:function(){ if (this.previous("mesh")) three.scene.remove(this.previous("mesh"));//remove current mesh from scene - this.set({scale:this.defaults.scale, orientation:this.defaults.orientation}, {silent:true});//restore defaults + this.set({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}); diff --git a/js/models/lattice.js b/js/models/lattice.js new file mode 100644 index 00000000..889d472f --- /dev/null +++ b/js/models/lattice.js @@ -0,0 +1,20 @@ +/** + * Created by aghassaei on 1/16/15. + */ + + +Lattice = Backbone.Model.extend({ + + defaults: { + scale: 1.0 + }, + + initialize: function(){ + + //bind events + + } + + + +}); \ No newline at end of file diff --git a/js/views/importView.js b/js/views/importView.js index 3fe0c7a4..1957d7da 100644 --- a/js/views/importView.js +++ b/js/views/importView.js @@ -12,13 +12,12 @@ ImportView = Backbone.View.extend({ "click .selectMesh": "selectMesh", "fileselect .btn-file :file": "readDataURL", "click .stlRotate": "rotate", - "slide #modelScale": "scale" }, initialize: function(){ _.bindAll(this, "render", "onMeshLoad"); - this.model.bind("change:filename change:boundingBoxHelper", this.render);//boundingBoxHelper covers orientation/scale + this.model.bind("change:filename change:boundingBoxHelper", this.render);//boundingBoxHelper covers orientation this.render(); }, @@ -61,9 +60,9 @@ ImportView = Backbone.View.extend({ this.model.set("geometry", e.content); }, - scale: function(e){ - this.model.set("scale", $(e.target).slider('getValue')); - }, +// scale: function(e){ +// this.model.set("scale", $(e.target).slider('getValue')); +// }, makeDimensionString: function(){ var bounds = this.model.get("boundingBoxHelper").box; @@ -111,9 +110,9 @@ ImportView = Backbone.View.extend({ </div>\ </div> <!-- /.col-xs-3 -->\ <div class="col-xs-9">\ - Geometry: <%= filename %><br/>\ - Dimensions: <%= dimensions %>\ - <div>Change model scale:</div>\ + <div>Geometry: <%= filename %><br/>\ + Dimensions: <%= dimensions %><br/>\ + Units: </div></br>\ <div class="col-xs-4">\ <a href="#" data-axis="z" class="stlRotate btn btn-block btn-lg btn-default">Rotate X</a>\ </div>\ diff --git a/main.html b/main.html index a48a4b05..c55cbadb 100644 --- a/main.html +++ b/main.html @@ -29,8 +29,9 @@ <script src="dependencies/OrbitControls.js"></script> <script src="js/threeMain.js"></script> - <!--stl export--> + <!--stl import/export--> <script src="dependencies/THREE2STL.js"></script> + <script src="dependencies/loaders/STLLoader.js"></script> <!--numerical javascript--> <script src="dependencies/numeric-1.2.6.js"></script> @@ -39,17 +40,16 @@ <script src="js/worker.js"></script> <script src="js/persistentWorkers.js"></script><!--global workers--> - <script src="js/main.js"></script> - <!--models--> <script src="js/models/fillGeometry.js"></script> + <script src="js/models/Lattice.js"></script> <!--views--> <script src="js/views/importView.js"></script> + <script src="js/main.js"></script> - <script src="dependencies/loaders/STLLoader.js"></script> <!--<script src="js/views/importMenu.js"></script>--> <!--<script src="js/views/elementMenu.js"></script>--> <script src="js/views/exportMenu.js"></script> -- GitLab