repo: janusweb
action: commit
revision: 
path_from: 
revision_from: e78051d21522fa192a87528427997db5dab575a8:
path_to: 
revision_to: 
git.thebackupbox.net
janusweb
git clone git://git.thebackupbox.net/janusweb
commit e78051d21522fa192a87528427997db5dab575a8
Author: James Baicoianu 
Date:   Wed May 8 12:19:12 2019 -0700

    Added .traverseObjects() function, fixes nested object attribute bugs

diff --git a/scripts/janusbase.js b/scripts/janusbase.js
index 932aa0374c17af4dc744df5370ab28a611823f31..
index ..775f2b09e635379a3bdae173f2c870ed6b129a82 100644
--- a/scripts/janusbase.js
+++ b/scripts/janusbase.js
@@ -649,7 +649,7 @@ console.error('dunno what this is', other);
     this.setOpacity = function(opacity) {
       if (this.objects['3d'] && this.currentopacity != opacity) {
         this.currentopacity = opacity;
-        this.objects['3d'].traverse(function(n) {
+        this.traverseObjects(function(n) {
           if (n.material) {
             var m = (elation.utils.isArray(n.material) ? n.material : [n.material]);
             for (var i = 0; i < m.length; i++) {
@@ -666,13 +666,13 @@ console.error('dunno what this is', other);
     this.setAlphaTest = function(alphatest) {
       if (this.objects['3d'] && this.currentalphatest != alphatest) {
         this.currentalphatest = alphatest;
-        this.objects['3d'].traverse(function(n) {
+        this.traverseObjects(function(n) {
           if (n.material) {
             var m = (elation.utils.isArray(n.material) ? n.material : [n.material]);
             for (var i = 0; i < m.length; i++) {
-              if (m[i].transparent) {
+              //if (m[i].transparent) {
                 m[i].alphaTest =alphatest;
-              }
+              //}
             }
           }
         });
@@ -828,5 +828,17 @@ console.error('dunno what this is', other);
       }
       return false;
     }
+    this.traverseObjects = function(callback, root) {
+      if (!root) root = this.objects['3d'];
+      callback(root);
+      if (root.children) {
+        for (let i = 0; i < root.children.length; i++) {
+          let child = root.children[i];
+          if (!child.userData.thing || child.userData.thing === this) {
+            this.traverseObjects(callback, child);
+          }
+        }
+      }
+    }
   }, elation.engine.things.generic);
 });

-----END OF PAGE-----