Commit 0c709aeb authored by Amanda Ghassaei's avatar Amanda Ghassaei
Browse files

gik lattice reorientation, and axes

parent 942cac95
...@@ -72,7 +72,7 @@ define(['underscore', 'appState', 'lattice', 'stlLoader', 'threeModel', 'cam', ' ...@@ -72,7 +72,7 @@ define(['underscore', 'appState', 'lattice', 'stlLoader', 'threeModel', 'cam', '
if (json.scale) geometry.applyMatrix(new THREE.Matrix4().makeScale(json.scale, json.scale, json.scale)); if (json.scale) geometry.applyMatrix(new THREE.Matrix4().makeScale(json.scale, json.scale, json.scale));
geometry.applyMatrix(new THREE.Matrix4().makeTranslation(-21, -0.63, 0));//todo get rid of these geometry.applyMatrix(new THREE.Matrix4().makeTranslation(-21, -0.63, 0));//todo get rid of these
geometry.applyMatrix(new THREE.Matrix4().makeRotationZ(Math.PI/2)); // geometry.applyMatrix(new THREE.Matrix4().makeRotationZ(Math.PI/2));
return geometry; return geometry;
} }
...@@ -339,10 +339,10 @@ define(['underscore', 'appState', 'lattice', 'stlLoader', 'threeModel', 'cam', ' ...@@ -339,10 +339,10 @@ define(['underscore', 'appState', 'lattice', 'stlLoader', 'threeModel', 'cam', '
if (totalThreads > 0) return; if (totalThreads > 0) return;
callback(); callback();
} }
var startingPos = {x:this.components.yAxis.getPosition().x, y:this.components.xAxis.getPosition().y, z:this.components.zAxis.getPosition().z}; var startingPos = {x:this.components.xAxis.getPosition().x, y:this.components.yAxis.getPosition().y, z:this.components.zAxis.getPosition().z};
speed = this._normalizeSpeed(startingPos, position, new THREE.Vector3(speed, speed, speed)); speed = this._normalizeSpeed(startingPos, position, new THREE.Vector3(speed, speed, speed));
this.components.yAxis.moveTo(this._makeAxisVector(position, "x"), speed.x, sketchyCallback); this.components.xAxis.moveTo(this._makeAxisVector(position, "x"), speed.x, sketchyCallback);
this.components.xAxis.moveTo(this._makeAxisVector(position, "y"), speed.y, sketchyCallback); this.components.yAxis.moveTo(this._makeAxisVector(position, "y"), speed.y, sketchyCallback);
this.components.zAxis.moveTo(this._makeAxisVector(position, "z"), speed.z, sketchyCallback); this.components.zAxis.moveTo(this._makeAxisVector(position, "z"), speed.z, sketchyCallback);
}; };
......
...@@ -44,12 +44,12 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre ...@@ -44,12 +44,12 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
}, },
_zIndexRotation: function(index){ _zIndexRotation: function(index){
if (index.z%2 == 0) return Math.PI/2; if (index.z%2 != 0) return Math.PI/2;
return 0; return 0;
}, },
_zIndexRotationSuperCell: function(index){ _zIndexRotationSuperCell: function(index){
if (index.z%2 != 0) return -Math.PI/2;//this never changes if (index.z%2 != 0) return Math.PI/2;//this goes neg if zIndexRotation rules are opp? need to clear this up eventually
return 0; return 0;
}, },
......
...@@ -22,6 +22,7 @@ require.config({ ...@@ -22,6 +22,7 @@ require.config({
threeModel: 'three/ThreeModel', threeModel: 'three/ThreeModel',
threeView: 'three/ThreeView', threeView: 'three/ThreeView',
fillGeometry: 'three/FillGeometry', fillGeometry: 'three/FillGeometry',
axes: 'three/Axes',
//plist //plist
plist: 'plists/PList', plist: 'plists/PList',
......
...@@ -12,7 +12,8 @@ define(['jquery', 'underscore', 'backbone', 'plist', 'lattice', 'appState', 'tex ...@@ -12,7 +12,8 @@ define(['jquery', 'underscore', 'backbone', 'plist', 'lattice', 'appState', 'tex
"click .ribbonCellMode": "_updateCellMode", "click .ribbonCellMode": "_updateCellMode",
"click .ribbonDeleteMode": "_updateDeleteMode", "click .ribbonDeleteMode": "_updateDeleteMode",
"click .highlightMode": "_updateHighlightMode", "click .highlightMode": "_updateHighlightMode",
"click .cellsVisible": "_updateCellVisibility" "click .cellsVisible": "_updateCellVisibility",
"click #ribbonAxesToggle": "_setAxesVis"
}, },
initialize: function(){ initialize: function(){
...@@ -25,6 +26,7 @@ define(['jquery', 'underscore', 'backbone', 'plist', 'lattice', 'appState', 'tex ...@@ -25,6 +26,7 @@ define(['jquery', 'underscore', 'backbone', 'plist', 'lattice', 'appState', 'tex
this.listenTo(this.model, "change:deleteMode", this.render); this.listenTo(this.model, "change:deleteMode", this.render);
this.listenTo(this.model, "change:highlightMode", this.render); this.listenTo(this.model, "change:highlightMode", this.render);
this.listenTo(this.model, "change:cellsVisible", this.render); this.listenTo(this.model, "change:cellsVisible", this.render);
this.listenTo(this.model, "change:axesAreVisible", this.render);
this.listenTo(lattice, "change:cellType change:connectionType", this.render); this.listenTo(lattice, "change:cellType change:connectionType", this.render);
this.render(); this.render();
}, },
...@@ -55,6 +57,11 @@ define(['jquery', 'underscore', 'backbone', 'plist', 'lattice', 'appState', 'tex ...@@ -55,6 +57,11 @@ define(['jquery', 'underscore', 'backbone', 'plist', 'lattice', 'appState', 'tex
else this.$el.hide(); else this.$el.hide();
}, },
_setAxesVis: function(e){
e.preventDefault();
this.model.set("axesAreVisible", !this.model.get("axesAreVisible"));
},
render: function(){ render: function(){
this.$el.html(this.template(_.extend(lattice.toJSON(), this.model.toJSON(), plist))); this.$el.html(this.template(_.extend(lattice.toJSON(), this.model.toJSON(), plist)));
}, },
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
<% if (currentNav != "electronicNavSim" && currentNav != "mechanicalNavSim" && currentNav != "navAssemble" && currentNav != "navOptimize"){%> <% if (currentNav != "electronicNavSim" && currentNav != "mechanicalNavSim" && currentNav != "navAssemble" && currentNav != "navOptimize"){%>
<a class="btn btn-primary btn-ribbon ribbonDeleteMode<% if (deleteMode){ %> ribbon-selected"<% } %>"><span class="fui-cross"></span></a> <a class="btn btn-primary btn-ribbon ribbonDeleteMode<% if (deleteMode){ %> ribbon-selected"<% } %>"><span class="fui-cross"></span></a>
<% } %> <% } %>
<a id="ribbonAxesToggle" class="btn btn-primary btn-ribbon <% if (axesAreVisible){ %> ribbon-selected"<% } %>">Axes</a>
</div> </div>
</div> </div>
<!--//<a class="btn btn-primary btn-ribbon highlightMode<% if (highlightMode){ %> ribbon-selected<% } %>" href="#"><img data-type="part" src="assets/imgs/cursor-light.png"></a>--> <!--//<a class="btn btn-primary btn-ribbon highlightMode<% if (highlightMode){ %> ribbon-selected<% } %>" href="#"><img data-type="part" src="assets/imgs/cursor-light.png"></a>-->
......
...@@ -62,6 +62,7 @@ define(['underscore', 'backbone', 'threeModel', 'three', 'plist', 'globals'], fu ...@@ -62,6 +62,7 @@ define(['underscore', 'backbone', 'threeModel', 'three', 'plist', 'globals'], fu
this.listenTo(this, "change:materialType", this._materialTypeChanged); this.listenTo(this, "change:materialType", this._materialTypeChanged);
this.listenTo(this, "change:gikLength", this._gikLengthChanged); this.listenTo(this, "change:gikLength", this._gikLengthChanged);
this.listenTo(this, "change:turnOffRendering", this._renderingOnOff); this.listenTo(this, "change:turnOffRendering", this._renderingOnOff);
this.listenTo(this, "change:axesAreVisible", this._showAxes);
this.downKeys = {};//track keypresses to prevent repeat keystrokes on hold this.downKeys = {};//track keypresses to prevent repeat keystrokes on hold
this.lastCellMode = this.get("cellMode");//store this to toggle on/off hide mode this.lastCellMode = this.get("cellMode");//store this to toggle on/off hide mode
...@@ -149,6 +150,14 @@ define(['underscore', 'backbone', 'threeModel', 'three', 'plist', 'globals'], fu ...@@ -149,6 +150,14 @@ define(['underscore', 'backbone', 'threeModel', 'three', 'plist', 'globals'], fu
if (!this.get("turnOffRendering")) three.render(); if (!this.get("turnOffRendering")) three.render();
}, },
_showAxes: function(){
var visible = this.get("axesAreVisible");
require(['axes'], function(axes){
axes.setVisibility(visible);
three.render();
})
},
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
/////////////////////KEY BINDINGS////////////////////////////////////////////// /////////////////////KEY BINDINGS//////////////////////////////////////////////
......
...@@ -111,8 +111,7 @@ define(['three'], function(THREE){ ...@@ -111,8 +111,7 @@ define(['three'], function(THREE){
}, },
name: "Stock 1", name: "Stock 1",
parent: "zAxis", parent: "zAxis",
position: {x:0,y:0,z:0}, position: {x:0,y:0,z:0}
rotation: {x:0, y:0, z:Math.PI/2}
}, },
stock2: { stock2: {
description:{ description:{
...@@ -121,8 +120,7 @@ define(['three'], function(THREE){ ...@@ -121,8 +120,7 @@ define(['three'], function(THREE){
}, },
name: "Stock 2", name: "Stock 2",
parent: "zAxis", parent: "zAxis",
position: {x:0.236,y:26,z:0}, position: {x:26,y:0.236,z:0}
rotation: {x:0, y:0, z:Math.PI/2}
} }
}, },
lattice:{ lattice:{
......
/**
* Created by aghassaei on 8/18/15.
*/
define(['three', 'threeModel'], function(THREE, three){
var radius = 0.5;
var height = 20;
var arrowGeometry = new THREE.CylinderGeometry(0, 2 * radius, height / 5);
var axisGeometry = new THREE.CylinderGeometry(radius, radius, height);
var xAxisMaterial = new THREE.MeshBasicMaterial({color: 0xFF0000});
var xAxisMesh = new THREE.Mesh(axisGeometry, xAxisMaterial);
var xArrowMesh = new THREE.Mesh(arrowGeometry, xAxisMaterial);
xAxisMesh.add(xArrowMesh);
xArrowMesh.position.y += height / 2;
xAxisMesh.rotation.z -= 90 * Math.PI / 180;
xAxisMesh.position.x += height / 2;
var yAxisMaterial = new THREE.MeshBasicMaterial({color: 0x00FF00});
var yAxisMesh = new THREE.Mesh(axisGeometry, yAxisMaterial);
var yArrowMesh = new THREE.Mesh(arrowGeometry, yAxisMaterial);
yAxisMesh.add(yArrowMesh);
yArrowMesh.position.y += height / 2;
yAxisMesh.position.y += height / 2;
var zAxisMaterial = new THREE.MeshBasicMaterial({color: 0x0000FF});
var zAxisMesh = new THREE.Mesh(axisGeometry, zAxisMaterial);
var zArrowMesh = new THREE.Mesh(arrowGeometry, zAxisMaterial);
zAxisMesh.add(zArrowMesh);
zAxisMesh.rotation.x += 90 * Math.PI / 180;
zArrowMesh.position.y += height / 2;
zAxisMesh.position.z += height / 2;
var axesMesh = new THREE.Object3D();
axesMesh.add(xAxisMesh);
axesMesh.add(yAxisMesh);
axesMesh.add(zAxisMesh);
three.sceneAdd(axesMesh);
setVisibility(false);
function setVisibility(visible){
axesMesh.visible = visible;
}
return {
setVisibility: setVisibility
}
});
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment