PageSourceSearch

https://meinxhain3d.de/static/Cesium/Workers/chunk-HKUES6UG.js

js meinxhain3d.de collected 2026-10-05 19:26:42 UTC 80,317 bytes, 2,357 lines download raw bytes

1/**
2 * @license
3 * Cesium - https://github.com/CesiumGS/cesium
4 * Version 1.140.0
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
26import {
27  RuntimeError_default
28} from "./chunk-EDXL4W76.js";
29import {
30  Cartesian3_default,
31  Frozen_default,
32  Matrix3_default
33} from "./chunk-ZBZRTRJB.js";
34import {
35  Math_default
36} from "./chunk-5GXYJQ2K.js";
37import {
38  Check_default,
39  DeveloperError_default
40} from "./chunk-VLDEUTOP.js";
41import {
42  defined_default
43} from "./chunk-AJLTU6PF.js";
44
45// packages/engine/Source/Core/Cartesian4.js
46var Cartesian4 = class _Cartesian4 {
47  /**
48   * @param {number} [x=0.0] The X component.
49   * @param {number} [y=0.0] The Y component.
50   * @param {number} [z=0.0] The Z component.
51   * @param {number} [w=0.0] The W component.
52   */
53  constructor(x, y, z, w) {
54    this.x = x ?? 0;
55    this.y = y ?? 0;
56    this.z = z ?? 0;
57    this.w = w ?? 0;
58  }
59  /**
60   * Creates a Cartesian4 instance from x, y, z and w coordinates.
61   *
62   * @param {number} x The x coordinate.
63   * @param {number} y The y coordinate.
64   * @param {number} z The z coordinate.
65   * @param {number} w The w coordinate.
66   * @param {Cartesian4} [result] The object onto which to store the result.
67   * @returns {Cartesian4} The modified result parameter or a new Cartesian4 instance if one was not provided.
68   */
69  static fromElements(x, y, z, w, result) {
70    if (!defined_default(result)) {
71      return new _Cartesian4(x, y, z, w);
72    }
73    result.x = x;
74    result.y = y;
75    result.z = z;
76    result.w = w;
77    return result;
78  }
79  /**
80   * Creates a Cartesian4 instance from a {@link Color}. <code>red</code>, <code>green</code>, <code>blue</code>,
81   * and <code>alpha</code> map to <code>x</code>, <code>y</code>, <code>z</code>, and <code>w</code>, respectively.
82   *
83   * @param {Color} color The source color.
84   * @param {Cartesian4} [result] The object onto which to store the result.
85   * @returns {Cartesian4} The modified result parameter or a new Cartesian4 instance if one was not provided.
86   */
87  static fromColor(color, result) {
88    Check_default.typeOf.object("color", color);
89    if (!defined_default(result)) {
90      return new _Cartesian4(color.red, color.green, color.blue, color.alpha);
91    }
92    result.x = color.red;
93    result.y = color.green;
94    result.z = color.blue;
95    result.w = color.alpha;
96    return result;
97  }
98  /**
99   * Duplicates a Cartesian4 instance.
100   *
101   * @param {Cartesian4} cartesian The Cartesian to duplicate.
102   * @param {Cartesian4} [result] The object onto which to store the result.
103   * @returns {Cartesian4} The modified result parameter or a new Cartesian4 instance if one was not provided. (Returns undefined if cartesian is undefined)
104   */
105  static clone(cartesian, result) {
106    if (!defined_default(cartesian)) {
107      return void 0;
108    }
109    if (!defined_default(result)) {
110      return new _Cartesian4(cartesian.x, cartesian.y, cartesian.z, cartesian.w);
111    }
112    result.x = cartesian.x;
113    result.y = cartesian.y;
114    result.z = cartesian.z;
115    result.w = cartesian.w;
116    return result;
117  }
118  /**
119   * Stores the provided instance into the provided array.
120   *
121   * @param {Cartesian4} value The value to pack.
122   * @param {number[]} array The array to pack into.
123   * @param {number} [startingIndex=0] The index into the array at which to start packing the elements.
124   *
125   * @returns {number[]} The array that was packed into
126   */
127  static pack(value, array, startingIndex) {
128    Check_default.typeOf.object("value", value);
129    Check_default.defined("array", array);
130    startingIndex = startingIndex ?? 0;
131    array[startingIndex++] = value.x;
132    array[startingIndex++] = value.y;
133    array[startingIndex++] = value.z;
134    array[startingIndex] = value.w;
135    return array;
136  }
137  /**
138   * Retrieves an instance from a packed array.
139   *
140   * @param {number[]} array The packed array.
141   * @param {number} [startingIndex=0] The starting index of the element to be unpacked.
142   * @param {Cartesian4} [result] The object into which to store the result.
143   * @returns {Cartesian4}  The modified result parameter or a new Cartesian4 instance if one was not provided.
144   */
145  static unpack(array, startingIndex, result) {
146    Check_default.defined("array", array);
147    startingIndex = startingIndex ?? 0;
148    if (!defined_default(result)) {
149      result = new _Cartesian4();
150    }
151    result.x = array[startingIndex++];
152    result.y = array[startingIndex++];
153    result.z = array[startingIndex++];
154    result.w = array[startingIndex];
155    return result;
156  }
157  /**
158   * Flattens an array of Cartesian4s into an array of components.
159   *
160   * @param {Cartesian4[]} array The array of cartesians to pack.
161   * @param {number[]} [result] The array onto which to store the result. If this is a typed array, it must have array.length * 4 components, else a {@link DeveloperError} will be thrown. If it is a regular array, it will be resized to have (array.length * 4) elements.
162   * @returns {number[]} The packed array.
163   */
164  static packArray(array, result) {
165    Check_default.defined("array", array);
166    const length = array.length;
167    const resultLength = length * 4;
168    if (!defined_default(result)) {
169      result = new Array(resultLength);
170    } else if (!Array.isArray(result) && result.length !== resultLength) {
171      throw new DeveloperError_default(
172        "If result is a typed array, it must have exactly array.length * 4 elements"
173      );
174    } else if (result.length !== resultLength) {
175      result.length = resultLength;
176    }
177    for (let i = 0; i < length; ++i) {
178      _Cartesian4.pack(array[i], result, i * 4);
179    }
180    return result;
181  }
182  /**
183   * Unpacks an array of cartesian components into an array of Cartesian4s.
184   *
185   * @param {number[]} array The array of components to unpack.
186   * @param {Cartesian4[]} [result] The array onto which to store the result.
187   * @returns {Cartesian4[]} The unpacked array.
188   */
189  static unpackArray(array, result) {
190    Check_default.defined("array", array);
191    Check_default.typeOf.number.greaterThanOrEquals("array.length", array.length, 4);
192    if (array.length % 4 !== 0) {
193      throw new DeveloperError_default("array length must be a multiple of 4.");
194    }
195    const length = array.length;
196    if (!defined_default(result)) {
197      result = new Array(length / 4);
198    } else {
199      result.length = length / 4;
200    }
201    for (let i = 0; i < length; i += 4) {
202      const index = i / 4;
203      result[index] = _Cartesian4.unpack(array, i, result[index]);
204    }
205    return result;
206  }
207  /**
208   * Computes the value of the maximum component for the supplied Cartesian.
209   *
210   * @param {Cartesian4} cartesian The cartesian to use.
211   * @returns {number} The value of the maximum component.
212   */
213  static maximumComponent(cartesian) {
214    Check_default.typeOf.object("cartesian", cartesian);
215    return Math.max(cartesian.x, cartesian.y, cartesian.z, cartesian.w);
216  }
217  /**
218   * Computes the value of the minimum component for the supplied Cartesian.
219   *
220   * @param {Cartesian4} cartesian The cartesian to use.
221   * @returns {number} The value of the minimum component.
222   */
223  static minimumComponent(cartesian) {
224    Check_default.typeOf.object("cartesian", cartesian);
225    return Math.min(cartesian.x, cartesian.y, cartesian.z, cartesian.w);
226  }
227  /**
228   * Compares two Cartesians and computes a Cartesian which contains the minimum components of the supplied Cartesians.
229   *
230   * @param {Cartesian4} first A cartesian to compare.
231   * @param {Cartesian4} second A cartesian to compare.
232   * @param {Cartesian4} result The object into which to store the result.
233   * @returns {Cartesian4} A cartesian with the minimum components.
234   */
235  static minimumByComponent(first, second, result) {
236    Check_default.typeOf.object("first", first);
237    Check_default.typeOf.object("second", second);
238    Check_default.typeOf.object("result", result);
239    result.x = Math.min(first.x, second.x);
240    result.y = Math.min(first.y, second.y);
241    result.z = Math.min(first.z, second.z);
242    result.w = Math.min(first.w, second.w);
243    return result;
244  }
245  /**
246   * Compares two Cartesians and computes a Cartesian which contains the maximum components of the supplied Cartesians.
247   *
248   * @param {Cartesian4} first A cartesian to compare.
249   * @param {Cartesian4} second A cartesian to compare.
250   * @param {Cartesian4} result The object into which to store the result.
251   * @returns {Cartesian4} A cartesian with the maximum components.
252   */
253  static maximumByComponent(first, second, result) {
254    Check_default.typeOf.object("first", first);
255    Check_default.typeOf.object("second", second);
256    Check_default.typeOf.object("result", result);
257    result.x = Math.max(first.x, second.x);
258    result.y = Math.max(first.y, second.y);
259    result.z = Math.max(first.z, second.z);
260    result.w = Math.max(first.w, second.w);
261    return result;
262  }
263  /**
264   * Constrain a value to lie between two values.
265   *
266   * @param {Cartesian4} value The value to clamp.
267   * @param {Cartesian4} min The minimum bound.
268   * @param {Cartesian4} max The maximum bound.
269   * @param {Cartesian4} result The object into which to store the result.
270   * @returns {Cartesian4} The clamped value such that min <= result <= max.
271   */
272  static clamp(value, min, max, result) {
273    Check_default.typeOf.object("value", value);
274    Check_default.typeOf.object("min", min);
275    Check_default.typeOf.object("max", max);
276    Check_default.typeOf.object("result", result);
277    const x = Math_default.clamp(value.x, min.x, max.x);
278    const y = Math_default.clamp(value.y, min.y, max.y);
279    const z = Math_default.clamp(value.z, min.z, max.z);
280    const w = Math_default.clamp(value.w, min.w, max.w);
281    result.x = x;
282    result.y = y;
283    result.z = z;
284    result.w = w;
285    return result;
286  }
287  /**
288   * Computes the provided Cartesian's squared magnitude.
289   *
290   * @param {Cartesian4}
290 cartesian The Cartesian instance whose squared magnitude is to be computed.
291   * @returns {number} The squared magnitude.
292   */
293  static magnitudeSquared(cartesian) {
294    Check_default.typeOf.object("cartesian", cartesian);
295    return cartesian.x * cartesian.x + cartesian.y * cartesian.y + cartesian.z * cartesian.z + cartesian.w * cartesian.w;
296  }
297  /**
298   * Computes the Cartesian's magnitude (length).
299   *
300   * @param {Cartesian4} cartesian The Cartesian instance whose magnitude is to be computed.
301   * @returns {number} The magnitude.
302   */
303  static magnitude(cartesian) {
304    return Math.sqrt(_Cartesian4.magnitudeSquared(cartesian));
305  }
306  /**
307   * Computes the 4-space distance between two points.
308   *
309   * @param {Cartesian4} left The first point to compute the distance from.
310   * @param {Cartesian4} right The second point to compute the distance to.
311   * @returns {number} The distance between two points.
312   *
313   * @example
314   * // Returns 1.0
315   * const d = Cesium.Cartesian4.distance(
316   *   new Cesium.Cartesian4(1.0, 0.0, 0.0, 0.0),
317   *   new Cesium.Cartesian4(2.0, 0.0, 0.0, 0.0));
318   */
319  static distance(left, right) {
320    Check_default.typeOf.object("left", left);
321    Check_default.typeOf.object("right", right);
322    _Cartesian4.subtract(left, right, distanceScratch);
323    return _Cartesian4.magnitude(distanceScratch);
324  }
325  /**
326   * Computes the squared distance between two points.  Comparing squared distances
327   * using this function is more efficient than comparing distances using {@link Cartesian4#distance}.
328   *
329   * @param {Cartesian4} left The first point to compute the distance from.
330   * @param {Cartesian4} right The second point to compute the distance to.
331   * @returns {number} The distance between two points.
332   *
333   * @example
334   * // Returns 4.0, not 2.0
335   * const d = Cesium.Cartesian4.distance(
336   *   new Cesium.Cartesian4(1.0, 0.0, 0.0, 0.0),
337   *   new Cesium.Cartesian4(3.0, 0.0, 0.0, 0.0));
338   */
339  static distanceSquared(left, right) {
340    Check_default.typeOf.object("left", left);
341    Check_default.typeOf.object("right", right);
342    _Cartesian4.subtract(left, right, distanceScratch);
343    return _Cartesian4.magnitudeSquared(distanceScratch);
344  }
345  /**
346   * Computes the normalized form of the supplied Cartesian.
347   *
348   * @param {Cartesian4} cartesian The Cartesian to be normalized.
349   * @param {Cartesian4} result The object onto which to store the result.
350   * @returns {Cartesian4} The modified result parameter.
351   */
352  static normalize(cartesian, result) {
353    Check_default.typeOf.object("cartesian", cartesian);
354    Check_default.typeOf.object("result", result);
355    const magnitude = _Cartesian4.magnitude(cartesian);
356    result.x = cartesian.x / magnitude;
357    result.y = cartesian.y / magnitude;
358    result.z = cartesian.z / magnitude;
359    result.w = cartesian.w / magnitude;
360    if (isNaN(result.x) || isNaN(result.y) || isNaN(result.z) || isNaN(result.w)) {
361      throw new DeveloperError_default("normalized result is not a number");
362    }
363    return result;
364  }
365  /**
366   * Computes the dot (scalar) product of two Cartesians.
367   *
368   * @param {Cartesian4} left The first Cartesian.
369   * @param {Cartesian4} right The second Cartesian.
370   * @returns {number} The dot product.
371   */
372  static dot(left, right) {
373    Check_default.typeOf.object("left", left);
374    Check_default.typeOf.object("right", right);
375    return left.x * right.x + left.y * right.y + left.z * right.z + left.w * right.w;
376  }
377  /**
378   * Computes the componentwise product of two Cartesians.
379   *
380   * @param {Cartesian4} left The first Cartesian.
381   * @param {Cartesian4} right The second Cartesian.
382   * @param {Cartesian4} result The object onto which to store the result.
383   * @returns {Cartesian4} The modified result parameter.
384   */
385  static multiplyComponents(left, right, result) {
386    Check_default.typeOf.object("left", left);
387    Check_default.typeOf.object("right", right);
388    Check_default.typeOf.object("result", result);
389    result.x = left.x * right.x;
390    result.y = left.y * right.y;
391    result.z = left.z * right.z;
392    result.w = left.w * right.w;
393    return result;
394  }
395  /**
396   * Computes the componentwise quotient of two Cartesians.
397   *
398   * @param {Cartesian4} left The first Cartesian.
399   * @param {Cartesian4} right The second Cartesian.
400   * @param {Cartesian4} result The object onto which to store the result.
401   * @returns {Cartesian4} The modified result parameter.
402   */
403  static divideComponents(left, right, result) {
404    Check_default.typeOf.object("left", left);
405    Check_default.typeOf.object("right", right);
406    Check_default.typeOf.object("result", result);
407    result.x = left.x / right.x;
408    result.y = left.y / right.y;
409    result.z = left.z / right.z;
410    result.w = left.w / right.w;
411    return result;
412  }
413  /**
414   * Computes the componentwise sum of two Cartesians.
415   *
416   * @param {Cartesian4} left The first Cartesian.
417   * @param {Cartesian4} right The second Cartesian.
418   * @param {Cartesian4} result The object onto which to store the result.
419   * @returns {Cartesian4} The modified result parameter.
420   */
421  static add(left, right, result) {
422    Check_default.typeOf.object("left", left);
423    Check_default.typeOf.object("right", right);
424    Check_default.typeOf.object("result", result);
425    result.x = left.x + right.x;
426    result.y = left.y + right.y;
427    result.z = left.z + right.z;
428    result.w = left.w + right.w;
429    return result;
430  }
431  /**
432   * Computes the componentwise difference of two Cartesians.
433   *
434   * @param {Cartesian4} left The first Cartesian.
435   * @param {Cartesian4} right The second Cartesian.
436   * @param {Cartesian4} result The object onto which to store the result.
437   * @returns {Cartesian4} The modified result parameter.
438   */
439  static subtract(left, right, result) {
440    Check_default.typeOf.object("left", left);
441    Check_default.typeOf.object("right", right);
442    Check_default.typeOf.object("result", result);
443    result.x = left.x - right.x;
444    result.y = left.y - right.y;
445    result.z = left.z - right.z;
446    result.w = left.w - right.w;
447    return result;
448  }
449  /**
450   * Multiplies the provided Cartesian componentwise by the provided scalar.
451   *
452   * @param {Cartesian4} cartesian The Cartesian to be scaled.
453   * @param {number} scalar The scalar to multiply with.
454   * @param {Cartesian4} result The object onto which to store the result.
455   * @returns {Cartesian4} The modified result parameter.
456   */
457  static multiplyByScalar(cartesian, scalar, result) {
458    Check_default.typeOf.object("cartesian", cartesian);
459    Check_default.typeOf.number("scalar", scalar);
460    Check_default.typeOf.object("result", result);
461    result.x = cartesian.x * scalar;
462    result.y = cartesian.y * scalar;
463    result.z = cartesian.z * scalar;
464    result.w = cartesian.w * scalar;
465    return result;
466  }
467  /**
468   * Divides the provided Cartesian componentwise by the provided scalar.
469   *
470   * @param {Cartesian4} cartesian The Cartesian to be divided.
471   * @param {number} scalar The scalar to divide by.
472   * @param {Cartesian4} result The object onto which to store the result.
473   * @returns {Cartesian4} The modified result parameter.
474   */
475  static divideByScalar(cartesian, scalar, result) {
476    Check_default.typeOf.object("cartesian", cartesian);
477    Check_default.typeOf.number("scalar", scalar);
478    Check_default.typeOf.object("result", result);
479    result.x = cartesian.x / scalar;
480    result.y = cartesian.y / scalar;
481    result.z = cartesian.z / scalar;
482    result.w = cartesian.w / scalar;
483    return result;
484  }
485  /**
486   * Negates the provided Cartesian.
487   *
488   * @param {Cartesian4} cartesian The Cartesian to be negated.
489   * @param {Cartesian4} result The object onto which to store the result.
490   * @returns {Cartesian4} The modified result parameter.
491   */
492  static negate(cartesian, result) {
493    Check_default.typeOf.object("cartesian", cartesian);
494    Check_default.typeOf.object("result", result);
495    result.x = -cartesian.x;
496    result.y = -cartesian.y;
497    result.z = -cartesian.z;
498    result.w = -cartesian.w;
499    return result;
500  }
501  /**
502   * Computes the absolute value of the provided Cartesian.
503   *
504   * @param {Cartesian4} cartesian The Cartesian whose absolute value is to be computed.
505   * @param {Cartesian4} result The object onto which to store the result.
506   * @returns {Cartesian4} The modified result parameter.
507   */
508  static abs(cartesian, result) {
509    Check_default.typeOf.object("cartesian", cartesian);
510    Check_default.typeOf.object("result", result);
511    result.x = Math.abs(cartesian.x);
512    result.y = Math.abs(cartesian.y);
513    result.z = Math.abs(cartesian.z);
514    result.w = Math.abs(cartesian.w);
515    return result;
516  }
517  /**
518   * Computes the linear interpolation or extrapolation at t using the provided cartesians.
519   *
520   * @param {Cartesian4} start The value corresponding to t at 0.0.
521   * @param {Cartesian4}end The value corresponding to t at 1.0.
522   * @param {number} t The point along t at which to interpolate.
523   * @param {Cartesian4} result The object onto which to store the result.
524   * @returns {Cartesian4} The modified result parameter.
525   */
526  static lerp(start, end, t, result) {
527    Check_default.typeOf.object("start", start);
528    Check_default.typeOf.object("end", end);
529    Check_default.typeOf.number("t", t);
530    Check_default.typeOf.object("result", result);
531    _Cartesian4.multiplyByScalar(end, t, lerpScratch);
532    result = _Cartesian4.multiplyByScalar(start, 1 - t, result);
533    return _Cartesian4.add(lerpScratch, result, result);
534  }
535  /**
536   * Returns the axis that is most orthogonal to the provided Cartesian.
537   *
538   * @param {Cartesian4} cartesian The Cartesian on which to find the most orthogonal axis.
539   * @param {Cartesian4} result The object onto which to store the result.
540   * @returns {Cartesian4} The most orthogonal axis.
541   */
542  static mostOrthogonalAxis(cartesian, result) {
543    Check_default.typeOf.object("cartesian", cartesian);
544    Check_default.typeOf.object("result", result);
545    const f = _Cartesian4.normalize(cartesian, mostOrthogonalAxisScratch);
546    _Cartesian4.abs(f, f);
547    if (f.x <= f.y) {
548      if (f.x <= f.z) {
549        if (f.x <= f.w) {
550          result = _Cartesian4.clone(_Cartesian4.UNIT_X, result);
551        } else {
552          result = _Cartesian4.clone(_Cartesian4.UNIT_W, result);
553        }
554      } else if (f.z <= f.w) {
555        result = _Cartesian4.clone(_Cartesian4.UNIT_Z, result);
556      } else {
557        result = _Cartesian4.clone(_Cartesian4.UNIT_W, result);
558      }
559    } else if (f.y <= f.z) {
560      if (f.y <= f.w) {
561        result = _Cartesian4.clone(_Cartesian4.UNIT_Y, result);
562      } else {
563        result = _Cartesian4.clone(_Cartesian4.UNIT_W, result);
564      }
565    } else if (f.z <= f.w) {
566      result = _Cartesian4.clone(_Cartesian4.UNIT_Z, result);
567    } else {
568      result = _Cartesian4.clone(_Cartesian4.UNIT_W, result);
569    }
570    return result;
571  }
572  /**
573   * Compares the provided Cartesians componentwise and returns
574   * <code>true</code> if they are equal, <code>false</code> otherwise.
575   *
576   * @param {Cartesian4} [left] The first Cartesian.
577   * @param {Cartesian4} [right] The second Cartesian.
578   * @returns {boolean} <code>true</code> if left and right are equal, <code>false</code> otherwise.
579   */
580  static equals(left, right) {
581    return left === right || defined_default(left) && defined_default(right) && left.x === right.x && left.y === right.y && left.z === right.z && left.w === right.w;
582  }
583  /**
584   * @param {Cartesian4} cartesian
585   * @param {number[]} array
586   * @param {number} offset
587   * @private
588   */
589  static equalsArray(cartesian, array, offset) {
590    return cartesian.x === array[offset] && cartesian.y === array[offset + 1] && cartesian.z === array[offset + 2] && cartesian.w === array[offset + 3];
591  }
592  /**
593   * Compares the provided Cartesians componentwise and returns
594   * <code>true</code> if they pass an absolute or relative tolerance test,
595   * <code>false</code> otherwise.
596   *
597   * @param {Cartesian4} [left] The first Cartesian.
598   * @param {Cartesian4} [right] The second Cartesian.
599   * @param {number} [relativeEpsilon=0] The relative epsilon tolerance to use for equality testing.
600   * @param {number} [absoluteEpsilon=relativeEpsilon] The absolute epsilon tolerance to use for equality testing.
601   * @returns {boolean} <code>true</code> if left and right are within the provided epsilon, <code>false</code> otherwise.
602   */
603  static equalsEpsilon(left, right, relativeEpsilon, absoluteEpsilon) {
604    return left === right || defined_default(left) && defined_default(right) && Math_default.equalsEpsilon(
605      left.x,
606      right.x,
607      relativeEpsilon,
608      absoluteEpsilon
609    ) && Math_default.equalsEpsilon(
610      left.y,
611      right.y,
612      relativeEpsilon,
613      absoluteEpsilon
614    ) && Math_default.equalsEpsilon(
615      left.z,
616      right.z,
617      relativeEpsilon,
618      absoluteEpsilon
619    ) && Math_default.equalsEpsilon(
620      left.w,
621      right.w,
622      relativeEpsilon,
623      absoluteEpsilon
624    );
625  }
626  /**
627   * Duplicates this Cartesian4 instance.
628   *
629   * @param {Cartesian4} [result] The object onto which to store the result.
630   * @returns {Cartesian4} The modified result parameter or a new Cartesian4 instance if one was not provided.
631   */
632  clone(result) {
633    return _Cartesian4.clone(this, result);
634  }
635  /**
636   * Compares this Cartesian against the provided Cartesian componentwise and returns
637   * <code>true</code> if they are equal, <code>false</code> otherwise.
638   *
639   * @param {Cartesian4} [right] The right hand side Cartesian.
640   * @returns {boolean} <code>true</code> if they are equal, <code>false</code> otherwise.
641   */
642  equals(right) {
643    return _Cartesian4.equals(this, right);
644  }
645  /**
646   * Compares this Cartesian against the provided Cartesian componentwise and returns
647   * <code>true</code> if they pass an absolute or relative tolerance test,
648   * <code>false</code> otherwise.
649   *
650   * @param {Cartesian4} [right] The right hand side Cartesian.
651   * @param {number} [relativeEpsilon=0] The relative epsilon tolerance to use for equality testing.
652   * @param {number} [absoluteEpsilon=relativeEpsilon] The absolute epsilon tolerance to use for equality testing.
653   * @returns {boolean} <code>true</code> if they are within the provided epsilon, <code>false</code> otherwise.
654   */
655  equalsEpsilon(right, relativeEpsilon, absoluteEpsilon) {
656    return _Cartesian4.equalsEpsilon(
657      this,
658      right,
659      relativeEpsilon,
660      absoluteEpsilon
661    );
662  }
663  /**
664   * Creates a string representing this Cartesian in the format '(x, y, z, w)'.
665   *
666   * @returns {string} A string representing the provided Cartesian in the format '(x, y, z, w)'.
667   */
668  toString() {
669    return `(${this.x}, ${this.y}, ${this.z}, ${this.w})`;
670  }
671  /**
672   * Packs an arbitrary floating point value to 4 values representable using uint8.
673   *
674   * @param {number} value A floating point number.
675   * @param {Cartesian4} [result] The Cartesian4 that will contain the packed float.
676   * @returns {Cartesian4} A Cartesian4 representing the float packed to values in x, y, z, and w.
677   */
678  static packFloat(value, result) {
679    Check_default.typeOf.number("value", value);
680    if (!defined_default(result)) {
681      result = new _Cartesian4();
682    }
683    scratchF32Array[0] = value;
684    if (littleEndian) {
685      result.x = scratchU8Array[0];
686      result.y = scratchU8Array[1];
687      result.z = scratchU8Array[2];
688      result.w = scratchU8Array[3];
689    } else {
690      result.x = scratchU8Array[3];
691      result.y = scratchU8Array[2];
692      result.z = scratchU8Array[1];
693      result.w = scratchU8Array[0];
694    }
695    return result;
696  }
697  /**
698   * Unpacks a float packed using Cartesian4.packFloat.
699   *
700   * @param {Cartesian4} packedFloat A Cartesian4 containing a float packed to 4 values representable using uint8.
701   * @returns {number} The unpacked float.
702   * @private
703   */
704  static unpackFloat(packedFloat) {
705    Check_default.typeOf.object("packedFloat", packedFloat);
706    if (littleEndian) {
707      scratchU8Array[0] = packedFloat.x;
708      scratchU8Array[1] = packedFloat.y;
709      scratchU8Array[2] = packedFloat.z;
710      scratchU8Array[3] = packedFloat.w;
711    } else {
712      scratchU8Array[0] = packedFloat.w;
713      scratchU8Array[1] = packedFloat.z;
714      scratchU8Array[2] = packedFloat.y;
715      scratchU8Array[3] = packedFloat.x;
716    }
717    return scratchF32Array[0];
718  }
719};
720Cartesian4.packedLength = 4;
721Cartesian4.fromArray = Cartesian4.unpack;
722var distanceScratch = new Cartesian4();
723var lerpScratch = new Cartesian4();
724var mostOrthogonalAxisScratch = new Cartesian4();
725Cartesian4.ZERO = Object.freeze(new Cartesian4(0, 0, 0, 0));
726Cartesian4.ONE = Object.freeze(new Cartesian4(1, 1, 1, 1));
727Cartesian4.UNIT_X = Object.freeze(new Cartesian4(1, 0, 0, 0));
728Cartesian4.UNIT_Y = Object.freeze(new Cartesian4(0, 1, 0, 0));
729Cartesian4.UNIT_Z = Object.freeze(new Cartesian4(0, 0, 1, 0));
730Cartesian4.UNIT_W = Object.freeze(new Cartesian4(0, 0, 0, 1));
731var scratchF32Array = new Float32Array(1);
732var scratchU8Array = new Uint8Array(scratchF32Array.buffer);
733var testU32 = new Uint32Array([287454020]);
734var testU8 = new Uint8Array(testU32.buffer);
735var littleEndian = testU8[0] === 68;
736var Cartesian4_default = Cartesian4;
737
738// packages/engine/Source/Core/Matrix4.js
739function Matrix4(column0Row0, column1Row0, column2Row0, column3Row0, column0Row1, column1Row1, column2Row1, column3Row1, column0Row2, column1Row2, column2Row2, column3Row2, column0Row3, column1Row3, column2Row3, column3Row3) {
740  this[0] = column0Row0 ?? 0;
741  this[1] = column0Row1 ?? 0;
742  this[2] = column0Row2 ?? 0;
743  this[3] = column0Row3 ?? 0;
744  this[4] = column1Row0 ?? 0;
745  this[5] = column1Row1 ?? 0;
746  this[6] = column1Row2 ?? 0;
747  this[7] = column1Row3 ?? 0;
748  this[8] = column2Row0 ?? 0;
749  this[9] = column2Row1 ?? 0;
750  this[10] = column2Row2 ?? 0;
751  this[11] = column2Row3 ?? 0;
752  this[12] = column3Row0 ?? 0;
753  this[13] = column3Row1 ?? 0;
754  this[14] = column3Row2 ?? 0;
755  this[15] = column3Row3 ?? 0;
756}
757Matrix4.packedLength = 16;
758Matrix4.pack = function(value, array, startingIndex) {
759  Check_default.typeOf.object("value", value);
760  Check_default.defined("array", array);
761  startingIndex = startingIndex ?? 0;
762  array[startingIndex++] = value[0];
763  array[startingIndex++] = value[1];
764  array[startingIndex++] = value[2];
765  array[startingIndex++] = value[3];
766  array[startingIndex++] = value[4];
767  array[startingIndex++] = value[5];
768  array[startingIndex++] = value[6];
769  array[startingIndex++] = value[7];
770  array[startingIndex++] = value[8];
771  array[startingIndex++] = value[9];
772  array[startingIndex++] = value[10];
773  array[startingIndex++] = value[11];
774  array[startingIndex++] = value[12];
775  array[startingIndex++] = value[13];
776  array[startingIndex++] = value[14];
777  array[startingIndex] = value[15];
778  return array;
779};
780Matrix4.unpack = function(array, startingIndex, result) {
781  Check_default.defined("array", array);
782  startingIndex = startingIndex ?? 0;
783  if (!defined_default(result)) {
784    result = new Matrix4();
785  }
786  result[0] = array[startingIndex++];
787  result[1] = array[startingIndex++];
788  result[2] = array[startingIndex++];
789  result[3] = array[startingIndex++];
790  result[4] = array[startingIndex++];
791  result[5] = array[startingIndex++];
792  result[6] = array[startingIndex++];
793  result[7] = array[startingIndex++];
794  result[8] = array[startingIndex++];
795  result[9] = array[startingIndex++];
796  result[10] = array[startingIndex++];
797  result[11] = array[startingIndex++];
798  result[12] = array[startingIndex++];
799  result[13] = array[startingIndex++];
800  result[14] = array[startingIndex++];
801  result[15] = array[startingIndex];
802  return result;
803};
804Matrix4.packArray = function(array, result) {
805  Check_default.defined("array", array);
806  const length = array.length;
807  const resultLength = length * 16;
808  if (!defined_default(result)) {
809    result = new Array(resultLength);
810  } else if (!Array.isArray(result) && result.length !== resultLength) {
811    throw new DeveloperError_default(
812      "If result is a typed array, it must have exactly array.length * 16 elements"
813    );
814  } else if (result.length !== resultLength) {
815    result.length = resultLength;
816  }
817  for (let i = 0; i < length; ++i) {
818    Matrix4.pack(array[i], result, i * 16);
819  }
820  return result;
821};
822Matrix4.unpackArray = function(array, result) {
823  Check_default.defined("array", array);
824  Check_default.typeOf.number.greaterThanOrEquals("array.length", array.length, 16);
825  if (array.length % 16 !== 0) {
826    throw new DeveloperError_default("array length must be a multiple of 16.");
827  }
828  const length = array.length;
829  if (!defined_default(result)) {
830    result = new Array(length / 16);
831  } else {
832    result.length = length / 16;
833  }
834  for (let i = 0; i < length; i += 16) {
835    const index = i / 16;
836    result[index] = Matrix4.unpack(array, i, result[index]);
837  }
838  return result;
839};
840Matrix4.clone = function(matrix, result) {
841  if (!defined_default(matrix)) {
842    return void 0;
843  }
844  if (!defined_default(result)) {
845    return new Matrix4(
846      matrix[0],
847      matrix[4],
848      matrix[8],
849      matrix[12],
850      matrix[1],
851      matrix[5],
852      matrix[9],
853      matrix[13],
854      matrix[2],
855      matrix[6],
856      matrix[10],
857      matrix[14],
858      matrix[3],
859      matrix[7],
860      matrix[11],
861      matrix[15]
862    );
863  }
864  result[0] = matrix[0];
865  result[1] = matrix[1];
866  result[2] = matrix[2];
867  result[3] = matrix[3];
868  result[4] = matrix[4];
869  result[5] = matrix[5];
870  result[6] = matrix[6];
871  result[7] = matrix[7];
872  result[8] = matrix[8];
873  result[9] = matrix[9];
874  result[10] = matrix[10];
875  result[11] = matrix[11];
876  result[12] = matrix[12];
877  result[13] = matrix[13];
878  result[14] = matrix[14];
879  result[15] = matrix[15];
880  return result;
881};
882Matrix4.fromArray = Matrix4.unpack;
883Matrix4.fromColumnMajorArray = function(values, result) {
884  Check_default.defined("values", values);
885  return Matrix4.clone(values, result);
886};
887Matrix4.fromRowMajorArray = function(values, result) {
888  Check_default.defined("values", values);
889  if (!defined_default(result)) {
890    return new Matrix4(
891      values[0],
892      values[1],
893      values[2],
894      values[3],
895      values[4],
896      values[5],
897      values[6],
898      values[7],
899      values[8],
900      values[9],
901      values[10],
902      values[11],
903      values[12],
904      values[13],
905      values[14],
906      values[15]
907    );
908  }
909  result[0] = values[0];
910  result[1] = values[4];
911  result[2] = values[8];
912  result[3] = values[12];
913  result[4] = values[1];
914  result[5] = values[5];
915  result[6] = values[9];
916  result[7] = values[13];
917  result[8] = values[2];
918  result[9] = values[6];
919  result[10] = values[10];
920  result[11] = values[14];
921  result[12] = values[3];
922  result[13] = values[7];
923  result[14] = values[11];
924  result[15] = values[15];
925  return result;
926};
927Matrix4.fromRotationTranslation = function(rotation, translation, result) {
928  Check_default.typeOf.object("rotation", rotation);
929  translation = translation ?? Cartesian3_default.ZERO;
930  if (!defined_default(result)) {
931    return new Matrix4(
932      rotation[0],
933      rotation[3],
934      rotation[6],
935      translation.x,
936      rotation[1],
937      rotation[4],
938      rotation[7],
939      translation.y,
940      rotation[2],
941      rotation[5],
942      rotation[8],
943      translation.z,
944      0,
945      0,
946      0,
947      1
948    );
949  }
950  result[0] = rotation[0];
951  result[1] = rotation[1];
952  result[2] = rotation[2];
953  result[3] = 0;
954  result[4] = rotation[3];
955  result[5] = rotation[4];
956  result[6] = rotation[5];
957  result[7] = 0;
958  result[8] = rotation[6];
959  result[9] = rotation[7];
960  result[10] = rotation[8];
961  result[11] = 0;
962  result[12] = translation.x;
963  result[13] = translation.y;
964  result[14] = translation.z;
965  result[15] = 1;
966  return result;
967};
968Matrix4.fromTranslationQuaternionRotationScale = function(translation, rotation, scale, result) {
969  Check_default.typeOf.object("translation", translation);
970  Check_default.typeOf.object("rotation", rotation);
971  Check_default.typeOf.object("scale", scale);
972  if (!defined_default(result)) {
973    result = new Matrix4();
974  }
975  const scaleX = scale.x;
976  const scaleY = scale.y;
977  const scaleZ = scale.z;
978  const x2 = rotation.x * rotation.x;
979  const xy = rotation.x * rotation.y;
980  const xz = rotation.x * rotation.z;
981  const xw = rotation.x * rotation.w;
982  const y2 = rotation.y * rotation.y;
983  const yz = rotation.y * rotation.z;
984  const yw = rotation.y * rotation.w;
985  const z2 = rotation.z * rotation.z;
986  const zw = rotation.z * rotation.w;
987  const w2 = rotation.w * rotation.w;
988  const m00 = x2 - y2 - z2 + w2;
989  const m01 = 2 * (xy - zw);
990  const m02 = 2 * (xz + yw);
991  const m10 = 2 * (xy + zw);
992  const m11 = -x2 + y2 - z2 + w2;
993  const m12 = 2 * (yz - xw);
994  const m20 = 2 * (xz - yw);
995  const m21 = 2 * (yz + xw);
996  const m22 = -x2 - y2 + z2 + w2;
997  result[0] = m00 * scaleX;
998  result[1] = m10 * scaleX;
999  result[2] = m20 * scaleX;
1000  result[3] = 0;
1001  result[4] = m01 * scaleY;
1002  result[5] = m11 * scaleY;
1003  result[6] = m21 * scaleY;
1004  result[7] = 0;
1005  result[8] = m02 * scaleZ;
1006  result[9] = m12 * scaleZ;
1007  result[10] = m22 * scaleZ;
1008  result[11] = 0;
1009  result[12] = translation.x;
1010  result[13] = translation.y;
1011  result[14] = translation.z;
1012  result[15] = 1;
1013  return result;
1014};
1015Matrix4.fromTranslationRotationScale = function(translationRotationScale, result) {
1016  Check_default.typeOf.object("translationRotationScale", translationRotationScale);
1017  return Matrix4.fromTranslationQuaternionRotationScale(
1018    translationRotationScale.translation,
1019    translationRotationScale.rotation,
1020    translationRotationScale.scale,
1021    result
1022  );
1023};
1024Matrix4.fromTranslation = function(translation, result) {
1025  Check_default.typeOf.object("translation", translation);
1026  return Matrix4.fromRotationTranslation(Matrix3_default.IDENTITY, translation, result);
1027};
1028Matrix4.fromScale = function(scale, result) {
1029  Check_default.typeOf.object("scale", scale);
1030  if (!defined_default(result)) {
1031    return new Matrix4(
1032      scale.x,
1033      0,
1034      0,
1035      0,
1036      0,
1037      scale.y,
1038      0,
1039      0,
1040      0,
1041      0,
1042      scale.z,
1043      0,
1044      0,
1045      0,
1046      0,
1047      1
1048    );
1049  }
1050  result[0] = scale.x;
1051  result[1] = 0;
1052  result[2] = 0;
1053  result[3] = 0;
1054  result[4] = 0;
1055  result[5] = scale.y;
1056  result[6] = 0;
1057  result[7] = 0;
1058  result[8] = 0;
1059  result[9] = 0;
1060  result[10] = scale.z;
1061  result[11] = 0;
1062  result[12] = 0;
1063  result[13] = 0;
1064  result[14] = 0;
1065  result[15] = 1;
1066  return result;
1067};
1068Matrix4.fromUniformScale = function(scale, result) {
1069  Check_default.typeOf.number("scale", scale);
1070  if (!defined_default(result)) {
1071    return new Matrix4(
1072      scale,
1073      0,
1074      0,
1075      0,
1076      0,
1077      scale,
1078      0,
1079      0,
1080      0,
1081      0,
1082      scale,
1083      0,
1084      0,
1085      0,
1086      0,
1087      1
1088    );
1089  }
1090  result[0] = scale;
1091  result[1] = 0;
1092  result[2] = 0;
1093  result[3] = 0;
1094  result[4] = 0;
1095  result[5] = scale;
1096  result[6] = 0;
1097  result[7] = 0;
1098  result[8] = 0;
1099  result[9] = 0;
1100  result[10] = scale;
1101  result[11] = 0;
1102  result[12] = 0;
1103  result[13] = 0;
1104  result[14] = 0;
1105  result[15] = 1;
1106  return result;
1107};
1108Matrix4.fromRotation = function(rotation, result) {
1109  Check_default.typeOf.object("rotation", rotation);
1110  if (!defined_default(result)) {
1111    result = new Matrix4();
1112  }
1113  result[0] = rotation[0];
1114  result[1] = rotation[1];
1115  result[2] = rotation[2];
1116  result[3] = 0;
1117  result[4] = rotation[3];
1118  result[5] = rotation[4];
1119  result[6] = rotation[5];
1120  result[7] = 0;
1121  result[8] = rotation[6];
1122  result[9] = rotation[7];
1123  result[10] = rotation[8];
1124  result[11] = 0;
1125  result[12] = 0;
1126  result[13] = 0;
1127  result[14] = 0;
1128  result[15] = 1;
1129  return result;
1130};
1131var fromCameraF = new Cartesian3_default();
1132var fromCameraR = new Cartesian3_default();
1133var fromCameraU = new Cartesian3_default();
1134Matrix4.fromCamera = function(camera, result) {
1135  Check_default.typeOf.object("camera", camera);
1136  const position = camera.position;
1137  const direction = camera.direction;
1138  const up = camera.up;
1139  Check_default.typeOf.object("camera.position", position);
1140  Check_default.typeOf.object("camera.direction", direction);
1141  Check_default.typeOf.object("camera.up", up);
1142  Cartesian3_default.normalize(direction, fromCameraF);
1143  Cartesian3_default.normalize(
1144    Cartesian3_default.cross(fromCameraF, up, fromCameraR),
1145    fromCameraR
1146  );
1147  Cartesian3_default.normalize(
1148    Cartesian3_default.cross(fromCameraR, fromCameraF, fromCameraU),
1149    fromCameraU
1150  );
1151  const sX = fromCameraR.x;
1152  const sY = fromCameraR.y;
1153  const sZ = fromCameraR.z;
1154  const fX = fromCameraF.x;
1155  const fY = fromCameraF.y;
1156  const fZ = fromCameraF.z;
1157  const uX = fromCameraU.x;
1158  const uY = fromCameraU.y;
1159  const uZ = fromCameraU.z;
1160  const positionX = position.x;
1161  const positionY = position.y;
1162  const positionZ = position.z;
1163  const t0 = sX * -positionX + sY * -positionY + sZ * -positionZ;
1164  const t1 = uX * -positionX + uY * -positionY + uZ * -positionZ;
1165  const t2 = fX * positionX + fY * positionY + fZ * positionZ;
1166  if (!defined_default(result)) {
1167    return new Matrix4(
1168      sX,
1169      sY,
1170      sZ,
1171      t0,
1172      uX,
1173      uY,
1174      uZ,
1175      t1,
1176      -fX,
1177      -fY,
1178      -fZ,
1179      t2,
1180      0,
1181      0,
1182      0,
1183      1
1184    );
1185  }
1186  result[0] = sX;
1187  result[1] = uX;
1188  result[2] = -fX;
1189  result[3] = 0;
1190  result[4] = sY;
1191  result[5] = uY;
1192  result[6] = -fY;
1193  result[7] = 0;
1194  result[8] = sZ;
1195  result[9] = uZ;
1196  result[10] = -fZ;
1197  result[11] = 0;
1198  result[12] = t0;
1199  result[13] = t1;
1200  result[14] = t2;
1201  result[15] = 1;
1202  return result;
1203};
1204Matrix4.computePerspectiveFieldOfView = function(fovY, aspectRatio, near, far, result) {
1205  Check_default.typeOf.number.greaterThan("fovY", fovY, 0);
1206  Check_default.typeOf.number.lessThan("fovY", fovY, Math.PI);
1207  Check_default.typeOf.number.greaterThan("near", near, 0);
1208  Check_default.typeOf.number.greaterThan("far", far, 0);
1209  Check_default.typeOf.object("result", result);
1210  const bottom = Math.tan(fovY * 0.5);
1211  const column1Row1 = 1 / bottom;
1212  const column0Row0 = column1Row1 / aspectRatio;
1213  const column2Row2 = (far + near) / (near - far);
1214  const column3Row2 = 2 * far * near / (near - far);
1215  result[0] = column0Row0;
1216  result[1] = 0;
1217  result[2] = 0;
1218  result[3] = 0;
1219  result[4] = 0;
1220  result[5] = column1Row1;
1221  result[6] = 0;
1222  result[7] = 0;
1223  result[8] = 0;
1224  result[9] = 0;
1225  result[10] = column2Row2;
1226  result[11] = -1;
1227  result[12] = 0;
1228  result[13] = 0;
1229  result[14] = column3Row2;
1230  result[15] = 0;
1231  return result;
1232};
1233Matrix4.computeOrthographicOffCenter = function(left, right, bottom, top, near, far, result) {
1234  Check_default.typeOf.number("left", left);
1235  Check_default.typeOf.number("right", right);
1236  Check_default.typeOf.number("bottom", bottom);
1237  Check_default.typeOf.number("top", top);
1238  Check_default.typeOf.number("near", near);
1239  Check_default.typeOf.number("far", far);
1240  Check_default.typeOf.object("result", result);
1241  let a = 1 / (right - left);
1242  let b = 1 / (top - bottom);
1243  let c = 1 / (far - near);
1244  const tx = -(right + left) * a;
1245  const ty = -(top + bottom) * b;
1246  const tz = -(far + near) * c;
1247  a *= 2;
1248  b *= 2;
1249  c *= -2;
1250  result[0] = a;
1251  result[1] = 0;
1252  result[2] = 0;
1253  result[3] = 0;
1254  result[4] = 0;
1255  result[5] = b;
1256  result[6] = 0;
1257  result[7] = 0;
1258  result[8] = 0;
1259  result[9] = 0;
1260  result[10] = c;
1261  result[11] = 0;
1262  result[12] = tx;
1263  result[13] = ty;
1264  result[14] = tz;
1265  result[15] = 1;
1266  return result;
1267};
1268Matrix4.computePerspectiveOffCenter = function(left, right, bottom, top, near, far, result) {
1269  Check_default.typeOf.number("left", left);
1270  Check_default.typeOf.number("right", right);
1271  Check_default.typeOf.number("bottom", bottom);
1272  Check_default.typeOf.number("top", top);
1273  Check_default.typeOf.number("near", near);
1274  Check_default.typeOf.number("far", far);
1275  Check_default.typeOf.object("result", result);
1276  const column0Row0 = 2 * near / (right - left);
1277  const column1Row1 = 2 * near / (top - bottom);
1278  const column2Row0 = (right + left) / (right - left);
1279  const column2Row1 = (top + bottom) / (top - bottom);
1280  const column2Row2 = -(far + near) / (far - near);
1281  const column2Row3 = -1;
1282  const column3Row2 = -2 * far * near / (far - near);
1283  result[0] = column0Row0;
1284  result[1] = 0;
1285  result[2] = 0;
1286  result[3] = 0;
1287  result[4] = 0;
1288  result[5] = column1Row1;
1289  result[6] = 0;
1290  result[7] = 0;
1291  result[8] = column2Row0;
1292  result[9] = column2Row1;
1293  result[10] = column2Row2;
1294  result[11] = column2Row3;
1295  result[12] = 0;
1296  result[13] = 0;
1297  result[14] = column3Row2;
1298  result[15] = 0;
1299  return result;
1300};
1301Matrix4.computeInfinitePerspectiveOffCenter = function(left, right, bottom, top, near, result) {
1302  Check_default.typeOf.number("left", left);
1303  Check_default.typeOf.number("right", right);
1304  Check_default.typeOf.number("bottom", bottom);
1305  Check_default.typeOf.number("top", top);
1306  Check_default.typeOf.number("near", near);
1307  Check_default.typeOf.object("result", result);
1308  const column0Row0 = 2 * near / (right - left);
1309  const column1Row1 = 2 * near / (top - bottom);
1310  const column2Row0 = (right + left) / (right - left);
1311  const column2Row1 = (top + bottom) / (top - bottom);
1312  const column2Row2 = -1;
1313  const column2Row3 = -1;
1314  const column3Row2 = -2 * near;
1315  result[0] = column0Row0;
1316  result[1] = 0;
1317  result[2] = 0;
1318  result[3] = 0;
1319  result[4] = 0;
1320  result[5] = column1Row1;
1321  result[6] = 0;
1322  result[7] = 0;
1323  result[8] = column2Row0;
1324  result[9] = column2Row1;
1325  result[10] = column2Row2;
1326  result[11] = column2Row3;
1327  result[12] = 0;
1328  result[13] = 0;
1329  result[14] = column3Row2;
1330  result[15] = 0;
1331  return result;
1332};
1333Matrix4.computeViewportTransformation = function(viewport, nearDepthRange, farDepthRange, result) {
1334  if (!defined_default(result)) {
1335    result = new Matrix4();
1336  }
1337  viewport = viewport ?? Frozen_default.EMPTY_OBJECT;
1338  const x = viewport.x ?? 0;
1339  const y = viewport.y ?? 0;
1340  const width = viewport.width ?? 0;
1341  const height = viewport.height ?? 0;
1342  nearDepthRange = nearDepthRange ?? 0;
1343  farDepthRange = farDepthRange ?? 1;
1344  const halfWidth = width * 0.5;
1345  const halfHeight = height * 0.5;
1346  const halfDepth = (farDepthRange - nearDepthRange) * 0.5;
1347  const column0Row0 = halfWidth;
1348  const column1Row1 = halfHeight;
1349  const column2Row2 = halfDepth;
1350  const column3Row0 = x + halfWidth;
1351  const column3Row1 = y + halfHeight;
1352  const column3Row2 = nearDepthRange + halfDepth;
1353  const column3Row3 = 1;
1354  result[0] = column0Row0;
1355  result[1] = 0;
1356  result[2] = 0;
1357  result[3] = 0;
1358  result[4] = 0;
1359  result[5] = column1Row1;
1360  result[6] = 0;
1361  result[7] = 0;
1362  result[8] = 0;
1363  result[9] = 0;
1364  result[10] = column2Row2;
1365  result[11] = 0;
1366  result[12] = column3Row0;
1367  result[13] = column3Row1;
1368  result[14] = column3Row2;
1369  result[15] = column3Row3;
1370  return result;
1371};
1372Matrix4.computeView = function(position, direction, up, right, result) {
1373  Check_default.typeOf.object("position", position);
1374  Check_default.typeOf.object("direction", direction);
1375  Check_default.typeOf.object("up", up);
1376  Check_default.typeOf.object("right", right);
1377  Check_default.typeOf.object("result", result);
1378  result[0] = right.x;
1379  result[1] = up.x;
1380  result[2] = -direction.x;
1381  result[3] = 0;
1382  result[4] = right.y;
1383  result[5] = up.y;
1384  result[6] = -direction.y;
1385  result[7] = 0;
1386  result[8] = right.z;
1387  result[9] = up.z;
1388  result[10] = -direction.z;
1389  result[11] = 0;
1390  result[12] = -Cartesian3_default.dot(right, position);
1391  result[13] = -Cartesian3_default.dot(up, position);
1392  result[14] = Cartesian3_default.dot(direction, position);
1393  result[15] = 1;
1394  return result;
1395};
1396Matrix4.toArray = function(matrix, result) {
1397  Check_default.typeOf.object("matrix", matrix);
1398  if (!defined_default(result)) {
1399    return [
1400      matrix[0],
1401      matrix[1],
1402      matrix[2],
1403      matrix[3],
1404      matrix[4],
1405      matrix[5],
1406      matrix[6],
1407      matrix[7],
1408      matrix[8],
1409      matrix[9],
1410      matrix[10],
1411      matrix[11],
1412      matrix[12],
1413      matrix[13],
1414      matrix[14],
1415      matrix[15]
1416    ];
1417  }
1418  result[0] = matrix[0];
1419  result[1] = matrix[1];
1420  result[2] = matrix[2];
1421  result[3] = matrix[3];
1422  result[4] = matrix[4];
1423  result[5] = matrix[5];
1424  result[6] = matrix[6];
1425  result[7] = matrix[7];
1426  result[8] = matrix[8];
1427  result[9] = matrix[9];
1428  result[10] = matrix[10];
1429  result[11] = matrix[11];
1430  result[12] = matrix[12];
1431  result[13] = matrix[13];
1432  result[14] = matrix[14];
1433  result[15] = matrix[15];
1434  return result;
1435};
1436Matrix4.getElementIndex = function(column, row) {
1437  Check_default.typeOf.number.greaterThanOrEquals("row", row, 0);
1438  Check_default.typeOf.number.lessThanOrEquals("row", row, 3);
1439  Check_default.typeOf.number.greaterThanOrEquals("column", column, 0);
1440  Check_default.typeOf.number.lessThanOrEquals("column", column, 3);
1441  return column * 4 + row;
1442};
1443Matrix4.getColumn = function(matrix, index, result) {
1444  Check_default.typeOf.object("matrix", matrix);
1445  Check_default.typeOf.number.greaterThanOrEquals("index", index, 0);
1446  Check_default.typeOf.number.lessThanOrEquals("index", index, 3);
1447  Check_default.typeOf.object("result", result);
1448  const startIndex = index * 4;
1449  const x = matrix[startIndex];
1450  const y = matrix[startIndex + 1];
1451  const z = matrix[startIndex + 2];
1452  const w = matrix[startIndex + 3];
1453  result.x = x;
1454  result.y = y;
1455  result.z = z;
1456  result.w = w;
1457  return result;
1458};
1459Matrix4.setColumn = function(matrix, index, cartesian, result) {
1460  Check_default.typeOf.object("matrix", matrix);
1461  Check_default.typeOf.number.greaterThanOrEquals("index", index, 0);
1462  Check_default.typeOf.number.lessThanOrEquals("index", index, 3);
1463  Check_default.typeOf.object("cartesian", cartesian);
1464  Check_default.typeOf.object("result", result);
1465  result = Matrix4.clone(matrix, result);
1466  const startIndex = index * 4;
1467  result[startIndex] = cartesian.x;
1468  result[startIndex + 1] = cartesian.y;
1469  result[startIndex + 2] = cartesian.z;
1470  result[startIndex + 3] = cartesian.w;
1471  return result;
1472};
1473Matrix4.getRow = function(matrix, index, result) {
1474  Check_default.typeOf.object("matrix", matrix);
1475  Check_default.typeOf.number.greaterThanOrEquals("index", index, 0);
1476  Check_default.typeOf.number.lessThanOrEquals("index", index, 3);
1477  Check_default.typeOf.object("result", result);
1478  const x = matrix[index];
1479  const y = matrix[index + 4];
1480  const z = matrix[index + 8];
1481  const w = matrix[index + 12];
1482  result.x = x;
1483  result.y = y;
1484  result.z = z;
1485  result.w = w;
1486  return result;
1487};
1488Matrix4.setRow = function(matrix, index, cartesian, result) {
1489  Check_default.typeOf.object("matrix", matrix);
1490  Check_default.typeOf.number.greaterThanOrEquals("index", index, 0);
1491  Check_default.typeOf.number.lessThanOrEquals("index", index, 3);
1492  Check_default.typeOf.object("cartesian", cartesian);
1493  Check_default.typeOf.object("result", result);
1494  result = Matrix4.clone(matrix, result);
1495  result[index] = cartesian.x;
1496  result[index + 4] = cartesian.y;
1497  result[index + 8] = cartesian.z;
1498  result[index + 12] = cartesian.w;
1499  return result;
1500};
1501Matrix4.setTranslation = function(matrix, translation, result) {
1502  Check_default.typeOf.object("matrix", matrix);
1503  Check_default.typeOf.object("translation", translation);
1504  Check_default.typeOf.object("result", result);
1505  result[0] = matrix[0];
1506  result[1] = matrix[1];
1507  result[2] = matrix[2];
1508  result[3] = matrix[3];
1509  result[4] = matrix[4];
1510  result[5] = matrix[5];
1511  result[6] = matrix[6];
1512  result[7] = matrix[7];
1513  result[8] = matrix[8];
1514  result[9] = matrix[9];
1515  result[10] = matrix[10];
1516  result[11] = matrix[11];
1517  result[12] = translation.x;
1518  result[13] = translation.y;
1519  result[14] = translation.z;
1520  result[15] = matrix[15];
1521  return result;
1522};
1523var scaleScratch1 = new Cartesian3_default();
1524Matrix4.setScale = function(matrix, scale, result) {
1525  Check_default.typeOf.object("matrix", matrix);
1526  Check_default.typeOf.object("scale", scale);
1527  Check_default.typeOf.object("result", result);
1528  const existingScale = Matrix4.getScale(matrix, scaleScratch1);
1529  const scaleRatioX = scale.x / existingScale.x;
1530  const scaleRatioY = scale.y / existingScale.y;
1531  const scaleRatioZ = scale.z / existingScale.z;
1532  result[0] = matrix[0] * scaleRatioX;
1533  result[1] = matrix[1] * scaleRatioX;
1534  result[2] = matrix[2] * scaleRatioX;
1535  result[3] = matrix[3];
1536  result[4] = matrix[4] * scaleRatioY;
1537  result[5] = matrix[5] * scaleRatioY;
1538  result[6] = matrix[6] * scaleRatioY;
1539  result[7] = matrix[7];
1540  result[8] = matrix[8] * scaleRatioZ;
1541  result[9] = matrix[9] * scaleRatioZ;
1542  result[10] = matrix[10] * scaleRatioZ;
1543  result[11] = matrix[11];
1544  result[12] = matrix[12];
1545  result[13] = matrix[13];
1546  result[14] = matrix[14];
1547  result[15] = matrix[15];
1548  return result;
1549};
1550var scaleScratch2 = new Cartesian3_default();
1551Matrix4.setUniformScale = function(matrix, scale, result) {
1552  Check_default.typeOf.object("matrix", matrix);
1553  Check_default.typeOf.number("scale", scale);
1554  Check_default.typeOf.object("result", result);
1555  const existingScale = Matrix4.getScale(matrix, scaleScratch2);
1556  const scaleRatioX = scale / existingScale.x;
1557  const scaleRatioY = scale / existingScale.y;
1558  const scaleRatioZ = scale / existingScale.z;
1559  result[0] = matrix[0] * scaleRatioX;
1560  result[1] = matrix[1] * scaleRatioX;
1561  result[2] = matrix[2] * scaleRatioX;
1562  result[3] = matrix[3];
1563  result[4] = matrix[4] * scaleRatioY;
1564  result[5] = matrix[5] * scaleRatioY;
1565  result[6] = matrix[6] * scaleRatioY;
1566  result[7] = matrix[7];
1567  result[8] = matrix[8] * scaleRatioZ;
1568  result[9] = matrix[9] * scaleRatioZ;
1569  result[10] = matrix[10] * scaleRatioZ;
1570  result[11] = matrix[11];
1571  result[12] = matrix[12];
1572  result[13] = matrix[13];
1573  result[14] = matrix[14];
1574  result[15] = matrix[15];
1575  return result;
1576};
1577var scratchColumn = new Cartesian3_default();
1578Matrix4.getScale = function(matrix, result) {
1579  Check_default.typeOf.object("matrix", matrix);
1580  Check_default.typeOf.object("result", result);
1581  result.x = Cartesian3_default.magnitude(
1582    Cartesian3_default.fromElements(matrix[0], matrix[1], matrix[2], scratchColumn)
1583  );
1584  result.y = Cartesian3_default.magnitude(
1585    Cartesian3_default.fromElements(matrix[4], matrix[5], matrix[6], scratchColumn)
1586  );
1587  result.z = Cartesian3_default.magnitude(
1588    Cartesian3_default.fromElements(matrix[8], matrix[9], matrix[10], scratchColumn)
1589  );
1590  return result;
1591};
1592var scaleScratch3 = new Cartesian3_default();
1593Matrix4.getMaximumScale = function(matrix) {
1594  Matrix4.getScale(matrix, scaleScratch3);
1595  return Cartesian3_default.maximumComponent(scaleScratch3);
1596};
1597var scaleScratch4 = new Cartesian3_default();
1598Matrix4.setRotation = function(matrix, rotation, result) {
1599  Check_default.typeOf.object("matrix", matrix);
1600  Check_default.typeOf.object("result", result);
1601  const scale = Matrix4.getScale(matrix, scaleScratch4);
1602  result[0] = rotation[0] * scale.x;
1603  result[1] = rotation[1] * scale.x;
1604  result[2] = rotation[2] * scale.x;
1605  result[3] = matrix[3];
1606  result[4] = rotation[3] * scale.y;
1607  result[5] = rotation[4] * scale.y;
1608  result[6] = rotation[5] * scale.y;
1609  result[7] = matrix[7];
1610  result[8] = rotation[6] * scale.z;
1611  result[9] = rotation[7] * scale.z;
1612  result[10] = rotation[8] * scale.z;
1613  result[11] = matrix[11];
1614  result[12] = matrix[12];
1615  result[13] = matrix[13];
1616  result[14] = matrix[14];
1617  result[15] = matrix[15];
1618  return result;
1619};
1620var scaleScratch5 = new Cartesian3_default();
1621Matrix4.getRotation = function(matrix, result) {
1622  Check_default.typeOf.object("matrix", matrix);
1623  Check_default.typeOf.object("result", result);
1624  const scale = Matrix4.getScale(matrix, scaleScratch5);
1625  result[0] = matrix[0] / scale.x;
1626  result[1] = matrix[1] / scale.x;
1627  result[2] = matrix[2] / scale.x;
1628  result[3] = matrix[4] / scale.y;
1629  result[4] = matrix[5] / scale.y;
1630  result[5] = matrix[6] / scale.y;
1631  result[6] = matrix[8] / scale.z;
1632  result[7] = matrix[9] / scale.z;
1633  result[8] = matrix[10] / scale.z;
1634  return result;
1635};
1636Matrix4.multiply = function(left, right, result) {
1637  Check_default.typeOf.object("left", left);
1638  Check_default.typeOf.object("right", right);
1639  Check_default.typeOf.object("result", result);
1640  const left0 = left[0];
1641  const left1 = left[1];
1642  const left2 = left[2];
1643  const left3 = left[3];
1644  const left4 = left[4];
1645  const left5 = left[5];
1646  const left6 = left[6];
1647  const left7 = left[7];
1648  const left8 = left[8];
1649  const left9 = left[9];
1650  const left10 = left[10];
1651  const left11 = left[11];
1652  const left12 = left[12];
1653  const left13 = left[13];
1654  const left14 = left[14];
1655  const left15 = left[15];
1656  const right0 = right[0];
1657  const right1 = right[1];
1658  const right2 = right[2];
1659  const right3 = right[3];
1660  const right4 = right[4];
1661  const right5 = right[5];
1662  const right6 = right[6];
1663  const right7 = right[7];
1664  const right8 = right[8];
1665  const right9 = right[9];
1666  const right10 = right[10];
1667  const right11 = right[11];
1668  const right12 = right[12];
1669  const right13 = right[13];
1670  const right14 = right[14];
1671  const right15 = right[15];
1672  const column0Row0 = left0 * right0 + left4 * right1 + left8 * right2 + left12 * right3;
1673  const column0Row1 = left1 * right0 + left5 * right1 + left9 * right2 + left13 * right3;
1674  const column0Row2 = left2 * right0 + left6 * right1 + left10 * right2 + left14 * right3;
1675  const column0Row3 = left3 * right0 + left7 * right1 + left11 * right2 + left15 * right3;
1676  const column1Row0 = left0 * right4 + left4 * right5 + left8 * right6 + left12 * right7;
1677  const column1Row1 = left1 * right4 + left5 * right5 + left9 * right6 + left13 * right7;
1678  const column1Row2 = left2 * right4 + left6 * right5 + left10 * right6 + left14 * right7;
1679  const column1Row3 = left3 * right4 + left7 * right5 + left11 * right6 + left15 * right7;
1680  const column2Row0 = left0 * right8 + left4 * right9 + left8 * right10 + left12 * right11;
1681  const column2Row1 = left1 * right8 + left5 * right9 + left9 * right10 + left13 * right11;
1682  const column2Row2 = left2 * right8 + left6 * right9 + left10 * right10 + left14 * right11;
1683  const column2Row3 = left3 * right8 + left7 * right9 + left11 * right10 + left15 * right11;
1684  const column3Row0 = left0 * right12 + left4 * right13 + left8 * right14 + left12 * right15;
1685  const column3Row1 = left1 * right12 + left5 * right13 + left9 * right14 + left13 * right15;
1686  const column3Row2 = left2 * right12 + left6 * right13 + left10 * right14 + left14 * right15;
1687  const column3Row3 = left3 * right12 + left7 * right13 + left11 * right14 + left15 * right15;
1688  result[0] = column0Row0;
1689  result[1] = column0Row1;
1690  result[2] = column0Row2;
1691  result[3] = column0Row3;
1692  result[4] = column1Row0;
1693  result[5] = column1Row1;
1694  result[6] = column1Row2;
1695  result[7] = column1Row3;
1696  result[8] = column2Row0;
1697  result[9] = column2Row1;
1698  result[10] = column2Row2;
1699  result[11] = column2Row3;
1700  result[12] = column3Row0;
1701  result[13] = column3Row1;
1702  result[14] = column3Row2;
1703  result[15] = column3Row3;
1704  return result;
1705};
1706Matrix4.add = function(left, right, result) {
1707  Check_default.typeOf.object("left", left);
1708  Check_default.typeOf.object("right", right);
1709  Check_default.typeOf.object("result", result);
1710  result[0] = left[0] + right[0];
1711  result[1] = left[1] + right[1];
1712  result[2] = left[2] + right[2];
1713  result[3] = left[3] + right[3];
1714  result[4] = left[4] + right[4];
1715  result[5] = left[5] + right[5];
1716  result[6] = left[6] + right[6];
1717  result[7] = left[7] + right[7];
1718  result[8] = left[8] + right[8];
1719  result[9] = left[9] + right[9];
1720  result[10] = left[10] + right[10];
1721  result[11] = left[11] + right[11];
1722  result[12] = left[12] + right[12];
1723  result[13] = left[13] + right[13];
1724  result[14] = left[14] + right[14];
1725  result[15] = left[15] + right[15];
1726  return result;
1727};
1728Matrix4.subtract = function(left, right, result) {
1729  Check_default.typeOf.object("left", left);
1730  Check_default.typeOf.object("right", right);
1731  Check_default.typeOf.object("result", result);
1732  result[0] = left[0] - right[0];
1733  result[1] = left[1] - right[1];
1734  result[2] = left[2] - right[2];
1735  result[3] = left[3] - right[3];
1736  result[4] = left[4] - right[4];
1737  result[5] = left[5] - right[5];
1738  result[6] = left[6] - right[6];
1739  result[7] = left[7] - right[7];
1740  result[8] = left[8] - right[8];
1741  result[9] = left[9] - right[9];
1742  result[10] = left[10] - right[10];
1743  result[11] = left[11] - right[11];
1744  result[12] = left[12] - right[12];
1745  result[13] = left[13] - right[13];
1746  result[14] = left[14] - right[14];
1747  result[15] = left[15] - right[15];
1748  return result;
1749};
1750Matrix4.multiplyTransformation = function(left, right, result) {
1751  Check_default.typeOf.object("left", left);
1752  Check_default.typeOf.object("right", right);
1753  Check_default.typeOf.object("result", result);
1754  const left0 = left[0];
1755  const left1 = left[1];
1756  const left2 = left[2];
1757  const left4 = left[4];
1758  const left5 = left[5];
1759  const left6 = left[6];
1760  const left8 = left[8];
1761  const left9 = left[9];
1762  const left10 = left[10];
1763  const left12 = left[12];
1764  const left13 = left[13];
1765  const left14 = left[14];
1766  const right0 = right[0];
1767  const right1 = right[1];
1768  const right2 = right[2];
1769  const right4 = right[4];
1770  const right5 = right[5];
1771  const right6 = right[6];
1772  const right8 = right[8];
1773  const right9 = right[9];
1774  const right10 = right[10];
1775  const right12 = right[12];
1776  const right13 = right[13];
1777  const right14 = right[14];
1778  const column0Row0 = left0 * right0 + left4 * right1 + left8 * right2;
1779  const column0Row1 = left1 * right0 + left5 * right1 + left9 * right2;
1780  const column0Row2 = left2 * right0 + left6 * right1 + left10 * right2;
1781  const column1Row0 = left0 * right4 + left4 * right5 + left8 * right6;
1782  const column1Row1 = left1 * right4 + left5 * right5 + left9 * right6;
1783  const column1Row2 = left2 * right4 + left6 * right5 + left10 * right6;
1784  const column2Row0 = left0 * right8 + left4 * right9 + left8 * right10;
1785  const column2Row1 = left1 * right8 + left5 * right9 + left9 * right10;
1786  const column2Row2 = left2 * right8 + left6 * right9 + left10 * right10;
1787  const column3Row0 = left0 * right12 + left4 * right13 + left8 * right14 + left12;
1788  const column3Row1 = left1 * right12 + left5 * right13 + left9 * right14 + left13;
1789  const column3Row2 = left2 * right12 + left6 * right13 + left10 * right14 + left14;
1790  result[0] = column0Row0;
1791  result[1] = column0Row1;
1792  result[2] = column0Row2;
1793  result[3] = 0;
1794  result[4] = column1Row0;
1795  result[5] = column1Row1;
1796  result[6] = column1Row2;
1797  result[7] = 0;
1798  result[8] = column2Row0;
1799  result[9] = column2Row1;
1800  result[10] = column2Row2;
1801  result[11] = 0;
1802  result[12] = column3Row0;
1803  result[13] = column3Row1;
1804  result[14] = column3Row2;
1805  result[15] = 1;
1806  return result;
1807};
1808Matrix4.multiplyByMatrix3 = function(matrix, rotation, result) {
1809  Check_default.typeOf.object("matrix", matrix);
1810  Check_default.typeOf.object("rotation", rotation);
1811  Check_default.typeOf.object("result", result);
1812  const left0 = matrix[0];
1813  const left1 = matrix[1];
1814  const left2 = matrix[2];
1815  const left4 = matrix[4];
1816  const left5 = matrix[5];
1817  const left6 = matrix[6];
1818  const left8 = matrix[8];
1819  const left9 = matrix[9];
1820  const left10 = matrix[10];
1821  const right0 = rotation[0];
1822  const right1 = rotation[1];
1823  const right2 = rotation[2];
1824  const right4 = rotation[3];
1825  const right5 = rotation[4];
1826  const right6 = rotation[5];
1827  const right8 = rotation[6];
1828  const right9 = rotation[7];
1829  const right10 = rotation[8];
1830  const column0Row0 = left0 * right0 + left4 * right1 + left8 * right2;
1831  const column0Row1 = left1 * right0 + left5 * right1 + left9 * right2;
1832  const column0Row2 = left2 * right0 + left6 * right1 + left10 * right2;
1833  const column1Row0 = left0 * right4 + left4 * right5 + left8 * right6;
1834  const column1Row1 = left1 * right4 + left5 * right5 + left9 * right6;
1835  const column1Row2 = left2 * right4 + left6 * right5 + left10 * right6;
1836  const column2Row0 = left0 * right8 + left4 * right9 + left8 * right10;
1837  const column2Row1 = left1 * right8 + left5 * right9 + left9 * right10;
1838  const column2Row2 = left2 * right8 + left6 * right9 + left10 * right10;
1839  result[0] = column0Row0;
1840  result[1] = column0Row1;
1841  result[2] = column0Row2;
1842  result[3] = 0;
1843  result[4] = column1Row0;
1844  result[5] = column1Row1;
1845  result[6] = column1Row2;
1846  result[7] = 0;
1847  result[8] = column2Row0;
1848  result[9] = column2Row1;
1849  result[10] = column2Row2;
1850  result[11] = 0;
1851  result[12] = matrix[12];
1852  result[13] = matrix[13];
1853  result[14] = matrix[14];
1854  result[15] = matrix[15];
1855  return result;
1856};
1857Matrix4.multiplyByTranslation = function(matrix, translation, result) {
1858  Check_default.typeOf.object("matrix", matrix);
1859  Check_default.typeOf.object("translation", translation);
1860  Check_default.typeOf.object("result", result);
1861  const x = translation.x;
1862  const y = translation.y;
1863  const z = translation.z;
1864  const tx = x * matrix[0] + y * matrix[4] + z * matrix[8] + matrix[12];
1865  const ty = x * matrix[1] + y * matrix[5] + z * matrix[9] + matrix[13];
1866  const tz = x * matrix[2] + y * matrix[6] + z * matrix[10] + matrix[14];
1867  result[0] = matrix[0];
1868  result[1] = matrix[1];
1869  result[2] = matrix[2];
1870  result[3] = matrix[3];
1871  result[4] = matrix[4];
1872  result[5] = matrix[5];
1873  result[6] = matrix[6];
1874  result[7] = matrix[7];
1875  result[8] = matrix[8];
1876  result[9] = matrix[9];
1877  result[10] = matrix[10];
1878  result[11] = matrix[11];
1879  result[12] = tx;
1880  result[13] = ty;
1881  result[14] = tz;
1882  result[15] = matrix[15];
1883  return result;
1884};
1885Matrix4.multiplyByScale = function(matrix, scale, result) {
1886  Check_default.typeOf.object("matrix", matrix);
1887  Check_default.typeOf.object("scale", scale);
1888  Check_default.typeOf.object("result", result);
1889  const scaleX = scale.x;
1890  const scaleY = scale.y;
1891  const scaleZ = scale.z;
1892  if (scaleX === 1 && scaleY === 1 && scaleZ === 1) {
1893    return Matrix4.clone(matrix, result);
1894  }
1895  result[0] = scaleX * matrix[0];
1896  result[1] = scaleX * matrix[1];
1897  result[2] = scaleX * matrix[2];
1898  result[3] = matrix[3];
1899  result[4] = scaleY * matrix[4];
1900  result[5] = scaleY * matrix[5];
1901  result[6] = scaleY * matrix[6];
1902  result[7] = matrix[7];
1903  result[8] = scaleZ * matrix[8];
1904  result[9] = scaleZ * matrix[9];
1905  result[10] = scaleZ * matrix[10];
1906  result[11] = matrix[11];
1907  result[12] = matrix[12];
1908  result[13] = matrix[13];
1909  result[14] = matrix[14];
1910  result[15] = matrix[15];
1911  return result;
1912};
1913Matrix4.multiplyByUniformScale = function(matrix, scale, result) {
1914  Check_default.typeOf.object("matrix", matrix);
1915  Check_default.typeOf.number("scale", scale);
1916  Check_default.typeOf.object("result", result);
1917  result[0] = matrix[0] * scale;
1918  result[1] = matrix[1] * scale;
1919  result[2] = matrix[2] * scale;
1920  result[3] = matrix[3];
1921  result[4] = matrix[4] * scale;
1922  result[5] = matrix[5] * scale;
1923  result[6] = matrix[6] * scale;
1924  result[7] = matrix[7];
1925  result[8] = matrix[8] * scale;
1926  result[9] = matrix[9] * scale;
1927  result[10] = matrix[10] * scale;
1928  result[11] = matrix[11];
1929  result[12] = matrix[12];
1930  result[13] = matrix[13];
1931  result[14] = matrix[14];
1932  result[15] = matrix[15];
1933  return result;
1934};
1935Matrix4.multiplyByVector = function(matrix, cartesian, result) {
1936  Check_default.typeOf.object("matrix", matrix);
1937  Check_default.typeOf.object("cartesian", cartesian);
1938  Check_default.typeOf.object("result", result);
1939  const vX = cartesian.x;
1940  const vY = cartesian.y;
1941  const vZ = cartesian.z;
1942  const vW = cartesian.w;
1943  const x = matrix[0] * vX + matrix[4] * vY + matrix[8] * vZ + matrix[12] * vW;
1944  const y = matrix[1] * vX + matrix[5] * vY + matrix[9] * vZ + matrix[13] * vW;
1945  const z = matrix[2] * vX + matrix[6] * vY + matrix[10] * vZ + matrix[14] * vW;
1946  const w = matrix[3] * vX + matrix[7] * vY + matrix[11] * vZ + matrix[15] * vW;
1947  result.x = x;
1948  result.y = y;
1949  result.z = z;
1950  result.w = w;
1951  return result;
1952};
1953Matrix4.multiplyByPointAsVector = function(matrix, cartesian, result) {
1954  Check_default.typeOf.object("matrix", matrix);
1955  Check_default.typeOf.object("cartesian", cartesian);
1956  Check_default.typeOf.object("result", result);
1957  const vX = cartesian.x;
1958  const vY = cartesian.y;
1959  const vZ = cartesian.z;
1960  const x = matrix[0] * vX + matrix[4] * vY + matrix[8] * vZ;
1961  const y = matrix[1] * vX + matrix[5] * vY + matrix[9] * vZ;
1962  const z = matrix[2] * vX + matrix[6] * vY + matrix[10] * vZ;
1963  result.x = x;
1964  result.y = y;
1965  result.z = z;
1966  return result;
1967};
1968Matrix4.multiplyByPoint = function(matrix, cartesian, result) {
1969  Check_default.typeOf.object("matrix", matrix);
1970  Check_default.typeOf.object("cartesian", cartesian);
1971  Check_default.typeOf.object("result", result);
1972  const vX = cartesian.x;
1973  const vY = cartesian.y;
1974  const vZ = cartesian.z;
1975  const x = matrix[0] * vX + matrix[4] * vY + matrix[8] * vZ + matrix[12];
1976  const y = matrix[1] * vX + matrix[5] * vY + matrix[9] * vZ + matrix[13];
1977  const z = matrix[2] * vX + matrix[6] * vY + matrix[10] * vZ + matrix[14];
1978  result.x = x;
1979  result.y = y;
1980  result.z = z;
1981  return result;
1982};
1983Matrix4.multiplyByScalar = function(matrix, scalar, result) {
1984  Check_default.typeOf.object("matrix", matrix);
1985  Check_default.typeOf.number("scalar", scalar);
1986  Check_default.typeOf.object("result", result);
1987  result[0] = matrix[0] * scalar;
1988  result[1] = matrix[1] * scalar;
1989  result[2] = matrix[2] * scalar;
1990  result[3] = matrix[3] * scalar;
1991  result[4] = matrix[4] * scalar;
1992  result[5] = matrix[5] * scalar;
1993  result[6] = matrix[6] * scalar;
1994  result[7] = matrix[7] * scalar;
1995  result[8] = matrix[8] * scalar;
1996  result[9] = matrix[9] * scalar;
1997  result[10] = matrix[10] * scalar;
1998  result[11] = matrix[11] * scalar;
1999  result[12] = matrix[12] * scalar;
2000  result[13] = matrix[13] * scalar;
2001  result[14] = matrix[14] * scalar;
2002  result[15] = matrix[15] * scalar;
2003  return result;
2004};
2005Matrix4.negate = function(matrix, result) {
2006  Check_default.typeOf.object("matrix", matrix);
2007  Check_default.typeOf.object("result", result);
2008  result[0] = -matrix[0];
2009  result[1] = -matrix[1];
2010  result[2] = -matrix[2];
2011  result[3] = -matrix[3];
2012  result[4] = -matrix[4];
2013  result[5] = -matrix[5];
2014  result[6] = -matrix[6];
2015  result[7] = -matrix[7];
2016  result[8] = -matrix[8];
2017  result[9] = -matrix[9];
2018  result[10] = -matrix[10];
2019  result[11] = -matrix[11];
2020  result[12] = -matrix[12];
2021  result[13] = -matrix[13];
2022  result[14] = -matrix[14];
2023  result[15] = -matrix[15];
2024  return result;
2025};
2026Matrix4.transpose = function(matrix, result) {
2027  Check_default.typeOf.object("matrix", matrix);
2028  Check_default.typeOf.object("result", result);
2029  const matrix1 = matrix[1];
2030  const matrix2 = matrix[2];
2031  const matrix3 = matrix[3];
2032  const matrix6 = matrix[6];
2033  const matrix7 = matrix[7];
2034  const matrix11 = matrix[11];
2035  result[0] = matrix[0];
2036  result[1] = matrix[4];
2037  result[2] = matrix[8];
2038  result[3] = matrix[12];
2039  result[4] = matrix1;
2040  result[5] = matrix[5];
2041  result[6] = matrix[9];
2042  result[7] = matrix[13];
2043  result[8] = matrix2;
2044  result[9] = matrix6;
2045  result[10] = matrix[10];
2046  result[11] = matrix[14];
2047  result[12] = matrix3;
2048  result[13] = matrix7;
2049  result[14] = matrix11;
2050  result[15] = matrix[15];
2051  return result;
2052};
2053Matrix4.abs = function(matrix, result) {
2054  Check_default.typeOf.object("matrix", matrix);
2055  Check_default.typeOf.object("result", result);
2056  result[0] = Math.abs(matrix[0]);
2057  result[1] = Math.abs(matrix[1]);
2058  result[2] = Math.abs(matrix[2]);
2059  result[3] = Math.abs(matrix[3]);
2060  result[4] = Math.abs(matrix[4]);
2061  result[5] = Math.abs(matrix[5]);
2062  result[6] = Math.abs(matrix[6]);
2063  result[7] = Math.abs(matrix[7]);
2064  result[8] = Math.abs(matrix[8]);
2065  result[9] = Math.abs(matrix[9]);
2066  result[10] = Math.abs(matrix[10]);
2067  result[11] = Math.abs(matrix[11]);
2068  result[12] = Math.abs(matrix[12]);
2069  result[13] = Math.abs(matrix[13]);
2070  result[14] = Math.abs(matrix[14]);
2071  result[15] = Math.abs(matrix[15]);
2072  return result;
2073};
2074Matrix4.equals = function(left, right) {
2075  return left === right || defined_default(left) && defined_default(right) && // Translation
2076  left[12] === right[12] && left[13] === right[13] && left[14] === right[14] && // Rotation/scale
2077  left[0] === right[0] && left[1] === right[1] && left[2] === right[2] && left[4] === right[4] && left[5] === right[5] && left[6] === right[6] && left[8] === right[8] && left[9] === right[9] && left[10] === right[10
2077] && // Bottom row
2078  left[3] === right[3] && left[7] === right[7] && left[11] === right[11] && left[15] === right[15];
2079};
2080Matrix4.equalsEpsilon = function(left, right, epsilon) {
2081  epsilon = epsilon ?? 0;
2082  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 && Math.abs(left[9] - right[9]) <= epsilon && Math.abs(left[10] - right[10]) <= epsilon && Math.abs(left[11] - right[11]) <= epsilon && Math.abs(left[12] - right[12]) <= epsilon && Math.abs(left[13] - right[13]) <= epsilon && Math.abs(left[14] - right[14]) <= epsilon && Math.abs(left[15] - right[15]) <= epsilon;
2083};
2084Matrix4.getTranslation = function(matrix, result) {
2085  Check_default.typeOf.object("matrix", matrix);
2086  Check_default.typeOf.object("result", result);
2087  result.x = matrix[12];
2088  result.y = matrix[13];
2089  result.z = matrix[14];
2090  return result;
2091};
2092Matrix4.getMatrix3 = function(matrix, result) {
2093  Check_default.typeOf.object("matrix", matrix);
2094  Check_default.typeOf.object("result", result);
2095  result[0] = matrix[0];
2096  result[1] = matrix[1];
2097  result[2] = matrix[2];
2098  result[3] = matrix[4];
2099  result[4] = matrix[5];
2100  result[5] = matrix[6];
2101  result[6] = matrix[8];
2102  result[7] = matrix[9];
2103  result[8] = matrix[10];
2104  return result;
2105};
2106var scratchInverseRotation = new Matrix3_default();
2107var scratchMatrix3Zero = new Matrix3_default();
2108var scratchBottomRow = new Cartesian4_default();
2109var scratchExpectedBottomRow = new Cartesian4_default(0, 0, 0, 1);
2110Matrix4.inverse = function(matrix, result) {
2111  Check_default.typeOf.object("matrix", matrix);
2112  Check_default.typeOf.object("result", result);
2113  const src0 = matrix[0];
2114  const src1 = matrix[4];
2115  const src2 = matrix[8];
2116  const src3 = matrix[12];
2117  const src4 = matrix[1];
2118  const src5 = matrix[5];
2119  const src6 = matrix[9];
2120  const src7 = matrix[13];
2121  const src8 = matrix[2];
2122  const src9 = matrix[6];
2123  const src10 = matrix[10];
2124  const src11 = matrix[14];
2125  const src12 = matrix[3];
2126  const src13 = matrix[7];
2127  const src14 = matrix[11];
2128  const src15 = matrix[15];
2129  let tmp0 = src10 * src15;
2130  let tmp1 = src11 * src14;
2131  let tmp2 = src9 * src15;
2132  let tmp3 = src11 * src13;
2133  let tmp4 = src9 * src14;
2134  let tmp5 = src10 * src13;
2135  let tmp6 = src8 * src15;
2136  let tmp7 = src11 * src12;
2137  let tmp8 = src8 * src14;
2138  let tmp9 = src10 * src12;
2139  let tmp10 = src8 * src13;
2140  let tmp11 = src9 * src12;
2141  const dst0 = tmp0 * src5 + tmp3 * src6 + tmp4 * src7 - (tmp1 * src5 + tmp2 * src6 + tmp5 * src7);
2142  const dst1 = tmp1 * src4 + tmp6 * src6 + tmp9 * src7 - (tmp0 * src4 + tmp7 * src6 + tmp8 * src7);
2143  const dst2 = tmp2 * src4 + tmp7 * src5 + tmp10 * src7 - (tmp3 * src4 + tmp6 * src5 + tmp11 * src7);
2144  const dst3 = tmp5 * src4 + tmp8 * src5 + tmp11 * src6 - (tmp4 * src4 + tmp9 * src5 + tmp10 * src6);
2145  const dst4 = tmp1 * src1 + tmp2 * src2 + tmp5 * src3 - (tmp0 * src1 + tmp3 * src2 + tmp4 * src3);
2146  const dst5 = tmp0 * src0 + tmp7 * src2 + tmp8 * src3 - (tmp1 * src0 + tmp6 * src2 + tmp9 * src3);
2147  const dst6 = tmp3 * src0 + tmp6 * src1 + tmp11 * src3 - (tmp2 * src0 + tmp7 * src1 + tmp10 * src3);
2148  const dst7 = tmp4 * src0 + tmp9 * src1 + tmp10 * src2 - (tmp5 * src0 + tmp8 * src1 + tmp11 * src2);
2149  tmp0 = src2 * src7;
2150  tmp1 = src3 * src6;
2151  tmp2 = src1 * src7;
2152  tmp3 = src3 * src5;
2153  tmp4 = src1 * src6;
2154  tmp5 = src2 * src5;
2155  tmp6 = src0 * src7;
2156  tmp7 = src3 * src4;
2157  tmp8 = src0 * src6;
2158  tmp9 = src2 * src4;
2159  tmp10 = src0 * src5;
2160  tmp11 = src1 * src4;
2161  const dst8 = tmp0 * src13 + tmp3 * src14 + tmp4 * src15 - (tmp1 * src13 + tmp2 * src14 + tmp5 * src15);
2162  const dst9 = tmp1 * src12 + tmp6 * src14 + tmp9 * src15 - (tmp0 * src12 + tmp7 * src14 + tmp8 * src15);
2163  const dst10 = tmp2 * src12 + tmp7 * src13 + tmp10 * src15 - (tmp3 * src12 + tmp6 * src13 + tmp11 * src15);
2164  const dst11 = tmp5 * src12 + tmp8 * src13 + tmp11 * src14 - (tmp4 * src12 + tmp9 * src13 + tmp10 * src14);
2165  const dst12 = tmp2 * src10 + tmp5 * src11 + tmp1 * src9 - (tmp4 * src11 + tmp0 * src9 + tmp3 * src10);
2166  const dst13 = tmp8 * src11 + tmp0 * src8 + tmp7 * src10 - (tmp6 * src10 + tmp9 * src11 + tmp1 * src8);
2167  const dst14 = tmp6 * src9 + tmp11 * src11 + tmp3 * src8 - (tmp10 * src11 + tmp2 * src8 + tmp7 * src9);
2168  const dst15 = tmp10 * src10 + tmp4 * src8 + tmp9 * src9 - (tmp8 * src9 + tmp11 * src10 + tmp5 * src8);
2169  let det = src0 * dst0 + src1 * dst1 + src2 * dst2 + src3 * dst3;
2170  if (Math.abs(det) < Math_default.EPSILON21) {
2171    if (Matrix3_default.equalsEpsilon(
2172      Matrix4.getMatrix3(matrix, scratchInverseRotation),
2173      scratchMatrix3Zero,
2174      Math_default.EPSILON7
2175    ) && Cartesian4_default.equals(
2176      Matrix4.getRow(matrix, 3, scratchBottomRow),
2177      scratchExpectedBottomRow
2178    )) {
2179      result[0] = 0;
2180      result[1] = 0;
2181      result[2] = 0;
2182      result[3] = 0;
2183      result[4] = 0;
2184      result[5] = 0;
2185      result[6] = 0;
2186      result[7] = 0;
2187      result[8] = 0;
2188      result[9] = 0;
2189      result[10] = 0;
2190      result[11] = 0;
2191      result[12] = -matrix[12];
2192      result[13] = -matrix[13];
2193      result[14] = -matrix[14];
2194      result[15] = 1;
2195      return result;
2196    }
2197    throw new RuntimeError_default(
2198      "matrix is not invertible because its determinate is zero."
2199    );
2200  }
2201  det = 1 / det;
2202  result[0] = dst0 * det;
2203  result[1] = dst1 * det;
2204  result[2] = dst2 * det;
2205  result[3] = dst3 * det;
2206  result[4] = dst4 * det;
2207  result[5] = dst5 * det;
2208  result[6] = dst6 * det;
2209  result[7] = dst7 * det;
2210  result[8] = dst8 * det;
2211  result[9] = dst9 * det;
2212  result[10] = dst10 * det;
2213  result[11] = dst11 * det;
2214  result[12] = dst12 * det;
2215  result[13] = dst13 * det;
2216  result[14] = dst14 * det;
2217  result[15] = dst15 * det;
2218  return result;
2219};
2220Matrix4.inverseTransformation = function(matrix, result) {
2221  Check_default.typeOf.object("matrix", matrix);
2222  Check_default.typeOf.object("result", result);
2223  const matrix0 = matrix[0];
2224  const matrix1 = matrix[1];
2225  const matrix2 = matrix[2];
2226  const matrix4 = matrix[4];
2227  const matrix5 = matrix[5];
2228  const matrix6 = matrix[6];
2229  const matrix8 = matrix[8];
2230  const matrix9 = matrix[9];
2231  const matrix10 = matrix[10];
2232  const vX = matrix[12];
2233  const vY = matrix[13];
2234  const vZ = matrix[14];
2235  const x = -matrix0 * vX - matrix1 * vY - matrix2 * vZ;
2236  const y = -matrix4 * vX - matrix5 * vY - matrix6 * vZ;
2237  const z = -matrix8 * vX - matrix9 * vY - matrix10 * vZ;
2238  result[0] = matrix0;
2239  result[1] = matrix4;
2240  result[2] = matrix8;
2241  result[3] = 0;
2242  result[4] = matrix1;
2243  result[5] = matrix5;
2244  result[6] = matrix9;
2245  result[7] = 0;
2246  result[8] = matrix2;
2247  result[9] = matrix6;
2248  result[10] = matrix10;
2249  result[11] = 0;
2250  result[12] = x;
2251  result[13] = y;
2252  result[14] = z;
2253  result[15] = 1;
2254  return result;
2255};
2256var scratchTransposeMatrix = new Matrix4();
2257Matrix4.inverseTranspose = function(matrix, result) {
2258  Check_default.typeOf.object("matrix", matrix);
2259  Check_default.typeOf.object("result", result);
2260  return Matrix4.inverse(
2261    Matrix4.transpose(matrix, scratchTransposeMatrix),
2262    result
2263  );
2264};
2265Matrix4.IDENTITY = Object.freeze(
2266  new Matrix4(
2267    1,
2268    0,
2269    0,
2270    0,
2271    0,
2272    1,
2273    0,
2274    0,
2275    0,
2276    0,
2277    1,
2278    0,
2279    0,
2280    0,
2281    0,
2282    1
2283  )
2284);
2285Matrix4.ZERO = Object.freeze(
2286  new Matrix4(
2287    0,
2288    0,
2289    0,
2290    0,
2291    0,
2292    0,
2293    0,
2294    0,
2295    0,
2296    0,
2297    0,
2298    0,
2299    0,
2300    0,
2301    0,
2302    0
2303  )
2304);
2305Matrix4.COLUMN0ROW0 = 0;
2306Matrix4.COLUMN0ROW1 = 1;
2307Matrix4.COLUMN0ROW2 = 2;
2308Matrix4.COLUMN0ROW3 = 3;
2309Matrix4.COLUMN1ROW0 = 4;
2310Matrix4.COLUMN1ROW1 = 5;
2311Matrix4.COLUMN1ROW2 = 6;
2312Matrix4.COLUMN1ROW3 = 7;
2313Matrix4.COLUMN2ROW0 = 8;
2314Matrix4.COLUMN2ROW1 = 9;
2315Matrix4.COLUMN2ROW2 = 10;
2316Matrix4.COLUMN2ROW3 = 11;
2317Matrix4.COLUMN3ROW0 = 12;
2318Matrix4.COLUMN3ROW1 = 13;
2319Matrix4.COLUMN3ROW2 = 14;
2320Matrix4.COLUMN3ROW3 = 15;
2321Object.defineProperties(Matrix4.prototype, {
2322  /**
2323   * Gets the number of items in the collection.
2324   * @memberof Matrix4.prototype
2325   *
2326   * @type {number}
2327   */
2328  length: {
2329    get: function() {
2330      return Matrix4.packedLength;
2331    }
2332  }
2333});
2334Matrix4.prototype.clone = function(result) {
2335  return Matrix4.clone(this, result);
2336};
2337Matrix4.prototype.equals = function(right) {
2338  return Matrix4.equals(this, right);
2339};
2340Matrix4.equalsArray = function(matrix, array, offset) {
2341  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] && matrix[9] === array[offset + 9] && matrix[10] === array[offset + 10] && matrix[11] === array[offset + 11] && matrix[12] === array[offset + 12] && matrix[13] === array[offset + 13] && matrix[14] === array[offset + 14] && matrix[15] === array[offset + 15];
2342};
2343Matrix4.prototype.equalsEpsilon = function(right, epsilon) {
2344  return Matrix4.equalsEpsilon(this, right, epsilon);
2345};
2346Matrix4.prototype.toString = function() {
2347  return `(${this[0]}, ${this[4]}, ${this[8]}, ${this[12]})
2348(${this[1]}, ${this[5]}, ${this[9]}, ${this[13]})
2349(${this[2]}, ${this[6]}, ${this[10]}, ${this[14]})
2350(${this[3]}, ${this[7]}, ${this[11]}, ${this[15]})`;
2351};
2352var Matrix4_default = Matrix4;
2353
2354export {
2355  Cartesian4_default,
2356  Matrix4_default
2357};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.