diff --git a/js/cells/supercells/CompositeCell.js b/js/cells/supercells/CompositeCell.js index cf4c34d74ef2844673a10e75db3a63b27648a9f7..52ccdeef0bbec0bae0262342d77129619dfc85b0 100644 --- a/js/cells/supercells/CompositeCell.js +++ b/js/cells/supercells/CompositeCell.js @@ -3,8 +3,8 @@ */ -define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'superCell', 'gikCell'], - function(_, THREE, three, lattice, appState, DMASuperCell, GIKCell){ +define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'superCell', 'globals'], + function(_, THREE, three, lattice, appState, DMASuperCell, globals){ CompositeCell = function(json, superCell){ DMASuperCell.call(this, json, superCell); @@ -32,5 +32,15 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'superCell', return wireframe; }; + CompositeCell.prototype.getMaterial = function(){ + if (!this.material) return null; + var material = globals.materials.compositeMaterials[this.material]; + if (!material){ + console.warn("no material "+ this.material + " found"); + return null; + } + return material; + }; + return CompositeCell; }); \ No newline at end of file diff --git a/js/lattice/LatticeBase.js b/js/lattice/LatticeBase.js index b1a4a640b0d32d47822620e4a2754c1ce0505bbe..2ee48c1932e8d6f41132e416ee800570f977a338 100644 --- a/js/lattice/LatticeBase.js +++ b/js/lattice/LatticeBase.js @@ -93,7 +93,9 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre //add/remove cells makeCellForLatticeType: function(json, callback){ - require([this.getCellSubclassFile()], function(CellSubclass){ + var subclassFile = this.getCellSubclassFile(); + if (appState.lattice.get("materialType").substr(0,5) == "super") subclassFile = "compositeCell"; + require([subclassFile], function(CellSubclass){ var cell = new CellSubclass(json); if (callback) callback(cell); }); diff --git a/js/main.js b/js/main.js index 626b9c43685ca83a038ed19a8c10a3647acfcdf8..054f1e37b72950675cd5f5d80f96bfa276289450 100644 --- a/js/main.js +++ b/js/main.js @@ -69,6 +69,7 @@ require.config({ gikCell: 'cells/GIKCell', superCell: 'cells/supercells/DMASupercell', gikSuperCell: 'cells/supercells/GIKSuperCell', + compositeCell: "cells/supercells/CompositeCell", //parts part: 'parts/DMAPart',