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

working through gik cell

parent 968b5ca0
No related branches found
No related tags found
No related merge requests found
......@@ -27,7 +27,7 @@ DMACell.prototype._getSceneType = function(){//todo need this?
DMACell.prototype._buildObject3D = function(){
var object3D = this._translateCell(this._rotateCell(new THREE.Object3D()));
object3D.myParent = this;//reference to get mouse raycasting back
object3D.name = "object3d";
object3D.name = "object3D";
return object3D;
};
......
......@@ -6,23 +6,28 @@
(function () {
function GIKCell(indices){
this.superCell = true;
CubeCell.call(this, indices, true);
this.indices = indices;
}
GIKCell.prototype = Object.create(CubeCell.prototype);
GIKCell.prototype.setSuperCell = function(superCell, index){
this.superCell = superCell;
this.superCellIndex = index;
CubeCell.call(this, this.indices);
if (this.superCellIndex == this.superCell.getLength()) this.object3D.rotateZ(Math.PI);
};
GIKCell.prototype._translateCell = function(object3D){
if (this.superCellIndex) object3D.position.set(-this.superCellIndex*this.xScale(),0, 0);
return object3D;
};
GIKCell.prototype.getMaterialType = function(){
return this.superCell.getMaterialType();
};
GIKCell.prototype._initParts = function(){
if (!this.superCell || this.superCell === true) return null;
if (!this.superCell) return null;
var parts = [];
var isEnd = this.superCellIndex == 0 || this.superCellIndex == this.superCell.getLength();
if (globals.lattice.get("partType") == "lego") {
......
......@@ -13,7 +13,7 @@ GIKSuperCell = function(length, range, cells){
this.object3D = this._buildObject3D();
this._addChildren(this._buildMesh(length), this.object3D);
this._addChildren(this._getCellObject3Ds(cells));
globals.three.sceneAdd(this.object3D, this._getSceneType());
// this.setMode();
......@@ -30,10 +30,16 @@ GIKSuperCell.prototype._buildObject3D = function(){
return this._translateCell(this._rotateCell(new THREE.Object3D()));
};
GIKSuperCell.prototype.addCellsToScene = function(){
this._addChildren(this._getCellObject3Ds(this.cells));
};
GIKSuperCell.prototype._getCellObject3Ds = function(cells){
var object3Ds = [];
var self = this;
_.each(cells, function(cell){
object3Ds.push(cell.getObject3D());
var object3D = cell.getObject3D();
object3Ds.push(object3D);
});
return object3Ds;
};
......@@ -76,28 +82,7 @@ GIKSuperCell.prototype.setMode = function(mode){
if (mode === undefined) mode = globals.appState.get("cellMode");
if (mode == "cell") mode = "supercell";
switch(mode) {
case "supercell":
break;
case "cell":
break;
case "part":
if (!this.parts) {
this.parts = this._initParts();
var self = this;
_.each(this.parts, function(part){
self._addChildren(part.getMesh());
});
}
break;
case "beam":
if (!this.beams) this.beams = this._initBeams();
break;
case "node":
if (!this.nodes) this.nodes = this._initNodes();
break;
}
if (mode == "part") mode = "object3D";
_.each(this.object3D.children, function(child){
child.visible = child.name == mode;
......
......@@ -52,6 +52,7 @@ latticeSubclasses["GIKLattice"] = {
_.each(cells, function(cell, index){
cell.setSuperCell(superCell, index);
});
superCell.addCellsToScene();
return superCell;
},
......
......@@ -59,7 +59,7 @@ function ThreeModel(){
cells.push(object.children[0]);
} else if (type == "supercell"){
_.each(object.children, function(child){//add cells as hover
if (child.name != "object3d") return;
if (child.name != "object3D") return;
cells.push(child.children[0]);
});
} else if (type == "part"){//todo change this
......
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