diff --git a/js/fea/DMASuperCell.js b/js/fea/DMASuperCell.js index 3b248259d66b92fcb1320508899ded0c970be27d..69d0183510ec4590c5f4fabd6495882ffbe177ee 100644 --- a/js/fea/DMASuperCell.js +++ b/js/fea/DMASuperCell.js @@ -3,8 +3,8 @@ */ -var cellBrassMaterial = [new THREE.MeshLambertMaterial({color:"#b5a642"})]; -var cellFiberGlassMaterial = [new THREE.MeshLambertMaterial({color:"#fef1b5"})]; +var cellBrassMaterial = new THREE.MeshLambertMaterial({color:"#b5a642"}); +var cellFiberGlassMaterial = new THREE.MeshLambertMaterial({color:"#fef1b5"}); DMASuperCell = function(length, range, cells){ var shouldRotate = range.max.x == range.min.x; @@ -22,15 +22,19 @@ DMASuperCell.prototype._buildSuperCellMesh = function(length, shouldRotate){ superCellGeo.applyMatrix(new THREE.Matrix4().makeScale(length, 1, 1)); superCellGeo.applyMatrix(new THREE.Matrix4().makeTranslation(-(length/2-1/2), 0, 0)); if (shouldRotate) superCellGeo.applyMatrix(new THREE.Matrix4().makeRotationZ(Math.PI/2)); - var material = cellBrassMaterial; - if (this.material == "fiberGlass") material = cellFiberGlassMaterial; - var mesh = THREE.SceneUtils.createMultiMaterialObject(superCellGeo, material); + var mesh = THREE.SceneUtils.createMultiMaterialObject(superCellGeo, [this.getMaterialType()]); var wireframe = new THREE.BoxHelper(mesh.children[0]); wireframe.material.color.set(0x000000); mesh.children.push(wireframe); return mesh; }; +DMASuperCell.prototype.getMaterialType = function(){ + var material = cellBrassMaterial; + if (this.material == "fiberGlass") material = cellFiberGlassMaterial; + return material; +}; + DMASuperCell.prototype._setPosition = function(index){ var position = dmaGlobals.lattice.getPositionForIndex(index); this.mesh.position.set(position.x, position.y, position.z); diff --git a/js/fea/DmaCellOther.js b/js/fea/DmaCellOther.js index 016e82f91a49f63958de7c7ae414965aa3b06e1f..4c1880897e202da0a94ac9b97db3b50422359ff5 100644 --- a/js/fea/DmaCellOther.js +++ b/js/fea/DmaCellOther.js @@ -90,6 +90,10 @@ var cellMaterial = [new THREE.MeshNormalMaterial()]; } }; + DMAGIKCell.prototype.getMaterialType = function(){ + return this.superCell.getMaterialType(); + }; + DMAGIKCell.prototype.__initParts = function(){ var parts = []; var isEnd = this.superCellIndex == 0 || this.superCellIndex == this.superCell.getLength(); diff --git a/js/fea/DmaPart.js b/js/fea/DmaPart.js index 0c6f4c7f5cb3eb154fe9657af0b56c1604e04d43..6c9baafb54a2cdc4e3814494ae4821b726b40c6f 100644 --- a/js/fea/DmaPart.js +++ b/js/fea/DmaPart.js @@ -237,7 +237,7 @@ var partMaterial = new THREE.MeshLambertMaterial({ color:0xffffff, shading: THRE DMAGIKPart.prototype = Object.create(DMAPart.prototype); DMAGIKPart.prototype._makeMeshForType = function(){ - var mesh = new THREE.Mesh(unitPartGeo, partMaterial); + var mesh = new THREE.Mesh(unitPartGeo, this.parentCell.getMaterialType()); mesh.myPart = this;//need a ref back to this part return mesh; }; @@ -269,7 +269,7 @@ var partMaterial = new THREE.MeshLambertMaterial({ color:0xffffff, shading: THRE DMAGIKPartLowPoly.prototype = Object.create(DMAGIKPart.prototype); DMAGIKPartLowPoly.prototype._makeMeshForType = function(){ - var mesh = new THREE.Mesh(unitPartGeo, partMaterial); + var mesh = new THREE.Mesh(unitPartGeo, this.parentCell.getMaterialType()); mesh.myPart = this;//need a ref back to this part return mesh; }; @@ -301,7 +301,7 @@ var partMaterial = new THREE.MeshLambertMaterial({ color:0xffffff, shading: THRE DMAGIKEndPart.prototype = Object.create(DMAGIKPart.prototype); DMAGIKEndPart.prototype._makeMeshForType = function(){ - var mesh = new THREE.Mesh(unitPartGeo, partMaterial); + var mesh = new THREE.Mesh(unitPartGeo, this.parentCell.getMaterialType()); mesh.myPart = this;//need a ref back to this part return mesh; }; @@ -333,7 +333,7 @@ var partMaterial = new THREE.MeshLambertMaterial({ color:0xffffff, shading: THRE DMAGIKEndPartLowPoly.prototype = Object.create(DMAGIKPart.prototype); DMAGIKEndPartLowPoly.prototype._makeMeshForType = function(){ - var mesh = new THREE.Mesh(unitPartGeo, partMaterial); + var mesh = new THREE.Mesh(unitPartGeo, this.parentCell.getMaterialType()); mesh.myPart = this;//need a ref back to this part return mesh; };