@cesium/engine 4.0.0 → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. package/Build/Workers/{chunk-SGRWJKNO.js → chunk-2AEUVYIC.js} +15 -15
  2. package/Build/Workers/{chunk-FKHRSGKP.js → chunk-2HEFBNI2.js} +13 -13
  3. package/Build/Workers/{chunk-2C65EKYA.js → chunk-2IZ2LJ3N.js} +1 -1
  4. package/Build/Workers/{chunk-YLS3FX3U.js → chunk-3ENSLRZD.js} +7 -7
  5. package/Build/Workers/{chunk-H6MBQ4W4.js → chunk-3FNFTDKS.js} +4 -4
  6. package/Build/Workers/{chunk-27R2KRIK.js → chunk-437Q4WBM.js} +6 -6
  7. package/Build/Workers/{chunk-RRUPTJ6P.js → chunk-54QBXZYE.js} +6 -6
  8. package/Build/Workers/{chunk-UN7AK64D.js → chunk-6EZ4NFIC.js} +2 -2
  9. package/Build/Workers/{chunk-YMJPANZZ.js → chunk-7FAOTOUR.js} +10 -34
  10. package/Build/Workers/{chunk-KAFF2QX3.js → chunk-7W3AMBD6.js} +5 -5
  11. package/Build/Workers/{chunk-PWDYKCNC.js → chunk-A7T4GOG3.js} +4 -4
  12. package/Build/Workers/{chunk-LGSGX2RH.js → chunk-AMGYJNEB.js} +10 -10
  13. package/Build/Workers/{chunk-F7P2HCYZ.js → chunk-ASJKRCO4.js} +2 -2
  14. package/Build/Workers/chunk-AXODHVUI.js +55 -0
  15. package/Build/Workers/{chunk-P7PWX5HR.js → chunk-BKVKFLIC.js} +7 -7
  16. package/Build/Workers/{chunk-YLAFWVOW.js → chunk-BWTCHYX6.js} +10 -10
  17. package/Build/Workers/{chunk-DJUTBX6A.js → chunk-BZHAJSUN.js} +2 -2
  18. package/Build/Workers/{chunk-LQRFWCNX.js → chunk-CBV4JE6S.js} +5 -5
  19. package/Build/Workers/{chunk-BT6YIL2N.js → chunk-CGHLEZ43.js} +1 -1
  20. package/Build/Workers/{chunk-TF5D2H7B.js → chunk-CLVX47CD.js} +5 -5
  21. package/Build/Workers/{chunk-P4M4QUNQ.js → chunk-DI3VM6NF.js} +6 -6
  22. package/Build/Workers/{chunk-U5LKG6LX.js → chunk-DUMQKN4C.js} +2 -2
  23. package/Build/Workers/{chunk-H52L6U76.js → chunk-DZUFRYQK.js} +11 -11
  24. package/Build/Workers/{chunk-RDCDRNJ7.js → chunk-EFUPZTUD.js} +6 -6
  25. package/Build/Workers/{chunk-PW5CA4MJ.js → chunk-EJWAO37W.js} +7 -7
  26. package/Build/Workers/{chunk-A6EA6KIE.js → chunk-EZPA2AXQ.js} +1 -1
  27. package/Build/Workers/{chunk-7CZEWQWE.js → chunk-FBRBVOAJ.js} +6 -6
  28. package/Build/Workers/{chunk-PGB3EFR7.js → chunk-FDNL4I6K.js} +6 -6
  29. package/Build/Workers/{chunk-FYHCAKU6.js → chunk-FK5BM4WD.js} +11 -11
  30. package/Build/Workers/{chunk-527JG4D7.js → chunk-GQ66IPL6.js} +1 -1
  31. package/Build/Workers/{chunk-V2LKNJGT.js → chunk-HW6ANEVG.js} +5 -5
  32. package/Build/Workers/{chunk-2NLMZNJI.js → chunk-HYNBEK4C.js} +4 -4
  33. package/Build/Workers/{chunk-N5MMDSD2.js → chunk-I6R5G76Q.js} +2 -2
  34. package/Build/Workers/{chunk-XZVQMPWG.js → chunk-J5YKECLG.js} +5 -5
  35. package/Build/Workers/{chunk-7IMAWM6A.js → chunk-KGVHVTX7.js} +229 -17
  36. package/Build/Workers/{chunk-QIS3NB7U.js → chunk-KXTDRKW5.js} +7 -7
  37. package/Build/Workers/{chunk-4VWUFKYW.js → chunk-LCMSJE5D.js} +12 -12
  38. package/Build/Workers/{chunk-XJCTFTBM.js → chunk-M57VBCI4.js} +5 -5
  39. package/Build/Workers/{chunk-EQ6ZAP37.js → chunk-MOSBHBQO.js} +7 -7
  40. package/Build/Workers/{chunk-FE2XG3SS.js → chunk-MQ32KIOU.js} +3 -3
  41. package/Build/Workers/{chunk-TVYIHH4V.js → chunk-PZKVP2WI.js} +14 -14
  42. package/Build/Workers/{chunk-NRETMGYL.js → chunk-SAYI6XNA.js} +13 -13
  43. package/Build/Workers/{chunk-5U4UHRZ2.js → chunk-TV4Q4TKV.js} +10 -10
  44. package/Build/Workers/{chunk-4V6RCTVH.js → chunk-TWN33EAP.js} +10 -10
  45. package/Build/Workers/{chunk-AXGQUPXA.js → chunk-VBOAZG67.js} +17 -17
  46. package/Build/Workers/{chunk-UGZGTV5K.js → chunk-VEPSTOBV.js} +8 -8
  47. package/Build/Workers/{chunk-C6MRR5YL.js → chunk-W2LZZCAF.js} +7 -7
  48. package/Build/Workers/{chunk-VSCXSFHE.js → chunk-XEOY7FXL.js} +13 -13
  49. package/Build/Workers/{chunk-QVJ6IRKV.js → chunk-XZKRFAT7.js} +1 -1
  50. package/Build/Workers/{chunk-I5MQWHBR.js → chunk-YOZZHZVR.js} +4 -4
  51. package/Build/Workers/{chunk-RDM3BKNC.js → chunk-Z6SS6KIF.js} +11 -11
  52. package/Build/Workers/{chunk-FVDTKX3F.js → chunk-ZADWOYGF.js} +2 -2
  53. package/Build/Workers/{chunk-G3MOT7BZ.js → chunk-ZBTL2GWA.js} +6 -6
  54. package/Build/Workers/{chunk-HCZR75II.js → chunk-ZEHXFKIR.js} +15 -15
  55. package/Build/Workers/combineGeometry.js +23 -23
  56. package/Build/Workers/createBoxGeometry.js +17 -17
  57. package/Build/Workers/createBoxOutlineGeometry.js +15 -15
  58. package/Build/Workers/createCircleGeometry.js +25 -25
  59. package/Build/Workers/createCircleOutlineGeometry.js +18 -18
  60. package/Build/Workers/createCoplanarPolygonGeometry.js +32 -32
  61. package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +30 -30
  62. package/Build/Workers/createCorridorGeometry.js +29 -28
  63. package/Build/Workers/createCorridorOutlineGeometry.js +28 -27
  64. package/Build/Workers/createCylinderGeometry.js +19 -19
  65. package/Build/Workers/createCylinderOutlineGeometry.js +17 -17
  66. package/Build/Workers/createEllipseGeometry.js +25 -25
  67. package/Build/Workers/createEllipseOutlineGeometry.js +18 -18
  68. package/Build/Workers/createEllipsoidGeometry.js +18 -18
  69. package/Build/Workers/createEllipsoidOutlineGeometry.js +17 -17
  70. package/Build/Workers/createFrustumGeometry.js +17 -17
  71. package/Build/Workers/createFrustumOutlineGeometry.js +17 -17
  72. package/Build/Workers/createGeometry.js +23 -23
  73. package/Build/Workers/createGroundPolylineGeometry.js +21 -21
  74. package/Build/Workers/createPlaneGeometry.js +15 -15
  75. package/Build/Workers/createPlaneOutlineGeometry.js +14 -14
  76. package/Build/Workers/createPolygonGeometry.js +469 -60
  77. package/Build/Workers/createPolygonOutlineGeometry.js +29 -29
  78. package/Build/Workers/createPolylineGeometry.js +24 -24
  79. package/Build/Workers/createPolylineVolumeGeometry.js +33 -31
  80. package/Build/Workers/createPolylineVolumeOutlineGeometry.js +27 -26
  81. package/Build/Workers/createRectangleGeometry.js +26 -26
  82. package/Build/Workers/createRectangleOutlineGeometry.js +19 -19
  83. package/Build/Workers/createSimplePolylineGeometry.js +22 -22
  84. package/Build/Workers/createSphereGeometry.js +18 -18
  85. package/Build/Workers/createSphereOutlineGeometry.js +17 -17
  86. package/Build/Workers/createTaskProcessorWorker.js +3 -3
  87. package/Build/Workers/createVectorTileClampedPolylines.js +14 -14
  88. package/Build/Workers/createVectorTileGeometries.js +23 -23
  89. package/Build/Workers/createVectorTilePoints.js +12 -12
  90. package/Build/Workers/createVectorTilePolygons.js +21 -21
  91. package/Build/Workers/createVectorTilePolylines.js +14 -14
  92. package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +21 -21
  93. package/Build/Workers/createVerticesFromHeightmap.js +21 -21
  94. package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +18 -18
  95. package/Build/Workers/createWallGeometry.js +23 -23
  96. package/Build/Workers/createWallOutlineGeometry.js +22 -22
  97. package/Build/Workers/decodeDraco.js +11 -11
  98. package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +5 -5
  99. package/Build/Workers/decodeI3S.js +9 -9
  100. package/Build/Workers/transcodeKTX2.js +7 -7
  101. package/Build/Workers/transferTypedArrayTest.js +1 -1
  102. package/Build/Workers/upsampleQuantizedTerrainMesh.js +21 -21
  103. package/Source/Core/Credit.js +7 -1
  104. package/Source/Core/GoogleMaps.js +8 -24
  105. package/Source/Core/Ion.js +1 -2
  106. package/Source/Core/PolygonGeometry.js +340 -27
  107. package/Source/Core/PolygonGeometryLibrary.js +302 -1
  108. package/Source/Core/Stereographic.js +247 -0
  109. package/Source/Core/TaskProcessor.js +53 -40
  110. package/Source/Core/buildModuleUrl.js +1 -1
  111. package/Source/Core/sampleTerrain.js +43 -10
  112. package/Source/Core/sampleTerrainMostDetailed.js +27 -3
  113. package/Source/Scene/ArcGisMapService.js +1 -2
  114. package/Source/Scene/Billboard.js +7 -0
  115. package/Source/Scene/Cesium3DTilePass.js +1 -1
  116. package/Source/Scene/Cesium3DTileset.js +38 -81
  117. package/Source/Scene/CreditDisplay.js +2 -2
  118. package/Source/Scene/LabelCollection.js +3 -1
  119. package/Source/Scene/Model/Model.js +16 -22
  120. package/Source/Scene/PostProcessStageLibrary.js +3 -3
  121. package/Source/Scene/PrimitiveCollection.js +39 -0
  122. package/Source/Scene/Scene.js +3 -0
  123. package/Source/Scene/createGooglePhotorealistic3DTileset.js +38 -8
  124. package/Source/Widget/CesiumWidget.js +2 -1
  125. package/index.d.ts +65 -31
  126. package/index.js +168 -167
  127. package/package.json +1 -1
