@cesium/engine 22.3.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-EAAH543Q.js → chunk-2GL2EUEE.js} +11 -11
- package/Build/Workers/{chunk-EUDHHS7K.js → chunk-2WI4HGJU.js} +6 -6
- package/Build/Workers/{chunk-LWZHJWYK.js → chunk-36LBFITA.js} +665 -366
- package/Build/Workers/{chunk-7U5YNLF3.js → chunk-3B65YFXC.js} +1 -1
- package/Build/Workers/{chunk-D63Z7KKL.js → chunk-4LGFX2P5.js} +11 -11
- package/Build/Workers/{chunk-D6OKR3BQ.js → chunk-4UNQX2MP.js} +2 -2
- package/Build/Workers/{chunk-BO22JHBX.js → chunk-52K3GJKG.js} +3 -3
- package/Build/Workers/{chunk-XLIJV3YZ.js → chunk-56OHFSLH.js} +10 -10
- package/Build/Workers/{chunk-AWELU5C6.js → chunk-5A7YSAXT.js} +14 -14
- package/Build/Workers/{chunk-T5MJDW43.js → chunk-5JP5FG7U.js} +7 -7
- package/Build/Workers/{chunk-NVL7JXAQ.js → chunk-5R7SBUTW.js} +10 -10
- package/Build/Workers/chunk-5VKZVPO5.js +1829 -0
- package/Build/Workers/{chunk-YHPBT4I5.js → chunk-6FVFM2KB.js} +5 -5
- package/Build/Workers/{chunk-WHLGBMBC.js → chunk-6SLGTBB2.js} +5 -5
- package/Build/Workers/{chunk-VIQIKMTZ.js → chunk-7KRN6JPQ.js} +14 -14
- package/Build/Workers/{chunk-TCOUGKXF.js → chunk-AA33B6PU.js} +4 -4
- package/Build/Workers/{chunk-S2KVL7OJ.js → chunk-AP6XWET5.js} +8 -8
- package/Build/Workers/{chunk-5PJB7ASO.js → chunk-APDKMX7W.js} +6 -6
- package/Build/Workers/{chunk-IXL46IYV.js → chunk-ARCFIOKA.js} +12 -12
- package/Build/Workers/{chunk-KIJR26N3.js → chunk-BNBD2YZK.js} +16 -16
- package/Build/Workers/{chunk-4R6FGUFP.js → chunk-DT5SJBKA.js} +29 -15
- package/Build/Workers/{chunk-FUDC3KOT.js → chunk-ESD4IEOU.js} +5 -5
- package/Build/Workers/{chunk-K2PLKJJG.js → chunk-FSDVXW7M.js} +5 -5
- package/Build/Workers/{chunk-4BBANFU6.js → chunk-G3YT7M7A.js} +1 -1
- package/Build/Workers/{chunk-K4PGSAR5.js → chunk-GN5NEUDT.js} +8 -8
- package/Build/Workers/{chunk-OOYICVOK.js → chunk-HYLEKKO5.js} +1 -1
- package/Build/Workers/{chunk-FDOLXORR.js → chunk-HYTFXWMY.js} +7 -7
- package/Build/Workers/{chunk-7SLNBIZS.js → chunk-IFA7VHHP.js} +560 -277
- package/Build/Workers/{chunk-N66PIK46.js → chunk-IYVDOB5V.js} +4 -4
- package/Build/Workers/{chunk-ZWWN2CQH.js → chunk-JUGY5AZN.js} +4 -4
- package/Build/Workers/{chunk-4O2ARYS7.js → chunk-KPYU6YZG.js} +1 -1
- package/Build/Workers/{chunk-TY5JXMVO.js → chunk-L7RDJ4V7.js} +1 -1
- package/Build/Workers/{chunk-L4OFWHNI.js → chunk-LDQWNMEC.js} +1 -1
- package/Build/Workers/{chunk-N6XBJBI7.js → chunk-MQJG522T.js} +6 -6
- package/Build/Workers/{chunk-FS42VX2H.js → chunk-MT5M7RLZ.js} +2 -2
- package/Build/Workers/{chunk-7ATKQRBM.js → chunk-N4AWE7TZ.js} +10 -10
- package/Build/Workers/{chunk-EOSX23OS.js → chunk-NAYRNPEP.js} +4 -4
- package/Build/Workers/{chunk-NO3LMU7T.js → chunk-NNHU33JK.js} +7 -7
- package/Build/Workers/{chunk-HWGP4GVC.js → chunk-NQCAZU7S.js} +13 -13
- package/Build/Workers/{chunk-6GBGEUWR.js → chunk-NUYLNQKV.js} +2 -2
- package/Build/Workers/{chunk-E4YDCSQK.js → chunk-OC6X22PG.js} +9 -9
- package/Build/Workers/{chunk-ZGGVEGTA.js → chunk-OHBM4YG4.js} +12 -12
- package/Build/Workers/{chunk-6WDMPXQ7.js → chunk-OMXN7YF4.js} +12 -12
- package/Build/Workers/{chunk-LK7GEFGB.js → chunk-OQ3EAJNW.js} +2 -2
- package/Build/Workers/{chunk-M5DVYXJJ.js → chunk-OQBPOKPZ.js} +6 -6
- package/Build/Workers/{chunk-WUWPKBOZ.js → chunk-PQVNT5CJ.js} +6 -6
- package/Build/Workers/{chunk-W5NV72VR.js → chunk-QA24Q62E.js} +17 -17
- package/Build/Workers/{chunk-PJLRXIMS.js → chunk-QQX7S5QT.js} +17 -17
- package/Build/Workers/{chunk-D2PEV362.js → chunk-QTOHIXGF.js} +10 -10
- package/Build/Workers/{chunk-MASEF4OV.js → chunk-R7M4XNPP.js} +8 -8
- package/Build/Workers/{chunk-2MLJ46ZZ.js → chunk-SGKTBHFQ.js} +13 -13
- package/Build/Workers/{chunk-EY5HOJFQ.js → chunk-SQTRWKO2.js} +5 -5
- package/Build/Workers/{chunk-AFGP5BXS.js → chunk-T43FXHNC.js} +7 -7
- package/Build/Workers/{chunk-IHFAFGR2.js → chunk-UEEGWJJP.js} +2 -2
- package/Build/Workers/{chunk-TMGLPEZW.js → chunk-WKXDCVBO.js} +4 -4
- package/Build/Workers/{chunk-VRAAQ3FS.js → chunk-Y5AJSEEN.js} +2 -2
- package/Build/Workers/{chunk-Y5MRBKQN.js → chunk-ZIW5FCIW.js} +18 -18
- 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 +10 -10
- 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/Cartesian2.js +689 -684
- package/Source/Core/Cartesian3.js +1044 -1043
- package/Source/Core/Cartesian4.js +816 -813
- package/Source/Core/GoogleMaps.js +23 -2
- package/Source/Core/Ion.js +1 -1
- package/Source/Core/OpenCageGeocoderService.js +2 -3
- package/Source/Core/globalTypes.js +16 -0
- package/Source/Renderer/ShaderDestination.js +54 -13
- package/Source/Scene/ArcGisMapService.js +1 -1
- package/Source/Scene/Billboard.js +7 -4
- package/Source/Scene/BillboardCollection.js +64 -25
- package/Source/Scene/BufferLoader.js +65 -74
- package/Source/Scene/CubeMapPanorama.js +351 -0
- package/Source/Scene/DerivedCommand.js +8 -31
- package/Source/Scene/DracoLoader.js +79 -78
- package/Source/Scene/EquirectangularPanorama.js +264 -0
- package/Source/Scene/FrameState.js +7 -0
- package/Source/Scene/GaussianSplatPrimitive.js +906 -167
- 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 +313 -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/Label.js +6 -4
- package/Source/Scene/LabelCollection.js +59 -1
- 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 +1 -1
- package/Source/Scene/Model/MetadataPipelineStage.js +438 -22
- package/Source/Scene/Model/PntsLoader.js +78 -89
- package/Source/Scene/Panorama.js +53 -0
- package/Source/Scene/PanoramaProvider.js +43 -0
- package/Source/Scene/PointPrimitiveCollection.js +14 -22
- package/Source/Scene/PropertyTable.js +43 -0
- package/Source/Scene/PropertyTexture.js +1 -1
- package/Source/Scene/PropertyTextureProperty.js +0 -97
- package/Source/Scene/ResourceLoader.js +84 -92
- package/Source/Scene/Scene.js +12 -0
- package/Source/Scene/SkyBox.js +29 -164
- package/Source/Scene/StructuralMetadata.js +18 -3
- package/Source/Scene/parseStructuralMetadata.js +244 -0
- 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/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 +2 -2
- package/Source/Shaders/Model/ModelFS.js +2 -2
- package/Source/Shaders/Model/ModelVS.glsl +2 -2
- package/Source/Shaders/Model/ModelVS.js +2 -2
- package/Source/Shaders/PointPrimitiveCollectionVS.glsl +8 -39
- package/Source/Shaders/PointPrimitiveCollectionVS.js +8 -39
- package/index.d.ts +564 -189
- package/index.js +127 -119
- package/package.json +1 -1
- package/Build/Workers/chunk-LYBNPUEI.js +0 -1443
|
@@ -1,708 +1,694 @@
|
|
|
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 Color from "./Color.js"; */
|
|
10
|
+
|
|
6
11
|
/**
|
|
7
12
|
* A 4D Cartesian point.
|
|
8
|
-
* @alias Cartesian4
|
|
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
|
-
* @param {number} [w=0.0] The W component.
|
|
15
13
|
*
|
|
16
14
|
* @see Cartesian2
|
|
17
15
|
* @see Cartesian3
|
|
18
16
|
* @see Packable
|
|
19
17
|
*/
|
|
20
|
-
|
|
18
|
+
class Cartesian4 {
|
|
21
19
|
/**
|
|
22
|
-
* The X component.
|
|
23
|
-
* @
|
|
24
|
-
* @
|
|
20
|
+
* @param {number} [x=0.0] The X component.
|
|
21
|
+
* @param {number} [y=0.0] The Y component.
|
|
22
|
+
* @param {number} [z=0.0] The Z component.
|
|
23
|
+
* @param {number} [w=0.0] The W component.
|
|
25
24
|
*/
|
|
26
|
-
|
|
25
|
+
constructor(x, y, z, w) {
|
|
26
|
+
/**
|
|
27
|
+
* The X component.
|
|
28
|
+
* @type {number}
|
|
29
|
+
* @default 0.0
|
|
30
|
+
*/
|
|
31
|
+
this.x = x ?? 0.0;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* The Y component.
|
|
35
|
+
* @type {number}
|
|
36
|
+
* @default 0.0
|
|
37
|
+
*/
|
|
38
|
+
this.y = y ?? 0.0;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* The Z component.
|
|
42
|
+
* @type {number}
|
|
43
|
+
* @default 0.0
|
|
44
|
+
*/
|
|
45
|
+
this.z = z ?? 0.0;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* The W component.
|
|
49
|
+
* @type {number}
|
|
50
|
+
* @default 0.0
|
|
51
|
+
*/
|
|
52
|
+
this.w = w ?? 0.0;
|
|
53
|
+
}
|
|
27
54
|
|
|
28
55
|
/**
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
* @
|
|
56
|
+
* Creates a Cartesian4 instance from x, y, z and w coordinates.
|
|
57
|
+
*
|
|
58
|
+
* @param {number} x The x coordinate.
|
|
59
|
+
* @param {number} y The y coordinate.
|
|
60
|
+
* @param {number} z The z coordinate.
|
|
61
|
+
* @param {number} w The w coordinate.
|
|
62
|
+
* @param {Cartesian4} [result] The object onto which to store the result.
|
|
63
|
+
* @returns {Cartesian4} The modified result parameter or a new Cartesian4 instance if one was not provided.
|
|
32
64
|
*/
|
|
33
|
-
|
|
65
|
+
static fromElements(x, y, z, w, result) {
|
|
66
|
+
if (!defined(result)) {
|
|
67
|
+
return new Cartesian4(x, y, z, w);
|
|
68
|
+
}
|
|
34
69
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
70
|
+
result.x = x;
|
|
71
|
+
result.y = y;
|
|
72
|
+
result.z = z;
|
|
73
|
+
result.w = w;
|
|
74
|
+
return result;
|
|
75
|
+
}
|
|
41
76
|
|
|
42
77
|
/**
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
78
|
+
* Creates a Cartesian4 instance from a {@link Color}. <code>red</code>, <code>green</code>, <code>blue</code>,
|
|
79
|
+
* and <code>alpha</code> map to <code>x</code>, <code>y</code>, <code>z</code>, and <code>w</code>, respectively.
|
|
80
|
+
*
|
|
81
|
+
* @param {Color} color The source color.
|
|
82
|
+
* @param {Cartesian4} [result] The object onto which to store the result.
|
|
83
|
+
* @returns {Cartesian4} The modified result parameter or a new Cartesian4 instance if one was not provided.
|
|
46
84
|
*/
|
|
47
|
-
|
|
48
|
-
|
|
85
|
+
static fromColor(color, result) {
|
|
86
|
+
//>>includeStart('debug', pragmas.debug);
|
|
87
|
+
Check.typeOf.object("color", color);
|
|
88
|
+
//>>includeEnd('debug');
|
|
89
|
+
if (!defined(result)) {
|
|
90
|
+
return new Cartesian4(color.red, color.green, color.blue, color.alpha);
|
|
91
|
+
}
|
|
49
92
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
* @param {number} z The z coordinate.
|
|
56
|
-
* @param {number} w The w coordinate.
|
|
57
|
-
* @param {Cartesian4} [result] The object onto which to store the result.
|
|
58
|
-
* @returns {Cartesian4} The modified result parameter or a new Cartesian4 instance if one was not provided.
|
|
59
|
-
*/
|
|
60
|
-
Cartesian4.fromElements = function (x, y, z, w, result) {
|
|
61
|
-
if (!defined(result)) {
|
|
62
|
-
return new Cartesian4(x, y, z, w);
|
|
93
|
+
result.x = color.red;
|
|
94
|
+
result.y = color.green;
|
|
95
|
+
result.z = color.blue;
|
|
96
|
+
result.w = color.alpha;
|
|
97
|
+
return result;
|
|
63
98
|
}
|
|
64
99
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
100
|
+
/**
|
|
101
|
+
* Duplicates a Cartesian4 instance.
|
|
102
|
+
*
|
|
103
|
+
* @param {Cartesian4} cartesian The Cartesian to duplicate.
|
|
104
|
+
* @param {Cartesian4} [result] The object onto which to store the result.
|
|
105
|
+
* @returns {Cartesian4} The modified result parameter or a new Cartesian4 instance if one was not provided. (Returns undefined if cartesian is undefined)
|
|
106
|
+
*/
|
|
107
|
+
static clone(cartesian, result) {
|
|
108
|
+
if (!defined(cartesian)) {
|
|
109
|
+
return undefined;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (!defined(result)) {
|
|
113
|
+
return new Cartesian4(cartesian.x, cartesian.y, cartesian.z, cartesian.w);
|
|
114
|
+
}
|
|
71
115
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
* @param {Cartesian4} [result] The object onto which to store the result.
|
|
78
|
-
* @returns {Cartesian4} The modified result parameter or a new Cartesian4 instance if one was not provided.
|
|
79
|
-
*/
|
|
80
|
-
Cartesian4.fromColor = function (color, result) {
|
|
81
|
-
//>>includeStart('debug', pragmas.debug);
|
|
82
|
-
Check.typeOf.object("color", color);
|
|
83
|
-
//>>includeEnd('debug');
|
|
84
|
-
if (!defined(result)) {
|
|
85
|
-
return new Cartesian4(color.red, color.green, color.blue, color.alpha);
|
|
116
|
+
result.x = cartesian.x;
|
|
117
|
+
result.y = cartesian.y;
|
|
118
|
+
result.z = cartesian.z;
|
|
119
|
+
result.w = cartesian.w;
|
|
120
|
+
return result;
|
|
86
121
|
}
|
|
87
122
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
}
|
|
123
|
+
/**
|
|
124
|
+
* Stores the provided instance into the provided array.
|
|
125
|
+
*
|
|
126
|
+
* @param {Cartesian4} value The value to pack.
|
|
127
|
+
* @param {number[]|TypedArray} array The array to pack into.
|
|
128
|
+
* @param {number} [startingIndex=0] The index into the array at which to start packing the elements.
|
|
129
|
+
*
|
|
130
|
+
* @returns {number[]|TypedArray} The array that was packed into
|
|
131
|
+
*/
|
|
132
|
+
static pack(value, array, startingIndex) {
|
|
133
|
+
//>>includeStart('debug', pragmas.debug);
|
|
134
|
+
Check.typeOf.object("value", value);
|
|
135
|
+
Check.defined("array", array);
|
|
136
|
+
//>>includeEnd('debug');
|
|
94
137
|
|
|
95
|
-
|
|
96
|
-
* Duplicates a Cartesian4 instance.
|
|
97
|
-
*
|
|
98
|
-
* @param {Cartesian4} cartesian The Cartesian to duplicate.
|
|
99
|
-
* @param {Cartesian4} [result] The object onto which to store the result.
|
|
100
|
-
* @returns {Cartesian4} The modified result parameter or a new Cartesian4 instance if one was not provided. (Returns undefined if cartesian is undefined)
|
|
101
|
-
*/
|
|
102
|
-
Cartesian4.clone = function (cartesian, result) {
|
|
103
|
-
if (!defined(cartesian)) {
|
|
104
|
-
return undefined;
|
|
105
|
-
}
|
|
138
|
+
startingIndex = startingIndex ?? 0;
|
|
106
139
|
|
|
107
|
-
|
|
108
|
-
|
|
140
|
+
array[startingIndex++] = value.x;
|
|
141
|
+
array[startingIndex++] = value.y;
|
|
142
|
+
array[startingIndex++] = value.z;
|
|
143
|
+
array[startingIndex] = value.w;
|
|
144
|
+
|
|
145
|
+
return array;
|
|
109
146
|
}
|
|
110
147
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
}
|
|
148
|
+
/**
|
|
149
|
+
* Retrieves an instance from a packed array.
|
|
150
|
+
*
|
|
151
|
+
* @param {number[]|TypedArray} array The packed array.
|
|
152
|
+
* @param {number} [startingIndex=0] The starting index of the element to be unpacked.
|
|
153
|
+
* @param {Cartesian4} [result] The object into which to store the result.
|
|
154
|
+
* @returns {Cartesian4} The modified result parameter or a new Cartesian4 instance if one was not provided.
|
|
155
|
+
*/
|
|
156
|
+
static unpack(array, startingIndex, result) {
|
|
157
|
+
//>>includeStart('debug', pragmas.debug);
|
|
158
|
+
Check.defined("array", array);
|
|
159
|
+
//>>includeEnd('debug');
|
|
117
160
|
|
|
118
|
-
|
|
119
|
-
* The number of elements used to pack the object into an array.
|
|
120
|
-
* @type {number}
|
|
121
|
-
*/
|
|
122
|
-
Cartesian4.packedLength = 4;
|
|
161
|
+
startingIndex = startingIndex ?? 0;
|
|
123
162
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
Cartesian4.pack = function (value, array, startingIndex) {
|
|
134
|
-
//>>includeStart('debug', pragmas.debug);
|
|
135
|
-
Check.typeOf.object("value", value);
|
|
136
|
-
Check.defined("array", array);
|
|
137
|
-
//>>includeEnd('debug');
|
|
163
|
+
if (!defined(result)) {
|
|
164
|
+
result = new Cartesian4();
|
|
165
|
+
}
|
|
166
|
+
result.x = array[startingIndex++];
|
|
167
|
+
result.y = array[startingIndex++];
|
|
168
|
+
result.z = array[startingIndex++];
|
|
169
|
+
result.w = array[startingIndex];
|
|
170
|
+
return result;
|
|
171
|
+
}
|
|
138
172
|
|
|
139
|
-
|
|
173
|
+
/**
|
|
174
|
+
* Flattens an array of Cartesian4s into an array of components.
|
|
175
|
+
*
|
|
176
|
+
* @param {Cartesian4[]} array The array of cartesians to pack.
|
|
177
|
+
* @param {number[]|TypedArray} [result] The array onto which to store the result. If this is a typed array, it must have array.length * 4 components, else a {@link DeveloperError} will be thrown. If it is a regular array, it will be resized to have (array.length * 4) elements.
|
|
178
|
+
* @returns {number[]|TypedArray} The packed array.
|
|
179
|
+
*/
|
|
180
|
+
static packArray(array, result) {
|
|
181
|
+
//>>includeStart('debug', pragmas.debug);
|
|
182
|
+
Check.defined("array", array);
|
|
183
|
+
//>>includeEnd('debug');
|
|
140
184
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
185
|
+
const length = array.length;
|
|
186
|
+
const resultLength = length * 4;
|
|
187
|
+
if (!defined(result)) {
|
|
188
|
+
result = new Array(resultLength);
|
|
189
|
+
} else if (!Array.isArray(result) && result.length !== resultLength) {
|
|
190
|
+
//>>includeStart('debug', pragmas.debug);
|
|
191
|
+
throw new DeveloperError(
|
|
192
|
+
"If result is a typed array, it must have exactly array.length * 4 elements",
|
|
193
|
+
);
|
|
194
|
+
//>>includeEnd('debug');
|
|
195
|
+
} else if (result.length !== resultLength) {
|
|
196
|
+
/** @type {number[]} */ (result).length = resultLength;
|
|
197
|
+
}
|
|
145
198
|
|
|
146
|
-
|
|
147
|
-
|
|
199
|
+
for (let i = 0; i < length; ++i) {
|
|
200
|
+
Cartesian4.pack(array[i], result, i * 4);
|
|
201
|
+
}
|
|
202
|
+
return result;
|
|
203
|
+
}
|
|
148
204
|
|
|
149
|
-
/**
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
205
|
+
/**
|
|
206
|
+
* Unpacks an array of cartesian components into an array of Cartesian4s.
|
|
207
|
+
*
|
|
208
|
+
* @param {number[]|TypedArray} array The array of components to unpack.
|
|
209
|
+
* @param {Cartesian4[]} [result] The array onto which to store the result.
|
|
210
|
+
* @returns {Cartesian4[]} The unpacked array.
|
|
211
|
+
*/
|
|
212
|
+
static unpackArray(array, result) {
|
|
213
|
+
//>>includeStart('debug', pragmas.debug);
|
|
214
|
+
Check.defined("array", array);
|
|
215
|
+
Check.typeOf.number.greaterThanOrEquals("array.length", array.length, 4);
|
|
216
|
+
if (array.length % 4 !== 0) {
|
|
217
|
+
throw new DeveloperError("array length must be a multiple of 4.");
|
|
218
|
+
}
|
|
219
|
+
//>>includeEnd('debug');
|
|
161
220
|
|
|
162
|
-
|
|
221
|
+
const length = array.length;
|
|
222
|
+
if (!defined(result)) {
|
|
223
|
+
result = new Array(length / 4);
|
|
224
|
+
} else {
|
|
225
|
+
result.length = length / 4;
|
|
226
|
+
}
|
|
163
227
|
|
|
164
|
-
|
|
165
|
-
|
|
228
|
+
for (let i = 0; i < length; i += 4) {
|
|
229
|
+
const index = i / 4;
|
|
230
|
+
result[index] = Cartesian4.unpack(array, i, result[index]);
|
|
231
|
+
}
|
|
232
|
+
return result;
|
|
166
233
|
}
|
|
167
|
-
result.x = array[startingIndex++];
|
|
168
|
-
result.y = array[startingIndex++];
|
|
169
|
-
result.z = array[startingIndex++];
|
|
170
|
-
result.w = array[startingIndex];
|
|
171
|
-
return result;
|
|
172
|
-
};
|
|
173
234
|
|
|
174
|
-
/**
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
Cartesian4.packArray = function (array, result) {
|
|
182
|
-
//>>includeStart('debug', pragmas.debug);
|
|
183
|
-
Check.defined("array", array);
|
|
184
|
-
//>>includeEnd('debug');
|
|
185
|
-
|
|
186
|
-
const length = array.length;
|
|
187
|
-
const resultLength = length * 4;
|
|
188
|
-
if (!defined(result)) {
|
|
189
|
-
result = new Array(resultLength);
|
|
190
|
-
} else if (!Array.isArray(result) && result.length !== resultLength) {
|
|
235
|
+
/**
|
|
236
|
+
* Computes the value of the maximum component for the supplied Cartesian.
|
|
237
|
+
*
|
|
238
|
+
* @param {Cartesian4} cartesian The cartesian to use.
|
|
239
|
+
* @returns {number} The value of the maximum component.
|
|
240
|
+
*/
|
|
241
|
+
static maximumComponent(cartesian) {
|
|
191
242
|
//>>includeStart('debug', pragmas.debug);
|
|
192
|
-
|
|
193
|
-
"If result is a typed array, it must have exactly array.length * 4 elements",
|
|
194
|
-
);
|
|
243
|
+
Check.typeOf.object("cartesian", cartesian);
|
|
195
244
|
//>>includeEnd('debug');
|
|
196
|
-
} else if (result.length !== resultLength) {
|
|
197
|
-
result.length = resultLength;
|
|
198
|
-
}
|
|
199
245
|
|
|
200
|
-
|
|
201
|
-
Cartesian4.pack(array[i], result, i * 4);
|
|
246
|
+
return Math.max(cartesian.x, cartesian.y, cartesian.z, cartesian.w);
|
|
202
247
|
}
|
|
203
|
-
return result;
|
|
204
|
-
};
|
|
205
248
|
|
|
206
|
-
/**
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
throw new DeveloperError("array length must be a multiple of 4.");
|
|
249
|
+
/**
|
|
250
|
+
* Computes the value of the minimum component for the supplied Cartesian.
|
|
251
|
+
*
|
|
252
|
+
* @param {Cartesian4} cartesian The cartesian to use.
|
|
253
|
+
* @returns {number} The value of the minimum component.
|
|
254
|
+
*/
|
|
255
|
+
static minimumComponent(cartesian) {
|
|
256
|
+
//>>includeStart('debug', pragmas.debug);
|
|
257
|
+
Check.typeOf.object("cartesian", cartesian);
|
|
258
|
+
//>>includeEnd('debug');
|
|
259
|
+
|
|
260
|
+
return Math.min(cartesian.x, cartesian.y, cartesian.z, cartesian.w);
|
|
219
261
|
}
|
|
220
|
-
//>>includeEnd('debug');
|
|
221
262
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
263
|
+
/**
|
|
264
|
+
* Compares two Cartesians and computes a Cartesian which contains the minimum components of the supplied Cartesians.
|
|
265
|
+
*
|
|
266
|
+
* @param {Cartesian4} first A cartesian to compare.
|
|
267
|
+
* @param {Cartesian4} second A cartesian to compare.
|
|
268
|
+
* @param {Cartesian4} result The object into which to store the result.
|
|
269
|
+
* @returns {Cartesian4} A cartesian with the minimum components.
|
|
270
|
+
*/
|
|
271
|
+
static minimumByComponent(first, second, result) {
|
|
272
|
+
//>>includeStart('debug', pragmas.debug);
|
|
273
|
+
Check.typeOf.object("first", first);
|
|
274
|
+
Check.typeOf.object("second", second);
|
|
275
|
+
Check.typeOf.object("result", result);
|
|
276
|
+
//>>includeEnd('debug');
|
|
277
|
+
|
|
278
|
+
result.x = Math.min(first.x, second.x);
|
|
279
|
+
result.y = Math.min(first.y, second.y);
|
|
280
|
+
result.z = Math.min(first.z, second.z);
|
|
281
|
+
result.w = Math.min(first.w, second.w);
|
|
282
|
+
|
|
283
|
+
return result;
|
|
227
284
|
}
|
|
228
285
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
286
|
+
/**
|
|
287
|
+
* Compares two Cartesians and computes a Cartesian which contains the maximum components of the supplied Cartesians.
|
|
288
|
+
*
|
|
289
|
+
* @param {Cartesian4} first A cartesian to compare.
|
|
290
|
+
* @param {Cartesian4} second A cartesian to compare.
|
|
291
|
+
* @param {Cartesian4} result The object into which to store the result.
|
|
292
|
+
* @returns {Cartesian4} A cartesian with the maximum components.
|
|
293
|
+
*/
|
|
294
|
+
static maximumByComponent(first, second, result) {
|
|
295
|
+
//>>includeStart('debug', pragmas.debug);
|
|
296
|
+
Check.typeOf.object("first", first);
|
|
297
|
+
Check.typeOf.object("second", second);
|
|
298
|
+
Check.typeOf.object("result", result);
|
|
299
|
+
//>>includeEnd('debug');
|
|
300
|
+
|
|
301
|
+
result.x = Math.max(first.x, second.x);
|
|
302
|
+
result.y = Math.max(first.y, second.y);
|
|
303
|
+
result.z = Math.max(first.z, second.z);
|
|
304
|
+
result.w = Math.max(first.w, second.w);
|
|
305
|
+
|
|
306
|
+
return result;
|
|
232
307
|
}
|
|
233
|
-
return result;
|
|
234
|
-
};
|
|
235
308
|
|
|
236
|
-
/**
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
* const p2 = Cesium.Cartesian4.fromArray(v2, 2);
|
|
253
|
-
*/
|
|
254
|
-
Cartesian4.fromArray = Cartesian4.unpack;
|
|
309
|
+
/**
|
|
310
|
+
* Constrain a value to lie between two values.
|
|
311
|
+
*
|
|
312
|
+
* @param {Cartesian4} value The value to clamp.
|
|
313
|
+
* @param {Cartesian4} min The minimum bound.
|
|
314
|
+
* @param {Cartesian4} max The maximum bound.
|
|
315
|
+
* @param {Cartesian4} result The object into which to store the result.
|
|
316
|
+
* @returns {Cartesian4} The clamped value such that min <= result <= max.
|
|
317
|
+
*/
|
|
318
|
+
static clamp(value, min, max, result) {
|
|
319
|
+
//>>includeStart('debug', pragmas.debug);
|
|
320
|
+
Check.typeOf.object("value", value);
|
|
321
|
+
Check.typeOf.object("min", min);
|
|
322
|
+
Check.typeOf.object("max", max);
|
|
323
|
+
Check.typeOf.object("result", result);
|
|
324
|
+
//>>includeEnd('debug');
|
|
255
325
|
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
* @returns {number} The value of the maximum component.
|
|
261
|
-
*/
|
|
262
|
-
Cartesian4.maximumComponent = function (cartesian) {
|
|
263
|
-
//>>includeStart('debug', pragmas.debug);
|
|
264
|
-
Check.typeOf.object("cartesian", cartesian);
|
|
265
|
-
//>>includeEnd('debug');
|
|
326
|
+
const x = CesiumMath.clamp(value.x, min.x, max.x);
|
|
327
|
+
const y = CesiumMath.clamp(value.y, min.y, max.y);
|
|
328
|
+
const z = CesiumMath.clamp(value.z, min.z, max.z);
|
|
329
|
+
const w = CesiumMath.clamp(value.w, min.w, max.w);
|
|
266
330
|
|
|
267
|
-
|
|
268
|
-
|
|
331
|
+
result.x = x;
|
|
332
|
+
result.y = y;
|
|
333
|
+
result.z = z;
|
|
334
|
+
result.w = w;
|
|
269
335
|
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
*
|
|
273
|
-
* @param {Cartesian4} cartesian The cartesian to use.
|
|
274
|
-
* @returns {number} The value of the minimum component.
|
|
275
|
-
*/
|
|
276
|
-
Cartesian4.minimumComponent = function (cartesian) {
|
|
277
|
-
//>>includeStart('debug', pragmas.debug);
|
|
278
|
-
Check.typeOf.object("cartesian", cartesian);
|
|
279
|
-
//>>includeEnd('debug');
|
|
336
|
+
return result;
|
|
337
|
+
}
|
|
280
338
|
|
|
281
|
-
|
|
282
|
-
|
|
339
|
+
/**
|
|
340
|
+
* Computes the provided Cartesian's squared magnitude.
|
|
341
|
+
*
|
|
342
|
+
* @param {Cartesian4} cartesian The Cartesian instance whose squared magnitude is to be computed.
|
|
343
|
+
* @returns {number} The squared magnitude.
|
|
344
|
+
*/
|
|
345
|
+
static magnitudeSquared(cartesian) {
|
|
346
|
+
//>>includeStart('debug', pragmas.debug);
|
|
347
|
+
Check.typeOf.object("cartesian", cartesian);
|
|
348
|
+
//>>includeEnd('debug');
|
|
283
349
|
|
|
284
|
-
|
|
285
|
-
*
|
|
286
|
-
*
|
|
287
|
-
*
|
|
288
|
-
*
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
*/
|
|
292
|
-
Cartesian4.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');
|
|
350
|
+
return (
|
|
351
|
+
cartesian.x * cartesian.x +
|
|
352
|
+
cartesian.y * cartesian.y +
|
|
353
|
+
cartesian.z * cartesian.z +
|
|
354
|
+
cartesian.w * cartesian.w
|
|
355
|
+
);
|
|
356
|
+
}
|
|
298
357
|
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
358
|
+
/**
|
|
359
|
+
* Computes the Cartesian's magnitude (length).
|
|
360
|
+
*
|
|
361
|
+
* @param {Cartesian4} cartesian The Cartesian instance whose magnitude is to be computed.
|
|
362
|
+
* @returns {number} The magnitude.
|
|
363
|
+
*/
|
|
364
|
+
static magnitude(cartesian) {
|
|
365
|
+
return Math.sqrt(Cartesian4.magnitudeSquared(cartesian));
|
|
366
|
+
}
|
|
303
367
|
|
|
304
|
-
|
|
305
|
-
|
|
368
|
+
/**
|
|
369
|
+
* Computes the 4-space distance between two points.
|
|
370
|
+
*
|
|
371
|
+
* @param {Cartesian4} left The first point to compute the distance from.
|
|
372
|
+
* @param {Cartesian4} right The second point to compute the distance to.
|
|
373
|
+
* @returns {number} The distance between two points.
|
|
374
|
+
*
|
|
375
|
+
* @example
|
|
376
|
+
* // Returns 1.0
|
|
377
|
+
* const d = Cesium.Cartesian4.distance(
|
|
378
|
+
* new Cesium.Cartesian4(1.0, 0.0, 0.0, 0.0),
|
|
379
|
+
* new Cesium.Cartesian4(2.0, 0.0, 0.0, 0.0));
|
|
380
|
+
*/
|
|
381
|
+
static distance(left, right) {
|
|
382
|
+
//>>includeStart('debug', pragmas.debug);
|
|
383
|
+
Check.typeOf.object("left", left);
|
|
384
|
+
Check.typeOf.object("right", right);
|
|
385
|
+
//>>includeEnd('debug');
|
|
306
386
|
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
* @param {Cartesian4} first A cartesian to compare.
|
|
311
|
-
* @param {Cartesian4} second A cartesian to compare.
|
|
312
|
-
* @param {Cartesian4} result The object into which to store the result.
|
|
313
|
-
* @returns {Cartesian4} A cartesian with the maximum components.
|
|
314
|
-
*/
|
|
315
|
-
Cartesian4.maximumByComponent = function (first, second, result) {
|
|
316
|
-
//>>includeStart('debug', pragmas.debug);
|
|
317
|
-
Check.typeOf.object("first", first);
|
|
318
|
-
Check.typeOf.object("second", second);
|
|
319
|
-
Check.typeOf.object("result", result);
|
|
320
|
-
//>>includeEnd('debug');
|
|
387
|
+
Cartesian4.subtract(left, right, distanceScratch);
|
|
388
|
+
return Cartesian4.magnitude(distanceScratch);
|
|
389
|
+
}
|
|
321
390
|
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
391
|
+
/**
|
|
392
|
+
* Computes the squared distance between two points. Comparing squared distances
|
|
393
|
+
* using this function is more efficient than comparing distances using {@link Cartesian4#distance}.
|
|
394
|
+
*
|
|
395
|
+
* @param {Cartesian4} left The first point to compute the distance from.
|
|
396
|
+
* @param {Cartesian4} right The second point to compute the distance to.
|
|
397
|
+
* @returns {number} The distance between two points.
|
|
398
|
+
*
|
|
399
|
+
* @example
|
|
400
|
+
* // Returns 4.0, not 2.0
|
|
401
|
+
* const d = Cesium.Cartesian4.distance(
|
|
402
|
+
* new Cesium.Cartesian4(1.0, 0.0, 0.0, 0.0),
|
|
403
|
+
* new Cesium.Cartesian4(3.0, 0.0, 0.0, 0.0));
|
|
404
|
+
*/
|
|
405
|
+
static distanceSquared(left, right) {
|
|
406
|
+
//>>includeStart('debug', pragmas.debug);
|
|
407
|
+
Check.typeOf.object("left", left);
|
|
408
|
+
Check.typeOf.object("right", right);
|
|
409
|
+
//>>includeEnd('debug');
|
|
326
410
|
|
|
327
|
-
|
|
328
|
-
|
|
411
|
+
Cartesian4.subtract(left, right, distanceScratch);
|
|
412
|
+
return Cartesian4.magnitudeSquared(distanceScratch);
|
|
413
|
+
}
|
|
329
414
|
|
|
330
|
-
/**
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
Check.typeOf.object("min", min);
|
|
343
|
-
Check.typeOf.object("max", max);
|
|
344
|
-
Check.typeOf.object("result", result);
|
|
345
|
-
//>>includeEnd('debug');
|
|
346
|
-
|
|
347
|
-
const x = CesiumMath.clamp(value.x, min.x, max.x);
|
|
348
|
-
const y = CesiumMath.clamp(value.y, min.y, max.y);
|
|
349
|
-
const z = CesiumMath.clamp(value.z, min.z, max.z);
|
|
350
|
-
const w = CesiumMath.clamp(value.w, min.w, max.w);
|
|
351
|
-
|
|
352
|
-
result.x = x;
|
|
353
|
-
result.y = y;
|
|
354
|
-
result.z = z;
|
|
355
|
-
result.w = w;
|
|
356
|
-
|
|
357
|
-
return result;
|
|
358
|
-
};
|
|
415
|
+
/**
|
|
416
|
+
* Computes the normalized form of the supplied Cartesian.
|
|
417
|
+
*
|
|
418
|
+
* @param {Cartesian4} cartesian The Cartesian to be normalized.
|
|
419
|
+
* @param {Cartesian4} result The object onto which to store the result.
|
|
420
|
+
* @returns {Cartesian4} The modified result parameter.
|
|
421
|
+
*/
|
|
422
|
+
static normalize(cartesian, result) {
|
|
423
|
+
//>>includeStart('debug', pragmas.debug);
|
|
424
|
+
Check.typeOf.object("cartesian", cartesian);
|
|
425
|
+
Check.typeOf.object("result", result);
|
|
426
|
+
//>>includeEnd('debug');
|
|
359
427
|
|
|
360
|
-
|
|
361
|
-
* Computes the provided Cartesian's squared magnitude.
|
|
362
|
-
*
|
|
363
|
-
* @param {Cartesian4} cartesian The Cartesian instance whose squared magnitude is to be computed.
|
|
364
|
-
* @returns {number} The squared magnitude.
|
|
365
|
-
*/
|
|
366
|
-
Cartesian4.magnitudeSquared = function (cartesian) {
|
|
367
|
-
//>>includeStart('debug', pragmas.debug);
|
|
368
|
-
Check.typeOf.object("cartesian", cartesian);
|
|
369
|
-
//>>includeEnd('debug');
|
|
370
|
-
|
|
371
|
-
return (
|
|
372
|
-
cartesian.x * cartesian.x +
|
|
373
|
-
cartesian.y * cartesian.y +
|
|
374
|
-
cartesian.z * cartesian.z +
|
|
375
|
-
cartesian.w * cartesian.w
|
|
376
|
-
);
|
|
377
|
-
};
|
|
428
|
+
const magnitude = Cartesian4.magnitude(cartesian);
|
|
378
429
|
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
* @returns {number} The magnitude.
|
|
384
|
-
*/
|
|
385
|
-
Cartesian4.magnitude = function (cartesian) {
|
|
386
|
-
return Math.sqrt(Cartesian4.magnitudeSquared(cartesian));
|
|
387
|
-
};
|
|
430
|
+
result.x = cartesian.x / magnitude;
|
|
431
|
+
result.y = cartesian.y / magnitude;
|
|
432
|
+
result.z = cartesian.z / magnitude;
|
|
433
|
+
result.w = cartesian.w / magnitude;
|
|
388
434
|
|
|
389
|
-
|
|
435
|
+
//>>includeStart('debug', pragmas.debug);
|
|
436
|
+
if (
|
|
437
|
+
isNaN(result.x) ||
|
|
438
|
+
isNaN(result.y) ||
|
|
439
|
+
isNaN(result.z) ||
|
|
440
|
+
isNaN(result.w)
|
|
441
|
+
) {
|
|
442
|
+
throw new DeveloperError("normalized result is not a number");
|
|
443
|
+
}
|
|
444
|
+
//>>includeEnd('debug');
|
|
390
445
|
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
*
|
|
394
|
-
* @param {Cartesian4} left The first point to compute the distance from.
|
|
395
|
-
* @param {Cartesian4} right The second point to compute the distance to.
|
|
396
|
-
* @returns {number} The distance between two points.
|
|
397
|
-
*
|
|
398
|
-
* @example
|
|
399
|
-
* // Returns 1.0
|
|
400
|
-
* const d = Cesium.Cartesian4.distance(
|
|
401
|
-
* new Cesium.Cartesian4(1.0, 0.0, 0.0, 0.0),
|
|
402
|
-
* new Cesium.Cartesian4(2.0, 0.0, 0.0, 0.0));
|
|
403
|
-
*/
|
|
404
|
-
Cartesian4.distance = function (left, right) {
|
|
405
|
-
//>>includeStart('debug', pragmas.debug);
|
|
406
|
-
Check.typeOf.object("left", left);
|
|
407
|
-
Check.typeOf.object("right", right);
|
|
408
|
-
//>>includeEnd('debug');
|
|
446
|
+
return result;
|
|
447
|
+
}
|
|
409
448
|
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
449
|
+
/**
|
|
450
|
+
* Computes the dot (scalar) product of two Cartesians.
|
|
451
|
+
*
|
|
452
|
+
* @param {Cartesian4} left The first Cartesian.
|
|
453
|
+
* @param {Cartesian4} right The second Cartesian.
|
|
454
|
+
* @returns {number} The dot product.
|
|
455
|
+
*/
|
|
456
|
+
static dot(left, right) {
|
|
457
|
+
//>>includeStart('debug', pragmas.debug);
|
|
458
|
+
Check.typeOf.object("left", left);
|
|
459
|
+
Check.typeOf.object("right", right);
|
|
460
|
+
//>>includeEnd('debug');
|
|
413
461
|
|
|
414
|
-
|
|
415
|
-
*
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
* @param {Cartesian4} left The first point to compute the distance from.
|
|
419
|
-
* @param {Cartesian4} right The second point to compute the distance to.
|
|
420
|
-
* @returns {number} The distance between two points.
|
|
421
|
-
*
|
|
422
|
-
* @example
|
|
423
|
-
* // Returns 4.0, not 2.0
|
|
424
|
-
* const d = Cesium.Cartesian4.distance(
|
|
425
|
-
* new Cesium.Cartesian4(1.0, 0.0, 0.0, 0.0),
|
|
426
|
-
* new Cesium.Cartesian4(3.0, 0.0, 0.0, 0.0));
|
|
427
|
-
*/
|
|
428
|
-
Cartesian4.distanceSquared = function (left, right) {
|
|
429
|
-
//>>includeStart('debug', pragmas.debug);
|
|
430
|
-
Check.typeOf.object("left", left);
|
|
431
|
-
Check.typeOf.object("right", right);
|
|
432
|
-
//>>includeEnd('debug');
|
|
462
|
+
return (
|
|
463
|
+
left.x * right.x + left.y * right.y + left.z * right.z + left.w * right.w
|
|
464
|
+
);
|
|
465
|
+
}
|
|
433
466
|
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
467
|
+
/**
|
|
468
|
+
* Computes the componentwise product of two Cartesians.
|
|
469
|
+
*
|
|
470
|
+
* @param {Cartesian4} left The first Cartesian.
|
|
471
|
+
* @param {Cartesian4} right The second Cartesian.
|
|
472
|
+
* @param {Cartesian4} result The object onto which to store the result.
|
|
473
|
+
* @returns {Cartesian4} The modified result parameter.
|
|
474
|
+
*/
|
|
475
|
+
static multiplyComponents(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');
|
|
437
481
|
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
*
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
*/
|
|
445
|
-
Cartesian4.normalize = function (cartesian, result) {
|
|
446
|
-
//>>includeStart('debug', pragmas.debug);
|
|
447
|
-
Check.typeOf.object("cartesian", cartesian);
|
|
448
|
-
Check.typeOf.object("result", result);
|
|
449
|
-
//>>includeEnd('debug');
|
|
482
|
+
result.x = left.x * right.x;
|
|
483
|
+
result.y = left.y * right.y;
|
|
484
|
+
result.z = left.z * right.z;
|
|
485
|
+
result.w = left.w * right.w;
|
|
486
|
+
return result;
|
|
487
|
+
}
|
|
450
488
|
|
|
451
|
-
|
|
489
|
+
/**
|
|
490
|
+
* Computes the componentwise quotient of two Cartesians.
|
|
491
|
+
*
|
|
492
|
+
* @param {Cartesian4} left The first Cartesian.
|
|
493
|
+
* @param {Cartesian4} right The second Cartesian.
|
|
494
|
+
* @param {Cartesian4} result The object onto which to store the result.
|
|
495
|
+
* @returns {Cartesian4} The modified result parameter.
|
|
496
|
+
*/
|
|
497
|
+
static divideComponents(left, right, result) {
|
|
498
|
+
//>>includeStart('debug', pragmas.debug);
|
|
499
|
+
Check.typeOf.object("left", left);
|
|
500
|
+
Check.typeOf.object("right", right);
|
|
501
|
+
Check.typeOf.object("result", result);
|
|
502
|
+
//>>includeEnd('debug');
|
|
503
|
+
|
|
504
|
+
result.x = left.x / right.x;
|
|
505
|
+
result.y = left.y / right.y;
|
|
506
|
+
result.z = left.z / right.z;
|
|
507
|
+
result.w = left.w / right.w;
|
|
508
|
+
return result;
|
|
509
|
+
}
|
|
452
510
|
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
511
|
+
/**
|
|
512
|
+
* Computes the componentwise sum of two Cartesians.
|
|
513
|
+
*
|
|
514
|
+
* @param {Cartesian4} left The first Cartesian.
|
|
515
|
+
* @param {Cartesian4} right The second Cartesian.
|
|
516
|
+
* @param {Cartesian4} result The object onto which to store the result.
|
|
517
|
+
* @returns {Cartesian4} The modified result parameter.
|
|
518
|
+
*/
|
|
519
|
+
static add(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');
|
|
457
525
|
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
isNaN(result.w)
|
|
464
|
-
) {
|
|
465
|
-
throw new DeveloperError("normalized result is not a number");
|
|
526
|
+
result.x = left.x + right.x;
|
|
527
|
+
result.y = left.y + right.y;
|
|
528
|
+
result.z = left.z + right.z;
|
|
529
|
+
result.w = left.w + right.w;
|
|
530
|
+
return result;
|
|
466
531
|
}
|
|
467
|
-
//>>includeEnd('debug');
|
|
468
532
|
|
|
469
|
-
|
|
470
|
-
|
|
533
|
+
/**
|
|
534
|
+
* Computes the componentwise difference of two Cartesians.
|
|
535
|
+
*
|
|
536
|
+
* @param {Cartesian4} left The first Cartesian.
|
|
537
|
+
* @param {Cartesian4} right The second Cartesian.
|
|
538
|
+
* @param {Cartesian4} result The object onto which to store the result.
|
|
539
|
+
* @returns {Cartesian4} The modified result parameter.
|
|
540
|
+
*/
|
|
541
|
+
static subtract(left, right, result) {
|
|
542
|
+
//>>includeStart('debug', pragmas.debug);
|
|
543
|
+
Check.typeOf.object("left", left);
|
|
544
|
+
Check.typeOf.object("right", right);
|
|
545
|
+
Check.typeOf.object("result", result);
|
|
546
|
+
//>>includeEnd('debug');
|
|
471
547
|
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
*/
|
|
479
|
-
Cartesian4.dot = function (left, right) {
|
|
480
|
-
//>>includeStart('debug', pragmas.debug);
|
|
481
|
-
Check.typeOf.object("left", left);
|
|
482
|
-
Check.typeOf.object("right", right);
|
|
483
|
-
//>>includeEnd('debug');
|
|
548
|
+
result.x = left.x - right.x;
|
|
549
|
+
result.y = left.y - right.y;
|
|
550
|
+
result.z = left.z - right.z;
|
|
551
|
+
result.w = left.w - right.w;
|
|
552
|
+
return result;
|
|
553
|
+
}
|
|
484
554
|
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
}
|
|
555
|
+
/**
|
|
556
|
+
* Multiplies the provided Cartesian componentwise by the provided scalar.
|
|
557
|
+
*
|
|
558
|
+
* @param {Cartesian4} cartesian The Cartesian to be scaled.
|
|
559
|
+
* @param {number} scalar The scalar to multiply with.
|
|
560
|
+
* @param {Cartesian4} result The object onto which to store the result.
|
|
561
|
+
* @returns {Cartesian4} The modified result parameter.
|
|
562
|
+
*/
|
|
563
|
+
static multiplyByScalar(cartesian, scalar, result) {
|
|
564
|
+
//>>includeStart('debug', pragmas.debug);
|
|
565
|
+
Check.typeOf.object("cartesian", cartesian);
|
|
566
|
+
Check.typeOf.number("scalar", scalar);
|
|
567
|
+
Check.typeOf.object("result", result);
|
|
568
|
+
//>>includeEnd('debug');
|
|
489
569
|
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
*
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
* @returns {Cartesian4} The modified result parameter.
|
|
497
|
-
*/
|
|
498
|
-
Cartesian4.multiplyComponents = function (left, right, result) {
|
|
499
|
-
//>>includeStart('debug', pragmas.debug);
|
|
500
|
-
Check.typeOf.object("left", left);
|
|
501
|
-
Check.typeOf.object("right", right);
|
|
502
|
-
Check.typeOf.object("result", result);
|
|
503
|
-
//>>includeEnd('debug');
|
|
504
|
-
|
|
505
|
-
result.x = left.x * right.x;
|
|
506
|
-
result.y = left.y * right.y;
|
|
507
|
-
result.z = left.z * right.z;
|
|
508
|
-
result.w = left.w * right.w;
|
|
509
|
-
return result;
|
|
510
|
-
};
|
|
570
|
+
result.x = cartesian.x * scalar;
|
|
571
|
+
result.y = cartesian.y * scalar;
|
|
572
|
+
result.z = cartesian.z * scalar;
|
|
573
|
+
result.w = cartesian.w * scalar;
|
|
574
|
+
return result;
|
|
575
|
+
}
|
|
511
576
|
|
|
512
|
-
/**
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
result.x = left.x / right.x;
|
|
528
|
-
result.y = left.y / right.y;
|
|
529
|
-
result.z = left.z / right.z;
|
|
530
|
-
result.w = left.w / right.w;
|
|
531
|
-
return result;
|
|
532
|
-
};
|
|
577
|
+
/**
|
|
578
|
+
* Divides the provided Cartesian componentwise by the provided scalar.
|
|
579
|
+
*
|
|
580
|
+
* @param {Cartesian4} cartesian The Cartesian to be divided.
|
|
581
|
+
* @param {number} scalar The scalar to divide by.
|
|
582
|
+
* @param {Cartesian4} result The object onto which to store the result.
|
|
583
|
+
* @returns {Cartesian4} The modified result parameter.
|
|
584
|
+
*/
|
|
585
|
+
static divideByScalar(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');
|
|
533
591
|
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
* @returns {Cartesian4} The modified result parameter.
|
|
541
|
-
*/
|
|
542
|
-
Cartesian4.add = function (left, right, result) {
|
|
543
|
-
//>>includeStart('debug', pragmas.debug);
|
|
544
|
-
Check.typeOf.object("left", left);
|
|
545
|
-
Check.typeOf.object("right", right);
|
|
546
|
-
Check.typeOf.object("result", result);
|
|
547
|
-
//>>includeEnd('debug');
|
|
548
|
-
|
|
549
|
-
result.x = left.x + right.x;
|
|
550
|
-
result.y = left.y + right.y;
|
|
551
|
-
result.z = left.z + right.z;
|
|
552
|
-
result.w = left.w + right.w;
|
|
553
|
-
return result;
|
|
554
|
-
};
|
|
592
|
+
result.x = cartesian.x / scalar;
|
|
593
|
+
result.y = cartesian.y / scalar;
|
|
594
|
+
result.z = cartesian.z / scalar;
|
|
595
|
+
result.w = cartesian.w / scalar;
|
|
596
|
+
return result;
|
|
597
|
+
}
|
|
555
598
|
|
|
556
|
-
/**
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
Check.typeOf.object("result", result);
|
|
569
|
-
//>>includeEnd('debug');
|
|
570
|
-
|
|
571
|
-
result.x = left.x - right.x;
|
|
572
|
-
result.y = left.y - right.y;
|
|
573
|
-
result.z = left.z - right.z;
|
|
574
|
-
result.w = left.w - right.w;
|
|
575
|
-
return result;
|
|
576
|
-
};
|
|
599
|
+
/**
|
|
600
|
+
* Negates the provided Cartesian.
|
|
601
|
+
*
|
|
602
|
+
* @param {Cartesian4} cartesian The Cartesian to be negated.
|
|
603
|
+
* @param {Cartesian4} result The object onto which to store the result.
|
|
604
|
+
* @returns {Cartesian4} The modified result parameter.
|
|
605
|
+
*/
|
|
606
|
+
static negate(cartesian, result) {
|
|
607
|
+
//>>includeStart('debug', pragmas.debug);
|
|
608
|
+
Check.typeOf.object("cartesian", cartesian);
|
|
609
|
+
Check.typeOf.object("result", result);
|
|
610
|
+
//>>includeEnd('debug');
|
|
577
611
|
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
* @returns {Cartesian4} The modified result parameter.
|
|
585
|
-
*/
|
|
586
|
-
Cartesian4.multiplyByScalar = function (cartesian, scalar, result) {
|
|
587
|
-
//>>includeStart('debug', pragmas.debug);
|
|
588
|
-
Check.typeOf.object("cartesian", cartesian);
|
|
589
|
-
Check.typeOf.number("scalar", scalar);
|
|
590
|
-
Check.typeOf.object("result", result);
|
|
591
|
-
//>>includeEnd('debug');
|
|
592
|
-
|
|
593
|
-
result.x = cartesian.x * scalar;
|
|
594
|
-
result.y = cartesian.y * scalar;
|
|
595
|
-
result.z = cartesian.z * scalar;
|
|
596
|
-
result.w = cartesian.w * scalar;
|
|
597
|
-
return result;
|
|
598
|
-
};
|
|
612
|
+
result.x = -cartesian.x;
|
|
613
|
+
result.y = -cartesian.y;
|
|
614
|
+
result.z = -cartesian.z;
|
|
615
|
+
result.w = -cartesian.w;
|
|
616
|
+
return result;
|
|
617
|
+
}
|
|
599
618
|
|
|
600
|
-
/**
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
Check.typeOf.object("result", result);
|
|
613
|
-
//>>includeEnd('debug');
|
|
614
|
-
|
|
615
|
-
result.x = cartesian.x / scalar;
|
|
616
|
-
result.y = cartesian.y / scalar;
|
|
617
|
-
result.z = cartesian.z / scalar;
|
|
618
|
-
result.w = cartesian.w / scalar;
|
|
619
|
-
return result;
|
|
620
|
-
};
|
|
619
|
+
/**
|
|
620
|
+
* Computes the absolute value of the provided Cartesian.
|
|
621
|
+
*
|
|
622
|
+
* @param {Cartesian4} cartesian The Cartesian whose absolute value is to be computed.
|
|
623
|
+
* @param {Cartesian4} result The object onto which to store the result.
|
|
624
|
+
* @returns {Cartesian4} The modified result parameter.
|
|
625
|
+
*/
|
|
626
|
+
static abs(cartesian, result) {
|
|
627
|
+
//>>includeStart('debug', pragmas.debug);
|
|
628
|
+
Check.typeOf.object("cartesian", cartesian);
|
|
629
|
+
Check.typeOf.object("result", result);
|
|
630
|
+
//>>includeEnd('debug');
|
|
621
631
|
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
*/
|
|
629
|
-
Cartesian4.negate = function (cartesian, result) {
|
|
630
|
-
//>>includeStart('debug', pragmas.debug);
|
|
631
|
-
Check.typeOf.object("cartesian", cartesian);
|
|
632
|
-
Check.typeOf.object("result", result);
|
|
633
|
-
//>>includeEnd('debug');
|
|
634
|
-
|
|
635
|
-
result.x = -cartesian.x;
|
|
636
|
-
result.y = -cartesian.y;
|
|
637
|
-
result.z = -cartesian.z;
|
|
638
|
-
result.w = -cartesian.w;
|
|
639
|
-
return result;
|
|
640
|
-
};
|
|
632
|
+
result.x = Math.abs(cartesian.x);
|
|
633
|
+
result.y = Math.abs(cartesian.y);
|
|
634
|
+
result.z = Math.abs(cartesian.z);
|
|
635
|
+
result.w = Math.abs(cartesian.w);
|
|
636
|
+
return result;
|
|
637
|
+
}
|
|
641
638
|
|
|
642
|
-
/**
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
Cartesian4
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
result.w = Math.abs(cartesian.w);
|
|
659
|
-
return result;
|
|
660
|
-
};
|
|
639
|
+
/**
|
|
640
|
+
* Computes the linear interpolation or extrapolation at t using the provided cartesians.
|
|
641
|
+
*
|
|
642
|
+
* @param {Cartesian4} start The value corresponding to t at 0.0.
|
|
643
|
+
* @param {Cartesian4}end The value corresponding to t at 1.0.
|
|
644
|
+
* @param {number} t The point along t at which to interpolate.
|
|
645
|
+
* @param {Cartesian4} result The object onto which to store the result.
|
|
646
|
+
* @returns {Cartesian4} The modified result parameter.
|
|
647
|
+
*/
|
|
648
|
+
static lerp(start, end, t, result) {
|
|
649
|
+
//>>includeStart('debug', pragmas.debug);
|
|
650
|
+
Check.typeOf.object("start", start);
|
|
651
|
+
Check.typeOf.object("end", end);
|
|
652
|
+
Check.typeOf.number("t", t);
|
|
653
|
+
Check.typeOf.object("result", result);
|
|
654
|
+
//>>includeEnd('debug');
|
|
661
655
|
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
* @param {Cartesian4} start The value corresponding to t at 0.0.
|
|
667
|
-
* @param {Cartesian4}end The value corresponding to t at 1.0.
|
|
668
|
-
* @param {number} t The point along t at which to interpolate.
|
|
669
|
-
* @param {Cartesian4} result The object onto which to store the result.
|
|
670
|
-
* @returns {Cartesian4} The modified result parameter.
|
|
671
|
-
*/
|
|
672
|
-
Cartesian4.lerp = function (start, end, t, result) {
|
|
673
|
-
//>>includeStart('debug', pragmas.debug);
|
|
674
|
-
Check.typeOf.object("start", start);
|
|
675
|
-
Check.typeOf.object("end", end);
|
|
676
|
-
Check.typeOf.number("t", t);
|
|
677
|
-
Check.typeOf.object("result", result);
|
|
678
|
-
//>>includeEnd('debug');
|
|
679
|
-
|
|
680
|
-
Cartesian4.multiplyByScalar(end, t, lerpScratch);
|
|
681
|
-
result = Cartesian4.multiplyByScalar(start, 1.0 - t, result);
|
|
682
|
-
return Cartesian4.add(lerpScratch, result, result);
|
|
683
|
-
};
|
|
656
|
+
Cartesian4.multiplyByScalar(end, t, lerpScratch);
|
|
657
|
+
result = Cartesian4.multiplyByScalar(start, 1.0 - t, result);
|
|
658
|
+
return Cartesian4.add(lerpScratch, result, result);
|
|
659
|
+
}
|
|
684
660
|
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
661
|
+
/**
|
|
662
|
+
* Returns the axis that is most orthogonal to the provided Cartesian.
|
|
663
|
+
*
|
|
664
|
+
* @param {Cartesian4} cartesian The Cartesian on which to find the most orthogonal axis.
|
|
665
|
+
* @param {Cartesian4} result The object onto which to store the result.
|
|
666
|
+
* @returns {Cartesian4} The most orthogonal axis.
|
|
667
|
+
*/
|
|
668
|
+
static mostOrthogonalAxis(cartesian, result) {
|
|
669
|
+
//>>includeStart('debug', pragmas.debug);
|
|
670
|
+
Check.typeOf.object("cartesian", cartesian);
|
|
671
|
+
Check.typeOf.object("result", result);
|
|
672
|
+
//>>includeEnd('debug');
|
|
673
|
+
|
|
674
|
+
const f = Cartesian4.normalize(cartesian, mostOrthogonalAxisScratch);
|
|
675
|
+
Cartesian4.abs(f, f);
|
|
676
|
+
|
|
677
|
+
if (f.x <= f.y) {
|
|
678
|
+
if (f.x <= f.z) {
|
|
679
|
+
if (f.x <= f.w) {
|
|
680
|
+
result = Cartesian4.clone(Cartesian4.UNIT_X, result);
|
|
681
|
+
} else {
|
|
682
|
+
result = Cartesian4.clone(Cartesian4.UNIT_W, result);
|
|
683
|
+
}
|
|
684
|
+
} else if (f.z <= f.w) {
|
|
685
|
+
result = Cartesian4.clone(Cartesian4.UNIT_Z, result);
|
|
686
|
+
} else {
|
|
687
|
+
result = Cartesian4.clone(Cartesian4.UNIT_W, result);
|
|
688
|
+
}
|
|
689
|
+
} else if (f.y <= f.z) {
|
|
690
|
+
if (f.y <= f.w) {
|
|
691
|
+
result = Cartesian4.clone(Cartesian4.UNIT_Y, result);
|
|
706
692
|
} else {
|
|
707
693
|
result = Cartesian4.clone(Cartesian4.UNIT_W, result);
|
|
708
694
|
}
|
|
@@ -711,100 +697,231 @@ Cartesian4.mostOrthogonalAxis = function (cartesian, result) {
|
|
|
711
697
|
} else {
|
|
712
698
|
result = Cartesian4.clone(Cartesian4.UNIT_W, result);
|
|
713
699
|
}
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
700
|
+
|
|
701
|
+
return result;
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
/**
|
|
705
|
+
* Compares the provided Cartesians componentwise and returns
|
|
706
|
+
* <code>true</code> if they are equal, <code>false</code> otherwise.
|
|
707
|
+
*
|
|
708
|
+
* @param {Cartesian4} [left] The first Cartesian.
|
|
709
|
+
* @param {Cartesian4} [right] The second Cartesian.
|
|
710
|
+
* @returns {boolean} <code>true</code> if left and right are equal, <code>false</code> otherwise.
|
|
711
|
+
*/
|
|
712
|
+
static equals(left, right) {
|
|
713
|
+
return (
|
|
714
|
+
left === right ||
|
|
715
|
+
(defined(left) &&
|
|
716
|
+
defined(right) &&
|
|
717
|
+
left.x === right.x &&
|
|
718
|
+
left.y === right.y &&
|
|
719
|
+
left.z === right.z &&
|
|
720
|
+
left.w === right.w)
|
|
721
|
+
);
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
/**
|
|
725
|
+
* @param {Cartesian4} cartesian
|
|
726
|
+
* @param {number[]} array
|
|
727
|
+
* @param {number} offset
|
|
728
|
+
* @private
|
|
729
|
+
*/
|
|
730
|
+
static equalsArray(cartesian, array, offset) {
|
|
731
|
+
return (
|
|
732
|
+
cartesian.x === array[offset] &&
|
|
733
|
+
cartesian.y === array[offset + 1] &&
|
|
734
|
+
cartesian.z === array[offset + 2] &&
|
|
735
|
+
cartesian.w === array[offset + 3]
|
|
736
|
+
);
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
/**
|
|
740
|
+
* Compares the provided Cartesians componentwise and returns
|
|
741
|
+
* <code>true</code> if they pass an absolute or relative tolerance test,
|
|
742
|
+
* <code>false</code> otherwise.
|
|
743
|
+
*
|
|
744
|
+
* @param {Cartesian4} [left] The first Cartesian.
|
|
745
|
+
* @param {Cartesian4} [right] The second Cartesian.
|
|
746
|
+
* @param {number} [relativeEpsilon=0] The relative epsilon tolerance to use for equality testing.
|
|
747
|
+
* @param {number} [absoluteEpsilon=relativeEpsilon] The absolute epsilon tolerance to use for equality testing.
|
|
748
|
+
* @returns {boolean} <code>true</code> if left and right are within the provided epsilon, <code>false</code> otherwise.
|
|
749
|
+
*/
|
|
750
|
+
static equalsEpsilon(left, right, relativeEpsilon, absoluteEpsilon) {
|
|
751
|
+
return (
|
|
752
|
+
left === right ||
|
|
753
|
+
(defined(left) &&
|
|
754
|
+
defined(right) &&
|
|
755
|
+
CesiumMath.equalsEpsilon(
|
|
756
|
+
left.x,
|
|
757
|
+
right.x,
|
|
758
|
+
relativeEpsilon,
|
|
759
|
+
absoluteEpsilon,
|
|
760
|
+
) &&
|
|
761
|
+
CesiumMath.equalsEpsilon(
|
|
762
|
+
left.y,
|
|
763
|
+
right.y,
|
|
764
|
+
relativeEpsilon,
|
|
765
|
+
absoluteEpsilon,
|
|
766
|
+
) &&
|
|
767
|
+
CesiumMath.equalsEpsilon(
|
|
768
|
+
left.z,
|
|
769
|
+
right.z,
|
|
770
|
+
relativeEpsilon,
|
|
771
|
+
absoluteEpsilon,
|
|
772
|
+
) &&
|
|
773
|
+
CesiumMath.equalsEpsilon(
|
|
774
|
+
left.w,
|
|
775
|
+
right.w,
|
|
776
|
+
relativeEpsilon,
|
|
777
|
+
absoluteEpsilon,
|
|
778
|
+
))
|
|
779
|
+
);
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
/**
|
|
783
|
+
* Duplicates this Cartesian4 instance.
|
|
784
|
+
*
|
|
785
|
+
* @param {Cartesian4} [result] The object onto which to store the result.
|
|
786
|
+
* @returns {Cartesian4} The modified result parameter or a new Cartesian4 instance if one was not provided.
|
|
787
|
+
*/
|
|
788
|
+
clone(result) {
|
|
789
|
+
return Cartesian4.clone(this, result);
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
/**
|
|
793
|
+
* Compares this Cartesian against the provided Cartesian componentwise and returns
|
|
794
|
+
* <code>true</code> if they are equal, <code>false</code> otherwise.
|
|
795
|
+
*
|
|
796
|
+
* @param {Cartesian4} [right] The right hand side Cartesian.
|
|
797
|
+
* @returns {boolean} <code>true</code> if they are equal, <code>false</code> otherwise.
|
|
798
|
+
*/
|
|
799
|
+
equals(right) {
|
|
800
|
+
return Cartesian4.equals(this, right);
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
/**
|
|
804
|
+
* Compares this Cartesian against the provided Cartesian componentwise and returns
|
|
805
|
+
* <code>true</code> if they pass an absolute or relative tolerance test,
|
|
806
|
+
* <code>false</code> otherwise.
|
|
807
|
+
*
|
|
808
|
+
* @param {Cartesian4} [right] The right hand side Cartesian.
|
|
809
|
+
* @param {number} [relativeEpsilon=0] The relative epsilon tolerance to use for equality testing.
|
|
810
|
+
* @param {number} [absoluteEpsilon=relativeEpsilon] The absolute epsilon tolerance to use for equality testing.
|
|
811
|
+
* @returns {boolean} <code>true</code> if they are within the provided epsilon, <code>false</code> otherwise.
|
|
812
|
+
*/
|
|
813
|
+
equalsEpsilon(right, relativeEpsilon, absoluteEpsilon) {
|
|
814
|
+
return Cartesian4.equalsEpsilon(
|
|
815
|
+
this,
|
|
816
|
+
right,
|
|
817
|
+
relativeEpsilon,
|
|
818
|
+
absoluteEpsilon,
|
|
819
|
+
);
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
/**
|
|
823
|
+
* Creates a string representing this Cartesian in the format '(x, y, z, w)'.
|
|
824
|
+
*
|
|
825
|
+
* @returns {string} A string representing the provided Cartesian in the format '(x, y, z, w)'.
|
|
826
|
+
*/
|
|
827
|
+
toString() {
|
|
828
|
+
return `(${this.x}, ${this.y}, ${this.z}, ${this.w})`;
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
/**
|
|
832
|
+
* Packs an arbitrary floating point value to 4 values representable using uint8.
|
|
833
|
+
*
|
|
834
|
+
* @param {number} value A floating point number.
|
|
835
|
+
* @param {Cartesian4} [result] The Cartesian4 that will contain the packed float.
|
|
836
|
+
* @returns {Cartesian4} A Cartesian4 representing the float packed to values in x, y, z, and w.
|
|
837
|
+
*/
|
|
838
|
+
static packFloat(value, result) {
|
|
839
|
+
//>>includeStart('debug', pragmas.debug);
|
|
840
|
+
Check.typeOf.number("value", value);
|
|
841
|
+
//>>includeEnd('debug');
|
|
842
|
+
|
|
843
|
+
if (!defined(result)) {
|
|
844
|
+
result = new Cartesian4();
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
// scratchU8Array and scratchF32Array are views into the same buffer
|
|
848
|
+
scratchF32Array[0] = value;
|
|
849
|
+
|
|
850
|
+
if (littleEndian) {
|
|
851
|
+
result.x = scratchU8Array[0];
|
|
852
|
+
result.y = scratchU8Array[1];
|
|
853
|
+
result.z = scratchU8Array[2];
|
|
854
|
+
result.w = scratchU8Array[3];
|
|
717
855
|
} else {
|
|
718
|
-
|
|
856
|
+
// convert from big-endian to little-endian
|
|
857
|
+
result.x = scratchU8Array[3];
|
|
858
|
+
result.y = scratchU8Array[2];
|
|
859
|
+
result.z = scratchU8Array[1];
|
|
860
|
+
result.w = scratchU8Array[0];
|
|
719
861
|
}
|
|
720
|
-
|
|
721
|
-
result = Cartesian4.clone(Cartesian4.UNIT_Z, result);
|
|
722
|
-
} else {
|
|
723
|
-
result = Cartesian4.clone(Cartesian4.UNIT_W, result);
|
|
862
|
+
return result;
|
|
724
863
|
}
|
|
725
864
|
|
|
726
|
-
|
|
727
|
-
|
|
865
|
+
/**
|
|
866
|
+
* Unpacks a float packed using Cartesian4.packFloat.
|
|
867
|
+
*
|
|
868
|
+
* @param {Cartesian4} packedFloat A Cartesian4 containing a float packed to 4 values representable using uint8.
|
|
869
|
+
* @returns {number} The unpacked float.
|
|
870
|
+
* @private
|
|
871
|
+
*/
|
|
872
|
+
static unpackFloat(packedFloat) {
|
|
873
|
+
//>>includeStart('debug', pragmas.debug);
|
|
874
|
+
Check.typeOf.object("packedFloat", packedFloat);
|
|
875
|
+
//>>includeEnd('debug');
|
|
728
876
|
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
left.w === right.w)
|
|
746
|
-
);
|
|
747
|
-
};
|
|
877
|
+
// scratchU8Array and scratchF32Array are views into the same buffer
|
|
878
|
+
if (littleEndian) {
|
|
879
|
+
scratchU8Array[0] = packedFloat.x;
|
|
880
|
+
scratchU8Array[1] = packedFloat.y;
|
|
881
|
+
scratchU8Array[2] = packedFloat.z;
|
|
882
|
+
scratchU8Array[3] = packedFloat.w;
|
|
883
|
+
} else {
|
|
884
|
+
// convert from little-endian to big-endian
|
|
885
|
+
scratchU8Array[0] = packedFloat.w;
|
|
886
|
+
scratchU8Array[1] = packedFloat.z;
|
|
887
|
+
scratchU8Array[2] = packedFloat.y;
|
|
888
|
+
scratchU8Array[3] = packedFloat.x;
|
|
889
|
+
}
|
|
890
|
+
return scratchF32Array[0];
|
|
891
|
+
}
|
|
892
|
+
}
|
|
748
893
|
|
|
749
894
|
/**
|
|
750
|
-
*
|
|
895
|
+
* The number of elements used to pack the object into an array.
|
|
896
|
+
* @type {number}
|
|
751
897
|
*/
|
|
752
|
-
Cartesian4.
|
|
753
|
-
return (
|
|
754
|
-
cartesian.x === array[offset] &&
|
|
755
|
-
cartesian.y === array[offset + 1] &&
|
|
756
|
-
cartesian.z === array[offset + 2] &&
|
|
757
|
-
cartesian.w === array[offset + 3]
|
|
758
|
-
);
|
|
759
|
-
};
|
|
898
|
+
Cartesian4.packedLength = 4;
|
|
760
899
|
|
|
761
900
|
/**
|
|
762
|
-
*
|
|
763
|
-
*
|
|
764
|
-
*
|
|
901
|
+
* Creates a Cartesian4 from four consecutive elements in an array.
|
|
902
|
+
* @function
|
|
903
|
+
*
|
|
904
|
+
* @param {number[]} array The array whose four consecutive elements correspond to the x, y, z, and w components, respectively.
|
|
905
|
+
* @param {number} [startingIndex=0] The offset into the array of the first element, which corresponds to the x component.
|
|
906
|
+
* @param {Cartesian4} [result] The object onto which to store the result.
|
|
907
|
+
* @returns {Cartesian4} The modified result parameter or a new Cartesian4 instance if one was not provided.
|
|
908
|
+
*
|
|
909
|
+
* @example
|
|
910
|
+
* // Create a Cartesian4 with (1.0, 2.0, 3.0, 4.0)
|
|
911
|
+
* const v = [1.0, 2.0, 3.0, 4.0];
|
|
912
|
+
* const p = Cesium.Cartesian4.fromArray(v);
|
|
765
913
|
*
|
|
766
|
-
*
|
|
767
|
-
*
|
|
768
|
-
*
|
|
769
|
-
* @param {number} [absoluteEpsilon=relativeEpsilon] The absolute epsilon tolerance to use for equality testing.
|
|
770
|
-
* @returns {boolean} <code>true</code> if left and right are within the provided epsilon, <code>false</code> otherwise.
|
|
914
|
+
* // Create a Cartesian4 with (1.0, 2.0, 3.0, 4.0) using an offset into an array
|
|
915
|
+
* const v2 = [0.0, 0.0, 1.0, 2.0, 3.0, 4.0];
|
|
916
|
+
* const p2 = Cesium.Cartesian4.fromArray(v2, 2);
|
|
771
917
|
*/
|
|
772
|
-
Cartesian4.
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
left === right ||
|
|
780
|
-
(defined(left) &&
|
|
781
|
-
defined(right) &&
|
|
782
|
-
CesiumMath.equalsEpsilon(
|
|
783
|
-
left.x,
|
|
784
|
-
right.x,
|
|
785
|
-
relativeEpsilon,
|
|
786
|
-
absoluteEpsilon,
|
|
787
|
-
) &&
|
|
788
|
-
CesiumMath.equalsEpsilon(
|
|
789
|
-
left.y,
|
|
790
|
-
right.y,
|
|
791
|
-
relativeEpsilon,
|
|
792
|
-
absoluteEpsilon,
|
|
793
|
-
) &&
|
|
794
|
-
CesiumMath.equalsEpsilon(
|
|
795
|
-
left.z,
|
|
796
|
-
right.z,
|
|
797
|
-
relativeEpsilon,
|
|
798
|
-
absoluteEpsilon,
|
|
799
|
-
) &&
|
|
800
|
-
CesiumMath.equalsEpsilon(
|
|
801
|
-
left.w,
|
|
802
|
-
right.w,
|
|
803
|
-
relativeEpsilon,
|
|
804
|
-
absoluteEpsilon,
|
|
805
|
-
))
|
|
806
|
-
);
|
|
807
|
-
};
|
|
918
|
+
Cartesian4.fromArray = Cartesian4.unpack;
|
|
919
|
+
|
|
920
|
+
const distanceScratch = new Cartesian4();
|
|
921
|
+
|
|
922
|
+
const lerpScratch = new Cartesian4();
|
|
923
|
+
|
|
924
|
+
const mostOrthogonalAxisScratch = new Cartesian4();
|
|
808
925
|
|
|
809
926
|
/**
|
|
810
927
|
* An immutable Cartesian4 instance initialized to (0.0, 0.0, 0.0, 0.0).
|
|
@@ -854,59 +971,6 @@ Cartesian4.UNIT_Z = Object.freeze(new Cartesian4(0.0, 0.0, 1.0, 0.0));
|
|
|
854
971
|
*/
|
|
855
972
|
Cartesian4.UNIT_W = Object.freeze(new Cartesian4(0.0, 0.0, 0.0, 1.0));
|
|
856
973
|
|
|
857
|
-
/**
|
|
858
|
-
* Duplicates this Cartesian4 instance.
|
|
859
|
-
*
|
|
860
|
-
* @param {Cartesian4} [result] The object onto which to store the result.
|
|
861
|
-
* @returns {Cartesian4} The modified result parameter or a new Cartesian4 instance if one was not provided.
|
|
862
|
-
*/
|
|
863
|
-
Cartesian4.prototype.clone = function (result) {
|
|
864
|
-
return Cartesian4.clone(this, result);
|
|
865
|
-
};
|
|
866
|
-
|
|
867
|
-
/**
|
|
868
|
-
* Compares this Cartesian against the provided Cartesian componentwise and returns
|
|
869
|
-
* <code>true</code> if they are equal, <code>false</code> otherwise.
|
|
870
|
-
*
|
|
871
|
-
* @param {Cartesian4} [right] The right hand side Cartesian.
|
|
872
|
-
* @returns {boolean} <code>true</code> if they are equal, <code>false</code> otherwise.
|
|
873
|
-
*/
|
|
874
|
-
Cartesian4.prototype.equals = function (right) {
|
|
875
|
-
return Cartesian4.equals(this, right);
|
|
876
|
-
};
|
|
877
|
-
|
|
878
|
-
/**
|
|
879
|
-
* Compares this Cartesian against the provided Cartesian componentwise and returns
|
|
880
|
-
* <code>true</code> if they pass an absolute or relative tolerance test,
|
|
881
|
-
* <code>false</code> otherwise.
|
|
882
|
-
*
|
|
883
|
-
* @param {Cartesian4} [right] The right hand side Cartesian.
|
|
884
|
-
* @param {number} [relativeEpsilon=0] The relative epsilon tolerance to use for equality testing.
|
|
885
|
-
* @param {number} [absoluteEpsilon=relativeEpsilon] The absolute epsilon tolerance to use for equality testing.
|
|
886
|
-
* @returns {boolean} <code>true</code> if they are within the provided epsilon, <code>false</code> otherwise.
|
|
887
|
-
*/
|
|
888
|
-
Cartesian4.prototype.equalsEpsilon = function (
|
|
889
|
-
right,
|
|
890
|
-
relativeEpsilon,
|
|
891
|
-
absoluteEpsilon,
|
|
892
|
-
) {
|
|
893
|
-
return Cartesian4.equalsEpsilon(
|
|
894
|
-
this,
|
|
895
|
-
right,
|
|
896
|
-
relativeEpsilon,
|
|
897
|
-
absoluteEpsilon,
|
|
898
|
-
);
|
|
899
|
-
};
|
|
900
|
-
|
|
901
|
-
/**
|
|
902
|
-
* Creates a string representing this Cartesian in the format '(x, y, z, w)'.
|
|
903
|
-
*
|
|
904
|
-
* @returns {string} A string representing the provided Cartesian in the format '(x, y, z, w)'.
|
|
905
|
-
*/
|
|
906
|
-
Cartesian4.prototype.toString = function () {
|
|
907
|
-
return `(${this.x}, ${this.y}, ${this.z}, ${this.w})`;
|
|
908
|
-
};
|
|
909
|
-
|
|
910
974
|
// scratchU8Array and scratchF32Array are views into the same buffer
|
|
911
975
|
const scratchF32Array = new Float32Array(1);
|
|
912
976
|
const scratchU8Array = new Uint8Array(scratchF32Array.buffer);
|
|
@@ -915,65 +979,4 @@ const testU32 = new Uint32Array([0x11223344]);
|
|
|
915
979
|
const testU8 = new Uint8Array(testU32.buffer);
|
|
916
980
|
const littleEndian = testU8[0] === 0x44;
|
|
917
981
|
|
|
918
|
-
/**
|
|
919
|
-
* Packs an arbitrary floating point value to 4 values representable using uint8.
|
|
920
|
-
*
|
|
921
|
-
* @param {number} value A floating point number.
|
|
922
|
-
* @param {Cartesian4} [result] The Cartesian4 that will contain the packed float.
|
|
923
|
-
* @returns {Cartesian4} A Cartesian4 representing the float packed to values in x, y, z, and w.
|
|
924
|
-
*/
|
|
925
|
-
Cartesian4.packFloat = function (value, result) {
|
|
926
|
-
//>>includeStart('debug', pragmas.debug);
|
|
927
|
-
Check.typeOf.number("value", value);
|
|
928
|
-
//>>includeEnd('debug');
|
|
929
|
-
|
|
930
|
-
if (!defined(result)) {
|
|
931
|
-
result = new Cartesian4();
|
|
932
|
-
}
|
|
933
|
-
|
|
934
|
-
// scratchU8Array and scratchF32Array are views into the same buffer
|
|
935
|
-
scratchF32Array[0] = value;
|
|
936
|
-
|
|
937
|
-
if (littleEndian) {
|
|
938
|
-
result.x = scratchU8Array[0];
|
|
939
|
-
result.y = scratchU8Array[1];
|
|
940
|
-
result.z = scratchU8Array[2];
|
|
941
|
-
result.w = scratchU8Array[3];
|
|
942
|
-
} else {
|
|
943
|
-
// convert from big-endian to little-endian
|
|
944
|
-
result.x = scratchU8Array[3];
|
|
945
|
-
result.y = scratchU8Array[2];
|
|
946
|
-
result.z = scratchU8Array[1];
|
|
947
|
-
result.w = scratchU8Array[0];
|
|
948
|
-
}
|
|
949
|
-
return result;
|
|
950
|
-
};
|
|
951
|
-
|
|
952
|
-
/**
|
|
953
|
-
* Unpacks a float packed using Cartesian4.packFloat.
|
|
954
|
-
*
|
|
955
|
-
* @param {Cartesian4} packedFloat A Cartesian4 containing a float packed to 4 values representable using uint8.
|
|
956
|
-
* @returns {number} The unpacked float.
|
|
957
|
-
* @private
|
|
958
|
-
*/
|
|
959
|
-
Cartesian4.unpackFloat = function (packedFloat) {
|
|
960
|
-
//>>includeStart('debug', pragmas.debug);
|
|
961
|
-
Check.typeOf.object("packedFloat", packedFloat);
|
|
962
|
-
//>>includeEnd('debug');
|
|
963
|
-
|
|
964
|
-
// scratchU8Array and scratchF32Array are views into the same buffer
|
|
965
|
-
if (littleEndian) {
|
|
966
|
-
scratchU8Array[0] = packedFloat.x;
|
|
967
|
-
scratchU8Array[1] = packedFloat.y;
|
|
968
|
-
scratchU8Array[2] = packedFloat.z;
|
|
969
|
-
scratchU8Array[3] = packedFloat.w;
|
|
970
|
-
} else {
|
|
971
|
-
// convert from little-endian to big-endian
|
|
972
|
-
scratchU8Array[0] = packedFloat.w;
|
|
973
|
-
scratchU8Array[1] = packedFloat.z;
|
|
974
|
-
scratchU8Array[2] = packedFloat.y;
|
|
975
|
-
scratchU8Array[3] = packedFloat.x;
|
|
976
|
-
}
|
|
977
|
-
return scratchF32Array[0];
|
|
978
|
-
};
|
|
979
982
|
export default Cartesian4;
|