aboutsummaryrefslogtreecommitdiff
path: root/js/panels/Materials/materials-popup.reel
diff options
context:
space:
mode:
Diffstat (limited to 'js/panels/Materials/materials-popup.reel')
-rwxr-xr-xjs/panels/Materials/materials-popup.reel/materials-popup.js43
1 files changed, 43 insertions, 0 deletions
diff --git a/js/panels/Materials/materials-popup.reel/materials-popup.js b/js/panels/Materials/materials-popup.reel/materials-popup.js
index 91d50234..e9535f94 100755
--- a/js/panels/Materials/materials-popup.reel/materials-popup.js
+++ b/js/panels/Materials/materials-popup.reel/materials-popup.js
@@ -35,6 +35,7 @@ exports.MaterialsPopup = Montage.create(Component, {
35 35
36 _useSelection: { value: false, enumerable: true }, 36 _useSelection: { value: false, enumerable: true },
37 _whichMaterial: { value: "fill", enumerable: true }, 37 _whichMaterial: { value: "fill", enumerable: true },
38 _originalValues: {value: null, enumerable: true },
38 39
39 captureAction: { 40 captureAction: {
40 value:function(event) { 41 value:function(event) {
@@ -42,6 +43,7 @@ exports.MaterialsPopup = Montage.create(Component, {
42 { 43 {
43 case "Cancel": 44 case "Cancel":
44 console.log("Cancel material edit"); 45 console.log("Cancel material edit");
46 this.revertToOriginalValues();
45 break; 47 break;
46 case "OK": 48 case "OK":
47 console.log("Committing material with the following values:"); 49 console.log("Committing material with the following values:");
@@ -70,6 +72,46 @@ exports.MaterialsPopup = Montage.create(Component, {
70 } 72 }
71 }, 73 },
72 74
75 revertToOriginalValues:
76 {
77 value: function()
78 {
79 if (this._originalValues)
80 {
81 this._material.importJSON( this._originalValues );
82
83 if (this._useSelection)
84 {
85 var selection = this.application.ninja.selectedElements;
86 if (selection && (selection.length > 0))
87 {
88 var nObjs = selection.length;
89 for (var iObj=0; iObj<nObjs; iObj++)
90 {
91 var canvas = selection[iObj];
92 var obj;
93 if (canvas.elementModel && canvas.elementModel.shapeModel) obj = canvas.elementModel.shapeModel.GLGeomObj;
94 if (obj)
95 {
96 var matArray = obj._materialArray;
97 var matTypeArray = obj._materialTypeArray;
98 var nMats = matArray.length;
99 for (var iMat=0; iMat<nMats; iMat++)
100 {
101 if (matTypeArray[iMat] === this._whichMaterial)
102 matArray[iMat].importJSON( this._originalValues );
103 }
104 var world = obj.getWorld();
105 if (world)
106 world.restartRenderLoop();
107 }
108 }
109 }
110 }
111 }
112 }
113 },
114
73 updatePreview: 115 updatePreview:
74 { 116 {
75 value: function(event) 117 value: function(event)
@@ -326,6 +368,7 @@ exports.MaterialsPopup = Montage.create(Component, {
326 if (material) 368 if (material)
327 { 369 {
328 this._material = material; 370 this._material = material;
371 this._originalValues = material.exportJSON();
329 this.materialsData = this.getMaterialData( material ); 372 this.materialsData = this.getMaterialData( material );
330 } 373 }
331 else 374 else