@@ -4,7 +4,7 @@ import Resource from "./Resource.js";
4
4
 
5
5
  let defaultTokenCredit;
6
6
  const defaultAccessToken =
7
- "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJlMmIzZjlhMy1kNzU1LTRmMmQtYTFkNi1jMWQ5NTliM2RmN2YiLCJpZCI6MjU5LCJpYXQiOjE2OTM1ODIzNDJ9.-Tpp8s9ismoMrkKqnNsHFEMZgXDfa2uZfBQRE-kn3gM";
7
+ "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJhYjVkZWE2Yi05ZjlmLTQyOTAtYjFkOC0xMmFmZTYyMjhmZGIiLCJpZCI6MjU5LCJpYXQiOjE2OTYyNjgyMzN9.iKIgzd7PueqxXsUNSIhk5C6n8uiugH-Dxy9uhOdJ5Zg";
8
8
  /**
9
9
  * Default settings for accessing the Cesium ion API.
10
10
  *
@@ -49,7 +49,6 @@ Ion.getDefaultTokenCredit = function (providedKey) {
49
49
  You can sign up for a free ion account at <a href="https://cesium.com">https://cesium.com</a>.</b>';
50
50
 
51
51
  defaultTokenCredit = new Credit(defaultTokenMessage, true);
52
- defaultTokenCredit._isDefaultToken = true;
53
52
  }
54
53
 
55
54
  return defaultTokenCredit;
@@ -8,6 +8,7 @@ import Check from "./Check.js";
8
8
  import ComponentDatatype from "./ComponentDatatype.js";
9
9
  import defaultValue from "./defaultValue.js";
10
10
  import defined from "./defined.js";
11
+ import deprecationWarning from "./deprecationWarning.js";
11
12
  import DeveloperError from "./DeveloperError.js";
12
13
  import Ellipsoid from "./Ellipsoid.js";
13
14
  import EllipsoidGeodesic from "./EllipsoidGeodesic.js";
@@ -24,6 +25,7 @@ import PolygonGeometryLibrary from "./PolygonGeometryLibrary.js";
24
25
  import PolygonPipeline from "./PolygonPipeline.js";
25
26
  import Quaternion from "./Quaternion.js";
26
27
  import Rectangle from "./Rectangle.js";
28
+ import Stereographic from "./Stereographic.js";
27
29
  import VertexFormat from "./VertexFormat.js";
28
30
  import WindingOrder from "./WindingOrder.js";
29
31
 
@@ -82,7 +84,8 @@ function computeAttributes(options) {
82
84
  // PERFORMANCE_IDEA: Compute before subdivision, then just interpolate during subdivision.
83
85
  // PERFORMANCE_IDEA: Compute with createGeometryFromPositions() for fast path when there's no holes.
84
86
  const boundingRectangle = options.boundingRectangle;
85
- const tangentPlane = options.tangentPlane;
87
+ const rotationAxis = options.rotationAxis;
88
+ const projectTo2d = options.projectTo2d;
86
89
  const ellipsoid = options.ellipsoid;
87
90
  const stRotation = options.stRotation;
88
91
  const perPositionHeight = options.perPositionHeight;
@@ -122,14 +125,14 @@ function computeAttributes(options) {
122
125
  let tangentRotationMatrix = tangentMatrixScratch;
123
126
  if (stRotation !== 0.0) {
124
127
  let rotation = Quaternion.fromAxisAngle(
125
- tangentPlane._plane.normal,
128
+ rotationAxis,
126
129
  stRotation,
127
130
  appendTextureCoordinatesQuaternion
128
131
  );
129
132
  textureMatrix = Matrix3.fromQuaternion(rotation, textureMatrix);
130
133
 
131
134
  rotation = Quaternion.fromAxisAngle(
132
- tangentPlane._plane.normal,
135
+ rotationAxis,
133
136
  -stRotation,
134
137
  appendTextureCoordinatesQuaternion
135
138
  );
@@ -170,10 +173,7 @@ function computeAttributes(options) {
170
173
  scratchPosition
171
174
  );
172
175
  p = ellipsoid.scaleToGeodeticSurface(p, p);
173
- const st = tangentPlane.projectPointOntoPlane(
174
- p,
175
- appendTextureCoordinatesCartesian2
176
- );
176
+ const st = projectTo2d(p, appendTextureCoordinatesCartesian2);
177
177
  Cartesian2.subtract(st, origin, st);
178
178
 
179
179
  const stx = CesiumMath.clamp(st.x / boundingRectangle.width, 0, 1);
@@ -1078,6 +1078,194 @@ PolygonGeometry.unpack = function (array, startingIndex, result) {
1078
1078
  return result;
1079
1079
  };
1080
1080
 
1081
+ const scratchCartesian0 = new Cartesian2();
1082
+ const scratchCartesian1 = new Cartesian2();
1083
+ const scratchPolarClosest = new Stereographic();
1084
+ function expandRectangle(
1085
+ polar,
1086
+ lastPolar,
1087
+ ellipsoid,
1088
+ arcType,
1089
+ polygon,
1090
+ result
1091
+ ) {
1092
+ const longitude = polar.longitude;
1093
+ const lonAdjusted =
1094
+ longitude >= 0.0 ? longitude : longitude + CesiumMath.TWO_PI;
1095
+ polygon.westOverIdl = Math.min(polygon.westOverIdl, lonAdjusted);
1096
+ polygon.eastOverIdl = Math.max(polygon.eastOverIdl, lonAdjusted);
1097
+
1098
+ result.west = Math.min(result.west, longitude);
1099
+ result.east = Math.max(result.east, longitude);
1100
+
1101
+ const latitude = polar.getLatitude(ellipsoid);
1102
+ let segmentLatitude = latitude;
1103
+
1104
+ result.south = Math.min(result.south, latitude);
1105
+ result.north = Math.max(result.north, latitude);
1106
+
1107
+ if (arcType !== ArcType.RHUMB) {
1108
+ // Geodesics will need to find the closest point on line. Rhumb lines will not have a latitude greater in magnitude than either of their endpoints.
1109
+ const segment = Cartesian2.subtract(
1110
+ lastPolar.position,
1111
+ polar.position,
1112
+ scratchCartesian0
1113
+ );
1114
+ const t =
1115
+ Cartesian2.dot(lastPolar.position, segment) /
1116
+ Cartesian2.dot(segment, segment);
1117
+ if (t > 0.0 && t < 1.0) {
1118
+ const projected = Cartesian2.add(
1119
+ lastPolar.position,
1120
+ Cartesian2.multiplyByScalar(segment, -t, segment),
1121
+ scratchCartesian1
1122
+ );
1123
+ const closestPolar = Stereographic.clone(lastPolar, scratchPolarClosest);
1124
+ closestPolar.position = projected;
1125
+ const adjustedLatitude = closestPolar.getLatitude(ellipsoid);
1126
+ result.south = Math.min(result.south, adjustedLatitude);
1127
+ result.north = Math.max(result.north, adjustedLatitude);
1128
+
1129
+ if (Math.abs(latitude) > Math.abs(adjustedLatitude)) {
1130
+ segmentLatitude = adjustedLatitude;
1131
+ }
1132
+ }
1133
+ }
1134
+ const direction = lastPolar.x * polar.y - polar.x * lastPolar.y;
1135
+
1136
+ // The total internal angle in either hemisphere determines if the pole is inside or outside the polygon
1137
+ let angle = Math.sign(direction);
1138
+ if (angle !== 0.0) {
1139
+ angle *= Cartesian2.angleBetween(lastPolar.position, polar.position);
1140
+ }
1141
+
1142
+ if (segmentLatitude >= 0.0) {
1143
+ polygon.northAngle += angle;
1144
+ }
1145
+
1146
+ if (segmentLatitude <= 0.0) {
1147
+ polygon.southAngle += angle;
1148
+ }
1149
+ }
1150
+
1151
+ const scratchPolar = new Stereographic();
1152
+ const scratchPolarPrevious = new Stereographic();
1153
+ const polygon = {
1154
+ northAngle: 0.0,
1155
+ southAngle: 0.0,
1156
+ westOverIdl: 0.0,
1157
+ eastOverIdl: 0.0,
1158
+ };
1159
+
1160
+ /**
1161
+ * Computes a rectangle which encloses the polygon defined by the list of positions, including cases over the international date line and the poles.
1162
+ *
1163
+ * @param {Cartesian3[]} positions A linear ring defining the outer boundary of the polygon.
1164
+ * @param {Ellipsoid} [ellipsoid=Ellipsoid.WGS84] The ellipsoid to be used as a reference.
1165
+ * @param {ArcType} [arcType=ArcType.GEODESIC] The type of line the polygon edges must follow. Valid options are {@link ArcType.GEODESIC} and {@link ArcType.RHUMB}.
1166
+ * @param {Rectangle} [result] An object in which to store the result.
1167
+ *
1168
+ * @returns {Rectangle} The result rectangle
1169
+ */
1170
+ PolygonGeometry.computeRectangleFromPositions = function (
1171
+ positions,
1172
+ ellipsoid,
1173
+ arcType,
1174
+ result
1175
+ ) {
1176
+ //>>includeStart('debug', pragmas.debug);
1177
+ Check.defined("positions", positions);
1178
+ //>>includeEnd('debug');
1179
+
1180
+ if (!defined(result)) {
1181
+ result = new Rectangle();
1182
+ }
1183
+
1184
+ if (positions.length < 3) {
1185
+ return result;
1186
+ }
1187
+
1188
+ result.west = Number.POSITIVE_INFINITY;
1189
+ result.east = Number.NEGATIVE_INFINITY;
1190
+ result.south = Number.POSITIVE_INFINITY;
1191
+ result.north = Number.NEGATIVE_INFINITY;
1192
+
1193
+ polygon.northAngle = 0.0;
1194
+ polygon.southAngle = 0.0;
1195
+ polygon.westOverIdl = Number.POSITIVE_INFINITY;
1196
+ polygon.eastOverIdl = Number.NEGATIVE_INFINITY;
1197
+
1198
+ const positionsLength = positions.length;
1199
+ let lastPolarPosition = Stereographic.fromCartesian(
1200
+ positions[0],
1201
+ scratchPolarPrevious
1202
+ );
1203
+ for (let i = 1; i < positionsLength; i++) {
1204
+ const polarPosition = Stereographic.fromCartesian(
1205
+ positions[i],
1206
+ scratchPolar
1207
+ );
1208
+ expandRectangle(
1209
+ polarPosition,
1210
+ lastPolarPosition,
1211
+ ellipsoid,
1212
+ arcType,
1213
+ polygon,
1214
+ result
1215
+ );
1216
+
1217
+ lastPolarPosition = Stereographic.clone(polarPosition, lastPolarPosition);
1218
+ }
1219
+
1220
+ expandRectangle(
1221
+ Stereographic.fromCartesian(positions[0], scratchPolar),
1222
+ lastPolarPosition,
1223
+ ellipsoid,
1224
+ arcType,
1225
+ polygon,
1226
+ result
1227
+ );
1228
+
1229
+ if (result.east - result.west > polygon.eastOverIdl - polygon.westOverIdl) {
1230
+ result.west = polygon.westOverIdl;
1231
+ result.east = polygon.eastOverIdl;
1232
+
1233
+ if (result.east > CesiumMath.PI) {
1234
+ result.east = result.east - CesiumMath.TWO_PI;
1235
+ }
1236
+ if (result.west > CesiumMath.PI) {
1237
+ result.west = result.west - CesiumMath.TWO_PI;
1238
+ }
1239
+ }
1240
+
1241
+ // If either pole is inside the polygon, adjust the rectangle so the pole is included
1242
+ if (
1243
+ CesiumMath.equalsEpsilon(
1244
+ Math.abs(polygon.northAngle),
1245
+ CesiumMath.TWO_PI,
1246
+ CesiumMath.EPSILON10
1247
+ )
1248
+ ) {
1249
+ result.north = CesiumMath.PI_OVER_TWO;
1250
+ result.east = CesiumMath.PI;
1251
+ result.west = -CesiumMath.PI;
1252
+ }
1253
+
1254
+ if (
1255
+ CesiumMath.equalsEpsilon(
1256
+ Math.abs(polygon.southAngle),
1257
+ CesiumMath.TWO_PI,
1258
+ CesiumMath.EPSILON10
1259
+ )
1260
+ ) {
1261
+ result.south = -CesiumMath.PI_OVER_TWO;
1262
+ result.east = CesiumMath.PI;
1263
+ result.west = -CesiumMath.PI;
1264
+ }
1265
+
1266
+ return result;
1267
+ };
1268
+
1081
1269
  /**
1082
1270
  * Returns the bounding rectangle given the provided options
1083
1271
  *
@@ -1089,6 +1277,8 @@ PolygonGeometry.unpack = function (array, startingIndex, result) {
1089
1277
  * @param {Rectangle} [result] An object in which to store the result.
1090
1278
  *
1091
1279
  * @returns {Rectangle} The result rectangle
1280
+ *
1281
+ * @deprecated
1092
1282
  */
