@pggis/pg-sdk 3.3.10 → 4.3.3

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 (163) hide show
  1. package/README.md +8 -8
  2. package/dist/index.js +1966 -4
  3. package/dist/pggis.min.css +1 -1
  4. package/dist/pggis.min.js +10980 -7539
  5. package/dist/resources/ThirdParty/Workers/pako_deflate.min.js +1 -2
  6. package/dist/resources/ThirdParty/Workers/pako_inflate.min.js +1 -2
  7. package/dist/resources/ThirdParty/Workers/z-worker-pako.js +1 -1
  8. package/dist/resources/ThirdParty/google-earth-dbroot-parser.js +1 -8337
  9. package/dist/resources/ThirdParty/wasm_splats_bg.wasm +0 -0
  10. package/dist/resources/Workers/chunk-35SHYARM.js +26 -0
  11. package/dist/resources/Workers/chunk-37F5JSTI.js +26 -0
  12. package/dist/resources/Workers/chunk-3SSKC3VN.js +26 -0
  13. package/dist/resources/Workers/chunk-3W4GT7KQ.js +26 -0
  14. package/dist/resources/Workers/chunk-4IW2T6GF.js +26 -0
  15. package/dist/resources/Workers/chunk-5YEWO3HT.js +26 -0
  16. package/dist/resources/Workers/chunk-64RSHJUE.js +28 -0
  17. package/dist/resources/Workers/chunk-77IHZJJ3.js +26 -0
  18. package/dist/resources/Workers/chunk-7HTKERZY.js +26 -0
  19. package/dist/resources/Workers/{chunk-F3YA3Y2Z.js → chunk-A56XVLQR.js} +2 -13
  20. package/dist/resources/Workers/chunk-AJYK4IVJ.js +26 -0
  21. package/dist/resources/Workers/{chunk-EHWHNOEX.js → chunk-ARG42DC4.js} +2 -31
  22. package/dist/resources/Workers/chunk-AU7IKHOH.js +26 -0
  23. package/dist/resources/Workers/chunk-B4AA3ARO.js +26 -0
  24. package/dist/resources/Workers/chunk-CNCV5UL7.js +26 -0
  25. package/dist/resources/Workers/chunk-CYCB63OH.js +26 -0
  26. package/dist/resources/Workers/{chunk-4H7PY4U5.js → chunk-D6AA5QVT.js} +2 -20
  27. package/dist/resources/Workers/chunk-D6C66QON.js +26 -0
  28. package/dist/resources/Workers/chunk-DEPHB2WM.js +26 -0
  29. package/dist/resources/Workers/chunk-DMEY62ID.js +26 -0
  30. package/dist/resources/Workers/chunk-DQQ63PYM.js +26 -0
  31. package/dist/resources/Workers/chunk-ED5JPB3S.js +27 -0
  32. package/dist/resources/Workers/chunk-EZUYS2JF.js +26 -0
  33. package/dist/resources/Workers/chunk-FEVXJ54I.js +26 -0
  34. package/dist/resources/Workers/chunk-G5AGHVVC.js +26 -0
  35. package/dist/resources/Workers/{chunk-BBWDMCVU.js → chunk-GBYLG25F.js} +2 -15
  36. package/dist/resources/Workers/chunk-GILIDQNQ.js +26 -0
  37. package/dist/resources/Workers/chunk-HMIYSTF6.js +26 -0
  38. package/dist/resources/Workers/chunk-HTFSEEMT.js +26 -0
  39. package/dist/resources/Workers/chunk-HWXX4CWK.js +26 -0
  40. package/dist/resources/Workers/chunk-IYTZ52EY.js +26 -0
  41. package/dist/resources/Workers/chunk-J6UP6FLE.js +26 -0
  42. package/dist/resources/Workers/chunk-LEYMRMBK.js +27 -0
  43. package/dist/resources/Workers/chunk-M3MGYQSL.js +26 -0
  44. package/dist/resources/Workers/chunk-N4VJKXZS.js +26 -0
  45. package/dist/resources/Workers/chunk-NB3ML6JO.js +26 -0
  46. package/dist/resources/Workers/chunk-OFUUQVMR.js +26 -0
  47. package/dist/resources/Workers/chunk-OSW76XDF.js +26 -0
  48. package/dist/resources/Workers/chunk-PSPPBZWI.js +66 -0
  49. package/dist/resources/Workers/chunk-QN3VOORQ.js +26 -0
  50. package/dist/resources/Workers/chunk-QOUAJ6TL.js +26 -0
  51. package/dist/resources/Workers/chunk-RCV6KWXS.js +26 -0
  52. package/dist/resources/Workers/chunk-TCGIRNHN.js +26 -0
  53. package/dist/resources/Workers/chunk-U4IEOH5K.js +26 -0
  54. package/dist/resources/Workers/chunk-UP6I5URU.js +26 -0
  55. package/dist/resources/Workers/chunk-VTAIKJXX.js +26 -0
  56. package/dist/resources/Workers/chunk-VTBDSFTG.js +26 -0
  57. package/dist/resources/Workers/chunk-VW6VD53G.js +26 -0
  58. package/dist/resources/Workers/chunk-WGGIH7QW.js +26 -0
  59. package/dist/resources/Workers/chunk-WWA5PL4H.js +26 -0
  60. package/dist/resources/Workers/chunk-WZDE3RYP.js +28 -0
  61. package/dist/resources/Workers/chunk-XRL4AVS5.js +26 -0
  62. package/dist/resources/Workers/combineGeometry.js +2 -44
  63. package/dist/resources/Workers/createBoxGeometry.js +2 -34
  64. package/dist/resources/Workers/createBoxOutlineGeometry.js +2 -211
  65. package/dist/resources/Workers/createCircleGeometry.js +2 -173
  66. package/dist/resources/Workers/createCircleOutlineGeometry.js +2 -123
  67. package/dist/resources/Workers/createCoplanarPolygonGeometry.js +2 -482
  68. package/dist/resources/Workers/createCoplanarPolygonOutlineGeometry.js +2 -201
  69. package/dist/resources/Workers/createCorridorGeometry.js +2 -1239
  70. package/dist/resources/Workers/createCorridorOutlineGeometry.js +2 -544
  71. package/dist/resources/Workers/createCylinderGeometry.js +2 -36
  72. package/dist/resources/Workers/createCylinderOutlineGeometry.js +2 -207
  73. package/dist/resources/Workers/createEllipseGeometry.js +2 -47
  74. package/dist/resources/Workers/createEllipseOutlineGeometry.js +2 -40
  75. package/dist/resources/Workers/createEllipsoidGeometry.js +2 -35
  76. package/dist/resources/Workers/createEllipsoidOutlineGeometry.js +2 -37
  77. package/dist/resources/Workers/createFrustumGeometry.js +2 -34
  78. package/dist/resources/Workers/createFrustumOutlineGeometry.js +2 -211
  79. package/dist/resources/Workers/createGeometry.js +2 -147
  80. package/dist/resources/Workers/createGroundPolylineGeometry.js +2 -1584
  81. package/dist/resources/Workers/createPlaneGeometry.js +2 -200
  82. package/dist/resources/Workers/createPlaneOutlineGeometry.js +2 -100
  83. package/dist/resources/Workers/createPolygonGeometry.js +2 -1387
  84. package/dist/resources/Workers/createPolygonOutlineGeometry.js +2 -519
  85. package/dist/resources/Workers/createPolylineGeometry.js +2 -472
  86. package/dist/resources/Workers/createPolylineVolumeGeometry.js +2 -355
  87. package/dist/resources/Workers/createPolylineVolumeOutlineGeometry.js +2 -253
  88. package/dist/resources/Workers/createRectangleGeometry.js +2 -1250
  89. package/dist/resources/Workers/createRectangleOutlineGeometry.js +2 -455
  90. package/dist/resources/Workers/createSimplePolylineGeometry.js +2 -376
  91. package/dist/resources/Workers/createSphereGeometry.js +2 -94
  92. package/dist/resources/Workers/createSphereOutlineGeometry.js +2 -94
  93. package/dist/resources/Workers/createTaskProcessorWorker.js +2 -8
  94. package/dist/resources/Workers/createVectorTileClampedPolylines.js +2 -468
  95. package/dist/resources/Workers/createVectorTileGeometries.js +2 -363
  96. package/dist/resources/Workers/createVectorTilePoints.js +2 -88
  97. package/dist/resources/Workers/createVectorTilePolygons.js +2 -361
  98. package/dist/resources/Workers/createVectorTilePolylines.js +2 -238
  99. package/dist/resources/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +2 -545
  100. package/dist/resources/Workers/createVerticesFromHeightmap.js +2 -2254
  101. package/dist/resources/Workers/createVerticesFromQuantizedTerrainMesh.js +2 -722
  102. package/dist/resources/Workers/createWallGeometry.js +2 -466
  103. package/dist/resources/Workers/createWallOutlineGeometry.js +2 -314
  104. package/dist/resources/Workers/decodeDraco.js +2 -345
  105. package/dist/resources/Workers/decodeGoogleEarthEnterprisePacket.js +2 -2626
  106. package/dist/resources/Workers/decodeI3S.js +2 -1320
  107. package/dist/resources/Workers/gaussianSplatSorter.js +26 -0
  108. package/dist/resources/Workers/gaussianSplatTextureGenerator.js +26 -0
  109. package/dist/resources/Workers/transcodeKTX2.js +29 -3398
  110. package/dist/resources/Workers/transferTypedArrayTest.js +2 -17
  111. package/dist/resources/Workers/upsampleQuantizedTerrainMesh.js +2 -795
  112. package/package.json +9 -8
  113. package/dist/resources/ThirdParty/Workers/basis_transcoder.js +0 -21
  114. package/dist/resources/Workers/chunk-23UFSGND.js +0 -236
  115. package/dist/resources/Workers/chunk-2A75IWRS.js +0 -218
  116. package/dist/resources/Workers/chunk-2FRVPMCS.js +0 -1258
  117. package/dist/resources/Workers/chunk-2FWRMUTY.js +0 -138
  118. package/dist/resources/Workers/chunk-2UPKWTMJ.js +0 -117
  119. package/dist/resources/Workers/chunk-34FXV7D7.js +0 -73
  120. package/dist/resources/Workers/chunk-3VAZEH7M.js +0 -101
  121. package/dist/resources/Workers/chunk-4DO5W5XZ.js +0 -196
  122. package/dist/resources/Workers/chunk-5QULIR53.js +0 -501
  123. package/dist/resources/Workers/chunk-7TC63SJW.js +0 -302
  124. package/dist/resources/Workers/chunk-7ZFGPDJA.js +0 -122
  125. package/dist/resources/Workers/chunk-A5DWLWCY.js +0 -834
  126. package/dist/resources/Workers/chunk-BG4UCVXN.js +0 -73
  127. package/dist/resources/Workers/chunk-BIKA3NRA.js +0 -59
  128. package/dist/resources/Workers/chunk-BROJAZRZ.js +0 -390
  129. package/dist/resources/Workers/chunk-DDUQAJ4P.js +0 -476
  130. package/dist/resources/Workers/chunk-EERJKOAF.js +0 -305
  131. package/dist/resources/Workers/chunk-EG6PTBY2.js +0 -2716
  132. package/dist/resources/Workers/chunk-F4HFJMGM.js +0 -353
  133. package/dist/resources/Workers/chunk-FJKNFAKQ.js +0 -8219
  134. package/dist/resources/Workers/chunk-FNIRWHJB.js +0 -289
  135. package/dist/resources/Workers/chunk-FZRIVR7Y.js +0 -100
  136. package/dist/resources/Workers/chunk-G43QFN4Q.js +0 -157
  137. package/dist/resources/Workers/chunk-GATZHF3K.js +0 -1860
  138. package/dist/resources/Workers/chunk-GRC2ZTAF.js +0 -398
  139. package/dist/resources/Workers/chunk-HU6N6EXB.js +0 -767
  140. package/dist/resources/Workers/chunk-I46ZRR5W.js +0 -1052
  141. package/dist/resources/Workers/chunk-JURN7NPV.js +0 -1075
  142. package/dist/resources/Workers/chunk-KKCR2YOP.js +0 -421
  143. package/dist/resources/Workers/chunk-LPR3YNP2.js +0 -138
  144. package/dist/resources/Workers/chunk-M7ERACJJ.js +0 -511
  145. package/dist/resources/Workers/chunk-MDWEGWPA.js +0 -1007
  146. package/dist/resources/Workers/chunk-OGXZVPPM.js +0 -2365
  147. package/dist/resources/Workers/chunk-PGSJK77E.js +0 -634
  148. package/dist/resources/Workers/chunk-PPH7OFP3.js +0 -258
  149. package/dist/resources/Workers/chunk-SH5USDPI.js +0 -456
  150. package/dist/resources/Workers/chunk-SOWMRMWA.js +0 -629
  151. package/dist/resources/Workers/chunk-STW2DGFI.js +0 -58
  152. package/dist/resources/Workers/chunk-T3XIFPYR.js +0 -1477
  153. package/dist/resources/Workers/chunk-TTUZP4BO.js +0 -501
  154. package/dist/resources/Workers/chunk-UEXTBDBE.js +0 -693
  155. package/dist/resources/Workers/chunk-VOXYEYJT.js +0 -684
  156. package/dist/resources/Workers/chunk-X4356LRH.js +0 -368
  157. package/dist/resources/Workers/chunk-XGI5BXZY.js +0 -163
  158. package/dist/resources/Workers/chunk-Y2ME2IJV.js +0 -781
  159. package/dist/resources/Workers/chunk-Y5UQJLYE.js +0 -171
  160. package/dist/resources/Workers/chunk-YJEBABKH.js +0 -2977
  161. package/dist/resources/Workers/chunk-YWTJ2B4B.js +0 -77
  162. package/dist/resources/Workers/chunk-Z3TIFFGF.js +0 -430
  163. package/dist/resources/Workers/chunk-ZT7KWISZ.js +0 -102
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @license
3
3
  * Cesium - https://github.com/CesiumGS/cesium
