Popov72 преди 5 години
родител
ревизия
d660380376
променени са 3 файла, в които са добавени 0 реда и са изтрити 201 реда
  1. 0 149
      src/Materials/material.shadowDepth.ts
  2. 0 1
      src/Meshes/index.ts
  3. 0 51
      src/Meshes/subMesh.shadowDepth.ts

+ 0 - 149
src/Materials/material.shadowDepth.ts

@@ -1,149 +0,0 @@
-import { Nullable } from "../types";
-import { Material } from "../Materials/material";
-import { MaterialDefines } from "./materialDefines";
-
-declare module "../Materials/material" {
-    export interface Material {
-        /** Gets or sets the custom material to use when generating the depth map during the shadow rendering process */
-        customShadowDepthMaterial: Nullable<Material>;
-
-        /**
-         * Gets or sets the specific uniforms to inject when building the custom shadow depth effect
-         * @hidden
-         */
-        customShadowDepthUniforms: string[];
-        /**
-         * Gets or sets the specific defines to inject when building the custom shadow depth effect
-         * @hidden
-         */
-        customShadowDepthDefines: string[];
-        /** @hidden */
-        _customShadowDepthMaterial: Nullable<Material>;
-        /** @hidden */
-        _customShadowDepthOldNameResolve: Nullable<(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[]) => string>;
-        /** @hidden */
-        _setupCustomShadowDepthMaterial: () => void;
-        /** @hidden */
-        _markAllSubMeshesAsDirtyForShadowDepthMaterial: () => void;
-        /** @hidden */
-        _customShadowDepthDefines: string[];
-        /** @hidden */
-        _cachedDefinesShadow: string;
-    }
-}
-
-Material.prototype._customShadowDepthMaterial = null;
-
-Material.prototype._customShadowDepthOldNameResolve = null;
-
-Object.defineProperty(Material.prototype, "customShadowDepthMaterial", {
-    get: function(this: Material) {
-        return this._customShadowDepthMaterial;
-    },
-    set: function(this: Material, mat: Nullable<Material>) {
-        if (this._customShadowDepthMaterial !== null && this._customShadowDepthMaterial !== mat && this._customShadowDepthOldNameResolve) {
-            this._customShadowDepthMaterial.customShaderNameResolve = this._customShadowDepthOldNameResolve;
-        }
-
-        this._customShadowDepthMaterial = mat;
-        this._customShadowDepthOldNameResolve = null;
-
-        if (mat !== null) {
-            this._setupCustomShadowDepthMaterial();
-        }
-
-        this.customShadowDepthUniforms = [];
-        this._customShadowDepthDefines = [];
-    },
-    enumerable: false,
-    configurable: true
-});
-
-function isMaterialDefines(defines:  MaterialDefines | string[]): defines is MaterialDefines {
-    return (defines as any)._keys !== undefined;
-}
-
-Material.prototype._setupCustomShadowDepthMaterial = function() {
-    const mat = this._customShadowDepthMaterial;
-
-    if (!mat) {
-        return;
-    }
-
-    this._customShadowDepthOldNameResolve = mat.customShaderNameResolve?.bind(mat);
-
-    mat.customShaderNameResolve = (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[]) => {
-        if (this._customShadowDepthDefines) {
-            if (!isMaterialDefines(defines)) {
-                for (let i = 0; i < this._customShadowDepthDefines.length; ++i) {
-                    defines.push(this._customShadowDepthDefines[i]);
-                }
-            } else {
-                for (let i = 0; i < this._customShadowDepthDefines.length; ++i) {
-                    const define = this._customShadowDepthDefines[i],
-                            offset = 8,
-                            spacePos = define.indexOf(" ", offset),
-                            name = define.substring(offset, spacePos !== -1 ? spacePos : define.length),
-                            value = spacePos === -1 ? true : define.substring(spacePos + 1);
-
-                    if (defines[name] === undefined) {
-                        (defines as any)._keys.push(name);
-                    }
-                    defines[name] = value;
-                }
-            }
-        }
-
-        if (this.customShadowDepthUniforms) {
-            uniforms.push(...this.customShadowDepthUniforms);
-        }
-
-        if (this._customShadowDepthOldNameResolve) {
-            shaderName = this._customShadowDepthOldNameResolve(shaderName, uniforms, uniformBuffers, samplers, defines, attributes);
-        }
-
-        return shaderName;
-    };
-};
-
-Object.defineProperty(Material.prototype, "customShadowDepthDefines", {
-    get: function(this: Material) {
-        return this._customShadowDepthDefines;
-    },
-    set: function(this: Material, defines: string[]) {
-        this._customShadowDepthDefines = defines;
-
-        const join = defines.join("\n");
-
-        if (this._customShadowDepthMaterial && join !== this._cachedDefinesShadow) {
-            this._cachedDefinesShadow = join;
-            this._customShadowDepthMaterial._markAllSubMeshesAsDirtyForShadowDepthMaterial();
-        }
-    },
-    enumerable: false,
-    configurable: true
-});
-
-Material.prototype._markAllSubMeshesAsDirtyForShadowDepthMaterial = function() {
-    if (this.getScene().blockMaterialDirtyMechanism) {
-        return;
-    }
-
-    const meshes = this.getScene().meshes;
-    for (var mesh of meshes) {
-        if (!mesh.subMeshes) {
-            continue;
-        }
-        for (var subMesh of mesh.subMeshes) {
-            if (subMesh.getMaterial()?.customShadowDepthMaterial !== this) {
-                continue;
-            }
-
-            if (!subMesh._materialDefinesShadowDepth) {
-                continue;
-            }
-
-            subMesh._materialDefinesShadowDepth.markAsUnprocessed();
-        }
-    }
-};

