aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorNivesh Rajbhandari2012-06-27 17:28:06 -0700
committerNivesh Rajbhandari2012-06-27 17:28:06 -0700
commit2da05a4c71bfe9b136384d9e94fbfbef19f24550 (patch)
treebfa21e77da8722f71fd8d32dc2f768f08a7a7183 /js
parent978b9049d057d2a0995758275f68da8641193201 (diff)
downloadninja-2da05a4c71bfe9b136384d9e94fbfbef19f24550.tar.gz
Performance fix for WebGL materials playing even when the dialog/file is no longer in view.
Also pausing videos when switching documents. Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com>
Diffstat (limited to 'js')
-rwxr-xr-xjs/document/views/base.js3
-rwxr-xr-xjs/document/views/design.js29
-rwxr-xr-xjs/lib/drawing/world.js1
-rwxr-xr-xjs/panels/Materials/materials-library-panel.reel/materials-library-panel.js2
-rwxr-xr-xjs/panels/Materials/materials-popup.reel/materials-popup.js51
5 files changed, 57 insertions, 29 deletions
diff --git a/js/document/views/base.js b/js/document/views/base.js
index d13dce1a..89759195 100755
--- a/js/document/views/base.js
+++ b/js/document/views/base.js
@@ -40,6 +40,7 @@ exports.BaseDocumentView = Montage.create(Component, {
40 if (this.iframe) { 40 if (this.iframe) {
41 this.iframe.style.display = 'block'; 41 this.iframe.style.display = 'block';
42 this.iframe.style.opacity = 1; 42 this.iframe.style.opacity = 1;
43 this.toggleWebGlAnimation(true);
43 } else { 44 } else {
44 console.log('Error: View has no iframe to show!'); 45 console.log('Error: View has no iframe to show!');
45 } 46 }
@@ -54,6 +55,8 @@ exports.BaseDocumentView = Montage.create(Component, {
54 if (this.iframe) { 55 if (this.iframe) {
55 this.iframe.style.display = 'none'; 56 this.iframe.style.display = 'none';
56 this.iframe.style.opacity = 0; 57 this.iframe.style.opacity = 0;
58 this.pauseVideos();
59 this.toggleWebGlAnimation(false);
57 } else { 60 } else {
58 console.log('Error: View has no iframe to hide!'); 61 console.log('Error: View has no iframe to hide!');
59 } 62 }
diff --git a/js/document/views/design.js b/js/document/views/design.js
index 6a60e1f9..5c7ba4fc 100755
--- a/js/document/views/design.js
+++ b/js/document/views/design.js
@@ -497,9 +497,11 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, {
497 // 497 //
498 pauseVideos:{ 498 pauseVideos:{
499 value:function(){ 499 value:function(){
500 var i, videos = this.document.getElementsByTagName("video"); 500 if(this.document) {
501 for(i = 0; i < videos.length; i++){ 501 var i, videos = this.document.getElementsByTagName("video");
502 if(!videos[i].paused) videos[i].pause(); 502 for(i = 0; i < videos.length; i++){
503 if(!videos[i].paused) videos[i].pause();
504 }
503 } 505 }
504 } 506 }
505 }, 507 },
@@ -523,9 +525,28 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, {
523 videos[i].src = ""; 525 videos[i].src = "";
524 } 526 }
525 } 527 }
526 } 528 },
527 //////////////////////////////////////////////////////////////////// 529 ////////////////////////////////////////////////////////////////////
528 //////////////////////////////////////////////////////////////////// 530 ////////////////////////////////////////////////////////////////////
531 toggleWebGlAnimation: {
532 value: function(show) {
533 if(this.document) {
534 var glCanvases = this.document.querySelectorAll('[data-RDGE-id]'),
535 glShapeModel;
536 if(glCanvases) {
537 for(var i = 0, len = glCanvases.length; i<len; i++) {
538 glShapeModel = glCanvases[i].elementModel.shapeModel;
539 if(show) {
540 glShapeModel.GLWorld.restartRenderLoop();
541 } else {
542 glShapeModel.GLWorld.stop();
543 }
544 }
545
546 }
547 }
548 }
549 }
529}); 550});
530//////////////////////////////////////////////////////////////////////// 551////////////////////////////////////////////////////////////////////////
531//////////////////////////////////////////////////////////////////////// \ No newline at end of file 552//////////////////////////////////////////////////////////////////////// \ No newline at end of file
diff --git a/js/lib/drawing/world.js b/js/lib/drawing/world.js
index 8068284e..c8c5b95a 100755
--- a/js/lib/drawing/world.js
+++ b/js/lib/drawing/world.js
@@ -623,6 +623,7 @@ World.prototype.clearTree = function()
623 623
624 if (this._useWebGL) 624 if (this._useWebGL)
625 { 625 {
626 this.stop();
626 var root = this._rootNode; 627 var root = this._rootNode;
627 root.children = new Array(); 628 root.children = new Array();
628 RDGE.globals.engine.unregisterCanvas( this._canvas.rdgeid ); 629 RDGE.globals.engine.unregisterCanvas( this._canvas.rdgeid );
diff --git a/js/panels/Materials/materials-library-panel.reel/materials-library-panel.js b/js/panels/Materials/materials-library-panel.reel/materials-library-panel.js
index cd933ea6..8c1aa1dc 100755
--- a/js/panels/Materials/materials-library-panel.reel/materials-library-panel.js
+++ b/js/panels/Materials/materials-library-panel.reel/materials-library-panel.js
@@ -129,6 +129,8 @@ exports.MaterialsLibraryPanel = Montage.create(Component, {
129 enumerable: false, 129 enumerable: false,
130 value: function (event) { 130 value: function (event) {
131 if(this._materialPopup){ 131 if(this._materialPopup){
132// console.log("hiding material popup");
133 this._materialInfo.destroy();
132 this._materialPopup.hide(); 134 this._materialPopup.hide();
133 } 135 }
134 } 136 }
diff --git a/js/panels/Materials/materials-popup.reel/materials-popup.js b/js/panels/Materials/materials-popup.reel/materials-popup.js
index 3f702459..9b7b031b 100755
--- a/js/panels/Materials/materials-popup.reel/materials-popup.js
+++ b/js/panels/Materials/materials-popup.reel/materials-popup.js
@@ -69,11 +69,11 @@ exports.MaterialsPopup = Montage.create(Component, {
69 switch(event._currentTarget.label) 69 switch(event._currentTarget.label)
70 { 70 {
71 case "Cancel": 71 case "Cancel":
72 console.log("Cancel material edit"); 72// console.log("Cancel material edit");
73 this.revertToOriginalValues(); 73 this.revertToOriginalValues();
74 break; 74 break;
75 case "OK": 75 case "OK":
76 console.log("Committing material with the following values:"); 76// console.log("Committing material with the following values:");
77 for(var i=0, len=this.materialsProperties.childComponents.length; i< len; i++) 77 for(var i=0, len=this.materialsProperties.childComponents.length; i< len; i++)
78 { 78 {
79 var childControl = this.materialsProperties.childComponents[i]; 79 var childControl = this.materialsProperties.childComponents[i];
@@ -109,7 +109,7 @@ exports.MaterialsPopup = Montage.create(Component, {
109 { 109 {
110 value: function() 110 value: function()
111 { 111 {
112 console.log("Save As..."); 112// console.log("Save As...");
113 var materialCopy = prompt("Save material as", this._materialName + "_Copy"); 113 var materialCopy = prompt("Save material as", this._materialName + "_Copy");
114 114
115 if (materialCopy) 115 if (materialCopy)
@@ -123,7 +123,7 @@ exports.MaterialsPopup = Montage.create(Component, {
123 { 123 {
124 value: function() 124 value: function()
125 { 125 {
126 console.log("Reset"); 126// console.log("Reset");
127 } 127 }
128 }, 128 },
129 129
@@ -186,15 +186,15 @@ exports.MaterialsPopup = Montage.create(Component, {
186 { 186 {
187 value: function(event) 187 value: function(event)
188 { 188 {
189 if(typeof event.propertyValue === "object") 189// if(typeof event.propertyValue === "object")
190 { 190// {
191 console.log(event.propertyLabel + " changing to "); 191// console.log(event.propertyLabel + " changing to ");
192 console.dir(event.propertyValue); 192// console.dir(event.propertyValue);
193 } 193// }
194 else 194// else
195 { 195// {
196 console.log(event.propertyLabel + " changing to " + event.propertyValue); 196// console.log(event.propertyLabel + " changing to " + event.propertyValue);
197 } 197// }
198 198
199 if (event.propertyLabel && event.propertyValue) 199 if (event.propertyLabel && event.propertyValue)
200 this.applyProperty( event.propertyLabel, event.propertyValue ); 200 this.applyProperty( event.propertyLabel, event.propertyValue );
@@ -206,15 +206,15 @@ exports.MaterialsPopup = Montage.create(Component, {
206 value: function(theEvent) 206 value: function(theEvent)
207 { 207 {
208 var event = theEvent._event; 208 var event = theEvent._event;
209 if(typeof event.propertyValue === "object") 209// if(typeof event.propertyValue === "object")
210 { 210// {
211 console.log(event.propertyLabel + " changed to "); 211// console.log(event.propertyLabel + " changed to ");
212 console.dir(event.propertyValue); 212// console.dir(event.propertyValue);
213 } 213// }
214 else 214// else
215 { 215// {
216 console.log(event.propertyLabel + " changed to " + event.propertyValue); 216// console.log(event.propertyLabel + " changed to " + event.propertyValue);
217 } 217// }
218 218
219 if (event.propertyLabel) 219 if (event.propertyLabel)
220 this.applyProperty( event.propertyLabel, event.propertyValue ); 220 this.applyProperty( event.propertyLabel, event.propertyValue );
@@ -253,7 +253,7 @@ exports.MaterialsPopup = Montage.create(Component, {
253 var obj, matArray, matTypeArray, nMats, iMat, world; 253 var obj, matArray, matTypeArray, nMats, iMat, world;
254 if (this._useSelection) 254 if (this._useSelection)
255 { 255 {
256 console.log( "apply to selection" ); 256// console.log( "apply to selection" );
257 257
258 var selection = this.application.ninja.selectedElements; 258 var selection = this.application.ninja.selectedElements;
259 if (selection && (selection.length > 0)) 259 if (selection && (selection.l