4
- * Version 1.115
4
+ * Version 1.132
5
5
  *
6
6
  * Copyright 2011-2022 Cesium Contributors
7
7
  *
@@ -23,1586 +23,4 @@
23
23
  * See https://github.com/CesiumGS/cesium/blob/main/LICENSE.md for full licensing details.
24
24
  */
25
25
 
26
- import {
27
- WebMercatorProjection_default
28
- } from "./chunk-2UPKWTMJ.js";
29
- import {
30
- ArcType_default
31
- } from "./chunk-EHWHNOEX.js";
32
- import {
33
- EncodedCartesian3_default
34
- } from "./chunk-ZT7KWISZ.js";
35
- import {
36
- EllipsoidGeodesic_default
37
- } from "./chunk-F4HFJMGM.js";
38
- import {
39
- arrayRemoveDuplicates_default
40
- } from "./chunk-FZRIVR7Y.js";
41
- import {
42
- EllipsoidRhumbLine_default
43
- } from "./chunk-SH5USDPI.js";
44
- import {
45
- IntersectionTests_default
46
- } from "./chunk-2FRVPMCS.js";
47
- import {
48
- Plane_default
49
- } from "./chunk-Y5UQJLYE.js";
50
- import {
51
- GeometryAttribute_default,
52
- Geometry_default
53
- } from "./chunk-7TC63SJW.js";
54
- import {
55
- BoundingSphere_default,
56
- GeographicProjection_default,
57
- Quaternion_default,
58
- Resource_default,
59
- buildModuleUrl_default
60
- } from "./chunk-FJKNFAKQ.js";
61
- import "./chunk-TTUZP4BO.js";
62
- import "./chunk-BG4UCVXN.js";
63
- import {
64
- Rectangle_default
65
- } from "./chunk-YJEBABKH.js";
66
- import {
67
- ComponentDatatype_default
68
- } from "./chunk-PPH7OFP3.js";
69
- import {
70
- Cartesian2_default,
71
- Cartesian3_default,
72
- Cartographic_default,
73
- Ellipsoid_default,
74
- Matrix3_default
75
- } from "./chunk-OGXZVPPM.js";
76
- import {
77
- Math_default
78
- } from "./chunk-5QULIR53.js";
79
- import "./chunk-SOWMRMWA.js";
80
- import "./chunk-STW2DGFI.js";
81
- import {
82
- defaultValue_default
83
- } from "./chunk-BBWDMCVU.js";
84
- import {
85
- Check_default,
86
- DeveloperError_default
87
- } from "./chunk-XGI5BXZY.js";
88
- import {
89
- defined_default
90
- } from "./chunk-YWTJ2B4B.js";
91
-
92
- // packages/engine/Source/Core/GeographicTilingScheme.js
93
- function GeographicTilingScheme(options) {
94
- options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
95
- this._ellipsoid = defaultValue_default(options.ellipsoid, Ellipsoid_default.WGS84);
96
- this._rectangle = defaultValue_default(options.rectangle, Rectangle_default.MAX_VALUE);
97
- this._projection = new GeographicProjection_default(this._ellipsoid);
98
- this._numberOfLevelZeroTilesX = defaultValue_default(
99
- options.numberOfLevelZeroTilesX,
100
- 2
101
- );
102
- this._numberOfLevelZeroTilesY = defaultValue_default(
103
- options.numberOfLevelZeroTilesY,
104
- 1
105
- );
106
- }
107
- Object.defineProperties(GeographicTilingScheme.prototype, {
108
- /**
109
- * Gets the ellipsoid that is tiled by this tiling scheme.
110
- * @memberof GeographicTilingScheme.prototype
111
- * @type {Ellipsoid}
112
- */
113
- ellipsoid: {
114
- get: function() {
115
- return this._ellipsoid;
116
- }
117
- },
118
- /**
119
- * Gets the rectangle, in radians, covered by this tiling scheme.
120
- * @memberof GeographicTilingScheme.prototype
121
- * @type {Rectangle}
122
- */
123
- rectangle: {
124
- get: function() {
125
- return this._rectangle;
126
- }
127
- },
128
- /**
129
- * Gets the map projection used by this tiling scheme.
130
- * @memberof GeographicTilingScheme.prototype
131
- * @type {MapProjection}
132
- */
133
- projection: {
134
- get: function() {
135
- return this._projection;
136
- }
137
- }
138
- });
139
- GeographicTilingScheme.prototype.getNumberOfXTilesAtLevel = function(level) {
140
- return this._numberOfLevelZeroTilesX << level;
141
- };
142
- GeographicTilingScheme.prototype.getNumberOfYTilesAtLevel = function(level) {
143
- return this._numberOfLevelZeroTilesY << level;
144
- };
145
- GeographicTilingScheme.prototype.rectangleToNativeRectangle = function(rectangle, result) {
146
- Check_default.defined("rectangle", rectangle);
147
- const west = Math_default.toDegrees(rectangle.west);
148
- const south = Math_default.toDegrees(rectangle.south);
149
- const east = Math_default.toDegrees(rectangle.east);
150
- const north = Math_default.toDegrees(rectangle.north);
151
- if (!defined_default(result)) {
152
- return new Rectangle_default(west, south, east, north);
153
- }
154
- result.west = west;
155
- result.south = south;
156
- result.east = east;
157
- result.north = north;
158
- return result;
159
- };
160
- GeographicTilingScheme.prototype.tileXYToNativeRectangle = function(x, y, level, result) {
161
- const rectangleRadians = this.tileXYToRectangle(x, y, level, result);
162
- rectangleRadians.west = Math_default.toDegrees(rectangleRadians.west);
163
- rectangleRadians.south = Math_default.toDegrees(rectangleRadians.south);
164
- rectangleRadians.east = Math_default.toDegrees(rectangleRadians.east);
165
- rectangleRadians.north = Math_default.toDegrees(rectangleRadians.north);
166
- return rectangleRadians;
167
- };
168
- GeographicTilingScheme.prototype.tileXYToRectangle = function(x, y, level, result) {
169
- const rectangle = this._rectangle;
170
- const xTiles = this.getNumberOfXTilesAtLevel(level);
171
- const yTiles = this.getNumberOfYTilesAtLevel(level);
172
- const xTileWidth = rectangle.width / xTiles;
173
- const west = x * xTileWidth + rectangle.west;
174
- const east = (x + 1) * xTileWidth + rectangle.west;
175
- const yTileHeight = rectangle.height / yTiles;
176
- const north = rectangle.north - y * yTileHeight;
177
- const south = rectangle.north - (y + 1) * yTileHeight;
178
- if (!defined_default(result)) {
179
- result = new Rectangle_default(west, south, east, north);
180
- }
181
- result.west = west;
182
- result.south = south;
183
- result.east = east;
184
- result.north = north;
185
- return result;
186
- };
187
- GeographicTilingScheme.prototype.positionToTileXY = function(position, level, result) {
188
- const rectangle = this._rectangle;
189
- if (!Rectangle_default.contains(rectangle, position)) {
190
- return void 0;
191
- }
192
- const xTiles = this.getNumberOfXTilesAtLevel(level);
193
- const yTiles = this.getNumberOfYTilesAtLevel(level);
194
- const xTileWidth = rectangle.width / xTiles;
195
- const yTileHeight = rectangle.height / yTiles;
196
- let longitude = position.longitude;
197
- if (rectangle.east < rectangle.west) {
198
- longitude += Math_default.TWO_PI;
199
- }
200
- let xTileCoordinate = (longitude - rectangle.west) / xTileWidth | 0;
201
- if (xTileCoordinate >= xTiles) {
202
- xTileCoordinate = xTiles - 1;
203
- }
204
- let yTileCoordinate = (rectangle.north - position.latitude) / yTileHeight | 0;
205
- if (yTileCoordinate >= yTiles) {
206
- yTileCoordinate = yTiles - 1;
207
- }
208
- if (!defined_default(result)) {
209
- return new Cartesian2_default(xTileCoordinate, yTileCoordinate);
210
- }
211
- result.x = xTileCoordinate;
212
- result.y = yTileCoordinate;
213
- return result;
214
- };
215
- var GeographicTilingScheme_default = GeographicTilingScheme;
216
-
217
- // packages/engine/Source/Core/ApproximateTerrainHeights.js
218
- var scratchDiagonalCartesianNE = new Cartesian3_default();
219
- var scratchDiagonalCartesianSW = new Cartesian3_default();
220
- var scratchDiagonalCartographic = new Cartographic_default();
221
- var scratchCenterCartesian = new Cartesian3_default();
222
- var scratchSurfaceCartesian = new Cartesian3_default();
223
- var scratchBoundingSphere = new BoundingSphere_default();
224
- var tilingScheme = new GeographicTilingScheme_default();
225
- var scratchCorners = [
226
- new Cartographic_default(),
227
- new Cartographic_default(),
228
- new Cartographic_default(),
229
- new Cartographic_default()
230
- ];
231
- var scratchTileXY = new Cartesian2_default();
232
- var ApproximateTerrainHeights = {};
233
- ApproximateTerrainHeights.initialize = function() {
234
- let initPromise = ApproximateTerrainHeights._initPromise;
235
- if (defined_default(initPromise)) {
236
- return initPromise;
237
- }
238
- initPromise = Resource_default.fetchJson(
239
- buildModuleUrl_default("Assets/approximateTerrainHeights.json")
240
- ).then(function(json) {
241
- ApproximateTerrainHeights._terrainHeights = json;
242
- });
243
- ApproximateTerrainHeights._initPromise = initPromise;
244
- return initPromise;
245
- };
246
- ApproximateTerrainHeights.getMinimumMaximumHeights = function(rectangle, ellipsoid) {
247
- Check_default.defined("rectangle", rectangle);
248
- if (!defined_default(ApproximateTerrainHeights._terrainHeights)) {
249
- throw new DeveloperError_default(
250
- "You must call ApproximateTerrainHeights.initialize and wait for the promise to resolve before using this function"
251
- );
252
- }
253
- ellipsoid = defaultValue_default(ellipsoid, Ellipsoid_default.WGS84);
254
- const xyLevel = getTileXYLevel(rectangle);
255
- let minTerrainHeight = ApproximateTerrainHeights._defaultMinTerrainHeight;
256
- let maxTerrainHeight = ApproximateTerrainHeights._defaultMaxTerrainHeight;
257
- if (defined_default(xyLevel)) {
258
- const key = `${xyLevel.level}-${xyLevel.x}-${xyLevel.y}`;
259
- const heights = ApproximateTerrainHeights._terrainHeights[key];
260
- if (defined_default(heights)) {
261
- minTerrainHeight = heights[0];
262
- maxTerrainHeight = heights[1];
263
- }
264
- ellipsoid.cartographicToCartesian(
265
- Rectangle_default.northeast(rectangle, scratchDiagonalCartographic),
266
- scratchDiagonalCartesianNE
267
- );
268
- ellipsoid.cartographicToCartesian(
269
- Rectangle_default.southwest(rectangle, scratchDiagonalCartographic),
270
- scratchDiagonalCartesianSW
271
- );
272
- Cartesian3_default.midpoint(
273
- scratchDiagonalCartesianSW,
274
- scratchDiagonalCartesianNE,
275
- scratchCenterCartesian
276
- );
277
- const surfacePosition = ellipsoid.scaleToGeodeticSurface(
278
- scratchCenterCartesian,
279
- scratchSurfaceCartesian
280
- );
281
- if (defined_default(surfacePosition)) {
282
- const distance = Cartesian3_default.distance(
283
- scratchCenterCartesian,
284
- surfacePosition
285
- );
286
- minTerrainHeight = Math.min(minTerrainHeight, -distance);
287
- } else {
288
- minTerrainHeight = ApproximateTerrainHeights._defaultMinTerrainHeight;
289
- }
290
- }
291
- minTerrainHeight = Math.max(
292
- ApproximateTerrainHeights._defaultMinTerrainHeight,
293
- minTerrainHeight
294
- );
295
- return {
296
- minimumTerrainHeight: minTerrainHeight,
297
- maximumTerrainHeight: maxTerrainHeight
298
- };
299
- };
300
- ApproximateTerrainHeights.getBoundingSphere = function(rectangle, ellipsoid) {
301
- Check_default.defined("rectangle", rectangle);
302
- if (!defined_default(ApproximateTerrainHeights._terrainHeights)) {
303
- throw new DeveloperError_default(
304
- "You must call ApproximateTerrainHeights.initialize and wait for the promise to resolve before using this function"
305
- );
306
- }
307
- ellipsoid = defaultValue_default(ellipsoid, Ellipsoid_default.WGS84);
308
- const xyLevel = getTileXYLevel(rectangle);
309
- let maxTerrainHeight = ApproximateTerrainHeights._defaultMaxTerrainHeight;
310
- if (defined_default(xyLevel)) {
311
- const key = `${xyLevel.level}-${xyLevel.x}-${xyLevel.y}`;
312
- const heights = ApproximateTerrainHeights._terrainHeights[key];
313
- if (defined_default(heights)) {
314
- maxTerrainHeight = heights[1];
315
- }
316
- }
317
- const result = BoundingSphere_default.fromRectangle3D(rectangle, ellipsoid, 0);
318
- BoundingSphere_default.fromRectangle3D(
319
- rectangle,
320
- ellipsoid,
321
- maxTerrainHeight,
322
- scratchBoundingSphere
323
- );
324
- return BoundingSphere_default.union(result, scratchBoundingSphere, result);
325
- };
326
- function getTileXYLevel(rectangle) {
327
- Cartographic_default.fromRadians(
328
- rectangle.east,
329
- rectangle.north,
330
- 0,
331
- scratchCorners[0]
332
- );
333
- Cartographic_default.fromRadians(
334
- rectangle.west,
335
- rectangle.north,
336
- 0,
337
- scratchCorners[1]
338
- );
339
- Cartographic_default.fromRadians(
340
- rectangle.east,
341
- rectangle.south,
342
- 0,
343
- scratchCorners[2]
344
- );
345
- Cartographic_default.fromRadians(
346
- rectangle.west,
347
- rectangle.south,
348
- 0,
349
- scratchCorners[3]
350
- );
351
- let lastLevelX = 0, lastLevelY = 0;
352
- let currentX = 0, currentY = 0;
353
- const maxLevel = ApproximateTerrainHeights._terrainHeightsMaxLevel;
354
- let i;
355
- for (i = 0; i <= maxLevel; ++i) {
356
- let failed = false;
357
- for (let j = 0; j < 4; ++j) {
358
- const corner = scratchCorners[j];
359
- tilingScheme.positionToTileXY(corner, i, scratchTileXY);
360
- if (j === 0) {
361
- currentX = scratchTileXY.x;
362
- currentY = scratchTileXY.y;
363
- } else if (currentX !== scratchTileXY.x || currentY !== scratchTileXY.y) {
364
- failed = true;
365
- break;
366
- }
367
- }
368
- if (failed) {
369
- break;
370
- }
371
- lastLevelX = currentX;
372
- lastLevelY = currentY;
373
- }
374
- if (i === 0) {
375
- return void 0;
376
- }
377
- return {
378
- x: lastLevelX,
379
- y: lastLevelY,
380
- level: i > maxLevel ? maxLevel : i - 1
381
- };
382
- }
383
- ApproximateTerrainHeights._terrainHeightsMaxLevel = 6;
384
- ApproximateTerrainHeights._defaultMaxTerrainHeight = 9e3;
385
- ApproximateTerrainHeights._defaultMinTerrainHeight = -1e5;
386
- ApproximateTerrainHeights._terrainHeights = void 0;
387
- ApproximateTerrainHeights._initPromise = void 0;
388
- Object.defineProperties(ApproximateTerrainHeights, {
389
- /**
390
- * Determines if the terrain heights are initialized and ready to use. To initialize the terrain heights,
391
- * call {@link ApproximateTerrainHeights#initialize} and wait for the returned promise to resolve.
392
- * @type {boolean}
393
- * @readonly
394
- * @memberof ApproximateTerrainHeights
395
- */
396
- initialized: {
397
- get: function() {
398
- return defined_default(ApproximateTerrainHeights._terrainHeights);
399
- }
400
- }
401
- });
402
- var ApproximateTerrainHeights_default = ApproximateTerrainHeights;
403
-
404
- // packages/engine/Source/Core/GroundPolylineGeometry.js
405
- var PROJECTIONS = [GeographicProjection_default, WebMercatorProjection_default];
406
- var PROJECTION_COUNT = PROJECTIONS.length;
407
- var MITER_BREAK_SMALL = Math.cos(Math_default.toRadians(30));
408
- var MITER_BREAK_LARGE = Math.cos(Math_default.toRadians(150));
409
- var WALL_INITIAL_MIN_HEIGHT = 0;
410
- var WALL_INITIAL_MAX_HEIGHT = 1e3;
411
- function GroundPolylineGeometry(options) {
412
- options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
413
- const positions = options.positions;
414
- if (!defined_default(positions) || positions.length < 2) {
415
- throw new DeveloperError_default("At least two positions are required.");
416
- }
417
- if (defined_default(options.arcType) && options.arcType !== ArcType_default.GEODESIC && options.arcType !== ArcType_default.RHUMB) {
418
- throw new DeveloperError_default(
419
- "Valid options for arcType are ArcType.GEODESIC and ArcType.RHUMB."
420
- );
421
- }
422
- this.width = defaultValue_default(options.width, 1);
423
- this._positions = positions;
424
- this.granularity = defaultValue_default(options.granularity, 9999);
425
- this.loop = defaultValue_default(options.loop, false);
426
- this.arcType = defaultValue_default(options.arcType, ArcType_default.GEODESIC);
427
- this._ellipsoid = Ellipsoid_default.WGS84;
428
- this._projectionIndex = 0;
429
- this._workerName = "createGroundPolylineGeometry";
430
- this._scene3DOnly = false;
431
- }
432
- Object.defineProperties(GroundPolylineGeometry.prototype, {
433
- /**
434
- * The number of elements used to pack the object into an array.
435
- * @memberof GroundPolylineGeometry.prototype
436
- * @type {number}
437
- * @readonly
438
- * @private
439
- */
440
- packedLength: {
441
- get: function() {
442
- return 1 + this._positions.length * 3 + 1 + 1 + 1 + Ellipsoid_default.packedLength + 1 + 1;
443
- }
444
- }
445
- });
446
- GroundPolylineGeometry.setProjectionAndEllipsoid = function(groundPolylineGeometry, mapProjection) {
447
- let projectionIndex = 0;
448
- for (let i = 0; i < PROJECTION_COUNT; i++) {
449
- if (mapProjection instanceof PROJECTIONS[i]) {
450
- projectionIndex = i;
451
- break;
452
- }
453
- }
454
- groundPolylineGeometry._projectionIndex = projectionIndex;
455
- groundPolylineGeometry._ellipsoid = mapProjection.ellipsoid;
456
- };
457
- var cart3Scratch1 = new Cartesian3_default();
458
- var cart3Scratch2 = new Cartesian3_default();
459
- var cart3Scratch3 = new Cartesian3_default();
460
- function computeRightNormal(start, end, maxHeight, ellipsoid, result) {
461
- const startBottom = getPosition(ellipsoid, start, 0, cart3Scratch1);
462
- const startTop = getPosition(ellipsoid, start, maxHeight, cart3Scratch2);
463
- const endBottom = getPosition(ellipsoid, end, 0, cart3Scratch3);
464
- const up = direction(startTop, startBottom, cart3Scratch2);
465
- const forward = direction(endBottom, startBottom, cart3Scratch3);
466
- Cartesian3_default.cross(forward, up, result);
467
- return Cartesian3_default.normalize(result, result);
468
- }
469
- var interpolatedCartographicScratch = new Cartographic_default();
470
- var interpolatedBottomScratch = new Cartesian3_default();
471
- var interpolatedTopScratch = new Cartesian3_default();
472
- var interpolatedNormalScratch = new Cartesian3_default();
473
- function interpolateSegment(start, end, minHeight, maxHeight, granularity, arcType, ellipsoid, normalsArray, bottomPositionsArray, topPositionsArray, cartographicsArray) {
474
- if (granularity === 0) {
475
- return;
476
- }
477
- let ellipsoidLine;
478
- if (arcType === ArcType_default.GEODESIC) {
479
- ellipsoidLine = new EllipsoidGeodesic_default(start, end, ellipsoid);
480
- } else if (arcType === ArcType_default.RHUMB) {
481
- ellipsoidLine = new EllipsoidRhumbLine_default(start, end, ellipsoid);
482
- }
483
- const surfaceDistance = ellipsoidLine.surfaceDistance;
484
- if (surfaceDistance < granularity) {
485
- return;
486
- }
487
- const interpolatedNormal = computeRightNormal(
488
- start,
489
- end,
490
- maxHeight,
491
- ellipsoid,
492
- interpolatedNormalScratch
493
- );
494
- const segments = Math.ceil(surfaceDistance / granularity);
495
- const interpointDistance = surfaceDistance / segments;
496
- let distanceFromStart = interpointDistance;
497
- const pointsToAdd = segments - 1;
498
- let packIndex = normalsArray.length;
499
- for (let i = 0; i < pointsToAdd; i++) {
500
- const interpolatedCartographic = ellipsoidLine.interpolateUsingSurfaceDistance(
501
- distanceFromStart,
502
- interpolatedCartographicScratch
503
- );
504
- const interpolatedBottom = getPosition(
505
- ellipsoid,
506
- interpolatedCartographic,
507
- minHeight,
508
- interpolatedBottomScratch
509
- );
510
- const interpolatedTop = getPosition(
511
- ellipsoid,
512
- interpolatedCartographic,
513
- maxHeight,
514
- interpolatedTopScratch
515
- );
516
- Cartesian3_default.pack(interpolatedNormal, normalsArray, packIndex);
517
- Cartesian3_default.pack(interpolatedBottom, bottomPositionsArray, packIndex);
518
- Cartesian3_default.pack(interpolatedTop, topPositionsArray, packIndex);
519
- cartographicsArray.push(interpolatedCartographic.latitude);
520
- cartographicsArray.push(interpolatedCartographic.longitude);
521
- packIndex += 3;
522
- distanceFromStart += interpointDistance;
523
- }
524
- }
525
- var heightlessCartographicScratch = new Cartographic_default();
526
- function getPosition(ellipsoid, cartographic, height, result) {
527
- Cartographic_default.clone(cartographic, heightlessCartographicScratch);
528
- heightlessCartographicScratch.height = height;
529
- return Cartographic_default.toCartesian(
530
- heightlessCartographicScratch,
531
- ellipsoid,
532
- result
533
- );
534
- }
535
- GroundPolylineGeometry.pack = function(value, array, startingIndex) {
536
- Check_default.typeOf.object("value", value);
537
- Check_default.defined("array", array);
538
- let index = defaultValue_default(startingIndex, 0);
539
- const positions = value._positions;
540
- const positionsLength = positions.length;
541
- array[index++] = positionsLength;
542
- for (let i = 0; i < positionsLength; ++i) {
543
- const cartesian = positions[i];
544
- Cartesian3_default.pack(cartesian, array, index);
545
- index += 3;
546
- }
547
- array[index++] = value.granularity;
548
- array[index++] = value.loop ? 1 : 0;
549
- array[index++] = value.arcType;
550
- Ellipsoid_default.pack(value._ellipsoid, array, index);
551
- index += Ellipsoid_default.packedLength;
552
- array[index++] = value._projectionIndex;
553
- array[index++] = value._scene3DOnly ? 1 : 0;
554
- return array;
555
- };
556
- GroundPolylineGeometry.unpack = function(array, startingIndex, result) {
557
- Check_default.defined("array", array);
558
- let index = defaultValue_default(startingIndex, 0);
559
- const positionsLength = array[index++];
560
- const positions = new Array(positionsLength);
561
- for (let i = 0; i < positionsLength; i++) {
562
- positions[i] = Cartesian3_default.unpack(array, index);
563
- index += 3;
564
- }
565
- const granularity = array[index++];
566
- const loop = array[index++] === 1;
567
- const arcType = array[index++];
568
- const ellipsoid = Ellipsoid_default.unpack(array, index);
569
- index += Ellipsoid_default.packedLength;
570
- const projectionIndex = array[index++];
571
- const scene3DOnly = array[index++] === 1;
572
- if (!defined_default(result)) {
573
- result = new GroundPolylineGeometry({
574
- positions
575
- });
576
- }
577
- result._positions = positions;
578
- result.granularity = granularity;
579
- result.loop = loop;
580
- result.arcType = arcType;
581
- result._ellipsoid = ellipsoid;
582
- result._projectionIndex = projectionIndex;
583
- result._scene3DOnly = scene3DOnly;
584
- return result;
585
- };
586
- function direction(target, origin, result) {
587
- Cartesian3_default.subtract(target, origin, result);
588
- Cartesian3_default.normalize(result, result);
589
- return result;
590
- }
591
- function tangentDirection(target, origin, up, result) {
592
- result = direction(target, origin, result);
593
- result = Cartesian3_default.cross(result, up, result);
594
- result = Cartesian3_default.normalize(result, result);
595
- result = Cartesian3_default.cross(up, result, result);
596
- return result;
597
- }
598
- var toPreviousScratch = new Cartesian3_default();
599
- var toNextScratch = new Cartesian3_default();
600
- var forwardScratch = new Cartesian3_default();
601
- var vertexUpScratch = new Cartesian3_default();
602
- var cosine90 = 0;
603
- var cosine180 = -1;
604
- function computeVertexMiterNormal(previousBottom, vertexBottom, vertexTop, nextBottom, result) {
605
- const up = direction(vertexTop, vertexBottom, vertexUpScratch);
606
- const toPrevious = tangentDirection(
607
- previousBottom,
608
- vertexBottom,
609
- up,
610
- toPreviousScratch
611
- );
612
- const toNext = tangentDirection(nextBottom, vertexBottom, up, toNextScratch);
613
- if (Math_default.equalsEpsilon(
614
- Cartesian3_default.dot(toPrevious, toNext),
615
- cosine180,
616
- Math_default.EPSILON5
617
- )) {
618
- result = Cartesian3_default.cross(up, toPrevious, result);
619
- result = Cartesian3_default.normalize(result, result);
620
- return result;
621
- }
622
- result = Cartesian3_default.add(toNext, toPrevious, result);
623
- result = Cartesian3_default.normalize(result, result);
624
- const forward = Cartesian3_default.cross(up, result, forwardScratch);
625
- if (Cartesian3_default.dot(toNext, forward) < cosine90) {
626
- result = Cartesian3_default.negate(result, result);
627
- }
628
- return result;
629
- }
630
- var XZ_PLANE = Plane_default.fromPointNormal(Cartesian3_default.ZERO, Cartesian3_default.UNIT_Y);
631
- var previousBottomScratch = new Cartesian3_default();
632
- var vertexBottomScratch = new Cartesian3_default();
633
- var vertexTopScratch = new Cartesian3_default();
634
- var nextBottomScratch = new Cartesian3_default();
635
- var vertexNormalScratch = new Cartesian3_default();
636
- var intersectionScratch = new Cartesian3_default();
637
- var cartographicScratch0 = new Cartographic_default();
638
- var cartographicScratch1 = new Cartographic_default();
639
- var cartographicIntersectionScratch = new Cartographic_default();
640
- GroundPolylineGeometry.createGeometry = function(groundPolylineGeometry) {
641
- const compute2dAttributes = !groundPolylineGeometry._scene3DOnly;
642
- let loop = groundPolylineGeometry.loop;
643
- const ellipsoid = groundPolylineGeometry._ellipsoid;
644
- const granularity = groundPolylineGeometry.granularity;
645
- const arcType = groundPolylineGeometry.arcType;
646
- const projection = new PROJECTIONS[groundPolylineGeometry._projectionIndex](
647
- ellipsoid
648
- );
649
- const minHeight = WALL_INITIAL_MIN_HEIGHT;
650
- const maxHeight = WALL_INITIAL_MAX_HEIGHT;
651
- let index;
652
- let i;
653
- const positions = groundPolylineGeometry._positions;
654
- const positionsLength = positions.length;
655
- if (positionsLength === 2) {
656
- loop = false;
657
- }
658
- let p0;
659
- let p1;
660
- let c0;
661
- let c1;
662
- const rhumbLine = new EllipsoidRhumbLine_default(void 0, void 0, ellipsoid);
663
- let intersection;
664
- let intersectionCartographic;
665
- let intersectionLongitude;
666
- const splitPositions = [positions[0]];
667
- for (i = 0; i < positionsLength - 1; i++) {
668
- p0 = positions[i];
669
- p1 = positions[i + 1];
670
- intersection = IntersectionTests_default.lineSegmentPlane(
671
- p0,
672
- p1,
673
- XZ_PLANE,
674
- intersectionScratch
675
- );
676
- if (defined_default(intersection) && !Cartesian3_default.equalsEpsilon(intersection, p0, Math_default.EPSILON7) && !Cartesian3_default.equalsEpsilon(intersection, p1, Math_default.EPSILON7)) {
677
- if (groundPolylineGeometry.arcType === ArcType_default.GEODESIC) {
678
- splitPositions.push(Cartesian3_default.clone(intersection));
679
- } else if (groundPolylineGeometry.arcType === ArcType_default.RHUMB) {
680
- intersectionLongitude = ellipsoid.cartesianToCartographic(
681
- intersection,
682
- cartographicScratch0
683
- ).longitude;
684
- c0 = ellipsoid.cartesianToCartographic(p0, cartographicScratch0);
685
- c1 = ellipsoid.cartesianToCartographic(p1, cartographicScratch1);
686
- rhumbLine.setEndPoints(c0, c1);
687
- intersectionCartographic = rhumbLine.findIntersectionWithLongitude(
688
- intersectionLongitude,
689
- cartographicIntersectionScratch
690
- );
691
- intersection = ellipsoid.cartographicToCartesian(
692
- intersectionCartographic,
693
- intersectionScratch
694
- );
695
- if (defined_default(intersection) && !Cartesian3_default.equalsEpsilon(intersection, p0, Math_default.EPSILON7) && !Cartesian3_default.equalsEpsilon(intersection, p1, Math_default.EPSILON7)) {
696
- splitPositions.push(Cartesian3_default.clone(intersection));
697
- }
698
- }
699
- }
700
- splitPositions.push(p1);
701
- }
702
- if (loop) {
703
- p0 = positions[positionsLength - 1];
704
- p1 = positions[0];
705
- intersection = IntersectionTests_default.lineSegmentPlane(
706
- p0,
707
- p1,
708
- XZ_PLANE,
709
- intersectionScratch
710
- );
711
- if (defined_default(intersection) && !Cartesian3_default.equalsEpsilon(intersection, p0, Math_default.EPSILON7) && !Cartesian3_default.equalsEpsilon(intersection, p1, Math_default.EPSILON7)) {
712
- if (groundPolylineGeometry.arcType === ArcType_default.GEODESIC) {
713
- splitPositions.push(Cartesian3_default.clone(intersection));
714
- } else if (groundPolylineGeometry.arcType === ArcType_default.RHUMB) {
715
- intersectionLongitude = ellipsoid.cartesianToCartographic(
716
- intersection,
717
- cartographicScratch0
718
- ).longitude;
719
- c0 = ellipsoid.cartesianToCartographic(p0, cartographicScratch0);
720
- c1 = ellipsoid.cartesianToCartographic(p1, cartographicScratch1);
721
- rhumbLine.setEndPoints(c0, c1);
722
- intersectionCartographic = rhumbLine.findIntersectionWithLongitude(
723
- intersectionLongitude,
724
- cartographicIntersectionScratch
725
- );
726
- intersection = ellipsoid.cartographicToCartesian(
727
- intersectionCartographic,
728
- intersectionScratch
729
- );
730
- if (defined_default(intersection) && !Cartesian3_default.equalsEpsilon(intersection, p0, Math_default.EPSILON7) && !Cartesian3_default.equalsEpsilon(intersection, p1, Math_default.EPSILON7)) {
731
- splitPositions.push(Cartesian3_default.clone(intersection));
732
- }
733
- }
734
- }
735
- }
736
- let cartographicsLength = splitPositions.length;
737
- let cartographics = new Array(cartographicsLength);
738
- for (i = 0; i < cartographicsLength; i++) {
739
- const cartographic = Cartographic_default.fromCartesian(
740
- splitPositions[i],
741
- ellipsoid
742
- );
743
- cartographic.height = 0;
744
- cartographics[i] = cartographic;
745
- }
746
- cartographics = arrayRemoveDuplicates_default(
747
- cartographics,
748
- Cartographic_default.equalsEpsilon
749
- );
750
- cartographicsLength = cartographics.length;
751
- if (cartographicsLength < 2) {
752
- return void 0;
753
- }
754
- const cartographicsArray = [];
755
- const normalsArray = [];
756
- const bottomPositionsArray = [];
757
- const topPositionsArray = [];
758
- let previousBottom = previousBottomScratch;
759
- let vertexBottom = vertexBottomScratch;
760
- let vertexTop = vertexTopScratch;
761
- let nextBottom = nextBottomScratch;
762
- let vertexNormal = vertexNormalScratch;
763
- const startCartographic = cartographics[0];
764
- const nextCartographic = cartographics[1];
765
- const prestartCartographic = cartographics[cartographicsLength - 1];
766
- previousBottom = getPosition(
767
- ellipsoid,
768
- prestartCartographic,
769
- minHeight,
770
- previousBottom
771
- );
772
- nextBottom = getPosition(ellipsoid, nextCartographic, minHeight, nextBottom);
773
- vertexBottom = getPosition(
774
- ellipsoid,
775
- startCartographic,
776
- minHeight,
777
- vertexBottom
778
- );
779
- vertexTop = getPosition(ellipsoid, startCartographic, maxHeight, vertexTop);
780
- if (loop) {
781
- vertexNormal = computeVertexMiterNormal(
782
- previousBottom,
783
- vertexBottom,
784
- vertexTop,
785
- nextBottom,
786
- vertexNormal
787
- );
788
- } else {
789
- vertexNormal = computeRightNormal(
790
- startCartographic,
791
- nextCartographic,
792
- maxHeight,
793
- ellipsoid,
794
- vertexNormal
795
- );
796
- }
797
- Cartesian3_default.pack(vertexNormal, normalsArray, 0);
798
- Cartesian3_default.pack(vertexBottom, bottomPositionsArray, 0);
799
- Cartesian3_default.pack(vertexTop, topPositionsArray, 0);
800
- cartographicsArray.push(startCartographic.latitude);
801
- cartographicsArray.push(startCartographic.longitude);
802
- interpolateSegment(
803
- startCartographic,
804
- nextCartographic,
805
- minHeight,
806
- maxHeight,
807
- granularity,
808
- arcType,
809
- ellipsoid,
810
- normalsArray,
811
- bottomPositionsArray,
812
- topPositionsArray,
813
- cartographicsArray
814
- );
815
- for (i = 1; i < cartographicsLength - 1; ++i) {
816
- previousBottom = Cartesian3_default.clone(vertexBottom, previousBottom);
817
- vertexBottom = Cartesian3_default.clone(nextBottom, vertexBottom);
818
- const vertexCartographic = cartographics[i];
819
- getPosition(ellipsoid, vertexCartographic, maxHeight, vertexTop);
820
- getPosition(ellipsoid, cartographics[i + 1], minHeight, nextBottom);
821
- computeVertexMiterNormal(
822
- previousBottom,
823
- vertexBottom,
824
- vertexTop,
825
- nextBottom,
826
- vertexNormal
827
- );
828
- index = normalsArray.length;
829
- Cartesian3_default.pack(vertexNormal, normalsArray, index);
830
- Cartesian3_default.pack(vertexBottom, bottomPositionsArray, index);
831
- Cartesian3_default.pack(vertexTop, topPositionsArray, index);
832
- cartographicsArray.push(vertexCartographic.latitude);
833
- cartographicsArray.push(vertexCartographic.longitude);
834
- interpolateSegment(
835
- cartographics[i],
836
- cartographics[i + 1],
837
- minHeight,
838
- maxHeight,
839
- granularity,
840
- arcType,
841
- ellipsoid,
842
- normalsArray,
843
- bottomPositionsArray,
844
- topPositionsArray,
845
- cartographicsArray
846
- );
847
- }
848
- const endCartographic = cartographics[cartographicsLength - 1];
849
- const preEndCartographic = cartographics[cartographicsLength - 2];
850
- vertexBottom = getPosition(
851
- ellipsoid,
852
- endCartographic,
853
- minHeight,
854
- vertexBottom
855
- );
856
- vertexTop = getPosition(ellipsoid, endCartographic, maxHeight, vertexTop);
857
- if (loop) {
858
- const postEndCartographic = cartographics[0];
859
- previousBottom = getPosition(
860
- ellipsoid,
861
- preEndCartographic,
862
- minHeight,
863
- previousBottom
864
- );
865
- nextBottom = getPosition(
866
- ellipsoid,
867
- postEndCartographic,
868
- minHeight,
869
- nextBottom
870
- );
871
- vertexNormal = computeVertexMiterNormal(
872
- previousBottom,
873
- vertexBottom,
874
- vertexTop,
875
- nextBottom,
876
- vertexNormal
877
- );
878
- } else {
879
- vertexNormal = computeRightNormal(
880
- preEndCartographic,
881
- endCartographic,
882
- maxHeight,
883
- ellipsoid,
884
- vertexNormal
885
- );
886
- }
887
- index = normalsArray.length;
888
- Cartesian3_default.pack(vertexNormal, normalsArray, index);
889
- Cartesian3_default.pack(vertexBottom, bottomPositionsArray, index);
890
- Cartesian3_default.pack(vertexTop, topPositionsArray, index);
891
- cartographicsArray.push(endCartographic.latitude);
892
- cartographicsArray.push(endCartographic.longitude);
893
- if (loop) {
894
- interpolateSegment(
895
- endCartographic,
896
- startCartographic,
897
- minHeight,
898
- maxHeight,
899
- granularity,
900
- arcType,
901
- ellipsoid,
902
- normalsArray,
903
- bottomPositionsArray,
904
- topPositionsArray,
905
- cartographicsArray
906
- );
907
- index = normalsArray.length;
908
- for (i = 0; i < 3; ++i) {
909
- normalsArray[index + i] = normalsArray[i];
910
- bottomPositionsArray[index + i] = bottomPositionsArray[i];
911
- topPositionsArray[index + i] = topPositionsArray[i];
912
- }
913
- cartographicsArray.push(startCartographic.latitude);
914
- cartographicsArray.push(startCartographic.longitude);
915
- }
916
- return generateGeometryAttributes(
917
- loop,
918
- projection,
919
- bottomPositionsArray,
920
- topPositionsArray,
921
- normalsArray,
922
- cartographicsArray,
923
- compute2dAttributes
924
- );
925
- };
926
- var lineDirectionScratch = new Cartesian3_default();
927
- var matrix3Scratch = new Matrix3_default();
928
- var quaternionScratch = new Quaternion_default();
929
- function breakMiter(endGeometryNormal, startBottom, endBottom, endTop) {
930
- const lineDirection = direction(endBottom, startBottom, lineDirectionScratch);
931
- const dot = Cartesian3_default.dot(lineDirection, endGeometryNormal);
932
- if (dot > MITER_BREAK_SMALL || dot < MITER_BREAK_LARGE) {
933
- const vertexUp = direction(endTop, endBottom, vertexUpScratch);
934
- const angle = dot < MITER_BREAK_LARGE ? Math_default.PI_OVER_TWO : -Math_default.PI_OVER_TWO;
935
- const quaternion = Quaternion_default.fromAxisAngle(
936
- vertexUp,
937
- angle,
938
- quaternionScratch
939
- );
940
- const rotationMatrix = Matrix3_default.fromQuaternion(quaternion, matrix3Scratch);
941
- Matrix3_default.multiplyByVector(
942
- rotationMatrix,
943
- endGeometryNormal,
944
- endGeometryNormal
945
- );
946
- return true;
947
- }
948
- return false;
949
- }
950
- var endPosCartographicScratch = new Cartographic_default();
951
- var normalStartpointScratch = new Cartesian3_default();
952
- var normalEndpointScratch = new Cartesian3_default();
953
- function projectNormal(projection, cartographic, normal, projectedPosition, result) {
954
- const position = Cartographic_default.toCartesian(
955
- cartographic,
956
- projection._ellipsoid,
957
- normalStartpointScratch
958
- );
959
- let normalEndpoint = Cartesian3_default.add(position, normal, normalEndpointScratch);
960
- let flipNormal = false;
961
- const ellipsoid = projection._ellipsoid;
962
- let normalEndpointCartographic = ellipsoid.cartesianToCartographic(
963
- normalEndpoint,
964
- endPosCartographicScratch
965
- );
966
- if (Math.abs(cartographic.longitude - normalEndpointCartographic.longitude) > Math_default.PI_OVER_TWO) {
967
- flipNormal = true;
968
- normalEndpoint = Cartesian3_default.subtract(
969
- position,
970
- normal,
971
- normalEndpointScratch
972
- );
973
- normalEndpointCartographic = ellipsoid.cartesianToCartographic(
974
- normalEndpoint,
975
- endPosCartographicScratch
976
- );
977
- }
978
- normalEndpointCartographic.height = 0;
979
- const normalEndpointProjected = projection.project(
980
- normalEndpointCartographic,
981
- result
982
- );
983
- result = Cartesian3_default.subtract(
984
- normalEndpointProjected,
985
- projectedPosition,
986
- result
987
- );
988
- result.z = 0;
989
- result = Cartesian3_default.normalize(result, result);
990
- if (flipNormal) {
991
- Cartesian3_default.negate(result, result);
992
- }
993
- return result;
994
- }
995
- var adjustHeightNormalScratch = new Cartesian3_default();
996
- var adjustHeightOffsetScratch = new Cartesian3_default();
997
- function adjustHeights(bottom, top, minHeight, maxHeight, adjustHeightBottom, adjustHeightTop) {
998
- const adjustHeightNormal = Cartesian3_default.subtract(
999
- top,
1000
- bottom,
1001
- adjustHeightNormalScratch
1002
- );
1003
- Cartesian3_default.normalize(adjustHeightNormal, adjustHeightNormal);
1004
- const distanceForBottom = minHeight - WALL_INITIAL_MIN_HEIGHT;
1005
- let adjustHeightOffset = Cartesian3_default.multiplyByScalar(
1006
- adjustHeightNormal,
1007
- distanceForBottom,
1008
- adjustHeightOffsetScratch
1009
- );
1010
- Cartesian3_default.add(bottom, adjustHeightOffset, adjustHeightBottom);
1011
- const distanceForTop = maxHeight - WALL_INITIAL_MAX_HEIGHT;
1012
- adjustHeightOffset = Cartesian3_default.multiplyByScalar(
1013
- adjustHeightNormal,
1014
- distanceForTop,
1015
- adjustHeightOffsetScratch
1016
- );
1017
- Cartesian3_default.add(top, adjustHeightOffset, adjustHeightTop);
1018
- }
1019
- var nudgeDirectionScratch = new Cartesian3_default();
1020
- function nudgeXZ(start, end) {
1021
- const startToXZdistance = Plane_default.getPointDistance(XZ_PLANE, start);
1022
- const endToXZdistance = Plane_default.getPointDistance(XZ_PLANE, end);
1023
- let offset = nudgeDirectionScratch;
1024
- if (Math_default.equalsEpsilon(startToXZdistance, 0, Math_default.EPSILON2)) {
1025
- offset = direction(end, start, offset);
1026
- Cartesian3_default.multiplyByScalar(offset, Math_default.EPSILON2, offset);
1027
- Cartesian3_default.add(start, offset, start);
1028
- } else if (Math_default.equalsEpsilon(endToXZdistance, 0, Math_default.EPSILON2)) {
1029
- offset = direction(start, end, offset);
1030
- Cartesian3_default.multiplyByScalar(offset, Math_default.EPSILON2, offset);
1031
- Cartesian3_default.add(end, offset, end);
1032
- }
1033
- }
1034
- function nudgeCartographic(start, end) {
1035
- const absStartLon = Math.abs(start.longitude);
1036
- const absEndLon = Math.abs(end.longitude);
1037
- if (Math_default.equalsEpsilon(absStartLon, Math_default.PI, Math_default.EPSILON11)) {
1038
- const endSign = Math_default.sign(end.longitude);
1039
- start.longitude = endSign * (absStartLon - Math_default.EPSILON11);
1040
- return 1;
1041
- } else if (Math_default.equalsEpsilon(absEndLon, Math_default.PI, Math_default.EPSILON11)) {
1042
- const startSign = Math_default.sign(start.longitude);
1043
- end.longitude = startSign * (absEndLon - Math_default.EPSILON11);
1044
- return 2;
1045
- }
1046
- return 0;
1047
- }
1048
- var startCartographicScratch = new Cartographic_default();
1049
- var endCartographicScratch = new Cartographic_default();
1050
- var segmentStartTopScratch = new Cartesian3_default();
1051
- var segmentEndTopScratch = new Cartesian3_default();
1052
- var segmentStartBottomScratch = new Cartesian3_default();
1053
- var segmentEndBottomScratch = new Cartesian3_default();
1054
- var segmentStartNormalScratch = new Cartesian3_default();
1055
- var segmentEndNormalScratch = new Cartesian3_default();
1056
- var getHeightCartographics = [
1057
- startCartographicScratch,
1058
- endCartographicScratch
1059
- ];
1060
- var getHeightRectangleScratch = new Rectangle_default();
1061
- var adjustHeightStartTopScratch = new Cartesian3_default();
1062
- var adjustHeightEndTopScratch = new Cartesian3_default();
1063
- var adjustHeightStartBottomScratch = new Cartesian3_default();
1064
- var adjustHeightEndBottomScratch = new Cartesian3_default();
1065
- var segmentStart2DScratch = new Cartesian3_default();
1066
- var segmentEnd2DScratch = new Cartesian3_default();
1067
- var segmentStartNormal2DScratch = new Cartesian3_default();
1068
- var segmentEndNormal2DScratch = new Cartesian3_default();
1069
- var offsetScratch = new Cartesian3_default();
1070
- var startUpScratch = new Cartesian3_default();
1071
- var endUpScratch = new Cartesian3_default();
1072
- var rightScratch = new Cartesian3_default();
1073
- var startPlaneNormalScratch = new Cartesian3_default();
1074
- var endPlaneNormalScratch = new Cartesian3_default();
1075
- var encodeScratch = new EncodedCartesian3_default();
1076
- var encodeScratch2D = new EncodedCartesian3_default();
1077
- var forwardOffset2DScratch = new Cartesian3_default();
1078
- var right2DScratch = new Cartesian3_default();
1079
- var normalNudgeScratch = new Cartesian3_default();
1080
- var scratchBoundingSpheres = [new BoundingSphere_default(), new BoundingSphere_default()];
1081
- var REFERENCE_INDICES = [
1082
- 0,
1083
- 2,
1084
- 1,
1085
- 0,
1086
- 3,
1087
- 2,
1088
- // right
1089
- 0,
1090
- 7,
1091
- 3,
1092
- 0,
1093
- 4,
1094
- 7,
1095
- // start
1096
- 0,
1097
- 5,
1098
- 4,
1099
- 0,
1100
- 1,
1101
- 5,
1102
- // bottom
1103
- 5,
1104
- 7,
1105
- 4,
1106
- 5,
1107
- 6,
1108
- 7,
1109
- // left
1110
- 5,
1111
- 2,
1112
- 6,
1113
- 5,
1114
- 1,
1115
- 2,
1116
- // end
1117
- 3,
1118
- 6,
1119
- 2,
1120
- 3,
1121
- 7,
1122
- 6
1123
- // top
1124
- ];
1125
- var REFERENCE_INDICES_LENGTH = REFERENCE_INDICES.length;
1126
- function generateGeometryAttributes(loop, projection, bottomPositionsArray, topPositionsArray, normalsArray, cartographicsArray, compute2dAttributes) {
1127
- let i;
1128
- let index;
1129
- const ellipsoid = projection._ellipsoid;
1130
- const segmentCount = bottomPositionsArray.length / 3 - 1;
1131
- const vertexCount = segmentCount * 8;
1132
- const arraySizeVec4 = vertexCount * 4;
1133
- const indexCount = segmentCount * 36;
1134
- const indices = vertexCount > 65535 ? new Uint32Array(indexCount) : new Uint16Array(indexCount);
1135
- const positionsArray = new Float64Array(vertexCount * 3);
1136
- const startHiAndForwardOffsetX = new Float32Array(arraySizeVec4);
1137
- const startLoAndForwardOffsetY = new Float32Array(arraySizeVec4);
1138
- const startNormalAndForwardOffsetZ = new Float32Array(arraySizeVec4);
1139
- const endNormalAndTextureCoordinateNormalizationX = new Float32Array(
1140
- arraySizeVec4
1141
- );
1142
- const rightNormalAndTextureCoordinateNormalizationY = new Float32Array(
1143
- arraySizeVec4
1144
- );
1145
- let startHiLo2D;
1146
- let offsetAndRight2D;
1147
- let startEndNormals2D;
1148
- let texcoordNormalization2D;
1149
- if (compute2dAttributes) {
1150
- startHiLo2D = new Float32Array(arraySizeVec4);
1151
- offsetAndRight2D = new Float32Array(arraySizeVec4);
1152
- startEndNormals2D = new Float32Array(arraySizeVec4);
1153
- texcoordNormalization2D = new Float32Array(vertexCount * 2);
1154
- }
1155
- const cartographicsLength = cartographicsArray.length / 2;
1156
- let length2D = 0;
1157
- const startCartographic = startCartographicScratch;
1158
- startCartographic.height = 0;
1159
- const endCartographic = endCartographicScratch;
1160
- endCartographic.height = 0;
1161
- let segmentStartCartesian = segmentStartTopScratch;
1162
- let segmentEndCartesian = segmentEndTopScratch;
1163
- if (compute2dAttributes) {
1164
- index = 0;
1165
- for (i = 1; i < cartographicsLength; i++) {
1166
- startCartographic.latitude = cartographicsArray[index];
1167
- startCartographic.longitude = cartographicsArray[index + 1];
1168
- endCartographic.latitude = cartographicsArray[index + 2];
1169
- endCartographic.longitude = cartographicsArray[index + 3];
1170
- segmentStartCartesian = projection.project(
1171
- startCartographic,
1172
- segmentStartCartesian
1173
- );
1174
- segmentEndCartesian = projection.project(
1175
- endCartographic,
1176
- segmentEndCartesian
1177
- );
1178
- length2D += Cartesian3_default.distance(
1179
- segmentStartCartesian,
1180
- segmentEndCartesian
1181
- );
1182
- index += 2;
1183
- }
1184
- }
1185
- const positionsLength = topPositionsArray.length / 3;
1186
- segmentEndCartesian = Cartesian3_default.unpack(
1187
- topPositionsArray,
1188
- 0,
1189
- segmentEndCartesian
1190
- );
1191
- let length3D = 0;
1192
- index = 3;
1193
- for (i = 1; i < positionsLength; i++) {
1194
- segmentStartCartesian = Cartesian3_default.clone(
1195
- segmentEndCartesian,
1196
- segmentStartCartesian
1197
- );
1198
- segmentEndCartesian = Cartesian3_default.unpack(
1199
- topPositionsArray,
1200
- index,
1201
- segmentEndCartesian
1202
- );
1203
- length3D += Cartesian3_default.distance(segmentStartCartesian, segmentEndCartesian);
1204
- index += 3;
1205
- }
1206
- let j;
1207
- index = 3;
1208
- let cartographicsIndex = 0;
1209
- let vec2sWriteIndex = 0;
1210
- let vec3sWriteIndex = 0;
1211
- let vec4sWriteIndex = 0;
1212
- let miterBroken = false;
1213
- let endBottom = Cartesian3_default.unpack(
1214
- bottomPositionsArray,
1215
- 0,
1216
- segmentEndBottomScratch
1217
- );
1218
- let endTop = Cartesian3_default.unpack(topPositionsArray, 0, segmentEndTopScratch);
1219
- let endGeometryNormal = Cartesian3_default.unpack(
1220
- normalsArray,
1221
- 0,
1222
- segmentEndNormalScratch
1223
- );
1224
- if (loop) {
1225
- const preEndBottom = Cartesian3_default.unpack(
1226
- bottomPositionsArray,
1227
- bottomPositionsArray.length - 6,
1228
- segmentStartBottomScratch
1229
- );
1230
- if (breakMiter(endGeometryNormal, preEndBottom, endBottom, endTop)) {
1231
- endGeometryNormal = Cartesian3_default.negate(
1232
- endGeometryNormal,
1233
- endGeometryNormal
1234
- );
1235
- }
1236
- }
1237
- let lengthSoFar3D = 0;
1238
- let lengthSoFar2D = 0;
1239
- let sumHeights = 0;
1240
- for (i = 0; i < segmentCount; i++) {
1241
- const startBottom = Cartesian3_default.clone(endBottom, segmentStartBottomScratch);
1242
- const startTop = Cartesian3_default.clone(endTop, segmentStartTopScratch);
1243
- let startGeometryNormal = Cartesian3_default.clone(
1244
- endGeometryNormal,
1245
- segmentStartNormalScratch
1246
- );
1247
- if (miterBroken) {
1248
- startGeometryNormal = Cartesian3_default.negate(
1249
- startGeometryNormal,
1250
- startGeometryNormal
1251
- );
1252
- }
1253
- endBottom = Cartesian3_default.unpack(
1254
- bottomPositionsArray,
1255
- index,
1256
- segmentEndBottomScratch
1257
- );
1258
- endTop = Cartesian3_default.unpack(topPositionsArray, index, segmentEndTopScratch);
1259
- endGeometryNormal = Cartesian3_default.unpack(
1260
- normalsArray,
1261
- index,
1262
- segmentEndNormalScratch
1263
- );
1264
- miterBroken = breakMiter(endGeometryNormal, startBottom, endBottom, endTop);
1265
- startCartographic.latitude = cartographicsArray[cartographicsIndex];
1266
- startCartographic.longitude = cartographicsArray[cartographicsIndex + 1];
1267
- endCartographic.latitude = cartographicsArray[cartographicsIndex + 2];
1268
- endCartographic.longitude = cartographicsArray[cartographicsIndex + 3];
1269
- let start2D;
1270
- let end2D;
1271
- let startGeometryNormal2D;
1272
- let endGeometryNormal2D;
1273
- if (compute2dAttributes) {
1274
- const nudgeResult = nudgeCartographic(startCartographic, endCartographic);
1275
- start2D = projection.project(startCartographic, segmentStart2DScratch);
1276
- end2D = projection.project(endCartographic, segmentEnd2DScratch);
1277
- const direction2D = direction(end2D, start2D, forwardOffset2DScratch);
1278
- direction2D.y = Math.abs(direction2D.y);
1279
- startGeometryNormal2D = segmentStartNormal2DScratch;
1280
- endGeometryNormal2D = segmentEndNormal2DScratch;
1281
- if (nudgeResult === 0 || Cartesian3_default.dot(direction2D, Cartesian3_default.UNIT_Y) > MITER_BREAK_SMALL) {
1282
- startGeometryNormal2D = projectNormal(
1283
- projection,
1284
- startCartographic,
1285
- startGeometryNormal,
1286
- start2D,
1287
- segmentStartNormal2DScratch
1288
- );
1289
- endGeometryNormal2D = projectNormal(
1290
- projection,
1291
- endCartographic,
1292
- endGeometryNormal,
1293
- end2D,
1294
- segmentEndNormal2DScratch
1295
- );
1296
- } else if (nudgeResult === 1) {
1297
- endGeometryNormal2D = projectNormal(
1298
- projection,
1299
- endCartographic,
1300
- endGeometryNormal,
1301
- end2D,
1302
- segmentEndNormal2DScratch
1303
- );
1304
- startGeometryNormal2D.x = 0;
1305
- startGeometryNormal2D.y = Math_default.sign(
1306
- startCartographic.longitude - Math.abs(endCartographic.longitude)
1307
- );
1308
- startGeometryNormal2D.z = 0;
1309
- } else {
1310
- startGeometryNormal2D = projectNormal(
1311
- projection,
1312
- startCartographic,
1313
- startGeometryNormal,
1314
- start2D,
1315
- segmentStartNormal2DScratch
1316
- );
1317
- endGeometryNormal2D.x = 0;
1318
- endGeometryNormal2D.y = Math_default.sign(
1319
- startCartographic.longitude - endCartographic.longitude
1320
- );
1321
- endGeometryNormal2D.z = 0;
1322
- }
1323
- }
1324
- const segmentLength3D = Cartesian3_default.distance(startTop, endTop);
1325
- const encodedStart = EncodedCartesian3_default.fromCartesian(
1326
- startBottom,
1327
- encodeScratch
1328
- );
1329
- const forwardOffset = Cartesian3_default.subtract(
1330
- endBottom,
1331
- startBottom,
1332
- offsetScratch
1333
- );
1334
- const forward = Cartesian3_default.normalize(forwardOffset, rightScratch);
1335
- let startUp = Cartesian3_default.subtract(startTop, startBottom, startUpScratch);
1336
- startUp = Cartesian3_default.normalize(startUp, startUp);
1337
- let rightNormal = Cartesian3_default.cross(forward, startUp, rightScratch);
1338
- rightNormal = Cartesian3_default.normalize(rightNormal, rightNormal);
1339
- let startPlaneNormal = Cartesian3_default.cross(
1340
- startUp,
1341
- startGeometryNormal,
1342
- startPlaneNormalScratch
1343
- );
1344
- startPlaneNormal = Cartesian3_default.normalize(startPlaneNormal, startPlaneNormal);
1345
- let endUp = Cartesian3_default.subtract(endTop, endBottom, endUpScratch);
1346
- endUp = Cartesian3_default.normalize(endUp, endUp);
1347
- let endPlaneNormal = Cartesian3_default.cross(
1348
- endGeometryNormal,
1349
- endUp,
1350
- endPlaneNormalScratch
1351
- );
1352
- endPlaneNormal = Cartesian3_default.normalize(endPlaneNormal, endPlaneNormal);
1353
- const texcoordNormalization3DX = segmentLength3D / length3D;
1354
- const texcoordNormalization3DY = lengthSoFar3D / length3D;
1355
- let segmentLength2D = 0;
1356
- let encodedStart2D;
1357
- let forwardOffset2D;
1358
- let right2D;
1359
- let texcoordNormalization2DX = 0;
1360
- let texcoordNormalization2DY = 0;
1361
- if (compute2dAttributes) {
1362
- segmentLength2D = Cartesian3_default.distance(start2D, end2D);
1363
- encodedStart2D = EncodedCartesian3_default.fromCartesian(
1364
- start2D,
1365
- encodeScratch2D
1366
- );
1367
- forwardOffset2D = Cartesian3_default.subtract(
1368
- end2D,
1369
- start2D,
1370
- forwardOffset2DScratch
1371
- );
1372
- right2D = Cartesian3_default.normalize(forwardOffset2D, right2DScratch);
1373
- const swap = right2D.x;
1374
- right2D.x = right2D.y;
1375
- right2D.y = -swap;
1376
- texcoordNormalization2DX = segmentLength2D / length2D;
1377
- texcoordNormalization2DY = lengthSoFar2D / length2D;
1378
- }
1379
- for (j = 0; j < 8; j++) {
1380
- const vec4Index = vec4sWriteIndex + j * 4;
1381
- const vec2Index = vec2sWriteIndex + j * 2;
1382
- const wIndex = vec4Index + 3;
1383
- const rightPlaneSide = j < 4 ? 1 : -1;
1384
- const topBottomSide = j === 2 || j === 3 || j === 6 || j === 7 ? 1 : -1;
1385
- Cartesian3_default.pack(encodedStart.high, startHiAndForwardOffsetX, vec4Index);
1386
- startHiAndForwardOffsetX[wIndex] = forwardOffset.x;
1387
- Cartesian3_default.pack(encodedStart.low, startLoAndForwardOffsetY, vec4Index);
1388
- startLoAndForwardOffsetY[wIndex] = forwardOffset.y;
1389
- Cartesian3_default.pack(
1390
- startPlaneNormal,
1391
- startNormalAndForwardOffsetZ,
1392
- vec4Index
1393
- );
1394
- startNormalAndForwardOffsetZ[wIndex] = forwardOffset.z;
1395
- Cartesian3_default.pack(
1396
- endPlaneNormal,
1397
- endNormalAndTextureCoordinateNormalizationX,
1398
- vec4Index
1399
- );
1400
- endNormalAndTextureCoordinateNormalizationX[wIndex] = texcoordNormalization3DX * rightPlaneSide;
1401
- Cartesian3_default.pack(
1402
- rightNormal,
1403
- rightNormalAndTextureCoordinateNormalizationY,
1404
- vec4Index
1405
- );
1406
- let texcoordNormalization = texcoordNormalization3DY * topBottomSide;
1407
- if (texcoordNormalization === 0 && topBottomSide < 0) {
1408
- texcoordNormalization = 9;
1409
- }
1410
- rightNormalAndTextureCoordinateNormalizationY[wIndex] = texcoordNormalization;
1411
- if (compute2dAttributes) {
1412
- startHiLo2D[vec4Index] = encodedStart2D.high.x;
1413
- startHiLo2D[vec4Index + 1] = encodedStart2D.high.y;
1414
- startHiLo2D[vec4Index + 2] = encodedStart2D.low.x;
1415
- startHiLo2D[vec4Index + 3] = encodedStart2D.low.y;
1416
- startEndNormals2D[vec4Index] = -startGeometryNormal2D.y;
1417
- startEndNormals2D[vec4Index + 1] = startGeometryNormal2D.x;
1418
- startEndNormals2D[vec4Index + 2] = endGeometryNormal2D.y;
1419
- startEndNormals2D[vec4Index + 3] = -endGeometryNormal2D.x;
1420
- offsetAndRight2D[vec4Index] = forwardOffset2D.x;
1421
- offsetAndRight2D[vec4Index + 1] = forwardOffset2D.y;
1422
- offsetAndRight2D[vec4Index + 2] = right2D.x;
1423
- offsetAndRight2D[vec4Index + 3] = right2D.y;
1424
- texcoordNormalization2D[vec2Index] = texcoordNormalization2DX * rightPlaneSide;
1425
- texcoordNormalization = texcoordNormalization2DY * topBottomSide;
1426
- if (texcoordNormalization === 0 && topBottomSide < 0) {
1427
- texcoordNormalization = 9;
1428
- }
1429
- texcoordNormalization2D[vec2Index + 1] = texcoordNormalization;
1430
- }
1431
- }
1432
- const adjustHeightStartBottom = adjustHeightStartBottomScratch;
1433
- const adjustHeightEndBottom = adjustHeightEndBottomScratch;
1434
- const adjustHeightStartTop = adjustHeightStartTopScratch;
1435
- const adjustHeightEndTop = adjustHeightEndTopScratch;
1436
- const getHeightsRectangle = Rectangle_default.fromCartographicArray(
1437
- getHeightCartographics,
1438
- getHeightRectangleScratch
1439
- );
1440
- const minMaxHeights = ApproximateTerrainHeights_default.getMinimumMaximumHeights(
1441
- getHeightsRectangle,
1442
- ellipsoid
1443
- );
1444
- const minHeight = minMaxHeights.minimumTerrainHeight;
1445
- const maxHeight = minMaxHeights.maximumTerrainHeight;
1446
- sumHeights += Math.abs(minHeight);
1447
- sumHeights += Math.abs(maxHeight);
1448
- adjustHeights(
1449
- startBottom,
1450
- startTop,
1451
- minHeight,
1452
- maxHeight,
1453
- adjustHeightStartBottom,
1454
- adjustHeightStartTop
1455
- );
1456
- adjustHeights(
1457
- endBottom,
1458
- endTop,
1459
- minHeight,
1460
- maxHeight,
1461
- adjustHeightEndBottom,
1462
- adjustHeightEndTop
1463
- );
1464
- let normalNudge = Cartesian3_default.multiplyByScalar(
1465
- rightNormal,
1466
- Math_default.EPSILON5,
1467
- normalNudgeScratch
1468
- );
1469
- Cartesian3_default.add(
1470
- adjustHeightStartBottom,
1471
- normalNudge,
1472
- adjustHeightStartBottom
1473
- );
1474
- Cartesian3_default.add(adjustHeightEndBottom, normalNudge, adjustHeightEndBottom);
1475
- Cartesian3_default.add(adjustHeightStartTop, normalNudge, adjustHeightStartTop);
1476
- Cartesian3_default.add(adjustHeightEndTop, normalNudge, adjustHeightEndTop);
1477
- nudgeXZ(adjustHeightStartBottom, adjustHeightEndBottom);
1478
- nudgeXZ(adjustHeightStartTop, adjustHeightEndTop);
1479
- Cartesian3_default.pack(adjustHeightStartBottom, positionsArray, vec3sWriteIndex);
1480
- Cartesian3_default.pack(adjustHeightEndBottom, positionsArray, vec3sWriteIndex + 3);
1481
- Cartesian3_default.pack(adjustHeightEndTop, positionsArray, vec3sWriteIndex + 6);
1482
- Cartesian3_default.pack(adjustHeightStartTop, positionsArray, vec3sWriteIndex + 9);
1483
- normalNudge = Cartesian3_default.multiplyByScalar(
1484
- rightNormal,
1485
- -2 * Math_default.EPSILON5,
1486
- normalNudgeScratch
1487
- );
1488
- Cartesian3_default.add(
1489
- adjustHeightStartBottom,
1490
- normalNudge,
1491
- adjustHeightStartBottom
1492
- );
1493
- Cartesian3_default.add(adjustHeightEndBottom, normalNudge, adjustHeightEndBottom);
1494
- Cartesian3_default.add(adjustHeightStartTop, normalNudge, adjustHeightStartTop);
1495
- Cartesian3_default.add(adjustHeightEndTop, normalNudge, adjustHeightEndTop);
1496
- nudgeXZ(adjustHeightStartBottom, adjustHeightEndBottom);
1497
- nudgeXZ(adjustHeightStartTop, adjustHeightEndTop);
1498
- Cartesian3_default.pack(
1499
- adjustHeightStartBottom,
1500
- positionsArray,
1501
- vec3sWriteIndex + 12
1502
- );
1503
- Cartesian3_default.pack(
1504
- adjustHeightEndBottom,
1505
- positionsArray,
1506
- vec3sWriteIndex + 15
1507
- );
1508
- Cartesian3_default.pack(adjustHeightEndTop, positionsArray, vec3sWriteIndex + 18);
1509
- Cartesian3_default.pack(adjustHeightStartTop, positionsArray, vec3sWriteIndex + 21);
1510
- cartographicsIndex += 2;
1511
- index += 3;
1512
- vec2sWriteIndex += 16;
1513
- vec3sWriteIndex += 24;
1514
- vec4sWriteIndex += 32;
1515
- lengthSoFar3D += segmentLength3D;
1516
- lengthSoFar2D += segmentLength2D;
1517
- }
1518
- index = 0;
1519
- let indexOffset = 0;
1520
- for (i = 0; i < segmentCount; i++) {
1521
- for (j = 0; j < REFERENCE_INDICES_LENGTH; j++) {
1522
- indices[index + j] = REFERENCE_INDICES[j] + indexOffset;
1523
- }
1524
- indexOffset += 8;
1525
- index += REFERENCE_INDICES_LENGTH;
1526
- }
1527
- const boundingSpheres = scratchBoundingSpheres;
1528
- BoundingSphere_default.fromVertices(
1529
- bottomPositionsArray,
1530
- Cartesian3_default.ZERO,
1531
- 3,
1532
- boundingSpheres[0]
1533
- );
1534
- BoundingSphere_default.fromVertices(
1535
- topPositionsArray,
1536
- Cartesian3_default.ZERO,
1537
- 3,
1538
- boundingSpheres[1]
1539
- );
1540
- const boundingSphere = BoundingSphere_default.fromBoundingSpheres(boundingSpheres);
1541
- boundingSphere.radius += sumHeights / (segmentCount * 2);
1542
- const attributes = {
1543
- position: new GeometryAttribute_default({
1544
- componentDatatype: ComponentDatatype_default.DOUBLE,
1545
- componentsPerAttribute: 3,
1546
- normalize: false,
1547
- values: positionsArray
1548
- }),
1549
- startHiAndForwardOffsetX: getVec4GeometryAttribute(
1550
- startHiAndForwardOffsetX
1551
- ),
1552
- startLoAndForwardOffsetY: getVec4GeometryAttribute(
1553
- startLoAndForwardOffsetY
1554
- ),
1555
- startNormalAndForwardOffsetZ: getVec4GeometryAttribute(
1556
- startNormalAndForwardOffsetZ
1557
- ),
1558
- endNormalAndTextureCoordinateNormalizationX: getVec4GeometryAttribute(
1559
- endNormalAndTextureCoordinateNormalizationX
1560
- ),
1561
- rightNormalAndTextureCoordinateNormalizationY: getVec4GeometryAttribute(
1562
- rightNormalAndTextureCoordinateNormalizationY
1563
- )
1564
- };
1565
- if (compute2dAttributes) {
1566
- attributes.startHiLo2D = getVec4GeometryAttribute(startHiLo2D);
1567
- attributes.offsetAndRight2D = getVec4GeometryAttribute(offsetAndRight2D);
1568
- attributes.startEndNormals2D = getVec4GeometryAttribute(startEndNormals2D);
1569
- attributes.texcoordNormalization2D = new GeometryAttribute_default({
1570
- componentDatatype: ComponentDatatype_default.FLOAT,
1571
- componentsPerAttribute: 2,
1572
- normalize: false,
1573
- values: texcoordNormalization2D
1574
- });
1575
- }
1576
- return new Geometry_default({
1577
- attributes,
1578
- indices,
1579
- boundingSphere
1580
- });
1581
- }
1582
- function getVec4GeometryAttribute(typedArray) {
1583
- return new GeometryAttribute_default({
1584
- componentDatatype: ComponentDatatype_default.FLOAT,
1585
- componentsPerAttribute: 4,
1586
- normalize: false,
1587
- values: typedArray
1588
- });
1589
- }
1590
- GroundPolylineGeometry._projectNormal = projectNormal;
1591
- var GroundPolylineGeometry_default = GroundPolylineGeometry;
1592
-
1593
- // packages/engine/Source/Workers/createGroundPolylineGeometry.js
1594
- function createGroundPolylineGeometry(groundPolylineGeometry, offset) {
1595
- return ApproximateTerrainHeights_default.initialize().then(function() {
1596
- if (defined_default(offset)) {
1597
- groundPolylineGeometry = GroundPolylineGeometry_default.unpack(
1598
- groundPolylineGeometry,
1599
- offset
1600
- );
1601
- }
1602
- return GroundPolylineGeometry_default.createGeometry(groundPolylineGeometry);
1603
- });
1604
- }
1605
- var createGroundPolylineGeometry_default = createGroundPolylineGeometry;
1606
- export {
1607
- createGroundPolylineGeometry_default as default
1608
- };
26
+ import{a as _e}from"./chunk-DQQ63PYM.js";import{a as W}from"./chunk-J6UP6FLE.js";import{a as Ct}from"./chunk-QOUAJ6TL.js";import{a as Oe}from"./chunk-U4IEOH5K.js";import{a as Le}from"./chunk-3W4GT7KQ.js";import{a as te}from"./chunk-G5AGHVVC.js";import{b as Qt}from"./chunk-DMEY62ID.js";import{a as jt}from"./chunk-HTFSEEMT.js";import{c as Ce,d as zt}from"./chunk-RCV6KWXS.js";import{a as Pt,d as U}from"./chunk-4IW2T6GF.js";import{d as xe,e as Ne,f as Kt,h as Y}from"./chunk-PSPPBZWI.js";import{a as Bt}from"./chunk-AU7IKHOH.js";import{a as t,b as u,c as Rt,d as B,e as bt,f as vt}from"./chunk-64RSHJUE.js";import{a as p}from"./chunk-3SSKC3VN.js";import"./chunk-OSW76XDF.js";import"./chunk-ED5JPB3S.js";import{a as wt,b as tt}from"./chunk-LEYMRMBK.js";import{e as g}from"./chunk-VTAIKJXX.js";function it(e){e=e??vt.EMPTY_OBJECT,this._ellipsoid=e.ellipsoid??B.default,this._rectangle=e.rectangle??Y.MAX_VALUE,this._projection=new Pt(this._ellipsoid),this._numberOfLevelZeroTilesX=e.numberOfLevelZeroTilesX??2,this._numberOfLevelZeroTilesY=e.numberOfLevelZeroTilesY??1}Object.defineProperties(it.prototype,{ellipsoid:{get:function(){return this._ellipsoid}},rectangle:{get:function(){return this._rectangle}},projection:{get:function(){return this._projection}}});it.prototype.getNumberOfXTilesAtLevel=function(e){return this._numberOfLevelZeroTilesX<<e};it.prototype.getNumberOfYTilesAtLevel=function(e){return this._numberOfLevelZeroTilesY<<e};it.prototype.rectangleToNativeRectangle=function(e,i){tt.defined("rectangle",e);let r=p.toDegrees(e.west),n=p.toDegrees(e.south),o=p.toDegrees(e.east),a=p.toDegrees(e.north);return g(i)?(i.west=r,i.south=n,i.east=o,i.north=a,i):new Y(r,n,o,a)};it.prototype.tileXYToNativeRectangle=function(e,i,r,n){let o=this.tileXYToRectangle(e,i,r,n);return o.west=p.toDegrees(o.west),o.south=p.toDegrees(o.south),o.east=p.toDegrees(o.east),o.north=p.toDegrees(o.north),o};it.prototype.tileXYToRectangle=function(e,i,r,n){let o=this._rectangle,a=this.getNumberOfXTilesAtLevel(r),c=this.getNumberOfYTilesAtLevel(r),l=o.width/a,s=e*l+o.west,d=(e+1)*l+o.west,h=o.height/c,N=o.north-i*h,S=o.north-(i+1)*h;return g(n)||(n=new Y(s,S,d,N)),n.west=s,n.south=S,n.east=d,n.north=N,n};it.prototype.positionToTileXY=function(e,i,r){let n=this._rectangle;if(!Y.contains(n,e))return;let o=this.getNumberOfXTilesAtLevel(i),a=this.getNumberOfYTilesAtLevel(i),c=n.width/o,l=n.height/a,s=e.longitude;n.east<n.west&&(s+=p.TWO_PI);let d=(s-n.west)/c|0;d>=o&&(d=o-1);let h=(n.north-e.latitude)/l|0;return h>=a&&(h=a-1),g(r)?(r.x=d,r.y=h,r):new Rt(d,h)};var De=it;var Ie=new t,He=new t,ke=new u,ee=new t,hn=new t,ye=new U,pn=new De,_t=[new u,new u,new u,new u],Lt=new Rt,w={};w.initialize=function(){let e=w._initPromise;return g(e)||(e=xe.fetchJson(Ne("Assets/approximateTerrainHeights.json")).then(function(i){w._terrainHeights=i}),w._initPromise=e),e};w.getMinimumMaximumHeights=function(e,i){if(tt.defined("rectangle",e),!g(w._terrainHeights))throw new wt("You must call ApproximateTerrainHeights.initialize and wait for the promise to resolve before using this function");i=i??B.default;let r=Ae(e),n=w._defaultMinTerrainHeight,o=w._defaultMaxTerrainHeight;if(g(r)){let a=`${r.level}-${r.x}-${r.y}`,c=w._terrainHeights[a];g(c)&&(n=c[0],o=c[1]),i.cartographicToCartesian(Y.northeast(e,ke),Ie),i.cartographicToCartesian(Y.southwest(e,ke),He),t.midpoint(He,Ie,ee);let l=i.scaleToGeodeticSurface(ee,hn);if(g(l)){let s=t.distance(ee,l);n=Math.min(n,-s)}else n=w._defaultMinTerrainHeight}return n=Math.max(w._defaultMinTerrainHeight,n),{minimumTerrainHeight:n,maximumTerrainHeight:o}};w.getBoundingSphere=function(e,i){if(tt.defined("rectangle",e),!g(w._terrainHeights))throw new wt("You must call ApproximateTerrainHeights.initialize and wait for the promise to resolve before using this function");i=i??B.default;let r=Ae(e),n=w._defaultMaxTerrainHeight;if(g(r)){let a=`${r.level}-${r.x}-${r.y}`,c=w._terrainHeights[a];g(c)&&(n=c[1])}let o=U.fromRectangle3D(e,i,0);return U.fromRectangle3D(e,i,n,ye),U.union(o,ye,o)};function Ae(e){u.fromRadians(e.east,e.north,0,_t[0]),u.fromRadians(e.west,e.north,0,_t[1]),u.fromRadians(e.east,e.south,0,_t[2]),u.fromRadians(e.west,e.south,0,_t[3]);let i=0,r=0,n=0,o=0,a=w._terrainHeightsMaxLevel,c;for(c=0;c<=a;++c){let l=!1;for(let s=0;s<4;++s){let d=_t[s];if(pn.positionToTileXY(d,c,Lt),s===0)n=Lt.x,o=Lt.y;else if(n!==Lt.x||o!==Lt.y){l=!0;break}}if(l)break;i=n,r=o}if(c!==0)return{x:i,y:r,level:c>a?a:c-1}}w._terrainHeightsMaxLevel=6;w._defaultMaxTerrainHeight=9e3;w._defaultMinTerrainHeight=-1e5;w._terrainHeights=void 0;w._initPromise=void 0;Object.defineProperties(w,{initialized:{get:function(){return g(w._terrainHeights)}}});var Ft=w;var le=[Pt,_e],dn=le.length,Ke=Math.cos(p.toRadians(30)),Me=Math.cos(p.toRadians(150)),Qe=0,tn=1e3;function at(e){e=e??vt.EMPTY_OBJECT;let i=e.positions;if(!g(i)||i.length<2)throw new wt("At least two positions are required.");if(g(e.arcType)&&e.arcType!==W.GEODESIC&&e.arcType!==W.RHUMB)throw new wt("Valid options for arcType are ArcType.GEODESIC and ArcType.RHUMB.");this.width=e.width??1,this._positions=i,this.granularity=e.granularity??9999,this.loop=e.loop??!1,this.arcType=e.arcType??W.GEODESIC,this._ellipsoid=B.default,this._projectionIndex=0,this._workerName="createGroundPolylineGeometry",this._scene3DOnly=!1}Object.defineProperties(at.prototype,{packedLength:{get:function(){return 1+this._positions.length*3+1+1+1+B.packedLength+1+1}}});at.setProjectionAndEllipsoid=function(e,i){let r=0;for(let n=0;n<dn;n++)if(i instanceof le[n]){r=n;break}e._projectionIndex=r,e._ellipsoid=i.ellipsoid};var fn=new t,Re=new t,Pe=new t;function se(e,i,r,n,o){let a=R(n,e,0,fn),c=R(n,e,r,Re),l=R(n,i,0,Pe),s=et(c,a,Re),d=et(l,a,Pe);return t.cross(d,s,o),t.normalize(o,o)}var mn=new u,gn=new t,un=new t,wn=new t;function ne(e,i,r,n,o,a,c,l,s,d,h){if(o===0)return;let N;a===W.GEODESIC?N=new Oe(e,i,c):a===W.RHUMB&&(N=new te(e,i,c));let S=N.surfaceDistance;if(S<o)return;let M=se(e,i,n,c,wn),O=Math.ceil(S/o),D=S/O,z=D,G=O-1,f=l.length;for(let j=0;j<G;j++){let b=N.interpolateUsingSurfaceDistance(z,mn),k=R(c,b,r,gn),I=R(c,b,n,un);t.pack(M,l,f),t.pack(k,s,f),t.pack(I,d,f),h.push(b.latitude),h.push(b.longitude),f+=3,z+=D}}var oe=new u;function R(e,i,r,n){return u.clone(i,oe),oe.height=r,u.toCartesian(oe,e,n)}at.pack=function(e,i,r){tt.typeOf.object("value",e),tt.defined("array",i);let n=r??0,o=e._positions,a=o.length;i[n++]=a;for(let c=0;c<a;++c){let l=o[c];t.pack(l,i,n),n+=3}return i[n++]=e.granularity,i[n++]=e.loop?1:0,i[n++]=e.arcType,B.pack(e._ellipsoid,i,n),n+=B.packedLength,i[n++]=e._projectionIndex,i[n++]=e._scene3DOnly?1:0,i};at.unpack=function(e,i,r){tt.defined("array",e);let n=i??0,o=e[n++],a=new Array(o);for(let S=0;S<o;S++)a[S]=t.unpack(e,n),n+=3;let c=e[n++],l=e[n++]===1,s=e[n++],d=B.unpack(e,n);n+=B.packedLength;let h=e[n++],N=e[n++]===1;return g(r)||(r=new at({positions:a})),r._positions=a,r.granularity=c,r.loop=l,r.arcType=s,r._ellipsoid=d,r._projectionIndex=h,r._scene3DOnly=N,r};function et(e,i,r){return t.subtract(e,i,r),t.normalize(r,r),r}function be(e,i,r,n){return n=et(e,i,n),n=t.cross(n,r,n),n=t.normalize(n,n),n=t.cross(r,n,n),n}var Sn=new t,Tn=new t,En=new t,en=new t,xn=0,Nn=-1;function ie(e,i,r,n,o){let a=et(r,i,en),c=be(e,i,a,Sn),l=be(n,i,a,Tn);if(p.equalsEpsilon(t.dot(c,l),Nn,p.EPSILON5))return o=t.cross(a,c,o),o=t.normalize(o,o),o;o=t.add(l,c,o),o=t.normalize(o,o);let s=t.cross(a,o,En);return t.dot(l,s)<xn&&(o=t.negate(o,o)),o}var Gt=jt.fromPointNormal(t.ZERO,t.UNIT_Y),Cn=new t,_n=new t,Ln=new t,On=new t,Dn=new t,Xt=new t,Yt=new u,ve=new u,Be=new u;at.createGeometry=function(e){let i=!e._scene3DOnly,r=e.loop,n=e._ellipsoid,o=e.granularity,a=e.arcType,c=new le[e._projectionIndex](n),l=Qe,s=tn,d,h,N=e._positions,S=N.length;S===2&&(r=!1);let M,O,D,z,G=new te(void 0,void 0,n),f,j,b,k=[N[0]];for(h=0;h<S-1;h++)M=N[h],O=N[h+1],f=Qt.lineSegmentPlane(M,O,Gt,Xt),g(f)&&!t.equalsEpsilon(f,M,p.EPSILON7)&&!t.equalsEpsilon(f,O,p.EPSILON7)&&(e.arcType===W.GEODESIC?k.push(t.clone(f)):e.arcType===W.RHUMB&&(b=n.cartesianToCartographic(f,Yt).longitude,D=n.cartesianToCartographic(M,Yt),z=n.cartesianToCartographic(O,ve),G.setEndPoints(D,z),j=G.findIntersectionWithLongitude(b,Be),f=n.cartographicToCartesian(j,Xt),g(f)&&!t.equalsEpsilon(f,M,p.EPSILON7)&&!t.equalsEpsilon(f,O,p.EPSILON7)&&k.push(t.clone(f)))),k.push(O);r&&(M=N[S-1],O=N[0],f=Qt.lineSegmentPlane(M,O,Gt,Xt),g(f)&&!t.equalsEpsilon(f,M,p.EPSILON7)&&!t.equalsEpsilon(f,O,p.EPSILON7)&&(e.arcType===W.GEODESIC?k.push(t.clone(f)):e.arcType===W.RHUMB&&(b=n.cartesianToCartographic(f,Yt).longitude,D=n.cartesianToCartographic(M,Yt),z=n.cartesianToCartographic(O,ve),G.setEndPoints(D,z),j=G.findIntersectionWithLongitude(b,Be),f=n.cartographicToCartesian(j,Xt),g(f)&&!t.equalsEpsilon(f,M,p.EPSILON7)&&!t.equalsEpsilon(f,O,p.EPSILON7)&&k.push(t.clone(f)))));let I=k.length,C=new Array(I);for(h=0;h<I;h++){let X=u.fromCartesian(k[h],n);X.height=0,C[h]=X}if(C=Le(C,u.equalsEpsilon),I=C.length,I<2)return;let H=[],P=[],v=[],E=[],x=Cn,L=_n,_=Ln,F=On,y=Dn,m=C[0],Z=C[1],Dt=C[I-1];for(x=R(n,Dt,l,x),F=R(n,Z,l,F),L=R(n,m,l,L),_=R(n,m,s,_),r?y=ie(x,L,_,F,y):y=se(m,Z,s,n,y),t.pack(y,P,0),t.pack(L,v,0),t.pack(_,E,0),H.push(m.latitude),H.push(m.longitude),ne(m,Z,l,s,o,a,n,P,v,E,H),h=1;h<I-1;++h){x=t.clone(L,x),L=t.clone(F,L);let X=C[h];R(n,X,s,_),R(n,C[h+1],l,F),ie(x,L,_,F,y),d=P.length,t.pack(y,P,d),t.pack(L,v,d),t.pack(_,E,d),H.push(X.latitude),H.push(X.longitude),ne(C[h],C[h+1],l,s,o,a,n,P,v,E,H)}let A=C[I-1],St=C[I-2];if(L=R(n,A,l,L),_=R(n,A,s,_),r){let X=C[0];x=R(n,St,l,x),F=R(n,X,l,F),y=ie(x,L,_,F,y)}else y=se(St,A,s,n,y);if(d=P.length,t.pack(y,P,d),t.pack(L,v,d),t.pack(_,E,d),H.push(A.latitude),H.push(A.longitude),r){for(ne(A,m,l,s,o,a,n,P,v,E,H),d=P.length,h=0;h<3;++h)P[d+h]=P[h],v[d+h]=v[h],E[d+h]=E[h];H.push(m.latitude),H.push(m.longitude)}return Qn(r,c,v,E,P,H,i)};var In=new t,Hn=new bt,kn=new Kt;function ze(e,i,r,n){let o=et(r,i,In),a=t.dot(o,e);if(a>Ke||a<Me){let c=et(n,r,en),l=a<Me?p.PI_OVER_TWO:-p.PI_OVER_TWO,s=Kt.fromAxisAngle(c,l,kn),d=bt.fromQuaternion(s,Hn);return bt.multiplyByVector(d,e,e),!0}return!1}var je=new u,yn=new t,Fe=new t;function Ot(e,i,r,n,o){let a=u.toCartesian(i,e._ellipsoid,yn),c=t.add(a,r,Fe),l=!1,s=e._ellipsoid,d=s.cartesianToCartographic(c,je);Math.abs(i.longitude-d.longitude)>p.PI_OVER_TWO&&(l=!0,c=t.subtract(a,r,Fe),d=s.cartesianToCartographic(c,je)),d.height=0;let h=e.project(d,o);return o=t.subtract(h,n,o),o.z=0,o=t.normalize(o,o),l&&t.negate(o,o),o}var An=new t,Xe=new t;function Ye(e,i,r,n,o,a){let c=t.subtract(i,e,An);t.normalize(c,c);let l=r-Qe,s=t.multiplyByScalar(c,l,Xe);t.add(e,s,o);let d=n-tn;s=t.multiplyByScalar(c,d,Xe),t.add(i,s,a)}var Mn=new t;function Ut(e,i){let r=jt.getPointDistance(Gt,e),n=jt.getPointDistance(Gt,i),o=Mn;p.equalsEpsilon(r,0,p.EPSILON2)?(o=et(i,e,o),t.multiplyByScalar(o,p.EPSILON2,o),t.add(e,o,e)):p.equalsEpsilon(n,0,p.EPSILON2)&&(o=et(e,i,o),t.multiplyByScalar(o,p.EPSILON2,o),t.add(i,o,i))}function Rn(e,i){let r=Math.abs(e.longitude),n=Math.abs(i.longitude);if(p.equalsEpsilon(r,p.PI,p.EPSILON11)){let o=p.sign(i.longitude);return e.longitude=o*(r-p.EPSILON11),1}else if(p.equalsEpsilon(n,p.PI,p.EPSILON11)){let o=p.sign(e.longitude);return i.longitude=o*(n-p.EPSILON11),2}return 0}var nn=new u,on=new u,Ue=new t,re=new t,Ge=new t,qe=new t,Pn=new t,We=new t,bn=[nn,on],vn=new Y,Bn=new t,zn=new t,jn=new t,Fn=new t,Xn=new t,Yn=new t,ae=new t,ce=new t,Un=new t,Gn=new t,qn=new t,Ze=new t,Wn=new t,Zn=new t,Vn=new Ct,$n=new Ct,Ve=new t,Jn=new t,$e=new t,Kn=[new U,new U],rn=[0,2,1,0,3,2,0,7,3,0,4,7,0,5,4,0,1,5,5,7,4,5,6,7,5,2,6,5,1,2,3,6,2,3,7,6],Je=rn.length;function Qn(e,i,r,n,o,a,c){let l,s,d=i._ellipsoid,h=r.length/3-1,N=h*8,S=N*4,M=h*36,O=N>65535?new Uint32Array(M):new Uint16Array(M),D=new Float64Array(N*3),z=new Float32Array(S),G=new Float32Array(S),f=new Float32Array(S),j=new Float32Array(S),b=new Float32Array(S),k,I,C,H;c&&(k=new Float32Array(S),I=new Float32Array(S),C=new Float32Array(S),H=new Float32Array(N*2));let P=a.length/2,v=0,E=nn;E.height=0;let x=on;x.height=0;let L=Ue,_=re;if(c)for(s=0,l=1;l<P;l++)E.latitude=a[s],E.longitude=a[s+1],x.latitude=a[s+2],x.longitude=a[s+3],L=i.project(E,L),_=i.project(x,_),v+=t.distance(L,_),s+=2;let F=n.length/3;_=t.unpack(n,0,_);let y=0;for(s=3,l=1;l<F;l++)L=t.clone(_,L),_=t.unpack(n,s,_),y+=t.distance(L,_),s+=3;let m;s=3;let Z=0,Dt=0,A=0,St=0,X=!1,ct=t.unpack(r,0,qe),st=t.unpack(n,0,re),q=t.unpack(o,0,We);if(e){let lt=t.unpack(r,r.length-6,Ge);ze(q,lt,ct,st)&&(q=t.negate(q,q))}let pe=0,de=0,qt=0;for(l=0;l<h;l++){let lt=t.clone(ct,Ge),Zt=t.clone(st,Ue),ft=t.clone(q,Pn);X&&(ft=t.negate(ft,ft)),ct=t.unpack(r,s,qe),st=t.unpack(n,s,re),q=t.unpack(o,s,We),X=ze(q,lt,ct,st),E.latitude=a[Z],E.longitude=a[Z+1],x.latitude=a[Z+2],x.longitude=a[Z+3];let ht,mt,nt,ot;if(c){let T=Rn(E,x);ht=i.project(E,Xn),mt=i.project(x,Yn);let ut=et(mt,ht,Ve);ut.y=Math.abs(ut.y),nt=ae,ot=ce,T===0||t.dot(ut,t.UNIT_Y)>Ke?(nt=Ot(i,E,ft,ht,ae),ot=Ot(i,x,q,mt,ce)):T===1?(ot=Ot(i,x,q,mt,ce),nt.x=0,nt.y=p.sign(E.longitude-Math.abs(x.longitude)),nt.z=0):(nt=Ot(i,E,ft,ht,ae),ot.x=0,ot.y=p.sign(E.longitude-x.longitude),ot.z=0)}let ge=t.distance(Zt,st),ue=Ct.fromCartesian(lt,Vn),It=t.subtract(ct,lt,Un),an=t.normalize(It,Ze),Et=t.subtract(Zt,lt,Gn);Et=t.normalize(Et,Et);let gt=t.cross(an,Et,Ze);gt=t.normalize(gt,gt);let Ht=t.cross(Et,ft,Wn);Ht=t.normalize(Ht,Ht);let kt=t.subtract(st,ct,qn);kt=t.normalize(kt,kt);let yt=t.cross(q,kt,Zn);yt=t.normalize(yt,yt);let cn=ge/y,sn=pe/y,Vt=0,xt,At,pt,we=0,Se=0;if(c){Vt=t.distance(ht,mt),xt=Ct.fromCartesian(ht,$n),At=t.subtract(mt,ht,Ve),pt=t.normalize(At,Jn);let T=pt.x;pt.x=pt.y,pt.y=-T,we=Vt/v,Se=de/v}for(m=0;m<8;m++){let T=St+m*4,ut=Dt+m*2,Nt=T+3,Ee=m<4?1:-1,Mt=m===2||m===3||m===6||m===7?1:-1;t.pack(ue.high,z,T),z[Nt]=It.x,t.pack(ue.low,G,T),G[Nt]=It.y,t.pack(Ht,f,T),f[Nt]=It.z,t.pack(yt,j,T),j[Nt]=cn*Ee,t.pack(gt,b,T);let dt=sn*Mt;dt===0&&Mt<0&&(dt=9),b[Nt]=dt,c&&(k[T]=xt.high.x,k[T+1]=xt.high.y,k[T+2]=xt.low.x,k[T+3]=xt.low.y,C[T]=-nt.y,C[T+1]=nt.x,C[T+2]=ot.y,C[T+3]=-ot.x,I[T]=At.x,I[T+1]=At.y,I[T+2]=pt.x,I[T+3]=pt.y,H[ut]=we*Ee,dt=Se*Mt,dt===0&&Mt<0&&(dt=9),H[ut+1]=dt)}let V=jn,$=Fn,J=Bn,K=zn,ln=Y.fromCartographicArray(bn,vn),Te=Ft.getMinimumMaximumHeights(ln,d),$t=Te.minimumTerrainHeight,Jt=Te.maximumTerrainHeight;qt+=Math.abs($t),qt+=Math.abs(Jt),Ye(lt,Zt,$t,Jt,V,J),Ye(ct,st,$t,Jt,$,K);let Q=t.multiplyByScalar(gt,p.EPSILON5,$e);t.add(V,Q,V),t.add($,Q,$),t.add(J,Q,J),t.add(K,Q,K),Ut(V,$),Ut(J,K),t.pack(V,D,A),t.pack($,D,A+3),t.pack(K,D,A+6),t.pack(J,D,A+9),Q=t.multiplyByScalar(gt,-2*p.EPSILON5,$e),t.add(V,Q,V),t.add($,Q,$),t.add(J,Q,J),t.add(K,Q,K),Ut(V,$),Ut(J,K),t.pack(V,D,A+12),t.pack($,D,A+15),t.pack(K,D,A+18),t.pack(J,D,A+21),Z+=2,s+=3,Dt+=16,A+=24,St+=32,pe+=ge,de+=Vt}s=0;let fe=0;for(l=0;l<h;l++){for(m=0;m<Je;m++)O[s+m]=rn[m]+fe;fe+=8,s+=Je}let Wt=Kn;U.fromVertices(r,t.ZERO,3,Wt[0]),U.fromVertices(n,t.ZERO,3,Wt[1]);let me=U.fromBoundingSpheres(Wt);me.radius+=qt/(h*2);let Tt={position:new zt({componentDatatype:Bt.DOUBLE,componentsPerAttribute:3,normalize:!1,values:D}),startHiAndForwardOffsetX:rt(z),startLoAndForwardOffsetY:rt(G),startNormalAndForwardOffsetZ:rt(f),endNormalAndTextureCoordinateNormalizationX:rt(j),rightNormalAndTextureCoordinateNormalizationY:rt(b)};return c&&(Tt.startHiLo2D=rt(k),Tt.offsetAndRight2D=rt(I),Tt.startEndNormals2D=rt(C),Tt.texcoordNormalization2D=new zt({componentDatatype:Bt.FLOAT,componentsPerAttribute:2,normalize:!1,values:H})),new Ce({attributes:Tt,indices:O,boundingSphere:me})}function rt(e){return new zt({componentDatatype:Bt.FLOAT,componentsPerAttribute:4,normalize:!1,values:e})}at._projectNormal=Ot;var he=at;function to(e,i){return Ft.initialize().then(function(){return g(i)&&(e=he.unpack(e,i)),he.createGeometry(e)})}var Qo=to;export{Qo as default};