diff --git a/assets/imgs/axes.png b/assets/imgs/axes.png new file mode 100644 index 0000000000000000000000000000000000000000..572060aac6865b27b61fd5e2ffa1c2c711b82bda Binary files /dev/null and b/assets/imgs/axes.png differ diff --git a/js/cam/assemblers/Assembler.js b/js/cam/assemblers/Assembler.js index 4edf6fd89761036448cde0b694c13a06f0f64e0b..c4fa5a07107b4d07d2900275517011439fa384b9 100644 --- a/js/cam/assemblers/Assembler.js +++ b/js/cam/assemblers/Assembler.js @@ -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)); 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; } @@ -339,10 +339,10 @@ define(['underscore', 'appState', 'lattice', 'stlLoader', 'threeModel', 'cam', ' if (totalThreads > 0) return; 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)); - this.components.yAxis.moveTo(this._makeAxisVector(position, "x"), speed.x, sketchyCallback); - this.components.xAxis.moveTo(this._makeAxisVector(position, "y"), speed.y, sketchyCallback); + this.components.xAxis.moveTo(this._makeAxisVector(position, "x"), speed.x, sketchyCallback); + this.components.yAxis.moveTo(this._makeAxisVector(position, "y"), speed.y, sketchyCallback); this.components.zAxis.moveTo(this._makeAxisVector(position, "z"), speed.z, sketchyCallback); }; diff --git a/js/lattice/latticeSubclasses/GIKLattice.js b/js/lattice/latticeSubclasses/GIKLattice.js index 1c0150a2de91a3ebd2671683adc649ef483e075f..67f16a40ce0396632f0dcbb2791260e863bca429 100644 --- a/js/lattice/latticeSubclasses/GIKLattice.js +++ b/js/lattice/latticeSubclasses/GIKLattice.js @@ -44,12 +44,12 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre }, _zIndexRotation: function(index){ - if (index.z%2 == 0) return Math.PI/2; + if (index.z%2 != 0) return Math.PI/2; return 0; }, _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; }, diff --git a/js/main.js b/js/main.js index ee92b4e1ba6f73b0f54115c410270aaa94785daf..82f8cf4e1686c34684f28b6f54116cf862ad0bc6 100644 --- a/js/main.js +++ b/js/main.js @@ -22,6 +22,7 @@ require.config({ threeModel: 'three/ThreeModel', threeView: 'three/ThreeView', fillGeometry: 'three/FillGeometry', + axes: 'three/Axes', //plist plist: 'plists/PList', diff --git a/js/menus/Ribbon.js b/js/menus/Ribbon.js index cbfaf48f73691e000f04828867d4d89e64982c78..9b30673d20595deda0460ba943a1f955b0886a39 100644 --- a/js/menus/Ribbon.js +++ b/js/menus/Ribbon.js @@ -12,7 +12,8 @@ define(['jquery', 'underscore', 'backbone', 'plist', 'lattice', 'appState', 'tex "click .ribbonCellMode": "_updateCellMode", "click .ribbonDeleteMode": "_updateDeleteMode", "click .highlightMode": "_updateHighlightMode", - "click .cellsVisible": "_updateCellVisibility" + "click .cellsVisible": "_updateCellVisibility", + "click #ribbonAxesToggle": "_setAxesVis" }, initialize: function(){ @@ -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:highlightMode", 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.render(); }, @@ -55,6 +57,11 @@ define(['jquery', 'underscore', 'backbone', 'plist', 'lattice', 'appState', 'tex else this.$el.hide(); }, + _setAxesVis: function(e){ + e.preventDefault(); + this.model.set("axesAreVisible", !this.model.get("axesAreVisible")); + }, + render: function(){ this.$el.html(this.template(_.extend(lattice.toJSON(), this.model.toJSON(), plist))); }, diff --git a/js/menus/templates/Ribbon.html b/js/menus/templates/Ribbon.html index 72ed5e43777b4c6703249f8bd468c2d52e38fece..1539dd935bdfe4f8e15b5f88c603dd5874c09936 100644 --- a/js/menus/templates/Ribbon.html +++ b/js/menus/templates/Ribbon.html @@ -10,6 +10,7 @@ <% 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 id="ribbonAxesToggle" class="btn btn-primary btn-ribbon <% if (axesAreVisible){ %> ribbon-selected"<% } %>">Axes</a> </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>--> diff --git a/js/models/AppState.js b/js/models/AppState.js index fde99e781ceeba2d8b9dca067b8e378c584f39ad..fc26021bd1e2184c55bf398823f67566d7ba6283 100644 --- a/js/models/AppState.js +++ b/js/models/AppState.js @@ -62,6 +62,7 @@ define(['underscore', 'backbone', 'threeModel', 'three', 'plist', 'globals'], fu this.listenTo(this, "change:materialType", this._materialTypeChanged); this.listenTo(this, "change:gikLength", this._gikLengthChanged); 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.lastCellMode = this.get("cellMode");//store this to toggle on/off hide mode @@ -149,6 +150,14 @@ define(['underscore', 'backbone', 'threeModel', 'three', 'plist', 'globals'], fu if (!this.get("turnOffRendering")) three.render(); }, + _showAxes: function(){ + var visible = this.get("axesAreVisible"); + require(['axes'], function(axes){ + axes.setVisibility(visible); + three.render(); + }) + }, + /////////////////////////////////////////////////////////////////////////////// /////////////////////KEY BINDINGS////////////////////////////////////////////// diff --git a/js/plists/CamPList.js b/js/plists/CamPList.js index 063694599e8ce2cb728e734b6661678e8ca7a4cd..fa1a63aab50cf2f1923fb444f24f997972e025db 100644 --- a/js/plists/CamPList.js +++ b/js/plists/CamPList.js @@ -111,8 +111,7 @@ define(['three'], function(THREE){ }, name: "Stock 1", parent: "zAxis", - position: {x:0,y:0,z:0}, - rotation: {x:0, y:0, z:Math.PI/2} + position: {x:0,y:0,z:0} }, stock2: { description:{ @@ -121,8 +120,7 @@ define(['three'], function(THREE){ }, name: "Stock 2", parent: "zAxis", - position: {x:0.236,y:26,z:0}, - rotation: {x:0, y:0, z:Math.PI/2} + position: {x:26,y:0.236,z:0} } }, lattice:{ diff --git a/js/three/Axes.js b/js/three/Axes.js new file mode 100644 index 0000000000000000000000000000000000000000..ffd7759b5400bed01ead7f9936540b5a86565227 --- /dev/null +++ b/js/three/Axes.js @@ -0,0 +1,53 @@ +/** + * 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