deeptwins-cesium-engine 0.1.2 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (219) hide show
  1. package/Build/Workers/chunk-2HWLF3FT.js +837 -0
  2. package/Build/Workers/chunk-2KXMJ5XS.js +3792 -0
  3. package/Build/Workers/chunk-2NPCLB3H.js +56 -0
  4. package/Build/Workers/chunk-2ZHQTIBH.js +1483 -0
  5. package/Build/Workers/chunk-3GLYOW63.js +352 -0
  6. package/Build/Workers/chunk-3L22KMPU.js +219 -0
  7. package/Build/Workers/chunk-3Q6V2B2I.js +73 -0
  8. package/Build/Workers/chunk-3QOKKRIG.js +387 -0
  9. package/Build/Workers/chunk-44YZFGRH.js +1800 -0
  10. package/Build/Workers/chunk-45VV4SBO.js +2342 -0
  11. package/Build/Workers/chunk-4EJ4AA2S.js +368 -0
  12. package/Build/Workers/chunk-4IJFHUL6.js +414 -0
  13. package/Build/Workers/chunk-4K3V5CGW.js +454 -0
  14. package/Build/Workers/chunk-4M4QL6KJ.js +305 -0
  15. package/Build/Workers/chunk-4YNRIEQ6.js +288 -0
  16. package/Build/Workers/chunk-56CVDPH5.js +352 -0
  17. package/Build/Workers/chunk-5CTAAPXH.js +1483 -0
  18. package/Build/Workers/chunk-5ISZ6NJD.js +102 -0
  19. package/Build/Workers/chunk-5SDHYIOS.js +56 -0
  20. package/Build/Workers/chunk-66TGUMCU.js +2719 -0
  21. package/Build/Workers/chunk-6EJMTDQJ.js +163 -0
  22. package/Build/Workers/chunk-6VWXYSMH.js +959 -0
  23. package/Build/Workers/chunk-6VZ7VB2Q.js +241 -0
  24. package/Build/Workers/chunk-7AMRE57Q.js +301 -0
  25. package/Build/Workers/chunk-7DH6C33H.js +398 -0
  26. package/Build/Workers/chunk-7VUS3FVE.js +38 -0
  27. package/Build/Workers/chunk-7Y3ZA6H3.js +198 -0
  28. package/Build/Workers/chunk-A6BMHZNA.js +38 -0
  29. package/Build/Workers/chunk-A7XY2MN7.js +171 -0
  30. package/Build/Workers/chunk-AC7ND63S.js +57 -0
  31. package/Build/Workers/chunk-AHCZ757M.js +9230 -0
  32. package/Build/Workers/chunk-ANOA7E7F.js +56 -0
  33. package/Build/Workers/chunk-AYO5HHV6.js +789 -0
  34. package/Build/Workers/chunk-BE2N56VZ.js +1344 -0
  35. package/Build/Workers/chunk-BR3BPM64.js +9230 -0
  36. package/Build/Workers/chunk-BVMRWGOK.js +455 -0
  37. package/Build/Workers/chunk-BXEL2NX7.js +455 -0
  38. package/Build/Workers/chunk-C5BO2JCG.js +278 -0
  39. package/Build/Workers/chunk-CIRQNZVR.js +301 -0
  40. package/Build/Workers/chunk-CM67CQME.js +305 -0
  41. package/Build/Workers/chunk-D3QIW4DH.js +630 -0
  42. package/Build/Workers/chunk-E5W7QIGZ.js +511 -0
  43. package/Build/Workers/chunk-E6CYGUJI.js +1054 -0
  44. package/Build/Workers/chunk-EIZ23IOX.js +414 -0
  45. package/Build/Workers/chunk-EIZJUMQY.js +101 -0
  46. package/Build/Workers/chunk-EXTMZJXB.js +82 -0
  47. package/Build/Workers/chunk-EYOOSIBW.js +682 -0
  48. package/Build/Workers/chunk-F37WADVC.js +1054 -0
  49. package/Build/Workers/chunk-FIWPJFHX.js +101 -0
  50. package/Build/Workers/chunk-FM32TNGT.js +198 -0
  51. package/Build/Workers/chunk-FOMYIEIB.js +476 -0
  52. package/Build/Workers/chunk-FWYDLSVQ.js +97 -0
  53. package/Build/Workers/chunk-HGZR6CZF.js +1067 -0
  54. package/Build/Workers/chunk-HIXHDABG.js +288 -0
  55. package/Build/Workers/chunk-HMCCZZWE.js +97 -0
  56. package/Build/Workers/chunk-HW54WHGM.js +2719 -0
  57. package/Build/Workers/chunk-IHYAI7GF.js +973 -0
  58. package/Build/Workers/chunk-INLQ7LVK.js +837 -0
  59. package/Build/Workers/chunk-IQMESTCB.js +124 -0
  60. package/Build/Workers/chunk-J4PISUNT.js +2342 -0
  61. package/Build/Workers/chunk-JSWU557I.js +693 -0
  62. package/Build/Workers/chunk-KHONDSQ7.js +693 -0
  63. package/Build/Workers/chunk-KLUL2SOE.js +352 -0
  64. package/Build/Workers/chunk-KMBLKQCC.js +1992 -0
  65. package/Build/Workers/chunk-KOTWWQN7.js +171 -0
  66. package/Build/Workers/chunk-KWV6ZTF4.js +163 -0
  67. package/Build/Workers/chunk-LSEFPQHG.js +476 -0
  68. package/Build/Workers/chunk-M66X4O24.js +44 -0
  69. package/Build/Workers/chunk-M6IXKBC7.js +1992 -0
  70. package/Build/Workers/chunk-MFUC3D5C.js +162 -0
  71. package/Build/Workers/chunk-MRMNELAH.js +82 -0
  72. package/Build/Workers/chunk-N3NUA5H2.js +3792 -0
  73. package/Build/Workers/chunk-NFB2NXJN.js +138 -0
  74. package/Build/Workers/chunk-NQAXBK4K.js +789 -0
  75. package/Build/Workers/chunk-NUGQWV6S.js +352 -0
  76. package/Build/Workers/chunk-O7S7WL7K.js +278 -0
  77. package/Build/Workers/chunk-ODZYB26X.js +1287 -0
  78. package/Build/Workers/chunk-OEHJY463.js +3201 -0
  79. package/Build/Workers/chunk-OMMRNMXF.js +44 -0
  80. package/Build/Workers/chunk-OZ3CQDO3.js +138 -0
  81. package/Build/Workers/chunk-PNXBG64I.js +219 -0
  82. package/Build/Workers/chunk-PYR35GK4.js +973 -0
  83. package/Build/Workers/chunk-Q4CXGW74.js +57 -0
  84. package/Build/Workers/chunk-QGISLKCW.js +147 -0
  85. package/Build/Workers/chunk-QQHVOJW6.js +497 -0
  86. package/Build/Workers/chunk-QWCMMRJW.js +58 -0
  87. package/Build/Workers/chunk-RDEZCHF4.js +398 -0
  88. package/Build/Workers/chunk-SJTE7FVN.js +778 -0
  89. package/Build/Workers/chunk-SM5T67LR.js +162 -0
  90. package/Build/Workers/chunk-T27NNXEU.js +58 -0
  91. package/Build/Workers/chunk-T4J5BWUO.js +511 -0
  92. package/Build/Workers/chunk-T6JS4BRN.js +140 -0
  93. package/Build/Workers/chunk-UH6DUQBW.js +140 -0
  94. package/Build/Workers/chunk-UJAH6XKF.js +73 -0
  95. package/Build/Workers/chunk-UKSTJ2PH.js +454 -0
  96. package/Build/Workers/chunk-UQCDCCZ7.js +368 -0
  97. package/Build/Workers/chunk-UXIFNEA3.js +1287 -0
  98. package/Build/Workers/chunk-UXJ6J5L7.js +56 -0
  99. package/Build/Workers/chunk-V4VUAZXI.js +1800 -0
  100. package/Build/Workers/chunk-VQH2YXO2.js +497 -0
  101. package/Build/Workers/chunk-VXKCLSE4.js +241 -0
  102. package/Build/Workers/chunk-W3U6YBEI.js +280 -0
  103. package/Build/Workers/chunk-W75ZVFKP.js +778 -0
  104. package/Build/Workers/chunk-WCDFJYFB.js +1344 -0
  105. package/Build/Workers/chunk-WME5M6W3.js +630 -0
  106. package/Build/Workers/chunk-XDQBQB64.js +1067 -0
  107. package/Build/Workers/chunk-Y6HOIWE5.js +959 -0
  108. package/Build/Workers/chunk-YEMC2ZOR.js +147 -0
  109. package/Build/Workers/chunk-YWNF3TPE.js +682 -0
  110. package/Build/Workers/chunk-Z55VGWJP.js +280 -0
  111. package/Build/Workers/chunk-Z5YWP24C.js +124 -0
  112. package/Build/Workers/chunk-ZHXCWUJB.js +387 -0
  113. package/Build/Workers/chunk-ZIMPUF2I.js +102 -0
  114. package/Build/Workers/chunk-ZKDWYQKC.js +3201 -0
  115. package/Build/Workers/combineGeometry.js +24 -22
  116. package/Build/Workers/createBoxGeometry.js +18 -16
  117. package/Build/Workers/createBoxOutlineGeometry.js +23 -25
  118. package/Build/Workers/createCircleGeometry.js +29 -27
  119. package/Build/Workers/createCircleOutlineGeometry.js +22 -20
  120. package/Build/Workers/createCoplanarPolygonGeometry.js +43 -43
  121. package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +37 -35
  122. package/Build/Workers/createCorridorGeometry.js +46 -49
  123. package/Build/Workers/createCorridorOutlineGeometry.js +40 -43
  124. package/Build/Workers/createCylinderGeometry.js +20 -18
  125. package/Build/Workers/createCylinderOutlineGeometry.js +27 -25
  126. package/Build/Workers/createEllipseGeometry.js +28 -25
  127. package/Build/Workers/createEllipseOutlineGeometry.js +21 -18
  128. package/Build/Workers/createEllipsoidGeometry.js +19 -17
  129. package/Build/Workers/createEllipsoidOutlineGeometry.js +18 -16
  130. package/Build/Workers/createFrustumGeometry.js +18 -16
  131. package/Build/Workers/createFrustumOutlineGeometry.js +21 -21
  132. package/Build/Workers/createGeometry.js +31 -26
  133. package/Build/Workers/createGroundPolylineGeometry.js +188 -135
  134. package/Build/Workers/createPlaneGeometry.js +22 -21
  135. package/Build/Workers/createPlaneOutlineGeometry.js +15 -13
  136. package/Build/Workers/createPolygonGeometry.js +51 -52
  137. package/Build/Workers/createPolygonOutlineGeometry.js +43 -44
  138. package/Build/Workers/createPolylineGeometry.js +37 -40
  139. package/Build/Workers/createPolylineVolumeGeometry.js +41 -44
  140. package/Build/Workers/createPolylineVolumeOutlineGeometry.js +36 -39
  141. package/Build/Workers/createRectangleGeometry.js +47 -53
  142. package/Build/Workers/createRectangleOutlineGeometry.js +32 -33
  143. package/Build/Workers/createSimplePolylineGeometry.js +33 -34
  144. package/Build/Workers/createSphereGeometry.js +20 -20
  145. package/Build/Workers/createSphereOutlineGeometry.js +19 -19
  146. package/Build/Workers/createTaskProcessorWorker.js +3 -3
  147. package/Build/Workers/createVectorTileClampedPolylines.js +16 -14
  148. package/Build/Workers/createVectorTileGeometries.js +24 -22
  149. package/Build/Workers/createVectorTilePoints.js +15 -13
  150. package/Build/Workers/createVectorTilePolygons.js +24 -21
  151. package/Build/Workers/createVectorTilePolylines.js +16 -14
  152. package/Build/Workers/createVerticesFromCesium3DTilesTerrain.js +25 -25
  153. package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +29 -27
  154. package/Build/Workers/createVerticesFromHeightmap.js +42 -63
  155. package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +26 -280
  156. package/Build/Workers/createWallGeometry.js +35 -36
  157. package/Build/Workers/createWallOutlineGeometry.js +33 -34
  158. package/Build/Workers/decodeDraco.js +10 -11
  159. package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +5 -5
  160. package/Build/Workers/decodeI3S.js +16 -20
  161. package/Build/Workers/gaussianSplatSorter.js +4 -4
  162. package/Build/Workers/gaussianSplatTextureGenerator.js +4 -4
  163. package/Build/Workers/incrementallyBuildTerrainPicker.js +20 -12
  164. package/Build/Workers/transcodeKTX2.js +42 -14
  165. package/Build/Workers/transferTypedArrayTest.js +1 -1
  166. package/Build/Workers/upsampleQuantizedTerrainMesh.js +24 -21
  167. package/Build/Workers/upsampleVerticesFromCesium3DTilesTerrain.js +25 -25
  168. package/Source/Shaders/BillboardCollectionFS.js +85 -81
  169. package/Source/Shaders/BillboardCollectionVS.js +60 -118
  170. package/Source/Shaders/Builtin/Constants/passCesium3DTile.js +1 -1
  171. package/Source/Shaders/Builtin/Constants/passCesium3DTileClassification.js +1 -1
  172. package/Source/Shaders/Builtin/Constants/passCesium3DTileClassificationIgnoreShow.js +1 -1
  173. package/Source/Shaders/Builtin/Constants/passCesium3DTileEdges.js +12 -0
  174. package/Source/Shaders/Builtin/Constants/passCesium3DTileEdgesDirect.js +11 -0
  175. package/Source/Shaders/Builtin/Constants/passGaussianSplats.js +11 -0
  176. package/Source/Shaders/Builtin/Constants/passOpaque.js +1 -1
  177. package/Source/Shaders/Builtin/Constants/passOverlay.js +1 -1
  178. package/Source/Shaders/Builtin/Constants/passTranslucent.js +1 -1
  179. package/Source/Shaders/Builtin/Constants/passVoxels.js +1 -1
  180. package/Source/Shaders/Builtin/CzmBuiltins.js +12 -0
  181. package/Source/Shaders/Builtin/Functions/columbusViewMorph.js +8 -1
  182. package/Source/Shaders/Builtin/Functions/computeTextureTransform.js +25 -0
  183. package/Source/Shaders/Builtin/Functions/decodeRGB8.js +24 -0
  184. package/Source/Shaders/Builtin/Functions/modelToWindowCoordinates.js +2 -1
  185. package/Source/Shaders/Builtin/Functions/unpackTexture.js +37 -0
  186. package/Source/Shaders/Builtin/Functions/windowToEyeCoordinates.js +0 -1
  187. package/Source/Shaders/EllipsoidVS.js +4 -4
  188. package/Source/Shaders/FXAA3_11.js +2 -0
  189. package/Source/Shaders/GlobeFS.js +22 -0
  190. package/Source/Shaders/GlobeVS.js +3 -2
  191. package/Source/Shaders/Model/MaterialStageFS.js +50 -20
  192. package/Source/Shaders/Model/MetadataStageFS.js +2 -1
  193. package/Source/Shaders/Model/MetadataStageVS.js +2 -1
  194. package/Source/Shaders/Model/ModelFS.js +32 -2
  195. package/Source/Shaders/Model/ModelVS.js +15 -1
  196. package/Source/Shaders/Model/PointCloudStylingStageVS.js +2 -1
  197. package/Source/Shaders/Model/PrimitiveOutlineStageFS.js +0 -1
  198. package/Source/Shaders/PointPrimitiveCollectionVS.js +8 -39
  199. package/Source/Shaders/PolygonSignedDistanceFS.js +64 -33
  200. package/Source/Shaders/PolylineCommon.js +1 -1
  201. package/Source/Shaders/ShadowVolumeAppearanceFS.js +7 -15
  202. package/Source/Shaders/SkyAtmosphereVS.js +2 -1
  203. package/Source/Shaders/Voxels/IntersectBox.js +20 -33
  204. package/Source/Shaders/Voxels/IntersectCylinder.js +28 -32
  205. package/Source/Shaders/Voxels/IntersectDepth.js +10 -6
  206. package/Source/Shaders/Voxels/IntersectEllipsoid.js +12 -20
  207. package/Source/Shaders/Voxels/IntersectLongitude.js +21 -9
  208. package/Source/Shaders/Voxels/Intersection.js +3 -5
  209. package/Source/Shaders/Voxels/IntersectionUtils.js +2 -1
  210. package/Source/Shaders/Voxels/Megatexture.js +15 -83
  211. package/Source/Shaders/Voxels/Octree.js +53 -61
  212. package/Source/Shaders/Voxels/VoxelFS.js +67 -52
  213. package/Source/Shaders/Voxels/VoxelUtils.js +0 -19
  214. package/index.js +346 -261
  215. package/package.json +1 -1
  216. package/Source/Shaders/Voxels/IntersectClippingPlanes.js +0 -80
  217. package/Source/Shaders/Voxels/convertUvToBox.js +0 -46
  218. package/Source/Shaders/Voxels/convertUvToCylinder.js +0 -101
  219. package/Source/Shaders/Voxels/convertUvToEllipsoid.js +0 -141
