@gmgis/gm-sdk 1.12.5 → 2.0.2

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