@cesium/engine 22.3.0 → 23.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (193) hide show
  1. package/Build/Workers/{chunk-XLIJV3YZ.js → chunk-2M7DKGLW.js} +10 -10
  2. package/Build/Workers/{chunk-AFGP5BXS.js → chunk-2OBWHTIC.js} +7 -7
  3. package/Build/Workers/{chunk-K4PGSAR5.js → chunk-3UQ2YMPP.js} +8 -8
  4. package/Build/Workers/{chunk-W5NV72VR.js → chunk-4JJQRZYL.js} +17 -17
  5. package/Build/Workers/{chunk-EUDHHS7K.js → chunk-54O3AGOA.js} +6 -6
  6. package/Build/Workers/{chunk-MASEF4OV.js → chunk-66OWUDO7.js} +8 -8
  7. package/Build/Workers/{chunk-E4YDCSQK.js → chunk-6U5QMZU3.js} +9 -9
  8. package/Build/Workers/{chunk-FDOLXORR.js → chunk-77DJBHMI.js} +7 -7
  9. package/Build/Workers/{chunk-PJLRXIMS.js → chunk-ALTCIHRH.js} +17 -17
  10. package/Build/Workers/{chunk-FUDC3KOT.js → chunk-B2VA6IEL.js} +5 -5
  11. package/Build/Workers/{chunk-7U5YNLF3.js → chunk-BTP3634E.js} +1 -1
  12. package/Build/Workers/{chunk-EY5HOJFQ.js → chunk-C6HHBKT5.js} +5 -5
  13. package/Build/Workers/{chunk-K2PLKJJG.js → chunk-CID5SY7L.js} +5 -5
  14. package/Build/Workers/{chunk-YHPBT4I5.js → chunk-CJ7ZDY77.js} +5 -5
  15. package/Build/Workers/{chunk-NVL7JXAQ.js → chunk-CNLXMOPM.js} +10 -10
  16. package/Build/Workers/{chunk-IHFAFGR2.js → chunk-CVAAIRNP.js} +2 -2
  17. package/Build/Workers/{chunk-IXL46IYV.js → chunk-CYOPNGPX.js} +12 -12
  18. package/Build/Workers/{chunk-6GBGEUWR.js → chunk-DNMASBMH.js} +2 -2
  19. package/Build/Workers/{chunk-NO3LMU7T.js → chunk-EIC3VAOZ.js} +7 -7
  20. package/Build/Workers/{chunk-S2KVL7OJ.js → chunk-FCJQO4NC.js} +8 -8
  21. package/Build/Workers/{chunk-TMGLPEZW.js → chunk-FKU77FNM.js} +4 -4
  22. package/Build/Workers/{chunk-EOSX23OS.js → chunk-FXSRA5UG.js} +4 -4
  23. package/Build/Workers/{chunk-D2PEV362.js → chunk-G6MJ3ZW3.js} +10 -10
  24. package/Build/Workers/{chunk-2MLJ46ZZ.js → chunk-GLCPE2BJ.js} +13 -13
  25. package/Build/Workers/{chunk-N66PIK46.js → chunk-H3TVRJLY.js} +4 -4
  26. package/Build/Workers/chunk-HNDE73JK.js +1829 -0
  27. package/Build/Workers/{chunk-4R6FGUFP.js → chunk-HXEPZWJN.js} +29 -15
  28. package/Build/Workers/{chunk-4BBANFU6.js → chunk-IJ3SUMK3.js} +1 -1
  29. package/Build/Workers/{chunk-4O2ARYS7.js → chunk-JUKGMJX7.js} +1 -1
  30. package/Build/Workers/{chunk-OOYICVOK.js → chunk-K7UTK4OM.js} +1 -1
  31. package/Build/Workers/{chunk-WUWPKBOZ.js → chunk-LHFC4R7Z.js} +6 -6
  32. package/Build/Workers/{chunk-T5MJDW43.js → chunk-MNSNOONX.js} +7 -7
  33. package/Build/Workers/{chunk-FS42VX2H.js → chunk-N6HRZLS6.js} +2 -2
  34. package/Build/Workers/{chunk-HWGP4GVC.js → chunk-O67UP5YO.js} +13 -13
  35. package/Build/Workers/{chunk-EAAH543Q.js → chunk-OZYB3AOR.js} +11 -11
  36. package/Build/Workers/{chunk-LWZHJWYK.js → chunk-PAFMAR7A.js} +665 -366
  37. package/Build/Workers/{chunk-VRAAQ3FS.js → chunk-PBECJOWF.js} +2 -2
  38. package/Build/Workers/{chunk-VIQIKMTZ.js → chunk-PGZ3B6CB.js} +14 -14
  39. package/Build/Workers/{chunk-KIJR26N3.js → chunk-PQTSXJBJ.js} +16 -16
  40. package/Build/Workers/{chunk-TY5JXMVO.js → chunk-PUO7BYDY.js} +1 -1
  41. package/Build/Workers/{chunk-6WDMPXQ7.js → chunk-QNABVTTP.js} +12 -12
  42. package/Build/Workers/{chunk-7ATKQRBM.js → chunk-QPXGGVHC.js} +10 -10
  43. package/Build/Workers/{chunk-5PJB7ASO.js → chunk-RZX6LOG6.js} +6 -6
  44. package/Build/Workers/{chunk-N6XBJBI7.js → chunk-S53HSRT6.js} +6 -6
  45. package/Build/Workers/{chunk-Y5MRBKQN.js → chunk-TFPG3ZKW.js} +18 -18
  46. package/Build/Workers/{chunk-AWELU5C6.js → chunk-TMCTZ5E3.js} +14 -14
  47. package/Build/Workers/{chunk-ZGGVEGTA.js → chunk-TNXOPEIG.js} +12 -12
  48. package/Build/Workers/{chunk-BO22JHBX.js → chunk-TXYQNXNW.js} +3 -3
  49. package/Build/Workers/{chunk-TCOUGKXF.js → chunk-U4SWB6TI.js} +4 -4
  50. package/Build/Workers/{chunk-D6OKR3BQ.js → chunk-UEWYSOFD.js} +2 -2
  51. package/Build/Workers/{chunk-7SLNBIZS.js → chunk-UOQB7XQI.js} +560 -277
  52. package/Build/Workers/{chunk-ZWWN2CQH.js → chunk-VPWYHFQA.js} +4 -4
  53. package/Build/Workers/{chunk-M5DVYXJJ.js → chunk-VX774SWE.js} +6 -6
  54. package/Build/Workers/{chunk-WHLGBMBC.js → chunk-XPMXRJDD.js} +5 -5
  55. package/Build/Workers/{chunk-L4OFWHNI.js → chunk-YDR5LX5Z.js} +1 -1
  56. package/Build/Workers/{chunk-LK7GEFGB.js → chunk-YSJRB2UZ.js} +2 -2
  57. package/Build/Workers/{chunk-D63Z7KKL.js → chunk-ZEMJQKHD.js} +11 -11
  58. package/Build/Workers/combineGeometry.js +24 -24
  59. package/Build/Workers/createBoxGeometry.js +18 -18
  60. package/Build/Workers/createBoxOutlineGeometry.js +16 -16
  61. package/Build/Workers/createCircleGeometry.js +26 -26
  62. package/Build/Workers/createCircleOutlineGeometry.js +19 -19
  63. package/Build/Workers/createCoplanarPolygonGeometry.js +33 -33
  64. package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +31 -31
  65. package/Build/Workers/createCorridorGeometry.js +29 -29
  66. package/Build/Workers/createCorridorOutlineGeometry.js +28 -28
  67. package/Build/Workers/createCylinderGeometry.js +20 -20
  68. package/Build/Workers/createCylinderOutlineGeometry.js +18 -18
  69. package/Build/Workers/createEllipseGeometry.js +26 -26
  70. package/Build/Workers/createEllipseOutlineGeometry.js +19 -19
  71. package/Build/Workers/createEllipsoidGeometry.js +19 -19
  72. package/Build/Workers/createEllipsoidOutlineGeometry.js +18 -18
  73. package/Build/Workers/createFrustumGeometry.js +18 -18
  74. package/Build/Workers/createFrustumOutlineGeometry.js +18 -18
  75. package/Build/Workers/createGeometry.js +24 -24
  76. package/Build/Workers/createGroundPolylineGeometry.js +22 -22
  77. package/Build/Workers/createPlaneGeometry.js +16 -16
  78. package/Build/Workers/createPlaneOutlineGeometry.js +15 -15
  79. package/Build/Workers/createPolygonGeometry.js +32 -32
  80. package/Build/Workers/createPolygonOutlineGeometry.js +30 -30
  81. package/Build/Workers/createPolylineGeometry.js +25 -25
  82. package/Build/Workers/createPolylineVolumeGeometry.js +31 -31
  83. package/Build/Workers/createPolylineVolumeOutlineGeometry.js +27 -27
  84. package/Build/Workers/createRectangleGeometry.js +27 -27
  85. package/Build/Workers/createRectangleOutlineGeometry.js +20 -20
  86. package/Build/Workers/createSimplePolylineGeometry.js +23 -23
  87. package/Build/Workers/createSphereGeometry.js +19 -19
  88. package/Build/Workers/createSphereOutlineGeometry.js +18 -18
  89. package/Build/Workers/createTaskProcessorWorker.js +3 -3
  90. package/Build/Workers/createVectorTileClampedPolylines.js +14 -14
  91. package/Build/Workers/createVectorTileGeometries.js +24 -24
  92. package/Build/Workers/createVectorTilePoints.js +13 -13
  93. package/Build/Workers/createVectorTilePolygons.js +22 -22
  94. package/Build/Workers/createVectorTilePolylines.js +14 -14
  95. package/Build/Workers/createVerticesFromCesium3DTilesTerrain.js +25 -25
  96. package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +22 -22
  97. package/Build/Workers/createVerticesFromHeightmap.js +22 -22
  98. package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +20 -20
  99. package/Build/Workers/createWallGeometry.js +24 -24
  100. package/Build/Workers/createWallOutlineGeometry.js +23 -23
  101. package/Build/Workers/decodeDraco.js +10 -10
  102. package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +5 -5
  103. package/Build/Workers/decodeI3S.js +10 -10
  104. package/Build/Workers/gaussianSplatSorter.js +4 -4
  105. package/Build/Workers/gaussianSplatTextureGenerator.js +4 -4
  106. package/Build/Workers/incrementallyBuildTerrainPicker.js +10 -10
  107. package/Build/Workers/transcodeKTX2.js +6 -6
  108. package/Build/Workers/transferTypedArrayTest.js +1 -1
  109. package/Build/Workers/upsampleQuantizedTerrainMesh.js +22 -22
  110. package/Build/Workers/upsampleVerticesFromCesium3DTilesTerrain.js +25 -25
  111. package/Source/Core/AttributeCompression.js +53 -6
  112. package/Source/Core/Cartesian2.js +689 -684
  113. package/Source/Core/Cartesian3.js +1044 -1043
  114. package/Source/Core/Cartesian4.js +816 -813
  115. package/Source/Core/GoogleMaps.js +23 -2
  116. package/Source/Core/Ion.js +1 -1
  117. package/Source/Core/OpenCageGeocoderService.js +2 -3
  118. package/Source/Core/globalTypes.js +16 -0
  119. package/Source/Renderer/ShaderDestination.js +54 -13
  120. package/Source/Scene/ArcGisMapService.js +1 -1
  121. package/Source/Scene/Billboard.js +7 -4
  122. package/Source/Scene/BillboardCollection.js +64 -25
  123. package/Source/Scene/BufferLoader.js +65 -74
  124. package/Source/Scene/CubeMapPanorama.js +351 -0
  125. package/Source/Scene/DerivedCommand.js +8 -31
  126. package/Source/Scene/DracoLoader.js +79 -78
  127. package/Source/Scene/EquirectangularPanorama.js +264 -0
  128. package/Source/Scene/FrameState.js +7 -0
  129. package/Source/Scene/GaussianSplatPrimitive.js +906 -167
  130. package/Source/Scene/GlobeSurfaceShaderSet.js +36 -32
  131. package/Source/Scene/GltfBufferViewLoader.js +109 -118
  132. package/Source/Scene/GltfDracoLoader.js +167 -176
  133. package/Source/Scene/GltfImageLoader.js +91 -101
  134. package/Source/Scene/GltfIndexBufferLoader.js +228 -241
  135. package/Source/Scene/GltfJsonLoader.js +90 -99
  136. package/Source/Scene/GltfLoader.js +325 -324
  137. package/Source/Scene/GltfSpzLoader.js +127 -134
  138. package/Source/Scene/GltfStructuralMetadataLoader.js +181 -186
  139. package/Source/Scene/GltfTextureLoader.js +217 -231
  140. package/Source/Scene/GltfVertexBufferLoader.js +267 -276
  141. package/Source/Scene/GoogleStreetViewCubeMapPanoramaProvider.js +341 -0
  142. package/Source/Scene/Label.js +6 -4
  143. package/Source/Scene/LabelCollection.js +59 -1
  144. package/Source/Scene/MetadataClassProperty.js +212 -7
  145. package/Source/Scene/MetadataComponentType.js +162 -127
  146. package/Source/Scene/MetadataSchemaLoader.js +60 -67
  147. package/Source/Scene/MetadataTable.js +14 -0
  148. package/Source/Scene/MetadataTableProperty.js +14 -0
  149. package/Source/Scene/Model/B3dmLoader.js +216 -224
  150. package/Source/Scene/Model/CustomShader.js +6 -1
  151. package/Source/Scene/Model/CustomShaderPipelineStage.js +122 -7
  152. package/Source/Scene/Model/GeoJsonLoader.js +53 -61
  153. package/Source/Scene/Model/GeometryPipelineStage.js +17 -3
  154. package/Source/Scene/Model/I3dmLoader.js +232 -240
  155. package/Source/Scene/Model/MaterialPipelineStage.js +1 -1
  156. package/Source/Scene/Model/MetadataPipelineStage.js +438 -22
  157. package/Source/Scene/Model/PntsLoader.js +78 -89
  158. package/Source/Scene/Panorama.js +53 -0
  159. package/Source/Scene/PanoramaProvider.js +43 -0
  160. package/Source/Scene/PointPrimitiveCollection.js +14 -22
  161. package/Source/Scene/PropertyTable.js +43 -0
  162. package/Source/Scene/PropertyTexture.js +1 -1
  163. package/Source/Scene/PropertyTextureProperty.js +0 -97
  164. package/Source/Scene/ResourceLoader.js +84 -92
  165. package/Source/Scene/Scene.js +12 -0
  166. package/Source/Scene/SkyBox.js +29 -164
  167. package/Source/Scene/StructuralMetadata.js +18 -3
  168. package/Source/Scene/parseStructuralMetadata.js +244 -0
  169. package/Source/Shaders/BillboardCollectionFS.glsl +66 -40
  170. package/Source/Shaders/BillboardCollectionFS.js +67 -40
  171. package/Source/Shaders/BillboardCollectionVS.glsl +22 -31
  172. package/Source/Shaders/BillboardCollectionVS.js +22 -31
  173. package/Source/Shaders/Builtin/CzmBuiltins.js +4 -0
  174. package/Source/Shaders/Builtin/Functions/decodeRGB8.glsl +22 -0
  175. package/Source/Shaders/Builtin/Functions/decodeRGB8.js +24 -0
  176. package/Source/Shaders/Builtin/Functions/unpackTexture.glsl +35 -0
  177. package/Source/Shaders/Builtin/Functions/unpackTexture.js +37 -0
  178. package/Source/Shaders/CubeMapPanoramaVS.glsl +11 -0
  179. package/Source/Shaders/CubeMapPanoramaVS.js +13 -0
  180. package/Source/Shaders/Model/MetadataStageFS.glsl +2 -1
  181. package/Source/Shaders/Model/MetadataStageFS.js +2 -1
  182. package/Source/Shaders/Model/MetadataStageVS.glsl +2 -1
  183. package/Source/Shaders/Model/MetadataStageVS.js +2 -1
  184. package/Source/Shaders/Model/ModelFS.glsl +2 -2
  185. package/Source/Shaders/Model/ModelFS.js +2 -2
  186. package/Source/Shaders/Model/ModelVS.glsl +2 -2
  187. package/Source/Shaders/Model/ModelVS.js +2 -2
  188. package/Source/Shaders/PointPrimitiveCollectionVS.glsl +8 -39
  189. package/Source/Shaders/PointPrimitiveCollectionVS.js +8 -39
  190. package/index.d.ts +564 -189
  191. package/index.js +83 -75
  192. package/package.json +1 -1
  193. package/Build/Workers/chunk-LYBNPUEI.js +0 -1443
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @license
3
3
  * Cesium - https://github.com/CesiumGS/cesium
