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.
- package/Build/Workers/chunk-2HWLF3FT.js +837 -0
- package/Build/Workers/chunk-2KXMJ5XS.js +3792 -0
- package/Build/Workers/chunk-2NPCLB3H.js +56 -0
- package/Build/Workers/chunk-2ZHQTIBH.js +1483 -0
- package/Build/Workers/chunk-3GLYOW63.js +352 -0
- package/Build/Workers/chunk-3L22KMPU.js +219 -0
- package/Build/Workers/chunk-3Q6V2B2I.js +73 -0
- package/Build/Workers/chunk-3QOKKRIG.js +387 -0
- package/Build/Workers/chunk-44YZFGRH.js +1800 -0
- package/Build/Workers/chunk-45VV4SBO.js +2342 -0
- package/Build/Workers/chunk-4EJ4AA2S.js +368 -0
- package/Build/Workers/chunk-4IJFHUL6.js +414 -0
- package/Build/Workers/chunk-4K3V5CGW.js +454 -0
- package/Build/Workers/chunk-4M4QL6KJ.js +305 -0
- package/Build/Workers/chunk-4YNRIEQ6.js +288 -0
- package/Build/Workers/chunk-56CVDPH5.js +352 -0
- package/Build/Workers/chunk-5CTAAPXH.js +1483 -0
- package/Build/Workers/chunk-5ISZ6NJD.js +102 -0
- package/Build/Workers/chunk-5SDHYIOS.js +56 -0
- package/Build/Workers/chunk-66TGUMCU.js +2719 -0
- package/Build/Workers/chunk-6EJMTDQJ.js +163 -0
- package/Build/Workers/chunk-6VWXYSMH.js +959 -0
- package/Build/Workers/chunk-6VZ7VB2Q.js +241 -0
- package/Build/Workers/chunk-7AMRE57Q.js +301 -0
- package/Build/Workers/chunk-7DH6C33H.js +398 -0
- package/Build/Workers/chunk-7VUS3FVE.js +38 -0
- package/Build/Workers/chunk-7Y3ZA6H3.js +198 -0
- package/Build/Workers/chunk-A6BMHZNA.js +38 -0
- package/Build/Workers/chunk-A7XY2MN7.js +171 -0
- package/Build/Workers/chunk-AC7ND63S.js +57 -0
- package/Build/Workers/chunk-AHCZ757M.js +9230 -0
- package/Build/Workers/chunk-ANOA7E7F.js +56 -0
- package/Build/Workers/chunk-AYO5HHV6.js +789 -0
- package/Build/Workers/chunk-BE2N56VZ.js +1344 -0
- package/Build/Workers/chunk-BR3BPM64.js +9230 -0
- package/Build/Workers/chunk-BVMRWGOK.js +455 -0
- package/Build/Workers/chunk-BXEL2NX7.js +455 -0
- package/Build/Workers/chunk-C5BO2JCG.js +278 -0
- package/Build/Workers/chunk-CIRQNZVR.js +301 -0
- package/Build/Workers/chunk-CM67CQME.js +305 -0
- package/Build/Workers/chunk-D3QIW4DH.js +630 -0
- package/Build/Workers/chunk-E5W7QIGZ.js +511 -0
- package/Build/Workers/chunk-E6CYGUJI.js +1054 -0
- package/Build/Workers/chunk-EIZ23IOX.js +414 -0
- package/Build/Workers/chunk-EIZJUMQY.js +101 -0
- package/Build/Workers/chunk-EXTMZJXB.js +82 -0
- package/Build/Workers/chunk-EYOOSIBW.js +682 -0
- package/Build/Workers/chunk-F37WADVC.js +1054 -0
- package/Build/Workers/chunk-FIWPJFHX.js +101 -0
- package/Build/Workers/chunk-FM32TNGT.js +198 -0
- package/Build/Workers/chunk-FOMYIEIB.js +476 -0
- package/Build/Workers/chunk-FWYDLSVQ.js +97 -0
- package/Build/Workers/chunk-HGZR6CZF.js +1067 -0
- package/Build/Workers/chunk-HIXHDABG.js +288 -0
- package/Build/Workers/chunk-HMCCZZWE.js +97 -0
- package/Build/Workers/chunk-HW54WHGM.js +2719 -0
- package/Build/Workers/chunk-IHYAI7GF.js +973 -0
- package/Build/Workers/chunk-INLQ7LVK.js +837 -0
- package/Build/Workers/chunk-IQMESTCB.js +124 -0
- package/Build/Workers/chunk-J4PISUNT.js +2342 -0
- package/Build/Workers/chunk-JSWU557I.js +693 -0
- package/Build/Workers/chunk-KHONDSQ7.js +693 -0
- package/Build/Workers/chunk-KLUL2SOE.js +352 -0
- package/Build/Workers/chunk-KMBLKQCC.js +1992 -0
- package/Build/Workers/chunk-KOTWWQN7.js +171 -0
- package/Build/Workers/chunk-KWV6ZTF4.js +163 -0
- package/Build/Workers/chunk-LSEFPQHG.js +476 -0
- package/Build/Workers/chunk-M66X4O24.js +44 -0
- package/Build/Workers/chunk-M6IXKBC7.js +1992 -0
- package/Build/Workers/chunk-MFUC3D5C.js +162 -0
- package/Build/Workers/chunk-MRMNELAH.js +82 -0
- package/Build/Workers/chunk-N3NUA5H2.js +3792 -0
- package/Build/Workers/chunk-NFB2NXJN.js +138 -0
- package/Build/Workers/chunk-NQAXBK4K.js +789 -0
- package/Build/Workers/chunk-NUGQWV6S.js +352 -0
- package/Build/Workers/chunk-O7S7WL7K.js +278 -0
- package/Build/Workers/chunk-ODZYB26X.js +1287 -0
- package/Build/Workers/chunk-OEHJY463.js +3201 -0
- package/Build/Workers/chunk-OMMRNMXF.js +44 -0
- package/Build/Workers/chunk-OZ3CQDO3.js +138 -0
- package/Build/Workers/chunk-PNXBG64I.js +219 -0
- package/Build/Workers/chunk-PYR35GK4.js +973 -0
- package/Build/Workers/chunk-Q4CXGW74.js +57 -0
- package/Build/Workers/chunk-QGISLKCW.js +147 -0
- package/Build/Workers/chunk-QQHVOJW6.js +497 -0
- package/Build/Workers/chunk-QWCMMRJW.js +58 -0
- package/Build/Workers/chunk-RDEZCHF4.js +398 -0
- package/Build/Workers/chunk-SJTE7FVN.js +778 -0
- package/Build/Workers/chunk-SM5T67LR.js +162 -0
- package/Build/Workers/chunk-T27NNXEU.js +58 -0
- package/Build/Workers/chunk-T4J5BWUO.js +511 -0
- package/Build/Workers/chunk-T6JS4BRN.js +140 -0
- package/Build/Workers/chunk-UH6DUQBW.js +140 -0
- package/Build/Workers/chunk-UJAH6XKF.js +73 -0
- package/Build/Workers/chunk-UKSTJ2PH.js +454 -0
- package/Build/Workers/chunk-UQCDCCZ7.js +368 -0
- package/Build/Workers/chunk-UXIFNEA3.js +1287 -0
- package/Build/Workers/chunk-UXJ6J5L7.js +56 -0
- package/Build/Workers/chunk-V4VUAZXI.js +1800 -0
- package/Build/Workers/chunk-VQH2YXO2.js +497 -0
- package/Build/Workers/chunk-VXKCLSE4.js +241 -0
- package/Build/Workers/chunk-W3U6YBEI.js +280 -0
- package/Build/Workers/chunk-W75ZVFKP.js +778 -0
- package/Build/Workers/chunk-WCDFJYFB.js +1344 -0
- package/Build/Workers/chunk-WME5M6W3.js +630 -0
- package/Build/Workers/chunk-XDQBQB64.js +1067 -0
- package/Build/Workers/chunk-Y6HOIWE5.js +959 -0
- package/Build/Workers/chunk-YEMC2ZOR.js +147 -0
- package/Build/Workers/chunk-YWNF3TPE.js +682 -0
- package/Build/Workers/chunk-Z55VGWJP.js +280 -0
- package/Build/Workers/chunk-Z5YWP24C.js +124 -0
- package/Build/Workers/chunk-ZHXCWUJB.js +387 -0
- package/Build/Workers/chunk-ZIMPUF2I.js +102 -0
- package/Build/Workers/chunk-ZKDWYQKC.js +3201 -0
- package/Build/Workers/combineGeometry.js +24 -22
- package/Build/Workers/createBoxGeometry.js +18 -16
- package/Build/Workers/createBoxOutlineGeometry.js +23 -25
- package/Build/Workers/createCircleGeometry.js +29 -27
- package/Build/Workers/createCircleOutlineGeometry.js +22 -20
- package/Build/Workers/createCoplanarPolygonGeometry.js +43 -43
- package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +37 -35
- package/Build/Workers/createCorridorGeometry.js +46 -49
- package/Build/Workers/createCorridorOutlineGeometry.js +40 -43
- package/Build/Workers/createCylinderGeometry.js +20 -18
- package/Build/Workers/createCylinderOutlineGeometry.js +27 -25
- package/Build/Workers/createEllipseGeometry.js +28 -25
- package/Build/Workers/createEllipseOutlineGeometry.js +21 -18
- package/Build/Workers/createEllipsoidGeometry.js +19 -17
- package/Build/Workers/createEllipsoidOutlineGeometry.js +18 -16
- package/Build/Workers/createFrustumGeometry.js +18 -16
- package/Build/Workers/createFrustumOutlineGeometry.js +21 -21
- package/Build/Workers/createGeometry.js +31 -26
- package/Build/Workers/createGroundPolylineGeometry.js +188 -135
- package/Build/Workers/createPlaneGeometry.js +22 -21
- package/Build/Workers/createPlaneOutlineGeometry.js +15 -13
- package/Build/Workers/createPolygonGeometry.js +51 -52
- package/Build/Workers/createPolygonOutlineGeometry.js +43 -44
- package/Build/Workers/createPolylineGeometry.js +37 -40
- package/Build/Workers/createPolylineVolumeGeometry.js +41 -44
- package/Build/Workers/createPolylineVolumeOutlineGeometry.js +36 -39
- package/Build/Workers/createRectangleGeometry.js +47 -53
- package/Build/Workers/createRectangleOutlineGeometry.js +32 -33
- package/Build/Workers/createSimplePolylineGeometry.js +33 -34
- package/Build/Workers/createSphereGeometry.js +20 -20
- package/Build/Workers/createSphereOutlineGeometry.js +19 -19
- package/Build/Workers/createTaskProcessorWorker.js +3 -3
- package/Build/Workers/createVectorTileClampedPolylines.js +16 -14
- package/Build/Workers/createVectorTileGeometries.js +24 -22
- package/Build/Workers/createVectorTilePoints.js +15 -13
- package/Build/Workers/createVectorTilePolygons.js +24 -21
- package/Build/Workers/createVectorTilePolylines.js +16 -14
- package/Build/Workers/createVerticesFromCesium3DTilesTerrain.js +25 -25
- package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +29 -27
- package/Build/Workers/createVerticesFromHeightmap.js +42 -63
- package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +26 -280
- package/Build/Workers/createWallGeometry.js +35 -36
- package/Build/Workers/createWallOutlineGeometry.js +33 -34
- package/Build/Workers/decodeDraco.js +10 -11
- package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +5 -5
- package/Build/Workers/decodeI3S.js +16 -20
- package/Build/Workers/gaussianSplatSorter.js +4 -4
- package/Build/Workers/gaussianSplatTextureGenerator.js +4 -4
- package/Build/Workers/incrementallyBuildTerrainPicker.js +20 -12
- package/Build/Workers/transcodeKTX2.js +42 -14
- package/Build/Workers/transferTypedArrayTest.js +1 -1
- package/Build/Workers/upsampleQuantizedTerrainMesh.js +24 -21
- package/Build/Workers/upsampleVerticesFromCesium3DTilesTerrain.js +25 -25
- package/Source/Shaders/BillboardCollectionFS.js +85 -81
- package/Source/Shaders/BillboardCollectionVS.js +60 -118
- package/Source/Shaders/Builtin/Constants/passCesium3DTile.js +1 -1
- package/Source/Shaders/Builtin/Constants/passCesium3DTileClassification.js +1 -1
- package/Source/Shaders/Builtin/Constants/passCesium3DTileClassificationIgnoreShow.js +1 -1
- package/Source/Shaders/Builtin/Constants/passCesium3DTileEdges.js +12 -0
- package/Source/Shaders/Builtin/Constants/passCesium3DTileEdgesDirect.js +11 -0
- package/Source/Shaders/Builtin/Constants/passGaussianSplats.js +11 -0
- package/Source/Shaders/Builtin/Constants/passOpaque.js +1 -1
- package/Source/Shaders/Builtin/Constants/passOverlay.js +1 -1
- package/Source/Shaders/Builtin/Constants/passTranslucent.js +1 -1
- package/Source/Shaders/Builtin/Constants/passVoxels.js +1 -1
- package/Source/Shaders/Builtin/CzmBuiltins.js +12 -0
- package/Source/Shaders/Builtin/Functions/columbusViewMorph.js +8 -1
- package/Source/Shaders/Builtin/Functions/computeTextureTransform.js +25 -0
- package/Source/Shaders/Builtin/Functions/decodeRGB8.js +24 -0
- package/Source/Shaders/Builtin/Functions/modelToWindowCoordinates.js +2 -1
- package/Source/Shaders/Builtin/Functions/unpackTexture.js +37 -0
- package/Source/Shaders/Builtin/Functions/windowToEyeCoordinates.js +0 -1
- package/Source/Shaders/EllipsoidVS.js +4 -4
- package/Source/Shaders/FXAA3_11.js +2 -0
- package/Source/Shaders/GlobeFS.js +22 -0
- package/Source/Shaders/GlobeVS.js +3 -2
- package/Source/Shaders/Model/MaterialStageFS.js +50 -20
- package/Source/Shaders/Model/MetadataStageFS.js +2 -1
- package/Source/Shaders/Model/MetadataStageVS.js +2 -1
- package/Source/Shaders/Model/ModelFS.js +32 -2
- package/Source/Shaders/Model/ModelVS.js +15 -1
- package/Source/Shaders/Model/PointCloudStylingStageVS.js +2 -1
- package/Source/Shaders/Model/PrimitiveOutlineStageFS.js +0 -1
- package/Source/Shaders/PointPrimitiveCollectionVS.js +8 -39
- package/Source/Shaders/PolygonSignedDistanceFS.js +64 -33
- package/Source/Shaders/PolylineCommon.js +1 -1
- package/Source/Shaders/ShadowVolumeAppearanceFS.js +7 -15
- package/Source/Shaders/SkyAtmosphereVS.js +2 -1
- package/Source/Shaders/Voxels/IntersectBox.js +20 -33
- package/Source/Shaders/Voxels/IntersectCylinder.js +28 -32
- package/Source/Shaders/Voxels/IntersectDepth.js +10 -6
- package/Source/Shaders/Voxels/IntersectEllipsoid.js +12 -20
- package/Source/Shaders/Voxels/IntersectLongitude.js +21 -9
- package/Source/Shaders/Voxels/Intersection.js +3 -5
- package/Source/Shaders/Voxels/IntersectionUtils.js +2 -1
- package/Source/Shaders/Voxels/Megatexture.js +15 -83
- package/Source/Shaders/Voxels/Octree.js +53 -61
- package/Source/Shaders/Voxels/VoxelFS.js +67 -52
- package/Source/Shaders/Voxels/VoxelUtils.js +0 -19
- package/index.js +346 -261
- package/package.json +1 -1
- package/Source/Shaders/Voxels/IntersectClippingPlanes.js +0 -80
- package/Source/Shaders/Voxels/convertUvToBox.js +0 -46
- package/Source/Shaders/Voxels/convertUvToCylinder.js +0 -101
- package/Source/Shaders/Voxels/convertUvToEllipsoid.js +0 -141
|
@@ -0,0 +1,1992 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Cesium - https://github.com/CesiumGS/cesium
|
|
4
|
+
* Version 0.1.4
|
|
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
|
+
Cartesian3_default
|
|
28
|
+
} from "./chunk-J4PISUNT.js";
|
|
29
|
+
import {
|
|
30
|
+
Math_default
|
|
31
|
+
} from "./chunk-VQH2YXO2.js";
|
|
32
|
+
import {
|
|
33
|
+
Check_default,
|
|
34
|
+
DeveloperError_default
|
|
35
|
+
} from "./chunk-KWV6ZTF4.js";
|
|
36
|
+
import {
|
|
37
|
+
__publicField,
|
|
38
|
+
defined_default
|
|
39
|
+
} from "./chunk-MRMNELAH.js";
|
|
40
|
+
|
|
41
|
+
// packages/engine/Source/Core/scaleToGeodeticSurface.js
|
|
42
|
+
var scaleToGeodeticSurfaceIntersection = new Cartesian3_default();
|
|
43
|
+
var scaleToGeodeticSurfaceGradient = new Cartesian3_default();
|
|
44
|
+
function scaleToGeodeticSurface(cartesian, oneOverRadii, oneOverRadiiSquared, centerToleranceSquared, result) {
|
|
45
|
+
if (!defined_default(cartesian)) {
|
|
46
|
+
throw new DeveloperError_default("cartesian is required.");
|
|
47
|
+
}
|
|
48
|
+
if (!defined_default(oneOverRadii)) {
|
|
49
|
+
throw new DeveloperError_default("oneOverRadii is required.");
|
|
50
|
+
}
|
|
51
|
+
if (!defined_default(oneOverRadiiSquared)) {
|
|
52
|
+
throw new DeveloperError_default("oneOverRadiiSquared is required.");
|
|
53
|
+
}
|
|
54
|
+
if (!defined_default(centerToleranceSquared)) {
|
|
55
|
+
throw new DeveloperError_default("centerToleranceSquared is required.");
|
|
56
|
+
}
|
|
57
|
+
const positionX = cartesian.x;
|
|
58
|
+
const positionY = cartesian.y;
|
|
59
|
+
const positionZ = cartesian.z;
|
|
60
|
+
const oneOverRadiiX = oneOverRadii.x;
|
|
61
|
+
const oneOverRadiiY = oneOverRadii.y;
|
|
62
|
+
const oneOverRadiiZ = oneOverRadii.z;
|
|
63
|
+
const x2 = positionX * positionX * oneOverRadiiX * oneOverRadiiX;
|
|
64
|
+
const y2 = positionY * positionY * oneOverRadiiY * oneOverRadiiY;
|
|
65
|
+
const z2 = positionZ * positionZ * oneOverRadiiZ * oneOverRadiiZ;
|
|
66
|
+
const squaredNorm = x2 + y2 + z2;
|
|
67
|
+
const ratio = Math.sqrt(1 / squaredNorm);
|
|
68
|
+
const intersection = Cartesian3_default.multiplyByScalar(
|
|
69
|
+
cartesian,
|
|
70
|
+
ratio,
|
|
71
|
+
scaleToGeodeticSurfaceIntersection
|
|
72
|
+
);
|
|
73
|
+
if (squaredNorm < centerToleranceSquared) {
|
|
74
|
+
return !isFinite(ratio) ? void 0 : Cartesian3_default.clone(intersection, result);
|
|
75
|
+
}
|
|
76
|
+
const oneOverRadiiSquaredX = oneOverRadiiSquared.x;
|
|
77
|
+
const oneOverRadiiSquaredY = oneOverRadiiSquared.y;
|
|
78
|
+
const oneOverRadiiSquaredZ = oneOverRadiiSquared.z;
|
|
79
|
+
const gradient = scaleToGeodeticSurfaceGradient;
|
|
80
|
+
gradient.x = intersection.x * oneOverRadiiSquaredX * 2;
|
|
81
|
+
gradient.y = intersection.y * oneOverRadiiSquaredY * 2;
|
|
82
|
+
gradient.z = intersection.z * oneOverRadiiSquaredZ * 2;
|
|
83
|
+
let lambda = (1 - ratio) * Cartesian3_default.magnitude(cartesian) / (0.5 * Cartesian3_default.magnitude(gradient));
|
|
84
|
+
let correction = 0;
|
|
85
|
+
let func;
|
|
86
|
+
let denominator;
|
|
87
|
+
let xMultiplier;
|
|
88
|
+
let yMultiplier;
|
|
89
|
+
let zMultiplier;
|
|
90
|
+
let xMultiplier2;
|
|
91
|
+
let yMultiplier2;
|
|
92
|
+
let zMultiplier2;
|
|
93
|
+
let xMultiplier3;
|
|
94
|
+
let yMultiplier3;
|
|
95
|
+
let zMultiplier3;
|
|
96
|
+
do {
|
|
97
|
+
lambda -= correction;
|
|
98
|
+
xMultiplier = 1 / (1 + lambda * oneOverRadiiSquaredX);
|
|
99
|
+
yMultiplier = 1 / (1 + lambda * oneOverRadiiSquaredY);
|
|
100
|
+
zMultiplier = 1 / (1 + lambda * oneOverRadiiSquaredZ);
|
|
101
|
+
xMultiplier2 = xMultiplier * xMultiplier;
|
|
102
|
+
yMultiplier2 = yMultiplier * yMultiplier;
|
|
103
|
+
zMultiplier2 = zMultiplier * zMultiplier;
|
|
104
|
+
xMultiplier3 = xMultiplier2 * xMultiplier;
|
|
105
|
+
yMultiplier3 = yMultiplier2 * yMultiplier;
|
|
106
|
+
zMultiplier3 = zMultiplier2 * zMultiplier;
|
|
107
|
+
func = x2 * xMultiplier2 + y2 * yMultiplier2 + z2 * zMultiplier2 - 1;
|
|
108
|
+
denominator = x2 * xMultiplier3 * oneOverRadiiSquaredX + y2 * yMultiplier3 * oneOverRadiiSquaredY + z2 * zMultiplier3 * oneOverRadiiSquaredZ;
|
|
109
|
+
const derivative = -2 * denominator;
|
|
110
|
+
correction = func / derivative;
|
|
111
|
+
} while (Math.abs(func) > Math_default.EPSILON12);
|
|
112
|
+
if (!defined_default(result)) {
|
|
113
|
+
return new Cartesian3_default(
|
|
114
|
+
positionX * xMultiplier,
|
|
115
|
+
positionY * yMultiplier,
|
|
116
|
+
positionZ * zMultiplier
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
result.x = positionX * xMultiplier;
|
|
120
|
+
result.y = positionY * yMultiplier;
|
|
121
|
+
result.z = positionZ * zMultiplier;
|
|
122
|
+
return result;
|
|
123
|
+
}
|
|
124
|
+
var scaleToGeodeticSurface_default = scaleToGeodeticSurface;
|
|
125
|
+
|
|
126
|
+
// packages/engine/Source/Core/Cartographic.js
|
|
127
|
+
var _Cartographic = class _Cartographic {
|
|
128
|
+
/**
|
|
129
|
+
* @param {number} [longitude=0.0] The longitude, in radians.
|
|
130
|
+
* @param {number} [latitude=0.0] The latitude, in radians.
|
|
131
|
+
* @param {number} [height=0.0] The height, in meters, above the ellipsoid.
|
|
132
|
+
*/
|
|
133
|
+
constructor(longitude, latitude, height) {
|
|
134
|
+
this.longitude = longitude ?? 0;
|
|
135
|
+
this.latitude = latitude ?? 0;
|
|
136
|
+
this.height = height ?? 0;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Creates a new Cartographic instance from longitude and latitude
|
|
140
|
+
* specified in radians.
|
|
141
|
+
*
|
|
142
|
+
* @param {number} longitude The longitude, in radians.
|
|
143
|
+
* @param {number} latitude The latitude, in radians.
|
|
144
|
+
* @param {number} [height=0.0] The height, in meters, above the ellipsoid.
|
|
145
|
+
* @param {Cartographic} [result] The object onto which to store the result.
|
|
146
|
+
* @returns {Cartographic} The modified result parameter or a new Cartographic instance if one was not provided.
|
|
147
|
+
*/
|
|
148
|
+
static fromRadians(longitude, latitude, height, result) {
|
|
149
|
+
Check_default.typeOf.number("longitude", longitude);
|
|
150
|
+
Check_default.typeOf.number("latitude", latitude);
|
|
151
|
+
height = height ?? 0;
|
|
152
|
+
if (!defined_default(result)) {
|
|
153
|
+
return new _Cartographic(longitude, latitude, height);
|
|
154
|
+
}
|
|
155
|
+
result.longitude = longitude;
|
|
156
|
+
result.latitude = latitude;
|
|
157
|
+
result.height = height;
|
|
158
|
+
return result;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Creates a new Cartographic instance from longitude and latitude
|
|
162
|
+
* specified in degrees. The values in the resulting object will
|
|
163
|
+
* be in radians.
|
|
164
|
+
*
|
|
165
|
+
* @param {number} longitude The longitude, in degrees.
|
|
166
|
+
* @param {number} latitude The latitude, in degrees.
|
|
167
|
+
* @param {number} [height=0.0] The height, in meters, above the ellipsoid.
|
|
168
|
+
* @param {Cartographic} [result] The object onto which to store the result.
|
|
169
|
+
* @returns {Cartographic} The modified result parameter or a new Cartographic instance if one was not provided.
|
|
170
|
+
*/
|
|
171
|
+
static fromDegrees(longitude, latitude, height, result) {
|
|
172
|
+
Check_default.typeOf.number("longitude", longitude);
|
|
173
|
+
Check_default.typeOf.number("latitude", latitude);
|
|
174
|
+
longitude = Math_default.toRadians(longitude);
|
|
175
|
+
latitude = Math_default.toRadians(latitude);
|
|
176
|
+
return _Cartographic.fromRadians(longitude, latitude, height, result);
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Creates a new Cartographic instance from a Cartesian position. The values in the
|
|
180
|
+
* resulting object will be in radians.
|
|
181
|
+
*
|
|
182
|
+
* @param {Cartesian3} cartesian The Cartesian position to convert to cartographic representation.
|
|
183
|
+
* @param {Ellipsoid} [ellipsoid=Ellipsoid.default] The ellipsoid on which the position lies.
|
|
184
|
+
* @param {Cartographic} [result] The object onto which to store the result.
|
|
185
|
+
* @returns {Cartographic} The modified result parameter, new Cartographic instance if none was provided, or undefined if the cartesian is at the center of the ellipsoid.
|
|
186
|
+
*/
|
|
187
|
+
static fromCartesian(cartesian, ellipsoid, result) {
|
|
188
|
+
const oneOverRadii = defined_default(ellipsoid) ? ellipsoid.oneOverRadii : _Cartographic._ellipsoidOneOverRadii;
|
|
189
|
+
const oneOverRadiiSquared = defined_default(ellipsoid) ? ellipsoid.oneOverRadiiSquared : _Cartographic._ellipsoidOneOverRadiiSquared;
|
|
190
|
+
const centerToleranceSquared = defined_default(ellipsoid) ? ellipsoid._centerToleranceSquared : _Cartographic._ellipsoidCenterToleranceSquared;
|
|
191
|
+
const p = scaleToGeodeticSurface_default(
|
|
192
|
+
cartesian,
|
|
193
|
+
oneOverRadii,
|
|
194
|
+
oneOverRadiiSquared,
|
|
195
|
+
centerToleranceSquared,
|
|
196
|
+
cartesianToCartographicP
|
|
197
|
+
);
|
|
198
|
+
if (!defined_default(p)) {
|
|
199
|
+
return void 0;
|
|
200
|
+
}
|
|
201
|
+
let n = Cartesian3_default.multiplyComponents(
|
|
202
|
+
p,
|
|
203
|
+
oneOverRadiiSquared,
|
|
204
|
+
cartesianToCartographicN
|
|
205
|
+
);
|
|
206
|
+
n = Cartesian3_default.normalize(n, n);
|
|
207
|
+
const h = Cartesian3_default.subtract(cartesian, p, cartesianToCartographicH);
|
|
208
|
+
const longitude = Math.atan2(n.y, n.x);
|
|
209
|
+
const latitude = Math.asin(n.z);
|
|
210
|
+
const height = Math_default.sign(Cartesian3_default.dot(h, cartesian)) * Cartesian3_default.magnitude(h);
|
|
211
|
+
if (!defined_default(result)) {
|
|
212
|
+
return new _Cartographic(longitude, latitude, height);
|
|
213
|
+
}
|
|
214
|
+
result.longitude = longitude;
|
|
215
|
+
result.latitude = latitude;
|
|
216
|
+
result.height = height;
|
|
217
|
+
return result;
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Creates a new Cartesian3 instance from a Cartographic input. The values in the inputted
|
|
221
|
+
* object should be in radians.
|
|
222
|
+
*
|
|
223
|
+
* @param {Cartographic} cartographic Input to be converted into a Cartesian3 output.
|
|
224
|
+
* @param {Ellipsoid} [ellipsoid=Ellipsoid.default] The ellipsoid on which the position lies.
|
|
225
|
+
* @param {Cartesian3} [result] The object onto which to store the result.
|
|
226
|
+
* @returns {Cartesian3} The position
|
|
227
|
+
*/
|
|
228
|
+
static toCartesian(cartographic, ellipsoid, result) {
|
|
229
|
+
Check_default.defined("cartographic", cartographic);
|
|
230
|
+
return Cartesian3_default.fromRadians(
|
|
231
|
+
cartographic.longitude,
|
|
232
|
+
cartographic.latitude,
|
|
233
|
+
cartographic.height,
|
|
234
|
+
ellipsoid,
|
|
235
|
+
result
|
|
236
|
+
);
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Duplicates a Cartographic instance.
|
|
240
|
+
*
|
|
241
|
+
* @param {Cartographic} cartographic The cartographic to duplicate.
|
|
242
|
+
* @param {Cartographic} [result] The object onto which to store the result.
|
|
243
|
+
* @returns {Cartographic} The modified result parameter or a new Cartographic instance if one was not provided. (Returns undefined if cartographic is undefined)
|
|
244
|
+
*/
|
|
245
|
+
static clone(cartographic, result) {
|
|
246
|
+
if (!defined_default(cartographic)) {
|
|
247
|
+
return void 0;
|
|
248
|
+
}
|
|
249
|
+
if (!defined_default(result)) {
|
|
250
|
+
return new _Cartographic(
|
|
251
|
+
cartographic.longitude,
|
|
252
|
+
cartographic.latitude,
|
|
253
|
+
cartographic.height
|
|
254
|
+
);
|
|
255
|
+
}
|
|
256
|
+
result.longitude = cartographic.longitude;
|
|
257
|
+
result.latitude = cartographic.latitude;
|
|
258
|
+
result.height = cartographic.height;
|
|
259
|
+
return result;
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Compares the provided cartographics componentwise and returns
|
|
263
|
+
* <code>true</code> if they are equal, <code>false</code> otherwise.
|
|
264
|
+
*
|
|
265
|
+
* @param {Cartographic} [left] The first cartographic.
|
|
266
|
+
* @param {Cartographic} [right] The second cartographic.
|
|
267
|
+
* @returns {boolean} <code>true</code> if left and right are equal, <code>false</code> otherwise.
|
|
268
|
+
*/
|
|
269
|
+
static equals(left, right) {
|
|
270
|
+
return left === right || defined_default(left) && defined_default(right) && left.longitude === right.longitude && left.latitude === right.latitude && left.height === right.height;
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Compares the provided cartographics componentwise and returns
|
|
274
|
+
* <code>true</code> if they are within the provided epsilon,
|
|
275
|
+
* <code>false</code> otherwise.
|
|
276
|
+
*
|
|
277
|
+
* @param {Cartographic} [left] The first cartographic.
|
|
278
|
+
* @param {Cartographic} [right] The second cartographic.
|
|
279
|
+
* @param {number} [epsilon=0] The epsilon to use for equality testing.
|
|
280
|
+
* @returns {boolean} <code>true</code> if left and right are within the provided epsilon, <code>false</code> otherwise.
|
|
281
|
+
*/
|
|
282
|
+
static equalsEpsilon(left, right, epsilon) {
|
|
283
|
+
epsilon = epsilon ?? 0;
|
|
284
|
+
return left === right || defined_default(left) && defined_default(right) && Math.abs(left.longitude - right.longitude) <= epsilon && Math.abs(left.latitude - right.latitude) <= epsilon && Math.abs(left.height - right.height) <= epsilon;
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Duplicates this instance.
|
|
288
|
+
*
|
|
289
|
+
* @param {Cartographic} [result] The object onto which to store the result.
|
|
290
|
+
* @returns {Cartographic} The modified result parameter or a new Cartographic instance if one was not provided.
|
|
291
|
+
*/
|
|
292
|
+
clone(result) {
|
|
293
|
+
return _Cartographic.clone(this, result);
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Compares the provided against this cartographic componentwise and returns
|
|
297
|
+
* <code>true</code> if they are equal, <code>false</code> otherwise.
|
|
298
|
+
*
|
|
299
|
+
* @param {Cartographic} [right] The second cartographic.
|
|
300
|
+
* @returns {boolean} <code>true</code> if left and right are equal, <code>false</code> otherwise.
|
|
301
|
+
*/
|
|
302
|
+
equals(right) {
|
|
303
|
+
return _Cartographic.equals(this, right);
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Compares the provided against this cartographic componentwise and returns
|
|
307
|
+
* <code>true</code> if they are within the provided epsilon,
|
|
308
|
+
* <code>false</code> otherwise.
|
|
309
|
+
*
|
|
310
|
+
* @param {Cartographic} [right] The second cartographic.
|
|
311
|
+
* @param {number} [epsilon=0] The epsilon to use for equality testing.
|
|
312
|
+
* @returns {boolean} <code>true</code> if left and right are within the provided epsilon, <code>false</code> otherwise.
|
|
313
|
+
*/
|
|
314
|
+
equalsEpsilon(right, epsilon) {
|
|
315
|
+
return _Cartographic.equalsEpsilon(this, right, epsilon);
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Creates a string representing this cartographic in the format '(longitude, latitude, height)'.
|
|
319
|
+
*
|
|
320
|
+
* @returns {string} A string representing the provided cartographic in the format '(longitude, latitude, height)'.
|
|
321
|
+
*/
|
|
322
|
+
toString() {
|
|
323
|
+
return `(${this.longitude}, ${this.latitude}, ${this.height})`;
|
|
324
|
+
}
|
|
325
|
+
};
|
|
326
|
+
// To avoid circular dependencies, these are set by Ellipsoid when Ellipsoid.default is set.
|
|
327
|
+
__publicField(_Cartographic, "_ellipsoidOneOverRadii", new Cartesian3_default(
|
|
328
|
+
1 / 6378137,
|
|
329
|
+
1 / 6378137,
|
|
330
|
+
1 / 6356752314245179e-9
|
|
331
|
+
));
|
|
332
|
+
__publicField(_Cartographic, "_ellipsoidOneOverRadiiSquared", new Cartesian3_default(
|
|
333
|
+
1 / (6378137 * 6378137),
|
|
334
|
+
1 / (6378137 * 6378137),
|
|
335
|
+
1 / (6356752314245179e-9 * 6356752314245179e-9)
|
|
336
|
+
));
|
|
337
|
+
__publicField(_Cartographic, "_ellipsoidCenterToleranceSquared", Math_default.EPSILON1);
|
|
338
|
+
var Cartographic = _Cartographic;
|
|
339
|
+
Cartographic.ZERO = Object.freeze(new Cartographic(0, 0, 0));
|
|
340
|
+
var cartesianToCartographicN = new Cartesian3_default();
|
|
341
|
+
var cartesianToCartographicP = new Cartesian3_default();
|
|
342
|
+
var cartesianToCartographicH = new Cartesian3_default();
|
|
343
|
+
var Cartographic_default = Cartographic;
|
|
344
|
+
|
|
345
|
+
// packages/engine/Source/Core/Cartesian2.js
|
|
346
|
+
var Cartesian2 = class _Cartesian2 {
|
|
347
|
+
/**
|
|
348
|
+
* @param {number} [x=0.0] The X component.
|
|
349
|
+
* @param {number} [y=0.0] The Y component.
|
|
350
|
+
*/
|
|
351
|
+
constructor(x, y) {
|
|
352
|
+
this.x = x ?? 0;
|
|
353
|
+
this.y = y ?? 0;
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* Creates a Cartesian2 instance from x and y coordinates.
|
|
357
|
+
*
|
|
358
|
+
* @param {number} x The x coordinate.
|
|
359
|
+
* @param {number} y The y coordinate.
|
|
360
|
+
* @param {Cartesian2} [result] The object onto which to store the result.
|
|
361
|
+
* @returns {Cartesian2} The modified result parameter or a new Cartesian2 instance if one was not provided.
|
|
362
|
+
*/
|
|
363
|
+
static fromElements(x, y, result) {
|
|
364
|
+
if (!defined_default(result)) {
|
|
365
|
+
return new _Cartesian2(x, y);
|
|
366
|
+
}
|
|
367
|
+
result.x = x;
|
|
368
|
+
result.y = y;
|
|
369
|
+
return result;
|
|
370
|
+
}
|
|
371
|
+
/**
|
|
372
|
+
* Duplicates a Cartesian2 instance.
|
|
373
|
+
*
|
|
374
|
+
* @param {Cartesian2} cartesian The Cartesian to duplicate.
|
|
375
|
+
* @param {Cartesian2} [result] The object onto which to store the result.
|
|
376
|
+
* @returns {Cartesian2} The modified result parameter or a new Cartesian2 instance if one was not provided. (Returns undefined if cartesian is undefined)
|
|
377
|
+
*/
|
|
378
|
+
static clone(cartesian, result) {
|
|
379
|
+
if (!defined_default(cartesian)) {
|
|
380
|
+
return void 0;
|
|
381
|
+
}
|
|
382
|
+
if (!defined_default(result)) {
|
|
383
|
+
return new _Cartesian2(cartesian.x, cartesian.y);
|
|
384
|
+
}
|
|
385
|
+
result.x = cartesian.x;
|
|
386
|
+
result.y = cartesian.y;
|
|
387
|
+
return result;
|
|
388
|
+
}
|
|
389
|
+
/**
|
|
390
|
+
* Stores the provided instance into the provided array.
|
|
391
|
+
*
|
|
392
|
+
* @param {Cartesian2} value The value to pack.
|
|
393
|
+
* @param {number[]} array The array to pack into.
|
|
394
|
+
* @param {number} [startingIndex=0] The index into the array at which to start packing the elements.
|
|
395
|
+
*
|
|
396
|
+
* @returns {number[]} The array that was packed into
|
|
397
|
+
*/
|
|
398
|
+
static pack(value, array, startingIndex) {
|
|
399
|
+
Check_default.typeOf.object("value", value);
|
|
400
|
+
Check_default.defined("array", array);
|
|
401
|
+
startingIndex = startingIndex ?? 0;
|
|
402
|
+
array[startingIndex++] = value.x;
|
|
403
|
+
array[startingIndex] = value.y;
|
|
404
|
+
return array;
|
|
405
|
+
}
|
|
406
|
+
/**
|
|
407
|
+
* Retrieves an instance from a packed array.
|
|
408
|
+
*
|
|
409
|
+
* @param {number[]} array The packed array.
|
|
410
|
+
* @param {number} [startingIndex=0] The starting index of the element to be unpacked.
|
|
411
|
+
* @param {Cartesian2} [result] The object into which to store the result.
|
|
412
|
+
* @returns {Cartesian2} The modified result parameter or a new Cartesian2 instance if one was not provided.
|
|
413
|
+
*/
|
|
414
|
+
static unpack(array, startingIndex, result) {
|
|
415
|
+
Check_default.defined("array", array);
|
|
416
|
+
startingIndex = startingIndex ?? 0;
|
|
417
|
+
if (!defined_default(result)) {
|
|
418
|
+
result = new _Cartesian2();
|
|
419
|
+
}
|
|
420
|
+
result.x = array[startingIndex++];
|
|
421
|
+
result.y = array[startingIndex];
|
|
422
|
+
return result;
|
|
423
|
+
}
|
|
424
|
+
/**
|
|
425
|
+
* Flattens an array of Cartesian2s into an array of components.
|
|
426
|
+
*
|
|
427
|
+
* @param {Cartesian2[]} array The array of cartesians to pack.
|
|
428
|
+
* @param {number[]} [result] The array onto which to store the result. If this is a typed array, it must have array.length * 2 components, else a {@link DeveloperError} will be thrown. If it is a regular array, it will be resized to have (array.length * 2) elements.
|
|
429
|
+
* @returns {number[]} The packed array.
|
|
430
|
+
*/
|
|
431
|
+
static packArray(array, result) {
|
|
432
|
+
Check_default.defined("array", array);
|
|
433
|
+
const length = array.length;
|
|
434
|
+
const resultLength = length * 2;
|
|
435
|
+
if (!defined_default(result)) {
|
|
436
|
+
result = new Array(resultLength);
|
|
437
|
+
} else if (!Array.isArray(result) && result.length !== resultLength) {
|
|
438
|
+
throw new DeveloperError_default(
|
|
439
|
+
"If result is a typed array, it must have exactly array.length * 2 elements"
|
|
440
|
+
);
|
|
441
|
+
} else if (result.length !== resultLength) {
|
|
442
|
+
result.length = resultLength;
|
|
443
|
+
}
|
|
444
|
+
for (let i = 0; i < length; ++i) {
|
|
445
|
+
_Cartesian2.pack(array[i], result, i * 2);
|
|
446
|
+
}
|
|
447
|
+
return result;
|
|
448
|
+
}
|
|
449
|
+
/**
|
|
450
|
+
* Unpacks an array of cartesian components into an array of Cartesian2s.
|
|
451
|
+
*
|
|
452
|
+
* @param {number[]} array The array of components to unpack.
|
|
453
|
+
* @param {Cartesian2[]} [result] The array onto which to store the result.
|
|
454
|
+
* @returns {Cartesian2[]} The unpacked array.
|
|
455
|
+
*/
|
|
456
|
+
static unpackArray(array, result) {
|
|
457
|
+
Check_default.defined("array", array);
|
|
458
|
+
Check_default.typeOf.number.greaterThanOrEquals("array.length", array.length, 2);
|
|
459
|
+
if (array.length % 2 !== 0) {
|
|
460
|
+
throw new DeveloperError_default("array length must be a multiple of 2.");
|
|
461
|
+
}
|
|
462
|
+
const length = array.length;
|
|
463
|
+
if (!defined_default(result)) {
|
|
464
|
+
result = new Array(length / 2);
|
|
465
|
+
} else {
|
|
466
|
+
result.length = length / 2;
|
|
467
|
+
}
|
|
468
|
+
for (let i = 0; i < length; i += 2) {
|
|
469
|
+
const index = i / 2;
|
|
470
|
+
result[index] = _Cartesian2.unpack(array, i, result[index]);
|
|
471
|
+
}
|
|
472
|
+
return result;
|
|
473
|
+
}
|
|
474
|
+
/**
|
|
475
|
+
* Computes the value of the maximum component for the supplied Cartesian.
|
|
476
|
+
*
|
|
477
|
+
* @param {Cartesian2} cartesian The cartesian to use.
|
|
478
|
+
* @returns {number} The value of the maximum component.
|
|
479
|
+
*/
|
|
480
|
+
static maximumComponent(cartesian) {
|
|
481
|
+
Check_default.typeOf.object("cartesian", cartesian);
|
|
482
|
+
return Math.max(cartesian.x, cartesian.y);
|
|
483
|
+
}
|
|
484
|
+
/**
|
|
485
|
+
* Computes the value of the minimum component for the supplied Cartesian.
|
|
486
|
+
*
|
|
487
|
+
* @param {Cartesian2} cartesian The cartesian to use.
|
|
488
|
+
* @returns {number} The value of the minimum component.
|
|
489
|
+
*/
|
|
490
|
+
static minimumComponent(cartesian) {
|
|
491
|
+
Check_default.typeOf.object("cartesian", cartesian);
|
|
492
|
+
return Math.min(cartesian.x, cartesian.y);
|
|
493
|
+
}
|
|
494
|
+
/**
|
|
495
|
+
* Compares two Cartesians and computes a Cartesian which contains the minimum components of the supplied Cartesians.
|
|
496
|
+
*
|
|
497
|
+
* @param {Cartesian2} first A cartesian to compare.
|
|
498
|
+
* @param {Cartesian2} second A cartesian to compare.
|
|
499
|
+
* @param {Cartesian2} result The object into which to store the result.
|
|
500
|
+
* @returns {Cartesian2} A cartesian with the minimum components.
|
|
501
|
+
*/
|
|
502
|
+
static minimumByComponent(first, second, result) {
|
|
503
|
+
Check_default.typeOf.object("first", first);
|
|
504
|
+
Check_default.typeOf.object("second", second);
|
|
505
|
+
Check_default.typeOf.object("result", result);
|
|
506
|
+
result.x = Math.min(first.x, second.x);
|
|
507
|
+
result.y = Math.min(first.y, second.y);
|
|
508
|
+
return result;
|
|
509
|
+
}
|
|
510
|
+
/**
|
|
511
|
+
* Compares two Cartesians and computes a Cartesian which contains the maximum components of the supplied Cartesians.
|
|
512
|
+
*
|
|
513
|
+
* @param {Cartesian2} first A cartesian to compare.
|
|
514
|
+
* @param {Cartesian2} second A cartesian to compare.
|
|
515
|
+
* @param {Cartesian2} result The object into which to store the result.
|
|
516
|
+
* @returns {Cartesian2} A cartesian with the maximum components.
|
|
517
|
+
*/
|
|
518
|
+
static maximumByComponent(first, second, result) {
|
|
519
|
+
Check_default.typeOf.object("first", first);
|
|
520
|
+
Check_default.typeOf.object("second", second);
|
|
521
|
+
Check_default.typeOf.object("result", result);
|
|
522
|
+
result.x = Math.max(first.x, second.x);
|
|
523
|
+
result.y = Math.max(first.y, second.y);
|
|
524
|
+
return result;
|
|
525
|
+
}
|
|
526
|
+
/**
|
|
527
|
+
* Constrain a value to lie between two values.
|
|
528
|
+
*
|
|
529
|
+
* @param {Cartesian2} value The value to clamp.
|
|
530
|
+
* @param {Cartesian2} min The minimum bound.
|
|
531
|
+
* @param {Cartesian2} max The maximum bound.
|
|
532
|
+
* @param {Cartesian2} result The object into which to store the result.
|
|
533
|
+
* @returns {Cartesian2} The clamped value such that min <= result <= max.
|
|
534
|
+
*/
|
|
535
|
+
static clamp(value, min, max, result) {
|
|
536
|
+
Check_default.typeOf.object("value", value);
|
|
537
|
+
Check_default.typeOf.object("min", min);
|
|
538
|
+
Check_default.typeOf.object("max", max);
|
|
539
|
+
Check_default.typeOf.object("result", result);
|
|
540
|
+
const x = Math_default.clamp(value.x, min.x, max.x);
|
|
541
|
+
const y = Math_default.clamp(value.y, min.y, max.y);
|
|
542
|
+
result.x = x;
|
|
543
|
+
result.y = y;
|
|
544
|
+
return result;
|
|
545
|
+
}
|
|
546
|
+
/**
|
|
547
|
+
* Computes the provided Cartesian's squared magnitude.
|
|
548
|
+
*
|
|
549
|
+
* @param {Cartesian2} cartesian The Cartesian instance whose squared magnitude is to be computed.
|
|
550
|
+
* @returns {number} The squared magnitude.
|
|
551
|
+
*/
|
|
552
|
+
static magnitudeSquared(cartesian) {
|
|
553
|
+
Check_default.typeOf.object("cartesian", cartesian);
|
|
554
|
+
return cartesian.x * cartesian.x + cartesian.y * cartesian.y;
|
|
555
|
+
}
|
|
556
|
+
/**
|
|
557
|
+
* Computes the Cartesian's magnitude (length).
|
|
558
|
+
*
|
|
559
|
+
* @param {Cartesian2} cartesian The Cartesian instance whose magnitude is to be computed.
|
|
560
|
+
* @returns {number} The magnitude.
|
|
561
|
+
*/
|
|
562
|
+
static magnitude(cartesian) {
|
|
563
|
+
return Math.sqrt(_Cartesian2.magnitudeSquared(cartesian));
|
|
564
|
+
}
|
|
565
|
+
/**
|
|
566
|
+
* Computes the distance between two points.
|
|
567
|
+
*
|
|
568
|
+
* @param {Cartesian2} left The first point to compute the distance from.
|
|
569
|
+
* @param {Cartesian2} right The second point to compute the distance to.
|
|
570
|
+
* @returns {number} The distance between two points.
|
|
571
|
+
*
|
|
572
|
+
* @example
|
|
573
|
+
* // Returns 1.0
|
|
574
|
+
* const d = Cesium.Cartesian2.distance(new Cesium.Cartesian2(1.0, 0.0), new Cesium.Cartesian2(2.0, 0.0));
|
|
575
|
+
*/
|
|
576
|
+
static distance(left, right) {
|
|
577
|
+
Check_default.typeOf.object("left", left);
|
|
578
|
+
Check_default.typeOf.object("right", right);
|
|
579
|
+
_Cartesian2.subtract(left, right, distanceScratch);
|
|
580
|
+
return _Cartesian2.magnitude(distanceScratch);
|
|
581
|
+
}
|
|
582
|
+
/**
|
|
583
|
+
* Computes the squared distance between two points. Comparing squared distances
|
|
584
|
+
* using this function is more efficient than comparing distances using {@link Cartesian2#distance}.
|
|
585
|
+
*
|
|
586
|
+
* @param {Cartesian2} left The first point to compute the distance from.
|
|
587
|
+
* @param {Cartesian2} right The second point to compute the distance to.
|
|
588
|
+
* @returns {number} The distance between two points.
|
|
589
|
+
*
|
|
590
|
+
* @example
|
|
591
|
+
* // Returns 4.0, not 2.0
|
|
592
|
+
* const d = Cesium.Cartesian2.distance(new Cesium.Cartesian2(1.0, 0.0), new Cesium.Cartesian2(3.0, 0.0));
|
|
593
|
+
*/
|
|
594
|
+
static distanceSquared(left, right) {
|
|
595
|
+
Check_default.typeOf.object("left", left);
|
|
596
|
+
Check_default.typeOf.object("right", right);
|
|
597
|
+
_Cartesian2.subtract(left, right, distanceScratch);
|
|
598
|
+
return _Cartesian2.magnitudeSquared(distanceScratch);
|
|
599
|
+
}
|
|
600
|
+
/**
|
|
601
|
+
* Computes the normalized form of the supplied Cartesian.
|
|
602
|
+
*
|
|
603
|
+
* @param {Cartesian2} cartesian The Cartesian to be normalized.
|
|
604
|
+
* @param {Cartesian2} result The object onto which to store the result.
|
|
605
|
+
* @returns {Cartesian2} The modified result parameter.
|
|
606
|
+
*/
|
|
607
|
+
static normalize(cartesian, result) {
|
|
608
|
+
Check_default.typeOf.object("cartesian", cartesian);
|
|
609
|
+
Check_default.typeOf.object("result", result);
|
|
610
|
+
const magnitude = _Cartesian2.magnitude(cartesian);
|
|
611
|
+
result.x = cartesian.x / magnitude;
|
|
612
|
+
result.y = cartesian.y / magnitude;
|
|
613
|
+
if (isNaN(result.x) || isNaN(result.y)) {
|
|
614
|
+
throw new DeveloperError_default("normalized result is not a number");
|
|
615
|
+
}
|
|
616
|
+
return result;
|
|
617
|
+
}
|
|
618
|
+
/**
|
|
619
|
+
* Computes the dot (scalar) product of two Cartesians.
|
|
620
|
+
*
|
|
621
|
+
* @param {Cartesian2} left The first Cartesian.
|
|
622
|
+
* @param {Cartesian2} right The second Cartesian.
|
|
623
|
+
* @returns {number} The dot product.
|
|
624
|
+
*/
|
|
625
|
+
static dot(left, right) {
|
|
626
|
+
Check_default.typeOf.object("left", left);
|
|
627
|
+
Check_default.typeOf.object("right", right);
|
|
628
|
+
return left.x * right.x + left.y * right.y;
|
|
629
|
+
}
|
|
630
|
+
/**
|
|
631
|
+
* Computes the magnitude of the cross product that would result from implicitly setting the Z coordinate of the input vectors to 0
|
|
632
|
+
*
|
|
633
|
+
* @param {Cartesian2} left The first Cartesian.
|
|
634
|
+
* @param {Cartesian2} right The second Cartesian.
|
|
635
|
+
* @returns {number} The cross product.
|
|
636
|
+
*/
|
|
637
|
+
static cross(left, right) {
|
|
638
|
+
Check_default.typeOf.object("left", left);
|
|
639
|
+
Check_default.typeOf.object("right", right);
|
|
640
|
+
return left.x * right.y - left.y * right.x;
|
|
641
|
+
}
|
|
642
|
+
/**
|
|
643
|
+
* Computes the componentwise product of two Cartesians.
|
|
644
|
+
*
|
|
645
|
+
* @param {Cartesian2} left The first Cartesian.
|
|
646
|
+
* @param {Cartesian2} right The second Cartesian.
|
|
647
|
+
* @param {Cartesian2} result The object onto which to store the result.
|
|
648
|
+
* @returns {Cartesian2} The modified result parameter.
|
|
649
|
+
*/
|
|
650
|
+
static multiplyComponents(left, right, result) {
|
|
651
|
+
Check_default.typeOf.object("left", left);
|
|
652
|
+
Check_default.typeOf.object("right", right);
|
|
653
|
+
Check_default.typeOf.object("result", result);
|
|
654
|
+
result.x = left.x * right.x;
|
|
655
|
+
result.y = left.y * right.y;
|
|
656
|
+
return result;
|
|
657
|
+
}
|
|
658
|
+
/**
|
|
659
|
+
* Computes the componentwise quotient of two Cartesians.
|
|
660
|
+
*
|
|
661
|
+
* @param {Cartesian2} left The first Cartesian.
|
|
662
|
+
* @param {Cartesian2} right The second Cartesian.
|
|
663
|
+
* @param {Cartesian2} result The object onto which to store the result.
|
|
664
|
+
* @returns {Cartesian2} The modified result parameter.
|
|
665
|
+
*/
|
|
666
|
+
static divideComponents(left, right, result) {
|
|
667
|
+
Check_default.typeOf.object("left", left);
|
|
668
|
+
Check_default.typeOf.object("right", right);
|
|
669
|
+
Check_default.typeOf.object("result", result);
|
|
670
|
+
result.x = left.x / right.x;
|
|
671
|
+
result.y = left.y / right.y;
|
|
672
|
+
return result;
|
|
673
|
+
}
|
|
674
|
+
/**
|
|
675
|
+
* Computes the componentwise sum of two Cartesians.
|
|
676
|
+
*
|
|
677
|
+
* @param {Cartesian2} left The first Cartesian.
|
|
678
|
+
* @param {Cartesian2} right The second Cartesian.
|
|
679
|
+
* @param {Cartesian2} result The object onto which to store the result.
|
|
680
|
+
* @returns {Cartesian2} The modified result parameter.
|
|
681
|
+
*/
|
|
682
|
+
static add(left, right, result) {
|
|
683
|
+
Check_default.typeOf.object("left", left);
|
|
684
|
+
Check_default.typeOf.object("right", right);
|
|
685
|
+
Check_default.typeOf.object("result", result);
|
|
686
|
+
result.x = left.x + right.x;
|
|
687
|
+
result.y = left.y + right.y;
|
|
688
|
+
return result;
|
|
689
|
+
}
|
|
690
|
+
/**
|
|
691
|
+
* Computes the componentwise difference of two Cartesians.
|
|
692
|
+
*
|
|
693
|
+
* @param {Cartesian2} left The first Cartesian.
|
|
694
|
+
* @param {Cartesian2} right The second Cartesian.
|
|
695
|
+
* @param {Cartesian2} result The object onto which to store the result.
|
|
696
|
+
* @returns {Cartesian2} The modified result parameter.
|
|
697
|
+
*/
|
|
698
|
+
static subtract(left, right, result) {
|
|
699
|
+
Check_default.typeOf.object("left", left);
|
|
700
|
+
Check_default.typeOf.object("right", right);
|
|
701
|
+
Check_default.typeOf.object("result", result);
|
|
702
|
+
result.x = left.x - right.x;
|
|
703
|
+
result.y = left.y - right.y;
|
|
704
|
+
return result;
|
|
705
|
+
}
|
|
706
|
+
/**
|
|
707
|
+
* Multiplies the provided Cartesian componentwise by the provided scalar.
|
|
708
|
+
*
|
|
709
|
+
* @param {Cartesian2} cartesian The Cartesian to be scaled.
|
|
710
|
+
* @param {number} scalar The scalar to multiply with.
|
|
711
|
+
* @param {Cartesian2} result The object onto which to store the result.
|
|
712
|
+
* @returns {Cartesian2} The modified result parameter.
|
|
713
|
+
*/
|
|
714
|
+
static multiplyByScalar(cartesian, scalar, result) {
|
|
715
|
+
Check_default.typeOf.object("cartesian", cartesian);
|
|
716
|
+
Check_default.typeOf.number("scalar", scalar);
|
|
717
|
+
Check_default.typeOf.object("result", result);
|
|
718
|
+
result.x = cartesian.x * scalar;
|
|
719
|
+
result.y = cartesian.y * scalar;
|
|
720
|
+
return result;
|
|
721
|
+
}
|
|
722
|
+
/**
|
|
723
|
+
* Divides the provided Cartesian componentwise by the provided scalar.
|
|
724
|
+
*
|
|
725
|
+
* @param {Cartesian2} cartesian The Cartesian to be divided.
|
|
726
|
+
* @param {number} scalar The scalar to divide by.
|
|
727
|
+
* @param {Cartesian2} result The object onto which to store the result.
|
|
728
|
+
* @returns {Cartesian2} The modified result parameter.
|
|
729
|
+
*/
|
|
730
|
+
static divideByScalar(cartesian, scalar, result) {
|
|
731
|
+
Check_default.typeOf.object("cartesian", cartesian);
|
|
732
|
+
Check_default.typeOf.number("scalar", scalar);
|
|
733
|
+
Check_default.typeOf.object("result", result);
|
|
734
|
+
result.x = cartesian.x / scalar;
|
|
735
|
+
result.y = cartesian.y / scalar;
|
|
736
|
+
return result;
|
|
737
|
+
}
|
|
738
|
+
/**
|
|
739
|
+
* Negates the provided Cartesian.
|
|
740
|
+
*
|
|
741
|
+
* @param {Cartesian2} cartesian The Cartesian to be negated.
|
|
742
|
+
* @param {Cartesian2} result The object onto which to store the result.
|
|
743
|
+
* @returns {Cartesian2} The modified result parameter.
|
|
744
|
+
*/
|
|
745
|
+
static negate(cartesian, result) {
|
|
746
|
+
Check_default.typeOf.object("cartesian", cartesian);
|
|
747
|
+
Check_default.typeOf.object("result", result);
|
|
748
|
+
result.x = -cartesian.x;
|
|
749
|
+
result.y = -cartesian.y;
|
|
750
|
+
return result;
|
|
751
|
+
}
|
|
752
|
+
/**
|
|
753
|
+
* Computes the absolute value of the provided Cartesian.
|
|
754
|
+
*
|
|
755
|
+
* @param {Cartesian2} cartesian The Cartesian whose absolute value is to be computed.
|
|
756
|
+
* @param {Cartesian2} result The object onto which to store the result.
|
|
757
|
+
* @returns {Cartesian2} The modified result parameter.
|
|
758
|
+
*/
|
|
759
|
+
static abs(cartesian, result) {
|
|
760
|
+
Check_default.typeOf.object("cartesian", cartesian);
|
|
761
|
+
Check_default.typeOf.object("result", result);
|
|
762
|
+
result.x = Math.abs(cartesian.x);
|
|
763
|
+
result.y = Math.abs(cartesian.y);
|
|
764
|
+
return result;
|
|
765
|
+
}
|
|
766
|
+
/**
|
|
767
|
+
* Computes the linear interpolation or extrapolation at t using the provided cartesians.
|
|
768
|
+
*
|
|
769
|
+
* @param {Cartesian2} start The value corresponding to t at 0.0.
|
|
770
|
+
* @param {Cartesian2} end The value corresponding to t at 1.0.
|
|
771
|
+
* @param {number} t The point along t at which to interpolate.
|
|
772
|
+
* @param {Cartesian2} result The object onto which to store the result.
|
|
773
|
+
* @returns {Cartesian2} The modified result parameter.
|
|
774
|
+
*/
|
|
775
|
+
static lerp(start, end, t, result) {
|
|
776
|
+
Check_default.typeOf.object("start", start);
|
|
777
|
+
Check_default.typeOf.object("end", end);
|
|
778
|
+
Check_default.typeOf.number("t", t);
|
|
779
|
+
Check_default.typeOf.object("result", result);
|
|
780
|
+
_Cartesian2.multiplyByScalar(end, t, lerpScratch);
|
|
781
|
+
result = _Cartesian2.multiplyByScalar(start, 1 - t, result);
|
|
782
|
+
return _Cartesian2.add(lerpScratch, result, result);
|
|
783
|
+
}
|
|
784
|
+
/**
|
|
785
|
+
* Returns the angle, in radians, between the provided Cartesians.
|
|
786
|
+
*
|
|
787
|
+
* @param {Cartesian2} left The first Cartesian.
|
|
788
|
+
* @param {Cartesian2} right The second Cartesian.
|
|
789
|
+
* @returns {number} The angle between the Cartesians.
|
|
790
|
+
*/
|
|
791
|
+
static angleBetween(left, right) {
|
|
792
|
+
Check_default.typeOf.object("left", left);
|
|
793
|
+
Check_default.typeOf.object("right", right);
|
|
794
|
+
_Cartesian2.normalize(left, angleBetweenScratch);
|
|
795
|
+
_Cartesian2.normalize(right, angleBetweenScratch2);
|
|
796
|
+
return Math_default.acosClamped(
|
|
797
|
+
_Cartesian2.dot(angleBetweenScratch, angleBetweenScratch2)
|
|
798
|
+
);
|
|
799
|
+
}
|
|
800
|
+
/**
|
|
801
|
+
* Returns the axis that is most orthogonal to the provided Cartesian.
|
|
802
|
+
*
|
|
803
|
+
* @param {Cartesian2} cartesian The Cartesian on which to find the most orthogonal axis.
|
|
804
|
+
* @param {Cartesian2} result The object onto which to store the result.
|
|
805
|
+
* @returns {Cartesian2} The most orthogonal axis.
|
|
806
|
+
*/
|
|
807
|
+
static mostOrthogonalAxis(cartesian, result) {
|
|
808
|
+
Check_default.typeOf.object("cartesian", cartesian);
|
|
809
|
+
Check_default.typeOf.object("result", result);
|
|
810
|
+
const f = _Cartesian2.normalize(cartesian, mostOrthogonalAxisScratch);
|
|
811
|
+
_Cartesian2.abs(f, f);
|
|
812
|
+
if (f.x <= f.y) {
|
|
813
|
+
result = _Cartesian2.clone(_Cartesian2.UNIT_X, result);
|
|
814
|
+
} else {
|
|
815
|
+
result = _Cartesian2.clone(_Cartesian2.UNIT_Y, result);
|
|
816
|
+
}
|
|
817
|
+
return result;
|
|
818
|
+
}
|
|
819
|
+
/**
|
|
820
|
+
* Compares the provided Cartesians componentwise and returns
|
|
821
|
+
* <code>true</code> if they are equal, <code>false</code> otherwise.
|
|
822
|
+
*
|
|
823
|
+
* @param {Cartesian2} [left] The first Cartesian.
|
|
824
|
+
* @param {Cartesian2} [right] The second Cartesian.
|
|
825
|
+
* @returns {boolean} <code>true</code> if left and right are equal, <code>false</code> otherwise.
|
|
826
|
+
*/
|
|
827
|
+
static equals(left, right) {
|
|
828
|
+
return left === right || defined_default(left) && defined_default(right) && left.x === right.x && left.y === right.y;
|
|
829
|
+
}
|
|
830
|
+
/**
|
|
831
|
+
* @param {Cartesian2} cartesian
|
|
832
|
+
* @param {number[]} array
|
|
833
|
+
* @param {number} offset
|
|
834
|
+
* @ignore
|
|
835
|
+
*/
|
|
836
|
+
static equalsArray(cartesian, array, offset) {
|
|
837
|
+
return cartesian.x === array[offset] && cartesian.y === array[offset + 1];
|
|
838
|
+
}
|
|
839
|
+
/**
|
|
840
|
+
* Compares the provided Cartesians componentwise and returns
|
|
841
|
+
* <code>true</code> if they pass an absolute or relative tolerance test,
|
|
842
|
+
* <code>false</code> otherwise.
|
|
843
|
+
*
|
|
844
|
+
* @param {Cartesian2} [left] The first Cartesian.
|
|
845
|
+
* @param {Cartesian2} [right] The second Cartesian.
|
|
846
|
+
* @param {number} [relativeEpsilon=0] The relative epsilon tolerance to use for equality testing.
|
|
847
|
+
* @param {number} [absoluteEpsilon=relativeEpsilon] The absolute epsilon tolerance to use for equality testing.
|
|
848
|
+
* @returns {boolean} <code>true</code> if left and right are within the provided epsilon, <code>false</code> otherwise.
|
|
849
|
+
*/
|
|
850
|
+
static equalsEpsilon(left, right, relativeEpsilon, absoluteEpsilon) {
|
|
851
|
+
return left === right || defined_default(left) && defined_default(right) && Math_default.equalsEpsilon(
|
|
852
|
+
left.x,
|
|
853
|
+
right.x,
|
|
854
|
+
relativeEpsilon,
|
|
855
|
+
absoluteEpsilon
|
|
856
|
+
) && Math_default.equalsEpsilon(
|
|
857
|
+
left.y,
|
|
858
|
+
right.y,
|
|
859
|
+
relativeEpsilon,
|
|
860
|
+
absoluteEpsilon
|
|
861
|
+
);
|
|
862
|
+
}
|
|
863
|
+
/**
|
|
864
|
+
* Duplicates this Cartesian2 instance.
|
|
865
|
+
*
|
|
866
|
+
* @param {Cartesian2} [result] The object onto which to store the result.
|
|
867
|
+
* @returns {Cartesian2} The modified result parameter or a new Cartesian2 instance if one was not provided.
|
|
868
|
+
*/
|
|
869
|
+
clone(result) {
|
|
870
|
+
return _Cartesian2.clone(this, result);
|
|
871
|
+
}
|
|
872
|
+
/**
|
|
873
|
+
* Compares this Cartesian against the provided Cartesian componentwise and returns
|
|
874
|
+
* <code>true</code> if they are equal, <code>false</code> otherwise.
|
|
875
|
+
*
|
|
876
|
+
* @param {Cartesian2} [right] The right hand side Cartesian.
|
|
877
|
+
* @returns {boolean} <code>true</code> if they are equal, <code>false</code> otherwise.
|
|
878
|
+
*/
|
|
879
|
+
equals(right) {
|
|
880
|
+
return _Cartesian2.equals(this, right);
|
|
881
|
+
}
|
|
882
|
+
/**
|
|
883
|
+
* Compares this Cartesian against the provided Cartesian componentwise and returns
|
|
884
|
+
* <code>true</code> if they pass an absolute or relative tolerance test,
|
|
885
|
+
* <code>false</code> otherwise.
|
|
886
|
+
*
|
|
887
|
+
* @param {Cartesian2} [right] The right hand side Cartesian.
|
|
888
|
+
* @param {number} [relativeEpsilon=0] The relative epsilon tolerance to use for equality testing.
|
|
889
|
+
* @param {number} [absoluteEpsilon=relativeEpsilon] The absolute epsilon tolerance to use for equality testing.
|
|
890
|
+
* @returns {boolean} <code>true</code> if they are within the provided epsilon, <code>false</code> otherwise.
|
|
891
|
+
*/
|
|
892
|
+
equalsEpsilon(right, relativeEpsilon, absoluteEpsilon) {
|
|
893
|
+
return _Cartesian2.equalsEpsilon(
|
|
894
|
+
this,
|
|
895
|
+
right,
|
|
896
|
+
relativeEpsilon,
|
|
897
|
+
absoluteEpsilon
|
|
898
|
+
);
|
|
899
|
+
}
|
|
900
|
+
/**
|
|
901
|
+
* Creates a string representing this Cartesian in the format '(x, y)'.
|
|
902
|
+
*
|
|
903
|
+
* @returns {string} A string representing the provided Cartesian in the format '(x, y)'.
|
|
904
|
+
*/
|
|
905
|
+
toString() {
|
|
906
|
+
return `(${this.x}, ${this.y})`;
|
|
907
|
+
}
|
|
908
|
+
};
|
|
909
|
+
Cartesian2.fromCartesian3 = Cartesian2.clone;
|
|
910
|
+
Cartesian2.fromCartesian4 = Cartesian2.clone;
|
|
911
|
+
Cartesian2.packedLength = 2;
|
|
912
|
+
Cartesian2.fromArray = Cartesian2.unpack;
|
|
913
|
+
var distanceScratch = new Cartesian2();
|
|
914
|
+
var lerpScratch = new Cartesian2();
|
|
915
|
+
var angleBetweenScratch = new Cartesian2();
|
|
916
|
+
var angleBetweenScratch2 = new Cartesian2();
|
|
917
|
+
var mostOrthogonalAxisScratch = new Cartesian2();
|
|
918
|
+
Cartesian2.ZERO = Object.freeze(new Cartesian2(0, 0));
|
|
919
|
+
Cartesian2.ONE = Object.freeze(new Cartesian2(1, 1));
|
|
920
|
+
Cartesian2.UNIT_X = Object.freeze(new Cartesian2(1, 0));
|
|
921
|
+
Cartesian2.UNIT_Y = Object.freeze(new Cartesian2(0, 1));
|
|
922
|
+
var Cartesian2_default = Cartesian2;
|
|
923
|
+
|
|
924
|
+
// packages/engine/Source/Core/Ellipsoid.js
|
|
925
|
+
function initialize(ellipsoid, x, y, z) {
|
|
926
|
+
x = x ?? 0;
|
|
927
|
+
y = y ?? 0;
|
|
928
|
+
z = z ?? 0;
|
|
929
|
+
Check_default.typeOf.number.greaterThanOrEquals("x", x, 0);
|
|
930
|
+
Check_default.typeOf.number.greaterThanOrEquals("y", y, 0);
|
|
931
|
+
Check_default.typeOf.number.greaterThanOrEquals("z", z, 0);
|
|
932
|
+
ellipsoid._radii = new Cartesian3_default(x, y, z);
|
|
933
|
+
ellipsoid._radiiSquared = new Cartesian3_default(x * x, y * y, z * z);
|
|
934
|
+
ellipsoid._radiiToTheFourth = new Cartesian3_default(
|
|
935
|
+
x * x * x * x,
|
|
936
|
+
y * y * y * y,
|
|
937
|
+
z * z * z * z
|
|
938
|
+
);
|
|
939
|
+
ellipsoid._oneOverRadii = new Cartesian3_default(
|
|
940
|
+
x === 0 ? 0 : 1 / x,
|
|
941
|
+
y === 0 ? 0 : 1 / y,
|
|
942
|
+
z === 0 ? 0 : 1 / z
|
|
943
|
+
);
|
|
944
|
+
ellipsoid._oneOverRadiiSquared = new Cartesian3_default(
|
|
945
|
+
x === 0 ? 0 : 1 / (x * x),
|
|
946
|
+
y === 0 ? 0 : 1 / (y * y),
|
|
947
|
+
z === 0 ? 0 : 1 / (z * z)
|
|
948
|
+
);
|
|
949
|
+
ellipsoid._minimumRadius = Math.min(x, y, z);
|
|
950
|
+
ellipsoid._maximumRadius = Math.max(x, y, z);
|
|
951
|
+
ellipsoid._centerToleranceSquared = Math_default.EPSILON1;
|
|
952
|
+
if (ellipsoid._radiiSquared.z !== 0) {
|
|
953
|
+
ellipsoid._squaredXOverSquaredZ = ellipsoid._radiiSquared.x / ellipsoid._radiiSquared.z;
|
|
954
|
+
}
|
|
955
|
+
}
|
|
956
|
+
var Ellipsoid = class _Ellipsoid {
|
|
957
|
+
/**
|
|
958
|
+
* @param {number} [x=0] The radius in the x direction.
|
|
959
|
+
* @param {number} [y=0] The radius in the y direction.
|
|
960
|
+
* @param {number} [z=0] The radius in the z direction.
|
|
961
|
+
*
|
|
962
|
+
* @exception {DeveloperError} All radii components must be greater than or equal to zero.
|
|
963
|
+
*/
|
|
964
|
+
constructor(x, y, z) {
|
|
965
|
+
this._radii = void 0;
|
|
966
|
+
this._radiiSquared = void 0;
|
|
967
|
+
this._radiiToTheFourth = void 0;
|
|
968
|
+
this._oneOverRadii = void 0;
|
|
969
|
+
this._oneOverRadiiSquared = void 0;
|
|
970
|
+
this._minimumRadius = void 0;
|
|
971
|
+
this._maximumRadius = void 0;
|
|
972
|
+
this._centerToleranceSquared = void 0;
|
|
973
|
+
this._squaredXOverSquaredZ = void 0;
|
|
974
|
+
initialize(this, x, y, z);
|
|
975
|
+
}
|
|
976
|
+
/**
|
|
977
|
+
* Gets the radii of the ellipsoid.
|
|
978
|
+
* @type {Cartesian3}
|
|
979
|
+
* @readonly
|
|
980
|
+
*/
|
|
981
|
+
get radii() {
|
|
982
|
+
return this._radii;
|
|
983
|
+
}
|
|
984
|
+
/**
|
|
985
|
+
* Gets the squared radii of the ellipsoid.
|
|
986
|
+
* @type {Cartesian3}
|
|
987
|
+
* @readonly
|
|
988
|
+
*/
|
|
989
|
+
get radiiSquared() {
|
|
990
|
+
return this._radiiSquared;
|
|
991
|
+
}
|
|
992
|
+
/**
|
|
993
|
+
* Gets the radii of the ellipsoid raise to the fourth power.
|
|
994
|
+
* @type {Cartesian3}
|
|
995
|
+
* @readonly
|
|
996
|
+
*/
|
|
997
|
+
get radiiToTheFourth() {
|
|
998
|
+
return this._radiiToTheFourth;
|
|
999
|
+
}
|
|
1000
|
+
/**
|
|
1001
|
+
* Gets one over the radii of the ellipsoid.
|
|
1002
|
+
* @type {Cartesian3}
|
|
1003
|
+
* @readonly
|
|
1004
|
+
*/
|
|
1005
|
+
get oneOverRadii() {
|
|
1006
|
+
return this._oneOverRadii;
|
|
1007
|
+
}
|
|
1008
|
+
/**
|
|
1009
|
+
* Gets one over the squared radii of the ellipsoid.
|
|
1010
|
+
* @type {Cartesian3}
|
|
1011
|
+
* @readonly
|
|
1012
|
+
*/
|
|
1013
|
+
get oneOverRadiiSquared() {
|
|
1014
|
+
return this._oneOverRadiiSquared;
|
|
1015
|
+
}
|
|
1016
|
+
/**
|
|
1017
|
+
* Gets the minimum radius of the ellipsoid.
|
|
1018
|
+
* @type {number}
|
|
1019
|
+
* @readonly
|
|
1020
|
+
*/
|
|
1021
|
+
get minimumRadius() {
|
|
1022
|
+
return this._minimumRadius;
|
|
1023
|
+
}
|
|
1024
|
+
/**
|
|
1025
|
+
* Gets the maximum radius of the ellipsoid.
|
|
1026
|
+
* @type {number}
|
|
1027
|
+
* @readonly
|
|
1028
|
+
*/
|
|
1029
|
+
get maximumRadius() {
|
|
1030
|
+
return this._maximumRadius;
|
|
1031
|
+
}
|
|
1032
|
+
/**
|
|
1033
|
+
* Duplicates an Ellipsoid instance.
|
|
1034
|
+
*
|
|
1035
|
+
* @param {Ellipsoid} ellipsoid The ellipsoid to duplicate.
|
|
1036
|
+
* @param {Ellipsoid} [result] The object onto which to store the result, or undefined if a new
|
|
1037
|
+
* instance should be created.
|
|
1038
|
+
* @returns {Ellipsoid} The cloned Ellipsoid. (Returns undefined if ellipsoid is undefined)
|
|
1039
|
+
*/
|
|
1040
|
+
static clone(ellipsoid, result) {
|
|
1041
|
+
if (!defined_default(ellipsoid)) {
|
|
1042
|
+
return void 0;
|
|
1043
|
+
}
|
|
1044
|
+
const radii = ellipsoid._radii;
|
|
1045
|
+
if (!defined_default(result)) {
|
|
1046
|
+
return new _Ellipsoid(radii.x, radii.y, radii.z);
|
|
1047
|
+
}
|
|
1048
|
+
Cartesian3_default.clone(radii, result._radii);
|
|
1049
|
+
Cartesian3_default.clone(ellipsoid._radiiSquared, result._radiiSquared);
|
|
1050
|
+
Cartesian3_default.clone(ellipsoid._radiiToTheFourth, result._radiiToTheFourth);
|
|
1051
|
+
Cartesian3_default.clone(ellipsoid._oneOverRadii, result._oneOverRadii);
|
|
1052
|
+
Cartesian3_default.clone(
|
|
1053
|
+
ellipsoid._oneOverRadiiSquared,
|
|
1054
|
+
result._oneOverRadiiSquared
|
|
1055
|
+
);
|
|
1056
|
+
result._minimumRadius = ellipsoid._minimumRadius;
|
|
1057
|
+
result._maximumRadius = ellipsoid._maximumRadius;
|
|
1058
|
+
result._centerToleranceSquared = ellipsoid._centerToleranceSquared;
|
|
1059
|
+
return result;
|
|
1060
|
+
}
|
|
1061
|
+
/**
|
|
1062
|
+
* Computes an Ellipsoid from a Cartesian specifying the radii in x, y, and z directions.
|
|
1063
|
+
*
|
|
1064
|
+
* @param {Cartesian3} [cartesian=Cartesian3.ZERO] The ellipsoid's radius in the x, y, and z directions.
|
|
1065
|
+
* @param {Ellipsoid} [result] The object onto which to store the result, or undefined if a new
|
|
1066
|
+
* instance should be created.
|
|
1067
|
+
* @returns {Ellipsoid} A new Ellipsoid instance.
|
|
1068
|
+
*
|
|
1069
|
+
* @exception {DeveloperError} All radii components must be greater than or equal to zero.
|
|
1070
|
+
*
|
|
1071
|
+
* @see Ellipsoid.WGS84
|
|
1072
|
+
* @see Ellipsoid.UNIT_SPHERE
|
|
1073
|
+
*/
|
|
1074
|
+
static fromCartesian3(cartesian, result) {
|
|
1075
|
+
if (!defined_default(result)) {
|
|
1076
|
+
result = new _Ellipsoid();
|
|
1077
|
+
}
|
|
1078
|
+
if (!defined_default(cartesian)) {
|
|
1079
|
+
return result;
|
|
1080
|
+
}
|
|
1081
|
+
initialize(result, cartesian.x, cartesian.y, cartesian.z);
|
|
1082
|
+
return result;
|
|
1083
|
+
}
|
|
1084
|
+
/**
|
|
1085
|
+
* The default ellipsoid used when not otherwise specified.
|
|
1086
|
+
* @type {Ellipsoid}
|
|
1087
|
+
* @example
|
|
1088
|
+
* Cesium.Ellipsoid.default = Cesium.Ellipsoid.MOON;
|
|
1089
|
+
*
|
|
1090
|
+
* // Apollo 11 landing site
|
|
1091
|
+
* const position = Cesium.Cartesian3.fromRadians(
|
|
1092
|
+
* 0.67416,
|
|
1093
|
+
* 23.47315,
|
|
1094
|
+
* );
|
|
1095
|
+
*/
|
|
1096
|
+
static get default() {
|
|
1097
|
+
return _Ellipsoid._default;
|
|
1098
|
+
}
|
|
1099
|
+
static set default(value) {
|
|
1100
|
+
Check_default.typeOf.object("value", value);
|
|
1101
|
+
_Ellipsoid._default = value;
|
|
1102
|
+
Cartesian3_default._ellipsoidRadiiSquared = value.radiiSquared;
|
|
1103
|
+
Cartographic_default._ellipsoidOneOverRadii = value.oneOverRadii;
|
|
1104
|
+
Cartographic_default._ellipsoidOneOverRadiiSquared = value.oneOverRadiiSquared;
|
|
1105
|
+
Cartographic_default._ellipsoidCenterToleranceSquared = value._centerToleranceSquared;
|
|
1106
|
+
}
|
|
1107
|
+
/**
|
|
1108
|
+
* Duplicates an Ellipsoid instance.
|
|
1109
|
+
*
|
|
1110
|
+
* @param {Ellipsoid} [result] The object onto which to store the result, or undefined if a new
|
|
1111
|
+
* instance should be created.
|
|
1112
|
+
* @returns {Ellipsoid} The cloned Ellipsoid.
|
|
1113
|
+
*/
|
|
1114
|
+
clone(result) {
|
|
1115
|
+
return _Ellipsoid.clone(this, result);
|
|
1116
|
+
}
|
|
1117
|
+
/**
|
|
1118
|
+
* Stores the provided instance into the provided array.
|
|
1119
|
+
*
|
|
1120
|
+
* @param {Ellipsoid} value The value to pack.
|
|
1121
|
+
* @param {number[]} array The array to pack into.
|
|
1122
|
+
* @param {number} [startingIndex=0] The index into the array at which to start packing the elements.
|
|
1123
|
+
*
|
|
1124
|
+
* @returns {number[]} The array that was packed into
|
|
1125
|
+
*/
|
|
1126
|
+
static pack(value, array, startingIndex) {
|
|
1127
|
+
Check_default.typeOf.object("value", value);
|
|
1128
|
+
Check_default.defined("array", array);
|
|
1129
|
+
startingIndex = startingIndex ?? 0;
|
|
1130
|
+
Cartesian3_default.pack(value._radii, array, startingIndex);
|
|
1131
|
+
return array;
|
|
1132
|
+
}
|
|
1133
|
+
/**
|
|
1134
|
+
* Retrieves an instance from a packed array.
|
|
1135
|
+
*
|
|
1136
|
+
* @param {number[]} array The packed array.
|
|
1137
|
+
* @param {number} [startingIndex=0] The starting index of the element to be unpacked.
|
|
1138
|
+
* @param {Ellipsoid} [result] The object into which to store the result.
|
|
1139
|
+
* @returns {Ellipsoid} The modified result parameter or a new Ellipsoid instance if one was not provided.
|
|
1140
|
+
*/
|
|
1141
|
+
static unpack(array, startingIndex, result) {
|
|
1142
|
+
Check_default.defined("array", array);
|
|
1143
|
+
startingIndex = startingIndex ?? 0;
|
|
1144
|
+
const radii = Cartesian3_default.unpack(array, startingIndex);
|
|
1145
|
+
return _Ellipsoid.fromCartesian3(radii, result);
|
|
1146
|
+
}
|
|
1147
|
+
/**
|
|
1148
|
+
* Computes the normal of the plane tangent to the surface of the ellipsoid at the provided position.
|
|
1149
|
+
*
|
|
1150
|
+
* @param {Cartographic} cartographic The cartographic position for which to to determine the geodetic normal.
|
|
1151
|
+
* @param {Cartesian3} [result] The object onto which to store the result.
|
|
1152
|
+
* @returns {Cartesian3} The modified result parameter or a new Cartesian3 instance if none was provided.
|
|
1153
|
+
*/
|
|
1154
|
+
geodeticSurfaceNormalCartographic(cartographic, result) {
|
|
1155
|
+
Check_default.typeOf.object("cartographic", cartographic);
|
|
1156
|
+
const longitude = cartographic.longitude;
|
|
1157
|
+
const latitude = cartographic.latitude;
|
|
1158
|
+
const cosLatitude = Math.cos(latitude);
|
|
1159
|
+
const x = cosLatitude * Math.cos(longitude);
|
|
1160
|
+
const y = cosLatitude * Math.sin(longitude);
|
|
1161
|
+
const z = Math.sin(latitude);
|
|
1162
|
+
if (!defined_default(result)) {
|
|
1163
|
+
result = new Cartesian3_default();
|
|
1164
|
+
}
|
|
1165
|
+
result.x = x;
|
|
1166
|
+
result.y = y;
|
|
1167
|
+
result.z = z;
|
|
1168
|
+
return Cartesian3_default.normalize(result, result);
|
|
1169
|
+
}
|
|
1170
|
+
/**
|
|
1171
|
+
* Computes the normal of the plane tangent to the surface of the ellipsoid at the provided position.
|
|
1172
|
+
*
|
|
1173
|
+
* @param {Cartesian3} cartesian The Cartesian position for which to to determine the surface normal.
|
|
1174
|
+
* @param {Cartesian3} [result] The object onto which to store the result.
|
|
1175
|
+
* @returns {Cartesian3} The modified result parameter or a new Cartesian3 instance if none was provided, or undefined if a normal cannot be found.
|
|
1176
|
+
*/
|
|
1177
|
+
geodeticSurfaceNormal(cartesian, result) {
|
|
1178
|
+
Check_default.typeOf.object("cartesian", cartesian);
|
|
1179
|
+
if (isNaN(cartesian.x) || isNaN(cartesian.y) || isNaN(cartesian.z)) {
|
|
1180
|
+
throw new DeveloperError_default("cartesian has a NaN component");
|
|
1181
|
+
}
|
|
1182
|
+
if (Cartesian3_default.equalsEpsilon(cartesian, Cartesian3_default.ZERO, Math_default.EPSILON14)) {
|
|
1183
|
+
return void 0;
|
|
1184
|
+
}
|
|
1185
|
+
if (!defined_default(result)) {
|
|
1186
|
+
result = new Cartesian3_default();
|
|
1187
|
+
}
|
|
1188
|
+
result = Cartesian3_default.multiplyComponents(
|
|
1189
|
+
cartesian,
|
|
1190
|
+
this._oneOverRadiiSquared,
|
|
1191
|
+
result
|
|
1192
|
+
);
|
|
1193
|
+
return Cartesian3_default.normalize(result, result);
|
|
1194
|
+
}
|
|
1195
|
+
/**
|
|
1196
|
+
* Converts the provided cartographic to Cartesian representation.
|
|
1197
|
+
*
|
|
1198
|
+
* @param {Cartographic} cartographic The cartographic position.
|
|
1199
|
+
* @param {Cartesian3} [result] The object onto which to store the result.
|
|
1200
|
+
* @returns {Cartesian3} The modified result parameter or a new Cartesian3 instance if none was provided.
|
|
1201
|
+
*
|
|
1202
|
+
* @example
|
|
1203
|
+
* //Create a Cartographic and determine it's Cartesian representation on a WGS84 ellipsoid.
|
|
1204
|
+
* const position = new Cesium.Cartographic(Cesium.Math.toRadians(21), Cesium.Math.toRadians(78), 5000);
|
|
1205
|
+
* const cartesianPosition = Cesium.Ellipsoid.WGS84.cartographicToCartesian(position);
|
|
1206
|
+
*/
|
|
1207
|
+
cartographicToCartesian(cartographic, result) {
|
|
1208
|
+
const n = cartographicToCartesianNormal;
|
|
1209
|
+
const k = cartographicToCartesianK;
|
|
1210
|
+
this.geodeticSurfaceNormalCartographic(cartographic, n);
|
|
1211
|
+
Cartesian3_default.multiplyComponents(this._radiiSquared, n, k);
|
|
1212
|
+
const gamma = Math.sqrt(Cartesian3_default.dot(n, k));
|
|
1213
|
+
Cartesian3_default.divideByScalar(k, gamma, k);
|
|
1214
|
+
Cartesian3_default.multiplyByScalar(n, cartographic.height, n);
|
|
1215
|
+
if (!defined_default(result)) {
|
|
1216
|
+
result = new Cartesian3_default();
|
|
1217
|
+
}
|
|
1218
|
+
return Cartesian3_default.add(k, n, result);
|
|
1219
|
+
}
|
|
1220
|
+
/**
|
|
1221
|
+
* Converts the provided array of cartographics to an array of Cartesians.
|
|
1222
|
+
*
|
|
1223
|
+
* @param {Cartographic[]} cartographics An array of cartographic positions.
|
|
1224
|
+
* @param {Cartesian3[]} [result] The object onto which to store the result.
|
|
1225
|
+
* @returns {Cartesian3[]} The modified result parameter or a new Array instance if none was provided.
|
|
1226
|
+
*
|
|
1227
|
+
* @example
|
|
1228
|
+
* //Convert an array of Cartographics and determine their Cartesian representation on a WGS84 ellipsoid.
|
|
1229
|
+
* const positions = [new Cesium.Cartographic(Cesium.Math.toRadians(21), Cesium.Math.toRadians(78), 0),
|
|
1230
|
+
* new Cesium.Cartographic(Cesium.Math.toRadians(21.321), Cesium.Math.toRadians(78.123), 100),
|
|
1231
|
+
* new Cesium.Cartographic(Cesium.Math.toRadians(21.645), Cesium.Math.toRadians(78.456), 250)];
|
|
1232
|
+
* const cartesianPositions = Cesium.Ellipsoid.WGS84.cartographicArrayToCartesianArray(positions);
|
|
1233
|
+
*/
|
|
1234
|
+
cartographicArrayToCartesianArray(cartographics, result) {
|
|
1235
|
+
Check_default.defined("cartographics", cartographics);
|
|
1236
|
+
const length = cartographics.length;
|
|
1237
|
+
if (!defined_default(result)) {
|
|
1238
|
+
result = new Array(length);
|
|
1239
|
+
} else {
|
|
1240
|
+
result.length = length;
|
|
1241
|
+
}
|
|
1242
|
+
for (let i = 0; i < length; i++) {
|
|
1243
|
+
result[i] = this.cartographicToCartesian(cartographics[i], result[i]);
|
|
1244
|
+
}
|
|
1245
|
+
return result;
|
|
1246
|
+
}
|
|
1247
|
+
/**
|
|
1248
|
+
* Converts the provided cartesian to cartographic representation.
|
|
1249
|
+
* The cartesian is undefined at the center of the ellipsoid.
|
|
1250
|
+
*
|
|
1251
|
+
* @param {Cartesian3} cartesian The Cartesian position to convert to cartographic representation.
|
|
1252
|
+
* @param {Cartographic} [result] The object onto which to store the result.
|
|
1253
|
+
* @returns {Cartographic} The modified result parameter, new Cartographic instance if none was provided, or undefined if the cartesian is at the center of the ellipsoid.
|
|
1254
|
+
*
|
|
1255
|
+
* @example
|
|
1256
|
+
* //Create a Cartesian and determine it's Cartographic representation on a WGS84 ellipsoid.
|
|
1257
|
+
* const position = new Cesium.Cartesian3(17832.12, 83234.52, 952313.73);
|
|
1258
|
+
* const cartographicPosition = Cesium.Ellipsoid.WGS84.cartesianToCartographic(position);
|
|
1259
|
+
*/
|
|
1260
|
+
cartesianToCartographic(cartesian, result) {
|
|
1261
|
+
const p = this.scaleToGeodeticSurface(cartesian, cartesianToCartographicP2);
|
|
1262
|
+
if (!defined_default(p)) {
|
|
1263
|
+
return void 0;
|
|
1264
|
+
}
|
|
1265
|
+
const n = this.geodeticSurfaceNormal(p, cartesianToCartographicN2);
|
|
1266
|
+
const h = Cartesian3_default.subtract(cartesian, p, cartesianToCartographicH2);
|
|
1267
|
+
const longitude = Math.atan2(n.y, n.x);
|
|
1268
|
+
const latitude = Math.asin(n.z);
|
|
1269
|
+
const height = Math_default.sign(Cartesian3_default.dot(h, cartesian)) * Cartesian3_default.magnitude(h);
|
|
1270
|
+
if (!defined_default(result)) {
|
|
1271
|
+
return new Cartographic_default(longitude, latitude, height);
|
|
1272
|
+
}
|
|
1273
|
+
result.longitude = longitude;
|
|
1274
|
+
result.latitude = latitude;
|
|
1275
|
+
result.height = height;
|
|
1276
|
+
return result;
|
|
1277
|
+
}
|
|
1278
|
+
/**
|
|
1279
|
+
* Converts the provided array of cartesians to an array of cartographics.
|
|
1280
|
+
*
|
|
1281
|
+
* @param {Cartesian3[]} cartesians An array of Cartesian positions.
|
|
1282
|
+
* @param {Cartographic[]} [result] The object onto which to store the result.
|
|
1283
|
+
* @returns {Cartographic[]} The modified result parameter or a new Array instance if none was provided.
|
|
1284
|
+
*
|
|
1285
|
+
* @example
|
|
1286
|
+
* //Create an array of Cartesians and determine their Cartographic representation on a WGS84 ellipsoid.
|
|
1287
|
+
* const positions = [new Cesium.Cartesian3(17832.12, 83234.52, 952313.73),
|
|
1288
|
+
* new Cesium.Cartesian3(17832.13, 83234.53, 952313.73),
|
|
1289
|
+
* new Cesium.Cartesian3(17832.14, 83234.54, 952313.73)]
|
|
1290
|
+
* const cartographicPositions = Cesium.Ellipsoid.WGS84.cartesianArrayToCartographicArray(positions);
|
|
1291
|
+
*/
|
|
1292
|
+
cartesianArrayToCartographicArray(cartesians, result) {
|
|
1293
|
+
Check_default.defined("cartesians", cartesians);
|
|
1294
|
+
const length = cartesians.length;
|
|
1295
|
+
if (!defined_default(result)) {
|
|
1296
|
+
result = new Array(length);
|
|
1297
|
+
} else {
|
|
1298
|
+
result.length = length;
|
|
1299
|
+
}
|
|
1300
|
+
for (let i = 0; i < length; ++i) {
|
|
1301
|
+
result[i] = this.cartesianToCartographic(cartesians[i], result[i]);
|
|
1302
|
+
}
|
|
1303
|
+
return result;
|
|
1304
|
+
}
|
|
1305
|
+
/**
|
|
1306
|
+
* Scales the provided Cartesian position along the geodetic surface normal
|
|
1307
|
+
* so that it is on the surface of this ellipsoid. If the position is
|
|
1308
|
+
* at the center of the ellipsoid, this function returns undefined.
|
|
1309
|
+
*
|
|
1310
|
+
* @param {Cartesian3} cartesian The Cartesian position to scale.
|
|
1311
|
+
* @param {Cartesian3} [result] The object onto which to store the result.
|
|
1312
|
+
* @returns {Cartesian3} The modified result parameter, a new Cartesian3 instance if none was provided, or undefined if the position is at the center.
|
|
1313
|
+
*/
|
|
1314
|
+
scaleToGeodeticSurface(cartesian, result) {
|
|
1315
|
+
return scaleToGeodeticSurface_default(
|
|
1316
|
+
cartesian,
|
|
1317
|
+
this._oneOverRadii,
|
|
1318
|
+
this._oneOverRadiiSquared,
|
|
1319
|
+
this._centerToleranceSquared,
|
|
1320
|
+
result
|
|
1321
|
+
);
|
|
1322
|
+
}
|
|
1323
|
+
/**
|
|
1324
|
+
* Scales the provided Cartesian position along the geocentric surface normal
|
|
1325
|
+
* so that it is on the surface of this ellipsoid.
|
|
1326
|
+
*
|
|
1327
|
+
* @param {Cartesian3} cartesian The Cartesian position to scale.
|
|
1328
|
+
* @param {Cartesian3} [result] The object onto which to store the result.
|
|
1329
|
+
* @returns {Cartesian3} The modified result parameter or a new Cartesian3 instance if none was provided.
|
|
1330
|
+
*/
|
|
1331
|
+
scaleToGeocentricSurface(cartesian, result) {
|
|
1332
|
+
Check_default.typeOf.object("cartesian", cartesian);
|
|
1333
|
+
if (!defined_default(result)) {
|
|
1334
|
+
result = new Cartesian3_default();
|
|
1335
|
+
}
|
|
1336
|
+
const positionX = cartesian.x;
|
|
1337
|
+
const positionY = cartesian.y;
|
|
1338
|
+
const positionZ = cartesian.z;
|
|
1339
|
+
const oneOverRadiiSquared = this._oneOverRadiiSquared;
|
|
1340
|
+
const beta = 1 / Math.sqrt(
|
|
1341
|
+
positionX * positionX * oneOverRadiiSquared.x + positionY * positionY * oneOverRadiiSquared.y + positionZ * positionZ * oneOverRadiiSquared.z
|
|
1342
|
+
);
|
|
1343
|
+
return Cartesian3_default.multiplyByScalar(cartesian, beta, result);
|
|
1344
|
+
}
|
|
1345
|
+
/**
|
|
1346
|
+
* Transforms a Cartesian X, Y, Z position to the ellipsoid-scaled space by multiplying
|
|
1347
|
+
* its components by the result of {@link Ellipsoid#oneOverRadii}.
|
|
1348
|
+
*
|
|
1349
|
+
* @param {Cartesian3} position The position to transform.
|
|
1350
|
+
* @param {Cartesian3} [result] The position to which to copy the result, or undefined to create and
|
|
1351
|
+
* return a new instance.
|
|
1352
|
+
* @returns {Cartesian3} The position expressed in the scaled space. The returned instance is the
|
|
1353
|
+
* one passed as the result parameter if it is not undefined, or a new instance of it is.
|
|
1354
|
+
*/
|
|
1355
|
+
transformPositionToScaledSpace(position, result) {
|
|
1356
|
+
if (!defined_default(result)) {
|
|
1357
|
+
result = new Cartesian3_default();
|
|
1358
|
+
}
|
|
1359
|
+
return Cartesian3_default.multiplyComponents(position, this._oneOverRadii, result);
|
|
1360
|
+
}
|
|
1361
|
+
/**
|
|
1362
|
+
* Transforms a Cartesian X, Y, Z position from the ellipsoid-scaled space by multiplying
|
|
1363
|
+
* its components by the result of {@link Ellipsoid#radii}.
|
|
1364
|
+
*
|
|
1365
|
+
* @param {Cartesian3} position The position to transform.
|
|
1366
|
+
* @param {Cartesian3} [result] The position to which to copy the result, or undefined to create and
|
|
1367
|
+
* return a new instance.
|
|
1368
|
+
* @returns {Cartesian3} The position expressed in the unscaled space. The returned instance is the
|
|
1369
|
+
* one passed as the result parameter if it is not undefined, or a new instance of it is.
|
|
1370
|
+
*/
|
|
1371
|
+
transformPositionFromScaledSpace(position, result) {
|
|
1372
|
+
if (!defined_default(result)) {
|
|
1373
|
+
result = new Cartesian3_default();
|
|
1374
|
+
}
|
|
1375
|
+
return Cartesian3_default.multiplyComponents(position, this._radii, result);
|
|
1376
|
+
}
|
|
1377
|
+
/**
|
|
1378
|
+
* Compares this Ellipsoid against the provided Ellipsoid componentwise and returns
|
|
1379
|
+
* <code>true</code> if they are equal, <code>false</code> otherwise.
|
|
1380
|
+
*
|
|
1381
|
+
* @param {Ellipsoid} [right] The other Ellipsoid.
|
|
1382
|
+
* @returns {boolean} <code>true</code> if they are equal, <code>false</code> otherwise.
|
|
1383
|
+
*/
|
|
1384
|
+
equals(right) {
|
|
1385
|
+
return this === right || defined_default(right) && Cartesian3_default.equals(this._radii, right._radii);
|
|
1386
|
+
}
|
|
1387
|
+
/**
|
|
1388
|
+
* Creates a string representing this Ellipsoid in the format '(radii.x, radii.y, radii.z)'.
|
|
1389
|
+
*
|
|
1390
|
+
* @returns {string} A string representing this ellipsoid in the format '(radii.x, radii.y, radii.z)'.
|
|
1391
|
+
*/
|
|
1392
|
+
toString() {
|
|
1393
|
+
return this._radii.toString();
|
|
1394
|
+
}
|
|
1395
|
+
/**
|
|
1396
|
+
* Computes a point which is the intersection of the surface normal with the z-axis.
|
|
1397
|
+
*
|
|
1398
|
+
* @param {Cartesian3} position the position. must be on the surface of the ellipsoid.
|
|
1399
|
+
* @param {number} [buffer = 0.0] A buffer to subtract from the ellipsoid size when checking if the point is inside the ellipsoid.
|
|
1400
|
+
* In earth case, with common earth datums, there is no need for this buffer since the intersection point is always (relatively) very close to the center.
|
|
1401
|
+
* In WGS84 datum, intersection point is at max z = +-42841.31151331382 (0.673% of z-axis).
|
|
1402
|
+
* Intersection point could be outside the ellipsoid if the ratio of MajorAxis / AxisOfRotation is bigger than the square root of 2
|
|
1403
|
+
* @param {Cartesian3} [result] The cartesian to which to copy the result, or undefined to create and
|
|
1404
|
+
* return a new instance.
|
|
1405
|
+
* @returns {Cartesian3 | undefined} the intersection point if it's inside the ellipsoid, undefined otherwise
|
|
1406
|
+
*
|
|
1407
|
+
* @exception {DeveloperError} position is required.
|
|
1408
|
+
* @exception {DeveloperError} Ellipsoid must be an ellipsoid of revolution (radii.x == radii.y).
|
|
1409
|
+
* @exception {DeveloperError} Ellipsoid.radii.z must be greater than 0.
|
|
1410
|
+
*/
|
|
1411
|
+
getSurfaceNormalIntersectionWithZAxis(position, buffer, result) {
|
|
1412
|
+
Check_default.typeOf.object("position", position);
|
|
1413
|
+
if (!Math_default.equalsEpsilon(
|
|
1414
|
+
this._radii.x,
|
|
1415
|
+
this._radii.y,
|
|
1416
|
+
Math_default.EPSILON15
|
|
1417
|
+
)) {
|
|
1418
|
+
throw new DeveloperError_default(
|
|
1419
|
+
"Ellipsoid must be an ellipsoid of revolution (radii.x == radii.y)"
|
|
1420
|
+
);
|
|
1421
|
+
}
|
|
1422
|
+
Check_default.typeOf.number.greaterThan("Ellipsoid.radii.z", this._radii.z, 0);
|
|
1423
|
+
buffer = buffer ?? 0;
|
|
1424
|
+
const squaredXOverSquaredZ = this._squaredXOverSquaredZ;
|
|
1425
|
+
if (!defined_default(result)) {
|
|
1426
|
+
result = new Cartesian3_default();
|
|
1427
|
+
}
|
|
1428
|
+
result.x = 0;
|
|
1429
|
+
result.y = 0;
|
|
1430
|
+
result.z = position.z * (1 - squaredXOverSquaredZ);
|
|
1431
|
+
if (Math.abs(result.z) >= this._radii.z - buffer) {
|
|
1432
|
+
return void 0;
|
|
1433
|
+
}
|
|
1434
|
+
return result;
|
|
1435
|
+
}
|
|
1436
|
+
/**
|
|
1437
|
+
* Computes the ellipsoid curvatures at a given position on the surface.
|
|
1438
|
+
*
|
|
1439
|
+
* @param {Cartesian3} surfacePosition The position on the ellipsoid surface where curvatures will be calculated.
|
|
1440
|
+
* @param {Cartesian2} [result] The cartesian to which to copy the result, or undefined to create and return a new instance.
|
|
1441
|
+
* @returns {Cartesian2} The local curvature of the ellipsoid surface at the provided position, in east and north directions.
|
|
1442
|
+
*
|
|
1443
|
+
* @exception {DeveloperError} position is required.
|
|
1444
|
+
*/
|
|
1445
|
+
getLocalCurvature(surfacePosition, result) {
|
|
1446
|
+
Check_default.typeOf.object("surfacePosition", surfacePosition);
|
|
1447
|
+
if (!defined_default(result)) {
|
|
1448
|
+
result = new Cartesian2_default();
|
|
1449
|
+
}
|
|
1450
|
+
const primeVerticalEndpoint = this.getSurfaceNormalIntersectionWithZAxis(
|
|
1451
|
+
surfacePosition,
|
|
1452
|
+
0,
|
|
1453
|
+
scratchEndpoint
|
|
1454
|
+
);
|
|
1455
|
+
const primeVerticalRadius = Cartesian3_default.distance(
|
|
1456
|
+
surfacePosition,
|
|
1457
|
+
primeVerticalEndpoint
|
|
1458
|
+
);
|
|
1459
|
+
const radiusRatio = this.minimumRadius * primeVerticalRadius / this.maximumRadius ** 2;
|
|
1460
|
+
const meridionalRadius = primeVerticalRadius * radiusRatio ** 2;
|
|
1461
|
+
return Cartesian2_default.fromElements(
|
|
1462
|
+
1 / primeVerticalRadius,
|
|
1463
|
+
1 / meridionalRadius,
|
|
1464
|
+
result
|
|
1465
|
+
);
|
|
1466
|
+
}
|
|
1467
|
+
/**
|
|
1468
|
+
* Computes an approximation of the surface area of a rectangle on the surface of an ellipsoid using
|
|
1469
|
+
* Gauss-Legendre 10th order quadrature.
|
|
1470
|
+
*
|
|
1471
|
+
* @param {Rectangle} rectangle The rectangle used for computing the surface area.
|
|
1472
|
+
* @returns {number} The approximate area of the rectangle on the surface of this ellipsoid.
|
|
1473
|
+
*/
|
|
1474
|
+
surfaceArea(rectangle) {
|
|
1475
|
+
Check_default.typeOf.object("rectangle", rectangle);
|
|
1476
|
+
const minLongitude = rectangle.west;
|
|
1477
|
+
let maxLongitude = rectangle.east;
|
|
1478
|
+
const minLatitude = rectangle.south;
|
|
1479
|
+
const maxLatitude = rectangle.north;
|
|
1480
|
+
while (maxLongitude < minLongitude) {
|
|
1481
|
+
maxLongitude += Math_default.TWO_PI;
|
|
1482
|
+
}
|
|
1483
|
+
const radiiSquared = this._radiiSquared;
|
|
1484
|
+
const a2 = radiiSquared.x;
|
|
1485
|
+
const b2 = radiiSquared.y;
|
|
1486
|
+
const c2 = radiiSquared.z;
|
|
1487
|
+
const a2b2 = a2 * b2;
|
|
1488
|
+
return gaussLegendreQuadrature(minLatitude, maxLatitude, function(lat) {
|
|
1489
|
+
const sinPhi = Math.cos(lat);
|
|
1490
|
+
const cosPhi = Math.sin(lat);
|
|
1491
|
+
return Math.cos(lat) * gaussLegendreQuadrature(minLongitude, maxLongitude, function(lon) {
|
|
1492
|
+
const cosTheta = Math.cos(lon);
|
|
1493
|
+
const sinTheta = Math.sin(lon);
|
|
1494
|
+
return Math.sqrt(
|
|
1495
|
+
a2b2 * cosPhi * cosPhi + c2 * (b2 * cosTheta * cosTheta + a2 * sinTheta * sinTheta) * sinPhi * sinPhi
|
|
1496
|
+
);
|
|
1497
|
+
});
|
|
1498
|
+
});
|
|
1499
|
+
}
|
|
1500
|
+
};
|
|
1501
|
+
Ellipsoid.WGS84 = Object.freeze(
|
|
1502
|
+
new Ellipsoid(6378137, 6378137, 6356752314245179e-9)
|
|
1503
|
+
);
|
|
1504
|
+
Ellipsoid.UNIT_SPHERE = Object.freeze(new Ellipsoid(1, 1, 1));
|
|
1505
|
+
Ellipsoid.MOON = Object.freeze(
|
|
1506
|
+
new Ellipsoid(
|
|
1507
|
+
Math_default.LUNAR_RADIUS,
|
|
1508
|
+
Math_default.LUNAR_RADIUS,
|
|
1509
|
+
Math_default.LUNAR_RADIUS
|
|
1510
|
+
)
|
|
1511
|
+
);
|
|
1512
|
+
Ellipsoid.MARS = Object.freeze(new Ellipsoid(3396190, 3396190, 3376200));
|
|
1513
|
+
Ellipsoid._default = Ellipsoid.WGS84;
|
|
1514
|
+
Ellipsoid.packedLength = Cartesian3_default.packedLength;
|
|
1515
|
+
Ellipsoid.prototype.geocentricSurfaceNormal = Cartesian3_default.normalize;
|
|
1516
|
+
var cartographicToCartesianNormal = new Cartesian3_default();
|
|
1517
|
+
var cartographicToCartesianK = new Cartesian3_default();
|
|
1518
|
+
var cartesianToCartographicN2 = new Cartesian3_default();
|
|
1519
|
+
var cartesianToCartographicP2 = new Cartesian3_default();
|
|
1520
|
+
var cartesianToCartographicH2 = new Cartesian3_default();
|
|
1521
|
+
var scratchEndpoint = new Cartesian3_default();
|
|
1522
|
+
var abscissas = [
|
|
1523
|
+
0.14887433898163,
|
|
1524
|
+
0.43339539412925,
|
|
1525
|
+
0.67940956829902,
|
|
1526
|
+
0.86506336668898,
|
|
1527
|
+
0.97390652851717,
|
|
1528
|
+
0
|
|
1529
|
+
];
|
|
1530
|
+
var weights = [
|
|
1531
|
+
0.29552422471475,
|
|
1532
|
+
0.26926671930999,
|
|
1533
|
+
0.21908636251598,
|
|
1534
|
+
0.14945134915058,
|
|
1535
|
+
0.066671344308684,
|
|
1536
|
+
0
|
|
1537
|
+
];
|
|
1538
|
+
function gaussLegendreQuadrature(a, b, func) {
|
|
1539
|
+
Check_default.typeOf.number("a", a);
|
|
1540
|
+
Check_default.typeOf.number("b", b);
|
|
1541
|
+
Check_default.typeOf.func("func", func);
|
|
1542
|
+
const xMean = 0.5 * (b + a);
|
|
1543
|
+
const xRange = 0.5 * (b - a);
|
|
1544
|
+
let sum = 0;
|
|
1545
|
+
for (let i = 0; i < 5; i++) {
|
|
1546
|
+
const dx = xRange * abscissas[i];
|
|
1547
|
+
sum += weights[i] * (func(xMean + dx) + func(xMean - dx));
|
|
1548
|
+
}
|
|
1549
|
+
sum *= xRange;
|
|
1550
|
+
return sum;
|
|
1551
|
+
}
|
|
1552
|
+
var Ellipsoid_default = Ellipsoid;
|
|
1553
|
+
|
|
1554
|
+
// packages/engine/Source/Core/Fullscreen.js
|
|
1555
|
+
var _supportsFullscreen;
|
|
1556
|
+
var _names = {
|
|
1557
|
+
requestFullscreen: void 0,
|
|
1558
|
+
exitFullscreen: void 0,
|
|
1559
|
+
fullscreenEnabled: void 0,
|
|
1560
|
+
fullscreenElement: void 0,
|
|
1561
|
+
fullscreenchange: void 0,
|
|
1562
|
+
fullscreenerror: void 0
|
|
1563
|
+
};
|
|
1564
|
+
var Fullscreen = {};
|
|
1565
|
+
Object.defineProperties(Fullscreen, {
|
|
1566
|
+
/**
|
|
1567
|
+
* The element that is currently fullscreen, if any. To simply check if the
|
|
1568
|
+
* browser is in fullscreen mode or not, use {@link Fullscreen#fullscreen}.
|
|
1569
|
+
* @memberof Fullscreen
|
|
1570
|
+
* @type {object}
|
|
1571
|
+
* @readonly
|
|
1572
|
+
*/
|
|
1573
|
+
element: {
|
|
1574
|
+
get: function() {
|
|
1575
|
+
if (!Fullscreen.supportsFullscreen()) {
|
|
1576
|
+
return void 0;
|
|
1577
|
+
}
|
|
1578
|
+
return document[_names.fullscreenElement];
|
|
1579
|
+
}
|
|
1580
|
+
},
|
|
1581
|
+
/**
|
|
1582
|
+
* The name of the event on the document that is fired when fullscreen is
|
|
1583
|
+
* entered or exited. This event name is intended for use with addEventListener.
|
|
1584
|
+
* In your event handler, to determine if the browser is in fullscreen mode or not,
|
|
1585
|
+
* use {@link Fullscreen#fullscreen}.
|
|
1586
|
+
* @memberof Fullscreen
|
|
1587
|
+
* @type {string}
|
|
1588
|
+
* @readonly
|
|
1589
|
+
*/
|
|
1590
|
+
changeEventName: {
|
|
1591
|
+
get: function() {
|
|
1592
|
+
if (!Fullscreen.supportsFullscreen()) {
|
|
1593
|
+
return void 0;
|
|
1594
|
+
}
|
|
1595
|
+
return _names.fullscreenchange;
|
|
1596
|
+
}
|
|
1597
|
+
},
|
|
1598
|
+
/**
|
|
1599
|
+
* The name of the event that is fired when a fullscreen error
|
|
1600
|
+
* occurs. This event name is intended for use with addEventListener.
|
|
1601
|
+
* @memberof Fullscreen
|
|
1602
|
+
* @type {string}
|
|
1603
|
+
* @readonly
|
|
1604
|
+
*/
|
|
1605
|
+
errorEventName: {
|
|
1606
|
+
get: function() {
|
|
1607
|
+
if (!Fullscreen.supportsFullscreen()) {
|
|
1608
|
+
return void 0;
|
|
1609
|
+
}
|
|
1610
|
+
return _names.fullscreenerror;
|
|
1611
|
+
}
|
|
1612
|
+
},
|
|
1613
|
+
/**
|
|
1614
|
+
* Determine whether the browser will allow an element to be made fullscreen, or not.
|
|
1615
|
+
* For example, by default, iframes cannot go fullscreen unless the containing page
|
|
1616
|
+
* adds an "allowfullscreen" attribute (or prefixed equivalent).
|
|
1617
|
+
* @memberof Fullscreen
|
|
1618
|
+
* @type {boolean}
|
|
1619
|
+
* @readonly
|
|
1620
|
+
*/
|
|
1621
|
+
enabled: {
|
|
1622
|
+
get: function() {
|
|
1623
|
+
if (!Fullscreen.supportsFullscreen()) {
|
|
1624
|
+
return void 0;
|
|
1625
|
+
}
|
|
1626
|
+
return document[_names.fullscreenEnabled];
|
|
1627
|
+
}
|
|
1628
|
+
},
|
|
1629
|
+
/**
|
|
1630
|
+
* Determines if the browser is currently in fullscreen mode.
|
|
1631
|
+
* @memberof Fullscreen
|
|
1632
|
+
* @type {boolean}
|
|
1633
|
+
* @readonly
|
|
1634
|
+
*/
|
|
1635
|
+
fullscreen: {
|
|
1636
|
+
get: function() {
|
|
1637
|
+
if (!Fullscreen.supportsFullscreen()) {
|
|
1638
|
+
return void 0;
|
|
1639
|
+
}
|
|
1640
|
+
return Fullscreen.element !== null;
|
|
1641
|
+
}
|
|
1642
|
+
}
|
|
1643
|
+
});
|
|
1644
|
+
Fullscreen.supportsFullscreen = function() {
|
|
1645
|
+
if (defined_default(_supportsFullscreen)) {
|
|
1646
|
+
return _supportsFullscreen;
|
|
1647
|
+
}
|
|
1648
|
+
_supportsFullscreen = false;
|
|
1649
|
+
const body = document.body;
|
|
1650
|
+
if (typeof body.requestFullscreen === "function") {
|
|
1651
|
+
_names.requestFullscreen = "requestFullscreen";
|
|
1652
|
+
_names.exitFullscreen = "exitFullscreen";
|
|
1653
|
+
_names.fullscreenEnabled = "fullscreenEnabled";
|
|
1654
|
+
_names.fullscreenElement = "fullscreenElement";
|
|
1655
|
+
_names.fullscreenchange = "fullscreenchange";
|
|
1656
|
+
_names.fullscreenerror = "fullscreenerror";
|
|
1657
|
+
_supportsFullscreen = true;
|
|
1658
|
+
return _supportsFullscreen;
|
|
1659
|
+
}
|
|
1660
|
+
const prefixes = ["webkit", "moz", "o", "ms", "khtml"];
|
|
1661
|
+
let name;
|
|
1662
|
+
for (let i = 0, len = prefixes.length; i < len; ++i) {
|
|
1663
|
+
const prefix = prefixes[i];
|
|
1664
|
+
name = `${prefix}RequestFullscreen`;
|
|
1665
|
+
if (typeof body[name] === "function") {
|
|
1666
|
+
_names.requestFullscreen = name;
|
|
1667
|
+
_supportsFullscreen = true;
|
|
1668
|
+
} else {
|
|
1669
|
+
name = `${prefix}RequestFullScreen`;
|
|
1670
|
+
if (typeof body[name] === "function") {
|
|
1671
|
+
_names.requestFullscreen = name;
|
|
1672
|
+
_supportsFullscreen = true;
|
|
1673
|
+
}
|
|
1674
|
+
}
|
|
1675
|
+
name = `${prefix}ExitFullscreen`;
|
|
1676
|
+
if (typeof document[name] === "function") {
|
|
1677
|
+
_names.exitFullscreen = name;
|
|
1678
|
+
} else {
|
|
1679
|
+
name = `${prefix}CancelFullScreen`;
|
|
1680
|
+
if (typeof document[name] === "function") {
|
|
1681
|
+
_names.exitFullscreen = name;
|
|
1682
|
+
}
|
|
1683
|
+
}
|
|
1684
|
+
name = `${prefix}FullscreenEnabled`;
|
|
1685
|
+
if (document[name] !== void 0) {
|
|
1686
|
+
_names.fullscreenEnabled = name;
|
|
1687
|
+
} else {
|
|
1688
|
+
name = `${prefix}FullScreenEnabled`;
|
|
1689
|
+
if (document[name] !== void 0) {
|
|
1690
|
+
_names.fullscreenEnabled = name;
|
|
1691
|
+
}
|
|
1692
|
+
}
|
|
1693
|
+
name = `${prefix}FullscreenElement`;
|
|
1694
|
+
if (document[name] !== void 0) {
|
|
1695
|
+
_names.fullscreenElement = name;
|
|
1696
|
+
} else {
|
|
1697
|
+
name = `${prefix}FullScreenElement`;
|
|
1698
|
+
if (document[name] !== void 0) {
|
|
1699
|
+
_names.fullscreenElement = name;
|
|
1700
|
+
}
|
|
1701
|
+
}
|
|
1702
|
+
name = `${prefix}fullscreenchange`;
|
|
1703
|
+
if (document[`on${name}`] !== void 0) {
|
|
1704
|
+
if (prefix === "ms") {
|
|
1705
|
+
name = "MSFullscreenChange";
|
|
1706
|
+
}
|
|
1707
|
+
_names.fullscreenchange = name;
|
|
1708
|
+
}
|
|
1709
|
+
name = `${prefix}fullscreenerror`;
|
|
1710
|
+
if (document[`on${name}`] !== void 0) {
|
|
1711
|
+
if (prefix === "ms") {
|
|
1712
|
+
name = "MSFullscreenError";
|
|
1713
|
+
}
|
|
1714
|
+
_names.fullscreenerror = name;
|
|
1715
|
+
}
|
|
1716
|
+
}
|
|
1717
|
+
return _supportsFullscreen;
|
|
1718
|
+
};
|
|
1719
|
+
Fullscreen.requestFullscreen = function(element, vrDevice) {
|
|
1720
|
+
if (!Fullscreen.supportsFullscreen()) {
|
|
1721
|
+
return;
|
|
1722
|
+
}
|
|
1723
|
+
element[_names.requestFullscreen]({ vrDisplay: vrDevice });
|
|
1724
|
+
};
|
|
1725
|
+
Fullscreen.exitFullscreen = function() {
|
|
1726
|
+
if (!Fullscreen.supportsFullscreen()) {
|
|
1727
|
+
return;
|
|
1728
|
+
}
|
|
1729
|
+
document[_names.exitFullscreen]();
|
|
1730
|
+
};
|
|
1731
|
+
Fullscreen._names = _names;
|
|
1732
|
+
var Fullscreen_default = Fullscreen;
|
|
1733
|
+
|
|
1734
|
+
// packages/engine/Source/Core/FeatureDetection.js
|
|
1735
|
+
var theNavigator;
|
|
1736
|
+
if (typeof navigator !== "undefined") {
|
|
1737
|
+
theNavigator = navigator;
|
|
1738
|
+
} else {
|
|
1739
|
+
theNavigator = {};
|
|
1740
|
+
}
|
|
1741
|
+
function extractVersion(versionString) {
|
|
1742
|
+
const parts = versionString.split(".");
|
|
1743
|
+
for (let i = 0, len = parts.length; i < len; ++i) {
|
|
1744
|
+
parts[i] = parseInt(parts[i], 10);
|
|
1745
|
+
}
|
|
1746
|
+
return parts;
|
|
1747
|
+
}
|
|
1748
|
+
var isChromeResult;
|
|
1749
|
+
var chromeVersionResult;
|
|
1750
|
+
function isChrome() {
|
|
1751
|
+
if (!defined_default(isChromeResult)) {
|
|
1752
|
+
isChromeResult = false;
|
|
1753
|
+
if (!isEdge()) {
|
|
1754
|
+
const fields = / Chrome\/([\.0-9]+)/.exec(theNavigator.userAgent);
|
|
1755
|
+
if (fields !== null) {
|
|
1756
|
+
isChromeResult = true;
|
|
1757
|
+
chromeVersionResult = extractVersion(fields[1]);
|
|
1758
|
+
}
|
|
1759
|
+
}
|
|
1760
|
+
}
|
|
1761
|
+
return isChromeResult;
|
|
1762
|
+
}
|
|
1763
|
+
function chromeVersion() {
|
|
1764
|
+
return isChrome() && chromeVersionResult;
|
|
1765
|
+
}
|
|
1766
|
+
var isSafariResult;
|
|
1767
|
+
var safariVersionResult;
|
|
1768
|
+
function isSafari() {
|
|
1769
|
+
if (!defined_default(isSafariResult)) {
|
|
1770
|
+
isSafariResult = false;
|
|
1771
|
+
if (!isChrome() && !isEdge() && / Safari\/[\.0-9]+/.test(theNavigator.userAgent)) {
|
|
1772
|
+
const fields = / Version\/([\.0-9]+)/.exec(theNavigator.userAgent);
|
|
1773
|
+
if (fields !== null) {
|
|
1774
|
+
isSafariResult = true;
|
|
1775
|
+
safariVersionResult = extractVersion(fields[1]);
|
|
1776
|
+
}
|
|
1777
|
+
}
|
|
1778
|
+
}
|
|
1779
|
+
return isSafariResult;
|
|
1780
|
+
}
|
|
1781
|
+
function safariVersion() {
|
|
1782
|
+
return isSafari() && safariVersionResult;
|
|
1783
|
+
}
|
|
1784
|
+
var isWebkitResult;
|
|
1785
|
+
var webkitVersionResult;
|
|
1786
|
+
function isWebkit() {
|
|
1787
|
+
if (!defined_default(isWebkitResult)) {
|
|
1788
|
+
isWebkitResult = false;
|
|
1789
|
+
const fields = / AppleWebKit\/([\.0-9]+)(\+?)/.exec(theNavigator.userAgent);
|
|
1790
|
+
if (fields !== null) {
|
|
1791
|
+
isWebkitResult = true;
|
|
1792
|
+
webkitVersionResult = extractVersion(fields[1]);
|
|
1793
|
+
webkitVersionResult.isNightly = !!fields[2];
|
|
1794
|
+
}
|
|
1795
|
+
}
|
|
1796
|
+
return isWebkitResult;
|
|
1797
|
+
}
|
|
1798
|
+
function webkitVersion() {
|
|
1799
|
+
return isWebkit() && webkitVersionResult;
|
|
1800
|
+
}
|
|
1801
|
+
var isEdgeResult;
|
|
1802
|
+
var edgeVersionResult;
|
|
1803
|
+
function isEdge() {
|
|
1804
|
+
if (!defined_default(isEdgeResult)) {
|
|
1805
|
+
isEdgeResult = false;
|
|
1806
|
+
const fields = / Edg\/([\.0-9]+)/.exec(theNavigator.userAgent);
|
|
1807
|
+
if (fields !== null) {
|
|
1808
|
+
isEdgeResult = true;
|
|
1809
|
+
edgeVersionResult = extractVersion(fields[1]);
|
|
1810
|
+
}
|
|
1811
|
+
}
|
|
1812
|
+
return isEdgeResult;
|
|
1813
|
+
}
|
|
1814
|
+
function edgeVersion() {
|
|
1815
|
+
return isEdge() && edgeVersionResult;
|
|
1816
|
+
}
|
|
1817
|
+
var isFirefoxResult;
|
|
1818
|
+
var firefoxVersionResult;
|
|
1819
|
+
function isFirefox() {
|
|
1820
|
+
if (!defined_default(isFirefoxResult)) {
|
|
1821
|
+
isFirefoxResult = false;
|
|
1822
|
+
const fields = /Firefox\/([\.0-9]+)/.exec(theNavigator.userAgent);
|
|
1823
|
+
if (fields !== null) {
|
|
1824
|
+
isFirefoxResult = true;
|
|
1825
|
+
firefoxVersionResult = extractVersion(fields[1]);
|
|
1826
|
+
}
|
|
1827
|
+
}
|
|
1828
|
+
return isFirefoxResult;
|
|
1829
|
+
}
|
|
1830
|
+
var isWindowsResult;
|
|
1831
|
+
function isWindows() {
|
|
1832
|
+
if (!defined_default(isWindowsResult)) {
|
|
1833
|
+
isWindowsResult = /Windows/i.test(theNavigator.appVersion);
|
|
1834
|
+
}
|
|
1835
|
+
return isWindowsResult;
|
|
1836
|
+
}
|
|
1837
|
+
var isIPadOrIOSResult;
|
|
1838
|
+
function isIPadOrIOS() {
|
|
1839
|
+
if (!defined_default(isIPadOrIOSResult)) {
|
|
1840
|
+
isIPadOrIOSResult = navigator.platform === "iPhone" || navigator.platform === "iPod" || navigator.platform === "iPad";
|
|
1841
|
+
}
|
|
1842
|
+
return isIPadOrIOSResult;
|
|
1843
|
+
}
|
|
1844
|
+
function firefoxVersion() {
|
|
1845
|
+
return isFirefox() && firefoxVersionResult;
|
|
1846
|
+
}
|
|
1847
|
+
var hasPointerEvents;
|
|
1848
|
+
function supportsPointerEvents() {
|
|
1849
|
+
if (!defined_default(hasPointerEvents)) {
|
|
1850
|
+
hasPointerEvents = !isFirefox() && typeof PointerEvent !== "undefined" && (!defined_default(theNavigator.pointerEnabled) || theNavigator.pointerEnabled);
|
|
1851
|
+
}
|
|
1852
|
+
return hasPointerEvents;
|
|
1853
|
+
}
|
|
1854
|
+
var imageRenderingValueResult;
|
|
1855
|
+
var supportsImageRenderingPixelatedResult;
|
|
1856
|
+
function supportsImageRenderingPixelated() {
|
|
1857
|
+
if (!defined_default(supportsImageRenderingPixelatedResult)) {
|
|
1858
|
+
const canvas = document.createElement("canvas");
|
|
1859
|
+
canvas.setAttribute(
|
|
1860
|
+
"style",
|
|
1861
|
+
"image-rendering: -moz-crisp-edges;image-rendering: pixelated;"
|
|
1862
|
+
);
|
|
1863
|
+
const tmp = canvas.style.imageRendering;
|
|
1864
|
+
supportsImageRenderingPixelatedResult = defined_default(tmp) && tmp !== "";
|
|
1865
|
+
if (supportsImageRenderingPixelatedResult) {
|
|
1866
|
+
imageRenderingValueResult = tmp;
|
|
1867
|
+
}
|
|
1868
|
+
}
|
|
1869
|
+
return supportsImageRenderingPixelatedResult;
|
|
1870
|
+
}
|
|
1871
|
+
function imageRenderingValue() {
|
|
1872
|
+
return supportsImageRenderingPixelated() ? imageRenderingValueResult : void 0;
|
|
1873
|
+
}
|
|
1874
|
+
function supportsWebP() {
|
|
1875
|
+
if (!supportsWebP.initialized) {
|
|
1876
|
+
throw new DeveloperError_default(
|
|
1877
|
+
"You must call FeatureDetection.supportsWebP.initialize and wait for the promise to resolve before calling FeatureDetection.supportsWebP"
|
|
1878
|
+
);
|
|
1879
|
+
}
|
|
1880
|
+
return supportsWebP._result;
|
|
1881
|
+
}
|
|
1882
|
+
supportsWebP._promise = void 0;
|
|
1883
|
+
supportsWebP._result = void 0;
|
|
1884
|
+
supportsWebP.initialize = function() {
|
|
1885
|
+
if (defined_default(supportsWebP._promise)) {
|
|
1886
|
+
return supportsWebP._promise;
|
|
1887
|
+
}
|
|
1888
|
+
supportsWebP._promise = new Promise((resolve) => {
|
|
1889
|
+
const image = new Image();
|
|
1890
|
+
image.onload = function() {
|
|
1891
|
+
supportsWebP._result = image.width > 0 && image.height > 0;
|
|
1892
|
+
resolve(supportsWebP._result);
|
|
1893
|
+
};
|
|
1894
|
+
image.onerror = function() {
|
|
1895
|
+
supportsWebP._result = false;
|
|
1896
|
+
resolve(supportsWebP._result);
|
|
1897
|
+
};
|
|
1898
|
+
image.src = "data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA";
|
|
1899
|
+
});
|
|
1900
|
+
return supportsWebP._promise;
|
|
1901
|
+
};
|
|
1902
|
+
Object.defineProperties(supportsWebP, {
|
|
1903
|
+
initialized: {
|
|
1904
|
+
get: function() {
|
|
1905
|
+
return defined_default(supportsWebP._result);
|
|
1906
|
+
}
|
|
1907
|
+
}
|
|
1908
|
+
});
|
|
1909
|
+
var typedArrayTypes = [];
|
|
1910
|
+
if (typeof ArrayBuffer !== "undefined") {
|
|
1911
|
+
typedArrayTypes.push(
|
|
1912
|
+
Int8Array,
|
|
1913
|
+
Uint8Array,
|
|
1914
|
+
Int16Array,
|
|
1915
|
+
Uint16Array,
|
|
1916
|
+
Int32Array,
|
|
1917
|
+
Uint32Array,
|
|
1918
|
+
Float32Array,
|
|
1919
|
+
Float64Array
|
|
1920
|
+
);
|
|
1921
|
+
if (typeof Uint8ClampedArray !== "undefined") {
|
|
1922
|
+
typedArrayTypes.push(Uint8ClampedArray);
|
|
1923
|
+
}
|
|
1924
|
+
if (typeof Uint8ClampedArray !== "undefined") {
|
|
1925
|
+
typedArrayTypes.push(Uint8ClampedArray);
|
|
1926
|
+
}
|
|
1927
|
+
if (typeof BigInt64Array !== "undefined") {
|
|
1928
|
+
typedArrayTypes.push(BigInt64Array);
|
|
1929
|
+
}
|
|
1930
|
+
if (typeof BigUint64Array !== "undefined") {
|
|
1931
|
+
typedArrayTypes.push(BigUint64Array);
|
|
1932
|
+
}
|
|
1933
|
+
}
|
|
1934
|
+
var FeatureDetection = {
|
|
1935
|
+
isChrome,
|
|
1936
|
+
chromeVersion,
|
|
1937
|
+
isSafari,
|
|
1938
|
+
safariVersion,
|
|
1939
|
+
isWebkit,
|
|
1940
|
+
webkitVersion,
|
|
1941
|
+
isEdge,
|
|
1942
|
+
edgeVersion,
|
|
1943
|
+
isFirefox,
|
|
1944
|
+
firefoxVersion,
|
|
1945
|
+
isWindows,
|
|
1946
|
+
isIPadOrIOS,
|
|
1947
|
+
hardwareConcurrency: theNavigator.hardwareConcurrency ?? 3,
|
|
1948
|
+
supportsPointerEvents,
|
|
1949
|
+
supportsImageRenderingPixelated,
|
|
1950
|
+
supportsWebP,
|
|
1951
|
+
imageRenderingValue,
|
|
1952
|
+
typedArrayTypes
|
|
1953
|
+
};
|
|
1954
|
+
FeatureDetection.supportsBasis = function(scene) {
|
|
1955
|
+
return FeatureDetection.supportsWebAssembly() && scene.context.supportsBasis;
|
|
1956
|
+
};
|
|
1957
|
+
FeatureDetection.supportsFullscreen = function() {
|
|
1958
|
+
return Fullscreen_default.supportsFullscreen();
|
|
1959
|
+
};
|
|
1960
|
+
FeatureDetection.supportsTypedArrays = function() {
|
|
1961
|
+
return typeof ArrayBuffer !== "undefined";
|
|
1962
|
+
};
|
|
1963
|
+
FeatureDetection.supportsBigInt64Array = function() {
|
|
1964
|
+
return typeof BigInt64Array !== "undefined";
|
|
1965
|
+
};
|
|
1966
|
+
FeatureDetection.supportsBigUint64Array = function() {
|
|
1967
|
+
return typeof BigUint64Array !== "undefined";
|
|
1968
|
+
};
|
|
1969
|
+
FeatureDetection.supportsBigInt = function() {
|
|
1970
|
+
return typeof BigInt !== "undefined";
|
|
1971
|
+
};
|
|
1972
|
+
FeatureDetection.supportsWebWorkers = function() {
|
|
1973
|
+
return typeof Worker !== "undefined";
|
|
1974
|
+
};
|
|
1975
|
+
FeatureDetection.supportsWebAssembly = function() {
|
|
1976
|
+
return typeof WebAssembly !== "undefined";
|
|
1977
|
+
};
|
|
1978
|
+
FeatureDetection.supportsWebgl2 = function(scene) {
|
|
1979
|
+
Check_default.defined("scene", scene);
|
|
1980
|
+
return scene.context.webgl2;
|
|
1981
|
+
};
|
|
1982
|
+
FeatureDetection.supportsEsmWebWorkers = function() {
|
|
1983
|
+
return !isFirefox() || parseInt(firefoxVersionResult) >= 114;
|
|
1984
|
+
};
|
|
1985
|
+
var FeatureDetection_default = FeatureDetection;
|
|
1986
|
+
|
|
1987
|
+
export {
|
|
1988
|
+
Cartographic_default,
|
|
1989
|
+
Cartesian2_default,
|
|
1990
|
+
Ellipsoid_default,
|
|
1991
|
+
FeatureDetection_default
|
|
1992
|
+
};
|