@cesium/engine 3.0.2 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (246) hide show
  1. package/Build/ThirdParty/Workers/pako_deflate.min.js +605 -0
  2. package/Build/ThirdParty/Workers/pako_inflate.min.js +800 -0
  3. package/Build/ThirdParty/Workers/z-worker-pako.js +502 -0
  4. package/Build/Workers/chunk-2U6EBIRX.js +757 -0
  5. package/Build/Workers/chunk-2ZI7FZ3Q.js +58 -0
  6. package/Build/Workers/chunk-3TSHZWOZ.js +1860 -0
  7. package/Build/Workers/chunk-44B6FQSJ.js +684 -0
  8. package/Build/Workers/chunk-4AJR66C5.js +368 -0
  9. package/Build/Workers/chunk-4HN3N5SE.js +501 -0
  10. package/Build/Workers/chunk-4QGPYV3W.js +102 -0
  11. package/Build/Workers/chunk-4RKE4B3G.js +476 -0
  12. package/Build/Workers/chunk-5E3V7Y4R.js +196 -0
  13. package/Build/Workers/chunk-6EHT6GS3.js +163 -0
  14. package/Build/Workers/chunk-6I22NWKQ.js +171 -0
  15. package/Build/Workers/chunk-7N67FBLW.js +1054 -0
  16. package/Build/Workers/chunk-AQQGAFKX.js +124 -0
  17. package/Build/Workers/chunk-CROU4RHL.js +138 -0
  18. package/Build/Workers/chunk-CTJCECTX.js +258 -0
  19. package/Build/Workers/chunk-DWJZFZ67.js +781 -0
  20. package/Build/Workers/chunk-EHJQEARC.js +59 -0
  21. package/Build/Workers/chunk-EVLKHUAE.js +1477 -0
  22. package/Build/Workers/chunk-FOOYJER7.js +834 -0
  23. package/Build/Workers/chunk-GLCRFDOB.js +73 -0
  24. package/Build/Workers/chunk-GPO47TW4.js +39 -0
  25. package/Build/Workers/chunk-H5Q2JKIA.js +1075 -0
  26. package/Build/Workers/chunk-HIDSEUWS.js +2041 -0
  27. package/Build/Workers/chunk-HV67ARO7.js +302 -0
  28. package/Build/Workers/chunk-IC7G4BX2.js +421 -0
  29. package/Build/Workers/chunk-IQN2LMGD.js +55 -0
  30. package/Build/Workers/chunk-J2FHYK2Z.js +55 -0
  31. package/Build/Workers/chunk-K3VEWONC.js +289 -0
  32. package/Build/Workers/chunk-KZFXE35V.js +117 -0
  33. package/Build/Workers/chunk-MG2TXIO5.js +400 -0
  34. package/Build/Workers/chunk-MRCFDEKH.js +138 -0
  35. package/Build/Workers/chunk-MYDS6HBL.js +3273 -0
  36. package/Build/Workers/chunk-OCIX2CQ7.js +305 -0
  37. package/Build/Workers/chunk-P32XMW4I.js +2716 -0
  38. package/Build/Workers/chunk-PEVZYZBQ.js +157 -0
  39. package/Build/Workers/chunk-PMDLIBEQ.js +218 -0
  40. package/Build/Workers/chunk-QDUOGCCO.js +1009 -0
  41. package/Build/Workers/chunk-QUCJGBCK.js +430 -0
  42. package/Build/Workers/chunk-RCI7BSOM.js +452 -0
  43. package/Build/Workers/chunk-SVTSC7FX.js +390 -0
  44. package/Build/Workers/chunk-TXOGSFHZ.js +77 -0
  45. package/Build/Workers/chunk-TXYJOVQK.js +629 -0
  46. package/Build/Workers/chunk-UFIT5XDI.js +1258 -0
  47. package/Build/Workers/chunk-ULLMQNFQ.js +73 -0
  48. package/Build/Workers/chunk-UM7FIUQW.js +101 -0
  49. package/Build/Workers/{package.js → chunk-UMLTOPAE.js} +13 -2
  50. package/Build/Workers/chunk-V5S5N2IS.js +8644 -0
  51. package/Build/Workers/chunk-VN2IHJKM.js +513 -0
  52. package/Build/Workers/chunk-VWSD2XV5.js +669 -0
  53. package/Build/Workers/chunk-X2KIWBTW.js +100 -0
  54. package/Build/Workers/chunk-Y24CDOJC.js +353 -0
  55. package/Build/Workers/chunk-YLMDWSXO.js +44 -0
  56. package/Build/Workers/chunk-YNZ4DMR7.js +634 -0
  57. package/Build/Workers/chunk-Z2MP3UBE.js +236 -0
  58. package/Build/Workers/combineGeometry.js +65 -15
  59. package/Build/Workers/createBoxGeometry.js +55 -10
  60. package/Build/Workers/createBoxOutlineGeometry.js +231 -310
  61. package/Build/Workers/createCircleGeometry.js +185 -202
  62. package/Build/Workers/createCircleOutlineGeometry.js +141 -155
  63. package/Build/Workers/createCoplanarPolygonGeometry.js +477 -557
  64. package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +218 -230
  65. package/Build/Workers/createCorridorGeometry.js +1163 -1307
  66. package/Build/Workers/createCorridorOutlineGeometry.js +534 -569
  67. package/Build/Workers/createCylinderGeometry.js +57 -10
  68. package/Build/Workers/createCylinderOutlineGeometry.js +224 -258
  69. package/Build/Workers/createEllipseGeometry.js +68 -12
  70. package/Build/Workers/createEllipseOutlineGeometry.js +61 -12
  71. package/Build/Workers/createEllipsoidGeometry.js +56 -10
  72. package/Build/Workers/createEllipsoidOutlineGeometry.js +58 -13
  73. package/Build/Workers/createFrustumGeometry.js +55 -10
  74. package/Build/Workers/createFrustumOutlineGeometry.js +226 -243
  75. package/Build/Workers/createGeometry.js +143 -48
  76. package/Build/Workers/createGroundPolylineGeometry.js +1484 -2012
  77. package/Build/Workers/createPlaneGeometry.js +216 -243
  78. package/Build/Workers/createPlaneOutlineGeometry.js +121 -113
  79. package/Build/Workers/createPolygonGeometry.js +1437 -1314
  80. package/Build/Workers/createPolygonOutlineGeometry.js +516 -657
  81. package/Build/Workers/createPolylineGeometry.js +471 -547
  82. package/Build/Workers/createPolylineVolumeGeometry.js +354 -384
  83. package/Build/Workers/createPolylineVolumeOutlineGeometry.js +272 -295
  84. package/Build/Workers/createRectangleGeometry.js +1128 -1331
  85. package/Build/Workers/createRectangleOutlineGeometry.js +445 -500
  86. package/Build/Workers/createSimplePolylineGeometry.js +381 -440
  87. package/Build/Workers/createSphereGeometry.js +112 -118
  88. package/Build/Workers/createSphereOutlineGeometry.js +112 -121
  89. package/Build/Workers/createTaskProcessorWorker.js +32 -127
  90. package/Build/Workers/createVectorTileClampedPolylines.js +462 -505
  91. package/Build/Workers/createVectorTileGeometries.js +377 -436
  92. package/Build/Workers/createVectorTilePoints.js +110 -77
  93. package/Build/Workers/createVectorTilePolygons.js +369 -391
  94. package/Build/Workers/createVectorTilePolylines.js +252 -244
  95. package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +543 -615
  96. package/Build/Workers/createVerticesFromHeightmap.js +2244 -2677
  97. package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +682 -904
  98. package/Build/Workers/createWallGeometry.js +459 -593
  99. package/Build/Workers/createWallOutlineGeometry.js +324 -419
  100. package/Build/Workers/decodeDraco.js +327 -347
  101. package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +2530 -3567
  102. package/Build/Workers/decodeI3S.js +765 -970
  103. package/Build/Workers/transcodeKTX2.js +3351 -1473
  104. package/Build/Workers/transferTypedArrayTest.js +3 -4
  105. package/Build/Workers/upsampleQuantizedTerrainMesh.js +748 -953
  106. package/LICENSE.md +0 -12
  107. package/Source/Core/CesiumTerrainProvider.js +1 -2
  108. package/Source/Core/Credit.js +7 -1
  109. package/Source/Core/FeatureDetection.js +9 -0
  110. package/Source/Core/GoogleMaps.js +1 -2
  111. package/Source/Core/Ion.js +1 -2
  112. package/Source/Core/KTX2Transcoder.js +7 -3
  113. package/Source/Core/PolygonGeometry.js +340 -27
  114. package/Source/Core/PolygonGeometryLibrary.js +302 -1
  115. package/Source/Core/Stereographic.js +247 -0
  116. package/Source/Core/TaskProcessor.js +185 -168
  117. package/Source/Core/Transforms.js +2 -2
  118. package/Source/Core/buildModuleUrl.js +6 -5
  119. package/Source/Core/sampleTerrain.js +43 -10
  120. package/Source/Core/sampleTerrainMostDetailed.js +27 -3
  121. package/Source/Scene/ArcGisMapService.js +1 -2
  122. package/Source/Scene/Billboard.js +7 -0
  123. package/Source/Scene/Cesium3DTilePass.js +1 -1
  124. package/Source/Scene/Cesium3DTileset.js +38 -81
  125. package/Source/Scene/CreditDisplay.js +2 -2
  126. package/Source/Scene/DracoLoader.js +26 -3
  127. package/Source/Scene/I3SDataProvider.js +0 -27
  128. package/Source/Scene/I3SDecoder.js +127 -0
  129. package/Source/Scene/I3SNode.js +32 -110
  130. package/Source/Scene/Implicit3DTileContent.js +13 -0
  131. package/Source/Scene/ImplicitTileset.js +5 -0
  132. package/Source/Scene/LabelCollection.js +3 -1
  133. package/Source/Scene/Model/I3dmLoader.js +5 -1
  134. package/Source/Scene/Model/Model.js +20 -23
  135. package/Source/Scene/OpenStreetMapImageryProvider.js +4 -1
  136. package/Source/Scene/PostProcessStageLibrary.js +3 -3
  137. package/Source/Scene/PrimitiveCollection.js +39 -0
  138. package/Source/Scene/Scene.js +3 -0
  139. package/Source/Scene/SingleTileImageryProvider.js +4 -2
  140. package/Source/ThirdParty/Workers/basis_transcoder.js +1 -1
  141. package/Source/Widget/CesiumWidget.js +2 -1
  142. package/Source/{WorkersES6 → Workers}/createGeometry.js +11 -12
  143. package/Source/{WorkersES6 → Workers}/createTaskProcessorWorker.js +43 -59
  144. package/Source/{WorkersES6 → Workers}/decodeDraco.js +19 -25
  145. package/Source/{WorkersES6 → Workers}/decodeI3S.js +18 -32
  146. package/Source/{WorkersES6 → Workers}/transcodeKTX2.js +19 -26
  147. package/Source/Workers/transferTypedArrayTest.js +0 -6
  148. package/index.d.ts +69 -35
  149. package/index.js +189 -187
  150. package/package.json +2 -1
  151. package/Build/Workers/ArcType-2d9abbbc.js +0 -37
  152. package/Build/Workers/AttributeCompression-f9f6c717.js +0 -716
  153. package/Build/Workers/AxisAlignedBoundingBox-a03420b1.js +0 -258
  154. package/Build/Workers/BoundingRectangle-32fa8a4a.js +0 -369
  155. package/Build/Workers/BoxGeometry-cd550612.js +0 -884
  156. package/Build/Workers/Check-6ede7e26.js +0 -290
  157. package/Build/Workers/Color-571a6085.js +0 -2262
  158. package/Build/Workers/ComponentDatatype-cf1fa08e.js +0 -341
  159. package/Build/Workers/CoplanarPolygonGeometryLibrary-488b1a9f.js +0 -132
  160. package/Build/Workers/CorridorGeometryLibrary-fc4ff147.js +0 -498
  161. package/Build/Workers/CylinderGeometry-bc26926d.js +0 -467
  162. package/Build/Workers/CylinderGeometryLibrary-7bf291b4.js +0 -63
  163. package/Build/Workers/EllipseGeometry-89533a10.js +0 -1304
  164. package/Build/Workers/EllipseGeometryLibrary-b0d7df17.js +0 -366
  165. package/Build/Workers/EllipseOutlineGeometry-63ff7a87.js +0 -443
  166. package/Build/Workers/EllipsoidGeodesic-5b3623dc.js +0 -520
  167. package/Build/Workers/EllipsoidGeometry-07e99d2d.js +0 -637
  168. package/Build/Workers/EllipsoidOutlineGeometry-ba5c7ee2.js +0 -454
  169. package/Build/Workers/EllipsoidRhumbLine-ef872433.js +0 -741
  170. package/Build/Workers/EllipsoidTangentPlane-65d41b3e.js +0 -373
  171. package/Build/Workers/EncodedCartesian3-57415c8a.js +0 -171
  172. package/Build/Workers/FrustumGeometry-4a7589ed.js +0 -2540
  173. package/Build/Workers/GeometryAttribute-a5b6275b.js +0 -619
  174. package/Build/Workers/GeometryAttributes-ad136444.js +0 -91
  175. package/Build/Workers/GeometryInstance-34d9e21e.js +0 -121
  176. package/Build/Workers/GeometryOffsetAttribute-9ad0019c.js +0 -16
  177. package/Build/Workers/GeometryPipeline-fa9e6ffc.js +0 -3690
  178. package/Build/Workers/IndexDatatype-2643aa47.js +0 -200
  179. package/Build/Workers/IntersectionTests-feace3da.js +0 -1836
  180. package/Build/Workers/Math-0a2ac845.js +0 -1340
  181. package/Build/Workers/Matrix2-e1298525.js +0 -7086
  182. package/Build/Workers/Matrix3-41c58dde.js +0 -4283
  183. package/Build/Workers/OrientedBoundingBox-6b94d955.js +0 -1259
  184. package/Build/Workers/Plane-4c3d403b.js +0 -309
  185. package/Build/Workers/PolygonGeometryLibrary-4ffc457d.js +0 -1074
  186. package/Build/Workers/PolygonPipeline-d5e66350.js +0 -1344
  187. package/Build/Workers/PolylinePipeline-83410f0c.js +0 -573
  188. package/Build/Workers/PolylineVolumeGeometryLibrary-290e7aec.js +0 -781
  189. package/Build/Workers/PrimitivePipeline-6081d138.js +0 -966
  190. package/Build/Workers/RectangleGeometryLibrary-986710d8.js +0 -280
  191. package/Build/Workers/RuntimeError-ef395448.js +0 -68
  192. package/Build/Workers/TerrainEncoding-528e1d68.js +0 -1227
  193. package/Build/Workers/Transforms-b527bb09.js +0 -14714
  194. package/Build/Workers/VertexFormat-030f11ff.js +0 -312
  195. package/Build/Workers/WallGeometryLibrary-faf583f8.js +0 -211
  196. package/Build/Workers/WebGLConstants-0b1ce7ba.js +0 -620
  197. package/Build/Workers/WebMercatorProjection-13ed1a6e.js +0 -151
  198. package/Build/Workers/arrayRemoveDuplicates-d2061e85.js +0 -129
  199. package/Build/Workers/cesiumWorkerBootstrapper.js +0 -1363
  200. package/Build/Workers/combine-d9581036.js +0 -82
  201. package/Build/Workers/defaultValue-fe22d8c0.js +0 -51
  202. package/Source/ThirdParty/Workers/draco_decoder_nodejs.js +0 -117
  203. package/Source/Workers/cesiumWorkerBootstrapper.js +0 -2290
  204. package/Source/Workers/package.json +0 -1
  205. /package/Source/{WorkersES6 → Workers}/combineGeometry.js +0 -0
  206. /package/Source/{WorkersES6 → Workers}/createBoxGeometry.js +0 -0
  207. /package/Source/{WorkersES6 → Workers}/createBoxOutlineGeometry.js +0 -0
  208. /package/Source/{WorkersES6 → Workers}/createCircleGeometry.js +0 -0
  209. /package/Source/{WorkersES6 → Workers}/createCircleOutlineGeometry.js +0 -0
  210. /package/Source/{WorkersES6 → Workers}/createCoplanarPolygonGeometry.js +0 -0
  211. /package/Source/{WorkersES6 → Workers}/createCoplanarPolygonOutlineGeometry.js +0 -0
  212. /package/Source/{WorkersES6 → Workers}/createCorridorGeometry.js +0 -0
  213. /package/Source/{WorkersES6 → Workers}/createCorridorOutlineGeometry.js +0 -0
  214. /package/Source/{WorkersES6 → Workers}/createCylinderGeometry.js +0 -0
  215. /package/Source/{WorkersES6 → Workers}/createCylinderOutlineGeometry.js +0 -0
  216. /package/Source/{WorkersES6 → Workers}/createEllipseGeometry.js +0 -0
  217. /package/Source/{WorkersES6 → Workers}/createEllipseOutlineGeometry.js +0 -0
  218. /package/Source/{WorkersES6 → Workers}/createEllipsoidGeometry.js +0 -0
  219. /package/Source/{WorkersES6 → Workers}/createEllipsoidOutlineGeometry.js +0 -0
  220. /package/Source/{WorkersES6 → Workers}/createFrustumGeometry.js +0 -0
  221. /package/Source/{WorkersES6 → Workers}/createFrustumOutlineGeometry.js +0 -0
  222. /package/Source/{WorkersES6 → Workers}/createGroundPolylineGeometry.js +0 -0
  223. /package/Source/{WorkersES6 → Workers}/createPlaneGeometry.js +0 -0
  224. /package/Source/{WorkersES6 → Workers}/createPlaneOutlineGeometry.js +0 -0
  225. /package/Source/{WorkersES6 → Workers}/createPolygonGeometry.js +0 -0
  226. /package/Source/{WorkersES6 → Workers}/createPolygonOutlineGeometry.js +0 -0
  227. /package/Source/{WorkersES6 → Workers}/createPolylineGeometry.js +0 -0
  228. /package/Source/{WorkersES6 → Workers}/createPolylineVolumeGeometry.js +0 -0
  229. /package/Source/{WorkersES6 → Workers}/createPolylineVolumeOutlineGeometry.js +0 -0
  230. /package/Source/{WorkersES6 → Workers}/createRectangleGeometry.js +0 -0
  231. /package/Source/{WorkersES6 → Workers}/createRectangleOutlineGeometry.js +0 -0
  232. /package/Source/{WorkersES6 → Workers}/createSimplePolylineGeometry.js +0 -0
  233. /package/Source/{WorkersES6 → Workers}/createSphereGeometry.js +0 -0
  234. /package/Source/{WorkersES6 → Workers}/createSphereOutlineGeometry.js +0 -0
  235. /package/Source/{WorkersES6 → Workers}/createVectorTileClampedPolylines.js +0 -0
  236. /package/Source/{WorkersES6 → Workers}/createVectorTileGeometries.js +0 -0
  237. /package/Source/{WorkersES6 → Workers}/createVectorTilePoints.js +0 -0
  238. /package/Source/{WorkersES6 → Workers}/createVectorTilePolygons.js +0 -0
  239. /package/Source/{WorkersES6 → Workers}/createVectorTilePolylines.js +0 -0
  240. /package/Source/{WorkersES6 → Workers}/createVerticesFromGoogleEarthEnterpriseBuffer.js +0 -0
  241. /package/Source/{WorkersES6 → Workers}/createVerticesFromHeightmap.js +0 -0
  242. /package/Source/{WorkersES6 → Workers}/createVerticesFromQuantizedTerrainMesh.js +0 -0
  243. /package/Source/{WorkersES6 → Workers}/createWallGeometry.js +0 -0
  244. /package/Source/{WorkersES6 → Workers}/createWallOutlineGeometry.js +0 -0
  245. /package/Source/{WorkersES6 → Workers}/decodeGoogleEarthEnterprisePacket.js +0 -0
  246. /package/Source/{WorkersES6 → Workers}/upsampleQuantizedTerrainMesh.js +0 -0
