Skip to content

Commit f924c16

Browse files
committed
Update maximum frustum size in 2D and fix terrain rendering.
1 parent 041ee30 commit f924c16

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

Apps/Sandcastle/gallery/3D Models.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
viewer.trackedEntity = entity;
5656
}
5757

58-
var options = [/*{
58+
var options = [{
5959
text : 'Aircraft',
6060
onselect : function() {
6161
createModel('../../SampleData/models/CesiumAir/Cesium_Air.glb', 5000.0);
@@ -70,7 +70,7 @@
7070
onselect : function() {
7171
createModel('../../SampleData/models/CesiumMilkTruck/CesiumMilkTruck-kmc.glb', 0);
7272
}
73-
},*/ {
73+
}, {
7474
text : 'Skinned character',
7575
onselect : function() {
7676
createModel('../../SampleData/models/CesiumMan/Cesium_Man.glb', 0);

Source/Scene/Scene.js

+16-16
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,7 @@ define([
577577
this._cameraVR = undefined;
578578
this._aspectRatioVR = undefined;
579579

580-
this.frustumSize2D = 1.0e6;
580+
this.frustumSize2D = 1.75e6;
581581

582582
// initial guess at frustums.
583583
var near = camera.frustum.near;
@@ -1099,7 +1099,7 @@ define([
10991099
curFar = Math.min(far, farToNearRatio * curNear);
11001100
} else {
11011101
curNear = near + m * frustumSize2D;
1102-
curFar = curNear + frustumSize2D;
1102+
curFar = Math.min(far, curNear + frustumSize2D);
11031103
}
11041104

11051105
var frustumCommands = frustumCommandsList[m];
@@ -1562,6 +1562,8 @@ define([
15621562
var clearDepth = scene._depthClearCommand;
15631563
var depthPlane = scene._depthPlane;
15641564

1565+
var height2D = camera.position.z;
1566+
15651567
// Execute commands in each frustum in back to front order
15661568
var j;
15671569
var frustumCommandsList = scene._frustumCommandsList;
@@ -1571,18 +1573,10 @@ define([
15711573
var index = numFrustums - i - 1;
15721574
var frustumCommands = frustumCommandsList[index];
15731575

1574-
if (scene.mode !== SceneMode.SCENE2D) {
1575-
// Avoid tearing artifacts between adjacent frustums in the opaque passes
1576-
frustum.near = index !== 0 ? frustumCommands.near * OPAQUE_FRUSTUM_NEAR_OFFSET : frustumCommands.near;
1577-
frustum.far = frustumCommands.far;
1578-
us.updateFrustum(frustum);
1579-
} else {
1580-
camera.position.z = frustum.right - frustum.left;//frustumCommands.near + 1.0;
1581-
frustum.far = frustumCommands.far - frustumCommands.near;
1582-
frustum.near = 1.0;
1583-
us.update(scene.frameState);
1584-
us.updateFrustum(frustum);
1585-
}
1576+
// Avoid tearing artifacts between adjacent frustums in the opaque passes
1577+
frustum.near = index !== 0 ? frustumCommands.near * OPAQUE_FRUSTUM_NEAR_OFFSET : frustumCommands.near;
1578+
frustum.far = frustumCommands.far;
1579+
us.updateFrustum(frustum);
15861580

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

@@ -1624,6 +1618,14 @@ define([
16241618
}
16251619
}
16261620

1621+
if (scene.mode === SceneMode.SCENE2D) {
1622+
camera.position.z = height2D - frustumCommands.near + 1.0;
1623+
frustum.far = Math.max(1.0, frustumCommands.far - frustumCommands.near);
1624+
frustum.near = 1.0;
1625+
us.update(scene.frameState);
1626+
us.updateFrustum(frustum);
1627+
}
1628+
16271629
// Execute commands in order by pass up to the translucent pass.
16281630
// Translucent geometry needs special handling (sorting/OIT).
16291631
var startPass = Pass.GROUND + 1;
@@ -1648,14 +1650,12 @@ define([
16481650
commands.length = frustumCommands.indices[Pass.TRANSLUCENT];
16491651
executeTranslucentCommands(scene, executeCommand, passState, commands);
16501652

1651-
/*
16521653
if (defined(globeDepth) && environmentState.useGlobeDepthFramebuffer && scene.useDepthPicking) {
16531654
// PERFORMANCE_IDEA: Use MRT to avoid the extra copy.
16541655
var pickDepth = getPickDepth(scene, index);
16551656
pickDepth.update(context, globeDepth.framebuffer.depthStencilTexture);
16561657
pickDepth.executeCopyDepth(context, passState);
16571658
}
1658-
*/
16591659
}
16601660
}
16611661

0 commit comments

Comments
 (0)