From 0d33965c38910fdd3db09d3975ae1da5f52801e5 Mon Sep 17 00:00:00 2001 From: Sean Lilley Date: Fri, 20 Sep 2019 15:23:48 -0400 Subject: [PATCH] Lower depth plane below marianna trench --- Source/Scene/DepthPlane.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Source/Scene/DepthPlane.js b/Source/Scene/DepthPlane.js index ebb85625175..c66d7af8b65 100644 --- a/Source/Scene/DepthPlane.js +++ b/Source/Scene/DepthPlane.js @@ -1,4 +1,5 @@ define([ + '../Core/ApproximateTerrainHeights', '../Core/BoundingSphere', '../Core/Cartesian3', '../Core/ComponentDatatype', @@ -18,6 +19,7 @@ define([ '../Shaders/DepthPlaneVS', './SceneMode' ], function( + ApproximateTerrainHeights, BoundingSphere, Cartesian3, ComponentDatatype, @@ -51,15 +53,23 @@ define([ } var depthQuadScratch = FeatureDetection.supportsTypedArrays() ? new Float32Array(12) : []; + var scratchRadii = new Cartesian3(); var scratchCartesian1 = new Cartesian3(); var scratchCartesian2 = new Cartesian3(); var scratchCartesian3 = new Cartesian3(); var scratchCartesian4 = new Cartesian3(); function computeDepthQuad(ellipsoid, frameState) { - var radii = ellipsoid.radii; + var radii = Cartesian3.clone(ellipsoid.radii, scratchRadii); var p = frameState.camera.positionWC; + // This effectively pushes the depth plane farther from the camera so that the depth plane does not render + // above primitives in the scene. + var radiusOffset = -ApproximateTerrainHeights._defaultMinTerrainHeight; + radii.x -= radiusOffset; + radii.y -= radiusOffset; + radii.z -= radiusOffset; + // Find the corresponding position in the scaled space of the ellipsoid. var q = Cartesian3.multiplyComponents(ellipsoid.oneOverRadii, p, scratchCartesian1);