@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,740 +1,797 @@
|
|
|
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 Cartesian3 from "./Cartesian3.js"; */
|
|
10
|
+
/** @import Cartesian4 from "./Cartesian4.js"; */
|
|
11
|
+
|
|
6
12
|
/**
|
|
7
13
|
* A 2D Cartesian point.
|
|
8
|
-
* @alias Cartesian2
|
|
9
|
-
* @constructor
|
|
10
|
-
*
|
|
11
|
-
* @param {number} [x=0.0] The X component.
|
|
12
|
-
* @param {number} [y=0.0] The Y component.
|
|
13
14
|
*
|
|
14
15
|
* @see Cartesian3
|
|
15
16
|
* @see Cartesian4
|
|
16
17
|
* @see Packable
|
|
17
18
|
*/
|
|
18
|
-
|
|
19
|
+
class Cartesian2 {
|
|
19
20
|
/**
|
|
20
|
-
* The X component.
|
|
21
|
-
* @
|
|
22
|
-
* @default 0.0
|
|
21
|
+
* @param {number} [x=0.0] The X component.
|
|
22
|
+
* @param {number} [y=0.0] The Y component.
|
|
23
23
|
*/
|
|
24
|
-
|
|
24
|
+
constructor(x, y) {
|
|
25
|
+
/**
|
|
26
|
+
* The X component.
|
|
27
|
+
* @type {number}
|
|
28
|
+
* @default 0.0
|
|
29
|
+
*/
|
|
30
|
+
this.x = x ?? 0.0;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* The Y component.
|
|
34
|
+
* @type {number}
|
|
35
|
+
* @default 0.0
|
|
36
|
+
*/
|
|
37
|
+
this.y = y ?? 0.0;
|
|
38
|
+
}
|
|
25
39
|
|
|
26
40
|
/**
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
* @
|
|
41
|
+
* Creates a Cartesian2 instance from x and y coordinates.
|
|
42
|
+
*
|
|
43
|
+
* @param {number} x The x coordinate.
|
|
44
|
+
* @param {number} y The y coordinate.
|
|
45
|
+
* @param {Cartesian2} [result] The object onto which to store the result.
|
|
46
|
+
* @returns {Cartesian2} The modified result parameter or a new Cartesian2 instance if one was not provided.
|
|
30
47
|
*/
|
|
31
|
-
|
|
32
|
-
|
|
48
|
+
static fromElements(x, y, result) {
|
|
49
|
+
if (!defined(result)) {
|
|
50
|
+
return new Cartesian2(x, y);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
result.x = x;
|
|
54
|
+
result.y = y;
|
|
55
|
+
return result;
|
|
56
|
+
}
|
|
33
57
|
|
|
34
|
-
/**
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
58
|
+
/**
|
|
59
|
+
* Duplicates a Cartesian2 instance.
|
|
60
|
+
*
|
|
61
|
+
* @param {Cartesian2} cartesian The Cartesian to duplicate.
|
|
62
|
+
* @param {Cartesian2} [result] The object onto which to store the result.
|
|
63
|
+
* @returns {Cartesian2} The modified result parameter or a new Cartesian2 instance if one was not provided. (Returns undefined if cartesian is undefined)
|
|
64
|
+
*/
|
|
65
|
+
static clone(cartesian, result) {
|
|
66
|
+
if (!defined(cartesian)) {
|
|
67
|
+
return undefined;
|
|
68
|
+
}
|
|
69
|
+
if (!defined(result)) {
|
|
70
|
+
return new Cartesian2(cartesian.x, cartesian.y);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
result.x = cartesian.x;
|
|
74
|
+
result.y = cartesian.y;
|
|
75
|
+
return result;
|
|
45
76
|
}
|
|
46
77
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
78
|
+
/**
|
|
79
|
+
* Stores the provided instance into the provided array.
|
|
80
|
+
*
|
|
81
|
+
* @param {Cartesian2} value The value to pack.
|
|
82
|
+
* @param {number[]|TypedArray} array The array to pack into.
|
|
83
|
+
* @param {number} [startingIndex=0] The index into the array at which to start packing the elements.
|
|
84
|
+
*
|
|
85
|
+
* @returns {number[]|TypedArray} The array that was packed into
|
|
86
|
+
*/
|
|
87
|
+
static pack(value, array, startingIndex) {
|
|
88
|
+
//>>includeStart('debug', pragmas.debug);
|
|
89
|
+
Check.typeOf.object("value", value);
|
|
90
|
+
Check.defined("array", array);
|
|
91
|
+
//>>includeEnd('debug');
|
|
51
92
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
*/
|
|
59
|
-
Cartesian2.clone = function (cartesian, result) {
|
|
60
|
-
if (!defined(cartesian)) {
|
|
61
|
-
return undefined;
|
|
93
|
+
startingIndex = startingIndex ?? 0;
|
|
94
|
+
|
|
95
|
+
array[startingIndex++] = value.x;
|
|
96
|
+
array[startingIndex] = value.y;
|
|
97
|
+
|
|
98
|
+
return array;
|
|
62
99
|
}
|
|
63
|
-
|
|
64
|
-
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Retrieves an instance from a packed array.
|
|
103
|
+
*
|
|
104
|
+
* @param {number[]|TypedArray} array The packed array.
|
|
105
|
+
* @param {number} [startingIndex=0] The starting index of the element to be unpacked.
|
|
106
|
+
* @param {Cartesian2} [result] The object into which to store the result.
|
|
107
|
+
* @returns {Cartesian2} The modified result parameter or a new Cartesian2 instance if one was not provided.
|
|
108
|
+
*/
|
|
109
|
+
static unpack(array, startingIndex, result) {
|
|
110
|
+
//>>includeStart('debug', pragmas.debug);
|
|
111
|
+
Check.defined("array", array);
|
|
112
|
+
//>>includeEnd('debug');
|
|
113
|
+
|
|
114
|
+
startingIndex = startingIndex ?? 0;
|
|
115
|
+
|
|
116
|
+
if (!defined(result)) {
|
|
117
|
+
result = new Cartesian2();
|
|
118
|
+
}
|
|
119
|
+
result.x = array[startingIndex++];
|
|
120
|
+
result.y = array[startingIndex];
|
|
121
|
+
return result;
|
|
65
122
|
}
|
|
66
123
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
124
|
+
/**
|
|
125
|
+
* Flattens an array of Cartesian2s into an array of components.
|
|
126
|
+
*
|
|
127
|
+
* @param {Cartesian2[]} array The array of cartesians to pack.
|
|
128
|
+
* @param {number[]|TypedArray} [result] The array onto which to store the result. If this is a typed array, it must have array.length * 2 components, else a {@link DeveloperError} will be thrown. If it is a regular array, it will be resized to have (array.length * 2) elements.
|
|
129
|
+
* @returns {number[]|TypedArray} The packed array.
|
|
130
|
+
*/
|
|
131
|
+
static packArray(array, result) {
|
|
132
|
+
//>>includeStart('debug', pragmas.debug);
|
|
133
|
+
Check.defined("array", array);
|
|
134
|
+
//>>includeEnd('debug');
|
|
71
135
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
136
|
+
const length = array.length;
|
|
137
|
+
const resultLength = length * 2;
|
|
138
|
+
if (!defined(result)) {
|
|
139
|
+
result = new Array(resultLength);
|
|
140
|
+
} else if (!Array.isArray(result) && result.length !== resultLength) {
|
|
141
|
+
//>>includeStart('debug', pragmas.debug);
|
|
142
|
+
throw new DeveloperError(
|
|
143
|
+
"If result is a typed array, it must have exactly array.length * 2 elements",
|
|
144
|
+
);
|
|
145
|
+
//>>includeEnd('debug');
|
|
146
|
+
} else if (result.length !== resultLength) {
|
|
147
|
+
/** @type {number[]} */ (result).length = resultLength;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
for (let i = 0; i < length; ++i) {
|
|
151
|
+
Cartesian2.pack(array[i], result, i * 2);
|
|
152
|
+
}
|
|
153
|
+
return result;
|
|
154
|
+
}
|
|
82
155
|
|
|
83
|
-
/**
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
156
|
+
/**
|
|
157
|
+
* Unpacks an array of cartesian components into an array of Cartesian2s.
|
|
158
|
+
*
|
|
159
|
+
* @param {number[]} array The array of components to unpack.
|
|
160
|
+
* @param {Cartesian2[]} [result] The array onto which to store the result.
|
|
161
|
+
* @returns {Cartesian2[]} The unpacked array.
|
|
162
|
+
*/
|
|
163
|
+
static unpackArray(array, result) {
|
|
164
|
+
//>>includeStart('debug', pragmas.debug);
|
|
165
|
+
Check.defined("array", array);
|
|
166
|
+
Check.typeOf.number.greaterThanOrEquals("array.length", array.length, 2);
|
|
167
|
+
if (array.length % 2 !== 0) {
|
|
168
|
+
throw new DeveloperError("array length must be a multiple of 2.");
|
|
169
|
+
}
|
|
170
|
+
//>>includeEnd('debug');
|
|
93
171
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
172
|
+
const length = array.length;
|
|
173
|
+
if (!defined(result)) {
|
|
174
|
+
result = new Array(length / 2);
|
|
175
|
+
} else {
|
|
176
|
+
result.length = length / 2;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
for (let i = 0; i < length; i += 2) {
|
|
180
|
+
const index = i / 2;
|
|
181
|
+
result[index] = Cartesian2.unpack(array, i, result[index]);
|
|
182
|
+
}
|
|
183
|
+
return result;
|
|
184
|
+
}
|
|
99
185
|
|
|
100
|
-
/**
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
//>>includeStart('debug', pragmas.debug);
|
|
111
|
-
Check.typeOf.object("value", value);
|
|
112
|
-
Check.defined("array", array);
|
|
113
|
-
//>>includeEnd('debug');
|
|
186
|
+
/**
|
|
187
|
+
* Computes the value of the maximum component for the supplied Cartesian.
|
|
188
|
+
*
|
|
189
|
+
* @param {Cartesian2} cartesian The cartesian to use.
|
|
190
|
+
* @returns {number} The value of the maximum component.
|
|
191
|
+
*/
|
|
192
|
+
static maximumComponent(cartesian) {
|
|
193
|
+
//>>includeStart('debug', pragmas.debug);
|
|
194
|
+
Check.typeOf.object("cartesian", cartesian);
|
|
195
|
+
//>>includeEnd('debug');
|
|
114
196
|
|
|
115
|
-
|
|
197
|
+
return Math.max(cartesian.x, cartesian.y);
|
|
198
|
+
}
|
|
116
199
|
|
|
117
|
-
|
|
118
|
-
|
|
200
|
+
/**
|
|
201
|
+
* Computes the value of the minimum component for the supplied Cartesian.
|
|
202
|
+
*
|
|
203
|
+
* @param {Cartesian2} cartesian The cartesian to use.
|
|
204
|
+
* @returns {number} The value of the minimum component.
|
|
205
|
+
*/
|
|
206
|
+
static minimumComponent(cartesian) {
|
|
207
|
+
//>>includeStart('debug', pragmas.debug);
|
|
208
|
+
Check.typeOf.object("cartesian", cartesian);
|
|
209
|
+
//>>includeEnd('debug');
|
|
119
210
|
|
|
120
|
-
|
|
121
|
-
}
|
|
211
|
+
return Math.min(cartesian.x, cartesian.y);
|
|
212
|
+
}
|
|
122
213
|
|
|
123
|
-
/**
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
214
|
+
/**
|
|
215
|
+
* Compares two Cartesians and computes a Cartesian which contains the minimum components of the supplied Cartesians.
|
|
216
|
+
*
|
|
217
|
+
* @param {Cartesian2} first A cartesian to compare.
|
|
218
|
+
* @param {Cartesian2} second A cartesian to compare.
|
|
219
|
+
* @param {Cartesian2} result The object into which to store the result.
|
|
220
|
+
* @returns {Cartesian2} A cartesian with the minimum components.
|
|
221
|
+
*/
|
|
222
|
+
static minimumByComponent(first, second, result) {
|
|
223
|
+
//>>includeStart('debug', pragmas.debug);
|
|
224
|
+
Check.typeOf.object("first", first);
|
|
225
|
+
Check.typeOf.object("second", second);
|
|
226
|
+
Check.typeOf.object("result", result);
|
|
227
|
+
//>>includeEnd('debug');
|
|
135
228
|
|
|
136
|
-
|
|
229
|
+
result.x = Math.min(first.x, second.x);
|
|
230
|
+
result.y = Math.min(first.y, second.y);
|
|
137
231
|
|
|
138
|
-
|
|
139
|
-
result = new Cartesian2();
|
|
232
|
+
return result;
|
|
140
233
|
}
|
|
141
|
-
result.x = array[startingIndex++];
|
|
142
|
-
result.y = array[startingIndex];
|
|
143
|
-
return result;
|
|
144
|
-
};
|
|
145
234
|
|
|
146
|
-
/**
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
Check.defined("array", array);
|
|
156
|
-
//>>includeEnd('debug');
|
|
157
|
-
|
|
158
|
-
const length = array.length;
|
|
159
|
-
const resultLength = length * 2;
|
|
160
|
-
if (!defined(result)) {
|
|
161
|
-
result = new Array(resultLength);
|
|
162
|
-
} else if (!Array.isArray(result) && result.length !== resultLength) {
|
|
235
|
+
/**
|
|
236
|
+
* Compares two Cartesians and computes a Cartesian which contains the maximum components of the supplied Cartesians.
|
|
237
|
+
*
|
|
238
|
+
* @param {Cartesian2} first A cartesian to compare.
|
|
239
|
+
* @param {Cartesian2} second A cartesian to compare.
|
|
240
|
+
* @param {Cartesian2} result The object into which to store the result.
|
|
241
|
+
* @returns {Cartesian2} A cartesian with the maximum components.
|
|
242
|
+
*/
|
|
243
|
+
static maximumByComponent(first, second, result) {
|
|
163
244
|
//>>includeStart('debug', pragmas.debug);
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
);
|
|
245
|
+
Check.typeOf.object("first", first);
|
|
246
|
+
Check.typeOf.object("second", second);
|
|
247
|
+
Check.typeOf.object("result", result);
|
|
167
248
|
//>>includeEnd('debug');
|
|
168
|
-
|
|
169
|
-
result.
|
|
249
|
+
|
|
250
|
+
result.x = Math.max(first.x, second.x);
|
|
251
|
+
result.y = Math.max(first.y, second.y);
|
|
252
|
+
return result;
|
|
170
253
|
}
|
|
171
254
|
|
|
172
|
-
|
|
173
|
-
|
|
255
|
+
/**
|
|
256
|
+
* Constrain a value to lie between two values.
|
|
257
|
+
*
|
|
258
|
+
* @param {Cartesian2} value The value to clamp.
|
|
259
|
+
* @param {Cartesian2} min The minimum bound.
|
|
260
|
+
* @param {Cartesian2} max The maximum bound.
|
|
261
|
+
* @param {Cartesian2} result The object into which to store the result.
|
|
262
|
+
* @returns {Cartesian2} The clamped value such that min <= result <= max.
|
|
263
|
+
*/
|
|
264
|
+
static clamp(value, min, max, result) {
|
|
265
|
+
//>>includeStart('debug', pragmas.debug);
|
|
266
|
+
Check.typeOf.object("value", value);
|
|
267
|
+
Check.typeOf.object("min", min);
|
|
268
|
+
Check.typeOf.object("max", max);
|
|
269
|
+
Check.typeOf.object("result", result);
|
|
270
|
+
//>>includeEnd('debug');
|
|
271
|
+
|
|
272
|
+
const x = CesiumMath.clamp(value.x, min.x, max.x);
|
|
273
|
+
const y = CesiumMath.clamp(value.y, min.y, max.y);
|
|
274
|
+
|
|
275
|
+
result.x = x;
|
|
276
|
+
result.y = y;
|
|
277
|
+
|
|
278
|
+
return result;
|
|
174
279
|
}
|
|
175
|
-
return result;
|
|
176
|
-
};
|
|
177
280
|
|
|
178
|
-
/**
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
throw new DeveloperError("array length must be a multiple of 2.");
|
|
281
|
+
/**
|
|
282
|
+
* Computes the provided Cartesian's squared magnitude.
|
|
283
|
+
*
|
|
284
|
+
* @param {Cartesian2} cartesian The Cartesian instance whose squared magnitude is to be computed.
|
|
285
|
+
* @returns {number} The squared magnitude.
|
|
286
|
+
*/
|
|
287
|
+
static magnitudeSquared(cartesian) {
|
|
288
|
+
//>>includeStart('debug', pragmas.debug);
|
|
289
|
+
Check.typeOf.object("cartesian", cartesian);
|
|
290
|
+
//>>includeEnd('debug');
|
|
291
|
+
|
|
292
|
+
return cartesian.x * cartesian.x + cartesian.y * cartesian.y;
|
|
191
293
|
}
|
|
192
|
-
//>>includeEnd('debug');
|
|
193
294
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
295
|
+
/**
|
|
296
|
+
* Computes the Cartesian's magnitude (length).
|
|
297
|
+
*
|
|
298
|
+
* @param {Cartesian2} cartesian The Cartesian instance whose magnitude is to be computed.
|
|
299
|
+
* @returns {number} The magnitude.
|
|
300
|
+
*/
|
|
301
|
+
static magnitude(cartesian) {
|
|
302
|
+
return Math.sqrt(Cartesian2.magnitudeSquared(cartesian));
|
|
199
303
|
}
|
|
200
304
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
305
|
+
/**
|
|
306
|
+
* Computes the distance between two points.
|
|
307
|
+
*
|
|
308
|
+
* @param {Cartesian2} left The first point to compute the distance from.
|
|
309
|
+
* @param {Cartesian2} right The second point to compute the distance to.
|
|
310
|
+
* @returns {number} The distance between two points.
|
|
311
|
+
*
|
|
312
|
+
* @example
|
|
313
|
+
* // Returns 1.0
|
|
314
|
+
* const d = Cesium.Cartesian2.distance(new Cesium.Cartesian2(1.0, 0.0), new Cesium.Cartesian2(2.0, 0.0));
|
|
315
|
+
*/
|
|
316
|
+
static distance(left, right) {
|
|
317
|
+
//>>includeStart('debug', pragmas.debug);
|
|
318
|
+
Check.typeOf.object("left", left);
|
|
319
|
+
Check.typeOf.object("right", right);
|
|
320
|
+
//>>includeEnd('debug');
|
|
321
|
+
|
|
322
|
+
Cartesian2.subtract(left, right, distanceScratch);
|
|
323
|
+
return Cartesian2.magnitude(distanceScratch);
|
|
204
324
|
}
|
|
205
|
-
return result;
|
|
206
|
-
};
|
|
207
325
|
|
|
208
|
-
/**
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
*/
|
|
226
|
-
Cartesian2.fromArray = Cartesian2.unpack;
|
|
326
|
+
/**
|
|
327
|
+
* Computes the squared distance between two points. Comparing squared distances
|
|
328
|
+
* using this function is more efficient than comparing distances using {@link Cartesian2#distance}.
|
|
329
|
+
*
|
|
330
|
+
* @param {Cartesian2} left The first point to compute the distance from.
|
|
331
|
+
* @param {Cartesian2} right The second point to compute the distance to.
|
|
332
|
+
* @returns {number} The distance between two points.
|
|
333
|
+
*
|
|
334
|
+
* @example
|
|
335
|
+
* // Returns 4.0, not 2.0
|
|
336
|
+
* const d = Cesium.Cartesian2.distance(new Cesium.Cartesian2(1.0, 0.0), new Cesium.Cartesian2(3.0, 0.0));
|
|
337
|
+
*/
|
|
338
|
+
static distanceSquared(left, right) {
|
|
339
|
+
//>>includeStart('debug', pragmas.debug);
|
|
340
|
+
Check.typeOf.object("left", left);
|
|
341
|
+
Check.typeOf.object("right", right);
|
|
342
|
+
//>>includeEnd('debug');
|
|
227
343
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
* @param {Cartesian2} cartesian The cartesian to use.
|
|
232
|
-
* @returns {number} The value of the maximum component.
|
|
233
|
-
*/
|
|
234
|
-
Cartesian2.maximumComponent = function (cartesian) {
|
|
235
|
-
//>>includeStart('debug', pragmas.debug);
|
|
236
|
-
Check.typeOf.object("cartesian", cartesian);
|
|
237
|
-
//>>includeEnd('debug');
|
|
344
|
+
Cartesian2.subtract(left, right, distanceScratch);
|
|
345
|
+
return Cartesian2.magnitudeSquared(distanceScratch);
|
|
346
|
+
}
|
|
238
347
|
|
|
239
|
-
|
|
240
|
-
|
|
348
|
+
/**
|
|
349
|
+
* Computes the normalized form of the supplied Cartesian.
|
|
350
|
+
*
|
|
351
|
+
* @param {Cartesian2} cartesian The Cartesian to be normalized.
|
|
352
|
+
* @param {Cartesian2} result The object onto which to store the result.
|
|
353
|
+
* @returns {Cartesian2} The modified result parameter.
|
|
354
|
+
*/
|
|
355
|
+
static normalize(cartesian, result) {
|
|
356
|
+
//>>includeStart('debug', pragmas.debug);
|
|
357
|
+
Check.typeOf.object("cartesian", cartesian);
|
|
358
|
+
Check.typeOf.object("result", result);
|
|
359
|
+
//>>includeEnd('debug');
|
|
241
360
|
|
|
242
|
-
|
|
243
|
-
* Computes the value of the minimum component for the supplied Cartesian.
|
|
244
|
-
*
|
|
245
|
-
* @param {Cartesian2} cartesian The cartesian to use.
|
|
246
|
-
* @returns {number} The value of the minimum component.
|
|
247
|
-
*/
|
|
248
|
-
Cartesian2.minimumComponent = function (cartesian) {
|
|
249
|
-
//>>includeStart('debug', pragmas.debug);
|
|
250
|
-
Check.typeOf.object("cartesian", cartesian);
|
|
251
|
-
//>>includeEnd('debug');
|
|
361
|
+
const magnitude = Cartesian2.magnitude(cartesian);
|
|
252
362
|
|
|
253
|
-
|
|
254
|
-
|
|
363
|
+
result.x = cartesian.x / magnitude;
|
|
364
|
+
result.y = cartesian.y / magnitude;
|
|
255
365
|
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
* @param {Cartesian2} result The object into which to store the result.
|
|
262
|
-
* @returns {Cartesian2} A cartesian with the minimum components.
|
|
263
|
-
*/
|
|
264
|
-
Cartesian2.minimumByComponent = function (first, second, result) {
|
|
265
|
-
//>>includeStart('debug', pragmas.debug);
|
|
266
|
-
Check.typeOf.object("first", first);
|
|
267
|
-
Check.typeOf.object("second", second);
|
|
268
|
-
Check.typeOf.object("result", result);
|
|
269
|
-
//>>includeEnd('debug');
|
|
366
|
+
//>>includeStart('debug', pragmas.debug);
|
|
367
|
+
if (isNaN(result.x) || isNaN(result.y)) {
|
|
368
|
+
throw new DeveloperError("normalized result is not a number");
|
|
369
|
+
}
|
|
370
|
+
//>>includeEnd('debug');
|
|
270
371
|
|
|
271
|
-
|
|
272
|
-
|
|
372
|
+
return result;
|
|
373
|
+
}
|
|
273
374
|
|
|
274
|
-
|
|
275
|
-
|
|
375
|
+
/**
|
|
376
|
+
* Computes the dot (scalar) product of two Cartesians.
|
|
377
|
+
*
|
|
378
|
+
* @param {Cartesian2} left The first Cartesian.
|
|
379
|
+
* @param {Cartesian2} right The second Cartesian.
|
|
380
|
+
* @returns {number} The dot product.
|
|
381
|
+
*/
|
|
382
|
+
static dot(left, right) {
|
|
383
|
+
//>>includeStart('debug', pragmas.debug);
|
|
384
|
+
Check.typeOf.object("left", left);
|
|
385
|
+
Check.typeOf.object("right", right);
|
|
386
|
+
//>>includeEnd('debug');
|
|
276
387
|
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
*
|
|
280
|
-
* @param {Cartesian2} first A cartesian to compare.
|
|
281
|
-
* @param {Cartesian2} second A cartesian to compare.
|
|
282
|
-
* @param {Cartesian2} result The object into which to store the result.
|
|
283
|
-
* @returns {Cartesian2} A cartesian with the maximum components.
|
|
284
|
-
*/
|
|
285
|
-
Cartesian2.maximumByComponent = function (first, second, result) {
|
|
286
|
-
//>>includeStart('debug', pragmas.debug);
|
|
287
|
-
Check.typeOf.object("first", first);
|
|
288
|
-
Check.typeOf.object("second", second);
|
|
289
|
-
Check.typeOf.object("result", result);
|
|
290
|
-
//>>includeEnd('debug');
|
|
291
|
-
|
|
292
|
-
result.x = Math.max(first.x, second.x);
|
|
293
|
-
result.y = Math.max(first.y, second.y);
|
|
294
|
-
return result;
|
|
295
|
-
};
|
|
388
|
+
return left.x * right.x + left.y * right.y;
|
|
389
|
+
}
|
|
296
390
|
|
|
297
|
-
/**
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
Check.typeOf.object("min", min);
|
|
310
|
-
Check.typeOf.object("max", max);
|
|
311
|
-
Check.typeOf.object("result", result);
|
|
312
|
-
//>>includeEnd('debug');
|
|
391
|
+
/**
|
|
392
|
+
* Computes the magnitude of the cross product that would result from implicitly setting the Z coordinate of the input vectors to 0
|
|
393
|
+
*
|
|
394
|
+
* @param {Cartesian2} left The first Cartesian.
|
|
395
|
+
* @param {Cartesian2} right The second Cartesian.
|
|
396
|
+
* @returns {number} The cross product.
|
|
397
|
+
*/
|
|
398
|
+
static cross(left, right) {
|
|
399
|
+
//>>includeStart('debug', pragmas.debug);
|
|
400
|
+
Check.typeOf.object("left", left);
|
|
401
|
+
Check.typeOf.object("right", right);
|
|
402
|
+
//>>includeEnd('debug');
|
|
313
403
|
|
|
314
|
-
|
|
315
|
-
|
|
404
|
+
return left.x * right.y - left.y * right.x;
|
|
405
|
+
}
|
|
316
406
|
|
|
317
|
-
|
|
318
|
-
|
|
407
|
+
/**
|
|
408
|
+
* Computes the componentwise product of two Cartesians.
|
|
409
|
+
*
|
|
410
|
+
* @param {Cartesian2} left The first Cartesian.
|
|
411
|
+
* @param {Cartesian2} right The second Cartesian.
|
|
412
|
+
* @param {Cartesian2} result The object onto which to store the result.
|
|
413
|
+
* @returns {Cartesian2} The modified result parameter.
|
|
414
|
+
*/
|
|
415
|
+
static multiplyComponents(left, right, result) {
|
|
416
|
+
//>>includeStart('debug', pragmas.debug);
|
|
417
|
+
Check.typeOf.object("left", left);
|
|
418
|
+
Check.typeOf.object("right", right);
|
|
419
|
+
Check.typeOf.object("result", result);
|
|
420
|
+
//>>includeEnd('debug');
|
|
319
421
|
|
|
320
|
-
|
|
321
|
-
|
|
422
|
+
result.x = left.x * right.x;
|
|
423
|
+
result.y = left.y * right.y;
|
|
424
|
+
return result;
|
|
425
|
+
}
|
|
322
426
|
|
|
323
|
-
/**
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
Cartesian2
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
427
|
+
/**
|
|
428
|
+
* Computes the componentwise quotient of two Cartesians.
|
|
429
|
+
*
|
|
430
|
+
* @param {Cartesian2} left The first Cartesian.
|
|
431
|
+
* @param {Cartesian2} right The second Cartesian.
|
|
432
|
+
* @param {Cartesian2} result The object onto which to store the result.
|
|
433
|
+
* @returns {Cartesian2} The modified result parameter.
|
|
434
|
+
*/
|
|
435
|
+
static divideComponents(left, right, result) {
|
|
436
|
+
//>>includeStart('debug', pragmas.debug);
|
|
437
|
+
Check.typeOf.object("left", left);
|
|
438
|
+
Check.typeOf.object("right", right);
|
|
439
|
+
Check.typeOf.object("result", result);
|
|
440
|
+
//>>includeEnd('debug');
|
|
333
441
|
|
|
334
|
-
|
|
335
|
-
|
|
442
|
+
result.x = left.x / right.x;
|
|
443
|
+
result.y = left.y / right.y;
|
|
444
|
+
return result;
|
|
445
|
+
}
|
|
336
446
|
|
|
337
|
-
/**
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
Cartesian2
|
|
344
|
-
|
|
345
|
-
|
|
447
|
+
/**
|
|
448
|
+
* Computes the componentwise sum of two Cartesians.
|
|
449
|
+
*
|
|
450
|
+
* @param {Cartesian2} left The first Cartesian.
|
|
451
|
+
* @param {Cartesian2} right The second Cartesian.
|
|
452
|
+
* @param {Cartesian2} result The object onto which to store the result.
|
|
453
|
+
* @returns {Cartesian2} The modified result parameter.
|
|
454
|
+
*/
|
|
455
|
+
static add(left, right, result) {
|
|
456
|
+
//>>includeStart('debug', pragmas.debug);
|
|
457
|
+
Check.typeOf.object("left", left);
|
|
458
|
+
Check.typeOf.object("right", right);
|
|
459
|
+
Check.typeOf.object("result", result);
|
|
460
|
+
//>>includeEnd('debug');
|
|
346
461
|
|
|
347
|
-
|
|
462
|
+
result.x = left.x + right.x;
|
|
463
|
+
result.y = left.y + right.y;
|
|
464
|
+
return result;
|
|
465
|
+
}
|
|
348
466
|
|
|
349
|
-
/**
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
Check.typeOf.object("right", right);
|
|
364
|
-
//>>includeEnd('debug');
|
|
467
|
+
/**
|
|
468
|
+
* Computes the componentwise difference of two Cartesians.
|
|
469
|
+
*
|
|
470
|
+
* @param {Cartesian2} left The first Cartesian.
|
|
471
|
+
* @param {Cartesian2} right The second Cartesian.
|
|
472
|
+
* @param {Cartesian2} result The object onto which to store the result.
|
|
473
|
+
* @returns {Cartesian2} The modified result parameter.
|
|
474
|
+
*/
|
|
475
|
+
static subtract(left, right, result) {
|
|
476
|
+
//>>includeStart('debug', pragmas.debug);
|
|
477
|
+
Check.typeOf.object("left", left);
|
|
478
|
+
Check.typeOf.object("right", right);
|
|
479
|
+
Check.typeOf.object("result", result);
|
|
480
|
+
//>>includeEnd('debug');
|
|
365
481
|
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
482
|
+
result.x = left.x - right.x;
|
|
483
|
+
result.y = left.y - right.y;
|
|
484
|
+
return result;
|
|
485
|
+
}
|
|
369
486
|
|
|
370
|
-
/**
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
Check.typeOf.object("left", left);
|
|
385
|
-
Check.typeOf.object("right", right);
|
|
386
|
-
//>>includeEnd('debug');
|
|
487
|
+
/**
|
|
488
|
+
* Multiplies the provided Cartesian componentwise by the provided scalar.
|
|
489
|
+
*
|
|
490
|
+
* @param {Cartesian2} cartesian The Cartesian to be scaled.
|
|
491
|
+
* @param {number} scalar The scalar to multiply with.
|
|
492
|
+
* @param {Cartesian2} result The object onto which to store the result.
|
|
493
|
+
* @returns {Cartesian2} The modified result parameter.
|
|
494
|
+
*/
|
|
495
|
+
static multiplyByScalar(cartesian, scalar, result) {
|
|
496
|
+
//>>includeStart('debug', pragmas.debug);
|
|
497
|
+
Check.typeOf.object("cartesian", cartesian);
|
|
498
|
+
Check.typeOf.number("scalar", scalar);
|
|
499
|
+
Check.typeOf.object("result", result);
|
|
500
|
+
//>>includeEnd('debug');
|
|
387
501
|
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
502
|
+
result.x = cartesian.x * scalar;
|
|
503
|
+
result.y = cartesian.y * scalar;
|
|
504
|
+
return result;
|
|
505
|
+
}
|
|
391
506
|
|
|
392
|
-
/**
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
507
|
+
/**
|
|
508
|
+
* Divides the provided Cartesian componentwise by the provided scalar.
|
|
509
|
+
*
|
|
510
|
+
* @param {Cartesian2} cartesian The Cartesian to be divided.
|
|
511
|
+
* @param {number} scalar The scalar to divide by.
|
|
512
|
+
* @param {Cartesian2} result The object onto which to store the result.
|
|
513
|
+
* @returns {Cartesian2} The modified result parameter.
|
|
514
|
+
*/
|
|
515
|
+
static divideByScalar(cartesian, scalar, result) {
|
|
516
|
+
//>>includeStart('debug', pragmas.debug);
|
|
517
|
+
Check.typeOf.object("cartesian", cartesian);
|
|
518
|
+
Check.typeOf.number("scalar", scalar);
|
|
519
|
+
Check.typeOf.object("result", result);
|
|
520
|
+
//>>includeEnd('debug');
|
|
404
521
|
|
|
405
|
-
|
|
522
|
+
result.x = cartesian.x / scalar;
|
|
523
|
+
result.y = cartesian.y / scalar;
|
|
524
|
+
return result;
|
|
525
|
+
}
|
|
406
526
|
|
|
407
|
-
|
|
408
|
-
|
|
527
|
+
/**
|
|
528
|
+
* Negates the provided Cartesian.
|
|
529
|
+
*
|
|
530
|
+
* @param {Cartesian2} cartesian The Cartesian to be negated.
|
|
531
|
+
* @param {Cartesian2} result The object onto which to store the result.
|
|
532
|
+
* @returns {Cartesian2} The modified result parameter.
|
|
533
|
+
*/
|
|
534
|
+
static negate(cartesian, result) {
|
|
535
|
+
//>>includeStart('debug', pragmas.debug);
|
|
536
|
+
Check.typeOf.object("cartesian", cartesian);
|
|
537
|
+
Check.typeOf.object("result", result);
|
|
538
|
+
//>>includeEnd('debug');
|
|
409
539
|
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
540
|
+
result.x = -cartesian.x;
|
|
541
|
+
result.y = -cartesian.y;
|
|
542
|
+
return result;
|
|
413
543
|
}
|
|
414
|
-
//>>includeEnd('debug');
|
|
415
544
|
|
|
416
|
-
|
|
417
|
-
|
|
545
|
+
/**
|
|
546
|
+
* Computes the absolute value of the provided Cartesian.
|
|
547
|
+
*
|
|
548
|
+
* @param {Cartesian2} cartesian The Cartesian whose absolute value is to be computed.
|
|
549
|
+
* @param {Cartesian2} result The object onto which to store the result.
|
|
550
|
+
* @returns {Cartesian2} The modified result parameter.
|
|
551
|
+
*/
|
|
552
|
+
static abs(cartesian, result) {
|
|
553
|
+
//>>includeStart('debug', pragmas.debug);
|
|
554
|
+
Check.typeOf.object("cartesian", cartesian);
|
|
555
|
+
Check.typeOf.object("result", result);
|
|
556
|
+
//>>includeEnd('debug');
|
|
418
557
|
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
* @param {Cartesian2} right The second Cartesian.
|
|
424
|
-
* @returns {number} The dot product.
|
|
425
|
-
*/
|
|
426
|
-
Cartesian2.dot = function (left, right) {
|
|
427
|
-
//>>includeStart('debug', pragmas.debug);
|
|
428
|
-
Check.typeOf.object("left", left);
|
|
429
|
-
Check.typeOf.object("right", right);
|
|
430
|
-
//>>includeEnd('debug');
|
|
558
|
+
result.x = Math.abs(cartesian.x);
|
|
559
|
+
result.y = Math.abs(cartesian.y);
|
|
560
|
+
return result;
|
|
561
|
+
}
|
|
431
562
|
|
|
432
|
-
|
|
433
|
-
|
|
563
|
+
/**
|
|
564
|
+
* Computes the linear interpolation or extrapolation at t using the provided cartesians.
|
|
565
|
+
*
|
|
566
|
+
* @param {Cartesian2} start The value corresponding to t at 0.0.
|
|
567
|
+
* @param {Cartesian2} end The value corresponding to t at 1.0.
|
|
568
|
+
* @param {number} t The point along t at which to interpolate.
|
|
569
|
+
* @param {Cartesian2} result The object onto which to store the result.
|
|
570
|
+
* @returns {Cartesian2} The modified result parameter.
|
|
571
|
+
*/
|
|
572
|
+
static lerp(start, end, t, result) {
|
|
573
|
+
//>>includeStart('debug', pragmas.debug);
|
|
574
|
+
Check.typeOf.object("start", start);
|
|
575
|
+
Check.typeOf.object("end", end);
|
|
576
|
+
Check.typeOf.number("t", t);
|
|
577
|
+
Check.typeOf.object("result", result);
|
|
578
|
+
//>>includeEnd('debug');
|
|
434
579
|
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
* @param {Cartesian2} right The second Cartesian.
|
|
440
|
-
* @returns {number} The cross product.
|
|
441
|
-
*/
|
|
442
|
-
Cartesian2.cross = function (left, right) {
|
|
443
|
-
//>>includeStart('debug', pragmas.debug);
|
|
444
|
-
Check.typeOf.object("left", left);
|
|
445
|
-
Check.typeOf.object("right", right);
|
|
446
|
-
//>>includeEnd('debug');
|
|
580
|
+
Cartesian2.multiplyByScalar(end, t, lerpScratch);
|
|
581
|
+
result = Cartesian2.multiplyByScalar(start, 1.0 - t, result);
|
|
582
|
+
return Cartesian2.add(lerpScratch, result, result);
|
|
583
|
+
}
|
|
447
584
|
|
|
448
|
-
|
|
449
|
-
|
|
585
|
+
/**
|
|
586
|
+
* Returns the angle, in radians, between the provided Cartesians.
|
|
587
|
+
*
|
|
588
|
+
* @param {Cartesian2} left The first Cartesian.
|
|
589
|
+
* @param {Cartesian2} right The second Cartesian.
|
|
590
|
+
* @returns {number} The angle between the Cartesians.
|
|
591
|
+
*/
|
|
592
|
+
static angleBetween(left, right) {
|
|
593
|
+
//>>includeStart('debug', pragmas.debug);
|
|
594
|
+
Check.typeOf.object("left", left);
|
|
595
|
+
Check.typeOf.object("right", right);
|
|
596
|
+
//>>includeEnd('debug');
|
|
450
597
|
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
* @returns {Cartesian2} The modified result parameter.
|
|
458
|
-
*/
|
|
459
|
-
Cartesian2.multiplyComponents = function (left, right, result) {
|
|
460
|
-
//>>includeStart('debug', pragmas.debug);
|
|
461
|
-
Check.typeOf.object("left", left);
|
|
462
|
-
Check.typeOf.object("right", right);
|
|
463
|
-
Check.typeOf.object("result", result);
|
|
464
|
-
//>>includeEnd('debug');
|
|
465
|
-
|
|
466
|
-
result.x = left.x * right.x;
|
|
467
|
-
result.y = left.y * right.y;
|
|
468
|
-
return result;
|
|
469
|
-
};
|
|
598
|
+
Cartesian2.normalize(left, angleBetweenScratch);
|
|
599
|
+
Cartesian2.normalize(right, angleBetweenScratch2);
|
|
600
|
+
return CesiumMath.acosClamped(
|
|
601
|
+
Cartesian2.dot(angleBetweenScratch, angleBetweenScratch2),
|
|
602
|
+
);
|
|
603
|
+
}
|
|
470
604
|
|
|
471
|
-
/**
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
Check.typeOf.object("result", result);
|
|
484
|
-
//>>includeEnd('debug');
|
|
485
|
-
|
|
486
|
-
result.x = left.x / right.x;
|
|
487
|
-
result.y = left.y / right.y;
|
|
488
|
-
return result;
|
|
489
|
-
};
|
|
605
|
+
/**
|
|
606
|
+
* Returns the axis that is most orthogonal to the provided Cartesian.
|
|
607
|
+
*
|
|
608
|
+
* @param {Cartesian2} cartesian The Cartesian on which to find the most orthogonal axis.
|
|
609
|
+
* @param {Cartesian2} result The object onto which to store the result.
|
|
610
|
+
* @returns {Cartesian2} The most orthogonal axis.
|
|
611
|
+
*/
|
|
612
|
+
static mostOrthogonalAxis(cartesian, result) {
|
|
613
|
+
//>>includeStart('debug', pragmas.debug);
|
|
614
|
+
Check.typeOf.object("cartesian", cartesian);
|
|
615
|
+
Check.typeOf.object("result", result);
|
|
616
|
+
//>>includeEnd('debug');
|
|
490
617
|
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
*
|
|
494
|
-
* @param {Cartesian2} left The first Cartesian.
|
|
495
|
-
* @param {Cartesian2} right The second Cartesian.
|
|
496
|
-
* @param {Cartesian2} result The object onto which to store the result.
|
|
497
|
-
* @returns {Cartesian2} The modified result parameter.
|
|
498
|
-
*/
|
|
499
|
-
Cartesian2.add = function (left, right, result) {
|
|
500
|
-
//>>includeStart('debug', pragmas.debug);
|
|
501
|
-
Check.typeOf.object("left", left);
|
|
502
|
-
Check.typeOf.object("right", right);
|
|
503
|
-
Check.typeOf.object("result", result);
|
|
504
|
-
//>>includeEnd('debug');
|
|
505
|
-
|
|
506
|
-
result.x = left.x + right.x;
|
|
507
|
-
result.y = left.y + right.y;
|
|
508
|
-
return result;
|
|
509
|
-
};
|
|
618
|
+
const f = Cartesian2.normalize(cartesian, mostOrthogonalAxisScratch);
|
|
619
|
+
Cartesian2.abs(f, f);
|
|
510
620
|
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
* @param {Cartesian2} result The object onto which to store the result.
|
|
517
|
-
* @returns {Cartesian2} The modified result parameter.
|
|
518
|
-
*/
|
|
519
|
-
Cartesian2.subtract = function (left, right, result) {
|
|
520
|
-
//>>includeStart('debug', pragmas.debug);
|
|
521
|
-
Check.typeOf.object("left", left);
|
|
522
|
-
Check.typeOf.object("right", right);
|
|
523
|
-
Check.typeOf.object("result", result);
|
|
524
|
-
//>>includeEnd('debug');
|
|
525
|
-
|
|
526
|
-
result.x = left.x - right.x;
|
|
527
|
-
result.y = left.y - right.y;
|
|
528
|
-
return result;
|
|
529
|
-
};
|
|
621
|
+
if (f.x <= f.y) {
|
|
622
|
+
result = Cartesian2.clone(Cartesian2.UNIT_X, result);
|
|
623
|
+
} else {
|
|
624
|
+
result = Cartesian2.clone(Cartesian2.UNIT_Y, result);
|
|
625
|
+
}
|
|
530
626
|
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
*
|
|
534
|
-
* @param {Cartesian2} cartesian The Cartesian to be scaled.
|
|
535
|
-
* @param {number} scalar The scalar to multiply with.
|
|
536
|
-
* @param {Cartesian2} result The object onto which to store the result.
|
|
537
|
-
* @returns {Cartesian2} The modified result parameter.
|
|
538
|
-
*/
|
|
539
|
-
Cartesian2.multiplyByScalar = function (cartesian, scalar, result) {
|
|
540
|
-
//>>includeStart('debug', pragmas.debug);
|
|
541
|
-
Check.typeOf.object("cartesian", cartesian);
|
|
542
|
-
Check.typeOf.number("scalar", scalar);
|
|
543
|
-
Check.typeOf.object("result", result);
|
|
544
|
-
//>>includeEnd('debug');
|
|
545
|
-
|
|
546
|
-
result.x = cartesian.x * scalar;
|
|
547
|
-
result.y = cartesian.y * scalar;
|
|
548
|
-
return result;
|
|
549
|
-
};
|
|
627
|
+
return result;
|
|
628
|
+
}
|
|
550
629
|
|
|
551
|
-
/**
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
return result;
|
|
569
|
-
};
|
|
630
|
+
/**
|
|
631
|
+
* Compares the provided Cartesians componentwise and returns
|
|
632
|
+
* <code>true</code> if they are equal, <code>false</code> otherwise.
|
|
633
|
+
*
|
|
634
|
+
* @param {Cartesian2} [left] The first Cartesian.
|
|
635
|
+
* @param {Cartesian2} [right] The second Cartesian.
|
|
636
|
+
* @returns {boolean} <code>true</code> if left and right are equal, <code>false</code> otherwise.
|
|
637
|
+
*/
|
|
638
|
+
static equals(left, right) {
|
|
639
|
+
return (
|
|
640
|
+
left === right ||
|
|
641
|
+
(defined(left) &&
|
|
642
|
+
defined(right) &&
|
|
643
|
+
left.x === right.x &&
|
|
644
|
+
left.y === right.y)
|
|
645
|
+
);
|
|
646
|
+
}
|
|
570
647
|
|
|
571
|
-
/**
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
Check.typeOf.object("cartesian", cartesian);
|
|
581
|
-
Check.typeOf.object("result", result);
|
|
582
|
-
//>>includeEnd('debug');
|
|
648
|
+
/**
|
|
649
|
+
* @param {Cartesian2} cartesian
|
|
650
|
+
* @param {number[]} array
|
|
651
|
+
* @param {number} offset
|
|
652
|
+
* @private
|
|
653
|
+
*/
|
|
654
|
+
static equalsArray(cartesian, array, offset) {
|
|
655
|
+
return cartesian.x === array[offset] && cartesian.y === array[offset + 1];
|
|
656
|
+
}
|
|
583
657
|
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
658
|
+
/**
|
|
659
|
+
* Compares the provided Cartesians componentwise and returns
|
|
660
|
+
* <code>true</code> if they pass an absolute or relative tolerance test,
|
|
661
|
+
* <code>false</code> otherwise.
|
|
662
|
+
*
|
|
663
|
+
* @param {Cartesian2} [left] The first Cartesian.
|
|
664
|
+
* @param {Cartesian2} [right] The second Cartesian.
|
|
665
|
+
* @param {number} [relativeEpsilon=0] The relative epsilon tolerance to use for equality testing.
|
|
666
|
+
* @param {number} [absoluteEpsilon=relativeEpsilon] The absolute epsilon tolerance to use for equality testing.
|
|
667
|
+
* @returns {boolean} <code>true</code> if left and right are within the provided epsilon, <code>false</code> otherwise.
|
|
668
|
+
*/
|
|
669
|
+
static equalsEpsilon(left, right, relativeEpsilon, absoluteEpsilon) {
|
|
670
|
+
return (
|
|
671
|
+
left === right ||
|
|
672
|
+
(defined(left) &&
|
|
673
|
+
defined(right) &&
|
|
674
|
+
CesiumMath.equalsEpsilon(
|
|
675
|
+
left.x,
|
|
676
|
+
right.x,
|
|
677
|
+
relativeEpsilon,
|
|
678
|
+
absoluteEpsilon,
|
|
679
|
+
) &&
|
|
680
|
+
CesiumMath.equalsEpsilon(
|
|
681
|
+
left.y,
|
|
682
|
+
right.y,
|
|
683
|
+
relativeEpsilon,
|
|
684
|
+
absoluteEpsilon,
|
|
685
|
+
))
|
|
686
|
+
);
|
|
687
|
+
}
|
|
588
688
|
|
|
589
|
-
/**
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
Cartesian2.
|
|
597
|
-
|
|
598
|
-
Check.typeOf.object("cartesian", cartesian);
|
|
599
|
-
Check.typeOf.object("result", result);
|
|
600
|
-
//>>includeEnd('debug');
|
|
689
|
+
/**
|
|
690
|
+
* Duplicates this Cartesian2 instance.
|
|
691
|
+
*
|
|
692
|
+
* @param {Cartesian2} [result] The object onto which to store the result.
|
|
693
|
+
* @returns {Cartesian2} The modified result parameter or a new Cartesian2 instance if one was not provided.
|
|
694
|
+
*/
|
|
695
|
+
clone(result) {
|
|
696
|
+
return Cartesian2.clone(this, result);
|
|
697
|
+
}
|
|
601
698
|
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
699
|
+
/**
|
|
700
|
+
* Compares this Cartesian against the provided Cartesian componentwise and returns
|
|
701
|
+
* <code>true</code> if they are equal, <code>false</code> otherwise.
|
|
702
|
+
*
|
|
703
|
+
* @param {Cartesian2} [right] The right hand side Cartesian.
|
|
704
|
+
* @returns {boolean} <code>true</code> if they are equal, <code>false</code> otherwise.
|
|
705
|
+
*/
|
|
706
|
+
equals(right) {
|
|
707
|
+
return Cartesian2.equals(this, right);
|
|
708
|
+
}
|
|
606
709
|
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
Cartesian2.multiplyByScalar(end, t, lerpScratch);
|
|
626
|
-
result = Cartesian2.multiplyByScalar(start, 1.0 - t, result);
|
|
627
|
-
return Cartesian2.add(lerpScratch, result, result);
|
|
628
|
-
};
|
|
710
|
+
/**
|
|
711
|
+
* Compares this Cartesian against the provided Cartesian componentwise and returns
|
|
712
|
+
* <code>true</code> if they pass an absolute or relative tolerance test,
|
|
713
|
+
* <code>false</code> otherwise.
|
|
714
|
+
*
|
|
715
|
+
* @param {Cartesian2} [right] The right hand side Cartesian.
|
|
716
|
+
* @param {number} [relativeEpsilon=0] The relative epsilon tolerance to use for equality testing.
|
|
717
|
+
* @param {number} [absoluteEpsilon=relativeEpsilon] The absolute epsilon tolerance to use for equality testing.
|
|
718
|
+
* @returns {boolean} <code>true</code> if they are within the provided epsilon, <code>false</code> otherwise.
|
|
719
|
+
*/
|
|
720
|
+
equalsEpsilon(right, relativeEpsilon, absoluteEpsilon) {
|
|
721
|
+
return Cartesian2.equalsEpsilon(
|
|
722
|
+
this,
|
|
723
|
+
right,
|
|
724
|
+
relativeEpsilon,
|
|
725
|
+
absoluteEpsilon,
|
|
726
|
+
);
|
|
727
|
+
}
|
|
629
728
|
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
Cartesian2.angleBetween = function (left, right) {
|
|
640
|
-
//>>includeStart('debug', pragmas.debug);
|
|
641
|
-
Check.typeOf.object("left", left);
|
|
642
|
-
Check.typeOf.object("right", right);
|
|
643
|
-
//>>includeEnd('debug');
|
|
644
|
-
|
|
645
|
-
Cartesian2.normalize(left, angleBetweenScratch);
|
|
646
|
-
Cartesian2.normalize(right, angleBetweenScratch2);
|
|
647
|
-
return CesiumMath.acosClamped(
|
|
648
|
-
Cartesian2.dot(angleBetweenScratch, angleBetweenScratch2),
|
|
649
|
-
);
|
|
650
|
-
};
|
|
729
|
+
/**
|
|
730
|
+
* Creates a string representing this Cartesian in the format '(x, y)'.
|
|
731
|
+
*
|
|
732
|
+
* @returns {string} A string representing the provided Cartesian in the format '(x, y)'.
|
|
733
|
+
*/
|
|
734
|
+
toString() {
|
|
735
|
+
return `(${this.x}, ${this.y})`;
|
|
736
|
+
}
|
|
737
|
+
}
|
|
651
738
|
|
|
652
|
-
const mostOrthogonalAxisScratch = new Cartesian2();
|
|
653
739
|
/**
|
|
654
|
-
*
|
|
740
|
+
* Creates a Cartesian2 instance from an existing Cartesian3. This simply takes the
|
|
741
|
+
* x and y properties of the Cartesian3 and drops z.
|
|
742
|
+
* @function
|
|
655
743
|
*
|
|
656
|
-
* @param {
|
|
657
|
-
* @param {Cartesian2} result The object onto which to store the result.
|
|
658
|
-
* @returns {Cartesian2} The
|
|
744
|
+
* @param {Cartesian3} cartesian The Cartesian3 instance to create a Cartesian2 instance from.
|
|
745
|
+
* @param {Cartesian2} [result] The object onto which to store the result.
|
|
746
|
+
* @returns {Cartesian2} The modified result parameter or a new Cartesian2 instance if one was not provided.
|
|
659
747
|
*/
|
|
660
|
-
Cartesian2.
|
|
661
|
-
//>>includeStart('debug', pragmas.debug);
|
|
662
|
-
Check.typeOf.object("cartesian", cartesian);
|
|
663
|
-
Check.typeOf.object("result", result);
|
|
664
|
-
//>>includeEnd('debug');
|
|
665
|
-
|
|
666
|
-
const f = Cartesian2.normalize(cartesian, mostOrthogonalAxisScratch);
|
|
667
|
-
Cartesian2.abs(f, f);
|
|
668
|
-
|
|
669
|
-
if (f.x <= f.y) {
|
|
670
|
-
result = Cartesian2.clone(Cartesian2.UNIT_X, result);
|
|
671
|
-
} else {
|
|
672
|
-
result = Cartesian2.clone(Cartesian2.UNIT_Y, result);
|
|
673
|
-
}
|
|
674
|
-
|
|
675
|
-
return result;
|
|
676
|
-
};
|
|
748
|
+
Cartesian2.fromCartesian3 = Cartesian2.clone;
|
|
677
749
|
|
|
678
750
|
/**
|
|
679
|
-
*
|
|
680
|
-
*
|
|
751
|
+
* Creates a Cartesian2 instance from an existing Cartesian4. This simply takes the
|
|
752
|
+
* x and y properties of the Cartesian4 and drops z and w.
|
|
753
|
+
* @function
|
|
681
754
|
*
|
|
682
|
-
* @param {
|
|
683
|
-
* @param {Cartesian2} [
|
|
684
|
-
* @returns {
|
|
755
|
+
* @param {Cartesian4} cartesian The Cartesian4 instance to create a Cartesian2 instance from.
|
|
756
|
+
* @param {Cartesian2} [result] The object onto which to store the result.
|
|
757
|
+
* @returns {Cartesian2} The modified result parameter or a new Cartesian2 instance if one was not provided.
|
|
685
758
|
*/
|
|
686
|
-
Cartesian2.
|
|
687
|
-
return (
|
|
688
|
-
left === right ||
|
|
689
|
-
(defined(left) &&
|
|
690
|
-
defined(right) &&
|
|
691
|
-
left.x === right.x &&
|
|
692
|
-
left.y === right.y)
|
|
693
|
-
);
|
|
694
|
-
};
|
|
759
|
+
Cartesian2.fromCartesian4 = Cartesian2.clone;
|
|
695
760
|
|
|
696
761
|
/**
|
|
697
|
-
*
|
|
762
|
+
* The number of elements used to pack the object into an array.
|
|
763
|
+
* @type {number}
|
|
698
764
|
*/
|
|
699
|
-
Cartesian2.
|
|
700
|
-
return cartesian.x === array[offset] && cartesian.y === array[offset + 1];
|
|
701
|
-
};
|
|
765
|
+
Cartesian2.packedLength = 2;
|
|
702
766
|
|
|
703
767
|
/**
|
|
704
|
-
*
|
|
705
|
-
*
|
|
706
|
-
* <code>false</code> otherwise.
|
|
768
|
+
* Creates a Cartesian2 from two consecutive elements in an array.
|
|
769
|
+
* @function
|
|
707
770
|
*
|
|
708
|
-
* @param {
|
|
709
|
-
* @param {
|
|
710
|
-
* @param {
|
|
711
|
-
* @
|
|
712
|
-
*
|
|
771
|
+
* @param {number[]} array The array whose two consecutive elements correspond to the x and y components, respectively.
|
|
772
|
+
* @param {number} [startingIndex=0] The offset into the array of the first element, which corresponds to the x component.
|
|
773
|
+
* @param {Cartesian2} [result] The object onto which to store the result.
|
|
774
|
+
* @returns {Cartesian2} The modified result parameter or a new Cartesian2 instance if one was not provided.
|
|
775
|
+
*
|
|
776
|
+
* @example
|
|
777
|
+
* // Create a Cartesian2 with (1.0, 2.0)
|
|
778
|
+
* const v = [1.0, 2.0];
|
|
779
|
+
* const p = Cesium.Cartesian2.fromArray(v);
|
|
780
|
+
*
|
|
781
|
+
* // Create a Cartesian2 with (1.0, 2.0) using an offset into an array
|
|
782
|
+
* const v2 = [0.0, 0.0, 1.0, 2.0];
|
|
783
|
+
* const p2 = Cesium.Cartesian2.fromArray(v2, 2);
|
|
713
784
|
*/
|
|
714
|
-
Cartesian2.
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
CesiumMath.equalsEpsilon(
|
|
725
|
-
left.x,
|
|
726
|
-
right.x,
|
|
727
|
-
relativeEpsilon,
|
|
728
|
-
absoluteEpsilon,
|
|
729
|
-
) &&
|
|
730
|
-
CesiumMath.equalsEpsilon(
|
|
731
|
-
left.y,
|
|
732
|
-
right.y,
|
|
733
|
-
relativeEpsilon,
|
|
734
|
-
absoluteEpsilon,
|
|
735
|
-
))
|
|
736
|
-
);
|
|
737
|
-
};
|
|
785
|
+
Cartesian2.fromArray = Cartesian2.unpack;
|
|
786
|
+
|
|
787
|
+
const distanceScratch = new Cartesian2();
|
|
788
|
+
|
|
789
|
+
const lerpScratch = new Cartesian2();
|
|
790
|
+
|
|
791
|
+
const angleBetweenScratch = new Cartesian2();
|
|
792
|
+
const angleBetweenScratch2 = new Cartesian2();
|
|
793
|
+
|
|
794
|
+
const mostOrthogonalAxisScratch = new Cartesian2();
|
|
738
795
|
|
|
739
796
|
/**
|
|
740
797
|
* An immutable Cartesian2 instance initialized to (0.0, 0.0).
|
|
@@ -768,56 +825,4 @@ Cartesian2.UNIT_X = Object.freeze(new Cartesian2(1.0, 0.0));
|
|
|
768
825
|
*/
|
|
769
826
|
Cartesian2.UNIT_Y = Object.freeze(new Cartesian2(0.0, 1.0));
|
|
770
827
|
|
|
771
|
-
/**
|
|
772
|
-
* Duplicates this Cartesian2 instance.
|
|
773
|
-
*
|
|
774
|
-
* @param {Cartesian2} [result] The object onto which to store the result.
|
|
775
|
-
* @returns {Cartesian2} The modified result parameter or a new Cartesian2 instance if one was not provided.
|
|
776
|
-
*/
|
|
777
|
-
Cartesian2.prototype.clone = function (result) {
|
|
778
|
-
return Cartesian2.clone(this, result);
|
|
779
|
-
};
|
|
780
|
-
|
|
781
|
-
/**
|
|
782
|
-
* Compares this Cartesian against the provided Cartesian componentwise and returns
|
|
783
|
-
* <code>true</code> if they are equal, <code>false</code> otherwise.
|
|
784
|
-
*
|
|
785
|
-
* @param {Cartesian2} [right] The right hand side Cartesian.
|
|
786
|
-
* @returns {boolean} <code>true</code> if they are equal, <code>false</code> otherwise.
|
|
787
|
-
*/
|
|
788
|
-
Cartesian2.prototype.equals = function (right) {
|
|
789
|
-
return Cartesian2.equals(this, right);
|
|
790
|
-
};
|
|
791
|
-
|
|
792
|
-
/**
|
|
793
|
-
* Compares this Cartesian against the provided Cartesian componentwise and returns
|
|
794
|
-
* <code>true</code> if they pass an absolute or relative tolerance test,
|
|
795
|
-
* <code>false</code> otherwise.
|
|
796
|
-
*
|
|
797
|
-
* @param {Cartesian2} [right] The right hand side Cartesian.
|
|
798
|
-
* @param {number} [relativeEpsilon=0] The relative epsilon tolerance to use for equality testing.
|
|
799
|
-
* @param {number} [absoluteEpsilon=relativeEpsilon] The absolute epsilon tolerance to use for equality testing.
|
|
800
|
-
* @returns {boolean} <code>true</code> if they are within the provided epsilon, <code>false</code> otherwise.
|
|
801
|
-
*/
|
|
802
|
-
Cartesian2.prototype.equalsEpsilon = function (
|
|
803
|
-
right,
|
|
804
|
-
relativeEpsilon,
|
|
805
|
-
absoluteEpsilon,
|
|
806
|
-
) {
|
|
807
|
-
return Cartesian2.equalsEpsilon(
|
|
808
|
-
this,
|
|
809
|
-
right,
|
|
810
|
-
relativeEpsilon,
|
|
811
|
-
absoluteEpsilon,
|
|
812
|
-
);
|
|
813
|
-
};
|
|
814
|
-
|
|
815
|
-
/**
|
|
816
|
-
* Creates a string representing this Cartesian in the format '(x, y)'.
|
|
817
|
-
*
|
|
818
|
-
* @returns {string} A string representing the provided Cartesian in the format '(x, y)'.
|
|
819
|
-
*/
|
|
820
|
-
Cartesian2.prototype.toString = function () {
|
|
821
|
-
return `(${this.x}, ${this.y})`;
|
|
822
|
-
};
|
|
823
828
|
export default Cartesian2;
|