From 5547d3381d129001bd8671cca6948628f0e8fa37 Mon Sep 17 00:00:00 2001 From: Amanda Ghassaei <amandaghassaei@gmail.com> Date: Mon, 23 Feb 2015 18:25:33 -0500 Subject: [PATCH] sketch plane --- js/fea/DmaCell.js | 2 +- js/menus/MenuWrapperView.js | 2 +- js/menus/SketchMenuView.js | 4 ++-- js/models/BasePlane.js | 29 +++++++++++++++++++---------- 4 files changed, 23 insertions(+), 14 deletions(-) diff --git a/js/fea/DmaCell.js b/js/fea/DmaCell.js index 9cff4de9..112f7c1a 100644 --- a/js/fea/DmaCell.js +++ b/js/fea/DmaCell.js @@ -267,7 +267,7 @@ DMACell.prototype.destroy = function(){ }; DMACubeCell.prototype.getHighlighterVertices = function(face){ - if (face.normal.z<0.99) return null;//only highlight horizontal faces +// if (face.normal.z<0.99) return null;//only highlight horizontal faces //the vertices don't include the position transformation applied to cell. Add these to create highlighter vertices var mesh = this.cellMesh.children[0]; diff --git a/js/menus/MenuWrapperView.js b/js/menus/MenuWrapperView.js index 60dc0fe7..64e5cd32 100644 --- a/js/menus/MenuWrapperView.js +++ b/js/menus/MenuWrapperView.js @@ -18,7 +18,7 @@ MenuWrapper = Backbone.View.extend({ //init all tab view controllers this.latticeMenu = new LatticeMenuView({model:this.model, lattice:options.lattice}); this.importMenu = new ImportMenuView({lattice:options.lattice, appState:this.model}); - this.sketchMenu = new SketchMenuView({model:options.lattice.get("basePlane"), appState:this.model}); + this.sketchMenu = new SketchMenuView({model:options.lattice, appState:this.model}); this.partMenu = new PartMenuView({model:this.model, lattice:options.lattice}); this.scriptMenu = new ScriptMenuView({model:this.model}); // this.animationMenu = new AnimationMenuView({model:options.lattice.get("basePlane"), appState:this.model}); diff --git a/js/menus/SketchMenuView.js b/js/menus/SketchMenuView.js index 1aefd45c..f0b1a0e3 100644 --- a/js/menus/SketchMenuView.js +++ b/js/menus/SketchMenuView.js @@ -20,12 +20,12 @@ SketchMenuView = Backbone.View.extend({ }, _moveSketchPlane: function(e){ - this.model.set("zIndex", $(e.target).val()); + this.model.get("basePlane").set("zIndex", $(e.target).val()); }, render: function(){ if (this.appState.get("currentTab") != "sketch") return; - this.$el.html(this.template(this.model.attributes)); + this.$el.html(this.template(this.model.get("basePlane").attributes)); $('#zHeightSlider').slider({ formatter: function(value) { diff --git a/js/models/BasePlane.js b/js/models/BasePlane.js index fb15c493..e3af6785 100644 --- a/js/models/BasePlane.js +++ b/js/models/BasePlane.js @@ -42,15 +42,6 @@ BasePlane = Backbone.Model.extend({ window.three.render(); }, - _renderZIndexChange: function(){ - var zIndex = this.get("zIndex"); - var scale = this.get("mesh").scale.z; - _.each(this.get("mesh"), function(mesh){ - mesh.position.set(0, 0, zIndex*scale*2/Math.sqrt(6)); - }); - window.three.render(); - }, - // _renderForCurrentScene: function(){ // }, @@ -142,6 +133,15 @@ OctaBasePlane = BasePlane.extend({ return [mesh]; }, + _renderZIndexChange: function(){ + var zIndex = this.get("zIndex"); + var scale = this.get("mesh")[0].scale.z; + _.each(this.get("mesh"), function(mesh){ + mesh.position.set(0, 0, zIndex*scale*2/Math.sqrt(6)); + }); + window.three.render(); + }, + _calcOctaFaceVertices: function(colSep){ var vertices = []; @@ -231,7 +231,16 @@ SquareBasePlane = BasePlane.extend({ var mesh = new THREE.Mesh(planeGeometry, new THREE.MeshBasicMaterial({color:0x000000, transparent:true, opacity:0.0, side:THREE.DoubleSide})); mesh.myParent = this;//reference used for intersection highlighting - return [mesh, new THREE.Line(geometry, new THREE.LineBasicMaterial({color:0x000000, transparent:true, linewidth:1, opacity:this.get("material").opacity}), THREE.LinePieces)]; + return [mesh, new THREE.Line(geometry, new THREE.LineBasicMaterial({color:0x000000, transparent:true, linewidth:2, opacity:this.get("material").opacity}), THREE.LinePieces)]; + }, + + _renderZIndexChange: function(){ + var zIndex = this.get("zIndex"); + var scale = this.get("mesh")[0].scale.z; + _.each(this.get("mesh"), function(mesh){ + mesh.position.set(0, 0, zIndex*scale); + }); + window.three.render(); }, getHighlighterVertices: function(face, position){ -- GitLab