From 296ee53c29d6fde91295dfe04c31d6c0919d455c Mon Sep 17 00:00:00 2001 From: Amanda Ghassaei <amandaghassaei@gmail.com> Date: Tue, 15 Sep 2015 00:34:43 -0400 Subject: [PATCH] delete material --- js/cells/DMACell.js | 2 +- js/materials/DMAMaterials.js | 7 ++++++- js/parts/DNAStraightPart.js | 8 ++++++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/js/cells/DMACell.js b/js/cells/DMACell.js index f32e1658..90b83d5b 100644 --- a/js/cells/DMACell.js +++ b/js/cells/DMACell.js @@ -158,7 +158,7 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'globals', ' DMACell.prototype.setDeleteMode = function(state){ var material; if (!state && !this.materialName) return;//cell may be deleted by now - if (state) material = materials.list.deleteMaterial.threeMaterial; + if (state) material = materials.getDeleteMaterial(); else material = this.getMaterial(true); if (!material) return;//no material object found if (this.object3D.children[0].material == material) return; diff --git a/js/materials/DMAMaterials.js b/js/materials/DMAMaterials.js index 131a6cdd..9feb0c9b 100644 --- a/js/materials/DMAMaterials.js +++ b/js/materials/DMAMaterials.js @@ -76,6 +76,10 @@ define(['underscore', 'three', 'appState', 'lattice', 'plist', 'threeModel'], fu return materialsList[id]; } + function getDeleteMaterial(){ + return materialsList.deleteMaterial.threeMaterial; + } + @@ -260,6 +264,7 @@ define(['underscore', 'three', 'appState', 'lattice', 'plist', 'threeModel'], fu getChildCellTypes:getChildCellTypes, setToDefaultMaterial: setToDefaultMaterial, setEditingMaterial: setEditingMaterial, - getEditingMaterial: getEditingMaterial + getEditingMaterial: getEditingMaterial, + getDeleteMaterial: getDeleteMaterial }; }); \ No newline at end of file diff --git a/js/parts/DNAStraightPart.js b/js/parts/DNAStraightPart.js index 76b0f810..57f436a4 100644 --- a/js/parts/DNAStraightPart.js +++ b/js/parts/DNAStraightPart.js @@ -3,13 +3,12 @@ */ -define(['underscore', 'stlLoader', 'gikPart'], function(_, THREE, GIKPart){ +define(['underscore', 'stlLoader', 'gikPart', 'materials'], function(_, THREE, GIKPart, materials){ var zScale = 1.08/8; var unitGeo = new THREE.BoxGeometry(0.2, 0.2, zScale); var bridgeGeo = new THREE.BoxGeometry(0.3, 0.4, zScale); - console.log(bridgeGeo); bridgeGeo.vertices[4].y = 0; bridgeGeo.vertices[5].y = 0; bridgeGeo.vertices[2].y = -0.1; @@ -65,6 +64,11 @@ define(['underscore', 'stlLoader', 'gikPart'], function(_, THREE, GIKPart){ return GIKPart.prototype.getMaterial.call(this, returnTHREEObject); }; + DNAStraightPart.prototype.setMaterial = function(material){ + if (material != materials.getDeleteMaterial()) material = this.getMaterial(true); + this.mesh.material = material; + }; + DNAStraightPart.prototype._translatePart = function(mesh){ if (this._isBridge){ mesh.translateX(0.15+0.2); -- GitLab