From 0362a8e39618251116e85e1791a091e10580b3a3 Mon Sep 17 00:00:00 2001 From: Amanda Ghassaei <amandaghassaei@gmail.com> Date: Fri, 12 Jun 2015 16:17:12 -0700 Subject: [PATCH] almost working --- js/cells/supercells/CompositeCell.js | 14 ++++++++++++-- js/lattice/LatticeBase.js | 4 +++- js/main.js | 1 + 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/js/cells/supercells/CompositeCell.js b/js/cells/supercells/CompositeCell.js index cf4c34d7..52ccdeef 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 b1a4a640..2ee48c19 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 626b9c43..054f1e37 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', -- GitLab