1093
1283
  PolygonGeometry.computeRectangle = function (options, result) {
1094
1284
  //>>includeStart('debug', pragmas.debug);
@@ -1096,6 +1286,11 @@ PolygonGeometry.computeRectangle = function (options, result) {
1096
1286
  Check.typeOf.object("options.polygonHierarchy", options.polygonHierarchy);
1097
1287
  //>>includeEnd('debug');
1098
1288
 
1289
+ deprecationWarning(
1290
+ "PolygonGeometry.computeRectangle",
1291
+ "PolygonGeometry.computeRectangle was deprecated in CesiumJS 1.110. It will be removed in CesiumJS 1.112. Use PolygonGeometry.computeRectangleFromPositions instead."
1292
+ );
1293
+
1099
1294
  const granularity = defaultValue(
1100
1295
  options.granularity,
1101
1296
  CesiumMath.RADIANS_PER_DEGREE
@@ -1121,6 +1316,127 @@ PolygonGeometry.computeRectangle = function (options, result) {
1121
1316
  );
1122
1317
  };
1123
1318
 
1319
+ const scratchPolarForPlane = new Stereographic();
1320
+ function getTangentPlane(rectangle, positions, ellipsoid) {
1321
+ if (rectangle.height >= CesiumMath.PI || rectangle.width >= CesiumMath.PI) {
1322
+ const polar = Stereographic.fromCartesian(
1323
+ positions[0],
1324
+ scratchPolarForPlane
1325
+ );
1326
+ return polar.tangentPlane;
1327
+ }
1328
+
1329
+ // Use a local tangent plane for smaller extents
1330
+ return EllipsoidTangentPlane.fromPoints(positions, ellipsoid);
1331
+ }
1332
+
1333
+ const scratchCartographicCyllindrical = new Cartographic();
1334
+ function createProjectTo2d(rectangle, ellipsoid) {
1335
+ return (positions, results) => {
1336
+ // If the polygon positions span a large enough extent, use a specialized projection
1337
+ if (rectangle.height >= CesiumMath.PI || rectangle.width >= CesiumMath.PI) {
1338
+ // polygons that cross the equator must use cyllindrical coordinates to correctly compute winding order.
1339
+ if (rectangle.south < 0 && rectangle.north > 0) {
1340
+ if (!defined(results)) {
1341
+ results = [];
1342
+ }
1343
+
1344
+ for (let i = 0; i < positions.length; ++i) {
1345
+ const cartographic = ellipsoid.cartesianToCartographic(
1346
+ positions[i],
1347
+ scratchCartographicCyllindrical
1348
+ );
1349
+ results[i] = new Cartesian2(
1350
+ cartographic.longitude / CesiumMath.PI,
1351
+ cartographic.latitude / CesiumMath.PI_OVER_TWO
1352
+ );
1353
+ }
1354
+
1355
+ results.length = positions.length;
1356
+ return results;
1357
+ }
1358
+
1359
+ return Stereographic.fromCartesianArray(positions, results);
1360
+ }
1361
+
1362
+ // Use a local tangent plane for smaller extents
1363
+ const tangentPlane = EllipsoidTangentPlane.fromPoints(positions, ellipsoid);
1364
+ return tangentPlane.projectPointsOntoPlane(positions, results);
1365
+ };
1366
+ }
1367
+
1368
+ function createProjectPositionTo2d(rectangle, outerRing, ellipsoid) {
1369
+ // If the polygon positions span a large enough extent, use a specialized projection
1370
+ if (rectangle.height >= CesiumMath.PI || rectangle.width >= CesiumMath.PI) {
1371
+ return (position, result) => {
1372
+ // polygons that cross the equator must use cyllindrical coordinates to correctly compute winding order.
1373
+ if (rectangle.south < 0 && rectangle.north > 0) {
1374
+ const cartographic = ellipsoid.cartesianToCartographic(
1375
+ position,
1376
+ scratchCartographicCyllindrical
1377
+ );
1378
+ if (!defined(result)) {
1379
+ result = new Cartesian2();
1380
+ }
1381
+ result.x = cartographic.longitude / CesiumMath.PI;
1382
+ result.y = cartographic.latitude / CesiumMath.PI_OVER_TWO;
1383
+
1384
+ return result;
1385
+ }
1386
+
1387
+ return Stereographic.fromCartesian(position, result);
1388
+ };
1389
+ }
1390
+
1391
+ const tangentPlane = EllipsoidTangentPlane.fromPoints(outerRing, ellipsoid);
1392
+ return (position, result) => {
1393
+ // Use a local tangent plane for smaller extents
1394
+ return tangentPlane.projectPointsOntoPlane(position, result);
1395
+ };
1396
+ }
1397
+
1398
+ function createSplitPolygons(rectangle, ellipsoid, arcType, perPositionHeight) {
1399
+ return (polygons, results) => {
1400
+ if (
1401
+ !perPositionHeight &&
1402
+ (rectangle.height >= CesiumMath.PI_OVER_TWO ||
1403
+ rectangle.width >= 2 * CesiumMath.PI_OVER_THREE)
1404
+ ) {
1405
+ return PolygonGeometryLibrary.splitPolygonsOnEquator(
1406
+ polygons,
1407
+ ellipsoid,
1408
+ arcType,
1409
+ results
1410
+ );
1411
+ }
1412
+
1413
+ return polygons;
1414
+ };
1415
+ }
1416
+
1417
+ function computeBoundingRectangle(outerRing, rectangle, ellipsoid, stRotation) {
1418
+ if (rectangle.height >= CesiumMath.PI || rectangle.width >= CesiumMath.PI) {
1419
+ return BoundingRectangle.fromRectangle(
1420
+ rectangle,
1421
+ undefined,
1422
+ scratchBoundingRectangle
1423
+ );
1424
+ }
1425
+
1426
+ const outerPositions = outerRing;
1427
+ const tangentPlane = EllipsoidTangentPlane.fromPoints(
1428
+ outerPositions,
1429
+ ellipsoid
1430
+ );
1431
+ return PolygonGeometryLibrary.computeBoundingRectangle(
1432
+ tangentPlane.plane.normal,
1433
+ tangentPlane.projectPointOntoPlane.bind(tangentPlane),
1434
+ outerPositions,
1435
+ stRotation,
1436
+ scratchBoundingRectangle
1437
+ );
1438
+ }
1439
+
1124
1440
  /**
1125
1441
  * Computes the geometric representation of a polygon, including its vertices, indices, and a bounding sphere.
1126
1442
  *
@@ -1141,22 +1457,19 @@ PolygonGeometry.createGeometry = function (polygonGeometry) {
1141
1457
 
1142
1458
  const hasTextureCoordinates = defined(textureCoordinates);
1143
1459
 
1144
- let outerPositions = polygonHierarchy.positions;
1460
+ const outerPositions = polygonHierarchy.positions;
1145
1461
  if (outerPositions.length < 3) {
1146
1462
  return;
1147
1463
  }
1148
1464
 
1149
- const tangentPlane = EllipsoidTangentPlane.fromPoints(
1150
- outerPositions,
1151
- ellipsoid
1152
- );
1153
-
1465
+ const rectangle = polygonGeometry.rectangle;
1154
1466
  const results = PolygonGeometryLibrary.polygonsFromHierarchy(
1155
1467
  polygonHierarchy,
1156
1468
  hasTextureCoordinates,
1157
- tangentPlane.projectPointsOntoPlane.bind(tangentPlane),
1469
+ createProjectTo2d(rectangle, ellipsoid),
1158
1470
  !perPositionHeight,
1159
- ellipsoid
1471
+ ellipsoid,
1472
+ createSplitPolygons(rectangle, ellipsoid, arcType, perPositionHeight)
1160
1473
  );
1161
1474
 
1162
1475
  const hierarchy = results.hierarchy;
@@ -1171,7 +1484,8 @@ PolygonGeometry.createGeometry = function (polygonGeometry) {
1171
1484
  textureCoordinates,
1172
1485
  true,
1173
1486
  dummyFunction,
1174
- false
1487
+ false,
1488
+ ellipsoid
1175
1489
  ).polygons
1176
1490
  : undefined;
1177
1491
 
@@ -1179,13 +1493,12 @@ PolygonGeometry.createGeometry = function (polygonGeometry) {
1179
1493
  return;
1180
1494
  }
1181
1495
 
1182
- outerPositions = hierarchy[0].outerRing;
1183
- const boundingRectangle = PolygonGeometryLibrary.computeBoundingRectangle(
1184
- tangentPlane.plane.normal,
1185
- tangentPlane.projectPointOntoPlane.bind(tangentPlane),
1186
- outerPositions,
1187
- stRotation,
1188
- scratchBoundingRectangle
1496
+ const outerRing = hierarchy[0].outerRing;
1497
+ const boundingRectangle = computeBoundingRectangle(
1498
+ outerRing,
1499
+ rectangle,
1500
+ ellipsoid,
1501
+ stRotation
1189
1502
  );
1190
1503
 
1191
1504
  const geometries = [];
@@ -1200,7 +1513,8 @@ PolygonGeometry.createGeometry = function (polygonGeometry) {
1200
1513
  perPositionHeight: perPositionHeight,
1201
1514
  vertexFormat: vertexFormat,
1202
1515
  geometry: undefined,
1203
- tangentPlane: tangentPlane,
1516
+ rotationAxis: getTangentPlane(rectangle, outerRing, ellipsoid).plane.normal,
1517
+ projectTo2d: createProjectPositionTo2d(rectangle, outerRing, ellipsoid),
1204
1518
  boundingRectangle: boundingRectangle,
1205
1519
  ellipsoid: ellipsoid,
1206
1520
  stRotation: stRotation,
@@ -1407,11 +1721,10 @@ Object.defineProperties(PolygonGeometry.prototype, {
1407
1721
  get: function () {
1408
1722
  if (!defined(this._rectangle)) {
1409
1723
  const positions = this._polygonHierarchy.positions;
1410
- this._rectangle = computeRectangle(
1724
+ this._rectangle = PolygonGeometry.computeRectangleFromPositions(
1411
1725
  positions,
1412
1726
  this._ellipsoid,
1413
- this._arcType,
1414
- this._granularity
1727
+ this._arcType
1415
1728
  );
1416
1729
  }
1417
1730