deeptwins-cesium-engine 0.1.2 → 0.1.4

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 (219) hide show
  1. package/Build/Workers/chunk-2HWLF3FT.js +837 -0
  2. package/Build/Workers/chunk-2KXMJ5XS.js +3792 -0
  3. package/Build/Workers/chunk-2NPCLB3H.js +56 -0
  4. package/Build/Workers/chunk-2ZHQTIBH.js +1483 -0
  5. package/Build/Workers/chunk-3GLYOW63.js +352 -0
  6. package/Build/Workers/chunk-3L22KMPU.js +219 -0
  7. package/Build/Workers/chunk-3Q6V2B2I.js +73 -0
  8. package/Build/Workers/chunk-3QOKKRIG.js +387 -0
  9. package/Build/Workers/chunk-44YZFGRH.js +1800 -0
  10. package/Build/Workers/chunk-45VV4SBO.js +2342 -0
  11. package/Build/Workers/chunk-4EJ4AA2S.js +368 -0
  12. package/Build/Workers/chunk-4IJFHUL6.js +414 -0
  13. package/Build/Workers/chunk-4K3V5CGW.js +454 -0
  14. package/Build/Workers/chunk-4M4QL6KJ.js +305 -0
  15. package/Build/Workers/chunk-4YNRIEQ6.js +288 -0
  16. package/Build/Workers/chunk-56CVDPH5.js +352 -0
  17. package/Build/Workers/chunk-5CTAAPXH.js +1483 -0
  18. package/Build/Workers/chunk-5ISZ6NJD.js +102 -0
  19. package/Build/Workers/chunk-5SDHYIOS.js +56 -0
  20. package/Build/Workers/chunk-66TGUMCU.js +2719 -0
  21. package/Build/Workers/chunk-6EJMTDQJ.js +163 -0
  22. package/Build/Workers/chunk-6VWXYSMH.js +959 -0
  23. package/Build/Workers/chunk-6VZ7VB2Q.js +241 -0
  24. package/Build/Workers/chunk-7AMRE57Q.js +301 -0
  25. package/Build/Workers/chunk-7DH6C33H.js +398 -0
  26. package/Build/Workers/chunk-7VUS3FVE.js +38 -0
  27. package/Build/Workers/chunk-7Y3ZA6H3.js +198 -0
  28. package/Build/Workers/chunk-A6BMHZNA.js +38 -0
  29. package/Build/Workers/chunk-A7XY2MN7.js +171 -0
  30. package/Build/Workers/chunk-AC7ND63S.js +57 -0
  31. package/Build/Workers/chunk-AHCZ757M.js +9230 -0
  32. package/Build/Workers/chunk-ANOA7E7F.js +56 -0
  33. package/Build/Workers/chunk-AYO5HHV6.js +789 -0
  34. package/Build/Workers/chunk-BE2N56VZ.js +1344 -0
  35. package/Build/Workers/chunk-BR3BPM64.js +9230 -0
  36. package/Build/Workers/chunk-BVMRWGOK.js +455 -0
  37. package/Build/Workers/chunk-BXEL2NX7.js +455 -0
  38. package/Build/Workers/chunk-C5BO2JCG.js +278 -0
  39. package/Build/Workers/chunk-CIRQNZVR.js +301 -0
  40. package/Build/Workers/chunk-CM67CQME.js +305 -0
  41. package/Build/Workers/chunk-D3QIW4DH.js +630 -0
  42. package/Build/Workers/chunk-E5W7QIGZ.js +511 -0
  43. package/Build/Workers/chunk-E6CYGUJI.js +1054 -0
  44. package/Build/Workers/chunk-EIZ23IOX.js +414 -0
  45. package/Build/Workers/chunk-EIZJUMQY.js +101 -0
  46. package/Build/Workers/chunk-EXTMZJXB.js +82 -0
  47. package/Build/Workers/chunk-EYOOSIBW.js +682 -0
  48. package/Build/Workers/chunk-F37WADVC.js +1054 -0
  49. package/Build/Workers/chunk-FIWPJFHX.js +101 -0
  50. package/Build/Workers/chunk-FM32TNGT.js +198 -0
  51. package/Build/Workers/chunk-FOMYIEIB.js +476 -0
  52. package/Build/Workers/chunk-FWYDLSVQ.js +97 -0
  53. package/Build/Workers/chunk-HGZR6CZF.js +1067 -0
  54. package/Build/Workers/chunk-HIXHDABG.js +288 -0
  55. package/Build/Workers/chunk-HMCCZZWE.js +97 -0
  56. package/Build/Workers/chunk-HW54WHGM.js +2719 -0
  57. package/Build/Workers/chunk-IHYAI7GF.js +973 -0
  58. package/Build/Workers/chunk-INLQ7LVK.js +837 -0
  59. package/Build/Workers/chunk-IQMESTCB.js +124 -0
  60. package/Build/Workers/chunk-J4PISUNT.js +2342 -0
  61. package/Build/Workers/chunk-JSWU557I.js +693 -0
  62. package/Build/Workers/chunk-KHONDSQ7.js +693 -0
  63. package/Build/Workers/chunk-KLUL2SOE.js +352 -0
  64. package/Build/Workers/chunk-KMBLKQCC.js +1992 -0
  65. package/Build/Workers/chunk-KOTWWQN7.js +171 -0
  66. package/Build/Workers/chunk-KWV6ZTF4.js +163 -0
  67. package/Build/Workers/chunk-LSEFPQHG.js +476 -0
  68. package/Build/Workers/chunk-M66X4O24.js +44 -0
  69. package/Build/Workers/chunk-M6IXKBC7.js +1992 -0
  70. package/Build/Workers/chunk-MFUC3D5C.js +162 -0
  71. package/Build/Workers/chunk-MRMNELAH.js +82 -0
  72. package/Build/Workers/chunk-N3NUA5H2.js +3792 -0
  73. package/Build/Workers/chunk-NFB2NXJN.js +138 -0
  74. package/Build/Workers/chunk-NQAXBK4K.js +789 -0
  75. package/Build/Workers/chunk-NUGQWV6S.js +352 -0
  76. package/Build/Workers/chunk-O7S7WL7K.js +278 -0
  77. package/Build/Workers/chunk-ODZYB26X.js +1287 -0
  78. package/Build/Workers/chunk-OEHJY463.js +3201 -0
  79. package/Build/Workers/chunk-OMMRNMXF.js +44 -0
  80. package/Build/Workers/chunk-OZ3CQDO3.js +138 -0
  81. package/Build/Workers/chunk-PNXBG64I.js +219 -0
  82. package/Build/Workers/chunk-PYR35GK4.js +973 -0
  83. package/Build/Workers/chunk-Q4CXGW74.js +57 -0
  84. package/Build/Workers/chunk-QGISLKCW.js +147 -0
  85. package/Build/Workers/chunk-QQHVOJW6.js +497 -0
  86. package/Build/Workers/chunk-QWCMMRJW.js +58 -0
  87. package/Build/Workers/chunk-RDEZCHF4.js +398 -0
  88. package/Build/Workers/chunk-SJTE7FVN.js +778 -0
  89. package/Build/Workers/chunk-SM5T67LR.js +162 -0
  90. package/Build/Workers/chunk-T27NNXEU.js +58 -0
  91. package/Build/Workers/chunk-T4J5BWUO.js +511 -0
  92. package/Build/Workers/chunk-T6JS4BRN.js +140 -0
  93. package/Build/Workers/chunk-UH6DUQBW.js +140 -0
  94. package/Build/Workers/chunk-UJAH6XKF.js +73 -0
  95. package/Build/Workers/chunk-UKSTJ2PH.js +454 -0
  96. package/Build/Workers/chunk-UQCDCCZ7.js +368 -0
  97. package/Build/Workers/chunk-UXIFNEA3.js +1287 -0
  98. package/Build/Workers/chunk-UXJ6J5L7.js +56 -0
  99. package/Build/Workers/chunk-V4VUAZXI.js +1800 -0
  100. package/Build/Workers/chunk-VQH2YXO2.js +497 -0
  101. package/Build/Workers/chunk-VXKCLSE4.js +241 -0
  102. package/Build/Workers/chunk-W3U6YBEI.js +280 -0
  103. package/Build/Workers/chunk-W75ZVFKP.js +778 -0
  104. package/Build/Workers/chunk-WCDFJYFB.js +1344 -0
  105. package/Build/Workers/chunk-WME5M6W3.js +630 -0
  106. package/Build/Workers/chunk-XDQBQB64.js +1067 -0
  107. package/Build/Workers/chunk-Y6HOIWE5.js +959 -0
  108. package/Build/Workers/chunk-YEMC2ZOR.js +147 -0
  109. package/Build/Workers/chunk-YWNF3TPE.js +682 -0
  110. package/Build/Workers/chunk-Z55VGWJP.js +280 -0
  111. package/Build/Workers/chunk-Z5YWP24C.js +124 -0
  112. package/Build/Workers/chunk-ZHXCWUJB.js +387 -0
  113. package/Build/Workers/chunk-ZIMPUF2I.js +102 -0
  114. package/Build/Workers/chunk-ZKDWYQKC.js +3201 -0
  115. package/Build/Workers/combineGeometry.js +24 -22
  116. package/Build/Workers/createBoxGeometry.js +18 -16
  117. package/Build/Workers/createBoxOutlineGeometry.js +23 -25
  118. package/Build/Workers/createCircleGeometry.js +29 -27
  119. package/Build/Workers/createCircleOutlineGeometry.js +22 -20
  120. package/Build/Workers/createCoplanarPolygonGeometry.js +43 -43
  121. package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +37 -35
  122. package/Build/Workers/createCorridorGeometry.js +46 -49
  123. package/Build/Workers/createCorridorOutlineGeometry.js +40 -43
  124. package/Build/Workers/createCylinderGeometry.js +20 -18
  125. package/Build/Workers/createCylinderOutlineGeometry.js +27 -25
  126. package/Build/Workers/createEllipseGeometry.js +28 -25
  127. package/Build/Workers/createEllipseOutlineGeometry.js +21 -18
  128. package/Build/Workers/createEllipsoidGeometry.js +19 -17
  129. package/Build/Workers/createEllipsoidOutlineGeometry.js +18 -16
  130. package/Build/Workers/createFrustumGeometry.js +18 -16
  131. package/Build/Workers/createFrustumOutlineGeometry.js +21 -21
  132. package/Build/Workers/createGeometry.js +31 -26
  133. package/Build/Workers/createGroundPolylineGeometry.js +188 -135
  134. package/Build/Workers/createPlaneGeometry.js +22 -21
  135. package/Build/Workers/createPlaneOutlineGeometry.js +15 -13
  136. package/Build/Workers/createPolygonGeometry.js +51 -52
  137. package/Build/Workers/createPolygonOutlineGeometry.js +43 -44
  138. package/Build/Workers/createPolylineGeometry.js +37 -40
  139. package/Build/Workers/createPolylineVolumeGeometry.js +41 -44
  140. package/Build/Workers/createPolylineVolumeOutlineGeometry.js +36 -39
  141. package/Build/Workers/createRectangleGeometry.js +47 -53
  142. package/Build/Workers/createRectangleOutlineGeometry.js +32 -33
  143. package/Build/Workers/createSimplePolylineGeometry.js +33 -34
  144. package/Build/Workers/createSphereGeometry.js +20 -20
  145. package/Build/Workers/createSphereOutlineGeometry.js +19 -19
  146. package/Build/Workers/createTaskProcessorWorker.js +3 -3
  147. package/Build/Workers/createVectorTileClampedPolylines.js +16 -14
  148. package/Build/Workers/createVectorTileGeometries.js +24 -22
  149. package/Build/Workers/createVectorTilePoints.js +15 -13
  150. package/Build/Workers/createVectorTilePolygons.js +24 -21
  151. package/Build/Workers/createVectorTilePolylines.js +16 -14
  152. package/Build/Workers/createVerticesFromCesium3DTilesTerrain.js +25 -25
  153. package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +29 -27
  154. package/Build/Workers/createVerticesFromHeightmap.js +42 -63
  155. package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +26 -280
  156. package/Build/Workers/createWallGeometry.js +35 -36
  157. package/Build/Workers/createWallOutlineGeometry.js +33 -34
  158. package/Build/Workers/decodeDraco.js +10 -11
  159. package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +5 -5
  160. package/Build/Workers/decodeI3S.js +16 -20
  161. package/Build/Workers/gaussianSplatSorter.js +4 -4
  162. package/Build/Workers/gaussianSplatTextureGenerator.js +4 -4
  163. package/Build/Workers/incrementallyBuildTerrainPicker.js +20 -12
  164. package/Build/Workers/transcodeKTX2.js +42 -14
  165. package/Build/Workers/transferTypedArrayTest.js +1 -1
  166. package/Build/Workers/upsampleQuantizedTerrainMesh.js +24 -21
  167. package/Build/Workers/upsampleVerticesFromCesium3DTilesTerrain.js +25 -25
  168. package/Source/Shaders/BillboardCollectionFS.js +85 -81
  169. package/Source/Shaders/BillboardCollectionVS.js +60 -118
  170. package/Source/Shaders/Builtin/Constants/passCesium3DTile.js +1 -1
  171. package/Source/Shaders/Builtin/Constants/passCesium3DTileClassification.js +1 -1
  172. package/Source/Shaders/Builtin/Constants/passCesium3DTileClassificationIgnoreShow.js +1 -1
  173. package/Source/Shaders/Builtin/Constants/passCesium3DTileEdges.js +12 -0
  174. package/Source/Shaders/Builtin/Constants/passCesium3DTileEdgesDirect.js +11 -0
  175. package/Source/Shaders/Builtin/Constants/passGaussianSplats.js +11 -0
  176. package/Source/Shaders/Builtin/Constants/passOpaque.js +1 -1
  177. package/Source/Shaders/Builtin/Constants/passOverlay.js +1 -1
  178. package/Source/Shaders/Builtin/Constants/passTranslucent.js +1 -1
  179. package/Source/Shaders/Builtin/Constants/passVoxels.js +1 -1
  180. package/Source/Shaders/Builtin/CzmBuiltins.js +12 -0
  181. package/Source/Shaders/Builtin/Functions/columbusViewMorph.js +8 -1
  182. package/Source/Shaders/Builtin/Functions/computeTextureTransform.js +25 -0
  183. package/Source/Shaders/Builtin/Functions/decodeRGB8.js +24 -0
  184. package/Source/Shaders/Builtin/Functions/modelToWindowCoordinates.js +2 -1
  185. package/Source/Shaders/Builtin/Functions/unpackTexture.js +37 -0
  186. package/Source/Shaders/Builtin/Functions/windowToEyeCoordinates.js +0 -1
  187. package/Source/Shaders/EllipsoidVS.js +4 -4
  188. package/Source/Shaders/FXAA3_11.js +2 -0
  189. package/Source/Shaders/GlobeFS.js +22 -0
  190. package/Source/Shaders/GlobeVS.js +3 -2
  191. package/Source/Shaders/Model/MaterialStageFS.js +50 -20
  192. package/Source/Shaders/Model/MetadataStageFS.js +2 -1
  193. package/Source/Shaders/Model/MetadataStageVS.js +2 -1
  194. package/Source/Shaders/Model/ModelFS.js +32 -2
  195. package/Source/Shaders/Model/ModelVS.js +15 -1
  196. package/Source/Shaders/Model/PointCloudStylingStageVS.js +2 -1
  197. package/Source/Shaders/Model/PrimitiveOutlineStageFS.js +0 -1
  198. package/Source/Shaders/PointPrimitiveCollectionVS.js +8 -39
  199. package/Source/Shaders/PolygonSignedDistanceFS.js +64 -33
  200. package/Source/Shaders/PolylineCommon.js +1 -1
  201. package/Source/Shaders/ShadowVolumeAppearanceFS.js +7 -15
  202. package/Source/Shaders/SkyAtmosphereVS.js +2 -1
  203. package/Source/Shaders/Voxels/IntersectBox.js +20 -33
  204. package/Source/Shaders/Voxels/IntersectCylinder.js +28 -32
  205. package/Source/Shaders/Voxels/IntersectDepth.js +10 -6
  206. package/Source/Shaders/Voxels/IntersectEllipsoid.js +12 -20
  207. package/Source/Shaders/Voxels/IntersectLongitude.js +21 -9
  208. package/Source/Shaders/Voxels/Intersection.js +3 -5
  209. package/Source/Shaders/Voxels/IntersectionUtils.js +2 -1
  210. package/Source/Shaders/Voxels/Megatexture.js +15 -83
  211. package/Source/Shaders/Voxels/Octree.js +53 -61
  212. package/Source/Shaders/Voxels/VoxelFS.js +67 -52
  213. package/Source/Shaders/Voxels/VoxelUtils.js +0 -19
  214. package/index.js +346 -261
  215. package/package.json +1 -1
  216. package/Source/Shaders/Voxels/IntersectClippingPlanes.js +0 -80
  217. package/Source/Shaders/Voxels/convertUvToBox.js +0 -46
  218. package/Source/Shaders/Voxels/convertUvToCylinder.js +0 -101
  219. package/Source/Shaders/Voxels/convertUvToEllipsoid.js +0 -141
