Skip to content
Snippets Groups Projects
Commit 76a6c4a5 authored by Amanda Ghassaei's avatar Amanda Ghassaei
Browse files

same geo used for gik of same length

parent 33fe1fd3
No related branches found
No related tags found
No related merge requests found
...@@ -7,7 +7,14 @@ ...@@ -7,7 +7,14 @@
define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'superCell', 'gikCell'], define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'superCell', 'gikCell'],
function(_, THREE, three, lattice, appState, DMASuperCell, GIKCell){ function(_, THREE, three, lattice, appState, DMASuperCell, GIKCell){
var unitGeo = new THREE.BoxGeometry(lattice.xScale(0),lattice.yScale(0),lattice.zScale(0)); var unitGeos = {};
function makePartWithLength(length){
var geo = new THREE.BoxGeometry(lattice.xScale(0),lattice.yScale(0),lattice.zScale(0));
geo.applyMatrix(new THREE.Matrix4().makeScale(length, 1, 1));
geo.applyMatrix(new THREE.Matrix4().makeTranslation(-length/2+0.5, 0, 0));
return geo;
}
GIKSuperCell = function(index, superCell){ GIKSuperCell = function(index, superCell){
DMASuperCell.call(this, index, superCell); DMASuperCell.call(this, index, superCell);
...@@ -24,12 +31,11 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'superCell', ...@@ -24,12 +31,11 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'superCell',
return object3D; return object3D;
}; };
GIKSuperCell.prototype._getGeometry = function(){//todo , do this to mesh? GIKSuperCell.prototype._getGeometry = function(){
var geo = unitGeo.clone();
var length = this.getLength() + 1; var length = this.getLength() + 1;
geo.applyMatrix(new THREE.Matrix4().makeScale(length, 1, 1)); var key = "length"+length;
geo.applyMatrix(new THREE.Matrix4().makeTranslation(-length/2+0.5, 0, 0)); if (!unitGeos[key]) unitGeos[key] = makePartWithLength(length);
return geo; return unitGeos[key];
}; };
GIKSuperCell.prototype._buildWireframe = function(mesh){ GIKSuperCell.prototype._buildWireframe = function(mesh){
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment