import { Mesh } from '../babylonjs-import';
import { BABYLON_MESH_ALPHA, CustomDepthMaterial, IS_BABYLON_MESH } from './CustomDepthMaterial';
export class BabylonMeshDepthMaterial extends CustomDepthMaterial {
    constructor(name, scene, renderingInfo, diffuseTexture) {
        super(name, scene, renderingInfo, diffuseTexture);
    }
    _type = 'BabylonMeshDepthMaterial';
    getUniformsAndDefinesAndSamplers() {
        const uniformsAndDefines = super.getUniformsAndDefinesAndSamplers();
        uniformsAndDefines.uniforms.push(BABYLON_MESH_ALPHA);
        uniformsAndDefines.defines.push(IS_BABYLON_MESH);
        return uniformsAndDefines;
    }
    bindFunction(mesh) {
        super.bindFunction(mesh);
        const effect = this.getEffect();
        //check if mesh is a twinfinity or babylon mesh
        if (mesh instanceof Mesh) {
            const isTwinfintySubMesh = !!mesh.twinfinity?.ifc;
            if (!isTwinfintySubMesh) {
                effect.setFloat('babylonMeshAlpha', mesh.material?.alpha ?? 1.0);
            }
            else {
                throw new Error('The mesh bound to this material is an IFC mesh, IFC meshes should not be assigned the Babylon mesh depth material (this material)');
            }
        }
    }
}
//# sourceMappingURL=BabylonMeshDepthMaterial.js.map