@@ -0,0 +1,1287 @@
1
+ /**
2
+ * @license
3
+ * Cesium - https://github.com/CesiumGS/cesium
4
+ * Version 0.1.3
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
+ Intersect_default
28
+ } from "./chunk-5SDHYIOS.js";
29
+ import {
30
+ Rectangle_default
31
+ } from "./chunk-AHCZ757M.js";
32
+ import {
33
+ Matrix4_default
34
+ } from "./chunk-ZKDWYQKC.js";
35
+ import {
36
+ Cartographic_default,
37
+ Ellipsoid_default
38
+ } from "./chunk-KMBLKQCC.js";
39
+ import {
40
+ Cartesian3_default,
41
+ Matrix3_default
42
+ } from "./chunk-45VV4SBO.js";
43
+ import {
44
+ Math_default
45
+ } from "./chunk-QQHVOJW6.js";
46
+ import {
47
+ Check_default,
48
+ DeveloperError_default
49
+ } from "./chunk-6EJMTDQJ.js";
50
+ import {
51
+ defined_default
52
+ } from "./chunk-EXTMZJXB.js";
53
+
54
+ // packages/engine/Source/Core/GeographicProjection.js
55
+ var GeographicProjection = class {
56
+ /**
57
+ * @param {Ellipsoid} [ellipsoid=Ellipsoid.default] The ellipsoid.
58
+ */
59
+ constructor(ellipsoid) {
60
+ this._ellipsoid = ellipsoid ?? Ellipsoid_default.default;
61
+ this._semimajorAxis = this._ellipsoid.maximumRadius;
62
+ this._oneOverSemimajorAxis = 1 / this._semimajorAxis;
63
+ }
64
+ /**
65
+ * Gets the {@link Ellipsoid}.
66
+ *
67
+ * @type {Ellipsoid}
68
+ * @readonly
69
+ */
70
+ get ellipsoid() {
71
+ return this._ellipsoid;
72
+ }
73
+ /**
74
+ * Projects a set of {@link Cartographic} coordinates, in radians, to map coordinates, in meters.
75
+ * X and Y are the longitude and latitude, respectively, multiplied by the maximum radius of the
76
+ * ellipsoid. Z is the unmodified height.
77
+ *
78
+ * @param {Cartographic} cartographic The coordinates to project.
79
+ * @param {Cartesian3} [result] An instance into which to copy the result. If this parameter is
80
+ * undefined, a new instance is created and returned.
81
+ * @returns {Cartesian3} The projected coordinates. If the result parameter is not undefined, the
82
+ * coordinates are copied there and that instance is returned. Otherwise, a new instance is
83
+ * created and returned.
84
+ */
85
+ project(cartographic, result) {
86
+ const semimajorAxis = this._semimajorAxis;
87
+ const x = cartographic.longitude * semimajorAxis;
88
+ const y = cartographic.latitude * semimajorAxis;
89
+ const z = cartographic.height;
90
+ if (!defined_default(result)) {
91
+ return new Cartesian3_default(x, y, z);
92
+ }
93
+ result.x = x;
94
+ result.y = y;
95
+ result.z = z;
96
+ return result;
97
+ }
98
+ /**
99
+ * Unprojects a set of projected {@link Cartesian3} coordinates, in meters, to {@link Cartographic}
100
+ * coordinates, in radians. Longitude and Latitude are the X and Y coordinates, respectively,
101
+ * divided by the maximum radius of the ellipsoid. Height is the unmodified Z coordinate.
102
+ *
103
+ * @param {Cartesian3} cartesian The Cartesian position to unproject with height (z) in meters.
104
+ * @param {Cartographic} [result] An instance into which to copy the result. If this parameter is
105
+ * undefined, a new instance is created and returned.
106
+ * @returns {Cartographic} The unprojected coordinates. If the result parameter is not undefined, the
107
+ * coordinates are copied there and that instance is returned. Otherwise, a new instance is
108
+ * created and returned.
109
+ */
110
+ unproject(cartesian, result) {
111
+ if (!defined_default(cartesian)) {
112
+ throw new DeveloperError_default("cartesian is required");
113
+ }
114
+ const oneOverEarthSemimajorAxis = this._oneOverSemimajorAxis;
115
+ const longitude = cartesian.x * oneOverEarthSemimajorAxis;
116
+ const latitude = cartesian.y * oneOverEarthSemimajorAxis;
117
+ const height = cartesian.z;
118
+ if (!defined_default(result)) {
119
+ return new Cartographic_default(longitude, latitude, height);
120
+ }
121
+ result.longitude = longitude;
122
+ result.latitude = latitude;
123
+ result.height = height;
124
+ return result;
125
+ }
126
+ };
127
+ var GeographicProjection_default = GeographicProjection;
128
+
129
+ // packages/engine/Source/Core/Interval.js
130
+ function Interval(start, stop) {
131
+ this.start = start ?? 0;
132
+ this.stop = stop ?? 0;
133
+ }
134
+ var Interval_default = Interval;
135
+
136
+ // packages/engine/Source/Core/BoundingSphere.js
137
+ var BoundingSphere = class _BoundingSphere {
138
+ /**
139
+ * @param {Cartesian3} [center=Cartesian3.ZERO] The center of the bounding sphere.
140
+ * @param {number} [radius=0.0] The radius of the bounding sphere.
141
+ */
142
+ constructor(center, radius) {
143
+ this.center = Cartesian3_default.clone(center ?? Cartesian3_default.ZERO);
144
+ this.radius = radius ?? 0;
145
+ }
146
+ /**
147
+ * Computes a tight-fitting bounding sphere enclosing a list of 3D Cartesian points.
148
+ * The bounding sphere is computed by running two algorithms, a naive algorithm and
149
+ * Ritter's algorithm. The smaller of the two spheres is used to ensure a tight fit.
150
+ *
151
+ * @param {Cartesian3[]} [positions] An array of points that the bounding sphere will enclose. Each point must have <code>x</code>, <code>y</code>, and <code>z</code> properties.
152
+ * @param {BoundingSphere} [result] The object onto which to store the result.
153
+ * @returns {BoundingSphere} The modified result parameter or a new BoundingSphere instance if one was not provided.
154
+ *
155
+ * @see {@link http://help.agi.com/AGIComponents/html/BlogBoundingSphere.htm|Bounding Sphere computation article}
156
+ */
157
+ static fromPoints(positions, result) {
158
+ if (!defined_default(result)) {
159
+ result = new _BoundingSphere();
160
+ }
161
+ if (!defined_default(positions) || positions.length === 0) {
162
+ result.center = Cartesian3_default.clone(Cartesian3_default.ZERO, result.center);
163
+ result.radius = 0;
164
+ return result;
165
+ }
166
+ const currentPos = Cartesian3_default.clone(positions[0], fromPointsCurrentPos);
167
+ const xMin = Cartesian3_default.clone(currentPos, fromPointsXMin);
168
+ const yMin = Cartesian3_default.clone(currentPos, fromPointsYMin);
169
+ const zMin = Cartesian3_default.clone(currentPos, fromPointsZMin);
170
+ const xMax = Cartesian3_default.clone(currentPos, fromPointsXMax);
171
+ const yMax = Cartesian3_default.clone(currentPos, fromPointsYMax);
172
+ const zMax = Cartesian3_default.clone(currentPos, fromPointsZMax);
173
+ const numPositions = positions.length;
174
+ let i;
175
+ for (i = 1; i < numPositions; i++) {
176
+ Cartesian3_default.clone(positions[i], currentPos);
177
+ const x = currentPos.x;
178
+ const y = currentPos.y;
179
+ const z = currentPos.z;
180
+ if (x < xMin.x) {
181
+ Cartesian3_default.clone(currentPos, xMin);
182
+ }
183
+ if (x > xMax.x) {
184
+ Cartesian3_default.clone(currentPos, xMax);
185
+ }
186
+ if (y < yMin.y) {
187
+ Cartesian3_default.clone(currentPos, yMin);
188
+ }
189
+ if (y > yMax.y) {
190
+ Cartesian3_default.clone(currentPos, yMax);
191
+ }
192
+ if (z < zMin.z) {
193
+ Cartesian3_default.clone(currentPos, zMin);
194
+ }
195
+ if (z > zMax.z) {
196
+ Cartesian3_default.clone(currentPos, zMax);
197
+ }
198
+ }
199
+ const xSpan = Cartesian3_default.magnitudeSquared(
200
+ Cartesian3_default.subtract(xMax, xMin, fromPointsScratch)
201
+ );
202
+ const ySpan = Cartesian3_default.magnitudeSquared(
203
+ Cartesian3_default.subtract(yMax, yMin, fromPointsScratch)
204
+ );
205
+ const zSpan = Cartesian3_default.magnitudeSquared(
206
+ Cartesian3_default.subtract(zMax, zMin, fromPointsScratch)
207
+ );
208
+ let diameter1 = xMin;
209
+ let diameter2 = xMax;
210
+ let maxSpan = xSpan;
211
+ if (ySpan > maxSpan) {
212
+ maxSpan = ySpan;
213
+ diameter1 = yMin;
214
+ diameter2 = yMax;
215
+ }
216
+ if (zSpan > maxSpan) {
217
+ maxSpan = zSpan;
218
+ diameter1 = zMin;
219
+ diameter2 = zMax;
220
+ }
221
+ const ritterCenter = fromPointsRitterCenter;
222
+ ritterCenter.x = (diameter1.x + diameter2.x) * 0.5;
223
+ ritterCenter.y = (diameter1.y + diameter2.y) * 0.5;
224
+ ritterCenter.z = (diameter1.z + diameter2.z) * 0.5;
225
+ let radiusSquared = Cartesian3_default.magnitudeSquared(
226
+ Cartesian3_default.subtract(diameter2, ritterCenter, fromPointsScratch)
227
+ );
228
+ let ritterRadius = Math.sqrt(radiusSquared);
229
+ const minBoxPt = fromPointsMinBoxPt;
230
+ minBoxPt.x = xMin.x;
231
+ minBoxPt.y = yMin.y;
232
+ minBoxPt.z = zMin.z;
233
+ const maxBoxPt = fromPointsMaxBoxPt;
234
+ maxBoxPt.x = xMax.x;
235
+ maxBoxPt.y = yMax.y;
236
+ maxBoxPt.z = zMax.z;
237
+ const naiveCenter = Cartesian3_default.midpoint(
238
+ minBoxPt,
239
+ maxBoxPt,
240
+ fromPointsNaiveCenterScratch
241
+ );
242
+ let naiveRadius = 0;
243
+ for (i = 0; i < numPositions; i++) {
244
+ Cartesian3_default.clone(positions[i], currentPos);
245
+ const r = Cartesian3_default.magnitude(
246
+ Cartesian3_default.subtract(currentPos, naiveCenter, fromPointsScratch)
247
+ );
248
+ if (r > naiveRadius) {
249
+ naiveRadius = r;
250
+ }
251
+ const oldCenterToPointSquared = Cartesian3_default.magnitudeSquared(
252
+ Cartesian3_default.subtract(currentPos, ritterCenter, fromPointsScratch)
253
+ );
254
+ if (oldCenterToPointSquared > radiusSquared) {
255
+ const oldCenterToPoint = Math.sqrt(oldCenterToPointSquared);
256
+ ritterRadius = (ritterRadius + oldCenterToPoint) * 0.5;
257
+ radiusSquared = ritterRadius * ritterRadius;
258
+ const oldToNew = oldCenterToPoint - ritterRadius;
259
+ ritterCenter.x = (ritterRadius * ritterCenter.x + oldToNew * currentPos.x) / oldCenterToPoint;
260
+ ritterCenter.y = (ritterRadius * ritterCenter.y + oldToNew * currentPos.y) / oldCenterToPoint;
261
+ ritterCenter.z = (ritterRadius * ritterCenter.z + oldToNew * currentPos.z) / oldCenterToPoint;
262
+ }
263
+ }
264
+ if (ritterRadius < naiveRadius) {
265
+ Cartesian3_default.clone(ritterCenter, result.center);
266
+ result.radius = ritterRadius;
267
+ } else {
268
+ Cartesian3_default.clone(naiveCenter, result.center);
269
+ result.radius = naiveRadius;
270
+ }
271
+ return result;
272
+ }
273
+ /**
274
+ * Computes a bounding sphere from a rectangle projected in 2D.
275
+ *
276
+ * @param {Rectangle} [rectangle] The rectangle around which to create a bounding sphere.
277
+ * @param {MapProjection} [projection=GeographicProjection] The projection used to project the rectangle into 2D.
278
+ * @param {BoundingSphere} [result] The object onto which to store the result.
279
+ * @returns {BoundingSphere} The modified result parameter or a new BoundingSphere instance if none was provided.
280
+ */
281
+ static fromRectangle2D(rectangle, projection, result) {
282
+ return _BoundingSphere.fromRectangleWithHeights2D(
283
+ rectangle,
284
+ projection,
285
+ 0,
286
+ 0,
287
+ result
288
+ );
289
+ }
290
+ /**
291
+ * Computes a bounding sphere from a rectangle projected in 2D. The bounding sphere accounts for the
292
+ * object's minimum and maximum heights over the rectangle.
293
+ *
294
+ * @param {Rectangle} [rectangle] The rectangle around which to create a bounding sphere.
295
+ * @param {MapProjection} [projection=GeographicProjection] The projection used to project the rectangle into 2D.
296
+ * @param {number} [minimumHeight=0.0] The minimum height over the rectangle.
297
+ * @param {number} [maximumHeight=0.0] The maximum height over the rectangle.
298
+ * @param {BoundingSphere} [result] The object onto which to store the result.
299
+ * @returns {BoundingSphere} The modified result parameter or a new BoundingSphere instance if none was provided.
300
+ */
301
+ static fromRectangleWithHeights2D(rectangle, projection, minimumHeight, maximumHeight, result) {
302
+ if (!defined_default(result)) {
303
+ result = new _BoundingSphere();
304
+ }
305
+ if (!defined_default(rectangle)) {
306
+ result.center = Cartesian3_default.clone(Cartesian3_default.ZERO, result.center);
307
+ result.radius = 0;
308
+ return result;
309
+ }
310
+ defaultProjection._ellipsoid = Ellipsoid_default.default;
311
+ projection = projection ?? defaultProjection;
312
+ Rectangle_default.southwest(rectangle, fromRectangle2DSouthwest);
313
+ fromRectangle2DSouthwest.height = minimumHeight;
314
+ Rectangle_default.northeast(rectangle, fromRectangle2DNortheast);
315
+ fromRectangle2DNortheast.height = maximumHeight;
316
+ const lowerLeft = projection.project(
317
+ fromRectangle2DSouthwest,
318
+ fromRectangle2DLowerLeft
319
+ );
320
+ const upperRight = projection.project(
321
+ fromRectangle2DNortheast,
322
+ fromRectangle2DUpperRight
323
+ );
324
+ const width = upperRight.x - lowerLeft.x;
325
+ const height = upperRight.y - lowerLeft.y;
326
+ const elevation = upperRight.z - lowerLeft.z;
327
+ result.radius = Math.sqrt(width * width + height * height + elevation * elevation) * 0.5;
328
+ const center = result.center;
329
+ center.x = lowerLeft.x + width * 0.5;
330
+ center.y = lowerLeft.y + height * 0.5;
331
+ center.z = lowerLeft.z + elevation * 0.5;
332
+ return result;
333
+ }
334
+ /**
335
+ * Computes a bounding sphere from a rectangle in 3D. The bounding sphere is created using a subsample of points
336
+ * on the ellipsoid and contained in the rectangle. It may not be accurate for all rectangles on all types of ellipsoids.
337
+ *
338
+ * @param {Rectangle} [rectangle] The valid rectangle used to create a bounding sphere.
339
+ * @param {Ellipsoid} [ellipsoid=Ellipsoid.default] The ellipsoid used to determine positions of the rectangle.
340
+ * @param {number} [surfaceHeight=0.0] The height above the surface of the ellipsoid.
341
+ * @param {BoundingSphere} [result] The object onto which to store the result.
342
+ * @returns {BoundingSphere} The modified result parameter or a new BoundingSphere instance if none was provided.
343
+ */
344
+ static fromRectangle3D(rectangle, ellipsoid, surfaceHeight, result) {
345
+ ellipsoid = ellipsoid ?? Ellipsoid_default.default;
346
+ surfaceHeight = surfaceHeight ?? 0;
347
+ if (!defined_default(result)) {
348
+ result = new _BoundingSphere();
349
+ }
350
+ if (!defined_default(rectangle)) {
351
+ result.center = Cartesian3_default.clone(Cartesian3_default.ZERO, result.center);
352
+ result.radius = 0;
353
+ return result;
354
+ }
355
+ const positions = Rectangle_default.subsample(
356
+ rectangle,
357
+ ellipsoid,
358
+ surfaceHeight,
359
+ fromRectangle3DScratch
360
+ );
361
+ return _BoundingSphere.fromPoints(positions, result);
362
+ }
363
+ /**
364
+ * Computes a tight-fitting bounding sphere enclosing a list of 3D points, where the points are
365
+ * stored in a flat array in X, Y, Z, order. The bounding sphere is computed by running two
366
+ * algorithms, a naive algorithm and Ritter's algorithm. The smaller of the two spheres is used to
367
+ * ensure a tight fit.
368
+ *
369
+ * @param {number[]|TypedArray} [positions] An array of points that the bounding sphere will enclose. Each point
370
+ * is formed from three elements in the array in the order X, Y, Z.
371
+ * @param {Cartesian3} [center=Cartesian3.ZERO] The position to which the positions are relative, which need not be the
372
+ * origin of the coordinate system. This is useful when the positions are to be used for
373
+ * relative-to-center (RTC) rendering.
374
+ * @param {number} [stride=3] The number of array elements per vertex. It must be at least 3, but it may
375
+ * be higher. Regardless of the value of this parameter, the X coordinate of the first position
376
+ * is at array index 0, the Y coordinate is at array index 1, and the Z coordinate is at array index
377
+ * 2. When stride is 3, the X coordinate of the next position then begins at array index 3. If
378
+ * the stride is 5, however, two array elements are skipped and the next position begins at array
379
+ * index 5.
380
+ * @param {BoundingSphere} [result] The object onto which to store the result.
381
+ * @returns {BoundingSphere} The modified result parameter or a new BoundingSphere instance if one was not provided.
382
+ *
383
+ * @example
384
+ * // Compute the bounding sphere from 3 positions, each specified relative to a center.
385
+ * // In addition to the X, Y, and Z coordinates, the points array contains two additional
386
+ * // elements per point which are ignored for the purpose of computing the bounding sphere.
387
+ * const center = new Cesium.Cartesian3(1.0, 2.0, 3.0);
388
+ * const points = [1.0, 2.0, 3.0, 0.1, 0.2,
389
+ * 4.0, 5.0, 6.0, 0.1, 0.2,
390
+ * 7.0, 8.0, 9.0, 0.1, 0.2];
391
+ * const sphere = Cesium.BoundingSphere.fromVertices(points, center, 5);
392
+ *
393
+ * @see {@link http://blogs.agi.com/insight3d/index.php/2008/02/04/a-bounding/|Bounding Sphere computation article}
394
+ */
395
+ static fromVertices(positions, center, stride, result) {
396
+ if (!defined_default(result)) {
397
+ result = new _BoundingSphere();
398
+ }
399
+ if (!defined_default(positions) || positions.length === 0) {
400
+ result.center = Cartesian3_default.clone(Cartesian3_default.ZERO, result.center);
401
+ result.radius = 0;
402
+ return result;
403
+ }
404
+ center = center ?? Cartesian3_default.ZERO;
405
+ stride = stride ?? 3;
406
+ Check_default.typeOf.number.greaterThanOrEquals("stride", stride, 3);
407
+ const currentPos = fromPointsCurrentPos;
408
+ currentPos.x = positions[0] + center.x;
409
+ currentPos.y = positions[1] + center.y;
410
+ currentPos.z = positions[2] + center.z;
411
+ const xMin = Cartesian3_default.clone(currentPos, fromPointsXMin);
412
+ const yMin = Cartesian3_default.clone(currentPos, fromPointsYMin);
413
+ const zMin = Cartesian3_default.clone(currentPos, fromPointsZMin);
414
+ const xMax = Cartesian3_default.clone(currentPos, fromPointsXMax);
415
+ const yMax = Cartesian3_default.clone(currentPos, fromPointsYMax);
416
+ const zMax = Cartesian3_default.clone(currentPos, fromPointsZMax);
417
+ const numElements = positions.length;
418
+ let i;
419
+ for (i = 0; i < numElements; i += stride) {
420
+ const x = positions[i] + center.x;
421
+ const y = positions[i + 1] + center.y;
422
+ const z = positions[i + 2] + center.z;
423
+ currentPos.x = x;
424
+ currentPos.y = y;
425
+ currentPos.z = z;
426
+ if (x < xMin.x) {
427
+ Cartesian3_default.clone(currentPos, xMin);
428
+ }
429
+ if (x > xMax.x) {
430
+ Cartesian3_default.clone(currentPos, xMax);
431
+ }
432
+ if (y < yMin.y) {
433
+ Cartesian3_default.clone(currentPos, yMin);
434
+ }
435
+ if (y > yMax.y) {
436
+ Cartesian3_default.clone(currentPos, yMax);
437
+ }
438
+ if (z < zMin.z) {
439
+ Cartesian3_default.clone(currentPos, zMin);
440
+ }
441
+ if (z > zMax.z) {
442
+ Cartesian3_default.clone(currentPos, zMax);
443
+ }
444
+ }
445
+ const xSpan = Cartesian3_default.magnitudeSquared(
446
+ Cartesian3_default.subtract(xMax, xMin, fromPointsScratch)
447
+ );
448
+ const ySpan = Cartesian3_default.magnitudeSquared(
449
+ Cartesian3_default.subtract(yMax, yMin, fromPointsScratch)
450
+ );
451
+ const zSpan = Cartesian3_default.magnitudeSquared(
452
+ Cartesian3_default.subtract(zMax, zMin, fromPointsScratch)
453
+ );
454
+ let diameter1 = xMin;
455
+ let diameter2 = xMax;
456
+ let maxSpan = xSpan;
457
+ if (ySpan > maxSpan) {
458
+ maxSpan = ySpan;
459
+ diameter1 = yMin;
460
+ diameter2 = yMax;
461
+ }
462
+ if (zSpan > maxSpan) {
463
+ maxSpan = zSpan;
464
+ diameter1 = zMin;
465
+ diameter2 = zMax;
466
+ }
467
+ const ritterCenter = fromPointsRitterCenter;
468
+ ritterCenter.x = (diameter1.x + diameter2.x) * 0.5;
469
+ ritterCenter.y = (diameter1.y + diameter2.y) * 0.5;
470
+ ritterCenter.z = (diameter1.z + diameter2.z) * 0.5;
471
+ let radiusSquared = Cartesian3_default.magnitudeSquared(
472
+ Cartesian3_default.subtract(diameter2, ritterCenter, fromPointsScratch)
473
+ );
474
+ let ritterRadius = Math.sqrt(radiusSquared);
475
+ const minBoxPt = fromPointsMinBoxPt;
476
+ minBoxPt.x = xMin.x;
477
+ minBoxPt.y = yMin.y;
478
+ minBoxPt.z = zMin.z;
479
+ const maxBoxPt = fromPointsMaxBoxPt;
480
+ maxBoxPt.x = xMax.x;
481
+ maxBoxPt.y = yMax.y;
482
+ maxBoxPt.z = zMax.z;
483
+ const naiveCenter = Cartesian3_default.midpoint(
484
+ minBoxPt,
485
+ maxBoxPt,
486
+ fromPointsNaiveCenterScratch
487
+ );
488
+ let naiveRadius = 0;
489
+ for (i = 0; i < numElements; i += stride) {
490
+ currentPos.x = positions[i] + center.x;
491
+ currentPos.y = positions[i + 1] + center.y;
492
+ currentPos.z = positions[i + 2] + center.z;
493
+ const r = Cartesian3_default.magnitude(
494
+ Cartesian3_default.subtract(currentPos, naiveCenter, fromPointsScratch)
495
+ );
496
+ if (r > naiveRadius) {
497
+ naiveRadius = r;
498
+ }
499
+ const oldCenterToPointSquared = Cartesian3_default.magnitudeSquared(
500
+ Cartesian3_default.subtract(currentPos, ritterCenter, fromPointsScratch)
501
+ );
502
+ if (oldCenterToPointSquared > radiusSquared) {
503
+ const oldCenterToPoint = Math.sqrt(oldCenterToPointSquared);
504
+ ritterRadius = (ritterRadius + oldCenterToPoint) * 0.5;
505
+ radiusSquared = ritterRadius * ritterRadius;
506
+ const oldToNew = oldCenterToPoint - ritterRadius;
507
+ ritterCenter.x = (ritterRadius * ritterCenter.x + oldToNew * currentPos.x) / oldCenterToPoint;
508
+ ritterCenter.y = (ritterRadius * ritterCenter.y + oldToNew * currentPos.y) / oldCenterToPoint;
509
+ ritterCenter.z = (ritterRadius * ritterCenter.z + oldToNew * currentPos.z) / oldCenterToPoint;
510
+ }
511
+ }
512
+ if (ritterRadius < naiveRadius) {
513
+ Cartesian3_default.clone(ritterCenter, result.center);
514
+ result.radius = ritterRadius;
515
+ } else {
516
+ Cartesian3_default.clone(naiveCenter, result.center);
517
+ result.radius = naiveRadius;
518
+ }
519
+ return result;
520
+ }
521
+ /**
522
+ * Computes a tight-fitting bounding sphere enclosing a list of EncodedCartesian3s, where the points are
523
+ * stored in parallel flat arrays in X, Y, Z, order. The bounding sphere is computed by running two
524
+ * algorithms, a naive algorithm and Ritter's algorithm. The smaller of the two spheres is used to
525
+ * ensure a tight fit.
526
+ *
527
+ * @param {number[]} [positionsHigh] An array of high bits of the encoded cartesians that the bounding sphere will enclose. Each point
528
+ * is formed from three elements in the array in the order X, Y, Z.
529
+ * @param {number[]} [positionsLow] An array of low bits of the encoded cartesians that the bounding sphere will enclose. Each point
530
+ * is formed from three elements in the array in the order X, Y, Z.
531
+ * @param {BoundingSphere} [result] The object onto which to store the result.
532
+ * @returns {BoundingSphere} The modified result parameter or a new BoundingSphere instance if one was not provided.
533
+ *
534
+ * @see {@link http://blogs.agi.com/insight3d/index.php/2008/02/04/a-bounding/|Bounding Sphere computation article}
535
+ */
536
+ static fromEncodedCartesianVertices(positionsHigh, positionsLow, result) {
537
+ if (!defined_default(result)) {
538
+ result = new _BoundingSphere();
539
+ }
540
+ if (!defined_default(positionsHigh) || !defined_default(positionsLow) || positionsHigh.length !== positionsLow.length || positionsHigh.length === 0) {
541
+ result.center = Cartesian3_default.clone(Cartesian3_default.ZERO, result.center);
542
+ result.radius = 0;
543
+ return result;
544
+ }
545
+ const currentPos = fromPointsCurrentPos;
546
+ currentPos.x = positionsHigh[0] + positionsLow[0];
547
+ currentPos.y = positionsHigh[1] + positionsLow[1];
548
+ currentPos.z = positionsHigh[2] + positionsLow[2];
549
+ const xMin = Cartesian3_default.clone(currentPos, fromPointsXMin);
550
+ const yMin = Cartesian3_default.clone(currentPos, fromPointsYMin);
551
+ const zMin = Cartesian3_default.clone(currentPos, fromPointsZMin);
552
+ const xMax = Cartesian3_default.clone(currentPos, fromPointsXMax);
553
+ const yMax = Cartesian3_default.clone(currentPos, fromPointsYMax);
554
+ const zMax = Cartesian3_default.clone(currentPos, fromPointsZMax);
555
+ const numElements = positionsHigh.length;
556
+ let i;
557
+ for (i = 0; i < numElements; i += 3) {
558
+ const x = positionsHigh[i] + positionsLow[i];
559
+ const y = positionsHigh[i + 1] + positionsLow[i + 1];
560
+ const z = positionsHigh[i + 2] + positionsLow[i + 2];
561
+ currentPos.x = x;
562
+ currentPos.y = y;
563
+ currentPos.z = z;
564
+ if (x < xMin.x) {
565
+ Cartesian3_default.clone(currentPos, xMin);
566
+ }
567
+ if (x > xMax.x) {
568
+ Cartesian3_default.clone(currentPos, xMax);
569
+ }
570
+ if (y < yMin.y) {
571
+ Cartesian3_default.clone(currentPos, yMin);
572
+ }
573
+ if (y > yMax.y) {
574
+ Cartesian3_default.clone(currentPos, yMax);
575
+ }
576
+ if (z < zMin.z) {
577
+ Cartesian3_default.clone(currentPos, zMin);
578
+ }
579
+ if (z > zMax.z) {
580
+ Cartesian3_default.clone(currentPos, zMax);
581
+ }
582
+ }
583
+ const xSpan = Cartesian3_default.magnitudeSquared(
584
+ Cartesian3_default.subtract(xMax, xMin, fromPointsScratch)
585
+ );
586
+ const ySpan = Cartesian3_default.magnitudeSquared(
587
+ Cartesian3_default.subtract(yMax, yMin, fromPointsScratch)
588
+ );
589
+ const zSpan = Cartesian3_default.magnitudeSquared(
590
+ Cartesian3_default.subtract(zMax, zMin, fromPointsScratch)
591
+ );
592
+ let diameter1 = xMin;
593
+ let diameter2 = xMax;
594
+ let maxSpan = xSpan;
595
+ if (ySpan > maxSpan) {
596
+ maxSpan = ySpan;
597
+ diameter1 = yMin;
598
+ diameter2 = yMax;
599
+ }
600
+ if (zSpan > maxSpan) {
601
+ maxSpan = zSpan;
602
+ diameter1 = zMin;
603
+ diameter2 = zMax;
604
+ }
605
+ const ritterCenter = fromPointsRitterCenter;
606
+ ritterCenter.x = (diameter1.x + diameter2.x) * 0.5;
607
+ ritterCenter.y = (diameter1.y + diameter2.y) * 0.5;
608
+ ritterCenter.z = (diameter1.z + diameter2.z) * 0.5;
609
+ let radiusSquared = Cartesian3_default.magnitudeSquared(
610
+ Cartesian3_default.subtract(diameter2, ritterCenter, fromPointsScratch)
611
+ );
612
+ let ritterRadius = Math.sqrt(radiusSquared);
613
+ const minBoxPt = fromPointsMinBoxPt;
614
+ minBoxPt.x = xMin.x;
615
+ minBoxPt.y = yMin.y;
616
+ minBoxPt.z = zMin.z;
617
+ const maxBoxPt = fromPointsMaxBoxPt;
618
+ maxBoxPt.x = xMax.x;
619
+ maxBoxPt.y = yMax.y;
620
+ maxBoxPt.z = zMax.z;
621
+ const naiveCenter = Cartesian3_default.midpoint(
622
+ minBoxPt,
623
+ maxBoxPt,
624
+ fromPointsNaiveCenterScratch
625
+ );
626
+ let naiveRadius = 0;
627
+ for (i = 0; i < numElements; i += 3) {
628
+ currentPos.x = positionsHigh[i] + positionsLow[i];
629
+ currentPos.y = positionsHigh[i + 1] + positionsLow[i + 1];
630
+ currentPos.z = positionsHigh[i + 2] + positionsLow[i + 2];
631
+ const r = Cartesian3_default.magnitude(
632
+ Cartesian3_default.subtract(currentPos, naiveCenter, fromPointsScratch)
633
+ );
634
+ if (r > naiveRadius) {
635
+ naiveRadius = r;
636
+ }
637
+ const oldCenterToPointSquared = Cartesian3_default.magnitudeSquared(
638
+ Cartesian3_default.subtract(currentPos, ritterCenter, fromPointsScratch)
639
+ );
640
+ if (oldCenterToPointSquared > radiusSquared) {
641
+ const oldCenterToPoint = Math.sqrt(oldCenterToPointSquared);
642
+ ritterRadius = (ritterRadius + oldCenterToPoint) * 0.5;
643
+ radiusSquared = ritterRadius * ritterRadius;
644
+ const oldToNew = oldCenterToPoint - ritterRadius;
645
+ ritterCenter.x = (ritterRadius * ritterCenter.x + oldToNew * currentPos.x) / oldCenterToPoint;
646
+ ritterCenter.y = (ritterRadius * ritterCenter.y + oldToNew * currentPos.y) / oldCenterToPoint;
647
+ ritterCenter.z = (ritterRadius * ritterCenter.z + oldToNew * currentPos.z) / oldCenterToPoint;
648
+ }
649
+ }
650
+ if (ritterRadius < naiveRadius) {
651
+ Cartesian3_default.clone(ritterCenter, result.center);
652
+ result.radius = ritterRadius;
653
+ } else {
654
+ Cartesian3_default.clone(naiveCenter, result.center);
655
+ result.radius = naiveRadius;
656
+ }
657
+ return result;
658
+ }
659
+ /**
660
+ * Computes a bounding sphere from the corner points of an axis-aligned bounding box. The sphere
661
+ * tightly and fully encompasses the box.
662
+ *
663
+ * @param {Cartesian3} [corner] The minimum height over the rectangle.
664
+ * @param {Cartesian3} [oppositeCorner] The maximum height over the rectangle.
665
+ * @param {BoundingSphere} [result] The object onto which to store the result.
666
+ * @returns {BoundingSphere} The modified result parameter or a new BoundingSphere instance if none was provided.
667
+ *
668
+ * @example
669
+ * // Create a bounding sphere around the unit cube
670
+ * const sphere = Cesium.BoundingSphere.fromCornerPoints(new Cesium.Cartesian3(-0.5, -0.5, -0.5), new Cesium.Cartesian3(0.5, 0.5, 0.5));
671
+ */
672
+ static fromCornerPoints(corner, oppositeCorner, result) {
673
+ Check_default.typeOf.object("corner", corner);
674
+ Check_default.typeOf.object("oppositeCorner", oppositeCorner);
675
+ if (!defined_default(result)) {
676
+ result = new _BoundingSphere();
677
+ }
678
+ const center = Cartesian3_default.midpoint(corner, oppositeCorner, result.center);
679
+ result.radius = Cartesian3_default.distance(center, oppositeCorner);
680
+ return result;
681
+ }
682
+ /**
683
+ * Creates a bounding sphere encompassing an ellipsoid.
684
+ *
685
+ * @param {Ellipsoid} ellipsoid The ellipsoid around which to create a bounding sphere.
686
+ * @param {BoundingSphere} [result] The object onto which to store the result.
687
+ * @returns {BoundingSphere} The modified result parameter or a new BoundingSphere instance if none was provided.
688
+ *
689
+ * @example
690
+ * const boundingSphere = Cesium.BoundingSphere.fromEllipsoid(ellipsoid);
691
+ */
692
+ static fromEllipsoid(ellipsoid, result) {
693
+ Check_default.typeOf.object("ellipsoid", ellipsoid);
694
+ if (!defined_default(result)) {
695
+ result = new _BoundingSphere();
696
+ }
697
+ Cartesian3_default.clone(Cartesian3_default.ZERO, result.center);
698
+ result.radius = ellipsoid.maximumRadius;
699
+ return result;
700
+ }
701
+ /**
702
+ * Computes a tight-fitting bounding sphere enclosing the provided array of bounding spheres.
703
+ *
704
+ * @param {BoundingSphere[]} [boundingSpheres] The array of bounding spheres.
705
+ * @param {BoundingSphere} [result] The object onto which to store the result.
706
+ * @returns {BoundingSphere} The modified result parameter or a new BoundingSphere instance if none was provided.
707
+ */
708
+ static fromBoundingSpheres(boundingSpheres, result) {
709
+ if (!defined_default(result)) {
710
+ result = new _BoundingSphere();
711
+ }
712
+ if (!defined_default(boundingSpheres) || boundingSpheres.length === 0) {
713
+ result.center = Cartesian3_default.clone(Cartesian3_default.ZERO, result.center);
714
+ result.radius = 0;
715
+ return result;
716
+ }
717
+ const length = boundingSpheres.length;
718
+ if (length === 1) {
719
+ return _BoundingSphere.clone(boundingSpheres[0], result);
720
+ }
721
+ if (length === 2) {
722
+ return _BoundingSphere.union(
723
+ boundingSpheres[0],
724
+ boundingSpheres[1],
725
+ result
726
+ );
727
+ }
728
+ const positions = [];
729
+ let i;
730
+ for (i = 0; i < length; i++) {
731
+ positions.push(boundingSpheres[i].center);
732
+ }
733
+ result = _BoundingSphere.fromPoints(positions, result);
734
+ const center = result.center;
735
+ let radius = result.radius;
736
+ for (i = 0; i < length; i++) {
737
+ const tmp = boundingSpheres[i];
738
+ radius = Math.max(
739
+ radius,
740
+ Cartesian3_default.distance(center, tmp.center) + tmp.radius
741
+ );
742
+ }
743
+ result.radius = radius;
744
+ return result;
745
+ }
746
+ /**
747
+ * Computes a tight-fitting bounding sphere enclosing the provided oriented bounding box.
748
+ *
749
+ * @param {OrientedBoundingBox} orientedBoundingBox The oriented bounding box.
750
+ * @param {BoundingSphere} [result] The object onto which to store the result.
751
+ * @returns {BoundingSphere} The modified result parameter or a new BoundingSphere instance if none was provided.
752
+ */
753
+ static fromOrientedBoundingBox(orientedBoundingBox, result) {
754
+ Check_default.defined("orientedBoundingBox", orientedBoundingBox);
755
+ if (!defined_default(result)) {
756
+ result = new _BoundingSphere();
757
+ }
758
+ const halfAxes = orientedBoundingBox.halfAxes;
759
+ const u = Matrix3_default.getColumn(halfAxes, 0, fromOrientedBoundingBoxScratchU);
760
+ const v = Matrix3_default.getColumn(halfAxes, 1, fromOrientedBoundingBoxScratchV);
761
+ const w = Matrix3_default.getColumn(halfAxes, 2, fromOrientedBoundingBoxScratchW);
762
+ Cartesian3_default.add(u, v, u);
763
+ Cartesian3_default.add(u, w, u);
764
+ result.center = Cartesian3_default.clone(orientedBoundingBox.center, result.center);
765
+ result.radius = Cartesian3_default.magnitude(u);
766
+ return result;
767
+ }
768
+ /**
769
+ * Computes a tight-fitting bounding sphere enclosing the provided affine transformation.
770
+ *
771
+ * @param {Matrix4} transformation The affine transformation.
772
+ * @param {BoundingSphere} [result] The object onto which to store the result.
773
+ * @returns {BoundingSphere} The modified result parameter or a new BoundingSphere instance if none was provided.
774
+ */
775
+ static fromTransformation(transformation, result) {
776
+ Check_default.typeOf.object("transformation", transformation);
777
+ if (!defined_default(result)) {
778
+ result = new _BoundingSphere();
779
+ }
780
+ const center = Matrix4_default.getTranslation(
781
+ transformation,
782
+ scratchFromTransformationCenter
783
+ );
784
+ const scale = Matrix4_default.getScale(
785
+ transformation,
786
+ scratchFromTransformationScale
787
+ );
788
+ const radius = 0.5 * Cartesian3_default.magnitude(scale);
789
+ result.center = Cartesian3_default.clone(center, result.center);
790
+ result.radius = radius;
791
+ return result;
792
+ }
793
+ /**
794
+ * Duplicates a BoundingSphere instance.
795
+ *
796
+ * @param {BoundingSphere} sphere The bounding sphere to duplicate.
797
+ * @param {BoundingSphere} [result] The object onto which to store the result.
798
+ * @returns {BoundingSphere} The modified result parameter or a new BoundingSphere instance if none was provided. (Returns undefined if sphere is undefined)
799
+ */
800
+ static clone(sphere, result) {
801
+ if (!defined_default(sphere)) {
802
+ return void 0;
803
+ }
804
+ if (!defined_default(result)) {
805
+ return new _BoundingSphere(sphere.center, sphere.radius);
806
+ }
807
+ result.center = Cartesian3_default.clone(sphere.center, result.center);
808
+ result.radius = sphere.radius;
809
+ return result;
810
+ }
811
+ /**
812
+ * Stores the provided instance into the provided array.
813
+ *
814
+ * @param {BoundingSphere} value The value to pack.
815
+ * @param {number[]} array The array to pack into.
816
+ * @param {number} [startingIndex=0] The index into the array at which to start packing the elements.
817
+ *
818
+ * @returns {number[]} The array that was packed into
819
+ */
820
+ static pack(value, array, startingIndex) {
821
+ Check_default.typeOf.object("value", value);
822
+ Check_default.defined("array", array);
823
+ startingIndex = startingIndex ?? 0;
824
+ const center = value.center;
825
+ array[startingIndex++] = center.x;
826
+ array[startingIndex++] = center.y;
827
+ array[startingIndex++] = center.z;
828
+ array[startingIndex] = value.radius;
829
+ return array;
830
+ }
831
+ /**
832
+ * Retrieves an instance from a packed array.
833
+ *
834
+ * @param {number[]} array The packed array.
835
+ * @param {number} [startingIndex=0] The starting index of the element to be unpacked.
836
+ * @param {BoundingSphere} [result] The object into which to store the result.
837
+ * @returns {BoundingSphere} The modified result parameter or a new BoundingSphere instance if one was not provided.
838
+ */
839
+ static unpack(array, startingIndex, result) {
840
+ Check_default.defined("array", array);
841
+ startingIndex = startingIndex ?? 0;
842
+ if (!defined_default(result)) {
843
+ result = new _BoundingSphere();
844
+ }
845
+ const center = result.center;
846
+ center.x = array[startingIndex++];
847
+ center.y = array[startingIndex++];
848
+ center.z = array[startingIndex++];
849
+ result.radius = array[startingIndex];
850
+ return result;
851
+ }
852
+ /**
853
+ * Computes a bounding sphere that contains both the left and right bounding spheres.
854
+ *
855
+ * @param {BoundingSphere} left A sphere to enclose in a bounding sphere.
856
+ * @param {BoundingSphere} right A sphere to enclose in a bounding sphere.
857
+ * @param {BoundingSphere} [result] The object onto which to store the result.
858
+ * @returns {BoundingSphere} The modified result parameter or a new BoundingSphere instance if none was provided.
859
+ */
860
+ static union(left, right, result) {
861
+ Check_default.typeOf.object("left", left);
862
+ Check_default.typeOf.object("right", right);
863
+ if (!defined_default(result)) {
864
+ result = new _BoundingSphere();
865
+ }
866
+ const leftCenter = left.center;
867
+ const leftRadius = left.radius;
868
+ const rightCenter = right.center;
869
+ const rightRadius = right.radius;
870
+ const toRightCenter = Cartesian3_default.subtract(
871
+ rightCenter,
872
+ leftCenter,
873
+ unionScratch
874
+ );
875
+ const centerSeparation = Cartesian3_default.magnitude(toRightCenter);
876
+ if (leftRadius >= centerSeparation + rightRadius) {
877
+ left.clone(result);
878
+ return result;
879
+ }
880
+ if (rightRadius >= centerSeparation + leftRadius) {
881
+ right.clone(result);
882
+ return result;
883
+ }
884
+ const halfDistanceBetweenTangentPoints = (leftRadius + centerSeparation + rightRadius) * 0.5;
885
+ const center = Cartesian3_default.multiplyByScalar(
886
+ toRightCenter,
887
+ (-leftRadius + halfDistanceBetweenTangentPoints) / centerSeparation,
888
+ unionScratchCenter
889
+ );
890
+ Cartesian3_default.add(center, leftCenter, center);
891
+ Cartesian3_default.clone(center, result.center);
892
+ result.radius = halfDistanceBetweenTangentPoints;
893
+ return result;
894
+ }
895
+ /**
896
+ * Computes a bounding sphere by enlarging the provided sphere to contain the provided point.
897
+ *
898
+ * @param {BoundingSphere} sphere A sphere to expand.
899
+ * @param {Cartesian3} point A point to enclose in a bounding sphere.
900
+ * @param {BoundingSphere} [result] The object onto which to store the result.
901
+ * @returns {BoundingSphere} The modified result parameter or a new BoundingSphere instance if none was provided.
902
+ */
903
+ static expand(sphere, point, result) {
904
+ Check_default.typeOf.object("sphere", sphere);
905
+ Check_default.typeOf.object("point", point);
906
+ result = _BoundingSphere.clone(sphere, result);
907
+ const radius = Cartesian3_default.magnitude(
908
+ Cartesian3_default.subtract(point, result.center, expandScratch)
909
+ );
910
+ if (radius > result.radius) {
911
+ result.radius = radius;
912
+ }
913
+ return result;
914
+ }
915
+ /**
916
+ * Determines which side of a plane a sphere is located.
917
+ *
918
+ * @param {BoundingSphere} sphere The bounding sphere to test.
919
+ * @param {Plane} plane The plane to test against.
920
+ * @returns {Intersect} {@link Intersect.INSIDE} if the entire sphere is on the side of the plane
921
+ * the normal is pointing, {@link Intersect.OUTSIDE} if the entire sphere is
922
+ * on the opposite side, and {@link Intersect.INTERSECTING} if the sphere
923
+ * intersects the plane.
924
+ */
925
+ static intersectPlane(sphere, plane) {
926
+ Check_default.typeOf.object("sphere", sphere);
927
+ Check_default.typeOf.object("plane", plane);
928
+ const center = sphere.center;
929
+ const radius = sphere.radius;
930
+ const normal = plane.normal;
931
+ const distanceToPlane = Cartesian3_default.dot(normal, center) + plane.distance;
932
+ if (distanceToPlane < -radius) {
933
+ return Intersect_default.OUTSIDE;
934
+ } else if (distanceToPlane < radius) {
935
+ return Intersect_default.INTERSECTING;
936
+ }
937
+ return Intersect_default.INSIDE;
938
+ }
939
+ /**
940
+ * Applies a 4x4 affine transformation matrix to a bounding sphere.
941
+ *
942
+ * @param {BoundingSphere} sphere The bounding sphere to apply the transformation to.
943
+ * @param {Matrix4} transform The transformation matrix to apply to the bounding sphere.
944
+ * @param {BoundingSphere} [result] The object onto which to store the result.
945
+ * @returns {BoundingSphere} The modified result parameter or a new BoundingSphere instance if none was provided.
946
+ */
947
+ static transform(sphere, transform, result) {
948
+ Check_default.typeOf.object("sphere", sphere);
949
+ Check_default.typeOf.object("transform", transform);
950
+ if (!defined_default(result)) {
951
+ result = new _BoundingSphere();
952
+ }
953
+ result.center = Matrix4_default.multiplyByPoint(
954
+ transform,
955
+ sphere.center,
956
+ result.center
957
+ );
958
+ result.radius = Matrix4_default.getMaximumScale(transform) * sphere.radius;
959
+ return result;
960
+ }
961
+ /**
962
+ * Computes the estimated distance squared from the closest point on a bounding sphere to a point.
963
+ *
964
+ * @param {BoundingSphere} sphere The sphere.
965
+ * @param {Cartesian3} cartesian The point
966
+ * @returns {number} The distance squared from the bounding sphere to the point. Returns 0 if the point is inside the sphere.
967
+ *
968
+ * @example
969
+ * // Sort bounding spheres from back to front
970
+ * spheres.sort(function(a, b) {
971
+ * return Cesium.BoundingSphere.distanceSquaredTo(b, camera.positionWC) - Cesium.BoundingSphere.distanceSquaredTo(a, camera.positionWC);
972
+ * });
973
+ */
974
+ static distanceSquaredTo(sphere, cartesian) {
975
+ Check_default.typeOf.object("sphere", sphere);
976
+ Check_default.typeOf.object("cartesian", cartesian);
977
+ const diff = Cartesian3_default.subtract(
978
+ sphere.center,
979
+ cartesian,
980
+ distanceSquaredToScratch
981
+ );
982
+ const distance = Cartesian3_default.magnitude(diff) - sphere.radius;
983
+ if (distance <= 0) {
984
+ return 0;
985
+ }
986
+ return distance * distance;
987
+ }
988
+ /**
989
+ * Applies a 4x4 affine transformation matrix to a bounding sphere where there is no scale
990
+ * The transformation matrix is not verified to have a uniform scale of 1.
991
+ * This method is faster than computing the general bounding sphere transform using {@link BoundingSphere.transform}.
992
+ *
993
+ * @param {BoundingSphere} sphere The bounding sphere to apply the transformation to.
994
+ * @param {Matrix4} transform The transformation matrix to apply to the bounding sphere.
995
+ * @param {BoundingSphere} [result] The object onto which to store the result.
996
+ * @returns {BoundingSphere} The modified result parameter or a new BoundingSphere instance if none was provided.
997
+ *
998
+ * @example
999
+ * const modelMatrix = Cesium.Transforms.eastNorthUpToFixedFrame(positionOnEllipsoid);
1000
+ * const boundingSphere = new Cesium.BoundingSphere();
1001
+ * const newBoundingSphere = Cesium.BoundingSphere.transformWithoutScale(boundingSphere, modelMatrix);
1002
+ */
1003
+ static transformWithoutScale(sphere, transform, result) {
1004
+ Check_default.typeOf.object("sphere", sphere);
1005
+ Check_default.typeOf.object("transform", transform);
1006
+ if (!defined_default(result)) {
1007
+ result = new _BoundingSphere();
1008
+ }
1009
+ result.center = Matrix4_default.multiplyByPoint(
1010
+ transform,
1011
+ sphere.center,
1012
+ result.center
1013
+ );
1014
+ result.radius = sphere.radius;
1015
+ return result;
1016
+ }
1017
+ /**
1018
+ * The distances calculated by the vector from the center of the bounding sphere to position projected onto direction
1019
+ * plus/minus the radius of the bounding sphere.
1020
+ * <br>
1021
+ * If you imagine the infinite number of planes with normal direction, this computes the smallest distance to the
1022
+ * closest and farthest planes from position that intersect the bounding sphere.
1023
+ *
1024
+ * @param {BoundingSphere} sphere The bounding sphere to calculate the distance to.
1025
+ * @param {Cartesian3} position The position to calculate the distance from.
1026
+ * @param {Cartesian3} direction The direction from position.
1027
+ * @param {Interval} [result] A Interval to store the nearest and farthest distances.
1028
+ * @returns {Interval} The nearest and farthest distances on the bounding sphere from position in direction.
1029
+ */
1030
+ static computePlaneDistances(sphere, position, direction, result) {
1031
+ Check_default.typeOf.object("sphere", sphere);
1032
+ Check_default.typeOf.object("position", position);
1033
+ Check_default.typeOf.object("direction", direction);
1034
+ if (!defined_default(result)) {
1035
+ result = new Interval_default();
1036
+ }
1037
+ const toCenter = Cartesian3_default.subtract(
1038
+ sphere.center,
1039
+ position,
1040
+ scratchCartesian3
1041
+ );
1042
+ const mag = Cartesian3_default.dot(direction, toCenter);
1043
+ result.start = mag - sphere.radius;
1044
+ result.stop = mag + sphere.radius;
1045
+ return result;
1046
+ }
1047
+ /**
1048
+ * Creates a bounding sphere in 2D from a bounding sphere in 3D world coordinates.
1049
+ *
1050
+ * @param {BoundingSphere} sphere The bounding sphere to transform to 2D.
1051
+ * @param {MapProjection} [projection=GeographicProjection] The projection to 2D.
1052
+ * @param {BoundingSphere} [result] The object onto which to store the result.
1053
+ * @returns {BoundingSphere} The modified result parameter or a new BoundingSphere instance if none was provided.
1054
+ */
1055
+ static projectTo2D(sphere, projection, result) {
1056
+ Check_default.typeOf.object("sphere", sphere);
1057
+ projectTo2DProjection._ellipsoid = Ellipsoid_default.default;
1058
+ projection = projection ?? projectTo2DProjection;
1059
+ const ellipsoid = projection.ellipsoid;
1060
+ let center = sphere.center;
1061
+ const radius = sphere.radius;
1062
+ let normal;
1063
+ if (Cartesian3_default.equals(center, Cartesian3_default.ZERO)) {
1064
+ normal = Cartesian3_default.clone(Cartesian3_default.UNIT_X, projectTo2DNormalScratch);
1065
+ } else {
1066
+ normal = ellipsoid.geodeticSurfaceNormal(
1067
+ center,
1068
+ projectTo2DNormalScratch
1069
+ );
1070
+ }
1071
+ const east = Cartesian3_default.cross(
1072
+ Cartesian3_default.UNIT_Z,
1073
+ normal,
1074
+ projectTo2DEastScratch
1075
+ );
1076
+ Cartesian3_default.normalize(east, east);
1077
+ const north = Cartesian3_default.cross(normal, east, projectTo2DNorthScratch);
1078
+ Cartesian3_default.normalize(north, north);
1079
+ Cartesian3_default.multiplyByScalar(normal, radius, normal);
1080
+ Cartesian3_default.multiplyByScalar(north, radius, north);
1081
+ Cartesian3_default.multiplyByScalar(east, radius, east);
1082
+ const south = Cartesian3_default.negate(north, projectTo2DSouthScratch);
1083
+ const west = Cartesian3_default.negate(east, projectTo2DWestScratch);
1084
+ const positions = projectTo2DPositionsScratch;
1085
+ let corner = positions[0];
1086
+ Cartesian3_default.add(normal, north, corner);
1087
+ Cartesian3_default.add(corner, east, corner);
1088
+ corner = positions[1];
1089
+ Cartesian3_default.add(normal, north, corner);
1090
+ Cartesian3_default.add(corner, west, corner);
1091
+ corner = positions[2];
1092
+ Cartesian3_default.add(normal, south, corner);
1093
+ Cartesian3_default.add(corner, west, corner);
1094
+ corner = positions[3];
1095
+ Cartesian3_default.add(normal, south, corner);
1096
+ Cartesian3_default.add(corner, east, corner);
1097
+ Cartesian3_default.negate(normal, normal);
1098
+ corner = positions[4];
1099
+ Cartesian3_default.add(normal, north, corner);
1100
+ Cartesian3_default.add(corner, east, corner);
1101
+ corner = positions[5];
1102
+ Cartesian3_default.add(normal, north, corner);
1103
+ Cartesian3_default.add(corner, west, corner);
1104
+ corner = positions[6];
1105
+ Cartesian3_default.add(normal, south, corner);
1106
+ Cartesian3_default.add(corner, west, corner);
1107
+ corner = positions[7];
1108
+ Cartesian3_default.add(normal, south, corner);
1109
+ Cartesian3_default.add(corner, east, corner);
1110
+ const length = positions.length;
1111
+ for (let i = 0; i < length; ++i) {
1112
+ const position = positions[i];
1113
+ Cartesian3_default.add(center, position, position);
1114
+ const cartographic = ellipsoid.cartesianToCartographic(
1115
+ position,
1116
+ projectTo2DCartographicScratch
1117
+ );
1118
+ projection.project(cartographic, position);
1119
+ }
1120
+ result = _BoundingSphere.fromPoints(positions, result);
1121
+ center = result.center;
1122
+ const x = center.x;
1123
+ const y = center.y;
1124
+ const z = center.z;
1125
+ center.x = z;
1126
+ center.y = x;
1127
+ center.z = y;
1128
+ return result;
1129
+ }
1130
+ /**
1131
+ * Determines whether or not a sphere is hidden from view by the occluder.
1132
+ *
1133
+ * @param {BoundingSphere} sphere The bounding sphere surrounding the occluded object.
1134
+ * @param {Occluder} occluder The occluder.
1135
+ * @returns {boolean} <code>true</code> if the sphere is not visible; otherwise <code>false</code>.
1136
+ */
1137
+ static isOccluded(sphere, occluder) {
1138
+ Check_default.typeOf.object("sphere", sphere);
1139
+ Check_default.typeOf.object("occluder", occluder);
1140
+ return !occluder.isBoundingSphereVisible(sphere);
1141
+ }
1142
+ /**
1143
+ * Compares the provided BoundingSphere componentwise and returns
1144
+ * <code>true</code> if they are equal, <code>false</code> otherwise.
1145
+ *
1146
+ * @param {BoundingSphere} [left] The first BoundingSphere.
1147
+ * @param {BoundingSphere} [right] The second BoundingSphere.
1148
+ * @returns {boolean} <code>true</code> if left and right are equal, <code>false</code> otherwise.
1149
+ */
1150
+ static equals(left, right) {
1151
+ return left === right || defined_default(left) && defined_default(right) && Cartesian3_default.equals(left.center, right.center) && left.radius === right.radius;
1152
+ }
1153
+ /**
1154
+ * Determines which side of a plane the sphere is located.
1155
+ *
1156
+ * @param {Plane} plane The plane to test against.
1157
+ * @returns {Intersect} {@link Intersect.INSIDE} if the entire sphere is on the side of the plane
1158
+ * the normal is pointing, {@link Intersect.OUTSIDE} if the entire sphere is
1159
+ * on the opposite side, and {@link Intersect.INTERSECTING} if the sphere
1160
+ * intersects the plane.
1161
+ */
1162
+ intersectPlane(plane) {
1163
+ return _BoundingSphere.intersectPlane(this, plane);
1164
+ }
1165
+ /**
1166
+ * Computes the estimated distance squared from the closest point on a bounding sphere to a point.
1167
+ *
1168
+ * @param {Cartesian3} cartesian The point
1169
+ * @returns {number} The estimated distance squared from the bounding sphere to the point.
1170
+ *
1171
+ * @example
1172
+ * // Sort bounding spheres from back to front
1173
+ * spheres.sort(function(a, b) {
1174
+ * return b.distanceSquaredTo(camera.positionWC) - a.distanceSquaredTo(camera.positionWC);
1175
+ * });
1176
+ */
1177
+ distanceSquaredTo(cartesian) {
1178
+ return _BoundingSphere.distanceSquaredTo(this, cartesian);
1179
+ }
1180
+ /**
1181
+ * The distances calculated by the vector from the center of the bounding sphere to position projected onto direction
1182
+ * plus/minus the radius of the bounding sphere.
1183
+ * <br>
1184
+ * If you imagine the infinite number of planes with normal direction, this computes the smallest distance to the
1185
+ * closest and farthest planes from position that intersect the bounding sphere.
1186
+ *
1187
+ * @param {Cartesian3} position The position to calculate the distance from.
1188
+ * @param {Cartesian3} direction The direction from position.
1189
+ * @param {Interval} [result] A Interval to store the nearest and farthest distances.
1190
+ * @returns {Interval} The nearest and farthest distances on the bounding sphere from position in direction.
1191
+ */
1192
+ computePlaneDistances(position, direction, result) {
1193
+ return _BoundingSphere.computePlaneDistances(
1194
+ this,
1195
+ position,
1196
+ direction,
1197
+ result
1198
+ );
1199
+ }
1200
+ /**
1201
+ * Determines whether or not a sphere is hidden from view by the occluder.
1202
+ *
1203
+ * @param {Occluder} occluder The occluder.
1204
+ * @returns {boolean} <code>true</code> if the sphere is not visible; otherwise <code>false</code>.
1205
+ */
1206
+ isOccluded(occluder) {
1207
+ return _BoundingSphere.isOccluded(this, occluder);
1208
+ }
1209
+ /**
1210
+ * Compares this BoundingSphere against the provided BoundingSphere componentwise and returns
1211
+ * <code>true</code> if they are equal, <code>false</code> otherwise.
1212
+ *
1213
+ * @param {BoundingSphere} [right] The right hand side BoundingSphere.
1214
+ * @returns {boolean} <code>true</code> if they are equal, <code>false</code> otherwise.
1215
+ */
1216
+ equals(right) {
1217
+ return _BoundingSphere.equals(this, right);
1218
+ }
1219
+ /**
1220
+ * Duplicates this BoundingSphere instance.
1221
+ *
1222
+ * @param {BoundingSphere} [result] The object onto which to store the result.
1223
+ * @returns {BoundingSphere} The modified result parameter or a new BoundingSphere instance if none was provided.
1224
+ */
1225
+ clone(result) {
1226
+ return _BoundingSphere.clone(this, result);
1227
+ }
1228
+ /**
1229
+ * Computes the radius of the BoundingSphere.
1230
+ * @returns {number} The radius of the BoundingSphere.
1231
+ */
1232
+ volume() {
1233
+ const radius = this.radius;
1234
+ return volumeConstant * radius * radius * radius;
1235
+ }
1236
+ };
1237
+ BoundingSphere.packedLength = 4;
1238
+ var fromPointsXMin = new Cartesian3_default();
1239
+ var fromPointsYMin = new Cartesian3_default();
1240
+ var fromPointsZMin = new Cartesian3_default();
1241
+ var fromPointsXMax = new Cartesian3_default();
1242
+ var fromPointsYMax = new Cartesian3_default();
1243
+ var fromPointsZMax = new Cartesian3_default();
1244
+ var fromPointsCurrentPos = new Cartesian3_default();
1245
+ var fromPointsScratch = new Cartesian3_default();
1246
+ var fromPointsRitterCenter = new Cartesian3_default();
1247
+ var fromPointsMinBoxPt = new Cartesian3_default();
1248
+ var fromPointsMaxBoxPt = new Cartesian3_default();
1249
+ var fromPointsNaiveCenterScratch = new Cartesian3_default();
1250
+ var volumeConstant = 4 / 3 * Math_default.PI;
1251
+ var defaultProjection = new GeographicProjection_default();
1252
+ var fromRectangle2DLowerLeft = new Cartesian3_default();
1253
+ var fromRectangle2DUpperRight = new Cartesian3_default();
1254
+ var fromRectangle2DSouthwest = new Cartographic_default();
1255
+ var fromRectangle2DNortheast = new Cartographic_default();
1256
+ var fromRectangle3DScratch = (
1257
+ /** @type {Cartesian3[]} */
1258
+ []
1259
+ );
1260
+ var fromOrientedBoundingBoxScratchU = new Cartesian3_default();
1261
+ var fromOrientedBoundingBoxScratchV = new Cartesian3_default();
1262
+ var fromOrientedBoundingBoxScratchW = new Cartesian3_default();
1263
+ var scratchFromTransformationCenter = new Cartesian3_default();
1264
+ var scratchFromTransformationScale = new Cartesian3_default();
1265
+ var unionScratch = new Cartesian3_default();
1266
+ var unionScratchCenter = new Cartesian3_default();
1267
+ var expandScratch = new Cartesian3_default();
1268
+ var distanceSquaredToScratch = new Cartesian3_default();
1269
+ var scratchCartesian3 = new Cartesian3_default();
1270
+ var projectTo2DNormalScratch = new Cartesian3_default();
1271
+ var projectTo2DEastScratch = new Cartesian3_default();
1272
+ var projectTo2DNorthScratch = new Cartesian3_default();
1273
+ var projectTo2DWestScratch = new Cartesian3_default();
1274
+ var projectTo2DSouthScratch = new Cartesian3_default();
1275
+ var projectTo2DCartographicScratch = new Cartographic_default();
1276
+ var projectTo2DPositionsScratch = new Array(8);
1277
+ for (let n = 0; n < 8; ++n) {
1278
+ projectTo2DPositionsScratch[n] = new Cartesian3_default();
1279
+ }
1280
+ var projectTo2DProjection = new GeographicProjection_default();
1281
+ var BoundingSphere_default = BoundingSphere;
1282
+
1283
+ export {
1284
+ GeographicProjection_default,
1285
+ Interval_default,
1286
+ BoundingSphere_default
1287
+ };