vendor: 329,280 bytes, lines 1-9237
1/** 2 * @license 3 * Cesium - https://github.com/CesiumGS/cesium 4 * Version 1.145.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 Cartesian4_default, 28 Matrix4_default 29} from "./chunk-6R6SGKYN.js"; 30import { 31 RuntimeError_default 32} from "./chunk-GLHDTTTO.js"; 33import { 34 Cartesian2_default, 35 Cartographic_default, 36 Ellipsoid_default, 37 FeatureDetection_default 38} from "./chunk-6BSNYZZG.js"; 39import { 40 Cartesian3_default, 41 Frozen_default, 42 Matrix3_default 43} from "./chunk-Z2DW5NM2.js"; 44import { 45 Math_default 46} from "./chunk-HDD3RFLT.js"; 47import { 48 Check_default, 49 DeveloperError_default 50} from "./chunk-XSIUYAT6.js"; 51import { 52 __commonJS, 53 __require, 54 __toESM, 55 defined_default 56} from "./chunk-B4AVL7VI.js"; 57 58// node_modules/urijs/src/punycode.js 59var require_punycode = __commonJS({ 60 "node_modules/urijs/src/punycode.js"(exports, module) { 61 /*! https://mths.be/punycode v1.4.0 by @mathias */ 62 (function(root) { 63 var freeExports = typeof exports == "object" && exports && !exports.nodeType && exports; 64 var freeModule = typeof module == "object" && module && !module.nodeType && module; 65 var freeGlobal = typeof global == "object" && global; 66 if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal || freeGlobal.self === freeGlobal) { 67 root = freeGlobal; 68 } 69 var punycode, maxInt = 2147483647, base = 36, tMin = 1, tMax = 26, skew = 38, damp = 700, initialBias = 72, initialN = 128, delimiter = "-", regexPunycode = /^xn--/, regexNonASCII = /[^\x20-\x7E]/, regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g, errors = { 70 "overflow": "Overflow: input needs wider integers to process", 71 "not-basic": "Illegal input >= 0x80 (not a basic code point)", 72 "invalid-input": "Invalid input" 73 }, baseMinusTMin = base - tMin, floor = Math.floor, stringFromCharCode = String.fromCharCode, key; 74 function error(type) { 75 throw new RangeError(errors[type]); 76 } 77 function map(array, fn) { 78 var length = array.length; 79 var result = []; 80 while (length--) { 81 result[length] = fn(array[length]); 82 } 83 return result; 84 } 85 function mapDomain(string, fn) { 86 var parts = string.split("@"); 87 var result = ""; 88 if (parts.length > 1) { 89 result = parts[0] + "@"; 90 string = parts[1]; 91 } 92 string = string.replace(regexSeparators, "."); 93 var labels = string.split("."); 94 var encoded = map(labels, fn).join("."); 95 return result + encoded; 96 } 97 function ucs2decode(string) { 98 var output = [], counter = 0, length = string.length, value, extra; 99 while (counter < length) { 100 value = string.charCodeAt(counter++); 101 if (value >= 55296 && value <= 56319 && counter < length) { 102 extra = string.charCodeAt(counter++); 103 if ((extra & 64512) == 56320) { 104 output.push(((value & 1023) << 10) + (extra & 1023) + 65536); 105 } else { 106 output.push(value); 107 counter--; 108 } 109 } else { 110 output.push(value); 111 } 112 } 113 return output; 114 } 115 function ucs2encode(array) { 116 return map(array, function(value) { 117 var output = ""; 118 if (value > 65535) { 119 value -= 65536; 120 output += stringFromCharCode(value >>> 10 & 1023 | 55296); 121 value = 56320 | value & 1023; 122 } 123 output += stringFromCharCode(value); 124 return output; 125 }).join(""); 126 } 127 function basicToDigit(codePoint) { 128 if (codePoint - 48 < 10) { 129 return codePoint - 22; 130 } 131 if (codePoint - 65 < 26) { 132 return codePoint - 65; 133 } 134 if (codePoint - 97 < 26) { 135 return codePoint - 97; 136 } 137 return base; 138 } 139 function digitToBasic(digit, flag) { 140 return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5); 141 } 142 function adapt(delta, numPoints, firstTime) { 143 var k = 0; 144 delta = firstTime ? floor(delta / damp) : delta >> 1; 145 delta += floor(delta / numPoints); 146 for (; delta > baseMinusTMin * tMax >> 1; k += base) { 147 delta = floor(delta / baseMinusTMin); 148 } 149 return floor(k + (baseMinusTMin + 1) * delta / (delta + skew)); 150 } 151 function decode(input) { 152 var output = [], inputLength = input.length, out, i = 0, n = initialN, bias = initialBias, basic, j, index, oldi, w, k, digit, t, baseMinusT; 153 basic = input.lastIndexOf(delimiter); 154 if (basic < 0) { 155 basic = 0; 156 } 157 for (j = 0; j < basic; ++j) { 158 if (input.charCodeAt(j) >= 128) { 159 error("not-basic"); 160 } 161 output.push(input.charCodeAt(j)); 162 } 163 for (index = basic > 0 ? basic + 1 : 0; index < inputLength; ) { 164 for (oldi = i, w = 1, k = base; ; k += base) { 165 if (index >= inputLength) { 166 error("invalid-input"); 167 } 168 digit = basicToDigit(input.charCodeAt(index++)); 169 if (digit >= base || digit > floor((maxInt - i) / w)) { 170 error("overflow"); 171 } 172 i += digit * w; 173 t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias; 174 if (digit < t) { 175 break; 176 } 177 baseMinusT = base - t; 178 if (w > floor(maxInt / baseMinusT)) { 179 error("overflow"); 180 } 181 w *= baseMinusT; 182 } 183 out = output.length + 1; 184 bias = adapt(i - oldi, out, oldi == 0); 185 if (floor(i / out) > maxInt - n) { 186 error("overflow"); 187 } 188 n += floor(i / out); 189 i %= out; 190 output.splice(i++, 0, n); 191 } 192 return ucs2encode(output); 193 } 194 function encode(input) { 195 var n, delta, handledCPCount, basicLength, bias, j, m, q, k, t, currentValue, output = [], inputLength, handledCPCountPlusOne, baseMinusT, qMinusT; 196 input = ucs2decode(input); 197 inputLength = input.length; 198 n = initialN; 199 delta = 0; 200 bias = initialBias; 201 for (j = 0; j < inputLength; ++j) { 202 currentValue = input[j]; 203 if (currentValue < 128) { 204 output.push(stringFromCharCode(currentValue)); 205 } 206 } 207 handledCPCount = basicLength = output.length; 208 if (basicLength) { 209 output.push(delimiter); 210 } 211 while (handledCPCount < inputLength) { 212 for (m = maxInt, j = 0; j < inputLength; ++j) { 213 currentValue = input[j]; 214 if (currentValue >= n && currentValue < m) { 215 m = currentValue; 216 } 217 } 218 handledCPCountPlusOne = handledCPCount + 1; 219 if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) { 220 error("overflow"); 221 } 222 delta += (m - n) * handledCPCountPlusOne; 223 n = m; 224 for (j = 0; j < inputLength; ++j) { 225 currentValue = input[j]; 226 if (currentValue < n && ++delta > maxInt) { 227 error("overflow"); 228 } 229 if (currentValue == n) { 230 for (q = delta, k = base; ; k += base) { 231 t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias; 232 if (q < t) { 233 break; 234 } 235 qMinusT = q - t; 236 baseMinusT = base - t; 237 output.push( 238 stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0)) 239 ); 240 q = floor(qMinusT / baseMinusT); 241 } 242 output.push(stringFromCharCode(digitToBasic(q, 0))); 243 bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength); 244 delta = 0; 245 ++handledCPCount; 246 } 247 } 248 ++delta; 249 ++n; 250 } 251 return output.join(""); 252 } 253 function toUnicode(input) { 254 return mapDomain(input, function(string) { 255 return regexPunycode.test(string) ? decode(string.slice(4).toLowerCase()) : string; 256 }); 257 } 258 function toASCII(input) { 259 return mapDomain(input, function(string) { 260 return regexNonASCII.test(string) ? "xn--" + encode(string) : string; 261 }); 262 } 263 punycode = { 264 /** 265 * A string representing the current Punycode.js version number. 266 * @memberOf punycode 267 * @type String 268 */ 269 "version": "1.3.2", 270 /** 271 * An object of methods to convert from JavaScript's internal character 272 * representation (UCS-2) to Unicode code points, and back. 273 * @see <https://mathiasbynens.be/notes/javascript-encoding> 274 * @memberOf punycode 275 * @type Object 276 */ 277 "ucs2": { 278 "decode": ucs2decode, 279 "encode": ucs2encode 280 }, 281 "decode": decode, 282 "encode": encode, 283 "toASCII": toASCII, 284 "toUnicode": toUnicode 285 }; 286 if (typeof define == "function" && typeof define.amd == "object" && define.amd) { 287 define("punycode", function() { 288 return punycode; 289 }); 290 } else if (freeExports && freeModule) { 291 if (module.exports == freeExports) { 292 freeModule.exports = punycode; 293 } else { 294 for (key in punycode) { 295 punycode.hasOwnProperty(key) && (freeExports[key] = punycode[key]); 296 } 297 } 298 } else { 299 root.punycode = punycode; 300 } 301 })(exports); 302 } 303}); 304 305// node_modules/urijs/src/IPv6.js 306var require_IPv6 = __commonJS({ 307 "node_modules/urijs/src/IPv6.js"(exports, module) { 308 /*! 309 * URI.js - Mutating URLs 310 * IPv6 Support 311 * 312 * Version: 1.19.11 313 * 314 * Author: Rodney Rehm 315 * Web: http://medialize.github.io/URI.js/ 316 * 317 * Licensed under 318 * MIT License http://www.opensource.org/licenses/mit-license 319 * 320 */ 321 (function(root, factory) { 322 "use strict"; 323 if (typeof module === "object" && module.exports) { 324 module.exports = factory(); 325 } else if (typeof define === "function" && define.amd) { 326 define(factory); 327 } else { 328 root.IPv6 = factory(root); 329 } 330 })(exports, function(root) { 331 "use strict"; 332 var _IPv6 = root && root.IPv6; 333 function bestPresentation(address) { 334 var _address = address.toLowerCase(); 335 var segments = _address.split(":"); 336 var length = segments.length; 337 var total = 8; 338 if (segments[0] === "" && segments[1] === "" && segments[2] === "") { 339 segments.shift(); 340 segments.shift(); 341 } else if (segments[0] === "" && segments[1] === "") { 342 segments.shift(); 343 } else if (segments[length - 1] === "" && segments[length - 2] === "") { 344 segments.pop(); 345 } 346 length = segments.length; 347 if (segments[length - 1].indexOf(".") !== -1) { 348 total = 7; 349 } 350 var pos; 351 for (pos = 0; pos < length; pos++) { 352 if (segments[pos] === "") { 353 break; 354 } 355 } 356 if (pos < total) { 357 segments.splice(pos, 1, "0000"); 358 while (segments.length < total) { 359 segments.splice(pos, 0, "0000"); 360 } 361 } 362 var _segments; 363 for (var i = 0; i < total; i++) { 364 _segments = segments[i].split(""); 365 for (var j = 0; j < 3; j++) { 366 if (_segments[0] === "0" && _segments.length > 1) { 367 _segments.splice(0, 1); 368 } else { 369 break; 370 } 371 } 372 segments[i] = _segments.join(""); 373 } 374 var best = -1; 375 var _best = 0; 376 var _current = 0; 377 var current = -1; 378 var inzeroes = false; 379 for (i = 0; i < total; i++) { 380 if (inzeroes) { 381 if (segments[i] === "0") { 382 _current += 1; 383 } else { 384 inzeroes = false; 385 if (_current > _best) { 386 best = current; 387 _best = _current; 388 } 389 } 390 } else { 391 if (segments[i] === "0") { 392 inzeroes = true; 393 current = i; 394 _current = 1; 395 } 396 } 397 } 398 if (_current > _best) { 399 best = current; 400 _best = _current; 401 } 402 if (_best > 1) { 403 segments.splice(best, _best, ""); 404 } 405 length = segments.length; 406 var result = ""; 407 if (segments[0] === "") { 408 result = ":"; 409 } 410 for (i = 0; i < length; i++) { 411 result += segments[i]; 412 if (i === length - 1) { 413 break; 414 } 415 result += ":"; 416 } 417 if (segments[length - 1] === "") { 418 result += ":"; 419 } 420 return result; 421 } 422 function noConflict() { 423 if (root.IPv6 === this) { 424 root.IPv6 = _IPv6; 425 } 426 return this; 427 } 428 return { 429 best: bestPresentation, 430 noConflict 431 }; 432 }); 433 } 434}); 435 436// node_modules/urijs/src/SecondLevelDomains.js 437var require_SecondLevelDomains = __commonJS({ 438 "node_modules/urijs/src/SecondLevelDomains.js"(exports, module) { 439 /*! 440 * URI.js - Mutating URLs 441 * Second Level Domain (SLD) Support 442 * 443 * Version: 1.19.11 444 * 445 * Author: Rodney Rehm 446 * Web: http://medialize.github.io/URI.js/ 447 * 448 * Licensed under 449 * MIT License http://www.opensource.org/licenses/mit-license 450 * 451 */ 452 (function(root, factory) { 453 "use strict"; 454 if (typeof module === "object" && module.exports) { 455 module.exports = factory(); 456 } else if (typeof define === "function" && define.amd) { 457 define(factory); 458 } else { 459 root.SecondLevelDomains = factory(root); 460 } 461 })(exports, function(root) { 462 "use strict"; 463 var _SecondLevelDomains = root && root.SecondLevelDomains; 464 var SLD = { 465 // list of known Second Level Domains 466 // converted list of SLDs from https://github.com/gavingmiller/second-level-domains 467 // ---- 468 // publicsuffix.org is more current and actually used by a couple of browsers internally. 469 // downside is it also contains domains like "dyndns.org" - which is fine for the security 470 // issues browser have to deal with (SOP for cookies, etc) - but is way overboard for URI.js 471 // ---- 472 list: { 473 "ac": " com gov mil net org ", 474 "ae": " ac co gov mil name net org pro sch ", 475 "af": " com edu gov net org ", 476 "al": " com edu gov mil net org ", 477 "ao": " co ed gv it og pb ", 478 "ar": " com edu gob gov int mil net org tur ", 479 "at": " ac co gv or ", 480 "au": " asn com csiro edu gov id net org ", 481 "ba": " co com edu gov mil net org rs unbi unmo unsa untz unze ", 482 "bb": " biz co com edu gov info net org store tv ", 483 "bh": " biz cc com edu gov info net org ", 484 "bn": " com edu gov net org ", 485 "bo": " com edu gob gov int mil net org tv ", 486 "br": " adm adv agr am arq art ato b bio blog bmd cim cng cnt com coop ecn edu eng esp etc eti far flog fm fnd fot fst g12 ggf gov imb ind inf jor jus lel mat med mil mus net nom not ntr odo org ppg pro psc psi qsl rec slg srv tmp trd tur tv vet vlog wiki zlg ", 487 "bs": " com edu gov net org ", 488 "bz": " du et om ov rg ", 489 "ca": " ab bc mb nb nf nl ns nt nu on pe qc sk yk ", 490 "ck": " biz co edu gen gov info net org ", 491 "cn": " ac ah bj com cq edu fj gd gov gs gx gz ha hb he hi hl hn jl js jx ln mil net nm nx org qh sc sd sh sn sx tj tw xj xz yn zj ", 492 "co": " com edu gov mil net nom org ", 493 "cr": " ac c co ed fi go or sa ", 494 "cy": " ac biz com ekloges gov ltd name net org parliament press pro tm ", 495 "do": " art com edu gob gov mil net org sld web ", 496 "dz": " art asso com edu gov net org pol ", 497 "ec": " com edu fin gov info med mil net org pro ", 498 "eg": " com edu eun gov mil name net org sci ", 499 "er": " com edu gov ind mil net org rochest w ", 500 "es": " com edu gob nom org ", 501 "et": " biz com edu gov info name net org ", 502 "fj": " ac biz com info mil name net org pro ", 503 "fk": " ac co gov net nom org ", 504 "fr": " asso com f gouv nom prd presse tm ", 505 "gg": " co net org ", 506 "gh": " com edu gov mil org ", 507 "gn": " ac com gov net org ", 508 "gr": " com edu gov mil net org ", 509 "gt": " com edu gob ind mil net org ", 510 "gu": " com edu gov net org ", 511 "hk": " com edu gov idv net org ", 512 "hu": " 2000 agrar bolt casino city co erotica erotika film forum games hotel info ingatlan jogasz konyvelo lakas media news org priv reklam sex shop sport suli szex tm tozsde utazas video ", 513 "id": " ac co go mil net or sch web ", 514 "il": " ac co gov idf k12 muni net org ", 515 "in": " ac co edu ernet firm gen gov i ind mil net nic org res ", 516 "iq": " com edu gov i mil net org ", 517 "ir": " ac co dnssec gov i id net org sch ", 518 "it": " edu gov ", 519 "je": " co net org ", 520 "jo": " com edu gov mil name net org sch ", 521 "jp": " ac ad co ed go gr lg ne or ", 522 "ke": " ac co go info me mobi ne or sc ", 523 "kh": " com edu gov mil net org per ", 524 "ki": " biz com de edu gov info mob net org tel ", 525 "km": " asso com coop edu gouv k medecin mil nom notaires pharmaciens presse tm veterinaire ", 526 "kn": " edu gov net org ", 527 "kr": " ac busan chungbuk chungnam co daegu daejeon es gangwon go gwangju gyeongbuk gyeonggi gyeongnam hs incheon jeju jeonbuk jeonnam k kg mil ms ne or pe re sc seoul ulsan ", 528 "kw": " com edu gov net org ", 529 "ky": " com edu gov net org ", 530 "kz": " com edu gov mil net org ", 531 "lb": " com edu gov net org ", 532 "lk": " assn com edu gov grp hotel int ltd net ngo org sch soc web ", 533 "lr": " com edu gov net org ", 534 "lv": " asn com conf edu gov id mil net org ", 535 "ly": " com edu gov id med net org plc sch ", 536 "ma": " ac co gov m net org press ", 537 "mc": " asso tm ", 538 "me": " ac co edu gov its net org priv ", 539 "mg": " com edu gov mil nom org prd tm ", 540 "mk": " com edu gov inf name net org pro ", 541 "ml": " com edu gov net org presse ", 542 "mn": " edu gov org ", 543 "mo": " com edu gov net org ", 544 "mt": " com edu gov net org ", 545 "mv": " aero biz com coop edu gov info int mil museum name net org pro ", 546 "mw": " ac co com coop edu gov int museum net org ", 547 "mx": " com edu gob net org ", 548 "my": " com edu gov mil name net org sch ", 549 "nf": " arts com firm info net other per rec store web ", 550 "ng": " biz com edu gov mil mobi name net org sch ", 551 "ni": " ac co com edu gob mil net nom org ", 552 "np": " com edu gov mil net org ", 553 "nr": " biz com edu gov info net org ", 554 "om": " ac biz co com edu gov med mil museum net org pro sch ", 555 "pe": " com edu gob mil net nom org sld ", 556 "ph": " com edu gov i mil net ngo org ", 557 "pk": " biz com edu fam gob gok gon gop gos gov net org web ", 558 "pl": " art bialystok biz com edu gda gdansk gorzow gov info katowice krakow lodz lublin mil net ngo olsztyn org poznan pwr radom slupsk szczecin torun warszawa waw wroc wroclaw zgora ", 559 "pr": " ac biz com edu est gov info isla name net org pro prof ", 560 "ps": " com edu gov net org plo sec ", 561 "pw": " belau co ed go ne or ", 562 "ro": " arts com firm info nom nt org rec store tm www ", 563 "rs": " ac co edu gov in org ", 564 "sb": " com edu gov net org ", 565 "sc": " com edu gov net org ", 566 "sh": " co com edu gov net nom org ", 567 "sl": " com edu gov net org ", 568 "st": " co com consulado edu embaixada gov mil net org principe saotome store ", 569 "sv": " com edu gob org red ", 570 "sz": " ac co org ", 571 "tr": " av bbs bel biz com dr edu gen gov info k12 name net org pol tel tsk tv web ", 572 "tt": " aero biz cat co com coop edu gov info int jobs mil mobi museum name net org pro tel travel ", 573 "tw": " club com ebiz edu game gov idv mil net org ", 574 "mu": " ac co com gov net or org ", 575 "mz": " ac co edu gov org ", 576 "na": " co com ", 577 "nz": " ac co cri geek gen govt health iwi maori mil net org parliament school ", 578 "pa": " abo ac com edu gob ing med net nom org sld ", 579 "pt": " com edu gov int net nome org publ ", 580 "py": " com edu gov mil net org ", 581 "qa": " com edu gov mil net org ", 582 "re": " asso com nom ", 583 "ru": " ac adygeya altai amur arkhangelsk astrakhan bashkiria belgorod bir bryansk buryatia cbg chel chelyabinsk chita chukotka chuvashia com dagestan e-burg edu gov grozny int irkutsk ivanovo izhevsk jar joshkar-ola kalmykia kaluga kamchatka karelia kazan kchr kemerovo khabarovsk khakassia khv kirov koenig komi kostroma kranoyarsk kuban kurgan kursk lipetsk magadan mari mari-el marine mil mordovia mosreg msk murmansk nalchik net nnov nov novosibirsk nsk omsk orenburg org oryol penza perm pp pskov ptz rnd ryazan sakhalin samara saratov simbirsk smolensk spb stavropol stv surgut tambov tatarstan tom tomsk tsaritsyn tsk tula tuva tver tyumen udm udmurtia ulan-ude vladikavkaz vladimir vladivostok volgograd vologda voronezh vrn vyatka yakutia yamal yekaterinburg yuzhno-sakhalinsk ", 584 "rw": " ac co com edu gouv gov int mil net ", 585 "sa": " com edu gov med net org pub sch ", 586 "sd": " com edu gov info med net org tv ", 587 "se": " a ac b bd c d e f g h i k l m n o org p parti pp press r s t tm u w x y z ", 588 "sg": " com edu gov idn net org per ", 589 "sn": " art com edu gouv org perso univ ", 590 "sy": " com edu gov mil net news org ", 591 "th": " ac co go in mi net or ", 592 "tj": " ac biz co com edu go gov info int mil name net nic org test web ", 593 "tn": " agrinet com defense edunet ens fin gov ind info intl mincom nat net org perso rnrt rns rnu tourism ", 594 "tz": " ac co go ne or ", 595 "ua": " biz cherkassy chernigov chernovtsy ck cn co com crimea cv dn dnepropetrovsk donetsk dp edu gov if in ivano-frankivsk kh kharkov kherson khmelnitskiy kiev kirovograd km kr ks kv lg lugansk lutsk lviv me mk net nikolaev od odessa org pl poltava pp rovno rv sebastopol sumy te ternopil uzhgorod vinnica vn zaporizhzhe zhitomir zp zt ", 596 "ug": " ac co go ne or org sc ", 597 "uk": " ac bl british-library co cym gov govt icnet jet lea ltd me mil mod national-library-scotland nel net nhs nic nls org orgn parliament plc police sch scot soc ", 598 "us": " dni fed isa kids nsn ", 599 "uy": " com edu gub mil net org ", 600 "ve": " co com edu gob info mil net org web ", 601 "vi": " co com k12 net org ", 602 "vn": " ac biz com edu gov health info int name net org pro ", 603 "ye": " co com gov ltd me net org plc ", 604 "yu": " ac co edu gov org ", 605 "za": " ac agric alt bourse city co cybernet db edu gov grondar iaccess imt inca landesign law mil net ngo nis nom olivetti org pix school tm web ", 606 "zm": " ac co com edu gov net org sch ", 607 // https://en.wikipedia.org/wiki/CentralNic#Second-level_domains 608 "com": "ar br cn de eu gb gr hu jpn kr no qc ru sa se uk us uy za ", 609 "net": "gb jp se uk ", 610 "org": "ae", 611 "de": "com " 612 }, 613 // gorhill 2013-10-25: Using indexOf() instead Regexp(). Significant boost 614 // in both performance and memory footprint. No initialization required. 615 // http://jsperf.com/uri-js-sld-regex-vs-binary-search/4 616 // Following methods use lastIndexOf() rather than array.split() in order 617 // to avoid any memory allocations. 618 has: function(domain) { 619 var tldOffset = domain.lastIndexOf("."); 620 if (tldOffset <= 0 || tldOffset >= domain.length - 1) { 621 return false; 622 } 623 var sldOffset = domain.lastIndexOf(".", tldOffset - 1); 624 if (sldOffset <= 0 || sldOffset >= tldOffset - 1) { 625 return false; 626 } 627 var sldList = SLD.list[domain.slice(tldOffset + 1)]; 628 if (!sldList) { 629 return false; 630 } 631 return sldList.indexOf(" " + domain.slice(sldOffset + 1, tldOffset) + " ") >= 0; 632 }, 633 is: function(domain) { 634 var tldOffset = domain.lastIndexOf("."); 635 if (tldOffset <= 0 || tldOffset >= domain.length - 1) { 636 return false; 637 } 638 var sldOffset = domain.lastIndexOf(".", tldOffset - 1); 639 if (sldOffset >= 0) { 640 return false; 641 } 642 var sldList = SLD.list[domain.slice(tldOffset + 1)]; 643 if (!sldList) { 644 return false; 645 } 646 return sldList.indexOf(" " + domain.slice(0, tldOffset) + " ") >= 0; 647 }, 648 get: function(domain) { 649 var tldOffset = domain.lastIndexOf("."); 650 if (tldOffset <= 0 || tldOffset >= domain.length - 1) { 651 return null; 652 } 653 var sldOffset = domain.lastIndexOf(".", tldOffset - 1); 654 if (sldOffset <= 0 || sldOffset >= tldOffset - 1) { 655 return null; 656 } 657 var sldList = SLD.list[domain.slice(tldOffset + 1)]; 658 if (!sldList) { 659 return null; 660 } 661 if (sldList.indexOf(" " + domain.slice(sldOffset + 1, tldOffset) + " ") < 0) { 662 return null; 663 } 664 return domain.slice(sldOffset + 1); 665 }, 666 noConflict: function() { 667 if (root.SecondLevelDomains === this) { 668 root.SecondLevelDomains = _SecondLevelDomains; 669 } 670 return this; 671 } 672 }; 673 return SLD; 674 }); 675 } 676}); 677 678// node_modules/urijs/src/URI.js 679var require_URI = __commonJS({ 680 "node_modules/urijs/src/URI.js"(exports, module) { 681 /*! 682 * URI.js - Mutating URLs 683 * 684 * Version: 1.19.11 685 * 686 * Author: Rodney Rehm 687 * Web: http://medialize.github.io/URI.js/ 688 * 689 * Licensed under 690 * MIT License http://www.opensource.org/licenses/mit-license 691 * 692 */ 693 (function(root, factory) { 694 "use strict"; 695 if (typeof module === "object" && module.exports) { 696 module.exports = factory(require_punycode(), require_IPv6(), require_SecondLevelDomains()); 697 } else if (typeof define === "function" && define.amd) { 698 define(["./punycode", "./IPv6", "./SecondLevelDomains"], factory); 699 } else { 700 root.URI = factory(root.punycode, root.IPv6, root.SecondLevelDomains, root); 701 } 702 })(exports, function(punycode, IPv6, SLD, root) { 703 "use strict"; 704 var _URI = root && root.URI; 705 function URI(url, base) { 706 var _urlSupplied = arguments.length >= 1; 707 var _baseSupplied = arguments.length >= 2; 708 if (!(this instanceof URI)) { 709 if (_urlSupplied) { 710 if (_baseSupplied) { 711 return new URI(url, base); 712 } 713 return new URI(url); 714 } 715 return new URI(); 716 } 717 if (url === void 0) { 718 if (_urlSupplied) { 719 throw new TypeError("undefined is not a valid argument for URI"); 720 } 721 if (typeof location !== "undefined") { 722 url = location.href + ""; 723 } else { 724 url = ""; 725 } 726 } 727 if (url === null) { 728 if (_urlSupplied) { 729 throw new TypeError("null is not a valid argument for URI"); 730 } 731 } 732 this.href(url); 733 if (base !== void 0) { 734 return this.absoluteTo(base); 735 } 736 return this; 737 } 738 function isInteger(value) { 739 return /^[0-9]+$/.test(value); 740 } 741 URI.version = "1.19.11"; 742 var p = URI.prototype; 743 var hasOwn = Object.prototype.hasOwnProperty; 744 function escapeRegEx(string) { 745 return string.replace(/([.*+?^=!:${}()|[\]\/\\])/g, "\\$1"); 746 } 747 function getType(value) { 748 if (value === void 0) { 749 return "Undefined"; 750 } 751 return String(Object.prototype.toString.call(value)).slice(8, -1); 752 } 753 function isArray(obj) { 754 return getType(obj) === "Array"; 755 } 756 function filterArrayValues(data, value) { 757 var lookup = {}; 758 var i, length; 759 if (getType(value) === "RegExp") { 760 lookup = null; 761 } else if (isArray(value)) { 762 for (i = 0, length = value.length; i < length; i++) { 763 lookup[value[i]] = true; 764 } 765 } else { 766 lookup[value] = true; 767 } 768 for (i = 0, length = data.length; i < length; i++) { 769 var _match = lookup && lookup[data[i]] !== void 0 || !lookup && value.test(data[i]); 770 if (_match) { 771 data.splice(i, 1); 772 length--; 773 i--; 774 } 775 } 776 return data; 777 } 778 function arrayContains(list, value) { 779 var i, length; 780 if (isArray(value)) { 781 for (i = 0, length = value.length; i < length; i++) { 782 if (!arrayContains(list, value[i])) { 783 return false; 784 } 785 } 786 return true; 787 } 788 var _type = getType(value); 789 for (i = 0, length = list.length; i < length; i++) { 790 if (_type === "RegExp") { 791 if (typeof list[i] === "string" && list[i].match(value)) { 792 return true; 793 } 794 } else if (list[i] === value) { 795 return true; 796 } 797 } 798 return false; 799 } 800 function arraysEqual(one, two) { 801 if (!isArray(one) || !isArray(two)) { 802 return false; 803 } 804 if (one.length !== two.length) { 805 return false; 806 } 807 one.sort(); 808 two.sort(); 809 for (var i = 0, l = one.length; i < l; i++) { 810 if (one[i] !== two[i]) { 811 return false; 812 } 813 } 814 return true; 815 } 816 function trimSlashes(text) { 817 var trim_expression = /^\/+|\/+$/g; 818 return text.replace(trim_expression, ""); 819 } 820 URI._parts = function() { 821 return { 822 protocol: null, 823 username: null, 824 password: null, 825 hostname: null, 826 urn: null, 827 port: null, 828 path: null, 829 query: null, 830 fragment: null, 831 // state 832 preventInvalidHostname: URI.preventInvalidHostname, 833 duplicateQueryParameters: URI.duplicateQueryParameters, 834 escapeQuerySpace: URI.escapeQuerySpace 835 }; 836 }; 837 URI.preventInvalidHostname = false; 838 URI.duplicateQueryParameters = false; 839 URI.escapeQuerySpace = true; 840 URI.protocol_expression = /^[a-z][a-z0-9.+-]*$/i; 841 URI.idn_expression = /[^a-z0-9\._-]/i; 842 URI.punycode_expression = /(xn--)/i; 843 URI.ip4_expression = /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/; 844 URI.ip6_expression = /^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$/; 845 URI.find_uri_expression = /\b((?:[a-z][\w-]+:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»ââââ]))/ig; 846 URI.findUri = { 847 // valid "scheme://" or "www." 848 start: /\b(?:([a-z][a-z0-9.+-]*:\/\/)|www\.)/gi, 849 // everything up to the next whitespace 850 end: /[\s\r\n]|$/, 851 // trim trailing punctuation captured by end RegExp 852 trim: /[`!()\[\]{};:'".,<>?«»âââââ]+$/, 853 // balanced parens inclusion (), [], {}, <> 854 parens: /(\([^\)]*\)|\[[^\]]*\]|\{[^}]*\}|<[^>]*>)/g 855 }; 856 URI.leading_whitespace_expression = /^[\x00-\x20\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]+/; 857 URI.ascii_tab_whitespace = /[\u0009\u000A\u000D]+/g; 858 URI.defaultPorts = { 859 http: "80", 860 https: "443", 861 ftp: "21", 862 gopher: "70", 863 ws: "80", 864 wss: "443" 865 }; 866 URI.hostProtocols = [ 867 "http", 868 "https" 869 ]; 870 URI.invalid_hostname_characters = /[^a-zA-Z0-9\.\-:_]/; 871 URI.domAttributes = { 872 "a": "href", 873 "blockquote": "cite", 874 "link": "href", 875 "base": "href", 876 "script": "src", 877 "form": "action", 878 "img": "src", 879 "area": "href", 880 "iframe": "src", 881 "embed": "src", 882 "source": "src", 883 "track": "src", 884 "input": "src", 885 // but only if type="image" 886 "audio": "src", 887 "video": "src" 888 }; 889 URI.getDomAttribute = function(node) { 890 if (!node || !node.nodeName) { 891 return void 0; 892 } 893 var nodeName = node.nodeName.toLowerCase(); 894 if (nodeName === "input" && node.type !== "image") { 895 return void 0; 896 } 897 return URI.domAttributes[nodeName]; 898 }; 899 function escapeForDumbFirefox36(value) { 900 return escape(value); 901 } 902 function strictEncodeURIComponent(string) { 903 return encodeURIComponent(string).replace(/[!'()*]/g, escapeForDumbFirefox36).replace(/\*/g, "%2A"); 904 } 905 URI.encode = strictEncodeURIComponent; 906 URI.decode = decodeURIComponent; 907 URI.iso8859 = function() { 908 URI.encode = escape; 909 URI.decode = unescape; 910 }; 911 URI.unicode = function() { 912 URI.encode = strictEncodeURIComponent; 913 URI.decode = decodeURIComponent; 914 }; 915 URI.characters = { 916 pathname: { 917 encode: { 918 // RFC3986 2.1: For consistency, URI producers and normalizers should 919 // use uppercase hexadecimal digits for all percent-encodings. 920 expression: /%(24|26|2B|2C|3B|3D|3A|40)/ig, 921 map: { 922 // -._~!'()* 923 "%24": "$", 924 "%26": "&", 925 "%2B": "+", 926 "%2C": ",", 927 "%3B": ";", 928 "%3D": "=", 929 "%3A": ":", 930 "%40": "@" 931 } 932 }, 933 decode: { 934 expression: /[\/\?#]/g, 935 map: { 936 "/": "%2F", 937 "?": "%3F", 938 "#": "%23" 939 } 940 } 941 }, 942 reserved: { 943 encode: { 944 // RFC3986 2.1: For consistency, URI producers and normalizers should 945 // use uppercase hexadecimal digits for all percent-encodings. 946 expression: /%(21|23|24|26|27|28|29|2A|2B|2C|2F|3A|3B|3D|3F|40|5B|5D)/ig, 947 map: { 948 // gen-delims 949 "%3A": ":", 950 "%2F": "/", 951 "%3F": "?", 952 "%23": "#", 953 "%5B": "[", 954 "%5D": "]", 955 "%40": "@", 956 // sub-delims 957 "%21": "!", 958 "%24": "$", 959 "%26": "&", 960 "%27": "'", 961 "%28": "(", 962 "%29": ")", 963 "%2A": "*", 964 "%2B": "+", 965 "%2C": ",", 966 "%3B": ";", 967 "%3D": "=" 968 } 969 } 970 }, 971 urnpath: { 972 // The characters under `encode` are the characters called out by RFC 2141 as being acceptable 973 // for usage in a URN. RFC2141 also calls out "-", ".", and "_" as acceptable characters, but 974 // these aren't encoded by encodeURIComponent, so we don't have to call them out here. Also 975 // note that the colon character is not featured in the encoding map; this is because URI.js 976 // gives the colons in URNs semantic meaning as the delimiters of path segements, and so it 977 // should not appear unencoded in a segment itself. 978 // See also the note above about RFC3986 and capitalalized hex digits. 979 encode: { 980 expression: /%(21|24|27|28|29|2A|2B|2C|3B|3D|40)/ig, 981 map: { 982 "%21": "!", 983 "%24": "$", 984 "%27": "'", 985 "%28": "(", 986 "%29": ")", 987 "%2A": "*", 988 "%2B": "+", 989 "%2C": ",", 990 "%3B": ";", 991 "%3D": "=", 992 "%40": "@" 993 } 994 }, 995 // These characters are the characters called out by RFC2141 as "reserved" characters that 996 // should never appear in a URN, plus the colon character (see note above). 997 decode: { 998 expression: /[\/\?#:]/g, 999 map: { 1000 "/": "%2F", 1001 "?": "%3F", 1002 "#": "%23", 1003 ":": "%3A" 1004 } 1005 } 1006 } 1007 }; 1008 URI.encodeQuery = function(string, escapeQuerySpace) { 1009 var escaped = URI.encode(string + ""); 1010 if (escapeQuerySpace === void 0) { 1011 escapeQuerySpace = URI.escapeQuerySpace; 1012 } 1013 return escapeQuerySpace ? escaped.replace(/%20/g, "+") : escaped; 1014 }; 1015 URI.decodeQuery = function(string, escapeQuerySpace) { 1016 string += ""; 1017 if (escapeQuerySpace === void 0) { 1018 escapeQuerySpace = URI.escapeQuerySpace; 1019 } 1020 try { 1021 return URI.decode(escapeQuerySpace ? string.replace(/\+/g, "%20") : string); 1022 } catch (e) { 1023 return string; 1024 } 1025 }; 1026 var _parts = { "encode": "encode", "decode": "decode" }; 1027 var _part; 1028 var generateAccessor = function(_group, _part2) { 1029 return function(string) { 1030 try { 1031 return URI[_part2](string + "").replace(URI.characters[_group][_part2].expression, function(c) { 1032 return URI.characters[_group][_part2].map[c]; 1033 }); 1034 } catch (e) { 1035 return string; 1036 } 1037 }; 1038 }; 1039 for (_part in _parts) { 1040 URI[_part + "PathSegment"] = generateAccessor("pathname", _parts[_part]); 1041 URI[_part + "UrnPathSegment"] = generateAccessor("urnpath", _parts[_part]); 1042 } 1043 var generateSegmentedPathFunction = function(_sep, _codingFuncName, _innerCodingFuncName) { 1044 return function(string) { 1045 var actualCodingFunc; 1046 if (!_innerCodingFuncName) { 1047 actualCodingFunc = URI[_codingFuncName]; 1048 } else { 1049 actualCodingFunc = function(string2) { 1050 return URI[_codingFuncName](URI[_innerCodingFuncName](string2)); 1051 }; 1052 } 1053 var segments = (string + "").split(_sep); 1054 for (var i = 0, length = segments.length; i < length; i++) { 1055 segments[i] = actualCodingFunc(segments[i]); 1056 } 1057 return segments.join(_sep); 1058 }; 1059 }; 1060 URI.decodePath = generateSegmentedPathFunction("/", "decodePathSegment"); 1061 URI.decodeUrnPath = generateSegmentedPathFunction(":", "decodeUrnPathSegment"); 1062 URI.recodePath = generateSegmentedPathFunction("/", "encodePathSegment", "decode"); 1063 URI.recodeUrnPath = generateSegmentedPathFunction(":", "encodeUrnPathSegment", "decode"); 1064 URI.encodeReserved = generateAccessor("reserved", "encode"); 1065 URI.parse = function(string, parts) { 1066 var pos; 1067 if (!parts) { 1068 parts = { 1069 preventInvalidHostname: URI.preventInvalidHostname 1070 }; 1071 } 1072 string = string.replace(URI.leading_whitespace_expression, ""); 1073 string = string.replace(URI.ascii_tab_whitespace, ""); 1074 pos = string.indexOf("#"); 1075 if (pos > -1) { 1076 parts.fragment = string.substring(pos + 1) || null; 1077 string = string.substring(0, pos); 1078 } 1079 pos = string.indexOf("?"); 1080 if (pos > -1) { 1081 parts.query = string.substring(pos + 1) || null; 1082 string = string.substring(0, pos); 1083 } 1084 string = string.replace(/^(https?|ftp|wss?)?:+[/\\]*/i, "$1://"); 1085 string = string.replace(/^[/\\]{2,}/i, "//"); 1086 if (string.substring(0, 2) === "//") { 1087 parts.protocol = null; 1088 string = string.substring(2); 1089 string = URI.parseAuthority(string, parts); 1090 } else { 1091 pos = string.indexOf(":"); 1092 if (pos > -1) { 1093 parts.protocol = string.substring(0, pos) || null; 1094 if (parts.protocol && !parts.protocol.match(URI.protocol_expression)) { 1095 parts.protocol = void 0; 1096 } else if (string.substring(pos + 1, pos + 3).replace(/\\/g, "/") === "//") { 1097 string = string.substring(pos + 3); 1098 string = URI.parseAuthority(string, parts); 1099 } else { 1100 string = string.substring(pos + 1); 1101 parts.urn = true; 1102 } 1103 } 1104 } 1105 parts.path = string; 1106 return parts; 1107 }; 1108 URI.parseHost = function(string, parts) { 1109 if (!string) { 1110 string = ""; 1111 } 1112 string = string.replace(/\\/g, "/"); 1113 var pos = string.indexOf("/"); 1114 var bracketPos; 1115 var t; 1116 if (pos === -1) { 1117 pos = string.length; 1118 } 1119 if (string.charAt(0) === "[") { 1120 bracketPos = string.indexOf("]"); 1121 parts.hostname = string.substring(1, bracketPos) || null; 1122 parts.port = string.substring(bracketPos + 2, pos) || null; 1123 if (parts.port === "/") { 1124 parts.port = null; 1125 } 1126 } else { 1127 var firstColon = string.indexOf(":"); 1128 var firstSlash = string.indexOf("/"); 1129 var nextColon = string.indexOf(":", firstColon + 1); 1130 if (nextColon !== -1 && (firstSlash === -1 || nextColon < firstSlash)) { 1131 parts.hostname = string.substring(0, pos) || null; 1132 parts.port = null; 1133 } else { 1134 t = string.substring(0, pos).split(":"); 1135 parts.hostname = t[0] || null; 1136 parts.port = t[1] || null; 1137 } 1138 } 1139 if (parts.hostname && string.substring(pos).charAt(0) !== "/") { 1140 pos++; 1141 string = "/" + string; 1142 } 1143 if (parts.preventInvalidHostname) { 1144 URI.ensureValidHostname(parts.hostname, parts.protocol); 1145 } 1146 if (parts.port) { 1147 URI.ensureValidPort(parts.port); 1148 } 1149 return string.substring(pos) || "/"; 1150 }; 1151 URI.parseAuthority = function(string, parts) { 1152 string = URI.parseUserinfo(string, parts); 1153 return URI.parseHost(string, parts); 1154 }; 1155 URI.parseUserinfo = function(string, parts) { 1156 var _string = string; 1157 var firstBackSlash = string.indexOf("\\"); 1158 if (firstBackSlash !== -1) { 1159 string = string.replace(/\\/g, "/"); 1160 } 1161 var firstSlash = string.indexOf("/"); 1162 var pos = string.lastIndexOf("@", firstSlash > -1 ? firstSlash : string.length - 1); 1163 var t; 1164 if (pos > -1 && (firstSlash === -1 || pos < firstSlash)) { 1165 t = string.substring(0, pos).split(":"); 1166 parts.username = t[0] ? URI.decode(t[0]) : null; 1167 t.shift(); 1168 parts.password = t[0] ? URI.decode(t.join(":")) : null; 1169 string = _string.substring(pos + 1); 1170 } else { 1171 parts.username = null; 1172 parts.password = null; 1173 } 1174 return string; 1175 }; 1176 URI.parseQuery = function(string, escapeQuerySpace) { 1177 if (!string) { 1178 return {}; 1179 } 1180 string = string.replace(/&+/g, "&").replace(/^\?*&*|&+$/g, ""); 1181 if (!string) { 1182 return {}; 1183 } 1184 var items = {}; 1185 var splits = string.split("&"); 1186 var length = splits.length; 1187 var v2, name, value; 1188 for (var i = 0; i < length; i++) { 1189 v2 = splits[i].split("="); 1190 name = URI.decodeQuery(v2.shift(), escapeQuerySpace); 1191 value = v2.length ? URI.decodeQuery(v2.join("="), escapeQuerySpace) : null; 1192 if (name === "__proto__") { 1193 continue; 1194 } else if (hasOwn.call(items, name)) { 1195 if (typeof items[name] === "string" || items[name] === null) { 1196 items[name] = [items[name]]; 1197 } 1198 items[name].push(value); 1199 } else { 1200 items[name] = value; 1201 } 1202 } 1203 return items; 1204 }; 1205 URI.build = function(parts) { 1206 var t = ""; 1207 var requireAbsolutePath = false; 1208 if (parts.protocol) { 1209 t += parts.protocol + ":"; 1210 } 1211 if (!parts.urn && (t || parts.hostname)) { 1212 t += "//"; 1213 requireAbsolutePath = true; 1214 } 1215 t += URI.buildAuthority(parts) || ""; 1216 if (typeof parts.path === "string") { 1217 if (parts.path.charAt(0) !== "/" && requireAbsolutePath) { 1218 t += "/"; 1219 } 1220 t += parts.path; 1221 } 1222 if (typeof parts.query === "string" && parts.query) { 1223 t += "?" + parts.query; 1224 } 1225 if (typeof parts.fragment === "string" && parts.fragment) { 1226 t += "#" + parts.fragment; 1227 } 1228 return t; 1229 }; 1230 URI.buildHost = function(parts) { 1231 var t = ""; 1232 if (!parts.hostname) { 1233 return ""; 1234 } else if (URI.ip6_expression.test(parts.hostname)) { 1235 t += "[" + parts.hostname + "]"; 1236 } else { 1237 t += parts.hostname; 1238 } 1239 if (parts.port) { 1240 t += ":" + parts.port; 1241 } 1242 return t; 1243 }; 1244 URI.buildAuthority = function(parts) { 1245 return URI.buildUserinfo(parts) + URI.buildHost(parts); 1246 }; 1247 URI.buildUserinfo = function(parts) { 1248 var t = ""; 1249 if (parts.username) { 1250 t += URI.encode(parts.username); 1251 } 1252 if (parts.password) { 1253 t += ":" + URI.encode(parts.password); 1254 } 1255 if (t) { 1256 t += "@"; 1257 } 1258 return t; 1259 }; 1260 URI.buildQuery = function(data, duplicateQueryParameters, escapeQuerySpace) { 1261 var t = ""; 1262 var unique, key, i, length; 1263 for (key in data) { 1264 if (key === "__proto__") { 1265 continue; 1266 } else if (hasOwn.call(data, key)) { 1267 if (isArray(data[key])) { 1268 unique = {}; 1269 for (i = 0, length = data[key].length; i < length; i++) { 1270 if (data[key][i] !== void 0 && unique[data[key][i] + ""] === void 0) { 1271 t += "&" + URI.buildQueryParameter(key, data[key][i], escapeQuerySpace); 1272 if (duplicateQueryParameters !== true) { 1273 unique[data[key][i] + ""] = true; 1274 } 1275 } 1276 } 1277 } else if (data[key] !== void 0) { 1278 t += "&" + URI.buildQueryParameter(key, data[key], escapeQuerySpace); 1279 } 1280 } 1281 } 1282 return t.substring(1); 1283 }; 1284 URI.buildQueryParameter = function(name, value, escapeQuerySpace) { 1285 return URI.encodeQuery(name, escapeQuerySpace) + (value !== null ? "=" + URI.encodeQuery(value, escapeQuerySpace) : ""); 1286 }; 1287 URI.addQuery = function(data, name, value) { 1288 if (typeof name === "object") { 1289 for (var key in name) { 1290 if (hasOwn.call(name, key)) { 1291 URI.addQuery(data, key, name[key]); 1292 } 1293 } 1294 } else if (typeof name === "string") { 1295 if (data[name] === void 0) { 1296 data[name] = value; 1297 return; 1298 } else if (typeof data[name] === "string") { 1299 data[name] = [data[name]]; 1300 } 1301 if (!isArray(value)) { 1302 value = [value]; 1303 } 1304 data[name] = (data[name] || []).concat(value); 1305 } else { 1306 throw new TypeError("URI.addQuery() accepts an object, string as the name parameter"); 1307 } 1308 }; 1309 URI.setQuery = function(data, name, value) { 1310 if (typeof name === "object") { 1311 for (var key in name) { 1312 if (hasOwn.call(name, key)) { 1313 URI.setQuery(data, key, name[key]); 1314 } 1315 } 1316 } else if (typeof name === "string") { 1317 data[name] = value === void 0 ? null : value; 1318 } else { 1319 throw new TypeError("URI.setQuery() accepts an object, string as the name parameter"); 1320 } 1321 }; 1322 URI.removeQuery = function(data, name, value) { 1323 var i, length, key; 1324 if (isArray(name)) { 1325 for (i = 0, length = name.length; i < length; i++) { 1326 data[name[i]] = void 0; 1327 } 1328 } else if (getType(name) === "RegExp") { 1329 for (key in data) { 1330 if (name.test(key)) { 1331 data[key] = void 0; 1332 } 1333 } 1334 } else if (typeof name === "object") { 1335 for (key in name) { 1336 if (hasOwn.call(name, key)) { 1337 URI.removeQuery(data, key, name[key]); 1338 } 1339 } 1340 } else if (typeof name === "string") { 1341 if (value !== void 0) { 1342 if (getType(value) === "RegExp") { 1343 if (!isArray(data[name]) && value.test(data[name])) { 1344 data[name] = void 0; 1345 } else { 1346 data[name] = filterArrayValues(data[name], value); 1347 } 1348 } else if (data[name] === String(value) && (!isArray(value) || value.length === 1)) { 1349 data[name] = void 0; 1350 } else if (isArray(data[name])) { 1351 data[name] = filterArrayValues(data[name], value); 1352 } 1353 } else { 1354 data[name] = void 0; 1355 } 1356 } else { 1357 throw new TypeError("URI.removeQuery() accepts an object, string, RegExp as the first parameter"); 1358 } 1359 }; 1360 URI.hasQuery = function(data, name, value, withinArray) { 1361 switch (getType(name)) { 1362 case "String": 1363 break; 1364 case "RegExp": 1365 for (var key in data) { 1366 if (hasOwn.call(data, key)) { 1367 if (name.test(key) && (value === void 0 || URI.hasQuery(data, key, value))) { 1368 return true; 1369 } 1370 } 1371 } 1372 return false; 1373 case "Object": 1374 for (var _key in name) { 1375 if (hasOwn.call(name, _key)) { 1376 if (!URI.hasQuery(data, _key, name[_key])) { 1377 return false; 1378 } 1379 } 1380 } 1381 return true; 1382 default: 1383 throw new TypeError("URI.hasQuery() accepts a string, regular expression or object as the name parameter"); 1384 } 1385 switch (getType(value)) { 1386 case "Undefined": 1387 return name in data; 1388 // data[name] !== undefined; 1389 case "Boolean": 1390 var _booly = Boolean(isArray(data[name]) ? data[name].length : data[name]); 1391 return value === _booly; 1392 case "Function": 1393 return !!value(data[name], name, data); 1394 case "Array": 1395 if (!isArray(data[name])) { 1396 return false; 1397 } 1398 var op = withinArray ? arrayContains : arraysEqual; 1399 return op(data[name], value); 1400 case "RegExp": 1401 if (!isArray(data[name])) { 1402 return Boolean(data[name] && data[name].match(value)); 1403 } 1404 if (!withinArray) { 1405 return false; 1406 } 1407 return arrayContains(data[name], value); 1408 case "Number": 1409 value = String(value); 1410 /* falls through */ 1411 case "String": 1412 if (!isArray(data[name])) { 1413 return data[name] === value; 1414 } 1415 if (!withinArray) { 1416 return false; 1417 } 1418 return arrayContains(data[name], value); 1419 default: 1420 throw new TypeError("URI.hasQuery() accepts undefined, boolean, string, number, RegExp, Function as the value parameter"); 1421 } 1422 }; 1423 URI.joinPaths = function() { 1424 var input = []; 1425 var segments = []; 1426 var nonEmptySegments = 0; 1427 for (var i = 0; i < arguments.length; i++) { 1428 var url = new URI(arguments[i]); 1429 input.push(url); 1430 var _segments = url.segment(); 1431 for (var s = 0; s < _segments.length; s++) { 1432 if (typeof _segments[s] === "string") { 1433 segments.push(_segments[s]); 1434 } 1435 if (_segments[s]) { 1436 nonEmptySegments++; 1437 } 1438 } 1439 } 1440 if (!segments.length || !nonEmptySegments) { 1441 return new URI(""); 1442 } 1443 var uri = new URI("").segment(segments); 1444 if (input[0].path() === "" || input[0].path().slice(0, 1) === "/") { 1445 uri.path("/" + uri.path()); 1446 } 1447 return uri.normalize(); 1448 }; 1449 URI.commonPath = function(one, two) { 1450 var length = Math.min(one.length, two.length); 1451 var pos; 1452 for (pos = 0; pos < length; pos++) { 1453 if (one.charAt(pos) !== two.charAt(pos)) { 1454 pos--; 1455 break; 1456 } 1457 } 1458 if (pos < 1) { 1459 return one.charAt(0) === two.charAt(0) && one.charAt(0) === "/" ? "/" : ""; 1460 } 1461 if (one.charAt(pos) !== "/" || two.charAt(pos) !== "/") { 1462 pos = one.substring(0, pos).lastIndexOf("/"); 1463 } 1464 return one.substring(0, pos + 1); 1465 }; 1466 URI.withinString = function(string, callback, options) { 1467 options || (options = {}); 1468 var _start = options.start || URI.findUri.start; 1469 var _end = options.end || URI.findUri.end; 1470 var _trim = options.trim || URI.findUri.trim; 1471 var _parens = options.parens || URI.findUri.parens; 1472 var _attributeOpen = /[a-z0-9-]=["']?$/i; 1473 _start.lastIndex = 0; 1474 while (true) { 1475 var match = _start.exec(string); 1476 if (!match) { 1477 break; 1478 } 1479 var start = match.index; 1480 if (options.ignoreHtml) { 1481 var attributeOpen = string.slice(Math.max(start - 3, 0), start); 1482 if (attributeOpen && _attributeOpen.test(attributeOpen)) { 1483 continue; 1484 } 1485 } 1486 var end = start + string.slice(start).search(_end); 1487 var slice = string.slice(start, end); 1488 var parensEnd = -1; 1489 while (true) { 1490 var parensMatch = _parens.exec(slice); 1491 if (!parensMatch) { 1492 break; 1493 } 1494 var parensMatchEnd = parensMatch.index + parensMatch[0].length; 1495 parensEnd = Math.max(parensEnd, parensMatchEnd); 1496 } 1497 if (parensEnd > -1) { 1498 slice = slice.slice(0, parensEnd) + slice.slice(parensEnd).replace(_trim, ""); 1499 } else { 1500 slice = slice.replace(_trim, ""); 1501 } 1502 if (slice.length <= match[0].length) { 1503 continue; 1504 } 1505 if (options.ignore && options.ignore.test(slice)) { 1506 continue; 1507 } 1508 end = start + slice.length; 1509 var result = callback(slice, start, end, string); 1510 if (result === void 0) { 1511 _start.lastIndex = end; 1512 continue; 1513 } 1514 result = String(result); 1515 string = string.slice(0, start) + result + string.slice(end); 1516 _start.lastIndex = start + result.length; 1517 } 1518 _start.lastIndex = 0; 1519 return string; 1520 }; 1521 URI.ensureValidHostname = function(v2, protocol) { 1522 var hasHostname = !!v2; 1523 var hasProtocol = !!protocol; 1524 var rejectEmptyHostname = false; 1525 if (hasProtocol) { 1526 rejectEmptyHostname = arrayContains(URI.hostProtocols, protocol); 1527 } 1528 if (rejectEmptyHostname && !hasHostname) { 1529 throw new TypeError("Hostname cannot be empty, if protocol is " + protocol); 1530 } else if (v2 && v2.match(URI.invalid_hostname_characters)) { 1531 if (!punycode) { 1532 throw new TypeError('Hostname "' + v2 + '" contains characters other than [A-Z0-9.-:_] and Punycode.js is not available'); 1533 } 1534 if (punycode.toASCII(v2).match(URI.invalid_hostname_characters)) { 1535 throw new TypeError('Hostname "' + v2 + '" contains characters other than [A-Z0-9.-:_]'); 1536 } 1537 } 1538 }; 1539 URI.ensureValidPort = function(v2) { 1540 if (!v2) { 1541 return; 1542 } 1543 var port = Number(v2); 1544 if (isInteger(port) && port > 0 && port < 65536) { 1545 return; 1546 } 1547 throw new TypeError('Port "' + v2 + '" is not a valid port'); 1548 }; 1549 URI.noConflict = function(removeAll) { 1550 if (removeAll) { 1551 var unconflicted = { 1552 URI: this.noConflict() 1553 }; 1554 if (root.URITemplate && typeof root.URITemplate.noConflict === "function") { 1555 unconflicted.URITemplate = root.URITemplate.noConflict(); 1556 } 1557 if (root.IPv6 && typeof root.IPv6.noConflict === "function") { 1558 unconflicted.IPv6 = root.IPv6.noConflict(); 1559 } 1560 if (root.SecondLevelDomains && typeof root.SecondLevelDomains.noConflict === "function") { 1561 unconflicted.SecondLevelDomains = root.SecondLevelDomains.noConflict(); 1562 } 1563 return unconflicted; 1564 } else if (root.URI === this) { 1565 root.URI = _URI; 1566 } 1567 return this; 1568 }; 1569 p.build = function(deferBuild) { 1570 if (deferBuild === true) { 1571 this._deferred_build = true; 1572 } else if (deferBuild === void 0 || this._deferred_build) { 1573 this._string = URI.build(this._parts); 1574 this._deferred_build = false; 1575 } 1576 return this; 1577 }; 1578 p.clone = function() { 1579 return new URI(this); 1580 }; 1581 p.valueOf = p.toString = function() { 1582 return this.build(false)._string; 1583 }; 1584 function generateSimpleAccessor(_part2) { 1585 return function(v2, build) { 1586 if (v2 === void 0) { 1587 return this._parts[_part2] || ""; 1588 } else { 1589 this._parts[_part2] = v2 || null; 1590 this.build(!build); 1591 return this; 1592 } 1593 }; 1594 } 1595 function generatePrefixAccessor(_part2, _key) { 1596 return function(v2, build) { 1597 if (v2 === void 0) { 1598 return this._parts[_part2] || ""; 1599 } else { 1600 if (v2 !== null) { 1601 v2 = v2 + ""; 1602 if (v2.charAt(0) === _key) { 1603 v2 = v2.substring(1); 1604 } 1605 } 1606 this._parts[_part2] = v2; 1607 this.build(!build); 1608 return this; 1609 } 1610 }; 1611 } 1612 p.protocol = generateSimpleAccessor("protocol"); 1613 p.username = generateSimpleAccessor("username"); 1614 p.password = generateSimpleAccessor("password"); 1615 p.hostname = generateSimpleAccessor("hostname"); 1616 p.port = generateSimpleAccessor("port"); 1617 p.query = generatePrefixAccessor("query", "?"); 1618 p.fragment = generatePrefixAccessor("fragment", "#"); 1619 p.search = function(v2, build) { 1620 var t = this.query(v2, build); 1621 return typeof t === "string" && t.length ? "?" + t : t; 1622 }; 1623 p.hash = function(v2, build) { 1624 var t = this.fragment(v2, build); 1625 return typeof t === "string" && t.length ? "#" + t : t; 1626 }; 1627 p.pathname = function(v2, build) { 1628 if (v2 === void 0 || v2 === true) { 1629 var res = this._parts.path || (this._parts.hostname ? "/" : ""); 1630 return v2 ? (this._parts.urn ? URI.decodeUrnPath : URI.decodePath)(res) : res; 1631 } else { 1632 if (this._parts.urn) { 1633 this._parts.path = v2 ? URI.recodeUrnPath(v2) : ""; 1634 } else { 1635 this._parts.path = v2 ? URI.recodePath(v2) : "/"; 1636 } 1637 this.build(!build); 1638 return this; 1639 } 1640 }; 1641 p.path = p.pathname; 1642 p.href = function(href, build) { 1643 var key; 1644 if (href === void 0) { 1645 return this.toString(); 1646 } 1647 this._string = ""; 1648 this._parts = URI._parts(); 1649 var _URI2 = href instanceof URI; 1650 var _object = typeof href === "object" && (href.hostname || href.path || href.pathname); 1651 if (href.nodeName) { 1652 var attribute = URI.getDomAttribute(href); 1653 href = href[attribute] || ""; 1654 _object = false; 1655 } 1656 if (!_URI2 && _object && href.pathname !== void 0) { 1657 href = href.toString(); 1658 } 1659 if (typeof href === "string" || href instanceof String) { 1660 this._parts = URI.parse(String(href), this._parts); 1661 } else if (_URI2 || _object) { 1662 var src = _URI2 ? href._parts : href; 1663 for (key in src) { 1664 if (key === "query") { 1665 continue; 1666 } 1667 if (hasOwn.call(this._parts, key)) { 1668 this._parts[key] = src[key]; 1669 } 1670 } 1671 if (src.query) { 1672 this.query(src.query, false); 1673 } 1674 } else { 1675 throw new TypeError("invalid input"); 1676 } 1677 this.build(!build); 1678 return this; 1679 }; 1680 p.is = function(what) { 1681 var ip = false; 1682 var ip4 = false; 1683 var ip6 = false; 1684 var name = false; 1685 var sld = false; 1686 var idn = false; 1687 var punycode2 = false; 1688 var relative = !this._parts.urn; 1689 if (this._parts.hostname) { 1690 relative = false; 1691 ip4 = URI.ip4_expression.test(this._parts.hostname); 1692 ip6 = URI.ip6_expression.test(this._parts.hostname); 1693 ip = ip4 || ip6; 1694 name = !ip; 1695 sld = name && SLD && SLD.has(this._parts.hostname); 1696 idn = name && URI.idn_expression.test(this._parts.hostname); 1697 punycode2 = name && URI.punycode_expression.test(this._parts.hostname); 1698 } 1699 switch (what.toLowerCase()) { 1700 case "relative": 1701 return relative; 1702 case "absolute": 1703 return !relative; 1704 // hostname identification 1705 case "domain": 1706 case "name": 1707 return name; 1708 case "sld": 1709 return sld; 1710 case "ip": 1711 return ip; 1712 case "ip4": 1713 case "ipv4": 1714 case "inet4": 1715 return ip4; 1716 case "ip6": 1717 case "ipv6": 1718 case "inet6": 1719 return ip6; 1720 case "idn": 1721 return idn; 1722 case "url": 1723 return !this._parts.urn; 1724 case "urn": 1725 return !!this._parts.urn; 1726 case "punycode": 1727 return punycode2; 1728 } 1729 return null; 1730 }; 1731 var _protocol = p.protocol; 1732 var _port = p.port; 1733 var _hostname = p.hostname; 1734 p.protocol = function(v2, build) { 1735 if (v2) { 1736 v2 = v2.replace(/:(\/\/)?$/, ""); 1737 if (!v2.match(URI.protocol_expression)) { 1738 throw new TypeError('Protocol "' + v2 + `" contains characters other than [A-Z0-9.+-] or doesn't start with [A-Z]`); 1739 } 1740 } 1741 return _protocol.call(this, v2, build); 1742 }; 1743 p.scheme = p.protocol; 1744 p.port = function(v2, build) { 1745 if (this._parts.urn) { 1746 return v2 === void 0 ? "" : this; 1747 } 1748 if (v2 !== void 0) { 1749 if (v2 === 0) { 1750 v2 = null; 1751 } 1752 if (v2) { 1753 v2 += ""; 1754 if (v2.charAt(0) === ":") { 1755 v2 = v2.substring(1); 1756 } 1757 URI.ensureValidPort(v2); 1758 } 1759 } 1760 return _port.call(this, v2, build); 1761 }; 1762 p.hostname = function(v2, build) { 1763 if (this._parts.urn) { 1764 return v2 === void 0 ? "" : this; 1765 } 1766 if (v2 !== void 0) { 1767 var x = { preventInvalidHostname: this._parts.preventInvalidHostname }; 1768 var res = URI.parseHost(v2, x); 1769 if (res !== "/") { 1770 throw new TypeError('Hostname "' + v2 + '" contains characters other than [A-Z0-9.-]'); 1771 } 1772 v2 = x.hostname; 1773 if (this._parts.preventInvalidHostname) { 1774 URI.ensureValidHostname(v2, this._parts.protocol); 1775 } 1776 } 1777 return _hostname.call(this, v2, build); 1778 }; 1779 p.origin = function(v2, build) { 1780 if (this._parts.urn) { 1781 return v2 === void 0 ? "" : this; 1782 } 1783 if (v2 === void 0) { 1784 var protocol = this.protocol(); 1785 var authority = this.authority(); 1786 if (!authority) { 1787 return ""; 1788 } 1789 return (protocol ? protocol + "://" : "") + this.authority(); 1790 } else { 1791 var origin = URI(v2); 1792 this.protocol(origin.protocol()).authority(origin.authority()).build(!build); 1793 return this; 1794 } 1795 }; 1796 p.host = function(v2, build) { 1797 if (this._parts.urn) { 1798 return v2 === void 0 ? "" : this; 1799 } 1800 if (v2 === void 0) { 1801 return this._parts.hostname ? URI.buildHost(this._parts) : ""; 1802 } else { 1803 var res = URI.parseHost(v2, this._parts); 1804 if (res !== "/") { 1805 throw new TypeError('Hostname "' + v2 + '" contains characters other than [A-Z0-9.-]'); 1806 } 1807 this.build(!build); 1808 return this; 1809 } 1810 }; 1811 p.authority = function(v2, build) { 1812 if (this._parts.urn) { 1813 return v2 === void 0 ? "" : this; 1814 } 1815 if (v2 === void 0) { 1816 return this._parts.hostname ? URI.buildAuthority(this._parts) : ""; 1817 } else { 1818 var res = URI.parseAuthority(v2, this._parts); 1819 if (res !== "/") { 1820 throw new TypeError('Hostname "' + v2 + '" contains characters other than [A-Z0-9.-]'); 1821 } 1822 this.build(!build); 1823 return this; 1824 } 1825 }; 1826 p.userinfo = function(v2, build) { 1827 if (this._parts.urn) { 1828 return v2 === void 0 ? "" : this; 1829 } 1830 if (v2 === void 0) { 1831 var t = URI.buildUserinfo(this._parts); 1832 return t ? t.substring(0, t.length - 1) : t; 1833 } else { 1834 if (v2[v2.length - 1] !== "@") { 1835 v2 += "@"; 1836 } 1837 URI.parseUserinfo(v2, this._parts); 1838 this.build(!build); 1839 return this; 1840 } 1841 }; 1842 p.resource = function(v2, build) { 1843 var parts; 1844 if (v2 === void 0) { 1845 return this.path() + this.search() + this.hash(); 1846 } 1847 parts = URI.parse(v2); 1848 this._parts.path = parts.path; 1849 this._parts.query = parts.query; 1850 this._parts.fragment = parts.fragment; 1851 this.build(!build); 1852 return this; 1853 }; 1854 p.subdomain = function(v2, build) { 1855 if (this._parts.urn) { 1856 return v2 === void 0 ? "" : this; 1857 } 1858 if (v2 === void 0) { 1859 if (!this._parts.hostname || this.is("IP")) { 1860 return ""; 1861 } 1862 var end = this._parts.hostname.length - this.domain().length - 1; 1863 return this._parts.hostname.substring(0, end) || ""; 1864 } else { 1865 var e = this._parts.hostname.length - this.domain().length; 1866 var sub = this._parts.hostname.substring(0, e); 1867 var replace = new RegExp("^" + escapeRegEx(sub)); 1868 if (v2 && v2.charAt(v2.length - 1) !== ".") { 1869 v2 += "."; 1870 } 1871 if (v2.indexOf(":") !== -1) { 1872 throw new TypeError("Domains cannot contain colons"); 1873 } 1874 if (v2) { 1875 URI.ensureValidHostname(v2, this._parts.protocol); 1876 } 1877 this._parts.hostname = this._parts.hostname.replace(replace, v2); 1878 this.build(!build); 1879 return this; 1880 } 1881 }; 1882 p.domain = function(v2, build) { 1883 if (this._parts.urn) { 1884 return v2 === void 0 ? "" : this; 1885 } 1886 if (typeof v2 === "boolean") { 1887 build = v2; 1888 v2 = void 0; 1889 } 1890 if (v2 === void 0) { 1891 if (!this._parts.hostname || this.is("IP")) { 1892 return ""; 1893 } 1894 var t = this._parts.hostname.match(/\./g); 1895 if (t && t.length < 2) { 1896 return this._parts.hostname; 1897 } 1898 var end = this._parts.hostname.length - this.tld(build).length - 1; 1899 end = this._parts.hostname.lastIndexOf(".", end - 1) + 1; 1900 return this._parts.hostname.substring(end) || ""; 1901 } else { 1902 if (!v2) { 1903 throw new TypeError("cannot set domain empty"); 1904 } 1905 if (v2.indexOf(":") !== -1) { 1906 throw new TypeError("Domains cannot contain colons"); 1907 } 1908 URI.ensureValidHostname(v2, this._parts.protocol); 1909 if (!this._parts.hostname || this.is("IP")) { 1910 this._parts.hostname = v2; 1911 } else { 1912 var replace = new RegExp(escapeRegEx(this.domain()) + "$"); 1913 this._parts.hostname = this._parts.hostname.replace(replace, v2); 1914 } 1915 this.build(!build); 1916 return this; 1917 } 1918 }; 1919 p.tld = function(v2, build) { 1920 if (this._parts.urn) { 1921 return v2 === void 0 ? "" : this; 1922 } 1923 if (typeof v2 === "boolean") { 1924 build = v2; 1925 v2 = void 0; 1926 } 1927 if (v2 === void 0) { 1928 if (!this._parts.hostname || this.is("IP")) { 1929 return ""; 1930 } 1931 var pos = this._parts.hostname.lastIndexOf("."); 1932 var tld = this._parts.hostname.substring(pos + 1); 1933 if (build !== true && SLD && SLD.list[tld.toLowerCase()]) { 1934 return SLD.get(this._parts.hostname) || tld; 1935 } 1936 return tld; 1937 } else { 1938 var replace; 1939 if (!v2) { 1940 throw new TypeError("cannot set TLD empty"); 1941 } else if (v2.match(/[^a-zA-Z0-9-]/)) { 1942 if (SLD && SLD.is(v2)) { 1943 replace = new RegExp(escapeRegEx(this.tld()) + "$"); 1944 this._parts.hostname = this._parts.hostname.replace(replace, v2); 1945 } else { 1946 throw new TypeError('TLD "' + v2 + '" contains characters other than [A-Z0-9]'); 1947 } 1948 } else if (!this._parts.hostname || this.is("IP")) { 1949 throw new ReferenceError("cannot set TLD on non-domain host"); 1950 } else { 1951 replace = new RegExp(escapeRegEx(this.tld()) + "$"); 1952 this._parts.hostname = this._parts.hostname.replace(replace, v2); 1953 } 1954 this.build(!build); 1955 return this; 1956 } 1957 }; 1958 p.directory = function(v2, build) { 1959 if (this._parts.urn) { 1960 return v2 === void 0 ? "" : this; 1961 } 1962 if (v2 === void 0 || v2 === true) { 1963 if (!this._parts.path && !this._parts.hostname) { 1964 return ""; 1965 } 1966 if (this._parts.path === "/") { 1967 return "/"; 1968 } 1969 var end = this._parts.path.length - this.filename().length - 1; 1970 var res = this._parts.path.substring(0, end) || (this._parts.hostname ? "/" : ""); 1971 return v2 ? URI.decodePath(res) : res; 1972 } else { 1973 var e = this._parts.path.length - this.filename().length; 1974 var directory = this._parts.path.substring(0, e); 1975 var replace = new RegExp("^" + escapeRegEx(directory)); 1976 if (!this.is("relative")) { 1977 if (!v2) { 1978 v2 = "/"; 1979 } 1980 if (v2.charAt(0) !== "/") { 1981 v2 = "/" + v2; 1982 } 1983 } 1984 if (v2 && v2.charAt(v2.length - 1) !== "/") { 1985 v2 += "/"; 1986 } 1987 v2 = URI.recodePath(v2); 1988 this._parts.path = this._parts.path.replace(replace, v2); 1989 this.build(!build); 1990 return this; 1991 } 1992 }; 1993 p.filename = function(v2, build) { 1994 if (this._parts.urn) { 1995 return v2 === void 0 ? "" : this; 1996 } 1997 if (typeof v2 !== "string") { 1998 if (!this._parts.path || this._parts.path === "/") { 1999 return ""; 2000 } 2001 var pos = this._parts.path.lastIndexOf("/"); 2002 var res = this._parts.path.substring(pos + 1); 2003 return v2 ? URI.decodePathSegment(res) : res; 2004 } else { 2005 var mutatedDirectory = false; 2006 if (v2.charAt(0) === "/") { 2007 v2 = v2.substring(1); 2008 } 2009 if (v2.match(/\.?\//)) { 2010 mutatedDirectory = true; 2011 } 2012 var replace = new RegExp(escapeRegEx(this.filename()) + "$"); 2013 v2 = URI.recodePath(v2); 2014 this._parts.path = this._parts.path.replace(replace, v2); 2015 if (mutatedDirectory) { 2016 this.normalizePath(build); 2017 } else { 2018 this.build(!build); 2019 } 2020 return this; 2021 } 2022 }; 2023 p.suffix = function(v2, build) { 2024 if (this._parts.urn) { 2025 return v2 === void 0 ? "" : this; 2026 } 2027 if (v2 === void 0 || v2 === true) { 2028 if (!this._parts.path || this._parts.path === "/") { 2029 return ""; 2030 } 2031 var filename = this.filename(); 2032 var pos = filename.lastIndexOf("."); 2033 var s, res; 2034 if (pos === -1) { 2035 return ""; 2036 } 2037 s = filename.substring(pos + 1); 2038 res = /^[a-z0-9%]+$/i.test(s) ? s : ""; 2039 return v2 ? URI.decodePathSegment(res) : res; 2040 } else { 2041 if (v2.charAt(0) === ".") { 2042 v2 = v2.substring(1); 2043 } 2044 var suffix = this.suffix(); 2045 var replace; 2046 if (!suffix) { 2047 if (!v2) { 2048 return this; 2049 } 2050 this._parts.path += "." + URI.recodePath(v2); 2051 } else if (!v2) { 2052 replace = new RegExp(escapeRegEx("." + suffix) + "$"); 2053 } else { 2054 replace = new RegExp(escapeRegEx(suffix) + "$"); 2055 } 2056 if (replace) { 2057 v2 = URI.recodePath(v2); 2058 this._parts.path = this._parts.path.replace(replace, v2); 2059 } 2060 this.build(!build); 2061 return this; 2062 } 2063 }; 2064 p.segment = function(segment, v2, build) { 2065 var separator = this._parts.urn ? ":" : "/"; 2066 var path = this.path(); 2067 var absolute = path.substring(0, 1) === "/"; 2068 var segments = path.split(separator); 2069 if (segment !== void 0 && typeof segment !== "number") { 2070 build = v2; 2071 v2 = segment; 2072 segment = void 0; 2073 } 2074 if (segment !== void 0 && typeof segment !== "number") { 2075 throw new Error('Bad segment "' + segment + '", must be 0-based integer'); 2076 } 2077 if (absolute) { 2078 segments.shift(); 2079 } 2080 if (segment < 0) { 2081 segment = Math.max(segments.length + segment, 0); 2082 } 2083 if (v2 === void 0) { 2084 return segment === void 0 ? segments : segments[segment]; 2085 } else if (segment === null || segments[segment] === void 0) { 2086 if (isArray(v2)) { 2087 segments = []; 2088 for (var i = 0, l = v2.length; i < l; i++) { 2089 if (!v2[i].length && (!segments.length || !segments[segments.length - 1].length)) { 2090 continue; 2091 } 2092 if (segments.length && !segments[segments.length - 1].length) { 2093 segments.pop(); 2094 } 2095 segments.push(trimSlashes(v2[i])); 2096 } 2097 } else if (v2 || typeof v2 === "string") { 2098 v2 = trimSlashes(v2); 2099 if (segments[segments.length - 1] === "") { 2100 segments[segments.length - 1] = v2; 2101 } else { 2102 segments.push(v2); 2103 } 2104 } 2105 } else { 2106 if (v2) { 2107 segments[segment] = trimSlashes(v2); 2108 } else { 2109 segments.splice(segment, 1); 2110 } 2111 } 2112 if (absolute) { 2113 segments.unshift(""); 2114 } 2115 return this.path(segments.join(separator), build); 2116 }; 2117 p.segmentCoded = function(segment, v2, build) { 2118 var segments, i, l; 2119 if (typeof segment !== "number") { 2120 build = v2; 2121 v2 = segment; 2122 segment = void 0; 2123 } 2124 if (v2 === void 0) { 2125 segments = this.segment(segment, v2, build); 2126 if (!isArray(segments)) { 2127 segments = segments !== void 0 ? URI.decode(segments) : void 0; 2128 } else { 2129 for (i = 0, l = segments.length; i < l; i++) { 2130 segments[i] = URI.decode(segments[i]); 2131 } 2132 } 2133 return segments; 2134 } 2135 if (!isArray(v2)) { 2136 v2 = typeof v2 === "string" || v2 instanceof String ? URI.encode(v2) : v2; 2137 } else { 2138 for (i = 0, l = v2.length; i < l; i++) { 2139 v2[i] = URI.encode(v2[i]); 2140 } 2141 } 2142 return this.segment(segment, v2, build); 2143 }; 2144 var q = p.query; 2145 p.query = function(v2, build) { 2146 if (v2 === true) { 2147 return URI.parseQuery(this._parts.query, this._parts.escapeQuerySpace); 2148 } else if (typeof v2 === "function") { 2149 var data = URI.parseQuery(this._parts.query, this._parts.escapeQuerySpace); 2150 var result = v2.call(this, data); 2151 this._parts.query = URI.buildQuery(result || data, this._parts.duplicateQueryParameters, this._parts.escapeQuerySpace); 2152 this.build(!build); 2153 return this; 2154 } else if (v2 !== void 0 && typeof v2 !== "string") { 2155 this._parts.query = URI.buildQuery(v2, this._parts.duplicateQueryParameters, this._parts.escapeQuerySpace); 2156 this.build(!build); 2157 return this; 2158 } else { 2159 return q.call(this, v2, build); 2160 } 2161 }; 2162 p.setQuery = function(name, value, build) { 2163 var data = URI.parseQuery(this._parts.query, this._parts.escapeQuerySpace); 2164 if (typeof name === "string" || name instanceof String) { 2165 data[name] = value !== void 0 ? value : null; 2166 } else if (typeof name === "object") { 2167 for (var key in name) { 2168 if (hasOwn.call(name, key)) { 2169 data[key] = name[key]; 2170 } 2171 } 2172 } else { 2173 throw new TypeError("URI.addQuery() accepts an object, string as the name parameter"); 2174 } 2175 this._parts.query = URI.buildQuery(data, this._parts.duplicateQueryParameters, this._parts.escapeQuerySpace); 2176 if (typeof name !== "string") { 2177 build = value; 2178 } 2179 this.build(!build); 2180 return this; 2181 }; 2182 p.addQuery = function(name, value, build) { 2183 var data = URI.parseQuery(this._parts.query, this._parts.escapeQuerySpace); 2184 URI.addQuery(data, name, value === void 0 ? null : value); 2185 this._parts.query = URI.buildQuery(data, this._parts.duplicateQueryParameters, this._parts.escapeQuerySpace); 2186 if (typeof name !== "string") { 2187 build = value; 2188 } 2189 this.build(!build); 2190 return this; 2191 }; 2192 p.removeQuery = function(name, value, build) { 2193 var data = URI.parseQuery(this._parts.query, this._parts.escapeQuerySpace); 2194 URI.removeQuery(data, name, value); 2195 this._parts.query = URI.buildQuery(data, this._parts.duplicateQueryParameters, this._parts.escapeQuerySpace); 2196 if (typeof name !== "string") { 2197 build = value; 2198 } 2199 this.build(!build); 2200 return this; 2201 }; 2202 p.hasQuery = function(name, value, withinArray) { 2203 var data = URI.parseQuery(this._parts.query, this._parts.escapeQuerySpace); 2204 return URI.hasQuery(data, name, value, withinArray); 2205 }; 2206 p.setSearch = p.setQuery; 2207 p.addSearch = p.addQuery; 2208 p.removeSearch = p.removeQuery; 2209 p.hasSearch = p.hasQuery; 2210 p.normalize = function() { 2211 if (this._parts.urn) { 2212 return this.normalizeProtocol(false).normalizePath(false).normalizeQuery(false).normalizeFragment(false).build(); 2213 } 2214 return this.normalizeProtocol(false).normalizeHostname(false).normalizePort(false).normalizePath(false).normalizeQuery(false).normalizeFragment(false).build(); 2215 }; 2216 p.normalizeProtocol = function(build) { 2217 if (typeof this._parts.protocol === "string") { 2218 this._parts.protocol = this._parts.protocol.toLowerCase(); 2219 this.build(!build); 2220 } 2221 return this; 2222 }; 2223 p.normalizeHostname = function(build) { 2224 if (this._parts.hostname) { 2225 if (this.is("IDN") && punycode) { 2226 this._parts.hostname = punycode.toASCII(this._parts.hostname); 2227 } else if (this.is("IPv6") && IPv6) { 2228 this._parts.hostname = IPv6.best(this._parts.hostname); 2229 } 2230 this._parts.hostname = this._parts.hostname.toLowerCase(); 2231 this.build(!build); 2232 } 2233 return this; 2234 }; 2235 p.normalizePort = function(build) { 2236 if (typeof this._parts.protocol === "string" && this._parts.port === URI.defaultPorts[this._parts.protocol]) { 2237 this._parts.port = null; 2238 this.build(!build); 2239 } 2240 return this; 2241 }; 2242 p.normalizePath = function(build) { 2243 var _path = this._parts.path; 2244 if (!_path) { 2245 return this; 2246 } 2247 if (this._parts.urn) { 2248 this._parts.path = URI.recodeUrnPath(this._parts.path); 2249 this.build(!build); 2250 return this; 2251 } 2252 if (this._parts.path === "/") { 2253 return this; 2254 } 2255 _path = URI.recodePath(_path); 2256 var _was_relative; 2257 var _leadingParents = ""; 2258 var _parent, _pos; 2259 if (_path.charAt(0) !== "/") { 2260 _was_relative = true; 2261 _path = "/" + _path; 2262 } 2263 if (_path.slice(-3) === "/.." || _path.slice(-2) === "/.") { 2264 _path += "/"; 2265 } 2266 _path = _path.replace(/(\/(\.\/)+)|(\/\.$)/g, "/").replace(/\/{2,}/g, "/"); 2267 if (_was_relative) { 2268 _leadingParents = _path.substring(1).match(/^(\.\.\/)+/) || ""; 2269 if (_leadingParents) { 2270 _leadingParents = _leadingParents[0]; 2271 } 2272 } 2273 while (true) { 2274 _parent = _path.search(/\/\.\.(\/|$)/); 2275 if (_parent === -1) { 2276 break; 2277 } else if (_parent === 0) { 2278 _path = _path.substring(3); 2279 continue; 2280 } 2281 _pos = _path.substring(0, _parent).lastIndexOf("/"); 2282 if (_pos === -1) { 2283 _pos = _parent; 2284 } 2285 _path = _path.substring(0, _pos) + _path.substring(_parent + 3); 2286 } 2287 if (_was_relative && this.is("relative")) { 2288 _path = _leadingParents + _path.substring(1); 2289 } 2290 this._parts.path = _path; 2291 this.build(!build); 2292 return this; 2293 }; 2294 p.normalizePathname = p.normalizePath; 2295 p.normalizeQuery = function(build) { 2296 if (typeof this._parts.query === "string") { 2297 if (!this._parts.query.length) { 2298 this._parts.query = null; 2299 } else { 2300 this.query(URI.parseQuery(this._parts.query, this._parts.escapeQuerySpace)); 2301 } 2302 this.build(!build); 2303 } 2304 return this; 2305 }; 2306 p.normalizeFragment = function(build) { 2307 if (!this._parts.fragment) { 2308 this._parts.fragment = null; 2309 this.build(!build); 2310 } 2311 return this; 2312 }; 2313 p.normalizeSearch = p.normalizeQuery; 2314 p.normalizeHash = p.normalizeFragment; 2315 p.iso8859 = function() { 2316 var e = URI.encode; 2317 var d = URI.decode; 2318 URI.encode = escape; 2319 URI.decode = decodeURIComponent; 2320 try { 2321 this.normalize(); 2322 } finally { 2323 URI.encode = e; 2324 URI.decode = d; 2325 } 2326 return this; 2327 }; 2328 p.unicode = function() { 2329 var e = URI.encode; 2330 var d = URI.decode; 2331 URI.encode = strictEncodeURIComponent; 2332 URI.decode = unescape; 2333 try { 2334 this.normalize(); 2335 } finally { 2336 URI.encode = e; 2337 URI.decode = d; 2338 } 2339 return this; 2340 }; 2341 p.readable = function() { 2342 var uri = this.clone(); 2343 uri.username("").password("").normalize(); 2344 var t = ""; 2345 if (uri._parts.protocol) { 2346 t += uri._parts.protocol + "://"; 2347 } 2348 if (uri._parts.hostname) { 2349 if (uri.is("punycode") && punycode) { 2350 t += punycode.toUnicode(uri._parts.hostname); 2351 if (uri._parts.port) { 2352 t += ":" + uri._parts.port; 2353 } 2354 } else { 2355 t += uri.host(); 2356 } 2357 } 2358 if (uri._parts.hostname && uri._parts.path && uri._parts.path.charAt(0) !== "/") { 2359 t += "/"; 2360 } 2361 t += uri.path(true); 2362 if (uri._parts.query) { 2363 var q2 = ""; 2364 for (var i = 0, qp = uri._parts.query.split("&"), l = qp.length; i < l; i++) { 2365 var kv = (qp[i] || "").split("="); 2366 q2 += "&" + URI.decodeQuery(kv[0], this._parts.escapeQuerySpace).replace(/&/g, "%26"); 2367 if (kv[1] !== void 0) { 2368 q2 += "=" + URI.decodeQuery(kv[1], this._parts.escapeQuerySpace).replace(/&/g, "%26"); 2369 } 2370 } 2371 t += "?" + q2.substring(1); 2372 } 2373 t += URI.decodeQuery(uri.hash(), true); 2374 return t; 2375 }; 2376 p.absoluteTo = function(base) { 2377 var resolved = this.clone(); 2378 var properties = ["protocol", "username", "password", "hostname", "port"]; 2379 var basedir, i, p2; 2380 if (this._parts.urn) { 2381 throw new Error("URNs do not have any generally defined hierarchical components"); 2382 } 2383 if (!(base instanceof URI)) { 2384 base = new URI(base); 2385 } 2386 if (resolved._parts.protocol) { 2387 return resolved; 2388 } else { 2389 resolved._parts.protocol = base._parts.protocol; 2390 } 2391 if (this._parts.hostname) { 2392 return resolved; 2393 } 2394 for (i = 0; p2 = properties[i]; i++) { 2395 resolved._parts[p2] = base._parts[p2]; 2396 } 2397 if (!resolved._parts.path) { 2398 resolved._parts.path = base._parts.path; 2399 if (!resolved._parts.query) { 2400 resolved._parts.query = base._parts.query; 2401 } 2402 } else { 2403 if (resolved._parts.path.substring(-2) === "..") { 2404 resolved._parts.path += "/"; 2405 } 2406 if (resolved.path().charAt(0) !== "/") { 2407 basedir = base.directory(); 2408 basedir = basedir ? basedir : base.path().indexOf("/") === 0 ? "/" : ""; 2409 resolved._parts.path = (basedir ? basedir + "/" : "") + resolved._parts.path; 2410 resolved.normalizePath(); 2411 } 2412 } 2413 resolved.build(); 2414 return resolved; 2415 }; 2416 p.relativeTo = function(base) { 2417 var relative = this.clone().normalize(); 2418 var relativeParts, baseParts, common, relativePath, basePath; 2419 if (relative._parts.urn) { 2420 throw new Error("URNs do not have any generally defined hierarchical components"); 2421 } 2422 base = new URI(base).normalize(); 2423 relativeParts = relative._parts; 2424 baseParts = base._parts; 2425 relativePath = relative.path(); 2426 basePath = base.path(); 2427 if (relativePath.charAt(0) !== "/") { 2428 throw new Error("URI is already relative"); 2429 } 2430 if (basePath.charAt(0) !== "/") { 2431 throw new Error("Cannot calculate a URI relative to another relative URI"); 2432 } 2433 if (relativeParts.protocol === baseParts.protocol) { 2434 relativeParts.protocol = null; 2435 } 2436 if (relativeParts.username !== baseParts.username || relativeParts.password !== baseParts.password) { 2437 return relative.build(); 2438 } 2439 if (relativeParts.protocol !== null || relativeParts.username !== null || relativeParts.password !== null) { 2440 return relative.build(); 2441 } 2442 if (relativeParts.hostname === baseParts.hostname && relativeParts.port === baseParts.port) { 2443 relativeParts.hostname = null; 2444 relativeParts.port = null; 2445 } else { 2446 return relative.build(); 2447 } 2448 if (relativePath === basePath) { 2449 relativeParts.path = ""; 2450 return relative.build(); 2451 } 2452 common = URI.commonPath(relativePath, basePath); 2453 if (!common) { 2454 return relative.build(); 2455 } 2456 var parents = baseParts.path.substring(common.length).replace(/[^\/]*$/, "").replace(/.*?\//g, "../"); 2457 relativeParts.path = parents + relativeParts.path.substring(common.length) || "./"; 2458 return relative.build(); 2459 }; 2460 p.equals = function(uri) { 2461 var one = this.clone(); 2462 var two = new URI(uri); 2463 var one_map = {}; 2464 var two_map = {}; 2465 var checked = {}; 2466 var one_query, two_query, key; 2467 one.normalize(); 2468 two.normalize(); 2469 if (one.toString() === two.toString()) { 2470 return true; 2471 } 2472 one_query = one.query(); 2473 two_query = two.query(); 2474 one.query(""); 2475 two.query(""); 2476 if (one.toString() !== two.toString()) { 2477 return false; 2478 } 2479 if (one_query.length !== two_query.length) { 2480 return false; 2481 } 2482 one_map = URI.parseQuery(one_query, this._parts.escapeQuerySpace); 2483 two_map = URI.parseQuery(two_query, this._parts.escapeQuerySpace); 2484 for (key in one_map) { 2485 if (hasOwn.call(one_map, key)) { 2486 if (!isArray(one_map[key])) { 2487 if (one_map[key] !== two_map[key]) { 2488 return false; 2489 } 2490 } else if (!arraysEqual(one_map[key], two_map[key])) { 2491 return false; 2492 } 2493 checked[key] = true; 2494 } 2495 } 2496 for (key in two_map) { 2497 if (hasOwn.call(two_map, key)) { 2498 if (!checked[key]) { 2499 return false; 2500 } 2501 } 2502 } 2503 return true; 2504 }; 2505 p.preventInvalidHostname = function(v2) { 2506 this._parts.preventInvalidHostname = !!v2; 2507 return this; 2508 }; 2509 p.duplicateQueryParameters = function(v2) { 2510 this._parts.duplicateQueryParameters = !!v2; 2511 return this; 2512 }; 2513 p.escapeQuerySpace = function(v2) { 2514 this._parts.escapeQuerySpace = !!v2; 2515 return this; 2516 }; 2517 return URI; 2518 }); 2519 } 2520}); 2521 2522// packages/engine/Source/Core/combine.js 2523function combine(object1, object2, deep) { 2524 deep = deep ?? false; 2525 const result = {}; 2526 const object1Defined = defined_default(object1); 2527 const object2Defined = defined_default(object2); 2528 let property; 2529 let object1Value; 2530 let object2Value; 2531 if (object1Defined) { 2532 for (property in object1) { 2533 if (object1.hasOwnProperty(property)) { 2534 object1Value = object1[property]; 2535 if (object2Defined && deep && typeof object1Value === "object" && object2.hasOwnProperty(property)) { 2536 object2Value = object2[property]; 2537 if (typeof object2Value === "object") { 2538 result[property] = combine(object1Value, object2Value, deep); 2539 } else { 2540 result[property] = object1Value; 2541 } 2542 } else { 2543 result[property] = object1Value; 2544 } 2545 } 2546 } 2547 } 2548 if (object2Defined) { 2549 for (property in object2) { 2550 if (object2.hasOwnProperty(property) && !result.hasOwnProperty(property)) { 2551 object2Value = object2[property]; 2552 result[property] = object2Value; 2553 } 2554 } 2555 } 2556 return result; 2557} 2558var combine_default = combine; 2559 2560// packages/engine/Source/Core/binarySearch.js 2561function binarySearch(array, itemToFind, comparator) { 2562 Check_default.defined("array", array); 2563 Check_default.defined("itemToFind", itemToFind); 2564 Check_default.defined("comparator", comparator); 2565 let low = 0; 2566 let high = array.length - 1; 2567 let i; 2568 let comparison; 2569 while (low <= high) { 2570 i = ~~((low + high) / 2); 2571 comparison = comparator(array[i], itemToFind); 2572 if (comparison < 0) { 2573 low = i + 1; 2574 continue; 2575 } 2576 if (comparison > 0) { 2577 high = i - 1; 2578 continue; 2579 } 2580 return i; 2581 } 2582 return ~(high + 1); 2583} 2584var binarySearch_default = binarySearch; 2585 2586// packages/engine/Source/Core/EarthOrientationParametersSample.js 2587function EarthOrientationParametersSample(xPoleWander, yPoleWander, xPoleOffset, yPoleOffset, ut1MinusUtc) { 2588 this.xPoleWander = xPoleWander; 2589 this.yPoleWander = yPoleWander; 2590 this.xPoleOffset = xPoleOffset; 2591 this.yPoleOffset = yPoleOffset; 2592 this.ut1MinusUtc = ut1MinusUtc; 2593} 2594var EarthOrientationParametersSample_default = EarthOrientationParametersSample; 2595 2596// packages/engine/Source/Core/isLeapYear.js 2597function isLeapYear(year) { 2598 if (year === null || isNaN(year)) { 2599 throw new DeveloperError_default("year is required and must be a number."); 2600 } 2601 return year % 4 === 0 && year % 100 !== 0 || year % 400 === 0; 2602} 2603var isLeapYear_default = isLeapYear; 2604 2605// packages/engine/Source/Core/GregorianDate.js 2606var daysInYear = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; 2607function GregorianDate(year, month, day, hour, minute, second, millisecond, isLeapSecond) { 2608 const minimumYear = 1; 2609 const minimumMonth = 1; 2610 const minimumDay = 1; 2611 const minimumHour = 0; 2612 const minimumMinute = 0; 2613 const minimumSecond = 0; 2614 const minimumMillisecond = 0; 2615 year = year ?? minimumYear; 2616 month = month ?? minimumMonth; 2617 day = day ?? minimumDay; 2618 hour = hour ?? minimumHour; 2619 minute = minute ?? minimumMinute; 2620 second = second ?? minimumSecond; 2621 millisecond = millisecond ?? minimumMillisecond; 2622 isLeapSecond = isLeapSecond ?? false; 2623 validateRange(); 2624 validateDate(); 2625 this.year = year; 2626 this.month = month; 2627 this.day = day; 2628 this.hour = hour; 2629 this.minute = minute; 2630 this.second = second; 2631 this.millisecond = millisecond; 2632 this.isLeapSecond = isLeapSecond; 2633 function validateRange() { 2634 const maximumYear = 9999; 2635 const maximumMonth = 12; 2636 const maximumDay = 31; 2637 const maximumHour = 23; 2638 const maximumMinute = 59; 2639 const maximumSecond = 59; 2640 const excludedMaximumMilisecond = 1e3; 2641 Check_default.typeOf.number.greaterThanOrEquals("Year", year, minimumYear); 2642 Check_default.typeOf.number.lessThanOrEquals("Year", year, maximumYear); 2643 Check_default.typeOf.number.greaterThanOrEquals("Month", month, minimumMonth); 2644 Check_default.typeOf.number.lessThanOrEquals("Month", month, maximumMonth); 2645 Check_default.typeOf.number.greaterThanOrEquals("Day", day, minimumDay); 2646 Check_default.typeOf.number.lessThanOrEquals("Day", day, maximumDay); 2647 Check_default.typeOf.number.greaterThanOrEquals("Hour", hour, minimumHour); 2648 Check_default.typeOf.number.lessThanOrEquals("Hour", hour, maximumHour); 2649 Check_default.typeOf.number.greaterThanOrEquals("Minute", minute, minimumMinute); 2650 Check_default.typeOf.number.lessThanOrEquals("Minute", minute, maximumMinute); 2651 Check_default.typeOf.bool("IsLeapSecond", isLeapSecond); 2652 Check_default.typeOf.number.greaterThanOrEquals("Second", second, minimumSecond); 2653 Check_default.typeOf.number.lessThanOrEquals( 2654 "Second", 2655 second, 2656 isLeapSecond ? maximumSecond + 1 : maximumSecond 2657 ); 2658 Check_default.typeOf.number.greaterThanOrEquals( 2659 "Millisecond", 2660 millisecond, 2661 minimumMillisecond 2662 ); 2663 Check_default.typeOf.number.lessThan( 2664 "Millisecond", 2665 millisecond, 2666 excludedMaximumMilisecond 2667 ); 2668 } 2669 function validateDate() { 2670 const daysInMonth2 = month === 2 && isLeapYear_default(year) ? daysInYear[month - 1] + 1 : daysInYear[month - 1]; 2671 if (day > daysInMonth2) { 2672 throw new DeveloperError_default("Month and Day represents invalid date"); 2673 } 2674 } 2675} 2676var GregorianDate_default = GregorianDate; 2677 2678// packages/engine/Source/Core/LeapSecond.js 2679function LeapSecond(date, offset) { 2680 this.julianDate = date; 2681 this.offset = offset; 2682} 2683var LeapSecond_default = LeapSecond; 2684 2685// packages/engine/Source/Core/TimeConstants.js 2686var TimeConstants = { 2687 /** 2688 * The number of seconds in one millisecond: <code>0.001</code> 2689 * @type {number} 2690 * @constant 2691 */ 2692 SECONDS_PER_MILLISECOND: 1e-3, 2693 /** 2694 * The number of seconds in one minute: <code>60</code>. 2695 * @type {number} 2696 * @constant 2697 */ 2698 SECONDS_PER_MINUTE: 60, 2699 /** 2700 * The number of minutes in one hour: <code>60</code>. 2701 * @type {number} 2702 * @constant 2703 */ 2704 MINUTES_PER_HOUR: 60, 2705 /** 2706 * The number of hours in one day: <code>24</code>. 2707 * @type {number} 2708 * @constant 2709 */ 2710 HOURS_PER_DAY: 24, 2711 /** 2712 * The number of seconds in one hour: <code>3600</code>. 2713 * @type {number} 2714 * @constant 2715 */ 2716 SECONDS_PER_HOUR: 3600, 2717 /** 2718 * The number of minutes in one day: <code>1440</code>. 2719 * @type {number} 2720 * @constant 2721 */ 2722 MINUTES_PER_DAY: 1440, 2723 /** 2724 * The number of seconds in one day, ignoring leap seconds: <code>86400</code>. 2725 * @type {number} 2726 * @constant 2727 */ 2728 SECONDS_PER_DAY: 86400, 2729 /** 2730 * The number of days in one Julian century: <code>36525</code>. 2731 * @type {number} 2732 * @constant 2733 */ 2734 DAYS_PER_JULIAN_CENTURY: 36525, 2735 /** 2736 * One trillionth of a second. 2737 * @type {number} 2738 * @constant 2739 */ 2740 PICOSECOND: 1e-9, 2741 /** 2742 * The number of days to subtract from a Julian date to determine the 2743 * modified Julian date, which gives the number of days since midnight 2744 * on November 17, 1858. 2745 * @type {number} 2746 * @constant 2747 */ 2748 MODIFIED_JULIAN_DATE_DIFFERENCE: 24000005e-1 2749}; 2750Object.freeze(TimeConstants); 2751var TimeConstants_default = TimeConstants; 2752 2753// packages/engine/Source/Core/TimeStandard.js 2754var TimeStandard = { 2755 /** 2756 * Represents the coordinated Universal Time (UTC) time standard. 2757 * 2758 * UTC is related to TAI according to the relationship 2759 * <code>UTC = TAI - deltaT</code> where <code>deltaT</code> is the number of leap 2760 * seconds which have been introduced as of the time in TAI. 2761 * 2762 * @type {number} 2763 * @constant 2764 */ 2765 UTC: 0, 2766 /** 2767 * Represents the International Atomic Time (TAI) time standard. 2768 * TAI is the principal time standard to which the other time standards are related. 2769 * 2770 * @type {number} 2771 * @constant 2772 */ 2773 TAI: 1 2774}; 2775Object.freeze(TimeStandard); 2776var TimeStandard_default = TimeStandard; 2777 2778// packages/engine/Source/Core/JulianDate.js 2779var gregorianDateScratch = new GregorianDate_default(); 2780var daysInMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; 2781var daysInLeapFebruary = 29; 2782function compareLeapSecondDates(leapSecond, dateToFind) { 2783 return JulianDate.compare(leapSecond.julianDate, dateToFind.julianDate); 2784} 2785var binarySearchScratchLeapSecond = new LeapSecond_default(); 2786function convertUtcToTai(julianDate) { 2787 binarySearchScratchLeapSecond.julianDate = julianDate; 2788 const leapSeconds = JulianDate.leapSeconds; 2789 let index = binarySearch_default( 2790 leapSeconds, 2791 binarySearchScratchLeapSecond, 2792 compareLeapSecondDates 2793 ); 2794 if (index < 0) { 2795 index = ~index; 2796 } 2797 if (index >= leapSeconds.length) { 2798 index = leapSeconds.length - 1; 2799 } 2800 let offset = leapSeconds[index].offset; 2801 if (index > 0) { 2802 const difference = JulianDate.secondsDifference( 2803 leapSeconds[index].julianDate, 2804 julianDate 2805 ); 2806 if (difference > offset) { 2807 index--; 2808 offset = leapSeconds[index].offset; 2809 } 2810 } 2811 JulianDate.addSeconds(julianDate, offset, julianDate); 2812} 2813function convertTaiToUtc(julianDate, result) { 2814 binarySearchScratchLeapSecond.julianDate = julianDate; 2815 const leapSeconds = JulianDate.leapSeconds; 2816 let index = binarySearch_default( 2817 leapSeconds, 2818 binarySearchScratchLeapSecond, 2819 compareLeapSecondDates 2820 ); 2821 if (index < 0) { 2822 index = ~index; 2823 } 2824 if (index === 0) { 2825 return JulianDate.addSeconds(julianDate, -leapSeconds[0].offset, result); 2826 } 2827 if (index >= leapSeconds.length) { 2828 return JulianDate.addSeconds( 2829 julianDate, 2830 -leapSeconds[index - 1].offset, 2831 result 2832 ); 2833 } 2834 const difference = JulianDate.secondsDifference( 2835 leapSeconds[index].julianDate, 2836 julianDate 2837 ); 2838 if (difference === 0) { 2839 return JulianDate.addSeconds( 2840 julianDate, 2841 -leapSeconds[index].offset, 2842 result 2843 ); 2844 } 2845 if (difference <= 1) { 2846 return void 0; 2847 } 2848 return JulianDate.addSeconds( 2849 julianDate, 2850 -leapSeconds[index - 1].offset, 2851 result 2852 ); 2853} 2854function setComponents(wholeDays, secondsOfDay, julianDate) { 2855 const extraDays = secondsOfDay / TimeConstants_default.SECONDS_PER_DAY | 0; 2856 wholeDays += extraDays; 2857 secondsOfDay -= TimeConstants_default.SECONDS_PER_DAY * extraDays; 2858 if (secondsOfDay < 0) { 2859 wholeDays--; 2860 secondsOfDay += TimeConstants_default.SECONDS_PER_DAY; 2861 } 2862 julianDate.dayNumber = wholeDays; 2863 julianDate.secondsOfDay = secondsOfDay; 2864 return julianDate; 2865} 2866function computeJulianDateComponents(year, month, day, hour, minute, second, millisecond) { 2867 const a3 = (month - 14) / 12 | 0; 2868 const b = year + 4800 + a3; 2869 let dayNumber = (1461 * b / 4 | 0) + (367 * (month - 2 - 12 * a3) / 12 | 0) - (3 * ((b + 100) / 100 | 0) / 4 | 0) + day - 32075; 2870 hour = hour - 12; 2871 if (hour < 0) { 2872 hour += 24; 2873 } 2874 const secondsOfDay = second + (hour * TimeConstants_default.SECONDS_PER_HOUR + minute * TimeConstants_default.SECONDS_PER_MINUTE + millisecond * TimeConstants_default.SECONDS_PER_MILLISECOND); 2875 if (secondsOfDay >= 43200) { 2876 dayNumber -= 1; 2877 } 2878 return [dayNumber, secondsOfDay]; 2879} 2880var matchCalendarYear = /^(\d{4})$/; 2881var matchCalendarMonth = /^(\d{4})-(\d{2})$/; 2882var matchOrdinalDate = /^(\d{4})-?(\d{3})$/; 2883var matchWeekDate = /^(\d{4})-?W(\d{2})-?(\d{1})?$/; 2884var matchCalendarDate = /^(\d{4})-?(\d{2})-?(\d{2})$/; 2885var utcOffset = /([Z+\-])?(\d{2})?:?(\d{2})?$/; 2886var matchHours = /^(\d{2})(\.\d+)?/.source + utcOffset.source; 2887var matchHoursMinutes = /^(\d{2}):?(\d{2})(\.\d+)?/.source + utcOffset.source; 2888var matchHoursMinutesSeconds = /^(\d{2}):?(\d{2}):?(\d{2})(\.\d+)?/.source + utcOffset.source; 2889var iso8601ErrorMessage = "Invalid ISO 8601 date."; 2890var JulianDate = class _JulianDate { 2891 /** 2892 * @param {number} [julianDayNumber=0.0] The Julian Day Number representing the number of whole days. Fractional days will also be handled correctly. 2893 * @param {number} [secondsOfDay=0.0] The number of seconds into the current Julian Day Number. Fractional seconds, negative seconds and seconds greater than a day will be handled correctly. 2894 * @param {TimeStandard} [timeStandard=TimeStandard.UTC] The time standard in which the first two parameters are defined. 2895 */ 2896 constructor(julianDayNumber, secondsOfDay, timeStandard) { 2897 this.dayNumber = void 0; 2898 this.secondsOfDay = void 0; 2899 julianDayNumber = julianDayNumber ?? 0; 2900 secondsOfDay = secondsOfDay ?? 0; 2901 timeStandard = timeStandard ?? TimeStandard_default.UTC; 2902 const wholeDays = julianDayNumber | 0; 2903 secondsOfDay = secondsOfDay + (julianDayNumber - wholeDays) * TimeConstants_default.SECONDS_PER_DAY; 2904 setComponents(wholeDays, secondsOfDay, this); 2905 if (timeStandard === TimeStandard_default.UTC) { 2906 convertUtcToTai(this); 2907 } 2908 } 2909 /** 2910 * Creates a new instance from a GregorianDate. 2911 * 2912 * @param {GregorianDate} date A GregorianDate. 2913 * @param {JulianDate} [result] An existing instance to use for the result. 2914 * @returns {JulianDate} The modified result parameter or a new instance if none was provided. 2915 * 2916 * @exception {DeveloperError} date must be a valid GregorianDate. 2917 */ 2918 static fromGregorianDate(date, result) { 2919 if (!(date instanceof GregorianDate_default)) { 2920 throw new DeveloperError_default("date must be a valid GregorianDate."); 2921 } 2922 const components = computeJulianDateComponents( 2923 date.year, 2924 date.month, 2925 date.day, 2926 date.hour, 2927 date.minute, 2928 date.second, 2929 date.millisecond 2930 ); 2931 if (!defined_default(result)) { 2932 return new _JulianDate(components[0], components[1], TimeStandard_default.UTC); 2933 } 2934 setComponents(components[0], components[1], result); 2935 convertUtcToTai(result); 2936 return result; 2937 } 2938 /** 2939 * Creates a new instance from a JavaScript Date. 2940 * 2941 * @param {Date} date A JavaScript Date. 2942 * @param {JulianDate} [result] An existing instance to use for the result. 2943 * @returns {JulianDate} The modified result parameter or a new instance if none was provided. 2944 * 2945 * @exception {DeveloperError} date must be a valid JavaScript Date. 2946 */ 2947 static fromDate(date, result) { 2948 if (!(date instanceof Date) || isNaN(date.getTime())) { 2949 throw new DeveloperError_default("date must be a valid JavaScript Date."); 2950 } 2951 const components = computeJulianDateComponents( 2952 date.getUTCFullYear(), 2953 date.getUTCMonth() + 1, 2954 date.getUTCDate(), 2955 date.getUTCHours(), 2956 date.getUTCMinutes(), 2957 date.getUTCSeconds(), 2958 date.getUTCMilliseconds() 2959 ); 2960 if (!defined_default(result)) { 2961 return new _JulianDate(components[0], components[1], TimeStandard_default.UTC); 2962 } 2963 setComponents(components[0], components[1], result); 2964 convertUtcToTai(result); 2965 return result; 2966 } 2967 /** 2968 * Creates a new instance from a from an {@link http://en.wikipedia.org/wiki/ISO_8601|ISO 8601} date. 2969 * This method is superior to <code>Date.parse</code> because it will handle all valid formats defined by the ISO 8601 2970 * specification, including leap seconds and sub-millisecond times, which discarded by most JavaScript implementations. 2971 * 2972 * @param {string} iso8601String An ISO 8601 date. 2973 * @param {JulianDate} [result] An existing instance to use for the result. 2974 * @returns {JulianDate} The modified result parameter or a new instance if none was provided. 2975 * 2976 * @exception {DeveloperError} Invalid ISO 8601 date. 2977 */ 2978 static fromIso8601(iso8601String, result) { 2979 if (typeof iso8601String !== "string") { 2980 throw new DeveloperError_default(iso8601ErrorMessage); 2981 } 2982 iso8601String = iso8601String.replace(",", "."); 2983 let tokens = iso8601String.split("T"); 2984 let year; 2985 let month = 1; 2986 let day = 1; 2987 let hour = 0; 2988 let minute = 0; 2989 let second = 0; 2990 let millisecond = 0; 2991 const date = tokens[0]; 2992 const time = tokens[1]; 2993 let tmp; 2994 let inLeapYear; 2995 if (!defined_default(date)) { 2996 throw new DeveloperError_default(iso8601ErrorMessage); 2997 } 2998 let dashCount; 2999 tokens = date.match(matchCalendarDate); 3000 if (tokens !== null) { 3001 dashCount = date.split("-").length - 1; 3002 if (dashCount > 0 && dashCount !== 2) { 3003 throw new DeveloperError_default(iso8601ErrorMessage); 3004 } 3005 year = +tokens[1]; 3006 month = +tokens[2]; 3007 day = +tokens[3]; 3008 } else { 3009 tokens = date.match(matchCalendarMonth); 3010 if (tokens !== null) { 3011 year = +tokens[1]; 3012 month = +tokens[2]; 3013 } else { 3014 tokens = date.match(matchCalendarYear); 3015 if (tokens !== null) { 3016 year = +tokens[1]; 3017 } else { 3018 let dayOfYear; 3019 tokens = date.match(matchOrdinalDate); 3020 if (tokens !== null) { 3021 year = +tokens[1]; 3022 dayOfYear = +tokens[2]; 3023 inLeapYear = isLeapYear_default(year); 3024 if (dayOfYear < 1 || inLeapYear && dayOfYear > 366 || !inLeapYear && dayOfYear > 365) { 3025 throw new DeveloperError_default(iso8601ErrorMessage); 3026 } 3027 } else { 3028 tokens = date.match(matchWeekDate); 3029 if (tokens !== null) { 3030 year = +tokens[1]; 3031 const weekNumber = +tokens[2]; 3032 const dayOfWeek = +tokens[3] || 0; 3033 dashCount = date.split("-").length - 1; 3034 if (dashCount > 0 && (!defined_default(tokens[3]) && dashCount !== 1 || defined_default(tokens[3]) && dashCount !== 2)) { 3035 throw new DeveloperError_default(iso8601ErrorMessage); 3036 } 3037 const january4 = new Date(Date.UTC(year, 0, 4)); 3038 dayOfYear = weekNumber * 7 + dayOfWeek - january4.getUTCDay() - 3; 3039 } else { 3040 throw new DeveloperError_default(iso8601ErrorMessage); 3041 } 3042 } 3043 tmp = new Date(Date.UTC(year, 0, 1)); 3044 tmp.setUTCDate(dayOfYear); 3045 month = tmp.getUTCMonth() + 1; 3046 day = tmp.getUTCDate(); 3047 } 3048 } 3049 } 3050 inLeapYear = isLeapYear_default(year); 3051 if (month < 1 || month > 12 || day < 1 || (month !== 2 || !inLeapYear) && day > daysInMonth[month - 1] || inLeapYear && month === 2 && day > daysInLeapFebruary) { 3052 throw new DeveloperError_default(iso8601ErrorMessage); 3053 } 3054 let offsetIndex; 3055 if (defined_default(time)) { 3056 tokens = time.match(matchHoursMinutesSeconds); 3057 if (tokens !== null) { 3058 dashCount = time.split(":").length - 1; 3059 if (dashCount > 0 && dashCount !== 2 && dashCount !== 3) { 3060 throw new DeveloperError_default(iso8601ErrorMessage); 3061 } 3062 hour = +tokens[1]; 3063 minute = +tokens[2]; 3064 second = +tokens[3]; 3065 millisecond = +(tokens[4] || 0) * 1e3; 3066 offsetIndex = 5; 3067 } else { 3068 tokens = time.match(matchHoursMinutes); 3069 if (tokens !== null) { 3070 dashCount = time.split(":").length - 1; 3071 if (dashCount > 2) { 3072 throw new DeveloperError_default(iso8601ErrorMessage); 3073 } 3074 hour = +tokens[1]; 3075 minute = +tokens[2]; 3076 second = +(tokens[3] || 0) * 60; 3077 offsetIndex = 4; 3078 } else { 3079 tokens = time.match(matchHours); 3080 if (tokens !== null) { 3081 hour = +tokens[1]; 3082 minute = +(tokens[2] || 0) * 60; 3083 offsetIndex = 3; 3084 } else { 3085 throw new DeveloperError_default(iso8601ErrorMessage); 3086 } 3087 } 3088 } 3089 if (minute >= 60 || second >= 61 || hour > 24 || hour === 24 && (minute > 0 || second > 0 || millisecond > 0)) { 3090 throw new DeveloperError_default(iso8601ErrorMessage); 3091 } 3092 const offset = tokens[offsetIndex]; 3093 const offsetHours = +tokens[offsetIndex + 1]; 3094 const offsetMinutes = +(tokens[offsetIndex + 2] || 0); 3095 switch (offset) { 3096 case "+": 3097 hour = hour - offsetHours; 3098 minute = minute - offsetMinutes; 3099 break; 3100 case "-": 3101 hour = hour + offsetHours; 3102 minute = minute + offsetMinutes; 3103 break; 3104 case "Z": 3105 break; 3106 default: 3107 minute = minute + new Date( 3108 Date.UTC(year, month - 1, day, hour, minute) 3109 ).getTimezoneOffset(); 3110 break; 3111 } 3112 } 3113 const isLeapSecond = second === 60; 3114 if (isLeapSecond) { 3115 second--; 3116 } 3117 while (minute >= 60) { 3118 minute -= 60; 3119 hour++; 3120 } 3121 while (hour >= 24) { 3122 hour -= 24; 3123 day++; 3124 } 3125 tmp = inLeapYear && month === 2 ? daysInLeapFebruary : daysInMonth[month - 1]; 3126 while (day > tmp) { 3127 day -= tmp; 3128 month++; 3129 if (month > 12) { 3130 month -= 12; 3131 year++; 3132 } 3133 tmp = inLeapYear && month === 2 ? daysInLeapFebruary : daysInMonth[month - 1]; 3134 } 3135 while (minute < 0) { 3136 minute += 60; 3137 hour--; 3138 } 3139 while (hour < 0) { 3140 hour += 24; 3141 day--; 3142 } 3143 while (day < 1) { 3144 month--; 3145 if (month < 1) { 3146 month += 12; 3147 year--; 3148 } 3149 tmp = inLeapYear && month === 2 ? daysInLeapFebruary : daysInMonth[month - 1]; 3150 day += tmp; 3151 } 3152 const components = computeJulianDateComponents( 3153 year, 3154 month, 3155 day, 3156 hour, 3157 minute, 3158 second, 3159 millisecond 3160 ); 3161 if (!defined_default(result)) { 3162 result = new _JulianDate(components[0], components[1], TimeStandard_default.UTC); 3163 } else { 3164 setComponents(components[0], components[1], result); 3165 convertUtcToTai(result); 3166 } 3167 if (isLeapSecond) { 3168 _JulianDate.addSeconds(result, 1, result); 3169 } 3170 return result; 3171 } 3172 /** 3173 * Creates a new instance that represents the current system time. 3174 * This is equivalent to calling <code>JulianDate.fromDate(new Date());</code>. 3175 * 3176 * @param {JulianDate} [result] An existing instance to use for the result. 3177 * @returns {JulianDate} The modified result parameter or a new instance if none was provided. 3178 */ 3179 static now(result) { 3180 return _JulianDate.fromDate(/* @__PURE__ */ new Date(), result); 3181 } 3182 /** 3183 * Creates a {@link GregorianDate} from the provided instance. 3184 * 3185 * @param {JulianDate} julianDate The date to be converted. 3186 * @param {GregorianDate} [result] An existing instance to use for the result. 3187 * @returns {GregorianDate} The modified result parameter or a new instance if none was provided. 3188 */ 3189 static toGregorianDate(julianDate, result) { 3190 if (!defined_default(julianDate)) { 3191 throw new DeveloperError_default("julianDate is required."); 3192 } 3193 let isLeapSecond = false; 3194 let thisUtc = convertTaiToUtc(julianDate, toGregorianDateScratch); 3195 if (!defined_default(thisUtc)) { 3196 _JulianDate.addSeconds(julianDate, -1, toGregorianDateScratch); 3197 thisUtc = convertTaiToUtc(toGregorianDateScratch, toGregorianDateScratch); 3198 isLeapSecond = true; 3199 } 3200 let julianDayNumber = thisUtc.dayNumber; 3201 const secondsOfDay = thisUtc.secondsOfDay; 3202 if (secondsOfDay >= 43200) { 3203 julianDayNumber += 1; 3204 } 3205 let L = julianDayNumber + 68569 | 0; 3206 const N = 4 * L / 146097 | 0; 3207 L = L - ((146097 * N + 3) / 4 | 0) | 0; 3208 const I = 4e3 * (L + 1) / 1461001 | 0; 3209 L = L - (1461 * I / 4 | 0) + 31 | 0; 3210 const J = 80 * L / 2447 | 0; 3211 const day = L - (2447 * J / 80 | 0) | 0; 3212 L = J / 11 | 0; 3213 const month = J + 2 - 12 * L | 0; 3214 const year = 100 * (N - 49) + I + L | 0; 3215 let hour = secondsOfDay / TimeConstants_default.SECONDS_PER_HOUR | 0; 3216 let remainingSeconds = secondsOfDay - hour * TimeConstants_default.SECONDS_PER_HOUR; 3217 const minute = remainingSeconds / TimeConstants_default.SECONDS_PER_MINUTE | 0; 3218 remainingSeconds = remainingSeconds - minute * TimeConstants_default.SECONDS_PER_MINUTE; 3219 let second = remainingSeconds | 0; 3220 const millisecond = (remainingSeconds - second) / TimeConstants_default.SECONDS_PER_MILLISECOND; 3221 hour += 12; 3222 if (hour > 23) { 3223 hour -= 24; 3224 } 3225 if (isLeapSecond) { 3226 second += 1; 3227 } 3228 if (!defined_default(result)) { 3229 return new GregorianDate_default( 3230 year, 3231 month, 3232 day, 3233 hour, 3234 minute, 3235 second, 3236 millisecond, 3237 isLeapSecond 3238 ); 3239 } 3240 result.year = year; 3241 result.month = month; 3242 result.day = day; 3243 result.hour = hour; 3244 result.minute = minute; 3245 result.second = second; 3246 result.millisecond = millisecond; 3247 result.isLeapSecond = isLeapSecond; 3248 return result; 3249 } 3250 /** 3251 * Creates a JavaScript Date from the provided instance. 3252 * Since JavaScript dates are only accurate to the nearest millisecond and 3253 * cannot represent a leap second, consider using {@link JulianDate.toGregorianDate} instead. 3254 * If the provided JulianDate is during a leap second, the previous second is used. 3255 * 3256 * @param {JulianDate} julianDate The date to be converted. 3257 * @returns {Date} A new instance representing the provided date. 3258 */ 3259 static toDate(julianDate) { 3260 if (!defined_default(julianDate)) { 3261 throw new DeveloperError_default("julianDate is required."); 3262 } 3263 const gDate = _JulianDate.toGregorianDate(julianDate, gregorianDateScratch); 3264 let second = gDate.second; 3265 if (gDate.isLeapSecond) { 3266 second -= 1; 3267 } 3268 return new Date( 3269 Date.UTC( 3270 gDate.year, 3271 gDate.month - 1, 3272 gDate.day, 3273 gDate.hour, 3274 gDate.minute, 3275 second, 3276 gDate.millisecond 3277 ) 3278 ); 3279 } 3280 /** 3281 * Creates an ISO8601 representation of the provided date. 3282 * 3283 * @param {JulianDate} julianDate The date to be converted. 3284 * @param {number} [precision] The number of fractional digits used to represent the seconds component. By default, the most precise representation is used. 3285 * @returns {string} The ISO8601 representation of the provided date. 3286 */ 3287 static toIso8601(julianDate, precision) { 3288 if (!defined_default(julianDate)) { 3289 throw new DeveloperError_default("julianDate is required."); 3290 } 3291 const gDate = _JulianDate.toGregorianDate(julianDate, gregorianDateScratch); 3292 let year = gDate.year; 3293 let month = gDate.month; 3294 let day = gDate.day; 3295 let hour = gDate.hour; 3296 const minute = gDate.minute; 3297 const second = gDate.second; 3298 const millisecond = gDate.millisecond; 3299 if (year === 1e4 && month === 1 && day === 1 && hour === 0 && minute === 0 && second === 0 && millisecond === 0) { 3300 year = 9999; 3301 month = 12; 3302 day = 31; 3303 hour = 24; 3304 } 3305 let millisecondStr; 3306 if (!defined_default(precision) && millisecond !== 0) { 3307 const millisecondHundreds = millisecond * 0.01; 3308 millisecondStr = millisecondHundreds < 1e-6 ? millisecondHundreds.toFixed(20).replace(".", "").replace(/0+$/, "") : millisecondHundreds.toString().replace(".", ""); 3309 return `${year.toString().padStart(4, "0")}-${month.toString().padStart(2, "0")}-${day.toString().padStart(2, "0")}T${hour.toString().padStart(2, "0")}:${minute.toString().padStart(2, "0")}:${second.toString().padStart(2, "0")}.${millisecondStr}Z`; 3310 } 3311 if (!defined_default(precision) || precision === 0) { 3312 return `${year.toString().padStart(4, "0")}-${month.toString().padStart(2, "0")}-${day.toString().padStart(2, "0")}T${hour.toString().padStart(2, "0")}:${minute.toString().padStart(2, "0")}:${second.toString().padStart(2, "0")}Z`; 3313 } 3314 millisecondStr = (millisecond * 0.01).toFixed(precision).replace(".", "").slice(0, precision); 3315 return `${year.toString().padStart(4, "0")}-${month.toString().padStart(2, "0")}-${day.toString().padStart(2, "0")}T${hour.toString().padStart(2, "0")}:${minute.toString().padStart(2, "0")}:${second.toString().padStart(2, "0")}.${millisecondStr}Z`; 3316 } 3317 /** 3318 * Duplicates a JulianDate instance. 3319 * 3320 * @param {JulianDate} julianDate The date to duplicate. 3321 * @param {JulianDate} [result] An existing instance to use for the result. 3322 * @returns {JulianDate} The modified result parameter or a new instance if none was provided. Returns undefined if julianDate is undefined. 3323 */ 3324 static clone(julianDate, result) { 3325 if (!defined_default(julianDate)) { 3326 return void 0; 3327 } 3328 if (!defined_default(result)) { 3329 return new _JulianDate( 3330 julianDate.dayNumber, 3331 julianDate.secondsOfDay, 3332 TimeStandard_default.TAI 3333 ); 3334 } 3335 result.dayNumber = julianDate.dayNumber; 3336 result.secondsOfDay = julianDate.secondsOfDay; 3337 return result; 3338 } 3339 /** 3340 * Compares two instances. 3341 * 3342 * @param {JulianDate} left The first instance. 3343 * @param {JulianDate} right The second instance. 3344 * @returns {number} A negative value if left is less than right, a positive value if left is greater than right, or zero if left and right are equal. 3345 */ 3346 static compare(left, right) { 3347 if (!defined_default(left)) { 3348 throw new DeveloperError_default("left is required."); 3349 } 3350 if (!defined_default(right)) { 3351 throw new DeveloperError_default("right is required."); 3352 } 3353 const julianDayNumberDifference = left.dayNumber - right.dayNumber; 3354 if (julianDayNumberDifference !== 0) { 3355 return julianDayNumberDifference; 3356 } 3357 return left.secondsOfDay - right.secondsOfDay; 3358 } 3359 /** 3360 * Compares two instances and returns <code>true</code> if they are equal, <code>false</code> otherwise. 3361 * 3362 * @param {JulianDate} [left] The first instance. 3363 * @param {JulianDate} [right] The second instance. 3364 * @returns {boolean} <code>true</code> if the dates are equal; otherwise, <code>false</code>. 3365 */ 3366 static equals(left, right) { 3367 return left === right || defined_default(left) && defined_default(right) && left.dayNumber === right.dayNumber && left.secondsOfDay === right.secondsOfDay; 3368 } 3369 /** 3370 * Compares two instances and returns <code>true</code> if they are within <code>epsilon</code> seconds of 3371 * each other. That is, in order for the dates to be considered equal (and for 3372 * this function to return <code>true</code>), the absolute value of the difference between them, in 3373 * seconds, must be less than <code>epsilon</code>. 3374 * 3375 * @param {JulianDate} [left] The first instance. 3376 * @param {JulianDate} [right] The second instance. 3377 * @param {number} [epsilon=0] The maximum number of seconds that should separate the two instances. 3378 * @returns {boolean} <code>true</code> if the two dates are within <code>epsilon</code> seconds of each other; otherwise <code>false</code>. 3379 */ 3380 static equalsEpsilon(left, right, epsilon) { 3381 epsilon = epsilon ?? 0; 3382 return left === right || defined_default(left) && defined_default(right) && Math.abs(_JulianDate.secondsDifference(left, right)) <= epsilon; 3383 } 3384 /** 3385 * Computes the total number of whole and fractional days represented by the provided instance. 3386 * 3387 * @param {JulianDate} julianDate The date. 3388 * @returns {number} The Julian date as single floating point number. 3389 */ 3390 static totalDays(julianDate) { 3391 if (!defined_default(julianDate)) { 3392 throw new DeveloperError_default("julianDate is required."); 3393 } 3394 return julianDate.dayNumber + julianDate.secondsOfDay / TimeConstants_default.SECONDS_PER_DAY; 3395 } 3396 /** 3397 * Computes the difference in seconds between the provided instance. 3398 * 3399 * @param {JulianDate} left The first instance. 3400 * @param {JulianDate} right The second instance. 3401 * @returns {number} The difference, in seconds, when subtracting <code>right</code> from <code>left</code>. 3402 */ 3403 static secondsDifference(left, right) { 3404 if (!defined_default(left)) { 3405 throw new DeveloperError_default("left is required."); 3406 } 3407 if (!defined_default(right)) { 3408 throw new DeveloperError_default("right is required."); 3409 } 3410 const dayDifference = (left.dayNumber - right.dayNumber) * TimeConstants_default.SECONDS_PER_DAY; 3411 return dayDifference + (left.secondsOfDay - right.secondsOfDay); 3412 } 3413 /** 3414 * Computes the difference in days between the provided instance. 3415 * 3416 * @param {JulianDate} left The first instance. 3417 * @param {JulianDate} right The second instance. 3418 * @returns {number} The difference, in days, when subtracting <code>right</code> from <code>left</code>. 3419 */ 3420 static daysDifference(left, right) { 3421 if (!defined_default(left)) { 3422 throw new DeveloperError_default("left is required."); 3423 } 3424 if (!defined_default(right)) { 3425 throw new DeveloperError_default("right is required."); 3426 } 3427 const dayDifference = left.dayNumber - right.dayNumber; 3428 const secondDifference = (left.secondsOfDay - right.secondsOfDay) / TimeConstants_default.SECONDS_PER_DAY; 3429 return dayDifference + secondDifference; 3430 } 3431 /** 3432 * Computes the number of seconds the provided instance is ahead of UTC. 3433 * 3434 * @param {JulianDate} julianDate The date. 3435 * @returns {number} The number of seconds the provided instance is ahead of UTC 3436 */ 3437 static computeTaiMinusUtc(julianDate) { 3438 binarySearchScratchLeapSecond.julianDate = julianDate; 3439 const leapSeconds = _JulianDate.leapSeconds; 3440 let index = binarySearch_default( 3441 leapSeconds, 3442 binarySearchScratchLeapSecond, 3443 compareLeapSecondDates 3444 ); 3445 if (index < 0) { 3446 index = ~index; 3447 --index; 3448 if (index < 0) { 3449 index = 0; 3450 } 3451 } 3452 return leapSeconds[index].offset; 3453 } 3454 /** 3455 * Adds the provided number of seconds to the provided date instance. 3456 * 3457 * @param {JulianDate} julianDate The date. 3458 * @param {number} seconds The number of seconds to add or subtract. 3459 * @param {JulianDate} result An existing instance to use for the result. 3460 * @returns {JulianDate} The modified result parameter. 3461 */ 3462 static addSeconds(julianDate, seconds, result) { 3463 if (!defined_default(julianDate)) { 3464 throw new DeveloperError_default("julianDate is required."); 3465 } 3466 if (!defined_default(seconds)) { 3467 throw new DeveloperError_default("seconds is required."); 3468 } 3469 if (!defined_default(result)) { 3470 throw new DeveloperError_default("result is required."); 3471 } 3472 return setComponents( 3473 julianDate.dayNumber, 3474 julianDate.secondsOfDay + seconds, 3475 result 3476 ); 3477 } 3478 /** 3479 * Adds the provided number of minutes to the provided date instance. 3480 * 3481 * @param {JulianDate} julianDate The date. 3482 * @param {number} minutes The number of minutes to add or subtract. 3483 * @param {JulianDate} result An existing instance to use for the result. 3484 * @returns {JulianDate} The modified result parameter. 3485 */ 3486 static addMinutes(julianDate, minutes, result) { 3487 if (!defined_default(julianDate)) { 3488 throw new DeveloperError_default("julianDate is required."); 3489 } 3490 if (!defined_default(minutes)) { 3491 throw new DeveloperError_default("minutes is required."); 3492 } 3493 if (!defined_default(result)) { 3494 throw new DeveloperError_default("result is required."); 3495 } 3496 const newSecondsOfDay = julianDate.secondsOfDay + minutes * TimeConstants_default.SECONDS_PER_MINUTE; 3497 return setComponents(julianDate.dayNumber, newSecondsOfDay, result); 3498 } 3499 /** 3500 * Adds the provided number of hours to the provided date instance. 3501 * 3502 * @param {JulianDate} julianDate The date. 3503 * @param {number} hours The number of hours to add or subtract. 3504 * @param {JulianDate} result An existing instance to use for the result. 3505 * @returns {JulianDate} The modified result parameter. 3506 */ 3507 static addHours(julianDate, hours, result) { 3508 if (!defined_default(julianDate)) { 3509 throw new DeveloperError_default("julianDate is required."); 3510 } 3511 if (!defined_default(hours)) { 3512 throw new DeveloperError_default("hours is required."); 3513 } 3514 if (!defined_default(result)) { 3515 throw new DeveloperError_default("result is required."); 3516 } 3517 const newSecondsOfDay = julianDate.secondsOfDay + hours * TimeConstants_default.SECONDS_PER_HOUR; 3518 return setComponents(julianDate.dayNumber, newSecondsOfDay, result); 3519 } 3520 /** 3521 * Adds the provided number of days to the provided date instance. 3522 * 3523 * @param {JulianDate} julianDate The date. 3524 * @param {number} days The number of days to add or subtract. 3525 * @param {JulianDate} result An existing instance to use for the result. 3526 * @returns {JulianDate} The modified result parameter. 3527 */ 3528 static addDays(julianDate, days, result) { 3529 if (!defined_default(julianDate)) { 3530 throw new DeveloperError_default("julianDate is required."); 3531 } 3532 if (!defined_default(days)) { 3533 throw new DeveloperError_default("days is required."); 3534 } 3535 if (!defined_default(result)) { 3536 throw new DeveloperError_default("result is required."); 3537 } 3538 const newJulianDayNumber = julianDate.dayNumber + days; 3539 return setComponents(newJulianDayNumber, julianDate.secondsOfDay, result); 3540 } 3541 /** 3542 * Compares the provided instances and returns <code>true</code> if <code>left</code> is earlier than <code>right</code>, <code>false</code> otherwise. 3543 * 3544 * @param {JulianDate} left The first instance. 3545 * @param {JulianDate} right The second instance. 3546 * @returns {boolean} <code>true</code> if <code>left</code> is earlier than <code>right</code>, <code>false</code> otherwise. 3547 */ 3548 static lessThan(left, right) { 3549 return _JulianDate.compare(left, right) < 0; 3550 } 3551 /** 3552 * Compares the provided instances and returns <code>true</code> if <code>left</code> is earlier than or equal to <code>right</code>, <code>false</code> otherwise. 3553 * 3554 * @param {JulianDate} left The first instance. 3555 * @param {JulianDate} right The second instance. 3556 * @returns {boolean} <code>true</code> if <code>left</code> is earlier than or equal to <code>right</code>, <code>false</code> otherwise. 3557 */ 3558 static lessThanOrEquals(left, right) { 3559 return _JulianDate.compare(left, right) <= 0; 3560 } 3561 /** 3562 * Compares the provided instances and returns <code>true</code> if <code>left</code> is later than <code>right</code>, <code>false</code> otherwise. 3563 * 3564 * @param {JulianDate} left The first instance. 3565 * @param {JulianDate} right The second instance. 3566 * @returns {boolean} <code>true</code> if <code>left</code> is later than <code>right</code>, <code>false</code> otherwise. 3567 */ 3568 static greaterThan(left, right) { 3569 return _JulianDate.compare(left, right) > 0; 3570 } 3571 /** 3572 * Compares the provided instances and returns <code>true</code> if <code>left</code> is later than or equal to <code>right</code>, <code>false</code> otherwise. 3573 * 3574 * @param {JulianDate} left The first instance. 3575 * @param {JulianDate} right The second instance. 3576 * @returns {boolean} <code>true</code> if <code>left</code> is later than or equal to <code>right</code>, <code>false</code> otherwise. 3577 */ 3578 static greaterThanOrEquals(left, right) { 3579 return _JulianDate.compare(left, right) >= 0; 3580 } 3581 /** 3582 * Duplicates this instance. 3583 * 3584 * @param {JulianDate} [result] An existing instance to use for the result. 3585 * @returns {JulianDate} The modified result parameter or a new instance if none was provided. 3586 */ 3587 clone(result) { 3588 return _JulianDate.clone(this, result); 3589 } 3590 /** 3591 * Compares this and the provided instance and returns <code>true</code> if they are equal, <code>false</code> otherwise. 3592 * 3593 * @param {JulianDate} [right] The second instance. 3594 * @returns {boolean} <code>true</code> if the dates are equal; otherwise, <code>false</code>. 3595 */ 3596 equals(right) { 3597 return _JulianDate.equals(this, right); 3598 } 3599 /** 3600 * Compares this and the provided instance and returns <code>true</code> if they are within <code>epsilon</code> seconds of 3601 * each other. That is, in order for the dates to be considered equal (and for 3602 * this function to return <code>true</code>), the absolute value of the difference between them, in 3603 * seconds, must be less than <code>epsilon</code>. 3604 * 3605 * @param {JulianDate} [right] The second instance. 3606 * @param {number} [epsilon=0] The maximum number of seconds that should separate the two instances. 3607 * @returns {boolean} <code>true</code> if the two dates are within <code>epsilon</code> seconds of each other; otherwise <code>false</code>. 3608 */ 3609 equalsEpsilon(right, epsilon) { 3610 return _JulianDate.equalsEpsilon(this, right, epsilon); 3611 } 3612 /** 3613 * Creates a string representing this date in ISO8601 format. 3614 * 3615 * @returns {string} A string representing this date in ISO8601 format. 3616 */ 3617 toString() { 3618 return _JulianDate.toIso8601(this); 3619 } 3620}; 3621var toGregorianDateScratch = new JulianDate(0, 0, TimeStandard_default.TAI); 3622JulianDate.leapSeconds = [ 3623 new LeapSecond_default(new JulianDate(2441317, 43210, TimeStandard_default.TAI), 10), 3624 // January 1, 1972 00:00:00 UTC 3625 new LeapSecond_default(new JulianDate(2441499, 43211, TimeStandard_default.TAI), 11), 3626 // July 1, 1972 00:00:00 UTC 3627 new LeapSecond_default(new JulianDate(2441683, 43212, TimeStandard_default.TAI), 12), 3628 // January 1, 1973 00:00:00 UTC 3629 new LeapSecond_default(new JulianDate(2442048, 43213, TimeStandard_default.TAI), 13), 3630 // January 1, 1974 00:00:00 UTC 3631 new LeapSecond_default(new JulianDate(2442413, 43214, TimeStandard_default.TAI), 14), 3632 // January 1, 1975 00:00:00 UTC 3633 new LeapSecond_default(new JulianDate(2442778, 43215, TimeStandard_default.TAI), 15), 3634 // January 1, 1976 00:00:00 UTC 3635 new LeapSecond_default(new JulianDate(2443144, 43216, TimeStandard_default.TAI), 16), 3636 // January 1, 1977 00:00:00 UTC 3637 new LeapSecond_default(new JulianDate(2443509, 43217, TimeStandard_default.TAI), 17), 3638 // January 1, 1978 00:00:00 UTC 3639 new LeapSecond_default(new JulianDate(2443874, 43218, TimeStandard_default.TAI), 18), 3640 // January 1, 1979 00:00:00 UTC 3641 new LeapSecond_default(new JulianDate(2444239, 43219, TimeStandard_default.TAI), 19), 3642 // January 1, 1980 00:00:00 UTC 3643 new LeapSecond_default(new JulianDate(2444786, 43220, TimeStandard_default.TAI), 20), 3644 // July 1, 1981 00:00:00 UTC 3645 new LeapSecond_default(new JulianDate(2445151, 43221, TimeStandard_default.TAI), 21), 3646 // July 1, 1982 00:00:00 UTC 3647 new LeapSecond_default(new JulianDate(2445516, 43222, TimeStandard_default.TAI), 22), 3648 // July 1, 1983 00:00:00 UTC 3649 new LeapSecond_default(new JulianDate(2446247, 43223, TimeStandard_default.TAI), 23), 3650 // July 1, 1985 00:00:00 UTC 3651 new LeapSecond_default(new JulianDate(2447161, 43224, TimeStandard_default.TAI), 24), 3652 // January 1, 1988 00:00:00 UTC 3653 new LeapSecond_default(new JulianDate(2447892, 43225, TimeStandard_default.TAI), 25), 3654 // January 1, 1990 00:00:00 UTC 3655 new LeapSecond_default(new JulianDate(2448257, 43226, TimeStandard_default.TAI), 26), 3656 // January 1, 1991 00:00:00 UTC 3657 new LeapSecond_default(new JulianDate(2448804, 43227, TimeStandard_default.TAI), 27), 3658 // July 1, 1992 00:00:00 UTC 3659 new LeapSecond_default(new JulianDate(2449169, 43228, TimeStandard_default.TAI), 28), 3660 // July 1, 1993 00:00:00 UTC 3661 new LeapSecond_default(new JulianDate(2449534, 43229, TimeStandard_default.TAI), 29), 3662 // July 1, 1994 00:00:00 UTC 3663 new LeapSecond_default(new JulianDate(2450083, 43230, TimeStandard_default.TAI), 30), 3664 // January 1, 1996 00:00:00 UTC 3665 new LeapSecond_default(new JulianDate(2450630, 43231, TimeStandard_default.TAI), 31), 3666 // July 1, 1997 00:00:00 UTC 3667 new LeapSecond_default(new JulianDate(2451179, 43232, TimeStandard_default.TAI), 32), 3668 // January 1, 1999 00:00:00 UTC 3669 new LeapSecond_default(new JulianDate(2453736, 43233, TimeStandard_default.TAI), 33), 3670 // January 1, 2006 00:00:00 UTC 3671 new LeapSecond_default(new JulianDate(2454832, 43234, TimeStandard_default.TAI), 34), 3672 // January 1, 2009 00:00:00 UTC 3673 new LeapSecond_default(new JulianDate(2456109, 43235, TimeStandard_default.TAI), 35), 3674 // July 1, 2012 00:00:00 UTC 3675 new LeapSecond_default(new JulianDate(2457204, 43236, TimeStandard_default.TAI), 36), 3676 // July 1, 2015 00:00:00 UTC 3677 new LeapSecond_default(new JulianDate(2457754, 43237, TimeStandard_default.TAI), 37) 3678 // January 1, 2017 00:00:00 UTC 3679]; 3680var JulianDate_default = JulianDate; 3681 3682// packages/engine/Source/Core/Resource.js 3683var import_urijs6 = __toESM(require_URI(), 1); 3684 3685// packages/engine/Source/Core/appendForwardSlash.js 3686function appendForwardSlash(url) { 3687 if (url.length === 0 || url[url.length - 1] !== "/") { 3688 url = `${url}/`; 3689 } 3690 return url; 3691} 3692var appendForwardSlash_default = appendForwardSlash; 3693 3694// packages/engine/Source/Core/clone.js 3695function clone(object, deep) { 3696 if (object === null || typeof object !== "object") { 3697 return object; 3698 } 3699 deep = deep ?? false; 3700 const result = new object.constructor(); 3701 for (const propertyName in object) { 3702 if (object.hasOwnProperty(propertyName)) { 3703 let value = object[propertyName]; 3704 if (deep) { 3705 value = clone(value, deep); 3706 } 3707 result[propertyName] = value; 3708 } 3709 } 3710 return result; 3711} 3712var clone_default = clone; 3713 3714// packages/engine/Source/Core/defer.js 3715function defer() { 3716 let resolve; 3717 let reject; 3718 const promise = new Promise(function(res, rej) { 3719 resolve = res; 3720 reject = rej; 3721 }); 3722 return { 3723 resolve, 3724 reject, 3725 promise 3726 }; 3727} 3728var defer_default = defer; 3729 3730// packages/engine/Source/Core/getAbsoluteUri.js 3731var import_urijs = __toESM(require_URI(), 1); 3732function getAbsoluteUri(relative, base) { 3733 let documentObject; 3734 if (typeof document !== "undefined") { 3735 documentObject = document; 3736 } 3737 return getAbsoluteUri._implementation(relative, base, documentObject); 3738} 3739getAbsoluteUri._implementation = function(relative, base, documentObject) { 3740 if (!defined_default(relative)) { 3741 throw new DeveloperError_default("relative uri is required."); 3742 } 3743 if (!defined_default(base)) { 3744 if (typeof documentObject === "undefined") { 3745 return relative; 3746 } 3747 base = documentObject.baseURI ?? documentObject.location.href; 3748 } 3749 const relativeUri = new import_urijs.default(relative); 3750 if (relativeUri.scheme() !== "") { 3751 return relativeUri.toString(); 3752 } 3753 return relativeUri.absoluteTo(base).toString(); 3754}; 3755var getAbsoluteUri_default = getAbsoluteUri; 3756 3757// packages/engine/Source/Core/getBaseUri.js 3758var import_urijs2 = __toESM(require_URI(), 1); 3759function getBaseUri(uri, includeQuery) { 3760 if (!defined_default(uri)) { 3761 throw new DeveloperError_default("uri is required."); 3762 } 3763 let basePath = ""; 3764 const i = uri.lastIndexOf("/"); 3765 if (i !== -1) { 3766 basePath = uri.substring(0, i + 1); 3767 } 3768 if (!includeQuery) { 3769 return basePath; 3770 } 3771 uri = new import_urijs2.default(uri); 3772 if (uri.query().length !== 0) { 3773 basePath += `?${uri.query()}`; 3774 } 3775 if (uri.fragment().length !== 0) { 3776 basePath += `#${uri.fragment()}`; 3777 } 3778 return basePath; 3779} 3780var getBaseUri_default = getBaseUri; 3781 3782// packages/engine/Source/Core/getExtensionFromUri.js 3783var import_urijs3 = __toESM(require_URI(), 1); 3784function getExtensionFromUri(uri) { 3785 if (!defined_default(uri)) { 3786 throw new DeveloperError_default("uri is required."); 3787 } 3788 const uriObject = new import_urijs3.default(uri); 3789 uriObject.normalize(); 3790 let path = uriObject.path(); 3791 let index = path.lastIndexOf("/"); 3792 if (index !== -1) { 3793 path = path.substr(index + 1); 3794 } 3795 index = path.lastIndexOf("."); 3796 if (index === -1) { 3797 path = ""; 3798 } else { 3799 path = path.substr(index + 1); 3800 } 3801 return path; 3802} 3803var getExtensionFromUri_default = getExtensionFromUri; 3804 3805// packages/engine/Source/Core/getImagePixels.js 3806var context2DsByWidthAndHeight = {}; 3807function getImagePixels(image, width, height) { 3808 if (!defined_default(width)) { 3809 width = image.width; 3810 } 3811 if (!defined_default(height)) { 3812 height = image.height; 3813 } 3814 let context2DsByHeight = context2DsByWidthAndHeight[width]; 3815 if (!defined_default(context2DsByHeight)) { 3816 context2DsByHeight = {}; 3817 context2DsByWidthAndHeight[width] = context2DsByHeight; 3818 } 3819 let context2d = context2DsByHeight[height]; 3820 if (!defined_default(context2d)) { 3821 const canvas = document.createElement("canvas"); 3822 canvas.width = width; 3823 canvas.height = height; 3824 context2d = canvas.getContext("2d", { willReadFrequently: true }); 3825 context2d.globalCompositeOperation = "copy"; 3826 context2DsByHeight[height] = context2d; 3827 } 3828 context2d.drawImage(image, 0, 0, width, height); 3829 return context2d.getImageData(0, 0, width, height).data; 3830} 3831var getImagePixels_default = getImagePixels; 3832 3833// packages/engine/Source/Core/isBlobUri.js 3834var blobUriRegex = /^blob:/i; 3835function isBlobUri(uri) { 3836 Check_default.typeOf.string("uri", uri); 3837 return blobUriRegex.test(uri); 3838} 3839var isBlobUri_default = isBlobUri; 3840 3841// packages/engine/Source/Core/isCrossOriginUrl.js 3842var a; 3843function isCrossOriginUrl(url) { 3844 if (!defined_default(a)) { 3845 a = document.createElement("a"); 3846 } 3847 a.href = window.location.href; 3848 const host = a.host; 3849 const protocol = a.protocol; 3850 a.href = url; 3851 a.href = a.href; 3852 return protocol !== a.protocol || host !== a.host; 3853} 3854var isCrossOriginUrl_default = isCrossOriginUrl; 3855 3856// packages/engine/Source/Core/isDataUri.js 3857var dataUriRegex = /^data:/i; 3858function isDataUri(uri) { 3859 Check_default.typeOf.string("uri", uri); 3860 return dataUriRegex.test(uri); 3861} 3862var isDataUri_default = isDataUri; 3863 3864// packages/engine/Source/Core/loadAndExecuteScript.js 3865function loadAndExecuteScript(url) { 3866 const script = document.createElement("script"); 3867 script.async = true; 3868 script.src = url; 3869 return new Promise((resolve, reject) => { 3870 if (window.crossOriginIsolated) { 3871 script.setAttribute("crossorigin", "anonymous"); 3872 } 3873 const head = document.getElementsByTagName("head")[0]; 3874 script.onload = function() { 3875 script.onload = void 0; 3876 head.removeChild(script); 3877 resolve(); 3878 }; 3879 script.onerror = function(e) { 3880 reject(e); 3881 }; 3882 head.appendChild(script); 3883 }); 3884} 3885var loadAndExecuteScript_default = loadAndExecuteScript; 3886 3887// packages/engine/Source/Core/objectToQuery.js 3888function objectToQuery(obj) { 3889 if (!defined_default(obj)) { 3890 throw new DeveloperError_default("obj is required."); 3891 } 3892 let result = ""; 3893 for (const propName in obj) { 3894 if (obj.hasOwnProperty(propName)) { 3895 const value = obj[propName]; 3896 const part = `${encodeURIComponent(propName)}=`; 3897 if (Array.isArray(value)) { 3898 for (let i = 0, len = value.length; i < len; ++i) { 3899 result += `${part + encodeURIComponent(value[i])}&`; 3900 } 3901 } else { 3902 result += `${part + encodeURIComponent(value)}&`; 3903 } 3904 } 3905 } 3906 result = result.slice(0, -1); 3907 return result; 3908} 3909var objectToQuery_default = objectToQuery; 3910 3911// packages/engine/Source/Core/queryToObject.js 3912function queryToObject(queryString) { 3913 if (!defined_default(queryString)) { 3914 throw new DeveloperError_default("queryString is required."); 3915 } 3916 const result = {}; 3917 if (queryString === "") { 3918 return result; 3919 } 3920 const parts = queryString.replace(/\+/g, "%20").split(/[&;]/); 3921 for (let i = 0, len = parts.length; i < len; ++i) { 3922 const subparts = parts[i].split("="); 3923 const name = decodeURIComponent(subparts[0]); 3924 let value = subparts[1]; 3925 if (defined_default(value)) { 3926 value = decodeURIComponent(value); 3927 } else { 3928 value = ""; 3929 } 3930 const resultValue = result[name]; 3931 if (typeof resultValue === "string") { 3932 result[name] = [resultValue, value]; 3933 } else if (Array.isArray(resultValue)) { 3934 resultValue.push(value); 3935 } else { 3936 result[name] = value; 3937 } 3938 } 3939 return result; 3940} 3941var queryToObject_default = queryToObject; 3942 3943// packages/engine/Source/Core/RequestState.js 3944var RequestState = { 3945 /** 3946 * Initial unissued state. 3947 * 3948 * @type {number} 3949 * @constant 3950 */ 3951 UNISSUED: 0, 3952 /** 3953 * Issued but not yet active. Will become active when open slots are available. 3954 * 3955 * @type {number} 3956 * @constant 3957 */ 3958 ISSUED: 1, 3959 /** 3960 * Actual http request has been sent. 3961 * 3962 * @type {number} 3963 * @constant 3964 */ 3965 ACTIVE: 2, 3966 /** 3967 * Request completed successfully. 3968 * 3969 * @type {number} 3970 * @constant 3971 */ 3972 RECEIVED: 3, 3973 /** 3974 * Request was cancelled, either explicitly or automatically because of low priority. 3975 * 3976 * @type {number} 3977 * @constant 3978 */ 3979 CANCELLED: 4, 3980 /** 3981 * Request failed. 3982 * 3983 * @type {number} 3984 * @constant 3985 */ 3986 FAILED: 5 3987}; 3988Object.freeze(RequestState); 3989var RequestState_default = RequestState; 3990 3991// packages/engine/Source/Core/RequestType.js 3992var RequestType = { 3993 /** 3994 * Terrain request. 3995 * 3996 * @type {number} 3997 * @constant 3998 */ 3999 TERRAIN: 0, 4000 /** 4001 * Imagery request. 4002 * 4003 * @type {number} 4004 * @constant 4005 */ 4006 IMAGERY: 1, 4007 /** 4008 * 3D Tiles request. 4009 * 4010 * @type {number} 4011 * @constant 4012 */ 4013 TILES3D: 2, 4014 /** 4015 * Other request. 4016 * 4017 * @type {number} 4018 * @constant 4019 */ 4020 OTHER: 3 4021}; 4022Object.freeze(RequestType); 4023var RequestType_default = RequestType; 4024 4025// packages/engine/Source/Core/Request.js 4026function Request(options) { 4027 options = options ?? Frozen_default.EMPTY_OBJECT; 4028 const throttleByServer = options.throttleByServer ?? false; 4029 const throttle = options.throttle ?? false; 4030 this.url = options.url; 4031 this.requestFunction = options.requestFunction; 4032 this.cancelFunction = options.cancelFunction; 4033 this.priorityFunction = options.priorityFunction; 4034 this.priority = options.priority ?? 0; 4035 this.throttle = throttle; 4036 this.throttleByServer = throttleByServer; 4037 this.type = options.type ?? RequestType_default.OTHER; 4038 this.serverKey = options.serverKey; 4039 this.state = RequestState_default.UNISSUED; 4040 this.deferred = void 0; 4041 this.cancelled = false; 4042} 4043Request.prototype.cancel = function() { 4044 this.cancelled = true; 4045}; 4046Request.prototype.clone = function(result) { 4047 if (!defined_default(result)) { 4048 return new Request(this); 4049 } 4050 result.url = this.url; 4051 result.requestFunction = this.requestFunction; 4052 result.cancelFunction = this.cancelFunction; 4053 result.priorityFunction = this.priorityFunction; 4054 result.priority = this.priority; 4055 result.throttle = this.throttle; 4056 result.throttleByServer = this.throttleByServer; 4057 result.type = this.type; 4058 result.serverKey = this.serverKey; 4059 result.state = RequestState_default.UNISSUED; 4060 result.deferred = void 0; 4061 result.cancelled = false; 4062 return result; 4063}; 4064var Request_default = Request; 4065 4066// packages/engine/Source/Core/parseResponseHeaders.js 4067function parseResponseHeaders(headerString) { 4068 const headers = {}; 4069 if (!headerString) { 4070 return headers; 4071 } 4072 const headerPairs = headerString.split("\r\n"); 4073 for (let i = 0; i < headerPairs.length; ++i) { 4074 const headerPair = headerPairs[i]; 4075 const index = headerPair.indexOf(": "); 4076 if (index > 0) { 4077 const key = headerPair.substring(0, index); 4078 const val = headerPair.substring(index + 2); 4079 headers[key] = val; 4080 } 4081 } 4082 return headers; 4083} 4084var parseResponseHeaders_default = parseResponseHeaders; 4085 4086// packages/engine/Source/Core/RequestErrorEvent.js 4087function RequestErrorEvent(statusCode, response, responseHeaders) { 4088 this.statusCode = statusCode; 4089 this.response = response; 4090 this.responseHeaders = responseHeaders; 4091 if (typeof this.responseHeaders === "string") { 4092 this.responseHeaders = parseResponseHeaders_default(this.responseHeaders); 4093 } 4094} 4095RequestErrorEvent.prototype.toString = function() { 4096 let str = "Request has failed."; 4097 if (defined_default(this.statusCode)) { 4098 str += ` Status Code: ${this.statusCode}`; 4099 } 4100 return str; 4101}; 4102var RequestErrorEvent_default = RequestErrorEvent; 4103 4104// packages/engine/Source/Core/RequestScheduler.js 4105var import_urijs4 = __toESM(require_URI(), 1); 4106 4107// packages/engine/Source/Core/Event.js 4108function Event() { 4109 this._listeners = /* @__PURE__ */ new Map(); 4110 this._toRemove = /* @__PURE__ */ new Map(); 4111 this._toAdd = /* @__PURE__ */ new Map(); 4112 this._invokingListeners = false; 4113 this._listenerCount = 0; 4114} 4115Object.defineProperties(Event.prototype, { 4116 /** 4117 * The number of listeners currently subscribed to the event. 4118 * @memberof Event.prototype 4119 * @type {number} 4120 * @readonly 4121 */ 4122 numberOfListeners: { 4123 get: function() { 4124 return this._listenerCount; 4125 } 4126 } 4127}); 4128Event.prototype.addEventListener = function(listener, scope) { 4129 Check_default.typeOf.func("listener", listener); 4130 const event = this; 4131 const listenerMap = event._invokingListeners ? event._toAdd : event._listeners; 4132 const added = addEventListener(this, listenerMap, listener, scope); 4133 if (added) { 4134 event._listenerCount++; 4135 } 4136 return function() { 4137 event.removeEventListener(listener, scope); 4138 }; 4139}; 4140function addEventListener(event, listenerMap, listener, scope) { 4141 if (!listenerMap.has(listener)) { 4142 listenerMap.set(listener, /* @__PURE__ */ new Set()); 4143 } 4144 const scopes = listenerMap.get(listener); 4145 if (!scopes.has(scope)) { 4146 scopes.add(scope); 4147 return true; 4148 } 4149 return false; 4150} 4151Event.prototype.removeEventListener = function(listener, scope) { 4152 Check_default.typeOf.func("listener", listener); 4153 const removedFromListeners = removeEventListener( 4154 this, 4155 this._listeners, 4156 listener, 4157 scope 4158 ); 4159 const removedFromToAdd = removeEventListener( 4160 this, 4161 this._toAdd, 4162 listener, 4163 scope 4164 ); 4165 const removed = removedFromListeners || removedFromToAdd; 4166 if (removed) { 4167 this._listenerCount--; 4168 } 4169 return removed; 4170}; 4171function removeEventListener(event, listenerMap, listener, scope) { 4172 const scopes = listenerMap.get(listener); 4173 if (!scopes || !scopes.has(scope)) { 4174 return false; 4175 } 4176 if (event._invokingListeners) { 4177 if (!addEventListener(event, event._toRemove, listener, scope)) { 4178 return false; 4179 } 4180 } else { 4181 scopes.delete(scope); 4182 if (scopes.size === 0) { 4183 listenerMap.delete(listener); 4184 } 4185 } 4186 return true; 4187} 4188Event.prototype.raiseEvent = function() { 4189 this._invokingListeners = true; 4190 for (const [listener, scopes] of this._listeners.entries()) { 4191 if (!defined_default(listener)) { 4192 continue; 4193 } 4194 for (const scope of scopes) { 4195 listener.apply(scope, arguments); 4196 } 4197 } 4198 this._invokingListeners = false; 4199 for (const [listener, scopes] of this._toAdd.entries()) { 4200 for (const scope of scopes) { 4201 addEventListener(this, this._listeners, listener, scope); 4202 } 4203 } 4204 this._toAdd.clear(); 4205 for (const [listener, scopes] of this._toRemove.entries()) { 4206 for (const scope of scopes) { 4207 removeEventListener(this, this._listeners, listener, scope); 4208 } 4209 } 4210 this._toRemove.clear(); 4211}; 4212var Event_default = Event; 4213 4214// packages/engine/Source/Core/Heap.js 4215function Heap(options) { 4216 Check_default.typeOf.object("options", options); 4217 Check_default.defined("options.comparator", options.comparator); 4218 this._comparator = options.comparator; 4219 this._array = []; 4220 this._length = 0; 4221 this._maximumLength = void 0; 4222} 4223Object.defineProperties(Heap.prototype, { 4224 /** 4225 * Gets the length of the heap. 4226 * 4227 * @memberof Heap.prototype 4228 * 4229 * @type {number} 4230 * @readonly 4231 */ 4232 length: { 4233 get: function() { 4234 return this._length; 4235 } 4236 }, 4237 /** 4238 * Gets the internal array. 4239 * 4240 * @memberof Heap.prototype 4241 * 4242 * @type {Array} 4243 * @readonly 4244 */ 4245 internalArray: { 4246 get: function() { 4247 return this._array; 4248 } 4249 }, 4250 /** 4251 * Gets and sets the maximum length of the heap. 4252 * 4253 * @memberof Heap.prototype 4254 * 4255 * @type {number} 4256 */ 4257 maximumLength: { 4258 get: function() { 4259 return this._maximumLength; 4260 }, 4261 set: function(value) { 4262 Check_default.typeOf.number.greaterThanOrEquals("maximumLength", value, 0); 4263 const originalLength = this._length; 4264 if (value < originalLength) { 4265 const array = this._array; 4266 for (let i = value; i < originalLength; ++i) { 4267 array[i] = void 0; 4268 } 4269 this._length = value; 4270 array.length = value; 4271 } 4272 this._maximumLength = value; 4273 } 4274 }, 4275 /** 4276 * The comparator to use for the heap. If comparator(a, b) is less than 0, sort a to a lower index than b, otherwise sort to a higher index. 4277 * 4278 * @memberof Heap.prototype 4279 * 4280 * @type {Heap.ComparatorCallback} 4281 */ 4282 comparator: { 4283 get: function() { 4284 return this._comparator; 4285 } 4286 } 4287}); 4288function swap(array, a3, b) { 4289 const temp = array[a3]; 4290 array[a3] = array[b]; 4291 array[b] = temp; 4292} 4293Heap.prototype.reserve = function(length) { 4294 length = length ?? this._length; 4295 this._array.length = length; 4296}; 4297Heap.prototype.heapify = function(index) { 4298 index = index ?? 0; 4299 const length = this._length; 4300 const comparator = this._comparator; 4301 const array = this._array; 4302 let candidate; 4303 let inserting = true; 4304 while (inserting) { 4305 const right = 2 * (index + 1); 4306 const left = right - 1; 4307 if (left < length && comparator(array[left], array[index]) < 0) { 4308 candidate = left; 4309 } else { 4310 candidate = index; 4311 } 4312 if (right < length && comparator(array[right], array[candidate]) < 0) { 4313 candidate = right; 4314 } 4315 if (candidate !== index) { 4316 swap(array, candidate, index); 4317 index = candidate; 4318 } else { 4319 inserting = false; 4320 } 4321 } 4322}; 4323Heap.prototype.resort = function() { 4324 const length = this._length; 4325 for (let i = Math.ceil(length / 2); i >= 0; --i) { 4326 this.heapify(i); 4327 } 4328}; 4329Heap.prototype.insert = function(element) { 4330 Check_default.defined("element", element); 4331 const array = this._array; 4332 const comparator = this._comparator; 4333 const maximumLength = this._maximumLength; 4334 let index = this._length++; 4335 if (index < array.length) { 4336 array[index] = element; 4337 } else { 4338 array.push(element); 4339 } 4340 while (index !== 0) { 4341 const parent = Math.floor((index - 1) / 2); 4342 if (comparator(array[index], array[parent]) < 0) { 4343 swap(array, index, parent); 4344 index = parent; 4345 } else { 4346 break; 4347 } 4348 } 4349 let removedElement; 4350 if (defined_default(maximumLength) && this._length > maximumLength) { 4351 removedElement = array[maximumLength]; 4352 this._length = maximumLength; 4353 } 4354 return removedElement; 4355}; 4356Heap.prototype.pop = function(index) { 4357 index = index ?? 0; 4358 if (this._length === 0) { 4359 return void 0; 4360 } 4361 Check_default.typeOf.number.lessThan("index", index, this._length); 4362 const array = this._array; 4363 const root = array[index]; 4364 swap(array, index, --this._length); 4365 this.heapify(index); 4366 array[this._length] = void 0; 4367 return root; 4368}; 4369var Heap_default = Heap; 4370 4371// packages/engine/Source/Core/RequestScheduler.js 4372function sortRequests(a3, b) { 4373 return a3.priority - b.priority; 4374} 4375var statistics = { 4376 numberOfAttemptedRequests: 0, 4377 numberOfActiveRequests: 0, 4378 numberOfCancelledRequests: 0, 4379 numberOfCancelledActiveRequests: 0, 4380 numberOfFailedRequests: 0, 4381 numberOfActiveRequestsEver: 0, 4382 lastNumberOfActiveRequests: 0 4383}; 4384var priorityHeapLength = 20; 4385var requestHeap = new Heap_default({ 4386 comparator: sortRequests 4387}); 4388requestHeap.maximumLength = priorityHeapLength; 4389requestHeap.reserve(priorityHeapLength); 4390var activeRequests = []; 4391var numberOfActiveRequestsByServer = {}; 4392var pageUri = typeof document !== "undefined" ? new import_urijs4.default(document.location.href) : new import_urijs4.default(); 4393var requestCompletedEvent = new Event_default(); 4394function RequestScheduler() { 4395} 4396RequestScheduler.maximumRequests = 50; 4397RequestScheduler.maximumRequestsPerServer = 18; 4398RequestScheduler.requestsByServer = {}; 4399RequestScheduler.throttleRequests = true; 4400RequestScheduler.debugShowStatistics = false; 4401RequestScheduler.requestCompletedEvent = requestCompletedEvent; 4402Object.defineProperties(RequestScheduler, { 4403 /** 4404 * Returns the statistics used by the request scheduler. 4405 * 4406 * @memberof RequestScheduler 4407 * 4408 * @type {object} 4409 * @readonly 4410 * @private 4411 */ 4412 statistics: { 4413 get: function() { 4414 return statistics; 4415 } 4416 }, 4417 /** 4418 * The maximum size of the priority heap. This limits the number of requests that are sorted by priority. Only applies to requests that are not yet active. 4419 * 4420 * @memberof RequestScheduler 4421 * 4422 * @type {number} 4423 * @default 20 4424 * @private 4425 */ 4426 priorityHeapLength: { 4427 get: function() { 4428 return priorityHeapLength; 4429 }, 4430 set: function(value) { 4431 if (value < priorityHeapLength) { 4432 while (requestHeap.length > value) { 4433 const request = requestHeap.pop(); 4434 cancelRequest(request); 4435 } 4436 } 4437 priorityHeapLength = value; 4438 requestHeap.maximumLength = value; 4439 requestHeap.reserve(value); 4440 } 4441 } 4442}); 4443function updatePriority(request) { 4444 if (defined_default(request.priorityFunction)) { 4445 request.priority = request.priorityFunction(); 4446 } 4447} 4448RequestScheduler.serverHasOpenSlots = function(serverKey, desiredRequests) { 4449 desiredRequests = desiredRequests ?? 1; 4450 const maxRequests = RequestScheduler.requestsByServer[serverKey] ?? RequestScheduler.maximumRequestsPerServer; 4451 const hasOpenSlotsServer = numberOfActiveRequestsByServer[serverKey] + desiredRequests <= maxRequests; 4452 return hasOpenSlotsServer; 4453}; 4454RequestScheduler.heapHasOpenSlots = function(desiredRequests) { 4455 const hasOpenSlotsHeap = requestHeap.length + desiredRequests <= priorityHeapLength; 4456 return hasOpenSlotsHeap; 4457}; 4458function issueRequest(request) { 4459 if (request.state === RequestState_default.UNISSUED) { 4460 request.state = RequestState_default.ISSUED; 4461 request.deferred = defer_default(); 4462 } 4463 return request.deferred.promise; 4464} 4465function getRequestReceivedFunction(request) { 4466 return function(results) { 4467 if (request.state === RequestState_default.CANCELLED) { 4468 return; 4469 } 4470 const deferred = request.deferred; 4471 --statistics.numberOfActiveRequests; 4472 --numberOfActiveRequestsByServer[request.serverKey]; 4473 requestCompletedEvent.raiseEvent(); 4474 request.state = RequestState_default.RECEIVED; 4475 request.deferred = void 0; 4476 deferred.resolve(results); 4477 }; 4478} 4479function getRequestFailedFunction(request) { 4480 return function(error) { 4481 if (request.state === RequestState_default.CANCELLED) { 4482 return; 4483 } 4484 ++statistics.numberOfFailedRequests; 4485 --statistics.numberOfActiveRequests; 4486 --numberOfActiveRequestsByServer[request.serverKey]; 4487 requestCompletedEvent.raiseEvent(error); 4488 request.state = RequestState_default.FAILED; 4489 request.deferred.reject(error); 4490 }; 4491} 4492function startRequest(request) { 4493 const promise = issueRequest(request); 4494 request.state = RequestState_default.ACTIVE; 4495 activeRequests.push(request); 4496 ++statistics.numberOfActiveRequests; 4497 ++statistics.numberOfActiveRequestsEver; 4498 ++numberOfActiveRequestsByServer[request.serverKey]; 4499 request.requestFunction().then(getRequestReceivedFunction(request)).catch(getRequestFailedFunction(request)); 4500 return promise; 4501} 4502function cancelRequest(request) { 4503 const active = request.state === RequestState_default.ACTIVE; 4504 request.state = RequestState_default.CANCELLED; 4505 ++statistics.numberOfCancelledRequests; 4506 if (defined_default(request.deferred)) { 4507 const deferred = request.deferred; 4508 deferred.promise.catch(() => { 4509 }); 4510 request.deferred = void 0; 4511 deferred.reject(new RuntimeError_default(`Request cancelled: "${request.url}"`)); 4512 } 4513 if (active) { 4514 --statistics.numberOfActiveRequests; 4515 --numberOfActiveRequestsByServer[request.serverKey]; 4516 ++statistics.numberOfCancelledActiveRequests; 4517 } 4518 if (defined_default(request.cancelFunction)) { 4519 request.cancelFunction(); 4520 } 4521} 4522RequestScheduler.update = function() { 4523 let i; 4524 let request; 4525 let removeCount = 0; 4526 const activeLength = activeRequests.length; 4527 for (i = 0; i < activeLength; ++i) { 4528 request = activeRequests[i]; 4529 if (request.cancelled) { 4530 cancelRequest(request); 4531 } 4532 if (request.state !== RequestState_default.ACTIVE) { 4533 ++removeCount; 4534 continue; 4535 } 4536 if (removeCount > 0) { 4537 activeRequests[i - removeCount] = request; 4538 } 4539 } 4540 activeRequests.length -= removeCount; 4541 const issuedRequests = requestHeap.internalArray; 4542 const issuedLength = requestHeap.length; 4543 for (i = 0; i < issuedLength; ++i) { 4544 updatePriority(issuedRequests[i]); 4545 } 4546 requestHeap.resort(); 4547 const openSlots = Math.max( 4548 RequestScheduler.maximumRequests - activeRequests.length, 4549 0 4550 ); 4551 let filledSlots = 0; 4552 while (filledSlots < openSlots && requestHeap.length > 0) { 4553 request = requestHeap.pop(); 4554 if (request.cancelled) { 4555 cancelRequest(request); 4556 continue; 4557 } 4558 if (request.throttleByServer && !RequestScheduler.serverHasOpenSlots(request.serverKey)) { 4559 cancelRequest(request); 4560 continue; 4561 } 4562 startRequest(request); 4563 ++filledSlots; 4564 } 4565 updateStatistics(); 4566}; 4567RequestScheduler.getServerKey = function(url) { 4568 Check_default.typeOf.string("url", url); 4569 let uri = new import_urijs4.default(url); 4570 if (uri.scheme() === "") { 4571 uri = uri.absoluteTo(pageUri); 4572 uri.normalize(); 4573 } 4574 let serverKey = uri.authority(); 4575 if (!/:/.test(serverKey)) { 4576 serverKey = `${serverKey}:${uri.scheme() === "https" ? "443" : "80"}`; 4577 } 4578 const length = numberOfActiveRequestsByServer[serverKey]; 4579 if (!defined_default(length)) { 4580 numberOfActiveRequestsByServer[serverKey] = 0; 4581 } 4582 return serverKey; 4583}; 4584RequestScheduler.request = function(request) { 4585 Check_default.typeOf.object("request", request); 4586 Check_default.typeOf.string("request.url", request.url); 4587 Check_default.typeOf.func("request.requestFunction", request.requestFunction); 4588 if (isDataUri_default(request.url) || isBlobUri_default(request.url)) { 4589 requestCompletedEvent.raiseEvent(); 4590 request.state = RequestState_default.RECEIVED; 4591 return request.requestFunction(); 4592 } 4593 ++statistics.numberOfAttemptedRequests; 4594 if (!defined_default(request.serverKey)) { 4595 request.serverKey = RequestScheduler.getServerKey(request.url); 4596 } 4597 if (RequestScheduler.throttleRequests && request.throttleByServer && !RequestScheduler.serverHasOpenSlots(request.serverKey)) { 4598 return void 0; 4599 } 4600 if (!RequestScheduler.throttleRequests || !request.throttle) { 4601 return startRequest(request); 4602 } 4603 if (activeRequests.length >= RequestScheduler.maximumRequests) { 4604 return void 0; 4605 } 4606 updatePriority(request); 4607 const removedRequest = requestHeap.insert(request); 4608 if (defined_default(removedRequest)) { 4609 if (removedRequest === request) { 4610 return void 0; 4611 } 4612 cancelRequest(removedRequest); 4613 } 4614 return issueRequest(request); 4615}; 4616function updateStatistics() { 4617 if (!RequestScheduler.debugShowStatistics) { 4618 return; 4619 } 4620 if (statistics.numberOfActiveRequests === 0 && statistics.lastNumberOfActiveRequests > 0) { 4621 if (statistics.numberOfAttemptedRequests > 0) { 4622 console.log( 4623 `Number of attempted requests: ${statistics.numberOfAttemptedRequests}` 4624 ); 4625 statistics.numberOfAttemptedRequests = 0; 4626 } 4627 if (statistics.numberOfCancelledRequests > 0) { 4628 console.log( 4629 `Number of cancelled requests: ${statistics.numberOfCancelledRequests}` 4630 ); 4631 statistics.numberOfCancelledRequests = 0; 4632 } 4633 if (statistics.numberOfCancelledActiveRequests > 0) { 4634 console.log( 4635 `Number of cancelled active requests: ${statistics.numberOfCancelledActiveRequests}` 4636 ); 4637 statistics.numberOfCancelledActiveRequests = 0; 4638 } 4639 if (statistics.numberOfFailedRequests > 0) { 4640 console.log( 4641 `Number of failed requests: ${statistics.numberOfFailedRequests}` 4642 ); 4643 statistics.numberOfFailedRequests = 0; 4644 } 4645 } 4646 statistics.lastNumberOfActiveRequests = statistics.numberOfActiveRequests; 4647} 4648RequestScheduler.clearForSpecs = function() { 4649 while (requestHeap.length > 0) { 4650 const request = requestHeap.pop(); 4651 cancelRequest(request); 4652 } 4653 const length = activeRequests.length; 4654 for (let i = 0; i < length; ++i) { 4655 cancelRequest(activeRequests[i]); 4656 } 4657 activeRequests.length = 0; 4658 numberOfActiveRequestsByServer = {}; 4659 statistics.numberOfAttemptedRequests = 0; 4660 statistics.numberOfActiveRequests = 0; 4661 statistics.numberOfCancelledRequests = 0; 4662 statistics.numberOfCancelledActiveRequests = 0; 4663 statistics.numberOfFailedRequests = 0; 4664 statistics.numberOfActiveRequestsEver = 0; 4665 statistics.lastNumberOfActiveRequests = 0; 4666}; 4667RequestScheduler.numberOfActiveRequestsByServer = function(serverKey) { 4668 return numberOfActiveRequestsByServer[serverKey]; 4669}; 4670RequestScheduler.requestHeap = requestHeap; 4671var RequestScheduler_default = RequestScheduler; 4672 4673// packages/engine/Source/Core/TrustedServers.js 4674var import_urijs5 = __toESM(require_URI(), 1); 4675var TrustedServers = {}; 4676var _servers = {}; 4677TrustedServers.add = function(host, port) { 4678 if (!defined_default(host)) { 4679 throw new DeveloperError_default("host is required."); 4680 } 4681 if (!defined_default(port) || port <= 0) { 4682 throw new DeveloperError_default("port is required to be greater than 0."); 4683 } 4684 const authority = `${host.toLowerCase()}:${port}`; 4685 if (!defined_default(_servers[authority])) { 4686 _servers[authority] = true; 4687 } 4688}; 4689TrustedServers.remove = function(host, port) { 4690 if (!defined_default(host)) { 4691 throw new DeveloperError_default("host is required."); 4692 } 4693 if (!defined_default(port) || port <= 0) { 4694 throw new DeveloperError_default("port is required to be greater than 0."); 4695 } 4696 const authority = `${host.toLowerCase()}:${port}`; 4697 if (defined_default(_servers[authority])) { 4698 delete _servers[authority]; 4699 } 4700}; 4701function getAuthority(url) { 4702 const uri = new import_urijs5.default(url); 4703 uri.normalize(); 4704 let authority = uri.authority(); 4705 if (authority.length === 0) { 4706 return void 0; 4707 } 4708 uri.authority(authority); 4709 if (authority.indexOf("@") !== -1) { 4710 const parts = authority.split("@"); 4711 authority = parts[1]; 4712 } 4713 if (authority.indexOf(":") === -1) { 4714 let scheme = uri.scheme(); 4715 if (scheme.length === 0) { 4716 scheme = window.location.protocol; 4717 scheme = scheme.substring(0, scheme.length - 1); 4718 } 4719 if (scheme === "http") { 4720 authority += ":80"; 4721 } else if (scheme === "https") { 4722 authority += ":443"; 4723 } else { 4724 return void 0; 4725 } 4726 } 4727 return authority; 4728} 4729TrustedServers.contains = function(url) { 4730 if (!defined_default(url)) { 4731 throw new DeveloperError_default("url is required."); 4732 } 4733 const authority = getAuthority(url); 4734 if (defined_default(authority) && defined_default(_servers[authority])) { 4735 return true; 4736 } 4737 return false; 4738}; 4739TrustedServers.clear = function() { 4740 _servers = {}; 4741}; 4742var TrustedServers_default = TrustedServers; 4743 4744// packages/engine/Source/Core/Resource.js 4745var xhrBlobSupported = (function() { 4746 try { 4747 const xhr = new XMLHttpRequest(); 4748 xhr.open("GET", "#", true); 4749 xhr.responseType = "blob"; 4750 return xhr.responseType === "blob"; 4751 } catch (e) { 4752 return false; 4753 } 4754})(); 4755function Resource(options) { 4756 options = options ?? Frozen_default.EMPTY_OBJECT; 4757 if (typeof options === "string") { 4758 options = { 4759 url: options 4760 }; 4761 } 4762 Check_default.typeOf.string("options.url", options.url); 4763 this._url = void 0; 4764 this._templateValues = defaultClone(options.templateValues, {}); 4765 this._queryParameters = defaultClone(options.queryParameters, {}); 4766 this.headers = defaultClone(options.headers, {}); 4767 this.request = options.request ?? new Request_default(); 4768 this.proxy = options.proxy; 4769 this.retryCallback = options.retryCallback; 4770 this.retryAttempts = options.retryAttempts ?? 0; 4771 this._retryCount = 0; 4772 const parseUrl = options.parseUrl ?? true; 4773 if (parseUrl) { 4774 this.parseUrl(options.url, true, true); 4775 } else { 4776 this._url = options.url; 4777 } 4778 this._credits = options.credits; 4779} 4780function defaultClone(value, defaultValue) { 4781 return defined_default(value) ? clone_default(value) : defaultValue; 4782} 4783Resource.createIfNeeded = function(resource) { 4784 if (resource instanceof Resource) { 4785 return resource.getDerivedResource({ 4786 request: resource.request 4787 }); 4788 } 4789 if (typeof resource !== "string") { 4790 return resource; 4791 } 4792 return new Resource({ 4793 url: resource 4794 }); 4795}; 4796var supportsImageBitmapOptionsPromise; 4797Resource.supportsImageBitmapOptions = function() { 4798 if (defined_default(supportsImageBitmapOptionsPromise)) { 4799 return supportsImageBitmapOptionsPromise; 4800 } 4801 if (typeof createImageBitmap !== "function") { 4802 supportsImageBitmapOptionsPromise = Promise.resolve(false); 4803 return supportsImageBitmapOptionsPromise; 4804 } 4805 const imageDataUri = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAABGdBTUEAAE4g3rEiDgAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAADElEQVQI12Ng6GAAAAEUAIngE3ZiAAAAAElFTkSuQmCC"; 4806 supportsImageBitmapOptionsPromise = Resource.fetchBlob({ 4807 url: imageDataUri 4808 }).then(function(blob) { 4809 const imageBitmapOptions = { 4810 // 'from-image' is deprecated, new option is 'none'. However, we still need to support older browsers, 4811 // and there's no good way to detect support for these options. For now, continue to use 'from-image'. See: https://github.com/CesiumGS/cesium/issues/12846 4812 imageOrientation: "flipY", 4813 // default is "from-image" 4814 premultiplyAlpha: "none", 4815 // default is "default" 4816 colorSpaceConversion: "none" 4817 // default is "default" 4818 }; 4819 return Promise.all([ 4820 createImageBitmap(blob, imageBitmapOptions), 4821 createImageBitmap(blob) 4822 ]); 4823 }).then(function(imageBitmaps) { 4824 const colorWithOptions = getImagePixels_default(imageBitmaps[0]); 4825 const colorWithDefaults = getImagePixels_default(imageBitmaps[1]); 4826 return colorWithOptions[1] !== colorWithDefaults[1]; 4827 }).catch(function() { 4828 return false; 4829 }); 4830 return supportsImageBitmapOptionsPromise; 4831}; 4832Object.defineProperties(Resource, { 4833 /** 4834 * Returns true if blobs are supported. 4835 * 4836 * @memberof Resource 4837 * @type {boolean} 4838 * 4839 * @readonly 4840 */ 4841 isBlobSupported: { 4842 get: function() { 4843 return xhrBlobSupported; 4844 } 4845 } 4846}); 4847Object.defineProperties(Resource.prototype, { 4848 /** 4849 * Query parameters appended to the url. 4850 * 4851 * @memberof Resource.prototype 4852 * @type {object} 4853 * 4854 * @readonly 4855 */ 4856 queryParameters: { 4857 get: function() { 4858 return this._queryParameters; 4859 } 4860 }, 4861 /** 4862 * The key/value pairs used to replace template parameters in the url. 4863 * 4864 * @memberof Resource.prototype 4865 * @type {object} 4866 * 4867 * @readonly 4868 */ 4869 templateValues: { 4870 get: function() { 4871 return this._templateValues; 4872 } 4873 }, 4874 /** 4875 * The url to the resource with template values replaced, query string appended and encoded by proxy if one was set. 4876 * 4877 * @memberof Resource.prototype 4878 * @type {string} 4879 */ 4880 url: { 4881 get: function() { 4882 return this.getUrlComponent(true, true); 4883 }, 4884 set: function(value) { 4885 this.parseUrl(value, false, false); 4886 } 4887 }, 4888 /** 4889 * The file extension of the resource. 4890 * 4891 * @memberof Resource.prototype 4892 * @type {string} 4893 * 4894 * @readonly 4895 */ 4896 extension: { 4897 get: function() { 4898 return getExtensionFromUri_default(this._url); 4899 } 4900 }, 4901 /** 4902 * True if the Resource refers to a data URI. 4903 * 4904 * @memberof Resource.prototype 4905 * @type {boolean} 4906 */ 4907 isDataUri: { 4908 get: function() { 4909 return isDataUri_default(this._url); 4910 } 4911 }, 4912 /** 4913 * True if the Resource refers to a blob URI. 4914 * 4915 * @memberof Resource.prototype 4916 * @type {boolean} 4917 */ 4918 isBlobUri: { 4919 get: function() { 4920 return isBlobUri_default(this._url); 4921 } 4922 }, 4923 /** 4924 * True if the Resource refers to a cross origin URL. 4925 * 4926 * @memberof Resource.prototype 4927 * @type {boolean} 4928 */ 4929 isCrossOriginUrl: { 4930 get: function() { 4931 return isCrossOriginUrl_default(this._url); 4932 } 4933 }, 4934 /** 4935 * True if the Resource has request headers. This is equivalent to checking if the headers property has any keys. 4936 * 4937 * @memberof Resource.prototype 4938 * @type {boolean} 4939 */ 4940 hasHeaders: { 4941 get: function() { 4942 return Object.keys(this.headers).length > 0; 4943 } 4944 }, 4945 /** 4946 * Gets the credits required for attribution of an asset. 4947 * @private 4948 */ 4949 credits: { 4950 get: function() { 4951 return this._credits; 4952 } 4953 } 4954}); 4955Resource.prototype.toString = function() { 4956 return this.getUrlComponent(true, true); 4957}; 4958Resource.prototype.parseUrl = function(url, merge, preserveQuery, baseUrl) { 4959 let uri = new import_urijs6.default(url); 4960 const query = parseQueryString(uri.query()); 4961 this._queryParameters = merge ? combineQueryParameters(query, this.queryParameters, preserveQuery) : query; 4962 uri.search(""); 4963 uri.fragment(""); 4964 if (defined_default(baseUrl) && uri.scheme() === "") { 4965 uri = uri.absoluteTo(getAbsoluteUri_default(baseUrl)); 4966 } 4967 this._url = uri.toString(); 4968}; 4969function parseQueryString(queryString) { 4970 if (queryString.length === 0) { 4971 return {}; 4972 } 4973 if (queryString.indexOf("=") === -1) { 4974 return { [queryString]: void 0 }; 4975 } 4976 return queryToObject_default(queryString); 4977} 4978function combineQueryParameters(q1, q2, preserveQueryParameters) { 4979 if (!preserveQueryParameters) { 4980 return combine_default(q1, q2); 4981 } 4982 const result = clone_default(q1, true); 4983 for (const param in q2) { 4984 if (q2.hasOwnProperty(param)) { 4985 let value = result[param]; 4986 const q2Value = q2[param]; 4987 if (defined_default(value)) { 4988 if (!Array.isArray(value)) { 4989 value = result[param] = [value]; 4990 } 4991 result[param] = value.concat(q2Value); 4992 } else { 4993 result[param] = Array.isArray(q2Value) ? q2Value.slice() : q2Value; 4994 } 4995 } 4996 } 4997 return result; 4998} 4999Resource.prototype.getUrlComponent = function(query, proxy) { 5000 if (this.isDataUri) { 5001 return this._url; 5002 } 5003 let url = this._url; 5004 if (query) { 5005 url = `${url}${stringifyQuery(this.queryParameters)}`; 5006 } 5007 url = url.replace(/%7B/g, "{").replace(/%7D/g, "}"); 5008 const templateValues = this._templateValues; 5009 if (Object.keys(templateValues).length > 0) { 5010 url = url.replace(/{(.*?)}/g, function(match, key) { 5011 const replacement = templateValues[key]; 5012 if (defined_default(replacement)) { 5013 return encodeURIComponent(replacement); 5014 } 5015 return match; 5016 }); 5017 } 5018 if (proxy && defined_default(this.proxy)) { 5019 url = this.proxy.getURL(url); 5020 } 5021 return url; 5022}; 5023function stringifyQuery(queryObject) { 5024 const keys = Object.keys(queryObject); 5025 if (keys.length === 0) { 5026 return ""; 5027 } 5028 if (keys.length === 1 && !defined_default(queryObject[keys[0]])) { 5029 return `?${keys[0]}`; 5030 } 5031 return `?${objectToQuery_default(queryObject)}`; 5032} 5033Resource.prototype.setQueryParameters = function(params, useAsDefault) { 5034 if (useAsDefault) { 5035 this._queryParameters = combineQueryParameters( 5036 this._queryParameters, 5037 params, 5038 false 5039 ); 5040 } else { 5041 this._queryParameters = combineQueryParameters( 5042 params, 5043 this._queryParameters, 5044 false 5045 ); 5046 } 5047}; 5048Resource.prototype.appendQueryParameters = function(params) { 5049 this._queryParameters = combineQueryParameters( 5050 params, 5051 this._queryParameters, 5052 true 5053 ); 5054}; 5055Resource.prototype.setTemplateValues = function(template, useAsDefault) { 5056 if (useAsDefault) { 5057 this._templateValues = combine_default(this._templateValues, template); 5058 } else { 5059 this._templateValues = combine_default(template, this._templateValues); 5060 } 5061}; 5062Resource.prototype.getDerivedResource = function(options) { 5063 const resource = this.clone(); 5064 resource._retryCount = 0; 5065 if (defined_default(options.url)) { 5066 const preserveQuery = options.preserveQueryParameters ?? false; 5067 resource.parseUrl(options.url, true, preserveQuery, this._url); 5068 } 5069 if (defined_default(options.queryParameters)) { 5070 resource._queryParameters = combine_default( 5071 options.queryParameters, 5072 resource.queryParameters 5073 ); 5074 } 5075 if (defined_default(options.templateValues)) { 5076 resource._templateValues = combine_default( 5077 options.templateValues, 5078 resource.templateValues 5079 ); 5080 } 5081 if (defined_default(options.headers)) { 5082 resource.headers = combine_default(options.headers, resource.headers); 5083 } 5084 if (defined_default(options.proxy)) { 5085 resource.proxy = options.proxy; 5086 } 5087 if (defined_default(options.request)) { 5088 resource.request = options.request; 5089 } 5090 if (defined_default(options.retryCallback)) { 5091 resource.retryCallback = options.retryCallback; 5092 } 5093 if (defined_default(options.retryAttempts)) { 5094 resource.retryAttempts = options.retryAttempts; 5095 } 5096 return resource; 5097}; 5098Resource.prototype.retryOnError = function(error) { 5099 const retryCallback = this.retryCallback; 5100 if (typeof retryCallback !== "function" || this._retryCount >= this.retryAttempts) { 5101 return Promise.resolve(false); 5102 } 5103 const that = this; 5104 return Promise.resolve(retryCallback(this, error)).then(function(result) { 5105 ++that._retryCount; 5106 return result; 5107 }); 5108}; 5109Resource.prototype.clone = function(result) { 5110 if (!defined_default(result)) { 5111 return new Resource({ 5112 url: this._url, 5113 queryParameters: this.queryParameters, 5114 templateValues: this.templateValues, 5115 headers: this.headers, 5116 proxy: this.proxy, 5117 retryCallback: this.retryCallback, 5118 retryAttempts: this.retryAttempts, 5119 request: this.request.clone(), 5120 parseUrl: false, 5121 credits: defined_default(this.credits) ? this.credits.slice() : void 0 5122 }); 5123 } 5124 result._url = this._url; 5125 result._queryParameters = clone_default(this._queryParameters); 5126 result._templateValues = clone_default(this._templateValues); 5127 result.headers = clone_default(this.headers); 5128 result.proxy = this.proxy; 5129 result.retryCallback = this.retryCallback; 5130 result.retryAttempts = this.retryAttempts; 5131 result._retryCount = 0; 5132 result.request = this.request.clone(); 5133 return result; 5134}; 5135Resource.prototype.getBaseUri = function(includeQuery) { 5136 return getBaseUri_default(this.getUrlComponent(includeQuery), includeQuery); 5137}; 5138Resource.prototype.appendForwardSlash = function() { 5139 this._url = appendForwardSlash_default(this._url); 5140}; 5141Resource.prototype.fetchArrayBuffer = function() { 5142 return this.fetch({ 5143 responseType: "arraybuffer" 5144 }); 5145}; 5146Resource.fetchArrayBuffer = function(options) { 5147 const resource = new Resource(options); 5148 return resource.fetchArrayBuffer(); 5149}; 5150Resource.prototype.fetchBlob = function() { 5151 return this.fetch({ 5152 responseType: "blob" 5153 }); 5154}; 5155Resource.fetchBlob = function(options) { 5156 const resource = new Resource(options); 5157 return resource.fetchBlob(); 5158}; 5159Resource.prototype.fetchImage = function(options) { 5160 options = options ?? Frozen_default.EMPTY_OBJECT; 5161 const preferImageBitmap = options.preferImageBitmap ?? false; 5162 const preferBlob = options.preferBlob ?? false; 5163 const flipY = options.flipY ?? false; 5164 const skipColorSpaceConversion = options.skipColorSpaceConversion ?? false; 5165 checkAndResetRequest(this.request); 5166 if (!xhrBlobSupported || this.isDataUri || this.isBlobUri || !this.hasHeaders && !preferBlob) { 5167 return this._fetchImage({ 5168 resource: this, 5169 flipY, 5170 skipColorSpaceConversion, 5171 preferImageBitmap 5172 }); 5173 } 5174 const blobPromise = this.fetchBlob(); 5175 if (!defined_default(blobPromise)) { 5176 return; 5177 } 5178 let supportsImageBitmap; 5179 let useImageBitmap; 5180 let generatedBlobResource; 5181 let generatedBlob; 5182 return Resource.supportsImageBitmapOptions().then(function(result) { 5183 supportsImageBitmap = result; 5184 useImageBitmap = supportsImageBitmap && preferImageBitmap; 5185 return blobPromise; 5186 }).then(function(blob) { 5187 if (!defined_default(blob)) { 5188 return; 5189 } 5190 generatedBlob = blob; 5191 if (useImageBitmap) { 5192 return Resource.createImageBitmapFromBlob(blob, { 5193 flipY, 5194 premultiplyAlpha: false, 5195 skipColorSpaceConversion 5196 }); 5197 } 5198 const blobUrl = window.URL.createObjectURL(blob); 5199 generatedBlobResource = new Resource({ 5200 url: blobUrl 5201 }); 5202 return generatedBlobResource._fetchImage({ 5203 flipY, 5204 skipColorSpaceConversion, 5205 preferImageBitmap: false 5206 }); 5207 }).then(function(image) { 5208 if (!defined_default(image)) { 5209 return; 5210 } 5211 image.blob = generatedBlob; 5212 if (useImageBitmap) { 5213 return image; 5214 } 5215 window.URL.revokeObjectURL(generatedBlobResource.url); 5216 return image; 5217 }).catch(function(error) { 5218 if (defined_default(generatedBlobResource)) { 5219 window.URL.revokeObjectURL(generatedBlobResource.url); 5220 } 5221 error.blob = generatedBlob; 5222 return Promise.reject(error); 5223 }); 5224}; 5225Resource.prototype._fetchImage = function(options) { 5226 const resource = this; 5227 const flipY = options.flipY; 5228 const skipColorSpaceConversion = options.skipColorSpaceConversion; 5229 const preferImageBitmap = options.preferImageBitmap; 5230 const request = resource.request; 5231 request.url = resource.url; 5232 request.requestFunction = function() { 5233 let crossOrigin = false; 5234 if (!resource.isDataUri && !resource.isBlobUri) { 5235 crossOrigin = resource.isCrossOriginUrl; 5236 } 5237 const deferred = defer_default(); 5238 Resource._Implementations.createImage( 5239 request, 5240 crossOrigin, 5241 deferred, 5242 flipY, 5243 skipColorSpaceConversion, 5244 preferImageBitmap 5245 ); 5246 return deferred.promise; 5247 }; 5248 const promise = RequestScheduler_default.request(request); 5249 if (!defined_default(promise)) { 5250 return; 5251 } 5252 return promise.catch(function(e) { 5253 if (request.state !== RequestState_default.FAILED) { 5254 return Promise.reject(e); 5255 } 5256 return resource.retryOnError(e).then(function(retry) { 5257 if (retry) { 5258 request.state = RequestState_default.UNISSUED; 5259 request.deferred = void 0; 5260 return resource._fetchImage({ 5261 flipY, 5262 skipColorSpaceConversion, 5263 preferImageBitmap 5264 }); 5265 } 5266 return Promise.reject(e); 5267 }); 5268 }); 5269}; 5270Resource.fetchImage = function(options) { 5271 const resource = new Resource(options); 5272 return resource.fetchImage({ 5273 flipY: options.flipY, 5274 skipColorSpaceConversion: options.skipColorSpaceConversion, 5275 preferBlob: options.preferBlob, 5276 preferImageBitmap: options.preferImageBitmap 5277 }); 5278}; 5279Resource.prototype.fetchText = function() { 5280 return this.fetch({ 5281 responseType: "text" 5282 }); 5283}; 5284Resource.fetchText = function(options) { 5285 const resource = new Resource(options); 5286 return resource.fetchText(); 5287}; 5288Resource.prototype.fetchJson = function() { 5289 const promise = this.fetch({ 5290 responseType: "text", 5291 headers: { 5292 Accept: "application/json,*/*;q=0.01" 5293 } 5294 }); 5295 if (!defined_default(promise)) { 5296 return void 0; 5297 } 5298 return promise.then(function(value) { 5299 if (!defined_default(value)) { 5300 return; 5301 } 5302 return JSON.parse(value); 5303 }); 5304}; 5305Resource.fetchJson = function(options) { 5306 const resource = new Resource(options); 5307 return resource.fetchJson(); 5308}; 5309Resource.prototype.fetchXML = function() { 5310 return this.fetch({ 5311 responseType: "document", 5312 overrideMimeType: "text/xml" 5313 }); 5314}; 5315Resource.fetchXML = function(options) { 5316 const resource = new Resource(options); 5317 return resource.fetchXML(); 5318}; 5319Resource.prototype.fetchJsonp = function(callbackParameterName) { 5320 callbackParameterName = callbackParameterName ?? "callback"; 5321 checkAndResetRequest(this.request); 5322 let functionName; 5323 do { 5324 functionName = `loadJsonp${Math_default.nextRandomNumber().toString().substring(2, 8)}`; 5325 } while (defined_default(window[functionName])); 5326 return fetchJsonp(this, callbackParameterName, functionName); 5327}; 5328function fetchJsonp(resource, callbackParameterName, functionName) { 5329 const callbackQuery = {}; 5330 callbackQuery[callbackParameterName] = functionName; 5331 resource.setQueryParameters(callbackQuery); 5332 const request = resource.request; 5333 const url = resource.url; 5334 request.url = url; 5335 request.requestFunction = function() { 5336 const deferred = defer_default(); 5337 window[functionName] = function(data) { 5338 deferred.resolve(data); 5339 try { 5340 delete window[functionName]; 5341 } catch (e) { 5342 window[functionName] = void 0; 5343 } 5344 }; 5345 Resource._Implementations.loadAndExecuteScript(url, functionName, deferred); 5346 return deferred.promise; 5347 }; 5348 const promise = RequestScheduler_default.request(request); 5349 if (!defined_default(promise)) { 5350 return; 5351 } 5352 return promise.catch(function(e) { 5353 if (request.state !== RequestState_default.FAILED) { 5354 return Promise.reject(e); 5355 } 5356 return resource.retryOnError(e).then(function(retry) { 5357 if (retry) { 5358 request.state = RequestState_default.UNISSUED; 5359 request.deferred = void 0; 5360 return fetchJsonp(resource, callbackParameterName, functionName); 5361 } 5362 return Promise.reject(e); 5363 }); 5364 }); 5365} 5366Resource.fetchJsonp = function(options) { 5367 const resource = new Resource(options); 5368 return resource.fetchJsonp(options.callbackParameterName); 5369}; 5370Resource.prototype._makeRequest = function(options) { 5371 const resource = this; 5372 checkAndResetRequest(resource.request); 5373 const request = resource.request; 5374 const url = resource.url; 5375 request.url = url; 5376 request.requestFunction = function() { 5377 const responseType = options.responseType; 5378 const headers = combine_default(options.headers, resource.headers); 5379 const overrideMimeType = options.overrideMimeType; 5380 const method = options.method; 5381 const data = options.data; 5382 const deferred = defer_default(); 5383 const xhr = Resource._Implementations.loadWithXhr( 5384 url, 5385 responseType, 5386 method, 5387 data, 5388 headers, 5389 deferred, 5390 overrideMimeType 5391 ); 5392 if (defined_default(xhr) && defined_default(xhr.abort)) { 5393 request.cancelFunction = function() { 5394 xhr.abort(); 5395 }; 5396 } 5397 return deferred.promise; 5398 }; 5399 const promise = RequestScheduler_default.request(request); 5400 if (!defined_default(promise)) { 5401 return; 5402 } 5403 return promise.then(function(data) { 5404 request.cancelFunction = void 0; 5405 return data; 5406 }).catch(function(e) { 5407 request.cancelFunction = void 0; 5408 if (request.state !== RequestState_default.FAILED) { 5409 return Promise.reject(e); 5410 } 5411 return resource.retryOnError(e).then(function(retry) { 5412 if (retry) { 5413 request.state = RequestState_default.UNISSUED; 5414 request.deferred = void 0; 5415 return resource.fetch(options); 5416 } 5417 return Promise.reject(e); 5418 }); 5419 }); 5420}; 5421function checkAndResetRequest(request) { 5422 if (request.state === RequestState_default.ISSUED || request.state === RequestState_default.ACTIVE) { 5423 throw new RuntimeError_default("The Resource is already being fetched."); 5424 } 5425 request.state = RequestState_default.UNISSUED; 5426 request.deferred = void 0; 5427} 5428var dataUriRegex2 = /^data:(.*?)(;base64)?,(.*)$/; 5429function decodeDataUriText(isBase64, data) { 5430 const result = decodeURIComponent(data); 5431 if (isBase64) { 5432 return atob(result); 5433 } 5434 return result; 5435} 5436function decodeDataUriArrayBuffer(isBase64, data) { 5437 const byteString = decodeDataUriText(isBase64, data); 5438 const buffer = new ArrayBuffer(byteString.length); 5439 const view = new Uint8Array(buffer); 5440 for (let i = 0; i < byteString.length; i++) { 5441 view[i] = byteString.charCodeAt(i); 5442 } 5443 return buffer; 5444} 5445function decodeDataUri(dataUriRegexResult, responseType) { 5446 responseType = responseType ?? ""; 5447 const mimeType = dataUriRegexResult[1]; 5448 const isBase64 = !!dataUriRegexResult[2]; 5449 const data = dataUriRegexResult[3]; 5450 let buffer; 5451 let parser; 5452 switch (responseType) { 5453 case "": 5454 case "text": 5455 return decodeDataUriText(isBase64, data); 5456 case "arraybuffer": 5457 return decodeDataUriArrayBuffer(isBase64, data); 5458 case "blob": 5459 buffer = decodeDataUriArrayBuffer(isBase64, data); 5460 return new Blob([buffer], { 5461 type: mimeType 5462 }); 5463 case "document": 5464 parser = new DOMParser(); 5465 return parser.parseFromString( 5466 decodeDataUriText(isBase64, data), 5467 mimeType 5468 ); 5469 case "json": 5470 return JSON.parse(decodeDataUriText(isBase64, data)); 5471 default: 5472 throw new DeveloperError_default(`Unhandled responseType: ${responseType}`); 5473 } 5474} 5475Resource.prototype.fetch = function(options) { 5476 options = defaultClone(options, {}); 5477 options.method = "GET"; 5478 return this._makeRequest(options); 5479}; 5480Resource.fetch = function(options) { 5481 const resource = new Resource(options); 5482 return resource.fetch({ 5483 // Make copy of just the needed fields because headers can be passed to both the constructor and to fetch 5484 responseType: options.responseType, 5485 overrideMimeType: options.overrideMimeType 5486 }); 5487}; 5488Resource.prototype.delete = function(options) { 5489 options = defaultClone(options, {}); 5490 options.method = "DELETE"; 5491 return this._makeRequest(options); 5492}; 5493Resource.delete = function(options) { 5494 const resource = new Resource(options); 5495 return resource.delete({ 5496 // Make copy of just the needed fields because headers can be passed to both the constructor and to fetch 5497 responseType: options.responseType, 5498 overrideMimeType: options.overrideMimeType, 5499 data: options.data 5500 }); 5501}; 5502Resource.prototype.head = function(options) { 5503 options = defaultClone(options, {}); 5504 options.method = "HEAD"; 5505 return this._makeRequest(options); 5506}; 5507Resource.head = function(options) { 5508 const resource = new Resource(options); 5509 return resource.head({ 5510 // Make copy of just the needed fields because headers can be passed to both the constructor and to fetch 5511 responseType: options.responseType, 5512 overrideMimeType: options.overrideMimeType 5513 }); 5514}; 5515Resource.prototype.options = function(options) { 5516 options = defaultClone(options, {}); 5517 options.method = "OPTIONS"; 5518 return this._makeRequest(options); 5519}; 5520Resource.options = function(options) { 5521 const resource = new Resource(options); 5522 return resource.options({ 5523 // Make copy of just the needed fields because headers can be passed to both the constructor and to fetch 5524 responseType: options.responseType, 5525 overrideMimeType: options.overrideMimeType 5526 }); 5527}; 5528Resource.prototype.post = function(data, options) { 5529 Check_default.defined("data", data); 5530 options = defaultClone(options, {}); 5531 options.method = "POST"; 5532 options.data = data; 5533 return this._makeRequest(options); 5534}; 5535Resource.post = function(options) { 5536 const resource = new Resource(options); 5537 return resource.post(options.data, { 5538 // Make copy of just the needed fields because headers can be passed to both the constructor and to post 5539 responseType: options.responseType, 5540 overrideMimeType: options.overrideMimeType 5541 }); 5542}; 5543Resource.prototype.put = function(data, options) { 5544 Check_default.defined("data", data); 5545 options = defaultClone(options, {}); 5546 options.method = "PUT"; 5547 options.data = data; 5548 return this._makeRequest(options); 5549}; 5550Resource.put = function(options) { 5551 const resource = new Resource(options); 5552 return resource.put(options.data, { 5553 // Make copy of just the needed fields because headers can be passed to both the constructor and to post 5554 responseType: options.responseType, 5555 overrideMimeType: options.overrideMimeType 5556 }); 5557}; 5558Resource.prototype.patch = function(data, options) { 5559 Check_default.defined("data", data); 5560 options = defaultClone(options, {}); 5561 options.method = "PATCH"; 5562 options.data = data; 5563 return this._makeRequest(options); 5564}; 5565Resource.patch = function(options) { 5566 const resource = new Resource(options); 5567 return resource.patch(options.data, { 5568 // Make copy of just the needed fields because headers can be passed to both the constructor and to post 5569 responseType: options.responseType, 5570 overrideMimeType: options.overrideMimeType 5571 }); 5572}; 5573Resource._Implementations = {}; 5574Resource._Implementations.loadImageElement = function(url, crossOrigin, deferred) { 5575 const image = new Image(); 5576 image.onload = function() { 5577 if (image.naturalWidth === 0 && image.naturalHeight === 0 && image.width === 0 && image.height === 0) { 5578 image.width = 300; 5579 image.height = 150; 5580 } 5581 deferred.resolve(image); 5582 }; 5583 image.onerror = function(e) { 5584 deferred.reject(e); 5585 }; 5586 if (crossOrigin) { 5587 if (TrustedServers_default.contains(url)) { 5588 image.crossOrigin = "use-credentials"; 5589 } else { 5590 image.crossOrigin = ""; 5591 } 5592 } 5593 image.src = url; 5594}; 5595Resource._Implementations.createImage = function(request, crossOrigin, deferred, flipY, skipColorSpaceConversion, preferImageBitmap, headers) { 5596 const url = request.url; 5597 Resource.supportsImageBitmapOptions().then(function(supportsImageBitmap) { 5598 if (!(supportsImageBitmap && preferImageBitmap)) { 5599 Resource._Implementations.loadImageElement(url, crossOrigin, deferred); 5600 return; 5601 } 5602 const responseType = "blob"; 5603 const method = "GET"; 5604 const xhrDeferred = defer_default(); 5605 const xhr = Resource._Implementations.loadWithXhr( 5606 url, 5607 responseType, 5608 method, 5609 void 0, 5610 headers, 5611 xhrDeferred, 5612 void 0, 5613 void 0, 5614 void 0 5615 ); 5616 if (defined_default(xhr) && defined_default(xhr.abort)) { 5617 request.cancelFunction = function() { 5618 xhr.abort(); 5619 }; 5620 } 5621 return xhrDeferred.promise.then(function(blob) { 5622 if (!defined_default(blob)) { 5623 deferred.reject( 5624 new RuntimeError_default( 5625 `Successfully retrieved ${url} but it contained no content.` 5626 ) 5627 ); 5628 return; 5629 } 5630 return Resource.createImageBitmapFromBlob(blob, { 5631 flipY, 5632 premultiplyAlpha: false, 5633 skipColorSpaceConversion 5634 }); 5635 }).then(function(image) { 5636 deferred.resolve(image); 5637 }); 5638 }).catch(function(e) { 5639 deferred.reject(e); 5640 }); 5641}; 5642Resource.createImageBitmapFromBlob = function(blob, options) { 5643 Check_default.defined("options", options); 5644 Check_default.typeOf.bool("options.flipY", options.flipY); 5645 Check_default.typeOf.bool("options.premultiplyAlpha", options.premultiplyAlpha); 5646 Check_default.typeOf.bool( 5647 "options.skipColorSpaceConversion", 5648 options.skipColorSpaceConversion 5649 ); 5650 return createImageBitmap(blob, { 5651 // 'from-image' is deprecated, new option is 'none'. However, we still need to support older browsers, 5652 // and there's no good way to detect support for these options. For now, continue to use 'from-image'. See: https://github.com/CesiumGS/cesium/issues/12846 5653 imageOrientation: options.flipY ? "flipY" : "none", 5654 premultiplyAlpha: options.premultiplyAlpha ? "premultiply" : "none", 5655 colorSpaceConversion: options.skipColorSpaceConversion ? "none" : "default" 5656 }); 5657}; 5658function loadWithHttpRequest(url, responseType, method, data, headers, deferred, overrideMimeType) { 5659 fetch(url, { 5660 method, 5661 headers 5662 }).then(async (response) => { 5663 if (!response.ok) { 5664 const responseHeaders = {}; 5665 response.headers.forEach((value, key) => { 5666 responseHeaders[key] = value; 5667 }); 5668 deferred.reject( 5669 new RequestErrorEvent_default(response.status, response, responseHeaders) 5670 ); 5671 return; 5672 } 5673 switch (responseType) { 5674 case "text": 5675 deferred.resolve(response.text()); 5676 break; 5677 case "json": 5678 deferred.resolve(response.json()); 5679 break; 5680 default: 5681 deferred.resolve(new Uint8Array(await response.arrayBuffer()).buffer); 5682 break; 5683 } 5684 }).catch(() => { 5685 deferred.reject(new RequestErrorEvent_default()); 5686 }); 5687} 5688var noXMLHttpRequest = typeof XMLHttpRequest === "undefined"; 5689Resource._Implementations.loadWithXhr = function(url, responseType, method, data, headers, deferred, overrideMimeType) { 5690 const dataUriRegexResult = dataUriRegex2.exec(url); 5691 if (dataUriRegexResult !== null) { 5692 deferred.resolve(decodeDataUri(dataUriRegexResult, responseType)); 5693 return; 5694 } 5695 if (noXMLHttpRequest) { 5696 loadWithHttpRequest( 5697 url, 5698 responseType, 5699 method, 5700 data, 5701 headers, 5702 deferred, 5703 overrideMimeType 5704 ); 5705 return; 5706 } 5707 const xhr = new XMLHttpRequest(); 5708 if (TrustedServers_default.contains(url)) { 5709 xhr.withCredentials = true; 5710 } 5711 xhr.open(method, url, true); 5712 if (defined_default(overrideMimeType) && defined_default(xhr.overrideMimeType)) { 5713 xhr.overrideMimeType(overrideMimeType); 5714 } 5715 if (defined_default(headers)) { 5716 for (const key in headers) { 5717 if (headers.hasOwnProperty(key)) { 5718 xhr.setRequestHeader(key, headers[key]); 5719 } 5720 } 5721 } 5722 if (defined_default(responseType)) { 5723 xhr.responseType = responseType; 5724 } 5725 let localFile = false; 5726 if (typeof url === "string") { 5727 localFile = url.indexOf("file://") === 0 || typeof window !== "undefined" && window.location.origin === "file://"; 5728 } 5729 xhr.onload = function() { 5730 if ((xhr.status < 200 || xhr.status >= 300) && !(localFile && xhr.status === 0)) { 5731 deferred.reject( 5732 new RequestErrorEvent_default( 5733 xhr.status, 5734 xhr.response, 5735 xhr.getAllResponseHeaders() 5736 ) 5737 ); 5738 return; 5739 } 5740 const response = xhr.response; 5741 const browserResponseType = xhr.responseType; 5742 if (method === "HEAD" || method === "OPTIONS") { 5743 const responseHeaderString = xhr.getAllResponseHeaders(); 5744 const splitHeaders = responseHeaderString.trim().split(/[\r\n]+/); 5745 const responseHeaders = {}; 5746 splitHeaders.forEach(function(line) { 5747 const parts = line.split(": "); 5748 const header = parts.shift(); 5749 responseHeaders[header] = parts.join(": "); 5750 }); 5751 deferred.resolve(responseHeaders); 5752 return; 5753 } 5754 if (xhr.status === 204) { 5755 deferred.resolve(void 0); 5756 } else if (defined_default(response) && (!defined_default(responseType) || browserResponseType === responseType)) { 5757 deferred.resolve(response); 5758 } else if (responseType === "json" && typeof response === "string") { 5759 try { 5760 deferred.resolve(JSON.parse(response)); 5761 } catch (e) { 5762 deferred.reject(e); 5763 } 5764 } else if ((browserResponseType === "" || browserResponseType === "document") && defined_default(xhr.responseXML) && xhr.responseXML.hasChildNodes()) { 5765 deferred.resolve(xhr.responseXML); 5766 } else if ((browserResponseType === "" || browserResponseType === "text") && defined_default(xhr.responseText)) { 5767 deferred.resolve(xhr.responseText); 5768 } else { 5769 deferred.reject( 5770 new RuntimeError_default("Invalid XMLHttpRequest response type.") 5771 ); 5772 } 5773 }; 5774 xhr.onerror = function(e) { 5775 deferred.reject(new RequestErrorEvent_default()); 5776 }; 5777 xhr.send(data); 5778 return xhr; 5779}; 5780Resource._Implementations.loadAndExecuteScript = function(url, functionName, deferred) { 5781 return loadAndExecuteScript_default(url, functionName).catch(function(e) { 5782 deferred.reject(e); 5783 }); 5784}; 5785Resource._DefaultImplementations = {}; 5786Resource._DefaultImplementations.createImage = Resource._Implementations.createImage; 5787Resource._DefaultImplementations.loadWithXhr = Resource._Implementations.loadWithXhr; 5788Resource._DefaultImplementations.loadAndExecuteScript = Resource._Implementations.loadAndExecuteScript; 5789Resource.DEFAULT = Object.freeze( 5790 new Resource({ 5791 url: typeof document === "undefined" ? "" : document.location.href.split("?")[0] 5792 }) 5793); 5794var Resource_default = Resource; 5795 5796// packages/engine/Source/Core/EarthOrientationParameters.js 5797function EarthOrientationParameters(options) { 5798 options = options ?? Frozen_default.EMPTY_OBJECT; 5799 this._dates = void 0; 5800 this._samples = void 0; 5801 this._dateColumn = -1; 5802 this._xPoleWanderRadiansColumn = -1; 5803 this._yPoleWanderRadiansColumn = -1; 5804 this._ut1MinusUtcSecondsColumn = -1; 5805 this._xCelestialPoleOffsetRadiansColumn = -1; 5806 this._yCelestialPoleOffsetRadiansColumn = -1; 5807 this._taiMinusUtcSecondsColumn = -1; 5808 this._columnCount = 0; 5809 this._lastIndex = -1; 5810 this._addNewLeapSeconds = options.addNewLeapSeconds ?? true; 5811 if (defined_default(options.data)) { 5812 onDataReady(this, options.data); 5813 } else { 5814 onDataReady(this, { 5815 columnNames: [ 5816 "dateIso8601", 5817 "modifiedJulianDateUtc", 5818 "xPoleWanderRadians", 5819 "yPoleWanderRadians", 5820 "ut1MinusUtcSeconds", 5821 "lengthOfDayCorrectionSeconds", 5822 "xCelestialPoleOffsetRadians", 5823 "yCelestialPoleOffsetRadians", 5824 "taiMinusUtcSeconds" 5825 ], 5826 samples: [] 5827 }); 5828 } 5829} 5830EarthOrientationParameters.fromUrl = async function(url, options) { 5831 Check_default.defined("url", url); 5832 options = options ?? Frozen_default.EMPTY_OBJECT; 5833 const resource = Resource_default.createIfNeeded(url); 5834 let eopData; 5835 try { 5836 eopData = await resource.fetchJson(); 5837 } catch (e) { 5838 throw new RuntimeError_default( 5839 `An error occurred while retrieving the EOP data from the URL ${resource.url}.` 5840 ); 5841 } 5842 return new EarthOrientationParameters({ 5843 addNewLeapSeconds: options.addNewLeapSeconds, 5844 data: eopData 5845 }); 5846}; 5847EarthOrientationParameters.NONE = Object.freeze({ 5848 compute: function(date, result) { 5849 if (!defined_default(result)) { 5850 result = new EarthOrientationParametersSample_default(0, 0, 0, 0, 0); 5851 } else { 5852 result.xPoleWander = 0; 5853 result.yPoleWander = 0; 5854 result.xPoleOffset = 0; 5855 result.yPoleOffset = 0; 5856 result.ut1MinusUtc = 0; 5857 } 5858 return result; 5859 } 5860}); 5861EarthOrientationParameters.prototype.compute = function(date, result) { 5862 if (!defined_default(this._samples)) { 5863 return void 0; 5864 } 5865 if (!defined_default(result)) { 5866 result = new EarthOrientationParametersSample_default(0, 0, 0, 0, 0); 5867 } 5868 if (this._samples.length === 0) { 5869 result.xPoleWander = 0; 5870 result.yPoleWander = 0; 5871 result.xPoleOffset = 0; 5872 result.yPoleOffset = 0; 5873 result.ut1MinusUtc = 0; 5874 return result; 5875 } 5876 const dates = this._dates; 5877 const lastIndex = this._lastIndex; 5878 let before; 5879 let after; 5880 if (defined_default(lastIndex)) { 5881 const previousIndexDate = dates[lastIndex]; 5882 const nextIndexDate = dates[lastIndex + 1]; 5883 const isAfterPrevious = JulianDate_default.lessThanOrEquals( 5884 previousIndexDate, 5885 date 5886 ); 5887 const isAfterLastSample = !defined_default(nextIndexDate); 5888 const isBeforeNext = isAfterLastSample || JulianDate_default.greaterThanOrEquals(nextIndexDate, date); 5889 if (isAfterPrevious && isBeforeNext) { 5890 before = lastIndex; 5891 if (!isAfterLastSample && nextIndexDate.equals(date)) { 5892 ++before; 5893 } 5894 after = before + 1; 5895 interpolate(this, dates, this._samples, date, before, after, result); 5896 return result; 5897 } 5898 } 5899 let index = binarySearch_default(dates, date, JulianDate_default.compare, this._dateColumn); 5900 if (index >= 0) { 5901 if (index < dates.length - 1 && dates[index + 1].equals(date)) { 5902 ++index; 5903 } 5904 before = index; 5905 after = index; 5906 } else { 5907 after = ~index; 5908 before = after - 1; 5909 if (before < 0) { 5910 before = 0; 5911 } 5912 } 5913 this._lastIndex = before; 5914 interpolate(this, dates, this._samples, date, before, after, result); 5915 return result; 5916}; 5917function compareLeapSecondDates2(leapSecond, dateToFind) { 5918 return JulianDate_default.compare(leapSecond.julianDate, dateToFind); 5919} 5920function onDataReady(eop, eopData) { 5921 if (!defined_default(eopData.columnNames)) { 5922 throw new RuntimeError_default( 5923 "Error in loaded EOP data: The columnNames property is required." 5924 ); 5925 } 5926 if (!defined_default(eopData.samples)) { 5927 throw new RuntimeError_default( 5928 "Error in loaded EOP data: The samples property is required." 5929 ); 5930 } 5931 const dateColumn = eopData.columnNames.indexOf("modifiedJulianDateUtc"); 5932 const xPoleWanderRadiansColumn = eopData.columnNames.indexOf("xPoleWanderRadians"); 5933 const yPoleWanderRadiansColumn = eopData.columnNames.indexOf("yPoleWanderRadians"); 5934 const ut1MinusUtcSecondsColumn = eopData.columnNames.indexOf("ut1MinusUtcSeconds"); 5935 const xCelestialPoleOffsetRadiansColumn = eopData.columnNames.indexOf( 5936 "xCelestialPoleOffsetRadians" 5937 ); 5938 const yCelestialPoleOffsetRadiansColumn = eopData.columnNames.indexOf( 5939 "yCelestialPoleOffsetRadians" 5940 ); 5941 const taiMinusUtcSecondsColumn = eopData.columnNames.indexOf("taiMinusUtcSeconds"); 5942 if (dateColumn < 0 || xPoleWanderRadiansColumn < 0 || yPoleWanderRadiansColumn < 0 || ut1MinusUtcSecondsColumn < 0 || xCelestialPoleOffsetRadiansColumn < 0 || yCelestialPoleOffsetRadiansColumn < 0 || taiMinusUtcSecondsColumn < 0) { 5943 throw new RuntimeError_default( 5944 "Error in loaded EOP data: The columnNames property must include modifiedJulianDateUtc, xPoleWanderRadians, yPoleWanderRadians, ut1MinusUtcSeconds, xCelestialPoleOffsetRadians, yCelestialPoleOffsetRadians, and taiMinusUtcSeconds columns" 5945 ); 5946 } 5947 const samples = eop._samples = eopData.samples; 5948 const dates = eop._dates = []; 5949 eop._dateColumn = dateColumn; 5950 eop._xPoleWanderRadiansColumn = xPoleWanderRadiansColumn; 5951 eop._yPoleWanderRadiansColumn = yPoleWanderRadiansColumn; 5952 eop._ut1MinusUtcSecondsColumn = ut1MinusUtcSecondsColumn; 5953 eop._xCelestialPoleOffsetRadiansColumn = xCelestialPoleOffsetRadiansColumn; 5954 eop._yCelestialPoleOffsetRadiansColumn = yCelestialPoleOffsetRadiansColumn; 5955 eop._taiMinusUtcSecondsColumn = taiMinusUtcSecondsColumn; 5956 eop._columnCount = eopData.columnNames.length; 5957 eop._lastIndex = void 0; 5958 let lastTaiMinusUtc; 5959 const addNewLeapSeconds = eop._addNewLeapSeconds; 5960 for (let i = 0, len = samples.length; i < len; i += eop._columnCount) { 5961 const mjd = samples[i + dateColumn]; 5962 const taiMinusUtc = samples[i + taiMinusUtcSecondsColumn]; 5963 const day = mjd + TimeConstants_default.MODIFIED_JULIAN_DATE_DIFFERENCE; 5964 const date = new JulianDate_default(day, taiMinusUtc, TimeStandard_default.TAI); 5965 dates.push(date); 5966 if (addNewLeapSeconds) { 5967 if (taiMinusUtc !== lastTaiMinusUtc && defined_default(lastTaiMinusUtc)) { 5968 const leapSeconds = JulianDate_default.leapSeconds; 5969 const leapSecondIndex = binarySearch_default( 5970 leapSeconds, 5971 date, 5972 compareLeapSecondDates2 5973 ); 5974 if (leapSecondIndex < 0) { 5975 const leapSecond = new LeapSecond_default(date, taiMinusUtc); 5976 leapSeconds.splice(~leapSecondIndex, 0, leapSecond); 5977 } 5978 } 5979 lastTaiMinusUtc = taiMinusUtc; 5980 } 5981 } 5982} 5983function fillResultFromIndex(eop, samples, index, columnCount, result) { 5984 const start = index * columnCount; 5985 result.xPoleWander = samples[start + eop._xPoleWanderRadiansColumn]; 5986 result.yPoleWander = samples[start + eop._yPoleWanderRadiansColumn]; 5987 result.xPoleOffset = samples[start + eop._xCelestialPoleOffsetRadiansColumn]; 5988 result.yPoleOffset = samples[start + eop._yCelestialPoleOffsetRadiansColumn]; 5989 result.ut1MinusUtc = samples[start + eop._ut1MinusUtcSecondsColumn]; 5990} 5991function linearInterp(dx, y1, y2) { 5992 return y1 + dx * (y2 - y1); 5993} 5994function interpolate(eop, dates, samples, date, before, after, result) { 5995 const columnCount = eop._columnCount; 5996 if (after > dates.length - 1) { 5997 result.xPoleWander = 0; 5998 result.yPoleWander = 0; 5999 result.xPoleOffset = 0; 6000 result.yPoleOffset = 0; 6001 result.ut1MinusUtc = 0; 6002 return result; 6003 } 6004 const beforeDate = dates[before]; 6005 const afterDate = dates[after]; 6006 if (beforeDate.equals(afterDate) || date.equals(beforeDate)) { 6007 fillResultFromIndex(eop, samples, before, columnCount, result); 6008 return result; 6009 } else if (date.equals(afterDate)) { 6010 fillResultFromIndex(eop, samples, after, columnCount, result); 6011 return result; 6012 } 6013 const factor = JulianDate_default.secondsDifference(date, beforeDate) / JulianDate_default.secondsDifference(afterDate, beforeDate); 6014 const startBefore = before * columnCount; 6015 const startAfter = after * columnCount; 6016 let beforeUt1MinusUtc = samples[startBefore + eop._ut1MinusUtcSecondsColumn]; 6017 let afterUt1MinusUtc = samples[startAfter + eop._ut1MinusUtcSecondsColumn]; 6018 const offsetDifference = afterUt1MinusUtc - beforeUt1MinusUtc; 6019 if (offsetDifference > 0.5 || offsetDifference < -0.5) { 6020 const beforeTaiMinusUtc = samples[startBefore + eop._taiMinusUtcSecondsColumn]; 6021 const afterTaiMinusUtc = samples[startAfter + eop._taiMinusUtcSecondsColumn]; 6022 if (beforeTaiMinusUtc !== afterTaiMinusUtc) { 6023 if (afterDate.equals(date)) { 6024 beforeUt1MinusUtc = afterUt1MinusUtc; 6025 } else { 6026 afterUt1MinusUtc -= afterTaiMinusUtc - beforeTaiMinusUtc; 6027 } 6028 } 6029 } 6030 result.xPoleWander = linearInterp( 6031 factor, 6032 samples[startBefore + eop._xPoleWanderRadiansColumn], 6033 samples[startAfter + eop._xPoleWanderRadiansColumn] 6034 ); 6035 result.yPoleWander = linearInterp( 6036 factor, 6037 samples[startBefore + eop._yPoleWanderRadiansColumn], 6038 samples[startAfter + eop._yPoleWanderRadiansColumn] 6039 ); 6040 result.xPoleOffset = linearInterp( 6041 factor, 6042 samples[startBefore + eop._xCelestialPoleOffsetRadiansColumn], 6043 samples[startAfter + eop._xCelestialPoleOffsetRadiansColumn] 6044 ); 6045 result.yPoleOffset = linearInterp( 6046 factor, 6047 samples[startBefore + eop._yCelestialPoleOffsetRadiansColumn], 6048 samples[startAfter + eop._yCelestialPoleOffsetRadiansColumn] 6049 ); 6050 result.ut1MinusUtc = linearInterp( 6051 factor, 6052 beforeUt1MinusUtc, 6053 afterUt1MinusUtc 6054 ); 6055 return result; 6056} 6057var EarthOrientationParameters_default = EarthOrientationParameters; 6058 6059// packages/engine/Source/Core/HeadingPitchRoll.js 6060function HeadingPitchRoll(heading, pitch, roll) { 6061 this.heading = heading ?? 0; 6062 this.pitch = pitch ?? 0; 6063 this.roll = roll ?? 0; 6064} 6065HeadingPitchRoll.fromQuaternion = function(quaternion, result) { 6066 if (!defined_default(quaternion)) { 6067 throw new DeveloperError_default("quaternion is required"); 6068 } 6069 if (!defined_default(result)) { 6070 result = new HeadingPitchRoll(); 6071 } 6072 const test = 2 * (quaternion.w * quaternion.y - quaternion.z * quaternion.x); 6073 const denominatorRoll = 1 - 2 * (quaternion.x * quaternion.x + quaternion.y * quaternion.y); 6074 const numeratorRoll = 2 * (quaternion.w * quaternion.x + quaternion.y * quaternion.z); 6075 const denominatorHeading = 1 - 2 * (quaternion.y * quaternion.y + quaternion.z * quaternion.z); 6076 const numeratorHeading = 2 * (quaternion.w * quaternion.z + quaternion.x * quaternion.y); 6077 result.heading = -Math.atan2(numeratorHeading, denominatorHeading); 6078 result.roll = Math.atan2(numeratorRoll, denominatorRoll); 6079 result.pitch = -Math_default.asinClamped(test); 6080 return result; 6081}; 6082HeadingPitchRoll.fromDegrees = function(heading, pitch, roll, result) { 6083 if (!defined_default(heading)) { 6084 throw new DeveloperError_default("heading is required"); 6085 } 6086 if (!defined_default(pitch)) { 6087 throw new DeveloperError_default("pitch is required"); 6088 } 6089 if (!defined_default(roll)) { 6090 throw new DeveloperError_default("roll is required"); 6091 } 6092 if (!defined_default(result)) { 6093 result = new HeadingPitchRoll(); 6094 } 6095 result.heading = heading * Math_default.RADIANS_PER_DEGREE; 6096 result.pitch = pitch * Math_default.RADIANS_PER_DEGREE; 6097 result.roll = roll * Math_default.RADIANS_PER_DEGREE; 6098 return result; 6099}; 6100HeadingPitchRoll.clone = function(headingPitchRoll, result) { 6101 if (!defined_default(headingPitchRoll)) { 6102 return void 0; 6103 } 6104 if (!defined_default(result)) { 6105 return new HeadingPitchRoll( 6106 headingPitchRoll.heading, 6107 headingPitchRoll.pitch, 6108 headingPitchRoll.roll 6109 ); 6110 } 6111 result.heading = headingPitchRoll.heading; 6112 result.pitch = headingPitchRoll.pitch; 6113 result.roll = headingPitchRoll.roll; 6114 return result; 6115}; 6116HeadingPitchRoll.equals = function(left, right) { 6117 return left === right || defined_default(left) && defined_default(right) && left.heading === right.heading && left.pitch === right.pitch && left.roll === right.roll; 6118}; 6119HeadingPitchRoll.equalsEpsilon = function(left, right, relativeEpsilon, absoluteEpsilon) { 6120 return left === right || defined_default(left) && defined_default(right) && Math_default.equalsEpsilon( 6121 left.heading, 6122 right.heading, 6123 relativeEpsilon, 6124 absoluteEpsilon 6125 ) && Math_default.equalsEpsilon( 6126 left.pitch, 6127 right.pitch, 6128 relativeEpsilon, 6129 absoluteEpsilon 6130 ) && Math_default.equalsEpsilon( 6131 left.roll, 6132 right.roll, 6133 relativeEpsilon, 6134 absoluteEpsilon 6135 ); 6136}; 6137HeadingPitchRoll.prototype.clone = function(result) { 6138 return HeadingPitchRoll.clone(this, result); 6139}; 6140HeadingPitchRoll.prototype.equals = function(right) { 6141 return HeadingPitchRoll.equals(this, right); 6142}; 6143HeadingPitchRoll.prototype.equalsEpsilon = function(right, relativeEpsilon, absoluteEpsilon) { 6144 return HeadingPitchRoll.equalsEpsilon( 6145 this, 6146 right, 6147 relativeEpsilon, 6148 absoluteEpsilon 6149 ); 6150}; 6151HeadingPitchRoll.prototype.toString = function() { 6152 return `(${this.heading}, ${this.pitch}, ${this.roll})`; 6153}; 6154var HeadingPitchRoll_default = HeadingPitchRoll; 6155 6156// packages/engine/Source/Core/buildModuleUrl.js 6157var cesiumScriptRegex = /((?:.*\/)|^)Cesium\.js(?:\?|\#|$)/; 6158function getBaseUrlFromCesiumScript() { 6159 const scripts = document.getElementsByTagName("script"); 6160 for (let i = 0, len = scripts.length; i < len; ++i) { 6161 const src = scripts[i].getAttribute("src"); 6162 const result = cesiumScriptRegex.exec(src); 6163 if (result !== null) { 6164 return result[1]; 6165 } 6166 } 6167 return void 0; 6168} 6169var a2; 6170function tryMakeAbsolute(url) { 6171 if (typeof document === "undefined") { 6172 return url; 6173 } 6174 if (!defined_default(a2)) { 6175 a2 = document.createElement("a"); 6176 } 6177 a2.href = url; 6178 return a2.href; 6179} 6180var baseResource; 6181function getCesiumBaseUrl() { 6182 if (defined_default(baseResource)) { 6183 return baseResource; 6184 } 6185 let baseUrlString; 6186 if (typeof CESIUM_BASE_URL !== "undefined") { 6187 baseUrlString = CESIUM_BASE_URL; 6188 } else if (defined_default(import.meta?.url)) { 6189 baseUrlString = getAbsoluteUri_default(".", import.meta.url); 6190 } else if (typeof define === "object" && defined_default(define.amd) && !define.amd.toUrlUndefined && defined_default(__require.toUrl)) { 6191 baseUrlString = getAbsoluteUri_default( 6192 "..", 6193 buildModuleUrl("Core/buildModuleUrl.js") 6194 ); 6195 } else { 6196 baseUrlString = getBaseUrlFromCesiumScript(); 6197 } 6198 if (!defined_default(baseUrlString)) { 6199 throw new DeveloperError_default( 6200 "Unable to determine Cesium base URL automatically, try defining a global variable called CESIUM_BASE_URL." 6201 ); 6202 } 6203 baseResource = new Resource_default({ 6204 url: tryMakeAbsolute(baseUrlString) 6205 }); 6206 baseResource.appendForwardSlash(); 6207 return baseResource; 6208} 6209function buildModuleUrlFromRequireToUrl(moduleID) { 6210 return tryMakeAbsolute(__require.toUrl(`../${moduleID}`)); 6211} 6212function buildModuleUrlFromBaseUrl(moduleID) { 6213 const resource = getCesiumBaseUrl().getDerivedResource({ 6214 url: moduleID 6215 }); 6216 return resource.url; 6217} 6218var implementation; 6219function buildModuleUrl(relativeUrl) { 6220 if (!defined_default(implementation)) { 6221 if (typeof define === "object" && defined_default(define.amd) && !define.amd.toUrlUndefined && defined_default(__require.toUrl)) { 6222 implementation = buildModuleUrlFromRequireToUrl; 6223 } else { 6224 implementation = buildModuleUrlFromBaseUrl; 6225 } 6226 } 6227 const url = implementation(relativeUrl); 6228 return url; 6229} 6230buildModuleUrl._cesiumScriptRegex = cesiumScriptRegex; 6231buildModuleUrl._buildModuleUrlFromBaseUrl = buildModuleUrlFromBaseUrl; 6232buildModuleUrl._clearBaseResource = function() { 6233 baseResource = void 0; 6234}; 6235buildModuleUrl.setBaseUrl = function(value) { 6236 baseResource = Resource_default.DEFAULT.getDerivedResource({ 6237 url: value 6238 }); 6239}; 6240buildModuleUrl.getCesiumBaseUrl = getCesiumBaseUrl; 6241var buildModuleUrl_default = buildModuleUrl; 6242 6243// packages/engine/Source/Core/Iau2006XysSample.js 6244function Iau2006XysSample(x, y, s) { 6245 this.x = x; 6246 this.y = y; 6247 this.s = s; 6248} 6249var Iau2006XysSample_default = Iau2006XysSample; 6250 6251// packages/engine/Source/Core/Iau2006XysData.js 6252function Iau2006XysData(options) { 6253 options = options ?? Frozen_default.EMPTY_OBJECT; 6254 this._xysFileUrlTemplate = Resource_default.createIfNeeded( 6255 options.xysFileUrlTemplate 6256 ); 6257 this._interpolationOrder = options.interpolationOrder ?? 9; 6258 this._sampleZeroJulianEphemerisDate = options.sampleZeroJulianEphemerisDate ?? 24423965e-1; 6259 this._sampleZeroDateTT = new JulianDate_default( 6260 this._sampleZeroJulianEphemerisDate, 6261 0, 6262 TimeStandard_default.TAI 6263 ); 6264 this._stepSizeDays = options.stepSizeDays ?? 1; 6265 this._samplesPerXysFile = options.samplesPerXysFile ?? 1e3; 6266 this._totalSamples = options.totalSamples ?? 27426; 6267 this._samples = new Array(this._totalSamples * 3); 6268 this._chunkDownloadsInProgress = []; 6269 const order = this._interpolationOrder; 6270 const denom = this._denominators = new Array(order + 1); 6271 const xTable = this._xTable = new Array(order + 1); 6272 const stepN = Math.pow(this._stepSizeDays, order); 6273 for (let i = 0; i <= order; ++i) { 6274 denom[i] = stepN; 6275 xTable[i] = i * this._stepSizeDays; 6276 for (let j = 0; j <= order; ++j) { 6277 if (j !== i) { 6278 denom[i] *= i - j; 6279 } 6280 } 6281 denom[i] = 1 / denom[i]; 6282 } 6283 this._work = new Array(order + 1); 6284 this._coef = new Array(order + 1); 6285} 6286var julianDateScratch = new JulianDate_default(0, 0, TimeStandard_default.TAI); 6287function getDaysSinceEpoch(xys, dayTT, secondTT) { 6288 const dateTT = julianDateScratch; 6289 dateTT.dayNumber = dayTT; 6290 dateTT.secondsOfDay = secondTT; 6291 return JulianDate_default.daysDifference(dateTT, xys._sampleZeroDateTT); 6292} 6293Iau2006XysData.prototype.preload = function(startDayTT, startSecondTT, stopDayTT, stopSecondTT) { 6294 const startDaysSinceEpoch = getDaysSinceEpoch( 6295 this, 6296 startDayTT, 6297 startSecondTT 6298 ); 6299 const stopDaysSinceEpoch = getDaysSinceEpoch(this, stopDayTT, stopSecondTT); 6300 let startIndex = startDaysSinceEpoch / this._stepSizeDays - this._interpolationOrder / 2 | 0; 6301 if (startIndex < 0) { 6302 startIndex = 0; 6303 } 6304 let stopIndex = stopDaysSinceEpoch / this._stepSizeDays - this._interpolationOrder / 2 | 0 + this._interpolationOrder; 6305 if (stopIndex >= this._totalSamples) { 6306 stopIndex = this._totalSamples - 1; 6307 } 6308 const startChunk = startIndex / this._samplesPerXysFile | 0; 6309 const stopChunk = stopIndex / this._samplesPerXysFile | 0; 6310 const promises = []; 6311 for (let i = startChunk; i <= stopChunk; ++i) { 6312 promises.push(requestXysChunk(this, i)); 6313 } 6314 return Promise.all(promises); 6315}; 6316Iau2006XysData.prototype.computeXysRadians = function(dayTT, secondTT, result) { 6317 const daysSinceEpoch = getDaysSinceEpoch(this, dayTT, secondTT); 6318 if (daysSinceEpoch < 0) { 6319 return void 0; 6320 } 6321 const centerIndex = daysSinceEpoch / this._stepSizeDays | 0; 6322 if (centerIndex >= this._totalSamples) { 6323 return void 0; 6324 } 6325 const degree = this._interpolationOrder; 6326 let firstIndex = centerIndex - (degree / 2 | 0); 6327 if (firstIndex < 0) { 6328 firstIndex = 0; 6329 } 6330 let lastIndex = firstIndex + degree; 6331 if (lastIndex >= this._totalSamples) { 6332 lastIndex = this._totalSamples - 1; 6333 firstIndex = lastIndex - degree; 6334 if (firstIndex < 0) { 6335 firstIndex = 0; 6336 } 6337 } 6338 let isDataMissing = false; 6339 const samples = this._samples; 6340 if (!defined_default(samples[firstIndex * 3])) { 6341 requestXysChunk(this, firstIndex / this._samplesPerXysFile | 0); 6342 isDataMissing = true; 6343 } 6344 if (!defined_default(samples[lastIndex * 3])) { 6345 requestXysChunk(this, lastIndex / this._samplesPerXysFile | 0); 6346 isDataMissing = true; 6347 } 6348 if (isDataMissing) { 6349 return void 0; 6350 } 6351 if (!defined_default(result)) { 6352 result = new Iau2006XysSample_default(0, 0, 0); 6353 } else { 6354 result.x = 0; 6355 result.y = 0; 6356 result.s = 0; 6357 } 6358 const x = daysSinceEpoch - firstIndex * this._stepSizeDays; 6359 const work = this._work; 6360 const denom = this._denominators; 6361 const coef = this._coef; 6362 const xTable = this._xTable; 6363 let i, j; 6364 for (i = 0; i <= degree; ++i) { 6365 work[i] = x - xTable[i]; 6366 } 6367 for (i = 0; i <= degree; ++i) { 6368 coef[i] = 1; 6369 for (j = 0; j <= degree; ++j) { 6370 if (j !== i) { 6371 coef[i] *= work[j]; 6372 } 6373 } 6374 coef[i] *= denom[i]; 6375 let sampleIndex = (firstIndex + i) * 3; 6376 result.x += coef[i] * samples[sampleIndex++]; 6377 result.y += coef[i] * samples[sampleIndex++]; 6378 result.s += coef[i] * samples[sampleIndex]; 6379 } 6380 return result; 6381}; 6382Iau2006XysData.prototype._updateChunkData = function(index, { samples }) { 6383 this._chunkDownloadsInProgress[index] = void 0; 6384 const samplesPerFile = this._samplesPerXysFile; 6385 const startIndex = index * samplesPerFile * 3; 6386 for (let i = 0; i < samples.length; ++i) { 6387 this._samples[startIndex + i] = samples[i]; 6388 } 6389}; 6390async function requestXysChunkJson(resource, index, xysData) { 6391 try { 6392 const chunk = await resource.fetchJson(); 6393 xysData._updateChunkData(index, chunk); 6394 } catch (e) { 6395 } 6396} 6397function requestXysChunk(xysData, chunkIndex) { 6398 if (defined_default(xysData._chunkDownloadsInProgress[chunkIndex])) { 6399 return xysData._chunkDownloadsInProgress[chunkIndex]; 6400 } 6401 let chunkUrl; 6402 const xysFileUrlTemplate = xysData._xysFileUrlTemplate; 6403 if (defined_default(xysFileUrlTemplate)) { 6404 chunkUrl = xysFileUrlTemplate.getDerivedResource({ 6405 templateValues: { 6406 0: chunkIndex 6407 } 6408 }); 6409 } else { 6410 chunkUrl = new Resource_default({ 6411 url: buildModuleUrl_default(`Assets/IAU2006_XYS/IAU2006_XYS_${chunkIndex}.json`) 6412 }); 6413 } 6414 const promise = requestXysChunkJson(chunkUrl, chunkIndex, xysData); 6415 xysData._chunkDownloadsInProgress[chunkIndex] = promise; 6416 return promise; 6417} 6418var Iau2006XysData_default = Iau2006XysData; 6419 6420// packages/engine/Source/Core/Quaternion.js 6421function Quaternion(x, y, z, w) { 6422 this.x = x ?? 0; 6423 this.y = y ?? 0; 6424 this.z = z ?? 0; 6425 this.w = w ?? 0; 6426} 6427var fromAxisAngleScratch = new Cartesian3_default(); 6428Quaternion.fromAxisAngle = function(axis, angle, result) { 6429 Check_default.typeOf.object("axis", axis); 6430 Check_default.typeOf.number("angle", angle); 6431 const halfAngle = angle / 2; 6432 const s = Math.sin(halfAngle); 6433 fromAxisAngleScratch = Cartesian3_default.normalize(axis, fromAxisAngleScratch); 6434 const x = fromAxisAngleScratch.x * s; 6435 const y = fromAxisAngleScratch.y * s; 6436 const z = fromAxisAngleScratch.z * s; 6437 const w = Math.cos(halfAngle); 6438 if (!defined_default(result)) { 6439 return new Quaternion(x, y, z, w); 6440 } 6441 result.x = x; 6442 result.y = y; 6443 result.z = z; 6444 result.w = w; 6445 return result; 6446}; 6447var fromRotationMatrixNext = [1, 2, 0]; 6448var fromRotationMatrixQuat = new Array(3); 6449Quaternion.fromRotationMatrix = function(matrix, result) { 6450 Check_default.typeOf.object("matrix", matrix); 6451 let root; 6452 let x; 6453 let y; 6454 let z; 6455 let w; 6456 const m00 = matrix[Matrix3_default.COLUMN0ROW0]; 6457 const m11 = matrix[Matrix3_default.COLUMN1ROW1]; 6458 const m22 = matrix[Matrix3_default.COLUMN2ROW2]; 6459 const trace = m00 + m11 + m22; 6460 if (trace > 0) { 6461 root = Math.sqrt(trace + 1); 6462 w = 0.5 * root; 6463 root = 0.5 / root; 6464 x = (matrix[Matrix3_default.COLUMN1ROW2] - matrix[Matrix3_default.COLUMN2ROW1]) * root; 6465 y = (matrix[Matrix3_default.COLUMN2ROW0] - matrix[Matrix3_default.COLUMN0ROW2]) * root; 6466 z = (matrix[Matrix3_default.COLUMN0ROW1] - matrix[Matrix3_default.COLUMN1ROW0]) * root; 6467 } else { 6468 const next = fromRotationMatrixNext; 6469 let i = 0; 6470 if (m11 > m00) { 6471 i = 1; 6472 } 6473 if (m22 > m00 && m22 > m11) { 6474 i = 2; 6475 } 6476 const j = next[i]; 6477 const k = next[j]; 6478 root = Math.sqrt( 6479 matrix[Matrix3_default.getElementIndex(i, i)] - matrix[Matrix3_default.getElementIndex(j, j)] - matrix[Matrix3_default.getElementIndex(k, k)] + 1 6480 ); 6481 const quat = fromRotationMatrixQuat; 6482 quat[i] = 0.5 * root; 6483 root = 0.5 / root; 6484 w = (matrix[Matrix3_default.getElementIndex(k, j)] - matrix[Matrix3_default.getElementIndex(j, k)]) * root; 6485 quat[j] = (matrix[Matrix3_default.getElementIndex(j, i)] + matrix[Matrix3_default.getElementIndex(i, j)]) * root; 6486 quat[k] = (matrix[Matrix3_default.getElementIndex(k, i)] + matrix[Matrix3_default.getElementIndex(i, k)]) * root; 6487 x = -quat[0]; 6488 y = -quat[1]; 6489 z = -quat[2]; 6490 } 6491 if (!defined_default(result)) { 6492 return new Quaternion(x, y, z, w); 6493 } 6494 result.x = x; 6495 result.y = y; 6496 result.z = z; 6497 result.w = w; 6498 return result; 6499}; 6500var scratchHPRQuaternion = new Quaternion(); 6501var scratchHeadingQuaternion = new Quaternion(); 6502var scratchPitchQuaternion = new Quaternion(); 6503var scratchRollQuaternion = new Quaternion(); 6504Quaternion.fromHeadingPitchRoll = function(headingPitchRoll, result) { 6505 Check_default.typeOf.object("headingPitchRoll", headingPitchRoll); 6506 scratchRollQuaternion = Quaternion.fromAxisAngle( 6507 Cartesian3_default.UNIT_X, 6508 headingPitchRoll.roll, 6509 scratchHPRQuaternion 6510 ); 6511 scratchPitchQuaternion = Quaternion.fromAxisAngle( 6512 Cartesian3_default.UNIT_Y, 6513 -headingPitchRoll.pitch, 6514 result 6515 ); 6516 result = Quaternion.multiply( 6517 scratchPitchQuaternion, 6518 scratchRollQuaternion, 6519 scratchPitchQuaternion 6520 ); 6521 scratchHeadingQuaternion = Quaternion.fromAxisAngle( 6522 Cartesian3_default.UNIT_Z, 6523 -headingPitchRoll.heading, 6524 scratchHPRQuaternion 6525 ); 6526 return Quaternion.multiply(scratchHeadingQuaternion, result, result); 6527}; 6528var sampledQuaternionAxis = new Cartesian3_default(); 6529var sampledQuaternionRotation = new Cartesian3_default(); 6530var sampledQuaternionTempQuaternion = new Quaternion(); 6531var sampledQuaternionQuaternion0 = new Quaternion(); 6532var sampledQuaternionQuaternion0Conjugate = new Quaternion(); 6533Quaternion.packedLength = 4; 6534Quaternion.pack = function(value, array, startingIndex) { 6535 Check_default.typeOf.object("value", value); 6536 Check_default.defined("array", array); 6537 startingIndex = startingIndex ?? 0; 6538 array[startingIndex++] = value.x; 6539 array[startingIndex++] = value.y; 6540 array[startingIndex++] = value.z; 6541 array[startingIndex] = value.w; 6542 return array; 6543}; 6544Quaternion.unpack = function(array, startingIndex, result) { 6545 Check_default.defined("array", array); 6546 startingIndex = startingIndex ?? 0; 6547 if (!defined_default(result)) { 6548 result = new Quaternion(); 6549 } 6550 result.x = array[startingIndex]; 6551 result.y = array[startingIndex + 1]; 6552 result.z = array[startingIndex + 2]; 6553 result.w = array[startingIndex + 3]; 6554 return result; 6555}; 6556Quaternion.packedInterpolationLength = 3; 6557Quaternion.convertPackedArrayForInterpolation = function(packedArray, startingIndex, lastIndex, result) { 6558 Quaternion.unpack( 6559 packedArray, 6560 lastIndex * 4, 6561 sampledQuaternionQuaternion0Conjugate 6562 ); 6563 Quaternion.conjugate( 6564 sampledQuaternionQuaternion0Conjugate, 6565 sampledQuaternionQuaternion0Conjugate 6566 ); 6567 for (let i = 0, len = lastIndex - startingIndex + 1; i < len; i++) { 6568 const offset = i * 3; 6569 Quaternion.unpack( 6570 packedArray, 6571 (startingIndex + i) * 4, 6572 sampledQuaternionTempQuaternion 6573 ); 6574 Quaternion.multiply( 6575 sampledQuaternionTempQuaternion, 6576 sampledQuaternionQuaternion0Conjugate, 6577 sampledQuaternionTempQuaternion 6578 ); 6579 if (sampledQuaternionTempQuaternion.w < 0) { 6580 Quaternion.negate( 6581 sampledQuaternionTempQuaternion, 6582 sampledQuaternionTempQuaternion 6583 ); 6584 } 6585 Quaternion.computeAxis( 6586 sampledQuaternionTempQuaternion, 6587 sampledQuaternionAxis 6588 ); 6589 const angle = Quaternion.computeAngle(sampledQuaternionTempQuaternion); 6590 if (!defined_default(result)) { 6591 result = []; 6592 } 6593 result[offset] = sampledQuaternionAxis.x * angle; 6594 result[offset + 1] = sampledQuaternionAxis.y * angle; 6595 result[offset + 2] = sampledQuaternionAxis.z * angle; 6596 } 6597}; 6598Quaternion.unpackInterpolationResult = function(array, sourceArray, firstIndex, lastIndex, result) { 6599 if (!defined_default(result)) { 6600 result = new Quaternion(); 6601 } 6602 Cartesian3_default.fromArray(array, 0, sampledQuaternionRotation); 6603 const magnitude = Cartesian3_default.magnitude(sampledQuaternionRotation); 6604 Quaternion.unpack(sourceArray, lastIndex * 4, sampledQuaternionQuaternion0); 6605 if (magnitude === 0) { 6606 Quaternion.clone(Quaternion.IDENTITY, sampledQuaternionTempQuaternion); 6607 } else { 6608 Quaternion.fromAxisAngle( 6609 sampledQuaternionRotation, 6610 magnitude, 6611 sampledQuaternionTempQuaternion 6612 ); 6613 } 6614 return Quaternion.multiply( 6615 sampledQuaternionTempQuaternion, 6616 sampledQuaternionQuaternion0, 6617 result 6618 ); 6619}; 6620Quaternion.clone = function(quaternion, result) { 6621 if (!defined_default(quaternion)) { 6622 return void 0; 6623 } 6624 if (!defined_default(result)) { 6625 return new Quaternion( 6626 quaternion.x, 6627 quaternion.y, 6628 quaternion.z, 6629 quaternion.w 6630 ); 6631 } 6632 result.x = quaternion.x; 6633 result.y = quaternion.y; 6634 result.z = quaternion.z; 6635 result.w = quaternion.w; 6636 return result; 6637}; 6638Quaternion.conjugate = function(quaternion, result) { 6639 Check_default.typeOf.object("quaternion", quaternion); 6640 Check_default.typeOf.object("result", result); 6641 result.x = -quaternion.x; 6642 result.y = -quaternion.y; 6643 result.z = -quaternion.z; 6644 result.w = quaternion.w; 6645 return result; 6646}; 6647Quaternion.magnitudeSquared = function(quaternion) { 6648 Check_default.typeOf.object("quaternion", quaternion); 6649 return quaternion.x * quaternion.x + quaternion.y * quaternion.y + quaternion.z * quaternion.z + quaternion.w * quaternion.w; 6650}; 6651Quaternion.magnitude = function(quaternion) { 6652 return Math.sqrt(Quaternion.magnitudeSquared(quaternion)); 6653}; 6654Quaternion.normalize = function(quaternion, result) { 6655 Check_default.typeOf.object("result", result); 6656 const inverseMagnitude = 1 / Quaternion.magnitude(quaternion); 6657 const x = quaternion.x * inverseMagnitude; 6658 const y = quaternion.y * inverseMagnitude; 6659 const z = quaternion.z * inverseMagnitude; 6660 const w = quaternion.w * inverseMagnitude; 6661 result.x = x; 6662 result.y = y; 6663 result.z = z; 6664 result.w = w; 6665 return result; 6666}; 6667Quaternion.inverse = function(quaternion, result) { 6668 Check_default.typeOf.object("result", result); 6669 const magnitudeSquared = Quaternion.magnitudeSquared(quaternion); 6670 result = Quaternion.conjugate(quaternion, result); 6671 return Quaternion.multiplyByScalar(result, 1 / magnitudeSquared, result); 6672}; 6673Quaternion.add = function(left, right, result) { 6674 Check_default.typeOf.object("left", left); 6675 Check_default.typeOf.object("right", right); 6676 Check_default.typeOf.object("result", result); 6677 result.x = left.x + right.x; 6678 result.y = left.y + right.y; 6679 result.z = left.z + right.z; 6680 result.w = left.w + right.w; 6681 return result; 6682}; 6683Quaternion.subtract = function(left, right, result) { 6684 Check_default.typeOf.object("left", left); 6685 Check_default.typeOf.object("right", right); 6686 Check_default.typeOf.object("result", result); 6687 result.x = left.x - right.x; 6688 result.y = left.y - right.y; 6689 result.z = left.z - right.z; 6690 result.w = left.w - right.w; 6691 return result; 6692}; 6693Quaternion.negate = function(quaternion, result) { 6694 Check_default.typeOf.object("quaternion", quaternion); 6695 Check_default.typeOf.object("result", result); 6696 result.x = -quaternion.x; 6697 result.y = -quaternion.y; 6698 result.z = -quaternion.z; 6699 result.w = -quaternion.w; 6700 return result; 6701}; 6702Quaternion.dot = function(left, right) { 6703 Check_default.typeOf.object("left", left); 6704 Check_default.typeOf.object("right", right); 6705 return left.x * right.x + left.y * right.y + left.z * right.z + left.w * right.w; 6706}; 6707Quaternion.multiply = function(left, right, result) { 6708 Check_default.typeOf.object("left", left); 6709 Check_default.typeOf.object("right", right); 6710 Check_default.typeOf.object("result", result); 6711 const leftX = left.x; 6712 const leftY = left.y; 6713 const leftZ = left.z; 6714 const leftW = left.w; 6715 const rightX = right.x; 6716 const rightY = right.y; 6717 const rightZ = right.z; 6718 const rightW = right.w; 6719 const x = leftW * rightX + leftX * rightW + leftY * rightZ - leftZ * rightY; 6720 const y = leftW * rightY - leftX * rightZ + leftY * rightW + leftZ * rightX; 6721 const z = leftW * rightZ + leftX * rightY - leftY * rightX + leftZ * rightW; 6722 const w = leftW * rightW - leftX * rightX - leftY * rightY - leftZ * rightZ; 6723 result.x = x; 6724 result.y = y; 6725 result.z = z; 6726 result.w = w; 6727 return result; 6728}; 6729Quaternion.multiplyByScalar = function(quaternion, scalar, result) { 6730 Check_default.typeOf.object("quaternion", quaternion); 6731 Check_default.typeOf.number("scalar", scalar); 6732 Check_default.typeOf.object("result", result); 6733 result.x = quaternion.x * scalar; 6734 result.y = quaternion.y * scalar; 6735 result.z = quaternion.z * scalar; 6736 result.w = quaternion.w * scalar; 6737 return result; 6738}; 6739Quaternion.divideByScalar = function(quaternion, scalar, result) { 6740 Check_default.typeOf.object("quaternion", quaternion); 6741 Check_default.typeOf.number("scalar", scalar); 6742 Check_default.typeOf.object("result", result); 6743 result.x = quaternion.x / scalar; 6744 result.y = quaternion.y / scalar; 6745 result.z = quaternion.z / scalar; 6746 result.w = quaternion.w / scalar; 6747 return result; 6748}; 6749Quaternion.computeAxis = function(quaternion, result) { 6750 Check_default.typeOf.object("quaternion", quaternion); 6751 Check_default.typeOf.object("result", result); 6752 const w = quaternion.w; 6753 if (Math.abs(w - 1) < Math_default.EPSILON6 || Math.abs(w + 1) < Math_default.EPSILON6) { 6754 result.x = 1; 6755 result.y = result.z = 0; 6756 return result; 6757 } 6758 const scalar = 1 / Math.sqrt(1 - w * w); 6759 result.x = quaternion.x * scalar; 6760 result.y = quaternion.y * scalar; 6761 result.z = quaternion.z * scalar; 6762 return result; 6763}; 6764Quaternion.computeAngle = function(quaternion) { 6765 Check_default.typeOf.object("quaternion", quaternion); 6766 if (Math.abs(quaternion.w - 1) < Math_default.EPSILON6) { 6767 return 0; 6768 } 6769 return 2 * Math.acos(quaternion.w); 6770}; 6771var lerpScratch = new Quaternion(); 6772Quaternion.lerp = function(start, end, t, result) { 6773 Check_default.typeOf.object("start", start); 6774 Check_default.typeOf.object("end", end); 6775 Check_default.typeOf.number("t", t); 6776 Check_default.typeOf.object("result", result); 6777 lerpScratch = Quaternion.multiplyByScalar(end, t, lerpScratch); 6778 result = Quaternion.multiplyByScalar(start, 1 - t, result); 6779 return Quaternion.add(lerpScratch, result, result); 6780}; 6781var slerpEndNegated = new Quaternion(); 6782var slerpScaledP = new Quaternion(); 6783var slerpScaledR = new Quaternion(); 6784Quaternion.slerp = function(start, end, t, result) { 6785 Check_default.typeOf.object("start", start); 6786 Check_default.typeOf.object("end", end); 6787 Check_default.typeOf.number("t", t); 6788 Check_default.typeOf.object("result", result); 6789 let dot = Quaternion.dot(start, end); 6790 let r = end; 6791 if (dot < 0) { 6792 dot = -dot; 6793 r = slerpEndNegated = Quaternion.negate(end, slerpEndNegated); 6794 } 6795 if (1 - dot < Math_default.EPSILON6) { 6796 return Quaternion.lerp(start, r, t, result); 6797 } 6798 const theta = Math.acos(dot); 6799 slerpScaledP = Quaternion.multiplyByScalar( 6800 start, 6801 Math.sin((1 - t) * theta), 6802 slerpScaledP 6803 ); 6804 slerpScaledR = Quaternion.multiplyByScalar( 6805 r, 6806 Math.sin(t * theta), 6807 slerpScaledR 6808 ); 6809 result = Quaternion.add(slerpScaledP, slerpScaledR, result); 6810 return Quaternion.multiplyByScalar(result, 1 / Math.sin(theta), result); 6811}; 6812Quaternion.log = function(quaternion, result) { 6813 Check_default.typeOf.object("quaternion", quaternion); 6814 Check_default.typeOf.object("result", result); 6815 const theta = Math_default.acosClamped(quaternion.w); 6816 let thetaOverSinTheta = 0; 6817 if (theta !== 0) { 6818 thetaOverSinTheta = theta / Math.sin(theta); 6819 } 6820 return Cartesian3_default.multiplyByScalar(quaternion, thetaOverSinTheta, result); 6821}; 6822Quaternion.exp = function(cartesian, result) { 6823 Check_default.typeOf.object("cartesian", cartesian); 6824 Check_default.typeOf.object("result", result); 6825 const theta = Cartesian3_default.magnitude(cartesian); 6826 let sinThetaOverTheta = 0; 6827 if (theta !== 0) { 6828 sinThetaOverTheta = Math.sin(theta) / theta; 6829 } 6830 result.x = cartesian.x * sinThetaOverTheta; 6831 result.y = cartesian.y * sinThetaOverTheta; 6832 result.z = cartesian.z * sinThetaOverTheta; 6833 result.w = Math.cos(theta); 6834 return result; 6835}; 6836var squadScratchCartesian0 = new Cartesian3_default(); 6837var squadScratchCartesian1 = new Cartesian3_default(); 6838var squadScratchQuaternion0 = new Quaternion(); 6839var squadScratchQuaternion1 = new Quaternion(); 6840Quaternion.computeInnerQuadrangle = function(q0, q1, q2, result) { 6841 Check_default.typeOf.object("q0", q0); 6842 Check_default.typeOf.object("q1", q1); 6843 Check_default.typeOf.object("q2", q2); 6844 Check_default.typeOf.object("result", result); 6845 const qInv = Quaternion.conjugate(q1, squadScratchQuaternion0); 6846 Quaternion.multiply(qInv, q2, squadScratchQuaternion1); 6847 const cart0 = Quaternion.log(squadScratchQuaternion1, squadScratchCartesian0); 6848 Quaternion.multiply(qInv, q0, squadScratchQuaternion1); 6849 const cart1 = Quaternion.log(squadScratchQuaternion1, squadScratchCartesian1); 6850 Cartesian3_default.add(cart0, cart1, cart0); 6851 Cartesian3_default.multiplyByScalar(cart0, 0.25, cart0); 6852 Cartesian3_default.negate(cart0, cart0); 6853 Quaternion.exp(cart0, squadScratchQuaternion0); 6854 return Quaternion.multiply(q1, squadScratchQuaternion0, result); 6855}; 6856Quaternion.squad = function(q0, q1, s0, s1, t, result) { 6857 Check_default.typeOf.object("q0", q0); 6858 Check_default.typeOf.object("q1", q1); 6859 Check_default.typeOf.object("s0", s0); 6860 Check_default.typeOf.object("s1", s1); 6861 Check_default.typeOf.number("t", t); 6862 Check_default.typeOf.object("result", result); 6863 const slerp0 = Quaternion.slerp(q0, q1, t, squadScratchQuaternion0); 6864 const slerp1 = Quaternion.slerp(s0, s1, t, squadScratchQuaternion1); 6865 return Quaternion.slerp(slerp0, slerp1, 2 * t * (1 - t), result); 6866}; 6867var fastSlerpScratchQuaternion = new Quaternion(); 6868var opmu = 1.9011074535173003; 6869var u = FeatureDetection_default.supportsTypedArrays() ? new Float32Array(8) : []; 6870var v = FeatureDetection_default.supportsTypedArrays() ? new Float32Array(8) : []; 6871var bT = FeatureDetection_default.supportsTypedArrays() ? new Float32Array(8) : []; 6872var bD = FeatureDetection_default.supportsTypedArrays() ? new Float32Array(8) : []; 6873for (let i = 0; i < 7; ++i) { 6874 const s = i + 1; 6875 const t = 2 * s + 1; 6876 u[i] = 1 / (s * t); 6877 v[i] = s / t; 6878} 6879u[7] = opmu / (8 * 17); 6880v[7] = opmu * 8 / 17; 6881Quaternion.fastSlerp = function(start, end, t, result) { 6882 Check_default.typeOf.object("start", start); 6883 Check_default.typeOf.object("end", end); 6884 Check_default.typeOf.number("t", t); 6885 Check_default.typeOf.object("result", result); 6886 let x = Quaternion.dot(start, end); 6887 let sign; 6888 if (x >= 0) { 6889 sign = 1; 6890 } else { 6891 sign = -1; 6892 x = -x; 6893 } 6894 const xm1 = x - 1; 6895 const d = 1 - t; 6896 const sqrT = t * t; 6897 const sqrD = d * d; 6898 for (let i = 7; i >= 0; --i) { 6899 bT[i] = (u[i] * sqrT - v[i]) * xm1; 6900 bD[i] = (u[i] * sqrD - v[i]) * xm1; 6901 } 6902 const cT = sign * t * (1 + bT[0] * (1 + bT[1] * (1 + bT[2] * (1 + bT[3] * (1 + bT[4] * (1 + bT[5] * (1 + bT[6] * (1 + bT[7])))))))); 6903 const cD = d * (1 + bD[0] * (1 + bD[1] * (1 + bD[2] * (1 + bD[3] * (1 + bD[4] * (1 + bD[5] * (1 + bD[6] * (1 + bD[7])))))))); 6904 const temp = Quaternion.multiplyByScalar( 6905 start, 6906 cD, 6907 fastSlerpScratchQuaternion 6908 ); 6909 Quaternion.multiplyByScalar(end, cT, result); 6910 return Quaternion.add(temp, result, result); 6911}; 6912Quaternion.fastSquad = function(q0, q1, s0, s1, t, result) { 6913 Check_default.typeOf.object("q0", q0); 6914 Check_default.typeOf.object("q1", q1); 6915 Check_default.typeOf.object("s0", s0); 6916 Check_default.typeOf.object("s1", s1); 6917 Check_default.typeOf.number("t", t); 6918 Check_default.typeOf.object("result", result); 6919 const slerp0 = Quaternion.fastSlerp(q0, q1, t, squadScratchQuaternion0); 6920 const slerp1 = Quaternion.fastSlerp(s0, s1, t, squadScratchQuaternion1); 6921 return Quaternion.fastSlerp(slerp0, slerp1, 2 * t * (1 - t), result); 6922}; 6923Quaternion.equals = function(left, right) { 6924 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; 6925}; 6926Quaternion.equalsEpsilon = function(left, right, epsilon) { 6927 epsilon = epsilon ?? 0; 6928 return left === right || defined_default(left) && defined_default(right) && Math.abs(left.x - right.x) <= epsilon && Math.abs(left.y - right.y) <= epsilon && Math.abs(left.z - right.z) <= epsilon && Math.abs(left.w - right.w) <= epsilon; 6929}; 6930Quaternion.ZERO = Object.freeze(new Quaternion(0, 0, 0, 0)); 6931Quaternion.IDENTITY = Object.freeze(new Quaternion(0, 0, 0, 1)); 6932Quaternion.prototype.clone = function(result) { 6933 return Quaternion.clone(this, result); 6934}; 6935Quaternion.prototype.equals = function(right) { 6936 return Quaternion.equals(this, right); 6937}; 6938Quaternion.prototype.equalsEpsilon = function(right, epsilon) { 6939 return Quaternion.equalsEpsilon(this, right, epsilon); 6940}; 6941Quaternion.prototype.toString = function() { 6942 return `(${this.x}, ${this.y}, ${this.z}, ${this.w})`; 6943}; 6944var Quaternion_default = Quaternion; 6945 6946// packages/engine/Source/Core/Transforms.js 6947var Transforms = {}; 6948var vectorProductLocalFrame = { 6949 up: { 6950 south: "east", 6951 north: "west", 6952 west: "south", 6953 east: "north" 6954 }, 6955 down: { 6956 south: "west", 6957 north: "east", 6958 west: "north", 6959 east: "south" 6960 }, 6961 south: { 6962 up: "west", 6963 down: "east", 6964 west: "down", 6965 east: "up" 6966 }, 6967 north: { 6968 up: "east", 6969 down: "west", 6970 west: "up", 6971 east: "down" 6972 }, 6973 west: { 6974 up: "north", 6975 down: "south", 6976 north: "down", 6977 south: "up" 6978 }, 6979 east: { 6980 up: "south", 6981 down: "north", 6982 north: "up", 6983 south: "down" 6984 } 6985}; 6986var degeneratePositionLocalFrame = { 6987 north: [-1, 0, 0], 6988 east: [0, 1, 0], 6989 up: [0, 0, 1], 6990 south: [1, 0, 0], 6991 west: [0, -1, 0], 6992 down: [0, 0, -1] 6993}; 6994var localFrameToFixedFrameCache = {}; 6995var scratchCalculateCartesian = { 6996 east: new Cartesian3_default(), 6997 north: new Cartesian3_default(), 6998 up: new Cartesian3_default(), 6999 west: new Cartesian3_default(), 7000 south: new Cartesian3_default(), 7001 down: new Cartesian3_default() 7002}; 7003var scratchFirstCartesian = new Cartesian3_default(); 7004var scratchSecondCartesian = new Cartesian3_default(); 7005var scratchThirdCartesian = new Cartesian3_default(); 7006Transforms.localFrameToFixedFrameGenerator = function(firstAxis, secondAxis) { 7007 if (!vectorProductLocalFrame.hasOwnProperty(firstAxis) || !vectorProductLocalFrame[firstAxis].hasOwnProperty(secondAxis)) { 7008 throw new DeveloperError_default( 7009 "firstAxis and secondAxis must be east, north, up, west, south or down." 7010 ); 7011 } 7012 const thirdAxis = vectorProductLocalFrame[firstAxis][secondAxis]; 7013 let resultat; 7014 const hashAxis = firstAxis + secondAxis; 7015 if (defined_default(localFrameToFixedFrameCache[hashAxis])) { 7016 resultat = localFrameToFixedFrameCache[hashAxis]; 7017 } else { 7018 resultat = function(origin, ellipsoid, result) { 7019 if (!defined_default(origin)) { 7020 throw new DeveloperError_default("origin is required."); 7021 } 7022 if (isNaN(origin.x) || isNaN(origin.y) || isNaN(origin.z)) { 7023 throw new DeveloperError_default("origin has a NaN component"); 7024 } 7025 if (!defined_default(result)) { 7026 result = new Matrix4_default(); 7027 } 7028 if (Cartesian3_default.equalsEpsilon(origin, Cartesian3_default.ZERO, Math_default.EPSILON14)) { 7029 Cartesian3_default.unpack( 7030 degeneratePositionLocalFrame[firstAxis], 7031 0, 7032 scratchFirstCartesian 7033 ); 7034 Cartesian3_default.unpack( 7035 degeneratePositionLocalFrame[secondAxis], 7036 0, 7037 scratchSecondCartesian 7038 ); 7039 Cartesian3_default.unpack( 7040 degeneratePositionLocalFrame[thirdAxis], 7041 0, 7042 scratchThirdCartesian 7043 ); 7044 } else if (Math_default.equalsEpsilon(origin.x, 0, Math_default.EPSILON14) && Math_default.equalsEpsilon(origin.y, 0, Math_default.EPSILON14)) { 7045 const sign = Math_default.sign(origin.z); 7046 Cartesian3_default.unpack( 7047 degeneratePositionLocalFrame[firstAxis], 7048 0, 7049 scratchFirstCartesian 7050 ); 7051 if (firstAxis !== "east" && firstAxis !== "west") { 7052 Cartesian3_default.multiplyByScalar( 7053 scratchFirstCartesian, 7054 sign, 7055 scratchFirstCartesian 7056 ); 7057 } 7058 Cartesian3_default.unpack( 7059 degeneratePositionLocalFrame[secondAxis], 7060 0, 7061 scratchSecondCartesian 7062 ); 7063 if (secondAxis !== "east" && secondAxis !== "west") { 7064 Cartesian3_default.multiplyByScalar( 7065 scratchSecondCartesian, 7066 sign, 7067 scratchSecondCartesian 7068 ); 7069 } 7070 Cartesian3_default.unpack( 7071 degeneratePositionLocalFrame[thirdAxis], 7072 0, 7073 scratchThirdCartesian 7074 ); 7075 if (thirdAxis !== "east" && thirdAxis !== "west") { 7076 Cartesian3_default.multiplyByScalar( 7077 scratchThirdCartesian, 7078 sign, 7079 scratchThirdCartesian 7080 ); 7081 } 7082 } else { 7083 ellipsoid = ellipsoid ?? Ellipsoid_default.default; 7084 ellipsoid.geodeticSurfaceNormal(origin, scratchCalculateCartesian.up); 7085 const up = scratchCalculateCartesian.up; 7086 const east = scratchCalculateCartesian.east; 7087 east.x = -origin.y; 7088 east.y = origin.x; 7089 east.z = 0; 7090 Cartesian3_default.normalize(east, scratchCalculateCartesian.east); 7091 Cartesian3_default.cross(up, east, scratchCalculateCartesian.north); 7092 Cartesian3_default.multiplyByScalar( 7093 scratchCalculateCartesian.up, 7094 -1, 7095 scratchCalculateCartesian.down 7096 ); 7097 Cartesian3_default.multiplyByScalar( 7098 scratchCalculateCartesian.east, 7099 -1, 7100 scratchCalculateCartesian.west 7101 ); 7102 Cartesian3_default.multiplyByScalar( 7103 scratchCalculateCartesian.north, 7104 -1, 7105 scratchCalculateCartesian.south 7106 ); 7107 scratchFirstCartesian = scratchCalculateCartesian[firstAxis]; 7108 scratchSecondCartesian = scratchCalculateCartesian[secondAxis]; 7109 scratchThirdCartesian = scratchCalculateCartesian[thirdAxis]; 7110 } 7111 result[0] = scratchFirstCartesian.x; 7112 result[1] = scratchFirstCartesian.y; 7113 result[2] = scratchFirstCartesian.z; 7114 result[3] = 0; 7115 result[4] = scratchSecondCartesian.x; 7116 result[5] = scratchSecondCartesian.y; 7117 result[6] = scratchSecondCartesian.z; 7118 result[7] = 0; 7119 result[8] = scratchThirdCartesian.x; 7120 result[9] = scratchThirdCartesian.y; 7121 result[10] = scratchThirdCartesian.z; 7122 result[11] = 0; 7123 result[12] = origin.x; 7124 result[13] = origin.y; 7125 result[14] = origin.z; 7126 result[15] = 1; 7127 return result; 7128 }; 7129 localFrameToFixedFrameCache[hashAxis] = resultat; 7130 } 7131 return resultat; 7132}; 7133Transforms.eastNorthUpToFixedFrame = Transforms.localFrameToFixedFrameGenerator( 7134 "east", 7135 "north" 7136); 7137Transforms.northEastDownToFixedFrame = Transforms.localFrameToFixedFrameGenerator("north", "east"); 7138Transforms.northUpEastToFixedFrame = Transforms.localFrameToFixedFrameGenerator( 7139 "north", 7140 "up" 7141); 7142Transforms.northWestUpToFixedFrame = Transforms.localFrameToFixedFrameGenerator( 7143 "north", 7144 "west" 7145); 7146var scratchHPRQuaternion2 = new Quaternion_default(); 7147var scratchScale = new Cartesian3_default(1, 1, 1); 7148var scratchHPRMatrix4 = new Matrix4_default(); 7149Transforms.headingPitchRollToFixedFrame = function(origin, headingPitchRoll, ellipsoid, fixedFrameTransform, result) { 7150 Check_default.typeOf.object("HeadingPitchRoll", headingPitchRoll); 7151 fixedFrameTransform = fixedFrameTransform ?? Transforms.eastNorthUpToFixedFrame; 7152 const hprQuaternion = Quaternion_default.fromHeadingPitchRoll( 7153 headingPitchRoll, 7154 scratchHPRQuaternion2 7155 ); 7156 const hprMatrix = Matrix4_default.fromTranslationQuaternionRotationScale( 7157 Cartesian3_default.ZERO, 7158 hprQuaternion, 7159 scratchScale, 7160 scratchHPRMatrix4 7161 ); 7162 result = fixedFrameTransform(origin, ellipsoid, result); 7163 return Matrix4_default.multiply(result, hprMatrix, result); 7164}; 7165var scratchENUMatrix4 = new Matrix4_default(); 7166var scratchHPRMatrix3 = new Matrix3_default(); 7167Transforms.headingPitchRollQuaternion = function(origin, headingPitchRoll, ellipsoid, fixedFrameTransform, result) { 7168 Check_default.typeOf.object("HeadingPitchRoll", headingPitchRoll); 7169 const transform = Transforms.headingPitchRollToFixedFrame( 7170 origin, 7171 headingPitchRoll, 7172 ellipsoid, 7173 fixedFrameTransform, 7174 scratchENUMatrix4 7175 ); 7176 const rotation = Matrix4_default.getMatrix3(transform, scratchHPRMatrix3); 7177 return Quaternion_default.fromRotationMatrix(rotation, result); 7178}; 7179var noScale = new Cartesian3_default(1, 1, 1); 7180var hprCenterScratch = new Cartesian3_default(); 7181var ffScratch = new Matrix4_default(); 7182var hprTransformScratch = new Matrix4_default(); 7183var hprRotationScratch = new Matrix3_default(); 7184var hprQuaternionScratch = new Quaternion_default(); 7185Transforms.fixedFrameToHeadingPitchRoll = function(transform, ellipsoid, fixedFrameTransform, result) { 7186 Check_default.defined("transform", transform); 7187 ellipsoid = ellipsoid ?? Ellipsoid_default.default; 7188 fixedFrameTransform = fixedFrameTransform ?? Transforms.eastNorthUpToFixedFrame; 7189 if (!defined_default(result)) { 7190 result = new HeadingPitchRoll_default(); 7191 } 7192 const center = Matrix4_default.getTranslation(transform, hprCenterScratch); 7193 if (Cartesian3_default.equals(center, Cartesian3_default.ZERO)) { 7194 result.heading = 0; 7195 result.pitch = 0; 7196 result.roll = 0; 7197 return result; 7198 } 7199 let toFixedFrame = Matrix4_default.inverseTransformation( 7200 fixedFrameTransform(center, ellipsoid, ffScratch), 7201 ffScratch 7202 ); 7203 let transformCopy = Matrix4_default.setScale(transform, noScale, hprTransformScratch); 7204 transformCopy = Matrix4_default.setTranslation( 7205 transformCopy, 7206 Cartesian3_default.ZERO, 7207 transformCopy 7208 ); 7209 toFixedFrame = Matrix4_default.multiply(toFixedFrame, transformCopy, toFixedFrame); 7210 let quaternionRotation = Quaternion_default.fromRotationMatrix( 7211 Matrix4_default.getMatrix3(toFixedFrame, hprRotationScratch), 7212 hprQuaternionScratch 7213 ); 7214 quaternionRotation = Quaternion_default.normalize( 7215 quaternionRotation, 7216 quaternionRotation 7217 ); 7218 return HeadingPitchRoll_default.fromQuaternion(quaternionRotation, result); 7219}; 7220var gmstConstant0 = 6 * 3600 + 41 * 60 + 50.54841; 7221var gmstConstant1 = 8640184812866e-6; 7222var gmstConstant2 = 0.093104; 7223var gmstConstant3 = -62e-7; 7224var rateCoef = 11772758384668e-32; 7225var wgs84WRPrecessing = 72921158553e-15; 7226var twoPiOverSecondsInDay = Math_default.TWO_PI / 86400; 7227var dateInUtc = new JulianDate_default(); 7228Transforms.computeIcrfToCentralBodyFixedMatrix = function(date, result) { 7229 let transformMatrix = Transforms.computeIcrfToFixedMatrix(date, result); 7230 if (!defined_default(transformMatrix)) { 7231 transformMatrix = Transforms.computeTemeToPseudoFixedMatrix(date, result); 7232 } 7233 return transformMatrix; 7234}; 7235Transforms.computeTemeToPseudoFixedMatrix = function(date, result) { 7236 if (!defined_default(date)) { 7237 throw new DeveloperError_default("date is required."); 7238 } 7239 dateInUtc = JulianDate_default.addSeconds( 7240 date, 7241 -JulianDate_default.computeTaiMinusUtc(date), 7242 dateInUtc 7243 ); 7244 const utcDayNumber = dateInUtc.dayNumber; 7245 const utcSecondsIntoDay = dateInUtc.secondsOfDay; 7246 let t; 7247 const diffDays = utcDayNumber - 2451545; 7248 if (utcSecondsIntoDay >= 43200) { 7249 t = (diffDays + 0.5) / TimeConstants_default.DAYS_PER_JULIAN_CENTURY; 7250 } else { 7251 t = (diffDays - 0.5) / TimeConstants_default.DAYS_PER_JULIAN_CENTURY; 7252 } 7253 const gmst0 = gmstConstant0 + t * (gmstConstant1 + t * (gmstConstant2 + t * gmstConstant3)); 7254 const angle = gmst0 * twoPiOverSecondsInDay % Math_default.TWO_PI; 7255 const ratio = wgs84WRPrecessing + rateCoef * (utcDayNumber - 24515455e-1); 7256 const secondsSinceMidnight = (utcSecondsIntoDay + TimeConstants_default.SECONDS_PER_DAY * 0.5) % TimeConstants_default.SECONDS_PER_DAY; 7257 const gha = angle + ratio * secondsSinceMidnight; 7258 const cosGha = Math.cos(gha); 7259 const sinGha = Math.sin(gha); 7260 if (!defined_default(result)) { 7261 return new Matrix3_default( 7262 cosGha, 7263 sinGha, 7264 0, 7265 -sinGha, 7266 cosGha, 7267 0, 7268 0, 7269 0, 7270 1 7271 ); 7272 } 7273 result[0] = cosGha; 7274 result[1] = -sinGha; 7275 result[2] = 0; 7276 result[3] = sinGha; 7277 result[4] = cosGha; 7278 result[5] = 0; 7279 result[6] = 0; 7280 result[7] = 0; 7281 result[8] = 1; 7282 return result; 7283}; 7284Transforms.iau2006XysData = new Iau2006XysData_default(); 7285Transforms.earthOrientationParameters = EarthOrientationParameters_default.NONE; 7286var ttMinusTai = 32.184; 7287var j2000ttDays = 2451545; 7288Transforms.preloadIcrfFixed = function(timeInterval) { 7289 const startDayTT = timeInterval.start.dayNumber; 7290 const startSecondTT = timeInterval.start.secondsOfDay + ttMinusTai; 7291 const stopDayTT = timeInterval.stop.dayNumber; 7292 const stopSecondTT = timeInterval.stop.secondsOfDay + ttMinusTai; 7293 return Transforms.iau2006XysData.preload( 7294 startDayTT, 7295 startSecondTT, 7296 stopDayTT, 7297 stopSecondTT 7298 ); 7299}; 7300Transforms.computeIcrfToFixedMatrix = function(date, result) { 7301 if (!defined_default(date)) { 7302 throw new DeveloperError_default("date is required."); 7303 } 7304 if (!defined_default(result)) { 7305 result = new Matrix3_default(); 7306 } 7307 const fixedToIcrfMtx = Transforms.computeFixedToIcrfMatrix(date, result); 7308 if (!defined_default(fixedToIcrfMtx)) { 7309 return void 0; 7310 } 7311 return Matrix3_default.transpose(fixedToIcrfMtx, result); 7312}; 7313var TdtMinusTai = 32.184; 7314var J2000d = 2451545; 7315var scratchHpr = new HeadingPitchRoll_default(); 7316var scratchRotationMatrix = new Matrix3_default(); 7317var dateScratch = new JulianDate_default(); 7318Transforms.computeMoonFixedToIcrfMatrix = function(date, result) { 7319 if (!defined_default(date)) { 7320 throw new DeveloperError_default("date is required."); 7321 } 7322 if (!defined_default(result)) { 7323 result = new Matrix3_default(); 7324 } 7325 const secondsTT = JulianDate_default.addSeconds(date, TdtMinusTai, dateScratch); 7326 const d = JulianDate_default.totalDays(secondsTT) - J2000d; 7327 const e1 = Math_default.toRadians(12.112) - Math_default.toRadians(0.052992) * d; 7328 const e2 = Math_default.toRadians(24.224) - Math_default.toRadians(0.105984) * d; 7329 const e3 = Math_default.toRadians(227.645) + Math_default.toRadians(13.012) * d; 7330 const e4 = Math_default.toRadians(261.105) + Math_default.toRadians(13.340716) * d; 7331 const e5 = Math_default.toRadians(358) + Math_default.toRadians(0.9856) * d; 7332 scratchHpr.pitch = Math_default.toRadians(270 - 90) - Math_default.toRadians(3.878) * Math.sin(e1) - Math_default.toRadians(0.12) * Math.sin(e2) + Math_default.toRadians(0.07) * Math.sin(e3) - Math_default.toRadians(0.017) * Math.sin(e4); 7333 scratchHpr.roll = Math_default.toRadians(66.53 - 90) + Math_default.toRadians(1.543) * Math.cos(e1) + Math_default.toRadians(0.24) * Math.cos(e2) - Math_default.toRadians(0.028) * Math.cos(e3) + Math_default.toRadians(7e-3) * Math.cos(e4); 7334 scratchHpr.heading = Math_default.toRadians(244.375 - 90) + Math_default.toRadians(13.17635831) * d + Math_default.toRadians(3.558) * Math.sin(e1) + Math_default.toRadians(0.121) * Math.sin(e2) - Math_default.toRadians(0.064) * Math.sin(e3) + Math_default.toRadians(0.016) * Math.sin(e4) + Math_default.toRadians(0.025) * Math.sin(e5); 7335 return Matrix3_default.fromHeadingPitchRoll( 7336 scratchHpr, 7337 scratchRotationMatrix, 7338 result 7339 ); 7340}; 7341Transforms.computeIcrfToMoonFixedMatrix = function(date, result) { 7342 if (!defined_default(date)) { 7343 throw new DeveloperError_default("date is required."); 7344 } 7345 if (!defined_default(result)) { 7346 result = new Matrix3_default(); 7347 } 7348 const fixedToIcrfMtx = Transforms.computeMoonFixedToIcrfMatrix(date, result); 7349 if (!defined_default(fixedToIcrfMtx)) { 7350 return void 0; 7351 } 7352 return Matrix3_default.transpose(fixedToIcrfMtx, result); 7353}; 7354var xysScratch = new Iau2006XysSample_default(0, 0, 0); 7355var eopScratch = new EarthOrientationParametersSample_default( 7356 0, 7357 0, 7358 0, 7359 0, 7360 0, 7361 0 7362); 7363var rotation1Scratch = new Matrix3_default(); 7364var rotation2Scratch = new Matrix3_default(); 7365Transforms.computeFixedToIcrfMatrix = function(date, result) { 7366 if (!defined_default(date)) { 7367 throw new DeveloperError_default("date is required."); 7368 } 7369 if (!defined_default(result)) { 7370 result = new Matrix3_default(); 7371 } 7372 const eop = Transforms.earthOrientationParameters.compute(date, eopScratch); 7373 if (!defined_default(eop)) { 7374 return void 0; 7375 } 7376 const dayTT = date.dayNumber; 7377 const secondTT = date.secondsOfDay + ttMinusTai; 7378 const xys = Transforms.iau2006XysData.computeXysRadians( 7379 dayTT, 7380 secondTT, 7381 xysScratch 7382 ); 7383 if (!defined_default(xys)) { 7384 return void 0; 7385 } 7386 const x = xys.x + eop.xPoleOffset; 7387 const y = xys.y + eop.yPoleOffset; 7388 const a3 = 1 / (1 + Math.sqrt(1 - x * x - y * y)); 7389 const rotation1 = rotation1Scratch; 7390 rotation1[0] = 1 - a3 * x * x; 7391 rotation1[3] = -a3 * x * y; 7392 rotation1[6] = x; 7393 rotation1[1] = -a3 * x * y; 7394 rotation1[4] = 1 - a3 * y * y; 7395 rotation1[7] = y; 7396 rotation1[2] = -x; 7397 rotation1[5] = -y; 7398 rotation1[8] = 1 - a3 * (x * x + y * y); 7399 const rotation2 = Matrix3_default.fromRotationZ(-xys.s, rotation2Scratch); 7400 const matrixQ = Matrix3_default.multiply(rotation1, rotation2, rotation1Scratch); 7401 const dateUt1day = date.dayNumber; 7402 const dateUt1sec = date.secondsOfDay - JulianDate_default.computeTaiMinusUtc(date) + eop.ut1MinusUtc; 7403 const daysSinceJ2000 = dateUt1day - 2451545; 7404 const fractionOfDay = dateUt1sec / TimeConstants_default.SECONDS_PER_DAY; 7405 let era = 0.779057273264 + fractionOfDay + 0.00273781191135448 * (daysSinceJ2000 + fractionOfDay); 7406 era = era % 1 * Math_default.TWO_PI; 7407 const earthRotation = Matrix3_default.fromRotationZ(era, rotation2Scratch); 7408 const pfToIcrf = Matrix3_default.multiply(matrixQ, earthRotation, rotation1Scratch); 7409 const cosxp = Math.cos(eop.xPoleWander); 7410 const cosyp = Math.cos(eop.yPoleWander); 7411 const sinxp = Math.sin(eop.xPoleWander); 7412 const sinyp = Math.sin(eop.yPoleWander); 7413 let ttt = dayTT - j2000ttDays + secondTT / TimeConstants_default.SECONDS_PER_DAY; 7414 ttt /= 36525; 7415 const sp = -47e-6 * ttt * Math_default.RADIANS_PER_DEGREE / 3600; 7416 const cossp = Math.cos(sp); 7417 const sinsp = Math.sin(sp); 7418 const fToPfMtx = rotation2Scratch; 7419 fToPfMtx[0] = cosxp * cossp; 7420 fToPfMtx[1] = cosxp * sinsp; 7421 fToPfMtx[2] = sinxp; 7422 fToPfMtx[3] = -cosyp * sinsp + sinyp * sinxp * cossp; 7423 fToPfMtx[4] = cosyp * cossp + sinyp * sinxp * sinsp; 7424 fToPfMtx[5] = -sinyp * cosxp; 7425 fToPfMtx[6] = -sinyp * sinsp - cosyp * sinxp * cossp; 7426 fToPfMtx[7] = sinyp * cossp - cosyp * sinxp * sinsp; 7427 fToPfMtx[8] = cosyp * cosxp; 7428 return Matrix3_default.multiply(pfToIcrf, fToPfMtx, result); 7429}; 7430var pointToWindowCoordinatesTemp = new Cartesian4_default(); 7431Transforms.pointToWindowCoordinates = function(modelViewProjectionMatrix, viewportTransformation, point, result) { 7432 result = Transforms.pointToGLWindowCoordinates( 7433 modelViewProjectionMatrix, 7434 viewportTransformation, 7435 point, 7436 result 7437 ); 7438 result.y = 2 * viewportTransformation[5] - result.y; 7439 return result; 7440}; 7441Transforms.pointToGLWindowCoordinates = function(modelViewProjectionMatrix, viewportTransformation, point, result) { 7442 if (!defined_default(modelViewProjectionMatrix)) { 7443 throw new DeveloperError_default("modelViewProjectionMatrix is required."); 7444 } 7445 if (!defined_default(viewportTransformation)) { 7446 throw new DeveloperError_default("viewportTransformation is required."); 7447 } 7448 if (!defined_default(point)) { 7449 throw new DeveloperError_default("point is required."); 7450 } 7451 if (!defined_default(result)) { 7452 result = new Cartesian2_default(); 7453 } 7454 const tmp = pointToWindowCoordinatesTemp; 7455 Matrix4_default.multiplyByVector( 7456 modelViewProjectionMatrix, 7457 Cartesian4_default.fromElements(point.x, point.y, point.z, 1, tmp), 7458 tmp 7459 ); 7460 Cartesian4_default.multiplyByScalar(tmp, 1 / tmp.w, tmp); 7461 Matrix4_default.multiplyByVector(viewportTransformation, tmp, tmp); 7462 return Cartesian2_default.fromCartesian4(tmp, result); 7463}; 7464var normalScratch = new Cartesian3_default(); 7465var rightScratch = new Cartesian3_default(); 7466var upScratch = new Cartesian3_default(); 7467Transforms.rotationMatrixFromPositionVelocity = function(position, velocity, ellipsoid, result) { 7468 if (!defined_default(position)) { 7469 throw new DeveloperError_default("position is required."); 7470 } 7471 if (!defined_default(velocity)) { 7472 throw new DeveloperError_default("velocity is required."); 7473 } 7474 const normal = (ellipsoid ?? Ellipsoid_default.default).geodeticSurfaceNormal( 7475 position, 7476 normalScratch 7477 ); 7478 let right = Cartesian3_default.cross(velocity, normal, rightScratch); 7479 if (Cartesian3_default.equalsEpsilon(right, Cartesian3_default.ZERO, Math_default.EPSILON6)) { 7480 right = Cartesian3_default.clone(Cartesian3_default.UNIT_X, right); 7481 } 7482 const up = Cartesian3_default.cross(right, velocity, upScratch); 7483 Cartesian3_default.normalize(up, up); 7484 Cartesian3_default.cross(velocity, up, right); 7485 Cartesian3_default.negate(right, right); 7486 Cartesian3_default.normalize(right, right); 7487 if (!defined_default(result)) { 7488 result = new Matrix3_default(); 7489 } 7490 result[0] = velocity.x; 7491 result[1] = velocity.y; 7492 result[2] = velocity.z; 7493 result[3] = right.x; 7494 result[4] = right.y; 7495 result[5] = right.z; 7496 result[6] = up.x; 7497 result[7] = up.y; 7498 result[8] = up.z; 7499 return result; 7500}; 7501Transforms.SWIZZLE_3D_TO_2D_MATRIX = Object.freeze( 7502 new Matrix4_default( 7503 0, 7504 0, 7505 1, 7506 0, 7507 1, 7508 0, 7509 0, 7510 0, 7511 0, 7512 1, 7513 0, 7514 0, 7515 0, 7516 0, 7517 0, 7518 1 7519 ) 7520); 7521var scratchCartographic = new Cartographic_default(); 7522var scratchCartesian3Projection = new Cartesian3_default(); 7523var scratchCenter = new Cartesian3_default(); 7524var scratchRotation = new Matrix3_default(); 7525var scratchFromENU = new Matrix4_default(); 7526var scratchToENU = new Matrix4_default(); 7527Transforms.basisTo2D = function(projection, matrix, result) { 7528 if (!defined_default(projection)) { 7529 throw new DeveloperError_default("projection is required."); 7530 } 7531 if (!defined_default(matrix)) { 7532 throw new DeveloperError_default("matrix is required."); 7533 } 7534 if (!defined_default(result)) { 7535 throw new DeveloperError_default("result is required."); 7536 } 7537 const rtcCenter = Matrix4_default.getTranslation(matrix, scratchCenter); 7538 const ellipsoid = projection.ellipsoid; 7539 let projectedPosition; 7540 if (Cartesian3_default.equals(rtcCenter, Cartesian3_default.ZERO)) { 7541 projectedPosition = Cartesian3_default.clone( 7542 Cartesian3_default.ZERO, 7543 scratchCartesian3Projection 7544 ); 7545 } else { 7546 const cartographic = ellipsoid.cartesianToCartographic( 7547 rtcCenter, 7548 scratchCartographic 7549 ); 7550 projectedPosition = projection.project( 7551 cartographic, 7552 scratchCartesian3Projection 7553 ); 7554 Cartesian3_default.fromElements( 7555 projectedPosition.z, 7556 projectedPosition.x, 7557 projectedPosition.y, 7558 projectedPosition 7559 ); 7560 } 7561 const fromENU = Transforms.eastNorthUpToFixedFrame( 7562 rtcCenter, 7563 ellipsoid, 7564 scratchFromENU 7565 ); 7566 const toENU = Matrix4_default.inverseTransformation(fromENU, scratchToENU); 7567 const rotation = Matrix4_default.getMatrix3(matrix, scratchRotation); 7568 const local = Matrix4_default.multiplyByMatrix3(toENU, rotation, result); 7569 Matrix4_default.multiply(Transforms.SWIZZLE_3D_TO_2D_MATRIX, local, result); 7570 Matrix4_default.setTranslation(result, projectedPosition, result); 7571 return result; 7572}; 7573Transforms.ellipsoidTo2DModelMatrix = function(projection, center, result) { 7574 if (!defined_default(projection)) { 7575 throw new DeveloperError_default("projection is required."); 7576 } 7577 if (!defined_default(center)) { 7578 throw new DeveloperError_default("center is required."); 7579 } 7580 if (!defined_default(result)) { 7581 throw new DeveloperError_default("result is required."); 7582 } 7583 const ellipsoid = projection.ellipsoid; 7584 const fromENU = Transforms.eastNorthUpToFixedFrame( 7585 center, 7586 ellipsoid, 7587 scratchFromENU 7588 ); 7589 const toENU = Matrix4_default.inverseTransformation(fromENU, scratchToENU); 7590 const cartographic = ellipsoid.cartesianToCartographic( 7591 center, 7592 scratchCartographic 7593 ); 7594 const projectedPosition = projection.project( 7595 cartographic, 7596 scratchCartesian3Projection 7597 ); 7598 Cartesian3_default.fromElements( 7599 projectedPosition.z, 7600 projectedPosition.x, 7601 projectedPosition.y, 7602 projectedPosition 7603 ); 7604 const translation = Matrix4_default.fromTranslation( 7605 projectedPosition, 7606 scratchFromENU 7607 ); 7608 Matrix4_default.multiply(Transforms.SWIZZLE_3D_TO_2D_MATRIX, toENU, result); 7609 Matrix4_default.multiply(translation, result, result); 7610 return result; 7611}; 7612var Transforms_default = Transforms; 7613 7614// packages/engine/Source/Core/Rectangle.js 7615var Rectangle = class _Rectangle { 7616 /** 7617 * @param {number} [west=0.0] The westernmost longitude, in radians, in the range [-Pi, Pi]. 7618 * @param {number} [south=0.0] The southernmost latitude, in radians, in the range [-Pi/2, Pi/2]. 7619 * @param {number} [east=0.0] The easternmost longitude, in radians, in the range [-Pi, Pi]. 7620 * @param {number} [north=0.0] The northernmost latitude, in radians, in the range [-Pi/2, Pi/2]. 7621 */ 7622 constructor(west, south, east, north) { 7623 this.west = west ?? 0; 7624 this.south = south ?? 0; 7625 this.east = east ?? 0; 7626 this.north = north ?? 0; 7627 } 7628 /** 7629 * Gets the width of the rectangle in radians. 7630 * @type {number} 7631 * @readonly 7632 */ 7633 get width() { 7634 return _Rectangle.computeWidth(this); 7635 } 7636 /** 7637 * Gets the height of the rectangle in radians. 7638 * @type {number} 7639 * @readonly 7640 */ 7641 get height() { 7642 return _Rectangle.computeHeight(this); 7643 } 7644 /** 7645 * Stores the provided instance into the provided array. 7646 * 7647 * @param {Rectangle} value The value to pack. 7648 * @param {number[]} array The array to pack into. 7649 * @param {number} [startingIndex=0] The index into the array at which to start packing the elements. 7650 * 7651 * @returns {number[]} The array that was packed into 7652 */ 7653 static pack(value, array, startingIndex) { 7654 Check_default.typeOf.object("value", value); 7655 Check_default.defined("array", array); 7656 startingIndex = startingIndex ?? 0; 7657 array[startingIndex++] = value.west; 7658 array[startingIndex++] = value.south; 7659 array[startingIndex++] = value.east; 7660 array[startingIndex] = value.north; 7661 return array; 7662 } 7663 /** 7664 * Retrieves an instance from a packed array. 7665 * 7666 * @param {number[]} array The packed array. 7667 * @param {number} [startingIndex=0] The starting index of the element to be unpacked. 7668 * @param {Rectangle} [result] The object into which to store the result. 7669 * @returns {Rectangle} The modified result parameter or a new Rectangle instance if one was not provided. 7670 */ 7671 static unpack(array, startingIndex, result) { 7672 Check_default.defined("array", array); 7673 startingIndex = startingIndex ?? 0; 7674 if (!defined_default(result)) { 7675 result = new _Rectangle(); 7676 } 7677 result.west = array[startingIndex++]; 7678 result.south = array[startingIndex++]; 7679 result.east = array[startingIndex++]; 7680 result.north = array[startingIndex]; 7681 return result; 7682 } 7683 /** 7684 * Computes the width of a rectangle in radians. 7685 * @param {Rectangle} rectangle The rectangle to compute the width of. 7686 * @returns {number} The width. 7687 */ 7688 static computeWidth(rectangle) { 7689 Check_default.typeOf.object("rectangle", rectangle); 7690 let east = rectangle.east; 7691 const west = rectangle.west; 7692 if (east < west) { 7693 east += Math_default.TWO_PI; 7694 } 7695 return east - west; 7696 } 7697 /** 7698 * Computes the height of a rectangle in radians. 7699 * @param {Rectangle} rectangle The rectangle to compute the height of. 7700 * @returns {number} The height. 7701 */ 7702 static computeHeight(rectangle) { 7703 Check_default.typeOf.object("rectangle", rectangle); 7704 return rectangle.north - rectangle.south; 7705 } 7706 /** 7707 * Creates a rectangle given the boundary longitude and latitude in degrees. 7708 * 7709 * @param {number} [west=0.0] The westernmost longitude in degrees in the range [-180.0, 180.0]. 7710 * @param {number} [south=0.0] The southernmost latitude in degrees in the range [-90.0, 90.0]. 7711 * @param {number} [east=0.0] The easternmost longitude in degrees in the range [-180.0, 180.0]. 7712 * @param {number} [north=0.0] The northernmost latitude in degrees in the range [-90.0, 90.0]. 7713 * @param {Rectangle} [result] The object onto which to store the result, or undefined if a new instance should be created. 7714 * @returns {Rectangle} The modified result parameter or a new Rectangle instance if none was provided. 7715 * 7716 * @example 7717 * const rectangle = Cesium.Rectangle.fromDegrees(0.0, 20.0, 10.0, 30.0); 7718 */ 7719 static fromDegrees(west, south, east, north, result) { 7720 west = Math_default.toRadians(west ?? 0); 7721 south = Math_default.toRadians(south ?? 0); 7722 east = Math_default.toRadians(east ?? 0); 7723 north = Math_default.toRadians(north ?? 0); 7724 if (!defined_default(result)) { 7725 return new _Rectangle(west, south, east, north); 7726 } 7727 result.west = west; 7728 result.south = south; 7729 result.east = east; 7730 result.north = north; 7731 return result; 7732 } 7733 /** 7734 * Creates a rectangle given the boundary longitude and latitude in radians. 7735 * 7736 * @param {number} [west=0.0] The westernmost longitude in radians in the range [-Math.PI, Math.PI]. 7737 * @param {number} [south=0.0] The southernmost latitude in radians in the range [-Math.PI/2, Math.PI/2]. 7738 * @param {number} [east=0.0] The easternmost longitude in radians in the range [-Math.PI, Math.PI]. 7739 * @param {number} [north=0.0] The northernmost latitude in radians in the range [-Math.PI/2, Math.PI/2]. 7740 * @param {Rectangle} [result] The object onto which to store the result, or undefined if a new instance should be created. 7741 * @returns {Rectangle} The modified result parameter or a new Rectangle instance if none was provided. 7742 * 7743 * @example 7744 * const rectangle = Cesium.Rectangle.fromRadians(0.0, Math.PI/4, Math.PI/8, 3*Math.PI/4); 7745 */ 7746 static fromRadians(west, south, east, north, result) { 7747 if (!defined_default(result)) { 7748 return new _Rectangle(west, south, east, north); 7749 } 7750 result.west = west ?? 0; 7751 result.south = south ?? 0; 7752 result.east = east ?? 0; 7753 result.north = north ?? 0; 7754 return result; 7755 } 7756 /** 7757 * Creates the smallest possible Rectangle that encloses all positions in the provided array. 7758 * 7759 * @param {Cartographic[]} cartographics The list of Cartographic instances. 7760 * @param {Rectangle} [result] The object onto which to store the result, or undefined if a new instance should be created. 7761 * @returns {Rectangle} The modified result parameter or a new Rectangle instance if none was provided. 7762 */ 7763 static fromCartographicArray(cartographics, result) { 7764 Check_default.defined("cartographics", cartographics); 7765 let west = Number.MAX_VALUE; 7766 let east = -Number.MAX_VALUE; 7767 let westOverIDL = Number.MAX_VALUE; 7768 let eastOverIDL = -Number.MAX_VALUE; 7769 let south = Number.MAX_VALUE; 7770 let north = -Number.MAX_VALUE; 7771 for (let i = 0, len = cartographics.length; i < len; i++) { 7772 const position = cartographics[i]; 7773 west = Math.min(west, position.longitude); 7774 east = Math.max(east, position.longitude); 7775 south = Math.min(south, position.latitude); 7776 north = Math.max(north, position.latitude); 7777 const lonAdjusted = position.longitude >= 0 ? position.longitude : position.longitude + Math_default.TWO_PI; 7778 westOverIDL = Math.min(westOverIDL, lonAdjusted); 7779 eastOverIDL = Math.max(eastOverIDL, lonAdjusted); 7780 } 7781 if (east - west > eastOverIDL - westOverIDL) { 7782 west = westOverIDL; 7783 east = eastOverIDL; 7784 if (east > Math_default.PI) { 7785 east = east - Math_default.TWO_PI; 7786 } 7787 if (west > Math_default.PI) { 7788 west = west - Math_default.TWO_PI; 7789 } 7790 } 7791 if (!defined_default(result)) { 7792 return new _Rectangle(west, south, east, north); 7793 } 7794 result.west = west; 7795 result.south = south; 7796 result.east = east; 7797 result.north = north; 7798 return result; 7799 } 7800 /** 7801 * Creates the smallest possible Rectangle that encloses all positions in the provided array. 7802 * 7803 * @param {Cartesian3[]} cartesians The list of Cartesian instances. 7804 * @param {Ellipsoid} [ellipsoid=Ellipsoid.default] The ellipsoid the cartesians are on. 7805 * @param {Rectangle} [result] The object onto which to store the result, or undefined if a new instance should be created. 7806 * @returns {Rectangle} The modified result parameter or a new Rectangle instance if none was provided. 7807 */ 7808 static fromCartesianArray(cartesians, ellipsoid, result) { 7809 Check_default.defined("cartesians", cartesians); 7810 ellipsoid = ellipsoid ?? Ellipsoid_default.default; 7811 let west = Number.MAX_VALUE; 7812 let east = -Number.MAX_VALUE; 7813 let westOverIDL = Number.MAX_VALUE; 7814 let eastOverIDL = -Number.MAX_VALUE; 7815 let south = Number.MAX_VALUE; 7816 let north = -Number.MAX_VALUE; 7817 for (let i = 0, len = cartesians.length; i < len; i++) { 7818 const position = ellipsoid.cartesianToCartographic(cartesians[i]); 7819 west = Math.min(west, position.longitude); 7820 east = Math.max(east, position.longitude); 7821 south = Math.min(south, position.latitude); 7822 north = Math.max(north, position.latitude); 7823 const lonAdjusted = position.longitude >= 0 ? position.longitude : position.longitude + Math_default.TWO_PI; 7824 westOverIDL = Math.min(westOverIDL, lonAdjusted); 7825 eastOverIDL = Math.max(eastOverIDL, lonAdjusted); 7826 } 7827 if (east - west > eastOverIDL - westOverIDL) { 7828 west = westOverIDL; 7829 east = eastOverIDL; 7830 if (east > Math_default.PI) { 7831 east = east - Math_default.TWO_PI; 7832 } 7833 if (west > Math_default.PI) { 7834 west = west - Math_default.TWO_PI; 7835 } 7836 } 7837 if (!defined_default(result)) { 7838 return new _Rectangle(west, south, east, north); 7839 } 7840 result.west = west; 7841 result.south = south; 7842 result.east = east; 7843 result.north = north; 7844 return result; 7845 } 7846 /** 7847 * Create a rectangle from a bounding sphere, ignoring height. 7848 * 7849 * 7850 * @param {BoundingSphere} boundingSphere The bounding sphere. 7851 * @param {Ellipsoid} [ellipsoid=Ellipsoid.default] The ellipsoid. 7852 * @param {Rectangle} [result] The object onto which to store the result, or undefined if a new instance should be created. 7853 * @returns {Rectangle} The modified result parameter or a new Rectangle instance if none was provided. 7854 */ 7855 static fromBoundingSphere(boundingSphere, ellipsoid, result) { 7856 Check_default.typeOf.object("boundingSphere", boundingSphere); 7857 const center = boundingSphere.center; 7858 const radius = boundingSphere.radius; 7859 if (!defined_default(ellipsoid)) { 7860 ellipsoid = Ellipsoid_default.default; 7861 } 7862 if (!defined_default(result)) { 7863 result = new _Rectangle(); 7864 } 7865 if (Cartesian3_default.equals(center, Cartesian3_default.ZERO)) { 7866 _Rectangle.clone(_Rectangle.MAX_VALUE, result); 7867 return result; 7868 } 7869 const fromENU = Transforms_default.eastNorthUpToFixedFrame( 7870 center, 7871 ellipsoid, 7872 fromBoundingSphereMatrixScratch 7873 ); 7874 const east = Matrix4_default.multiplyByPointAsVector( 7875 fromENU, 7876 Cartesian3_default.UNIT_X, 7877 fromBoundingSphereEastScratch 7878 ); 7879 Cartesian3_default.normalize(east, east); 7880 const north = Matrix4_default.multiplyByPointAsVector( 7881 fromENU, 7882 Cartesian3_default.UNIT_Y, 7883 fromBoundingSphereNorthScratch 7884 ); 7885 Cartesian3_default.normalize(north, north); 7886 Cartesian3_default.multiplyByScalar(north, radius, north); 7887 Cartesian3_default.multiplyByScalar(east, radius, east); 7888 const south = Cartesian3_default.negate(north, fromBoundingSphereSouthScratch); 7889 const west = Cartesian3_default.negate(east, fromBoundingSphereWestScratch); 7890 const positions = fromBoundingSpherePositionsScratch; 7891 let corner = positions[0]; 7892 Cartesian3_default.add(center, north, corner); 7893 corner = positions[1]; 7894 Cartesian3_default.add(center, west, corner); 7895 corner = positions[2]; 7896 Cartesian3_default.add(center, south, corner); 7897 corner = positions[3]; 7898 Cartesian3_default.add(center, east, corner); 7899 positions[4] = center; 7900 return _Rectangle.fromCartesianArray(positions, ellipsoid, result); 7901 } 7902 /** 7903 * Duplicates a Rectangle. 7904 * 7905 * @param {Rectangle} rectangle The rectangle to clone. 7906 * @param {Rectangle} [result] The object onto which to store the result, or undefined if a new instance should be created. 7907 * @returns {Rectangle} The modified result parameter or a new Rectangle instance if none was provided. (Returns undefined if rectangle is undefined) 7908 */ 7909 static clone(rectangle, result) { 7910 if (!defined_default(rectangle)) { 7911 return void 0; 7912 } 7913 if (!defined_default(result)) { 7914 return new _Rectangle( 7915 rectangle.west, 7916 rectangle.south, 7917 rectangle.east, 7918 rectangle.north 7919 ); 7920 } 7921 result.west = rectangle.west; 7922 result.south = rectangle.south; 7923 result.east = rectangle.east; 7924 result.north = rectangle.north; 7925 return result; 7926 } 7927 /** 7928 * Compares the provided Rectangles componentwise and returns 7929 * <code>true</code> if they pass an absolute or relative tolerance test, 7930 * <code>false</code> otherwise. 7931 * 7932 * @param {Rectangle} [left] The first Rectangle. 7933 * @param {Rectangle} [right] The second Rectangle. 7934 * @param {number} [absoluteEpsilon=0] The absolute epsilon tolerance to use for equality testing. 7935 * @returns {boolean} <code>true</code> if left and right are within the provided epsilon, <code>false</code> otherwise. 7936 */ 7937 static equalsEpsilon(left, right, absoluteEpsilon) { 7938 absoluteEpsilon = absoluteEpsilon ?? 0; 7939 return left === right || defined_default(left) && defined_default(right) && Math.abs(left.west - right.west) <= absoluteEpsilon && Math.abs(left.south - right.south) <= absoluteEpsilon && Math.abs(left.east - right.east) <= absoluteEpsilon && Math.abs(left.north - right.north) <= absoluteEpsilon; 7940 } 7941 /** 7942 * Duplicates this Rectangle. 7943 * 7944 * @param {Rectangle} [result] The object onto which to store the result. 7945 * @returns {Rectangle} The modified result parameter or a new Rectangle instance if none was provided. 7946 */ 7947 clone(result) { 7948 return _Rectangle.clone(this, result); 7949 } 7950 /** 7951 * Compares the provided Rectangle with this Rectangle componentwise and returns 7952 * <code>true</code> if they are equal, <code>false</code> otherwise. 7953 * 7954 * @param {Rectangle} [other] The Rectangle to compare. 7955 * @returns {boolean} <code>true</code> if the Rectangles are equal, <code>false</code> otherwise. 7956 */ 7957 equals(other) { 7958 return _Rectangle.equals(this, other); 7959 } 7960 /** 7961 * Compares the provided rectangles and returns <code>true</code> if they are equal, 7962 * <code>false</code> otherwise. 7963 * 7964 * @param {Rectangle} [left] The first Rectangle. 7965 * @param {Rectangle} [right] The second Rectangle. 7966 * @returns {boolean} <code>true</code> if left and right are equal; otherwise <code>false</code>. 7967 */ 7968 static equals(left, right) { 7969 return left === right || defined_default(left) && defined_default(right) && left.west === right.west && left.south === right.south && left.east === right.east && left.north === right.north; 7970 } 7971 /** 7972 * Compares the provided Rectangle with this Rectangle componentwise and returns 7973 * <code>true</code> if they are within the provided epsilon, 7974 * <code>false</code> otherwise. 7975 * 7976 * @param {Rectangle} [other] The Rectangle to compare. 7977 * @param {number} [epsilon=0] The epsilon to use for equality testing. 7978 * @returns {boolean} <code>true</code> if the Rectangles are within the provided epsilon, <code>false</code> otherwise. 7979 */ 7980 equalsEpsilon(other, epsilon) { 7981 return _Rectangle.equalsEpsilon(this, other, epsilon); 7982 } 7983 /** 7984 * Checks a Rectangle's properties and throws if they are not in valid ranges. 7985 * 7986 * @param {Rectangle} rectangle The rectangle to validate 7987 * 7988 * @exception {DeveloperError} <code>north</code> must be in the interval [<code>-Pi/2</code>, <code>Pi/2</code>]. 7989 * @exception {DeveloperError} <code>south</code> must be in the interval [<code>-Pi/2</code>, <code>Pi/2</code>]. 7990 * @exception {DeveloperError} <code>east</code> must be in the interval [<code>-Pi</code>, <code>Pi</code>]. 7991 * @exception {DeveloperError} <code>west</code> must be in the interval [<code>-Pi</code>, <code>Pi</code>]. 7992 * @private 7993 */ 7994 static _validate(rectangle) { 7995 Check_default.typeOf.object("rectangle", rectangle); 7996 const north = rectangle.north; 7997 Check_default.typeOf.number.greaterThanOrEquals( 7998 "north", 7999 north, 8000 -Math_default.PI_OVER_TWO 8001 ); 8002 Check_default.typeOf.number.lessThanOrEquals( 8003 "north", 8004 north, 8005 Math_default.PI_OVER_TWO 8006 ); 8007 const south = rectangle.south; 8008 Check_default.typeOf.number.greaterThanOrEquals( 8009 "south", 8010 south, 8011 -Math_default.PI_OVER_TWO 8012 ); 8013 Check_default.typeOf.number.lessThanOrEquals( 8014 "south", 8015 south, 8016 Math_default.PI_OVER_TWO 8017 ); 8018 const west = rectangle.west; 8019 Check_default.typeOf.number.greaterThanOrEquals("west", west, -Math.PI); 8020 Check_default.typeOf.number.lessThanOrEquals("west", west, Math.PI); 8021 const east = rectangle.east; 8022 Check_default.typeOf.number.greaterThanOrEquals("east", east, -Math.PI); 8023 Check_default.typeOf.number.lessThanOrEquals("east", east, Math.PI); 8024 } 8025 /** 8026 * Computes the southwest corner of a rectangle. 8027 * 8028 * @param {Rectangle} rectangle The rectangle for which to find the corner 8029 * @param {Cartographic} [result] The object onto which to store the result. 8030 * @returns {Cartographic} The modified result parameter or a new Cartographic instance if none was provided. 8031 */ 8032 static southwest(rectangle, result) { 8033 Check_default.typeOf.object("rectangle", rectangle); 8034 if (!defined_default(result)) { 8035 return new Cartographic_default(rectangle.west, rectangle.south); 8036 } 8037 result.longitude = rectangle.west; 8038 result.latitude = rectangle.south; 8039 result.height = 0; 8040 return result; 8041 } 8042 /** 8043 * Computes the northwest corner of a rectangle. 8044 * 8045 * @param {Rectangle} rectangle The rectangle for which to find the corner 8046 * @param {Cartographic} [result] The object onto which to store the result. 8047 * @returns {Cartographic} The modified result parameter or a new Cartographic instance if none was provided. 8048 */ 8049 static northwest(rectangle, result) { 8050 Check_default.typeOf.object("rectangle", rectangle); 8051 if (!defined_default(result)) { 8052 return new Cartographic_default(rectangle.west, rectangle.north); 8053 } 8054 result.longitude = rectangle.west; 8055 result.latitude = rectangle.north; 8056 result.height = 0; 8057 return result; 8058 } 8059 /** 8060 * Computes the northeast corner of a rectangle. 8061 * 8062 * @param {Rectangle} rectangle The rectangle for which to find the corner 8063 * @param {Cartographic} [result] The object onto which to store the result. 8064 * @returns {Cartographic} The modified result parameter or a new Cartographic instance if none was provided. 8065 */ 8066 static northeast(rectangle, result) { 8067 Check_default.typeOf.object("rectangle", rectangle); 8068 if (!defined_default(result)) { 8069 return new Cartographic_default(rectangle.east, rectangle.north); 8070 } 8071 result.longitude = rectangle.east; 8072 result.latitude = rectangle.north; 8073 result.height = 0; 8074 return result; 8075 } 8076 /** 8077 * Computes the southeast corner of a rectangle. 8078 * 8079 * @param {Rectangle} rectangle The rectangle for which to find the corner 8080 * @param {Cartographic} [result] The object onto which to store the result. 8081 * @returns {Cartographic} The modified result parameter or a new Cartographic instance if none was provided. 8082 */ 8083 static southeast(rectangle, result) { 8084 Check_default.typeOf.object("rectangle", rectangle); 8085 if (!defined_default(result)) { 8086 return new Cartographic_default(rectangle.east, rectangle.south); 8087 } 8088 result.longitude = rectangle.east; 8089 result.latitude = rectangle.south; 8090 result.height = 0; 8091 return result; 8092 } 8093 /** 8094 * Computes the center of a rectangle. 8095 * 8096 * @param {Rectangle} rectangle The rectangle for which to find the center 8097 * @param {Cartographic} [result] The object onto which to store the result. 8098 * @returns {Cartographic} The modified result parameter or a new Cartographic instance if none was provided. 8099 */ 8100 static center(rectangle, result) { 8101 Check_default.typeOf.object("rectangle", rectangle); 8102 let east = rectangle.east; 8103 const west = rectangle.west; 8104 if (east < west) { 8105 east += Math_default.TWO_PI; 8106 } 8107 const longitude = Math_default.negativePiToPi((west + east) * 0.5); 8108 const latitude = (rectangle.south + rectangle.north) * 0.5; 8109 if (!defined_default(result)) { 8110 return new Cartographic_default(longitude, latitude); 8111 } 8112 result.longitude = longitude; 8113 result.latitude = latitude; 8114 result.height = 0; 8115 return result; 8116 } 8117 /** 8118 * Computes the intersection of two rectangles. This function assumes that the rectangle's coordinates are 8119 * latitude and longitude in radians and produces a correct intersection, taking into account the fact that 8120 * the same angle can be represented with multiple values as well as the wrapping of longitude at the 8121 * anti-meridian. For a simple intersection that ignores these factors and can be used with projected 8122 * coordinates, see {@link Rectangle.simpleIntersection}. 8123 * 8124 * @param {Rectangle} rectangle On rectangle to find an intersection 8125 * @param {Rectangle} otherRectangle Another rectangle to find an intersection 8126 * @param {Rectangle} [result] The object onto which to store the result. 8127 * @returns {Rectangle|undefined} The modified result parameter, a new Rectangle instance if none was provided or undefined if there is no intersection. 8128 */ 8129 static intersection(rectangle, otherRectangle, result) { 8130 Check_default.typeOf.object("rectangle", rectangle); 8131 Check_default.typeOf.object("otherRectangle", otherRectangle); 8132 let rectangleEast = rectangle.east; 8133 let rectangleWest = rectangle.west; 8134 let otherRectangleEast = otherRectangle.east; 8135 let otherRectangleWest = otherRectangle.west; 8136 if (rectangleEast < rectangleWest && otherRectangleEast > 0) { 8137 rectangleEast += Math_default.TWO_PI; 8138 } else if (otherRectangleEast < otherRectangleWest && rectangleEast > 0) { 8139 otherRectangleEast += Math_default.TWO_PI; 8140 } 8141 if (rectangleEast < rectangleWest && otherRectangleWest < 0) { 8142 otherRectangleWest += Math_default.TWO_PI; 8143 } else if (otherRectangleEast < otherRectangleWest && rectangleWest < 0) { 8144 rectangleWest += Math_default.TWO_PI; 8145 } 8146 let west = Math_default.negativePiToPi( 8147 Math.max(rectangleWest, otherRectangleWest) 8148 ); 8149 const east = Math_default.negativePiToPi( 8150 Math.min(rectangleEast, otherRectangleEast) 8151 ); 8152 if (west === Math_default.PI && east < Math_default.PI) { 8153 west = -Math_default.PI; 8154 } 8155 if ((rectangle.west < rectangle.east || otherRectangle.west < otherRectangle.east) && east <= west) { 8156 return void 0; 8157 } 8158 const south = Math.max(rectangle.south, otherRectangle.south); 8159 const north = Math.min(rectangle.north, otherRectangle.north); 8160 if (south >= north) { 8161 return void 0; 8162 } 8163 if (!defined_default(result)) { 8164 return new _Rectangle(west, south, east, north); 8165 } 8166 result.west = west; 8167 result.south = south; 8168 result.east = east; 8169 result.north = north; 8170 return result; 8171 } 8172 /** 8173 * Computes a simple intersection of two rectangles. Unlike {@link Rectangle.intersection}, this function 8174 * does not attempt to put the angular coordinates into a consistent range or to account for crossing the 8175 * anti-meridian. As such, it can be used for rectangles where the coordinates are not simply latitude 8176 * and longitude (i.e. projected coordinates). 8177 * 8178 * @param {Rectangle} rectangle On rectangle to find an intersection 8179 * @param {Rectangle} otherRectangle Another rectangle to find an intersection 8180 * @param {Rectangle} [result] The object onto which to store the result. 8181 * @returns {Rectangle|undefined} The modified result parameter, a new Rectangle instance if none was provided or undefined if there is no intersection. 8182 */ 8183 static simpleIntersection(rectangle, otherRectangle, result) { 8184 Check_default.typeOf.object("rectangle", rectangle); 8185 Check_default.typeOf.object("otherRectangle", otherRectangle); 8186 const west = Math.max(rectangle.west, otherRectangle.west); 8187 const south = Math.max(rectangle.south, otherRectangle.south); 8188 const east = Math.min(rectangle.east, otherRectangle.east); 8189 const north = Math.min(rectangle.north, otherRectangle.north); 8190 if (south >= north || west >= east) { 8191 return void 0; 8192 } 8193 if (!defined_default(result)) { 8194 return new _Rectangle(west, south, east, north); 8195 } 8196 result.west = west; 8197 result.south = south; 8198 result.east = east; 8199 result.north = north; 8200 return result; 8201 } 8202 /** 8203 * Computes a rectangle that is the union of two rectangles. 8204 * 8205 * @param {Rectangle} rectangle A rectangle to enclose in rectangle. 8206 * @param {Rectangle} otherRectangle A rectangle to enclose in a rectangle. 8207 * @param {Rectangle} [result] The object onto which to store the result. 8208 * @returns {Rectangle} The modified result parameter or a new Rectangle instance if none was provided. 8209 */ 8210 static union(rectangle, otherRectangle, result) { 8211 Check_default.typeOf.object("rectangle", rectangle); 8212 Check_default.typeOf.object("otherRectangle", otherRectangle); 8213 if (!defined_default(result)) { 8214 result = new _Rectangle(); 8215 } 8216 let rectangleEast = rectangle.east; 8217 let rectangleWest = rectangle.west; 8218 let otherRectangleEast = otherRectangle.east; 8219 let otherRectangleWest = otherRectangle.west; 8220 if (rectangleEast < rectangleWest && otherRectangleEast > 0) { 8221 rectangleEast += Math_default.TWO_PI; 8222 } else if (otherRectangleEast < otherRectangleWest && rectangleEast > 0) { 8223 otherRectangleEast += Math_default.TWO_PI; 8224 } 8225 if (rectangleEast < rectangleWest && otherRectangleWest < 0) { 8226 otherRectangleWest += Math_default.TWO_PI; 8227 } else if (otherRectangleEast < otherRectangleWest && rectangleWest < 0) { 8228 rectangleWest += Math_default.TWO_PI; 8229 } 8230 const west = Math_default.negativePiToPi( 8231 Math.min(rectangleWest, otherRectangleWest) 8232 ); 8233 const east = Math_default.negativePiToPi( 8234 Math.max(rectangleEast, otherRectangleEast) 8235 ); 8236 result.west = west; 8237 result.south = Math.min(rectangle.south, otherRectangle.south); 8238 result.east = east; 8239 result.north = Math.max(rectangle.north, otherRectangle.north); 8240 return result; 8241 } 8242 /** 8243 * Computes a rectangle by enlarging the provided rectangle until it contains the provided cartographic. 8244 * 8245 * @param {Rectangle} rectangle A rectangle to expand. 8246 * @param {Cartographic} cartographic A cartographic to enclose in a rectangle. 8247 * @param {Rectangle} [result] The object onto which to store the result. 8248 * @returns {Rectangle} The modified result parameter or a new Rectangle instance if one was not provided. 8249 */ 8250 static expand(rectangle, cartographic, result) { 8251 Check_default.typeOf.object("rectangle", rectangle); 8252 Check_default.typeOf.object("cartographic", cartographic); 8253 if (!defined_default(result)) { 8254 result = new _Rectangle(); 8255 } 8256 result.west = Math.min(rectangle.west, cartographic.longitude); 8257 result.south = Math.min(rectangle.south, cartographic.latitude); 8258 result.east = Math.max(rectangle.east, cartographic.longitude); 8259 result.north = Math.max(rectangle.north, cartographic.latitude); 8260 return result; 8261 } 8262 /** 8263 * Returns true if the cartographic is on or inside the rectangle, false otherwise. 8264 * 8265 * @param {Rectangle} rectangle The rectangle 8266 * @param {Cartographic} cartographic The cartographic to test. 8267 * @returns {boolean} true if the provided cartographic is inside the rectangle, false otherwise. 8268 */ 8269 static contains(rectangle, cartographic) { 8270 Check_default.typeOf.object("rectangle", rectangle); 8271 Check_default.typeOf.object("cartographic", cartographic); 8272 let longitude = cartographic.longitude; 8273 const latitude = cartographic.latitude; 8274 const west = rectangle.west; 8275 let east = rectangle.east; 8276 if (east < west) { 8277 east += Math_default.TWO_PI; 8278 if (longitude < 0) { 8279 longitude += Math_default.TWO_PI; 8280 } 8281 } 8282 return (longitude > west || Math_default.equalsEpsilon(longitude, west, Math_default.EPSILON14)) && (longitude < east || Math_default.equalsEpsilon(longitude, east, Math_default.EPSILON14)) && latitude >= rectangle.south && latitude <= rectangle.north; 8283 } 8284 /** 8285 * Samples a rectangle so that it includes a list of Cartesian points suitable for passing to 8286 * {@link BoundingSphere#fromPoints}. Sampling is necessary to account 8287 * for rectangles that cover the poles or cross the equator. 8288 * 8289 * @param {Rectangle} rectangle The rectangle to subsample. 8290 * @param {Ellipsoid} [ellipsoid=Ellipsoid.default] The ellipsoid to use. 8291 * @param {number} [surfaceHeight=0.0] The height of the rectangle above the ellipsoid. 8292 * @param {Cartesian3[]} [result] The array of Cartesians onto which to store the result. 8293 * @returns {Cartesian3[]} The modified result parameter or a new Array of Cartesians instances if none was provided. 8294 */ 8295 static subsample(rectangle, ellipsoid, surfaceHeight, result) { 8296 Check_default.typeOf.object("rectangle", rectangle); 8297 ellipsoid = ellipsoid ?? Ellipsoid_default.default; 8298 surfaceHeight = surfaceHeight ?? 0; 8299 if (!defined_default(result)) { 8300 result = []; 8301 } 8302 let length = 0; 8303 const north = rectangle.north; 8304 const south = rectangle.south; 8305 const east = rectangle.east; 8306 const west = rectangle.west; 8307 const lla = subsampleLlaScratch; 8308 lla.height = surfaceHeight; 8309 lla.longitude = west; 8310 lla.latitude = north; 8311 result[length] = ellipsoid.cartographicToCartesian(lla, result[length]); 8312 length++; 8313 lla.longitude = east; 8314 result[length] = ellipsoid.cartographicToCartesian(lla, result[length]); 8315 length++; 8316 lla.latitude = south; 8317 result[length] = ellipsoid.cartographicToCartesian(lla, result[length]); 8318 length++; 8319 lla.longitude = west; 8320 result[length] = ellipsoid.cartographicToCartesian(lla, result[length]); 8321 length++; 8322 if (north < 0) { 8323 lla.latitude = north; 8324 } else if (south > 0) { 8325 lla.latitude = south; 8326 } else { 8327 lla.latitude = 0; 8328 } 8329 for (let i = 1; i < 8; ++i) { 8330 lla.longitude = -Math.PI + i * Math_default.PI_OVER_TWO; 8331 if (_Rectangle.contains(rectangle, lla)) { 8332 result[length] = ellipsoid.cartographicToCartesian(lla, result[length]); 8333 length++; 8334 } 8335 } 8336 if (lla.latitude === 0) { 8337 lla.longitude = west; 8338 result[length] = ellipsoid.cartographicToCartesian(lla, result[length]); 8339 length++; 8340 lla.longitude = east; 8341 result[length] = ellipsoid.cartographicToCartesian(lla, result[length]); 8342 length++; 8343 } 8344 result.length = length; 8345 return result; 8346 } 8347 /** 8348 * Computes a subsection of a rectangle from normalized coordinates in the range [0.0, 1.0]. 8349 * 8350 * @param {Rectangle} rectangle The rectangle to subsection. 8351 * @param {number} westLerp The west interpolation factor in the range [0.0, 1.0]. Must be less than or equal to eastLerp. 8352 * @param {number} southLerp The south interpolation factor in the range [0.0, 1.0]. Must be less than or equal to northLerp. 8353 * @param {number} eastLerp The east interpolation factor in the range [0.0, 1.0]. Must be greater than or equal to westLerp. 8354 * @param {number} northLerp The north interpolation factor in the range [0.0, 1.0]. Must be greater than or equal to southLerp. 8355 * @param {Rectangle} [result] The object onto which to store the result. 8356 * @returns {Rectangle} The modified result parameter or a new Rectangle instance if none was provided. 8357 */ 8358 static subsection(rectangle, westLerp, southLerp, eastLerp, northLerp, result) { 8359 Check_default.typeOf.object("rectangle", rectangle); 8360 Check_default.typeOf.number.greaterThanOrEquals("westLerp", westLerp, 0); 8361 Check_default.typeOf.number.lessThanOrEquals("westLerp", westLerp, 1); 8362 Check_default.typeOf.number.greaterThanOrEquals("southLerp", southLerp, 0); 8363 Check_default.typeOf.number.lessThanOrEquals("southLerp", southLerp, 1); 8364 Check_default.typeOf.number.greaterThanOrEquals("eastLerp", eastLerp, 0); 8365 Check_default.typeOf.number.lessThanOrEquals("eastLerp", eastLerp, 1); 8366 Check_default.typeOf.number.greaterThanOrEquals("northLerp", northLerp, 0); 8367 Check_default.typeOf.number.lessThanOrEquals("northLerp", northLerp, 1); 8368 Check_default.typeOf.number.lessThanOrEquals("westLerp", westLerp, eastLerp); 8369 Check_default.typeOf.number.lessThanOrEquals("southLerp", southLerp, northLerp); 8370 if (!defined_default(result)) { 8371 result = new _Rectangle(); 8372 } 8373 if (rectangle.west <= rectangle.east) { 8374 const width = rectangle.east - rectangle.west; 8375 result.west = rectangle.west + westLerp * width; 8376 result.east = rectangle.west + eastLerp * width; 8377 } else { 8378 const width = Math_default.TWO_PI + rectangle.east - rectangle.west; 8379 result.west = Math_default.negativePiToPi( 8380 rectangle.west + westLerp * width 8381 ); 8382 result.east = Math_default.negativePiToPi( 8383 rectangle.west + eastLerp * width 8384 ); 8385 } 8386 const height = rectangle.north - rectangle.south; 8387 result.south = rectangle.south + southLerp * height; 8388 result.north = rectangle.south + northLerp * height; 8389 if (westLerp === 1) { 8390 result.west = rectangle.east; 8391 } 8392 if (eastLerp === 1) { 8393 result.east = rectangle.east; 8394 } 8395 if (southLerp === 1) { 8396 result.south = rectangle.north; 8397 } 8398 if (northLerp === 1) { 8399 result.north = rectangle.north; 8400 } 8401 return result; 8402 } 8403}; 8404Rectangle.packedLength = 4; 8405var fromBoundingSphereMatrixScratch = new Matrix4_default(); 8406var fromBoundingSphereEastScratch = new Cartesian3_default(); 8407var fromBoundingSphereNorthScratch = new Cartesian3_default(); 8408var fromBoundingSphereWestScratch = new Cartesian3_default(); 8409var fromBoundingSphereSouthScratch = new Cartesian3_default(); 8410var fromBoundingSpherePositionsScratch = new Array(5); 8411for (let n = 0; n < fromBoundingSpherePositionsScratch.length; ++n) { 8412 fromBoundingSpherePositionsScratch[n] = new Cartesian3_default(); 8413} 8414var subsampleLlaScratch = new Cartographic_default(); 8415Rectangle.MAX_VALUE = Object.freeze( 8416 new Rectangle( 8417 -Math.PI, 8418 -Math_default.PI_OVER_TWO, 8419 Math.PI, 8420 Math_default.PI_OVER_TWO 8421 ) 8422); 8423var Rectangle_default = Rectangle; 8424 8425// packages/engine/Source/Core/Matrix2.js 8426var Matrix2 = class _Matrix2 { 8427 /** 8428 * @param {number} [column0Row0=0.0] The value for column 0, row 0. 8429 * @param {number} [column1Row0=0.0] The value for column 1, row 0. 8430 * @param {number} [column0Row1=0.0] The value for column 0, row 1. 8431 * @param {number} [column1Row1=0.0] The value for column 1, row 1. 8432 */ 8433 constructor(column0Row0, column1Row0, column0Row1, column1Row1) { 8434 this[0] = column0Row0 ?? 0; 8435 this[1] = column0Row1 ?? 0; 8436 this[2] = column1Row0 ?? 0; 8437 this[3] = column1Row1 ?? 0; 8438 } 8439 /** 8440 * Stores the provided instance into the provided array. 8441 * 8442 * @param {Matrix2} value The value to pack. 8443 * @param {number[]} array The array to pack into. 8444 * @param {number} [startingIndex=0] The index into the array at which to start packing the elements. 8445 * 8446 * @returns {number[]} The array that was packed into 8447 */ 8448 static pack(value, array, startingIndex) { 8449 Check_default.typeOf.object("value", value); 8450 Check_default.defined("array", array); 8451 startingIndex = startingIndex ?? 0; 8452 array[startingIndex++] = value[0]; 8453 array[startingIndex++] = value[1]; 8454 array[startingIndex++] = value[2]; 8455 array[startingIndex] = value[3]; 8456 return array; 8457 } 8458 /** 8459 * Retrieves an instance from a packed array. 8460 * 8461 * @param {number[]} array The packed array. 8462 * @param {number} [startingIndex=0] The starting index of the element to be unpacked. 8463 * @param {Matrix2} [result] The object into which to store the result. 8464 * @returns {Matrix2} The modified result parameter or a new Matrix2 instance if one was not provided. 8465 */ 8466 static unpack(array, startingIndex, result) { 8467 Check_default.defined("array", array); 8468 startingIndex = startingIndex ?? 0; 8469 if (!defined_default(result)) { 8470 result = new _Matrix2(); 8471 } 8472 result[0] = array[startingIndex++]; 8473 result[1] = array[startingIndex++]; 8474 result[2] = array[startingIndex++]; 8475 result[3] = array[startingIndex]; 8476 return result; 8477 } 8478 /** 8479 * Flattens an array of Matrix2s into an array of components. The components 8480 * are stored in column-major order. 8481 * 8482 * @param {Matrix2[]} array The array of matrices to pack. 8483 * @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. 8484 * @returns {number[]} The packed array. 8485 */ 8486 static packArray(array, result) { 8487 Check_default.defined("array", array); 8488 const length = array.length; 8489 const resultLength = length * 4; 8490 if (!defined_default(result)) { 8491 result = new Array(resultLength); 8492 } else if (!Array.isArray(result) && result.length !== resultLength) { 8493 throw new DeveloperError_default( 8494 "If result is a typed array, it must have exactly array.length * 4 elements" 8495 ); 8496 } else if (result.length !== resultLength) { 8497 result.length = resultLength; 8498 } 8499 for (let i = 0; i < length; ++i) { 8500 _Matrix2.pack(array[i], result, i * 4); 8501 } 8502 return result; 8503 } 8504 /** 8505 * Unpacks an array of column-major matrix components into an array of Matrix2s. 8506 * 8507 * @param {number[]} array The array of components to unpack. 8508 * @param {Matrix2[]} [result] The array onto which to store the result. 8509 * @returns {Matrix2[]} The unpacked array. 8510 */ 8511 static unpackArray(array, result) { 8512 Check_default.defined("array", array); 8513 Check_default.typeOf.number.greaterThanOrEquals("array.length", array.length, 4); 8514 if (array.length % 4 !== 0) { 8515 throw new DeveloperError_default("array length must be a multiple of 4."); 8516 } 8517 const length = array.length; 8518 if (!defined_default(result)) { 8519 result = new Array(length / 4); 8520 } else { 8521 result.length = length / 4; 8522 } 8523 for (let i = 0; i < length; i += 4) { 8524 const index = i / 4; 8525 result[index] = _Matrix2.unpack(array, i, result[index]); 8526 } 8527 return result; 8528 } 8529 /** 8530 * Duplicates a Matrix2 instance. 8531 * 8532 * @param {Matrix2} matrix The matrix to duplicate. 8533 * @param {Matrix2} [result] The object onto which to store the result. 8534 * @returns {Matrix2} The modified result parameter or a new Matrix2 instance if one was not provided. (Returns undefined if matrix is undefined) 8535 */ 8536 static clone(matrix, result) { 8537 if (!defined_default(matrix)) { 8538 return void 0; 8539 } 8540 if (!defined_default(result)) { 8541 return new _Matrix2(matrix[0], matrix[2], matrix[1], matrix[3]); 8542 } 8543 result[0] = matrix[0]; 8544 result[1] = matrix[1]; 8545 result[2] = matrix[2]; 8546 result[3] = matrix[3]; 8547 return result; 8548 } 8549 /** 8550 * Creates a Matrix2 instance from a column-major order array. 8551 * 8552 * @param {number[]} values The column-major order array. 8553 * @param {Matrix2} [result] The object in which the result will be stored, if undefined a new instance will be created. 8554 * @returns {Matrix2} The modified result parameter, or a new Matrix2 instance if one was not provided. 8555 */ 8556 static fromColumnMajorArray(values, result) { 8557 Check_default.defined("values", values); 8558 return _Matrix2.clone(values, result); 8559 } 8560 /** 8561 * Creates a Matrix2 instance from a row-major order array. 8562 * The resulting matrix will be in column-major order. 8563 * 8564 * @param {number[]} values The row-major order array. 8565 * @param {Matrix2} [result] The object in which the result will be stored, if undefined a new instance will be created. 8566 * @returns {Matrix2} The modified result parameter, or a new Matrix2 instance if one was not provided. 8567 */ 8568 static fromRowMajorArray(values, result) { 8569 Check_default.defined("values", values); 8570 if (!defined_default(result)) { 8571 return new _Matrix2(values[0], values[1], values[2], values[3]); 8572 } 8573 result[0] = values[0]; 8574 result[1] = values[2]; 8575 result[2] = values[1]; 8576 result[3] = values[3]; 8577 return result; 8578 } 8579 /** 8580 * Computes a Matrix2 instance representing a non-uniform scale. 8581 * 8582 * @param {Cartesian2} scale The x and y scale factors. 8583 * @param {Matrix2} [result] The object in which the result will be stored, if undefined a new instance will be created. 8584 * @returns {Matrix2} The modified result parameter, or a new Matrix2 instance if one was not provided. 8585 * 8586 * @example 8587 * // Creates 8588 * // [7.0, 0.0] 8589 * // [0.0, 8.0] 8590 * const m = Cesium.Matrix2.fromScale(new Cesium.Cartesian2(7.0, 8.0)); 8591 */ 8592 static fromScale(scale, result) { 8593 Check_default.typeOf.object("scale", scale); 8594 if (!defined_default(result)) { 8595 return new _Matrix2(scale.x, 0, 0, scale.y); 8596 } 8597 result[0] = scale.x; 8598 result[1] = 0; 8599 result[2] = 0; 8600 result[3] = scale.y; 8601 return result; 8602 } 8603 /** 8604 * Computes a Matrix2 instance representing a uniform scale. 8605 * 8606 * @param {number} scale The uniform scale factor. 8607 * @param {Matrix2} [result] The object in which the result will be stored, if undefined a new instance will be created. 8608 * @returns {Matrix2} The modified result parameter, or a new Matrix2 instance if one was not provided. 8609 * 8610 * @example 8611 * // Creates 8612 * // [2.0, 0.0] 8613 * // [0.0, 2.0] 8614 * const m = Cesium.Matrix2.fromUniformScale(2.0); 8615 */ 8616 static fromUniformScale(scale, result) { 8617 Check_default.typeOf.number("scale", scale); 8618 if (!defined_default(result)) { 8619 return new _Matrix2(scale, 0, 0, scale); 8620 } 8621 result[0] = scale; 8622 result[1] = 0; 8623 result[2] = 0; 8624 result[3] = scale; 8625 return result; 8626 } 8627 /** 8628 * Creates a rotation matrix. 8629 * 8630 * @param {number} angle The angle, in radians, of the rotation. Positive angles are counterclockwise. 8631 * @param {Matrix2} [result] The object in which the result will be stored, if undefined a new instance will be created. 8632 * @returns {Matrix2} The modified result parameter, or a new Matrix2 instance if one was not provided. 8633 * 8634 * @example 8635 * // Rotate a point 45 degrees counterclockwise. 8636 * const p = new Cesium.Cartesian2(5, 6); 8637 * const m = Cesium.Matrix2.fromRotation(Cesium.Math.toRadians(45.0)); 8638 * const rotated = Cesium.Matrix2.multiplyByVector(m, p, new Cesium.Cartesian2()); 8639 */ 8640 static fromRotation(angle, result) { 8641 Check_default.typeOf.number("angle", angle); 8642 const cosAngle = Math.cos(angle); 8643 const sinAngle = Math.sin(angle); 8644 if (!defined_default(result)) { 8645 return new _Matrix2(cosAngle, -sinAngle, sinAngle, cosAngle); 8646 } 8647 result[0] = cosAngle; 8648 result[1] = sinAngle; 8649 result[2] = -sinAngle; 8650 result[3] = cosAngle; 8651 return result; 8652 } 8653 /** 8654 * Creates an Array from the provided Matrix2 instance. 8655 * The array will be in column-major order. 8656 * 8657 * @param {Matrix2} matrix The matrix to use.. 8658 * @param {number[]} [result] The Array onto which to store the result. 8659 * @returns {number[]} The modified Array parameter or a new Array instance if one was not provided. 8660 */ 8661 static toArray(matrix, result) { 8662 Check_default.typeOf.object("matrix", matrix); 8663 if (!defined_default(result)) { 8664 return [matrix[0], matrix[1], matrix[2], matrix[3]]; 8665 } 8666 result[0] = matrix[0]; 8667 result[1] = matrix[1]; 8668 result[2] = matrix[2]; 8669 result[3] = matrix[3]; 8670 return result; 8671 } 8672 /** 8673 * Computes the array index of the element at the provided row and column. 8674 * 8675 * @param {number} row The zero-based index of the row. 8676 * @param {number} column The zero-based index of the column. 8677 * @returns {number} The index of the element at the provided row and column. 8678 * 8679 * @exception {DeveloperError} row must be 0 or 1. 8680 * @exception {DeveloperError} column must be 0 or 1. 8681 * 8682 * @example 8683 * const myMatrix = new Cesium.Matrix2(); 8684 * const column1Row0Index = Cesium.Matrix2.getElementIndex(1, 0); 8685 * const column1Row0 = myMatrix[column1Row0Index] 8686 * myMatrix[column1Row0Index] = 10.0; 8687 */ 8688 static getElementIndex(column, row) { 8689 Check_default.typeOf.number.greaterThanOrEquals("row", row, 0); 8690 Check_default.typeOf.number.lessThanOrEquals("row", row, 1); 8691 Check_default.typeOf.number.greaterThanOrEquals("column", column, 0); 8692 Check_default.typeOf.number.lessThanOrEquals("column", column, 1); 8693 return column * 2 + row; 8694 } 8695 /** 8696 * Retrieves a copy of the matrix column at the provided index as a Cartesian2 instance. 8697 * 8698 * @param {Matrix2} matrix The matrix to use. 8699 * @param {number} index The zero-based index of the column to retrieve. 8700 * @param {Cartesian2} result The object onto which to store the result. 8701 * @returns {Cartesian2} The modified result parameter. 8702 * 8703 * @exception {DeveloperError} index must be 0 or 1. 8704 */ 8705 static getColumn(matrix, index, result) { 8706 Check_default.typeOf.object("matrix", matrix); 8707 Check_default.typeOf.number.greaterThanOrEquals("index", index, 0); 8708 Check_default.typeOf.number.lessThanOrEquals("index", index, 1); 8709 Check_default.typeOf.object("result", result); 8710 const startIndex = index * 2; 8711 const x = matrix[startIndex]; 8712 const y = matrix[startIndex + 1]; 8713 result.x = x; 8714 result.y = y; 8715 return result; 8716 } 8717 /** 8718 * Computes a new matrix that replaces the specified column in the provided matrix with the provided Cartesian2 instance. 8719 * 8720 * @param {Matrix2} matrix The matrix to use. 8721 * @param {number} index The zero-based index of the column to set. 8722 * @param {Cartesian2} cartesian The Cartesian whose values will be assigned to the specified column. 8723 * @param {Matrix2} result The object onto which to store the result. 8724 * @returns {Matrix2} The modified result parameter. 8725 * 8726 * @exception {DeveloperError} index must be 0 or 1. 8727 */ 8728 static setColumn(matrix, index, cartesian, result) { 8729 Check_default.typeOf.object("matrix", matrix); 8730 Check_default.typeOf.number.greaterThanOrEquals("index", index, 0); 8731 Check_default.typeOf.number.lessThanOrEquals("index", index, 1); 8732 Check_default.typeOf.object("cartesian", cartesian); 8733 Check_default.typeOf.object("result", result); 8734 result = _Matrix2.clone(matrix, result); 8735 const startIndex = index * 2; 8736 result[startIndex] = cartesian.x; 8737 result[startIndex + 1] = cartesian.y; 8738 return result; 8739 } 8740 /** 8741 * Retrieves a copy of the matrix row at the provided index as a Cartesian2 instance. 8742 * 8743 * @param {Matrix2} matrix The matrix to use. 8744 * @param {number} index The zero-based index of the row to retrieve. 8745 * @param {Cartesian2} result The object onto which to store the result. 8746 * @returns {Cartesian2} The modified result parameter. 8747 * 8748 * @exception {DeveloperError} index must be 0 or 1. 8749 */ 8750 static getRow(matrix, index, result) { 8751 Check_default.typeOf.object("matrix", matrix); 8752 Check_default.typeOf.number.greaterThanOrEquals("index", index, 0); 8753 Check_default.typeOf.number.lessThanOrEquals("index", index, 1); 8754 Check_default.typeOf.object("result", result); 8755 const x = matrix[index]; 8756 const y = matrix[index + 2]; 8757 result.x = x; 8758 result.y = y; 8759 return result; 8760 } 8761 /** 8762 * Computes a new matrix that replaces the specified row in the provided matrix with the provided Cartesian2 instance. 8763 * 8764 * @param {Matrix2} matrix The matrix to use. 8765 * @param {number} index The zero-based index of the row to set. 8766 * @param {Cartesian2} cartesian The Cartesian whose values will be assigned to the specified row. 8767 * @param {Matrix2} result The object onto which to store the result. 8768 * @returns {Matrix2} The modified result parameter. 8769 * 8770 * @exception {DeveloperError} index must be 0 or 1. 8771 */ 8772 static setRow(matrix, index, cartesian, result) { 8773 Check_default.typeOf.object("matrix", matrix); 8774 Check_default.typeOf.number.greaterThanOrEquals("index", index, 0); 8775 Check_default.typeOf.number.lessThanOrEquals("index", index, 1); 8776 Check_default.typeOf.object("cartesian", cartesian); 8777 Check_default.typeOf.object("result", result); 8778 result = _Matrix2.clone(matrix, result); 8779 result[index] = cartesian.x; 8780 result[index + 2] = cartesian.y; 8781 return result; 8782 } 8783 /** 8784 * Computes a new matrix that replaces the scale with the provided scale. 8785 * This assumes the matrix is an affine transformation. 8786 * 8787 * @param {Matrix2} matrix The matrix to use. 8788 * @param {Cartesian2} scale The scale that replaces the scale of the provided matrix. 8789 * @param {Matrix2} result The object onto which to store the result. 8790 * @returns {Matrix2} The modified result parameter. 8791 * 8792 * @see Matrix2.setUniformScale 8793 * @see Matrix2.fromScale 8794 * @see Matrix2.fromUniformScale 8795 * @see Matrix2.multiplyByScale 8796 * @see Matrix2.multiplyByUniformScale 8797 * @see Matrix2.getScale 8798 */ 8799 static setScale(matrix, scale, result) { 8800 Check_default.typeOf.object("matrix", matrix); 8801 Check_default.typeOf.object("scale", scale); 8802 Check_default.typeOf.object("result", result); 8803 const existingScale = _Matrix2.getScale(matrix, scaleScratch1); 8804 const scaleRatioX = scale.x / existingScale.x; 8805 const scaleRatioY = scale.y / existingScale.y; 8806 result[0] = matrix[0] * scaleRatioX; 8807 result[1] = matrix[1] * scaleRatioX; 8808 result[2] = matrix[2] * scaleRatioY; 8809 result[3] = matrix[3] * scaleRatioY; 8810 return result; 8811 } 8812 /** 8813 * Computes a new matrix that replaces the scale with the provided uniform scale. 8814 * This assumes the matrix is an affine transformation. 8815 * 8816 * @param {Matrix2} matrix The matrix to use. 8817 * @param {number} scale The uniform scale that replaces the scale of the provided matrix. 8818 * @param {Matrix2} result The object onto which to store the result. 8819 * @returns {Matrix2} The modified result parameter. 8820 * 8821 * @see Matrix2.setScale 8822 * @see Matrix2.fromScale 8823 * @see Matrix2.fromUniformScale 8824 * @see Matrix2.multiplyByScale 8825 * @see Matrix2.multiplyByUniformScale 8826 * @see Matrix2.getScale 8827 */ 8828 static setUniformScale(matrix, scale, result) { 8829 Check_default.typeOf.object("matrix", matrix); 8830 Check_default.typeOf.number("scale", scale); 8831 Check_default.typeOf.object("result", result); 8832 const existingScale = _Matrix2.getScale(matrix, scaleScratch2); 8833 const scaleRatioX = scale / existingScale.x; 8834 const scaleRatioY = scale / existingScale.y; 8835 result[0] = matrix[0] * scaleRatioX; 8836 result[1] = matrix[1] * scaleRatioX; 8837 result[2] = matrix[2] * scaleRatioY; 8838 result[3] = matrix[3] * scaleRatioY; 8839 return result; 8840 } 8841 /** 8842 * Extracts the non-uniform scale assuming the matrix is an affine transformation. 8843 * 8844 * @param {Matrix2} matrix The matrix. 8845 * @param {Cartesian2} result The object onto which to store the result. 8846 * @returns {Cartesian2} The modified result parameter. 8847 * 8848 * @see Matrix2.multiplyByScale 8849 * @see Matrix2.multiplyByUniformScale 8850 * @see Matrix2.fromScale 8851 * @see Matrix2.fromUniformScale 8852 * @see Matrix2.setScale 8853 * @see Matrix2.setUniformScale 8854 */ 8855 static getScale(matrix, result) { 8856 Check_default.typeOf.object("matrix", matrix); 8857 Check_default.typeOf.object("result", result); 8858 result.x = Cartesian2_default.magnitude( 8859 Cartesian2_default.fromElements(matrix[0], matrix[1], scratchColumn) 8860 ); 8861 result.y = Cartesian2_default.magnitude( 8862 Cartesian2_default.fromElements(matrix[2], matrix[3], scratchColumn) 8863 ); 8864 return result; 8865 } 8866 /** 8867 * Computes the maximum scale assuming the matrix is an affine transformation. 8868 * The maximum scale is the maximum length of the column vectors. 8869 * 8870 * @param {Matrix2} matrix The matrix. 8871 * @returns {number} The maximum scale. 8872 */ 8873 static getMaximumScale(matrix) { 8874 _Matrix2.getScale(matrix, scaleScratch3); 8875 return Cartesian2_default.maximumComponent(scaleScratch3); 8876 } 8877 /** 8878 * Sets the rotation assuming the matrix is an affine transformation. 8879 * 8880 * @param {Matrix2} matrix The matrix. 8881 * @param {Matrix2} rotation The rotation matrix. 8882 * @param {Matrix2} result The object onto which to store the result. 8883 * @returns {Matrix2} The modified result parameter. 8884 * 8885 * @see Matrix2.fromRotation 8886 * @see Matrix2.getRotation 8887 */ 8888 static setRotation(matrix, rotation, result) { 8889 Check_default.typeOf.object("matrix", matrix); 8890 Check_default.typeOf.object("result", result); 8891 const scale = _Matrix2.getScale(matrix, scaleScratch4); 8892 result[0] = rotation[0] * scale.x; 8893 result[1] = rotation[1] * scale.x; 8894 result[2] = rotation[2] * scale.y; 8895 result[3] = rotation[3] * scale.y; 8896 return result; 8897 } 8898 /** 8899 * Extracts the rotation matrix assuming the matrix is an affine transformation. 8900 * 8901 * @param {Matrix2} matrix The matrix. 8902 * @param {Matrix2} result The object onto which to store the result. 8903 * @returns {Matrix2} The modified result parameter. 8904 * 8905 * @see Matrix2.setRotation 8906 * @see Matrix2.fromRotation 8907 */ 8908 static getRotation(matrix, result) { 8909 Check_default.typeOf.object("matrix", matrix); 8910 Check_default.typeOf.object("result", result); 8911 const scale = _Matrix2.getScale(matrix, scaleScratch5); 8912 result[0] = matrix[0] / scale.x; 8913 result[1] = matrix[1] / scale.x; 8914 result[2] = matrix[2] / scale.y; 8915 result[3] = matrix[3] / scale.y; 8916 return result; 8917 } 8918 /** 8919 * Computes the product of two matrices. 8920 * 8921 * @param {Matrix2} left The first matrix. 8922 * @param {Matrix2} right The second matrix. 8923 * @param {Matrix2} result The object onto which to store the result. 8924 * @returns {Matrix2} The modified result parameter. 8925 */ 8926 static multiply(left, right, result) { 8927 Check_default.typeOf.object("left", left); 8928 Check_default.typeOf.object("right", right); 8929 Check_default.typeOf.object("result", result); 8930 const column0Row0 = left[0] * right[0] + left[2] * right[1]; 8931 const column1Row0 = left[0] * right[2] + left[2] * right[3]; 8932 const column0Row1 = left[1] * right[0] + left[3] * right[1]; 8933 const column1Row1 = left[1] * right[2] + left[3] * right[3]; 8934 result[0] = column0Row0; 8935 result[1] = column0Row1; 8936 result[2] = column1Row0; 8937 result[3] = column1Row1; 8938 return result; 8939 } 8940 /** 8941 * Computes the sum of two matrices. 8942 * 8943 * @param {Matrix2} left The first matrix. 8944 * @param {Matrix2} right The second matrix. 8945 * @param {Matrix2} result The object onto which to store the result. 8946 * @returns {Matrix2} The modified result parameter. 8947 */ 8948 static add(left, right, result) { 8949 Check_default.typeOf.object("left", left); 8950 Check_default.typeOf.object("right", right); 8951 Check_default.typeOf.object("result", result); 8952 result[0] = left[0] + right[0]; 8953 result[1] = left[1] + right[1]; 8954 result[2] = left[2] + right[2]; 8955 result[3] = left[3] + right[3]; 8956 return result; 8957 } 8958 /** 8959 * Computes the difference of two matrices. 8960 * 8961 * @param {Matrix2} left The first matrix. 8962 * @param {Matrix2} right The second matrix. 8963 * @param {Matrix2} result The object onto which to store the result. 8964 * @returns {Matrix2} The modified result parameter. 8965 */ 8966 static subtract(left, right, result) { 8967 Check_default.typeOf.object("left", left); 8968 Check_default.typeOf.object("right", right); 8969 Check_default.typeOf.object("result", result); 8970 result[0] = left[0] - right[0]; 8971 result[1] = left[1] - right[1]; 8972 result[2] = left[2] - right[2]; 8973 result[3] = left[3] - right[3]; 8974 return result; 8975 } 8976 /** 8977 * Computes the product of a matrix and a column vector. 8978 * 8979 * @param {Matrix2} matrix The matrix. 8980 * @param {Cartesian2} cartesian The column. 8981 * @param {Cartesian2} result The object onto which to store the result. 8982 * @returns {Cartesian2} The modified result parameter. 8983 */ 8984 static multiplyByVector(matrix, cartesian, result) { 8985 Check_default.typeOf.object("matrix", matrix); 8986 Check_default.typeOf.object("cartesian", cartesian); 8987 Check_default.typeOf.object("result", result); 8988 const x = matrix[0] * cartesian.x + matrix[2] * cartesian.y; 8989 const y = matrix[1] * cartesian.x + matrix[3] * cartesian.y; 8990 result.x = x; 8991 result.y = y; 8992 return result; 8993 } 8994 /** 8995 * Computes the product of a matrix and a scalar. 8996 * 8997 * @param {Matrix2} matrix The matrix. 8998 * @param {number} scalar The number to multiply by. 8999 * @param {Matrix2} result The object onto which to store the result. 9000 * @returns {Matrix2} The modified result parameter. 9001 */ 9002 static multiplyByScalar(matrix, scalar, result) { 9003 Check_default.typeOf.object("matrix", matrix); 9004 Check_default.typeOf.number("scalar", scalar); 9005 Check_default.typeOf.object("result", result); 9006 result[0] = matrix[0] * scalar; 9007 result[1] = matrix[1] * scalar; 9008 result[2] = matrix[2] * scalar; 9009 result[3] = matrix[3] * scalar; 9010 return result; 9011 } 9012 /** 9013 * Computes the product of a matrix times a (non-uniform) scale, as if the scale were a scale matrix. 9014 * 9015 * @param {Matrix2} matrix The matrix on the left-hand side. 9016 * @param {Cartesian2} scale The non-uniform scale on the right-hand side. 9017 * @param {Matrix2} result The object onto which to store the result. 9018 * @returns {Matrix2} The modified result parameter. 9019 * 9020 * 9021 * @example 9022 * // Instead of Cesium.Matrix2.multiply(m, Cesium.Matrix2.fromScale(scale), m); 9023 * Cesium.Matrix2.multiplyByScale(m, scale, m); 9024 * 9025 * @see Matrix2.multiplyByUniformScale 9026 * @see Matrix2.fromScale 9027 * @see Matrix2.fromUniformScale 9028 * @see Matrix2.setScale 9029 * @see Matrix2.setUniformScale 9030 * @see Matrix2.getScale 9031 */ 9032 static multiplyByScale(matrix, scale, result) { 9033 Check_default.typeOf.object("matrix", matrix); 9034 Check_default.typeOf.object("scale", scale); 9035 Check_default.typeOf.object("result", result); 9036 result[0] = matrix[0] * scale.x; 9037 result[1] = matrix[1] * scale.x; 9038 result[2] = matrix[2] * scale.y; 9039 result[3] = matrix[3] * scale.y; 9040 return result; 9041 } 9042 /** 9043 * Computes the product of a matrix times a uniform scale, as if the scale were a scale matrix. 9044 * 9045 * @param {Matrix2} matrix The matrix on the left-hand side. 9046 * @param {number} scale The uniform scale on the right-hand side. 9047 * @param {Matrix2} result The object onto which to store the result. 9048 * @returns {Matrix2} The modified result parameter. 9049 * 9050 * @example 9051 * // Instead of Cesium.Matrix2.multiply(m, Cesium.Matrix2.fromUniformScale(scale), m); 9052 * Cesium.Matrix2.multiplyByUniformScale(m, scale, m); 9053 * 9054 * @see Matrix2.multiplyByScale 9055 * @see Matrix2.fromScale 9056 * @see Matrix2.fromUniformScale 9057 * @see Matrix2.setScale 9058 * @see Matrix2.setUniformScale 9059 * @see Matrix2.getScale 9060 */ 9061 static multiplyByUniformScale(matrix, scale, result) { 9062 Check_default.typeOf.object("matrix", matrix); 9063 Check_default.typeOf.number("scale", scale); 9064 Check_default.typeOf.object("result", result); 9065 result[0] = matrix[0] * scale; 9066 result[1] = matrix[1] * scale; 9067 result[2] = matrix[2] * scale; 9068 result[3] = matrix[3] * scale; 9069 return result; 9070 } 9071 /** 9072 * Creates a negated copy of the provided matrix. 9073 * 9074 * @param {Matrix2} matrix The matrix to negate. 9075 * @param {Matrix2} result The object onto which to store the result. 9076 * @returns {Matrix2} The modified result parameter. 9077 */ 9078 static negate(matrix, result) { 9079 Check_default.typeOf.object("matrix", matrix); 9080 Check_default.typeOf.object("result", result); 9081 result[0] = -matrix[0]; 9082 result[1] = -matrix[1]; 9083 result[2] = -matrix[2]; 9084 result[3] = -matrix[3]; 9085 return result; 9086 } 9087 /** 9088 * Computes the transpose of the provided matrix. 9089 * 9090 * @param {Matrix2} matrix The matrix to transpose. 9091 * @param {Matrix2} result The object onto which to store the result. 9092 * @returns {Matrix2} The modified result parameter. 9093 */ 9094 static transpose(matrix, result) { 9095 Check_default.typeOf.object("matrix", matrix); 9096 Check_default.typeOf.object("result", result); 9097 const column0Row0 = matrix[0]; 9098 const column0Row1 = matrix[2]; 9099 const column1Row0 = matrix[1]; 9100 const column1Row1 = matrix[3]; 9101 result[0] = column0Row0; 9102 result[1] = column0Row1; 9103 result[2] = column1Row0; 9104 result[3] = column1Row1; 9105 return result; 9106 } 9107 /** 9108 * Computes a matrix, which contains the absolute (unsigned) values of the provided matrix's elements. 9109 * 9110 * @param {Matrix2} matrix The matrix with signed elements. 9111 * @param {Matrix2} result The object onto which to store the result. 9112 * @returns {Matrix2} The modified result parameter. 9113 */ 9114 static abs(matrix, result) { 9115 Check_default.typeOf.object("matrix", matrix); 9116 Check_default.typeOf.object("result", result); 9117 result[0] = Math.abs(matrix[0]); 9118 result[1] = Math.abs(matrix[1]); 9119 result[2] = Math.abs(matrix[2]); 9120 result[3] = Math.abs(matrix[3]); 9121 return result; 9122 } 9123 /** 9124 * Compares the provided matrices componentwise and returns 9125 * <code>true</code> if they are equal, <code>false</code> otherwise. 9126 * 9127 * @param {Matrix2} [left] The first matrix. 9128 * @param {Matrix2} [right] The second matrix. 9129 * @returns {boolean} <code>true</code> if left and right are equal, <code>false</code> otherwise. 9130 */ 9131 static equals(left, right) { 9132 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]; 9133 } 9134 /** 9135 * Compares provided matrix and array, starting from a given array offset. 9136 * 9137 * @param {Matrix2} matrix 9138 * @param {number[]} array 9139 * @param {number} offset 9140 * @ignore 9141 */ 9142 static equalsArray(matrix, array, offset) { 9143 return matrix[0] === array[offset] && matrix[1] === array[offset + 1] && matrix[2] === array[offset + 2] && matrix[3] === array[offset + 3]; 9144 } 9145 /** 9146 * Compares the provided matrices componentwise and returns 9147 * <code>true</code> if they are within the provided epsilon, 9148 * <code>false</code> otherwise. 9149 * 9150 * @param {Matrix2} [left] The first matrix. 9151 * @param {Matrix2} [right] The second matrix. 9152 * @param {number} [epsilon=0] The epsilon to use for equality testing. 9153 * @returns {boolean} <code>true</code> if left and right are within the provided epsilon, <code>false</code> otherwise. 9154 */ 9155 static equalsEpsilon(left, right, epsilon) { 9156 epsilon = epsilon ?? 0; 9157 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; 9158 } 9159 /** 9160 * Gets the number of items in the collection. 9161 * 9162 * @type {number} 9163 */ 9164 get length() { 9165 return _Matrix2.packedLength; 9166 } 9167 /** 9168 * Duplicates the provided Matrix2 instance. 9169 * 9170 * @param {Matrix2} [result] The object onto which to store the result. 9171 * @returns {Matrix2} The modified result parameter or a new Matrix2 instance if one was not provided. 9172 */ 9173 clone(result) { 9174 return _Matrix2.clone(this, result); 9175 } 9176 /** 9177 * Compares this matrix to the provided matrix componentwise and returns 9178 * <code>true</code> if they are equal, <code>false</code> otherwise. 9179 * 9180 * @param {Matrix2} [right] The right hand side matrix. 9181 * @returns {boolean} <code>true</code> if they are equal, <code>false</code> otherwise. 9182 */ 9183 equals(right) { 9184 return _Matrix2.equals(this, right); 9185 } 9186 /** 9187 * Compares this matrix to the provided matrix componentwise and returns 9188 * <code>true</code> if they are within the provided epsilon, 9189 * <code>false</code> otherwise. 9190 * 9191 * @param {Matrix2} [right] The right hand side matrix. 9192 * @param {number} [epsilon=0] The epsilon to use for equality testing. 9193 * @returns {boolean} <code>true</code> if they are within the provided epsilon, <code>false</code> otherwise. 9194 */ 9195 equalsEpsilon(right, epsilon) { 9196 return _Matrix2.equalsEpsilon(this, right, epsilon); 9197 } 9198 /** 9199 * Creates a string representing this Matrix with each row being 9200 * on a separate line and in the format '(column0, column1)'. 9201 * 9202 * @returns {string} A string representing the provided Matrix with each row being on a separate line and in the format '(column0, column1)'. 9203 */ 9204 toString() { 9205 return `(${this[0]}, ${this[2]}) 9206(${this[1]}, ${this[3]})`; 9207 } 9208}; 9209Matrix2.packedLength = 4; 9210Matrix2.fromArray = Matrix2.unpack; 9211Matrix2.IDENTITY = Object.freeze(new Matrix2(1, 0, 0, 1)); 9212Matrix2.ZERO = Object.freeze(new Matrix2(0, 0, 0, 0)); 9213Matrix2.COLUMN0ROW0 = 0; 9214Matrix2.COLUMN0ROW1 = 1; 9215Matrix2.COLUMN1ROW0 = 2; 9216Matrix2.COLUMN1ROW1 = 3; 9217var scaleScratch1 = new Cartesian2_default(); 9218var scaleScratch2 = new Cartesian2_default(); 9219var scratchColumn = new Cartesian2_default(); 9220var scaleScratch3 = new Cartesian2_default(); 9221var scaleScratch4 = new Cartesian2_default(); 9222var scaleScratch5 = new Cartesian2_default(); 9223var Matrix2_default = Matrix2; 9224 9225export { 9226 binarySearch_default, 9227 require_URI, 9228 combine_default, 9229 isCrossOriginUrl_default, 9230 Event_default, 9231 Resource_default, 9232 buildModuleUrl_default, 9233 Quaternion_default, 9234 Transforms_default, 9235 Rectangle_default, 9236 Matrix2_default 9237};
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.