@@ -0,0 +1,2342 @@
1
+ /**
2
+ * @license
3
+ * Cesium - https://github.com/CesiumGS/cesium
4
+ * Version 0.1.3
5
+ *
6
+ * Copyright 2011-2022 Cesium Contributors
7
+ *
8
+ * Licensed under the Apache License, Version 2.0 (the "License");
9
+ * you may not use this file except in compliance with the License.
10
+ * You may obtain a copy of the License at
11
+ *
12
+ * http://www.apache.org/licenses/LICENSE-2.0
13
+ *
14
+ * Unless required by applicable law or agreed to in writing, software
15
+ * distributed under the License is distributed on an "AS IS" BASIS,
16
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ * See the License for the specific language governing permissions and
18
+ * limitations under the License.
19
+ *
20
+ * Columbus View (Pat. Pend.)
21
+ *
22
+ * Portions licensed separately.
23
+ * See https://github.com/CesiumGS/cesium/blob/main/LICENSE.md for full licensing details.
24
+ */
25
+
26
+ import {
27
+ Math_default
28
+ } from "./chunk-QQHVOJW6.js";
29
+ import {
30
+ Check_default,
31
+ DeveloperError_default
32
+ } from "./chunk-6EJMTDQJ.js";
33
+ import {
34
+ defined_default
35
+ } from "./chunk-EXTMZJXB.js";
36
+
37
+ // packages/engine/Source/Core/Cartesian3.js
38
+ var Cartesian3 = class _Cartesian3 {
39
+ /**
40
+ * @param {number} [x=0.0] The X component.
41
+ * @param {number} [y=0.0] The Y component.
42
+ * @param {number} [z=0.0] The Z component.
43
+ */
44
+ constructor(x, y, z) {
45
+ this.x = x ?? 0;
46
+ this.y = y ?? 0;
47
+ this.z = z ?? 0;
48
+ }
49
+ /**
50
+ * Converts the provided Spherical into Cartesian3 coordinates.
51
+ *
52
+ * @param {Spherical} spherical The Spherical to be converted to Cartesian3.
53
+ * @param {Cartesian3} [result] The object onto which to store the result.
54
+ * @returns {Cartesian3} The modified result parameter or a new Cartesian3 instance if one was not provided.
55
+ */
56
+ static fromSpherical(spherical, result) {
57
+ Check_default.typeOf.object("spherical", spherical);
58
+ if (!defined_default(result)) {
59
+ result = new _Cartesian3();
60
+ }
61
+ const clock = spherical.clock;
62
+ const cone = spherical.cone;
63
+ const magnitude = spherical.magnitude ?? 1;
64
+ const radial = magnitude * Math.sin(cone);
65
+ result.x = radial * Math.cos(clock);
66
+ result.y = radial * Math.sin(clock);
67
+ result.z = magnitude * Math.cos(cone);
68
+ return result;
69
+ }
70
+ /**
71
+ * Creates a Cartesian3 instance from x, y and z coordinates.
72
+ *
73
+ * @param {number} x The x coordinate.
74
+ * @param {number} y The y coordinate.
75
+ * @param {number} z The z coordinate.
76
+ * @param {Cartesian3} [result] The object onto which to store the result.
77
+ * @returns {Cartesian3} The modified result parameter or a new Cartesian3 instance if one was not provided.
78
+ */
79
+ static fromElements(x, y, z, result) {
80
+ if (!defined_default(result)) {
81
+ return new _Cartesian3(x, y, z);
82
+ }
83
+ result.x = x;
84
+ result.y = y;
85
+ result.z = z;
86
+ return result;
87
+ }
88
+ /**
89
+ * Duplicates a Cartesian3 instance.
90
+ *
91
+ * @param {Cartesian3} cartesian The Cartesian to duplicate.
92
+ * @param {Cartesian3} [result] The object onto which to store the result.
93
+ * @returns {Cartesian3} The modified result parameter or a new Cartesian3 instance if one was not provided. (Returns undefined if cartesian is undefined)
94
+ */
95
+ static clone(cartesian, result) {
96
+ if (!defined_default(cartesian)) {
97
+ return void 0;
98
+ }
99
+ if (!defined_default(result)) {
100
+ return new _Cartesian3(cartesian.x, cartesian.y, cartesian.z);
101
+ }
102
+ result.x = cartesian.x;
103
+ result.y = cartesian.y;
104
+ result.z = cartesian.z;
105
+ return result;
106
+ }
107
+ /**
108
+ * Stores the provided instance into the provided array.
109
+ *
110
+ * @param {Cartesian3} value The value to pack.
111
+ * @param {number[]} array The array to pack into.
112
+ * @param {number} [startingIndex=0] The index into the array at which to start packing the elements.
113
+ *
114
+ * @returns {number[]} The array that was packed into
115
+ */
116
+ static pack(value, array, startingIndex) {
117
+ Check_default.typeOf.object("value", value);
118
+ Check_default.defined("array", array);
119
+ startingIndex = startingIndex ?? 0;
120
+ array[startingIndex++] = value.x;
121
+ array[startingIndex++] = value.y;
122
+ array[startingIndex] = value.z;
123
+ return array;
124
+ }
125
+ /**
126
+ * Retrieves an instance from a packed array.
127
+ *
128
+ * @param {number[]} array The packed array.
129
+ * @param {number} [startingIndex=0] The starting index of the element to be unpacked.
130
+ * @param {Cartesian3} [result] The object into which to store the result.
131
+ * @returns {Cartesian3} The modified result parameter or a new Cartesian3 instance if one was not provided.
132
+ */
133
+ static unpack(array, startingIndex, result) {
134
+ Check_default.defined("array", array);
135
+ startingIndex = startingIndex ?? 0;
136
+ if (!defined_default(result)) {
137
+ result = new _Cartesian3();
138
+ }
139
+ result.x = array[startingIndex++];
140
+ result.y = array[startingIndex++];
141
+ result.z = array[startingIndex];
142
+ return result;
143
+ }
144
+ /**
145
+ * Flattens an array of Cartesian3s into an array of components.
146
+ *
147
+ * @param {Cartesian3[]} array The array of cartesians to pack.
148
+ * @param {number[]} [result] The array onto which to store the result. If this is a typed array, it must have array.length * 3 components, else a {@link DeveloperError} will be thrown. If it is a regular array, it will be resized to have (array.length * 3) elements.
149
+ * @returns {number[]} The packed array.
150
+ */
151
+ static packArray(array, result) {
152
+ Check_default.defined("array", array);
153
+ const length = array.length;
154
+ const resultLength = length * 3;
155
+ if (!defined_default(result)) {
156
+ result = new Array(resultLength);
157
+ } else if (!Array.isArray(result) && result.length !== resultLength) {
158
+ throw new DeveloperError_default(
159
+ "If result is a typed array, it must have exactly array.length * 3 elements"
160
+ );
161
+ } else if (result.length !== resultLength) {
162
+ result.length = resultLength;
163
+ }
164
+ for (let i = 0; i < length; ++i) {
165
+ _Cartesian3.pack(array[i], result, i * 3);
166
+ }
167
+ return result;
168
+ }
169
+ /**
170
+ * Unpacks an array of cartesian components into an array of Cartesian3s.
171
+ *
172
+ * @param {number[]} array The array of components to unpack.
173
+ * @param {Cartesian3[]} [result] The array onto which to store the result.
174
+ * @returns {Cartesian3[]} The unpacked array.
175
+ */
176
+ static unpackArray(array, result) {
177
+ Check_default.defined("array", array);
178
+ Check_default.typeOf.number.greaterThanOrEquals("array.length", array.length, 3);
179
+ if (array.length % 3 !== 0) {
180
+ throw new DeveloperError_default("array length must be a multiple of 3.");
181
+ }
182
+ const length = array.length;
183
+ if (!defined_default(result)) {
184
+ result = new Array(length / 3);
185
+ } else {
186
+ result.length = length / 3;
187
+ }
188
+ for (let i = 0; i < length; i += 3) {
189
+ const index = i / 3;
190
+ result[index] = _Cartesian3.unpack(array, i, result[index]);
191
+ }
192
+ return result;
193
+ }
194
+ /**
195
+ * Computes the value of the maximum component for the supplied Cartesian.
196
+ *
197
+ * @param {Cartesian3} cartesian The cartesian to use.
198
+ * @returns {number} The value of the maximum component.
199
+ */
200
+ static maximumComponent(cartesian) {
201
+ Check_default.typeOf.object("cartesian", cartesian);
202
+ return Math.max(cartesian.x, cartesian.y, cartesian.z);
203
+ }
204
+ /**
205
+ * Computes the value of the minimum component for the supplied Cartesian.
206
+ *
207
+ * @param {Cartesian3} cartesian The cartesian to use.
208
+ * @returns {number} The value of the minimum component.
209
+ */
210
+ static minimumComponent(cartesian) {
211
+ Check_default.typeOf.object("cartesian", cartesian);
212
+ return Math.min(cartesian.x, cartesian.y, cartesian.z);
213
+ }
214
+ /**
215
+ * Compares two Cartesians and computes a Cartesian which contains the minimum components of the supplied Cartesians.
216
+ *
217
+ * @param {Cartesian3} first A cartesian to compare.
218
+ * @param {Cartesian3} second A cartesian to compare.
219
+ * @param {Cartesian3} result The object into which to store the result.
220
+ * @returns {Cartesian3} A cartesian with the minimum components.
221
+ */
222
+ static minimumByComponent(first, second, result) {
223
+ Check_default.typeOf.object("first", first);
224
+ Check_default.typeOf.object("second", second);
225
+ Check_default.typeOf.object("result", result);
226
+ result.x = Math.min(first.x, second.x);
227
+ result.y = Math.min(first.y, second.y);
228
+ result.z = Math.min(first.z, second.z);
229
+ return result;
230
+ }
231
+ /**
232
+ * Compares two Cartesians and computes a Cartesian which contains the maximum components of the supplied Cartesians.
233
+ *
234
+ * @param {Cartesian3} first A cartesian to compare.
235
+ * @param {Cartesian3} second A cartesian to compare.
236
+ * @param {Cartesian3} result The object into which to store the result.
237
+ * @returns {Cartesian3} A cartesian with the maximum components.
238
+ */
239
+ static maximumByComponent(first, second, result) {
240
+ Check_default.typeOf.object("first", first);
241
+ Check_default.typeOf.object("second", second);
242
+ Check_default.typeOf.object("result", result);
243
+ result.x = Math.max(first.x, second.x);
244
+ result.y = Math.max(first.y, second.y);
245
+ result.z = Math.max(first.z, second.z);
246
+ return result;
247
+ }
248
+ /**
249
+ * Constrain a value to lie between two values.
250
+ *
251
+ * @param {Cartesian3} value The value to clamp.
252
+ * @param {Cartesian3} min The minimum bound.
253
+ * @param {Cartesian3} max The maximum bound.
254
+ * @param {Cartesian3} result The object into which to store the result.
255
+ * @returns {Cartesian3} The clamped value such that min <= value <= max.
256
+ */
257
+ static clamp(value, min, max, result) {
258
+ Check_default.typeOf.object("value", value);
259
+ Check_default.typeOf.object("min", min);
260
+ Check_default.typeOf.object("max", max);
261
+ Check_default.typeOf.object("result", result);
262
+ const x = Math_default.clamp(value.x, min.x, max.x);
263
+ const y = Math_default.clamp(value.y, min.y, max.y);
264
+ const z = Math_default.clamp(value.z, min.z, max.z);
265
+ result.x = x;
266
+ result.y = y;
267
+ result.z = z;
268
+ return result;
269
+ }
270
+ /**
271
+ * Computes the provided Cartesian's squared magnitude.
272
+ *
273
+ * @param {Cartesian3} cartesian The Cartesian instance whose squared magnitude is to be computed.
274
+ * @returns {number} The squared magnitude.
275
+ */
276
+ static magnitudeSquared(cartesian) {
277
+ Check_default.typeOf.object("cartesian", cartesian);
278
+ return cartesian.x * cartesian.x + cartesian.y * cartesian.y + cartesian.z * cartesian.z;
279
+ }
280
+ /**
281
+ * Computes the Cartesian's magnitude (length).
282
+ *
283
+ * @param {Cartesian3} cartesian The Cartesian instance whose magnitude is to be computed.
284
+ * @returns {number} The magnitude.
285
+ */
286
+ static magnitude(cartesian) {
287
+ return Math.sqrt(_Cartesian3.magnitudeSquared(cartesian));
288
+ }
289
+ /**
290
+ * Computes the distance between two points.
291
+ *
292
+ * @param {Cartesian3} left The first point to compute the distance from.
293
+ * @param {Cartesian3} right The second point to compute the distance to.
294
+ * @returns {number} The distance between two points.
295
+ *
296
+ * @example
297
+ * // Returns 1.0
298
+ * const d = Cesium.Cartesian3.distance(new Cesium.Cartesian3(1.0, 0.0, 0.0), new Cesium.Cartesian3(2.0, 0.0, 0.0));
299
+ */
300
+ static distance(left, right) {
301
+ Check_default.typeOf.object("left", left);
302
+ Check_default.typeOf.object("right", right);
303
+ _Cartesian3.subtract(left, right, distanceScratch);
304
+ return _Cartesian3.magnitude(distanceScratch);
305
+ }
306
+ /**
307
+ * Computes the squared distance between two points. Comparing squared distances
308
+ * using this function is more efficient than comparing distances using {@link Cartesian3#distance}.
309
+ *
310
+ * @param {Cartesian3} left The first point to compute the distance from.
311
+ * @param {Cartesian3} right The second point to compute the distance to.
312
+ * @returns {number} The distance between two points.
313
+ *
314
+ * @example
315
+ * // Returns 4.0, not 2.0
316
+ * const d = Cesium.Cartesian3.distanceSquared(new Cesium.Cartesian3(1.0, 0.0, 0.0), new Cesium.Cartesian3(3.0, 0.0, 0.0));
317
+ */
318
+ static distanceSquared(left, right) {
319
+ Check_default.typeOf.object("left", left);
320
+ Check_default.typeOf.object("right", right);
321
+ _Cartesian3.subtract(left, right, distanceScratch);
322
+ return _Cartesian3.magnitudeSquared(distanceScratch);
323
+ }
324
+ /**
325
+ * Computes the normalized form of the supplied Cartesian.
326
+ *
327
+ * @param {Cartesian3} cartesian The Cartesian to be normalized.
328
+ * @param {Cartesian3} result The object onto which to store the result.
329
+ * @returns {Cartesian3} The modified result parameter.
330
+ */
331
+ static normalize(cartesian, result) {
332
+ Check_default.typeOf.object("cartesian", cartesian);
333
+ Check_default.typeOf.object("result", result);
334
+ const magnitude = _Cartesian3.magnitude(cartesian);
335
+ result.x = cartesian.x / magnitude;
336
+ result.y = cartesian.y / magnitude;
337
+ result.z = cartesian.z / magnitude;
338
+ if (isNaN(result.x) || isNaN(result.y) || isNaN(result.z)) {
339
+ throw new DeveloperError_default("normalized result is not a number");
340
+ }
341
+ return result;
342
+ }
343
+ /**
344
+ * Computes the dot (scalar) product of two Cartesians.
345
+ *
346
+ * @param {Cartesian3} left The first Cartesian.
347
+ * @param {Cartesian3} right The second Cartesian.
348
+ * @returns {number} The dot product.
349
+ */
350
+ static dot(left, right) {
351
+ Check_default.typeOf.object("left", left);
352
+ Check_default.typeOf.object("right", right);
353
+ return left.x * right.x + left.y * right.y + left.z * right.z;
354
+ }
355
+ /**
356
+ * Computes the componentwise product of two Cartesians.
357
+ *
358
+ * @param {Cartesian3} left The first Cartesian.
359
+ * @param {Cartesian3} right The second Cartesian.
360
+ * @param {Cartesian3} result The object onto which to store the result.
361
+ * @returns {Cartesian3} The modified result parameter.
362
+ */
363
+ static multiplyComponents(left, right, result) {
364
+ Check_default.typeOf.object("left", left);
365
+ Check_default.typeOf.object("right", right);
366
+ Check_default.typeOf.object("result", result);
367
+ result.x = left.x * right.x;
368
+ result.y = left.y * right.y;
369
+ result.z = left.z * right.z;
370
+ return result;
371
+ }
372
+ /**
373
+ * Computes the componentwise quotient of two Cartesians.
374
+ *
375
+ * @param {Cartesian3} left The first Cartesian.
376
+ * @param {Cartesian3} right The second Cartesian.
377
+ * @param {Cartesian3} result The object onto which to store the result.
378
+ * @returns {Cartesian3} The modified result parameter.
379
+ */
380
+ static divideComponents(left, right, result) {
381
+ Check_default.typeOf.object("left", left);
382
+ Check_default.typeOf.object("right", right);
383
+ Check_default.typeOf.object("result", result);
384
+ result.x = left.x / right.x;
385
+ result.y = left.y / right.y;
386
+ result.z = left.z / right.z;
387
+ return result;
388
+ }
389
+ /**
390
+ * Computes the componentwise sum of two Cartesians.
391
+ *
392
+ * @param {Cartesian3} left The first Cartesian.
393
+ * @param {Cartesian3} right The second Cartesian.
394
+ * @param {Cartesian3} result The object onto which to store the result.
395
+ * @returns {Cartesian3} The modified result parameter.
396
+ */
397
+ static add(left, right, result) {
398
+ Check_default.typeOf.object("left", left);
399
+ Check_default.typeOf.object("right", right);
400
+ Check_default.typeOf.object("result", result);
401
+ result.x = left.x + right.x;
402
+ result.y = left.y + right.y;
403
+ result.z = left.z + right.z;
404
+ return result;
405
+ }
406
+ /**
407
+ * Computes the componentwise difference of two Cartesians.
408
+ *
409
+ * @param {Cartesian3} left The first Cartesian.
410
+ * @param {Cartesian3} right The second Cartesian.
411
+ * @param {Cartesian3} result The object onto which to store the result.
412
+ * @returns {Cartesian3} The modified result parameter.
413
+ */
414
+ static subtract(left, right, result) {
415
+ Check_default.typeOf.object("left", left);
416
+ Check_default.typeOf.object("right", right);
417
+ Check_default.typeOf.object("result", result);
418
+ result.x = left.x - right.x;
419
+ result.y = left.y - right.y;
420
+ result.z = left.z - right.z;
421
+ return result;
422
+ }
423
+ /**
424
+ * Multiplies the provided Cartesian componentwise by the provided scalar.
425
+ *
426
+ * @param {Cartesian3} cartesian The Cartesian to be scaled.
427
+ * @param {number} scalar The scalar to multiply with.
428
+ * @param {Cartesian3} result The object onto which to store the result.
429
+ * @returns {Cartesian3} The modified result parameter.
430
+ */
431
+ static multiplyByScalar(cartesian, scalar, result) {
432
+ Check_default.typeOf.object("cartesian", cartesian);
433
+ Check_default.typeOf.number("scalar", scalar);
434
+ Check_default.typeOf.object("result", result);
435
+ result.x = cartesian.x * scalar;
436
+ result.y = cartesian.y * scalar;
437
+ result.z = cartesian.z * scalar;
438
+ return result;
439
+ }
440
+ /**
441
+ * Divides the provided Cartesian componentwise by the provided scalar.
442
+ *
443
+ * @param {Cartesian3} cartesian The Cartesian to be divided.
444
+ * @param {number} scalar The scalar to divide by.
445
+ * @param {Cartesian3} result The object onto which to store the result.
446
+ * @returns {Cartesian3} The modified result parameter.
447
+ */
448
+ static divideByScalar(cartesian, scalar, result) {
449
+ Check_default.typeOf.object("cartesian", cartesian);
450
+ Check_default.typeOf.number("scalar", scalar);
451
+ Check_default.typeOf.object("result", result);
452
+ result.x = cartesian.x / scalar;
453
+ result.y = cartesian.y / scalar;
454
+ result.z = cartesian.z / scalar;
455
+ return result;
456
+ }
457
+ /**
458
+ * Negates the provided Cartesian.
459
+ *
460
+ * @param {Cartesian3} cartesian The Cartesian to be negated.
461
+ * @param {Cartesian3} result The object onto which to store the result.
462
+ * @returns {Cartesian3} The modified result parameter.
463
+ */
464
+ static negate(cartesian, result) {
465
+ Check_default.typeOf.object("cartesian", cartesian);
466
+ Check_default.typeOf.object("result", result);
467
+ result.x = -cartesian.x;
468
+ result.y = -cartesian.y;
469
+ result.z = -cartesian.z;
470
+ return result;
471
+ }
472
+ /**
473
+ * Computes the absolute value of the provided Cartesian.
474
+ *
475
+ * @param {Cartesian3} cartesian The Cartesian whose absolute value is to be computed.
476
+ * @param {Cartesian3} result The object onto which to store the result.
477
+ * @returns {Cartesian3} The modified result parameter.
478
+ */
479
+ static abs(cartesian, result) {
480
+ Check_default.typeOf.object("cartesian", cartesian);
481
+ Check_default.typeOf.object("result", result);
482
+ result.x = Math.abs(cartesian.x);
483
+ result.y = Math.abs(cartesian.y);
484
+ result.z = Math.abs(cartesian.z);
485
+ return result;
486
+ }
487
+ /**
488
+ * Computes the linear interpolation or extrapolation at t using the provided cartesians.
489
+ *
490
+ * @param {Cartesian3} start The value corresponding to t at 0.0.
491
+ * @param {Cartesian3} end The value corresponding to t at 1.0.
492
+ * @param {number} t The point along t at which to interpolate.
493
+ * @param {Cartesian3} result The object onto which to store the result.
494
+ * @returns {Cartesian3} The modified result parameter.
495
+ */
496
+ static lerp(start, end, t, result) {
497
+ Check_default.typeOf.object("start", start);
498
+ Check_default.typeOf.object("end", end);
499
+ Check_default.typeOf.number("t", t);
500
+ Check_default.typeOf.object("result", result);
501
+ _Cartesian3.multiplyByScalar(end, t, lerpScratch);
502
+ result = _Cartesian3.multiplyByScalar(start, 1 - t, result);
503
+ return _Cartesian3.add(lerpScratch, result, result);
504
+ }
505
+ /**
506
+ * Returns the angle, in radians, between the provided Cartesians.
507
+ *
508
+ * @param {Cartesian3} left The first Cartesian.
509
+ * @param {Cartesian3} right The second Cartesian.
510
+ * @returns {number} The angle between the Cartesians.
511
+ */
512
+ static angleBetween(left, right) {
513
+ Check_default.typeOf.object("left", left);
514
+ Check_default.typeOf.object("right", right);
515
+ _Cartesian3.normalize(left, angleBetweenScratch);
516
+ _Cartesian3.normalize(right, angleBetweenScratch2);
517
+ const cosine = _Cartesian3.dot(angleBetweenScratch, angleBetweenScratch2);
518
+ const sine = _Cartesian3.magnitude(
519
+ _Cartesian3.cross(
520
+ angleBetweenScratch,
521
+ angleBetweenScratch2,
522
+ angleBetweenScratch
523
+ )
524
+ );
525
+ return Math.atan2(sine, cosine);
526
+ }
527
+ /**
528
+ * Returns the axis that is most orthogonal to the provided Cartesian.
529
+ *
530
+ * @param {Cartesian3} cartesian The Cartesian on which to find the most orthogonal axis.
531
+ * @param {Cartesian3} result The object onto which to store the result.
532
+ * @returns {Cartesian3} The most orthogonal axis.
533
+ */
534
+ static mostOrthogonalAxis(cartesian, result) {
535
+ Check_default.typeOf.object("cartesian", cartesian);
536
+ Check_default.typeOf.object("result", result);
537
+ const f = _Cartesian3.normalize(cartesian, mostOrthogonalAxisScratch);
538
+ _Cartesian3.abs(f, f);
539
+ if (f.x <= f.y) {
540
+ if (f.x <= f.z) {
541
+ result = _Cartesian3.clone(_Cartesian3.UNIT_X, result);
542
+ } else {
543
+ result = _Cartesian3.clone(_Cartesian3.UNIT_Z, result);
544
+ }
545
+ } else if (f.y <= f.z) {
546
+ result = _Cartesian3.clone(_Cartesian3.UNIT_Y, result);
547
+ } else {
548
+ result = _Cartesian3.clone(_Cartesian3.UNIT_Z, result);
549
+ }
550
+ return result;
551
+ }
552
+ /**
553
+ * Projects vector a onto vector b
554
+ * @param {Cartesian3} a The vector that needs projecting
555
+ * @param {Cartesian3} b The vector to project onto
556
+ * @param {Cartesian3} result The result cartesian
557
+ * @returns {Cartesian3} The modified result parameter
558
+ */
559
+ static projectVector(a, b, result) {
560
+ Check_default.defined("a", a);
561
+ Check_default.defined("b", b);
562
+ Check_default.defined("result", result);
563
+ const scalar = _Cartesian3.dot(a, b) / _Cartesian3.dot(b, b);
564
+ return _Cartesian3.multiplyByScalar(b, scalar, result);
565
+ }
566
+ /**
567
+ * Compares the provided Cartesians componentwise and returns
568
+ * <code>true</code> if they are equal, <code>false</code> otherwise.
569
+ *
570
+ * @param {Cartesian3} [left] The first Cartesian.
571
+ * @param {Cartesian3} [right] The second Cartesian.
572
+ * @returns {boolean} <code>true</code> if left and right are equal, <code>false</code> otherwise.
573
+ */
574
+ static equals(left, right) {
575
+ return left === right || defined_default(left) && defined_default(right) && left.x === right.x && left.y === right.y && left.z === right.z;
576
+ }
577
+ /**
578
+ * @param {Cartesian3} cartesian
579
+ * @param {number[]} array
580
+ * @param {number} offset
581
+ * @ignore
582
+ */
583
+ static equalsArray(cartesian, array, offset) {
584
+ return cartesian.x === array[offset] && cartesian.y === array[offset + 1] && cartesian.z === array[offset + 2];
585
+ }
586
+ /**
587
+ * Compares the provided Cartesians componentwise and returns
588
+ * <code>true</code> if they pass an absolute or relative tolerance test,
589
+ * <code>false</code> otherwise.
590
+ *
591
+ * @param {Cartesian3} [left] The first Cartesian.
592
+ * @param {Cartesian3} [right] The second Cartesian.
593
+ * @param {number} [relativeEpsilon=0] The relative epsilon tolerance to use for equality testing.
594
+ * @param {number} [absoluteEpsilon=relativeEpsilon] The absolute epsilon tolerance to use for equality testing.
595
+ * @returns {boolean} <code>true</code> if left and right are within the provided epsilon, <code>false</code> otherwise.
596
+ */
597
+ static equalsEpsilon(left, right, relativeEpsilon, absoluteEpsilon) {
598
+ return left === right || defined_default(left) && defined_default(right) && Math_default.equalsEpsilon(
599
+ left.x,
600
+ right.x,
601
+ relativeEpsilon,
602
+ absoluteEpsilon
603
+ ) && Math_default.equalsEpsilon(
604
+ left.y,
605
+ right.y,
606
+ relativeEpsilon,
607
+ absoluteEpsilon
608
+ ) && Math_default.equalsEpsilon(
609
+ left.z,
610
+ right.z,
611
+ relativeEpsilon,
612
+ absoluteEpsilon
613
+ );
614
+ }
615
+ /**
616
+ * Computes the cross (outer) product of two Cartesians.
617
+ *
618
+ * @param {Cartesian3} left The first Cartesian.
619
+ * @param {Cartesian3} right The second Cartesian.
620
+ * @param {Cartesian3} result The object onto which to store the result.
621
+ * @returns {Cartesian3} The cross product.
622
+ */
623
+ static cross(left, right, result) {
624
+ Check_default.typeOf.object("left", left);
625
+ Check_default.typeOf.object("right", right);
626
+ Check_default.typeOf.object("result", result);
627
+ const leftX = left.x;
628
+ const leftY = left.y;
629
+ const leftZ = left.z;
630
+ const rightX = right.x;
631
+ const rightY = right.y;
632
+ const rightZ = right.z;
633
+ const x = leftY * rightZ - leftZ * rightY;
634
+ const y = leftZ * rightX - leftX * rightZ;
635
+ const z = leftX * rightY - leftY * rightX;
636
+ result.x = x;
637
+ result.y = y;
638
+ result.z = z;
639
+ return result;
640
+ }
641
+ /**
642
+ * Computes the midpoint between the right and left Cartesian.
643
+ * @param {Cartesian3} left The first Cartesian.
644
+ * @param {Cartesian3} right The second Cartesian.
645
+ * @param {Cartesian3} result The object onto which to store the result.
646
+ * @returns {Cartesian3} The midpoint.
647
+ */
648
+ static midpoint(left, right, result) {
649
+ Check_default.typeOf.object("left", left);
650
+ Check_default.typeOf.object("right", right);
651
+ Check_default.typeOf.object("result", result);
652
+ result.x = (left.x + right.x) * 0.5;
653
+ result.y = (left.y + right.y) * 0.5;
654
+ result.z = (left.z + right.z) * 0.5;
655
+ return result;
656
+ }
657
+ /**
658
+ * Returns a Cartesian3 position from longitude and latitude values given in degrees.
659
+ *
660
+ * @param {number} longitude The longitude, in degrees
661
+ * @param {number} latitude The latitude, in degrees
662
+ * @param {number} [height=0.0] The height, in meters, above the ellipsoid.
663
+ * @param {Ellipsoid} [ellipsoid=Ellipsoid.default] The ellipsoid on which the position lies.
664
+ * @param {Cartesian3} [result] The object onto which to store the result.
665
+ * @returns {Cartesian3} The position
666
+ *
667
+ * @example
668
+ * const position = Cesium.Cartesian3.fromDegrees(-115.0, 37.0);
669
+ */
670
+ static fromDegrees(longitude, latitude, height, ellipsoid, result) {
671
+ Check_default.typeOf.number("longitude", longitude);
672
+ Check_default.typeOf.number("latitude", latitude);
673
+ longitude = Math_default.toRadians(longitude);
674
+ latitude = Math_default.toRadians(latitude);
675
+ return _Cartesian3.fromRadians(
676
+ longitude,
677
+ latitude,
678
+ height,
679
+ ellipsoid,
680
+ result
681
+ );
682
+ }
683
+ /**
684
+ * Returns a Cartesian3 position from longitude and latitude values given in radians.
685
+ *
686
+ * @param {number} longitude The longitude, in radians
687
+ * @param {number} latitude The latitude, in radians
688
+ * @param {number} [height=0.0] The height, in meters, above the ellipsoid.
689
+ * @param {Ellipsoid} [ellipsoid=Ellipsoid.default] The ellipsoid on which the position lies.
690
+ * @param {Cartesian3} [result] The object onto which to store the result.
691
+ * @returns {Cartesian3} The position
692
+ *
693
+ * @example
694
+ * const position = Cesium.Cartesian3.fromRadians(-2.007, 0.645);
695
+ */
696
+ static fromRadians(longitude, latitude, height, ellipsoid, result) {
697
+ Check_default.typeOf.number("longitude", longitude);
698
+ Check_default.typeOf.number("latitude", latitude);
699
+ height = height ?? 0;
700
+ const radiiSquared = !defined_default(ellipsoid) ? _Cartesian3._ellipsoidRadiiSquared : ellipsoid.radiiSquared;
701
+ const cosLatitude = Math.cos(latitude);
702
+ scratchN.x = cosLatitude * Math.cos(longitude);
703
+ scratchN.y = cosLatitude * Math.sin(longitude);
704
+ scratchN.z = Math.sin(latitude);
705
+ scratchN = _Cartesian3.normalize(scratchN, scratchN);
706
+ _Cartesian3.multiplyComponents(radiiSquared, scratchN, scratchK);
707
+ const gamma = Math.sqrt(_Cartesian3.dot(scratchN, scratchK));
708
+ scratchK = _Cartesian3.divideByScalar(scratchK, gamma, scratchK);
709
+ scratchN = _Cartesian3.multiplyByScalar(scratchN, height, scratchN);
710
+ if (!defined_default(result)) {
711
+ result = new _Cartesian3();
712
+ }
713
+ return _Cartesian3.add(scratchK, scratchN, result);
714
+ }
715
+ /**
716
+ * Returns an array of Cartesian3 positions given an array of longitude and latitude values given in degrees.
717
+ *
718
+ * @param {number[]} coordinates A list of longitude and latitude values. Values alternate [longitude, latitude, longitude, latitude...].
719
+ * @param {Ellipsoid} [ellipsoid=Ellipsoid.default] The ellipsoid on which the coordinates lie.
720
+ * @param {Cartesian3[]} [result] An array of Cartesian3 objects to store the result.
721
+ * @returns {Cartesian3[]} The array of positions.
722
+ *
723
+ * @example
724
+ * const positions = Cesium.Cartesian3.fromDegreesArray([-115.0, 37.0, -107.0, 33.0]);
725
+ */
726
+ static fromDegreesArray(coordinates, ellipsoid, result) {
727
+ Check_default.defined("coordinates", coordinates);
728
+ if (coordinates.length < 2 || coordinates.length % 2 !== 0) {
729
+ throw new DeveloperError_default(
730
+ "the number of coordinates must be a multiple of 2 and at least 2"
731
+ );
732
+ }
733
+ const length = coordinates.length;
734
+ if (!defined_default(result)) {
735
+ result = new Array(length / 2);
736
+ } else {
737
+ result.length = length / 2;
738
+ }
739
+ for (let i = 0; i < length; i += 2) {
740
+ const longitude = coordinates[i];
741
+ const latitude = coordinates[i + 1];
742
+ const index = i / 2;
743
+ result[index] = _Cartesian3.fromDegrees(
744
+ longitude,
745
+ latitude,
746
+ 0,
747
+ ellipsoid,
748
+ result[index]
749
+ );
750
+ }
751
+ return result;
752
+ }
753
+ /**
754
+ * Returns an array of Cartesian3 positions given an array of longitude and latitude values given in radians.
755
+ *
756
+ * @param {number[]} coordinates A list of longitude and latitude values. Values alternate [longitude, latitude, longitude, latitude...].
757
+ * @param {Ellipsoid} [ellipsoid=Ellipsoid.default] The ellipsoid on which the coordinates lie.
758
+ * @param {Cartesian3[]} [result] An array of Cartesian3 objects to store the result.
759
+ * @returns {Cartesian3[]} The array of positions.
760
+ *
761
+ * @example
762
+ * const positions = Cesium.Cartesian3.fromRadiansArray([-2.007, 0.645, -1.867, .575]);
763
+ */
764
+ static fromRadiansArray(coordinates, ellipsoid, result) {
765
+ Check_default.defined("coordinates", coordinates);
766
+ if (coordinates.length < 2 || coordinates.length % 2 !== 0) {
767
+ throw new DeveloperError_default(
768
+ "the number of coordinates must be a multiple of 2 and at least 2"
769
+ );
770
+ }
771
+ const length = coordinates.length;
772
+ if (!defined_default(result)) {
773
+ result = new Array(length / 2);
774
+ } else {
775
+ result.length = length / 2;
776
+ }
777
+ for (let i = 0; i < length; i += 2) {
778
+ const longitude = coordinates[i];
779
+ const latitude = coordinates[i + 1];
780
+ const index = i / 2;
781
+ result[index] = _Cartesian3.fromRadians(
782
+ longitude,
783
+ latitude,
784
+ 0,
785
+ ellipsoid,
786
+ result[index]
787
+ );
788
+ }
789
+ return result;
790
+ }
791
+ /**
792
+ * Returns an array of Cartesian3 positions given an array of longitude, latitude and height values where longitude and latitude are given in degrees.
793
+ *
794
+ * @param {number[]} coordinates A list of longitude, latitude and height values. Values alternate [longitude, latitude, height, longitude, latitude, height...].
795
+ * @param {Ellipsoid} [ellipsoid=Ellipsoid.default] The ellipsoid on which the position lies.
796
+ * @param {Cartesian3[]} [result] An array of Cartesian3 objects to store the result.
797
+ * @returns {Cartesian3[]} The array of positions.
798
+ *
799
+ * @example
800
+ * const positions = Cesium.Cartesian3.fromDegreesArrayHeights([-115.0, 37.0, 100000.0, -107.0, 33.0, 150000.0]);
801
+ */
802
+ static fromDegreesArrayHeights(coordinates, ellipsoid, result) {
803
+ Check_default.defined("coordinates", coordinates);
804
+ if (coordinates.length < 3 || coordinates.length % 3 !== 0) {
805
+ throw new DeveloperError_default(
806
+ "the number of coordinates must be a multiple of 3 and at least 3"
807
+ );
808
+ }
809
+ const length = coordinates.length;
810
+ if (!defined_default(result)) {
811
+ result = new Array(length / 3);
812
+ } else {
813
+ result.length = length / 3;
814
+ }
815
+ for (let i = 0; i < length; i += 3) {
816
+ const longitude = coordinates[i];
817
+ const latitude = coordinates[i + 1];
818
+ const height = coordinates[i + 2];
819
+ const index = i / 3;
820
+ result[index] = _Cartesian3.fromDegrees(
821
+ longitude,
822
+ latitude,
823
+ height,
824
+ ellipsoid,
825
+ result[index]
826
+ );
827
+ }
828
+ return result;
829
+ }
830
+ /**
831
+ * Returns an array of Cartesian3 positions given an array of longitude, latitude and height values where longitude and latitude are given in radians.
832
+ *
833
+ * @param {number[]} coordinates A list of longitude, latitude and height values. Values alternate [longitude, latitude, height, longitude, latitude, height...].
834
+ * @param {Ellipsoid} [ellipsoid=Ellipsoid.default] The ellipsoid on which the position lies.
835
+ * @param {Cartesian3[]} [result] An array of Cartesian3 objects to store the result.
836
+ * @returns {Cartesian3[]} The array of positions.
837
+ *
838
+ * @example
839
+ * const positions = Cesium.Cartesian3.fromRadiansArrayHeights([-2.007, 0.645, 100000.0, -1.867, .575, 150000.0]);
840
+ */
841
+ static fromRadiansArrayHeights(coordinates, ellipsoid, result) {
842
+ Check_default.defined("coordinates", coordinates);
843
+ if (coordinates.length < 3 || coordinates.length % 3 !== 0) {
844
+ throw new DeveloperError_default(
845
+ "the number of coordinates must be a multiple of 3 and at least 3"
846
+ );
847
+ }
848
+ const length = coordinates.length;
849
+ if (!defined_default(result)) {
850
+ result = new Array(length / 3);
851
+ } else {
852
+ result.length = length / 3;
853
+ }
854
+ for (let i = 0; i < length; i += 3) {
855
+ const longitude = coordinates[i];
856
+ const latitude = coordinates[i + 1];
857
+ const height = coordinates[i + 2];
858
+ const index = i / 3;
859
+ result[index] = _Cartesian3.fromRadians(
860
+ longitude,
861
+ latitude,
862
+ height,
863
+ ellipsoid,
864
+ result[index]
865
+ );
866
+ }
867
+ return result;
868
+ }
869
+ /**
870
+ * Duplicates this Cartesian3 instance.
871
+ *
872
+ * @param {Cartesian3} [result] The object onto which to store the result.
873
+ * @returns {Cartesian3} The modified result parameter or a new Cartesian3 instance if one was not provided.
874
+ */
875
+ clone(result) {
876
+ return _Cartesian3.clone(this, result);
877
+ }
878
+ /**
879
+ * Compares this Cartesian against the provided Cartesian componentwise and returns
880
+ * <code>true</code> if they are equal, <code>false</code> otherwise.
881
+ *
882
+ * @param {Cartesian3} [right] The right hand side Cartesian.
883
+ * @returns {boolean} <code>true</code> if they are equal, <code>false</code> otherwise.
884
+ */
885
+ equals(right) {
886
+ return _Cartesian3.equals(this, right);
887
+ }
888
+ /**
889
+ * Compares this Cartesian against the provided Cartesian componentwise and returns
890
+ * <code>true</code> if they pass an absolute or relative tolerance test,
891
+ * <code>false</code> otherwise.
892
+ *
893
+ * @param {Cartesian3} [right] The right hand side Cartesian.
894
+ * @param {number} [relativeEpsilon=0] The relative epsilon tolerance to use for equality testing.
895
+ * @param {number} [absoluteEpsilon=relativeEpsilon] The absolute epsilon tolerance to use for equality testing.
896
+ * @returns {boolean} <code>true</code> if they are within the provided epsilon, <code>false</code> otherwise.
897
+ */
898
+ equalsEpsilon(right, relativeEpsilon, absoluteEpsilon) {
899
+ return _Cartesian3.equalsEpsilon(
900
+ this,
901
+ right,
902
+ relativeEpsilon,
903
+ absoluteEpsilon
904
+ );
905
+ }
906
+ /**
907
+ * Creates a string representing this Cartesian in the format '(x, y, z)'.
908
+ *
909
+ * @returns {string} A string representing this Cartesian in the format '(x, y, z)'.
910
+ */
911
+ toString() {
912
+ return `(${this.x}, ${this.y}, ${this.z})`;
913
+ }
914
+ };
915
+ Cartesian3.fromCartesian4 = Cartesian3.clone;
916
+ Cartesian3.packedLength = 3;
917
+ Cartesian3.fromArray = Cartesian3.unpack;
918
+ var distanceScratch = new Cartesian3();
919
+ var lerpScratch = new Cartesian3();
920
+ var angleBetweenScratch = new Cartesian3();
921
+ var angleBetweenScratch2 = new Cartesian3();
922
+ var mostOrthogonalAxisScratch = new Cartesian3();
923
+ var scratchN = new Cartesian3();
924
+ var scratchK = new Cartesian3();
925
+ Cartesian3._ellipsoidRadiiSquared = new Cartesian3(
926
+ 6378137 * 6378137,
927
+ 6378137 * 6378137,
928
+ 6356752314245179e-9 * 6356752314245179e-9
929
+ );
930
+ Cartesian3.ZERO = Object.freeze(new Cartesian3(0, 0, 0));
931
+ Cartesian3.ONE = Object.freeze(new Cartesian3(1, 1, 1));
932
+ Cartesian3.UNIT_X = Object.freeze(new Cartesian3(1, 0, 0));
933
+ Cartesian3.UNIT_Y = Object.freeze(new Cartesian3(0, 1, 0));
934
+ Cartesian3.UNIT_Z = Object.freeze(new Cartesian3(0, 0, 1));
935
+ var Cartesian3_default = Cartesian3;
936
+
937
+ // packages/engine/Source/Core/Matrix3.js
938
+ var Matrix3 = class _Matrix3 {
939
+ /**
940
+ * @param {number} [column0Row0=0.0] The value for column 0, row 0.
941
+ * @param {number} [column1Row0=0.0] The value for column 1, row 0.
942
+ * @param {number} [column2Row0=0.0] The value for column 2, row 0.
943
+ * @param {number} [column0Row1=0.0] The value for column 0, row 1.
944
+ * @param {number} [column1Row1=0.0] The value for column 1, row 1.
945
+ * @param {number} [column2Row1=0.0] The value for column 2, row 1.
946
+ * @param {number} [column0Row2=0.0] The value for column 0, row 2.
947
+ * @param {number} [column1Row2=0.0] The value for column 1, row 2.
948
+ * @param {number} [column2Row2=0.0] The value for column 2, row 2.
949
+ */
950
+ constructor(column0Row0, column1Row0, column2Row0, column0Row1, column1Row1, column2Row1, column0Row2, column1Row2, column2Row2) {
951
+ this[0] = column0Row0 ?? 0;
952
+ this[1] = column0Row1 ?? 0;
953
+ this[2] = column0Row2 ?? 0;
954
+ this[3] = column1Row0 ?? 0;
955
+ this[4] = column1Row1 ?? 0;
956
+ this[5] = column1Row2 ?? 0;
957
+ this[6] = column2Row0 ?? 0;
958
+ this[7] = column2Row1 ?? 0;
959
+ this[8] = column2Row2 ?? 0;
960
+ }
961
+ /**
962
+ * Stores the provided instance into the provided array.
963
+ *
964
+ * @param {Matrix3} value The value to pack.
965
+ * @param {number[]} array The array to pack into.
966
+ * @param {number} [startingIndex=0] The index into the array at which to start packing the elements.
967
+ *
968
+ * @returns {number[]} The array that was packed into
969
+ */
970
+ static pack(value, array, startingIndex) {
971
+ Check_default.typeOf.object("value", value);
972
+ Check_default.defined("array", array);
973
+ startingIndex = startingIndex ?? 0;
974
+ array[startingIndex++] = value[0];
975
+ array[startingIndex++] = value[1];
976
+ array[startingIndex++] = value[2];
977
+ array[startingIndex++] = value[3];
978
+ array[startingIndex++] = value[4];
979
+ array[startingIndex++] = value[5];
980
+ array[startingIndex++] = value[6];
981
+ array[startingIndex++] = value[7];
982
+ array[startingIndex++] = value[8];
983
+ return array;
984
+ }
985
+ /**
986
+ * Retrieves an instance from a packed array.
987
+ *
988
+ * @param {number[]} array The packed array.
989
+ * @param {number} [startingIndex=0] The starting index of the element to be unpacked.
990
+ * @param {Matrix3} [result] The object into which to store the result.
991
+ * @returns {Matrix3} The modified result parameter or a new Matrix3 instance if one was not provided.
992
+ */
993
+ static unpack(array, startingIndex, result) {
994
+ Check_default.defined("array", array);
995
+ startingIndex = startingIndex ?? 0;
996
+ if (!defined_default(result)) {
997
+ result = new _Matrix3();
998
+ }
999
+ result[0] = array[startingIndex++];
1000
+ result[1] = array[startingIndex++];
1001
+ result[2] = array[startingIndex++];
1002
+ result[3] = array[startingIndex++];
1003
+ result[4] = array[startingIndex++];
1004
+ result[5] = array[startingIndex++];
1005
+ result[6] = array[startingIndex++];
1006
+ result[7] = array[startingIndex++];
1007
+ result[8] = array[startingIndex++];
1008
+ return result;
1009
+ }
1010
+ /**
1011
+ * Flattens an array of Matrix3s into an array of components. The components
1012
+ * are stored in column-major order.
1013
+ *
1014
+ * @param {Matrix3[]} array The array of matrices to pack.
1015
+ * @param {number[]} [result] The array onto which to store the result. If this is a typed array, it must have array.length * 9 components, else a {@link DeveloperError} will be thrown. If it is a regular array, it will be resized to have (array.length * 9) elements.
1016
+ * @returns {number[]} The packed array.
1017
+ */
1018
+ static packArray(array, result) {
1019
+ Check_default.defined("array", array);
1020
+ const length = array.length;
1021
+ const resultLength = length * 9;
1022
+ if (!defined_default(result)) {
1023
+ result = new Array(resultLength);
1024
+ } else if (!Array.isArray(result) && result.length !== resultLength) {
1025
+ throw new DeveloperError_default(
1026
+ "If result is a typed array, it must have exactly array.length * 9 elements"
1027
+ );
1028
+ } else if (result.length !== resultLength) {
1029
+ result.length = resultLength;
1030
+ }
1031
+ for (let i = 0; i < length; ++i) {
1032
+ _Matrix3.pack(array[i], result, i * 9);
1033
+ }
1034
+ return result;
1035
+ }
1036
+ /**
1037
+ * Unpacks an array of column-major matrix components into an array of Matrix3s.
1038
+ *
1039
+ * @param {number[]} array The array of components to unpack.
1040
+ * @param {Matrix3[]} [result] The array onto which to store the result.
1041
+ * @returns {Matrix3[]} The unpacked array.
1042
+ */
1043
+ static unpackArray(array, result) {
1044
+ Check_default.defined("array", array);
1045
+ Check_default.typeOf.number.greaterThanOrEquals("array.length", array.length, 9);
1046
+ if (array.length % 9 !== 0) {
1047
+ throw new DeveloperError_default("array length must be a multiple of 9.");
1048
+ }
1049
+ const length = array.length;
1050
+ if (!defined_default(result)) {
1051
+ result = new Array(length / 9);
1052
+ } else {
1053
+ result.length = length / 9;
1054
+ }
1055
+ for (let i = 0; i < length; i += 9) {
1056
+ const index = i / 9;
1057
+ result[index] = _Matrix3.unpack(array, i, result[index]);
1058
+ }
1059
+ return result;
1060
+ }
1061
+ /**
1062
+ * Duplicates a Matrix3 instance.
1063
+ *
1064
+ * @param {Matrix3} matrix The matrix to duplicate.
1065
+ * @param {Matrix3} [result] The object onto which to store the result.
1066
+ * @returns {Matrix3} The modified result parameter or a new Matrix3 instance if one was not provided. (Returns undefined if matrix is undefined)
1067
+ */
1068
+ static clone(matrix, result) {
1069
+ if (!defined_default(matrix)) {
1070
+ return void 0;
1071
+ }
1072
+ if (!defined_default(result)) {
1073
+ return new _Matrix3(
1074
+ matrix[0],
1075
+ matrix[3],
1076
+ matrix[6],
1077
+ matrix[1],
1078
+ matrix[4],
1079
+ matrix[7],
1080
+ matrix[2],
1081
+ matrix[5],
1082
+ matrix[8]
1083
+ );
1084
+ }
1085
+ result[0] = matrix[0];
1086
+ result[1] = matrix[1];
1087
+ result[2] = matrix[2];
1088
+ result[3] = matrix[3];
1089
+ result[4] = matrix[4];
1090
+ result[5] = matrix[5];
1091
+ result[6] = matrix[6];
1092
+ result[7] = matrix[7];
1093
+ result[8] = matrix[8];
1094
+ return result;
1095
+ }
1096
+ /**
1097
+ * Creates a Matrix3 instance from a column-major order array.
1098
+ *
1099
+ * @param {number[]} values The column-major order array.
1100
+ * @param {Matrix3} [result] The object in which the result will be stored, if undefined a new instance will be created.
1101
+ * @returns {Matrix3} The modified result parameter, or a new Matrix3 instance if one was not provided.
1102
+ */
1103
+ static fromColumnMajorArray(values, result) {
1104
+ Check_default.defined("values", values);
1105
+ return _Matrix3.clone(values, result);
1106
+ }
1107
+ /**
1108
+ * Creates a Matrix3 instance from a row-major order array.
1109
+ * The resulting matrix will be in column-major order.
1110
+ *
1111
+ * @param {number[]} values The row-major order array.
1112
+ * @param {Matrix3} [result] The object in which the result will be stored, if undefined a new instance will be created.
1113
+ * @returns {Matrix3} The modified result parameter, or a new Matrix3 instance if one was not provided.
1114
+ */
1115
+ static fromRowMajorArray(values, result) {
1116
+ Check_default.defined("values", values);
1117
+ if (!defined_default(result)) {
1118
+ return new _Matrix3(
1119
+ values[0],
1120
+ values[1],
1121
+ values[2],
1122
+ values[3],
1123
+ values[4],
1124
+ values[5],
1125
+ values[6],
1126
+ values[7],
1127
+ values[8]
1128
+ );
1129
+ }
1130
+ result[0] = values[0];
1131
+ result[1] = values[3];
1132
+ result[2] = values[6];
1133
+ result[3] = values[1];
1134
+ result[4] = values[4];
1135
+ result[5] = values[7];
1136
+ result[6] = values[2];
1137
+ result[7] = values[5];
1138
+ result[8] = values[8];
1139
+ return result;
1140
+ }
1141
+ /**
1142
+ * Computes a 3x3 rotation matrix from the provided quaternion.
1143
+ *
1144
+ * @param {Quaternion} quaternion the quaternion to use.
1145
+ * @param {Matrix3} [result] The object in which the result will be stored, if undefined a new instance will be created.
1146
+ * @returns {Matrix3} The 3x3 rotation matrix from this quaternion.
1147
+ */
1148
+ static fromQuaternion(quaternion, result) {
1149
+ Check_default.typeOf.object("quaternion", quaternion);
1150
+ const x2 = quaternion.x * quaternion.x;
1151
+ const xy = quaternion.x * quaternion.y;
1152
+ const xz = quaternion.x * quaternion.z;
1153
+ const xw = quaternion.x * quaternion.w;
1154
+ const y2 = quaternion.y * quaternion.y;
1155
+ const yz = quaternion.y * quaternion.z;
1156
+ const yw = quaternion.y * quaternion.w;
1157
+ const z2 = quaternion.z * quaternion.z;
1158
+ const zw = quaternion.z * quaternion.w;
1159
+ const w2 = quaternion.w * quaternion.w;
1160
+ const m00 = x2 - y2 - z2 + w2;
1161
+ const m01 = 2 * (xy - zw);
1162
+ const m02 = 2 * (xz + yw);
1163
+ const m10 = 2 * (xy + zw);
1164
+ const m11 = -x2 + y2 - z2 + w2;
1165
+ const m12 = 2 * (yz - xw);
1166
+ const m20 = 2 * (xz - yw);
1167
+ const m21 = 2 * (yz + xw);
1168
+ const m22 = -x2 - y2 + z2 + w2;
1169
+ if (!defined_default(result)) {
1170
+ return new _Matrix3(m00, m01, m02, m10, m11, m12, m20, m21, m22);
1171
+ }
1172
+ result[0] = m00;
1173
+ result[1] = m10;
1174
+ result[2] = m20;
1175
+ result[3] = m01;
1176
+ result[4] = m11;
1177
+ result[5] = m21;
1178
+ result[6] = m02;
1179
+ result[7] = m12;
1180
+ result[8] = m22;
1181
+ return result;
1182
+ }
1183
+ /**
1184
+ * Computes a 3x3 rotation matrix from the provided headingPitchRoll. (see http://en.wikipedia.org/wiki/Conversion_between_quaternions_and_Euler_angles )
1185
+ *
1186
+ * @param {HeadingPitchRoll} headingPitchRoll the headingPitchRoll to use.
1187
+ * @param {Matrix3} [result] The object in which the result will be stored, if undefined a new instance will be created.
1188
+ * @returns {Matrix3} The 3x3 rotation matrix from this headingPitchRoll.
1189
+ */
1190
+ static fromHeadingPitchRoll(headingPitchRoll, result) {
1191
+ Check_default.typeOf.object("headingPitchRoll", headingPitchRoll);
1192
+ const cosTheta = Math.cos(-headingPitchRoll.pitch);
1193
+ const cosPsi = Math.cos(-headingPitchRoll.heading);
1194
+ const cosPhi = Math.cos(headingPitchRoll.roll);
1195
+ const sinTheta = Math.sin(-headingPitchRoll.pitch);
1196
+ const sinPsi = Math.sin(-headingPitchRoll.heading);
1197
+ const sinPhi = Math.sin(headingPitchRoll.roll);
1198
+ const m00 = cosTheta * cosPsi;
1199
+ const m01 = -cosPhi * sinPsi + sinPhi * sinTheta * cosPsi;
1200
+ const m02 = sinPhi * sinPsi + cosPhi * sinTheta * cosPsi;
1201
+ const m10 = cosTheta * sinPsi;
1202
+ const m11 = cosPhi * cosPsi + sinPhi * sinTheta * sinPsi;
1203
+ const m12 = -sinPhi * cosPsi + cosPhi * sinTheta * sinPsi;
1204
+ const m20 = -sinTheta;
1205
+ const m21 = sinPhi * cosTheta;
1206
+ const m22 = cosPhi * cosTheta;
1207
+ if (!defined_default(result)) {
1208
+ return new _Matrix3(m00, m01, m02, m10, m11, m12, m20, m21, m22);
1209
+ }
1210
+ result[0] = m00;
1211
+ result[1] = m10;
1212
+ result[2] = m20;
1213
+ result[3] = m01;
1214
+ result[4] = m11;
1215
+ result[5] = m21;
1216
+ result[6] = m02;
1217
+ result[7] = m12;
1218
+ result[8] = m22;
1219
+ return result;
1220
+ }
1221
+ /**
1222
+ * Computes a Matrix3 instance representing a non-uniform scale.
1223
+ *
1224
+ * @param {Cartesian3} scale The x, y, and z scale factors.
1225
+ * @param {Matrix3} [result] The object in which the result will be stored, if undefined a new instance will be created.
1226
+ * @returns {Matrix3} The modified result parameter, or a new Matrix3 instance if one was not provided.
1227
+ *
1228
+ * @example
1229
+ * // Creates
1230
+ * // [7.0, 0.0, 0.0]
1231
+ * // [0.0, 8.0, 0.0]
1232
+ * // [0.0, 0.0, 9.0]
1233
+ * const m = Cesium.Matrix3.fromScale(new Cesium.Cartesian3(7.0, 8.0, 9.0));
1234
+ */
1235
+ static fromScale(scale, result) {
1236
+ Check_default.typeOf.object("scale", scale);
1237
+ if (!defined_default(result)) {
1238
+ return new _Matrix3(
1239
+ scale.x,
1240
+ 0,
1241
+ 0,
1242
+ 0,
1243
+ scale.y,
1244
+ 0,
1245
+ 0,
1246
+ 0,
1247
+ scale.z
1248
+ );
1249
+ }
1250
+ result[0] = scale.x;
1251
+ result[1] = 0;
1252
+ result[2] = 0;
1253
+ result[3] = 0;
1254
+ result[4] = scale.y;
1255
+ result[5] = 0;
1256
+ result[6] = 0;
1257
+ result[7] = 0;
1258
+ result[8] = scale.z;
1259
+ return result;
1260
+ }
1261
+ /**
1262
+ * Computes a Matrix3 instance representing a uniform scale.
1263
+ *
1264
+ * @param {number} scale The uniform scale factor.
1265
+ * @param {Matrix3} [result] The object in which the result will be stored, if undefined a new instance will be created.
1266
+ * @returns {Matrix3} The modified result parameter, or a new Matrix3 instance if one was not provided.
1267
+ *
1268
+ * @example
1269
+ * // Creates
1270
+ * // [2.0, 0.0, 0.0]
1271
+ * // [0.0, 2.0, 0.0]
1272
+ * // [0.0, 0.0, 2.0]
1273
+ * const m = Cesium.Matrix3.fromUniformScale(2.0);
1274
+ */
1275
+ static fromUniformScale(scale, result) {
1276
+ Check_default.typeOf.number("scale", scale);
1277
+ if (!defined_default(result)) {
1278
+ return new _Matrix3(scale, 0, 0, 0, scale, 0, 0, 0, scale);
1279
+ }
1280
+ result[0] = scale;
1281
+ result[1] = 0;
1282
+ result[2] = 0;
1283
+ result[3] = 0;
1284
+ result[4] = scale;
1285
+ result[5] = 0;
1286
+ result[6] = 0;
1287
+ result[7] = 0;
1288
+ result[8] = scale;
1289
+ return result;
1290
+ }
1291
+ /**
1292
+ * Computes a Matrix3 instance representing the cross product equivalent matrix of a Cartesian3 vector.
1293
+ *
1294
+ * @param {Cartesian3} vector the vector on the left hand side of the cross product operation.
1295
+ * @param {Matrix3} [result] The object in which the result will be stored, if undefined a new instance will be created.
1296
+ * @returns {Matrix3} The modified result parameter, or a new Matrix3 instance if one was not provided.
1297
+ *
1298
+ * @example
1299
+ * // Creates
1300
+ * // [0.0, -9.0, 8.0]
1301
+ * // [9.0, 0.0, -7.0]
1302
+ * // [-8.0, 7.0, 0.0]
1303
+ * const m = Cesium.Matrix3.fromCrossProduct(new Cesium.Cartesian3(7.0, 8.0, 9.0));
1304
+ */
1305
+ static fromCrossProduct(vector, result) {
1306
+ Check_default.typeOf.object("vector", vector);
1307
+ if (!defined_default(result)) {
1308
+ return new _Matrix3(
1309
+ 0,
1310
+ -vector.z,
1311
+ vector.y,
1312
+ vector.z,
1313
+ 0,
1314
+ -vector.x,
1315
+ -vector.y,
1316
+ vector.x,
1317
+ 0
1318
+ );
1319
+ }
1320
+ result[0] = 0;
1321
+ result[1] = vector.z;
1322
+ result[2] = -vector.y;
1323
+ result[3] = -vector.z;
1324
+ result[4] = 0;
1325
+ result[5] = vector.x;
1326
+ result[6] = vector.y;
1327
+ result[7] = -vector.x;
1328
+ result[8] = 0;
1329
+ return result;
1330
+ }
1331
+ /**
1332
+ * Creates a rotation matrix around the x-axis.
1333
+ *
1334
+ * @param {number} angle The angle, in radians, of the rotation. Positive angles are counterclockwise.
1335
+ * @param {Matrix3} [result] The object in which the result will be stored, if undefined a new instance will be created.
1336
+ * @returns {Matrix3} The modified result parameter, or a new Matrix3 instance if one was not provided.
1337
+ *
1338
+ * @example
1339
+ * // Rotate a point 45 degrees counterclockwise around the x-axis.
1340
+ * const p = new Cesium.Cartesian3(5, 6, 7);
1341
+ * const m = Cesium.Matrix3.fromRotationX(Cesium.Math.toRadians(45.0));
1342
+ * const rotated = Cesium.Matrix3.multiplyByVector(m, p, new Cesium.Cartesian3());
1343
+ */
1344
+ static fromRotationX(angle, result) {
1345
+ Check_default.typeOf.number("angle", angle);
1346
+ const cosAngle = Math.cos(angle);
1347
+ const sinAngle = Math.sin(angle);
1348
+ if (!defined_default(result)) {
1349
+ return new _Matrix3(
1350
+ 1,
1351
+ 0,
1352
+ 0,
1353
+ 0,
1354
+ cosAngle,
1355
+ -sinAngle,
1356
+ 0,
1357
+ sinAngle,
1358
+ cosAngle
1359
+ );
1360
+ }
1361
+ result[0] = 1;
1362
+ result[1] = 0;
1363
+ result[2] = 0;
1364
+ result[3] = 0;
1365
+ result[4] = cosAngle;
1366
+ result[5] = sinAngle;
1367
+ result[6] = 0;
1368
+ result[7] = -sinAngle;
1369
+ result[8] = cosAngle;
1370
+ return result;
1371
+ }
1372
+ /**
1373
+ * Creates a rotation matrix around the y-axis.
1374
+ *
1375
+ * @param {number} angle The angle, in radians, of the rotation. Positive angles are counterclockwise.
1376
+ * @param {Matrix3} [result] The object in which the result will be stored, if undefined a new instance will be created.
1377
+ * @returns {Matrix3} The modified result parameter, or a new Matrix3 instance if one was not provided.
1378
+ *
1379
+ * @example
1380
+ * // Rotate a point 45 degrees counterclockwise around the y-axis.
1381
+ * const p = new Cesium.Cartesian3(5, 6, 7);
1382
+ * const m = Cesium.Matrix3.fromRotationY(Cesium.Math.toRadians(45.0));
1383
+ * const rotated = Cesium.Matrix3.multiplyByVector(m, p, new Cesium.Cartesian3());
1384
+ */
1385
+ static fromRotationY(angle, result) {
1386
+ Check_default.typeOf.number("angle", angle);
1387
+ const cosAngle = Math.cos(angle);
1388
+ const sinAngle = Math.sin(angle);
1389
+ if (!defined_default(result)) {
1390
+ return new _Matrix3(
1391
+ cosAngle,
1392
+ 0,
1393
+ sinAngle,
1394
+ 0,
1395
+ 1,
1396
+ 0,
1397
+ -sinAngle,
1398
+ 0,
1399
+ cosAngle
1400
+ );
1401
+ }
1402
+ result[0] = cosAngle;
1403
+ result[1] = 0;
1404
+ result[2] = -sinAngle;
1405
+ result[3] = 0;
1406
+ result[4] = 1;
1407
+ result[5] = 0;
1408
+ result[6] = sinAngle;
1409
+ result[7] = 0;
1410
+ result[8] = cosAngle;
1411
+ return result;
1412
+ }
1413
+ /**
1414
+ * Creates a rotation matrix around the z-axis.
1415
+ *
1416
+ * @param {number} angle The angle, in radians, of the rotation. Positive angles are counterclockwise.
1417
+ * @param {Matrix3} [result] The object in which the result will be stored, if undefined a new instance will be created.
1418
+ * @returns {Matrix3} The modified result parameter, or a new Matrix3 instance if one was not provided.
1419
+ *
1420
+ * @example
1421
+ * // Rotate a point 45 degrees counterclockwise around the z-axis.
1422
+ * const p = new Cesium.Cartesian3(5, 6, 7);
1423
+ * const m = Cesium.Matrix3.fromRotationZ(Cesium.Math.toRadians(45.0));
1424
+ * const rotated = Cesium.Matrix3.multiplyByVector(m, p, new Cesium.Cartesian3());
1425
+ */
1426
+ static fromRotationZ(angle, result) {
1427
+ Check_default.typeOf.number("angle", angle);
1428
+ const cosAngle = Math.cos(angle);
1429
+ const sinAngle = Math.sin(angle);
1430
+ if (!defined_default(result)) {
1431
+ return new _Matrix3(
1432
+ cosAngle,
1433
+ -sinAngle,
1434
+ 0,
1435
+ sinAngle,
1436
+ cosAngle,
1437
+ 0,
1438
+ 0,
1439
+ 0,
1440
+ 1
1441
+ );
1442
+ }
1443
+ result[0] = cosAngle;
1444
+ result[1] = sinAngle;
1445
+ result[2] = 0;
1446
+ result[3] = -sinAngle;
1447
+ result[4] = cosAngle;
1448
+ result[5] = 0;
1449
+ result[6] = 0;
1450
+ result[7] = 0;
1451
+ result[8] = 1;
1452
+ return result;
1453
+ }
1454
+ /**
1455
+ * Creates an Array from the provided Matrix3 instance.
1456
+ * The array will be in column-major order.
1457
+ *
1458
+ * @param {Matrix3} matrix The matrix to use..
1459
+ * @param {number[]} [result] The Array onto which to store the result.
1460
+ * @returns {number[]} The modified Array parameter or a new Array instance if one was not provided.
1461
+ */
1462
+ static toArray(matrix, result) {
1463
+ Check_default.typeOf.object("matrix", matrix);
1464
+ if (!defined_default(result)) {
1465
+ return [
1466
+ matrix[0],
1467
+ matrix[1],
1468
+ matrix[2],
1469
+ matrix[3],
1470
+ matrix[4],
1471
+ matrix[5],
1472
+ matrix[6],
1473
+ matrix[7],
1474
+ matrix[8]
1475
+ ];
1476
+ }
1477
+ result[0] = matrix[0];
1478
+ result[1] = matrix[1];
1479
+ result[2] = matrix[2];
1480
+ result[3] = matrix[3];
1481
+ result[4] = matrix[4];
1482
+ result[5] = matrix[5];
1483
+ result[6] = matrix[6];
1484
+ result[7] = matrix[7];
1485
+ result[8] = matrix[8];
1486
+ return result;
1487
+ }
1488
+ /**
1489
+ * Computes the array index of the element at the provided row and column.
1490
+ *
1491
+ * @param {number} column The zero-based index of the column.
1492
+ * @param {number} row The zero-based index of the row.
1493
+ * @returns {number} The index of the element at the provided row and column.
1494
+ *
1495
+ * @exception {DeveloperError} row must be 0, 1, or 2.
1496
+ * @exception {DeveloperError} column must be 0, 1, or 2.
1497
+ *
1498
+ * @example
1499
+ * const myMatrix = new Cesium.Matrix3();
1500
+ * const column1Row0Index = Cesium.Matrix3.getElementIndex(1, 0);
1501
+ * const column1Row0 = myMatrix[column1Row0Index]
1502
+ * myMatrix[column1Row0Index] = 10.0;
1503
+ */
1504
+ static getElementIndex(column, row) {
1505
+ Check_default.typeOf.number.greaterThanOrEquals("row", row, 0);
1506
+ Check_default.typeOf.number.lessThanOrEquals("row", row, 2);
1507
+ Check_default.typeOf.number.greaterThanOrEquals("column", column, 0);
1508
+ Check_default.typeOf.number.lessThanOrEquals("column", column, 2);
1509
+ return column * 3 + row;
1510
+ }
1511
+ /**
1512
+ * Retrieves a copy of the matrix column at the provided index as a Cartesian3 instance.
1513
+ *
1514
+ * @param {Matrix3} matrix The matrix to use.
1515
+ * @param {number} index The zero-based index of the column to retrieve.
1516
+ * @param {Cartesian3} result The object onto which to store the result.
1517
+ * @returns {Cartesian3} The modified result parameter.
1518
+ *
1519
+ * @exception {DeveloperError} index must be 0, 1, or 2.
1520
+ */
1521
+ static getColumn(matrix, index, result) {
1522
+ Check_default.typeOf.object("matrix", matrix);
1523
+ Check_default.typeOf.number.greaterThanOrEquals("index", index, 0);
1524
+ Check_default.typeOf.number.lessThanOrEquals("index", index, 2);
1525
+ Check_default.typeOf.object("result", result);
1526
+ const startIndex = index * 3;
1527
+ const x = matrix[startIndex];
1528
+ const y = matrix[startIndex + 1];
1529
+ const z = matrix[startIndex + 2];
1530
+ result.x = x;
1531
+ result.y = y;
1532
+ result.z = z;
1533
+ return result;
1534
+ }
1535
+ /**
1536
+ * Computes a new matrix that replaces the specified column in the provided matrix with the provided Cartesian3 instance.
1537
+ *
1538
+ * @param {Matrix3} matrix The matrix to use.
1539
+ * @param {number} index The zero-based index of the column to set.
1540
+ * @param {Cartesian3} cartesian The Cartesian whose values will be assigned to the specified column.
1541
+ * @param {Matrix3} result The object onto which to store the result.
1542
+ * @returns {Matrix3} The modified result parameter.
1543
+ *
1544
+ * @exception {DeveloperError} index must be 0, 1, or 2.
1545
+ */
1546
+ static setColumn(matrix, index, cartesian, result) {
1547
+ Check_default.typeOf.object("matrix", matrix);
1548
+ Check_default.typeOf.number.greaterThanOrEquals("index", index, 0);
1549
+ Check_default.typeOf.number.lessThanOrEquals("index", index, 2);
1550
+ Check_default.typeOf.object("cartesian", cartesian);
1551
+ Check_default.typeOf.object("result", result);
1552
+ result = _Matrix3.clone(matrix, result);
1553
+ const startIndex = index * 3;
1554
+ result[startIndex] = cartesian.x;
1555
+ result[startIndex + 1] = cartesian.y;
1556
+ result[startIndex + 2] = cartesian.z;
1557
+ return result;
1558
+ }
1559
+ /**
1560
+ * Retrieves a copy of the matrix row at the provided index as a Cartesian3 instance.
1561
+ *
1562
+ * @param {Matrix3} matrix The matrix to use.
1563
+ * @param {number} index The zero-based index of the row to retrieve.
1564
+ * @param {Cartesian3} result The object onto which to store the result.
1565
+ * @returns {Cartesian3} The modified result parameter.
1566
+ *
1567
+ * @exception {DeveloperError} index must be 0, 1, or 2.
1568
+ */
1569
+ static getRow(matrix, index, result) {
1570
+ Check_default.typeOf.object("matrix", matrix);
1571
+ Check_default.typeOf.number.greaterThanOrEquals("index", index, 0);
1572
+ Check_default.typeOf.number.lessThanOrEquals("index", index, 2);
1573
+ Check_default.typeOf.object("result", result);
1574
+ const x = matrix[index];
1575
+ const y = matrix[index + 3];
1576
+ const z = matrix[index + 6];
1577
+ result.x = x;
1578
+ result.y = y;
1579
+ result.z = z;
1580
+ return result;
1581
+ }
1582
+ /**
1583
+ * Computes a new matrix that replaces the specified row in the provided matrix with the provided Cartesian3 instance.
1584
+ *
1585
+ * @param {Matrix3} matrix The matrix to use.
1586
+ * @param {number} index The zero-based index of the row to set.
1587
+ * @param {Cartesian3} cartesian The Cartesian whose values will be assigned to the specified row.
1588
+ * @param {Matrix3} result The object onto which to store the result.
1589
+ * @returns {Matrix3} The modified result parameter.
1590
+ *
1591
+ * @exception {DeveloperError} index must be 0, 1, or 2.
1592
+ */
1593
+ static setRow(matrix, index, cartesian, result) {
1594
+ Check_default.typeOf.object("matrix", matrix);
1595
+ Check_default.typeOf.number.greaterThanOrEquals("index", index, 0);
1596
+ Check_default.typeOf.number.lessThanOrEquals("index", index, 2);
1597
+ Check_default.typeOf.object("cartesian", cartesian);
1598
+ Check_default.typeOf.object("result", result);
1599
+ result = _Matrix3.clone(matrix, result);
1600
+ result[index] = cartesian.x;
1601
+ result[index + 3] = cartesian.y;
1602
+ result[index + 6] = cartesian.z;
1603
+ return result;
1604
+ }
1605
+ /**
1606
+ * Computes a new matrix that replaces the scale with the provided scale.
1607
+ * This assumes the matrix is an affine transformation.
1608
+ *
1609
+ * @param {Matrix3} matrix The matrix to use.
1610
+ * @param {Cartesian3} scale The scale that replaces the scale of the provided matrix.
1611
+ * @param {Matrix3} result The object onto which to store the result.
1612
+ * @returns {Matrix3} The modified result parameter.
1613
+ *
1614
+ * @see Matrix3.setUniformScale
1615
+ * @see Matrix3.fromScale
1616
+ * @see Matrix3.fromUniformScale
1617
+ * @see Matrix3.multiplyByScale
1618
+ * @see Matrix3.multiplyByUniformScale
1619
+ * @see Matrix3.getScale
1620
+ */
1621
+ static setScale(matrix, scale, result) {
1622
+ Check_default.typeOf.object("matrix", matrix);
1623
+ Check_default.typeOf.object("scale", scale);
1624
+ Check_default.typeOf.object("result", result);
1625
+ const existingScale = _Matrix3.getScale(matrix, scaleScratch1);
1626
+ const scaleRatioX = scale.x / existingScale.x;
1627
+ const scaleRatioY = scale.y / existingScale.y;
1628
+ const scaleRatioZ = scale.z / existingScale.z;
1629
+ result[0] = matrix[0] * scaleRatioX;
1630
+ result[1] = matrix[1] * scaleRatioX;
1631
+ result[2] = matrix[2] * scaleRatioX;
1632
+ result[3] = matrix[3] * scaleRatioY;
1633
+ result[4] = matrix[4] * scaleRatioY;
1634
+ result[5] = matrix[5] * scaleRatioY;
1635
+ result[6] = matrix[6] * scaleRatioZ;
1636
+ result[7] = matrix[7] * scaleRatioZ;
1637
+ result[8] = matrix[8] * scaleRatioZ;
1638
+ return result;
1639
+ }
1640
+ /**
1641
+ * Computes a new matrix that replaces the scale with the provided uniform scale.
1642
+ * This assumes the matrix is an affine transformation.
1643
+ *
1644
+ * @param {Matrix3} matrix The matrix to use.
1645
+ * @param {number} scale The uniform scale that replaces the scale of the provided matrix.
1646
+ * @param {Matrix3} result The object onto which to store the result.
1647
+ * @returns {Matrix3} The modified result parameter.
1648
+ *
1649
+ * @see Matrix3.setScale
1650
+ * @see Matrix3.fromScale
1651
+ * @see Matrix3.fromUniformScale
1652
+ * @see Matrix3.multiplyByScale
1653
+ * @see Matrix3.multiplyByUniformScale
1654
+ * @see Matrix3.getScale
1655
+ */
1656
+ static setUniformScale(matrix, scale, result) {
1657
+ Check_default.typeOf.object("matrix", matrix);
1658
+ Check_default.typeOf.number("scale", scale);
1659
+ Check_default.typeOf.object("result", result);
1660
+ const existingScale = _Matrix3.getScale(matrix, scaleScratch2);
1661
+ const scaleRatioX = scale / existingScale.x;
1662
+ const scaleRatioY = scale / existingScale.y;
1663
+ const scaleRatioZ = scale / existingScale.z;
1664
+ result[0] = matrix[0] * scaleRatioX;
1665
+ result[1] = matrix[1] * scaleRatioX;
1666
+ result[2] = matrix[2] * scaleRatioX;
1667
+ result[3] = matrix[3] * scaleRatioY;
1668
+ result[4] = matrix[4] * scaleRatioY;
1669
+ result[5] = matrix[5] * scaleRatioY;
1670
+ result[6] = matrix[6] * scaleRatioZ;
1671
+ result[7] = matrix[7] * scaleRatioZ;
1672
+ result[8] = matrix[8] * scaleRatioZ;
1673
+ return result;
1674
+ }
1675
+ /**
1676
+ * Extracts the non-uniform scale assuming the matrix is an affine transformation.
1677
+ *
1678
+ * @param {Matrix3} matrix The matrix.
1679
+ * @param {Cartesian3} result The object onto which to store the result.
1680
+ * @returns {Cartesian3} The modified result parameter.
1681
+ *
1682
+ * @see Matrix3.multiplyByScale
1683
+ * @see Matrix3.multiplyByUniformScale
1684
+ * @see Matrix3.fromScale
1685
+ * @see Matrix3.fromUniformScale
1686
+ * @see Matrix3.setScale
1687
+ * @see Matrix3.setUniformScale
1688
+ */
1689
+ static getScale(matrix, result) {
1690
+ Check_default.typeOf.object("matrix", matrix);
1691
+ Check_default.typeOf.object("result", result);
1692
+ result.x = Cartesian3_default.magnitude(
1693
+ Cartesian3_default.fromElements(matrix[0], matrix[1], matrix[2], scratchColumn)
1694
+ );
1695
+ result.y = Cartesian3_default.magnitude(
1696
+ Cartesian3_default.fromElements(matrix[3], matrix[4], matrix[5], scratchColumn)
1697
+ );
1698
+ result.z = Cartesian3_default.magnitude(
1699
+ Cartesian3_default.fromElements(matrix[6], matrix[7], matrix[8], scratchColumn)
1700
+ );
1701
+ return result;
1702
+ }
1703
+ /**
1704
+ * Computes the maximum scale assuming the matrix is an affine transformation.
1705
+ * The maximum scale is the maximum length of the column vectors.
1706
+ *
1707
+ * @param {Matrix3} matrix The matrix.
1708
+ * @returns {number} The maximum scale.
1709
+ */
1710
+ static getMaximumScale(matrix) {
1711
+ _Matrix3.getScale(matrix, scaleScratch3);
1712
+ return Cartesian3_default.maximumComponent(scaleScratch3);
1713
+ }
1714
+ /**
1715
+ * Sets the rotation assuming the matrix is an affine transformation.
1716
+ *
1717
+ * @param {Matrix3} matrix The matrix.
1718
+ * @param {Matrix3} rotation The rotation matrix.
1719
+ * @param {Matrix3} result The object onto which to store the result.
1720
+ * @returns {Matrix3} The modified result parameter.
1721
+ *
1722
+ * @see Matrix3.getRotation
1723
+ */
1724
+ static setRotation(matrix, rotation, result) {
1725
+ Check_default.typeOf.object("matrix", matrix);
1726
+ Check_default.typeOf.object("result", result);
1727
+ const scale = _Matrix3.getScale(matrix, scaleScratch4);
1728
+ result[0] = rotation[0] * scale.x;
1729
+ result[1] = rotation[1] * scale.x;
1730
+ result[2] = rotation[2] * scale.x;
1731
+ result[3] = rotation[3] * scale.y;
1732
+ result[4] = rotation[4] * scale.y;
1733
+ result[5] = rotation[5] * scale.y;
1734
+ result[6] = rotation[6] * scale.z;
1735
+ result[7] = rotation[7] * scale.z;
1736
+ result[8] = rotation[8] * scale.z;
1737
+ return result;
1738
+ }
1739
+ /**
1740
+ * Extracts the rotation matrix assuming the matrix is an affine transformation.
1741
+ *
1742
+ * @param {Matrix3} matrix The matrix.
1743
+ * @param {Matrix3} result The object onto which to store the result.
1744
+ * @returns {Matrix3} The modified result parameter.
1745
+ *
1746
+ * @see Matrix3.setRotation
1747
+ */
1748
+ static getRotation(matrix, result) {
1749
+ Check_default.typeOf.object("matrix", matrix);
1750
+ Check_default.typeOf.object("result", result);
1751
+ const scale = _Matrix3.getScale(matrix, scaleScratch5);
1752
+ result[0] = matrix[0] / scale.x;
1753
+ result[1] = matrix[1] / scale.x;
1754
+ result[2] = matrix[2] / scale.x;
1755
+ result[3] = matrix[3] / scale.y;
1756
+ result[4] = matrix[4] / scale.y;
1757
+ result[5] = matrix[5] / scale.y;
1758
+ result[6] = matrix[6] / scale.z;
1759
+ result[7] = matrix[7] / scale.z;
1760
+ result[8] = matrix[8] / scale.z;
1761
+ return result;
1762
+ }
1763
+ /**
1764
+ * Computes the product of two matrices.
1765
+ *
1766
+ * @param {Matrix3} left The first matrix.
1767
+ * @param {Matrix3} right The second matrix.
1768
+ * @param {Matrix3} result The object onto which to store the result.
1769
+ * @returns {Matrix3} The modified result parameter.
1770
+ */
1771
+ static multiply(left, right, result) {
1772
+ Check_default.typeOf.object("left", left);
1773
+ Check_default.typeOf.object("right", right);
1774
+ Check_default.typeOf.object("result", result);
1775
+ const column0Row0 = left[0] * right[0] + left[3] * right[1] + left[6] * right[2];
1776
+ const column0Row1 = left[1] * right[0] + left[4] * right[1] + left[7] * right[2];
1777
+ const column0Row2 = left[2] * right[0] + left[5] * right[1] + left[8] * right[2];
1778
+ const column1Row0 = left[0] * right[3] + left[3] * right[4] + left[6] * right[5];
1779
+ const column1Row1 = left[1] * right[3] + left[4] * right[4] + left[7] * right[5];
1780
+ const column1Row2 = left[2] * right[3] + left[5] * right[4] + left[8] * right[5];
1781
+ const column2Row0 = left[0] * right[6] + left[3] * right[7] + left[6] * right[8];
1782
+ const column2Row1 = left[1] * right[6] + left[4] * right[7] + left[7] * right[8];
1783
+ const column2Row2 = left[2] * right[6] + left[5] * right[7] + left[8] * right[8];
1784
+ result[0] = column0Row0;
1785
+ result[1] = column0Row1;
1786
+ result[2] = column0Row2;
1787
+ result[3] = column1Row0;
1788
+ result[4] = column1Row1;
1789
+ result[5] = column1Row2;
1790
+ result[6] = column2Row0;
1791
+ result[7] = column2Row1;
1792
+ result[8] = column2Row2;
1793
+ return result;
1794
+ }
1795
+ /**
1796
+ * Computes the sum of two matrices.
1797
+ *
1798
+ * @param {Matrix3} left The first matrix.
1799
+ * @param {Matrix3} right The second matrix.
1800
+ * @param {Matrix3} result The object onto which to store the result.
1801
+ * @returns {Matrix3} The modified result parameter.
1802
+ */
1803
+ static add(left, right, result) {
1804
+ Check_default.typeOf.object("left", left);
1805
+ Check_default.typeOf.object("right", right);
1806
+ Check_default.typeOf.object("result", result);
1807
+ result[0] = left[0] + right[0];
1808
+ result[1] = left[1] + right[1];
1809
+ result[2] = left[2] + right[2];
1810
+ result[3] = left[3] + right[3];
1811
+ result[4] = left[4] + right[4];
1812
+ result[5] = left[5] + right[5];
1813
+ result[6] = left[6] + right[6];
1814
+ result[7] = left[7] + right[7];
1815
+ result[8] = left[8] + right[8];
1816
+ return result;
1817
+ }
1818
+ /**
1819
+ * Computes the difference of two matrices.
1820
+ *
1821
+ * @param {Matrix3} left The first matrix.
1822
+ * @param {Matrix3} right The second matrix.
1823
+ * @param {Matrix3} result The object onto which to store the result.
1824
+ * @returns {Matrix3} The modified result parameter.
1825
+ */
1826
+ static subtract(left, right, result) {
1827
+ Check_default.typeOf.object("left", left);
1828
+ Check_default.typeOf.object("right", right);
1829
+ Check_default.typeOf.object("result", result);
1830
+ result[0] = left[0] - right[0];
1831
+ result[1] = left[1] - right[1];
1832
+ result[2] = left[2] - right[2];
1833
+ result[3] = left[3] - right[3];
1834
+ result[4] = left[4] - right[4];
1835
+ result[5] = left[5] - right[5];
1836
+ result[6] = left[6] - right[6];
1837
+ result[7] = left[7] - right[7];
1838
+ result[8] = left[8] - right[8];
1839
+ return result;
1840
+ }
1841
+ /**
1842
+ * Computes the product of a matrix and a column vector.
1843
+ *
1844
+ * @param {Matrix3} matrix The matrix.
1845
+ * @param {Cartesian3} cartesian The column.
1846
+ * @param {Cartesian3} result The object onto which to store the result.
1847
+ * @returns {Cartesian3} The modified result parameter.
1848
+ */
1849
+ static multiplyByVector(matrix, cartesian, result) {
1850
+ Check_default.typeOf.object("matrix", matrix);
1851
+ Check_default.typeOf.object("cartesian", cartesian);
1852
+ Check_default.typeOf.object("result", result);
1853
+ const vX = cartesian.x;
1854
+ const vY = cartesian.y;
1855
+ const vZ = cartesian.z;
1856
+ const x = matrix[0] * vX + matrix[3] * vY + matrix[6] * vZ;
1857
+ const y = matrix[1] * vX + matrix[4] * vY + matrix[7] * vZ;
1858
+ const z = matrix[2] * vX + matrix[5] * vY + matrix[8] * vZ;
1859
+ result.x = x;
1860
+ result.y = y;
1861
+ result.z = z;
1862
+ return result;
1863
+ }
1864
+ /**
1865
+ * Computes the product of a matrix and a scalar.
1866
+ *
1867
+ * @param {Matrix3} matrix The matrix.
1868
+ * @param {number} scalar The number to multiply by.
1869
+ * @param {Matrix3} result The object onto which to store the result.
1870
+ * @returns {Matrix3} The modified result parameter.
1871
+ */
1872
+ static multiplyByScalar(matrix, scalar, result) {
1873
+ Check_default.typeOf.object("matrix", matrix);
1874
+ Check_default.typeOf.number("scalar", scalar);
1875
+ Check_default.typeOf.object("result", result);
1876
+ result[0] = matrix[0] * scalar;
1877
+ result[1] = matrix[1] * scalar;
1878
+ result[2] = matrix[2] * scalar;
1879
+ result[3] = matrix[3] * scalar;
1880
+ result[4] = matrix[4] * scalar;
1881
+ result[5] = matrix[5] * scalar;
1882
+ result[6] = matrix[6] * scalar;
1883
+ result[7] = matrix[7] * scalar;
1884
+ result[8] = matrix[8] * scalar;
1885
+ return result;
1886
+ }
1887
+ /**
1888
+ * Computes the product of a matrix times a (non-uniform) scale, as if the scale were a scale matrix.
1889
+ *
1890
+ * @param {Matrix3} matrix The matrix on the left-hand side.
1891
+ * @param {Cartesian3} scale The non-uniform scale on the right-hand side.
1892
+ * @param {Matrix3} result The object onto which to store the result.
1893
+ * @returns {Matrix3} The modified result parameter.
1894
+ *
1895
+ *
1896
+ * @example
1897
+ * // Instead of Cesium.Matrix3.multiply(m, Cesium.Matrix3.fromScale(scale), m);
1898
+ * Cesium.Matrix3.multiplyByScale(m, scale, m);
1899
+ *
1900
+ * @see Matrix3.multiplyByUniformScale
1901
+ * @see Matrix3.fromScale
1902
+ * @see Matrix3.fromUniformScale
1903
+ * @see Matrix3.setScale
1904
+ * @see Matrix3.setUniformScale
1905
+ * @see Matrix3.getScale
1906
+ */
1907
+ static multiplyByScale(matrix, scale, result) {
1908
+ Check_default.typeOf.object("matrix", matrix);
1909
+ Check_default.typeOf.object("scale", scale);
1910
+ Check_default.typeOf.object("result", result);
1911
+ result[0] = matrix[0] * scale.x;
1912
+ result[1] = matrix[1] * scale.x;
1913
+ result[2] = matrix[2] * scale.x;
1914
+ result[3] = matrix[3] * scale.y;
1915
+ result[4] = matrix[4] * scale.y;
1916
+ result[5] = matrix[5] * scale.y;
1917
+ result[6] = matrix[6] * scale.z;
1918
+ result[7] = matrix[7] * scale.z;
1919
+ result[8] = matrix[8] * scale.z;
1920
+ return result;
1921
+ }
1922
+ /**
1923
+ * Computes the product of a matrix times a uniform scale, as if the scale were a scale matrix.
1924
+ *
1925
+ * @param {Matrix3} matrix The matrix on the left-hand side.
1926
+ * @param {number} scale The uniform scale on the right-hand side.
1927
+ * @param {Matrix3} result The object onto which to store the result.
1928
+ * @returns {Matrix3} The modified result parameter.
1929
+ *
1930
+ * @example
1931
+ * // Instead of Cesium.Matrix3.multiply(m, Cesium.Matrix3.fromUniformScale(scale), m);
1932
+ * Cesium.Matrix3.multiplyByUniformScale(m, scale, m);
1933
+ *
1934
+ * @see Matrix3.multiplyByScale
1935
+ * @see Matrix3.fromScale
1936
+ * @see Matrix3.fromUniformScale
1937
+ * @see Matrix3.setScale
1938
+ * @see Matrix3.setUniformScale
1939
+ * @see Matrix3.getScale
1940
+ */
1941
+ static multiplyByUniformScale(matrix, scale, result) {
1942
+ Check_default.typeOf.object("matrix", matrix);
1943
+ Check_default.typeOf.number("scale", scale);
1944
+ Check_default.typeOf.object("result", result);
1945
+ result[0] = matrix[0] * scale;
1946
+ result[1] = matrix[1] * scale;
1947
+ result[2] = matrix[2] * scale;
1948
+ result[3] = matrix[3] * scale;
1949
+ result[4] = matrix[4] * scale;
1950
+ result[5] = matrix[5] * scale;
1951
+ result[6] = matrix[6] * scale;
1952
+ result[7] = matrix[7] * scale;
1953
+ result[8] = matrix[8] * scale;
1954
+ return result;
1955
+ }
1956
+ /**
1957
+ * Creates a negated copy of the provided matrix.
1958
+ *
1959
+ * @param {Matrix3} matrix The matrix to negate.
1960
+ * @param {Matrix3} result The object onto which to store the result.
1961
+ * @returns {Matrix3} The modified result parameter.
1962
+ */
1963
+ static negate(matrix, result) {
1964
+ Check_default.typeOf.object("matrix", matrix);
1965
+ Check_default.typeOf.object("result", result);
1966
+ result[0] = -matrix[0];
1967
+ result[1] = -matrix[1];
1968
+ result[2] = -matrix[2];
1969
+ result[3] = -matrix[3];
1970
+ result[4] = -matrix[4];
1971
+ result[5] = -matrix[5];
1972
+ result[6] = -matrix[6];
1973
+ result[7] = -matrix[7];
1974
+ result[8] = -matrix[8];
1975
+ return result;
1976
+ }
1977
+ /**
1978
+ * Computes the transpose of the provided matrix.
1979
+ *
1980
+ * @param {Matrix3} matrix The matrix to transpose.
1981
+ * @param {Matrix3} result The object onto which to store the result.
1982
+ * @returns {Matrix3} The modified result parameter.
1983
+ */
1984
+ static transpose(matrix, result) {
1985
+ Check_default.typeOf.object("matrix", matrix);
1986
+ Check_default.typeOf.object("result", result);
1987
+ const column0Row0 = matrix[0];
1988
+ const column0Row1 = matrix[3];
1989
+ const column0Row2 = matrix[6];
1990
+ const column1Row0 = matrix[1];
1991
+ const column1Row1 = matrix[4];
1992
+ const column1Row2 = matrix[7];
1993
+ const column2Row0 = matrix[2];
1994
+ const column2Row1 = matrix[5];
1995
+ const column2Row2 = matrix[8];
1996
+ result[0] = column0Row0;
1997
+ result[1] = column0Row1;
1998
+ result[2] = column0Row2;
1999
+ result[3] = column1Row0;
2000
+ result[4] = column1Row1;
2001
+ result[5] = column1Row2;
2002
+ result[6] = column2Row0;
2003
+ result[7] = column2Row1;
2004
+ result[8] = column2Row2;
2005
+ return result;
2006
+ }
2007
+ /**
2008
+ * Computes the eigenvectors and eigenvalues of a symmetric matrix.
2009
+ * <p>
2010
+ * Returns a diagonal matrix and unitary matrix such that:
2011
+ * <code>matrix = unitary matrix * diagonal matrix * transpose(unitary matrix)</code>
2012
+ * </p>
2013
+ * <p>
2014
+ * The values along the diagonal of the diagonal matrix are the eigenvalues. The columns
2015
+ * of the unitary matrix are the corresponding eigenvectors.
2016
+ * </p>
2017
+ *
2018
+ * @param {Matrix3} matrix The matrix to decompose into diagonal and unitary matrix. Expected to be symmetric.
2019
+ * @param {EigenDecompositionResult} [result] An object with unitary and diagonal properties which are matrices onto which to store the result.
2020
+ * @returns {EigenDecompositionResult} An object with unitary and diagonal properties which are the unitary and diagonal matrices, respectively.
2021
+ *
2022
+ * @example
2023
+ * const a = //... symetric matrix
2024
+ * const result = {
2025
+ * unitary : new Cesium.Matrix3(),
2026
+ * diagonal : new Cesium.Matrix3()
2027
+ * };
2028
+ * Cesium.Matrix3.computeEigenDecomposition(a, result);
2029
+ *
2030
+ * const unitaryTranspose = Cesium.Matrix3.transpose(result.unitary, new Cesium.Matrix3());
2031
+ * const b = Cesium.Matrix3.multiply(result.unitary, result.diagonal, new Cesium.Matrix3());
2032
+ * Cesium.Matrix3.multiply(b, unitaryTranspose, b); // b is now equal to a
2033
+ *
2034
+ * const lambda = Cesium.Matrix3.getColumn(result.diagonal, 0, new Cesium.Cartesian3()).x; // first eigenvalue
2035
+ * const v = Cesium.Matrix3.getColumn(result.unitary, 0, new Cesium.Cartesian3()); // first eigenvector
2036
+ * const c = Cesium.Cartesian3.multiplyByScalar(v, lambda, new Cesium.Cartesian3()); // equal to Cesium.Matrix3.multiplyByVector(a, v)
2037
+ */
2038
+ static computeEigenDecomposition(matrix, result) {
2039
+ Check_default.typeOf.object("matrix", matrix);
2040
+ const tolerance = Math_default.EPSILON20;
2041
+ const maxSweeps = 10;
2042
+ let count = 0;
2043
+ let sweep = 0;
2044
+ if (!defined_default(result)) {
2045
+ result = {};
2046
+ }
2047
+ const unitaryMatrix = result.unitary = _Matrix3.clone(
2048
+ _Matrix3.IDENTITY,
2049
+ result.unitary
2050
+ );
2051
+ const diagMatrix = result.diagonal = _Matrix3.clone(
2052
+ matrix,
2053
+ result.diagonal
2054
+ );
2055
+ const epsilon = tolerance * computeFrobeniusNorm(diagMatrix);
2056
+ while (sweep < maxSweeps && offDiagonalFrobeniusNorm(diagMatrix) > epsilon) {
2057
+ shurDecomposition(diagMatrix, jMatrix);
2058
+ _Matrix3.transpose(jMatrix, jMatrixTranspose);
2059
+ _Matrix3.multiply(diagMatrix, jMatrix, diagMatrix);
2060
+ _Matrix3.multiply(jMatrixTranspose, diagMatrix, diagMatrix);
2061
+ _Matrix3.multiply(unitaryMatrix, jMatrix, unitaryMatrix);
2062
+ if (++count > 2) {
2063
+ ++sweep;
2064
+ count = 0;
2065
+ }
2066
+ }
2067
+ return result;
2068
+ }
2069
+ /**
2070
+ * Computes a matrix, which contains the absolute (unsigned) values of the provided matrix's elements.
2071
+ *
2072
+ * @param {Matrix3} matrix The matrix with signed elements.
2073
+ * @param {Matrix3} result The object onto which to store the result.
2074
+ * @returns {Matrix3} The modified result parameter.
2075
+ */
2076
+ static abs(matrix, result) {
2077
+ Check_default.typeOf.object("matrix", matrix);
2078
+ Check_default.typeOf.object("result", result);
2079
+ result[0] = Math.abs(matrix[0]);
2080
+ result[1] = Math.abs(matrix[1]);
2081
+ result[2] = Math.abs(matrix[2]);
2082
+ result[3] = Math.abs(matrix[3]);
2083
+ result[4] = Math.abs(matrix[4]);
2084
+ result[5] = Math.abs(matrix[5]);
2085
+ result[6] = Math.abs(matrix[6]);
2086
+ result[7] = Math.abs(matrix[7]);
2087
+ result[8] = Math.abs(matrix[8]);
2088
+ return result;
2089
+ }
2090
+ /**
2091
+ * Computes the determinant of the provided matrix.
2092
+ *
2093
+ * @param {Matrix3} matrix The matrix to use.
2094
+ * @returns {number} The value of the determinant of the matrix.
2095
+ */
2096
+ static determinant(matrix) {
2097
+ Check_default.typeOf.object("matrix", matrix);
2098
+ const m11 = matrix[0];
2099
+ const m21 = matrix[3];
2100
+ const m31 = matrix[6];
2101
+ const m12 = matrix[1];
2102
+ const m22 = matrix[4];
2103
+ const m32 = matrix[7];
2104
+ const m13 = matrix[2];
2105
+ const m23 = matrix[5];
2106
+ const m33 = matrix[8];
2107
+ return m11 * (m22 * m33 - m23 * m32) + m12 * (m23 * m31 - m21 * m33) + m13 * (m21 * m32 - m22 * m31);
2108
+ }
2109
+ /**
2110
+ * Computes the inverse of the provided matrix.
2111
+ *
2112
+ * @param {Matrix3} matrix The matrix to invert.
2113
+ * @param {Matrix3} result The object onto which to store the result.
2114
+ * @returns {Matrix3} The modified result parameter.
2115
+ *
2116
+ * @exception {DeveloperError} matrix is not invertible.
2117
+ */
2118
+ static inverse(matrix, result) {
2119
+ Check_default.typeOf.object("matrix", matrix);
2120
+ Check_default.typeOf.object("result", result);
2121
+ const m11 = matrix[0];
2122
+ const m21 = matrix[1];
2123
+ const m31 = matrix[2];
2124
+ const m12 = matrix[3];
2125
+ const m22 = matrix[4];
2126
+ const m32 = matrix[5];
2127
+ const m13 = matrix[6];
2128
+ const m23 = matrix[7];
2129
+ const m33 = matrix[8];
2130
+ const determinant = _Matrix3.determinant(matrix);
2131
+ if (Math.abs(determinant) <= Math_default.EPSILON15) {
2132
+ throw new DeveloperError_default("matrix is not invertible");
2133
+ }
2134
+ result[0] = m22 * m33 - m23 * m32;
2135
+ result[1] = m23 * m31 - m21 * m33;
2136
+ result[2] = m21 * m32 - m22 * m31;
2137
+ result[3] = m13 * m32 - m12 * m33;
2138
+ result[4] = m11 * m33 - m13 * m31;
2139
+ result[5] = m12 * m31 - m11 * m32;
2140
+ result[6] = m12 * m23 - m13 * m22;
2141
+ result[7] = m13 * m21 - m11 * m23;
2142
+ result[8] = m11 * m22 - m12 * m21;
2143
+ const scale = 1 / determinant;
2144
+ return _Matrix3.multiplyByScalar(result, scale, result);
2145
+ }
2146
+ /**
2147
+ * Computes the inverse transpose of a matrix.
2148
+ *
2149
+ * @param {Matrix3} matrix The matrix to transpose and invert.
2150
+ * @param {Matrix3} result The object onto which to store the result.
2151
+ * @returns {Matrix3} The modified result parameter.
2152
+ */
2153
+ static inverseTranspose(matrix, result) {
2154
+ Check_default.typeOf.object("matrix", matrix);
2155
+ Check_default.typeOf.object("result", result);
2156
+ return _Matrix3.inverse(
2157
+ _Matrix3.transpose(matrix, scratchTransposeMatrix),
2158
+ result
2159
+ );
2160
+ }
2161
+ /**
2162
+ * Compares the provided matrices componentwise and returns
2163
+ * <code>true</code> if they are equal, <code>false</code> otherwise.
2164
+ *
2165
+ * @param {Matrix3} [left] The first matrix.
2166
+ * @param {Matrix3} [right] The second matrix.
2167
+ * @returns {boolean} <code>true</code> if left and right are equal, <code>false</code> otherwise.
2168
+ */
2169
+ static equals(left, right) {
2170
+ return left === right || defined_default(left) && defined_default(right) && left[0] === right[0] && left[1] === right[1] && left[2] === right[2] && left[3] === right[3] && left[4] === right[4] && left[5] === right[5] && left[6] === right[6] && left[7] === right[7] && left[8] === right[8];
2171
+ }
2172
+ /**
2173
+ * Compares the provided matrices componentwise and returns
2174
+ * <code>true</code> if they are within the provided epsilon,
2175
+ * <code>false</code> otherwise.
2176
+ *
2177
+ * @param {Matrix3} [left] The first matrix.
2178
+ * @param {Matrix3} [right] The second matrix.
2179
+ * @param {number} [epsilon=0] The epsilon to use for equality testing.
2180
+ * @returns {boolean} <code>true</code> if left and right are within the provided epsilon, <code>false</code> otherwise.
2181
+ */
2182
+ static equalsEpsilon(left, right, epsilon) {
2183
+ epsilon = epsilon ?? 0;
2184
+ return left === right || defined_default(left) && defined_default(right) && Math.abs(left[0] - right[0]) <= epsilon && Math.abs(left[1] - right[1]) <= epsilon && Math.abs(left[2] - right[2]) <= epsilon && Math.abs(left[3] - right[3]) <= epsilon && Math.abs(left[4] - right[4]) <= epsilon && Math.abs(left[5] - right[5]) <= epsilon && Math.abs(left[6] - right[6]) <= epsilon && Math.abs(left[7] - right[7]) <= epsilon && Math.abs(left[8] - right[8]) <= epsilon;
2185
+ }
2186
+ /**
2187
+ * Gets the number of items in the collection.
2188
+ *
2189
+ * @type {number}
2190
+ */
2191
+ get length() {
2192
+ return _Matrix3.packedLength;
2193
+ }
2194
+ /**
2195
+ * Duplicates the provided Matrix3 instance.
2196
+ *
2197
+ * @param {Matrix3} [result] The object onto which to store the result.
2198
+ * @returns {Matrix3} The modified result parameter or a new Matrix3 instance if one was not provided.
2199
+ */
2200
+ clone(result) {
2201
+ return _Matrix3.clone(this, result);
2202
+ }
2203
+ /**
2204
+ * Compares this matrix to the provided matrix componentwise and returns
2205
+ * <code>true</code> if they are equal, <code>false</code> otherwise.
2206
+ *
2207
+ * @param {Matrix3} [right] The right hand side matrix.
2208
+ * @returns {boolean} <code>true</code> if they are equal, <code>false</code> otherwise.
2209
+ */
2210
+ equals(right) {
2211
+ return _Matrix3.equals(this, right);
2212
+ }
2213
+ /**
2214
+ * Compares provided matrix and array, starting from a given array offset.
2215
+ *
2216
+ * @param {Matrix3} matrix
2217
+ * @param {number[]} array
2218
+ * @param {number} offset
2219
+ * @ignore
2220
+ */
2221
+ static equalsArray(matrix, array, offset) {
2222
+ return matrix[0] === array[offset] && matrix[1] === array[offset + 1] && matrix[2] === array[offset + 2] && matrix[3] === array[offset + 3] && matrix[4] === array[offset + 4] && matrix[5] === array[offset + 5] && matrix[6] === array[offset + 6] && matrix[7] === array[offset + 7] && matrix[8] === array[offset + 8];
2223
+ }
2224
+ /**
2225
+ * Compares this matrix to the provided matrix componentwise and returns
2226
+ * <code>true</code> if they are within the provided epsilon,
2227
+ * <code>false</code> otherwise.
2228
+ *
2229
+ * @param {Matrix3} [right] The right hand side matrix.
2230
+ * @param {number} [epsilon=0] The epsilon to use for equality testing.
2231
+ * @returns {boolean} <code>true</code> if they are within the provided epsilon, <code>false</code> otherwise.
2232
+ */
2233
+ equalsEpsilon(right, epsilon) {
2234
+ return _Matrix3.equalsEpsilon(this, right, epsilon);
2235
+ }
2236
+ /**
2237
+ * Creates a string representing this Matrix with each row being
2238
+ * on a separate line and in the format '(column0, column1, column2)'.
2239
+ *
2240
+ * @returns {string} A string representing the provided Matrix with each row being on a separate line and in the format '(column0, column1, column2)'.
2241
+ */
2242
+ toString() {
2243
+ return `(${this[0]}, ${this[3]}, ${this[6]})
2244
+ (${this[1]}, ${this[4]}, ${this[7]})
2245
+ (${this[2]}, ${this[5]}, ${this[8]})`;
2246
+ }
2247
+ };
2248
+ Matrix3.packedLength = 9;
2249
+ Matrix3.fromArray = Matrix3.unpack;
2250
+ Matrix3.IDENTITY = Object.freeze(
2251
+ new Matrix3(1, 0, 0, 0, 1, 0, 0, 0, 1)
2252
+ );
2253
+ Matrix3.ZERO = Object.freeze(
2254
+ new Matrix3(0, 0, 0, 0, 0, 0, 0, 0, 0)
2255
+ );
2256
+ Matrix3.COLUMN0ROW0 = 0;
2257
+ Matrix3.COLUMN0ROW1 = 1;
2258
+ Matrix3.COLUMN0ROW2 = 2;
2259
+ Matrix3.COLUMN1ROW0 = 3;
2260
+ Matrix3.COLUMN1ROW1 = 4;
2261
+ Matrix3.COLUMN1ROW2 = 5;
2262
+ Matrix3.COLUMN2ROW0 = 6;
2263
+ Matrix3.COLUMN2ROW1 = 7;
2264
+ Matrix3.COLUMN2ROW2 = 8;
2265
+ var scaleScratch1 = new Cartesian3_default();
2266
+ var scaleScratch2 = new Cartesian3_default();
2267
+ var scratchColumn = new Cartesian3_default();
2268
+ var scaleScratch3 = new Cartesian3_default();
2269
+ var scaleScratch4 = new Cartesian3_default();
2270
+ var scaleScratch5 = new Cartesian3_default();
2271
+ var jMatrix = new Matrix3();
2272
+ var jMatrixTranspose = new Matrix3();
2273
+ var scratchTransposeMatrix = new Matrix3();
2274
+ function computeFrobeniusNorm(matrix) {
2275
+ let norm = 0;
2276
+ for (let i = 0; i < 9; ++i) {
2277
+ const temp = matrix[i];
2278
+ norm += temp * temp;
2279
+ }
2280
+ return Math.sqrt(norm);
2281
+ }
2282
+ var rowVal = [1, 0, 0];
2283
+ var colVal = [2, 2, 1];
2284
+ function offDiagonalFrobeniusNorm(matrix) {
2285
+ let norm = 0;
2286
+ for (let i = 0; i < 3; ++i) {
2287
+ const temp = matrix[Matrix3.getElementIndex(colVal[i], rowVal[i])];
2288
+ norm += 2 * temp * temp;
2289
+ }
2290
+ return Math.sqrt(norm);
2291
+ }
2292
+ function shurDecomposition(matrix, result) {
2293
+ const tolerance = Math_default.EPSILON15;
2294
+ let maxDiagonal = 0;
2295
+ let rotAxis = 1;
2296
+ for (let i = 0; i < 3; ++i) {
2297
+ const temp = Math.abs(
2298
+ // @ts-expect-error TODO(tsd-jsdoc): Requires index signature support.
2299
+ matrix[Matrix3.getElementIndex(colVal[i], rowVal[i])]
2300
+ );
2301
+ if (temp > maxDiagonal) {
2302
+ rotAxis = i;
2303
+ maxDiagonal = temp;
2304
+ }
2305
+ }
2306
+ let c = 1;
2307
+ let s = 0;
2308
+ const p = rowVal[rotAxis];
2309
+ const q = colVal[rotAxis];
2310
+ if (Math.abs(matrix[Matrix3.getElementIndex(q, p)]) > tolerance) {
2311
+ const qq = matrix[Matrix3.getElementIndex(q, q)];
2312
+ const pp = matrix[Matrix3.getElementIndex(p, p)];
2313
+ const qp = matrix[Matrix3.getElementIndex(q, p)];
2314
+ const tau = (qq - pp) / 2 / qp;
2315
+ let t;
2316
+ if (tau < 0) {
2317
+ t = -1 / (-tau + Math.sqrt(1 + tau * tau));
2318
+ } else {
2319
+ t = 1 / (tau + Math.sqrt(1 + tau * tau));
2320
+ }
2321
+ c = 1 / Math.sqrt(1 + t * t);
2322
+ s = t * c;
2323
+ }
2324
+ result = Matrix3.clone(Matrix3.IDENTITY, result);
2325
+ result[Matrix3.getElementIndex(p, p)] = result[Matrix3.getElementIndex(q, q)] = c;
2326
+ result[Matrix3.getElementIndex(q, p)] = s;
2327
+ result[Matrix3.getElementIndex(p, q)] = -s;
2328
+ return result;
2329
+ }
2330
+ var Matrix3_default = Matrix3;
2331
+
2332
+ // packages/engine/Source/Core/Frozen.js
2333
+ var Frozen = {};
2334
+ Frozen.EMPTY_OBJECT = Object.freeze({});
2335
+ Frozen.EMPTY_ARRAY = Object.freeze([]);
2336
+ var Frozen_default = Frozen;
2337
+
2338
+ export {
2339
+ Cartesian3_default,
2340
+ Matrix3_default,
2341
+ Frozen_default
2342
+ };