How to Get DepthTexture of Current Scene?

1. A concise explanation of the problem you're experiencing.

2. A minimal code example. If you've found a bug, this helps us reproduce and repair it.
getSceneDepthTexture(viewer){
        var scene = viewer.scene;
        var environmentState = scene._environmentState;
        var view = scene._view;
        var useGlobeDepthFramebuffer = environmentState.useGlobeDepthFramebuffer;
        var globeFramebuffer = useGlobeDepthFramebuffer ? view.globeDepth.framebuffer : undefined;
        var sceneFramebuffer = view.sceneFramebuffer.getFramebuffer();
        var depthTexture = Cesium.defaultValue(globeFramebuffer,sceneFramebuffer).depthStencilTexture;
        // var depthTexture = scene._view.pickDepths[0]._depthTexture;
        // var depthTexture = scene._view.pickDepths[0]._textureToCopy;
        // var depthTexture = scene._view.pickDepths[0]._copyDepthCommand._framebuffer._colorTextures[0];
        // var depthTexture = this.wyypost&&this.wyypost._depthTexture?this.wyypost._depthTexture:scene.context.uniformState.globeDepthTexture;
        // var depthTexture = scene.context.uniformState.globeDepthTexture;
        return depthTexture;
    }

As shown in the code above, I tried a lot of methods, but it didn't seem to work as I wanted.

3. Context. Why do you need to do this? We might know a better way to accomplish your goal.
I'm trying to use depthTexture of scene in the uniformMap of the custom command, so how do I get the current scene depth maps?

4. The Cesium version you're using, your operating system and browser.
1.59

Create my command code:

_mergeTexture(currViewShed){
        let _this = this;
        let context = this.viewer.scene.context;
        if(currViewShed.drawDepthCommand){
            currViewShed.drawDepthCommand.execute(context);
            return;
        };
        let fs = MergeViewFieldFS;
        // // rs.blending.enabled = true;
        // // rs.blending.functionSourceAlpha = context._gl.ONE;
        // // rs.blending.functionSourceRgb = context._gl.ONE;
        // // rs.blending.functionSourceAlpha = context._gl.ONE;
        // // rs.blending.functionDestinationAlpha = context._gl.ONE;
        var bias = currViewShed.viewShadowMap._isPointLight ? currViewShed.viewShadowMap._pointBias : currViewShed.viewShadowMap._primitiveBias;
        let uniformMap = {
            czzj: function () {
                return currViewShed.verticalAngle;
            },
            dis: function () {
                return currViewShed.distance;
            },
            spzj: function () {
                return currViewShed.horizontalAngle;
            },
            visibleColor: function () {
                return currViewShed.visibleAreaColor;
            },
            disVisibleColor: function () {
                return currViewShed.hiddenAreaColor;
            },
            stcshadow: function () {
                return currViewShed.viewShadowMap._shadowMapTexture;
            },
            _shadowMap_matrix: function () {
                return currViewShed.viewShadowMap._shadowMapMatrix;
            },
            shadowMap_lightPositionEC: function () {
                return currViewShed.viewShadowMap._lightPositionEC;
            },
            shadowMap_lightDirectionEC: function () {
                return currViewShed.viewShadowMap._lightDirectionEC;
            },
            shadowMap_lightUp: function () {
                return currViewShed.viewShadowMap._lightCamera.up;
            },
            shadowMap_lightDir: function () {
                return currViewShed.viewShadowMap._lightCamera.direction;
            },
            shadowMap_lightRight: function () {
                return currViewShed.viewShadowMap._lightCamera.right;
            },
            shadowMap_texelSizeDepthBiasAndNormalShadingSmooth: function () {
                var texelStepSize = new Cesium.Cartesian2();
                texelStepSize.x = 1.0 / currViewShed.viewShadowMap._textureSize.x;
                texelStepSize.y = 1.0 / currViewShed.viewShadowMap._textureSize.y;
                return Cesium.Cartesian4.fromElements(texelStepSize.x, texelStepSize.y, bias.depthBias, bias.normalShadingSmooth, this.combinedUniforms1);
            },
            shadowMap_normalOffsetScaleDistanceMaxDistanceAndDarkness: function () {
                return Cesium.Cartesian4.fromElements(bias.normalOffsetScale, currViewShed.viewShadowMap._distance, currViewShed.viewShadowMap.maximumDistance, currViewShed.viewShadowMap._darkness, this.combinedUniforms2);
            },
            depthTexture:function(){
                return _this.getSceneDepthTexture(_this.viewer);
            }
        }
        var fbo = this.mergeFBO;
        var rs = new Cesium.RenderState();
        var pass = Cesium.Pass.TRANSLUCENT;
        currViewShed.drawDepthCommand = context.createViewportQuadCommand(fs,{
            renderState:rs,
            uniformMap:uniformMap,
            owner:currViewShed,
            framebuffer:fbo,
            pass:pass
        });
        currViewShed.drawDepthCommand.execute(context);
    }

