Skip to content

Commit

Permalink
Merge pull request #172 from NASAWorldWind/fix/#105-atmosphere-clipping
Browse files Browse the repository at this point in the history
Repaired atmosphere layer clipping
  • Loading branch information
AkeluX committed Aug 8, 2017
2 parents 1f7f6f3 + 3686c4c commit 7d327de
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion examples/Atmosphere.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ <h4>Destination</h4>
</div>
</div>
<div class="col-sm-9" id="globe">
<canvas id="canvasOne" width="1000" height="1000" style="background-color: #000000">
<canvas id="canvasOne" width="1000" height="1000" style="width: 100%; height: auto; background-color: black;">
Your browser does not support HTML5 Canvas.
</canvas>
</div>
Expand Down
11 changes: 7 additions & 4 deletions src/navigate/Navigator.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,16 +102,19 @@ define([
globeRadius = WWMath.max(globe.equatorialRadius, globe.polarRadius),
eyePoint = modelviewMatrix.extractEyePoint(new Vec3(0, 0, 0)),
eyePos = globe.computePositionFromPoint(eyePoint[0], eyePoint[1], eyePoint[2], new Position(0, 0, 0)),
eyeHorizon = WWMath.horizonDistanceForGlobeRadius(globeRadius, eyePos.altitude),
atmosphereHorizon = WWMath.horizonDistanceForGlobeRadius(globeRadius, 160000),
viewport = this.worldWindow.viewport,
viewDepthBits = this.worldWindow.depthBits,
distanceToSurface,
maxNearDistance,
projectionMatrix = Matrix.fromIdentity();

// Compute the far clip distance based on the current eye altitude. This must be done after computing the
// modelview matrix and before computing the near clip distance. The far clip distance depends on the
// modelview matrix, and the near clip distance depends on the far clip distance.
this.farDistance = WWMath.horizonDistanceForGlobeRadius(globeRadius, eyePos.altitude);
// Set the far clip distance to the smallest value that does not clip the atmosphere.
// TODO adjust the clip plane distances based on the navigator's orientation - shorter distances when the
// TODO horizon is not in view
// TODO parameterize the object altitude for horizon distance
this.farDistance = eyeHorizon + atmosphereHorizon;
if (this.farDistance < 1e3)
this.farDistance = 1e3;

Expand Down

0 comments on commit 7d327de

Please sign in to comment.