@@ -0,0 +1,1054 @@
1
+ /**
2
+ * @license
3
+ * Cesium - https://github.com/CesiumGS/cesium
4
+ * Version 1.110
5
+ *
6
+ * Copyright 2011-2022 Cesium Contributors
7
+ *
8
+ * Licensed under the Apache License, Version 2.0 (the "License");
9
+ * you may not use this file except in compliance with the License.
10
+ * You may obtain a copy of the License at
11
+ *
12
+ * http://www.apache.org/licenses/LICENSE-2.0
13
+ *
14
+ * Unless required by applicable law or agreed to in writing, software
15
+ * distributed under the License is distributed on an "AS IS" BASIS,
16
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ * See the License for the specific language governing permissions and
18
+ * limitations under the License.
19
+ *
20
+ * Columbus View (Pat. Pend.)
21
+ *
22
+ * Portions licensed separately.
23
+ * See https://github.com/CesiumGS/cesium/blob/main/LICENSE.md for full licensing details.
24
+ */
25
+
26
+ import {
27
+ ArcType_default
28
+ } from "./chunk-IQN2LMGD.js";
29
+ import {
30
+ GeometryPipeline_default
31
+ } from "./chunk-P32XMW4I.js";
32
+ import {
33
+ PolygonPipeline_default,
34
+ WindingOrder_default
35
+ } from "./chunk-QDUOGCCO.js";
36
+ import {
37
+ arrayRemoveDuplicates_default
38
+ } from "./chunk-X2KIWBTW.js";
39
+ import {
40
+ EllipsoidRhumbLine_default
41
+ } from "./chunk-RCI7BSOM.js";
42
+ import {
43
+ IntersectionTests_default
44
+ } from "./chunk-UFIT5XDI.js";
45
+ import {
46
+ Plane_default
47
+ } from "./chunk-6I22NWKQ.js";
48
+ import {
49
+ IndexDatatype_default
50
+ } from "./chunk-CROU4RHL.js";
51
+ import {
52
+ GeometryAttributes_default
53
+ } from "./chunk-YLMDWSXO.js";
54
+ import {
55
+ GeometryAttribute_default,
56
+ Geometry_default,
57
+ PrimitiveType_default
58
+ } from "./chunk-HV67ARO7.js";
59
+ import {
60
+ Quaternion_default
61
+ } from "./chunk-V5S5N2IS.js";
62
+ import {
63
+ Cartesian2_default
64
+ } from "./chunk-MYDS6HBL.js";
65
+ import {
66
+ ComponentDatatype_default
67
+ } from "./chunk-CTJCECTX.js";
68
+ import {
69
+ Cartesian3_default,
70
+ Cartographic_default,
71
+ Ellipsoid_default,
72
+ Matrix3_default
73
+ } from "./chunk-HIDSEUWS.js";
74
+ import {
75
+ Math_default
76
+ } from "./chunk-4HN3N5SE.js";
77
+ import {
78
+ defaultValue_default
79
+ } from "./chunk-GPO47TW4.js";
80
+ import {
81
+ defined_default
82
+ } from "./chunk-TXOGSFHZ.js";
83
+
84
+ // packages/engine/Source/Core/PolygonHierarchy.js
85
+ function PolygonHierarchy(positions, holes) {
86
+ this.positions = defined_default(positions) ? positions : [];
87
+ this.holes = defined_default(holes) ? holes : [];
88
+ }
89
+ var PolygonHierarchy_default = PolygonHierarchy;
90
+
91
+ // packages/engine/Source/Core/Queue.js
92
+ function Queue() {
93
+ this._array = [];
94
+ this._offset = 0;
95
+ this._length = 0;
96
+ }
97
+ Object.defineProperties(Queue.prototype, {
98
+ /**
99
+ * The length of the queue.
100
+ *
101
+ * @memberof Queue.prototype
102
+ *
103
+ * @type {number}
104
+ * @readonly
105
+ */
106
+ length: {
107
+ get: function() {
108
+ return this._length;
109
+ }
110
+ }
111
+ });
112
+ Queue.prototype.enqueue = function(item) {
113
+ this._array.push(item);
114
+ this._length++;
115
+ };
116
+ Queue.prototype.dequeue = function() {
117
+ if (this._length === 0) {
118
+ return void 0;
119
+ }
120
+ const array = this._array;
121
+ let offset = this._offset;
122
+ const item = array[offset];
123
+ array[offset] = void 0;
124
+ offset++;
125
+ if (offset > 10 && offset * 2 > array.length) {
126
+ this._array = array.slice(offset);
127
+ offset = 0;
128
+ }
129
+ this._offset = offset;
130
+ this._length--;
131
+ return item;
132
+ };
133
+ Queue.prototype.peek = function() {
134
+ if (this._length === 0) {
135
+ return void 0;
136
+ }
137
+ return this._array[this._offset];
138
+ };
139
+ Queue.prototype.contains = function(item) {
140
+ return this._array.indexOf(item) !== -1;
141
+ };
142
+ Queue.prototype.clear = function() {
143
+ this._array.length = this._offset = this._length = 0;
144
+ };
145
+ Queue.prototype.sort = function(compareFunction) {
146
+ if (this._offset > 0) {
147
+ this._array = this._array.slice(this._offset);
148
+ this._offset = 0;
149
+ }
150
+ this._array.sort(compareFunction);
151
+ };
152
+ var Queue_default = Queue;
153
+
154
+ // packages/engine/Source/Core/PolygonGeometryLibrary.js
155
+ var PolygonGeometryLibrary = {};
156
+ PolygonGeometryLibrary.computeHierarchyPackedLength = function(polygonHierarchy, CartesianX) {
157
+ let numComponents = 0;
158
+ const stack = [polygonHierarchy];
159
+ while (stack.length > 0) {
160
+ const hierarchy = stack.pop();
161
+ if (!defined_default(hierarchy)) {
162
+ continue;
163
+ }
164
+ numComponents += 2;
165
+ const positions = hierarchy.positions;
166
+ const holes = hierarchy.holes;
167
+ if (defined_default(positions) && positions.length > 0) {
168
+ numComponents += positions.length * CartesianX.packedLength;
169
+ }
170
+ if (defined_default(holes)) {
171
+ const length = holes.length;
172
+ for (let i = 0; i < length; ++i) {
173
+ stack.push(holes[i]);
174
+ }
175
+ }
176
+ }
177
+ return numComponents;
178
+ };
179
+ PolygonGeometryLibrary.packPolygonHierarchy = function(polygonHierarchy, array, startingIndex, CartesianX) {
180
+ const stack = [polygonHierarchy];
181
+ while (stack.length > 0) {
182
+ const hierarchy = stack.pop();
183
+ if (!defined_default(hierarchy)) {
184
+ continue;
185
+ }
186
+ const positions = hierarchy.positions;
187
+ const holes = hierarchy.holes;
188
+ array[startingIndex++] = defined_default(positions) ? positions.length : 0;
189
+ array[startingIndex++] = defined_default(holes) ? holes.length : 0;
190
+ if (defined_default(positions)) {
191
+ const positionsLength = positions.length;
192
+ for (let i = 0; i < positionsLength; ++i, startingIndex += CartesianX.packedLength) {
193
+ CartesianX.pack(positions[i], array, startingIndex);
194
+ }
195
+ }
196
+ if (defined_default(holes)) {
197
+ const holesLength = holes.length;
198
+ for (let j = 0; j < holesLength; ++j) {
199
+ stack.push(holes[j]);
200
+ }
201
+ }
202
+ }
203
+ return startingIndex;
204
+ };
205
+ PolygonGeometryLibrary.unpackPolygonHierarchy = function(array, startingIndex, CartesianX) {
206
+ const positionsLength = array[startingIndex++];
207
+ const holesLength = array[startingIndex++];
208
+ const positions = new Array(positionsLength);
209
+ const holes = holesLength > 0 ? new Array(holesLength) : void 0;
210
+ for (let i = 0; i < positionsLength; ++i, startingIndex += CartesianX.packedLength) {
211
+ positions[i] = CartesianX.unpack(array, startingIndex);
212
+ }
213
+ for (let j = 0; j < holesLength; ++j) {
214
+ holes[j] = PolygonGeometryLibrary.unpackPolygonHierarchy(
215
+ array,
216
+ startingIndex,
217
+ CartesianX
218
+ );
219
+ startingIndex = holes[j].startingIndex;
220
+ delete holes[j].startingIndex;
221
+ }
222
+ return {
223
+ positions,
224
+ holes,
225
+ startingIndex
226
+ };
227
+ };
228
+ var distance2DScratch = new Cartesian2_default();
229
+ function getPointAtDistance2D(p0, p1, distance, length) {
230
+ Cartesian2_default.subtract(p1, p0, distance2DScratch);
231
+ Cartesian2_default.multiplyByScalar(
232
+ distance2DScratch,
233
+ distance / length,
234
+ distance2DScratch
235
+ );
236
+ Cartesian2_default.add(p0, distance2DScratch, distance2DScratch);
237
+ return [distance2DScratch.x, distance2DScratch.y];
238
+ }
239
+ var distanceScratch = new Cartesian3_default();
240
+ function getPointAtDistance(p0, p1, distance, length) {
241
+ Cartesian3_default.subtract(p1, p0, distanceScratch);
242
+ Cartesian3_default.multiplyByScalar(
243
+ distanceScratch,
244
+ distance / length,
245
+ distanceScratch
246
+ );
247
+ Cartesian3_default.add(p0, distanceScratch, distanceScratch);
248
+ return [distanceScratch.x, distanceScratch.y, distanceScratch.z];
249
+ }
250
+ PolygonGeometryLibrary.subdivideLineCount = function(p0, p1, minDistance) {
251
+ const distance = Cartesian3_default.distance(p0, p1);
252
+ const n = distance / minDistance;
253
+ const countDivide = Math.max(0, Math.ceil(Math_default.log2(n)));
254
+ return Math.pow(2, countDivide);
255
+ };
256
+ var scratchCartographic0 = new Cartographic_default();
257
+ var scratchCartographic1 = new Cartographic_default();
258
+ var scratchCartographic2 = new Cartographic_default();
259
+ var scratchCartesian0 = new Cartesian3_default();
260
+ var scratchRhumbLine = new EllipsoidRhumbLine_default();
261
+ PolygonGeometryLibrary.subdivideRhumbLineCount = function(ellipsoid, p0, p1, minDistance) {
262
+ const c0 = ellipsoid.cartesianToCartographic(p0, scratchCartographic0);
263
+ const c1 = ellipsoid.cartesianToCartographic(p1, scratchCartographic1);
264
+ const rhumb = new EllipsoidRhumbLine_default(c0, c1, ellipsoid);
265
+ const n = rhumb.surfaceDistance / minDistance;
266
+ const countDivide = Math.max(0, Math.ceil(Math_default.log2(n)));
267
+ return Math.pow(2, countDivide);
268
+ };
269
+ PolygonGeometryLibrary.subdivideTexcoordLine = function(t0, t1, p0, p1, minDistance, result) {
270
+ const subdivisions = PolygonGeometryLibrary.subdivideLineCount(
271
+ p0,
272
+ p1,
273
+ minDistance
274
+ );
275
+ const length2D = Cartesian2_default.distance(t0, t1);
276
+ const distanceBetweenCoords = length2D / subdivisions;
277
+ const texcoords = result;
278
+ texcoords.length = subdivisions * 2;
279
+ let index = 0;
280
+ for (let i = 0; i < subdivisions; i++) {
281
+ const t = getPointAtDistance2D(t0, t1, i * distanceBetweenCoords, length2D);
282
+ texcoords[index++] = t[0];
283
+ texcoords[index++] = t[1];
284
+ }
285
+ return texcoords;
286
+ };
287
+ PolygonGeometryLibrary.subdivideLine = function(p0, p1, minDistance, result) {
288
+ const numVertices = PolygonGeometryLibrary.subdivideLineCount(
289
+ p0,
290
+ p1,
291
+ minDistance
292
+ );
293
+ const length = Cartesian3_default.distance(p0, p1);
294
+ const distanceBetweenVertices = length / numVertices;
295
+ if (!defined_default(result)) {
296
+ result = [];
297
+ }
298
+ const positions = result;
299
+ positions.length = numVertices * 3;
300
+ let index = 0;
301
+ for (let i = 0; i < numVertices; i++) {
302
+ const p = getPointAtDistance(p0, p1, i * distanceBetweenVertices, length);
303
+ positions[index++] = p[0];
304
+ positions[index++] = p[1];
305
+ positions[index++] = p[2];
306
+ }
307
+ return positions;
308
+ };
309
+ PolygonGeometryLibrary.subdivideTexcoordRhumbLine = function(t0, t1, ellipsoid, p0, p1, minDistance, result) {
310
+ const c0 = ellipsoid.cartesianToCartographic(p0, scratchCartographic0);
311
+ const c1 = ellipsoid.cartesianToCartographic(p1, scratchCartographic1);
312
+ scratchRhumbLine.setEndPoints(c0, c1);
313
+ const n = scratchRhumbLine.surfaceDistance / minDistance;
314
+ const countDivide = Math.max(0, Math.ceil(Math_default.log2(n)));
315
+ const subdivisions = Math.pow(2, countDivide);
316
+ const length2D = Cartesian2_default.distance(t0, t1);
317
+ const distanceBetweenCoords = length2D / subdivisions;
318
+ const texcoords = result;
319
+ texcoords.length = subdivisions * 2;
320
+ let index = 0;
321
+ for (let i = 0; i < subdivisions; i++) {
322
+ const t = getPointAtDistance2D(t0, t1, i * distanceBetweenCoords, length2D);
323
+ texcoords[index++] = t[0];
324
+ texcoords[index++] = t[1];
325
+ }
326
+ return texcoords;
327
+ };
328
+ PolygonGeometryLibrary.subdivideRhumbLine = function(ellipsoid, p0, p1, minDistance, result) {
329
+ const c0 = ellipsoid.cartesianToCartographic(p0, scratchCartographic0);
330
+ const c1 = ellipsoid.cartesianToCartographic(p1, scratchCartographic1);
331
+ const rhumb = new EllipsoidRhumbLine_default(c0, c1, ellipsoid);
332
+ const n = rhumb.surfaceDistance / minDistance;
333
+ const countDivide = Math.max(0, Math.ceil(Math_default.log2(n)));
334
+ const numVertices = Math.pow(2, countDivide);
335
+ const distanceBetweenVertices = rhumb.surfaceDistance / numVertices;
336
+ if (!defined_default(result)) {
337
+ result = [];
338
+ }
339
+ const positions = result;
340
+ positions.length = numVertices * 3;
341
+ let index = 0;
342
+ for (let i = 0; i < numVertices; i++) {
343
+ const c = rhumb.interpolateUsingSurfaceDistance(
344
+ i * distanceBetweenVertices,
345
+ scratchCartographic2
346
+ );
347
+ const p = ellipsoid.cartographicToCartesian(c, scratchCartesian0);
348
+ positions[index++] = p.x;
349
+ positions[index++] = p.y;
350
+ positions[index++] = p.z;
351
+ }
352
+ return positions;
353
+ };
354
+ var scaleToGeodeticHeightN1 = new Cartesian3_default();
355
+ var scaleToGeodeticHeightN2 = new Cartesian3_default();
356
+ var scaleToGeodeticHeightP1 = new Cartesian3_default();
357
+ var scaleToGeodeticHeightP2 = new Cartesian3_default();
358
+ PolygonGeometryLibrary.scaleToGeodeticHeightExtruded = function(geometry, maxHeight, minHeight, ellipsoid, perPositionHeight) {
359
+ ellipsoid = defaultValue_default(ellipsoid, Ellipsoid_default.WGS84);
360
+ const n1 = scaleToGeodeticHeightN1;
361
+ let n2 = scaleToGeodeticHeightN2;
362
+ const p = scaleToGeodeticHeightP1;
363
+ let p2 = scaleToGeodeticHeightP2;
364
+ if (defined_default(geometry) && defined_default(geometry.attributes) && defined_default(geometry.attributes.position)) {
365
+ const positions = geometry.attributes.position.values;
366
+ const length = positions.length / 2;
367
+ for (let i = 0; i < length; i += 3) {
368
+ Cartesian3_default.fromArray(positions, i, p);
369
+ ellipsoid.geodeticSurfaceNormal(p, n1);
370
+ p2 = ellipsoid.scaleToGeodeticSurface(p, p2);
371
+ n2 = Cartesian3_default.multiplyByScalar(n1, minHeight, n2);
372
+ n2 = Cartesian3_default.add(p2, n2, n2);
373
+ positions[i + length] = n2.x;
374
+ positions[i + 1 + length] = n2.y;
375
+ positions[i + 2 + length] = n2.z;
376
+ if (perPositionHeight) {
377
+ p2 = Cartesian3_default.clone(p, p2);
378
+ }
379
+ n2 = Cartesian3_default.multiplyByScalar(n1, maxHeight, n2);
380
+ n2 = Cartesian3_default.add(p2, n2, n2);
381
+ positions[i] = n2.x;
382
+ positions[i + 1] = n2.y;
383
+ positions[i + 2] = n2.z;
384
+ }
385
+ }
386
+ return geometry;
387
+ };
388
+ PolygonGeometryLibrary.polygonOutlinesFromHierarchy = function(polygonHierarchy, scaleToEllipsoidSurface, ellipsoid) {
389
+ const polygons = [];
390
+ const queue = new Queue_default();
391
+ queue.enqueue(polygonHierarchy);
392
+ let i;
393
+ let j;
394
+ let length;
395
+ while (queue.length !== 0) {
396
+ const outerNode = queue.dequeue();
397
+ let outerRing = outerNode.positions;
398
+ if (scaleToEllipsoidSurface) {
399
+ length = outerRing.length;
400
+ for (i = 0; i < length; i++) {
401
+ ellipsoid.scaleToGeodeticSurface(outerRing[i], outerRing[i]);
402
+ }
403
+ }
404
+ outerRing = arrayRemoveDuplicates_default(
405
+ outerRing,
406
+ Cartesian3_default.equalsEpsilon,
407
+ true
408
+ );
409
+ if (outerRing.length < 3) {
410
+ continue;
411
+ }
412
+ const numChildren = outerNode.holes ? outerNode.holes.length : 0;
413
+ for (i = 0; i < numChildren; i++) {
414
+ const hole = outerNode.holes[i];
415
+ let holePositions = hole.positions;
416
+ if (scaleToEllipsoidSurface) {
417
+ length = holePositions.length;
418
+ for (j = 0; j < length; ++j) {
419
+ ellipsoid.scaleToGeodeticSurface(holePositions[j], holePositions[j]);
420
+ }
421
+ }
422
+ holePositions = arrayRemoveDuplicates_default(
423
+ holePositions,
424
+ Cartesian3_default.equalsEpsilon,
425
+ true
426
+ );
427
+ if (holePositions.length < 3) {
428
+ continue;
429
+ }
430
+ polygons.push(holePositions);
431
+ let numGrandchildren = 0;
432
+ if (defined_default(hole.holes)) {
433
+ numGrandchildren = hole.holes.length;
434
+ }
435
+ for (j = 0; j < numGrandchildren; j++) {
436
+ queue.enqueue(hole.holes[j]);
437
+ }
438
+ }
439
+ polygons.push(outerRing);
440
+ }
441
+ return polygons;
442
+ };
443
+ var scratchRhumbIntersection = new Cartographic_default();
444
+ function computeEquatorIntersectionRhumb(start, end, ellipsoid) {
445
+ const c0 = ellipsoid.cartesianToCartographic(start, scratchCartographic0);
446
+ const c1 = ellipsoid.cartesianToCartographic(end, scratchCartographic1);
447
+ if (Math.sign(c0.latitude) === Math.sign(c1.latitude)) {
448
+ return;
449
+ }
450
+ scratchRhumbLine.setEndPoints(c0, c1);
451
+ const intersection = scratchRhumbLine.findIntersectionWithLatitude(
452
+ 0,
453
+ scratchRhumbIntersection
454
+ );
455
+ if (!defined_default(intersection)) {
456
+ return;
457
+ }
458
+ let minLongitude = Math.min(c0.longitude, c1.longitude);
459
+ let maxLongitude = Math.max(c0.longitude, c1.longitude);
460
+ if (Math.abs(maxLongitude - minLongitude) > Math_default.PI) {
461
+ const swap = minLongitude;
462
+ minLongitude = maxLongitude;
463
+ maxLongitude = swap;
464
+ }
465
+ if (intersection.longitude < minLongitude || intersection.longitude > maxLongitude) {
466
+ return;
467
+ }
468
+ return ellipsoid.cartographicToCartesian(intersection);
469
+ }
470
+ function computeEquatorIntersection(start, end, ellipsoid, arcType) {
471
+ if (arcType === ArcType_default.RHUMB) {
472
+ return computeEquatorIntersectionRhumb(start, end, ellipsoid);
473
+ }
474
+ const intersection = IntersectionTests_default.lineSegmentPlane(
475
+ start,
476
+ end,
477
+ Plane_default.ORIGIN_XY_PLANE
478
+ );
479
+ if (!defined_default(intersection)) {
480
+ return;
481
+ }
482
+ return ellipsoid.scaleToGeodeticSurface(intersection, intersection);
483
+ }
484
+ var scratchCartographic = new Cartographic_default();
485
+ function computeEdgesOnPlane(positions, ellipsoid, arcType) {
486
+ const edgesOnPlane = [];
487
+ let startPoint, endPoint, type, next, intersection, i = 0;
488
+ while (i < positions.length) {
489
+ startPoint = positions[i];
490
+ endPoint = positions[(i + 1) % positions.length];
491
+ type = Math_default.sign(startPoint.z);
492
+ next = Math_default.sign(endPoint.z);
493
+ const getLongitude = (position) => {
494
+ const cartographic = ellipsoid.cartesianToCartographic(
495
+ position,
496
+ scratchCartographic
497
+ );
498
+ return cartographic.longitude;
499
+ };
500
+ if (type === 0) {
501
+ edgesOnPlane.push({
502
+ position: i,
503
+ type,
504
+ visited: false,
505
+ next,
506
+ theta: getLongitude(startPoint)
507
+ });
508
+ } else if (next !== 0) {
509
+ intersection = computeEquatorIntersection(
510
+ startPoint,
511
+ endPoint,
512
+ ellipsoid,
513
+ arcType
514
+ );
515
+ ++i;
516
+ if (!defined_default(intersection)) {
517
+ continue;
518
+ }
519
+ positions.splice(i, 0, intersection);
520
+ edgesOnPlane.push({
521
+ position: i,
522
+ type,
523
+ visited: false,
524
+ next,
525
+ theta: getLongitude(intersection)
526
+ });
527
+ }
528
+ ++i;
529
+ }
530
+ return edgesOnPlane;
531
+ }
532
+ function wirePolygon(polygons, polygonIndex, positions, edgesOnPlane, toDelete, startIndex, abovePlane) {
533
+ const polygon = [];
534
+ let i = startIndex;
535
+ const getMatchingEdge = (i2) => (edge) => edge.position === i2;
536
+ const polygonsToWire = [];
537
+ do {
538
+ const position = positions[i];
539
+ polygon.push(position);
540
+ const edgeIndex = edgesOnPlane.findIndex(getMatchingEdge(i));
541
+ const edge = edgesOnPlane[edgeIndex];
542
+ if (!defined_default(edge)) {
543
+ ++i;
544
+ continue;
545
+ }
546
+ const { visited: hasBeenVisited, type, next } = edge;
547
+ edge.visited = true;
548
+ if (type === 0) {
549
+ if (next === 0) {
550
+ const previousEdge = edgesOnPlane[edgeIndex - (abovePlane ? 1 : -1)];
551
+ if (previousEdge?.position === i + 1) {
552
+ previousEdge.visited = true;
553
+ } else {
554
+ ++i;
555
+ continue;
556
+ }
557
+ }
558
+ if (!hasBeenVisited && abovePlane && next > 0 || startIndex === i && !abovePlane && next < 0) {
559
+ ++i;
560
+ continue;
561
+ }
562
+ }
563
+ const followEdge = abovePlane ? type >= 0 : type <= 0;
564
+ if (!followEdge) {
565
+ ++i;
566
+ continue;
567
+ }
568
+ if (!hasBeenVisited) {
569
+ polygonsToWire.push(i);
570
+ }
571
+ const nextEdgeIndex = edgeIndex + (abovePlane ? 1 : -1);
572
+ const nextEdge = edgesOnPlane[nextEdgeIndex];
573
+ if (!defined_default(nextEdge)) {
574
+ ++i;
575
+ continue;
576
+ }
577
+ i = nextEdge.position;
578
+ } while (i < positions.length && i >= 0 && i !== startIndex && polygon.length < positions.length);
579
+ polygons.splice(polygonIndex, toDelete, polygon);
580
+ for (const index of polygonsToWire) {
581
+ polygonIndex = wirePolygon(
582
+ polygons,
583
+ ++polygonIndex,
584
+ positions,
585
+ edgesOnPlane,
586
+ 0,
587
+ index,
588
+ !abovePlane
589
+ );
590
+ }
591
+ return polygonIndex;
592
+ }
593
+ PolygonGeometryLibrary.splitPolygonsOnEquator = function(outerRings, ellipsoid, arcType, result) {
594
+ if (!defined_default(result)) {
595
+ result = [];
596
+ }
597
+ result.splice(0, 0, ...outerRings);
598
+ result.length = outerRings.length;
599
+ let currentPolygon = 0;
600
+ while (currentPolygon < result.length) {
601
+ const outerRing = result[currentPolygon];
602
+ const positions = outerRing.slice();
603
+ if (outerRing.length < 3) {
604
+ result[currentPolygon] = positions;
605
+ ++currentPolygon;
606
+ continue;
607
+ }
608
+ const edgesOnPlane = computeEdgesOnPlane(positions, ellipsoid, arcType);
609
+ if (positions.length === outerRing.length || edgesOnPlane.length <= 1) {
610
+ result[currentPolygon] = positions;
611
+ ++currentPolygon;
612
+ continue;
613
+ }
614
+ edgesOnPlane.sort((a, b) => {
615
+ return a.theta - b.theta;
616
+ });
617
+ const north = positions[0].z >= 0;
618
+ currentPolygon = wirePolygon(
619
+ result,
620
+ currentPolygon,
621
+ positions,
622
+ edgesOnPlane,
623
+ 1,
624
+ 0,
625
+ north
626
+ );
627
+ }
628
+ return result;
629
+ };
630
+ PolygonGeometryLibrary.polygonsFromHierarchy = function(polygonHierarchy, keepDuplicates, projectPointsTo2D, scaleToEllipsoidSurface, ellipsoid, splitPolygons) {
631
+ const hierarchy = [];
632
+ const polygons = [];
633
+ const queue = new Queue_default();
634
+ queue.enqueue(polygonHierarchy);
635
+ let split = defined_default(splitPolygons);
636
+ while (queue.length !== 0) {
637
+ const outerNode = queue.dequeue();
638
+ let outerRing = outerNode.positions;
639
+ const holes = outerNode.holes;
640
+ let i;
641
+ let length;
642
+ if (scaleToEllipsoidSurface) {
643
+ length = outerRing.length;
644
+ for (i = 0; i < length; i++) {
645
+ ellipsoid.scaleToGeodeticSurface(outerRing[i], outerRing[i]);
646
+ }
647
+ }
648
+ if (!keepDuplicates) {
649
+ outerRing = arrayRemoveDuplicates_default(
650
+ outerRing,
651
+ Cartesian3_default.equalsEpsilon,
652
+ true
653
+ );
654
+ }
655
+ if (outerRing.length < 3) {
656
+ continue;
657
+ }
658
+ let positions2D = projectPointsTo2D(outerRing);
659
+ if (!defined_default(positions2D)) {
660
+ continue;
661
+ }
662
+ const holeIndices = [];
663
+ let originalWindingOrder = PolygonPipeline_default.computeWindingOrder2D(
664
+ positions2D
665
+ );
666
+ if (originalWindingOrder === WindingOrder_default.CLOCKWISE) {
667
+ positions2D.reverse();
668
+ outerRing = outerRing.slice().reverse();
669
+ }
670
+ if (split) {
671
+ split = false;
672
+ let polygons2 = [outerRing];
673
+ polygons2 = splitPolygons(polygons2, polygons2);
674
+ if (polygons2.length > 1) {
675
+ for (const positions2 of polygons2) {
676
+ queue.enqueue(new PolygonHierarchy_default(positions2, holes));
677
+ }
678
+ continue;
679
+ }
680
+ }
681
+ let positions = outerRing.slice();
682
+ const numChildren = defined_default(holes) ? holes.length : 0;
683
+ const polygonHoles = [];
684
+ let j;
685
+ for (i = 0; i < numChildren; i++) {
686
+ const hole = holes[i];
687
+ let holePositions = hole.positions;
688
+ if (scaleToEllipsoidSurface) {
689
+ length = holePositions.length;
690
+ for (j = 0; j < length; ++j) {
691
+ ellipsoid.scaleToGeodeticSurface(holePositions[j], holePositions[j]);
692
+ }
693
+ }
694
+ if (!keepDuplicates) {
695
+ holePositions = arrayRemoveDuplicates_default(
696
+ holePositions,
697
+ Cartesian3_default.equalsEpsilon,
698
+ true
699
+ );
700
+ }
701
+ if (holePositions.length < 3) {
702
+ continue;
703
+ }
704
+ const holePositions2D = projectPointsTo2D(holePositions);
705
+ if (!defined_default(holePositions2D)) {
706
+ continue;
707
+ }
708
+ originalWindingOrder = PolygonPipeline_default.computeWindingOrder2D(
709
+ holePositions2D
710
+ );
711
+ if (originalWindingOrder === WindingOrder_default.CLOCKWISE) {
712
+ holePositions2D.reverse();
713
+ holePositions = holePositions.slice().reverse();
714
+ }
715
+ polygonHoles.push(holePositions);
716
+ holeIndices.push(positions.length);
717
+ positions = positions.concat(holePositions);
718
+ positions2D = positions2D.concat(holePositions2D);
719
+ let numGrandchildren = 0;
720
+ if (defined_default(hole.holes)) {
721
+ numGrandchildren = hole.holes.length;
722
+ }
723
+ for (j = 0; j < numGrandchildren; j++) {
724
+ queue.enqueue(hole.holes[j]);
725
+ }
726
+ }
727
+ hierarchy.push({
728
+ outerRing,
729
+ holes: polygonHoles
730
+ });
731
+ polygons.push({
732
+ positions,
733
+ positions2D,
734
+ holes: holeIndices
735
+ });
736
+ }
737
+ return {
738
+ hierarchy,
739
+ polygons
740
+ };
741
+ };
742
+ var computeBoundingRectangleCartesian2 = new Cartesian2_default();
743
+ var computeBoundingRectangleCartesian3 = new Cartesian3_default();
744
+ var computeBoundingRectangleQuaternion = new Quaternion_default();
745
+ var computeBoundingRectangleMatrix3 = new Matrix3_default();
746
+ PolygonGeometryLibrary.computeBoundingRectangle = function(planeNormal, projectPointTo2D, positions, angle, result) {
747
+ const rotation = Quaternion_default.fromAxisAngle(
748
+ planeNormal,
749
+ angle,
750
+ computeBoundingRectangleQuaternion
751
+ );
752
+ const textureMatrix = Matrix3_default.fromQuaternion(
753
+ rotation,
754
+ computeBoundingRectangleMatrix3
755
+ );
756
+ let minX = Number.POSITIVE_INFINITY;
757
+ let maxX = Number.NEGATIVE_INFINITY;
758
+ let minY = Number.POSITIVE_INFINITY;
759
+ let maxY = Number.NEGATIVE_INFINITY;
760
+ const length = positions.length;
761
+ for (let i = 0; i < length; ++i) {
762
+ const p = Cartesian3_default.clone(
763
+ positions[i],
764
+ computeBoundingRectangleCartesian3
765
+ );
766
+ Matrix3_default.multiplyByVector(textureMatrix, p, p);
767
+ const st = projectPointTo2D(p, computeBoundingRectangleCartesian2);
768
+ if (defined_default(st)) {
769
+ minX = Math.min(minX, st.x);
770
+ maxX = Math.max(maxX, st.x);
771
+ minY = Math.min(minY, st.y);
772
+ maxY = Math.max(maxY, st.y);
773
+ }
774
+ }
775
+ result.x = minX;
776
+ result.y = minY;
777
+ result.width = maxX - minX;
778
+ result.height = maxY - minY;
779
+ return result;
780
+ };
781
+ PolygonGeometryLibrary.createGeometryFromPositions = function(ellipsoid, polygon, textureCoordinates, granularity, perPositionHeight, vertexFormat, arcType) {
782
+ let indices = PolygonPipeline_default.triangulate(polygon.positions2D, polygon.holes);
783
+ if (indices.length < 3) {
784
+ indices = [0, 1, 2];
785
+ }
786
+ const positions = polygon.positions;
787
+ const hasTexcoords = defined_default(textureCoordinates);
788
+ const texcoords = hasTexcoords ? textureCoordinates.positions : void 0;
789
+ if (perPositionHeight) {
790
+ const length = positions.length;
791
+ const flattenedPositions = new Array(length * 3);
792
+ let index = 0;
793
+ for (let i = 0; i < length; i++) {
794
+ const p = positions[i];
795
+ flattenedPositions[index++] = p.x;
796
+ flattenedPositions[index++] = p.y;
797
+ flattenedPositions[index++] = p.z;
798
+ }
799
+ const geometryOptions = {
800
+ attributes: {
801
+ position: new GeometryAttribute_default({
802
+ componentDatatype: ComponentDatatype_default.DOUBLE,
803
+ componentsPerAttribute: 3,
804
+ values: flattenedPositions
805
+ })
806
+ },
807
+ indices,
808
+ primitiveType: PrimitiveType_default.TRIANGLES
809
+ };
810
+ if (hasTexcoords) {
811
+ geometryOptions.attributes.st = new GeometryAttribute_default({
812
+ componentDatatype: ComponentDatatype_default.FLOAT,
813
+ componentsPerAttribute: 2,
814
+ values: Cartesian2_default.packArray(texcoords)
815
+ });
816
+ }
817
+ const geometry = new Geometry_default(geometryOptions);
818
+ if (vertexFormat.normal) {
819
+ return GeometryPipeline_default.computeNormal(geometry);
820
+ }
821
+ return geometry;
822
+ }
823
+ if (arcType === ArcType_default.GEODESIC) {
824
+ return PolygonPipeline_default.computeSubdivision(
825
+ ellipsoid,
826
+ positions,
827
+ indices,
828
+ texcoords,
829
+ granularity
830
+ );
831
+ } else if (arcType === ArcType_default.RHUMB) {
832
+ return PolygonPipeline_default.computeRhumbLineSubdivision(
833
+ ellipsoid,
834
+ positions,
835
+ indices,
836
+ texcoords,
837
+ granularity
838
+ );
839
+ }
840
+ };
841
+ var computeWallTexcoordsSubdivided = [];
842
+ var computeWallIndicesSubdivided = [];
843
+ var p1Scratch = new Cartesian3_default();
844
+ var p2Scratch = new Cartesian3_default();
845
+ PolygonGeometryLibrary.computeWallGeometry = function(positions, textureCoordinates, ellipsoid, granularity, perPositionHeight, arcType) {
846
+ let edgePositions;
847
+ let topEdgeLength;
848
+ let i;
849
+ let p1;
850
+ let p2;
851
+ let t1;
852
+ let t2;
853
+ let edgeTexcoords;
854
+ let topEdgeTexcoordLength;
855
+ let length = positions.length;
856
+ let index = 0;
857
+ let textureIndex = 0;
858
+ const hasTexcoords = defined_default(textureCoordinates);
859
+ const texcoords = hasTexcoords ? textureCoordinates.positions : void 0;
860
+ if (!perPositionHeight) {
861
+ const minDistance = Math_default.chordLength(
862
+ granularity,
863
+ ellipsoid.maximumRadius
864
+ );
865
+ let numVertices = 0;
866
+ if (arcType === ArcType_default.GEODESIC) {
867
+ for (i = 0; i < length; i++) {
868
+ numVertices += PolygonGeometryLibrary.subdivideLineCount(
869
+ positions[i],
870
+ positions[(i + 1) % length],
871
+ minDistance
872
+ );
873
+ }
874
+ } else if (arcType === ArcType_default.RHUMB) {
875
+ for (i = 0; i < length; i++) {
876
+ numVertices += PolygonGeometryLibrary.subdivideRhumbLineCount(
877
+ ellipsoid,
878
+ positions[i],
879
+ positions[(i + 1) % length],
880
+ minDistance
881
+ );
882
+ }
883
+ }
884
+ topEdgeLength = (numVertices + length) * 3;
885
+ edgePositions = new Array(topEdgeLength * 2);
886
+ if (hasTexcoords) {
887
+ topEdgeTexcoordLength = (numVertices + length) * 2;
888
+ edgeTexcoords = new Array(topEdgeTexcoordLength * 2);
889
+ }
890
+ for (i = 0; i < length; i++) {
891
+ p1 = positions[i];
892
+ p2 = positions[(i + 1) % length];
893
+ let tempPositions;
894
+ let tempTexcoords;
895
+ if (hasTexcoords) {
896
+ t1 = texcoords[i];
897
+ t2 = texcoords[(i + 1) % length];
898
+ }
899
+ if (arcType === ArcType_default.GEODESIC) {
900
+ tempPositions = PolygonGeometryLibrary.subdivideLine(
901
+ p1,
902
+ p2,
903
+ minDistance,
904
+ computeWallIndicesSubdivided
905
+ );
906
+ if (hasTexcoords) {
907
+ tempTexcoords = PolygonGeometryLibrary.subdivideTexcoordLine(
908
+ t1,
909
+ t2,
910
+ p1,
911
+ p2,
912
+ minDistance,
913
+ computeWallTexcoordsSubdivided
914
+ );
915
+ }
916
+ } else if (arcType === ArcType_default.RHUMB) {
917
+ tempPositions = PolygonGeometryLibrary.subdivideRhumbLine(
918
+ ellipsoid,
919
+ p1,
920
+ p2,
921
+ minDistance,
922
+ computeWallIndicesSubdivided
923
+ );
924
+ if (hasTexcoords) {
925
+ tempTexcoords = PolygonGeometryLibrary.subdivideTexcoordRhumbLine(
926
+ t1,
927
+ t2,
928
+ ellipsoid,
929
+ p1,
930
+ p2,
931
+ minDistance,
932
+ computeWallTexcoordsSubdivided
933
+ );
934
+ }
935
+ }
936
+ const tempPositionsLength = tempPositions.length;
937
+ for (let j = 0; j < tempPositionsLength; ++j, ++index) {
938
+ edgePositions[index] = tempPositions[j];
939
+ edgePositions[index + topEdgeLength] = tempPositions[j];
940
+ }
941
+ edgePositions[index] = p2.x;
942
+ edgePositions[index + topEdgeLength] = p2.x;
943
+ ++index;
944
+ edgePositions[index] = p2.y;
945
+ edgePositions[index + topEdgeLength] = p2.y;
946
+ ++index;
947
+ edgePositions[index] = p2.z;
948
+ edgePositions[index + topEdgeLength] = p2.z;
949
+ ++index;
950
+ if (hasTexcoords) {
951
+ const tempTexcoordsLength = tempTexcoords.length;
952
+ for (let k = 0; k < tempTexcoordsLength; ++k, ++textureIndex) {
953
+ edgeTexcoords[textureIndex] = tempTexcoords[k];
954
+ edgeTexcoords[textureIndex + topEdgeTexcoordLength] = tempTexcoords[k];
955
+ }
956
+ edgeTexcoords[textureIndex] = t2.x;
957
+ edgeTexcoords[textureIndex + topEdgeTexcoordLength] = t2.x;
958
+ ++textureIndex;
959
+ edgeTexcoords[textureIndex] = t2.y;
960
+ edgeTexcoords[textureIndex + topEdgeTexcoordLength] = t2.y;
961
+ ++textureIndex;
962
+ }
963
+ }
964
+ } else {
965
+ topEdgeLength = length * 3 * 2;
966
+ edgePositions = new Array(topEdgeLength * 2);
967
+ if (hasTexcoords) {
968
+ topEdgeTexcoordLength = length * 2 * 2;
969
+ edgeTexcoords = new Array(topEdgeTexcoordLength * 2);
970
+ }
971
+ for (i = 0; i < length; i++) {
972
+ p1 = positions[i];
973
+ p2 = positions[(i + 1) % length];
974
+ edgePositions[index] = edgePositions[index + topEdgeLength] = p1.x;
975
+ ++index;
976
+ edgePositions[index] = edgePositions[index + topEdgeLength] = p1.y;
977
+ ++index;
978
+ edgePositions[index] = edgePositions[index + topEdgeLength] = p1.z;
979
+ ++index;
980
+ edgePositions[index] = edgePositions[index + topEdgeLength] = p2.x;
981
+ ++index;
982
+ edgePositions[index] = edgePositions[index + topEdgeLength] = p2.y;
983
+ ++index;
984
+ edgePositions[index] = edgePositions[index + topEdgeLength] = p2.z;
985
+ ++index;
986
+ if (hasTexcoords) {
987
+ t1 = texcoords[i];
988
+ t2 = texcoords[(i + 1) % length];
989
+ edgeTexcoords[textureIndex] = edgeTexcoords[textureIndex + topEdgeTexcoordLength] = t1.x;
990
+ ++textureIndex;
991
+ edgeTexcoords[textureIndex] = edgeTexcoords[textureIndex + topEdgeTexcoordLength] = t1.y;
992
+ ++textureIndex;
993
+ edgeTexcoords[textureIndex] = edgeTexcoords[textureIndex + topEdgeTexcoordLength] = t2.x;
994
+ ++textureIndex;
995
+ edgeTexcoords[textureIndex] = edgeTexcoords[textureIndex + topEdgeTexcoordLength] = t2.y;
996
+ ++textureIndex;
997
+ }
998
+ }
999
+ }
1000
+ length = edgePositions.length;
1001
+ const indices = IndexDatatype_default.createTypedArray(
1002
+ length / 3,
1003
+ length - positions.length * 6
1004
+ );
1005
+ let edgeIndex = 0;
1006
+ length /= 6;
1007
+ for (i = 0; i < length; i++) {
1008
+ const UL = i;
1009
+ const UR = UL + 1;
1010
+ const LL = UL + length;
1011
+ const LR = LL + 1;
1012
+ p1 = Cartesian3_default.fromArray(edgePositions, UL * 3, p1Scratch);
1013
+ p2 = Cartesian3_default.fromArray(edgePositions, UR * 3, p2Scratch);
1014
+ if (Cartesian3_default.equalsEpsilon(
1015
+ p1,
1016
+ p2,
1017
+ Math_default.EPSILON10,
1018
+ Math_default.EPSILON10
1019
+ )) {
1020
+ continue;
1021
+ }
1022
+ indices[edgeIndex++] = UL;
1023
+ indices[edgeIndex++] = LL;
1024
+ indices[edgeIndex++] = UR;
1025
+ indices[edgeIndex++] = UR;
1026
+ indices[edgeIndex++] = LL;
1027
+ indices[edgeIndex++] = LR;
1028
+ }
1029
+ const geometryOptions = {
1030
+ attributes: new GeometryAttributes_default({
1031
+ position: new GeometryAttribute_default({
1032
+ componentDatatype: ComponentDatatype_default.DOUBLE,
1033
+ componentsPerAttribute: 3,
1034
+ values: edgePositions
1035
+ })
1036
+ }),
1037
+ indices,
1038
+ primitiveType: PrimitiveType_default.TRIANGLES
1039
+ };
1040
+ if (hasTexcoords) {
1041
+ geometryOptions.attributes.st = new GeometryAttribute_default({
1042
+ componentDatatype: ComponentDatatype_default.FLOAT,
1043
+ componentsPerAttribute: 2,
1044
+ values: edgeTexcoords
1045
+ });
1046
+ }
1047
+ const geometry = new Geometry_default(geometryOptions);
1048
+ return geometry;
1049
+ };
1050
+ var PolygonGeometryLibrary_default = PolygonGeometryLibrary;
1051
+
1052
+ export {
1053
+ PolygonGeometryLibrary_default
1054
+ };