My FragmengtShader code snippet:

vec4 toEye(in vec2 uv, in float depth){
    vec2 xy = vec2((uv.x * 2.0 - 1.0),(uv.y * 2.0 - 1.0));
    vec4 posInCamera =czm_inverseProjection * vec4(xy, depth, 1.0);
    posInCamera =posInCamera / posInCamera.w;
    return posInCamera;
}
float getDepth(in vec4 depth){
    float z_window = czm_unpackDepth(depth);
    z_window = czm_reverseLogDepth(z_window);
    float n_range = czm_depthRange.near;
    float f_range = czm_depthRange.far;
    return (2.0 * z_window - n_range - f_range) / (f_range - n_range);
}
float _czm_sampleShadowMap(sampler2D shadowMap, vec2 uv){
    return texture2D(shadowMap, uv).r;
}
float _czm_shadowDepthCompare(sampler2D shadowMap, vec2 uv, float depth){
    return step(depth, _czm_sampleShadowMap(shadowMap, uv));
}
float _czm_shadowVisibility(sampler2D shadowMap, czm_shadowParameters shadowParameters){
    float depthBias = shadowParameters.depthBias;
    float depth = shadowParameters.depth;
    float nDotL = shadowParameters.nDotL;
    float normalShadingSmooth = shadowParameters.normalShadingSmooth;
    float darkness = shadowParameters.darkness;
    vec2 uv = shadowParameters.texCoords;
    depth -= depthBias;
    vec2 texelStepSize = shadowParameters.texelStepSize;
    float radius = 1.0;
    float dx0 = -texelStepSize.x * radius;
    float dy0 = -texelStepSize.y * radius;
    float dx1 = texelStepSize.x * radius;
    float dy1 = texelStepSize.y * radius;
    float visibility =
    (
    _czm_shadowDepthCompare(shadowMap, uv, depth)
    +_czm_shadowDepthCompare(shadowMap, uv + vec2(dx0, dy0), depth) +
    _czm_shadowDepthCompare(shadowMap, uv + vec2(0.0, dy0), depth) +
    _czm_shadowDepthCompare(shadowMap, uv + vec2(dx1, dy0), depth) +
    _czm_shadowDepthCompare(shadowMap, uv + vec2(dx0, 0.0), depth) +
    _czm_shadowDepthCompare(shadowMap, uv + vec2(dx1, 0.0), depth) +
    _czm_shadowDepthCompare(shadowMap, uv + vec2(dx0, dy1), depth) +
    _czm_shadowDepthCompare(shadowMap, uv + vec2(0.0, dy1), depth) +
    _czm_shadowDepthCompare(shadowMap, uv + vec2(dx1, dy1), depth)
    ) * (1.0 / 9.0)
    ;
    return visibility;
}
vec3 pointProjectOnPlane(in vec3 planeNormal, in vec3 planeOrigin, in vec3 point){
    vec3 v01 = point -planeOrigin;
    float d = dot(planeNormal, v01) ;
    return (point - planeNormal * d);
}
float ptm(vec3 pt){
    return sqrt(pt.x*pt.x + pt.y*pt.y + pt.z*pt.z);
}
void main()
{
    const float PI = 3.141592653589793;
    vec4 currD = texture2D(depthTexture, v_textureCoordinates);
    vec4 color = vec4(0.0,0.0,1.0,1.0);
    // vec4 stcc = texture2D(stcshadow, v_textureCoordinates);
    // gl_FragColor = stcc;
    // return;
    if(gl_FragColor.g>0.3){
        gl_FragColor = vec4(0.0,1.0,0.0,1.0);
        return;
    }
    if(currD.r>=1.0){
        gl_FragColor = vec4(1.0,1.0,0.0,1.0);
        return;
    }
    float depth = getDepth(currD);
    vec4 positionEC = toEye(v_textureCoordinates, depth);
    vec3 normalEC = vec3(1.0);

    //坐标与视点位置距离,大于最大距离则舍弃阴影效果
    vec4 lw = czm_inverseView* vec4(shadowMap_lightPositionEC.xyz, 1.0);
    vec4 vw = czm_inverseView* vec4(positionEC.xyz, 1.0);
    if(distance(lw.xyz,vw.xyz)>dis){
        gl_FragColor = vec4(1.0,1.0,1.0,1.0);
        return;
    }

Why is distance (lw. xyz, vw. xyz)>dis always true?