diff --git a/js/baseplane/OctaBasePlane.js b/js/baseplane/OctaBasePlane.js index 9bed1ab77d5e2e40ff260fcdbd193fa1da0cc147..bc1ca132272b262150618e80d2cc1efb9a160c1f 100644 --- a/js/baseplane/OctaBasePlane.js +++ b/js/baseplane/OctaBasePlane.js @@ -38,10 +38,6 @@ define(['underscore', 'backbone', 'appState', 'lattice', 'threeModel', 'three', return [new THREE.Mesh(geometry, this.get("material"))]; }, - getType: function(){//todo hack from freeform octa, get rid of this eventually - return "octa"; - }, - _renderZIndexChange: function(){ var zIndex = this.get("zIndex"); var xScale = lattice.xScale(); diff --git a/js/cells/DMACellFreeform.js b/js/cells/DMACellFreeform.js deleted file mode 100644 index 9b166f5ae8e30f76e9120648346fc152392d5b49..0000000000000000000000000000000000000000 --- a/js/cells/DMACellFreeform.js +++ /dev/null @@ -1,177 +0,0 @@ -/** - * Created by aghassaei on 4/14/15. - */ - - -/////////////////////////////////////////////////////////////////////////////////////////////// -////////////////////////FREEFORM SUPERCLASS//////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////////////////////// - - -function DMAFreeFormCell(index, parentCellPos, parentCellQuat, direction, parentType){//no rigid lattice structure for cells - this.parentPos = parentCellPos; - this.parentQuaternion = parentCellQuat; - this.parentDirection = direction; - this.parentType = parentType; - DMACell.call(this, index); -} -DMAFreeFormCell.prototype = Object.create(DMACell.prototype); - -DMAFreeFormCell.prototype._calcPosition = function(){//todo this might not be necessary - put in lattice - var position = {}; - var zScale = globals.lattice.zScale(); - position.x = this.parentPos.x+this.parentDirection.x*zScale/2; - position.y = this.parentPos.y+this.parentDirection.y*zScale/2; - position.z = this.parentPos.z+this.parentDirection.z*zScale/2; - return position; -}; - -DMAFreeFormCell.prototype.calcHighlighterPosition = function(face){ - //var direction = face.normal.clone().applyEuler(this.mesh.rotation); - var direction = face.normal.clone(); - direction.applyQuaternion(this.mesh.quaternion); - var position = this.getPosition(); - position.add(direction.clone().multiplyScalar(this.zScale()/2)); - return {index: _.clone(this.index), direction:direction, position:position}; -}; - -DMAFreeFormCell.prototype.toJSON = function(){ - var json = DMACell.prototype.toJSON.call(this); - _.extend(json, { - parentPosition: this.parentPos, - parentOrientation: this.parentQuaternion, - direction: this.parentDirection, - parentType: this.parentType, - type: this.getType() - }); - return json; -}; - - - -/////////////////////////////////////////////////////////////////////////////////////////////// -////////////////////////OCTA/////////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////////////////////// - - -function DMAFreeFormOctaCell(index, parentCellPos, parentCellQuat, direction, parentType){ - DMAFreeFormCell.call(this, index, parentCellPos, parentCellQuat, direction, parentType); -} -DMAFreeFormOctaCell.prototype = Object.create(DMAFreeFormCell.prototype); - -DMAFreeFormOctaCell.prototype._doMeshTransformations = function(mesh){ - - if (!this.parentDirection) { - this.parentDirection = new THREE.Vector3(0,0,1); - this.parentQuaternion = new THREE.Quaternion(); - this.parentPos = new THREE.Vector3(0,0,0); - } - 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); - console.log(quaternion.clone()); - quaternion.multiply(this.parentQuaternion); - - var zAlignment = direction.sub(zAxis).length(); - if ((this.parentType == "octa" && zAlignment < 0.1) || this.parentType == "tetra"){ - console.log("yes"); - var zRot = new THREE.Quaternion().setFromAxisAngle(this.parentDirection, Math.PI); - zRot.multiply(quaternion); - quaternion = zRot; - } - - mesh.quaternion.set(quaternion.x, quaternion.y, quaternion.z, quaternion.w); -}; - -DMAFreeFormOctaCell.prototype._initParts = function(){ - var parts = []; - parts.push(new DMAOctaTroxPart(1, this)); - return parts; -}; - -DMAFreeFormOctaCell.prototype.getType = function(){ - return "octa"; -}; - -DMAFreeFormOctaCell.prototype._getGeometry = function(){ - return unitFaceOctaGeo; -}; - -DMAFreeFormOctaCell.prototype.xScale = function(){ - return 1; -}; - -DMAFreeFormOctaCell.prototype.yScale = function(){ - return this.xScale()/2*Math.sqrt(3); -}; - -DMAFreeFormOctaCell.prototype.zScale = function(){ - return 2/Math.sqrt(6); -}; - - - - -/////////////////////////////////////////////////////////////////////////////////////////////// -////////////////////////TETRA////////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////////////////////// - - -var unitCellGeo2 = new THREE.TetrahedronGeometry(Math.sqrt(3/8)); -unitCellGeo2.applyMatrix(new THREE.Matrix4().makeRotationZ(Math.PI/4)); -unitCellGeo2.applyMatrix(new THREE.Matrix4().makeRotationX((Math.PI-Math.atan(2*Math.sqrt(2)))/2)); - -function DMAFreeFormTetraCell(index, parentCellPos, parentCellQuat, direction, parentType){ - DMAFreeFormCell.call(this, index, parentCellPos, parentCellQuat, direction, parentType); -} -DMAFreeFormTetraCell.prototype = Object.create(DMAFreeFormCell.prototype); - -DMAFreeFormTetraCell.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); - - var zComponent = direction.sub(zAxis).length(); - console.log(zComponent); - console.log(new THREE.Euler().setFromQuaternion(quaternion)); - if (zComponent >= 1){ - console.log("yes"); - console.log(""); - 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.getType = function(){ - return "tetra"; -}; - -DMAFreeFormTetraCell.prototype._initParts = function(){ - var parts = []; - parts.push(new DMATetraTroxPart(1, this)); - return parts; -}; - -DMAFreeFormTetraCell.prototype.xScale = function(){ - return 1; -}; - -DMAFreeFormTetraCell.prototype.yScale = function(){ - return this.xScale()/2*Math.sqrt(3); -}; - -DMAFreeFormTetraCell.prototype.zScale = function(){ - return 2/Math.sqrt(24); -}; - -DMAFreeFormTetraCell.prototype._getGeometry = function(){ - return unitCellGeo2; -}; - diff --git a/js/highlighter/Highlighter.js b/js/highlighter/Highlighter.js index 411dbcb39523c754c5c78eaefb14c1e4ada2d98a..839d77a4ae7d3fe4fca5cb012f02bd7edf876aad 100644 --- a/js/highlighter/Highlighter.js +++ b/js/highlighter/Highlighter.js @@ -132,11 +132,6 @@ define(['underscore', 'backbone', 'threeModel', 'appState', 'lattice', 'cell', ' addRemoveVoxel: function(shouldAdd){ if (shouldAdd){ if (!this.isVisible() || !this.highlightedObject) return; - if (lattice.get("connectionType") == "freeformFace"){ - //todo make this work for baseplane - lattice.addFreeFormCell(this.mesh.position.clone(), this.highlightedObject.getOrientation(), this.direction, this.highlightedObject.getType()); - return; - } lattice.addCellAtIndex(this._getNextCellPosition()); } else { if (!this.highlightedObject) return; diff --git a/js/lattice/Lattice.js b/js/lattice/Lattice.js index b17a97d63c780f181a15526e260f3c2cdf1547c4..569f79e420213dc59eed71cf07b21a8ed6e8686e 100644 --- a/js/lattice/Lattice.js +++ b/js/lattice/Lattice.js @@ -374,18 +374,18 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre _updateLatticeType: function(loadingFromFile){//do not clear cells if loading from file (cells array contains important metadata) - if (this.previous("connectionType") == "gik") this.clearCells(); - this._setToDefaultsSilently(); this._setDefaultCellMode(); if (loadingFromFile === undefined) loadingFromFile = false; + if (loadingFromFile) console.warn('loading from file'); + this.clearCells(); if (this._undo) this._undo(); if (globals.basePlane) globals.basePlane.destroy(); if (globals.highlighter) globals.highlighter.destroy(); - var subclass = this._getSubclassForLatticeType(loadingFromFile); + var subclass = this._getSubclassForLatticeType(); var self = this; require([subclass], function(subclassObject){ @@ -404,15 +404,12 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre }); }, - _getSubclassForLatticeType: function(loadingFromFile){ + _getSubclassForLatticeType: function(){ var cellType = this.get("cellType"); var connectionType = this.get("connectionType"); if (cellType == "octa"){ if (connectionType == "face"){ return "octaFaceLattice"; - } else if (connectionType == "freeformFace"){ - if (!loadingFromFile) this.clearCells(); - return "octaFreeFormFaceLattice"; } else if (connectionType == "edge"){ return "octaEdgeLattice"; } else if (connectionType == "edgeRot"){ @@ -426,7 +423,6 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre if (connectionType == "face"){ return "cubeLattice"; } else if (connectionType == "gik"){ - if (!loadingFromFile) this.clearCells(); return "gikLattice"; } } else if (cellType == "truncatedCube"){ diff --git a/js/lattice/OctaFreeFormFaceLattice.js b/js/lattice/OctaFreeFormFaceLattice.js deleted file mode 100644 index dff105fe61bcde56825102f7080844e4ff650738..0000000000000000000000000000000000000000 --- a/js/lattice/OctaFreeFormFaceLattice.js +++ /dev/null @@ -1,80 +0,0 @@ -/** - * Created by aghassaei on 5/26/15. - */ - -define(['underscore', 'backbone', 'appState', 'lattice', 'globals', 'plist', 'three', 'threeModel'], - function(_, Backbone, appState, lattice, globals, plist, THREE, three){ - - var OctaFreeFormFaceLattice = { - - _initLatticeType: function(){ - require(['octaBaseplane'], function(OctaBasePlane){ - globals.basePlane = new OctaBasePlane(); - }); - require(['defaultHighlighter'], function(DefaultHighlighter){ - globals.highlighter = new DefaultHighlighter(); - }); - this.set("freeformCellType", "octa"); - }, - - addFreeFormCell: function(parentCellPos, parentCellOrient, direction, parentType, type){ - var cells = this.get("cells"); - cells[0][0].push(this.makeCellForLatticeType({x:0,y:0,z:cells[0][0].length}, parentCellPos, parentCellOrient, direction, parentType, type)); - this.set("numCells", this.get("numCells")+1); - globals.three.render(); - }, - - makeCellForLatticeType: function(index, parentPosition, parentOrientation, direction, parentType, type){ - if (type){ - if (type == "octa") return new DMAFreeFormOctaCell(index, parentPosition, parentOrientation, direction, parentType); - return new DMAFreeFormTetraCell(index, parentPosition, parentOrientation, direction, parentType); - } - if (this.get("freeformCellType") == "octa") return new DMAFreeFormOctaCell(index, parentPosition, parentOrientation, direction, parentType); - return new DMAFreeFormTetraCell(index, parentPosition, parentOrientation, direction, parentType); - }, - - getIndexForPosition: function(absPosition){//only used by baseplane - var yIndex = Math.floor(absPosition.y/this.yScale()); - if (yIndex%2 != 0) absPosition.x += this.xScale()/2; - var index = this._indexForPosition(absPosition); - if (index.z%2 == 1) index.y += 1; - return index; - }, - - getPositionForIndex: function(index){//only used by baseplane - var position = _.clone(index); - var xScale = this.xScale(); - position.x = (position.x+1/2)*xScale; - position.y = position.y*this.yScale()+1/Math.sqrt(3)/2; - position.z = (position.z+0.5)*this.zScale(); - if ((index.y%2) != 0) position.x -= xScale/2; - return position; - }, - - xScale: function(cellSeparation){ - if (cellSeparation === undefined) cellSeparation = this.get("cellSeparation").xy; - return 1+2*cellSeparation; - }, - - yScale: function(cellSeparation){ - return this.xScale(cellSeparation)/2*Math.sqrt(3); - }, - - zScale: function(cellSeparation){ - if (cellSeparation === undefined) cellSeparation = this.get("cellSeparation").xy;//todo xy? - if (this.get("freeformCellType") == "octa") return 2/Math.sqrt(6)+2*cellSeparation; - return 2/Math.sqrt(24)+2*cellSeparation; - }, - - _undo: function(){//remove all the mixins - var self = this; - this.set("freeformCellType", null);//todo get rid of this property - this.clearCells(); - _.each(_.keys(OctaFreeFormFaceLattice), function(key){ - self[key] = null; - }); - } - }; - - return OctaFreeFormFaceLattice; -}); \ No newline at end of file diff --git a/js/main.js b/js/main.js index 1182e50b15d1e747fb1e9370d3ca060ba20a3787..308ea6739b781983980f937252dd4e151b40557d 100644 --- a/js/main.js +++ b/js/main.js @@ -32,7 +32,6 @@ require.config({ kelvinLattice: 'lattice/KelvinLattice', octaEdgeLattice: 'lattice/OctaEdgeLattice', octaFaceLattice: 'lattice/OctaFaceLattice', - octaFreeFormFaceLattice: 'lattice/OctaFreeFormFaceLattice', octaRotEdgeLattice: 'lattice/OctaRotEdgeLattice', octavertexLattice: 'lattice/OctaVertexLattice', truncatedCubeLattice: 'lattice/TruncatedCubeLattice', diff --git a/js/menus/LatticeMenuView.js b/js/menus/LatticeMenuView.js index 42b00e67a4fb67a2106f9d979c5530bac3bc205f..1d75d2afb731cb91589fddb208e9b32bc51e0fb6 100644 --- a/js/menus/LatticeMenuView.js +++ b/js/menus/LatticeMenuView.js @@ -37,17 +37,6 @@ define(['jquery', 'underscore', 'menuParent', 'plist', 'lattice'], function($, _ <% }); %>\ </ul>\ </div><br/><br/>\ - <% if (connectionType == "freeformFace") { %>\ - Current Draw Shape: \ - <div class="btn-group">\ - <button data-toggle="dropdown" class="btn dropdown-toggle" type="button"><%= freeformCellType %><span class="caret"></span></button>\ - <ul role="menu" class="dropdown-menu">\ - <li><a class="lattice dropdownSelector" data-property="freeformCellType" data-value="octa" href="#">octa</a></li>\ - <li><a class="lattice dropdownSelector" data-property="freeformCellType" data-value="tetra" href="#">tetra</a></li>\ - </ul>\ - </div>\ - <br/><br/>\ - <% } %>\ <% if (connectionType == "gik") { %>\ GIK Length: <input data-property="superCellRange" data-key="x" value="<%= superCellRange.x %>" placeholder="GIK length" class="form-control intInput lattice" type="text"><br/>\ <br/>\ diff --git a/js/menus/PartMenuView.js b/js/menus/PartMenuView.js index ddf94a70597b914e422f32815cf85781dc49e08b..9852a6578e0c7234df495e347c6bdf8b6b9692ba 100644 --- a/js/menus/PartMenuView.js +++ b/js/menus/PartMenuView.js @@ -29,9 +29,8 @@ define(['jquery', 'underscore', 'menuParent', 'plist', 'lattice'], function($, _ <% }); %>\ </ul>\ </div><br/><br/>\ - <!--Cell Separation <% if (connectionType != "freeformFace"){ %>(xy, z): <input data-property="cellSeparation" data-key="xy" value="<%= cellSeparation.xy %>" placeholder="XY" class="form-control floatInput lattice" type="text">\ + <!--Cell Separation (xy, z): <input data-property="cellSeparation" data-key="xy" value="<%= cellSeparation.xy %>" placeholder="XY" class="form-control floatInput lattice" type="text">\ <input data-property="cellSeparation" data-key="z" value="<%= cellSeparation.z %>" placeholder="Z" class="form-control floatInput lattice" type="text">\ - <% } else { %>( radial ): <input data-property="cellSeparation" data-key="xy" value="<%= cellSeparation.xy %>" placeholder="XY" class="form-control floatInput lattice" type="text"><% } %>\ <br/><br/>--><br/>\ <% if (allMaterialTypes[cellType][connectionType]){ %> \ Materials:<br/>\ diff --git a/js/models/PList.js b/js/models/PList.js index b19973349df997734172545e1108acb6af460142..071f2fee911600a67ce58227e4e357aae62ace7c 100644 --- a/js/models/PList.js +++ b/js/models/PList.js @@ -46,9 +46,6 @@ define(['three'], function(THREE){ face: { triangle:"Triangle" }, - freeformFace: { - trox:"Troxes" - }, edge: null, edgeRot: { vox: "Snap Voxel (high res)", @@ -78,7 +75,6 @@ define(['three'], function(THREE){ allMaterialTypes:{ octa:{ face: null, - freeformFace: null, edge: null, edgeRot: null, vertex: null @@ -134,7 +130,6 @@ define(['three'], function(THREE){ allMachineTypes:{ octa:{ face: {handOfGod: "Hand of God"}, - freeformFace: {handOfGod: "Hand of God"}, edgeRot: { shopbot: "Shopbot", oneBitBot: "One Bit Bot",