@@ -168,6 +168,13 @@ define([
168
168
* @private
169
169
*/
170
170
this . _clippingPlanes = undefined ;
171
+
172
+ /**
173
+ * A property specifying a {@link Rectangle} used to selectively prevent tiles outside a region from loading.
174
+ * For limiting terrain in scenes that use custom projections or Proj4JS projections that cause overlapping tiles.
175
+ * @type {Rectangle }
176
+ */
177
+ this . geographicLimitRectangle = Rectangle . clone ( Rectangle . MAX_VALUE ) ;
171
178
}
172
179
173
180
defineProperties ( GlobeSurfaceTileProvider . prototype , {
@@ -509,6 +516,7 @@ define([
509
516
} ;
510
517
511
518
var boundingSphereScratch = new BoundingSphere ( ) ;
519
+ var rectangleIntersectionScratch = new Rectangle ( ) ;
512
520
513
521
/**
514
522
* Determines the visibility of a given tile. The tile may be fully visible, partially visible, or not
@@ -536,6 +544,16 @@ define([
536
544
var cullingVolume = frameState . cullingVolume ;
537
545
var boundingVolume = defaultValue ( surfaceTile . orientedBoundingBox , surfaceTile . boundingSphere3D ) ;
538
546
547
+ // Check if the tile is outside the limit area in cartographic space
548
+ surfaceTile . clippedByBoundaries = false ;
549
+ var areaLimitIntersection = Rectangle . simpleIntersection ( this . geographicLimitRectangle , tile . rectangle , rectangleIntersectionScratch ) ;
550
+ if ( ! defined ( areaLimitIntersection ) ) {
551
+ return Visibility . NONE ;
552
+ }
553
+ if ( ! Rectangle . equals ( areaLimitIntersection , tile . rectangle ) ) {
554
+ surfaceTile . clippedByBoundaries = true ;
555
+ }
556
+
539
557
if ( frameState . mode !== SceneMode . SCENE3D ) {
540
558
boundingVolume = boundingSphereScratch ;
541
559
BoundingSphere . fromRectangleWithHeights2D ( tile . rectangle , frameState . mapProjection , surfaceTile . minimumHeight , surfaceTile . maximumHeight , boundingVolume ) ;
@@ -580,6 +598,7 @@ define([
580
598
var modifiedModelViewScratch = new Matrix4 ( ) ;
581
599
var modifiedModelViewProjectionScratch = new Matrix4 ( ) ;
582
600
var tileRectangleScratch = new Cartesian4 ( ) ;
601
+ var localizedGeographicLimitRectangleScratch = new Cartesian4 ( ) ;
583
602
var rtcScratch = new Cartesian3 ( ) ;
584
603
var centerEyeScratch = new Cartesian3 ( ) ;
585
604
var southwestScratch = new Cartesian3 ( ) ;
@@ -921,6 +940,9 @@ define([
921
940
}
922
941
return frameState . context . defaultTexture ;
923
942
} ,
943
+ u_geographicLimitRectangle : function ( ) {
944
+ return this . properties . localizedGeographicLimitRectangle ;
945
+ } ,
924
946
u_clippingPlanesMatrix : function ( ) {
925
947
var clippingPlanes = globeSurfaceTileProvider . _clippingPlanes ;
926
948
return defined ( clippingPlanes ) ? Matrix4 . multiply ( frameState . context . uniformState . view , clippingPlanes . modelMatrix , scratchClippingPlaneMatrix ) : Matrix4 . IDENTITY ;
@@ -969,7 +991,9 @@ define([
969
991
minMaxHeight : new Cartesian2 ( ) ,
970
992
scaleAndBias : new Matrix4 ( ) ,
971
993
clippingPlanesEdgeColor : Color . clone ( Color . WHITE ) ,
972
- clippingPlanesEdgeWidth : 0.0
994
+ clippingPlanesEdgeWidth : 0.0 ,
995
+
996
+ localizedGeographicLimitRectangle : new Cartesian4 ( )
973
997
}
974
998
} ;
975
999
@@ -1255,6 +1279,20 @@ define([
1255
1279
uniformMapProperties . southMercatorYAndOneOverHeight . x = southMercatorY ;
1256
1280
uniformMapProperties . southMercatorYAndOneOverHeight . y = oneOverMercatorHeight ;
1257
1281
1282
+ // Convert tile limiter rectangle from cartographic to texture space using the tileRectangle.
1283
+ var localizedGeographicLimitRectangle = localizedGeographicLimitRectangleScratch ;
1284
+ var geographicLimitRectangle = tileProvider . geographicLimitRectangle ;
1285
+
1286
+ var cartographicTileRectangle = tile . rectangle ;
1287
+ var inverseTileWidth = 1.0 / cartographicTileRectangle . width ;
1288
+ var inverseTileHeight = 1.0 / cartographicTileRectangle . height ;
1289
+ localizedGeographicLimitRectangle . x = ( geographicLimitRectangle . west - cartographicTileRectangle . west ) * inverseTileWidth ;
1290
+ localizedGeographicLimitRectangle . y = ( geographicLimitRectangle . south - cartographicTileRectangle . south ) * inverseTileHeight ;
1291
+ localizedGeographicLimitRectangle . z = ( geographicLimitRectangle . east - cartographicTileRectangle . west ) * inverseTileWidth ;
1292
+ localizedGeographicLimitRectangle . w = ( geographicLimitRectangle . north - cartographicTileRectangle . south ) * inverseTileHeight ;
1293
+
1294
+ Cartesian4 . clone ( localizedGeographicLimitRectangle , uniformMapProperties . localizedGeographicLimitRectangle ) ;
1295
+
1258
1296
// For performance, use fog in the shader only when the tile is in fog.
1259
1297
var applyFog = enableFog && CesiumMath . fog ( tile . _distance , frameState . fog . density ) > CesiumMath . EPSILON3 ;
1260
1298
@@ -1357,7 +1395,7 @@ define([
1357
1395
uniformMap = combine ( uniformMap , tileProvider . uniformMap ) ;
1358
1396
}
1359
1397
1360
- command . shaderProgram = tileProvider . _surfaceShaderSet . getShaderProgram ( frameState , surfaceTile , numberOfDayTextures , applyBrightness , applyContrast , applyHue , applySaturation , applyGamma , applyAlpha , applySplit , showReflectiveOcean , showOceanWaves , tileProvider . enableLighting , hasVertexNormals , useWebMercatorProjection , applyFog , clippingPlanesEnabled , clippingPlanes ) ;
1398
+ command . shaderProgram = tileProvider . _surfaceShaderSet . getShaderProgram ( frameState , surfaceTile , numberOfDayTextures , applyBrightness , applyContrast , applyHue , applySaturation , applyGamma , applyAlpha , applySplit , showReflectiveOcean , showOceanWaves , tileProvider . enableLighting , hasVertexNormals , useWebMercatorProjection , applyFog , clippingPlanesEnabled , clippingPlanes , surfaceTile . clippedByBoundaries ) ;
1361
1399
command . castShadows = castShadows ;
1362
1400
command . receiveShadows = receiveShadows ;
1363
1401
command . renderState = renderState ;
0 commit comments