repo: janusweb
action: commit
revision: 
path_from: 
revision_from: 837eff35e568857600a78b7e3678f9971a3589b2:
path_to: 
revision_to: 
git.thebackupbox.net
janusweb
git clone git://git.thebackupbox.net/janusweb
commit 837eff35e568857600a78b7e3678f9971a3589b2
Author: James Baicoianu 
Date:   Sun Dec 2 01:44:46 2018 -0800

    Respect texture alpha when casting shadows

diff --git a/scripts/object.js b/scripts/object.js
index f7c90476a4dcafa8d301fac3fc76fe7f7683b657..
index ..12760874f48c7ef521da8bb8aa9afe98537be334 100644
--- a/scripts/object.js
+++ b/scripts/object.js
@@ -530,7 +530,23 @@ elation.require(['janusweb.janusbase', 'janusweb.websurface'], function() {
             if (this.depth_test !== null) {
               m.depthTest = this.depth_test;
             }
-
+            // If our diffuse texture has an alpha channel, set up a customDepthMaterial / customDistanceMaterial to allow shadows to work
+            if (true) { //this.shadow && m.transparent && m.map) {
+              if (!n.customDepthMaterial) {
+                n.customDepthMaterial = new THREE.MeshDepthMaterial({
+                  depthPacking: THREE.RGBADepthPacking,
+                  map: m.map,
+                  alphaTest: 0.5
+                });
+              }
+              if (!n.customDistanceMaterial) {
+                n.customDistanceMaterial = new THREE.MeshDistanceMaterial({
+                  //depthPacking: THREE.RGBADepthPacking,
+                  map: m.map,
+                  alphaTest: 0.5
+                });
+              }
+            }
             //m.needsUpdate = true;
             m.skinning = useSkinning;
           }

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