+ 0 - 1
src/Meshes/index.ts

@@ -14,7 +14,6 @@ export * from "./meshSimplification";
 export * from "./meshSimplificationSceneComponent";
 export * from "./polygonMesh";
 export * from "./subMesh";
-export * from "./subMesh.shadowDepth";
 export * from "./meshLODLevel";
 export * from "./transformNode";
 export * from "./Builders/index";

+ 0 - 51
src/Meshes/subMesh.shadowDepth.ts

@@ -1,51 +0,0 @@
-import { Nullable } from "../types";
-import { Effect } from "../Materials/effect";
-import { SubMesh } from './subMesh';
-
-declare type MaterialDefines = import("../Materials/materialDefines").MaterialDefines;
-
-declare module "../Meshes/subMesh" {
-    export interface SubMesh {
-        /** Switch the current effect to be the regular effect for this sub mesh */
-        switchToRegularEffect: () => void;
-
-        /** Switch the current effect to be the shadow depth effect for this sub mesh */
-        switchToShadowDepthEffect: () => void;
-
-        /** @hidden */
-        _materialDefinesShadowDepth: Nullable<MaterialDefines>;
-        /** @hidden */
-        _materialEffectShadowDepth: Nullable<Effect>;
-
-        /** @hidden */
-        _regularDefines: Nullable<MaterialDefines>;
-        /** @hidden */
-        _regularEffect: Nullable<Effect>;
-
-        /** @hidden */
-        _currentEffect: number; /* 0=regular, 1=shadow depth */
-
-    }
-}
-
-SubMesh.prototype._currentEffect = 0;
-
-SubMesh.prototype.switchToRegularEffect = function() {
-    if (this._currentEffect !== 0)  {
-        this._currentEffect = 0;
-        this._materialDefinesShadowDepth = this._materialDefines;
-        this._materialEffectShadowDepth = this._materialEffect;
-        this._materialDefines = this._regularDefines;
-        this._materialEffect = this._regularEffect;
-    }
-};
-
-SubMesh.prototype.switchToShadowDepthEffect = function() {
-    if (this._currentEffect !== 1)  {
-        this._currentEffect = 1;
-        this._regularDefines = this._materialDefines;
-        this._regularEffect = this._materialEffect;
-        this._materialDefines = this._materialDefinesShadowDepth;
-        this._materialEffect = this._materialEffectShadowDepth;
-    }
-};