@@ -25,7 +25,8 @@ defineSuite([
25
25
'Specs/Cesium3DTilesTester' ,
26
26
'Specs/createCanvas' ,
27
27
'Specs/createScene' ,
28
- 'Specs/pollToPromise'
28
+ 'Specs/pollToPromise' ,
29
+ 'ThirdParty/when'
29
30
] , 'Scene/Pick' , function (
30
31
Cartesian3 ,
31
32
Cartographic ,
@@ -53,7 +54,8 @@ defineSuite([
53
54
Cesium3DTilesTester ,
54
55
createCanvas ,
55
56
createScene ,
56
- pollToPromise ) {
57
+ pollToPromise ,
58
+ when ) {
57
59
'use strict' ;
58
60
59
61
// It's not easily possible to mock the asynchronous pick functions
@@ -69,6 +71,9 @@ defineSuite([
69
71
var primitiveRay ;
70
72
var offscreenRay ;
71
73
74
+ var batchedTilesetUrl = 'Data/Cesium3DTiles/Batched/BatchedWithTransformBox/tileset.json' ;
75
+ var pointCloudTilesetUrl = 'Data/Cesium3DTiles/PointCloud/PointCloudWithTransform/tileset.json' ;
76
+
72
77
beforeAll ( function ( ) {
73
78
scene = createScene ( {
74
79
canvas : createCanvas ( 10 , 10 )
@@ -138,8 +143,7 @@ defineSuite([
138
143
return createRectangle ( height , smallRectangle ) ;
139
144
}
140
145
141
- function createTileset ( ) {
142
- var url = 'Data/Cesium3DTiles/Batched/BatchedWithTransformBox/tileset.json' ;
146
+ function createTileset ( url ) {
143
147
var options = {
144
148
maximumScreenSpaceError : 0
145
149
} ;
@@ -442,7 +446,7 @@ defineSuite([
442
446
} ) ;
443
447
444
448
function picksFromRayTileset ( style ) {
445
- return createTileset ( ) . then ( function ( tileset ) {
449
+ return createTileset ( batchedTilesetUrl ) . then ( function ( tileset ) {
446
450
tileset . style = style ;
447
451
expect ( scene ) . toPickFromRayAndCall ( function ( result ) {
448
452
var primitive = result . object . primitive ;
@@ -561,7 +565,18 @@ defineSuite([
561
565
expect ( scene ) . toPickFromRayAndCall ( function ( result ) {
562
566
expect ( result . object . primitive ) . toBe ( point ) ;
563
567
expect ( result . position ) . toBeUndefined ( ) ;
564
- } , primitiveRay ) ;
568
+ } , primitiveRay , [ ] , 0.01 ) ;
569
+ } ) ;
570
+
571
+ it ( 'changes width' , function ( ) {
572
+ return createTileset ( pointCloudTilesetUrl ) . then ( function ( tileset ) {
573
+ expect ( scene ) . toPickFromRayAndCall ( function ( result ) {
574
+ expect ( result ) . toBeUndefined ( ) ;
575
+ } , primitiveRay , [ ] , 0.1 ) ;
576
+ expect ( scene ) . toPickFromRayAndCall ( function ( result ) {
577
+ expect ( result ) . toBeDefined ( ) ;
578
+ } , primitiveRay , [ ] , 1.0 ) ;
579
+ } ) ;
565
580
} ) ;
566
581
567
582
it ( 'throws if ray is undefined' , function ( ) {
@@ -812,6 +827,17 @@ defineSuite([
812
827
} , primitiveRay , 2 , [ rectangle5 , rectangle3 ] ) ;
813
828
} ) ;
814
829
830
+ it ( 'changes width' , function ( ) {
831
+ return createTileset ( pointCloudTilesetUrl ) . then ( function ( tileset ) {
832
+ expect ( scene ) . toDrillPickFromRayAndCall ( function ( result ) {
833
+ expect ( result . length ) . toBe ( 0 ) ;
834
+ } , primitiveRay , [ ] , 0.1 ) ;
835
+ expect ( scene ) . toDrillPickFromRayAndCall ( function ( result ) {
836
+ expect ( result . length ) . toBe ( 1 ) ;
837
+ } , primitiveRay , Number . POSITIVE_INFINITY , [ ] , 1.0 ) ;
838
+ } ) ;
839
+ } ) ;
840
+
815
841
it ( 'throws if ray is undefined' , function ( ) {
816
842
expect ( function ( ) {
817
843
scene . drillPickFromRay ( undefined ) ;
@@ -840,7 +866,7 @@ defineSuite([
840
866
}
841
867
842
868
var cartographic = new Cartographic ( 0.0 , 0.0 ) ;
843
- return createTileset ( ) . then ( function ( tileset ) {
869
+ return createTileset ( batchedTilesetUrl ) . then ( function ( tileset ) {
844
870
expect ( scene ) . toSampleHeightAndCall ( function ( height ) {
845
871
expect ( height ) . toBeGreaterThan ( 0.0 ) ;
846
872
expect ( height ) . toBeLessThan ( 20.0 ) ; // Rough height of tile
@@ -940,6 +966,22 @@ defineSuite([
940
966
} , cartographic ) ;
941
967
} ) ;
942
968
969
+ it ( 'changes width' , function ( ) {
970
+ if ( ! scene . sampleHeightSupported ) {
971
+ return ;
972
+ }
973
+
974
+ var cartographic = new Cartographic ( 0.0 , 0.0 ) ;
975
+ return createTileset ( pointCloudTilesetUrl ) . then ( function ( tileset ) {
976
+ expect ( scene ) . toSampleHeightAndCall ( function ( height ) {
977
+ expect ( height ) . toBeUndefined ( ) ;
978
+ } , cartographic , [ ] , 0.1 ) ;
979
+ expect ( scene ) . toSampleHeightAndCall ( function ( height ) {
980
+ expect ( height ) . toBeDefined ( ) ;
981
+ } , cartographic , [ ] , 1.0 ) ;
982
+ } ) ;
983
+ } ) ;
984
+
943
985
it ( 'throws if position is undefined' , function ( ) {
944
986
if ( ! scene . sampleHeightSupported ) {
945
987
return ;
@@ -999,7 +1041,7 @@ defineSuite([
999
1041
}
1000
1042
1001
1043
var cartesian = Cartesian3 . fromRadians ( 0.0 , 0.0 , 100000.0 ) ;
1002
- return createTileset ( ) . then ( function ( tileset ) {
1044
+ return createTileset ( batchedTilesetUrl ) . then ( function ( tileset ) {
1003
1045
expect ( scene ) . toClampToHeightAndCall ( function ( position ) {
1004
1046
var minimumHeight = Cartesian3 . fromRadians ( 0.0 , 0.0 ) . x ;
1005
1047
var maximumHeight = minimumHeight + 20.0 ; // Rough height of tile
@@ -1105,6 +1147,22 @@ defineSuite([
1105
1147
} , cartesian ) ;
1106
1148
} ) ;
1107
1149
1150
+ it ( 'changes width' , function ( ) {
1151
+ if ( ! scene . clampToHeightSupported ) {
1152
+ return ;
1153
+ }
1154
+
1155
+ var cartesian = Cartesian3 . fromRadians ( 0.0 , 0.0 , 100.0 ) ;
1156
+ return createTileset ( pointCloudTilesetUrl ) . then ( function ( tileset ) {
1157
+ expect ( scene ) . toClampToHeightAndCall ( function ( clampedCartesian ) {
1158
+ expect ( clampedCartesian ) . toBeUndefined ( ) ;
1159
+ } , cartesian , [ ] , 0.1 ) ;
1160
+ expect ( scene ) . toClampToHeightAndCall ( function ( clampedCartesian ) {
1161
+ expect ( clampedCartesian ) . toBeDefined ( ) ;
1162
+ } , cartesian , [ ] , 1.0 ) ;
1163
+ } ) ;
1164
+ } ) ;
1165
+
1108
1166
it ( 'throws if cartesian is undefined' , function ( ) {
1109
1167
if ( ! scene . clampToHeightSupported ) {
1110
1168
return ;
@@ -1157,10 +1215,10 @@ defineSuite([
1157
1215
} ) ;
1158
1216
} ) ;
1159
1217
1160
- function pickFromRayMostDetailed ( ray , objectsToExclude ) {
1218
+ function pickFromRayMostDetailed ( ray , objectsToExclude , width ) {
1161
1219
var result ;
1162
1220
var completed = false ;
1163
- scene . pickFromRayMostDetailed ( ray , objectsToExclude ) . then ( function ( pickResult ) {
1221
+ scene . pickFromRayMostDetailed ( ray , objectsToExclude , width ) . then ( function ( pickResult ) {
1164
1222
result = pickResult ;
1165
1223
completed = true ;
1166
1224
} ) ;
@@ -1173,10 +1231,10 @@ defineSuite([
1173
1231
} ) ;
1174
1232
}
1175
1233
1176
- function drillPickFromRayMostDetailed ( ray , limit , objectsToExclude ) {
1234
+ function drillPickFromRayMostDetailed ( ray , limit , objectsToExclude , width ) {
1177
1235
var result ;
1178
1236
var completed = false ;
1179
- scene . drillPickFromRayMostDetailed ( ray , limit , objectsToExclude ) . then ( function ( pickResult ) {
1237
+ scene . drillPickFromRayMostDetailed ( ray , limit , objectsToExclude , width ) . then ( function ( pickResult ) {
1180
1238
result = pickResult ;
1181
1239
completed = true ;
1182
1240
} ) ;
@@ -1189,10 +1247,10 @@ defineSuite([
1189
1247
} ) ;
1190
1248
}
1191
1249
1192
- function sampleHeightMostDetailed ( cartographics , objectsToExclude ) {
1250
+ function sampleHeightMostDetailed ( cartographics , objectsToExclude , width ) {
1193
1251
var result ;
1194
1252
var completed = false ;
1195
- scene . sampleHeightMostDetailed ( cartographics , objectsToExclude ) . then ( function ( pickResult ) {
1253
+ scene . sampleHeightMostDetailed ( cartographics , objectsToExclude , width ) . then ( function ( pickResult ) {
1196
1254
result = pickResult ;
1197
1255
completed = true ;
1198
1256
} ) ;
@@ -1205,10 +1263,10 @@ defineSuite([
1205
1263
} ) ;
1206
1264
}
1207
1265
1208
- function clampToHeightMostDetailed ( cartesians , objectsToExclude ) {
1266
+ function clampToHeightMostDetailed ( cartesians , objectsToExclude , width ) {
1209
1267
var result ;
1210
1268
var completed = false ;
1211
- scene . clampToHeightMostDetailed ( cartesians , objectsToExclude ) . then ( function ( pickResult ) {
1269
+ scene . clampToHeightMostDetailed ( cartesians , objectsToExclude , width ) . then ( function ( pickResult ) {
1212
1270
result = pickResult ;
1213
1271
completed = true ;
1214
1272
} ) ;
@@ -1227,7 +1285,7 @@ defineSuite([
1227
1285
return ;
1228
1286
}
1229
1287
scene . camera . setView ( { destination : offscreenRectangle } ) ;
1230
- return createTileset ( ) . then ( function ( tileset ) {
1288
+ return createTileset ( batchedTilesetUrl ) . then ( function ( tileset ) {
1231
1289
return pickFromRayMostDetailed ( primitiveRay ) . then ( function ( result ) {
1232
1290
var primitive = result . object . primitive ;
1233
1291
var position = result . position ;
@@ -1251,7 +1309,7 @@ defineSuite([
1251
1309
return ;
1252
1310
}
1253
1311
scene . camera . setView ( { destination : offscreenRectangle } ) ;
1254
- return createTileset ( ) . then ( function ( tileset ) {
1312
+ return createTileset ( batchedTilesetUrl ) . then ( function ( tileset ) {
1255
1313
var objectsToExclude = [ tileset ] ;
1256
1314
return pickFromRayMostDetailed ( primitiveRay , objectsToExclude ) . then ( function ( result ) {
1257
1315
expect ( result ) . toBeUndefined ( ) ;
@@ -1264,7 +1322,7 @@ defineSuite([
1264
1322
return ;
1265
1323
}
1266
1324
scene . camera . setView ( { destination : offscreenRectangle } ) ;
1267
- return createTileset ( ) . then ( function ( tileset ) {
1325
+ return createTileset ( batchedTilesetUrl ) . then ( function ( tileset ) {
1268
1326
tileset . show = false ;
1269
1327
return pickFromRayMostDetailed ( primitiveRay ) . then ( function ( result ) {
1270
1328
expect ( result ) . toBeUndefined ( ) ;
@@ -1345,12 +1403,27 @@ defineSuite([
1345
1403
} ) ;
1346
1404
1347
1405
scene . camera . setView ( { destination : offscreenRectangle } ) ;
1348
- return pickFromRayMostDetailed ( primitiveRay ) . then ( function ( result ) {
1406
+ return pickFromRayMostDetailed ( primitiveRay , [ ] , 0.01 ) . then ( function ( result ) {
1349
1407
expect ( result . object . primitive ) . toBe ( point ) ;
1350
1408
expect ( result . position ) . toBeUndefined ( ) ;
1351
1409
} ) ;
1352
1410
} ) ;
1353
1411
1412
+ it ( 'changes width' , function ( ) {
1413
+ if ( webglStub ) {
1414
+ return ;
1415
+ }
1416
+ return createTileset ( pointCloudTilesetUrl ) . then ( function ( tileset ) {
1417
+ var promise1 = pickFromRayMostDetailed ( primitiveRay , [ ] , 0.1 ) . then ( function ( result ) {
1418
+ expect ( result ) . toBeUndefined ( ) ;
1419
+ } ) ;
1420
+ var promise2 = pickFromRayMostDetailed ( primitiveRay , [ ] , 1.0 ) . then ( function ( result ) {
1421
+ expect ( result ) . toBeDefined ( ) ;
1422
+ } ) ;
1423
+ return when . all ( [ promise1 , promise2 ] ) ;
1424
+ } ) ;
1425
+ } ) ;
1426
+
1354
1427
it ( 'throws if ray is undefined' , function ( ) {
1355
1428
expect ( function ( ) {
1356
1429
scene . pickFromRayMostDetailed ( undefined ) ;
@@ -1639,6 +1712,21 @@ defineSuite([
1639
1712
} ) ;
1640
1713
} ) ;
1641
1714
1715
+ it ( 'changes width' , function ( ) {
1716
+ if ( webglStub ) {
1717
+ return ;
1718
+ }
1719
+ return createTileset ( pointCloudTilesetUrl ) . then ( function ( tileset ) {
1720
+ var promise1 = drillPickFromRayMostDetailed ( primitiveRay , 1 , [ ] , 0.1 ) . then ( function ( result ) {
1721
+ expect ( result . length ) . toBe ( 0 ) ;
1722
+ } ) ;
1723
+ var promise2 = drillPickFromRayMostDetailed ( primitiveRay , 1 , [ ] , 1.0 ) . then ( function ( result ) {
1724
+ expect ( result . length ) . toBe ( 1 ) ;
1725
+ } ) ;
1726
+ return when . all ( [ promise1 , promise2 ] ) ;
1727
+ } ) ;
1728
+ } ) ;
1729
+
1642
1730
it ( 'throws if ray is undefined' , function ( ) {
1643
1731
expect ( function ( ) {
1644
1732
scene . drillPickFromRayMostDetailed ( undefined ) ;
@@ -1667,7 +1755,7 @@ defineSuite([
1667
1755
}
1668
1756
1669
1757
var cartographics = [ new Cartographic ( 0.0 , 0.0 ) ] ;
1670
- return createTileset ( ) . then ( function ( ) {
1758
+ return createTileset ( batchedTilesetUrl ) . then ( function ( ) {
1671
1759
return sampleHeightMostDetailed ( cartographics ) . then ( function ( updatedCartographics ) {
1672
1760
var height = updatedCartographics [ 0 ] . height ;
1673
1761
expect ( height ) . toBeGreaterThan ( 0.0 ) ;
@@ -1829,6 +1917,24 @@ defineSuite([
1829
1917
} ) ;
1830
1918
} ) ;
1831
1919
1920
+ it ( 'changes width' , function ( ) {
1921
+ if ( ! scene . sampleHeightSupported ) {
1922
+ return ;
1923
+ }
1924
+
1925
+ var cartographics1 = [ new Cartographic ( 0.0 , 0.0 ) ] ;
1926
+ var cartographics2 = [ new Cartographic ( 0.0 , 0.0 ) ] ;
1927
+ return createTileset ( pointCloudTilesetUrl ) . then ( function ( tileset ) {
1928
+ var promise1 = sampleHeightMostDetailed ( cartographics1 , [ ] , 0.1 ) . then ( function ( updatedCartographics1 ) {
1929
+ expect ( updatedCartographics1 [ 0 ] . height ) . toBeUndefined ( ) ;
1930
+ } ) ;
1931
+ var promise2 = sampleHeightMostDetailed ( cartographics2 , [ ] , 1.0 ) . then ( function ( updatedCartographics2 ) {
1932
+ expect ( updatedCartographics2 [ 0 ] . height ) . toBeDefined ( ) ;
1933
+ } ) ;
1934
+ return when . all ( [ promise1 , promise2 ] ) ;
1935
+ } ) ;
1936
+ } ) ;
1937
+
1832
1938
it ( 'handles empty array' , function ( ) {
1833
1939
if ( ! scene . sampleHeightSupported ) {
1834
1940
return ;
@@ -1899,7 +2005,7 @@ defineSuite([
1899
2005
}
1900
2006
1901
2007
var cartesians = [ Cartesian3 . fromRadians ( 0.0 , 0.0 , 100000.0 ) ] ;
1902
- return createTileset ( ) . then ( function ( ) {
2008
+ return createTileset ( batchedTilesetUrl ) . then ( function ( ) {
1903
2009
return clampToHeightMostDetailed ( cartesians ) . then ( function ( updatedCartesians ) {
1904
2010
var minimumHeight = Cartesian3 . fromRadians ( 0.0 , 0.0 ) . x ;
1905
2011
var maximumHeight = minimumHeight + 20.0 ; // Rough height of tile
@@ -2073,6 +2179,25 @@ defineSuite([
2073
2179
} ) ;
2074
2180
} ) ;
2075
2181
2182
+ it ( 'changes width' , function ( ) {
2183
+ if ( ! scene . clampToHeightSupported ) {
2184
+ return ;
2185
+ }
2186
+
2187
+ var cartesian = Cartesian3 . fromRadians ( 0.0 , 0.0 , 100.0 ) ;
2188
+ var cartesians1 = [ Cartesian3 . clone ( cartesian ) ] ;
2189
+ var cartesians2 = [ Cartesian3 . clone ( cartesian ) ] ;
2190
+ return createTileset ( pointCloudTilesetUrl ) . then ( function ( tileset ) {
2191
+ var promise1 = clampToHeightMostDetailed ( cartesians1 , [ ] , 0.1 ) . then ( function ( clampedCartesians1 ) {
2192
+ expect ( clampedCartesians1 [ 0 ] ) . toBeUndefined ( ) ;
2193
+ } ) ;
2194
+ var promise2 = clampToHeightMostDetailed ( cartesians2 , [ ] , 1.0 ) . then ( function ( clampedCartesians2 ) {
2195
+ expect ( clampedCartesians2 [ 0 ] ) . toBeDefined ( ) ;
2196
+ } ) ;
2197
+ return when . all ( [ promise1 , promise2 ] ) ;
2198
+ } ) ;
2199
+ } ) ;
2200
+
2076
2201
it ( 'handles empty array' , function ( ) {
2077
2202
if ( ! scene . clampToHeightSupported ) {
2078
2203
return ;
0 commit comments