Newer
Older
define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'superCell', 'gikCell'],
function(_, THREE, three, lattice, appState, DMASuperCell, GIKCell){
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));
function GIKSuperCell(json, superCell){
this.length = json.length || appState.get("superCellRange").x;
GIKSuperCell.prototype = Object.create(DMASuperCell.prototype);
GIKSuperCell.prototype._getSuperCellRange = function(){
if (this.length) return new THREE.Vector3(this.length, 1, 1);
console.warn("no length property for gik super cell");
return null;
};
GIKSuperCell.prototype._makeSubCellForIndex = function(json, callback){
if (this.index.z%2 != 0) object3D.rotateZ(Math.PI/2);
GIKSuperCell.prototype.getLength = function(){
return this.length;
};
GIKSuperCell.prototype._getGeometry = function(){
var key = "length"+this.length;
if (!unitGeos[key]) unitGeos[key] = makePartWithLength(this.length);
};
GIKSuperCell.prototype._buildWireframe = function(mesh){
var wireframe = new THREE.BoxHelper(mesh);
wireframe.material.color.set(0x000000);
wireframe.matrixWorld = mesh.matrixWorld;
wireframe.matrixAutoUpdate = true;
return wireframe;
};
GIKSuperCell.prototype._getMeshName = function(){
return "cell";
};
GIKSuperCell.prototype._isMiddleLayer = function(){
return false;
};
GIKSuperCell.prototype._isTopLayerCell = function(){
return this.superCell === null || this.superCell === undefined;
};
var data = DMASuperCell.prototype.toJSON.call(this);
if (!this.length) console.warn("no length assigned to gik supercell");
data.length = this.length;
return data;
};
GIKSuperCell.prototype.destroy = function(){
DMASuperCell.prototype.destroy.call(this);
this.length = null;