浏览代码

Add a customAllowRendering user function

Popov72 4 年之前
父节点
当前提交
c472f22393
共有 1 个文件被更改,包括 6 次插入6 次删除
  1. 6 6
      src/Lights/Shadows/shadowGenerator.ts

+ 6 - 6
src/Lights/Shadows/shadowGenerator.ts

@@ -226,6 +226,9 @@ export class ShadowGenerator implements IShadowGenerator {
     /** Gets or sets the custom shader name to use */
     /** Gets or sets the custom shader name to use */
     public customShaderOptions: ICustomShaderOptions;
     public customShaderOptions: ICustomShaderOptions;
 
 
+    /** Gets or sets a custom function to allow/disable rendering a sub mesh in the shadow map */
+    public customAllowRendering: (subMesh: SubMesh) => boolean;
+
     /**
     /**
      * Observable triggered before the shadow is rendered. Can be used to update internal effect state
      * Observable triggered before the shadow is rendered. Can be used to update internal effect state
      */
      */
@@ -1099,12 +1102,9 @@ export class ShadowGenerator implements IShadowGenerator {
         }
         }
 
 
         var hardwareInstancedRendering = engine.getCaps().instancedArrays && (batch.visibleInstances[subMesh._id] !== null && batch.visibleInstances[subMesh._id] !== undefined || renderingMesh.hasThinInstances);
         var hardwareInstancedRendering = engine.getCaps().instancedArrays && (batch.visibleInstances[subMesh._id] !== null && batch.visibleInstances[subMesh._id] !== undefined || renderingMesh.hasThinInstances);
-        if (effectiveMesh._internalAbstractMeshDataInfo._currentLOD !== effectiveMesh) {
-            if (hardwareInstancedRendering) {
-                delete batch.renderSelf[subMesh._id];
-            } else {
-                return;
-            }
+
+        if (this.customAllowRendering && !this.customAllowRendering(subMesh)) {
+            return;
         }
         }
 
 
         if (this.isReady(subMesh, hardwareInstancedRendering, isTransparent)) {
         if (this.isReady(subMesh, hardwareInstancedRendering, isTransparent)) {