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.Vector3( 0, 0, 0.98888888888 );

p.project( camera );

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