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', '
};
DMACell.prototype.xScale = function(){
return lattice.xScale(0);
return lattice.xScale();
};
DMACell.prototype.yScale = function(){
return lattice.yScale(0);
return lattice.yScale();
};
DMACell.prototype.zScale = function(){
return lattice.zScale(0);
return lattice.zScale();
};
......
......@@ -10,7 +10,7 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'superCell',
var unitGeos = {};
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().makeTranslation(length/2-0.5, 0, 0));
return geo;
......
......@@ -23,21 +23,17 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
denseCellsMin: null,
overlapDetected: false,
nodes: [],
cellSeparation: {xy:0, z:0}//spacing for connectors/joints
nodes: []
}),
__initialize: function(){
//todo change latticeType
this.listenTo(this, "change:partType change:latticeType", this._updatePartType);
this.listenTo(this, "change:cellType change:connectionType", function(){
this._updateLatticeConfig();//pass no params
});
this.listenTo(this, "change:latticeType", this._updateLatticeType);
this.listenTo(this, "change:cellSeparation", this._updateCellSeparation);
this.listenTo(appState, "change:currentNav", this._navChanged);
this.listenTo(this, "change:cellsMin change:cellsMax", function(){
......@@ -85,6 +81,10 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
var newMaterialClass = (latticeData.materialClasses || _.keys(plist.allMaterialClasses))[0];
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
......@@ -107,25 +107,25 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
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");
var partType = this.get("partType");
// this._iterCells(this.cells, function(cell){
// if (cell) cell.updateForScale(cellMode, partType);
// });
three.render();
},
//events
__clearCells: function(silent){
three.removeAllCells();//todo add flag in cell destroy to avoid redundancy here
......
......@@ -28,20 +28,6 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
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(){
return "cubeCell";
},
......
......@@ -29,20 +29,6 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
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){
if (index.z%2 == 0) return Math.PI/2;
return 0;
......
......@@ -36,21 +36,6 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
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(){
return "hexCell";
},
......
......@@ -42,21 +42,6 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
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(){
return "hexRotCell";
},
......
......@@ -29,20 +29,6 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
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(){
return "kelvinCell";
},
......
......@@ -66,20 +66,6 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
// 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(){
return "octaEdgeCell";
},
......
......@@ -35,20 +35,6 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
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(){
return "octaFaceCell";
},
......
......@@ -39,20 +39,6 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
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(){
return "octaRotEdgeCell";
},
......
......@@ -28,20 +28,6 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
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(){
return "octaVertexCell";
},
......
......@@ -35,20 +35,6 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
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(){
return "tetraStackedCell";
},
......
......@@ -37,20 +37,6 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
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(){
return "tetraVertexCell";
},
......
......@@ -29,20 +29,6 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
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(){
return "truncatedCubeCell";
},
......
......@@ -21,9 +21,4 @@ define(['jquery', 'underscore', 'menuParent', 'plist', 'lattice', 'text!latticeM
template: _.template(template)
});
});
//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
});
\ No newline at end of file
......@@ -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/>
<% } %>
<a href="#" class="clearCells btn btn-block btn-lg btn-danger">Clear All Cells</a><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">-->
<!--//&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
Num Cells:&nbsp;&nbsp;<%= numCells %><br/>
\ No newline at end of file
......@@ -7,7 +7,4 @@ Part Type: &nbsp;&nbsp;
<li><a class="lattice dropdownSelector" data-property="partType" data-value="<%= key %>" href="#"><%= val.name %></a></li>
<% }); %>
</ul>
</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">
&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
</div><br/><br/>
\ No newline at end of file
......@@ -103,13 +103,13 @@ define(['three'], function(THREE){
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']
},
default: {
name: "Default",
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){
name: "Snap Voxel (low res)"
}
},
aspectRatio: new THREE.Vector3(1,1,1),
aspectRatio: new THREE.Vector3(1,1,Math.sqrt(2)/2),
materialClasses: ['mechanical']
},
default: {
name: "Default",
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){
}
// xShape:"X"
},
aspectRatio: new THREE.Vector3(1,1,1),
aspectRatio: new THREE.Vector3(Math.sqrt(2),Math.sqrt(2),Math.sqrt(2)),
materialClasses: ['mechanical']
},
default: {
name: "Default",
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){
default: {
name: "Default",
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: {
name: "Cube",
......@@ -215,8 +216,27 @@ define(['three'], function(THREE){
name: "Micro LEGO (low res)"
}
},
aspectRatio: new THREE.Vector3(1,1,1.28),
materialClasses: ['electronic']
aspectRatio: new THREE.Vector3(1,1,5),//1.28
materialClasses: ['electronic'],
options: {
gikLength: 4
}
},
dnaBricks: {
name: "DNA Bricks",
parts: {
dnaLego: {
name: "Lego Blocks"
},
dnaStraight: {
name: "DNA (straight chains)"
}
},
aspectRatio: new THREE.Vector3(1,1,1),
materialClasses: ['mechanical'],
options: {
gikLength: 2
}
},
default: {
name: "Default",
......@@ -237,7 +257,7 @@ define(['three'], function(THREE){
default: {
name: "Default",
parts: null,
aspectRatio: new THREE.Vector3(1,1,1)
aspectRatio: new THREE.Vector3(Math.sqrt(2),Math.sqrt(2),Math.sqrt(2))
}
}
}
......@@ -253,7 +273,7 @@ define(['three'], function(THREE){
default: {
name: "Default",
parts: null,
aspectRatio: new THREE.Vector3(1,1,1)
aspectRatio: new THREE.Vector3(2*Math.sqrt(2),2*Math.sqrt(2),2*Math.sqrt(2))
}
}
}
......@@ -269,7 +289,7 @@ define(['three'], function(THREE){
default: {
name: "Default",
parts: null,
aspectRatio: new THREE.Vector3(1,1,1)
aspectRatio: new THREE.Vector3(Math.sqrt(3),1.5,1)
}
}
},
......@@ -280,7 +300,7 @@ define(['three'], function(THREE){
default: {
name: "Default",
parts: null,
aspectRatio: new THREE.Vector3(1,1,1)
aspectRatio: new THREE.Vector3(3,1,Math.sqrt(3)/2)
}
}
}
......
......@@ -104,7 +104,7 @@ define(['lattice', 'appState', 'three', 'threeModel', 'numeric', 'eSim', 'eSimFi
}
});
var offset = this.get("cellsMin").clone().sub(new THREE.Vector3(1/(2*resolution)+this.xScale(0)/2, 1/(2*resolution)+this.yScale(0)/2, 1/(2*resolution)+this.zScale(0)/2));
var offset = this.get("cellsMin").clone().sub(new THREE.Vector3(1/(2*resolution)+this.xScale()/2, 1/(2*resolution)+this.yScale()/2, 1/(2*resolution)+this.zScale()/2));
var dataRange = [];
_.each(conductorGroups, function(group){
dataRange.push(group.voltage);
......
Markdown is supported
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