JSFiddle - React, Tailwind, and code Playground

HTML

<script src="//cdn.rawgit.com/mrdoob/three.js/master/build/three.min.js"></script>

CSS

body {
	  margin: 0;
}

JavaScript

const camera = new THREE.PerspectiveCamera( 70, window.innerWidth / window.innerHeight, 0.01, 10 );
camera.position.z = 1;
camera.updateMatrixWorld();

const p = new THREE.Vector4( 0, 0, 0.98888888888, 1 );

p.applyMatrix4( camera.matrixWorldInverse ).applyMatrix4( camera.projectionMatrix );

const ndcZ = p.z / p.w;
const depthValue = ( 0.5 * ndcZ ) + 0.5;
console.log( depthValue );