4
- * Version 1.138.0
4
+ * Version 1.139.1
5
5
  *
6
6
  * Copyright 2011-2022 Cesium Contributors
7
7
  *
@@ -25,415 +25,714 @@
25
25
 
26
26
  import {
27
27
  RuntimeError_default
28
- } from "./chunk-VRAAQ3FS.js";
28
+ } from "./chunk-PBECJOWF.js";
29
29
  import {
30
30
  Cartesian3_default,
31
31
  Frozen_default,
32
32
  Matrix3_default
33
- } from "./chunk-LYBNPUEI.js";
33
+ } from "./chunk-HNDE73JK.js";
34
34
  import {
35
35
  Math_default
36
- } from "./chunk-BO22JHBX.js";
36
+ } from "./chunk-TXYQNXNW.js";
37
37
  import {
38
38
  Check_default,
39
39
  DeveloperError_default
40
- } from "./chunk-FS42VX2H.js";
40
+ } from "./chunk-N6HRZLS6.js";
41
41
  import {
42
42
  defined_default
43
- } from "./chunk-7U5YNLF3.js";
43
+ } from "./chunk-BTP3634E.js";
44
44
 
45
45
  // packages/engine/Source/Core/Cartesian4.js
46
- function Cartesian4(x, y, z, w) {
47
- this.x = x ?? 0;
48
- this.y = y ?? 0;
49
- this.z = z ?? 0;
50
- this.w = w ?? 0;
51
- }
52
- Cartesian4.fromElements = function(x, y, z, w, result) {
53
- if (!defined_default(result)) {
54
- return new Cartesian4(x, y, z, w);
46
+ var Cartesian4 = class _Cartesian4 {
47
+ /**
48
+ * @param {number} [x=0.0] The X component.
49
+ * @param {number} [y=0.0] The Y component.
50
+ * @param {number} [z=0.0] The Z component.
51
+ * @param {number} [w=0.0] The W component.
52
+ */
53
+ constructor(x, y, z, w) {
54
+ this.x = x ?? 0;
55
+ this.y = y ?? 0;
56
+ this.z = z ?? 0;
57
+ this.w = w ?? 0;
55
58
  }
56
- result.x = x;
57
- result.y = y;
58
- result.z = z;
59
- result.w = w;
60
- return result;
61
- };
62
- Cartesian4.fromColor = function(color, result) {
63
- Check_default.typeOf.object("color", color);
64
- if (!defined_default(result)) {
65
- return new Cartesian4(color.red, color.green, color.blue, color.alpha);
59
+ /**
60
+ * Creates a Cartesian4 instance from x, y, z and w coordinates.
61
+ *
62
+ * @param {number} x The x coordinate.
63
+ * @param {number} y The y coordinate.
64
+ * @param {number} z The z coordinate.
65
+ * @param {number} w The w coordinate.
66
+ * @param {Cartesian4} [result] The object onto which to store the result.
67
+ * @returns {Cartesian4} The modified result parameter or a new Cartesian4 instance if one was not provided.
68
+ */
69
+ static fromElements(x, y, z, w, result) {
70
+ if (!defined_default(result)) {
71
+ return new _Cartesian4(x, y, z, w);
72
+ }
73
+ result.x = x;
74
+ result.y = y;
75
+ result.z = z;
76
+ result.w = w;
77
+ return result;
66
78
  }
67
- result.x = color.red;
68
- result.y = color.green;
69
- result.z = color.blue;
70
- result.w = color.alpha;
71
- return result;
72
- };
73
- Cartesian4.clone = function(cartesian, result) {
74
- if (!defined_default(cartesian)) {
75
- return void 0;
79
+ /**
80
+ * Creates a Cartesian4 instance from a {@link Color}. <code>red</code>, <code>green</code>, <code>blue</code>,
81
+ * and <code>alpha</code> map to <code>x</code>, <code>y</code>, <code>z</code>, and <code>w</code>, respectively.
82
+ *
83
+ * @param {Color} color The source color.
84
+ * @param {Cartesian4} [result] The object onto which to store the result.
85
+ * @returns {Cartesian4} The modified result parameter or a new Cartesian4 instance if one was not provided.
86
+ */
87
+ static fromColor(color, result) {
88
+ Check_default.typeOf.object("color", color);
89
+ if (!defined_default(result)) {
90
+ return new _Cartesian4(color.red, color.green, color.blue, color.alpha);
91
+ }
92
+ result.x = color.red;
93
+ result.y = color.green;
94
+ result.z = color.blue;
95
+ result.w = color.alpha;
96
+ return result;
76
97
  }
77
- if (!defined_default(result)) {
78
- return new Cartesian4(cartesian.x, cartesian.y, cartesian.z, cartesian.w);
98
+ /**
99
+ * Duplicates a Cartesian4 instance.
100
+ *
101
+ * @param {Cartesian4} cartesian The Cartesian to duplicate.
102
+ * @param {Cartesian4} [result] The object onto which to store the result.
103
+ * @returns {Cartesian4} The modified result parameter or a new Cartesian4 instance if one was not provided. (Returns undefined if cartesian is undefined)
104
+ */
105
+ static clone(cartesian, result) {
106
+ if (!defined_default(cartesian)) {
107
+ return void 0;
108
+ }
109
+ if (!defined_default(result)) {
110
+ return new _Cartesian4(cartesian.x, cartesian.y, cartesian.z, cartesian.w);
111
+ }
112
+ result.x = cartesian.x;
113
+ result.y = cartesian.y;
114
+ result.z = cartesian.z;
115
+ result.w = cartesian.w;
116
+ return result;
79
117
  }
80
- result.x = cartesian.x;
81
- result.y = cartesian.y;
82
- result.z = cartesian.z;
83
- result.w = cartesian.w;
84
- return result;
85
- };
86
- Cartesian4.packedLength = 4;
87
- Cartesian4.pack = function(value, array, startingIndex) {
88
- Check_default.typeOf.object("value", value);
89
- Check_default.defined("array", array);
90
- startingIndex = startingIndex ?? 0;
91
- array[startingIndex++] = value.x;
92
- array[startingIndex++] = value.y;
93
- array[startingIndex++] = value.z;
94
- array[startingIndex] = value.w;
95
- return array;
96
- };
97
- Cartesian4.unpack = function(array, startingIndex, result) {
98
- Check_default.defined("array", array);
99
- startingIndex = startingIndex ?? 0;
100
- if (!defined_default(result)) {
101
- result = new Cartesian4();
118
+ /**
119
+ * Stores the provided instance into the provided array.
120
+ *
121
+ * @param {Cartesian4} value The value to pack.
122
+ * @param {number[]|TypedArray} array The array to pack into.
123
+ * @param {number} [startingIndex=0] The index into the array at which to start packing the elements.
124
+ *
125
+ * @returns {number[]|TypedArray} The array that was packed into
126
+ */
127
+ static pack(value, array, startingIndex) {
128
+ Check_default.typeOf.object("value", value);
129
+ Check_default.defined("array", array);
130
+ startingIndex = startingIndex ?? 0;
131
+ array[startingIndex++] = value.x;
132
+ array[startingIndex++] = value.y;
133
+ array[startingIndex++] = value.z;
134
+ array[startingIndex] = value.w;
135
+ return array;
102
136
  }
103
- result.x = array[startingIndex++];
104
- result.y = array[startingIndex++];
105
- result.z = array[startingIndex++];
106
- result.w = array[startingIndex];
107
- return result;
108
- };
109
- Cartesian4.packArray = function(array, result) {
110
- Check_default.defined("array", array);
111
- const length = array.length;
112
- const resultLength = length * 4;
113
- if (!defined_default(result)) {
114
- result = new Array(resultLength);
115
- } else if (!Array.isArray(result) && result.length !== resultLength) {
116
- throw new DeveloperError_default(
117
- "If result is a typed array, it must have exactly array.length * 4 elements"
118
- );
119
- } else if (result.length !== resultLength) {
120
- result.length = resultLength;
137
+ /**
138
+ * Retrieves an instance from a packed array.
139
+ *
140
+ * @param {number[]|TypedArray} array The packed array.
141
+ * @param {number} [startingIndex=0] The starting index of the element to be unpacked.
142
+ * @param {Cartesian4} [result] The object into which to store the result.
143
+ * @returns {Cartesian4} The modified result parameter or a new Cartesian4 instance if one was not provided.
144
+ */
145
+ static unpack(array, startingIndex, result) {
146
+ Check_default.defined("array", array);
147
+ startingIndex = startingIndex ?? 0;
148
+ if (!defined_default(result)) {
149
+ result = new _Cartesian4();
150
+ }
151
+ result.x = array[startingIndex++];
152
+ result.y = array[startingIndex++];
153
+ result.z = array[startingIndex++];
154
+ result.w = array[startingIndex];
155
+ return result;
121
156
  }
122
- for (let i = 0; i < length; ++i) {
123
- Cartesian4.pack(array[i], result, i * 4);
157
+ /**
158
+ * Flattens an array of Cartesian4s into an array of components.
159
+ *
160
+ * @param {Cartesian4[]} array The array of cartesians to pack.
161
+ * @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.
162
+ * @returns {number[]|TypedArray} The packed array.
163
+ */
164
+ static packArray(array, result) {
165
+ Check_default.defined("array", array);
166
+ const length = array.length;
167
+ const resultLength = length * 4;
168
+ if (!defined_default(result)) {
169
+ result = new Array(resultLength);
170
+ } else if (!Array.isArray(result) && result.length !== resultLength) {
171
+ throw new DeveloperError_default(
172
+ "If result is a typed array, it must have exactly array.length * 4 elements"
173
+ );
174
+ } else if (result.length !== resultLength) {
175
+ result.length = resultLength;
176
+ }
177
+ for (let i = 0; i < length; ++i) {
178
+ _Cartesian4.pack(array[i], result, i * 4);
179
+ }
180
+ return result;
124
181
  }
125
- return result;
126
- };
127
- Cartesian4.unpackArray = function(array, result) {
128
- Check_default.defined("array", array);
129
- Check_default.typeOf.number.greaterThanOrEquals("array.length", array.length, 4);
130
- if (array.length % 4 !== 0) {
131
- throw new DeveloperError_default("array length must be a multiple of 4.");
182
+ /**
183
+ * Unpacks an array of cartesian components into an array of Cartesian4s.
184
+ *
185
+ * @param {number[]|TypedArray} array The array of components to unpack.
186
+ * @param {Cartesian4[]} [result] The array onto which to store the result.
187
+ * @returns {Cartesian4[]} The unpacked array.
188
+ */
189
+ static unpackArray(array, result) {
190
+ Check_default.defined("array", array);
191
+ Check_default.typeOf.number.greaterThanOrEquals("array.length", array.length, 4);
192
+ if (array.length % 4 !== 0) {
193
+ throw new DeveloperError_default("array length must be a multiple of 4.");
194
+ }
195
+ const length = array.length;
196
+ if (!defined_default(result)) {
197
+ result = new Array(length / 4);
198
+ } else {
199
+ result.length = length / 4;
200
+ }
201
+ for (let i = 0; i < length; i += 4) {
202
+ const index = i / 4;
203
+ result[index] = _Cartesian4.unpack(array, i, result[index]);
204
+ }
205
+ return result;
132
206
  }
133
- const length = array.length;
134
- if (!defined_default(result)) {
135
- result = new Array(length / 4);
136
- } else {
137
- result.length = length / 4;
207
+ /**
208
+ * Computes the value of the maximum component for the supplied Cartesian.
209
+ *
210
+ * @param {Cartesian4} cartesian The cartesian to use.
211
+ * @returns {number} The value of the maximum component.
212
+ */
213
+ static maximumComponent(cartesian) {
214
+ Check_default.typeOf.object("cartesian", cartesian);
215
+ return Math.max(cartesian.x, cartesian.y, cartesian.z, cartesian.w);
138
216
  }
139
- for (let i = 0; i < length; i += 4) {
140
- const index = i / 4;
141
- result[index] = Cartesian4.unpack(array, i, result[index]);
217
+ /**
218
+ * Computes the value of the minimum component for the supplied Cartesian.
219
+ *
220
+ * @param {Cartesian4} cartesian The cartesian to use.
221
+ * @returns {number} The value of the minimum component.
222
+ */
223
+ static minimumComponent(cartesian) {
224
+ Check_default.typeOf.object("cartesian", cartesian);
225
+ return Math.min(cartesian.x, cartesian.y, cartesian.z, cartesian.w);
142
226
  }
143
- return result;
144
- };
145
- Cartesian4.fromArray = Cartesian4.unpack;
146
- Cartesian4.maximumComponent = function(cartesian) {
147
- Check_default.typeOf.object("cartesian", cartesian);
148
- return Math.max(cartesian.x, cartesian.y, cartesian.z, cartesian.w);
149
- };
150
- Cartesian4.minimumComponent = function(cartesian) {
151
- Check_default.typeOf.object("cartesian", cartesian);
152
- return Math.min(cartesian.x, cartesian.y, cartesian.z, cartesian.w);
153
- };
154
- Cartesian4.minimumByComponent = function(first, second, result) {
155
- Check_default.typeOf.object("first", first);
156
- Check_default.typeOf.object("second", second);
157
- Check_default.typeOf.object("result", result);
158
- result.x = Math.min(first.x, second.x);
159
- result.y = Math.min(first.y, second.y);
160
- result.z = Math.min(first.z, second.z);
161
- result.w = Math.min(first.w, second.w);
162
- return result;
163
- };
164
- Cartesian4.maximumByComponent = function(first, second, result) {
165
- Check_default.typeOf.object("first", first);
166
- Check_default.typeOf.object("second", second);
167
- Check_default.typeOf.object("result", result);
168
- result.x = Math.max(first.x, second.x);
169
- result.y = Math.max(first.y, second.y);
170
- result.z = Math.max(first.z, second.z);
171
- result.w = Math.max(first.w, second.w);
172
- return result;
173
- };
174
- Cartesian4.clamp = function(value, min, max, result) {
175
- Check_default.typeOf.object("value", value);
176
- Check_default.typeOf.object("min", min);
177
- Check_default.typeOf.object("max", max);
178
- Check_default.typeOf.object("result", result);
179
- const x = Math_default.clamp(value.x, min.x, max.x);
180
- const y = Math_default.clamp(value.y, min.y, max.y);
181
- const z = Math_default.clamp(value.z, min.z, max.z);
182
- const w = Math_default.clamp(value.w, min.w, max.w);
183
- result.x = x;
184
- result.y = y;
185
- result.z = z;
186
- result.w = w;
187
- return result;
188
- };
189
- Cartesian4.magnitudeSquared = function(cartesian) {
190
- Check_default.typeOf.object("cartesian", cartesian);
191
- return cartesian.x * cartesian.x + cartesian.y * cartesian.y + cartesian.z * cartesian.z + cartesian.w * cartesian.w;
192
- };
193
- Cartesian4.magnitude = function(cartesian) {
194
- return Math.sqrt(Cartesian4.magnitudeSquared(cartesian));
195
- };
196
- var distanceScratch = new Cartesian4();
197
- Cartesian4.distance = function(left, right) {
198
- Check_default.typeOf.object("left", left);
199
- Check_default.typeOf.object("right", right);
200
- Cartesian4.subtract(left, right, distanceScratch);
201
- return Cartesian4.magnitude(distanceScratch);
202
- };
203
- Cartesian4.distanceSquared = function(left, right) {
204
- Check_default.typeOf.object("left", left);
205
- Check_default.typeOf.object("right", right);
206
- Cartesian4.subtract(left, right, distanceScratch);
207
- return Cartesian4.magnitudeSquared(distanceScratch);
208
- };
209
- Cartesian4.normalize = function(cartesian, result) {
210
- Check_default.typeOf.object("cartesian", cartesian);
211
- Check_default.typeOf.object("result", result);
212
- const magnitude = Cartesian4.magnitude(cartesian);
213
- result.x = cartesian.x / magnitude;
214
- result.y = cartesian.y / magnitude;
215
- result.z = cartesian.z / magnitude;
216
- result.w = cartesian.w / magnitude;
217
- if (isNaN(result.x) || isNaN(result.y) || isNaN(result.z) || isNaN(result.w)) {
218
- throw new DeveloperError_default("normalized result is not a number");
227
+ /**
228
+ * Compares two Cartesians and computes a Cartesian which contains the minimum components of the supplied Cartesians.
229
+ *
230
+ * @param {Cartesian4} first A cartesian to compare.
231
+ * @param {Cartesian4} second A cartesian to compare.
232
+ * @param {Cartesian4} result The object into which to store the result.
233
+ * @returns {Cartesian4} A cartesian with the minimum components.
234
+ */
235
+ static minimumByComponent(first, second, result) {
236
+ Check_default.typeOf.object("first", first);
237
+ Check_default.typeOf.object("second", second);
238
+ Check_default.typeOf.object("result", result);
239
+ result.x = Math.min(first.x, second.x);
240
+ result.y = Math.min(first.y, second.y);
241
+ result.z = Math.min(first.z, second.z);
242
+ result.w = Math.min(first.w, second.w);
243
+ return result;
219
244
  }
220
- return result;
221
- };
222
- Cartesian4.dot = function(left, right) {
223
- Check_default.typeOf.object("left", left);
224
- Check_default.typeOf.object("right", right);
225
- return left.x * right.x + left.y * right.y + left.z * right.z + left.w * right.w;
226
- };
227
- Cartesian4.multiplyComponents = function(left, right, result) {
228
- Check_default.typeOf.object("left", left);
229
- Check_default.typeOf.object("right", right);
230
- Check_default.typeOf.object("result", result);
231
- result.x = left.x * right.x;
232
- result.y = left.y * right.y;
233
- result.z = left.z * right.z;
234
- result.w = left.w * right.w;
235
- return result;
236
- };
237
- Cartesian4.divideComponents = function(left, right, result) {
238
- Check_default.typeOf.object("left", left);
239
- Check_default.typeOf.object("right", right);
240
- Check_default.typeOf.object("result", result);
241
- result.x = left.x / right.x;
242
- result.y = left.y / right.y;
243
- result.z = left.z / right.z;
244
- result.w = left.w / right.w;
245
- return result;
246
- };
247
- Cartesian4.add = function(left, right, result) {
248
- Check_default.typeOf.object("left", left);
249
- Check_default.typeOf.object("right", right);
250
- Check_default.typeOf.object("result", result);
251
- result.x = left.x + right.x;
252
- result.y = left.y + right.y;
253
- result.z = left.z + right.z;
254
- result.w = left.w + right.w;
255
- return result;
256
- };
257
- Cartesian4.subtract = function(left, right, result) {
258
- Check_default.typeOf.object("left", left);
259
- Check_default.typeOf.object("right", right);
260
- Check_default.typeOf.object("result", result);
261
- result.x = left.x - right.x;
262
- result.y = left.y - right.y;
263
- result.z = left.z - right.z;
264
- result.w = left.w - right.w;
265
- return result;
266
- };
267
- Cartesian4.multiplyByScalar = function(cartesian, scalar, result) {
268
- Check_default.typeOf.object("cartesian", cartesian);
269
- Check_default.typeOf.number("scalar", scalar);
270
- Check_default.typeOf.object("result", result);
271
- result.x = cartesian.x * scalar;
272
- result.y = cartesian.y * scalar;
273
- result.z = cartesian.z * scalar;
274
- result.w = cartesian.w * scalar;
275
- return result;
276
- };
277
- Cartesian4.divideByScalar = function(cartesian, scalar, result) {
278
- Check_default.typeOf.object("cartesian", cartesian);
279
- Check_default.typeOf.number("scalar", scalar);
280
- Check_default.typeOf.object("result", result);
281
- result.x = cartesian.x / scalar;
282
- result.y = cartesian.y / scalar;
283
- result.z = cartesian.z / scalar;
284
- result.w = cartesian.w / scalar;
285
- return result;
286
- };
287
- Cartesian4.negate = function(cartesian, result) {
288
- Check_default.typeOf.object("cartesian", cartesian);
289
- Check_default.typeOf.object("result", result);
290
- result.x = -cartesian.x;
291
- result.y = -cartesian.y;
292
- result.z = -cartesian.z;
293
- result.w = -cartesian.w;
294
- return result;
295
- };
296
- Cartesian4.abs = function(cartesian, result) {
297
- Check_default.typeOf.object("cartesian", cartesian);
298
- Check_default.typeOf.object("result", result);
299
- result.x = Math.abs(cartesian.x);
300
- result.y = Math.abs(cartesian.y);
301
- result.z = Math.abs(cartesian.z);
302
- result.w = Math.abs(cartesian.w);
303
- return result;
304
- };
305
- var lerpScratch = new Cartesian4();
306
- Cartesian4.lerp = function(start, end, t, result) {
307
- Check_default.typeOf.object("start", start);
308
- Check_default.typeOf.object("end", end);
309
- Check_default.typeOf.number("t", t);
310
- Check_default.typeOf.object("result", result);
311
- Cartesian4.multiplyByScalar(end, t, lerpScratch);
312
- result = Cartesian4.multiplyByScalar(start, 1 - t, result);
313
- return Cartesian4.add(lerpScratch, result, result);
314
- };
315
- var mostOrthogonalAxisScratch = new Cartesian4();
316
- Cartesian4.mostOrthogonalAxis = function(cartesian, result) {
317
- Check_default.typeOf.object("cartesian", cartesian);
318
- Check_default.typeOf.object("result", result);
319
- const f = Cartesian4.normalize(cartesian, mostOrthogonalAxisScratch);
320
- Cartesian4.abs(f, f);
321
- if (f.x <= f.y) {
322
- if (f.x <= f.z) {
323
- if (f.x <= f.w) {
324
- result = Cartesian4.clone(Cartesian4.UNIT_X, result);
245
+ /**
246
+ * Compares two Cartesians and computes a Cartesian which contains the maximum components of the supplied Cartesians.
247
+ *
248
+ * @param {Cartesian4} first A cartesian to compare.
249
+ * @param {Cartesian4} second A cartesian to compare.
250
+ * @param {Cartesian4} result The object into which to store the result.
251
+ * @returns {Cartesian4} A cartesian with the maximum components.
252
+ */
253
+ static maximumByComponent(first, second, result) {
254
+ Check_default.typeOf.object("first", first);
255
+ Check_default.typeOf.object("second", second);
256
+ Check_default.typeOf.object("result", result);
257
+ result.x = Math.max(first.x, second.x);
258
+ result.y = Math.max(first.y, second.y);
259
+ result.z = Math.max(first.z, second.z);
260
+ result.w = Math.max(first.w, second.w);
261
+ return result;
262
+ }
263
+ /**
264
+ * Constrain a value to lie between two values.
265
+ *
266
+ * @param {Cartesian4} value The value to clamp.
267
+ * @param {Cartesian4} min The minimum bound.
268
+ * @param {Cartesian4} max The maximum bound.
269
+ * @param {Cartesian4} result The object into which to store the result.
270
+ * @returns {Cartesian4} The clamped value such that min <= result <= max.
271
+ */
272
+ static clamp(value, min, max, result) {
273
+ Check_default.typeOf.object("value", value);
274
+ Check_default.typeOf.object("min", min);
275
+ Check_default.typeOf.object("max", max);
276
+ Check_default.typeOf.object("result", result);
277
+ const x = Math_default.clamp(value.x, min.x, max.x);
278
+ const y = Math_default.clamp(value.y, min.y, max.y);
279
+ const z = Math_default.clamp(value.z, min.z, max.z);
280
+ const w = Math_default.clamp(value.w, min.w, max.w);
281
+ result.x = x;
282
+ result.y = y;
283
+ result.z = z;
284
+ result.w = w;
285
+ return result;
286
+ }
287
+ /**
288
+ * Computes the provided Cartesian's squared magnitude.
289
+ *
290
+ * @param {Cartesian4} cartesian The Cartesian instance whose squared magnitude is to be computed.
291
+ * @returns {number} The squared magnitude.
292
+ */
293
+ static magnitudeSquared(cartesian) {
294
+ Check_default.typeOf.object("cartesian", cartesian);
295
+ return cartesian.x * cartesian.x + cartesian.y * cartesian.y + cartesian.z * cartesian.z + cartesian.w * cartesian.w;
296
+ }
297
+ /**
298
+ * Computes the Cartesian's magnitude (length).
299
+ *
300
+ * @param {Cartesian4} cartesian The Cartesian instance whose magnitude is to be computed.
301
+ * @returns {number} The magnitude.
302
+ */
303
+ static magnitude(cartesian) {
304
+ return Math.sqrt(_Cartesian4.magnitudeSquared(cartesian));
305
+ }
306
+ /**
307
+ * Computes the 4-space distance between two points.
308
+ *
309
+ * @param {Cartesian4} left The first point to compute the distance from.
310
+ * @param {Cartesian4} right The second point to compute the distance to.
311
+ * @returns {number} The distance between two points.
312
+ *
313
+ * @example
314
+ * // Returns 1.0
315
+ * const d = Cesium.Cartesian4.distance(
316
+ * new Cesium.Cartesian4(1.0, 0.0, 0.0, 0.0),
317
+ * new Cesium.Cartesian4(2.0, 0.0, 0.0, 0.0));
318
+ */
319
+ static distance(left, right) {
320
+ Check_default.typeOf.object("left", left);
321
+ Check_default.typeOf.object("right", right);
322
+ _Cartesian4.subtract(left, right, distanceScratch);
323
+ return _Cartesian4.magnitude(distanceScratch);
324
+ }
325
+ /**
326
+ * Computes the squared distance between two points. Comparing squared distances
327
+ * using this function is more efficient than comparing distances using {@link Cartesian4#distance}.
328
+ *
329
+ * @param {Cartesian4} left The first point to compute the distance from.
330
+ * @param {Cartesian4} right The second point to compute the distance to.
331
+ * @returns {number} The distance between two points.
332
+ *
333
+ * @example
334
+ * // Returns 4.0, not 2.0
335
+ * const d = Cesium.Cartesian4.distance(
336
+ * new Cesium.Cartesian4(1.0, 0.0, 0.0, 0.0),
337
+ * new Cesium.Cartesian4(3.0, 0.0, 0.0, 0.0));
338
+ */
339
+ static distanceSquared(left, right) {
340
+ Check_default.typeOf.object("left", left);
341
+ Check_default.typeOf.object("right", right);
342
+ _Cartesian4.subtract(left, right, distanceScratch);
343
+ return _Cartesian4.magnitudeSquared(distanceScratch);
344
+ }
345
+ /**
346
+ * Computes the normalized form of the supplied Cartesian.
347
+ *
348
+ * @param {Cartesian4} cartesian The Cartesian to be normalized.
349
+ * @param {Cartesian4} result The object onto which to store the result.
350
+ * @returns {Cartesian4} The modified result parameter.
351
+ */
352
+ static normalize(cartesian, result) {
353
+ Check_default.typeOf.object("cartesian", cartesian);
354
+ Check_default.typeOf.object("result", result);
355
+ const magnitude = _Cartesian4.magnitude(cartesian);
356
+ result.x = cartesian.x / magnitude;
357
+ result.y = cartesian.y / magnitude;
358
+ result.z = cartesian.z / magnitude;
359
+ result.w = cartesian.w / magnitude;
360
+ if (isNaN(result.x) || isNaN(result.y) || isNaN(result.z) || isNaN(result.w)) {
361
+ throw new DeveloperError_default("normalized result is not a number");
362
+ }
363
+ return result;
364
+ }
365
+ /**
366
+ * Computes the dot (scalar) product of two Cartesians.
367
+ *
368
+ * @param {Cartesian4} left The first Cartesian.
369
+ * @param {Cartesian4} right The second Cartesian.
370
+ * @returns {number} The dot product.
371
+ */
372
+ static dot(left, right) {
373
+ Check_default.typeOf.object("left", left);
374
+ Check_default.typeOf.object("right", right);
375
+ return left.x * right.x + left.y * right.y + left.z * right.z + left.w * right.w;
376
+ }
377
+ /**
378
+ * Computes the componentwise product of two Cartesians.
379
+ *
380
+ * @param {Cartesian4} left The first Cartesian.
381
+ * @param {Cartesian4} right The second Cartesian.
382
+ * @param {Cartesian4} result The object onto which to store the result.
383
+ * @returns {Cartesian4} The modified result parameter.
384
+ */
385
+ static multiplyComponents(left, right, result) {
386
+ Check_default.typeOf.object("left", left);
387
+ Check_default.typeOf.object("right", right);
388
+ Check_default.typeOf.object("result", result);
389
+ result.x = left.x * right.x;
390
+ result.y = left.y * right.y;
391
+ result.z = left.z * right.z;
392
+ result.w = left.w * right.w;
393
+ return result;
394
+ }
395
+ /**
396
+ * Computes the componentwise quotient of two Cartesians.
397
+ *
398
+ * @param {Cartesian4} left The first Cartesian.
399
+ * @param {Cartesian4} right The second Cartesian.
400
+ * @param {Cartesian4} result The object onto which to store the result.
401
+ * @returns {Cartesian4} The modified result parameter.
402
+ */
403
+ static divideComponents(left, right, result) {
404
+ Check_default.typeOf.object("left", left);
405
+ Check_default.typeOf.object("right", right);
406
+ Check_default.typeOf.object("result", result);
407
+ result.x = left.x / right.x;
408
+ result.y = left.y / right.y;
409
+ result.z = left.z / right.z;
410
+ result.w = left.w / right.w;
411
+ return result;
412
+ }
413
+ /**
414
+ * Computes the componentwise sum of two Cartesians.
415
+ *
416
+ * @param {Cartesian4} left The first Cartesian.
417
+ * @param {Cartesian4} right The second Cartesian.
418
+ * @param {Cartesian4} result The object onto which to store the result.
419
+ * @returns {Cartesian4} The modified result parameter.
420
+ */
421
+ static add(left, right, result) {
422
+ Check_default.typeOf.object("left", left);
423
+ Check_default.typeOf.object("right", right);
424
+ Check_default.typeOf.object("result", result);
425
+ result.x = left.x + right.x;
426
+ result.y = left.y + right.y;
427
+ result.z = left.z + right.z;
428
+ result.w = left.w + right.w;
429
+ return result;
430
+ }
431
+ /**
432
+ * Computes the componentwise difference of two Cartesians.
433
+ *
434
+ * @param {Cartesian4} left The first Cartesian.
435
+ * @param {Cartesian4} right The second Cartesian.
436
+ * @param {Cartesian4} result The object onto which to store the result.
437
+ * @returns {Cartesian4} The modified result parameter.
438
+ */
439
+ static subtract(left, right, result) {
440
+ Check_default.typeOf.object("left", left);
441
+ Check_default.typeOf.object("right", right);
442
+ Check_default.typeOf.object("result", result);
443
+ result.x = left.x - right.x;
444
+ result.y = left.y - right.y;
445
+ result.z = left.z - right.z;
446
+ result.w = left.w - right.w;
447
+ return result;
448
+ }
449
+ /**
450
+ * Multiplies the provided Cartesian componentwise by the provided scalar.
451
+ *
452
+ * @param {Cartesian4} cartesian The Cartesian to be scaled.
453
+ * @param {number} scalar The scalar to multiply with.
454
+ * @param {Cartesian4} result The object onto which to store the result.
455
+ * @returns {Cartesian4} The modified result parameter.
456
+ */
457
+ static multiplyByScalar(cartesian, scalar, result) {
458
+ Check_default.typeOf.object("cartesian", cartesian);
459
+ Check_default.typeOf.number("scalar", scalar);
460
+ Check_default.typeOf.object("result", result);
461
+ result.x = cartesian.x * scalar;
462
+ result.y = cartesian.y * scalar;
463
+ result.z = cartesian.z * scalar;
464
+ result.w = cartesian.w * scalar;
465
+ return result;
466
+ }
467
+ /**
468
+ * Divides the provided Cartesian componentwise by the provided scalar.
469
+ *
470
+ * @param {Cartesian4} cartesian The Cartesian to be divided.
471
+ * @param {number} scalar The scalar to divide by.
472
+ * @param {Cartesian4} result The object onto which to store the result.
473
+ * @returns {Cartesian4} The modified result parameter.
474
+ */
475
+ static divideByScalar(cartesian, scalar, result) {
476
+ Check_default.typeOf.object("cartesian", cartesian);
477
+ Check_default.typeOf.number("scalar", scalar);
478
+ Check_default.typeOf.object("result", result);
479
+ result.x = cartesian.x / scalar;
480
+ result.y = cartesian.y / scalar;
481
+ result.z = cartesian.z / scalar;
482
+ result.w = cartesian.w / scalar;
483
+ return result;
484
+ }
485
+ /**
486
+ * Negates the provided Cartesian.
487
+ *
488
+ * @param {Cartesian4} cartesian The Cartesian to be negated.
489
+ * @param {Cartesian4} result The object onto which to store the result.
490
+ * @returns {Cartesian4} The modified result parameter.
491
+ */
492
+ static negate(cartesian, result) {
493
+ Check_default.typeOf.object("cartesian", cartesian);
494
+ Check_default.typeOf.object("result", result);
495
+ result.x = -cartesian.x;
496
+ result.y = -cartesian.y;
497
+ result.z = -cartesian.z;
498
+ result.w = -cartesian.w;
499
+ return result;
500
+ }
501
+ /**
502
+ * Computes the absolute value of the provided Cartesian.
503
+ *
504
+ * @param {Cartesian4} cartesian The Cartesian whose absolute value is to be computed.
505
+ * @param {Cartesian4} result The object onto which to store the result.
506
+ * @returns {Cartesian4} The modified result parameter.
507
+ */
508
+ static abs(cartesian, result) {
509
+ Check_default.typeOf.object("cartesian", cartesian);
510
+ Check_default.typeOf.object("result", result);
511
+ result.x = Math.abs(cartesian.x);
512
+ result.y = Math.abs(cartesian.y);
513
+ result.z = Math.abs(cartesian.z);
514
+ result.w = Math.abs(cartesian.w);
515
+ return result;
516
+ }
517
+ /**
518
+ * Computes the linear interpolation or extrapolation at t using the provided cartesians.
519
+ *
520
+ * @param {Cartesian4} start The value corresponding to t at 0.0.
521
+ * @param {Cartesian4}end The value corresponding to t at 1.0.
522
+ * @param {number} t The point along t at which to interpolate.
523
+ * @param {Cartesian4} result The object onto which to store the result.
524
+ * @returns {Cartesian4} The modified result parameter.
525
+ */
526
+ static lerp(start, end, t, result) {
527
+ Check_default.typeOf.object("start", start);
528
+ Check_default.typeOf.object("end", end);
529
+ Check_default.typeOf.number("t", t);
530
+ Check_default.typeOf.object("result", result);
531
+ _Cartesian4.multiplyByScalar(end, t, lerpScratch);
532
+ result = _Cartesian4.multiplyByScalar(start, 1 - t, result);
533
+ return _Cartesian4.add(lerpScratch, result, result);
534
+ }
535
+ /**
536
+ * Returns the axis that is most orthogonal to the provided Cartesian.
537
+ *
538
+ * @param {Cartesian4} cartesian The Cartesian on which to find the most orthogonal axis.
539
+ * @param {Cartesian4} result The object onto which to store the result.
540
+ * @returns {Cartesian4} The most orthogonal axis.
541
+ */
542
+ static mostOrthogonalAxis(cartesian, result) {
543
+ Check_default.typeOf.object("cartesian", cartesian);
544
+ Check_default.typeOf.object("result", result);
545
+ const f = _Cartesian4.normalize(cartesian, mostOrthogonalAxisScratch);
546
+ _Cartesian4.abs(f, f);
547
+ if (f.x <= f.y) {
548
+ if (f.x <= f.z) {
549
+ if (f.x <= f.w) {
550
+ result = _Cartesian4.clone(_Cartesian4.UNIT_X, result);
551
+ } else {
552
+ result = _Cartesian4.clone(_Cartesian4.UNIT_W, result);
553
+ }
554
+ } else if (f.z <= f.w) {
555
+ result = _Cartesian4.clone(_Cartesian4.UNIT_Z, result);
325
556
  } else {
326
- result = Cartesian4.clone(Cartesian4.UNIT_W, result);
557
+ result = _Cartesian4.clone(_Cartesian4.UNIT_W, result);
558
+ }
559
+ } else if (f.y <= f.z) {
560
+ if (f.y <= f.w) {
561
+ result = _Cartesian4.clone(_Cartesian4.UNIT_Y, result);
562
+ } else {
563
+ result = _Cartesian4.clone(_Cartesian4.UNIT_W, result);
327
564
  }
328
565
  } else if (f.z <= f.w) {
329
- result = Cartesian4.clone(Cartesian4.UNIT_Z, result);
566
+ result = _Cartesian4.clone(_Cartesian4.UNIT_Z, result);
330
567
  } else {
331
- result = Cartesian4.clone(Cartesian4.UNIT_W, result);
568
+ result = _Cartesian4.clone(_Cartesian4.UNIT_W, result);
332
569
  }
333
- } else if (f.y <= f.z) {
334
- if (f.y <= f.w) {
335
- result = Cartesian4.clone(Cartesian4.UNIT_Y, result);
570
+ return result;
571
+ }
572
+ /**
573
+ * Compares the provided Cartesians componentwise and returns
574
+ * <code>true</code> if they are equal, <code>false</code> otherwise.
575
+ *
576
+ * @param {Cartesian4} [left] The first Cartesian.
577
+ * @param {Cartesian4} [right] The second Cartesian.
578
+ * @returns {boolean} <code>true</code> if left and right are equal, <code>false</code> otherwise.
579
+ */
580
+ static equals(left, right) {
581
+ return left === right || defined_default(left) && defined_default(right) && left.x === right.x && left.y === right.y && left.z === right.z && left.w === right.w;
582
+ }
583
+ /**
584
+ * @param {Cartesian4} cartesian
585
+ * @param {number[]} array
586
+ * @param {number} offset
587
+ * @private
588
+ */
589
+ static equalsArray(cartesian, array, offset) {
590
+ return cartesian.x === array[offset] && cartesian.y === array[offset + 1] && cartesian.z === array[offset + 2] && cartesian.w === array[offset + 3];
591
+ }
592
+ /**
593
+ * Compares the provided Cartesians componentwise and returns
594
+ * <code>true</code> if they pass an absolute or relative tolerance test,
595
+ * <code>false</code> otherwise.
596
+ *
597
+ * @param {Cartesian4} [left] The first Cartesian.
598
+ * @param {Cartesian4} [right] The second Cartesian.
599
+ * @param {number} [relativeEpsilon=0] The relative epsilon tolerance to use for equality testing.
600
+ * @param {number} [absoluteEpsilon=relativeEpsilon] The absolute epsilon tolerance to use for equality testing.
601
+ * @returns {boolean} <code>true</code> if left and right are within the provided epsilon, <code>false</code> otherwise.
602
+ */
603
+ static equalsEpsilon(left, right, relativeEpsilon, absoluteEpsilon) {
604
+ return left === right || defined_default(left) && defined_default(right) && Math_default.equalsEpsilon(
605
+ left.x,
606
+ right.x,
607
+ relativeEpsilon,
608
+ absoluteEpsilon
609
+ ) && Math_default.equalsEpsilon(
610
+ left.y,
611
+ right.y,
612
+ relativeEpsilon,
613
+ absoluteEpsilon
614
+ ) && Math_default.equalsEpsilon(
615
+ left.z,
616
+ right.z,
617
+ relativeEpsilon,
618
+ absoluteEpsilon
619
+ ) && Math_default.equalsEpsilon(
620
+ left.w,
621
+ right.w,
622
+ relativeEpsilon,
623
+ absoluteEpsilon
624
+ );
625
+ }
626
+ /**
627
+ * Duplicates this Cartesian4 instance.
628
+ *
629
+ * @param {Cartesian4} [result] The object onto which to store the result.
630
+ * @returns {Cartesian4} The modified result parameter or a new Cartesian4 instance if one was not provided.
631
+ */
632
+ clone(result) {
633
+ return _Cartesian4.clone(this, result);
634
+ }
635
+ /**
636
+ * Compares this Cartesian against the provided Cartesian componentwise and returns
637
+ * <code>true</code> if they are equal, <code>false</code> otherwise.
638
+ *
639
+ * @param {Cartesian4} [right] The right hand side Cartesian.
640
+ * @returns {boolean} <code>true</code> if they are equal, <code>false</code> otherwise.
641
+ */
642
+ equals(right) {
643
+ return _Cartesian4.equals(this, right);
644
+ }
645
+ /**
646
+ * Compares this Cartesian against the provided Cartesian componentwise and returns
647
+ * <code>true</code> if they pass an absolute or relative tolerance test,
648
+ * <code>false</code> otherwise.
649
+ *
650
+ * @param {Cartesian4} [right] The right hand side Cartesian.
651
+ * @param {number} [relativeEpsilon=0] The relative epsilon tolerance to use for equality testing.
652
+ * @param {number} [absoluteEpsilon=relativeEpsilon] The absolute epsilon tolerance to use for equality testing.
653
+ * @returns {boolean} <code>true</code> if they are within the provided epsilon, <code>false</code> otherwise.
654
+ */
655
+ equalsEpsilon(right, relativeEpsilon, absoluteEpsilon) {
656
+ return _Cartesian4.equalsEpsilon(
657
+ this,
658
+ right,
659
+ relativeEpsilon,
660
+ absoluteEpsilon
661
+ );
662
+ }
663
+ /**
664
+ * Creates a string representing this Cartesian in the format '(x, y, z, w)'.
665
+ *
666
+ * @returns {string} A string representing the provided Cartesian in the format '(x, y, z, w)'.
667
+ */
668
+ toString() {
669
+ return `(${this.x}, ${this.y}, ${this.z}, ${this.w})`;
670
+ }
671
+ /**
672
+ * Packs an arbitrary floating point value to 4 values representable using uint8.
673
+ *
674
+ * @param {number} value A floating point number.
675
+ * @param {Cartesian4} [result] The Cartesian4 that will contain the packed float.
676
+ * @returns {Cartesian4} A Cartesian4 representing the float packed to values in x, y, z, and w.
677
+ */
678
+ static packFloat(value, result) {
679
+ Check_default.typeOf.number("value", value);
680
+ if (!defined_default(result)) {
681
+ result = new _Cartesian4();
682
+ }
683
+ scratchF32Array[0] = value;
684
+ if (littleEndian) {
685
+ result.x = scratchU8Array[0];
686
+ result.y = scratchU8Array[1];
687
+ result.z = scratchU8Array[2];
688
+ result.w = scratchU8Array[3];
336
689
  } else {
337
- result = Cartesian4.clone(Cartesian4.UNIT_W, result);
690
+ result.x = scratchU8Array[3];
691
+ result.y = scratchU8Array[2];
692
+ result.z = scratchU8Array[1];
693
+ result.w = scratchU8Array[0];
338
694
  }
339
- } else if (f.z <= f.w) {
340
- result = Cartesian4.clone(Cartesian4.UNIT_Z, result);
341
- } else {
342
- result = Cartesian4.clone(Cartesian4.UNIT_W, result);
695
+ return result;
696
+ }
697
+ /**
698
+ * Unpacks a float packed using Cartesian4.packFloat.
699
+ *
700
+ * @param {Cartesian4} packedFloat A Cartesian4 containing a float packed to 4 values representable using uint8.
701
+ * @returns {number} The unpacked float.
702
+ * @private
703
+ */
704
+ static unpackFloat(packedFloat) {
705
+ Check_default.typeOf.object("packedFloat", packedFloat);
706
+ if (littleEndian) {
707
+ scratchU8Array[0] = packedFloat.x;
708
+ scratchU8Array[1] = packedFloat.y;
709
+ scratchU8Array[2] = packedFloat.z;
710
+ scratchU8Array[3] = packedFloat.w;
711
+ } else {
712
+ scratchU8Array[0] = packedFloat.w;
713
+ scratchU8Array[1] = packedFloat.z;
714
+ scratchU8Array[2] = packedFloat.y;
715
+ scratchU8Array[3] = packedFloat.x;
716
+ }
717
+ return scratchF32Array[0];
343
718
  }
344
- return result;
345
- };
346
- Cartesian4.equals = function(left, right) {
347
- return left === right || defined_default(left) && defined_default(right) && left.x === right.x && left.y === right.y && left.z === right.z && left.w === right.w;
348
- };
349
- Cartesian4.equalsArray = function(cartesian, array, offset) {
350
- return cartesian.x === array[offset] && cartesian.y === array[offset + 1] && cartesian.z === array[offset + 2] && cartesian.w === array[offset + 3];
351
- };
352
- Cartesian4.equalsEpsilon = function(left, right, relativeEpsilon, absoluteEpsilon) {
353
- return left === right || defined_default(left) && defined_default(right) && Math_default.equalsEpsilon(
354
- left.x,
355
- right.x,
356
- relativeEpsilon,
357
- absoluteEpsilon
358
- ) && Math_default.equalsEpsilon(
359
- left.y,
360
- right.y,
361
- relativeEpsilon,
362
- absoluteEpsilon
363
- ) && Math_default.equalsEpsilon(
364
- left.z,
365
- right.z,
366
- relativeEpsilon,
367
- absoluteEpsilon
368
- ) && Math_default.equalsEpsilon(
369
- left.w,
370
- right.w,
371
- relativeEpsilon,
372
- absoluteEpsilon
373
- );
374
719
  };
720
+ Cartesian4.packedLength = 4;
721
+ Cartesian4.fromArray = Cartesian4.unpack;
722
+ var distanceScratch = new Cartesian4();
723
+ var lerpScratch = new Cartesian4();
724
+ var mostOrthogonalAxisScratch = new Cartesian4();
375
725
  Cartesian4.ZERO = Object.freeze(new Cartesian4(0, 0, 0, 0));
376
726
  Cartesian4.ONE = Object.freeze(new Cartesian4(1, 1, 1, 1));
377
727
  Cartesian4.UNIT_X = Object.freeze(new Cartesian4(1, 0, 0, 0));
378
728
  Cartesian4.UNIT_Y = Object.freeze(new Cartesian4(0, 1, 0, 0));
379
729
  Cartesian4.UNIT_Z = Object.freeze(new Cartesian4(0, 0, 1, 0));
380
730
  Cartesian4.UNIT_W = Object.freeze(new Cartesian4(0, 0, 0, 1));
381
- Cartesian4.prototype.clone = function(result) {
382
- return Cartesian4.clone(this, result);
383
- };
384
- Cartesian4.prototype.equals = function(right) {
385
- return Cartesian4.equals(this, right);
386
- };
387
- Cartesian4.prototype.equalsEpsilon = function(right, relativeEpsilon, absoluteEpsilon) {
388
- return Cartesian4.equalsEpsilon(
389
- this,
390
- right,
391
- relativeEpsilon,
392
- absoluteEpsilon
393
- );
394
- };
395
- Cartesian4.prototype.toString = function() {
396
- return `(${this.x}, ${this.y}, ${this.z}, ${this.w})`;
397
- };
398
731
  var scratchF32Array = new Float32Array(1);
399
732
  var scratchU8Array = new Uint8Array(scratchF32Array.buffer);
400
733
  var testU32 = new Uint32Array([287454020]);
401
734
  var testU8 = new Uint8Array(testU32.buffer);
402
735
  var littleEndian = testU8[0] === 68;
403
- Cartesian4.packFloat = function(value, result) {
404
- Check_default.typeOf.number("value", value);
405
- if (!defined_default(result)) {
406
- result = new Cartesian4();
407
- }
408
- scratchF32Array[0] = value;
409
- if (littleEndian) {
410
- result.x = scratchU8Array[0];
411
- result.y = scratchU8Array[1];
412
- result.z = scratchU8Array[2];
413
- result.w = scratchU8Array[3];
414
- } else {
415
- result.x = scratchU8Array[3];
416
- result.y = scratchU8Array[2];
417
- result.z = scratchU8Array[1];
418
- result.w = scratchU8Array[0];
419
- }
420
- return result;
421
- };
422
- Cartesian4.unpackFloat = function(packedFloat) {
423
- Check_default.typeOf.object("packedFloat", packedFloat);
424
- if (littleEndian) {
425
- scratchU8Array[0] = packedFloat.x;
426
- scratchU8Array[1] = packedFloat.y;
427
- scratchU8Array[2] = packedFloat.z;
428
- scratchU8Array[3] = packedFloat.w;
429
- } else {
430
- scratchU8Array[0] = packedFloat.w;
431
- scratchU8Array[1] = packedFloat.z;
432
- scratchU8Array[2] = packedFloat.y;
433
- scratchU8Array[3] = packedFloat.x;
434
- }
435
- return scratchF32Array[0];
436
- };
437
736
  var Cartesian4_default = Cartesian4;
438
737
 
439
738
  // packages/engine/Source/Core/Matrix4.js