diff --git a/js/cells/DMACell.js b/js/cells/DMACell.js index e8fadf15227fe6f0efb7133952265370a714c315..7ab6ea12be92629714b6533c30a3ccee495a1c44 100644 --- a/js/cells/DMACell.js +++ b/js/cells/DMACell.js @@ -342,9 +342,8 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'globals'], }; DMACell.prototype.destroyParts = function(){ - if (!this.parts && !this.cells) return; if (this.cells){ - _.each(this.cells, function(cell){ + this._loopCells(function(cell){ if (cell) cell.destroyParts(); }); return; diff --git a/js/cells/GIKCell.js b/js/cells/GIKCell.js index 64fe2ca20cb21c83c8649790c8118f2e7c803f99..2c8bf84e67fffa6bd5ab47e2507e2e9a0f1b1dd5 100644 --- a/js/cells/GIKCell.js +++ b/js/cells/GIKCell.js @@ -23,7 +23,7 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'cubeCell'], return null; }; - GIKCell.prototype._initParts = function(){ + GIKCell.prototype._initParts = function(callback){ if (!this.superCell) return; var self = this; var parts = []; @@ -34,14 +34,14 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'cubeCell'], for (var i=0;i<length;i++){ parts.push(new GIKPart(i, self)); } - self.parts = parts; + callback(parts); }); } else { require(['gikPartLowPoly'], function(GIKPartLowPoly){ for (var i=0;i<length;i++){ parts.push(new GIKPartLowPoly(i, self)); } - self.parts = parts; + callback(parts); }); } }; diff --git a/js/parts/GIKPartLowPoly.js b/js/parts/GIKPartLowPoly.js index e071eb12b418e9c62e20265b23d74a69fabcc69f..0aa6ae06c9103aa15df06f6f4d8fe93847d236c7 100644 --- a/js/parts/GIKPartLowPoly.js +++ b/js/parts/GIKPartLowPoly.js @@ -11,6 +11,7 @@ define(['underscore', 'three', 'gikPart', 'bin!gikPartLowPolySTL', 'bin!gikEndPa var unitGeoEnd = preProcessGeo(loader.parse(gikEndPartLowPoly)); function preProcessGeo(geo){ + geo.computeBoundingBox(); geo.applyMatrix(new THREE.Matrix4().makeTranslation(-(geo.boundingBox.min.x+0.5), -(geo.boundingBox.min.y+geo.boundingBox.max.y)/2, -(geo.boundingBox.min.z+geo.boundingBox.max.z)/2)); var unitScale = 1/(1.2699999809265137); @@ -25,7 +26,7 @@ define(['underscore', 'three', 'gikPart', 'bin!gikPartLowPolySTL', 'bin!gikEndPa GIKPartLowPoly.prototype = Object.create(GIKPart.prototype); GIKPartLowPoly.prototype._getGeometry = function(){ - if (this.index == 0 || this.index == this.superCell.getLength()) return unitGeoEnd; + if (this._isEnd()) return unitGeoEnd; return unitGeo; };