Commit dcea419d authored by Amanda Ghassaei's avatar Amanda Ghassaei

lattice aspect ratio moving to plist

parent 42a715a0
...@@ -399,15 +399,15 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'globals', ' ...@@ -399,15 +399,15 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'globals', '
}; };
DMACell.prototype.xScale = function(){ DMACell.prototype.xScale = function(){
return lattice.xScale(0); return lattice.xScale();
}; };
DMACell.prototype.yScale = function(){ DMACell.prototype.yScale = function(){
return lattice.yScale(0); return lattice.yScale();
}; };
DMACell.prototype.zScale = function(){ DMACell.prototype.zScale = function(){
return lattice.zScale(0); return lattice.zScale();
}; };
......
...@@ -10,7 +10,7 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'superCell', ...@@ -10,7 +10,7 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'superCell',
var unitGeos = {}; var unitGeos = {};
function makePartWithLength(length){ function makePartWithLength(length){
var geo = new THREE.BoxGeometry(lattice.xScale(0),lattice.yScale(0),lattice.zScale(0)); var geo = new THREE.BoxGeometry(lattice.xScale(),lattice.yScale(),lattice.zScale());
geo.applyMatrix(new THREE.Matrix4().makeScale(length, 1, 1)); geo.applyMatrix(new THREE.Matrix4().makeScale(length, 1, 1));
geo.applyMatrix(new THREE.Matrix4().makeTranslation(length/2-0.5, 0, 0)); geo.applyMatrix(new THREE.Matrix4().makeTranslation(length/2-0.5, 0, 0));
return geo; return geo;
......
...@@ -23,21 +23,17 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre ...@@ -23,21 +23,17 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
denseCellsMin: null, denseCellsMin: null,
overlapDetected: false, overlapDetected: false,
nodes: [], nodes: []
cellSeparation: {xy:0, z:0}//spacing for connectors/joints
}), }),
__initialize: function(){ __initialize: function(){
//todo change latticeType
this.listenTo(this, "change:partType change:latticeType", this._updatePartType); this.listenTo(this, "change:partType change:latticeType", this._updatePartType);
this.listenTo(this, "change:cellType change:connectionType", function(){ this.listenTo(this, "change:cellType change:connectionType", function(){
this._updateLatticeConfig();//pass no params this._updateLatticeConfig();//pass no params
}); });
this.listenTo(this, "change:latticeType", this._updateLatticeType); this.listenTo(this, "change:latticeType", this._updateLatticeType);
this.listenTo(this, "change:cellSeparation", this._updateCellSeparation);
this.listenTo(appState, "change:currentNav", this._navChanged); this.listenTo(appState, "change:currentNav", this._navChanged);
this.listenTo(this, "change:cellsMin change:cellsMax", function(){ this.listenTo(this, "change:cellsMin change:cellsMax", function(){
...@@ -85,6 +81,10 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre ...@@ -85,6 +81,10 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
var newMaterialClass = (latticeData.materialClasses || _.keys(plist.allMaterialClasses))[0]; var newMaterialClass = (latticeData.materialClasses || _.keys(plist.allMaterialClasses))[0];
appState.set("materialClass", newMaterialClass); appState.set("materialClass", newMaterialClass);
if (latticeData.options){
if (latticeData.options.gikLength) appState.set("gikLength", latticeData.options.gikLength);
}
}, },
_setDefaultCellMode: function(){//if no part associated with this lattice type _setDefaultCellMode: function(){//if no part associated with this lattice type
...@@ -107,25 +107,25 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre ...@@ -107,25 +107,25 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
return subclass; return subclass;
}, },
xScale: function(){
return this.get("aspectRatio").x;
},
yScale: function(){
return this.get("aspectRatio").y;
},
zScale: function(){
return this.get("aspectRatio").z;
},
//events
_updateCellSeparation: function(){
var cellSep = this.get("cellSeparation");
globals.basePlane.updateXYSeparation(cellSep.xy);
var cellMode = appState.get("cellMode"); //events
var partType = this.get("partType");
// this._iterCells(this.cells, function(cell){
// if (cell) cell.updateForScale(cellMode, partType);
// });
three.render();
},
__clearCells: function(silent){ __clearCells: function(silent){
three.removeAllCells();//todo add flag in cell destroy to avoid redundancy here three.removeAllCells();//todo add flag in cell destroy to avoid redundancy here
......
...@@ -28,20 +28,6 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre ...@@ -28,20 +28,6 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
return this._positionForIndex(index); return this._positionForIndex(index);
}, },
xScale: function(cellSeparation){
if (cellSeparation === undefined) cellSeparation = this.get("cellSeparation").xy;
return 1+2*cellSeparation;
},
yScale: function(cellSeparation){
return this.xScale(cellSeparation);
},
zScale: function(cellSeparation){
if (cellSeparation === undefined) cellSeparation = this.get("cellSeparation").z;
return 1+2*cellSeparation;
},
getCellSubclassFile: function(){ getCellSubclassFile: function(){
return "cubeCell"; return "cubeCell";
}, },
......
...@@ -29,20 +29,6 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre ...@@ -29,20 +29,6 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
return this._positionForIndex(index); return this._positionForIndex(index);
}, },
xScale: function(cellSeparation){
if (cellSeparation === undefined) cellSeparation = this.get("cellSeparation").xy;
return 1+2*cellSeparation;
},
yScale: function(cellSeparation){
return this.xScale(cellSeparation);
},
zScale: function(cellSeparation){
if (cellSeparation === undefined) cellSeparation = this.get("cellSeparation").z;
return 1.28*(1+2*cellSeparation);
},
_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;
......
...@@ -36,21 +36,6 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre ...@@ -36,21 +36,6 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
return position; return position;
}, },
xScale: function(cellSeparation){
if (cellSeparation === undefined) cellSeparation = this.get("cellSeparation").xy;
return Math.sqrt(3)+2*cellSeparation;
},
yScale: function(cellSeparation){
if (cellSeparation === undefined) cellSeparation = this.get("cellSeparation").xy;
return 1.5+2*cellSeparation;
},
zScale: function(cellSeparation){
if (cellSeparation === undefined) cellSeparation = this.get("cellSeparation").z;
return 1+2*cellSeparation;
},
getCellSubclassFile: function(){ getCellSubclassFile: function(){
return "hexCell"; return "hexCell";
}, },
......
...@@ -42,21 +42,6 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre ...@@ -42,21 +42,6 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
return position; return position;
}, },
xScale: function(cellSeparation){
if (cellSeparation === undefined) cellSeparation = this.get("cellSeparation").xy;
return 3+2*cellSeparation;
},
yScale: function(cellSeparation){
if (cellSeparation === undefined) cellSeparation = this.get("cellSeparation").xy;
return 1+2*cellSeparation;
},
zScale: function(cellSeparation){
if (cellSeparation === undefined) cellSeparation = this.get("cellSeparation").z;
return Math.sqrt(3)/2+2*cellSeparation;
},
getCellSubclassFile: function(){ getCellSubclassFile: function(){
return "hexRotCell"; return "hexRotCell";
}, },
......
...@@ -29,20 +29,6 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre ...@@ -29,20 +29,6 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
return this._positionForIndex(index); return this._positionForIndex(index);
}, },
xScale: function(cellSeparation){
if (cellSeparation === undefined) cellSeparation = this.get("cellSeparation").xy;
return 2*Math.sqrt(2)+2*cellSeparation;
},
yScale: function(cellSeparation){
return this.xScale(cellSeparation);
},
zScale: function(cellSeparation){
if (cellSeparation === undefined) cellSeparation = this.get("cellSeparation").z;
return 2*Math.sqrt(2)+2*cellSeparation;
},
getCellSubclassFile: function(){ getCellSubclassFile: function(){
return "kelvinCell"; return "kelvinCell";
}, },
......
...@@ -66,20 +66,6 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre ...@@ -66,20 +66,6 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
// return position; // 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").z;
return 2/Math.sqrt(6)+2*cellSeparation;
},
getCellSubclassFile: function(){ getCellSubclassFile: function(){
return "octaEdgeCell"; return "octaEdgeCell";
}, },
......
...@@ -35,20 +35,6 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre ...@@ -35,20 +35,6 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
return position; 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").z;
return 2/Math.sqrt(6)+2*cellSeparation;
},
getCellSubclassFile: function(){ getCellSubclassFile: function(){
return "octaFaceCell"; return "octaFaceCell";
}, },
......
...@@ -39,20 +39,6 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre ...@@ -39,20 +39,6 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
return position; return position;
}, },
xScale: function(cellSeparation){
if (cellSeparation === undefined) cellSeparation = this.get("cellSeparation").xy;
return 1 + 2*cellSeparation;
},
yScale: function(cellSeparation){
return this.xScale(cellSeparation);
},
zScale: function(cellSeparation){
if (cellSeparation === undefined) cellSeparation = this.get("cellSeparation").z;
return Math.sqrt(2)/2 + 2*cellSeparation;
},
getCellSubclassFile: function(){ getCellSubclassFile: function(){
return "octaRotEdgeCell"; return "octaRotEdgeCell";
}, },
......
...@@ -28,20 +28,6 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre ...@@ -28,20 +28,6 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
return this._positionForIndex(index); return this._positionForIndex(index);
}, },
xScale: function(cellSeparation){
if (cellSeparation === undefined) cellSeparation = this.get("cellSeparation").xy;
return Math.sqrt(2)+2*cellSeparation;
},
yScale: function(cellSeparation){
return this.xScale(cellSeparation);
},
zScale: function(cellSeparation){
if (cellSeparation === undefined) cellSeparation = this.get("cellSeparation").z;
return Math.sqrt(2)+2*cellSeparation;
},
getCellSubclassFile: function(){ getCellSubclassFile: function(){
return "octaVertexCell"; return "octaVertexCell";
}, },
......
...@@ -35,20 +35,6 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre ...@@ -35,20 +35,6 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
return position; 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").z;
return 2/Math.sqrt(6)+2*cellSeparation;
},
getCellSubclassFile: function(){ getCellSubclassFile: function(){
return "tetraStackedCell"; return "tetraStackedCell";
}, },
......
...@@ -37,20 +37,6 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre ...@@ -37,20 +37,6 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
return position; 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").z;
return 2/Math.sqrt(6)+2*cellSeparation;
},
getCellSubclassFile: function(){ getCellSubclassFile: function(){
return "tetraVertexCell"; return "tetraVertexCell";
}, },
......
...@@ -29,20 +29,6 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre ...@@ -29,20 +29,6 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
return this._positionForIndex(index); return this._positionForIndex(index);
}, },
xScale: function(cellSeparation){
if (cellSeparation === undefined) cellSeparation = this.get("cellSeparation").xy;
return Math.sqrt(2)+2*cellSeparation;
},
yScale: function(cellSeparation){
return this.xScale(cellSeparation);
},
zScale: function(cellSeparation){
if (cellSeparation === undefined) cellSeparation = this.get("cellSeparation").z;
return Math.sqrt(2)+2*cellSeparation;
},
getCellSubclassFile: function(){ getCellSubclassFile: function(){
return "truncatedCubeCell"; return "truncatedCubeCell";
}, },
......
...@@ -21,9 +21,4 @@ define(['jquery', 'underscore', 'menuParent', 'plist', 'lattice', 'text!latticeM ...@@ -21,9 +21,4 @@ define(['jquery', 'underscore', 'menuParent', 'plist', 'lattice', 'text!latticeM
template: _.template(template) template: _.template(template)
}); });
}); });
\ No newline at end of file
//Cell Separation <% if (connectionType != "freeformFace"){ %>(xy, z): &nbsp;&nbsp;<input data-type="xy" value="<%= cellSeparation.xy %>" placeholder="XY" class="form-control numberInput cellSeparation" type="text">\
//&nbsp;<input data-type="z" value="<%= cellSeparation.z %>" placeholder="Z" class="form-control numberInput cellSeparation" type="text">\
//<% } else { %>( radial ): &nbsp;&nbsp;<input data-type="xy" value="<%= cellSeparation.xy %>" placeholder="XY" class="form-control numberInput cellSeparation" type="text"><% } %>\
//<br/><br/>\
\ No newline at end of file
...@@ -33,8 +33,4 @@ Aspect Ratio:&nbsp;&nbsp; ...@@ -33,8 +33,4 @@ Aspect Ratio:&nbsp;&nbsp;
Part Length:&nbsp;&nbsp;<input data-property="gikLength" value="<%= gikLength %>" placeholder="Length" class="form-control intInput appState" type="text"><br/><br/> Part Length:&nbsp;&nbsp;<input data-property="gikLength" value="<%= gikLength %>" placeholder="Length" class="form-control intInput appState" type="text"><br/><br/>
<% } %> <% } %>
<a href="#" class="clearCells btn btn-block btn-lg btn-danger">Clear All Cells</a><br/> <a href="#" class="clearCells btn btn-block btn-lg btn-danger">Clear All Cells</a><br/>
Num Cells:&nbsp;&nbsp;<%= numCells %><br/> Num Cells:&nbsp;&nbsp;<%= numCells %><br/>
<!--//Cell Separation <% if (connectionType != "freeformFace"){ %>(xy, z): &nbsp;&nbsp;<input data-type="xy" value="<%= cellSeparation.xy %>" placeholder="XY" class="form-control numberInput cellSeparation" type="text">--> \ No newline at end of file
<!--//&nbsp;<input data-type="z" value="<%= cellSeparation.z %>" placeholder="Z" class="form-control numberInput cellSeparation" type="text">-->
<!--//<% } else { %>( radial ): &nbsp;&nbsp;<input data-type="xy" value="<%= cellSeparation.xy %>" placeholder="XY" class="form-control numberInput cellSeparation" type="text"><% } %>-->
<!--//<br/><br/>-->
\ No newline at end of file
...@@ -7,7 +7,4 @@ Part Type: &nbsp;&nbsp; ...@@ -7,7 +7,4 @@ Part Type: &nbsp;&nbsp;
<li><a class="lattice dropdownSelector" data-property="partType" data-value="<%= key %>" href="#"><%= val.name %></a></li> <li><a class="lattice dropdownSelector" data-property="partType" data-value="<%= key %>" href="#"><%= val.name %></a></li>
<% }); %> <% }); %>
</ul> </ul>
</div><br/><br/> </div><br/><br/>
<!--Cell Separation (xy, z): &nbsp;&nbsp;<input data-property="cellSeparation" data-key="xy" value="<%= cellSeparation.xy %>" placeholder="XY" class="form-control floatInput lattice" type="text"> \ No newline at end of file
&nbsp;<input data-property="cellSeparation" data-key="z" value="<%= cellSeparation.z %>" placeholder="Z" class="form-control floatInput lattice" type="text">
<br/><br/>--><br/>
\ No newline at end of file
...@@ -103,13 +103,13 @@ define(['three'], function(THREE){ ...@@ -103,13 +103,13 @@ define(['three'], function(THREE){
name: "Triangle" name: "Triangle"
} }
}, },
aspectRatio: new THREE.Vector3(1,1,1), aspectRatio: new THREE.Vector3(1,1/2*Math.sqrt(3),2/Math.sqrt(6)),
materialClasses: ['mechanical'] materialClasses: ['mechanical']
}, },
default: { default: {
name: "Default", name: "Default",
parts: null, parts: null,
aspectRatio: new THREE.Vector3(1,1,1) aspectRatio: new THREE.Vector3(1,1/2*Math.sqrt(3),2/Math.sqrt(6))
} }
} }
}, },
...@@ -131,13 +131,13 @@ define(['three'], function(THREE){ ...@@ -131,13 +131,13 @@ define(['three'], function(THREE){
name: "Snap Voxel (low res)" name: "Snap Voxel (low res)"
} }
}, },
aspectRatio: new THREE.Vector3(1,1,1), aspectRatio: new THREE.Vector3(1,1,Math.sqrt(2)/2),
materialClasses: ['mechanical'] materialClasses: ['mechanical']
}, },
default: { default: {
name: "Default", name: "Default",
parts: null, parts: null,
aspectRatio: new THREE.Vector3(1,1,1) aspectRatio: new THREE.Vector3(1,1,Math.sqrt(2)/2)
} }
} }
}, },
...@@ -159,13 +159,13 @@ define(['three'], function(THREE){ ...@@ -159,13 +159,13 @@ define(['three'], function(THREE){
} }
// xShape:"X" // xShape:"X"
}, },
aspectRatio: new THREE.Vector3(1,1,1), aspectRatio: new THREE.Vector3(Math.sqrt(2),Math.sqrt(2),Math.sqrt(2)),
materialClasses: ['mechanical'] materialClasses: ['mechanical']
}, },
default: { default: {
name: "Default", name: "Default",
parts: null, parts: null,
aspectRatio: new THREE.Vector3(1,1,1) aspectRatio: new THREE.Vector3(Math.sqrt(2),Math.sqrt(2),Math.sqrt(2))
} }
} }
} }
...@@ -181,11 +181,12 @@ define(['three'], function(THREE){ ...@@ -181,11 +181,12 @@ define(['three'], function(THREE){
default: { default: {
name: "Default", name: "Default",
parts: null, parts: null,
aspectRatio: new THREE.Vector3(1,1,1) aspectRatio: new THREE.Vector3(1,1/2*Math.sqrt(3),2/Math.sqrt(6))
} }
} }
} }
} }
//vetex (1, 1//2*Math.sqrt(3), 2/Math.sqrt(6))
}, },
cube: { cube: {
name: "Cube", name: "Cube",
...@@ -215,8 +216,27 @@ define(['three'], function(THREE){ ...@@ -215,8 +216,27 @@ define(['three'], function(THREE){
name: "Micro LEGO (low res)" name: "Micro LEGO (low res)"
} }
}, },
aspectRatio: new THREE.Vector3(1,1,1.28), aspectRatio: new THREE.Vector3(1,1,5),//1.28
materialClasses: ['electronic'] materialClasses: ['electronic'],
options: {
gikLength: 4
}
},
dnaBricks: {