diff --git a/js/fea/DmaCell.js b/js/fea/DmaCell.js index 26d0418bca0156d68a850e496b6260a8c05b500f..77d893ca46d64cf1c669cfb5d9259ea106679a9f 100644 --- a/js/fea/DmaCell.js +++ b/js/fea/DmaCell.js @@ -382,6 +382,63 @@ DMACell.prototype.toJSON = function(){ +// var unitCellGeo3 = new THREE.TetrahedronGeometry(Math.sqrt(3/8)); +// unitCellGeo3.applyMatrix(new THREE.Matrix4().makeRotationZ(Math.PI/4)); +// unitCellGeo3.applyMatrix(new THREE.Matrix4().makeRotationX((Math.PI-Math.atan(2*Math.sqrt(2)))/2)); +// unitCellGeo3.applyMatrix(new THREE.Matrix4().makeScale(1,1,2/3)); +// +// function DMAFreeFormSquashedTetraCell(indices, scale, parentCellPos, parentCellQuat, direction, parentType){ +// DMAFreeFormTetraCell.call(this, indices, scale, parentCellPos, parentCellQuat, direction, parentType); +// } +// DMAFreeFormSquashedTetraCell.prototype = Object.create(DMAFreeFormTetraCell.prototype); +// +// DMAFreeFormSquashedTetraCell.prototype._buildCellMesh = function(){//abstract mesh representation of cell +// return this._superBuildCellMesh(unitCellGeo3); +// }; +// +// DMAFreeFormSquashedTetraCell.prototype._doMeshTransformations = function(mesh){ +// var direction = this.parentDirection.clone(); +// var zAxis = new THREE.Vector3(0,0,1); +// zAxis.applyQuaternion(this.parentQuaternion); +// var quaternion = new THREE.Quaternion().setFromUnitVectors(zAxis, direction); +// quaternion.multiply(this.parentQuaternion); +// +// if (this.parentType == "octa" && direction.sub(zAxis).length() > 0.1){//only do this if connecting to octa +// var zRot = new THREE.Quaternion().setFromAxisAngle(this.parentDirection, Math.PI); +// zRot.multiply(quaternion); +// quaternion = zRot; +// } +// +// var eulerRot = new THREE.Euler().setFromQuaternion(quaternion); +// mesh.rotation.set(eulerRot.x, eulerRot.y, eulerRot.z); +// }; +// +// DMAFreeFormTetraCell.prototype.calcHighlighterPosition = function(face){ +// +// var direction = face.normal.clone(); +// direction.applyQuaternion(this.cellMesh.quaternion); +// +// var position = this.getPosition(); +// var zScale = this.zScale()*3/2; +// position.x += direction.x*zScale/2; +// position.y += direction.y*zScale/2; +// position.z += direction.z*zScale/2; +// +// return {index: _.clone(this.indices), direction:direction, position:position}; +// }; +// +// DMAFreeFormSquashedTetraCell.prototype.zScale = function(scale){ +// if (!scale) scale = dmaGlobals.lattice.get("scale"); +// return 2*scale/Math.sqrt(24)*2/3; +// }; +// +// DMAFreeFormSquashedTetraCell.prototype.getType = function(){ +// return "squashedTetra"; +// }; +// self.DMAFreeFormSquashedTetraCell = DMAFreeFormSquashedTetraCell; + + + function DMATetraEdgeCell(indices, scale){ DMATetraFaceCell.call(this, indices, scale, true); } diff --git a/js/menus/LatticeMenuView.js b/js/menus/LatticeMenuView.js index d2dc2f06477f626b84d9fd09202b525da8c8002f..9dc9c7ccb257a4bc219bd5d06dbd4c7472c5032d 100644 --- a/js/menus/LatticeMenuView.js +++ b/js/menus/LatticeMenuView.js @@ -17,7 +17,8 @@ LatticeMenuView = Backbone.View.extend({ "change #preserveCells": "_changePreserveCells", "change #showInverse": "_showInverseCells", "click #freeformTetraCell": "_setTetraCell", - "click #freeformOctaCell": "_setOctaCell" + "click #freeformOctaCell": "_setOctaCell", + "click #freeformSquasehdTetraCell": "_setSquashedTetraCell" }, @@ -119,6 +120,11 @@ LatticeMenuView = Backbone.View.extend({ this.lattice.set("freeformCellType", "tetra"); }, + _setSquashedTetraCell: function(e){ + e.preventDefault(); + this.lattice.set("freeformCellType", "squashedTetra"); + }, + _setOctaCell: function(e){ e.preventDefault(); this.lattice.set("freeformCellType", "octa"); @@ -161,6 +167,7 @@ LatticeMenuView = Backbone.View.extend({ <ul role="menu" class="dropdown-menu">\ <li><a id="freeformOctaCell" href="#">octa</a></li>\ <li><a id="freeformTetraCell" href="#">tetra</a></li>\ + <li><a id="freeformSquasehdTetraCell" href="#">squashedTetra</a></li>\ </ul>\ </div><br/>\ <% } else { %>\ diff --git a/js/models/Lattice.js b/js/models/Lattice.js index 366a394ab695e1244bbc2871c7e85f0be71fe9c7..5790d15ee4a702d7a4a46ed2f31fee0c4e4e9743 100644 --- a/js/models/Lattice.js +++ b/js/models/Lattice.js @@ -664,9 +664,11 @@ Lattice = Backbone.Model.extend({ if (type){ if (type == "octa") return new DMAFreeFormOctaCell(index, scale, parentPosition, parentOrientation, direction, parentType); return new DMAFreeFormTetraCell(index, scale, parentPosition, parentOrientation, direction, parentType); +// return new DMAFreeFormSquashedTetraCell(index, scale, parentPosition, parentOrientation, direction, parentType); } if (this.get("freeformCellType") == "octa") return new DMAFreeFormOctaCell(index, scale, parentPosition, parentOrientation, direction, parentType); return new DMAFreeFormTetraCell(index, scale, parentPosition, parentOrientation, direction, parentType); +// return new DMAFreeFormSquashedTetraCell(index, scale, parentPosition, parentOrientation, direction, parentType); }, getIndexForPosition: function(absPosition){//only used by baseplane @@ -701,7 +703,7 @@ Lattice = Backbone.Model.extend({ zScale: function(scale){ if (!scale) scale = this.get("scale"); - if (this.get("freeformCellType") == "octa") return 2*scale/Math.sqrt(6); +// if (this.get("freeformCellType") == "octa") return 2*scale/Math.sqrt(6); return 2*scale/Math.sqrt(24); }, diff --git a/main.html b/main.html index 8b621e7d2d58a39a6af9b358a62cda02244529f4..394f8027c10d2a0254200e68cadf93fa8f8f1b1d 100644 --- a/main.html +++ b/main.html @@ -98,9 +98,8 @@ <li><a id="saveJSON" href="#">Save JSON     (CTRL/⌘ + S)</a></li> <li><a data-toggle="modal" data-target="#saveAsModel" href="#">Save JSON As...     (CTRL/⌘ + Shift + S)</a></li> <li><a id="importJSON" href="#">Open JSON     (CTRL/⌘ + O)</a></li> - <li><a id="exportSTL" href="#">Export STL</a></li> <li class="divider"></li> - <li><a href="#">Separated link</a></li> + <li><a id="exportSTL" href="#">Export STL</a></li> </ul> </li> <li><a data-menu-id="about" class="menuHoverControls" href="#">About</a></li>