Skip to content

Commit

Permalink
Merge pull request #3985 from AnalyticalGraphicsInc/fix-2d
Browse files Browse the repository at this point in the history
Fix 2D
  • Loading branch information
Tom Fili committed Jun 1, 2016
2 parents 448d481 + ce4d2d4 commit 55d17c9
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions Source/Scene/Scene.js
Original file line number Diff line number Diff line change
Expand Up @@ -1687,10 +1687,20 @@ define([
var index = numFrustums - i - 1;
var frustumCommands = frustumCommandsList[index];

// Avoid tearing artifacts between adjacent frustums in the opaque passes
frustum.near = index !== 0 ? frustumCommands.near * OPAQUE_FRUSTUM_NEAR_OFFSET : frustumCommands.near;
frustum.far = frustumCommands.far;
us.updateFrustum(frustum);
if (scene.mode === SceneMode.SCENE2D) {
// To avoid z-fighting in 2D, move the camera to just before the frustum
// and scale the frustum depth to be in [1.0, nearToFarDistance2D].
camera.position.z = height2D - frustumCommands.near + 1.0;
frustum.far = Math.max(1.0, frustumCommands.far - frustumCommands.near);
frustum.near = 1.0;
us.update(scene.frameState);
us.updateFrustum(frustum);
} else {
// Avoid tearing artifacts between adjacent frustums in the opaque passes
frustum.near = index !== 0 ? frustumCommands.near * OPAQUE_FRUSTUM_NEAR_OFFSET : frustumCommands.near;
frustum.far = frustumCommands.far;
us.updateFrustum(frustum);
}

var globeDepth = scene.debugShowGlobeDepth ? getDebugGlobeDepth(scene, index) : scene._globeDepth;

Expand Down Expand Up @@ -1732,16 +1742,6 @@ define([
}
}

if (scene.mode === SceneMode.SCENE2D) {
// To avoid z-fighting in 2D, move the camera to just before the frustum
// and scale the frustum depth to be in [1.0, nearToFarDistance2D].
camera.position.z = height2D - frustumCommands.near + 1.0;
frustum.far = Math.max(1.0, frustumCommands.far - frustumCommands.near);
frustum.near = 1.0;
us.update(scene.frameState);
us.updateFrustum(frustum);
}

// Execute commands in order by pass up to the translucent pass.
// Translucent geometry needs special handling (sorting/OIT).
var startPass = Pass.GROUND + 1;
Expand Down

0 comments on commit 55d17c9

Please sign in to comment.