@cesium/engine 22.2.0 → 23.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Build/Workers/{chunk-YFEZPDAY.js → chunk-2GL2EUEE.js} +11 -11
- package/Build/Workers/{chunk-A3NUMZBG.js → chunk-2WI4HGJU.js} +6 -6
- package/Build/Workers/{chunk-3JB2X2PR.js → chunk-36LBFITA.js} +665 -366
- package/Build/Workers/{chunk-VSZ5DB2W.js → chunk-3B65YFXC.js} +1 -1
- package/Build/Workers/{chunk-PSHZAHFE.js → chunk-4LGFX2P5.js} +11 -11
- package/Build/Workers/{chunk-AMWXJ5A7.js → chunk-4UNQX2MP.js} +2 -2
- package/Build/Workers/{chunk-LDSQMLRC.js → chunk-52K3GJKG.js} +3 -3
- package/Build/Workers/{chunk-MSTAVM2N.js → chunk-56OHFSLH.js} +10 -10
- package/Build/Workers/{chunk-IWOSJVFQ.js → chunk-5A7YSAXT.js} +14 -14
- package/Build/Workers/{chunk-PMDPP22G.js → chunk-5JP5FG7U.js} +7 -7
- package/Build/Workers/{chunk-DIJ7IG5D.js → chunk-5R7SBUTW.js} +10 -10
- package/Build/Workers/chunk-5VKZVPO5.js +1829 -0
- package/Build/Workers/{chunk-L2FSBEW2.js → chunk-6FVFM2KB.js} +5 -5
- package/Build/Workers/{chunk-G6WQA27G.js → chunk-6SLGTBB2.js} +5 -5
- package/Build/Workers/{chunk-3HUEBDFC.js → chunk-7KRN6JPQ.js} +14 -14
- package/Build/Workers/{chunk-GMHDOQPH.js → chunk-AA33B6PU.js} +4 -4
- package/Build/Workers/{chunk-7CDQUIP5.js → chunk-AP6XWET5.js} +8 -8
- package/Build/Workers/{chunk-IVN5HSOI.js → chunk-APDKMX7W.js} +6 -6
- package/Build/Workers/{chunk-72LZ3FN6.js → chunk-ARCFIOKA.js} +12 -12
- package/Build/Workers/{chunk-UBJYWGMV.js → chunk-BNBD2YZK.js} +16 -16
- package/Build/Workers/{chunk-VGH2CSC7.js → chunk-DT5SJBKA.js} +29 -15
- package/Build/Workers/{chunk-ED4UXMYY.js → chunk-ESD4IEOU.js} +5 -5
- package/Build/Workers/{chunk-JFN2DQHY.js → chunk-FSDVXW7M.js} +5 -5
- package/Build/Workers/{chunk-JERDRSEI.js → chunk-G3YT7M7A.js} +1 -1
- package/Build/Workers/{chunk-NY3CWLIZ.js → chunk-GN5NEUDT.js} +8 -8
- package/Build/Workers/{chunk-O3GWUTWM.js → chunk-HYLEKKO5.js} +1 -1
- package/Build/Workers/{chunk-64PJ4MTB.js → chunk-HYTFXWMY.js} +7 -7
- package/Build/Workers/{chunk-FPRM6PCE.js → chunk-IFA7VHHP.js} +560 -306
- package/Build/Workers/{chunk-FM5XPC2E.js → chunk-IYVDOB5V.js} +4 -4
- package/Build/Workers/{chunk-P7ISUYLW.js → chunk-JUGY5AZN.js} +4 -4
- package/Build/Workers/{chunk-JONWM4IO.js → chunk-KPYU6YZG.js} +1 -1
- package/Build/Workers/{chunk-JUOSYFXT.js → chunk-L7RDJ4V7.js} +1 -1
- package/Build/Workers/{chunk-MWGB6DLR.js → chunk-LDQWNMEC.js} +1 -1
- package/Build/Workers/{chunk-C6FTHSJA.js → chunk-MQJG522T.js} +6 -6
- package/Build/Workers/{chunk-WH4HDRGN.js → chunk-MT5M7RLZ.js} +2 -2
- package/Build/Workers/{chunk-4ZQN7M7E.js → chunk-N4AWE7TZ.js} +10 -10
- package/Build/Workers/{chunk-SDUH3N6G.js → chunk-NAYRNPEP.js} +4 -4
- package/Build/Workers/{chunk-7OPRTZBT.js → chunk-NNHU33JK.js} +7 -7
- package/Build/Workers/{chunk-CQCEPC6N.js → chunk-NQCAZU7S.js} +13 -13
- package/Build/Workers/{chunk-35J4D6PX.js → chunk-NUYLNQKV.js} +2 -2
- package/Build/Workers/{chunk-I45CATZK.js → chunk-OC6X22PG.js} +9 -9
- package/Build/Workers/{chunk-7MGTX4WP.js → chunk-OHBM4YG4.js} +12 -12
- package/Build/Workers/{chunk-DCR62BCO.js → chunk-OMXN7YF4.js} +12 -12
- package/Build/Workers/{chunk-XPNY2VY3.js → chunk-OQ3EAJNW.js} +2 -2
- package/Build/Workers/{chunk-4I7BCCNU.js → chunk-OQBPOKPZ.js} +6 -6
- package/Build/Workers/{chunk-2JNPWPLE.js → chunk-PQVNT5CJ.js} +6 -6
- package/Build/Workers/{chunk-K64RQCRK.js → chunk-QA24Q62E.js} +17 -17
- package/Build/Workers/{chunk-K6BXEBAF.js → chunk-QQX7S5QT.js} +17 -17
- package/Build/Workers/{chunk-2YVTOY5Z.js → chunk-QTOHIXGF.js} +10 -10
- package/Build/Workers/{chunk-4MCPC4TE.js → chunk-R7M4XNPP.js} +8 -8
- package/Build/Workers/{chunk-C35SJ4QP.js → chunk-SGKTBHFQ.js} +13 -13
- package/Build/Workers/{chunk-BKYJBTHW.js → chunk-SQTRWKO2.js} +5 -5
- package/Build/Workers/{chunk-I4D5IP46.js → chunk-T43FXHNC.js} +7 -7
- package/Build/Workers/{chunk-QO6Z5UJE.js → chunk-UEEGWJJP.js} +2 -2
- package/Build/Workers/{chunk-ZUWF63QU.js → chunk-WKXDCVBO.js} +4 -4
- package/Build/Workers/{chunk-N5MNKWED.js → chunk-Y5AJSEEN.js} +2 -2
- package/Build/Workers/{chunk-V26Y7ZQL.js → chunk-ZIW5FCIW.js} +37 -27
- package/Build/Workers/combineGeometry.js +24 -24
- package/Build/Workers/createBoxGeometry.js +18 -18
- package/Build/Workers/createBoxOutlineGeometry.js +16 -16
- package/Build/Workers/createCircleGeometry.js +26 -26
- package/Build/Workers/createCircleOutlineGeometry.js +19 -19
- package/Build/Workers/createCoplanarPolygonGeometry.js +33 -33
- package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +31 -31
- package/Build/Workers/createCorridorGeometry.js +29 -29
- package/Build/Workers/createCorridorOutlineGeometry.js +28 -28
- package/Build/Workers/createCylinderGeometry.js +20 -20
- package/Build/Workers/createCylinderOutlineGeometry.js +18 -18
- package/Build/Workers/createEllipseGeometry.js +26 -26
- package/Build/Workers/createEllipseOutlineGeometry.js +19 -19
- package/Build/Workers/createEllipsoidGeometry.js +19 -19
- package/Build/Workers/createEllipsoidOutlineGeometry.js +18 -18
- package/Build/Workers/createFrustumGeometry.js +18 -18
- package/Build/Workers/createFrustumOutlineGeometry.js +18 -18
- package/Build/Workers/createGeometry.js +24 -24
- package/Build/Workers/createGroundPolylineGeometry.js +22 -22
- package/Build/Workers/createPlaneGeometry.js +16 -16
- package/Build/Workers/createPlaneOutlineGeometry.js +15 -15
- package/Build/Workers/createPolygonGeometry.js +32 -32
- package/Build/Workers/createPolygonOutlineGeometry.js +30 -30
- package/Build/Workers/createPolylineGeometry.js +25 -25
- package/Build/Workers/createPolylineVolumeGeometry.js +31 -31
- package/Build/Workers/createPolylineVolumeOutlineGeometry.js +27 -27
- package/Build/Workers/createRectangleGeometry.js +27 -27
- package/Build/Workers/createRectangleOutlineGeometry.js +20 -20
- package/Build/Workers/createSimplePolylineGeometry.js +23 -23
- package/Build/Workers/createSphereGeometry.js +19 -19
- package/Build/Workers/createSphereOutlineGeometry.js +18 -18
- package/Build/Workers/createTaskProcessorWorker.js +3 -3
- package/Build/Workers/createVectorTileClampedPolylines.js +14 -14
- package/Build/Workers/createVectorTileGeometries.js +24 -24
- package/Build/Workers/createVectorTilePoints.js +13 -13
- package/Build/Workers/createVectorTilePolygons.js +22 -22
- package/Build/Workers/createVectorTilePolylines.js +14 -14
- package/Build/Workers/createVerticesFromCesium3DTilesTerrain.js +25 -25
- package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +22 -22
- package/Build/Workers/createVerticesFromHeightmap.js +22 -22
- package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +20 -20
- package/Build/Workers/createWallGeometry.js +24 -24
- package/Build/Workers/createWallOutlineGeometry.js +23 -23
- package/Build/Workers/decodeDraco.js +10 -10
- package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +5 -5
- package/Build/Workers/decodeI3S.js +10 -10
- 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 +6 -6
- package/Build/Workers/transferTypedArrayTest.js +1 -1
- package/Build/Workers/upsampleQuantizedTerrainMesh.js +22 -22
- package/Build/Workers/upsampleVerticesFromCesium3DTilesTerrain.js +25 -25
- package/Source/Core/AttributeCompression.js +53 -6
- package/Source/Core/BoxGeometry.js +1 -1
- package/Source/Core/Cartesian2.js +689 -684
- package/Source/Core/Cartesian3.js +1044 -1043
- package/Source/Core/Cartesian4.js +816 -813
- package/Source/Core/CornerType.js +1 -1
- package/Source/Core/CorridorGeometry.js +1 -1
- package/Source/Core/FeatureDetection.js +1 -32
- package/Source/Core/Geometry.js +1 -1
- package/Source/Core/GoogleMaps.js +23 -2
- package/Source/Core/IntersectionTests.js +2 -2
- package/Source/Core/Ion.js +1 -1
- package/Source/Core/OpenCageGeocoderService.js +2 -3
- package/Source/Core/PinBuilder.js +1 -1
- package/Source/Core/PolygonGeometry.js +1 -1
- package/Source/Core/PolylineGeometry.js +1 -1
- package/Source/Core/PolylineVolumeGeometry.js +1 -1
- package/Source/Core/RectangleGeometry.js +1 -1
- package/Source/Core/ScreenSpaceEventHandler.js +4 -8
- package/Source/Core/TerrainMesh.js +11 -8
- package/Source/Core/TerrainPicker.js +24 -7
- package/Source/Core/VideoSynchronizer.js +1 -1
- package/Source/Core/WallGeometry.js +1 -1
- package/Source/Core/globalTypes.js +16 -0
- package/Source/Core/writeTextToCanvas.js +40 -86
- package/Source/DataSources/BillboardGraphics.js +1 -1
- package/Source/DataSources/BoxGraphics.js +1 -1
- package/Source/DataSources/CallbackPositionProperty.js +1 -1
- package/Source/DataSources/CorridorGraphics.js +1 -1
- package/Source/DataSources/CzmlDataSource.js +1 -1
- package/Source/DataSources/EllipseGraphics.js +1 -1
- package/Source/DataSources/EllipsoidGraphics.js +1 -1
- package/Source/DataSources/Entity.js +1 -1
- package/Source/DataSources/EntityCluster.js +2 -2
- package/Source/DataSources/GeoJsonDataSource.js +2 -2
- package/Source/DataSources/GpxDataSource.js +1 -1
- package/Source/DataSources/KmlDataSource.js +1 -1
- package/Source/DataSources/KmlTour.js +1 -1
- package/Source/DataSources/LabelGraphics.js +1 -1
- package/Source/DataSources/ModelGraphics.js +1 -1
- package/Source/DataSources/PlaneGraphics.js +1 -1
- package/Source/DataSources/PolygonGraphics.js +1 -1
- package/Source/DataSources/PolylineGraphics.js +1 -1
- package/Source/DataSources/PolylineVolumeGraphics.js +1 -1
- package/Source/DataSources/RectangleGraphics.js +1 -1
- package/Source/DataSources/WallGraphics.js +1 -1
- package/Source/DataSources/exportKml.js +1 -1
- package/Source/Renderer/Context.js +11 -10
- package/Source/Renderer/ContextLimits.js +66 -33
- package/Source/Renderer/ShaderDestination.js +54 -13
- package/Source/Renderer/ShaderSource.js +19 -18
- package/Source/Renderer/Texture.js +1 -1
- package/Source/Renderer/Texture3D.js +166 -7
- package/Source/Renderer/TextureAtlas.js +2 -2
- package/Source/Scene/Appearance.js +1 -1
- package/Source/Scene/ArcGisMapService.js +1 -1
- package/Source/Scene/Billboard.js +8 -5
- package/Source/Scene/BillboardCollection.js +65 -26
- package/Source/Scene/BillboardTexture.js +4 -1
- package/Source/Scene/BufferLoader.js +65 -74
- package/Source/Scene/Camera.js +13 -2
- package/Source/Scene/ClippingPlaneCollection.js +2 -2
- package/Source/Scene/CloudCollection.js +2 -2
- package/Source/Scene/CubeMapPanorama.js +351 -0
- package/Source/Scene/CumulusCloud.js +1 -1
- package/Source/Scene/DerivedCommand.js +8 -31
- package/Source/Scene/DracoLoader.js +79 -78
- package/Source/Scene/DynamicEnvironmentMapManager.js +41 -26
- package/Source/Scene/EquirectangularPanorama.js +264 -0
- package/Source/Scene/Fog.js +1 -1
- package/Source/Scene/FrameState.js +7 -0
- package/Source/Scene/GaussianSplatPrimitive.js +907 -168
- package/Source/Scene/Globe.js +3 -10
- package/Source/Scene/GlobeSurfaceShaderSet.js +36 -32
- package/Source/Scene/GltfBufferViewLoader.js +109 -118
- package/Source/Scene/GltfDracoLoader.js +167 -176
- package/Source/Scene/GltfImageLoader.js +91 -101
- package/Source/Scene/GltfIndexBufferLoader.js +228 -241
- package/Source/Scene/GltfJsonLoader.js +90 -99
- package/Source/Scene/GltfLoader.js +323 -324
- package/Source/Scene/GltfSpzLoader.js +127 -134
- package/Source/Scene/GltfStructuralMetadataLoader.js +181 -186
- package/Source/Scene/GltfTextureLoader.js +217 -231
- package/Source/Scene/GltfVertexBufferLoader.js +267 -276
- package/Source/Scene/GoogleStreetViewCubeMapPanoramaProvider.js +341 -0
- package/Source/Scene/ImageBasedLighting.js +2 -2
- package/Source/Scene/ImageryLayerCollection.js +2 -2
- package/Source/Scene/ImageryProvider.js +2 -2
- package/Source/Scene/Label.js +7 -5
- package/Source/Scene/LabelCollection.js +60 -2
- package/Source/Scene/Material.js +1 -1
- package/Source/Scene/MaterialAppearance.js +1 -1
- package/Source/Scene/Megatexture.js +174 -242
- package/Source/Scene/MetadataClassProperty.js +212 -7
- package/Source/Scene/MetadataComponentType.js +162 -127
- package/Source/Scene/MetadataSchemaLoader.js +60 -67
- package/Source/Scene/MetadataTable.js +14 -0
- package/Source/Scene/MetadataTableProperty.js +14 -0
- package/Source/Scene/Model/B3dmLoader.js +216 -224
- package/Source/Scene/Model/CustomShader.js +6 -1
- package/Source/Scene/Model/CustomShaderPipelineStage.js +122 -7
- package/Source/Scene/Model/GeoJsonLoader.js +53 -61
- package/Source/Scene/Model/GeometryPipelineStage.js +17 -3
- package/Source/Scene/Model/I3dmLoader.js +232 -240
- package/Source/Scene/Model/MaterialPipelineStage.js +17 -0
- package/Source/Scene/Model/MetadataPipelineStage.js +438 -22
- package/Source/Scene/Model/Model.js +1 -1
- package/Source/Scene/Model/PntsLoader.js +78 -89
- package/Source/Scene/ModelComponents.js +10 -0
- package/Source/Scene/Panorama.js +53 -0
- package/Source/Scene/PanoramaProvider.js +43 -0
- package/Source/Scene/ParticleSystem.js +2 -2
- package/Source/Scene/PointPrimitive.js +1 -1
- package/Source/Scene/PointPrimitiveCollection.js +14 -22
- package/Source/Scene/Polyline.js +0 -1
- package/Source/Scene/PolylineCollection.js +1 -4
- package/Source/Scene/PolylineColorAppearance.js +1 -6
- package/Source/Scene/PolylineMaterialAppearance.js +1 -6
- package/Source/Scene/PostProcessStageCollection.js +1 -1
- package/Source/Scene/PropertyTable.js +43 -0
- package/Source/Scene/PropertyTexture.js +1 -1
- package/Source/Scene/PropertyTextureProperty.js +0 -97
- package/Source/Scene/QuadtreePrimitive.js +6 -3
- package/Source/Scene/ResourceLoader.js +84 -92
- package/Source/Scene/Scene.js +12 -0
- package/Source/Scene/ShadowMap.js +1 -2
- package/Source/Scene/SkyBox.js +29 -164
- package/Source/Scene/StructuralMetadata.js +18 -3
- package/Source/Scene/Vector3DTileClampedPolylines.js +1 -5
- package/Source/Scene/Vector3DTilePolylines.js +1 -5
- package/Source/Scene/VoxelPrimitive.js +16 -33
- package/Source/Scene/VoxelRenderResources.js +1 -8
- package/Source/Scene/VoxelTraversal.js +16 -61
- package/Source/Scene/WebMapTileServiceImageryProvider.js +1 -1
- package/Source/Scene/createElevationBandMaterial.js +1 -1
- package/Source/Scene/parseStructuralMetadata.js +244 -0
- package/Source/Scene/processVoxelProperties.js +1 -1
- package/Source/Shaders/BillboardCollectionFS.glsl +66 -40
- package/Source/Shaders/BillboardCollectionFS.js +67 -40
- package/Source/Shaders/BillboardCollectionVS.glsl +22 -31
- package/Source/Shaders/BillboardCollectionVS.js +22 -31
- package/Source/Shaders/Builtin/CzmBuiltins.js +4 -0
- package/Source/Shaders/Builtin/Functions/columbusViewMorph.glsl +8 -1
- package/Source/Shaders/Builtin/Functions/columbusViewMorph.js +8 -1
- package/Source/Shaders/Builtin/Functions/decodeRGB8.glsl +22 -0
- package/Source/Shaders/Builtin/Functions/decodeRGB8.js +24 -0
- package/Source/Shaders/Builtin/Functions/unpackTexture.glsl +35 -0
- package/Source/Shaders/Builtin/Functions/unpackTexture.js +37 -0
- package/Source/Shaders/CubeMapPanoramaVS.glsl +11 -0
- package/Source/Shaders/CubeMapPanoramaVS.js +13 -0
- package/Source/Shaders/Model/MetadataStageFS.glsl +2 -1
- package/Source/Shaders/Model/MetadataStageFS.js +2 -1
- package/Source/Shaders/Model/MetadataStageVS.glsl +2 -1
- package/Source/Shaders/Model/MetadataStageVS.js +2 -1
- package/Source/Shaders/Model/ModelFS.glsl +9 -1
- package/Source/Shaders/Model/ModelFS.js +9 -1
- package/Source/Shaders/Model/ModelVS.glsl +4 -2
- package/Source/Shaders/Model/ModelVS.js +4 -2
- package/Source/Shaders/PointPrimitiveCollectionVS.glsl +8 -39
- package/Source/Shaders/PointPrimitiveCollectionVS.js +8 -39
- package/Source/Shaders/Voxels/IntersectionUtils.glsl +1 -1
- package/Source/Shaders/Voxels/IntersectionUtils.js +1 -1
- package/Source/Shaders/Voxels/Megatexture.glsl +15 -83
- package/Source/Shaders/Voxels/Megatexture.js +15 -83
- package/Source/Shaders/Voxels/Octree.glsl +6 -9
- package/Source/Shaders/Voxels/Octree.js +6 -9
- package/Source/Widget/CesiumWidget.js +1 -1
- package/Source/Workers/incrementallyBuildTerrainPicker.js +16 -2
- package/index.d.ts +582 -193
- package/index.js +91 -83
- package/package.json +2 -1
- package/Build/Workers/chunk-ZGWX2R5I.js +0 -1443
|
@@ -1,1129 +1,1182 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
1
3
|
import Check from "./Check.js";
|
|
2
4
|
import defined from "./defined.js";
|
|
3
5
|
import DeveloperError from "./DeveloperError.js";
|
|
4
6
|
import CesiumMath from "./Math.js";
|
|
5
7
|
|
|
8
|
+
/** @import {TypedArray} from "./globalTypes.js"; */
|
|
9
|
+
/** @import Cartesian4 from "./Cartesian4.js"; */
|
|
10
|
+
/** @import Ellipsoid from "./Ellipsoid.js"; */
|
|
11
|
+
/** @import Spherical from "./Spherical.js"; */
|
|
12
|
+
|
|
6
13
|
/**
|
|
7
14
|
* A 3D Cartesian point.
|
|
8
|
-
* @alias Cartesian3
|
|
9
|
-
* @constructor
|
|
10
|
-
*
|
|
11
|
-
* @param {number} [x=0.0] The X component.
|
|
12
|
-
* @param {number} [y=0.0] The Y component.
|
|
13
|
-
* @param {number} [z=0.0] The Z component.
|
|
14
15
|
*
|
|
15
16
|
* @see Cartesian2
|
|
16
17
|
* @see Cartesian4
|
|
17
18
|
* @see Packable
|
|
18
19
|
*/
|
|
19
|
-
|
|
20
|
+
class Cartesian3 {
|
|
20
21
|
/**
|
|
21
|
-
* The X component.
|
|
22
|
-
* @
|
|
23
|
-
* @
|
|
22
|
+
* @param {number} [x=0.0] The X component.
|
|
23
|
+
* @param {number} [y=0.0] The Y component.
|
|
24
|
+
* @param {number} [z=0.0] The Z component.
|
|
24
25
|
*/
|
|
25
|
-
|
|
26
|
+
constructor(x, y, z) {
|
|
27
|
+
/**
|
|
28
|
+
* The X component.
|
|
29
|
+
* @type {number}
|
|
30
|
+
* @default 0.0
|
|
31
|
+
*/
|
|
32
|
+
this.x = x ?? 0.0;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* The Y component.
|
|
36
|
+
* @type {number}
|
|
37
|
+
* @default 0.0
|
|
38
|
+
*/
|
|
39
|
+
this.y = y ?? 0.0;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* The Z component.
|
|
43
|
+
* @type {number}
|
|
44
|
+
* @default 0.0
|
|
45
|
+
*/
|
|
46
|
+
this.z = z ?? 0.0;
|
|
47
|
+
}
|
|
26
48
|
|
|
27
49
|
/**
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
* @
|
|
50
|
+
* Converts the provided Spherical into Cartesian3 coordinates.
|
|
51
|
+
*
|
|
52
|
+
* @param {Spherical} spherical The Spherical to be converted to Cartesian3.
|
|
53
|
+
* @param {Cartesian3} [result] The object onto which to store the result.
|
|
54
|
+
* @returns {Cartesian3} The modified result parameter or a new Cartesian3 instance if one was not provided.
|
|
31
55
|
*/
|
|
32
|
-
|
|
56
|
+
static fromSpherical(spherical, result) {
|
|
57
|
+
//>>includeStart('debug', pragmas.debug);
|
|
58
|
+
Check.typeOf.object("spherical", spherical);
|
|
59
|
+
//>>includeEnd('debug');
|
|
60
|
+
|
|
61
|
+
if (!defined(result)) {
|
|
62
|
+
result = new Cartesian3();
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const clock = spherical.clock;
|
|
66
|
+
const cone = spherical.cone;
|
|
67
|
+
const magnitude = spherical.magnitude ?? 1.0;
|
|
68
|
+
const radial = magnitude * Math.sin(cone);
|
|
69
|
+
result.x = radial * Math.cos(clock);
|
|
70
|
+
result.y = radial * Math.sin(clock);
|
|
71
|
+
result.z = magnitude * Math.cos(cone);
|
|
72
|
+
return result;
|
|
73
|
+
}
|
|
33
74
|
|
|
34
75
|
/**
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
* @
|
|
76
|
+
* Creates a Cartesian3 instance from x, y and z coordinates.
|
|
77
|
+
*
|
|
78
|
+
* @param {number} x The x coordinate.
|
|
79
|
+
* @param {number} y The y coordinate.
|
|
80
|
+
* @param {number} z The z coordinate.
|
|
81
|
+
* @param {Cartesian3} [result] The object onto which to store the result.
|
|
82
|
+
* @returns {Cartesian3} The modified result parameter or a new Cartesian3 instance if one was not provided.
|
|
38
83
|
*/
|
|
39
|
-
|
|
40
|
-
|
|
84
|
+
static fromElements(x, y, z, result) {
|
|
85
|
+
if (!defined(result)) {
|
|
86
|
+
return new Cartesian3(x, y, z);
|
|
87
|
+
}
|
|
41
88
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
* @returns {Cartesian3} The modified result parameter or a new Cartesian3 instance if one was not provided.
|
|
48
|
-
*/
|
|
49
|
-
Cartesian3.fromSpherical = function (spherical, result) {
|
|
50
|
-
//>>includeStart('debug', pragmas.debug);
|
|
51
|
-
Check.typeOf.object("spherical", spherical);
|
|
52
|
-
//>>includeEnd('debug');
|
|
89
|
+
result.x = x;
|
|
90
|
+
result.y = y;
|
|
91
|
+
result.z = z;
|
|
92
|
+
return result;
|
|
93
|
+
}
|
|
53
94
|
|
|
54
|
-
|
|
55
|
-
|
|
95
|
+
/**
|
|
96
|
+
* Duplicates a Cartesian3 instance.
|
|
97
|
+
*
|
|
98
|
+
* @param {Cartesian3} cartesian The Cartesian to duplicate.
|
|
99
|
+
* @param {Cartesian3} [result] The object onto which to store the result.
|
|
100
|
+
* @returns {Cartesian3} The modified result parameter or a new Cartesian3 instance if one was not provided. (Returns undefined if cartesian is undefined)
|
|
101
|
+
*/
|
|
102
|
+
static clone(cartesian, result) {
|
|
103
|
+
if (!defined(cartesian)) {
|
|
104
|
+
return undefined;
|
|
105
|
+
}
|
|
106
|
+
if (!defined(result)) {
|
|
107
|
+
return new Cartesian3(cartesian.x, cartesian.y, cartesian.z);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
result.x = cartesian.x;
|
|
111
|
+
result.y = cartesian.y;
|
|
112
|
+
result.z = cartesian.z;
|
|
113
|
+
return result;
|
|
56
114
|
}
|
|
57
115
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
116
|
+
/**
|
|
117
|
+
* Stores the provided instance into the provided array.
|
|
118
|
+
*
|
|
119
|
+
* @param {Cartesian3} value The value to pack.
|
|
120
|
+
* @param {number[]|TypedArray} array The array to pack into.
|
|
121
|
+
* @param {number} [startingIndex=0] The index into the array at which to start packing the elements.
|
|
122
|
+
*
|
|
123
|
+
* @returns {number[]|TypedArray} The array that was packed into
|
|
124
|
+
*/
|
|
125
|
+
static pack(value, array, startingIndex) {
|
|
126
|
+
//>>includeStart('debug', pragmas.debug);
|
|
127
|
+
Check.typeOf.object("value", value);
|
|
128
|
+
Check.defined("array", array);
|
|
129
|
+
//>>includeEnd('debug');
|
|
67
130
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
* @returns {Cartesian3} The modified result parameter or a new Cartesian3 instance if one was not provided.
|
|
76
|
-
*/
|
|
77
|
-
Cartesian3.fromElements = function (x, y, z, result) {
|
|
78
|
-
if (!defined(result)) {
|
|
79
|
-
return new Cartesian3(x, y, z);
|
|
131
|
+
startingIndex = startingIndex ?? 0;
|
|
132
|
+
|
|
133
|
+
array[startingIndex++] = value.x;
|
|
134
|
+
array[startingIndex++] = value.y;
|
|
135
|
+
array[startingIndex] = value.z;
|
|
136
|
+
|
|
137
|
+
return array;
|
|
80
138
|
}
|
|
81
139
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
140
|
+
/**
|
|
141
|
+
* Retrieves an instance from a packed array.
|
|
142
|
+
*
|
|
143
|
+
* @param {number[]|TypedArray} array The packed array.
|
|
144
|
+
* @param {number} [startingIndex=0] The starting index of the element to be unpacked.
|
|
145
|
+
* @param {Cartesian3} [result] The object into which to store the result.
|
|
146
|
+
* @returns {Cartesian3} The modified result parameter or a new Cartesian3 instance if one was not provided.
|
|
147
|
+
*/
|
|
148
|
+
static unpack(array, startingIndex, result) {
|
|
149
|
+
//>>includeStart('debug', pragmas.debug);
|
|
150
|
+
Check.defined("array", array);
|
|
151
|
+
//>>includeEnd('debug');
|
|
152
|
+
|
|
153
|
+
startingIndex = startingIndex ?? 0;
|
|
87
154
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
Cartesian3.clone = function (cartesian, result) {
|
|
96
|
-
if (!defined(cartesian)) {
|
|
97
|
-
return undefined;
|
|
155
|
+
if (!defined(result)) {
|
|
156
|
+
result = new Cartesian3();
|
|
157
|
+
}
|
|
158
|
+
result.x = array[startingIndex++];
|
|
159
|
+
result.y = array[startingIndex++];
|
|
160
|
+
result.z = array[startingIndex];
|
|
161
|
+
return result;
|
|
98
162
|
}
|
|
99
|
-
|
|
100
|
-
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Flattens an array of Cartesian3s into an array of components.
|
|
166
|
+
*
|
|
167
|
+
* @param {Cartesian3[]} array The array of cartesians to pack.
|
|
168
|
+
* @param {number[]|TypedArray} [result] The array onto which to store the result. If this is a typed array, it must have array.length * 3 components, else a {@link DeveloperError} will be thrown. If it is a regular array, it will be resized to have (array.length * 3) elements.
|
|
169
|
+
* @returns {number[]|TypedArray} The packed array.
|
|
170
|
+
*/
|
|
171
|
+
static packArray(array, result) {
|
|
172
|
+
//>>includeStart('debug', pragmas.debug);
|
|
173
|
+
Check.defined("array", array);
|
|
174
|
+
//>>includeEnd('debug');
|
|
175
|
+
|
|
176
|
+
const length = array.length;
|
|
177
|
+
const resultLength = length * 3;
|
|
178
|
+
if (!defined(result)) {
|
|
179
|
+
result = new Array(resultLength);
|
|
180
|
+
} else if (!Array.isArray(result) && result.length !== resultLength) {
|
|
181
|
+
//>>includeStart('debug', pragmas.debug);
|
|
182
|
+
throw new DeveloperError(
|
|
183
|
+
"If result is a typed array, it must have exactly array.length * 3 elements",
|
|
184
|
+
);
|
|
185
|
+
//>>includeEnd('debug');
|
|
186
|
+
} else if (result.length !== resultLength) {
|
|
187
|
+
/** @type {number[]} */ (result).length = resultLength;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
for (let i = 0; i < length; ++i) {
|
|
191
|
+
Cartesian3.pack(array[i], result, i * 3);
|
|
192
|
+
}
|
|
193
|
+
return result;
|
|
101
194
|
}
|
|
102
195
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
}
|
|
196
|
+
/**
|
|
197
|
+
* Unpacks an array of cartesian components into an array of Cartesian3s.
|
|
198
|
+
*
|
|
199
|
+
* @param {number[]|TypedArray} array The array of components to unpack.
|
|
200
|
+
* @param {Cartesian3[]} [result] The array onto which to store the result.
|
|
201
|
+
* @returns {Cartesian3[]} The unpacked array.
|
|
202
|
+
*/
|
|
203
|
+
static unpackArray(array, result) {
|
|
204
|
+
//>>includeStart('debug', pragmas.debug);
|
|
205
|
+
Check.defined("array", array);
|
|
206
|
+
Check.typeOf.number.greaterThanOrEquals("array.length", array.length, 3);
|
|
207
|
+
if (array.length % 3 !== 0) {
|
|
208
|
+
throw new DeveloperError("array length must be a multiple of 3.");
|
|
209
|
+
}
|
|
210
|
+
//>>includeEnd('debug');
|
|
108
211
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
* @param {Cartesian3} [result] The object onto which to store the result.
|
|
116
|
-
* @returns {Cartesian3} The modified result parameter or a new Cartesian3 instance if one was not provided.
|
|
117
|
-
*/
|
|
118
|
-
Cartesian3.fromCartesian4 = Cartesian3.clone;
|
|
212
|
+
const length = array.length;
|
|
213
|
+
if (!defined(result)) {
|
|
214
|
+
result = new Array(length / 3);
|
|
215
|
+
} else {
|
|
216
|
+
result.length = length / 3;
|
|
217
|
+
}
|
|
119
218
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
219
|
+
for (let i = 0; i < length; i += 3) {
|
|
220
|
+
const index = i / 3;
|
|
221
|
+
result[index] = Cartesian3.unpack(array, i, result[index]);
|
|
222
|
+
}
|
|
223
|
+
return result;
|
|
224
|
+
}
|
|
125
225
|
|
|
126
|
-
/**
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
//>>includeStart('debug', pragmas.debug);
|
|
137
|
-
Check.typeOf.object("value", value);
|
|
138
|
-
Check.defined("array", array);
|
|
139
|
-
//>>includeEnd('debug');
|
|
226
|
+
/**
|
|
227
|
+
* Computes the value of the maximum component for the supplied Cartesian.
|
|
228
|
+
*
|
|
229
|
+
* @param {Cartesian3} cartesian The cartesian to use.
|
|
230
|
+
* @returns {number} The value of the maximum component.
|
|
231
|
+
*/
|
|
232
|
+
static maximumComponent(cartesian) {
|
|
233
|
+
//>>includeStart('debug', pragmas.debug);
|
|
234
|
+
Check.typeOf.object("cartesian", cartesian);
|
|
235
|
+
//>>includeEnd('debug');
|
|
140
236
|
|
|
141
|
-
|
|
237
|
+
return Math.max(cartesian.x, cartesian.y, cartesian.z);
|
|
238
|
+
}
|
|
142
239
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
240
|
+
/**
|
|
241
|
+
* Computes the value of the minimum component for the supplied Cartesian.
|
|
242
|
+
*
|
|
243
|
+
* @param {Cartesian3} cartesian The cartesian to use.
|
|
244
|
+
* @returns {number} The value of the minimum component.
|
|
245
|
+
*/
|
|
246
|
+
static minimumComponent(cartesian) {
|
|
247
|
+
//>>includeStart('debug', pragmas.debug);
|
|
248
|
+
Check.typeOf.object("cartesian", cartesian);
|
|
249
|
+
//>>includeEnd('debug');
|
|
146
250
|
|
|
147
|
-
|
|
148
|
-
}
|
|
251
|
+
return Math.min(cartesian.x, cartesian.y, cartesian.z);
|
|
252
|
+
}
|
|
149
253
|
|
|
150
|
-
/**
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
254
|
+
/**
|
|
255
|
+
* Compares two Cartesians and computes a Cartesian which contains the minimum components of the supplied Cartesians.
|
|
256
|
+
*
|
|
257
|
+
* @param {Cartesian3} first A cartesian to compare.
|
|
258
|
+
* @param {Cartesian3} second A cartesian to compare.
|
|
259
|
+
* @param {Cartesian3} result The object into which to store the result.
|
|
260
|
+
* @returns {Cartesian3} A cartesian with the minimum components.
|
|
261
|
+
*/
|
|
262
|
+
static minimumByComponent(first, second, result) {
|
|
263
|
+
//>>includeStart('debug', pragmas.debug);
|
|
264
|
+
Check.typeOf.object("first", first);
|
|
265
|
+
Check.typeOf.object("second", second);
|
|
266
|
+
Check.typeOf.object("result", result);
|
|
267
|
+
//>>includeEnd('debug');
|
|
162
268
|
|
|
163
|
-
|
|
269
|
+
result.x = Math.min(first.x, second.x);
|
|
270
|
+
result.y = Math.min(first.y, second.y);
|
|
271
|
+
result.z = Math.min(first.z, second.z);
|
|
164
272
|
|
|
165
|
-
|
|
166
|
-
result = new Cartesian3();
|
|
273
|
+
return result;
|
|
167
274
|
}
|
|
168
|
-
result.x = array[startingIndex++];
|
|
169
|
-
result.y = array[startingIndex++];
|
|
170
|
-
result.z = array[startingIndex];
|
|
171
|
-
return result;
|
|
172
|
-
};
|
|
173
275
|
|
|
174
|
-
/**
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
result =
|
|
190
|
-
|
|
276
|
+
/**
|
|
277
|
+
* Compares two Cartesians and computes a Cartesian which contains the maximum components of the supplied Cartesians.
|
|
278
|
+
*
|
|
279
|
+
* @param {Cartesian3} first A cartesian to compare.
|
|
280
|
+
* @param {Cartesian3} second A cartesian to compare.
|
|
281
|
+
* @param {Cartesian3} result The object into which to store the result.
|
|
282
|
+
* @returns {Cartesian3} A cartesian with the maximum components.
|
|
283
|
+
*/
|
|
284
|
+
static maximumByComponent(first, second, result) {
|
|
285
|
+
//>>includeStart('debug', pragmas.debug);
|
|
286
|
+
Check.typeOf.object("first", first);
|
|
287
|
+
Check.typeOf.object("second", second);
|
|
288
|
+
Check.typeOf.object("result", result);
|
|
289
|
+
//>>includeEnd('debug');
|
|
290
|
+
|
|
291
|
+
result.x = Math.max(first.x, second.x);
|
|
292
|
+
result.y = Math.max(first.y, second.y);
|
|
293
|
+
result.z = Math.max(first.z, second.z);
|
|
294
|
+
return result;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* Constrain a value to lie between two values.
|
|
299
|
+
*
|
|
300
|
+
* @param {Cartesian3} value The value to clamp.
|
|
301
|
+
* @param {Cartesian3} min The minimum bound.
|
|
302
|
+
* @param {Cartesian3} max The maximum bound.
|
|
303
|
+
* @param {Cartesian3} result The object into which to store the result.
|
|
304
|
+
* @returns {Cartesian3} The clamped value such that min <= value <= max.
|
|
305
|
+
*/
|
|
306
|
+
static clamp(value, min, max, result) {
|
|
307
|
+
//>>includeStart('debug', pragmas.debug);
|
|
308
|
+
Check.typeOf.object("value", value);
|
|
309
|
+
Check.typeOf.object("min", min);
|
|
310
|
+
Check.typeOf.object("max", max);
|
|
311
|
+
Check.typeOf.object("result", result);
|
|
312
|
+
//>>includeEnd('debug');
|
|
313
|
+
|
|
314
|
+
const x = CesiumMath.clamp(value.x, min.x, max.x);
|
|
315
|
+
const y = CesiumMath.clamp(value.y, min.y, max.y);
|
|
316
|
+
const z = CesiumMath.clamp(value.z, min.z, max.z);
|
|
317
|
+
|
|
318
|
+
result.x = x;
|
|
319
|
+
result.y = y;
|
|
320
|
+
result.z = z;
|
|
321
|
+
|
|
322
|
+
return result;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* Computes the provided Cartesian's squared magnitude.
|
|
327
|
+
*
|
|
328
|
+
* @param {Cartesian3} cartesian The Cartesian instance whose squared magnitude is to be computed.
|
|
329
|
+
* @returns {number} The squared magnitude.
|
|
330
|
+
*/
|
|
331
|
+
static magnitudeSquared(cartesian) {
|
|
191
332
|
//>>includeStart('debug', pragmas.debug);
|
|
192
|
-
|
|
193
|
-
|
|
333
|
+
Check.typeOf.object("cartesian", cartesian);
|
|
334
|
+
//>>includeEnd('debug');
|
|
335
|
+
|
|
336
|
+
return (
|
|
337
|
+
cartesian.x * cartesian.x +
|
|
338
|
+
cartesian.y * cartesian.y +
|
|
339
|
+
cartesian.z * cartesian.z
|
|
194
340
|
);
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* Computes the Cartesian's magnitude (length).
|
|
345
|
+
*
|
|
346
|
+
* @param {Cartesian3} cartesian The Cartesian instance whose magnitude is to be computed.
|
|
347
|
+
* @returns {number} The magnitude.
|
|
348
|
+
*/
|
|
349
|
+
static magnitude(cartesian) {
|
|
350
|
+
return Math.sqrt(Cartesian3.magnitudeSquared(cartesian));
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
/**
|
|
354
|
+
* Computes the distance between two points.
|
|
355
|
+
*
|
|
356
|
+
* @param {Cartesian3} left The first point to compute the distance from.
|
|
357
|
+
* @param {Cartesian3} right The second point to compute the distance to.
|
|
358
|
+
* @returns {number} The distance between two points.
|
|
359
|
+
*
|
|
360
|
+
* @example
|
|
361
|
+
* // Returns 1.0
|
|
362
|
+
* const d = Cesium.Cartesian3.distance(new Cesium.Cartesian3(1.0, 0.0, 0.0), new Cesium.Cartesian3(2.0, 0.0, 0.0));
|
|
363
|
+
*/
|
|
364
|
+
static distance(left, right) {
|
|
365
|
+
//>>includeStart('debug', pragmas.debug);
|
|
366
|
+
Check.typeOf.object("left", left);
|
|
367
|
+
Check.typeOf.object("right", right);
|
|
195
368
|
//>>includeEnd('debug');
|
|
196
|
-
|
|
197
|
-
|
|
369
|
+
|
|
370
|
+
Cartesian3.subtract(left, right, distanceScratch);
|
|
371
|
+
return Cartesian3.magnitude(distanceScratch);
|
|
198
372
|
}
|
|
199
373
|
|
|
200
|
-
|
|
201
|
-
|
|
374
|
+
/**
|
|
375
|
+
* Computes the squared distance between two points. Comparing squared distances
|
|
376
|
+
* using this function is more efficient than comparing distances using {@link Cartesian3#distance}.
|
|
377
|
+
*
|
|
378
|
+
* @param {Cartesian3} left The first point to compute the distance from.
|
|
379
|
+
* @param {Cartesian3} right The second point to compute the distance to.
|
|
380
|
+
* @returns {number} The distance between two points.
|
|
381
|
+
*
|
|
382
|
+
* @example
|
|
383
|
+
* // Returns 4.0, not 2.0
|
|
384
|
+
* const d = Cesium.Cartesian3.distanceSquared(new Cesium.Cartesian3(1.0, 0.0, 0.0), new Cesium.Cartesian3(3.0, 0.0, 0.0));
|
|
385
|
+
*/
|
|
386
|
+
static distanceSquared(left, right) {
|
|
387
|
+
//>>includeStart('debug', pragmas.debug);
|
|
388
|
+
Check.typeOf.object("left", left);
|
|
389
|
+
Check.typeOf.object("right", right);
|
|
390
|
+
//>>includeEnd('debug');
|
|
391
|
+
|
|
392
|
+
Cartesian3.subtract(left, right, distanceScratch);
|
|
393
|
+
return Cartesian3.magnitudeSquared(distanceScratch);
|
|
202
394
|
}
|
|
203
|
-
return result;
|
|
204
|
-
};
|
|
205
395
|
|
|
206
|
-
/**
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
396
|
+
/**
|
|
397
|
+
* Computes the normalized form of the supplied Cartesian.
|
|
398
|
+
*
|
|
399
|
+
* @param {Cartesian3} cartesian The Cartesian to be normalized.
|
|
400
|
+
* @param {Cartesian3} result The object onto which to store the result.
|
|
401
|
+
* @returns {Cartesian3} The modified result parameter.
|
|
402
|
+
*/
|
|
403
|
+
static normalize(cartesian, result) {
|
|
404
|
+
//>>includeStart('debug', pragmas.debug);
|
|
405
|
+
Check.typeOf.object("cartesian", cartesian);
|
|
406
|
+
Check.typeOf.object("result", result);
|
|
407
|
+
//>>includeEnd('debug');
|
|
408
|
+
|
|
409
|
+
const magnitude = Cartesian3.magnitude(cartesian);
|
|
410
|
+
|
|
411
|
+
result.x = cartesian.x / magnitude;
|
|
412
|
+
result.y = cartesian.y / magnitude;
|
|
413
|
+
result.z = cartesian.z / magnitude;
|
|
414
|
+
|
|
415
|
+
//>>includeStart('debug', pragmas.debug);
|
|
416
|
+
if (isNaN(result.x) || isNaN(result.y) || isNaN(result.z)) {
|
|
417
|
+
throw new DeveloperError("normalized result is not a number");
|
|
418
|
+
}
|
|
419
|
+
//>>includeEnd('debug');
|
|
420
|
+
|
|
421
|
+
return result;
|
|
219
422
|
}
|
|
220
|
-
//>>includeEnd('debug');
|
|
221
423
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
424
|
+
/**
|
|
425
|
+
* Computes the dot (scalar) product of two Cartesians.
|
|
426
|
+
*
|
|
427
|
+
* @param {Cartesian3} left The first Cartesian.
|
|
428
|
+
* @param {Cartesian3} right The second Cartesian.
|
|
429
|
+
* @returns {number} The dot product.
|
|
430
|
+
*/
|
|
431
|
+
static dot(left, right) {
|
|
432
|
+
//>>includeStart('debug', pragmas.debug);
|
|
433
|
+
Check.typeOf.object("left", left);
|
|
434
|
+
Check.typeOf.object("right", right);
|
|
435
|
+
//>>includeEnd('debug');
|
|
436
|
+
|
|
437
|
+
return left.x * right.x + left.y * right.y + left.z * right.z;
|
|
227
438
|
}
|
|
228
439
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
440
|
+
/**
|
|
441
|
+
* Computes the componentwise product of two Cartesians.
|
|
442
|
+
*
|
|
443
|
+
* @param {Cartesian3} left The first Cartesian.
|
|
444
|
+
* @param {Cartesian3} right The second Cartesian.
|
|
445
|
+
* @param {Cartesian3} result The object onto which to store the result.
|
|
446
|
+
* @returns {Cartesian3} The modified result parameter.
|
|
447
|
+
*/
|
|
448
|
+
static multiplyComponents(left, right, result) {
|
|
449
|
+
//>>includeStart('debug', pragmas.debug);
|
|
450
|
+
Check.typeOf.object("left", left);
|
|
451
|
+
Check.typeOf.object("right", right);
|
|
452
|
+
Check.typeOf.object("result", result);
|
|
453
|
+
//>>includeEnd('debug');
|
|
454
|
+
|
|
455
|
+
result.x = left.x * right.x;
|
|
456
|
+
result.y = left.y * right.y;
|
|
457
|
+
result.z = left.z * right.z;
|
|
458
|
+
return result;
|
|
232
459
|
}
|
|
233
|
-
return result;
|
|
234
|
-
};
|
|
235
460
|
|
|
236
|
-
/**
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
* // Create a Cartesian3 with (1.0, 2.0, 3.0) using an offset into an array
|
|
251
|
-
* const v2 = [0.0, 0.0, 1.0, 2.0, 3.0];
|
|
252
|
-
* const p2 = Cesium.Cartesian3.fromArray(v2, 2);
|
|
253
|
-
*/
|
|
254
|
-
Cartesian3.fromArray = Cartesian3.unpack;
|
|
461
|
+
/**
|
|
462
|
+
* Computes the componentwise quotient of two Cartesians.
|
|
463
|
+
*
|
|
464
|
+
* @param {Cartesian3} left The first Cartesian.
|
|
465
|
+
* @param {Cartesian3} right The second Cartesian.
|
|
466
|
+
* @param {Cartesian3} result The object onto which to store the result.
|
|
467
|
+
* @returns {Cartesian3} The modified result parameter.
|
|
468
|
+
*/
|
|
469
|
+
static divideComponents(left, right, result) {
|
|
470
|
+
//>>includeStart('debug', pragmas.debug);
|
|
471
|
+
Check.typeOf.object("left", left);
|
|
472
|
+
Check.typeOf.object("right", right);
|
|
473
|
+
Check.typeOf.object("result", result);
|
|
474
|
+
//>>includeEnd('debug');
|
|
255
475
|
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
*/
|
|
262
|
-
Cartesian3.maximumComponent = function (cartesian) {
|
|
263
|
-
//>>includeStart('debug', pragmas.debug);
|
|
264
|
-
Check.typeOf.object("cartesian", cartesian);
|
|
265
|
-
//>>includeEnd('debug');
|
|
476
|
+
result.x = left.x / right.x;
|
|
477
|
+
result.y = left.y / right.y;
|
|
478
|
+
result.z = left.z / right.z;
|
|
479
|
+
return result;
|
|
480
|
+
}
|
|
266
481
|
|
|
267
|
-
|
|
268
|
-
|
|
482
|
+
/**
|
|
483
|
+
* Computes the componentwise sum of two Cartesians.
|
|
484
|
+
*
|
|
485
|
+
* @param {Cartesian3} left The first Cartesian.
|
|
486
|
+
* @param {Cartesian3} right The second Cartesian.
|
|
487
|
+
* @param {Cartesian3} result The object onto which to store the result.
|
|
488
|
+
* @returns {Cartesian3} The modified result parameter.
|
|
489
|
+
*/
|
|
490
|
+
static add(left, right, result) {
|
|
491
|
+
//>>includeStart('debug', pragmas.debug);
|
|
492
|
+
Check.typeOf.object("left", left);
|
|
493
|
+
Check.typeOf.object("right", right);
|
|
494
|
+
Check.typeOf.object("result", result);
|
|
495
|
+
//>>includeEnd('debug');
|
|
269
496
|
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
*/
|
|
276
|
-
Cartesian3.minimumComponent = function (cartesian) {
|
|
277
|
-
//>>includeStart('debug', pragmas.debug);
|
|
278
|
-
Check.typeOf.object("cartesian", cartesian);
|
|
279
|
-
//>>includeEnd('debug');
|
|
497
|
+
result.x = left.x + right.x;
|
|
498
|
+
result.y = left.y + right.y;
|
|
499
|
+
result.z = left.z + right.z;
|
|
500
|
+
return result;
|
|
501
|
+
}
|
|
280
502
|
|
|
281
|
-
|
|
282
|
-
|
|
503
|
+
/**
|
|
504
|
+
* Computes the componentwise difference of two Cartesians.
|
|
505
|
+
*
|
|
506
|
+
* @param {Cartesian3} left The first Cartesian.
|
|
507
|
+
* @param {Cartesian3} right The second Cartesian.
|
|
508
|
+
* @param {Cartesian3} result The object onto which to store the result.
|
|
509
|
+
* @returns {Cartesian3} The modified result parameter.
|
|
510
|
+
*/
|
|
511
|
+
static subtract(left, right, result) {
|
|
512
|
+
//>>includeStart('debug', pragmas.debug);
|
|
513
|
+
Check.typeOf.object("left", left);
|
|
514
|
+
Check.typeOf.object("right", right);
|
|
515
|
+
Check.typeOf.object("result", result);
|
|
516
|
+
//>>includeEnd('debug');
|
|
283
517
|
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
* @param {Cartesian3} result The object into which to store the result.
|
|
290
|
-
* @returns {Cartesian3} A cartesian with the minimum components.
|
|
291
|
-
*/
|
|
292
|
-
Cartesian3.minimumByComponent = function (first, second, result) {
|
|
293
|
-
//>>includeStart('debug', pragmas.debug);
|
|
294
|
-
Check.typeOf.object("first", first);
|
|
295
|
-
Check.typeOf.object("second", second);
|
|
296
|
-
Check.typeOf.object("result", result);
|
|
297
|
-
//>>includeEnd('debug');
|
|
518
|
+
result.x = left.x - right.x;
|
|
519
|
+
result.y = left.y - right.y;
|
|
520
|
+
result.z = left.z - right.z;
|
|
521
|
+
return result;
|
|
522
|
+
}
|
|
298
523
|
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
524
|
+
/**
|
|
525
|
+
* Multiplies the provided Cartesian componentwise by the provided scalar.
|
|
526
|
+
*
|
|
527
|
+
* @param {Cartesian3} cartesian The Cartesian to be scaled.
|
|
528
|
+
* @param {number} scalar The scalar to multiply with.
|
|
529
|
+
* @param {Cartesian3} result The object onto which to store the result.
|
|
530
|
+
* @returns {Cartesian3} The modified result parameter.
|
|
531
|
+
*/
|
|
532
|
+
static multiplyByScalar(cartesian, scalar, result) {
|
|
533
|
+
//>>includeStart('debug', pragmas.debug);
|
|
534
|
+
Check.typeOf.object("cartesian", cartesian);
|
|
535
|
+
Check.typeOf.number("scalar", scalar);
|
|
536
|
+
Check.typeOf.object("result", result);
|
|
537
|
+
//>>includeEnd('debug');
|
|
302
538
|
|
|
303
|
-
|
|
304
|
-
|
|
539
|
+
result.x = cartesian.x * scalar;
|
|
540
|
+
result.y = cartesian.y * scalar;
|
|
541
|
+
result.z = cartesian.z * scalar;
|
|
542
|
+
return result;
|
|
543
|
+
}
|
|
305
544
|
|
|
306
|
-
/**
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
result.x = Math.max(first.x, second.x);
|
|
322
|
-
result.y = Math.max(first.y, second.y);
|
|
323
|
-
result.z = Math.max(first.z, second.z);
|
|
324
|
-
return result;
|
|
325
|
-
};
|
|
545
|
+
/**
|
|
546
|
+
* Divides the provided Cartesian componentwise by the provided scalar.
|
|
547
|
+
*
|
|
548
|
+
* @param {Cartesian3} cartesian The Cartesian to be divided.
|
|
549
|
+
* @param {number} scalar The scalar to divide by.
|
|
550
|
+
* @param {Cartesian3} result The object onto which to store the result.
|
|
551
|
+
* @returns {Cartesian3} The modified result parameter.
|
|
552
|
+
*/
|
|
553
|
+
static divideByScalar(cartesian, scalar, result) {
|
|
554
|
+
//>>includeStart('debug', pragmas.debug);
|
|
555
|
+
Check.typeOf.object("cartesian", cartesian);
|
|
556
|
+
Check.typeOf.number("scalar", scalar);
|
|
557
|
+
Check.typeOf.object("result", result);
|
|
558
|
+
//>>includeEnd('debug');
|
|
326
559
|
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
* @param {Cartesian3} max The maximum bound.
|
|
333
|
-
* @param {Cartesian3} result The object into which to store the result.
|
|
334
|
-
* @returns {Cartesian3} The clamped value such that min <= value <= max.
|
|
335
|
-
*/
|
|
336
|
-
Cartesian3.clamp = function (value, min, max, result) {
|
|
337
|
-
//>>includeStart('debug', pragmas.debug);
|
|
338
|
-
Check.typeOf.object("value", value);
|
|
339
|
-
Check.typeOf.object("min", min);
|
|
340
|
-
Check.typeOf.object("max", max);
|
|
341
|
-
Check.typeOf.object("result", result);
|
|
342
|
-
//>>includeEnd('debug');
|
|
560
|
+
result.x = cartesian.x / scalar;
|
|
561
|
+
result.y = cartesian.y / scalar;
|
|
562
|
+
result.z = cartesian.z / scalar;
|
|
563
|
+
return result;
|
|
564
|
+
}
|
|
343
565
|
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
566
|
+
/**
|
|
567
|
+
* Negates the provided Cartesian.
|
|
568
|
+
*
|
|
569
|
+
* @param {Cartesian3} cartesian The Cartesian to be negated.
|
|
570
|
+
* @param {Cartesian3} result The object onto which to store the result.
|
|
571
|
+
* @returns {Cartesian3} The modified result parameter.
|
|
572
|
+
*/
|
|
573
|
+
static negate(cartesian, result) {
|
|
574
|
+
//>>includeStart('debug', pragmas.debug);
|
|
575
|
+
Check.typeOf.object("cartesian", cartesian);
|
|
576
|
+
Check.typeOf.object("result", result);
|
|
577
|
+
//>>includeEnd('debug');
|
|
347
578
|
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
579
|
+
result.x = -cartesian.x;
|
|
580
|
+
result.y = -cartesian.y;
|
|
581
|
+
result.z = -cartesian.z;
|
|
582
|
+
return result;
|
|
583
|
+
}
|
|
351
584
|
|
|
352
|
-
|
|
353
|
-
|
|
585
|
+
/**
|
|
586
|
+
* Computes the absolute value of the provided Cartesian.
|
|
587
|
+
*
|
|
588
|
+
* @param {Cartesian3} cartesian The Cartesian whose absolute value is to be computed.
|
|
589
|
+
* @param {Cartesian3} result The object onto which to store the result.
|
|
590
|
+
* @returns {Cartesian3} The modified result parameter.
|
|
591
|
+
*/
|
|
592
|
+
static abs(cartesian, result) {
|
|
593
|
+
//>>includeStart('debug', pragmas.debug);
|
|
594
|
+
Check.typeOf.object("cartesian", cartesian);
|
|
595
|
+
Check.typeOf.object("result", result);
|
|
596
|
+
//>>includeEnd('debug');
|
|
354
597
|
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
*/
|
|
361
|
-
Cartesian3.magnitudeSquared = function (cartesian) {
|
|
362
|
-
//>>includeStart('debug', pragmas.debug);
|
|
363
|
-
Check.typeOf.object("cartesian", cartesian);
|
|
364
|
-
//>>includeEnd('debug');
|
|
365
|
-
|
|
366
|
-
return (
|
|
367
|
-
cartesian.x * cartesian.x +
|
|
368
|
-
cartesian.y * cartesian.y +
|
|
369
|
-
cartesian.z * cartesian.z
|
|
370
|
-
);
|
|
371
|
-
};
|
|
598
|
+
result.x = Math.abs(cartesian.x);
|
|
599
|
+
result.y = Math.abs(cartesian.y);
|
|
600
|
+
result.z = Math.abs(cartesian.z);
|
|
601
|
+
return result;
|
|
602
|
+
}
|
|
372
603
|
|
|
373
|
-
/**
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
Cartesian3
|
|
380
|
-
|
|
381
|
-
|
|
604
|
+
/**
|
|
605
|
+
* Computes the linear interpolation or extrapolation at t using the provided cartesians.
|
|
606
|
+
*
|
|
607
|
+
* @param {Cartesian3} start The value corresponding to t at 0.0.
|
|
608
|
+
* @param {Cartesian3} end The value corresponding to t at 1.0.
|
|
609
|
+
* @param {number} t The point along t at which to interpolate.
|
|
610
|
+
* @param {Cartesian3} result The object onto which to store the result.
|
|
611
|
+
* @returns {Cartesian3} The modified result parameter.
|
|
612
|
+
*/
|
|
613
|
+
static lerp(start, end, t, result) {
|
|
614
|
+
//>>includeStart('debug', pragmas.debug);
|
|
615
|
+
Check.typeOf.object("start", start);
|
|
616
|
+
Check.typeOf.object("end", end);
|
|
617
|
+
Check.typeOf.number("t", t);
|
|
618
|
+
Check.typeOf.object("result", result);
|
|
619
|
+
//>>includeEnd('debug');
|
|
382
620
|
|
|
383
|
-
|
|
621
|
+
Cartesian3.multiplyByScalar(end, t, lerpScratch);
|
|
622
|
+
result = Cartesian3.multiplyByScalar(start, 1.0 - t, result);
|
|
623
|
+
return Cartesian3.add(lerpScratch, result, result);
|
|
624
|
+
}
|
|
384
625
|
|
|
385
|
-
/**
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
//>>includeStart('debug', pragmas.debug);
|
|
398
|
-
Check.typeOf.object("left", left);
|
|
399
|
-
Check.typeOf.object("right", right);
|
|
400
|
-
//>>includeEnd('debug');
|
|
626
|
+
/**
|
|
627
|
+
* Returns the angle, in radians, between the provided Cartesians.
|
|
628
|
+
*
|
|
629
|
+
* @param {Cartesian3} left The first Cartesian.
|
|
630
|
+
* @param {Cartesian3} right The second Cartesian.
|
|
631
|
+
* @returns {number} The angle between the Cartesians.
|
|
632
|
+
*/
|
|
633
|
+
static angleBetween(left, right) {
|
|
634
|
+
//>>includeStart('debug', pragmas.debug);
|
|
635
|
+
Check.typeOf.object("left", left);
|
|
636
|
+
Check.typeOf.object("right", right);
|
|
637
|
+
//>>includeEnd('debug');
|
|
401
638
|
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
639
|
+
Cartesian3.normalize(left, angleBetweenScratch);
|
|
640
|
+
Cartesian3.normalize(right, angleBetweenScratch2);
|
|
641
|
+
const cosine = Cartesian3.dot(angleBetweenScratch, angleBetweenScratch2);
|
|
642
|
+
const sine = Cartesian3.magnitude(
|
|
643
|
+
Cartesian3.cross(
|
|
644
|
+
angleBetweenScratch,
|
|
645
|
+
angleBetweenScratch2,
|
|
646
|
+
angleBetweenScratch,
|
|
647
|
+
),
|
|
648
|
+
);
|
|
649
|
+
return Math.atan2(sine, cosine);
|
|
650
|
+
}
|
|
405
651
|
|
|
406
|
-
/**
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
Cartesian3.distanceSquared = function (left, right) {
|
|
419
|
-
//>>includeStart('debug', pragmas.debug);
|
|
420
|
-
Check.typeOf.object("left", left);
|
|
421
|
-
Check.typeOf.object("right", right);
|
|
422
|
-
//>>includeEnd('debug');
|
|
652
|
+
/**
|
|
653
|
+
* Returns the axis that is most orthogonal to the provided Cartesian.
|
|
654
|
+
*
|
|
655
|
+
* @param {Cartesian3} cartesian The Cartesian on which to find the most orthogonal axis.
|
|
656
|
+
* @param {Cartesian3} result The object onto which to store the result.
|
|
657
|
+
* @returns {Cartesian3} The most orthogonal axis.
|
|
658
|
+
*/
|
|
659
|
+
static mostOrthogonalAxis(cartesian, result) {
|
|
660
|
+
//>>includeStart('debug', pragmas.debug);
|
|
661
|
+
Check.typeOf.object("cartesian", cartesian);
|
|
662
|
+
Check.typeOf.object("result", result);
|
|
663
|
+
//>>includeEnd('debug');
|
|
423
664
|
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
665
|
+
const f = Cartesian3.normalize(cartesian, mostOrthogonalAxisScratch);
|
|
666
|
+
Cartesian3.abs(f, f);
|
|
667
|
+
|
|
668
|
+
if (f.x <= f.y) {
|
|
669
|
+
if (f.x <= f.z) {
|
|
670
|
+
result = Cartesian3.clone(Cartesian3.UNIT_X, result);
|
|
671
|
+
} else {
|
|
672
|
+
result = Cartesian3.clone(Cartesian3.UNIT_Z, result);
|
|
673
|
+
}
|
|
674
|
+
} else if (f.y <= f.z) {
|
|
675
|
+
result = Cartesian3.clone(Cartesian3.UNIT_Y, result);
|
|
676
|
+
} else {
|
|
677
|
+
result = Cartesian3.clone(Cartesian3.UNIT_Z, result);
|
|
678
|
+
}
|
|
427
679
|
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
*
|
|
431
|
-
* @param {Cartesian3} cartesian The Cartesian to be normalized.
|
|
432
|
-
* @param {Cartesian3} result The object onto which to store the result.
|
|
433
|
-
* @returns {Cartesian3} The modified result parameter.
|
|
434
|
-
*/
|
|
435
|
-
Cartesian3.normalize = function (cartesian, result) {
|
|
436
|
-
//>>includeStart('debug', pragmas.debug);
|
|
437
|
-
Check.typeOf.object("cartesian", cartesian);
|
|
438
|
-
Check.typeOf.object("result", result);
|
|
439
|
-
//>>includeEnd('debug');
|
|
680
|
+
return result;
|
|
681
|
+
}
|
|
440
682
|
|
|
441
|
-
|
|
683
|
+
/**
|
|
684
|
+
* Projects vector a onto vector b
|
|
685
|
+
* @param {Cartesian3} a The vector that needs projecting
|
|
686
|
+
* @param {Cartesian3} b The vector to project onto
|
|
687
|
+
* @param {Cartesian3} result The result cartesian
|
|
688
|
+
* @returns {Cartesian3} The modified result parameter
|
|
689
|
+
*/
|
|
690
|
+
static projectVector(a, b, result) {
|
|
691
|
+
//>>includeStart('debug', pragmas.debug);
|
|
692
|
+
Check.defined("a", a);
|
|
693
|
+
Check.defined("b", b);
|
|
694
|
+
Check.defined("result", result);
|
|
695
|
+
//>>includeEnd('debug');
|
|
696
|
+
|
|
697
|
+
const scalar = Cartesian3.dot(a, b) / Cartesian3.dot(b, b);
|
|
698
|
+
return Cartesian3.multiplyByScalar(b, scalar, result);
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
/**
|
|
702
|
+
* Compares the provided Cartesians componentwise and returns
|
|
703
|
+
* <code>true</code> if they are equal, <code>false</code> otherwise.
|
|
704
|
+
*
|
|
705
|
+
* @param {Cartesian3} [left] The first Cartesian.
|
|
706
|
+
* @param {Cartesian3} [right] The second Cartesian.
|
|
707
|
+
* @returns {boolean} <code>true</code> if left and right are equal, <code>false</code> otherwise.
|
|
708
|
+
*/
|
|
709
|
+
static equals(left, right) {
|
|
710
|
+
return (
|
|
711
|
+
left === right ||
|
|
712
|
+
(defined(left) &&
|
|
713
|
+
defined(right) &&
|
|
714
|
+
left.x === right.x &&
|
|
715
|
+
left.y === right.y &&
|
|
716
|
+
left.z === right.z)
|
|
717
|
+
);
|
|
718
|
+
}
|
|
442
719
|
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
720
|
+
/**
|
|
721
|
+
* @param {Cartesian3} cartesian
|
|
722
|
+
* @param {number[]} array
|
|
723
|
+
* @param {number} offset
|
|
724
|
+
* @private
|
|
725
|
+
*/
|
|
726
|
+
static equalsArray(cartesian, array, offset) {
|
|
727
|
+
return (
|
|
728
|
+
cartesian.x === array[offset] &&
|
|
729
|
+
cartesian.y === array[offset + 1] &&
|
|
730
|
+
cartesian.z === array[offset + 2]
|
|
731
|
+
);
|
|
732
|
+
}
|
|
446
733
|
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
734
|
+
/**
|
|
735
|
+
* Compares the provided Cartesians componentwise and returns
|
|
736
|
+
* <code>true</code> if they pass an absolute or relative tolerance test,
|
|
737
|
+
* <code>false</code> otherwise.
|
|
738
|
+
*
|
|
739
|
+
* @param {Cartesian3} [left] The first Cartesian.
|
|
740
|
+
* @param {Cartesian3} [right] The second Cartesian.
|
|
741
|
+
* @param {number} [relativeEpsilon=0] The relative epsilon tolerance to use for equality testing.
|
|
742
|
+
* @param {number} [absoluteEpsilon=relativeEpsilon] The absolute epsilon tolerance to use for equality testing.
|
|
743
|
+
* @returns {boolean} <code>true</code> if left and right are within the provided epsilon, <code>false</code> otherwise.
|
|
744
|
+
*/
|
|
745
|
+
static equalsEpsilon(left, right, relativeEpsilon, absoluteEpsilon) {
|
|
746
|
+
return (
|
|
747
|
+
left === right ||
|
|
748
|
+
(defined(left) &&
|
|
749
|
+
defined(right) &&
|
|
750
|
+
CesiumMath.equalsEpsilon(
|
|
751
|
+
left.x,
|
|
752
|
+
right.x,
|
|
753
|
+
relativeEpsilon,
|
|
754
|
+
absoluteEpsilon,
|
|
755
|
+
) &&
|
|
756
|
+
CesiumMath.equalsEpsilon(
|
|
757
|
+
left.y,
|
|
758
|
+
right.y,
|
|
759
|
+
relativeEpsilon,
|
|
760
|
+
absoluteEpsilon,
|
|
761
|
+
) &&
|
|
762
|
+
CesiumMath.equalsEpsilon(
|
|
763
|
+
left.z,
|
|
764
|
+
right.z,
|
|
765
|
+
relativeEpsilon,
|
|
766
|
+
absoluteEpsilon,
|
|
767
|
+
))
|
|
768
|
+
);
|
|
450
769
|
}
|
|
451
|
-
//>>includeEnd('debug');
|
|
452
770
|
|
|
453
|
-
|
|
454
|
-
|
|
771
|
+
/**
|
|
772
|
+
* Computes the cross (outer) product of two Cartesians.
|
|
773
|
+
*
|
|
774
|
+
* @param {Cartesian3} left The first Cartesian.
|
|
775
|
+
* @param {Cartesian3} right The second Cartesian.
|
|
776
|
+
* @param {Cartesian3} result The object onto which to store the result.
|
|
777
|
+
* @returns {Cartesian3} The cross product.
|
|
778
|
+
*/
|
|
779
|
+
static cross(left, right, result) {
|
|
780
|
+
//>>includeStart('debug', pragmas.debug);
|
|
781
|
+
Check.typeOf.object("left", left);
|
|
782
|
+
Check.typeOf.object("right", right);
|
|
783
|
+
Check.typeOf.object("result", result);
|
|
784
|
+
//>>includeEnd('debug');
|
|
455
785
|
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
786
|
+
const leftX = left.x;
|
|
787
|
+
const leftY = left.y;
|
|
788
|
+
const leftZ = left.z;
|
|
789
|
+
const rightX = right.x;
|
|
790
|
+
const rightY = right.y;
|
|
791
|
+
const rightZ = right.z;
|
|
792
|
+
|
|
793
|
+
const x = leftY * rightZ - leftZ * rightY;
|
|
794
|
+
const y = leftZ * rightX - leftX * rightZ;
|
|
795
|
+
const z = leftX * rightY - leftY * rightX;
|
|
796
|
+
|
|
797
|
+
result.x = x;
|
|
798
|
+
result.y = y;
|
|
799
|
+
result.z = z;
|
|
800
|
+
return result;
|
|
801
|
+
}
|
|
468
802
|
|
|
469
|
-
|
|
470
|
-
|
|
803
|
+
/**
|
|
804
|
+
* Computes the midpoint between the right and left Cartesian.
|
|
805
|
+
* @param {Cartesian3} left The first Cartesian.
|
|
806
|
+
* @param {Cartesian3} right The second Cartesian.
|
|
807
|
+
* @param {Cartesian3} result The object onto which to store the result.
|
|
808
|
+
* @returns {Cartesian3} The midpoint.
|
|
809
|
+
*/
|
|
810
|
+
static midpoint(left, right, result) {
|
|
811
|
+
//>>includeStart('debug', pragmas.debug);
|
|
812
|
+
Check.typeOf.object("left", left);
|
|
813
|
+
Check.typeOf.object("right", right);
|
|
814
|
+
Check.typeOf.object("result", result);
|
|
815
|
+
//>>includeEnd('debug');
|
|
471
816
|
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
*
|
|
475
|
-
* @param {Cartesian3} left The first Cartesian.
|
|
476
|
-
* @param {Cartesian3} right The second Cartesian.
|
|
477
|
-
* @param {Cartesian3} result The object onto which to store the result.
|
|
478
|
-
* @returns {Cartesian3} The modified result parameter.
|
|
479
|
-
*/
|
|
480
|
-
Cartesian3.multiplyComponents = function (left, right, result) {
|
|
481
|
-
//>>includeStart('debug', pragmas.debug);
|
|
482
|
-
Check.typeOf.object("left", left);
|
|
483
|
-
Check.typeOf.object("right", right);
|
|
484
|
-
Check.typeOf.object("result", result);
|
|
485
|
-
//>>includeEnd('debug');
|
|
486
|
-
|
|
487
|
-
result.x = left.x * right.x;
|
|
488
|
-
result.y = left.y * right.y;
|
|
489
|
-
result.z = left.z * right.z;
|
|
490
|
-
return result;
|
|
491
|
-
};
|
|
817
|
+
result.x = (left.x + right.x) * 0.5;
|
|
818
|
+
result.y = (left.y + right.y) * 0.5;
|
|
819
|
+
result.z = (left.z + right.z) * 0.5;
|
|
492
820
|
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
*
|
|
496
|
-
* @param {Cartesian3} left The first Cartesian.
|
|
497
|
-
* @param {Cartesian3} right The second Cartesian.
|
|
498
|
-
* @param {Cartesian3} result The object onto which to store the result.
|
|
499
|
-
* @returns {Cartesian3} The modified result parameter.
|
|
500
|
-
*/
|
|
501
|
-
Cartesian3.divideComponents = function (left, right, result) {
|
|
502
|
-
//>>includeStart('debug', pragmas.debug);
|
|
503
|
-
Check.typeOf.object("left", left);
|
|
504
|
-
Check.typeOf.object("right", right);
|
|
505
|
-
Check.typeOf.object("result", result);
|
|
506
|
-
//>>includeEnd('debug');
|
|
507
|
-
|
|
508
|
-
result.x = left.x / right.x;
|
|
509
|
-
result.y = left.y / right.y;
|
|
510
|
-
result.z = left.z / right.z;
|
|
511
|
-
return result;
|
|
512
|
-
};
|
|
821
|
+
return result;
|
|
822
|
+
}
|
|
513
823
|
|
|
514
|
-
/**
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
return result;
|
|
533
|
-
};
|
|
824
|
+
/**
|
|
825
|
+
* Returns a Cartesian3 position from longitude and latitude values given in degrees.
|
|
826
|
+
*
|
|
827
|
+
* @param {number} longitude The longitude, in degrees
|
|
828
|
+
* @param {number} latitude The latitude, in degrees
|
|
829
|
+
* @param {number} [height=0.0] The height, in meters, above the ellipsoid.
|
|
830
|
+
* @param {Ellipsoid} [ellipsoid=Ellipsoid.default] The ellipsoid on which the position lies.
|
|
831
|
+
* @param {Cartesian3} [result] The object onto which to store the result.
|
|
832
|
+
* @returns {Cartesian3} The position
|
|
833
|
+
*
|
|
834
|
+
* @example
|
|
835
|
+
* const position = Cesium.Cartesian3.fromDegrees(-115.0, 37.0);
|
|
836
|
+
*/
|
|
837
|
+
static fromDegrees(longitude, latitude, height, ellipsoid, result) {
|
|
838
|
+
//>>includeStart('debug', pragmas.debug);
|
|
839
|
+
Check.typeOf.number("longitude", longitude);
|
|
840
|
+
Check.typeOf.number("latitude", latitude);
|
|
841
|
+
//>>includeEnd('debug');
|
|
534
842
|
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
Check.typeOf.object("left", left);
|
|
546
|
-
Check.typeOf.object("right", right);
|
|
547
|
-
Check.typeOf.object("result", result);
|
|
548
|
-
//>>includeEnd('debug');
|
|
549
|
-
|
|
550
|
-
result.x = left.x - right.x;
|
|
551
|
-
result.y = left.y - right.y;
|
|
552
|
-
result.z = left.z - right.z;
|
|
553
|
-
return result;
|
|
554
|
-
};
|
|
843
|
+
longitude = CesiumMath.toRadians(longitude);
|
|
844
|
+
latitude = CesiumMath.toRadians(latitude);
|
|
845
|
+
return Cartesian3.fromRadians(
|
|
846
|
+
longitude,
|
|
847
|
+
latitude,
|
|
848
|
+
height,
|
|
849
|
+
ellipsoid,
|
|
850
|
+
result,
|
|
851
|
+
);
|
|
852
|
+
}
|
|
555
853
|
|
|
556
|
-
/**
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
return result;
|
|
575
|
-
};
|
|
854
|
+
/**
|
|
855
|
+
* Returns a Cartesian3 position from longitude and latitude values given in radians.
|
|
856
|
+
*
|
|
857
|
+
* @param {number} longitude The longitude, in radians
|
|
858
|
+
* @param {number} latitude The latitude, in radians
|
|
859
|
+
* @param {number} [height=0.0] The height, in meters, above the ellipsoid.
|
|
860
|
+
* @param {Ellipsoid} [ellipsoid=Ellipsoid.default] The ellipsoid on which the position lies.
|
|
861
|
+
* @param {Cartesian3} [result] The object onto which to store the result.
|
|
862
|
+
* @returns {Cartesian3} The position
|
|
863
|
+
*
|
|
864
|
+
* @example
|
|
865
|
+
* const position = Cesium.Cartesian3.fromRadians(-2.007, 0.645);
|
|
866
|
+
*/
|
|
867
|
+
static fromRadians(longitude, latitude, height, ellipsoid, result) {
|
|
868
|
+
//>>includeStart('debug', pragmas.debug);
|
|
869
|
+
Check.typeOf.number("longitude", longitude);
|
|
870
|
+
Check.typeOf.number("latitude", latitude);
|
|
871
|
+
//>>includeEnd('debug');
|
|
576
872
|
|
|
577
|
-
|
|
578
|
-
* Divides the provided Cartesian componentwise by the provided scalar.
|
|
579
|
-
*
|
|
580
|
-
* @param {Cartesian3} cartesian The Cartesian to be divided.
|
|
581
|
-
* @param {number} scalar The scalar to divide by.
|
|
582
|
-
* @param {Cartesian3} result The object onto which to store the result.
|
|
583
|
-
* @returns {Cartesian3} The modified result parameter.
|
|
584
|
-
*/
|
|
585
|
-
Cartesian3.divideByScalar = function (cartesian, scalar, result) {
|
|
586
|
-
//>>includeStart('debug', pragmas.debug);
|
|
587
|
-
Check.typeOf.object("cartesian", cartesian);
|
|
588
|
-
Check.typeOf.number("scalar", scalar);
|
|
589
|
-
Check.typeOf.object("result", result);
|
|
590
|
-
//>>includeEnd('debug');
|
|
591
|
-
|
|
592
|
-
result.x = cartesian.x / scalar;
|
|
593
|
-
result.y = cartesian.y / scalar;
|
|
594
|
-
result.z = cartesian.z / scalar;
|
|
595
|
-
return result;
|
|
596
|
-
};
|
|
873
|
+
height = height ?? 0.0;
|
|
597
874
|
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
* @param {Cartesian3} result The object onto which to store the result.
|
|
603
|
-
* @returns {Cartesian3} The modified result parameter.
|
|
604
|
-
*/
|
|
605
|
-
Cartesian3.negate = function (cartesian, result) {
|
|
606
|
-
//>>includeStart('debug', pragmas.debug);
|
|
607
|
-
Check.typeOf.object("cartesian", cartesian);
|
|
608
|
-
Check.typeOf.object("result", result);
|
|
609
|
-
//>>includeEnd('debug');
|
|
610
|
-
|
|
611
|
-
result.x = -cartesian.x;
|
|
612
|
-
result.y = -cartesian.y;
|
|
613
|
-
result.z = -cartesian.z;
|
|
614
|
-
return result;
|
|
615
|
-
};
|
|
875
|
+
const radiiSquared = !defined(ellipsoid)
|
|
876
|
+
? Cartesian3._ellipsoidRadiiSquared
|
|
877
|
+
: // @ts-expect-error Requires type-checking on Ellipsoid.js.
|
|
878
|
+
ellipsoid.radiiSquared;
|
|
616
879
|
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
*
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
* @returns {Cartesian3} The modified result parameter.
|
|
623
|
-
*/
|
|
624
|
-
Cartesian3.abs = function (cartesian, result) {
|
|
625
|
-
//>>includeStart('debug', pragmas.debug);
|
|
626
|
-
Check.typeOf.object("cartesian", cartesian);
|
|
627
|
-
Check.typeOf.object("result", result);
|
|
628
|
-
//>>includeEnd('debug');
|
|
629
|
-
|
|
630
|
-
result.x = Math.abs(cartesian.x);
|
|
631
|
-
result.y = Math.abs(cartesian.y);
|
|
632
|
-
result.z = Math.abs(cartesian.z);
|
|
633
|
-
return result;
|
|
634
|
-
};
|
|
880
|
+
const cosLatitude = Math.cos(latitude);
|
|
881
|
+
scratchN.x = cosLatitude * Math.cos(longitude);
|
|
882
|
+
scratchN.y = cosLatitude * Math.sin(longitude);
|
|
883
|
+
scratchN.z = Math.sin(latitude);
|
|
884
|
+
scratchN = Cartesian3.normalize(scratchN, scratchN);
|
|
635
885
|
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
* @param {Cartesian3} start The value corresponding to t at 0.0.
|
|
641
|
-
* @param {Cartesian3} end The value corresponding to t at 1.0.
|
|
642
|
-
* @param {number} t The point along t at which to interpolate.
|
|
643
|
-
* @param {Cartesian3} result The object onto which to store the result.
|
|
644
|
-
* @returns {Cartesian3} The modified result parameter.
|
|
645
|
-
*/
|
|
646
|
-
Cartesian3.lerp = function (start, end, t, result) {
|
|
647
|
-
//>>includeStart('debug', pragmas.debug);
|
|
648
|
-
Check.typeOf.object("start", start);
|
|
649
|
-
Check.typeOf.object("end", end);
|
|
650
|
-
Check.typeOf.number("t", t);
|
|
651
|
-
Check.typeOf.object("result", result);
|
|
652
|
-
//>>includeEnd('debug');
|
|
653
|
-
|
|
654
|
-
Cartesian3.multiplyByScalar(end, t, lerpScratch);
|
|
655
|
-
result = Cartesian3.multiplyByScalar(start, 1.0 - t, result);
|
|
656
|
-
return Cartesian3.add(lerpScratch, result, result);
|
|
657
|
-
};
|
|
886
|
+
Cartesian3.multiplyComponents(radiiSquared, scratchN, scratchK);
|
|
887
|
+
const gamma = Math.sqrt(Cartesian3.dot(scratchN, scratchK));
|
|
888
|
+
scratchK = Cartesian3.divideByScalar(scratchK, gamma, scratchK);
|
|
889
|
+
scratchN = Cartesian3.multiplyByScalar(scratchN, height, scratchN);
|
|
658
890
|
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
* @param {Cartesian3} left The first Cartesian.
|
|
665
|
-
* @param {Cartesian3} right The second Cartesian.
|
|
666
|
-
* @returns {number} The angle between the Cartesians.
|
|
667
|
-
*/
|
|
668
|
-
Cartesian3.angleBetween = function (left, right) {
|
|
669
|
-
//>>includeStart('debug', pragmas.debug);
|
|
670
|
-
Check.typeOf.object("left", left);
|
|
671
|
-
Check.typeOf.object("right", right);
|
|
672
|
-
//>>includeEnd('debug');
|
|
673
|
-
|
|
674
|
-
Cartesian3.normalize(left, angleBetweenScratch);
|
|
675
|
-
Cartesian3.normalize(right, angleBetweenScratch2);
|
|
676
|
-
const cosine = Cartesian3.dot(angleBetweenScratch, angleBetweenScratch2);
|
|
677
|
-
const sine = Cartesian3.magnitude(
|
|
678
|
-
Cartesian3.cross(
|
|
679
|
-
angleBetweenScratch,
|
|
680
|
-
angleBetweenScratch2,
|
|
681
|
-
angleBetweenScratch,
|
|
682
|
-
),
|
|
683
|
-
);
|
|
684
|
-
return Math.atan2(sine, cosine);
|
|
685
|
-
};
|
|
891
|
+
if (!defined(result)) {
|
|
892
|
+
result = new Cartesian3();
|
|
893
|
+
}
|
|
894
|
+
return Cartesian3.add(scratchK, scratchN, result);
|
|
895
|
+
}
|
|
686
896
|
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
897
|
+
/**
|
|
898
|
+
* Returns an array of Cartesian3 positions given an array of longitude and latitude values given in degrees.
|
|
899
|
+
*
|
|
900
|
+
* @param {number[]} coordinates A list of longitude and latitude values. Values alternate [longitude, latitude, longitude, latitude...].
|
|
901
|
+
* @param {Ellipsoid} [ellipsoid=Ellipsoid.default] The ellipsoid on which the coordinates lie.
|
|
902
|
+
* @param {Cartesian3[]} [result] An array of Cartesian3 objects to store the result.
|
|
903
|
+
* @returns {Cartesian3[]} The array of positions.
|
|
904
|
+
*
|
|
905
|
+
* @example
|
|
906
|
+
* const positions = Cesium.Cartesian3.fromDegreesArray([-115.0, 37.0, -107.0, 33.0]);
|
|
907
|
+
*/
|
|
908
|
+
static fromDegreesArray(coordinates, ellipsoid, result) {
|
|
909
|
+
//>>includeStart('debug', pragmas.debug);
|
|
910
|
+
Check.defined("coordinates", coordinates);
|
|
911
|
+
if (coordinates.length < 2 || coordinates.length % 2 !== 0) {
|
|
912
|
+
throw new DeveloperError(
|
|
913
|
+
"the number of coordinates must be a multiple of 2 and at least 2",
|
|
914
|
+
);
|
|
915
|
+
}
|
|
916
|
+
//>>includeEnd('debug');
|
|
917
|
+
|
|
918
|
+
const length = coordinates.length;
|
|
919
|
+
if (!defined(result)) {
|
|
920
|
+
result = new Array(length / 2);
|
|
707
921
|
} else {
|
|
708
|
-
result =
|
|
922
|
+
result.length = length / 2;
|
|
709
923
|
}
|
|
710
|
-
} else if (f.y <= f.z) {
|
|
711
|
-
result = Cartesian3.clone(Cartesian3.UNIT_Y, result);
|
|
712
|
-
} else {
|
|
713
|
-
result = Cartesian3.clone(Cartesian3.UNIT_Z, result);
|
|
714
|
-
}
|
|
715
924
|
|
|
716
|
-
|
|
717
|
-
|
|
925
|
+
for (let i = 0; i < length; i += 2) {
|
|
926
|
+
const longitude = coordinates[i];
|
|
927
|
+
const latitude = coordinates[i + 1];
|
|
928
|
+
const index = i / 2;
|
|
929
|
+
result[index] = Cartesian3.fromDegrees(
|
|
930
|
+
longitude,
|
|
931
|
+
latitude,
|
|
932
|
+
0,
|
|
933
|
+
ellipsoid,
|
|
934
|
+
result[index],
|
|
935
|
+
);
|
|
936
|
+
}
|
|
718
937
|
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
* @param {Cartesian3} a The vector that needs projecting
|
|
722
|
-
* @param {Cartesian3} b The vector to project onto
|
|
723
|
-
* @param {Cartesian3} result The result cartesian
|
|
724
|
-
* @returns {Cartesian3} The modified result parameter
|
|
725
|
-
*/
|
|
726
|
-
Cartesian3.projectVector = function (a, b, result) {
|
|
727
|
-
//>>includeStart('debug', pragmas.debug);
|
|
728
|
-
Check.defined("a", a);
|
|
729
|
-
Check.defined("b", b);
|
|
730
|
-
Check.defined("result", result);
|
|
731
|
-
//>>includeEnd('debug');
|
|
938
|
+
return result;
|
|
939
|
+
}
|
|
732
940
|
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
941
|
+
/**
|
|
942
|
+
* Returns an array of Cartesian3 positions given an array of longitude and latitude values given in radians.
|
|
943
|
+
*
|
|
944
|
+
* @param {number[]} coordinates A list of longitude and latitude values. Values alternate [longitude, latitude, longitude, latitude...].
|
|
945
|
+
* @param {Ellipsoid} [ellipsoid=Ellipsoid.default] The ellipsoid on which the coordinates lie.
|
|
946
|
+
* @param {Cartesian3[]} [result] An array of Cartesian3 objects to store the result.
|
|
947
|
+
* @returns {Cartesian3[]} The array of positions.
|
|
948
|
+
*
|
|
949
|
+
* @example
|
|
950
|
+
* const positions = Cesium.Cartesian3.fromRadiansArray([-2.007, 0.645, -1.867, .575]);
|
|
951
|
+
*/
|
|
952
|
+
static fromRadiansArray(coordinates, ellipsoid, result) {
|
|
953
|
+
//>>includeStart('debug', pragmas.debug);
|
|
954
|
+
Check.defined("coordinates", coordinates);
|
|
955
|
+
if (coordinates.length < 2 || coordinates.length % 2 !== 0) {
|
|
956
|
+
throw new DeveloperError(
|
|
957
|
+
"the number of coordinates must be a multiple of 2 and at least 2",
|
|
958
|
+
);
|
|
959
|
+
}
|
|
960
|
+
//>>includeEnd('debug');
|
|
736
961
|
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
* @returns {boolean} <code>true</code> if left and right are equal, <code>false</code> otherwise.
|
|
744
|
-
*/
|
|
745
|
-
Cartesian3.equals = function (left, right) {
|
|
746
|
-
return (
|
|
747
|
-
left === right ||
|
|
748
|
-
(defined(left) &&
|
|
749
|
-
defined(right) &&
|
|
750
|
-
left.x === right.x &&
|
|
751
|
-
left.y === right.y &&
|
|
752
|
-
left.z === right.z)
|
|
753
|
-
);
|
|
754
|
-
};
|
|
962
|
+
const length = coordinates.length;
|
|
963
|
+
if (!defined(result)) {
|
|
964
|
+
result = new Array(length / 2);
|
|
965
|
+
} else {
|
|
966
|
+
result.length = length / 2;
|
|
967
|
+
}
|
|
755
968
|
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
969
|
+
for (let i = 0; i < length; i += 2) {
|
|
970
|
+
const longitude = coordinates[i];
|
|
971
|
+
const latitude = coordinates[i + 1];
|
|
972
|
+
const index = i / 2;
|
|
973
|
+
result[index] = Cartesian3.fromRadians(
|
|
974
|
+
longitude,
|
|
975
|
+
latitude,
|
|
976
|
+
0,
|
|
977
|
+
ellipsoid,
|
|
978
|
+
result[index],
|
|
979
|
+
);
|
|
980
|
+
}
|
|
766
981
|
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
* <code>true</code> if they pass an absolute or relative tolerance test,
|
|
770
|
-
* <code>false</code> otherwise.
|
|
771
|
-
*
|
|
772
|
-
* @param {Cartesian3} [left] The first Cartesian.
|
|
773
|
-
* @param {Cartesian3} [right] The second Cartesian.
|
|
774
|
-
* @param {number} [relativeEpsilon=0] The relative epsilon tolerance to use for equality testing.
|
|
775
|
-
* @param {number} [absoluteEpsilon=relativeEpsilon] The absolute epsilon tolerance to use for equality testing.
|
|
776
|
-
* @returns {boolean} <code>true</code> if left and right are within the provided epsilon, <code>false</code> otherwise.
|
|
777
|
-
*/
|
|
778
|
-
Cartesian3.equalsEpsilon = function (
|
|
779
|
-
left,
|
|
780
|
-
right,
|
|
781
|
-
relativeEpsilon,
|
|
782
|
-
absoluteEpsilon,
|
|
783
|
-
) {
|
|
784
|
-
return (
|
|
785
|
-
left === right ||
|
|
786
|
-
(defined(left) &&
|
|
787
|
-
defined(right) &&
|
|
788
|
-
CesiumMath.equalsEpsilon(
|
|
789
|
-
left.x,
|
|
790
|
-
right.x,
|
|
791
|
-
relativeEpsilon,
|
|
792
|
-
absoluteEpsilon,
|
|
793
|
-
) &&
|
|
794
|
-
CesiumMath.equalsEpsilon(
|
|
795
|
-
left.y,
|
|
796
|
-
right.y,
|
|
797
|
-
relativeEpsilon,
|
|
798
|
-
absoluteEpsilon,
|
|
799
|
-
) &&
|
|
800
|
-
CesiumMath.equalsEpsilon(
|
|
801
|
-
left.z,
|
|
802
|
-
right.z,
|
|
803
|
-
relativeEpsilon,
|
|
804
|
-
absoluteEpsilon,
|
|
805
|
-
))
|
|
806
|
-
);
|
|
807
|
-
};
|
|
982
|
+
return result;
|
|
983
|
+
}
|
|
808
984
|
|
|
809
|
-
/**
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
const rightZ = right.z;
|
|
830
|
-
|
|
831
|
-
const x = leftY * rightZ - leftZ * rightY;
|
|
832
|
-
const y = leftZ * rightX - leftX * rightZ;
|
|
833
|
-
const z = leftX * rightY - leftY * rightX;
|
|
834
|
-
|
|
835
|
-
result.x = x;
|
|
836
|
-
result.y = y;
|
|
837
|
-
result.z = z;
|
|
838
|
-
return result;
|
|
839
|
-
};
|
|
985
|
+
/**
|
|
986
|
+
* Returns an array of Cartesian3 positions given an array of longitude, latitude and height values where longitude and latitude are given in degrees.
|
|
987
|
+
*
|
|
988
|
+
* @param {number[]} coordinates A list of longitude, latitude and height values. Values alternate [longitude, latitude, height, longitude, latitude, height...].
|
|
989
|
+
* @param {Ellipsoid} [ellipsoid=Ellipsoid.default] The ellipsoid on which the position lies.
|
|
990
|
+
* @param {Cartesian3[]} [result] An array of Cartesian3 objects to store the result.
|
|
991
|
+
* @returns {Cartesian3[]} The array of positions.
|
|
992
|
+
*
|
|
993
|
+
* @example
|
|
994
|
+
* const positions = Cesium.Cartesian3.fromDegreesArrayHeights([-115.0, 37.0, 100000.0, -107.0, 33.0, 150000.0]);
|
|
995
|
+
*/
|
|
996
|
+
static fromDegreesArrayHeights(coordinates, ellipsoid, result) {
|
|
997
|
+
//>>includeStart('debug', pragmas.debug);
|
|
998
|
+
Check.defined("coordinates", coordinates);
|
|
999
|
+
if (coordinates.length < 3 || coordinates.length % 3 !== 0) {
|
|
1000
|
+
throw new DeveloperError(
|
|
1001
|
+
"the number of coordinates must be a multiple of 3 and at least 3",
|
|
1002
|
+
);
|
|
1003
|
+
}
|
|
1004
|
+
//>>includeEnd('debug');
|
|
840
1005
|
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
*/
|
|
848
|
-
Cartesian3.midpoint = function (left, right, result) {
|
|
849
|
-
//>>includeStart('debug', pragmas.debug);
|
|
850
|
-
Check.typeOf.object("left", left);
|
|
851
|
-
Check.typeOf.object("right", right);
|
|
852
|
-
Check.typeOf.object("result", result);
|
|
853
|
-
//>>includeEnd('debug');
|
|
1006
|
+
const length = coordinates.length;
|
|
1007
|
+
if (!defined(result)) {
|
|
1008
|
+
result = new Array(length / 3);
|
|
1009
|
+
} else {
|
|
1010
|
+
result.length = length / 3;
|
|
1011
|
+
}
|
|
854
1012
|
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
1013
|
+
for (let i = 0; i < length; i += 3) {
|
|
1014
|
+
const longitude = coordinates[i];
|
|
1015
|
+
const latitude = coordinates[i + 1];
|
|
1016
|
+
const height = coordinates[i + 2];
|
|
1017
|
+
const index = i / 3;
|
|
1018
|
+
result[index] = Cartesian3.fromDegrees(
|
|
1019
|
+
longitude,
|
|
1020
|
+
latitude,
|
|
1021
|
+
height,
|
|
1022
|
+
ellipsoid,
|
|
1023
|
+
result[index],
|
|
1024
|
+
);
|
|
1025
|
+
}
|
|
858
1026
|
|
|
859
|
-
|
|
860
|
-
}
|
|
1027
|
+
return result;
|
|
1028
|
+
}
|
|
861
1029
|
|
|
862
|
-
/**
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
)
|
|
882
|
-
//>>includeStart('debug', pragmas.debug);
|
|
883
|
-
Check.typeOf.number("longitude", longitude);
|
|
884
|
-
Check.typeOf.number("latitude", latitude);
|
|
885
|
-
//>>includeEnd('debug');
|
|
886
|
-
|
|
887
|
-
longitude = CesiumMath.toRadians(longitude);
|
|
888
|
-
latitude = CesiumMath.toRadians(latitude);
|
|
889
|
-
return Cartesian3.fromRadians(longitude, latitude, height, ellipsoid, result);
|
|
890
|
-
};
|
|
1030
|
+
/**
|
|
1031
|
+
* Returns an array of Cartesian3 positions given an array of longitude, latitude and height values where longitude and latitude are given in radians.
|
|
1032
|
+
*
|
|
1033
|
+
* @param {number[]} coordinates A list of longitude, latitude and height values. Values alternate [longitude, latitude, height, longitude, latitude, height...].
|
|
1034
|
+
* @param {Ellipsoid} [ellipsoid=Ellipsoid.default] The ellipsoid on which the position lies.
|
|
1035
|
+
* @param {Cartesian3[]} [result] An array of Cartesian3 objects to store the result.
|
|
1036
|
+
* @returns {Cartesian3[]} The array of positions.
|
|
1037
|
+
*
|
|
1038
|
+
* @example
|
|
1039
|
+
* const positions = Cesium.Cartesian3.fromRadiansArrayHeights([-2.007, 0.645, 100000.0, -1.867, .575, 150000.0]);
|
|
1040
|
+
*/
|
|
1041
|
+
static fromRadiansArrayHeights(coordinates, ellipsoid, result) {
|
|
1042
|
+
//>>includeStart('debug', pragmas.debug);
|
|
1043
|
+
Check.defined("coordinates", coordinates);
|
|
1044
|
+
if (coordinates.length < 3 || coordinates.length % 3 !== 0) {
|
|
1045
|
+
throw new DeveloperError(
|
|
1046
|
+
"the number of coordinates must be a multiple of 3 and at least 3",
|
|
1047
|
+
);
|
|
1048
|
+
}
|
|
1049
|
+
//>>includeEnd('debug');
|
|
891
1050
|
|
|
892
|
-
|
|
893
|
-
|
|
1051
|
+
const length = coordinates.length;
|
|
1052
|
+
if (!defined(result)) {
|
|
1053
|
+
result = new Array(length / 3);
|
|
1054
|
+
} else {
|
|
1055
|
+
result.length = length / 3;
|
|
1056
|
+
}
|
|
894
1057
|
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
1058
|
+
for (let i = 0; i < length; i += 3) {
|
|
1059
|
+
const longitude = coordinates[i];
|
|
1060
|
+
const latitude = coordinates[i + 1];
|
|
1061
|
+
const height = coordinates[i + 2];
|
|
1062
|
+
const index = i / 3;
|
|
1063
|
+
result[index] = Cartesian3.fromRadians(
|
|
1064
|
+
longitude,
|
|
1065
|
+
latitude,
|
|
1066
|
+
height,
|
|
1067
|
+
ellipsoid,
|
|
1068
|
+
result[index],
|
|
1069
|
+
);
|
|
1070
|
+
}
|
|
901
1071
|
|
|
902
|
-
|
|
903
|
-
* Returns a Cartesian3 position from longitude and latitude values given in radians.
|
|
904
|
-
*
|
|
905
|
-
* @param {number} longitude The longitude, in radians
|
|
906
|
-
* @param {number} latitude The latitude, in radians
|
|
907
|
-
* @param {number} [height=0.0] The height, in meters, above the ellipsoid.
|
|
908
|
-
* @param {Ellipsoid} [ellipsoid=Ellipsoid.default] The ellipsoid on which the position lies.
|
|
909
|
-
* @param {Cartesian3} [result] The object onto which to store the result.
|
|
910
|
-
* @returns {Cartesian3} The position
|
|
911
|
-
*
|
|
912
|
-
* @example
|
|
913
|
-
* const position = Cesium.Cartesian3.fromRadians(-2.007, 0.645);
|
|
914
|
-
*/
|
|
915
|
-
Cartesian3.fromRadians = function (
|
|
916
|
-
longitude,
|
|
917
|
-
latitude,
|
|
918
|
-
height,
|
|
919
|
-
ellipsoid,
|
|
920
|
-
result,
|
|
921
|
-
) {
|
|
922
|
-
//>>includeStart('debug', pragmas.debug);
|
|
923
|
-
Check.typeOf.number("longitude", longitude);
|
|
924
|
-
Check.typeOf.number("latitude", latitude);
|
|
925
|
-
//>>includeEnd('debug');
|
|
926
|
-
|
|
927
|
-
height = height ?? 0.0;
|
|
928
|
-
|
|
929
|
-
const radiiSquared = !defined(ellipsoid)
|
|
930
|
-
? Cartesian3._ellipsoidRadiiSquared
|
|
931
|
-
: ellipsoid.radiiSquared;
|
|
932
|
-
|
|
933
|
-
const cosLatitude = Math.cos(latitude);
|
|
934
|
-
scratchN.x = cosLatitude * Math.cos(longitude);
|
|
935
|
-
scratchN.y = cosLatitude * Math.sin(longitude);
|
|
936
|
-
scratchN.z = Math.sin(latitude);
|
|
937
|
-
scratchN = Cartesian3.normalize(scratchN, scratchN);
|
|
938
|
-
|
|
939
|
-
Cartesian3.multiplyComponents(radiiSquared, scratchN, scratchK);
|
|
940
|
-
const gamma = Math.sqrt(Cartesian3.dot(scratchN, scratchK));
|
|
941
|
-
scratchK = Cartesian3.divideByScalar(scratchK, gamma, scratchK);
|
|
942
|
-
scratchN = Cartesian3.multiplyByScalar(scratchN, height, scratchN);
|
|
943
|
-
|
|
944
|
-
if (!defined(result)) {
|
|
945
|
-
result = new Cartesian3();
|
|
1072
|
+
return result;
|
|
946
1073
|
}
|
|
947
|
-
return Cartesian3.add(scratchK, scratchN, result);
|
|
948
|
-
};
|
|
949
1074
|
|
|
950
|
-
/**
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
* @example
|
|
959
|
-
* const positions = Cesium.Cartesian3.fromDegreesArray([-115.0, 37.0, -107.0, 33.0]);
|
|
960
|
-
*/
|
|
961
|
-
Cartesian3.fromDegreesArray = function (coordinates, ellipsoid, result) {
|
|
962
|
-
//>>includeStart('debug', pragmas.debug);
|
|
963
|
-
Check.defined("coordinates", coordinates);
|
|
964
|
-
if (coordinates.length < 2 || coordinates.length % 2 !== 0) {
|
|
965
|
-
throw new DeveloperError(
|
|
966
|
-
"the number of coordinates must be a multiple of 2 and at least 2",
|
|
967
|
-
);
|
|
1075
|
+
/**
|
|
1076
|
+
* Duplicates this Cartesian3 instance.
|
|
1077
|
+
*
|
|
1078
|
+
* @param {Cartesian3} [result] The object onto which to store the result.
|
|
1079
|
+
* @returns {Cartesian3} The modified result parameter or a new Cartesian3 instance if one was not provided.
|
|
1080
|
+
*/
|
|
1081
|
+
clone(result) {
|
|
1082
|
+
return Cartesian3.clone(this, result);
|
|
968
1083
|
}
|
|
969
|
-
//>>includeEnd('debug');
|
|
970
1084
|
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
1085
|
+
/**
|
|
1086
|
+
* Compares this Cartesian against the provided Cartesian componentwise and returns
|
|
1087
|
+
* <code>true</code> if they are equal, <code>false</code> otherwise.
|
|
1088
|
+
*
|
|
1089
|
+
* @param {Cartesian3} [right] The right hand side Cartesian.
|
|
1090
|
+
* @returns {boolean} <code>true</code> if they are equal, <code>false</code> otherwise.
|
|
1091
|
+
*/
|
|
1092
|
+
equals(right) {
|
|
1093
|
+
return Cartesian3.equals(this, right);
|
|
976
1094
|
}
|
|
977
1095
|
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
1096
|
+
/**
|
|
1097
|
+
* Compares this Cartesian against the provided Cartesian componentwise and returns
|
|
1098
|
+
* <code>true</code> if they pass an absolute or relative tolerance test,
|
|
1099
|
+
* <code>false</code> otherwise.
|
|
1100
|
+
*
|
|
1101
|
+
* @param {Cartesian3} [right] The right hand side Cartesian.
|
|
1102
|
+
* @param {number} [relativeEpsilon=0] The relative epsilon tolerance to use for equality testing.
|
|
1103
|
+
* @param {number} [absoluteEpsilon=relativeEpsilon] The absolute epsilon tolerance to use for equality testing.
|
|
1104
|
+
* @returns {boolean} <code>true</code> if they are within the provided epsilon, <code>false</code> otherwise.
|
|
1105
|
+
*/
|
|
1106
|
+
equalsEpsilon(right, relativeEpsilon, absoluteEpsilon) {
|
|
1107
|
+
return Cartesian3.equalsEpsilon(
|
|
1108
|
+
this,
|
|
1109
|
+
right,
|
|
1110
|
+
relativeEpsilon,
|
|
1111
|
+
absoluteEpsilon,
|
|
988
1112
|
);
|
|
989
1113
|
}
|
|
990
1114
|
|
|
991
|
-
|
|
992
|
-
|
|
1115
|
+
/**
|
|
1116
|
+
* Creates a string representing this Cartesian in the format '(x, y, z)'.
|
|
1117
|
+
*
|
|
1118
|
+
* @returns {string} A string representing this Cartesian in the format '(x, y, z)'.
|
|
1119
|
+
*/
|
|
1120
|
+
toString() {
|
|
1121
|
+
return `(${this.x}, ${this.y}, ${this.z})`;
|
|
1122
|
+
}
|
|
1123
|
+
}
|
|
993
1124
|
|
|
994
1125
|
/**
|
|
995
|
-
*
|
|
996
|
-
*
|
|
997
|
-
* @
|
|
998
|
-
* @param {Ellipsoid} [ellipsoid=Ellipsoid.default] The ellipsoid on which the coordinates lie.
|
|
999
|
-
* @param {Cartesian3[]} [result] An array of Cartesian3 objects to store the result.
|
|
1000
|
-
* @returns {Cartesian3[]} The array of positions.
|
|
1126
|
+
* Creates a Cartesian3 instance from an existing Cartesian4. This simply takes the
|
|
1127
|
+
* x, y, and z properties of the Cartesian4 and drops w.
|
|
1128
|
+
* @function
|
|
1001
1129
|
*
|
|
1002
|
-
* @
|
|
1003
|
-
*
|
|
1130
|
+
* @param {Cartesian4} cartesian The Cartesian4 instance to create a Cartesian3 instance from.
|
|
1131
|
+
* @param {Cartesian3} [result] The object onto which to store the result.
|
|
1132
|
+
* @returns {Cartesian3} The modified result parameter or a new Cartesian3 instance if one was not provided.
|
|
1004
1133
|
*/
|
|
1005
|
-
Cartesian3.
|
|
1006
|
-
//>>includeStart('debug', pragmas.debug);
|
|
1007
|
-
Check.defined("coordinates", coordinates);
|
|
1008
|
-
if (coordinates.length < 2 || coordinates.length % 2 !== 0) {
|
|
1009
|
-
throw new DeveloperError(
|
|
1010
|
-
"the number of coordinates must be a multiple of 2 and at least 2",
|
|
1011
|
-
);
|
|
1012
|
-
}
|
|
1013
|
-
//>>includeEnd('debug');
|
|
1014
|
-
|
|
1015
|
-
const length = coordinates.length;
|
|
1016
|
-
if (!defined(result)) {
|
|
1017
|
-
result = new Array(length / 2);
|
|
1018
|
-
} else {
|
|
1019
|
-
result.length = length / 2;
|
|
1020
|
-
}
|
|
1021
|
-
|
|
1022
|
-
for (let i = 0; i < length; i += 2) {
|
|
1023
|
-
const longitude = coordinates[i];
|
|
1024
|
-
const latitude = coordinates[i + 1];
|
|
1025
|
-
const index = i / 2;
|
|
1026
|
-
result[index] = Cartesian3.fromRadians(
|
|
1027
|
-
longitude,
|
|
1028
|
-
latitude,
|
|
1029
|
-
0,
|
|
1030
|
-
ellipsoid,
|
|
1031
|
-
result[index],
|
|
1032
|
-
);
|
|
1033
|
-
}
|
|
1134
|
+
Cartesian3.fromCartesian4 = Cartesian3.clone;
|
|
1034
1135
|
|
|
1035
|
-
|
|
1036
|
-
|
|
1136
|
+
/**
|
|
1137
|
+
* The number of elements used to pack the object into an array.
|
|
1138
|
+
* @type {number}
|
|
1139
|
+
*/
|
|
1140
|
+
Cartesian3.packedLength = 3;
|
|
1037
1141
|
|
|
1038
1142
|
/**
|
|
1039
|
-
*
|
|
1143
|
+
* Creates a Cartesian3 from three consecutive elements in an array.
|
|
1144
|
+
* @function
|
|
1040
1145
|
*
|
|
1041
|
-
* @param {number[]}
|
|
1042
|
-
* @param {
|
|
1043
|
-
* @param {Cartesian3
|
|
1044
|
-
* @returns {Cartesian3
|
|
1146
|
+
* @param {number[]} array The array whose three consecutive elements correspond to the x, y, and z components, respectively.
|
|
1147
|
+
* @param {number} [startingIndex=0] The offset into the array of the first element, which corresponds to the x component.
|
|
1148
|
+
* @param {Cartesian3} [result] The object onto which to store the result.
|
|
1149
|
+
* @returns {Cartesian3} The modified result parameter or a new Cartesian3 instance if one was not provided.
|
|
1045
1150
|
*
|
|
1046
1151
|
* @example
|
|
1047
|
-
*
|
|
1152
|
+
* // Create a Cartesian3 with (1.0, 2.0, 3.0)
|
|
1153
|
+
* const v = [1.0, 2.0, 3.0];
|
|
1154
|
+
* const p = Cesium.Cartesian3.fromArray(v);
|
|
1155
|
+
*
|
|
1156
|
+
* // Create a Cartesian3 with (1.0, 2.0, 3.0) using an offset into an array
|
|
1157
|
+
* const v2 = [0.0, 0.0, 1.0, 2.0, 3.0];
|
|
1158
|
+
* const p2 = Cesium.Cartesian3.fromArray(v2, 2);
|
|
1048
1159
|
*/
|
|
1049
|
-
Cartesian3.
|
|
1050
|
-
//>>includeStart('debug', pragmas.debug);
|
|
1051
|
-
Check.defined("coordinates", coordinates);
|
|
1052
|
-
if (coordinates.length < 3 || coordinates.length % 3 !== 0) {
|
|
1053
|
-
throw new DeveloperError(
|
|
1054
|
-
"the number of coordinates must be a multiple of 3 and at least 3",
|
|
1055
|
-
);
|
|
1056
|
-
}
|
|
1057
|
-
//>>includeEnd('debug');
|
|
1058
|
-
|
|
1059
|
-
const length = coordinates.length;
|
|
1060
|
-
if (!defined(result)) {
|
|
1061
|
-
result = new Array(length / 3);
|
|
1062
|
-
} else {
|
|
1063
|
-
result.length = length / 3;
|
|
1064
|
-
}
|
|
1160
|
+
Cartesian3.fromArray = Cartesian3.unpack;
|
|
1065
1161
|
|
|
1066
|
-
|
|
1067
|
-
const longitude = coordinates[i];
|
|
1068
|
-
const latitude = coordinates[i + 1];
|
|
1069
|
-
const height = coordinates[i + 2];
|
|
1070
|
-
const index = i / 3;
|
|
1071
|
-
result[index] = Cartesian3.fromDegrees(
|
|
1072
|
-
longitude,
|
|
1073
|
-
latitude,
|
|
1074
|
-
height,
|
|
1075
|
-
ellipsoid,
|
|
1076
|
-
result[index],
|
|
1077
|
-
);
|
|
1078
|
-
}
|
|
1162
|
+
const distanceScratch = new Cartesian3();
|
|
1079
1163
|
|
|
1080
|
-
|
|
1081
|
-
};
|
|
1164
|
+
const lerpScratch = new Cartesian3();
|
|
1082
1165
|
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
*
|
|
1086
|
-
* @param {number[]} coordinates A list of longitude, latitude and height values. Values alternate [longitude, latitude, height, longitude, latitude, height...].
|
|
1087
|
-
* @param {Ellipsoid} [ellipsoid=Ellipsoid.default] The ellipsoid on which the position lies.
|
|
1088
|
-
* @param {Cartesian3[]} [result] An array of Cartesian3 objects to store the result.
|
|
1089
|
-
* @returns {Cartesian3[]} The array of positions.
|
|
1090
|
-
*
|
|
1091
|
-
* @example
|
|
1092
|
-
* const positions = Cesium.Cartesian3.fromRadiansArrayHeights([-2.007, 0.645, 100000.0, -1.867, .575, 150000.0]);
|
|
1093
|
-
*/
|
|
1094
|
-
Cartesian3.fromRadiansArrayHeights = function (coordinates, ellipsoid, result) {
|
|
1095
|
-
//>>includeStart('debug', pragmas.debug);
|
|
1096
|
-
Check.defined("coordinates", coordinates);
|
|
1097
|
-
if (coordinates.length < 3 || coordinates.length % 3 !== 0) {
|
|
1098
|
-
throw new DeveloperError(
|
|
1099
|
-
"the number of coordinates must be a multiple of 3 and at least 3",
|
|
1100
|
-
);
|
|
1101
|
-
}
|
|
1102
|
-
//>>includeEnd('debug');
|
|
1166
|
+
const angleBetweenScratch = new Cartesian3();
|
|
1167
|
+
const angleBetweenScratch2 = new Cartesian3();
|
|
1103
1168
|
|
|
1104
|
-
|
|
1105
|
-
if (!defined(result)) {
|
|
1106
|
-
result = new Array(length / 3);
|
|
1107
|
-
} else {
|
|
1108
|
-
result.length = length / 3;
|
|
1109
|
-
}
|
|
1169
|
+
const mostOrthogonalAxisScratch = new Cartesian3();
|
|
1110
1170
|
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
const latitude = coordinates[i + 1];
|
|
1114
|
-
const height = coordinates[i + 2];
|
|
1115
|
-
const index = i / 3;
|
|
1116
|
-
result[index] = Cartesian3.fromRadians(
|
|
1117
|
-
longitude,
|
|
1118
|
-
latitude,
|
|
1119
|
-
height,
|
|
1120
|
-
ellipsoid,
|
|
1121
|
-
result[index],
|
|
1122
|
-
);
|
|
1123
|
-
}
|
|
1171
|
+
let scratchN = new Cartesian3();
|
|
1172
|
+
let scratchK = new Cartesian3();
|
|
1124
1173
|
|
|
1125
|
-
|
|
1126
|
-
|
|
1174
|
+
// To prevent a circular dependency, this value is overridden by Ellipsoid when Ellipsoid.default is set
|
|
1175
|
+
Cartesian3._ellipsoidRadiiSquared = new Cartesian3(
|
|
1176
|
+
6378137.0 * 6378137.0,
|
|
1177
|
+
6378137.0 * 6378137.0,
|
|
1178
|
+
6356752.3142451793 * 6356752.3142451793,
|
|
1179
|
+
);
|
|
1127
1180
|
|
|
1128
1181
|
/**
|
|
1129
1182
|
* An immutable Cartesian3 instance initialized to (0.0, 0.0, 0.0).
|
|
@@ -1165,56 +1218,4 @@ Cartesian3.UNIT_Y = Object.freeze(new Cartesian3(0.0, 1.0, 0.0));
|
|
|
1165
1218
|
*/
|
|
1166
1219
|
Cartesian3.UNIT_Z = Object.freeze(new Cartesian3(0.0, 0.0, 1.0));
|
|
1167
1220
|
|
|
1168
|
-
/**
|
|
1169
|
-
* Duplicates this Cartesian3 instance.
|
|
1170
|
-
*
|
|
1171
|
-
* @param {Cartesian3} [result] The object onto which to store the result.
|
|
1172
|
-
* @returns {Cartesian3} The modified result parameter or a new Cartesian3 instance if one was not provided.
|
|
1173
|
-
*/
|
|
1174
|
-
Cartesian3.prototype.clone = function (result) {
|
|
1175
|
-
return Cartesian3.clone(this, result);
|
|
1176
|
-
};
|
|
1177
|
-
|
|
1178
|
-
/**
|
|
1179
|
-
* Compares this Cartesian against the provided Cartesian componentwise and returns
|
|
1180
|
-
* <code>true</code> if they are equal, <code>false</code> otherwise.
|
|
1181
|
-
*
|
|
1182
|
-
* @param {Cartesian3} [right] The right hand side Cartesian.
|
|
1183
|
-
* @returns {boolean} <code>true</code> if they are equal, <code>false</code> otherwise.
|
|
1184
|
-
*/
|
|
1185
|
-
Cartesian3.prototype.equals = function (right) {
|
|
1186
|
-
return Cartesian3.equals(this, right);
|
|
1187
|
-
};
|
|
1188
|
-
|
|
1189
|
-
/**
|
|
1190
|
-
* Compares this Cartesian against the provided Cartesian componentwise and returns
|
|
1191
|
-
* <code>true</code> if they pass an absolute or relative tolerance test,
|
|
1192
|
-
* <code>false</code> otherwise.
|
|
1193
|
-
*
|
|
1194
|
-
* @param {Cartesian3} [right] The right hand side Cartesian.
|
|
1195
|
-
* @param {number} [relativeEpsilon=0] The relative epsilon tolerance to use for equality testing.
|
|
1196
|
-
* @param {number} [absoluteEpsilon=relativeEpsilon] The absolute epsilon tolerance to use for equality testing.
|
|
1197
|
-
* @returns {boolean} <code>true</code> if they are within the provided epsilon, <code>false</code> otherwise.
|
|
1198
|
-
*/
|
|
1199
|
-
Cartesian3.prototype.equalsEpsilon = function (
|
|
1200
|
-
right,
|
|
1201
|
-
relativeEpsilon,
|
|
1202
|
-
absoluteEpsilon,
|
|
1203
|
-
) {
|
|
1204
|
-
return Cartesian3.equalsEpsilon(
|
|
1205
|
-
this,
|
|
1206
|
-
right,
|
|
1207
|
-
relativeEpsilon,
|
|
1208
|
-
absoluteEpsilon,
|
|
1209
|
-
);
|
|
1210
|
-
};
|
|
1211
|
-
|
|
1212
|
-
/**
|
|
1213
|
-
* Creates a string representing this Cartesian in the format '(x, y, z)'.
|
|
1214
|
-
*
|
|
1215
|
-
* @returns {string} A string representing this Cartesian in the format '(x, y, z)'.
|
|
1216
|
-
*/
|
|
1217
|
-
Cartesian3.prototype.toString = function () {
|
|
1218
|
-
return `(${this.x}, ${this.y}, ${this.z})`;
|
|
1219
|
-
};
|
|
1220
1221
|
export default Cartesian3;
|