/**
* @license
* Cesium - https://github.com/CesiumGS/cesium
* Version 1.96
*
* Copyright 2011-2022 Cesium Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Columbus View (Pat. Pend.)
*
* Portions licensed separately.
* See https://github.com/CesiumGS/cesium/blob/main/LICENSE.md for full licensing details.
*/
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __commonJS = (cb, mod2) => function __require() {
return mod2 || (0, cb[__getOwnPropNames(cb)[0]])((mod2 = { exports: {} }).exports, mod2), mod2.exports;
};
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod2, isNodeMode, target) => (target = mod2 != null ? __create(__getProtoOf(mod2)) : {}, __copyProps(
isNodeMode || !mod2 || !mod2.__esModule ? __defProp(target, "default", { value: mod2, enumerable: true }) : target,
mod2
));
var __toCommonJS = (mod2) => __copyProps(__defProp({}, "__esModule", { value: true }), mod2);
// node_modules/mersenne-twister/src/mersenne-twister.js
var require_mersenne_twister = __commonJS({
"node_modules/mersenne-twister/src/mersenne-twister.js"(exports2, module2) {
var MersenneTwister = function(seed) {
if (seed == void 0) {
seed = new Date().getTime();
}
this.N = 624;
this.M = 397;
this.MATRIX_A = 2567483615;
this.UPPER_MASK = 2147483648;
this.LOWER_MASK = 2147483647;
this.mt = new Array(this.N);
this.mti = this.N + 1;
if (seed.constructor == Array) {
this.init_by_array(seed, seed.length);
} else {
this.init_seed(seed);
}
};
MersenneTwister.prototype.init_seed = function(s) {
this.mt[0] = s >>> 0;
for (this.mti = 1; this.mti < this.N; this.mti++) {
var s = this.mt[this.mti - 1] ^ this.mt[this.mti - 1] >>> 30;
this.mt[this.mti] = (((s & 4294901760) >>> 16) * 1812433253 << 16) + (s & 65535) * 1812433253 + this.mti;
this.mt[this.mti] >>>= 0;
}
};
MersenneTwister.prototype.init_by_array = function(init_key, key_length) {
var i, j, k;
this.init_seed(19650218);
i = 1;
j = 0;
k = this.N > key_length ? this.N : key_length;
for (; k; k--) {
var s = this.mt[i - 1] ^ this.mt[i - 1] >>> 30;
this.mt[i] = (this.mt[i] ^ (((s & 4294901760) >>> 16) * 1664525 << 16) + (s & 65535) * 1664525) + init_key[j] + j;
this.mt[i] >>>= 0;
i++;
j++;
if (i >= this.N) {
this.mt[0] = this.mt[this.N - 1];
i = 1;
}
if (j >= key_length)
j = 0;
}
for (k = this.N - 1; k; k--) {
var s = this.mt[i - 1] ^ this.mt[i - 1] >>> 30;
this.mt[i] = (this.mt[i] ^ (((s & 4294901760) >>> 16) * 1566083941 << 16) + (s & 65535) * 1566083941) - i;
this.mt[i] >>>= 0;
i++;
if (i >= this.N) {
this.mt[0] = this.mt[this.N - 1];
i = 1;
}
}
this.mt[0] = 2147483648;
};
MersenneTwister.prototype.random_int = function() {
var y;
var mag01 = new Array(0, this.MATRIX_A);
if (this.mti >= this.N) {
var kk;
if (this.mti == this.N + 1)
this.init_seed(5489);
for (kk = 0; kk < this.N - this.M; kk++) {
y = this.mt[kk] & this.UPPER_MASK | this.mt[kk + 1] & this.LOWER_MASK;
this.mt[kk] = this.mt[kk + this.M] ^ y >>> 1 ^ mag01[y & 1];
}
for (; kk < this.N - 1; kk++) {
y = this.mt[kk] & this.UPPER_MASK | this.mt[kk + 1] & this.LOWER_MASK;
this.mt[kk] = this.mt[kk + (this.M - this.N)] ^ y >>> 1 ^ mag01[y & 1];
}
y = this.mt[this.N - 1] & this.UPPER_MASK | this.mt[0] & this.LOWER_MASK;
this.mt[this.N - 1] = this.mt[this.M - 1] ^ y >>> 1 ^ mag01[y & 1];
this.mti = 0;
}
y = this.mt[this.mti++];
y ^= y >>> 11;
y ^= y << 7 & 2636928640;
y ^= y << 15 & 4022730752;
y ^= y >>> 18;
return y >>> 0;
};
MersenneTwister.prototype.random_int31 = function() {
return this.random_int() >>> 1;
};
MersenneTwister.prototype.random_incl = function() {
return this.random_int() * (1 / 4294967295);
};
MersenneTwister.prototype.random = function() {
return this.random_int() * (1 / 4294967296);
};
MersenneTwister.prototype.random_excl = function() {
return (this.random_int() + 0.5) * (1 / 4294967296);
};
MersenneTwister.prototype.random_long = function() {
var a3 = this.random_int() >>> 5, b = this.random_int() >>> 6;
return (a3 * 67108864 + b) * (1 / 9007199254740992);
};
module2.exports = MersenneTwister;
}
});
// node_modules/urijs/src/punycode.js
var require_punycode = __commonJS({
"node_modules/urijs/src/punycode.js"(exports2, module2) {
/*! https://mths.be/punycode v1.4.0 by @mathias */
(function(root) {
var freeExports = typeof exports2 == "object" && exports2 && !exports2.nodeType && exports2;
var freeModule = typeof module2 == "object" && module2 && !module2.nodeType && module2;
var freeGlobal = typeof global == "object" && global;
if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal || freeGlobal.self === freeGlobal) {
root = freeGlobal;
}
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 = {
"overflow": "Overflow: input needs wider integers to process",
"not-basic": "Illegal input >= 0x80 (not a basic code point)",
"invalid-input": "Invalid input"
}, baseMinusTMin = base - tMin, floor = Math.floor, stringFromCharCode = String.fromCharCode, key;
function error(type) {
throw new RangeError(errors[type]);
}
function map(array, fn) {
var length3 = array.length;
var result = [];
while (length3--) {
result[length3] = fn(array[length3]);
}
return result;
}
function mapDomain(string, fn) {
var parts = string.split("@");
var result = "";
if (parts.length > 1) {
result = parts[0] + "@";
string = parts[1];
}
string = string.replace(regexSeparators, ".");
var labels = string.split(".");
var encoded = map(labels, fn).join(".");
return result + encoded;
}
function ucs2decode(string) {
var output = [], counter = 0, length3 = string.length, value, extra;
while (counter < length3) {
value = string.charCodeAt(counter++);
if (value >= 55296 && value <= 56319 && counter < length3) {
extra = string.charCodeAt(counter++);
if ((extra & 64512) == 56320) {
output.push(((value & 1023) << 10) + (extra & 1023) + 65536);
} else {
output.push(value);
counter--;
}
} else {
output.push(value);
}
}
return output;
}
function ucs2encode(array) {
return map(array, function(value) {
var output = "";
if (value > 65535) {
value -= 65536;
output += stringFromCharCode(value >>> 10 & 1023 | 55296);
value = 56320 | value & 1023;
}
output += stringFromCharCode(value);
return output;
}).join("");
}
function basicToDigit(codePoint) {
if (codePoint - 48 < 10) {
return codePoint - 22;
}
if (codePoint - 65 < 26) {
return codePoint - 65;
}
if (codePoint - 97 < 26) {
return codePoint - 97;
}
return base;
}
function digitToBasic(digit, flag) {
return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5);
}
function adapt(delta, numPoints, firstTime) {
var k = 0;
delta = firstTime ? floor(delta / damp) : delta >> 1;
delta += floor(delta / numPoints);
for (; delta > baseMinusTMin * tMax >> 1; k += base) {
delta = floor(delta / baseMinusTMin);
}
return floor(k + (baseMinusTMin + 1) * delta / (delta + skew));
}
function decode(input) {
var output = [], inputLength = input.length, out, i = 0, n = initialN, bias = initialBias, basic, j, index, oldi, w, k, digit, t, baseMinusT;
basic = input.lastIndexOf(delimiter);
if (basic < 0) {
basic = 0;
}
for (j = 0; j < basic; ++j) {
if (input.charCodeAt(j) >= 128) {
error("not-basic");
}
output.push(input.charCodeAt(j));
}
for (index = basic > 0 ? basic + 1 : 0; index < inputLength; ) {
for (oldi = i, w = 1, k = base; ; k += base) {
if (index >= inputLength) {
error("invalid-input");
}
digit = basicToDigit(input.charCodeAt(index++));
if (digit >= base || digit > floor((maxInt - i) / w)) {
error("overflow");
}
i += digit * w;
t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias;
if (digit < t) {
break;
}
baseMinusT = base - t;
if (w > floor(maxInt / baseMinusT)) {
error("overflow");
}
w *= baseMinusT;
}
out = output.length + 1;
bias = adapt(i - oldi, out, oldi == 0);
if (floor(i / out) > maxInt - n) {
error("overflow");
}
n += floor(i / out);
i %= out;
output.splice(i++, 0, n);
}
return ucs2encode(output);
}
function encode(input) {
var n, delta, handledCPCount, basicLength, bias, j, m, q, k, t, currentValue, output = [], inputLength, handledCPCountPlusOne, baseMinusT, qMinusT;
input = ucs2decode(input);
inputLength = input.length;
n = initialN;
delta = 0;
bias = initialBias;
for (j = 0; j < inputLength; ++j) {
currentValue = input[j];
if (currentValue < 128) {
output.push(stringFromCharCode(currentValue));
}
}
handledCPCount = basicLength = output.length;
if (basicLength) {
output.push(delimiter);
}
while (handledCPCount < inputLength) {
for (m = maxInt, j = 0; j < inputLength; ++j) {
currentValue = input[j];
if (currentValue >= n && currentValue < m) {
m = currentValue;
}
}
handledCPCountPlusOne = handledCPCount + 1;
if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) {
error("overflow");
}
delta += (m - n) * handledCPCountPlusOne;
n = m;
for (j = 0; j < inputLength; ++j) {
currentValue = input[j];
if (currentValue < n && ++delta > maxInt) {
error("overflow");
}
if (currentValue == n) {
for (q = delta, k = base; ; k += base) {
t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias;
if (q < t) {
break;
}
qMinusT = q - t;
baseMinusT = base - t;
output.push(
stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0))
);
q = floor(qMinusT / baseMinusT);
}
output.push(stringFromCharCode(digitToBasic(q, 0)));
bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength);
delta = 0;
++handledCPCount;
}
}
++delta;
++n;
}
return output.join("");
}
function toUnicode(input) {
return mapDomain(input, function(string) {
return regexPunycode.test(string) ? decode(string.slice(4).toLowerCase()) : string;
});
}
function toASCII(input) {
return mapDomain(input, function(string) {
return regexNonASCII.test(string) ? "xn--" + encode(string) : string;
});
}
punycode = {
"version": "1.3.2",
"ucs2": {
"decode": ucs2decode,
"encode": ucs2encode
},
"decode": decode,
"encode": encode,
"toASCII": toASCII,
"toUnicode": toUnicode
};
if (typeof define == "function" && typeof define.amd == "object" && define.amd) {
define("punycode", function() {
return punycode;
});
} else if (freeExports && freeModule) {
if (module2.exports == freeExports) {
freeModule.exports = punycode;
} else {
for (key in punycode) {
punycode.hasOwnProperty(key) && (freeExports[key] = punycode[key]);
}
}
} else {
root.punycode = punycode;
}
})(exports2);
}
});
// node_modules/urijs/src/IPv6.js
var require_IPv6 = __commonJS({
"node_modules/urijs/src/IPv6.js"(exports2, module2) {
/*!
* URI.js - Mutating URLs
* IPv6 Support
*
* Version: 1.19.11
*
* Author: Rodney Rehm
* Web: http://medialize.github.io/URI.js/
*
* Licensed under
* MIT License http://www.opensource.org/licenses/mit-license
*
*/
(function(root, factory) {
"use strict";
if (typeof module2 === "object" && module2.exports) {
module2.exports = factory();
} else if (typeof define === "function" && define.amd) {
define(factory);
} else {
root.IPv6 = factory(root);
}
})(exports2, function(root) {
"use strict";
var _IPv6 = root && root.IPv6;
function bestPresentation(address) {
var _address = address.toLowerCase();
var segments = _address.split(":");
var length3 = segments.length;
var total = 8;
if (segments[0] === "" && segments[1] === "" && segments[2] === "") {
segments.shift();
segments.shift();
} else if (segments[0] === "" && segments[1] === "") {
segments.shift();
} else if (segments[length3 - 1] === "" && segments[length3 - 2] === "") {
segments.pop();
}
length3 = segments.length;
if (segments[length3 - 1].indexOf(".") !== -1) {
total = 7;
}
var pos;
for (pos = 0; pos < length3; pos++) {
if (segments[pos] === "") {
break;
}
}
if (pos < total) {
segments.splice(pos, 1, "0000");
while (segments.length < total) {
segments.splice(pos, 0, "0000");
}
}
var _segments;
for (var i = 0; i < total; i++) {
_segments = segments[i].split("");
for (var j = 0; j < 3; j++) {
if (_segments[0] === "0" && _segments.length > 1) {
_segments.splice(0, 1);
} else {
break;
}
}
segments[i] = _segments.join("");
}
var best = -1;
var _best = 0;
var _current = 0;
var current = -1;
var inzeroes = false;
for (i = 0; i < total; i++) {
if (inzeroes) {
if (segments[i] === "0") {
_current += 1;
} else {
inzeroes = false;
if (_current > _best) {
best = current;
_best = _current;
}
}
} else {
if (segments[i] === "0") {
inzeroes = true;
current = i;
_current = 1;
}
}
}
if (_current > _best) {
best = current;
_best = _current;
}
if (_best > 1) {
segments.splice(best, _best, "");
}
length3 = segments.length;
var result = "";
if (segments[0] === "") {
result = ":";
}
for (i = 0; i < length3; i++) {
result += segments[i];
if (i === length3 - 1) {
break;
}
result += ":";
}
if (segments[length3 - 1] === "") {
result += ":";
}
return result;
}
function noConflict() {
if (root.IPv6 === this) {
root.IPv6 = _IPv6;
}
return this;
}
return {
best: bestPresentation,
noConflict
};
});
}
});
// node_modules/urijs/src/SecondLevelDomains.js
var require_SecondLevelDomains = __commonJS({
"node_modules/urijs/src/SecondLevelDomains.js"(exports2, module2) {
/*!
* URI.js - Mutating URLs
* Second Level Domain (SLD) Support
*
* Version: 1.19.11
*
* Author: Rodney Rehm
* Web: http://medialize.github.io/URI.js/
*
* Licensed under
* MIT License http://www.opensource.org/licenses/mit-license
*
*/
(function(root, factory) {
"use strict";
if (typeof module2 === "object" && module2.exports) {
module2.exports = factory();
} else if (typeof define === "function" && define.amd) {
define(factory);
} else {
root.SecondLevelDomains = factory(root);
}
})(exports2, function(root) {
"use strict";
var _SecondLevelDomains = root && root.SecondLevelDomains;
var SLD = {
list: {
"ac": " com gov mil net org ",
"ae": " ac co gov mil name net org pro sch ",
"af": " com edu gov net org ",
"al": " com edu gov mil net org ",
"ao": " co ed gv it og pb ",
"ar": " com edu gob gov int mil net org tur ",
"at": " ac co gv or ",
"au": " asn com csiro edu gov id net org ",
"ba": " co com edu gov mil net org rs unbi unmo unsa untz unze ",
"bb": " biz co com edu gov info net org store tv ",
"bh": " biz cc com edu gov info net org ",
"bn": " com edu gov net org ",
"bo": " com edu gob gov int mil net org tv ",
"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 ",
"bs": " com edu gov net org ",
"bz": " du et om ov rg ",
"ca": " ab bc mb nb nf nl ns nt nu on pe qc sk yk ",
"ck": " biz co edu gen gov info net org ",
"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 ",
"co": " com edu gov mil net nom org ",
"cr": " ac c co ed fi go or sa ",
"cy": " ac biz com ekloges gov ltd name net org parliament press pro tm ",
"do": " art com edu gob gov mil net org sld web ",
"dz": " art asso com edu gov net org pol ",
"ec": " com edu fin gov info med mil net org pro ",
"eg": " com edu eun gov mil name net org sci ",
"er": " com edu gov ind mil net org rochest w ",
"es": " com edu gob nom org ",
"et": " biz com edu gov info name net org ",
"fj": " ac biz com info mil name net org pro ",
"fk": " ac co gov net nom org ",
"fr": " asso com f gouv nom prd presse tm ",
"gg": " co net org ",
"gh": " com edu gov mil org ",
"gn": " ac com gov net org ",
"gr": " com edu gov mil net org ",
"gt": " com edu gob ind mil net org ",
"gu": " com edu gov net org ",
"hk": " com edu gov idv net org ",
"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 ",
"id": " ac co go mil net or sch web ",
"il": " ac co gov idf k12 muni net org ",
"in": " ac co edu ernet firm gen gov i ind mil net nic org res ",
"iq": " com edu gov i mil net org ",
"ir": " ac co dnssec gov i id net org sch ",
"it": " edu gov ",
"je": " co net org ",
"jo": " com edu gov mil name net org sch ",
"jp": " ac ad co ed go gr lg ne or ",
"ke": " ac co go info me mobi ne or sc ",
"kh": " com edu gov mil net org per ",
"ki": " biz com de edu gov info mob net org tel ",
"km": " asso com coop edu gouv k medecin mil nom notaires pharmaciens presse tm veterinaire ",
"kn": " edu gov net org ",
"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 ",
"kw": " com edu gov net org ",
"ky": " com edu gov net org ",
"kz": " com edu gov mil net org ",
"lb": " com edu gov net org ",
"lk": " assn com edu gov grp hotel int ltd net ngo org sch soc web ",
"lr": " com edu gov net org ",
"lv": " asn com conf edu gov id mil net org ",
"ly": " com edu gov id med net org plc sch ",
"ma": " ac co gov m net org press ",
"mc": " asso tm ",
"me": " ac co edu gov its net org priv ",
"mg": " com edu gov mil nom org prd tm ",
"mk": " com edu gov inf name net org pro ",
"ml": " com edu gov net org presse ",
"mn": " edu gov org ",
"mo": " com edu gov net org ",
"mt": " com edu gov net org ",
"mv": " aero biz com coop edu gov info int mil museum name net org pro ",
"mw": " ac co com coop edu gov int museum net org ",
"mx": " com edu gob net org ",
"my": " com edu gov mil name net org sch ",
"nf": " arts com firm info net other per rec store web ",
"ng": " biz com edu gov mil mobi name net org sch ",
"ni": " ac co com edu gob mil net nom org ",
"np": " com edu gov mil net org ",
"nr": " biz com edu gov info net org ",
"om": " ac biz co com edu gov med mil museum net org pro sch ",
"pe": " com edu gob mil net nom org sld ",
"ph": " com edu gov i mil net ngo org ",
"pk": " biz com edu fam gob gok gon gop gos gov net org web ",
"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 ",
"pr": " ac biz com edu est gov info isla name net org pro prof ",
"ps": " com edu gov net org plo sec ",
"pw": " belau co ed go ne or ",
"ro": " arts com firm info nom nt org rec store tm www ",
"rs": " ac co edu gov in org ",
"sb": " com edu gov net org ",
"sc": " com edu gov net org ",
"sh": " co com edu gov net nom org ",
"sl": " com edu gov net org ",
"st": " co com consulado edu embaixada gov mil net org principe saotome store ",
"sv": " com edu gob org red ",
"sz": " ac co org ",
"tr": " av bbs bel biz com dr edu gen gov info k12 name net org pol tel tsk tv web ",
"tt": " aero biz cat co com coop edu gov info int jobs mil mobi museum name net org pro tel travel ",
"tw": " club com ebiz edu game gov idv mil net org ",
"mu": " ac co com gov net or org ",
"mz": " ac co edu gov org ",
"na": " co com ",
"nz": " ac co cri geek gen govt health iwi maori mil net org parliament school ",
"pa": " abo ac com edu gob ing med net nom org sld ",
"pt": " com edu gov int net nome org publ ",
"py": " com edu gov mil net org ",
"qa": " com edu gov mil net org ",
"re": " asso com nom ",
"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 ",
"rw": " ac co com edu gouv gov int mil net ",
"sa": " com edu gov med net org pub sch ",
"sd": " com edu gov info med net org tv ",
"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 ",
"sg": " com edu gov idn net org per ",
"sn": " art com edu gouv org perso univ ",
"sy": " com edu gov mil net news org ",
"th": " ac co go in mi net or ",
"tj": " ac biz co com edu go gov info int mil name net nic org test web ",
"tn": " agrinet com defense edunet ens fin gov ind info intl mincom nat net org perso rnrt rns rnu tourism ",
"tz": " ac co go ne or ",
"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 ",
"ug": " ac co go ne or org sc ",
"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 ",
"us": " dni fed isa kids nsn ",
"uy": " com edu gub mil net org ",
"ve": " co com edu gob info mil net org web ",
"vi": " co com k12 net org ",
"vn": " ac biz com edu gov health info int name net org pro ",
"ye": " co com gov ltd me net org plc ",
"yu": " ac co edu gov org ",
"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 ",
"zm": " ac co com edu gov net org sch ",
"com": "ar br cn de eu gb gr hu jpn kr no qc ru sa se uk us uy za ",
"net": "gb jp se uk ",
"org": "ae",
"de": "com "
},
has: function(domain) {
var tldOffset = domain.lastIndexOf(".");
if (tldOffset <= 0 || tldOffset >= domain.length - 1) {
return false;
}
var sldOffset = domain.lastIndexOf(".", tldOffset - 1);
if (sldOffset <= 0 || sldOffset >= tldOffset - 1) {
return false;
}
var sldList = SLD.list[domain.slice(tldOffset + 1)];
if (!sldList) {
return false;
}
return sldList.indexOf(" " + domain.slice(sldOffset + 1, tldOffset) + " ") >= 0;
},
is: function(domain) {
var tldOffset = domain.lastIndexOf(".");
if (tldOffset <= 0 || tldOffset >= domain.length - 1) {
return false;
}
var sldOffset = domain.lastIndexOf(".", tldOffset - 1);
if (sldOffset >= 0) {
return false;
}
var sldList = SLD.list[domain.slice(tldOffset + 1)];
if (!sldList) {
return false;
}
return sldList.indexOf(" " + domain.slice(0, tldOffset) + " ") >= 0;
},
get: function(domain) {
var tldOffset = domain.lastIndexOf(".");
if (tldOffset <= 0 || tldOffset >= domain.length - 1) {
return null;
}
var sldOffset = domain.lastIndexOf(".", tldOffset - 1);
if (sldOffset <= 0 || sldOffset >= tldOffset - 1) {
return null;
}
var sldList = SLD.list[domain.slice(tldOffset + 1)];
if (!sldList) {
return null;
}
if (sldList.indexOf(" " + domain.slice(sldOffset + 1, tldOffset) + " ") < 0) {
return null;
}
return domain.slice(sldOffset + 1);
},
noConflict: function() {
if (root.SecondLevelDomains === this) {
root.SecondLevelDomains = _SecondLevelDomains;
}
return this;
}
};
return SLD;
});
}
});
// node_modules/urijs/src/URI.js
var require_URI = __commonJS({
"node_modules/urijs/src/URI.js"(exports2, module2) {
/*!
* URI.js - Mutating URLs
*
* Version: 1.19.11
*
* Author: Rodney Rehm
* Web: http://medialize.github.io/URI.js/
*
* Licensed under
* MIT License http://www.opensource.org/licenses/mit-license
*
*/
(function(root, factory) {
"use strict";
if (typeof module2 === "object" && module2.exports) {
module2.exports = factory(require_punycode(), require_IPv6(), require_SecondLevelDomains());
} else if (typeof define === "function" && define.amd) {
define(["./punycode", "./IPv6", "./SecondLevelDomains"], factory);
} else {
root.URI = factory(root.punycode, root.IPv6, root.SecondLevelDomains, root);
}
})(exports2, function(punycode, IPv6, SLD, root) {
"use strict";
var _URI = root && root.URI;
function URI(url2, base) {
var _urlSupplied = arguments.length >= 1;
var _baseSupplied = arguments.length >= 2;
if (!(this instanceof URI)) {
if (_urlSupplied) {
if (_baseSupplied) {
return new URI(url2, base);
}
return new URI(url2);
}
return new URI();
}
if (url2 === void 0) {
if (_urlSupplied) {
throw new TypeError("undefined is not a valid argument for URI");
}
if (typeof location !== "undefined") {
url2 = location.href + "";
} else {
url2 = "";
}
}
if (url2 === null) {
if (_urlSupplied) {
throw new TypeError("null is not a valid argument for URI");
}
}
this.href(url2);
if (base !== void 0) {
return this.absoluteTo(base);
}
return this;
}
function isInteger(value) {
return /^[0-9]+$/.test(value);
}
URI.version = "1.19.11";
var p = URI.prototype;
var hasOwn = Object.prototype.hasOwnProperty;
function escapeRegEx(string) {
return string.replace(/([.*+?^=!:${}()|[\]\/\\])/g, "\\$1");
}
function getType(value) {
if (value === void 0) {
return "Undefined";
}
return String(Object.prototype.toString.call(value)).slice(8, -1);
}
function isArray(obj) {
return getType(obj) === "Array";
}
function filterArrayValues(data, value) {
var lookup = {};
var i, length3;
if (getType(value) === "RegExp") {
lookup = null;
} else if (isArray(value)) {
for (i = 0, length3 = value.length; i < length3; i++) {
lookup[value[i]] = true;
}
} else {
lookup[value] = true;
}
for (i = 0, length3 = data.length; i < length3; i++) {
var _match = lookup && lookup[data[i]] !== void 0 || !lookup && value.test(data[i]);
if (_match) {
data.splice(i, 1);
length3--;
i--;
}
}
return data;
}
function arrayContains(list, value) {
var i, length3;
if (isArray(value)) {
for (i = 0, length3 = value.length; i < length3; i++) {
if (!arrayContains(list, value[i])) {
return false;
}
}
return true;
}
var _type = getType(value);
for (i = 0, length3 = list.length; i < length3; i++) {
if (_type === "RegExp") {
if (typeof list[i] === "string" && list[i].match(value)) {
return true;
}
} else if (list[i] === value) {
return true;
}
}
return false;
}
function arraysEqual(one, two) {
if (!isArray(one) || !isArray(two)) {
return false;
}
if (one.length !== two.length) {
return false;
}
one.sort();
two.sort();
for (var i = 0, l = one.length; i < l; i++) {
if (one[i] !== two[i]) {
return false;
}
}
return true;
}
function trimSlashes(text) {
var trim_expression = /^\/+|\/+$/g;
return text.replace(trim_expression, "");
}
URI._parts = function() {
return {
protocol: null,
username: null,
password: null,
hostname: null,
urn: null,
port: null,
path: null,
query: null,
fragment: null,
preventInvalidHostname: URI.preventInvalidHostname,
duplicateQueryParameters: URI.duplicateQueryParameters,
escapeQuerySpace: URI.escapeQuerySpace
};
};
URI.preventInvalidHostname = false;
URI.duplicateQueryParameters = false;
URI.escapeQuerySpace = true;
URI.protocol_expression = /^[a-z][a-z0-9.+-]*$/i;
URI.idn_expression = /[^a-z0-9\._-]/i;
URI.punycode_expression = /(xn--)/i;
URI.ip4_expression = /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/;
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*$/;
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;
URI.findUri = {
start: /\b(?:([a-z][a-z0-9.+-]*:\/\/)|www\.)/gi,
end: /[\s\r\n]|$/,
trim: /[`!()\[\]{};:'".,<>?«»“”„‘’]+$/,
parens: /(\([^\)]*\)|\[[^\]]*\]|\{[^}]*\}|<[^>]*>)/g
};
URI.leading_whitespace_expression = /^[\x00-\x20\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]+/;
URI.ascii_tab_whitespace = /[\u0009\u000A\u000D]+/g;
URI.defaultPorts = {
http: "80",
https: "443",
ftp: "21",
gopher: "70",
ws: "80",
wss: "443"
};
URI.hostProtocols = [
"http",
"https"
];
URI.invalid_hostname_characters = /[^a-zA-Z0-9\.\-:_]/;
URI.domAttributes = {
"a": "href",
"blockquote": "cite",
"link": "href",
"base": "href",
"script": "src",
"form": "action",
"img": "src",
"area": "href",
"iframe": "src",
"embed": "src",
"source": "src",
"track": "src",
"input": "src",
"audio": "src",
"video": "src"
};
URI.getDomAttribute = function(node) {
if (!node || !node.nodeName) {
return void 0;
}
var nodeName = node.nodeName.toLowerCase();
if (nodeName === "input" && node.type !== "image") {
return void 0;
}
return URI.domAttributes[nodeName];
};
function escapeForDumbFirefox36(value) {
return escape(value);
}
function strictEncodeURIComponent(string) {
return encodeURIComponent(string).replace(/[!'()*]/g, escapeForDumbFirefox36).replace(/\*/g, "%2A");
}
URI.encode = strictEncodeURIComponent;
URI.decode = decodeURIComponent;
URI.iso8859 = function() {
URI.encode = escape;
URI.decode = unescape;
};
URI.unicode = function() {
URI.encode = strictEncodeURIComponent;
URI.decode = decodeURIComponent;
};
URI.characters = {
pathname: {
encode: {
expression: /%(24|26|2B|2C|3B|3D|3A|40)/ig,
map: {
"%24": "$",
"%26": "&",
"%2B": "+",
"%2C": ",",
"%3B": ";",
"%3D": "=",
"%3A": ":",
"%40": "@"
}
},
decode: {
expression: /[\/\?#]/g,
map: {
"/": "%2F",
"?": "%3F",
"#": "%23"
}
}
},
reserved: {
encode: {
expression: /%(21|23|24|26|27|28|29|2A|2B|2C|2F|3A|3B|3D|3F|40|5B|5D)/ig,
map: {
"%3A": ":",
"%2F": "/",
"%3F": "?",
"%23": "#",
"%5B": "[",
"%5D": "]",
"%40": "@",
"%21": "!",
"%24": "$",
"%26": "&",
"%27": "'",
"%28": "(",
"%29": ")",
"%2A": "*",
"%2B": "+",
"%2C": ",",
"%3B": ";",
"%3D": "="
}
}
},
urnpath: {
encode: {
expression: /%(21|24|27|28|29|2A|2B|2C|3B|3D|40)/ig,
map: {
"%21": "!",
"%24": "$",
"%27": "'",
"%28": "(",
"%29": ")",
"%2A": "*",
"%2B": "+",
"%2C": ",",
"%3B": ";",
"%3D": "=",
"%40": "@"
}
},
decode: {
expression: /[\/\?#:]/g,
map: {
"/": "%2F",
"?": "%3F",
"#": "%23",
":": "%3A"
}
}
}
};
URI.encodeQuery = function(string, escapeQuerySpace) {
var escaped = URI.encode(string + "");
if (escapeQuerySpace === void 0) {
escapeQuerySpace = URI.escapeQuerySpace;
}
return escapeQuerySpace ? escaped.replace(/%20/g, "+") : escaped;
};
URI.decodeQuery = function(string, escapeQuerySpace) {
string += "";
if (escapeQuerySpace === void 0) {
escapeQuerySpace = URI.escapeQuerySpace;
}
try {
return URI.decode(escapeQuerySpace ? string.replace(/\+/g, "%20") : string);
} catch (e) {
return string;
}
};
var _parts = { "encode": "encode", "decode": "decode" };
var _part;
var generateAccessor = function(_group, _part2) {
return function(string) {
try {
return URI[_part2](string + "").replace(URI.characters[_group][_part2].expression, function(c) {
return URI.characters[_group][_part2].map[c];
});
} catch (e) {
return string;
}
};
};
for (_part in _parts) {
URI[_part + "PathSegment"] = generateAccessor("pathname", _parts[_part]);
URI[_part + "UrnPathSegment"] = generateAccessor("urnpath", _parts[_part]);
}
var generateSegmentedPathFunction = function(_sep, _codingFuncName, _innerCodingFuncName) {
return function(string) {
var actualCodingFunc;
if (!_innerCodingFuncName) {
actualCodingFunc = URI[_codingFuncName];
} else {
actualCodingFunc = function(string2) {
return URI[_codingFuncName](URI[_innerCodingFuncName](string2));
};
}
var segments = (string + "").split(_sep);
for (var i = 0, length3 = segments.length; i < length3; i++) {
segments[i] = actualCodingFunc(segments[i]);
}
return segments.join(_sep);
};
};
URI.decodePath = generateSegmentedPathFunction("/", "decodePathSegment");
URI.decodeUrnPath = generateSegmentedPathFunction(":", "decodeUrnPathSegment");
URI.recodePath = generateSegmentedPathFunction("/", "encodePathSegment", "decode");
URI.recodeUrnPath = generateSegmentedPathFunction(":", "encodeUrnPathSegment", "decode");
URI.encodeReserved = generateAccessor("reserved", "encode");
URI.parse = function(string, parts) {
var pos;
if (!parts) {
parts = {
preventInvalidHostname: URI.preventInvalidHostname
};
}
string = string.replace(URI.leading_whitespace_expression, "");
string = string.replace(URI.ascii_tab_whitespace, "");
pos = string.indexOf("#");
if (pos > -1) {
parts.fragment = string.substring(pos + 1) || null;
string = string.substring(0, pos);
}
pos = string.indexOf("?");
if (pos > -1) {
parts.query = string.substring(pos + 1) || null;
string = string.substring(0, pos);
}
string = string.replace(/^(https?|ftp|wss?)?:+[/\\]*/i, "$1://");
string = string.replace(/^[/\\]{2,}/i, "//");
if (string.substring(0, 2) === "//") {
parts.protocol = null;
string = string.substring(2);
string = URI.parseAuthority(string, parts);
} else {
pos = string.indexOf(":");
if (pos > -1) {
parts.protocol = string.substring(0, pos) || null;
if (parts.protocol && !parts.protocol.match(URI.protocol_expression)) {
parts.protocol = void 0;
} else if (string.substring(pos + 1, pos + 3).replace(/\\/g, "/") === "//") {
string = string.substring(pos + 3);
string = URI.parseAuthority(string, parts);
} else {
string = string.substring(pos + 1);
parts.urn = true;
}
}
}
parts.path = string;
return parts;
};
URI.parseHost = function(string, parts) {
if (!string) {
string = "";
}
string = string.replace(/\\/g, "/");
var pos = string.indexOf("/");
var bracketPos;
var t;
if (pos === -1) {
pos = string.length;
}
if (string.charAt(0) === "[") {
bracketPos = string.indexOf("]");
parts.hostname = string.substring(1, bracketPos) || null;
parts.port = string.substring(bracketPos + 2, pos) || null;
if (parts.port === "/") {
parts.port = null;
}
} else {
var firstColon = string.indexOf(":");
var firstSlash = string.indexOf("/");
var nextColon = string.indexOf(":", firstColon + 1);
if (nextColon !== -1 && (firstSlash === -1 || nextColon < firstSlash)) {
parts.hostname = string.substring(0, pos) || null;
parts.port = null;
} else {
t = string.substring(0, pos).split(":");
parts.hostname = t[0] || null;
parts.port = t[1] || null;
}
}
if (parts.hostname && string.substring(pos).charAt(0) !== "/") {
pos++;
string = "/" + string;
}
if (parts.preventInvalidHostname) {
URI.ensureValidHostname(parts.hostname, parts.protocol);
}
if (parts.port) {
URI.ensureValidPort(parts.port);
}
return string.substring(pos) || "/";
};
URI.parseAuthority = function(string, parts) {
string = URI.parseUserinfo(string, parts);
return URI.parseHost(string, parts);
};
URI.parseUserinfo = function(string, parts) {
var _string = string;
var firstBackSlash = string.indexOf("\\");
if (firstBackSlash !== -1) {
string = string.replace(/\\/g, "/");
}
var firstSlash = string.indexOf("/");
var pos = string.lastIndexOf("@", firstSlash > -1 ? firstSlash : string.length - 1);
var t;
if (pos > -1 && (firstSlash === -1 || pos < firstSlash)) {
t = string.substring(0, pos).split(":");
parts.username = t[0] ? URI.decode(t[0]) : null;
t.shift();
parts.password = t[0] ? URI.decode(t.join(":")) : null;
string = _string.substring(pos + 1);
} else {
parts.username = null;
parts.password = null;
}
return string;
};
URI.parseQuery = function(string, escapeQuerySpace) {
if (!string) {
return {};
}
string = string.replace(/&+/g, "&").replace(/^\?*&*|&+$/g, "");
if (!string) {
return {};
}
var items = {};
var splits = string.split("&");
var length3 = splits.length;
var v7, name, value;
for (var i = 0; i < length3; i++) {
v7 = splits[i].split("=");
name = URI.decodeQuery(v7.shift(), escapeQuerySpace);
value = v7.length ? URI.decodeQuery(v7.join("="), escapeQuerySpace) : null;
if (name === "__proto__") {
continue;
} else if (hasOwn.call(items, name)) {
if (typeof items[name] === "string" || items[name] === null) {
items[name] = [items[name]];
}
items[name].push(value);
} else {
items[name] = value;
}
}
return items;
};
URI.build = function(parts) {
var t = "";
var requireAbsolutePath = false;
if (parts.protocol) {
t += parts.protocol + ":";
}
if (!parts.urn && (t || parts.hostname)) {
t += "//";
requireAbsolutePath = true;
}
t += URI.buildAuthority(parts) || "";
if (typeof parts.path === "string") {
if (parts.path.charAt(0) !== "/" && requireAbsolutePath) {
t += "/";
}
t += parts.path;
}
if (typeof parts.query === "string" && parts.query) {
t += "?" + parts.query;
}
if (typeof parts.fragment === "string" && parts.fragment) {
t += "#" + parts.fragment;
}
return t;
};
URI.buildHost = function(parts) {
var t = "";
if (!parts.hostname) {
return "";
} else if (URI.ip6_expression.test(parts.hostname)) {
t += "[" + parts.hostname + "]";
} else {
t += parts.hostname;
}
if (parts.port) {
t += ":" + parts.port;
}
return t;
};
URI.buildAuthority = function(parts) {
return URI.buildUserinfo(parts) + URI.buildHost(parts);
};
URI.buildUserinfo = function(parts) {
var t = "";
if (parts.username) {
t += URI.encode(parts.username);
}
if (parts.password) {
t += ":" + URI.encode(parts.password);
}
if (t) {
t += "@";
}
return t;
};
URI.buildQuery = function(data, duplicateQueryParameters, escapeQuerySpace) {
var t = "";
var unique, key, i, length3;
for (key in data) {
if (key === "__proto__") {
continue;
} else if (hasOwn.call(data, key)) {
if (isArray(data[key])) {
unique = {};
for (i = 0, length3 = data[key].length; i < length3; i++) {
if (data[key][i] !== void 0 && unique[data[key][i] + ""] === void 0) {
t += "&" + URI.buildQueryParameter(key, data[key][i], escapeQuerySpace);
if (duplicateQueryParameters !== true) {
unique[data[key][i] + ""] = true;
}
}
}
} else if (data[key] !== void 0) {
t += "&" + URI.buildQueryParameter(key, data[key], escapeQuerySpace);
}
}
}
return t.substring(1);
};
URI.buildQueryParameter = function(name, value, escapeQuerySpace) {
return URI.encodeQuery(name, escapeQuerySpace) + (value !== null ? "=" + URI.encodeQuery(value, escapeQuerySpace) : "");
};
URI.addQuery = function(data, name, value) {
if (typeof name === "object") {
for (var key in name) {
if (hasOwn.call(name, key)) {
URI.addQuery(data, key, name[key]);
}
}
} else if (typeof name === "string") {
if (data[name] === void 0) {
data[name] = value;
return;
} else if (typeof data[name] === "string") {
data[name] = [data[name]];
}
if (!isArray(value)) {
value = [value];
}
data[name] = (data[name] || []).concat(value);
} else {
throw new TypeError("URI.addQuery() accepts an object, string as the name parameter");
}
};
URI.setQuery = function(data, name, value) {
if (typeof name === "object") {
for (var key in name) {
if (hasOwn.call(name, key)) {
URI.setQuery(data, key, name[key]);
}
}
} else if (typeof name === "string") {
data[name] = value === void 0 ? null : value;
} else {
throw new TypeError("URI.setQuery() accepts an object, string as the name parameter");
}
};
URI.removeQuery = function(data, name, value) {
var i, length3, key;
if (isArray(name)) {
for (i = 0, length3 = name.length; i < length3; i++) {
data[name[i]] = void 0;
}
} else if (getType(name) === "RegExp") {
for (key in data) {
if (name.test(key)) {
data[key] = void 0;
}
}
} else if (typeof name === "object") {
for (key in name) {
if (hasOwn.call(name, key)) {
URI.removeQuery(data, key, name[key]);
}
}
} else if (typeof name === "string") {
if (value !== void 0) {
if (getType(value) === "RegExp") {
if (!isArray(data[name]) && value.test(data[name])) {
data[name] = void 0;
} else {
data[name] = filterArrayValues(data[name], value);
}
} else if (data[name] === String(value) && (!isArray(value) || value.length === 1)) {
data[name] = void 0;
} else if (isArray(data[name])) {
data[name] = filterArrayValues(data[name], value);
}
} else {
data[name] = void 0;
}
} else {
throw new TypeError("URI.removeQuery() accepts an object, string, RegExp as the first parameter");
}
};
URI.hasQuery = function(data, name, value, withinArray) {
switch (getType(name)) {
case "String":
break;
case "RegExp":
for (var key in data) {
if (hasOwn.call(data, key)) {
if (name.test(key) && (value === void 0 || URI.hasQuery(data, key, value))) {
return true;
}
}
}
return false;
case "Object":
for (var _key in name) {
if (hasOwn.call(name, _key)) {
if (!URI.hasQuery(data, _key, name[_key])) {
return false;
}
}
}
return true;
default:
throw new TypeError("URI.hasQuery() accepts a string, regular expression or object as the name parameter");
}
switch (getType(value)) {
case "Undefined":
return name in data;
case "Boolean":
var _booly = Boolean(isArray(data[name]) ? data[name].length : data[name]);
return value === _booly;
case "Function":
return !!value(data[name], name, data);
case "Array":
if (!isArray(data[name])) {
return false;
}
var op = withinArray ? arrayContains : arraysEqual;
return op(data[name], value);
case "RegExp":
if (!isArray(data[name])) {
return Boolean(data[name] && data[name].match(value));
}
if (!withinArray) {
return false;
}
return arrayContains(data[name], value);
case "Number":
value = String(value);
case "String":
if (!isArray(data[name])) {
return data[name] === value;
}
if (!withinArray) {
return false;
}
return arrayContains(data[name], value);
default:
throw new TypeError("URI.hasQuery() accepts undefined, boolean, string, number, RegExp, Function as the value parameter");
}
};
URI.joinPaths = function() {
var input = [];
var segments = [];
var nonEmptySegments = 0;
for (var i = 0; i < arguments.length; i++) {
var url2 = new URI(arguments[i]);
input.push(url2);
var _segments = url2.segment();
for (var s = 0; s < _segments.length; s++) {
if (typeof _segments[s] === "string") {
segments.push(_segments[s]);
}
if (_segments[s]) {
nonEmptySegments++;
}
}
}
if (!segments.length || !nonEmptySegments) {
return new URI("");
}
var uri = new URI("").segment(segments);
if (input[0].path() === "" || input[0].path().slice(0, 1) === "/") {
uri.path("/" + uri.path());
}
return uri.normalize();
};
URI.commonPath = function(one, two) {
var length3 = Math.min(one.length, two.length);
var pos;
for (pos = 0; pos < length3; pos++) {
if (one.charAt(pos) !== two.charAt(pos)) {
pos--;
break;
}
}
if (pos < 1) {
return one.charAt(0) === two.charAt(0) && one.charAt(0) === "/" ? "/" : "";
}
if (one.charAt(pos) !== "/" || two.charAt(pos) !== "/") {
pos = one.substring(0, pos).lastIndexOf("/");
}
return one.substring(0, pos + 1);
};
URI.withinString = function(string, callback, options) {
options || (options = {});
var _start = options.start || URI.findUri.start;
var _end = options.end || URI.findUri.end;
var _trim = options.trim || URI.findUri.trim;
var _parens = options.parens || URI.findUri.parens;
var _attributeOpen = /[a-z0-9-]=["']?$/i;
_start.lastIndex = 0;
while (true) {
var match = _start.exec(string);
if (!match) {
break;
}
var start = match.index;
if (options.ignoreHtml) {
var attributeOpen = string.slice(Math.max(start - 3, 0), start);
if (attributeOpen && _attributeOpen.test(attributeOpen)) {
continue;
}
}
var end = start + string.slice(start).search(_end);
var slice = string.slice(start, end);
var parensEnd = -1;
while (true) {
var parensMatch = _parens.exec(slice);
if (!parensMatch) {
break;
}
var parensMatchEnd = parensMatch.index + parensMatch[0].length;
parensEnd = Math.max(parensEnd, parensMatchEnd);
}
if (parensEnd > -1) {
slice = slice.slice(0, parensEnd) + slice.slice(parensEnd).replace(_trim, "");
} else {
slice = slice.replace(_trim, "");
}
if (slice.length <= match[0].length) {
continue;
}
if (options.ignore && options.ignore.test(slice)) {
continue;
}
end = start + slice.length;
var result = callback(slice, start, end, string);
if (result === void 0) {
_start.lastIndex = end;
continue;
}
result = String(result);
string = string.slice(0, start) + result + string.slice(end);
_start.lastIndex = start + result.length;
}
_start.lastIndex = 0;
return string;
};
URI.ensureValidHostname = function(v7, protocol) {
var hasHostname = !!v7;
var hasProtocol = !!protocol;
var rejectEmptyHostname = false;
if (hasProtocol) {
rejectEmptyHostname = arrayContains(URI.hostProtocols, protocol);
}
if (rejectEmptyHostname && !hasHostname) {
throw new TypeError("Hostname cannot be empty, if protocol is " + protocol);
} else if (v7 && v7.match(URI.invalid_hostname_characters)) {
if (!punycode) {
throw new TypeError('Hostname "' + v7 + '" contains characters other than [A-Z0-9.-:_] and Punycode.js is not available');
}
if (punycode.toASCII(v7).match(URI.invalid_hostname_characters)) {
throw new TypeError('Hostname "' + v7 + '" contains characters other than [A-Z0-9.-:_]');
}
}
};
URI.ensureValidPort = function(v7) {
if (!v7) {
return;
}
var port = Number(v7);
if (isInteger(port) && port > 0 && port < 65536) {
return;
}
throw new TypeError('Port "' + v7 + '" is not a valid port');
};
URI.noConflict = function(removeAll) {
if (removeAll) {
var unconflicted = {
URI: this.noConflict()
};
if (root.URITemplate && typeof root.URITemplate.noConflict === "function") {
unconflicted.URITemplate = root.URITemplate.noConflict();
}
if (root.IPv6 && typeof root.IPv6.noConflict === "function") {
unconflicted.IPv6 = root.IPv6.noConflict();
}
if (root.SecondLevelDomains && typeof root.SecondLevelDomains.noConflict === "function") {
unconflicted.SecondLevelDomains = root.SecondLevelDomains.noConflict();
}
return unconflicted;
} else if (root.URI === this) {
root.URI = _URI;
}
return this;
};
p.build = function(deferBuild) {
if (deferBuild === true) {
this._deferred_build = true;
} else if (deferBuild === void 0 || this._deferred_build) {
this._string = URI.build(this._parts);
this._deferred_build = false;
}
return this;
};
p.clone = function() {
return new URI(this);
};
p.valueOf = p.toString = function() {
return this.build(false)._string;
};
function generateSimpleAccessor(_part2) {
return function(v7, build) {
if (v7 === void 0) {
return this._parts[_part2] || "";
} else {
this._parts[_part2] = v7 || null;
this.build(!build);
return this;
}
};
}
function generatePrefixAccessor(_part2, _key) {
return function(v7, build) {
if (v7 === void 0) {
return this._parts[_part2] || "";
} else {
if (v7 !== null) {
v7 = v7 + "";
if (v7.charAt(0) === _key) {
v7 = v7.substring(1);
}
}
this._parts[_part2] = v7;
this.build(!build);
return this;
}
};
}
p.protocol = generateSimpleAccessor("protocol");
p.username = generateSimpleAccessor("username");
p.password = generateSimpleAccessor("password");
p.hostname = generateSimpleAccessor("hostname");
p.port = generateSimpleAccessor("port");
p.query = generatePrefixAccessor("query", "?");
p.fragment = generatePrefixAccessor("fragment", "#");
p.search = function(v7, build) {
var t = this.query(v7, build);
return typeof t === "string" && t.length ? "?" + t : t;
};
p.hash = function(v7, build) {
var t = this.fragment(v7, build);
return typeof t === "string" && t.length ? "#" + t : t;
};
p.pathname = function(v7, build) {
if (v7 === void 0 || v7 === true) {
var res = this._parts.path || (this._parts.hostname ? "/" : "");
return v7 ? (this._parts.urn ? URI.decodeUrnPath : URI.decodePath)(res) : res;
} else {
if (this._parts.urn) {
this._parts.path = v7 ? URI.recodeUrnPath(v7) : "";
} else {
this._parts.path = v7 ? URI.recodePath(v7) : "/";
}
this.build(!build);
return this;
}
};
p.path = p.pathname;
p.href = function(href, build) {
var key;
if (href === void 0) {
return this.toString();
}
this._string = "";
this._parts = URI._parts();
var _URI2 = href instanceof URI;
var _object = typeof href === "object" && (href.hostname || href.path || href.pathname);
if (href.nodeName) {
var attribute = URI.getDomAttribute(href);
href = href[attribute] || "";
_object = false;
}
if (!_URI2 && _object && href.pathname !== void 0) {
href = href.toString();
}
if (typeof href === "string" || href instanceof String) {
this._parts = URI.parse(String(href), this._parts);
} else if (_URI2 || _object) {
var src = _URI2 ? href._parts : href;
for (key in src) {
if (key === "query") {
continue;
}
if (hasOwn.call(this._parts, key)) {
this._parts[key] = src[key];
}
}
if (src.query) {
this.query(src.query, false);
}
} else {
throw new TypeError("invalid input");
}
this.build(!build);
return this;
};
p.is = function(what) {
var ip = false;
var ip4 = false;
var ip6 = false;
var name = false;
var sld = false;
var idn = false;
var punycode2 = false;
var relative = !this._parts.urn;
if (this._parts.hostname) {
relative = false;
ip4 = URI.ip4_expression.test(this._parts.hostname);
ip6 = URI.ip6_expression.test(this._parts.hostname);
ip = ip4 || ip6;
name = !ip;
sld = name && SLD && SLD.has(this._parts.hostname);
idn = name && URI.idn_expression.test(this._parts.hostname);
punycode2 = name && URI.punycode_expression.test(this._parts.hostname);
}
switch (what.toLowerCase()) {
case "relative":
return relative;
case "absolute":
return !relative;
case "domain":
case "name":
return name;
case "sld":
return sld;
case "ip":
return ip;
case "ip4":
case "ipv4":
case "inet4":
return ip4;
case "ip6":
case "ipv6":
case "inet6":
return ip6;
case "idn":
return idn;
case "url":
return !this._parts.urn;
case "urn":
return !!this._parts.urn;
case "punycode":
return punycode2;
}
return null;
};
var _protocol = p.protocol;
var _port = p.port;
var _hostname = p.hostname;
p.protocol = function(v7, build) {
if (v7) {
v7 = v7.replace(/:(\/\/)?$/, "");
if (!v7.match(URI.protocol_expression)) {
throw new TypeError('Protocol "' + v7 + `" contains characters other than [A-Z0-9.+-] or doesn't start with [A-Z]`);
}
}
return _protocol.call(this, v7, build);
};
p.scheme = p.protocol;
p.port = function(v7, build) {
if (this._parts.urn) {
return v7 === void 0 ? "" : this;
}
if (v7 !== void 0) {
if (v7 === 0) {
v7 = null;
}
if (v7) {
v7 += "";
if (v7.charAt(0) === ":") {
v7 = v7.substring(1);
}
URI.ensureValidPort(v7);
}
}
return _port.call(this, v7, build);
};
p.hostname = function(v7, build) {
if (this._parts.urn) {
return v7 === void 0 ? "" : this;
}
if (v7 !== void 0) {
var x = { preventInvalidHostname: this._parts.preventInvalidHostname };
var res = URI.parseHost(v7, x);
if (res !== "/") {
throw new TypeError('Hostname "' + v7 + '" contains characters other than [A-Z0-9.-]');
}
v7 = x.hostname;
if (this._parts.preventInvalidHostname) {
URI.ensureValidHostname(v7, this._parts.protocol);
}
}
return _hostname.call(this, v7, build);
};
p.origin = function(v7, build) {
if (this._parts.urn) {
return v7 === void 0 ? "" : this;
}
if (v7 === void 0) {
var protocol = this.protocol();
var authority = this.authority();
if (!authority) {
return "";
}
return (protocol ? protocol + "://" : "") + this.authority();
} else {
var origin = URI(v7);
this.protocol(origin.protocol()).authority(origin.authority()).build(!build);
return this;
}
};
p.host = function(v7, build) {
if (this._parts.urn) {
return v7 === void 0 ? "" : this;
}
if (v7 === void 0) {
return this._parts.hostname ? URI.buildHost(this._parts) : "";
} else {
var res = URI.parseHost(v7, this._parts);
if (res !== "/") {
throw new TypeError('Hostname "' + v7 + '" contains characters other than [A-Z0-9.-]');
}
this.build(!build);
return this;
}
};
p.authority = function(v7, build) {
if (this._parts.urn) {
return v7 === void 0 ? "" : this;
}
if (v7 === void 0) {
return this._parts.hostname ? URI.buildAuthority(this._parts) : "";
} else {
var res = URI.parseAuthority(v7, this._parts);
if (res !== "/") {
throw new TypeError('Hostname "' + v7 + '" contains characters other than [A-Z0-9.-]');
}
this.build(!build);
return this;
}
};
p.userinfo = function(v7, build) {
if (this._parts.urn) {
return v7 === void 0 ? "" : this;
}
if (v7 === void 0) {
var t = URI.buildUserinfo(this._parts);
return t ? t.substring(0, t.length - 1) : t;
} else {
if (v7[v7.length - 1] !== "@") {
v7 += "@";
}
URI.parseUserinfo(v7, this._parts);
this.build(!build);
return this;
}
};
p.resource = function(v7, build) {
var parts;
if (v7 === void 0) {
return this.path() + this.search() + this.hash();
}
parts = URI.parse(v7);
this._parts.path = parts.path;
this._parts.query = parts.query;
this._parts.fragment = parts.fragment;
this.build(!build);
return this;
};
p.subdomain = function(v7, build) {
if (this._parts.urn) {
return v7 === void 0 ? "" : this;
}
if (v7 === void 0) {
if (!this._parts.hostname || this.is("IP")) {
return "";
}
var end = this._parts.hostname.length - this.domain().length - 1;
return this._parts.hostname.substring(0, end) || "";
} else {
var e = this._parts.hostname.length - this.domain().length;
var sub = this._parts.hostname.substring(0, e);
var replace = new RegExp("^" + escapeRegEx(sub));
if (v7 && v7.charAt(v7.length - 1) !== ".") {
v7 += ".";
}
if (v7.indexOf(":") !== -1) {
throw new TypeError("Domains cannot contain colons");
}
if (v7) {
URI.ensureValidHostname(v7, this._parts.protocol);
}
this._parts.hostname = this._parts.hostname.replace(replace, v7);
this.build(!build);
return this;
}
};
p.domain = function(v7, build) {
if (this._parts.urn) {
return v7 === void 0 ? "" : this;
}
if (typeof v7 === "boolean") {
build = v7;
v7 = void 0;
}
if (v7 === void 0) {
if (!this._parts.hostname || this.is("IP")) {
return "";
}
var t = this._parts.hostname.match(/\./g);
if (t && t.length < 2) {
return this._parts.hostname;
}
var end = this._parts.hostname.length - this.tld(build).length - 1;
end = this._parts.hostname.lastIndexOf(".", end - 1) + 1;
return this._parts.hostname.substring(end) || "";
} else {
if (!v7) {
throw new TypeError("cannot set domain empty");
}
if (v7.indexOf(":") !== -1) {
throw new TypeError("Domains cannot contain colons");
}
URI.ensureValidHostname(v7, this._parts.protocol);
if (!this._parts.hostname || this.is("IP")) {
this._parts.hostname = v7;
} else {
var replace = new RegExp(escapeRegEx(this.domain()) + "$");
this._parts.hostname = this._parts.hostname.replace(replace, v7);
}
this.build(!build);
return this;
}
};
p.tld = function(v7, build) {
if (this._parts.urn) {
return v7 === void 0 ? "" : this;
}
if (typeof v7 === "boolean") {
build = v7;
v7 = void 0;
}
if (v7 === void 0) {
if (!this._parts.hostname || this.is("IP")) {
return "";
}
var pos = this._parts.hostname.lastIndexOf(".");
var tld = this._parts.hostname.substring(pos + 1);
if (build !== true && SLD && SLD.list[tld.toLowerCase()]) {
return SLD.get(this._parts.hostname) || tld;
}
return tld;
} else {
var replace;
if (!v7) {
throw new TypeError("cannot set TLD empty");
} else if (v7.match(/[^a-zA-Z0-9-]/)) {
if (SLD && SLD.is(v7)) {
replace = new RegExp(escapeRegEx(this.tld()) + "$");
this._parts.hostname = this._parts.hostname.replace(replace, v7);
} else {
throw new TypeError('TLD "' + v7 + '" contains characters other than [A-Z0-9]');
}
} else if (!this._parts.hostname || this.is("IP")) {
throw new ReferenceError("cannot set TLD on non-domain host");
} else {
replace = new RegExp(escapeRegEx(this.tld()) + "$");
this._parts.hostname = this._parts.hostname.replace(replace, v7);
}
this.build(!build);
return this;
}
};
p.directory = function(v7, build) {
if (this._parts.urn) {
return v7 === void 0 ? "" : this;
}
if (v7 === void 0 || v7 === true) {
if (!this._parts.path && !this._parts.hostname) {
return "";
}
if (this._parts.path === "/") {
return "/";
}
var end = this._parts.path.length - this.filename().length - 1;
var res = this._parts.path.substring(0, end) || (this._parts.hostname ? "/" : "");
return v7 ? URI.decodePath(res) : res;
} else {
var e = this._parts.path.length - this.filename().length;
var directory = this._parts.path.substring(0, e);
var replace = new RegExp("^" + escapeRegEx(directory));
if (!this.is("relative")) {
if (!v7) {
v7 = "/";
}
if (v7.charAt(0) !== "/") {
v7 = "/" + v7;
}
}
if (v7 && v7.charAt(v7.length - 1) !== "/") {
v7 += "/";
}
v7 = URI.recodePath(v7);
this._parts.path = this._parts.path.replace(replace, v7);
this.build(!build);
return this;
}
};
p.filename = function(v7, build) {
if (this._parts.urn) {
return v7 === void 0 ? "" : this;
}
if (typeof v7 !== "string") {
if (!this._parts.path || this._parts.path === "/") {
return "";
}
var pos = this._parts.path.lastIndexOf("/");
var res = this._parts.path.substring(pos + 1);
return v7 ? URI.decodePathSegment(res) : res;
} else {
var mutatedDirectory = false;
if (v7.charAt(0) === "/") {
v7 = v7.substring(1);
}
if (v7.match(/\.?\//)) {
mutatedDirectory = true;
}
var replace = new RegExp(escapeRegEx(this.filename()) + "$");
v7 = URI.recodePath(v7);
this._parts.path = this._parts.path.replace(replace, v7);
if (mutatedDirectory) {
this.normalizePath(build);
} else {
this.build(!build);
}
return this;
}
};
p.suffix = function(v7, build) {
if (this._parts.urn) {
return v7 === void 0 ? "" : this;
}
if (v7 === void 0 || v7 === true) {
if (!this._parts.path || this._parts.path === "/") {
return "";
}
var filename = this.filename();
var pos = filename.lastIndexOf(".");
var s, res;
if (pos === -1) {
return "";
}
s = filename.substring(pos + 1);
res = /^[a-z0-9%]+$/i.test(s) ? s : "";
return v7 ? URI.decodePathSegment(res) : res;
} else {
if (v7.charAt(0) === ".") {
v7 = v7.substring(1);
}
var suffix = this.suffix();
var replace;
if (!suffix) {
if (!v7) {
return this;
}
this._parts.path += "." + URI.recodePath(v7);
} else if (!v7) {
replace = new RegExp(escapeRegEx("." + suffix) + "$");
} else {
replace = new RegExp(escapeRegEx(suffix) + "$");
}
if (replace) {
v7 = URI.recodePath(v7);
this._parts.path = this._parts.path.replace(replace, v7);
}
this.build(!build);
return this;
}
};
p.segment = function(segment, v7, build) {
var separator = this._parts.urn ? ":" : "/";
var path = this.path();
var absolute = path.substring(0, 1) === "/";
var segments = path.split(separator);
if (segment !== void 0 && typeof segment !== "number") {
build = v7;
v7 = segment;
segment = void 0;
}
if (segment !== void 0 && typeof segment !== "number") {
throw new Error('Bad segment "' + segment + '", must be 0-based integer');
}
if (absolute) {
segments.shift();
}
if (segment < 0) {
segment = Math.max(segments.length + segment, 0);
}
if (v7 === void 0) {
return segment === void 0 ? segments : segments[segment];
} else if (segment === null || segments[segment] === void 0) {
if (isArray(v7)) {
segments = [];
for (var i = 0, l = v7.length; i < l; i++) {
if (!v7[i].length && (!segments.length || !segments[segments.length - 1].length)) {
continue;
}
if (segments.length && !segments[segments.length - 1].length) {
segments.pop();
}
segments.push(trimSlashes(v7[i]));
}
} else if (v7 || typeof v7 === "string") {
v7 = trimSlashes(v7);
if (segments[segments.length - 1] === "") {
segments[segments.length - 1] = v7;
} else {
segments.push(v7);
}
}
} else {
if (v7) {
segments[segment] = trimSlashes(v7);
} else {
segments.splice(segment, 1);
}
}
if (absolute) {
segments.unshift("");
}
return this.path(segments.join(separator), build);
};
p.segmentCoded = function(segment, v7, build) {
var segments, i, l;
if (typeof segment !== "number") {
build = v7;
v7 = segment;
segment = void 0;
}
if (v7 === void 0) {
segments = this.segment(segment, v7, build);
if (!isArray(segments)) {
segments = segments !== void 0 ? URI.decode(segments) : void 0;
} else {
for (i = 0, l = segments.length; i < l; i++) {
segments[i] = URI.decode(segments[i]);
}
}
return segments;
}
if (!isArray(v7)) {
v7 = typeof v7 === "string" || v7 instanceof String ? URI.encode(v7) : v7;
} else {
for (i = 0, l = v7.length; i < l; i++) {
v7[i] = URI.encode(v7[i]);
}
}
return this.segment(segment, v7, build);
};
var q = p.query;
p.query = function(v7, build) {
if (v7 === true) {
return URI.parseQuery(this._parts.query, this._parts.escapeQuerySpace);
} else if (typeof v7 === "function") {
var data = URI.parseQuery(this._parts.query, this._parts.escapeQuerySpace);
var result = v7.call(this, data);
this._parts.query = URI.buildQuery(result || data, this._parts.duplicateQueryParameters, this._parts.escapeQuerySpace);
this.build(!build);
return this;
} else if (v7 !== void 0 && typeof v7 !== "string") {
this._parts.query = URI.buildQuery(v7, this._parts.duplicateQueryParameters, this._parts.escapeQuerySpace);
this.build(!build);
return this;
} else {
return q.call(this, v7, build);
}
};
p.setQuery = function(name, value, build) {
var data = URI.parseQuery(this._parts.query, this._parts.escapeQuerySpace);
if (typeof name === "string" || name instanceof String) {
data[name] = value !== void 0 ? value : null;
} else if (typeof name === "object") {
for (var key in name) {
if (hasOwn.call(name, key)) {
data[key] = name[key];
}
}
} else {
throw new TypeError("URI.addQuery() accepts an object, string as the name parameter");
}
this._parts.query = URI.buildQuery(data, this._parts.duplicateQueryParameters, this._parts.escapeQuerySpace);
if (typeof name !== "string") {
build = value;
}
this.build(!build);
return this;
};
p.addQuery = function(name, value, build) {
var data = URI.parseQuery(this._parts.query, this._parts.escapeQuerySpace);
URI.addQuery(data, name, value === void 0 ? null : value);
this._parts.query = URI.buildQuery(data, this._parts.duplicateQueryParameters, this._parts.escapeQuerySpace);
if (typeof name !== "string") {
build = value;
}
this.build(!build);
return this;
};
p.removeQuery = function(name, value, build) {
var data = URI.parseQuery(this._parts.query, this._parts.escapeQuerySpace);
URI.removeQuery(data, name, value);
this._parts.query = URI.buildQuery(data, this._parts.duplicateQueryParameters, this._parts.escapeQuerySpace);
if (typeof name !== "string") {
build = value;
}
this.build(!build);
return this;
};
p.hasQuery = function(name, value, withinArray) {
var data = URI.parseQuery(this._parts.query, this._parts.escapeQuerySpace);
return URI.hasQuery(data, name, value, withinArray);
};
p.setSearch = p.setQuery;
p.addSearch = p.addQuery;
p.removeSearch = p.removeQuery;
p.hasSearch = p.hasQuery;
p.normalize = function() {
if (this._parts.urn) {
return this.normalizeProtocol(false).normalizePath(false).normalizeQuery(false).normalizeFragment(false).build();
}
return this.normalizeProtocol(false).normalizeHostname(false).normalizePort(false).normalizePath(false).normalizeQuery(false).normalizeFragment(false).build();
};
p.normalizeProtocol = function(build) {
if (typeof this._parts.protocol === "string") {
this._parts.protocol = this._parts.protocol.toLowerCase();
this.build(!build);
}
return this;
};
p.normalizeHostname = function(build) {
if (this._parts.hostname) {
if (this.is("IDN") && punycode) {
this._parts.hostname = punycode.toASCII(this._parts.hostname);
} else if (this.is("IPv6") && IPv6) {
this._parts.hostname = IPv6.best(this._parts.hostname);
}
this._parts.hostname = this._parts.hostname.toLowerCase();
this.build(!build);
}
return this;
};
p.normalizePort = function(build) {
if (typeof this._parts.protocol === "string" && this._parts.port === URI.defaultPorts[this._parts.protocol]) {
this._parts.port = null;
this.build(!build);
}
return this;
};
p.normalizePath = function(build) {
var _path = this._parts.path;
if (!_path) {
return this;
}
if (this._parts.urn) {
this._parts.path = URI.recodeUrnPath(this._parts.path);
this.build(!build);
return this;
}
if (this._parts.path === "/") {
return this;
}
_path = URI.recodePath(_path);
var _was_relative;
var _leadingParents = "";
var _parent, _pos;
if (_path.charAt(0) !== "/") {
_was_relative = true;
_path = "/" + _path;
}
if (_path.slice(-3) === "/.." || _path.slice(-2) === "/.") {
_path += "/";
}
_path = _path.replace(/(\/(\.\/)+)|(\/\.$)/g, "/").replace(/\/{2,}/g, "/");
if (_was_relative) {
_leadingParents = _path.substring(1).match(/^(\.\.\/)+/) || "";
if (_leadingParents) {
_leadingParents = _leadingParents[0];
}
}
while (true) {
_parent = _path.search(/\/\.\.(\/|$)/);
if (_parent === -1) {
break;
} else if (_parent === 0) {
_path = _path.substring(3);
continue;
}
_pos = _path.substring(0, _parent).lastIndexOf("/");
if (_pos === -1) {
_pos = _parent;
}
_path = _path.substring(0, _pos) + _path.substring(_parent + 3);
}
if (_was_relative && this.is("relative")) {
_path = _leadingParents + _path.substring(1);
}
this._parts.path = _path;
this.build(!build);
return this;
};
p.normalizePathname = p.normalizePath;
p.normalizeQuery = function(build) {
if (typeof this._parts.query === "string") {
if (!this._parts.query.length) {
this._parts.query = null;
} else {
this.query(URI.parseQuery(this._parts.query, this._parts.escapeQuerySpace));
}
this.build(!build);
}
return this;
};
p.normalizeFragment = function(build) {
if (!this._parts.fragment) {
this._parts.fragment = null;
this.build(!build);
}
return this;
};
p.normalizeSearch = p.normalizeQuery;
p.normalizeHash = p.normalizeFragment;
p.iso8859 = function() {
var e = URI.encode;
var d = URI.decode;
URI.encode = escape;
URI.decode = decodeURIComponent;
try {
this.normalize();
} finally {
URI.encode = e;
URI.decode = d;
}
return this;
};
p.unicode = function() {
var e = URI.encode;
var d = URI.decode;
URI.encode = strictEncodeURIComponent;
URI.decode = unescape;
try {
this.normalize();
} finally {
URI.encode = e;
URI.decode = d;
}
return this;
};
p.readable = function() {
var uri = this.clone();
uri.username("").password("").normalize();
var t = "";
if (uri._parts.protocol) {
t += uri._parts.protocol + "://";
}
if (uri._parts.hostname) {
if (uri.is("punycode") && punycode) {
t += punycode.toUnicode(uri._parts.hostname);
if (uri._parts.port) {
t += ":" + uri._parts.port;
}
} else {
t += uri.host();
}
}
if (uri._parts.hostname && uri._parts.path && uri._parts.path.charAt(0) !== "/") {
t += "/";
}
t += uri.path(true);
if (uri._parts.query) {
var q3 = "";
for (var i = 0, qp = uri._parts.query.split("&"), l = qp.length; i < l; i++) {
var kv = (qp[i] || "").split("=");
q3 += "&" + URI.decodeQuery(kv[0], this._parts.escapeQuerySpace).replace(/&/g, "%26");
if (kv[1] !== void 0) {
q3 += "=" + URI.decodeQuery(kv[1], this._parts.escapeQuerySpace).replace(/&/g, "%26");
}
}
t += "?" + q3.substring(1);
}
t += URI.decodeQuery(uri.hash(), true);
return t;
};
p.absoluteTo = function(base) {
var resolved = this.clone();
var properties = ["protocol", "username", "password", "hostname", "port"];
var basedir, i, p2;
if (this._parts.urn) {
throw new Error("URNs do not have any generally defined hierarchical components");
}
if (!(base instanceof URI)) {
base = new URI(base);
}
if (resolved._parts.protocol) {
return resolved;
} else {
resolved._parts.protocol = base._parts.protocol;
}
if (this._parts.hostname) {
return resolved;
}
for (i = 0; p2 = properties[i]; i++) {
resolved._parts[p2] = base._parts[p2];
}
if (!resolved._parts.path) {
resolved._parts.path = base._parts.path;
if (!resolved._parts.query) {
resolved._parts.query = base._parts.query;
}
} else {
if (resolved._parts.path.substring(-2) === "..") {
resolved._parts.path += "/";
}
if (resolved.path().charAt(0) !== "/") {
basedir = base.directory();
basedir = basedir ? basedir : base.path().indexOf("/") === 0 ? "/" : "";
resolved._parts.path = (basedir ? basedir + "/" : "") + resolved._parts.path;
resolved.normalizePath();
}
}
resolved.build();
return resolved;
};
p.relativeTo = function(base) {
var relative = this.clone().normalize();
var relativeParts, baseParts, common, relativePath, basePath;
if (relative._parts.urn) {
throw new Error("URNs do not have any generally defined hierarchical components");
}
base = new URI(base).normalize();
relativeParts = relative._parts;
baseParts = base._parts;
relativePath = relative.path();
basePath = base.path();
if (relativePath.charAt(0) !== "/") {
throw new Error("URI is already relative");
}
if (basePath.charAt(0) !== "/") {
throw new Error("Cannot calculate a URI relative to another relative URI");
}
if (relativeParts.protocol === baseParts.protocol) {
relativeParts.protocol = null;
}
if (relativeParts.username !== baseParts.username || relativeParts.password !== baseParts.password) {
return relative.build();
}
if (relativeParts.protocol !== null || relativeParts.username !== null || relativeParts.password !== null) {
return relative.build();
}
if (relativeParts.hostname === baseParts.hostname && relativeParts.port === baseParts.port) {
relativeParts.hostname = null;
relativeParts.port = null;
} else {
return relative.build();
}
if (relativePath === basePath) {
relativeParts.path = "";
return relative.build();
}
common = URI.commonPath(relativePath, basePath);
if (!common) {
return relative.build();
}
var parents = baseParts.path.substring(common.length).replace(/[^\/]*$/, "").replace(/.*?\//g, "../");
relativeParts.path = parents + relativeParts.path.substring(common.length) || "./";
return relative.build();
};
p.equals = function(uri) {
var one = this.clone();
var two = new URI(uri);
var one_map = {};
var two_map = {};
var checked = {};
var one_query, two_query, key;
one.normalize();
two.normalize();
if (one.toString() === two.toString()) {
return true;
}
one_query = one.query();
two_query = two.query();
one.query("");
two.query("");
if (one.toString() !== two.toString()) {
return false;
}
if (one_query.length !== two_query.length) {
return false;
}
one_map = URI.parseQuery(one_query, this._parts.escapeQuerySpace);
two_map = URI.parseQuery(two_query, this._parts.escapeQuerySpace);
for (key in one_map) {
if (hasOwn.call(one_map, key)) {
if (!isArray(one_map[key])) {
if (one_map[key] !== two_map[key]) {
return false;
}
} else if (!arraysEqual(one_map[key], two_map[key])) {
return false;
}
checked[key] = true;
}
}
for (key in two_map) {
if (hasOwn.call(two_map, key)) {
if (!checked[key]) {
return false;
}
}
}
return true;
};
p.preventInvalidHostname = function(v7) {
this._parts.preventInvalidHostname = !!v7;
return this;
};
p.duplicateQueryParameters = function(v7) {
this._parts.duplicateQueryParameters = !!v7;
return this;
};
p.escapeQuerySpace = function(v7) {
this._parts.escapeQuerySpace = !!v7;
return this;
};
return URI;
});
}
});
// node_modules/dompurify/dist/purify.cjs.js
var require_purify_cjs = __commonJS({
"node_modules/dompurify/dist/purify.cjs.js"(exports2, module2) {
"use strict";
/*! @license DOMPurify 2.3.10 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/2.3.10/LICENSE */
function _typeof(obj) {
"@babel/helpers - typeof";
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(obj2) {
return typeof obj2;
} : function(obj2) {
return obj2 && "function" == typeof Symbol && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
}, _typeof(obj);
}
function _setPrototypeOf(o, p) {
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf2(o2, p2) {
o2.__proto__ = p2;
return o2;
};
return _setPrototypeOf(o, p);
}
function _isNativeReflectConstruct() {
if (typeof Reflect === "undefined" || !Reflect.construct)
return false;
if (Reflect.construct.sham)
return false;
if (typeof Proxy === "function")
return true;
try {
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
}));
return true;
} catch (e) {
return false;
}
}
function _construct(Parent, args, Class) {
if (_isNativeReflectConstruct()) {
_construct = Reflect.construct;
} else {
_construct = function _construct2(Parent2, args2, Class2) {
var a3 = [null];
a3.push.apply(a3, args2);
var Constructor = Function.bind.apply(Parent2, a3);
var instance = new Constructor();
if (Class2)
_setPrototypeOf(instance, Class2.prototype);
return instance;
};
}
return _construct.apply(null, arguments);
}
function _toConsumableArray(arr) {
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
}
function _arrayWithoutHoles(arr) {
if (Array.isArray(arr))
return _arrayLikeToArray(arr);
}
function _iterableToArray(iter) {
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null)
return Array.from(iter);
}
function _unsupportedIterableToArray(o, minLen) {
if (!o)
return;
if (typeof o === "string")
return _arrayLikeToArray(o, minLen);
var n = Object.prototype.toString.call(o).slice(8, -1);
if (n === "Object" && o.constructor)
n = o.constructor.name;
if (n === "Map" || n === "Set")
return Array.from(o);
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
return _arrayLikeToArray(o, minLen);
}
function _arrayLikeToArray(arr, len) {
if (len == null || len > arr.length)
len = arr.length;
for (var i = 0, arr2 = new Array(len); i < len; i++)
arr2[i] = arr[i];
return arr2;
}
function _nonIterableSpread() {
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
var hasOwnProperty = Object.hasOwnProperty;
var setPrototypeOf = Object.setPrototypeOf;
var isFrozen = Object.isFrozen;
var getPrototypeOf = Object.getPrototypeOf;
var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
var freeze = Object.freeze;
var seal = Object.seal;
var create = Object.create;
var _ref = typeof Reflect !== "undefined" && Reflect;
var apply = _ref.apply;
var construct = _ref.construct;
if (!apply) {
apply = function apply2(fun, thisValue, args) {
return fun.apply(thisValue, args);
};
}
if (!freeze) {
freeze = function freeze2(x) {
return x;
};
}
if (!seal) {
seal = function seal2(x) {
return x;
};
}
if (!construct) {
construct = function construct2(Func, args) {
return _construct(Func, _toConsumableArray(args));
};
}
var arrayForEach = unapply(Array.prototype.forEach);
var arrayPop = unapply(Array.prototype.pop);
var arrayPush = unapply(Array.prototype.push);
var stringToLowerCase = unapply(String.prototype.toLowerCase);
var stringMatch = unapply(String.prototype.match);
var stringReplace = unapply(String.prototype.replace);
var stringIndexOf = unapply(String.prototype.indexOf);
var stringTrim = unapply(String.prototype.trim);
var regExpTest = unapply(RegExp.prototype.test);
var typeErrorCreate = unconstruct(TypeError);
function unapply(func) {
return function(thisArg) {
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}
return apply(func, thisArg, args);
};
}
function unconstruct(func) {
return function() {
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
args[_key2] = arguments[_key2];
}
return construct(func, args);
};
}
function addToSet(set2, array, transformCaseFunc) {
transformCaseFunc = transformCaseFunc ? transformCaseFunc : stringToLowerCase;
if (setPrototypeOf) {
setPrototypeOf(set2, null);
}
var l = array.length;
while (l--) {
var element = array[l];
if (typeof element === "string") {
var lcElement = transformCaseFunc(element);
if (lcElement !== element) {
if (!isFrozen(array)) {
array[l] = lcElement;
}
element = lcElement;
}
}
set2[element] = true;
}
return set2;
}
function clone2(object) {
var newObject = create(null);
var property;
for (property in object) {
if (apply(hasOwnProperty, object, [property])) {
newObject[property] = object[property];
}
}
return newObject;
}
function lookupGetter(object, prop) {
while (object !== null) {
var desc = getOwnPropertyDescriptor(object, prop);
if (desc) {
if (desc.get) {
return unapply(desc.get);
}
if (typeof desc.value === "function") {
return unapply(desc.value);
}
}
object = getPrototypeOf(object);
}
function fallbackValue(element) {
console.warn("fallback value for", element);
return null;
}
return fallbackValue;
}
var html$1 = freeze(["a", "abbr", "acronym", "address", "area", "article", "aside", "audio", "b", "bdi", "bdo", "big", "blink", "blockquote", "body", "br", "button", "canvas", "caption", "center", "cite", "code", "col", "colgroup", "content", "data", "datalist", "dd", "decorator", "del", "details", "dfn", "dialog", "dir", "div", "dl", "dt", "element", "em", "fieldset", "figcaption", "figure", "font", "footer", "form", "h1", "h2", "h3", "h4", "h5", "h6", "head", "header", "hgroup", "hr", "html", "i", "img", "input", "ins", "kbd", "label", "legend", "li", "main", "map", "mark", "marquee", "menu", "menuitem", "meter", "nav", "nobr", "ol", "optgroup", "option", "output", "p", "picture", "pre", "progress", "q", "rp", "rt", "ruby", "s", "samp", "section", "select", "shadow", "small", "source", "spacer", "span", "strike", "strong", "style", "sub", "summary", "sup", "table", "tbody", "td", "template", "textarea", "tfoot", "th", "thead", "time", "tr", "track", "tt", "u", "ul", "var", "video", "wbr"]);
var svg$1 = freeze(["svg", "a", "altglyph", "altglyphdef", "altglyphitem", "animatecolor", "animatemotion", "animatetransform", "circle", "clippath", "defs", "desc", "ellipse", "filter", "font", "g", "glyph", "glyphref", "hkern", "image", "line", "lineargradient", "marker", "mask", "metadata", "mpath", "path", "pattern", "polygon", "polyline", "radialgradient", "rect", "stop", "style", "switch", "symbol", "text", "textpath", "title", "tref", "tspan", "view", "vkern"]);
var svgFilters = freeze(["feBlend", "feColorMatrix", "feComponentTransfer", "feComposite", "feConvolveMatrix", "feDiffuseLighting", "feDisplacementMap", "feDistantLight", "feFlood", "feFuncA", "feFuncB", "feFuncG", "feFuncR", "feGaussianBlur", "feImage", "feMerge", "feMergeNode", "feMorphology", "feOffset", "fePointLight", "feSpecularLighting", "feSpotLight", "feTile", "feTurbulence"]);
var svgDisallowed = freeze(["animate", "color-profile", "cursor", "discard", "fedropshadow", "font-face", "font-face-format", "font-face-name", "font-face-src", "font-face-uri", "foreignobject", "hatch", "hatchpath", "mesh", "meshgradient", "meshpatch", "meshrow", "missing-glyph", "script", "set", "solidcolor", "unknown", "use"]);
var mathMl$1 = freeze(["math", "menclose", "merror", "mfenced", "mfrac", "mglyph", "mi", "mlabeledtr", "mmultiscripts", "mn", "mo", "mover", "mpadded", "mphantom", "mroot", "mrow", "ms", "mspace", "msqrt", "mstyle", "msub", "msup", "msubsup", "mtable", "mtd", "mtext", "mtr", "munder", "munderover"]);
var mathMlDisallowed = freeze(["maction", "maligngroup", "malignmark", "mlongdiv", "mscarries", "mscarry", "msgroup", "mstack", "msline", "msrow", "semantics", "annotation", "annotation-xml", "mprescripts", "none"]);
var text = freeze(["#text"]);
var html = freeze(["accept", "action", "align", "alt", "autocapitalize", "autocomplete", "autopictureinpicture", "autoplay", "background", "bgcolor", "border", "capture", "cellpadding", "cellspacing", "checked", "cite", "class", "clear", "color", "cols", "colspan", "controls", "controlslist", "coords", "crossorigin", "datetime", "decoding", "default", "dir", "disabled", "disablepictureinpicture", "disableremoteplayback", "download", "draggable", "enctype", "enterkeyhint", "face", "for", "headers", "height", "hidden", "high", "href", "hreflang", "id", "inputmode", "integrity", "ismap", "kind", "label", "lang", "list", "loading", "loop", "low", "max", "maxlength", "media", "method", "min", "minlength", "multiple", "muted", "name", "nonce", "noshade", "novalidate", "nowrap", "open", "optimum", "pattern", "placeholder", "playsinline", "poster", "preload", "pubdate", "radiogroup", "readonly", "rel", "required", "rev", "reversed", "role", "rows", "rowspan", "spellcheck", "scope", "selected", "shape", "size", "sizes", "span", "srclang", "start", "src", "srcset", "step", "style", "summary", "tabindex", "title", "translate", "type", "usemap", "valign", "value", "width", "xmlns", "slot"]);
var svg = freeze(["accent-height", "accumulate", "additive", "alignment-baseline", "ascent", "attributename", "attributetype", "azimuth", "basefrequency", "baseline-shift", "begin", "bias", "by", "class", "clip", "clippathunits", "clip-path", "clip-rule", "color", "color-interpolation", "color-interpolation-filters", "color-profile", "color-rendering", "cx", "cy", "d", "dx", "dy", "diffuseconstant", "direction", "display", "divisor", "dur", "edgemode", "elevation", "end", "fill", "fill-opacity", "fill-rule", "filter", "filterunits", "flood-color", "flood-opacity", "font-family", "font-size", "font-size-adjust", "font-stretch", "font-style", "font-variant", "font-weight", "fx", "fy", "g1", "g2", "glyph-name", "glyphref", "gradientunits", "gradienttransform", "height", "href", "id", "image-rendering", "in", "in2", "k", "k1", "k2", "k3", "k4", "kerning", "keypoints", "keysplines", "keytimes", "lang", "lengthadjust", "letter-spacing", "kernelmatrix", "kernelunitlength", "lighting-color", "local", "marker-end", "marker-mid", "marker-start", "markerheight", "markerunits", "markerwidth", "maskcontentunits", "maskunits", "max", "mask", "media", "method", "mode", "min", "name", "numoctaves", "offset", "operator", "opacity", "order", "orient", "orientation", "origin", "overflow", "paint-order", "path", "pathlength", "patterncontentunits", "patterntransform", "patternunits", "points", "preservealpha", "preserveaspectratio", "primitiveunits", "r", "rx", "ry", "radius", "refx", "refy", "repeatcount", "repeatdur", "restart", "result", "rotate", "scale", "seed", "shape-rendering", "specularconstant", "specularexponent", "spreadmethod", "startoffset", "stddeviation", "stitchtiles", "stop-color", "stop-opacity", "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin", "stroke-miterlimit", "stroke-opacity", "stroke", "stroke-width", "style", "surfacescale", "systemlanguage", "tabindex", "targetx", "targety", "transform", "transform-origin", "text-anchor", "text-decoration", "text-rendering", "textlength", "type", "u1", "u2", "unicode", "values", "viewbox", "visibility", "version", "vert-adv-y", "vert-origin-x", "vert-origin-y", "width", "word-spacing", "wrap", "writing-mode", "xchannelselector", "ychannelselector", "x", "x1", "x2", "xmlns", "y", "y1", "y2", "z", "zoomandpan"]);
var mathMl = freeze(["accent", "accentunder", "align", "bevelled", "close", "columnsalign", "columnlines", "columnspan", "denomalign", "depth", "dir", "display", "displaystyle", "encoding", "fence", "frame", "height", "href", "id", "largeop", "length", "linethickness", "lspace", "lquote", "mathbackground", "mathcolor", "mathsize", "mathvariant", "maxsize", "minsize", "movablelimits", "notation", "numalign", "open", "rowalign", "rowlines", "rowspacing", "rowspan", "rspace", "rquote", "scriptlevel", "scriptminsize", "scriptsizemultiplier", "selection", "separator", "separators", "stretchy", "subscriptshift", "supscriptshift", "symmetric", "voffset", "width", "xmlns"]);
var xml = freeze(["xlink:href", "xml:id", "xlink:title", "xml:space", "xmlns:xlink"]);
var MUSTACHE_EXPR = seal(/\{\{[\w\W]*|[\w\W]*\}\}/gm);
var ERB_EXPR = seal(/<%[\w\W]*|[\w\W]*%>/gm);
var DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]/);
var ARIA_ATTR = seal(/^aria-[\-\w]+$/);
var IS_ALLOWED_URI = seal(
/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i
);
var IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i);
var ATTR_WHITESPACE = seal(
/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g
);
var DOCTYPE_NAME = seal(/^html$/i);
var getGlobal = function getGlobal2() {
return typeof window === "undefined" ? null : window;
};
var _createTrustedTypesPolicy = function _createTrustedTypesPolicy2(trustedTypes, document2) {
if (_typeof(trustedTypes) !== "object" || typeof trustedTypes.createPolicy !== "function") {
return null;
}
var suffix = null;
var ATTR_NAME = "data-tt-policy-suffix";
if (document2.currentScript && document2.currentScript.hasAttribute(ATTR_NAME)) {
suffix = document2.currentScript.getAttribute(ATTR_NAME);
}
var policyName = "dompurify" + (suffix ? "#" + suffix : "");
try {
return trustedTypes.createPolicy(policyName, {
createHTML: function createHTML(html2) {
return html2;
},
createScriptURL: function createScriptURL(scriptUrl) {
return scriptUrl;
}
});
} catch (_) {
console.warn("TrustedTypes policy " + policyName + " could not be created.");
return null;
}
};
function createDOMPurify() {
var window2 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : getGlobal();
var DOMPurify = function DOMPurify2(root) {
return createDOMPurify(root);
};
DOMPurify.version = "2.3.10";
DOMPurify.removed = [];
if (!window2 || !window2.document || window2.document.nodeType !== 9) {
DOMPurify.isSupported = false;
return DOMPurify;
}
var originalDocument = window2.document;
var document2 = window2.document;
var DocumentFragment2 = window2.DocumentFragment, HTMLTemplateElement = window2.HTMLTemplateElement, Node6 = window2.Node, Element2 = window2.Element, NodeFilter = window2.NodeFilter, _window$NamedNodeMap = window2.NamedNodeMap, NamedNodeMap = _window$NamedNodeMap === void 0 ? window2.NamedNodeMap || window2.MozNamedAttrMap : _window$NamedNodeMap, HTMLFormElement = window2.HTMLFormElement, DOMParser2 = window2.DOMParser, trustedTypes = window2.trustedTypes;
var ElementPrototype = Element2.prototype;
var cloneNode = lookupGetter(ElementPrototype, "cloneNode");
var getNextSibling = lookupGetter(ElementPrototype, "nextSibling");
var getChildNodes = lookupGetter(ElementPrototype, "childNodes");
var getParentNode = lookupGetter(ElementPrototype, "parentNode");
if (typeof HTMLTemplateElement === "function") {
var template = document2.createElement("template");
if (template.content && template.content.ownerDocument) {
document2 = template.content.ownerDocument;
}
}
var trustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, originalDocument);
var emptyHTML = trustedTypesPolicy ? trustedTypesPolicy.createHTML("") : "";
var _document = document2, implementation4 = _document.implementation, createNodeIterator = _document.createNodeIterator, createDocumentFragment = _document.createDocumentFragment, getElementsByTagName = _document.getElementsByTagName;
var importNode = originalDocument.importNode;
var documentMode = {};
try {
documentMode = clone2(document2).documentMode ? document2.documentMode : {};
} catch (_) {
}
var hooks = {};
DOMPurify.isSupported = typeof getParentNode === "function" && implementation4 && typeof implementation4.createHTMLDocument !== "undefined" && documentMode !== 9;
var MUSTACHE_EXPR$1 = MUSTACHE_EXPR, ERB_EXPR$1 = ERB_EXPR, DATA_ATTR$1 = DATA_ATTR, ARIA_ATTR$1 = ARIA_ATTR, IS_SCRIPT_OR_DATA$1 = IS_SCRIPT_OR_DATA, ATTR_WHITESPACE$1 = ATTR_WHITESPACE;
var IS_ALLOWED_URI$1 = IS_ALLOWED_URI;
var ALLOWED_TAGS = null;
var DEFAULT_ALLOWED_TAGS = addToSet({}, [].concat(_toConsumableArray(html$1), _toConsumableArray(svg$1), _toConsumableArray(svgFilters), _toConsumableArray(mathMl$1), _toConsumableArray(text)));
var ALLOWED_ATTR = null;
var DEFAULT_ALLOWED_ATTR = addToSet({}, [].concat(_toConsumableArray(html), _toConsumableArray(svg), _toConsumableArray(mathMl), _toConsumableArray(xml)));
var CUSTOM_ELEMENT_HANDLING = Object.seal(Object.create(null, {
tagNameCheck: {
writable: true,
configurable: false,
enumerable: true,
value: null
},
attributeNameCheck: {
writable: true,
configurable: false,
enumerable: true,
value: null
},
allowCustomizedBuiltInElements: {
writable: true,
configurable: false,
enumerable: true,
value: false
}
}));
var FORBID_TAGS = null;
var FORBID_ATTR = null;
var ALLOW_ARIA_ATTR = true;
var ALLOW_DATA_ATTR = true;
var ALLOW_UNKNOWN_PROTOCOLS = false;
var SAFE_FOR_TEMPLATES = false;
var WHOLE_DOCUMENT = false;
var SET_CONFIG = false;
var FORCE_BODY = false;
var RETURN_DOM = false;
var RETURN_DOM_FRAGMENT = false;
var RETURN_TRUSTED_TYPE = false;
var SANITIZE_DOM = true;
var KEEP_CONTENT = true;
var IN_PLACE = false;
var USE_PROFILES = {};
var FORBID_CONTENTS = null;
var DEFAULT_FORBID_CONTENTS = addToSet({}, ["annotation-xml", "audio", "colgroup", "desc", "foreignobject", "head", "iframe", "math", "mi", "mn", "mo", "ms", "mtext", "noembed", "noframes", "noscript", "plaintext", "script", "style", "svg", "template", "thead", "title", "video", "xmp"]);
var DATA_URI_TAGS = null;
var DEFAULT_DATA_URI_TAGS = addToSet({}, ["audio", "video", "img", "source", "image", "track"]);
var URI_SAFE_ATTRIBUTES = null;
var DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, ["alt", "class", "for", "id", "label", "name", "pattern", "placeholder", "role", "summary", "title", "value", "style", "xmlns"]);
var MATHML_NAMESPACE = "http://www.w3.org/1998/Math/MathML";
var SVG_NAMESPACE = "http://www.w3.org/2000/svg";
var HTML_NAMESPACE = "http://www.w3.org/1999/xhtml";
var NAMESPACE = HTML_NAMESPACE;
var IS_EMPTY_INPUT = false;
var PARSER_MEDIA_TYPE;
var SUPPORTED_PARSER_MEDIA_TYPES = ["application/xhtml+xml", "text/html"];
var DEFAULT_PARSER_MEDIA_TYPE = "text/html";
var transformCaseFunc;
var CONFIG = null;
var formElement = document2.createElement("form");
var isRegexOrFunction = function isRegexOrFunction2(testValue) {
return testValue instanceof RegExp || testValue instanceof Function;
};
var _parseConfig = function _parseConfig2(cfg) {
if (CONFIG && CONFIG === cfg) {
return;
}
if (!cfg || _typeof(cfg) !== "object") {
cfg = {};
}
cfg = clone2(cfg);
PARSER_MEDIA_TYPE = SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? PARSER_MEDIA_TYPE = DEFAULT_PARSER_MEDIA_TYPE : PARSER_MEDIA_TYPE = cfg.PARSER_MEDIA_TYPE;
transformCaseFunc = PARSER_MEDIA_TYPE === "application/xhtml+xml" ? function(x) {
return x;
} : stringToLowerCase;
ALLOWED_TAGS = "ALLOWED_TAGS" in cfg ? addToSet({}, cfg.ALLOWED_TAGS, transformCaseFunc) : DEFAULT_ALLOWED_TAGS;
ALLOWED_ATTR = "ALLOWED_ATTR" in cfg ? addToSet({}, cfg.ALLOWED_ATTR, transformCaseFunc) : DEFAULT_ALLOWED_ATTR;
URI_SAFE_ATTRIBUTES = "ADD_URI_SAFE_ATTR" in cfg ? addToSet(
clone2(DEFAULT_URI_SAFE_ATTRIBUTES),
cfg.ADD_URI_SAFE_ATTR,
transformCaseFunc
) : DEFAULT_URI_SAFE_ATTRIBUTES;
DATA_URI_TAGS = "ADD_DATA_URI_TAGS" in cfg ? addToSet(
clone2(DEFAULT_DATA_URI_TAGS),
cfg.ADD_DATA_URI_TAGS,
transformCaseFunc
) : DEFAULT_DATA_URI_TAGS;
FORBID_CONTENTS = "FORBID_CONTENTS" in cfg ? addToSet({}, cfg.FORBID_CONTENTS, transformCaseFunc) : DEFAULT_FORBID_CONTENTS;
FORBID_TAGS = "FORBID_TAGS" in cfg ? addToSet({}, cfg.FORBID_TAGS, transformCaseFunc) : {};
FORBID_ATTR = "FORBID_ATTR" in cfg ? addToSet({}, cfg.FORBID_ATTR, transformCaseFunc) : {};
USE_PROFILES = "USE_PROFILES" in cfg ? cfg.USE_PROFILES : false;
ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false;
ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false;
ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false;
SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false;
WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false;
RETURN_DOM = cfg.RETURN_DOM || false;
RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false;
RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false;
FORCE_BODY = cfg.FORCE_BODY || false;
SANITIZE_DOM = cfg.SANITIZE_DOM !== false;
KEEP_CONTENT = cfg.KEEP_CONTENT !== false;
IN_PLACE = cfg.IN_PLACE || false;
IS_ALLOWED_URI$1 = cfg.ALLOWED_URI_REGEXP || IS_ALLOWED_URI$1;
NAMESPACE = cfg.NAMESPACE || HTML_NAMESPACE;
if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck)) {
CUSTOM_ELEMENT_HANDLING.tagNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck;
}
if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)) {
CUSTOM_ELEMENT_HANDLING.attributeNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck;
}
if (cfg.CUSTOM_ELEMENT_HANDLING && typeof cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements === "boolean") {
CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements = cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements;
}
if (SAFE_FOR_TEMPLATES) {
ALLOW_DATA_ATTR = false;
}
if (RETURN_DOM_FRAGMENT) {
RETURN_DOM = true;
}
if (USE_PROFILES) {
ALLOWED_TAGS = addToSet({}, _toConsumableArray(text));
ALLOWED_ATTR = [];
if (USE_PROFILES.html === true) {
addToSet(ALLOWED_TAGS, html$1);
addToSet(ALLOWED_ATTR, html);
}
if (USE_PROFILES.svg === true) {
addToSet(ALLOWED_TAGS, svg$1);
addToSet(ALLOWED_ATTR, svg);
addToSet(ALLOWED_ATTR, xml);
}
if (USE_PROFILES.svgFilters === true) {
addToSet(ALLOWED_TAGS, svgFilters);
addToSet(ALLOWED_ATTR, svg);
addToSet(ALLOWED_ATTR, xml);
}
if (USE_PROFILES.mathMl === true) {
addToSet(ALLOWED_TAGS, mathMl$1);
addToSet(ALLOWED_ATTR, mathMl);
addToSet(ALLOWED_ATTR, xml);
}
}
if (cfg.ADD_TAGS) {
if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) {
ALLOWED_TAGS = clone2(ALLOWED_TAGS);
}
addToSet(ALLOWED_TAGS, cfg.ADD_TAGS, transformCaseFunc);
}
if (cfg.ADD_ATTR) {
if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) {
ALLOWED_ATTR = clone2(ALLOWED_ATTR);
}
addToSet(ALLOWED_ATTR, cfg.ADD_ATTR, transformCaseFunc);
}
if (cfg.ADD_URI_SAFE_ATTR) {
addToSet(URI_SAFE_ATTRIBUTES, cfg.ADD_URI_SAFE_ATTR, transformCaseFunc);
}
if (cfg.FORBID_CONTENTS) {
if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
FORBID_CONTENTS = clone2(FORBID_CONTENTS);
}
addToSet(FORBID_CONTENTS, cfg.FORBID_CONTENTS, transformCaseFunc);
}
if (KEEP_CONTENT) {
ALLOWED_TAGS["#text"] = true;
}
if (WHOLE_DOCUMENT) {
addToSet(ALLOWED_TAGS, ["html", "head", "body"]);
}
if (ALLOWED_TAGS.table) {
addToSet(ALLOWED_TAGS, ["tbody"]);
delete FORBID_TAGS.tbody;
}
if (freeze) {
freeze(cfg);
}
CONFIG = cfg;
};
var MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, ["mi", "mo", "mn", "ms", "mtext"]);
var HTML_INTEGRATION_POINTS = addToSet({}, ["foreignobject", "desc", "title", "annotation-xml"]);
var COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, ["title", "style", "font", "a", "script"]);
var ALL_SVG_TAGS = addToSet({}, svg$1);
addToSet(ALL_SVG_TAGS, svgFilters);
addToSet(ALL_SVG_TAGS, svgDisallowed);
var ALL_MATHML_TAGS = addToSet({}, mathMl$1);
addToSet(ALL_MATHML_TAGS, mathMlDisallowed);
var _checkValidNamespace = function _checkValidNamespace2(element) {
var parent = getParentNode(element);
if (!parent || !parent.tagName) {
parent = {
namespaceURI: HTML_NAMESPACE,
tagName: "template"
};
}
var tagName = stringToLowerCase(element.tagName);
var parentTagName = stringToLowerCase(parent.tagName);
if (element.namespaceURI === SVG_NAMESPACE) {
if (parent.namespaceURI === HTML_NAMESPACE) {
return tagName === "svg";
}
if (parent.namespaceURI === MATHML_NAMESPACE) {
return tagName === "svg" && (parentTagName === "annotation-xml" || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);
}
return Boolean(ALL_SVG_TAGS[tagName]);
}
if (element.namespaceURI === MATHML_NAMESPACE) {
if (parent.namespaceURI === HTML_NAMESPACE) {
return tagName === "math";
}
if (parent.namespaceURI === SVG_NAMESPACE) {
return tagName === "math" && HTML_INTEGRATION_POINTS[parentTagName];
}
return Boolean(ALL_MATHML_TAGS[tagName]);
}
if (element.namespaceURI === HTML_NAMESPACE) {
if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) {
return false;
}
if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) {
return false;
}
return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]);
}
return false;
};
var _forceRemove = function _forceRemove2(node) {
arrayPush(DOMPurify.removed, {
element: node
});
try {
node.parentNode.removeChild(node);
} catch (_) {
try {
node.outerHTML = emptyHTML;
} catch (_2) {
node.remove();
}
}
};
var _removeAttribute = function _removeAttribute2(name, node) {
try {
arrayPush(DOMPurify.removed, {
attribute: node.getAttributeNode(name),
from: node
});
} catch (_) {
arrayPush(DOMPurify.removed, {
attribute: null,
from: node
});
}
node.removeAttribute(name);
if (name === "is" && !ALLOWED_ATTR[name]) {
if (RETURN_DOM || RETURN_DOM_FRAGMENT) {
try {
_forceRemove(node);
} catch (_) {
}
} else {
try {
node.setAttribute(name, "");
} catch (_) {
}
}
}
};
var _initDocument = function _initDocument2(dirty) {
var doc;
var leadingWhitespace;
if (FORCE_BODY) {
dirty = "" + dirty;
} else {
var matches = stringMatch(dirty, /^[\r\n\t ]+/);
leadingWhitespace = matches && matches[0];
}
if (PARSER_MEDIA_TYPE === "application/xhtml+xml") {
dirty = '
' + dirty + "";
}
var dirtyPayload = trustedTypesPolicy ? trustedTypesPolicy.createHTML(dirty) : dirty;
if (NAMESPACE === HTML_NAMESPACE) {
try {
doc = new DOMParser2().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE);
} catch (_) {
}
}
if (!doc || !doc.documentElement) {
doc = implementation4.createDocument(NAMESPACE, "template", null);
try {
doc.documentElement.innerHTML = IS_EMPTY_INPUT ? "" : dirtyPayload;
} catch (_) {
}
}
var body = doc.body || doc.documentElement;
if (dirty && leadingWhitespace) {
body.insertBefore(document2.createTextNode(leadingWhitespace), body.childNodes[0] || null);
}
if (NAMESPACE === HTML_NAMESPACE) {
return getElementsByTagName.call(doc, WHOLE_DOCUMENT ? "html" : "body")[0];
}
return WHOLE_DOCUMENT ? doc.documentElement : body;
};
var _createIterator = function _createIterator2(root) {
return createNodeIterator.call(
root.ownerDocument || root,
root,
NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT,
null,
false
);
};
var _isClobbered = function _isClobbered2(elm) {
return elm instanceof HTMLFormElement && (typeof elm.nodeName !== "string" || typeof elm.textContent !== "string" || typeof elm.removeChild !== "function" || !(elm.attributes instanceof NamedNodeMap) || typeof elm.removeAttribute !== "function" || typeof elm.setAttribute !== "function" || typeof elm.namespaceURI !== "string" || typeof elm.insertBefore !== "function");
};
var _isNode = function _isNode2(object) {
return _typeof(Node6) === "object" ? object instanceof Node6 : object && _typeof(object) === "object" && typeof object.nodeType === "number" && typeof object.nodeName === "string";
};
var _executeHook = function _executeHook2(entryPoint, currentNode, data) {
if (!hooks[entryPoint]) {
return;
}
arrayForEach(hooks[entryPoint], function(hook) {
hook.call(DOMPurify, currentNode, data, CONFIG);
});
};
var _sanitizeElements = function _sanitizeElements2(currentNode) {
var content;
_executeHook("beforeSanitizeElements", currentNode, null);
if (_isClobbered(currentNode)) {
_forceRemove(currentNode);
return true;
}
if (regExpTest(/[\u0080-\uFFFF]/, currentNode.nodeName)) {
_forceRemove(currentNode);
return true;
}
var tagName = transformCaseFunc(currentNode.nodeName);
_executeHook("uponSanitizeElement", currentNode, {
tagName,
allowedTags: ALLOWED_TAGS
});
if (currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && (!_isNode(currentNode.content) || !_isNode(currentNode.content.firstElementChild)) && regExpTest(/<[/\w]/g, currentNode.innerHTML) && regExpTest(/<[/\w]/g, currentNode.textContent)) {
_forceRemove(currentNode);
return true;
}
if (tagName === "select" && regExpTest(/= 0; --i) {
parentNode.insertBefore(cloneNode(childNodes[i], true), getNextSibling(currentNode));
}
}
}
_forceRemove(currentNode);
return true;
}
if (currentNode instanceof Element2 && !_checkValidNamespace(currentNode)) {
_forceRemove(currentNode);
return true;
}
if ((tagName === "noscript" || tagName === "noembed") && regExpTest(/<\/no(script|embed)/i, currentNode.innerHTML)) {
_forceRemove(currentNode);
return true;
}
if (SAFE_FOR_TEMPLATES && currentNode.nodeType === 3) {
content = currentNode.textContent;
content = stringReplace(content, MUSTACHE_EXPR$1, " ");
content = stringReplace(content, ERB_EXPR$1, " ");
if (currentNode.textContent !== content) {
arrayPush(DOMPurify.removed, {
element: currentNode.cloneNode()
});
currentNode.textContent = content;
}
}
_executeHook("afterSanitizeElements", currentNode, null);
return false;
};
var _isValidAttribute = function _isValidAttribute2(lcTag, lcName, value) {
if (SANITIZE_DOM && (lcName === "id" || lcName === "name") && (value in document2 || value in formElement)) {
return false;
}
if (ALLOW_DATA_ATTR && !FORBID_ATTR[lcName] && regExpTest(DATA_ATTR$1, lcName))
;
else if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR$1, lcName))
;
else if (!ALLOWED_ATTR[lcName] || FORBID_ATTR[lcName]) {
if (_basicCustomElementTest(lcTag) && (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, lcTag) || CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(lcTag)) && (CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.attributeNameCheck, lcName) || CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.attributeNameCheck(lcName)) || lcName === "is" && CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements && (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, value) || CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(value)))
;
else {
return false;
}
} else if (URI_SAFE_ATTRIBUTES[lcName])
;
else if (regExpTest(IS_ALLOWED_URI$1, stringReplace(value, ATTR_WHITESPACE$1, "")))
;
else if ((lcName === "src" || lcName === "xlink:href" || lcName === "href") && lcTag !== "script" && stringIndexOf(value, "data:") === 0 && DATA_URI_TAGS[lcTag])
;
else if (ALLOW_UNKNOWN_PROTOCOLS && !regExpTest(IS_SCRIPT_OR_DATA$1, stringReplace(value, ATTR_WHITESPACE$1, "")))
;
else if (!value)
;
else {
return false;
}
return true;
};
var _basicCustomElementTest = function _basicCustomElementTest2(tagName) {
return tagName.indexOf("-") > 0;
};
var _sanitizeAttributes = function _sanitizeAttributes2(currentNode) {
var attr;
var value;
var lcName;
var l;
_executeHook("beforeSanitizeAttributes", currentNode, null);
var attributes = currentNode.attributes;
if (!attributes) {
return;
}
var hookEvent = {
attrName: "",
attrValue: "",
keepAttr: true,
allowedAttributes: ALLOWED_ATTR
};
l = attributes.length;
while (l--) {
attr = attributes[l];
var _attr = attr, name = _attr.name, namespaceURI = _attr.namespaceURI;
value = name === "value" ? attr.value : stringTrim(attr.value);
lcName = transformCaseFunc(name);
hookEvent.attrName = lcName;
hookEvent.attrValue = value;
hookEvent.keepAttr = true;
hookEvent.forceKeepAttr = void 0;
_executeHook("uponSanitizeAttribute", currentNode, hookEvent);
value = hookEvent.attrValue;
if (hookEvent.forceKeepAttr) {
continue;
}
_removeAttribute(name, currentNode);
if (!hookEvent.keepAttr) {
continue;
}
if (regExpTest(/\/>/i, value)) {
_removeAttribute(name, currentNode);
continue;
}
if (SAFE_FOR_TEMPLATES) {
value = stringReplace(value, MUSTACHE_EXPR$1, " ");
value = stringReplace(value, ERB_EXPR$1, " ");
}
var lcTag = transformCaseFunc(currentNode.nodeName);
if (!_isValidAttribute(lcTag, lcName, value)) {
continue;
}
if (trustedTypesPolicy && _typeof(trustedTypes) === "object" && typeof trustedTypes.getAttributeType === "function") {
if (namespaceURI)
;
else {
switch (trustedTypes.getAttributeType(lcTag, lcName)) {
case "TrustedHTML":
value = trustedTypesPolicy.createHTML(value);
break;
case "TrustedScriptURL":
value = trustedTypesPolicy.createScriptURL(value);
break;
}
}
}
try {
if (namespaceURI) {
currentNode.setAttributeNS(namespaceURI, name, value);
} else {
currentNode.setAttribute(name, value);
}
arrayPop(DOMPurify.removed);
} catch (_) {
}
}
_executeHook("afterSanitizeAttributes", currentNode, null);
};
var _sanitizeShadowDOM = function _sanitizeShadowDOM2(fragment) {
var shadowNode;
var shadowIterator = _createIterator(fragment);
_executeHook("beforeSanitizeShadowDOM", fragment, null);
while (shadowNode = shadowIterator.nextNode()) {
_executeHook("uponSanitizeShadowNode", shadowNode, null);
if (_sanitizeElements(shadowNode)) {
continue;
}
if (shadowNode.content instanceof DocumentFragment2) {
_sanitizeShadowDOM2(shadowNode.content);
}
_sanitizeAttributes(shadowNode);
}
_executeHook("afterSanitizeShadowDOM", fragment, null);
};
DOMPurify.sanitize = function(dirty, cfg) {
var body;
var importedNode;
var currentNode;
var oldNode;
var returnNode;
IS_EMPTY_INPUT = !dirty;
if (IS_EMPTY_INPUT) {
dirty = "";
}
if (typeof dirty !== "string" && !_isNode(dirty)) {
if (typeof dirty.toString !== "function") {
throw typeErrorCreate("toString is not a function");
} else {
dirty = dirty.toString();
if (typeof dirty !== "string") {
throw typeErrorCreate("dirty is not a string, aborting");
}
}
}
if (!DOMPurify.isSupported) {
if (_typeof(window2.toStaticHTML) === "object" || typeof window2.toStaticHTML === "function") {
if (typeof dirty === "string") {
return window2.toStaticHTML(dirty);
}
if (_isNode(dirty)) {
return window2.toStaticHTML(dirty.outerHTML);
}
}
return dirty;
}
if (!SET_CONFIG) {
_parseConfig(cfg);
}
DOMPurify.removed = [];
if (typeof dirty === "string") {
IN_PLACE = false;
}
if (IN_PLACE) {
if (dirty.nodeName) {
var tagName = transformCaseFunc(dirty.nodeName);
if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
throw typeErrorCreate("root node is forbidden and cannot be sanitized in-place");
}
}
} else if (dirty instanceof Node6) {
body = _initDocument("");
importedNode = body.ownerDocument.importNode(dirty, true);
if (importedNode.nodeType === 1 && importedNode.nodeName === "BODY") {
body = importedNode;
} else if (importedNode.nodeName === "HTML") {
body = importedNode;
} else {
body.appendChild(importedNode);
}
} else {
if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT && dirty.indexOf("<") === -1) {
return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(dirty) : dirty;
}
body = _initDocument(dirty);
if (!body) {
return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : "";
}
}
if (body && FORCE_BODY) {
_forceRemove(body.firstChild);
}
var nodeIterator = _createIterator(IN_PLACE ? dirty : body);
while (currentNode = nodeIterator.nextNode()) {
if (currentNode.nodeType === 3 && currentNode === oldNode) {
continue;
}
if (_sanitizeElements(currentNode)) {
continue;
}
if (currentNode.content instanceof DocumentFragment2) {
_sanitizeShadowDOM(currentNode.content);
}
_sanitizeAttributes(currentNode);
oldNode = currentNode;
}
oldNode = null;
if (IN_PLACE) {
return dirty;
}
if (RETURN_DOM) {
if (RETURN_DOM_FRAGMENT) {
returnNode = createDocumentFragment.call(body.ownerDocument);
while (body.firstChild) {
returnNode.appendChild(body.firstChild);
}
} else {
returnNode = body;
}
if (ALLOWED_ATTR.shadowroot) {
returnNode = importNode.call(originalDocument, returnNode, true);
}
return returnNode;
}
var serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML;
if (WHOLE_DOCUMENT && ALLOWED_TAGS["!doctype"] && body.ownerDocument && body.ownerDocument.doctype && body.ownerDocument.doctype.name && regExpTest(DOCTYPE_NAME, body.ownerDocument.doctype.name)) {
serializedHTML = "\n" + serializedHTML;
}
if (SAFE_FOR_TEMPLATES) {
serializedHTML = stringReplace(serializedHTML, MUSTACHE_EXPR$1, " ");
serializedHTML = stringReplace(serializedHTML, ERB_EXPR$1, " ");
}
return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(serializedHTML) : serializedHTML;
};
DOMPurify.setConfig = function(cfg) {
_parseConfig(cfg);
SET_CONFIG = true;
};
DOMPurify.clearConfig = function() {
CONFIG = null;
SET_CONFIG = false;
};
DOMPurify.isValidAttribute = function(tag, attr, value) {
if (!CONFIG) {
_parseConfig({});
}
var lcTag = transformCaseFunc(tag);
var lcName = transformCaseFunc(attr);
return _isValidAttribute(lcTag, lcName, value);
};
DOMPurify.addHook = function(entryPoint, hookFunction) {
if (typeof hookFunction !== "function") {
return;
}
hooks[entryPoint] = hooks[entryPoint] || [];
arrayPush(hooks[entryPoint], hookFunction);
};
DOMPurify.removeHook = function(entryPoint) {
if (hooks[entryPoint]) {
return arrayPop(hooks[entryPoint]);
}
};
DOMPurify.removeHooks = function(entryPoint) {
if (hooks[entryPoint]) {
hooks[entryPoint] = [];
}
};
DOMPurify.removeAllHooks = function() {
hooks = {};
};
return DOMPurify;
}
var purify = createDOMPurify();
module2.exports = purify;
}
});
// node_modules/earcut/src/earcut.js
var require_earcut = __commonJS({
"node_modules/earcut/src/earcut.js"(exports2, module2) {
"use strict";
module2.exports = earcut2;
module2.exports.default = earcut2;
function earcut2(data, holeIndices, dim) {
dim = dim || 2;
var hasHoles = holeIndices && holeIndices.length, outerLen = hasHoles ? holeIndices[0] * dim : data.length, outerNode = linkedList(data, 0, outerLen, dim, true), triangles = [];
if (!outerNode || outerNode.next === outerNode.prev)
return triangles;
var minX, minY, maxX, maxY, x, y, invSize;
if (hasHoles)
outerNode = eliminateHoles(data, holeIndices, outerNode, dim);
if (data.length > 80 * dim) {
minX = maxX = data[0];
minY = maxY = data[1];
for (var i = dim; i < outerLen; i += dim) {
x = data[i];
y = data[i + 1];
if (x < minX)
minX = x;
if (y < minY)
minY = y;
if (x > maxX)
maxX = x;
if (y > maxY)
maxY = y;
}
invSize = Math.max(maxX - minX, maxY - minY);
invSize = invSize !== 0 ? 32767 / invSize : 0;
}
earcutLinked(outerNode, triangles, dim, minX, minY, invSize, 0);
return triangles;
}
function linkedList(data, start, end, dim, clockwise) {
var i, last;
if (clockwise === signedArea(data, start, end, dim) > 0) {
for (i = start; i < end; i += dim)
last = insertNode(i, data[i], data[i + 1], last);
} else {
for (i = end - dim; i >= start; i -= dim)
last = insertNode(i, data[i], data[i + 1], last);
}
if (last && equals(last, last.next)) {
removeNode(last);
last = last.next;
}
return last;
}
function filterPoints(start, end) {
if (!start)
return start;
if (!end)
end = start;
var p = start, again;
do {
again = false;
if (!p.steiner && (equals(p, p.next) || area(p.prev, p, p.next) === 0)) {
removeNode(p);
p = end = p.prev;
if (p === p.next)
break;
again = true;
} else {
p = p.next;
}
} while (again || p !== end);
return end;
}
function earcutLinked(ear, triangles, dim, minX, minY, invSize, pass) {
if (!ear)
return;
if (!pass && invSize)
indexCurve(ear, minX, minY, invSize);
var stop2 = ear, prev, next;
while (ear.prev !== ear.next) {
prev = ear.prev;
next = ear.next;
if (invSize ? isEarHashed(ear, minX, minY, invSize) : isEar(ear)) {
triangles.push(prev.i / dim | 0);
triangles.push(ear.i / dim | 0);
triangles.push(next.i / dim | 0);
removeNode(ear);
ear = next.next;
stop2 = next.next;
continue;
}
ear = next;
if (ear === stop2) {
if (!pass) {
earcutLinked(filterPoints(ear), triangles, dim, minX, minY, invSize, 1);
} else if (pass === 1) {
ear = cureLocalIntersections(filterPoints(ear), triangles, dim);
earcutLinked(ear, triangles, dim, minX, minY, invSize, 2);
} else if (pass === 2) {
splitEarcut(ear, triangles, dim, minX, minY, invSize);
}
break;
}
}
}
function isEar(ear) {
var a3 = ear.prev, b = ear, c = ear.next;
if (area(a3, b, c) >= 0)
return false;
var ax = a3.x, bx = b.x, cx = c.x, ay = a3.y, by = b.y, cy = c.y;
var x0 = ax < bx ? ax < cx ? ax : cx : bx < cx ? bx : cx, y0 = ay < by ? ay < cy ? ay : cy : by < cy ? by : cy, x1 = ax > bx ? ax > cx ? ax : cx : bx > cx ? bx : cx, y1 = ay > by ? ay > cy ? ay : cy : by > cy ? by : cy;
var p = c.next;
while (p !== a3) {
if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 && pointInTriangle(ax, ay, bx, by, cx, cy, p.x, p.y) && area(p.prev, p, p.next) >= 0)
return false;
p = p.next;
}
return true;
}
function isEarHashed(ear, minX, minY, invSize) {
var a3 = ear.prev, b = ear, c = ear.next;
if (area(a3, b, c) >= 0)
return false;
var ax = a3.x, bx = b.x, cx = c.x, ay = a3.y, by = b.y, cy = c.y;
var x0 = ax < bx ? ax < cx ? ax : cx : bx < cx ? bx : cx, y0 = ay < by ? ay < cy ? ay : cy : by < cy ? by : cy, x1 = ax > bx ? ax > cx ? ax : cx : bx > cx ? bx : cx, y1 = ay > by ? ay > cy ? ay : cy : by > cy ? by : cy;
var minZ = zOrder(x0, y0, minX, minY, invSize), maxZ = zOrder(x1, y1, minX, minY, invSize);
var p = ear.prevZ, n = ear.nextZ;
while (p && p.z >= minZ && n && n.z <= maxZ) {
if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 && p !== a3 && p !== c && pointInTriangle(ax, ay, bx, by, cx, cy, p.x, p.y) && area(p.prev, p, p.next) >= 0)
return false;
p = p.prevZ;
if (n.x >= x0 && n.x <= x1 && n.y >= y0 && n.y <= y1 && n !== a3 && n !== c && pointInTriangle(ax, ay, bx, by, cx, cy, n.x, n.y) && area(n.prev, n, n.next) >= 0)
return false;
n = n.nextZ;
}
while (p && p.z >= minZ) {
if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 && p !== a3 && p !== c && pointInTriangle(ax, ay, bx, by, cx, cy, p.x, p.y) && area(p.prev, p, p.next) >= 0)
return false;
p = p.prevZ;
}
while (n && n.z <= maxZ) {
if (n.x >= x0 && n.x <= x1 && n.y >= y0 && n.y <= y1 && n !== a3 && n !== c && pointInTriangle(ax, ay, bx, by, cx, cy, n.x, n.y) && area(n.prev, n, n.next) >= 0)
return false;
n = n.nextZ;
}
return true;
}
function cureLocalIntersections(start, triangles, dim) {
var p = start;
do {
var a3 = p.prev, b = p.next.next;
if (!equals(a3, b) && intersects(a3, p, p.next, b) && locallyInside(a3, b) && locallyInside(b, a3)) {
triangles.push(a3.i / dim | 0);
triangles.push(p.i / dim | 0);
triangles.push(b.i / dim | 0);
removeNode(p);
removeNode(p.next);
p = start = b;
}
p = p.next;
} while (p !== start);
return filterPoints(p);
}
function splitEarcut(start, triangles, dim, minX, minY, invSize) {
var a3 = start;
do {
var b = a3.next.next;
while (b !== a3.prev) {
if (a3.i !== b.i && isValidDiagonal(a3, b)) {
var c = splitPolygon(a3, b);
a3 = filterPoints(a3, a3.next);
c = filterPoints(c, c.next);
earcutLinked(a3, triangles, dim, minX, minY, invSize, 0);
earcutLinked(c, triangles, dim, minX, minY, invSize, 0);
return;
}
b = b.next;
}
a3 = a3.next;
} while (a3 !== start);
}
function eliminateHoles(data, holeIndices, outerNode, dim) {
var queue = [], i, len, start, end, list;
for (i = 0, len = holeIndices.length; i < len; i++) {
start = holeIndices[i] * dim;
end = i < len - 1 ? holeIndices[i + 1] * dim : data.length;
list = linkedList(data, start, end, dim, false);
if (list === list.next)
list.steiner = true;
queue.push(getLeftmost(list));
}
queue.sort(compareX);
for (i = 0; i < queue.length; i++) {
outerNode = eliminateHole(queue[i], outerNode);
}
return outerNode;
}
function compareX(a3, b) {
return a3.x - b.x;
}
function eliminateHole(hole, outerNode) {
var bridge = findHoleBridge(hole, outerNode);
if (!bridge) {
return outerNode;
}
var bridgeReverse = splitPolygon(bridge, hole);
filterPoints(bridgeReverse, bridgeReverse.next);
return filterPoints(bridge, bridge.next);
}
function findHoleBridge(hole, outerNode) {
var p = outerNode, hx = hole.x, hy = hole.y, qx = -Infinity, m;
do {
if (hy <= p.y && hy >= p.next.y && p.next.y !== p.y) {
var x = p.x + (hy - p.y) * (p.next.x - p.x) / (p.next.y - p.y);
if (x <= hx && x > qx) {
qx = x;
m = p.x < p.next.x ? p : p.next;
if (x === hx)
return m;
}
}
p = p.next;
} while (p !== outerNode);
if (!m)
return null;
var stop2 = m, mx = m.x, my = m.y, tanMin = Infinity, tan;
p = m;
do {
if (hx >= p.x && p.x >= mx && hx !== p.x && pointInTriangle(hy < my ? hx : qx, hy, mx, my, hy < my ? qx : hx, hy, p.x, p.y)) {
tan = Math.abs(hy - p.y) / (hx - p.x);
if (locallyInside(p, hole) && (tan < tanMin || tan === tanMin && (p.x > m.x || p.x === m.x && sectorContainsSector(m, p)))) {
m = p;
tanMin = tan;
}
}
p = p.next;
} while (p !== stop2);
return m;
}
function sectorContainsSector(m, p) {
return area(m.prev, m, p.prev) < 0 && area(p.next, m, m.next) < 0;
}
function indexCurve(start, minX, minY, invSize) {
var p = start;
do {
if (p.z === 0)
p.z = zOrder(p.x, p.y, minX, minY, invSize);
p.prevZ = p.prev;
p.nextZ = p.next;
p = p.next;
} while (p !== start);
p.prevZ.nextZ = null;
p.prevZ = null;
sortLinked(p);
}
function sortLinked(list) {
var i, p, q, e, tail, numMerges, pSize, qSize, inSize = 1;
do {
p = list;
list = null;
tail = null;
numMerges = 0;
while (p) {
numMerges++;
q = p;
pSize = 0;
for (i = 0; i < inSize; i++) {
pSize++;
q = q.nextZ;
if (!q)
break;
}
qSize = inSize;
while (pSize > 0 || qSize > 0 && q) {
if (pSize !== 0 && (qSize === 0 || !q || p.z <= q.z)) {
e = p;
p = p.nextZ;
pSize--;
} else {
e = q;
q = q.nextZ;
qSize--;
}
if (tail)
tail.nextZ = e;
else
list = e;
e.prevZ = tail;
tail = e;
}
p = q;
}
tail.nextZ = null;
inSize *= 2;
} while (numMerges > 1);
return list;
}
function zOrder(x, y, minX, minY, invSize) {
x = (x - minX) * invSize | 0;
y = (y - minY) * invSize | 0;
x = (x | x << 8) & 16711935;
x = (x | x << 4) & 252645135;
x = (x | x << 2) & 858993459;
x = (x | x << 1) & 1431655765;
y = (y | y << 8) & 16711935;
y = (y | y << 4) & 252645135;
y = (y | y << 2) & 858993459;
y = (y | y << 1) & 1431655765;
return x | y << 1;
}
function getLeftmost(start) {
var p = start, leftmost = start;
do {
if (p.x < leftmost.x || p.x === leftmost.x && p.y < leftmost.y)
leftmost = p;
p = p.next;
} while (p !== start);
return leftmost;
}
function pointInTriangle(ax, ay, bx, by, cx, cy, px, py) {
return (cx - px) * (ay - py) >= (ax - px) * (cy - py) && (ax - px) * (by - py) >= (bx - px) * (ay - py) && (bx - px) * (cy - py) >= (cx - px) * (by - py);
}
function isValidDiagonal(a3, b) {
return a3.next.i !== b.i && a3.prev.i !== b.i && !intersectsPolygon(a3, b) && (locallyInside(a3, b) && locallyInside(b, a3) && middleInside(a3, b) && (area(a3.prev, a3, b.prev) || area(a3, b.prev, b)) || equals(a3, b) && area(a3.prev, a3, a3.next) > 0 && area(b.prev, b, b.next) > 0);
}
function area(p, q, r) {
return (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y);
}
function equals(p1, p2) {
return p1.x === p2.x && p1.y === p2.y;
}
function intersects(p1, q12, p2, q22) {
var o1 = sign2(area(p1, q12, p2));
var o2 = sign2(area(p1, q12, q22));
var o3 = sign2(area(p2, q22, p1));
var o4 = sign2(area(p2, q22, q12));
if (o1 !== o2 && o3 !== o4)
return true;
if (o1 === 0 && onSegment(p1, p2, q12))
return true;
if (o2 === 0 && onSegment(p1, q22, q12))
return true;
if (o3 === 0 && onSegment(p2, p1, q22))
return true;
if (o4 === 0 && onSegment(p2, q12, q22))
return true;
return false;
}
function onSegment(p, q, r) {
return q.x <= Math.max(p.x, r.x) && q.x >= Math.min(p.x, r.x) && q.y <= Math.max(p.y, r.y) && q.y >= Math.min(p.y, r.y);
}
function sign2(num) {
return num > 0 ? 1 : num < 0 ? -1 : 0;
}
function intersectsPolygon(a3, b) {
var p = a3;
do {
if (p.i !== a3.i && p.next.i !== a3.i && p.i !== b.i && p.next.i !== b.i && intersects(p, p.next, a3, b))
return true;
p = p.next;
} while (p !== a3);
return false;
}
function locallyInside(a3, b) {
return area(a3.prev, a3, a3.next) < 0 ? area(a3, b, a3.next) >= 0 && area(a3, a3.prev, b) >= 0 : area(a3, b, a3.prev) < 0 || area(a3, a3.next, b) < 0;
}
function middleInside(a3, b) {
var p = a3, inside = false, px = (a3.x + b.x) / 2, py = (a3.y + b.y) / 2;
do {
if (p.y > py !== p.next.y > py && p.next.y !== p.y && px < (p.next.x - p.x) * (py - p.y) / (p.next.y - p.y) + p.x)
inside = !inside;
p = p.next;
} while (p !== a3);
return inside;
}
function splitPolygon(a3, b) {
var a22 = new Node6(a3.i, a3.x, a3.y), b2 = new Node6(b.i, b.x, b.y), an = a3.next, bp = b.prev;
a3.next = b;
b.prev = a3;
a22.next = an;
an.prev = a22;
b2.next = a22;
a22.prev = b2;
bp.next = b2;
b2.prev = bp;
return b2;
}
function insertNode(i, x, y, last) {
var p = new Node6(i, x, y);
if (!last) {
p.prev = p;
p.next = p;
} else {
p.next = last.next;
p.prev = last;
last.next.prev = p;
last.next = p;
}
return p;
}
function removeNode(p) {
p.next.prev = p.prev;
p.prev.next = p.next;
if (p.prevZ)
p.prevZ.nextZ = p.nextZ;
if (p.nextZ)
p.nextZ.prevZ = p.prevZ;
}
function Node6(i, x, y) {
this.i = i;
this.x = x;
this.y = y;
this.prev = null;
this.next = null;
this.z = 0;
this.prevZ = null;
this.nextZ = null;
this.steiner = false;
}
earcut2.deviation = function(data, holeIndices, dim, triangles) {
var hasHoles = holeIndices && holeIndices.length;
var outerLen = hasHoles ? holeIndices[0] * dim : data.length;
var polygonArea = Math.abs(signedArea(data, 0, outerLen, dim));
if (hasHoles) {
for (var i = 0, len = holeIndices.length; i < len; i++) {
var start = holeIndices[i] * dim;
var end = i < len - 1 ? holeIndices[i + 1] * dim : data.length;
polygonArea -= Math.abs(signedArea(data, start, end, dim));
}
}
var trianglesArea = 0;
for (i = 0; i < triangles.length; i += 3) {
var a3 = triangles[i] * dim;
var b = triangles[i + 1] * dim;
var c = triangles[i + 2] * dim;
trianglesArea += Math.abs(
(data[a3] - data[c]) * (data[b + 1] - data[a3 + 1]) - (data[a3] - data[b]) * (data[c + 1] - data[a3 + 1])
);
}
return polygonArea === 0 && trianglesArea === 0 ? 0 : Math.abs((trianglesArea - polygonArea) / polygonArea);
};
function signedArea(data, start, end, dim) {
var sum = 0;
for (var i = start, j = end - dim; i < end; i += dim) {
sum += (data[j] - data[i]) * (data[i + 1] + data[j + 1]);
j = i;
}
return sum;
}
earcut2.flatten = function(data) {
var dim = data[0][0].length, result = { vertices: [], holes: [], dimensions: dim }, holeIndex = 0;
for (var i = 0; i < data.length; i++) {
for (var j = 0; j < data[i].length; j++) {
for (var d = 0; d < dim; d++)
result.vertices.push(data[i][j][d]);
}
if (i > 0) {
holeIndex += data[i - 1].length;
result.holes.push(holeIndex);
}
}
return result;
};
}
});
// node_modules/tween.js/src/Tween.js
var require_Tween = __commonJS({
"node_modules/tween.js/src/Tween.js"(exports2, module2) {
var TWEEN = TWEEN || function() {
var _tweens = [];
return {
getAll: function() {
return _tweens;
},
removeAll: function() {
_tweens = [];
},
add: function(tween) {
_tweens.push(tween);
},
remove: function(tween) {
var i = _tweens.indexOf(tween);
if (i !== -1) {
_tweens.splice(i, 1);
}
},
update: function(time, preserve) {
if (_tweens.length === 0) {
return false;
}
var i = 0;
time = time !== void 0 ? time : TWEEN.now();
while (i < _tweens.length) {
if (_tweens[i].update(time) || preserve) {
i++;
} else {
_tweens.splice(i, 1);
}
}
return true;
}
};
}();
if (typeof window === "undefined" && typeof process !== "undefined") {
TWEEN.now = function() {
var time = process.hrtime();
return time[0] * 1e3 + time[1] / 1e6;
};
} else if (typeof window !== "undefined" && window.performance !== void 0 && window.performance.now !== void 0) {
TWEEN.now = window.performance.now.bind(window.performance);
} else if (Date.now !== void 0) {
TWEEN.now = Date.now;
} else {
TWEEN.now = function() {
return new Date().getTime();
};
}
TWEEN.Tween = function(object) {
var _object = object;
var _valuesStart = {};
var _valuesEnd = {};
var _valuesStartRepeat = {};
var _duration = 1e3;
var _repeat = 0;
var _repeatDelayTime;
var _yoyo = false;
var _isPlaying = false;
var _reversed = false;
var _delayTime = 0;
var _startTime = null;
var _easingFunction = TWEEN.Easing.Linear.None;
var _interpolationFunction = TWEEN.Interpolation.Linear;
var _chainedTweens = [];
var _onStartCallback = null;
var _onStartCallbackFired = false;
var _onUpdateCallback = null;
var _onCompleteCallback = null;
var _onStopCallback = null;
this.to = function(properties, duration) {
_valuesEnd = properties;
if (duration !== void 0) {
_duration = duration;
}
return this;
};
this.start = function(time) {
TWEEN.add(this);
_isPlaying = true;
_onStartCallbackFired = false;
_startTime = time !== void 0 ? time : TWEEN.now();
_startTime += _delayTime;
for (var property in _valuesEnd) {
if (_valuesEnd[property] instanceof Array) {
if (_valuesEnd[property].length === 0) {
continue;
}
_valuesEnd[property] = [_object[property]].concat(_valuesEnd[property]);
}
if (_object[property] === void 0) {
continue;
}
_valuesStart[property] = _object[property];
if (_valuesStart[property] instanceof Array === false) {
_valuesStart[property] *= 1;
}
_valuesStartRepeat[property] = _valuesStart[property] || 0;
}
return this;
};
this.stop = function() {
if (!_isPlaying) {
return this;
}
TWEEN.remove(this);
_isPlaying = false;
if (_onStopCallback !== null) {
_onStopCallback.call(_object, _object);
}
this.stopChainedTweens();
return this;
};
this.end = function() {
this.update(_startTime + _duration);
return this;
};
this.stopChainedTweens = function() {
for (var i = 0, numChainedTweens = _chainedTweens.length; i < numChainedTweens; i++) {
_chainedTweens[i].stop();
}
};
this.delay = function(amount) {
_delayTime = amount;
return this;
};
this.repeat = function(times) {
_repeat = times;
return this;
};
this.repeatDelay = function(amount) {
_repeatDelayTime = amount;
return this;
};
this.yoyo = function(yoyo) {
_yoyo = yoyo;
return this;
};
this.easing = function(easing) {
_easingFunction = easing;
return this;
};
this.interpolation = function(interpolation) {
_interpolationFunction = interpolation;
return this;
};
this.chain = function() {
_chainedTweens = arguments;
return this;
};
this.onStart = function(callback) {
_onStartCallback = callback;
return this;
};
this.onUpdate = function(callback) {
_onUpdateCallback = callback;
return this;
};
this.onComplete = function(callback) {
_onCompleteCallback = callback;
return this;
};
this.onStop = function(callback) {
_onStopCallback = callback;
return this;
};
this.update = function(time) {
var property;
var elapsed;
var value;
if (time < _startTime) {
return true;
}
if (_onStartCallbackFired === false) {
if (_onStartCallback !== null) {
_onStartCallback.call(_object, _object);
}
_onStartCallbackFired = true;
}
elapsed = (time - _startTime) / _duration;
elapsed = elapsed > 1 ? 1 : elapsed;
value = _easingFunction(elapsed);
for (property in _valuesEnd) {
if (_valuesStart[property] === void 0) {
continue;
}
var start = _valuesStart[property] || 0;
var end = _valuesEnd[property];
if (end instanceof Array) {
_object[property] = _interpolationFunction(end, value);
} else {
if (typeof end === "string") {
if (end.charAt(0) === "+" || end.charAt(0) === "-") {
end = start + parseFloat(end);
} else {
end = parseFloat(end);
}
}
if (typeof end === "number") {
_object[property] = start + (end - start) * value;
}
}
}
if (_onUpdateCallback !== null) {
_onUpdateCallback.call(_object, value);
}
if (elapsed === 1) {
if (_repeat > 0) {
if (isFinite(_repeat)) {
_repeat--;
}
for (property in _valuesStartRepeat) {
if (typeof _valuesEnd[property] === "string") {
_valuesStartRepeat[property] = _valuesStartRepeat[property] + parseFloat(_valuesEnd[property]);
}
if (_yoyo) {
var tmp2 = _valuesStartRepeat[property];
_valuesStartRepeat[property] = _valuesEnd[property];
_valuesEnd[property] = tmp2;
}
_valuesStart[property] = _valuesStartRepeat[property];
}
if (_yoyo) {
_reversed = !_reversed;
}
if (_repeatDelayTime !== void 0) {
_startTime = time + _repeatDelayTime;
} else {
_startTime = time + _delayTime;
}
return true;
} else {
if (_onCompleteCallback !== null) {
_onCompleteCallback.call(_object, _object);
}
for (var i = 0, numChainedTweens = _chainedTweens.length; i < numChainedTweens; i++) {
_chainedTweens[i].start(_startTime + _duration);
}
return false;
}
}
return true;
};
};
TWEEN.Easing = {
Linear: {
None: function(k) {
return k;
}
},
Quadratic: {
In: function(k) {
return k * k;
},
Out: function(k) {
return k * (2 - k);
},
InOut: function(k) {
if ((k *= 2) < 1) {
return 0.5 * k * k;
}
return -0.5 * (--k * (k - 2) - 1);
}
},
Cubic: {
In: function(k) {
return k * k * k;
},
Out: function(k) {
return --k * k * k + 1;
},
InOut: function(k) {
if ((k *= 2) < 1) {
return 0.5 * k * k * k;
}
return 0.5 * ((k -= 2) * k * k + 2);
}
},
Quartic: {
In: function(k) {
return k * k * k * k;
},
Out: function(k) {
return 1 - --k * k * k * k;
},
InOut: function(k) {
if ((k *= 2) < 1) {
return 0.5 * k * k * k * k;
}
return -0.5 * ((k -= 2) * k * k * k - 2);
}
},
Quintic: {
In: function(k) {
return k * k * k * k * k;
},
Out: function(k) {
return --k * k * k * k * k + 1;
},
InOut: function(k) {
if ((k *= 2) < 1) {
return 0.5 * k * k * k * k * k;
}
return 0.5 * ((k -= 2) * k * k * k * k + 2);
}
},
Sinusoidal: {
In: function(k) {
return 1 - Math.cos(k * Math.PI / 2);
},
Out: function(k) {
return Math.sin(k * Math.PI / 2);
},
InOut: function(k) {
return 0.5 * (1 - Math.cos(Math.PI * k));
}
},
Exponential: {
In: function(k) {
return k === 0 ? 0 : Math.pow(1024, k - 1);
},
Out: function(k) {
return k === 1 ? 1 : 1 - Math.pow(2, -10 * k);
},
InOut: function(k) {
if (k === 0) {
return 0;
}
if (k === 1) {
return 1;
}
if ((k *= 2) < 1) {
return 0.5 * Math.pow(1024, k - 1);
}
return 0.5 * (-Math.pow(2, -10 * (k - 1)) + 2);
}
},
Circular: {
In: function(k) {
return 1 - Math.sqrt(1 - k * k);
},
Out: function(k) {
return Math.sqrt(1 - --k * k);
},
InOut: function(k) {
if ((k *= 2) < 1) {
return -0.5 * (Math.sqrt(1 - k * k) - 1);
}
return 0.5 * (Math.sqrt(1 - (k -= 2) * k) + 1);
}
},
Elastic: {
In: function(k) {
if (k === 0) {
return 0;
}
if (k === 1) {
return 1;
}
return -Math.pow(2, 10 * (k - 1)) * Math.sin((k - 1.1) * 5 * Math.PI);
},
Out: function(k) {
if (k === 0) {
return 0;
}
if (k === 1) {
return 1;
}
return Math.pow(2, -10 * k) * Math.sin((k - 0.1) * 5 * Math.PI) + 1;
},
InOut: function(k) {
if (k === 0) {
return 0;
}
if (k === 1) {
return 1;
}
k *= 2;
if (k < 1) {
return -0.5 * Math.pow(2, 10 * (k - 1)) * Math.sin((k - 1.1) * 5 * Math.PI);
}
return 0.5 * Math.pow(2, -10 * (k - 1)) * Math.sin((k - 1.1) * 5 * Math.PI) + 1;
}
},
Back: {
In: function(k) {
var s = 1.70158;
return k * k * ((s + 1) * k - s);
},
Out: function(k) {
var s = 1.70158;
return --k * k * ((s + 1) * k + s) + 1;
},
InOut: function(k) {
var s = 1.70158 * 1.525;
if ((k *= 2) < 1) {
return 0.5 * (k * k * ((s + 1) * k - s));
}
return 0.5 * ((k -= 2) * k * ((s + 1) * k + s) + 2);
}
},
Bounce: {
In: function(k) {
return 1 - TWEEN.Easing.Bounce.Out(1 - k);
},
Out: function(k) {
if (k < 1 / 2.75) {
return 7.5625 * k * k;
} else if (k < 2 / 2.75) {
return 7.5625 * (k -= 1.5 / 2.75) * k + 0.75;
} else if (k < 2.5 / 2.75) {
return 7.5625 * (k -= 2.25 / 2.75) * k + 0.9375;
} else {
return 7.5625 * (k -= 2.625 / 2.75) * k + 0.984375;
}
},
InOut: function(k) {
if (k < 0.5) {
return TWEEN.Easing.Bounce.In(k * 2) * 0.5;
}
return TWEEN.Easing.Bounce.Out(k * 2 - 1) * 0.5 + 0.5;
}
}
};
TWEEN.Interpolation = {
Linear: function(v7, k) {
var m = v7.length - 1;
var f = m * k;
var i = Math.floor(f);
var fn = TWEEN.Interpolation.Utils.Linear;
if (k < 0) {
return fn(v7[0], v7[1], f);
}
if (k > 1) {
return fn(v7[m], v7[m - 1], m - f);
}
return fn(v7[i], v7[i + 1 > m ? m : i + 1], f - i);
},
Bezier: function(v7, k) {
var b = 0;
var n = v7.length - 1;
var pw = Math.pow;
var bn = TWEEN.Interpolation.Utils.Bernstein;
for (var i = 0; i <= n; i++) {
b += pw(1 - k, n - i) * pw(k, i) * v7[i] * bn(n, i);
}
return b;
},
CatmullRom: function(v7, k) {
var m = v7.length - 1;
var f = m * k;
var i = Math.floor(f);
var fn = TWEEN.Interpolation.Utils.CatmullRom;
if (v7[0] === v7[m]) {
if (k < 0) {
i = Math.floor(f = m * (1 + k));
}
return fn(v7[(i - 1 + m) % m], v7[i], v7[(i + 1) % m], v7[(i + 2) % m], f - i);
} else {
if (k < 0) {
return v7[0] - (fn(v7[0], v7[0], v7[1], v7[1], -f) - v7[0]);
}
if (k > 1) {
return v7[m] - (fn(v7[m], v7[m], v7[m - 1], v7[m - 1], f - m) - v7[m]);
}
return fn(v7[i ? i - 1 : 0], v7[i], v7[m < i + 1 ? m : i + 1], v7[m < i + 2 ? m : i + 2], f - i);
}
},
Utils: {
Linear: function(p0, p1, t) {
return (p1 - p0) * t + p0;
},
Bernstein: function(n, i) {
var fc = TWEEN.Interpolation.Utils.Factorial;
return fc(n) / fc(i) / fc(n - i);
},
Factorial: function() {
var a3 = [1];
return function(n) {
var s = 1;
if (a3[n]) {
return a3[n];
}
for (var i = n; i > 1; i--) {
s *= i;
}
a3[n] = s;
return s;
};
}(),
CatmullRom: function(p0, p1, p2, p3, t) {
var v02 = (p2 - p0) * 0.5;
var v13 = (p3 - p1) * 0.5;
var t2 = t * t;
var t3 = t * t2;
return (2 * p1 - 2 * p2 + v02 + v13) * t3 + (-3 * p1 + 3 * p2 - 2 * v02 - v13) * t2 + v02 * t + p1;
}
}
};
(function(root) {
if (typeof define === "function" && define.amd) {
define([], function() {
return TWEEN;
});
} else if (typeof module2 !== "undefined" && typeof exports2 === "object") {
module2.exports = TWEEN;
} else if (root !== void 0) {
root.TWEEN = TWEEN;
}
})(exports2);
}
});
// node_modules/protobufjs/dist/minimal/protobuf.js
var require_protobuf = __commonJS({
"node_modules/protobufjs/dist/minimal/protobuf.js"(exports, module) {
/*!
* protobuf.js v6.10.2 (c) 2016, daniel wirtz
* compiled fri, 08 jul 2022 16:17:13 utc
* licensed under the bsd-3-clause license
* see: https://github.com/dcodeio/protobuf.js for details
*/
(function(undefined) {
"use strict";
(function prelude(modules, cache, entries) {
function $require(name) {
var $module = cache[name];
if (!$module)
modules[name][0].call($module = cache[name] = { exports: {} }, $require, $module, $module.exports);
return $module.exports;
}
var protobuf2 = $require(entries[0]);
protobuf2.util.global.protobuf = protobuf2;
if (typeof define === "function" && define.amd)
define(["long"], function(Long) {
if (Long && Long.isLong) {
protobuf2.util.Long = Long;
protobuf2.configure();
}
return protobuf2;
});
if (typeof module === "object" && module && module.exports)
module.exports = protobuf2;
})({ 1: [function(require2, module2, exports2) {
"use strict";
module2.exports = asPromise;
function asPromise(fn, ctx) {
var params = new Array(arguments.length - 1), offset2 = 0, index = 2, pending = true;
while (index < arguments.length)
params[offset2++] = arguments[index++];
return new Promise(function executor(resolve2, reject) {
params[offset2] = function callback(err) {
if (pending) {
pending = false;
if (err)
reject(err);
else {
var params2 = new Array(arguments.length - 1), offset3 = 0;
while (offset3 < params2.length)
params2[offset3++] = arguments[offset3];
resolve2.apply(null, params2);
}
}
};
try {
fn.apply(ctx || null, params);
} catch (err) {
if (pending) {
pending = false;
reject(err);
}
}
});
}
}, {}], 2: [function(require2, module2, exports2) {
"use strict";
var base64 = exports2;
base64.length = function length3(string) {
var p = string.length;
if (!p)
return 0;
var n = 0;
while (--p % 4 > 1 && string.charAt(p) === "=")
++n;
return Math.ceil(string.length * 3) / 4 - n;
};
var b64 = new Array(64);
var s64 = new Array(123);
for (var i = 0; i < 64; )
s64[b64[i] = i < 26 ? i + 65 : i < 52 ? i + 71 : i < 62 ? i - 4 : i - 59 | 43] = i++;
base64.encode = function encode(buffer, start, end) {
var parts = null, chunk = [];
var i2 = 0, j = 0, t;
while (start < end) {
var b = buffer[start++];
switch (j) {
case 0:
chunk[i2++] = b64[b >> 2];
t = (b & 3) << 4;
j = 1;
break;
case 1:
chunk[i2++] = b64[t | b >> 4];
t = (b & 15) << 2;
j = 2;
break;
case 2:
chunk[i2++] = b64[t | b >> 6];
chunk[i2++] = b64[b & 63];
j = 0;
break;
}
if (i2 > 8191) {
(parts || (parts = [])).push(String.fromCharCode.apply(String, chunk));
i2 = 0;
}
}
if (j) {
chunk[i2++] = b64[t];
chunk[i2++] = 61;
if (j === 1)
chunk[i2++] = 61;
}
if (parts) {
if (i2)
parts.push(String.fromCharCode.apply(String, chunk.slice(0, i2)));
return parts.join("");
}
return String.fromCharCode.apply(String, chunk.slice(0, i2));
};
var invalidEncoding = "invalid encoding";
base64.decode = function decode(string, buffer, offset2) {
var start = offset2;
var j = 0, t;
for (var i2 = 0; i2 < string.length; ) {
var c = string.charCodeAt(i2++);
if (c === 61 && j > 1)
break;
if ((c = s64[c]) === undefined)
throw Error(invalidEncoding);
switch (j) {
case 0:
t = c;
j = 1;
break;
case 1:
buffer[offset2++] = t << 2 | (c & 48) >> 4;
t = c;
j = 2;
break;
case 2:
buffer[offset2++] = (t & 15) << 4 | (c & 60) >> 2;
t = c;
j = 3;
break;
case 3:
buffer[offset2++] = (t & 3) << 6 | c;
j = 0;
break;
}
}
if (j === 1)
throw Error(invalidEncoding);
return offset2 - start;
};
base64.test = function test(string) {
return /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(string);
};
}, {}], 3: [function(require2, module2, exports2) {
"use strict";
module2.exports = EventEmitter;
function EventEmitter() {
this._listeners = {};
}
EventEmitter.prototype.on = function on(evt, fn, ctx) {
(this._listeners[evt] || (this._listeners[evt] = [])).push({
fn,
ctx: ctx || this
});
return this;
};
EventEmitter.prototype.off = function off(evt, fn) {
if (evt === undefined)
this._listeners = {};
else {
if (fn === undefined)
this._listeners[evt] = [];
else {
var listeners = this._listeners[evt];
for (var i = 0; i < listeners.length; )
if (listeners[i].fn === fn)
listeners.splice(i, 1);
else
++i;
}
}
return this;
};
EventEmitter.prototype.emit = function emit(evt) {
var listeners = this._listeners[evt];
if (listeners) {
var args = [], i = 1;
for (; i < arguments.length; )
args.push(arguments[i++]);
for (i = 0; i < listeners.length; )
listeners[i].fn.apply(listeners[i++].ctx, args);
}
return this;
};
}, {}], 4: [function(require2, module2, exports2) {
"use strict";
module2.exports = factory(factory);
function factory(exports3) {
if (typeof Float32Array !== "undefined")
(function() {
var f32 = new Float32Array([-0]), f8b = new Uint8Array(f32.buffer), le = f8b[3] === 128;
function writeFloat_f32_cpy(val, buf, pos) {
f32[0] = val;
buf[pos] = f8b[0];
buf[pos + 1] = f8b[1];
buf[pos + 2] = f8b[2];
buf[pos + 3] = f8b[3];
}
function writeFloat_f32_rev(val, buf, pos) {
f32[0] = val;
buf[pos] = f8b[3];
buf[pos + 1] = f8b[2];
buf[pos + 2] = f8b[1];
buf[pos + 3] = f8b[0];
}
exports3.writeFloatLE = le ? writeFloat_f32_cpy : writeFloat_f32_rev;
exports3.writeFloatBE = le ? writeFloat_f32_rev : writeFloat_f32_cpy;
function readFloat_f32_cpy(buf, pos) {
f8b[0] = buf[pos];
f8b[1] = buf[pos + 1];
f8b[2] = buf[pos + 2];
f8b[3] = buf[pos + 3];
return f32[0];
}
function readFloat_f32_rev(buf, pos) {
f8b[3] = buf[pos];
f8b[2] = buf[pos + 1];
f8b[1] = buf[pos + 2];
f8b[0] = buf[pos + 3];
return f32[0];
}
exports3.readFloatLE = le ? readFloat_f32_cpy : readFloat_f32_rev;
exports3.readFloatBE = le ? readFloat_f32_rev : readFloat_f32_cpy;
})();
else
(function() {
function writeFloat_ieee754(writeUint, val, buf, pos) {
var sign2 = val < 0 ? 1 : 0;
if (sign2)
val = -val;
if (val === 0)
writeUint(1 / val > 0 ? 0 : 2147483648, buf, pos);
else if (isNaN(val))
writeUint(2143289344, buf, pos);
else if (val > 34028234663852886e22)
writeUint((sign2 << 31 | 2139095040) >>> 0, buf, pos);
else if (val < 11754943508222875e-54)
writeUint((sign2 << 31 | Math.round(val / 1401298464324817e-60)) >>> 0, buf, pos);
else {
var exponent = Math.floor(Math.log(val) / Math.LN2), mantissa = Math.round(val * Math.pow(2, -exponent) * 8388608) & 8388607;
writeUint((sign2 << 31 | exponent + 127 << 23 | mantissa) >>> 0, buf, pos);
}
}
exports3.writeFloatLE = writeFloat_ieee754.bind(null, writeUintLE);
exports3.writeFloatBE = writeFloat_ieee754.bind(null, writeUintBE);
function readFloat_ieee754(readUint, buf, pos) {
var uint = readUint(buf, pos), sign2 = (uint >> 31) * 2 + 1, exponent = uint >>> 23 & 255, mantissa = uint & 8388607;
return exponent === 255 ? mantissa ? NaN : sign2 * Infinity : exponent === 0 ? sign2 * 1401298464324817e-60 * mantissa : sign2 * Math.pow(2, exponent - 150) * (mantissa + 8388608);
}
exports3.readFloatLE = readFloat_ieee754.bind(null, readUintLE);
exports3.readFloatBE = readFloat_ieee754.bind(null, readUintBE);
})();
if (typeof Float64Array !== "undefined")
(function() {
var f64 = new Float64Array([-0]), f8b = new Uint8Array(f64.buffer), le = f8b[7] === 128;
function writeDouble_f64_cpy(val, buf, pos) {
f64[0] = val;
buf[pos] = f8b[0];
buf[pos + 1] = f8b[1];
buf[pos + 2] = f8b[2];
buf[pos + 3] = f8b[3];
buf[pos + 4] = f8b[4];
buf[pos + 5] = f8b[5];
buf[pos + 6] = f8b[6];
buf[pos + 7] = f8b[7];
}
function writeDouble_f64_rev(val, buf, pos) {
f64[0] = val;
buf[pos] = f8b[7];
buf[pos + 1] = f8b[6];
buf[pos + 2] = f8b[5];
buf[pos + 3] = f8b[4];
buf[pos + 4] = f8b[3];
buf[pos + 5] = f8b[2];
buf[pos + 6] = f8b[1];
buf[pos + 7] = f8b[0];
}
exports3.writeDoubleLE = le ? writeDouble_f64_cpy : writeDouble_f64_rev;
exports3.writeDoubleBE = le ? writeDouble_f64_rev : writeDouble_f64_cpy;
function readDouble_f64_cpy(buf, pos) {
f8b[0] = buf[pos];
f8b[1] = buf[pos + 1];
f8b[2] = buf[pos + 2];
f8b[3] = buf[pos + 3];
f8b[4] = buf[pos + 4];
f8b[5] = buf[pos + 5];
f8b[6] = buf[pos + 6];
f8b[7] = buf[pos + 7];
return f64[0];
}
function readDouble_f64_rev(buf, pos) {
f8b[7] = buf[pos];
f8b[6] = buf[pos + 1];
f8b[5] = buf[pos + 2];
f8b[4] = buf[pos + 3];
f8b[3] = buf[pos + 4];
f8b[2] = buf[pos + 5];
f8b[1] = buf[pos + 6];
f8b[0] = buf[pos + 7];
return f64[0];
}
exports3.readDoubleLE = le ? readDouble_f64_cpy : readDouble_f64_rev;
exports3.readDoubleBE = le ? readDouble_f64_rev : readDouble_f64_cpy;
})();
else
(function() {
function writeDouble_ieee754(writeUint, off0, off1, val, buf, pos) {
var sign2 = val < 0 ? 1 : 0;
if (sign2)
val = -val;
if (val === 0) {
writeUint(0, buf, pos + off0);
writeUint(1 / val > 0 ? 0 : 2147483648, buf, pos + off1);
} else if (isNaN(val)) {
writeUint(0, buf, pos + off0);
writeUint(2146959360, buf, pos + off1);
} else if (val > 17976931348623157e292) {
writeUint(0, buf, pos + off0);
writeUint((sign2 << 31 | 2146435072) >>> 0, buf, pos + off1);
} else {
var mantissa;
if (val < 22250738585072014e-324) {
mantissa = val / 5e-324;
writeUint(mantissa >>> 0, buf, pos + off0);
writeUint((sign2 << 31 | mantissa / 4294967296) >>> 0, buf, pos + off1);
} else {
var exponent = Math.floor(Math.log(val) / Math.LN2);
if (exponent === 1024)
exponent = 1023;
mantissa = val * Math.pow(2, -exponent);
writeUint(mantissa * 4503599627370496 >>> 0, buf, pos + off0);
writeUint((sign2 << 31 | exponent + 1023 << 20 | mantissa * 1048576 & 1048575) >>> 0, buf, pos + off1);
}
}
}
exports3.writeDoubleLE = writeDouble_ieee754.bind(null, writeUintLE, 0, 4);
exports3.writeDoubleBE = writeDouble_ieee754.bind(null, writeUintBE, 4, 0);
function readDouble_ieee754(readUint, off0, off1, buf, pos) {
var lo = readUint(buf, pos + off0), hi = readUint(buf, pos + off1);
var sign2 = (hi >> 31) * 2 + 1, exponent = hi >>> 20 & 2047, mantissa = 4294967296 * (hi & 1048575) + lo;
return exponent === 2047 ? mantissa ? NaN : sign2 * Infinity : exponent === 0 ? sign2 * 5e-324 * mantissa : sign2 * Math.pow(2, exponent - 1075) * (mantissa + 4503599627370496);
}
exports3.readDoubleLE = readDouble_ieee754.bind(null, readUintLE, 0, 4);
exports3.readDoubleBE = readDouble_ieee754.bind(null, readUintBE, 4, 0);
})();
return exports3;
}
function writeUintLE(val, buf, pos) {
buf[pos] = val & 255;
buf[pos + 1] = val >>> 8 & 255;
buf[pos + 2] = val >>> 16 & 255;
buf[pos + 3] = val >>> 24;
}
function writeUintBE(val, buf, pos) {
buf[pos] = val >>> 24;
buf[pos + 1] = val >>> 16 & 255;
buf[pos + 2] = val >>> 8 & 255;
buf[pos + 3] = val & 255;
}
function readUintLE(buf, pos) {
return (buf[pos] | buf[pos + 1] << 8 | buf[pos + 2] << 16 | buf[pos + 3] << 24) >>> 0;
}
function readUintBE(buf, pos) {
return (buf[pos] << 24 | buf[pos + 1] << 16 | buf[pos + 2] << 8 | buf[pos + 3]) >>> 0;
}
}, {}], 5: [function(require, module, exports) {
"use strict";
module.exports = inquire;
function inquire(moduleName) {
try {
var mod = eval("quire".replace(/^/, "re"))(moduleName);
if (mod && (mod.length || Object.keys(mod).length))
return mod;
} catch (e) {
}
return null;
}
}, {}], 6: [function(require2, module2, exports2) {
"use strict";
module2.exports = pool2;
function pool2(alloc, slice, size) {
var SIZE = size || 8192;
var MAX = SIZE >>> 1;
var slab = null;
var offset2 = SIZE;
return function pool_alloc(size2) {
if (size2 < 1 || size2 > MAX)
return alloc(size2);
if (offset2 + size2 > SIZE) {
slab = alloc(SIZE);
offset2 = 0;
}
var buf = slice.call(slab, offset2, offset2 += size2);
if (offset2 & 7)
offset2 = (offset2 | 7) + 1;
return buf;
};
}
}, {}], 7: [function(require2, module2, exports2) {
"use strict";
var utf8 = exports2;
utf8.length = function utf8_length(string) {
var len = 0, c = 0;
for (var i = 0; i < string.length; ++i) {
c = string.charCodeAt(i);
if (c < 128)
len += 1;
else if (c < 2048)
len += 2;
else if ((c & 64512) === 55296 && (string.charCodeAt(i + 1) & 64512) === 56320) {
++i;
len += 4;
} else
len += 3;
}
return len;
};
utf8.read = function utf8_read(buffer, start, end) {
var len = end - start;
if (len < 1)
return "";
var parts = null, chunk = [], i = 0, t;
while (start < end) {
t = buffer[start++];
if (t < 128)
chunk[i++] = t;
else if (t > 191 && t < 224)
chunk[i++] = (t & 31) << 6 | buffer[start++] & 63;
else if (t > 239 && t < 365) {
t = ((t & 7) << 18 | (buffer[start++] & 63) << 12 | (buffer[start++] & 63) << 6 | buffer[start++] & 63) - 65536;
chunk[i++] = 55296 + (t >> 10);
chunk[i++] = 56320 + (t & 1023);
} else
chunk[i++] = (t & 15) << 12 | (buffer[start++] & 63) << 6 | buffer[start++] & 63;
if (i > 8191) {
(parts || (parts = [])).push(String.fromCharCode.apply(String, chunk));
i = 0;
}
}
if (parts) {
if (i)
parts.push(String.fromCharCode.apply(String, chunk.slice(0, i)));
return parts.join("");
}
return String.fromCharCode.apply(String, chunk.slice(0, i));
};
utf8.write = function utf8_write(string, buffer, offset2) {
var start = offset2, c14, c22;
for (var i = 0; i < string.length; ++i) {
c14 = string.charCodeAt(i);
if (c14 < 128) {
buffer[offset2++] = c14;
} else if (c14 < 2048) {
buffer[offset2++] = c14 >> 6 | 192;
buffer[offset2++] = c14 & 63 | 128;
} else if ((c14 & 64512) === 55296 && ((c22 = string.charCodeAt(i + 1)) & 64512) === 56320) {
c14 = 65536 + ((c14 & 1023) << 10) + (c22 & 1023);
++i;
buffer[offset2++] = c14 >> 18 | 240;
buffer[offset2++] = c14 >> 12 & 63 | 128;
buffer[offset2++] = c14 >> 6 & 63 | 128;
buffer[offset2++] = c14 & 63 | 128;
} else {
buffer[offset2++] = c14 >> 12 | 224;
buffer[offset2++] = c14 >> 6 & 63 | 128;
buffer[offset2++] = c14 & 63 | 128;
}
}
return offset2 - start;
};
}, {}], 8: [function(require2, module2, exports2) {
"use strict";
var protobuf2 = exports2;
protobuf2.build = "minimal";
protobuf2.Writer = require2(16);
protobuf2.BufferWriter = require2(17);
protobuf2.Reader = require2(9);
protobuf2.BufferReader = require2(10);
protobuf2.util = require2(15);
protobuf2.rpc = require2(12);
protobuf2.roots = require2(11);
protobuf2.configure = configure2;
function configure2() {
protobuf2.util._configure();
protobuf2.Writer._configure(protobuf2.BufferWriter);
protobuf2.Reader._configure(protobuf2.BufferReader);
}
configure2();
}, { "10": 10, "11": 11, "12": 12, "15": 15, "16": 16, "17": 17, "9": 9 }], 9: [function(require2, module2, exports2) {
"use strict";
module2.exports = Reader2;
var util = require2(15);
var BufferReader;
var LongBits = util.LongBits, utf8 = util.utf8;
function indexOutOfRange(reader, writeLength) {
return RangeError("index out of range: " + reader.pos + " + " + (writeLength || 1) + " > " + reader.len);
}
function Reader2(buffer) {
this.buf = buffer;
this.pos = 0;
this.len = buffer.length;
}
var create_array = typeof Uint8Array !== "undefined" ? function create_typed_array(buffer) {
if (buffer instanceof Uint8Array || Array.isArray(buffer))
return new Reader2(buffer);
throw Error("illegal buffer");
} : function create_array2(buffer) {
if (Array.isArray(buffer))
return new Reader2(buffer);
throw Error("illegal buffer");
};
var create = function create2() {
return util.Buffer ? function create_buffer_setup(buffer) {
return (Reader2.create = function create_buffer(buffer2) {
return util.Buffer.isBuffer(buffer2) ? new BufferReader(buffer2) : create_array(buffer2);
})(buffer);
} : create_array;
};
Reader2.create = create();
Reader2.prototype._slice = util.Array.prototype.subarray || util.Array.prototype.slice;
Reader2.prototype.uint32 = function read_uint32_setup() {
var value = 4294967295;
return function read_uint32() {
value = (this.buf[this.pos] & 127) >>> 0;
if (this.buf[this.pos++] < 128)
return value;
value = (value | (this.buf[this.pos] & 127) << 7) >>> 0;
if (this.buf[this.pos++] < 128)
return value;
value = (value | (this.buf[this.pos] & 127) << 14) >>> 0;
if (this.buf[this.pos++] < 128)
return value;
value = (value | (this.buf[this.pos] & 127) << 21) >>> 0;
if (this.buf[this.pos++] < 128)
return value;
value = (value | (this.buf[this.pos] & 15) << 28) >>> 0;
if (this.buf[this.pos++] < 128)
return value;
if ((this.pos += 5) > this.len) {
this.pos = this.len;
throw indexOutOfRange(this, 10);
}
return value;
};
}();
Reader2.prototype.int32 = function read_int32() {
return this.uint32() | 0;
};
Reader2.prototype.sint32 = function read_sint32() {
var value = this.uint32();
return value >>> 1 ^ -(value & 1) | 0;
};
function readLongVarint() {
var bits = new LongBits(0, 0);
var i = 0;
if (this.len - this.pos > 4) {
for (; i < 4; ++i) {
bits.lo = (bits.lo | (this.buf[this.pos] & 127) << i * 7) >>> 0;
if (this.buf[this.pos++] < 128)
return bits;
}
bits.lo = (bits.lo | (this.buf[this.pos] & 127) << 28) >>> 0;
bits.hi = (bits.hi | (this.buf[this.pos] & 127) >> 4) >>> 0;
if (this.buf[this.pos++] < 128)
return bits;
i = 0;
} else {
for (; i < 3; ++i) {
if (this.pos >= this.len)
throw indexOutOfRange(this);
bits.lo = (bits.lo | (this.buf[this.pos] & 127) << i * 7) >>> 0;
if (this.buf[this.pos++] < 128)
return bits;
}
bits.lo = (bits.lo | (this.buf[this.pos++] & 127) << i * 7) >>> 0;
return bits;
}
if (this.len - this.pos > 4) {
for (; i < 5; ++i) {
bits.hi = (bits.hi | (this.buf[this.pos] & 127) << i * 7 + 3) >>> 0;
if (this.buf[this.pos++] < 128)
return bits;
}
} else {
for (; i < 5; ++i) {
if (this.pos >= this.len)
throw indexOutOfRange(this);
bits.hi = (bits.hi | (this.buf[this.pos] & 127) << i * 7 + 3) >>> 0;
if (this.buf[this.pos++] < 128)
return bits;
}
}
throw Error("invalid varint encoding");
}
Reader2.prototype.bool = function read_bool() {
return this.uint32() !== 0;
};
function readFixed32_end(buf, end) {
return (buf[end - 4] | buf[end - 3] << 8 | buf[end - 2] << 16 | buf[end - 1] << 24) >>> 0;
}
Reader2.prototype.fixed32 = function read_fixed32() {
if (this.pos + 4 > this.len)
throw indexOutOfRange(this, 4);
return readFixed32_end(this.buf, this.pos += 4);
};
Reader2.prototype.sfixed32 = function read_sfixed32() {
if (this.pos + 4 > this.len)
throw indexOutOfRange(this, 4);
return readFixed32_end(this.buf, this.pos += 4) | 0;
};
function readFixed64() {
if (this.pos + 8 > this.len)
throw indexOutOfRange(this, 8);
return new LongBits(readFixed32_end(this.buf, this.pos += 4), readFixed32_end(this.buf, this.pos += 4));
}
Reader2.prototype.float = function read_float() {
if (this.pos + 4 > this.len)
throw indexOutOfRange(this, 4);
var value = util.float.readFloatLE(this.buf, this.pos);
this.pos += 4;
return value;
};
Reader2.prototype.double = function read_double() {
if (this.pos + 8 > this.len)
throw indexOutOfRange(this, 4);
var value = util.float.readDoubleLE(this.buf, this.pos);
this.pos += 8;
return value;
};
Reader2.prototype.bytes = function read_bytes() {
var length3 = this.uint32(), start = this.pos, end = this.pos + length3;
if (end > this.len)
throw indexOutOfRange(this, length3);
this.pos += length3;
if (Array.isArray(this.buf))
return this.buf.slice(start, end);
return start === end ? new this.buf.constructor(0) : this._slice.call(this.buf, start, end);
};
Reader2.prototype.string = function read_string() {
var bytes = this.bytes();
return utf8.read(bytes, 0, bytes.length);
};
Reader2.prototype.skip = function skip(length3) {
if (typeof length3 === "number") {
if (this.pos + length3 > this.len)
throw indexOutOfRange(this, length3);
this.pos += length3;
} else {
do {
if (this.pos >= this.len)
throw indexOutOfRange(this);
} while (this.buf[this.pos++] & 128);
}
return this;
};
Reader2.prototype.skipType = function(wireType) {
switch (wireType) {
case 0:
this.skip();
break;
case 1:
this.skip(8);
break;
case 2:
this.skip(this.uint32());
break;
case 3:
while ((wireType = this.uint32() & 7) !== 4) {
this.skipType(wireType);
}
break;
case 5:
this.skip(4);
break;
default:
throw Error("invalid wire type " + wireType + " at offset " + this.pos);
}
return this;
};
Reader2._configure = function(BufferReader_) {
BufferReader = BufferReader_;
Reader2.create = create();
BufferReader._configure();
var fn = util.Long ? "toLong" : "toNumber";
util.merge(Reader2.prototype, {
int64: function read_int64() {
return readLongVarint.call(this)[fn](false);
},
uint64: function read_uint64() {
return readLongVarint.call(this)[fn](true);
},
sint64: function read_sint64() {
return readLongVarint.call(this).zzDecode()[fn](false);
},
fixed64: function read_fixed64() {
return readFixed64.call(this)[fn](true);
},
sfixed64: function read_sfixed64() {
return readFixed64.call(this)[fn](false);
}
});
};
}, { "15": 15 }], 10: [function(require2, module2, exports2) {
"use strict";
module2.exports = BufferReader;
var Reader2 = require2(9);
(BufferReader.prototype = Object.create(Reader2.prototype)).constructor = BufferReader;
var util = require2(15);
function BufferReader(buffer) {
Reader2.call(this, buffer);
}
BufferReader._configure = function() {
if (util.Buffer)
BufferReader.prototype._slice = util.Buffer.prototype.slice;
};
BufferReader.prototype.string = function read_string_buffer() {
var len = this.uint32();
return this.buf.utf8Slice ? this.buf.utf8Slice(this.pos, this.pos = Math.min(this.pos + len, this.len)) : this.buf.toString("utf-8", this.pos, this.pos = Math.min(this.pos + len, this.len));
};
BufferReader._configure();
}, { "15": 15, "9": 9 }], 11: [function(require2, module2, exports2) {
"use strict";
module2.exports = {};
}, {}], 12: [function(require2, module2, exports2) {
"use strict";
var rpc = exports2;
rpc.Service = require2(13);
}, { "13": 13 }], 13: [function(require2, module2, exports2) {
"use strict";
module2.exports = Service;
var util = require2(15);
(Service.prototype = Object.create(util.EventEmitter.prototype)).constructor = Service;
function Service(rpcImpl, requestDelimited, responseDelimited) {
if (typeof rpcImpl !== "function")
throw TypeError("rpcImpl must be a function");
util.EventEmitter.call(this);
this.rpcImpl = rpcImpl;
this.requestDelimited = Boolean(requestDelimited);
this.responseDelimited = Boolean(responseDelimited);
}
Service.prototype.rpcCall = function rpcCall(method, requestCtor, responseCtor, request, callback) {
if (!request)
throw TypeError("request must be specified");
var self2 = this;
if (!callback)
return util.asPromise(rpcCall, self2, method, requestCtor, responseCtor, request);
if (!self2.rpcImpl) {
setTimeout(function() {
callback(Error("already ended"));
}, 0);
return undefined;
}
try {
return self2.rpcImpl(
method,
requestCtor[self2.requestDelimited ? "encodeDelimited" : "encode"](request).finish(),
function rpcCallback(err, response) {
if (err) {
self2.emit("error", err, method);
return callback(err);
}
if (response === null) {
self2.end(true);
return undefined;
}
if (!(response instanceof responseCtor)) {
try {
response = responseCtor[self2.responseDelimited ? "decodeDelimited" : "decode"](response);
} catch (err2) {
self2.emit("error", err2, method);
return callback(err2);
}
}
self2.emit("data", response, method);
return callback(null, response);
}
);
} catch (err) {
self2.emit("error", err, method);
setTimeout(function() {
callback(err);
}, 0);
return undefined;
}
};
Service.prototype.end = function end(endedByRPC) {
if (this.rpcImpl) {
if (!endedByRPC)
this.rpcImpl(null, null, null);
this.rpcImpl = null;
this.emit("end").off();
}
return this;
};
}, { "15": 15 }], 14: [function(require2, module2, exports2) {
"use strict";
module2.exports = LongBits;
var util = require2(15);
function LongBits(lo, hi) {
this.lo = lo >>> 0;
this.hi = hi >>> 0;
}
var zero = LongBits.zero = new LongBits(0, 0);
zero.toNumber = function() {
return 0;
};
zero.zzEncode = zero.zzDecode = function() {
return this;
};
zero.length = function() {
return 1;
};
var zeroHash = LongBits.zeroHash = "\0\0\0\0\0\0\0\0";
LongBits.fromNumber = function fromNumber(value) {
if (value === 0)
return zero;
var sign2 = value < 0;
if (sign2)
value = -value;
var lo = value >>> 0, hi = (value - lo) / 4294967296 >>> 0;
if (sign2) {
hi = ~hi >>> 0;
lo = ~lo >>> 0;
if (++lo > 4294967295) {
lo = 0;
if (++hi > 4294967295)
hi = 0;
}
}
return new LongBits(lo, hi);
};
LongBits.from = function from(value) {
if (typeof value === "number")
return LongBits.fromNumber(value);
if (util.isString(value)) {
if (util.Long)
value = util.Long.fromString(value);
else
return LongBits.fromNumber(parseInt(value, 10));
}
return value.low || value.high ? new LongBits(value.low >>> 0, value.high >>> 0) : zero;
};
LongBits.prototype.toNumber = function toNumber(unsigned) {
if (!unsigned && this.hi >>> 31) {
var lo = ~this.lo + 1 >>> 0, hi = ~this.hi >>> 0;
if (!lo)
hi = hi + 1 >>> 0;
return -(lo + hi * 4294967296);
}
return this.lo + this.hi * 4294967296;
};
LongBits.prototype.toLong = function toLong(unsigned) {
return util.Long ? new util.Long(this.lo | 0, this.hi | 0, Boolean(unsigned)) : { low: this.lo | 0, high: this.hi | 0, unsigned: Boolean(unsigned) };
};
var charCodeAt = String.prototype.charCodeAt;
LongBits.fromHash = function fromHash(hash2) {
if (hash2 === zeroHash)
return zero;
return new LongBits(
(charCodeAt.call(hash2, 0) | charCodeAt.call(hash2, 1) << 8 | charCodeAt.call(hash2, 2) << 16 | charCodeAt.call(hash2, 3) << 24) >>> 0,
(charCodeAt.call(hash2, 4) | charCodeAt.call(hash2, 5) << 8 | charCodeAt.call(hash2, 6) << 16 | charCodeAt.call(hash2, 7) << 24) >>> 0
);
};
LongBits.prototype.toHash = function toHash() {
return String.fromCharCode(
this.lo & 255,
this.lo >>> 8 & 255,
this.lo >>> 16 & 255,
this.lo >>> 24,
this.hi & 255,
this.hi >>> 8 & 255,
this.hi >>> 16 & 255,
this.hi >>> 24
);
};
LongBits.prototype.zzEncode = function zzEncode() {
var mask = this.hi >> 31;
this.hi = ((this.hi << 1 | this.lo >>> 31) ^ mask) >>> 0;
this.lo = (this.lo << 1 ^ mask) >>> 0;
return this;
};
LongBits.prototype.zzDecode = function zzDecode() {
var mask = -(this.lo & 1);
this.lo = ((this.lo >>> 1 | this.hi << 31) ^ mask) >>> 0;
this.hi = (this.hi >>> 1 ^ mask) >>> 0;
return this;
};
LongBits.prototype.length = function length3() {
var part0 = this.lo, part1 = (this.lo >>> 28 | this.hi << 4) >>> 0, part2 = this.hi >>> 24;
return part2 === 0 ? part1 === 0 ? part0 < 16384 ? part0 < 128 ? 1 : 2 : part0 < 2097152 ? 3 : 4 : part1 < 16384 ? part1 < 128 ? 5 : 6 : part1 < 2097152 ? 7 : 8 : part2 < 128 ? 9 : 10;
};
}, { "15": 15 }], 15: [function(require2, module2, exports2) {
"use strict";
var util = exports2;
util.asPromise = require2(1);
util.base64 = require2(2);
util.EventEmitter = require2(3);
util.float = require2(4);
util.inquire = require2(5);
util.utf8 = require2(7);
util.pool = require2(6);
util.LongBits = require2(14);
util.isNode = Boolean(typeof global !== "undefined" && global && global.process && global.process.versions && global.process.versions.node);
util.global = util.isNode && global || typeof window !== "undefined" && window || typeof self !== "undefined" && self || this;
util.emptyArray = Object.freeze ? Object.freeze([]) : [];
util.emptyObject = Object.freeze ? Object.freeze({}) : {};
util.isInteger = Number.isInteger || function isInteger(value) {
return typeof value === "number" && isFinite(value) && Math.floor(value) === value;
};
util.isString = function isString(value) {
return typeof value === "string" || value instanceof String;
};
util.isObject = function isObject(value) {
return value && typeof value === "object";
};
util.isset = util.isSet = function isSet(obj, prop) {
var value = obj[prop];
if (value != null && obj.hasOwnProperty(prop))
return typeof value !== "object" || (Array.isArray(value) ? value.length : Object.keys(value).length) > 0;
return false;
};
util.Buffer = function() {
try {
var Buffer3 = util.inquire("buffer").Buffer;
return Buffer3.prototype.utf8Write ? Buffer3 : null;
} catch (e) {
return null;
}
}();
util._Buffer_from = null;
util._Buffer_allocUnsafe = null;
util.newBuffer = function newBuffer(sizeOrArray) {
return typeof sizeOrArray === "number" ? util.Buffer ? util._Buffer_allocUnsafe(sizeOrArray) : new util.Array(sizeOrArray) : util.Buffer ? util._Buffer_from(sizeOrArray) : typeof Uint8Array === "undefined" ? sizeOrArray : new Uint8Array(sizeOrArray);
};
util.Array = typeof Uint8Array !== "undefined" ? Uint8Array : Array;
util.Long = util.global.dcodeIO && util.global.dcodeIO.Long || util.global.Long || util.inquire("long");
util.key2Re = /^true|false|0|1$/;
util.key32Re = /^-?(?:0|[1-9][0-9]*)$/;
util.key64Re = /^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/;
util.longToHash = function longToHash(value) {
return value ? util.LongBits.from(value).toHash() : util.LongBits.zeroHash;
};
util.longFromHash = function longFromHash(hash2, unsigned) {
var bits = util.LongBits.fromHash(hash2);
if (util.Long)
return util.Long.fromBits(bits.lo, bits.hi, unsigned);
return bits.toNumber(Boolean(unsigned));
};
function merge2(dst, src, ifNotSet) {
for (var keys = Object.keys(src), i = 0; i < keys.length; ++i)
if (dst[keys[i]] === undefined || !ifNotSet)
dst[keys[i]] = src[keys[i]];
return dst;
}
util.merge = merge2;
util.lcFirst = function lcFirst(str) {
return str.charAt(0).toLowerCase() + str.substring(1);
};
function newError(name) {
function CustomError(message, properties) {
if (!(this instanceof CustomError))
return new CustomError(message, properties);
Object.defineProperty(this, "message", { get: function() {
return message;
} });
if (Error.captureStackTrace)
Error.captureStackTrace(this, CustomError);
else
Object.defineProperty(this, "stack", { value: new Error().stack || "" });
if (properties)
merge2(this, properties);
}
CustomError.prototype = Object.create(Error.prototype, {
constructor: {
value: CustomError,
writable: true,
enumerable: false,
configurable: true
},
name: {
get() {
return name;
},
set: undefined,
enumerable: false,
configurable: true
},
toString: {
value() {
return this.name + ": " + this.message;
},
writable: true,
enumerable: false,
configurable: true
}
});
return CustomError;
}
util.newError = newError;
util.ProtocolError = newError("ProtocolError");
util.oneOfGetter = function getOneOf(fieldNames) {
var fieldMap = {};
for (var i = 0; i < fieldNames.length; ++i)
fieldMap[fieldNames[i]] = 1;
return function() {
for (var keys = Object.keys(this), i2 = keys.length - 1; i2 > -1; --i2)
if (fieldMap[keys[i2]] === 1 && this[keys[i2]] !== undefined && this[keys[i2]] !== null)
return keys[i2];
};
};
util.oneOfSetter = function setOneOf(fieldNames) {
return function(name) {
for (var i = 0; i < fieldNames.length; ++i)
if (fieldNames[i] !== name)
delete this[fieldNames[i]];
};
};
util.toJSONOptions = {
longs: String,
enums: String,
bytes: String,
json: true
};
util._configure = function() {
var Buffer3 = util.Buffer;
if (!Buffer3) {
util._Buffer_from = util._Buffer_allocUnsafe = null;
return;
}
util._Buffer_from = Buffer3.from !== Uint8Array.from && Buffer3.from || function Buffer_from(value, encoding) {
return new Buffer3(value, encoding);
};
util._Buffer_allocUnsafe = Buffer3.allocUnsafe || function Buffer_allocUnsafe(size) {
return new Buffer3(size);
};
};
}, { "1": 1, "14": 14, "2": 2, "3": 3, "4": 4, "5": 5, "6": 6, "7": 7 }], 16: [function(require2, module2, exports2) {
"use strict";
module2.exports = Writer2;
var util = require2(15);
var BufferWriter;
var LongBits = util.LongBits, base64 = util.base64, utf8 = util.utf8;
function Op(fn, len, val) {
this.fn = fn;
this.len = len;
this.next = undefined;
this.val = val;
}
function noop() {
}
function State(writer) {
this.head = writer.head;
this.tail = writer.tail;
this.len = writer.len;
this.next = writer.states;
}
function Writer2() {
this.len = 0;
this.head = new Op(noop, 0, 0);
this.tail = this.head;
this.states = null;
}
var create = function create2() {
return util.Buffer ? function create_buffer_setup() {
return (Writer2.create = function create_buffer() {
return new BufferWriter();
})();
} : function create_array() {
return new Writer2();
};
};
Writer2.create = create();
Writer2.alloc = function alloc(size) {
return new util.Array(size);
};
if (util.Array !== Array)
Writer2.alloc = util.pool(Writer2.alloc, util.Array.prototype.subarray);
Writer2.prototype._push = function push(fn, len, val) {
this.tail = this.tail.next = new Op(fn, len, val);
this.len += len;
return this;
};
function writeByte(val, buf, pos) {
buf[pos] = val & 255;
}
function writeVarint32(val, buf, pos) {
while (val > 127) {
buf[pos++] = val & 127 | 128;
val >>>= 7;
}
buf[pos] = val;
}
function VarintOp(len, val) {
this.len = len;
this.next = undefined;
this.val = val;
}
VarintOp.prototype = Object.create(Op.prototype);
VarintOp.prototype.fn = writeVarint32;
Writer2.prototype.uint32 = function write_uint32(value) {
this.len += (this.tail = this.tail.next = new VarintOp(
(value = value >>> 0) < 128 ? 1 : value < 16384 ? 2 : value < 2097152 ? 3 : value < 268435456 ? 4 : 5,
value
)).len;
return this;
};
Writer2.prototype.int32 = function write_int32(value) {
return value < 0 ? this._push(writeVarint64, 10, LongBits.fromNumber(value)) : this.uint32(value);
};
Writer2.prototype.sint32 = function write_sint32(value) {
return this.uint32((value << 1 ^ value >> 31) >>> 0);
};
function writeVarint64(val, buf, pos) {
while (val.hi) {
buf[pos++] = val.lo & 127 | 128;
val.lo = (val.lo >>> 7 | val.hi << 25) >>> 0;
val.hi >>>= 7;
}
while (val.lo > 127) {
buf[pos++] = val.lo & 127 | 128;
val.lo = val.lo >>> 7;
}
buf[pos++] = val.lo;
}
Writer2.prototype.uint64 = function write_uint64(value) {
var bits = LongBits.from(value);
return this._push(writeVarint64, bits.length(), bits);
};
Writer2.prototype.int64 = Writer2.prototype.uint64;
Writer2.prototype.sint64 = function write_sint64(value) {
var bits = LongBits.from(value).zzEncode();
return this._push(writeVarint64, bits.length(), bits);
};
Writer2.prototype.bool = function write_bool(value) {
return this._push(writeByte, 1, value ? 1 : 0);
};
function writeFixed32(val, buf, pos) {
buf[pos] = val & 255;
buf[pos + 1] = val >>> 8 & 255;
buf[pos + 2] = val >>> 16 & 255;
buf[pos + 3] = val >>> 24;
}
Writer2.prototype.fixed32 = function write_fixed32(value) {
return this._push(writeFixed32, 4, value >>> 0);
};
Writer2.prototype.sfixed32 = Writer2.prototype.fixed32;
Writer2.prototype.fixed64 = function write_fixed64(value) {
var bits = LongBits.from(value);
return this._push(writeFixed32, 4, bits.lo)._push(writeFixed32, 4, bits.hi);
};
Writer2.prototype.sfixed64 = Writer2.prototype.fixed64;
Writer2.prototype.float = function write_float(value) {
return this._push(util.float.writeFloatLE, 4, value);
};
Writer2.prototype.double = function write_double(value) {
return this._push(util.float.writeDoubleLE, 8, value);
};
var writeBytes = util.Array.prototype.set ? function writeBytes_set(val, buf, pos) {
buf.set(val, pos);
} : function writeBytes_for(val, buf, pos) {
for (var i = 0; i < val.length; ++i)
buf[pos + i] = val[i];
};
Writer2.prototype.bytes = function write_bytes(value) {
var len = value.length >>> 0;
if (!len)
return this._push(writeByte, 1, 0);
if (util.isString(value)) {
var buf = Writer2.alloc(len = base64.length(value));
base64.decode(value, buf, 0);
value = buf;
}
return this.uint32(len)._push(writeBytes, len, value);
};
Writer2.prototype.string = function write_string(value) {
var len = utf8.length(value);
return len ? this.uint32(len)._push(utf8.write, len, value) : this._push(writeByte, 1, 0);
};
Writer2.prototype.fork = function fork() {
this.states = new State(this);
this.head = this.tail = new Op(noop, 0, 0);
this.len = 0;
return this;
};
Writer2.prototype.reset = function reset() {
if (this.states) {
this.head = this.states.head;
this.tail = this.states.tail;
this.len = this.states.len;
this.states = this.states.next;
} else {
this.head = this.tail = new Op(noop, 0, 0);
this.len = 0;
}
return this;
};
Writer2.prototype.ldelim = function ldelim() {
var head = this.head, tail = this.tail, len = this.len;
this.reset().uint32(len);
if (len) {
this.tail.next = head.next;
this.tail = tail;
this.len += len;
}
return this;
};
Writer2.prototype.finish = function finish() {
var head = this.head.next, buf = this.constructor.alloc(this.len), pos = 0;
while (head) {
head.fn(head.val, buf, pos);
pos += head.len;
head = head.next;
}
return buf;
};
Writer2._configure = function(BufferWriter_) {
BufferWriter = BufferWriter_;
Writer2.create = create();
BufferWriter._configure();
};
}, { "15": 15 }], 17: [function(require2, module2, exports2) {
"use strict";
module2.exports = BufferWriter;
var Writer2 = require2(16);
(BufferWriter.prototype = Object.create(Writer2.prototype)).constructor = BufferWriter;
var util = require2(15);
function BufferWriter() {
Writer2.call(this);
}
BufferWriter._configure = function() {
BufferWriter.alloc = util._Buffer_allocUnsafe;
BufferWriter.writeBytesBuffer = util.Buffer && util.Buffer.prototype instanceof Uint8Array && util.Buffer.prototype.set.name === "set" ? function writeBytesBuffer_set(val, buf, pos) {
buf.set(val, pos);
} : function writeBytesBuffer_copy(val, buf, pos) {
if (val.copy)
val.copy(buf, pos, 0, val.length);
else
for (var i = 0; i < val.length; )
buf[pos++] = val[i++];
};
};
BufferWriter.prototype.bytes = function write_bytes_buffer(value) {
if (util.isString(value))
value = util._Buffer_from(value, "base64");
var len = value.length >>> 0;
this.uint32(len);
if (len)
this._push(BufferWriter.writeBytesBuffer, len, value);
return this;
};
function writeStringBuffer(val, buf, pos) {
if (val.length < 40)
util.utf8.write(val, buf, pos);
else if (buf.utf8Write)
buf.utf8Write(val, pos);
else
buf.write(val, pos);
}
BufferWriter.prototype.string = function write_string_buffer(value) {
var len = util.Buffer.byteLength(value);
this.uint32(len);
if (len)
this._push(writeStringBuffer, len, value);
return this;
};
BufferWriter._configure();
}, { "15": 15, "16": 16 }] }, {}, [8]);
})();
}
});
// node_modules/rbush/rbush.js
var require_rbush = __commonJS({
"node_modules/rbush/rbush.js"(exports2, module2) {
(function(global2, factory) {
typeof exports2 === "object" && typeof module2 !== "undefined" ? module2.exports = factory() : typeof define === "function" && define.amd ? define(factory) : (global2 = global2 || self, global2.RBush = factory());
})(exports2, function() {
"use strict";
function quickselect(arr, k, left, right, compare) {
quickselectStep(arr, k, left || 0, right || arr.length - 1, compare || defaultCompare);
}
function quickselectStep(arr, k, left, right, compare) {
while (right > left) {
if (right - left > 600) {
var n = right - left + 1;
var m = k - left + 1;
var z = Math.log(n);
var s = 0.5 * Math.exp(2 * z / 3);
var sd = 0.5 * Math.sqrt(z * s * (n - s) / n) * (m - n / 2 < 0 ? -1 : 1);
var newLeft = Math.max(left, Math.floor(k - m * s / n + sd));
var newRight = Math.min(right, Math.floor(k + (n - m) * s / n + sd));
quickselectStep(arr, k, newLeft, newRight, compare);
}
var t = arr[k];
var i = left;
var j = right;
swap3(arr, left, k);
if (compare(arr[right], t) > 0) {
swap3(arr, left, right);
}
while (i < j) {
swap3(arr, i, j);
i++;
j--;
while (compare(arr[i], t) < 0) {
i++;
}
while (compare(arr[j], t) > 0) {
j--;
}
}
if (compare(arr[left], t) === 0) {
swap3(arr, left, j);
} else {
j++;
swap3(arr, j, right);
}
if (j <= k) {
left = j + 1;
}
if (k <= j) {
right = j - 1;
}
}
}
function swap3(arr, i, j) {
var tmp2 = arr[i];
arr[i] = arr[j];
arr[j] = tmp2;
}
function defaultCompare(a3, b) {
return a3 < b ? -1 : a3 > b ? 1 : 0;
}
var RBush = function RBush2(maxEntries) {
if (maxEntries === void 0)
maxEntries = 9;
this._maxEntries = Math.max(4, maxEntries);
this._minEntries = Math.max(2, Math.ceil(this._maxEntries * 0.4));
this.clear();
};
RBush.prototype.all = function all() {
return this._all(this.data, []);
};
RBush.prototype.search = function search(bbox) {
var node = this.data;
var result = [];
if (!intersects(bbox, node)) {
return result;
}
var toBBox = this.toBBox;
var nodesToSearch = [];
while (node) {
for (var i = 0; i < node.children.length; i++) {
var child = node.children[i];
var childBBox = node.leaf ? toBBox(child) : child;
if (intersects(bbox, childBBox)) {
if (node.leaf) {
result.push(child);
} else if (contains2(bbox, childBBox)) {
this._all(child, result);
} else {
nodesToSearch.push(child);
}
}
}
node = nodesToSearch.pop();
}
return result;
};
RBush.prototype.collides = function collides(bbox) {
var node = this.data;
if (!intersects(bbox, node)) {
return false;
}
var nodesToSearch = [];
while (node) {
for (var i = 0; i < node.children.length; i++) {
var child = node.children[i];
var childBBox = node.leaf ? this.toBBox(child) : child;
if (intersects(bbox, childBBox)) {
if (node.leaf || contains2(bbox, childBBox)) {
return true;
}
nodesToSearch.push(child);
}
}
node = nodesToSearch.pop();
}
return false;
};
RBush.prototype.load = function load5(data) {
if (!(data && data.length)) {
return this;
}
if (data.length < this._minEntries) {
for (var i = 0; i < data.length; i++) {
this.insert(data[i]);
}
return this;
}
var node = this._build(data.slice(), 0, data.length - 1, 0);
if (!this.data.children.length) {
this.data = node;
} else if (this.data.height === node.height) {
this._splitRoot(this.data, node);
} else {
if (this.data.height < node.height) {
var tmpNode = this.data;
this.data = node;
node = tmpNode;
}
this._insert(node, this.data.height - node.height - 1, true);
}
return this;
};
RBush.prototype.insert = function insert(item) {
if (item) {
this._insert(item, this.data.height - 1);
}
return this;
};
RBush.prototype.clear = function clear2() {
this.data = createNode([]);
return this;
};
RBush.prototype.remove = function remove3(item, equalsFn) {
if (!item) {
return this;
}
var node = this.data;
var bbox = this.toBBox(item);
var path = [];
var indexes = [];
var i, parent, goingUp;
while (node || path.length) {
if (!node) {
node = path.pop();
parent = path[path.length - 1];
i = indexes.pop();
goingUp = true;
}
if (node.leaf) {
var index = findItem(item, node.children, equalsFn);
if (index !== -1) {
node.children.splice(index, 1);
path.push(node);
this._condense(path);
return this;
}
}
if (!goingUp && !node.leaf && contains2(node, bbox)) {
path.push(node);
indexes.push(i);
i = 0;
parent = node;
node = node.children[0];
} else if (parent) {
i++;
node = parent.children[i];
goingUp = false;
} else {
node = null;
}
}
return this;
};
RBush.prototype.toBBox = function toBBox(item) {
return item;
};
RBush.prototype.compareMinX = function compareMinX(a3, b) {
return a3.minX - b.minX;
};
RBush.prototype.compareMinY = function compareMinY(a3, b) {
return a3.minY - b.minY;
};
RBush.prototype.toJSON = function toJSON() {
return this.data;
};
RBush.prototype.fromJSON = function fromJSON(data) {
this.data = data;
return this;
};
RBush.prototype._all = function _all(node, result) {
var nodesToSearch = [];
while (node) {
if (node.leaf) {
result.push.apply(result, node.children);
} else {
nodesToSearch.push.apply(nodesToSearch, node.children);
}
node = nodesToSearch.pop();
}
return result;
};
RBush.prototype._build = function _build(items, left, right, height) {
var N = right - left + 1;
var M = this._maxEntries;
var node;
if (N <= M) {
node = createNode(items.slice(left, right + 1));
calcBBox(node, this.toBBox);
return node;
}
if (!height) {
height = Math.ceil(Math.log(N) / Math.log(M));
M = Math.ceil(N / Math.pow(M, height - 1));
}
node = createNode([]);
node.leaf = false;
node.height = height;
var N2 = Math.ceil(N / M);
var N1 = N2 * Math.ceil(Math.sqrt(M));
multiSelect(items, left, right, N1, this.compareMinX);
for (var i = left; i <= right; i += N1) {
var right2 = Math.min(i + N1 - 1, right);
multiSelect(items, i, right2, N2, this.compareMinY);
for (var j = i; j <= right2; j += N2) {
var right3 = Math.min(j + N2 - 1, right2);
node.children.push(this._build(items, j, right3, height - 1));
}
}
calcBBox(node, this.toBBox);
return node;
};
RBush.prototype._chooseSubtree = function _chooseSubtree(bbox, node, level, path) {
while (true) {
path.push(node);
if (node.leaf || path.length - 1 === level) {
break;
}
var minArea = Infinity;
var minEnlargement = Infinity;
var targetNode = void 0;
for (var i = 0; i < node.children.length; i++) {
var child = node.children[i];
var area = bboxArea(child);
var enlargement = enlargedArea(bbox, child) - area;
if (enlargement < minEnlargement) {
minEnlargement = enlargement;
minArea = area < minArea ? area : minArea;
targetNode = child;
} else if (enlargement === minEnlargement) {
if (area < minArea) {
minArea = area;
targetNode = child;
}
}
}
node = targetNode || node.children[0];
}
return node;
};
RBush.prototype._insert = function _insert(item, level, isNode) {
var bbox = isNode ? item : this.toBBox(item);
var insertPath = [];
var node = this._chooseSubtree(bbox, this.data, level, insertPath);
node.children.push(item);
extend(node, bbox);
while (level >= 0) {
if (insertPath[level].children.length > this._maxEntries) {
this._split(insertPath, level);
level--;
} else {
break;
}
}
this._adjustParentBBoxes(bbox, insertPath, level);
};
RBush.prototype._split = function _split(insertPath, level) {
var node = insertPath[level];
var M = node.children.length;
var m = this._minEntries;
this._chooseSplitAxis(node, m, M);
var splitIndex = this._chooseSplitIndex(node, m, M);
var newNode = createNode(node.children.splice(splitIndex, node.children.length - splitIndex));
newNode.height = node.height;
newNode.leaf = node.leaf;
calcBBox(node, this.toBBox);
calcBBox(newNode, this.toBBox);
if (level) {
insertPath[level - 1].children.push(newNode);
} else {
this._splitRoot(node, newNode);
}
};
RBush.prototype._splitRoot = function _splitRoot(node, newNode) {
this.data = createNode([node, newNode]);
this.data.height = node.height + 1;
this.data.leaf = false;
calcBBox(this.data, this.toBBox);
};
RBush.prototype._chooseSplitIndex = function _chooseSplitIndex(node, m, M) {
var index;
var minOverlap = Infinity;
var minArea = Infinity;
for (var i = m; i <= M - m; i++) {
var bbox1 = distBBox(node, 0, i, this.toBBox);
var bbox2 = distBBox(node, i, M, this.toBBox);
var overlap = intersectionArea(bbox1, bbox2);
var area = bboxArea(bbox1) + bboxArea(bbox2);
if (overlap < minOverlap) {
minOverlap = overlap;
index = i;
minArea = area < minArea ? area : minArea;
} else if (overlap === minOverlap) {
if (area < minArea) {
minArea = area;
index = i;
}
}
}
return index || M - m;
};
RBush.prototype._chooseSplitAxis = function _chooseSplitAxis(node, m, M) {
var compareMinX = node.leaf ? this.compareMinX : compareNodeMinX;
var compareMinY = node.leaf ? this.compareMinY : compareNodeMinY;
var xMargin = this._allDistMargin(node, m, M, compareMinX);
var yMargin = this._allDistMargin(node, m, M, compareMinY);
if (xMargin < yMargin) {
node.children.sort(compareMinX);
}
};
RBush.prototype._allDistMargin = function _allDistMargin(node, m, M, compare) {
node.children.sort(compare);
var toBBox = this.toBBox;
var leftBBox = distBBox(node, 0, m, toBBox);
var rightBBox = distBBox(node, M - m, M, toBBox);
var margin = bboxMargin(leftBBox) + bboxMargin(rightBBox);
for (var i = m; i < M - m; i++) {
var child = node.children[i];
extend(leftBBox, node.leaf ? toBBox(child) : child);
margin += bboxMargin(leftBBox);
}
for (var i$1 = M - m - 1; i$1 >= m; i$1--) {
var child$1 = node.children[i$1];
extend(rightBBox, node.leaf ? toBBox(child$1) : child$1);
margin += bboxMargin(rightBBox);
}
return margin;
};
RBush.prototype._adjustParentBBoxes = function _adjustParentBBoxes(bbox, path, level) {
for (var i = level; i >= 0; i--) {
extend(path[i], bbox);
}
};
RBush.prototype._condense = function _condense(path) {
for (var i = path.length - 1, siblings = void 0; i >= 0; i--) {
if (path[i].children.length === 0) {
if (i > 0) {
siblings = path[i - 1].children;
siblings.splice(siblings.indexOf(path[i]), 1);
} else {
this.clear();
}
} else {
calcBBox(path[i], this.toBBox);
}
}
};
function findItem(item, items, equalsFn) {
if (!equalsFn) {
return items.indexOf(item);
}
for (var i = 0; i < items.length; i++) {
if (equalsFn(item, items[i])) {
return i;
}
}
return -1;
}
function calcBBox(node, toBBox) {
distBBox(node, 0, node.children.length, toBBox, node);
}
function distBBox(node, k, p, toBBox, destNode) {
if (!destNode) {
destNode = createNode(null);
}
destNode.minX = Infinity;
destNode.minY = Infinity;
destNode.maxX = -Infinity;
destNode.maxY = -Infinity;
for (var i = k; i < p; i++) {
var child = node.children[i];
extend(destNode, node.leaf ? toBBox(child) : child);
}
return destNode;
}
function extend(a3, b) {
a3.minX = Math.min(a3.minX, b.minX);
a3.minY = Math.min(a3.minY, b.minY);
a3.maxX = Math.max(a3.maxX, b.maxX);
a3.maxY = Math.max(a3.maxY, b.maxY);
return a3;
}
function compareNodeMinX(a3, b) {
return a3.minX - b.minX;
}
function compareNodeMinY(a3, b) {
return a3.minY - b.minY;
}
function bboxArea(a3) {
return (a3.maxX - a3.minX) * (a3.maxY - a3.minY);
}
function bboxMargin(a3) {
return a3.maxX - a3.minX + (a3.maxY - a3.minY);
}
function enlargedArea(a3, b) {
return (Math.max(b.maxX, a3.maxX) - Math.min(b.minX, a3.minX)) * (Math.max(b.maxY, a3.maxY) - Math.min(b.minY, a3.minY));
}
function intersectionArea(a3, b) {
var minX = Math.max(a3.minX, b.minX);
var minY = Math.max(a3.minY, b.minY);
var maxX = Math.min(a3.maxX, b.maxX);
var maxY = Math.min(a3.maxY, b.maxY);
return Math.max(0, maxX - minX) * Math.max(0, maxY - minY);
}
function contains2(a3, b) {
return a3.minX <= b.minX && a3.minY <= b.minY && b.maxX <= a3.maxX && b.maxY <= a3.maxY;
}
function intersects(a3, b) {
return b.minX <= a3.maxX && b.minY <= a3.maxY && b.maxX >= a3.minX && b.maxY >= a3.minY;
}
function createNode(children) {
return {
children,
height: 1,
leaf: true,
minX: Infinity,
minY: Infinity,
maxX: -Infinity,
maxY: -Infinity
};
}
function multiSelect(arr, left, right, n, compare) {
var stack = [left, right];
while (stack.length) {
right = stack.pop();
left = stack.pop();
if (right - left <= n) {
continue;
}
var mid = left + Math.ceil((right - left) / n / 2) * n;
quickselect(arr, mid, left, right, compare);
stack.push(left, mid, mid, right);
}
}
return RBush;
});
}
});
// node_modules/jsep/build/jsep.js
var require_jsep = __commonJS({
"node_modules/jsep/build/jsep.js"(exports2, module2) {
(function(root) {
"use strict";
var COMPOUND = "Compound", IDENTIFIER = "Identifier", MEMBER_EXP = "MemberExpression", LITERAL = "Literal", THIS_EXP = "ThisExpression", CALL_EXP = "CallExpression", UNARY_EXP = "UnaryExpression", BINARY_EXP = "BinaryExpression", LOGICAL_EXP = "LogicalExpression", CONDITIONAL_EXP = "ConditionalExpression", ARRAY_EXP = "ArrayExpression", PERIOD_CODE = 46, COMMA_CODE = 44, SQUOTE_CODE = 39, DQUOTE_CODE = 34, OPAREN_CODE = 40, CPAREN_CODE = 41, OBRACK_CODE = 91, CBRACK_CODE = 93, QUMARK_CODE = 63, SEMCOL_CODE = 59, COLON_CODE = 58, throwError = function(message, index) {
var error = new Error(message + " at character " + index);
error.index = index;
error.description = message;
throw error;
}, t = true, unary_ops = { "-": t, "!": t, "~": t, "+": t }, binary_ops = {
"||": 1,
"&&": 2,
"|": 3,
"^": 4,
"&": 5,
"==": 6,
"!=": 6,
"===": 6,
"!==": 6,
"<": 7,
">": 7,
"<=": 7,
">=": 7,
"<<": 8,
">>": 8,
">>>": 8,
"+": 9,
"-": 9,
"*": 10,
"/": 10,
"%": 10
}, getMaxKeyLen = function(obj) {
var max_len = 0, len;
for (var key in obj) {
if ((len = key.length) > max_len && obj.hasOwnProperty(key)) {
max_len = len;
}
}
return max_len;
}, max_unop_len = getMaxKeyLen(unary_ops), max_binop_len = getMaxKeyLen(binary_ops), literals = {
"true": true,
"false": false,
"null": null
}, this_str = "this", binaryPrecedence = function(op_val) {
return binary_ops[op_val] || 0;
}, createBinaryExpression = function(operator, left, right) {
var type = operator === "||" || operator === "&&" ? LOGICAL_EXP : BINARY_EXP;
return {
type,
operator,
left,
right
};
}, isDecimalDigit = function(ch) {
return ch >= 48 && ch <= 57;
}, isIdentifierStart = function(ch) {
return ch === 36 || ch === 95 || ch >= 65 && ch <= 90 || ch >= 97 && ch <= 122 || ch >= 128 && !binary_ops[String.fromCharCode(ch)];
}, isIdentifierPart = function(ch) {
return ch === 36 || ch === 95 || ch >= 65 && ch <= 90 || ch >= 97 && ch <= 122 || ch >= 48 && ch <= 57 || ch >= 128 && !binary_ops[String.fromCharCode(ch)];
}, jsep = function(expr) {
var index = 0, charAtFunc = expr.charAt, charCodeAtFunc = expr.charCodeAt, exprI = function(i) {
return charAtFunc.call(expr, i);
}, exprICode = function(i) {
return charCodeAtFunc.call(expr, i);
}, length3 = expr.length, gobbleSpaces = function() {
var ch = exprICode(index);
while (ch === 32 || ch === 9 || ch === 10 || ch === 13) {
ch = exprICode(++index);
}
}, gobbleExpression = function() {
var test = gobbleBinaryExpression(), consequent, alternate;
gobbleSpaces();
if (exprICode(index) === QUMARK_CODE) {
index++;
consequent = gobbleExpression();
if (!consequent) {
throwError("Expected expression", index);
}
gobbleSpaces();
if (exprICode(index) === COLON_CODE) {
index++;
alternate = gobbleExpression();
if (!alternate) {
throwError("Expected expression", index);
}
return {
type: CONDITIONAL_EXP,
test,
consequent,
alternate
};
} else {
throwError("Expected :", index);
}
} else {
return test;
}
}, gobbleBinaryOp = function() {
gobbleSpaces();
var biop, to_check = expr.substr(index, max_binop_len), tc_len = to_check.length;
while (tc_len > 0) {
if (binary_ops.hasOwnProperty(to_check) && (!isIdentifierStart(exprICode(index)) || index + to_check.length < expr.length && !isIdentifierPart(exprICode(index + to_check.length)))) {
index += tc_len;
return to_check;
}
to_check = to_check.substr(0, --tc_len);
}
return false;
}, gobbleBinaryExpression = function() {
var ch_i2, node2, biop, prec, stack, biop_info, left, right, i, cur_biop;
left = gobbleToken();
biop = gobbleBinaryOp();
if (!biop) {
return left;
}
biop_info = { value: biop, prec: binaryPrecedence(biop) };
right = gobbleToken();
if (!right) {
throwError("Expected expression after " + biop, index);
}
stack = [left, biop_info, right];
while (biop = gobbleBinaryOp()) {
prec = binaryPrecedence(biop);
if (prec === 0) {
break;
}
biop_info = { value: biop, prec };
cur_biop = biop;
while (stack.length > 2 && prec <= stack[stack.length - 2].prec) {
right = stack.pop();
biop = stack.pop().value;
left = stack.pop();
node2 = createBinaryExpression(biop, left, right);
stack.push(node2);
}
node2 = gobbleToken();
if (!node2) {
throwError("Expected expression after " + cur_biop, index);
}
stack.push(biop_info, node2);
}
i = stack.length - 1;
node2 = stack[i];
while (i > 1) {
node2 = createBinaryExpression(stack[i - 1].value, stack[i - 2], node2);
i -= 2;
}
return node2;
}, gobbleToken = function() {
var ch, to_check, tc_len;
gobbleSpaces();
ch = exprICode(index);
if (isDecimalDigit(ch) || ch === PERIOD_CODE) {
return gobbleNumericLiteral();
} else if (ch === SQUOTE_CODE || ch === DQUOTE_CODE) {
return gobbleStringLiteral();
} else if (ch === OBRACK_CODE) {
return gobbleArray();
} else {
to_check = expr.substr(index, max_unop_len);
tc_len = to_check.length;
while (tc_len > 0) {
if (unary_ops.hasOwnProperty(to_check) && (!isIdentifierStart(exprICode(index)) || index + to_check.length < expr.length && !isIdentifierPart(exprICode(index + to_check.length)))) {
index += tc_len;
return {
type: UNARY_EXP,
operator: to_check,
argument: gobbleToken(),
prefix: true
};
}
to_check = to_check.substr(0, --tc_len);
}
if (isIdentifierStart(ch) || ch === OPAREN_CODE) {
return gobbleVariable();
}
}
return false;
}, gobbleNumericLiteral = function() {
var number = "", ch, chCode;
while (isDecimalDigit(exprICode(index))) {
number += exprI(index++);
}
if (exprICode(index) === PERIOD_CODE) {
number += exprI(index++);
while (isDecimalDigit(exprICode(index))) {
number += exprI(index++);
}
}
ch = exprI(index);
if (ch === "e" || ch === "E") {
number += exprI(index++);
ch = exprI(index);
if (ch === "+" || ch === "-") {
number += exprI(index++);
}
while (isDecimalDigit(exprICode(index))) {
number += exprI(index++);
}
if (!isDecimalDigit(exprICode(index - 1))) {
throwError("Expected exponent (" + number + exprI(index) + ")", index);
}
}
chCode = exprICode(index);
if (isIdentifierStart(chCode)) {
throwError("Variable names cannot start with a number (" + number + exprI(index) + ")", index);
} else if (chCode === PERIOD_CODE) {
throwError("Unexpected period", index);
}
return {
type: LITERAL,
value: parseFloat(number),
raw: number
};
}, gobbleStringLiteral = function() {
var str = "", quote = exprI(index++), closed = false, ch;
while (index < length3) {
ch = exprI(index++);
if (ch === quote) {
closed = true;
break;
} else if (ch === "\\") {
ch = exprI(index++);
switch (ch) {
case "n":
str += "\n";
break;
case "r":
str += "\r";
break;
case "t":
str += " ";
break;
case "b":
str += "\b";
break;
case "f":
str += "\f";
break;
case "v":
str += "\v";
break;
default:
str += ch;
}
} else {
str += ch;
}
}
if (!closed) {
throwError('Unclosed quote after "' + str + '"', index);
}
return {
type: LITERAL,
value: str,
raw: quote + str + quote
};
}, gobbleIdentifier = function() {
var ch = exprICode(index), start = index, identifier;
if (isIdentifierStart(ch)) {
index++;
} else {
throwError("Unexpected " + exprI(index), index);
}
while (index < length3) {
ch = exprICode(index);
if (isIdentifierPart(ch)) {
index++;
} else {
break;
}
}
identifier = expr.slice(start, index);
if (literals.hasOwnProperty(identifier)) {
return {
type: LITERAL,
value: literals[identifier],
raw: identifier
};
} else if (identifier === this_str) {
return { type: THIS_EXP };
} else {
return {
type: IDENTIFIER,
name: identifier
};
}
}, gobbleArguments = function(termination) {
var ch_i2, args = [], node2, closed = false;
var separator_count = 0;
while (index < length3) {
gobbleSpaces();
ch_i2 = exprICode(index);
if (ch_i2 === termination) {
closed = true;
index++;
if (termination === CPAREN_CODE && separator_count && separator_count >= args.length) {
throwError("Unexpected token " + String.fromCharCode(termination), index);
}
break;
} else if (ch_i2 === COMMA_CODE) {
index++;
separator_count++;
if (separator_count !== args.length) {
if (termination === CPAREN_CODE) {
throwError("Unexpected token ,", index);
} else if (termination === CBRACK_CODE) {
for (var arg = args.length; arg < separator_count; arg++) {
args.push(null);
}
}
}
} else {
node2 = gobbleExpression();
if (!node2 || node2.type === COMPOUND) {
throwError("Expected comma", index);
}
args.push(node2);
}
}
if (!closed) {
throwError("Expected " + String.fromCharCode(termination), index);
}
return args;
}, gobbleVariable = function() {
var ch_i2, node2;
ch_i2 = exprICode(index);
if (ch_i2 === OPAREN_CODE) {
node2 = gobbleGroup();
} else {
node2 = gobbleIdentifier();
}
gobbleSpaces();
ch_i2 = exprICode(index);
while (ch_i2 === PERIOD_CODE || ch_i2 === OBRACK_CODE || ch_i2 === OPAREN_CODE) {
index++;
if (ch_i2 === PERIOD_CODE) {
gobbleSpaces();
node2 = {
type: MEMBER_EXP,
computed: false,
object: node2,
property: gobbleIdentifier()
};
} else if (ch_i2 === OBRACK_CODE) {
node2 = {
type: MEMBER_EXP,
computed: true,
object: node2,
property: gobbleExpression()
};
gobbleSpaces();
ch_i2 = exprICode(index);
if (ch_i2 !== CBRACK_CODE) {
throwError("Unclosed [", index);
}
index++;
} else if (ch_i2 === OPAREN_CODE) {
node2 = {
type: CALL_EXP,
"arguments": gobbleArguments(CPAREN_CODE),
callee: node2
};
}
gobbleSpaces();
ch_i2 = exprICode(index);
}
return node2;
}, gobbleGroup = function() {
index++;
var node2 = gobbleExpression();
gobbleSpaces();
if (exprICode(index) === CPAREN_CODE) {
index++;
return node2;
} else {
throwError("Unclosed (", index);
}
}, gobbleArray = function() {
index++;
return {
type: ARRAY_EXP,
elements: gobbleArguments(CBRACK_CODE)
};
}, nodes = [], ch_i, node;
while (index < length3) {
ch_i = exprICode(index);
if (ch_i === SEMCOL_CODE || ch_i === COMMA_CODE) {
index++;
} else {
if (node = gobbleExpression()) {
nodes.push(node);
} else if (index < length3) {
throwError('Unexpected "' + exprI(index) + '"', index);
}
}
}
if (nodes.length === 1) {
return nodes[0];
} else {
return {
type: COMPOUND,
body: nodes
};
}
};
jsep.version = "0.3.5";
jsep.toString = function() {
return "JavaScript Expression Parser (JSEP) v" + jsep.version;
};
jsep.addUnaryOp = function(op_name) {
max_unop_len = Math.max(op_name.length, max_unop_len);
unary_ops[op_name] = t;
return this;
};
jsep.addBinaryOp = function(op_name, precedence) {
max_binop_len = Math.max(op_name.length, max_binop_len);
binary_ops[op_name] = precedence;
return this;
};
jsep.addLiteral = function(literal_name, literal_value) {
literals[literal_name] = literal_value;
return this;
};
jsep.removeUnaryOp = function(op_name) {
delete unary_ops[op_name];
if (op_name.length === max_unop_len) {
max_unop_len = getMaxKeyLen(unary_ops);
}
return this;
};
jsep.removeAllUnaryOps = function() {
unary_ops = {};
max_unop_len = 0;
return this;
};
jsep.removeBinaryOp = function(op_name) {
delete binary_ops[op_name];
if (op_name.length === max_binop_len) {
max_binop_len = getMaxKeyLen(binary_ops);
}
return this;
};
jsep.removeAllBinaryOps = function() {
binary_ops = {};
max_binop_len = 0;
return this;
};
jsep.removeLiteral = function(literal_name) {
delete literals[literal_name];
return this;
};
jsep.removeAllLiterals = function() {
literals = {};
return this;
};
if (typeof exports2 === "undefined") {
var old_jsep = root.jsep;
root.jsep = jsep;
jsep.noConflict = function() {
if (root.jsep === jsep) {
root.jsep = old_jsep;
}
return jsep;
};
} else {
if (typeof module2 !== "undefined" && module2.exports) {
exports2 = module2.exports = jsep;
} else {
exports2.parse = jsep;
}
}
})(exports2);
}
});
// node_modules/meshoptimizer/meshopt_encoder.js
var require_meshopt_encoder = __commonJS({
"node_modules/meshoptimizer/meshopt_encoder.js"(exports2, module2) {
var MeshoptEncoder = function() {
"use strict";
var wasm = "B9h79tEBBBENQ9gEUEU9gEUB9gBB9gVUUUUUEU9gDUUEU9gLUUUUEU9gIUUUEU9gVUUUUUB9gLUUUUB9gD99UE99Ie8aDILEVOLEVLRRRRRWWVBOOBEdddLVE9wEIIVIEBEOWEUEC+Q/KEKR/QIhO9tw9t9vv95DBh9f9f939h79t9f9j9h229f9jT9vv7BB8a9tw79o9v9wT9fw9u9j9v9kw9WwvTw949C919m9mwvBE8f9tw79o9v9wT9fw9u9j9v9kw9WwvTw949C919m9mwv9C9v919u9kBDe9tw79o9v9wT9fw9u9j9v9kw9WwvTw949Wwv79p9v9uBIy9tw79o9v9wT9fw9u9j9v9kw69u9kw949C919m9mwvBL8e9tw79o9v9wT9fw9u9j9v9kw69u9kw949C919m9mwv9C9v919u9kBO8a9tw79o9v9wT9fw9u9j9v9kw69u9kw949Wwv79p9v9uBRe9tw79o9v9wT9fw9u9j9v9kw69u9kw949Twg91w9u9jwBWA9tw79o9v9wT9fw9u9j9v9kw69u9kw949Twg91w9u9jw9C9v919u9kBdl9tw79o9v9wT9fw9u9j9v9kws9p2Twv9P9jTBQk9tw79o9v9wT9fw9u9j9v9kws9p2Twv9R919hTBKl9tw79o9v9wT9fw9u9j9v9kws9p2Twvt949wBXe9tw79o9v9wT9f9v9wT9p9t9p96w9WwvTw94j9h9j9owBSA9tw79o9v9wT9f9v9wT9p9t9p96w9WwvTw94j9h9j9ow9TTv9p9wBZA9tw79o9v9wT9f9v9wT9p9t9p96w9WwvTw94swT9j9o9Sw9t9h9wBhL79iv9rBodWEBCEKDqxQ+f9Q8aDBK/EpE8jU8jJJJJBCJO9rGV8kJJJJBCBHODNALCEFAE0MBABCBrBJ+KJJBC+gEv86BBAVCJDFCBCJDZnJJJB8aDNAItMBAVCJDFADALZ+TJJJB8aKABAEFHRABCEFHEAVALFCBCBCJDAL9rALCfE0eZnJJJB8aAVAVCJDFALZ+TJJJBHWCJ/ABAL9uHODNAItMBAOC/wfBgGOCJDAOCJD6eHdCBHQINAWCJLFCBCJDZnJJJB8aAdAIAQ9rAQAdFAI6eHKADAQAL2FHXDNALtMBAKCSFGOC9wgHMAOCL4CIFCD4HpCBHSAXHZAEHhINDNAKtMBAWASFrBBHoCBHEAZHOINAWCJLFAEFAOrBBGaAo9rGoCETAoCkTCk91CR4786BBAOALFHOAaHoAECEFGEAK9HMBKKDNARAh9rAp6MBAhCBApZnJJJBGcApFHEDNAMtMBCBHxAWCJLFHqINARAE9rCk6MDAWCJLFAxFGlrBDHoCUHODNAlrBEGaAlrBBGkvCfEgMBCBHaAoCfEgMBCBHoDNAlrBIMBAlrBLMBAlrBVMBAlrBOMBAlrBRMBAlrBWMBAlrBdMBAlrBQMBAlrBKMBAlrBXMBAlrBMMBCBHaAlrBpMECBHoCUCBAlrBSeHOKCBHaKDNDNDNDNCLCDCECWAOCZ6GheAkCfEgGkCD0CLvAaCfEgGaCD0FAoCfEgGoCD0FAlrBIGyCD0FAlrBLG8aCD0FAlrBVGeCD0FAlrBOG3CD0FAlrBRG5CD0FAlrBWG8eCD0FAlrBdG8fCD0FAlrBQGACD0FAlrBKGHCD0FAlrBXGGCD0FAlrBMG8jCD0FAlrBpG8kCD0FAlrBSG8lCD0FG8mAOCZAheG8n6GOeAkCp0CWvAaCp0FAoCp0FAyCp0FA8aCp0FAeCp0FA3Cp0FA5Cp0FA8eCp0FA8fCp0FAACp0FAHCp0FAGCp0FA8jCp0FA8kCp0FA8lCp0FA8mA8nAOe6GoeGyCUFpDIEBKAcAxCO4FGaAarBBCDCIAoeAxCI4COgTv86BBAyCW9HMEAEAl8pBB83BBAECWFAlCWF8pBB83BBAECZFHEXDKAcAxCO4FGaAarBBCEAxCI4COgTv86BBKCDCLCWCEAheAOeAoeH8aCUAyTCU7HaCBH5AqHeINAEH3A8aHoAeHECBHOINAErBBGhAaAhAaCfEgGk6eAOCfEgAyTvHOAECEFHEAoCUFGoMBKA3AO86BBAeA8aFHeA3CEFHEA5A8aFG5CZ6MBKDNAlrBBGOAk6MBA3AO86BEA3CDFHEKDNAlrBEGOAk6MBAEAO86BBAECEFHEKDNAlrBDGOAk6MBAEAO86BBAECEFHEKDNAlrBIGOAk6MBAEAO86BBAECEFHEKDNAlrBLGOAk6MBAEAO86BBAECEFHEKDNAlrBVGOAk6MBAEAO86BBAECEFHEKDNAlrBOGOAk6MBAEAO86BBAECEFHEKDNAlrBRGOAk6MBAEAO86BBAECEFHEKDNAlrBWGOAk6MBAEAO86BBAECEFHEKDNAlrBdGOAk6MBAEAO86BBAECEFHEKDNAlrBQGOAk6MBAEAO86BBAECEFHEKDNAlrBKGOAk6MBAEAO86BBAECEFHEKDNAlrBXGOAk6MBAEAO86BBAECEFHEKDNAlrBMGOAk6MBAEAO86BBAECEFHEKDNAlrBpGOAk6MBAEAO86BBAECEFHEKAlrBSGOAk6MBAEAO86BBAECEFHEKAqCZFHqAxCZFGxAM6MBKKAEtMBAZCEFHZAEHhASCEFGSALsMDXEKKCBHOXIKAWAXAKCUFAL2FALZ+TJJJB8aAKAQFGQAI6MBKKCBHOARAE9rCAALALCA6e6MBDNALC8f0MBAECBCAAL9rGOZnJJJBAOFHEKAEAWCJDFALZ+TJJJBALFAB9rHOKAVCJOF8kJJJJBAOK9HEEUAECAAECA0eABCJ/ABAE9uC/wfBgGDCJDADCJD6eGDFCUFAD9uAE2ADCL4CIFCD4ADv2FCEFKMBCBABbDJ+KJJBK/pSEeU8jJJJJBC/AE9rGL8kJJJJBCBHVDNAICI9uGOChFAE0MBABCBYD+E+KJJBGRC/gEv86BBALC/ABFCfECJEZnJJJB8aALCuFGW9CU83IBALC8wFGd9CU83IBALCYFGQ9CU83IBALCAFGK9CU83IBALCkFGX9CU83IBALCZFGM9CU83IBAL9CU83IWAL9CU83IBABAEFC9wFGpABCEFGSAOFGE6HODNAItMBCMCSARCB9KeHZCBHhCBHoCBHaCBHcCBHxINDNAOCEgtMBCBHVXIKCDHqADAaCDTFGOYDBHlAOCWFYDBHkAOCLFYDBHyCBH8aCBHODNDNDNDNDNDNDNDNDNINALC/ABFAOCU7AxFCSgCITFGVYDLHeDNAVYDBGVAl9HMBAeAy9HMBAqC9+FHqXDKDNAVAy9HMBAeAk9HMBAqCUFHqXDKDNAVAk9HMBAeAlsMDKAqCLFHqA8aCZFH8aAOCEFGOCZ9HMBXDKKAqC870MBADAqCIgCX2GVC+E1JJBFYDBAaFCDTFYDBHqADAVCJ1JJBFYDBAaFCDTFYDBHyALADAVC11JJBFYDBAaFCDTFYDBGVAcZ+FJJJBGeCBCSAVAhsGkeAeCB9KAeAZ9IgGleHeAkAlCE7gHkDNARCE9IMBAeCS9HMBAVAVAoAVCEFAosGeeGoCEFsMDCMCSAeeHeKASAeA8av86BBAeCS9HMDAVAo9rGOCETAOC8f917HOINAEAOCfB0CRTAOCfBgv86BBAECEFHEAOCR4GOMBKAVHoXIKADCEAkAhsCETAyAhseCX2GOC11JJBFYDBAaFCDTFYDBHqADAOC+E1JJBFYDBAaFCDTFYDBHeADAOCJ1JJBFYDBAaFCDTFYDBHVCBHlDNARCE9IMBAhtMBAVMBAeCE9HMBAqCD9HMBAW9CU83IBAd9CU83IBAQ9CU83IBAK9CU83IBAX9CU83IBAM9CU83IBAL9CU83IWAL9CU83IBCBHhCEHlKAhAVAhsGOFH8aALAeAcZ+FJJJBHyALAqAcZ+FJJJBHkAyCM0MLAyCEFHyXVKCpHeASAOCLTCpv86BBAVHoKAetMBAeAZ9IMEKALAcCDTFAVbDBAcCEFCSgHcKAhAkFHhALC/ABFAxCITFGOAqbDLAOAVbDBALC/ABFAxCEFCSgGOCITFGeAVbDLAeAybDBAOCEFHVXDKCBCSAeA8asG3eHyA8aA3FH8aKDNDNAkCM0MBAkCEFHkXEKCBCSAqA8asG3eHkA8aA3FH8aKDNDNDNDNDNDNDNDNDNDNDNDNDNDNDNDNDNAkAyCLTvG3CfEgG5C+qUFp9UISSSSSSSSSSSSSSWSLQMSSSSSSSSSSSSESVSSSSSSSSSSSSSRDSdSSSSSSSSSSSSSSKSSSSSSSSSSSSSSSSOBKC/wEH8eA5pDMKpKC/xEH8eXXKC/yEH8eXKKC/zEH8eXQKC/0EH8eXdKC/1EH8eXWKC/2EH8eXRKC/3EH8eXOKC/4EH8eXVKC/5EH8eXLKC/6EH8eXIKC/7EH8eXDKC/8EH8eXEKCPEH8eKAlAVAh9HvMBASA8e86BBXEKASC9+CUAOe86BBAEA386BBAECEFHEKDNAOMBAVAo9rGOCETAOC8f917HOINAEAOCfB0CRTAOCfBgv86BBAECEFHEAOCR4GOMBKAVHoKDNAyCS9HMBAeAo9rGOCETAOC8f917HOINAEAOCfB0CRTAOCfBgv86BBAECEFHEAOCR4GOMBKAeHoKDNAkCS9HMBAqAo9rGOCETAOC8f917HOINAEAOCfB0CRTAOCfBgv86BBAECEFHEAOCR4GOMBKAqHoKALAcCDTFAVbDBAcCEFCSgHODNDNAypZBEEEEEEEEEEEEEEBEKALAOCDTFAebDBAcCDFCSgHOKDNDNAkpZBEEEEEEEEEEEEEEBEKALAOCDTFAqbDBAOCEFCSgHOKALC/ABFAxCITFGyAVbDLAyAebDBALC/ABFAxCEFCSgCITFGyAebDLAyAqbDBALC/ABFAxCDFCSgCITFGeAqbDLAeAVbDBAxCIFHVAOHcA8aHhKApAE6HOASCEFHSAVCSgHxAaCIFGaAI6MBKKCBHVAOMBAE9C/lm+i/D+Z+g8a83BWAE9CJ/s+d+0/1+M/e/U+GU83BBAEAB9rCZFHVKALC/AEF8kJJJJBAVK+mIEEUCBHIDNABADCUFCSgCDTFYDBAEsMBCEHIABADCpFCSgCDTFYDBAEsMBCDHIABADCMFCSgCDTFYDBAEsMBCIHIABADCXFCSgCDTFYDBAEsMBCLHIABADCKFCSgCDTFYDBAEsMBCVHIABADCQFCSgCDTFYDBAEsMBCOHIABADCdFCSgCDTFYDBAEsMBCRHIABADCWFCSgCDTFYDBAEsMBCWHIABADCRFCSgCDTFYDBAEsMBCdHIABADCOFCSgCDTFYDBAEsMBCQHIABADCVFCSgCDTFYDBAEsMBCKHIABADCLFCSgCDTFYDBAEsMBCXHIABADCIFCSgCDTFYDBAEsMBCMHIABADCDFCSgCDTFYDBAEsMBCpHIABADCEFCSgCDTFYDBAEsMBCSCUABADCSgCDTFYDBAEseSKAIKjEIUCRHDDNINADCEFHIADC96FGLC8f0MEAIHDCEALTAE6MBKKAICR9uCI2CDFABCI9u2ChFKMBCBABbD+E+KJJBK+YDERU8jJJJJBCZ9rHLCBHVDNAICVFAE0MBCBHVABCBrB+E+KJJBC/QEv86BBAL9CB83IWABCEFHOABAEFC98FHRDNAItMBCBHWINDNARAO0MBCBSKAVADAWCDTFYDBGdALCWFAVCDTFYDB9rGEAEC8f91GEFAE7C59K7GVAdALCWFAVCDTFGQYDB9rGEC8f91CETAECDT7vHEINAOAECfB0CRTAECfBgv86BBAOCEFHOAECR4GEMBKAQAdbDBAWCEFGWAI9HMBKKCBHVARAO6MBAOCBbBBAOAB9rCLFHVKAVK86EIUCWHDDNINADCEFHIADC95FGLC8f0MEAIHDCEALTAE6MBKKAICR9uAB2CVFK+yWDEUO99DNAEtMBADCLsHVCUADCETCUFTCU7HDDNDNCUAICUFTCU7+yGOjBBBzmGR+LjBBB9P9dtMBAR+oHIXEKCJJJJ94HIKAD+yHWDNAVMBABCOFHDINALCLFiDBGRjBBBBjBBJzALiDBGd+LAR+LmALCWFiDBGQ+LmGR+VARjBBBB9beGRnHKAdARnHRALCXFiDBHdDNDNAQjBBBB9gtMBAKHQXEKjBBJzAR+L+TGQAQ+MAKjBBBB9geHQjBBJzAK+L+TGKAK+MARjBBBB9geHRKADC9+FAI87EBDNDNjBBBzjBBB+/AdjBBBB9geAdjBBJ+/AdjBBJ+/9geGdjBBJzAdjBBJz9feAWnmGd+LjBBB9P9dtMBAd+oHBXEKCJJJJ94HBKADAB87EBDNDNjBBBzjBBB+/AQjBBBB9geAQjBBJ+/AQjBBJ+/9geGdjBBJzAdjBBJz9feAOnmGd+LjBBB9P9dtMBAd+oHBXEKCJJJJ94HBKADC98FAB87EBDNDNjBBBzjBBB+/ARjBBBB9geARjBBJ+/ARjBBJ+/9geGRjBBJzARjBBJz9feAOnmGR+LjBBB9P9dtMBAR+oHBXEKCJJJJ94HBKADC96FAB87EBALCZFHLADCWFHDAECUFGEMBXDKKABCIFHDINALCLFiDBGRjBBBBjBBJzALiDBGd+LAR+LmALCWFiDBGQ+LmGR+VARjBBBB9beGRnHKAdARnHRALCXFiDBHdDNDNAQjBBBB9gtMBAKHQXEKjBBJzAR+L+TGQAQ+MAKjBBBB9geHQjBBJzAK+L+TGKAK+MARjBBBB9geHRKADCUFAI86BBDNDNjBBBzjBBB+/AdjBBBB9geAdjBBJ+/AdjBBJ+/9geGdjBBJzAdjBBJz9feAWnmGd+LjBBB9P9dtMBAd+oHBXEKCJJJJ94HBKADAB86BBDNDNjBBBzjBBB+/AQjBBBB9geAQjBBJ+/AQjBBJ+/9geGdjBBJzAdjBBJz9feAOnmGd+LjBBB9P9dtMBAd+oHBXEKCJJJJ94HBKADC9+FAB86BBDNDNjBBBzjBBB+/ARjBBBB9geARjBBJ+/ARjBBJ+/9geGRjBBJzARjBBJz9feAOnmGR+LjBBB9P9dtMBAR+oHBXEKCJJJJ94HBKADC99FAB86BBALCZFHLADCLFHDAECUFGEMBKKK/KLLD99EUE99EUDNAEtMBDNDNCUAICUFTCU7+yGVjBBBzmGO+LjBBB9P9dtMBAO+oHIXEKCJJJJ94HIKAIC/8fIgHRINABCOFCICDALCLFiDB+LALiDB+L9eGIALCWFiDB+LALAICDTFiDB+L9eeGIALCXFiDB+LALAICDTFiDB+L9eeGIARv87EBDNDNjBBBzjBBB+/ALAICEFCIgCDTFiDBj/zL+1znjBBJ+/jBBJzALAICDTFiDBjBBBB9deGOnGWjBBBB9geAWjBBJ+/AWjBBJ+/9geGWjBBJzAWjBBJz9feAVnmGW+LjBBB9P9dtMBAW+oHdXEKCJJJJ94HdKABAd87EBDNDNjBBBzjBBB+/AOALAICDFCIgCDTFiDBj/zL+1znnGWjBBBB9geAWjBBJ+/AWjBBJ+/9geGWjBBJzAWjBBJz9feAVnmGW+LjBBB9P9dtMBAW+oHdXEKCJJJJ94HdKABCDFAd87EBDNDNjBBBzjBBB+/AOALAICUFCIgCDTFiDBj/zL+1znnGOjBBBB9geAOjBBJ+/AOjBBJ+/9geGOjBBJzAOjBBJz9feAVnmGO+LjBBB9P9dtMBAO+oHIXEKCJJJJ94HIKABCLFAI87EBABCWFHBALCZFHLAECUFGEMBKKK+tDDWUE998jJJJJBCZ9rGV8kJJJJBDNAEtMBADCD4GOtMBCEAI9rHRAOCDTHWCBHdINC+cUHDALHIAOHQINAIiDBAVCXFZ+YJJJB8aAVYDXGKADADAK9IeHDAICLFHIAQCUFGQMBKARADFGICkTHKCBHDCBAI9rHXAOHIINDNDNALADFiDBGMAXZ+XJJJBjBBBzjBBB+/AMjBBBB9gemGM+LjBBB9P9dtMBAM+oHQXEKCJJJJ94HQKABADFAQCfffRgAKvbDBADCLFHDAICUFGIMBKABAWFHBALAWFHLAdCEFGdAE9HMBKKAVCZF8kJJJJBK+iMDlUI998jJJJJBC+QD9rGV8kJJJJBAVC+oEFCBC/kBZnJJJB8aCBHODNADtMBCBHOAItMBDNABAE9HMBAVCUADCDTGRADCffffI0eCBYD/4+JJJBhJJJJBBGEbD+oEAVCEbD1DAEABARZ+TJJJB8aKAVC+YEFCWFCBbDBAV9CB83I+YEAVC+YEFAEADAIAVC+oEFZ+OJJJBCUAICDTGWAICffffI0eGdCBYD/4+JJJBhJJJJBBHRAVC+oEFAVYD1DGOCDTFARbDBAVAOCEFGQbD1DARAVYD+YEGKAWZ+TJJJBHXAVC+oEFAQCDTFADCI9uGMCBYD/4+JJJBhJJJJBBGRbDBAVAOCDFGWbD1DARCBAMZnJJJBHpAVC+oEFAWCDTFAdCBYD/4+JJJBhJJJJBBGSbDBAVAOCIFGQbD1DAXHRASHWINAWALiDBALARYDBGdCWAdCW6eCDTFC/EBFiDBmuDBARCLFHRAWCLFHWAICUFGIMBKCBHIAVC+oEFAQCDTFCUAMCDTADCffff970eCBYD/4+JJJBhJJJJBBGQbDBAVAOCLFGObD1DDNADCI6MBAEHRAQHWINAWASARYDBCDTFiDBASARCLFYDBCDTFiDBmASARCWFYDBCDTFiDBmuDBARCXFHRAWCLFHWAICEFGIAM6MBKKAVC/MBFHZAVYD+cEHhAVYD+gEHoAVHRCBHdCBHWCBHaCEHcINARHxAEAWCX2FGqCWFGlYDBHDAqYDBHkABAaCX2FGRCLFAqCLFGyYDBG8abDBARAkbDBARCWFADbDBApAWFCE86BBAZADbDWAZA8abDLAZAkbDBAQAWCDTFCBbDBCIHeDNAdtMBAxHRINDNARYDBGIADsMBAIAksMBAIA8asMBAZAeCDTFAIbDBAeCEFHeKARCLFHRAdCUFGdMBKKAXAkCDTFGRARYDBCUFbDBAXA8aCDTFGRARYDBCUFbDBAXADCDTFGRARYDBCUFbDBAoAhAqYDBCDTGIFYDBCDTFGkHRAKAIFGDYDBGdHIDNAdtMBDNINARYDBAWsMEARCLFHRAICUFGItMDXBKKARAdCDTAkFC98FYDBbDBADADYDBCUFbDBKAoAhAyYDBCDTGIFYDBCDTFGkHRAKAIFGDYDBGdHIDNAdtMBDNINARYDBAWsMEARCLFHRAICUFGIMBXDKKARAdCDTAkFC98FYDBbDBADADYDBCUFbDBKDNAKAlYDBCDTGRFGDYDBGdtMBAoAhARFYDBCDTFGkHRAdHIDNINARYDBAWsMEARCLFHRAICUFGIMBXDKKARAdCDTAkFC98FYDBbDBADADYDBCUFbDBKDNDNAetMBCUHWjBBBBH3CBHRINASAZARCDTFYDBCDTGIFGdiDBH5AdALCBARCEFGkARCS0eCDTFiDBALAXAIFYDBGRCWARCW6eCDTFC/EBFiDBmG8euDBDNAKAIFYDBGdtMBA8eA5+TH8eAoAhAIFYDBCDTFHRAdCDTHIINAQARYDBGdCDTFGDA8eADiDBmG5uDBA5A3A3A59dGDeH3AdAWADeHWARCLFHRAIC98FGIMBKKAkHRAkAe9HMBKAWCU9HMEKAcAM9PMDINDNApAcFrBBMBAcHWXDKAMAcCEFGc9HMBXIKKAaCEFHaAeCZAeCZ6eHdAZHRAxHZAWCU9HMBKKAOCDTAVC+oEFFC98FHRDNINAOtMEARYDBCBYD/0+JJJBh+BJJJBBARC98FHRAOCUFHOXBKKAVC+QDF8kJJJJBK/iLEVUCUAICDTGVAICffffI0eGOCBYD/4+JJJBhJJJJBBHRALALYD9gGWCDTFARbDBALAWCEFbD9gABARbDBAOCBYD/4+JJJBhJJJJBBHRALALYD9gGOCDTFARbDBALAOCEFbD9gABARbDLCUADCDTADCffffI0eCBYD/4+JJJBhJJJJBBHRALALYD9gGOCDTFARbDBALAOCEFbD9gABARbDWABYDBCBAVZnJJJB8aADCI9uHdDNADtMBABYDBHOAEHLADHRINAOALYDBCDTFGVAVYDBCEFbDBALCLFHLARCUFGRMBKKDNAItMBABYDBHLABYDLHRCBHVAIHOINARAVbDBARCLFHRALYDBAVFHVALCLFHLAOCUFGOMBKKDNADCI6MBABYDLHRABYDWHVCBHLINAECWFYDBHOAECLFYDBHDARAEYDBCDTFGWAWYDBGWCEFbDBAVAWCDTFALbDBARADCDTFGDADYDBGDCEFbDBAVADCDTFALbDBARAOCDTFGOAOYDBGOCEFbDBAVAOCDTFALbDBAECXFHEALCEFGLAd6MBKKDNAItMBABYDLHEABYDBHLINAEAEYDBALYDB9rbDBALCLFHLAECLFHEAICUFGIMBKKKqBABAEADAIC+k1JJBZ+NJJJBKqBABAEADAIC+M+JJJBZ+NJJJBK9dEEUABCfEAICDTZnJJJBHLCBHIDNADtMBINDNALAEYDBCDTFGBYDBCU9HMBABAIbDBAICEFHIKAECLFHEADCUFGDMBKKAIK9TEIUCBCBYD/8+JJJBGEABCIFC98gFGBbD/8+JJJBDNDNABzBCZTGD9NMBCUHIABAD9rCffIFCZ4NBCUsMEKAEHIKAIK/lEEEUDNDNAEABvCIgtMBABHIXEKDNDNADCZ9PMBABHIXEKABHIINAIAEYDBbDBAICLFAECLFYDBbDBAICWFAECWFYDBbDBAICXFAECXFYDBbDBAICZFHIAECZFHEADC9wFGDCS0MBKKADCL6MBINAIAEYDBbDBAECLFHEAICLFHIADC98FGDCI0MBKKDNADtMBINAIAErBB86BBAICEFHIAECEFHEADCUFGDMBKKABK/AEEDUDNDNABCIgtMBABHIXEKAECfEgC+B+C+EW2HLDNDNADCZ9PMBABHIXEKABHIINAIALbDBAICXFALbDBAICWFALbDBAICLFALbDBAICZFHIADC9wFGDCS0MBKKADCL6MBINAIALbDBAICLFHIADC98FGDCI0MBKKDNADtMBINAIAE86BBAICEFHIADCUFGDMBKKABK9TEIUCBCBYD/8+JJJBGEABCIFC98gFGBbD/8+JJJBDNDNABzBCZTGD9NMBCUHIABAD9rCffIFCZ4NBCUsMEKAEHIKAIK9+EIUzBHEDNDNCBYD/8+JJJBGDAECZTGI9NMBCUHEADAI9rCffIFCZ4NBCUsMEKADHEKCBABAE9rCIFC98gCBYD/8+JJJBFGDbD/8+JJJBDNADzBCZTGE9NMBADAE9rCffIFCZ4NB8aKKXBABAEZ+ZJJJBK+BEEIUDNAB+8GDCl4GICfEgGLCfEsMBDNALMBDNABjBBBB9cMBAECBbDBABSKABjBBJ9fnAEZ+YJJJBHBAEAEYDBCNFbDBABSKAEAICfEgC+CUFbDBADCfff+D94gCJJJ/4Iv++HBKABK+gEBDNDNAECJE9IMBABjBBBUnHBDNAECfE9OMBAEC+BUFHEXDKABjBBBUnHBAECPDAECPD9IeC+C9+FHEXEKAEC+BU9KMBABjBBJXnHBDNAEC+b9+9MMBAEC/mBFHEXEKABjBBJXnHBAEC+299AEC+2999KeC/MEFHEKABAEClTCJJJ/8IF++nKK+ODDBCJWK/0EBBBBEBBBDBBBEBBBDBBBBBBBDBBBBBBBEBBBBBBB+L29Hz/69+9Kz/n/76z/RG97z/Z/O9Xz8j/b85z/+/U9Yz/B/K9hz+2/z9dz9E+L9Mz59a8kz+R/t3z+a+Zyz79ohz/J4++8++y+d9v8+BBBB9S+49+z8r+Hbz9m9m/m8+l/Z/O8+/8+pg89Q/X+j878r+Hq8++m+b/E87BBBBBBJzBBJzBBJz+e/v/n8++y+dSz9I/h/68+XD/r8+/H0838+/w+nOzBBBB+wv9o8+UF888+9I/h/68+9C9g/l89/N/M9M89/d8kO8+BBBBF+8Tz9M836zs+2azl/Zpzz818ez9E+LXz/u98f8+819e/68+BC/0dKXEBBBDBBBZwBB";
var wasmpack = new Uint8Array([32, 0, 65, 2, 1, 106, 34, 33, 3, 128, 11, 4, 13, 64, 6, 253, 10, 7, 15, 116, 127, 5, 8, 12, 40, 16, 19, 54, 20, 9, 27, 255, 113, 17, 42, 67, 24, 23, 146, 148, 18, 14, 22, 45, 70, 69, 56, 114, 101, 21, 25, 63, 75, 136, 108, 28, 118, 29, 73, 115]);
if (typeof WebAssembly !== "object") {
return {
supported: false
};
}
var instance;
var promise = WebAssembly.instantiate(unpack(wasm), {}).then(function(result) {
instance = result.instance;
instance.exports.__wasm_call_ctors();
instance.exports.meshopt_encodeVertexVersion(0);
instance.exports.meshopt_encodeIndexVersion(1);
});
function unpack(data) {
var result = new Uint8Array(data.length);
for (var i = 0; i < data.length; ++i) {
var ch = data.charCodeAt(i);
result[i] = ch > 96 ? ch - 71 : ch > 64 ? ch - 65 : ch > 47 ? ch + 4 : ch > 46 ? 63 : 62;
}
var write = 0;
for (var i = 0; i < data.length; ++i) {
result[write++] = result[i] < 60 ? wasmpack[result[i]] : (result[i] - 60) * 64 + result[++i];
}
return result.buffer.slice(0, write);
}
function assert(cond) {
if (!cond) {
throw new Error("Assertion failed");
}
}
function reorder(indices2, vertices, optf) {
var sbrk = instance.exports.sbrk;
var ip = sbrk(indices2.length * 4);
var rp = sbrk(vertices * 4);
var heap = new Uint8Array(instance.exports.memory.buffer);
var indices8 = new Uint8Array(indices2.buffer, indices2.byteOffset, indices2.byteLength);
heap.set(indices8, ip);
if (optf) {
optf(ip, ip, indices2.length, vertices);
}
var unique = instance.exports.meshopt_optimizeVertexFetchRemap(rp, ip, indices2.length, vertices);
heap = new Uint8Array(instance.exports.memory.buffer);
var remap = new Uint32Array(vertices);
new Uint8Array(remap.buffer).set(heap.subarray(rp, rp + vertices * 4));
indices8.set(heap.subarray(ip, ip + indices2.length * 4));
sbrk(ip - sbrk(0));
for (var i = 0; i < indices2.length; ++i)
indices2[i] = remap[indices2[i]];
return [remap, unique];
}
function encode(fun, bound, source, count, size) {
var sbrk = instance.exports.sbrk;
var tp = sbrk(bound);
var sp = sbrk(count * size);
var heap = new Uint8Array(instance.exports.memory.buffer);
heap.set(new Uint8Array(source.buffer, source.byteOffset, source.byteLength), sp);
var res = fun(tp, bound, sp, count, size);
var target = new Uint8Array(res);
target.set(heap.subarray(tp, tp + res));
sbrk(tp - sbrk(0));
return target;
}
function maxindex(source) {
var result = 0;
for (var i = 0; i < source.length; ++i) {
var index = source[i];
result = result < index ? index : result;
}
return result;
}
function index32(source, size) {
assert(size == 2 || size == 4);
if (size == 4) {
return new Uint32Array(source.buffer, source.byteOffset, source.byteLength / 4);
} else {
var view = new Uint16Array(source.buffer, source.byteOffset, source.byteLength / 2);
return new Uint32Array(view);
}
}
function filter(fun, source, count, stride, bits, insize) {
var sbrk = instance.exports.sbrk;
var tp = sbrk(count * stride);
var sp = sbrk(count * insize);
var heap = new Uint8Array(instance.exports.memory.buffer);
heap.set(new Uint8Array(source.buffer, source.byteOffset, source.byteLength), sp);
fun(tp, count, stride, bits, sp);
var target = new Uint8Array(count * stride);
target.set(heap.subarray(tp, tp + count * stride));
sbrk(tp - sbrk(0));
return target;
}
return {
ready: promise,
supported: true,
reorderMesh: function(indices2, triangles, optsize) {
var optf = triangles ? optsize ? instance.exports.meshopt_optimizeVertexCacheStrip : instance.exports.meshopt_optimizeVertexCache : void 0;
return reorder(indices2, maxindex(indices2) + 1, optf);
},
encodeVertexBuffer: function(source, count, size) {
assert(size > 0 && size <= 256);
assert(size % 4 == 0);
var bound = instance.exports.meshopt_encodeVertexBufferBound(count, size);
return encode(instance.exports.meshopt_encodeVertexBuffer, bound, source, count, size);
},
encodeIndexBuffer: function(source, count, size) {
assert(size == 2 || size == 4);
assert(count % 3 == 0);
var indices2 = index32(source, size);
var bound = instance.exports.meshopt_encodeIndexBufferBound(count, maxindex(indices2) + 1);
return encode(instance.exports.meshopt_encodeIndexBuffer, bound, indices2, count, 4);
},
encodeIndexSequence: function(source, count, size) {
assert(size == 2 || size == 4);
var indices2 = index32(source, size);
var bound = instance.exports.meshopt_encodeIndexSequenceBound(count, maxindex(indices2) + 1);
return encode(instance.exports.meshopt_encodeIndexSequence, bound, indices2, count, 4);
},
encodeGltfBuffer: function(source, count, size, mode2) {
var table2 = {
ATTRIBUTES: this.encodeVertexBuffer,
TRIANGLES: this.encodeIndexBuffer,
INDICES: this.encodeIndexSequence
};
assert(table2[mode2]);
return table2[mode2](source, count, size);
},
encodeFilterOct: function(source, count, stride, bits) {
assert(stride == 4 || stride == 8);
assert(bits >= 1 && bits <= 16);
return filter(instance.exports.meshopt_encodeFilterOct, source, count, stride, bits, 4);
},
encodeFilterQuat: function(source, count, stride, bits) {
assert(stride == 8);
assert(bits >= 4 && bits <= 16);
return filter(instance.exports.meshopt_encodeFilterQuat, source, count, stride, bits, 4);
},
encodeFilterExp: function(source, count, stride, bits) {
assert(stride > 0 && stride % 4 == 0);
assert(bits >= 1 && bits <= 24);
return filter(instance.exports.meshopt_encodeFilterExp, source, count, stride, bits, stride / 4);
}
};
}();
if (typeof exports2 === "object" && typeof module2 === "object")
module2.exports = MeshoptEncoder;
else if (typeof define === "function" && define["amd"])
define([], function() {
return MeshoptEncoder;
});
else if (typeof exports2 === "object")
exports2["MeshoptEncoder"] = MeshoptEncoder;
else
(typeof self !== "undefined" ? self : exports2).MeshoptEncoder = MeshoptEncoder;
}
});
// node_modules/meshoptimizer/meshopt_decoder.js
var require_meshopt_decoder = __commonJS({
"node_modules/meshoptimizer/meshopt_decoder.js"(exports2, module2) {
var MeshoptDecoder2 = function() {
"use strict";
var wasm_base = "B9h79tEBBBE8fV9gBB9gVUUUUUEU9gIUUUB9gEUEU9gIUUUEUIKQBEEEDDDILLLVE9wEEEVIEBEOWEUEC+Q/IEKR/LEdO9tw9t9vv95DBh9f9f939h79t9f9j9h229f9jT9vv7BB8a9tw79o9v9wT9f9kw9j9v9kw9WwvTw949C919m9mwvBEy9tw79o9v9wT9f9kw9j9v9kw69u9kw949C919m9mwvBDe9tw79o9v9wT9f9kw9j9v9kw69u9kw949Twg91w9u9jwBIl9tw79o9v9wT9f9kw9j9v9kws9p2Twv9P9jTBLk9tw79o9v9wT9f9kw9j9v9kws9p2Twv9R919hTBVl9tw79o9v9wT9f9kw9j9v9kws9p2Twvt949wBOL79iv9rBRQ+x8yQDBK/qMEZU8jJJJJBCJ/EB9rGV8kJJJJBC9+HODNADCEFAL0MBCUHOAIrBBC+gE9HMBAVAIALFGRAD9rADZ1JJJBHWCJ/ABAD9uC/wfBgGOCJDAOCJD6eHdAICEFHLCBHQDNINAQAE9PMEAdAEAQ9rAQAdFAE6eHKDNDNADtMBAKCSFGOC9wgHXAOCL4CIFCD4HMAWCJDFHpCBHSALHZINDNARAZ9rAM9PMBCBHLXIKAZAMFHLDNAXtMBCBHhCBHIINDNARAL9rCk9PMBCBHLXVKAWCJ/CBFAIFHODNDNDNDNDNAZAICO4FrBBAhCOg4CIgpLBEDIBKAO9CB83IBAOCWF9CB83IBXIKAOALrBLALrBBGoCO4GaAaCIsGae86BBAOCEFALCLFAaFGarBBAoCL4CIgGcAcCIsGce86BBAOCDFAaAcFGarBBAoCD4CIgGcAcCIsGce86BBAOCIFAaAcFGarBBAoCIgGoAoCIsGoe86BBAOCLFAaAoFGarBBALrBEGoCO4GcAcCIsGce86BBAOCVFAaAcFGarBBAoCL4CIgGcAcCIsGce86BBAOCOFAaAcFGarBBAoCD4CIgGcAcCIsGce86BBAOCRFAaAcFGarBBAoCIgGoAoCIsGoe86BBAOCWFAaAoFGarBBALrBDGoCO4GcAcCIsGce86BBAOCdFAaAcFGarBBAoCL4CIgGcAcCIsGce86BBAOCQFAaAcFGarBBAoCD4CIgGcAcCIsGce86BBAOCKFAaAcFGarBBAoCIgGoAoCIsGoe86BBAOCXFAaAoFGorBBALrBIGLCO4GaAaCIsGae86BBAOCMFAoAaFGorBBALCL4CIgGaAaCIsGae86BBAOCpFAoAaFGorBBALCD4CIgGaAaCIsGae86BBAOCSFAoAaFGOrBBALCIgGLALCIsGLe86BBAOALFHLXDKAOALrBWALrBBGoCL4GaAaCSsGae86BBAOCEFALCWFAaFGarBBAoCSgGoAoCSsGoe86BBAOCDFAaAoFGorBBALrBEGaCL4GcAcCSsGce86BBAOCIFAoAcFGorBBAaCSgGaAaCSsGae86BBAOCLFAoAaFGorBBALrBDGaCL4GcAcCSsGce86BBAOCVFAoAcFGorBBAaCSgGaAaCSsGae86BBAOCOFAoAaFGorBBALrBIGaCL4GcAcCSsGce86BBAOCRFAoAcFGorBBAaCSgGaAaCSsGae86BBAOCWFAoAaFGorBBALrBLGaCL4GcAcCSsGce86BBAOCdFAoAcFGorBBAaCSgGaAaCSsGae86BBAOCQFAoAaFGorBBALrBVGaCL4GcAcCSsGce86BBAOCKFAoAcFGorBBAaCSgGaAaCSsGae86BBAOCXFAoAaFGorBBALrBOGaCL4GcAcCSsGce86BBAOCMFAoAcFGorBBAaCSgGaAaCSsGae86BBAOCpFAoAaFGorBBALrBRGLCL4GaAaCSsGae86BBAOCSFAoAaFGOrBBALCSgGLALCSsGLe86BBAOALFHLXEKAOAL8pBB83BBAOCWFALCWF8pBB83BBALCZFHLKAhCDFHhAICZFGIAX6MBKKDNALMBCBHLXIKDNAKtMBAWASFrBBHhCBHOApHIINAIAWCJ/CBFAOFrBBGZCE4CBAZCEg9r7AhFGh86BBAIADFHIAOCEFGOAK9HMBKKApCEFHpALHZASCEFGSAD9HMBKKABAQAD2FAWCJDFAKAD2Z1JJJB8aAWAWCJDFAKCUFAD2FADZ1JJJB8aKAKCBALeAQFHQALMBKC9+HOXEKCBC99ARAL9rADCAADCA0eseHOKAVCJ/EBF8kJJJJBAOK+OoEZU8jJJJJBC/AE9rGV8kJJJJBC9+HODNAECI9uGRChFAL0MBCUHOAIrBBGWC/wEgC/gE9HMBAWCSgGdCE0MBAVC/ABFCfECJEZ+JJJJB8aAVCuF9CU83IBAVC8wF9CU83IBAVCYF9CU83IBAVCAF9CU83IBAVCkF9CU83IBAVCZF9CU83IBAV9CU83IWAV9CU83IBAIALFC9wFHQAICEFGWARFHKDNAEtMBCMCSAdCEseHXABHICBHdCBHMCBHpCBHLCBHOINDNAKAQ9NMBC9+HOXIKDNDNAWrBBGRC/vE0MBAVC/ABFARCL4CU7AOFCSgCITFGSYDLHZASYDBHhDNARCSgGSAX9PMBAVARCU7ALFCSgCDTFYDBAdASeHRAStHSDNDNADCD9HMBABAh87EBABCLFAR87EBABCDFAZ87EBXEKAIAhbDBAICWFARbDBAICLFAZbDBKAdASFHdAVC/ABFAOCITFGoARbDBAoAZbDLAVALCDTFARbDBAVC/ABFAOCEFCSgGOCITFGZAhbDBAZARbDLALASFHLAOCEFHOXDKDNDNASCSsMBAMASFASC987FCEFHMXEKAK8sBBGSCfEgHRDNDNASCU9MMBAKCEFHKXEKAK8sBEGSCfBgCRTARCfBgvHRDNASCU9MMBAKCDFHKXEKAK8sBDGSCfBgCpTARvHRDNASCU9MMBAKCIFHKXEKAK8sBIGSCfBgCxTARvHRDNASCU9MMBAKCLFHKXEKAKrBLC3TARvHRAKCVFHKKARCE4CBARCEg9r7AMFHMKDNDNADCD9HMBABAh87EBABCLFAM87EBABCDFAZ87EBXEKAIAhbDBAICWFAMbDBAICLFAZbDBKAVC/ABFAOCITFGRAMbDBARAZbDLAVALCDTFAMbDBAVC/ABFAOCEFCSgGOCITFGRAhbDBARAMbDLALCEFHLAOCEFHOXEKDNARCPE0MBAVALAQARCSgFrBBGSCL4GZ9rCSgCDTFYDBAdCEFGhAZeHRAVALAS9rCSgCDTFYDBAhAZtGoFGhASCSgGZeHSAZtHZDNDNADCD9HMBABAd87EBABCLFAS87EBABCDFAR87EBXEKAIAdbDBAICWFASbDBAICLFARbDBKAVALCDTFAdbDBAVC/ABFAOCITFGaARbDBAaAdbDLAVALCEFGLCSgCDTFARbDBAVC/ABFAOCEFCSgCITFGaASbDBAaARbDLAVALAoFCSgGLCDTFASbDBAVC/ABFAOCDFCSgGOCITFGRAdbDBARASbDLAOCEFHOALAZFHLAhAZFHdXEKAdCBAKrBBGaeGZARC/+EsGcFHRAaCSgHhDNDNAaCL4GoMBARCEFHSXEKARHSAVALAo9rCSgCDTFYDBHRKDNDNAhMBASCEFHdXEKASHdAVALAa9rCSgCDTFYDBHSKDNDNActMBAKCEFHaXEKAK8sBEGaCfEgHZDNDNAaCU9MMBAKCDFHaXEKAK8sBDGaCfBgCRTAZCfBgvHZDNAaCU9MMBAKCIFHaXEKAK8sBIGaCfBgCpTAZvHZDNAaCU9MMBAKCLFHaXEKAK8sBLGaCfBgCxTAZvHZDNAaCU9MMBAKCVFHaXEKAKCOFHaAKrBVC3TAZvHZKAZCE4CBAZCEg9r7AMFGMHZKDNDNAoCSsMBAaHcXEKAa8sBBGKCfEgHRDNDNAKCU9MMBAaCEFHcXEKAa8sBEGKCfBgCRTARCfBgvHRDNAKCU9MMBAaCDFHcXEKAa8sBDGKCfBgCpTARvHRDNAKCU9MMBAaCIFHcXEKAa8sBIGKCfBgCxTARvHRDNAKCU9MMBAaCLFHcXEKAaCVFHcAarBLC3TARvHRKARCE4CBARCEg9r7AMFGMHRKDNDNAhCSsMBAcHKXEKAc8sBBGKCfEgHSDNDNAKCU9MMBAcCEFHKXEKAc8sBEGKCfBgCRTASCfBgvHSDNAKCU9MMBAcCDFHKXEKAc8sBDGKCfBgCpTASvHSDNAKCU9MMBAcCIFHKXEKAc8sBIGKCfBgCxTASvHSDNAKCU9MMBAcCLFHKXEKAcCVFHKAcrBLC3TASvHSKASCE4CBASCEg9r7AMFGMHSKDNDNADCD9HMBABAZ87EBABCLFAS87EBABCDFAR87EBXEKAIAZbDBAICWFASbDBAICLFARbDBKAVC/ABFAOCITFGaARbDBAaAZbDLAVALCDTFAZbDBAVC/ABFAOCEFCSgCITFGaASbDBAaARbDLAVALCEFGLCSgCDTFARbDBAVC/ABFAOCDFCSgCITFGRAZbDBARASbDLAVALAotAoCSsvFGLCSgCDTFASbDBALAhtAhCSsvFHLAOCIFHOKAWCEFHWABCOFHBAICXFHIAOCSgHOALCSgHLApCIFGpAE6MBKKCBC99AKAQseHOKAVC/AEF8kJJJJBAOK/tLEDU8jJJJJBCZ9rHVC9+HODNAECVFAL0MBCUHOAIrBBC/+EgC/QE9HMBAV9CB83IWAICEFHOAIALFC98FHIDNAEtMBDNADCDsMBINDNAOAI6MBC9+SKAO8sBBGDCfEgHLDNDNADCU9MMBAOCEFHOXEKAO8sBEGDCfBgCRTALCfBgvHLDNADCU9MMBAOCDFHOXEKAO8sBDGDCfBgCpTALvHLDNADCU9MMBAOCIFHOXEKAO8sBIGDCfBgCxTALvHLDNADCU9MMBAOCLFHOXEKAOrBLC3TALvHLAOCVFHOKAVCWFALCEgCDTvGDALCD4CBALCE4CEg9r7ADYDBFGLbDBABALbDBABCLFHBAECUFGEMBXDKKINDNAOAI6MBC9+SKAO8sBBGDCfEgHLDNDNADCU9MMBAOCEFHOXEKAO8sBEGDCfBgCRTALCfBgvHLDNADCU9MMBAOCDFHOXEKAO8sBDGDCfBgCpTALvHLDNADCU9MMBAOCIFHOXEKAO8sBIGDCfBgCxTALvHLDNADCU9MMBAOCLFHOXEKAOrBLC3TALvHLAOCVFHOKABALCD4CBALCE4CEg9r7AVCWFALCEgCDTvGLYDBFGD87EBALADbDBABCDFHBAECUFGEMBKKCBC99AOAIseHOKAOK+lVOEUE99DUD99EUD99DNDNADCL9HMBAEtMEINDNDNjBBBzjBBB+/ABCDFGD8sBB+yAB8sBBGI+yGL+L+TABCEFGV8sBBGO+yGR+L+TGWjBBBB9gGdeAWjBB/+9CAWAWnjBBBBAWAdeGQAQ+MGKAICU9KeALmGLALnAQAKAOCU9KeARmGQAQnmm+R+VGRnmGW+LjBBB9P9dtMBAW+oHIXEKCJJJJ94HIKADAI86BBDNDNjBBBzjBBB+/AQjBBBB9geAQARnmGW+LjBBB9P9dtMBAW+oHDXEKCJJJJ94HDKAVAD86BBDNDNjBBBzjBBB+/ALjBBBB9geALARnmGW+LjBBB9P9dtMBAW+oHDXEKCJJJJ94HDKABAD86BBABCLFHBAECUFGEMBXDKKAEtMBINDNDNjBBBzjBBB+/ABCLFGD8uEB+yAB8uEBGI+yGL+L+TABCDFGV8uEBGO+yGR+L+TGWjBBBB9gGdeAWjB/+fsAWAWnjBBBBAWAdeGQAQ+MGKAICU9KeALmGLALnAQAKAOCU9KeARmGQAQnmm+R+VGRnmGW+LjBBB9P9dtMBAW+oHIXEKCJJJJ94HIKADAI87EBDNDNjBBBzjBBB+/AQjBBBB9geAQARnmGW+LjBBB9P9dtMBAW+oHDXEKCJJJJ94HDKAVAD87EBDNDNjBBBzjBBB+/ALjBBBB9geALARnmGW+LjBBB9P9dtMBAW+oHDXEKCJJJJ94HDKABAD87EBABCWFHBAECUFGEMBKKK/SILIUI99IUE99DNAEtMBCBHIABHLINDNDNj/zL81zALCOF8uEBGVCIv+y+VGOAL8uEB+ynGRjB/+fsnjBBBzjBBB+/ARjBBBB9gemGW+LjBBB9P9dtMBAW+oHdXEKCJJJJ94HdKALCLF8uEBHQALCDF8uEBHKABAVCEFCIgAIvCETFAd87EBDNDNAOAK+ynGWjB/+fsnjBBBzjBBB+/AWjBBBB9gemGX+LjBBB9P9dtMBAX+oHKXEKCJJJJ94HKKABAVCDFCIgAIvCETFAK87EBDNDNAOAQ+ynGOjB/+fsnjBBBzjBBB+/AOjBBBB9gemGX+LjBBB9P9dtMBAX+oHQXEKCJJJJ94HQKABAVCUFCIgAIvCETFAQ87EBDNDNjBBJzARARn+TAWAWn+TAOAOn+TGRjBBBBARjBBBB9ge+RjB/+fsnjBBBzmGR+LjBBB9P9dtMBAR+oHQXEKCJJJJ94HQKABAVCIgAIvCETFAQ87EBALCWFHLAICLFHIAECUFGEMBKKK6BDNADCD4AE2GEtMBINABABYDBGDCWTCW91+yADCk91ClTCJJJ/8IF++nuDBABCLFHBAECUFGEMBKKK9TEIUCBCBYDJ1JJBGEABCIFC98gFGBbDJ1JJBDNDNABzBCZTGD9NMBCUHIABAD9rCffIFCZ4NBCUsMEKAEHIKAIK/lEEEUDNDNAEABvCIgtMBABHIXEKDNDNADCZ9PMBABHIXEKABHIINAIAEYDBbDBAICLFAECLFYDBbDBAICWFAECWFYDBbDBAICXFAECXFYDBbDBAICZFHIAECZFHEADC9wFGDCS0MBKKADCL6MBINAIAEYDBbDBAECLFHEAICLFHIADC98FGDCI0MBKKDNADtMBINAIAErBB86BBAICEFHIAECEFHEADCUFGDMBKKABK/AEEDUDNDNABCIgtMBABHIXEKAECfEgC+B+C+EW2HLDNDNADCZ9PMBABHIXEKABHIINAIALbDBAICXFALbDBAICWFALbDBAICLFALbDBAICZFHIADC9wFGDCS0MBKKADCL6MBINAIALbDBAICLFHIADC98FGDCI0MBKKDNADtMBINAIAE86BBAICEFHIADCUFGDMBKKABKKKEBCJWKLZ9kBB";
var wasm_simd = "B9h79tEBBBE5V9gBB9gVUUUUUEU9gIUUUB9gDUUB9gEUEUIMXBBEBEEDIDIDLLVE9wEEEVIEBEOWEUEC+Q/aEKR/LEdO9tw9t9vv95DBh9f9f939h79t9f9j9h229f9jT9vv7BB8a9tw79o9v9wT9f9kw9j9v9kw9WwvTw949C919m9mwvBDy9tw79o9v9wT9f9kw9j9v9kw69u9kw949C919m9mwvBLe9tw79o9v9wT9f9kw9j9v9kw69u9kw949Twg91w9u9jwBVl9tw79o9v9wT9f9kw9j9v9kws9p2Twv9P9jTBOk9tw79o9v9wT9f9kw9j9v9kws9p2Twv9R919hTBWl9tw79o9v9wT9f9kw9j9v9kws9p2Twvt949wBQL79iv9rBKQ/j6XLBZIK9+EVU8jJJJJBCZ9rHBCBHEINCBHDCBHIINABCWFADFAICJUAEAD4CEgGLe86BBAIALFHIADCEFGDCW9HMBKAEC+Q+YJJBFAI86BBAECITC+Q1JJBFAB8pIW83IBAECEFGECJD9HMBKK1HLSUD97EUO978jJJJJBCJ/KB9rGV8kJJJJBC9+HODNADCEFAL0MBCUHOAIrBBC+gE9HMBAVAIALFGRAD9rAD/8QBBCJ/ABAD9uC/wfBgGOCJDAOCJD6eHWAICEFHOCBHdDNINAdAE9PMEAWAEAd9rAdAWFAE6eHQDNDNADtMBAQCSFGLC9wgGKCI2HXAKCETHMALCL4CIFCD4HpCBHSINAOHZCBHhDNINDNARAZ9rAp9PMBCBHOXVKAVCJ/CBFAhAK2FHoAZApFHOCBHIDNAKC/AB6MBARAO9rC/gB6MBCBHLINAoALFHIDNDNDNDNDNAZALCO4FrBBGaCIgpLBEDIBKAICBPhPKLBXIKAIAOPBBLAOPBBBGcCLP+MEAcPMBZEhDoIaLcVxOqRlGcCDP+MEAcPMBZEhDoIaLcVxOqRlC+D+G+MkPhP9OGxCIPSP8jGcP5B9CJf/8/4/w/g/AB9+9Cu1+nGqCITC+Q1JJBFPBIBAqC+Q+YJJBFPBBBGlAlPMBBBBBBBBBBBBBBBBAcP5E9CJf/8/4/w/g/AB9+9Cu1+nGqCITC+Q1JJBFPBIBP9uPMBEDILVORZhoacxqlPpAxAcP9SPKLBAOCLFAlPqBFAqC+Q+YJJBFrBBFHOXDKAIAOPBBWAOPBBBGcCLP+MEAcPMBZEhDoIaLcVxOqRlC+P+e+8/4BPhP9OGxCSPSP8jGcP5B9CJf/8/4/w/g/AB9+9Cu1+nGqCITC+Q1JJBFPBIBAqC+Q+YJJBFPBBBGlAlPMBBBBBBBBBBBBBBBBAcP5E9CJf/8/4/w/g/AB9+9Cu1+nGqCITC+Q1JJBFPBIBP9uPMBEDILVORZhoacxqlPpAxAcP9SPKLBAOCWFAlPqBFAqC+Q+YJJBFrBBFHOXEKAIAOPBBBPKLBAOCZFHOKDNDNDNDNDNAaCD4CIgpLBEDIBKAICBPhPKLZXIKAIAOPBBLAOPBBBGcCLP+MEAcPMBZEhDoIaLcVxOqRlGcCDP+MEAcPMBZEhDoIaLcVxOqRlC+D+G+MkPhP9OGxCIPSP8jGcP5B9CJf/8/4/w/g/AB9+9Cu1+nGqCITC+Q1JJBFPBIBAqC+Q+YJJBFPBBBGlAlPMBBBBBBBBBBBBBBBBAcP5E9CJf/8/4/w/g/AB9+9Cu1+nGqCITC+Q1JJBFPBIBP9uPMBEDILVORZhoacxqlPpAxAcP9SPKLZAOCLFAlPqBFAqC+Q+YJJBFrBBFHOXDKAIAOPBBWAOPBBBGcCLP+MEAcPMBZEhDoIaLcVxOqRlC+P+e+8/4BPhP9OGxCSPSP8jGcP5B9CJf/8/4/w/g/AB9+9Cu1+nGqCITC+Q1JJBFPBIBAqC+Q+YJJBFPBBBGlAlPMBBBBBBBBBBBBBBBBAcP5E9CJf/8/4/w/g/AB9+9Cu1+nGqCITC+Q1JJBFPBIBP9uPMBEDILVORZhoacxqlPpAxAcP9SPKLZAOCWFAlPqBFAqC+Q+YJJBFrBBFHOXEKAIAOPBBBPKLZAOCZFHOKDNDNDNDNDNAaCL4CIgpLBEDIBKAICBPhPKLAXIKAIAOPBBLAOPBBBGcCLP+MEAcPMBZEhDoIaLcVxOqRlGcCDP+MEAcPMBZEhDoIaLcVxOqRlC+D+G+MkPhP9OGxCIPSP8jGcP5B9CJf/8/4/w/g/AB9+9Cu1+nGqCITC+Q1JJBFPBIBAqC+Q+YJJBFPBBBGlAlPMBBBBBBBBBBBBBBBBAcP5E9CJf/8/4/w/g/AB9+9Cu1+nGqCITC+Q1JJBFPBIBP9uPMBEDILVORZhoacxqlPpAxAcP9SPKLAAOCLFAlPqBFAqC+Q+YJJBFrBBFHOXDKAIAOPBBWAOPBBBGcCLP+MEAcPMBZEhDoIaLcVxOqRlC+P+e+8/4BPhP9OGxCSPSP8jGcP5B9CJf/8/4/w/g/AB9+9Cu1+nGqCITC+Q1JJBFPBIBAqC+Q+YJJBFPBBBGlAlPMBBBBBBBBBBBBBBBBAcP5E9CJf/8/4/w/g/AB9+9Cu1+nGqCITC+Q1JJBFPBIBP9uPMBEDILVORZhoacxqlPpAxAcP9SPKLAAOCWFAlPqBFAqC+Q+YJJBFrBBFHOXEKAIAOPBBBPKLAAOCZFHOKDNDNDNDNDNAaCO4pLBEDIBKAICBPhPKL8wXIKAIAOPBBLAOPBBBGcCLP+MEAcPMBZEhDoIaLcVxOqRlGcCDP+MEAcPMBZEhDoIaLcVxOqRlC+D+G+MkPhP9OGxCIPSP8jGcP5B9CJf/8/4/w/g/AB9+9Cu1+nGaCITC+Q1JJBFPBIBAaC+Q+YJJBFPBBBGlAlPMBBBBBBBBBBBBBBBBAcP5E9CJf/8/4/w/g/AB9+9Cu1+nGaCITC+Q1JJBFPBIBP9uPMBEDILVORZhoacxqlPpAxAcP9SPKL8wAOCLFAlPqBFAaC+Q+YJJBFrBBFHOXDKAIAOPBBWAOPBBBGcCLP+MEAcPMBZEhDoIaLcVxOqRlC+P+e+8/4BPhP9OGxCSPSP8jGcP5B9CJf/8/4/w/g/AB9+9Cu1+nGaCITC+Q1JJBFPBIBAaC+Q+YJJBFPBBBGlAlPMBBBBBBBBBBBBBBBBAcP5E9CJf/8/4/w/g/AB9+9Cu1+nGaCITC+Q1JJBFPBIBP9uPMBEDILVORZhoacxqlPpAxAcP9SPKL8wAOCWFAlPqBFAaC+Q+YJJBFrBBFHOXEKAIAOPBBBPKL8wAOCZFHOKALC/ABFHIALCJEFAK0MEAIHLARAO9rC/fB0MBKKDNAIAK9PMBAICI4HLINDNARAO9rCk9PMBCBHOXRKAoAIFHaDNDNDNDNDNAZAICO4FrBBALCOg4CIgpLBEDIBKAaCBPhPKLBXIKAaAOPBBLAOPBBBGcCLP+MEAcPMBZEhDoIaLcVxOqRlGcCDP+MEAcPMBZEhDoIaLcVxOqRlC+D+G+MkPhP9OGxCIPSP8jGcP5B9CJf/8/4/w/g/AB9+9Cu1+nGqCITC+Q1JJBFPBIBAqC+Q+YJJBFPBBBGlAlPMBBBBBBBBBBBBBBBBAcP5E9CJf/8/4/w/g/AB9+9Cu1+nGqCITC+Q1JJBFPBIBP9uPMBEDILVORZhoacxqlPpAxAcP9SPKLBAOCLFAlPqBFAqC+Q+YJJBFrBBFHOXDKAaAOPBBWAOPBBBGcCLP+MEAcPMBZEhDoIaLcVxOqRlC+P+e+8/4BPhP9OGxCSPSP8jGcP5B9CJf/8/4/w/g/AB9+9Cu1+nGqCITC+Q1JJBFPBIBAqC+Q+YJJBFPBBBGlAlPMBBBBBBBBBBBBBBBBAcP5E9CJf/8/4/w/g/AB9+9Cu1+nGqCITC+Q1JJBFPBIBP9uPMBEDILVORZhoacxqlPpAxAcP9SPKLBAOCWFAlPqBFAqC+Q+YJJBFrBBFHOXEKAaAOPBBBPKLBAOCZFHOKALCDFHLAICZFGIAK6MBKKDNAOtMBAOHZAhCEFGhCLsMDXEKKCBHOXIKDNAKtMBAVCJDFASFHIAVASFPBDBHlCBHaINAIAVCJ/CBFAaFGLPBLBGxCEP9tAxCEPSGcP9OP9hP9RGxALAKFPBLBGkCEP9tAkAcP9OP9hP9RGkPMBZEhDoIaLcVxOqRlGyALAMFPBLBG8aCEP9tA8aAcP9OP9hP9RG8aALAXFPBLBGeCEP9tAeAcP9OP9hP9RGePMBZEhDoIaLcVxOqRlG3PMBEZhDIoaLVcxORqlGcAcPMBEDIBEDIBEDIBEDIAlP9uGlPeBbDBAIADFGLAlAcAcPMLVORLVORLVORLVORP9uGlPeBbDBALADFGLAlAcAcPMWdQKWdQKWdQKWdQKP9uGlPeBbDBALADFGLAlAcAcPMXMpSXMpSXMpSXMpSP9uGlPeBbDBALADFGLAlAyA3PMWdkyQK8aeXM35pS8e8fGcAcPMBEDIBEDIBEDIBEDIP9uGlPeBbDBALADFGLAlAcAcPMLVORLVORLVORLVORP9uGlPeBbDBALADFGLAlAcAcPMWdQKWdQKWdQKWdQKP9uGlPeBbDBALADFGLAlAcAcPMXMpSXMpSXMpSXMpSP9uGlPeBbDBALADFGLAlAxAkPMWkdyQ8aKeX3M5p8eS8fGxA8aAePMWkdyQ8aKeX3M5p8eS8fGkPMBEZhDIoaLVcxORqlGcAcPMBEDIBEDIBEDIBEDIP9uGlPeBbDBALADFGLAlAcAcPMLVORLVORLVORLVORP9uGlPeBbDBALADFGLAlAcAcPMWdQKWdQKWdQKWdQKP9uGlPeBbDBALADFGLAlAcAcPMXMpSXMpSXMpSXMpSP9uGlPeBbDBALADFGLAlAxAkPMWdkyQK8aeXM35pS8e8fGcAcPMBEDIBEDIBEDIBEDIP9uGlPeBbDBALADFGLAlAcAcPMLVORLVORLVORLVORP9uGlPeBbDBALADFGLAlAcAcPMWdQKWdQKWdQKWdQKP9uGlPeBbDBALADFGLAlAcAcPMXMpSXMpSXMpSXMpSP9uGlPeBbDBALADFHIAaCZFGaAK6MBKKASCLFGSAD6MBKKABAdAD2FAVCJDFAQAD2/8QBBAVAVCJDFAQCUFAD2FAD/8QBBKAQCBAOeAdFHdAOMBKC9+HOXEKCBC99ARAO9rADCAADCA0eseHOKAVCJ/KBF8kJJJJBAOKWBZ+BJJJBK+KoEZU8jJJJJBC/AE9rGV8kJJJJBC9+HODNAECI9uGRChFAL0MBCUHOAIrBBGWC/wEgC/gE9HMBAWCSgGdCE0MBAVC/ABFCfECJE/8KBAVCuF9CU83IBAVC8wF9CU83IBAVCYF9CU83IBAVCAF9CU83IBAVCkF9CU83IBAVCZF9CU83IBAV9CU83IWAV9CU83IBAIALFC9wFHQAICEFGWARFHKDNAEtMBCMCSAdCEseHXABHICBHdCBHMCBHpCBHLCBHOINDNAKAQ9NMBC9+HOXIKDNDNAWrBBGRC/vE0MBAVC/ABFARCL4CU7AOFCSgCITFGSYDLHZASYDBHhDNARCSgGSAX9PMBAVARCU7ALFCSgCDTFYDBAdASeHRAStHSDNDNADCD9HMBABAh87EBABCLFAR87EBABCDFAZ87EBXEKAIAhbDBAICWFARbDBAICLFAZbDBKAdASFHdAVC/ABFAOCITFGoARbDBAoAZbDLAVALCDTFARbDBAVC/ABFAOCEFCSgGOCITFGZAhbDBAZARbDLALASFHLAOCEFHOXDKDNDNASCSsMBAMASFASC987FCEFHMXEKAK8sBBGSCfEgHRDNDNASCU9MMBAKCEFHKXEKAK8sBEGSCfBgCRTARCfBgvHRDNASCU9MMBAKCDFHKXEKAK8sBDGSCfBgCpTARvHRDNASCU9MMBAKCIFHKXEKAK8sBIGSCfBgCxTARvHRDNASCU9MMBAKCLFHKXEKAKrBLC3TARvHRAKCVFHKKARCE4CBARCEg9r7AMFHMKDNDNADCD9HMBABAh87EBABCLFAM87EBABCDFAZ87EBXEKAIAhbDBAICWFAMbDBAICLFAZbDBKAVC/ABFAOCITFGRAMbDBARAZbDLAVALCDTFAMbDBAVC/ABFAOCEFCSgGOCITFGRAhbDBARAMbDLALCEFHLAOCEFHOXEKDNARCPE0MBAVALAQARCSgFrBBGSCL4GZ9rCSgCDTFYDBAdCEFGhAZeHRAVALAS9rCSgCDTFYDBAhAZtGoFGhASCSgGZeHSAZtHZDNDNADCD9HMBABAd87EBABCLFAS87EBABCDFAR87EBXEKAIAdbDBAICWFASbDBAICLFARbDBKAVALCDTFAdbDBAVC/ABFAOCITFGaARbDBAaAdbDLAVALCEFGLCSgCDTFARbDBAVC/ABFAOCEFCSgCITFGaASbDBAaARbDLAVALAoFCSgGLCDTFASbDBAVC/ABFAOCDFCSgGOCITFGRAdbDBARASbDLAOCEFHOALAZFHLAhAZFHdXEKAdCBAKrBBGaeGZARC/+EsGcFHRAaCSgHhDNDNAaCL4GoMBARCEFHSXEKARHSAVALAo9rCSgCDTFYDBHRKDNDNAhMBASCEFHdXEKASHdAVALAa9rCSgCDTFYDBHSKDNDNActMBAKCEFHaXEKAK8sBEGaCfEgHZDNDNAaCU9MMBAKCDFHaXEKAK8sBDGaCfBgCRTAZCfBgvHZDNAaCU9MMBAKCIFHaXEKAK8sBIGaCfBgCpTAZvHZDNAaCU9MMBAKCLFHaXEKAK8sBLGaCfBgCxTAZvHZDNAaCU9MMBAKCVFHaXEKAKCOFHaAKrBVC3TAZvHZKAZCE4CBAZCEg9r7AMFGMHZKDNDNAoCSsMBAaHcXEKAa8sBBGKCfEgHRDNDNAKCU9MMBAaCEFHcXEKAa8sBEGKCfBgCRTARCfBgvHRDNAKCU9MMBAaCDFHcXEKAa8sBDGKCfBgCpTARvHRDNAKCU9MMBAaCIFHcXEKAa8sBIGKCfBgCxTARvHRDNAKCU9MMBAaCLFHcXEKAaCVFHcAarBLC3TARvHRKARCE4CBARCEg9r7AMFGMHRKDNDNAhCSsMBAcHKXEKAc8sBBGKCfEgHSDNDNAKCU9MMBAcCEFHKXEKAc8sBEGKCfBgCRTASCfBgvHSDNAKCU9MMBAcCDFHKXEKAc8sBDGKCfBgCpTASvHSDNAKCU9MMBAcCIFHKXEKAc8sBIGKCfBgCxTASvHSDNAKCU9MMBAcCLFHKXEKAcCVFHKAcrBLC3TASvHSKASCE4CBASCEg9r7AMFGMHSKDNDNADCD9HMBABAZ87EBABCLFAS87EBABCDFAR87EBXEKAIAZbDBAICWFASbDBAICLFARbDBKAVC/ABFAOCITFGaARbDBAaAZbDLAVALCDTFAZbDBAVC/ABFAOCEFCSgCITFGaASbDBAaARbDLAVALCEFGLCSgCDTFARbDBAVC/ABFAOCDFCSgCITFGRAZbDBARASbDLAVALAotAoCSsvFGLCSgCDTFASbDBALAhtAhCSsvFHLAOCIFHOKAWCEFHWABCOFHBAICXFHIAOCSgHOALCSgHLApCIFGpAE6MBKKCBC99AKAQseHOKAVC/AEF8kJJJJBAOK/tLEDU8jJJJJBCZ9rHVC9+HODNAECVFAL0MBCUHOAIrBBC/+EgC/QE9HMBAV9CB83IWAICEFHOAIALFC98FHIDNAEtMBDNADCDsMBINDNAOAI6MBC9+SKAO8sBBGDCfEgHLDNDNADCU9MMBAOCEFHOXEKAO8sBEGDCfBgCRTALCfBgvHLDNADCU9MMBAOCDFHOXEKAO8sBDGDCfBgCpTALvHLDNADCU9MMBAOCIFHOXEKAO8sBIGDCfBgCxTALvHLDNADCU9MMBAOCLFHOXEKAOrBLC3TALvHLAOCVFHOKAVCWFALCEgCDTvGDALCD4CBALCE4CEg9r7ADYDBFGLbDBABALbDBABCLFHBAECUFGEMBXDKKINDNAOAI6MBC9+SKAO8sBBGDCfEgHLDNDNADCU9MMBAOCEFHOXEKAO8sBEGDCfBgCRTALCfBgvHLDNADCU9MMBAOCDFHOXEKAO8sBDGDCfBgCpTALvHLDNADCU9MMBAOCIFHOXEKAO8sBIGDCfBgCxTALvHLDNADCU9MMBAOCLFHOXEKAOrBLC3TALvHLAOCVFHOKABALCD4CBALCE4CEg9r7AVCWFALCEgCDTvGLYDBFGD87EBALADbDBABCDFHBAECUFGEMBKKCBC99AOAIseHOKAOK/xVDIUO978jJJJJBCA9rGI8kJJJJBDNDNADCL9HMBDNAEC98gGLtMBABHDCBHVINADADPBBBGOCkP+rECkP+sEP/6EGRAOCWP+rECkP+sEP/6EARP/gEAOCZP+rECkP+sEP/6EGWP/gEP/kEP/lEGdCBPhP+2EGQARCJJJJ94PhGKP9OP9RP/kEGRjBB/+9CPaARARP/mEAdAdP/mEAWAQAWAKP9OP9RP/kEGRARP/mEP/kEP/kEP/jEP/nEGWP/mEjBBN0PaGQP/kECfEPhP9OAOCJJJ94PhP9OP9QARAWP/mEAQP/kECWP+rECJ/+IPhP9OP9QAdAWP/mEAQP/kECZP+rECJJ/8RPhP9OP9QPKBBADCZFHDAVCLFGVAL6MBKKALAE9PMEAIAECIgGVCDTGDvCBCZAD9r/8KBAIABALCDTFGLAD/8QBBDNAVtMBAIAIPBLBGOCkP+rECkP+sEP/6EGRAOCWP+rECkP+sEP/6EARP/gEAOCZP+rECkP+sEP/6EGWP/gEP/kEP/lEGdCBPhP+2EGQARCJJJJ94PhGKP9OP9RP/kEGRjBB/+9CPaARARP/mEAdAdP/mEAWAQAWAKP9OP9RP/kEGRARP/mEP/kEP/kEP/jEP/nEGWP/mEjBBN0PaGQP/kECfEPhP9OAOCJJJ94PhP9OP9QARAWP/mEAQP/kECWP+rECJ/+IPhP9OP9QAdAWP/mEAQP/kECZP+rECJJ/8RPhP9OP9QPKLBKALAIAD/8QBBXEKABAEC98gGDZ+HJJJBADAE9PMBAIAECIgGLCITGVFCBCAAV9r/8KBAIABADCITFGDAV/8QBBAIALZ+HJJJBADAIAV/8QBBKAICAF8kJJJJBK+yIDDUR97DNAEtMBCBHDINABCZFGIAIPBBBGLCBPhGVCJJ98P3ECJJ98P3IGOP9OABPBBBGRALPMLVORXMpScxql358e8fCffEPhP9OP/6EARALPMBEDIWdQKZhoaky8aeGLCZP+sEP/6EGWP/gEALCZP+rECZP+sEP/6EGdP/gEP/kEP/lEGLjB/+fsPaAdALAVP+2EGVAdCJJJJ94PhGQP9OP9RP/kEGdAdP/mEALALP/mEAWAVAWAQP9OP9RP/kEGLALP/mEP/kEP/kEP/jEP/nEGWP/mEjBBN0PaGVP/kECZP+rEAdAWP/mEAVP/kECffIPhP9OP9QGdALAWP/mEAVP/kECUPSCBPlDCBPlICBPlOCBPlRCBPlQCBPlKCBPlpCBPlSP9OGLPMWdkyQK8aeXM35pS8e8fP9QPKBBABARAOP9OAdALPMBEZhDIoaLVcxORqlP9QPKBBABCAFHBADCLFGDAE6MBKKK94EIU8jJJJJBCA9rGI8kJJJJBABAEC98gGLZ+JJJJBDNALAE9PMBAIAECIgGVCITGEFCBCAAE9r/8KBAIABALCITFGBAE/8QBBAIAVZ+JJJJBABAIAE/8QBBKAICAF8kJJJJBK/hILDUE97EUV978jJJJJBCZ9rHDDNAEtMBCBHIINADABPBBBGLABCZFGVPBBBGOPMLVORXMpScxql358e8fGRCZP+sEGWCLP+rEPKLBABjBBJzPaj/zL81zPaAWCIPhP9QP/6EP/nEGWALAOPMBEDIWdQKZhoaky8aeGLCZP+rECZP+sEP/6EP/mEGOAOP/mEAWALCZP+sEP/6EP/mEGdAdP/mEAWARCZP+rECZP+sEP/6EP/mEGRARP/mEP/kEP/kEP/lECBPhP+4EP/jEjB/+fsPaGWP/mEjBBN0PaGLP/kECffIPhGQP9OAdAWP/mEALP/kECZP+rEP9QGdARAWP/mEALP/kECZP+rEAOAWP/mEALP/kEAQP9OP9QGWPMBEZhDIoaLVcxORqlGLP5BADPBLBPeB+t+J83IBABCWFALP5EADPBLBPeE+t+J83IBAVAdAWPMWdkyQK8aeXM35pS8e8fGWP5BADPBLBPeD+t+J83IBABCkFAWP5EADPBLBPeI+t+J83IBABCAFHBAICLFGIAE6MBKKK/3EDIUE978jJJJJBC/AB9rHIDNADCD4AE2GLC98gGVtMBCBHDABHEINAEAEPBBBGOCWP+rECWP+sEP/6EAOCkP+sEClP+rECJJJ/8IPhP+uEP/mEPKBBAECZFHEADCLFGDAV6MBKKDNAVAL9PMBAIALCIgGDCDTGEvCBC/ABAE9r/8KBAIABAVCDTFGVAE/8QBBDNADtMBAIAIPBLBGOCWP+rECWP+sEP/6EAOCkP+sEClP+rECJJJ/8IPhP+uEP/mEPKLBKAVAIAE/8QBBKK9TEIUCBCBYDJ1JJBGEABCIFC98gFGBbDJ1JJBDNDNABzBCZTGD9NMBCUHIABAD9rCffIFCZ4NBCUsMEKAEHIKAIKKKEBCJWKLZ9tBB";
var detector = new Uint8Array([0, 97, 115, 109, 1, 0, 0, 0, 1, 4, 1, 96, 0, 0, 3, 3, 2, 0, 0, 5, 3, 1, 0, 1, 12, 1, 0, 10, 22, 2, 12, 0, 65, 0, 65, 0, 65, 0, 252, 10, 0, 0, 11, 7, 0, 65, 0, 253, 15, 26, 11]);
var wasmpack = new Uint8Array([32, 0, 65, 2, 1, 106, 34, 33, 3, 128, 11, 4, 13, 64, 6, 253, 10, 7, 15, 116, 127, 5, 8, 12, 40, 16, 19, 54, 20, 9, 27, 255, 113, 17, 42, 67, 24, 23, 146, 148, 18, 14, 22, 45, 70, 69, 56, 114, 101, 21, 25, 63, 75, 136, 108, 28, 118, 29, 73, 115]);
if (typeof WebAssembly !== "object") {
return {
supported: false
};
}
var wasm = wasm_base;
if (WebAssembly.validate(detector)) {
wasm = wasm_simd;
}
var instance;
var promise = WebAssembly.instantiate(unpack(wasm), {}).then(function(result) {
instance = result.instance;
instance.exports.__wasm_call_ctors();
});
function unpack(data) {
var result = new Uint8Array(data.length);
for (var i = 0; i < data.length; ++i) {
var ch = data.charCodeAt(i);
result[i] = ch > 96 ? ch - 71 : ch > 64 ? ch - 65 : ch > 47 ? ch + 4 : ch > 46 ? 63 : 62;
}
var write = 0;
for (var i = 0; i < data.length; ++i) {
result[write++] = result[i] < 60 ? wasmpack[result[i]] : (result[i] - 60) * 64 + result[++i];
}
return result.buffer.slice(0, write);
}
function decode(fun, target, count, size, source, filter) {
var sbrk = instance.exports.sbrk;
var count4 = count + 3 & ~3;
var tp = sbrk(count4 * size);
var sp = sbrk(source.length);
var heap = new Uint8Array(instance.exports.memory.buffer);
heap.set(source, sp);
var res = fun(tp, count, size, sp, source.length);
if (res == 0 && filter) {
filter(tp, count4, size);
}
target.set(heap.subarray(tp, tp + count * size));
sbrk(tp - sbrk(0));
if (res != 0) {
throw new Error("Malformed buffer data: " + res);
}
}
;
var filters = {
0: "",
1: "meshopt_decodeFilterOct",
2: "meshopt_decodeFilterQuat",
3: "meshopt_decodeFilterExp",
NONE: "",
OCTAHEDRAL: "meshopt_decodeFilterOct",
QUATERNION: "meshopt_decodeFilterQuat",
EXPONENTIAL: "meshopt_decodeFilterExp"
};
var decoders = {
0: "meshopt_decodeVertexBuffer",
1: "meshopt_decodeIndexBuffer",
2: "meshopt_decodeIndexSequence",
ATTRIBUTES: "meshopt_decodeVertexBuffer",
TRIANGLES: "meshopt_decodeIndexBuffer",
INDICES: "meshopt_decodeIndexSequence"
};
return {
ready: promise,
supported: true,
decodeVertexBuffer: function(target, count, size, source, filter) {
decode(instance.exports.meshopt_decodeVertexBuffer, target, count, size, source, instance.exports[filters[filter]]);
},
decodeIndexBuffer: function(target, count, size, source) {
decode(instance.exports.meshopt_decodeIndexBuffer, target, count, size, source);
},
decodeIndexSequence: function(target, count, size, source) {
decode(instance.exports.meshopt_decodeIndexSequence, target, count, size, source);
},
decodeGltfBuffer: function(target, count, size, source, mode2, filter) {
decode(instance.exports[decoders[mode2]], target, count, size, source, instance.exports[filters[filter]]);
}
};
}();
if (typeof exports2 === "object" && typeof module2 === "object")
module2.exports = MeshoptDecoder2;
else if (typeof define === "function" && define["amd"])
define([], function() {
return MeshoptDecoder2;
});
else if (typeof exports2 === "object")
exports2["MeshoptDecoder"] = MeshoptDecoder2;
else
(typeof self !== "undefined" ? self : exports2).MeshoptDecoder = MeshoptDecoder2;
}
});
// node_modules/meshoptimizer/index.js
var require_meshoptimizer = __commonJS({
"node_modules/meshoptimizer/index.js"(exports2, module2) {
var MeshoptEncoder = require_meshopt_encoder();
var MeshoptDecoder2 = require_meshopt_decoder();
module2.exports = { MeshoptEncoder, MeshoptDecoder: MeshoptDecoder2 };
}
});
// node_modules/bitmap-sdf/index.js
var require_bitmap_sdf = __commonJS({
"node_modules/bitmap-sdf/index.js"(exports2, module2) {
"use strict";
module2.exports = calcSDF2;
var INF = 1e20;
function calcSDF2(src, options) {
if (!options)
options = {};
var cutoff = options.cutoff == null ? 0.25 : options.cutoff;
var radius = options.radius == null ? 8 : options.radius;
var channel = options.channel || 0;
var w, h, size, data, intData, stride, ctx, canvas, imgData, i, l;
if (ArrayBuffer.isView(src) || Array.isArray(src)) {
if (!options.width || !options.height)
throw Error("For raw data width and height should be provided by options");
w = options.width, h = options.height;
data = src;
if (!options.stride)
stride = Math.floor(src.length / w / h);
else
stride = options.stride;
} else {
if (window.HTMLCanvasElement && src instanceof window.HTMLCanvasElement) {
canvas = src;
ctx = canvas.getContext("2d");
w = canvas.width, h = canvas.height;
imgData = ctx.getImageData(0, 0, w, h);
data = imgData.data;
stride = 4;
} else if (window.CanvasRenderingContext2D && src instanceof window.CanvasRenderingContext2D) {
canvas = src.canvas;
ctx = src;
w = canvas.width, h = canvas.height;
imgData = ctx.getImageData(0, 0, w, h);
data = imgData.data;
stride = 4;
} else if (window.ImageData && src instanceof window.ImageData) {
imgData = src;
w = src.width, h = src.height;
data = imgData.data;
stride = 4;
}
}
size = Math.max(w, h);
if (window.Uint8ClampedArray && data instanceof window.Uint8ClampedArray || window.Uint8Array && data instanceof window.Uint8Array) {
intData = data;
data = Array(w * h);
for (i = 0, l = Math.floor(intData.length / stride); i < l; i++) {
data[i] = intData[i * stride + channel] / 255;
}
} else {
if (stride !== 1)
throw Error("Raw data can have only 1 value per pixel");
}
var gridOuter = Array(w * h);
var gridInner = Array(w * h);
var f = Array(size);
var d = Array(size);
var z = Array(size + 1);
var v7 = Array(size);
for (i = 0, l = w * h; i < l; i++) {
var a3 = data[i];
gridOuter[i] = a3 === 1 ? 0 : a3 === 0 ? INF : Math.pow(Math.max(0, 0.5 - a3), 2);
gridInner[i] = a3 === 1 ? INF : a3 === 0 ? 0 : Math.pow(Math.max(0, a3 - 0.5), 2);
}
edt(gridOuter, w, h, f, d, v7, z);
edt(gridInner, w, h, f, d, v7, z);
var dist = window.Float32Array ? new Float32Array(w * h) : new Array(w * h);
for (i = 0, l = w * h; i < l; i++) {
dist[i] = Math.min(Math.max(1 - ((gridOuter[i] - gridInner[i]) / radius + cutoff), 0), 1);
}
return dist;
}
function edt(data, width, height, f, d, v7, z) {
for (var x = 0; x < width; x++) {
for (var y = 0; y < height; y++) {
f[y] = data[y * width + x];
}
edt1d(f, d, v7, z, height);
for (y = 0; y < height; y++) {
data[y * width + x] = d[y];
}
}
for (y = 0; y < height; y++) {
for (x = 0; x < width; x++) {
f[x] = data[y * width + x];
}
edt1d(f, d, v7, z, width);
for (x = 0; x < width; x++) {
data[y * width + x] = Math.sqrt(d[x]);
}
}
}
function edt1d(f, d, v7, z, n) {
v7[0] = 0;
z[0] = -INF;
z[1] = +INF;
for (var q = 1, k = 0; q < n; q++) {
var s = (f[q] + q * q - (f[v7[k]] + v7[k] * v7[k])) / (2 * q - 2 * v7[k]);
while (s <= z[k]) {
k--;
s = (f[q] + q * q - (f[v7[k]] + v7[k] * v7[k])) / (2 * q - 2 * v7[k]);
}
k++;
v7[k] = q;
z[k] = s;
z[k + 1] = +INF;
}
for (q = 0, k = 0; q < n; q++) {
while (z[k + 1] < q)
k++;
d[q] = (q - v7[k]) * (q - v7[k]) + f[v7[k]];
}
}
}
});
// node_modules/grapheme-splitter/index.js
var require_grapheme_splitter = __commonJS({
"node_modules/grapheme-splitter/index.js"(exports2, module2) {
function GraphemeSplitter() {
var CR = 0, LF = 1, Control = 2, Extend = 3, Regional_Indicator = 4, SpacingMark = 5, L = 6, V = 7, T = 8, LV = 9, LVT = 10, Other = 11, Prepend = 12, E_Base = 13, E_Modifier = 14, ZWJ = 15, Glue_After_Zwj = 16, E_Base_GAZ = 17;
var NotBreak = 0, BreakStart = 1, Break = 2, BreakLastRegional = 3, BreakPenultimateRegional = 4;
function isSurrogate(str, pos) {
return 55296 <= str.charCodeAt(pos) && str.charCodeAt(pos) <= 56319 && 56320 <= str.charCodeAt(pos + 1) && str.charCodeAt(pos + 1) <= 57343;
}
function codePointAt(str, idx) {
if (idx === void 0) {
idx = 0;
}
var code = str.charCodeAt(idx);
if (55296 <= code && code <= 56319 && idx < str.length - 1) {
var hi = code;
var low = str.charCodeAt(idx + 1);
if (56320 <= low && low <= 57343) {
return (hi - 55296) * 1024 + (low - 56320) + 65536;
}
return hi;
}
if (56320 <= code && code <= 57343 && idx >= 1) {
var hi = str.charCodeAt(idx - 1);
var low = code;
if (55296 <= hi && hi <= 56319) {
return (hi - 55296) * 1024 + (low - 56320) + 65536;
}
return low;
}
return code;
}
function shouldBreak(start, mid, end) {
var all = [start].concat(mid).concat([end]);
var previous = all[all.length - 2];
var next = end;
var eModifierIndex = all.lastIndexOf(E_Modifier);
if (eModifierIndex > 1 && all.slice(1, eModifierIndex).every(function(c) {
return c == Extend;
}) && [Extend, E_Base, E_Base_GAZ].indexOf(start) == -1) {
return Break;
}
var rIIndex = all.lastIndexOf(Regional_Indicator);
if (rIIndex > 0 && all.slice(1, rIIndex).every(function(c) {
return c == Regional_Indicator;
}) && [Prepend, Regional_Indicator].indexOf(previous) == -1) {
if (all.filter(function(c) {
return c == Regional_Indicator;
}).length % 2 == 1) {
return BreakLastRegional;
} else {
return BreakPenultimateRegional;
}
}
if (previous == CR && next == LF) {
return NotBreak;
} else if (previous == Control || previous == CR || previous == LF) {
if (next == E_Modifier && mid.every(function(c) {
return c == Extend;
})) {
return Break;
} else {
return BreakStart;
}
} else if (next == Control || next == CR || next == LF) {
return BreakStart;
} else if (previous == L && (next == L || next == V || next == LV || next == LVT)) {
return NotBreak;
} else if ((previous == LV || previous == V) && (next == V || next == T)) {
return NotBreak;
} else if ((previous == LVT || previous == T) && next == T) {
return NotBreak;
} else if (next == Extend || next == ZWJ) {
return NotBreak;
} else if (next == SpacingMark) {
return NotBreak;
} else if (previous == Prepend) {
return NotBreak;
}
var previousNonExtendIndex = all.indexOf(Extend) != -1 ? all.lastIndexOf(Extend) - 1 : all.length - 2;
if ([E_Base, E_Base_GAZ].indexOf(all[previousNonExtendIndex]) != -1 && all.slice(previousNonExtendIndex + 1, -1).every(function(c) {
return c == Extend;
}) && next == E_Modifier) {
return NotBreak;
}
if (previous == ZWJ && [Glue_After_Zwj, E_Base_GAZ].indexOf(next) != -1) {
return NotBreak;
}
if (mid.indexOf(Regional_Indicator) != -1) {
return Break;
}
if (previous == Regional_Indicator && next == Regional_Indicator) {
return NotBreak;
}
return BreakStart;
}
this.nextBreak = function(string, index) {
if (index === void 0) {
index = 0;
}
if (index < 0) {
return 0;
}
if (index >= string.length - 1) {
return string.length;
}
var prev = getGraphemeBreakProperty(codePointAt(string, index));
var mid = [];
for (var i = index + 1; i < string.length; i++) {
if (isSurrogate(string, i - 1)) {
continue;
}
var next = getGraphemeBreakProperty(codePointAt(string, i));
if (shouldBreak(prev, mid, next)) {
return i;
}
mid.push(next);
}
return string.length;
};
this.splitGraphemes = function(str) {
var res = [];
var index = 0;
var brk;
while ((brk = this.nextBreak(str, index)) < str.length) {
res.push(str.slice(index, brk));
index = brk;
}
if (index < str.length) {
res.push(str.slice(index));
}
return res;
};
this.iterateGraphemes = function(str) {
var index = 0;
var res = {
next: function() {
var value;
var brk;
if ((brk = this.nextBreak(str, index)) < str.length) {
value = str.slice(index, brk);
index = brk;
return { value, done: false };
}
if (index < str.length) {
value = str.slice(index);
index = str.length;
return { value, done: false };
}
return { value: void 0, done: true };
}.bind(this)
};
if (typeof Symbol !== "undefined" && Symbol.iterator) {
res[Symbol.iterator] = function() {
return res;
};
}
return res;
};
this.countGraphemes = function(str) {
var count = 0;
var index = 0;
var brk;
while ((brk = this.nextBreak(str, index)) < str.length) {
index = brk;
count++;
}
if (index < str.length) {
count++;
}
return count;
};
function getGraphemeBreakProperty(code) {
if (1536 <= code && code <= 1541 || 1757 == code || 1807 == code || 2274 == code || 3406 == code || 69821 == code || 70082 <= code && code <= 70083 || 72250 == code || 72326 <= code && code <= 72329 || 73030 == code) {
return Prepend;
}
if (13 == code) {
return CR;
}
if (10 == code) {
return LF;
}
if (0 <= code && code <= 9 || 11 <= code && code <= 12 || 14 <= code && code <= 31 || 127 <= code && code <= 159 || 173 == code || 1564 == code || 6158 == code || 8203 == code || 8206 <= code && code <= 8207 || 8232 == code || 8233 == code || 8234 <= code && code <= 8238 || 8288 <= code && code <= 8292 || 8293 == code || 8294 <= code && code <= 8303 || 55296 <= code && code <= 57343 || 65279 == code || 65520 <= code && code <= 65528 || 65529 <= code && code <= 65531 || 113824 <= code && code <= 113827 || 119155 <= code && code <= 119162 || 917504 == code || 917505 == code || 917506 <= code && code <= 917535 || 917632 <= code && code <= 917759 || 918e3 <= code && code <= 921599) {
return Control;
}
if (768 <= code && code <= 879 || 1155 <= code && code <= 1159 || 1160 <= code && code <= 1161 || 1425 <= code && code <= 1469 || 1471 == code || 1473 <= code && code <= 1474 || 1476 <= code && code <= 1477 || 1479 == code || 1552 <= code && code <= 1562 || 1611 <= code && code <= 1631 || 1648 == code || 1750 <= code && code <= 1756 || 1759 <= code && code <= 1764 || 1767 <= code && code <= 1768 || 1770 <= code && code <= 1773 || 1809 == code || 1840 <= code && code <= 1866 || 1958 <= code && code <= 1968 || 2027 <= code && code <= 2035 || 2070 <= code && code <= 2073 || 2075 <= code && code <= 2083 || 2085 <= code && code <= 2087 || 2089 <= code && code <= 2093 || 2137 <= code && code <= 2139 || 2260 <= code && code <= 2273 || 2275 <= code && code <= 2306 || 2362 == code || 2364 == code || 2369 <= code && code <= 2376 || 2381 == code || 2385 <= code && code <= 2391 || 2402 <= code && code <= 2403 || 2433 == code || 2492 == code || 2494 == code || 2497 <= code && code <= 2500 || 2509 == code || 2519 == code || 2530 <= code && code <= 2531 || 2561 <= code && code <= 2562 || 2620 == code || 2625 <= code && code <= 2626 || 2631 <= code && code <= 2632 || 2635 <= code && code <= 2637 || 2641 == code || 2672 <= code && code <= 2673 || 2677 == code || 2689 <= code && code <= 2690 || 2748 == code || 2753 <= code && code <= 2757 || 2759 <= code && code <= 2760 || 2765 == code || 2786 <= code && code <= 2787 || 2810 <= code && code <= 2815 || 2817 == code || 2876 == code || 2878 == code || 2879 == code || 2881 <= code && code <= 2884 || 2893 == code || 2902 == code || 2903 == code || 2914 <= code && code <= 2915 || 2946 == code || 3006 == code || 3008 == code || 3021 == code || 3031 == code || 3072 == code || 3134 <= code && code <= 3136 || 3142 <= code && code <= 3144 || 3146 <= code && code <= 3149 || 3157 <= code && code <= 3158 || 3170 <= code && code <= 3171 || 3201 == code || 3260 == code || 3263 == code || 3266 == code || 3270 == code || 3276 <= code && code <= 3277 || 3285 <= code && code <= 3286 || 3298 <= code && code <= 3299 || 3328 <= code && code <= 3329 || 3387 <= code && code <= 3388 || 3390 == code || 3393 <= code && code <= 3396 || 3405 == code || 3415 == code || 3426 <= code && code <= 3427 || 3530 == code || 3535 == code || 3538 <= code && code <= 3540 || 3542 == code || 3551 == code || 3633 == code || 3636 <= code && code <= 3642 || 3655 <= code && code <= 3662 || 3761 == code || 3764 <= code && code <= 3769 || 3771 <= code && code <= 3772 || 3784 <= code && code <= 3789 || 3864 <= code && code <= 3865 || 3893 == code || 3895 == code || 3897 == code || 3953 <= code && code <= 3966 || 3968 <= code && code <= 3972 || 3974 <= code && code <= 3975 || 3981 <= code && code <= 3991 || 3993 <= code && code <= 4028 || 4038 == code || 4141 <= code && code <= 4144 || 4146 <= code && code <= 4151 || 4153 <= code && code <= 4154 || 4157 <= code && code <= 4158 || 4184 <= code && code <= 4185 || 4190 <= code && code <= 4192 || 4209 <= code && code <= 4212 || 4226 == code || 4229 <= code && code <= 4230 || 4237 == code || 4253 == code || 4957 <= code && code <= 4959 || 5906 <= code && code <= 5908 || 5938 <= code && code <= 5940 || 5970 <= code && code <= 5971 || 6002 <= code && code <= 6003 || 6068 <= code && code <= 6069 || 6071 <= code && code <= 6077 || 6086 == code || 6089 <= code && code <= 6099 || 6109 == code || 6155 <= code && code <= 6157 || 6277 <= code && code <= 6278 || 6313 == code || 6432 <= code && code <= 6434 || 6439 <= code && code <= 6440 || 6450 == code || 6457 <= code && code <= 6459 || 6679 <= code && code <= 6680 || 6683 == code || 6742 == code || 6744 <= code && code <= 6750 || 6752 == code || 6754 == code || 6757 <= code && code <= 6764 || 6771 <= code && code <= 6780 || 6783 == code || 6832 <= code && code <= 6845 || 6846 == code || 6912 <= code && code <= 6915 || 6964 == code || 6966 <= code && code <= 6970 || 6972 == code || 6978 == code || 7019 <= code && code <= 7027 || 7040 <= code && code <= 7041 || 7074 <= code && code <= 7077 || 7080 <= code && code <= 7081 || 7083 <= code && code <= 7085 || 7142 == code || 7144 <= code && code <= 7145 || 7149 == code || 7151 <= code && code <= 7153 || 7212 <= code && code <= 7219 || 7222 <= code && code <= 7223 || 7376 <= code && code <= 7378 || 7380 <= code && code <= 7392 || 7394 <= code && code <= 7400 || 7405 == code || 7412 == code || 7416 <= code && code <= 7417 || 7616 <= code && code <= 7673 || 7675 <= code && code <= 7679 || 8204 == code || 8400 <= code && code <= 8412 || 8413 <= code && code <= 8416 || 8417 == code || 8418 <= code && code <= 8420 || 8421 <= code && code <= 8432 || 11503 <= code && code <= 11505 || 11647 == code || 11744 <= code && code <= 11775 || 12330 <= code && code <= 12333 || 12334 <= code && code <= 12335 || 12441 <= code && code <= 12442 || 42607 == code || 42608 <= code && code <= 42610 || 42612 <= code && code <= 42621 || 42654 <= code && code <= 42655 || 42736 <= code && code <= 42737 || 43010 == code || 43014 == code || 43019 == code || 43045 <= code && code <= 43046 || 43204 <= code && code <= 43205 || 43232 <= code && code <= 43249 || 43302 <= code && code <= 43309 || 43335 <= code && code <= 43345 || 43392 <= code && code <= 43394 || 43443 == code || 43446 <= code && code <= 43449 || 43452 == code || 43493 == code || 43561 <= code && code <= 43566 || 43569 <= code && code <= 43570 || 43573 <= code && code <= 43574 || 43587 == code || 43596 == code || 43644 == code || 43696 == code || 43698 <= code && code <= 43700 || 43703 <= code && code <= 43704 || 43710 <= code && code <= 43711 || 43713 == code || 43756 <= code && code <= 43757 || 43766 == code || 44005 == code || 44008 == code || 44013 == code || 64286 == code || 65024 <= code && code <= 65039 || 65056 <= code && code <= 65071 || 65438 <= code && code <= 65439 || 66045 == code || 66272 == code || 66422 <= code && code <= 66426 || 68097 <= code && code <= 68099 || 68101 <= code && code <= 68102 || 68108 <= code && code <= 68111 || 68152 <= code && code <= 68154 || 68159 == code || 68325 <= code && code <= 68326 || 69633 == code || 69688 <= code && code <= 69702 || 69759 <= code && code <= 69761 || 69811 <= code && code <= 69814 || 69817 <= code && code <= 69818 || 69888 <= code && code <= 69890 || 69927 <= code && code <= 69931 || 69933 <= code && code <= 69940 || 70003 == code || 70016 <= code && code <= 70017 || 70070 <= code && code <= 70078 || 70090 <= code && code <= 70092 || 70191 <= code && code <= 70193 || 70196 == code || 70198 <= code && code <= 70199 || 70206 == code || 70367 == code || 70371 <= code && code <= 70378 || 70400 <= code && code <= 70401 || 70460 == code || 70462 == code || 70464 == code || 70487 == code || 70502 <= code && code <= 70508 || 70512 <= code && code <= 70516 || 70712 <= code && code <= 70719 || 70722 <= code && code <= 70724 || 70726 == code || 70832 == code || 70835 <= code && code <= 70840 || 70842 == code || 70845 == code || 70847 <= code && code <= 70848 || 70850 <= code && code <= 70851 || 71087 == code || 71090 <= code && code <= 71093 || 71100 <= code && code <= 71101 || 71103 <= code && code <= 71104 || 71132 <= code && code <= 71133 || 71219 <= code && code <= 71226 || 71229 == code || 71231 <= code && code <= 71232 || 71339 == code || 71341 == code || 71344 <= code && code <= 71349 || 71351 == code || 71453 <= code && code <= 71455 || 71458 <= code && code <= 71461 || 71463 <= code && code <= 71467 || 72193 <= code && code <= 72198 || 72201 <= code && code <= 72202 || 72243 <= code && code <= 72248 || 72251 <= code && code <= 72254 || 72263 == code || 72273 <= code && code <= 72278 || 72281 <= code && code <= 72283 || 72330 <= code && code <= 72342 || 72344 <= code && code <= 72345 || 72752 <= code && code <= 72758 || 72760 <= code && code <= 72765 || 72767 == code || 72850 <= code && code <= 72871 || 72874 <= code && code <= 72880 || 72882 <= code && code <= 72883 || 72885 <= code && code <= 72886 || 73009 <= code && code <= 73014 || 73018 == code || 73020 <= code && code <= 73021 || 73023 <= code && code <= 73029 || 73031 == code || 92912 <= code && code <= 92916 || 92976 <= code && code <= 92982 || 94095 <= code && code <= 94098 || 113821 <= code && code <= 113822 || 119141 == code || 119143 <= code && code <= 119145 || 119150 <= code && code <= 119154 || 119163 <= code && code <= 119170 || 119173 <= code && code <= 119179 || 119210 <= code && code <= 119213 || 119362 <= code && code <= 119364 || 121344 <= code && code <= 121398 || 121403 <= code && code <= 121452 || 121461 == code || 121476 == code || 121499 <= code && code <= 121503 || 121505 <= code && code <= 121519 || 122880 <= code && code <= 122886 || 122888 <= code && code <= 122904 || 122907 <= code && code <= 122913 || 122915 <= code && code <= 122916 || 122918 <= code && code <= 122922 || 125136 <= code && code <= 125142 || 125252 <= code && code <= 125258 || 917536 <= code && code <= 917631 || 917760 <= code && code <= 917999) {
return Extend;
}
if (127462 <= code && code <= 127487) {
return Regional_Indicator;
}
if (2307 == code || 2363 == code || 2366 <= code && code <= 2368 || 2377 <= code && code <= 2380 || 2382 <= code && code <= 2383 || 2434 <= code && code <= 2435 || 2495 <= code && code <= 2496 || 2503 <= code && code <= 2504 || 2507 <= code && code <= 2508 || 2563 == code || 2622 <= code && code <= 2624 || 2691 == code || 2750 <= code && code <= 2752 || 2761 == code || 2763 <= code && code <= 2764 || 2818 <= code && code <= 2819 || 2880 == code || 2887 <= code && code <= 2888 || 2891 <= code && code <= 2892 || 3007 == code || 3009 <= code && code <= 3010 || 3014 <= code && code <= 3016 || 3018 <= code && code <= 3020 || 3073 <= code && code <= 3075 || 3137 <= code && code <= 3140 || 3202 <= code && code <= 3203 || 3262 == code || 3264 <= code && code <= 3265 || 3267 <= code && code <= 3268 || 3271 <= code && code <= 3272 || 3274 <= code && code <= 3275 || 3330 <= code && code <= 3331 || 3391 <= code && code <= 3392 || 3398 <= code && code <= 3400 || 3402 <= code && code <= 3404 || 3458 <= code && code <= 3459 || 3536 <= code && code <= 3537 || 3544 <= code && code <= 3550 || 3570 <= code && code <= 3571 || 3635 == code || 3763 == code || 3902 <= code && code <= 3903 || 3967 == code || 4145 == code || 4155 <= code && code <= 4156 || 4182 <= code && code <= 4183 || 4228 == code || 6070 == code || 6078 <= code && code <= 6085 || 6087 <= code && code <= 6088 || 6435 <= code && code <= 6438 || 6441 <= code && code <= 6443 || 6448 <= code && code <= 6449 || 6451 <= code && code <= 6456 || 6681 <= code && code <= 6682 || 6741 == code || 6743 == code || 6765 <= code && code <= 6770 || 6916 == code || 6965 == code || 6971 == code || 6973 <= code && code <= 6977 || 6979 <= code && code <= 6980 || 7042 == code || 7073 == code || 7078 <= code && code <= 7079 || 7082 == code || 7143 == code || 7146 <= code && code <= 7148 || 7150 == code || 7154 <= code && code <= 7155 || 7204 <= code && code <= 7211 || 7220 <= code && code <= 7221 || 7393 == code || 7410 <= code && code <= 7411 || 7415 == code || 43043 <= code && code <= 43044 || 43047 == code || 43136 <= code && code <= 43137 || 43188 <= code && code <= 43203 || 43346 <= code && code <= 43347 || 43395 == code || 43444 <= code && code <= 43445 || 43450 <= code && code <= 43451 || 43453 <= code && code <= 43456 || 43567 <= code && code <= 43568 || 43571 <= code && code <= 43572 || 43597 == code || 43755 == code || 43758 <= code && code <= 43759 || 43765 == code || 44003 <= code && code <= 44004 || 44006 <= code && code <= 44007 || 44009 <= code && code <= 44010 || 44012 == code || 69632 == code || 69634 == code || 69762 == code || 69808 <= code && code <= 69810 || 69815 <= code && code <= 69816 || 69932 == code || 70018 == code || 70067 <= code && code <= 70069 || 70079 <= code && code <= 70080 || 70188 <= code && code <= 70190 || 70194 <= code && code <= 70195 || 70197 == code || 70368 <= code && code <= 70370 || 70402 <= code && code <= 70403 || 70463 == code || 70465 <= code && code <= 70468 || 70471 <= code && code <= 70472 || 70475 <= code && code <= 70477 || 70498 <= code && code <= 70499 || 70709 <= code && code <= 70711 || 70720 <= code && code <= 70721 || 70725 == code || 70833 <= code && code <= 70834 || 70841 == code || 70843 <= code && code <= 70844 || 70846 == code || 70849 == code || 71088 <= code && code <= 71089 || 71096 <= code && code <= 71099 || 71102 == code || 71216 <= code && code <= 71218 || 71227 <= code && code <= 71228 || 71230 == code || 71340 == code || 71342 <= code && code <= 71343 || 71350 == code || 71456 <= code && code <= 71457 || 71462 == code || 72199 <= code && code <= 72200 || 72249 == code || 72279 <= code && code <= 72280 || 72343 == code || 72751 == code || 72766 == code || 72873 == code || 72881 == code || 72884 == code || 94033 <= code && code <= 94078 || 119142 == code || 119149 == code) {
return SpacingMark;
}
if (4352 <= code && code <= 4447 || 43360 <= code && code <= 43388) {
return L;
}
if (4448 <= code && code <= 4519 || 55216 <= code && code <= 55238) {
return V;
}
if (4520 <= code && code <= 4607 || 55243 <= code && code <= 55291) {
return T;
}
if (44032 == code || 44060 == code || 44088 == code || 44116 == code || 44144 == code || 44172 == code || 44200 == code || 44228 == code || 44256 == code || 44284 == code || 44312 == code || 44340 == code || 44368 == code || 44396 == code || 44424 == code || 44452 == code || 44480 == code || 44508 == code || 44536 == code || 44564 == code || 44592 == code || 44620 == code || 44648 == code || 44676 == code || 44704 == code || 44732 == code || 44760 == code || 44788 == code || 44816 == code || 44844 == code || 44872 == code || 44900 == code || 44928 == code || 44956 == code || 44984 == code || 45012 == code || 45040 == code || 45068 == code || 45096 == code || 45124 == code || 45152 == code || 45180 == code || 45208 == code || 45236 == code || 45264 == code || 45292 == code || 45320 == code || 45348 == code || 45376 == code || 45404 == code || 45432 == code || 45460 == code || 45488 == code || 45516 == code || 45544 == code || 45572 == code || 45600 == code || 45628 == code || 45656 == code || 45684 == code || 45712 == code || 45740 == code || 45768 == code || 45796 == code || 45824 == code || 45852 == code || 45880 == code || 45908 == code || 45936 == code || 45964 == code || 45992 == code || 46020 == code || 46048 == code || 46076 == code || 46104 == code || 46132 == code || 46160 == code || 46188 == code || 46216 == code || 46244 == code || 46272 == code || 46300 == code || 46328 == code || 46356 == code || 46384 == code || 46412 == code || 46440 == code || 46468 == code || 46496 == code || 46524 == code || 46552 == code || 46580 == code || 46608 == code || 46636 == code || 46664 == code || 46692 == code || 46720 == code || 46748 == code || 46776 == code || 46804 == code || 46832 == code || 46860 == code || 46888 == code || 46916 == code || 46944 == code || 46972 == code || 47e3 == code || 47028 == code || 47056 == code || 47084 == code || 47112 == code || 47140 == code || 47168 == code || 47196 == code || 47224 == code || 47252 == code || 47280 == code || 47308 == code || 47336 == code || 47364 == code || 47392 == code || 47420 == code || 47448 == code || 47476 == code || 47504 == code || 47532 == code || 47560 == code || 47588 == code || 47616 == code || 47644 == code || 47672 == code || 47700 == code || 47728 == code || 47756 == code || 47784 == code || 47812 == code || 47840 == code || 47868 == code || 47896 == code || 47924 == code || 47952 == code || 47980 == code || 48008 == code || 48036 == code || 48064 == code || 48092 == code || 48120 == code || 48148 == code || 48176 == code || 48204 == code || 48232 == code || 48260 == code || 48288 == code || 48316 == code || 48344 == code || 48372 == code || 48400 == code || 48428 == code || 48456 == code || 48484 == code || 48512 == code || 48540 == code || 48568 == code || 48596 == code || 48624 == code || 48652 == code || 48680 == code || 48708 == code || 48736 == code || 48764 == code || 48792 == code || 48820 == code || 48848 == code || 48876 == code || 48904 == code || 48932 == code || 48960 == code || 48988 == code || 49016 == code || 49044 == code || 49072 == code || 49100 == code || 49128 == code || 49156 == code || 49184 == code || 49212 == code || 49240 == code || 49268 == code || 49296 == code || 49324 == code || 49352 == code || 49380 == code || 49408 == code || 49436 == code || 49464 == code || 49492 == code || 49520 == code || 49548 == code || 49576 == code || 49604 == code || 49632 == code || 49660 == code || 49688 == code || 49716 == code || 49744 == code || 49772 == code || 49800 == code || 49828 == code || 49856 == code || 49884 == code || 49912 == code || 49940 == code || 49968 == code || 49996 == code || 50024 == code || 50052 == code || 50080 == code || 50108 == code || 50136 == code || 50164 == code || 50192 == code || 50220 == code || 50248 == code || 50276 == code || 50304 == code || 50332 == code || 50360 == code || 50388 == code || 50416 == code || 50444 == code || 50472 == code || 50500 == code || 50528 == code || 50556 == code || 50584 == code || 50612 == code || 50640 == code || 50668 == code || 50696 == code || 50724 == code || 50752 == code || 50780 == code || 50808 == code || 50836 == code || 50864 == code || 50892 == code || 50920 == code || 50948 == code || 50976 == code || 51004 == code || 51032 == code || 51060 == code || 51088 == code || 51116 == code || 51144 == code || 51172 == code || 51200 == code || 51228 == code || 51256 == code || 51284 == code || 51312 == code || 51340 == code || 51368 == code || 51396 == code || 51424 == code || 51452 == code || 51480 == code || 51508 == code || 51536 == code || 51564 == code || 51592 == code || 51620 == code || 51648 == code || 51676 == code || 51704 == code || 51732 == code || 51760 == code || 51788 == code || 51816 == code || 51844 == code || 51872 == code || 51900 == code || 51928 == code || 51956 == code || 51984 == code || 52012 == code || 52040 == code || 52068 == code || 52096 == code || 52124 == code || 52152 == code || 52180 == code || 52208 == code || 52236 == code || 52264 == code || 52292 == code || 52320 == code || 52348 == code || 52376 == code || 52404 == code || 52432 == code || 52460 == code || 52488 == code || 52516 == code || 52544 == code || 52572 == code || 52600 == code || 52628 == code || 52656 == code || 52684 == code || 52712 == code || 52740 == code || 52768 == code || 52796 == code || 52824 == code || 52852 == code || 52880 == code || 52908 == code || 52936 == code || 52964 == code || 52992 == code || 53020 == code || 53048 == code || 53076 == code || 53104 == code || 53132 == code || 53160 == code || 53188 == code || 53216 == code || 53244 == code || 53272 == code || 53300 == code || 53328 == code || 53356 == code || 53384 == code || 53412 == code || 53440 == code || 53468 == code || 53496 == code || 53524 == code || 53552 == code || 53580 == code || 53608 == code || 53636 == code || 53664 == code || 53692 == code || 53720 == code || 53748 == code || 53776 == code || 53804 == code || 53832 == code || 53860 == code || 53888 == code || 53916 == code || 53944 == code || 53972 == code || 54e3 == code || 54028 == code || 54056 == code || 54084 == code || 54112 == code || 54140 == code || 54168 == code || 54196 == code || 54224 == code || 54252 == code || 54280 == code || 54308 == code || 54336 == code || 54364 == code || 54392 == code || 54420 == code || 54448 == code || 54476 == code || 54504 == code || 54532 == code || 54560 == code || 54588 == code || 54616 == code || 54644 == code || 54672 == code || 54700 == code || 54728 == code || 54756 == code || 54784 == code || 54812 == code || 54840 == code || 54868 == code || 54896 == code || 54924 == code || 54952 == code || 54980 == code || 55008 == code || 55036 == code || 55064 == code || 55092 == code || 55120 == code || 55148 == code || 55176 == code) {
return LV;
}
if (44033 <= code && code <= 44059 || 44061 <= code && code <= 44087 || 44089 <= code && code <= 44115 || 44117 <= code && code <= 44143 || 44145 <= code && code <= 44171 || 44173 <= code && code <= 44199 || 44201 <= code && code <= 44227 || 44229 <= code && code <= 44255 || 44257 <= code && code <= 44283 || 44285 <= code && code <= 44311 || 44313 <= code && code <= 44339 || 44341 <= code && code <= 44367 || 44369 <= code && code <= 44395 || 44397 <= code && code <= 44423 || 44425 <= code && code <= 44451 || 44453 <= code && code <= 44479 || 44481 <= code && code <= 44507 || 44509 <= code && code <= 44535 || 44537 <= code && code <= 44563 || 44565 <= code && code <= 44591 || 44593 <= code && code <= 44619 || 44621 <= code && code <= 44647 || 44649 <= code && code <= 44675 || 44677 <= code && code <= 44703 || 44705 <= code && code <= 44731 || 44733 <= code && code <= 44759 || 44761 <= code && code <= 44787 || 44789 <= code && code <= 44815 || 44817 <= code && code <= 44843 || 44845 <= code && code <= 44871 || 44873 <= code && code <= 44899 || 44901 <= code && code <= 44927 || 44929 <= code && code <= 44955 || 44957 <= code && code <= 44983 || 44985 <= code && code <= 45011 || 45013 <= code && code <= 45039 || 45041 <= code && code <= 45067 || 45069 <= code && code <= 45095 || 45097 <= code && code <= 45123 || 45125 <= code && code <= 45151 || 45153 <= code && code <= 45179 || 45181 <= code && code <= 45207 || 45209 <= code && code <= 45235 || 45237 <= code && code <= 45263 || 45265 <= code && code <= 45291 || 45293 <= code && code <= 45319 || 45321 <= code && code <= 45347 || 45349 <= code && code <= 45375 || 45377 <= code && code <= 45403 || 45405 <= code && code <= 45431 || 45433 <= code && code <= 45459 || 45461 <= code && code <= 45487 || 45489 <= code && code <= 45515 || 45517 <= code && code <= 45543 || 45545 <= code && code <= 45571 || 45573 <= code && code <= 45599 || 45601 <= code && code <= 45627 || 45629 <= code && code <= 45655 || 45657 <= code && code <= 45683 || 45685 <= code && code <= 45711 || 45713 <= code && code <= 45739 || 45741 <= code && code <= 45767 || 45769 <= code && code <= 45795 || 45797 <= code && code <= 45823 || 45825 <= code && code <= 45851 || 45853 <= code && code <= 45879 || 45881 <= code && code <= 45907 || 45909 <= code && code <= 45935 || 45937 <= code && code <= 45963 || 45965 <= code && code <= 45991 || 45993 <= code && code <= 46019 || 46021 <= code && code <= 46047 || 46049 <= code && code <= 46075 || 46077 <= code && code <= 46103 || 46105 <= code && code <= 46131 || 46133 <= code && code <= 46159 || 46161 <= code && code <= 46187 || 46189 <= code && code <= 46215 || 46217 <= code && code <= 46243 || 46245 <= code && code <= 46271 || 46273 <= code && code <= 46299 || 46301 <= code && code <= 46327 || 46329 <= code && code <= 46355 || 46357 <= code && code <= 46383 || 46385 <= code && code <= 46411 || 46413 <= code && code <= 46439 || 46441 <= code && code <= 46467 || 46469 <= code && code <= 46495 || 46497 <= code && code <= 46523 || 46525 <= code && code <= 46551 || 46553 <= code && code <= 46579 || 46581 <= code && code <= 46607 || 46609 <= code && code <= 46635 || 46637 <= code && code <= 46663 || 46665 <= code && code <= 46691 || 46693 <= code && code <= 46719 || 46721 <= code && code <= 46747 || 46749 <= code && code <= 46775 || 46777 <= code && code <= 46803 || 46805 <= code && code <= 46831 || 46833 <= code && code <= 46859 || 46861 <= code && code <= 46887 || 46889 <= code && code <= 46915 || 46917 <= code && code <= 46943 || 46945 <= code && code <= 46971 || 46973 <= code && code <= 46999 || 47001 <= code && code <= 47027 || 47029 <= code && code <= 47055 || 47057 <= code && code <= 47083 || 47085 <= code && code <= 47111 || 47113 <= code && code <= 47139 || 47141 <= code && code <= 47167 || 47169 <= code && code <= 47195 || 47197 <= code && code <= 47223 || 47225 <= code && code <= 47251 || 47253 <= code && code <= 47279 || 47281 <= code && code <= 47307 || 47309 <= code && code <= 47335 || 47337 <= code && code <= 47363 || 47365 <= code && code <= 47391 || 47393 <= code && code <= 47419 || 47421 <= code && code <= 47447 || 47449 <= code && code <= 47475 || 47477 <= code && code <= 47503 || 47505 <= code && code <= 47531 || 47533 <= code && code <= 47559 || 47561 <= code && code <= 47587 || 47589 <= code && code <= 47615 || 47617 <= code && code <= 47643 || 47645 <= code && code <= 47671 || 47673 <= code && code <= 47699 || 47701 <= code && code <= 47727 || 47729 <= code && code <= 47755 || 47757 <= code && code <= 47783 || 47785 <= code && code <= 47811 || 47813 <= code && code <= 47839 || 47841 <= code && code <= 47867 || 47869 <= code && code <= 47895 || 47897 <= code && code <= 47923 || 47925 <= code && code <= 47951 || 47953 <= code && code <= 47979 || 47981 <= code && code <= 48007 || 48009 <= code && code <= 48035 || 48037 <= code && code <= 48063 || 48065 <= code && code <= 48091 || 48093 <= code && code <= 48119 || 48121 <= code && code <= 48147 || 48149 <= code && code <= 48175 || 48177 <= code && code <= 48203 || 48205 <= code && code <= 48231 || 48233 <= code && code <= 48259 || 48261 <= code && code <= 48287 || 48289 <= code && code <= 48315 || 48317 <= code && code <= 48343 || 48345 <= code && code <= 48371 || 48373 <= code && code <= 48399 || 48401 <= code && code <= 48427 || 48429 <= code && code <= 48455 || 48457 <= code && code <= 48483 || 48485 <= code && code <= 48511 || 48513 <= code && code <= 48539 || 48541 <= code && code <= 48567 || 48569 <= code && code <= 48595 || 48597 <= code && code <= 48623 || 48625 <= code && code <= 48651 || 48653 <= code && code <= 48679 || 48681 <= code && code <= 48707 || 48709 <= code && code <= 48735 || 48737 <= code && code <= 48763 || 48765 <= code && code <= 48791 || 48793 <= code && code <= 48819 || 48821 <= code && code <= 48847 || 48849 <= code && code <= 48875 || 48877 <= code && code <= 48903 || 48905 <= code && code <= 48931 || 48933 <= code && code <= 48959 || 48961 <= code && code <= 48987 || 48989 <= code && code <= 49015 || 49017 <= code && code <= 49043 || 49045 <= code && code <= 49071 || 49073 <= code && code <= 49099 || 49101 <= code && code <= 49127 || 49129 <= code && code <= 49155 || 49157 <= code && code <= 49183 || 49185 <= code && code <= 49211 || 49213 <= code && code <= 49239 || 49241 <= code && code <= 49267 || 49269 <= code && code <= 49295 || 49297 <= code && code <= 49323 || 49325 <= code && code <= 49351 || 49353 <= code && code <= 49379 || 49381 <= code && code <= 49407 || 49409 <= code && code <= 49435 || 49437 <= code && code <= 49463 || 49465 <= code && code <= 49491 || 49493 <= code && code <= 49519 || 49521 <= code && code <= 49547 || 49549 <= code && code <= 49575 || 49577 <= code && code <= 49603 || 49605 <= code && code <= 49631 || 49633 <= code && code <= 49659 || 49661 <= code && code <= 49687 || 49689 <= code && code <= 49715 || 49717 <= code && code <= 49743 || 49745 <= code && code <= 49771 || 49773 <= code && code <= 49799 || 49801 <= code && code <= 49827 || 49829 <= code && code <= 49855 || 49857 <= code && code <= 49883 || 49885 <= code && code <= 49911 || 49913 <= code && code <= 49939 || 49941 <= code && code <= 49967 || 49969 <= code && code <= 49995 || 49997 <= code && code <= 50023 || 50025 <= code && code <= 50051 || 50053 <= code && code <= 50079 || 50081 <= code && code <= 50107 || 50109 <= code && code <= 50135 || 50137 <= code && code <= 50163 || 50165 <= code && code <= 50191 || 50193 <= code && code <= 50219 || 50221 <= code && code <= 50247 || 50249 <= code && code <= 50275 || 50277 <= code && code <= 50303 || 50305 <= code && code <= 50331 || 50333 <= code && code <= 50359 || 50361 <= code && code <= 50387 || 50389 <= code && code <= 50415 || 50417 <= code && code <= 50443 || 50445 <= code && code <= 50471 || 50473 <= code && code <= 50499 || 50501 <= code && code <= 50527 || 50529 <= code && code <= 50555 || 50557 <= code && code <= 50583 || 50585 <= code && code <= 50611 || 50613 <= code && code <= 50639 || 50641 <= code && code <= 50667 || 50669 <= code && code <= 50695 || 50697 <= code && code <= 50723 || 50725 <= code && code <= 50751 || 50753 <= code && code <= 50779 || 50781 <= code && code <= 50807 || 50809 <= code && code <= 50835 || 50837 <= code && code <= 50863 || 50865 <= code && code <= 50891 || 50893 <= code && code <= 50919 || 50921 <= code && code <= 50947 || 50949 <= code && code <= 50975 || 50977 <= code && code <= 51003 || 51005 <= code && code <= 51031 || 51033 <= code && code <= 51059 || 51061 <= code && code <= 51087 || 51089 <= code && code <= 51115 || 51117 <= code && code <= 51143 || 51145 <= code && code <= 51171 || 51173 <= code && code <= 51199 || 51201 <= code && code <= 51227 || 51229 <= code && code <= 51255 || 51257 <= code && code <= 51283 || 51285 <= code && code <= 51311 || 51313 <= code && code <= 51339 || 51341 <= code && code <= 51367 || 51369 <= code && code <= 51395 || 51397 <= code && code <= 51423 || 51425 <= code && code <= 51451 || 51453 <= code && code <= 51479 || 51481 <= code && code <= 51507 || 51509 <= code && code <= 51535 || 51537 <= code && code <= 51563 || 51565 <= code && code <= 51591 || 51593 <= code && code <= 51619 || 51621 <= code && code <= 51647 || 51649 <= code && code <= 51675 || 51677 <= code && code <= 51703 || 51705 <= code && code <= 51731 || 51733 <= code && code <= 51759 || 51761 <= code && code <= 51787 || 51789 <= code && code <= 51815 || 51817 <= code && code <= 51843 || 51845 <= code && code <= 51871 || 51873 <= code && code <= 51899 || 51901 <= code && code <= 51927 || 51929 <= code && code <= 51955 || 51957 <= code && code <= 51983 || 51985 <= code && code <= 52011 || 52013 <= code && code <= 52039 || 52041 <= code && code <= 52067 || 52069 <= code && code <= 52095 || 52097 <= code && code <= 52123 || 52125 <= code && code <= 52151 || 52153 <= code && code <= 52179 || 52181 <= code && code <= 52207 || 52209 <= code && code <= 52235 || 52237 <= code && code <= 52263 || 52265 <= code && code <= 52291 || 52293 <= code && code <= 52319 || 52321 <= code && code <= 52347 || 52349 <= code && code <= 52375 || 52377 <= code && code <= 52403 || 52405 <= code && code <= 52431 || 52433 <= code && code <= 52459 || 52461 <= code && code <= 52487 || 52489 <= code && code <= 52515 || 52517 <= code && code <= 52543 || 52545 <= code && code <= 52571 || 52573 <= code && code <= 52599 || 52601 <= code && code <= 52627 || 52629 <= code && code <= 52655 || 52657 <= code && code <= 52683 || 52685 <= code && code <= 52711 || 52713 <= code && code <= 52739 || 52741 <= code && code <= 52767 || 52769 <= code && code <= 52795 || 52797 <= code && code <= 52823 || 52825 <= code && code <= 52851 || 52853 <= code && code <= 52879 || 52881 <= code && code <= 52907 || 52909 <= code && code <= 52935 || 52937 <= code && code <= 52963 || 52965 <= code && code <= 52991 || 52993 <= code && code <= 53019 || 53021 <= code && code <= 53047 || 53049 <= code && code <= 53075 || 53077 <= code && code <= 53103 || 53105 <= code && code <= 53131 || 53133 <= code && code <= 53159 || 53161 <= code && code <= 53187 || 53189 <= code && code <= 53215 || 53217 <= code && code <= 53243 || 53245 <= code && code <= 53271 || 53273 <= code && code <= 53299 || 53301 <= code && code <= 53327 || 53329 <= code && code <= 53355 || 53357 <= code && code <= 53383 || 53385 <= code && code <= 53411 || 53413 <= code && code <= 53439 || 53441 <= code && code <= 53467 || 53469 <= code && code <= 53495 || 53497 <= code && code <= 53523 || 53525 <= code && code <= 53551 || 53553 <= code && code <= 53579 || 53581 <= code && code <= 53607 || 53609 <= code && code <= 53635 || 53637 <= code && code <= 53663 || 53665 <= code && code <= 53691 || 53693 <= code && code <= 53719 || 53721 <= code && code <= 53747 || 53749 <= code && code <= 53775 || 53777 <= code && code <= 53803 || 53805 <= code && code <= 53831 || 53833 <= code && code <= 53859 || 53861 <= code && code <= 53887 || 53889 <= code && code <= 53915 || 53917 <= code && code <= 53943 || 53945 <= code && code <= 53971 || 53973 <= code && code <= 53999 || 54001 <= code && code <= 54027 || 54029 <= code && code <= 54055 || 54057 <= code && code <= 54083 || 54085 <= code && code <= 54111 || 54113 <= code && code <= 54139 || 54141 <= code && code <= 54167 || 54169 <= code && code <= 54195 || 54197 <= code && code <= 54223 || 54225 <= code && code <= 54251 || 54253 <= code && code <= 54279 || 54281 <= code && code <= 54307 || 54309 <= code && code <= 54335 || 54337 <= code && code <= 54363 || 54365 <= code && code <= 54391 || 54393 <= code && code <= 54419 || 54421 <= code && code <= 54447 || 54449 <= code && code <= 54475 || 54477 <= code && code <= 54503 || 54505 <= code && code <= 54531 || 54533 <= code && code <= 54559 || 54561 <= code && code <= 54587 || 54589 <= code && code <= 54615 || 54617 <= code && code <= 54643 || 54645 <= code && code <= 54671 || 54673 <= code && code <= 54699 || 54701 <= code && code <= 54727 || 54729 <= code && code <= 54755 || 54757 <= code && code <= 54783 || 54785 <= code && code <= 54811 || 54813 <= code && code <= 54839 || 54841 <= code && code <= 54867 || 54869 <= code && code <= 54895 || 54897 <= code && code <= 54923 || 54925 <= code && code <= 54951 || 54953 <= code && code <= 54979 || 54981 <= code && code <= 55007 || 55009 <= code && code <= 55035 || 55037 <= code && code <= 55063 || 55065 <= code && code <= 55091 || 55093 <= code && code <= 55119 || 55121 <= code && code <= 55147 || 55149 <= code && code <= 55175 || 55177 <= code && code <= 55203) {
return LVT;
}
if (9757 == code || 9977 == code || 9994 <= code && code <= 9997 || 127877 == code || 127938 <= code && code <= 127940 || 127943 == code || 127946 <= code && code <= 127948 || 128066 <= code && code <= 128067 || 128070 <= code && code <= 128080 || 128110 == code || 128112 <= code && code <= 128120 || 128124 == code || 128129 <= code && code <= 128131 || 128133 <= code && code <= 128135 || 128170 == code || 128372 <= code && code <= 128373 || 128378 == code || 128400 == code || 128405 <= code && code <= 128406 || 128581 <= code && code <= 128583 || 128587 <= code && code <= 128591 || 128675 == code || 128692 <= code && code <= 128694 || 128704 == code || 128716 == code || 129304 <= code && code <= 129308 || 129310 <= code && code <= 129311 || 129318 == code || 129328 <= code && code <= 129337 || 129341 <= code && code <= 129342 || 129489 <= code && code <= 129501) {
return E_Base;
}
if (127995 <= code && code <= 127999) {
return E_Modifier;
}
if (8205 == code) {
return ZWJ;
}
if (9792 == code || 9794 == code || 9877 <= code && code <= 9878 || 9992 == code || 10084 == code || 127752 == code || 127806 == code || 127859 == code || 127891 == code || 127908 == code || 127912 == code || 127979 == code || 127981 == code || 128139 == code || 128187 <= code && code <= 128188 || 128295 == code || 128300 == code || 128488 == code || 128640 == code || 128658 == code) {
return Glue_After_Zwj;
}
if (128102 <= code && code <= 128105) {
return E_Base_GAZ;
}
return Other;
}
return this;
}
if (typeof module2 != "undefined" && module2.exports) {
module2.exports = GraphemeSplitter;
}
}
});
// node_modules/kdbush/kdbush.js
var require_kdbush = __commonJS({
"node_modules/kdbush/kdbush.js"(exports2, module2) {
(function(global2, factory) {
typeof exports2 === "object" && typeof module2 !== "undefined" ? module2.exports = factory() : typeof define === "function" && define.amd ? define(factory) : global2.KDBush = factory();
})(exports2, function() {
"use strict";
function sortKD(ids, coords, nodeSize, left, right, depth) {
if (right - left <= nodeSize) {
return;
}
var m = left + right >> 1;
select(ids, coords, m, left, right, depth % 2);
sortKD(ids, coords, nodeSize, left, m - 1, depth + 1);
sortKD(ids, coords, nodeSize, m + 1, right, depth + 1);
}
function select(ids, coords, k, left, right, inc) {
while (right > left) {
if (right - left > 600) {
var n = right - left + 1;
var m = k - left + 1;
var z = Math.log(n);
var s = 0.5 * Math.exp(2 * z / 3);
var sd = 0.5 * Math.sqrt(z * s * (n - s) / n) * (m - n / 2 < 0 ? -1 : 1);
var newLeft = Math.max(left, Math.floor(k - m * s / n + sd));
var newRight = Math.min(right, Math.floor(k + (n - m) * s / n + sd));
select(ids, coords, k, newLeft, newRight, inc);
}
var t = coords[2 * k + inc];
var i = left;
var j = right;
swapItem(ids, coords, left, k);
if (coords[2 * right + inc] > t) {
swapItem(ids, coords, left, right);
}
while (i < j) {
swapItem(ids, coords, i, j);
i++;
j--;
while (coords[2 * i + inc] < t) {
i++;
}
while (coords[2 * j + inc] > t) {
j--;
}
}
if (coords[2 * left + inc] === t) {
swapItem(ids, coords, left, j);
} else {
j++;
swapItem(ids, coords, j, right);
}
if (j <= k) {
left = j + 1;
}
if (k <= j) {
right = j - 1;
}
}
}
function swapItem(ids, coords, i, j) {
swap3(ids, i, j);
swap3(coords, 2 * i, 2 * j);
swap3(coords, 2 * i + 1, 2 * j + 1);
}
function swap3(arr, i, j) {
var tmp2 = arr[i];
arr[i] = arr[j];
arr[j] = tmp2;
}
function range(ids, coords, minX, minY, maxX, maxY, nodeSize) {
var stack = [0, ids.length - 1, 0];
var result = [];
var x, y;
while (stack.length) {
var axis = stack.pop();
var right = stack.pop();
var left = stack.pop();
if (right - left <= nodeSize) {
for (var i = left; i <= right; i++) {
x = coords[2 * i];
y = coords[2 * i + 1];
if (x >= minX && x <= maxX && y >= minY && y <= maxY) {
result.push(ids[i]);
}
}
continue;
}
var m = Math.floor((left + right) / 2);
x = coords[2 * m];
y = coords[2 * m + 1];
if (x >= minX && x <= maxX && y >= minY && y <= maxY) {
result.push(ids[m]);
}
var nextAxis = (axis + 1) % 2;
if (axis === 0 ? minX <= x : minY <= y) {
stack.push(left);
stack.push(m - 1);
stack.push(nextAxis);
}
if (axis === 0 ? maxX >= x : maxY >= y) {
stack.push(m + 1);
stack.push(right);
stack.push(nextAxis);
}
}
return result;
}
function within(ids, coords, qx, qy, r, nodeSize) {
var stack = [0, ids.length - 1, 0];
var result = [];
var r2 = r * r;
while (stack.length) {
var axis = stack.pop();
var right = stack.pop();
var left = stack.pop();
if (right - left <= nodeSize) {
for (var i = left; i <= right; i++) {
if (sqDist(coords[2 * i], coords[2 * i + 1], qx, qy) <= r2) {
result.push(ids[i]);
}
}
continue;
}
var m = Math.floor((left + right) / 2);
var x = coords[2 * m];
var y = coords[2 * m + 1];
if (sqDist(x, y, qx, qy) <= r2) {
result.push(ids[m]);
}
var nextAxis = (axis + 1) % 2;
if (axis === 0 ? qx - r <= x : qy - r <= y) {
stack.push(left);
stack.push(m - 1);
stack.push(nextAxis);
}
if (axis === 0 ? qx + r >= x : qy + r >= y) {
stack.push(m + 1);
stack.push(right);
stack.push(nextAxis);
}
}
return result;
}
function sqDist(ax, ay, bx, by) {
var dx = ax - bx;
var dy = ay - by;
return dx * dx + dy * dy;
}
var defaultGetX = function(p) {
return p[0];
};
var defaultGetY = function(p) {
return p[1];
};
var KDBush = function KDBush2(points, getX2, getY2, nodeSize, ArrayType) {
if (getX2 === void 0)
getX2 = defaultGetX;
if (getY2 === void 0)
getY2 = defaultGetY;
if (nodeSize === void 0)
nodeSize = 64;
if (ArrayType === void 0)
ArrayType = Float64Array;
this.nodeSize = nodeSize;
this.points = points;
var IndexArrayType = points.length < 65536 ? Uint16Array : Uint32Array;
var ids = this.ids = new IndexArrayType(points.length);
var coords = this.coords = new ArrayType(points.length * 2);
for (var i = 0; i < points.length; i++) {
ids[i] = i;
coords[2 * i] = getX2(points[i]);
coords[2 * i + 1] = getY2(points[i]);
}
sortKD(ids, coords, nodeSize, 0, ids.length - 1, 0);
};
KDBush.prototype.range = function range$1(minX, minY, maxX, maxY) {
return range(this.ids, this.coords, minX, minY, maxX, maxY, this.nodeSize);
};
KDBush.prototype.within = function within$1(x, y, r) {
return within(this.ids, this.coords, x, y, r, this.nodeSize);
};
return KDBush;
});
}
});
// node_modules/topojson-client/dist/topojson-client.js
var require_topojson_client = __commonJS({
"node_modules/topojson-client/dist/topojson-client.js"(exports2, module2) {
(function(global2, factory) {
typeof exports2 === "object" && typeof module2 !== "undefined" ? factory(exports2) : typeof define === "function" && define.amd ? define(["exports"], factory) : (global2 = global2 || self, factory(global2.topojson = global2.topojson || {}));
})(exports2, function(exports3) {
"use strict";
function identity(x) {
return x;
}
function transform3(transform4) {
if (transform4 == null)
return identity;
var x0, y0, kx = transform4.scale[0], ky = transform4.scale[1], dx = transform4.translate[0], dy = transform4.translate[1];
return function(input, i) {
if (!i)
x0 = y0 = 0;
var j = 2, n = input.length, output = new Array(n);
output[0] = (x0 += input[0]) * kx + dx;
output[1] = (y0 += input[1]) * ky + dy;
while (j < n)
output[j] = input[j], ++j;
return output;
};
}
function bbox(topology) {
var t = transform3(topology.transform), key, x0 = Infinity, y0 = x0, x1 = -x0, y1 = -x0;
function bboxPoint(p) {
p = t(p);
if (p[0] < x0)
x0 = p[0];
if (p[0] > x1)
x1 = p[0];
if (p[1] < y0)
y0 = p[1];
if (p[1] > y1)
y1 = p[1];
}
function bboxGeometry(o) {
switch (o.type) {
case "GeometryCollection":
o.geometries.forEach(bboxGeometry);
break;
case "Point":
bboxPoint(o.coordinates);
break;
case "MultiPoint":
o.coordinates.forEach(bboxPoint);
break;
}
}
topology.arcs.forEach(function(arc) {
var i = -1, n = arc.length, p;
while (++i < n) {
p = t(arc[i], i);
if (p[0] < x0)
x0 = p[0];
if (p[0] > x1)
x1 = p[0];
if (p[1] < y0)
y0 = p[1];
if (p[1] > y1)
y1 = p[1];
}
});
for (key in topology.objects) {
bboxGeometry(topology.objects[key]);
}
return [x0, y0, x1, y1];
}
function reverse(array, n) {
var t, j = array.length, i = j - n;
while (i < --j)
t = array[i], array[i++] = array[j], array[j] = t;
}
function feature(topology, o) {
if (typeof o === "string")
o = topology.objects[o];
return o.type === "GeometryCollection" ? { type: "FeatureCollection", features: o.geometries.map(function(o2) {
return feature$1(topology, o2);
}) } : feature$1(topology, o);
}
function feature$1(topology, o) {
var id = o.id, bbox2 = o.bbox, properties = o.properties == null ? {} : o.properties, geometry = object(topology, o);
return id == null && bbox2 == null ? { type: "Feature", properties, geometry } : bbox2 == null ? { type: "Feature", id, properties, geometry } : { type: "Feature", id, bbox: bbox2, properties, geometry };
}
function object(topology, o) {
var transformPoint2 = transform3(topology.transform), arcs = topology.arcs;
function arc(i, points) {
if (points.length)
points.pop();
for (var a3 = arcs[i < 0 ? ~i : i], k = 0, n = a3.length; k < n; ++k) {
points.push(transformPoint2(a3[k], k));
}
if (i < 0)
reverse(points, n);
}
function point(p) {
return transformPoint2(p);
}
function line(arcs2) {
var points = [];
for (var i = 0, n = arcs2.length; i < n; ++i)
arc(arcs2[i], points);
if (points.length < 2)
points.push(points[0]);
return points;
}
function ring(arcs2) {
var points = line(arcs2);
while (points.length < 4)
points.push(points[0]);
return points;
}
function polygon(arcs2) {
return arcs2.map(ring);
}
function geometry(o2) {
var type = o2.type, coordinates;
switch (type) {
case "GeometryCollection":
return { type, geometries: o2.geometries.map(geometry) };
case "Point":
coordinates = point(o2.coordinates);
break;
case "MultiPoint":
coordinates = o2.coordinates.map(point);
break;
case "LineString":
coordinates = line(o2.arcs);
break;
case "MultiLineString":
coordinates = o2.arcs.map(line);
break;
case "Polygon":
coordinates = polygon(o2.arcs);
break;
case "MultiPolygon":
coordinates = o2.arcs.map(polygon);
break;
default:
return null;
}
return { type, coordinates };
}
return geometry(o);
}
function stitch(topology, arcs) {
var stitchedArcs = {}, fragmentByStart = {}, fragmentByEnd = {}, fragments = [], emptyIndex = -1;
arcs.forEach(function(i, j) {
var arc = topology.arcs[i < 0 ? ~i : i], t;
if (arc.length < 3 && !arc[1][0] && !arc[1][1]) {
t = arcs[++emptyIndex], arcs[emptyIndex] = i, arcs[j] = t;
}
});
arcs.forEach(function(i) {
var e = ends(i), start = e[0], end = e[1], f, g;
if (f = fragmentByEnd[start]) {
delete fragmentByEnd[f.end];
f.push(i);
f.end = end;
if (g = fragmentByStart[end]) {
delete fragmentByStart[g.start];
var fg = g === f ? f : f.concat(g);
fragmentByStart[fg.start = f.start] = fragmentByEnd[fg.end = g.end] = fg;
} else {
fragmentByStart[f.start] = fragmentByEnd[f.end] = f;
}
} else if (f = fragmentByStart[end]) {
delete fragmentByStart[f.start];
f.unshift(i);
f.start = start;
if (g = fragmentByEnd[start]) {
delete fragmentByEnd[g.end];
var gf = g === f ? f : g.concat(f);
fragmentByStart[gf.start = g.start] = fragmentByEnd[gf.end = f.end] = gf;
} else {
fragmentByStart[f.start] = fragmentByEnd[f.end] = f;
}
} else {
f = [i];
fragmentByStart[f.start = start] = fragmentByEnd[f.end = end] = f;
}
});
function ends(i) {
var arc = topology.arcs[i < 0 ? ~i : i], p0 = arc[0], p1;
if (topology.transform)
p1 = [0, 0], arc.forEach(function(dp) {
p1[0] += dp[0], p1[1] += dp[1];
});
else
p1 = arc[arc.length - 1];
return i < 0 ? [p1, p0] : [p0, p1];
}
function flush(fragmentByEnd2, fragmentByStart2) {
for (var k in fragmentByEnd2) {
var f = fragmentByEnd2[k];
delete fragmentByStart2[f.start];
delete f.start;
delete f.end;
f.forEach(function(i) {
stitchedArcs[i < 0 ? ~i : i] = 1;
});
fragments.push(f);
}
}
flush(fragmentByEnd, fragmentByStart);
flush(fragmentByStart, fragmentByEnd);
arcs.forEach(function(i) {
if (!stitchedArcs[i < 0 ? ~i : i])
fragments.push([i]);
});
return fragments;
}
function mesh(topology) {
return object(topology, meshArcs.apply(this, arguments));
}
function meshArcs(topology, object2, filter) {
var arcs, i, n;
if (arguments.length > 1)
arcs = extractArcs(topology, object2, filter);
else
for (i = 0, arcs = new Array(n = topology.arcs.length); i < n; ++i)
arcs[i] = i;
return { type: "MultiLineString", arcs: stitch(topology, arcs) };
}
function extractArcs(topology, object2, filter) {
var arcs = [], geomsByArc = [], geom;
function extract0(i) {
var j = i < 0 ? ~i : i;
(geomsByArc[j] || (geomsByArc[j] = [])).push({ i, g: geom });
}
function extract1(arcs2) {
arcs2.forEach(extract0);
}
function extract2(arcs2) {
arcs2.forEach(extract1);
}
function extract3(arcs2) {
arcs2.forEach(extract2);
}
function geometry(o) {
switch (geom = o, o.type) {
case "GeometryCollection":
o.geometries.forEach(geometry);
break;
case "LineString":
extract1(o.arcs);
break;
case "MultiLineString":
case "Polygon":
extract2(o.arcs);
break;
case "MultiPolygon":
extract3(o.arcs);
break;
}
}
geometry(object2);
geomsByArc.forEach(filter == null ? function(geoms) {
arcs.push(geoms[0].i);
} : function(geoms) {
if (filter(geoms[0].g, geoms[geoms.length - 1].g))
arcs.push(geoms[0].i);
});
return arcs;
}
function planarRingArea(ring) {
var i = -1, n = ring.length, a3, b = ring[n - 1], area = 0;
while (++i < n)
a3 = b, b = ring[i], area += a3[0] * b[1] - a3[1] * b[0];
return Math.abs(area);
}
function merge2(topology) {
return object(topology, mergeArcs.apply(this, arguments));
}
function mergeArcs(topology, objects) {
var polygonsByArc = {}, polygons = [], groups = [];
objects.forEach(geometry);
function geometry(o) {
switch (o.type) {
case "GeometryCollection":
o.geometries.forEach(geometry);
break;
case "Polygon":
extract(o.arcs);
break;
case "MultiPolygon":
o.arcs.forEach(extract);
break;
}
}
function extract(polygon) {
polygon.forEach(function(ring) {
ring.forEach(function(arc) {
(polygonsByArc[arc = arc < 0 ? ~arc : arc] || (polygonsByArc[arc] = [])).push(polygon);
});
});
polygons.push(polygon);
}
function area(ring) {
return planarRingArea(object(topology, { type: "Polygon", arcs: [ring] }).coordinates[0]);
}
polygons.forEach(function(polygon) {
if (!polygon._) {
var group = [], neighbors2 = [polygon];
polygon._ = 1;
groups.push(group);
while (polygon = neighbors2.pop()) {
group.push(polygon);
polygon.forEach(function(ring) {
ring.forEach(function(arc) {
polygonsByArc[arc < 0 ? ~arc : arc].forEach(function(polygon2) {
if (!polygon2._) {
polygon2._ = 1;
neighbors2.push(polygon2);
}
});
});
});
}
}
});
polygons.forEach(function(polygon) {
delete polygon._;
});
return {
type: "MultiPolygon",
arcs: groups.map(function(polygons2) {
var arcs = [], n;
polygons2.forEach(function(polygon) {
polygon.forEach(function(ring) {
ring.forEach(function(arc) {
if (polygonsByArc[arc < 0 ? ~arc : arc].length < 2) {
arcs.push(arc);
}
});
});
});
arcs = stitch(topology, arcs);
if ((n = arcs.length) > 1) {
for (var i = 1, k = area(arcs[0]), ki, t; i < n; ++i) {
if ((ki = area(arcs[i])) > k) {
t = arcs[0], arcs[0] = arcs[i], arcs[i] = t, k = ki;
}
}
}
return arcs;
}).filter(function(arcs) {
return arcs.length > 0;
})
};
}
function bisect(a3, x) {
var lo = 0, hi = a3.length;
while (lo < hi) {
var mid = lo + hi >>> 1;
if (a3[mid] < x)
lo = mid + 1;
else
hi = mid;
}
return lo;
}
function neighbors(objects) {
var indexesByArc = {}, neighbors2 = objects.map(function() {
return [];
});
function line(arcs, i2) {
arcs.forEach(function(a3) {
if (a3 < 0)
a3 = ~a3;
var o = indexesByArc[a3];
if (o)
o.push(i2);
else
indexesByArc[a3] = [i2];
});
}
function polygon(arcs, i2) {
arcs.forEach(function(arc) {
line(arc, i2);
});
}
function geometry(o, i2) {
if (o.type === "GeometryCollection")
o.geometries.forEach(function(o2) {
geometry(o2, i2);
});
else if (o.type in geometryType)
geometryType[o.type](o.arcs, i2);
}
var geometryType = {
LineString: line,
MultiLineString: polygon,
Polygon: polygon,
MultiPolygon: function(arcs, i2) {
arcs.forEach(function(arc) {
polygon(arc, i2);
});
}
};
objects.forEach(geometry);
for (var i in indexesByArc) {
for (var indexes = indexesByArc[i], m = indexes.length, j = 0; j < m; ++j) {
for (var k = j + 1; k < m; ++k) {
var ij = indexes[j], ik = indexes[k], n;
if ((n = neighbors2[ij])[i = bisect(n, ik)] !== ik)
n.splice(i, 0, ik);
if ((n = neighbors2[ik])[i = bisect(n, ij)] !== ij)
n.splice(i, 0, ij);
}
}
}
return neighbors2;
}
function untransform(transform4) {
if (transform4 == null)
return identity;
var x0, y0, kx = transform4.scale[0], ky = transform4.scale[1], dx = transform4.translate[0], dy = transform4.translate[1];
return function(input, i) {
if (!i)
x0 = y0 = 0;
var j = 2, n = input.length, output = new Array(n), x1 = Math.round((input[0] - dx) / kx), y1 = Math.round((input[1] - dy) / ky);
output[0] = x1 - x0, x0 = x1;
output[1] = y1 - y0, y0 = y1;
while (j < n)
output[j] = input[j], ++j;
return output;
};
}
function quantize(topology, transform4) {
if (topology.transform)
throw new Error("already quantized");
if (!transform4 || !transform4.scale) {
if (!((n = Math.floor(transform4)) >= 2))
throw new Error("n must be \u22652");
box = topology.bbox || bbox(topology);
var x0 = box[0], y0 = box[1], x1 = box[2], y1 = box[3], n;
transform4 = { scale: [x1 - x0 ? (x1 - x0) / (n - 1) : 1, y1 - y0 ? (y1 - y0) / (n - 1) : 1], translate: [x0, y0] };
} else {
box = topology.bbox;
}
var t = untransform(transform4), box, key, inputs = topology.objects, outputs = {};
function quantizePoint(point) {
return t(point);
}
function quantizeGeometry(input) {
var output;
switch (input.type) {
case "GeometryCollection":
output = { type: "GeometryCollection", geometries: input.geometries.map(quantizeGeometry) };
break;
case "Point":
output = { type: "Point", coordinates: quantizePoint(input.coordinates) };
break;
case "MultiPoint":
output = { type: "MultiPoint", coordinates: input.coordinates.map(quantizePoint) };
break;
default:
return input;
}
if (input.id != null)
output.id = input.id;
if (input.bbox != null)
output.bbox = input.bbox;
if (input.properties != null)
output.properties = input.properties;
return output;
}
function quantizeArc(input) {
var i = 0, j = 1, n2 = input.length, p, output = new Array(n2);
output[0] = t(input[0], 0);
while (++i < n2)
if ((p = t(input[i], i))[0] || p[1])
output[j++] = p;
if (j === 1)
output[j++] = [0, 0];
output.length = j;
return output;
}
for (key in inputs)
outputs[key] = quantizeGeometry(inputs[key]);
return {
type: "Topology",
bbox: box,
transform: transform4,
objects: outputs,
arcs: topology.arcs.map(quantizeArc)
};
}
exports3.bbox = bbox;
exports3.feature = feature;
exports3.merge = merge2;
exports3.mergeArcs = mergeArcs;
exports3.mesh = mesh;
exports3.meshArcs = meshArcs;
exports3.neighbors = neighbors;
exports3.quantize = quantize;
exports3.transform = transform3;
exports3.untransform = untransform;
Object.defineProperty(exports3, "__esModule", { value: true });
});
}
});
// node_modules/autolinker/dist/commonjs/utils.js
var require_utils = __commonJS({
"node_modules/autolinker/dist/commonjs/utils.js"(exports2) {
"use strict";
Object.defineProperty(exports2, "__esModule", { value: true });
exports2.throwUnhandledCaseError = exports2.splitAndCapture = exports2.remove = exports2.indexOf = exports2.ellipsis = exports2.defaults = void 0;
function defaults(dest, src) {
for (var prop in src) {
if (src.hasOwnProperty(prop) && dest[prop] === void 0) {
dest[prop] = src[prop];
}
}
return dest;
}
exports2.defaults = defaults;
function ellipsis(str, truncateLen, ellipsisChars) {
var ellipsisLength;
if (str.length > truncateLen) {
if (ellipsisChars == null) {
ellipsisChars = "…";
ellipsisLength = 3;
} else {
ellipsisLength = ellipsisChars.length;
}
str = str.substring(0, truncateLen - ellipsisLength) + ellipsisChars;
}
return str;
}
exports2.ellipsis = ellipsis;
function indexOf2(arr, element) {
if (Array.prototype.indexOf) {
return arr.indexOf(element);
} else {
for (var i = 0, len = arr.length; i < len; i++) {
if (arr[i] === element)
return i;
}
return -1;
}
}
exports2.indexOf = indexOf2;
function remove3(arr, fn) {
for (var i = arr.length - 1; i >= 0; i--) {
if (fn(arr[i]) === true) {
arr.splice(i, 1);
}
}
}
exports2.remove = remove3;
function splitAndCapture(str, splitRegex) {
if (!splitRegex.global)
throw new Error("`splitRegex` must have the 'g' flag set");
var result = [], lastIdx = 0, match;
while (match = splitRegex.exec(str)) {
result.push(str.substring(lastIdx, match.index));
result.push(match[0]);
lastIdx = match.index + match[0].length;
}
result.push(str.substring(lastIdx));
return result;
}
exports2.splitAndCapture = splitAndCapture;
function throwUnhandledCaseError(theValue) {
throw new Error("Unhandled case for value: '".concat(theValue, "'"));
}
exports2.throwUnhandledCaseError = throwUnhandledCaseError;
}
});
// node_modules/autolinker/dist/commonjs/html-tag.js
var require_html_tag = __commonJS({
"node_modules/autolinker/dist/commonjs/html-tag.js"(exports2) {
"use strict";
Object.defineProperty(exports2, "__esModule", { value: true });
exports2.HtmlTag = void 0;
var utils_1 = require_utils();
var HtmlTag = function() {
function HtmlTag2(cfg) {
if (cfg === void 0) {
cfg = {};
}
this.tagName = "";
this.attrs = {};
this.innerHTML = "";
this.whitespaceRegex = /\s+/;
this.tagName = cfg.tagName || "";
this.attrs = cfg.attrs || {};
this.innerHTML = cfg.innerHtml || cfg.innerHTML || "";
}
HtmlTag2.prototype.setTagName = function(tagName) {
this.tagName = tagName;
return this;
};
HtmlTag2.prototype.getTagName = function() {
return this.tagName || "";
};
HtmlTag2.prototype.setAttr = function(attrName, attrValue) {
var tagAttrs = this.getAttrs();
tagAttrs[attrName] = attrValue;
return this;
};
HtmlTag2.prototype.getAttr = function(attrName) {
return this.getAttrs()[attrName];
};
HtmlTag2.prototype.setAttrs = function(attrs) {
Object.assign(this.getAttrs(), attrs);
return this;
};
HtmlTag2.prototype.getAttrs = function() {
return this.attrs || (this.attrs = {});
};
HtmlTag2.prototype.setClass = function(cssClass) {
return this.setAttr("class", cssClass);
};
HtmlTag2.prototype.addClass = function(cssClass) {
var classAttr = this.getClass(), whitespaceRegex = this.whitespaceRegex, classes = !classAttr ? [] : classAttr.split(whitespaceRegex), newClasses = cssClass.split(whitespaceRegex), newClass;
while (newClass = newClasses.shift()) {
if ((0, utils_1.indexOf)(classes, newClass) === -1) {
classes.push(newClass);
}
}
this.getAttrs()["class"] = classes.join(" ");
return this;
};
HtmlTag2.prototype.removeClass = function(cssClass) {
var classAttr = this.getClass(), whitespaceRegex = this.whitespaceRegex, classes = !classAttr ? [] : classAttr.split(whitespaceRegex), removeClasses = cssClass.split(whitespaceRegex), removeClass;
while (classes.length && (removeClass = removeClasses.shift())) {
var idx = (0, utils_1.indexOf)(classes, removeClass);
if (idx !== -1) {
classes.splice(idx, 1);
}
}
this.getAttrs()["class"] = classes.join(" ");
return this;
};
HtmlTag2.prototype.getClass = function() {
return this.getAttrs()["class"] || "";
};
HtmlTag2.prototype.hasClass = function(cssClass) {
return (" " + this.getClass() + " ").indexOf(" " + cssClass + " ") !== -1;
};
HtmlTag2.prototype.setInnerHTML = function(html) {
this.innerHTML = html;
return this;
};
HtmlTag2.prototype.setInnerHtml = function(html) {
return this.setInnerHTML(html);
};
HtmlTag2.prototype.getInnerHTML = function() {
return this.innerHTML || "";
};
HtmlTag2.prototype.getInnerHtml = function() {
return this.getInnerHTML();
};
HtmlTag2.prototype.toAnchorString = function() {
var tagName = this.getTagName(), attrsStr = this.buildAttrsStr();
attrsStr = attrsStr ? " " + attrsStr : "";
return ["<", tagName, attrsStr, ">", this.getInnerHtml(), "", tagName, ">"].join("");
};
HtmlTag2.prototype.buildAttrsStr = function() {
if (!this.attrs)
return "";
var attrs = this.getAttrs(), attrsArr = [];
for (var prop in attrs) {
if (attrs.hasOwnProperty(prop)) {
attrsArr.push(prop + '="' + attrs[prop] + '"');
}
}
return attrsArr.join(" ");
};
return HtmlTag2;
}();
exports2.HtmlTag = HtmlTag;
}
});
// node_modules/autolinker/dist/commonjs/truncate/truncate-smart.js
var require_truncate_smart = __commonJS({
"node_modules/autolinker/dist/commonjs/truncate/truncate-smart.js"(exports2) {
"use strict";
Object.defineProperty(exports2, "__esModule", { value: true });
exports2.truncateSmart = void 0;
function truncateSmart(url2, truncateLen, ellipsisChars) {
var ellipsisLengthBeforeParsing;
var ellipsisLength;
if (ellipsisChars == null) {
ellipsisChars = "…";
ellipsisLength = 3;
ellipsisLengthBeforeParsing = 8;
} else {
ellipsisLength = ellipsisChars.length;
ellipsisLengthBeforeParsing = ellipsisChars.length;
}
var parse_url = function(url3) {
var urlObj2 = {};
var urlSub = url3;
var match = urlSub.match(/^([a-z]+):\/\//i);
if (match) {
urlObj2.scheme = match[1];
urlSub = urlSub.substr(match[0].length);
}
match = urlSub.match(/^(.*?)(?=(\?|#|\/|$))/i);
if (match) {
urlObj2.host = match[1];
urlSub = urlSub.substr(match[0].length);
}
match = urlSub.match(/^\/(.*?)(?=(\?|#|$))/i);
if (match) {
urlObj2.path = match[1];
urlSub = urlSub.substr(match[0].length);
}
match = urlSub.match(/^\?(.*?)(?=(#|$))/i);
if (match) {
urlObj2.query = match[1];
urlSub = urlSub.substr(match[0].length);
}
match = urlSub.match(/^#(.*?)$/i);
if (match) {
urlObj2.fragment = match[1];
}
return urlObj2;
};
var buildUrl = function(urlObj2) {
var url3 = "";
if (urlObj2.scheme && urlObj2.host) {
url3 += urlObj2.scheme + "://";
}
if (urlObj2.host) {
url3 += urlObj2.host;
}
if (urlObj2.path) {
url3 += "/" + urlObj2.path;
}
if (urlObj2.query) {
url3 += "?" + urlObj2.query;
}
if (urlObj2.fragment) {
url3 += "#" + urlObj2.fragment;
}
return url3;
};
var buildSegment = function(segment, remainingAvailableLength3) {
var remainingAvailableLengthHalf = remainingAvailableLength3 / 2, startOffset = Math.ceil(remainingAvailableLengthHalf), endOffset = -1 * Math.floor(remainingAvailableLengthHalf), end2 = "";
if (endOffset < 0) {
end2 = segment.substr(endOffset);
}
return segment.substr(0, startOffset) + ellipsisChars + end2;
};
if (url2.length <= truncateLen) {
return url2;
}
var availableLength = truncateLen - ellipsisLength;
var urlObj = parse_url(url2);
if (urlObj.query) {
var matchQuery = urlObj.query.match(/^(.*?)(?=(\?|\#))(.*?)$/i);
if (matchQuery) {
urlObj.query = urlObj.query.substr(0, matchQuery[1].length);
url2 = buildUrl(urlObj);
}
}
if (url2.length <= truncateLen) {
return url2;
}
if (urlObj.host) {
urlObj.host = urlObj.host.replace(/^www\./, "");
url2 = buildUrl(urlObj);
}
if (url2.length <= truncateLen) {
return url2;
}
var str = "";
if (urlObj.host) {
str += urlObj.host;
}
if (str.length >= availableLength) {
if (urlObj.host.length == truncateLen) {
return (urlObj.host.substr(0, truncateLen - ellipsisLength) + ellipsisChars).substr(0, availableLength + ellipsisLengthBeforeParsing);
}
return buildSegment(str, availableLength).substr(0, availableLength + ellipsisLengthBeforeParsing);
}
var pathAndQuery = "";
if (urlObj.path) {
pathAndQuery += "/" + urlObj.path;
}
if (urlObj.query) {
pathAndQuery += "?" + urlObj.query;
}
if (pathAndQuery) {
if ((str + pathAndQuery).length >= availableLength) {
if ((str + pathAndQuery).length == truncateLen) {
return (str + pathAndQuery).substr(0, truncateLen);
}
var remainingAvailableLength = availableLength - str.length;
return (str + buildSegment(pathAndQuery, remainingAvailableLength)).substr(0, availableLength + ellipsisLengthBeforeParsing);
} else {
str += pathAndQuery;
}
}
if (urlObj.fragment) {
var fragment = "#" + urlObj.fragment;
if ((str + fragment).length >= availableLength) {
if ((str + fragment).length == truncateLen) {
return (str + fragment).substr(0, truncateLen);
}
var remainingAvailableLength2 = availableLength - str.length;
return (str + buildSegment(fragment, remainingAvailableLength2)).substr(0, availableLength + ellipsisLengthBeforeParsing);
} else {
str += fragment;
}
}
if (urlObj.scheme && urlObj.host) {
var scheme = urlObj.scheme + "://";
if ((str + scheme).length < availableLength) {
return (scheme + str).substr(0, truncateLen);
}
}
if (str.length <= truncateLen) {
return str;
}
var end = "";
if (availableLength > 0) {
end = str.substr(-1 * Math.floor(availableLength / 2));
}
return (str.substr(0, Math.ceil(availableLength / 2)) + ellipsisChars + end).substr(0, availableLength + ellipsisLengthBeforeParsing);
}
exports2.truncateSmart = truncateSmart;
}
});
// node_modules/autolinker/dist/commonjs/truncate/truncate-middle.js
var require_truncate_middle = __commonJS({
"node_modules/autolinker/dist/commonjs/truncate/truncate-middle.js"(exports2) {
"use strict";
Object.defineProperty(exports2, "__esModule", { value: true });
exports2.truncateMiddle = void 0;
function truncateMiddle(url2, truncateLen, ellipsisChars) {
if (url2.length <= truncateLen) {
return url2;
}
var ellipsisLengthBeforeParsing;
var ellipsisLength;
if (ellipsisChars == null) {
ellipsisChars = "…";
ellipsisLengthBeforeParsing = 8;
ellipsisLength = 3;
} else {
ellipsisLengthBeforeParsing = ellipsisChars.length;
ellipsisLength = ellipsisChars.length;
}
var availableLength = truncateLen - ellipsisLength;
var end = "";
if (availableLength > 0) {
end = url2.substr(-1 * Math.floor(availableLength / 2));
}
return (url2.substr(0, Math.ceil(availableLength / 2)) + ellipsisChars + end).substr(0, availableLength + ellipsisLengthBeforeParsing);
}
exports2.truncateMiddle = truncateMiddle;
}
});
// node_modules/autolinker/dist/commonjs/truncate/truncate-end.js
var require_truncate_end = __commonJS({
"node_modules/autolinker/dist/commonjs/truncate/truncate-end.js"(exports2) {
"use strict";
Object.defineProperty(exports2, "__esModule", { value: true });
exports2.truncateEnd = void 0;
var utils_1 = require_utils();
function truncateEnd(anchorText, truncateLen, ellipsisChars) {
return (0, utils_1.ellipsis)(anchorText, truncateLen, ellipsisChars);
}
exports2.truncateEnd = truncateEnd;
}
});
// node_modules/autolinker/dist/commonjs/anchor-tag-builder.js
var require_anchor_tag_builder = __commonJS({
"node_modules/autolinker/dist/commonjs/anchor-tag-builder.js"(exports2) {
"use strict";
Object.defineProperty(exports2, "__esModule", { value: true });
exports2.AnchorTagBuilder = void 0;
var html_tag_1 = require_html_tag();
var truncate_smart_1 = require_truncate_smart();
var truncate_middle_1 = require_truncate_middle();
var truncate_end_1 = require_truncate_end();
var AnchorTagBuilder = function() {
function AnchorTagBuilder2(cfg) {
if (cfg === void 0) {
cfg = {};
}
this.newWindow = false;
this.truncate = {};
this.className = "";
this.newWindow = cfg.newWindow || false;
this.truncate = cfg.truncate || {};
this.className = cfg.className || "";
}
AnchorTagBuilder2.prototype.build = function(match) {
return new html_tag_1.HtmlTag({
tagName: "a",
attrs: this.createAttrs(match),
innerHtml: this.processAnchorText(match.getAnchorText())
});
};
AnchorTagBuilder2.prototype.createAttrs = function(match) {
var attrs = {
"href": match.getAnchorHref()
};
var cssClass = this.createCssClass(match);
if (cssClass) {
attrs["class"] = cssClass;
}
if (this.newWindow) {
attrs["target"] = "_blank";
attrs["rel"] = "noopener noreferrer";
}
if (this.truncate) {
if (this.truncate.length && this.truncate.length < match.getAnchorText().length) {
attrs["title"] = match.getAnchorHref();
}
}
return attrs;
};
AnchorTagBuilder2.prototype.createCssClass = function(match) {
var className = this.className;
if (!className) {
return "";
} else {
var returnClasses = [className], cssClassSuffixes = match.getCssClassSuffixes();
for (var i = 0, len = cssClassSuffixes.length; i < len; i++) {
returnClasses.push(className + "-" + cssClassSuffixes[i]);
}
return returnClasses.join(" ");
}
};
AnchorTagBuilder2.prototype.processAnchorText = function(anchorText) {
anchorText = this.doTruncate(anchorText);
return anchorText;
};
AnchorTagBuilder2.prototype.doTruncate = function(anchorText) {
var truncate = this.truncate;
if (!truncate || !truncate.length)
return anchorText;
var truncateLength = truncate.length, truncateLocation = truncate.location;
if (truncateLocation === "smart") {
return (0, truncate_smart_1.truncateSmart)(anchorText, truncateLength);
} else if (truncateLocation === "middle") {
return (0, truncate_middle_1.truncateMiddle)(anchorText, truncateLength);
} else {
return (0, truncate_end_1.truncateEnd)(anchorText, truncateLength);
}
};
return AnchorTagBuilder2;
}();
exports2.AnchorTagBuilder = AnchorTagBuilder;
}
});
// node_modules/autolinker/dist/commonjs/match/match.js
var require_match = __commonJS({
"node_modules/autolinker/dist/commonjs/match/match.js"(exports2) {
"use strict";
Object.defineProperty(exports2, "__esModule", { value: true });
exports2.Match = void 0;
var Match = function() {
function Match2(cfg) {
this.__jsduckDummyDocProp = null;
this.matchedText = "";
this.offset = 0;
this.tagBuilder = cfg.tagBuilder;
this.matchedText = cfg.matchedText;
this.offset = cfg.offset;
}
Match2.prototype.getMatchedText = function() {
return this.matchedText;
};
Match2.prototype.setOffset = function(offset2) {
this.offset = offset2;
};
Match2.prototype.getOffset = function() {
return this.offset;
};
Match2.prototype.getCssClassSuffixes = function() {
return [this.getType()];
};
Match2.prototype.buildTag = function() {
return this.tagBuilder.build(this);
};
return Match2;
}();
exports2.Match = Match;
}
});
// node_modules/tslib/tslib.js
var require_tslib = __commonJS({
"node_modules/tslib/tslib.js"(exports2, module2) {
var __extends;
var __assign;
var __rest;
var __decorate;
var __param;
var __metadata;
var __awaiter;
var __generator;
var __exportStar;
var __values;
var __read;
var __spread;
var __spreadArrays;
var __spreadArray;
var __await;
var __asyncGenerator;
var __asyncDelegator;
var __asyncValues;
var __makeTemplateObject;
var __importStar;
var __importDefault;
var __classPrivateFieldGet;
var __classPrivateFieldSet;
var __classPrivateFieldIn;
var __createBinding;
(function(factory) {
var root = typeof global === "object" ? global : typeof self === "object" ? self : typeof this === "object" ? this : {};
if (typeof define === "function" && define.amd) {
define("tslib", ["exports"], function(exports3) {
factory(createExporter(root, createExporter(exports3)));
});
} else if (typeof module2 === "object" && typeof module2.exports === "object") {
factory(createExporter(root, createExporter(module2.exports)));
} else {
factory(createExporter(root));
}
function createExporter(exports3, previous) {
if (exports3 !== root) {
if (typeof Object.create === "function") {
Object.defineProperty(exports3, "__esModule", { value: true });
} else {
exports3.__esModule = true;
}
}
return function(id, v7) {
return exports3[id] = previous ? previous(id, v7) : v7;
};
}
})(function(exporter) {
var extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d, b) {
d.__proto__ = b;
} || function(d, b) {
for (var p in b)
if (Object.prototype.hasOwnProperty.call(b, p))
d[p] = b[p];
};
__extends = function(d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s)
if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
__rest = function(s, e) {
var t = {};
for (var p in s)
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
};
__decorate = function(decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
r = Reflect.decorate(decorators, target, key, desc);
else
for (var i = decorators.length - 1; i >= 0; i--)
if (d = decorators[i])
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
__param = function(paramIndex, decorator) {
return function(target, key) {
decorator(target, key, paramIndex);
};
};
__metadata = function(metadataKey, metadataValue) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
return Reflect.metadata(metadataKey, metadataValue);
};
__awaiter = function(thisArg, _arguments, P, generator) {
function adopt(value) {
return value instanceof P ? value : new P(function(resolve2) {
resolve2(value);
});
}
return new (P || (P = Promise))(function(resolve2, reject) {
function fulfilled(value) {
try {
step2(generator.next(value));
} catch (e) {
reject(e);
}
}
function rejected(value) {
try {
step2(generator["throw"](value));
} catch (e) {
reject(e);
}
}
function step2(result) {
result.done ? resolve2(result.value) : adopt(result.value).then(fulfilled, rejected);
}
step2((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
__generator = function(thisArg, body) {
var _ = { label: 0, sent: function() {
if (t[0] & 1)
throw t[1];
return t[1];
}, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
return this;
}), g;
function verb(n) {
return function(v7) {
return step2([n, v7]);
};
}
function step2(op) {
if (f)
throw new TypeError("Generator is already executing.");
while (_)
try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
return t;
if (y = 0, t)
op = [op[0] & 2, t.value];
switch (op[0]) {
case 0:
case 1:
t = op;
break;
case 4:
_.label++;
return { value: op[1], done: false };
case 5:
_.label++;
y = op[1];
op = [0];
continue;
case 7:
op = _.ops.pop();
_.trys.pop();
continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
_ = 0;
continue;
}
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
_.label = op[1];
break;
}
if (op[0] === 6 && _.label < t[1]) {
_.label = t[1];
t = op;
break;
}
if (t && _.label < t[2]) {
_.label = t[2];
_.ops.push(op);
break;
}
if (t[2])
_.ops.pop();
_.trys.pop();
continue;
}
op = body.call(thisArg, _);
} catch (e) {
op = [6, e];
y = 0;
} finally {
f = t = 0;
}
if (op[0] & 5)
throw op[1];
return { value: op[0] ? op[1] : void 0, done: true };
}
};
__exportStar = function(m, o) {
for (var p in m)
if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
__createBinding(o, m, p);
};
__createBinding = Object.create ? function(o, m, k, k2) {
if (k2 === void 0)
k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() {
return m[k];
} };
}
Object.defineProperty(o, k2, desc);
} : function(o, m, k, k2) {
if (k2 === void 0)
k2 = k;
o[k2] = m[k];
};
__values = function(o) {
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
if (m)
return m.call(o);
if (o && typeof o.length === "number")
return {
next: function() {
if (o && i >= o.length)
o = void 0;
return { value: o && o[i++], done: !o };
}
};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
};
__read = function(o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m)
return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
ar.push(r.value);
} catch (error) {
e = { error };
} finally {
try {
if (r && !r.done && (m = i["return"]))
m.call(i);
} finally {
if (e)
throw e.error;
}
}
return ar;
};
__spread = function() {
for (var ar = [], i = 0; i < arguments.length; i++)
ar = ar.concat(__read(arguments[i]));
return ar;
};
__spreadArrays = function() {
for (var s = 0, i = 0, il = arguments.length; i < il; i++)
s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a3 = arguments[i], j = 0, jl = a3.length; j < jl; j++, k++)
r[k] = a3[j];
return r;
};
__spreadArray = function(to, from, pack) {
if (pack || arguments.length === 2)
for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar)
ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};
__await = function(v7) {
return this instanceof __await ? (this.v = v7, this) : new __await(v7);
};
__asyncGenerator = function(thisArg, _arguments, generator) {
if (!Symbol.asyncIterator)
throw new TypeError("Symbol.asyncIterator is not defined.");
var g = generator.apply(thisArg, _arguments || []), i, q = [];
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function() {
return this;
}, i;
function verb(n) {
if (g[n])
i[n] = function(v7) {
return new Promise(function(a3, b) {
q.push([n, v7, a3, b]) > 1 || resume(n, v7);
});
};
}
function resume(n, v7) {
try {
step2(g[n](v7));
} catch (e) {
settle(q[0][3], e);
}
}
function step2(r) {
r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r);
}
function fulfill(value) {
resume("next", value);
}
function reject(value) {
resume("throw", value);
}
function settle(f, v7) {
if (f(v7), q.shift(), q.length)
resume(q[0][0], q[0][1]);
}
};
__asyncDelegator = function(o) {
var i, p;
return i = {}, verb("next"), verb("throw", function(e) {
throw e;
}), verb("return"), i[Symbol.iterator] = function() {
return this;
}, i;
function verb(n, f) {
i[n] = o[n] ? function(v7) {
return (p = !p) ? { value: __await(o[n](v7)), done: n === "return" } : f ? f(v7) : v7;
} : f;
}
};
__asyncValues = function(o) {
if (!Symbol.asyncIterator)
throw new TypeError("Symbol.asyncIterator is not defined.");
var m = o[Symbol.asyncIterator], i;
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function() {
return this;
}, i);
function verb(n) {
i[n] = o[n] && function(v7) {
return new Promise(function(resolve2, reject) {
v7 = o[n](v7), settle(resolve2, reject, v7.done, v7.value);
});
};
}
function settle(resolve2, reject, d, v7) {
Promise.resolve(v7).then(function(v8) {
resolve2({ value: v8, done: d });
}, reject);
}
};
__makeTemplateObject = function(cooked, raw) {
if (Object.defineProperty) {
Object.defineProperty(cooked, "raw", { value: raw });
} else {
cooked.raw = raw;
}
return cooked;
};
var __setModuleDefault = Object.create ? function(o, v7) {
Object.defineProperty(o, "default", { enumerable: true, value: v7 });
} : function(o, v7) {
o["default"] = v7;
};
__importStar = function(mod2) {
if (mod2 && mod2.__esModule)
return mod2;
var result = {};
if (mod2 != null) {
for (var k in mod2)
if (k !== "default" && Object.prototype.hasOwnProperty.call(mod2, k))
__createBinding(result, mod2, k);
}
__setModuleDefault(result, mod2);
return result;
};
__importDefault = function(mod2) {
return mod2 && mod2.__esModule ? mod2 : { "default": mod2 };
};
__classPrivateFieldGet = function(receiver, state, kind, f) {
if (kind === "a" && !f)
throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
__classPrivateFieldSet = function(receiver, state, value, kind, f) {
if (kind === "m")
throw new TypeError("Private method is not writable");
if (kind === "a" && !f)
throw new TypeError("Private accessor was defined without a setter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
throw new TypeError("Cannot write private member to an object whose class did not declare it");
return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
};
__classPrivateFieldIn = function(state, receiver) {
if (receiver === null || typeof receiver !== "object" && typeof receiver !== "function")
throw new TypeError("Cannot use 'in' operator on non-object");
return typeof state === "function" ? receiver === state : state.has(receiver);
};
exporter("__extends", __extends);
exporter("__assign", __assign);
exporter("__rest", __rest);
exporter("__decorate", __decorate);
exporter("__param", __param);
exporter("__metadata", __metadata);
exporter("__awaiter", __awaiter);
exporter("__generator", __generator);
exporter("__exportStar", __exportStar);
exporter("__createBinding", __createBinding);
exporter("__values", __values);
exporter("__read", __read);
exporter("__spread", __spread);
exporter("__spreadArrays", __spreadArrays);
exporter("__spreadArray", __spreadArray);
exporter("__await", __await);
exporter("__asyncGenerator", __asyncGenerator);
exporter("__asyncDelegator", __asyncDelegator);
exporter("__asyncValues", __asyncValues);
exporter("__makeTemplateObject", __makeTemplateObject);
exporter("__importStar", __importStar);
exporter("__importDefault", __importDefault);
exporter("__classPrivateFieldGet", __classPrivateFieldGet);
exporter("__classPrivateFieldSet", __classPrivateFieldSet);
exporter("__classPrivateFieldIn", __classPrivateFieldIn);
});
}
});
// node_modules/autolinker/dist/commonjs/match/email-match.js
var require_email_match = __commonJS({
"node_modules/autolinker/dist/commonjs/match/email-match.js"(exports2) {
"use strict";
Object.defineProperty(exports2, "__esModule", { value: true });
exports2.EmailMatch = void 0;
var tslib_1 = require_tslib();
var match_1 = require_match();
var EmailMatch = function(_super) {
(0, tslib_1.__extends)(EmailMatch2, _super);
function EmailMatch2(cfg) {
var _this = _super.call(this, cfg) || this;
_this.email = "";
_this.email = cfg.email;
return _this;
}
EmailMatch2.prototype.getType = function() {
return "email";
};
EmailMatch2.prototype.getEmail = function() {
return this.email;
};
EmailMatch2.prototype.getAnchorHref = function() {
return "mailto:" + this.email;
};
EmailMatch2.prototype.getAnchorText = function() {
return this.email;
};
return EmailMatch2;
}(match_1.Match);
exports2.EmailMatch = EmailMatch;
}
});
// node_modules/autolinker/dist/commonjs/match/hashtag-match.js
var require_hashtag_match = __commonJS({
"node_modules/autolinker/dist/commonjs/match/hashtag-match.js"(exports2) {
"use strict";
Object.defineProperty(exports2, "__esModule", { value: true });
exports2.HashtagMatch = void 0;
var tslib_1 = require_tslib();
var match_1 = require_match();
var HashtagMatch = function(_super) {
(0, tslib_1.__extends)(HashtagMatch2, _super);
function HashtagMatch2(cfg) {
var _this = _super.call(this, cfg) || this;
_this.serviceName = "";
_this.hashtag = "";
_this.serviceName = cfg.serviceName;
_this.hashtag = cfg.hashtag;
return _this;
}
HashtagMatch2.prototype.getType = function() {
return "hashtag";
};
HashtagMatch2.prototype.getServiceName = function() {
return this.serviceName;
};
HashtagMatch2.prototype.getHashtag = function() {
return this.hashtag;
};
HashtagMatch2.prototype.getAnchorHref = function() {
var serviceName = this.serviceName, hashtag = this.hashtag;
switch (serviceName) {
case "twitter":
return "https://twitter.com/hashtag/" + hashtag;
case "facebook":
return "https://www.facebook.com/hashtag/" + hashtag;
case "instagram":
return "https://instagram.com/explore/tags/" + hashtag;
case "tiktok":
return "https://www.tiktok.com/tag/" + hashtag;
default:
throw new Error("Unknown service name to point hashtag to: " + serviceName);
}
};
HashtagMatch2.prototype.getAnchorText = function() {
return "#" + this.hashtag;
};
return HashtagMatch2;
}(match_1.Match);
exports2.HashtagMatch = HashtagMatch;
}
});
// node_modules/autolinker/dist/commonjs/match/mention-match.js
var require_mention_match = __commonJS({
"node_modules/autolinker/dist/commonjs/match/mention-match.js"(exports2) {
"use strict";
Object.defineProperty(exports2, "__esModule", { value: true });
exports2.MentionMatch = void 0;
var tslib_1 = require_tslib();
var match_1 = require_match();
var MentionMatch = function(_super) {
(0, tslib_1.__extends)(MentionMatch2, _super);
function MentionMatch2(cfg) {
var _this = _super.call(this, cfg) || this;
_this.serviceName = "twitter";
_this.mention = "";
_this.mention = cfg.mention;
_this.serviceName = cfg.serviceName;
return _this;
}
MentionMatch2.prototype.getType = function() {
return "mention";
};
MentionMatch2.prototype.getMention = function() {
return this.mention;
};
MentionMatch2.prototype.getServiceName = function() {
return this.serviceName;
};
MentionMatch2.prototype.getAnchorHref = function() {
switch (this.serviceName) {
case "twitter":
return "https://twitter.com/" + this.mention;
case "instagram":
return "https://instagram.com/" + this.mention;
case "soundcloud":
return "https://soundcloud.com/" + this.mention;
case "tiktok":
return "https://www.tiktok.com/@" + this.mention;
default:
throw new Error("Unknown service name to point mention to: " + this.serviceName);
}
};
MentionMatch2.prototype.getAnchorText = function() {
return "@" + this.mention;
};
MentionMatch2.prototype.getCssClassSuffixes = function() {
var cssClassSuffixes = _super.prototype.getCssClassSuffixes.call(this), serviceName = this.getServiceName();
if (serviceName) {
cssClassSuffixes.push(serviceName);
}
return cssClassSuffixes;
};
return MentionMatch2;
}(match_1.Match);
exports2.MentionMatch = MentionMatch;
}
});
// node_modules/autolinker/dist/commonjs/match/phone-match.js
var require_phone_match = __commonJS({
"node_modules/autolinker/dist/commonjs/match/phone-match.js"(exports2) {
"use strict";
Object.defineProperty(exports2, "__esModule", { value: true });
exports2.PhoneMatch = void 0;
var tslib_1 = require_tslib();
var match_1 = require_match();
var PhoneMatch = function(_super) {
(0, tslib_1.__extends)(PhoneMatch2, _super);
function PhoneMatch2(cfg) {
var _this = _super.call(this, cfg) || this;
_this.number = "";
_this.plusSign = false;
_this.number = cfg.number;
_this.plusSign = cfg.plusSign;
return _this;
}
PhoneMatch2.prototype.getType = function() {
return "phone";
};
PhoneMatch2.prototype.getPhoneNumber = function() {
return this.number;
};
PhoneMatch2.prototype.getNumber = function() {
return this.getPhoneNumber();
};
PhoneMatch2.prototype.getAnchorHref = function() {
return "tel:" + (this.plusSign ? "+" : "") + this.number;
};
PhoneMatch2.prototype.getAnchorText = function() {
return this.matchedText;
};
return PhoneMatch2;
}(match_1.Match);
exports2.PhoneMatch = PhoneMatch;
}
});
// node_modules/autolinker/dist/commonjs/match/url-match.js
var require_url_match = __commonJS({
"node_modules/autolinker/dist/commonjs/match/url-match.js"(exports2) {
"use strict";
Object.defineProperty(exports2, "__esModule", { value: true });
exports2.UrlMatch = void 0;
var tslib_1 = require_tslib();
var match_1 = require_match();
var UrlMatch = function(_super) {
(0, tslib_1.__extends)(UrlMatch2, _super);
function UrlMatch2(cfg) {
var _this = _super.call(this, cfg) || this;
_this.url = "";
_this.urlMatchType = "scheme";
_this.protocolUrlMatch = false;
_this.protocolRelativeMatch = false;
_this.stripPrefix = { scheme: true, www: true };
_this.stripTrailingSlash = true;
_this.decodePercentEncoding = true;
_this.schemePrefixRegex = /^(https?:\/\/)?/i;
_this.wwwPrefixRegex = /^(https?:\/\/)?(www\.)?/i;
_this.protocolRelativeRegex = /^\/\//;
_this.protocolPrepended = false;
_this.urlMatchType = cfg.urlMatchType;
_this.url = cfg.url;
_this.protocolUrlMatch = cfg.protocolUrlMatch;
_this.protocolRelativeMatch = cfg.protocolRelativeMatch;
_this.stripPrefix = cfg.stripPrefix;
_this.stripTrailingSlash = cfg.stripTrailingSlash;
_this.decodePercentEncoding = cfg.decodePercentEncoding;
return _this;
}
UrlMatch2.prototype.getType = function() {
return "url";
};
UrlMatch2.prototype.getUrlMatchType = function() {
return this.urlMatchType;
};
UrlMatch2.prototype.getUrl = function() {
var url2 = this.url;
if (!this.protocolRelativeMatch && !this.protocolUrlMatch && !this.protocolPrepended) {
url2 = this.url = "http://" + url2;
this.protocolPrepended = true;
}
return url2;
};
UrlMatch2.prototype.getAnchorHref = function() {
var url2 = this.getUrl();
return url2.replace(/&/g, "&");
};
UrlMatch2.prototype.getAnchorText = function() {
var anchorText = this.getMatchedText();
if (this.protocolRelativeMatch) {
anchorText = this.stripProtocolRelativePrefix(anchorText);
}
if (this.stripPrefix.scheme) {
anchorText = this.stripSchemePrefix(anchorText);
}
if (this.stripPrefix.www) {
anchorText = this.stripWwwPrefix(anchorText);
}
if (this.stripTrailingSlash) {
anchorText = this.removeTrailingSlash(anchorText);
}
if (this.decodePercentEncoding) {
anchorText = this.removePercentEncoding(anchorText);
}
return anchorText;
};
UrlMatch2.prototype.stripSchemePrefix = function(url2) {
return url2.replace(this.schemePrefixRegex, "");
};
UrlMatch2.prototype.stripWwwPrefix = function(url2) {
return url2.replace(this.wwwPrefixRegex, "$1");
};
UrlMatch2.prototype.stripProtocolRelativePrefix = function(text) {
return text.replace(this.protocolRelativeRegex, "");
};
UrlMatch2.prototype.removeTrailingSlash = function(anchorText) {
if (anchorText.charAt(anchorText.length - 1) === "/") {
anchorText = anchorText.slice(0, -1);
}
return anchorText;
};
UrlMatch2.prototype.removePercentEncoding = function(anchorText) {
var preProcessedEntityAnchorText = anchorText.replace(/%22/gi, """).replace(/%26/gi, "&").replace(/%27/gi, "'").replace(/%3C/gi, "<").replace(/%3E/gi, ">");
try {
return decodeURIComponent(preProcessedEntityAnchorText);
} catch (e) {
return preProcessedEntityAnchorText;
}
};
return UrlMatch2;
}(match_1.Match);
exports2.UrlMatch = UrlMatch;
}
});
// node_modules/autolinker/dist/commonjs/matcher/matcher.js
var require_matcher = __commonJS({
"node_modules/autolinker/dist/commonjs/matcher/matcher.js"(exports2) {
"use strict";
Object.defineProperty(exports2, "__esModule", { value: true });
exports2.Matcher = void 0;
var Matcher = function() {
function Matcher2(cfg) {
this.__jsduckDummyDocProp = null;
this.tagBuilder = cfg.tagBuilder;
}
return Matcher2;
}();
exports2.Matcher = Matcher;
}
});
// node_modules/autolinker/dist/commonjs/regex-lib.js
var require_regex_lib = __commonJS({
"node_modules/autolinker/dist/commonjs/regex-lib.js"(exports2) {
"use strict";
Object.defineProperty(exports2, "__esModule", { value: true });
exports2.domainNameCharRegex = exports2.domainNameRegex = exports2.getDomainNameStr = exports2.alphaNumericAndMarksCharsStr = exports2.alphaNumericCharsStr = exports2.decimalNumbersStr = exports2.alphaCharsAndMarksStr = exports2.marksStr = exports2.emojiStr = exports2.alphaCharsStr = exports2.controlCharsRe = exports2.quoteRe = exports2.whitespaceRe = exports2.nonDigitRe = exports2.digitRe = exports2.letterRe = void 0;
exports2.letterRe = /[A-Za-z]/;
exports2.digitRe = /[\d]/;
exports2.nonDigitRe = /[\D]/;
exports2.whitespaceRe = /\s/;
exports2.quoteRe = /['"]/;
exports2.controlCharsRe = /[\x00-\x1F\x7F]/;
exports2.alphaCharsStr = /A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0-\u08B4\u08B6-\u08BD\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC/.source;
exports2.emojiStr = /\u2700-\u27bf\udde6-\uddff\ud800-\udbff\udc00-\udfff\ufe0e\ufe0f\u0300-\u036f\ufe20-\ufe23\u20d0-\u20f0\ud83c\udffb-\udfff\u200d\u3299\u3297\u303d\u3030\u24c2\ud83c\udd70-\udd71\udd7e-\udd7f\udd8e\udd91-\udd9a\udde6-\uddff\ude01-\ude02\ude1a\ude2f\ude32-\ude3a\ude50-\ude51\u203c\u2049\u25aa-\u25ab\u25b6\u25c0\u25fb-\u25fe\u00a9\u00ae\u2122\u2139\udc04\u2600-\u26FF\u2b05\u2b06\u2b07\u2b1b\u2b1c\u2b50\u2b55\u231a\u231b\u2328\u23cf\u23e9-\u23f3\u23f8-\u23fa\udccf\u2935\u2934\u2190-\u21ff/.source;
exports2.marksStr = /\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D4-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C03\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D01-\u0D03\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF8\u1CF9\u1DC0-\u1DF5\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F/.source;
exports2.alphaCharsAndMarksStr = exports2.alphaCharsStr + exports2.emojiStr + exports2.marksStr;
exports2.decimalNumbersStr = /0-9\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0BE6-\u0BEF\u0C66-\u0C6F\u0CE6-\u0CEF\u0D66-\u0D6F\u0DE6-\u0DEF\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F29\u1040-\u1049\u1090-\u1099\u17E0-\u17E9\u1810-\u1819\u1946-\u194F\u19D0-\u19D9\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\uA620-\uA629\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uA9F0-\uA9F9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19/.source;
exports2.alphaNumericCharsStr = exports2.alphaCharsAndMarksStr + exports2.decimalNumbersStr;
exports2.alphaNumericAndMarksCharsStr = exports2.alphaCharsAndMarksStr + exports2.decimalNumbersStr;
var ipStr = "(?:[" + exports2.decimalNumbersStr + "]{1,3}\\.){3}[" + exports2.decimalNumbersStr + "]{1,3}";
var domainLabelStr = "[" + exports2.alphaNumericAndMarksCharsStr + "](?:[" + exports2.alphaNumericAndMarksCharsStr + "\\-]{0,61}[" + exports2.alphaNumericAndMarksCharsStr + "])?";
var getDomainLabelStr = function(group) {
return "(?=(" + domainLabelStr + "))\\" + group;
};
var getDomainNameStr = function(group) {
return "(?:" + getDomainLabelStr(group) + "(?:\\." + getDomainLabelStr(group + 1) + "){0,126}|" + ipStr + ")";
};
exports2.getDomainNameStr = getDomainNameStr;
exports2.domainNameRegex = new RegExp("[" + exports2.alphaNumericAndMarksCharsStr + ".\\-]*[" + exports2.alphaNumericAndMarksCharsStr + "\\-]");
exports2.domainNameCharRegex = new RegExp("[".concat(exports2.alphaNumericAndMarksCharsStr, "]"));
}
});
// node_modules/autolinker/dist/commonjs/matcher/tld-regex.js
var require_tld_regex = __commonJS({
"node_modules/autolinker/dist/commonjs/matcher/tld-regex.js"(exports2) {
"use strict";
Object.defineProperty(exports2, "__esModule", { value: true });
exports2.tldRegex = void 0;
exports2.tldRegex = /(?:xn--vermgensberatung-pwb|xn--vermgensberater-ctb|xn--clchc0ea0b2g2a9gcd|xn--w4r85el8fhu5dnra|northwesternmutual|travelersinsurance|vermögensberatung|xn--3oq18vl8pn36a|xn--5su34j936bgsg|xn--bck1b9a5dre4c|xn--mgbah1a3hjkrd|xn--mgbai9azgqp6j|xn--mgberp4a5d4ar|xn--xkc2dl3a5ee0h|vermögensberater|xn--fzys8d69uvgm|xn--mgba7c0bbn0a|xn--mgbcpq6gpa1a|xn--xkc2al3hye2a|americanexpress|kerryproperties|sandvikcoromant|xn--i1b6b1a6a2e|xn--kcrx77d1x4a|xn--lgbbat1ad8j|xn--mgba3a4f16a|xn--mgbaakc7dvf|xn--mgbc0a9azcg|xn--nqv7fs00ema|afamilycompany|americanfamily|bananarepublic|cancerresearch|cookingchannel|kerrylogistics|weatherchannel|xn--54b7fta0cc|xn--6qq986b3xl|xn--80aqecdr1a|xn--b4w605ferd|xn--fiq228c5hs|xn--h2breg3eve|xn--jlq480n2rg|xn--jlq61u9w7b|xn--mgba3a3ejt|xn--mgbaam7a8h|xn--mgbayh7gpa|xn--mgbbh1a71e|xn--mgbca7dzdo|xn--mgbi4ecexp|xn--mgbx4cd0ab|xn--rvc1e0am3e|international|lifeinsurance|travelchannel|wolterskluwer|xn--cckwcxetd|xn--eckvdtc9d|xn--fpcrj9c3d|xn--fzc2c9e2c|xn--h2brj9c8c|xn--tiq49xqyj|xn--yfro4i67o|xn--ygbi2ammx|construction|lplfinancial|scholarships|versicherung|xn--3e0b707e|xn--45br5cyl|xn--4dbrk0ce|xn--80adxhks|xn--80asehdb|xn--8y0a063a|xn--gckr3f0f|xn--mgb9awbf|xn--mgbab2bd|xn--mgbgu82a|xn--mgbpl2fh|xn--mgbt3dhd|xn--mk1bu44c|xn--ngbc5azd|xn--ngbe9e0a|xn--ogbpf8fl|xn--qcka1pmc|accountants|barclaycard|blackfriday|blockbuster|bridgestone|calvinklein|contractors|creditunion|engineering|enterprises|foodnetwork|investments|kerryhotels|lamborghini|motorcycles|olayangroup|photography|playstation|productions|progressive|redumbrella|williamhill|xn--11b4c3d|xn--1ck2e1b|xn--1qqw23a|xn--2scrj9c|xn--3bst00m|xn--3ds443g|xn--3hcrj9c|xn--42c2d9a|xn--45brj9c|xn--55qw42g|xn--6frz82g|xn--80ao21a|xn--9krt00a|xn--cck2b3b|xn--czr694b|xn--d1acj3b|xn--efvy88h|xn--fct429k|xn--fjq720a|xn--flw351e|xn--g2xx48c|xn--gecrj9c|xn--gk3at1e|xn--h2brj9c|xn--hxt814e|xn--imr513n|xn--j6w193g|xn--jvr189m|xn--kprw13d|xn--kpry57d|xn--mgbbh1a|xn--mgbtx2b|xn--mix891f|xn--nyqy26a|xn--otu796d|xn--pgbs0dh|xn--q9jyb4c|xn--rhqv96g|xn--rovu88b|xn--s9brj9c|xn--ses554g|xn--t60b56a|xn--vuq861b|xn--w4rs40l|xn--xhq521b|xn--zfr164b|சிங்கப்பூர்|accountant|apartments|associates|basketball|bnpparibas|boehringer|capitalone|consulting|creditcard|cuisinella|eurovision|extraspace|foundation|healthcare|immobilien|industries|management|mitsubishi|nextdirect|properties|protection|prudential|realestate|republican|restaurant|schaeffler|swiftcover|tatamotors|technology|university|vlaanderen|volkswagen|xn--30rr7y|xn--3pxu8k|xn--45q11c|xn--4gbrim|xn--55qx5d|xn--5tzm5g|xn--80aswg|xn--90a3ac|xn--9dbq2a|xn--9et52u|xn--c2br7g|xn--cg4bki|xn--czrs0t|xn--czru2d|xn--fiq64b|xn--fiqs8s|xn--fiqz9s|xn--io0a7i|xn--kput3i|xn--mxtq1m|xn--o3cw4h|xn--pssy2u|xn--q7ce6a|xn--unup4y|xn--wgbh1c|xn--wgbl6a|xn--y9a3aq|accenture|alfaromeo|allfinanz|amsterdam|analytics|aquarelle|barcelona|bloomberg|christmas|community|directory|education|equipment|fairwinds|financial|firestone|fresenius|frontdoor|furniture|goldpoint|hisamitsu|homedepot|homegoods|homesense|institute|insurance|kuokgroup|lancaster|landrover|lifestyle|marketing|marshalls|melbourne|microsoft|panasonic|passagens|pramerica|richardli|scjohnson|shangrila|solutions|statebank|statefarm|stockholm|travelers|vacations|xn--90ais|xn--c1avg|xn--d1alf|xn--e1a4c|xn--fhbei|xn--j1aef|xn--j1amh|xn--l1acc|xn--ngbrx|xn--nqv7f|xn--p1acf|xn--qxa6a|xn--tckwe|xn--vhquv|yodobashi|موريتانيا|abudhabi|airforce|allstate|attorney|barclays|barefoot|bargains|baseball|boutique|bradesco|broadway|brussels|budapest|builders|business|capetown|catering|catholic|cipriani|cityeats|cleaning|clinique|clothing|commbank|computer|delivery|deloitte|democrat|diamonds|discount|discover|download|engineer|ericsson|etisalat|exchange|feedback|fidelity|firmdale|football|frontier|goodyear|grainger|graphics|guardian|hdfcbank|helsinki|holdings|hospital|infiniti|ipiranga|istanbul|jpmorgan|lighting|lundbeck|marriott|maserati|mckinsey|memorial|merckmsd|mortgage|observer|partners|pharmacy|pictures|plumbing|property|redstone|reliance|saarland|samsclub|security|services|shopping|showtime|softbank|software|stcgroup|supplies|training|vanguard|ventures|verisign|woodside|xn--90ae|xn--node|xn--p1ai|xn--qxam|yokohama|السعودية|abogado|academy|agakhan|alibaba|android|athleta|auction|audible|auspost|avianca|banamex|bauhaus|bentley|bestbuy|booking|brother|bugatti|capital|caravan|careers|channel|charity|chintai|citadel|clubmed|college|cologne|comcast|company|compare|contact|cooking|corsica|country|coupons|courses|cricket|cruises|dentist|digital|domains|exposed|express|farmers|fashion|ferrari|ferrero|finance|fishing|fitness|flights|florist|flowers|forsale|frogans|fujitsu|gallery|genting|godaddy|grocery|guitars|hamburg|hangout|hitachi|holiday|hosting|hoteles|hotmail|hyundai|ismaili|jewelry|juniper|kitchen|komatsu|lacaixa|lanxess|lasalle|latrobe|leclerc|limited|lincoln|markets|monster|netbank|netflix|network|neustar|okinawa|oldnavy|organic|origins|philips|pioneer|politie|realtor|recipes|rentals|reviews|rexroth|samsung|sandvik|schmidt|schwarz|science|shiksha|singles|staples|storage|support|surgery|systems|temasek|theater|theatre|tickets|tiffany|toshiba|trading|walmart|wanggou|watches|weather|website|wedding|whoswho|windows|winners|xfinity|yamaxun|youtube|zuerich|католик|اتصالات|البحرين|الجزائر|العليان|پاکستان|كاثوليك|இந்தியா|abarth|abbott|abbvie|africa|agency|airbus|airtel|alipay|alsace|alstom|amazon|anquan|aramco|author|bayern|beauty|berlin|bharti|bostik|boston|broker|camera|career|casino|center|chanel|chrome|church|circle|claims|clinic|coffee|comsec|condos|coupon|credit|cruise|dating|datsun|dealer|degree|dental|design|direct|doctor|dunlop|dupont|durban|emerck|energy|estate|events|expert|family|flickr|futbol|gallup|garden|george|giving|global|google|gratis|health|hermes|hiphop|hockey|hotels|hughes|imamat|insure|intuit|jaguar|joburg|juegos|kaufen|kinder|kindle|kosher|lancia|latino|lawyer|lefrak|living|locker|london|luxury|madrid|maison|makeup|market|mattel|mobile|monash|mormon|moscow|museum|mutual|nagoya|natura|nissan|nissay|norton|nowruz|office|olayan|online|oracle|orange|otsuka|pfizer|photos|physio|pictet|quebec|racing|realty|reisen|repair|report|review|rocher|rogers|ryukyu|safety|sakura|sanofi|school|schule|search|secure|select|shouji|soccer|social|stream|studio|supply|suzuki|swatch|sydney|taipei|taobao|target|tattoo|tennis|tienda|tjmaxx|tkmaxx|toyota|travel|unicom|viajes|viking|villas|virgin|vision|voting|voyage|vuelos|walter|webcam|xihuan|yachts|yandex|zappos|москва|онлайн|ابوظبي|ارامكو|الاردن|المغرب|امارات|فلسطين|مليسيا|भारतम्|இலங்கை|ファッション|actor|adult|aetna|amfam|amica|apple|archi|audio|autos|azure|baidu|beats|bible|bingo|black|boats|bosch|build|canon|cards|chase|cheap|cisco|citic|click|cloud|coach|codes|crown|cymru|dabur|dance|deals|delta|drive|dubai|earth|edeka|email|epson|faith|fedex|final|forex|forum|gallo|games|gifts|gives|glade|glass|globo|gmail|green|gripe|group|gucci|guide|homes|honda|horse|house|hyatt|ikano|irish|jetzt|koeln|kyoto|lamer|lease|legal|lexus|lilly|linde|lipsy|lixil|loans|locus|lotte|lotto|macys|mango|media|miami|money|movie|nexus|nikon|ninja|nokia|nowtv|omega|osaka|paris|parts|party|phone|photo|pizza|place|poker|praxi|press|prime|promo|quest|radio|rehab|reise|ricoh|rocks|rodeo|rugby|salon|sener|seven|sharp|shell|shoes|skype|sling|smart|smile|solar|space|sport|stada|store|study|style|sucks|swiss|tatar|tires|tirol|tmall|today|tokyo|tools|toray|total|tours|trade|trust|tunes|tushu|ubank|vegas|video|vodka|volvo|wales|watch|weber|weibo|works|world|xerox|yahoo|ישראל|ایران|بازار|بھارت|سودان|سورية|همراه|भारोत|संगठन|বাংলা|భారత్|ഭാരതം|嘉里大酒店|aarp|able|adac|aero|akdn|ally|amex|arab|army|arpa|arte|asda|asia|audi|auto|baby|band|bank|bbva|beer|best|bike|bing|blog|blue|bofa|bond|book|buzz|cafe|call|camp|care|cars|casa|case|cash|cbre|cern|chat|citi|city|club|cool|coop|cyou|data|date|dclk|deal|dell|desi|diet|dish|docs|duck|dvag|erni|fage|fail|fans|farm|fast|fiat|fido|film|fire|fish|flir|food|ford|free|fund|game|gbiz|gent|ggee|gift|gmbh|gold|golf|goog|guge|guru|hair|haus|hdfc|help|here|hgtv|host|hsbc|icbc|ieee|imdb|immo|info|itau|java|jeep|jobs|jprs|kddi|kiwi|kpmg|kred|land|lego|lgbt|lidl|life|like|limo|link|live|loan|loft|love|ltda|luxe|maif|meet|meme|menu|mini|mint|mobi|moda|moto|name|navy|news|next|nico|nike|ollo|open|page|pars|pccw|pics|ping|pink|play|plus|pohl|porn|post|prod|prof|qpon|raid|read|reit|rent|rest|rich|rmit|room|rsvp|ruhr|safe|sale|sarl|save|saxo|scot|seat|seek|sexy|shaw|shia|shop|show|silk|sina|site|skin|sncf|sohu|song|sony|spot|star|surf|talk|taxi|team|tech|teva|tiaa|tips|town|toys|tube|vana|visa|viva|vivo|vote|voto|wang|weir|wien|wiki|wine|work|xbox|yoga|zara|zero|zone|дети|сайт|بارت|بيتك|ڀارت|تونس|شبكة|عراق|عمان|موقع|भारत|ভারত|ভাৰত|ਭਾਰਤ|ભારત|ଭାରତ|ಭಾರತ|ලංකා|アマゾン|グーグル|クラウド|ポイント|大众汽车|组织机构|電訊盈科|香格里拉|aaa|abb|abc|aco|ads|aeg|afl|aig|anz|aol|app|art|aws|axa|bar|bbc|bbt|bcg|bcn|bet|bid|bio|biz|bms|bmw|bom|boo|bot|box|buy|bzh|cab|cal|cam|car|cat|cba|cbn|cbs|ceo|cfa|cfd|com|cpa|crs|csc|dad|day|dds|dev|dhl|diy|dnp|dog|dot|dtv|dvr|eat|eco|edu|esq|eus|fan|fit|fly|foo|fox|frl|ftr|fun|fyi|gal|gap|gay|gdn|gea|gle|gmo|gmx|goo|gop|got|gov|hbo|hiv|hkt|hot|how|ibm|ice|icu|ifm|inc|ing|ink|int|ist|itv|jcb|jio|jll|jmp|jnj|jot|joy|kfh|kia|kim|kpn|krd|lat|law|lds|llc|llp|lol|lpl|ltd|man|map|mba|med|men|mil|mit|mlb|mls|mma|moe|moi|mom|mov|msd|mtn|mtr|nab|nba|nec|net|new|nfl|ngo|nhk|now|nra|nrw|ntt|nyc|obi|off|one|ong|onl|ooo|org|ott|ovh|pay|pet|phd|pid|pin|pnc|pro|pru|pub|pwc|qvc|red|ren|ril|rio|rip|run|rwe|sap|sas|sbi|sbs|sca|scb|ses|sew|sex|sfr|ski|sky|soy|spa|srl|stc|tab|tax|tci|tdk|tel|thd|tjx|top|trv|tui|tvs|ubs|uno|uol|ups|vet|vig|vin|vip|wed|win|wme|wow|wtc|wtf|xin|xxx|xyz|you|yun|zip|бел|ком|қаз|мкд|мон|орг|рус|срб|укр|հայ|קום|عرب|قطر|كوم|مصر|कॉम|नेट|คอม|ไทย|ລາວ|ストア|セール|みんな|中文网|亚马逊|天主教|我爱你|新加坡|淡马锡|诺基亚|飞利浦|ac|ad|ae|af|ag|ai|al|am|ao|aq|ar|as|at|au|aw|ax|az|ba|bb|bd|be|bf|bg|bh|bi|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|cr|cu|cv|cw|cx|cy|cz|de|dj|dk|dm|do|dz|ec|ee|eg|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|in|io|iq|ir|is|it|je|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mg|mh|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|mv|mw|mx|my|mz|na|nc|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|ps|pt|pw|py|qa|re|ro|rs|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|ss|st|su|sv|sx|sy|sz|tc|td|tf|tg|th|tj|tk|tl|tm|tn|to|tr|tt|tv|tw|tz|ua|ug|uk|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|za|zm|zw|ελ|ευ|бг|ею|рф|გე|닷넷|닷컴|삼성|한국|コム|世界|中信|中国|中國|企业|佛山|信息|健康|八卦|公司|公益|台湾|台灣|商城|商店|商标|嘉里|在线|大拿|娱乐|家電|广东|微博|慈善|手机|招聘|政务|政府|新闻|时尚|書籍|机构|游戏|澳門|点看|移动|网址|网店|网站|网络|联通|谷歌|购物|通販|集团|食品|餐厅|香港)/;
}
});
// node_modules/autolinker/dist/commonjs/matcher/email-matcher.js
var require_email_matcher = __commonJS({
"node_modules/autolinker/dist/commonjs/matcher/email-matcher.js"(exports2) {
"use strict";
Object.defineProperty(exports2, "__esModule", { value: true });
exports2.EmailMatcher = void 0;
var tslib_1 = require_tslib();
var matcher_1 = require_matcher();
var regex_lib_1 = require_regex_lib();
var email_match_1 = require_email_match();
var utils_1 = require_utils();
var tld_regex_1 = require_tld_regex();
var localPartCharRegex = new RegExp("[".concat(regex_lib_1.alphaNumericAndMarksCharsStr, "!#$%&'*+/=?^_`{|}~-]"));
var strictTldRegex = new RegExp("^".concat(tld_regex_1.tldRegex.source, "$"));
var EmailMatcher = function(_super) {
(0, tslib_1.__extends)(EmailMatcher2, _super);
function EmailMatcher2() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.localPartCharRegex = localPartCharRegex;
_this.strictTldRegex = strictTldRegex;
return _this;
}
EmailMatcher2.prototype.parseMatches = function(text) {
var tagBuilder = this.tagBuilder, localPartCharRegex2 = this.localPartCharRegex, strictTldRegex2 = this.strictTldRegex, matches = [], len = text.length, noCurrentEmailMatch = new CurrentEmailMatch();
var mailtoTransitions = {
"m": "a",
"a": "i",
"i": "l",
"l": "t",
"t": "o",
"o": ":"
};
var charIdx = 0, state = 0, currentEmailMatch = noCurrentEmailMatch;
while (charIdx < len) {
var char = text.charAt(charIdx);
switch (state) {
case 0:
stateNonEmailAddress(char);
break;
case 1:
stateMailTo(text.charAt(charIdx - 1), char);
break;
case 2:
stateLocalPart(char);
break;
case 3:
stateLocalPartDot(char);
break;
case 4:
stateAtSign(char);
break;
case 5:
stateDomainChar(char);
break;
case 6:
stateDomainHyphen(char);
break;
case 7:
stateDomainDot(char);
break;
default:
(0, utils_1.throwUnhandledCaseError)(state);
}
charIdx++;
}
captureMatchIfValidAndReset();
return matches;
function stateNonEmailAddress(char2) {
if (char2 === "m") {
beginEmailMatch(1);
} else if (localPartCharRegex2.test(char2)) {
beginEmailMatch();
} else {
}
}
function stateMailTo(prevChar, char2) {
if (prevChar === ":") {
if (localPartCharRegex2.test(char2)) {
state = 2;
currentEmailMatch = new CurrentEmailMatch((0, tslib_1.__assign)((0, tslib_1.__assign)({}, currentEmailMatch), { hasMailtoPrefix: true }));
} else {
resetToNonEmailMatchState();
}
} else if (mailtoTransitions[prevChar] === char2) {
} else if (localPartCharRegex2.test(char2)) {
state = 2;
} else if (char2 === ".") {
state = 3;
} else if (char2 === "@") {
state = 4;
} else {
resetToNonEmailMatchState();
}
}
function stateLocalPart(char2) {
if (char2 === ".") {
state = 3;
} else if (char2 === "@") {
state = 4;
} else if (localPartCharRegex2.test(char2)) {
} else {
resetToNonEmailMatchState();
}
}
function stateLocalPartDot(char2) {
if (char2 === ".") {
resetToNonEmailMatchState();
} else if (char2 === "@") {
resetToNonEmailMatchState();
} else if (localPartCharRegex2.test(char2)) {
state = 2;
} else {
resetToNonEmailMatchState();
}
}
function stateAtSign(char2) {
if (regex_lib_1.domainNameCharRegex.test(char2)) {
state = 5;
} else {
resetToNonEmailMatchState();
}
}
function stateDomainChar(char2) {
if (char2 === ".") {
state = 7;
} else if (char2 === "-") {
state = 6;
} else if (regex_lib_1.domainNameCharRegex.test(char2)) {
} else {
captureMatchIfValidAndReset();
}
}
function stateDomainHyphen(char2) {
if (char2 === "-" || char2 === ".") {
captureMatchIfValidAndReset();
} else if (regex_lib_1.domainNameCharRegex.test(char2)) {
state = 5;
} else {
captureMatchIfValidAndReset();
}
}
function stateDomainDot(char2) {
if (char2 === "." || char2 === "-") {
captureMatchIfValidAndReset();
} else if (regex_lib_1.domainNameCharRegex.test(char2)) {
state = 5;
currentEmailMatch = new CurrentEmailMatch((0, tslib_1.__assign)((0, tslib_1.__assign)({}, currentEmailMatch), { hasDomainDot: true }));
} else {
captureMatchIfValidAndReset();
}
}
function beginEmailMatch(newState) {
if (newState === void 0) {
newState = 2;
}
state = newState;
currentEmailMatch = new CurrentEmailMatch({ idx: charIdx });
}
function resetToNonEmailMatchState() {
state = 0;
currentEmailMatch = noCurrentEmailMatch;
}
function captureMatchIfValidAndReset() {
if (currentEmailMatch.hasDomainDot) {
var matchedText = text.slice(currentEmailMatch.idx, charIdx);
if (/[-.]$/.test(matchedText)) {
matchedText = matchedText.slice(0, -1);
}
var emailAddress = currentEmailMatch.hasMailtoPrefix ? matchedText.slice("mailto:".length) : matchedText;
if (doesEmailHaveValidTld(emailAddress)) {
matches.push(new email_match_1.EmailMatch({
tagBuilder,
matchedText,
offset: currentEmailMatch.idx,
email: emailAddress
}));
}
}
resetToNonEmailMatchState();
function doesEmailHaveValidTld(emailAddress2) {
var emailAddressTld = emailAddress2.split(".").pop() || "";
var emailAddressNormalized = emailAddressTld.toLowerCase();
var isValidTld = strictTldRegex2.test(emailAddressNormalized);
return isValidTld;
}
}
};
return EmailMatcher2;
}(matcher_1.Matcher);
exports2.EmailMatcher = EmailMatcher;
var CurrentEmailMatch = function() {
function CurrentEmailMatch2(cfg) {
if (cfg === void 0) {
cfg = {};
}
this.idx = cfg.idx !== void 0 ? cfg.idx : -1;
this.hasMailtoPrefix = !!cfg.hasMailtoPrefix;
this.hasDomainDot = !!cfg.hasDomainDot;
}
return CurrentEmailMatch2;
}();
}
});
// node_modules/autolinker/dist/commonjs/matcher/url-match-validator.js
var require_url_match_validator = __commonJS({
"node_modules/autolinker/dist/commonjs/matcher/url-match-validator.js"(exports2) {
"use strict";
Object.defineProperty(exports2, "__esModule", { value: true });
exports2.UrlMatchValidator = void 0;
var regex_lib_1 = require_regex_lib();
var UrlMatchValidator = function() {
function UrlMatchValidator2() {
}
UrlMatchValidator2.isValid = function(urlMatch, protocolUrlMatch) {
if (protocolUrlMatch && !this.isValidUriScheme(protocolUrlMatch) || this.urlMatchDoesNotHaveProtocolOrDot(urlMatch, protocolUrlMatch) || this.urlMatchDoesNotHaveAtLeastOneWordChar(urlMatch, protocolUrlMatch) && !this.isValidIpAddress(urlMatch) || this.containsMultipleDots(urlMatch)) {
return false;
}
return true;
};
UrlMatchValidator2.isValidIpAddress = function(uriSchemeMatch) {
var newRegex = new RegExp(this.hasFullProtocolRegex.source + this.ipRegex.source);
var uriScheme = uriSchemeMatch.match(newRegex);
return uriScheme !== null;
};
UrlMatchValidator2.containsMultipleDots = function(urlMatch) {
var stringBeforeSlash = urlMatch;
if (this.hasFullProtocolRegex.test(urlMatch)) {
stringBeforeSlash = urlMatch.split("://")[1];
}
return stringBeforeSlash.split("/")[0].indexOf("..") > -1;
};
UrlMatchValidator2.isValidUriScheme = function(uriSchemeMatch) {
var uriSchemeMatchArr = uriSchemeMatch.match(this.uriSchemeRegex), uriScheme = uriSchemeMatchArr && uriSchemeMatchArr[0].toLowerCase();
return uriScheme !== "javascript:" && uriScheme !== "vbscript:";
};
UrlMatchValidator2.urlMatchDoesNotHaveProtocolOrDot = function(urlMatch, protocolUrlMatch) {
return !!urlMatch && (!protocolUrlMatch || !this.hasFullProtocolRegex.test(protocolUrlMatch)) && urlMatch.indexOf(".") === -1;
};
UrlMatchValidator2.urlMatchDoesNotHaveAtLeastOneWordChar = function(urlMatch, protocolUrlMatch) {
if (urlMatch && protocolUrlMatch) {
return !this.hasFullProtocolRegex.test(protocolUrlMatch) && !this.hasWordCharAfterProtocolRegex.test(urlMatch);
} else {
return false;
}
};
UrlMatchValidator2.hasFullProtocolRegex = /^[A-Za-z][-.+A-Za-z0-9]*:\/\//;
UrlMatchValidator2.uriSchemeRegex = /^[A-Za-z][-.+A-Za-z0-9]*:/;
UrlMatchValidator2.hasWordCharAfterProtocolRegex = new RegExp(":[^\\s]*?[" + regex_lib_1.alphaCharsStr + "]");
UrlMatchValidator2.ipRegex = /[0-9][0-9]?[0-9]?\.[0-9][0-9]?[0-9]?\.[0-9][0-9]?[0-9]?\.[0-9][0-9]?[0-9]?(:[0-9]*)?\/?$/;
return UrlMatchValidator2;
}();
exports2.UrlMatchValidator = UrlMatchValidator;
}
});
// node_modules/autolinker/dist/commonjs/matcher/url-matcher.js
var require_url_matcher = __commonJS({
"node_modules/autolinker/dist/commonjs/matcher/url-matcher.js"(exports2) {
"use strict";
Object.defineProperty(exports2, "__esModule", { value: true });
exports2.UrlMatcher = void 0;
var tslib_1 = require_tslib();
var matcher_1 = require_matcher();
var regex_lib_1 = require_regex_lib();
var tld_regex_1 = require_tld_regex();
var url_match_1 = require_url_match();
var url_match_validator_1 = require_url_match_validator();
var matcherRegex = function() {
var schemeRegex = /(?:[A-Za-z][-.+A-Za-z0-9]{0,63}:(?![A-Za-z][-.+A-Za-z0-9]{0,63}:\/\/)(?!\d+\/?)(?:\/\/)?)/, wwwRegex = /(?:www\.)/, urlSuffixRegex = new RegExp("[/?#](?:[" + regex_lib_1.alphaNumericAndMarksCharsStr + "\\-+&@#/%=~_()|'$*\\[\\]{}?!:,.;^\u2713]*[" + regex_lib_1.alphaNumericAndMarksCharsStr + "\\-+&@#/%=~_()|'$*\\[\\]{}\u2713])?");
return new RegExp([
"(?:",
"(",
schemeRegex.source,
(0, regex_lib_1.getDomainNameStr)(2),
")",
"|",
"(",
"(//)?",
wwwRegex.source,
(0, regex_lib_1.getDomainNameStr)(6),
")",
"|",
"(",
"(//)?",
(0, regex_lib_1.getDomainNameStr)(10) + "\\.",
tld_regex_1.tldRegex.source,
"(?![-" + regex_lib_1.alphaNumericCharsStr + "])",
")",
")",
"(?::[0-9]+)?",
"(?:" + urlSuffixRegex.source + ")?"
].join(""), "gi");
}();
var wordCharRegExp = new RegExp("[" + regex_lib_1.alphaNumericAndMarksCharsStr + "]");
var UrlMatcher = function(_super) {
(0, tslib_1.__extends)(UrlMatcher2, _super);
function UrlMatcher2(cfg) {
var _this = _super.call(this, cfg) || this;
_this.stripPrefix = { scheme: true, www: true };
_this.stripTrailingSlash = true;
_this.decodePercentEncoding = true;
_this.matcherRegex = matcherRegex;
_this.wordCharRegExp = wordCharRegExp;
_this.stripPrefix = cfg.stripPrefix;
_this.stripTrailingSlash = cfg.stripTrailingSlash;
_this.decodePercentEncoding = cfg.decodePercentEncoding;
return _this;
}
UrlMatcher2.prototype.parseMatches = function(text) {
var matcherRegex2 = this.matcherRegex, stripPrefix = this.stripPrefix, stripTrailingSlash = this.stripTrailingSlash, decodePercentEncoding = this.decodePercentEncoding, tagBuilder = this.tagBuilder, matches = [], match;
var _loop_1 = function() {
var matchStr = match[0], schemeUrlMatch = match[1], wwwUrlMatch = match[4], wwwProtocolRelativeMatch = match[5], tldProtocolRelativeMatch = match[9], offset2 = match.index, protocolRelativeMatch = wwwProtocolRelativeMatch || tldProtocolRelativeMatch, prevChar = text.charAt(offset2 - 1);
if (!url_match_validator_1.UrlMatchValidator.isValid(matchStr, schemeUrlMatch)) {
return "continue";
}
if (offset2 > 0 && prevChar === "@") {
return "continue";
}
if (offset2 > 0 && protocolRelativeMatch && this_1.wordCharRegExp.test(prevChar)) {
return "continue";
}
if (/\?$/.test(matchStr)) {
matchStr = matchStr.substr(0, matchStr.length - 1);
}
if (this_1.matchHasUnbalancedClosingParen(matchStr)) {
matchStr = matchStr.substr(0, matchStr.length - 1);
} else {
var pos = this_1.matchHasInvalidCharAfterTld(matchStr, schemeUrlMatch);
if (pos > -1) {
matchStr = matchStr.substr(0, pos);
}
}
var foundCommonScheme = ["http://", "https://"].find(function(commonScheme) {
return !!schemeUrlMatch && schemeUrlMatch.indexOf(commonScheme) !== -1;
});
if (foundCommonScheme) {
var indexOfSchemeStart = matchStr.indexOf(foundCommonScheme);
matchStr = matchStr.substr(indexOfSchemeStart);
schemeUrlMatch = schemeUrlMatch.substr(indexOfSchemeStart);
offset2 = offset2 + indexOfSchemeStart;
}
var urlMatchType = schemeUrlMatch ? "scheme" : wwwUrlMatch ? "www" : "tld", protocolUrlMatch = !!schemeUrlMatch;
matches.push(new url_match_1.UrlMatch({
tagBuilder,
matchedText: matchStr,
offset: offset2,
urlMatchType,
url: matchStr,
protocolUrlMatch,
protocolRelativeMatch: !!protocolRelativeMatch,
stripPrefix,
stripTrailingSlash,
decodePercentEncoding
}));
};
var this_1 = this;
while ((match = matcherRegex2.exec(text)) !== null) {
_loop_1();
}
return matches;
};
UrlMatcher2.prototype.matchHasUnbalancedClosingParen = function(matchStr) {
var endChar = matchStr.charAt(matchStr.length - 1);
var startChar;
if (endChar === ")") {
startChar = "(";
} else if (endChar === "]") {
startChar = "[";
} else if (endChar === "}") {
startChar = "{";
} else {
return false;
}
var numOpenBraces = 0;
for (var i = 0, len = matchStr.length - 1; i < len; i++) {
var char = matchStr.charAt(i);
if (char === startChar) {
numOpenBraces++;
} else if (char === endChar) {
numOpenBraces = Math.max(numOpenBraces - 1, 0);
}
}
if (numOpenBraces === 0) {
return true;
}
return false;
};
UrlMatcher2.prototype.matchHasInvalidCharAfterTld = function(urlMatch, schemeUrlMatch) {
if (!urlMatch) {
return -1;
}
var offset2 = 0;
if (schemeUrlMatch) {
offset2 = urlMatch.indexOf(":");
urlMatch = urlMatch.slice(offset2);
}
var re = new RegExp("^((.?//)?[-." + regex_lib_1.alphaNumericAndMarksCharsStr + "]*[-" + regex_lib_1.alphaNumericAndMarksCharsStr + "]\\.[-" + regex_lib_1.alphaNumericAndMarksCharsStr + "]+)");
var res = re.exec(urlMatch);
if (res === null) {
return -1;
}
offset2 += res[1].length;
urlMatch = urlMatch.slice(res[1].length);
if (/^[^-.A-Za-z0-9:\/?#]/.test(urlMatch)) {
return offset2;
}
return -1;
};
return UrlMatcher2;
}(matcher_1.Matcher);
exports2.UrlMatcher = UrlMatcher;
}
});
// node_modules/autolinker/dist/commonjs/matcher/hashtag-matcher.js
var require_hashtag_matcher = __commonJS({
"node_modules/autolinker/dist/commonjs/matcher/hashtag-matcher.js"(exports2) {
"use strict";
Object.defineProperty(exports2, "__esModule", { value: true });
exports2.HashtagMatcher = void 0;
var tslib_1 = require_tslib();
var matcher_1 = require_matcher();
var regex_lib_1 = require_regex_lib();
var hashtag_match_1 = require_hashtag_match();
var matcherRegex = new RegExp("#[_".concat(regex_lib_1.alphaNumericAndMarksCharsStr, "]{1,139}(?![_").concat(regex_lib_1.alphaNumericAndMarksCharsStr, "])"), "g");
var nonWordCharRegex = new RegExp("[^" + regex_lib_1.alphaNumericAndMarksCharsStr + "]");
var HashtagMatcher = function(_super) {
(0, tslib_1.__extends)(HashtagMatcher2, _super);
function HashtagMatcher2(cfg) {
var _this = _super.call(this, cfg) || this;
_this.serviceName = "twitter";
_this.matcherRegex = matcherRegex;
_this.nonWordCharRegex = nonWordCharRegex;
_this.serviceName = cfg.serviceName;
return _this;
}
HashtagMatcher2.prototype.parseMatches = function(text) {
var matcherRegex2 = this.matcherRegex, nonWordCharRegex2 = this.nonWordCharRegex, serviceName = this.serviceName, tagBuilder = this.tagBuilder, matches = [], match;
while ((match = matcherRegex2.exec(text)) !== null) {
var offset2 = match.index, prevChar = text.charAt(offset2 - 1);
if (offset2 === 0 || nonWordCharRegex2.test(prevChar)) {
var matchedText = match[0], hashtag = match[0].slice(1);
matches.push(new hashtag_match_1.HashtagMatch({
tagBuilder,
matchedText,
offset: offset2,
serviceName,
hashtag
}));
}
}
return matches;
};
return HashtagMatcher2;
}(matcher_1.Matcher);
exports2.HashtagMatcher = HashtagMatcher;
}
});
// node_modules/autolinker/dist/commonjs/matcher/phone-matcher.js
var require_phone_matcher = __commonJS({
"node_modules/autolinker/dist/commonjs/matcher/phone-matcher.js"(exports2) {
"use strict";
Object.defineProperty(exports2, "__esModule", { value: true });
exports2.PhoneMatcher = void 0;
var tslib_1 = require_tslib();
var matcher_1 = require_matcher();
var phone_match_1 = require_phone_match();
var regex_lib_1 = require_regex_lib();
var mostPhoneNumbers = /(?:(?:(?:(\+)?\d{1,3}[-\040.]?)?\(?\d{3}\)?[-\040.]?\d{3}[-\040.]?\d{4})|(?:(\+)(?:9[976]\d|8[987530]\d|6[987]\d|5[90]\d|42\d|3[875]\d|2[98654321]\d|9[8543210]|8[6421]|6[6543210]|5[87654321]|4[987654310]|3[9643210]|2[70]|7|1)[-\040.]?(?:\d[-\040.]?){6,12}\d+))([,;]+[0-9]+#?)*/;
var japanesePhoneRe = /(0([1-9]{1}-?[1-9]\d{3}|[1-9]{2}-?\d{3}|[1-9]{2}\d{1}-?\d{2}|[1-9]{2}\d{2}-?\d{1})-?\d{4}|0[789]0-?\d{4}-?\d{4}|050-?\d{4}-?\d{4})/;
var phoneMatcherRegex = new RegExp("".concat(mostPhoneNumbers.source, "|").concat(japanesePhoneRe.source), "g");
var PhoneMatcher = function(_super) {
(0, tslib_1.__extends)(PhoneMatcher2, _super);
function PhoneMatcher2() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.matcherRegex = phoneMatcherRegex;
return _this;
}
PhoneMatcher2.prototype.parseMatches = function(text) {
var matcherRegex = this.matcherRegex, tagBuilder = this.tagBuilder, matches = [], match;
while ((match = matcherRegex.exec(text)) !== null) {
var matchedText = match[0], cleanNumber = matchedText.replace(/[^0-9,;#]/g, ""), plusSign = !!(match[1] || match[2]), before = match.index == 0 ? "" : text.substr(match.index - 1, 1), after = text.substr(match.index + matchedText.length, 1), contextClear = !before.match(/\d/) && !after.match(/\d/);
if (this.testMatch(match[3]) && this.testMatch(matchedText) && contextClear) {
matches.push(new phone_match_1.PhoneMatch({
tagBuilder,
matchedText,
offset: match.index,
number: cleanNumber,
plusSign
}));
}
}
return matches;
};
PhoneMatcher2.prototype.testMatch = function(text) {
return regex_lib_1.nonDigitRe.test(text);
};
return PhoneMatcher2;
}(matcher_1.Matcher);
exports2.PhoneMatcher = PhoneMatcher;
}
});
// node_modules/autolinker/dist/commonjs/matcher/mention-matcher.js
var require_mention_matcher = __commonJS({
"node_modules/autolinker/dist/commonjs/matcher/mention-matcher.js"(exports2) {
"use strict";
Object.defineProperty(exports2, "__esModule", { value: true });
exports2.MentionMatcher = void 0;
var tslib_1 = require_tslib();
var matcher_1 = require_matcher();
var regex_lib_1 = require_regex_lib();
var mention_match_1 = require_mention_match();
var twitterRegex = new RegExp("@[_".concat(regex_lib_1.alphaNumericAndMarksCharsStr, "]{1,50}(?![_").concat(regex_lib_1.alphaNumericAndMarksCharsStr, "])"), "g");
var instagramRegex = new RegExp("@[_.".concat(regex_lib_1.alphaNumericAndMarksCharsStr, "]{1,30}(?![_").concat(regex_lib_1.alphaNumericAndMarksCharsStr, "])"), "g");
var soundcloudRegex = new RegExp("@[-_.".concat(regex_lib_1.alphaNumericAndMarksCharsStr, "]{1,50}(?![-_").concat(regex_lib_1.alphaNumericAndMarksCharsStr, "])"), "g");
var tiktokRegex = new RegExp("@[_.".concat(regex_lib_1.alphaNumericAndMarksCharsStr, "]{1,23}[_").concat(regex_lib_1.alphaNumericAndMarksCharsStr, "](?![_").concat(regex_lib_1.alphaNumericAndMarksCharsStr, "])"), "g");
var nonWordCharRegex = new RegExp("[^" + regex_lib_1.alphaNumericAndMarksCharsStr + "]");
var MentionMatcher = function(_super) {
(0, tslib_1.__extends)(MentionMatcher2, _super);
function MentionMatcher2(cfg) {
var _this = _super.call(this, cfg) || this;
_this.serviceName = "twitter";
_this.matcherRegexes = {
"twitter": twitterRegex,
"instagram": instagramRegex,
"soundcloud": soundcloudRegex,
"tiktok": tiktokRegex
};
_this.nonWordCharRegex = nonWordCharRegex;
_this.serviceName = cfg.serviceName;
return _this;
}
MentionMatcher2.prototype.parseMatches = function(text) {
var serviceName = this.serviceName, matcherRegex = this.matcherRegexes[this.serviceName], nonWordCharRegex2 = this.nonWordCharRegex, tagBuilder = this.tagBuilder, matches = [], match;
if (!matcherRegex) {
return matches;
}
while ((match = matcherRegex.exec(text)) !== null) {
var offset2 = match.index, prevChar = text.charAt(offset2 - 1);
if (offset2 === 0 || nonWordCharRegex2.test(prevChar)) {
var matchedText = match[0].replace(/\.+$/g, ""), mention = matchedText.slice(1);
matches.push(new mention_match_1.MentionMatch({
tagBuilder,
matchedText,
offset: offset2,
serviceName,
mention
}));
}
}
return matches;
};
return MentionMatcher2;
}(matcher_1.Matcher);
exports2.MentionMatcher = MentionMatcher;
}
});
// node_modules/autolinker/dist/commonjs/htmlParser/parse-html.js
var require_parse_html = __commonJS({
"node_modules/autolinker/dist/commonjs/htmlParser/parse-html.js"(exports2) {
"use strict";
Object.defineProperty(exports2, "__esModule", { value: true });
exports2.parseHtml = void 0;
var tslib_1 = require_tslib();
var regex_lib_1 = require_regex_lib();
var utils_1 = require_utils();
function parseHtml(html, _a) {
var onOpenTag = _a.onOpenTag, onCloseTag = _a.onCloseTag, onText = _a.onText, onComment = _a.onComment, onDoctype = _a.onDoctype;
var noCurrentTag = new CurrentTag();
var charIdx = 0, len = html.length, state = 0, currentDataIdx = 0, currentTag = noCurrentTag;
while (charIdx < len) {
var char = html.charAt(charIdx);
switch (state) {
case 0:
stateData(char);
break;
case 1:
stateTagOpen(char);
break;
case 2:
stateEndTagOpen(char);
break;
case 3:
stateTagName(char);
break;
case 4:
stateBeforeAttributeName(char);
break;
case 5:
stateAttributeName(char);
break;
case 6:
stateAfterAttributeName(char);
break;
case 7:
stateBeforeAttributeValue(char);
break;
case 8:
stateAttributeValueDoubleQuoted(char);
break;
case 9:
stateAttributeValueSingleQuoted(char);
break;
case 10:
stateAttributeValueUnquoted(char);
break;
case 11:
stateAfterAttributeValueQuoted(char);
break;
case 12:
stateSelfClosingStartTag(char);
break;
case 13:
stateMarkupDeclarationOpen(char);
break;
case 14:
stateCommentStart(char);
break;
case 15:
stateCommentStartDash(char);
break;
case 16:
stateComment(char);
break;
case 17:
stateCommentEndDash(char);
break;
case 18:
stateCommentEnd(char);
break;
case 19:
stateCommentEndBang(char);
break;
case 20:
stateDoctype(char);
break;
default:
(0, utils_1.throwUnhandledCaseError)(state);
}
charIdx++;
}
if (currentDataIdx < charIdx) {
emitText();
}
function stateData(char2) {
if (char2 === "<") {
startNewTag();
}
}
function stateTagOpen(char2) {
if (char2 === "!") {
state = 13;
} else if (char2 === "/") {
state = 2;
currentTag = new CurrentTag((0, tslib_1.__assign)((0, tslib_1.__assign)({}, currentTag), { isClosing: true }));
} else if (char2 === "<") {
startNewTag();
} else if (regex_lib_1.letterRe.test(char2)) {
state = 3;
currentTag = new CurrentTag((0, tslib_1.__assign)((0, tslib_1.__assign)({}, currentTag), { isOpening: true }));
} else {
state = 0;
currentTag = noCurrentTag;
}
}
function stateTagName(char2) {
if (regex_lib_1.whitespaceRe.test(char2)) {
currentTag = new CurrentTag((0, tslib_1.__assign)((0, tslib_1.__assign)({}, currentTag), { name: captureTagName() }));
state = 4;
} else if (char2 === "<") {
startNewTag();
} else if (char2 === "/") {
currentTag = new CurrentTag((0, tslib_1.__assign)((0, tslib_1.__assign)({}, currentTag), { name: captureTagName() }));
state = 12;
} else if (char2 === ">") {
currentTag = new CurrentTag((0, tslib_1.__assign)((0, tslib_1.__assign)({}, currentTag), { name: captureTagName() }));
emitTagAndPreviousTextNode();
} else if (!regex_lib_1.letterRe.test(char2) && !regex_lib_1.digitRe.test(char2) && char2 !== ":") {
resetToDataState();
} else {
}
}
function stateEndTagOpen(char2) {
if (char2 === ">") {
resetToDataState();
} else if (regex_lib_1.letterRe.test(char2)) {
state = 3;
} else {
resetToDataState();
}
}
function stateBeforeAttributeName(char2) {
if (regex_lib_1.whitespaceRe.test(char2)) {
} else if (char2 === "/") {
state = 12;
} else if (char2 === ">") {
emitTagAndPreviousTextNode();
} else if (char2 === "<") {
startNewTag();
} else if (char2 === "=" || regex_lib_1.quoteRe.test(char2) || regex_lib_1.controlCharsRe.test(char2)) {
resetToDataState();
} else {
state = 5;
}
}
function stateAttributeName(char2) {
if (regex_lib_1.whitespaceRe.test(char2)) {
state = 6;
} else if (char2 === "/") {
state = 12;
} else if (char2 === "=") {
state = 7;
} else if (char2 === ">") {
emitTagAndPreviousTextNode();
} else if (char2 === "<") {
startNewTag();
} else if (regex_lib_1.quoteRe.test(char2)) {
resetToDataState();
} else {
}
}
function stateAfterAttributeName(char2) {
if (regex_lib_1.whitespaceRe.test(char2)) {
} else if (char2 === "/") {
state = 12;
} else if (char2 === "=") {
state = 7;
} else if (char2 === ">") {
emitTagAndPreviousTextNode();
} else if (char2 === "<") {
startNewTag();
} else if (regex_lib_1.quoteRe.test(char2)) {
resetToDataState();
} else {
state = 5;
}
}
function stateBeforeAttributeValue(char2) {
if (regex_lib_1.whitespaceRe.test(char2)) {
} else if (char2 === '"') {
state = 8;
} else if (char2 === "'") {
state = 9;
} else if (/[>=`]/.test(char2)) {
resetToDataState();
} else if (char2 === "<") {
startNewTag();
} else {
state = 10;
}
}
function stateAttributeValueDoubleQuoted(char2) {
if (char2 === '"') {
state = 11;
} else {
}
}
function stateAttributeValueSingleQuoted(char2) {
if (char2 === "'") {
state = 11;
} else {
}
}
function stateAttributeValueUnquoted(char2) {
if (regex_lib_1.whitespaceRe.test(char2)) {
state = 4;
} else if (char2 === ">") {
emitTagAndPreviousTextNode();
} else if (char2 === "<") {
startNewTag();
} else {
}
}
function stateAfterAttributeValueQuoted(char2) {
if (regex_lib_1.whitespaceRe.test(char2)) {
state = 4;
} else if (char2 === "/") {
state = 12;
} else if (char2 === ">") {
emitTagAndPreviousTextNode();
} else if (char2 === "<") {
startNewTag();
} else {
state = 4;
reconsumeCurrentCharacter();
}
}
function stateSelfClosingStartTag(char2) {
if (char2 === ">") {
currentTag = new CurrentTag((0, tslib_1.__assign)((0, tslib_1.__assign)({}, currentTag), { isClosing: true }));
emitTagAndPreviousTextNode();
} else {
state = 4;
}
}
function stateMarkupDeclarationOpen(char2) {
if (html.substr(charIdx, 2) === "--") {
charIdx += 2;
currentTag = new CurrentTag((0, tslib_1.__assign)((0, tslib_1.__assign)({}, currentTag), { type: "comment" }));
state = 14;
} else if (html.substr(charIdx, 7).toUpperCase() === "DOCTYPE") {
charIdx += 7;
currentTag = new CurrentTag((0, tslib_1.__assign)((0, tslib_1.__assign)({}, currentTag), { type: "doctype" }));
state = 20;
} else {
resetToDataState();
}
}
function stateCommentStart(char2) {
if (char2 === "-") {
state = 15;
} else if (char2 === ">") {
resetToDataState();
} else {
state = 16;
}
}
function stateCommentStartDash(char2) {
if (char2 === "-") {
state = 18;
} else if (char2 === ">") {
resetToDataState();
} else {
state = 16;
}
}
function stateComment(char2) {
if (char2 === "-") {
state = 17;
} else {
}
}
function stateCommentEndDash(char2) {
if (char2 === "-") {
state = 18;
} else {
state = 16;
}
}
function stateCommentEnd(char2) {
if (char2 === ">") {
emitTagAndPreviousTextNode();
} else if (char2 === "!") {
state = 19;
} else if (char2 === "-") {
} else {
state = 16;
}
}
function stateCommentEndBang(char2) {
if (char2 === "-") {
state = 17;
} else if (char2 === ">") {
emitTagAndPreviousTextNode();
} else {
state = 16;
}
}
function stateDoctype(char2) {
if (char2 === ">") {
emitTagAndPreviousTextNode();
} else if (char2 === "<") {
startNewTag();
} else {
}
}
function resetToDataState() {
state = 0;
currentTag = noCurrentTag;
}
function startNewTag() {
state = 1;
currentTag = new CurrentTag({ idx: charIdx });
}
function emitTagAndPreviousTextNode() {
var textBeforeTag = html.slice(currentDataIdx, currentTag.idx);
if (textBeforeTag) {
onText(textBeforeTag, currentDataIdx);
}
if (currentTag.type === "comment") {
onComment(currentTag.idx);
} else if (currentTag.type === "doctype") {
onDoctype(currentTag.idx);
} else {
if (currentTag.isOpening) {
onOpenTag(currentTag.name, currentTag.idx);
}
if (currentTag.isClosing) {
onCloseTag(currentTag.name, currentTag.idx);
}
}
resetToDataState();
currentDataIdx = charIdx + 1;
}
function emitText() {
var text = html.slice(currentDataIdx, charIdx);
onText(text, currentDataIdx);
currentDataIdx = charIdx + 1;
}
function captureTagName() {
var startIdx = currentTag.idx + (currentTag.isClosing ? 2 : 1);
return html.slice(startIdx, charIdx).toLowerCase();
}
function reconsumeCurrentCharacter() {
charIdx--;
}
}
exports2.parseHtml = parseHtml;
var CurrentTag = function() {
function CurrentTag2(cfg) {
if (cfg === void 0) {
cfg = {};
}
this.idx = cfg.idx !== void 0 ? cfg.idx : -1;
this.type = cfg.type || "tag";
this.name = cfg.name || "";
this.isOpening = !!cfg.isOpening;
this.isClosing = !!cfg.isClosing;
}
return CurrentTag2;
}();
}
});
// node_modules/autolinker/dist/commonjs/autolinker.js
var require_autolinker = __commonJS({
"node_modules/autolinker/dist/commonjs/autolinker.js"(exports2) {
"use strict";
Object.defineProperty(exports2, "__esModule", { value: true });
var utils_1 = require_utils();
var anchor_tag_builder_1 = require_anchor_tag_builder();
var match_1 = require_match();
var email_match_1 = require_email_match();
var hashtag_match_1 = require_hashtag_match();
var mention_match_1 = require_mention_match();
var phone_match_1 = require_phone_match();
var url_match_1 = require_url_match();
var matcher_1 = require_matcher();
var html_tag_1 = require_html_tag();
var email_matcher_1 = require_email_matcher();
var url_matcher_1 = require_url_matcher();
var hashtag_matcher_1 = require_hashtag_matcher();
var phone_matcher_1 = require_phone_matcher();
var mention_matcher_1 = require_mention_matcher();
var parse_html_1 = require_parse_html();
var Autolinker = function() {
function Autolinker2(cfg) {
if (cfg === void 0) {
cfg = {};
}
this.version = Autolinker2.version;
this.urls = {};
this.email = true;
this.phone = true;
this.hashtag = false;
this.mention = false;
this.newWindow = true;
this.stripPrefix = { scheme: true, www: true };
this.stripTrailingSlash = true;
this.decodePercentEncoding = true;
this.truncate = { length: 0, location: "end" };
this.className = "";
this.replaceFn = null;
this.context = void 0;
this.sanitizeHtml = false;
this.matchers = null;
this.tagBuilder = null;
this.urls = this.normalizeUrlsCfg(cfg.urls);
this.email = typeof cfg.email === "boolean" ? cfg.email : this.email;
this.phone = typeof cfg.phone === "boolean" ? cfg.phone : this.phone;
this.hashtag = cfg.hashtag || this.hashtag;
this.mention = cfg.mention || this.mention;
this.newWindow = typeof cfg.newWindow === "boolean" ? cfg.newWindow : this.newWindow;
this.stripPrefix = this.normalizeStripPrefixCfg(cfg.stripPrefix);
this.stripTrailingSlash = typeof cfg.stripTrailingSlash === "boolean" ? cfg.stripTrailingSlash : this.stripTrailingSlash;
this.decodePercentEncoding = typeof cfg.decodePercentEncoding === "boolean" ? cfg.decodePercentEncoding : this.decodePercentEncoding;
this.sanitizeHtml = cfg.sanitizeHtml || false;
var mention = this.mention;
if (mention !== false && ["twitter", "instagram", "soundcloud", "tiktok"].indexOf(mention) === -1) {
throw new Error("invalid `mention` cfg '".concat(mention, "' - see docs"));
}
var hashtag = this.hashtag;
if (hashtag !== false && ["twitter", "facebook", "instagram", "tiktok"].indexOf(hashtag) === -1) {
throw new Error("invalid `hashtag` cfg '".concat(hashtag, "' - see docs"));
}
this.truncate = this.normalizeTruncateCfg(cfg.truncate);
this.className = cfg.className || this.className;
this.replaceFn = cfg.replaceFn || this.replaceFn;
this.context = cfg.context || this;
}
Autolinker2.link = function(textOrHtml, options) {
var autolinker3 = new Autolinker2(options);
return autolinker3.link(textOrHtml);
};
Autolinker2.parse = function(textOrHtml, options) {
var autolinker3 = new Autolinker2(options);
return autolinker3.parse(textOrHtml);
};
Autolinker2.prototype.normalizeUrlsCfg = function(urls) {
if (urls == null)
urls = true;
if (typeof urls === "boolean") {
return { schemeMatches: urls, wwwMatches: urls, tldMatches: urls };
} else {
return {
schemeMatches: typeof urls.schemeMatches === "boolean" ? urls.schemeMatches : true,
wwwMatches: typeof urls.wwwMatches === "boolean" ? urls.wwwMatches : true,
tldMatches: typeof urls.tldMatches === "boolean" ? urls.tldMatches : true
};
}
};
Autolinker2.prototype.normalizeStripPrefixCfg = function(stripPrefix) {
if (stripPrefix == null)
stripPrefix = true;
if (typeof stripPrefix === "boolean") {
return { scheme: stripPrefix, www: stripPrefix };
} else {
return {
scheme: typeof stripPrefix.scheme === "boolean" ? stripPrefix.scheme : true,
www: typeof stripPrefix.www === "boolean" ? stripPrefix.www : true
};
}
};
Autolinker2.prototype.normalizeTruncateCfg = function(truncate) {
if (typeof truncate === "number") {
return { length: truncate, location: "end" };
} else {
return (0, utils_1.defaults)(truncate || {}, {
length: Number.POSITIVE_INFINITY,
location: "end"
});
}
};
Autolinker2.prototype.parse = function(textOrHtml) {
var _this = this;
var skipTagNames = ["a", "style", "script"], skipTagsStackCount = 0, matches = [];
(0, parse_html_1.parseHtml)(textOrHtml, {
onOpenTag: function(tagName) {
if (skipTagNames.indexOf(tagName) >= 0) {
skipTagsStackCount++;
}
},
onText: function(text, offset2) {
if (skipTagsStackCount === 0) {
var htmlCharacterEntitiesRegex = /( | |<|<|>|>|"|"|')/gi;
var textSplit = (0, utils_1.splitAndCapture)(text, htmlCharacterEntitiesRegex);
var currentOffset_1 = offset2;
textSplit.forEach(function(splitText, i) {
if (i % 2 === 0) {
var textNodeMatches = _this.parseText(splitText, currentOffset_1);
matches.push.apply(matches, textNodeMatches);
}
currentOffset_1 += splitText.length;
});
}
},
onCloseTag: function(tagName) {
if (skipTagNames.indexOf(tagName) >= 0) {
skipTagsStackCount = Math.max(skipTagsStackCount - 1, 0);
}
},
onComment: function(offset2) {
},
onDoctype: function(offset2) {
}
});
matches = this.compactMatches(matches);
matches = this.removeUnwantedMatches(matches);
return matches;
};
Autolinker2.prototype.compactMatches = function(matches) {
matches.sort(function(a3, b) {
return a3.getOffset() - b.getOffset();
});
var i = 0;
while (i < matches.length - 1) {
var match = matches[i], offset2 = match.getOffset(), matchedTextLength = match.getMatchedText().length, endIdx = offset2 + matchedTextLength;
if (i + 1 < matches.length) {
if (matches[i + 1].getOffset() === offset2) {
var removeIdx = matches[i + 1].getMatchedText().length > matchedTextLength ? i : i + 1;
matches.splice(removeIdx, 1);
continue;
}
if (matches[i + 1].getOffset() < endIdx) {
matches.splice(i + 1, 1);
continue;
}
}
i++;
}
return matches;
};
Autolinker2.prototype.removeUnwantedMatches = function(matches) {
if (!this.hashtag)
(0, utils_1.remove)(matches, function(match) {
return match.getType() === "hashtag";
});
if (!this.email)
(0, utils_1.remove)(matches, function(match) {
return match.getType() === "email";
});
if (!this.phone)
(0, utils_1.remove)(matches, function(match) {
return match.getType() === "phone";
});
if (!this.mention)
(0, utils_1.remove)(matches, function(match) {
return match.getType() === "mention";
});
if (!this.urls.schemeMatches) {
(0, utils_1.remove)(matches, function(m) {
return m.getType() === "url" && m.getUrlMatchType() === "scheme";
});
}
if (!this.urls.wwwMatches) {
(0, utils_1.remove)(matches, function(m) {
return m.getType() === "url" && m.getUrlMatchType() === "www";
});
}
if (!this.urls.tldMatches) {
(0, utils_1.remove)(matches, function(m) {
return m.getType() === "url" && m.getUrlMatchType() === "tld";
});
}
return matches;
};
Autolinker2.prototype.parseText = function(text, offset2) {
if (offset2 === void 0) {
offset2 = 0;
}
offset2 = offset2 || 0;
var matchers = this.getMatchers(), matches = [];
for (var i = 0, numMatchers = matchers.length; i < numMatchers; i++) {
var textMatches = matchers[i].parseMatches(text);
for (var j = 0, numTextMatches = textMatches.length; j < numTextMatches; j++) {
textMatches[j].setOffset(offset2 + textMatches[j].getOffset());
}
matches.push.apply(matches, textMatches);
}
return matches;
};
Autolinker2.prototype.link = function(textOrHtml) {
if (!textOrHtml) {
return "";
}
if (this.sanitizeHtml) {
textOrHtml = textOrHtml.replace(//g, ">");
}
var matches = this.parse(textOrHtml), newHtml = [], lastIndex = 0;
for (var i = 0, len = matches.length; i < len; i++) {
var match = matches[i];
newHtml.push(textOrHtml.substring(lastIndex, match.getOffset()));
newHtml.push(this.createMatchReturnVal(match));
lastIndex = match.getOffset() + match.getMatchedText().length;
}
newHtml.push(textOrHtml.substring(lastIndex));
return newHtml.join("");
};
Autolinker2.prototype.createMatchReturnVal = function(match) {
var replaceFnResult;
if (this.replaceFn) {
replaceFnResult = this.replaceFn.call(this.context, match);
}
if (typeof replaceFnResult === "string") {
return replaceFnResult;
} else if (replaceFnResult === false) {
return match.getMatchedText();
} else if (replaceFnResult instanceof html_tag_1.HtmlTag) {
return replaceFnResult.toAnchorString();
} else {
var anchorTag = match.buildTag();
return anchorTag.toAnchorString();
}
};
Autolinker2.prototype.getMatchers = function() {
if (!this.matchers) {
var tagBuilder = this.getTagBuilder();
var matchers = [
new hashtag_matcher_1.HashtagMatcher({ tagBuilder, serviceName: this.hashtag }),
new email_matcher_1.EmailMatcher({ tagBuilder }),
new phone_matcher_1.PhoneMatcher({ tagBuilder }),
new mention_matcher_1.MentionMatcher({ tagBuilder, serviceName: this.mention }),
new url_matcher_1.UrlMatcher({ tagBuilder, stripPrefix: this.stripPrefix, stripTrailingSlash: this.stripTrailingSlash, decodePercentEncoding: this.decodePercentEncoding })
];
return this.matchers = matchers;
} else {
return this.matchers;
}
};
Autolinker2.prototype.getTagBuilder = function() {
var tagBuilder = this.tagBuilder;
if (!tagBuilder) {
tagBuilder = this.tagBuilder = new anchor_tag_builder_1.AnchorTagBuilder({
newWindow: this.newWindow,
truncate: this.truncate,
className: this.className
});
}
return tagBuilder;
};
Autolinker2.version = "3.15.0";
Autolinker2.AnchorTagBuilder = anchor_tag_builder_1.AnchorTagBuilder;
Autolinker2.HtmlTag = html_tag_1.HtmlTag;
Autolinker2.matcher = {
Email: email_matcher_1.EmailMatcher,
Hashtag: hashtag_matcher_1.HashtagMatcher,
Matcher: matcher_1.Matcher,
Mention: mention_matcher_1.MentionMatcher,
Phone: phone_matcher_1.PhoneMatcher,
Url: url_matcher_1.UrlMatcher
};
Autolinker2.match = {
Email: email_match_1.EmailMatch,
Hashtag: hashtag_match_1.HashtagMatch,
Match: match_1.Match,
Mention: mention_match_1.MentionMatch,
Phone: phone_match_1.PhoneMatch,
Url: url_match_1.UrlMatch
};
return Autolinker2;
}();
exports2.default = Autolinker;
}
});
// node_modules/autolinker/dist/commonjs/match/index.js
var require_match2 = __commonJS({
"node_modules/autolinker/dist/commonjs/match/index.js"(exports2) {
"use strict";
Object.defineProperty(exports2, "__esModule", { value: true });
var tslib_1 = require_tslib();
(0, tslib_1.__exportStar)(require_email_match(), exports2);
(0, tslib_1.__exportStar)(require_hashtag_match(), exports2);
(0, tslib_1.__exportStar)(require_match(), exports2);
(0, tslib_1.__exportStar)(require_mention_match(), exports2);
(0, tslib_1.__exportStar)(require_phone_match(), exports2);
(0, tslib_1.__exportStar)(require_url_match(), exports2);
}
});
// node_modules/autolinker/dist/commonjs/matcher/index.js
var require_matcher2 = __commonJS({
"node_modules/autolinker/dist/commonjs/matcher/index.js"(exports2) {
"use strict";
Object.defineProperty(exports2, "__esModule", { value: true });
var tslib_1 = require_tslib();
(0, tslib_1.__exportStar)(require_email_matcher(), exports2);
(0, tslib_1.__exportStar)(require_hashtag_matcher(), exports2);
(0, tslib_1.__exportStar)(require_matcher(), exports2);
(0, tslib_1.__exportStar)(require_mention_matcher(), exports2);
(0, tslib_1.__exportStar)(require_phone_matcher(), exports2);
(0, tslib_1.__exportStar)(require_url_matcher(), exports2);
}
});
// node_modules/autolinker/dist/commonjs/index.js
var require_commonjs = __commonJS({
"node_modules/autolinker/dist/commonjs/index.js"(exports2, module2) {
"use strict";
exports2 = module2.exports = require_autolinker().default;
Object.defineProperty(exports2, "__esModule", { value: true });
exports2.Autolinker = void 0;
var tslib_1 = require_tslib();
var autolinker_1 = (0, tslib_1.__importDefault)(require_autolinker());
exports2.Autolinker = autolinker_1.default;
exports2.default = autolinker_1.default;
(0, tslib_1.__exportStar)(require_autolinker(), exports2);
(0, tslib_1.__exportStar)(require_anchor_tag_builder(), exports2);
(0, tslib_1.__exportStar)(require_html_tag(), exports2);
(0, tslib_1.__exportStar)(require_match2(), exports2);
(0, tslib_1.__exportStar)(require_matcher2(), exports2);
}
});
// node_modules/ktx-parse/dist/ktx-parse.js
var require_ktx_parse = __commonJS({
"node_modules/ktx-parse/dist/ktx-parse.js"(exports2) {
var t;
var e;
var n;
var i;
var r;
var a3;
var s;
var o;
var l = new Uint8Array([0]);
var f = [171, 75, 84, 88, 32, 50, 48, 187, 13, 10, 26, 10];
(t = exports2.KTX2SupercompressionScheme || (exports2.KTX2SupercompressionScheme = {}))[t.NONE = 0] = "NONE", t[t.BASISLZ = 1] = "BASISLZ", t[t.ZSTD = 2] = "ZSTD", t[t.ZLIB = 3] = "ZLIB", (e = exports2.KTX2DescriptorType || (exports2.KTX2DescriptorType = {}))[e.BASICFORMAT = 0] = "BASICFORMAT", (n = exports2.KTX2Model || (exports2.KTX2Model = {}))[n.UNSPECIFIED = 0] = "UNSPECIFIED", n[n.ETC1S = 163] = "ETC1S", n[n.UASTC = 166] = "UASTC", (i = exports2.KTX2Primaries || (exports2.KTX2Primaries = {}))[i.UNSPECIFIED = 0] = "UNSPECIFIED", i[i.SRGB = 1] = "SRGB", (r = exports2.KTX2Transfer || (exports2.KTX2Transfer = {}))[r.UNSPECIFIED = 0] = "UNSPECIFIED", r[r.LINEAR = 1] = "LINEAR", r[r.SRGB = 2] = "SRGB", r[r.ITU = 3] = "ITU", r[r.NTSC = 4] = "NTSC", r[r.SLOG = 5] = "SLOG", r[r.SLOG2 = 6] = "SLOG2", (a3 = exports2.KTX2Flags || (exports2.KTX2Flags = {}))[a3.ALPHA_STRAIGHT = 0] = "ALPHA_STRAIGHT", a3[a3.ALPHA_PREMULTIPLIED = 1] = "ALPHA_PREMULTIPLIED", (s = exports2.KTX2ChannelETC1S || (exports2.KTX2ChannelETC1S = {}))[s.RGB = 0] = "RGB", s[s.RRR = 3] = "RRR", s[s.GGG = 4] = "GGG", s[s.AAA = 15] = "AAA", (o = exports2.KTX2ChannelUASTC || (exports2.KTX2ChannelUASTC = {}))[o.RGB = 0] = "RGB", o[o.RGBA = 3] = "RGBA", o[o.RRR = 4] = "RRR", o[o.RRRG = 5] = "RRRG";
var U = function() {
this.vkFormat = 0, this.typeSize = 1, this.pixelWidth = 0, this.pixelHeight = 0, this.pixelDepth = 0, this.layerCount = 0, this.faceCount = 1, this.supercompressionScheme = exports2.KTX2SupercompressionScheme.NONE, this.levels = [], this.dataFormatDescriptor = [{ vendorId: 0, descriptorType: exports2.KTX2DescriptorType.BASICFORMAT, versionNumber: 2, descriptorBlockSize: 40, colorModel: exports2.KTX2Model.UNSPECIFIED, colorPrimaries: exports2.KTX2Primaries.SRGB, transferFunction: exports2.KTX2Primaries.SRGB, flags: exports2.KTX2Flags.ALPHA_STRAIGHT, texelBlockDimension: { x: 4, y: 4, z: 1, w: 1 }, bytesPlane: [], samples: [] }], this.keyValue = {}, this.globalData = null;
};
var p = function() {
function t2(t3, e3, n2, i2) {
this._dataView = new DataView(t3.buffer, t3.byteOffset + e3, n2), this._littleEndian = i2, this._offset = 0;
}
var e2 = t2.prototype;
return e2._nextUint8 = function() {
var t3 = this._dataView.getUint8(this._offset);
return this._offset += 1, t3;
}, e2._nextUint16 = function() {
var t3 = this._dataView.getUint16(this._offset, this._littleEndian);
return this._offset += 2, t3;
}, e2._nextUint32 = function() {
var t3 = this._dataView.getUint32(this._offset, this._littleEndian);
return this._offset += 4, t3;
}, e2._nextUint64 = function() {
var t3 = this._dataView.getUint32(this._offset, this._littleEndian), e3 = this._dataView.getUint32(this._offset + 4, this._littleEndian), n2 = t3 + Math.pow(2, 32) * e3;
return this._offset += 8, n2;
}, e2._skip = function(t3) {
return this._offset += t3, this;
}, e2._scan = function(t3, e3) {
void 0 === e3 && (e3 = 0);
for (var n2 = this._offset, i2 = 0; this._dataView.getUint8(this._offset) !== e3 && i2 < t3; )
i2++, this._offset++;
return i2 < t3 && this._offset++, new Uint8Array(this._dataView.buffer, this._dataView.byteOffset + n2, i2);
}, t2;
}();
function h() {
return (h = Object.assign || function(t2) {
for (var e2 = 1; e2 < arguments.length; e2++) {
var n2 = arguments[e2];
for (var i2 in n2)
Object.prototype.hasOwnProperty.call(n2, i2) && (t2[i2] = n2[i2]);
}
return t2;
}).apply(this, arguments);
}
function c(t2, e2) {
(null == e2 || e2 > t2.length) && (e2 = t2.length);
for (var n2 = 0, i2 = new Array(e2); n2 < e2; n2++)
i2[n2] = t2[n2];
return i2;
}
function x(t2, e2) {
var n2;
if ("undefined" == typeof Symbol || null == t2[Symbol.iterator]) {
if (Array.isArray(t2) || (n2 = function(t3, e3) {
if (t3) {
if ("string" == typeof t3)
return c(t3, void 0);
var n3 = Object.prototype.toString.call(t3).slice(8, -1);
return "Object" === n3 && t3.constructor && (n3 = t3.constructor.name), "Map" === n3 || "Set" === n3 ? Array.from(t3) : "Arguments" === n3 || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n3) ? c(t3, void 0) : void 0;
}
}(t2)) || e2 && t2 && "number" == typeof t2.length) {
n2 && (t2 = n2);
var i2 = 0;
return function() {
return i2 >= t2.length ? { done: true } : { done: false, value: t2[i2++] };
};
}
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
return (n2 = t2[Symbol.iterator]()).next.bind(n2);
}
function u3(t2) {
return "undefined" != typeof TextEncoder ? new TextEncoder().encode(t2) : Buffer.from(t2);
}
function _(t2) {
return "undefined" != typeof TextDecoder ? new TextDecoder().decode(t2) : Buffer.from(t2).toString("utf8");
}
function g(t2) {
for (var e2, n2 = 0, i2 = x(t2); !(e2 = i2()).done; )
n2 += e2.value.byteLength;
for (var r2, a4 = new Uint8Array(n2), s2 = 0, o2 = x(t2); !(r2 = o2()).done; ) {
var l2 = r2.value;
a4.set(new Uint8Array(l2), s2), s2 += l2.byteLength;
}
return a4;
}
var y = { keepWriter: false };
exports2.KTX2Container = U, exports2.read = function(t2) {
var e2 = new Uint8Array(t2.buffer, t2.byteOffset, f.length);
if (e2[0] !== f[0] || e2[1] !== f[1] || e2[2] !== f[2] || e2[3] !== f[3] || e2[4] !== f[4] || e2[5] !== f[5] || e2[6] !== f[6] || e2[7] !== f[7] || e2[8] !== f[8] || e2[9] !== f[9] || e2[10] !== f[10] || e2[11] !== f[11])
throw new Error("Missing KTX 2.0 identifier.");
var n2 = new U(), i2 = 17 * Uint32Array.BYTES_PER_ELEMENT, r2 = new p(t2, f.length, i2, true);
n2.vkFormat = r2._nextUint32(), n2.typeSize = r2._nextUint32(), n2.pixelWidth = r2._nextUint32(), n2.pixelHeight = r2._nextUint32(), n2.pixelDepth = r2._nextUint32(), n2.layerCount = r2._nextUint32(), n2.faceCount = r2._nextUint32();
var a4 = r2._nextUint32();
n2.supercompressionScheme = r2._nextUint32();
for (var s2 = r2._nextUint32(), o2 = r2._nextUint32(), l2 = r2._nextUint32(), h2 = r2._nextUint32(), c14 = r2._nextUint64(), x2 = r2._nextUint64(), u4 = new p(t2, f.length + i2, 3 * a4 * 8, true), g2 = 0; g2 < a4; g2++)
n2.levels.push({ levelData: new Uint8Array(t2.buffer, t2.byteOffset + u4._nextUint64(), u4._nextUint64()), uncompressedByteLength: u4._nextUint64() });
for (var y2 = new p(t2, s2, o2, true), d = { vendorId: y2._skip(4)._nextUint16(), descriptorType: y2._nextUint16(), versionNumber: y2._nextUint16(), descriptorBlockSize: y2._nextUint16(), colorModel: y2._nextUint8(), colorPrimaries: y2._nextUint8(), transferFunction: y2._nextUint8(), flags: y2._nextUint8(), texelBlockDimension: { x: y2._nextUint8() + 1, y: y2._nextUint8() + 1, z: y2._nextUint8() + 1, w: y2._nextUint8() + 1 }, bytesPlane: [y2._nextUint8(), y2._nextUint8(), y2._nextUint8(), y2._nextUint8(), y2._nextUint8(), y2._nextUint8(), y2._nextUint8(), y2._nextUint8()], samples: [] }, b = (d.descriptorBlockSize / 4 - 6) / 4, D = 0; D < b; D++)
d.samples[D] = { bitOffset: y2._nextUint16(), bitLength: y2._nextUint8(), channelID: y2._nextUint8(), samplePosition: [y2._nextUint8(), y2._nextUint8(), y2._nextUint8(), y2._nextUint8()], sampleLower: y2._nextUint32(), sampleUpper: y2._nextUint32() };
n2.dataFormatDescriptor.length = 0, n2.dataFormatDescriptor.push(d);
for (var m = new p(t2, l2, h2, true); m._offset < h2; ) {
var v7 = m._nextUint32(), S = m._scan(v7), T = _(S), A = m._scan(v7 - S.byteLength);
n2.keyValue[T] = T.match(/^ktx/i) ? _(A) : A, m._offset % 4 && m._skip(4 - m._offset % 4);
}
if (x2 <= 0)
return n2;
for (var w = new p(t2, c14, x2, true), B = w._nextUint16(), L = w._nextUint16(), I = w._nextUint32(), R = w._nextUint32(), E = w._nextUint32(), C = w._nextUint32(), P = [], O = 0; O < a4; O++)
P.push({ imageFlags: w._nextUint32(), rgbSliceByteOffset: w._nextUint32(), rgbSliceByteLength: w._nextUint32(), alphaSliceByteOffset: w._nextUint32(), alphaSliceByteLength: w._nextUint32() });
var F = c14 + w._offset, G = F + I, K = G + R, X = K + E, k = new Uint8Array(t2.buffer, t2.byteOffset + F, I), N = new Uint8Array(t2.buffer, t2.byteOffset + G, R), V = new Uint8Array(t2.buffer, t2.byteOffset + K, E), M = new Uint8Array(t2.buffer, t2.byteOffset + X, C);
return n2.globalData = { endpointCount: B, selectorCount: L, imageDescs: P, endpointsData: k, selectorsData: N, tablesData: V, extendedData: M }, n2;
}, exports2.write = function(t2, e2) {
void 0 === e2 && (e2 = {}), e2 = h({}, y, e2);
var n2 = new ArrayBuffer(0);
if (t2.globalData) {
var i2 = new ArrayBuffer(20 + 5 * t2.globalData.imageDescs.length * 4), r2 = new DataView(i2);
r2.setUint16(0, t2.globalData.endpointCount, true), r2.setUint16(2, t2.globalData.selectorCount, true), r2.setUint32(4, t2.globalData.endpointsData.byteLength, true), r2.setUint32(8, t2.globalData.selectorsData.byteLength, true), r2.setUint32(12, t2.globalData.tablesData.byteLength, true), r2.setUint32(16, t2.globalData.extendedData.byteLength, true);
for (var a4 = 0; a4 < t2.globalData.imageDescs.length; a4++) {
var s2 = t2.globalData.imageDescs[a4];
r2.setUint32(20 + 5 * a4 * 4 + 0, s2.imageFlags, true), r2.setUint32(20 + 5 * a4 * 4 + 4, s2.rgbSliceByteOffset, true), r2.setUint32(20 + 5 * a4 * 4 + 8, s2.rgbSliceByteLength, true), r2.setUint32(20 + 5 * a4 * 4 + 12, s2.alphaSliceByteOffset, true), r2.setUint32(20 + 5 * a4 * 4 + 16, s2.alphaSliceByteLength, true);
}
n2 = g([i2, t2.globalData.endpointsData, t2.globalData.selectorsData, t2.globalData.tablesData, t2.globalData.extendedData]);
}
var o2 = [], U2 = t2.keyValue;
for (var p2 in e2.keepWriter || (U2 = h({}, t2.keyValue, { KTXwriter: "KTX-Parse v0.2.2" })), U2) {
var c14 = U2[p2], x2 = u3(p2), _2 = "string" == typeof c14 ? u3(c14) : c14, d = x2.byteLength + 1 + _2.byteLength + 1, b = d % 4 ? 4 - d % 4 : 0;
o2.push(g([new Uint32Array([d]), x2, l, _2, l, new Uint8Array(b).fill(0)]));
}
var D = g(o2);
if (1 !== t2.dataFormatDescriptor.length || t2.dataFormatDescriptor[0].descriptorType !== exports2.KTX2DescriptorType.BASICFORMAT)
throw new Error("Only BASICFORMAT Data Format Descriptor output supported.");
var m = t2.dataFormatDescriptor[0], v7 = new ArrayBuffer(28 + 16 * m.samples.length), S = new DataView(v7);
S.setUint32(0, v7.byteLength, true), S.setUint16(4, m.vendorId, true), S.setUint16(6, m.descriptorType, true), S.setUint16(8, m.versionNumber, true), S.setUint16(10, m.descriptorBlockSize, true), S.setUint8(12, m.colorModel), S.setUint8(13, m.colorPrimaries), S.setUint8(14, m.transferFunction), S.setUint8(15, m.flags), S.setUint8(16, m.texelBlockDimension.x - 1), S.setUint8(17, m.texelBlockDimension.y - 1), S.setUint8(18, m.texelBlockDimension.z - 1), S.setUint8(19, m.texelBlockDimension.w - 1);
for (var T = 0; T < 8; T++)
S.setUint8(20 + T, m.bytesPlane[T]);
for (var A = 0; A < m.samples.length; A++) {
var w = m.samples[A], B = 28 + 16 * A;
S.setUint16(B + 0, w.bitOffset, true), S.setUint8(B + 2, w.bitLength), S.setUint8(B + 3, w.channelID), S.setUint8(B + 4, w.samplePosition[0]), S.setUint8(B + 5, w.samplePosition[1]), S.setUint8(B + 6, w.samplePosition[2]), S.setUint8(B + 7, w.samplePosition[3]), S.setUint32(B + 8, w.sampleLower, true), S.setUint32(B + 12, w.sampleUpper, true);
}
var L = f.length + 68 + 3 * t2.levels.length * 8, I = L + v7.byteLength, R = I + D.byteLength;
R % 8 && (R += 8 - R % 8);
for (var E = [], C = new DataView(new ArrayBuffer(3 * t2.levels.length * 8)), P = R + n2.byteLength, O = 0; O < t2.levels.length; O++) {
var F = t2.levels[O];
E.push(F.levelData), C.setBigUint64(24 * O + 0, BigInt(P), true), C.setBigUint64(24 * O + 8, BigInt(F.levelData.byteLength), true), C.setBigUint64(24 * O + 16, BigInt(F.uncompressedByteLength), true), P += F.levelData.byteLength;
}
var G = new ArrayBuffer(68), K = new DataView(G);
return K.setUint32(0, t2.vkFormat, true), K.setUint32(4, t2.typeSize, true), K.setUint32(8, t2.pixelWidth, true), K.setUint32(12, t2.pixelHeight, true), K.setUint32(16, t2.pixelDepth, true), K.setUint32(20, t2.layerCount, true), K.setUint32(24, t2.faceCount, true), K.setUint32(28, t2.levels.length, true), K.setUint32(32, t2.supercompressionScheme, true), K.setUint32(36, L, true), K.setUint32(40, v7.byteLength, true), K.setUint32(44, I, true), K.setUint32(48, D.byteLength, true), K.setBigUint64(52, BigInt(R), true), K.setBigUint64(60, BigInt(n2.byteLength), true), new Uint8Array(g([new Uint8Array(f).buffer, G, C.buffer, v7, D, new ArrayBuffer(R - (I + D.byteLength)), n2].concat(E)));
};
}
});
// node_modules/lerc/LercDecode.js
var require_LercDecode = __commonJS({
"node_modules/lerc/LercDecode.js"(exports2, module2) {
/* Copyright 2015-2018 Esri. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @preserve */
(function() {
var LercDecode = function() {
var CntZImage = {};
CntZImage.defaultNoDataValue = -34027999387901484e22;
CntZImage.decode = function(input, options) {
options = options || {};
var skipMask = options.encodedMaskData || options.encodedMaskData === null;
var parsedData = parse3(input, options.inputOffset || 0, skipMask);
var noDataValue = options.noDataValue !== null ? options.noDataValue : CntZImage.defaultNoDataValue;
var uncompressedData = uncompressPixelValues(
parsedData,
options.pixelType || Float32Array,
options.encodedMaskData,
noDataValue,
options.returnMask
);
var result = {
width: parsedData.width,
height: parsedData.height,
pixelData: uncompressedData.resultPixels,
minValue: uncompressedData.minValue,
maxValue: parsedData.pixels.maxValue,
noDataValue
};
if (uncompressedData.resultMask) {
result.maskData = uncompressedData.resultMask;
}
if (options.returnEncodedMask && parsedData.mask) {
result.encodedMaskData = parsedData.mask.bitset ? parsedData.mask.bitset : null;
}
if (options.returnFileInfo) {
result.fileInfo = formatFileInfo(parsedData);
if (options.computeUsedBitDepths) {
result.fileInfo.bitDepths = computeUsedBitDepths(parsedData);
}
}
return result;
};
var uncompressPixelValues = function(data, TypedArrayClass, maskBitset, noDataValue, storeDecodedMask) {
var blockIdx = 0;
var numX = data.pixels.numBlocksX;
var numY = data.pixels.numBlocksY;
var blockWidth = Math.floor(data.width / numX);
var blockHeight = Math.floor(data.height / numY);
var scale = 2 * data.maxZError;
var minValue = Number.MAX_VALUE, currentValue;
maskBitset = maskBitset || (data.mask ? data.mask.bitset : null);
var resultPixels, resultMask;
resultPixels = new TypedArrayClass(data.width * data.height);
if (storeDecodedMask && maskBitset) {
resultMask = new Uint8Array(data.width * data.height);
}
var blockDataBuffer = new Float32Array(blockWidth * blockHeight);
var xx, yy;
for (var y = 0; y <= numY; y++) {
var thisBlockHeight = y !== numY ? blockHeight : data.height % numY;
if (thisBlockHeight === 0) {
continue;
}
for (var x = 0; x <= numX; x++) {
var thisBlockWidth = x !== numX ? blockWidth : data.width % numX;
if (thisBlockWidth === 0) {
continue;
}
var outPtr = y * data.width * blockHeight + x * blockWidth;
var outStride = data.width - thisBlockWidth;
var block = data.pixels.blocks[blockIdx];
var blockData, blockPtr, constValue;
if (block.encoding < 2) {
if (block.encoding === 0) {
blockData = block.rawData;
} else {
unstuff(block.stuffedData, block.bitsPerPixel, block.numValidPixels, block.offset, scale, blockDataBuffer, data.pixels.maxValue);
blockData = blockDataBuffer;
}
blockPtr = 0;
} else if (block.encoding === 2) {
constValue = 0;
} else {
constValue = block.offset;
}
var maskByte;
if (maskBitset) {
for (yy = 0; yy < thisBlockHeight; yy++) {
if (outPtr & 7) {
maskByte = maskBitset[outPtr >> 3];
maskByte <<= outPtr & 7;
}
for (xx = 0; xx < thisBlockWidth; xx++) {
if (!(outPtr & 7)) {
maskByte = maskBitset[outPtr >> 3];
}
if (maskByte & 128) {
if (resultMask) {
resultMask[outPtr] = 1;
}
currentValue = block.encoding < 2 ? blockData[blockPtr++] : constValue;
minValue = minValue > currentValue ? currentValue : minValue;
resultPixels[outPtr++] = currentValue;
} else {
if (resultMask) {
resultMask[outPtr] = 0;
}
resultPixels[outPtr++] = noDataValue;
}
maskByte <<= 1;
}
outPtr += outStride;
}
} else {
if (block.encoding < 2) {
for (yy = 0; yy < thisBlockHeight; yy++) {
for (xx = 0; xx < thisBlockWidth; xx++) {
currentValue = blockData[blockPtr++];
minValue = minValue > currentValue ? currentValue : minValue;
resultPixels[outPtr++] = currentValue;
}
outPtr += outStride;
}
} else {
minValue = minValue > constValue ? constValue : minValue;
for (yy = 0; yy < thisBlockHeight; yy++) {
for (xx = 0; xx < thisBlockWidth; xx++) {
resultPixels[outPtr++] = constValue;
}
outPtr += outStride;
}
}
}
if (block.encoding === 1 && blockPtr !== block.numValidPixels) {
throw "Block and Mask do not match";
}
blockIdx++;
}
}
return {
resultPixels,
resultMask,
minValue
};
};
var formatFileInfo = function(data) {
return {
"fileIdentifierString": data.fileIdentifierString,
"fileVersion": data.fileVersion,
"imageType": data.imageType,
"height": data.height,
"width": data.width,
"maxZError": data.maxZError,
"eofOffset": data.eofOffset,
"mask": data.mask ? {
"numBlocksX": data.mask.numBlocksX,
"numBlocksY": data.mask.numBlocksY,
"numBytes": data.mask.numBytes,
"maxValue": data.mask.maxValue
} : null,
"pixels": {
"numBlocksX": data.pixels.numBlocksX,
"numBlocksY": data.pixels.numBlocksY,
"numBytes": data.pixels.numBytes,
"maxValue": data.pixels.maxValue,
"noDataValue": data.noDataValue
}
};
};
var computeUsedBitDepths = function(data) {
var numBlocks = data.pixels.numBlocksX * data.pixels.numBlocksY;
var bitDepths = {};
for (var i = 0; i < numBlocks; i++) {
var block = data.pixels.blocks[i];
if (block.encoding === 0) {
bitDepths.float32 = true;
} else if (block.encoding === 1) {
bitDepths[block.bitsPerPixel] = true;
} else {
bitDepths[0] = true;
}
}
return Object.keys(bitDepths);
};
var parse3 = function(input, fp, skipMask) {
var data = {};
var fileIdView = new Uint8Array(input, fp, 10);
data.fileIdentifierString = String.fromCharCode.apply(null, fileIdView);
if (data.fileIdentifierString.trim() !== "CntZImage") {
throw "Unexpected file identifier string: " + data.fileIdentifierString;
}
fp += 10;
var view = new DataView(input, fp, 24);
data.fileVersion = view.getInt32(0, true);
data.imageType = view.getInt32(4, true);
data.height = view.getUint32(8, true);
data.width = view.getUint32(12, true);
data.maxZError = view.getFloat64(16, true);
fp += 24;
if (!skipMask) {
view = new DataView(input, fp, 16);
data.mask = {};
data.mask.numBlocksY = view.getUint32(0, true);
data.mask.numBlocksX = view.getUint32(4, true);
data.mask.numBytes = view.getUint32(8, true);
data.mask.maxValue = view.getFloat32(12, true);
fp += 16;
if (data.mask.numBytes > 0) {
var bitset = new Uint8Array(Math.ceil(data.width * data.height / 8));
view = new DataView(input, fp, data.mask.numBytes);
var cnt = view.getInt16(0, true);
var ip = 2, op = 0;
do {
if (cnt > 0) {
while (cnt--) {
bitset[op++] = view.getUint8(ip++);
}
} else {
var val = view.getUint8(ip++);
cnt = -cnt;
while (cnt--) {
bitset[op++] = val;
}
}
cnt = view.getInt16(ip, true);
ip += 2;
} while (ip < data.mask.numBytes);
if (cnt !== -32768 || op < bitset.length) {
throw "Unexpected end of mask RLE encoding";
}
data.mask.bitset = bitset;
fp += data.mask.numBytes;
} else if ((data.mask.numBytes | data.mask.numBlocksY | data.mask.maxValue) === 0) {
data.mask.bitset = new Uint8Array(Math.ceil(data.width * data.height / 8));
}
}
view = new DataView(input, fp, 16);
data.pixels = {};
data.pixels.numBlocksY = view.getUint32(0, true);
data.pixels.numBlocksX = view.getUint32(4, true);
data.pixels.numBytes = view.getUint32(8, true);
data.pixels.maxValue = view.getFloat32(12, true);
fp += 16;
var numBlocksX = data.pixels.numBlocksX;
var numBlocksY = data.pixels.numBlocksY;
var actualNumBlocksX = numBlocksX + (data.width % numBlocksX > 0 ? 1 : 0);
var actualNumBlocksY = numBlocksY + (data.height % numBlocksY > 0 ? 1 : 0);
data.pixels.blocks = new Array(actualNumBlocksX * actualNumBlocksY);
var blockI = 0;
for (var blockY = 0; blockY < actualNumBlocksY; blockY++) {
for (var blockX = 0; blockX < actualNumBlocksX; blockX++) {
var size = 0;
var bytesLeft = input.byteLength - fp;
view = new DataView(input, fp, Math.min(10, bytesLeft));
var block = {};
data.pixels.blocks[blockI++] = block;
var headerByte = view.getUint8(0);
size++;
block.encoding = headerByte & 63;
if (block.encoding > 3) {
throw "Invalid block encoding (" + block.encoding + ")";
}
if (block.encoding === 2) {
fp++;
continue;
}
if (headerByte !== 0 && headerByte !== 2) {
headerByte >>= 6;
block.offsetType = headerByte;
if (headerByte === 2) {
block.offset = view.getInt8(1);
size++;
} else if (headerByte === 1) {
block.offset = view.getInt16(1, true);
size += 2;
} else if (headerByte === 0) {
block.offset = view.getFloat32(1, true);
size += 4;
} else {
throw "Invalid block offset type";
}
if (block.encoding === 1) {
headerByte = view.getUint8(size);
size++;
block.bitsPerPixel = headerByte & 63;
headerByte >>= 6;
block.numValidPixelsType = headerByte;
if (headerByte === 2) {
block.numValidPixels = view.getUint8(size);
size++;
} else if (headerByte === 1) {
block.numValidPixels = view.getUint16(size, true);
size += 2;
} else if (headerByte === 0) {
block.numValidPixels = view.getUint32(size, true);
size += 4;
} else {
throw "Invalid valid pixel count type";
}
}
}
fp += size;
if (block.encoding === 3) {
continue;
}
var arrayBuf, store8;
if (block.encoding === 0) {
var numPixels = (data.pixels.numBytes - 1) / 4;
if (numPixels !== Math.floor(numPixels)) {
throw "uncompressed block has invalid length";
}
arrayBuf = new ArrayBuffer(numPixels * 4);
store8 = new Uint8Array(arrayBuf);
store8.set(new Uint8Array(input, fp, numPixels * 4));
var rawData = new Float32Array(arrayBuf);
block.rawData = rawData;
fp += numPixels * 4;
} else if (block.encoding === 1) {
var dataBytes = Math.ceil(block.numValidPixels * block.bitsPerPixel / 8);
var dataWords = Math.ceil(dataBytes / 4);
arrayBuf = new ArrayBuffer(dataWords * 4);
store8 = new Uint8Array(arrayBuf);
store8.set(new Uint8Array(input, fp, dataBytes));
block.stuffedData = new Uint32Array(arrayBuf);
fp += dataBytes;
}
}
}
data.eofOffset = fp;
return data;
};
var unstuff = function(src, bitsPerPixel, numPixels, offset2, scale, dest, maxValue) {
var bitMask = (1 << bitsPerPixel) - 1;
var i = 0, o;
var bitsLeft = 0;
var n, buffer;
var nmax = Math.ceil((maxValue - offset2) / scale);
var numInvalidTailBytes = src.length * 4 - Math.ceil(bitsPerPixel * numPixels / 8);
src[src.length - 1] <<= 8 * numInvalidTailBytes;
for (o = 0; o < numPixels; o++) {
if (bitsLeft === 0) {
buffer = src[i++];
bitsLeft = 32;
}
if (bitsLeft >= bitsPerPixel) {
n = buffer >>> bitsLeft - bitsPerPixel & bitMask;
bitsLeft -= bitsPerPixel;
} else {
var missingBits = bitsPerPixel - bitsLeft;
n = (buffer & bitMask) << missingBits & bitMask;
buffer = src[i++];
bitsLeft = 32 - missingBits;
n += buffer >>> bitsLeft;
}
dest[o] = n < nmax ? offset2 + n * scale : maxValue;
}
return dest;
};
return CntZImage;
}();
var Lerc2Decode = function() {
"use strict";
var BitStuffer = {
unstuff: function(src, dest, bitsPerPixel, numPixels, lutArr, offset2, scale, maxValue) {
var bitMask = (1 << bitsPerPixel) - 1;
var i = 0, o;
var bitsLeft = 0;
var n, buffer, missingBits, nmax;
var numInvalidTailBytes = src.length * 4 - Math.ceil(bitsPerPixel * numPixels / 8);
src[src.length - 1] <<= 8 * numInvalidTailBytes;
if (lutArr) {
for (o = 0; o < numPixels; o++) {
if (bitsLeft === 0) {
buffer = src[i++];
bitsLeft = 32;
}
if (bitsLeft >= bitsPerPixel) {
n = buffer >>> bitsLeft - bitsPerPixel & bitMask;
bitsLeft -= bitsPerPixel;
} else {
missingBits = bitsPerPixel - bitsLeft;
n = (buffer & bitMask) << missingBits & bitMask;
buffer = src[i++];
bitsLeft = 32 - missingBits;
n += buffer >>> bitsLeft;
}
dest[o] = lutArr[n];
}
} else {
nmax = Math.ceil((maxValue - offset2) / scale);
for (o = 0; o < numPixels; o++) {
if (bitsLeft === 0) {
buffer = src[i++];
bitsLeft = 32;
}
if (bitsLeft >= bitsPerPixel) {
n = buffer >>> bitsLeft - bitsPerPixel & bitMask;
bitsLeft -= bitsPerPixel;
} else {
missingBits = bitsPerPixel - bitsLeft;
n = (buffer & bitMask) << missingBits & bitMask;
buffer = src[i++];
bitsLeft = 32 - missingBits;
n += buffer >>> bitsLeft;
}
dest[o] = n < nmax ? offset2 + n * scale : maxValue;
}
}
},
unstuffLUT: function(src, bitsPerPixel, numPixels, offset2, scale, maxValue) {
var bitMask = (1 << bitsPerPixel) - 1;
var i = 0, o = 0, missingBits = 0, bitsLeft = 0, n = 0;
var buffer;
var dest = [];
var numInvalidTailBytes = src.length * 4 - Math.ceil(bitsPerPixel * numPixels / 8);
src[src.length - 1] <<= 8 * numInvalidTailBytes;
var nmax = Math.ceil((maxValue - offset2) / scale);
for (o = 0; o < numPixels; o++) {
if (bitsLeft === 0) {
buffer = src[i++];
bitsLeft = 32;
}
if (bitsLeft >= bitsPerPixel) {
n = buffer >>> bitsLeft - bitsPerPixel & bitMask;
bitsLeft -= bitsPerPixel;
} else {
missingBits = bitsPerPixel - bitsLeft;
n = (buffer & bitMask) << missingBits & bitMask;
buffer = src[i++];
bitsLeft = 32 - missingBits;
n += buffer >>> bitsLeft;
}
dest[o] = n < nmax ? offset2 + n * scale : maxValue;
}
dest.unshift(offset2);
return dest;
},
unstuff2: function(src, dest, bitsPerPixel, numPixels, lutArr, offset2, scale, maxValue) {
var bitMask = (1 << bitsPerPixel) - 1;
var i = 0, o;
var bitsLeft = 0, bitPos = 0;
var n, buffer, missingBits;
if (lutArr) {
for (o = 0; o < numPixels; o++) {
if (bitsLeft === 0) {
buffer = src[i++];
bitsLeft = 32;
bitPos = 0;
}
if (bitsLeft >= bitsPerPixel) {
n = buffer >>> bitPos & bitMask;
bitsLeft -= bitsPerPixel;
bitPos += bitsPerPixel;
} else {
missingBits = bitsPerPixel - bitsLeft;
n = buffer >>> bitPos & bitMask;
buffer = src[i++];
bitsLeft = 32 - missingBits;
n |= (buffer & (1 << missingBits) - 1) << bitsPerPixel - missingBits;
bitPos = missingBits;
}
dest[o] = lutArr[n];
}
} else {
var nmax = Math.ceil((maxValue - offset2) / scale);
for (o = 0; o < numPixels; o++) {
if (bitsLeft === 0) {
buffer = src[i++];
bitsLeft = 32;
bitPos = 0;
}
if (bitsLeft >= bitsPerPixel) {
n = buffer >>> bitPos & bitMask;
bitsLeft -= bitsPerPixel;
bitPos += bitsPerPixel;
} else {
missingBits = bitsPerPixel - bitsLeft;
n = buffer >>> bitPos & bitMask;
buffer = src[i++];
bitsLeft = 32 - missingBits;
n |= (buffer & (1 << missingBits) - 1) << bitsPerPixel - missingBits;
bitPos = missingBits;
}
dest[o] = n < nmax ? offset2 + n * scale : maxValue;
}
}
return dest;
},
unstuffLUT2: function(src, bitsPerPixel, numPixels, offset2, scale, maxValue) {
var bitMask = (1 << bitsPerPixel) - 1;
var i = 0, o = 0, missingBits = 0, bitsLeft = 0, n = 0, bitPos = 0;
var buffer;
var dest = [];
var nmax = Math.ceil((maxValue - offset2) / scale);
for (o = 0; o < numPixels; o++) {
if (bitsLeft === 0) {
buffer = src[i++];
bitsLeft = 32;
bitPos = 0;
}
if (bitsLeft >= bitsPerPixel) {
n = buffer >>> bitPos & bitMask;
bitsLeft -= bitsPerPixel;
bitPos += bitsPerPixel;
} else {
missingBits = bitsPerPixel - bitsLeft;
n = buffer >>> bitPos & bitMask;
buffer = src[i++];
bitsLeft = 32 - missingBits;
n |= (buffer & (1 << missingBits) - 1) << bitsPerPixel - missingBits;
bitPos = missingBits;
}
dest[o] = n < nmax ? offset2 + n * scale : maxValue;
}
dest.unshift(offset2);
return dest;
},
originalUnstuff: function(src, dest, bitsPerPixel, numPixels) {
var bitMask = (1 << bitsPerPixel) - 1;
var i = 0, o;
var bitsLeft = 0;
var n, buffer, missingBits;
var numInvalidTailBytes = src.length * 4 - Math.ceil(bitsPerPixel * numPixels / 8);
src[src.length - 1] <<= 8 * numInvalidTailBytes;
for (o = 0; o < numPixels; o++) {
if (bitsLeft === 0) {
buffer = src[i++];
bitsLeft = 32;
}
if (bitsLeft >= bitsPerPixel) {
n = buffer >>> bitsLeft - bitsPerPixel & bitMask;
bitsLeft -= bitsPerPixel;
} else {
missingBits = bitsPerPixel - bitsLeft;
n = (buffer & bitMask) << missingBits & bitMask;
buffer = src[i++];
bitsLeft = 32 - missingBits;
n += buffer >>> bitsLeft;
}
dest[o] = n;
}
return dest;
},
originalUnstuff2: function(src, dest, bitsPerPixel, numPixels) {
var bitMask = (1 << bitsPerPixel) - 1;
var i = 0, o;
var bitsLeft = 0, bitPos = 0;
var n, buffer, missingBits;
for (o = 0; o < numPixels; o++) {
if (bitsLeft === 0) {
buffer = src[i++];
bitsLeft = 32;
bitPos = 0;
}
if (bitsLeft >= bitsPerPixel) {
n = buffer >>> bitPos & bitMask;
bitsLeft -= bitsPerPixel;
bitPos += bitsPerPixel;
} else {
missingBits = bitsPerPixel - bitsLeft;
n = buffer >>> bitPos & bitMask;
buffer = src[i++];
bitsLeft = 32 - missingBits;
n |= (buffer & (1 << missingBits) - 1) << bitsPerPixel - missingBits;
bitPos = missingBits;
}
dest[o] = n;
}
return dest;
}
};
var Lerc2Helpers = {
HUFFMAN_LUT_BITS_MAX: 12,
computeChecksumFletcher32: function(input) {
var sum1 = 65535, sum2 = 65535;
var len = input.length;
var words = Math.floor(len / 2);
var i = 0;
while (words) {
var tlen = words >= 359 ? 359 : words;
words -= tlen;
do {
sum1 += input[i++] << 8;
sum2 += sum1 += input[i++];
} while (--tlen);
sum1 = (sum1 & 65535) + (sum1 >>> 16);
sum2 = (sum2 & 65535) + (sum2 >>> 16);
}
if (len & 1) {
sum2 += sum1 += input[i] << 8;
}
sum1 = (sum1 & 65535) + (sum1 >>> 16);
sum2 = (sum2 & 65535) + (sum2 >>> 16);
return (sum2 << 16 | sum1) >>> 0;
},
readHeaderInfo: function(input, data) {
var ptr = data.ptr;
var fileIdView = new Uint8Array(input, ptr, 6);
var headerInfo = {};
headerInfo.fileIdentifierString = String.fromCharCode.apply(null, fileIdView);
if (headerInfo.fileIdentifierString.lastIndexOf("Lerc2", 0) !== 0) {
throw "Unexpected file identifier string (expect Lerc2 ): " + headerInfo.fileIdentifierString;
}
ptr += 6;
var view = new DataView(input, ptr, 8);
var fileVersion = view.getInt32(0, true);
headerInfo.fileVersion = fileVersion;
ptr += 4;
if (fileVersion >= 3) {
headerInfo.checksum = view.getUint32(4, true);
ptr += 4;
}
view = new DataView(input, ptr, 12);
headerInfo.height = view.getUint32(0, true);
headerInfo.width = view.getUint32(4, true);
ptr += 8;
if (fileVersion >= 4) {
headerInfo.numDims = view.getUint32(8, true);
ptr += 4;
} else {
headerInfo.numDims = 1;
}
view = new DataView(input, ptr, 40);
headerInfo.numValidPixel = view.getUint32(0, true);
headerInfo.microBlockSize = view.getInt32(4, true);
headerInfo.blobSize = view.getInt32(8, true);
headerInfo.imageType = view.getInt32(12, true);
headerInfo.maxZError = view.getFloat64(16, true);
headerInfo.zMin = view.getFloat64(24, true);
headerInfo.zMax = view.getFloat64(32, true);
ptr += 40;
data.headerInfo = headerInfo;
data.ptr = ptr;
var checksum, keyLength;
if (fileVersion >= 3) {
keyLength = fileVersion >= 4 ? 52 : 48;
checksum = this.computeChecksumFletcher32(new Uint8Array(input, ptr - keyLength, headerInfo.blobSize - 14));
if (checksum !== headerInfo.checksum) {
throw "Checksum failed.";
}
}
return true;
},
checkMinMaxRanges: function(input, data) {
var headerInfo = data.headerInfo;
var OutPixelTypeArray = this.getDataTypeArray(headerInfo.imageType);
var rangeBytes = headerInfo.numDims * this.getDataTypeSize(headerInfo.imageType);
var minValues = this.readSubArray(input, data.ptr, OutPixelTypeArray, rangeBytes);
var maxValues = this.readSubArray(input, data.ptr + rangeBytes, OutPixelTypeArray, rangeBytes);
data.ptr += 2 * rangeBytes;
var i, equal = true;
for (i = 0; i < headerInfo.numDims; i++) {
if (minValues[i] !== maxValues[i]) {
equal = false;
break;
}
}
headerInfo.minValues = minValues;
headerInfo.maxValues = maxValues;
return equal;
},
readSubArray: function(input, ptr, OutPixelTypeArray, numBytes) {
var rawData;
if (OutPixelTypeArray === Uint8Array) {
rawData = new Uint8Array(input, ptr, numBytes);
} else {
var arrayBuf = new ArrayBuffer(numBytes);
var store8 = new Uint8Array(arrayBuf);
store8.set(new Uint8Array(input, ptr, numBytes));
rawData = new OutPixelTypeArray(arrayBuf);
}
return rawData;
},
readMask: function(input, data) {
var ptr = data.ptr;
var headerInfo = data.headerInfo;
var numPixels = headerInfo.width * headerInfo.height;
var numValidPixel = headerInfo.numValidPixel;
var view = new DataView(input, ptr, 4);
var mask = {};
mask.numBytes = view.getUint32(0, true);
ptr += 4;
if ((0 === numValidPixel || numPixels === numValidPixel) && 0 !== mask.numBytes) {
throw "invalid mask";
}
var bitset, resultMask;
if (numValidPixel === 0) {
bitset = new Uint8Array(Math.ceil(numPixels / 8));
mask.bitset = bitset;
resultMask = new Uint8Array(numPixels);
data.pixels.resultMask = resultMask;
ptr += mask.numBytes;
} else if (mask.numBytes > 0) {
bitset = new Uint8Array(Math.ceil(numPixels / 8));
view = new DataView(input, ptr, mask.numBytes);
var cnt = view.getInt16(0, true);
var ip = 2, op = 0, val = 0;
do {
if (cnt > 0) {
while (cnt--) {
bitset[op++] = view.getUint8(ip++);
}
} else {
val = view.getUint8(ip++);
cnt = -cnt;
while (cnt--) {
bitset[op++] = val;
}
}
cnt = view.getInt16(ip, true);
ip += 2;
} while (ip < mask.numBytes);
if (cnt !== -32768 || op < bitset.length) {
throw "Unexpected end of mask RLE encoding";
}
resultMask = new Uint8Array(numPixels);
var mb = 0, k = 0;
for (k = 0; k < numPixels; k++) {
if (k & 7) {
mb = bitset[k >> 3];
mb <<= k & 7;
} else {
mb = bitset[k >> 3];
}
if (mb & 128) {
resultMask[k] = 1;
}
}
data.pixels.resultMask = resultMask;
mask.bitset = bitset;
ptr += mask.numBytes;
}
data.ptr = ptr;
data.mask = mask;
return true;
},
readDataOneSweep: function(input, data, OutPixelTypeArray) {
var ptr = data.ptr;
var headerInfo = data.headerInfo;
var numDims = headerInfo.numDims;
var numPixels = headerInfo.width * headerInfo.height;
var imageType = headerInfo.imageType;
var numBytes = headerInfo.numValidPixel * Lerc2Helpers.getDataTypeSize(imageType) * numDims;
var rawData;
var mask = data.pixels.resultMask;
if (OutPixelTypeArray === Uint8Array) {
rawData = new Uint8Array(input, ptr, numBytes);
} else {
var arrayBuf = new ArrayBuffer(numBytes);
var store8 = new Uint8Array(arrayBuf);
store8.set(new Uint8Array(input, ptr, numBytes));
rawData = new OutPixelTypeArray(arrayBuf);
}
if (rawData.length === numPixels * numDims) {
data.pixels.resultPixels = rawData;
} else {
data.pixels.resultPixels = new OutPixelTypeArray(numPixels * numDims);
var z = 0, k = 0, i = 0, nStart = 0;
if (numDims > 1) {
for (i = 0; i < numDims; i++) {
nStart = i * numPixels;
for (k = 0; k < numPixels; k++) {
if (mask[k]) {
data.pixels.resultPixels[nStart + k] = rawData[z++];
}
}
}
} else {
for (k = 0; k < numPixels; k++) {
if (mask[k]) {
data.pixels.resultPixels[k] = rawData[z++];
}
}
}
}
ptr += numBytes;
data.ptr = ptr;
return true;
},
readHuffmanTree: function(input, data) {
var BITS_MAX = this.HUFFMAN_LUT_BITS_MAX;
var view = new DataView(input, data.ptr, 16);
data.ptr += 16;
var version = view.getInt32(0, true);
if (version < 2) {
throw "unsupported Huffman version";
}
var size = view.getInt32(4, true);
var i0 = view.getInt32(8, true);
var i1 = view.getInt32(12, true);
if (i0 >= i1) {
return false;
}
var blockDataBuffer = new Uint32Array(i1 - i0);
Lerc2Helpers.decodeBits(input, data, blockDataBuffer);
var codeTable = [];
var i, j, k, len;
for (i = i0; i < i1; i++) {
j = i - (i < size ? 0 : size);
codeTable[j] = { first: blockDataBuffer[i - i0], second: null };
}
var dataBytes = input.byteLength - data.ptr;
var dataWords = Math.ceil(dataBytes / 4);
var arrayBuf = new ArrayBuffer(dataWords * 4);
var store8 = new Uint8Array(arrayBuf);
store8.set(new Uint8Array(input, data.ptr, dataBytes));
var stuffedData = new Uint32Array(arrayBuf);
var bitPos = 0, word, srcPtr = 0;
word = stuffedData[0];
for (i = i0; i < i1; i++) {
j = i - (i < size ? 0 : size);
len = codeTable[j].first;
if (len > 0) {
codeTable[j].second = word << bitPos >>> 32 - len;
if (32 - bitPos >= len) {
bitPos += len;
if (bitPos === 32) {
bitPos = 0;
srcPtr++;
word = stuffedData[srcPtr];
}
} else {
bitPos += len - 32;
srcPtr++;
word = stuffedData[srcPtr];
codeTable[j].second |= word >>> 32 - bitPos;
}
}
}
var numBitsLUT = 0, numBitsLUTQick = 0;
var tree = new TreeNode();
for (i = 0; i < codeTable.length; i++) {
if (codeTable[i] !== void 0) {
numBitsLUT = Math.max(numBitsLUT, codeTable[i].first);
}
}
if (numBitsLUT >= BITS_MAX) {
numBitsLUTQick = BITS_MAX;
} else {
numBitsLUTQick = numBitsLUT;
}
if (numBitsLUT >= 30) {
console.log("WARning, large NUM LUT BITS IS " + numBitsLUT);
}
var decodeLut = [], entry, code, numEntries, jj, currentBit, node;
for (i = i0; i < i1; i++) {
j = i - (i < size ? 0 : size);
len = codeTable[j].first;
if (len > 0) {
entry = [len, j];
if (len <= numBitsLUTQick) {
code = codeTable[j].second << numBitsLUTQick - len;
numEntries = 1 << numBitsLUTQick - len;
for (k = 0; k < numEntries; k++) {
decodeLut[code | k] = entry;
}
} else {
code = codeTable[j].second;
node = tree;
for (jj = len - 1; jj >= 0; jj--) {
currentBit = code >>> jj & 1;
if (currentBit) {
if (!node.right) {
node.right = new TreeNode();
}
node = node.right;
} else {
if (!node.left) {
node.left = new TreeNode();
}
node = node.left;
}
if (jj === 0 && !node.val) {
node.val = entry[1];
}
}
}
}
}
return {
decodeLut,
numBitsLUTQick,
numBitsLUT,
tree,
stuffedData,
srcPtr,
bitPos
};
},
readHuffman: function(input, data, OutPixelTypeArray) {
var headerInfo = data.headerInfo;
var numDims = headerInfo.numDims;
var height = data.headerInfo.height;
var width = data.headerInfo.width;
var numPixels = width * height;
var huffmanInfo = this.readHuffmanTree(input, data);
var decodeLut = huffmanInfo.decodeLut;
var tree = huffmanInfo.tree;
var stuffedData = huffmanInfo.stuffedData;
var srcPtr = huffmanInfo.srcPtr;
var bitPos = huffmanInfo.bitPos;
var numBitsLUTQick = huffmanInfo.numBitsLUTQick;
var numBitsLUT = huffmanInfo.numBitsLUT;
var offset2 = data.headerInfo.imageType === 0 ? 128 : 0;
var node, val, delta, mask = data.pixels.resultMask, valTmp, valTmpQuick, currentBit;
var i, j, k, ii;
var prevVal = 0;
if (bitPos > 0) {
srcPtr++;
bitPos = 0;
}
var word = stuffedData[srcPtr];
var deltaEncode = data.encodeMode === 1;
var resultPixelsAllDim = new OutPixelTypeArray(numPixels * numDims);
var resultPixels = resultPixelsAllDim;
var iDim;
for (iDim = 0; iDim < headerInfo.numDims; iDim++) {
if (numDims > 1) {
resultPixels = new OutPixelTypeArray(resultPixelsAllDim.buffer, numPixels * iDim, numPixels);
prevVal = 0;
}
if (data.headerInfo.numValidPixel === width * height) {
for (k = 0, i = 0; i < height; i++) {
for (j = 0; j < width; j++, k++) {
val = 0;
valTmp = word << bitPos >>> 32 - numBitsLUTQick;
valTmpQuick = valTmp;
if (32 - bitPos < numBitsLUTQick) {
valTmp |= stuffedData[srcPtr + 1] >>> 64 - bitPos - numBitsLUTQick;
valTmpQuick = valTmp;
}
if (decodeLut[valTmpQuick]) {
val = decodeLut[valTmpQuick][1];
bitPos += decodeLut[valTmpQuick][0];
} else {
valTmp = word << bitPos >>> 32 - numBitsLUT;
valTmpQuick = valTmp;
if (32 - bitPos < numBitsLUT) {
valTmp |= stuffedData[srcPtr + 1] >>> 64 - bitPos - numBitsLUT;
valTmpQuick = valTmp;
}
node = tree;
for (ii = 0; ii < numBitsLUT; ii++) {
currentBit = valTmp >>> numBitsLUT - ii - 1 & 1;
node = currentBit ? node.right : node.left;
if (!(node.left || node.right)) {
val = node.val;
bitPos = bitPos + ii + 1;
break;
}
}
}
if (bitPos >= 32) {
bitPos -= 32;
srcPtr++;
word = stuffedData[srcPtr];
}
delta = val - offset2;
if (deltaEncode) {
if (j > 0) {
delta += prevVal;
} else if (i > 0) {
delta += resultPixels[k - width];
} else {
delta += prevVal;
}
delta &= 255;
resultPixels[k] = delta;
prevVal = delta;
} else {
resultPixels[k] = delta;
}
}
}
} else {
for (k = 0, i = 0; i < height; i++) {
for (j = 0; j < width; j++, k++) {
if (mask[k]) {
val = 0;
valTmp = word << bitPos >>> 32 - numBitsLUTQick;
valTmpQuick = valTmp;
if (32 - bitPos < numBitsLUTQick) {
valTmp |= stuffedData[srcPtr + 1] >>> 64 - bitPos - numBitsLUTQick;
valTmpQuick = valTmp;
}
if (decodeLut[valTmpQuick]) {
val = decodeLut[valTmpQuick][1];
bitPos += decodeLut[valTmpQuick][0];
} else {
valTmp = word << bitPos >>> 32 - numBitsLUT;
valTmpQuick = valTmp;
if (32 - bitPos < numBitsLUT) {
valTmp |= stuffedData[srcPtr + 1] >>> 64 - bitPos - numBitsLUT;
valTmpQuick = valTmp;
}
node = tree;
for (ii = 0; ii < numBitsLUT; ii++) {
currentBit = valTmp >>> numBitsLUT - ii - 1 & 1;
node = currentBit ? node.right : node.left;
if (!(node.left || node.right)) {
val = node.val;
bitPos = bitPos + ii + 1;
break;
}
}
}
if (bitPos >= 32) {
bitPos -= 32;
srcPtr++;
word = stuffedData[srcPtr];
}
delta = val - offset2;
if (deltaEncode) {
if (j > 0 && mask[k - 1]) {
delta += prevVal;
} else if (i > 0 && mask[k - width]) {
delta += resultPixels[k - width];
} else {
delta += prevVal;
}
delta &= 255;
resultPixels[k] = delta;
prevVal = delta;
} else {
resultPixels[k] = delta;
}
}
}
}
}
data.ptr = data.ptr + (srcPtr + 1) * 4 + (bitPos > 0 ? 4 : 0);
}
data.pixels.resultPixels = resultPixelsAllDim;
},
decodeBits: function(input, data, blockDataBuffer, offset2, iDim) {
{
var headerInfo = data.headerInfo;
var fileVersion = headerInfo.fileVersion;
var blockPtr = 0;
var view = new DataView(input, data.ptr, 5);
var headerByte = view.getUint8(0);
blockPtr++;
var bits67 = headerByte >> 6;
var n = bits67 === 0 ? 4 : 3 - bits67;
var doLut = (headerByte & 32) > 0 ? true : false;
var numBits = headerByte & 31;
var numElements = 0;
if (n === 1) {
numElements = view.getUint8(blockPtr);
blockPtr++;
} else if (n === 2) {
numElements = view.getUint16(blockPtr, true);
blockPtr += 2;
} else if (n === 4) {
numElements = view.getUint32(blockPtr, true);
blockPtr += 4;
} else {
throw "Invalid valid pixel count type";
}
var scale = 2 * headerInfo.maxZError;
var stuffedData, arrayBuf, store8, dataBytes, dataWords;
var lutArr, lutData, lutBytes, lutBitsPerElement, bitsPerPixel;
var zMax = headerInfo.numDims > 1 ? headerInfo.maxValues[iDim] : headerInfo.zMax;
if (doLut) {
data.counter.lut++;
lutBytes = view.getUint8(blockPtr);
lutBitsPerElement = numBits;
blockPtr++;
dataBytes = Math.ceil((lutBytes - 1) * numBits / 8);
dataWords = Math.ceil(dataBytes / 4);
arrayBuf = new ArrayBuffer(dataWords * 4);
store8 = new Uint8Array(arrayBuf);
data.ptr += blockPtr;
store8.set(new Uint8Array(input, data.ptr, dataBytes));
lutData = new Uint32Array(arrayBuf);
data.ptr += dataBytes;
bitsPerPixel = 0;
while (lutBytes - 1 >>> bitsPerPixel) {
bitsPerPixel++;
}
dataBytes = Math.ceil(numElements * bitsPerPixel / 8);
dataWords = Math.ceil(dataBytes / 4);
arrayBuf = new ArrayBuffer(dataWords * 4);
store8 = new Uint8Array(arrayBuf);
store8.set(new Uint8Array(input, data.ptr, dataBytes));
stuffedData = new Uint32Array(arrayBuf);
data.ptr += dataBytes;
if (fileVersion >= 3) {
lutArr = BitStuffer.unstuffLUT2(lutData, numBits, lutBytes - 1, offset2, scale, zMax);
} else {
lutArr = BitStuffer.unstuffLUT(lutData, numBits, lutBytes - 1, offset2, scale, zMax);
}
if (fileVersion >= 3) {
BitStuffer.unstuff2(stuffedData, blockDataBuffer, bitsPerPixel, numElements, lutArr);
} else {
BitStuffer.unstuff(stuffedData, blockDataBuffer, bitsPerPixel, numElements, lutArr);
}
} else {
data.counter.bitstuffer++;
bitsPerPixel = numBits;
data.ptr += blockPtr;
if (bitsPerPixel > 0) {
dataBytes = Math.ceil(numElements * bitsPerPixel / 8);
dataWords = Math.ceil(dataBytes / 4);
arrayBuf = new ArrayBuffer(dataWords * 4);
store8 = new Uint8Array(arrayBuf);
store8.set(new Uint8Array(input, data.ptr, dataBytes));
stuffedData = new Uint32Array(arrayBuf);
data.ptr += dataBytes;
if (fileVersion >= 3) {
if (offset2 == null) {
BitStuffer.originalUnstuff2(stuffedData, blockDataBuffer, bitsPerPixel, numElements);
} else {
BitStuffer.unstuff2(stuffedData, blockDataBuffer, bitsPerPixel, numElements, false, offset2, scale, zMax);
}
} else {
if (offset2 == null) {
BitStuffer.originalUnstuff(stuffedData, blockDataBuffer, bitsPerPixel, numElements);
} else {
BitStuffer.unstuff(stuffedData, blockDataBuffer, bitsPerPixel, numElements, false, offset2, scale, zMax);
}
}
}
}
}
},
readTiles: function(input, data, OutPixelTypeArray) {
var headerInfo = data.headerInfo;
var width = headerInfo.width;
var height = headerInfo.height;
var microBlockSize = headerInfo.microBlockSize;
var imageType = headerInfo.imageType;
var dataTypeSize = Lerc2Helpers.getDataTypeSize(imageType);
var numBlocksX = Math.ceil(width / microBlockSize);
var numBlocksY = Math.ceil(height / microBlockSize);
data.pixels.numBlocksY = numBlocksY;
data.pixels.numBlocksX = numBlocksX;
data.pixels.ptr = 0;
var row = 0, col = 0, blockY = 0, blockX = 0, thisBlockHeight = 0, thisBlockWidth = 0, bytesLeft = 0, headerByte = 0, bits67 = 0, testCode = 0, outPtr = 0, outStride = 0, numBytes = 0, bytesleft = 0, z = 0, blockPtr = 0;
var view, block, arrayBuf, store8, rawData;
var blockEncoding;
var blockDataBuffer = new OutPixelTypeArray(microBlockSize * microBlockSize);
var lastBlockHeight = height % microBlockSize || microBlockSize;
var lastBlockWidth = width % microBlockSize || microBlockSize;
var offsetType, offset2;
var numDims = headerInfo.numDims, iDim;
var mask = data.pixels.resultMask;
var resultPixels = data.pixels.resultPixels;
for (blockY = 0; blockY < numBlocksY; blockY++) {
thisBlockHeight = blockY !== numBlocksY - 1 ? microBlockSize : lastBlockHeight;
for (blockX = 0; blockX < numBlocksX; blockX++) {
thisBlockWidth = blockX !== numBlocksX - 1 ? microBlockSize : lastBlockWidth;
outPtr = blockY * width * microBlockSize + blockX * microBlockSize;
outStride = width - thisBlockWidth;
for (iDim = 0; iDim < numDims; iDim++) {
if (numDims > 1) {
resultPixels = new OutPixelTypeArray(data.pixels.resultPixels.buffer, width * height * iDim * dataTypeSize, width * height);
}
bytesLeft = input.byteLength - data.ptr;
view = new DataView(input, data.ptr, Math.min(10, bytesLeft));
block = {};
blockPtr = 0;
headerByte = view.getUint8(0);
blockPtr++;
bits67 = headerByte >> 6 & 255;
testCode = headerByte >> 2 & 15;
if (testCode !== (blockX * microBlockSize >> 3 & 15)) {
throw "integrity issue";
}
blockEncoding = headerByte & 3;
if (blockEncoding > 3) {
data.ptr += blockPtr;
throw "Invalid block encoding (" + blockEncoding + ")";
} else if (blockEncoding === 2) {
data.counter.constant++;
data.ptr += blockPtr;
continue;
} else if (blockEncoding === 0) {
data.counter.uncompressed++;
data.ptr += blockPtr;
numBytes = thisBlockHeight * thisBlockWidth * dataTypeSize;
bytesleft = input.byteLength - data.ptr;
numBytes = numBytes < bytesleft ? numBytes : bytesleft;
arrayBuf = new ArrayBuffer(numBytes % dataTypeSize === 0 ? numBytes : numBytes + dataTypeSize - numBytes % dataTypeSize);
store8 = new Uint8Array(arrayBuf);
store8.set(new Uint8Array(input, data.ptr, numBytes));
rawData = new OutPixelTypeArray(arrayBuf);
z = 0;
if (mask) {
for (row = 0; row < thisBlockHeight; row++) {
for (col = 0; col < thisBlockWidth; col++) {
if (mask[outPtr]) {
resultPixels[outPtr] = rawData[z++];
}
outPtr++;
}
outPtr += outStride;
}
} else {
for (row = 0; row < thisBlockHeight; row++) {
for (col = 0; col < thisBlockWidth; col++) {
resultPixels[outPtr++] = rawData[z++];
}
outPtr += outStride;
}
}
data.ptr += z * dataTypeSize;
} else {
offsetType = Lerc2Helpers.getDataTypeUsed(imageType, bits67);
offset2 = Lerc2Helpers.getOnePixel(block, blockPtr, offsetType, view);
blockPtr += Lerc2Helpers.getDataTypeSize(offsetType);
if (blockEncoding === 3) {
data.ptr += blockPtr;
data.counter.constantoffset++;
if (mask) {
for (row = 0; row < thisBlockHeight; row++) {
for (col = 0; col < thisBlockWidth; col++) {
if (mask[outPtr]) {
resultPixels[outPtr] = offset2;
}
outPtr++;
}
outPtr += outStride;
}
} else {
for (row = 0; row < thisBlockHeight; row++) {
for (col = 0; col < thisBlockWidth; col++) {
resultPixels[outPtr++] = offset2;
}
outPtr += outStride;
}
}
} else {
data.ptr += blockPtr;
Lerc2Helpers.decodeBits(input, data, blockDataBuffer, offset2, iDim);
blockPtr = 0;
if (mask) {
for (row = 0; row < thisBlockHeight; row++) {
for (col = 0; col < thisBlockWidth; col++) {
if (mask[outPtr]) {
resultPixels[outPtr] = blockDataBuffer[blockPtr++];
}
outPtr++;
}
outPtr += outStride;
}
} else {
for (row = 0; row < thisBlockHeight; row++) {
for (col = 0; col < thisBlockWidth; col++) {
resultPixels[outPtr++] = blockDataBuffer[blockPtr++];
}
outPtr += outStride;
}
}
}
}
}
}
}
},
formatFileInfo: function(data) {
return {
"fileIdentifierString": data.headerInfo.fileIdentifierString,
"fileVersion": data.headerInfo.fileVersion,
"imageType": data.headerInfo.imageType,
"height": data.headerInfo.height,
"width": data.headerInfo.width,
"numValidPixel": data.headerInfo.numValidPixel,
"microBlockSize": data.headerInfo.microBlockSize,
"blobSize": data.headerInfo.blobSize,
"maxZError": data.headerInfo.maxZError,
"pixelType": Lerc2Helpers.getPixelType(data.headerInfo.imageType),
"eofOffset": data.eofOffset,
"mask": data.mask ? {
"numBytes": data.mask.numBytes
} : null,
"pixels": {
"numBlocksX": data.pixels.numBlocksX,
"numBlocksY": data.pixels.numBlocksY,
"maxValue": data.headerInfo.zMax,
"minValue": data.headerInfo.zMin,
"noDataValue": data.noDataValue
}
};
},
constructConstantSurface: function(data) {
var val = data.headerInfo.zMax;
var numDims = data.headerInfo.numDims;
var numPixels = data.headerInfo.height * data.headerInfo.width;
var numPixelAllDims = numPixels * numDims;
var i = 0, k = 0, nStart = 0;
var mask = data.pixels.resultMask;
if (mask) {
if (numDims > 1) {
for (i = 0; i < numDims; i++) {
nStart = i * numPixels;
for (k = 0; k < numPixels; k++) {
if (mask[k]) {
data.pixels.resultPixels[nStart + k] = val;
}
}
}
} else {
for (k = 0; k < numPixels; k++) {
if (mask[k]) {
data.pixels.resultPixels[k] = val;
}
}
}
} else {
if (data.pixels.resultPixels.fill) {
data.pixels.resultPixels.fill(val);
} else {
for (k = 0; k < numPixelAllDims; k++) {
data.pixels.resultPixels[k] = val;
}
}
}
return;
},
getDataTypeArray: function(t) {
var tp;
switch (t) {
case 0:
tp = Int8Array;
break;
case 1:
tp = Uint8Array;
break;
case 2:
tp = Int16Array;
break;
case 3:
tp = Uint16Array;
break;
case 4:
tp = Int32Array;
break;
case 5:
tp = Uint32Array;
break;
case 6:
tp = Float32Array;
break;
case 7:
tp = Float64Array;
break;
default:
tp = Float32Array;
}
return tp;
},
getPixelType: function(t) {
var tp;
switch (t) {
case 0:
tp = "S8";
break;
case 1:
tp = "U8";
break;
case 2:
tp = "S16";
break;
case 3:
tp = "U16";
break;
case 4:
tp = "S32";
break;
case 5:
tp = "U32";
break;
case 6:
tp = "F32";
break;
case 7:
tp = "F64";
break;
default:
tp = "F32";
}
return tp;
},
isValidPixelValue: function(t, val) {
if (val == null) {
return false;
}
var isValid;
switch (t) {
case 0:
isValid = val >= -128 && val <= 127;
break;
case 1:
isValid = val >= 0 && val <= 255;
break;
case 2:
isValid = val >= -32768 && val <= 32767;
break;
case 3:
isValid = val >= 0 && val <= 65536;
break;
case 4:
isValid = val >= -2147483648 && val <= 2147483647;
break;
case 5:
isValid = val >= 0 && val <= 4294967296;
break;
case 6:
isValid = val >= -34027999387901484e22 && val <= 34027999387901484e22;
break;
case 7:
isValid = val >= 5e-324 && val <= 17976931348623157e292;
break;
default:
isValid = false;
}
return isValid;
},
getDataTypeSize: function(t) {
var s = 0;
switch (t) {
case 0:
case 1:
s = 1;
break;
case 2:
case 3:
s = 2;
break;
case 4:
case 5:
case 6:
s = 4;
break;
case 7:
s = 8;
break;
default:
s = t;
}
return s;
},
getDataTypeUsed: function(dt, tc) {
var t = dt;
switch (dt) {
case 2:
case 4:
t = dt - tc;
break;
case 3:
case 5:
t = dt - 2 * tc;
break;
case 6:
if (0 === tc) {
t = dt;
} else if (1 === tc) {
t = 2;
} else {
t = 1;
}
break;
case 7:
if (0 === tc) {
t = dt;
} else {
t = dt - 2 * tc + 1;
}
break;
default:
t = dt;
break;
}
return t;
},
getOnePixel: function(block, blockPtr, offsetType, view) {
var temp = 0;
switch (offsetType) {
case 0:
temp = view.getInt8(blockPtr);
break;
case 1:
temp = view.getUint8(blockPtr);
break;
case 2:
temp = view.getInt16(blockPtr, true);
break;
case 3:
temp = view.getUint16(blockPtr, true);
break;
case 4:
temp = view.getInt32(blockPtr, true);
break;
case 5:
temp = view.getUInt32(blockPtr, true);
break;
case 6:
temp = view.getFloat32(blockPtr, true);
break;
case 7:
temp = view.getFloat64(blockPtr, true);
break;
default:
throw "the decoder does not understand this pixel type";
}
return temp;
}
};
var TreeNode = function(val, left, right) {
this.val = val;
this.left = left;
this.right = right;
};
var Lerc2Decode2 = {
decode: function(input, options) {
options = options || {};
var noDataValue = options.noDataValue;
var i = 0, data = {};
data.ptr = options.inputOffset || 0;
data.pixels = {};
if (!Lerc2Helpers.readHeaderInfo(input, data)) {
return;
}
var headerInfo = data.headerInfo;
var fileVersion = headerInfo.fileVersion;
var OutPixelTypeArray = Lerc2Helpers.getDataTypeArray(headerInfo.imageType);
Lerc2Helpers.readMask(input, data);
if (headerInfo.numValidPixel !== headerInfo.width * headerInfo.height && !data.pixels.resultMask) {
data.pixels.resultMask = options.maskData;
}
var numPixels = headerInfo.width * headerInfo.height;
data.pixels.resultPixels = new OutPixelTypeArray(numPixels * headerInfo.numDims);
data.counter = {
onesweep: 0,
uncompressed: 0,
lut: 0,
bitstuffer: 0,
constant: 0,
constantoffset: 0
};
if (headerInfo.numValidPixel !== 0) {
if (headerInfo.zMax === headerInfo.zMin) {
Lerc2Helpers.constructConstantSurface(data);
} else if (fileVersion >= 4 && Lerc2Helpers.checkMinMaxRanges(input, data)) {
Lerc2Helpers.constructConstantSurface(data);
} else {
var view = new DataView(input, data.ptr, 2);
var bReadDataOneSweep = view.getUint8(0);
data.ptr++;
if (bReadDataOneSweep) {
Lerc2Helpers.readDataOneSweep(input, data, OutPixelTypeArray);
} else {
if (fileVersion > 1 && headerInfo.imageType <= 1 && Math.abs(headerInfo.maxZError - 0.5) < 1e-5) {
var flagHuffman = view.getUint8(1);
data.ptr++;
data.encodeMode = flagHuffman;
if (flagHuffman > 2 || fileVersion < 4 && flagHuffman > 1) {
throw "Invalid Huffman flag " + flagHuffman;
}
if (flagHuffman) {
Lerc2Helpers.readHuffman(input, data, OutPixelTypeArray);
} else {
Lerc2Helpers.readTiles(input, data, OutPixelTypeArray);
}
} else {
Lerc2Helpers.readTiles(input, data, OutPixelTypeArray);
}
}
}
}
data.eofOffset = data.ptr;
var diff;
if (options.inputOffset) {
diff = data.headerInfo.blobSize + options.inputOffset - data.ptr;
if (Math.abs(diff) >= 1) {
data.eofOffset = options.inputOffset + data.headerInfo.blobSize;
}
} else {
diff = data.headerInfo.blobSize - data.ptr;
if (Math.abs(diff) >= 1) {
data.eofOffset = data.headerInfo.blobSize;
}
}
var result = {
width: headerInfo.width,
height: headerInfo.height,
pixelData: data.pixels.resultPixels,
minValue: headerInfo.zMin,
maxValue: headerInfo.zMax,
validPixelCount: headerInfo.numValidPixel,
dimCount: headerInfo.numDims,
dimStats: {
minValues: headerInfo.minValues,
maxValues: headerInfo.maxValues
},
maskData: data.pixels.resultMask
};
if (data.pixels.resultMask && Lerc2Helpers.isValidPixelValue(headerInfo.imageType, noDataValue)) {
var mask = data.pixels.resultMask;
for (i = 0; i < numPixels; i++) {
if (!mask[i]) {
result.pixelData[i] = noDataValue;
}
}
result.noDataValue = noDataValue;
}
data.noDataValue = noDataValue;
if (options.returnFileInfo) {
result.fileInfo = Lerc2Helpers.formatFileInfo(data);
}
return result;
},
getBandCount: function(input) {
var count = 0;
var i = 0;
var temp = {};
temp.ptr = 0;
temp.pixels = {};
while (i < input.byteLength - 58) {
Lerc2Helpers.readHeaderInfo(input, temp);
i += temp.headerInfo.blobSize;
count++;
temp.ptr = i;
}
return count;
}
};
return Lerc2Decode2;
}();
var isPlatformLittleEndian = function() {
var a3 = new ArrayBuffer(4);
var b = new Uint8Array(a3);
var c = new Uint32Array(a3);
c[0] = 1;
return b[0] === 1;
}();
var Lerc = {
decode: function(encodedData, options) {
if (!isPlatformLittleEndian) {
throw "Big endian system is not supported.";
}
options = options || {};
var inputOffset = options.inputOffset || 0;
var fileIdView = new Uint8Array(encodedData, inputOffset, 10);
var fileIdentifierString = String.fromCharCode.apply(null, fileIdView);
var lerc, majorVersion;
if (fileIdentifierString.trim() === "CntZImage") {
lerc = LercDecode;
majorVersion = 1;
} else if (fileIdentifierString.substring(0, 5) === "Lerc2") {
lerc = Lerc2Decode;
majorVersion = 2;
} else {
throw "Unexpected file identifier string: " + fileIdentifierString;
}
var iPlane = 0, eof = encodedData.byteLength - 10, encodedMaskData, bandMasks = [], bandMask, maskData;
var decodedPixelBlock = {
width: 0,
height: 0,
pixels: [],
pixelType: options.pixelType,
mask: null,
statistics: []
};
while (inputOffset < eof) {
var result = lerc.decode(encodedData, {
inputOffset,
encodedMaskData,
maskData,
returnMask: iPlane === 0 ? true : false,
returnEncodedMask: iPlane === 0 ? true : false,
returnFileInfo: true,
pixelType: options.pixelType || null,
noDataValue: options.noDataValue || null
});
inputOffset = result.fileInfo.eofOffset;
if (iPlane === 0) {
encodedMaskData = result.encodedMaskData;
maskData = result.maskData;
decodedPixelBlock.width = result.width;
decodedPixelBlock.height = result.height;
decodedPixelBlock.dimCount = result.dimCount || 1;
decodedPixelBlock.pixelType = result.pixelType || result.fileInfo.pixelType;
decodedPixelBlock.mask = result.maskData;
}
if (majorVersion > 1 && result.fileInfo.mask && result.fileInfo.mask.numBytes > 0) {
bandMasks.push(result.maskData);
}
iPlane++;
decodedPixelBlock.pixels.push(result.pixelData);
decodedPixelBlock.statistics.push({
minValue: result.minValue,
maxValue: result.maxValue,
noDataValue: result.noDataValue,
dimStats: result.dimStats
});
}
var i, j, numPixels;
if (majorVersion > 1 && bandMasks.length > 1) {
numPixels = decodedPixelBlock.width * decodedPixelBlock.height;
decodedPixelBlock.bandMasks = bandMasks;
maskData = new Uint8Array(numPixels);
maskData.set(bandMasks[0]);
for (i = 1; i < bandMasks.length; i++) {
bandMask = bandMasks[i];
for (j = 0; j < numPixels; j++) {
maskData[j] = maskData[j] & bandMask[j];
}
}
decodedPixelBlock.maskData = maskData;
}
return decodedPixelBlock;
}
};
if (typeof define === "function" && define.amd) {
define([], function() {
return Lerc;
});
} else if (typeof module2 !== "undefined" && module2.exports) {
module2.exports = Lerc;
} else {
this.Lerc = Lerc;
}
})();
}
});
// node_modules/nosleep.js/dist/NoSleep.min.js
var require_NoSleep_min = __commonJS({
"node_modules/nosleep.js/dist/NoSleep.min.js"(exports2, module2) {
/*! NoSleep.min.js v0.9.0 - git.io/vfn01 - Rich Tibbett - MIT license */
!function(A, e) {
"object" == typeof exports2 && "object" == typeof module2 ? module2.exports = e() : "function" == typeof define && define.amd ? define([], e) : "object" == typeof exports2 ? exports2.NoSleep = e() : A.NoSleep = e();
}("undefined" != typeof self ? self : exports2, function() {
return function(A) {
function e(B) {
if (o[B])
return o[B].exports;
var Q = o[B] = { i: B, l: false, exports: {} };
return A[B].call(Q.exports, Q, Q.exports, e), Q.l = true, Q.exports;
}
var o = {};
return e.m = A, e.c = o, e.d = function(A2, o2, B) {
e.o(A2, o2) || Object.defineProperty(A2, o2, { configurable: false, enumerable: true, get: B });
}, e.n = function(A2) {
var o2 = A2 && A2.__esModule ? function() {
return A2.default;
} : function() {
return A2;
};
return e.d(o2, "a", o2), o2;
}, e.o = function(A2, e2) {
return Object.prototype.hasOwnProperty.call(A2, e2);
}, e.p = "", e(e.s = 0);
}([function(A, e, o) {
"use strict";
function B(A2, e2) {
if (!(A2 instanceof e2))
throw new TypeError("Cannot call a class as a function");
}
var Q = function() {
function A2(A3, e2) {
for (var o2 = 0; o2 < e2.length; o2++) {
var B2 = e2[o2];
B2.enumerable = B2.enumerable || false, B2.configurable = true, "value" in B2 && (B2.writable = true), Object.defineProperty(A3, B2.key, B2);
}
}
return function(e2, o2, B2) {
return o2 && A2(e2.prototype, o2), B2 && A2(e2, B2), e2;
};
}(), t = o(1), n = t.webm, c = t.mp4, E = "undefined" != typeof navigator && parseFloat(("" + (/CPU.*OS ([0-9_]{3,4})[0-9_]{0,1}|(CPU like).*AppleWebKit.*Mobile/i.exec(navigator.userAgent) || [0, ""])[1]).replace("undefined", "3_2").replace("_", ".").replace("_", "")) < 10 && !window.MSStream, l = function() {
function A2() {
var e2 = this;
B(this, A2), E ? this.noSleepTimer = null : (this.noSleepVideo = document.createElement("video"), this.noSleepVideo.setAttribute("muted", ""), this.noSleepVideo.setAttribute("title", "No Sleep"), this.noSleepVideo.setAttribute("playsinline", ""), this._addSourceToVideo(this.noSleepVideo, "webm", n), this._addSourceToVideo(this.noSleepVideo, "mp4", c), this.noSleepVideo.addEventListener("loadedmetadata", function() {
e2.noSleepVideo.duration <= 1 ? e2.noSleepVideo.setAttribute("loop", "") : e2.noSleepVideo.addEventListener("timeupdate", function() {
e2.noSleepVideo.currentTime > 0.5 && (e2.noSleepVideo.currentTime = Math.random());
});
}));
}
return Q(A2, [{ key: "_addSourceToVideo", value: function(A3, e2, o2) {
var B2 = document.createElement("source");
B2.src = o2, B2.type = "video/" + e2, A3.appendChild(B2);
} }, { key: "enable", value: function() {
E ? (this.disable(), console.warn("\n NoSleep enabled for older iOS devices. This can interrupt\n active or long-running network requests from completing successfully.\n See https://github.com/richtr/NoSleep.js/issues/15 for more details.\n "), this.noSleepTimer = window.setInterval(function() {
document.hidden || (window.location.href = window.location.href.split("#")[0], window.setTimeout(window.stop, 0));
}, 15e3)) : this.noSleepVideo.play();
} }, { key: "disable", value: function() {
E ? this.noSleepTimer && (console.warn("\n NoSleep now disabled for older iOS devices.\n "), window.clearInterval(this.noSleepTimer), this.noSleepTimer = null) : this.noSleepVideo.pause();
} }]), A2;
}();
A.exports = l;
}, function(A, e, o) {
"use strict";
A.exports = { webm: "data:video/webm;base64,GkXfo0AgQoaBAUL3gQFC8oEEQvOBCEKCQAR3ZWJtQoeBAkKFgQIYU4BnQI0VSalmQCgq17FAAw9CQE2AQAZ3aGFtbXlXQUAGd2hhbW15RIlACECPQAAAAAAAFlSua0AxrkAu14EBY8WBAZyBACK1nEADdW5khkAFVl9WUDglhohAA1ZQOIOBAeBABrCBCLqBCB9DtnVAIueBAKNAHIEAAIAwAQCdASoIAAgAAUAmJaQAA3AA/vz0AAA=", mp4: "data:video/mp4;base64,AAAAIGZ0eXBtcDQyAAACAGlzb21pc28yYXZjMW1wNDEAAAAIZnJlZQAACKBtZGF0AAAC8wYF///v3EXpvebZSLeWLNgg2SPu73gyNjQgLSBjb3JlIDE0MiByMjQ3OSBkZDc5YTYxIC0gSC4yNjQvTVBFRy00IEFWQyBjb2RlYyAtIENvcHlsZWZ0IDIwMDMtMjAxNCAtIGh0dHA6Ly93d3cudmlkZW9sYW4ub3JnL3gyNjQuaHRtbCAtIG9wdGlvbnM6IGNhYmFjPTEgcmVmPTEgZGVibG9jaz0xOjA6MCBhbmFseXNlPTB4MToweDExMSBtZT1oZXggc3VibWU9MiBwc3k9MSBwc3lfcmQ9MS4wMDowLjAwIG1peGVkX3JlZj0wIG1lX3JhbmdlPTE2IGNocm9tYV9tZT0xIHRyZWxsaXM9MCA4eDhkY3Q9MCBjcW09MCBkZWFkem9uZT0yMSwxMSBmYXN0X3Bza2lwPTEgY2hyb21hX3FwX29mZnNldD0wIHRocmVhZHM9NiBsb29rYWhlYWRfdGhyZWFkcz0xIHNsaWNlZF90aHJlYWRzPTAgbnI9MCBkZWNpbWF0ZT0xIGludGVybGFjZWQ9MCBibHVyYXlfY29tcGF0PTAgY29uc3RyYWluZWRfaW50cmE9MCBiZnJhbWVzPTMgYl9weXJhbWlkPTIgYl9hZGFwdD0xIGJfYmlhcz0wIGRpcmVjdD0xIHdlaWdodGI9MSBvcGVuX2dvcD0wIHdlaWdodHA9MSBrZXlpbnQ9MzAwIGtleWludF9taW49MzAgc2NlbmVjdXQ9NDAgaW50cmFfcmVmcmVzaD0wIHJjX2xvb2thaGVhZD0xMCByYz1jcmYgbWJ0cmVlPTEgY3JmPTIwLjAgcWNvbXA9MC42MCBxcG1pbj0wIHFwbWF4PTY5IHFwc3RlcD00IHZidl9tYXhyYXRlPTIwMDAwIHZidl9idWZzaXplPTI1MDAwIGNyZl9tYXg9MC4wIG5hbF9ocmQ9bm9uZSBmaWxsZXI9MCBpcF9yYXRpbz0xLjQwIGFxPTE6MS4wMACAAAAAOWWIhAA3//p+C7v8tDDSTjf97w55i3SbRPO4ZY+hkjD5hbkAkL3zpJ6h/LR1CAABzgB1kqqzUorlhQAAAAxBmiQYhn/+qZYADLgAAAAJQZ5CQhX/AAj5IQADQGgcIQADQGgcAAAACQGeYUQn/wALKCEAA0BoHAAAAAkBnmNEJ/8ACykhAANAaBwhAANAaBwAAAANQZpoNExDP/6plgAMuSEAA0BoHAAAAAtBnoZFESwr/wAI+SEAA0BoHCEAA0BoHAAAAAkBnqVEJ/8ACykhAANAaBwAAAAJAZ6nRCf/AAsoIQADQGgcIQADQGgcAAAADUGarDRMQz/+qZYADLghAANAaBwAAAALQZ7KRRUsK/8ACPkhAANAaBwAAAAJAZ7pRCf/AAsoIQADQGgcIQADQGgcAAAACQGe60Qn/wALKCEAA0BoHAAAAA1BmvA0TEM//qmWAAy5IQADQGgcIQADQGgcAAAAC0GfDkUVLCv/AAj5IQADQGgcAAAACQGfLUQn/wALKSEAA0BoHCEAA0BoHAAAAAkBny9EJ/8ACyghAANAaBwAAAANQZs0NExDP/6plgAMuCEAA0BoHAAAAAtBn1JFFSwr/wAI+SEAA0BoHCEAA0BoHAAAAAkBn3FEJ/8ACyghAANAaBwAAAAJAZ9zRCf/AAsoIQADQGgcIQADQGgcAAAADUGbeDRMQz/+qZYADLkhAANAaBwAAAALQZ+WRRUsK/8ACPghAANAaBwhAANAaBwAAAAJAZ+1RCf/AAspIQADQGgcAAAACQGft0Qn/wALKSEAA0BoHCEAA0BoHAAAAA1Bm7w0TEM//qmWAAy4IQADQGgcAAAAC0Gf2kUVLCv/AAj5IQADQGgcAAAACQGf+UQn/wALKCEAA0BoHCEAA0BoHAAAAAkBn/tEJ/8ACykhAANAaBwAAAANQZvgNExDP/6plgAMuSEAA0BoHCEAA0BoHAAAAAtBnh5FFSwr/wAI+CEAA0BoHAAAAAkBnj1EJ/8ACyghAANAaBwhAANAaBwAAAAJAZ4/RCf/AAspIQADQGgcAAAADUGaJDRMQz/+qZYADLghAANAaBwAAAALQZ5CRRUsK/8ACPkhAANAaBwhAANAaBwAAAAJAZ5hRCf/AAsoIQADQGgcAAAACQGeY0Qn/wALKSEAA0BoHCEAA0BoHAAAAA1Bmmg0TEM//qmWAAy5IQADQGgcAAAAC0GehkUVLCv/AAj5IQADQGgcIQADQGgcAAAACQGepUQn/wALKSEAA0BoHAAAAAkBnqdEJ/8ACyghAANAaBwAAAANQZqsNExDP/6plgAMuCEAA0BoHCEAA0BoHAAAAAtBnspFFSwr/wAI+SEAA0BoHAAAAAkBnulEJ/8ACyghAANAaBwhAANAaBwAAAAJAZ7rRCf/AAsoIQADQGgcAAAADUGa8DRMQz/+qZYADLkhAANAaBwhAANAaBwAAAALQZ8ORRUsK/8ACPkhAANAaBwAAAAJAZ8tRCf/AAspIQADQGgcIQADQGgcAAAACQGfL0Qn/wALKCEAA0BoHAAAAA1BmzQ0TEM//qmWAAy4IQADQGgcAAAAC0GfUkUVLCv/AAj5IQADQGgcIQADQGgcAAAACQGfcUQn/wALKCEAA0BoHAAAAAkBn3NEJ/8ACyghAANAaBwhAANAaBwAAAANQZt4NExC//6plgAMuSEAA0BoHAAAAAtBn5ZFFSwr/wAI+CEAA0BoHCEAA0BoHAAAAAkBn7VEJ/8ACykhAANAaBwAAAAJAZ+3RCf/AAspIQADQGgcAAAADUGbuzRMQn/+nhAAYsAhAANAaBwhAANAaBwAAAAJQZ/aQhP/AAspIQADQGgcAAAACQGf+UQn/wALKCEAA0BoHCEAA0BoHCEAA0BoHCEAA0BoHCEAA0BoHCEAA0BoHAAACiFtb292AAAAbG12aGQAAAAA1YCCX9WAgl8AAAPoAAAH/AABAAABAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADAAAAGGlvZHMAAAAAEICAgAcAT////v7/AAAF+XRyYWsAAABcdGtoZAAAAAPVgIJf1YCCXwAAAAEAAAAAAAAH0AAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAEAAAAAAygAAAMoAAAAAACRlZHRzAAAAHGVsc3QAAAAAAAAAAQAAB9AAABdwAAEAAAAABXFtZGlhAAAAIG1kaGQAAAAA1YCCX9WAgl8AAV+QAAK/IFXEAAAAAAAtaGRscgAAAAAAAAAAdmlkZQAAAAAAAAAAAAAAAFZpZGVvSGFuZGxlcgAAAAUcbWluZgAAABR2bWhkAAAAAQAAAAAAAAAAAAAAJGRpbmYAAAAcZHJlZgAAAAAAAAABAAAADHVybCAAAAABAAAE3HN0YmwAAACYc3RzZAAAAAAAAAABAAAAiGF2YzEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAygDKAEgAAABIAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAY//8AAAAyYXZjQwFNQCj/4QAbZ01AKOyho3ySTUBAQFAAAAMAEAAr8gDxgxlgAQAEaO+G8gAAABhzdHRzAAAAAAAAAAEAAAA8AAALuAAAABRzdHNzAAAAAAAAAAEAAAABAAAB8GN0dHMAAAAAAAAAPAAAAAEAABdwAAAAAQAAOpgAAAABAAAXcAAAAAEAAAAAAAAAAQAAC7gAAAABAAA6mAAAAAEAABdwAAAAAQAAAAAAAAABAAALuAAAAAEAADqYAAAAAQAAF3AAAAABAAAAAAAAAAEAAAu4AAAAAQAAOpgAAAABAAAXcAAAAAEAAAAAAAAAAQAAC7gAAAABAAA6mAAAAAEAABdwAAAAAQAAAAAAAAABAAALuAAAAAEAADqYAAAAAQAAF3AAAAABAAAAAAAAAAEAAAu4AAAAAQAAOpgAAAABAAAXcAAAAAEAAAAAAAAAAQAAC7gAAAABAAA6mAAAAAEAABdwAAAAAQAAAAAAAAABAAALuAAAAAEAADqYAAAAAQAAF3AAAAABAAAAAAAAAAEAAAu4AAAAAQAAOpgAAAABAAAXcAAAAAEAAAAAAAAAAQAAC7gAAAABAAA6mAAAAAEAABdwAAAAAQAAAAAAAAABAAALuAAAAAEAADqYAAAAAQAAF3AAAAABAAAAAAAAAAEAAAu4AAAAAQAAOpgAAAABAAAXcAAAAAEAAAAAAAAAAQAAC7gAAAABAAA6mAAAAAEAABdwAAAAAQAAAAAAAAABAAALuAAAAAEAAC7gAAAAAQAAF3AAAAABAAAAAAAAABxzdHNjAAAAAAAAAAEAAAABAAAAAQAAAAEAAAEEc3RzegAAAAAAAAAAAAAAPAAAAzQAAAAQAAAADQAAAA0AAAANAAAAEQAAAA8AAAANAAAADQAAABEAAAAPAAAADQAAAA0AAAARAAAADwAAAA0AAAANAAAAEQAAAA8AAAANAAAADQAAABEAAAAPAAAADQAAAA0AAAARAAAADwAAAA0AAAANAAAAEQAAAA8AAAANAAAADQAAABEAAAAPAAAADQAAAA0AAAARAAAADwAAAA0AAAANAAAAEQAAAA8AAAANAAAADQAAABEAAAAPAAAADQAAAA0AAAARAAAADwAAAA0AAAANAAAAEQAAAA8AAAANAAAADQAAABEAAAANAAAADQAAAQBzdGNvAAAAAAAAADwAAAAwAAADZAAAA3QAAAONAAADoAAAA7kAAAPQAAAD6wAAA/4AAAQXAAAELgAABEMAAARcAAAEbwAABIwAAAShAAAEugAABM0AAATkAAAE/wAABRIAAAUrAAAFQgAABV0AAAVwAAAFiQAABaAAAAW1AAAFzgAABeEAAAX+AAAGEwAABiwAAAY/AAAGVgAABnEAAAaEAAAGnQAABrQAAAbPAAAG4gAABvUAAAcSAAAHJwAAB0AAAAdTAAAHcAAAB4UAAAeeAAAHsQAAB8gAAAfjAAAH9gAACA8AAAgmAAAIQQAACFQAAAhnAAAIhAAACJcAAAMsdHJhawAAAFx0a2hkAAAAA9WAgl/VgIJfAAAAAgAAAAAAAAf8AAAAAAAAAAAAAAABAQAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAACsm1kaWEAAAAgbWRoZAAAAADVgIJf1YCCXwAArEQAAWAAVcQAAAAAACdoZGxyAAAAAAAAAABzb3VuAAAAAAAAAAAAAAAAU3RlcmVvAAAAAmNtaW5mAAAAEHNtaGQAAAAAAAAAAAAAACRkaW5mAAAAHGRyZWYAAAAAAAAAAQAAAAx1cmwgAAAAAQAAAidzdGJsAAAAZ3N0c2QAAAAAAAAAAQAAAFdtcDRhAAAAAAAAAAEAAAAAAAAAAAACABAAAAAArEQAAAAAADNlc2RzAAAAAAOAgIAiAAIABICAgBRAFQAAAAADDUAAAAAABYCAgAISEAaAgIABAgAAABhzdHRzAAAAAAAAAAEAAABYAAAEAAAAABxzdHNjAAAAAAAAAAEAAAABAAAAAQAAAAEAAAAUc3RzegAAAAAAAAAGAAAAWAAAAXBzdGNvAAAAAAAAAFgAAAOBAAADhwAAA5oAAAOtAAADswAAA8oAAAPfAAAD5QAAA/gAAAQLAAAEEQAABCgAAAQ9AAAEUAAABFYAAARpAAAEgAAABIYAAASbAAAErgAABLQAAATHAAAE3gAABPMAAAT5AAAFDAAABR8AAAUlAAAFPAAABVEAAAVXAAAFagAABX0AAAWDAAAFmgAABa8AAAXCAAAFyAAABdsAAAXyAAAF+AAABg0AAAYgAAAGJgAABjkAAAZQAAAGZQAABmsAAAZ+AAAGkQAABpcAAAauAAAGwwAABskAAAbcAAAG7wAABwYAAAcMAAAHIQAABzQAAAc6AAAHTQAAB2QAAAdqAAAHfwAAB5IAAAeYAAAHqwAAB8IAAAfXAAAH3QAAB/AAAAgDAAAICQAACCAAAAg1AAAIOwAACE4AAAhhAAAIeAAACH4AAAiRAAAIpAAACKoAAAiwAAAItgAACLwAAAjCAAAAFnVkdGEAAAAObmFtZVN0ZXJlbwAAAHB1ZHRhAAAAaG1ldGEAAAAAAAAAIWhkbHIAAAAAAAAAAG1kaXJhcHBsAAAAAAAAAAAAAAAAO2lsc3QAAAAzqXRvbwAAACtkYXRhAAAAAQAAAABIYW5kQnJha2UgMC4xMC4yIDIwMTUwNjExMDA=" };
}]);
});
}
});
// node_modules/pako/lib/utils/common.js
var require_common = __commonJS({
"node_modules/pako/lib/utils/common.js"(exports2) {
"use strict";
var TYPED_OK = typeof Uint8Array !== "undefined" && typeof Uint16Array !== "undefined" && typeof Int32Array !== "undefined";
function _has(obj, key) {
return Object.prototype.hasOwnProperty.call(obj, key);
}
exports2.assign = function(obj) {
var sources = Array.prototype.slice.call(arguments, 1);
while (sources.length) {
var source = sources.shift();
if (!source) {
continue;
}
if (typeof source !== "object") {
throw new TypeError(source + "must be non-object");
}
for (var p in source) {
if (_has(source, p)) {
obj[p] = source[p];
}
}
}
return obj;
};
exports2.shrinkBuf = function(buf, size) {
if (buf.length === size) {
return buf;
}
if (buf.subarray) {
return buf.subarray(0, size);
}
buf.length = size;
return buf;
};
var fnTyped = {
arraySet: function(dest, src, src_offs, len, dest_offs) {
if (src.subarray && dest.subarray) {
dest.set(src.subarray(src_offs, src_offs + len), dest_offs);
return;
}
for (var i = 0; i < len; i++) {
dest[dest_offs + i] = src[src_offs + i];
}
},
flattenChunks: function(chunks) {
var i, l, len, pos, chunk, result;
len = 0;
for (i = 0, l = chunks.length; i < l; i++) {
len += chunks[i].length;
}
result = new Uint8Array(len);
pos = 0;
for (i = 0, l = chunks.length; i < l; i++) {
chunk = chunks[i];
result.set(chunk, pos);
pos += chunk.length;
}
return result;
}
};
var fnUntyped = {
arraySet: function(dest, src, src_offs, len, dest_offs) {
for (var i = 0; i < len; i++) {
dest[dest_offs + i] = src[src_offs + i];
}
},
flattenChunks: function(chunks) {
return [].concat.apply([], chunks);
}
};
exports2.setTyped = function(on) {
if (on) {
exports2.Buf8 = Uint8Array;
exports2.Buf16 = Uint16Array;
exports2.Buf32 = Int32Array;
exports2.assign(exports2, fnTyped);
} else {
exports2.Buf8 = Array;
exports2.Buf16 = Array;
exports2.Buf32 = Array;
exports2.assign(exports2, fnUntyped);
}
};
exports2.setTyped(TYPED_OK);
}
});
// node_modules/pako/lib/zlib/adler32.js
var require_adler32 = __commonJS({
"node_modules/pako/lib/zlib/adler32.js"(exports2, module2) {
"use strict";
function adler32(adler, buf, len, pos) {
var s1 = adler & 65535 | 0, s2 = adler >>> 16 & 65535 | 0, n = 0;
while (len !== 0) {
n = len > 2e3 ? 2e3 : len;
len -= n;
do {
s1 = s1 + buf[pos++] | 0;
s2 = s2 + s1 | 0;
} while (--n);
s1 %= 65521;
s2 %= 65521;
}
return s1 | s2 << 16 | 0;
}
module2.exports = adler32;
}
});
// node_modules/pako/lib/zlib/crc32.js
var require_crc32 = __commonJS({
"node_modules/pako/lib/zlib/crc32.js"(exports2, module2) {
"use strict";
function makeTable() {
var c, table2 = [];
for (var n = 0; n < 256; n++) {
c = n;
for (var k = 0; k < 8; k++) {
c = c & 1 ? 3988292384 ^ c >>> 1 : c >>> 1;
}
table2[n] = c;
}
return table2;
}
var crcTable = makeTable();
function crc32(crc, buf, len, pos) {
var t = crcTable, end = pos + len;
crc ^= -1;
for (var i = pos; i < end; i++) {
crc = crc >>> 8 ^ t[(crc ^ buf[i]) & 255];
}
return crc ^ -1;
}
module2.exports = crc32;
}
});
// node_modules/pako/lib/zlib/inffast.js
var require_inffast = __commonJS({
"node_modules/pako/lib/zlib/inffast.js"(exports2, module2) {
"use strict";
var BAD = 30;
var TYPE = 12;
module2.exports = function inflate_fast(strm, start) {
var state;
var _in;
var last;
var _out;
var beg;
var end;
var dmax;
var wsize;
var whave;
var wnext;
var s_window;
var hold;
var bits;
var lcode;
var dcode;
var lmask;
var dmask;
var here;
var op;
var len;
var dist;
var from;
var from_source;
var input, output;
state = strm.state;
_in = strm.next_in;
input = strm.input;
last = _in + (strm.avail_in - 5);
_out = strm.next_out;
output = strm.output;
beg = _out - (start - strm.avail_out);
end = _out + (strm.avail_out - 257);
dmax = state.dmax;
wsize = state.wsize;
whave = state.whave;
wnext = state.wnext;
s_window = state.window;
hold = state.hold;
bits = state.bits;
lcode = state.lencode;
dcode = state.distcode;
lmask = (1 << state.lenbits) - 1;
dmask = (1 << state.distbits) - 1;
top:
do {
if (bits < 15) {
hold += input[_in++] << bits;
bits += 8;
hold += input[_in++] << bits;
bits += 8;
}
here = lcode[hold & lmask];
dolen:
for (; ; ) {
op = here >>> 24;
hold >>>= op;
bits -= op;
op = here >>> 16 & 255;
if (op === 0) {
output[_out++] = here & 65535;
} else if (op & 16) {
len = here & 65535;
op &= 15;
if (op) {
if (bits < op) {
hold += input[_in++] << bits;
bits += 8;
}
len += hold & (1 << op) - 1;
hold >>>= op;
bits -= op;
}
if (bits < 15) {
hold += input[_in++] << bits;
bits += 8;
hold += input[_in++] << bits;
bits += 8;
}
here = dcode[hold & dmask];
dodist:
for (; ; ) {
op = here >>> 24;
hold >>>= op;
bits -= op;
op = here >>> 16 & 255;
if (op & 16) {
dist = here & 65535;
op &= 15;
if (bits < op) {
hold += input[_in++] << bits;
bits += 8;
if (bits < op) {
hold += input[_in++] << bits;
bits += 8;
}
}
dist += hold & (1 << op) - 1;
if (dist > dmax) {
strm.msg = "invalid distance too far back";
state.mode = BAD;
break top;
}
hold >>>= op;
bits -= op;
op = _out - beg;
if (dist > op) {
op = dist - op;
if (op > whave) {
if (state.sane) {
strm.msg = "invalid distance too far back";
state.mode = BAD;
break top;
}
}
from = 0;
from_source = s_window;
if (wnext === 0) {
from += wsize - op;
if (op < len) {
len -= op;
do {
output[_out++] = s_window[from++];
} while (--op);
from = _out - dist;
from_source = output;
}
} else if (wnext < op) {
from += wsize + wnext - op;
op -= wnext;
if (op < len) {
len -= op;
do {
output[_out++] = s_window[from++];
} while (--op);
from = 0;
if (wnext < len) {
op = wnext;
len -= op;
do {
output[_out++] = s_window[from++];
} while (--op);
from = _out - dist;
from_source = output;
}
}
} else {
from += wnext - op;
if (op < len) {
len -= op;
do {
output[_out++] = s_window[from++];
} while (--op);
from = _out - dist;
from_source = output;
}
}
while (len > 2) {
output[_out++] = from_source[from++];
output[_out++] = from_source[from++];
output[_out++] = from_source[from++];
len -= 3;
}
if (len) {
output[_out++] = from_source[from++];
if (len > 1) {
output[_out++] = from_source[from++];
}
}
} else {
from = _out - dist;
do {
output[_out++] = output[from++];
output[_out++] = output[from++];
output[_out++] = output[from++];
len -= 3;
} while (len > 2);
if (len) {
output[_out++] = output[from++];
if (len > 1) {
output[_out++] = output[from++];
}
}
}
} else if ((op & 64) === 0) {
here = dcode[(here & 65535) + (hold & (1 << op) - 1)];
continue dodist;
} else {
strm.msg = "invalid distance code";
state.mode = BAD;
break top;
}
break;
}
} else if ((op & 64) === 0) {
here = lcode[(here & 65535) + (hold & (1 << op) - 1)];
continue dolen;
} else if (op & 32) {
state.mode = TYPE;
break top;
} else {
strm.msg = "invalid literal/length code";
state.mode = BAD;
break top;
}
break;
}
} while (_in < last && _out < end);
len = bits >> 3;
_in -= len;
bits -= len << 3;
hold &= (1 << bits) - 1;
strm.next_in = _in;
strm.next_out = _out;
strm.avail_in = _in < last ? 5 + (last - _in) : 5 - (_in - last);
strm.avail_out = _out < end ? 257 + (end - _out) : 257 - (_out - end);
state.hold = hold;
state.bits = bits;
return;
};
}
});
// node_modules/pako/lib/zlib/inftrees.js
var require_inftrees = __commonJS({
"node_modules/pako/lib/zlib/inftrees.js"(exports2, module2) {
"use strict";
var utils = require_common();
var MAXBITS = 15;
var ENOUGH_LENS = 852;
var ENOUGH_DISTS = 592;
var CODES = 0;
var LENS = 1;
var DISTS = 2;
var lbase = [
3,
4,
5,
6,
7,
8,
9,
10,
11,
13,
15,
17,
19,
23,
27,
31,
35,
43,
51,
59,
67,
83,
99,
115,
131,
163,
195,
227,
258,
0,
0
];
var lext = [
16,
16,
16,
16,
16,
16,
16,
16,
17,
17,
17,
17,
18,
18,
18,
18,
19,
19,
19,
19,
20,
20,
20,
20,
21,
21,
21,
21,
16,
72,
78
];
var dbase = [
1,
2,
3,
4,
5,
7,
9,
13,
17,
25,
33,
49,
65,
97,
129,
193,
257,
385,
513,
769,
1025,
1537,
2049,
3073,
4097,
6145,
8193,
12289,
16385,
24577,
0,
0
];
var dext = [
16,
16,
16,
16,
17,
17,
18,
18,
19,
19,
20,
20,
21,
21,
22,
22,
23,
23,
24,
24,
25,
25,
26,
26,
27,
27,
28,
28,
29,
29,
64,
64
];
module2.exports = function inflate_table(type, lens, lens_index, codes, table2, table_index, work, opts) {
var bits = opts.bits;
var len = 0;
var sym = 0;
var min3 = 0, max3 = 0;
var root = 0;
var curr = 0;
var drop = 0;
var left = 0;
var used = 0;
var huff = 0;
var incr;
var fill;
var low;
var mask;
var next;
var base = null;
var base_index = 0;
var end;
var count = new utils.Buf16(MAXBITS + 1);
var offs = new utils.Buf16(MAXBITS + 1);
var extra = null;
var extra_index = 0;
var here_bits, here_op, here_val;
for (len = 0; len <= MAXBITS; len++) {
count[len] = 0;
}
for (sym = 0; sym < codes; sym++) {
count[lens[lens_index + sym]]++;
}
root = bits;
for (max3 = MAXBITS; max3 >= 1; max3--) {
if (count[max3] !== 0) {
break;
}
}
if (root > max3) {
root = max3;
}
if (max3 === 0) {
table2[table_index++] = 1 << 24 | 64 << 16 | 0;
table2[table_index++] = 1 << 24 | 64 << 16 | 0;
opts.bits = 1;
return 0;
}
for (min3 = 1; min3 < max3; min3++) {
if (count[min3] !== 0) {
break;
}
}
if (root < min3) {
root = min3;
}
left = 1;
for (len = 1; len <= MAXBITS; len++) {
left <<= 1;
left -= count[len];
if (left < 0) {
return -1;
}
}
if (left > 0 && (type === CODES || max3 !== 1)) {
return -1;
}
offs[1] = 0;
for (len = 1; len < MAXBITS; len++) {
offs[len + 1] = offs[len] + count[len];
}
for (sym = 0; sym < codes; sym++) {
if (lens[lens_index + sym] !== 0) {
work[offs[lens[lens_index + sym]]++] = sym;
}
}
if (type === CODES) {
base = extra = work;
end = 19;
} else if (type === LENS) {
base = lbase;
base_index -= 257;
extra = lext;
extra_index -= 257;
end = 256;
} else {
base = dbase;
extra = dext;
end = -1;
}
huff = 0;
sym = 0;
len = min3;
next = table_index;
curr = root;
drop = 0;
low = -1;
used = 1 << root;
mask = used - 1;
if (type === LENS && used > ENOUGH_LENS || type === DISTS && used > ENOUGH_DISTS) {
return 1;
}
for (; ; ) {
here_bits = len - drop;
if (work[sym] < end) {
here_op = 0;
here_val = work[sym];
} else if (work[sym] > end) {
here_op = extra[extra_index + work[sym]];
here_val = base[base_index + work[sym]];
} else {
here_op = 32 + 64;
here_val = 0;
}
incr = 1 << len - drop;
fill = 1 << curr;
min3 = fill;
do {
fill -= incr;
table2[next + (huff >> drop) + fill] = here_bits << 24 | here_op << 16 | here_val | 0;
} while (fill !== 0);
incr = 1 << len - 1;
while (huff & incr) {
incr >>= 1;
}
if (incr !== 0) {
huff &= incr - 1;
huff += incr;
} else {
huff = 0;
}
sym++;
if (--count[len] === 0) {
if (len === max3) {
break;
}
len = lens[lens_index + work[sym]];
}
if (len > root && (huff & mask) !== low) {
if (drop === 0) {
drop = root;
}
next += min3;
curr = len - drop;
left = 1 << curr;
while (curr + drop < max3) {
left -= count[curr + drop];
if (left <= 0) {
break;
}
curr++;
left <<= 1;
}
used += 1 << curr;
if (type === LENS && used > ENOUGH_LENS || type === DISTS && used > ENOUGH_DISTS) {
return 1;
}
low = huff & mask;
table2[low] = root << 24 | curr << 16 | next - table_index | 0;
}
}
if (huff !== 0) {
table2[next + huff] = len - drop << 24 | 64 << 16 | 0;
}
opts.bits = root;
return 0;
};
}
});
// node_modules/pako/lib/zlib/inflate.js
var require_inflate = __commonJS({
"node_modules/pako/lib/zlib/inflate.js"(exports2) {
"use strict";
var utils = require_common();
var adler32 = require_adler32();
var crc32 = require_crc32();
var inflate_fast = require_inffast();
var inflate_table = require_inftrees();
var CODES = 0;
var LENS = 1;
var DISTS = 2;
var Z_FINISH = 4;
var Z_BLOCK = 5;
var Z_TREES = 6;
var Z_OK = 0;
var Z_STREAM_END = 1;
var Z_NEED_DICT = 2;
var Z_STREAM_ERROR = -2;
var Z_DATA_ERROR = -3;
var Z_MEM_ERROR = -4;
var Z_BUF_ERROR = -5;
var Z_DEFLATED = 8;
var HEAD = 1;
var FLAGS = 2;
var TIME = 3;
var OS = 4;
var EXLEN = 5;
var EXTRA = 6;
var NAME = 7;
var COMMENT = 8;
var HCRC = 9;
var DICTID = 10;
var DICT = 11;
var TYPE = 12;
var TYPEDO = 13;
var STORED = 14;
var COPY_ = 15;
var COPY = 16;
var TABLE = 17;
var LENLENS = 18;
var CODELENS = 19;
var LEN_ = 20;
var LEN = 21;
var LENEXT = 22;
var DIST = 23;
var DISTEXT = 24;
var MATCH = 25;
var LIT = 26;
var CHECK = 27;
var LENGTH = 28;
var DONE = 29;
var BAD = 30;
var MEM = 31;
var SYNC = 32;
var ENOUGH_LENS = 852;
var ENOUGH_DISTS = 592;
var MAX_WBITS = 15;
var DEF_WBITS = MAX_WBITS;
function zswap32(q) {
return (q >>> 24 & 255) + (q >>> 8 & 65280) + ((q & 65280) << 8) + ((q & 255) << 24);
}
function InflateState() {
this.mode = 0;
this.last = false;
this.wrap = 0;
this.havedict = false;
this.flags = 0;
this.dmax = 0;
this.check = 0;
this.total = 0;
this.head = null;
this.wbits = 0;
this.wsize = 0;
this.whave = 0;
this.wnext = 0;
this.window = null;
this.hold = 0;
this.bits = 0;
this.length = 0;
this.offset = 0;
this.extra = 0;
this.lencode = null;
this.distcode = null;
this.lenbits = 0;
this.distbits = 0;
this.ncode = 0;
this.nlen = 0;
this.ndist = 0;
this.have = 0;
this.next = null;
this.lens = new utils.Buf16(320);
this.work = new utils.Buf16(288);
this.lendyn = null;
this.distdyn = null;
this.sane = 0;
this.back = 0;
this.was = 0;
}
function inflateResetKeep(strm) {
var state;
if (!strm || !strm.state) {
return Z_STREAM_ERROR;
}
state = strm.state;
strm.total_in = strm.total_out = state.total = 0;
strm.msg = "";
if (state.wrap) {
strm.adler = state.wrap & 1;
}
state.mode = HEAD;
state.last = 0;
state.havedict = 0;
state.dmax = 32768;
state.head = null;
state.hold = 0;
state.bits = 0;
state.lencode = state.lendyn = new utils.Buf32(ENOUGH_LENS);
state.distcode = state.distdyn = new utils.Buf32(ENOUGH_DISTS);
state.sane = 1;
state.back = -1;
return Z_OK;
}
function inflateReset(strm) {
var state;
if (!strm || !strm.state) {
return Z_STREAM_ERROR;
}
state = strm.state;
state.wsize = 0;
state.whave = 0;
state.wnext = 0;
return inflateResetKeep(strm);
}
function inflateReset2(strm, windowBits) {
var wrap;
var state;
if (!strm || !strm.state) {
return Z_STREAM_ERROR;
}
state = strm.state;
if (windowBits < 0) {
wrap = 0;
windowBits = -windowBits;
} else {
wrap = (windowBits >> 4) + 1;
if (windowBits < 48) {
windowBits &= 15;
}
}
if (windowBits && (windowBits < 8 || windowBits > 15)) {
return Z_STREAM_ERROR;
}
if (state.window !== null && state.wbits !== windowBits) {
state.window = null;
}
state.wrap = wrap;
state.wbits = windowBits;
return inflateReset(strm);
}
function inflateInit2(strm, windowBits) {
var ret;
var state;
if (!strm) {
return Z_STREAM_ERROR;
}
state = new InflateState();
strm.state = state;
state.window = null;
ret = inflateReset2(strm, windowBits);
if (ret !== Z_OK) {
strm.state = null;
}
return ret;
}
function inflateInit(strm) {
return inflateInit2(strm, DEF_WBITS);
}
var virgin = true;
var lenfix;
var distfix;
function fixedtables(state) {
if (virgin) {
var sym;
lenfix = new utils.Buf32(512);
distfix = new utils.Buf32(32);
sym = 0;
while (sym < 144) {
state.lens[sym++] = 8;
}
while (sym < 256) {
state.lens[sym++] = 9;
}
while (sym < 280) {
state.lens[sym++] = 7;
}
while (sym < 288) {
state.lens[sym++] = 8;
}
inflate_table(LENS, state.lens, 0, 288, lenfix, 0, state.work, { bits: 9 });
sym = 0;
while (sym < 32) {
state.lens[sym++] = 5;
}
inflate_table(DISTS, state.lens, 0, 32, distfix, 0, state.work, { bits: 5 });
virgin = false;
}
state.lencode = lenfix;
state.lenbits = 9;
state.distcode = distfix;
state.distbits = 5;
}
function updatewindow(strm, src, end, copy) {
var dist;
var state = strm.state;
if (state.window === null) {
state.wsize = 1 << state.wbits;
state.wnext = 0;
state.whave = 0;
state.window = new utils.Buf8(state.wsize);
}
if (copy >= state.wsize) {
utils.arraySet(state.window, src, end - state.wsize, state.wsize, 0);
state.wnext = 0;
state.whave = state.wsize;
} else {
dist = state.wsize - state.wnext;
if (dist > copy) {
dist = copy;
}
utils.arraySet(state.window, src, end - copy, dist, state.wnext);
copy -= dist;
if (copy) {
utils.arraySet(state.window, src, end - copy, copy, 0);
state.wnext = copy;
state.whave = state.wsize;
} else {
state.wnext += dist;
if (state.wnext === state.wsize) {
state.wnext = 0;
}
if (state.whave < state.wsize) {
state.whave += dist;
}
}
}
return 0;
}
function inflate(strm, flush) {
var state;
var input, output;
var next;
var put;
var have, left;
var hold;
var bits;
var _in, _out;
var copy;
var from;
var from_source;
var here = 0;
var here_bits, here_op, here_val;
var last_bits, last_op, last_val;
var len;
var ret;
var hbuf = new utils.Buf8(4);
var opts;
var n;
var order = [16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15];
if (!strm || !strm.state || !strm.output || !strm.input && strm.avail_in !== 0) {
return Z_STREAM_ERROR;
}
state = strm.state;
if (state.mode === TYPE) {
state.mode = TYPEDO;
}
put = strm.next_out;
output = strm.output;
left = strm.avail_out;
next = strm.next_in;
input = strm.input;
have = strm.avail_in;
hold = state.hold;
bits = state.bits;
_in = have;
_out = left;
ret = Z_OK;
inf_leave:
for (; ; ) {
switch (state.mode) {
case HEAD:
if (state.wrap === 0) {
state.mode = TYPEDO;
break;
}
while (bits < 16) {
if (have === 0) {
break inf_leave;
}
have--;
hold += input[next++] << bits;
bits += 8;
}
if (state.wrap & 2 && hold === 35615) {
state.check = 0;
hbuf[0] = hold & 255;
hbuf[1] = hold >>> 8 & 255;
state.check = crc32(state.check, hbuf, 2, 0);
hold = 0;
bits = 0;
state.mode = FLAGS;
break;
}
state.flags = 0;
if (state.head) {
state.head.done = false;
}
if (!(state.wrap & 1) || (((hold & 255) << 8) + (hold >> 8)) % 31) {
strm.msg = "incorrect header check";
state.mode = BAD;
break;
}
if ((hold & 15) !== Z_DEFLATED) {
strm.msg = "unknown compression method";
state.mode = BAD;
break;
}
hold >>>= 4;
bits -= 4;
len = (hold & 15) + 8;
if (state.wbits === 0) {
state.wbits = len;
} else if (len > state.wbits) {
strm.msg = "invalid window size";
state.mode = BAD;
break;
}
state.dmax = 1 << len;
strm.adler = state.check = 1;
state.mode = hold & 512 ? DICTID : TYPE;
hold = 0;
bits = 0;
break;
case FLAGS:
while (bits < 16) {
if (have === 0) {
break inf_leave;
}
have--;
hold += input[next++] << bits;
bits += 8;
}
state.flags = hold;
if ((state.flags & 255) !== Z_DEFLATED) {
strm.msg = "unknown compression method";
state.mode = BAD;
break;
}
if (state.flags & 57344) {
strm.msg = "unknown header flags set";
state.mode = BAD;
break;
}
if (state.head) {
state.head.text = hold >> 8 & 1;
}
if (state.flags & 512) {
hbuf[0] = hold & 255;
hbuf[1] = hold >>> 8 & 255;
state.check = crc32(state.check, hbuf, 2, 0);
}
hold = 0;
bits = 0;
state.mode = TIME;
case TIME:
while (bits < 32) {
if (have === 0) {
break inf_leave;
}
have--;
hold += input[next++] << bits;
bits += 8;
}
if (state.head) {
state.head.time = hold;
}
if (state.flags & 512) {
hbuf[0] = hold & 255;
hbuf[1] = hold >>> 8 & 255;
hbuf[2] = hold >>> 16 & 255;
hbuf[3] = hold >>> 24 & 255;
state.check = crc32(state.check, hbuf, 4, 0);
}
hold = 0;
bits = 0;
state.mode = OS;
case OS:
while (bits < 16) {
if (have === 0) {
break inf_leave;
}
have--;
hold += input[next++] << bits;
bits += 8;
}
if (state.head) {
state.head.xflags = hold & 255;
state.head.os = hold >> 8;
}
if (state.flags & 512) {
hbuf[0] = hold & 255;
hbuf[1] = hold >>> 8 & 255;
state.check = crc32(state.check, hbuf, 2, 0);
}
hold = 0;
bits = 0;
state.mode = EXLEN;
case EXLEN:
if (state.flags & 1024) {
while (bits < 16) {
if (have === 0) {
break inf_leave;
}
have--;
hold += input[next++] << bits;
bits += 8;
}
state.length = hold;
if (state.head) {
state.head.extra_len = hold;
}
if (state.flags & 512) {
hbuf[0] = hold & 255;
hbuf[1] = hold >>> 8 & 255;
state.check = crc32(state.check, hbuf, 2, 0);
}
hold = 0;
bits = 0;
} else if (state.head) {
state.head.extra = null;
}
state.mode = EXTRA;
case EXTRA:
if (state.flags & 1024) {
copy = state.length;
if (copy > have) {
copy = have;
}
if (copy) {
if (state.head) {
len = state.head.extra_len - state.length;
if (!state.head.extra) {
state.head.extra = new Array(state.head.extra_len);
}
utils.arraySet(
state.head.extra,
input,
next,
copy,
len
);
}
if (state.flags & 512) {
state.check = crc32(state.check, input, copy, next);
}
have -= copy;
next += copy;
state.length -= copy;
}
if (state.length) {
break inf_leave;
}
}
state.length = 0;
state.mode = NAME;
case NAME:
if (state.flags & 2048) {
if (have === 0) {
break inf_leave;
}
copy = 0;
do {
len = input[next + copy++];
if (state.head && len && state.length < 65536) {
state.head.name += String.fromCharCode(len);
}
} while (len && copy < have);
if (state.flags & 512) {
state.check = crc32(state.check, input, copy, next);
}
have -= copy;
next += copy;
if (len) {
break inf_leave;
}
} else if (state.head) {
state.head.name = null;
}
state.length = 0;
state.mode = COMMENT;
case COMMENT:
if (state.flags & 4096) {
if (have === 0) {
break inf_leave;
}
copy = 0;
do {
len = input[next + copy++];
if (state.head && len && state.length < 65536) {
state.head.comment += String.fromCharCode(len);
}
} while (len && copy < have);
if (state.flags & 512) {
state.check = crc32(state.check, input, copy, next);
}
have -= copy;
next += copy;
if (len) {
break inf_leave;
}
} else if (state.head) {
state.head.comment = null;
}
state.mode = HCRC;
case HCRC:
if (state.flags & 512) {
while (bits < 16) {
if (have === 0) {
break inf_leave;
}
have--;
hold += input[next++] << bits;
bits += 8;
}
if (hold !== (state.check & 65535)) {
strm.msg = "header crc mismatch";
state.mode = BAD;
break;
}
hold = 0;
bits = 0;
}
if (state.head) {
state.head.hcrc = state.flags >> 9 & 1;
state.head.done = true;
}
strm.adler = state.check = 0;
state.mode = TYPE;
break;
case DICTID:
while (bits < 32) {
if (have === 0) {
break inf_leave;
}
have--;
hold += input[next++] << bits;
bits += 8;
}
strm.adler = state.check = zswap32(hold);
hold = 0;
bits = 0;
state.mode = DICT;
case DICT:
if (state.havedict === 0) {
strm.next_out = put;
strm.avail_out = left;
strm.next_in = next;
strm.avail_in = have;
state.hold = hold;
state.bits = bits;
return Z_NEED_DICT;
}
strm.adler = state.check = 1;
state.mode = TYPE;
case TYPE:
if (flush === Z_BLOCK || flush === Z_TREES) {
break inf_leave;
}
case TYPEDO:
if (state.last) {
hold >>>= bits & 7;
bits -= bits & 7;
state.mode = CHECK;
break;
}
while (bits < 3) {
if (have === 0) {
break inf_leave;
}
have--;
hold += input[next++] << bits;
bits += 8;
}
state.last = hold & 1;
hold >>>= 1;
bits -= 1;
switch (hold & 3) {
case 0:
state.mode = STORED;
break;
case 1:
fixedtables(state);
state.mode = LEN_;
if (flush === Z_TREES) {
hold >>>= 2;
bits -= 2;
break inf_leave;
}
break;
case 2:
state.mode = TABLE;
break;
case 3:
strm.msg = "invalid block type";
state.mode = BAD;
}
hold >>>= 2;
bits -= 2;
break;
case STORED:
hold >>>= bits & 7;
bits -= bits & 7;
while (bits < 32) {
if (have === 0) {
break inf_leave;
}
have--;
hold += input[next++] << bits;
bits += 8;
}
if ((hold & 65535) !== (hold >>> 16 ^ 65535)) {
strm.msg = "invalid stored block lengths";
state.mode = BAD;
break;
}
state.length = hold & 65535;
hold = 0;
bits = 0;
state.mode = COPY_;
if (flush === Z_TREES) {
break inf_leave;
}
case COPY_:
state.mode = COPY;
case COPY:
copy = state.length;
if (copy) {
if (copy > have) {
copy = have;
}
if (copy > left) {
copy = left;
}
if (copy === 0) {
break inf_leave;
}
utils.arraySet(output, input, next, copy, put);
have -= copy;
next += copy;
left -= copy;
put += copy;
state.length -= copy;
break;
}
state.mode = TYPE;
break;
case TABLE:
while (bits < 14) {
if (have === 0) {
break inf_leave;
}
have--;
hold += input[next++] << bits;
bits += 8;
}
state.nlen = (hold & 31) + 257;
hold >>>= 5;
bits -= 5;
state.ndist = (hold & 31) + 1;
hold >>>= 5;
bits -= 5;
state.ncode = (hold & 15) + 4;
hold >>>= 4;
bits -= 4;
if (state.nlen > 286 || state.ndist > 30) {
strm.msg = "too many length or distance symbols";
state.mode = BAD;
break;
}
state.have = 0;
state.mode = LENLENS;
case LENLENS:
while (state.have < state.ncode) {
while (bits < 3) {
if (have === 0) {
break inf_leave;
}
have--;
hold += input[next++] << bits;
bits += 8;
}
state.lens[order[state.have++]] = hold & 7;
hold >>>= 3;
bits -= 3;
}
while (state.have < 19) {
state.lens[order[state.have++]] = 0;
}
state.lencode = state.lendyn;
state.lenbits = 7;
opts = { bits: state.lenbits };
ret = inflate_table(CODES, state.lens, 0, 19, state.lencode, 0, state.work, opts);
state.lenbits = opts.bits;
if (ret) {
strm.msg = "invalid code lengths set";
state.mode = BAD;
break;
}
state.have = 0;
state.mode = CODELENS;
case CODELENS:
while (state.have < state.nlen + state.ndist) {
for (; ; ) {
here = state.lencode[hold & (1 << state.lenbits) - 1];
here_bits = here >>> 24;
here_op = here >>> 16 & 255;
here_val = here & 65535;
if (here_bits <= bits) {
break;
}
if (have === 0) {
break inf_leave;
}
have--;
hold += input[next++] << bits;
bits += 8;
}
if (here_val < 16) {
hold >>>= here_bits;
bits -= here_bits;
state.lens[state.have++] = here_val;
} else {
if (here_val === 16) {
n = here_bits + 2;
while (bits < n) {
if (have === 0) {
break inf_leave;
}
have--;
hold += input[next++] << bits;
bits += 8;
}
hold >>>= here_bits;
bits -= here_bits;
if (state.have === 0) {
strm.msg = "invalid bit length repeat";
state.mode = BAD;
break;
}
len = state.lens[state.have - 1];
copy = 3 + (hold & 3);
hold >>>= 2;
bits -= 2;
} else if (here_val === 17) {
n = here_bits + 3;
while (bits < n) {
if (have === 0) {
break inf_leave;
}
have--;
hold += input[next++] << bits;
bits += 8;
}
hold >>>= here_bits;
bits -= here_bits;
len = 0;
copy = 3 + (hold & 7);
hold >>>= 3;
bits -= 3;
} else {
n = here_bits + 7;
while (bits < n) {
if (have === 0) {
break inf_leave;
}
have--;
hold += input[next++] << bits;
bits += 8;
}
hold >>>= here_bits;
bits -= here_bits;
len = 0;
copy = 11 + (hold & 127);
hold >>>= 7;
bits -= 7;
}
if (state.have + copy > state.nlen + state.ndist) {
strm.msg = "invalid bit length repeat";
state.mode = BAD;
break;
}
while (copy--) {
state.lens[state.have++] = len;
}
}
}
if (state.mode === BAD) {
break;
}
if (state.lens[256] === 0) {
strm.msg = "invalid code -- missing end-of-block";
state.mode = BAD;
break;
}
state.lenbits = 9;
opts = { bits: state.lenbits };
ret = inflate_table(LENS, state.lens, 0, state.nlen, state.lencode, 0, state.work, opts);
state.lenbits = opts.bits;
if (ret) {
strm.msg = "invalid literal/lengths set";
state.mode = BAD;
break;
}
state.distbits = 6;
state.distcode = state.distdyn;
opts = { bits: state.distbits };
ret = inflate_table(DISTS, state.lens, state.nlen, state.ndist, state.distcode, 0, state.work, opts);
state.distbits = opts.bits;
if (ret) {
strm.msg = "invalid distances set";
state.mode = BAD;
break;
}
state.mode = LEN_;
if (flush === Z_TREES) {
break inf_leave;
}
case LEN_:
state.mode = LEN;
case LEN:
if (have >= 6 && left >= 258) {
strm.next_out = put;
strm.avail_out = left;
strm.next_in = next;
strm.avail_in = have;
state.hold = hold;
state.bits = bits;
inflate_fast(strm, _out);
put = strm.next_out;
output = strm.output;
left = strm.avail_out;
next = strm.next_in;
input = strm.input;
have = strm.avail_in;
hold = state.hold;
bits = state.bits;
if (state.mode === TYPE) {
state.back = -1;
}
break;
}
state.back = 0;
for (; ; ) {
here = state.lencode[hold & (1 << state.lenbits) - 1];
here_bits = here >>> 24;
here_op = here >>> 16 & 255;
here_val = here & 65535;
if (here_bits <= bits) {
break;
}
if (have === 0) {
break inf_leave;
}
have--;
hold += input[next++] << bits;
bits += 8;
}
if (here_op && (here_op & 240) === 0) {
last_bits = here_bits;
last_op = here_op;
last_val = here_val;
for (; ; ) {
here = state.lencode[last_val + ((hold & (1 << last_bits + last_op) - 1) >> last_bits)];
here_bits = here >>> 24;
here_op = here >>> 16 & 255;
here_val = here & 65535;
if (last_bits + here_bits <= bits) {
break;
}
if (have === 0) {
break inf_leave;
}
have--;
hold += input[next++] << bits;
bits += 8;
}
hold >>>= last_bits;
bits -= last_bits;
state.back += last_bits;
}
hold >>>= here_bits;
bits -= here_bits;
state.back += here_bits;
state.length = here_val;
if (here_op === 0) {
state.mode = LIT;
break;
}
if (here_op & 32) {
state.back = -1;
state.mode = TYPE;
break;
}
if (here_op & 64) {
strm.msg = "invalid literal/length code";
state.mode = BAD;
break;
}
state.extra = here_op & 15;
state.mode = LENEXT;
case LENEXT:
if (state.extra) {
n = state.extra;
while (bits < n) {
if (have === 0) {
break inf_leave;
}
have--;
hold += input[next++] << bits;
bits += 8;
}
state.length += hold & (1 << state.extra) - 1;
hold >>>= state.extra;
bits -= state.extra;
state.back += state.extra;
}
state.was = state.length;
state.mode = DIST;
case DIST:
for (; ; ) {
here = state.distcode[hold & (1 << state.distbits) - 1];
here_bits = here >>> 24;
here_op = here >>> 16 & 255;
here_val = here & 65535;
if (here_bits <= bits) {
break;
}
if (have === 0) {
break inf_leave;
}
have--;
hold += input[next++] << bits;
bits += 8;
}
if ((here_op & 240) === 0) {
last_bits = here_bits;
last_op = here_op;
last_val = here_val;
for (; ; ) {
here = state.distcode[last_val + ((hold & (1 << last_bits + last_op) - 1) >> last_bits)];
here_bits = here >>> 24;
here_op = here >>> 16 & 255;
here_val = here & 65535;
if (last_bits + here_bits <= bits) {
break;
}
if (have === 0) {
break inf_leave;
}
have--;
hold += input[next++] << bits;
bits += 8;
}
hold >>>= last_bits;
bits -= last_bits;
state.back += last_bits;
}
hold >>>= here_bits;
bits -= here_bits;
state.back += here_bits;
if (here_op & 64) {
strm.msg = "invalid distance code";
state.mode = BAD;
break;
}
state.offset = here_val;
state.extra = here_op & 15;
state.mode = DISTEXT;
case DISTEXT:
if (state.extra) {
n = state.extra;
while (bits < n) {
if (have === 0) {
break inf_leave;
}
have--;
hold += input[next++] << bits;
bits += 8;
}
state.offset += hold & (1 << state.extra) - 1;
hold >>>= state.extra;
bits -= state.extra;
state.back += state.extra;
}
if (state.offset > state.dmax) {
strm.msg = "invalid distance too far back";
state.mode = BAD;
break;
}
state.mode = MATCH;
case MATCH:
if (left === 0) {
break inf_leave;
}
copy = _out - left;
if (state.offset > copy) {
copy = state.offset - copy;
if (copy > state.whave) {
if (state.sane) {
strm.msg = "invalid distance too far back";
state.mode = BAD;
break;
}
}
if (copy > state.wnext) {
copy -= state.wnext;
from = state.wsize - copy;
} else {
from = state.wnext - copy;
}
if (copy > state.length) {
copy = state.length;
}
from_source = state.window;
} else {
from_source = output;
from = put - state.offset;
copy = state.length;
}
if (copy > left) {
copy = left;
}
left -= copy;
state.length -= copy;
do {
output[put++] = from_source[from++];
} while (--copy);
if (state.length === 0) {
state.mode = LEN;
}
break;
case LIT:
if (left === 0) {
break inf_leave;
}
output[put++] = state.length;
left--;
state.mode = LEN;
break;
case CHECK:
if (state.wrap) {
while (bits < 32) {
if (have === 0) {
break inf_leave;
}
have--;
hold |= input[next++] << bits;
bits += 8;
}
_out -= left;
strm.total_out += _out;
state.total += _out;
if (_out) {
strm.adler = state.check = state.flags ? crc32(state.check, output, _out, put - _out) : adler32(state.check, output, _out, put - _out);
}
_out = left;
if ((state.flags ? hold : zswap32(hold)) !== state.check) {
strm.msg = "incorrect data check";
state.mode = BAD;
break;
}
hold = 0;
bits = 0;
}
state.mode = LENGTH;
case LENGTH:
if (state.wrap && state.flags) {
while (bits < 32) {
if (have === 0) {
break inf_leave;
}
have--;
hold += input[next++] << bits;
bits += 8;
}
if (hold !== (state.total & 4294967295)) {
strm.msg = "incorrect length check";
state.mode = BAD;
break;
}
hold = 0;
bits = 0;
}
state.mode = DONE;
case DONE:
ret = Z_STREAM_END;
break inf_leave;
case BAD:
ret = Z_DATA_ERROR;
break inf_leave;
case MEM:
return Z_MEM_ERROR;
case SYNC:
default:
return Z_STREAM_ERROR;
}
}
strm.next_out = put;
strm.avail_out = left;
strm.next_in = next;
strm.avail_in = have;
state.hold = hold;
state.bits = bits;
if (state.wsize || _out !== strm.avail_out && state.mode < BAD && (state.mode < CHECK || flush !== Z_FINISH)) {
if (updatewindow(strm, strm.output, strm.next_out, _out - strm.avail_out)) {
state.mode = MEM;
return Z_MEM_ERROR;
}
}
_in -= strm.avail_in;
_out -= strm.avail_out;
strm.total_in += _in;
strm.total_out += _out;
state.total += _out;
if (state.wrap && _out) {
strm.adler = state.check = state.flags ? crc32(state.check, output, _out, strm.next_out - _out) : adler32(state.check, output, _out, strm.next_out - _out);
}
strm.data_type = state.bits + (state.last ? 64 : 0) + (state.mode === TYPE ? 128 : 0) + (state.mode === LEN_ || state.mode === COPY_ ? 256 : 0);
if ((_in === 0 && _out === 0 || flush === Z_FINISH) && ret === Z_OK) {
ret = Z_BUF_ERROR;
}
return ret;
}
function inflateEnd(strm) {
if (!strm || !strm.state) {
return Z_STREAM_ERROR;
}
var state = strm.state;
if (state.window) {
state.window = null;
}
strm.state = null;
return Z_OK;
}
function inflateGetHeader(strm, head) {
var state;
if (!strm || !strm.state) {
return Z_STREAM_ERROR;
}
state = strm.state;
if ((state.wrap & 2) === 0) {
return Z_STREAM_ERROR;
}
state.head = head;
head.done = false;
return Z_OK;
}
function inflateSetDictionary(strm, dictionary) {
var dictLength = dictionary.length;
var state;
var dictid;
var ret;
if (!strm || !strm.state) {
return Z_STREAM_ERROR;
}
state = strm.state;
if (state.wrap !== 0 && state.mode !== DICT) {
return Z_STREAM_ERROR;
}
if (state.mode === DICT) {
dictid = 1;
dictid = adler32(dictid, dictionary, dictLength, 0);
if (dictid !== state.check) {
return Z_DATA_ERROR;
}
}
ret = updatewindow(strm, dictionary, dictLength, dictLength);
if (ret) {
state.mode = MEM;
return Z_MEM_ERROR;
}
state.havedict = 1;
return Z_OK;
}
exports2.inflateReset = inflateReset;
exports2.inflateReset2 = inflateReset2;
exports2.inflateResetKeep = inflateResetKeep;
exports2.inflateInit = inflateInit;
exports2.inflateInit2 = inflateInit2;
exports2.inflate = inflate;
exports2.inflateEnd = inflateEnd;
exports2.inflateGetHeader = inflateGetHeader;
exports2.inflateSetDictionary = inflateSetDictionary;
exports2.inflateInfo = "pako inflate (from Nodeca project)";
}
});
// node_modules/pako/lib/utils/strings.js
var require_strings = __commonJS({
"node_modules/pako/lib/utils/strings.js"(exports2) {
"use strict";
var utils = require_common();
var STR_APPLY_OK = true;
var STR_APPLY_UIA_OK = true;
try {
String.fromCharCode.apply(null, [0]);
} catch (__) {
STR_APPLY_OK = false;
}
try {
String.fromCharCode.apply(null, new Uint8Array(1));
} catch (__) {
STR_APPLY_UIA_OK = false;
}
var _utf8len = new utils.Buf8(256);
for (q = 0; q < 256; q++) {
_utf8len[q] = q >= 252 ? 6 : q >= 248 ? 5 : q >= 240 ? 4 : q >= 224 ? 3 : q >= 192 ? 2 : 1;
}
var q;
_utf8len[254] = _utf8len[254] = 1;
exports2.string2buf = function(str) {
var buf, c, c22, m_pos, i, str_len = str.length, buf_len = 0;
for (m_pos = 0; m_pos < str_len; m_pos++) {
c = str.charCodeAt(m_pos);
if ((c & 64512) === 55296 && m_pos + 1 < str_len) {
c22 = str.charCodeAt(m_pos + 1);
if ((c22 & 64512) === 56320) {
c = 65536 + (c - 55296 << 10) + (c22 - 56320);
m_pos++;
}
}
buf_len += c < 128 ? 1 : c < 2048 ? 2 : c < 65536 ? 3 : 4;
}
buf = new utils.Buf8(buf_len);
for (i = 0, m_pos = 0; i < buf_len; m_pos++) {
c = str.charCodeAt(m_pos);
if ((c & 64512) === 55296 && m_pos + 1 < str_len) {
c22 = str.charCodeAt(m_pos + 1);
if ((c22 & 64512) === 56320) {
c = 65536 + (c - 55296 << 10) + (c22 - 56320);
m_pos++;
}
}
if (c < 128) {
buf[i++] = c;
} else if (c < 2048) {
buf[i++] = 192 | c >>> 6;
buf[i++] = 128 | c & 63;
} else if (c < 65536) {
buf[i++] = 224 | c >>> 12;
buf[i++] = 128 | c >>> 6 & 63;
buf[i++] = 128 | c & 63;
} else {
buf[i++] = 240 | c >>> 18;
buf[i++] = 128 | c >>> 12 & 63;
buf[i++] = 128 | c >>> 6 & 63;
buf[i++] = 128 | c & 63;
}
}
return buf;
};
function buf2binstring(buf, len) {
if (len < 65534) {
if (buf.subarray && STR_APPLY_UIA_OK || !buf.subarray && STR_APPLY_OK) {
return String.fromCharCode.apply(null, utils.shrinkBuf(buf, len));
}
}
var result = "";
for (var i = 0; i < len; i++) {
result += String.fromCharCode(buf[i]);
}
return result;
}
exports2.buf2binstring = function(buf) {
return buf2binstring(buf, buf.length);
};
exports2.binstring2buf = function(str) {
var buf = new utils.Buf8(str.length);
for (var i = 0, len = buf.length; i < len; i++) {
buf[i] = str.charCodeAt(i);
}
return buf;
};
exports2.buf2string = function(buf, max3) {
var i, out, c, c_len;
var len = max3 || buf.length;
var utf16buf = new Array(len * 2);
for (out = 0, i = 0; i < len; ) {
c = buf[i++];
if (c < 128) {
utf16buf[out++] = c;
continue;
}
c_len = _utf8len[c];
if (c_len > 4) {
utf16buf[out++] = 65533;
i += c_len - 1;
continue;
}
c &= c_len === 2 ? 31 : c_len === 3 ? 15 : 7;
while (c_len > 1 && i < len) {
c = c << 6 | buf[i++] & 63;
c_len--;
}
if (c_len > 1) {
utf16buf[out++] = 65533;
continue;
}
if (c < 65536) {
utf16buf[out++] = c;
} else {
c -= 65536;
utf16buf[out++] = 55296 | c >> 10 & 1023;
utf16buf[out++] = 56320 | c & 1023;
}
}
return buf2binstring(utf16buf, out);
};
exports2.utf8border = function(buf, max3) {
var pos;
max3 = max3 || buf.length;
if (max3 > buf.length) {
max3 = buf.length;
}
pos = max3 - 1;
while (pos >= 0 && (buf[pos] & 192) === 128) {
pos--;
}
if (pos < 0) {
return max3;
}
if (pos === 0) {
return max3;
}
return pos + _utf8len[buf[pos]] > max3 ? pos : max3;
};
}
});
// node_modules/pako/lib/zlib/constants.js
var require_constants = __commonJS({
"node_modules/pako/lib/zlib/constants.js"(exports2, module2) {
"use strict";
module2.exports = {
Z_NO_FLUSH: 0,
Z_PARTIAL_FLUSH: 1,
Z_SYNC_FLUSH: 2,
Z_FULL_FLUSH: 3,
Z_FINISH: 4,
Z_BLOCK: 5,
Z_TREES: 6,
Z_OK: 0,
Z_STREAM_END: 1,
Z_NEED_DICT: 2,
Z_ERRNO: -1,
Z_STREAM_ERROR: -2,
Z_DATA_ERROR: -3,
Z_BUF_ERROR: -5,
Z_NO_COMPRESSION: 0,
Z_BEST_SPEED: 1,
Z_BEST_COMPRESSION: 9,
Z_DEFAULT_COMPRESSION: -1,
Z_FILTERED: 1,
Z_HUFFMAN_ONLY: 2,
Z_RLE: 3,
Z_FIXED: 4,
Z_DEFAULT_STRATEGY: 0,
Z_BINARY: 0,
Z_TEXT: 1,
Z_UNKNOWN: 2,
Z_DEFLATED: 8
};
}
});
// node_modules/pako/lib/zlib/messages.js
var require_messages = __commonJS({
"node_modules/pako/lib/zlib/messages.js"(exports2, module2) {
"use strict";
module2.exports = {
2: "need dictionary",
1: "stream end",
0: "",
"-1": "file error",
"-2": "stream error",
"-3": "data error",
"-4": "insufficient memory",
"-5": "buffer error",
"-6": "incompatible version"
};
}
});
// node_modules/pako/lib/zlib/zstream.js
var require_zstream = __commonJS({
"node_modules/pako/lib/zlib/zstream.js"(exports2, module2) {
"use strict";
function ZStream() {
this.input = null;
this.next_in = 0;
this.avail_in = 0;
this.total_in = 0;
this.output = null;
this.next_out = 0;
this.avail_out = 0;
this.total_out = 0;
this.msg = "";
this.state = null;
this.data_type = 2;
this.adler = 0;
}
module2.exports = ZStream;
}
});
// node_modules/pako/lib/zlib/gzheader.js
var require_gzheader = __commonJS({
"node_modules/pako/lib/zlib/gzheader.js"(exports2, module2) {
"use strict";
function GZheader() {
this.text = 0;
this.time = 0;
this.xflags = 0;
this.os = 0;
this.extra = null;
this.extra_len = 0;
this.name = "";
this.comment = "";
this.hcrc = 0;
this.done = false;
}
module2.exports = GZheader;
}
});
// node_modules/pako/lib/inflate.js
var require_inflate2 = __commonJS({
"node_modules/pako/lib/inflate.js"(exports2) {
"use strict";
var zlib_inflate = require_inflate();
var utils = require_common();
var strings = require_strings();
var c = require_constants();
var msg = require_messages();
var ZStream = require_zstream();
var GZheader = require_gzheader();
var toString = Object.prototype.toString;
function Inflate(options) {
if (!(this instanceof Inflate))
return new Inflate(options);
this.options = utils.assign({
chunkSize: 16384,
windowBits: 0,
to: ""
}, options || {});
var opt = this.options;
if (opt.raw && opt.windowBits >= 0 && opt.windowBits < 16) {
opt.windowBits = -opt.windowBits;
if (opt.windowBits === 0) {
opt.windowBits = -15;
}
}
if (opt.windowBits >= 0 && opt.windowBits < 16 && !(options && options.windowBits)) {
opt.windowBits += 32;
}
if (opt.windowBits > 15 && opt.windowBits < 48) {
if ((opt.windowBits & 15) === 0) {
opt.windowBits |= 15;
}
}
this.err = 0;
this.msg = "";
this.ended = false;
this.chunks = [];
this.strm = new ZStream();
this.strm.avail_out = 0;
var status = zlib_inflate.inflateInit2(
this.strm,
opt.windowBits
);
if (status !== c.Z_OK) {
throw new Error(msg[status]);
}
this.header = new GZheader();
zlib_inflate.inflateGetHeader(this.strm, this.header);
if (opt.dictionary) {
if (typeof opt.dictionary === "string") {
opt.dictionary = strings.string2buf(opt.dictionary);
} else if (toString.call(opt.dictionary) === "[object ArrayBuffer]") {
opt.dictionary = new Uint8Array(opt.dictionary);
}
if (opt.raw) {
status = zlib_inflate.inflateSetDictionary(this.strm, opt.dictionary);
if (status !== c.Z_OK) {
throw new Error(msg[status]);
}
}
}
}
Inflate.prototype.push = function(data, mode2) {
var strm = this.strm;
var chunkSize = this.options.chunkSize;
var dictionary = this.options.dictionary;
var status, _mode;
var next_out_utf8, tail, utf8str;
var allowBufError = false;
if (this.ended) {
return false;
}
_mode = mode2 === ~~mode2 ? mode2 : mode2 === true ? c.Z_FINISH : c.Z_NO_FLUSH;
if (typeof data === "string") {
strm.input = strings.binstring2buf(data);
} else if (toString.call(data) === "[object ArrayBuffer]") {
strm.input = new Uint8Array(data);
} else {
strm.input = data;
}
strm.next_in = 0;
strm.avail_in = strm.input.length;
do {
if (strm.avail_out === 0) {
strm.output = new utils.Buf8(chunkSize);
strm.next_out = 0;
strm.avail_out = chunkSize;
}
status = zlib_inflate.inflate(strm, c.Z_NO_FLUSH);
if (status === c.Z_NEED_DICT && dictionary) {
status = zlib_inflate.inflateSetDictionary(this.strm, dictionary);
}
if (status === c.Z_BUF_ERROR && allowBufError === true) {
status = c.Z_OK;
allowBufError = false;
}
if (status !== c.Z_STREAM_END && status !== c.Z_OK) {
this.onEnd(status);
this.ended = true;
return false;
}
if (strm.next_out) {
if (strm.avail_out === 0 || status === c.Z_STREAM_END || strm.avail_in === 0 && (_mode === c.Z_FINISH || _mode === c.Z_SYNC_FLUSH)) {
if (this.options.to === "string") {
next_out_utf8 = strings.utf8border(strm.output, strm.next_out);
tail = strm.next_out - next_out_utf8;
utf8str = strings.buf2string(strm.output, next_out_utf8);
strm.next_out = tail;
strm.avail_out = chunkSize - tail;
if (tail) {
utils.arraySet(strm.output, strm.output, next_out_utf8, tail, 0);
}
this.onData(utf8str);
} else {
this.onData(utils.shrinkBuf(strm.output, strm.next_out));
}
}
}
if (strm.avail_in === 0 && strm.avail_out === 0) {
allowBufError = true;
}
} while ((strm.avail_in > 0 || strm.avail_out === 0) && status !== c.Z_STREAM_END);
if (status === c.Z_STREAM_END) {
_mode = c.Z_FINISH;
}
if (_mode === c.Z_FINISH) {
status = zlib_inflate.inflateEnd(this.strm);
this.onEnd(status);
this.ended = true;
return status === c.Z_OK;
}
if (_mode === c.Z_SYNC_FLUSH) {
this.onEnd(c.Z_OK);
strm.avail_out = 0;
return true;
}
return true;
};
Inflate.prototype.onData = function(chunk) {
this.chunks.push(chunk);
};
Inflate.prototype.onEnd = function(status) {
if (status === c.Z_OK) {
if (this.options.to === "string") {
this.result = this.chunks.join("");
} else {
this.result = utils.flattenChunks(this.chunks);
}
}
this.chunks = [];
this.err = status;
this.msg = this.strm.msg;
};
function inflate(input, options) {
var inflator = new Inflate(options);
inflator.push(input, true);
if (inflator.err) {
throw inflator.msg || msg[inflator.err];
}
return inflator.result;
}
function inflateRaw(input, options) {
options = options || {};
options.raw = true;
return inflate(input, options);
}
exports2.Inflate = Inflate;
exports2.inflate = inflate;
exports2.inflateRaw = inflateRaw;
exports2.ungzip = inflate;
}
});
// Source/Cesium.js
var Cesium_exports = {};
__export(Cesium_exports, {
AlphaMode: () => AlphaMode_default,
AlphaPipelineStage: () => AlphaPipelineStage_default,
Animation: () => Animation_default,
AnimationViewModel: () => AnimationViewModel_default,
Appearance: () => Appearance_default,
ApproximateTerrainHeights: () => ApproximateTerrainHeights_default,
ArcGISTiledElevationTerrainProvider: () => ArcGISTiledElevationTerrainProvider_default,
ArcGisMapServerImageryProvider: () => ArcGisMapServerImageryProvider_default,
ArcType: () => ArcType_default,
ArticulationStageType: () => ArticulationStageType_default,
AssociativeArray: () => AssociativeArray_default,
AttributeCompression: () => AttributeCompression_default,
AttributeType: () => AttributeType_default,
AutoExposure: () => AutoExposure_default,
Autolinker: () => import_autolinker.default,
AutomaticUniforms: () => AutomaticUniforms_default,
Axis: () => Axis_default,
AxisAlignedBoundingBox: () => AxisAlignedBoundingBox_default,
B3dmLoader: () => B3dmLoader_default,
B3dmParser: () => B3dmParser_default,
BaseLayerPicker: () => BaseLayerPicker_default,
BaseLayerPickerViewModel: () => BaseLayerPickerViewModel_default,
BatchTable: () => BatchTable_default,
BatchTableHierarchy: () => BatchTableHierarchy,
BatchTexture: () => BatchTexture,
BatchTexturePipelineStage: () => BatchTexturePipelineStage_default,
Batched3DModel3DTileContent: () => Batched3DModel3DTileContent_default,
Billboard: () => Billboard_default,
BillboardCollection: () => BillboardCollection_default,
BillboardGraphics: () => BillboardGraphics_default,
BillboardVisualizer: () => BillboardVisualizer_default,
BingMapsGeocoderService: () => BingMapsGeocoderService_default,
BingMapsImageryProvider: () => BingMapsImageryProvider_default,
BingMapsStyle: () => BingMapsStyle_default,
BlendEquation: () => BlendEquation_default,
BlendFunction: () => BlendFunction_default,
BlendOption: () => BlendOption_default,
BlendingState: () => BlendingState_default,
BoundingRectangle: () => BoundingRectangle_default,
BoundingSphere: () => BoundingSphere_default,
BoundingSphereState: () => BoundingSphereState_default,
BoxEmitter: () => BoxEmitter_default,
BoxGeometry: () => BoxGeometry_default,
BoxGeometryUpdater: () => BoxGeometryUpdater_default,
BoxGraphics: () => BoxGraphics_default,
BoxOutlineGeometry: () => BoxOutlineGeometry_default,
BrdfLutGenerator: () => BrdfLutGenerator_default,
Buffer: () => Buffer_default,
BufferLoader: () => BufferLoader,
BufferUsage: () => BufferUsage_default,
CPUStylingPipelineStage: () => CPUStylingPipelineStage_default,
CallbackProperty: () => CallbackProperty_default,
Camera: () => Camera_default,
CameraEventAggregator: () => CameraEventAggregator_default,
CameraEventType: () => CameraEventType_default,
CameraFlightPath: () => CameraFlightPath_default,
Cartesian2: () => Cartesian2_default,
Cartesian3: () => Cartesian3_default,
Cartesian4: () => Cartesian4_default,
Cartographic: () => Cartographic_default,
CartographicGeocoderService: () => CartographicGeocoderService_default,
CatmullRomSpline: () => CatmullRomSpline_default,
Cesium3DContentGroup: () => Cesium3DContentGroup,
Cesium3DTile: () => Cesium3DTile_default,
Cesium3DTileBatchTable: () => Cesium3DTileBatchTable_default,
Cesium3DTileColorBlendMode: () => Cesium3DTileColorBlendMode_default,
Cesium3DTileContent: () => Cesium3DTileContent_default,
Cesium3DTileContentFactory: () => Cesium3DTileContentFactory_default,
Cesium3DTileContentState: () => Cesium3DTileContentState_default,
Cesium3DTileContentType: () => Cesium3DTileContentType_default,
Cesium3DTileFeature: () => Cesium3DTileFeature_default,
Cesium3DTileFeatureTable: () => Cesium3DTileFeatureTable_default,
Cesium3DTileOptimizationHint: () => Cesium3DTileOptimizationHint_default,
Cesium3DTileOptimizations: () => Cesium3DTileOptimizations_default,
Cesium3DTilePass: () => Cesium3DTilePass_default,
Cesium3DTilePassState: () => Cesium3DTilePassState_default,
Cesium3DTilePointFeature: () => Cesium3DTilePointFeature_default,
Cesium3DTileRefine: () => Cesium3DTileRefine_default,
Cesium3DTileStyle: () => Cesium3DTileStyle_default,
Cesium3DTileStyleEngine: () => Cesium3DTileStyleEngine_default,
Cesium3DTilesInspector: () => Cesium3DTilesInspector_default,
Cesium3DTilesInspectorViewModel: () => Cesium3DTilesInspectorViewModel_default,
Cesium3DTileset: () => Cesium3DTileset_default,
Cesium3DTilesetCache: () => Cesium3DTilesetCache_default,
Cesium3DTilesetGraphics: () => Cesium3DTilesetGraphics_default,
Cesium3DTilesetHeatmap: () => Cesium3DTilesetHeatmap_default,
Cesium3DTilesetMetadata: () => Cesium3DTilesetMetadata_default,
Cesium3DTilesetMostDetailedTraversal: () => Cesium3DTilesetMostDetailedTraversal_default,
Cesium3DTilesetStatistics: () => Cesium3DTilesetStatistics_default,
Cesium3DTilesetTraversal: () => Cesium3DTilesetTraversal_default,
Cesium3DTilesetVisualizer: () => Cesium3DTilesetVisualizer_default,
CesiumInspector: () => CesiumInspector_default,
CesiumInspectorViewModel: () => CesiumInspectorViewModel_default,
CesiumTerrainProvider: () => CesiumTerrainProvider_default,
CesiumWidget: () => CesiumWidget_default,
Check: () => Check_default,
CheckerboardMaterialProperty: () => CheckerboardMaterialProperty_default,
CircleEmitter: () => CircleEmitter_default,
CircleGeometry: () => CircleGeometry_default,
CircleOutlineGeometry: () => CircleOutlineGeometry_default,
ClassificationModel: () => ClassificationModel_default,
ClassificationPrimitive: () => ClassificationPrimitive_default,
ClassificationType: () => ClassificationType_default,
ClearCommand: () => ClearCommand_default,
ClippingPlane: () => ClippingPlane_default,
ClippingPlaneCollection: () => ClippingPlaneCollection_default,
Clock: () => Clock_default,
ClockRange: () => ClockRange_default,
ClockStep: () => ClockStep_default,
ClockViewModel: () => ClockViewModel_default,
CloudCollection: () => CloudCollection_default,
CloudType: () => CloudType_default,
Color: () => Color_default,
ColorBlendMode: () => ColorBlendMode_default,
ColorGeometryInstanceAttribute: () => ColorGeometryInstanceAttribute_default,
ColorMaterialProperty: () => ColorMaterialProperty_default,
Command: () => Command_default,
ComponentDatatype: () => ComponentDatatype_default,
Composite3DTileContent: () => Composite3DTileContent_default,
CompositeEntityCollection: () => CompositeEntityCollection_default,
CompositeMaterialProperty: () => CompositeMaterialProperty_default,
CompositePositionProperty: () => CompositePositionProperty_default,
CompositeProperty: () => CompositeProperty_default,
CompressedTextureBuffer: () => CompressedTextureBuffer_default,
ComputeCommand: () => ComputeCommand_default,
ComputeEngine: () => ComputeEngine_default,
ConditionsExpression: () => ConditionsExpression_default,
ConeEmitter: () => ConeEmitter_default,
ConstantPositionProperty: () => ConstantPositionProperty_default,
ConstantProperty: () => ConstantProperty_default,
ConstantSpline: () => ConstantSpline_default,
ContentMetadata: () => ContentMetadata,
Context: () => Context_default,
ContextLimits: () => ContextLimits_default,
CoplanarPolygonGeometry: () => CoplanarPolygonGeometry_default,
CoplanarPolygonGeometryLibrary: () => CoplanarPolygonGeometryLibrary_default,
CoplanarPolygonOutlineGeometry: () => CoplanarPolygonOutlineGeometry_default,
CornerType: () => CornerType_default,
CorridorGeometry: () => CorridorGeometry_default,
CorridorGeometryLibrary: () => CorridorGeometryLibrary_default,
CorridorGeometryUpdater: () => CorridorGeometryUpdater_default,
CorridorGraphics: () => CorridorGraphics_default,
CorridorOutlineGeometry: () => CorridorOutlineGeometry_default,
Credit: () => Credit_default,
CreditDisplay: () => CreditDisplay_default,
CubeMap: () => CubeMap_default,
CubeMapFace: () => CubeMapFace_default,
CubicRealPolynomial: () => CubicRealPolynomial_default,
CullFace: () => CullFace_default,
CullingVolume: () => CullingVolume_default,
CumulusCloud: () => CumulusCloud_default,
CustomDataSource: () => CustomDataSource_default,
CustomHeightmapTerrainProvider: () => CustomHeightmapTerrainProvider_default,
CustomShader: () => CustomShader,
CustomShaderMode: () => CustomShaderMode_default,
CustomShaderPipelineStage: () => CustomShaderPipelineStage_default,
CylinderGeometry: () => CylinderGeometry_default,
CylinderGeometryLibrary: () => CylinderGeometryLibrary_default,
CylinderGeometryUpdater: () => CylinderGeometryUpdater_default,
CylinderGraphics: () => CylinderGraphics_default,
CylinderOutlineGeometry: () => CylinderOutlineGeometry_default,
CzmlDataSource: () => CzmlDataSource_default,
DataSource: () => DataSource_default,
DataSourceClock: () => DataSourceClock_default,
DataSourceCollection: () => DataSourceCollection_default,
DataSourceDisplay: () => DataSourceDisplay_default,
DebugAppearance: () => DebugAppearance_default,
DebugCameraPrimitive: () => DebugCameraPrimitive_default,
DebugInspector: () => DebugInspector_default,
DebugModelMatrixPrimitive: () => DebugModelMatrixPrimitive_default,
DefaultProxy: () => DefaultProxy_default,
DepthFunction: () => DepthFunction_default,
DepthPlane: () => DepthPlane_default,
DequantizationPipelineStage: () => DequantizationPipelineStage_default,
DerivedCommand: () => DerivedCommand_default,
DeveloperError: () => DeveloperError_default,
DeviceOrientationCameraController: () => DeviceOrientationCameraController_default,
DirectionalLight: () => DirectionalLight_default,
DiscardEmptyTileImagePolicy: () => DiscardEmptyTileImagePolicy_default,
DiscardMissingTileImagePolicy: () => DiscardMissingTileImagePolicy_default,
DistanceDisplayCondition: () => DistanceDisplayCondition_default,
DistanceDisplayConditionGeometryInstanceAttribute: () => DistanceDisplayConditionGeometryInstanceAttribute_default,
DoubleEndedPriorityQueue: () => DoubleEndedPriorityQueue_default,
DoublyLinkedList: () => DoublyLinkedList_default,
DracoLoader: () => DracoLoader_default,
DrawCommand: () => DrawCommand_default,
DynamicGeometryBatch: () => DynamicGeometryBatch_default,
DynamicGeometryUpdater: () => DynamicGeometryUpdater_default,
EarthOrientationParameters: () => EarthOrientationParameters_default,
EarthOrientationParametersSample: () => EarthOrientationParametersSample_default,
EasingFunction: () => EasingFunction_default,
EllipseGeometry: () => EllipseGeometry_default,
EllipseGeometryLibrary: () => EllipseGeometryLibrary_default,
EllipseGeometryUpdater: () => EllipseGeometryUpdater_default,
EllipseGraphics: () => EllipseGraphics_default,
EllipseOutlineGeometry: () => EllipseOutlineGeometry_default,
Ellipsoid: () => Ellipsoid_default,
EllipsoidGeodesic: () => EllipsoidGeodesic_default,
EllipsoidGeometry: () => EllipsoidGeometry_default,
EllipsoidGeometryUpdater: () => EllipsoidGeometryUpdater_default,
EllipsoidGraphics: () => EllipsoidGraphics_default,
EllipsoidOutlineGeometry: () => EllipsoidOutlineGeometry_default,
EllipsoidPrimitive: () => EllipsoidPrimitive_default,
EllipsoidRhumbLine: () => EllipsoidRhumbLine_default,
EllipsoidSurfaceAppearance: () => EllipsoidSurfaceAppearance_default,
EllipsoidTangentPlane: () => EllipsoidTangentPlane_default,
EllipsoidTerrainProvider: () => EllipsoidTerrainProvider_default,
EllipsoidalOccluder: () => EllipsoidalOccluder_default,
Empty3DTileContent: () => Empty3DTileContent_default,
EncodedCartesian3: () => EncodedCartesian3_default,
Entity: () => Entity_default,
EntityCluster: () => EntityCluster_default,
EntityCollection: () => EntityCollection_default,
EntityView: () => EntityView_default,
Event: () => Event_default,
EventHelper: () => EventHelper_default,
ExperimentalFeatures: () => ExperimentalFeatures_default,
Expression: () => Expression_default,
ExpressionNodeType: () => ExpressionNodeType_default,
ExtrapolationType: () => ExtrapolationType_default,
FeatureDetection: () => FeatureDetection_default,
FeatureIdPipelineStage: () => FeatureIdPipelineStage_default,
Fog: () => Fog_default,
ForEach: () => ForEach_default,
FrameRateMonitor: () => FrameRateMonitor_default,
FrameState: () => FrameState_default,
Framebuffer: () => Framebuffer_default,
FramebufferManager: () => FramebufferManager_default,
FrustumCommands: () => FrustumCommands_default,
FrustumGeometry: () => FrustumGeometry_default,
FrustumOutlineGeometry: () => FrustumOutlineGeometry_default,
Fullscreen: () => Fullscreen_default,
FullscreenButton: () => FullscreenButton_default,
FullscreenButtonViewModel: () => FullscreenButtonViewModel_default,
GeoJsonDataSource: () => GeoJsonDataSource_default,
GeoJsonLoader: () => GeoJsonLoader,
GeocodeType: () => GeocodeType_default,
Geocoder: () => Geocoder_default,
GeocoderService: () => GeocoderService_default,
GeocoderViewModel: () => GeocoderViewModel_default,
GeographicProjection: () => GeographicProjection_default,
GeographicTilingScheme: () => GeographicTilingScheme_default,
Geometry: () => Geometry_default,
Geometry3DTileContent: () => Geometry3DTileContent_default,
GeometryAttribute: () => GeometryAttribute_default,
GeometryAttributes: () => GeometryAttributes_default,
GeometryFactory: () => GeometryFactory_default,
GeometryInstance: () => GeometryInstance_default,
GeometryInstanceAttribute: () => GeometryInstanceAttribute_default,
GeometryOffsetAttribute: () => GeometryOffsetAttribute_default,
GeometryPipeline: () => GeometryPipeline_default,
GeometryPipelineStage: () => GeometryPipelineStage_default,
GeometryType: () => GeometryType_default,
GeometryUpdater: () => GeometryUpdater_default,
GeometryVisualizer: () => GeometryVisualizer_default,
GetFeatureInfoFormat: () => GetFeatureInfoFormat_default,
Globe: () => Globe_default,
GlobeDepth: () => GlobeDepth_default,
GlobeSurfaceShaderSet: () => GlobeSurfaceShaderSet_default,
GlobeSurfaceTile: () => GlobeSurfaceTile_default,
GlobeSurfaceTileProvider: () => GlobeSurfaceTileProvider_default,
GlobeTranslucency: () => GlobeTranslucency_default,
GlobeTranslucencyFramebuffer: () => GlobeTranslucencyFramebuffer_default,
GlobeTranslucencyState: () => GlobeTranslucencyState_default,
GltfBufferViewLoader: () => GltfBufferViewLoader,
GltfDracoLoader: () => GltfDracoLoader,
GltfImageLoader: () => GltfImageLoader,
GltfIndexBufferLoader: () => GltfIndexBufferLoader,
GltfJsonLoader: () => GltfJsonLoader,
GltfLoader: () => GltfLoader,
GltfLoaderUtil: () => GltfLoaderUtil_default,
GltfStructuralMetadataLoader: () => GltfStructuralMetadataLoader,
GltfTextureLoader: () => GltfTextureLoader,
GltfVertexBufferLoader: () => GltfVertexBufferLoader,
GoogleEarthEnterpriseImageryProvider: () => GoogleEarthEnterpriseImageryProvider_default,
GoogleEarthEnterpriseMapsProvider: () => GoogleEarthEnterpriseMapsProvider_default,
GoogleEarthEnterpriseMetadata: () => GoogleEarthEnterpriseMetadata_default,
GoogleEarthEnterpriseTerrainData: () => GoogleEarthEnterpriseTerrainData_default,
GoogleEarthEnterpriseTerrainProvider: () => GoogleEarthEnterpriseTerrainProvider_default,
GoogleEarthEnterpriseTileInformation: () => GoogleEarthEnterpriseTileInformation_default,
GpxDataSource: () => GpxDataSource_default,
GregorianDate: () => GregorianDate_default,
GridImageryProvider: () => GridImageryProvider_default,
GridMaterialProperty: () => GridMaterialProperty_default,
GroundGeometryUpdater: () => GroundGeometryUpdater_default,
GroundPolylineGeometry: () => GroundPolylineGeometry_default,
GroundPolylinePrimitive: () => GroundPolylinePrimitive_default,
GroundPrimitive: () => GroundPrimitive_default,
GroupMetadata: () => GroupMetadata_default,
HeadingPitchRange: () => HeadingPitchRange_default,
HeadingPitchRoll: () => HeadingPitchRoll_default,
Heap: () => Heap_default,
HeightReference: () => HeightReference_default,
HeightmapEncoding: () => HeightmapEncoding_default,
HeightmapTerrainData: () => HeightmapTerrainData_default,
HeightmapTessellator: () => HeightmapTessellator_default,
HermitePolynomialApproximation: () => HermitePolynomialApproximation_default,
HermiteSpline: () => HermiteSpline_default,
HilbertOrder: () => HilbertOrder_default,
HomeButton: () => HomeButton_default,
HomeButtonViewModel: () => HomeButtonViewModel_default,
HorizontalOrigin: () => HorizontalOrigin_default,
I3dmLoader: () => I3dmLoader_default,
I3dmParser: () => I3dmParser_default,
Iau2000Orientation: () => Iau2000Orientation_default,
Iau2006XysData: () => Iau2006XysData_default,
Iau2006XysSample: () => Iau2006XysSample_default,
IauOrientationAxes: () => IauOrientationAxes_default,
IauOrientationParameters: () => IauOrientationParameters_default,
ImageBasedLighting: () => ImageBasedLighting,
ImageBasedLightingPipelineStage: () => ImageBasedLightingPipelineStage_default,
ImageMaterialProperty: () => ImageMaterialProperty_default,
Imagery: () => Imagery_default,
ImageryLayer: () => ImageryLayer_default,
ImageryLayerCollection: () => ImageryLayerCollection_default,
ImageryLayerFeatureInfo: () => ImageryLayerFeatureInfo_default,
ImageryProvider: () => ImageryProvider_default,
ImageryState: () => ImageryState_default,
Implicit3DTileContent: () => Implicit3DTileContent,
ImplicitAvailabilityBitstream: () => ImplicitAvailabilityBitstream,
ImplicitMetadataView: () => ImplicitMetadataView,
ImplicitSubdivisionScheme: () => ImplicitSubdivisionScheme_default,
ImplicitSubtree: () => ImplicitSubtree,
ImplicitSubtreeMetadata: () => ImplicitSubtreeMetadata_default,
ImplicitTileCoordinates: () => ImplicitTileCoordinates,
ImplicitTileset: () => ImplicitTileset,
IndexDatatype: () => IndexDatatype_default,
InfoBox: () => InfoBox_default,
InfoBoxViewModel: () => InfoBoxViewModel_default,
InspectorShared: () => InspectorShared_default,
InstanceAttributeSemantic: () => InstanceAttributeSemantic_default,
Instanced3DModel3DTileContent: () => Instanced3DModel3DTileContent_default,
InstancingPipelineStage: () => InstancingPipelineStage_default,
InterpolationAlgorithm: () => InterpolationAlgorithm_default,
InterpolationType: () => InterpolationType_default,
Intersect: () => Intersect_default,
IntersectionTests: () => IntersectionTests_default,
Intersections2D: () => Intersections2D_default,
Interval: () => Interval_default,
InvertClassification: () => InvertClassification_default,
Ion: () => Ion_default,
IonGeocoderService: () => IonGeocoderService_default,
IonImageryProvider: () => IonImageryProvider_default,
IonResource: () => IonResource_default,
IonWorldImageryStyle: () => IonWorldImageryStyle_default,
Iso8601: () => Iso8601_default,
JobScheduler: () => JobScheduler_default,
JobType: () => JobType_default,
JsonMetadataTable: () => JsonMetadataTable,
JulianDate: () => JulianDate_default,
KTX2Transcoder: () => KTX2Transcoder_default,
KeyboardEventModifier: () => KeyboardEventModifier_default,
KmlCamera: () => KmlCamera_default,
KmlDataSource: () => KmlDataSource_default,
KmlLookAt: () => KmlLookAt_default,
KmlTour: () => KmlTour_default,
KmlTourFlyTo: () => KmlTourFlyTo_default,
KmlTourWait: () => KmlTourWait_default,
Label: () => Label_default,
LabelCollection: () => LabelCollection_default,
LabelGraphics: () => LabelGraphics_default,
LabelStyle: () => LabelStyle_default,
LabelVisualizer: () => LabelVisualizer_default,
LagrangePolynomialApproximation: () => LagrangePolynomialApproximation_default,
LeapSecond: () => LeapSecond_default,
Light: () => Light_default,
LightingModel: () => LightingModel_default,
LightingPipelineStage: () => LightingPipelineStage_default,
LinearApproximation: () => LinearApproximation_default,
LinearSpline: () => LinearSpline_default,
ManagedArray: () => ManagedArray_default,
MapMode2D: () => MapMode2D_default,
MapProjection: () => MapProjection_default,
MapboxImageryProvider: () => MapboxImageryProvider_default,
MapboxStyleImageryProvider: () => MapboxStyleImageryProvider_default,
Material: () => Material_default,
MaterialAppearance: () => MaterialAppearance_default,
MaterialPipelineStage: () => MaterialPipelineStage_default,
MaterialProperty: () => MaterialProperty_default,
Math: () => Math_default,
Matrix2: () => Matrix2_default,
Matrix3: () => Matrix3_default,
Matrix4: () => Matrix4_default,
MetadataClass: () => MetadataClass_default,
MetadataClassProperty: () => MetadataClassProperty_default,
MetadataComponentType: () => MetadataComponentType_default,
MetadataEntity: () => MetadataEntity_default,
MetadataEnum: () => MetadataEnum_default,
MetadataEnumValue: () => MetadataEnumValue_default,
MetadataPipelineStage: () => MetadataPipelineStage_default,
MetadataSchema: () => MetadataSchema_default,
MetadataSchemaLoader: () => MetadataSchemaLoader,
MetadataSemantic: () => MetadataSemantic_default,
MetadataTable: () => MetadataTable_default,
MetadataTableProperty: () => MetadataTableProperty_default,
MetadataType: () => MetadataType_default,
MipmapHint: () => MipmapHint_default,
Model: () => Model_default,
ModelAlphaOptions: () => ModelAlphaOptions,
ModelAnimation: () => ModelAnimation_default,
ModelAnimationCache: () => ModelAnimationCache_default,
ModelAnimationCollection: () => ModelAnimationCollection_default,
ModelAnimationLoop: () => ModelAnimationLoop_default,
ModelAnimationState: () => ModelAnimationState_default,
ModelClippingPlanesPipelineStage: () => ModelClippingPlanesPipelineStage_default,
ModelColorPipelineStage: () => ModelColorPipelineStage_default,
ModelComponents: () => ModelComponents_default,
ModelExperimental: () => ModelExperimental,
ModelExperimental3DTileContent: () => ModelExperimental3DTileContent,
ModelExperimentalAnimation: () => ModelExperimentalAnimation_default,
ModelExperimentalAnimationChannel: () => ModelExperimentalAnimationChannel_default,
ModelExperimentalAnimationCollection: () => ModelExperimentalAnimationCollection_default,
ModelExperimentalArticulation: () => ModelExperimentalArticulation,
ModelExperimentalArticulationStage: () => ModelExperimentalArticulationStage,
ModelExperimentalDrawCommand: () => ModelExperimentalDrawCommand_default,
ModelExperimentalNode: () => ModelExperimentalNode,
ModelExperimentalRuntimeNode: () => ModelExperimentalRuntimeNode,
ModelExperimentalRuntimePrimitive: () => ModelExperimentalRuntimePrimitive,
ModelExperimentalSceneGraph: () => ModelExperimentalSceneGraph,
ModelExperimentalSkin: () => ModelExperimentalSkin,
ModelExperimentalStatistics: () => ModelExperimentalStatistics,
ModelExperimentalType: () => ModelExperimentalType_default,
ModelExperimentalUtility: () => ModelExperimentalUtility,
ModelFeature: () => ModelFeature,
ModelFeatureTable: () => ModelFeatureTable,
ModelGraphics: () => ModelGraphics_default,
ModelInstance: () => ModelInstance_default,
ModelInstanceCollection: () => ModelInstanceCollection_default,
ModelLightingOptions: () => ModelLightingOptions,
ModelLoadResources: () => ModelLoadResources_default,
ModelMaterial: () => ModelMaterial_default,
ModelMatrixUpdateStage: () => ModelMatrixUpdateStage_default,
ModelMesh: () => ModelMesh_default,
ModelNode: () => ModelNode_default,
ModelOutlineLoader: () => ModelOutlineLoader_default,
ModelRenderResources: () => ModelRenderResources,
ModelSilhouettePipelineStage: () => ModelSilhouettePipelineStage_default,
ModelSplitterPipelineStage: () => ModelSplitterPipelineStage_default,
ModelUtility: () => ModelUtility_default,
ModelVisualizer: () => ModelVisualizer_default,
Moon: () => Moon_default,
MorphTargetsPipelineStage: () => MorphTargetsPipelineStage_default,
MorphWeightSpline: () => MorphWeightSpline_default,
MortonOrder: () => MortonOrder_default,
Multiple3DTileContent: () => Multiple3DTileContent,
MultisampleFramebuffer: () => MultisampleFramebuffer_default,
NavigationHelpButton: () => NavigationHelpButton_default,
NavigationHelpButtonViewModel: () => NavigationHelpButtonViewModel_default,
NearFarScalar: () => NearFarScalar_default,
NeverTileDiscardPolicy: () => NeverTileDiscardPolicy_default,
NodeRenderResources: () => NodeRenderResources,
NodeStatisticsPipelineStage: () => NodeStatisticsPipelineStage_default,
NodeTransformationProperty: () => NodeTransformationProperty_default,
OIT: () => OIT_default,
Occluder: () => Occluder_default,
OctahedralProjectedCubeMap: () => OctahedralProjectedCubeMap_default,
OffsetGeometryInstanceAttribute: () => OffsetGeometryInstanceAttribute_default,
OpenCageGeocoderService: () => OpenCageGeocoderService_default,
OpenStreetMapImageryProvider: () => OpenStreetMapImageryProvider_default,
OrderedGroundPrimitiveCollection: () => OrderedGroundPrimitiveCollection_default,
OrientedBoundingBox: () => OrientedBoundingBox_default,
OrthographicFrustum: () => OrthographicFrustum_default,
OrthographicOffCenterFrustum: () => OrthographicOffCenterFrustum_default,
Packable: () => Packable_default,
PackableForInterpolation: () => PackableForInterpolation_default,
Particle: () => Particle_default,
ParticleBurst: () => ParticleBurst_default,
ParticleEmitter: () => ParticleEmitter_default,
ParticleSystem: () => ParticleSystem_default,
Pass: () => Pass_default,
PassState: () => PassState_default,
PathGraphics: () => PathGraphics_default,
PathVisualizer: () => PathVisualizer_default,
PeliasGeocoderService: () => PeliasGeocoderService_default,
PerInstanceColorAppearance: () => PerInstanceColorAppearance_default,
PerformanceDisplay: () => PerformanceDisplay_default,
PerformanceWatchdog: () => PerformanceWatchdog_default,
PerformanceWatchdogViewModel: () => PerformanceWatchdogViewModel_default,
PerspectiveFrustum: () => PerspectiveFrustum_default,
PerspectiveOffCenterFrustum: () => PerspectiveOffCenterFrustum_default,
PickDepth: () => PickDepth_default,
PickDepthFramebuffer: () => PickDepthFramebuffer_default,
PickFramebuffer: () => PickFramebuffer_default,
Picking: () => Picking_default,
PickingPipelineStage: () => PickingPipelineStage_default,
PinBuilder: () => PinBuilder_default,
PixelDatatype: () => PixelDatatype_default,
PixelFormat: () => PixelFormat_default,
Plane: () => Plane_default,
PlaneGeometry: () => PlaneGeometry_default,
PlaneGeometryUpdater: () => PlaneGeometryUpdater_default,
PlaneGraphics: () => PlaneGraphics_default,
PlaneOutlineGeometry: () => PlaneOutlineGeometry_default,
PntsLoader: () => PntsLoader,
PntsParser: () => PntsParser_default,
PointCloud: () => PointCloud_default,
PointCloud3DTileContent: () => PointCloud3DTileContent_default,
PointCloudEyeDomeLighting: () => PointCloudEyeDomeLighting_default2,
PointCloudShading: () => PointCloudShading_default,
PointCloudStylingPipelineStage: () => PointCloudStylingPipelineStage_default,
PointGraphics: () => PointGraphics_default,
PointPrimitive: () => PointPrimitive_default,
PointPrimitiveCollection: () => PointPrimitiveCollection_default,
PointVisualizer: () => PointVisualizer_default,
PolygonGeometry: () => PolygonGeometry_default,
PolygonGeometryLibrary: () => PolygonGeometryLibrary_default,
PolygonGeometryUpdater: () => PolygonGeometryUpdater_default,
PolygonGraphics: () => PolygonGraphics_default,
PolygonHierarchy: () => PolygonHierarchy_default,
PolygonOutlineGeometry: () => PolygonOutlineGeometry_default,
PolygonPipeline: () => PolygonPipeline_default,
Polyline: () => Polyline_default,
PolylineArrowMaterialProperty: () => PolylineArrowMaterialProperty_default,
PolylineCollection: () => PolylineCollection_default,
PolylineColorAppearance: () => PolylineColorAppearance_default,
PolylineDashMaterialProperty: () => PolylineDashMaterialProperty_default,
PolylineGeometry: () => PolylineGeometry_default,
PolylineGeometryUpdater: () => PolylineGeometryUpdater_default,
PolylineGlowMaterialProperty: () => PolylineGlowMaterialProperty_default,
PolylineGraphics: () => PolylineGraphics_default,
PolylineMaterialAppearance: () => PolylineMaterialAppearance_default,
PolylineOutlineMaterialProperty: () => PolylineOutlineMaterialProperty_default,
PolylinePipeline: () => PolylinePipeline_default,
PolylineVisualizer: () => PolylineVisualizer_default,
PolylineVolumeGeometry: () => PolylineVolumeGeometry_default,
PolylineVolumeGeometryLibrary: () => PolylineVolumeGeometryLibrary_default,
PolylineVolumeGeometryUpdater: () => PolylineVolumeGeometryUpdater_default,
PolylineVolumeGraphics: () => PolylineVolumeGraphics_default,
PolylineVolumeOutlineGeometry: () => PolylineVolumeOutlineGeometry_default,
PositionProperty: () => PositionProperty_default,
PositionPropertyArray: () => PositionPropertyArray_default,
PostProcessStage: () => PostProcessStage_default,
PostProcessStageCollection: () => PostProcessStageCollection_default,
PostProcessStageComposite: () => PostProcessStageComposite_default,
PostProcessStageLibrary: () => PostProcessStageLibrary_default,
PostProcessStageSampleMode: () => PostProcessStageSampleMode_default,
PostProcessStageTextureCache: () => PostProcessStageTextureCache_default,
Primitive: () => Primitive_default,
PrimitiveCollection: () => PrimitiveCollection_default,
PrimitiveLoadPlan: () => PrimitiveLoadPlan_default,
PrimitiveOutlineGenerator: () => PrimitiveOutlineGenerator,
PrimitiveOutlinePipelineStage: () => PrimitiveOutlinePipelineStage_default,
PrimitivePipeline: () => PrimitivePipeline_default,
PrimitiveRenderResources: () => PrimitiveRenderResources,
PrimitiveState: () => PrimitiveState_default,
PrimitiveStatisticsPipelineStage: () => PrimitiveStatisticsPipelineStage_default,
PrimitiveType: () => PrimitiveType_default,
ProjectionPicker: () => ProjectionPicker_default,
ProjectionPickerViewModel: () => ProjectionPickerViewModel_default,
Property: () => Property_default,
PropertyArray: () => PropertyArray_default,
PropertyAttribute: () => PropertyAttribute,
PropertyAttributeProperty: () => PropertyAttributeProperty,
PropertyBag: () => PropertyBag_default,
PropertyTable: () => PropertyTable_default,
PropertyTexture: () => PropertyTexture_default,
PropertyTextureProperty: () => PropertyTextureProperty_default,
ProviderViewModel: () => ProviderViewModel_default,
Proxy: () => Proxy_default,
QuadraticRealPolynomial: () => QuadraticRealPolynomial_default,
QuadtreeOccluders: () => QuadtreeOccluders_default,
QuadtreePrimitive: () => QuadtreePrimitive_default,
QuadtreeTile: () => QuadtreeTile_default,
QuadtreeTileLoadState: () => QuadtreeTileLoadState_default,
QuadtreeTileProvider: () => QuadtreeTileProvider_default,
QuantizedMeshTerrainData: () => QuantizedMeshTerrainData_default,
QuarticRealPolynomial: () => QuarticRealPolynomial_default,
Quaternion: () => Quaternion_default,
QuaternionSpline: () => QuaternionSpline_default,
Queue: () => Queue_default,
Ray: () => Ray_default,
Rectangle: () => Rectangle_default,
RectangleCollisionChecker: () => RectangleCollisionChecker_default,
RectangleGeometry: () => RectangleGeometry_default,
RectangleGeometryLibrary: () => RectangleGeometryLibrary_default,
RectangleGeometryUpdater: () => RectangleGeometryUpdater_default,
RectangleGraphics: () => RectangleGraphics_default,
RectangleOutlineGeometry: () => RectangleOutlineGeometry_default,
ReferenceFrame: () => ReferenceFrame_default,
ReferenceProperty: () => ReferenceProperty_default,
RenderState: () => RenderState_default,
Renderbuffer: () => Renderbuffer_default,
RenderbufferFormat: () => RenderbufferFormat_default,
Request: () => Request_default,
RequestErrorEvent: () => RequestErrorEvent_default,
RequestScheduler: () => RequestScheduler_default,
RequestState: () => RequestState_default,
RequestType: () => RequestType_default,
Resource: () => Resource_default,
ResourceCache: () => ResourceCache_default,
ResourceCacheKey: () => ResourceCacheKey_default,
ResourceCacheStatistics: () => ResourceCacheStatistics,
ResourceLoader: () => ResourceLoader,
ResourceLoaderState: () => ResourceLoaderState_default,
Rotation: () => Rotation_default,
RuntimeError: () => RuntimeError_default,
S2Cell: () => S2Cell_default,
SDFSettings: () => SDFSettings_default,
SampledPositionProperty: () => SampledPositionProperty_default,
SampledProperty: () => SampledProperty_default,
Sampler: () => Sampler_default,
ScaledPositionProperty: () => ScaledPositionProperty_default,
Scene: () => Scene_default,
SceneFramebuffer: () => SceneFramebuffer_default,
SceneMode: () => SceneMode_default,
SceneMode2DPipelineStage: () => SceneMode2DPipelineStage_default,
SceneModePicker: () => SceneModePicker_default,
SceneModePickerViewModel: () => SceneModePickerViewModel_default,
SceneTransforms: () => SceneTransforms_default,
SceneTransitioner: () => SceneTransitioner_default,
ScreenSpaceCameraController: () => ScreenSpaceCameraController_default,
ScreenSpaceEventHandler: () => ScreenSpaceEventHandler_default,
ScreenSpaceEventType: () => ScreenSpaceEventType_default,
SelectedFeatureIdPipelineStage: () => SelectedFeatureIdPipelineStage_default,
SelectionIndicator: () => SelectionIndicator_default,
SelectionIndicatorViewModel: () => SelectionIndicatorViewModel_default,
ShaderBuilder: () => ShaderBuilder,
ShaderCache: () => ShaderCache_default,
ShaderDestination: () => ShaderDestination_default,
ShaderFunction: () => ShaderFunction,
ShaderProgram: () => ShaderProgram_default,
ShaderSource: () => ShaderSource_default,
ShaderStruct: () => ShaderStruct,
ShadowMap: () => ShadowMap_default,
ShadowMapShader: () => ShadowMapShader_default,
ShadowMode: () => ShadowMode_default,
ShadowVolumeAppearance: () => ShadowVolumeAppearance_default,
ShowGeometryInstanceAttribute: () => ShowGeometryInstanceAttribute_default,
Simon1994PlanetaryPositions: () => Simon1994PlanetaryPositions_default,
SimplePolylineGeometry: () => SimplePolylineGeometry_default,
SingleTileImageryProvider: () => SingleTileImageryProvider_default,
SkinningPipelineStage: () => SkinningPipelineStage_default,
SkyAtmosphere: () => SkyAtmosphere_default,
SkyBox: () => SkyBox_default,
SphereEmitter: () => SphereEmitter_default,
SphereGeometry: () => SphereGeometry_default,
SphereOutlineGeometry: () => SphereOutlineGeometry_default,
Spherical: () => Spherical_default,
Spline: () => Spline_default,
SplitDirection: () => SplitDirection_default,
Splitter: () => Splitter_default,
StaticGeometryColorBatch: () => StaticGeometryColorBatch_default,
StaticGeometryPerMaterialBatch: () => StaticGeometryPerMaterialBatch_default,
StaticGroundGeometryColorBatch: () => StaticGroundGeometryColorBatch_default,
StaticGroundGeometryPerMaterialBatch: () => StaticGroundGeometryPerMaterialBatch_default,
StaticGroundPolylinePerMaterialBatch: () => StaticGroundPolylinePerMaterialBatch_default,
StaticOutlineGeometryBatch: () => StaticOutlineGeometryBatch_default,
StencilConstants: () => StencilConstants_default,
StencilFunction: () => StencilFunction_default,
StencilOperation: () => StencilOperation_default,
SteppedSpline: () => SteppedSpline_default,
StripeMaterialProperty: () => StripeMaterialProperty_default,
StripeOrientation: () => StripeOrientation_default,
StructuralMetadata: () => StructuralMetadata_default,
StyleCommandsNeeded: () => StyleCommandsNeeded_default,
StyleExpression: () => StyleExpression_default,
Sun: () => Sun_default,
SunLight: () => SunLight_default,
SunPostProcess: () => SunPostProcess_default,
SupportedImageFormats: () => SupportedImageFormats,
SvgPathBindingHandler: () => SvgPathBindingHandler_default,
TaskProcessor: () => TaskProcessor_default,
TerrainData: () => TerrainData_default,
TerrainEncoding: () => TerrainEncoding_default,
TerrainExaggeration: () => TerrainExaggeration_default,
TerrainFillMesh: () => TerrainFillMesh_default,
TerrainMesh: () => TerrainMesh_default,
TerrainOffsetProperty: () => TerrainOffsetProperty_default,
TerrainProvider: () => TerrainProvider_default,
TerrainQuantization: () => TerrainQuantization_default,
TerrainState: () => TerrainState_default,
Texture: () => Texture_default,
TextureAtlas: () => TextureAtlas_default,
TextureCache: () => TextureCache_default,
TextureMagnificationFilter: () => TextureMagnificationFilter_default,
TextureManager: () => TextureManager,
TextureMinificationFilter: () => TextureMinificationFilter_default,
TextureUniform: () => TextureUniform,
TextureWrap: () => TextureWrap_default,
TileAvailability: () => TileAvailability_default,
TileBoundingRegion: () => TileBoundingRegion_default,
TileBoundingS2Cell: () => TileBoundingS2Cell_default,
TileBoundingSphere: () => TileBoundingSphere_default,
TileBoundingVolume: () => TileBoundingVolume_default,
TileCoordinatesImageryProvider: () => TileCoordinatesImageryProvider_default,
TileDiscardPolicy: () => TileDiscardPolicy_default,
TileEdge: () => TileEdge_default,
TileImagery: () => TileImagery_default,
TileMapServiceImageryProvider: () => TileMapServiceImageryProvider_default,
TileMetadata: () => TileMetadata,
TileOrientedBoundingBox: () => TileOrientedBoundingBox_default,
TileProviderError: () => TileProviderError_default,
TileReplacementQueue: () => TileReplacementQueue_default,
TileSelectionResult: () => TileSelectionResult_default,
TileState: () => TileState_default,
Tileset3DTileContent: () => Tileset3DTileContent_default,
TilesetMetadata: () => TilesetMetadata_default,
TilingScheme: () => TilingScheme_default,
TimeConstants: () => TimeConstants_default,
TimeDynamicImagery: () => TimeDynamicImagery_default,
TimeDynamicPointCloud: () => TimeDynamicPointCloud_default,
TimeInterval: () => TimeInterval_default,
TimeIntervalCollection: () => TimeIntervalCollection_default,
TimeIntervalCollectionPositionProperty: () => TimeIntervalCollectionPositionProperty_default,
TimeIntervalCollectionProperty: () => TimeIntervalCollectionProperty_default,
TimeStandard: () => TimeStandard_default,
Timeline: () => Timeline_default,
TimelineHighlightRange: () => TimelineHighlightRange_default,
TimelineTrack: () => TimelineTrack_default,
Tipsify: () => Tipsify_default,
ToggleButtonViewModel: () => ToggleButtonViewModel_default,
Tonemapper: () => Tonemapper_default,
Transforms: () => Transforms_default,
TranslationRotationScale: () => TranslationRotationScale_default,
TranslucentTileClassification: () => TranslucentTileClassification_default,
TridiagonalSystemSolver: () => TridiagonalSystemSolver_default,
TrustedServers: () => TrustedServers_default,
Tween: () => import_tween.default,
TweenCollection: () => TweenCollection_default,
UniformState: () => UniformState_default,
UniformType: () => UniformType_default,
Uri: () => import_urijs.default,
UrlTemplateImageryProvider: () => UrlTemplateImageryProvider_default,
VERSION: () => VERSION,
VRButton: () => VRButton_default,
VRButtonViewModel: () => VRButtonViewModel_default,
VRTheWorldTerrainProvider: () => VRTheWorldTerrainProvider_default,
VaryingType: () => VaryingType_default,
Vector3DTileBatch: () => Vector3DTileBatch_default,
Vector3DTileClampedPolylines: () => Vector3DTileClampedPolylines_default,
Vector3DTileContent: () => Vector3DTileContent_default,
Vector3DTileGeometry: () => Vector3DTileGeometry_default,
Vector3DTilePoints: () => Vector3DTilePoints_default,
Vector3DTilePolygons: () => Vector3DTilePolygons_default,
Vector3DTilePolylines: () => Vector3DTilePolylines_default,
Vector3DTilePrimitive: () => Vector3DTilePrimitive_default,
VelocityOrientationProperty: () => VelocityOrientationProperty_default,
VelocityVectorProperty: () => VelocityVectorProperty_default,
VertexArray: () => VertexArray_default,
VertexArrayFacade: () => VertexArrayFacade_default,
VertexAttributeSemantic: () => VertexAttributeSemantic_default,
VertexFormat: () => VertexFormat_default,
VerticalOrigin: () => VerticalOrigin_default,
VideoSynchronizer: () => VideoSynchronizer_default,
View: () => View_default,
Viewer: () => Viewer_default,
ViewportQuad: () => ViewportQuad_default,
Visibility: () => Visibility_default,
Visualizer: () => Visualizer_default,
VulkanConstants: () => VulkanConstants_default,
WallGeometry: () => WallGeometry_default,
WallGeometryLibrary: () => WallGeometryLibrary_default,
WallGeometryUpdater: () => WallGeometryUpdater_default,
WallGraphics: () => WallGraphics_default,
WallOutlineGeometry: () => WallOutlineGeometry_default,
WebGLConstants: () => WebGLConstants_default,
WebMapServiceImageryProvider: () => WebMapServiceImageryProvider_default,
WebMapTileServiceImageryProvider: () => WebMapTileServiceImageryProvider_default,
WebMercatorProjection: () => WebMercatorProjection_default,
WebMercatorTilingScheme: () => WebMercatorTilingScheme_default,
WindingOrder: () => WindingOrder_default,
WireframeIndexGenerator: () => WireframeIndexGenerator_default,
WireframePipelineStage: () => WireframePipelineStage_default,
_shadersAcesTonemappingStage: () => AcesTonemappingStage_default,
_shadersAdditiveBlend: () => AdditiveBlend_default,
_shadersAdjustTranslucentFS: () => AdjustTranslucentFS_default,
_shadersAllMaterialAppearanceFS: () => AllMaterialAppearanceFS_default,
_shadersAllMaterialAppearanceVS: () => AllMaterialAppearanceVS_default,
_shadersAmbientOcclusionGenerate: () => AmbientOcclusionGenerate_default,
_shadersAmbientOcclusionModulate: () => AmbientOcclusionModulate_default,
_shadersAspectRampMaterial: () => AspectRampMaterial_default,
_shadersAtmosphereCommon: () => AtmosphereCommon_default,
_shadersBasicMaterialAppearanceFS: () => BasicMaterialAppearanceFS_default,
_shadersBasicMaterialAppearanceVS: () => BasicMaterialAppearanceVS_default,
_shadersBillboardCollectionFS: () => BillboardCollectionFS_default,
_shadersBillboardCollectionVS: () => BillboardCollectionVS_default,
_shadersBlackAndWhite: () => BlackAndWhite_default,
_shadersBloomComposite: () => BloomComposite_default,
_shadersBrdfLutGeneratorFS: () => BrdfLutGeneratorFS_default,
_shadersBrightPass: () => BrightPass_default,
_shadersBrightness: () => Brightness_default,
_shadersBumpMapMaterial: () => BumpMapMaterial_default,
_shadersCPUStylingStageFS: () => CPUStylingStageFS_default,
_shadersCPUStylingStageVS: () => CPUStylingStageVS_default,
_shadersCheckerboardMaterial: () => CheckerboardMaterial_default,
_shadersCloudCollectionFS: () => CloudCollectionFS_default,
_shadersCloudCollectionVS: () => CloudCollectionVS_default,
_shadersCloudNoiseFS: () => CloudNoiseFS_default,
_shadersCloudNoiseVS: () => CloudNoiseVS_default,
_shadersCompareAndPackTranslucentDepth: () => CompareAndPackTranslucentDepth_default,
_shadersCompositeOITFS: () => CompositeOITFS_default,
_shadersCompositeTranslucentClassification: () => CompositeTranslucentClassification_default,
_shadersContrastBias: () => ContrastBias_default,
_shadersCustomShaderStageFS: () => CustomShaderStageFS_default,
_shadersCustomShaderStageVS: () => CustomShaderStageVS_default,
_shadersCzmBuiltins: () => CzmBuiltins_default,
_shadersDepthOfField: () => DepthOfField_default,
_shadersDepthPlaneFS: () => DepthPlaneFS_default,
_shadersDepthPlaneVS: () => DepthPlaneVS_default,
_shadersDepthView: () => DepthView_default,
_shadersDepthViewPacked: () => DepthViewPacked_default,
_shadersDotMaterial: () => DotMaterial_default,
_shadersEdgeDetection: () => EdgeDetection_default,
_shadersElevationBandMaterial: () => ElevationBandMaterial_default,
_shadersElevationContourMaterial: () => ElevationContourMaterial_default,
_shadersElevationRampMaterial: () => ElevationRampMaterial_default,
_shadersEllipsoidFS: () => EllipsoidFS_default,
_shadersEllipsoidSurfaceAppearanceFS: () => EllipsoidSurfaceAppearanceFS_default,
_shadersEllipsoidSurfaceAppearanceVS: () => EllipsoidSurfaceAppearanceVS_default,
_shadersEllipsoidVS: () => EllipsoidVS_default,
_shadersFXAA: () => FXAA_default,
_shadersFXAA3_11: () => FXAA3_11_default,
_shadersFadeMaterial: () => FadeMaterial_default,
_shadersFeatureIdStageFS: () => FeatureIdStageFS_default,
_shadersFeatureIdStageVS: () => FeatureIdStageVS_default,
_shadersFilmicTonemapping: () => FilmicTonemapping_default,
_shadersGaussianBlur1D: () => GaussianBlur1D_default,
_shadersGeometryStageFS: () => GeometryStageFS_default,
_shadersGeometryStageVS: () => GeometryStageVS_default,
_shadersGlobeFS: () => GlobeFS_default,
_shadersGlobeVS: () => GlobeVS_default,
_shadersGridMaterial: () => GridMaterial_default,
_shadersGroundAtmosphere: () => GroundAtmosphere_default,
_shadersHSBToRGB: () => HSBToRGB_default,
_shadersHSLToRGB: () => HSLToRGB_default,
_shadersImageBasedLightingStageFS: () => ImageBasedLightingStageFS_default,
_shadersInstancingStageCommon: () => InstancingStageCommon_default,
_shadersInstancingStageVS: () => InstancingStageVS_default,
_shadersLegacyInstancingStageVS: () => LegacyInstancingStageVS_default,
_shadersLensFlare: () => LensFlare_default,
_shadersLightingStageFS: () => LightingStageFS_default,
_shadersMaterialStageFS: () => MaterialStageFS_default,
_shadersMetadataStageFS: () => MetadataStageFS_default,
_shadersMetadataStageVS: () => MetadataStageVS_default,
_shadersModelClippingPlanesStageFS: () => ModelClippingPlanesStageFS_default,
_shadersModelColorStageFS: () => ModelColorStageFS_default,
_shadersModelExperimentalFS: () => ModelExperimentalFS_default,
_shadersModelExperimentalVS: () => ModelExperimentalVS_default,
_shadersModelSilhouetteStageFS: () => ModelSilhouetteStageFS_default,
_shadersModelSilhouetteStageVS: () => ModelSilhouetteStageVS_default,
_shadersModelSplitterStageFS: () => ModelSplitterStageFS_default,
_shadersModifiedReinhardTonemapping: () => ModifiedReinhardTonemapping_default,
_shadersMorphTargetsStageVS: () => MorphTargetsStageVS_default,
_shadersNightVision: () => NightVision_default,
_shadersNormalMapMaterial: () => NormalMapMaterial_default,
_shadersOctahedralProjectionAtlasFS: () => OctahedralProjectionAtlasFS_default,
_shadersOctahedralProjectionFS: () => OctahedralProjectionFS_default,
_shadersOctahedralProjectionVS: () => OctahedralProjectionVS_default,
_shadersPassThrough: () => PassThrough_default,
_shadersPassThroughDepth: () => PassThroughDepth_default,
_shadersPerInstanceColorAppearanceFS: () => PerInstanceColorAppearanceFS_default,
_shadersPerInstanceColorAppearanceVS: () => PerInstanceColorAppearanceVS_default,
_shadersPerInstanceFlatColorAppearanceFS: () => PerInstanceFlatColorAppearanceFS_default,
_shadersPerInstanceFlatColorAppearanceVS: () => PerInstanceFlatColorAppearanceVS_default,
_shadersPointCloudEyeDomeLighting: () => PointCloudEyeDomeLighting_default,
_shadersPointCloudStylingStageVS: () => PointCloudStylingStageVS_default,
_shadersPointPrimitiveCollectionFS: () => PointPrimitiveCollectionFS_default,
_shadersPointPrimitiveCollectionVS: () => PointPrimitiveCollectionVS_default,
_shadersPolylineArrowMaterial: () => PolylineArrowMaterial_default,
_shadersPolylineColorAppearanceVS: () => PolylineColorAppearanceVS_default,
_shadersPolylineCommon: () => PolylineCommon_default,
_shadersPolylineDashMaterial: () => PolylineDashMaterial_default,
_shadersPolylineFS: () => PolylineFS_default,
_shadersPolylineGlowMaterial: () => PolylineGlowMaterial_default,
_shadersPolylineMaterialAppearanceVS: () => PolylineMaterialAppearanceVS_default,
_shadersPolylineOutlineMaterial: () => PolylineOutlineMaterial_default,
_shadersPolylineShadowVolumeFS: () => PolylineShadowVolumeFS_default,
_shadersPolylineShadowVolumeMorphFS: () => PolylineShadowVolumeMorphFS_default,
_shadersPolylineShadowVolumeMorphVS: () => PolylineShadowVolumeMorphVS_default,
_shadersPolylineShadowVolumeVS: () => PolylineShadowVolumeVS_default,
_shadersPolylineVS: () => PolylineVS_default,
_shadersPrimitiveOutlineStageFS: () => PrimitiveOutlineStageFS_default,
_shadersPrimitiveOutlineStageVS: () => PrimitiveOutlineStageVS_default,
_shadersRGBToHSB: () => RGBToHSB_default,
_shadersRGBToHSL: () => RGBToHSL_default,
_shadersRGBToXYZ: () => RGBToXYZ_default,
_shadersReinhardTonemapping: () => ReinhardTonemapping_default,
_shadersReprojectWebMercatorFS: () => ReprojectWebMercatorFS_default,
_shadersReprojectWebMercatorVS: () => ReprojectWebMercatorVS_default,
_shadersRimLightingMaterial: () => RimLightingMaterial_default,
_shadersSelectedFeatureIdStageCommon: () => SelectedFeatureIdStageCommon_default,
_shadersShadowVolumeAppearanceFS: () => ShadowVolumeAppearanceFS_default,
_shadersShadowVolumeAppearanceVS: () => ShadowVolumeAppearanceVS_default,
_shadersShadowVolumeFS: () => ShadowVolumeFS_default,
_shadersSilhouette: () => Silhouette_default,
_shadersSkinningStageVS: () => SkinningStageVS_default,
_shadersSkyAtmosphereCommon: () => SkyAtmosphereCommon_default,
_shadersSkyAtmosphereFS: () => SkyAtmosphereFS_default,
_shadersSkyAtmosphereVS: () => SkyAtmosphereVS_default,
_shadersSkyBoxFS: () => SkyBoxFS_default,
_shadersSkyBoxVS: () => SkyBoxVS_default,
_shadersSlopeRampMaterial: () => SlopeRampMaterial_default,
_shadersStripeMaterial: () => StripeMaterial_default,
_shadersSunFS: () => SunFS_default,
_shadersSunTextureFS: () => SunTextureFS_default,
_shadersSunVS: () => SunVS_default,
_shadersTexturedMaterialAppearanceFS: () => TexturedMaterialAppearanceFS_default,
_shadersTexturedMaterialAppearanceVS: () => TexturedMaterialAppearanceVS_default,
_shadersVector3DTileClampedPolylinesFS: () => Vector3DTileClampedPolylinesFS_default,
_shadersVector3DTileClampedPolylinesVS: () => Vector3DTileClampedPolylinesVS_default,
_shadersVector3DTilePolylinesVS: () => Vector3DTilePolylinesVS_default,
_shadersVectorTileVS: () => VectorTileVS_default,
_shadersViewportQuadFS: () => ViewportQuadFS_default,
_shadersViewportQuadVS: () => ViewportQuadVS_default,
_shadersWater: () => Water_default,
_shadersXYZToRGB: () => XYZToRGB_default,
_shadersacesTonemapping: () => acesTonemapping_default,
_shadersalphaWeight: () => alphaWeight_default,
_shadersantialias: () => antialias_default,
_shadersapproximateSphericalCoordinates: () => approximateSphericalCoordinates_default,
_shadersbackFacing: () => backFacing_default,
_shadersbranchFreeTernary: () => branchFreeTernary_default,
_shaderscascadeColor: () => cascadeColor_default,
_shaderscascadeDistance: () => cascadeDistance_default,
_shaderscascadeMatrix: () => cascadeMatrix_default,
_shaderscascadeWeights: () => cascadeWeights_default,
_shaderscolumbusViewMorph: () => columbusViewMorph_default,
_shaderscomputePosition: () => computePosition_default,
_shaderscosineAndSine: () => cosineAndSine_default,
_shadersdecompressTextureCoordinates: () => decompressTextureCoordinates_default,
_shadersdefaultPbrMaterial: () => defaultPbrMaterial_default,
_shadersdegreesPerRadian: () => degreesPerRadian_default,
_shadersdepthClamp: () => depthClamp_default,
_shadersdepthRange: () => depthRange_default,
_shadersdepthRangeStruct: () => depthRangeStruct_default,
_shaderseastNorthUpToEyeCoordinates: () => eastNorthUpToEyeCoordinates_default,
_shadersellipsoidContainsPoint: () => ellipsoidContainsPoint_default,
_shadersellipsoidWgs84TextureCoordinates: () => ellipsoidWgs84TextureCoordinates_default,
_shadersepsilon1: () => epsilon1_default,
_shadersepsilon2: () => epsilon2_default,
_shadersepsilon3: () => epsilon3_default,
_shadersepsilon4: () => epsilon4_default,
_shadersepsilon5: () => epsilon5_default,
_shadersepsilon6: () => epsilon6_default,
_shadersepsilon7: () => epsilon7_default,
_shadersequalsEpsilon: () => equalsEpsilon_default,
_shaderseyeOffset: () => eyeOffset_default,
_shaderseyeToWindowCoordinates: () => eyeToWindowCoordinates_default,
_shadersfastApproximateAtan: () => fastApproximateAtan_default,
_shadersfog: () => fog_default,
_shadersgammaCorrect: () => gammaCorrect_default,
_shadersgeodeticSurfaceNormal: () => geodeticSurfaceNormal_default,
_shadersgetDefaultMaterial: () => getDefaultMaterial_default,
_shadersgetLambertDiffuse: () => getLambertDiffuse_default,
_shadersgetSpecular: () => getSpecular_default,
_shadersgetWaterNoise: () => getWaterNoise_default,
_shadershue: () => hue_default,
_shadersinfinity: () => infinity_default,
_shadersinverseGamma: () => inverseGamma_default,
_shadersisEmpty: () => isEmpty_default,
_shadersisFull: () => isFull_default,
_shaderslatitudeToWebMercatorFraction: () => latitudeToWebMercatorFraction_default,
_shaderslineDistance: () => lineDistance_default,
_shaderslinearToSrgb: () => linearToSrgb_default,
_shadersluminance: () => luminance_default,
_shadersmaterial: () => material_default,
_shadersmaterialInput: () => materialInput_default,
_shadersmetersPerPixel: () => metersPerPixel_default,
_shadersmodelMaterial: () => modelMaterial_default,
_shadersmodelToWindowCoordinates: () => modelToWindowCoordinates_default,
_shadersmodelVertexOutput: () => modelVertexOutput_default,
_shadersmultiplyWithColorBalance: () => multiplyWithColorBalance_default,
_shadersnearFarScalar: () => nearFarScalar_default,
_shadersoctDecode: () => octDecode_default,
_shadersoneOverPi: () => oneOverPi_default,
_shadersoneOverTwoPi: () => oneOverTwoPi_default,
_shaderspackDepth: () => packDepth_default,
_shaderspassCesium3DTile: () => passCesium3DTile_default,
_shaderspassCesium3DTileClassification: () => passCesium3DTileClassification_default,
_shaderspassCesium3DTileClassificationIgnoreShow: () => passCesium3DTileClassificationIgnoreShow_default,
_shaderspassClassification: () => passClassification_default,
_shaderspassCompute: () => passCompute_default,
_shaderspassEnvironment: () => passEnvironment_default,
_shaderspassGlobe: () => passGlobe_default,
_shaderspassOpaque: () => passOpaque_default,
_shaderspassOverlay: () => passOverlay_default,
_shaderspassTerrainClassification: () => passTerrainClassification_default,
_shaderspassTranslucent: () => passTranslucent_default,
_shaderspbrLighting: () => pbrLighting_default,
_shaderspbrMetallicRoughnessMaterial: () => pbrMetallicRoughnessMaterial_default,
_shaderspbrParameters: () => pbrParameters_default,
_shaderspbrSpecularGlossinessMaterial: () => pbrSpecularGlossinessMaterial_default,
_shadersphong: () => phong_default,
_shaderspi: () => pi_default,
_shaderspiOverFour: () => piOverFour_default,
_shaderspiOverSix: () => piOverSix_default,
_shaderspiOverThree: () => piOverThree_default,
_shaderspiOverTwo: () => piOverTwo_default,
_shadersplaneDistance: () => planeDistance_default,
_shaderspointAlongRay: () => pointAlongRay_default,
_shadersradiansPerDegree: () => radiansPerDegree_default,
_shadersray: () => ray_default,
_shadersrayEllipsoidIntersectionInterval: () => rayEllipsoidIntersectionInterval_default,
_shadersraySegment: () => raySegment_default,
_shadersraySphereIntersectionInterval: () => raySphereIntersectionInterval_default,
_shadersreadDepth: () => readDepth_default,
_shadersreadNonPerspective: () => readNonPerspective_default,
_shadersreverseLogDepth: () => reverseLogDepth_default,
_shadersround: () => round_default,
_shaderssampleOctahedralProjection: () => sampleOctahedralProjection_default,
_shaderssaturation: () => saturation_default,
_shaderssceneMode2D: () => sceneMode2D_default,
_shaderssceneMode3D: () => sceneMode3D_default,
_shaderssceneModeColumbusView: () => sceneModeColumbusView_default,
_shaderssceneModeMorphing: () => sceneModeMorphing_default,
_shadersshadowDepthCompare: () => shadowDepthCompare_default,
_shadersshadowParameters: () => shadowParameters_default,
_shadersshadowVisibility: () => shadowVisibility_default,
_shaderssignNotZero: () => signNotZero_default,
_shaderssolarRadius: () => solarRadius_default,
_shaderssphericalHarmonics: () => sphericalHarmonics_default,
_shaderssrgbToLinear: () => srgbToLinear_default,
_shaderstangentToEyeSpaceMatrix: () => tangentToEyeSpaceMatrix_default,
_shadersthreePiOver2: () => threePiOver2_default,
_shaderstransformPlane: () => transformPlane_default,
_shaderstranslateRelativeToEye: () => translateRelativeToEye_default,
_shaderstranslucentPhong: () => translucentPhong_default,
_shaderstranspose: () => transpose_default,
_shaderstwoPi: () => twoPi_default,
_shadersunpackDepth: () => unpackDepth_default,
_shadersunpackFloat: () => unpackFloat_default,
_shadersunpackUint: () => unpackUint_default,
_shadersvalueTransform: () => valueTransform_default,
_shadersvertexLogDepth: () => vertexLogDepth_default,
_shaderswebMercatorMaxLatitude: () => webMercatorMaxLatitude_default,
_shaderswindowToEyeCoordinates: () => windowToEyeCoordinates_default,
_shaderswriteDepthClamp: () => writeDepthClamp_default,
_shaderswriteLogDepth: () => writeLogDepth_default,
_shaderswriteNonPerspective: () => writeNonPerspective_default,
addBuffer: () => addBuffer_default,
addDefaults: () => addDefaults_default,
addExtensionsRequired: () => addExtensionsRequired_default,
addExtensionsUsed: () => addExtensionsUsed_default,
addPipelineExtras: () => addPipelineExtras_default,
addToArray: () => addToArray_default,
appendForwardSlash: () => appendForwardSlash_default,
arrayRemoveDuplicates: () => arrayRemoveDuplicates_default,
barycentricCoordinates: () => barycentricCoordinates_default,
binarySearch: () => binarySearch_default,
bitmap_sdf: () => import_bitmap_sdf.default,
buildDrawCommand: () => buildDrawCommand,
buildModuleUrl: () => buildModuleUrl_default,
cancelAnimationFrame: () => cancelAnimationFrame_default,
clone: () => clone_default,
combine: () => combine_default,
computeFlyToLocationForRectangle: () => computeFlyToLocationForRectangle_default,
createBillboardPointCallback: () => createBillboardPointCallback_default,
createCommand: () => createCommand_default,
createDefaultImageryProviderViewModels: () => createDefaultImageryProviderViewModels_default,
createDefaultTerrainProviderViewModels: () => createDefaultTerrainProviderViewModels_default,
createElevationBandMaterial: () => createElevationBandMaterial_default,
createGuid: () => createGuid_default,
createMaterialPropertyDescriptor: () => createMaterialPropertyDescriptor_default,
createOsmBuildings: () => createOsmBuildings_default,
createPropertyDescriptor: () => createPropertyDescriptor_default,
createRawPropertyDescriptor: () => createRawPropertyDescriptor_default,
createTangentSpaceDebugPrimitive: () => createTangentSpaceDebugPrimitive_default,
createTaskProcessorWorker: () => createTaskProcessorWorker_default,
createUniform: () => createUniform_default,
createUniformArray: () => createUniformArray_default,
createWorldImagery: () => createWorldImagery_default,
createWorldTerrain: () => createWorldTerrain_default,
decodeGoogleEarthEnterpriseData: () => decodeGoogleEarthEnterpriseData_default,
decodeVectorPolylinePositions: () => decodeVectorPolylinePositions_default,
defaultValue: () => defaultValue_default,
defer: () => defer_default,
defined: () => defined_default,
deprecationWarning: () => deprecationWarning_default,
destroyObject: () => destroyObject_default,
dompurify: () => import_dompurify.default,
earcut: () => import_earcut.default,
exportKml: () => exportKml_default,
findAccessorMinMax: () => findAccessorMinMax_default,
findContentMetadata: () => findContentMetadata_default,
findGroupMetadata: () => findGroupMetadata,
findTileMetadata: () => findTileMetadata_default,
forEachTextureInMaterial: () => forEachTextureInMaterial_default,
formatError: () => formatError_default,
freezeRenderState: () => freezeRenderState_default,
getAbsoluteUri: () => getAbsoluteUri_default,
getAccessorByteStride: () => getAccessorByteStride_default,
getBaseUri: () => getBaseUri_default,
getBinaryAccessor: () => getBinaryAccessor_default,
getClipAndStyleCode: () => getClipAndStyleCode_default,
getClippingFunction: () => getClippingFunction_default,
getComponentReader: () => getComponentReader_default,
getElement: () => getElement_default,
getExtensionFromUri: () => getExtensionFromUri_default,
getFilenameFromUri: () => getFilenameFromUri_default,
getImageFromTypedArray: () => getImageFromTypedArray_default,
getImagePixels: () => getImagePixels_default,
getJsonFromTypedArray: () => getJsonFromTypedArray_default,
getMagic: () => getMagic_default,
getStringFromTypedArray: () => getStringFromTypedArray_default,
getTimestamp: () => getTimestamp_default,
grapheme_splitter: () => import_grapheme_splitter.default,
hasExtension: () => hasExtension,
heightReferenceOnEntityPropertyChanged: () => heightReferenceOnEntityPropertyChanged_default,
isBitSet: () => isBitSet_default,
isBlobUri: () => isBlobUri_default,
isCrossOriginUrl: () => isCrossOriginUrl_default,
isDataUri: () => isDataUri_default,
isLeapYear: () => isLeapYear_default,
jsep: () => import_jsep.default,
kdbush: () => import_kdbush.default,
knockout: () => knockout_default,
knockout_3_5_1: () => knockout_3_5_1_default,
knockout_es5: () => knockout_es5_default,
ktx_parse: () => import_ktx_parse.read,
lerc: () => import_lerc.default,
loadAndExecuteScript: () => loadAndExecuteScript_default,
loadCubeMap: () => loadCubeMap_default,
loadImageFromTypedArray: () => loadImageFromTypedArray_default,
loadKTX2: () => loadKTX2_default,
mergeSort: () => mergeSort_default,
mersenne_twister: () => import_mersenne_twister.default,
meshoptimizer: () => import_meshoptimizer.MeshoptDecoder,
modernizeShader: () => modernizeShader_default,
moveTechniqueRenderStates: () => moveTechniqueRenderStates_default,
moveTechniquesToExtension: () => moveTechniquesToExtension_default,
nosleep: () => import_nosleep.default,
numberOfComponentsForType: () => numberOfComponentsForType_default,
objectToQuery: () => objectToQuery_default,
oneTimeWarning: () => oneTimeWarning_default,
pako: () => import_inflate2.default,
parseBatchTable: () => parseBatchTable,
parseBoundingVolumeSemantics: () => parseBoundingVolumeSemantics,
parseFeatureMetadataLegacy: () => parseFeatureMetadataLegacy,
parseGlb: () => parseGlb_default,
parseResponseHeaders: () => parseResponseHeaders_default,
parseStructuralMetadata: () => parseStructuralMetadata,
pointInsideTriangle: () => pointInsideTriangle_default,
preprocess3DTileContent: () => preprocess3DTileContent,
processModelMaterialsCommon: () => processModelMaterialsCommon_default,
processPbrMaterials: () => processPbrMaterials_default,
protobufjs: () => protobuf,
queryToObject: () => queryToObject_default,
rbush: () => import_rbush.default,
readAccessorPacked: () => readAccessorPacked_default,
removeExtensionsRequired: () => removeExtensionsRequired_default,
removeExtensionsUsed: () => removeExtensionsUsed_default,
removePipelineExtras: () => removePipelineExtras_default,
removeUnusedElements: () => removeUnusedElements_default,
requestAnimationFrame: () => requestAnimationFrame_default,
resizeImageToNextPowerOfTwo: () => resizeImageToNextPowerOfTwo_default,
sampleTerrain: () => sampleTerrain_default,
sampleTerrainMostDetailed: () => sampleTerrainMostDetailed_default,
scaleToGeodeticSurface: () => scaleToGeodeticSurface_default,
subdivideArray: () => subdivideArray_default,
subscribeAndEvaluate: () => subscribeAndEvaluate_default,
topojson: () => topojson,
updateAccessorComponentTypes: () => updateAccessorComponentTypes_default,
updateVersion: () => updateVersion_default,
usesExtension: () => usesExtension_default,
viewerCesium3DTilesInspectorMixin: () => viewerCesium3DTilesInspectorMixin_default,
viewerCesiumInspectorMixin: () => viewerCesiumInspectorMixin_default,
viewerDragDropMixin: () => viewerDragDropMixin_default,
viewerPerformanceWatchdogMixin: () => viewerPerformanceWatchdogMixin_default,
webGLConstantToGlslType: () => webGLConstantToGlslType_default,
wrapFunction: () => wrapFunction_default,
writeTextToCanvas: () => writeTextToCanvas_default,
zip: () => zip_no_worker_exports
});
module.exports = __toCommonJS(Cesium_exports);
// Source/Core/appendForwardSlash.js
function appendForwardSlash(url2) {
if (url2.length === 0 || url2[url2.length - 1] !== "/") {
url2 = `${url2}/`;
}
return url2;
}
var appendForwardSlash_default = appendForwardSlash;
// Source/Core/defined.js
function defined(value) {
return value !== void 0 && value !== null;
}
var defined_default = defined;
// Source/Core/DeveloperError.js
function DeveloperError(message) {
this.name = "DeveloperError";
this.message = message;
let stack;
try {
throw new Error();
} catch (e) {
stack = e.stack;
}
this.stack = stack;
}
if (defined_default(Object.create)) {
DeveloperError.prototype = Object.create(Error.prototype);
DeveloperError.prototype.constructor = DeveloperError;
}
DeveloperError.prototype.toString = function() {
let str = `${this.name}: ${this.message}`;
if (defined_default(this.stack)) {
str += `
${this.stack.toString()}`;
}
return str;
};
DeveloperError.throwInstantiationError = function() {
throw new DeveloperError(
"This function defines an interface and should not be called directly."
);
};
var DeveloperError_default = DeveloperError;
// Source/Core/Check.js
var Check = {};
Check.typeOf = {};
function getUndefinedErrorMessage(name) {
return `${name} is required, actual value was undefined`;
}
function getFailedTypeErrorMessage(actual, expected, name) {
return `Expected ${name} to be typeof ${expected}, actual typeof was ${actual}`;
}
Check.defined = function(name, test) {
if (!defined_default(test)) {
throw new DeveloperError_default(getUndefinedErrorMessage(name));
}
};
Check.typeOf.func = function(name, test) {
if (typeof test !== "function") {
throw new DeveloperError_default(
getFailedTypeErrorMessage(typeof test, "function", name)
);
}
};
Check.typeOf.string = function(name, test) {
if (typeof test !== "string") {
throw new DeveloperError_default(
getFailedTypeErrorMessage(typeof test, "string", name)
);
}
};
Check.typeOf.number = function(name, test) {
if (typeof test !== "number") {
throw new DeveloperError_default(
getFailedTypeErrorMessage(typeof test, "number", name)
);
}
};
Check.typeOf.number.lessThan = function(name, test, limit) {
Check.typeOf.number(name, test);
if (test >= limit) {
throw new DeveloperError_default(
`Expected ${name} to be less than ${limit}, actual value was ${test}`
);
}
};
Check.typeOf.number.lessThanOrEquals = function(name, test, limit) {
Check.typeOf.number(name, test);
if (test > limit) {
throw new DeveloperError_default(
`Expected ${name} to be less than or equal to ${limit}, actual value was ${test}`
);
}
};
Check.typeOf.number.greaterThan = function(name, test, limit) {
Check.typeOf.number(name, test);
if (test <= limit) {
throw new DeveloperError_default(
`Expected ${name} to be greater than ${limit}, actual value was ${test}`
);
}
};
Check.typeOf.number.greaterThanOrEquals = function(name, test, limit) {
Check.typeOf.number(name, test);
if (test < limit) {
throw new DeveloperError_default(
`Expected ${name} to be greater than or equal to ${limit}, actual value was ${test}`
);
}
};
Check.typeOf.object = function(name, test) {
if (typeof test !== "object") {
throw new DeveloperError_default(
getFailedTypeErrorMessage(typeof test, "object", name)
);
}
};
Check.typeOf.bool = function(name, test) {
if (typeof test !== "boolean") {
throw new DeveloperError_default(
getFailedTypeErrorMessage(typeof test, "boolean", name)
);
}
};
Check.typeOf.bigint = function(name, test) {
if (typeof test !== "bigint") {
throw new DeveloperError_default(
getFailedTypeErrorMessage(typeof test, "bigint", name)
);
}
};
Check.typeOf.number.equals = function(name1, name2, test1, test2) {
Check.typeOf.number(name1, test1);
Check.typeOf.number(name2, test2);
if (test1 !== test2) {
throw new DeveloperError_default(
`${name1} must be equal to ${name2}, the actual values are ${test1} and ${test2}`
);
}
};
var Check_default = Check;
// Source/Core/defaultValue.js
function defaultValue(a3, b) {
if (a3 !== void 0 && a3 !== null) {
return a3;
}
return b;
}
defaultValue.EMPTY_OBJECT = Object.freeze({});
var defaultValue_default = defaultValue;
// Source/ThirdParty/mersenne-twister.js
var import_mersenne_twister = __toESM(require_mersenne_twister(), 1);
// Source/Core/Math.js
var CesiumMath = {};
CesiumMath.EPSILON1 = 0.1;
CesiumMath.EPSILON2 = 0.01;
CesiumMath.EPSILON3 = 1e-3;
CesiumMath.EPSILON4 = 1e-4;
CesiumMath.EPSILON5 = 1e-5;
CesiumMath.EPSILON6 = 1e-6;
CesiumMath.EPSILON7 = 1e-7;
CesiumMath.EPSILON8 = 1e-8;
CesiumMath.EPSILON9 = 1e-9;
CesiumMath.EPSILON10 = 1e-10;
CesiumMath.EPSILON11 = 1e-11;
CesiumMath.EPSILON12 = 1e-12;
CesiumMath.EPSILON13 = 1e-13;
CesiumMath.EPSILON14 = 1e-14;
CesiumMath.EPSILON15 = 1e-15;
CesiumMath.EPSILON16 = 1e-16;
CesiumMath.EPSILON17 = 1e-17;
CesiumMath.EPSILON18 = 1e-18;
CesiumMath.EPSILON19 = 1e-19;
CesiumMath.EPSILON20 = 1e-20;
CesiumMath.EPSILON21 = 1e-21;
CesiumMath.GRAVITATIONALPARAMETER = 3986004418e5;
CesiumMath.SOLAR_RADIUS = 6955e5;
CesiumMath.LUNAR_RADIUS = 1737400;
CesiumMath.SIXTY_FOUR_KILOBYTES = 64 * 1024;
CesiumMath.FOUR_GIGABYTES = 4 * 1024 * 1024 * 1024;
CesiumMath.sign = defaultValue_default(Math.sign, function sign(value) {
value = +value;
if (value === 0 || value !== value) {
return value;
}
return value > 0 ? 1 : -1;
});
CesiumMath.signNotZero = function(value) {
return value < 0 ? -1 : 1;
};
CesiumMath.toSNorm = function(value, rangeMaximum) {
rangeMaximum = defaultValue_default(rangeMaximum, 255);
return Math.round(
(CesiumMath.clamp(value, -1, 1) * 0.5 + 0.5) * rangeMaximum
);
};
CesiumMath.fromSNorm = function(value, rangeMaximum) {
rangeMaximum = defaultValue_default(rangeMaximum, 255);
return CesiumMath.clamp(value, 0, rangeMaximum) / rangeMaximum * 2 - 1;
};
CesiumMath.normalize = function(value, rangeMinimum, rangeMaximum) {
rangeMaximum = Math.max(rangeMaximum - rangeMinimum, 0);
return rangeMaximum === 0 ? 0 : CesiumMath.clamp((value - rangeMinimum) / rangeMaximum, 0, 1);
};
CesiumMath.sinh = defaultValue_default(Math.sinh, function sinh(value) {
return (Math.exp(value) - Math.exp(-value)) / 2;
});
CesiumMath.cosh = defaultValue_default(Math.cosh, function cosh(value) {
return (Math.exp(value) + Math.exp(-value)) / 2;
});
CesiumMath.lerp = function(p, q, time) {
return (1 - time) * p + time * q;
};
CesiumMath.PI = Math.PI;
CesiumMath.ONE_OVER_PI = 1 / Math.PI;
CesiumMath.PI_OVER_TWO = Math.PI / 2;
CesiumMath.PI_OVER_THREE = Math.PI / 3;
CesiumMath.PI_OVER_FOUR = Math.PI / 4;
CesiumMath.PI_OVER_SIX = Math.PI / 6;
CesiumMath.THREE_PI_OVER_TWO = 3 * Math.PI / 2;
CesiumMath.TWO_PI = 2 * Math.PI;
CesiumMath.ONE_OVER_TWO_PI = 1 / (2 * Math.PI);
CesiumMath.RADIANS_PER_DEGREE = Math.PI / 180;
CesiumMath.DEGREES_PER_RADIAN = 180 / Math.PI;
CesiumMath.RADIANS_PER_ARCSECOND = CesiumMath.RADIANS_PER_DEGREE / 3600;
CesiumMath.toRadians = function(degrees) {
if (!defined_default(degrees)) {
throw new DeveloperError_default("degrees is required.");
}
return degrees * CesiumMath.RADIANS_PER_DEGREE;
};
CesiumMath.toDegrees = function(radians) {
if (!defined_default(radians)) {
throw new DeveloperError_default("radians is required.");
}
return radians * CesiumMath.DEGREES_PER_RADIAN;
};
CesiumMath.convertLongitudeRange = function(angle) {
if (!defined_default(angle)) {
throw new DeveloperError_default("angle is required.");
}
const twoPi = CesiumMath.TWO_PI;
const simplified = angle - Math.floor(angle / twoPi) * twoPi;
if (simplified < -Math.PI) {
return simplified + twoPi;
}
if (simplified >= Math.PI) {
return simplified - twoPi;
}
return simplified;
};
CesiumMath.clampToLatitudeRange = function(angle) {
if (!defined_default(angle)) {
throw new DeveloperError_default("angle is required.");
}
return CesiumMath.clamp(
angle,
-1 * CesiumMath.PI_OVER_TWO,
CesiumMath.PI_OVER_TWO
);
};
CesiumMath.negativePiToPi = function(angle) {
if (!defined_default(angle)) {
throw new DeveloperError_default("angle is required.");
}
if (angle >= -CesiumMath.PI && angle <= CesiumMath.PI) {
return angle;
}
return CesiumMath.zeroToTwoPi(angle + CesiumMath.PI) - CesiumMath.PI;
};
CesiumMath.zeroToTwoPi = function(angle) {
if (!defined_default(angle)) {
throw new DeveloperError_default("angle is required.");
}
if (angle >= 0 && angle <= CesiumMath.TWO_PI) {
return angle;
}
const mod2 = CesiumMath.mod(angle, CesiumMath.TWO_PI);
if (Math.abs(mod2) < CesiumMath.EPSILON14 && Math.abs(angle) > CesiumMath.EPSILON14) {
return CesiumMath.TWO_PI;
}
return mod2;
};
CesiumMath.mod = function(m, n) {
if (!defined_default(m)) {
throw new DeveloperError_default("m is required.");
}
if (!defined_default(n)) {
throw new DeveloperError_default("n is required.");
}
if (n === 0) {
throw new DeveloperError_default("divisor cannot be 0.");
}
if (CesiumMath.sign(m) === CesiumMath.sign(n) && Math.abs(m) < Math.abs(n)) {
return m;
}
return (m % n + n) % n;
};
CesiumMath.equalsEpsilon = function(left, right, relativeEpsilon, absoluteEpsilon) {
if (!defined_default(left)) {
throw new DeveloperError_default("left is required.");
}
if (!defined_default(right)) {
throw new DeveloperError_default("right is required.");
}
relativeEpsilon = defaultValue_default(relativeEpsilon, 0);
absoluteEpsilon = defaultValue_default(absoluteEpsilon, relativeEpsilon);
const absDiff = Math.abs(left - right);
return absDiff <= absoluteEpsilon || absDiff <= relativeEpsilon * Math.max(Math.abs(left), Math.abs(right));
};
CesiumMath.lessThan = function(left, right, absoluteEpsilon) {
if (!defined_default(left)) {
throw new DeveloperError_default("first is required.");
}
if (!defined_default(right)) {
throw new DeveloperError_default("second is required.");
}
if (!defined_default(absoluteEpsilon)) {
throw new DeveloperError_default("absoluteEpsilon is required.");
}
return left - right < -absoluteEpsilon;
};
CesiumMath.lessThanOrEquals = function(left, right, absoluteEpsilon) {
if (!defined_default(left)) {
throw new DeveloperError_default("first is required.");
}
if (!defined_default(right)) {
throw new DeveloperError_default("second is required.");
}
if (!defined_default(absoluteEpsilon)) {
throw new DeveloperError_default("absoluteEpsilon is required.");
}
return left - right < absoluteEpsilon;
};
CesiumMath.greaterThan = function(left, right, absoluteEpsilon) {
if (!defined_default(left)) {
throw new DeveloperError_default("first is required.");
}
if (!defined_default(right)) {
throw new DeveloperError_default("second is required.");
}
if (!defined_default(absoluteEpsilon)) {
throw new DeveloperError_default("absoluteEpsilon is required.");
}
return left - right > absoluteEpsilon;
};
CesiumMath.greaterThanOrEquals = function(left, right, absoluteEpsilon) {
if (!defined_default(left)) {
throw new DeveloperError_default("first is required.");
}
if (!defined_default(right)) {
throw new DeveloperError_default("second is required.");
}
if (!defined_default(absoluteEpsilon)) {
throw new DeveloperError_default("absoluteEpsilon is required.");
}
return left - right > -absoluteEpsilon;
};
var factorials = [1];
CesiumMath.factorial = function(n) {
if (typeof n !== "number" || n < 0) {
throw new DeveloperError_default(
"A number greater than or equal to 0 is required."
);
}
const length3 = factorials.length;
if (n >= length3) {
let sum = factorials[length3 - 1];
for (let i = length3; i <= n; i++) {
const next = sum * i;
factorials.push(next);
sum = next;
}
}
return factorials[n];
};
CesiumMath.incrementWrap = function(n, maximumValue, minimumValue) {
minimumValue = defaultValue_default(minimumValue, 0);
if (!defined_default(n)) {
throw new DeveloperError_default("n is required.");
}
if (maximumValue <= minimumValue) {
throw new DeveloperError_default("maximumValue must be greater than minimumValue.");
}
++n;
if (n > maximumValue) {
n = minimumValue;
}
return n;
};
CesiumMath.isPowerOfTwo = function(n) {
if (typeof n !== "number" || n < 0 || n > 4294967295) {
throw new DeveloperError_default("A number between 0 and (2^32)-1 is required.");
}
return n !== 0 && (n & n - 1) === 0;
};
CesiumMath.nextPowerOfTwo = function(n) {
if (typeof n !== "number" || n < 0 || n > 2147483648) {
throw new DeveloperError_default("A number between 0 and 2^31 is required.");
}
--n;
n |= n >> 1;
n |= n >> 2;
n |= n >> 4;
n |= n >> 8;
n |= n >> 16;
++n;
return n;
};
CesiumMath.previousPowerOfTwo = function(n) {
if (typeof n !== "number" || n < 0 || n > 4294967295) {
throw new DeveloperError_default("A number between 0 and (2^32)-1 is required.");
}
n |= n >> 1;
n |= n >> 2;
n |= n >> 4;
n |= n >> 8;
n |= n >> 16;
n |= n >> 32;
n = (n >>> 0) - (n >>> 1);
return n;
};
CesiumMath.clamp = function(value, min3, max3) {
Check_default.typeOf.number("value", value);
Check_default.typeOf.number("min", min3);
Check_default.typeOf.number("max", max3);
return value < min3 ? min3 : value > max3 ? max3 : value;
};
var randomNumberGenerator = new import_mersenne_twister.default();
CesiumMath.setRandomNumberSeed = function(seed) {
if (!defined_default(seed)) {
throw new DeveloperError_default("seed is required.");
}
randomNumberGenerator = new import_mersenne_twister.default(seed);
};
CesiumMath.nextRandomNumber = function() {
return randomNumberGenerator.random();
};
CesiumMath.randomBetween = function(min3, max3) {
return CesiumMath.nextRandomNumber() * (max3 - min3) + min3;
};
CesiumMath.acosClamped = function(value) {
if (!defined_default(value)) {
throw new DeveloperError_default("value is required.");
}
return Math.acos(CesiumMath.clamp(value, -1, 1));
};
CesiumMath.asinClamped = function(value) {
if (!defined_default(value)) {
throw new DeveloperError_default("value is required.");
}
return Math.asin(CesiumMath.clamp(value, -1, 1));
};
CesiumMath.chordLength = function(angle, radius) {
if (!defined_default(angle)) {
throw new DeveloperError_default("angle is required.");
}
if (!defined_default(radius)) {
throw new DeveloperError_default("radius is required.");
}
return 2 * radius * Math.sin(angle * 0.5);
};
CesiumMath.logBase = function(number, base) {
if (!defined_default(number)) {
throw new DeveloperError_default("number is required.");
}
if (!defined_default(base)) {
throw new DeveloperError_default("base is required.");
}
return Math.log(number) / Math.log(base);
};
CesiumMath.cbrt = defaultValue_default(Math.cbrt, function cbrt(number) {
const result = Math.pow(Math.abs(number), 1 / 3);
return number < 0 ? -result : result;
});
CesiumMath.log2 = defaultValue_default(Math.log2, function log2(number) {
return Math.log(number) * Math.LOG2E;
});
CesiumMath.fog = function(distanceToCamera, density) {
const scalar = distanceToCamera * density;
return 1 - Math.exp(-(scalar * scalar));
};
CesiumMath.fastApproximateAtan = function(x) {
Check_default.typeOf.number("x", x);
return x * (-0.1784 * Math.abs(x) - 0.0663 * x * x + 1.0301);
};
CesiumMath.fastApproximateAtan2 = function(x, y) {
Check_default.typeOf.number("x", x);
Check_default.typeOf.number("y", y);
let opposite;
let t = Math.abs(x);
opposite = Math.abs(y);
const adjacent = Math.max(t, opposite);
opposite = Math.min(t, opposite);
const oppositeOverAdjacent = opposite / adjacent;
if (isNaN(oppositeOverAdjacent)) {
throw new DeveloperError_default("either x or y must be nonzero");
}
t = CesiumMath.fastApproximateAtan(oppositeOverAdjacent);
t = Math.abs(y) > Math.abs(x) ? CesiumMath.PI_OVER_TWO - t : t;
t = x < 0 ? CesiumMath.PI - t : t;
t = y < 0 ? -t : t;
return t;
};
var Math_default = CesiumMath;
// Source/Core/Cartesian3.js
function Cartesian3(x, y, z) {
this.x = defaultValue_default(x, 0);
this.y = defaultValue_default(y, 0);
this.z = defaultValue_default(z, 0);
}
Cartesian3.fromSpherical = function(spherical, result) {
Check_default.typeOf.object("spherical", spherical);
if (!defined_default(result)) {
result = new Cartesian3();
}
const clock = spherical.clock;
const cone = spherical.cone;
const magnitude = defaultValue_default(spherical.magnitude, 1);
const radial = magnitude * Math.sin(cone);
result.x = radial * Math.cos(clock);
result.y = radial * Math.sin(clock);
result.z = magnitude * Math.cos(cone);
return result;
};
Cartesian3.fromElements = function(x, y, z, result) {
if (!defined_default(result)) {
return new Cartesian3(x, y, z);
}
result.x = x;
result.y = y;
result.z = z;
return result;
};
Cartesian3.clone = function(cartesian11, result) {
if (!defined_default(cartesian11)) {
return void 0;
}
if (!defined_default(result)) {
return new Cartesian3(cartesian11.x, cartesian11.y, cartesian11.z);
}
result.x = cartesian11.x;
result.y = cartesian11.y;
result.z = cartesian11.z;
return result;
};
Cartesian3.fromCartesian4 = Cartesian3.clone;
Cartesian3.packedLength = 3;
Cartesian3.pack = function(value, array, startingIndex) {
Check_default.typeOf.object("value", value);
Check_default.defined("array", array);
startingIndex = defaultValue_default(startingIndex, 0);
array[startingIndex++] = value.x;
array[startingIndex++] = value.y;
array[startingIndex] = value.z;
return array;
};
Cartesian3.unpack = function(array, startingIndex, result) {
Check_default.defined("array", array);
startingIndex = defaultValue_default(startingIndex, 0);
if (!defined_default(result)) {
result = new Cartesian3();
}
result.x = array[startingIndex++];
result.y = array[startingIndex++];
result.z = array[startingIndex];
return result;
};
Cartesian3.packArray = function(array, result) {
Check_default.defined("array", array);
const length3 = array.length;
const resultLength = length3 * 3;
if (!defined_default(result)) {
result = new Array(resultLength);
} else if (!Array.isArray(result) && result.length !== resultLength) {
throw new DeveloperError_default(
"If result is a typed array, it must have exactly array.length * 3 elements"
);
} else if (result.length !== resultLength) {
result.length = resultLength;
}
for (let i = 0; i < length3; ++i) {
Cartesian3.pack(array[i], result, i * 3);
}
return result;
};
Cartesian3.unpackArray = function(array, result) {
Check_default.defined("array", array);
Check_default.typeOf.number.greaterThanOrEquals("array.length", array.length, 3);
if (array.length % 3 !== 0) {
throw new DeveloperError_default("array length must be a multiple of 3.");
}
const length3 = array.length;
if (!defined_default(result)) {
result = new Array(length3 / 3);
} else {
result.length = length3 / 3;
}
for (let i = 0; i < length3; i += 3) {
const index = i / 3;
result[index] = Cartesian3.unpack(array, i, result[index]);
}
return result;
};
Cartesian3.fromArray = Cartesian3.unpack;
Cartesian3.maximumComponent = function(cartesian11) {
Check_default.typeOf.object("cartesian", cartesian11);
return Math.max(cartesian11.x, cartesian11.y, cartesian11.z);
};
Cartesian3.minimumComponent = function(cartesian11) {
Check_default.typeOf.object("cartesian", cartesian11);
return Math.min(cartesian11.x, cartesian11.y, cartesian11.z);
};
Cartesian3.minimumByComponent = function(first, second, result) {
Check_default.typeOf.object("first", first);
Check_default.typeOf.object("second", second);
Check_default.typeOf.object("result", result);
result.x = Math.min(first.x, second.x);
result.y = Math.min(first.y, second.y);
result.z = Math.min(first.z, second.z);
return result;
};
Cartesian3.maximumByComponent = function(first, second, result) {
Check_default.typeOf.object("first", first);
Check_default.typeOf.object("second", second);
Check_default.typeOf.object("result", result);
result.x = Math.max(first.x, second.x);
result.y = Math.max(first.y, second.y);
result.z = Math.max(first.z, second.z);
return result;
};
Cartesian3.clamp = function(value, min3, max3, result) {
Check_default.typeOf.object("value", value);
Check_default.typeOf.object("min", min3);
Check_default.typeOf.object("max", max3);
Check_default.typeOf.object("result", result);
const x = Math_default.clamp(value.x, min3.x, max3.x);
const y = Math_default.clamp(value.y, min3.y, max3.y);
const z = Math_default.clamp(value.z, min3.z, max3.z);
result.x = x;
result.y = y;
result.z = z;
return result;
};
Cartesian3.magnitudeSquared = function(cartesian11) {
Check_default.typeOf.object("cartesian", cartesian11);
return cartesian11.x * cartesian11.x + cartesian11.y * cartesian11.y + cartesian11.z * cartesian11.z;
};
Cartesian3.magnitude = function(cartesian11) {
return Math.sqrt(Cartesian3.magnitudeSquared(cartesian11));
};
var distanceScratch = new Cartesian3();
Cartesian3.distance = function(left, right) {
Check_default.typeOf.object("left", left);
Check_default.typeOf.object("right", right);
Cartesian3.subtract(left, right, distanceScratch);
return Cartesian3.magnitude(distanceScratch);
};
Cartesian3.distanceSquared = function(left, right) {
Check_default.typeOf.object("left", left);
Check_default.typeOf.object("right", right);
Cartesian3.subtract(left, right, distanceScratch);
return Cartesian3.magnitudeSquared(distanceScratch);
};
Cartesian3.normalize = function(cartesian11, result) {
Check_default.typeOf.object("cartesian", cartesian11);
Check_default.typeOf.object("result", result);
const magnitude = Cartesian3.magnitude(cartesian11);
result.x = cartesian11.x / magnitude;
result.y = cartesian11.y / magnitude;
result.z = cartesian11.z / magnitude;
if (isNaN(result.x) || isNaN(result.y) || isNaN(result.z)) {
throw new DeveloperError_default("normalized result is not a number");
}
return result;
};
Cartesian3.dot = function(left, right) {
Check_default.typeOf.object("left", left);
Check_default.typeOf.object("right", right);
return left.x * right.x + left.y * right.y + left.z * right.z;
};
Cartesian3.multiplyComponents = function(left, right, result) {
Check_default.typeOf.object("left", left);
Check_default.typeOf.object("right", right);
Check_default.typeOf.object("result", result);
result.x = left.x * right.x;
result.y = left.y * right.y;
result.z = left.z * right.z;
return result;
};
Cartesian3.divideComponents = function(left, right, result) {
Check_default.typeOf.object("left", left);
Check_default.typeOf.object("right", right);
Check_default.typeOf.object("result", result);
result.x = left.x / right.x;
result.y = left.y / right.y;
result.z = left.z / right.z;
return result;
};
Cartesian3.add = function(left, right, result) {
Check_default.typeOf.object("left", left);
Check_default.typeOf.object("right", right);
Check_default.typeOf.object("result", result);
result.x = left.x + right.x;
result.y = left.y + right.y;
result.z = left.z + right.z;
return result;
};
Cartesian3.subtract = function(left, right, result) {
Check_default.typeOf.object("left", left);
Check_default.typeOf.object("right", right);
Check_default.typeOf.object("result", result);
result.x = left.x - right.x;
result.y = left.y - right.y;
result.z = left.z - right.z;
return result;
};
Cartesian3.multiplyByScalar = function(cartesian11, scalar, result) {
Check_default.typeOf.object("cartesian", cartesian11);
Check_default.typeOf.number("scalar", scalar);
Check_default.typeOf.object("result", result);
result.x = cartesian11.x * scalar;
result.y = cartesian11.y * scalar;
result.z = cartesian11.z * scalar;
return result;
};
Cartesian3.divideByScalar = function(cartesian11, scalar, result) {
Check_default.typeOf.object("cartesian", cartesian11);
Check_default.typeOf.number("scalar", scalar);
Check_default.typeOf.object("result", result);
result.x = cartesian11.x / scalar;
result.y = cartesian11.y / scalar;
result.z = cartesian11.z / scalar;
return result;
};
Cartesian3.negate = function(cartesian11, result) {
Check_default.typeOf.object("cartesian", cartesian11);
Check_default.typeOf.object("result", result);
result.x = -cartesian11.x;
result.y = -cartesian11.y;
result.z = -cartesian11.z;
return result;
};
Cartesian3.abs = function(cartesian11, result) {
Check_default.typeOf.object("cartesian", cartesian11);
Check_default.typeOf.object("result", result);
result.x = Math.abs(cartesian11.x);
result.y = Math.abs(cartesian11.y);
result.z = Math.abs(cartesian11.z);
return result;
};
var lerpScratch = new Cartesian3();
Cartesian3.lerp = function(start, end, t, result) {
Check_default.typeOf.object("start", start);
Check_default.typeOf.object("end", end);
Check_default.typeOf.number("t", t);
Check_default.typeOf.object("result", result);
Cartesian3.multiplyByScalar(end, t, lerpScratch);
result = Cartesian3.multiplyByScalar(start, 1 - t, result);
return Cartesian3.add(lerpScratch, result, result);
};
var angleBetweenScratch = new Cartesian3();
var angleBetweenScratch2 = new Cartesian3();
Cartesian3.angleBetween = function(left, right) {
Check_default.typeOf.object("left", left);
Check_default.typeOf.object("right", right);
Cartesian3.normalize(left, angleBetweenScratch);
Cartesian3.normalize(right, angleBetweenScratch2);
const cosine = Cartesian3.dot(angleBetweenScratch, angleBetweenScratch2);
const sine = Cartesian3.magnitude(
Cartesian3.cross(
angleBetweenScratch,
angleBetweenScratch2,
angleBetweenScratch
)
);
return Math.atan2(sine, cosine);
};
var mostOrthogonalAxisScratch = new Cartesian3();
Cartesian3.mostOrthogonalAxis = function(cartesian11, result) {
Check_default.typeOf.object("cartesian", cartesian11);
Check_default.typeOf.object("result", result);
const f = Cartesian3.normalize(cartesian11, mostOrthogonalAxisScratch);
Cartesian3.abs(f, f);
if (f.x <= f.y) {
if (f.x <= f.z) {
result = Cartesian3.clone(Cartesian3.UNIT_X, result);
} else {
result = Cartesian3.clone(Cartesian3.UNIT_Z, result);
}
} else if (f.y <= f.z) {
result = Cartesian3.clone(Cartesian3.UNIT_Y, result);
} else {
result = Cartesian3.clone(Cartesian3.UNIT_Z, result);
}
return result;
};
Cartesian3.projectVector = function(a3, b, result) {
Check_default.defined("a", a3);
Check_default.defined("b", b);
Check_default.defined("result", result);
const scalar = Cartesian3.dot(a3, b) / Cartesian3.dot(b, b);
return Cartesian3.multiplyByScalar(b, scalar, result);
};
Cartesian3.equals = function(left, right) {
return left === right || defined_default(left) && defined_default(right) && left.x === right.x && left.y === right.y && left.z === right.z;
};
Cartesian3.equalsArray = function(cartesian11, array, offset2) {
return cartesian11.x === array[offset2] && cartesian11.y === array[offset2 + 1] && cartesian11.z === array[offset2 + 2];
};
Cartesian3.equalsEpsilon = function(left, right, relativeEpsilon, absoluteEpsilon) {
return left === right || defined_default(left) && defined_default(right) && Math_default.equalsEpsilon(
left.x,
right.x,
relativeEpsilon,
absoluteEpsilon
) && Math_default.equalsEpsilon(
left.y,
right.y,
relativeEpsilon,
absoluteEpsilon
) && Math_default.equalsEpsilon(
left.z,
right.z,
relativeEpsilon,
absoluteEpsilon
);
};
Cartesian3.cross = function(left, right, result) {
Check_default.typeOf.object("left", left);
Check_default.typeOf.object("right", right);
Check_default.typeOf.object("result", result);
const leftX = left.x;
const leftY = left.y;
const leftZ = left.z;
const rightX = right.x;
const rightY = right.y;
const rightZ = right.z;
const x = leftY * rightZ - leftZ * rightY;
const y = leftZ * rightX - leftX * rightZ;
const z = leftX * rightY - leftY * rightX;
result.x = x;
result.y = y;
result.z = z;
return result;
};
Cartesian3.midpoint = function(left, right, result) {
Check_default.typeOf.object("left", left);
Check_default.typeOf.object("right", right);
Check_default.typeOf.object("result", result);
result.x = (left.x + right.x) * 0.5;
result.y = (left.y + right.y) * 0.5;
result.z = (left.z + right.z) * 0.5;
return result;
};
Cartesian3.fromDegrees = function(longitude, latitude, height, ellipsoid, result) {
Check_default.typeOf.number("longitude", longitude);
Check_default.typeOf.number("latitude", latitude);
longitude = Math_default.toRadians(longitude);
latitude = Math_default.toRadians(latitude);
return Cartesian3.fromRadians(longitude, latitude, height, ellipsoid, result);
};
var scratchN = new Cartesian3();
var scratchK = new Cartesian3();
var wgs84RadiiSquared = new Cartesian3(
6378137 * 6378137,
6378137 * 6378137,
6356752314245179e-9 * 6356752314245179e-9
);
Cartesian3.fromRadians = function(longitude, latitude, height, ellipsoid, result) {
Check_default.typeOf.number("longitude", longitude);
Check_default.typeOf.number("latitude", latitude);
height = defaultValue_default(height, 0);
const radiiSquared = defined_default(ellipsoid) ? ellipsoid.radiiSquared : wgs84RadiiSquared;
const cosLatitude = Math.cos(latitude);
scratchN.x = cosLatitude * Math.cos(longitude);
scratchN.y = cosLatitude * Math.sin(longitude);
scratchN.z = Math.sin(latitude);
scratchN = Cartesian3.normalize(scratchN, scratchN);
Cartesian3.multiplyComponents(radiiSquared, scratchN, scratchK);
const gamma = Math.sqrt(Cartesian3.dot(scratchN, scratchK));
scratchK = Cartesian3.divideByScalar(scratchK, gamma, scratchK);
scratchN = Cartesian3.multiplyByScalar(scratchN, height, scratchN);
if (!defined_default(result)) {
result = new Cartesian3();
}
return Cartesian3.add(scratchK, scratchN, result);
};
Cartesian3.fromDegreesArray = function(coordinates, ellipsoid, result) {
Check_default.defined("coordinates", coordinates);
if (coordinates.length < 2 || coordinates.length % 2 !== 0) {
throw new DeveloperError_default(
"the number of coordinates must be a multiple of 2 and at least 2"
);
}
const length3 = coordinates.length;
if (!defined_default(result)) {
result = new Array(length3 / 2);
} else {
result.length = length3 / 2;
}
for (let i = 0; i < length3; i += 2) {
const longitude = coordinates[i];
const latitude = coordinates[i + 1];
const index = i / 2;
result[index] = Cartesian3.fromDegrees(
longitude,
latitude,
0,
ellipsoid,
result[index]
);
}
return result;
};
Cartesian3.fromRadiansArray = function(coordinates, ellipsoid, result) {
Check_default.defined("coordinates", coordinates);
if (coordinates.length < 2 || coordinates.length % 2 !== 0) {
throw new DeveloperError_default(
"the number of coordinates must be a multiple of 2 and at least 2"
);
}
const length3 = coordinates.length;
if (!defined_default(result)) {
result = new Array(length3 / 2);
} else {
result.length = length3 / 2;
}
for (let i = 0; i < length3; i += 2) {
const longitude = coordinates[i];
const latitude = coordinates[i + 1];
const index = i / 2;
result[index] = Cartesian3.fromRadians(
longitude,
latitude,
0,
ellipsoid,
result[index]
);
}
return result;
};
Cartesian3.fromDegreesArrayHeights = function(coordinates, ellipsoid, result) {
Check_default.defined("coordinates", coordinates);
if (coordinates.length < 3 || coordinates.length % 3 !== 0) {
throw new DeveloperError_default(
"the number of coordinates must be a multiple of 3 and at least 3"
);
}
const length3 = coordinates.length;
if (!defined_default(result)) {
result = new Array(length3 / 3);
} else {
result.length = length3 / 3;
}
for (let i = 0; i < length3; i += 3) {
const longitude = coordinates[i];
const latitude = coordinates[i + 1];
const height = coordinates[i + 2];
const index = i / 3;
result[index] = Cartesian3.fromDegrees(
longitude,
latitude,
height,
ellipsoid,
result[index]
);
}
return result;
};
Cartesian3.fromRadiansArrayHeights = function(coordinates, ellipsoid, result) {
Check_default.defined("coordinates", coordinates);
if (coordinates.length < 3 || coordinates.length % 3 !== 0) {
throw new DeveloperError_default(
"the number of coordinates must be a multiple of 3 and at least 3"
);
}
const length3 = coordinates.length;
if (!defined_default(result)) {
result = new Array(length3 / 3);
} else {
result.length = length3 / 3;
}
for (let i = 0; i < length3; i += 3) {
const longitude = coordinates[i];
const latitude = coordinates[i + 1];
const height = coordinates[i + 2];
const index = i / 3;
result[index] = Cartesian3.fromRadians(
longitude,
latitude,
height,
ellipsoid,
result[index]
);
}
return result;
};
Cartesian3.ZERO = Object.freeze(new Cartesian3(0, 0, 0));
Cartesian3.ONE = Object.freeze(new Cartesian3(1, 1, 1));
Cartesian3.UNIT_X = Object.freeze(new Cartesian3(1, 0, 0));
Cartesian3.UNIT_Y = Object.freeze(new Cartesian3(0, 1, 0));
Cartesian3.UNIT_Z = Object.freeze(new Cartesian3(0, 0, 1));
Cartesian3.prototype.clone = function(result) {
return Cartesian3.clone(this, result);
};
Cartesian3.prototype.equals = function(right) {
return Cartesian3.equals(this, right);
};
Cartesian3.prototype.equalsEpsilon = function(right, relativeEpsilon, absoluteEpsilon) {
return Cartesian3.equalsEpsilon(
this,
right,
relativeEpsilon,
absoluteEpsilon
);
};
Cartesian3.prototype.toString = function() {
return `(${this.x}, ${this.y}, ${this.z})`;
};
var Cartesian3_default = Cartesian3;
// Source/Core/scaleToGeodeticSurface.js
var scaleToGeodeticSurfaceIntersection = new Cartesian3_default();
var scaleToGeodeticSurfaceGradient = new Cartesian3_default();
function scaleToGeodeticSurface(cartesian11, oneOverRadii, oneOverRadiiSquared, centerToleranceSquared, result) {
if (!defined_default(cartesian11)) {
throw new DeveloperError_default("cartesian is required.");
}
if (!defined_default(oneOverRadii)) {
throw new DeveloperError_default("oneOverRadii is required.");
}
if (!defined_default(oneOverRadiiSquared)) {
throw new DeveloperError_default("oneOverRadiiSquared is required.");
}
if (!defined_default(centerToleranceSquared)) {
throw new DeveloperError_default("centerToleranceSquared is required.");
}
const positionX = cartesian11.x;
const positionY = cartesian11.y;
const positionZ = cartesian11.z;
const oneOverRadiiX = oneOverRadii.x;
const oneOverRadiiY = oneOverRadii.y;
const oneOverRadiiZ = oneOverRadii.z;
const x2 = positionX * positionX * oneOverRadiiX * oneOverRadiiX;
const y2 = positionY * positionY * oneOverRadiiY * oneOverRadiiY;
const z2 = positionZ * positionZ * oneOverRadiiZ * oneOverRadiiZ;
const squaredNorm = x2 + y2 + z2;
const ratio = Math.sqrt(1 / squaredNorm);
const intersection = Cartesian3_default.multiplyByScalar(
cartesian11,
ratio,
scaleToGeodeticSurfaceIntersection
);
if (squaredNorm < centerToleranceSquared) {
return !isFinite(ratio) ? void 0 : Cartesian3_default.clone(intersection, result);
}
const oneOverRadiiSquaredX = oneOverRadiiSquared.x;
const oneOverRadiiSquaredY = oneOverRadiiSquared.y;
const oneOverRadiiSquaredZ = oneOverRadiiSquared.z;
const gradient = scaleToGeodeticSurfaceGradient;
gradient.x = intersection.x * oneOverRadiiSquaredX * 2;
gradient.y = intersection.y * oneOverRadiiSquaredY * 2;
gradient.z = intersection.z * oneOverRadiiSquaredZ * 2;
let lambda = (1 - ratio) * Cartesian3_default.magnitude(cartesian11) / (0.5 * Cartesian3_default.magnitude(gradient));
let correction = 0;
let func;
let denominator;
let xMultiplier;
let yMultiplier;
let zMultiplier;
let xMultiplier2;
let yMultiplier2;
let zMultiplier2;
let xMultiplier3;
let yMultiplier3;
let zMultiplier3;
do {
lambda -= correction;
xMultiplier = 1 / (1 + lambda * oneOverRadiiSquaredX);
yMultiplier = 1 / (1 + lambda * oneOverRadiiSquaredY);
zMultiplier = 1 / (1 + lambda * oneOverRadiiSquaredZ);
xMultiplier2 = xMultiplier * xMultiplier;
yMultiplier2 = yMultiplier * yMultiplier;
zMultiplier2 = zMultiplier * zMultiplier;
xMultiplier3 = xMultiplier2 * xMultiplier;
yMultiplier3 = yMultiplier2 * yMultiplier;
zMultiplier3 = zMultiplier2 * zMultiplier;
func = x2 * xMultiplier2 + y2 * yMultiplier2 + z2 * zMultiplier2 - 1;
denominator = x2 * xMultiplier3 * oneOverRadiiSquaredX + y2 * yMultiplier3 * oneOverRadiiSquaredY + z2 * zMultiplier3 * oneOverRadiiSquaredZ;
const derivative = -2 * denominator;
correction = func / derivative;
} while (Math.abs(func) > Math_default.EPSILON12);
if (!defined_default(result)) {
return new Cartesian3_default(
positionX * xMultiplier,
positionY * yMultiplier,
positionZ * zMultiplier
);
}
result.x = positionX * xMultiplier;
result.y = positionY * yMultiplier;
result.z = positionZ * zMultiplier;
return result;
}
var scaleToGeodeticSurface_default = scaleToGeodeticSurface;
// Source/Core/Cartographic.js
function Cartographic(longitude, latitude, height) {
this.longitude = defaultValue_default(longitude, 0);
this.latitude = defaultValue_default(latitude, 0);
this.height = defaultValue_default(height, 0);
}
Cartographic.fromRadians = function(longitude, latitude, height, result) {
Check_default.typeOf.number("longitude", longitude);
Check_default.typeOf.number("latitude", latitude);
height = defaultValue_default(height, 0);
if (!defined_default(result)) {
return new Cartographic(longitude, latitude, height);
}
result.longitude = longitude;
result.latitude = latitude;
result.height = height;
return result;
};
Cartographic.fromDegrees = function(longitude, latitude, height, result) {
Check_default.typeOf.number("longitude", longitude);
Check_default.typeOf.number("latitude", latitude);
longitude = Math_default.toRadians(longitude);
latitude = Math_default.toRadians(latitude);
return Cartographic.fromRadians(longitude, latitude, height, result);
};
var cartesianToCartographicN = new Cartesian3_default();
var cartesianToCartographicP = new Cartesian3_default();
var cartesianToCartographicH = new Cartesian3_default();
var wgs84OneOverRadii = new Cartesian3_default(
1 / 6378137,
1 / 6378137,
1 / 6356752314245179e-9
);
var wgs84OneOverRadiiSquared = new Cartesian3_default(
1 / (6378137 * 6378137),
1 / (6378137 * 6378137),
1 / (6356752314245179e-9 * 6356752314245179e-9)
);
var wgs84CenterToleranceSquared = Math_default.EPSILON1;
Cartographic.fromCartesian = function(cartesian11, ellipsoid, result) {
const oneOverRadii = defined_default(ellipsoid) ? ellipsoid.oneOverRadii : wgs84OneOverRadii;
const oneOverRadiiSquared = defined_default(ellipsoid) ? ellipsoid.oneOverRadiiSquared : wgs84OneOverRadiiSquared;
const centerToleranceSquared = defined_default(ellipsoid) ? ellipsoid._centerToleranceSquared : wgs84CenterToleranceSquared;
const p = scaleToGeodeticSurface_default(
cartesian11,
oneOverRadii,
oneOverRadiiSquared,
centerToleranceSquared,
cartesianToCartographicP
);
if (!defined_default(p)) {
return void 0;
}
let n = Cartesian3_default.multiplyComponents(
p,
oneOverRadiiSquared,
cartesianToCartographicN
);
n = Cartesian3_default.normalize(n, n);
const h = Cartesian3_default.subtract(cartesian11, p, cartesianToCartographicH);
const longitude = Math.atan2(n.y, n.x);
const latitude = Math.asin(n.z);
const height = Math_default.sign(Cartesian3_default.dot(h, cartesian11)) * Cartesian3_default.magnitude(h);
if (!defined_default(result)) {
return new Cartographic(longitude, latitude, height);
}
result.longitude = longitude;
result.latitude = latitude;
result.height = height;
return result;
};
Cartographic.toCartesian = function(cartographic2, ellipsoid, result) {
Check_default.defined("cartographic", cartographic2);
return Cartesian3_default.fromRadians(
cartographic2.longitude,
cartographic2.latitude,
cartographic2.height,
ellipsoid,
result
);
};
Cartographic.clone = function(cartographic2, result) {
if (!defined_default(cartographic2)) {
return void 0;
}
if (!defined_default(result)) {
return new Cartographic(
cartographic2.longitude,
cartographic2.latitude,
cartographic2.height
);
}
result.longitude = cartographic2.longitude;
result.latitude = cartographic2.latitude;
result.height = cartographic2.height;
return result;
};
Cartographic.equals = function(left, right) {
return left === right || defined_default(left) && defined_default(right) && left.longitude === right.longitude && left.latitude === right.latitude && left.height === right.height;
};
Cartographic.equalsEpsilon = function(left, right, epsilon) {
epsilon = defaultValue_default(epsilon, 0);
return left === right || defined_default(left) && defined_default(right) && Math.abs(left.longitude - right.longitude) <= epsilon && Math.abs(left.latitude - right.latitude) <= epsilon && Math.abs(left.height - right.height) <= epsilon;
};
Cartographic.ZERO = Object.freeze(new Cartographic(0, 0, 0));
Cartographic.prototype.clone = function(result) {
return Cartographic.clone(this, result);
};
Cartographic.prototype.equals = function(right) {
return Cartographic.equals(this, right);
};
Cartographic.prototype.equalsEpsilon = function(right, epsilon) {
return Cartographic.equalsEpsilon(this, right, epsilon);
};
Cartographic.prototype.toString = function() {
return `(${this.longitude}, ${this.latitude}, ${this.height})`;
};
var Cartographic_default = Cartographic;
// Source/Core/Ellipsoid.js
function initialize(ellipsoid, x, y, z) {
x = defaultValue_default(x, 0);
y = defaultValue_default(y, 0);
z = defaultValue_default(z, 0);
Check_default.typeOf.number.greaterThanOrEquals("x", x, 0);
Check_default.typeOf.number.greaterThanOrEquals("y", y, 0);
Check_default.typeOf.number.greaterThanOrEquals("z", z, 0);
ellipsoid._radii = new Cartesian3_default(x, y, z);
ellipsoid._radiiSquared = new Cartesian3_default(x * x, y * y, z * z);
ellipsoid._radiiToTheFourth = new Cartesian3_default(
x * x * x * x,
y * y * y * y,
z * z * z * z
);
ellipsoid._oneOverRadii = new Cartesian3_default(
x === 0 ? 0 : 1 / x,
y === 0 ? 0 : 1 / y,
z === 0 ? 0 : 1 / z
);
ellipsoid._oneOverRadiiSquared = new Cartesian3_default(
x === 0 ? 0 : 1 / (x * x),
y === 0 ? 0 : 1 / (y * y),
z === 0 ? 0 : 1 / (z * z)
);
ellipsoid._minimumRadius = Math.min(x, y, z);
ellipsoid._maximumRadius = Math.max(x, y, z);
ellipsoid._centerToleranceSquared = Math_default.EPSILON1;
if (ellipsoid._radiiSquared.z !== 0) {
ellipsoid._squaredXOverSquaredZ = ellipsoid._radiiSquared.x / ellipsoid._radiiSquared.z;
}
}
function Ellipsoid(x, y, z) {
this._radii = void 0;
this._radiiSquared = void 0;
this._radiiToTheFourth = void 0;
this._oneOverRadii = void 0;
this._oneOverRadiiSquared = void 0;
this._minimumRadius = void 0;
this._maximumRadius = void 0;
this._centerToleranceSquared = void 0;
this._squaredXOverSquaredZ = void 0;
initialize(this, x, y, z);
}
Object.defineProperties(Ellipsoid.prototype, {
radii: {
get: function() {
return this._radii;
}
},
radiiSquared: {
get: function() {
return this._radiiSquared;
}
},
radiiToTheFourth: {
get: function() {
return this._radiiToTheFourth;
}
},
oneOverRadii: {
get: function() {
return this._oneOverRadii;
}
},
oneOverRadiiSquared: {
get: function() {
return this._oneOverRadiiSquared;
}
},
minimumRadius: {
get: function() {
return this._minimumRadius;
}
},
maximumRadius: {
get: function() {
return this._maximumRadius;
}
}
});
Ellipsoid.clone = function(ellipsoid, result) {
if (!defined_default(ellipsoid)) {
return void 0;
}
const radii = ellipsoid._radii;
if (!defined_default(result)) {
return new Ellipsoid(radii.x, radii.y, radii.z);
}
Cartesian3_default.clone(radii, result._radii);
Cartesian3_default.clone(ellipsoid._radiiSquared, result._radiiSquared);
Cartesian3_default.clone(ellipsoid._radiiToTheFourth, result._radiiToTheFourth);
Cartesian3_default.clone(ellipsoid._oneOverRadii, result._oneOverRadii);
Cartesian3_default.clone(ellipsoid._oneOverRadiiSquared, result._oneOverRadiiSquared);
result._minimumRadius = ellipsoid._minimumRadius;
result._maximumRadius = ellipsoid._maximumRadius;
result._centerToleranceSquared = ellipsoid._centerToleranceSquared;
return result;
};
Ellipsoid.fromCartesian3 = function(cartesian11, result) {
if (!defined_default(result)) {
result = new Ellipsoid();
}
if (!defined_default(cartesian11)) {
return result;
}
initialize(result, cartesian11.x, cartesian11.y, cartesian11.z);
return result;
};
Ellipsoid.WGS84 = Object.freeze(
new Ellipsoid(6378137, 6378137, 6356752314245179e-9)
);
Ellipsoid.UNIT_SPHERE = Object.freeze(new Ellipsoid(1, 1, 1));
Ellipsoid.MOON = Object.freeze(
new Ellipsoid(
Math_default.LUNAR_RADIUS,
Math_default.LUNAR_RADIUS,
Math_default.LUNAR_RADIUS
)
);
Ellipsoid.prototype.clone = function(result) {
return Ellipsoid.clone(this, result);
};
Ellipsoid.packedLength = Cartesian3_default.packedLength;
Ellipsoid.pack = function(value, array, startingIndex) {
Check_default.typeOf.object("value", value);
Check_default.defined("array", array);
startingIndex = defaultValue_default(startingIndex, 0);
Cartesian3_default.pack(value._radii, array, startingIndex);
return array;
};
Ellipsoid.unpack = function(array, startingIndex, result) {
Check_default.defined("array", array);
startingIndex = defaultValue_default(startingIndex, 0);
const radii = Cartesian3_default.unpack(array, startingIndex);
return Ellipsoid.fromCartesian3(radii, result);
};
Ellipsoid.prototype.geocentricSurfaceNormal = Cartesian3_default.normalize;
Ellipsoid.prototype.geodeticSurfaceNormalCartographic = function(cartographic2, result) {
Check_default.typeOf.object("cartographic", cartographic2);
const longitude = cartographic2.longitude;
const latitude = cartographic2.latitude;
const cosLatitude = Math.cos(latitude);
const x = cosLatitude * Math.cos(longitude);
const y = cosLatitude * Math.sin(longitude);
const z = Math.sin(latitude);
if (!defined_default(result)) {
result = new Cartesian3_default();
}
result.x = x;
result.y = y;
result.z = z;
return Cartesian3_default.normalize(result, result);
};
Ellipsoid.prototype.geodeticSurfaceNormal = function(cartesian11, result) {
if (Cartesian3_default.equalsEpsilon(cartesian11, Cartesian3_default.ZERO, Math_default.EPSILON14)) {
return void 0;
}
if (!defined_default(result)) {
result = new Cartesian3_default();
}
result = Cartesian3_default.multiplyComponents(
cartesian11,
this._oneOverRadiiSquared,
result
);
return Cartesian3_default.normalize(result, result);
};
var cartographicToCartesianNormal = new Cartesian3_default();
var cartographicToCartesianK = new Cartesian3_default();
Ellipsoid.prototype.cartographicToCartesian = function(cartographic2, result) {
const n = cartographicToCartesianNormal;
const k = cartographicToCartesianK;
this.geodeticSurfaceNormalCartographic(cartographic2, n);
Cartesian3_default.multiplyComponents(this._radiiSquared, n, k);
const gamma = Math.sqrt(Cartesian3_default.dot(n, k));
Cartesian3_default.divideByScalar(k, gamma, k);
Cartesian3_default.multiplyByScalar(n, cartographic2.height, n);
if (!defined_default(result)) {
result = new Cartesian3_default();
}
return Cartesian3_default.add(k, n, result);
};
Ellipsoid.prototype.cartographicArrayToCartesianArray = function(cartographics, result) {
Check_default.defined("cartographics", cartographics);
const length3 = cartographics.length;
if (!defined_default(result)) {
result = new Array(length3);
} else {
result.length = length3;
}
for (let i = 0; i < length3; i++) {
result[i] = this.cartographicToCartesian(cartographics[i], result[i]);
}
return result;
};
var cartesianToCartographicN2 = new Cartesian3_default();
var cartesianToCartographicP2 = new Cartesian3_default();
var cartesianToCartographicH2 = new Cartesian3_default();
Ellipsoid.prototype.cartesianToCartographic = function(cartesian11, result) {
const p = this.scaleToGeodeticSurface(cartesian11, cartesianToCartographicP2);
if (!defined_default(p)) {
return void 0;
}
const n = this.geodeticSurfaceNormal(p, cartesianToCartographicN2);
const h = Cartesian3_default.subtract(cartesian11, p, cartesianToCartographicH2);
const longitude = Math.atan2(n.y, n.x);
const latitude = Math.asin(n.z);
const height = Math_default.sign(Cartesian3_default.dot(h, cartesian11)) * Cartesian3_default.magnitude(h);
if (!defined_default(result)) {
return new Cartographic_default(longitude, latitude, height);
}
result.longitude = longitude;
result.latitude = latitude;
result.height = height;
return result;
};
Ellipsoid.prototype.cartesianArrayToCartographicArray = function(cartesians, result) {
Check_default.defined("cartesians", cartesians);
const length3 = cartesians.length;
if (!defined_default(result)) {
result = new Array(length3);
} else {
result.length = length3;
}
for (let i = 0; i < length3; ++i) {
result[i] = this.cartesianToCartographic(cartesians[i], result[i]);
}
return result;
};
Ellipsoid.prototype.scaleToGeodeticSurface = function(cartesian11, result) {
return scaleToGeodeticSurface_default(
cartesian11,
this._oneOverRadii,
this._oneOverRadiiSquared,
this._centerToleranceSquared,
result
);
};
Ellipsoid.prototype.scaleToGeocentricSurface = function(cartesian11, result) {
Check_default.typeOf.object("cartesian", cartesian11);
if (!defined_default(result)) {
result = new Cartesian3_default();
}
const positionX = cartesian11.x;
const positionY = cartesian11.y;
const positionZ = cartesian11.z;
const oneOverRadiiSquared = this._oneOverRadiiSquared;
const beta = 1 / Math.sqrt(
positionX * positionX * oneOverRadiiSquared.x + positionY * positionY * oneOverRadiiSquared.y + positionZ * positionZ * oneOverRadiiSquared.z
);
return Cartesian3_default.multiplyByScalar(cartesian11, beta, result);
};
Ellipsoid.prototype.transformPositionToScaledSpace = function(position, result) {
if (!defined_default(result)) {
result = new Cartesian3_default();
}
return Cartesian3_default.multiplyComponents(position, this._oneOverRadii, result);
};
Ellipsoid.prototype.transformPositionFromScaledSpace = function(position, result) {
if (!defined_default(result)) {
result = new Cartesian3_default();
}
return Cartesian3_default.multiplyComponents(position, this._radii, result);
};
Ellipsoid.prototype.equals = function(right) {
return this === right || defined_default(right) && Cartesian3_default.equals(this._radii, right._radii);
};
Ellipsoid.prototype.toString = function() {
return this._radii.toString();
};
Ellipsoid.prototype.getSurfaceNormalIntersectionWithZAxis = function(position, buffer, result) {
Check_default.typeOf.object("position", position);
if (!Math_default.equalsEpsilon(
this._radii.x,
this._radii.y,
Math_default.EPSILON15
)) {
throw new DeveloperError_default(
"Ellipsoid must be an ellipsoid of revolution (radii.x == radii.y)"
);
}
Check_default.typeOf.number.greaterThan("Ellipsoid.radii.z", this._radii.z, 0);
buffer = defaultValue_default(buffer, 0);
const squaredXOverSquaredZ = this._squaredXOverSquaredZ;
if (!defined_default(result)) {
result = new Cartesian3_default();
}
result.x = 0;
result.y = 0;
result.z = position.z * (1 - squaredXOverSquaredZ);
if (Math.abs(result.z) >= this._radii.z - buffer) {
return void 0;
}
return result;
};
var abscissas = [
0.14887433898163,
0.43339539412925,
0.67940956829902,
0.86506336668898,
0.97390652851717,
0
];
var weights = [
0.29552422471475,
0.26926671930999,
0.21908636251598,
0.14945134915058,
0.066671344308684,
0
];
function gaussLegendreQuadrature(a3, b, func) {
Check_default.typeOf.number("a", a3);
Check_default.typeOf.number("b", b);
Check_default.typeOf.func("func", func);
const xMean = 0.5 * (b + a3);
const xRange = 0.5 * (b - a3);
let sum = 0;
for (let i = 0; i < 5; i++) {
const dx = xRange * abscissas[i];
sum += weights[i] * (func(xMean + dx) + func(xMean - dx));
}
sum *= xRange;
return sum;
}
Ellipsoid.prototype.surfaceArea = function(rectangle) {
Check_default.typeOf.object("rectangle", rectangle);
const minLongitude = rectangle.west;
let maxLongitude = rectangle.east;
const minLatitude = rectangle.south;
const maxLatitude = rectangle.north;
while (maxLongitude < minLongitude) {
maxLongitude += Math_default.TWO_PI;
}
const radiiSquared = this._radiiSquared;
const a22 = radiiSquared.x;
const b2 = radiiSquared.y;
const c22 = radiiSquared.z;
const a2b2 = a22 * b2;
return gaussLegendreQuadrature(minLatitude, maxLatitude, function(lat) {
const sinPhi = Math.cos(lat);
const cosPhi = Math.sin(lat);
return Math.cos(lat) * gaussLegendreQuadrature(minLongitude, maxLongitude, function(lon) {
const cosTheta = Math.cos(lon);
const sinTheta = Math.sin(lon);
return Math.sqrt(
a2b2 * cosPhi * cosPhi + c22 * (b2 * cosTheta * cosTheta + a22 * sinTheta * sinTheta) * sinPhi * sinPhi
);
});
});
};
var Ellipsoid_default = Ellipsoid;
// Source/Core/GeographicProjection.js
function GeographicProjection(ellipsoid) {
this._ellipsoid = defaultValue_default(ellipsoid, Ellipsoid_default.WGS84);
this._semimajorAxis = this._ellipsoid.maximumRadius;
this._oneOverSemimajorAxis = 1 / this._semimajorAxis;
}
Object.defineProperties(GeographicProjection.prototype, {
ellipsoid: {
get: function() {
return this._ellipsoid;
}
}
});
GeographicProjection.prototype.project = function(cartographic2, result) {
const semimajorAxis = this._semimajorAxis;
const x = cartographic2.longitude * semimajorAxis;
const y = cartographic2.latitude * semimajorAxis;
const z = cartographic2.height;
if (!defined_default(result)) {
return new Cartesian3_default(x, y, z);
}
result.x = x;
result.y = y;
result.z = z;
return result;
};
GeographicProjection.prototype.unproject = function(cartesian11, result) {
if (!defined_default(cartesian11)) {
throw new DeveloperError_default("cartesian is required");
}
const oneOverEarthSemimajorAxis = this._oneOverSemimajorAxis;
const longitude = cartesian11.x * oneOverEarthSemimajorAxis;
const latitude = cartesian11.y * oneOverEarthSemimajorAxis;
const height = cartesian11.z;
if (!defined_default(result)) {
return new Cartographic_default(longitude, latitude, height);
}
result.longitude = longitude;
result.latitude = latitude;
result.height = height;
return result;
};
var GeographicProjection_default = GeographicProjection;
// Source/Core/Intersect.js
var Intersect = {
OUTSIDE: -1,
INTERSECTING: 0,
INSIDE: 1
};
var Intersect_default = Object.freeze(Intersect);
// Source/Core/Interval.js
function Interval(start, stop2) {
this.start = defaultValue_default(start, 0);
this.stop = defaultValue_default(stop2, 0);
}
var Interval_default = Interval;
// Source/Core/Matrix3.js
function Matrix3(column0Row0, column1Row0, column2Row0, column0Row1, column1Row1, column2Row1, column0Row2, column1Row2, column2Row2) {
this[0] = defaultValue_default(column0Row0, 0);
this[1] = defaultValue_default(column0Row1, 0);
this[2] = defaultValue_default(column0Row2, 0);
this[3] = defaultValue_default(column1Row0, 0);
this[4] = defaultValue_default(column1Row1, 0);
this[5] = defaultValue_default(column1Row2, 0);
this[6] = defaultValue_default(column2Row0, 0);
this[7] = defaultValue_default(column2Row1, 0);
this[8] = defaultValue_default(column2Row2, 0);
}
Matrix3.packedLength = 9;
Matrix3.pack = function(value, array, startingIndex) {
Check_default.typeOf.object("value", value);
Check_default.defined("array", array);
startingIndex = defaultValue_default(startingIndex, 0);
array[startingIndex++] = value[0];
array[startingIndex++] = value[1];
array[startingIndex++] = value[2];
array[startingIndex++] = value[3];
array[startingIndex++] = value[4];
array[startingIndex++] = value[5];
array[startingIndex++] = value[6];
array[startingIndex++] = value[7];
array[startingIndex++] = value[8];
return array;
};
Matrix3.unpack = function(array, startingIndex, result) {
Check_default.defined("array", array);
startingIndex = defaultValue_default(startingIndex, 0);
if (!defined_default(result)) {
result = new Matrix3();
}
result[0] = array[startingIndex++];
result[1] = array[startingIndex++];
result[2] = array[startingIndex++];
result[3] = array[startingIndex++];
result[4] = array[startingIndex++];
result[5] = array[startingIndex++];
result[6] = array[startingIndex++];
result[7] = array[startingIndex++];
result[8] = array[startingIndex++];
return result;
};
Matrix3.packArray = function(array, result) {
Check_default.defined("array", array);
const length3 = array.length;
const resultLength = length3 * 9;
if (!defined_default(result)) {
result = new Array(resultLength);
} else if (!Array.isArray(result) && result.length !== resultLength) {
throw new DeveloperError_default(
"If result is a typed array, it must have exactly array.length * 9 elements"
);
} else if (result.length !== resultLength) {
result.length = resultLength;
}
for (let i = 0; i < length3; ++i) {
Matrix3.pack(array[i], result, i * 9);
}
return result;
};
Matrix3.unpackArray = function(array, result) {
Check_default.defined("array", array);
Check_default.typeOf.number.greaterThanOrEquals("array.length", array.length, 9);
if (array.length % 9 !== 0) {
throw new DeveloperError_default("array length must be a multiple of 9.");
}
const length3 = array.length;
if (!defined_default(result)) {
result = new Array(length3 / 9);
} else {
result.length = length3 / 9;
}
for (let i = 0; i < length3; i += 9) {
const index = i / 9;
result[index] = Matrix3.unpack(array, i, result[index]);
}
return result;
};
Matrix3.clone = function(matrix, result) {
if (!defined_default(matrix)) {
return void 0;
}
if (!defined_default(result)) {
return new Matrix3(
matrix[0],
matrix[3],
matrix[6],
matrix[1],
matrix[4],
matrix[7],
matrix[2],
matrix[5],
matrix[8]
);
}
result[0] = matrix[0];
result[1] = matrix[1];
result[2] = matrix[2];
result[3] = matrix[3];
result[4] = matrix[4];
result[5] = matrix[5];
result[6] = matrix[6];
result[7] = matrix[7];
result[8] = matrix[8];
return result;
};
Matrix3.fromArray = Matrix3.unpack;
Matrix3.fromColumnMajorArray = function(values, result) {
Check_default.defined("values", values);
return Matrix3.clone(values, result);
};
Matrix3.fromRowMajorArray = function(values, result) {
Check_default.defined("values", values);
if (!defined_default(result)) {
return new Matrix3(
values[0],
values[1],
values[2],
values[3],
values[4],
values[5],
values[6],
values[7],
values[8]
);
}
result[0] = values[0];
result[1] = values[3];
result[2] = values[6];
result[3] = values[1];
result[4] = values[4];
result[5] = values[7];
result[6] = values[2];
result[7] = values[5];
result[8] = values[8];
return result;
};
Matrix3.fromQuaternion = function(quaternion, result) {
Check_default.typeOf.object("quaternion", quaternion);
const x2 = quaternion.x * quaternion.x;
const xy = quaternion.x * quaternion.y;
const xz = quaternion.x * quaternion.z;
const xw = quaternion.x * quaternion.w;
const y2 = quaternion.y * quaternion.y;
const yz = quaternion.y * quaternion.z;
const yw = quaternion.y * quaternion.w;
const z2 = quaternion.z * quaternion.z;
const zw = quaternion.z * quaternion.w;
const w2 = quaternion.w * quaternion.w;
const m00 = x2 - y2 - z2 + w2;
const m01 = 2 * (xy - zw);
const m02 = 2 * (xz + yw);
const m10 = 2 * (xy + zw);
const m11 = -x2 + y2 - z2 + w2;
const m12 = 2 * (yz - xw);
const m20 = 2 * (xz - yw);
const m21 = 2 * (yz + xw);
const m22 = -x2 - y2 + z2 + w2;
if (!defined_default(result)) {
return new Matrix3(m00, m01, m02, m10, m11, m12, m20, m21, m22);
}
result[0] = m00;
result[1] = m10;
result[2] = m20;
result[3] = m01;
result[4] = m11;
result[5] = m21;
result[6] = m02;
result[7] = m12;
result[8] = m22;
return result;
};
Matrix3.fromHeadingPitchRoll = function(headingPitchRoll, result) {
Check_default.typeOf.object("headingPitchRoll", headingPitchRoll);
const cosTheta = Math.cos(-headingPitchRoll.pitch);
const cosPsi = Math.cos(-headingPitchRoll.heading);
const cosPhi = Math.cos(headingPitchRoll.roll);
const sinTheta = Math.sin(-headingPitchRoll.pitch);
const sinPsi = Math.sin(-headingPitchRoll.heading);
const sinPhi = Math.sin(headingPitchRoll.roll);
const m00 = cosTheta * cosPsi;
const m01 = -cosPhi * sinPsi + sinPhi * sinTheta * cosPsi;
const m02 = sinPhi * sinPsi + cosPhi * sinTheta * cosPsi;
const m10 = cosTheta * sinPsi;
const m11 = cosPhi * cosPsi + sinPhi * sinTheta * sinPsi;
const m12 = -sinPhi * cosPsi + cosPhi * sinTheta * sinPsi;
const m20 = -sinTheta;
const m21 = sinPhi * cosTheta;
const m22 = cosPhi * cosTheta;
if (!defined_default(result)) {
return new Matrix3(m00, m01, m02, m10, m11, m12, m20, m21, m22);
}
result[0] = m00;
result[1] = m10;
result[2] = m20;
result[3] = m01;
result[4] = m11;
result[5] = m21;
result[6] = m02;
result[7] = m12;
result[8] = m22;
return result;
};
Matrix3.fromScale = function(scale, result) {
Check_default.typeOf.object("scale", scale);
if (!defined_default(result)) {
return new Matrix3(scale.x, 0, 0, 0, scale.y, 0, 0, 0, scale.z);
}
result[0] = scale.x;
result[1] = 0;
result[2] = 0;
result[3] = 0;
result[4] = scale.y;
result[5] = 0;
result[6] = 0;
result[7] = 0;
result[8] = scale.z;
return result;
};
Matrix3.fromUniformScale = function(scale, result) {
Check_default.typeOf.number("scale", scale);
if (!defined_default(result)) {
return new Matrix3(scale, 0, 0, 0, scale, 0, 0, 0, scale);
}
result[0] = scale;
result[1] = 0;
result[2] = 0;
result[3] = 0;
result[4] = scale;
result[5] = 0;
result[6] = 0;
result[7] = 0;
result[8] = scale;
return result;
};
Matrix3.fromCrossProduct = function(vector, result) {
Check_default.typeOf.object("vector", vector);
if (!defined_default(result)) {
return new Matrix3(
0,
-vector.z,
vector.y,
vector.z,
0,
-vector.x,
-vector.y,
vector.x,
0
);
}
result[0] = 0;
result[1] = vector.z;
result[2] = -vector.y;
result[3] = -vector.z;
result[4] = 0;
result[5] = vector.x;
result[6] = vector.y;
result[7] = -vector.x;
result[8] = 0;
return result;
};
Matrix3.fromRotationX = function(angle, result) {
Check_default.typeOf.number("angle", angle);
const cosAngle = Math.cos(angle);
const sinAngle = Math.sin(angle);
if (!defined_default(result)) {
return new Matrix3(
1,
0,
0,
0,
cosAngle,
-sinAngle,
0,
sinAngle,
cosAngle
);
}
result[0] = 1;
result[1] = 0;
result[2] = 0;
result[3] = 0;
result[4] = cosAngle;
result[5] = sinAngle;
result[6] = 0;
result[7] = -sinAngle;
result[8] = cosAngle;
return result;
};
Matrix3.fromRotationY = function(angle, result) {
Check_default.typeOf.number("angle", angle);
const cosAngle = Math.cos(angle);
const sinAngle = Math.sin(angle);
if (!defined_default(result)) {
return new Matrix3(
cosAngle,
0,
sinAngle,
0,
1,
0,
-sinAngle,
0,
cosAngle
);
}
result[0] = cosAngle;
result[1] = 0;
result[2] = -sinAngle;
result[3] = 0;
result[4] = 1;
result[5] = 0;
result[6] = sinAngle;
result[7] = 0;
result[8] = cosAngle;
return result;
};
Matrix3.fromRotationZ = function(angle, result) {
Check_default.typeOf.number("angle", angle);
const cosAngle = Math.cos(angle);
const sinAngle = Math.sin(angle);
if (!defined_default(result)) {
return new Matrix3(
cosAngle,
-sinAngle,
0,
sinAngle,
cosAngle,
0,
0,
0,
1
);
}
result[0] = cosAngle;
result[1] = sinAngle;
result[2] = 0;
result[3] = -sinAngle;
result[4] = cosAngle;
result[5] = 0;
result[6] = 0;
result[7] = 0;
result[8] = 1;
return result;
};
Matrix3.toArray = function(matrix, result) {
Check_default.typeOf.object("matrix", matrix);
if (!defined_default(result)) {
return [
matrix[0],
matrix[1],
matrix[2],
matrix[3],
matrix[4],
matrix[5],
matrix[6],
matrix[7],
matrix[8]
];
}
result[0] = matrix[0];
result[1] = matrix[1];
result[2] = matrix[2];
result[3] = matrix[3];
result[4] = matrix[4];
result[5] = matrix[5];
result[6] = matrix[6];
result[7] = matrix[7];
result[8] = matrix[8];
return result;
};
Matrix3.getElementIndex = function(column, row) {
Check_default.typeOf.number.greaterThanOrEquals("row", row, 0);
Check_default.typeOf.number.lessThanOrEquals("row", row, 2);
Check_default.typeOf.number.greaterThanOrEquals("column", column, 0);
Check_default.typeOf.number.lessThanOrEquals("column", column, 2);
return column * 3 + row;
};
Matrix3.getColumn = function(matrix, index, result) {
Check_default.typeOf.object("matrix", matrix);
Check_default.typeOf.number.greaterThanOrEquals("index", index, 0);
Check_default.typeOf.number.lessThanOrEquals("index", index, 2);
Check_default.typeOf.object("result", result);
const startIndex = index * 3;
const x = matrix[startIndex];
const y = matrix[startIndex + 1];
const z = matrix[startIndex + 2];
result.x = x;
result.y = y;
result.z = z;
return result;
};
Matrix3.setColumn = function(matrix, index, cartesian11, result) {
Check_default.typeOf.object("matrix", matrix);
Check_default.typeOf.number.greaterThanOrEquals("index", index, 0);
Check_default.typeOf.number.lessThanOrEquals("index", index, 2);
Check_default.typeOf.object("cartesian", cartesian11);
Check_default.typeOf.object("result", result);
result = Matrix3.clone(matrix, result);
const startIndex = index * 3;
result[startIndex] = cartesian11.x;
result[startIndex + 1] = cartesian11.y;
result[startIndex + 2] = cartesian11.z;
return result;
};
Matrix3.getRow = function(matrix, index, result) {
Check_default.typeOf.object("matrix", matrix);
Check_default.typeOf.number.greaterThanOrEquals("index", index, 0);
Check_default.typeOf.number.lessThanOrEquals("index", index, 2);
Check_default.typeOf.object("result", result);
const x = matrix[index];
const y = matrix[index + 3];
const z = matrix[index + 6];
result.x = x;
result.y = y;
result.z = z;
return result;
};
Matrix3.setRow = function(matrix, index, cartesian11, result) {
Check_default.typeOf.object("matrix", matrix);
Check_default.typeOf.number.greaterThanOrEquals("index", index, 0);
Check_default.typeOf.number.lessThanOrEquals("index", index, 2);
Check_default.typeOf.object("cartesian", cartesian11);
Check_default.typeOf.object("result", result);
result = Matrix3.clone(matrix, result);
result[index] = cartesian11.x;
result[index + 3] = cartesian11.y;
result[index + 6] = cartesian11.z;
return result;
};
var scaleScratch1 = new Cartesian3_default();
Matrix3.setScale = function(matrix, scale, result) {
Check_default.typeOf.object("matrix", matrix);
Check_default.typeOf.object("scale", scale);
Check_default.typeOf.object("result", result);
const existingScale = Matrix3.getScale(matrix, scaleScratch1);
const scaleRatioX = scale.x / existingScale.x;
const scaleRatioY = scale.y / existingScale.y;
const scaleRatioZ = scale.z / existingScale.z;
result[0] = matrix[0] * scaleRatioX;
result[1] = matrix[1] * scaleRatioX;
result[2] = matrix[2] * scaleRatioX;
result[3] = matrix[3] * scaleRatioY;
result[4] = matrix[4] * scaleRatioY;
result[5] = matrix[5] * scaleRatioY;
result[6] = matrix[6] * scaleRatioZ;
result[7] = matrix[7] * scaleRatioZ;
result[8] = matrix[8] * scaleRatioZ;
return result;
};
var scaleScratch2 = new Cartesian3_default();
Matrix3.setUniformScale = function(matrix, scale, result) {
Check_default.typeOf.object("matrix", matrix);
Check_default.typeOf.number("scale", scale);
Check_default.typeOf.object("result", result);
const existingScale = Matrix3.getScale(matrix, scaleScratch2);
const scaleRatioX = scale / existingScale.x;
const scaleRatioY = scale / existingScale.y;
const scaleRatioZ = scale / existingScale.z;
result[0] = matrix[0] * scaleRatioX;
result[1] = matrix[1] * scaleRatioX;
result[2] = matrix[2] * scaleRatioX;
result[3] = matrix[3] * scaleRatioY;
result[4] = matrix[4] * scaleRatioY;
result[5] = matrix[5] * scaleRatioY;
result[6] = matrix[6] * scaleRatioZ;
result[7] = matrix[7] * scaleRatioZ;
result[8] = matrix[8] * scaleRatioZ;
return result;
};
var scratchColumn = new Cartesian3_default();
Matrix3.getScale = function(matrix, result) {
Check_default.typeOf.object("matrix", matrix);
Check_default.typeOf.object("result", result);
result.x = Cartesian3_default.magnitude(
Cartesian3_default.fromElements(matrix[0], matrix[1], matrix[2], scratchColumn)
);
result.y = Cartesian3_default.magnitude(
Cartesian3_default.fromElements(matrix[3], matrix[4], matrix[5], scratchColumn)
);
result.z = Cartesian3_default.magnitude(
Cartesian3_default.fromElements(matrix[6], matrix[7], matrix[8], scratchColumn)
);
return result;
};
var scaleScratch3 = new Cartesian3_default();
Matrix3.getMaximumScale = function(matrix) {
Matrix3.getScale(matrix, scaleScratch3);
return Cartesian3_default.maximumComponent(scaleScratch3);
};
var scaleScratch4 = new Cartesian3_default();
Matrix3.setRotation = function(matrix, rotation, result) {
Check_default.typeOf.object("matrix", matrix);
Check_default.typeOf.object("result", result);
const scale = Matrix3.getScale(matrix, scaleScratch4);
result[0] = rotation[0] * scale.x;
result[1] = rotation[1] * scale.x;
result[2] = rotation[2] * scale.x;
result[3] = rotation[3] * scale.y;
result[4] = rotation[4] * scale.y;
result[5] = rotation[5] * scale.y;
result[6] = rotation[6] * scale.z;
result[7] = rotation[7] * scale.z;
result[8] = rotation[8] * scale.z;
return result;
};
var scaleScratch5 = new Cartesian3_default();
Matrix3.getRotation = function(matrix, result) {
Check_default.typeOf.object("matrix", matrix);
Check_default.typeOf.object("result", result);
const scale = Matrix3.getScale(matrix, scaleScratch5);
result[0] = matrix[0] / scale.x;
result[1] = matrix[1] / scale.x;
result[2] = matrix[2] / scale.x;
result[3] = matrix[3] / scale.y;
result[4] = matrix[4] / scale.y;
result[5] = matrix[5] / scale.y;
result[6] = matrix[6] / scale.z;
result[7] = matrix[7] / scale.z;
result[8] = matrix[8] / scale.z;
return result;
};
Matrix3.multiply = function(left, right, result) {
Check_default.typeOf.object("left", left);
Check_default.typeOf.object("right", right);
Check_default.typeOf.object("result", result);
const column0Row0 = left[0] * right[0] + left[3] * right[1] + left[6] * right[2];
const column0Row1 = left[1] * right[0] + left[4] * right[1] + left[7] * right[2];
const column0Row2 = left[2] * right[0] + left[5] * right[1] + left[8] * right[2];
const column1Row0 = left[0] * right[3] + left[3] * right[4] + left[6] * right[5];
const column1Row1 = left[1] * right[3] + left[4] * right[4] + left[7] * right[5];
const column1Row2 = left[2] * right[3] + left[5] * right[4] + left[8] * right[5];
const column2Row0 = left[0] * right[6] + left[3] * right[7] + left[6] * right[8];
const column2Row1 = left[1] * right[6] + left[4] * right[7] + left[7] * right[8];
const column2Row2 = left[2] * right[6] + left[5] * right[7] + left[8] * right[8];
result[0] = column0Row0;
result[1] = column0Row1;
result[2] = column0Row2;
result[3] = column1Row0;
result[4] = column1Row1;
result[5] = column1Row2;
result[6] = column2Row0;
result[7] = column2Row1;
result[8] = column2Row2;
return result;
};
Matrix3.add = function(left, right, result) {
Check_default.typeOf.object("left", left);
Check_default.typeOf.object("right", right);
Check_default.typeOf.object("result", result);
result[0] = left[0] + right[0];
result[1] = left[1] + right[1];
result[2] = left[2] + right[2];
result[3] = left[3] + right[3];
result[4] = left[4] + right[4];
result[5] = left[5] + right[5];
result[6] = left[6] + right[6];
result[7] = left[7] + right[7];
result[8] = left[8] + right[8];
return result;
};
Matrix3.subtract = function(left, right, result) {
Check_default.typeOf.object("left", left);
Check_default.typeOf.object("right", right);
Check_default.typeOf.object("result", result);
result[0] = left[0] - right[0];
result[1] = left[1] - right[1];
result[2] = left[2] - right[2];
result[3] = left[3] - right[3];
result[4] = left[4] - right[4];
result[5] = left[5] - right[5];
result[6] = left[6] - right[6];
result[7] = left[7] - right[7];
result[8] = left[8] - right[8];
return result;
};
Matrix3.multiplyByVector = function(matrix, cartesian11, result) {
Check_default.typeOf.object("matrix", matrix);
Check_default.typeOf.object("cartesian", cartesian11);
Check_default.typeOf.object("result", result);
const vX = cartesian11.x;
const vY = cartesian11.y;
const vZ = cartesian11.z;
const x = matrix[0] * vX + matrix[3] * vY + matrix[6] * vZ;
const y = matrix[1] * vX + matrix[4] * vY + matrix[7] * vZ;
const z = matrix[2] * vX + matrix[5] * vY + matrix[8] * vZ;
result.x = x;
result.y = y;
result.z = z;
return result;
};
Matrix3.multiplyByScalar = function(matrix, scalar, result) {
Check_default.typeOf.object("matrix", matrix);
Check_default.typeOf.number("scalar", scalar);
Check_default.typeOf.object("result", result);
result[0] = matrix[0] * scalar;
result[1] = matrix[1] * scalar;
result[2] = matrix[2] * scalar;
result[3] = matrix[3] * scalar;
result[4] = matrix[4] * scalar;
result[5] = matrix[5] * scalar;
result[6] = matrix[6] * scalar;
result[7] = matrix[7] * scalar;
result[8] = matrix[8] * scalar;
return result;
};
Matrix3.multiplyByScale = function(matrix, scale, result) {
Check_default.typeOf.object("matrix", matrix);
Check_default.typeOf.object("scale", scale);
Check_default.typeOf.object("result", result);
result[0] = matrix[0] * scale.x;
result[1] = matrix[1] * scale.x;
result[2] = matrix[2] * scale.x;
result[3] = matrix[3] * scale.y;
result[4] = matrix[4] * scale.y;
result[5] = matrix[5] * scale.y;
result[6] = matrix[6] * scale.z;
result[7] = matrix[7] * scale.z;
result[8] = matrix[8] * scale.z;
return result;
};
Matrix3.multiplyByUniformScale = function(matrix, scale, result) {
Check_default.typeOf.object("matrix", matrix);
Check_default.typeOf.number("scale", scale);
Check_default.typeOf.object("result", result);
result[0] = matrix[0] * scale;
result[1] = matrix[1] * scale;
result[2] = matrix[2] * scale;
result[3] = matrix[3] * scale;
result[4] = matrix[4] * scale;
result[5] = matrix[5] * scale;
result[6] = matrix[6] * scale;
result[7] = matrix[7] * scale;
result[8] = matrix[8] * scale;
return result;
};
Matrix3.negate = function(matrix, result) {
Check_default.typeOf.object("matrix", matrix);
Check_default.typeOf.object("result", result);
result[0] = -matrix[0];
result[1] = -matrix[1];
result[2] = -matrix[2];
result[3] = -matrix[3];
result[4] = -matrix[4];
result[5] = -matrix[5];
result[6] = -matrix[6];
result[7] = -matrix[7];
result[8] = -matrix[8];
return result;
};
Matrix3.transpose = function(matrix, result) {
Check_default.typeOf.object("matrix", matrix);
Check_default.typeOf.object("result", result);
const column0Row0 = matrix[0];
const column0Row1 = matrix[3];
const column0Row2 = matrix[6];
const column1Row0 = matrix[1];
const column1Row1 = matrix[4];
const column1Row2 = matrix[7];
const column2Row0 = matrix[2];
const column2Row1 = matrix[5];
const column2Row2 = matrix[8];
result[0] = column0Row0;
result[1] = column0Row1;
result[2] = column0Row2;
result[3] = column1Row0;
result[4] = column1Row1;
result[5] = column1Row2;
result[6] = column2Row0;
result[7] = column2Row1;
result[8] = column2Row2;
return result;
};
function computeFrobeniusNorm(matrix) {
let norm = 0;
for (let i = 0; i < 9; ++i) {
const temp = matrix[i];
norm += temp * temp;
}
return Math.sqrt(norm);
}
var rowVal = [1, 0, 0];
var colVal = [2, 2, 1];
function offDiagonalFrobeniusNorm(matrix) {
let norm = 0;
for (let i = 0; i < 3; ++i) {
const temp = matrix[Matrix3.getElementIndex(colVal[i], rowVal[i])];
norm += 2 * temp * temp;
}
return Math.sqrt(norm);
}
function shurDecomposition(matrix, result) {
const tolerance = Math_default.EPSILON15;
let maxDiagonal = 0;
let rotAxis2 = 1;
for (let i = 0; i < 3; ++i) {
const temp = Math.abs(
matrix[Matrix3.getElementIndex(colVal[i], rowVal[i])]
);
if (temp > maxDiagonal) {
rotAxis2 = i;
maxDiagonal = temp;
}
}
let c = 1;
let s = 0;
const p = rowVal[rotAxis2];
const q = colVal[rotAxis2];
if (Math.abs(matrix[Matrix3.getElementIndex(q, p)]) > tolerance) {
const qq = matrix[Matrix3.getElementIndex(q, q)];
const pp = matrix[Matrix3.getElementIndex(p, p)];
const qp = matrix[Matrix3.getElementIndex(q, p)];
const tau = (qq - pp) / 2 / qp;
let t;
if (tau < 0) {
t = -1 / (-tau + Math.sqrt(1 + tau * tau));
} else {
t = 1 / (tau + Math.sqrt(1 + tau * tau));
}
c = 1 / Math.sqrt(1 + t * t);
s = t * c;
}
result = Matrix3.clone(Matrix3.IDENTITY, result);
result[Matrix3.getElementIndex(p, p)] = result[Matrix3.getElementIndex(q, q)] = c;
result[Matrix3.getElementIndex(q, p)] = s;
result[Matrix3.getElementIndex(p, q)] = -s;
return result;
}
var jMatrix = new Matrix3();
var jMatrixTranspose = new Matrix3();
Matrix3.computeEigenDecomposition = function(matrix, result) {
Check_default.typeOf.object("matrix", matrix);
const tolerance = Math_default.EPSILON20;
const maxSweeps = 10;
let count = 0;
let sweep = 0;
if (!defined_default(result)) {
result = {};
}
const unitaryMatrix = result.unitary = Matrix3.clone(
Matrix3.IDENTITY,
result.unitary
);
const diagMatrix = result.diagonal = Matrix3.clone(matrix, result.diagonal);
const epsilon = tolerance * computeFrobeniusNorm(diagMatrix);
while (sweep < maxSweeps && offDiagonalFrobeniusNorm(diagMatrix) > epsilon) {
shurDecomposition(diagMatrix, jMatrix);
Matrix3.transpose(jMatrix, jMatrixTranspose);
Matrix3.multiply(diagMatrix, jMatrix, diagMatrix);
Matrix3.multiply(jMatrixTranspose, diagMatrix, diagMatrix);
Matrix3.multiply(unitaryMatrix, jMatrix, unitaryMatrix);
if (++count > 2) {
++sweep;
count = 0;
}
}
return result;
};
Matrix3.abs = function(matrix, result) {
Check_default.typeOf.object("matrix", matrix);
Check_default.typeOf.object("result", result);
result[0] = Math.abs(matrix[0]);
result[1] = Math.abs(matrix[1]);
result[2] = Math.abs(matrix[2]);
result[3] = Math.abs(matrix[3]);
result[4] = Math.abs(matrix[4]);
result[5] = Math.abs(matrix[5]);
result[6] = Math.abs(matrix[6]);
result[7] = Math.abs(matrix[7]);
result[8] = Math.abs(matrix[8]);
return result;
};
Matrix3.determinant = function(matrix) {
Check_default.typeOf.object("matrix", matrix);
const m11 = matrix[0];
const m21 = matrix[3];
const m31 = matrix[6];
const m12 = matrix[1];
const m22 = matrix[4];
const m32 = matrix[7];
const m13 = matrix[2];
const m23 = matrix[5];
const m33 = matrix[8];
return m11 * (m22 * m33 - m23 * m32) + m12 * (m23 * m31 - m21 * m33) + m13 * (m21 * m32 - m22 * m31);
};
Matrix3.inverse = function(matrix, result) {
Check_default.typeOf.object("matrix", matrix);
Check_default.typeOf.object("result", result);
const m11 = matrix[0];
const m21 = matrix[1];
const m31 = matrix[2];
const m12 = matrix[3];
const m22 = matrix[4];
const m32 = matrix[5];
const m13 = matrix[6];
const m23 = matrix[7];
const m33 = matrix[8];
const determinant = Matrix3.determinant(matrix);
if (Math.abs(determinant) <= Math_default.EPSILON15) {
throw new DeveloperError_default("matrix is not invertible");
}
result[0] = m22 * m33 - m23 * m32;
result[1] = m23 * m31 - m21 * m33;
result[2] = m21 * m32 - m22 * m31;
result[3] = m13 * m32 - m12 * m33;
result[4] = m11 * m33 - m13 * m31;
result[5] = m12 * m31 - m11 * m32;
result[6] = m12 * m23 - m13 * m22;
result[7] = m13 * m21 - m11 * m23;
result[8] = m11 * m22 - m12 * m21;
const scale = 1 / determinant;
return Matrix3.multiplyByScalar(result, scale, result);
};
var scratchTransposeMatrix = new Matrix3();
Matrix3.inverseTranspose = function(matrix, result) {
Check_default.typeOf.object("matrix", matrix);
Check_default.typeOf.object("result", result);
return Matrix3.inverse(
Matrix3.transpose(matrix, scratchTransposeMatrix),
result
);
};
Matrix3.equals = function(left, right) {
return left === right || defined_default(left) && defined_default(right) && left[0] === right[0] && left[1] === right[1] && left[2] === right[2] && left[3] === right[3] && left[4] === right[4] && left[5] === right[5] && left[6] === right[6] && left[7] === right[7] && left[8] === right[8];
};
Matrix3.equalsEpsilon = function(left, right, epsilon) {
epsilon = defaultValue_default(epsilon, 0);
return left === right || defined_default(left) && defined_default(right) && Math.abs(left[0] - right[0]) <= epsilon && Math.abs(left[1] - right[1]) <= epsilon && Math.abs(left[2] - right[2]) <= epsilon && Math.abs(left[3] - right[3]) <= epsilon && Math.abs(left[4] - right[4]) <= epsilon && Math.abs(left[5] - right[5]) <= epsilon && Math.abs(left[6] - right[6]) <= epsilon && Math.abs(left[7] - right[7]) <= epsilon && Math.abs(left[8] - right[8]) <= epsilon;
};
Matrix3.IDENTITY = Object.freeze(
new Matrix3(1, 0, 0, 0, 1, 0, 0, 0, 1)
);
Matrix3.ZERO = Object.freeze(
new Matrix3(0, 0, 0, 0, 0, 0, 0, 0, 0)
);
Matrix3.COLUMN0ROW0 = 0;
Matrix3.COLUMN0ROW1 = 1;
Matrix3.COLUMN0ROW2 = 2;
Matrix3.COLUMN1ROW0 = 3;
Matrix3.COLUMN1ROW1 = 4;
Matrix3.COLUMN1ROW2 = 5;
Matrix3.COLUMN2ROW0 = 6;
Matrix3.COLUMN2ROW1 = 7;
Matrix3.COLUMN2ROW2 = 8;
Object.defineProperties(Matrix3.prototype, {
length: {
get: function() {
return Matrix3.packedLength;
}
}
});
Matrix3.prototype.clone = function(result) {
return Matrix3.clone(this, result);
};
Matrix3.prototype.equals = function(right) {
return Matrix3.equals(this, right);
};
Matrix3.equalsArray = function(matrix, array, offset2) {
return matrix[0] === array[offset2] && matrix[1] === array[offset2 + 1] && matrix[2] === array[offset2 + 2] && matrix[3] === array[offset2 + 3] && matrix[4] === array[offset2 + 4] && matrix[5] === array[offset2 + 5] && matrix[6] === array[offset2 + 6] && matrix[7] === array[offset2 + 7] && matrix[8] === array[offset2 + 8];
};
Matrix3.prototype.equalsEpsilon = function(right, epsilon) {
return Matrix3.equalsEpsilon(this, right, epsilon);
};
Matrix3.prototype.toString = function() {
return `(${this[0]}, ${this[3]}, ${this[6]})
(${this[1]}, ${this[4]}, ${this[7]})
(${this[2]}, ${this[5]}, ${this[8]})`;
};
var Matrix3_default = Matrix3;
// Source/Core/Cartesian4.js
function Cartesian4(x, y, z, w) {
this.x = defaultValue_default(x, 0);
this.y = defaultValue_default(y, 0);
this.z = defaultValue_default(z, 0);
this.w = defaultValue_default(w, 0);
}
Cartesian4.fromElements = function(x, y, z, w, result) {
if (!defined_default(result)) {
return new Cartesian4(x, y, z, w);
}
result.x = x;
result.y = y;
result.z = z;
result.w = w;
return result;
};
Cartesian4.fromColor = function(color, result) {
Check_default.typeOf.object("color", color);
if (!defined_default(result)) {
return new Cartesian4(color.red, color.green, color.blue, color.alpha);
}
result.x = color.red;
result.y = color.green;
result.z = color.blue;
result.w = color.alpha;
return result;
};
Cartesian4.clone = function(cartesian11, result) {
if (!defined_default(cartesian11)) {
return void 0;
}
if (!defined_default(result)) {
return new Cartesian4(cartesian11.x, cartesian11.y, cartesian11.z, cartesian11.w);
}
result.x = cartesian11.x;
result.y = cartesian11.y;
result.z = cartesian11.z;
result.w = cartesian11.w;
return result;
};
Cartesian4.packedLength = 4;
Cartesian4.pack = function(value, array, startingIndex) {
Check_default.typeOf.object("value", value);
Check_default.defined("array", array);
startingIndex = defaultValue_default(startingIndex, 0);
array[startingIndex++] = value.x;
array[startingIndex++] = value.y;
array[startingIndex++] = value.z;
array[startingIndex] = value.w;
return array;
};
Cartesian4.unpack = function(array, startingIndex, result) {
Check_default.defined("array", array);
startingIndex = defaultValue_default(startingIndex, 0);
if (!defined_default(result)) {
result = new Cartesian4();
}
result.x = array[startingIndex++];
result.y = array[startingIndex++];
result.z = array[startingIndex++];
result.w = array[startingIndex];
return result;
};
Cartesian4.packArray = function(array, result) {
Check_default.defined("array", array);
const length3 = array.length;
const resultLength = length3 * 4;
if (!defined_default(result)) {
result = new Array(resultLength);
} else if (!Array.isArray(result) && result.length !== resultLength) {
throw new DeveloperError_default(
"If result is a typed array, it must have exactly array.length * 4 elements"
);
} else if (result.length !== resultLength) {
result.length = resultLength;
}
for (let i = 0; i < length3; ++i) {
Cartesian4.pack(array[i], result, i * 4);
}
return result;
};
Cartesian4.unpackArray = function(array, result) {
Check_default.defined("array", array);
Check_default.typeOf.number.greaterThanOrEquals("array.length", array.length, 4);
if (array.length % 4 !== 0) {
throw new DeveloperError_default("array length must be a multiple of 4.");
}
const length3 = array.length;
if (!defined_default(result)) {
result = new Array(length3 / 4);
} else {
result.length = length3 / 4;
}
for (let i = 0; i < length3; i += 4) {
const index = i / 4;
result[index] = Cartesian4.unpack(array, i, result[index]);
}
return result;
};
Cartesian4.fromArray = Cartesian4.unpack;
Cartesian4.maximumComponent = function(cartesian11) {
Check_default.typeOf.object("cartesian", cartesian11);
return Math.max(cartesian11.x, cartesian11.y, cartesian11.z, cartesian11.w);
};
Cartesian4.minimumComponent = function(cartesian11) {
Check_default.typeOf.object("cartesian", cartesian11);
return Math.min(cartesian11.x, cartesian11.y, cartesian11.z, cartesian11.w);
};
Cartesian4.minimumByComponent = function(first, second, result) {
Check_default.typeOf.object("first", first);
Check_default.typeOf.object("second", second);
Check_default.typeOf.object("result", result);
result.x = Math.min(first.x, second.x);
result.y = Math.min(first.y, second.y);
result.z = Math.min(first.z, second.z);
result.w = Math.min(first.w, second.w);
return result;
};
Cartesian4.maximumByComponent = function(first, second, result) {
Check_default.typeOf.object("first", first);
Check_default.typeOf.object("second", second);
Check_default.typeOf.object("result", result);
result.x = Math.max(first.x, second.x);
result.y = Math.max(first.y, second.y);
result.z = Math.max(first.z, second.z);
result.w = Math.max(first.w, second.w);
return result;
};
Cartesian4.clamp = function(value, min3, max3, result) {
Check_default.typeOf.object("value", value);
Check_default.typeOf.object("min", min3);
Check_default.typeOf.object("max", max3);
Check_default.typeOf.object("result", result);
const x = Math_default.clamp(value.x, min3.x, max3.x);
const y = Math_default.clamp(value.y, min3.y, max3.y);
const z = Math_default.clamp(value.z, min3.z, max3.z);
const w = Math_default.clamp(value.w, min3.w, max3.w);
result.x = x;
result.y = y;
result.z = z;
result.w = w;
return result;
};
Cartesian4.magnitudeSquared = function(cartesian11) {
Check_default.typeOf.object("cartesian", cartesian11);
return cartesian11.x * cartesian11.x + cartesian11.y * cartesian11.y + cartesian11.z * cartesian11.z + cartesian11.w * cartesian11.w;
};
Cartesian4.magnitude = function(cartesian11) {
return Math.sqrt(Cartesian4.magnitudeSquared(cartesian11));
};
var distanceScratch2 = new Cartesian4();
Cartesian4.distance = function(left, right) {
Check_default.typeOf.object("left", left);
Check_default.typeOf.object("right", right);
Cartesian4.subtract(left, right, distanceScratch2);
return Cartesian4.magnitude(distanceScratch2);
};
Cartesian4.distanceSquared = function(left, right) {
Check_default.typeOf.object("left", left);
Check_default.typeOf.object("right", right);
Cartesian4.subtract(left, right, distanceScratch2);
return Cartesian4.magnitudeSquared(distanceScratch2);
};
Cartesian4.normalize = function(cartesian11, result) {
Check_default.typeOf.object("cartesian", cartesian11);
Check_default.typeOf.object("result", result);
const magnitude = Cartesian4.magnitude(cartesian11);
result.x = cartesian11.x / magnitude;
result.y = cartesian11.y / magnitude;
result.z = cartesian11.z / magnitude;
result.w = cartesian11.w / magnitude;
if (isNaN(result.x) || isNaN(result.y) || isNaN(result.z) || isNaN(result.w)) {
throw new DeveloperError_default("normalized result is not a number");
}
return result;
};
Cartesian4.dot = function(left, right) {
Check_default.typeOf.object("left", left);
Check_default.typeOf.object("right", right);
return left.x * right.x + left.y * right.y + left.z * right.z + left.w * right.w;
};
Cartesian4.multiplyComponents = function(left, right, result) {
Check_default.typeOf.object("left", left);
Check_default.typeOf.object("right", right);
Check_default.typeOf.object("result", result);
result.x = left.x * right.x;
result.y = left.y * right.y;
result.z = left.z * right.z;
result.w = left.w * right.w;
return result;
};
Cartesian4.divideComponents = function(left, right, result) {
Check_default.typeOf.object("left", left);
Check_default.typeOf.object("right", right);
Check_default.typeOf.object("result", result);
result.x = left.x / right.x;
result.y = left.y / right.y;
result.z = left.z / right.z;
result.w = left.w / right.w;
return result;
};
Cartesian4.add = function(left, right, result) {
Check_default.typeOf.object("left", left);
Check_default.typeOf.object("right", right);
Check_default.typeOf.object("result", result);
result.x = left.x + right.x;
result.y = left.y + right.y;
result.z = left.z + right.z;
result.w = left.w + right.w;
return result;
};
Cartesian4.subtract = function(left, right, result) {
Check_default.typeOf.object("left", left);
Check_default.typeOf.object("right", right);
Check_default.typeOf.object("result", result);
result.x = left.x - right.x;
result.y = left.y - right.y;
result.z = left.z - right.z;
result.w = left.w - right.w;
return result;
};
Cartesian4.multiplyByScalar = function(cartesian11, scalar, result) {
Check_default.typeOf.object("cartesian", cartesian11);
Check_default.typeOf.number("scalar", scalar);
Check_default.typeOf.object("result", result);
result.x = cartesian11.x * scalar;
result.y = cartesian11.y * scalar;
result.z = cartesian11.z * scalar;
result.w = cartesian11.w * scalar;
return result;
};
Cartesian4.divideByScalar = function(cartesian11, scalar, result) {
Check_default.typeOf.object("cartesian", cartesian11);
Check_default.typeOf.number("scalar", scalar);
Check_default.typeOf.object("result", result);
result.x = cartesian11.x / scalar;
result.y = cartesian11.y / scalar;
result.z = cartesian11.z / scalar;
result.w = cartesian11.w / scalar;
return result;
};
Cartesian4.negate = function(cartesian11, result) {
Check_default.typeOf.object("cartesian", cartesian11);
Check_default.typeOf.object("result", result);
result.x = -cartesian11.x;
result.y = -cartesian11.y;
result.z = -cartesian11.z;
result.w = -cartesian11.w;
return result;
};
Cartesian4.abs = function(cartesian11, result) {
Check_default.typeOf.object("cartesian", cartesian11);
Check_default.typeOf.object("result", result);
result.x = Math.abs(cartesian11.x);
result.y = Math.abs(cartesian11.y);
result.z = Math.abs(cartesian11.z);
result.w = Math.abs(cartesian11.w);
return result;
};
var lerpScratch2 = new Cartesian4();
Cartesian4.lerp = function(start, end, t, result) {
Check_default.typeOf.object("start", start);
Check_default.typeOf.object("end", end);
Check_default.typeOf.number("t", t);
Check_default.typeOf.object("result", result);
Cartesian4.multiplyByScalar(end, t, lerpScratch2);
result = Cartesian4.multiplyByScalar(start, 1 - t, result);
return Cartesian4.add(lerpScratch2, result, result);
};
var mostOrthogonalAxisScratch2 = new Cartesian4();
Cartesian4.mostOrthogonalAxis = function(cartesian11, result) {
Check_default.typeOf.object("cartesian", cartesian11);
Check_default.typeOf.object("result", result);
const f = Cartesian4.normalize(cartesian11, mostOrthogonalAxisScratch2);
Cartesian4.abs(f, f);
if (f.x <= f.y) {
if (f.x <= f.z) {
if (f.x <= f.w) {
result = Cartesian4.clone(Cartesian4.UNIT_X, result);
} else {
result = Cartesian4.clone(Cartesian4.UNIT_W, result);
}
} else if (f.z <= f.w) {
result = Cartesian4.clone(Cartesian4.UNIT_Z, result);
} else {
result = Cartesian4.clone(Cartesian4.UNIT_W, result);
}
} else if (f.y <= f.z) {
if (f.y <= f.w) {
result = Cartesian4.clone(Cartesian4.UNIT_Y, result);
} else {
result = Cartesian4.clone(Cartesian4.UNIT_W, result);
}
} else if (f.z <= f.w) {
result = Cartesian4.clone(Cartesian4.UNIT_Z, result);
} else {
result = Cartesian4.clone(Cartesian4.UNIT_W, result);
}
return result;
};
Cartesian4.equals = function(left, right) {
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;
};
Cartesian4.equalsArray = function(cartesian11, array, offset2) {
return cartesian11.x === array[offset2] && cartesian11.y === array[offset2 + 1] && cartesian11.z === array[offset2 + 2] && cartesian11.w === array[offset2 + 3];
};
Cartesian4.equalsEpsilon = function(left, right, relativeEpsilon, absoluteEpsilon) {
return left === right || defined_default(left) && defined_default(right) && Math_default.equalsEpsilon(
left.x,
right.x,
relativeEpsilon,
absoluteEpsilon
) && Math_default.equalsEpsilon(
left.y,
right.y,
relativeEpsilon,
absoluteEpsilon
) && Math_default.equalsEpsilon(
left.z,
right.z,
relativeEpsilon,
absoluteEpsilon
) && Math_default.equalsEpsilon(
left.w,
right.w,
relativeEpsilon,
absoluteEpsilon
);
};
Cartesian4.ZERO = Object.freeze(new Cartesian4(0, 0, 0, 0));
Cartesian4.ONE = Object.freeze(new Cartesian4(1, 1, 1, 1));
Cartesian4.UNIT_X = Object.freeze(new Cartesian4(1, 0, 0, 0));
Cartesian4.UNIT_Y = Object.freeze(new Cartesian4(0, 1, 0, 0));
Cartesian4.UNIT_Z = Object.freeze(new Cartesian4(0, 0, 1, 0));
Cartesian4.UNIT_W = Object.freeze(new Cartesian4(0, 0, 0, 1));
Cartesian4.prototype.clone = function(result) {
return Cartesian4.clone(this, result);
};
Cartesian4.prototype.equals = function(right) {
return Cartesian4.equals(this, right);
};
Cartesian4.prototype.equalsEpsilon = function(right, relativeEpsilon, absoluteEpsilon) {
return Cartesian4.equalsEpsilon(
this,
right,
relativeEpsilon,
absoluteEpsilon
);
};
Cartesian4.prototype.toString = function() {
return `(${this.x}, ${this.y}, ${this.z}, ${this.w})`;
};
var scratchF32Array = new Float32Array(1);
var scratchU8Array = new Uint8Array(scratchF32Array.buffer);
var testU32 = new Uint32Array([287454020]);
var testU8 = new Uint8Array(testU32.buffer);
var littleEndian = testU8[0] === 68;
Cartesian4.packFloat = function(value, result) {
Check_default.typeOf.number("value", value);
if (!defined_default(result)) {
result = new Cartesian4();
}
scratchF32Array[0] = value;
if (littleEndian) {
result.x = scratchU8Array[0];
result.y = scratchU8Array[1];
result.z = scratchU8Array[2];
result.w = scratchU8Array[3];
} else {
result.x = scratchU8Array[3];
result.y = scratchU8Array[2];
result.z = scratchU8Array[1];
result.w = scratchU8Array[0];
}
return result;
};
Cartesian4.unpackFloat = function(packedFloat) {
Check_default.typeOf.object("packedFloat", packedFloat);
if (littleEndian) {
scratchU8Array[0] = packedFloat.x;
scratchU8Array[1] = packedFloat.y;
scratchU8Array[2] = packedFloat.z;
scratchU8Array[3] = packedFloat.w;
} else {
scratchU8Array[0] = packedFloat.w;
scratchU8Array[1] = packedFloat.z;
scratchU8Array[2] = packedFloat.y;
scratchU8Array[3] = packedFloat.x;
}
return scratchF32Array[0];
};
var Cartesian4_default = Cartesian4;
// Source/Core/RuntimeError.js
function RuntimeError(message) {
this.name = "RuntimeError";
this.message = message;
let stack;
try {
throw new Error();
} catch (e) {
stack = e.stack;
}
this.stack = stack;
}
if (defined_default(Object.create)) {
RuntimeError.prototype = Object.create(Error.prototype);
RuntimeError.prototype.constructor = RuntimeError;
}
RuntimeError.prototype.toString = function() {
let str = `${this.name}: ${this.message}`;
if (defined_default(this.stack)) {
str += `
${this.stack.toString()}`;
}
return str;
};
var RuntimeError_default = RuntimeError;
// Source/Core/Matrix4.js
function Matrix4(column0Row0, column1Row0, column2Row0, column3Row0, column0Row1, column1Row1, column2Row1, column3Row1, column0Row2, column1Row2, column2Row2, column3Row2, column0Row3, column1Row3, column2Row3, column3Row3) {
this[0] = defaultValue_default(column0Row0, 0);
this[1] = defaultValue_default(column0Row1, 0);
this[2] = defaultValue_default(column0Row2, 0);
this[3] = defaultValue_default(column0Row3, 0);
this[4] = defaultValue_default(column1Row0, 0);
this[5] = defaultValue_default(column1Row1, 0);
this[6] = defaultValue_default(column1Row2, 0);
this[7] = defaultValue_default(column1Row3, 0);
this[8] = defaultValue_default(column2Row0, 0);
this[9] = defaultValue_default(column2Row1, 0);
this[10] = defaultValue_default(column2Row2, 0);
this[11] = defaultValue_default(column2Row3, 0);
this[12] = defaultValue_default(column3Row0, 0);
this[13] = defaultValue_default(column3Row1, 0);
this[14] = defaultValue_default(column3Row2, 0);
this[15] = defaultValue_default(column3Row3, 0);
}
Matrix4.packedLength = 16;
Matrix4.pack = function(value, array, startingIndex) {
Check_default.typeOf.object("value", value);
Check_default.defined("array", array);
startingIndex = defaultValue_default(startingIndex, 0);
array[startingIndex++] = value[0];
array[startingIndex++] = value[1];
array[startingIndex++] = value[2];
array[startingIndex++] = value[3];
array[startingIndex++] = value[4];
array[startingIndex++] = value[5];
array[startingIndex++] = value[6];
array[startingIndex++] = value[7];
array[startingIndex++] = value[8];
array[startingIndex++] = value[9];
array[startingIndex++] = value[10];
array[startingIndex++] = value[11];
array[startingIndex++] = value[12];
array[startingIndex++] = value[13];
array[startingIndex++] = value[14];
array[startingIndex] = value[15];
return array;
};
Matrix4.unpack = function(array, startingIndex, result) {
Check_default.defined("array", array);
startingIndex = defaultValue_default(startingIndex, 0);
if (!defined_default(result)) {
result = new Matrix4();
}
result[0] = array[startingIndex++];
result[1] = array[startingIndex++];
result[2] = array[startingIndex++];
result[3] = array[startingIndex++];
result[4] = array[startingIndex++];
result[5] = array[startingIndex++];
result[6] = array[startingIndex++];
result[7] = array[startingIndex++];
result[8] = array[startingIndex++];
result[9] = array[startingIndex++];
result[10] = array[startingIndex++];
result[11] = array[startingIndex++];
result[12] = array[startingIndex++];
result[13] = array[startingIndex++];
result[14] = array[startingIndex++];
result[15] = array[startingIndex];
return result;
};
Matrix4.packArray = function(array, result) {
Check_default.defined("array", array);
const length3 = array.length;
const resultLength = length3 * 16;
if (!defined_default(result)) {
result = new Array(resultLength);
} else if (!Array.isArray(result) && result.length !== resultLength) {
throw new DeveloperError_default(
"If result is a typed array, it must have exactly array.length * 16 elements"
);
} else if (result.length !== resultLength) {
result.length = resultLength;
}
for (let i = 0; i < length3; ++i) {
Matrix4.pack(array[i], result, i * 16);
}
return result;
};
Matrix4.unpackArray = function(array, result) {
Check_default.defined("array", array);
Check_default.typeOf.number.greaterThanOrEquals("array.length", array.length, 16);
if (array.length % 16 !== 0) {
throw new DeveloperError_default("array length must be a multiple of 16.");
}
const length3 = array.length;
if (!defined_default(result)) {
result = new Array(length3 / 16);
} else {
result.length = length3 / 16;
}
for (let i = 0; i < length3; i += 16) {
const index = i / 16;
result[index] = Matrix4.unpack(array, i, result[index]);
}
return result;
};
Matrix4.clone = function(matrix, result) {
if (!defined_default(matrix)) {
return void 0;
}
if (!defined_default(result)) {
return new Matrix4(
matrix[0],
matrix[4],
matrix[8],
matrix[12],
matrix[1],
matrix[5],
matrix[9],
matrix[13],
matrix[2],
matrix[6],
matrix[10],
matrix[14],
matrix[3],
matrix[7],
matrix[11],
matrix[15]
);
}
result[0] = matrix[0];
result[1] = matrix[1];
result[2] = matrix[2];
result[3] = matrix[3];
result[4] = matrix[4];
result[5] = matrix[5];
result[6] = matrix[6];
result[7] = matrix[7];
result[8] = matrix[8];
result[9] = matrix[9];
result[10] = matrix[10];
result[11] = matrix[11];
result[12] = matrix[12];
result[13] = matrix[13];
result[14] = matrix[14];
result[15] = matrix[15];
return result;
};
Matrix4.fromArray = Matrix4.unpack;
Matrix4.fromColumnMajorArray = function(values, result) {
Check_default.defined("values", values);
return Matrix4.clone(values, result);
};
Matrix4.fromRowMajorArray = function(values, result) {
Check_default.defined("values", values);
if (!defined_default(result)) {
return new Matrix4(
values[0],
values[1],
values[2],
values[3],
values[4],
values[5],
values[6],
values[7],
values[8],
values[9],
values[10],
values[11],
values[12],
values[13],
values[14],
values[15]
);
}
result[0] = values[0];
result[1] = values[4];
result[2] = values[8];
result[3] = values[12];
result[4] = values[1];
result[5] = values[5];
result[6] = values[9];
result[7] = values[13];
result[8] = values[2];
result[9] = values[6];
result[10] = values[10];
result[11] = values[14];
result[12] = values[3];
result[13] = values[7];
result[14] = values[11];
result[15] = values[15];
return result;
};
Matrix4.fromRotationTranslation = function(rotation, translation3, result) {
Check_default.typeOf.object("rotation", rotation);
translation3 = defaultValue_default(translation3, Cartesian3_default.ZERO);
if (!defined_default(result)) {
return new Matrix4(
rotation[0],
rotation[3],
rotation[6],
translation3.x,
rotation[1],
rotation[4],
rotation[7],
translation3.y,
rotation[2],
rotation[5],
rotation[8],
translation3.z,
0,
0,
0,
1
);
}
result[0] = rotation[0];
result[1] = rotation[1];
result[2] = rotation[2];
result[3] = 0;
result[4] = rotation[3];
result[5] = rotation[4];
result[6] = rotation[5];
result[7] = 0;
result[8] = rotation[6];
result[9] = rotation[7];
result[10] = rotation[8];
result[11] = 0;
result[12] = translation3.x;
result[13] = translation3.y;
result[14] = translation3.z;
result[15] = 1;
return result;
};
Matrix4.fromTranslationQuaternionRotationScale = function(translation3, rotation, scale, result) {
Check_default.typeOf.object("translation", translation3);
Check_default.typeOf.object("rotation", rotation);
Check_default.typeOf.object("scale", scale);
if (!defined_default(result)) {
result = new Matrix4();
}
const scaleX = scale.x;
const scaleY = scale.y;
const scaleZ = scale.z;
const x2 = rotation.x * rotation.x;
const xy = rotation.x * rotation.y;
const xz = rotation.x * rotation.z;
const xw = rotation.x * rotation.w;
const y2 = rotation.y * rotation.y;
const yz = rotation.y * rotation.z;
const yw = rotation.y * rotation.w;
const z2 = rotation.z * rotation.z;
const zw = rotation.z * rotation.w;
const w2 = rotation.w * rotation.w;
const m00 = x2 - y2 - z2 + w2;
const m01 = 2 * (xy - zw);
const m02 = 2 * (xz + yw);
const m10 = 2 * (xy + zw);
const m11 = -x2 + y2 - z2 + w2;
const m12 = 2 * (yz - xw);
const m20 = 2 * (xz - yw);
const m21 = 2 * (yz + xw);
const m22 = -x2 - y2 + z2 + w2;
result[0] = m00 * scaleX;
result[1] = m10 * scaleX;
result[2] = m20 * scaleX;
result[3] = 0;
result[4] = m01 * scaleY;
result[5] = m11 * scaleY;
result[6] = m21 * scaleY;
result[7] = 0;
result[8] = m02 * scaleZ;
result[9] = m12 * scaleZ;
result[10] = m22 * scaleZ;
result[11] = 0;
result[12] = translation3.x;
result[13] = translation3.y;
result[14] = translation3.z;
result[15] = 1;
return result;
};
Matrix4.fromTranslationRotationScale = function(translationRotationScale, result) {
Check_default.typeOf.object("translationRotationScale", translationRotationScale);
return Matrix4.fromTranslationQuaternionRotationScale(
translationRotationScale.translation,
translationRotationScale.rotation,
translationRotationScale.scale,
result
);
};
Matrix4.fromTranslation = function(translation3, result) {
Check_default.typeOf.object("translation", translation3);
return Matrix4.fromRotationTranslation(Matrix3_default.IDENTITY, translation3, result);
};
Matrix4.fromScale = function(scale, result) {
Check_default.typeOf.object("scale", scale);
if (!defined_default(result)) {
return new Matrix4(
scale.x,
0,
0,
0,
0,
scale.y,
0,
0,
0,
0,
scale.z,
0,
0,
0,
0,
1
);
}
result[0] = scale.x;
result[1] = 0;
result[2] = 0;
result[3] = 0;
result[4] = 0;
result[5] = scale.y;
result[6] = 0;
result[7] = 0;
result[8] = 0;
result[9] = 0;
result[10] = scale.z;
result[11] = 0;
result[12] = 0;
result[13] = 0;
result[14] = 0;
result[15] = 1;
return result;
};
Matrix4.fromUniformScale = function(scale, result) {
Check_default.typeOf.number("scale", scale);
if (!defined_default(result)) {
return new Matrix4(
scale,
0,
0,
0,
0,
scale,
0,
0,
0,
0,
scale,
0,
0,
0,
0,
1
);
}
result[0] = scale;
result[1] = 0;
result[2] = 0;
result[3] = 0;
result[4] = 0;
result[5] = scale;
result[6] = 0;
result[7] = 0;
result[8] = 0;
result[9] = 0;
result[10] = scale;
result[11] = 0;
result[12] = 0;
result[13] = 0;
result[14] = 0;
result[15] = 1;
return result;
};
Matrix4.fromRotation = function(rotation, result) {
Check_default.typeOf.object("rotation", rotation);
if (!defined_default(result)) {
result = new Matrix4();
}
result[0] = rotation[0];
result[1] = rotation[1];
result[2] = rotation[2];
result[3] = 0;
result[4] = rotation[3];
result[5] = rotation[4];
result[6] = rotation[5];
result[7] = 0;
result[8] = rotation[6];
result[9] = rotation[7];
result[10] = rotation[8];
result[11] = 0;
result[12] = 0;
result[13] = 0;
result[14] = 0;
result[15] = 1;
return result;
};
var fromCameraF = new Cartesian3_default();
var fromCameraR = new Cartesian3_default();
var fromCameraU = new Cartesian3_default();
Matrix4.fromCamera = function(camera, result) {
Check_default.typeOf.object("camera", camera);
const position = camera.position;
const direction2 = camera.direction;
const up = camera.up;
Check_default.typeOf.object("camera.position", position);
Check_default.typeOf.object("camera.direction", direction2);
Check_default.typeOf.object("camera.up", up);
Cartesian3_default.normalize(direction2, fromCameraF);
Cartesian3_default.normalize(
Cartesian3_default.cross(fromCameraF, up, fromCameraR),
fromCameraR
);
Cartesian3_default.normalize(
Cartesian3_default.cross(fromCameraR, fromCameraF, fromCameraU),
fromCameraU
);
const sX = fromCameraR.x;
const sY = fromCameraR.y;
const sZ = fromCameraR.z;
const fX = fromCameraF.x;
const fY = fromCameraF.y;
const fZ = fromCameraF.z;
const uX = fromCameraU.x;
const uY = fromCameraU.y;
const uZ = fromCameraU.z;
const positionX = position.x;
const positionY = position.y;
const positionZ = position.z;
const t0 = sX * -positionX + sY * -positionY + sZ * -positionZ;
const t1 = uX * -positionX + uY * -positionY + uZ * -positionZ;
const t2 = fX * positionX + fY * positionY + fZ * positionZ;
if (!defined_default(result)) {
return new Matrix4(
sX,
sY,
sZ,
t0,
uX,
uY,
uZ,
t1,
-fX,
-fY,
-fZ,
t2,
0,
0,
0,
1
);
}
result[0] = sX;
result[1] = uX;
result[2] = -fX;
result[3] = 0;
result[4] = sY;
result[5] = uY;
result[6] = -fY;
result[7] = 0;
result[8] = sZ;
result[9] = uZ;
result[10] = -fZ;
result[11] = 0;
result[12] = t0;
result[13] = t1;
result[14] = t2;
result[15] = 1;
return result;
};
Matrix4.computePerspectiveFieldOfView = function(fovY, aspectRatio, near, far, result) {
Check_default.typeOf.number.greaterThan("fovY", fovY, 0);
Check_default.typeOf.number.lessThan("fovY", fovY, Math.PI);
Check_default.typeOf.number.greaterThan("near", near, 0);
Check_default.typeOf.number.greaterThan("far", far, 0);
Check_default.typeOf.object("result", result);
const bottom = Math.tan(fovY * 0.5);
const column1Row1 = 1 / bottom;
const column0Row0 = column1Row1 / aspectRatio;
const column2Row2 = (far + near) / (near - far);
const column3Row2 = 2 * far * near / (near - far);
result[0] = column0Row0;
result[1] = 0;
result[2] = 0;
result[3] = 0;
result[4] = 0;
result[5] = column1Row1;
result[6] = 0;
result[7] = 0;
result[8] = 0;
result[9] = 0;
result[10] = column2Row2;
result[11] = -1;
result[12] = 0;
result[13] = 0;
result[14] = column3Row2;
result[15] = 0;
return result;
};
Matrix4.computeOrthographicOffCenter = function(left, right, bottom, top, near, far, result) {
Check_default.typeOf.number("left", left);
Check_default.typeOf.number("right", right);
Check_default.typeOf.number("bottom", bottom);
Check_default.typeOf.number("top", top);
Check_default.typeOf.number("near", near);
Check_default.typeOf.number("far", far);
Check_default.typeOf.object("result", result);
let a3 = 1 / (right - left);
let b = 1 / (top - bottom);
let c = 1 / (far - near);
const tx = -(right + left) * a3;
const ty = -(top + bottom) * b;
const tz = -(far + near) * c;
a3 *= 2;
b *= 2;
c *= -2;
result[0] = a3;
result[1] = 0;
result[2] = 0;
result[3] = 0;
result[4] = 0;
result[5] = b;
result[6] = 0;
result[7] = 0;
result[8] = 0;
result[9] = 0;
result[10] = c;
result[11] = 0;
result[12] = tx;
result[13] = ty;
result[14] = tz;
result[15] = 1;
return result;
};
Matrix4.computePerspectiveOffCenter = function(left, right, bottom, top, near, far, result) {
Check_default.typeOf.number("left", left);
Check_default.typeOf.number("right", right);
Check_default.typeOf.number("bottom", bottom);
Check_default.typeOf.number("top", top);
Check_default.typeOf.number("near", near);
Check_default.typeOf.number("far", far);
Check_default.typeOf.object("result", result);
const column0Row0 = 2 * near / (right - left);
const column1Row1 = 2 * near / (top - bottom);
const column2Row0 = (right + left) / (right - left);
const column2Row1 = (top + bottom) / (top - bottom);
const column2Row2 = -(far + near) / (far - near);
const column2Row3 = -1;
const column3Row2 = -2 * far * near / (far - near);
result[0] = column0Row0;
result[1] = 0;
result[2] = 0;
result[3] = 0;
result[4] = 0;
result[5] = column1Row1;
result[6] = 0;
result[7] = 0;
result[8] = column2Row0;
result[9] = column2Row1;
result[10] = column2Row2;
result[11] = column2Row3;
result[12] = 0;
result[13] = 0;
result[14] = column3Row2;
result[15] = 0;
return result;
};
Matrix4.computeInfinitePerspectiveOffCenter = function(left, right, bottom, top, near, result) {
Check_default.typeOf.number("left", left);
Check_default.typeOf.number("right", right);
Check_default.typeOf.number("bottom", bottom);
Check_default.typeOf.number("top", top);
Check_default.typeOf.number("near", near);
Check_default.typeOf.object("result", result);
const column0Row0 = 2 * near / (right - left);
const column1Row1 = 2 * near / (top - bottom);
const column2Row0 = (right + left) / (right - left);
const column2Row1 = (top + bottom) / (top - bottom);
const column2Row2 = -1;
const column2Row3 = -1;
const column3Row2 = -2 * near;
result[0] = column0Row0;
result[1] = 0;
result[2] = 0;
result[3] = 0;
result[4] = 0;
result[5] = column1Row1;
result[6] = 0;
result[7] = 0;
result[8] = column2Row0;
result[9] = column2Row1;
result[10] = column2Row2;
result[11] = column2Row3;
result[12] = 0;
result[13] = 0;
result[14] = column3Row2;
result[15] = 0;
return result;
};
Matrix4.computeViewportTransformation = function(viewport, nearDepthRange, farDepthRange, result) {
if (!defined_default(result)) {
result = new Matrix4();
}
viewport = defaultValue_default(viewport, defaultValue_default.EMPTY_OBJECT);
const x = defaultValue_default(viewport.x, 0);
const y = defaultValue_default(viewport.y, 0);
const width = defaultValue_default(viewport.width, 0);
const height = defaultValue_default(viewport.height, 0);
nearDepthRange = defaultValue_default(nearDepthRange, 0);
farDepthRange = defaultValue_default(farDepthRange, 1);
const halfWidth = width * 0.5;
const halfHeight = height * 0.5;
const halfDepth = (farDepthRange - nearDepthRange) * 0.5;
const column0Row0 = halfWidth;
const column1Row1 = halfHeight;
const column2Row2 = halfDepth;
const column3Row0 = x + halfWidth;
const column3Row1 = y + halfHeight;
const column3Row2 = nearDepthRange + halfDepth;
const column3Row3 = 1;
result[0] = column0Row0;
result[1] = 0;
result[2] = 0;
result[3] = 0;
result[4] = 0;
result[5] = column1Row1;
result[6] = 0;
result[7] = 0;
result[8] = 0;
result[9] = 0;
result[10] = column2Row2;
result[11] = 0;
result[12] = column3Row0;
result[13] = column3Row1;
result[14] = column3Row2;
result[15] = column3Row3;
return result;
};
Matrix4.computeView = function(position, direction2, up, right, result) {
Check_default.typeOf.object("position", position);
Check_default.typeOf.object("direction", direction2);
Check_default.typeOf.object("up", up);
Check_default.typeOf.object("right", right);
Check_default.typeOf.object("result", result);
result[0] = right.x;
result[1] = up.x;
result[2] = -direction2.x;
result[3] = 0;
result[4] = right.y;
result[5] = up.y;
result[6] = -direction2.y;
result[7] = 0;
result[8] = right.z;
result[9] = up.z;
result[10] = -direction2.z;
result[11] = 0;
result[12] = -Cartesian3_default.dot(right, position);
result[13] = -Cartesian3_default.dot(up, position);
result[14] = Cartesian3_default.dot(direction2, position);
result[15] = 1;
return result;
};
Matrix4.toArray = function(matrix, result) {
Check_default.typeOf.object("matrix", matrix);
if (!defined_default(result)) {
return [
matrix[0],
matrix[1],
matrix[2],
matrix[3],
matrix[4],
matrix[5],
matrix[6],
matrix[7],
matrix[8],
matrix[9],
matrix[10],
matrix[11],
matrix[12],
matrix[13],
matrix[14],
matrix[15]
];
}
result[0] = matrix[0];
result[1] = matrix[1];
result[2] = matrix[2];
result[3] = matrix[3];
result[4] = matrix[4];
result[5] = matrix[5];
result[6] = matrix[6];
result[7] = matrix[7];
result[8] = matrix[8];
result[9] = matrix[9];
result[10] = matrix[10];
result[11] = matrix[11];
result[12] = matrix[12];
result[13] = matrix[13];
result[14] = matrix[14];
result[15] = matrix[15];
return result;
};
Matrix4.getElementIndex = function(column, row) {
Check_default.typeOf.number.greaterThanOrEquals("row", row, 0);
Check_default.typeOf.number.lessThanOrEquals("row", row, 3);
Check_default.typeOf.number.greaterThanOrEquals("column", column, 0);
Check_default.typeOf.number.lessThanOrEquals("column", column, 3);
return column * 4 + row;
};
Matrix4.getColumn = function(matrix, index, result) {
Check_default.typeOf.object("matrix", matrix);
Check_default.typeOf.number.greaterThanOrEquals("index", index, 0);
Check_default.typeOf.number.lessThanOrEquals("index", index, 3);
Check_default.typeOf.object("result", result);
const startIndex = index * 4;
const x = matrix[startIndex];
const y = matrix[startIndex + 1];
const z = matrix[startIndex + 2];
const w = matrix[startIndex + 3];
result.x = x;
result.y = y;
result.z = z;
result.w = w;
return result;
};
Matrix4.setColumn = function(matrix, index, cartesian11, result) {
Check_default.typeOf.object("matrix", matrix);
Check_default.typeOf.number.greaterThanOrEquals("index", index, 0);
Check_default.typeOf.number.lessThanOrEquals("index", index, 3);
Check_default.typeOf.object("cartesian", cartesian11);
Check_default.typeOf.object("result", result);
result = Matrix4.clone(matrix, result);
const startIndex = index * 4;
result[startIndex] = cartesian11.x;
result[startIndex + 1] = cartesian11.y;
result[startIndex + 2] = cartesian11.z;
result[startIndex + 3] = cartesian11.w;
return result;
};
Matrix4.getRow = function(matrix, index, result) {
Check_default.typeOf.object("matrix", matrix);
Check_default.typeOf.number.greaterThanOrEquals("index", index, 0);
Check_default.typeOf.number.lessThanOrEquals("index", index, 3);
Check_default.typeOf.object("result", result);
const x = matrix[index];
const y = matrix[index + 4];
const z = matrix[index + 8];
const w = matrix[index + 12];
result.x = x;
result.y = y;
result.z = z;
result.w = w;
return result;
};
Matrix4.setRow = function(matrix, index, cartesian11, result) {
Check_default.typeOf.object("matrix", matrix);
Check_default.typeOf.number.greaterThanOrEquals("index", index, 0);
Check_default.typeOf.number.lessThanOrEquals("index", index, 3);
Check_default.typeOf.object("cartesian", cartesian11);
Check_default.typeOf.object("result", result);
result = Matrix4.clone(matrix, result);
result[index] = cartesian11.x;
result[index + 4] = cartesian11.y;
result[index + 8] = cartesian11.z;
result[index + 12] = cartesian11.w;
return result;
};
Matrix4.setTranslation = function(matrix, translation3, result) {
Check_default.typeOf.object("matrix", matrix);
Check_default.typeOf.object("translation", translation3);
Check_default.typeOf.object("result", result);
result[0] = matrix[0];
result[1] = matrix[1];
result[2] = matrix[2];
result[3] = matrix[3];
result[4] = matrix[4];
result[5] = matrix[5];
result[6] = matrix[6];
result[7] = matrix[7];
result[8] = matrix[8];
result[9] = matrix[9];
result[10] = matrix[10];
result[11] = matrix[11];
result[12] = translation3.x;
result[13] = translation3.y;
result[14] = translation3.z;
result[15] = matrix[15];
return result;
};
var scaleScratch12 = new Cartesian3_default();
Matrix4.setScale = function(matrix, scale, result) {
Check_default.typeOf.object("matrix", matrix);
Check_default.typeOf.object("scale", scale);
Check_default.typeOf.object("result", result);
const existingScale = Matrix4.getScale(matrix, scaleScratch12);
const scaleRatioX = scale.x / existingScale.x;
const scaleRatioY = scale.y / existingScale.y;
const scaleRatioZ = scale.z / existingScale.z;
result[0] = matrix[0] * scaleRatioX;
result[1] = matrix[1] * scaleRatioX;
result[2] = matrix[2] * scaleRatioX;
result[3] = matrix[3];
result[4] = matrix[4] * scaleRatioY;
result[5] = matrix[5] * scaleRatioY;
result[6] = matrix[6] * scaleRatioY;
result[7] = matrix[7];
result[8] = matrix[8] * scaleRatioZ;
result[9] = matrix[9] * scaleRatioZ;
result[10] = matrix[10] * scaleRatioZ;
result[11] = matrix[11];
result[12] = matrix[12];
result[13] = matrix[13];
result[14] = matrix[14];
result[15] = matrix[15];
return result;
};
var scaleScratch22 = new Cartesian3_default();
Matrix4.setUniformScale = function(matrix, scale, result) {
Check_default.typeOf.object("matrix", matrix);
Check_default.typeOf.number("scale", scale);
Check_default.typeOf.object("result", result);
const existingScale = Matrix4.getScale(matrix, scaleScratch22);
const scaleRatioX = scale / existingScale.x;
const scaleRatioY = scale / existingScale.y;
const scaleRatioZ = scale / existingScale.z;
result[0] = matrix[0] * scaleRatioX;
result[1] = matrix[1] * scaleRatioX;
result[2] = matrix[2] * scaleRatioX;
result[3] = matrix[3];
result[4] = matrix[4] * scaleRatioY;
result[5] = matrix[5] * scaleRatioY;
result[6] = matrix[6] * scaleRatioY;
result[7] = matrix[7];
result[8] = matrix[8] * scaleRatioZ;
result[9] = matrix[9] * scaleRatioZ;
result[10] = matrix[10] * scaleRatioZ;
result[11] = matrix[11];
result[12] = matrix[12];
result[13] = matrix[13];
result[14] = matrix[14];
result[15] = matrix[15];
return result;
};
var scratchColumn2 = new Cartesian3_default();
Matrix4.getScale = function(matrix, result) {
Check_default.typeOf.object("matrix", matrix);
Check_default.typeOf.object("result", result);
result.x = Cartesian3_default.magnitude(
Cartesian3_default.fromElements(matrix[0], matrix[1], matrix[2], scratchColumn2)
);
result.y = Cartesian3_default.magnitude(
Cartesian3_default.fromElements(matrix[4], matrix[5], matrix[6], scratchColumn2)
);
result.z = Cartesian3_default.magnitude(
Cartesian3_default.fromElements(matrix[8], matrix[9], matrix[10], scratchColumn2)
);
return result;
};
var scaleScratch32 = new Cartesian3_default();
Matrix4.getMaximumScale = function(matrix) {
Matrix4.getScale(matrix, scaleScratch32);
return Cartesian3_default.maximumComponent(scaleScratch32);
};
var scaleScratch42 = new Cartesian3_default();
Matrix4.setRotation = function(matrix, rotation, result) {
Check_default.typeOf.object("matrix", matrix);
Check_default.typeOf.object("result", result);
const scale = Matrix4.getScale(matrix, scaleScratch42);
result[0] = rotation[0] * scale.x;
result[1] = rotation[1] * scale.x;
result[2] = rotation[2] * scale.x;
result[3] = matrix[3];
result[4] = rotation[3] * scale.y;
result[5] = rotation[4] * scale.y;
result[6] = rotation[5] * scale.y;
result[7] = matrix[7];
result[8] = rotation[6] * scale.z;
result[9] = rotation[7] * scale.z;
result[10] = rotation[8] * scale.z;
result[11] = matrix[11];
result[12] = matrix[12];
result[13] = matrix[13];
result[14] = matrix[14];
result[15] = matrix[15];
return result;
};
var scaleScratch52 = new Cartesian3_default();
Matrix4.getRotation = function(matrix, result) {
Check_default.typeOf.object("matrix", matrix);
Check_default.typeOf.object("result", result);
const scale = Matrix4.getScale(matrix, scaleScratch52);
result[0] = matrix[0] / scale.x;
result[1] = matrix[1] / scale.x;
result[2] = matrix[2] / scale.x;
result[3] = matrix[4] / scale.y;
result[4] = matrix[5] / scale.y;
result[5] = matrix[6] / scale.y;
result[6] = matrix[8] / scale.z;
result[7] = matrix[9] / scale.z;
result[8] = matrix[10] / scale.z;
return result;
};
Matrix4.multiply = function(left, right, result) {
Check_default.typeOf.object("left", left);
Check_default.typeOf.object("right", right);
Check_default.typeOf.object("result", result);
const left0 = left[0];
const left1 = left[1];
const left2 = left[2];
const left3 = left[3];
const left4 = left[4];
const left5 = left[5];
const left6 = left[6];
const left7 = left[7];
const left8 = left[8];
const left9 = left[9];
const left10 = left[10];
const left11 = left[11];
const left12 = left[12];
const left13 = left[13];
const left14 = left[14];
const left15 = left[15];
const right0 = right[0];
const right1 = right[1];
const right2 = right[2];
const right3 = right[3];
const right4 = right[4];
const right5 = right[5];
const right6 = right[6];
const right7 = right[7];
const right8 = right[8];
const right9 = right[9];
const right10 = right[10];
const right11 = right[11];
const right12 = right[12];
const right13 = right[13];
const right14 = right[14];
const right15 = right[15];
const column0Row0 = left0 * right0 + left4 * right1 + left8 * right2 + left12 * right3;
const column0Row1 = left1 * right0 + left5 * right1 + left9 * right2 + left13 * right3;
const column0Row2 = left2 * right0 + left6 * right1 + left10 * right2 + left14 * right3;
const column0Row3 = left3 * right0 + left7 * right1 + left11 * right2 + left15 * right3;
const column1Row0 = left0 * right4 + left4 * right5 + left8 * right6 + left12 * right7;
const column1Row1 = left1 * right4 + left5 * right5 + left9 * right6 + left13 * right7;
const column1Row2 = left2 * right4 + left6 * right5 + left10 * right6 + left14 * right7;
const column1Row3 = left3 * right4 + left7 * right5 + left11 * right6 + left15 * right7;
const column2Row0 = left0 * right8 + left4 * right9 + left8 * right10 + left12 * right11;
const column2Row1 = left1 * right8 + left5 * right9 + left9 * right10 + left13 * right11;
const column2Row2 = left2 * right8 + left6 * right9 + left10 * right10 + left14 * right11;
const column2Row3 = left3 * right8 + left7 * right9 + left11 * right10 + left15 * right11;
const column3Row0 = left0 * right12 + left4 * right13 + left8 * right14 + left12 * right15;
const column3Row1 = left1 * right12 + left5 * right13 + left9 * right14 + left13 * right15;
const column3Row2 = left2 * right12 + left6 * right13 + left10 * right14 + left14 * right15;
const column3Row3 = left3 * right12 + left7 * right13 + left11 * right14 + left15 * right15;
result[0] = column0Row0;
result[1] = column0Row1;
result[2] = column0Row2;
result[3] = column0Row3;
result[4] = column1Row0;
result[5] = column1Row1;
result[6] = column1Row2;
result[7] = column1Row3;
result[8] = column2Row0;
result[9] = column2Row1;
result[10] = column2Row2;
result[11] = column2Row3;
result[12] = column3Row0;
result[13] = column3Row1;
result[14] = column3Row2;
result[15] = column3Row3;
return result;
};
Matrix4.add = function(left, right, result) {
Check_default.typeOf.object("left", left);
Check_default.typeOf.object("right", right);
Check_default.typeOf.object("result", result);
result[0] = left[0] + right[0];
result[1] = left[1] + right[1];
result[2] = left[2] + right[2];
result[3] = left[3] + right[3];
result[4] = left[4] + right[4];
result[5] = left[5] + right[5];
result[6] = left[6] + right[6];
result[7] = left[7] + right[7];
result[8] = left[8] + right[8];
result[9] = left[9] + right[9];
result[10] = left[10] + right[10];
result[11] = left[11] + right[11];
result[12] = left[12] + right[12];
result[13] = left[13] + right[13];
result[14] = left[14] + right[14];
result[15] = left[15] + right[15];
return result;
};
Matrix4.subtract = function(left, right, result) {
Check_default.typeOf.object("left", left);
Check_default.typeOf.object("right", right);
Check_default.typeOf.object("result", result);
result[0] = left[0] - right[0];
result[1] = left[1] - right[1];
result[2] = left[2] - right[2];
result[3] = left[3] - right[3];
result[4] = left[4] - right[4];
result[5] = left[5] - right[5];
result[6] = left[6] - right[6];
result[7] = left[7] - right[7];
result[8] = left[8] - right[8];
result[9] = left[9] - right[9];
result[10] = left[10] - right[10];
result[11] = left[11] - right[11];
result[12] = left[12] - right[12];
result[13] = left[13] - right[13];
result[14] = left[14] - right[14];
result[15] = left[15] - right[15];
return result;
};
Matrix4.multiplyTransformation = function(left, right, result) {
Check_default.typeOf.object("left", left);
Check_default.typeOf.object("right", right);
Check_default.typeOf.object("result", result);
const left0 = left[0];
const left1 = left[1];
const left2 = left[2];
const left4 = left[4];
const left5 = left[5];
const left6 = left[6];
const left8 = left[8];
const left9 = left[9];
const left10 = left[10];
const left12 = left[12];
const left13 = left[13];
const left14 = left[14];
const right0 = right[0];
const right1 = right[1];
const right2 = right[2];
const right4 = right[4];
const right5 = right[5];
const right6 = right[6];
const right8 = right[8];
const right9 = right[9];
const right10 = right[10];
const right12 = right[12];
const right13 = right[13];
const right14 = right[14];
const column0Row0 = left0 * right0 + left4 * right1 + left8 * right2;
const column0Row1 = left1 * right0 + left5 * right1 + left9 * right2;
const column0Row2 = left2 * right0 + left6 * right1 + left10 * right2;
const column1Row0 = left0 * right4 + left4 * right5 + left8 * right6;
const column1Row1 = left1 * right4 + left5 * right5 + left9 * right6;
const column1Row2 = left2 * right4 + left6 * right5 + left10 * right6;
const column2Row0 = left0 * right8 + left4 * right9 + left8 * right10;
const column2Row1 = left1 * right8 + left5 * right9 + left9 * right10;
const column2Row2 = left2 * right8 + left6 * right9 + left10 * right10;
const column3Row0 = left0 * right12 + left4 * right13 + left8 * right14 + left12;
const column3Row1 = left1 * right12 + left5 * right13 + left9 * right14 + left13;
const column3Row2 = left2 * right12 + left6 * right13 + left10 * right14 + left14;
result[0] = column0Row0;
result[1] = column0Row1;
result[2] = column0Row2;
result[3] = 0;
result[4] = column1Row0;
result[5] = column1Row1;
result[6] = column1Row2;
result[7] = 0;
result[8] = column2Row0;
result[9] = column2Row1;
result[10] = column2Row2;
result[11] = 0;
result[12] = column3Row0;
result[13] = column3Row1;
result[14] = column3Row2;
result[15] = 1;
return result;
};
Matrix4.multiplyByMatrix3 = function(matrix, rotation, result) {
Check_default.typeOf.object("matrix", matrix);
Check_default.typeOf.object("rotation", rotation);
Check_default.typeOf.object("result", result);
const left0 = matrix[0];
const left1 = matrix[1];
const left2 = matrix[2];
const left4 = matrix[4];
const left5 = matrix[5];
const left6 = matrix[6];
const left8 = matrix[8];
const left9 = matrix[9];
const left10 = matrix[10];
const right0 = rotation[0];
const right1 = rotation[1];
const right2 = rotation[2];
const right4 = rotation[3];
const right5 = rotation[4];
const right6 = rotation[5];
const right8 = rotation[6];
const right9 = rotation[7];
const right10 = rotation[8];
const column0Row0 = left0 * right0 + left4 * right1 + left8 * right2;
const column0Row1 = left1 * right0 + left5 * right1 + left9 * right2;
const column0Row2 = left2 * right0 + left6 * right1 + left10 * right2;
const column1Row0 = left0 * right4 + left4 * right5 + left8 * right6;
const column1Row1 = left1 * right4 + left5 * right5 + left9 * right6;
const column1Row2 = left2 * right4 + left6 * right5 + left10 * right6;
const column2Row0 = left0 * right8 + left4 * right9 + left8 * right10;
const column2Row1 = left1 * right8 + left5 * right9 + left9 * right10;
const column2Row2 = left2 * right8 + left6 * right9 + left10 * right10;
result[0] = column0Row0;
result[1] = column0Row1;
result[2] = column0Row2;
result[3] = 0;
result[4] = column1Row0;
result[5] = column1Row1;
result[6] = column1Row2;
result[7] = 0;
result[8] = column2Row0;
result[9] = column2Row1;
result[10] = column2Row2;
result[11] = 0;
result[12] = matrix[12];
result[13] = matrix[13];
result[14] = matrix[14];
result[15] = matrix[15];
return result;
};
Matrix4.multiplyByTranslation = function(matrix, translation3, result) {
Check_default.typeOf.object("matrix", matrix);
Check_default.typeOf.object("translation", translation3);
Check_default.typeOf.object("result", result);
const x = translation3.x;
const y = translation3.y;
const z = translation3.z;
const tx = x * matrix[0] + y * matrix[4] + z * matrix[8] + matrix[12];
const ty = x * matrix[1] + y * matrix[5] + z * matrix[9] + matrix[13];
const tz = x * matrix[2] + y * matrix[6] + z * matrix[10] + matrix[14];
result[0] = matrix[0];
result[1] = matrix[1];
result[2] = matrix[2];
result[3] = matrix[3];
result[4] = matrix[4];
result[5] = matrix[5];
result[6] = matrix[6];
result[7] = matrix[7];
result[8] = matrix[8];
result[9] = matrix[9];
result[10] = matrix[10];
result[11] = matrix[11];
result[12] = tx;
result[13] = ty;
result[14] = tz;
result[15] = matrix[15];
return result;
};
Matrix4.multiplyByScale = function(matrix, scale, result) {
Check_default.typeOf.object("matrix", matrix);
Check_default.typeOf.object("scale", scale);
Check_default.typeOf.object("result", result);
const scaleX = scale.x;
const scaleY = scale.y;
const scaleZ = scale.z;
if (scaleX === 1 && scaleY === 1 && scaleZ === 1) {
return Matrix4.clone(matrix, result);
}
result[0] = scaleX * matrix[0];
result[1] = scaleX * matrix[1];
result[2] = scaleX * matrix[2];
result[3] = matrix[3];
result[4] = scaleY * matrix[4];
result[5] = scaleY * matrix[5];
result[6] = scaleY * matrix[6];
result[7] = matrix[7];
result[8] = scaleZ * matrix[8];
result[9] = scaleZ * matrix[9];
result[10] = scaleZ * matrix[10];
result[11] = matrix[11];
result[12] = matrix[12];
result[13] = matrix[13];
result[14] = matrix[14];
result[15] = matrix[15];
return result;
};
Matrix4.multiplyByUniformScale = function(matrix, scale, result) {
Check_default.typeOf.object("matrix", matrix);
Check_default.typeOf.number("scale", scale);
Check_default.typeOf.object("result", result);
result[0] = matrix[0] * scale;
result[1] = matrix[1] * scale;
result[2] = matrix[2] * scale;
result[3] = matrix[3];
result[4] = matrix[4] * scale;
result[5] = matrix[5] * scale;
result[6] = matrix[6] * scale;
result[7] = matrix[7];
result[8] = matrix[8] * scale;
result[9] = matrix[9] * scale;
result[10] = matrix[10] * scale;
result[11] = matrix[11];
result[12] = matrix[12];
result[13] = matrix[13];
result[14] = matrix[14];
result[15] = matrix[15];
return result;
};
Matrix4.multiplyByVector = function(matrix, cartesian11, result) {
Check_default.typeOf.object("matrix", matrix);
Check_default.typeOf.object("cartesian", cartesian11);
Check_default.typeOf.object("result", result);
const vX = cartesian11.x;
const vY = cartesian11.y;
const vZ = cartesian11.z;
const vW = cartesian11.w;
const x = matrix[0] * vX + matrix[4] * vY + matrix[8] * vZ + matrix[12] * vW;
const y = matrix[1] * vX + matrix[5] * vY + matrix[9] * vZ + matrix[13] * vW;
const z = matrix[2] * vX + matrix[6] * vY + matrix[10] * vZ + matrix[14] * vW;
const w = matrix[3] * vX + matrix[7] * vY + matrix[11] * vZ + matrix[15] * vW;
result.x = x;
result.y = y;
result.z = z;
result.w = w;
return result;
};
Matrix4.multiplyByPointAsVector = function(matrix, cartesian11, result) {
Check_default.typeOf.object("matrix", matrix);
Check_default.typeOf.object("cartesian", cartesian11);
Check_default.typeOf.object("result", result);
const vX = cartesian11.x;
const vY = cartesian11.y;
const vZ = cartesian11.z;
const x = matrix[0] * vX + matrix[4] * vY + matrix[8] * vZ;
const y = matrix[1] * vX + matrix[5] * vY + matrix[9] * vZ;
const z = matrix[2] * vX + matrix[6] * vY + matrix[10] * vZ;
result.x = x;
result.y = y;
result.z = z;
return result;
};
Matrix4.multiplyByPoint = function(matrix, cartesian11, result) {
Check_default.typeOf.object("matrix", matrix);
Check_default.typeOf.object("cartesian", cartesian11);
Check_default.typeOf.object("result", result);
const vX = cartesian11.x;
const vY = cartesian11.y;
const vZ = cartesian11.z;
const x = matrix[0] * vX + matrix[4] * vY + matrix[8] * vZ + matrix[12];
const y = matrix[1] * vX + matrix[5] * vY + matrix[9] * vZ + matrix[13];
const z = matrix[2] * vX + matrix[6] * vY + matrix[10] * vZ + matrix[14];
result.x = x;
result.y = y;
result.z = z;
return result;
};
Matrix4.multiplyByScalar = function(matrix, scalar, result) {
Check_default.typeOf.object("matrix", matrix);
Check_default.typeOf.number("scalar", scalar);
Check_default.typeOf.object("result", result);
result[0] = matrix[0] * scalar;
result[1] = matrix[1] * scalar;
result[2] = matrix[2] * scalar;
result[3] = matrix[3] * scalar;
result[4] = matrix[4] * scalar;
result[5] = matrix[5] * scalar;
result[6] = matrix[6] * scalar;
result[7] = matrix[7] * scalar;
result[8] = matrix[8] * scalar;
result[9] = matrix[9] * scalar;
result[10] = matrix[10] * scalar;
result[11] = matrix[11] * scalar;
result[12] = matrix[12] * scalar;
result[13] = matrix[13] * scalar;
result[14] = matrix[14] * scalar;
result[15] = matrix[15] * scalar;
return result;
};
Matrix4.negate = function(matrix, result) {
Check_default.typeOf.object("matrix", matrix);
Check_default.typeOf.object("result", result);
result[0] = -matrix[0];
result[1] = -matrix[1];
result[2] = -matrix[2];
result[3] = -matrix[3];
result[4] = -matrix[4];
result[5] = -matrix[5];
result[6] = -matrix[6];
result[7] = -matrix[7];
result[8] = -matrix[8];
result[9] = -matrix[9];
result[10] = -matrix[10];
result[11] = -matrix[11];
result[12] = -matrix[12];
result[13] = -matrix[13];
result[14] = -matrix[14];
result[15] = -matrix[15];
return result;
};
Matrix4.transpose = function(matrix, result) {
Check_default.typeOf.object("matrix", matrix);
Check_default.typeOf.object("result", result);
const matrix1 = matrix[1];
const matrix2 = matrix[2];
const matrix3 = matrix[3];
const matrix6 = matrix[6];
const matrix7 = matrix[7];
const matrix11 = matrix[11];
result[0] = matrix[0];
result[1] = matrix[4];
result[2] = matrix[8];
result[3] = matrix[12];
result[4] = matrix1;
result[5] = matrix[5];
result[6] = matrix[9];
result[7] = matrix[13];
result[8] = matrix2;
result[9] = matrix6;
result[10] = matrix[10];
result[11] = matrix[14];
result[12] = matrix3;
result[13] = matrix7;
result[14] = matrix11;
result[15] = matrix[15];
return result;
};
Matrix4.abs = function(matrix, result) {
Check_default.typeOf.object("matrix", matrix);
Check_default.typeOf.object("result", result);
result[0] = Math.abs(matrix[0]);
result[1] = Math.abs(matrix[1]);
result[2] = Math.abs(matrix[2]);
result[3] = Math.abs(matrix[3]);
result[4] = Math.abs(matrix[4]);
result[5] = Math.abs(matrix[5]);
result[6] = Math.abs(matrix[6]);
result[7] = Math.abs(matrix[7]);
result[8] = Math.abs(matrix[8]);
result[9] = Math.abs(matrix[9]);
result[10] = Math.abs(matrix[10]);
result[11] = Math.abs(matrix[11]);
result[12] = Math.abs(matrix[12]);
result[13] = Math.abs(matrix[13]);
result[14] = Math.abs(matrix[14]);
result[15] = Math.abs(matrix[15]);
return result;
};
Matrix4.equals = function(left, right) {
return left === right || defined_default(left) && defined_default(right) && left[12] === right[12] && left[13] === right[13] && left[14] === right[14] && left[0] === right[0] && left[1] === right[1] && left[2] === right[2] && left[4] === right[4] && left[5] === right[5] && left[6] === right[6] && left[8] === right[8] && left[9] === right[9] && left[10] === right[10] && left[3] === right[3] && left[7] === right[7] && left[11] === right[11] && left[15] === right[15];
};
Matrix4.equalsEpsilon = function(left, right, epsilon) {
epsilon = defaultValue_default(epsilon, 0);
return left === right || defined_default(left) && defined_default(right) && Math.abs(left[0] - right[0]) <= epsilon && Math.abs(left[1] - right[1]) <= epsilon && Math.abs(left[2] - right[2]) <= epsilon && Math.abs(left[3] - right[3]) <= epsilon && Math.abs(left[4] - right[4]) <= epsilon && Math.abs(left[5] - right[5]) <= epsilon && Math.abs(left[6] - right[6]) <= epsilon && Math.abs(left[7] - right[7]) <= epsilon && Math.abs(left[8] - right[8]) <= epsilon && Math.abs(left[9] - right[9]) <= epsilon && Math.abs(left[10] - right[10]) <= epsilon && Math.abs(left[11] - right[11]) <= epsilon && Math.abs(left[12] - right[12]) <= epsilon && Math.abs(left[13] - right[13]) <= epsilon && Math.abs(left[14] - right[14]) <= epsilon && Math.abs(left[15] - right[15]) <= epsilon;
};
Matrix4.getTranslation = function(matrix, result) {
Check_default.typeOf.object("matrix", matrix);
Check_default.typeOf.object("result", result);
result.x = matrix[12];
result.y = matrix[13];
result.z = matrix[14];
return result;
};
Matrix4.getMatrix3 = function(matrix, result) {
Check_default.typeOf.object("matrix", matrix);
Check_default.typeOf.object("result", result);
result[0] = matrix[0];
result[1] = matrix[1];
result[2] = matrix[2];
result[3] = matrix[4];
result[4] = matrix[5];
result[5] = matrix[6];
result[6] = matrix[8];
result[7] = matrix[9];
result[8] = matrix[10];
return result;
};
var scratchInverseRotation = new Matrix3_default();
var scratchMatrix3Zero = new Matrix3_default();
var scratchBottomRow = new Cartesian4_default();
var scratchExpectedBottomRow = new Cartesian4_default(0, 0, 0, 1);
Matrix4.inverse = function(matrix, result) {
Check_default.typeOf.object("matrix", matrix);
Check_default.typeOf.object("result", result);
const src0 = matrix[0];
const src1 = matrix[4];
const src2 = matrix[8];
const src3 = matrix[12];
const src4 = matrix[1];
const src5 = matrix[5];
const src6 = matrix[9];
const src7 = matrix[13];
const src8 = matrix[2];
const src9 = matrix[6];
const src10 = matrix[10];
const src11 = matrix[14];
const src12 = matrix[3];
const src13 = matrix[7];
const src14 = matrix[11];
const src15 = matrix[15];
let tmp0 = src10 * src15;
let tmp1 = src11 * src14;
let tmp2 = src9 * src15;
let tmp3 = src11 * src13;
let tmp4 = src9 * src14;
let tmp5 = src10 * src13;
let tmp6 = src8 * src15;
let tmp7 = src11 * src12;
let tmp8 = src8 * src14;
let tmp9 = src10 * src12;
let tmp10 = src8 * src13;
let tmp11 = src9 * src12;
const dst0 = tmp0 * src5 + tmp3 * src6 + tmp4 * src7 - (tmp1 * src5 + tmp2 * src6 + tmp5 * src7);
const dst1 = tmp1 * src4 + tmp6 * src6 + tmp9 * src7 - (tmp0 * src4 + tmp7 * src6 + tmp8 * src7);
const dst2 = tmp2 * src4 + tmp7 * src5 + tmp10 * src7 - (tmp3 * src4 + tmp6 * src5 + tmp11 * src7);
const dst3 = tmp5 * src4 + tmp8 * src5 + tmp11 * src6 - (tmp4 * src4 + tmp9 * src5 + tmp10 * src6);
const dst4 = tmp1 * src1 + tmp2 * src2 + tmp5 * src3 - (tmp0 * src1 + tmp3 * src2 + tmp4 * src3);
const dst5 = tmp0 * src0 + tmp7 * src2 + tmp8 * src3 - (tmp1 * src0 + tmp6 * src2 + tmp9 * src3);
const dst6 = tmp3 * src0 + tmp6 * src1 + tmp11 * src3 - (tmp2 * src0 + tmp7 * src1 + tmp10 * src3);
const dst7 = tmp4 * src0 + tmp9 * src1 + tmp10 * src2 - (tmp5 * src0 + tmp8 * src1 + tmp11 * src2);
tmp0 = src2 * src7;
tmp1 = src3 * src6;
tmp2 = src1 * src7;
tmp3 = src3 * src5;
tmp4 = src1 * src6;
tmp5 = src2 * src5;
tmp6 = src0 * src7;
tmp7 = src3 * src4;
tmp8 = src0 * src6;
tmp9 = src2 * src4;
tmp10 = src0 * src5;
tmp11 = src1 * src4;
const dst8 = tmp0 * src13 + tmp3 * src14 + tmp4 * src15 - (tmp1 * src13 + tmp2 * src14 + tmp5 * src15);
const dst9 = tmp1 * src12 + tmp6 * src14 + tmp9 * src15 - (tmp0 * src12 + tmp7 * src14 + tmp8 * src15);
const dst10 = tmp2 * src12 + tmp7 * src13 + tmp10 * src15 - (tmp3 * src12 + tmp6 * src13 + tmp11 * src15);
const dst11 = tmp5 * src12 + tmp8 * src13 + tmp11 * src14 - (tmp4 * src12 + tmp9 * src13 + tmp10 * src14);
const dst12 = tmp2 * src10 + tmp5 * src11 + tmp1 * src9 - (tmp4 * src11 + tmp0 * src9 + tmp3 * src10);
const dst13 = tmp8 * src11 + tmp0 * src8 + tmp7 * src10 - (tmp6 * src10 + tmp9 * src11 + tmp1 * src8);
const dst14 = tmp6 * src9 + tmp11 * src11 + tmp3 * src8 - (tmp10 * src11 + tmp2 * src8 + tmp7 * src9);
const dst15 = tmp10 * src10 + tmp4 * src8 + tmp9 * src9 - (tmp8 * src9 + tmp11 * src10 + tmp5 * src8);
let det = src0 * dst0 + src1 * dst1 + src2 * dst2 + src3 * dst3;
if (Math.abs(det) < Math_default.EPSILON21) {
if (Matrix3_default.equalsEpsilon(
Matrix4.getMatrix3(matrix, scratchInverseRotation),
scratchMatrix3Zero,
Math_default.EPSILON7
) && Cartesian4_default.equals(
Matrix4.getRow(matrix, 3, scratchBottomRow),
scratchExpectedBottomRow
)) {
result[0] = 0;
result[1] = 0;
result[2] = 0;
result[3] = 0;
result[4] = 0;
result[5] = 0;
result[6] = 0;
result[7] = 0;
result[8] = 0;
result[9] = 0;
result[10] = 0;
result[11] = 0;
result[12] = -matrix[12];
result[13] = -matrix[13];
result[14] = -matrix[14];
result[15] = 1;
return result;
}
throw new RuntimeError_default(
"matrix is not invertible because its determinate is zero."
);
}
det = 1 / det;
result[0] = dst0 * det;
result[1] = dst1 * det;
result[2] = dst2 * det;
result[3] = dst3 * det;
result[4] = dst4 * det;
result[5] = dst5 * det;
result[6] = dst6 * det;
result[7] = dst7 * det;
result[8] = dst8 * det;
result[9] = dst9 * det;
result[10] = dst10 * det;
result[11] = dst11 * det;
result[12] = dst12 * det;
result[13] = dst13 * det;
result[14] = dst14 * det;
result[15] = dst15 * det;
return result;
};
Matrix4.inverseTransformation = function(matrix, result) {
Check_default.typeOf.object("matrix", matrix);
Check_default.typeOf.object("result", result);
const matrix0 = matrix[0];
const matrix1 = matrix[1];
const matrix2 = matrix[2];
const matrix4 = matrix[4];
const matrix5 = matrix[5];
const matrix6 = matrix[6];
const matrix8 = matrix[8];
const matrix9 = matrix[9];
const matrix10 = matrix[10];
const vX = matrix[12];
const vY = matrix[13];
const vZ = matrix[14];
const x = -matrix0 * vX - matrix1 * vY - matrix2 * vZ;
const y = -matrix4 * vX - matrix5 * vY - matrix6 * vZ;
const z = -matrix8 * vX - matrix9 * vY - matrix10 * vZ;
result[0] = matrix0;
result[1] = matrix4;
result[2] = matrix8;
result[3] = 0;
result[4] = matrix1;
result[5] = matrix5;
result[6] = matrix9;
result[7] = 0;
result[8] = matrix2;
result[9] = matrix6;
result[10] = matrix10;
result[11] = 0;
result[12] = x;
result[13] = y;
result[14] = z;
result[15] = 1;
return result;
};
var scratchTransposeMatrix2 = new Matrix4();
Matrix4.inverseTranspose = function(matrix, result) {
Check_default.typeOf.object("matrix", matrix);
Check_default.typeOf.object("result", result);
return Matrix4.inverse(
Matrix4.transpose(matrix, scratchTransposeMatrix2),
result
);
};
Matrix4.IDENTITY = Object.freeze(
new Matrix4(
1,
0,
0,
0,
0,
1,
0,
0,
0,
0,
1,
0,
0,
0,
0,
1
)
);
Matrix4.ZERO = Object.freeze(
new Matrix4(
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
)
);
Matrix4.COLUMN0ROW0 = 0;
Matrix4.COLUMN0ROW1 = 1;
Matrix4.COLUMN0ROW2 = 2;
Matrix4.COLUMN0ROW3 = 3;
Matrix4.COLUMN1ROW0 = 4;
Matrix4.COLUMN1ROW1 = 5;
Matrix4.COLUMN1ROW2 = 6;
Matrix4.COLUMN1ROW3 = 7;
Matrix4.COLUMN2ROW0 = 8;
Matrix4.COLUMN2ROW1 = 9;
Matrix4.COLUMN2ROW2 = 10;
Matrix4.COLUMN2ROW3 = 11;
Matrix4.COLUMN3ROW0 = 12;
Matrix4.COLUMN3ROW1 = 13;
Matrix4.COLUMN3ROW2 = 14;
Matrix4.COLUMN3ROW3 = 15;
Object.defineProperties(Matrix4.prototype, {
length: {
get: function() {
return Matrix4.packedLength;
}
}
});
Matrix4.prototype.clone = function(result) {
return Matrix4.clone(this, result);
};
Matrix4.prototype.equals = function(right) {
return Matrix4.equals(this, right);
};
Matrix4.equalsArray = function(matrix, array, offset2) {
return matrix[0] === array[offset2] && matrix[1] === array[offset2 + 1] && matrix[2] === array[offset2 + 2] && matrix[3] === array[offset2 + 3] && matrix[4] === array[offset2 + 4] && matrix[5] === array[offset2 + 5] && matrix[6] === array[offset2 + 6] && matrix[7] === array[offset2 + 7] && matrix[8] === array[offset2 + 8] && matrix[9] === array[offset2 + 9] && matrix[10] === array[offset2 + 10] && matrix[11] === array[offset2 + 11] && matrix[12] === array[offset2 + 12] && matrix[13] === array[offset2 + 13] && matrix[14] === array[offset2 + 14] && matrix[15] === array[offset2 + 15];
};
Matrix4.prototype.equalsEpsilon = function(right, epsilon) {
return Matrix4.equalsEpsilon(this, right, epsilon);
};
Matrix4.prototype.toString = function() {
return `(${this[0]}, ${this[4]}, ${this[8]}, ${this[12]})
(${this[1]}, ${this[5]}, ${this[9]}, ${this[13]})
(${this[2]}, ${this[6]}, ${this[10]}, ${this[14]})
(${this[3]}, ${this[7]}, ${this[11]}, ${this[15]})`;
};
var Matrix4_default = Matrix4;
// Source/Core/Rectangle.js
function Rectangle(west, south, east, north) {
this.west = defaultValue_default(west, 0);
this.south = defaultValue_default(south, 0);
this.east = defaultValue_default(east, 0);
this.north = defaultValue_default(north, 0);
}
Object.defineProperties(Rectangle.prototype, {
width: {
get: function() {
return Rectangle.computeWidth(this);
}
},
height: {
get: function() {
return Rectangle.computeHeight(this);
}
}
});
Rectangle.packedLength = 4;
Rectangle.pack = function(value, array, startingIndex) {
Check_default.typeOf.object("value", value);
Check_default.defined("array", array);
startingIndex = defaultValue_default(startingIndex, 0);
array[startingIndex++] = value.west;
array[startingIndex++] = value.south;
array[startingIndex++] = value.east;
array[startingIndex] = value.north;
return array;
};
Rectangle.unpack = function(array, startingIndex, result) {
Check_default.defined("array", array);
startingIndex = defaultValue_default(startingIndex, 0);
if (!defined_default(result)) {
result = new Rectangle();
}
result.west = array[startingIndex++];
result.south = array[startingIndex++];
result.east = array[startingIndex++];
result.north = array[startingIndex];
return result;
};
Rectangle.computeWidth = function(rectangle) {
Check_default.typeOf.object("rectangle", rectangle);
let east = rectangle.east;
const west = rectangle.west;
if (east < west) {
east += Math_default.TWO_PI;
}
return east - west;
};
Rectangle.computeHeight = function(rectangle) {
Check_default.typeOf.object("rectangle", rectangle);
return rectangle.north - rectangle.south;
};
Rectangle.fromDegrees = function(west, south, east, north, result) {
west = Math_default.toRadians(defaultValue_default(west, 0));
south = Math_default.toRadians(defaultValue_default(south, 0));
east = Math_default.toRadians(defaultValue_default(east, 0));
north = Math_default.toRadians(defaultValue_default(north, 0));
if (!defined_default(result)) {
return new Rectangle(west, south, east, north);
}
result.west = west;
result.south = south;
result.east = east;
result.north = north;
return result;
};
Rectangle.fromRadians = function(west, south, east, north, result) {
if (!defined_default(result)) {
return new Rectangle(west, south, east, north);
}
result.west = defaultValue_default(west, 0);
result.south = defaultValue_default(south, 0);
result.east = defaultValue_default(east, 0);
result.north = defaultValue_default(north, 0);
return result;
};
Rectangle.fromCartographicArray = function(cartographics, result) {
Check_default.defined("cartographics", cartographics);
let west = Number.MAX_VALUE;
let east = -Number.MAX_VALUE;
let westOverIDL = Number.MAX_VALUE;
let eastOverIDL = -Number.MAX_VALUE;
let south = Number.MAX_VALUE;
let north = -Number.MAX_VALUE;
for (let i = 0, len = cartographics.length; i < len; i++) {
const position = cartographics[i];
west = Math.min(west, position.longitude);
east = Math.max(east, position.longitude);
south = Math.min(south, position.latitude);
north = Math.max(north, position.latitude);
const lonAdjusted = position.longitude >= 0 ? position.longitude : position.longitude + Math_default.TWO_PI;
westOverIDL = Math.min(westOverIDL, lonAdjusted);
eastOverIDL = Math.max(eastOverIDL, lonAdjusted);
}
if (east - west > eastOverIDL - westOverIDL) {
west = westOverIDL;
east = eastOverIDL;
if (east > Math_default.PI) {
east = east - Math_default.TWO_PI;
}
if (west > Math_default.PI) {
west = west - Math_default.TWO_PI;
}
}
if (!defined_default(result)) {
return new Rectangle(west, south, east, north);
}
result.west = west;
result.south = south;
result.east = east;
result.north = north;
return result;
};
Rectangle.fromCartesianArray = function(cartesians, ellipsoid, result) {
Check_default.defined("cartesians", cartesians);
ellipsoid = defaultValue_default(ellipsoid, Ellipsoid_default.WGS84);
let west = Number.MAX_VALUE;
let east = -Number.MAX_VALUE;
let westOverIDL = Number.MAX_VALUE;
let eastOverIDL = -Number.MAX_VALUE;
let south = Number.MAX_VALUE;
let north = -Number.MAX_VALUE;
for (let i = 0, len = cartesians.length; i < len; i++) {
const position = ellipsoid.cartesianToCartographic(cartesians[i]);
west = Math.min(west, position.longitude);
east = Math.max(east, position.longitude);
south = Math.min(south, position.latitude);
north = Math.max(north, position.latitude);
const lonAdjusted = position.longitude >= 0 ? position.longitude : position.longitude + Math_default.TWO_PI;
westOverIDL = Math.min(westOverIDL, lonAdjusted);
eastOverIDL = Math.max(eastOverIDL, lonAdjusted);
}
if (east - west > eastOverIDL - westOverIDL) {
west = westOverIDL;
east = eastOverIDL;
if (east > Math_default.PI) {
east = east - Math_default.TWO_PI;
}
if (west > Math_default.PI) {
west = west - Math_default.TWO_PI;
}
}
if (!defined_default(result)) {
return new Rectangle(west, south, east, north);
}
result.west = west;
result.south = south;
result.east = east;
result.north = north;
return result;
};
Rectangle.clone = function(rectangle, result) {
if (!defined_default(rectangle)) {
return void 0;
}
if (!defined_default(result)) {
return new Rectangle(
rectangle.west,
rectangle.south,
rectangle.east,
rectangle.north
);
}
result.west = rectangle.west;
result.south = rectangle.south;
result.east = rectangle.east;
result.north = rectangle.north;
return result;
};
Rectangle.equalsEpsilon = function(left, right, absoluteEpsilon) {
absoluteEpsilon = defaultValue_default(absoluteEpsilon, 0);
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;
};
Rectangle.prototype.clone = function(result) {
return Rectangle.clone(this, result);
};
Rectangle.prototype.equals = function(other) {
return Rectangle.equals(this, other);
};
Rectangle.equals = function(left, right) {
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;
};
Rectangle.prototype.equalsEpsilon = function(other, epsilon) {
return Rectangle.equalsEpsilon(this, other, epsilon);
};
Rectangle.validate = function(rectangle) {
Check_default.typeOf.object("rectangle", rectangle);
const north = rectangle.north;
Check_default.typeOf.number.greaterThanOrEquals(
"north",
north,
-Math_default.PI_OVER_TWO
);
Check_default.typeOf.number.lessThanOrEquals("north", north, Math_default.PI_OVER_TWO);
const south = rectangle.south;
Check_default.typeOf.number.greaterThanOrEquals(
"south",
south,
-Math_default.PI_OVER_TWO
);
Check_default.typeOf.number.lessThanOrEquals("south", south, Math_default.PI_OVER_TWO);
const west = rectangle.west;
Check_default.typeOf.number.greaterThanOrEquals("west", west, -Math.PI);
Check_default.typeOf.number.lessThanOrEquals("west", west, Math.PI);
const east = rectangle.east;
Check_default.typeOf.number.greaterThanOrEquals("east", east, -Math.PI);
Check_default.typeOf.number.lessThanOrEquals("east", east, Math.PI);
};
Rectangle.southwest = function(rectangle, result) {
Check_default.typeOf.object("rectangle", rectangle);
if (!defined_default(result)) {
return new Cartographic_default(rectangle.west, rectangle.south);
}
result.longitude = rectangle.west;
result.latitude = rectangle.south;
result.height = 0;
return result;
};
Rectangle.northwest = function(rectangle, result) {
Check_default.typeOf.object("rectangle", rectangle);
if (!defined_default(result)) {
return new Cartographic_default(rectangle.west, rectangle.north);
}
result.longitude = rectangle.west;
result.latitude = rectangle.north;
result.height = 0;
return result;
};
Rectangle.northeast = function(rectangle, result) {
Check_default.typeOf.object("rectangle", rectangle);
if (!defined_default(result)) {
return new Cartographic_default(rectangle.east, rectangle.north);
}
result.longitude = rectangle.east;
result.latitude = rectangle.north;
result.height = 0;
return result;
};
Rectangle.southeast = function(rectangle, result) {
Check_default.typeOf.object("rectangle", rectangle);
if (!defined_default(result)) {
return new Cartographic_default(rectangle.east, rectangle.south);
}
result.longitude = rectangle.east;
result.latitude = rectangle.south;
result.height = 0;
return result;
};
Rectangle.center = function(rectangle, result) {
Check_default.typeOf.object("rectangle", rectangle);
let east = rectangle.east;
const west = rectangle.west;
if (east < west) {
east += Math_default.TWO_PI;
}
const longitude = Math_default.negativePiToPi((west + east) * 0.5);
const latitude = (rectangle.south + rectangle.north) * 0.5;
if (!defined_default(result)) {
return new Cartographic_default(longitude, latitude);
}
result.longitude = longitude;
result.latitude = latitude;
result.height = 0;
return result;
};
Rectangle.intersection = function(rectangle, otherRectangle, result) {
Check_default.typeOf.object("rectangle", rectangle);
Check_default.typeOf.object("otherRectangle", otherRectangle);
let rectangleEast = rectangle.east;
let rectangleWest = rectangle.west;
let otherRectangleEast = otherRectangle.east;
let otherRectangleWest = otherRectangle.west;
if (rectangleEast < rectangleWest && otherRectangleEast > 0) {
rectangleEast += Math_default.TWO_PI;
} else if (otherRectangleEast < otherRectangleWest && rectangleEast > 0) {
otherRectangleEast += Math_default.TWO_PI;
}
if (rectangleEast < rectangleWest && otherRectangleWest < 0) {
otherRectangleWest += Math_default.TWO_PI;
} else if (otherRectangleEast < otherRectangleWest && rectangleWest < 0) {
rectangleWest += Math_default.TWO_PI;
}
const west = Math_default.negativePiToPi(
Math.max(rectangleWest, otherRectangleWest)
);
const east = Math_default.negativePiToPi(
Math.min(rectangleEast, otherRectangleEast)
);
if ((rectangle.west < rectangle.east || otherRectangle.west < otherRectangle.east) && east <= west) {
return void 0;
}
const south = Math.max(rectangle.south, otherRectangle.south);
const north = Math.min(rectangle.north, otherRectangle.north);
if (south >= north) {
return void 0;
}
if (!defined_default(result)) {
return new Rectangle(west, south, east, north);
}
result.west = west;
result.south = south;
result.east = east;
result.north = north;
return result;
};
Rectangle.simpleIntersection = function(rectangle, otherRectangle, result) {
Check_default.typeOf.object("rectangle", rectangle);
Check_default.typeOf.object("otherRectangle", otherRectangle);
const west = Math.max(rectangle.west, otherRectangle.west);
const south = Math.max(rectangle.south, otherRectangle.south);
const east = Math.min(rectangle.east, otherRectangle.east);
const north = Math.min(rectangle.north, otherRectangle.north);
if (south >= north || west >= east) {
return void 0;
}
if (!defined_default(result)) {
return new Rectangle(west, south, east, north);
}
result.west = west;
result.south = south;
result.east = east;
result.north = north;
return result;
};
Rectangle.union = function(rectangle, otherRectangle, result) {
Check_default.typeOf.object("rectangle", rectangle);
Check_default.typeOf.object("otherRectangle", otherRectangle);
if (!defined_default(result)) {
result = new Rectangle();
}
let rectangleEast = rectangle.east;
let rectangleWest = rectangle.west;
let otherRectangleEast = otherRectangle.east;
let otherRectangleWest = otherRectangle.west;
if (rectangleEast < rectangleWest && otherRectangleEast > 0) {
rectangleEast += Math_default.TWO_PI;
} else if (otherRectangleEast < otherRectangleWest && rectangleEast > 0) {
otherRectangleEast += Math_default.TWO_PI;
}
if (rectangleEast < rectangleWest && otherRectangleWest < 0) {
otherRectangleWest += Math_default.TWO_PI;
} else if (otherRectangleEast < otherRectangleWest && rectangleWest < 0) {
rectangleWest += Math_default.TWO_PI;
}
const west = Math_default.negativePiToPi(
Math.min(rectangleWest, otherRectangleWest)
);
const east = Math_default.negativePiToPi(
Math.max(rectangleEast, otherRectangleEast)
);
result.west = west;
result.south = Math.min(rectangle.south, otherRectangle.south);
result.east = east;
result.north = Math.max(rectangle.north, otherRectangle.north);
return result;
};
Rectangle.expand = function(rectangle, cartographic2, result) {
Check_default.typeOf.object("rectangle", rectangle);
Check_default.typeOf.object("cartographic", cartographic2);
if (!defined_default(result)) {
result = new Rectangle();
}
result.west = Math.min(rectangle.west, cartographic2.longitude);
result.south = Math.min(rectangle.south, cartographic2.latitude);
result.east = Math.max(rectangle.east, cartographic2.longitude);
result.north = Math.max(rectangle.north, cartographic2.latitude);
return result;
};
Rectangle.contains = function(rectangle, cartographic2) {
Check_default.typeOf.object("rectangle", rectangle);
Check_default.typeOf.object("cartographic", cartographic2);
let longitude = cartographic2.longitude;
const latitude = cartographic2.latitude;
const west = rectangle.west;
let east = rectangle.east;
if (east < west) {
east += Math_default.TWO_PI;
if (longitude < 0) {
longitude += Math_default.TWO_PI;
}
}
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;
};
var subsampleLlaScratch = new Cartographic_default();
Rectangle.subsample = function(rectangle, ellipsoid, surfaceHeight, result) {
Check_default.typeOf.object("rectangle", rectangle);
ellipsoid = defaultValue_default(ellipsoid, Ellipsoid_default.WGS84);
surfaceHeight = defaultValue_default(surfaceHeight, 0);
if (!defined_default(result)) {
result = [];
}
let length3 = 0;
const north = rectangle.north;
const south = rectangle.south;
const east = rectangle.east;
const west = rectangle.west;
const lla = subsampleLlaScratch;
lla.height = surfaceHeight;
lla.longitude = west;
lla.latitude = north;
result[length3] = ellipsoid.cartographicToCartesian(lla, result[length3]);
length3++;
lla.longitude = east;
result[length3] = ellipsoid.cartographicToCartesian(lla, result[length3]);
length3++;
lla.latitude = south;
result[length3] = ellipsoid.cartographicToCartesian(lla, result[length3]);
length3++;
lla.longitude = west;
result[length3] = ellipsoid.cartographicToCartesian(lla, result[length3]);
length3++;
if (north < 0) {
lla.latitude = north;
} else if (south > 0) {
lla.latitude = south;
} else {
lla.latitude = 0;
}
for (let i = 1; i < 8; ++i) {
lla.longitude = -Math.PI + i * Math_default.PI_OVER_TWO;
if (Rectangle.contains(rectangle, lla)) {
result[length3] = ellipsoid.cartographicToCartesian(lla, result[length3]);
length3++;
}
}
if (lla.latitude === 0) {
lla.longitude = west;
result[length3] = ellipsoid.cartographicToCartesian(lla, result[length3]);
length3++;
lla.longitude = east;
result[length3] = ellipsoid.cartographicToCartesian(lla, result[length3]);
length3++;
}
result.length = length3;
return result;
};
Rectangle.subsection = function(rectangle, westLerp, southLerp, eastLerp, northLerp, result) {
Check_default.typeOf.object("rectangle", rectangle);
Check_default.typeOf.number.greaterThanOrEquals("westLerp", westLerp, 0);
Check_default.typeOf.number.lessThanOrEquals("westLerp", westLerp, 1);
Check_default.typeOf.number.greaterThanOrEquals("southLerp", southLerp, 0);
Check_default.typeOf.number.lessThanOrEquals("southLerp", southLerp, 1);
Check_default.typeOf.number.greaterThanOrEquals("eastLerp", eastLerp, 0);
Check_default.typeOf.number.lessThanOrEquals("eastLerp", eastLerp, 1);
Check_default.typeOf.number.greaterThanOrEquals("northLerp", northLerp, 0);
Check_default.typeOf.number.lessThanOrEquals("northLerp", northLerp, 1);
Check_default.typeOf.number.lessThanOrEquals("westLerp", westLerp, eastLerp);
Check_default.typeOf.number.lessThanOrEquals("southLerp", southLerp, northLerp);
if (!defined_default(result)) {
result = new Rectangle();
}
if (rectangle.west <= rectangle.east) {
const width = rectangle.east - rectangle.west;
result.west = rectangle.west + westLerp * width;
result.east = rectangle.west + eastLerp * width;
} else {
const width = Math_default.TWO_PI + rectangle.east - rectangle.west;
result.west = Math_default.negativePiToPi(rectangle.west + westLerp * width);
result.east = Math_default.negativePiToPi(rectangle.west + eastLerp * width);
}
const height = rectangle.north - rectangle.south;
result.south = rectangle.south + southLerp * height;
result.north = rectangle.south + northLerp * height;
if (westLerp === 1) {
result.west = rectangle.east;
}
if (eastLerp === 1) {
result.east = rectangle.east;
}
if (southLerp === 1) {
result.south = rectangle.north;
}
if (northLerp === 1) {
result.north = rectangle.north;
}
return result;
};
Rectangle.MAX_VALUE = Object.freeze(
new Rectangle(
-Math.PI,
-Math_default.PI_OVER_TWO,
Math.PI,
Math_default.PI_OVER_TWO
)
);
var Rectangle_default = Rectangle;
// Source/Core/BoundingSphere.js
function BoundingSphere(center, radius) {
this.center = Cartesian3_default.clone(defaultValue_default(center, Cartesian3_default.ZERO));
this.radius = defaultValue_default(radius, 0);
}
var fromPointsXMin = new Cartesian3_default();
var fromPointsYMin = new Cartesian3_default();
var fromPointsZMin = new Cartesian3_default();
var fromPointsXMax = new Cartesian3_default();
var fromPointsYMax = new Cartesian3_default();
var fromPointsZMax = new Cartesian3_default();
var fromPointsCurrentPos = new Cartesian3_default();
var fromPointsScratch = new Cartesian3_default();
var fromPointsRitterCenter = new Cartesian3_default();
var fromPointsMinBoxPt = new Cartesian3_default();
var fromPointsMaxBoxPt = new Cartesian3_default();
var fromPointsNaiveCenterScratch = new Cartesian3_default();
var volumeConstant = 4 / 3 * Math_default.PI;
BoundingSphere.fromPoints = function(positions, result) {
if (!defined_default(result)) {
result = new BoundingSphere();
}
if (!defined_default(positions) || positions.length === 0) {
result.center = Cartesian3_default.clone(Cartesian3_default.ZERO, result.center);
result.radius = 0;
return result;
}
const currentPos = Cartesian3_default.clone(positions[0], fromPointsCurrentPos);
const xMin = Cartesian3_default.clone(currentPos, fromPointsXMin);
const yMin = Cartesian3_default.clone(currentPos, fromPointsYMin);
const zMin = Cartesian3_default.clone(currentPos, fromPointsZMin);
const xMax = Cartesian3_default.clone(currentPos, fromPointsXMax);
const yMax = Cartesian3_default.clone(currentPos, fromPointsYMax);
const zMax = Cartesian3_default.clone(currentPos, fromPointsZMax);
const numPositions = positions.length;
let i;
for (i = 1; i < numPositions; i++) {
Cartesian3_default.clone(positions[i], currentPos);
const x = currentPos.x;
const y = currentPos.y;
const z = currentPos.z;
if (x < xMin.x) {
Cartesian3_default.clone(currentPos, xMin);
}
if (x > xMax.x) {
Cartesian3_default.clone(currentPos, xMax);
}
if (y < yMin.y) {
Cartesian3_default.clone(currentPos, yMin);
}
if (y > yMax.y) {
Cartesian3_default.clone(currentPos, yMax);
}
if (z < zMin.z) {
Cartesian3_default.clone(currentPos, zMin);
}
if (z > zMax.z) {
Cartesian3_default.clone(currentPos, zMax);
}
}
const xSpan = Cartesian3_default.magnitudeSquared(
Cartesian3_default.subtract(xMax, xMin, fromPointsScratch)
);
const ySpan = Cartesian3_default.magnitudeSquared(
Cartesian3_default.subtract(yMax, yMin, fromPointsScratch)
);
const zSpan = Cartesian3_default.magnitudeSquared(
Cartesian3_default.subtract(zMax, zMin, fromPointsScratch)
);
let diameter1 = xMin;
let diameter2 = xMax;
let maxSpan = xSpan;
if (ySpan > maxSpan) {
maxSpan = ySpan;
diameter1 = yMin;
diameter2 = yMax;
}
if (zSpan > maxSpan) {
maxSpan = zSpan;
diameter1 = zMin;
diameter2 = zMax;
}
const ritterCenter = fromPointsRitterCenter;
ritterCenter.x = (diameter1.x + diameter2.x) * 0.5;
ritterCenter.y = (diameter1.y + diameter2.y) * 0.5;
ritterCenter.z = (diameter1.z + diameter2.z) * 0.5;
let radiusSquared = Cartesian3_default.magnitudeSquared(
Cartesian3_default.subtract(diameter2, ritterCenter, fromPointsScratch)
);
let ritterRadius = Math.sqrt(radiusSquared);
const minBoxPt = fromPointsMinBoxPt;
minBoxPt.x = xMin.x;
minBoxPt.y = yMin.y;
minBoxPt.z = zMin.z;
const maxBoxPt = fromPointsMaxBoxPt;
maxBoxPt.x = xMax.x;
maxBoxPt.y = yMax.y;
maxBoxPt.z = zMax.z;
const naiveCenter = Cartesian3_default.midpoint(
minBoxPt,
maxBoxPt,
fromPointsNaiveCenterScratch
);
let naiveRadius = 0;
for (i = 0; i < numPositions; i++) {
Cartesian3_default.clone(positions[i], currentPos);
const r = Cartesian3_default.magnitude(
Cartesian3_default.subtract(currentPos, naiveCenter, fromPointsScratch)
);
if (r > naiveRadius) {
naiveRadius = r;
}
const oldCenterToPointSquared = Cartesian3_default.magnitudeSquared(
Cartesian3_default.subtract(currentPos, ritterCenter, fromPointsScratch)
);
if (oldCenterToPointSquared > radiusSquared) {
const oldCenterToPoint = Math.sqrt(oldCenterToPointSquared);
ritterRadius = (ritterRadius + oldCenterToPoint) * 0.5;
radiusSquared = ritterRadius * ritterRadius;
const oldToNew = oldCenterToPoint - ritterRadius;
ritterCenter.x = (ritterRadius * ritterCenter.x + oldToNew * currentPos.x) / oldCenterToPoint;
ritterCenter.y = (ritterRadius * ritterCenter.y + oldToNew * currentPos.y) / oldCenterToPoint;
ritterCenter.z = (ritterRadius * ritterCenter.z + oldToNew * currentPos.z) / oldCenterToPoint;
}
}
if (ritterRadius < naiveRadius) {
Cartesian3_default.clone(ritterCenter, result.center);
result.radius = ritterRadius;
} else {
Cartesian3_default.clone(naiveCenter, result.center);
result.radius = naiveRadius;
}
return result;
};
var defaultProjection = new GeographicProjection_default();
var fromRectangle2DLowerLeft = new Cartesian3_default();
var fromRectangle2DUpperRight = new Cartesian3_default();
var fromRectangle2DSouthwest = new Cartographic_default();
var fromRectangle2DNortheast = new Cartographic_default();
BoundingSphere.fromRectangle2D = function(rectangle, projection, result) {
return BoundingSphere.fromRectangleWithHeights2D(
rectangle,
projection,
0,
0,
result
);
};
BoundingSphere.fromRectangleWithHeights2D = function(rectangle, projection, minimumHeight, maximumHeight, result) {
if (!defined_default(result)) {
result = new BoundingSphere();
}
if (!defined_default(rectangle)) {
result.center = Cartesian3_default.clone(Cartesian3_default.ZERO, result.center);
result.radius = 0;
return result;
}
projection = defaultValue_default(projection, defaultProjection);
Rectangle_default.southwest(rectangle, fromRectangle2DSouthwest);
fromRectangle2DSouthwest.height = minimumHeight;
Rectangle_default.northeast(rectangle, fromRectangle2DNortheast);
fromRectangle2DNortheast.height = maximumHeight;
const lowerLeft = projection.project(
fromRectangle2DSouthwest,
fromRectangle2DLowerLeft
);
const upperRight = projection.project(
fromRectangle2DNortheast,
fromRectangle2DUpperRight
);
const width = upperRight.x - lowerLeft.x;
const height = upperRight.y - lowerLeft.y;
const elevation = upperRight.z - lowerLeft.z;
result.radius = Math.sqrt(width * width + height * height + elevation * elevation) * 0.5;
const center = result.center;
center.x = lowerLeft.x + width * 0.5;
center.y = lowerLeft.y + height * 0.5;
center.z = lowerLeft.z + elevation * 0.5;
return result;
};
var fromRectangle3DScratch = [];
BoundingSphere.fromRectangle3D = function(rectangle, ellipsoid, surfaceHeight, result) {
ellipsoid = defaultValue_default(ellipsoid, Ellipsoid_default.WGS84);
surfaceHeight = defaultValue_default(surfaceHeight, 0);
if (!defined_default(result)) {
result = new BoundingSphere();
}
if (!defined_default(rectangle)) {
result.center = Cartesian3_default.clone(Cartesian3_default.ZERO, result.center);
result.radius = 0;
return result;
}
const positions = Rectangle_default.subsample(
rectangle,
ellipsoid,
surfaceHeight,
fromRectangle3DScratch
);
return BoundingSphere.fromPoints(positions, result);
};
BoundingSphere.fromVertices = function(positions, center, stride, result) {
if (!defined_default(result)) {
result = new BoundingSphere();
}
if (!defined_default(positions) || positions.length === 0) {
result.center = Cartesian3_default.clone(Cartesian3_default.ZERO, result.center);
result.radius = 0;
return result;
}
center = defaultValue_default(center, Cartesian3_default.ZERO);
stride = defaultValue_default(stride, 3);
Check_default.typeOf.number.greaterThanOrEquals("stride", stride, 3);
const currentPos = fromPointsCurrentPos;
currentPos.x = positions[0] + center.x;
currentPos.y = positions[1] + center.y;
currentPos.z = positions[2] + center.z;
const xMin = Cartesian3_default.clone(currentPos, fromPointsXMin);
const yMin = Cartesian3_default.clone(currentPos, fromPointsYMin);
const zMin = Cartesian3_default.clone(currentPos, fromPointsZMin);
const xMax = Cartesian3_default.clone(currentPos, fromPointsXMax);
const yMax = Cartesian3_default.clone(currentPos, fromPointsYMax);
const zMax = Cartesian3_default.clone(currentPos, fromPointsZMax);
const numElements = positions.length;
let i;
for (i = 0; i < numElements; i += stride) {
const x = positions[i] + center.x;
const y = positions[i + 1] + center.y;
const z = positions[i + 2] + center.z;
currentPos.x = x;
currentPos.y = y;
currentPos.z = z;
if (x < xMin.x) {
Cartesian3_default.clone(currentPos, xMin);
}
if (x > xMax.x) {
Cartesian3_default.clone(currentPos, xMax);
}
if (y < yMin.y) {
Cartesian3_default.clone(currentPos, yMin);
}
if (y > yMax.y) {
Cartesian3_default.clone(currentPos, yMax);
}
if (z < zMin.z) {
Cartesian3_default.clone(currentPos, zMin);
}
if (z > zMax.z) {
Cartesian3_default.clone(currentPos, zMax);
}
}
const xSpan = Cartesian3_default.magnitudeSquared(
Cartesian3_default.subtract(xMax, xMin, fromPointsScratch)
);
const ySpan = Cartesian3_default.magnitudeSquared(
Cartesian3_default.subtract(yMax, yMin, fromPointsScratch)
);
const zSpan = Cartesian3_default.magnitudeSquared(
Cartesian3_default.subtract(zMax, zMin, fromPointsScratch)
);
let diameter1 = xMin;
let diameter2 = xMax;
let maxSpan = xSpan;
if (ySpan > maxSpan) {
maxSpan = ySpan;
diameter1 = yMin;
diameter2 = yMax;
}
if (zSpan > maxSpan) {
maxSpan = zSpan;
diameter1 = zMin;
diameter2 = zMax;
}
const ritterCenter = fromPointsRitterCenter;
ritterCenter.x = (diameter1.x + diameter2.x) * 0.5;
ritterCenter.y = (diameter1.y + diameter2.y) * 0.5;
ritterCenter.z = (diameter1.z + diameter2.z) * 0.5;
let radiusSquared = Cartesian3_default.magnitudeSquared(
Cartesian3_default.subtract(diameter2, ritterCenter, fromPointsScratch)
);
let ritterRadius = Math.sqrt(radiusSquared);
const minBoxPt = fromPointsMinBoxPt;
minBoxPt.x = xMin.x;
minBoxPt.y = yMin.y;
minBoxPt.z = zMin.z;
const maxBoxPt = fromPointsMaxBoxPt;
maxBoxPt.x = xMax.x;
maxBoxPt.y = yMax.y;
maxBoxPt.z = zMax.z;
const naiveCenter = Cartesian3_default.midpoint(
minBoxPt,
maxBoxPt,
fromPointsNaiveCenterScratch
);
let naiveRadius = 0;
for (i = 0; i < numElements; i += stride) {
currentPos.x = positions[i] + center.x;
currentPos.y = positions[i + 1] + center.y;
currentPos.z = positions[i + 2] + center.z;
const r = Cartesian3_default.magnitude(
Cartesian3_default.subtract(currentPos, naiveCenter, fromPointsScratch)
);
if (r > naiveRadius) {
naiveRadius = r;
}
const oldCenterToPointSquared = Cartesian3_default.magnitudeSquared(
Cartesian3_default.subtract(currentPos, ritterCenter, fromPointsScratch)
);
if (oldCenterToPointSquared > radiusSquared) {
const oldCenterToPoint = Math.sqrt(oldCenterToPointSquared);
ritterRadius = (ritterRadius + oldCenterToPoint) * 0.5;
radiusSquared = ritterRadius * ritterRadius;
const oldToNew = oldCenterToPoint - ritterRadius;
ritterCenter.x = (ritterRadius * ritterCenter.x + oldToNew * currentPos.x) / oldCenterToPoint;
ritterCenter.y = (ritterRadius * ritterCenter.y + oldToNew * currentPos.y) / oldCenterToPoint;
ritterCenter.z = (ritterRadius * ritterCenter.z + oldToNew * currentPos.z) / oldCenterToPoint;
}
}
if (ritterRadius < naiveRadius) {
Cartesian3_default.clone(ritterCenter, result.center);
result.radius = ritterRadius;
} else {
Cartesian3_default.clone(naiveCenter, result.center);
result.radius = naiveRadius;
}
return result;
};
BoundingSphere.fromEncodedCartesianVertices = function(positionsHigh, positionsLow, result) {
if (!defined_default(result)) {
result = new BoundingSphere();
}
if (!defined_default(positionsHigh) || !defined_default(positionsLow) || positionsHigh.length !== positionsLow.length || positionsHigh.length === 0) {
result.center = Cartesian3_default.clone(Cartesian3_default.ZERO, result.center);
result.radius = 0;
return result;
}
const currentPos = fromPointsCurrentPos;
currentPos.x = positionsHigh[0] + positionsLow[0];
currentPos.y = positionsHigh[1] + positionsLow[1];
currentPos.z = positionsHigh[2] + positionsLow[2];
const xMin = Cartesian3_default.clone(currentPos, fromPointsXMin);
const yMin = Cartesian3_default.clone(currentPos, fromPointsYMin);
const zMin = Cartesian3_default.clone(currentPos, fromPointsZMin);
const xMax = Cartesian3_default.clone(currentPos, fromPointsXMax);
const yMax = Cartesian3_default.clone(currentPos, fromPointsYMax);
const zMax = Cartesian3_default.clone(currentPos, fromPointsZMax);
const numElements = positionsHigh.length;
let i;
for (i = 0; i < numElements; i += 3) {
const x = positionsHigh[i] + positionsLow[i];
const y = positionsHigh[i + 1] + positionsLow[i + 1];
const z = positionsHigh[i + 2] + positionsLow[i + 2];
currentPos.x = x;
currentPos.y = y;
currentPos.z = z;
if (x < xMin.x) {
Cartesian3_default.clone(currentPos, xMin);
}
if (x > xMax.x) {
Cartesian3_default.clone(currentPos, xMax);
}
if (y < yMin.y) {
Cartesian3_default.clone(currentPos, yMin);
}
if (y > yMax.y) {
Cartesian3_default.clone(currentPos, yMax);
}
if (z < zMin.z) {
Cartesian3_default.clone(currentPos, zMin);
}
if (z > zMax.z) {
Cartesian3_default.clone(currentPos, zMax);
}
}
const xSpan = Cartesian3_default.magnitudeSquared(
Cartesian3_default.subtract(xMax, xMin, fromPointsScratch)
);
const ySpan = Cartesian3_default.magnitudeSquared(
Cartesian3_default.subtract(yMax, yMin, fromPointsScratch)
);
const zSpan = Cartesian3_default.magnitudeSquared(
Cartesian3_default.subtract(zMax, zMin, fromPointsScratch)
);
let diameter1 = xMin;
let diameter2 = xMax;
let maxSpan = xSpan;
if (ySpan > maxSpan) {
maxSpan = ySpan;
diameter1 = yMin;
diameter2 = yMax;
}
if (zSpan > maxSpan) {
maxSpan = zSpan;
diameter1 = zMin;
diameter2 = zMax;
}
const ritterCenter = fromPointsRitterCenter;
ritterCenter.x = (diameter1.x + diameter2.x) * 0.5;
ritterCenter.y = (diameter1.y + diameter2.y) * 0.5;
ritterCenter.z = (diameter1.z + diameter2.z) * 0.5;
let radiusSquared = Cartesian3_default.magnitudeSquared(
Cartesian3_default.subtract(diameter2, ritterCenter, fromPointsScratch)
);
let ritterRadius = Math.sqrt(radiusSquared);
const minBoxPt = fromPointsMinBoxPt;
minBoxPt.x = xMin.x;
minBoxPt.y = yMin.y;
minBoxPt.z = zMin.z;
const maxBoxPt = fromPointsMaxBoxPt;
maxBoxPt.x = xMax.x;
maxBoxPt.y = yMax.y;
maxBoxPt.z = zMax.z;
const naiveCenter = Cartesian3_default.midpoint(
minBoxPt,
maxBoxPt,
fromPointsNaiveCenterScratch
);
let naiveRadius = 0;
for (i = 0; i < numElements; i += 3) {
currentPos.x = positionsHigh[i] + positionsLow[i];
currentPos.y = positionsHigh[i + 1] + positionsLow[i + 1];
currentPos.z = positionsHigh[i + 2] + positionsLow[i + 2];
const r = Cartesian3_default.magnitude(
Cartesian3_default.subtract(currentPos, naiveCenter, fromPointsScratch)
);
if (r > naiveRadius) {
naiveRadius = r;
}
const oldCenterToPointSquared = Cartesian3_default.magnitudeSquared(
Cartesian3_default.subtract(currentPos, ritterCenter, fromPointsScratch)
);
if (oldCenterToPointSquared > radiusSquared) {
const oldCenterToPoint = Math.sqrt(oldCenterToPointSquared);
ritterRadius = (ritterRadius + oldCenterToPoint) * 0.5;
radiusSquared = ritterRadius * ritterRadius;
const oldToNew = oldCenterToPoint - ritterRadius;
ritterCenter.x = (ritterRadius * ritterCenter.x + oldToNew * currentPos.x) / oldCenterToPoint;
ritterCenter.y = (ritterRadius * ritterCenter.y + oldToNew * currentPos.y) / oldCenterToPoint;
ritterCenter.z = (ritterRadius * ritterCenter.z + oldToNew * currentPos.z) / oldCenterToPoint;
}
}
if (ritterRadius < naiveRadius) {
Cartesian3_default.clone(ritterCenter, result.center);
result.radius = ritterRadius;
} else {
Cartesian3_default.clone(naiveCenter, result.center);
result.radius = naiveRadius;
}
return result;
};
BoundingSphere.fromCornerPoints = function(corner, oppositeCorner, result) {
Check_default.typeOf.object("corner", corner);
Check_default.typeOf.object("oppositeCorner", oppositeCorner);
if (!defined_default(result)) {
result = new BoundingSphere();
}
const center = Cartesian3_default.midpoint(corner, oppositeCorner, result.center);
result.radius = Cartesian3_default.distance(center, oppositeCorner);
return result;
};
BoundingSphere.fromEllipsoid = function(ellipsoid, result) {
Check_default.typeOf.object("ellipsoid", ellipsoid);
if (!defined_default(result)) {
result = new BoundingSphere();
}
Cartesian3_default.clone(Cartesian3_default.ZERO, result.center);
result.radius = ellipsoid.maximumRadius;
return result;
};
var fromBoundingSpheresScratch = new Cartesian3_default();
BoundingSphere.fromBoundingSpheres = function(boundingSpheres, result) {
if (!defined_default(result)) {
result = new BoundingSphere();
}
if (!defined_default(boundingSpheres) || boundingSpheres.length === 0) {
result.center = Cartesian3_default.clone(Cartesian3_default.ZERO, result.center);
result.radius = 0;
return result;
}
const length3 = boundingSpheres.length;
if (length3 === 1) {
return BoundingSphere.clone(boundingSpheres[0], result);
}
if (length3 === 2) {
return BoundingSphere.union(boundingSpheres[0], boundingSpheres[1], result);
}
const positions = [];
let i;
for (i = 0; i < length3; i++) {
positions.push(boundingSpheres[i].center);
}
result = BoundingSphere.fromPoints(positions, result);
const center = result.center;
let radius = result.radius;
for (i = 0; i < length3; i++) {
const tmp2 = boundingSpheres[i];
radius = Math.max(
radius,
Cartesian3_default.distance(center, tmp2.center, fromBoundingSpheresScratch) + tmp2.radius
);
}
result.radius = radius;
return result;
};
var fromOrientedBoundingBoxScratchU = new Cartesian3_default();
var fromOrientedBoundingBoxScratchV = new Cartesian3_default();
var fromOrientedBoundingBoxScratchW = new Cartesian3_default();
BoundingSphere.fromOrientedBoundingBox = function(orientedBoundingBox, result) {
Check_default.defined("orientedBoundingBox", orientedBoundingBox);
if (!defined_default(result)) {
result = new BoundingSphere();
}
const halfAxes = orientedBoundingBox.halfAxes;
const u3 = Matrix3_default.getColumn(halfAxes, 0, fromOrientedBoundingBoxScratchU);
const v7 = Matrix3_default.getColumn(halfAxes, 1, fromOrientedBoundingBoxScratchV);
const w = Matrix3_default.getColumn(halfAxes, 2, fromOrientedBoundingBoxScratchW);
Cartesian3_default.add(u3, v7, u3);
Cartesian3_default.add(u3, w, u3);
result.center = Cartesian3_default.clone(orientedBoundingBox.center, result.center);
result.radius = Cartesian3_default.magnitude(u3);
return result;
};
var scratchFromTransformationCenter = new Cartesian3_default();
var scratchFromTransformationScale = new Cartesian3_default();
BoundingSphere.fromTransformation = function(transformation, result) {
Check_default.typeOf.object("transformation", transformation);
if (!defined_default(result)) {
result = new BoundingSphere();
}
const center = Matrix4_default.getTranslation(
transformation,
scratchFromTransformationCenter
);
const scale = Matrix4_default.getScale(
transformation,
scratchFromTransformationScale
);
const radius = 0.5 * Cartesian3_default.magnitude(scale);
result.center = Cartesian3_default.clone(center, result.center);
result.radius = radius;
return result;
};
BoundingSphere.clone = function(sphere, result) {
if (!defined_default(sphere)) {
return void 0;
}
if (!defined_default(result)) {
return new BoundingSphere(sphere.center, sphere.radius);
}
result.center = Cartesian3_default.clone(sphere.center, result.center);
result.radius = sphere.radius;
return result;
};
BoundingSphere.packedLength = 4;
BoundingSphere.pack = function(value, array, startingIndex) {
Check_default.typeOf.object("value", value);
Check_default.defined("array", array);
startingIndex = defaultValue_default(startingIndex, 0);
const center = value.center;
array[startingIndex++] = center.x;
array[startingIndex++] = center.y;
array[startingIndex++] = center.z;
array[startingIndex] = value.radius;
return array;
};
BoundingSphere.unpack = function(array, startingIndex, result) {
Check_default.defined("array", array);
startingIndex = defaultValue_default(startingIndex, 0);
if (!defined_default(result)) {
result = new BoundingSphere();
}
const center = result.center;
center.x = array[startingIndex++];
center.y = array[startingIndex++];
center.z = array[startingIndex++];
result.radius = array[startingIndex];
return result;
};
var unionScratch = new Cartesian3_default();
var unionScratchCenter = new Cartesian3_default();
BoundingSphere.union = function(left, right, result) {
Check_default.typeOf.object("left", left);
Check_default.typeOf.object("right", right);
if (!defined_default(result)) {
result = new BoundingSphere();
}
const leftCenter = left.center;
const leftRadius = left.radius;
const rightCenter = right.center;
const rightRadius = right.radius;
const toRightCenter = Cartesian3_default.subtract(
rightCenter,
leftCenter,
unionScratch
);
const centerSeparation = Cartesian3_default.magnitude(toRightCenter);
if (leftRadius >= centerSeparation + rightRadius) {
left.clone(result);
return result;
}
if (rightRadius >= centerSeparation + leftRadius) {
right.clone(result);
return result;
}
const halfDistanceBetweenTangentPoints = (leftRadius + centerSeparation + rightRadius) * 0.5;
const center = Cartesian3_default.multiplyByScalar(
toRightCenter,
(-leftRadius + halfDistanceBetweenTangentPoints) / centerSeparation,
unionScratchCenter
);
Cartesian3_default.add(center, leftCenter, center);
Cartesian3_default.clone(center, result.center);
result.radius = halfDistanceBetweenTangentPoints;
return result;
};
var expandScratch = new Cartesian3_default();
BoundingSphere.expand = function(sphere, point, result) {
Check_default.typeOf.object("sphere", sphere);
Check_default.typeOf.object("point", point);
result = BoundingSphere.clone(sphere, result);
const radius = Cartesian3_default.magnitude(
Cartesian3_default.subtract(point, result.center, expandScratch)
);
if (radius > result.radius) {
result.radius = radius;
}
return result;
};
BoundingSphere.intersectPlane = function(sphere, plane) {
Check_default.typeOf.object("sphere", sphere);
Check_default.typeOf.object("plane", plane);
const center = sphere.center;
const radius = sphere.radius;
const normal2 = plane.normal;
const distanceToPlane = Cartesian3_default.dot(normal2, center) + plane.distance;
if (distanceToPlane < -radius) {
return Intersect_default.OUTSIDE;
} else if (distanceToPlane < radius) {
return Intersect_default.INTERSECTING;
}
return Intersect_default.INSIDE;
};
BoundingSphere.transform = function(sphere, transform3, result) {
Check_default.typeOf.object("sphere", sphere);
Check_default.typeOf.object("transform", transform3);
if (!defined_default(result)) {
result = new BoundingSphere();
}
result.center = Matrix4_default.multiplyByPoint(
transform3,
sphere.center,
result.center
);
result.radius = Matrix4_default.getMaximumScale(transform3) * sphere.radius;
return result;
};
var distanceSquaredToScratch = new Cartesian3_default();
BoundingSphere.distanceSquaredTo = function(sphere, cartesian11) {
Check_default.typeOf.object("sphere", sphere);
Check_default.typeOf.object("cartesian", cartesian11);
const diff = Cartesian3_default.subtract(
sphere.center,
cartesian11,
distanceSquaredToScratch
);
const distance2 = Cartesian3_default.magnitude(diff) - sphere.radius;
if (distance2 <= 0) {
return 0;
}
return distance2 * distance2;
};
BoundingSphere.transformWithoutScale = function(sphere, transform3, result) {
Check_default.typeOf.object("sphere", sphere);
Check_default.typeOf.object("transform", transform3);
if (!defined_default(result)) {
result = new BoundingSphere();
}
result.center = Matrix4_default.multiplyByPoint(
transform3,
sphere.center,
result.center
);
result.radius = sphere.radius;
return result;
};
var scratchCartesian3 = new Cartesian3_default();
BoundingSphere.computePlaneDistances = function(sphere, position, direction2, result) {
Check_default.typeOf.object("sphere", sphere);
Check_default.typeOf.object("position", position);
Check_default.typeOf.object("direction", direction2);
if (!defined_default(result)) {
result = new Interval_default();
}
const toCenter = Cartesian3_default.subtract(
sphere.center,
position,
scratchCartesian3
);
const mag = Cartesian3_default.dot(direction2, toCenter);
result.start = mag - sphere.radius;
result.stop = mag + sphere.radius;
return result;
};
var projectTo2DNormalScratch = new Cartesian3_default();
var projectTo2DEastScratch = new Cartesian3_default();
var projectTo2DNorthScratch = new Cartesian3_default();
var projectTo2DWestScratch = new Cartesian3_default();
var projectTo2DSouthScratch = new Cartesian3_default();
var projectTo2DCartographicScratch = new Cartographic_default();
var projectTo2DPositionsScratch = new Array(8);
for (let n = 0; n < 8; ++n) {
projectTo2DPositionsScratch[n] = new Cartesian3_default();
}
var projectTo2DProjection = new GeographicProjection_default();
BoundingSphere.projectTo2D = function(sphere, projection, result) {
Check_default.typeOf.object("sphere", sphere);
projection = defaultValue_default(projection, projectTo2DProjection);
const ellipsoid = projection.ellipsoid;
let center = sphere.center;
const radius = sphere.radius;
let normal2;
if (Cartesian3_default.equals(center, Cartesian3_default.ZERO)) {
normal2 = Cartesian3_default.clone(Cartesian3_default.UNIT_X, projectTo2DNormalScratch);
} else {
normal2 = ellipsoid.geodeticSurfaceNormal(center, projectTo2DNormalScratch);
}
const east = Cartesian3_default.cross(
Cartesian3_default.UNIT_Z,
normal2,
projectTo2DEastScratch
);
Cartesian3_default.normalize(east, east);
const north = Cartesian3_default.cross(normal2, east, projectTo2DNorthScratch);
Cartesian3_default.normalize(north, north);
Cartesian3_default.multiplyByScalar(normal2, radius, normal2);
Cartesian3_default.multiplyByScalar(north, radius, north);
Cartesian3_default.multiplyByScalar(east, radius, east);
const south = Cartesian3_default.negate(north, projectTo2DSouthScratch);
const west = Cartesian3_default.negate(east, projectTo2DWestScratch);
const positions = projectTo2DPositionsScratch;
let corner = positions[0];
Cartesian3_default.add(normal2, north, corner);
Cartesian3_default.add(corner, east, corner);
corner = positions[1];
Cartesian3_default.add(normal2, north, corner);
Cartesian3_default.add(corner, west, corner);
corner = positions[2];
Cartesian3_default.add(normal2, south, corner);
Cartesian3_default.add(corner, west, corner);
corner = positions[3];
Cartesian3_default.add(normal2, south, corner);
Cartesian3_default.add(corner, east, corner);
Cartesian3_default.negate(normal2, normal2);
corner = positions[4];
Cartesian3_default.add(normal2, north, corner);
Cartesian3_default.add(corner, east, corner);
corner = positions[5];
Cartesian3_default.add(normal2, north, corner);
Cartesian3_default.add(corner, west, corner);
corner = positions[6];
Cartesian3_default.add(normal2, south, corner);
Cartesian3_default.add(corner, west, corner);
corner = positions[7];
Cartesian3_default.add(normal2, south, corner);
Cartesian3_default.add(corner, east, corner);
const length3 = positions.length;
for (let i = 0; i < length3; ++i) {
const position = positions[i];
Cartesian3_default.add(center, position, position);
const cartographic2 = ellipsoid.cartesianToCartographic(
position,
projectTo2DCartographicScratch
);
projection.project(cartographic2, position);
}
result = BoundingSphere.fromPoints(positions, result);
center = result.center;
const x = center.x;
const y = center.y;
const z = center.z;
center.x = z;
center.y = x;
center.z = y;
return result;
};
BoundingSphere.isOccluded = function(sphere, occluder) {
Check_default.typeOf.object("sphere", sphere);
Check_default.typeOf.object("occluder", occluder);
return !occluder.isBoundingSphereVisible(sphere);
};
BoundingSphere.equals = function(left, right) {
return left === right || defined_default(left) && defined_default(right) && Cartesian3_default.equals(left.center, right.center) && left.radius === right.radius;
};
BoundingSphere.prototype.intersectPlane = function(plane) {
return BoundingSphere.intersectPlane(this, plane);
};
BoundingSphere.prototype.distanceSquaredTo = function(cartesian11) {
return BoundingSphere.distanceSquaredTo(this, cartesian11);
};
BoundingSphere.prototype.computePlaneDistances = function(position, direction2, result) {
return BoundingSphere.computePlaneDistances(
this,
position,
direction2,
result
);
};
BoundingSphere.prototype.isOccluded = function(occluder) {
return BoundingSphere.isOccluded(this, occluder);
};
BoundingSphere.prototype.equals = function(right) {
return BoundingSphere.equals(this, right);
};
BoundingSphere.prototype.clone = function(result) {
return BoundingSphere.clone(this, result);
};
BoundingSphere.prototype.volume = function() {
const radius = this.radius;
return volumeConstant * radius * radius * radius;
};
var BoundingSphere_default = BoundingSphere;
// Source/ThirdParty/Uri.js
var import_urijs = __toESM(require_URI(), 1);
// Source/Core/getAbsoluteUri.js
function getAbsoluteUri(relative, base) {
let documentObject;
if (typeof document !== "undefined") {
documentObject = document;
}
return getAbsoluteUri._implementation(relative, base, documentObject);
}
getAbsoluteUri._implementation = function(relative, base, documentObject) {
if (!defined_default(relative)) {
throw new DeveloperError_default("relative uri is required.");
}
if (!defined_default(base)) {
if (typeof documentObject === "undefined") {
return relative;
}
base = defaultValue_default(documentObject.baseURI, documentObject.location.href);
}
const relativeUri = new import_urijs.default(relative);
if (relativeUri.scheme() !== "") {
return relativeUri.toString();
}
return relativeUri.absoluteTo(base).toString();
};
var getAbsoluteUri_default = getAbsoluteUri;
// Source/Core/clone.js
function clone(object, deep) {
if (object === null || typeof object !== "object") {
return object;
}
deep = defaultValue_default(deep, false);
const result = new object.constructor();
for (const propertyName in object) {
if (object.hasOwnProperty(propertyName)) {
let value = object[propertyName];
if (deep) {
value = clone(value, deep);
}
result[propertyName] = value;
}
}
return result;
}
var clone_default = clone;
// Source/Core/combine.js
function combine(object1, object2, deep) {
deep = defaultValue_default(deep, false);
const result = {};
const object1Defined = defined_default(object1);
const object2Defined = defined_default(object2);
let property;
let object1Value;
let object2Value;
if (object1Defined) {
for (property in object1) {
if (object1.hasOwnProperty(property)) {
object1Value = object1[property];
if (object2Defined && deep && typeof object1Value === "object" && object2.hasOwnProperty(property)) {
object2Value = object2[property];
if (typeof object2Value === "object") {
result[property] = combine(object1Value, object2Value, deep);
} else {
result[property] = object1Value;
}
} else {
result[property] = object1Value;
}
}
}
}
if (object2Defined) {
for (property in object2) {
if (object2.hasOwnProperty(property) && !result.hasOwnProperty(property)) {
object2Value = object2[property];
result[property] = object2Value;
}
}
}
return result;
}
var combine_default = combine;
// Source/Core/defer.js
function defer() {
let resolve2;
let reject;
const promise = new Promise(function(res, rej) {
resolve2 = res;
reject = rej;
});
return {
resolve: resolve2,
reject,
promise
};
}
var defer_default = defer;
// Source/Core/getBaseUri.js
function getBaseUri(uri, includeQuery) {
if (!defined_default(uri)) {
throw new DeveloperError_default("uri is required.");
}
let basePath = "";
const i = uri.lastIndexOf("/");
if (i !== -1) {
basePath = uri.substring(0, i + 1);
}
if (!includeQuery) {
return basePath;
}
uri = new import_urijs.default(uri);
if (uri.query().length !== 0) {
basePath += `?${uri.query()}`;
}
if (uri.fragment().length !== 0) {
basePath += `#${uri.fragment()}`;
}
return basePath;
}
var getBaseUri_default = getBaseUri;
// Source/Core/getExtensionFromUri.js
function getExtensionFromUri(uri) {
if (!defined_default(uri)) {
throw new DeveloperError_default("uri is required.");
}
const uriObject = new import_urijs.default(uri);
uriObject.normalize();
let path = uriObject.path();
let index = path.lastIndexOf("/");
if (index !== -1) {
path = path.substr(index + 1);
}
index = path.lastIndexOf(".");
if (index === -1) {
path = "";
} else {
path = path.substr(index + 1);
}
return path;
}
var getExtensionFromUri_default = getExtensionFromUri;
// Source/Core/getImagePixels.js
var context2DsByWidthAndHeight = {};
function getImagePixels(image, width, height) {
if (!defined_default(width)) {
width = image.width;
}
if (!defined_default(height)) {
height = image.height;
}
let context2DsByHeight = context2DsByWidthAndHeight[width];
if (!defined_default(context2DsByHeight)) {
context2DsByHeight = {};
context2DsByWidthAndHeight[width] = context2DsByHeight;
}
let context2d = context2DsByHeight[height];
if (!defined_default(context2d)) {
const canvas = document.createElement("canvas");
canvas.width = width;
canvas.height = height;
context2d = canvas.getContext("2d");
context2d.globalCompositeOperation = "copy";
context2DsByHeight[height] = context2d;
}
context2d.drawImage(image, 0, 0, width, height);
return context2d.getImageData(0, 0, width, height).data;
}
var getImagePixels_default = getImagePixels;
// Source/Core/isBlobUri.js
var blobUriRegex = /^blob:/i;
function isBlobUri(uri) {
Check_default.typeOf.string("uri", uri);
return blobUriRegex.test(uri);
}
var isBlobUri_default = isBlobUri;
// Source/Core/isCrossOriginUrl.js
var a;
function isCrossOriginUrl(url2) {
if (!defined_default(a)) {
a = document.createElement("a");
}
a.href = window.location.href;
const host = a.host;
const protocol = a.protocol;
a.href = url2;
a.href = a.href;
return protocol !== a.protocol || host !== a.host;
}
var isCrossOriginUrl_default = isCrossOriginUrl;
// Source/Core/isDataUri.js
var dataUriRegex = /^data:/i;
function isDataUri(uri) {
Check_default.typeOf.string("uri", uri);
return dataUriRegex.test(uri);
}
var isDataUri_default = isDataUri;
// Source/Core/loadAndExecuteScript.js
function loadAndExecuteScript(url2) {
const script = document.createElement("script");
script.async = true;
script.src = url2;
return new Promise((resolve2, reject) => {
if (window.crossOriginIsolated) {
script.setAttribute("crossorigin", "anonymous");
}
const head = document.getElementsByTagName("head")[0];
script.onload = function() {
script.onload = void 0;
head.removeChild(script);
resolve2();
};
script.onerror = function(e) {
reject(e);
};
head.appendChild(script);
});
}
var loadAndExecuteScript_default = loadAndExecuteScript;
// Source/Core/objectToQuery.js
function objectToQuery(obj) {
if (!defined_default(obj)) {
throw new DeveloperError_default("obj is required.");
}
let result = "";
for (const propName in obj) {
if (obj.hasOwnProperty(propName)) {
const value = obj[propName];
const part = `${encodeURIComponent(propName)}=`;
if (Array.isArray(value)) {
for (let i = 0, len = value.length; i < len; ++i) {
result += `${part + encodeURIComponent(value[i])}&`;
}
} else {
result += `${part + encodeURIComponent(value)}&`;
}
}
}
result = result.slice(0, -1);
return result;
}
var objectToQuery_default = objectToQuery;
// Source/Core/queryToObject.js
function queryToObject(queryString) {
if (!defined_default(queryString)) {
throw new DeveloperError_default("queryString is required.");
}
const result = {};
if (queryString === "") {
return result;
}
const parts = queryString.replace(/\+/g, "%20").split(/[&;]/);
for (let i = 0, len = parts.length; i < len; ++i) {
const subparts = parts[i].split("=");
const name = decodeURIComponent(subparts[0]);
let value = subparts[1];
if (defined_default(value)) {
value = decodeURIComponent(value);
} else {
value = "";
}
const resultValue = result[name];
if (typeof resultValue === "string") {
result[name] = [resultValue, value];
} else if (Array.isArray(resultValue)) {
resultValue.push(value);
} else {
result[name] = value;
}
}
return result;
}
var queryToObject_default = queryToObject;
// Source/Core/RequestState.js
var RequestState = {
UNISSUED: 0,
ISSUED: 1,
ACTIVE: 2,
RECEIVED: 3,
CANCELLED: 4,
FAILED: 5
};
var RequestState_default = Object.freeze(RequestState);
// Source/Core/RequestType.js
var RequestType = {
TERRAIN: 0,
IMAGERY: 1,
TILES3D: 2,
OTHER: 3
};
var RequestType_default = Object.freeze(RequestType);
// Source/Core/Request.js
function Request(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
const throttleByServer = defaultValue_default(options.throttleByServer, false);
const throttle = defaultValue_default(options.throttle, false);
this.url = options.url;
this.requestFunction = options.requestFunction;
this.cancelFunction = options.cancelFunction;
this.priorityFunction = options.priorityFunction;
this.priority = defaultValue_default(options.priority, 0);
this.throttle = throttle;
this.throttleByServer = throttleByServer;
this.type = defaultValue_default(options.type, RequestType_default.OTHER);
this.serverKey = void 0;
this.state = RequestState_default.UNISSUED;
this.deferred = void 0;
this.cancelled = false;
}
Request.prototype.cancel = function() {
this.cancelled = true;
};
Request.prototype.clone = function(result) {
if (!defined_default(result)) {
return new Request(this);
}
result.url = this.url;
result.requestFunction = this.requestFunction;
result.cancelFunction = this.cancelFunction;
result.priorityFunction = this.priorityFunction;
result.priority = this.priority;
result.throttle = this.throttle;
result.throttleByServer = this.throttleByServer;
result.type = this.type;
result.serverKey = this.serverKey;
result.state = this.RequestState.UNISSUED;
result.deferred = void 0;
result.cancelled = false;
return result;
};
var Request_default = Request;
// Source/Core/parseResponseHeaders.js
function parseResponseHeaders(headerString) {
const headers = {};
if (!headerString) {
return headers;
}
const headerPairs = headerString.split("\r\n");
for (let i = 0; i < headerPairs.length; ++i) {
const headerPair = headerPairs[i];
const index = headerPair.indexOf(": ");
if (index > 0) {
const key = headerPair.substring(0, index);
const val = headerPair.substring(index + 2);
headers[key] = val;
}
}
return headers;
}
var parseResponseHeaders_default = parseResponseHeaders;
// Source/Core/RequestErrorEvent.js
function RequestErrorEvent(statusCode, response, responseHeaders) {
this.statusCode = statusCode;
this.response = response;
this.responseHeaders = responseHeaders;
if (typeof this.responseHeaders === "string") {
this.responseHeaders = parseResponseHeaders_default(this.responseHeaders);
}
}
RequestErrorEvent.prototype.toString = function() {
let str = "Request has failed.";
if (defined_default(this.statusCode)) {
str += ` Status Code: ${this.statusCode}`;
}
return str;
};
var RequestErrorEvent_default = RequestErrorEvent;
// Source/Core/Event.js
function Event() {
this._listeners = [];
this._scopes = [];
this._toRemove = [];
this._insideRaiseEvent = false;
}
Object.defineProperties(Event.prototype, {
numberOfListeners: {
get: function() {
return this._listeners.length - this._toRemove.length;
}
}
});
Event.prototype.addEventListener = function(listener, scope) {
Check_default.typeOf.func("listener", listener);
this._listeners.push(listener);
this._scopes.push(scope);
const event = this;
return function() {
event.removeEventListener(listener, scope);
};
};
Event.prototype.removeEventListener = function(listener, scope) {
Check_default.typeOf.func("listener", listener);
const listeners = this._listeners;
const scopes = this._scopes;
let index = -1;
for (let i = 0; i < listeners.length; i++) {
if (listeners[i] === listener && scopes[i] === scope) {
index = i;
break;
}
}
if (index !== -1) {
if (this._insideRaiseEvent) {
this._toRemove.push(index);
listeners[index] = void 0;
scopes[index] = void 0;
} else {
listeners.splice(index, 1);
scopes.splice(index, 1);
}
return true;
}
return false;
};
function compareNumber(a3, b) {
return b - a3;
}
Event.prototype.raiseEvent = function() {
this._insideRaiseEvent = true;
let i;
const listeners = this._listeners;
const scopes = this._scopes;
let length3 = listeners.length;
for (i = 0; i < length3; i++) {
const listener = listeners[i];
if (defined_default(listener)) {
listeners[i].apply(scopes[i], arguments);
}
}
const toRemove = this._toRemove;
length3 = toRemove.length;
if (length3 > 0) {
toRemove.sort(compareNumber);
for (i = 0; i < length3; i++) {
const index = toRemove[i];
listeners.splice(index, 1);
scopes.splice(index, 1);
}
toRemove.length = 0;
}
this._insideRaiseEvent = false;
};
var Event_default = Event;
// Source/Core/Heap.js
function Heap(options) {
Check_default.typeOf.object("options", options);
Check_default.defined("options.comparator", options.comparator);
this._comparator = options.comparator;
this._array = [];
this._length = 0;
this._maximumLength = void 0;
}
Object.defineProperties(Heap.prototype, {
length: {
get: function() {
return this._length;
}
},
internalArray: {
get: function() {
return this._array;
}
},
maximumLength: {
get: function() {
return this._maximumLength;
},
set: function(value) {
Check_default.typeOf.number.greaterThanOrEquals("maximumLength", value, 0);
const originalLength = this._length;
if (value < originalLength) {
const array = this._array;
for (let i = value; i < originalLength; ++i) {
array[i] = void 0;
}
this._length = value;
array.length = value;
}
this._maximumLength = value;
}
},
comparator: {
get: function() {
return this._comparator;
}
}
});
function swap(array, a3, b) {
const temp = array[a3];
array[a3] = array[b];
array[b] = temp;
}
Heap.prototype.reserve = function(length3) {
length3 = defaultValue_default(length3, this._length);
this._array.length = length3;
};
Heap.prototype.heapify = function(index) {
index = defaultValue_default(index, 0);
const length3 = this._length;
const comparator = this._comparator;
const array = this._array;
let candidate = -1;
let inserting = true;
while (inserting) {
const right = 2 * (index + 1);
const left = right - 1;
if (left < length3 && comparator(array[left], array[index]) < 0) {
candidate = left;
} else {
candidate = index;
}
if (right < length3 && comparator(array[right], array[candidate]) < 0) {
candidate = right;
}
if (candidate !== index) {
swap(array, candidate, index);
index = candidate;
} else {
inserting = false;
}
}
};
Heap.prototype.resort = function() {
const length3 = this._length;
for (let i = Math.ceil(length3 / 2); i >= 0; --i) {
this.heapify(i);
}
};
Heap.prototype.insert = function(element) {
Check_default.defined("element", element);
const array = this._array;
const comparator = this._comparator;
const maximumLength = this._maximumLength;
let index = this._length++;
if (index < array.length) {
array[index] = element;
} else {
array.push(element);
}
while (index !== 0) {
const parent = Math.floor((index - 1) / 2);
if (comparator(array[index], array[parent]) < 0) {
swap(array, index, parent);
index = parent;
} else {
break;
}
}
let removedElement;
if (defined_default(maximumLength) && this._length > maximumLength) {
removedElement = array[maximumLength];
this._length = maximumLength;
}
return removedElement;
};
Heap.prototype.pop = function(index) {
index = defaultValue_default(index, 0);
if (this._length === 0) {
return void 0;
}
Check_default.typeOf.number.lessThan("index", index, this._length);
const array = this._array;
const root = array[index];
swap(array, index, --this._length);
this.heapify(index);
array[this._length] = void 0;
return root;
};
var Heap_default = Heap;
// Source/Core/RequestScheduler.js
function sortRequests(a3, b) {
return a3.priority - b.priority;
}
var statistics = {
numberOfAttemptedRequests: 0,
numberOfActiveRequests: 0,
numberOfCancelledRequests: 0,
numberOfCancelledActiveRequests: 0,
numberOfFailedRequests: 0,
numberOfActiveRequestsEver: 0,
lastNumberOfActiveRequests: 0
};
var priorityHeapLength = 20;
var requestHeap = new Heap_default({
comparator: sortRequests
});
requestHeap.maximumLength = priorityHeapLength;
requestHeap.reserve(priorityHeapLength);
var activeRequests = [];
var numberOfActiveRequestsByServer = {};
var pageUri = typeof document !== "undefined" ? new import_urijs.default(document.location.href) : new import_urijs.default();
var requestCompletedEvent = new Event_default();
function RequestScheduler() {
}
RequestScheduler.maximumRequests = 50;
RequestScheduler.maximumRequestsPerServer = 6;
RequestScheduler.requestsByServer = {
"api.cesium.com:443": 18,
"assets.cesium.com:443": 18
};
RequestScheduler.throttleRequests = true;
RequestScheduler.debugShowStatistics = false;
RequestScheduler.requestCompletedEvent = requestCompletedEvent;
Object.defineProperties(RequestScheduler, {
statistics: {
get: function() {
return statistics;
}
},
priorityHeapLength: {
get: function() {
return priorityHeapLength;
},
set: function(value) {
if (value < priorityHeapLength) {
while (requestHeap.length > value) {
const request = requestHeap.pop();
cancelRequest(request);
}
}
priorityHeapLength = value;
requestHeap.maximumLength = value;
requestHeap.reserve(value);
}
}
});
function updatePriority(request) {
if (defined_default(request.priorityFunction)) {
request.priority = request.priorityFunction();
}
}
RequestScheduler.serverHasOpenSlots = function(serverKey, desiredRequests) {
desiredRequests = defaultValue_default(desiredRequests, 1);
const maxRequests = defaultValue_default(
RequestScheduler.requestsByServer[serverKey],
RequestScheduler.maximumRequestsPerServer
);
const hasOpenSlotsServer = numberOfActiveRequestsByServer[serverKey] + desiredRequests <= maxRequests;
return hasOpenSlotsServer;
};
RequestScheduler.heapHasOpenSlots = function(desiredRequests) {
const hasOpenSlotsHeap = requestHeap.length + desiredRequests <= priorityHeapLength;
return hasOpenSlotsHeap;
};
function issueRequest(request) {
if (request.state === RequestState_default.UNISSUED) {
request.state = RequestState_default.ISSUED;
request.deferred = defer_default();
}
return request.deferred.promise;
}
function getRequestReceivedFunction(request) {
return function(results) {
if (request.state === RequestState_default.CANCELLED) {
return;
}
const deferred = request.deferred;
--statistics.numberOfActiveRequests;
--numberOfActiveRequestsByServer[request.serverKey];
requestCompletedEvent.raiseEvent();
request.state = RequestState_default.RECEIVED;
request.deferred = void 0;
deferred.resolve(results);
};
}
function getRequestFailedFunction(request) {
return function(error) {
if (request.state === RequestState_default.CANCELLED) {
return;
}
++statistics.numberOfFailedRequests;
--statistics.numberOfActiveRequests;
--numberOfActiveRequestsByServer[request.serverKey];
requestCompletedEvent.raiseEvent(error);
request.state = RequestState_default.FAILED;
request.deferred.reject(error);
};
}
function startRequest(request) {
const promise = issueRequest(request);
request.state = RequestState_default.ACTIVE;
activeRequests.push(request);
++statistics.numberOfActiveRequests;
++statistics.numberOfActiveRequestsEver;
++numberOfActiveRequestsByServer[request.serverKey];
request.requestFunction().then(getRequestReceivedFunction(request)).catch(getRequestFailedFunction(request));
return promise;
}
function cancelRequest(request) {
const active = request.state === RequestState_default.ACTIVE;
request.state = RequestState_default.CANCELLED;
++statistics.numberOfCancelledRequests;
if (defined_default(request.deferred)) {
const deferred = request.deferred;
request.deferred = void 0;
deferred.reject();
}
if (active) {
--statistics.numberOfActiveRequests;
--numberOfActiveRequestsByServer[request.serverKey];
++statistics.numberOfCancelledActiveRequests;
}
if (defined_default(request.cancelFunction)) {
request.cancelFunction();
}
}
RequestScheduler.update = function() {
let i;
let request;
let removeCount = 0;
const activeLength = activeRequests.length;
for (i = 0; i < activeLength; ++i) {
request = activeRequests[i];
if (request.cancelled) {
cancelRequest(request);
}
if (request.state !== RequestState_default.ACTIVE) {
++removeCount;
continue;
}
if (removeCount > 0) {
activeRequests[i - removeCount] = request;
}
}
activeRequests.length -= removeCount;
const issuedRequests = requestHeap.internalArray;
const issuedLength = requestHeap.length;
for (i = 0; i < issuedLength; ++i) {
updatePriority(issuedRequests[i]);
}
requestHeap.resort();
const openSlots = Math.max(
RequestScheduler.maximumRequests - activeRequests.length,
0
);
let filledSlots = 0;
while (filledSlots < openSlots && requestHeap.length > 0) {
request = requestHeap.pop();
if (request.cancelled) {
cancelRequest(request);
continue;
}
if (request.throttleByServer && !RequestScheduler.serverHasOpenSlots(request.serverKey)) {
cancelRequest(request);
continue;
}
startRequest(request);
++filledSlots;
}
updateStatistics();
};
RequestScheduler.getServerKey = function(url2) {
Check_default.typeOf.string("url", url2);
let uri = new import_urijs.default(url2);
if (uri.scheme() === "") {
uri = new import_urijs.default(url2).absoluteTo(pageUri);
uri.normalize();
}
let serverKey = uri.authority();
if (!/:/.test(serverKey)) {
serverKey = `${serverKey}:${uri.scheme() === "https" ? "443" : "80"}`;
}
const length3 = numberOfActiveRequestsByServer[serverKey];
if (!defined_default(length3)) {
numberOfActiveRequestsByServer[serverKey] = 0;
}
return serverKey;
};
RequestScheduler.request = function(request) {
Check_default.typeOf.object("request", request);
Check_default.typeOf.string("request.url", request.url);
Check_default.typeOf.func("request.requestFunction", request.requestFunction);
if (isDataUri_default(request.url) || isBlobUri_default(request.url)) {
requestCompletedEvent.raiseEvent();
request.state = RequestState_default.RECEIVED;
return request.requestFunction();
}
++statistics.numberOfAttemptedRequests;
if (!defined_default(request.serverKey)) {
request.serverKey = RequestScheduler.getServerKey(request.url);
}
if (RequestScheduler.throttleRequests && request.throttleByServer && !RequestScheduler.serverHasOpenSlots(request.serverKey)) {
return void 0;
}
if (!RequestScheduler.throttleRequests || !request.throttle) {
return startRequest(request);
}
if (activeRequests.length >= RequestScheduler.maximumRequests) {
return void 0;
}
updatePriority(request);
const removedRequest = requestHeap.insert(request);
if (defined_default(removedRequest)) {
if (removedRequest === request) {
return void 0;
}
cancelRequest(removedRequest);
}
return issueRequest(request);
};
function updateStatistics() {
if (!RequestScheduler.debugShowStatistics) {
return;
}
if (statistics.numberOfActiveRequests === 0 && statistics.lastNumberOfActiveRequests > 0) {
if (statistics.numberOfAttemptedRequests > 0) {
console.log(
`Number of attempted requests: ${statistics.numberOfAttemptedRequests}`
);
statistics.numberOfAttemptedRequests = 0;
}
if (statistics.numberOfCancelledRequests > 0) {
console.log(
`Number of cancelled requests: ${statistics.numberOfCancelledRequests}`
);
statistics.numberOfCancelledRequests = 0;
}
if (statistics.numberOfCancelledActiveRequests > 0) {
console.log(
`Number of cancelled active requests: ${statistics.numberOfCancelledActiveRequests}`
);
statistics.numberOfCancelledActiveRequests = 0;
}
if (statistics.numberOfFailedRequests > 0) {
console.log(
`Number of failed requests: ${statistics.numberOfFailedRequests}`
);
statistics.numberOfFailedRequests = 0;
}
}
statistics.lastNumberOfActiveRequests = statistics.numberOfActiveRequests;
}
RequestScheduler.clearForSpecs = function() {
while (requestHeap.length > 0) {
const request = requestHeap.pop();
cancelRequest(request);
}
const length3 = activeRequests.length;
for (let i = 0; i < length3; ++i) {
cancelRequest(activeRequests[i]);
}
activeRequests.length = 0;
numberOfActiveRequestsByServer = {};
statistics.numberOfAttemptedRequests = 0;
statistics.numberOfActiveRequests = 0;
statistics.numberOfCancelledRequests = 0;
statistics.numberOfCancelledActiveRequests = 0;
statistics.numberOfFailedRequests = 0;
statistics.numberOfActiveRequestsEver = 0;
statistics.lastNumberOfActiveRequests = 0;
};
RequestScheduler.numberOfActiveRequestsByServer = function(serverKey) {
return numberOfActiveRequestsByServer[serverKey];
};
RequestScheduler.requestHeap = requestHeap;
var RequestScheduler_default = RequestScheduler;
// Source/Core/TrustedServers.js
var TrustedServers = {};
var _servers = {};
TrustedServers.add = function(host, port) {
if (!defined_default(host)) {
throw new DeveloperError_default("host is required.");
}
if (!defined_default(port) || port <= 0) {
throw new DeveloperError_default("port is required to be greater than 0.");
}
const authority = `${host.toLowerCase()}:${port}`;
if (!defined_default(_servers[authority])) {
_servers[authority] = true;
}
};
TrustedServers.remove = function(host, port) {
if (!defined_default(host)) {
throw new DeveloperError_default("host is required.");
}
if (!defined_default(port) || port <= 0) {
throw new DeveloperError_default("port is required to be greater than 0.");
}
const authority = `${host.toLowerCase()}:${port}`;
if (defined_default(_servers[authority])) {
delete _servers[authority];
}
};
function getAuthority(url2) {
const uri = new import_urijs.default(url2);
uri.normalize();
let authority = uri.authority();
if (authority.length === 0) {
return void 0;
}
uri.authority(authority);
if (authority.indexOf("@") !== -1) {
const parts = authority.split("@");
authority = parts[1];
}
if (authority.indexOf(":") === -1) {
let scheme = uri.scheme();
if (scheme.length === 0) {
scheme = window.location.protocol;
scheme = scheme.substring(0, scheme.length - 1);
}
if (scheme === "http") {
authority += ":80";
} else if (scheme === "https") {
authority += ":443";
} else {
return void 0;
}
}
return authority;
}
TrustedServers.contains = function(url2) {
if (!defined_default(url2)) {
throw new DeveloperError_default("url is required.");
}
const authority = getAuthority(url2);
if (defined_default(authority) && defined_default(_servers[authority])) {
return true;
}
return false;
};
TrustedServers.clear = function() {
_servers = {};
};
var TrustedServers_default = TrustedServers;
// Source/Core/Resource.js
var xhrBlobSupported = function() {
try {
const xhr = new XMLHttpRequest();
xhr.open("GET", "#", true);
xhr.responseType = "blob";
return xhr.responseType === "blob";
} catch (e) {
return false;
}
}();
function parseQuery(uri, resource, merge2, preserveQueryParameters) {
const queryString = uri.query();
if (queryString.length === 0) {
return {};
}
let query;
if (queryString.indexOf("=") === -1) {
const result = {};
result[queryString] = void 0;
query = result;
} else {
query = queryToObject_default(queryString);
}
if (merge2) {
resource._queryParameters = combineQueryParameters(
query,
resource._queryParameters,
preserveQueryParameters
);
} else {
resource._queryParameters = query;
}
uri.search("");
}
function stringifyQuery(uri, resource) {
const queryObject = resource._queryParameters;
const keys = Object.keys(queryObject);
if (keys.length === 1 && !defined_default(queryObject[keys[0]])) {
uri.search(keys[0]);
} else {
uri.search(objectToQuery_default(queryObject));
}
}
function defaultClone(val, defaultVal) {
if (!defined_default(val)) {
return defaultVal;
}
return defined_default(val.clone) ? val.clone() : clone_default(val);
}
function checkAndResetRequest(request) {
if (request.state === RequestState_default.ISSUED || request.state === RequestState_default.ACTIVE) {
throw new RuntimeError_default("The Resource is already being fetched.");
}
request.state = RequestState_default.UNISSUED;
request.deferred = void 0;
}
function combineQueryParameters(q12, q22, preserveQueryParameters) {
if (!preserveQueryParameters) {
return combine_default(q12, q22);
}
const result = clone_default(q12, true);
for (const param in q22) {
if (q22.hasOwnProperty(param)) {
let value = result[param];
const q2Value = q22[param];
if (defined_default(value)) {
if (!Array.isArray(value)) {
value = result[param] = [value];
}
result[param] = value.concat(q2Value);
} else {
result[param] = Array.isArray(q2Value) ? q2Value.slice() : q2Value;
}
}
}
return result;
}
function Resource(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
if (typeof options === "string") {
options = {
url: options
};
}
Check_default.typeOf.string("options.url", options.url);
this._url = void 0;
this._templateValues = defaultClone(options.templateValues, {});
this._queryParameters = defaultClone(options.queryParameters, {});
this.headers = defaultClone(options.headers, {});
this.request = defaultValue_default(options.request, new Request_default());
this.proxy = options.proxy;
this.retryCallback = options.retryCallback;
this.retryAttempts = defaultValue_default(options.retryAttempts, 0);
this._retryCount = 0;
const uri = new import_urijs.default(options.url);
parseQuery(uri, this, true, true);
uri.fragment("");
this._url = uri.toString();
}
Resource.createIfNeeded = function(resource) {
if (resource instanceof Resource) {
return resource.getDerivedResource({
request: resource.request
});
}
if (typeof resource !== "string") {
return resource;
}
return new Resource({
url: resource
});
};
var supportsImageBitmapOptionsPromise;
Resource.supportsImageBitmapOptions = function() {
if (defined_default(supportsImageBitmapOptionsPromise)) {
return supportsImageBitmapOptionsPromise;
}
if (typeof createImageBitmap !== "function") {
supportsImageBitmapOptionsPromise = Promise.resolve(false);
return supportsImageBitmapOptionsPromise;
}
const imageDataUri = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAABGdBTUEAAE4g3rEiDgAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAADElEQVQI12Ng6GAAAAEUAIngE3ZiAAAAAElFTkSuQmCC";
supportsImageBitmapOptionsPromise = Resource.fetchBlob({
url: imageDataUri
}).then(function(blob) {
const imageBitmapOptions = {
imageOrientation: "flipY",
premultiplyAlpha: "none",
colorSpaceConversion: "none"
};
return Promise.all([
createImageBitmap(blob, imageBitmapOptions),
createImageBitmap(blob)
]);
}).then(function(imageBitmaps) {
const colorWithOptions = getImagePixels_default(imageBitmaps[0]);
const colorWithDefaults = getImagePixels_default(imageBitmaps[1]);
return colorWithOptions[1] !== colorWithDefaults[1];
}).catch(function() {
return false;
});
return supportsImageBitmapOptionsPromise;
};
Object.defineProperties(Resource, {
isBlobSupported: {
get: function() {
return xhrBlobSupported;
}
}
});
Object.defineProperties(Resource.prototype, {
queryParameters: {
get: function() {
return this._queryParameters;
}
},
templateValues: {
get: function() {
return this._templateValues;
}
},
url: {
get: function() {
return this.getUrlComponent(true, true);
},
set: function(value) {
const uri = new import_urijs.default(value);
parseQuery(uri, this, false);
uri.fragment("");
this._url = uri.toString();
}
},
extension: {
get: function() {
return getExtensionFromUri_default(this._url);
}
},
isDataUri: {
get: function() {
return isDataUri_default(this._url);
}
},
isBlobUri: {
get: function() {
return isBlobUri_default(this._url);
}
},
isCrossOriginUrl: {
get: function() {
return isCrossOriginUrl_default(this._url);
}
},
hasHeaders: {
get: function() {
return Object.keys(this.headers).length > 0;
}
}
});
Resource.prototype.toString = function() {
return this.getUrlComponent(true, true);
};
Resource.prototype.getUrlComponent = function(query, proxy) {
if (this.isDataUri) {
return this._url;
}
const uri = new import_urijs.default(this._url);
if (query) {
stringifyQuery(uri, this);
}
let url2 = uri.toString().replace(/%7B/g, "{").replace(/%7D/g, "}");
const templateValues = this._templateValues;
url2 = url2.replace(/{(.*?)}/g, function(match, key) {
const replacement = templateValues[key];
if (defined_default(replacement)) {
return encodeURIComponent(replacement);
}
return match;
});
if (proxy && defined_default(this.proxy)) {
url2 = this.proxy.getURL(url2);
}
return url2;
};
Resource.prototype.setQueryParameters = function(params, useAsDefault) {
if (useAsDefault) {
this._queryParameters = combineQueryParameters(
this._queryParameters,
params,
false
);
} else {
this._queryParameters = combineQueryParameters(
params,
this._queryParameters,
false
);
}
};
Resource.prototype.appendQueryParameters = function(params) {
this._queryParameters = combineQueryParameters(
params,
this._queryParameters,
true
);
};
Resource.prototype.setTemplateValues = function(template, useAsDefault) {
if (useAsDefault) {
this._templateValues = combine_default(this._templateValues, template);
} else {
this._templateValues = combine_default(template, this._templateValues);
}
};
Resource.prototype.getDerivedResource = function(options) {
const resource = this.clone();
resource._retryCount = 0;
if (defined_default(options.url)) {
const uri = new import_urijs.default(options.url);
const preserveQueryParameters = defaultValue_default(
options.preserveQueryParameters,
false
);
parseQuery(uri, resource, true, preserveQueryParameters);
uri.fragment("");
if (uri.scheme() !== "") {
resource._url = uri.toString();
} else {
resource._url = uri.absoluteTo(new import_urijs.default(getAbsoluteUri_default(this._url))).toString();
}
}
if (defined_default(options.queryParameters)) {
resource._queryParameters = combine_default(
options.queryParameters,
resource._queryParameters
);
}
if (defined_default(options.templateValues)) {
resource._templateValues = combine_default(
options.templateValues,
resource.templateValues
);
}
if (defined_default(options.headers)) {
resource.headers = combine_default(options.headers, resource.headers);
}
if (defined_default(options.proxy)) {
resource.proxy = options.proxy;
}
if (defined_default(options.request)) {
resource.request = options.request;
}
if (defined_default(options.retryCallback)) {
resource.retryCallback = options.retryCallback;
}
if (defined_default(options.retryAttempts)) {
resource.retryAttempts = options.retryAttempts;
}
return resource;
};
Resource.prototype.retryOnError = function(error) {
const retryCallback2 = this.retryCallback;
if (typeof retryCallback2 !== "function" || this._retryCount >= this.retryAttempts) {
return Promise.resolve(false);
}
const that = this;
return Promise.resolve(retryCallback2(this, error)).then(function(result) {
++that._retryCount;
return result;
});
};
Resource.prototype.clone = function(result) {
if (!defined_default(result)) {
result = new Resource({
url: this._url
});
}
result._url = this._url;
result._queryParameters = clone_default(this._queryParameters);
result._templateValues = clone_default(this._templateValues);
result.headers = clone_default(this.headers);
result.proxy = this.proxy;
result.retryCallback = this.retryCallback;
result.retryAttempts = this.retryAttempts;
result._retryCount = 0;
result.request = this.request.clone();
return result;
};
Resource.prototype.getBaseUri = function(includeQuery) {
return getBaseUri_default(this.getUrlComponent(includeQuery), includeQuery);
};
Resource.prototype.appendForwardSlash = function() {
this._url = appendForwardSlash_default(this._url);
};
Resource.prototype.fetchArrayBuffer = function() {
return this.fetch({
responseType: "arraybuffer"
});
};
Resource.fetchArrayBuffer = function(options) {
const resource = new Resource(options);
return resource.fetchArrayBuffer();
};
Resource.prototype.fetchBlob = function() {
return this.fetch({
responseType: "blob"
});
};
Resource.fetchBlob = function(options) {
const resource = new Resource(options);
return resource.fetchBlob();
};
Resource.prototype.fetchImage = function(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
const preferImageBitmap = defaultValue_default(options.preferImageBitmap, false);
const preferBlob = defaultValue_default(options.preferBlob, false);
const flipY = defaultValue_default(options.flipY, false);
const skipColorSpaceConversion = defaultValue_default(
options.skipColorSpaceConversion,
false
);
checkAndResetRequest(this.request);
if (!xhrBlobSupported || this.isDataUri || this.isBlobUri || !this.hasHeaders && !preferBlob) {
return fetchImage({
resource: this,
flipY,
skipColorSpaceConversion,
preferImageBitmap
});
}
const blobPromise = this.fetchBlob();
if (!defined_default(blobPromise)) {
return;
}
let supportsImageBitmap;
let useImageBitmap;
let generatedBlobResource;
let generatedBlob;
return Resource.supportsImageBitmapOptions().then(function(result) {
supportsImageBitmap = result;
useImageBitmap = supportsImageBitmap && preferImageBitmap;
return blobPromise;
}).then(function(blob) {
if (!defined_default(blob)) {
return;
}
generatedBlob = blob;
if (useImageBitmap) {
return Resource.createImageBitmapFromBlob(blob, {
flipY,
premultiplyAlpha: false,
skipColorSpaceConversion
});
}
const blobUrl = window.URL.createObjectURL(blob);
generatedBlobResource = new Resource({
url: blobUrl
});
return fetchImage({
resource: generatedBlobResource,
flipY,
skipColorSpaceConversion,
preferImageBitmap: false
});
}).then(function(image) {
if (!defined_default(image)) {
return;
}
image.blob = generatedBlob;
if (useImageBitmap) {
return image;
}
window.URL.revokeObjectURL(generatedBlobResource.url);
return image;
}).catch(function(error) {
if (defined_default(generatedBlobResource)) {
window.URL.revokeObjectURL(generatedBlobResource.url);
}
error.blob = generatedBlob;
return Promise.reject(error);
});
};
function fetchImage(options) {
const resource = options.resource;
const flipY = options.flipY;
const skipColorSpaceConversion = options.skipColorSpaceConversion;
const preferImageBitmap = options.preferImageBitmap;
const request = resource.request;
request.url = resource.url;
request.requestFunction = function() {
let crossOrigin = false;
if (!resource.isDataUri && !resource.isBlobUri) {
crossOrigin = resource.isCrossOriginUrl;
}
const deferred = defer_default();
Resource._Implementations.createImage(
request,
crossOrigin,
deferred,
flipY,
skipColorSpaceConversion,
preferImageBitmap
);
return deferred.promise;
};
const promise = RequestScheduler_default.request(request);
if (!defined_default(promise)) {
return;
}
return promise.catch(function(e) {
if (request.state !== RequestState_default.FAILED) {
return Promise.reject(e);
}
return resource.retryOnError(e).then(function(retry) {
if (retry) {
request.state = RequestState_default.UNISSUED;
request.deferred = void 0;
return fetchImage({
resource,
flipY,
skipColorSpaceConversion,
preferImageBitmap
});
}
return Promise.reject(e);
});
});
}
Resource.fetchImage = function(options) {
const resource = new Resource(options);
return resource.fetchImage({
flipY: options.flipY,
skipColorSpaceConversion: options.skipColorSpaceConversion,
preferBlob: options.preferBlob,
preferImageBitmap: options.preferImageBitmap
});
};
Resource.prototype.fetchText = function() {
return this.fetch({
responseType: "text"
});
};
Resource.fetchText = function(options) {
const resource = new Resource(options);
return resource.fetchText();
};
Resource.prototype.fetchJson = function() {
const promise = this.fetch({
responseType: "text",
headers: {
Accept: "application/json,*/*;q=0.01"
}
});
if (!defined_default(promise)) {
return void 0;
}
return promise.then(function(value) {
if (!defined_default(value)) {
return;
}
return JSON.parse(value);
});
};
Resource.fetchJson = function(options) {
const resource = new Resource(options);
return resource.fetchJson();
};
Resource.prototype.fetchXML = function() {
return this.fetch({
responseType: "document",
overrideMimeType: "text/xml"
});
};
Resource.fetchXML = function(options) {
const resource = new Resource(options);
return resource.fetchXML();
};
Resource.prototype.fetchJsonp = function(callbackParameterName) {
callbackParameterName = defaultValue_default(callbackParameterName, "callback");
checkAndResetRequest(this.request);
let functionName;
do {
functionName = `loadJsonp${Math_default.nextRandomNumber().toString().substring(2, 8)}`;
} while (defined_default(window[functionName]));
return fetchJsonp(this, callbackParameterName, functionName);
};
function fetchJsonp(resource, callbackParameterName, functionName) {
const callbackQuery = {};
callbackQuery[callbackParameterName] = functionName;
resource.setQueryParameters(callbackQuery);
const request = resource.request;
request.url = resource.url;
request.requestFunction = function() {
const deferred = defer_default();
window[functionName] = function(data) {
deferred.resolve(data);
try {
delete window[functionName];
} catch (e) {
window[functionName] = void 0;
}
};
Resource._Implementations.loadAndExecuteScript(
resource.url,
functionName,
deferred
);
return deferred.promise;
};
const promise = RequestScheduler_default.request(request);
if (!defined_default(promise)) {
return;
}
return promise.catch(function(e) {
if (request.state !== RequestState_default.FAILED) {
return Promise.reject(e);
}
return resource.retryOnError(e).then(function(retry) {
if (retry) {
request.state = RequestState_default.UNISSUED;
request.deferred = void 0;
return fetchJsonp(resource, callbackParameterName, functionName);
}
return Promise.reject(e);
});
});
}
Resource.fetchJsonp = function(options) {
const resource = new Resource(options);
return resource.fetchJsonp(options.callbackParameterName);
};
Resource.prototype._makeRequest = function(options) {
const resource = this;
checkAndResetRequest(resource.request);
const request = resource.request;
request.url = resource.url;
request.requestFunction = function() {
const responseType = options.responseType;
const headers = combine_default(options.headers, resource.headers);
const overrideMimeType = options.overrideMimeType;
const method = options.method;
const data = options.data;
const deferred = defer_default();
const xhr = Resource._Implementations.loadWithXhr(
resource.url,
responseType,
method,
data,
headers,
deferred,
overrideMimeType
);
if (defined_default(xhr) && defined_default(xhr.abort)) {
request.cancelFunction = function() {
xhr.abort();
};
}
return deferred.promise;
};
const promise = RequestScheduler_default.request(request);
if (!defined_default(promise)) {
return;
}
return promise.then(function(data) {
request.cancelFunction = void 0;
return data;
}).catch(function(e) {
request.cancelFunction = void 0;
if (request.state !== RequestState_default.FAILED) {
return Promise.reject(e);
}
return resource.retryOnError(e).then(function(retry) {
if (retry) {
request.state = RequestState_default.UNISSUED;
request.deferred = void 0;
return resource.fetch(options);
}
return Promise.reject(e);
});
});
};
var dataUriRegex2 = /^data:(.*?)(;base64)?,(.*)$/;
function decodeDataUriText(isBase64, data) {
const result = decodeURIComponent(data);
if (isBase64) {
return atob(result);
}
return result;
}
function decodeDataUriArrayBuffer(isBase64, data) {
const byteString = decodeDataUriText(isBase64, data);
const buffer = new ArrayBuffer(byteString.length);
const view = new Uint8Array(buffer);
for (let i = 0; i < byteString.length; i++) {
view[i] = byteString.charCodeAt(i);
}
return buffer;
}
function decodeDataUri(dataUriRegexResult, responseType) {
responseType = defaultValue_default(responseType, "");
const mimeType = dataUriRegexResult[1];
const isBase64 = !!dataUriRegexResult[2];
const data = dataUriRegexResult[3];
let buffer;
let parser3;
switch (responseType) {
case "":
case "text":
return decodeDataUriText(isBase64, data);
case "arraybuffer":
return decodeDataUriArrayBuffer(isBase64, data);
case "blob":
buffer = decodeDataUriArrayBuffer(isBase64, data);
return new Blob([buffer], {
type: mimeType
});
case "document":
parser3 = new DOMParser();
return parser3.parseFromString(
decodeDataUriText(isBase64, data),
mimeType
);
case "json":
return JSON.parse(decodeDataUriText(isBase64, data));
default:
throw new DeveloperError_default(`Unhandled responseType: ${responseType}`);
}
}
Resource.prototype.fetch = function(options) {
options = defaultClone(options, {});
options.method = "GET";
return this._makeRequest(options);
};
Resource.fetch = function(options) {
const resource = new Resource(options);
return resource.fetch({
responseType: options.responseType,
overrideMimeType: options.overrideMimeType
});
};
Resource.prototype.delete = function(options) {
options = defaultClone(options, {});
options.method = "DELETE";
return this._makeRequest(options);
};
Resource.delete = function(options) {
const resource = new Resource(options);
return resource.delete({
responseType: options.responseType,
overrideMimeType: options.overrideMimeType,
data: options.data
});
};
Resource.prototype.head = function(options) {
options = defaultClone(options, {});
options.method = "HEAD";
return this._makeRequest(options);
};
Resource.head = function(options) {
const resource = new Resource(options);
return resource.head({
responseType: options.responseType,
overrideMimeType: options.overrideMimeType
});
};
Resource.prototype.options = function(options) {
options = defaultClone(options, {});
options.method = "OPTIONS";
return this._makeRequest(options);
};
Resource.options = function(options) {
const resource = new Resource(options);
return resource.options({
responseType: options.responseType,
overrideMimeType: options.overrideMimeType
});
};
Resource.prototype.post = function(data, options) {
Check_default.defined("data", data);
options = defaultClone(options, {});
options.method = "POST";
options.data = data;
return this._makeRequest(options);
};
Resource.post = function(options) {
const resource = new Resource(options);
return resource.post(options.data, {
responseType: options.responseType,
overrideMimeType: options.overrideMimeType
});
};
Resource.prototype.put = function(data, options) {
Check_default.defined("data", data);
options = defaultClone(options, {});
options.method = "PUT";
options.data = data;
return this._makeRequest(options);
};
Resource.put = function(options) {
const resource = new Resource(options);
return resource.put(options.data, {
responseType: options.responseType,
overrideMimeType: options.overrideMimeType
});
};
Resource.prototype.patch = function(data, options) {
Check_default.defined("data", data);
options = defaultClone(options, {});
options.method = "PATCH";
options.data = data;
return this._makeRequest(options);
};
Resource.patch = function(options) {
const resource = new Resource(options);
return resource.patch(options.data, {
responseType: options.responseType,
overrideMimeType: options.overrideMimeType
});
};
Resource._Implementations = {};
Resource._Implementations.loadImageElement = function(url2, crossOrigin, deferred) {
const image = new Image();
image.onload = function() {
if (image.naturalWidth === 0 && image.naturalHeight === 0 && image.width === 0 && image.height === 0) {
image.width = 300;
image.height = 150;
}
deferred.resolve(image);
};
image.onerror = function(e) {
deferred.reject(e);
};
if (crossOrigin) {
if (TrustedServers_default.contains(url2)) {
image.crossOrigin = "use-credentials";
} else {
image.crossOrigin = "";
}
}
image.src = url2;
};
Resource._Implementations.createImage = function(request, crossOrigin, deferred, flipY, skipColorSpaceConversion, preferImageBitmap) {
const url2 = request.url;
Resource.supportsImageBitmapOptions().then(function(supportsImageBitmap) {
if (!(supportsImageBitmap && preferImageBitmap)) {
Resource._Implementations.loadImageElement(url2, crossOrigin, deferred);
return;
}
const responseType = "blob";
const method = "GET";
const xhrDeferred = defer_default();
const xhr = Resource._Implementations.loadWithXhr(
url2,
responseType,
method,
void 0,
void 0,
xhrDeferred,
void 0,
void 0,
void 0
);
if (defined_default(xhr) && defined_default(xhr.abort)) {
request.cancelFunction = function() {
xhr.abort();
};
}
return xhrDeferred.promise.then(function(blob) {
if (!defined_default(blob)) {
deferred.reject(
new RuntimeError_default(
`Successfully retrieved ${url2} but it contained no content.`
)
);
return;
}
return Resource.createImageBitmapFromBlob(blob, {
flipY,
premultiplyAlpha: false,
skipColorSpaceConversion
});
}).then(function(image) {
deferred.resolve(image);
});
}).catch(function(e) {
deferred.reject(e);
});
};
Resource.createImageBitmapFromBlob = function(blob, options) {
Check_default.defined("options", options);
Check_default.typeOf.bool("options.flipY", options.flipY);
Check_default.typeOf.bool("options.premultiplyAlpha", options.premultiplyAlpha);
Check_default.typeOf.bool(
"options.skipColorSpaceConversion",
options.skipColorSpaceConversion
);
return createImageBitmap(blob, {
imageOrientation: options.flipY ? "flipY" : "none",
premultiplyAlpha: options.premultiplyAlpha ? "premultiply" : "none",
colorSpaceConversion: options.skipColorSpaceConversion ? "none" : "default"
});
};
function decodeResponse(loadWithHttpResponse, responseType) {
switch (responseType) {
case "text":
return loadWithHttpResponse.toString("utf8");
case "json":
return JSON.parse(loadWithHttpResponse.toString("utf8"));
default:
return new Uint8Array(loadWithHttpResponse).buffer;
}
}
function loadWithHttpRequest(url2, responseType, method, data, headers, deferred, overrideMimeType) {
const URL2 = require("url").parse(url2);
const http = URL2.protocol === "https:" ? require("https") : require("http");
const zlib = require("zlib");
const options = {
protocol: URL2.protocol,
hostname: URL2.hostname,
port: URL2.port,
path: URL2.path,
query: URL2.query,
method,
headers
};
http.request(options).on("response", function(res) {
if (res.statusCode < 200 || res.statusCode >= 300) {
deferred.reject(
new RequestErrorEvent_default(res.statusCode, res, res.headers)
);
return;
}
const chunkArray = [];
res.on("data", function(chunk) {
chunkArray.push(chunk);
});
res.on("end", function() {
const result = Buffer.concat(chunkArray);
if (res.headers["content-encoding"] === "gzip") {
zlib.gunzip(result, function(error, resultUnzipped) {
if (error) {
deferred.reject(
new RuntimeError_default("Error decompressing response.")
);
} else {
deferred.resolve(decodeResponse(resultUnzipped, responseType));
}
});
} else {
deferred.resolve(decodeResponse(result, responseType));
}
});
}).on("error", function(e) {
deferred.reject(new RequestErrorEvent_default());
}).end();
}
var noXMLHttpRequest = typeof XMLHttpRequest === "undefined";
Resource._Implementations.loadWithXhr = function(url2, responseType, method, data, headers, deferred, overrideMimeType) {
const dataUriRegexResult = dataUriRegex2.exec(url2);
if (dataUriRegexResult !== null) {
deferred.resolve(decodeDataUri(dataUriRegexResult, responseType));
return;
}
if (noXMLHttpRequest) {
loadWithHttpRequest(
url2,
responseType,
method,
data,
headers,
deferred,
overrideMimeType
);
return;
}
const xhr = new XMLHttpRequest();
if (TrustedServers_default.contains(url2)) {
xhr.withCredentials = true;
}
xhr.open(method, url2, true);
if (defined_default(overrideMimeType) && defined_default(xhr.overrideMimeType)) {
xhr.overrideMimeType(overrideMimeType);
}
if (defined_default(headers)) {
for (const key in headers) {
if (headers.hasOwnProperty(key)) {
xhr.setRequestHeader(key, headers[key]);
}
}
}
if (defined_default(responseType)) {
xhr.responseType = responseType;
}
let localFile = false;
if (typeof url2 === "string") {
localFile = url2.indexOf("file://") === 0 || typeof window !== "undefined" && window.location.origin === "file://";
}
xhr.onload = function() {
if ((xhr.status < 200 || xhr.status >= 300) && !(localFile && xhr.status === 0)) {
deferred.reject(
new RequestErrorEvent_default(
xhr.status,
xhr.response,
xhr.getAllResponseHeaders()
)
);
return;
}
const response = xhr.response;
const browserResponseType = xhr.responseType;
if (method === "HEAD" || method === "OPTIONS") {
const responseHeaderString = xhr.getAllResponseHeaders();
const splitHeaders = responseHeaderString.trim().split(/[\r\n]+/);
const responseHeaders = {};
splitHeaders.forEach(function(line) {
const parts = line.split(": ");
const header = parts.shift();
responseHeaders[header] = parts.join(": ");
});
deferred.resolve(responseHeaders);
return;
}
if (xhr.status === 204) {
deferred.resolve();
} else if (defined_default(response) && (!defined_default(responseType) || browserResponseType === responseType)) {
deferred.resolve(response);
} else if (responseType === "json" && typeof response === "string") {
try {
deferred.resolve(JSON.parse(response));
} catch (e) {
deferred.reject(e);
}
} else if ((browserResponseType === "" || browserResponseType === "document") && defined_default(xhr.responseXML) && xhr.responseXML.hasChildNodes()) {
deferred.resolve(xhr.responseXML);
} else if ((browserResponseType === "" || browserResponseType === "text") && defined_default(xhr.responseText)) {
deferred.resolve(xhr.responseText);
} else {
deferred.reject(
new RuntimeError_default("Invalid XMLHttpRequest response type.")
);
}
};
xhr.onerror = function(e) {
deferred.reject(new RequestErrorEvent_default());
};
xhr.send(data);
return xhr;
};
Resource._Implementations.loadAndExecuteScript = function(url2, functionName, deferred) {
return loadAndExecuteScript_default(url2, functionName).catch(function(e) {
deferred.reject(e);
});
};
Resource._DefaultImplementations = {};
Resource._DefaultImplementations.createImage = Resource._Implementations.createImage;
Resource._DefaultImplementations.loadWithXhr = Resource._Implementations.loadWithXhr;
Resource._DefaultImplementations.loadAndExecuteScript = Resource._Implementations.loadAndExecuteScript;
Resource.DEFAULT = Object.freeze(
new Resource({
url: typeof document === "undefined" ? "" : document.location.href.split("?")[0]
})
);
var Resource_default = Resource;
// Source/Core/buildModuleUrl.js
var cesiumScriptRegex = /((?:.*\/)|^)Cesium\.js(?:\?|\#|$)/;
function getBaseUrlFromCesiumScript() {
const scripts = document.getElementsByTagName("script");
for (let i = 0, len = scripts.length; i < len; ++i) {
const src = scripts[i].getAttribute("src");
const result = cesiumScriptRegex.exec(src);
if (result !== null) {
return result[1];
}
}
return void 0;
}
var a2;
function tryMakeAbsolute(url2) {
if (typeof document === "undefined") {
return url2;
}
if (!defined_default(a2)) {
a2 = document.createElement("a");
}
a2.href = url2;
a2.href = a2.href;
return a2.href;
}
var baseResource;
function getCesiumBaseUrl() {
if (defined_default(baseResource)) {
return baseResource;
}
let baseUrlString;
if (typeof CESIUM_BASE_URL !== "undefined") {
baseUrlString = CESIUM_BASE_URL;
} else if (typeof define === "object" && defined_default(define.amd) && !define.amd.toUrlUndefined && defined_default(require.toUrl)) {
baseUrlString = getAbsoluteUri_default(
"..",
buildModuleUrl("Core/buildModuleUrl.js")
);
} else {
baseUrlString = getBaseUrlFromCesiumScript();
}
if (!defined_default(baseUrlString)) {
throw new DeveloperError_default(
"Unable to determine Cesium base URL automatically, try defining a global variable called CESIUM_BASE_URL."
);
}
baseResource = new Resource_default({
url: tryMakeAbsolute(baseUrlString)
});
baseResource.appendForwardSlash();
return baseResource;
}
function buildModuleUrlFromRequireToUrl(moduleID) {
return tryMakeAbsolute(require.toUrl(`../${moduleID}`));
}
function buildModuleUrlFromBaseUrl(moduleID) {
const resource = getCesiumBaseUrl().getDerivedResource({
url: moduleID
});
return resource.url;
}
var implementation;
function buildModuleUrl(relativeUrl) {
if (!defined_default(implementation)) {
if (typeof define === "object" && defined_default(define.amd) && !define.amd.toUrlUndefined && defined_default(require.toUrl)) {
implementation = buildModuleUrlFromRequireToUrl;
} else {
implementation = buildModuleUrlFromBaseUrl;
}
}
const url2 = implementation(relativeUrl);
return url2;
}
buildModuleUrl._cesiumScriptRegex = cesiumScriptRegex;
buildModuleUrl._buildModuleUrlFromBaseUrl = buildModuleUrlFromBaseUrl;
buildModuleUrl._clearBaseResource = function() {
baseResource = void 0;
};
buildModuleUrl.setBaseUrl = function(value) {
baseResource = Resource_default.DEFAULT.getDerivedResource({
url: value
});
};
buildModuleUrl.getCesiumBaseUrl = getCesiumBaseUrl;
var buildModuleUrl_default = buildModuleUrl;
// Source/Core/Cartesian2.js
function Cartesian2(x, y) {
this.x = defaultValue_default(x, 0);
this.y = defaultValue_default(y, 0);
}
Cartesian2.fromElements = function(x, y, result) {
if (!defined_default(result)) {
return new Cartesian2(x, y);
}
result.x = x;
result.y = y;
return result;
};
Cartesian2.clone = function(cartesian11, result) {
if (!defined_default(cartesian11)) {
return void 0;
}
if (!defined_default(result)) {
return new Cartesian2(cartesian11.x, cartesian11.y);
}
result.x = cartesian11.x;
result.y = cartesian11.y;
return result;
};
Cartesian2.fromCartesian3 = Cartesian2.clone;
Cartesian2.fromCartesian4 = Cartesian2.clone;
Cartesian2.packedLength = 2;
Cartesian2.pack = function(value, array, startingIndex) {
Check_default.typeOf.object("value", value);
Check_default.defined("array", array);
startingIndex = defaultValue_default(startingIndex, 0);
array[startingIndex++] = value.x;
array[startingIndex] = value.y;
return array;
};
Cartesian2.unpack = function(array, startingIndex, result) {
Check_default.defined("array", array);
startingIndex = defaultValue_default(startingIndex, 0);
if (!defined_default(result)) {
result = new Cartesian2();
}
result.x = array[startingIndex++];
result.y = array[startingIndex];
return result;
};
Cartesian2.packArray = function(array, result) {
Check_default.defined("array", array);
const length3 = array.length;
const resultLength = length3 * 2;
if (!defined_default(result)) {
result = new Array(resultLength);
} else if (!Array.isArray(result) && result.length !== resultLength) {
throw new DeveloperError_default(
"If result is a typed array, it must have exactly array.length * 2 elements"
);
} else if (result.length !== resultLength) {
result.length = resultLength;
}
for (let i = 0; i < length3; ++i) {
Cartesian2.pack(array[i], result, i * 2);
}
return result;
};
Cartesian2.unpackArray = function(array, result) {
Check_default.defined("array", array);
Check_default.typeOf.number.greaterThanOrEquals("array.length", array.length, 2);
if (array.length % 2 !== 0) {
throw new DeveloperError_default("array length must be a multiple of 2.");
}
const length3 = array.length;
if (!defined_default(result)) {
result = new Array(length3 / 2);
} else {
result.length = length3 / 2;
}
for (let i = 0; i < length3; i += 2) {
const index = i / 2;
result[index] = Cartesian2.unpack(array, i, result[index]);
}
return result;
};
Cartesian2.fromArray = Cartesian2.unpack;
Cartesian2.maximumComponent = function(cartesian11) {
Check_default.typeOf.object("cartesian", cartesian11);
return Math.max(cartesian11.x, cartesian11.y);
};
Cartesian2.minimumComponent = function(cartesian11) {
Check_default.typeOf.object("cartesian", cartesian11);
return Math.min(cartesian11.x, cartesian11.y);
};
Cartesian2.minimumByComponent = function(first, second, result) {
Check_default.typeOf.object("first", first);
Check_default.typeOf.object("second", second);
Check_default.typeOf.object("result", result);
result.x = Math.min(first.x, second.x);
result.y = Math.min(first.y, second.y);
return result;
};
Cartesian2.maximumByComponent = function(first, second, result) {
Check_default.typeOf.object("first", first);
Check_default.typeOf.object("second", second);
Check_default.typeOf.object("result", result);
result.x = Math.max(first.x, second.x);
result.y = Math.max(first.y, second.y);
return result;
};
Cartesian2.clamp = function(value, min3, max3, result) {
Check_default.typeOf.object("value", value);
Check_default.typeOf.object("min", min3);
Check_default.typeOf.object("max", max3);
Check_default.typeOf.object("result", result);
const x = Math_default.clamp(value.x, min3.x, max3.x);
const y = Math_default.clamp(value.y, min3.y, max3.y);
result.x = x;
result.y = y;
return result;
};
Cartesian2.magnitudeSquared = function(cartesian11) {
Check_default.typeOf.object("cartesian", cartesian11);
return cartesian11.x * cartesian11.x + cartesian11.y * cartesian11.y;
};
Cartesian2.magnitude = function(cartesian11) {
return Math.sqrt(Cartesian2.magnitudeSquared(cartesian11));
};
var distanceScratch3 = new Cartesian2();
Cartesian2.distance = function(left, right) {
Check_default.typeOf.object("left", left);
Check_default.typeOf.object("right", right);
Cartesian2.subtract(left, right, distanceScratch3);
return Cartesian2.magnitude(distanceScratch3);
};
Cartesian2.distanceSquared = function(left, right) {
Check_default.typeOf.object("left", left);
Check_default.typeOf.object("right", right);
Cartesian2.subtract(left, right, distanceScratch3);
return Cartesian2.magnitudeSquared(distanceScratch3);
};
Cartesian2.normalize = function(cartesian11, result) {
Check_default.typeOf.object("cartesian", cartesian11);
Check_default.typeOf.object("result", result);
const magnitude = Cartesian2.magnitude(cartesian11);
result.x = cartesian11.x / magnitude;
result.y = cartesian11.y / magnitude;
if (isNaN(result.x) || isNaN(result.y)) {
throw new DeveloperError_default("normalized result is not a number");
}
return result;
};
Cartesian2.dot = function(left, right) {
Check_default.typeOf.object("left", left);
Check_default.typeOf.object("right", right);
return left.x * right.x + left.y * right.y;
};
Cartesian2.cross = function(left, right) {
Check_default.typeOf.object("left", left);
Check_default.typeOf.object("right", right);
return left.x * right.y - left.y * right.x;
};
Cartesian2.multiplyComponents = function(left, right, result) {
Check_default.typeOf.object("left", left);
Check_default.typeOf.object("right", right);
Check_default.typeOf.object("result", result);
result.x = left.x * right.x;
result.y = left.y * right.y;
return result;
};
Cartesian2.divideComponents = function(left, right, result) {
Check_default.typeOf.object("left", left);
Check_default.typeOf.object("right", right);
Check_default.typeOf.object("result", result);
result.x = left.x / right.x;
result.y = left.y / right.y;
return result;
};
Cartesian2.add = function(left, right, result) {
Check_default.typeOf.object("left", left);
Check_default.typeOf.object("right", right);
Check_default.typeOf.object("result", result);
result.x = left.x + right.x;
result.y = left.y + right.y;
return result;
};
Cartesian2.subtract = function(left, right, result) {
Check_default.typeOf.object("left", left);
Check_default.typeOf.object("right", right);
Check_default.typeOf.object("result", result);
result.x = left.x - right.x;
result.y = left.y - right.y;
return result;
};
Cartesian2.multiplyByScalar = function(cartesian11, scalar, result) {
Check_default.typeOf.object("cartesian", cartesian11);
Check_default.typeOf.number("scalar", scalar);
Check_default.typeOf.object("result", result);
result.x = cartesian11.x * scalar;
result.y = cartesian11.y * scalar;
return result;
};
Cartesian2.divideByScalar = function(cartesian11, scalar, result) {
Check_default.typeOf.object("cartesian", cartesian11);
Check_default.typeOf.number("scalar", scalar);
Check_default.typeOf.object("result", result);
result.x = cartesian11.x / scalar;
result.y = cartesian11.y / scalar;
return result;
};
Cartesian2.negate = function(cartesian11, result) {
Check_default.typeOf.object("cartesian", cartesian11);
Check_default.typeOf.object("result", result);
result.x = -cartesian11.x;
result.y = -cartesian11.y;
return result;
};
Cartesian2.abs = function(cartesian11, result) {
Check_default.typeOf.object("cartesian", cartesian11);
Check_default.typeOf.object("result", result);
result.x = Math.abs(cartesian11.x);
result.y = Math.abs(cartesian11.y);
return result;
};
var lerpScratch3 = new Cartesian2();
Cartesian2.lerp = function(start, end, t, result) {
Check_default.typeOf.object("start", start);
Check_default.typeOf.object("end", end);
Check_default.typeOf.number("t", t);
Check_default.typeOf.object("result", result);
Cartesian2.multiplyByScalar(end, t, lerpScratch3);
result = Cartesian2.multiplyByScalar(start, 1 - t, result);
return Cartesian2.add(lerpScratch3, result, result);
};
var angleBetweenScratch3 = new Cartesian2();
var angleBetweenScratch22 = new Cartesian2();
Cartesian2.angleBetween = function(left, right) {
Check_default.typeOf.object("left", left);
Check_default.typeOf.object("right", right);
Cartesian2.normalize(left, angleBetweenScratch3);
Cartesian2.normalize(right, angleBetweenScratch22);
return Math_default.acosClamped(
Cartesian2.dot(angleBetweenScratch3, angleBetweenScratch22)
);
};
var mostOrthogonalAxisScratch3 = new Cartesian2();
Cartesian2.mostOrthogonalAxis = function(cartesian11, result) {
Check_default.typeOf.object("cartesian", cartesian11);
Check_default.typeOf.object("result", result);
const f = Cartesian2.normalize(cartesian11, mostOrthogonalAxisScratch3);
Cartesian2.abs(f, f);
if (f.x <= f.y) {
result = Cartesian2.clone(Cartesian2.UNIT_X, result);
} else {
result = Cartesian2.clone(Cartesian2.UNIT_Y, result);
}
return result;
};
Cartesian2.equals = function(left, right) {
return left === right || defined_default(left) && defined_default(right) && left.x === right.x && left.y === right.y;
};
Cartesian2.equalsArray = function(cartesian11, array, offset2) {
return cartesian11.x === array[offset2] && cartesian11.y === array[offset2 + 1];
};
Cartesian2.equalsEpsilon = function(left, right, relativeEpsilon, absoluteEpsilon) {
return left === right || defined_default(left) && defined_default(right) && Math_default.equalsEpsilon(
left.x,
right.x,
relativeEpsilon,
absoluteEpsilon
) && Math_default.equalsEpsilon(
left.y,
right.y,
relativeEpsilon,
absoluteEpsilon
);
};
Cartesian2.ZERO = Object.freeze(new Cartesian2(0, 0));
Cartesian2.ONE = Object.freeze(new Cartesian2(1, 1));
Cartesian2.UNIT_X = Object.freeze(new Cartesian2(1, 0));
Cartesian2.UNIT_Y = Object.freeze(new Cartesian2(0, 1));
Cartesian2.prototype.clone = function(result) {
return Cartesian2.clone(this, result);
};
Cartesian2.prototype.equals = function(right) {
return Cartesian2.equals(this, right);
};
Cartesian2.prototype.equalsEpsilon = function(right, relativeEpsilon, absoluteEpsilon) {
return Cartesian2.equalsEpsilon(
this,
right,
relativeEpsilon,
absoluteEpsilon
);
};
Cartesian2.prototype.toString = function() {
return `(${this.x}, ${this.y})`;
};
var Cartesian2_default = Cartesian2;
// Source/Core/GeographicTilingScheme.js
function GeographicTilingScheme(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
this._ellipsoid = defaultValue_default(options.ellipsoid, Ellipsoid_default.WGS84);
this._rectangle = defaultValue_default(options.rectangle, Rectangle_default.MAX_VALUE);
this._projection = new GeographicProjection_default(this._ellipsoid);
this._numberOfLevelZeroTilesX = defaultValue_default(
options.numberOfLevelZeroTilesX,
2
);
this._numberOfLevelZeroTilesY = defaultValue_default(
options.numberOfLevelZeroTilesY,
1
);
}
Object.defineProperties(GeographicTilingScheme.prototype, {
ellipsoid: {
get: function() {
return this._ellipsoid;
}
},
rectangle: {
get: function() {
return this._rectangle;
}
},
projection: {
get: function() {
return this._projection;
}
}
});
GeographicTilingScheme.prototype.getNumberOfXTilesAtLevel = function(level) {
return this._numberOfLevelZeroTilesX << level;
};
GeographicTilingScheme.prototype.getNumberOfYTilesAtLevel = function(level) {
return this._numberOfLevelZeroTilesY << level;
};
GeographicTilingScheme.prototype.rectangleToNativeRectangle = function(rectangle, result) {
Check_default.defined("rectangle", rectangle);
const west = Math_default.toDegrees(rectangle.west);
const south = Math_default.toDegrees(rectangle.south);
const east = Math_default.toDegrees(rectangle.east);
const north = Math_default.toDegrees(rectangle.north);
if (!defined_default(result)) {
return new Rectangle_default(west, south, east, north);
}
result.west = west;
result.south = south;
result.east = east;
result.north = north;
return result;
};
GeographicTilingScheme.prototype.tileXYToNativeRectangle = function(x, y, level, result) {
const rectangleRadians = this.tileXYToRectangle(x, y, level, result);
rectangleRadians.west = Math_default.toDegrees(rectangleRadians.west);
rectangleRadians.south = Math_default.toDegrees(rectangleRadians.south);
rectangleRadians.east = Math_default.toDegrees(rectangleRadians.east);
rectangleRadians.north = Math_default.toDegrees(rectangleRadians.north);
return rectangleRadians;
};
GeographicTilingScheme.prototype.tileXYToRectangle = function(x, y, level, result) {
const rectangle = this._rectangle;
const xTiles = this.getNumberOfXTilesAtLevel(level);
const yTiles = this.getNumberOfYTilesAtLevel(level);
const xTileWidth = rectangle.width / xTiles;
const west = x * xTileWidth + rectangle.west;
const east = (x + 1) * xTileWidth + rectangle.west;
const yTileHeight = rectangle.height / yTiles;
const north = rectangle.north - y * yTileHeight;
const south = rectangle.north - (y + 1) * yTileHeight;
if (!defined_default(result)) {
result = new Rectangle_default(west, south, east, north);
}
result.west = west;
result.south = south;
result.east = east;
result.north = north;
return result;
};
GeographicTilingScheme.prototype.positionToTileXY = function(position, level, result) {
const rectangle = this._rectangle;
if (!Rectangle_default.contains(rectangle, position)) {
return void 0;
}
const xTiles = this.getNumberOfXTilesAtLevel(level);
const yTiles = this.getNumberOfYTilesAtLevel(level);
const xTileWidth = rectangle.width / xTiles;
const yTileHeight = rectangle.height / yTiles;
let longitude = position.longitude;
if (rectangle.east < rectangle.west) {
longitude += Math_default.TWO_PI;
}
let xTileCoordinate = (longitude - rectangle.west) / xTileWidth | 0;
if (xTileCoordinate >= xTiles) {
xTileCoordinate = xTiles - 1;
}
let yTileCoordinate = (rectangle.north - position.latitude) / yTileHeight | 0;
if (yTileCoordinate >= yTiles) {
yTileCoordinate = yTiles - 1;
}
if (!defined_default(result)) {
return new Cartesian2_default(xTileCoordinate, yTileCoordinate);
}
result.x = xTileCoordinate;
result.y = yTileCoordinate;
return result;
};
var GeographicTilingScheme_default = GeographicTilingScheme;
// Source/Core/ApproximateTerrainHeights.js
var scratchDiagonalCartesianNE = new Cartesian3_default();
var scratchDiagonalCartesianSW = new Cartesian3_default();
var scratchDiagonalCartographic = new Cartographic_default();
var scratchCenterCartesian = new Cartesian3_default();
var scratchSurfaceCartesian = new Cartesian3_default();
var scratchBoundingSphere = new BoundingSphere_default();
var tilingScheme = new GeographicTilingScheme_default();
var scratchCorners = [
new Cartographic_default(),
new Cartographic_default(),
new Cartographic_default(),
new Cartographic_default()
];
var scratchTileXY = new Cartesian2_default();
var ApproximateTerrainHeights = {};
ApproximateTerrainHeights.initialize = function() {
let initPromise = ApproximateTerrainHeights._initPromise;
if (defined_default(initPromise)) {
return initPromise;
}
initPromise = Resource_default.fetchJson(
buildModuleUrl_default("Assets/approximateTerrainHeights.json")
).then(function(json) {
ApproximateTerrainHeights._terrainHeights = json;
});
ApproximateTerrainHeights._initPromise = initPromise;
return initPromise;
};
ApproximateTerrainHeights.getMinimumMaximumHeights = function(rectangle, ellipsoid) {
Check_default.defined("rectangle", rectangle);
if (!defined_default(ApproximateTerrainHeights._terrainHeights)) {
throw new DeveloperError_default(
"You must call ApproximateTerrainHeights.initialize and wait for the promise to resolve before using this function"
);
}
ellipsoid = defaultValue_default(ellipsoid, Ellipsoid_default.WGS84);
const xyLevel = getTileXYLevel(rectangle);
let minTerrainHeight = ApproximateTerrainHeights._defaultMinTerrainHeight;
let maxTerrainHeight = ApproximateTerrainHeights._defaultMaxTerrainHeight;
if (defined_default(xyLevel)) {
const key = `${xyLevel.level}-${xyLevel.x}-${xyLevel.y}`;
const heights = ApproximateTerrainHeights._terrainHeights[key];
if (defined_default(heights)) {
minTerrainHeight = heights[0];
maxTerrainHeight = heights[1];
}
ellipsoid.cartographicToCartesian(
Rectangle_default.northeast(rectangle, scratchDiagonalCartographic),
scratchDiagonalCartesianNE
);
ellipsoid.cartographicToCartesian(
Rectangle_default.southwest(rectangle, scratchDiagonalCartographic),
scratchDiagonalCartesianSW
);
Cartesian3_default.midpoint(
scratchDiagonalCartesianSW,
scratchDiagonalCartesianNE,
scratchCenterCartesian
);
const surfacePosition = ellipsoid.scaleToGeodeticSurface(
scratchCenterCartesian,
scratchSurfaceCartesian
);
if (defined_default(surfacePosition)) {
const distance2 = Cartesian3_default.distance(
scratchCenterCartesian,
surfacePosition
);
minTerrainHeight = Math.min(minTerrainHeight, -distance2);
} else {
minTerrainHeight = ApproximateTerrainHeights._defaultMinTerrainHeight;
}
}
minTerrainHeight = Math.max(
ApproximateTerrainHeights._defaultMinTerrainHeight,
minTerrainHeight
);
return {
minimumTerrainHeight: minTerrainHeight,
maximumTerrainHeight: maxTerrainHeight
};
};
ApproximateTerrainHeights.getBoundingSphere = function(rectangle, ellipsoid) {
Check_default.defined("rectangle", rectangle);
if (!defined_default(ApproximateTerrainHeights._terrainHeights)) {
throw new DeveloperError_default(
"You must call ApproximateTerrainHeights.initialize and wait for the promise to resolve before using this function"
);
}
ellipsoid = defaultValue_default(ellipsoid, Ellipsoid_default.WGS84);
const xyLevel = getTileXYLevel(rectangle);
let maxTerrainHeight = ApproximateTerrainHeights._defaultMaxTerrainHeight;
if (defined_default(xyLevel)) {
const key = `${xyLevel.level}-${xyLevel.x}-${xyLevel.y}`;
const heights = ApproximateTerrainHeights._terrainHeights[key];
if (defined_default(heights)) {
maxTerrainHeight = heights[1];
}
}
const result = BoundingSphere_default.fromRectangle3D(rectangle, ellipsoid, 0);
BoundingSphere_default.fromRectangle3D(
rectangle,
ellipsoid,
maxTerrainHeight,
scratchBoundingSphere
);
return BoundingSphere_default.union(result, scratchBoundingSphere, result);
};
function getTileXYLevel(rectangle) {
Cartographic_default.fromRadians(
rectangle.east,
rectangle.north,
0,
scratchCorners[0]
);
Cartographic_default.fromRadians(
rectangle.west,
rectangle.north,
0,
scratchCorners[1]
);
Cartographic_default.fromRadians(
rectangle.east,
rectangle.south,
0,
scratchCorners[2]
);
Cartographic_default.fromRadians(
rectangle.west,
rectangle.south,
0,
scratchCorners[3]
);
let lastLevelX = 0, lastLevelY = 0;
let currentX = 0, currentY = 0;
const maxLevel = ApproximateTerrainHeights._terrainHeightsMaxLevel;
let i;
for (i = 0; i <= maxLevel; ++i) {
let failed = false;
for (let j = 0; j < 4; ++j) {
const corner = scratchCorners[j];
tilingScheme.positionToTileXY(corner, i, scratchTileXY);
if (j === 0) {
currentX = scratchTileXY.x;
currentY = scratchTileXY.y;
} else if (currentX !== scratchTileXY.x || currentY !== scratchTileXY.y) {
failed = true;
break;
}
}
if (failed) {
break;
}
lastLevelX = currentX;
lastLevelY = currentY;
}
if (i === 0) {
return void 0;
}
return {
x: lastLevelX,
y: lastLevelY,
level: i > maxLevel ? maxLevel : i - 1
};
}
ApproximateTerrainHeights._terrainHeightsMaxLevel = 6;
ApproximateTerrainHeights._defaultMaxTerrainHeight = 9e3;
ApproximateTerrainHeights._defaultMinTerrainHeight = -1e5;
ApproximateTerrainHeights._terrainHeights = void 0;
ApproximateTerrainHeights._initPromise = void 0;
Object.defineProperties(ApproximateTerrainHeights, {
initialized: {
get: function() {
return defined_default(ApproximateTerrainHeights._terrainHeights);
}
}
});
var ApproximateTerrainHeights_default = ApproximateTerrainHeights;
// Source/ThirdParty/dompurify.js
var import_dompurify = __toESM(require_purify_cjs(), 1);
// Source/Core/Credit.js
var nextCreditId = 0;
var creditToId = {};
function Credit(html, showOnScreen) {
Check_default.typeOf.string("html", html);
let id;
const key = html;
if (defined_default(creditToId[key])) {
id = creditToId[key];
} else {
id = nextCreditId++;
creditToId[key] = id;
}
showOnScreen = defaultValue_default(showOnScreen, false);
this._id = id;
this._html = html;
this._showOnScreen = showOnScreen;
this._element = void 0;
}
Object.defineProperties(Credit.prototype, {
html: {
get: function() {
return this._html;
}
},
id: {
get: function() {
return this._id;
}
},
showOnScreen: {
get: function() {
return this._showOnScreen;
},
set: function(value) {
this._showOnScreen = value;
}
},
element: {
get: function() {
if (!defined_default(this._element)) {
const html = import_dompurify.default.sanitize(this._html);
const div = document.createElement("div");
div._creditId = this._id;
div.style.display = "inline";
div.innerHTML = html;
const links = div.querySelectorAll("a");
for (let i = 0; i < links.length; i++) {
links[i].setAttribute("target", "_blank");
}
this._element = div;
}
return this._element;
}
}
});
Credit.equals = function(left, right) {
return left === right || defined_default(left) && defined_default(right) && left._id === right._id && left._showOnScreen === right._showOnScreen;
};
Credit.prototype.equals = function(credit) {
return Credit.equals(this, credit);
};
Credit.getIonCredit = function(attribution) {
const showOnScreen = defined_default(attribution.collapsible) && !attribution.collapsible;
const credit = new Credit(attribution.html, showOnScreen);
credit._isIon = credit.html.indexOf("ion-credit.png") !== -1;
return credit;
};
Credit.clone = function(credit) {
if (defined_default(credit)) {
return new Credit(credit.html, credit.showOnScreen);
}
};
var Credit_default = Credit;
// Source/Core/HeightmapEncoding.js
var HeightmapEncoding = {
NONE: 0,
LERC: 1
};
var HeightmapEncoding_default = Object.freeze(HeightmapEncoding);
// Source/Core/AxisAlignedBoundingBox.js
function AxisAlignedBoundingBox(minimum, maximum, center) {
this.minimum = Cartesian3_default.clone(defaultValue_default(minimum, Cartesian3_default.ZERO));
this.maximum = Cartesian3_default.clone(defaultValue_default(maximum, Cartesian3_default.ZERO));
if (!defined_default(center)) {
center = Cartesian3_default.midpoint(this.minimum, this.maximum, new Cartesian3_default());
} else {
center = Cartesian3_default.clone(center);
}
this.center = center;
}
AxisAlignedBoundingBox.fromCorners = function(minimum, maximum, result) {
Check_default.defined("minimum", minimum);
Check_default.defined("maximum", maximum);
if (!defined_default(result)) {
result = new AxisAlignedBoundingBox();
}
result.minimum = Cartesian3_default.clone(minimum, result.minimum);
result.maximum = Cartesian3_default.clone(maximum, result.maximum);
result.center = Cartesian3_default.midpoint(minimum, maximum, result.center);
return result;
};
AxisAlignedBoundingBox.fromPoints = function(positions, result) {
if (!defined_default(result)) {
result = new AxisAlignedBoundingBox();
}
if (!defined_default(positions) || positions.length === 0) {
result.minimum = Cartesian3_default.clone(Cartesian3_default.ZERO, result.minimum);
result.maximum = Cartesian3_default.clone(Cartesian3_default.ZERO, result.maximum);
result.center = Cartesian3_default.clone(Cartesian3_default.ZERO, result.center);
return result;
}
let minimumX = positions[0].x;
let minimumY = positions[0].y;
let minimumZ = positions[0].z;
let maximumX = positions[0].x;
let maximumY = positions[0].y;
let maximumZ = positions[0].z;
const length3 = positions.length;
for (let i = 1; i < length3; i++) {
const p = positions[i];
const x = p.x;
const y = p.y;
const z = p.z;
minimumX = Math.min(x, minimumX);
maximumX = Math.max(x, maximumX);
minimumY = Math.min(y, minimumY);
maximumY = Math.max(y, maximumY);
minimumZ = Math.min(z, minimumZ);
maximumZ = Math.max(z, maximumZ);
}
const minimum = result.minimum;
minimum.x = minimumX;
minimum.y = minimumY;
minimum.z = minimumZ;
const maximum = result.maximum;
maximum.x = maximumX;
maximum.y = maximumY;
maximum.z = maximumZ;
result.center = Cartesian3_default.midpoint(minimum, maximum, result.center);
return result;
};
AxisAlignedBoundingBox.clone = function(box, result) {
if (!defined_default(box)) {
return void 0;
}
if (!defined_default(result)) {
return new AxisAlignedBoundingBox(box.minimum, box.maximum, box.center);
}
result.minimum = Cartesian3_default.clone(box.minimum, result.minimum);
result.maximum = Cartesian3_default.clone(box.maximum, result.maximum);
result.center = Cartesian3_default.clone(box.center, result.center);
return result;
};
AxisAlignedBoundingBox.equals = function(left, right) {
return left === right || defined_default(left) && defined_default(right) && Cartesian3_default.equals(left.center, right.center) && Cartesian3_default.equals(left.minimum, right.minimum) && Cartesian3_default.equals(left.maximum, right.maximum);
};
var intersectScratch = new Cartesian3_default();
AxisAlignedBoundingBox.intersectPlane = function(box, plane) {
Check_default.defined("box", box);
Check_default.defined("plane", plane);
intersectScratch = Cartesian3_default.subtract(
box.maximum,
box.minimum,
intersectScratch
);
const h = Cartesian3_default.multiplyByScalar(
intersectScratch,
0.5,
intersectScratch
);
const normal2 = plane.normal;
const e = h.x * Math.abs(normal2.x) + h.y * Math.abs(normal2.y) + h.z * Math.abs(normal2.z);
const s = Cartesian3_default.dot(box.center, normal2) + plane.distance;
if (s - e > 0) {
return Intersect_default.INSIDE;
}
if (s + e < 0) {
return Intersect_default.OUTSIDE;
}
return Intersect_default.INTERSECTING;
};
AxisAlignedBoundingBox.prototype.clone = function(result) {
return AxisAlignedBoundingBox.clone(this, result);
};
AxisAlignedBoundingBox.prototype.intersectPlane = function(plane) {
return AxisAlignedBoundingBox.intersectPlane(this, plane);
};
AxisAlignedBoundingBox.prototype.equals = function(right) {
return AxisAlignedBoundingBox.equals(this, right);
};
var AxisAlignedBoundingBox_default = AxisAlignedBoundingBox;
// Source/Core/EllipsoidalOccluder.js
function EllipsoidalOccluder(ellipsoid, cameraPosition) {
Check_default.typeOf.object("ellipsoid", ellipsoid);
this._ellipsoid = ellipsoid;
this._cameraPosition = new Cartesian3_default();
this._cameraPositionInScaledSpace = new Cartesian3_default();
this._distanceToLimbInScaledSpaceSquared = 0;
if (defined_default(cameraPosition)) {
this.cameraPosition = cameraPosition;
}
}
Object.defineProperties(EllipsoidalOccluder.prototype, {
ellipsoid: {
get: function() {
return this._ellipsoid;
}
},
cameraPosition: {
get: function() {
return this._cameraPosition;
},
set: function(cameraPosition) {
const ellipsoid = this._ellipsoid;
const cv = ellipsoid.transformPositionToScaledSpace(
cameraPosition,
this._cameraPositionInScaledSpace
);
const vhMagnitudeSquared = Cartesian3_default.magnitudeSquared(cv) - 1;
Cartesian3_default.clone(cameraPosition, this._cameraPosition);
this._cameraPositionInScaledSpace = cv;
this._distanceToLimbInScaledSpaceSquared = vhMagnitudeSquared;
}
}
});
var scratchCartesian = new Cartesian3_default();
EllipsoidalOccluder.prototype.isPointVisible = function(occludee) {
const ellipsoid = this._ellipsoid;
const occludeeScaledSpacePosition = ellipsoid.transformPositionToScaledSpace(
occludee,
scratchCartesian
);
return isScaledSpacePointVisible(
occludeeScaledSpacePosition,
this._cameraPositionInScaledSpace,
this._distanceToLimbInScaledSpaceSquared
);
};
EllipsoidalOccluder.prototype.isScaledSpacePointVisible = function(occludeeScaledSpacePosition) {
return isScaledSpacePointVisible(
occludeeScaledSpacePosition,
this._cameraPositionInScaledSpace,
this._distanceToLimbInScaledSpaceSquared
);
};
var scratchCameraPositionInScaledSpaceShrunk = new Cartesian3_default();
EllipsoidalOccluder.prototype.isScaledSpacePointVisiblePossiblyUnderEllipsoid = function(occludeeScaledSpacePosition, minimumHeight) {
const ellipsoid = this._ellipsoid;
let vhMagnitudeSquared;
let cv;
if (defined_default(minimumHeight) && minimumHeight < 0 && ellipsoid.minimumRadius > -minimumHeight) {
cv = scratchCameraPositionInScaledSpaceShrunk;
cv.x = this._cameraPosition.x / (ellipsoid.radii.x + minimumHeight);
cv.y = this._cameraPosition.y / (ellipsoid.radii.y + minimumHeight);
cv.z = this._cameraPosition.z / (ellipsoid.radii.z + minimumHeight);
vhMagnitudeSquared = cv.x * cv.x + cv.y * cv.y + cv.z * cv.z - 1;
} else {
cv = this._cameraPositionInScaledSpace;
vhMagnitudeSquared = this._distanceToLimbInScaledSpaceSquared;
}
return isScaledSpacePointVisible(
occludeeScaledSpacePosition,
cv,
vhMagnitudeSquared
);
};
EllipsoidalOccluder.prototype.computeHorizonCullingPoint = function(directionToPoint, positions, result) {
return computeHorizonCullingPointFromPositions(
this._ellipsoid,
directionToPoint,
positions,
result
);
};
var scratchEllipsoidShrunk = Ellipsoid_default.clone(Ellipsoid_default.UNIT_SPHERE);
EllipsoidalOccluder.prototype.computeHorizonCullingPointPossiblyUnderEllipsoid = function(directionToPoint, positions, minimumHeight, result) {
const possiblyShrunkEllipsoid = getPossiblyShrunkEllipsoid(
this._ellipsoid,
minimumHeight,
scratchEllipsoidShrunk
);
return computeHorizonCullingPointFromPositions(
possiblyShrunkEllipsoid,
directionToPoint,
positions,
result
);
};
EllipsoidalOccluder.prototype.computeHorizonCullingPointFromVertices = function(directionToPoint, vertices, stride, center, result) {
return computeHorizonCullingPointFromVertices(
this._ellipsoid,
directionToPoint,
vertices,
stride,
center,
result
);
};
EllipsoidalOccluder.prototype.computeHorizonCullingPointFromVerticesPossiblyUnderEllipsoid = function(directionToPoint, vertices, stride, center, minimumHeight, result) {
const possiblyShrunkEllipsoid = getPossiblyShrunkEllipsoid(
this._ellipsoid,
minimumHeight,
scratchEllipsoidShrunk
);
return computeHorizonCullingPointFromVertices(
possiblyShrunkEllipsoid,
directionToPoint,
vertices,
stride,
center,
result
);
};
var subsampleScratch = [];
EllipsoidalOccluder.prototype.computeHorizonCullingPointFromRectangle = function(rectangle, ellipsoid, result) {
Check_default.typeOf.object("rectangle", rectangle);
const positions = Rectangle_default.subsample(
rectangle,
ellipsoid,
0,
subsampleScratch
);
const bs = BoundingSphere_default.fromPoints(positions);
if (Cartesian3_default.magnitude(bs.center) < 0.1 * ellipsoid.minimumRadius) {
return void 0;
}
return this.computeHorizonCullingPoint(bs.center, positions, result);
};
var scratchEllipsoidShrunkRadii = new Cartesian3_default();
function getPossiblyShrunkEllipsoid(ellipsoid, minimumHeight, result) {
if (defined_default(minimumHeight) && minimumHeight < 0 && ellipsoid.minimumRadius > -minimumHeight) {
const ellipsoidShrunkRadii = Cartesian3_default.fromElements(
ellipsoid.radii.x + minimumHeight,
ellipsoid.radii.y + minimumHeight,
ellipsoid.radii.z + minimumHeight,
scratchEllipsoidShrunkRadii
);
ellipsoid = Ellipsoid_default.fromCartesian3(ellipsoidShrunkRadii, result);
}
return ellipsoid;
}
function computeHorizonCullingPointFromPositions(ellipsoid, directionToPoint, positions, result) {
Check_default.typeOf.object("directionToPoint", directionToPoint);
Check_default.defined("positions", positions);
if (!defined_default(result)) {
result = new Cartesian3_default();
}
const scaledSpaceDirectionToPoint = computeScaledSpaceDirectionToPoint(
ellipsoid,
directionToPoint
);
let resultMagnitude = 0;
for (let i = 0, len = positions.length; i < len; ++i) {
const position = positions[i];
const candidateMagnitude = computeMagnitude(
ellipsoid,
position,
scaledSpaceDirectionToPoint
);
if (candidateMagnitude < 0) {
return void 0;
}
resultMagnitude = Math.max(resultMagnitude, candidateMagnitude);
}
return magnitudeToPoint(scaledSpaceDirectionToPoint, resultMagnitude, result);
}
var positionScratch = new Cartesian3_default();
function computeHorizonCullingPointFromVertices(ellipsoid, directionToPoint, vertices, stride, center, result) {
Check_default.typeOf.object("directionToPoint", directionToPoint);
Check_default.defined("vertices", vertices);
Check_default.typeOf.number("stride", stride);
if (!defined_default(result)) {
result = new Cartesian3_default();
}
stride = defaultValue_default(stride, 3);
center = defaultValue_default(center, Cartesian3_default.ZERO);
const scaledSpaceDirectionToPoint = computeScaledSpaceDirectionToPoint(
ellipsoid,
directionToPoint
);
let resultMagnitude = 0;
for (let i = 0, len = vertices.length; i < len; i += stride) {
positionScratch.x = vertices[i] + center.x;
positionScratch.y = vertices[i + 1] + center.y;
positionScratch.z = vertices[i + 2] + center.z;
const candidateMagnitude = computeMagnitude(
ellipsoid,
positionScratch,
scaledSpaceDirectionToPoint
);
if (candidateMagnitude < 0) {
return void 0;
}
resultMagnitude = Math.max(resultMagnitude, candidateMagnitude);
}
return magnitudeToPoint(scaledSpaceDirectionToPoint, resultMagnitude, result);
}
function isScaledSpacePointVisible(occludeeScaledSpacePosition, cameraPositionInScaledSpace, distanceToLimbInScaledSpaceSquared) {
const cv = cameraPositionInScaledSpace;
const vhMagnitudeSquared = distanceToLimbInScaledSpaceSquared;
const vt = Cartesian3_default.subtract(
occludeeScaledSpacePosition,
cv,
scratchCartesian
);
const vtDotVc = -Cartesian3_default.dot(vt, cv);
const isOccluded = vhMagnitudeSquared < 0 ? vtDotVc > 0 : vtDotVc > vhMagnitudeSquared && vtDotVc * vtDotVc / Cartesian3_default.magnitudeSquared(vt) > vhMagnitudeSquared;
return !isOccluded;
}
var scaledSpaceScratch = new Cartesian3_default();
var directionScratch = new Cartesian3_default();
function computeMagnitude(ellipsoid, position, scaledSpaceDirectionToPoint) {
const scaledSpacePosition = ellipsoid.transformPositionToScaledSpace(
position,
scaledSpaceScratch
);
let magnitudeSquared = Cartesian3_default.magnitudeSquared(scaledSpacePosition);
let magnitude = Math.sqrt(magnitudeSquared);
const direction2 = Cartesian3_default.divideByScalar(
scaledSpacePosition,
magnitude,
directionScratch
);
magnitudeSquared = Math.max(1, magnitudeSquared);
magnitude = Math.max(1, magnitude);
const cosAlpha = Cartesian3_default.dot(direction2, scaledSpaceDirectionToPoint);
const sinAlpha = Cartesian3_default.magnitude(
Cartesian3_default.cross(direction2, scaledSpaceDirectionToPoint, direction2)
);
const cosBeta = 1 / magnitude;
const sinBeta = Math.sqrt(magnitudeSquared - 1) * cosBeta;
return 1 / (cosAlpha * cosBeta - sinAlpha * sinBeta);
}
function magnitudeToPoint(scaledSpaceDirectionToPoint, resultMagnitude, result) {
if (resultMagnitude <= 0 || resultMagnitude === 1 / 0 || resultMagnitude !== resultMagnitude) {
return void 0;
}
return Cartesian3_default.multiplyByScalar(
scaledSpaceDirectionToPoint,
resultMagnitude,
result
);
}
var directionToPointScratch = new Cartesian3_default();
function computeScaledSpaceDirectionToPoint(ellipsoid, directionToPoint) {
if (Cartesian3_default.equals(directionToPoint, Cartesian3_default.ZERO)) {
return directionToPoint;
}
ellipsoid.transformPositionToScaledSpace(
directionToPoint,
directionToPointScratch
);
return Cartesian3_default.normalize(directionToPointScratch, directionToPointScratch);
}
var EllipsoidalOccluder_default = EllipsoidalOccluder;
// Source/Core/QuadraticRealPolynomial.js
var QuadraticRealPolynomial = {};
QuadraticRealPolynomial.computeDiscriminant = function(a3, b, c) {
if (typeof a3 !== "number") {
throw new DeveloperError_default("a is a required number.");
}
if (typeof b !== "number") {
throw new DeveloperError_default("b is a required number.");
}
if (typeof c !== "number") {
throw new DeveloperError_default("c is a required number.");
}
const discriminant = b * b - 4 * a3 * c;
return discriminant;
};
function addWithCancellationCheck(left, right, tolerance) {
const difference = left + right;
if (Math_default.sign(left) !== Math_default.sign(right) && Math.abs(difference / Math.max(Math.abs(left), Math.abs(right))) < tolerance) {
return 0;
}
return difference;
}
QuadraticRealPolynomial.computeRealRoots = function(a3, b, c) {
if (typeof a3 !== "number") {
throw new DeveloperError_default("a is a required number.");
}
if (typeof b !== "number") {
throw new DeveloperError_default("b is a required number.");
}
if (typeof c !== "number") {
throw new DeveloperError_default("c is a required number.");
}
let ratio;
if (a3 === 0) {
if (b === 0) {
return [];
}
return [-c / b];
} else if (b === 0) {
if (c === 0) {
return [0, 0];
}
const cMagnitude = Math.abs(c);
const aMagnitude = Math.abs(a3);
if (cMagnitude < aMagnitude && cMagnitude / aMagnitude < Math_default.EPSILON14) {
return [0, 0];
} else if (cMagnitude > aMagnitude && aMagnitude / cMagnitude < Math_default.EPSILON14) {
return [];
}
ratio = -c / a3;
if (ratio < 0) {
return [];
}
const root = Math.sqrt(ratio);
return [-root, root];
} else if (c === 0) {
ratio = -b / a3;
if (ratio < 0) {
return [ratio, 0];
}
return [0, ratio];
}
const b2 = b * b;
const four_ac = 4 * a3 * c;
const radicand = addWithCancellationCheck(b2, -four_ac, Math_default.EPSILON14);
if (radicand < 0) {
return [];
}
const q = -0.5 * addWithCancellationCheck(
b,
Math_default.sign(b) * Math.sqrt(radicand),
Math_default.EPSILON14
);
if (b > 0) {
return [q / a3, c / q];
}
return [c / q, q / a3];
};
var QuadraticRealPolynomial_default = QuadraticRealPolynomial;
// Source/Core/CubicRealPolynomial.js
var CubicRealPolynomial = {};
CubicRealPolynomial.computeDiscriminant = function(a3, b, c, d) {
if (typeof a3 !== "number") {
throw new DeveloperError_default("a is a required number.");
}
if (typeof b !== "number") {
throw new DeveloperError_default("b is a required number.");
}
if (typeof c !== "number") {
throw new DeveloperError_default("c is a required number.");
}
if (typeof d !== "number") {
throw new DeveloperError_default("d is a required number.");
}
const a22 = a3 * a3;
const b2 = b * b;
const c22 = c * c;
const d2 = d * d;
const discriminant = 18 * a3 * b * c * d + b2 * c22 - 27 * a22 * d2 - 4 * (a3 * c22 * c + b2 * b * d);
return discriminant;
};
function computeRealRoots(a3, b, c, d) {
const A = a3;
const B = b / 3;
const C = c / 3;
const D = d;
const AC = A * C;
const BD = B * D;
const B2 = B * B;
const C2 = C * C;
const delta1 = A * C - B2;
const delta2 = A * D - B * C;
const delta3 = B * D - C2;
const discriminant = 4 * delta1 * delta3 - delta2 * delta2;
let temp;
let temp1;
if (discriminant < 0) {
let ABar;
let CBar;
let DBar;
if (B2 * BD >= AC * C2) {
ABar = A;
CBar = delta1;
DBar = -2 * B * delta1 + A * delta2;
} else {
ABar = D;
CBar = delta3;
DBar = -D * delta2 + 2 * C * delta3;
}
const s = DBar < 0 ? -1 : 1;
const temp0 = -s * Math.abs(ABar) * Math.sqrt(-discriminant);
temp1 = -DBar + temp0;
const x = temp1 / 2;
const p = x < 0 ? -Math.pow(-x, 1 / 3) : Math.pow(x, 1 / 3);
const q = temp1 === temp0 ? -p : -CBar / p;
temp = CBar <= 0 ? p + q : -DBar / (p * p + q * q + CBar);
if (B2 * BD >= AC * C2) {
return [(temp - B) / A];
}
return [-D / (temp + C)];
}
const CBarA = delta1;
const DBarA = -2 * B * delta1 + A * delta2;
const CBarD = delta3;
const DBarD = -D * delta2 + 2 * C * delta3;
const squareRootOfDiscriminant = Math.sqrt(discriminant);
const halfSquareRootOf3 = Math.sqrt(3) / 2;
let theta = Math.abs(Math.atan2(A * squareRootOfDiscriminant, -DBarA) / 3);
temp = 2 * Math.sqrt(-CBarA);
let cosine = Math.cos(theta);
temp1 = temp * cosine;
let temp3 = temp * (-cosine / 2 - halfSquareRootOf3 * Math.sin(theta));
const numeratorLarge = temp1 + temp3 > 2 * B ? temp1 - B : temp3 - B;
const denominatorLarge = A;
const root1 = numeratorLarge / denominatorLarge;
theta = Math.abs(Math.atan2(D * squareRootOfDiscriminant, -DBarD) / 3);
temp = 2 * Math.sqrt(-CBarD);
cosine = Math.cos(theta);
temp1 = temp * cosine;
temp3 = temp * (-cosine / 2 - halfSquareRootOf3 * Math.sin(theta));
const numeratorSmall = -D;
const denominatorSmall = temp1 + temp3 < 2 * C ? temp1 + C : temp3 + C;
const root3 = numeratorSmall / denominatorSmall;
const E = denominatorLarge * denominatorSmall;
const F = -numeratorLarge * denominatorSmall - denominatorLarge * numeratorSmall;
const G = numeratorLarge * numeratorSmall;
const root2 = (C * F - B * G) / (-B * F + C * E);
if (root1 <= root2) {
if (root1 <= root3) {
if (root2 <= root3) {
return [root1, root2, root3];
}
return [root1, root3, root2];
}
return [root3, root1, root2];
}
if (root1 <= root3) {
return [root2, root1, root3];
}
if (root2 <= root3) {
return [root2, root3, root1];
}
return [root3, root2, root1];
}
CubicRealPolynomial.computeRealRoots = function(a3, b, c, d) {
if (typeof a3 !== "number") {
throw new DeveloperError_default("a is a required number.");
}
if (typeof b !== "number") {
throw new DeveloperError_default("b is a required number.");
}
if (typeof c !== "number") {
throw new DeveloperError_default("c is a required number.");
}
if (typeof d !== "number") {
throw new DeveloperError_default("d is a required number.");
}
let roots;
let ratio;
if (a3 === 0) {
return QuadraticRealPolynomial_default.computeRealRoots(b, c, d);
} else if (b === 0) {
if (c === 0) {
if (d === 0) {
return [0, 0, 0];
}
ratio = -d / a3;
const root = ratio < 0 ? -Math.pow(-ratio, 1 / 3) : Math.pow(ratio, 1 / 3);
return [root, root, root];
} else if (d === 0) {
roots = QuadraticRealPolynomial_default.computeRealRoots(a3, 0, c);
if (roots.Length === 0) {
return [0];
}
return [roots[0], 0, roots[1]];
}
return computeRealRoots(a3, 0, c, d);
} else if (c === 0) {
if (d === 0) {
ratio = -b / a3;
if (ratio < 0) {
return [ratio, 0, 0];
}
return [0, 0, ratio];
}
return computeRealRoots(a3, b, 0, d);
} else if (d === 0) {
roots = QuadraticRealPolynomial_default.computeRealRoots(a3, b, c);
if (roots.length === 0) {
return [0];
} else if (roots[1] <= 0) {
return [roots[0], roots[1], 0];
} else if (roots[0] >= 0) {
return [0, roots[0], roots[1]];
}
return [roots[0], 0, roots[1]];
}
return computeRealRoots(a3, b, c, d);
};
var CubicRealPolynomial_default = CubicRealPolynomial;
// Source/Core/QuarticRealPolynomial.js
var QuarticRealPolynomial = {};
QuarticRealPolynomial.computeDiscriminant = function(a3, b, c, d, e) {
if (typeof a3 !== "number") {
throw new DeveloperError_default("a is a required number.");
}
if (typeof b !== "number") {
throw new DeveloperError_default("b is a required number.");
}
if (typeof c !== "number") {
throw new DeveloperError_default("c is a required number.");
}
if (typeof d !== "number") {
throw new DeveloperError_default("d is a required number.");
}
if (typeof e !== "number") {
throw new DeveloperError_default("e is a required number.");
}
const a22 = a3 * a3;
const a32 = a22 * a3;
const b2 = b * b;
const b3 = b2 * b;
const c22 = c * c;
const c33 = c22 * c;
const d2 = d * d;
const d3 = d2 * d;
const e2 = e * e;
const e3 = e2 * e;
const discriminant = b2 * c22 * d2 - 4 * b3 * d3 - 4 * a3 * c33 * d2 + 18 * a3 * b * c * d3 - 27 * a22 * d2 * d2 + 256 * a32 * e3 + e * (18 * b3 * c * d - 4 * b2 * c33 + 16 * a3 * c22 * c22 - 80 * a3 * b * c22 * d - 6 * a3 * b2 * d2 + 144 * a22 * c * d2) + e2 * (144 * a3 * b2 * c - 27 * b2 * b2 - 128 * a22 * c22 - 192 * a22 * b * d);
return discriminant;
};
function original(a3, a22, a1, a0) {
const a3Squared = a3 * a3;
const p = a22 - 3 * a3Squared / 8;
const q = a1 - a22 * a3 / 2 + a3Squared * a3 / 8;
const r = a0 - a1 * a3 / 4 + a22 * a3Squared / 16 - 3 * a3Squared * a3Squared / 256;
const cubicRoots = CubicRealPolynomial_default.computeRealRoots(
1,
2 * p,
p * p - 4 * r,
-q * q
);
if (cubicRoots.length > 0) {
const temp = -a3 / 4;
const hSquared = cubicRoots[cubicRoots.length - 1];
if (Math.abs(hSquared) < Math_default.EPSILON14) {
const roots = QuadraticRealPolynomial_default.computeRealRoots(1, p, r);
if (roots.length === 2) {
const root0 = roots[0];
const root1 = roots[1];
let y;
if (root0 >= 0 && root1 >= 0) {
const y0 = Math.sqrt(root0);
const y1 = Math.sqrt(root1);
return [temp - y1, temp - y0, temp + y0, temp + y1];
} else if (root0 >= 0 && root1 < 0) {
y = Math.sqrt(root0);
return [temp - y, temp + y];
} else if (root0 < 0 && root1 >= 0) {
y = Math.sqrt(root1);
return [temp - y, temp + y];
}
}
return [];
} else if (hSquared > 0) {
const h = Math.sqrt(hSquared);
const m = (p + hSquared - q / h) / 2;
const n = (p + hSquared + q / h) / 2;
const roots1 = QuadraticRealPolynomial_default.computeRealRoots(1, h, m);
const roots2 = QuadraticRealPolynomial_default.computeRealRoots(1, -h, n);
if (roots1.length !== 0) {
roots1[0] += temp;
roots1[1] += temp;
if (roots2.length !== 0) {
roots2[0] += temp;
roots2[1] += temp;
if (roots1[1] <= roots2[0]) {
return [roots1[0], roots1[1], roots2[0], roots2[1]];
} else if (roots2[1] <= roots1[0]) {
return [roots2[0], roots2[1], roots1[0], roots1[1]];
} else if (roots1[0] >= roots2[0] && roots1[1] <= roots2[1]) {
return [roots2[0], roots1[0], roots1[1], roots2[1]];
} else if (roots2[0] >= roots1[0] && roots2[1] <= roots1[1]) {
return [roots1[0], roots2[0], roots2[1], roots1[1]];
} else if (roots1[0] > roots2[0] && roots1[0] < roots2[1]) {
return [roots2[0], roots1[0], roots2[1], roots1[1]];
}
return [roots1[0], roots2[0], roots1[1], roots2[1]];
}
return roots1;
}
if (roots2.length !== 0) {
roots2[0] += temp;
roots2[1] += temp;
return roots2;
}
return [];
}
}
return [];
}
function neumark(a3, a22, a1, a0) {
const a1Squared = a1 * a1;
const a2Squared = a22 * a22;
const a3Squared = a3 * a3;
const p = -2 * a22;
const q = a1 * a3 + a2Squared - 4 * a0;
const r = a3Squared * a0 - a1 * a22 * a3 + a1Squared;
const cubicRoots = CubicRealPolynomial_default.computeRealRoots(1, p, q, r);
if (cubicRoots.length > 0) {
const y = cubicRoots[0];
const temp = a22 - y;
const tempSquared = temp * temp;
const g1 = a3 / 2;
const h1 = temp / 2;
const m = tempSquared - 4 * a0;
const mError = tempSquared + 4 * Math.abs(a0);
const n = a3Squared - 4 * y;
const nError = a3Squared + 4 * Math.abs(y);
let g2;
let h2;
if (y < 0 || m * nError < n * mError) {
const squareRootOfN = Math.sqrt(n);
g2 = squareRootOfN / 2;
h2 = squareRootOfN === 0 ? 0 : (a3 * h1 - a1) / squareRootOfN;
} else {
const squareRootOfM = Math.sqrt(m);
g2 = squareRootOfM === 0 ? 0 : (a3 * h1 - a1) / squareRootOfM;
h2 = squareRootOfM / 2;
}
let G;
let g;
if (g1 === 0 && g2 === 0) {
G = 0;
g = 0;
} else if (Math_default.sign(g1) === Math_default.sign(g2)) {
G = g1 + g2;
g = y / G;
} else {
g = g1 - g2;
G = y / g;
}
let H;
let h;
if (h1 === 0 && h2 === 0) {
H = 0;
h = 0;
} else if (Math_default.sign(h1) === Math_default.sign(h2)) {
H = h1 + h2;
h = a0 / H;
} else {
h = h1 - h2;
H = a0 / h;
}
const roots1 = QuadraticRealPolynomial_default.computeRealRoots(1, G, H);
const roots2 = QuadraticRealPolynomial_default.computeRealRoots(1, g, h);
if (roots1.length !== 0) {
if (roots2.length !== 0) {
if (roots1[1] <= roots2[0]) {
return [roots1[0], roots1[1], roots2[0], roots2[1]];
} else if (roots2[1] <= roots1[0]) {
return [roots2[0], roots2[1], roots1[0], roots1[1]];
} else if (roots1[0] >= roots2[0] && roots1[1] <= roots2[1]) {
return [roots2[0], roots1[0], roots1[1], roots2[1]];
} else if (roots2[0] >= roots1[0] && roots2[1] <= roots1[1]) {
return [roots1[0], roots2[0], roots2[1], roots1[1]];
} else if (roots1[0] > roots2[0] && roots1[0] < roots2[1]) {
return [roots2[0], roots1[0], roots2[1], roots1[1]];
}
return [roots1[0], roots2[0], roots1[1], roots2[1]];
}
return roots1;
}
if (roots2.length !== 0) {
return roots2;
}
}
return [];
}
QuarticRealPolynomial.computeRealRoots = function(a3, b, c, d, e) {
if (typeof a3 !== "number") {
throw new DeveloperError_default("a is a required number.");
}
if (typeof b !== "number") {
throw new DeveloperError_default("b is a required number.");
}
if (typeof c !== "number") {
throw new DeveloperError_default("c is a required number.");
}
if (typeof d !== "number") {
throw new DeveloperError_default("d is a required number.");
}
if (typeof e !== "number") {
throw new DeveloperError_default("e is a required number.");
}
if (Math.abs(a3) < Math_default.EPSILON15) {
return CubicRealPolynomial_default.computeRealRoots(b, c, d, e);
}
const a32 = b / a3;
const a22 = c / a3;
const a1 = d / a3;
const a0 = e / a3;
let k = a32 < 0 ? 1 : 0;
k += a22 < 0 ? k + 1 : k;
k += a1 < 0 ? k + 1 : k;
k += a0 < 0 ? k + 1 : k;
switch (k) {
case 0:
return original(a32, a22, a1, a0);
case 1:
return neumark(a32, a22, a1, a0);
case 2:
return neumark(a32, a22, a1, a0);
case 3:
return original(a32, a22, a1, a0);
case 4:
return original(a32, a22, a1, a0);
case 5:
return neumark(a32, a22, a1, a0);
case 6:
return original(a32, a22, a1, a0);
case 7:
return original(a32, a22, a1, a0);
case 8:
return neumark(a32, a22, a1, a0);
case 9:
return original(a32, a22, a1, a0);
case 10:
return original(a32, a22, a1, a0);
case 11:
return neumark(a32, a22, a1, a0);
case 12:
return original(a32, a22, a1, a0);
case 13:
return original(a32, a22, a1, a0);
case 14:
return original(a32, a22, a1, a0);
case 15:
return original(a32, a22, a1, a0);
default:
return void 0;
}
};
var QuarticRealPolynomial_default = QuarticRealPolynomial;
// Source/Core/Ray.js
function Ray(origin, direction2) {
direction2 = Cartesian3_default.clone(defaultValue_default(direction2, Cartesian3_default.ZERO));
if (!Cartesian3_default.equals(direction2, Cartesian3_default.ZERO)) {
Cartesian3_default.normalize(direction2, direction2);
}
this.origin = Cartesian3_default.clone(defaultValue_default(origin, Cartesian3_default.ZERO));
this.direction = direction2;
}
Ray.clone = function(ray, result) {
if (!defined_default(ray)) {
return void 0;
}
if (!defined_default(result)) {
return new Ray(ray.origin, ray.direction);
}
result.origin = Cartesian3_default.clone(ray.origin);
result.direction = Cartesian3_default.clone(ray.direction);
return result;
};
Ray.getPoint = function(ray, t, result) {
Check_default.typeOf.object("ray", ray);
Check_default.typeOf.number("t", t);
if (!defined_default(result)) {
result = new Cartesian3_default();
}
result = Cartesian3_default.multiplyByScalar(ray.direction, t, result);
return Cartesian3_default.add(ray.origin, result, result);
};
var Ray_default = Ray;
// Source/Core/IntersectionTests.js
var IntersectionTests = {};
IntersectionTests.rayPlane = function(ray, plane, result) {
if (!defined_default(ray)) {
throw new DeveloperError_default("ray is required.");
}
if (!defined_default(plane)) {
throw new DeveloperError_default("plane is required.");
}
if (!defined_default(result)) {
result = new Cartesian3_default();
}
const origin = ray.origin;
const direction2 = ray.direction;
const normal2 = plane.normal;
const denominator = Cartesian3_default.dot(normal2, direction2);
if (Math.abs(denominator) < Math_default.EPSILON15) {
return void 0;
}
const t = (-plane.distance - Cartesian3_default.dot(normal2, origin)) / denominator;
if (t < 0) {
return void 0;
}
result = Cartesian3_default.multiplyByScalar(direction2, t, result);
return Cartesian3_default.add(origin, result, result);
};
var scratchEdge0 = new Cartesian3_default();
var scratchEdge1 = new Cartesian3_default();
var scratchPVec = new Cartesian3_default();
var scratchTVec = new Cartesian3_default();
var scratchQVec = new Cartesian3_default();
IntersectionTests.rayTriangleParametric = function(ray, p0, p1, p2, cullBackFaces) {
if (!defined_default(ray)) {
throw new DeveloperError_default("ray is required.");
}
if (!defined_default(p0)) {
throw new DeveloperError_default("p0 is required.");
}
if (!defined_default(p1)) {
throw new DeveloperError_default("p1 is required.");
}
if (!defined_default(p2)) {
throw new DeveloperError_default("p2 is required.");
}
cullBackFaces = defaultValue_default(cullBackFaces, false);
const origin = ray.origin;
const direction2 = ray.direction;
const edge0 = Cartesian3_default.subtract(p1, p0, scratchEdge0);
const edge1 = Cartesian3_default.subtract(p2, p0, scratchEdge1);
const p = Cartesian3_default.cross(direction2, edge1, scratchPVec);
const det = Cartesian3_default.dot(edge0, p);
let tvec;
let q;
let u3;
let v7;
let t;
if (cullBackFaces) {
if (det < Math_default.EPSILON6) {
return void 0;
}
tvec = Cartesian3_default.subtract(origin, p0, scratchTVec);
u3 = Cartesian3_default.dot(tvec, p);
if (u3 < 0 || u3 > det) {
return void 0;
}
q = Cartesian3_default.cross(tvec, edge0, scratchQVec);
v7 = Cartesian3_default.dot(direction2, q);
if (v7 < 0 || u3 + v7 > det) {
return void 0;
}
t = Cartesian3_default.dot(edge1, q) / det;
} else {
if (Math.abs(det) < Math_default.EPSILON6) {
return void 0;
}
const invDet = 1 / det;
tvec = Cartesian3_default.subtract(origin, p0, scratchTVec);
u3 = Cartesian3_default.dot(tvec, p) * invDet;
if (u3 < 0 || u3 > 1) {
return void 0;
}
q = Cartesian3_default.cross(tvec, edge0, scratchQVec);
v7 = Cartesian3_default.dot(direction2, q) * invDet;
if (v7 < 0 || u3 + v7 > 1) {
return void 0;
}
t = Cartesian3_default.dot(edge1, q) * invDet;
}
return t;
};
IntersectionTests.rayTriangle = function(ray, p0, p1, p2, cullBackFaces, result) {
const t = IntersectionTests.rayTriangleParametric(
ray,
p0,
p1,
p2,
cullBackFaces
);
if (!defined_default(t) || t < 0) {
return void 0;
}
if (!defined_default(result)) {
result = new Cartesian3_default();
}
Cartesian3_default.multiplyByScalar(ray.direction, t, result);
return Cartesian3_default.add(ray.origin, result, result);
};
var scratchLineSegmentTriangleRay = new Ray_default();
IntersectionTests.lineSegmentTriangle = function(v02, v13, p0, p1, p2, cullBackFaces, result) {
if (!defined_default(v02)) {
throw new DeveloperError_default("v0 is required.");
}
if (!defined_default(v13)) {
throw new DeveloperError_default("v1 is required.");
}
if (!defined_default(p0)) {
throw new DeveloperError_default("p0 is required.");
}
if (!defined_default(p1)) {
throw new DeveloperError_default("p1 is required.");
}
if (!defined_default(p2)) {
throw new DeveloperError_default("p2 is required.");
}
const ray = scratchLineSegmentTriangleRay;
Cartesian3_default.clone(v02, ray.origin);
Cartesian3_default.subtract(v13, v02, ray.direction);
Cartesian3_default.normalize(ray.direction, ray.direction);
const t = IntersectionTests.rayTriangleParametric(
ray,
p0,
p1,
p2,
cullBackFaces
);
if (!defined_default(t) || t < 0 || t > Cartesian3_default.distance(v02, v13)) {
return void 0;
}
if (!defined_default(result)) {
result = new Cartesian3_default();
}
Cartesian3_default.multiplyByScalar(ray.direction, t, result);
return Cartesian3_default.add(ray.origin, result, result);
};
function solveQuadratic(a3, b, c, result) {
const det = b * b - 4 * a3 * c;
if (det < 0) {
return void 0;
} else if (det > 0) {
const denom = 1 / (2 * a3);
const disc = Math.sqrt(det);
const root0 = (-b + disc) * denom;
const root1 = (-b - disc) * denom;
if (root0 < root1) {
result.root0 = root0;
result.root1 = root1;
} else {
result.root0 = root1;
result.root1 = root0;
}
return result;
}
const root = -b / (2 * a3);
if (root === 0) {
return void 0;
}
result.root0 = result.root1 = root;
return result;
}
var raySphereRoots = {
root0: 0,
root1: 0
};
function raySphere(ray, sphere, result) {
if (!defined_default(result)) {
result = new Interval_default();
}
const origin = ray.origin;
const direction2 = ray.direction;
const center = sphere.center;
const radiusSquared = sphere.radius * sphere.radius;
const diff = Cartesian3_default.subtract(origin, center, scratchPVec);
const a3 = Cartesian3_default.dot(direction2, direction2);
const b = 2 * Cartesian3_default.dot(direction2, diff);
const c = Cartesian3_default.magnitudeSquared(diff) - radiusSquared;
const roots = solveQuadratic(a3, b, c, raySphereRoots);
if (!defined_default(roots)) {
return void 0;
}
result.start = roots.root0;
result.stop = roots.root1;
return result;
}
IntersectionTests.raySphere = function(ray, sphere, result) {
if (!defined_default(ray)) {
throw new DeveloperError_default("ray is required.");
}
if (!defined_default(sphere)) {
throw new DeveloperError_default("sphere is required.");
}
result = raySphere(ray, sphere, result);
if (!defined_default(result) || result.stop < 0) {
return void 0;
}
result.start = Math.max(result.start, 0);
return result;
};
var scratchLineSegmentRay = new Ray_default();
IntersectionTests.lineSegmentSphere = function(p0, p1, sphere, result) {
if (!defined_default(p0)) {
throw new DeveloperError_default("p0 is required.");
}
if (!defined_default(p1)) {
throw new DeveloperError_default("p1 is required.");
}
if (!defined_default(sphere)) {
throw new DeveloperError_default("sphere is required.");
}
const ray = scratchLineSegmentRay;
Cartesian3_default.clone(p0, ray.origin);
const direction2 = Cartesian3_default.subtract(p1, p0, ray.direction);
const maxT = Cartesian3_default.magnitude(direction2);
Cartesian3_default.normalize(direction2, direction2);
result = raySphere(ray, sphere, result);
if (!defined_default(result) || result.stop < 0 || result.start > maxT) {
return void 0;
}
result.start = Math.max(result.start, 0);
result.stop = Math.min(result.stop, maxT);
return result;
};
var scratchQ = new Cartesian3_default();
var scratchW = new Cartesian3_default();
IntersectionTests.rayEllipsoid = function(ray, ellipsoid) {
if (!defined_default(ray)) {
throw new DeveloperError_default("ray is required.");
}
if (!defined_default(ellipsoid)) {
throw new DeveloperError_default("ellipsoid is required.");
}
const inverseRadii = ellipsoid.oneOverRadii;
const q = Cartesian3_default.multiplyComponents(inverseRadii, ray.origin, scratchQ);
const w = Cartesian3_default.multiplyComponents(
inverseRadii,
ray.direction,
scratchW
);
const q22 = Cartesian3_default.magnitudeSquared(q);
const qw = Cartesian3_default.dot(q, w);
let difference, w2, product, discriminant, temp;
if (q22 > 1) {
if (qw >= 0) {
return void 0;
}
const qw2 = qw * qw;
difference = q22 - 1;
w2 = Cartesian3_default.magnitudeSquared(w);
product = w2 * difference;
if (qw2 < product) {
return void 0;
} else if (qw2 > product) {
discriminant = qw * qw - product;
temp = -qw + Math.sqrt(discriminant);
const root0 = temp / w2;
const root1 = difference / temp;
if (root0 < root1) {
return new Interval_default(root0, root1);
}
return {
start: root1,
stop: root0
};
}
const root = Math.sqrt(difference / w2);
return new Interval_default(root, root);
} else if (q22 < 1) {
difference = q22 - 1;
w2 = Cartesian3_default.magnitudeSquared(w);
product = w2 * difference;
discriminant = qw * qw - product;
temp = -qw + Math.sqrt(discriminant);
return new Interval_default(0, temp / w2);
}
if (qw < 0) {
w2 = Cartesian3_default.magnitudeSquared(w);
return new Interval_default(0, -qw / w2);
}
return void 0;
};
function addWithCancellationCheck2(left, right, tolerance) {
const difference = left + right;
if (Math_default.sign(left) !== Math_default.sign(right) && Math.abs(difference / Math.max(Math.abs(left), Math.abs(right))) < tolerance) {
return 0;
}
return difference;
}
function quadraticVectorExpression(A, b, c, x, w) {
const xSquared = x * x;
const wSquared = w * w;
const l2 = (A[Matrix3_default.COLUMN1ROW1] - A[Matrix3_default.COLUMN2ROW2]) * wSquared;
const l1 = w * (x * addWithCancellationCheck2(
A[Matrix3_default.COLUMN1ROW0],
A[Matrix3_default.COLUMN0ROW1],
Math_default.EPSILON15
) + b.y);
const l0 = A[Matrix3_default.COLUMN0ROW0] * xSquared + A[Matrix3_default.COLUMN2ROW2] * wSquared + x * b.x + c;
const r1 = wSquared * addWithCancellationCheck2(
A[Matrix3_default.COLUMN2ROW1],
A[Matrix3_default.COLUMN1ROW2],
Math_default.EPSILON15
);
const r0 = w * (x * addWithCancellationCheck2(A[Matrix3_default.COLUMN2ROW0], A[Matrix3_default.COLUMN0ROW2]) + b.z);
let cosines;
const solutions = [];
if (r0 === 0 && r1 === 0) {
cosines = QuadraticRealPolynomial_default.computeRealRoots(l2, l1, l0);
if (cosines.length === 0) {
return solutions;
}
const cosine0 = cosines[0];
const sine0 = Math.sqrt(Math.max(1 - cosine0 * cosine0, 0));
solutions.push(new Cartesian3_default(x, w * cosine0, w * -sine0));
solutions.push(new Cartesian3_default(x, w * cosine0, w * sine0));
if (cosines.length === 2) {
const cosine1 = cosines[1];
const sine1 = Math.sqrt(Math.max(1 - cosine1 * cosine1, 0));
solutions.push(new Cartesian3_default(x, w * cosine1, w * -sine1));
solutions.push(new Cartesian3_default(x, w * cosine1, w * sine1));
}
return solutions;
}
const r0Squared = r0 * r0;
const r1Squared = r1 * r1;
const l2Squared = l2 * l2;
const r0r1 = r0 * r1;
const c42 = l2Squared + r1Squared;
const c33 = 2 * (l1 * l2 + r0r1);
const c22 = 2 * l0 * l2 + l1 * l1 - r1Squared + r0Squared;
const c14 = 2 * (l0 * l1 - r0r1);
const c0 = l0 * l0 - r0Squared;
if (c42 === 0 && c33 === 0 && c22 === 0 && c14 === 0) {
return solutions;
}
cosines = QuarticRealPolynomial_default.computeRealRoots(c42, c33, c22, c14, c0);
const length3 = cosines.length;
if (length3 === 0) {
return solutions;
}
for (let i = 0; i < length3; ++i) {
const cosine = cosines[i];
const cosineSquared = cosine * cosine;
const sineSquared = Math.max(1 - cosineSquared, 0);
const sine = Math.sqrt(sineSquared);
let left;
if (Math_default.sign(l2) === Math_default.sign(l0)) {
left = addWithCancellationCheck2(
l2 * cosineSquared + l0,
l1 * cosine,
Math_default.EPSILON12
);
} else if (Math_default.sign(l0) === Math_default.sign(l1 * cosine)) {
left = addWithCancellationCheck2(
l2 * cosineSquared,
l1 * cosine + l0,
Math_default.EPSILON12
);
} else {
left = addWithCancellationCheck2(
l2 * cosineSquared + l1 * cosine,
l0,
Math_default.EPSILON12
);
}
const right = addWithCancellationCheck2(
r1 * cosine,
r0,
Math_default.EPSILON15
);
const product = left * right;
if (product < 0) {
solutions.push(new Cartesian3_default(x, w * cosine, w * sine));
} else if (product > 0) {
solutions.push(new Cartesian3_default(x, w * cosine, w * -sine));
} else if (sine !== 0) {
solutions.push(new Cartesian3_default(x, w * cosine, w * -sine));
solutions.push(new Cartesian3_default(x, w * cosine, w * sine));
++i;
} else {
solutions.push(new Cartesian3_default(x, w * cosine, w * sine));
}
}
return solutions;
}
var firstAxisScratch = new Cartesian3_default();
var secondAxisScratch = new Cartesian3_default();
var thirdAxisScratch = new Cartesian3_default();
var referenceScratch = new Cartesian3_default();
var bCart = new Cartesian3_default();
var bScratch = new Matrix3_default();
var btScratch = new Matrix3_default();
var diScratch = new Matrix3_default();
var dScratch = new Matrix3_default();
var cScratch = new Matrix3_default();
var tempMatrix = new Matrix3_default();
var aScratch = new Matrix3_default();
var sScratch = new Cartesian3_default();
var closestScratch = new Cartesian3_default();
var surfPointScratch = new Cartographic_default();
IntersectionTests.grazingAltitudeLocation = function(ray, ellipsoid) {
if (!defined_default(ray)) {
throw new DeveloperError_default("ray is required.");
}
if (!defined_default(ellipsoid)) {
throw new DeveloperError_default("ellipsoid is required.");
}
const position = ray.origin;
const direction2 = ray.direction;
if (!Cartesian3_default.equals(position, Cartesian3_default.ZERO)) {
const normal2 = ellipsoid.geodeticSurfaceNormal(position, firstAxisScratch);
if (Cartesian3_default.dot(direction2, normal2) >= 0) {
return position;
}
}
const intersects = defined_default(this.rayEllipsoid(ray, ellipsoid));
const f = ellipsoid.transformPositionToScaledSpace(
direction2,
firstAxisScratch
);
const firstAxis = Cartesian3_default.normalize(f, f);
const reference = Cartesian3_default.mostOrthogonalAxis(f, referenceScratch);
const secondAxis = Cartesian3_default.normalize(
Cartesian3_default.cross(reference, firstAxis, secondAxisScratch),
secondAxisScratch
);
const thirdAxis = Cartesian3_default.normalize(
Cartesian3_default.cross(firstAxis, secondAxis, thirdAxisScratch),
thirdAxisScratch
);
const B = bScratch;
B[0] = firstAxis.x;
B[1] = firstAxis.y;
B[2] = firstAxis.z;
B[3] = secondAxis.x;
B[4] = secondAxis.y;
B[5] = secondAxis.z;
B[6] = thirdAxis.x;
B[7] = thirdAxis.y;
B[8] = thirdAxis.z;
const B_T = Matrix3_default.transpose(B, btScratch);
const D_I = Matrix3_default.fromScale(ellipsoid.radii, diScratch);
const D = Matrix3_default.fromScale(ellipsoid.oneOverRadii, dScratch);
const C = cScratch;
C[0] = 0;
C[1] = -direction2.z;
C[2] = direction2.y;
C[3] = direction2.z;
C[4] = 0;
C[5] = -direction2.x;
C[6] = -direction2.y;
C[7] = direction2.x;
C[8] = 0;
const temp = Matrix3_default.multiply(
Matrix3_default.multiply(B_T, D, tempMatrix),
C,
tempMatrix
);
const A = Matrix3_default.multiply(
Matrix3_default.multiply(temp, D_I, aScratch),
B,
aScratch
);
const b = Matrix3_default.multiplyByVector(temp, position, bCart);
const solutions = quadraticVectorExpression(
A,
Cartesian3_default.negate(b, firstAxisScratch),
0,
0,
1
);
let s;
let altitude;
const length3 = solutions.length;
if (length3 > 0) {
let closest = Cartesian3_default.clone(Cartesian3_default.ZERO, closestScratch);
let maximumValue = Number.NEGATIVE_INFINITY;
for (let i = 0; i < length3; ++i) {
s = Matrix3_default.multiplyByVector(
D_I,
Matrix3_default.multiplyByVector(B, solutions[i], sScratch),
sScratch
);
const v7 = Cartesian3_default.normalize(
Cartesian3_default.subtract(s, position, referenceScratch),
referenceScratch
);
const dotProduct = Cartesian3_default.dot(v7, direction2);
if (dotProduct > maximumValue) {
maximumValue = dotProduct;
closest = Cartesian3_default.clone(s, closest);
}
}
const surfacePoint = ellipsoid.cartesianToCartographic(
closest,
surfPointScratch
);
maximumValue = Math_default.clamp(maximumValue, 0, 1);
altitude = Cartesian3_default.magnitude(
Cartesian3_default.subtract(closest, position, referenceScratch)
) * Math.sqrt(1 - maximumValue * maximumValue);
altitude = intersects ? -altitude : altitude;
surfacePoint.height = altitude;
return ellipsoid.cartographicToCartesian(surfacePoint, new Cartesian3_default());
}
return void 0;
};
var lineSegmentPlaneDifference = new Cartesian3_default();
IntersectionTests.lineSegmentPlane = function(endPoint0, endPoint1, plane, result) {
if (!defined_default(endPoint0)) {
throw new DeveloperError_default("endPoint0 is required.");
}
if (!defined_default(endPoint1)) {
throw new DeveloperError_default("endPoint1 is required.");
}
if (!defined_default(plane)) {
throw new DeveloperError_default("plane is required.");
}
if (!defined_default(result)) {
result = new Cartesian3_default();
}
const difference = Cartesian3_default.subtract(
endPoint1,
endPoint0,
lineSegmentPlaneDifference
);
const normal2 = plane.normal;
const nDotDiff = Cartesian3_default.dot(normal2, difference);
if (Math.abs(nDotDiff) < Math_default.EPSILON6) {
return void 0;
}
const nDotP0 = Cartesian3_default.dot(normal2, endPoint0);
const t = -(plane.distance + nDotP0) / nDotDiff;
if (t < 0 || t > 1) {
return void 0;
}
Cartesian3_default.multiplyByScalar(difference, t, result);
Cartesian3_default.add(endPoint0, result, result);
return result;
};
IntersectionTests.trianglePlaneIntersection = function(p0, p1, p2, plane) {
if (!defined_default(p0) || !defined_default(p1) || !defined_default(p2) || !defined_default(plane)) {
throw new DeveloperError_default("p0, p1, p2, and plane are required.");
}
const planeNormal = plane.normal;
const planeD = plane.distance;
const p0Behind = Cartesian3_default.dot(planeNormal, p0) + planeD < 0;
const p1Behind = Cartesian3_default.dot(planeNormal, p1) + planeD < 0;
const p2Behind = Cartesian3_default.dot(planeNormal, p2) + planeD < 0;
let numBehind = 0;
numBehind += p0Behind ? 1 : 0;
numBehind += p1Behind ? 1 : 0;
numBehind += p2Behind ? 1 : 0;
let u12, u22;
if (numBehind === 1 || numBehind === 2) {
u12 = new Cartesian3_default();
u22 = new Cartesian3_default();
}
if (numBehind === 1) {
if (p0Behind) {
IntersectionTests.lineSegmentPlane(p0, p1, plane, u12);
IntersectionTests.lineSegmentPlane(p0, p2, plane, u22);
return {
positions: [p0, p1, p2, u12, u22],
indices: [
0,
3,
4,
1,
2,
4,
1,
4,
3
]
};
} else if (p1Behind) {
IntersectionTests.lineSegmentPlane(p1, p2, plane, u12);
IntersectionTests.lineSegmentPlane(p1, p0, plane, u22);
return {
positions: [p0, p1, p2, u12, u22],
indices: [
1,
3,
4,
2,
0,
4,
2,
4,
3
]
};
} else if (p2Behind) {
IntersectionTests.lineSegmentPlane(p2, p0, plane, u12);
IntersectionTests.lineSegmentPlane(p2, p1, plane, u22);
return {
positions: [p0, p1, p2, u12, u22],
indices: [
2,
3,
4,
0,
1,
4,
0,
4,
3
]
};
}
} else if (numBehind === 2) {
if (!p0Behind) {
IntersectionTests.lineSegmentPlane(p1, p0, plane, u12);
IntersectionTests.lineSegmentPlane(p2, p0, plane, u22);
return {
positions: [p0, p1, p2, u12, u22],
indices: [
1,
2,
4,
1,
4,
3,
0,
3,
4
]
};
} else if (!p1Behind) {
IntersectionTests.lineSegmentPlane(p2, p1, plane, u12);
IntersectionTests.lineSegmentPlane(p0, p1, plane, u22);
return {
positions: [p0, p1, p2, u12, u22],
indices: [
2,
0,
4,
2,
4,
3,
1,
3,
4
]
};
} else if (!p2Behind) {
IntersectionTests.lineSegmentPlane(p0, p2, plane, u12);
IntersectionTests.lineSegmentPlane(p1, p2, plane, u22);
return {
positions: [p0, p1, p2, u12, u22],
indices: [
0,
1,
4,
0,
4,
3,
2,
3,
4
]
};
}
}
return void 0;
};
var IntersectionTests_default = IntersectionTests;
// Source/Core/Plane.js
function Plane(normal2, distance2) {
Check_default.typeOf.object("normal", normal2);
if (!Math_default.equalsEpsilon(
Cartesian3_default.magnitude(normal2),
1,
Math_default.EPSILON6
)) {
throw new DeveloperError_default("normal must be normalized.");
}
Check_default.typeOf.number("distance", distance2);
this.normal = Cartesian3_default.clone(normal2);
this.distance = distance2;
}
Plane.fromPointNormal = function(point, normal2, result) {
Check_default.typeOf.object("point", point);
Check_default.typeOf.object("normal", normal2);
if (!Math_default.equalsEpsilon(
Cartesian3_default.magnitude(normal2),
1,
Math_default.EPSILON6
)) {
throw new DeveloperError_default("normal must be normalized.");
}
const distance2 = -Cartesian3_default.dot(normal2, point);
if (!defined_default(result)) {
return new Plane(normal2, distance2);
}
Cartesian3_default.clone(normal2, result.normal);
result.distance = distance2;
return result;
};
var scratchNormal = new Cartesian3_default();
Plane.fromCartesian4 = function(coefficients, result) {
Check_default.typeOf.object("coefficients", coefficients);
const normal2 = Cartesian3_default.fromCartesian4(coefficients, scratchNormal);
const distance2 = coefficients.w;
if (!Math_default.equalsEpsilon(
Cartesian3_default.magnitude(normal2),
1,
Math_default.EPSILON6
)) {
throw new DeveloperError_default("normal must be normalized.");
}
if (!defined_default(result)) {
return new Plane(normal2, distance2);
}
Cartesian3_default.clone(normal2, result.normal);
result.distance = distance2;
return result;
};
Plane.getPointDistance = function(plane, point) {
Check_default.typeOf.object("plane", plane);
Check_default.typeOf.object("point", point);
return Cartesian3_default.dot(plane.normal, point) + plane.distance;
};
var scratchCartesian2 = new Cartesian3_default();
Plane.projectPointOntoPlane = function(plane, point, result) {
Check_default.typeOf.object("plane", plane);
Check_default.typeOf.object("point", point);
if (!defined_default(result)) {
result = new Cartesian3_default();
}
const pointDistance = Plane.getPointDistance(plane, point);
const scaledNormal = Cartesian3_default.multiplyByScalar(
plane.normal,
pointDistance,
scratchCartesian2
);
return Cartesian3_default.subtract(point, scaledNormal, result);
};
var scratchInverseTranspose = new Matrix4_default();
var scratchPlaneCartesian4 = new Cartesian4_default();
var scratchTransformNormal = new Cartesian3_default();
Plane.transform = function(plane, transform3, result) {
Check_default.typeOf.object("plane", plane);
Check_default.typeOf.object("transform", transform3);
const normal2 = plane.normal;
const distance2 = plane.distance;
const inverseTranspose2 = Matrix4_default.inverseTranspose(
transform3,
scratchInverseTranspose
);
let planeAsCartesian4 = Cartesian4_default.fromElements(
normal2.x,
normal2.y,
normal2.z,
distance2,
scratchPlaneCartesian4
);
planeAsCartesian4 = Matrix4_default.multiplyByVector(
inverseTranspose2,
planeAsCartesian4,
planeAsCartesian4
);
const transformedNormal = Cartesian3_default.fromCartesian4(
planeAsCartesian4,
scratchTransformNormal
);
planeAsCartesian4 = Cartesian4_default.divideByScalar(
planeAsCartesian4,
Cartesian3_default.magnitude(transformedNormal),
planeAsCartesian4
);
return Plane.fromCartesian4(planeAsCartesian4, result);
};
Plane.clone = function(plane, result) {
Check_default.typeOf.object("plane", plane);
if (!defined_default(result)) {
return new Plane(plane.normal, plane.distance);
}
Cartesian3_default.clone(plane.normal, result.normal);
result.distance = plane.distance;
return result;
};
Plane.equals = function(left, right) {
Check_default.typeOf.object("left", left);
Check_default.typeOf.object("right", right);
return left.distance === right.distance && Cartesian3_default.equals(left.normal, right.normal);
};
Plane.ORIGIN_XY_PLANE = Object.freeze(new Plane(Cartesian3_default.UNIT_Z, 0));
Plane.ORIGIN_YZ_PLANE = Object.freeze(new Plane(Cartesian3_default.UNIT_X, 0));
Plane.ORIGIN_ZX_PLANE = Object.freeze(new Plane(Cartesian3_default.UNIT_Y, 0));
var Plane_default = Plane;
// Source/Core/binarySearch.js
function binarySearch(array, itemToFind, comparator) {
Check_default.defined("array", array);
Check_default.defined("itemToFind", itemToFind);
Check_default.defined("comparator", comparator);
let low = 0;
let high = array.length - 1;
let i;
let comparison;
while (low <= high) {
i = ~~((low + high) / 2);
comparison = comparator(array[i], itemToFind);
if (comparison < 0) {
low = i + 1;
continue;
}
if (comparison > 0) {
high = i - 1;
continue;
}
return i;
}
return ~(high + 1);
}
var binarySearch_default = binarySearch;
// Source/Core/EarthOrientationParametersSample.js
function EarthOrientationParametersSample(xPoleWander, yPoleWander, xPoleOffset, yPoleOffset, ut1MinusUtc) {
this.xPoleWander = xPoleWander;
this.yPoleWander = yPoleWander;
this.xPoleOffset = xPoleOffset;
this.yPoleOffset = yPoleOffset;
this.ut1MinusUtc = ut1MinusUtc;
}
var EarthOrientationParametersSample_default = EarthOrientationParametersSample;
// Source/Core/GregorianDate.js
function GregorianDate(year, month, day, hour, minute, second, millisecond, isLeapSecond) {
this.year = year;
this.month = month;
this.day = day;
this.hour = hour;
this.minute = minute;
this.second = second;
this.millisecond = millisecond;
this.isLeapSecond = isLeapSecond;
}
var GregorianDate_default = GregorianDate;
// Source/Core/isLeapYear.js
function isLeapYear(year) {
if (year === null || isNaN(year)) {
throw new DeveloperError_default("year is required and must be a number.");
}
return year % 4 === 0 && year % 100 !== 0 || year % 400 === 0;
}
var isLeapYear_default = isLeapYear;
// Source/Core/LeapSecond.js
function LeapSecond(date, offset2) {
this.julianDate = date;
this.offset = offset2;
}
var LeapSecond_default = LeapSecond;
// Source/Core/TimeConstants.js
var TimeConstants = {
SECONDS_PER_MILLISECOND: 1e-3,
SECONDS_PER_MINUTE: 60,
MINUTES_PER_HOUR: 60,
HOURS_PER_DAY: 24,
SECONDS_PER_HOUR: 3600,
MINUTES_PER_DAY: 1440,
SECONDS_PER_DAY: 86400,
DAYS_PER_JULIAN_CENTURY: 36525,
PICOSECOND: 1e-9,
MODIFIED_JULIAN_DATE_DIFFERENCE: 24000005e-1
};
var TimeConstants_default = Object.freeze(TimeConstants);
// Source/Core/TimeStandard.js
var TimeStandard = {
UTC: 0,
TAI: 1
};
var TimeStandard_default = Object.freeze(TimeStandard);
// Source/Core/JulianDate.js
var gregorianDateScratch = new GregorianDate_default();
var daysInMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
var daysInLeapFeburary = 29;
function compareLeapSecondDates(leapSecond, dateToFind) {
return JulianDate.compare(leapSecond.julianDate, dateToFind.julianDate);
}
var binarySearchScratchLeapSecond = new LeapSecond_default();
function convertUtcToTai(julianDate) {
binarySearchScratchLeapSecond.julianDate = julianDate;
const leapSeconds = JulianDate.leapSeconds;
let index = binarySearch_default(
leapSeconds,
binarySearchScratchLeapSecond,
compareLeapSecondDates
);
if (index < 0) {
index = ~index;
}
if (index >= leapSeconds.length) {
index = leapSeconds.length - 1;
}
let offset2 = leapSeconds[index].offset;
if (index > 0) {
const difference = JulianDate.secondsDifference(
leapSeconds[index].julianDate,
julianDate
);
if (difference > offset2) {
index--;
offset2 = leapSeconds[index].offset;
}
}
JulianDate.addSeconds(julianDate, offset2, julianDate);
}
function convertTaiToUtc(julianDate, result) {
binarySearchScratchLeapSecond.julianDate = julianDate;
const leapSeconds = JulianDate.leapSeconds;
let index = binarySearch_default(
leapSeconds,
binarySearchScratchLeapSecond,
compareLeapSecondDates
);
if (index < 0) {
index = ~index;
}
if (index === 0) {
return JulianDate.addSeconds(julianDate, -leapSeconds[0].offset, result);
}
if (index >= leapSeconds.length) {
return JulianDate.addSeconds(
julianDate,
-leapSeconds[index - 1].offset,
result
);
}
const difference = JulianDate.secondsDifference(
leapSeconds[index].julianDate,
julianDate
);
if (difference === 0) {
return JulianDate.addSeconds(
julianDate,
-leapSeconds[index].offset,
result
);
}
if (difference <= 1) {
return void 0;
}
return JulianDate.addSeconds(
julianDate,
-leapSeconds[--index].offset,
result
);
}
function setComponents(wholeDays, secondsOfDay, julianDate) {
const extraDays = secondsOfDay / TimeConstants_default.SECONDS_PER_DAY | 0;
wholeDays += extraDays;
secondsOfDay -= TimeConstants_default.SECONDS_PER_DAY * extraDays;
if (secondsOfDay < 0) {
wholeDays--;
secondsOfDay += TimeConstants_default.SECONDS_PER_DAY;
}
julianDate.dayNumber = wholeDays;
julianDate.secondsOfDay = secondsOfDay;
return julianDate;
}
function computeJulianDateComponents(year, month, day, hour, minute, second, millisecond) {
const a3 = (month - 14) / 12 | 0;
const b = year + 4800 + a3;
let dayNumber = (1461 * b / 4 | 0) + (367 * (month - 2 - 12 * a3) / 12 | 0) - (3 * ((b + 100) / 100 | 0) / 4 | 0) + day - 32075;
hour = hour - 12;
if (hour < 0) {
hour += 24;
}
const secondsOfDay = second + (hour * TimeConstants_default.SECONDS_PER_HOUR + minute * TimeConstants_default.SECONDS_PER_MINUTE + millisecond * TimeConstants_default.SECONDS_PER_MILLISECOND);
if (secondsOfDay >= 43200) {
dayNumber -= 1;
}
return [dayNumber, secondsOfDay];
}
var matchCalendarYear = /^(\d{4})$/;
var matchCalendarMonth = /^(\d{4})-(\d{2})$/;
var matchOrdinalDate = /^(\d{4})-?(\d{3})$/;
var matchWeekDate = /^(\d{4})-?W(\d{2})-?(\d{1})?$/;
var matchCalendarDate = /^(\d{4})-?(\d{2})-?(\d{2})$/;
var utcOffset = /([Z+\-])?(\d{2})?:?(\d{2})?$/;
var matchHours = /^(\d{2})(\.\d+)?/.source + utcOffset.source;
var matchHoursMinutes = /^(\d{2}):?(\d{2})(\.\d+)?/.source + utcOffset.source;
var matchHoursMinutesSeconds = /^(\d{2}):?(\d{2}):?(\d{2})(\.\d+)?/.source + utcOffset.source;
var iso8601ErrorMessage = "Invalid ISO 8601 date.";
function JulianDate(julianDayNumber, secondsOfDay, timeStandard) {
this.dayNumber = void 0;
this.secondsOfDay = void 0;
julianDayNumber = defaultValue_default(julianDayNumber, 0);
secondsOfDay = defaultValue_default(secondsOfDay, 0);
timeStandard = defaultValue_default(timeStandard, TimeStandard_default.UTC);
const wholeDays = julianDayNumber | 0;
secondsOfDay = secondsOfDay + (julianDayNumber - wholeDays) * TimeConstants_default.SECONDS_PER_DAY;
setComponents(wholeDays, secondsOfDay, this);
if (timeStandard === TimeStandard_default.UTC) {
convertUtcToTai(this);
}
}
JulianDate.fromGregorianDate = function(date, result) {
if (!(date instanceof GregorianDate_default)) {
throw new DeveloperError_default("date must be a valid GregorianDate.");
}
const components = computeJulianDateComponents(
date.year,
date.month,
date.day,
date.hour,
date.minute,
date.second,
date.millisecond
);
if (!defined_default(result)) {
return new JulianDate(components[0], components[1], TimeStandard_default.UTC);
}
setComponents(components[0], components[1], result);
convertUtcToTai(result);
return result;
};
JulianDate.fromDate = function(date, result) {
if (!(date instanceof Date) || isNaN(date.getTime())) {
throw new DeveloperError_default("date must be a valid JavaScript Date.");
}
const components = computeJulianDateComponents(
date.getUTCFullYear(),
date.getUTCMonth() + 1,
date.getUTCDate(),
date.getUTCHours(),
date.getUTCMinutes(),
date.getUTCSeconds(),
date.getUTCMilliseconds()
);
if (!defined_default(result)) {
return new JulianDate(components[0], components[1], TimeStandard_default.UTC);
}
setComponents(components[0], components[1], result);
convertUtcToTai(result);
return result;
};
JulianDate.fromIso8601 = function(iso8601String, result) {
if (typeof iso8601String !== "string") {
throw new DeveloperError_default(iso8601ErrorMessage);
}
iso8601String = iso8601String.replace(",", ".");
let tokens = iso8601String.split("T");
let year;
let month = 1;
let day = 1;
let hour = 0;
let minute = 0;
let second = 0;
let millisecond = 0;
const date = tokens[0];
const time = tokens[1];
let tmp2;
let inLeapYear;
if (!defined_default(date)) {
throw new DeveloperError_default(iso8601ErrorMessage);
}
let dashCount;
tokens = date.match(matchCalendarDate);
if (tokens !== null) {
dashCount = date.split("-").length - 1;
if (dashCount > 0 && dashCount !== 2) {
throw new DeveloperError_default(iso8601ErrorMessage);
}
year = +tokens[1];
month = +tokens[2];
day = +tokens[3];
} else {
tokens = date.match(matchCalendarMonth);
if (tokens !== null) {
year = +tokens[1];
month = +tokens[2];
} else {
tokens = date.match(matchCalendarYear);
if (tokens !== null) {
year = +tokens[1];
} else {
let dayOfYear;
tokens = date.match(matchOrdinalDate);
if (tokens !== null) {
year = +tokens[1];
dayOfYear = +tokens[2];
inLeapYear = isLeapYear_default(year);
if (dayOfYear < 1 || inLeapYear && dayOfYear > 366 || !inLeapYear && dayOfYear > 365) {
throw new DeveloperError_default(iso8601ErrorMessage);
}
} else {
tokens = date.match(matchWeekDate);
if (tokens !== null) {
year = +tokens[1];
const weekNumber = +tokens[2];
const dayOfWeek = +tokens[3] || 0;
dashCount = date.split("-").length - 1;
if (dashCount > 0 && (!defined_default(tokens[3]) && dashCount !== 1 || defined_default(tokens[3]) && dashCount !== 2)) {
throw new DeveloperError_default(iso8601ErrorMessage);
}
const january4 = new Date(Date.UTC(year, 0, 4));
dayOfYear = weekNumber * 7 + dayOfWeek - january4.getUTCDay() - 3;
} else {
throw new DeveloperError_default(iso8601ErrorMessage);
}
}
tmp2 = new Date(Date.UTC(year, 0, 1));
tmp2.setUTCDate(dayOfYear);
month = tmp2.getUTCMonth() + 1;
day = tmp2.getUTCDate();
}
}
}
inLeapYear = isLeapYear_default(year);
if (month < 1 || month > 12 || day < 1 || (month !== 2 || !inLeapYear) && day > daysInMonth[month - 1] || inLeapYear && month === 2 && day > daysInLeapFeburary) {
throw new DeveloperError_default(iso8601ErrorMessage);
}
let offsetIndex;
if (defined_default(time)) {
tokens = time.match(matchHoursMinutesSeconds);
if (tokens !== null) {
dashCount = time.split(":").length - 1;
if (dashCount > 0 && dashCount !== 2 && dashCount !== 3) {
throw new DeveloperError_default(iso8601ErrorMessage);
}
hour = +tokens[1];
minute = +tokens[2];
second = +tokens[3];
millisecond = +(tokens[4] || 0) * 1e3;
offsetIndex = 5;
} else {
tokens = time.match(matchHoursMinutes);
if (tokens !== null) {
dashCount = time.split(":").length - 1;
if (dashCount > 2) {
throw new DeveloperError_default(iso8601ErrorMessage);
}
hour = +tokens[1];
minute = +tokens[2];
second = +(tokens[3] || 0) * 60;
offsetIndex = 4;
} else {
tokens = time.match(matchHours);
if (tokens !== null) {
hour = +tokens[1];
minute = +(tokens[2] || 0) * 60;
offsetIndex = 3;
} else {
throw new DeveloperError_default(iso8601ErrorMessage);
}
}
}
if (minute >= 60 || second >= 61 || hour > 24 || hour === 24 && (minute > 0 || second > 0 || millisecond > 0)) {
throw new DeveloperError_default(iso8601ErrorMessage);
}
const offset2 = tokens[offsetIndex];
const offsetHours = +tokens[offsetIndex + 1];
const offsetMinutes = +(tokens[offsetIndex + 2] || 0);
switch (offset2) {
case "+":
hour = hour - offsetHours;
minute = minute - offsetMinutes;
break;
case "-":
hour = hour + offsetHours;
minute = minute + offsetMinutes;
break;
case "Z":
break;
default:
minute = minute + new Date(
Date.UTC(year, month - 1, day, hour, minute)
).getTimezoneOffset();
break;
}
}
const isLeapSecond = second === 60;
if (isLeapSecond) {
second--;
}
while (minute >= 60) {
minute -= 60;
hour++;
}
while (hour >= 24) {
hour -= 24;
day++;
}
tmp2 = inLeapYear && month === 2 ? daysInLeapFeburary : daysInMonth[month - 1];
while (day > tmp2) {
day -= tmp2;
month++;
if (month > 12) {
month -= 12;
year++;
}
tmp2 = inLeapYear && month === 2 ? daysInLeapFeburary : daysInMonth[month - 1];
}
while (minute < 0) {
minute += 60;
hour--;
}
while (hour < 0) {
hour += 24;
day--;
}
while (day < 1) {
month--;
if (month < 1) {
month += 12;
year--;
}
tmp2 = inLeapYear && month === 2 ? daysInLeapFeburary : daysInMonth[month - 1];
day += tmp2;
}
const components = computeJulianDateComponents(
year,
month,
day,
hour,
minute,
second,
millisecond
);
if (!defined_default(result)) {
result = new JulianDate(components[0], components[1], TimeStandard_default.UTC);
} else {
setComponents(components[0], components[1], result);
convertUtcToTai(result);
}
if (isLeapSecond) {
JulianDate.addSeconds(result, 1, result);
}
return result;
};
JulianDate.now = function(result) {
return JulianDate.fromDate(new Date(), result);
};
var toGregorianDateScratch = new JulianDate(0, 0, TimeStandard_default.TAI);
JulianDate.toGregorianDate = function(julianDate, result) {
if (!defined_default(julianDate)) {
throw new DeveloperError_default("julianDate is required.");
}
let isLeapSecond = false;
let thisUtc = convertTaiToUtc(julianDate, toGregorianDateScratch);
if (!defined_default(thisUtc)) {
JulianDate.addSeconds(julianDate, -1, toGregorianDateScratch);
thisUtc = convertTaiToUtc(toGregorianDateScratch, toGregorianDateScratch);
isLeapSecond = true;
}
let julianDayNumber = thisUtc.dayNumber;
const secondsOfDay = thisUtc.secondsOfDay;
if (secondsOfDay >= 43200) {
julianDayNumber += 1;
}
let L = julianDayNumber + 68569 | 0;
const N = 4 * L / 146097 | 0;
L = L - ((146097 * N + 3) / 4 | 0) | 0;
const I = 4e3 * (L + 1) / 1461001 | 0;
L = L - (1461 * I / 4 | 0) + 31 | 0;
const J = 80 * L / 2447 | 0;
const day = L - (2447 * J / 80 | 0) | 0;
L = J / 11 | 0;
const month = J + 2 - 12 * L | 0;
const year = 100 * (N - 49) + I + L | 0;
let hour = secondsOfDay / TimeConstants_default.SECONDS_PER_HOUR | 0;
let remainingSeconds = secondsOfDay - hour * TimeConstants_default.SECONDS_PER_HOUR;
const minute = remainingSeconds / TimeConstants_default.SECONDS_PER_MINUTE | 0;
remainingSeconds = remainingSeconds - minute * TimeConstants_default.SECONDS_PER_MINUTE;
let second = remainingSeconds | 0;
const millisecond = (remainingSeconds - second) / TimeConstants_default.SECONDS_PER_MILLISECOND;
hour += 12;
if (hour > 23) {
hour -= 24;
}
if (isLeapSecond) {
second += 1;
}
if (!defined_default(result)) {
return new GregorianDate_default(
year,
month,
day,
hour,
minute,
second,
millisecond,
isLeapSecond
);
}
result.year = year;
result.month = month;
result.day = day;
result.hour = hour;
result.minute = minute;
result.second = second;
result.millisecond = millisecond;
result.isLeapSecond = isLeapSecond;
return result;
};
JulianDate.toDate = function(julianDate) {
if (!defined_default(julianDate)) {
throw new DeveloperError_default("julianDate is required.");
}
const gDate = JulianDate.toGregorianDate(julianDate, gregorianDateScratch);
let second = gDate.second;
if (gDate.isLeapSecond) {
second -= 1;
}
return new Date(
Date.UTC(
gDate.year,
gDate.month - 1,
gDate.day,
gDate.hour,
gDate.minute,
second,
gDate.millisecond
)
);
};
JulianDate.toIso8601 = function(julianDate, precision) {
if (!defined_default(julianDate)) {
throw new DeveloperError_default("julianDate is required.");
}
const gDate = JulianDate.toGregorianDate(julianDate, gregorianDateScratch);
let year = gDate.year;
let month = gDate.month;
let day = gDate.day;
let hour = gDate.hour;
const minute = gDate.minute;
const second = gDate.second;
const millisecond = gDate.millisecond;
if (year === 1e4 && month === 1 && day === 1 && hour === 0 && minute === 0 && second === 0 && millisecond === 0) {
year = 9999;
month = 12;
day = 31;
hour = 24;
}
let millisecondStr;
if (!defined_default(precision) && millisecond !== 0) {
millisecondStr = (millisecond * 0.01).toString().replace(".", "");
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`;
}
if (!defined_default(precision) || precision === 0) {
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`;
}
millisecondStr = (millisecond * 0.01).toFixed(precision).replace(".", "").slice(0, precision);
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`;
};
JulianDate.clone = function(julianDate, result) {
if (!defined_default(julianDate)) {
return void 0;
}
if (!defined_default(result)) {
return new JulianDate(
julianDate.dayNumber,
julianDate.secondsOfDay,
TimeStandard_default.TAI
);
}
result.dayNumber = julianDate.dayNumber;
result.secondsOfDay = julianDate.secondsOfDay;
return result;
};
JulianDate.compare = function(left, right) {
if (!defined_default(left)) {
throw new DeveloperError_default("left is required.");
}
if (!defined_default(right)) {
throw new DeveloperError_default("right is required.");
}
const julianDayNumberDifference = left.dayNumber - right.dayNumber;
if (julianDayNumberDifference !== 0) {
return julianDayNumberDifference;
}
return left.secondsOfDay - right.secondsOfDay;
};
JulianDate.equals = function(left, right) {
return left === right || defined_default(left) && defined_default(right) && left.dayNumber === right.dayNumber && left.secondsOfDay === right.secondsOfDay;
};
JulianDate.equalsEpsilon = function(left, right, epsilon) {
epsilon = defaultValue_default(epsilon, 0);
return left === right || defined_default(left) && defined_default(right) && Math.abs(JulianDate.secondsDifference(left, right)) <= epsilon;
};
JulianDate.totalDays = function(julianDate) {
if (!defined_default(julianDate)) {
throw new DeveloperError_default("julianDate is required.");
}
return julianDate.dayNumber + julianDate.secondsOfDay / TimeConstants_default.SECONDS_PER_DAY;
};
JulianDate.secondsDifference = function(left, right) {
if (!defined_default(left)) {
throw new DeveloperError_default("left is required.");
}
if (!defined_default(right)) {
throw new DeveloperError_default("right is required.");
}
const dayDifference = (left.dayNumber - right.dayNumber) * TimeConstants_default.SECONDS_PER_DAY;
return dayDifference + (left.secondsOfDay - right.secondsOfDay);
};
JulianDate.daysDifference = function(left, right) {
if (!defined_default(left)) {
throw new DeveloperError_default("left is required.");
}
if (!defined_default(right)) {
throw new DeveloperError_default("right is required.");
}
const dayDifference = left.dayNumber - right.dayNumber;
const secondDifference = (left.secondsOfDay - right.secondsOfDay) / TimeConstants_default.SECONDS_PER_DAY;
return dayDifference + secondDifference;
};
JulianDate.computeTaiMinusUtc = function(julianDate) {
binarySearchScratchLeapSecond.julianDate = julianDate;
const leapSeconds = JulianDate.leapSeconds;
let index = binarySearch_default(
leapSeconds,
binarySearchScratchLeapSecond,
compareLeapSecondDates
);
if (index < 0) {
index = ~index;
--index;
if (index < 0) {
index = 0;
}
}
return leapSeconds[index].offset;
};
JulianDate.addSeconds = function(julianDate, seconds, result) {
if (!defined_default(julianDate)) {
throw new DeveloperError_default("julianDate is required.");
}
if (!defined_default(seconds)) {
throw new DeveloperError_default("seconds is required.");
}
if (!defined_default(result)) {
throw new DeveloperError_default("result is required.");
}
return setComponents(
julianDate.dayNumber,
julianDate.secondsOfDay + seconds,
result
);
};
JulianDate.addMinutes = function(julianDate, minutes, result) {
if (!defined_default(julianDate)) {
throw new DeveloperError_default("julianDate is required.");
}
if (!defined_default(minutes)) {
throw new DeveloperError_default("minutes is required.");
}
if (!defined_default(result)) {
throw new DeveloperError_default("result is required.");
}
const newSecondsOfDay = julianDate.secondsOfDay + minutes * TimeConstants_default.SECONDS_PER_MINUTE;
return setComponents(julianDate.dayNumber, newSecondsOfDay, result);
};
JulianDate.addHours = function(julianDate, hours, result) {
if (!defined_default(julianDate)) {
throw new DeveloperError_default("julianDate is required.");
}
if (!defined_default(hours)) {
throw new DeveloperError_default("hours is required.");
}
if (!defined_default(result)) {
throw new DeveloperError_default("result is required.");
}
const newSecondsOfDay = julianDate.secondsOfDay + hours * TimeConstants_default.SECONDS_PER_HOUR;
return setComponents(julianDate.dayNumber, newSecondsOfDay, result);
};
JulianDate.addDays = function(julianDate, days, result) {
if (!defined_default(julianDate)) {
throw new DeveloperError_default("julianDate is required.");
}
if (!defined_default(days)) {
throw new DeveloperError_default("days is required.");
}
if (!defined_default(result)) {
throw new DeveloperError_default("result is required.");
}
const newJulianDayNumber = julianDate.dayNumber + days;
return setComponents(newJulianDayNumber, julianDate.secondsOfDay, result);
};
JulianDate.lessThan = function(left, right) {
return JulianDate.compare(left, right) < 0;
};
JulianDate.lessThanOrEquals = function(left, right) {
return JulianDate.compare(left, right) <= 0;
};
JulianDate.greaterThan = function(left, right) {
return JulianDate.compare(left, right) > 0;
};
JulianDate.greaterThanOrEquals = function(left, right) {
return JulianDate.compare(left, right) >= 0;
};
JulianDate.prototype.clone = function(result) {
return JulianDate.clone(this, result);
};
JulianDate.prototype.equals = function(right) {
return JulianDate.equals(this, right);
};
JulianDate.prototype.equalsEpsilon = function(right, epsilon) {
return JulianDate.equalsEpsilon(this, right, epsilon);
};
JulianDate.prototype.toString = function() {
return JulianDate.toIso8601(this);
};
JulianDate.leapSeconds = [
new LeapSecond_default(new JulianDate(2441317, 43210, TimeStandard_default.TAI), 10),
new LeapSecond_default(new JulianDate(2441499, 43211, TimeStandard_default.TAI), 11),
new LeapSecond_default(new JulianDate(2441683, 43212, TimeStandard_default.TAI), 12),
new LeapSecond_default(new JulianDate(2442048, 43213, TimeStandard_default.TAI), 13),
new LeapSecond_default(new JulianDate(2442413, 43214, TimeStandard_default.TAI), 14),
new LeapSecond_default(new JulianDate(2442778, 43215, TimeStandard_default.TAI), 15),
new LeapSecond_default(new JulianDate(2443144, 43216, TimeStandard_default.TAI), 16),
new LeapSecond_default(new JulianDate(2443509, 43217, TimeStandard_default.TAI), 17),
new LeapSecond_default(new JulianDate(2443874, 43218, TimeStandard_default.TAI), 18),
new LeapSecond_default(new JulianDate(2444239, 43219, TimeStandard_default.TAI), 19),
new LeapSecond_default(new JulianDate(2444786, 43220, TimeStandard_default.TAI), 20),
new LeapSecond_default(new JulianDate(2445151, 43221, TimeStandard_default.TAI), 21),
new LeapSecond_default(new JulianDate(2445516, 43222, TimeStandard_default.TAI), 22),
new LeapSecond_default(new JulianDate(2446247, 43223, TimeStandard_default.TAI), 23),
new LeapSecond_default(new JulianDate(2447161, 43224, TimeStandard_default.TAI), 24),
new LeapSecond_default(new JulianDate(2447892, 43225, TimeStandard_default.TAI), 25),
new LeapSecond_default(new JulianDate(2448257, 43226, TimeStandard_default.TAI), 26),
new LeapSecond_default(new JulianDate(2448804, 43227, TimeStandard_default.TAI), 27),
new LeapSecond_default(new JulianDate(2449169, 43228, TimeStandard_default.TAI), 28),
new LeapSecond_default(new JulianDate(2449534, 43229, TimeStandard_default.TAI), 29),
new LeapSecond_default(new JulianDate(2450083, 43230, TimeStandard_default.TAI), 30),
new LeapSecond_default(new JulianDate(2450630, 43231, TimeStandard_default.TAI), 31),
new LeapSecond_default(new JulianDate(2451179, 43232, TimeStandard_default.TAI), 32),
new LeapSecond_default(new JulianDate(2453736, 43233, TimeStandard_default.TAI), 33),
new LeapSecond_default(new JulianDate(2454832, 43234, TimeStandard_default.TAI), 34),
new LeapSecond_default(new JulianDate(2456109, 43235, TimeStandard_default.TAI), 35),
new LeapSecond_default(new JulianDate(2457204, 43236, TimeStandard_default.TAI), 36),
new LeapSecond_default(new JulianDate(2457754, 43237, TimeStandard_default.TAI), 37)
];
var JulianDate_default = JulianDate;
// Source/Core/EarthOrientationParameters.js
function EarthOrientationParameters(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
this._dates = void 0;
this._samples = void 0;
this._dateColumn = -1;
this._xPoleWanderRadiansColumn = -1;
this._yPoleWanderRadiansColumn = -1;
this._ut1MinusUtcSecondsColumn = -1;
this._xCelestialPoleOffsetRadiansColumn = -1;
this._yCelestialPoleOffsetRadiansColumn = -1;
this._taiMinusUtcSecondsColumn = -1;
this._columnCount = 0;
this._lastIndex = -1;
this._downloadPromise = void 0;
this._dataError = void 0;
this._addNewLeapSeconds = defaultValue_default(options.addNewLeapSeconds, true);
if (defined_default(options.data)) {
onDataReady(this, options.data);
} else if (defined_default(options.url)) {
const resource = Resource_default.createIfNeeded(options.url);
const that = this;
this._downloadPromise = resource.fetchJson().then(function(eopData) {
onDataReady(that, eopData);
}).catch(function() {
that._dataError = `An error occurred while retrieving the EOP data from the URL ${resource.url}.`;
});
} else {
onDataReady(this, {
columnNames: [
"dateIso8601",
"modifiedJulianDateUtc",
"xPoleWanderRadians",
"yPoleWanderRadians",
"ut1MinusUtcSeconds",
"lengthOfDayCorrectionSeconds",
"xCelestialPoleOffsetRadians",
"yCelestialPoleOffsetRadians",
"taiMinusUtcSeconds"
],
samples: []
});
}
}
EarthOrientationParameters.NONE = Object.freeze({
getPromiseToLoad: function() {
return Promise.resolve();
},
compute: function(date, result) {
if (!defined_default(result)) {
result = new EarthOrientationParametersSample_default(0, 0, 0, 0, 0);
} else {
result.xPoleWander = 0;
result.yPoleWander = 0;
result.xPoleOffset = 0;
result.yPoleOffset = 0;
result.ut1MinusUtc = 0;
}
return result;
}
});
EarthOrientationParameters.prototype.getPromiseToLoad = function() {
return Promise.resolve(this._downloadPromise);
};
EarthOrientationParameters.prototype.compute = function(date, result) {
if (!defined_default(this._samples)) {
if (defined_default(this._dataError)) {
throw new RuntimeError_default(this._dataError);
}
return void 0;
}
if (!defined_default(result)) {
result = new EarthOrientationParametersSample_default(0, 0, 0, 0, 0);
}
if (this._samples.length === 0) {
result.xPoleWander = 0;
result.yPoleWander = 0;
result.xPoleOffset = 0;
result.yPoleOffset = 0;
result.ut1MinusUtc = 0;
return result;
}
const dates = this._dates;
const lastIndex = this._lastIndex;
let before = 0;
let after = 0;
if (defined_default(lastIndex)) {
const previousIndexDate = dates[lastIndex];
const nextIndexDate = dates[lastIndex + 1];
const isAfterPrevious = JulianDate_default.lessThanOrEquals(
previousIndexDate,
date
);
const isAfterLastSample = !defined_default(nextIndexDate);
const isBeforeNext = isAfterLastSample || JulianDate_default.greaterThanOrEquals(nextIndexDate, date);
if (isAfterPrevious && isBeforeNext) {
before = lastIndex;
if (!isAfterLastSample && nextIndexDate.equals(date)) {
++before;
}
after = before + 1;
interpolate(this, dates, this._samples, date, before, after, result);
return result;
}
}
let index = binarySearch_default(dates, date, JulianDate_default.compare, this._dateColumn);
if (index >= 0) {
if (index < dates.length - 1 && dates[index + 1].equals(date)) {
++index;
}
before = index;
after = index;
} else {
after = ~index;
before = after - 1;
if (before < 0) {
before = 0;
}
}
this._lastIndex = before;
interpolate(this, dates, this._samples, date, before, after, result);
return result;
};
function compareLeapSecondDates2(leapSecond, dateToFind) {
return JulianDate_default.compare(leapSecond.julianDate, dateToFind);
}
function onDataReady(eop, eopData) {
if (!defined_default(eopData.columnNames)) {
eop._dataError = "Error in loaded EOP data: The columnNames property is required.";
return;
}
if (!defined_default(eopData.samples)) {
eop._dataError = "Error in loaded EOP data: The samples property is required.";
return;
}
const dateColumn = eopData.columnNames.indexOf("modifiedJulianDateUtc");
const xPoleWanderRadiansColumn = eopData.columnNames.indexOf(
"xPoleWanderRadians"
);
const yPoleWanderRadiansColumn = eopData.columnNames.indexOf(
"yPoleWanderRadians"
);
const ut1MinusUtcSecondsColumn = eopData.columnNames.indexOf(
"ut1MinusUtcSeconds"
);
const xCelestialPoleOffsetRadiansColumn = eopData.columnNames.indexOf(
"xCelestialPoleOffsetRadians"
);
const yCelestialPoleOffsetRadiansColumn = eopData.columnNames.indexOf(
"yCelestialPoleOffsetRadians"
);
const taiMinusUtcSecondsColumn = eopData.columnNames.indexOf(
"taiMinusUtcSeconds"
);
if (dateColumn < 0 || xPoleWanderRadiansColumn < 0 || yPoleWanderRadiansColumn < 0 || ut1MinusUtcSecondsColumn < 0 || xCelestialPoleOffsetRadiansColumn < 0 || yCelestialPoleOffsetRadiansColumn < 0 || taiMinusUtcSecondsColumn < 0) {
eop._dataError = "Error in loaded EOP data: The columnNames property must include modifiedJulianDateUtc, xPoleWanderRadians, yPoleWanderRadians, ut1MinusUtcSeconds, xCelestialPoleOffsetRadians, yCelestialPoleOffsetRadians, and taiMinusUtcSeconds columns";
return;
}
const samples = eop._samples = eopData.samples;
const dates = eop._dates = [];
eop._dateColumn = dateColumn;
eop._xPoleWanderRadiansColumn = xPoleWanderRadiansColumn;
eop._yPoleWanderRadiansColumn = yPoleWanderRadiansColumn;
eop._ut1MinusUtcSecondsColumn = ut1MinusUtcSecondsColumn;
eop._xCelestialPoleOffsetRadiansColumn = xCelestialPoleOffsetRadiansColumn;
eop._yCelestialPoleOffsetRadiansColumn = yCelestialPoleOffsetRadiansColumn;
eop._taiMinusUtcSecondsColumn = taiMinusUtcSecondsColumn;
eop._columnCount = eopData.columnNames.length;
eop._lastIndex = void 0;
let lastTaiMinusUtc;
const addNewLeapSeconds = eop._addNewLeapSeconds;
for (let i = 0, len = samples.length; i < len; i += eop._columnCount) {
const mjd = samples[i + dateColumn];
const taiMinusUtc = samples[i + taiMinusUtcSecondsColumn];
const day = mjd + TimeConstants_default.MODIFIED_JULIAN_DATE_DIFFERENCE;
const date = new JulianDate_default(day, taiMinusUtc, TimeStandard_default.TAI);
dates.push(date);
if (addNewLeapSeconds) {
if (taiMinusUtc !== lastTaiMinusUtc && defined_default(lastTaiMinusUtc)) {
const leapSeconds = JulianDate_default.leapSeconds;
const leapSecondIndex = binarySearch_default(
leapSeconds,
date,
compareLeapSecondDates2
);
if (leapSecondIndex < 0) {
const leapSecond = new LeapSecond_default(date, taiMinusUtc);
leapSeconds.splice(~leapSecondIndex, 0, leapSecond);
}
}
lastTaiMinusUtc = taiMinusUtc;
}
}
}
function fillResultFromIndex(eop, samples, index, columnCount, result) {
const start = index * columnCount;
result.xPoleWander = samples[start + eop._xPoleWanderRadiansColumn];
result.yPoleWander = samples[start + eop._yPoleWanderRadiansColumn];
result.xPoleOffset = samples[start + eop._xCelestialPoleOffsetRadiansColumn];
result.yPoleOffset = samples[start + eop._yCelestialPoleOffsetRadiansColumn];
result.ut1MinusUtc = samples[start + eop._ut1MinusUtcSecondsColumn];
}
function linearInterp(dx, y1, y2) {
return y1 + dx * (y2 - y1);
}
function interpolate(eop, dates, samples, date, before, after, result) {
const columnCount = eop._columnCount;
if (after > dates.length - 1) {
result.xPoleWander = 0;
result.yPoleWander = 0;
result.xPoleOffset = 0;
result.yPoleOffset = 0;
result.ut1MinusUtc = 0;
return result;
}
const beforeDate = dates[before];
const afterDate = dates[after];
if (beforeDate.equals(afterDate) || date.equals(beforeDate)) {
fillResultFromIndex(eop, samples, before, columnCount, result);
return result;
} else if (date.equals(afterDate)) {
fillResultFromIndex(eop, samples, after, columnCount, result);
return result;
}
const factor2 = JulianDate_default.secondsDifference(date, beforeDate) / JulianDate_default.secondsDifference(afterDate, beforeDate);
const startBefore = before * columnCount;
const startAfter = after * columnCount;
let beforeUt1MinusUtc = samples[startBefore + eop._ut1MinusUtcSecondsColumn];
let afterUt1MinusUtc = samples[startAfter + eop._ut1MinusUtcSecondsColumn];
const offsetDifference = afterUt1MinusUtc - beforeUt1MinusUtc;
if (offsetDifference > 0.5 || offsetDifference < -0.5) {
const beforeTaiMinusUtc = samples[startBefore + eop._taiMinusUtcSecondsColumn];
const afterTaiMinusUtc = samples[startAfter + eop._taiMinusUtcSecondsColumn];
if (beforeTaiMinusUtc !== afterTaiMinusUtc) {
if (afterDate.equals(date)) {
beforeUt1MinusUtc = afterUt1MinusUtc;
} else {
afterUt1MinusUtc -= afterTaiMinusUtc - beforeTaiMinusUtc;
}
}
}
result.xPoleWander = linearInterp(
factor2,
samples[startBefore + eop._xPoleWanderRadiansColumn],
samples[startAfter + eop._xPoleWanderRadiansColumn]
);
result.yPoleWander = linearInterp(
factor2,
samples[startBefore + eop._yPoleWanderRadiansColumn],
samples[startAfter + eop._yPoleWanderRadiansColumn]
);
result.xPoleOffset = linearInterp(
factor2,
samples[startBefore + eop._xCelestialPoleOffsetRadiansColumn],
samples[startAfter + eop._xCelestialPoleOffsetRadiansColumn]
);
result.yPoleOffset = linearInterp(
factor2,
samples[startBefore + eop._yCelestialPoleOffsetRadiansColumn],
samples[startAfter + eop._yCelestialPoleOffsetRadiansColumn]
);
result.ut1MinusUtc = linearInterp(
factor2,
beforeUt1MinusUtc,
afterUt1MinusUtc
);
return result;
}
var EarthOrientationParameters_default = EarthOrientationParameters;
// Source/Core/HeadingPitchRoll.js
function HeadingPitchRoll(heading, pitch, roll) {
this.heading = defaultValue_default(heading, 0);
this.pitch = defaultValue_default(pitch, 0);
this.roll = defaultValue_default(roll, 0);
}
HeadingPitchRoll.fromQuaternion = function(quaternion, result) {
if (!defined_default(quaternion)) {
throw new DeveloperError_default("quaternion is required");
}
if (!defined_default(result)) {
result = new HeadingPitchRoll();
}
const test = 2 * (quaternion.w * quaternion.y - quaternion.z * quaternion.x);
const denominatorRoll = 1 - 2 * (quaternion.x * quaternion.x + quaternion.y * quaternion.y);
const numeratorRoll = 2 * (quaternion.w * quaternion.x + quaternion.y * quaternion.z);
const denominatorHeading = 1 - 2 * (quaternion.y * quaternion.y + quaternion.z * quaternion.z);
const numeratorHeading = 2 * (quaternion.w * quaternion.z + quaternion.x * quaternion.y);
result.heading = -Math.atan2(numeratorHeading, denominatorHeading);
result.roll = Math.atan2(numeratorRoll, denominatorRoll);
result.pitch = -Math_default.asinClamped(test);
return result;
};
HeadingPitchRoll.fromDegrees = function(heading, pitch, roll, result) {
if (!defined_default(heading)) {
throw new DeveloperError_default("heading is required");
}
if (!defined_default(pitch)) {
throw new DeveloperError_default("pitch is required");
}
if (!defined_default(roll)) {
throw new DeveloperError_default("roll is required");
}
if (!defined_default(result)) {
result = new HeadingPitchRoll();
}
result.heading = heading * Math_default.RADIANS_PER_DEGREE;
result.pitch = pitch * Math_default.RADIANS_PER_DEGREE;
result.roll = roll * Math_default.RADIANS_PER_DEGREE;
return result;
};
HeadingPitchRoll.clone = function(headingPitchRoll, result) {
if (!defined_default(headingPitchRoll)) {
return void 0;
}
if (!defined_default(result)) {
return new HeadingPitchRoll(
headingPitchRoll.heading,
headingPitchRoll.pitch,
headingPitchRoll.roll
);
}
result.heading = headingPitchRoll.heading;
result.pitch = headingPitchRoll.pitch;
result.roll = headingPitchRoll.roll;
return result;
};
HeadingPitchRoll.equals = function(left, right) {
return left === right || defined_default(left) && defined_default(right) && left.heading === right.heading && left.pitch === right.pitch && left.roll === right.roll;
};
HeadingPitchRoll.equalsEpsilon = function(left, right, relativeEpsilon, absoluteEpsilon) {
return left === right || defined_default(left) && defined_default(right) && Math_default.equalsEpsilon(
left.heading,
right.heading,
relativeEpsilon,
absoluteEpsilon
) && Math_default.equalsEpsilon(
left.pitch,
right.pitch,
relativeEpsilon,
absoluteEpsilon
) && Math_default.equalsEpsilon(
left.roll,
right.roll,
relativeEpsilon,
absoluteEpsilon
);
};
HeadingPitchRoll.prototype.clone = function(result) {
return HeadingPitchRoll.clone(this, result);
};
HeadingPitchRoll.prototype.equals = function(right) {
return HeadingPitchRoll.equals(this, right);
};
HeadingPitchRoll.prototype.equalsEpsilon = function(right, relativeEpsilon, absoluteEpsilon) {
return HeadingPitchRoll.equalsEpsilon(
this,
right,
relativeEpsilon,
absoluteEpsilon
);
};
HeadingPitchRoll.prototype.toString = function() {
return `(${this.heading}, ${this.pitch}, ${this.roll})`;
};
var HeadingPitchRoll_default = HeadingPitchRoll;
// Source/Core/Iau2006XysSample.js
function Iau2006XysSample(x, y, s) {
this.x = x;
this.y = y;
this.s = s;
}
var Iau2006XysSample_default = Iau2006XysSample;
// Source/Core/Iau2006XysData.js
function Iau2006XysData(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
this._xysFileUrlTemplate = Resource_default.createIfNeeded(
options.xysFileUrlTemplate
);
this._interpolationOrder = defaultValue_default(options.interpolationOrder, 9);
this._sampleZeroJulianEphemerisDate = defaultValue_default(
options.sampleZeroJulianEphemerisDate,
24423965e-1
);
this._sampleZeroDateTT = new JulianDate_default(
this._sampleZeroJulianEphemerisDate,
0,
TimeStandard_default.TAI
);
this._stepSizeDays = defaultValue_default(options.stepSizeDays, 1);
this._samplesPerXysFile = defaultValue_default(options.samplesPerXysFile, 1e3);
this._totalSamples = defaultValue_default(options.totalSamples, 27426);
this._samples = new Array(this._totalSamples * 3);
this._chunkDownloadsInProgress = [];
const order = this._interpolationOrder;
const denom = this._denominators = new Array(order + 1);
const xTable = this._xTable = new Array(order + 1);
const stepN = Math.pow(this._stepSizeDays, order);
for (let i = 0; i <= order; ++i) {
denom[i] = stepN;
xTable[i] = i * this._stepSizeDays;
for (let j = 0; j <= order; ++j) {
if (j !== i) {
denom[i] *= i - j;
}
}
denom[i] = 1 / denom[i];
}
this._work = new Array(order + 1);
this._coef = new Array(order + 1);
}
var julianDateScratch = new JulianDate_default(0, 0, TimeStandard_default.TAI);
function getDaysSinceEpoch(xys, dayTT, secondTT) {
const dateTT2 = julianDateScratch;
dateTT2.dayNumber = dayTT;
dateTT2.secondsOfDay = secondTT;
return JulianDate_default.daysDifference(dateTT2, xys._sampleZeroDateTT);
}
Iau2006XysData.prototype.preload = function(startDayTT, startSecondTT, stopDayTT, stopSecondTT) {
const startDaysSinceEpoch = getDaysSinceEpoch(
this,
startDayTT,
startSecondTT
);
const stopDaysSinceEpoch = getDaysSinceEpoch(this, stopDayTT, stopSecondTT);
let startIndex = startDaysSinceEpoch / this._stepSizeDays - this._interpolationOrder / 2 | 0;
if (startIndex < 0) {
startIndex = 0;
}
let stopIndex = stopDaysSinceEpoch / this._stepSizeDays - this._interpolationOrder / 2 | 0 + this._interpolationOrder;
if (stopIndex >= this._totalSamples) {
stopIndex = this._totalSamples - 1;
}
const startChunk = startIndex / this._samplesPerXysFile | 0;
const stopChunk = stopIndex / this._samplesPerXysFile | 0;
const promises = [];
for (let i = startChunk; i <= stopChunk; ++i) {
promises.push(requestXysChunk(this, i));
}
return Promise.all(promises);
};
Iau2006XysData.prototype.computeXysRadians = function(dayTT, secondTT, result) {
const daysSinceEpoch = getDaysSinceEpoch(this, dayTT, secondTT);
if (daysSinceEpoch < 0) {
return void 0;
}
const centerIndex = daysSinceEpoch / this._stepSizeDays | 0;
if (centerIndex >= this._totalSamples) {
return void 0;
}
const degree = this._interpolationOrder;
let firstIndex = centerIndex - (degree / 2 | 0);
if (firstIndex < 0) {
firstIndex = 0;
}
let lastIndex = firstIndex + degree;
if (lastIndex >= this._totalSamples) {
lastIndex = this._totalSamples - 1;
firstIndex = lastIndex - degree;
if (firstIndex < 0) {
firstIndex = 0;
}
}
let isDataMissing = false;
const samples = this._samples;
if (!defined_default(samples[firstIndex * 3])) {
requestXysChunk(this, firstIndex / this._samplesPerXysFile | 0);
isDataMissing = true;
}
if (!defined_default(samples[lastIndex * 3])) {
requestXysChunk(this, lastIndex / this._samplesPerXysFile | 0);
isDataMissing = true;
}
if (isDataMissing) {
return void 0;
}
if (!defined_default(result)) {
result = new Iau2006XysSample_default(0, 0, 0);
} else {
result.x = 0;
result.y = 0;
result.s = 0;
}
const x = daysSinceEpoch - firstIndex * this._stepSizeDays;
const work = this._work;
const denom = this._denominators;
const coef = this._coef;
const xTable = this._xTable;
let i, j;
for (i = 0; i <= degree; ++i) {
work[i] = x - xTable[i];
}
for (i = 0; i <= degree; ++i) {
coef[i] = 1;
for (j = 0; j <= degree; ++j) {
if (j !== i) {
coef[i] *= work[j];
}
}
coef[i] *= denom[i];
let sampleIndex = (firstIndex + i) * 3;
result.x += coef[i] * samples[sampleIndex++];
result.y += coef[i] * samples[sampleIndex++];
result.s += coef[i] * samples[sampleIndex];
}
return result;
};
function requestXysChunk(xysData, chunkIndex) {
if (xysData._chunkDownloadsInProgress[chunkIndex]) {
return xysData._chunkDownloadsInProgress[chunkIndex];
}
let chunkUrl;
const xysFileUrlTemplate = xysData._xysFileUrlTemplate;
if (defined_default(xysFileUrlTemplate)) {
chunkUrl = xysFileUrlTemplate.getDerivedResource({
templateValues: {
0: chunkIndex
}
});
} else {
chunkUrl = new Resource_default({
url: buildModuleUrl_default(`Assets/IAU2006_XYS/IAU2006_XYS_${chunkIndex}.json`)
});
}
const promise = chunkUrl.fetchJson().then(function(chunk) {
xysData._chunkDownloadsInProgress[chunkIndex] = false;
const samples = xysData._samples;
const newSamples = chunk.samples;
const startIndex = chunkIndex * xysData._samplesPerXysFile * 3;
for (let i = 0, len = newSamples.length; i < len; ++i) {
samples[startIndex + i] = newSamples[i];
}
});
xysData._chunkDownloadsInProgress[chunkIndex] = promise;
return promise;
}
var Iau2006XysData_default = Iau2006XysData;
// Source/Core/Fullscreen.js
var _supportsFullscreen;
var _names = {
requestFullscreen: void 0,
exitFullscreen: void 0,
fullscreenEnabled: void 0,
fullscreenElement: void 0,
fullscreenchange: void 0,
fullscreenerror: void 0
};
var Fullscreen = {};
Object.defineProperties(Fullscreen, {
element: {
get: function() {
if (!Fullscreen.supportsFullscreen()) {
return void 0;
}
return document[_names.fullscreenElement];
}
},
changeEventName: {
get: function() {
if (!Fullscreen.supportsFullscreen()) {
return void 0;
}
return _names.fullscreenchange;
}
},
errorEventName: {
get: function() {
if (!Fullscreen.supportsFullscreen()) {
return void 0;
}
return _names.fullscreenerror;
}
},
enabled: {
get: function() {
if (!Fullscreen.supportsFullscreen()) {
return void 0;
}
return document[_names.fullscreenEnabled];
}
},
fullscreen: {
get: function() {
if (!Fullscreen.supportsFullscreen()) {
return void 0;
}
return Fullscreen.element !== null;
}
}
});
Fullscreen.supportsFullscreen = function() {
if (defined_default(_supportsFullscreen)) {
return _supportsFullscreen;
}
_supportsFullscreen = false;
const body = document.body;
if (typeof body.requestFullscreen === "function") {
_names.requestFullscreen = "requestFullscreen";
_names.exitFullscreen = "exitFullscreen";
_names.fullscreenEnabled = "fullscreenEnabled";
_names.fullscreenElement = "fullscreenElement";
_names.fullscreenchange = "fullscreenchange";
_names.fullscreenerror = "fullscreenerror";
_supportsFullscreen = true;
return _supportsFullscreen;
}
const prefixes = ["webkit", "moz", "o", "ms", "khtml"];
let name;
for (let i = 0, len = prefixes.length; i < len; ++i) {
const prefix = prefixes[i];
name = `${prefix}RequestFullscreen`;
if (typeof body[name] === "function") {
_names.requestFullscreen = name;
_supportsFullscreen = true;
} else {
name = `${prefix}RequestFullScreen`;
if (typeof body[name] === "function") {
_names.requestFullscreen = name;
_supportsFullscreen = true;
}
}
name = `${prefix}ExitFullscreen`;
if (typeof document[name] === "function") {
_names.exitFullscreen = name;
} else {
name = `${prefix}CancelFullScreen`;
if (typeof document[name] === "function") {
_names.exitFullscreen = name;
}
}
name = `${prefix}FullscreenEnabled`;
if (document[name] !== void 0) {
_names.fullscreenEnabled = name;
} else {
name = `${prefix}FullScreenEnabled`;
if (document[name] !== void 0) {
_names.fullscreenEnabled = name;
}
}
name = `${prefix}FullscreenElement`;
if (document[name] !== void 0) {
_names.fullscreenElement = name;
} else {
name = `${prefix}FullScreenElement`;
if (document[name] !== void 0) {
_names.fullscreenElement = name;
}
}
name = `${prefix}fullscreenchange`;
if (document[`on${name}`] !== void 0) {
if (prefix === "ms") {
name = "MSFullscreenChange";
}
_names.fullscreenchange = name;
}
name = `${prefix}fullscreenerror`;
if (document[`on${name}`] !== void 0) {
if (prefix === "ms") {
name = "MSFullscreenError";
}
_names.fullscreenerror = name;
}
}
return _supportsFullscreen;
};
Fullscreen.requestFullscreen = function(element, vrDevice) {
if (!Fullscreen.supportsFullscreen()) {
return;
}
element[_names.requestFullscreen]({ vrDisplay: vrDevice });
};
Fullscreen.exitFullscreen = function() {
if (!Fullscreen.supportsFullscreen()) {
return;
}
document[_names.exitFullscreen]();
};
Fullscreen._names = _names;
var Fullscreen_default = Fullscreen;
// Source/Core/FeatureDetection.js
var theNavigator;
if (typeof navigator !== "undefined") {
theNavigator = navigator;
} else {
theNavigator = {};
}
function extractVersion(versionString) {
const parts = versionString.split(".");
for (let i = 0, len = parts.length; i < len; ++i) {
parts[i] = parseInt(parts[i], 10);
}
return parts;
}
var isChromeResult;
var chromeVersionResult;
function isChrome() {
if (!defined_default(isChromeResult)) {
isChromeResult = false;
if (!isEdge()) {
const fields = / Chrome\/([\.0-9]+)/.exec(theNavigator.userAgent);
if (fields !== null) {
isChromeResult = true;
chromeVersionResult = extractVersion(fields[1]);
}
}
}
return isChromeResult;
}
function chromeVersion() {
return isChrome() && chromeVersionResult;
}
var isSafariResult;
var safariVersionResult;
function isSafari() {
if (!defined_default(isSafariResult)) {
isSafariResult = false;
if (!isChrome() && !isEdge() && / Safari\/[\.0-9]+/.test(theNavigator.userAgent)) {
const fields = / Version\/([\.0-9]+)/.exec(theNavigator.userAgent);
if (fields !== null) {
isSafariResult = true;
safariVersionResult = extractVersion(fields[1]);
}
}
}
return isSafariResult;
}
function safariVersion() {
return isSafari() && safariVersionResult;
}
var isWebkitResult;
var webkitVersionResult;
function isWebkit() {
if (!defined_default(isWebkitResult)) {
isWebkitResult = false;
const fields = / AppleWebKit\/([\.0-9]+)(\+?)/.exec(theNavigator.userAgent);
if (fields !== null) {
isWebkitResult = true;
webkitVersionResult = extractVersion(fields[1]);
webkitVersionResult.isNightly = !!fields[2];
}
}
return isWebkitResult;
}
function webkitVersion() {
return isWebkit() && webkitVersionResult;
}
var isInternetExplorerResult;
var internetExplorerVersionResult;
function isInternetExplorer() {
if (!defined_default(isInternetExplorerResult)) {
isInternetExplorerResult = false;
let fields;
if (theNavigator.appName === "Microsoft Internet Explorer") {
fields = /MSIE ([0-9]{1,}[\.0-9]{0,})/.exec(theNavigator.userAgent);
if (fields !== null) {
isInternetExplorerResult = true;
internetExplorerVersionResult = extractVersion(fields[1]);
}
} else if (theNavigator.appName === "Netscape") {
fields = /Trident\/.*rv:([0-9]{1,}[\.0-9]{0,})/.exec(
theNavigator.userAgent
);
if (fields !== null) {
isInternetExplorerResult = true;
internetExplorerVersionResult = extractVersion(fields[1]);
}
}
}
return isInternetExplorerResult;
}
function internetExplorerVersion() {
return isInternetExplorer() && internetExplorerVersionResult;
}
var isEdgeResult;
var edgeVersionResult;
function isEdge() {
if (!defined_default(isEdgeResult)) {
isEdgeResult = false;
const fields = / Edg\/([\.0-9]+)/.exec(theNavigator.userAgent);
if (fields !== null) {
isEdgeResult = true;
edgeVersionResult = extractVersion(fields[1]);
}
}
return isEdgeResult;
}
function edgeVersion() {
return isEdge() && edgeVersionResult;
}
var isFirefoxResult;
var firefoxVersionResult;
function isFirefox() {
if (!defined_default(isFirefoxResult)) {
isFirefoxResult = false;
const fields = /Firefox\/([\.0-9]+)/.exec(theNavigator.userAgent);
if (fields !== null) {
isFirefoxResult = true;
firefoxVersionResult = extractVersion(fields[1]);
}
}
return isFirefoxResult;
}
var isWindowsResult;
function isWindows() {
if (!defined_default(isWindowsResult)) {
isWindowsResult = /Windows/i.test(theNavigator.appVersion);
}
return isWindowsResult;
}
var isIPadOrIOSResult;
function isIPadOrIOS() {
if (!defined_default(isIPadOrIOSResult)) {
isIPadOrIOSResult = navigator.platform === "iPhone" || navigator.platform === "iPod" || navigator.platform === "iPad";
}
return isIPadOrIOSResult;
}
function firefoxVersion() {
return isFirefox() && firefoxVersionResult;
}
var hasPointerEvents;
function supportsPointerEvents() {
if (!defined_default(hasPointerEvents)) {
hasPointerEvents = !isFirefox() && typeof PointerEvent !== "undefined" && (!defined_default(theNavigator.pointerEnabled) || theNavigator.pointerEnabled);
}
return hasPointerEvents;
}
var imageRenderingValueResult;
var supportsImageRenderingPixelatedResult;
function supportsImageRenderingPixelated() {
if (!defined_default(supportsImageRenderingPixelatedResult)) {
const canvas = document.createElement("canvas");
canvas.setAttribute(
"style",
"image-rendering: -moz-crisp-edges;image-rendering: pixelated;"
);
const tmp2 = canvas.style.imageRendering;
supportsImageRenderingPixelatedResult = defined_default(tmp2) && tmp2 !== "";
if (supportsImageRenderingPixelatedResult) {
imageRenderingValueResult = tmp2;
}
}
return supportsImageRenderingPixelatedResult;
}
function imageRenderingValue() {
return supportsImageRenderingPixelated() ? imageRenderingValueResult : void 0;
}
function supportsWebP() {
if (!supportsWebP.initialized) {
throw new DeveloperError_default(
"You must call FeatureDetection.supportsWebP.initialize and wait for the promise to resolve before calling FeatureDetection.supportsWebP"
);
}
return supportsWebP._result;
}
supportsWebP._promise = void 0;
supportsWebP._result = void 0;
supportsWebP.initialize = function() {
if (defined_default(supportsWebP._promise)) {
return supportsWebP._promise;
}
supportsWebP._promise = new Promise((resolve2) => {
const image = new Image();
image.onload = function() {
supportsWebP._result = image.width > 0 && image.height > 0;
resolve2(supportsWebP._result);
};
image.onerror = function() {
supportsWebP._result = false;
resolve2(supportsWebP._result);
};
image.src = "data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA";
});
return supportsWebP._promise;
};
Object.defineProperties(supportsWebP, {
initialized: {
get: function() {
return defined_default(supportsWebP._result);
}
}
});
var typedArrayTypes = [];
if (typeof ArrayBuffer !== "undefined") {
typedArrayTypes.push(
Int8Array,
Uint8Array,
Int16Array,
Uint16Array,
Int32Array,
Uint32Array,
Float32Array,
Float64Array
);
if (typeof Uint8ClampedArray !== "undefined") {
typedArrayTypes.push(Uint8ClampedArray);
}
if (typeof Uint8ClampedArray !== "undefined") {
typedArrayTypes.push(Uint8ClampedArray);
}
if (typeof BigInt64Array !== "undefined") {
typedArrayTypes.push(BigInt64Array);
}
if (typeof BigUint64Array !== "undefined") {
typedArrayTypes.push(BigUint64Array);
}
}
var FeatureDetection = {
isChrome,
chromeVersion,
isSafari,
safariVersion,
isWebkit,
webkitVersion,
isInternetExplorer,
internetExplorerVersion,
isEdge,
edgeVersion,
isFirefox,
firefoxVersion,
isWindows,
isIPadOrIOS,
hardwareConcurrency: defaultValue_default(theNavigator.hardwareConcurrency, 3),
supportsPointerEvents,
supportsImageRenderingPixelated,
supportsWebP,
imageRenderingValue,
typedArrayTypes
};
FeatureDetection.supportsBasis = function(scene) {
return FeatureDetection.supportsWebAssembly() && scene.context.supportsBasis;
};
FeatureDetection.supportsFullscreen = function() {
return Fullscreen_default.supportsFullscreen();
};
FeatureDetection.supportsTypedArrays = function() {
return typeof ArrayBuffer !== "undefined";
};
FeatureDetection.supportsBigInt64Array = function() {
return typeof BigInt64Array !== "undefined";
};
FeatureDetection.supportsBigUint64Array = function() {
return typeof BigUint64Array !== "undefined";
};
FeatureDetection.supportsBigInt = function() {
return typeof BigInt !== "undefined";
};
FeatureDetection.supportsWebWorkers = function() {
return typeof Worker !== "undefined";
};
FeatureDetection.supportsWebAssembly = function() {
return typeof WebAssembly !== "undefined";
};
var FeatureDetection_default = FeatureDetection;
// Source/Core/Quaternion.js
function Quaternion(x, y, z, w) {
this.x = defaultValue_default(x, 0);
this.y = defaultValue_default(y, 0);
this.z = defaultValue_default(z, 0);
this.w = defaultValue_default(w, 0);
}
var fromAxisAngleScratch = new Cartesian3_default();
Quaternion.fromAxisAngle = function(axis, angle, result) {
Check_default.typeOf.object("axis", axis);
Check_default.typeOf.number("angle", angle);
const halfAngle = angle / 2;
const s = Math.sin(halfAngle);
fromAxisAngleScratch = Cartesian3_default.normalize(axis, fromAxisAngleScratch);
const x = fromAxisAngleScratch.x * s;
const y = fromAxisAngleScratch.y * s;
const z = fromAxisAngleScratch.z * s;
const w = Math.cos(halfAngle);
if (!defined_default(result)) {
return new Quaternion(x, y, z, w);
}
result.x = x;
result.y = y;
result.z = z;
result.w = w;
return result;
};
var fromRotationMatrixNext = [1, 2, 0];
var fromRotationMatrixQuat = new Array(3);
Quaternion.fromRotationMatrix = function(matrix, result) {
Check_default.typeOf.object("matrix", matrix);
let root;
let x;
let y;
let z;
let w;
const m00 = matrix[Matrix3_default.COLUMN0ROW0];
const m11 = matrix[Matrix3_default.COLUMN1ROW1];
const m22 = matrix[Matrix3_default.COLUMN2ROW2];
const trace = m00 + m11 + m22;
if (trace > 0) {
root = Math.sqrt(trace + 1);
w = 0.5 * root;
root = 0.5 / root;
x = (matrix[Matrix3_default.COLUMN1ROW2] - matrix[Matrix3_default.COLUMN2ROW1]) * root;
y = (matrix[Matrix3_default.COLUMN2ROW0] - matrix[Matrix3_default.COLUMN0ROW2]) * root;
z = (matrix[Matrix3_default.COLUMN0ROW1] - matrix[Matrix3_default.COLUMN1ROW0]) * root;
} else {
const next = fromRotationMatrixNext;
let i = 0;
if (m11 > m00) {
i = 1;
}
if (m22 > m00 && m22 > m11) {
i = 2;
}
const j = next[i];
const k = next[j];
root = Math.sqrt(
matrix[Matrix3_default.getElementIndex(i, i)] - matrix[Matrix3_default.getElementIndex(j, j)] - matrix[Matrix3_default.getElementIndex(k, k)] + 1
);
const quat = fromRotationMatrixQuat;
quat[i] = 0.5 * root;
root = 0.5 / root;
w = (matrix[Matrix3_default.getElementIndex(k, j)] - matrix[Matrix3_default.getElementIndex(j, k)]) * root;
quat[j] = (matrix[Matrix3_default.getElementIndex(j, i)] + matrix[Matrix3_default.getElementIndex(i, j)]) * root;
quat[k] = (matrix[Matrix3_default.getElementIndex(k, i)] + matrix[Matrix3_default.getElementIndex(i, k)]) * root;
x = -quat[0];
y = -quat[1];
z = -quat[2];
}
if (!defined_default(result)) {
return new Quaternion(x, y, z, w);
}
result.x = x;
result.y = y;
result.z = z;
result.w = w;
return result;
};
var scratchHPRQuaternion = new Quaternion();
var scratchHeadingQuaternion = new Quaternion();
var scratchPitchQuaternion = new Quaternion();
var scratchRollQuaternion = new Quaternion();
Quaternion.fromHeadingPitchRoll = function(headingPitchRoll, result) {
Check_default.typeOf.object("headingPitchRoll", headingPitchRoll);
scratchRollQuaternion = Quaternion.fromAxisAngle(
Cartesian3_default.UNIT_X,
headingPitchRoll.roll,
scratchHPRQuaternion
);
scratchPitchQuaternion = Quaternion.fromAxisAngle(
Cartesian3_default.UNIT_Y,
-headingPitchRoll.pitch,
result
);
result = Quaternion.multiply(
scratchPitchQuaternion,
scratchRollQuaternion,
scratchPitchQuaternion
);
scratchHeadingQuaternion = Quaternion.fromAxisAngle(
Cartesian3_default.UNIT_Z,
-headingPitchRoll.heading,
scratchHPRQuaternion
);
return Quaternion.multiply(scratchHeadingQuaternion, result, result);
};
var sampledQuaternionAxis = new Cartesian3_default();
var sampledQuaternionRotation = new Cartesian3_default();
var sampledQuaternionTempQuaternion = new Quaternion();
var sampledQuaternionQuaternion0 = new Quaternion();
var sampledQuaternionQuaternion0Conjugate = new Quaternion();
Quaternion.packedLength = 4;
Quaternion.pack = function(value, array, startingIndex) {
Check_default.typeOf.object("value", value);
Check_default.defined("array", array);
startingIndex = defaultValue_default(startingIndex, 0);
array[startingIndex++] = value.x;
array[startingIndex++] = value.y;
array[startingIndex++] = value.z;
array[startingIndex] = value.w;
return array;
};
Quaternion.unpack = function(array, startingIndex, result) {
Check_default.defined("array", array);
startingIndex = defaultValue_default(startingIndex, 0);
if (!defined_default(result)) {
result = new Quaternion();
}
result.x = array[startingIndex];
result.y = array[startingIndex + 1];
result.z = array[startingIndex + 2];
result.w = array[startingIndex + 3];
return result;
};
Quaternion.packedInterpolationLength = 3;
Quaternion.convertPackedArrayForInterpolation = function(packedArray, startingIndex, lastIndex, result) {
Quaternion.unpack(
packedArray,
lastIndex * 4,
sampledQuaternionQuaternion0Conjugate
);
Quaternion.conjugate(
sampledQuaternionQuaternion0Conjugate,
sampledQuaternionQuaternion0Conjugate
);
for (let i = 0, len = lastIndex - startingIndex + 1; i < len; i++) {
const offset2 = i * 3;
Quaternion.unpack(
packedArray,
(startingIndex + i) * 4,
sampledQuaternionTempQuaternion
);
Quaternion.multiply(
sampledQuaternionTempQuaternion,
sampledQuaternionQuaternion0Conjugate,
sampledQuaternionTempQuaternion
);
if (sampledQuaternionTempQuaternion.w < 0) {
Quaternion.negate(
sampledQuaternionTempQuaternion,
sampledQuaternionTempQuaternion
);
}
Quaternion.computeAxis(
sampledQuaternionTempQuaternion,
sampledQuaternionAxis
);
const angle = Quaternion.computeAngle(sampledQuaternionTempQuaternion);
if (!defined_default(result)) {
result = [];
}
result[offset2] = sampledQuaternionAxis.x * angle;
result[offset2 + 1] = sampledQuaternionAxis.y * angle;
result[offset2 + 2] = sampledQuaternionAxis.z * angle;
}
};
Quaternion.unpackInterpolationResult = function(array, sourceArray, firstIndex, lastIndex, result) {
if (!defined_default(result)) {
result = new Quaternion();
}
Cartesian3_default.fromArray(array, 0, sampledQuaternionRotation);
const magnitude = Cartesian3_default.magnitude(sampledQuaternionRotation);
Quaternion.unpack(sourceArray, lastIndex * 4, sampledQuaternionQuaternion0);
if (magnitude === 0) {
Quaternion.clone(Quaternion.IDENTITY, sampledQuaternionTempQuaternion);
} else {
Quaternion.fromAxisAngle(
sampledQuaternionRotation,
magnitude,
sampledQuaternionTempQuaternion
);
}
return Quaternion.multiply(
sampledQuaternionTempQuaternion,
sampledQuaternionQuaternion0,
result
);
};
Quaternion.clone = function(quaternion, result) {
if (!defined_default(quaternion)) {
return void 0;
}
if (!defined_default(result)) {
return new Quaternion(
quaternion.x,
quaternion.y,
quaternion.z,
quaternion.w
);
}
result.x = quaternion.x;
result.y = quaternion.y;
result.z = quaternion.z;
result.w = quaternion.w;
return result;
};
Quaternion.conjugate = function(quaternion, result) {
Check_default.typeOf.object("quaternion", quaternion);
Check_default.typeOf.object("result", result);
result.x = -quaternion.x;
result.y = -quaternion.y;
result.z = -quaternion.z;
result.w = quaternion.w;
return result;
};
Quaternion.magnitudeSquared = function(quaternion) {
Check_default.typeOf.object("quaternion", quaternion);
return quaternion.x * quaternion.x + quaternion.y * quaternion.y + quaternion.z * quaternion.z + quaternion.w * quaternion.w;
};
Quaternion.magnitude = function(quaternion) {
return Math.sqrt(Quaternion.magnitudeSquared(quaternion));
};
Quaternion.normalize = function(quaternion, result) {
Check_default.typeOf.object("result", result);
const inverseMagnitude = 1 / Quaternion.magnitude(quaternion);
const x = quaternion.x * inverseMagnitude;
const y = quaternion.y * inverseMagnitude;
const z = quaternion.z * inverseMagnitude;
const w = quaternion.w * inverseMagnitude;
result.x = x;
result.y = y;
result.z = z;
result.w = w;
return result;
};
Quaternion.inverse = function(quaternion, result) {
Check_default.typeOf.object("result", result);
const magnitudeSquared = Quaternion.magnitudeSquared(quaternion);
result = Quaternion.conjugate(quaternion, result);
return Quaternion.multiplyByScalar(result, 1 / magnitudeSquared, result);
};
Quaternion.add = function(left, right, result) {
Check_default.typeOf.object("left", left);
Check_default.typeOf.object("right", right);
Check_default.typeOf.object("result", result);
result.x = left.x + right.x;
result.y = left.y + right.y;
result.z = left.z + right.z;
result.w = left.w + right.w;
return result;
};
Quaternion.subtract = function(left, right, result) {
Check_default.typeOf.object("left", left);
Check_default.typeOf.object("right", right);
Check_default.typeOf.object("result", result);
result.x = left.x - right.x;
result.y = left.y - right.y;
result.z = left.z - right.z;
result.w = left.w - right.w;
return result;
};
Quaternion.negate = function(quaternion, result) {
Check_default.typeOf.object("quaternion", quaternion);
Check_default.typeOf.object("result", result);
result.x = -quaternion.x;
result.y = -quaternion.y;
result.z = -quaternion.z;
result.w = -quaternion.w;
return result;
};
Quaternion.dot = function(left, right) {
Check_default.typeOf.object("left", left);
Check_default.typeOf.object("right", right);
return left.x * right.x + left.y * right.y + left.z * right.z + left.w * right.w;
};
Quaternion.multiply = function(left, right, result) {
Check_default.typeOf.object("left", left);
Check_default.typeOf.object("right", right);
Check_default.typeOf.object("result", result);
const leftX = left.x;
const leftY = left.y;
const leftZ = left.z;
const leftW = left.w;
const rightX = right.x;
const rightY = right.y;
const rightZ = right.z;
const rightW = right.w;
const x = leftW * rightX + leftX * rightW + leftY * rightZ - leftZ * rightY;
const y = leftW * rightY - leftX * rightZ + leftY * rightW + leftZ * rightX;
const z = leftW * rightZ + leftX * rightY - leftY * rightX + leftZ * rightW;
const w = leftW * rightW - leftX * rightX - leftY * rightY - leftZ * rightZ;
result.x = x;
result.y = y;
result.z = z;
result.w = w;
return result;
};
Quaternion.multiplyByScalar = function(quaternion, scalar, result) {
Check_default.typeOf.object("quaternion", quaternion);
Check_default.typeOf.number("scalar", scalar);
Check_default.typeOf.object("result", result);
result.x = quaternion.x * scalar;
result.y = quaternion.y * scalar;
result.z = quaternion.z * scalar;
result.w = quaternion.w * scalar;
return result;
};
Quaternion.divideByScalar = function(quaternion, scalar, result) {
Check_default.typeOf.object("quaternion", quaternion);
Check_default.typeOf.number("scalar", scalar);
Check_default.typeOf.object("result", result);
result.x = quaternion.x / scalar;
result.y = quaternion.y / scalar;
result.z = quaternion.z / scalar;
result.w = quaternion.w / scalar;
return result;
};
Quaternion.computeAxis = function(quaternion, result) {
Check_default.typeOf.object("quaternion", quaternion);
Check_default.typeOf.object("result", result);
const w = quaternion.w;
if (Math.abs(w - 1) < Math_default.EPSILON6) {
result.x = result.y = result.z = 0;
return result;
}
const scalar = 1 / Math.sqrt(1 - w * w);
result.x = quaternion.x * scalar;
result.y = quaternion.y * scalar;
result.z = quaternion.z * scalar;
return result;
};
Quaternion.computeAngle = function(quaternion) {
Check_default.typeOf.object("quaternion", quaternion);
if (Math.abs(quaternion.w - 1) < Math_default.EPSILON6) {
return 0;
}
return 2 * Math.acos(quaternion.w);
};
var lerpScratch4 = new Quaternion();
Quaternion.lerp = function(start, end, t, result) {
Check_default.typeOf.object("start", start);
Check_default.typeOf.object("end", end);
Check_default.typeOf.number("t", t);
Check_default.typeOf.object("result", result);
lerpScratch4 = Quaternion.multiplyByScalar(end, t, lerpScratch4);
result = Quaternion.multiplyByScalar(start, 1 - t, result);
return Quaternion.add(lerpScratch4, result, result);
};
var slerpEndNegated = new Quaternion();
var slerpScaledP = new Quaternion();
var slerpScaledR = new Quaternion();
Quaternion.slerp = function(start, end, t, result) {
Check_default.typeOf.object("start", start);
Check_default.typeOf.object("end", end);
Check_default.typeOf.number("t", t);
Check_default.typeOf.object("result", result);
let dot2 = Quaternion.dot(start, end);
let r = end;
if (dot2 < 0) {
dot2 = -dot2;
r = slerpEndNegated = Quaternion.negate(end, slerpEndNegated);
}
if (1 - dot2 < Math_default.EPSILON6) {
return Quaternion.lerp(start, r, t, result);
}
const theta = Math.acos(dot2);
slerpScaledP = Quaternion.multiplyByScalar(
start,
Math.sin((1 - t) * theta),
slerpScaledP
);
slerpScaledR = Quaternion.multiplyByScalar(
r,
Math.sin(t * theta),
slerpScaledR
);
result = Quaternion.add(slerpScaledP, slerpScaledR, result);
return Quaternion.multiplyByScalar(result, 1 / Math.sin(theta), result);
};
Quaternion.log = function(quaternion, result) {
Check_default.typeOf.object("quaternion", quaternion);
Check_default.typeOf.object("result", result);
const theta = Math_default.acosClamped(quaternion.w);
let thetaOverSinTheta = 0;
if (theta !== 0) {
thetaOverSinTheta = theta / Math.sin(theta);
}
return Cartesian3_default.multiplyByScalar(quaternion, thetaOverSinTheta, result);
};
Quaternion.exp = function(cartesian11, result) {
Check_default.typeOf.object("cartesian", cartesian11);
Check_default.typeOf.object("result", result);
const theta = Cartesian3_default.magnitude(cartesian11);
let sinThetaOverTheta = 0;
if (theta !== 0) {
sinThetaOverTheta = Math.sin(theta) / theta;
}
result.x = cartesian11.x * sinThetaOverTheta;
result.y = cartesian11.y * sinThetaOverTheta;
result.z = cartesian11.z * sinThetaOverTheta;
result.w = Math.cos(theta);
return result;
};
var squadScratchCartesian0 = new Cartesian3_default();
var squadScratchCartesian1 = new Cartesian3_default();
var squadScratchQuaternion0 = new Quaternion();
var squadScratchQuaternion1 = new Quaternion();
Quaternion.computeInnerQuadrangle = function(q0, q12, q22, result) {
Check_default.typeOf.object("q0", q0);
Check_default.typeOf.object("q1", q12);
Check_default.typeOf.object("q2", q22);
Check_default.typeOf.object("result", result);
const qInv = Quaternion.conjugate(q12, squadScratchQuaternion0);
Quaternion.multiply(qInv, q22, squadScratchQuaternion1);
const cart0 = Quaternion.log(squadScratchQuaternion1, squadScratchCartesian0);
Quaternion.multiply(qInv, q0, squadScratchQuaternion1);
const cart1 = Quaternion.log(squadScratchQuaternion1, squadScratchCartesian1);
Cartesian3_default.add(cart0, cart1, cart0);
Cartesian3_default.multiplyByScalar(cart0, 0.25, cart0);
Cartesian3_default.negate(cart0, cart0);
Quaternion.exp(cart0, squadScratchQuaternion0);
return Quaternion.multiply(q12, squadScratchQuaternion0, result);
};
Quaternion.squad = function(q0, q12, s0, s1, t, result) {
Check_default.typeOf.object("q0", q0);
Check_default.typeOf.object("q1", q12);
Check_default.typeOf.object("s0", s0);
Check_default.typeOf.object("s1", s1);
Check_default.typeOf.number("t", t);
Check_default.typeOf.object("result", result);
const slerp0 = Quaternion.slerp(q0, q12, t, squadScratchQuaternion0);
const slerp1 = Quaternion.slerp(s0, s1, t, squadScratchQuaternion1);
return Quaternion.slerp(slerp0, slerp1, 2 * t * (1 - t), result);
};
var fastSlerpScratchQuaternion = new Quaternion();
var opmu = 1.9011074535173003;
var u = FeatureDetection_default.supportsTypedArrays() ? new Float32Array(8) : [];
var v = FeatureDetection_default.supportsTypedArrays() ? new Float32Array(8) : [];
var bT = FeatureDetection_default.supportsTypedArrays() ? new Float32Array(8) : [];
var bD = FeatureDetection_default.supportsTypedArrays() ? new Float32Array(8) : [];
for (let i = 0; i < 7; ++i) {
const s = i + 1;
const t = 2 * s + 1;
u[i] = 1 / (s * t);
v[i] = s / t;
}
u[7] = opmu / (8 * 17);
v[7] = opmu * 8 / 17;
Quaternion.fastSlerp = function(start, end, t, result) {
Check_default.typeOf.object("start", start);
Check_default.typeOf.object("end", end);
Check_default.typeOf.number("t", t);
Check_default.typeOf.object("result", result);
let x = Quaternion.dot(start, end);
let sign2;
if (x >= 0) {
sign2 = 1;
} else {
sign2 = -1;
x = -x;
}
const xm1 = x - 1;
const d = 1 - t;
const sqrT = t * t;
const sqrD = d * d;
for (let i = 7; i >= 0; --i) {
bT[i] = (u[i] * sqrT - v[i]) * xm1;
bD[i] = (u[i] * sqrD - v[i]) * xm1;
}
const cT = sign2 * 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]))))))));
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]))))))));
const temp = Quaternion.multiplyByScalar(
start,
cD,
fastSlerpScratchQuaternion
);
Quaternion.multiplyByScalar(end, cT, result);
return Quaternion.add(temp, result, result);
};
Quaternion.fastSquad = function(q0, q12, s0, s1, t, result) {
Check_default.typeOf.object("q0", q0);
Check_default.typeOf.object("q1", q12);
Check_default.typeOf.object("s0", s0);
Check_default.typeOf.object("s1", s1);
Check_default.typeOf.number("t", t);
Check_default.typeOf.object("result", result);
const slerp0 = Quaternion.fastSlerp(q0, q12, t, squadScratchQuaternion0);
const slerp1 = Quaternion.fastSlerp(s0, s1, t, squadScratchQuaternion1);
return Quaternion.fastSlerp(slerp0, slerp1, 2 * t * (1 - t), result);
};
Quaternion.equals = function(left, right) {
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;
};
Quaternion.equalsEpsilon = function(left, right, epsilon) {
epsilon = defaultValue_default(epsilon, 0);
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;
};
Quaternion.ZERO = Object.freeze(new Quaternion(0, 0, 0, 0));
Quaternion.IDENTITY = Object.freeze(new Quaternion(0, 0, 0, 1));
Quaternion.prototype.clone = function(result) {
return Quaternion.clone(this, result);
};
Quaternion.prototype.equals = function(right) {
return Quaternion.equals(this, right);
};
Quaternion.prototype.equalsEpsilon = function(right, epsilon) {
return Quaternion.equalsEpsilon(this, right, epsilon);
};
Quaternion.prototype.toString = function() {
return `(${this.x}, ${this.y}, ${this.z}, ${this.w})`;
};
var Quaternion_default = Quaternion;
// Source/Core/Transforms.js
var Transforms = {};
var vectorProductLocalFrame = {
up: {
south: "east",
north: "west",
west: "south",
east: "north"
},
down: {
south: "west",
north: "east",
west: "north",
east: "south"
},
south: {
up: "west",
down: "east",
west: "down",
east: "up"
},
north: {
up: "east",
down: "west",
west: "up",
east: "down"
},
west: {
up: "north",
down: "south",
north: "down",
south: "up"
},
east: {
up: "south",
down: "north",
north: "up",
south: "down"
}
};
var degeneratePositionLocalFrame = {
north: [-1, 0, 0],
east: [0, 1, 0],
up: [0, 0, 1],
south: [1, 0, 0],
west: [0, -1, 0],
down: [0, 0, -1]
};
var localFrameToFixedFrameCache = {};
var scratchCalculateCartesian = {
east: new Cartesian3_default(),
north: new Cartesian3_default(),
up: new Cartesian3_default(),
west: new Cartesian3_default(),
south: new Cartesian3_default(),
down: new Cartesian3_default()
};
var scratchFirstCartesian = new Cartesian3_default();
var scratchSecondCartesian = new Cartesian3_default();
var scratchThirdCartesian = new Cartesian3_default();
Transforms.localFrameToFixedFrameGenerator = function(firstAxis, secondAxis) {
if (!vectorProductLocalFrame.hasOwnProperty(firstAxis) || !vectorProductLocalFrame[firstAxis].hasOwnProperty(secondAxis)) {
throw new DeveloperError_default(
"firstAxis and secondAxis must be east, north, up, west, south or down."
);
}
const thirdAxis = vectorProductLocalFrame[firstAxis][secondAxis];
let resultat;
const hashAxis = firstAxis + secondAxis;
if (defined_default(localFrameToFixedFrameCache[hashAxis])) {
resultat = localFrameToFixedFrameCache[hashAxis];
} else {
resultat = function(origin, ellipsoid, result) {
if (!defined_default(origin)) {
throw new DeveloperError_default("origin is required.");
}
if (!defined_default(result)) {
result = new Matrix4_default();
}
if (Cartesian3_default.equalsEpsilon(origin, Cartesian3_default.ZERO, Math_default.EPSILON14)) {
Cartesian3_default.unpack(
degeneratePositionLocalFrame[firstAxis],
0,
scratchFirstCartesian
);
Cartesian3_default.unpack(
degeneratePositionLocalFrame[secondAxis],
0,
scratchSecondCartesian
);
Cartesian3_default.unpack(
degeneratePositionLocalFrame[thirdAxis],
0,
scratchThirdCartesian
);
} else if (Math_default.equalsEpsilon(origin.x, 0, Math_default.EPSILON14) && Math_default.equalsEpsilon(origin.y, 0, Math_default.EPSILON14)) {
const sign2 = Math_default.sign(origin.z);
Cartesian3_default.unpack(
degeneratePositionLocalFrame[firstAxis],
0,
scratchFirstCartesian
);
if (firstAxis !== "east" && firstAxis !== "west") {
Cartesian3_default.multiplyByScalar(
scratchFirstCartesian,
sign2,
scratchFirstCartesian
);
}
Cartesian3_default.unpack(
degeneratePositionLocalFrame[secondAxis],
0,
scratchSecondCartesian
);
if (secondAxis !== "east" && secondAxis !== "west") {
Cartesian3_default.multiplyByScalar(
scratchSecondCartesian,
sign2,
scratchSecondCartesian
);
}
Cartesian3_default.unpack(
degeneratePositionLocalFrame[thirdAxis],
0,
scratchThirdCartesian
);
if (thirdAxis !== "east" && thirdAxis !== "west") {
Cartesian3_default.multiplyByScalar(
scratchThirdCartesian,
sign2,
scratchThirdCartesian
);
}
} else {
ellipsoid = defaultValue_default(ellipsoid, Ellipsoid_default.WGS84);
ellipsoid.geodeticSurfaceNormal(origin, scratchCalculateCartesian.up);
const up = scratchCalculateCartesian.up;
const east = scratchCalculateCartesian.east;
east.x = -origin.y;
east.y = origin.x;
east.z = 0;
Cartesian3_default.normalize(east, scratchCalculateCartesian.east);
Cartesian3_default.cross(up, east, scratchCalculateCartesian.north);
Cartesian3_default.multiplyByScalar(
scratchCalculateCartesian.up,
-1,
scratchCalculateCartesian.down
);
Cartesian3_default.multiplyByScalar(
scratchCalculateCartesian.east,
-1,
scratchCalculateCartesian.west
);
Cartesian3_default.multiplyByScalar(
scratchCalculateCartesian.north,
-1,
scratchCalculateCartesian.south
);
scratchFirstCartesian = scratchCalculateCartesian[firstAxis];
scratchSecondCartesian = scratchCalculateCartesian[secondAxis];
scratchThirdCartesian = scratchCalculateCartesian[thirdAxis];
}
result[0] = scratchFirstCartesian.x;
result[1] = scratchFirstCartesian.y;
result[2] = scratchFirstCartesian.z;
result[3] = 0;
result[4] = scratchSecondCartesian.x;
result[5] = scratchSecondCartesian.y;
result[6] = scratchSecondCartesian.z;
result[7] = 0;
result[8] = scratchThirdCartesian.x;
result[9] = scratchThirdCartesian.y;
result[10] = scratchThirdCartesian.z;
result[11] = 0;
result[12] = origin.x;
result[13] = origin.y;
result[14] = origin.z;
result[15] = 1;
return result;
};
localFrameToFixedFrameCache[hashAxis] = resultat;
}
return resultat;
};
Transforms.eastNorthUpToFixedFrame = Transforms.localFrameToFixedFrameGenerator(
"east",
"north"
);
Transforms.northEastDownToFixedFrame = Transforms.localFrameToFixedFrameGenerator(
"north",
"east"
);
Transforms.northUpEastToFixedFrame = Transforms.localFrameToFixedFrameGenerator(
"north",
"up"
);
Transforms.northWestUpToFixedFrame = Transforms.localFrameToFixedFrameGenerator(
"north",
"west"
);
var scratchHPRQuaternion2 = new Quaternion_default();
var scratchScale = new Cartesian3_default(1, 1, 1);
var scratchHPRMatrix4 = new Matrix4_default();
Transforms.headingPitchRollToFixedFrame = function(origin, headingPitchRoll, ellipsoid, fixedFrameTransform, result) {
Check_default.typeOf.object("HeadingPitchRoll", headingPitchRoll);
fixedFrameTransform = defaultValue_default(
fixedFrameTransform,
Transforms.eastNorthUpToFixedFrame
);
const hprQuaternion = Quaternion_default.fromHeadingPitchRoll(
headingPitchRoll,
scratchHPRQuaternion2
);
const hprMatrix = Matrix4_default.fromTranslationQuaternionRotationScale(
Cartesian3_default.ZERO,
hprQuaternion,
scratchScale,
scratchHPRMatrix4
);
result = fixedFrameTransform(origin, ellipsoid, result);
return Matrix4_default.multiply(result, hprMatrix, result);
};
var scratchENUMatrix4 = new Matrix4_default();
var scratchHPRMatrix3 = new Matrix3_default();
Transforms.headingPitchRollQuaternion = function(origin, headingPitchRoll, ellipsoid, fixedFrameTransform, result) {
Check_default.typeOf.object("HeadingPitchRoll", headingPitchRoll);
const transform3 = Transforms.headingPitchRollToFixedFrame(
origin,
headingPitchRoll,
ellipsoid,
fixedFrameTransform,
scratchENUMatrix4
);
const rotation = Matrix4_default.getMatrix3(transform3, scratchHPRMatrix3);
return Quaternion_default.fromRotationMatrix(rotation, result);
};
var noScale = new Cartesian3_default(1, 1, 1);
var hprCenterScratch = new Cartesian3_default();
var ffScratch = new Matrix4_default();
var hprTransformScratch = new Matrix4_default();
var hprRotationScratch = new Matrix3_default();
var hprQuaternionScratch = new Quaternion_default();
Transforms.fixedFrameToHeadingPitchRoll = function(transform3, ellipsoid, fixedFrameTransform, result) {
Check_default.defined("transform", transform3);
ellipsoid = defaultValue_default(ellipsoid, Ellipsoid_default.WGS84);
fixedFrameTransform = defaultValue_default(
fixedFrameTransform,
Transforms.eastNorthUpToFixedFrame
);
if (!defined_default(result)) {
result = new HeadingPitchRoll_default();
}
const center = Matrix4_default.getTranslation(transform3, hprCenterScratch);
if (Cartesian3_default.equals(center, Cartesian3_default.ZERO)) {
result.heading = 0;
result.pitch = 0;
result.roll = 0;
return result;
}
let toFixedFrame = Matrix4_default.inverseTransformation(
fixedFrameTransform(center, ellipsoid, ffScratch),
ffScratch
);
let transformCopy = Matrix4_default.setScale(transform3, noScale, hprTransformScratch);
transformCopy = Matrix4_default.setTranslation(
transformCopy,
Cartesian3_default.ZERO,
transformCopy
);
toFixedFrame = Matrix4_default.multiply(toFixedFrame, transformCopy, toFixedFrame);
let quaternionRotation = Quaternion_default.fromRotationMatrix(
Matrix4_default.getMatrix3(toFixedFrame, hprRotationScratch),
hprQuaternionScratch
);
quaternionRotation = Quaternion_default.normalize(
quaternionRotation,
quaternionRotation
);
return HeadingPitchRoll_default.fromQuaternion(quaternionRotation, result);
};
var gmstConstant0 = 6 * 3600 + 41 * 60 + 50.54841;
var gmstConstant1 = 8640184812866e-6;
var gmstConstant2 = 0.093104;
var gmstConstant3 = -62e-7;
var rateCoef = 11772758384668e-32;
var wgs84WRPrecessing = 72921158553e-15;
var twoPiOverSecondsInDay = Math_default.TWO_PI / 86400;
var dateInUtc = new JulianDate_default();
Transforms.computeTemeToPseudoFixedMatrix = function(date, result) {
if (!defined_default(date)) {
throw new DeveloperError_default("date is required.");
}
dateInUtc = JulianDate_default.addSeconds(
date,
-JulianDate_default.computeTaiMinusUtc(date),
dateInUtc
);
const utcDayNumber = dateInUtc.dayNumber;
const utcSecondsIntoDay = dateInUtc.secondsOfDay;
let t;
const diffDays = utcDayNumber - 2451545;
if (utcSecondsIntoDay >= 43200) {
t = (diffDays + 0.5) / TimeConstants_default.DAYS_PER_JULIAN_CENTURY;
} else {
t = (diffDays - 0.5) / TimeConstants_default.DAYS_PER_JULIAN_CENTURY;
}
const gmst0 = gmstConstant0 + t * (gmstConstant1 + t * (gmstConstant2 + t * gmstConstant3));
const angle = gmst0 * twoPiOverSecondsInDay % Math_default.TWO_PI;
const ratio = wgs84WRPrecessing + rateCoef * (utcDayNumber - 24515455e-1);
const secondsSinceMidnight = (utcSecondsIntoDay + TimeConstants_default.SECONDS_PER_DAY * 0.5) % TimeConstants_default.SECONDS_PER_DAY;
const gha = angle + ratio * secondsSinceMidnight;
const cosGha = Math.cos(gha);
const sinGha = Math.sin(gha);
if (!defined_default(result)) {
return new Matrix3_default(
cosGha,
sinGha,
0,
-sinGha,
cosGha,
0,
0,
0,
1
);
}
result[0] = cosGha;
result[1] = -sinGha;
result[2] = 0;
result[3] = sinGha;
result[4] = cosGha;
result[5] = 0;
result[6] = 0;
result[7] = 0;
result[8] = 1;
return result;
};
Transforms.iau2006XysData = new Iau2006XysData_default();
Transforms.earthOrientationParameters = EarthOrientationParameters_default.NONE;
var ttMinusTai = 32.184;
var j2000ttDays = 2451545;
Transforms.preloadIcrfFixed = function(timeInterval) {
const startDayTT = timeInterval.start.dayNumber;
const startSecondTT = timeInterval.start.secondsOfDay + ttMinusTai;
const stopDayTT = timeInterval.stop.dayNumber;
const stopSecondTT = timeInterval.stop.secondsOfDay + ttMinusTai;
const xysPromise = Transforms.iau2006XysData.preload(
startDayTT,
startSecondTT,
stopDayTT,
stopSecondTT
);
const eopPromise = Transforms.earthOrientationParameters.getPromiseToLoad();
return Promise.all([xysPromise, eopPromise]);
};
Transforms.computeIcrfToFixedMatrix = function(date, result) {
if (!defined_default(date)) {
throw new DeveloperError_default("date is required.");
}
if (!defined_default(result)) {
result = new Matrix3_default();
}
const fixedToIcrfMtx = Transforms.computeFixedToIcrfMatrix(date, result);
if (!defined_default(fixedToIcrfMtx)) {
return void 0;
}
return Matrix3_default.transpose(fixedToIcrfMtx, result);
};
var xysScratch = new Iau2006XysSample_default(0, 0, 0);
var eopScratch = new EarthOrientationParametersSample_default(
0,
0,
0,
0,
0,
0
);
var rotation1Scratch = new Matrix3_default();
var rotation2Scratch = new Matrix3_default();
Transforms.computeFixedToIcrfMatrix = function(date, result) {
if (!defined_default(date)) {
throw new DeveloperError_default("date is required.");
}
if (!defined_default(result)) {
result = new Matrix3_default();
}
const eop = Transforms.earthOrientationParameters.compute(date, eopScratch);
if (!defined_default(eop)) {
return void 0;
}
const dayTT = date.dayNumber;
const secondTT = date.secondsOfDay + ttMinusTai;
const xys = Transforms.iau2006XysData.computeXysRadians(
dayTT,
secondTT,
xysScratch
);
if (!defined_default(xys)) {
return void 0;
}
const x = xys.x + eop.xPoleOffset;
const y = xys.y + eop.yPoleOffset;
const a3 = 1 / (1 + Math.sqrt(1 - x * x - y * y));
const rotation1 = rotation1Scratch;
rotation1[0] = 1 - a3 * x * x;
rotation1[3] = -a3 * x * y;
rotation1[6] = x;
rotation1[1] = -a3 * x * y;
rotation1[4] = 1 - a3 * y * y;
rotation1[7] = y;
rotation1[2] = -x;
rotation1[5] = -y;
rotation1[8] = 1 - a3 * (x * x + y * y);
const rotation2 = Matrix3_default.fromRotationZ(-xys.s, rotation2Scratch);
const matrixQ = Matrix3_default.multiply(rotation1, rotation2, rotation1Scratch);
const dateUt1day = date.dayNumber;
const dateUt1sec = date.secondsOfDay - JulianDate_default.computeTaiMinusUtc(date) + eop.ut1MinusUtc;
const daysSinceJ2000 = dateUt1day - 2451545;
const fractionOfDay = dateUt1sec / TimeConstants_default.SECONDS_PER_DAY;
let era = 0.779057273264 + fractionOfDay + 0.00273781191135448 * (daysSinceJ2000 + fractionOfDay);
era = era % 1 * Math_default.TWO_PI;
const earthRotation = Matrix3_default.fromRotationZ(era, rotation2Scratch);
const pfToIcrf = Matrix3_default.multiply(matrixQ, earthRotation, rotation1Scratch);
const cosxp = Math.cos(eop.xPoleWander);
const cosyp = Math.cos(eop.yPoleWander);
const sinxp = Math.sin(eop.xPoleWander);
const sinyp = Math.sin(eop.yPoleWander);
let ttt = dayTT - j2000ttDays + secondTT / TimeConstants_default.SECONDS_PER_DAY;
ttt /= 36525;
const sp = -47e-6 * ttt * Math_default.RADIANS_PER_DEGREE / 3600;
const cossp = Math.cos(sp);
const sinsp = Math.sin(sp);
const fToPfMtx = rotation2Scratch;
fToPfMtx[0] = cosxp * cossp;
fToPfMtx[1] = cosxp * sinsp;
fToPfMtx[2] = sinxp;
fToPfMtx[3] = -cosyp * sinsp + sinyp * sinxp * cossp;
fToPfMtx[4] = cosyp * cossp + sinyp * sinxp * sinsp;
fToPfMtx[5] = -sinyp * cosxp;
fToPfMtx[6] = -sinyp * sinsp - cosyp * sinxp * cossp;
fToPfMtx[7] = sinyp * cossp - cosyp * sinxp * sinsp;
fToPfMtx[8] = cosyp * cosxp;
return Matrix3_default.multiply(pfToIcrf, fToPfMtx, result);
};
var pointToWindowCoordinatesTemp = new Cartesian4_default();
Transforms.pointToWindowCoordinates = function(modelViewProjectionMatrix, viewportTransformation, point, result) {
result = Transforms.pointToGLWindowCoordinates(
modelViewProjectionMatrix,
viewportTransformation,
point,
result
);
result.y = 2 * viewportTransformation[5] - result.y;
return result;
};
Transforms.pointToGLWindowCoordinates = function(modelViewProjectionMatrix, viewportTransformation, point, result) {
if (!defined_default(modelViewProjectionMatrix)) {
throw new DeveloperError_default("modelViewProjectionMatrix is required.");
}
if (!defined_default(viewportTransformation)) {
throw new DeveloperError_default("viewportTransformation is required.");
}
if (!defined_default(point)) {
throw new DeveloperError_default("point is required.");
}
if (!defined_default(result)) {
result = new Cartesian2_default();
}
const tmp2 = pointToWindowCoordinatesTemp;
Matrix4_default.multiplyByVector(
modelViewProjectionMatrix,
Cartesian4_default.fromElements(point.x, point.y, point.z, 1, tmp2),
tmp2
);
Cartesian4_default.multiplyByScalar(tmp2, 1 / tmp2.w, tmp2);
Matrix4_default.multiplyByVector(viewportTransformation, tmp2, tmp2);
return Cartesian2_default.fromCartesian4(tmp2, result);
};
var normalScratch = new Cartesian3_default();
var rightScratch = new Cartesian3_default();
var upScratch = new Cartesian3_default();
Transforms.rotationMatrixFromPositionVelocity = function(position, velocity, ellipsoid, result) {
if (!defined_default(position)) {
throw new DeveloperError_default("position is required.");
}
if (!defined_default(velocity)) {
throw new DeveloperError_default("velocity is required.");
}
const normal2 = defaultValue_default(ellipsoid, Ellipsoid_default.WGS84).geodeticSurfaceNormal(
position,
normalScratch
);
let right = Cartesian3_default.cross(velocity, normal2, rightScratch);
if (Cartesian3_default.equalsEpsilon(right, Cartesian3_default.ZERO, Math_default.EPSILON6)) {
right = Cartesian3_default.clone(Cartesian3_default.UNIT_X, right);
}
const up = Cartesian3_default.cross(right, velocity, upScratch);
Cartesian3_default.normalize(up, up);
Cartesian3_default.cross(velocity, up, right);
Cartesian3_default.negate(right, right);
Cartesian3_default.normalize(right, right);
if (!defined_default(result)) {
result = new Matrix3_default();
}
result[0] = velocity.x;
result[1] = velocity.y;
result[2] = velocity.z;
result[3] = right.x;
result[4] = right.y;
result[5] = right.z;
result[6] = up.x;
result[7] = up.y;
result[8] = up.z;
return result;
};
var swizzleMatrix = new Matrix4_default(
0,
0,
1,
0,
1,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
1
);
var scratchCartographic = new Cartographic_default();
var scratchCartesian3Projection = new Cartesian3_default();
var scratchCenter = new Cartesian3_default();
var scratchRotation = new Matrix3_default();
var scratchFromENU = new Matrix4_default();
var scratchToENU = new Matrix4_default();
Transforms.basisTo2D = function(projection, matrix, result) {
if (!defined_default(projection)) {
throw new DeveloperError_default("projection is required.");
}
if (!defined_default(matrix)) {
throw new DeveloperError_default("matrix is required.");
}
if (!defined_default(result)) {
throw new DeveloperError_default("result is required.");
}
const rtcCenter = Matrix4_default.getTranslation(matrix, scratchCenter);
const ellipsoid = projection.ellipsoid;
const cartographic2 = ellipsoid.cartesianToCartographic(
rtcCenter,
scratchCartographic
);
const projectedPosition2 = projection.project(
cartographic2,
scratchCartesian3Projection
);
Cartesian3_default.fromElements(
projectedPosition2.z,
projectedPosition2.x,
projectedPosition2.y,
projectedPosition2
);
const fromENU = Transforms.eastNorthUpToFixedFrame(
rtcCenter,
ellipsoid,
scratchFromENU
);
const toENU = Matrix4_default.inverseTransformation(fromENU, scratchToENU);
const rotation = Matrix4_default.getMatrix3(matrix, scratchRotation);
const local = Matrix4_default.multiplyByMatrix3(toENU, rotation, result);
Matrix4_default.multiply(swizzleMatrix, local, result);
Matrix4_default.setTranslation(result, projectedPosition2, result);
return result;
};
Transforms.wgs84To2DModelMatrix = function(projection, center, result) {
if (!defined_default(projection)) {
throw new DeveloperError_default("projection is required.");
}
if (!defined_default(center)) {
throw new DeveloperError_default("center is required.");
}
if (!defined_default(result)) {
throw new DeveloperError_default("result is required.");
}
const ellipsoid = projection.ellipsoid;
const fromENU = Transforms.eastNorthUpToFixedFrame(
center,
ellipsoid,
scratchFromENU
);
const toENU = Matrix4_default.inverseTransformation(fromENU, scratchToENU);
const cartographic2 = ellipsoid.cartesianToCartographic(
center,
scratchCartographic
);
const projectedPosition2 = projection.project(
cartographic2,
scratchCartesian3Projection
);
Cartesian3_default.fromElements(
projectedPosition2.z,
projectedPosition2.x,
projectedPosition2.y,
projectedPosition2
);
const translation3 = Matrix4_default.fromTranslation(
projectedPosition2,
scratchFromENU
);
Matrix4_default.multiply(swizzleMatrix, toENU, result);
Matrix4_default.multiply(translation3, result, result);
return result;
};
var Transforms_default = Transforms;
// Source/Core/EllipsoidTangentPlane.js
var scratchCart4 = new Cartesian4_default();
function EllipsoidTangentPlane(origin, ellipsoid) {
Check_default.defined("origin", origin);
ellipsoid = defaultValue_default(ellipsoid, Ellipsoid_default.WGS84);
origin = ellipsoid.scaleToGeodeticSurface(origin);
if (!defined_default(origin)) {
throw new DeveloperError_default(
"origin must not be at the center of the ellipsoid."
);
}
const eastNorthUp = Transforms_default.eastNorthUpToFixedFrame(origin, ellipsoid);
this._ellipsoid = ellipsoid;
this._origin = origin;
this._xAxis = Cartesian3_default.fromCartesian4(
Matrix4_default.getColumn(eastNorthUp, 0, scratchCart4)
);
this._yAxis = Cartesian3_default.fromCartesian4(
Matrix4_default.getColumn(eastNorthUp, 1, scratchCart4)
);
const normal2 = Cartesian3_default.fromCartesian4(
Matrix4_default.getColumn(eastNorthUp, 2, scratchCart4)
);
this._plane = Plane_default.fromPointNormal(origin, normal2);
}
Object.defineProperties(EllipsoidTangentPlane.prototype, {
ellipsoid: {
get: function() {
return this._ellipsoid;
}
},
origin: {
get: function() {
return this._origin;
}
},
plane: {
get: function() {
return this._plane;
}
},
xAxis: {
get: function() {
return this._xAxis;
}
},
yAxis: {
get: function() {
return this._yAxis;
}
},
zAxis: {
get: function() {
return this._plane.normal;
}
}
});
var tmp = new AxisAlignedBoundingBox_default();
EllipsoidTangentPlane.fromPoints = function(cartesians, ellipsoid) {
Check_default.defined("cartesians", cartesians);
const box = AxisAlignedBoundingBox_default.fromPoints(cartesians, tmp);
return new EllipsoidTangentPlane(box.center, ellipsoid);
};
var scratchProjectPointOntoPlaneRay = new Ray_default();
var scratchProjectPointOntoPlaneCartesian3 = new Cartesian3_default();
EllipsoidTangentPlane.prototype.projectPointOntoPlane = function(cartesian11, result) {
Check_default.defined("cartesian", cartesian11);
const ray = scratchProjectPointOntoPlaneRay;
ray.origin = cartesian11;
Cartesian3_default.normalize(cartesian11, ray.direction);
let intersectionPoint = IntersectionTests_default.rayPlane(
ray,
this._plane,
scratchProjectPointOntoPlaneCartesian3
);
if (!defined_default(intersectionPoint)) {
Cartesian3_default.negate(ray.direction, ray.direction);
intersectionPoint = IntersectionTests_default.rayPlane(
ray,
this._plane,
scratchProjectPointOntoPlaneCartesian3
);
}
if (defined_default(intersectionPoint)) {
const v7 = Cartesian3_default.subtract(
intersectionPoint,
this._origin,
intersectionPoint
);
const x = Cartesian3_default.dot(this._xAxis, v7);
const y = Cartesian3_default.dot(this._yAxis, v7);
if (!defined_default(result)) {
return new Cartesian2_default(x, y);
}
result.x = x;
result.y = y;
return result;
}
return void 0;
};
EllipsoidTangentPlane.prototype.projectPointsOntoPlane = function(cartesians, result) {
Check_default.defined("cartesians", cartesians);
if (!defined_default(result)) {
result = [];
}
let count = 0;
const length3 = cartesians.length;
for (let i = 0; i < length3; i++) {
const p = this.projectPointOntoPlane(cartesians[i], result[count]);
if (defined_default(p)) {
result[count] = p;
count++;
}
}
result.length = count;
return result;
};
EllipsoidTangentPlane.prototype.projectPointToNearestOnPlane = function(cartesian11, result) {
Check_default.defined("cartesian", cartesian11);
if (!defined_default(result)) {
result = new Cartesian2_default();
}
const ray = scratchProjectPointOntoPlaneRay;
ray.origin = cartesian11;
Cartesian3_default.clone(this._plane.normal, ray.direction);
let intersectionPoint = IntersectionTests_default.rayPlane(
ray,
this._plane,
scratchProjectPointOntoPlaneCartesian3
);
if (!defined_default(intersectionPoint)) {
Cartesian3_default.negate(ray.direction, ray.direction);
intersectionPoint = IntersectionTests_default.rayPlane(
ray,
this._plane,
scratchProjectPointOntoPlaneCartesian3
);
}
const v7 = Cartesian3_default.subtract(
intersectionPoint,
this._origin,
intersectionPoint
);
const x = Cartesian3_default.dot(this._xAxis, v7);
const y = Cartesian3_default.dot(this._yAxis, v7);
result.x = x;
result.y = y;
return result;
};
EllipsoidTangentPlane.prototype.projectPointsToNearestOnPlane = function(cartesians, result) {
Check_default.defined("cartesians", cartesians);
if (!defined_default(result)) {
result = [];
}
const length3 = cartesians.length;
result.length = length3;
for (let i = 0; i < length3; i++) {
result[i] = this.projectPointToNearestOnPlane(cartesians[i], result[i]);
}
return result;
};
var projectPointsOntoEllipsoidScratch = new Cartesian3_default();
EllipsoidTangentPlane.prototype.projectPointOntoEllipsoid = function(cartesian11, result) {
Check_default.defined("cartesian", cartesian11);
if (!defined_default(result)) {
result = new Cartesian3_default();
}
const ellipsoid = this._ellipsoid;
const origin = this._origin;
const xAxis = this._xAxis;
const yAxis = this._yAxis;
const tmp2 = projectPointsOntoEllipsoidScratch;
Cartesian3_default.multiplyByScalar(xAxis, cartesian11.x, tmp2);
result = Cartesian3_default.add(origin, tmp2, result);
Cartesian3_default.multiplyByScalar(yAxis, cartesian11.y, tmp2);
Cartesian3_default.add(result, tmp2, result);
ellipsoid.scaleToGeocentricSurface(result, result);
return result;
};
EllipsoidTangentPlane.prototype.projectPointsOntoEllipsoid = function(cartesians, result) {
Check_default.defined("cartesians", cartesians);
const length3 = cartesians.length;
if (!defined_default(result)) {
result = new Array(length3);
} else {
result.length = length3;
}
for (let i = 0; i < length3; ++i) {
result[i] = this.projectPointOntoEllipsoid(cartesians[i], result[i]);
}
return result;
};
var EllipsoidTangentPlane_default = EllipsoidTangentPlane;
// Source/Core/OrientedBoundingBox.js
function OrientedBoundingBox(center, halfAxes) {
this.center = Cartesian3_default.clone(defaultValue_default(center, Cartesian3_default.ZERO));
this.halfAxes = Matrix3_default.clone(defaultValue_default(halfAxes, Matrix3_default.ZERO));
}
OrientedBoundingBox.packedLength = Cartesian3_default.packedLength + Matrix3_default.packedLength;
OrientedBoundingBox.pack = function(value, array, startingIndex) {
Check_default.typeOf.object("value", value);
Check_default.defined("array", array);
startingIndex = defaultValue_default(startingIndex, 0);
Cartesian3_default.pack(value.center, array, startingIndex);
Matrix3_default.pack(value.halfAxes, array, startingIndex + Cartesian3_default.packedLength);
return array;
};
OrientedBoundingBox.unpack = function(array, startingIndex, result) {
Check_default.defined("array", array);
startingIndex = defaultValue_default(startingIndex, 0);
if (!defined_default(result)) {
result = new OrientedBoundingBox();
}
Cartesian3_default.unpack(array, startingIndex, result.center);
Matrix3_default.unpack(
array,
startingIndex + Cartesian3_default.packedLength,
result.halfAxes
);
return result;
};
var scratchCartesian1 = new Cartesian3_default();
var scratchCartesian22 = new Cartesian3_default();
var scratchCartesian32 = new Cartesian3_default();
var scratchCartesian4 = new Cartesian3_default();
var scratchCartesian5 = new Cartesian3_default();
var scratchCartesian6 = new Cartesian3_default();
var scratchCovarianceResult = new Matrix3_default();
var scratchEigenResult = {
unitary: new Matrix3_default(),
diagonal: new Matrix3_default()
};
OrientedBoundingBox.fromPoints = function(positions, result) {
if (!defined_default(result)) {
result = new OrientedBoundingBox();
}
if (!defined_default(positions) || positions.length === 0) {
result.halfAxes = Matrix3_default.ZERO;
result.center = Cartesian3_default.ZERO;
return result;
}
let i;
const length3 = positions.length;
const meanPoint = Cartesian3_default.clone(positions[0], scratchCartesian1);
for (i = 1; i < length3; i++) {
Cartesian3_default.add(meanPoint, positions[i], meanPoint);
}
const invLength = 1 / length3;
Cartesian3_default.multiplyByScalar(meanPoint, invLength, meanPoint);
let exx = 0;
let exy = 0;
let exz = 0;
let eyy = 0;
let eyz = 0;
let ezz = 0;
let p;
for (i = 0; i < length3; i++) {
p = Cartesian3_default.subtract(positions[i], meanPoint, scratchCartesian22);
exx += p.x * p.x;
exy += p.x * p.y;
exz += p.x * p.z;
eyy += p.y * p.y;
eyz += p.y * p.z;
ezz += p.z * p.z;
}
exx *= invLength;
exy *= invLength;
exz *= invLength;
eyy *= invLength;
eyz *= invLength;
ezz *= invLength;
const covarianceMatrix = scratchCovarianceResult;
covarianceMatrix[0] = exx;
covarianceMatrix[1] = exy;
covarianceMatrix[2] = exz;
covarianceMatrix[3] = exy;
covarianceMatrix[4] = eyy;
covarianceMatrix[5] = eyz;
covarianceMatrix[6] = exz;
covarianceMatrix[7] = eyz;
covarianceMatrix[8] = ezz;
const eigenDecomposition = Matrix3_default.computeEigenDecomposition(
covarianceMatrix,
scratchEigenResult
);
const rotation = Matrix3_default.clone(eigenDecomposition.unitary, result.halfAxes);
let v13 = Matrix3_default.getColumn(rotation, 0, scratchCartesian4);
let v23 = Matrix3_default.getColumn(rotation, 1, scratchCartesian5);
let v32 = Matrix3_default.getColumn(rotation, 2, scratchCartesian6);
let u12 = -Number.MAX_VALUE;
let u22 = -Number.MAX_VALUE;
let u3 = -Number.MAX_VALUE;
let l1 = Number.MAX_VALUE;
let l2 = Number.MAX_VALUE;
let l3 = Number.MAX_VALUE;
for (i = 0; i < length3; i++) {
p = positions[i];
u12 = Math.max(Cartesian3_default.dot(v13, p), u12);
u22 = Math.max(Cartesian3_default.dot(v23, p), u22);
u3 = Math.max(Cartesian3_default.dot(v32, p), u3);
l1 = Math.min(Cartesian3_default.dot(v13, p), l1);
l2 = Math.min(Cartesian3_default.dot(v23, p), l2);
l3 = Math.min(Cartesian3_default.dot(v32, p), l3);
}
v13 = Cartesian3_default.multiplyByScalar(v13, 0.5 * (l1 + u12), v13);
v23 = Cartesian3_default.multiplyByScalar(v23, 0.5 * (l2 + u22), v23);
v32 = Cartesian3_default.multiplyByScalar(v32, 0.5 * (l3 + u3), v32);
const center = Cartesian3_default.add(v13, v23, result.center);
Cartesian3_default.add(center, v32, center);
const scale = scratchCartesian32;
scale.x = u12 - l1;
scale.y = u22 - l2;
scale.z = u3 - l3;
Cartesian3_default.multiplyByScalar(scale, 0.5, scale);
Matrix3_default.multiplyByScale(result.halfAxes, scale, result.halfAxes);
return result;
};
var scratchOffset = new Cartesian3_default();
var scratchScale2 = new Cartesian3_default();
function fromPlaneExtents(planeOrigin, planeXAxis, planeYAxis, planeZAxis, minimumX, maximumX, minimumY, maximumY, minimumZ, maximumZ, result) {
if (!defined_default(minimumX) || !defined_default(maximumX) || !defined_default(minimumY) || !defined_default(maximumY) || !defined_default(minimumZ) || !defined_default(maximumZ)) {
throw new DeveloperError_default(
"all extents (minimum/maximum X/Y/Z) are required."
);
}
if (!defined_default(result)) {
result = new OrientedBoundingBox();
}
const halfAxes = result.halfAxes;
Matrix3_default.setColumn(halfAxes, 0, planeXAxis, halfAxes);
Matrix3_default.setColumn(halfAxes, 1, planeYAxis, halfAxes);
Matrix3_default.setColumn(halfAxes, 2, planeZAxis, halfAxes);
let centerOffset = scratchOffset;
centerOffset.x = (minimumX + maximumX) / 2;
centerOffset.y = (minimumY + maximumY) / 2;
centerOffset.z = (minimumZ + maximumZ) / 2;
const scale = scratchScale2;
scale.x = (maximumX - minimumX) / 2;
scale.y = (maximumY - minimumY) / 2;
scale.z = (maximumZ - minimumZ) / 2;
const center = result.center;
centerOffset = Matrix3_default.multiplyByVector(halfAxes, centerOffset, centerOffset);
Cartesian3_default.add(planeOrigin, centerOffset, center);
Matrix3_default.multiplyByScale(halfAxes, scale, halfAxes);
return result;
}
var scratchRectangleCenterCartographic = new Cartographic_default();
var scratchRectangleCenter = new Cartesian3_default();
var scratchPerimeterCartographicNC = new Cartographic_default();
var scratchPerimeterCartographicNW = new Cartographic_default();
var scratchPerimeterCartographicCW = new Cartographic_default();
var scratchPerimeterCartographicSW = new Cartographic_default();
var scratchPerimeterCartographicSC = new Cartographic_default();
var scratchPerimeterCartesianNC = new Cartesian3_default();
var scratchPerimeterCartesianNW = new Cartesian3_default();
var scratchPerimeterCartesianCW = new Cartesian3_default();
var scratchPerimeterCartesianSW = new Cartesian3_default();
var scratchPerimeterCartesianSC = new Cartesian3_default();
var scratchPerimeterProjectedNC = new Cartesian2_default();
var scratchPerimeterProjectedNW = new Cartesian2_default();
var scratchPerimeterProjectedCW = new Cartesian2_default();
var scratchPerimeterProjectedSW = new Cartesian2_default();
var scratchPerimeterProjectedSC = new Cartesian2_default();
var scratchPlaneOrigin = new Cartesian3_default();
var scratchPlaneNormal = new Cartesian3_default();
var scratchPlaneXAxis = new Cartesian3_default();
var scratchHorizonCartesian = new Cartesian3_default();
var scratchHorizonProjected = new Cartesian2_default();
var scratchMaxY = new Cartesian3_default();
var scratchMinY = new Cartesian3_default();
var scratchZ = new Cartesian3_default();
var scratchPlane = new Plane_default(Cartesian3_default.UNIT_X, 0);
OrientedBoundingBox.fromRectangle = function(rectangle, minimumHeight, maximumHeight, ellipsoid, result) {
if (!defined_default(rectangle)) {
throw new DeveloperError_default("rectangle is required");
}
if (rectangle.width < 0 || rectangle.width > Math_default.TWO_PI) {
throw new DeveloperError_default("Rectangle width must be between 0 and 2*pi");
}
if (rectangle.height < 0 || rectangle.height > Math_default.PI) {
throw new DeveloperError_default("Rectangle height must be between 0 and pi");
}
if (defined_default(ellipsoid) && !Math_default.equalsEpsilon(
ellipsoid.radii.x,
ellipsoid.radii.y,
Math_default.EPSILON15
)) {
throw new DeveloperError_default(
"Ellipsoid must be an ellipsoid of revolution (radii.x == radii.y)"
);
}
minimumHeight = defaultValue_default(minimumHeight, 0);
maximumHeight = defaultValue_default(maximumHeight, 0);
ellipsoid = defaultValue_default(ellipsoid, Ellipsoid_default.WGS84);
let minX, maxX, minY, maxY, minZ, maxZ, plane;
if (rectangle.width <= Math_default.PI) {
const tangentPointCartographic = Rectangle_default.center(
rectangle,
scratchRectangleCenterCartographic
);
const tangentPoint = ellipsoid.cartographicToCartesian(
tangentPointCartographic,
scratchRectangleCenter
);
const tangentPlane = new EllipsoidTangentPlane_default(tangentPoint, ellipsoid);
plane = tangentPlane.plane;
const lonCenter = tangentPointCartographic.longitude;
const latCenter = rectangle.south < 0 && rectangle.north > 0 ? 0 : tangentPointCartographic.latitude;
const perimeterCartographicNC = Cartographic_default.fromRadians(
lonCenter,
rectangle.north,
maximumHeight,
scratchPerimeterCartographicNC
);
const perimeterCartographicNW = Cartographic_default.fromRadians(
rectangle.west,
rectangle.north,
maximumHeight,
scratchPerimeterCartographicNW
);
const perimeterCartographicCW = Cartographic_default.fromRadians(
rectangle.west,
latCenter,
maximumHeight,
scratchPerimeterCartographicCW
);
const perimeterCartographicSW = Cartographic_default.fromRadians(
rectangle.west,
rectangle.south,
maximumHeight,
scratchPerimeterCartographicSW
);
const perimeterCartographicSC = Cartographic_default.fromRadians(
lonCenter,
rectangle.south,
maximumHeight,
scratchPerimeterCartographicSC
);
const perimeterCartesianNC = ellipsoid.cartographicToCartesian(
perimeterCartographicNC,
scratchPerimeterCartesianNC
);
let perimeterCartesianNW = ellipsoid.cartographicToCartesian(
perimeterCartographicNW,
scratchPerimeterCartesianNW
);
const perimeterCartesianCW = ellipsoid.cartographicToCartesian(
perimeterCartographicCW,
scratchPerimeterCartesianCW
);
let perimeterCartesianSW = ellipsoid.cartographicToCartesian(
perimeterCartographicSW,
scratchPerimeterCartesianSW
);
const perimeterCartesianSC = ellipsoid.cartographicToCartesian(
perimeterCartographicSC,
scratchPerimeterCartesianSC
);
const perimeterProjectedNC = tangentPlane.projectPointToNearestOnPlane(
perimeterCartesianNC,
scratchPerimeterProjectedNC
);
const perimeterProjectedNW = tangentPlane.projectPointToNearestOnPlane(
perimeterCartesianNW,
scratchPerimeterProjectedNW
);
const perimeterProjectedCW = tangentPlane.projectPointToNearestOnPlane(
perimeterCartesianCW,
scratchPerimeterProjectedCW
);
const perimeterProjectedSW = tangentPlane.projectPointToNearestOnPlane(
perimeterCartesianSW,
scratchPerimeterProjectedSW
);
const perimeterProjectedSC = tangentPlane.projectPointToNearestOnPlane(
perimeterCartesianSC,
scratchPerimeterProjectedSC
);
minX = Math.min(
perimeterProjectedNW.x,
perimeterProjectedCW.x,
perimeterProjectedSW.x
);
maxX = -minX;
maxY = Math.max(perimeterProjectedNW.y, perimeterProjectedNC.y);
minY = Math.min(perimeterProjectedSW.y, perimeterProjectedSC.y);
perimeterCartographicNW.height = perimeterCartographicSW.height = minimumHeight;
perimeterCartesianNW = ellipsoid.cartographicToCartesian(
perimeterCartographicNW,
scratchPerimeterCartesianNW
);
perimeterCartesianSW = ellipsoid.cartographicToCartesian(
perimeterCartographicSW,
scratchPerimeterCartesianSW
);
minZ = Math.min(
Plane_default.getPointDistance(plane, perimeterCartesianNW),
Plane_default.getPointDistance(plane, perimeterCartesianSW)
);
maxZ = maximumHeight;
return fromPlaneExtents(
tangentPlane.origin,
tangentPlane.xAxis,
tangentPlane.yAxis,
tangentPlane.zAxis,
minX,
maxX,
minY,
maxY,
minZ,
maxZ,
result
);
}
const fullyAboveEquator = rectangle.south > 0;
const fullyBelowEquator = rectangle.north < 0;
const latitudeNearestToEquator = fullyAboveEquator ? rectangle.south : fullyBelowEquator ? rectangle.north : 0;
const centerLongitude = Rectangle_default.center(
rectangle,
scratchRectangleCenterCartographic
).longitude;
const planeOrigin = Cartesian3_default.fromRadians(
centerLongitude,
latitudeNearestToEquator,
maximumHeight,
ellipsoid,
scratchPlaneOrigin
);
planeOrigin.z = 0;
const isPole = Math.abs(planeOrigin.x) < Math_default.EPSILON10 && Math.abs(planeOrigin.y) < Math_default.EPSILON10;
const planeNormal = !isPole ? Cartesian3_default.normalize(planeOrigin, scratchPlaneNormal) : Cartesian3_default.UNIT_X;
const planeYAxis = Cartesian3_default.UNIT_Z;
const planeXAxis = Cartesian3_default.cross(
planeNormal,
planeYAxis,
scratchPlaneXAxis
);
plane = Plane_default.fromPointNormal(planeOrigin, planeNormal, scratchPlane);
const horizonCartesian = Cartesian3_default.fromRadians(
centerLongitude + Math_default.PI_OVER_TWO,
latitudeNearestToEquator,
maximumHeight,
ellipsoid,
scratchHorizonCartesian
);
maxX = Cartesian3_default.dot(
Plane_default.projectPointOntoPlane(
plane,
horizonCartesian,
scratchHorizonProjected
),
planeXAxis
);
minX = -maxX;
maxY = Cartesian3_default.fromRadians(
0,
rectangle.north,
fullyBelowEquator ? minimumHeight : maximumHeight,
ellipsoid,
scratchMaxY
).z;
minY = Cartesian3_default.fromRadians(
0,
rectangle.south,
fullyAboveEquator ? minimumHeight : maximumHeight,
ellipsoid,
scratchMinY
).z;
const farZ = Cartesian3_default.fromRadians(
rectangle.east,
latitudeNearestToEquator,
maximumHeight,
ellipsoid,
scratchZ
);
minZ = Plane_default.getPointDistance(plane, farZ);
maxZ = 0;
return fromPlaneExtents(
planeOrigin,
planeXAxis,
planeYAxis,
planeNormal,
minX,
maxX,
minY,
maxY,
minZ,
maxZ,
result
);
};
OrientedBoundingBox.fromTransformation = function(transformation, result) {
Check_default.typeOf.object("transformation", transformation);
if (!defined_default(result)) {
result = new OrientedBoundingBox();
}
result.center = Matrix4_default.getTranslation(transformation, result.center);
result.halfAxes = Matrix4_default.getMatrix3(transformation, result.halfAxes);
result.halfAxes = Matrix3_default.multiplyByScalar(
result.halfAxes,
0.5,
result.halfAxes
);
return result;
};
OrientedBoundingBox.clone = function(box, result) {
if (!defined_default(box)) {
return void 0;
}
if (!defined_default(result)) {
return new OrientedBoundingBox(box.center, box.halfAxes);
}
Cartesian3_default.clone(box.center, result.center);
Matrix3_default.clone(box.halfAxes, result.halfAxes);
return result;
};
OrientedBoundingBox.intersectPlane = function(box, plane) {
if (!defined_default(box)) {
throw new DeveloperError_default("box is required.");
}
if (!defined_default(plane)) {
throw new DeveloperError_default("plane is required.");
}
const center = box.center;
const normal2 = plane.normal;
const halfAxes = box.halfAxes;
const normalX = normal2.x, normalY = normal2.y, normalZ = normal2.z;
const radEffective = Math.abs(
normalX * halfAxes[Matrix3_default.COLUMN0ROW0] + normalY * halfAxes[Matrix3_default.COLUMN0ROW1] + normalZ * halfAxes[Matrix3_default.COLUMN0ROW2]
) + Math.abs(
normalX * halfAxes[Matrix3_default.COLUMN1ROW0] + normalY * halfAxes[Matrix3_default.COLUMN1ROW1] + normalZ * halfAxes[Matrix3_default.COLUMN1ROW2]
) + Math.abs(
normalX * halfAxes[Matrix3_default.COLUMN2ROW0] + normalY * halfAxes[Matrix3_default.COLUMN2ROW1] + normalZ * halfAxes[Matrix3_default.COLUMN2ROW2]
);
const distanceToPlane = Cartesian3_default.dot(normal2, center) + plane.distance;
if (distanceToPlane <= -radEffective) {
return Intersect_default.OUTSIDE;
} else if (distanceToPlane >= radEffective) {
return Intersect_default.INSIDE;
}
return Intersect_default.INTERSECTING;
};
var scratchCartesianU = new Cartesian3_default();
var scratchCartesianV = new Cartesian3_default();
var scratchCartesianW = new Cartesian3_default();
var scratchValidAxis2 = new Cartesian3_default();
var scratchValidAxis3 = new Cartesian3_default();
var scratchPPrime = new Cartesian3_default();
OrientedBoundingBox.distanceSquaredTo = function(box, cartesian11) {
if (!defined_default(box)) {
throw new DeveloperError_default("box is required.");
}
if (!defined_default(cartesian11)) {
throw new DeveloperError_default("cartesian is required.");
}
const offset2 = Cartesian3_default.subtract(cartesian11, box.center, scratchOffset);
const halfAxes = box.halfAxes;
let u3 = Matrix3_default.getColumn(halfAxes, 0, scratchCartesianU);
let v7 = Matrix3_default.getColumn(halfAxes, 1, scratchCartesianV);
let w = Matrix3_default.getColumn(halfAxes, 2, scratchCartesianW);
const uHalf = Cartesian3_default.magnitude(u3);
const vHalf = Cartesian3_default.magnitude(v7);
const wHalf = Cartesian3_default.magnitude(w);
let uValid = true;
let vValid = true;
let wValid = true;
if (uHalf > 0) {
Cartesian3_default.divideByScalar(u3, uHalf, u3);
} else {
uValid = false;
}
if (vHalf > 0) {
Cartesian3_default.divideByScalar(v7, vHalf, v7);
} else {
vValid = false;
}
if (wHalf > 0) {
Cartesian3_default.divideByScalar(w, wHalf, w);
} else {
wValid = false;
}
const numberOfDegenerateAxes = !uValid + !vValid + !wValid;
let validAxis1;
let validAxis2;
let validAxis3;
if (numberOfDegenerateAxes === 1) {
let degenerateAxis = u3;
validAxis1 = v7;
validAxis2 = w;
if (!vValid) {
degenerateAxis = v7;
validAxis1 = u3;
} else if (!wValid) {
degenerateAxis = w;
validAxis2 = u3;
}
validAxis3 = Cartesian3_default.cross(validAxis1, validAxis2, scratchValidAxis3);
if (degenerateAxis === u3) {
u3 = validAxis3;
} else if (degenerateAxis === v7) {
v7 = validAxis3;
} else if (degenerateAxis === w) {
w = validAxis3;
}
} else if (numberOfDegenerateAxes === 2) {
validAxis1 = u3;
if (vValid) {
validAxis1 = v7;
} else if (wValid) {
validAxis1 = w;
}
let crossVector = Cartesian3_default.UNIT_Y;
if (crossVector.equalsEpsilon(validAxis1, Math_default.EPSILON3)) {
crossVector = Cartesian3_default.UNIT_X;
}
validAxis2 = Cartesian3_default.cross(validAxis1, crossVector, scratchValidAxis2);
Cartesian3_default.normalize(validAxis2, validAxis2);
validAxis3 = Cartesian3_default.cross(validAxis1, validAxis2, scratchValidAxis3);
Cartesian3_default.normalize(validAxis3, validAxis3);
if (validAxis1 === u3) {
v7 = validAxis2;
w = validAxis3;
} else if (validAxis1 === v7) {
w = validAxis2;
u3 = validAxis3;
} else if (validAxis1 === w) {
u3 = validAxis2;
v7 = validAxis3;
}
} else if (numberOfDegenerateAxes === 3) {
u3 = Cartesian3_default.UNIT_X;
v7 = Cartesian3_default.UNIT_Y;
w = Cartesian3_default.UNIT_Z;
}
const pPrime = scratchPPrime;
pPrime.x = Cartesian3_default.dot(offset2, u3);
pPrime.y = Cartesian3_default.dot(offset2, v7);
pPrime.z = Cartesian3_default.dot(offset2, w);
let distanceSquared = 0;
let d;
if (pPrime.x < -uHalf) {
d = pPrime.x + uHalf;
distanceSquared += d * d;
} else if (pPrime.x > uHalf) {
d = pPrime.x - uHalf;
distanceSquared += d * d;
}
if (pPrime.y < -vHalf) {
d = pPrime.y + vHalf;
distanceSquared += d * d;
} else if (pPrime.y > vHalf) {
d = pPrime.y - vHalf;
distanceSquared += d * d;
}
if (pPrime.z < -wHalf) {
d = pPrime.z + wHalf;
distanceSquared += d * d;
} else if (pPrime.z > wHalf) {
d = pPrime.z - wHalf;
distanceSquared += d * d;
}
return distanceSquared;
};
var scratchCorner = new Cartesian3_default();
var scratchToCenter = new Cartesian3_default();
OrientedBoundingBox.computePlaneDistances = function(box, position, direction2, result) {
if (!defined_default(box)) {
throw new DeveloperError_default("box is required.");
}
if (!defined_default(position)) {
throw new DeveloperError_default("position is required.");
}
if (!defined_default(direction2)) {
throw new DeveloperError_default("direction is required.");
}
if (!defined_default(result)) {
result = new Interval_default();
}
let minDist = Number.POSITIVE_INFINITY;
let maxDist = Number.NEGATIVE_INFINITY;
const center = box.center;
const halfAxes = box.halfAxes;
const u3 = Matrix3_default.getColumn(halfAxes, 0, scratchCartesianU);
const v7 = Matrix3_default.getColumn(halfAxes, 1, scratchCartesianV);
const w = Matrix3_default.getColumn(halfAxes, 2, scratchCartesianW);
const corner = Cartesian3_default.add(u3, v7, scratchCorner);
Cartesian3_default.add(corner, w, corner);
Cartesian3_default.add(corner, center, corner);
const toCenter = Cartesian3_default.subtract(corner, position, scratchToCenter);
let mag = Cartesian3_default.dot(direction2, toCenter);
minDist = Math.min(mag, minDist);
maxDist = Math.max(mag, maxDist);
Cartesian3_default.add(center, u3, corner);
Cartesian3_default.add(corner, v7, corner);
Cartesian3_default.subtract(corner, w, corner);
Cartesian3_default.subtract(corner, position, toCenter);
mag = Cartesian3_default.dot(direction2, toCenter);
minDist = Math.min(mag, minDist);
maxDist = Math.max(mag, maxDist);
Cartesian3_default.add(center, u3, corner);
Cartesian3_default.subtract(corner, v7, corner);
Cartesian3_default.add(corner, w, corner);
Cartesian3_default.subtract(corner, position, toCenter);
mag = Cartesian3_default.dot(direction2, toCenter);
minDist = Math.min(mag, minDist);
maxDist = Math.max(mag, maxDist);
Cartesian3_default.add(center, u3, corner);
Cartesian3_default.subtract(corner, v7, corner);
Cartesian3_default.subtract(corner, w, corner);
Cartesian3_default.subtract(corner, position, toCenter);
mag = Cartesian3_default.dot(direction2, toCenter);
minDist = Math.min(mag, minDist);
maxDist = Math.max(mag, maxDist);
Cartesian3_default.subtract(center, u3, corner);
Cartesian3_default.add(corner, v7, corner);
Cartesian3_default.add(corner, w, corner);
Cartesian3_default.subtract(corner, position, toCenter);
mag = Cartesian3_default.dot(direction2, toCenter);
minDist = Math.min(mag, minDist);
maxDist = Math.max(mag, maxDist);
Cartesian3_default.subtract(center, u3, corner);
Cartesian3_default.add(corner, v7, corner);
Cartesian3_default.subtract(corner, w, corner);
Cartesian3_default.subtract(corner, position, toCenter);
mag = Cartesian3_default.dot(direction2, toCenter);
minDist = Math.min(mag, minDist);
maxDist = Math.max(mag, maxDist);
Cartesian3_default.subtract(center, u3, corner);
Cartesian3_default.subtract(corner, v7, corner);
Cartesian3_default.add(corner, w, corner);
Cartesian3_default.subtract(corner, position, toCenter);
mag = Cartesian3_default.dot(direction2, toCenter);
minDist = Math.min(mag, minDist);
maxDist = Math.max(mag, maxDist);
Cartesian3_default.subtract(center, u3, corner);
Cartesian3_default.subtract(corner, v7, corner);
Cartesian3_default.subtract(corner, w, corner);
Cartesian3_default.subtract(corner, position, toCenter);
mag = Cartesian3_default.dot(direction2, toCenter);
minDist = Math.min(mag, minDist);
maxDist = Math.max(mag, maxDist);
result.start = minDist;
result.stop = maxDist;
return result;
};
var scratchXAxis = new Cartesian3_default();
var scratchYAxis = new Cartesian3_default();
var scratchZAxis = new Cartesian3_default();
OrientedBoundingBox.computeCorners = function(box, result) {
Check_default.typeOf.object("box", box);
if (!defined_default(result)) {
result = [
new Cartesian3_default(),
new Cartesian3_default(),
new Cartesian3_default(),
new Cartesian3_default(),
new Cartesian3_default(),
new Cartesian3_default(),
new Cartesian3_default(),
new Cartesian3_default()
];
}
const center = box.center;
const halfAxes = box.halfAxes;
const xAxis = Matrix3_default.getColumn(halfAxes, 0, scratchXAxis);
const yAxis = Matrix3_default.getColumn(halfAxes, 1, scratchYAxis);
const zAxis = Matrix3_default.getColumn(halfAxes, 2, scratchZAxis);
Cartesian3_default.clone(center, result[0]);
Cartesian3_default.subtract(result[0], xAxis, result[0]);
Cartesian3_default.subtract(result[0], yAxis, result[0]);
Cartesian3_default.subtract(result[0], zAxis, result[0]);
Cartesian3_default.clone(center, result[1]);
Cartesian3_default.subtract(result[1], xAxis, result[1]);
Cartesian3_default.subtract(result[1], yAxis, result[1]);
Cartesian3_default.add(result[1], zAxis, result[1]);
Cartesian3_default.clone(center, result[2]);
Cartesian3_default.subtract(result[2], xAxis, result[2]);
Cartesian3_default.add(result[2], yAxis, result[2]);
Cartesian3_default.subtract(result[2], zAxis, result[2]);
Cartesian3_default.clone(center, result[3]);
Cartesian3_default.subtract(result[3], xAxis, result[3]);
Cartesian3_default.add(result[3], yAxis, result[3]);
Cartesian3_default.add(result[3], zAxis, result[3]);
Cartesian3_default.clone(center, result[4]);
Cartesian3_default.add(result[4], xAxis, result[4]);
Cartesian3_default.subtract(result[4], yAxis, result[4]);
Cartesian3_default.subtract(result[4], zAxis, result[4]);
Cartesian3_default.clone(center, result[5]);
Cartesian3_default.add(result[5], xAxis, result[5]);
Cartesian3_default.subtract(result[5], yAxis, result[5]);
Cartesian3_default.add(result[5], zAxis, result[5]);
Cartesian3_default.clone(center, result[6]);
Cartesian3_default.add(result[6], xAxis, result[6]);
Cartesian3_default.add(result[6], yAxis, result[6]);
Cartesian3_default.subtract(result[6], zAxis, result[6]);
Cartesian3_default.clone(center, result[7]);
Cartesian3_default.add(result[7], xAxis, result[7]);
Cartesian3_default.add(result[7], yAxis, result[7]);
Cartesian3_default.add(result[7], zAxis, result[7]);
return result;
};
var scratchRotationScale = new Matrix3_default();
OrientedBoundingBox.computeTransformation = function(box, result) {
Check_default.typeOf.object("box", box);
if (!defined_default(result)) {
result = new Matrix4_default();
}
const translation3 = box.center;
const rotationScale = Matrix3_default.multiplyByUniformScale(
box.halfAxes,
2,
scratchRotationScale
);
return Matrix4_default.fromRotationTranslation(rotationScale, translation3, result);
};
var scratchBoundingSphere2 = new BoundingSphere_default();
OrientedBoundingBox.isOccluded = function(box, occluder) {
if (!defined_default(box)) {
throw new DeveloperError_default("box is required.");
}
if (!defined_default(occluder)) {
throw new DeveloperError_default("occluder is required.");
}
const sphere = BoundingSphere_default.fromOrientedBoundingBox(
box,
scratchBoundingSphere2
);
return !occluder.isBoundingSphereVisible(sphere);
};
OrientedBoundingBox.prototype.intersectPlane = function(plane) {
return OrientedBoundingBox.intersectPlane(this, plane);
};
OrientedBoundingBox.prototype.distanceSquaredTo = function(cartesian11) {
return OrientedBoundingBox.distanceSquaredTo(this, cartesian11);
};
OrientedBoundingBox.prototype.computePlaneDistances = function(position, direction2, result) {
return OrientedBoundingBox.computePlaneDistances(
this,
position,
direction2,
result
);
};
OrientedBoundingBox.prototype.computeCorners = function(result) {
return OrientedBoundingBox.computeCorners(this, result);
};
OrientedBoundingBox.prototype.computeTransformation = function(result) {
return OrientedBoundingBox.computeTransformation(this, result);
};
OrientedBoundingBox.prototype.isOccluded = function(occluder) {
return OrientedBoundingBox.isOccluded(this, occluder);
};
OrientedBoundingBox.equals = function(left, right) {
return left === right || defined_default(left) && defined_default(right) && Cartesian3_default.equals(left.center, right.center) && Matrix3_default.equals(left.halfAxes, right.halfAxes);
};
OrientedBoundingBox.prototype.clone = function(result) {
return OrientedBoundingBox.clone(this, result);
};
OrientedBoundingBox.prototype.equals = function(right) {
return OrientedBoundingBox.equals(this, right);
};
var OrientedBoundingBox_default = OrientedBoundingBox;
// Source/Core/WebGLConstants.js
var WebGLConstants = {
DEPTH_BUFFER_BIT: 256,
STENCIL_BUFFER_BIT: 1024,
COLOR_BUFFER_BIT: 16384,
POINTS: 0,
LINES: 1,
LINE_LOOP: 2,
LINE_STRIP: 3,
TRIANGLES: 4,
TRIANGLE_STRIP: 5,
TRIANGLE_FAN: 6,
ZERO: 0,
ONE: 1,
SRC_COLOR: 768,
ONE_MINUS_SRC_COLOR: 769,
SRC_ALPHA: 770,
ONE_MINUS_SRC_ALPHA: 771,
DST_ALPHA: 772,
ONE_MINUS_DST_ALPHA: 773,
DST_COLOR: 774,
ONE_MINUS_DST_COLOR: 775,
SRC_ALPHA_SATURATE: 776,
FUNC_ADD: 32774,
BLEND_EQUATION: 32777,
BLEND_EQUATION_RGB: 32777,
BLEND_EQUATION_ALPHA: 34877,
FUNC_SUBTRACT: 32778,
FUNC_REVERSE_SUBTRACT: 32779,
BLEND_DST_RGB: 32968,
BLEND_SRC_RGB: 32969,
BLEND_DST_ALPHA: 32970,
BLEND_SRC_ALPHA: 32971,
CONSTANT_COLOR: 32769,
ONE_MINUS_CONSTANT_COLOR: 32770,
CONSTANT_ALPHA: 32771,
ONE_MINUS_CONSTANT_ALPHA: 32772,
BLEND_COLOR: 32773,
ARRAY_BUFFER: 34962,
ELEMENT_ARRAY_BUFFER: 34963,
ARRAY_BUFFER_BINDING: 34964,
ELEMENT_ARRAY_BUFFER_BINDING: 34965,
STREAM_DRAW: 35040,
STATIC_DRAW: 35044,
DYNAMIC_DRAW: 35048,
BUFFER_SIZE: 34660,
BUFFER_USAGE: 34661,
CURRENT_VERTEX_ATTRIB: 34342,
FRONT: 1028,
BACK: 1029,
FRONT_AND_BACK: 1032,
CULL_FACE: 2884,
BLEND: 3042,
DITHER: 3024,
STENCIL_TEST: 2960,
DEPTH_TEST: 2929,
SCISSOR_TEST: 3089,
POLYGON_OFFSET_FILL: 32823,
SAMPLE_ALPHA_TO_COVERAGE: 32926,
SAMPLE_COVERAGE: 32928,
NO_ERROR: 0,
INVALID_ENUM: 1280,
INVALID_VALUE: 1281,
INVALID_OPERATION: 1282,
OUT_OF_MEMORY: 1285,
CW: 2304,
CCW: 2305,
LINE_WIDTH: 2849,
ALIASED_POINT_SIZE_RANGE: 33901,
ALIASED_LINE_WIDTH_RANGE: 33902,
CULL_FACE_MODE: 2885,
FRONT_FACE: 2886,
DEPTH_RANGE: 2928,
DEPTH_WRITEMASK: 2930,
DEPTH_CLEAR_VALUE: 2931,
DEPTH_FUNC: 2932,
STENCIL_CLEAR_VALUE: 2961,
STENCIL_FUNC: 2962,
STENCIL_FAIL: 2964,
STENCIL_PASS_DEPTH_FAIL: 2965,
STENCIL_PASS_DEPTH_PASS: 2966,
STENCIL_REF: 2967,
STENCIL_VALUE_MASK: 2963,
STENCIL_WRITEMASK: 2968,
STENCIL_BACK_FUNC: 34816,
STENCIL_BACK_FAIL: 34817,
STENCIL_BACK_PASS_DEPTH_FAIL: 34818,
STENCIL_BACK_PASS_DEPTH_PASS: 34819,
STENCIL_BACK_REF: 36003,
STENCIL_BACK_VALUE_MASK: 36004,
STENCIL_BACK_WRITEMASK: 36005,
VIEWPORT: 2978,
SCISSOR_BOX: 3088,
COLOR_CLEAR_VALUE: 3106,
COLOR_WRITEMASK: 3107,
UNPACK_ALIGNMENT: 3317,
PACK_ALIGNMENT: 3333,
MAX_TEXTURE_SIZE: 3379,
MAX_VIEWPORT_DIMS: 3386,
SUBPIXEL_BITS: 3408,
RED_BITS: 3410,
GREEN_BITS: 3411,
BLUE_BITS: 3412,
ALPHA_BITS: 3413,
DEPTH_BITS: 3414,
STENCIL_BITS: 3415,
POLYGON_OFFSET_UNITS: 10752,
POLYGON_OFFSET_FACTOR: 32824,
TEXTURE_BINDING_2D: 32873,
SAMPLE_BUFFERS: 32936,
SAMPLES: 32937,
SAMPLE_COVERAGE_VALUE: 32938,
SAMPLE_COVERAGE_INVERT: 32939,
COMPRESSED_TEXTURE_FORMATS: 34467,
DONT_CARE: 4352,
FASTEST: 4353,
NICEST: 4354,
GENERATE_MIPMAP_HINT: 33170,
BYTE: 5120,
UNSIGNED_BYTE: 5121,
SHORT: 5122,
UNSIGNED_SHORT: 5123,
INT: 5124,
UNSIGNED_INT: 5125,
FLOAT: 5126,
DEPTH_COMPONENT: 6402,
ALPHA: 6406,
RGB: 6407,
RGBA: 6408,
LUMINANCE: 6409,
LUMINANCE_ALPHA: 6410,
UNSIGNED_SHORT_4_4_4_4: 32819,
UNSIGNED_SHORT_5_5_5_1: 32820,
UNSIGNED_SHORT_5_6_5: 33635,
FRAGMENT_SHADER: 35632,
VERTEX_SHADER: 35633,
MAX_VERTEX_ATTRIBS: 34921,
MAX_VERTEX_UNIFORM_VECTORS: 36347,
MAX_VARYING_VECTORS: 36348,
MAX_COMBINED_TEXTURE_IMAGE_UNITS: 35661,
MAX_VERTEX_TEXTURE_IMAGE_UNITS: 35660,
MAX_TEXTURE_IMAGE_UNITS: 34930,
MAX_FRAGMENT_UNIFORM_VECTORS: 36349,
SHADER_TYPE: 35663,
DELETE_STATUS: 35712,
LINK_STATUS: 35714,
VALIDATE_STATUS: 35715,
ATTACHED_SHADERS: 35717,
ACTIVE_UNIFORMS: 35718,
ACTIVE_ATTRIBUTES: 35721,
SHADING_LANGUAGE_VERSION: 35724,
CURRENT_PROGRAM: 35725,
NEVER: 512,
LESS: 513,
EQUAL: 514,
LEQUAL: 515,
GREATER: 516,
NOTEQUAL: 517,
GEQUAL: 518,
ALWAYS: 519,
KEEP: 7680,
REPLACE: 7681,
INCR: 7682,
DECR: 7683,
INVERT: 5386,
INCR_WRAP: 34055,
DECR_WRAP: 34056,
VENDOR: 7936,
RENDERER: 7937,
VERSION: 7938,
NEAREST: 9728,
LINEAR: 9729,
NEAREST_MIPMAP_NEAREST: 9984,
LINEAR_MIPMAP_NEAREST: 9985,
NEAREST_MIPMAP_LINEAR: 9986,
LINEAR_MIPMAP_LINEAR: 9987,
TEXTURE_MAG_FILTER: 10240,
TEXTURE_MIN_FILTER: 10241,
TEXTURE_WRAP_S: 10242,
TEXTURE_WRAP_T: 10243,
TEXTURE_2D: 3553,
TEXTURE: 5890,
TEXTURE_CUBE_MAP: 34067,
TEXTURE_BINDING_CUBE_MAP: 34068,
TEXTURE_CUBE_MAP_POSITIVE_X: 34069,
TEXTURE_CUBE_MAP_NEGATIVE_X: 34070,
TEXTURE_CUBE_MAP_POSITIVE_Y: 34071,
TEXTURE_CUBE_MAP_NEGATIVE_Y: 34072,
TEXTURE_CUBE_MAP_POSITIVE_Z: 34073,
TEXTURE_CUBE_MAP_NEGATIVE_Z: 34074,
MAX_CUBE_MAP_TEXTURE_SIZE: 34076,
TEXTURE0: 33984,
TEXTURE1: 33985,
TEXTURE2: 33986,
TEXTURE3: 33987,
TEXTURE4: 33988,
TEXTURE5: 33989,
TEXTURE6: 33990,
TEXTURE7: 33991,
TEXTURE8: 33992,
TEXTURE9: 33993,
TEXTURE10: 33994,
TEXTURE11: 33995,
TEXTURE12: 33996,
TEXTURE13: 33997,
TEXTURE14: 33998,
TEXTURE15: 33999,
TEXTURE16: 34e3,
TEXTURE17: 34001,
TEXTURE18: 34002,
TEXTURE19: 34003,
TEXTURE20: 34004,
TEXTURE21: 34005,
TEXTURE22: 34006,
TEXTURE23: 34007,
TEXTURE24: 34008,
TEXTURE25: 34009,
TEXTURE26: 34010,
TEXTURE27: 34011,
TEXTURE28: 34012,
TEXTURE29: 34013,
TEXTURE30: 34014,
TEXTURE31: 34015,
ACTIVE_TEXTURE: 34016,
REPEAT: 10497,
CLAMP_TO_EDGE: 33071,
MIRRORED_REPEAT: 33648,
FLOAT_VEC2: 35664,
FLOAT_VEC3: 35665,
FLOAT_VEC4: 35666,
INT_VEC2: 35667,
INT_VEC3: 35668,
INT_VEC4: 35669,
BOOL: 35670,
BOOL_VEC2: 35671,
BOOL_VEC3: 35672,
BOOL_VEC4: 35673,
FLOAT_MAT2: 35674,
FLOAT_MAT3: 35675,
FLOAT_MAT4: 35676,
SAMPLER_2D: 35678,
SAMPLER_CUBE: 35680,
VERTEX_ATTRIB_ARRAY_ENABLED: 34338,
VERTEX_ATTRIB_ARRAY_SIZE: 34339,
VERTEX_ATTRIB_ARRAY_STRIDE: 34340,
VERTEX_ATTRIB_ARRAY_TYPE: 34341,
VERTEX_ATTRIB_ARRAY_NORMALIZED: 34922,
VERTEX_ATTRIB_ARRAY_POINTER: 34373,
VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: 34975,
IMPLEMENTATION_COLOR_READ_TYPE: 35738,
IMPLEMENTATION_COLOR_READ_FORMAT: 35739,
COMPILE_STATUS: 35713,
LOW_FLOAT: 36336,
MEDIUM_FLOAT: 36337,
HIGH_FLOAT: 36338,
LOW_INT: 36339,
MEDIUM_INT: 36340,
HIGH_INT: 36341,
FRAMEBUFFER: 36160,
RENDERBUFFER: 36161,
RGBA4: 32854,
RGB5_A1: 32855,
RGB565: 36194,
DEPTH_COMPONENT16: 33189,
STENCIL_INDEX: 6401,
STENCIL_INDEX8: 36168,
DEPTH_STENCIL: 34041,
RENDERBUFFER_WIDTH: 36162,
RENDERBUFFER_HEIGHT: 36163,
RENDERBUFFER_INTERNAL_FORMAT: 36164,
RENDERBUFFER_RED_SIZE: 36176,
RENDERBUFFER_GREEN_SIZE: 36177,
RENDERBUFFER_BLUE_SIZE: 36178,
RENDERBUFFER_ALPHA_SIZE: 36179,
RENDERBUFFER_DEPTH_SIZE: 36180,
RENDERBUFFER_STENCIL_SIZE: 36181,
FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: 36048,
FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: 36049,
FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL: 36050,
FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE: 36051,
COLOR_ATTACHMENT0: 36064,
DEPTH_ATTACHMENT: 36096,
STENCIL_ATTACHMENT: 36128,
DEPTH_STENCIL_ATTACHMENT: 33306,
NONE: 0,
FRAMEBUFFER_COMPLETE: 36053,
FRAMEBUFFER_INCOMPLETE_ATTACHMENT: 36054,
FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: 36055,
FRAMEBUFFER_INCOMPLETE_DIMENSIONS: 36057,
FRAMEBUFFER_UNSUPPORTED: 36061,
FRAMEBUFFER_BINDING: 36006,
RENDERBUFFER_BINDING: 36007,
MAX_RENDERBUFFER_SIZE: 34024,
INVALID_FRAMEBUFFER_OPERATION: 1286,
UNPACK_FLIP_Y_WEBGL: 37440,
UNPACK_PREMULTIPLY_ALPHA_WEBGL: 37441,
CONTEXT_LOST_WEBGL: 37442,
UNPACK_COLORSPACE_CONVERSION_WEBGL: 37443,
BROWSER_DEFAULT_WEBGL: 37444,
COMPRESSED_RGB_S3TC_DXT1_EXT: 33776,
COMPRESSED_RGBA_S3TC_DXT1_EXT: 33777,
COMPRESSED_RGBA_S3TC_DXT3_EXT: 33778,
COMPRESSED_RGBA_S3TC_DXT5_EXT: 33779,
COMPRESSED_RGB_PVRTC_4BPPV1_IMG: 35840,
COMPRESSED_RGB_PVRTC_2BPPV1_IMG: 35841,
COMPRESSED_RGBA_PVRTC_4BPPV1_IMG: 35842,
COMPRESSED_RGBA_PVRTC_2BPPV1_IMG: 35843,
COMPRESSED_RGBA_ASTC_4x4_WEBGL: 37808,
COMPRESSED_RGB_ETC1_WEBGL: 36196,
COMPRESSED_RGBA_BPTC_UNORM: 36492,
HALF_FLOAT_OES: 36193,
DOUBLE: 5130,
READ_BUFFER: 3074,
UNPACK_ROW_LENGTH: 3314,
UNPACK_SKIP_ROWS: 3315,
UNPACK_SKIP_PIXELS: 3316,
PACK_ROW_LENGTH: 3330,
PACK_SKIP_ROWS: 3331,
PACK_SKIP_PIXELS: 3332,
COLOR: 6144,
DEPTH: 6145,
STENCIL: 6146,
RED: 6403,
RGB8: 32849,
RGBA8: 32856,
RGB10_A2: 32857,
TEXTURE_BINDING_3D: 32874,
UNPACK_SKIP_IMAGES: 32877,
UNPACK_IMAGE_HEIGHT: 32878,
TEXTURE_3D: 32879,
TEXTURE_WRAP_R: 32882,
MAX_3D_TEXTURE_SIZE: 32883,
UNSIGNED_INT_2_10_10_10_REV: 33640,
MAX_ELEMENTS_VERTICES: 33e3,
MAX_ELEMENTS_INDICES: 33001,
TEXTURE_MIN_LOD: 33082,
TEXTURE_MAX_LOD: 33083,
TEXTURE_BASE_LEVEL: 33084,
TEXTURE_MAX_LEVEL: 33085,
MIN: 32775,
MAX: 32776,
DEPTH_COMPONENT24: 33190,
MAX_TEXTURE_LOD_BIAS: 34045,
TEXTURE_COMPARE_MODE: 34892,
TEXTURE_COMPARE_FUNC: 34893,
CURRENT_QUERY: 34917,
QUERY_RESULT: 34918,
QUERY_RESULT_AVAILABLE: 34919,
STREAM_READ: 35041,
STREAM_COPY: 35042,
STATIC_READ: 35045,
STATIC_COPY: 35046,
DYNAMIC_READ: 35049,
DYNAMIC_COPY: 35050,
MAX_DRAW_BUFFERS: 34852,
DRAW_BUFFER0: 34853,
DRAW_BUFFER1: 34854,
DRAW_BUFFER2: 34855,
DRAW_BUFFER3: 34856,
DRAW_BUFFER4: 34857,
DRAW_BUFFER5: 34858,
DRAW_BUFFER6: 34859,
DRAW_BUFFER7: 34860,
DRAW_BUFFER8: 34861,
DRAW_BUFFER9: 34862,
DRAW_BUFFER10: 34863,
DRAW_BUFFER11: 34864,
DRAW_BUFFER12: 34865,
DRAW_BUFFER13: 34866,
DRAW_BUFFER14: 34867,
DRAW_BUFFER15: 34868,
MAX_FRAGMENT_UNIFORM_COMPONENTS: 35657,
MAX_VERTEX_UNIFORM_COMPONENTS: 35658,
SAMPLER_3D: 35679,
SAMPLER_2D_SHADOW: 35682,
FRAGMENT_SHADER_DERIVATIVE_HINT: 35723,
PIXEL_PACK_BUFFER: 35051,
PIXEL_UNPACK_BUFFER: 35052,
PIXEL_PACK_BUFFER_BINDING: 35053,
PIXEL_UNPACK_BUFFER_BINDING: 35055,
FLOAT_MAT2x3: 35685,
FLOAT_MAT2x4: 35686,
FLOAT_MAT3x2: 35687,
FLOAT_MAT3x4: 35688,
FLOAT_MAT4x2: 35689,
FLOAT_MAT4x3: 35690,
SRGB: 35904,
SRGB8: 35905,
SRGB8_ALPHA8: 35907,
COMPARE_REF_TO_TEXTURE: 34894,
RGBA32F: 34836,
RGB32F: 34837,
RGBA16F: 34842,
RGB16F: 34843,
VERTEX_ATTRIB_ARRAY_INTEGER: 35069,
MAX_ARRAY_TEXTURE_LAYERS: 35071,
MIN_PROGRAM_TEXEL_OFFSET: 35076,
MAX_PROGRAM_TEXEL_OFFSET: 35077,
MAX_VARYING_COMPONENTS: 35659,
TEXTURE_2D_ARRAY: 35866,
TEXTURE_BINDING_2D_ARRAY: 35869,
R11F_G11F_B10F: 35898,
UNSIGNED_INT_10F_11F_11F_REV: 35899,
RGB9_E5: 35901,
UNSIGNED_INT_5_9_9_9_REV: 35902,
TRANSFORM_FEEDBACK_BUFFER_MODE: 35967,
MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS: 35968,
TRANSFORM_FEEDBACK_VARYINGS: 35971,
TRANSFORM_FEEDBACK_BUFFER_START: 35972,
TRANSFORM_FEEDBACK_BUFFER_SIZE: 35973,
TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN: 35976,
RASTERIZER_DISCARD: 35977,
MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS: 35978,
MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS: 35979,
INTERLEAVED_ATTRIBS: 35980,
SEPARATE_ATTRIBS: 35981,
TRANSFORM_FEEDBACK_BUFFER: 35982,
TRANSFORM_FEEDBACK_BUFFER_BINDING: 35983,
RGBA32UI: 36208,
RGB32UI: 36209,
RGBA16UI: 36214,
RGB16UI: 36215,
RGBA8UI: 36220,
RGB8UI: 36221,
RGBA32I: 36226,
RGB32I: 36227,
RGBA16I: 36232,
RGB16I: 36233,
RGBA8I: 36238,
RGB8I: 36239,
RED_INTEGER: 36244,
RGB_INTEGER: 36248,
RGBA_INTEGER: 36249,
SAMPLER_2D_ARRAY: 36289,
SAMPLER_2D_ARRAY_SHADOW: 36292,
SAMPLER_CUBE_SHADOW: 36293,
UNSIGNED_INT_VEC2: 36294,
UNSIGNED_INT_VEC3: 36295,
UNSIGNED_INT_VEC4: 36296,
INT_SAMPLER_2D: 36298,
INT_SAMPLER_3D: 36299,
INT_SAMPLER_CUBE: 36300,
INT_SAMPLER_2D_ARRAY: 36303,
UNSIGNED_INT_SAMPLER_2D: 36306,
UNSIGNED_INT_SAMPLER_3D: 36307,
UNSIGNED_INT_SAMPLER_CUBE: 36308,
UNSIGNED_INT_SAMPLER_2D_ARRAY: 36311,
DEPTH_COMPONENT32F: 36012,
DEPTH32F_STENCIL8: 36013,
FLOAT_32_UNSIGNED_INT_24_8_REV: 36269,
FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING: 33296,
FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE: 33297,
FRAMEBUFFER_ATTACHMENT_RED_SIZE: 33298,
FRAMEBUFFER_ATTACHMENT_GREEN_SIZE: 33299,
FRAMEBUFFER_ATTACHMENT_BLUE_SIZE: 33300,
FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE: 33301,
FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE: 33302,
FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE: 33303,
FRAMEBUFFER_DEFAULT: 33304,
UNSIGNED_INT_24_8: 34042,
DEPTH24_STENCIL8: 35056,
UNSIGNED_NORMALIZED: 35863,
DRAW_FRAMEBUFFER_BINDING: 36006,
READ_FRAMEBUFFER: 36008,
DRAW_FRAMEBUFFER: 36009,
READ_FRAMEBUFFER_BINDING: 36010,
RENDERBUFFER_SAMPLES: 36011,
FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER: 36052,
MAX_COLOR_ATTACHMENTS: 36063,
COLOR_ATTACHMENT1: 36065,
COLOR_ATTACHMENT2: 36066,
COLOR_ATTACHMENT3: 36067,
COLOR_ATTACHMENT4: 36068,
COLOR_ATTACHMENT5: 36069,
COLOR_ATTACHMENT6: 36070,
COLOR_ATTACHMENT7: 36071,
COLOR_ATTACHMENT8: 36072,
COLOR_ATTACHMENT9: 36073,
COLOR_ATTACHMENT10: 36074,
COLOR_ATTACHMENT11: 36075,
COLOR_ATTACHMENT12: 36076,
COLOR_ATTACHMENT13: 36077,
COLOR_ATTACHMENT14: 36078,
COLOR_ATTACHMENT15: 36079,
FRAMEBUFFER_INCOMPLETE_MULTISAMPLE: 36182,
MAX_SAMPLES: 36183,
HALF_FLOAT: 5131,
RG: 33319,
RG_INTEGER: 33320,
R8: 33321,
RG8: 33323,
R16F: 33325,
R32F: 33326,
RG16F: 33327,
RG32F: 33328,
R8I: 33329,
R8UI: 33330,
R16I: 33331,
R16UI: 33332,
R32I: 33333,
R32UI: 33334,
RG8I: 33335,
RG8UI: 33336,
RG16I: 33337,
RG16UI: 33338,
RG32I: 33339,
RG32UI: 33340,
VERTEX_ARRAY_BINDING: 34229,
R8_SNORM: 36756,
RG8_SNORM: 36757,
RGB8_SNORM: 36758,
RGBA8_SNORM: 36759,
SIGNED_NORMALIZED: 36764,
COPY_READ_BUFFER: 36662,
COPY_WRITE_BUFFER: 36663,
COPY_READ_BUFFER_BINDING: 36662,
COPY_WRITE_BUFFER_BINDING: 36663,
UNIFORM_BUFFER: 35345,
UNIFORM_BUFFER_BINDING: 35368,
UNIFORM_BUFFER_START: 35369,
UNIFORM_BUFFER_SIZE: 35370,
MAX_VERTEX_UNIFORM_BLOCKS: 35371,
MAX_FRAGMENT_UNIFORM_BLOCKS: 35373,
MAX_COMBINED_UNIFORM_BLOCKS: 35374,
MAX_UNIFORM_BUFFER_BINDINGS: 35375,
MAX_UNIFORM_BLOCK_SIZE: 35376,
MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS: 35377,
MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS: 35379,
UNIFORM_BUFFER_OFFSET_ALIGNMENT: 35380,
ACTIVE_UNIFORM_BLOCKS: 35382,
UNIFORM_TYPE: 35383,
UNIFORM_SIZE: 35384,
UNIFORM_BLOCK_INDEX: 35386,
UNIFORM_OFFSET: 35387,
UNIFORM_ARRAY_STRIDE: 35388,
UNIFORM_MATRIX_STRIDE: 35389,
UNIFORM_IS_ROW_MAJOR: 35390,
UNIFORM_BLOCK_BINDING: 35391,
UNIFORM_BLOCK_DATA_SIZE: 35392,
UNIFORM_BLOCK_ACTIVE_UNIFORMS: 35394,
UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES: 35395,
UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER: 35396,
UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER: 35398,
INVALID_INDEX: 4294967295,
MAX_VERTEX_OUTPUT_COMPONENTS: 37154,
MAX_FRAGMENT_INPUT_COMPONENTS: 37157,
MAX_SERVER_WAIT_TIMEOUT: 37137,
OBJECT_TYPE: 37138,
SYNC_CONDITION: 37139,
SYNC_STATUS: 37140,
SYNC_FLAGS: 37141,
SYNC_FENCE: 37142,
SYNC_GPU_COMMANDS_COMPLETE: 37143,
UNSIGNALED: 37144,
SIGNALED: 37145,
ALREADY_SIGNALED: 37146,
TIMEOUT_EXPIRED: 37147,
CONDITION_SATISFIED: 37148,
WAIT_FAILED: 37149,
SYNC_FLUSH_COMMANDS_BIT: 1,
VERTEX_ATTRIB_ARRAY_DIVISOR: 35070,
ANY_SAMPLES_PASSED: 35887,
ANY_SAMPLES_PASSED_CONSERVATIVE: 36202,
SAMPLER_BINDING: 35097,
RGB10_A2UI: 36975,
INT_2_10_10_10_REV: 36255,
TRANSFORM_FEEDBACK: 36386,
TRANSFORM_FEEDBACK_PAUSED: 36387,
TRANSFORM_FEEDBACK_ACTIVE: 36388,
TRANSFORM_FEEDBACK_BINDING: 36389,
COMPRESSED_R11_EAC: 37488,
COMPRESSED_SIGNED_R11_EAC: 37489,
COMPRESSED_RG11_EAC: 37490,
COMPRESSED_SIGNED_RG11_EAC: 37491,
COMPRESSED_RGB8_ETC2: 37492,
COMPRESSED_SRGB8_ETC2: 37493,
COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2: 37494,
COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2: 37495,
COMPRESSED_RGBA8_ETC2_EAC: 37496,
COMPRESSED_SRGB8_ALPHA8_ETC2_EAC: 37497,
TEXTURE_IMMUTABLE_FORMAT: 37167,
MAX_ELEMENT_INDEX: 36203,
TEXTURE_IMMUTABLE_LEVELS: 33503,
MAX_TEXTURE_MAX_ANISOTROPY_EXT: 34047
};
var WebGLConstants_default = Object.freeze(WebGLConstants);
// Source/Core/ComponentDatatype.js
var ComponentDatatype = {
BYTE: WebGLConstants_default.BYTE,
UNSIGNED_BYTE: WebGLConstants_default.UNSIGNED_BYTE,
SHORT: WebGLConstants_default.SHORT,
UNSIGNED_SHORT: WebGLConstants_default.UNSIGNED_SHORT,
INT: WebGLConstants_default.INT,
UNSIGNED_INT: WebGLConstants_default.UNSIGNED_INT,
FLOAT: WebGLConstants_default.FLOAT,
DOUBLE: WebGLConstants_default.DOUBLE
};
ComponentDatatype.getSizeInBytes = function(componentDatatype) {
if (!defined_default(componentDatatype)) {
throw new DeveloperError_default("value is required.");
}
switch (componentDatatype) {
case ComponentDatatype.BYTE:
return Int8Array.BYTES_PER_ELEMENT;
case ComponentDatatype.UNSIGNED_BYTE:
return Uint8Array.BYTES_PER_ELEMENT;
case ComponentDatatype.SHORT:
return Int16Array.BYTES_PER_ELEMENT;
case ComponentDatatype.UNSIGNED_SHORT:
return Uint16Array.BYTES_PER_ELEMENT;
case ComponentDatatype.INT:
return Int32Array.BYTES_PER_ELEMENT;
case ComponentDatatype.UNSIGNED_INT:
return Uint32Array.BYTES_PER_ELEMENT;
case ComponentDatatype.FLOAT:
return Float32Array.BYTES_PER_ELEMENT;
case ComponentDatatype.DOUBLE:
return Float64Array.BYTES_PER_ELEMENT;
default:
throw new DeveloperError_default("componentDatatype is not a valid value.");
}
};
ComponentDatatype.fromTypedArray = function(array) {
if (array instanceof Int8Array) {
return ComponentDatatype.BYTE;
}
if (array instanceof Uint8Array) {
return ComponentDatatype.UNSIGNED_BYTE;
}
if (array instanceof Int16Array) {
return ComponentDatatype.SHORT;
}
if (array instanceof Uint16Array) {
return ComponentDatatype.UNSIGNED_SHORT;
}
if (array instanceof Int32Array) {
return ComponentDatatype.INT;
}
if (array instanceof Uint32Array) {
return ComponentDatatype.UNSIGNED_INT;
}
if (array instanceof Float32Array) {
return ComponentDatatype.FLOAT;
}
if (array instanceof Float64Array) {
return ComponentDatatype.DOUBLE;
}
throw new DeveloperError_default(
"array must be an Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array, or Float64Array."
);
};
ComponentDatatype.validate = function(componentDatatype) {
return defined_default(componentDatatype) && (componentDatatype === ComponentDatatype.BYTE || componentDatatype === ComponentDatatype.UNSIGNED_BYTE || componentDatatype === ComponentDatatype.SHORT || componentDatatype === ComponentDatatype.UNSIGNED_SHORT || componentDatatype === ComponentDatatype.INT || componentDatatype === ComponentDatatype.UNSIGNED_INT || componentDatatype === ComponentDatatype.FLOAT || componentDatatype === ComponentDatatype.DOUBLE);
};
ComponentDatatype.createTypedArray = function(componentDatatype, valuesOrLength) {
if (!defined_default(componentDatatype)) {
throw new DeveloperError_default("componentDatatype is required.");
}
if (!defined_default(valuesOrLength)) {
throw new DeveloperError_default("valuesOrLength is required.");
}
switch (componentDatatype) {
case ComponentDatatype.BYTE:
return new Int8Array(valuesOrLength);
case ComponentDatatype.UNSIGNED_BYTE:
return new Uint8Array(valuesOrLength);
case ComponentDatatype.SHORT:
return new Int16Array(valuesOrLength);
case ComponentDatatype.UNSIGNED_SHORT:
return new Uint16Array(valuesOrLength);
case ComponentDatatype.INT:
return new Int32Array(valuesOrLength);
case ComponentDatatype.UNSIGNED_INT:
return new Uint32Array(valuesOrLength);
case ComponentDatatype.FLOAT:
return new Float32Array(valuesOrLength);
case ComponentDatatype.DOUBLE:
return new Float64Array(valuesOrLength);
default:
throw new DeveloperError_default("componentDatatype is not a valid value.");
}
};
ComponentDatatype.createArrayBufferView = function(componentDatatype, buffer, byteOffset, length3) {
if (!defined_default(componentDatatype)) {
throw new DeveloperError_default("componentDatatype is required.");
}
if (!defined_default(buffer)) {
throw new DeveloperError_default("buffer is required.");
}
byteOffset = defaultValue_default(byteOffset, 0);
length3 = defaultValue_default(
length3,
(buffer.byteLength - byteOffset) / ComponentDatatype.getSizeInBytes(componentDatatype)
);
switch (componentDatatype) {
case ComponentDatatype.BYTE:
return new Int8Array(buffer, byteOffset, length3);
case ComponentDatatype.UNSIGNED_BYTE:
return new Uint8Array(buffer, byteOffset, length3);
case ComponentDatatype.SHORT:
return new Int16Array(buffer, byteOffset, length3);
case ComponentDatatype.UNSIGNED_SHORT:
return new Uint16Array(buffer, byteOffset, length3);
case ComponentDatatype.INT:
return new Int32Array(buffer, byteOffset, length3);
case ComponentDatatype.UNSIGNED_INT:
return new Uint32Array(buffer, byteOffset, length3);
case ComponentDatatype.FLOAT:
return new Float32Array(buffer, byteOffset, length3);
case ComponentDatatype.DOUBLE:
return new Float64Array(buffer, byteOffset, length3);
default:
throw new DeveloperError_default("componentDatatype is not a valid value.");
}
};
ComponentDatatype.fromName = function(name) {
switch (name) {
case "BYTE":
return ComponentDatatype.BYTE;
case "UNSIGNED_BYTE":
return ComponentDatatype.UNSIGNED_BYTE;
case "SHORT":
return ComponentDatatype.SHORT;
case "UNSIGNED_SHORT":
return ComponentDatatype.UNSIGNED_SHORT;
case "INT":
return ComponentDatatype.INT;
case "UNSIGNED_INT":
return ComponentDatatype.UNSIGNED_INT;
case "FLOAT":
return ComponentDatatype.FLOAT;
case "DOUBLE":
return ComponentDatatype.DOUBLE;
default:
throw new DeveloperError_default("name is not a valid value.");
}
};
var ComponentDatatype_default = Object.freeze(ComponentDatatype);
// Source/Core/Matrix2.js
function Matrix2(column0Row0, column1Row0, column0Row1, column1Row1) {
this[0] = defaultValue_default(column0Row0, 0);
this[1] = defaultValue_default(column0Row1, 0);
this[2] = defaultValue_default(column1Row0, 0);
this[3] = defaultValue_default(column1Row1, 0);
}
Matrix2.packedLength = 4;
Matrix2.pack = function(value, array, startingIndex) {
Check_default.typeOf.object("value", value);
Check_default.defined("array", array);
startingIndex = defaultValue_default(startingIndex, 0);
array[startingIndex++] = value[0];
array[startingIndex++] = value[1];
array[startingIndex++] = value[2];
array[startingIndex++] = value[3];
return array;
};
Matrix2.unpack = function(array, startingIndex, result) {
Check_default.defined("array", array);
startingIndex = defaultValue_default(startingIndex, 0);
if (!defined_default(result)) {
result = new Matrix2();
}
result[0] = array[startingIndex++];
result[1] = array[startingIndex++];
result[2] = array[startingIndex++];
result[3] = array[startingIndex++];
return result;
};
Matrix2.packArray = function(array, result) {
Check_default.defined("array", array);
const length3 = array.length;
const resultLength = length3 * 4;
if (!defined_default(result)) {
result = new Array(resultLength);
} else if (!Array.isArray(result) && result.length !== resultLength) {
throw new DeveloperError_default(
"If result is a typed array, it must have exactly array.length * 4 elements"
);
} else if (result.length !== resultLength) {
result.length = resultLength;
}
for (let i = 0; i < length3; ++i) {
Matrix2.pack(array[i], result, i * 4);
}
return result;
};
Matrix2.unpackArray = function(array, result) {
Check_default.defined("array", array);
Check_default.typeOf.number.greaterThanOrEquals("array.length", array.length, 4);
if (array.length % 4 !== 0) {
throw new DeveloperError_default("array length must be a multiple of 4.");
}
const length3 = array.length;
if (!defined_default(result)) {
result = new Array(length3 / 4);
} else {
result.length = length3 / 4;
}
for (let i = 0; i < length3; i += 4) {
const index = i / 4;
result[index] = Matrix2.unpack(array, i, result[index]);
}
return result;
};
Matrix2.clone = function(matrix, result) {
if (!defined_default(matrix)) {
return void 0;
}
if (!defined_default(result)) {
return new Matrix2(matrix[0], matrix[2], matrix[1], matrix[3]);
}
result[0] = matrix[0];
result[1] = matrix[1];
result[2] = matrix[2];
result[3] = matrix[3];
return result;
};
Matrix2.fromArray = Matrix2.unpack;
Matrix2.fromColumnMajorArray = function(values, result) {
Check_default.defined("values", values);
return Matrix2.clone(values, result);
};
Matrix2.fromRowMajorArray = function(values, result) {
Check_default.defined("values", values);
if (!defined_default(result)) {
return new Matrix2(values[0], values[1], values[2], values[3]);
}
result[0] = values[0];
result[1] = values[2];
result[2] = values[1];
result[3] = values[3];
return result;
};
Matrix2.fromScale = function(scale, result) {
Check_default.typeOf.object("scale", scale);
if (!defined_default(result)) {
return new Matrix2(scale.x, 0, 0, scale.y);
}
result[0] = scale.x;
result[1] = 0;
result[2] = 0;
result[3] = scale.y;
return result;
};
Matrix2.fromUniformScale = function(scale, result) {
Check_default.typeOf.number("scale", scale);
if (!defined_default(result)) {
return new Matrix2(scale, 0, 0, scale);
}
result[0] = scale;
result[1] = 0;
result[2] = 0;
result[3] = scale;
return result;
};
Matrix2.fromRotation = function(angle, result) {
Check_default.typeOf.number("angle", angle);
const cosAngle = Math.cos(angle);
const sinAngle = Math.sin(angle);
if (!defined_default(result)) {
return new Matrix2(cosAngle, -sinAngle, sinAngle, cosAngle);
}
result[0] = cosAngle;
result[1] = sinAngle;
result[2] = -sinAngle;
result[3] = cosAngle;
return result;
};
Matrix2.toArray = function(matrix, result) {
Check_default.typeOf.object("matrix", matrix);
if (!defined_default(result)) {
return [matrix[0], matrix[1], matrix[2], matrix[3]];
}
result[0] = matrix[0];
result[1] = matrix[1];
result[2] = matrix[2];
result[3] = matrix[3];
return result;
};
Matrix2.getElementIndex = function(column, row) {
Check_default.typeOf.number.greaterThanOrEquals("row", row, 0);
Check_default.typeOf.number.lessThanOrEquals("row", row, 1);
Check_default.typeOf.number.greaterThanOrEquals("column", column, 0);
Check_default.typeOf.number.lessThanOrEquals("column", column, 1);
return column * 2 + row;
};
Matrix2.getColumn = function(matrix, index, result) {
Check_default.typeOf.object("matrix", matrix);
Check_default.typeOf.number.greaterThanOrEquals("index", index, 0);
Check_default.typeOf.number.lessThanOrEquals("index", index, 1);
Check_default.typeOf.object("result", result);
const startIndex = index * 2;
const x = matrix[startIndex];
const y = matrix[startIndex + 1];
result.x = x;
result.y = y;
return result;
};
Matrix2.setColumn = function(matrix, index, cartesian11, result) {
Check_default.typeOf.object("matrix", matrix);
Check_default.typeOf.number.greaterThanOrEquals("index", index, 0);
Check_default.typeOf.number.lessThanOrEquals("index", index, 1);
Check_default.typeOf.object("cartesian", cartesian11);
Check_default.typeOf.object("result", result);
result = Matrix2.clone(matrix, result);
const startIndex = index * 2;
result[startIndex] = cartesian11.x;
result[startIndex + 1] = cartesian11.y;
return result;
};
Matrix2.getRow = function(matrix, index, result) {
Check_default.typeOf.object("matrix", matrix);
Check_default.typeOf.number.greaterThanOrEquals("index", index, 0);
Check_default.typeOf.number.lessThanOrEquals("index", index, 1);
Check_default.typeOf.object("result", result);
const x = matrix[index];
const y = matrix[index + 2];
result.x = x;
result.y = y;
return result;
};
Matrix2.setRow = function(matrix, index, cartesian11, result) {
Check_default.typeOf.object("matrix", matrix);
Check_default.typeOf.number.greaterThanOrEquals("index", index, 0);
Check_default.typeOf.number.lessThanOrEquals("index", index, 1);
Check_default.typeOf.object("cartesian", cartesian11);
Check_default.typeOf.object("result", result);
result = Matrix2.clone(matrix, result);
result[index] = cartesian11.x;
result[index + 2] = cartesian11.y;
return result;
};
var scaleScratch13 = new Cartesian2_default();
Matrix2.setScale = function(matrix, scale, result) {
Check_default.typeOf.object("matrix", matrix);
Check_default.typeOf.object("scale", scale);
Check_default.typeOf.object("result", result);
const existingScale = Matrix2.getScale(matrix, scaleScratch13);
const scaleRatioX = scale.x / existingScale.x;
const scaleRatioY = scale.y / existingScale.y;
result[0] = matrix[0] * scaleRatioX;
result[1] = matrix[1] * scaleRatioX;
result[2] = matrix[2] * scaleRatioY;
result[3] = matrix[3] * scaleRatioY;
return result;
};
var scaleScratch23 = new Cartesian2_default();
Matrix2.setUniformScale = function(matrix, scale, result) {
Check_default.typeOf.object("matrix", matrix);
Check_default.typeOf.number("scale", scale);
Check_default.typeOf.object("result", result);
const existingScale = Matrix2.getScale(matrix, scaleScratch23);
const scaleRatioX = scale / existingScale.x;
const scaleRatioY = scale / existingScale.y;
result[0] = matrix[0] * scaleRatioX;
result[1] = matrix[1] * scaleRatioX;
result[2] = matrix[2] * scaleRatioY;
result[3] = matrix[3] * scaleRatioY;
return result;
};
var scratchColumn3 = new Cartesian2_default();
Matrix2.getScale = function(matrix, result) {
Check_default.typeOf.object("matrix", matrix);
Check_default.typeOf.object("result", result);
result.x = Cartesian2_default.magnitude(
Cartesian2_default.fromElements(matrix[0], matrix[1], scratchColumn3)
);
result.y = Cartesian2_default.magnitude(
Cartesian2_default.fromElements(matrix[2], matrix[3], scratchColumn3)
);
return result;
};
var scaleScratch33 = new Cartesian2_default();
Matrix2.getMaximumScale = function(matrix) {
Matrix2.getScale(matrix, scaleScratch33);
return Cartesian2_default.maximumComponent(scaleScratch33);
};
var scaleScratch43 = new Cartesian2_default();
Matrix2.setRotation = function(matrix, rotation, result) {
Check_default.typeOf.object("matrix", matrix);
Check_default.typeOf.object("result", result);
const scale = Matrix2.getScale(matrix, scaleScratch43);
result[0] = rotation[0] * scale.x;
result[1] = rotation[1] * scale.x;
result[2] = rotation[2] * scale.y;
result[3] = rotation[3] * scale.y;
return result;
};
var scaleScratch53 = new Cartesian2_default();
Matrix2.getRotation = function(matrix, result) {
Check_default.typeOf.object("matrix", matrix);
Check_default.typeOf.object("result", result);
const scale = Matrix2.getScale(matrix, scaleScratch53);
result[0] = matrix[0] / scale.x;
result[1] = matrix[1] / scale.x;
result[2] = matrix[2] / scale.y;
result[3] = matrix[3] / scale.y;
return result;
};
Matrix2.multiply = function(left, right, result) {
Check_default.typeOf.object("left", left);
Check_default.typeOf.object("right", right);
Check_default.typeOf.object("result", result);
const column0Row0 = left[0] * right[0] + left[2] * right[1];
const column1Row0 = left[0] * right[2] + left[2] * right[3];
const column0Row1 = left[1] * right[0] + left[3] * right[1];
const column1Row1 = left[1] * right[2] + left[3] * right[3];
result[0] = column0Row0;
result[1] = column0Row1;
result[2] = column1Row0;
result[3] = column1Row1;
return result;
};
Matrix2.add = function(left, right, result) {
Check_default.typeOf.object("left", left);
Check_default.typeOf.object("right", right);
Check_default.typeOf.object("result", result);
result[0] = left[0] + right[0];
result[1] = left[1] + right[1];
result[2] = left[2] + right[2];
result[3] = left[3] + right[3];
return result;
};
Matrix2.subtract = function(left, right, result) {
Check_default.typeOf.object("left", left);
Check_default.typeOf.object("right", right);
Check_default.typeOf.object("result", result);
result[0] = left[0] - right[0];
result[1] = left[1] - right[1];
result[2] = left[2] - right[2];
result[3] = left[3] - right[3];
return result;
};
Matrix2.multiplyByVector = function(matrix, cartesian11, result) {
Check_default.typeOf.object("matrix", matrix);
Check_default.typeOf.object("cartesian", cartesian11);
Check_default.typeOf.object("result", result);
const x = matrix[0] * cartesian11.x + matrix[2] * cartesian11.y;
const y = matrix[1] * cartesian11.x + matrix[3] * cartesian11.y;
result.x = x;
result.y = y;
return result;
};
Matrix2.multiplyByScalar = function(matrix, scalar, result) {
Check_default.typeOf.object("matrix", matrix);
Check_default.typeOf.number("scalar", scalar);
Check_default.typeOf.object("result", result);
result[0] = matrix[0] * scalar;
result[1] = matrix[1] * scalar;
result[2] = matrix[2] * scalar;
result[3] = matrix[3] * scalar;
return result;
};
Matrix2.multiplyByScale = function(matrix, scale, result) {
Check_default.typeOf.object("matrix", matrix);
Check_default.typeOf.object("scale", scale);
Check_default.typeOf.object("result", result);
result[0] = matrix[0] * scale.x;
result[1] = matrix[1] * scale.x;
result[2] = matrix[2] * scale.y;
result[3] = matrix[3] * scale.y;
return result;
};
Matrix2.multiplyByUniformScale = function(matrix, scale, result) {
Check_default.typeOf.object("matrix", matrix);
Check_default.typeOf.number("scale", scale);
Check_default.typeOf.object("result", result);
result[0] = matrix[0] * scale;
result[1] = matrix[1] * scale;
result[2] = matrix[2] * scale;
result[3] = matrix[3] * scale;
return result;
};
Matrix2.negate = function(matrix, result) {
Check_default.typeOf.object("matrix", matrix);
Check_default.typeOf.object("result", result);
result[0] = -matrix[0];
result[1] = -matrix[1];
result[2] = -matrix[2];
result[3] = -matrix[3];
return result;
};
Matrix2.transpose = function(matrix, result) {
Check_default.typeOf.object("matrix", matrix);
Check_default.typeOf.object("result", result);
const column0Row0 = matrix[0];
const column0Row1 = matrix[2];
const column1Row0 = matrix[1];
const column1Row1 = matrix[3];
result[0] = column0Row0;
result[1] = column0Row1;
result[2] = column1Row0;
result[3] = column1Row1;
return result;
};
Matrix2.abs = function(matrix, result) {
Check_default.typeOf.object("matrix", matrix);
Check_default.typeOf.object("result", result);
result[0] = Math.abs(matrix[0]);
result[1] = Math.abs(matrix[1]);
result[2] = Math.abs(matrix[2]);
result[3] = Math.abs(matrix[3]);
return result;
};
Matrix2.equals = function(left, right) {
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];
};
Matrix2.equalsArray = function(matrix, array, offset2) {
return matrix[0] === array[offset2] && matrix[1] === array[offset2 + 1] && matrix[2] === array[offset2 + 2] && matrix[3] === array[offset2 + 3];
};
Matrix2.equalsEpsilon = function(left, right, epsilon) {
epsilon = defaultValue_default(epsilon, 0);
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;
};
Matrix2.IDENTITY = Object.freeze(new Matrix2(1, 0, 0, 1));
Matrix2.ZERO = Object.freeze(new Matrix2(0, 0, 0, 0));
Matrix2.COLUMN0ROW0 = 0;
Matrix2.COLUMN0ROW1 = 1;
Matrix2.COLUMN1ROW0 = 2;
Matrix2.COLUMN1ROW1 = 3;
Object.defineProperties(Matrix2.prototype, {
length: {
get: function() {
return Matrix2.packedLength;
}
}
});
Matrix2.prototype.clone = function(result) {
return Matrix2.clone(this, result);
};
Matrix2.prototype.equals = function(right) {
return Matrix2.equals(this, right);
};
Matrix2.prototype.equalsEpsilon = function(right, epsilon) {
return Matrix2.equalsEpsilon(this, right, epsilon);
};
Matrix2.prototype.toString = function() {
return `(${this[0]}, ${this[2]})
(${this[1]}, ${this[3]})`;
};
var Matrix2_default = Matrix2;
// Source/Scene/AttributeType.js
var AttributeType = {
SCALAR: "SCALAR",
VEC2: "VEC2",
VEC3: "VEC3",
VEC4: "VEC4",
MAT2: "MAT2",
MAT3: "MAT3",
MAT4: "MAT4"
};
AttributeType.getMathType = function(attributeType) {
switch (attributeType) {
case AttributeType.SCALAR:
return Number;
case AttributeType.VEC2:
return Cartesian2_default;
case AttributeType.VEC3:
return Cartesian3_default;
case AttributeType.VEC4:
return Cartesian4_default;
case AttributeType.MAT2:
return Matrix2_default;
case AttributeType.MAT3:
return Matrix3_default;
case AttributeType.MAT4:
return Matrix4_default;
default:
throw new DeveloperError_default("attributeType is not a valid value.");
}
};
AttributeType.getNumberOfComponents = function(attributeType) {
switch (attributeType) {
case AttributeType.SCALAR:
return 1;
case AttributeType.VEC2:
return 2;
case AttributeType.VEC3:
return 3;
case AttributeType.VEC4:
case AttributeType.MAT2:
return 4;
case AttributeType.MAT3:
return 9;
case AttributeType.MAT4:
return 16;
default:
throw new DeveloperError_default("attributeType is not a valid value.");
}
};
AttributeType.getAttributeLocationCount = function(attributeType) {
switch (attributeType) {
case AttributeType.SCALAR:
case AttributeType.VEC2:
case AttributeType.VEC3:
case AttributeType.VEC4:
return 1;
case AttributeType.MAT2:
return 2;
case AttributeType.MAT3:
return 3;
case AttributeType.MAT4:
return 4;
default:
throw new DeveloperError_default("attributeType is not a valid value.");
}
};
AttributeType.getGlslType = function(attributeType) {
Check_default.typeOf.string("attributeType", attributeType);
switch (attributeType) {
case AttributeType.SCALAR:
return "float";
case AttributeType.VEC2:
return "vec2";
case AttributeType.VEC3:
return "vec3";
case AttributeType.VEC4:
return "vec4";
case AttributeType.MAT2:
return "mat2";
case AttributeType.MAT3:
return "mat3";
case AttributeType.MAT4:
return "mat4";
default:
throw new DeveloperError_default("attributeType is not a valid value.");
}
};
var AttributeType_default = Object.freeze(AttributeType);
// Source/Core/AttributeCompression.js
var RIGHT_SHIFT = 1 / 256;
var LEFT_SHIFT = 256;
var AttributeCompression = {};
AttributeCompression.octEncodeInRange = function(vector, rangeMax, result) {
Check_default.defined("vector", vector);
Check_default.defined("result", result);
const magSquared = Cartesian3_default.magnitudeSquared(vector);
if (Math.abs(magSquared - 1) > Math_default.EPSILON6) {
throw new DeveloperError_default("vector must be normalized.");
}
result.x = vector.x / (Math.abs(vector.x) + Math.abs(vector.y) + Math.abs(vector.z));
result.y = vector.y / (Math.abs(vector.x) + Math.abs(vector.y) + Math.abs(vector.z));
if (vector.z < 0) {
const x = result.x;
const y = result.y;
result.x = (1 - Math.abs(y)) * Math_default.signNotZero(x);
result.y = (1 - Math.abs(x)) * Math_default.signNotZero(y);
}
result.x = Math_default.toSNorm(result.x, rangeMax);
result.y = Math_default.toSNorm(result.y, rangeMax);
return result;
};
AttributeCompression.octEncode = function(vector, result) {
return AttributeCompression.octEncodeInRange(vector, 255, result);
};
var octEncodeScratch = new Cartesian2_default();
var uint8ForceArray = new Uint8Array(1);
function forceUint8(value) {
uint8ForceArray[0] = value;
return uint8ForceArray[0];
}
AttributeCompression.octEncodeToCartesian4 = function(vector, result) {
AttributeCompression.octEncodeInRange(vector, 65535, octEncodeScratch);
result.x = forceUint8(octEncodeScratch.x * RIGHT_SHIFT);
result.y = forceUint8(octEncodeScratch.x);
result.z = forceUint8(octEncodeScratch.y * RIGHT_SHIFT);
result.w = forceUint8(octEncodeScratch.y);
return result;
};
AttributeCompression.octDecodeInRange = function(x, y, rangeMax, result) {
Check_default.defined("result", result);
if (x < 0 || x > rangeMax || y < 0 || y > rangeMax) {
throw new DeveloperError_default(
`x and y must be unsigned normalized integers between 0 and ${rangeMax}`
);
}
result.x = Math_default.fromSNorm(x, rangeMax);
result.y = Math_default.fromSNorm(y, rangeMax);
result.z = 1 - (Math.abs(result.x) + Math.abs(result.y));
if (result.z < 0) {
const oldVX = result.x;
result.x = (1 - Math.abs(result.y)) * Math_default.signNotZero(oldVX);
result.y = (1 - Math.abs(oldVX)) * Math_default.signNotZero(result.y);
}
return Cartesian3_default.normalize(result, result);
};
AttributeCompression.octDecode = function(x, y, result) {
return AttributeCompression.octDecodeInRange(x, y, 255, result);
};
AttributeCompression.octDecodeFromCartesian4 = function(encoded, result) {
Check_default.typeOf.object("encoded", encoded);
Check_default.typeOf.object("result", result);
const x = encoded.x;
const y = encoded.y;
const z = encoded.z;
const w = encoded.w;
if (x < 0 || x > 255 || y < 0 || y > 255 || z < 0 || z > 255 || w < 0 || w > 255) {
throw new DeveloperError_default(
"x, y, z, and w must be unsigned normalized integers between 0 and 255"
);
}
const xOct16 = x * LEFT_SHIFT + y;
const yOct16 = z * LEFT_SHIFT + w;
return AttributeCompression.octDecodeInRange(xOct16, yOct16, 65535, result);
};
AttributeCompression.octPackFloat = function(encoded) {
Check_default.defined("encoded", encoded);
return 256 * encoded.x + encoded.y;
};
var scratchEncodeCart2 = new Cartesian2_default();
AttributeCompression.octEncodeFloat = function(vector) {
AttributeCompression.octEncode(vector, scratchEncodeCart2);
return AttributeCompression.octPackFloat(scratchEncodeCart2);
};
AttributeCompression.octDecodeFloat = function(value, result) {
Check_default.defined("value", value);
const temp = value / 256;
const x = Math.floor(temp);
const y = (temp - x) * 256;
return AttributeCompression.octDecode(x, y, result);
};
AttributeCompression.octPack = function(v13, v23, v32, result) {
Check_default.defined("v1", v13);
Check_default.defined("v2", v23);
Check_default.defined("v3", v32);
Check_default.defined("result", result);
const encoded1 = AttributeCompression.octEncodeFloat(v13);
const encoded2 = AttributeCompression.octEncodeFloat(v23);
const encoded3 = AttributeCompression.octEncode(v32, scratchEncodeCart2);
result.x = 65536 * encoded3.x + encoded1;
result.y = 65536 * encoded3.y + encoded2;
return result;
};
AttributeCompression.octUnpack = function(packed, v13, v23, v32) {
Check_default.defined("packed", packed);
Check_default.defined("v1", v13);
Check_default.defined("v2", v23);
Check_default.defined("v3", v32);
let temp = packed.x / 65536;
const x = Math.floor(temp);
const encodedFloat1 = (temp - x) * 65536;
temp = packed.y / 65536;
const y = Math.floor(temp);
const encodedFloat2 = (temp - y) * 65536;
AttributeCompression.octDecodeFloat(encodedFloat1, v13);
AttributeCompression.octDecodeFloat(encodedFloat2, v23);
AttributeCompression.octDecode(x, y, v32);
};
AttributeCompression.compressTextureCoordinates = function(textureCoordinates) {
Check_default.defined("textureCoordinates", textureCoordinates);
const x = textureCoordinates.x * 4095 | 0;
const y = textureCoordinates.y * 4095 | 0;
return 4096 * x + y;
};
AttributeCompression.decompressTextureCoordinates = function(compressed, result) {
Check_default.defined("compressed", compressed);
Check_default.defined("result", result);
const temp = compressed / 4096;
const xZeroTo4095 = Math.floor(temp);
result.x = xZeroTo4095 / 4095;
result.y = (compressed - xZeroTo4095 * 4096) / 4095;
return result;
};
function zigZagDecode(value) {
return value >> 1 ^ -(value & 1);
}
AttributeCompression.zigZagDeltaDecode = function(uBuffer, vBuffer, heightBuffer) {
Check_default.defined("uBuffer", uBuffer);
Check_default.defined("vBuffer", vBuffer);
Check_default.typeOf.number.equals(
"uBuffer.length",
"vBuffer.length",
uBuffer.length,
vBuffer.length
);
if (defined_default(heightBuffer)) {
Check_default.typeOf.number.equals(
"uBuffer.length",
"heightBuffer.length",
uBuffer.length,
heightBuffer.length
);
}
const count = uBuffer.length;
let u3 = 0;
let v7 = 0;
let height = 0;
for (let i = 0; i < count; ++i) {
u3 += zigZagDecode(uBuffer[i]);
v7 += zigZagDecode(vBuffer[i]);
uBuffer[i] = u3;
vBuffer[i] = v7;
if (defined_default(heightBuffer)) {
height += zigZagDecode(heightBuffer[i]);
heightBuffer[i] = height;
}
}
};
AttributeCompression.dequantize = function(typedArray, componentDatatype, type, count) {
Check_default.defined("typedArray", typedArray);
Check_default.defined("componentDatatype", componentDatatype);
Check_default.defined("type", type);
Check_default.defined("count", count);
const componentsPerAttribute = AttributeType_default.getNumberOfComponents(type);
let divisor;
switch (componentDatatype) {
case ComponentDatatype_default.BYTE:
divisor = 127;
break;
case ComponentDatatype_default.UNSIGNED_BYTE:
divisor = 255;
break;
case ComponentDatatype_default.SHORT:
divisor = 32767;
break;
case ComponentDatatype_default.UNSIGNED_SHORT:
divisor = 65535;
break;
case ComponentDatatype_default.INT:
divisor = 2147483647;
break;
case ComponentDatatype_default.UNSIGNED_INT:
divisor = 4294967295;
break;
default:
throw new DeveloperError_default(
`Cannot dequantize component datatype: ${componentDatatype}`
);
}
const dequantizedTypedArray = new Float32Array(
count * componentsPerAttribute
);
for (let i = 0; i < count; i++) {
for (let j = 0; j < componentsPerAttribute; j++) {
const index = i * componentsPerAttribute + j;
dequantizedTypedArray[index] = Math.max(
typedArray[index] / divisor,
-1
);
}
}
return dequantizedTypedArray;
};
AttributeCompression.decodeRGB565 = function(typedArray, result) {
Check_default.defined("typedArray", typedArray);
const expectedLength = typedArray.length * 3;
if (defined_default(result)) {
Check_default.typeOf.number.equals(
"result.length",
"typedArray.length * 3",
result.length,
expectedLength
);
}
const count = typedArray.length;
if (!defined_default(result)) {
result = new Float32Array(count * 3);
}
const mask5 = (1 << 5) - 1;
const mask6 = (1 << 6) - 1;
const normalize5 = 1 / 31;
const normalize6 = 1 / 63;
for (let i = 0; i < count; i++) {
const value = typedArray[i];
const red = value >> 11;
const green = value >> 5 & mask6;
const blue = value & mask5;
const offset2 = 3 * i;
result[offset2] = red * normalize5;
result[offset2 + 1] = green * normalize6;
result[offset2 + 2] = blue * normalize5;
}
return result;
};
var AttributeCompression_default = AttributeCompression;
// Source/Core/TerrainExaggeration.js
var TerrainExaggeration = {};
TerrainExaggeration.getHeight = function(height, scale, relativeHeight) {
return (height - relativeHeight) * scale + relativeHeight;
};
var scratchCartographic2 = new Cartesian3_default();
TerrainExaggeration.getPosition = function(position, ellipsoid, terrainExaggeration, terrainExaggerationRelativeHeight, result) {
const cartographic2 = ellipsoid.cartesianToCartographic(
position,
scratchCartographic2
);
const newHeight = TerrainExaggeration.getHeight(
cartographic2.height,
terrainExaggeration,
terrainExaggerationRelativeHeight
);
return Cartesian3_default.fromRadians(
cartographic2.longitude,
cartographic2.latitude,
newHeight,
ellipsoid,
result
);
};
var TerrainExaggeration_default = TerrainExaggeration;
// Source/Core/TerrainQuantization.js
var TerrainQuantization = {
NONE: 0,
BITS12: 1
};
var TerrainQuantization_default = Object.freeze(TerrainQuantization);
// Source/Core/TerrainEncoding.js
var cartesian3Scratch = new Cartesian3_default();
var cartesian3DimScratch = new Cartesian3_default();
var cartesian2Scratch = new Cartesian2_default();
var matrix4Scratch = new Matrix4_default();
var matrix4Scratch2 = new Matrix4_default();
var SHIFT_LEFT_12 = Math.pow(2, 12);
function TerrainEncoding(center, axisAlignedBoundingBox, minimumHeight, maximumHeight, fromENU, hasVertexNormals, hasWebMercatorT, hasGeodeticSurfaceNormals, exaggeration, exaggerationRelativeHeight) {
let quantization = TerrainQuantization_default.NONE;
let toENU;
let matrix;
if (defined_default(axisAlignedBoundingBox) && defined_default(minimumHeight) && defined_default(maximumHeight) && defined_default(fromENU)) {
const minimum = axisAlignedBoundingBox.minimum;
const maximum = axisAlignedBoundingBox.maximum;
const dimensions = Cartesian3_default.subtract(
maximum,
minimum,
cartesian3DimScratch
);
const hDim = maximumHeight - minimumHeight;
const maxDim = Math.max(Cartesian3_default.maximumComponent(dimensions), hDim);
if (maxDim < SHIFT_LEFT_12 - 1) {
quantization = TerrainQuantization_default.BITS12;
} else {
quantization = TerrainQuantization_default.NONE;
}
toENU = Matrix4_default.inverseTransformation(fromENU, new Matrix4_default());
const translation3 = Cartesian3_default.negate(minimum, cartesian3Scratch);
Matrix4_default.multiply(
Matrix4_default.fromTranslation(translation3, matrix4Scratch),
toENU,
toENU
);
const scale = cartesian3Scratch;
scale.x = 1 / dimensions.x;
scale.y = 1 / dimensions.y;
scale.z = 1 / dimensions.z;
Matrix4_default.multiply(Matrix4_default.fromScale(scale, matrix4Scratch), toENU, toENU);
matrix = Matrix4_default.clone(fromENU);
Matrix4_default.setTranslation(matrix, Cartesian3_default.ZERO, matrix);
fromENU = Matrix4_default.clone(fromENU, new Matrix4_default());
const translationMatrix = Matrix4_default.fromTranslation(minimum, matrix4Scratch);
const scaleMatrix2 = Matrix4_default.fromScale(dimensions, matrix4Scratch2);
const st = Matrix4_default.multiply(translationMatrix, scaleMatrix2, matrix4Scratch);
Matrix4_default.multiply(fromENU, st, fromENU);
Matrix4_default.multiply(matrix, st, matrix);
}
this.quantization = quantization;
this.minimumHeight = minimumHeight;
this.maximumHeight = maximumHeight;
this.center = Cartesian3_default.clone(center);
this.toScaledENU = toENU;
this.fromScaledENU = fromENU;
this.matrix = matrix;
this.hasVertexNormals = hasVertexNormals;
this.hasWebMercatorT = defaultValue_default(hasWebMercatorT, false);
this.hasGeodeticSurfaceNormals = defaultValue_default(
hasGeodeticSurfaceNormals,
false
);
this.exaggeration = defaultValue_default(exaggeration, 1);
this.exaggerationRelativeHeight = defaultValue_default(
exaggerationRelativeHeight,
0
);
this.stride = 0;
this._offsetGeodeticSurfaceNormal = 0;
this._offsetVertexNormal = 0;
this._calculateStrideAndOffsets();
}
TerrainEncoding.prototype.encode = function(vertexBuffer, bufferIndex, position, uv, height, normalToPack, webMercatorT, geodeticSurfaceNormal) {
const u3 = uv.x;
const v7 = uv.y;
if (this.quantization === TerrainQuantization_default.BITS12) {
position = Matrix4_default.multiplyByPoint(
this.toScaledENU,
position,
cartesian3Scratch
);
position.x = Math_default.clamp(position.x, 0, 1);
position.y = Math_default.clamp(position.y, 0, 1);
position.z = Math_default.clamp(position.z, 0, 1);
const hDim = this.maximumHeight - this.minimumHeight;
const h = Math_default.clamp((height - this.minimumHeight) / hDim, 0, 1);
Cartesian2_default.fromElements(position.x, position.y, cartesian2Scratch);
const compressed0 = AttributeCompression_default.compressTextureCoordinates(
cartesian2Scratch
);
Cartesian2_default.fromElements(position.z, h, cartesian2Scratch);
const compressed1 = AttributeCompression_default.compressTextureCoordinates(
cartesian2Scratch
);
Cartesian2_default.fromElements(u3, v7, cartesian2Scratch);
const compressed2 = AttributeCompression_default.compressTextureCoordinates(
cartesian2Scratch
);
vertexBuffer[bufferIndex++] = compressed0;
vertexBuffer[bufferIndex++] = compressed1;
vertexBuffer[bufferIndex++] = compressed2;
if (this.hasWebMercatorT) {
Cartesian2_default.fromElements(webMercatorT, 0, cartesian2Scratch);
const compressed3 = AttributeCompression_default.compressTextureCoordinates(
cartesian2Scratch
);
vertexBuffer[bufferIndex++] = compressed3;
}
} else {
Cartesian3_default.subtract(position, this.center, cartesian3Scratch);
vertexBuffer[bufferIndex++] = cartesian3Scratch.x;
vertexBuffer[bufferIndex++] = cartesian3Scratch.y;
vertexBuffer[bufferIndex++] = cartesian3Scratch.z;
vertexBuffer[bufferIndex++] = height;
vertexBuffer[bufferIndex++] = u3;
vertexBuffer[bufferIndex++] = v7;
if (this.hasWebMercatorT) {
vertexBuffer[bufferIndex++] = webMercatorT;
}
}
if (this.hasVertexNormals) {
vertexBuffer[bufferIndex++] = AttributeCompression_default.octPackFloat(
normalToPack
);
}
if (this.hasGeodeticSurfaceNormals) {
vertexBuffer[bufferIndex++] = geodeticSurfaceNormal.x;
vertexBuffer[bufferIndex++] = geodeticSurfaceNormal.y;
vertexBuffer[bufferIndex++] = geodeticSurfaceNormal.z;
}
return bufferIndex;
};
var scratchPosition = new Cartesian3_default();
var scratchGeodeticSurfaceNormal = new Cartesian3_default();
TerrainEncoding.prototype.addGeodeticSurfaceNormals = function(oldBuffer, newBuffer, ellipsoid) {
if (this.hasGeodeticSurfaceNormals) {
return;
}
const oldStride = this.stride;
const vertexCount = oldBuffer.length / oldStride;
this.hasGeodeticSurfaceNormals = true;
this._calculateStrideAndOffsets();
const newStride = this.stride;
for (let index = 0; index < vertexCount; index++) {
for (let offset2 = 0; offset2 < oldStride; offset2++) {
const oldIndex = index * oldStride + offset2;
const newIndex = index * newStride + offset2;
newBuffer[newIndex] = oldBuffer[oldIndex];
}
const position = this.decodePosition(newBuffer, index, scratchPosition);
const geodeticSurfaceNormal = ellipsoid.geodeticSurfaceNormal(
position,
scratchGeodeticSurfaceNormal
);
const bufferIndex = index * newStride + this._offsetGeodeticSurfaceNormal;
newBuffer[bufferIndex] = geodeticSurfaceNormal.x;
newBuffer[bufferIndex + 1] = geodeticSurfaceNormal.y;
newBuffer[bufferIndex + 2] = geodeticSurfaceNormal.z;
}
};
TerrainEncoding.prototype.removeGeodeticSurfaceNormals = function(oldBuffer, newBuffer) {
if (!this.hasGeodeticSurfaceNormals) {
return;
}
const oldStride = this.stride;
const vertexCount = oldBuffer.length / oldStride;
this.hasGeodeticSurfaceNormals = false;
this._calculateStrideAndOffsets();
const newStride = this.stride;
for (let index = 0; index < vertexCount; index++) {
for (let offset2 = 0; offset2 < newStride; offset2++) {
const oldIndex = index * oldStride + offset2;
const newIndex = index * newStride + offset2;
newBuffer[newIndex] = oldBuffer[oldIndex];
}
}
};
TerrainEncoding.prototype.decodePosition = function(buffer, index, result) {
if (!defined_default(result)) {
result = new Cartesian3_default();
}
index *= this.stride;
if (this.quantization === TerrainQuantization_default.BITS12) {
const xy = AttributeCompression_default.decompressTextureCoordinates(
buffer[index],
cartesian2Scratch
);
result.x = xy.x;
result.y = xy.y;
const zh = AttributeCompression_default.decompressTextureCoordinates(
buffer[index + 1],
cartesian2Scratch
);
result.z = zh.x;
return Matrix4_default.multiplyByPoint(this.fromScaledENU, result, result);
}
result.x = buffer[index];
result.y = buffer[index + 1];
result.z = buffer[index + 2];
return Cartesian3_default.add(result, this.center, result);
};
TerrainEncoding.prototype.getExaggeratedPosition = function(buffer, index, result) {
result = this.decodePosition(buffer, index, result);
const exaggeration = this.exaggeration;
const exaggerationRelativeHeight = this.exaggerationRelativeHeight;
const hasExaggeration = exaggeration !== 1;
if (hasExaggeration && this.hasGeodeticSurfaceNormals) {
const geodeticSurfaceNormal = this.decodeGeodeticSurfaceNormal(
buffer,
index,
scratchGeodeticSurfaceNormal
);
const rawHeight = this.decodeHeight(buffer, index);
const heightDifference = TerrainExaggeration_default.getHeight(
rawHeight,
exaggeration,
exaggerationRelativeHeight
) - rawHeight;
result.x += geodeticSurfaceNormal.x * heightDifference;
result.y += geodeticSurfaceNormal.y * heightDifference;
result.z += geodeticSurfaceNormal.z * heightDifference;
}
return result;
};
TerrainEncoding.prototype.decodeTextureCoordinates = function(buffer, index, result) {
if (!defined_default(result)) {
result = new Cartesian2_default();
}
index *= this.stride;
if (this.quantization === TerrainQuantization_default.BITS12) {
return AttributeCompression_default.decompressTextureCoordinates(
buffer[index + 2],
result
);
}
return Cartesian2_default.fromElements(buffer[index + 4], buffer[index + 5], result);
};
TerrainEncoding.prototype.decodeHeight = function(buffer, index) {
index *= this.stride;
if (this.quantization === TerrainQuantization_default.BITS12) {
const zh = AttributeCompression_default.decompressTextureCoordinates(
buffer[index + 1],
cartesian2Scratch
);
return zh.y * (this.maximumHeight - this.minimumHeight) + this.minimumHeight;
}
return buffer[index + 3];
};
TerrainEncoding.prototype.decodeWebMercatorT = function(buffer, index) {
index *= this.stride;
if (this.quantization === TerrainQuantization_default.BITS12) {
return AttributeCompression_default.decompressTextureCoordinates(
buffer[index + 3],
cartesian2Scratch
).x;
}
return buffer[index + 6];
};
TerrainEncoding.prototype.getOctEncodedNormal = function(buffer, index, result) {
index = index * this.stride + this._offsetVertexNormal;
const temp = buffer[index] / 256;
const x = Math.floor(temp);
const y = (temp - x) * 256;
return Cartesian2_default.fromElements(x, y, result);
};
TerrainEncoding.prototype.decodeGeodeticSurfaceNormal = function(buffer, index, result) {
index = index * this.stride + this._offsetGeodeticSurfaceNormal;
result.x = buffer[index];
result.y = buffer[index + 1];
result.z = buffer[index + 2];
return result;
};
TerrainEncoding.prototype._calculateStrideAndOffsets = function() {
let vertexStride = 0;
switch (this.quantization) {
case TerrainQuantization_default.BITS12:
vertexStride += 3;
break;
default:
vertexStride += 6;
}
if (this.hasWebMercatorT) {
vertexStride += 1;
}
if (this.hasVertexNormals) {
this._offsetVertexNormal = vertexStride;
vertexStride += 1;
}
if (this.hasGeodeticSurfaceNormals) {
this._offsetGeodeticSurfaceNormal = vertexStride;
vertexStride += 3;
}
this.stride = vertexStride;
};
var attributesIndicesNone = {
position3DAndHeight: 0,
textureCoordAndEncodedNormals: 1,
geodeticSurfaceNormal: 2
};
var attributesIndicesBits12 = {
compressed0: 0,
compressed1: 1,
geodeticSurfaceNormal: 2
};
TerrainEncoding.prototype.getAttributes = function(buffer) {
const datatype = ComponentDatatype_default.FLOAT;
const sizeInBytes = ComponentDatatype_default.getSizeInBytes(datatype);
const strideInBytes = this.stride * sizeInBytes;
let offsetInBytes = 0;
const attributes = [];
function addAttribute2(index, componentsPerAttribute) {
attributes.push({
index,
vertexBuffer: buffer,
componentDatatype: datatype,
componentsPerAttribute,
offsetInBytes,
strideInBytes
});
offsetInBytes += componentsPerAttribute * sizeInBytes;
}
if (this.quantization === TerrainQuantization_default.NONE) {
addAttribute2(attributesIndicesNone.position3DAndHeight, 4);
let componentsTexCoordAndNormals = 2;
componentsTexCoordAndNormals += this.hasWebMercatorT ? 1 : 0;
componentsTexCoordAndNormals += this.hasVertexNormals ? 1 : 0;
addAttribute2(
attributesIndicesNone.textureCoordAndEncodedNormals,
componentsTexCoordAndNormals
);
if (this.hasGeodeticSurfaceNormals) {
addAttribute2(attributesIndicesNone.geodeticSurfaceNormal, 3);
}
} else {
const usingAttribute0Component4 = this.hasWebMercatorT || this.hasVertexNormals;
const usingAttribute1Component1 = this.hasWebMercatorT && this.hasVertexNormals;
addAttribute2(
attributesIndicesBits12.compressed0,
usingAttribute0Component4 ? 4 : 3
);
if (usingAttribute1Component1) {
addAttribute2(attributesIndicesBits12.compressed1, 1);
}
if (this.hasGeodeticSurfaceNormals) {
addAttribute2(attributesIndicesBits12.geodeticSurfaceNormal, 3);
}
}
return attributes;
};
TerrainEncoding.prototype.getAttributeLocations = function() {
if (this.quantization === TerrainQuantization_default.NONE) {
return attributesIndicesNone;
}
return attributesIndicesBits12;
};
TerrainEncoding.clone = function(encoding, result) {
if (!defined_default(encoding)) {
return void 0;
}
if (!defined_default(result)) {
result = new TerrainEncoding();
}
result.quantization = encoding.quantization;
result.minimumHeight = encoding.minimumHeight;
result.maximumHeight = encoding.maximumHeight;
result.center = Cartesian3_default.clone(encoding.center);
result.toScaledENU = Matrix4_default.clone(encoding.toScaledENU);
result.fromScaledENU = Matrix4_default.clone(encoding.fromScaledENU);
result.matrix = Matrix4_default.clone(encoding.matrix);
result.hasVertexNormals = encoding.hasVertexNormals;
result.hasWebMercatorT = encoding.hasWebMercatorT;
result.hasGeodeticSurfaceNormals = encoding.hasGeodeticSurfaceNormals;
result.exaggeration = encoding.exaggeration;
result.exaggerationRelativeHeight = encoding.exaggerationRelativeHeight;
result._calculateStrideAndOffsets();
return result;
};
var TerrainEncoding_default = TerrainEncoding;
// Source/Core/WebMercatorProjection.js
function WebMercatorProjection(ellipsoid) {
this._ellipsoid = defaultValue_default(ellipsoid, Ellipsoid_default.WGS84);
this._semimajorAxis = this._ellipsoid.maximumRadius;
this._oneOverSemimajorAxis = 1 / this._semimajorAxis;
}
Object.defineProperties(WebMercatorProjection.prototype, {
ellipsoid: {
get: function() {
return this._ellipsoid;
}
}
});
WebMercatorProjection.mercatorAngleToGeodeticLatitude = function(mercatorAngle) {
return Math_default.PI_OVER_TWO - 2 * Math.atan(Math.exp(-mercatorAngle));
};
WebMercatorProjection.geodeticLatitudeToMercatorAngle = function(latitude) {
if (latitude > WebMercatorProjection.MaximumLatitude) {
latitude = WebMercatorProjection.MaximumLatitude;
} else if (latitude < -WebMercatorProjection.MaximumLatitude) {
latitude = -WebMercatorProjection.MaximumLatitude;
}
const sinLatitude = Math.sin(latitude);
return 0.5 * Math.log((1 + sinLatitude) / (1 - sinLatitude));
};
WebMercatorProjection.MaximumLatitude = WebMercatorProjection.mercatorAngleToGeodeticLatitude(
Math.PI
);
WebMercatorProjection.prototype.project = function(cartographic2, result) {
const semimajorAxis = this._semimajorAxis;
const x = cartographic2.longitude * semimajorAxis;
const y = WebMercatorProjection.geodeticLatitudeToMercatorAngle(
cartographic2.latitude
) * semimajorAxis;
const z = cartographic2.height;
if (!defined_default(result)) {
return new Cartesian3_default(x, y, z);
}
result.x = x;
result.y = y;
result.z = z;
return result;
};
WebMercatorProjection.prototype.unproject = function(cartesian11, result) {
if (!defined_default(cartesian11)) {
throw new DeveloperError_default("cartesian is required");
}
const oneOverEarthSemimajorAxis = this._oneOverSemimajorAxis;
const longitude = cartesian11.x * oneOverEarthSemimajorAxis;
const latitude = WebMercatorProjection.mercatorAngleToGeodeticLatitude(
cartesian11.y * oneOverEarthSemimajorAxis
);
const height = cartesian11.z;
if (!defined_default(result)) {
return new Cartographic_default(longitude, latitude, height);
}
result.longitude = longitude;
result.latitude = latitude;
result.height = height;
return result;
};
var WebMercatorProjection_default = WebMercatorProjection;
// Source/Core/HeightmapTessellator.js
var HeightmapTessellator = {};
HeightmapTessellator.DEFAULT_STRUCTURE = Object.freeze({
heightScale: 1,
heightOffset: 0,
elementsPerHeight: 1,
stride: 1,
elementMultiplier: 256,
isBigEndian: false
});
var cartesian3Scratch2 = new Cartesian3_default();
var matrix4Scratch3 = new Matrix4_default();
var minimumScratch = new Cartesian3_default();
var maximumScratch = new Cartesian3_default();
HeightmapTessellator.computeVertices = function(options) {
if (!defined_default(options) || !defined_default(options.heightmap)) {
throw new DeveloperError_default("options.heightmap is required.");
}
if (!defined_default(options.width) || !defined_default(options.height)) {
throw new DeveloperError_default("options.width and options.height are required.");
}
if (!defined_default(options.nativeRectangle)) {
throw new DeveloperError_default("options.nativeRectangle is required.");
}
if (!defined_default(options.skirtHeight)) {
throw new DeveloperError_default("options.skirtHeight is required.");
}
const cos4 = Math.cos;
const sin4 = Math.sin;
const sqrt2 = Math.sqrt;
const atan = Math.atan;
const exp = Math.exp;
const piOverTwo = Math_default.PI_OVER_TWO;
const toRadians = Math_default.toRadians;
const heightmap = options.heightmap;
const width = options.width;
const height = options.height;
const skirtHeight = options.skirtHeight;
const hasSkirts = skirtHeight > 0;
const isGeographic = defaultValue_default(options.isGeographic, true);
const ellipsoid = defaultValue_default(options.ellipsoid, Ellipsoid_default.WGS84);
const oneOverGlobeSemimajorAxis = 1 / ellipsoid.maximumRadius;
const nativeRectangle = Rectangle_default.clone(options.nativeRectangle);
const rectangle = Rectangle_default.clone(options.rectangle);
let geographicWest;
let geographicSouth;
let geographicEast;
let geographicNorth;
if (!defined_default(rectangle)) {
if (isGeographic) {
geographicWest = toRadians(nativeRectangle.west);
geographicSouth = toRadians(nativeRectangle.south);
geographicEast = toRadians(nativeRectangle.east);
geographicNorth = toRadians(nativeRectangle.north);
} else {
geographicWest = nativeRectangle.west * oneOverGlobeSemimajorAxis;
geographicSouth = piOverTwo - 2 * atan(exp(-nativeRectangle.south * oneOverGlobeSemimajorAxis));
geographicEast = nativeRectangle.east * oneOverGlobeSemimajorAxis;
geographicNorth = piOverTwo - 2 * atan(exp(-nativeRectangle.north * oneOverGlobeSemimajorAxis));
}
} else {
geographicWest = rectangle.west;
geographicSouth = rectangle.south;
geographicEast = rectangle.east;
geographicNorth = rectangle.north;
}
let relativeToCenter = options.relativeToCenter;
const hasRelativeToCenter = defined_default(relativeToCenter);
relativeToCenter = hasRelativeToCenter ? relativeToCenter : Cartesian3_default.ZERO;
const includeWebMercatorT = defaultValue_default(options.includeWebMercatorT, false);
const exaggeration = defaultValue_default(options.exaggeration, 1);
const exaggerationRelativeHeight = defaultValue_default(
options.exaggerationRelativeHeight,
0
);
const hasExaggeration = exaggeration !== 1;
const includeGeodeticSurfaceNormals = hasExaggeration;
const structure = defaultValue_default(
options.structure,
HeightmapTessellator.DEFAULT_STRUCTURE
);
const heightScale = defaultValue_default(
structure.heightScale,
HeightmapTessellator.DEFAULT_STRUCTURE.heightScale
);
const heightOffset = defaultValue_default(
structure.heightOffset,
HeightmapTessellator.DEFAULT_STRUCTURE.heightOffset
);
const elementsPerHeight = defaultValue_default(
structure.elementsPerHeight,
HeightmapTessellator.DEFAULT_STRUCTURE.elementsPerHeight
);
const stride = defaultValue_default(
structure.stride,
HeightmapTessellator.DEFAULT_STRUCTURE.stride
);
const elementMultiplier = defaultValue_default(
structure.elementMultiplier,
HeightmapTessellator.DEFAULT_STRUCTURE.elementMultiplier
);
const isBigEndian = defaultValue_default(
structure.isBigEndian,
HeightmapTessellator.DEFAULT_STRUCTURE.isBigEndian
);
let rectangleWidth = Rectangle_default.computeWidth(nativeRectangle);
let rectangleHeight = Rectangle_default.computeHeight(nativeRectangle);
const granularityX = rectangleWidth / (width - 1);
const granularityY = rectangleHeight / (height - 1);
if (!isGeographic) {
rectangleWidth *= oneOverGlobeSemimajorAxis;
rectangleHeight *= oneOverGlobeSemimajorAxis;
}
const radiiSquared = ellipsoid.radiiSquared;
const radiiSquaredX = radiiSquared.x;
const radiiSquaredY = radiiSquared.y;
const radiiSquaredZ = radiiSquared.z;
let minimumHeight = 65536;
let maximumHeight = -65536;
const fromENU = Transforms_default.eastNorthUpToFixedFrame(
relativeToCenter,
ellipsoid
);
const toENU = Matrix4_default.inverseTransformation(fromENU, matrix4Scratch3);
let southMercatorY;
let oneOverMercatorHeight;
if (includeWebMercatorT) {
southMercatorY = WebMercatorProjection_default.geodeticLatitudeToMercatorAngle(
geographicSouth
);
oneOverMercatorHeight = 1 / (WebMercatorProjection_default.geodeticLatitudeToMercatorAngle(geographicNorth) - southMercatorY);
}
const minimum = minimumScratch;
minimum.x = Number.POSITIVE_INFINITY;
minimum.y = Number.POSITIVE_INFINITY;
minimum.z = Number.POSITIVE_INFINITY;
const maximum = maximumScratch;
maximum.x = Number.NEGATIVE_INFINITY;
maximum.y = Number.NEGATIVE_INFINITY;
maximum.z = Number.NEGATIVE_INFINITY;
let hMin = Number.POSITIVE_INFINITY;
const gridVertexCount = width * height;
const edgeVertexCount = skirtHeight > 0 ? width * 2 + height * 2 : 0;
const vertexCount = gridVertexCount + edgeVertexCount;
const positions = new Array(vertexCount);
const heights = new Array(vertexCount);
const uvs = new Array(vertexCount);
const webMercatorTs = includeWebMercatorT ? new Array(vertexCount) : [];
const geodeticSurfaceNormals = includeGeodeticSurfaceNormals ? new Array(vertexCount) : [];
let startRow = 0;
let endRow = height;
let startCol = 0;
let endCol = width;
if (hasSkirts) {
--startRow;
++endRow;
--startCol;
++endCol;
}
const skirtOffsetPercentage = 1e-5;
for (let rowIndex = startRow; rowIndex < endRow; ++rowIndex) {
let row = rowIndex;
if (row < 0) {
row = 0;
}
if (row >= height) {
row = height - 1;
}
let latitude = nativeRectangle.north - granularityY * row;
if (!isGeographic) {
latitude = piOverTwo - 2 * atan(exp(-latitude * oneOverGlobeSemimajorAxis));
} else {
latitude = toRadians(latitude);
}
let v7 = (latitude - geographicSouth) / (geographicNorth - geographicSouth);
v7 = Math_default.clamp(v7, 0, 1);
const isNorthEdge = rowIndex === startRow;
const isSouthEdge = rowIndex === endRow - 1;
if (skirtHeight > 0) {
if (isNorthEdge) {
latitude += skirtOffsetPercentage * rectangleHeight;
} else if (isSouthEdge) {
latitude -= skirtOffsetPercentage * rectangleHeight;
}
}
const cosLatitude = cos4(latitude);
const nZ = sin4(latitude);
const kZ = radiiSquaredZ * nZ;
let webMercatorT;
if (includeWebMercatorT) {
webMercatorT = (WebMercatorProjection_default.geodeticLatitudeToMercatorAngle(latitude) - southMercatorY) * oneOverMercatorHeight;
}
for (let colIndex = startCol; colIndex < endCol; ++colIndex) {
let col = colIndex;
if (col < 0) {
col = 0;
}
if (col >= width) {
col = width - 1;
}
const terrainOffset = row * (width * stride) + col * stride;
let heightSample;
if (elementsPerHeight === 1) {
heightSample = heightmap[terrainOffset];
} else {
heightSample = 0;
let elementOffset;
if (isBigEndian) {
for (elementOffset = 0; elementOffset < elementsPerHeight; ++elementOffset) {
heightSample = heightSample * elementMultiplier + heightmap[terrainOffset + elementOffset];
}
} else {
for (elementOffset = elementsPerHeight - 1; elementOffset >= 0; --elementOffset) {
heightSample = heightSample * elementMultiplier + heightmap[terrainOffset + elementOffset];
}
}
}
heightSample = heightSample * heightScale + heightOffset;
maximumHeight = Math.max(maximumHeight, heightSample);
minimumHeight = Math.min(minimumHeight, heightSample);
let longitude = nativeRectangle.west + granularityX * col;
if (!isGeographic) {
longitude = longitude * oneOverGlobeSemimajorAxis;
} else {
longitude = toRadians(longitude);
}
let u3 = (longitude - geographicWest) / (geographicEast - geographicWest);
u3 = Math_default.clamp(u3, 0, 1);
let index = row * width + col;
if (skirtHeight > 0) {
const isWestEdge = colIndex === startCol;
const isEastEdge = colIndex === endCol - 1;
const isEdge2 = isNorthEdge || isSouthEdge || isWestEdge || isEastEdge;
const isCorner = (isNorthEdge || isSouthEdge) && (isWestEdge || isEastEdge);
if (isCorner) {
continue;
} else if (isEdge2) {
heightSample -= skirtHeight;
if (isWestEdge) {
index = gridVertexCount + (height - row - 1);
longitude -= skirtOffsetPercentage * rectangleWidth;
} else if (isSouthEdge) {
index = gridVertexCount + height + (width - col - 1);
} else if (isEastEdge) {
index = gridVertexCount + height + width + row;
longitude += skirtOffsetPercentage * rectangleWidth;
} else if (isNorthEdge) {
index = gridVertexCount + height + width + height + col;
}
}
}
const nX = cosLatitude * cos4(longitude);
const nY = cosLatitude * sin4(longitude);
const kX = radiiSquaredX * nX;
const kY = radiiSquaredY * nY;
const gamma = sqrt2(kX * nX + kY * nY + kZ * nZ);
const oneOverGamma = 1 / gamma;
const rSurfaceX = kX * oneOverGamma;
const rSurfaceY = kY * oneOverGamma;
const rSurfaceZ = kZ * oneOverGamma;
const position = new Cartesian3_default();
position.x = rSurfaceX + nX * heightSample;
position.y = rSurfaceY + nY * heightSample;
position.z = rSurfaceZ + nZ * heightSample;
Matrix4_default.multiplyByPoint(toENU, position, cartesian3Scratch2);
Cartesian3_default.minimumByComponent(cartesian3Scratch2, minimum, minimum);
Cartesian3_default.maximumByComponent(cartesian3Scratch2, maximum, maximum);
hMin = Math.min(hMin, heightSample);
positions[index] = position;
uvs[index] = new Cartesian2_default(u3, v7);
heights[index] = heightSample;
if (includeWebMercatorT) {
webMercatorTs[index] = webMercatorT;
}
if (includeGeodeticSurfaceNormals) {
geodeticSurfaceNormals[index] = ellipsoid.geodeticSurfaceNormal(
position
);
}
}
}
const boundingSphere3D = BoundingSphere_default.fromPoints(positions);
let orientedBoundingBox;
if (defined_default(rectangle)) {
orientedBoundingBox = OrientedBoundingBox_default.fromRectangle(
rectangle,
minimumHeight,
maximumHeight,
ellipsoid
);
}
let occludeePointInScaledSpace;
if (hasRelativeToCenter) {
const occluder = new EllipsoidalOccluder_default(ellipsoid);
occludeePointInScaledSpace = occluder.computeHorizonCullingPointPossiblyUnderEllipsoid(
relativeToCenter,
positions,
minimumHeight
);
}
const aaBox = new AxisAlignedBoundingBox_default(minimum, maximum, relativeToCenter);
const encoding = new TerrainEncoding_default(
relativeToCenter,
aaBox,
hMin,
maximumHeight,
fromENU,
false,
includeWebMercatorT,
includeGeodeticSurfaceNormals,
exaggeration,
exaggerationRelativeHeight
);
const vertices = new Float32Array(vertexCount * encoding.stride);
let bufferIndex = 0;
for (let j = 0; j < vertexCount; ++j) {
bufferIndex = encoding.encode(
vertices,
bufferIndex,
positions[j],
uvs[j],
heights[j],
void 0,
webMercatorTs[j],
geodeticSurfaceNormals[j]
);
}
return {
vertices,
maximumHeight,
minimumHeight,
encoding,
boundingSphere3D,
orientedBoundingBox,
occludeePointInScaledSpace
};
};
var HeightmapTessellator_default = HeightmapTessellator;
// Source/Core/destroyObject.js
function returnTrue() {
return true;
}
function destroyObject(object, message) {
message = defaultValue_default(
message,
"This object was destroyed, i.e., destroy() was called."
);
function throwOnDestroyed() {
throw new DeveloperError_default(message);
}
for (const key in object) {
if (typeof object[key] === "function") {
object[key] = throwOnDestroyed;
}
}
object.isDestroyed = returnTrue;
return void 0;
}
var destroyObject_default = destroyObject;
// Source/Core/TaskProcessor.js
function canTransferArrayBuffer() {
if (!defined_default(TaskProcessor._canTransferArrayBuffer)) {
const worker = new Worker(
getWorkerUrl("Workers/transferTypedArrayTest.js")
);
worker.postMessage = defaultValue_default(
worker.webkitPostMessage,
worker.postMessage
);
const value = 99;
const array = new Int8Array([value]);
try {
worker.postMessage(
{
array
},
[array.buffer]
);
} catch (e) {
TaskProcessor._canTransferArrayBuffer = false;
return TaskProcessor._canTransferArrayBuffer;
}
const deferred = defer_default();
worker.onmessage = function(event) {
const array2 = event.data.array;
const result = defined_default(array2) && array2[0] === value;
deferred.resolve(result);
worker.terminate();
TaskProcessor._canTransferArrayBuffer = result;
};
TaskProcessor._canTransferArrayBuffer = deferred.promise;
}
return TaskProcessor._canTransferArrayBuffer;
}
var taskCompletedEvent = new Event_default();
function completeTask(processor, data) {
--processor._activeTasks;
const id = data.id;
if (!defined_default(id)) {
return;
}
const deferreds = processor._deferreds;
const deferred = deferreds[id];
if (defined_default(data.error)) {
let error = data.error;
if (error.name === "RuntimeError") {
error = new RuntimeError_default(data.error.message);
error.stack = data.error.stack;
} else if (error.name === "DeveloperError") {
error = new DeveloperError_default(data.error.message);
error.stack = data.error.stack;
}
taskCompletedEvent.raiseEvent(error);
deferred.reject(error);
} else {
taskCompletedEvent.raiseEvent();
deferred.resolve(data.result);
}
delete deferreds[id];
}
function getWorkerUrl(moduleID) {
let url2 = buildModuleUrl_default(moduleID);
if (isCrossOriginUrl_default(url2)) {
const script = `importScripts("${url2}");`;
let blob;
try {
blob = new Blob([script], {
type: "application/javascript"
});
} catch (e) {
const BlobBuilder = window.BlobBuilder || window.WebKitBlobBuilder || window.MozBlobBuilder || window.MSBlobBuilder;
const blobBuilder = new BlobBuilder();
blobBuilder.append(script);
blob = blobBuilder.getBlob("application/javascript");
}
const URL2 = window.URL || window.webkitURL;
url2 = URL2.createObjectURL(blob);
}
return url2;
}
var bootstrapperUrlResult;
function getBootstrapperUrl() {
if (!defined_default(bootstrapperUrlResult)) {
bootstrapperUrlResult = getWorkerUrl("Workers/cesiumWorkerBootstrapper.js");
}
return bootstrapperUrlResult;
}
function createWorker(processor) {
const worker = new Worker(getBootstrapperUrl());
worker.postMessage = defaultValue_default(
worker.webkitPostMessage,
worker.postMessage
);
const bootstrapMessage = {
loaderConfig: {
paths: {
Workers: buildModuleUrl_default("Workers")
},
baseUrl: buildModuleUrl_default.getCesiumBaseUrl().url
},
workerModule: processor._workerPath
};
worker.postMessage(bootstrapMessage);
worker.onmessage = function(event) {
completeTask(processor, event.data);
};
return worker;
}
function getWebAssemblyLoaderConfig(processor, wasmOptions) {
const config2 = {
modulePath: void 0,
wasmBinaryFile: void 0,
wasmBinary: void 0
};
if (!FeatureDetection_default.supportsWebAssembly()) {
if (!defined_default(wasmOptions.fallbackModulePath)) {
throw new RuntimeError_default(
`This browser does not support Web Assembly, and no backup module was provided for ${processor._workerPath}`
);
}
config2.modulePath = buildModuleUrl_default(wasmOptions.fallbackModulePath);
return Promise.resolve(config2);
}
config2.modulePath = buildModuleUrl_default(wasmOptions.modulePath);
config2.wasmBinaryFile = buildModuleUrl_default(wasmOptions.wasmBinaryFile);
return Resource_default.fetchArrayBuffer({
url: config2.wasmBinaryFile
}).then(function(arrayBuffer) {
config2.wasmBinary = arrayBuffer;
return config2;
});
}
function TaskProcessor(workerPath, maximumActiveTasks) {
const uri = new import_urijs.default(workerPath);
this._workerPath = uri.scheme().length !== 0 && uri.fragment().length === 0 ? workerPath : TaskProcessor._workerModulePrefix + workerPath;
this._maximumActiveTasks = defaultValue_default(
maximumActiveTasks,
Number.POSITIVE_INFINITY
);
this._activeTasks = 0;
this._deferreds = {};
this._nextID = 0;
}
var emptyTransferableObjectArray = [];
TaskProcessor.prototype.scheduleTask = function(parameters, transferableObjects) {
if (!defined_default(this._worker)) {
this._worker = createWorker(this);
}
if (this._activeTasks >= this._maximumActiveTasks) {
return void 0;
}
++this._activeTasks;
const processor = this;
return Promise.resolve(canTransferArrayBuffer()).then(function(canTransferArrayBuffer2) {
if (!defined_default(transferableObjects)) {
transferableObjects = emptyTransferableObjectArray;
} else if (!canTransferArrayBuffer2) {
transferableObjects.length = 0;
}
const id = processor._nextID++;
const deferred = defer_default();
processor._deferreds[id] = deferred;
processor._worker.postMessage(
{
id,
parameters,
canTransferArrayBuffer: canTransferArrayBuffer2
},
transferableObjects
);
return deferred.promise;
});
};
TaskProcessor.prototype.initWebAssemblyModule = function(webAssemblyOptions) {
if (!defined_default(this._worker)) {
this._worker = createWorker(this);
}
const deferred = defer_default();
const processor = this;
const worker = this._worker;
getWebAssemblyLoaderConfig(this, webAssemblyOptions).then(function(wasmConfig) {
return Promise.resolve(canTransferArrayBuffer()).then(function(canTransferArrayBuffer2) {
let transferableObjects;
const binary = wasmConfig.wasmBinary;
if (defined_default(binary) && canTransferArrayBuffer2) {
transferableObjects = [binary];
}
worker.onmessage = function(event) {
worker.onmessage = function(event2) {
completeTask(processor, event2.data);
};
deferred.resolve(event.data);
};
worker.postMessage(
{ webAssemblyConfig: wasmConfig },
transferableObjects
);
});
});
return deferred.promise;
};
TaskProcessor.prototype.isDestroyed = function() {
return false;
};
TaskProcessor.prototype.destroy = function() {
if (defined_default(this._worker)) {
this._worker.terminate();
}
return destroyObject_default(this);
};
TaskProcessor.taskCompletedEvent = taskCompletedEvent;
TaskProcessor._defaultWorkerModulePrefix = "Workers/";
TaskProcessor._workerModulePrefix = TaskProcessor._defaultWorkerModulePrefix;
TaskProcessor._canTransferArrayBuffer = void 0;
var TaskProcessor_default = TaskProcessor;
// Source/Core/TerrainData.js
function TerrainData() {
DeveloperError_default.throwInstantiationError();
}
Object.defineProperties(TerrainData.prototype, {
credits: {
get: DeveloperError_default.throwInstantiationError
},
waterMask: {
get: DeveloperError_default.throwInstantiationError
}
});
TerrainData.prototype.interpolateHeight = DeveloperError_default.throwInstantiationError;
TerrainData.prototype.isChildAvailable = DeveloperError_default.throwInstantiationError;
TerrainData.prototype.createMesh = DeveloperError_default.throwInstantiationError;
TerrainData.prototype.upsample = DeveloperError_default.throwInstantiationError;
TerrainData.prototype.wasCreatedByUpsampling = DeveloperError_default.throwInstantiationError;
TerrainData.maximumAsynchronousTasks = 5;
var TerrainData_default = TerrainData;
// Source/Core/TerrainMesh.js
function TerrainMesh(center, vertices, indices2, indexCountWithoutSkirts, vertexCountWithoutSkirts, minimumHeight, maximumHeight, boundingSphere3D, occludeePointInScaledSpace, vertexStride, orientedBoundingBox, encoding, westIndicesSouthToNorth, southIndicesEastToWest, eastIndicesNorthToSouth, northIndicesWestToEast) {
this.center = center;
this.vertices = vertices;
this.stride = defaultValue_default(vertexStride, 6);
this.indices = indices2;
this.indexCountWithoutSkirts = indexCountWithoutSkirts;
this.vertexCountWithoutSkirts = vertexCountWithoutSkirts;
this.minimumHeight = minimumHeight;
this.maximumHeight = maximumHeight;
this.boundingSphere3D = boundingSphere3D;
this.occludeePointInScaledSpace = occludeePointInScaledSpace;
this.orientedBoundingBox = orientedBoundingBox;
this.encoding = encoding;
this.westIndicesSouthToNorth = westIndicesSouthToNorth;
this.southIndicesEastToWest = southIndicesEastToWest;
this.eastIndicesNorthToSouth = eastIndicesNorthToSouth;
this.northIndicesWestToEast = northIndicesWestToEast;
}
var TerrainMesh_default = TerrainMesh;
// Source/Core/IndexDatatype.js
var IndexDatatype = {
UNSIGNED_BYTE: WebGLConstants_default.UNSIGNED_BYTE,
UNSIGNED_SHORT: WebGLConstants_default.UNSIGNED_SHORT,
UNSIGNED_INT: WebGLConstants_default.UNSIGNED_INT
};
IndexDatatype.getSizeInBytes = function(indexDatatype) {
switch (indexDatatype) {
case IndexDatatype.UNSIGNED_BYTE:
return Uint8Array.BYTES_PER_ELEMENT;
case IndexDatatype.UNSIGNED_SHORT:
return Uint16Array.BYTES_PER_ELEMENT;
case IndexDatatype.UNSIGNED_INT:
return Uint32Array.BYTES_PER_ELEMENT;
}
throw new DeveloperError_default(
"indexDatatype is required and must be a valid IndexDatatype constant."
);
};
IndexDatatype.fromSizeInBytes = function(sizeInBytes) {
switch (sizeInBytes) {
case 2:
return IndexDatatype.UNSIGNED_SHORT;
case 4:
return IndexDatatype.UNSIGNED_INT;
case 1:
return IndexDatatype.UNSIGNED_BYTE;
default:
throw new DeveloperError_default(
"Size in bytes cannot be mapped to an IndexDatatype"
);
}
};
IndexDatatype.validate = function(indexDatatype) {
return defined_default(indexDatatype) && (indexDatatype === IndexDatatype.UNSIGNED_BYTE || indexDatatype === IndexDatatype.UNSIGNED_SHORT || indexDatatype === IndexDatatype.UNSIGNED_INT);
};
IndexDatatype.createTypedArray = function(numberOfVertices, indicesLengthOrArray) {
if (!defined_default(numberOfVertices)) {
throw new DeveloperError_default("numberOfVertices is required.");
}
if (numberOfVertices >= Math_default.SIXTY_FOUR_KILOBYTES) {
return new Uint32Array(indicesLengthOrArray);
}
return new Uint16Array(indicesLengthOrArray);
};
IndexDatatype.createTypedArrayFromArrayBuffer = function(numberOfVertices, sourceArray, byteOffset, length3) {
if (!defined_default(numberOfVertices)) {
throw new DeveloperError_default("numberOfVertices is required.");
}
if (!defined_default(sourceArray)) {
throw new DeveloperError_default("sourceArray is required.");
}
if (!defined_default(byteOffset)) {
throw new DeveloperError_default("byteOffset is required.");
}
if (numberOfVertices >= Math_default.SIXTY_FOUR_KILOBYTES) {
return new Uint32Array(sourceArray, byteOffset, length3);
}
return new Uint16Array(sourceArray, byteOffset, length3);
};
IndexDatatype.fromTypedArray = function(array) {
if (array instanceof Uint8Array) {
return IndexDatatype.UNSIGNED_BYTE;
}
if (array instanceof Uint16Array) {
return IndexDatatype.UNSIGNED_SHORT;
}
if (array instanceof Uint32Array) {
return IndexDatatype.UNSIGNED_INT;
}
throw new DeveloperError_default(
"array must be a Uint8Array, Uint16Array, or Uint32Array."
);
};
var IndexDatatype_default = Object.freeze(IndexDatatype);
// Source/Core/TerrainProvider.js
function TerrainProvider() {
DeveloperError_default.throwInstantiationError();
}
Object.defineProperties(TerrainProvider.prototype, {
errorEvent: {
get: DeveloperError_default.throwInstantiationError
},
credit: {
get: DeveloperError_default.throwInstantiationError
},
tilingScheme: {
get: DeveloperError_default.throwInstantiationError
},
ready: {
get: DeveloperError_default.throwInstantiationError
},
readyPromise: {
get: DeveloperError_default.throwInstantiationError
},
hasWaterMask: {
get: DeveloperError_default.throwInstantiationError
},
hasVertexNormals: {
get: DeveloperError_default.throwInstantiationError
},
availability: {
get: DeveloperError_default.throwInstantiationError
}
});
var regularGridIndicesCache = [];
TerrainProvider.getRegularGridIndices = function(width, height) {
if (width * height >= Math_default.FOUR_GIGABYTES) {
throw new DeveloperError_default(
"The total number of vertices (width * height) must be less than 4,294,967,296."
);
}
let byWidth = regularGridIndicesCache[width];
if (!defined_default(byWidth)) {
regularGridIndicesCache[width] = byWidth = [];
}
let indices2 = byWidth[height];
if (!defined_default(indices2)) {
if (width * height < Math_default.SIXTY_FOUR_KILOBYTES) {
indices2 = byWidth[height] = new Uint16Array(
(width - 1) * (height - 1) * 6
);
} else {
indices2 = byWidth[height] = new Uint32Array(
(width - 1) * (height - 1) * 6
);
}
addRegularGridIndices(width, height, indices2, 0);
}
return indices2;
};
var regularGridAndEdgeIndicesCache = [];
TerrainProvider.getRegularGridIndicesAndEdgeIndices = function(width, height) {
if (width * height >= Math_default.FOUR_GIGABYTES) {
throw new DeveloperError_default(
"The total number of vertices (width * height) must be less than 4,294,967,296."
);
}
let byWidth = regularGridAndEdgeIndicesCache[width];
if (!defined_default(byWidth)) {
regularGridAndEdgeIndicesCache[width] = byWidth = [];
}
let indicesAndEdges = byWidth[height];
if (!defined_default(indicesAndEdges)) {
const indices2 = TerrainProvider.getRegularGridIndices(width, height);
const edgeIndices = getEdgeIndices(width, height);
const westIndicesSouthToNorth = edgeIndices.westIndicesSouthToNorth;
const southIndicesEastToWest = edgeIndices.southIndicesEastToWest;
const eastIndicesNorthToSouth = edgeIndices.eastIndicesNorthToSouth;
const northIndicesWestToEast = edgeIndices.northIndicesWestToEast;
indicesAndEdges = byWidth[height] = {
indices: indices2,
westIndicesSouthToNorth,
southIndicesEastToWest,
eastIndicesNorthToSouth,
northIndicesWestToEast
};
}
return indicesAndEdges;
};
var regularGridAndSkirtAndEdgeIndicesCache = [];
TerrainProvider.getRegularGridAndSkirtIndicesAndEdgeIndices = function(width, height) {
if (width * height >= Math_default.FOUR_GIGABYTES) {
throw new DeveloperError_default(
"The total number of vertices (width * height) must be less than 4,294,967,296."
);
}
let byWidth = regularGridAndSkirtAndEdgeIndicesCache[width];
if (!defined_default(byWidth)) {
regularGridAndSkirtAndEdgeIndicesCache[width] = byWidth = [];
}
let indicesAndEdges = byWidth[height];
if (!defined_default(indicesAndEdges)) {
const gridVertexCount = width * height;
const gridIndexCount = (width - 1) * (height - 1) * 6;
const edgeVertexCount = width * 2 + height * 2;
const edgeIndexCount = Math.max(0, edgeVertexCount - 4) * 6;
const vertexCount = gridVertexCount + edgeVertexCount;
const indexCount = gridIndexCount + edgeIndexCount;
const edgeIndices = getEdgeIndices(width, height);
const westIndicesSouthToNorth = edgeIndices.westIndicesSouthToNorth;
const southIndicesEastToWest = edgeIndices.southIndicesEastToWest;
const eastIndicesNorthToSouth = edgeIndices.eastIndicesNorthToSouth;
const northIndicesWestToEast = edgeIndices.northIndicesWestToEast;
const indices2 = IndexDatatype_default.createTypedArray(vertexCount, indexCount);
addRegularGridIndices(width, height, indices2, 0);
TerrainProvider.addSkirtIndices(
westIndicesSouthToNorth,
southIndicesEastToWest,
eastIndicesNorthToSouth,
northIndicesWestToEast,
gridVertexCount,
indices2,
gridIndexCount
);
indicesAndEdges = byWidth[height] = {
indices: indices2,
westIndicesSouthToNorth,
southIndicesEastToWest,
eastIndicesNorthToSouth,
northIndicesWestToEast,
indexCountWithoutSkirts: gridIndexCount
};
}
return indicesAndEdges;
};
TerrainProvider.addSkirtIndices = function(westIndicesSouthToNorth, southIndicesEastToWest, eastIndicesNorthToSouth, northIndicesWestToEast, vertexCount, indices2, offset2) {
let vertexIndex = vertexCount;
offset2 = addSkirtIndices(
westIndicesSouthToNorth,
vertexIndex,
indices2,
offset2
);
vertexIndex += westIndicesSouthToNorth.length;
offset2 = addSkirtIndices(
southIndicesEastToWest,
vertexIndex,
indices2,
offset2
);
vertexIndex += southIndicesEastToWest.length;
offset2 = addSkirtIndices(
eastIndicesNorthToSouth,
vertexIndex,
indices2,
offset2
);
vertexIndex += eastIndicesNorthToSouth.length;
addSkirtIndices(northIndicesWestToEast, vertexIndex, indices2, offset2);
};
function getEdgeIndices(width, height) {
const westIndicesSouthToNorth = new Array(height);
const southIndicesEastToWest = new Array(width);
const eastIndicesNorthToSouth = new Array(height);
const northIndicesWestToEast = new Array(width);
let i;
for (i = 0; i < width; ++i) {
northIndicesWestToEast[i] = i;
southIndicesEastToWest[i] = width * height - 1 - i;
}
for (i = 0; i < height; ++i) {
eastIndicesNorthToSouth[i] = (i + 1) * width - 1;
westIndicesSouthToNorth[i] = (height - i - 1) * width;
}
return {
westIndicesSouthToNorth,
southIndicesEastToWest,
eastIndicesNorthToSouth,
northIndicesWestToEast
};
}
function addRegularGridIndices(width, height, indices2, offset2) {
let index = 0;
for (let j = 0; j < height - 1; ++j) {
for (let i = 0; i < width - 1; ++i) {
const upperLeft = index;
const lowerLeft = upperLeft + width;
const lowerRight = lowerLeft + 1;
const upperRight = upperLeft + 1;
indices2[offset2++] = upperLeft;
indices2[offset2++] = lowerLeft;
indices2[offset2++] = upperRight;
indices2[offset2++] = upperRight;
indices2[offset2++] = lowerLeft;
indices2[offset2++] = lowerRight;
++index;
}
++index;
}
}
function addSkirtIndices(edgeIndices, vertexIndex, indices2, offset2) {
let previousIndex = edgeIndices[0];
const length3 = edgeIndices.length;
for (let i = 1; i < length3; ++i) {
const index = edgeIndices[i];
indices2[offset2++] = previousIndex;
indices2[offset2++] = index;
indices2[offset2++] = vertexIndex;
indices2[offset2++] = vertexIndex;
indices2[offset2++] = index;
indices2[offset2++] = vertexIndex + 1;
previousIndex = index;
++vertexIndex;
}
return offset2;
}
TerrainProvider.heightmapTerrainQuality = 0.25;
TerrainProvider.getEstimatedLevelZeroGeometricErrorForAHeightmap = function(ellipsoid, tileImageWidth, numberOfTilesAtLevelZero) {
return ellipsoid.maximumRadius * 2 * Math.PI * TerrainProvider.heightmapTerrainQuality / (tileImageWidth * numberOfTilesAtLevelZero);
};
TerrainProvider.prototype.requestTileGeometry = DeveloperError_default.throwInstantiationError;
TerrainProvider.prototype.getLevelMaximumGeometricError = DeveloperError_default.throwInstantiationError;
TerrainProvider.prototype.getTileDataAvailable = DeveloperError_default.throwInstantiationError;
TerrainProvider.prototype.loadTileDataAvailability = DeveloperError_default.throwInstantiationError;
var TerrainProvider_default = TerrainProvider;
// Source/Core/HeightmapTerrainData.js
function HeightmapTerrainData(options) {
if (!defined_default(options) || !defined_default(options.buffer)) {
throw new DeveloperError_default("options.buffer is required.");
}
if (!defined_default(options.width)) {
throw new DeveloperError_default("options.width is required.");
}
if (!defined_default(options.height)) {
throw new DeveloperError_default("options.height is required.");
}
this._buffer = options.buffer;
this._width = options.width;
this._height = options.height;
this._childTileMask = defaultValue_default(options.childTileMask, 15);
this._encoding = defaultValue_default(options.encoding, HeightmapEncoding_default.NONE);
const defaultStructure = HeightmapTessellator_default.DEFAULT_STRUCTURE;
let structure = options.structure;
if (!defined_default(structure)) {
structure = defaultStructure;
} else if (structure !== defaultStructure) {
structure.heightScale = defaultValue_default(
structure.heightScale,
defaultStructure.heightScale
);
structure.heightOffset = defaultValue_default(
structure.heightOffset,
defaultStructure.heightOffset
);
structure.elementsPerHeight = defaultValue_default(
structure.elementsPerHeight,
defaultStructure.elementsPerHeight
);
structure.stride = defaultValue_default(structure.stride, defaultStructure.stride);
structure.elementMultiplier = defaultValue_default(
structure.elementMultiplier,
defaultStructure.elementMultiplier
);
structure.isBigEndian = defaultValue_default(
structure.isBigEndian,
defaultStructure.isBigEndian
);
}
this._structure = structure;
this._createdByUpsampling = defaultValue_default(options.createdByUpsampling, false);
this._waterMask = options.waterMask;
this._skirtHeight = void 0;
this._bufferType = this._encoding === HeightmapEncoding_default.LERC ? Float32Array : this._buffer.constructor;
this._mesh = void 0;
}
Object.defineProperties(HeightmapTerrainData.prototype, {
credits: {
get: function() {
return void 0;
}
},
waterMask: {
get: function() {
return this._waterMask;
}
},
childTileMask: {
get: function() {
return this._childTileMask;
}
}
});
var createMeshTaskName = "createVerticesFromHeightmap";
var createMeshTaskProcessorNoThrottle = new TaskProcessor_default(createMeshTaskName);
var createMeshTaskProcessorThrottle = new TaskProcessor_default(
createMeshTaskName,
TerrainData_default.maximumAsynchronousTasks
);
HeightmapTerrainData.prototype.createMesh = function(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
Check_default.typeOf.object("options.tilingScheme", options.tilingScheme);
Check_default.typeOf.number("options.x", options.x);
Check_default.typeOf.number("options.y", options.y);
Check_default.typeOf.number("options.level", options.level);
const tilingScheme2 = options.tilingScheme;
const x = options.x;
const y = options.y;
const level = options.level;
const exaggeration = defaultValue_default(options.exaggeration, 1);
const exaggerationRelativeHeight = defaultValue_default(
options.exaggerationRelativeHeight,
0
);
const throttle = defaultValue_default(options.throttle, true);
const ellipsoid = tilingScheme2.ellipsoid;
const nativeRectangle = tilingScheme2.tileXYToNativeRectangle(x, y, level);
const rectangle = tilingScheme2.tileXYToRectangle(x, y, level);
const center = ellipsoid.cartographicToCartesian(Rectangle_default.center(rectangle));
const structure = this._structure;
const levelZeroMaxError = TerrainProvider_default.getEstimatedLevelZeroGeometricErrorForAHeightmap(
ellipsoid,
this._width,
tilingScheme2.getNumberOfXTilesAtLevel(0)
);
const thisLevelMaxError = levelZeroMaxError / (1 << level);
this._skirtHeight = Math.min(thisLevelMaxError * 4, 1e3);
const createMeshTaskProcessor = throttle ? createMeshTaskProcessorThrottle : createMeshTaskProcessorNoThrottle;
const verticesPromise = createMeshTaskProcessor.scheduleTask({
heightmap: this._buffer,
structure,
includeWebMercatorT: true,
width: this._width,
height: this._height,
nativeRectangle,
rectangle,
relativeToCenter: center,
ellipsoid,
skirtHeight: this._skirtHeight,
isGeographic: tilingScheme2.projection instanceof GeographicProjection_default,
exaggeration,
exaggerationRelativeHeight,
encoding: this._encoding
});
if (!defined_default(verticesPromise)) {
return void 0;
}
const that = this;
return Promise.resolve(verticesPromise).then(function(result) {
let indicesAndEdges;
if (that._skirtHeight > 0) {
indicesAndEdges = TerrainProvider_default.getRegularGridAndSkirtIndicesAndEdgeIndices(
result.gridWidth,
result.gridHeight
);
} else {
indicesAndEdges = TerrainProvider_default.getRegularGridIndicesAndEdgeIndices(
result.gridWidth,
result.gridHeight
);
}
const vertexCountWithoutSkirts = result.gridWidth * result.gridHeight;
that._mesh = new TerrainMesh_default(
center,
new Float32Array(result.vertices),
indicesAndEdges.indices,
indicesAndEdges.indexCountWithoutSkirts,
vertexCountWithoutSkirts,
result.minimumHeight,
result.maximumHeight,
BoundingSphere_default.clone(result.boundingSphere3D),
Cartesian3_default.clone(result.occludeePointInScaledSpace),
result.numberOfAttributes,
OrientedBoundingBox_default.clone(result.orientedBoundingBox),
TerrainEncoding_default.clone(result.encoding),
indicesAndEdges.westIndicesSouthToNorth,
indicesAndEdges.southIndicesEastToWest,
indicesAndEdges.eastIndicesNorthToSouth,
indicesAndEdges.northIndicesWestToEast
);
that._buffer = void 0;
return that._mesh;
});
};
HeightmapTerrainData.prototype._createMeshSync = function(options) {
Check_default.typeOf.object("options.tilingScheme", options.tilingScheme);
Check_default.typeOf.number("options.x", options.x);
Check_default.typeOf.number("options.y", options.y);
Check_default.typeOf.number("options.level", options.level);
const tilingScheme2 = options.tilingScheme;
const x = options.x;
const y = options.y;
const level = options.level;
const exaggeration = defaultValue_default(options.exaggeration, 1);
const exaggerationRelativeHeight = defaultValue_default(
options.exaggerationRelativeHeight,
0
);
const ellipsoid = tilingScheme2.ellipsoid;
const nativeRectangle = tilingScheme2.tileXYToNativeRectangle(x, y, level);
const rectangle = tilingScheme2.tileXYToRectangle(x, y, level);
const center = ellipsoid.cartographicToCartesian(Rectangle_default.center(rectangle));
const structure = this._structure;
const levelZeroMaxError = TerrainProvider_default.getEstimatedLevelZeroGeometricErrorForAHeightmap(
ellipsoid,
this._width,
tilingScheme2.getNumberOfXTilesAtLevel(0)
);
const thisLevelMaxError = levelZeroMaxError / (1 << level);
this._skirtHeight = Math.min(thisLevelMaxError * 4, 1e3);
const result = HeightmapTessellator_default.computeVertices({
heightmap: this._buffer,
structure,
includeWebMercatorT: true,
width: this._width,
height: this._height,
nativeRectangle,
rectangle,
relativeToCenter: center,
ellipsoid,
skirtHeight: this._skirtHeight,
isGeographic: tilingScheme2.projection instanceof GeographicProjection_default,
exaggeration,
exaggerationRelativeHeight
});
this._buffer = void 0;
let indicesAndEdges;
if (this._skirtHeight > 0) {
indicesAndEdges = TerrainProvider_default.getRegularGridAndSkirtIndicesAndEdgeIndices(
this._width,
this._height
);
} else {
indicesAndEdges = TerrainProvider_default.getRegularGridIndicesAndEdgeIndices(
this._width,
this._height
);
}
const vertexCountWithoutSkirts = result.gridWidth * result.gridHeight;
this._mesh = new TerrainMesh_default(
center,
result.vertices,
indicesAndEdges.indices,
indicesAndEdges.indexCountWithoutSkirts,
vertexCountWithoutSkirts,
result.minimumHeight,
result.maximumHeight,
result.boundingSphere3D,
result.occludeePointInScaledSpace,
result.encoding.stride,
result.orientedBoundingBox,
result.encoding,
indicesAndEdges.westIndicesSouthToNorth,
indicesAndEdges.southIndicesEastToWest,
indicesAndEdges.eastIndicesNorthToSouth,
indicesAndEdges.northIndicesWestToEast
);
return this._mesh;
};
HeightmapTerrainData.prototype.interpolateHeight = function(rectangle, longitude, latitude) {
const width = this._width;
const height = this._height;
const structure = this._structure;
const stride = structure.stride;
const elementsPerHeight = structure.elementsPerHeight;
const elementMultiplier = structure.elementMultiplier;
const isBigEndian = structure.isBigEndian;
const heightOffset = structure.heightOffset;
const heightScale = structure.heightScale;
const isMeshCreated = defined_default(this._mesh);
const isLERCEncoding = this._encoding === HeightmapEncoding_default.LERC;
const isInterpolationImpossible = !isMeshCreated && isLERCEncoding;
if (isInterpolationImpossible) {
return void 0;
}
let heightSample;
if (isMeshCreated) {
const buffer = this._mesh.vertices;
const encoding = this._mesh.encoding;
heightSample = interpolateMeshHeight(
buffer,
encoding,
heightOffset,
heightScale,
rectangle,
width,
height,
longitude,
latitude
);
} else {
heightSample = interpolateHeight(
this._buffer,
elementsPerHeight,
elementMultiplier,
stride,
isBigEndian,
rectangle,
width,
height,
longitude,
latitude
);
heightSample = heightSample * heightScale + heightOffset;
}
return heightSample;
};
HeightmapTerrainData.prototype.upsample = function(tilingScheme2, thisX, thisY, thisLevel, descendantX, descendantY, descendantLevel) {
if (!defined_default(tilingScheme2)) {
throw new DeveloperError_default("tilingScheme is required.");
}
if (!defined_default(thisX)) {
throw new DeveloperError_default("thisX is required.");
}
if (!defined_default(thisY)) {
throw new DeveloperError_default("thisY is required.");
}
if (!defined_default(thisLevel)) {
throw new DeveloperError_default("thisLevel is required.");
}
if (!defined_default(descendantX)) {
throw new DeveloperError_default("descendantX is required.");
}
if (!defined_default(descendantY)) {
throw new DeveloperError_default("descendantY is required.");
}
if (!defined_default(descendantLevel)) {
throw new DeveloperError_default("descendantLevel is required.");
}
const levelDifference = descendantLevel - thisLevel;
if (levelDifference > 1) {
throw new DeveloperError_default(
"Upsampling through more than one level at a time is not currently supported."
);
}
const meshData = this._mesh;
if (!defined_default(meshData)) {
return void 0;
}
const width = this._width;
const height = this._height;
const structure = this._structure;
const stride = structure.stride;
const heights = new this._bufferType(width * height * stride);
const buffer = meshData.vertices;
const encoding = meshData.encoding;
const sourceRectangle = tilingScheme2.tileXYToRectangle(
thisX,
thisY,
thisLevel
);
const destinationRectangle = tilingScheme2.tileXYToRectangle(
descendantX,
descendantY,
descendantLevel
);
const heightOffset = structure.heightOffset;
const heightScale = structure.heightScale;
const elementsPerHeight = structure.elementsPerHeight;
const elementMultiplier = structure.elementMultiplier;
const isBigEndian = structure.isBigEndian;
const divisor = Math.pow(elementMultiplier, elementsPerHeight - 1);
for (let j = 0; j < height; ++j) {
const latitude = Math_default.lerp(
destinationRectangle.north,
destinationRectangle.south,
j / (height - 1)
);
for (let i = 0; i < width; ++i) {
const longitude = Math_default.lerp(
destinationRectangle.west,
destinationRectangle.east,
i / (width - 1)
);
let heightSample = interpolateMeshHeight(
buffer,
encoding,
heightOffset,
heightScale,
sourceRectangle,
width,
height,
longitude,
latitude
);
heightSample = heightSample < structure.lowestEncodedHeight ? structure.lowestEncodedHeight : heightSample;
heightSample = heightSample > structure.highestEncodedHeight ? structure.highestEncodedHeight : heightSample;
setHeight(
heights,
elementsPerHeight,
elementMultiplier,
divisor,
stride,
isBigEndian,
j * width + i,
heightSample
);
}
}
return Promise.resolve(
new HeightmapTerrainData({
buffer: heights,
width,
height,
childTileMask: 0,
structure: this._structure,
createdByUpsampling: true
})
);
};
HeightmapTerrainData.prototype.isChildAvailable = function(thisX, thisY, childX, childY) {
if (!defined_default(thisX)) {
throw new DeveloperError_default("thisX is required.");
}
if (!defined_default(thisY)) {
throw new DeveloperError_default("thisY is required.");
}
if (!defined_default(childX)) {
throw new DeveloperError_default("childX is required.");
}
if (!defined_default(childY)) {
throw new DeveloperError_default("childY is required.");
}
let bitNumber = 2;
if (childX !== thisX * 2) {
++bitNumber;
}
if (childY !== thisY * 2) {
bitNumber -= 2;
}
return (this._childTileMask & 1 << bitNumber) !== 0;
};
HeightmapTerrainData.prototype.wasCreatedByUpsampling = function() {
return this._createdByUpsampling;
};
function interpolateHeight(sourceHeights, elementsPerHeight, elementMultiplier, stride, isBigEndian, sourceRectangle, width, height, longitude, latitude) {
const fromWest = (longitude - sourceRectangle.west) * (width - 1) / (sourceRectangle.east - sourceRectangle.west);
const fromSouth = (latitude - sourceRectangle.south) * (height - 1) / (sourceRectangle.north - sourceRectangle.south);
let westInteger = fromWest | 0;
let eastInteger = westInteger + 1;
if (eastInteger >= width) {
eastInteger = width - 1;
westInteger = width - 2;
}
let southInteger = fromSouth | 0;
let northInteger = southInteger + 1;
if (northInteger >= height) {
northInteger = height - 1;
southInteger = height - 2;
}
const dx = fromWest - westInteger;
const dy = fromSouth - southInteger;
southInteger = height - 1 - southInteger;
northInteger = height - 1 - northInteger;
const southwestHeight = getHeight(
sourceHeights,
elementsPerHeight,
elementMultiplier,
stride,
isBigEndian,
southInteger * width + westInteger
);
const southeastHeight = getHeight(
sourceHeights,
elementsPerHeight,
elementMultiplier,
stride,
isBigEndian,
southInteger * width + eastInteger
);
const northwestHeight = getHeight(
sourceHeights,
elementsPerHeight,
elementMultiplier,
stride,
isBigEndian,
northInteger * width + westInteger
);
const northeastHeight = getHeight(
sourceHeights,
elementsPerHeight,
elementMultiplier,
stride,
isBigEndian,
northInteger * width + eastInteger
);
return triangleInterpolateHeight(
dx,
dy,
southwestHeight,
southeastHeight,
northwestHeight,
northeastHeight
);
}
function interpolateMeshHeight(buffer, encoding, heightOffset, heightScale, sourceRectangle, width, height, longitude, latitude) {
const fromWest = (longitude - sourceRectangle.west) * (width - 1) / (sourceRectangle.east - sourceRectangle.west);
const fromSouth = (latitude - sourceRectangle.south) * (height - 1) / (sourceRectangle.north - sourceRectangle.south);
let westInteger = fromWest | 0;
let eastInteger = westInteger + 1;
if (eastInteger >= width) {
eastInteger = width - 1;
westInteger = width - 2;
}
let southInteger = fromSouth | 0;
let northInteger = southInteger + 1;
if (northInteger >= height) {
northInteger = height - 1;
southInteger = height - 2;
}
const dx = fromWest - westInteger;
const dy = fromSouth - southInteger;
southInteger = height - 1 - southInteger;
northInteger = height - 1 - northInteger;
const southwestHeight = (encoding.decodeHeight(buffer, southInteger * width + westInteger) - heightOffset) / heightScale;
const southeastHeight = (encoding.decodeHeight(buffer, southInteger * width + eastInteger) - heightOffset) / heightScale;
const northwestHeight = (encoding.decodeHeight(buffer, northInteger * width + westInteger) - heightOffset) / heightScale;
const northeastHeight = (encoding.decodeHeight(buffer, northInteger * width + eastInteger) - heightOffset) / heightScale;
return triangleInterpolateHeight(
dx,
dy,
southwestHeight,
southeastHeight,
northwestHeight,
northeastHeight
);
}
function triangleInterpolateHeight(dX, dY, southwestHeight, southeastHeight, northwestHeight, northeastHeight) {
if (dY < dX) {
return southwestHeight + dX * (southeastHeight - southwestHeight) + dY * (northeastHeight - southeastHeight);
}
return southwestHeight + dX * (northeastHeight - northwestHeight) + dY * (northwestHeight - southwestHeight);
}
function getHeight(heights, elementsPerHeight, elementMultiplier, stride, isBigEndian, index) {
index *= stride;
let height = 0;
let i;
if (isBigEndian) {
for (i = 0; i < elementsPerHeight; ++i) {
height = height * elementMultiplier + heights[index + i];
}
} else {
for (i = elementsPerHeight - 1; i >= 0; --i) {
height = height * elementMultiplier + heights[index + i];
}
}
return height;
}
function setHeight(heights, elementsPerHeight, elementMultiplier, divisor, stride, isBigEndian, index, height) {
index *= stride;
let i;
if (isBigEndian) {
for (i = 0; i < elementsPerHeight - 1; ++i) {
heights[index + i] = height / divisor | 0;
height -= heights[index + i] * divisor;
divisor /= elementMultiplier;
}
} else {
for (i = elementsPerHeight - 1; i > 0; --i) {
heights[index + i] = height / divisor | 0;
height -= heights[index + i] * divisor;
divisor /= elementMultiplier;
}
}
heights[index + i] = height;
}
var HeightmapTerrainData_default = HeightmapTerrainData;
// Source/Core/TileAvailability.js
function TileAvailability(tilingScheme2, maximumLevel) {
this._tilingScheme = tilingScheme2;
this._maximumLevel = maximumLevel;
this._rootNodes = [];
}
var rectangleScratch = new Rectangle_default();
function findNode(level, x, y, nodes) {
const count = nodes.length;
for (let i = 0; i < count; ++i) {
const node = nodes[i];
if (node.x === x && node.y === y && node.level === level) {
return true;
}
}
return false;
}
TileAvailability.prototype.addAvailableTileRange = function(level, startX, startY, endX, endY) {
const tilingScheme2 = this._tilingScheme;
const rootNodes = this._rootNodes;
if (level === 0) {
for (let y = startY; y <= endY; ++y) {
for (let x = startX; x <= endX; ++x) {
if (!findNode(level, x, y, rootNodes)) {
rootNodes.push(new QuadtreeNode(tilingScheme2, void 0, 0, x, y));
}
}
}
}
tilingScheme2.tileXYToRectangle(startX, startY, level, rectangleScratch);
const west = rectangleScratch.west;
const north = rectangleScratch.north;
tilingScheme2.tileXYToRectangle(endX, endY, level, rectangleScratch);
const east = rectangleScratch.east;
const south = rectangleScratch.south;
const rectangleWithLevel = new RectangleWithLevel(
level,
west,
south,
east,
north
);
for (let i = 0; i < rootNodes.length; ++i) {
const rootNode = rootNodes[i];
if (rectanglesOverlap(rootNode.extent, rectangleWithLevel)) {
putRectangleInQuadtree(this._maximumLevel, rootNode, rectangleWithLevel);
}
}
};
TileAvailability.prototype.computeMaximumLevelAtPosition = function(position) {
let node;
for (let nodeIndex = 0; nodeIndex < this._rootNodes.length; ++nodeIndex) {
const rootNode = this._rootNodes[nodeIndex];
if (rectangleContainsPosition(rootNode.extent, position)) {
node = rootNode;
break;
}
}
if (!defined_default(node)) {
return -1;
}
return findMaxLevelFromNode(void 0, node, position);
};
var rectanglesScratch = [];
var remainingToCoverByLevelScratch = [];
var westScratch = new Rectangle_default();
var eastScratch = new Rectangle_default();
TileAvailability.prototype.computeBestAvailableLevelOverRectangle = function(rectangle) {
const rectangles = rectanglesScratch;
rectangles.length = 0;
if (rectangle.east < rectangle.west) {
rectangles.push(
Rectangle_default.fromRadians(
-Math.PI,
rectangle.south,
rectangle.east,
rectangle.north,
westScratch
)
);
rectangles.push(
Rectangle_default.fromRadians(
rectangle.west,
rectangle.south,
Math.PI,
rectangle.north,
eastScratch
)
);
} else {
rectangles.push(rectangle);
}
const remainingToCoverByLevel = remainingToCoverByLevelScratch;
remainingToCoverByLevel.length = 0;
let i;
for (i = 0; i < this._rootNodes.length; ++i) {
updateCoverageWithNode(
remainingToCoverByLevel,
this._rootNodes[i],
rectangles
);
}
for (i = remainingToCoverByLevel.length - 1; i >= 0; --i) {
if (defined_default(remainingToCoverByLevel[i]) && remainingToCoverByLevel[i].length === 0) {
return i;
}
}
return 0;
};
var cartographicScratch = new Cartographic_default();
TileAvailability.prototype.isTileAvailable = function(level, x, y) {
const rectangle = this._tilingScheme.tileXYToRectangle(
x,
y,
level,
rectangleScratch
);
Rectangle_default.center(rectangle, cartographicScratch);
return this.computeMaximumLevelAtPosition(cartographicScratch) >= level;
};
TileAvailability.prototype.computeChildMaskForTile = function(level, x, y) {
const childLevel = level + 1;
if (childLevel >= this._maximumLevel) {
return 0;
}
let mask = 0;
mask |= this.isTileAvailable(childLevel, 2 * x, 2 * y + 1) ? 1 : 0;
mask |= this.isTileAvailable(childLevel, 2 * x + 1, 2 * y + 1) ? 2 : 0;
mask |= this.isTileAvailable(childLevel, 2 * x, 2 * y) ? 4 : 0;
mask |= this.isTileAvailable(childLevel, 2 * x + 1, 2 * y) ? 8 : 0;
return mask;
};
function QuadtreeNode(tilingScheme2, parent, level, x, y) {
this.tilingScheme = tilingScheme2;
this.parent = parent;
this.level = level;
this.x = x;
this.y = y;
this.extent = tilingScheme2.tileXYToRectangle(x, y, level);
this.rectangles = [];
this._sw = void 0;
this._se = void 0;
this._nw = void 0;
this._ne = void 0;
}
Object.defineProperties(QuadtreeNode.prototype, {
nw: {
get: function() {
if (!this._nw) {
this._nw = new QuadtreeNode(
this.tilingScheme,
this,
this.level + 1,
this.x * 2,
this.y * 2
);
}
return this._nw;
}
},
ne: {
get: function() {
if (!this._ne) {
this._ne = new QuadtreeNode(
this.tilingScheme,
this,
this.level + 1,
this.x * 2 + 1,
this.y * 2
);
}
return this._ne;
}
},
sw: {
get: function() {
if (!this._sw) {
this._sw = new QuadtreeNode(
this.tilingScheme,
this,
this.level + 1,
this.x * 2,
this.y * 2 + 1
);
}
return this._sw;
}
},
se: {
get: function() {
if (!this._se) {
this._se = new QuadtreeNode(
this.tilingScheme,
this,
this.level + 1,
this.x * 2 + 1,
this.y * 2 + 1
);
}
return this._se;
}
}
});
function RectangleWithLevel(level, west, south, east, north) {
this.level = level;
this.west = west;
this.south = south;
this.east = east;
this.north = north;
}
function rectanglesOverlap(rectangle1, rectangle2) {
const west = Math.max(rectangle1.west, rectangle2.west);
const south = Math.max(rectangle1.south, rectangle2.south);
const east = Math.min(rectangle1.east, rectangle2.east);
const north = Math.min(rectangle1.north, rectangle2.north);
return south < north && west < east;
}
function putRectangleInQuadtree(maxDepth, node, rectangle) {
while (node.level < maxDepth) {
if (rectangleFullyContainsRectangle(node.nw.extent, rectangle)) {
node = node.nw;
} else if (rectangleFullyContainsRectangle(node.ne.extent, rectangle)) {
node = node.ne;
} else if (rectangleFullyContainsRectangle(node.sw.extent, rectangle)) {
node = node.sw;
} else if (rectangleFullyContainsRectangle(node.se.extent, rectangle)) {
node = node.se;
} else {
break;
}
}
if (node.rectangles.length === 0 || node.rectangles[node.rectangles.length - 1].level <= rectangle.level) {
node.rectangles.push(rectangle);
} else {
let index = binarySearch_default(
node.rectangles,
rectangle.level,
rectangleLevelComparator
);
if (index < 0) {
index = ~index;
}
node.rectangles.splice(index, 0, rectangle);
}
}
function rectangleLevelComparator(a3, b) {
return a3.level - b;
}
function rectangleFullyContainsRectangle(potentialContainer, rectangleToTest) {
return rectangleToTest.west >= potentialContainer.west && rectangleToTest.east <= potentialContainer.east && rectangleToTest.south >= potentialContainer.south && rectangleToTest.north <= potentialContainer.north;
}
function rectangleContainsPosition(potentialContainer, positionToTest) {
return positionToTest.longitude >= potentialContainer.west && positionToTest.longitude <= potentialContainer.east && positionToTest.latitude >= potentialContainer.south && positionToTest.latitude <= potentialContainer.north;
}
function findMaxLevelFromNode(stopNode, node, position) {
let maxLevel = 0;
let found = false;
while (!found) {
const nw = node._nw && rectangleContainsPosition(node._nw.extent, position);
const ne = node._ne && rectangleContainsPosition(node._ne.extent, position);
const sw = node._sw && rectangleContainsPosition(node._sw.extent, position);
const se = node._se && rectangleContainsPosition(node._se.extent, position);
if (nw + ne + sw + se > 1) {
if (nw) {
maxLevel = Math.max(
maxLevel,
findMaxLevelFromNode(node, node._nw, position)
);
}
if (ne) {
maxLevel = Math.max(
maxLevel,
findMaxLevelFromNode(node, node._ne, position)
);
}
if (sw) {
maxLevel = Math.max(
maxLevel,
findMaxLevelFromNode(node, node._sw, position)
);
}
if (se) {
maxLevel = Math.max(
maxLevel,
findMaxLevelFromNode(node, node._se, position)
);
}
break;
} else if (nw) {
node = node._nw;
} else if (ne) {
node = node._ne;
} else if (sw) {
node = node._sw;
} else if (se) {
node = node._se;
} else {
found = true;
}
}
while (node !== stopNode) {
const rectangles = node.rectangles;
for (let i = rectangles.length - 1; i >= 0 && rectangles[i].level > maxLevel; --i) {
const rectangle = rectangles[i];
if (rectangleContainsPosition(rectangle, position)) {
maxLevel = rectangle.level;
}
}
node = node.parent;
}
return maxLevel;
}
function updateCoverageWithNode(remainingToCoverByLevel, node, rectanglesToCover) {
if (!node) {
return;
}
let i;
let anyOverlap = false;
for (i = 0; i < rectanglesToCover.length; ++i) {
anyOverlap = anyOverlap || rectanglesOverlap(node.extent, rectanglesToCover[i]);
}
if (!anyOverlap) {
return;
}
const rectangles = node.rectangles;
for (i = 0; i < rectangles.length; ++i) {
const rectangle = rectangles[i];
if (!remainingToCoverByLevel[rectangle.level]) {
remainingToCoverByLevel[rectangle.level] = rectanglesToCover;
}
remainingToCoverByLevel[rectangle.level] = subtractRectangle(
remainingToCoverByLevel[rectangle.level],
rectangle
);
}
updateCoverageWithNode(remainingToCoverByLevel, node._nw, rectanglesToCover);
updateCoverageWithNode(remainingToCoverByLevel, node._ne, rectanglesToCover);
updateCoverageWithNode(remainingToCoverByLevel, node._sw, rectanglesToCover);
updateCoverageWithNode(remainingToCoverByLevel, node._se, rectanglesToCover);
}
function subtractRectangle(rectangleList, rectangleToSubtract) {
const result = [];
for (let i = 0; i < rectangleList.length; ++i) {
const rectangle = rectangleList[i];
if (!rectanglesOverlap(rectangle, rectangleToSubtract)) {
result.push(rectangle);
} else {
if (rectangle.west < rectangleToSubtract.west) {
result.push(
new Rectangle_default(
rectangle.west,
rectangle.south,
rectangleToSubtract.west,
rectangle.north
)
);
}
if (rectangle.east > rectangleToSubtract.east) {
result.push(
new Rectangle_default(
rectangleToSubtract.east,
rectangle.south,
rectangle.east,
rectangle.north
)
);
}
if (rectangle.south < rectangleToSubtract.south) {
result.push(
new Rectangle_default(
Math.max(rectangleToSubtract.west, rectangle.west),
rectangle.south,
Math.min(rectangleToSubtract.east, rectangle.east),
rectangleToSubtract.south
)
);
}
if (rectangle.north > rectangleToSubtract.north) {
result.push(
new Rectangle_default(
Math.max(rectangleToSubtract.west, rectangle.west),
rectangleToSubtract.north,
Math.min(rectangleToSubtract.east, rectangle.east),
rectangle.north
)
);
}
}
}
return result;
}
var TileAvailability_default = TileAvailability;
// Source/Core/oneTimeWarning.js
var warnings = {};
function oneTimeWarning(identifier, message) {
if (!defined_default(identifier)) {
throw new DeveloperError_default("identifier is required.");
}
if (!defined_default(warnings[identifier])) {
warnings[identifier] = true;
console.warn(defaultValue_default(message, identifier));
}
}
oneTimeWarning.geometryOutlines = "Entity geometry outlines are unsupported on terrain. Outlines will be disabled. To enable outlines, disable geometry terrain clamping by explicitly setting height to 0.";
oneTimeWarning.geometryZIndex = "Entity geometry with zIndex are unsupported when height or extrudedHeight are defined. zIndex will be ignored";
oneTimeWarning.geometryHeightReference = "Entity corridor, ellipse, polygon or rectangle with heightReference must also have a defined height. heightReference will be ignored";
oneTimeWarning.geometryExtrudedHeightReference = "Entity corridor, ellipse, polygon or rectangle with extrudedHeightReference must also have a defined extrudedHeight. extrudedHeightReference will be ignored";
var oneTimeWarning_default = oneTimeWarning;
// Source/Core/deprecationWarning.js
function deprecationWarning(identifier, message) {
if (!defined_default(identifier) || !defined_default(message)) {
throw new DeveloperError_default("identifier and message are required.");
}
oneTimeWarning_default(identifier, message);
}
var deprecationWarning_default = deprecationWarning;
// Source/Core/formatError.js
function formatError(object) {
let result;
const name = object.name;
const message = object.message;
if (defined_default(name) && defined_default(message)) {
result = `${name}: ${message}`;
} else {
result = object.toString();
}
const stack = object.stack;
if (defined_default(stack)) {
result += `
${stack}`;
}
return result;
}
var formatError_default = formatError;
// Source/Core/TileProviderError.js
function TileProviderError(provider, message, x, y, level, timesRetried, error) {
this.provider = provider;
this.message = message;
this.x = x;
this.y = y;
this.level = level;
this.timesRetried = defaultValue_default(timesRetried, 0);
this.retry = false;
this.error = error;
}
TileProviderError.reportError = function(previousError, provider, event, message, x, y, level, errorDetails) {
let error = previousError;
if (!defined_default(previousError)) {
error = new TileProviderError(
provider,
message,
x,
y,
level,
0,
errorDetails
);
} else {
error.provider = provider;
error.message = message;
error.x = x;
error.y = y;
error.level = level;
error.retry = false;
error.error = errorDetails;
++error.timesRetried;
}
if (event.numberOfListeners > 0) {
event.raiseEvent(error);
} else {
console.log(
`An error occurred in "${provider.constructor.name}": ${formatError_default(
message
)}`
);
}
return error;
};
TileProviderError.handleError = function(previousError, provider, event, message, x, y, level, retryFunction, errorDetails) {
deprecationWarning_default(
"TileProviderError.handleError",
"TileProviderError.handleError was deprecated in CesiumJS 1.96 and will be removed in 1.97. Use TileProviderError.reportError instead."
);
const error = TileProviderError.reportError(
previousError,
provider,
event,
message,
x,
y,
level,
errorDetails
);
if (error.retry && defined_default(retryFunction)) {
retryFunction();
}
return error;
};
TileProviderError.reportSuccess = function(previousError) {
if (defined_default(previousError)) {
previousError.timesRetried = -1;
}
};
TileProviderError.handleSuccess = function(previousError) {
deprecationWarning_default(
"TileProviderError.handleSuccess",
"TileProviderError.handleSuccess was deprecated in CesiumJS 1.96 and will be removed in 1.97. Use TileProviderError.reportSuccess instead."
);
TileProviderError.reportSuccess(previousError);
};
var TileProviderError_default = TileProviderError;
// Source/Core/WebMercatorTilingScheme.js
function WebMercatorTilingScheme(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
this._ellipsoid = defaultValue_default(options.ellipsoid, Ellipsoid_default.WGS84);
this._numberOfLevelZeroTilesX = defaultValue_default(
options.numberOfLevelZeroTilesX,
1
);
this._numberOfLevelZeroTilesY = defaultValue_default(
options.numberOfLevelZeroTilesY,
1
);
this._projection = new WebMercatorProjection_default(this._ellipsoid);
if (defined_default(options.rectangleSouthwestInMeters) && defined_default(options.rectangleNortheastInMeters)) {
this._rectangleSouthwestInMeters = options.rectangleSouthwestInMeters;
this._rectangleNortheastInMeters = options.rectangleNortheastInMeters;
} else {
const semimajorAxisTimesPi = this._ellipsoid.maximumRadius * Math.PI;
this._rectangleSouthwestInMeters = new Cartesian2_default(
-semimajorAxisTimesPi,
-semimajorAxisTimesPi
);
this._rectangleNortheastInMeters = new Cartesian2_default(
semimajorAxisTimesPi,
semimajorAxisTimesPi
);
}
const southwest = this._projection.unproject(
this._rectangleSouthwestInMeters
);
const northeast = this._projection.unproject(
this._rectangleNortheastInMeters
);
this._rectangle = new Rectangle_default(
southwest.longitude,
southwest.latitude,
northeast.longitude,
northeast.latitude
);
}
Object.defineProperties(WebMercatorTilingScheme.prototype, {
ellipsoid: {
get: function() {
return this._ellipsoid;
}
},
rectangle: {
get: function() {
return this._rectangle;
}
},
projection: {
get: function() {
return this._projection;
}
}
});
WebMercatorTilingScheme.prototype.getNumberOfXTilesAtLevel = function(level) {
return this._numberOfLevelZeroTilesX << level;
};
WebMercatorTilingScheme.prototype.getNumberOfYTilesAtLevel = function(level) {
return this._numberOfLevelZeroTilesY << level;
};
WebMercatorTilingScheme.prototype.rectangleToNativeRectangle = function(rectangle, result) {
const projection = this._projection;
const southwest = projection.project(Rectangle_default.southwest(rectangle));
const northeast = projection.project(Rectangle_default.northeast(rectangle));
if (!defined_default(result)) {
return new Rectangle_default(southwest.x, southwest.y, northeast.x, northeast.y);
}
result.west = southwest.x;
result.south = southwest.y;
result.east = northeast.x;
result.north = northeast.y;
return result;
};
WebMercatorTilingScheme.prototype.tileXYToNativeRectangle = function(x, y, level, result) {
const xTiles = this.getNumberOfXTilesAtLevel(level);
const yTiles = this.getNumberOfYTilesAtLevel(level);
const xTileWidth = (this._rectangleNortheastInMeters.x - this._rectangleSouthwestInMeters.x) / xTiles;
const west = this._rectangleSouthwestInMeters.x + x * xTileWidth;
const east = this._rectangleSouthwestInMeters.x + (x + 1) * xTileWidth;
const yTileHeight = (this._rectangleNortheastInMeters.y - this._rectangleSouthwestInMeters.y) / yTiles;
const north = this._rectangleNortheastInMeters.y - y * yTileHeight;
const south = this._rectangleNortheastInMeters.y - (y + 1) * yTileHeight;
if (!defined_default(result)) {
return new Rectangle_default(west, south, east, north);
}
result.west = west;
result.south = south;
result.east = east;
result.north = north;
return result;
};
WebMercatorTilingScheme.prototype.tileXYToRectangle = function(x, y, level, result) {
const nativeRectangle = this.tileXYToNativeRectangle(x, y, level, result);
const projection = this._projection;
const southwest = projection.unproject(
new Cartesian2_default(nativeRectangle.west, nativeRectangle.south)
);
const northeast = projection.unproject(
new Cartesian2_default(nativeRectangle.east, nativeRectangle.north)
);
nativeRectangle.west = southwest.longitude;
nativeRectangle.south = southwest.latitude;
nativeRectangle.east = northeast.longitude;
nativeRectangle.north = northeast.latitude;
return nativeRectangle;
};
WebMercatorTilingScheme.prototype.positionToTileXY = function(position, level, result) {
const rectangle = this._rectangle;
if (!Rectangle_default.contains(rectangle, position)) {
return void 0;
}
const xTiles = this.getNumberOfXTilesAtLevel(level);
const yTiles = this.getNumberOfYTilesAtLevel(level);
const overallWidth = this._rectangleNortheastInMeters.x - this._rectangleSouthwestInMeters.x;
const xTileWidth = overallWidth / xTiles;
const overallHeight = this._rectangleNortheastInMeters.y - this._rectangleSouthwestInMeters.y;
const yTileHeight = overallHeight / yTiles;
const projection = this._projection;
const webMercatorPosition = projection.project(position);
const distanceFromWest = webMercatorPosition.x - this._rectangleSouthwestInMeters.x;
const distanceFromNorth = this._rectangleNortheastInMeters.y - webMercatorPosition.y;
let xTileCoordinate = distanceFromWest / xTileWidth | 0;
if (xTileCoordinate >= xTiles) {
xTileCoordinate = xTiles - 1;
}
let yTileCoordinate = distanceFromNorth / yTileHeight | 0;
if (yTileCoordinate >= yTiles) {
yTileCoordinate = yTiles - 1;
}
if (!defined_default(result)) {
return new Cartesian2_default(xTileCoordinate, yTileCoordinate);
}
result.x = xTileCoordinate;
result.y = yTileCoordinate;
return result;
};
var WebMercatorTilingScheme_default = WebMercatorTilingScheme;
// Source/Core/ArcGISTiledElevationTerrainProvider.js
var ALL_CHILDREN = 15;
function ArcGISTiledElevationTerrainProvider(options) {
if (!defined_default(options) || !defined_default(options.url)) {
throw new DeveloperError_default("options.url is required.");
}
this._resource = void 0;
this._credit = void 0;
this._tilingScheme = void 0;
this._levelZeroMaximumGeometricError = void 0;
this._maxLevel = void 0;
this._terrainDataStructure = void 0;
this._ready = false;
this._width = void 0;
this._height = void 0;
this._encoding = void 0;
const token = options.token;
this._hasAvailability = false;
this._tilesAvailable = void 0;
this._tilesAvailablityLoaded = void 0;
this._availableCache = {};
const that = this;
const ellipsoid = defaultValue_default(options.ellipsoid, Ellipsoid_default.WGS84);
this._readyPromise = Promise.resolve(options.url).then(function(url2) {
let resource = Resource_default.createIfNeeded(url2);
resource.appendForwardSlash();
if (defined_default(token)) {
resource = resource.getDerivedResource({
queryParameters: {
token
}
});
}
that._resource = resource;
const metadataResource = resource.getDerivedResource({
queryParameters: {
f: "pjson"
}
});
return metadataResource.fetchJson();
}).then(function(metadata) {
const copyrightText = metadata.copyrightText;
if (defined_default(copyrightText)) {
that._credit = new Credit_default(copyrightText);
}
const spatialReference = metadata.spatialReference;
const wkid = defaultValue_default(
spatialReference.latestWkid,
spatialReference.wkid
);
const extent = metadata.extent;
const tilingSchemeOptions = {
ellipsoid
};
if (wkid === 4326) {
tilingSchemeOptions.rectangle = Rectangle_default.fromDegrees(
extent.xmin,
extent.ymin,
extent.xmax,
extent.ymax
);
that._tilingScheme = new GeographicTilingScheme_default(tilingSchemeOptions);
} else if (wkid === 3857) {
tilingSchemeOptions.rectangleSouthwestInMeters = new Cartesian2_default(
extent.xmin,
extent.ymin
);
tilingSchemeOptions.rectangleNortheastInMeters = new Cartesian2_default(
extent.xmax,
extent.ymax
);
that._tilingScheme = new WebMercatorTilingScheme_default(tilingSchemeOptions);
} else {
return Promise.reject(new RuntimeError_default("Invalid spatial reference"));
}
const tileInfo = metadata.tileInfo;
if (!defined_default(tileInfo)) {
return Promise.reject(new RuntimeError_default("tileInfo is required"));
}
that._width = tileInfo.rows + 1;
that._height = tileInfo.cols + 1;
that._encoding = tileInfo.format === "LERC" ? HeightmapEncoding_default.LERC : HeightmapEncoding_default.NONE;
that._lodCount = tileInfo.lods.length - 1;
const hasAvailability = that._hasAvailability = metadata.capabilities.indexOf("Tilemap") !== -1;
if (hasAvailability) {
that._tilesAvailable = new TileAvailability_default(
that._tilingScheme,
that._lodCount
);
that._tilesAvailable.addAvailableTileRange(
0,
0,
0,
that._tilingScheme.getNumberOfXTilesAtLevel(0),
that._tilingScheme.getNumberOfYTilesAtLevel(0)
);
that._tilesAvailablityLoaded = new TileAvailability_default(
that._tilingScheme,
that._lodCount
);
}
that._levelZeroMaximumGeometricError = TerrainProvider_default.getEstimatedLevelZeroGeometricErrorForAHeightmap(
that._tilingScheme.ellipsoid,
that._width,
that._tilingScheme.getNumberOfXTilesAtLevel(0)
);
if (metadata.bandCount > 1) {
console.log(
"ArcGISTiledElevationTerrainProvider: Terrain data has more than 1 band. Using the first one."
);
}
that._terrainDataStructure = {
elementMultiplier: 1,
lowestEncodedHeight: metadata.minValues[0],
highestEncodedHeight: metadata.maxValues[0]
};
that._ready = true;
return true;
}).catch(function(error) {
const message = `An error occurred while accessing ${that._resource.url}.`;
TileProviderError_default.reportError(void 0, that, that._errorEvent, message);
return Promise.reject(error);
});
this._errorEvent = new Event_default();
}
Object.defineProperties(ArcGISTiledElevationTerrainProvider.prototype, {
errorEvent: {
get: function() {
return this._errorEvent;
}
},
credit: {
get: function() {
if (!this.ready) {
throw new DeveloperError_default(
"credit must not be called before ready returns true."
);
}
return this._credit;
}
},
tilingScheme: {
get: function() {
if (!this.ready) {
throw new DeveloperError_default(
"tilingScheme must not be called before ready returns true."
);
}
return this._tilingScheme;
}
},
ready: {
get: function() {
return this._ready;
}
},
readyPromise: {
get: function() {
return this._readyPromise;
}
},
hasWaterMask: {
get: function() {
return false;
}
},
hasVertexNormals: {
get: function() {
return false;
}
},
availability: {
get: function() {
if (!this._ready) {
throw new DeveloperError_default(
"availability must not be called before the terrain provider is ready."
);
}
return this._tilesAvailable;
}
}
});
ArcGISTiledElevationTerrainProvider.prototype.requestTileGeometry = function(x, y, level, request) {
if (!this._ready) {
throw new DeveloperError_default(
"requestTileGeometry must not be called before the terrain provider is ready."
);
}
const tileResource = this._resource.getDerivedResource({
url: `tile/${level}/${y}/${x}`,
request
});
const hasAvailability = this._hasAvailability;
let availabilityPromise = Promise.resolve(true);
let availabilityRequest;
if (hasAvailability && !defined_default(isTileAvailable(this, level + 1, x * 2, y * 2))) {
const availabilityResult = requestAvailability(
this,
level + 1,
x * 2,
y * 2
);
availabilityPromise = availabilityResult.promise;
availabilityRequest = availabilityResult.request;
}
const promise = tileResource.fetchArrayBuffer();
if (!defined_default(promise) || !defined_default(availabilityPromise)) {
return void 0;
}
const that = this;
const tilesAvailable = this._tilesAvailable;
return Promise.all([promise, availabilityPromise]).then(function(result) {
return new HeightmapTerrainData_default({
buffer: result[0],
width: that._width,
height: that._height,
childTileMask: hasAvailability ? tilesAvailable.computeChildMaskForTile(level, x, y) : ALL_CHILDREN,
structure: that._terrainDataStructure,
encoding: that._encoding
});
}).catch(function(error) {
if (defined_default(availabilityRequest) && availabilityRequest.state === RequestState_default.CANCELLED) {
request.cancel();
return request.deferred.promise.finally(function() {
request.state = RequestState_default.CANCELLED;
return Promise.reject(error);
});
}
return Promise.reject(error);
});
};
function isTileAvailable(that, level, x, y) {
if (!that._hasAvailability) {
return void 0;
}
const tilesAvailablityLoaded = that._tilesAvailablityLoaded;
const tilesAvailable = that._tilesAvailable;
if (level > that._lodCount) {
return false;
}
if (tilesAvailable.isTileAvailable(level, x, y)) {
return true;
}
if (tilesAvailablityLoaded.isTileAvailable(level, x, y)) {
return false;
}
return void 0;
}
ArcGISTiledElevationTerrainProvider.prototype.getLevelMaximumGeometricError = function(level) {
if (!this.ready) {
throw new DeveloperError_default(
"getLevelMaximumGeometricError must not be called before ready returns true."
);
}
return this._levelZeroMaximumGeometricError / (1 << level);
};
ArcGISTiledElevationTerrainProvider.prototype.getTileDataAvailable = function(x, y, level) {
if (!this._hasAvailability) {
return void 0;
}
const result = isTileAvailable(this, level, x, y);
if (defined_default(result)) {
return result;
}
requestAvailability(this, level, x, y);
return void 0;
};
ArcGISTiledElevationTerrainProvider.prototype.loadTileDataAvailability = function(x, y, level) {
return void 0;
};
function findRange(origin, width, height, data) {
const endCol = width - 1;
const endRow = height - 1;
const value = data[origin.y * width + origin.x];
const endingIndices = [];
const range = {
startX: origin.x,
startY: origin.y,
endX: 0,
endY: 0
};
const corner = new Cartesian2_default(origin.x + 1, origin.y + 1);
let doneX = false;
let doneY = false;
while (!(doneX && doneY)) {
let endX = corner.x;
const endY = doneY ? corner.y + 1 : corner.y;
if (!doneX) {
for (let y = origin.y; y < endY; ++y) {
if (data[y * width + corner.x] !== value) {
doneX = true;
break;
}
}
if (doneX) {
endingIndices.push(new Cartesian2_default(corner.x, origin.y));
--corner.x;
--endX;
range.endX = corner.x;
} else if (corner.x === endCol) {
range.endX = corner.x;
doneX = true;
} else {
++corner.x;
}
}
if (!doneY) {
const col = corner.y * width;
for (let x = origin.x; x <= endX; ++x) {
if (data[col + x] !== value) {
doneY = true;
break;
}
}
if (doneY) {
endingIndices.push(new Cartesian2_default(origin.x, corner.y));
--corner.y;
range.endY = corner.y;
} else if (corner.y === endRow) {
range.endY = corner.y;
doneY = true;
} else {
++corner.y;
}
}
}
return {
endingIndices,
range,
value
};
}
function computeAvailability(x, y, width, height, data) {
const ranges = [];
const singleValue = data.every(function(val) {
return val === data[0];
});
if (singleValue) {
if (data[0] === 1) {
ranges.push({
startX: x,
startY: y,
endX: x + width - 1,
endY: y + height - 1
});
}
return ranges;
}
let positions = [new Cartesian2_default(0, 0)];
while (positions.length > 0) {
const origin = positions.pop();
const result = findRange(origin, width, height, data);
if (result.value === 1) {
const range = result.range;
range.startX += x;
range.endX += x;
range.startY += y;
range.endY += y;
ranges.push(range);
}
const endingIndices = result.endingIndices;
if (endingIndices.length > 0) {
positions = positions.concat(endingIndices);
}
}
return ranges;
}
function requestAvailability(that, level, x, y) {
if (!that._hasAvailability) {
return {};
}
const xOffset = Math.floor(x / 128) * 128;
const yOffset = Math.floor(y / 128) * 128;
const dim = Math.min(1 << level, 128);
const url2 = `tilemap/${level}/${yOffset}/${xOffset}/${dim}/${dim}`;
const availableCache = that._availableCache;
if (defined_default(availableCache[url2])) {
return availableCache[url2];
}
const request = new Request_default({
throttle: false,
throttleByServer: true,
type: RequestType_default.TERRAIN
});
const tilemapResource = that._resource.getDerivedResource({
url: url2,
request
});
let promise = tilemapResource.fetchJson();
if (!defined_default(promise)) {
return {};
}
promise = promise.then(function(result) {
const available = computeAvailability(
xOffset,
yOffset,
dim,
dim,
result.data
);
that._tilesAvailablityLoaded.addAvailableTileRange(
level,
xOffset,
yOffset,
xOffset + dim,
yOffset + dim
);
const tilesAvailable = that._tilesAvailable;
for (let i = 0; i < available.length; ++i) {
const range = available[i];
tilesAvailable.addAvailableTileRange(
level,
range.startX,
range.startY,
range.endX,
range.endY
);
}
return isTileAvailable(that, level, x, y);
});
availableCache[url2] = {
promise,
request
};
promise = promise.finally(function(result) {
delete availableCache[url2];
return result;
});
return {
promise,
request
};
}
var ArcGISTiledElevationTerrainProvider_default = ArcGISTiledElevationTerrainProvider;
// Source/Core/ArcType.js
var ArcType = {
NONE: 0,
GEODESIC: 1,
RHUMB: 2
};
var ArcType_default = Object.freeze(ArcType);
// Source/Core/arrayRemoveDuplicates.js
var removeDuplicatesEpsilon = Math_default.EPSILON10;
function arrayRemoveDuplicates(values, equalsEpsilon, wrapAround, removedIndices) {
Check_default.defined("equalsEpsilon", equalsEpsilon);
if (!defined_default(values)) {
return void 0;
}
wrapAround = defaultValue_default(wrapAround, false);
const storeRemovedIndices = defined_default(removedIndices);
const length3 = values.length;
if (length3 < 2) {
return values;
}
let i;
let v02 = values[0];
let v13;
let cleanedValues;
let lastCleanIndex = 0;
let removedIndexLCI = -1;
for (i = 1; i < length3; ++i) {
v13 = values[i];
if (equalsEpsilon(v02, v13, removeDuplicatesEpsilon)) {
if (!defined_default(cleanedValues)) {
cleanedValues = values.slice(0, i);
lastCleanIndex = i - 1;
removedIndexLCI = 0;
}
if (storeRemovedIndices) {
removedIndices.push(i);
}
} else {
if (defined_default(cleanedValues)) {
cleanedValues.push(v13);
lastCleanIndex = i;
if (storeRemovedIndices) {
removedIndexLCI = removedIndices.length;
}
}
v02 = v13;
}
}
if (wrapAround && equalsEpsilon(values[0], values[length3 - 1], removeDuplicatesEpsilon)) {
if (storeRemovedIndices) {
if (defined_default(cleanedValues)) {
removedIndices.splice(removedIndexLCI, 0, lastCleanIndex);
} else {
removedIndices.push(length3 - 1);
}
}
if (defined_default(cleanedValues)) {
cleanedValues.length -= 1;
} else {
cleanedValues = values.slice(0, -1);
}
}
return defined_default(cleanedValues) ? cleanedValues : values;
}
var arrayRemoveDuplicates_default = arrayRemoveDuplicates;
// Source/Core/ArticulationStageType.js
var ArticulationStageType = {
XTRANSLATE: "xTranslate",
YTRANSLATE: "yTranslate",
ZTRANSLATE: "zTranslate",
XROTATE: "xRotate",
YROTATE: "yRotate",
ZROTATE: "zRotate",
XSCALE: "xScale",
YSCALE: "yScale",
ZSCALE: "zScale",
UNIFORMSCALE: "uniformScale"
};
var ArticulationStageType_default = Object.freeze(ArticulationStageType);
// Source/Core/AssociativeArray.js
function AssociativeArray() {
this._array = [];
this._hash = {};
}
Object.defineProperties(AssociativeArray.prototype, {
length: {
get: function() {
return this._array.length;
}
},
values: {
get: function() {
return this._array;
}
}
});
AssociativeArray.prototype.contains = function(key) {
if (typeof key !== "string" && typeof key !== "number") {
throw new DeveloperError_default("key is required to be a string or number.");
}
return defined_default(this._hash[key]);
};
AssociativeArray.prototype.set = function(key, value) {
if (typeof key !== "string" && typeof key !== "number") {
throw new DeveloperError_default("key is required to be a string or number.");
}
const oldValue2 = this._hash[key];
if (value !== oldValue2) {
this.remove(key);
this._hash[key] = value;
this._array.push(value);
}
};
AssociativeArray.prototype.get = function(key) {
if (typeof key !== "string" && typeof key !== "number") {
throw new DeveloperError_default("key is required to be a string or number.");
}
return this._hash[key];
};
AssociativeArray.prototype.remove = function(key) {
if (defined_default(key) && typeof key !== "string" && typeof key !== "number") {
throw new DeveloperError_default("key is required to be a string or number.");
}
const value = this._hash[key];
const hasValue = defined_default(value);
if (hasValue) {
const array = this._array;
array.splice(array.indexOf(value), 1);
delete this._hash[key];
}
return hasValue;
};
AssociativeArray.prototype.removeAll = function() {
const array = this._array;
if (array.length > 0) {
this._hash = {};
array.length = 0;
}
};
var AssociativeArray_default = AssociativeArray;
// Source/Core/barycentricCoordinates.js
var scratchCartesian12 = new Cartesian3_default();
var scratchCartesian23 = new Cartesian3_default();
var scratchCartesian33 = new Cartesian3_default();
function barycentricCoordinates(point, p0, p1, p2, result) {
Check_default.defined("point", point);
Check_default.defined("p0", p0);
Check_default.defined("p1", p1);
Check_default.defined("p2", p2);
if (!defined_default(result)) {
result = new Cartesian3_default();
}
let v02;
let v13;
let v23;
let dot00;
let dot01;
let dot02;
let dot11;
let dot12;
if (!defined_default(p0.z)) {
if (Cartesian2_default.equalsEpsilon(point, p0, Math_default.EPSILON14)) {
return Cartesian3_default.clone(Cartesian3_default.UNIT_X, result);
}
if (Cartesian2_default.equalsEpsilon(point, p1, Math_default.EPSILON14)) {
return Cartesian3_default.clone(Cartesian3_default.UNIT_Y, result);
}
if (Cartesian2_default.equalsEpsilon(point, p2, Math_default.EPSILON14)) {
return Cartesian3_default.clone(Cartesian3_default.UNIT_Z, result);
}
v02 = Cartesian2_default.subtract(p1, p0, scratchCartesian12);
v13 = Cartesian2_default.subtract(p2, p0, scratchCartesian23);
v23 = Cartesian2_default.subtract(point, p0, scratchCartesian33);
dot00 = Cartesian2_default.dot(v02, v02);
dot01 = Cartesian2_default.dot(v02, v13);
dot02 = Cartesian2_default.dot(v02, v23);
dot11 = Cartesian2_default.dot(v13, v13);
dot12 = Cartesian2_default.dot(v13, v23);
} else {
if (Cartesian3_default.equalsEpsilon(point, p0, Math_default.EPSILON14)) {
return Cartesian3_default.clone(Cartesian3_default.UNIT_X, result);
}
if (Cartesian3_default.equalsEpsilon(point, p1, Math_default.EPSILON14)) {
return Cartesian3_default.clone(Cartesian3_default.UNIT_Y, result);
}
if (Cartesian3_default.equalsEpsilon(point, p2, Math_default.EPSILON14)) {
return Cartesian3_default.clone(Cartesian3_default.UNIT_Z, result);
}
v02 = Cartesian3_default.subtract(p1, p0, scratchCartesian12);
v13 = Cartesian3_default.subtract(p2, p0, scratchCartesian23);
v23 = Cartesian3_default.subtract(point, p0, scratchCartesian33);
dot00 = Cartesian3_default.dot(v02, v02);
dot01 = Cartesian3_default.dot(v02, v13);
dot02 = Cartesian3_default.dot(v02, v23);
dot11 = Cartesian3_default.dot(v13, v13);
dot12 = Cartesian3_default.dot(v13, v23);
}
result.y = dot11 * dot02 - dot01 * dot12;
result.z = dot00 * dot12 - dot01 * dot02;
const q = dot00 * dot11 - dot01 * dot01;
if (q === 0) {
return void 0;
}
result.y /= q;
result.z /= q;
result.x = 1 - result.y - result.z;
return result;
}
var barycentricCoordinates_default = barycentricCoordinates;
// Source/Core/BingMapsGeocoderService.js
var url = "https://dev.virtualearth.net/REST/v1/Locations";
function BingMapsGeocoderService(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
const key = options.key;
if (!defined_default(key)) {
throw new DeveloperError_default("options.key is required.");
}
this._key = key;
const queryParameters = {
key
};
if (defined_default(options.culture)) {
queryParameters.culture = options.culture;
}
this._resource = new Resource_default({
url,
queryParameters
});
}
Object.defineProperties(BingMapsGeocoderService.prototype, {
url: {
get: function() {
return url;
}
},
key: {
get: function() {
return this._key;
}
}
});
BingMapsGeocoderService.prototype.geocode = function(query) {
Check_default.typeOf.string("query", query);
const resource = this._resource.getDerivedResource({
queryParameters: {
query
}
});
return resource.fetchJsonp("jsonp").then(function(result) {
if (result.resourceSets.length === 0) {
return [];
}
const results = result.resourceSets[0].resources;
return results.map(function(resource2) {
const bbox = resource2.bbox;
const south = bbox[0];
const west = bbox[1];
const north = bbox[2];
const east = bbox[3];
return {
displayName: resource2.name,
destination: Rectangle_default.fromDegrees(west, south, east, north)
};
});
});
};
var BingMapsGeocoderService_default = BingMapsGeocoderService;
// Source/Core/BoundingRectangle.js
function BoundingRectangle(x, y, width, height) {
this.x = defaultValue_default(x, 0);
this.y = defaultValue_default(y, 0);
this.width = defaultValue_default(width, 0);
this.height = defaultValue_default(height, 0);
}
BoundingRectangle.packedLength = 4;
BoundingRectangle.pack = function(value, array, startingIndex) {
Check_default.typeOf.object("value", value);
Check_default.defined("array", array);
startingIndex = defaultValue_default(startingIndex, 0);
array[startingIndex++] = value.x;
array[startingIndex++] = value.y;
array[startingIndex++] = value.width;
array[startingIndex] = value.height;
return array;
};
BoundingRectangle.unpack = function(array, startingIndex, result) {
Check_default.defined("array", array);
startingIndex = defaultValue_default(startingIndex, 0);
if (!defined_default(result)) {
result = new BoundingRectangle();
}
result.x = array[startingIndex++];
result.y = array[startingIndex++];
result.width = array[startingIndex++];
result.height = array[startingIndex];
return result;
};
BoundingRectangle.fromPoints = function(positions, result) {
if (!defined_default(result)) {
result = new BoundingRectangle();
}
if (!defined_default(positions) || positions.length === 0) {
result.x = 0;
result.y = 0;
result.width = 0;
result.height = 0;
return result;
}
const length3 = positions.length;
let minimumX = positions[0].x;
let minimumY = positions[0].y;
let maximumX = positions[0].x;
let maximumY = positions[0].y;
for (let i = 1; i < length3; i++) {
const p = positions[i];
const x = p.x;
const y = p.y;
minimumX = Math.min(x, minimumX);
maximumX = Math.max(x, maximumX);
minimumY = Math.min(y, minimumY);
maximumY = Math.max(y, maximumY);
}
result.x = minimumX;
result.y = minimumY;
result.width = maximumX - minimumX;
result.height = maximumY - minimumY;
return result;
};
var defaultProjection2 = new GeographicProjection_default();
var fromRectangleLowerLeft = new Cartographic_default();
var fromRectangleUpperRight = new Cartographic_default();
BoundingRectangle.fromRectangle = function(rectangle, projection, result) {
if (!defined_default(result)) {
result = new BoundingRectangle();
}
if (!defined_default(rectangle)) {
result.x = 0;
result.y = 0;
result.width = 0;
result.height = 0;
return result;
}
projection = defaultValue_default(projection, defaultProjection2);
const lowerLeft = projection.project(
Rectangle_default.southwest(rectangle, fromRectangleLowerLeft)
);
const upperRight = projection.project(
Rectangle_default.northeast(rectangle, fromRectangleUpperRight)
);
Cartesian2_default.subtract(upperRight, lowerLeft, upperRight);
result.x = lowerLeft.x;
result.y = lowerLeft.y;
result.width = upperRight.x;
result.height = upperRight.y;
return result;
};
BoundingRectangle.clone = function(rectangle, result) {
if (!defined_default(rectangle)) {
return void 0;
}
if (!defined_default(result)) {
return new BoundingRectangle(
rectangle.x,
rectangle.y,
rectangle.width,
rectangle.height
);
}
result.x = rectangle.x;
result.y = rectangle.y;
result.width = rectangle.width;
result.height = rectangle.height;
return result;
};
BoundingRectangle.union = function(left, right, result) {
Check_default.typeOf.object("left", left);
Check_default.typeOf.object("right", right);
if (!defined_default(result)) {
result = new BoundingRectangle();
}
const lowerLeftX = Math.min(left.x, right.x);
const lowerLeftY = Math.min(left.y, right.y);
const upperRightX = Math.max(left.x + left.width, right.x + right.width);
const upperRightY = Math.max(left.y + left.height, right.y + right.height);
result.x = lowerLeftX;
result.y = lowerLeftY;
result.width = upperRightX - lowerLeftX;
result.height = upperRightY - lowerLeftY;
return result;
};
BoundingRectangle.expand = function(rectangle, point, result) {
Check_default.typeOf.object("rectangle", rectangle);
Check_default.typeOf.object("point", point);
result = BoundingRectangle.clone(rectangle, result);
const width = point.x - result.x;
const height = point.y - result.y;
if (width > result.width) {
result.width = width;
} else if (width < 0) {
result.width -= width;
result.x = point.x;
}
if (height > result.height) {
result.height = height;
} else if (height < 0) {
result.height -= height;
result.y = point.y;
}
return result;
};
BoundingRectangle.intersect = function(left, right) {
Check_default.typeOf.object("left", left);
Check_default.typeOf.object("right", right);
const leftX = left.x;
const leftY = left.y;
const rightX = right.x;
const rightY = right.y;
if (!(leftX > rightX + right.width || leftX + left.width < rightX || leftY + left.height < rightY || leftY > rightY + right.height)) {
return Intersect_default.INTERSECTING;
}
return Intersect_default.OUTSIDE;
};
BoundingRectangle.equals = function(left, right) {
return left === right || defined_default(left) && defined_default(right) && left.x === right.x && left.y === right.y && left.width === right.width && left.height === right.height;
};
BoundingRectangle.prototype.clone = function(result) {
return BoundingRectangle.clone(this, result);
};
BoundingRectangle.prototype.intersect = function(right) {
return BoundingRectangle.intersect(this, right);
};
BoundingRectangle.prototype.equals = function(right) {
return BoundingRectangle.equals(this, right);
};
var BoundingRectangle_default = BoundingRectangle;
// Source/Core/GeometryType.js
var GeometryType = {
NONE: 0,
TRIANGLES: 1,
LINES: 2,
POLYLINES: 3
};
var GeometryType_default = Object.freeze(GeometryType);
// Source/Core/PrimitiveType.js
var PrimitiveType = {
POINTS: WebGLConstants_default.POINTS,
LINES: WebGLConstants_default.LINES,
LINE_LOOP: WebGLConstants_default.LINE_LOOP,
LINE_STRIP: WebGLConstants_default.LINE_STRIP,
TRIANGLES: WebGLConstants_default.TRIANGLES,
TRIANGLE_STRIP: WebGLConstants_default.TRIANGLE_STRIP,
TRIANGLE_FAN: WebGLConstants_default.TRIANGLE_FAN
};
PrimitiveType.isLines = function(primitiveType) {
return primitiveType === PrimitiveType.LINES || primitiveType === PrimitiveType.LINE_LOOP || primitiveType === PrimitiveType.LINE_STRIP;
};
PrimitiveType.isTriangles = function(primitiveType) {
return primitiveType === PrimitiveType.TRIANGLES || primitiveType === PrimitiveType.TRIANGLE_STRIP || primitiveType === PrimitiveType.TRIANGLE_FAN;
};
PrimitiveType.validate = function(primitiveType) {
return primitiveType === PrimitiveType.POINTS || primitiveType === PrimitiveType.LINES || primitiveType === PrimitiveType.LINE_LOOP || primitiveType === PrimitiveType.LINE_STRIP || primitiveType === PrimitiveType.TRIANGLES || primitiveType === PrimitiveType.TRIANGLE_STRIP || primitiveType === PrimitiveType.TRIANGLE_FAN;
};
var PrimitiveType_default = Object.freeze(PrimitiveType);
// Source/Core/Geometry.js
function Geometry(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
Check_default.typeOf.object("options.attributes", options.attributes);
this.attributes = options.attributes;
this.indices = options.indices;
this.primitiveType = defaultValue_default(
options.primitiveType,
PrimitiveType_default.TRIANGLES
);
this.boundingSphere = options.boundingSphere;
this.geometryType = defaultValue_default(options.geometryType, GeometryType_default.NONE);
this.boundingSphereCV = options.boundingSphereCV;
this.offsetAttribute = options.offsetAttribute;
}
Geometry.computeNumberOfVertices = function(geometry) {
Check_default.typeOf.object("geometry", geometry);
let numberOfVertices = -1;
for (const property in geometry.attributes) {
if (geometry.attributes.hasOwnProperty(property) && defined_default(geometry.attributes[property]) && defined_default(geometry.attributes[property].values)) {
const attribute = geometry.attributes[property];
const num = attribute.values.length / attribute.componentsPerAttribute;
if (numberOfVertices !== num && numberOfVertices !== -1) {
throw new DeveloperError_default(
"All attribute lists must have the same number of attributes."
);
}
numberOfVertices = num;
}
}
return numberOfVertices;
};
var rectangleCenterScratch = new Cartographic_default();
var enuCenterScratch = new Cartesian3_default();
var fixedFrameToEnuScratch = new Matrix4_default();
var boundingRectanglePointsCartographicScratch = [
new Cartographic_default(),
new Cartographic_default(),
new Cartographic_default()
];
var boundingRectanglePointsEnuScratch = [
new Cartesian2_default(),
new Cartesian2_default(),
new Cartesian2_default()
];
var points2DScratch = [new Cartesian2_default(), new Cartesian2_default(), new Cartesian2_default()];
var pointEnuScratch = new Cartesian3_default();
var enuRotationScratch = new Quaternion_default();
var enuRotationMatrixScratch = new Matrix4_default();
var rotation2DScratch = new Matrix2_default();
Geometry._textureCoordinateRotationPoints = function(positions, stRotation, ellipsoid, boundingRectangle) {
let i;
const rectangleCenter = Rectangle_default.center(
boundingRectangle,
rectangleCenterScratch
);
const enuCenter = Cartographic_default.toCartesian(
rectangleCenter,
ellipsoid,
enuCenterScratch
);
const enuToFixedFrame = Transforms_default.eastNorthUpToFixedFrame(
enuCenter,
ellipsoid,
fixedFrameToEnuScratch
);
const fixedFrameToEnu = Matrix4_default.inverse(
enuToFixedFrame,
fixedFrameToEnuScratch
);
const boundingPointsEnu = boundingRectanglePointsEnuScratch;
const boundingPointsCarto = boundingRectanglePointsCartographicScratch;
boundingPointsCarto[0].longitude = boundingRectangle.west;
boundingPointsCarto[0].latitude = boundingRectangle.south;
boundingPointsCarto[1].longitude = boundingRectangle.west;
boundingPointsCarto[1].latitude = boundingRectangle.north;
boundingPointsCarto[2].longitude = boundingRectangle.east;
boundingPointsCarto[2].latitude = boundingRectangle.south;
let posEnu = pointEnuScratch;
for (i = 0; i < 3; i++) {
Cartographic_default.toCartesian(boundingPointsCarto[i], ellipsoid, posEnu);
posEnu = Matrix4_default.multiplyByPointAsVector(fixedFrameToEnu, posEnu, posEnu);
boundingPointsEnu[i].x = posEnu.x;
boundingPointsEnu[i].y = posEnu.y;
}
const rotation = Quaternion_default.fromAxisAngle(
Cartesian3_default.UNIT_Z,
-stRotation,
enuRotationScratch
);
const textureMatrix = Matrix3_default.fromQuaternion(
rotation,
enuRotationMatrixScratch
);
const positionsLength = positions.length;
let enuMinX = Number.POSITIVE_INFINITY;
let enuMinY = Number.POSITIVE_INFINITY;
let enuMaxX = Number.NEGATIVE_INFINITY;
let enuMaxY = Number.NEGATIVE_INFINITY;
for (i = 0; i < positionsLength; i++) {
posEnu = Matrix4_default.multiplyByPointAsVector(
fixedFrameToEnu,
positions[i],
posEnu
);
posEnu = Matrix3_default.multiplyByVector(textureMatrix, posEnu, posEnu);
enuMinX = Math.min(enuMinX, posEnu.x);
enuMinY = Math.min(enuMinY, posEnu.y);
enuMaxX = Math.max(enuMaxX, posEnu.x);
enuMaxY = Math.max(enuMaxY, posEnu.y);
}
const toDesiredInComputed = Matrix2_default.fromRotation(
stRotation,
rotation2DScratch
);
const points2D = points2DScratch;
points2D[0].x = enuMinX;
points2D[0].y = enuMinY;
points2D[1].x = enuMinX;
points2D[1].y = enuMaxY;
points2D[2].x = enuMaxX;
points2D[2].y = enuMinY;
const boundingEnuMin = boundingPointsEnu[0];
const boundingPointsWidth = boundingPointsEnu[2].x - boundingEnuMin.x;
const boundingPointsHeight = boundingPointsEnu[1].y - boundingEnuMin.y;
for (i = 0; i < 3; i++) {
const point2D = points2D[i];
Matrix2_default.multiplyByVector(toDesiredInComputed, point2D, point2D);
point2D.x = (point2D.x - boundingEnuMin.x) / boundingPointsWidth;
point2D.y = (point2D.y - boundingEnuMin.y) / boundingPointsHeight;
}
const minXYCorner = points2D[0];
const maxYCorner = points2D[1];
const maxXCorner = points2D[2];
const result = new Array(6);
Cartesian2_default.pack(minXYCorner, result);
Cartesian2_default.pack(maxYCorner, result, 2);
Cartesian2_default.pack(maxXCorner, result, 4);
return result;
};
var Geometry_default = Geometry;
// Source/Core/GeometryAttribute.js
function GeometryAttribute(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
if (!defined_default(options.componentDatatype)) {
throw new DeveloperError_default("options.componentDatatype is required.");
}
if (!defined_default(options.componentsPerAttribute)) {
throw new DeveloperError_default("options.componentsPerAttribute is required.");
}
if (options.componentsPerAttribute < 1 || options.componentsPerAttribute > 4) {
throw new DeveloperError_default(
"options.componentsPerAttribute must be between 1 and 4."
);
}
if (!defined_default(options.values)) {
throw new DeveloperError_default("options.values is required.");
}
this.componentDatatype = options.componentDatatype;
this.componentsPerAttribute = options.componentsPerAttribute;
this.normalize = defaultValue_default(options.normalize, false);
this.values = options.values;
}
var GeometryAttribute_default = GeometryAttribute;
// Source/Core/GeometryAttributes.js
function GeometryAttributes(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
this.position = options.position;
this.normal = options.normal;
this.st = options.st;
this.bitangent = options.bitangent;
this.tangent = options.tangent;
this.color = options.color;
}
var GeometryAttributes_default = GeometryAttributes;
// Source/Core/GeometryOffsetAttribute.js
var GeometryOffsetAttribute = {
NONE: 0,
TOP: 1,
ALL: 2
};
var GeometryOffsetAttribute_default = Object.freeze(GeometryOffsetAttribute);
// Source/Core/VertexFormat.js
function VertexFormat(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
this.position = defaultValue_default(options.position, false);
this.normal = defaultValue_default(options.normal, false);
this.st = defaultValue_default(options.st, false);
this.bitangent = defaultValue_default(options.bitangent, false);
this.tangent = defaultValue_default(options.tangent, false);
this.color = defaultValue_default(options.color, false);
}
VertexFormat.POSITION_ONLY = Object.freeze(
new VertexFormat({
position: true
})
);
VertexFormat.POSITION_AND_NORMAL = Object.freeze(
new VertexFormat({
position: true,
normal: true
})
);
VertexFormat.POSITION_NORMAL_AND_ST = Object.freeze(
new VertexFormat({
position: true,
normal: true,
st: true
})
);
VertexFormat.POSITION_AND_ST = Object.freeze(
new VertexFormat({
position: true,
st: true
})
);
VertexFormat.POSITION_AND_COLOR = Object.freeze(
new VertexFormat({
position: true,
color: true
})
);
VertexFormat.ALL = Object.freeze(
new VertexFormat({
position: true,
normal: true,
st: true,
tangent: true,
bitangent: true
})
);
VertexFormat.DEFAULT = VertexFormat.POSITION_NORMAL_AND_ST;
VertexFormat.packedLength = 6;
VertexFormat.pack = function(value, array, startingIndex) {
if (!defined_default(value)) {
throw new DeveloperError_default("value is required");
}
if (!defined_default(array)) {
throw new DeveloperError_default("array is required");
}
startingIndex = defaultValue_default(startingIndex, 0);
array[startingIndex++] = value.position ? 1 : 0;
array[startingIndex++] = value.normal ? 1 : 0;
array[startingIndex++] = value.st ? 1 : 0;
array[startingIndex++] = value.tangent ? 1 : 0;
array[startingIndex++] = value.bitangent ? 1 : 0;
array[startingIndex] = value.color ? 1 : 0;
return array;
};
VertexFormat.unpack = function(array, startingIndex, result) {
if (!defined_default(array)) {
throw new DeveloperError_default("array is required");
}
startingIndex = defaultValue_default(startingIndex, 0);
if (!defined_default(result)) {
result = new VertexFormat();
}
result.position = array[startingIndex++] === 1;
result.normal = array[startingIndex++] === 1;
result.st = array[startingIndex++] === 1;
result.tangent = array[startingIndex++] === 1;
result.bitangent = array[startingIndex++] === 1;
result.color = array[startingIndex] === 1;
return result;
};
VertexFormat.clone = function(vertexFormat, result) {
if (!defined_default(vertexFormat)) {
return void 0;
}
if (!defined_default(result)) {
result = new VertexFormat();
}
result.position = vertexFormat.position;
result.normal = vertexFormat.normal;
result.st = vertexFormat.st;
result.tangent = vertexFormat.tangent;
result.bitangent = vertexFormat.bitangent;
result.color = vertexFormat.color;
return result;
};
var VertexFormat_default = VertexFormat;
// Source/Core/BoxGeometry.js
var diffScratch = new Cartesian3_default();
function BoxGeometry(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
const min3 = options.minimum;
const max3 = options.maximum;
Check_default.typeOf.object("min", min3);
Check_default.typeOf.object("max", max3);
if (defined_default(options.offsetAttribute) && options.offsetAttribute === GeometryOffsetAttribute_default.TOP) {
throw new DeveloperError_default(
"GeometryOffsetAttribute.TOP is not a supported options.offsetAttribute for this geometry."
);
}
const vertexFormat = defaultValue_default(options.vertexFormat, VertexFormat_default.DEFAULT);
this._minimum = Cartesian3_default.clone(min3);
this._maximum = Cartesian3_default.clone(max3);
this._vertexFormat = vertexFormat;
this._offsetAttribute = options.offsetAttribute;
this._workerName = "createBoxGeometry";
}
BoxGeometry.fromDimensions = function(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
const dimensions = options.dimensions;
Check_default.typeOf.object("dimensions", dimensions);
Check_default.typeOf.number.greaterThanOrEquals("dimensions.x", dimensions.x, 0);
Check_default.typeOf.number.greaterThanOrEquals("dimensions.y", dimensions.y, 0);
Check_default.typeOf.number.greaterThanOrEquals("dimensions.z", dimensions.z, 0);
const corner = Cartesian3_default.multiplyByScalar(dimensions, 0.5, new Cartesian3_default());
return new BoxGeometry({
minimum: Cartesian3_default.negate(corner, new Cartesian3_default()),
maximum: corner,
vertexFormat: options.vertexFormat,
offsetAttribute: options.offsetAttribute
});
};
BoxGeometry.fromAxisAlignedBoundingBox = function(boundingBox) {
Check_default.typeOf.object("boundingBox", boundingBox);
return new BoxGeometry({
minimum: boundingBox.minimum,
maximum: boundingBox.maximum
});
};
BoxGeometry.packedLength = 2 * Cartesian3_default.packedLength + VertexFormat_default.packedLength + 1;
BoxGeometry.pack = function(value, array, startingIndex) {
Check_default.typeOf.object("value", value);
Check_default.defined("array", array);
startingIndex = defaultValue_default(startingIndex, 0);
Cartesian3_default.pack(value._minimum, array, startingIndex);
Cartesian3_default.pack(
value._maximum,
array,
startingIndex + Cartesian3_default.packedLength
);
VertexFormat_default.pack(
value._vertexFormat,
array,
startingIndex + 2 * Cartesian3_default.packedLength
);
array[startingIndex + 2 * Cartesian3_default.packedLength + VertexFormat_default.packedLength] = defaultValue_default(value._offsetAttribute, -1);
return array;
};
var scratchMin = new Cartesian3_default();
var scratchMax = new Cartesian3_default();
var scratchVertexFormat = new VertexFormat_default();
var scratchOptions = {
minimum: scratchMin,
maximum: scratchMax,
vertexFormat: scratchVertexFormat,
offsetAttribute: void 0
};
BoxGeometry.unpack = function(array, startingIndex, result) {
Check_default.defined("array", array);
startingIndex = defaultValue_default(startingIndex, 0);
const min3 = Cartesian3_default.unpack(array, startingIndex, scratchMin);
const max3 = Cartesian3_default.unpack(
array,
startingIndex + Cartesian3_default.packedLength,
scratchMax
);
const vertexFormat = VertexFormat_default.unpack(
array,
startingIndex + 2 * Cartesian3_default.packedLength,
scratchVertexFormat
);
const offsetAttribute = array[startingIndex + 2 * Cartesian3_default.packedLength + VertexFormat_default.packedLength];
if (!defined_default(result)) {
scratchOptions.offsetAttribute = offsetAttribute === -1 ? void 0 : offsetAttribute;
return new BoxGeometry(scratchOptions);
}
result._minimum = Cartesian3_default.clone(min3, result._minimum);
result._maximum = Cartesian3_default.clone(max3, result._maximum);
result._vertexFormat = VertexFormat_default.clone(vertexFormat, result._vertexFormat);
result._offsetAttribute = offsetAttribute === -1 ? void 0 : offsetAttribute;
return result;
};
BoxGeometry.createGeometry = function(boxGeometry) {
const min3 = boxGeometry._minimum;
const max3 = boxGeometry._maximum;
const vertexFormat = boxGeometry._vertexFormat;
if (Cartesian3_default.equals(min3, max3)) {
return;
}
const attributes = new GeometryAttributes_default();
let indices2;
let positions;
if (vertexFormat.position && (vertexFormat.st || vertexFormat.normal || vertexFormat.tangent || vertexFormat.bitangent)) {
if (vertexFormat.position) {
positions = new Float64Array(6 * 4 * 3);
positions[0] = min3.x;
positions[1] = min3.y;
positions[2] = max3.z;
positions[3] = max3.x;
positions[4] = min3.y;
positions[5] = max3.z;
positions[6] = max3.x;
positions[7] = max3.y;
positions[8] = max3.z;
positions[9] = min3.x;
positions[10] = max3.y;
positions[11] = max3.z;
positions[12] = min3.x;
positions[13] = min3.y;
positions[14] = min3.z;
positions[15] = max3.x;
positions[16] = min3.y;
positions[17] = min3.z;
positions[18] = max3.x;
positions[19] = max3.y;
positions[20] = min3.z;
positions[21] = min3.x;
positions[22] = max3.y;
positions[23] = min3.z;
positions[24] = max3.x;
positions[25] = min3.y;
positions[26] = min3.z;
positions[27] = max3.x;
positions[28] = max3.y;
positions[29] = min3.z;
positions[30] = max3.x;
positions[31] = max3.y;
positions[32] = max3.z;
positions[33] = max3.x;
positions[34] = min3.y;
positions[35] = max3.z;
positions[36] = min3.x;
positions[37] = min3.y;
positions[38] = min3.z;
positions[39] = min3.x;
positions[40] = max3.y;
positions[41] = min3.z;
positions[42] = min3.x;
positions[43] = max3.y;
positions[44] = max3.z;
positions[45] = min3.x;
positions[46] = min3.y;
positions[47] = max3.z;
positions[48] = min3.x;
positions[49] = max3.y;
positions[50] = min3.z;
positions[51] = max3.x;
positions[52] = max3.y;
positions[53] = min3.z;
positions[54] = max3.x;
positions[55] = max3.y;
positions[56] = max3.z;
positions[57] = min3.x;
positions[58] = max3.y;
positions[59] = max3.z;
positions[60] = min3.x;
positions[61] = min3.y;
positions[62] = min3.z;
positions[63] = max3.x;
positions[64] = min3.y;
positions[65] = min3.z;
positions[66] = max3.x;
positions[67] = min3.y;
positions[68] = max3.z;
positions[69] = min3.x;
positions[70] = min3.y;
positions[71] = max3.z;
attributes.position = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.DOUBLE,
componentsPerAttribute: 3,
values: positions
});
}
if (vertexFormat.normal) {
const normals = new Float32Array(6 * 4 * 3);
normals[0] = 0;
normals[1] = 0;
normals[2] = 1;
normals[3] = 0;
normals[4] = 0;
normals[5] = 1;
normals[6] = 0;
normals[7] = 0;
normals[8] = 1;
normals[9] = 0;
normals[10] = 0;
normals[11] = 1;
normals[12] = 0;
normals[13] = 0;
normals[14] = -1;
normals[15] = 0;
normals[16] = 0;
normals[17] = -1;
normals[18] = 0;
normals[19] = 0;
normals[20] = -1;
normals[21] = 0;
normals[22] = 0;
normals[23] = -1;
normals[24] = 1;
normals[25] = 0;
normals[26] = 0;
normals[27] = 1;
normals[28] = 0;
normals[29] = 0;
normals[30] = 1;
normals[31] = 0;
normals[32] = 0;
normals[33] = 1;
normals[34] = 0;
normals[35] = 0;
normals[36] = -1;
normals[37] = 0;
normals[38] = 0;
normals[39] = -1;
normals[40] = 0;
normals[41] = 0;
normals[42] = -1;
normals[43] = 0;
normals[44] = 0;
normals[45] = -1;
normals[46] = 0;
normals[47] = 0;
normals[48] = 0;
normals[49] = 1;
normals[50] = 0;
normals[51] = 0;
normals[52] = 1;
normals[53] = 0;
normals[54] = 0;
normals[55] = 1;
normals[56] = 0;
normals[57] = 0;
normals[58] = 1;
normals[59] = 0;
normals[60] = 0;
normals[61] = -1;
normals[62] = 0;
normals[63] = 0;
normals[64] = -1;
normals[65] = 0;
normals[66] = 0;
normals[67] = -1;
normals[68] = 0;
normals[69] = 0;
normals[70] = -1;
normals[71] = 0;
attributes.normal = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.FLOAT,
componentsPerAttribute: 3,
values: normals
});
}
if (vertexFormat.st) {
const texCoords = new Float32Array(6 * 4 * 2);
texCoords[0] = 0;
texCoords[1] = 0;
texCoords[2] = 1;
texCoords[3] = 0;
texCoords[4] = 1;
texCoords[5] = 1;
texCoords[6] = 0;
texCoords[7] = 1;
texCoords[8] = 1;
texCoords[9] = 0;
texCoords[10] = 0;
texCoords[11] = 0;
texCoords[12] = 0;
texCoords[13] = 1;
texCoords[14] = 1;
texCoords[15] = 1;
texCoords[16] = 0;
texCoords[17] = 0;
texCoords[18] = 1;
texCoords[19] = 0;
texCoords[20] = 1;
texCoords[21] = 1;
texCoords[22] = 0;
texCoords[23] = 1;
texCoords[24] = 1;
texCoords[25] = 0;
texCoords[26] = 0;
texCoords[27] = 0;
texCoords[28] = 0;
texCoords[29] = 1;
texCoords[30] = 1;
texCoords[31] = 1;
texCoords[32] = 1;
texCoords[33] = 0;
texCoords[34] = 0;
texCoords[35] = 0;
texCoords[36] = 0;
texCoords[37] = 1;
texCoords[38] = 1;
texCoords[39] = 1;
texCoords[40] = 0;
texCoords[41] = 0;
texCoords[42] = 1;
texCoords[43] = 0;
texCoords[44] = 1;
texCoords[45] = 1;
texCoords[46] = 0;
texCoords[47] = 1;
attributes.st = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.FLOAT,
componentsPerAttribute: 2,
values: texCoords
});
}
if (vertexFormat.tangent) {
const tangents = new Float32Array(6 * 4 * 3);
tangents[0] = 1;
tangents[1] = 0;
tangents[2] = 0;
tangents[3] = 1;
tangents[4] = 0;
tangents[5] = 0;
tangents[6] = 1;
tangents[7] = 0;
tangents[8] = 0;
tangents[9] = 1;
tangents[10] = 0;
tangents[11] = 0;
tangents[12] = -1;
tangents[13] = 0;
tangents[14] = 0;
tangents[15] = -1;
tangents[16] = 0;
tangents[17] = 0;
tangents[18] = -1;
tangents[19] = 0;
tangents[20] = 0;
tangents[21] = -1;
tangents[22] = 0;
tangents[23] = 0;
tangents[24] = 0;
tangents[25] = 1;
tangents[26] = 0;
tangents[27] = 0;
tangents[28] = 1;
tangents[29] = 0;
tangents[30] = 0;
tangents[31] = 1;
tangents[32] = 0;
tangents[33] = 0;
tangents[34] = 1;
tangents[35] = 0;
tangents[36] = 0;
tangents[37] = -1;
tangents[38] = 0;
tangents[39] = 0;
tangents[40] = -1;
tangents[41] = 0;
tangents[42] = 0;
tangents[43] = -1;
tangents[44] = 0;
tangents[45] = 0;
tangents[46] = -1;
tangents[47] = 0;
tangents[48] = -1;
tangents[49] = 0;
tangents[50] = 0;
tangents[51] = -1;
tangents[52] = 0;
tangents[53] = 0;
tangents[54] = -1;
tangents[55] = 0;
tangents[56] = 0;
tangents[57] = -1;
tangents[58] = 0;
tangents[59] = 0;
tangents[60] = 1;
tangents[61] = 0;
tangents[62] = 0;
tangents[63] = 1;
tangents[64] = 0;
tangents[65] = 0;
tangents[66] = 1;
tangents[67] = 0;
tangents[68] = 0;
tangents[69] = 1;
tangents[70] = 0;
tangents[71] = 0;
attributes.tangent = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.FLOAT,
componentsPerAttribute: 3,
values: tangents
});
}
if (vertexFormat.bitangent) {
const bitangents = new Float32Array(6 * 4 * 3);
bitangents[0] = 0;
bitangents[1] = 1;
bitangents[2] = 0;
bitangents[3] = 0;
bitangents[4] = 1;
bitangents[5] = 0;
bitangents[6] = 0;
bitangents[7] = 1;
bitangents[8] = 0;
bitangents[9] = 0;
bitangents[10] = 1;
bitangents[11] = 0;
bitangents[12] = 0;
bitangents[13] = 1;
bitangents[14] = 0;
bitangents[15] = 0;
bitangents[16] = 1;
bitangents[17] = 0;
bitangents[18] = 0;
bitangents[19] = 1;
bitangents[20] = 0;
bitangents[21] = 0;
bitangents[22] = 1;
bitangents[23] = 0;
bitangents[24] = 0;
bitangents[25] = 0;
bitangents[26] = 1;
bitangents[27] = 0;
bitangents[28] = 0;
bitangents[29] = 1;
bitangents[30] = 0;
bitangents[31] = 0;
bitangents[32] = 1;
bitangents[33] = 0;
bitangents[34] = 0;
bitangents[35] = 1;
bitangents[36] = 0;
bitangents[37] = 0;
bitangents[38] = 1;
bitangents[39] = 0;
bitangents[40] = 0;
bitangents[41] = 1;
bitangents[42] = 0;
bitangents[43] = 0;
bitangents[44] = 1;
bitangents[45] = 0;
bitangents[46] = 0;
bitangents[47] = 1;
bitangents[48] = 0;
bitangents[49] = 0;
bitangents[50] = 1;
bitangents[51] = 0;
bitangents[52] = 0;
bitangents[53] = 1;
bitangents[54] = 0;
bitangents[55] = 0;
bitangents[56] = 1;
bitangents[57] = 0;
bitangents[58] = 0;
bitangents[59] = 1;
bitangents[60] = 0;
bitangents[61] = 0;
bitangents[62] = 1;
bitangents[63] = 0;
bitangents[64] = 0;
bitangents[65] = 1;
bitangents[66] = 0;
bitangents[67] = 0;
bitangents[68] = 1;
bitangents[69] = 0;
bitangents[70] = 0;
bitangents[71] = 1;
attributes.bitangent = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.FLOAT,
componentsPerAttribute: 3,
values: bitangents
});
}
indices2 = new Uint16Array(6 * 2 * 3);
indices2[0] = 0;
indices2[1] = 1;
indices2[2] = 2;
indices2[3] = 0;
indices2[4] = 2;
indices2[5] = 3;
indices2[6] = 4 + 2;
indices2[7] = 4 + 1;
indices2[8] = 4 + 0;
indices2[9] = 4 + 3;
indices2[10] = 4 + 2;
indices2[11] = 4 + 0;
indices2[12] = 8 + 0;
indices2[13] = 8 + 1;
indices2[14] = 8 + 2;
indices2[15] = 8 + 0;
indices2[16] = 8 + 2;
indices2[17] = 8 + 3;
indices2[18] = 12 + 2;
indices2[19] = 12 + 1;
indices2[20] = 12 + 0;
indices2[21] = 12 + 3;
indices2[22] = 12 + 2;
indices2[23] = 12 + 0;
indices2[24] = 16 + 2;
indices2[25] = 16 + 1;
indices2[26] = 16 + 0;
indices2[27] = 16 + 3;
indices2[28] = 16 + 2;
indices2[29] = 16 + 0;
indices2[30] = 20 + 0;
indices2[31] = 20 + 1;
indices2[32] = 20 + 2;
indices2[33] = 20 + 0;
indices2[34] = 20 + 2;
indices2[35] = 20 + 3;
} else {
positions = new Float64Array(8 * 3);
positions[0] = min3.x;
positions[1] = min3.y;
positions[2] = min3.z;
positions[3] = max3.x;
positions[4] = min3.y;
positions[5] = min3.z;
positions[6] = max3.x;
positions[7] = max3.y;
positions[8] = min3.z;
positions[9] = min3.x;
positions[10] = max3.y;
positions[11] = min3.z;
positions[12] = min3.x;
positions[13] = min3.y;
positions[14] = max3.z;
positions[15] = max3.x;
positions[16] = min3.y;
positions[17] = max3.z;
positions[18] = max3.x;
positions[19] = max3.y;
positions[20] = max3.z;
positions[21] = min3.x;
positions[22] = max3.y;
positions[23] = max3.z;
attributes.position = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.DOUBLE,
componentsPerAttribute: 3,
values: positions
});
indices2 = new Uint16Array(6 * 2 * 3);
indices2[0] = 4;
indices2[1] = 5;
indices2[2] = 6;
indices2[3] = 4;
indices2[4] = 6;
indices2[5] = 7;
indices2[6] = 1;
indices2[7] = 0;
indices2[8] = 3;
indices2[9] = 1;
indices2[10] = 3;
indices2[11] = 2;
indices2[12] = 1;
indices2[13] = 6;
indices2[14] = 5;
indices2[15] = 1;
indices2[16] = 2;
indices2[17] = 6;
indices2[18] = 2;
indices2[19] = 3;
indices2[20] = 7;
indices2[21] = 2;
indices2[22] = 7;
indices2[23] = 6;
indices2[24] = 3;
indices2[25] = 0;
indices2[26] = 4;
indices2[27] = 3;
indices2[28] = 4;
indices2[29] = 7;
indices2[30] = 0;
indices2[31] = 1;
indices2[32] = 5;
indices2[33] = 0;
indices2[34] = 5;
indices2[35] = 4;
}
const diff = Cartesian3_default.subtract(max3, min3, diffScratch);
const radius = Cartesian3_default.magnitude(diff) * 0.5;
if (defined_default(boxGeometry._offsetAttribute)) {
const length3 = positions.length;
const offsetValue = boxGeometry._offsetAttribute === GeometryOffsetAttribute_default.NONE ? 0 : 1;
const applyOffset = new Uint8Array(length3 / 3).fill(offsetValue);
attributes.applyOffset = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.UNSIGNED_BYTE,
componentsPerAttribute: 1,
values: applyOffset
});
}
return new Geometry_default({
attributes,
indices: indices2,
primitiveType: PrimitiveType_default.TRIANGLES,
boundingSphere: new BoundingSphere_default(Cartesian3_default.ZERO, radius),
offsetAttribute: boxGeometry._offsetAttribute
});
};
var unitBoxGeometry;
BoxGeometry.getUnitBox = function() {
if (!defined_default(unitBoxGeometry)) {
unitBoxGeometry = BoxGeometry.createGeometry(
BoxGeometry.fromDimensions({
dimensions: new Cartesian3_default(1, 1, 1),
vertexFormat: VertexFormat_default.POSITION_ONLY
})
);
}
return unitBoxGeometry;
};
var BoxGeometry_default = BoxGeometry;
// Source/Core/BoxOutlineGeometry.js
var diffScratch2 = new Cartesian3_default();
function BoxOutlineGeometry(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
const min3 = options.minimum;
const max3 = options.maximum;
Check_default.typeOf.object("min", min3);
Check_default.typeOf.object("max", max3);
if (defined_default(options.offsetAttribute) && options.offsetAttribute === GeometryOffsetAttribute_default.TOP) {
throw new DeveloperError_default(
"GeometryOffsetAttribute.TOP is not a supported options.offsetAttribute for this geometry."
);
}
this._min = Cartesian3_default.clone(min3);
this._max = Cartesian3_default.clone(max3);
this._offsetAttribute = options.offsetAttribute;
this._workerName = "createBoxOutlineGeometry";
}
BoxOutlineGeometry.fromDimensions = function(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
const dimensions = options.dimensions;
Check_default.typeOf.object("dimensions", dimensions);
Check_default.typeOf.number.greaterThanOrEquals("dimensions.x", dimensions.x, 0);
Check_default.typeOf.number.greaterThanOrEquals("dimensions.y", dimensions.y, 0);
Check_default.typeOf.number.greaterThanOrEquals("dimensions.z", dimensions.z, 0);
const corner = Cartesian3_default.multiplyByScalar(dimensions, 0.5, new Cartesian3_default());
return new BoxOutlineGeometry({
minimum: Cartesian3_default.negate(corner, new Cartesian3_default()),
maximum: corner,
offsetAttribute: options.offsetAttribute
});
};
BoxOutlineGeometry.fromAxisAlignedBoundingBox = function(boundingBox) {
Check_default.typeOf.object("boundindBox", boundingBox);
return new BoxOutlineGeometry({
minimum: boundingBox.minimum,
maximum: boundingBox.maximum
});
};
BoxOutlineGeometry.packedLength = 2 * Cartesian3_default.packedLength + 1;
BoxOutlineGeometry.pack = function(value, array, startingIndex) {
Check_default.typeOf.object("value", value);
Check_default.defined("array", array);
startingIndex = defaultValue_default(startingIndex, 0);
Cartesian3_default.pack(value._min, array, startingIndex);
Cartesian3_default.pack(value._max, array, startingIndex + Cartesian3_default.packedLength);
array[startingIndex + Cartesian3_default.packedLength * 2] = defaultValue_default(
value._offsetAttribute,
-1
);
return array;
};
var scratchMin2 = new Cartesian3_default();
var scratchMax2 = new Cartesian3_default();
var scratchOptions2 = {
minimum: scratchMin2,
maximum: scratchMax2,
offsetAttribute: void 0
};
BoxOutlineGeometry.unpack = function(array, startingIndex, result) {
Check_default.defined("array", array);
startingIndex = defaultValue_default(startingIndex, 0);
const min3 = Cartesian3_default.unpack(array, startingIndex, scratchMin2);
const max3 = Cartesian3_default.unpack(
array,
startingIndex + Cartesian3_default.packedLength,
scratchMax2
);
const offsetAttribute = array[startingIndex + Cartesian3_default.packedLength * 2];
if (!defined_default(result)) {
scratchOptions2.offsetAttribute = offsetAttribute === -1 ? void 0 : offsetAttribute;
return new BoxOutlineGeometry(scratchOptions2);
}
result._min = Cartesian3_default.clone(min3, result._min);
result._max = Cartesian3_default.clone(max3, result._max);
result._offsetAttribute = offsetAttribute === -1 ? void 0 : offsetAttribute;
return result;
};
BoxOutlineGeometry.createGeometry = function(boxGeometry) {
const min3 = boxGeometry._min;
const max3 = boxGeometry._max;
if (Cartesian3_default.equals(min3, max3)) {
return;
}
const attributes = new GeometryAttributes_default();
const indices2 = new Uint16Array(12 * 2);
const positions = new Float64Array(8 * 3);
positions[0] = min3.x;
positions[1] = min3.y;
positions[2] = min3.z;
positions[3] = max3.x;
positions[4] = min3.y;
positions[5] = min3.z;
positions[6] = max3.x;
positions[7] = max3.y;
positions[8] = min3.z;
positions[9] = min3.x;
positions[10] = max3.y;
positions[11] = min3.z;
positions[12] = min3.x;
positions[13] = min3.y;
positions[14] = max3.z;
positions[15] = max3.x;
positions[16] = min3.y;
positions[17] = max3.z;
positions[18] = max3.x;
positions[19] = max3.y;
positions[20] = max3.z;
positions[21] = min3.x;
positions[22] = max3.y;
positions[23] = max3.z;
attributes.position = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.DOUBLE,
componentsPerAttribute: 3,
values: positions
});
indices2[0] = 4;
indices2[1] = 5;
indices2[2] = 5;
indices2[3] = 6;
indices2[4] = 6;
indices2[5] = 7;
indices2[6] = 7;
indices2[7] = 4;
indices2[8] = 0;
indices2[9] = 1;
indices2[10] = 1;
indices2[11] = 2;
indices2[12] = 2;
indices2[13] = 3;
indices2[14] = 3;
indices2[15] = 0;
indices2[16] = 0;
indices2[17] = 4;
indices2[18] = 1;
indices2[19] = 5;
indices2[20] = 2;
indices2[21] = 6;
indices2[22] = 3;
indices2[23] = 7;
const diff = Cartesian3_default.subtract(max3, min3, diffScratch2);
const radius = Cartesian3_default.magnitude(diff) * 0.5;
if (defined_default(boxGeometry._offsetAttribute)) {
const length3 = positions.length;
const offsetValue = boxGeometry._offsetAttribute === GeometryOffsetAttribute_default.NONE ? 0 : 1;
const applyOffset = new Uint8Array(length3 / 3).fill(offsetValue);
attributes.applyOffset = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.UNSIGNED_BYTE,
componentsPerAttribute: 1,
values: applyOffset
});
}
return new Geometry_default({
attributes,
indices: indices2,
primitiveType: PrimitiveType_default.LINES,
boundingSphere: new BoundingSphere_default(Cartesian3_default.ZERO, radius),
offsetAttribute: boxGeometry._offsetAttribute
});
};
var BoxOutlineGeometry_default = BoxOutlineGeometry;
// Source/Core/cancelAnimationFrame.js
var implementation2;
if (typeof cancelAnimationFrame !== "undefined") {
implementation2 = cancelAnimationFrame;
}
(function() {
if (!defined_default(implementation2) && typeof window !== "undefined") {
const vendors = ["webkit", "moz", "ms", "o"];
let i = 0;
const len = vendors.length;
while (i < len && !defined_default(implementation2)) {
implementation2 = window[`${vendors[i]}CancelAnimationFrame`];
if (!defined_default(implementation2)) {
implementation2 = window[`${vendors[i]}CancelRequestAnimationFrame`];
}
++i;
}
}
if (!defined_default(implementation2)) {
implementation2 = clearTimeout;
}
})();
function cancelAnimationFramePolyfill(requestID) {
deprecationWarning_default(
"Cesium.cancelAnimationFrame",
"Cesium.cancelAnimationFrame was deprecated in CesiumJS 1.96 and will be removed in 1.99. Use the native cancelAnimationFrame method instead."
);
implementation2(requestID);
}
var cancelAnimationFrame_default = cancelAnimationFramePolyfill;
// Source/Core/CartographicGeocoderService.js
function CartographicGeocoderService() {
}
CartographicGeocoderService.prototype.geocode = function(query) {
Check_default.typeOf.string("query", query);
const splitQuery = query.match(/[^\s,\n]+/g);
if (splitQuery.length === 2 || splitQuery.length === 3) {
let longitude = +splitQuery[0];
let latitude = +splitQuery[1];
const height = splitQuery.length === 3 ? +splitQuery[2] : 300;
if (isNaN(longitude) && isNaN(latitude)) {
const coordTest = /^(\d+.?\d*)([nsew])/i;
for (let i = 0; i < splitQuery.length; ++i) {
const splitCoord = splitQuery[i].match(coordTest);
if (coordTest.test(splitQuery[i]) && splitCoord.length === 3) {
if (/^[ns]/i.test(splitCoord[2])) {
latitude = /^[n]/i.test(splitCoord[2]) ? +splitCoord[1] : -splitCoord[1];
} else if (/^[ew]/i.test(splitCoord[2])) {
longitude = /^[e]/i.test(splitCoord[2]) ? +splitCoord[1] : -splitCoord[1];
}
}
}
}
if (!isNaN(longitude) && !isNaN(latitude) && !isNaN(height)) {
const result = {
displayName: query,
destination: Cartesian3_default.fromDegrees(longitude, latitude, height)
};
return Promise.resolve([result]);
}
}
return Promise.resolve([]);
};
var CartographicGeocoderService_default = CartographicGeocoderService;
// Source/Core/Spline.js
function Spline() {
this.times = void 0;
this.points = void 0;
DeveloperError_default.throwInstantiationError();
}
Spline.getPointType = function(point) {
if (typeof point === "number") {
return Number;
}
if (point instanceof Cartesian3_default) {
return Cartesian3_default;
}
if (point instanceof Quaternion_default) {
return Quaternion_default;
}
throw new DeveloperError_default(
"point must be a Cartesian3, Quaternion, or Number."
);
};
Spline.prototype.evaluate = DeveloperError_default.throwInstantiationError;
Spline.prototype.findTimeInterval = function(time, startIndex) {
const times = this.times;
const length3 = times.length;
Check_default.typeOf.number("time", time);
if (time < times[0] || time > times[length3 - 1]) {
throw new DeveloperError_default("time is out of range.");
}
startIndex = defaultValue_default(startIndex, 0);
if (time >= times[startIndex]) {
if (startIndex + 1 < length3 && time < times[startIndex + 1]) {
return startIndex;
} else if (startIndex + 2 < length3 && time < times[startIndex + 2]) {
return startIndex + 1;
}
} else if (startIndex - 1 >= 0 && time >= times[startIndex - 1]) {
return startIndex - 1;
}
let i;
if (time > times[startIndex]) {
for (i = startIndex; i < length3 - 1; ++i) {
if (time >= times[i] && time < times[i + 1]) {
break;
}
}
} else {
for (i = startIndex - 1; i >= 0; --i) {
if (time >= times[i] && time < times[i + 1]) {
break;
}
}
}
if (i === length3 - 1) {
i = length3 - 2;
}
return i;
};
Spline.prototype.wrapTime = function(time) {
Check_default.typeOf.number("time", time);
const times = this.times;
const timeEnd = times[times.length - 1];
const timeStart = times[0];
const timeStretch = timeEnd - timeStart;
let divs;
if (time < timeStart) {
divs = Math.floor((timeStart - time) / timeStretch) + 1;
time += divs * timeStretch;
}
if (time > timeEnd) {
divs = Math.floor((time - timeEnd) / timeStretch) + 1;
time -= divs * timeStretch;
}
return time;
};
Spline.prototype.clampTime = function(time) {
Check_default.typeOf.number("time", time);
const times = this.times;
return Math_default.clamp(time, times[0], times[times.length - 1]);
};
var Spline_default = Spline;
// Source/Core/LinearSpline.js
function LinearSpline(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
const points = options.points;
const times = options.times;
if (!defined_default(points) || !defined_default(times)) {
throw new DeveloperError_default("points and times are required.");
}
if (points.length < 2) {
throw new DeveloperError_default(
"points.length must be greater than or equal to 2."
);
}
if (times.length !== points.length) {
throw new DeveloperError_default("times.length must be equal to points.length.");
}
this._times = times;
this._points = points;
this._pointType = Spline_default.getPointType(points[0]);
this._lastTimeIndex = 0;
}
Object.defineProperties(LinearSpline.prototype, {
times: {
get: function() {
return this._times;
}
},
points: {
get: function() {
return this._points;
}
}
});
LinearSpline.prototype.findTimeInterval = Spline_default.prototype.findTimeInterval;
LinearSpline.prototype.wrapTime = Spline_default.prototype.wrapTime;
LinearSpline.prototype.clampTime = Spline_default.prototype.clampTime;
LinearSpline.prototype.evaluate = function(time, result) {
const points = this.points;
const times = this.times;
const i = this._lastTimeIndex = this.findTimeInterval(
time,
this._lastTimeIndex
);
const u3 = (time - times[i]) / (times[i + 1] - times[i]);
const PointType = this._pointType;
if (PointType === Number) {
return (1 - u3) * points[i] + u3 * points[i + 1];
}
if (!defined_default(result)) {
result = new Cartesian3_default();
}
return Cartesian3_default.lerp(points[i], points[i + 1], u3, result);
};
var LinearSpline_default = LinearSpline;
// Source/Core/TridiagonalSystemSolver.js
var TridiagonalSystemSolver = {};
TridiagonalSystemSolver.solve = function(lower, diagonal, upper, right) {
if (!defined_default(lower) || !(lower instanceof Array)) {
throw new DeveloperError_default("The array lower is required.");
}
if (!defined_default(diagonal) || !(diagonal instanceof Array)) {
throw new DeveloperError_default("The array diagonal is required.");
}
if (!defined_default(upper) || !(upper instanceof Array)) {
throw new DeveloperError_default("The array upper is required.");
}
if (!defined_default(right) || !(right instanceof Array)) {
throw new DeveloperError_default("The array right is required.");
}
if (diagonal.length !== right.length) {
throw new DeveloperError_default("diagonal and right must have the same lengths.");
}
if (lower.length !== upper.length) {
throw new DeveloperError_default("lower and upper must have the same lengths.");
} else if (lower.length !== diagonal.length - 1) {
throw new DeveloperError_default(
"lower and upper must be one less than the length of diagonal."
);
}
const c = new Array(upper.length);
const d = new Array(right.length);
const x = new Array(right.length);
let i;
for (i = 0; i < d.length; i++) {
d[i] = new Cartesian3_default();
x[i] = new Cartesian3_default();
}
c[0] = upper[0] / diagonal[0];
d[0] = Cartesian3_default.multiplyByScalar(right[0], 1 / diagonal[0], d[0]);
let scalar;
for (i = 1; i < c.length; ++i) {
scalar = 1 / (diagonal[i] - c[i - 1] * lower[i - 1]);
c[i] = upper[i] * scalar;
d[i] = Cartesian3_default.subtract(
right[i],
Cartesian3_default.multiplyByScalar(d[i - 1], lower[i - 1], d[i]),
d[i]
);
d[i] = Cartesian3_default.multiplyByScalar(d[i], scalar, d[i]);
}
scalar = 1 / (diagonal[i] - c[i - 1] * lower[i - 1]);
d[i] = Cartesian3_default.subtract(
right[i],
Cartesian3_default.multiplyByScalar(d[i - 1], lower[i - 1], d[i]),
d[i]
);
d[i] = Cartesian3_default.multiplyByScalar(d[i], scalar, d[i]);
x[x.length - 1] = d[d.length - 1];
for (i = x.length - 2; i >= 0; --i) {
x[i] = Cartesian3_default.subtract(
d[i],
Cartesian3_default.multiplyByScalar(x[i + 1], c[i], x[i]),
x[i]
);
}
return x;
};
var TridiagonalSystemSolver_default = TridiagonalSystemSolver;
// Source/Core/HermiteSpline.js
var scratchLower = [];
var scratchDiagonal = [];
var scratchUpper = [];
var scratchRight = [];
function generateClamped(points, firstTangent, lastTangent) {
const l = scratchLower;
const u3 = scratchUpper;
const d = scratchDiagonal;
const r = scratchRight;
l.length = u3.length = points.length - 1;
d.length = r.length = points.length;
let i;
l[0] = d[0] = 1;
u3[0] = 0;
let right = r[0];
if (!defined_default(right)) {
right = r[0] = new Cartesian3_default();
}
Cartesian3_default.clone(firstTangent, right);
for (i = 1; i < l.length - 1; ++i) {
l[i] = u3[i] = 1;
d[i] = 4;
right = r[i];
if (!defined_default(right)) {
right = r[i] = new Cartesian3_default();
}
Cartesian3_default.subtract(points[i + 1], points[i - 1], right);
Cartesian3_default.multiplyByScalar(right, 3, right);
}
l[i] = 0;
u3[i] = 1;
d[i] = 4;
right = r[i];
if (!defined_default(right)) {
right = r[i] = new Cartesian3_default();
}
Cartesian3_default.subtract(points[i + 1], points[i - 1], right);
Cartesian3_default.multiplyByScalar(right, 3, right);
d[i + 1] = 1;
right = r[i + 1];
if (!defined_default(right)) {
right = r[i + 1] = new Cartesian3_default();
}
Cartesian3_default.clone(lastTangent, right);
return TridiagonalSystemSolver_default.solve(l, d, u3, r);
}
function generateNatural(points) {
const l = scratchLower;
const u3 = scratchUpper;
const d = scratchDiagonal;
const r = scratchRight;
l.length = u3.length = points.length - 1;
d.length = r.length = points.length;
let i;
l[0] = u3[0] = 1;
d[0] = 2;
let right = r[0];
if (!defined_default(right)) {
right = r[0] = new Cartesian3_default();
}
Cartesian3_default.subtract(points[1], points[0], right);
Cartesian3_default.multiplyByScalar(right, 3, right);
for (i = 1; i < l.length; ++i) {
l[i] = u3[i] = 1;
d[i] = 4;
right = r[i];
if (!defined_default(right)) {
right = r[i] = new Cartesian3_default();
}
Cartesian3_default.subtract(points[i + 1], points[i - 1], right);
Cartesian3_default.multiplyByScalar(right, 3, right);
}
d[i] = 2;
right = r[i];
if (!defined_default(right)) {
right = r[i] = new Cartesian3_default();
}
Cartesian3_default.subtract(points[i], points[i - 1], right);
Cartesian3_default.multiplyByScalar(right, 3, right);
return TridiagonalSystemSolver_default.solve(l, d, u3, r);
}
function HermiteSpline(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
const points = options.points;
const times = options.times;
const inTangents = options.inTangents;
const outTangents = options.outTangents;
if (!defined_default(points) || !defined_default(times) || !defined_default(inTangents) || !defined_default(outTangents)) {
throw new DeveloperError_default(
"times, points, inTangents, and outTangents are required."
);
}
if (points.length < 2) {
throw new DeveloperError_default(
"points.length must be greater than or equal to 2."
);
}
if (times.length !== points.length) {
throw new DeveloperError_default("times.length must be equal to points.length.");
}
if (inTangents.length !== outTangents.length || inTangents.length !== points.length - 1) {
throw new DeveloperError_default(
"inTangents and outTangents must have a length equal to points.length - 1."
);
}
this._times = times;
this._points = points;
this._pointType = Spline_default.getPointType(points[0]);
if (this._pointType !== Spline_default.getPointType(inTangents[0]) || this._pointType !== Spline_default.getPointType(outTangents[0])) {
throw new DeveloperError_default(
"inTangents and outTangents must be of the same type as points."
);
}
this._inTangents = inTangents;
this._outTangents = outTangents;
this._lastTimeIndex = 0;
}
Object.defineProperties(HermiteSpline.prototype, {
times: {
get: function() {
return this._times;
}
},
points: {
get: function() {
return this._points;
}
},
inTangents: {
get: function() {
return this._inTangents;
}
},
outTangents: {
get: function() {
return this._outTangents;
}
}
});
HermiteSpline.createC1 = function(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
const times = options.times;
const points = options.points;
const tangents = options.tangents;
if (!defined_default(points) || !defined_default(times) || !defined_default(tangents)) {
throw new DeveloperError_default("points, times and tangents are required.");
}
if (points.length < 2) {
throw new DeveloperError_default(
"points.length must be greater than or equal to 2."
);
}
if (times.length !== points.length || times.length !== tangents.length) {
throw new DeveloperError_default(
"times, points and tangents must have the same length."
);
}
const outTangents = tangents.slice(0, tangents.length - 1);
const inTangents = tangents.slice(1, tangents.length);
return new HermiteSpline({
times,
points,
inTangents,
outTangents
});
};
HermiteSpline.createNaturalCubic = function(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
const times = options.times;
const points = options.points;
if (!defined_default(points) || !defined_default(times)) {
throw new DeveloperError_default("points and times are required.");
}
if (points.length < 2) {
throw new DeveloperError_default(
"points.length must be greater than or equal to 2."
);
}
if (times.length !== points.length) {
throw new DeveloperError_default("times.length must be equal to points.length.");
}
if (points.length < 3) {
return new LinearSpline_default({
points,
times
});
}
const tangents = generateNatural(points);
const outTangents = tangents.slice(0, tangents.length - 1);
const inTangents = tangents.slice(1, tangents.length);
return new HermiteSpline({
times,
points,
inTangents,
outTangents
});
};
HermiteSpline.createClampedCubic = function(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
const times = options.times;
const points = options.points;
const firstTangent = options.firstTangent;
const lastTangent = options.lastTangent;
if (!defined_default(points) || !defined_default(times) || !defined_default(firstTangent) || !defined_default(lastTangent)) {
throw new DeveloperError_default(
"points, times, firstTangent and lastTangent are required."
);
}
if (points.length < 2) {
throw new DeveloperError_default(
"points.length must be greater than or equal to 2."
);
}
if (times.length !== points.length) {
throw new DeveloperError_default("times.length must be equal to points.length.");
}
const PointType = Spline_default.getPointType(points[0]);
if (PointType !== Spline_default.getPointType(firstTangent) || PointType !== Spline_default.getPointType(lastTangent)) {
throw new DeveloperError_default(
"firstTangent and lastTangent must be of the same type as points."
);
}
if (points.length < 3) {
return new LinearSpline_default({
points,
times
});
}
const tangents = generateClamped(points, firstTangent, lastTangent);
const outTangents = tangents.slice(0, tangents.length - 1);
const inTangents = tangents.slice(1, tangents.length);
return new HermiteSpline({
times,
points,
inTangents,
outTangents
});
};
HermiteSpline.hermiteCoefficientMatrix = new Matrix4_default(
2,
-3,
0,
1,
-2,
3,
0,
0,
1,
-2,
1,
0,
1,
-1,
0,
0
);
HermiteSpline.prototype.findTimeInterval = Spline_default.prototype.findTimeInterval;
var scratchTimeVec = new Cartesian4_default();
var scratchTemp = new Cartesian3_default();
HermiteSpline.prototype.wrapTime = Spline_default.prototype.wrapTime;
HermiteSpline.prototype.clampTime = Spline_default.prototype.clampTime;
HermiteSpline.prototype.evaluate = function(time, result) {
const points = this.points;
const times = this.times;
const inTangents = this.inTangents;
const outTangents = this.outTangents;
this._lastTimeIndex = this.findTimeInterval(time, this._lastTimeIndex);
const i = this._lastTimeIndex;
const timesDelta = times[i + 1] - times[i];
const u3 = (time - times[i]) / timesDelta;
const timeVec = scratchTimeVec;
timeVec.z = u3;
timeVec.y = u3 * u3;
timeVec.x = timeVec.y * u3;
timeVec.w = 1;
const coefs = Matrix4_default.multiplyByVector(
HermiteSpline.hermiteCoefficientMatrix,
timeVec,
timeVec
);
coefs.z *= timesDelta;
coefs.w *= timesDelta;
const PointType = this._pointType;
if (PointType === Number) {
return points[i] * coefs.x + points[i + 1] * coefs.y + outTangents[i] * coefs.z + inTangents[i] * coefs.w;
}
if (!defined_default(result)) {
result = new PointType();
}
result = PointType.multiplyByScalar(points[i], coefs.x, result);
PointType.multiplyByScalar(points[i + 1], coefs.y, scratchTemp);
PointType.add(result, scratchTemp, result);
PointType.multiplyByScalar(outTangents[i], coefs.z, scratchTemp);
PointType.add(result, scratchTemp, result);
PointType.multiplyByScalar(inTangents[i], coefs.w, scratchTemp);
return PointType.add(result, scratchTemp, result);
};
var HermiteSpline_default = HermiteSpline;
// Source/Core/CatmullRomSpline.js
var scratchTimeVec2 = new Cartesian4_default();
var scratchTemp0 = new Cartesian3_default();
var scratchTemp1 = new Cartesian3_default();
function createEvaluateFunction(spline) {
const points = spline.points;
const times = spline.times;
if (points.length < 3) {
const t0 = times[0];
const invSpan = 1 / (times[1] - t0);
const p0 = points[0];
const p1 = points[1];
return function(time, result) {
if (!defined_default(result)) {
result = new Cartesian3_default();
}
const u3 = (time - t0) * invSpan;
return Cartesian3_default.lerp(p0, p1, u3, result);
};
}
return function(time, result) {
if (!defined_default(result)) {
result = new Cartesian3_default();
}
const i = spline._lastTimeIndex = spline.findTimeInterval(
time,
spline._lastTimeIndex
);
const u3 = (time - times[i]) / (times[i + 1] - times[i]);
const timeVec = scratchTimeVec2;
timeVec.z = u3;
timeVec.y = u3 * u3;
timeVec.x = timeVec.y * u3;
timeVec.w = 1;
let p0;
let p1;
let p2;
let p3;
let coefs;
if (i === 0) {
p0 = points[0];
p1 = points[1];
p2 = spline.firstTangent;
p3 = Cartesian3_default.subtract(points[2], p0, scratchTemp0);
Cartesian3_default.multiplyByScalar(p3, 0.5, p3);
coefs = Matrix4_default.multiplyByVector(
HermiteSpline_default.hermiteCoefficientMatrix,
timeVec,
timeVec
);
} else if (i === points.length - 2) {
p0 = points[i];
p1 = points[i + 1];
p3 = spline.lastTangent;
p2 = Cartesian3_default.subtract(p1, points[i - 1], scratchTemp0);
Cartesian3_default.multiplyByScalar(p2, 0.5, p2);
coefs = Matrix4_default.multiplyByVector(
HermiteSpline_default.hermiteCoefficientMatrix,
timeVec,
timeVec
);
} else {
p0 = points[i - 1];
p1 = points[i];
p2 = points[i + 1];
p3 = points[i + 2];
coefs = Matrix4_default.multiplyByVector(
CatmullRomSpline.catmullRomCoefficientMatrix,
timeVec,
timeVec
);
}
result = Cartesian3_default.multiplyByScalar(p0, coefs.x, result);
Cartesian3_default.multiplyByScalar(p1, coefs.y, scratchTemp1);
Cartesian3_default.add(result, scratchTemp1, result);
Cartesian3_default.multiplyByScalar(p2, coefs.z, scratchTemp1);
Cartesian3_default.add(result, scratchTemp1, result);
Cartesian3_default.multiplyByScalar(p3, coefs.w, scratchTemp1);
return Cartesian3_default.add(result, scratchTemp1, result);
};
}
var firstTangentScratch = new Cartesian3_default();
var lastTangentScratch = new Cartesian3_default();
function CatmullRomSpline(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
const points = options.points;
const times = options.times;
let firstTangent = options.firstTangent;
let lastTangent = options.lastTangent;
Check_default.defined("points", points);
Check_default.defined("times", times);
Check_default.typeOf.number.greaterThanOrEquals("points.length", points.length, 2);
Check_default.typeOf.number.equals(
"times.length",
"points.length",
times.length,
points.length
);
if (points.length > 2) {
if (!defined_default(firstTangent)) {
firstTangent = firstTangentScratch;
Cartesian3_default.multiplyByScalar(points[1], 2, firstTangent);
Cartesian3_default.subtract(firstTangent, points[2], firstTangent);
Cartesian3_default.subtract(firstTangent, points[0], firstTangent);
Cartesian3_default.multiplyByScalar(firstTangent, 0.5, firstTangent);
}
if (!defined_default(lastTangent)) {
const n = points.length - 1;
lastTangent = lastTangentScratch;
Cartesian3_default.multiplyByScalar(points[n - 1], 2, lastTangent);
Cartesian3_default.subtract(points[n], lastTangent, lastTangent);
Cartesian3_default.add(lastTangent, points[n - 2], lastTangent);
Cartesian3_default.multiplyByScalar(lastTangent, 0.5, lastTangent);
}
}
this._times = times;
this._points = points;
this._firstTangent = Cartesian3_default.clone(firstTangent);
this._lastTangent = Cartesian3_default.clone(lastTangent);
this._evaluateFunction = createEvaluateFunction(this);
this._lastTimeIndex = 0;
}
Object.defineProperties(CatmullRomSpline.prototype, {
times: {
get: function() {
return this._times;
}
},
points: {
get: function() {
return this._points;
}
},
firstTangent: {
get: function() {
return this._firstTangent;
}
},
lastTangent: {
get: function() {
return this._lastTangent;
}
}
});
CatmullRomSpline.catmullRomCoefficientMatrix = new Matrix4_default(
-0.5,
1,
-0.5,
0,
1.5,
-2.5,
0,
1,
-1.5,
2,
0.5,
0,
0.5,
-0.5,
0,
0
);
CatmullRomSpline.prototype.findTimeInterval = Spline_default.prototype.findTimeInterval;
CatmullRomSpline.prototype.wrapTime = Spline_default.prototype.wrapTime;
CatmullRomSpline.prototype.clampTime = Spline_default.prototype.clampTime;
CatmullRomSpline.prototype.evaluate = function(time, result) {
return this._evaluateFunction(time, result);
};
var CatmullRomSpline_default = CatmullRomSpline;
// Source/Core/getStringFromTypedArray.js
function getStringFromTypedArray(uint8Array, byteOffset, byteLength) {
if (!defined_default(uint8Array)) {
throw new DeveloperError_default("uint8Array is required.");
}
if (byteOffset < 0) {
throw new DeveloperError_default("byteOffset cannot be negative.");
}
if (byteLength < 0) {
throw new DeveloperError_default("byteLength cannot be negative.");
}
if (byteOffset + byteLength > uint8Array.byteLength) {
throw new DeveloperError_default("sub-region exceeds array bounds.");
}
byteOffset = defaultValue_default(byteOffset, 0);
byteLength = defaultValue_default(byteLength, uint8Array.byteLength - byteOffset);
uint8Array = uint8Array.subarray(byteOffset, byteOffset + byteLength);
return getStringFromTypedArray.decode(uint8Array);
}
getStringFromTypedArray.decodeWithTextDecoder = function(view) {
const decoder = new TextDecoder("utf-8");
return decoder.decode(view);
};
getStringFromTypedArray.decodeWithFromCharCode = function(view) {
let result = "";
const codePoints = utf8Handler(view);
const length3 = codePoints.length;
for (let i = 0; i < length3; ++i) {
let cp = codePoints[i];
if (cp <= 65535) {
result += String.fromCharCode(cp);
} else {
cp -= 65536;
result += String.fromCharCode((cp >> 10) + 55296, (cp & 1023) + 56320);
}
}
return result;
};
function inRange(a3, min3, max3) {
return min3 <= a3 && a3 <= max3;
}
function utf8Handler(utfBytes) {
let codePoint = 0;
let bytesSeen = 0;
let bytesNeeded = 0;
let lowerBoundary = 128;
let upperBoundary = 191;
const codePoints = [];
const length3 = utfBytes.length;
for (let i = 0; i < length3; ++i) {
const currentByte = utfBytes[i];
if (bytesNeeded === 0) {
if (inRange(currentByte, 0, 127)) {
codePoints.push(currentByte);
continue;
}
if (inRange(currentByte, 194, 223)) {
bytesNeeded = 1;
codePoint = currentByte & 31;
continue;
}
if (inRange(currentByte, 224, 239)) {
if (currentByte === 224) {
lowerBoundary = 160;
}
if (currentByte === 237) {
upperBoundary = 159;
}
bytesNeeded = 2;
codePoint = currentByte & 15;
continue;
}
if (inRange(currentByte, 240, 244)) {
if (currentByte === 240) {
lowerBoundary = 144;
}
if (currentByte === 244) {
upperBoundary = 143;
}
bytesNeeded = 3;
codePoint = currentByte & 7;
continue;
}
throw new RuntimeError_default("String decoding failed.");
}
if (!inRange(currentByte, lowerBoundary, upperBoundary)) {
codePoint = bytesNeeded = bytesSeen = 0;
lowerBoundary = 128;
upperBoundary = 191;
--i;
continue;
}
lowerBoundary = 128;
upperBoundary = 191;
codePoint = codePoint << 6 | currentByte & 63;
++bytesSeen;
if (bytesSeen === bytesNeeded) {
codePoints.push(codePoint);
codePoint = bytesNeeded = bytesSeen = 0;
}
}
return codePoints;
}
if (typeof TextDecoder !== "undefined") {
getStringFromTypedArray.decode = getStringFromTypedArray.decodeWithTextDecoder;
} else {
getStringFromTypedArray.decode = getStringFromTypedArray.decodeWithFromCharCode;
}
var getStringFromTypedArray_default = getStringFromTypedArray;
// Source/Core/getJsonFromTypedArray.js
function getJsonFromTypedArray(uint8Array, byteOffset, byteLength) {
return JSON.parse(
getStringFromTypedArray_default(uint8Array, byteOffset, byteLength)
);
}
var getJsonFromTypedArray_default = getJsonFromTypedArray;
// Source/Core/Intersections2D.js
var Intersections2D = {};
Intersections2D.clipTriangleAtAxisAlignedThreshold = function(threshold, keepAbove, u0, u12, u22, result) {
if (!defined_default(threshold)) {
throw new DeveloperError_default("threshold is required.");
}
if (!defined_default(keepAbove)) {
throw new DeveloperError_default("keepAbove is required.");
}
if (!defined_default(u0)) {
throw new DeveloperError_default("u0 is required.");
}
if (!defined_default(u12)) {
throw new DeveloperError_default("u1 is required.");
}
if (!defined_default(u22)) {
throw new DeveloperError_default("u2 is required.");
}
if (!defined_default(result)) {
result = [];
} else {
result.length = 0;
}
let u0Behind;
let u1Behind;
let u2Behind;
if (keepAbove) {
u0Behind = u0 < threshold;
u1Behind = u12 < threshold;
u2Behind = u22 < threshold;
} else {
u0Behind = u0 > threshold;
u1Behind = u12 > threshold;
u2Behind = u22 > threshold;
}
const numBehind = u0Behind + u1Behind + u2Behind;
let u01Ratio;
let u02Ratio;
let u12Ratio;
let u10Ratio;
let u20Ratio;
let u21Ratio;
if (numBehind === 1) {
if (u0Behind) {
u01Ratio = (threshold - u0) / (u12 - u0);
u02Ratio = (threshold - u0) / (u22 - u0);
result.push(1);
result.push(2);
if (u02Ratio !== 1) {
result.push(-1);
result.push(0);
result.push(2);
result.push(u02Ratio);
}
if (u01Ratio !== 1) {
result.push(-1);
result.push(0);
result.push(1);
result.push(u01Ratio);
}
} else if (u1Behind) {
u12Ratio = (threshold - u12) / (u22 - u12);
u10Ratio = (threshold - u12) / (u0 - u12);
result.push(2);
result.push(0);
if (u10Ratio !== 1) {
result.push(-1);
result.push(1);
result.push(0);
result.push(u10Ratio);
}
if (u12Ratio !== 1) {
result.push(-1);
result.push(1);
result.push(2);
result.push(u12Ratio);
}
} else if (u2Behind) {
u20Ratio = (threshold - u22) / (u0 - u22);
u21Ratio = (threshold - u22) / (u12 - u22);
result.push(0);
result.push(1);
if (u21Ratio !== 1) {
result.push(-1);
result.push(2);
result.push(1);
result.push(u21Ratio);
}
if (u20Ratio !== 1) {
result.push(-1);
result.push(2);
result.push(0);
result.push(u20Ratio);
}
}
} else if (numBehind === 2) {
if (!u0Behind && u0 !== threshold) {
u10Ratio = (threshold - u12) / (u0 - u12);
u20Ratio = (threshold - u22) / (u0 - u22);
result.push(0);
result.push(-1);
result.push(1);
result.push(0);
result.push(u10Ratio);
result.push(-1);
result.push(2);
result.push(0);
result.push(u20Ratio);
} else if (!u1Behind && u12 !== threshold) {
u21Ratio = (threshold - u22) / (u12 - u22);
u01Ratio = (threshold - u0) / (u12 - u0);
result.push(1);
result.push(-1);
result.push(2);
result.push(1);
result.push(u21Ratio);
result.push(-1);
result.push(0);
result.push(1);
result.push(u01Ratio);
} else if (!u2Behind && u22 !== threshold) {
u02Ratio = (threshold - u0) / (u22 - u0);
u12Ratio = (threshold - u12) / (u22 - u12);
result.push(2);
result.push(-1);
result.push(0);
result.push(2);
result.push(u02Ratio);
result.push(-1);
result.push(1);
result.push(2);
result.push(u12Ratio);
}
} else if (numBehind !== 3) {
result.push(0);
result.push(1);
result.push(2);
}
return result;
};
Intersections2D.computeBarycentricCoordinates = function(x, y, x1, y1, x2, y2, x3, y3, result) {
if (!defined_default(x)) {
throw new DeveloperError_default("x is required.");
}
if (!defined_default(y)) {
throw new DeveloperError_default("y is required.");
}
if (!defined_default(x1)) {
throw new DeveloperError_default("x1 is required.");
}
if (!defined_default(y1)) {
throw new DeveloperError_default("y1 is required.");
}
if (!defined_default(x2)) {
throw new DeveloperError_default("x2 is required.");
}
if (!defined_default(y2)) {
throw new DeveloperError_default("y2 is required.");
}
if (!defined_default(x3)) {
throw new DeveloperError_default("x3 is required.");
}
if (!defined_default(y3)) {
throw new DeveloperError_default("y3 is required.");
}
const x1mx3 = x1 - x3;
const x3mx2 = x3 - x2;
const y2my3 = y2 - y3;
const y1my3 = y1 - y3;
const inverseDeterminant = 1 / (y2my3 * x1mx3 + x3mx2 * y1my3);
const ymy3 = y - y3;
const xmx3 = x - x3;
const l1 = (y2my3 * xmx3 + x3mx2 * ymy3) * inverseDeterminant;
const l2 = (-y1my3 * xmx3 + x1mx3 * ymy3) * inverseDeterminant;
const l3 = 1 - l1 - l2;
if (defined_default(result)) {
result.x = l1;
result.y = l2;
result.z = l3;
return result;
}
return new Cartesian3_default(l1, l2, l3);
};
Intersections2D.computeLineSegmentLineSegmentIntersection = function(x00, y00, x01, y01, x10, y10, x11, y11, result) {
Check_default.typeOf.number("x00", x00);
Check_default.typeOf.number("y00", y00);
Check_default.typeOf.number("x01", x01);
Check_default.typeOf.number("y01", y01);
Check_default.typeOf.number("x10", x10);
Check_default.typeOf.number("y10", y10);
Check_default.typeOf.number("x11", x11);
Check_default.typeOf.number("y11", y11);
const numerator1A = (x11 - x10) * (y00 - y10) - (y11 - y10) * (x00 - x10);
const numerator1B = (x01 - x00) * (y00 - y10) - (y01 - y00) * (x00 - x10);
const denominator1 = (y11 - y10) * (x01 - x00) - (x11 - x10) * (y01 - y00);
if (denominator1 === 0) {
return;
}
const ua1 = numerator1A / denominator1;
const ub1 = numerator1B / denominator1;
if (ua1 >= 0 && ua1 <= 1 && ub1 >= 0 && ub1 <= 1) {
if (!defined_default(result)) {
result = new Cartesian2_default();
}
result.x = x00 + ua1 * (x01 - x00);
result.y = y00 + ua1 * (y01 - y00);
return result;
}
};
var Intersections2D_default = Intersections2D;
// Source/Core/QuantizedMeshTerrainData.js
function QuantizedMeshTerrainData(options) {
if (!defined_default(options) || !defined_default(options.quantizedVertices)) {
throw new DeveloperError_default("options.quantizedVertices is required.");
}
if (!defined_default(options.indices)) {
throw new DeveloperError_default("options.indices is required.");
}
if (!defined_default(options.minimumHeight)) {
throw new DeveloperError_default("options.minimumHeight is required.");
}
if (!defined_default(options.maximumHeight)) {
throw new DeveloperError_default("options.maximumHeight is required.");
}
if (!defined_default(options.maximumHeight)) {
throw new DeveloperError_default("options.maximumHeight is required.");
}
if (!defined_default(options.boundingSphere)) {
throw new DeveloperError_default("options.boundingSphere is required.");
}
if (!defined_default(options.horizonOcclusionPoint)) {
throw new DeveloperError_default("options.horizonOcclusionPoint is required.");
}
if (!defined_default(options.westIndices)) {
throw new DeveloperError_default("options.westIndices is required.");
}
if (!defined_default(options.southIndices)) {
throw new DeveloperError_default("options.southIndices is required.");
}
if (!defined_default(options.eastIndices)) {
throw new DeveloperError_default("options.eastIndices is required.");
}
if (!defined_default(options.northIndices)) {
throw new DeveloperError_default("options.northIndices is required.");
}
if (!defined_default(options.westSkirtHeight)) {
throw new DeveloperError_default("options.westSkirtHeight is required.");
}
if (!defined_default(options.southSkirtHeight)) {
throw new DeveloperError_default("options.southSkirtHeight is required.");
}
if (!defined_default(options.eastSkirtHeight)) {
throw new DeveloperError_default("options.eastSkirtHeight is required.");
}
if (!defined_default(options.northSkirtHeight)) {
throw new DeveloperError_default("options.northSkirtHeight is required.");
}
this._quantizedVertices = options.quantizedVertices;
this._encodedNormals = options.encodedNormals;
this._indices = options.indices;
this._minimumHeight = options.minimumHeight;
this._maximumHeight = options.maximumHeight;
this._boundingSphere = options.boundingSphere;
this._orientedBoundingBox = options.orientedBoundingBox;
this._horizonOcclusionPoint = options.horizonOcclusionPoint;
this._credits = options.credits;
const vertexCount = this._quantizedVertices.length / 3;
const uValues = this._uValues = this._quantizedVertices.subarray(
0,
vertexCount
);
const vValues = this._vValues = this._quantizedVertices.subarray(
vertexCount,
2 * vertexCount
);
this._heightValues = this._quantizedVertices.subarray(
2 * vertexCount,
3 * vertexCount
);
function sortByV(a3, b) {
return vValues[a3] - vValues[b];
}
function sortByU(a3, b) {
return uValues[a3] - uValues[b];
}
this._westIndices = sortIndicesIfNecessary(
options.westIndices,
sortByV,
vertexCount
);
this._southIndices = sortIndicesIfNecessary(
options.southIndices,
sortByU,
vertexCount
);
this._eastIndices = sortIndicesIfNecessary(
options.eastIndices,
sortByV,
vertexCount
);
this._northIndices = sortIndicesIfNecessary(
options.northIndices,
sortByU,
vertexCount
);
this._westSkirtHeight = options.westSkirtHeight;
this._southSkirtHeight = options.southSkirtHeight;
this._eastSkirtHeight = options.eastSkirtHeight;
this._northSkirtHeight = options.northSkirtHeight;
this._childTileMask = defaultValue_default(options.childTileMask, 15);
this._createdByUpsampling = defaultValue_default(options.createdByUpsampling, false);
this._waterMask = options.waterMask;
this._mesh = void 0;
}
Object.defineProperties(QuantizedMeshTerrainData.prototype, {
credits: {
get: function() {
return this._credits;
}
},
waterMask: {
get: function() {
return this._waterMask;
}
},
childTileMask: {
get: function() {
return this._childTileMask;
}
},
canUpsample: {
get: function() {
return defined_default(this._mesh);
}
}
});
var arrayScratch = [];
function sortIndicesIfNecessary(indices2, sortFunction, vertexCount) {
arrayScratch.length = indices2.length;
let needsSort = false;
for (let i = 0, len = indices2.length; i < len; ++i) {
arrayScratch[i] = indices2[i];
needsSort = needsSort || i > 0 && sortFunction(indices2[i - 1], indices2[i]) > 0;
}
if (needsSort) {
arrayScratch.sort(sortFunction);
return IndexDatatype_default.createTypedArray(vertexCount, arrayScratch);
}
return indices2;
}
var createMeshTaskName2 = "createVerticesFromQuantizedTerrainMesh";
var createMeshTaskProcessorNoThrottle2 = new TaskProcessor_default(createMeshTaskName2);
var createMeshTaskProcessorThrottle2 = new TaskProcessor_default(
createMeshTaskName2,
TerrainData_default.maximumAsynchronousTasks
);
QuantizedMeshTerrainData.prototype.createMesh = function(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
Check_default.typeOf.object("options.tilingScheme", options.tilingScheme);
Check_default.typeOf.number("options.x", options.x);
Check_default.typeOf.number("options.y", options.y);
Check_default.typeOf.number("options.level", options.level);
const tilingScheme2 = options.tilingScheme;
const x = options.x;
const y = options.y;
const level = options.level;
const exaggeration = defaultValue_default(options.exaggeration, 1);
const exaggerationRelativeHeight = defaultValue_default(
options.exaggerationRelativeHeight,
0
);
const throttle = defaultValue_default(options.throttle, true);
const ellipsoid = tilingScheme2.ellipsoid;
const rectangle = tilingScheme2.tileXYToRectangle(x, y, level);
const createMeshTaskProcessor = throttle ? createMeshTaskProcessorThrottle2 : createMeshTaskProcessorNoThrottle2;
const verticesPromise = createMeshTaskProcessor.scheduleTask({
minimumHeight: this._minimumHeight,
maximumHeight: this._maximumHeight,
quantizedVertices: this._quantizedVertices,
octEncodedNormals: this._encodedNormals,
includeWebMercatorT: true,
indices: this._indices,
westIndices: this._westIndices,
southIndices: this._southIndices,
eastIndices: this._eastIndices,
northIndices: this._northIndices,
westSkirtHeight: this._westSkirtHeight,
southSkirtHeight: this._southSkirtHeight,
eastSkirtHeight: this._eastSkirtHeight,
northSkirtHeight: this._northSkirtHeight,
rectangle,
relativeToCenter: this._boundingSphere.center,
ellipsoid,
exaggeration,
exaggerationRelativeHeight
});
if (!defined_default(verticesPromise)) {
return void 0;
}
const that = this;
return Promise.resolve(verticesPromise).then(function(result) {
const vertexCountWithoutSkirts = that._quantizedVertices.length / 3;
const vertexCount = vertexCountWithoutSkirts + that._westIndices.length + that._southIndices.length + that._eastIndices.length + that._northIndices.length;
const indicesTypedArray = IndexDatatype_default.createTypedArray(
vertexCount,
result.indices
);
const vertices = new Float32Array(result.vertices);
const rtc = result.center;
const minimumHeight = result.minimumHeight;
const maximumHeight = result.maximumHeight;
const boundingSphere = that._boundingSphere;
const obb = that._orientedBoundingBox;
const occludeePointInScaledSpace = defaultValue_default(
Cartesian3_default.clone(result.occludeePointInScaledSpace),
that._horizonOcclusionPoint
);
const stride = result.vertexStride;
const terrainEncoding = TerrainEncoding_default.clone(result.encoding);
that._mesh = new TerrainMesh_default(
rtc,
vertices,
indicesTypedArray,
result.indexCountWithoutSkirts,
vertexCountWithoutSkirts,
minimumHeight,
maximumHeight,
boundingSphere,
occludeePointInScaledSpace,
stride,
obb,
terrainEncoding,
result.westIndicesSouthToNorth,
result.southIndicesEastToWest,
result.eastIndicesNorthToSouth,
result.northIndicesWestToEast
);
that._quantizedVertices = void 0;
that._encodedNormals = void 0;
that._indices = void 0;
that._uValues = void 0;
that._vValues = void 0;
that._heightValues = void 0;
that._westIndices = void 0;
that._southIndices = void 0;
that._eastIndices = void 0;
that._northIndices = void 0;
return that._mesh;
});
};
var upsampleTaskProcessor = new TaskProcessor_default(
"upsampleQuantizedTerrainMesh",
TerrainData_default.maximumAsynchronousTasks
);
QuantizedMeshTerrainData.prototype.upsample = function(tilingScheme2, thisX, thisY, thisLevel, descendantX, descendantY, descendantLevel) {
if (!defined_default(tilingScheme2)) {
throw new DeveloperError_default("tilingScheme is required.");
}
if (!defined_default(thisX)) {
throw new DeveloperError_default("thisX is required.");
}
if (!defined_default(thisY)) {
throw new DeveloperError_default("thisY is required.");
}
if (!defined_default(thisLevel)) {
throw new DeveloperError_default("thisLevel is required.");
}
if (!defined_default(descendantX)) {
throw new DeveloperError_default("descendantX is required.");
}
if (!defined_default(descendantY)) {
throw new DeveloperError_default("descendantY is required.");
}
if (!defined_default(descendantLevel)) {
throw new DeveloperError_default("descendantLevel is required.");
}
const levelDifference = descendantLevel - thisLevel;
if (levelDifference > 1) {
throw new DeveloperError_default(
"Upsampling through more than one level at a time is not currently supported."
);
}
const mesh = this._mesh;
if (!defined_default(this._mesh)) {
return void 0;
}
const isEastChild = thisX * 2 !== descendantX;
const isNorthChild = thisY * 2 === descendantY;
const ellipsoid = tilingScheme2.ellipsoid;
const childRectangle = tilingScheme2.tileXYToRectangle(
descendantX,
descendantY,
descendantLevel
);
const upsamplePromise = upsampleTaskProcessor.scheduleTask({
vertices: mesh.vertices,
vertexCountWithoutSkirts: mesh.vertexCountWithoutSkirts,
indices: mesh.indices,
indexCountWithoutSkirts: mesh.indexCountWithoutSkirts,
encoding: mesh.encoding,
minimumHeight: this._minimumHeight,
maximumHeight: this._maximumHeight,
isEastChild,
isNorthChild,
childRectangle,
ellipsoid
});
if (!defined_default(upsamplePromise)) {
return void 0;
}
let shortestSkirt = Math.min(this._westSkirtHeight, this._eastSkirtHeight);
shortestSkirt = Math.min(shortestSkirt, this._southSkirtHeight);
shortestSkirt = Math.min(shortestSkirt, this._northSkirtHeight);
const westSkirtHeight = isEastChild ? shortestSkirt * 0.5 : this._westSkirtHeight;
const southSkirtHeight = isNorthChild ? shortestSkirt * 0.5 : this._southSkirtHeight;
const eastSkirtHeight = isEastChild ? this._eastSkirtHeight : shortestSkirt * 0.5;
const northSkirtHeight = isNorthChild ? this._northSkirtHeight : shortestSkirt * 0.5;
const credits = this._credits;
return Promise.resolve(upsamplePromise).then(function(result) {
const quantizedVertices = new Uint16Array(result.vertices);
const indicesTypedArray = IndexDatatype_default.createTypedArray(
quantizedVertices.length / 3,
result.indices
);
let encodedNormals;
if (defined_default(result.encodedNormals)) {
encodedNormals = new Uint8Array(result.encodedNormals);
}
return new QuantizedMeshTerrainData({
quantizedVertices,
indices: indicesTypedArray,
encodedNormals,
minimumHeight: result.minimumHeight,
maximumHeight: result.maximumHeight,
boundingSphere: BoundingSphere_default.clone(result.boundingSphere),
orientedBoundingBox: OrientedBoundingBox_default.clone(
result.orientedBoundingBox
),
horizonOcclusionPoint: Cartesian3_default.clone(result.horizonOcclusionPoint),
westIndices: result.westIndices,
southIndices: result.southIndices,
eastIndices: result.eastIndices,
northIndices: result.northIndices,
westSkirtHeight,
southSkirtHeight,
eastSkirtHeight,
northSkirtHeight,
childTileMask: 0,
credits,
createdByUpsampling: true
});
});
};
var maxShort = 32767;
var barycentricCoordinateScratch = new Cartesian3_default();
QuantizedMeshTerrainData.prototype.interpolateHeight = function(rectangle, longitude, latitude) {
let u3 = Math_default.clamp(
(longitude - rectangle.west) / rectangle.width,
0,
1
);
u3 *= maxShort;
let v7 = Math_default.clamp(
(latitude - rectangle.south) / rectangle.height,
0,
1
);
v7 *= maxShort;
if (!defined_default(this._mesh)) {
return interpolateHeight2(this, u3, v7);
}
return interpolateMeshHeight2(this, u3, v7);
};
function pointInBoundingBox(u3, v7, u0, v02, u12, v13, u22, v23) {
const minU = Math.min(u0, u12, u22);
const maxU = Math.max(u0, u12, u22);
const minV = Math.min(v02, v13, v23);
const maxV = Math.max(v02, v13, v23);
return u3 >= minU && u3 <= maxU && v7 >= minV && v7 <= maxV;
}
var texCoordScratch0 = new Cartesian2_default();
var texCoordScratch1 = new Cartesian2_default();
var texCoordScratch2 = new Cartesian2_default();
function interpolateMeshHeight2(terrainData, u3, v7) {
const mesh = terrainData._mesh;
const vertices = mesh.vertices;
const encoding = mesh.encoding;
const indices2 = mesh.indices;
for (let i = 0, len = indices2.length; i < len; i += 3) {
const i0 = indices2[i];
const i1 = indices2[i + 1];
const i2 = indices2[i + 2];
const uv0 = encoding.decodeTextureCoordinates(
vertices,
i0,
texCoordScratch0
);
const uv1 = encoding.decodeTextureCoordinates(
vertices,
i1,
texCoordScratch1
);
const uv2 = encoding.decodeTextureCoordinates(
vertices,
i2,
texCoordScratch2
);
if (pointInBoundingBox(u3, v7, uv0.x, uv0.y, uv1.x, uv1.y, uv2.x, uv2.y)) {
const barycentric = Intersections2D_default.computeBarycentricCoordinates(
u3,
v7,
uv0.x,
uv0.y,
uv1.x,
uv1.y,
uv2.x,
uv2.y,
barycentricCoordinateScratch
);
if (barycentric.x >= -1e-15 && barycentric.y >= -1e-15 && barycentric.z >= -1e-15) {
const h0 = encoding.decodeHeight(vertices, i0);
const h1 = encoding.decodeHeight(vertices, i1);
const h2 = encoding.decodeHeight(vertices, i2);
return barycentric.x * h0 + barycentric.y * h1 + barycentric.z * h2;
}
}
}
return void 0;
}
function interpolateHeight2(terrainData, u3, v7) {
const uBuffer = terrainData._uValues;
const vBuffer = terrainData._vValues;
const heightBuffer = terrainData._heightValues;
const indices2 = terrainData._indices;
for (let i = 0, len = indices2.length; i < len; i += 3) {
const i0 = indices2[i];
const i1 = indices2[i + 1];
const i2 = indices2[i + 2];
const u0 = uBuffer[i0];
const u12 = uBuffer[i1];
const u22 = uBuffer[i2];
const v02 = vBuffer[i0];
const v13 = vBuffer[i1];
const v23 = vBuffer[i2];
if (pointInBoundingBox(u3, v7, u0, v02, u12, v13, u22, v23)) {
const barycentric = Intersections2D_default.computeBarycentricCoordinates(
u3,
v7,
u0,
v02,
u12,
v13,
u22,
v23,
barycentricCoordinateScratch
);
if (barycentric.x >= -1e-15 && barycentric.y >= -1e-15 && barycentric.z >= -1e-15) {
const quantizedHeight = barycentric.x * heightBuffer[i0] + barycentric.y * heightBuffer[i1] + barycentric.z * heightBuffer[i2];
return Math_default.lerp(
terrainData._minimumHeight,
terrainData._maximumHeight,
quantizedHeight / maxShort
);
}
}
}
return void 0;
}
QuantizedMeshTerrainData.prototype.isChildAvailable = function(thisX, thisY, childX, childY) {
if (!defined_default(thisX)) {
throw new DeveloperError_default("thisX is required.");
}
if (!defined_default(thisY)) {
throw new DeveloperError_default("thisY is required.");
}
if (!defined_default(childX)) {
throw new DeveloperError_default("childX is required.");
}
if (!defined_default(childY)) {
throw new DeveloperError_default("childY is required.");
}
let bitNumber = 2;
if (childX !== thisX * 2) {
++bitNumber;
}
if (childY !== thisY * 2) {
bitNumber -= 2;
}
return (this._childTileMask & 1 << bitNumber) !== 0;
};
QuantizedMeshTerrainData.prototype.wasCreatedByUpsampling = function() {
return this._createdByUpsampling;
};
var QuantizedMeshTerrainData_default = QuantizedMeshTerrainData;
// Source/Core/CesiumTerrainProvider.js
function LayerInformation(layer) {
this.resource = layer.resource;
this.version = layer.version;
this.isHeightmap = layer.isHeightmap;
this.tileUrlTemplates = layer.tileUrlTemplates;
this.availability = layer.availability;
this.hasVertexNormals = layer.hasVertexNormals;
this.hasWaterMask = layer.hasWaterMask;
this.hasMetadata = layer.hasMetadata;
this.availabilityLevels = layer.availabilityLevels;
this.availabilityTilesLoaded = layer.availabilityTilesLoaded;
this.littleEndianExtensionSize = layer.littleEndianExtensionSize;
this.availabilityPromiseCache = {};
}
function CesiumTerrainProvider(options) {
if (!defined_default(options) || !defined_default(options.url)) {
throw new DeveloperError_default("options.url is required.");
}
this._heightmapWidth = 65;
this._heightmapStructure = void 0;
this._hasWaterMask = false;
this._hasVertexNormals = false;
this._ellipsoid = options.ellipsoid;
this._requestVertexNormals = defaultValue_default(
options.requestVertexNormals,
false
);
this._requestWaterMask = defaultValue_default(options.requestWaterMask, false);
this._requestMetadata = defaultValue_default(options.requestMetadata, true);
this._errorEvent = new Event_default();
let credit = options.credit;
if (typeof credit === "string") {
credit = new Credit_default(credit);
}
this._credit = credit;
this._availability = void 0;
this._ready = false;
this._tileCredits = void 0;
const that = this;
let lastResource;
let layerJsonResource;
let metadataError;
const layers = this._layers = [];
let attribution = "";
const overallAvailability = [];
let overallMaxZoom = 0;
this._readyPromise = Promise.resolve(options.url).then(function(url2) {
const resource = Resource_default.createIfNeeded(url2);
resource.appendForwardSlash();
lastResource = resource;
layerJsonResource = lastResource.getDerivedResource({
url: "layer.json"
});
that._tileCredits = resource.credits;
return requestLayerJson();
});
function parseMetadataSuccess(data) {
let message;
if (!data.format) {
message = "The tile format is not specified in the layer.json file.";
metadataError = TileProviderError_default.reportError(
metadataError,
that,
that._errorEvent,
message
);
if (metadataError.retry) {
return requestLayerJson();
}
return Promise.reject(new RuntimeError_default(message));
}
if (!data.tiles || data.tiles.length === 0) {
message = "The layer.json file does not specify any tile URL templates.";
metadataError = TileProviderError_default.reportError(
metadataError,
that,
that._errorEvent,
message
);
if (metadataError.retry) {
return requestLayerJson();
}
return Promise.reject(new RuntimeError_default(message));
}
let hasVertexNormals = false;
let hasWaterMask = false;
let hasMetadata = false;
let littleEndianExtensionSize = true;
let isHeightmap = false;
if (data.format === "heightmap-1.0") {
isHeightmap = true;
if (!defined_default(that._heightmapStructure)) {
that._heightmapStructure = {
heightScale: 1 / 5,
heightOffset: -1e3,
elementsPerHeight: 1,
stride: 1,
elementMultiplier: 256,
isBigEndian: false,
lowestEncodedHeight: 0,
highestEncodedHeight: 256 * 256 - 1
};
}
hasWaterMask = true;
that._requestWaterMask = true;
} else if (data.format.indexOf("quantized-mesh-1.") !== 0) {
message = `The tile format "${data.format}" is invalid or not supported.`;
metadataError = TileProviderError_default.reportError(
metadataError,
that,
that._errorEvent,
message
);
if (metadataError.retry) {
return requestLayerJson();
}
return Promise.reject(new RuntimeError_default(message));
}
const tileUrlTemplates = data.tiles;
const maxZoom = data.maxzoom;
overallMaxZoom = Math.max(overallMaxZoom, maxZoom);
if (!data.projection || data.projection === "EPSG:4326") {
that._tilingScheme = new GeographicTilingScheme_default({
numberOfLevelZeroTilesX: 2,
numberOfLevelZeroTilesY: 1,
ellipsoid: that._ellipsoid
});
} else if (data.projection === "EPSG:3857") {
that._tilingScheme = new WebMercatorTilingScheme_default({
numberOfLevelZeroTilesX: 1,
numberOfLevelZeroTilesY: 1,
ellipsoid: that._ellipsoid
});
} else {
message = `The projection "${data.projection}" is invalid or not supported.`;
metadataError = TileProviderError_default.reportError(
metadataError,
that,
that._errorEvent,
message
);
if (metadataError.retry) {
return requestLayerJson();
}
return Promise.reject(new RuntimeError_default(message));
}
that._levelZeroMaximumGeometricError = TerrainProvider_default.getEstimatedLevelZeroGeometricErrorForAHeightmap(
that._tilingScheme.ellipsoid,
that._heightmapWidth,
that._tilingScheme.getNumberOfXTilesAtLevel(0)
);
if (!data.scheme || data.scheme === "tms" || data.scheme === "slippyMap") {
that._scheme = data.scheme;
} else {
message = `The scheme "${data.scheme}" is invalid or not supported.`;
metadataError = TileProviderError_default.reportError(
metadataError,
that,
that._errorEvent,
message
);
if (metadataError.retry) {
return requestLayerJson();
}
return Promise.reject(new RuntimeError_default(message));
}
let availabilityTilesLoaded;
if (defined_default(data.extensions) && data.extensions.indexOf("octvertexnormals") !== -1) {
hasVertexNormals = true;
} else if (defined_default(data.extensions) && data.extensions.indexOf("vertexnormals") !== -1) {
hasVertexNormals = true;
littleEndianExtensionSize = false;
}
if (defined_default(data.extensions) && data.extensions.indexOf("watermask") !== -1) {
hasWaterMask = true;
}
if (defined_default(data.extensions) && data.extensions.indexOf("metadata") !== -1) {
hasMetadata = true;
}
const availabilityLevels = data.metadataAvailability;
const availableTiles = data.available;
let availability;
if (defined_default(availableTiles) && !defined_default(availabilityLevels)) {
availability = new TileAvailability_default(
that._tilingScheme,
availableTiles.length
);
for (let level = 0; level < availableTiles.length; ++level) {
const rangesAtLevel = availableTiles[level];
const yTiles = that._tilingScheme.getNumberOfYTilesAtLevel(level);
if (!defined_default(overallAvailability[level])) {
overallAvailability[level] = [];
}
for (let rangeIndex = 0; rangeIndex < rangesAtLevel.length; ++rangeIndex) {
const range = rangesAtLevel[rangeIndex];
const yStart = yTiles - range.endY - 1;
const yEnd = yTiles - range.startY - 1;
overallAvailability[level].push([
range.startX,
yStart,
range.endX,
yEnd
]);
availability.addAvailableTileRange(
level,
range.startX,
yStart,
range.endX,
yEnd
);
}
}
} else if (defined_default(availabilityLevels)) {
availabilityTilesLoaded = new TileAvailability_default(
that._tilingScheme,
maxZoom
);
availability = new TileAvailability_default(that._tilingScheme, maxZoom);
overallAvailability[0] = [[0, 0, 1, 0]];
availability.addAvailableTileRange(0, 0, 0, 1, 0);
}
that._hasWaterMask = that._hasWaterMask || hasWaterMask;
that._hasVertexNormals = that._hasVertexNormals || hasVertexNormals;
that._hasMetadata = that._hasMetadata || hasMetadata;
if (defined_default(data.attribution)) {
if (attribution.length > 0) {
attribution += " ";
}
attribution += data.attribution;
}
layers.push(
new LayerInformation({
resource: lastResource,
version: data.version,
isHeightmap,
tileUrlTemplates,
availability,
hasVertexNormals,
hasWaterMask,
hasMetadata,
availabilityLevels,
availabilityTilesLoaded,
littleEndianExtensionSize
})
);
const parentUrl = data.parentUrl;
if (defined_default(parentUrl)) {
if (!defined_default(availability)) {
console.log(
"A layer.json can't have a parentUrl if it does't have an available array."
);
return Promise.resolve(true);
}
lastResource = lastResource.getDerivedResource({
url: parentUrl
});
lastResource.appendForwardSlash();
layerJsonResource = lastResource.getDerivedResource({
url: "layer.json"
});
const parentMetadata = layerJsonResource.fetchJson();
return Promise.resolve(parentMetadata).then(parseMetadataSuccess).catch(parseMetadataFailure);
}
return Promise.resolve(true);
}
function parseMetadataFailure(data) {
const message = `An error occurred while accessing ${layerJsonResource.url}.`;
metadataError = TileProviderError_default.reportError(
metadataError,
that,
that._errorEvent,
message
);
if (metadataError.retry) {
return requestLayerJson();
}
return Promise.reject(new RuntimeError_default(message));
}
function metadataSuccess(data) {
return parseMetadataSuccess(data).then(function() {
if (defined_default(metadataError)) {
return;
}
const length3 = overallAvailability.length;
if (length3 > 0) {
const availability = that._availability = new TileAvailability_default(
that._tilingScheme,
overallMaxZoom
);
for (let level = 0; level < length3; ++level) {
const levelRanges = overallAvailability[level];
for (let i = 0; i < levelRanges.length; ++i) {
const range = levelRanges[i];
availability.addAvailableTileRange(
level,
range[0],
range[1],
range[2],
range[3]
);
}
}
}
if (attribution.length > 0) {
const layerJsonCredit = new Credit_default(attribution);
if (defined_default(that._tileCredits)) {
that._tileCredits.push(layerJsonCredit);
} else {
that._tileCredits = [layerJsonCredit];
}
}
that._ready = true;
return Promise.resolve(true);
});
}
function metadataFailure(data) {
if (defined_default(data) && data.statusCode === 404) {
return metadataSuccess({
tilejson: "2.1.0",
format: "heightmap-1.0",
version: "1.0.0",
scheme: "tms",
tiles: ["{z}/{x}/{y}.terrain?v={version}"]
});
}
return parseMetadataFailure(data);
}
function requestLayerJson() {
return Promise.resolve(layerJsonResource.fetchJson()).then(metadataSuccess).catch(metadataFailure);
}
}
var QuantizedMeshExtensionIds = {
OCT_VERTEX_NORMALS: 1,
WATER_MASK: 2,
METADATA: 4
};
function getRequestHeader(extensionsList) {
if (!defined_default(extensionsList) || extensionsList.length === 0) {
return {
Accept: "application/vnd.quantized-mesh,application/octet-stream;q=0.9,*/*;q=0.01"
};
}
const extensions = extensionsList.join("-");
return {
Accept: `application/vnd.quantized-mesh;extensions=${extensions},application/octet-stream;q=0.9,*/*;q=0.01`
};
}
function createHeightmapTerrainData(provider, buffer, level, x, y) {
const heightBuffer = new Uint16Array(
buffer,
0,
provider._heightmapWidth * provider._heightmapWidth
);
return new HeightmapTerrainData_default({
buffer: heightBuffer,
childTileMask: new Uint8Array(buffer, heightBuffer.byteLength, 1)[0],
waterMask: new Uint8Array(
buffer,
heightBuffer.byteLength + 1,
buffer.byteLength - heightBuffer.byteLength - 1
),
width: provider._heightmapWidth,
height: provider._heightmapWidth,
structure: provider._heightmapStructure,
credits: provider._tileCredits
});
}
function createQuantizedMeshTerrainData(provider, buffer, level, x, y, layer) {
const littleEndianExtensionSize = layer.littleEndianExtensionSize;
let pos = 0;
const cartesian3Elements = 3;
const boundingSphereElements = cartesian3Elements + 1;
const cartesian3Length = Float64Array.BYTES_PER_ELEMENT * cartesian3Elements;
const boundingSphereLength = Float64Array.BYTES_PER_ELEMENT * boundingSphereElements;
const encodedVertexElements = 3;
const encodedVertexLength = Uint16Array.BYTES_PER_ELEMENT * encodedVertexElements;
const triangleElements = 3;
let bytesPerIndex = Uint16Array.BYTES_PER_ELEMENT;
let triangleLength = bytesPerIndex * triangleElements;
const view = new DataView(buffer);
const center = new Cartesian3_default(
view.getFloat64(pos, true),
view.getFloat64(pos + 8, true),
view.getFloat64(pos + 16, true)
);
pos += cartesian3Length;
const minimumHeight = view.getFloat32(pos, true);
pos += Float32Array.BYTES_PER_ELEMENT;
const maximumHeight = view.getFloat32(pos, true);
pos += Float32Array.BYTES_PER_ELEMENT;
const boundingSphere = new BoundingSphere_default(
new Cartesian3_default(
view.getFloat64(pos, true),
view.getFloat64(pos + 8, true),
view.getFloat64(pos + 16, true)
),
view.getFloat64(pos + cartesian3Length, true)
);
pos += boundingSphereLength;
const horizonOcclusionPoint = new Cartesian3_default(
view.getFloat64(pos, true),
view.getFloat64(pos + 8, true),
view.getFloat64(pos + 16, true)
);
pos += cartesian3Length;
const vertexCount = view.getUint32(pos, true);
pos += Uint32Array.BYTES_PER_ELEMENT;
const encodedVertexBuffer = new Uint16Array(buffer, pos, vertexCount * 3);
pos += vertexCount * encodedVertexLength;
if (vertexCount > 64 * 1024) {
bytesPerIndex = Uint32Array.BYTES_PER_ELEMENT;
triangleLength = bytesPerIndex * triangleElements;
}
const uBuffer = encodedVertexBuffer.subarray(0, vertexCount);
const vBuffer = encodedVertexBuffer.subarray(vertexCount, 2 * vertexCount);
const heightBuffer = encodedVertexBuffer.subarray(
vertexCount * 2,
3 * vertexCount
);
AttributeCompression_default.zigZagDeltaDecode(uBuffer, vBuffer, heightBuffer);
if (pos % bytesPerIndex !== 0) {
pos += bytesPerIndex - pos % bytesPerIndex;
}
const triangleCount = view.getUint32(pos, true);
pos += Uint32Array.BYTES_PER_ELEMENT;
const indices2 = IndexDatatype_default.createTypedArrayFromArrayBuffer(
vertexCount,
buffer,
pos,
triangleCount * triangleElements
);
pos += triangleCount * triangleLength;
let highest = 0;
const length3 = indices2.length;
for (let i = 0; i < length3; ++i) {
const code = indices2[i];
indices2[i] = highest - code;
if (code === 0) {
++highest;
}
}
const westVertexCount = view.getUint32(pos, true);
pos += Uint32Array.BYTES_PER_ELEMENT;
const westIndices = IndexDatatype_default.createTypedArrayFromArrayBuffer(
vertexCount,
buffer,
pos,
westVertexCount
);
pos += westVertexCount * bytesPerIndex;
const southVertexCount = view.getUint32(pos, true);
pos += Uint32Array.BYTES_PER_ELEMENT;
const southIndices = IndexDatatype_default.createTypedArrayFromArrayBuffer(
vertexCount,
buffer,
pos,
southVertexCount
);
pos += southVertexCount * bytesPerIndex;
const eastVertexCount = view.getUint32(pos, true);
pos += Uint32Array.BYTES_PER_ELEMENT;
const eastIndices = IndexDatatype_default.createTypedArrayFromArrayBuffer(
vertexCount,
buffer,
pos,
eastVertexCount
);
pos += eastVertexCount * bytesPerIndex;
const northVertexCount = view.getUint32(pos, true);
pos += Uint32Array.BYTES_PER_ELEMENT;
const northIndices = IndexDatatype_default.createTypedArrayFromArrayBuffer(
vertexCount,
buffer,
pos,
northVertexCount
);
pos += northVertexCount * bytesPerIndex;
let encodedNormalBuffer;
let waterMaskBuffer;
while (pos < view.byteLength) {
const extensionId = view.getUint8(pos, true);
pos += Uint8Array.BYTES_PER_ELEMENT;
const extensionLength = view.getUint32(pos, littleEndianExtensionSize);
pos += Uint32Array.BYTES_PER_ELEMENT;
if (extensionId === QuantizedMeshExtensionIds.OCT_VERTEX_NORMALS && provider._requestVertexNormals) {
encodedNormalBuffer = new Uint8Array(buffer, pos, vertexCount * 2);
} else if (extensionId === QuantizedMeshExtensionIds.WATER_MASK && provider._requestWaterMask) {
waterMaskBuffer = new Uint8Array(buffer, pos, extensionLength);
} else if (extensionId === QuantizedMeshExtensionIds.METADATA && provider._requestMetadata) {
const stringLength = view.getUint32(pos, true);
if (stringLength > 0) {
const metadata = getJsonFromTypedArray_default(
new Uint8Array(buffer),
pos + Uint32Array.BYTES_PER_ELEMENT,
stringLength
);
const availableTiles = metadata.available;
if (defined_default(availableTiles)) {
for (let offset2 = 0; offset2 < availableTiles.length; ++offset2) {
const availableLevel = level + offset2 + 1;
const rangesAtLevel = availableTiles[offset2];
const yTiles = provider._tilingScheme.getNumberOfYTilesAtLevel(
availableLevel
);
for (let rangeIndex = 0; rangeIndex < rangesAtLevel.length; ++rangeIndex) {
const range = rangesAtLevel[rangeIndex];
const yStart = yTiles - range.endY - 1;
const yEnd = yTiles - range.startY - 1;
provider.availability.addAvailableTileRange(
availableLevel,
range.startX,
yStart,
range.endX,
yEnd
);
layer.availability.addAvailableTileRange(
availableLevel,
range.startX,
yStart,
range.endX,
yEnd
);
}
}
}
}
layer.availabilityTilesLoaded.addAvailableTileRange(level, x, y, x, y);
}
pos += extensionLength;
}
const skirtHeight = provider.getLevelMaximumGeometricError(level) * 5;
const rectangle = provider._tilingScheme.tileXYToRectangle(x, y, level);
const orientedBoundingBox = OrientedBoundingBox_default.fromRectangle(
rectangle,
minimumHeight,
maximumHeight,
provider._tilingScheme.ellipsoid
);
return new QuantizedMeshTerrainData_default({
center,
minimumHeight,
maximumHeight,
boundingSphere,
orientedBoundingBox,
horizonOcclusionPoint,
quantizedVertices: encodedVertexBuffer,
encodedNormals: encodedNormalBuffer,
indices: indices2,
westIndices,
southIndices,
eastIndices,
northIndices,
westSkirtHeight: skirtHeight,
southSkirtHeight: skirtHeight,
eastSkirtHeight: skirtHeight,
northSkirtHeight: skirtHeight,
childTileMask: provider.availability.computeChildMaskForTile(level, x, y),
waterMask: waterMaskBuffer,
credits: provider._tileCredits
});
}
CesiumTerrainProvider.prototype.requestTileGeometry = function(x, y, level, request) {
if (!this._ready) {
throw new DeveloperError_default(
"requestTileGeometry must not be called before the terrain provider is ready."
);
}
const layers = this._layers;
let layerToUse;
const layerCount = layers.length;
if (layerCount === 1) {
layerToUse = layers[0];
} else {
for (let i = 0; i < layerCount; ++i) {
const layer = layers[i];
if (!defined_default(layer.availability) || layer.availability.isTileAvailable(level, x, y)) {
layerToUse = layer;
break;
}
}
}
return requestTileGeometry(this, x, y, level, layerToUse, request);
};
function requestTileGeometry(provider, x, y, level, layerToUse, request) {
if (!defined_default(layerToUse)) {
return Promise.reject(new RuntimeError_default("Terrain tile doesn't exist"));
}
const urlTemplates = layerToUse.tileUrlTemplates;
if (urlTemplates.length === 0) {
return void 0;
}
let terrainY;
if (!provider._scheme || provider._scheme === "tms") {
const yTiles = provider._tilingScheme.getNumberOfYTilesAtLevel(level);
terrainY = yTiles - y - 1;
} else {
terrainY = y;
}
const extensionList = [];
if (provider._requestVertexNormals && layerToUse.hasVertexNormals) {
extensionList.push(
layerToUse.littleEndianExtensionSize ? "octvertexnormals" : "vertexnormals"
);
}
if (provider._requestWaterMask && layerToUse.hasWaterMask) {
extensionList.push("watermask");
}
if (provider._requestMetadata && layerToUse.hasMetadata) {
extensionList.push("metadata");
}
let headers;
let query;
const url2 = urlTemplates[(x + terrainY + level) % urlTemplates.length];
const resource = layerToUse.resource;
if (defined_default(resource._ionEndpoint) && !defined_default(resource._ionEndpoint.externalType)) {
if (extensionList.length !== 0) {
query = { extensions: extensionList.join("-") };
}
headers = getRequestHeader(void 0);
} else {
headers = getRequestHeader(extensionList);
}
const promise = resource.getDerivedResource({
url: url2,
templateValues: {
version: layerToUse.version,
z: level,
x,
y: terrainY
},
queryParameters: query,
headers,
request
}).fetchArrayBuffer();
if (!defined_default(promise)) {
return void 0;
}
return promise.then(function(buffer) {
if (!defined_default(buffer)) {
return Promise.reject(new RuntimeError_default("Mesh buffer doesn't exist."));
}
if (defined_default(provider._heightmapStructure)) {
return createHeightmapTerrainData(provider, buffer, level, x, y);
}
return createQuantizedMeshTerrainData(
provider,
buffer,
level,
x,
y,
layerToUse
);
});
}
Object.defineProperties(CesiumTerrainProvider.prototype, {
errorEvent: {
get: function() {
return this._errorEvent;
}
},
credit: {
get: function() {
if (!this._ready) {
throw new DeveloperError_default(
"credit must not be called before the terrain provider is ready."
);
}
return this._credit;
}
},
tilingScheme: {
get: function() {
if (!this._ready) {
throw new DeveloperError_default(
"tilingScheme must not be called before the terrain provider is ready."
);
}
return this._tilingScheme;
}
},
ready: {
get: function() {
return this._ready;
}
},
readyPromise: {
get: function() {
return this._readyPromise;
}
},
hasWaterMask: {
get: function() {
if (!this._ready) {
throw new DeveloperError_default(
"hasWaterMask must not be called before the terrain provider is ready."
);
}
return this._hasWaterMask && this._requestWaterMask;
}
},
hasVertexNormals: {
get: function() {
if (!this._ready) {
throw new DeveloperError_default(
"hasVertexNormals must not be called before the terrain provider is ready."
);
}
return this._hasVertexNormals && this._requestVertexNormals;
}
},
hasMetadata: {
get: function() {
if (!this._ready) {
throw new DeveloperError_default(
"hasMetadata must not be called before the terrain provider is ready."
);
}
return this._hasMetadata && this._requestMetadata;
}
},
requestVertexNormals: {
get: function() {
return this._requestVertexNormals;
}
},
requestWaterMask: {
get: function() {
return this._requestWaterMask;
}
},
requestMetadata: {
get: function() {
return this._requestMetadata;
}
},
availability: {
get: function() {
if (!this._ready) {
throw new DeveloperError_default(
"availability must not be called before the terrain provider is ready."
);
}
return this._availability;
}
}
});
CesiumTerrainProvider.prototype.getLevelMaximumGeometricError = function(level) {
return this._levelZeroMaximumGeometricError / (1 << level);
};
CesiumTerrainProvider.prototype.getTileDataAvailable = function(x, y, level) {
if (!defined_default(this._availability)) {
return void 0;
}
if (level > this._availability._maximumLevel) {
return false;
}
if (this._availability.isTileAvailable(level, x, y)) {
return true;
}
if (!this._hasMetadata) {
return false;
}
const layers = this._layers;
const count = layers.length;
for (let i = 0; i < count; ++i) {
const layerResult = checkLayer(this, x, y, level, layers[i], i === 0);
if (layerResult.result) {
return void 0;
}
}
return false;
};
CesiumTerrainProvider.prototype.loadTileDataAvailability = function(x, y, level) {
if (!defined_default(this._availability) || level > this._availability._maximumLevel || this._availability.isTileAvailable(level, x, y) || !this._hasMetadata) {
return void 0;
}
const layers = this._layers;
const count = layers.length;
for (let i = 0; i < count; ++i) {
const layerResult = checkLayer(this, x, y, level, layers[i], i === 0);
if (defined_default(layerResult.promise)) {
return layerResult.promise;
}
}
};
function getAvailabilityTile(layer, x, y, level) {
if (level === 0) {
return;
}
const availabilityLevels = layer.availabilityLevels;
const parentLevel = level % availabilityLevels === 0 ? level - availabilityLevels : (level / availabilityLevels | 0) * availabilityLevels;
const divisor = 1 << level - parentLevel;
const parentX = x / divisor | 0;
const parentY = y / divisor | 0;
return {
level: parentLevel,
x: parentX,
y: parentY
};
}
function checkLayer(provider, x, y, level, layer, topLayer) {
if (!defined_default(layer.availabilityLevels)) {
return {
result: false
};
}
let cacheKey;
const deleteFromCache = function() {
delete layer.availabilityPromiseCache[cacheKey];
};
const availabilityTilesLoaded = layer.availabilityTilesLoaded;
const availability = layer.availability;
let tile = getAvailabilityTile(layer, x, y, level);
while (defined_default(tile)) {
if (availability.isTileAvailable(tile.level, tile.x, tile.y) && !availabilityTilesLoaded.isTileAvailable(tile.level, tile.x, tile.y)) {
let requestPromise;
if (!topLayer) {
cacheKey = `${tile.level}-${tile.x}-${tile.y}`;
requestPromise = layer.availabilityPromiseCache[cacheKey];
if (!defined_default(requestPromise)) {
const request = new Request_default({
throttle: false,
throttleByServer: true,
type: RequestType_default.TERRAIN
});
requestPromise = requestTileGeometry(
provider,
tile.x,
tile.y,
tile.level,
layer,
request
);
if (defined_default(requestPromise)) {
layer.availabilityPromiseCache[cacheKey] = requestPromise;
requestPromise.then(deleteFromCache);
}
}
}
return {
result: true,
promise: requestPromise
};
}
tile = getAvailabilityTile(layer, tile.x, tile.y, tile.level);
}
return {
result: false
};
}
CesiumTerrainProvider._getAvailabilityTile = getAvailabilityTile;
var CesiumTerrainProvider_default = CesiumTerrainProvider;
// Source/Core/EllipseGeometryLibrary.js
var EllipseGeometryLibrary = {};
var rotAxis = new Cartesian3_default();
var tempVec = new Cartesian3_default();
var unitQuat = new Quaternion_default();
var rotMtx = new Matrix3_default();
function pointOnEllipsoid(theta, rotation, northVec, eastVec, aSqr, ab, bSqr, mag, unitPos, result) {
const azimuth = theta + rotation;
Cartesian3_default.multiplyByScalar(eastVec, Math.cos(azimuth), rotAxis);
Cartesian3_default.multiplyByScalar(northVec, Math.sin(azimuth), tempVec);
Cartesian3_default.add(rotAxis, tempVec, rotAxis);
let cosThetaSquared = Math.cos(theta);
cosThetaSquared = cosThetaSquared * cosThetaSquared;
let sinThetaSquared = Math.sin(theta);
sinThetaSquared = sinThetaSquared * sinThetaSquared;
const radius = ab / Math.sqrt(bSqr * cosThetaSquared + aSqr * sinThetaSquared);
const angle = radius / mag;
Quaternion_default.fromAxisAngle(rotAxis, angle, unitQuat);
Matrix3_default.fromQuaternion(unitQuat, rotMtx);
Matrix3_default.multiplyByVector(rotMtx, unitPos, result);
Cartesian3_default.normalize(result, result);
Cartesian3_default.multiplyByScalar(result, mag, result);
return result;
}
var scratchCartesian13 = new Cartesian3_default();
var scratchCartesian24 = new Cartesian3_default();
var scratchCartesian34 = new Cartesian3_default();
var scratchNormal2 = new Cartesian3_default();
EllipseGeometryLibrary.raisePositionsToHeight = function(positions, options, extrude) {
const ellipsoid = options.ellipsoid;
const height = options.height;
const extrudedHeight = options.extrudedHeight;
const size = extrude ? positions.length / 3 * 2 : positions.length / 3;
const finalPositions = new Float64Array(size * 3);
const length3 = positions.length;
const bottomOffset = extrude ? length3 : 0;
for (let i = 0; i < length3; i += 3) {
const i1 = i + 1;
const i2 = i + 2;
const position = Cartesian3_default.fromArray(positions, i, scratchCartesian13);
ellipsoid.scaleToGeodeticSurface(position, position);
const extrudedPosition = Cartesian3_default.clone(position, scratchCartesian24);
const normal2 = ellipsoid.geodeticSurfaceNormal(position, scratchNormal2);
const scaledNormal = Cartesian3_default.multiplyByScalar(
normal2,
height,
scratchCartesian34
);
Cartesian3_default.add(position, scaledNormal, position);
if (extrude) {
Cartesian3_default.multiplyByScalar(normal2, extrudedHeight, scaledNormal);
Cartesian3_default.add(extrudedPosition, scaledNormal, extrudedPosition);
finalPositions[i + bottomOffset] = extrudedPosition.x;
finalPositions[i1 + bottomOffset] = extrudedPosition.y;
finalPositions[i2 + bottomOffset] = extrudedPosition.z;
}
finalPositions[i] = position.x;
finalPositions[i1] = position.y;
finalPositions[i2] = position.z;
}
return finalPositions;
};
var unitPosScratch = new Cartesian3_default();
var eastVecScratch = new Cartesian3_default();
var northVecScratch = new Cartesian3_default();
EllipseGeometryLibrary.computeEllipsePositions = function(options, addFillPositions, addEdgePositions) {
const semiMinorAxis = options.semiMinorAxis;
const semiMajorAxis = options.semiMajorAxis;
const rotation = options.rotation;
const center = options.center;
const granularity = options.granularity * 8;
const aSqr = semiMinorAxis * semiMinorAxis;
const bSqr = semiMajorAxis * semiMajorAxis;
const ab = semiMajorAxis * semiMinorAxis;
const mag = Cartesian3_default.magnitude(center);
const unitPos = Cartesian3_default.normalize(center, unitPosScratch);
let eastVec = Cartesian3_default.cross(Cartesian3_default.UNIT_Z, center, eastVecScratch);
eastVec = Cartesian3_default.normalize(eastVec, eastVec);
const northVec = Cartesian3_default.cross(unitPos, eastVec, northVecScratch);
let numPts = 1 + Math.ceil(Math_default.PI_OVER_TWO / granularity);
const deltaTheta = Math_default.PI_OVER_TWO / (numPts - 1);
let theta = Math_default.PI_OVER_TWO - numPts * deltaTheta;
if (theta < 0) {
numPts -= Math.ceil(Math.abs(theta) / deltaTheta);
}
const size = 2 * (numPts * (numPts + 2));
const positions = addFillPositions ? new Array(size * 3) : void 0;
let positionIndex = 0;
let position = scratchCartesian13;
let reflectedPosition = scratchCartesian24;
const outerPositionsLength = numPts * 4 * 3;
let outerRightIndex = outerPositionsLength - 1;
let outerLeftIndex = 0;
const outerPositions = addEdgePositions ? new Array(outerPositionsLength) : void 0;
let i;
let j;
let numInterior;
let t;
let interiorPosition;
theta = Math_default.PI_OVER_TWO;
position = pointOnEllipsoid(
theta,
rotation,
northVec,
eastVec,
aSqr,
ab,
bSqr,
mag,
unitPos,
position
);
if (addFillPositions) {
positions[positionIndex++] = position.x;
positions[positionIndex++] = position.y;
positions[positionIndex++] = position.z;
}
if (addEdgePositions) {
outerPositions[outerRightIndex--] = position.z;
outerPositions[outerRightIndex--] = position.y;
outerPositions[outerRightIndex--] = position.x;
}
theta = Math_default.PI_OVER_TWO - deltaTheta;
for (i = 1; i < numPts + 1; ++i) {
position = pointOnEllipsoid(
theta,
rotation,
northVec,
eastVec,
aSqr,
ab,
bSqr,
mag,
unitPos,
position
);
reflectedPosition = pointOnEllipsoid(
Math.PI - theta,
rotation,
northVec,
eastVec,
aSqr,
ab,
bSqr,
mag,
unitPos,
reflectedPosition
);
if (addFillPositions) {
positions[positionIndex++] = position.x;
positions[positionIndex++] = position.y;
positions[positionIndex++] = position.z;
numInterior = 2 * i + 2;
for (j = 1; j < numInterior - 1; ++j) {
t = j / (numInterior - 1);
interiorPosition = Cartesian3_default.lerp(
position,
reflectedPosition,
t,
scratchCartesian34
);
positions[positionIndex++] = interiorPosition.x;
positions[positionIndex++] = interiorPosition.y;
positions[positionIndex++] = interiorPosition.z;
}
positions[positionIndex++] = reflectedPosition.x;
positions[positionIndex++] = reflectedPosition.y;
positions[positionIndex++] = reflectedPosition.z;
}
if (addEdgePositions) {
outerPositions[outerRightIndex--] = position.z;
outerPositions[outerRightIndex--] = position.y;
outerPositions[outerRightIndex--] = position.x;
outerPositions[outerLeftIndex++] = reflectedPosition.x;
outerPositions[outerLeftIndex++] = reflectedPosition.y;
outerPositions[outerLeftIndex++] = reflectedPosition.z;
}
theta = Math_default.PI_OVER_TWO - (i + 1) * deltaTheta;
}
for (i = numPts; i > 1; --i) {
theta = Math_default.PI_OVER_TWO - (i - 1) * deltaTheta;
position = pointOnEllipsoid(
-theta,
rotation,
northVec,
eastVec,
aSqr,
ab,
bSqr,
mag,
unitPos,
position
);
reflectedPosition = pointOnEllipsoid(
theta + Math.PI,
rotation,
northVec,
eastVec,
aSqr,
ab,
bSqr,
mag,
unitPos,
reflectedPosition
);
if (addFillPositions) {
positions[positionIndex++] = position.x;
positions[positionIndex++] = position.y;
positions[positionIndex++] = position.z;
numInterior = 2 * (i - 1) + 2;
for (j = 1; j < numInterior - 1; ++j) {
t = j / (numInterior - 1);
interiorPosition = Cartesian3_default.lerp(
position,
reflectedPosition,
t,
scratchCartesian34
);
positions[positionIndex++] = interiorPosition.x;
positions[positionIndex++] = interiorPosition.y;
positions[positionIndex++] = interiorPosition.z;
}
positions[positionIndex++] = reflectedPosition.x;
positions[positionIndex++] = reflectedPosition.y;
positions[positionIndex++] = reflectedPosition.z;
}
if (addEdgePositions) {
outerPositions[outerRightIndex--] = position.z;
outerPositions[outerRightIndex--] = position.y;
outerPositions[outerRightIndex--] = position.x;
outerPositions[outerLeftIndex++] = reflectedPosition.x;
outerPositions[outerLeftIndex++] = reflectedPosition.y;
outerPositions[outerLeftIndex++] = reflectedPosition.z;
}
}
theta = Math_default.PI_OVER_TWO;
position = pointOnEllipsoid(
-theta,
rotation,
northVec,
eastVec,
aSqr,
ab,
bSqr,
mag,
unitPos,
position
);
const r = {};
if (addFillPositions) {
positions[positionIndex++] = position.x;
positions[positionIndex++] = position.y;
positions[positionIndex++] = position.z;
r.positions = positions;
r.numPts = numPts;
}
if (addEdgePositions) {
outerPositions[outerRightIndex--] = position.z;
outerPositions[outerRightIndex--] = position.y;
outerPositions[outerRightIndex--] = position.x;
r.outerPositions = outerPositions;
}
return r;
};
var EllipseGeometryLibrary_default = EllipseGeometryLibrary;
// Source/Core/GeometryInstance.js
function GeometryInstance(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
if (!defined_default(options.geometry)) {
throw new DeveloperError_default("options.geometry is required.");
}
this.geometry = options.geometry;
this.modelMatrix = Matrix4_default.clone(
defaultValue_default(options.modelMatrix, Matrix4_default.IDENTITY)
);
this.id = options.id;
this.pickPrimitive = options.pickPrimitive;
this.attributes = defaultValue_default(options.attributes, {});
this.westHemisphereGeometry = void 0;
this.eastHemisphereGeometry = void 0;
}
var GeometryInstance_default = GeometryInstance;
// Source/Core/EncodedCartesian3.js
function EncodedCartesian3() {
this.high = Cartesian3_default.clone(Cartesian3_default.ZERO);
this.low = Cartesian3_default.clone(Cartesian3_default.ZERO);
}
EncodedCartesian3.encode = function(value, result) {
Check_default.typeOf.number("value", value);
if (!defined_default(result)) {
result = {
high: 0,
low: 0
};
}
let doubleHigh;
if (value >= 0) {
doubleHigh = Math.floor(value / 65536) * 65536;
result.high = doubleHigh;
result.low = value - doubleHigh;
} else {
doubleHigh = Math.floor(-value / 65536) * 65536;
result.high = -doubleHigh;
result.low = value + doubleHigh;
}
return result;
};
var scratchEncode = {
high: 0,
low: 0
};
EncodedCartesian3.fromCartesian = function(cartesian11, result) {
Check_default.typeOf.object("cartesian", cartesian11);
if (!defined_default(result)) {
result = new EncodedCartesian3();
}
const high = result.high;
const low = result.low;
EncodedCartesian3.encode(cartesian11.x, scratchEncode);
high.x = scratchEncode.high;
low.x = scratchEncode.low;
EncodedCartesian3.encode(cartesian11.y, scratchEncode);
high.y = scratchEncode.high;
low.y = scratchEncode.low;
EncodedCartesian3.encode(cartesian11.z, scratchEncode);
high.z = scratchEncode.high;
low.z = scratchEncode.low;
return result;
};
var encodedP = new EncodedCartesian3();
EncodedCartesian3.writeElements = function(cartesian11, cartesianArray, index) {
Check_default.defined("cartesianArray", cartesianArray);
Check_default.typeOf.number("index", index);
Check_default.typeOf.number.greaterThanOrEquals("index", index, 0);
EncodedCartesian3.fromCartesian(cartesian11, encodedP);
const high = encodedP.high;
const low = encodedP.low;
cartesianArray[index] = high.x;
cartesianArray[index + 1] = high.y;
cartesianArray[index + 2] = high.z;
cartesianArray[index + 3] = low.x;
cartesianArray[index + 4] = low.y;
cartesianArray[index + 5] = low.z;
};
var EncodedCartesian3_default = EncodedCartesian3;
// Source/Core/Tipsify.js
var Tipsify = {};
Tipsify.calculateACMR = function(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
const indices2 = options.indices;
let maximumIndex = options.maximumIndex;
const cacheSize = defaultValue_default(options.cacheSize, 24);
if (!defined_default(indices2)) {
throw new DeveloperError_default("indices is required.");
}
const numIndices = indices2.length;
if (numIndices < 3 || numIndices % 3 !== 0) {
throw new DeveloperError_default("indices length must be a multiple of three.");
}
if (maximumIndex <= 0) {
throw new DeveloperError_default("maximumIndex must be greater than zero.");
}
if (cacheSize < 3) {
throw new DeveloperError_default("cacheSize must be greater than two.");
}
if (!defined_default(maximumIndex)) {
maximumIndex = 0;
let currentIndex = 0;
let intoIndices = indices2[currentIndex];
while (currentIndex < numIndices) {
if (intoIndices > maximumIndex) {
maximumIndex = intoIndices;
}
++currentIndex;
intoIndices = indices2[currentIndex];
}
}
const vertexTimeStamps = [];
for (let i = 0; i < maximumIndex + 1; i++) {
vertexTimeStamps[i] = 0;
}
let s = cacheSize + 1;
for (let j = 0; j < numIndices; ++j) {
if (s - vertexTimeStamps[indices2[j]] > cacheSize) {
vertexTimeStamps[indices2[j]] = s;
++s;
}
}
return (s - cacheSize + 1) / (numIndices / 3);
};
Tipsify.tipsify = function(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
const indices2 = options.indices;
const maximumIndex = options.maximumIndex;
const cacheSize = defaultValue_default(options.cacheSize, 24);
let cursor;
function skipDeadEnd(vertices2, deadEnd2, indices3, maximumIndexPlusOne2) {
while (deadEnd2.length >= 1) {
const d = deadEnd2[deadEnd2.length - 1];
deadEnd2.splice(deadEnd2.length - 1, 1);
if (vertices2[d].numLiveTriangles > 0) {
return d;
}
}
while (cursor < maximumIndexPlusOne2) {
if (vertices2[cursor].numLiveTriangles > 0) {
++cursor;
return cursor - 1;
}
++cursor;
}
return -1;
}
function getNextVertex(indices3, cacheSize2, oneRing2, vertices2, s2, deadEnd2, maximumIndexPlusOne2) {
let n = -1;
let p;
let m = -1;
let itOneRing = 0;
while (itOneRing < oneRing2.length) {
const index2 = oneRing2[itOneRing];
if (vertices2[index2].numLiveTriangles) {
p = 0;
if (s2 - vertices2[index2].timeStamp + 2 * vertices2[index2].numLiveTriangles <= cacheSize2) {
p = s2 - vertices2[index2].timeStamp;
}
if (p > m || m === -1) {
m = p;
n = index2;
}
}
++itOneRing;
}
if (n === -1) {
return skipDeadEnd(vertices2, deadEnd2, indices3, maximumIndexPlusOne2);
}
return n;
}
if (!defined_default(indices2)) {
throw new DeveloperError_default("indices is required.");
}
const numIndices = indices2.length;
if (numIndices < 3 || numIndices % 3 !== 0) {
throw new DeveloperError_default("indices length must be a multiple of three.");
}
if (maximumIndex <= 0) {
throw new DeveloperError_default("maximumIndex must be greater than zero.");
}
if (cacheSize < 3) {
throw new DeveloperError_default("cacheSize must be greater than two.");
}
let maximumIndexPlusOne = 0;
let currentIndex = 0;
let intoIndices = indices2[currentIndex];
const endIndex = numIndices;
if (defined_default(maximumIndex)) {
maximumIndexPlusOne = maximumIndex + 1;
} else {
while (currentIndex < endIndex) {
if (intoIndices > maximumIndexPlusOne) {
maximumIndexPlusOne = intoIndices;
}
++currentIndex;
intoIndices = indices2[currentIndex];
}
if (maximumIndexPlusOne === -1) {
return 0;
}
++maximumIndexPlusOne;
}
const vertices = [];
let i;
for (i = 0; i < maximumIndexPlusOne; i++) {
vertices[i] = {
numLiveTriangles: 0,
timeStamp: 0,
vertexTriangles: []
};
}
currentIndex = 0;
let triangle = 0;
while (currentIndex < endIndex) {
vertices[indices2[currentIndex]].vertexTriangles.push(triangle);
++vertices[indices2[currentIndex]].numLiveTriangles;
vertices[indices2[currentIndex + 1]].vertexTriangles.push(triangle);
++vertices[indices2[currentIndex + 1]].numLiveTriangles;
vertices[indices2[currentIndex + 2]].vertexTriangles.push(triangle);
++vertices[indices2[currentIndex + 2]].numLiveTriangles;
++triangle;
currentIndex += 3;
}
let f = 0;
let s = cacheSize + 1;
cursor = 1;
let oneRing = [];
const deadEnd = [];
let vertex;
let intoVertices;
let currentOutputIndex = 0;
const outputIndices = [];
const numTriangles = numIndices / 3;
const triangleEmitted = [];
for (i = 0; i < numTriangles; i++) {
triangleEmitted[i] = false;
}
let index;
let limit;
while (f !== -1) {
oneRing = [];
intoVertices = vertices[f];
limit = intoVertices.vertexTriangles.length;
for (let k = 0; k < limit; ++k) {
triangle = intoVertices.vertexTriangles[k];
if (!triangleEmitted[triangle]) {
triangleEmitted[triangle] = true;
currentIndex = triangle + triangle + triangle;
for (let j = 0; j < 3; ++j) {
index = indices2[currentIndex];
oneRing.push(index);
deadEnd.push(index);
outputIndices[currentOutputIndex] = index;
++currentOutputIndex;
vertex = vertices[index];
--vertex.numLiveTriangles;
if (s - vertex.timeStamp > cacheSize) {
vertex.timeStamp = s;
++s;
}
++currentIndex;
}
}
}
f = getNextVertex(
indices2,
cacheSize,
oneRing,
vertices,
s,
deadEnd,
maximumIndexPlusOne
);
}
return outputIndices;
};
var Tipsify_default = Tipsify;
// Source/Core/GeometryPipeline.js
var GeometryPipeline = {};
function addTriangle(lines, index, i0, i1, i2) {
lines[index++] = i0;
lines[index++] = i1;
lines[index++] = i1;
lines[index++] = i2;
lines[index++] = i2;
lines[index] = i0;
}
function trianglesToLines(triangles) {
const count = triangles.length;
const size = count / 3 * 6;
const lines = IndexDatatype_default.createTypedArray(count, size);
let index = 0;
for (let i = 0; i < count; i += 3, index += 6) {
addTriangle(lines, index, triangles[i], triangles[i + 1], triangles[i + 2]);
}
return lines;
}
function triangleStripToLines(triangles) {
const count = triangles.length;
if (count >= 3) {
const size = (count - 2) * 6;
const lines = IndexDatatype_default.createTypedArray(count, size);
addTriangle(lines, 0, triangles[0], triangles[1], triangles[2]);
let index = 6;
for (let i = 3; i < count; ++i, index += 6) {
addTriangle(
lines,
index,
triangles[i - 1],
triangles[i],
triangles[i - 2]
);
}
return lines;
}
return new Uint16Array();
}
function triangleFanToLines(triangles) {
if (triangles.length > 0) {
const count = triangles.length - 1;
const size = (count - 1) * 6;
const lines = IndexDatatype_default.createTypedArray(count, size);
const base = triangles[0];
let index = 0;
for (let i = 1; i < count; ++i, index += 6) {
addTriangle(lines, index, base, triangles[i], triangles[i + 1]);
}
return lines;
}
return new Uint16Array();
}
GeometryPipeline.toWireframe = function(geometry) {
if (!defined_default(geometry)) {
throw new DeveloperError_default("geometry is required.");
}
const indices2 = geometry.indices;
if (defined_default(indices2)) {
switch (geometry.primitiveType) {
case PrimitiveType_default.TRIANGLES:
geometry.indices = trianglesToLines(indices2);
break;
case PrimitiveType_default.TRIANGLE_STRIP:
geometry.indices = triangleStripToLines(indices2);
break;
case PrimitiveType_default.TRIANGLE_FAN:
geometry.indices = triangleFanToLines(indices2);
break;
default:
throw new DeveloperError_default(
"geometry.primitiveType must be TRIANGLES, TRIANGLE_STRIP, or TRIANGLE_FAN."
);
}
geometry.primitiveType = PrimitiveType_default.LINES;
}
return geometry;
};
GeometryPipeline.createLineSegmentsForVectors = function(geometry, attributeName, length3) {
attributeName = defaultValue_default(attributeName, "normal");
if (!defined_default(geometry)) {
throw new DeveloperError_default("geometry is required.");
}
if (!defined_default(geometry.attributes.position)) {
throw new DeveloperError_default("geometry.attributes.position is required.");
}
if (!defined_default(geometry.attributes[attributeName])) {
throw new DeveloperError_default(
`geometry.attributes must have an attribute with the same name as the attributeName parameter, ${attributeName}.`
);
}
length3 = defaultValue_default(length3, 1e4);
const positions = geometry.attributes.position.values;
const vectors = geometry.attributes[attributeName].values;
const positionsLength = positions.length;
const newPositions = new Float64Array(2 * positionsLength);
let j = 0;
for (let i = 0; i < positionsLength; i += 3) {
newPositions[j++] = positions[i];
newPositions[j++] = positions[i + 1];
newPositions[j++] = positions[i + 2];
newPositions[j++] = positions[i] + vectors[i] * length3;
newPositions[j++] = positions[i + 1] + vectors[i + 1] * length3;
newPositions[j++] = positions[i + 2] + vectors[i + 2] * length3;
}
let newBoundingSphere;
const bs = geometry.boundingSphere;
if (defined_default(bs)) {
newBoundingSphere = new BoundingSphere_default(bs.center, bs.radius + length3);
}
return new Geometry_default({
attributes: {
position: new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.DOUBLE,
componentsPerAttribute: 3,
values: newPositions
})
},
primitiveType: PrimitiveType_default.LINES,
boundingSphere: newBoundingSphere
});
};
GeometryPipeline.createAttributeLocations = function(geometry) {
if (!defined_default(geometry)) {
throw new DeveloperError_default("geometry is required.");
}
const semantics = [
"position",
"positionHigh",
"positionLow",
"position3DHigh",
"position3DLow",
"position2DHigh",
"position2DLow",
"pickColor",
"normal",
"st",
"tangent",
"bitangent",
"extrudeDirection",
"compressedAttributes"
];
const attributes = geometry.attributes;
const indices2 = {};
let j = 0;
let i;
const len = semantics.length;
for (i = 0; i < len; ++i) {
const semantic = semantics[i];
if (defined_default(attributes[semantic])) {
indices2[semantic] = j++;
}
}
for (const name in attributes) {
if (attributes.hasOwnProperty(name) && !defined_default(indices2[name])) {
indices2[name] = j++;
}
}
return indices2;
};
GeometryPipeline.reorderForPreVertexCache = function(geometry) {
if (!defined_default(geometry)) {
throw new DeveloperError_default("geometry is required.");
}
const numVertices = Geometry_default.computeNumberOfVertices(geometry);
const indices2 = geometry.indices;
if (defined_default(indices2)) {
const indexCrossReferenceOldToNew = new Int32Array(numVertices);
for (let i = 0; i < numVertices; i++) {
indexCrossReferenceOldToNew[i] = -1;
}
const indicesIn = indices2;
const numIndices = indicesIn.length;
const indicesOut = IndexDatatype_default.createTypedArray(numVertices, numIndices);
let intoIndicesIn = 0;
let intoIndicesOut = 0;
let nextIndex = 0;
let tempIndex;
while (intoIndicesIn < numIndices) {
tempIndex = indexCrossReferenceOldToNew[indicesIn[intoIndicesIn]];
if (tempIndex !== -1) {
indicesOut[intoIndicesOut] = tempIndex;
} else {
tempIndex = indicesIn[intoIndicesIn];
indexCrossReferenceOldToNew[tempIndex] = nextIndex;
indicesOut[intoIndicesOut] = nextIndex;
++nextIndex;
}
++intoIndicesIn;
++intoIndicesOut;
}
geometry.indices = indicesOut;
const attributes = geometry.attributes;
for (const property in attributes) {
if (attributes.hasOwnProperty(property) && defined_default(attributes[property]) && defined_default(attributes[property].values)) {
const attribute = attributes[property];
const elementsIn = attribute.values;
let intoElementsIn = 0;
const numComponents = attribute.componentsPerAttribute;
const elementsOut = ComponentDatatype_default.createTypedArray(
attribute.componentDatatype,
nextIndex * numComponents
);
while (intoElementsIn < numVertices) {
const temp = indexCrossReferenceOldToNew[intoElementsIn];
if (temp !== -1) {
for (let j = 0; j < numComponents; j++) {
elementsOut[numComponents * temp + j] = elementsIn[numComponents * intoElementsIn + j];
}
}
++intoElementsIn;
}
attribute.values = elementsOut;
}
}
}
return geometry;
};
GeometryPipeline.reorderForPostVertexCache = function(geometry, cacheCapacity) {
if (!defined_default(geometry)) {
throw new DeveloperError_default("geometry is required.");
}
const indices2 = geometry.indices;
if (geometry.primitiveType === PrimitiveType_default.TRIANGLES && defined_default(indices2)) {
const numIndices = indices2.length;
let maximumIndex = 0;
for (let j = 0; j < numIndices; j++) {
if (indices2[j] > maximumIndex) {
maximumIndex = indices2[j];
}
}
geometry.indices = Tipsify_default.tipsify({
indices: indices2,
maximumIndex,
cacheSize: cacheCapacity
});
}
return geometry;
};
function copyAttributesDescriptions(attributes) {
const newAttributes = {};
for (const attribute in attributes) {
if (attributes.hasOwnProperty(attribute) && defined_default(attributes[attribute]) && defined_default(attributes[attribute].values)) {
const attr = attributes[attribute];
newAttributes[attribute] = new GeometryAttribute_default({
componentDatatype: attr.componentDatatype,
componentsPerAttribute: attr.componentsPerAttribute,
normalize: attr.normalize,
values: []
});
}
}
return newAttributes;
}
function copyVertex(destinationAttributes, sourceAttributes, index) {
for (const attribute in sourceAttributes) {
if (sourceAttributes.hasOwnProperty(attribute) && defined_default(sourceAttributes[attribute]) && defined_default(sourceAttributes[attribute].values)) {
const attr = sourceAttributes[attribute];
for (let k = 0; k < attr.componentsPerAttribute; ++k) {
destinationAttributes[attribute].values.push(
attr.values[index * attr.componentsPerAttribute + k]
);
}
}
}
}
GeometryPipeline.fitToUnsignedShortIndices = function(geometry) {
if (!defined_default(geometry)) {
throw new DeveloperError_default("geometry is required.");
}
if (defined_default(geometry.indices) && geometry.primitiveType !== PrimitiveType_default.TRIANGLES && geometry.primitiveType !== PrimitiveType_default.LINES && geometry.primitiveType !== PrimitiveType_default.POINTS) {
throw new DeveloperError_default(
"geometry.primitiveType must equal to PrimitiveType.TRIANGLES, PrimitiveType.LINES, or PrimitiveType.POINTS."
);
}
const geometries = [];
const numberOfVertices = Geometry_default.computeNumberOfVertices(geometry);
if (defined_default(geometry.indices) && numberOfVertices >= Math_default.SIXTY_FOUR_KILOBYTES) {
let oldToNewIndex = [];
let newIndices = [];
let currentIndex = 0;
let newAttributes = copyAttributesDescriptions(geometry.attributes);
const originalIndices = geometry.indices;
const numberOfIndices = originalIndices.length;
let indicesPerPrimitive;
if (geometry.primitiveType === PrimitiveType_default.TRIANGLES) {
indicesPerPrimitive = 3;
} else if (geometry.primitiveType === PrimitiveType_default.LINES) {
indicesPerPrimitive = 2;
} else if (geometry.primitiveType === PrimitiveType_default.POINTS) {
indicesPerPrimitive = 1;
}
for (let j = 0; j < numberOfIndices; j += indicesPerPrimitive) {
for (let k = 0; k < indicesPerPrimitive; ++k) {
const x = originalIndices[j + k];
let i = oldToNewIndex[x];
if (!defined_default(i)) {
i = currentIndex++;
oldToNewIndex[x] = i;
copyVertex(newAttributes, geometry.attributes, x);
}
newIndices.push(i);
}
if (currentIndex + indicesPerPrimitive >= Math_default.SIXTY_FOUR_KILOBYTES) {
geometries.push(
new Geometry_default({
attributes: newAttributes,
indices: newIndices,
primitiveType: geometry.primitiveType,
boundingSphere: geometry.boundingSphere,
boundingSphereCV: geometry.boundingSphereCV
})
);
oldToNewIndex = [];
newIndices = [];
currentIndex = 0;
newAttributes = copyAttributesDescriptions(geometry.attributes);
}
}
if (newIndices.length !== 0) {
geometries.push(
new Geometry_default({
attributes: newAttributes,
indices: newIndices,
primitiveType: geometry.primitiveType,
boundingSphere: geometry.boundingSphere,
boundingSphereCV: geometry.boundingSphereCV
})
);
}
} else {
geometries.push(geometry);
}
return geometries;
};
var scratchProjectTo2DCartesian3 = new Cartesian3_default();
var scratchProjectTo2DCartographic = new Cartographic_default();
GeometryPipeline.projectTo2D = function(geometry, attributeName, attributeName3D, attributeName2D, projection) {
if (!defined_default(geometry)) {
throw new DeveloperError_default("geometry is required.");
}
if (!defined_default(attributeName)) {
throw new DeveloperError_default("attributeName is required.");
}
if (!defined_default(attributeName3D)) {
throw new DeveloperError_default("attributeName3D is required.");
}
if (!defined_default(attributeName2D)) {
throw new DeveloperError_default("attributeName2D is required.");
}
if (!defined_default(geometry.attributes[attributeName])) {
throw new DeveloperError_default(
`geometry must have attribute matching the attributeName argument: ${attributeName}.`
);
}
if (geometry.attributes[attributeName].componentDatatype !== ComponentDatatype_default.DOUBLE) {
throw new DeveloperError_default(
"The attribute componentDatatype must be ComponentDatatype.DOUBLE."
);
}
const attribute = geometry.attributes[attributeName];
projection = defined_default(projection) ? projection : new GeographicProjection_default();
const ellipsoid = projection.ellipsoid;
const values3D = attribute.values;
const projectedValues = new Float64Array(values3D.length);
let index = 0;
for (let i = 0; i < values3D.length; i += 3) {
const value = Cartesian3_default.fromArray(
values3D,
i,
scratchProjectTo2DCartesian3
);
const lonLat = ellipsoid.cartesianToCartographic(
value,
scratchProjectTo2DCartographic
);
if (!defined_default(lonLat)) {
throw new DeveloperError_default(
`Could not project point (${value.x}, ${value.y}, ${value.z}) to 2D.`
);
}
const projectedLonLat = projection.project(
lonLat,
scratchProjectTo2DCartesian3
);
projectedValues[index++] = projectedLonLat.x;
projectedValues[index++] = projectedLonLat.y;
projectedValues[index++] = projectedLonLat.z;
}
geometry.attributes[attributeName3D] = attribute;
geometry.attributes[attributeName2D] = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.DOUBLE,
componentsPerAttribute: 3,
values: projectedValues
});
delete geometry.attributes[attributeName];
return geometry;
};
var encodedResult = {
high: 0,
low: 0
};
GeometryPipeline.encodeAttribute = function(geometry, attributeName, attributeHighName, attributeLowName) {
if (!defined_default(geometry)) {
throw new DeveloperError_default("geometry is required.");
}
if (!defined_default(attributeName)) {
throw new DeveloperError_default("attributeName is required.");
}
if (!defined_default(attributeHighName)) {
throw new DeveloperError_default("attributeHighName is required.");
}
if (!defined_default(attributeLowName)) {
throw new DeveloperError_default("attributeLowName is required.");
}
if (!defined_default(geometry.attributes[attributeName])) {
throw new DeveloperError_default(
`geometry must have attribute matching the attributeName argument: ${attributeName}.`
);
}
if (geometry.attributes[attributeName].componentDatatype !== ComponentDatatype_default.DOUBLE) {
throw new DeveloperError_default(
"The attribute componentDatatype must be ComponentDatatype.DOUBLE."
);
}
const attribute = geometry.attributes[attributeName];
const values = attribute.values;
const length3 = values.length;
const highValues = new Float32Array(length3);
const lowValues = new Float32Array(length3);
for (let i = 0; i < length3; ++i) {
EncodedCartesian3_default.encode(values[i], encodedResult);
highValues[i] = encodedResult.high;
lowValues[i] = encodedResult.low;
}
const componentsPerAttribute = attribute.componentsPerAttribute;
geometry.attributes[attributeHighName] = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.FLOAT,
componentsPerAttribute,
values: highValues
});
geometry.attributes[attributeLowName] = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.FLOAT,
componentsPerAttribute,
values: lowValues
});
delete geometry.attributes[attributeName];
return geometry;
};
var scratchCartesian35 = new Cartesian3_default();
function transformPoint(matrix, attribute) {
if (defined_default(attribute)) {
const values = attribute.values;
const length3 = values.length;
for (let i = 0; i < length3; i += 3) {
Cartesian3_default.unpack(values, i, scratchCartesian35);
Matrix4_default.multiplyByPoint(matrix, scratchCartesian35, scratchCartesian35);
Cartesian3_default.pack(scratchCartesian35, values, i);
}
}
}
function transformVector(matrix, attribute) {
if (defined_default(attribute)) {
const values = attribute.values;
const length3 = values.length;
for (let i = 0; i < length3; i += 3) {
Cartesian3_default.unpack(values, i, scratchCartesian35);
Matrix3_default.multiplyByVector(matrix, scratchCartesian35, scratchCartesian35);
scratchCartesian35 = Cartesian3_default.normalize(
scratchCartesian35,
scratchCartesian35
);
Cartesian3_default.pack(scratchCartesian35, values, i);
}
}
}
var inverseTranspose = new Matrix4_default();
var normalMatrix = new Matrix3_default();
GeometryPipeline.transformToWorldCoordinates = function(instance) {
if (!defined_default(instance)) {
throw new DeveloperError_default("instance is required.");
}
const modelMatrix = instance.modelMatrix;
if (Matrix4_default.equals(modelMatrix, Matrix4_default.IDENTITY)) {
return instance;
}
const attributes = instance.geometry.attributes;
transformPoint(modelMatrix, attributes.position);
transformPoint(modelMatrix, attributes.prevPosition);
transformPoint(modelMatrix, attributes.nextPosition);
if (defined_default(attributes.normal) || defined_default(attributes.tangent) || defined_default(attributes.bitangent)) {
Matrix4_default.inverse(modelMatrix, inverseTranspose);
Matrix4_default.transpose(inverseTranspose, inverseTranspose);
Matrix4_default.getMatrix3(inverseTranspose, normalMatrix);
transformVector(normalMatrix, attributes.normal);
transformVector(normalMatrix, attributes.tangent);
transformVector(normalMatrix, attributes.bitangent);
}
const boundingSphere = instance.geometry.boundingSphere;
if (defined_default(boundingSphere)) {
instance.geometry.boundingSphere = BoundingSphere_default.transform(
boundingSphere,
modelMatrix,
boundingSphere
);
}
instance.modelMatrix = Matrix4_default.clone(Matrix4_default.IDENTITY);
return instance;
};
function findAttributesInAllGeometries(instances, propertyName) {
const length3 = instances.length;
const attributesInAllGeometries = {};
const attributes0 = instances[0][propertyName].attributes;
let name;
for (name in attributes0) {
if (attributes0.hasOwnProperty(name) && defined_default(attributes0[name]) && defined_default(attributes0[name].values)) {
const attribute = attributes0[name];
let numberOfComponents = attribute.values.length;
let inAllGeometries = true;
for (let i = 1; i < length3; ++i) {
const otherAttribute = instances[i][propertyName].attributes[name];
if (!defined_default(otherAttribute) || attribute.componentDatatype !== otherAttribute.componentDatatype || attribute.componentsPerAttribute !== otherAttribute.componentsPerAttribute || attribute.normalize !== otherAttribute.normalize) {
inAllGeometries = false;
break;
}
numberOfComponents += otherAttribute.values.length;
}
if (inAllGeometries) {
attributesInAllGeometries[name] = new GeometryAttribute_default({
componentDatatype: attribute.componentDatatype,
componentsPerAttribute: attribute.componentsPerAttribute,
normalize: attribute.normalize,
values: ComponentDatatype_default.createTypedArray(
attribute.componentDatatype,
numberOfComponents
)
});
}
}
}
return attributesInAllGeometries;
}
var tempScratch = new Cartesian3_default();
function combineGeometries(instances, propertyName) {
const length3 = instances.length;
let name;
let i;
let j;
let k;
const m = instances[0].modelMatrix;
const haveIndices = defined_default(instances[0][propertyName].indices);
const primitiveType = instances[0][propertyName].primitiveType;
for (i = 1; i < length3; ++i) {
if (!Matrix4_default.equals(instances[i].modelMatrix, m)) {
throw new DeveloperError_default("All instances must have the same modelMatrix.");
}
if (defined_default(instances[i][propertyName].indices) !== haveIndices) {
throw new DeveloperError_default(
"All instance geometries must have an indices or not have one."
);
}
if (instances[i][propertyName].primitiveType !== primitiveType) {
throw new DeveloperError_default(
"All instance geometries must have the same primitiveType."
);
}
}
const attributes = findAttributesInAllGeometries(instances, propertyName);
let values;
let sourceValues;
let sourceValuesLength;
for (name in attributes) {
if (attributes.hasOwnProperty(name)) {
values = attributes[name].values;
k = 0;
for (i = 0; i < length3; ++i) {
sourceValues = instances[i][propertyName].attributes[name].values;
sourceValuesLength = sourceValues.length;
for (j = 0; j < sourceValuesLength; ++j) {
values[k++] = sourceValues[j];
}
}
}
}
let indices2;
if (haveIndices) {
let numberOfIndices = 0;
for (i = 0; i < length3; ++i) {
numberOfIndices += instances[i][propertyName].indices.length;
}
const numberOfVertices = Geometry_default.computeNumberOfVertices(
new Geometry_default({
attributes,
primitiveType: PrimitiveType_default.POINTS
})
);
const destIndices = IndexDatatype_default.createTypedArray(
numberOfVertices,
numberOfIndices
);
let destOffset = 0;
let offset2 = 0;
for (i = 0; i < length3; ++i) {
const sourceIndices = instances[i][propertyName].indices;
const sourceIndicesLen = sourceIndices.length;
for (k = 0; k < sourceIndicesLen; ++k) {
destIndices[destOffset++] = offset2 + sourceIndices[k];
}
offset2 += Geometry_default.computeNumberOfVertices(instances[i][propertyName]);
}
indices2 = destIndices;
}
let center = new Cartesian3_default();
let radius = 0;
let bs;
for (i = 0; i < length3; ++i) {
bs = instances[i][propertyName].boundingSphere;
if (!defined_default(bs)) {
center = void 0;
break;
}
Cartesian3_default.add(bs.center, center, center);
}
if (defined_default(center)) {
Cartesian3_default.divideByScalar(center, length3, center);
for (i = 0; i < length3; ++i) {
bs = instances[i][propertyName].boundingSphere;
const tempRadius = Cartesian3_default.magnitude(
Cartesian3_default.subtract(bs.center, center, tempScratch)
) + bs.radius;
if (tempRadius > radius) {
radius = tempRadius;
}
}
}
return new Geometry_default({
attributes,
indices: indices2,
primitiveType,
boundingSphere: defined_default(center) ? new BoundingSphere_default(center, radius) : void 0
});
}
GeometryPipeline.combineInstances = function(instances) {
if (!defined_default(instances) || instances.length < 1) {
throw new DeveloperError_default(
"instances is required and must have length greater than zero."
);
}
const instanceGeometry = [];
const instanceSplitGeometry = [];
const length3 = instances.length;
for (let i = 0; i < length3; ++i) {
const instance = instances[i];
if (defined_default(instance.geometry)) {
instanceGeometry.push(instance);
} else if (defined_default(instance.westHemisphereGeometry) && defined_default(instance.eastHemisphereGeometry)) {
instanceSplitGeometry.push(instance);
}
}
const geometries = [];
if (instanceGeometry.length > 0) {
geometries.push(combineGeometries(instanceGeometry, "geometry"));
}
if (instanceSplitGeometry.length > 0) {
geometries.push(
combineGeometries(instanceSplitGeometry, "westHemisphereGeometry")
);
geometries.push(
combineGeometries(instanceSplitGeometry, "eastHemisphereGeometry")
);
}
return geometries;
};
var normal = new Cartesian3_default();
var v0 = new Cartesian3_default();
var v1 = new Cartesian3_default();
var v2 = new Cartesian3_default();
GeometryPipeline.computeNormal = function(geometry) {
if (!defined_default(geometry)) {
throw new DeveloperError_default("geometry is required.");
}
if (!defined_default(geometry.attributes.position) || !defined_default(geometry.attributes.position.values)) {
throw new DeveloperError_default(
"geometry.attributes.position.values is required."
);
}
if (!defined_default(geometry.indices)) {
throw new DeveloperError_default("geometry.indices is required.");
}
if (geometry.indices.length < 2 || geometry.indices.length % 3 !== 0) {
throw new DeveloperError_default(
"geometry.indices length must be greater than 0 and be a multiple of 3."
);
}
if (geometry.primitiveType !== PrimitiveType_default.TRIANGLES) {
throw new DeveloperError_default(
"geometry.primitiveType must be PrimitiveType.TRIANGLES."
);
}
const indices2 = geometry.indices;
const attributes = geometry.attributes;
const vertices = attributes.position.values;
const numVertices = attributes.position.values.length / 3;
const numIndices = indices2.length;
const normalsPerVertex = new Array(numVertices);
const normalsPerTriangle = new Array(numIndices / 3);
const normalIndices = new Array(numIndices);
let i;
for (i = 0; i < numVertices; i++) {
normalsPerVertex[i] = {
indexOffset: 0,
count: 0,
currentCount: 0
};
}
let j = 0;
for (i = 0; i < numIndices; i += 3) {
const i0 = indices2[i];
const i1 = indices2[i + 1];
const i2 = indices2[i + 2];
const i03 = i0 * 3;
const i13 = i1 * 3;
const i23 = i2 * 3;
v0.x = vertices[i03];
v0.y = vertices[i03 + 1];
v0.z = vertices[i03 + 2];
v1.x = vertices[i13];
v1.y = vertices[i13 + 1];
v1.z = vertices[i13 + 2];
v2.x = vertices[i23];
v2.y = vertices[i23 + 1];
v2.z = vertices[i23 + 2];
normalsPerVertex[i0].count++;
normalsPerVertex[i1].count++;
normalsPerVertex[i2].count++;
Cartesian3_default.subtract(v1, v0, v1);
Cartesian3_default.subtract(v2, v0, v2);
normalsPerTriangle[j] = Cartesian3_default.cross(v1, v2, new Cartesian3_default());
j++;
}
let indexOffset = 0;
for (i = 0; i < numVertices; i++) {
normalsPerVertex[i].indexOffset += indexOffset;
indexOffset += normalsPerVertex[i].count;
}
j = 0;
let vertexNormalData;
for (i = 0; i < numIndices; i += 3) {
vertexNormalData = normalsPerVertex[indices2[i]];
let index = vertexNormalData.indexOffset + vertexNormalData.currentCount;
normalIndices[index] = j;
vertexNormalData.currentCount++;
vertexNormalData = normalsPerVertex[indices2[i + 1]];
index = vertexNormalData.indexOffset + vertexNormalData.currentCount;
normalIndices[index] = j;
vertexNormalData.currentCount++;
vertexNormalData = normalsPerVertex[indices2[i + 2]];
index = vertexNormalData.indexOffset + vertexNormalData.currentCount;
normalIndices[index] = j;
vertexNormalData.currentCount++;
j++;
}
const normalValues = new Float32Array(numVertices * 3);
for (i = 0; i < numVertices; i++) {
const i3 = i * 3;
vertexNormalData = normalsPerVertex[i];
Cartesian3_default.clone(Cartesian3_default.ZERO, normal);
if (vertexNormalData.count > 0) {
for (j = 0; j < vertexNormalData.count; j++) {
Cartesian3_default.add(
normal,
normalsPerTriangle[normalIndices[vertexNormalData.indexOffset + j]],
normal
);
}
if (Cartesian3_default.equalsEpsilon(Cartesian3_default.ZERO, normal, Math_default.EPSILON10)) {
Cartesian3_default.clone(
normalsPerTriangle[normalIndices[vertexNormalData.indexOffset]],
normal
);
}
}
if (Cartesian3_default.equalsEpsilon(Cartesian3_default.ZERO, normal, Math_default.EPSILON10)) {
normal.z = 1;
}
Cartesian3_default.normalize(normal, normal);
normalValues[i3] = normal.x;
normalValues[i3 + 1] = normal.y;
normalValues[i3 + 2] = normal.z;
}
geometry.attributes.normal = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.FLOAT,
componentsPerAttribute: 3,
values: normalValues
});
return geometry;
};
var normalScratch2 = new Cartesian3_default();
var normalScale = new Cartesian3_default();
var tScratch = new Cartesian3_default();
GeometryPipeline.computeTangentAndBitangent = function(geometry) {
if (!defined_default(geometry)) {
throw new DeveloperError_default("geometry is required.");
}
const attributes = geometry.attributes;
const indices2 = geometry.indices;
if (!defined_default(attributes.position) || !defined_default(attributes.position.values)) {
throw new DeveloperError_default(
"geometry.attributes.position.values is required."
);
}
if (!defined_default(attributes.normal) || !defined_default(attributes.normal.values)) {
throw new DeveloperError_default("geometry.attributes.normal.values is required.");
}
if (!defined_default(attributes.st) || !defined_default(attributes.st.values)) {
throw new DeveloperError_default("geometry.attributes.st.values is required.");
}
if (!defined_default(indices2)) {
throw new DeveloperError_default("geometry.indices is required.");
}
if (indices2.length < 2 || indices2.length % 3 !== 0) {
throw new DeveloperError_default(
"geometry.indices length must be greater than 0 and be a multiple of 3."
);
}
if (geometry.primitiveType !== PrimitiveType_default.TRIANGLES) {
throw new DeveloperError_default(
"geometry.primitiveType must be PrimitiveType.TRIANGLES."
);
}
const vertices = geometry.attributes.position.values;
const normals = geometry.attributes.normal.values;
const st = geometry.attributes.st.values;
const numVertices = geometry.attributes.position.values.length / 3;
const numIndices = indices2.length;
const tan1 = new Array(numVertices * 3);
let i;
for (i = 0; i < tan1.length; i++) {
tan1[i] = 0;
}
let i03;
let i13;
let i23;
for (i = 0; i < numIndices; i += 3) {
const i0 = indices2[i];
const i1 = indices2[i + 1];
const i2 = indices2[i + 2];
i03 = i0 * 3;
i13 = i1 * 3;
i23 = i2 * 3;
const i02 = i0 * 2;
const i12 = i1 * 2;
const i22 = i2 * 2;
const ux = vertices[i03];
const uy = vertices[i03 + 1];
const uz = vertices[i03 + 2];
const wx = st[i02];
const wy = st[i02 + 1];
const t1 = st[i12 + 1] - wy;
const t2 = st[i22 + 1] - wy;
const r = 1 / ((st[i12] - wx) * t2 - (st[i22] - wx) * t1);
const sdirx = (t2 * (vertices[i13] - ux) - t1 * (vertices[i23] - ux)) * r;
const sdiry = (t2 * (vertices[i13 + 1] - uy) - t1 * (vertices[i23 + 1] - uy)) * r;
const sdirz = (t2 * (vertices[i13 + 2] - uz) - t1 * (vertices[i23 + 2] - uz)) * r;
tan1[i03] += sdirx;
tan1[i03 + 1] += sdiry;
tan1[i03 + 2] += sdirz;
tan1[i13] += sdirx;
tan1[i13 + 1] += sdiry;
tan1[i13 + 2] += sdirz;
tan1[i23] += sdirx;
tan1[i23 + 1] += sdiry;
tan1[i23 + 2] += sdirz;
}
const tangentValues = new Float32Array(numVertices * 3);
const bitangentValues = new Float32Array(numVertices * 3);
for (i = 0; i < numVertices; i++) {
i03 = i * 3;
i13 = i03 + 1;
i23 = i03 + 2;
const n = Cartesian3_default.fromArray(normals, i03, normalScratch2);
const t = Cartesian3_default.fromArray(tan1, i03, tScratch);
const scalar = Cartesian3_default.dot(n, t);
Cartesian3_default.multiplyByScalar(n, scalar, normalScale);
Cartesian3_default.normalize(Cartesian3_default.subtract(t, normalScale, t), t);
tangentValues[i03] = t.x;
tangentValues[i13] = t.y;
tangentValues[i23] = t.z;
Cartesian3_default.normalize(Cartesian3_default.cross(n, t, t), t);
bitangentValues[i03] = t.x;
bitangentValues[i13] = t.y;
bitangentValues[i23] = t.z;
}
geometry.attributes.tangent = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.FLOAT,
componentsPerAttribute: 3,
values: tangentValues
});
geometry.attributes.bitangent = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.FLOAT,
componentsPerAttribute: 3,
values: bitangentValues
});
return geometry;
};
var scratchCartesian25 = new Cartesian2_default();
var toEncode1 = new Cartesian3_default();
var toEncode2 = new Cartesian3_default();
var toEncode3 = new Cartesian3_default();
var encodeResult2 = new Cartesian2_default();
GeometryPipeline.compressVertices = function(geometry) {
if (!defined_default(geometry)) {
throw new DeveloperError_default("geometry is required.");
}
const extrudeAttribute = geometry.attributes.extrudeDirection;
let i;
let numVertices;
if (defined_default(extrudeAttribute)) {
const extrudeDirections = extrudeAttribute.values;
numVertices = extrudeDirections.length / 3;
const compressedDirections = new Float32Array(numVertices * 2);
let i2 = 0;
for (i = 0; i < numVertices; ++i) {
Cartesian3_default.fromArray(extrudeDirections, i * 3, toEncode1);
if (Cartesian3_default.equals(toEncode1, Cartesian3_default.ZERO)) {
i2 += 2;
continue;
}
encodeResult2 = AttributeCompression_default.octEncodeInRange(
toEncode1,
65535,
encodeResult2
);
compressedDirections[i2++] = encodeResult2.x;
compressedDirections[i2++] = encodeResult2.y;
}
geometry.attributes.compressedAttributes = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.FLOAT,
componentsPerAttribute: 2,
values: compressedDirections
});
delete geometry.attributes.extrudeDirection;
return geometry;
}
const normalAttribute = geometry.attributes.normal;
const stAttribute = geometry.attributes.st;
const hasNormal = defined_default(normalAttribute);
const hasSt = defined_default(stAttribute);
if (!hasNormal && !hasSt) {
return geometry;
}
const tangentAttribute = geometry.attributes.tangent;
const bitangentAttribute = geometry.attributes.bitangent;
const hasTangent = defined_default(tangentAttribute);
const hasBitangent = defined_default(bitangentAttribute);
let normals;
let st;
let tangents;
let bitangents;
if (hasNormal) {
normals = normalAttribute.values;
}
if (hasSt) {
st = stAttribute.values;
}
if (hasTangent) {
tangents = tangentAttribute.values;
}
if (hasBitangent) {
bitangents = bitangentAttribute.values;
}
const length3 = hasNormal ? normals.length : st.length;
const numComponents = hasNormal ? 3 : 2;
numVertices = length3 / numComponents;
let compressedLength = numVertices;
let numCompressedComponents = hasSt && hasNormal ? 2 : 1;
numCompressedComponents += hasTangent || hasBitangent ? 1 : 0;
compressedLength *= numCompressedComponents;
const compressedAttributes = new Float32Array(compressedLength);
let normalIndex = 0;
for (i = 0; i < numVertices; ++i) {
if (hasSt) {
Cartesian2_default.fromArray(st, i * 2, scratchCartesian25);
compressedAttributes[normalIndex++] = AttributeCompression_default.compressTextureCoordinates(scratchCartesian25);
}
const index = i * 3;
if (hasNormal && defined_default(tangents) && defined_default(bitangents)) {
Cartesian3_default.fromArray(normals, index, toEncode1);
Cartesian3_default.fromArray(tangents, index, toEncode2);
Cartesian3_default.fromArray(bitangents, index, toEncode3);
AttributeCompression_default.octPack(
toEncode1,
toEncode2,
toEncode3,
scratchCartesian25
);
compressedAttributes[normalIndex++] = scratchCartesian25.x;
compressedAttributes[normalIndex++] = scratchCartesian25.y;
} else {
if (hasNormal) {
Cartesian3_default.fromArray(normals, index, toEncode1);
compressedAttributes[normalIndex++] = AttributeCompression_default.octEncodeFloat(toEncode1);
}
if (hasTangent) {
Cartesian3_default.fromArray(tangents, index, toEncode1);
compressedAttributes[normalIndex++] = AttributeCompression_default.octEncodeFloat(toEncode1);
}
if (hasBitangent) {
Cartesian3_default.fromArray(bitangents, index, toEncode1);
compressedAttributes[normalIndex++] = AttributeCompression_default.octEncodeFloat(toEncode1);
}
}
}
geometry.attributes.compressedAttributes = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.FLOAT,
componentsPerAttribute: numCompressedComponents,
values: compressedAttributes
});
if (hasNormal) {
delete geometry.attributes.normal;
}
if (hasSt) {
delete geometry.attributes.st;
}
if (hasBitangent) {
delete geometry.attributes.bitangent;
}
if (hasTangent) {
delete geometry.attributes.tangent;
}
return geometry;
};
function indexTriangles(geometry) {
if (defined_default(geometry.indices)) {
return geometry;
}
const numberOfVertices = Geometry_default.computeNumberOfVertices(geometry);
if (numberOfVertices < 3) {
throw new DeveloperError_default("The number of vertices must be at least three.");
}
if (numberOfVertices % 3 !== 0) {
throw new DeveloperError_default(
"The number of vertices must be a multiple of three."
);
}
const indices2 = IndexDatatype_default.createTypedArray(
numberOfVertices,
numberOfVertices
);
for (let i = 0; i < numberOfVertices; ++i) {
indices2[i] = i;
}
geometry.indices = indices2;
return geometry;
}
function indexTriangleFan(geometry) {
const numberOfVertices = Geometry_default.computeNumberOfVertices(geometry);
if (numberOfVertices < 3) {
throw new DeveloperError_default("The number of vertices must be at least three.");
}
const indices2 = IndexDatatype_default.createTypedArray(
numberOfVertices,
(numberOfVertices - 2) * 3
);
indices2[0] = 1;
indices2[1] = 0;
indices2[2] = 2;
let indicesIndex = 3;
for (let i = 3; i < numberOfVertices; ++i) {
indices2[indicesIndex++] = i - 1;
indices2[indicesIndex++] = 0;
indices2[indicesIndex++] = i;
}
geometry.indices = indices2;
geometry.primitiveType = PrimitiveType_default.TRIANGLES;
return geometry;
}
function indexTriangleStrip(geometry) {
const numberOfVertices = Geometry_default.computeNumberOfVertices(geometry);
if (numberOfVertices < 3) {
throw new DeveloperError_default("The number of vertices must be at least 3.");
}
const indices2 = IndexDatatype_default.createTypedArray(
numberOfVertices,
(numberOfVertices - 2) * 3
);
indices2[0] = 0;
indices2[1] = 1;
indices2[2] = 2;
if (numberOfVertices > 3) {
indices2[3] = 0;
indices2[4] = 2;
indices2[5] = 3;
}
let indicesIndex = 6;
for (let i = 3; i < numberOfVertices - 1; i += 2) {
indices2[indicesIndex++] = i;
indices2[indicesIndex++] = i - 1;
indices2[indicesIndex++] = i + 1;
if (i + 2 < numberOfVertices) {
indices2[indicesIndex++] = i;
indices2[indicesIndex++] = i + 1;
indices2[indicesIndex++] = i + 2;
}
}
geometry.indices = indices2;
geometry.primitiveType = PrimitiveType_default.TRIANGLES;
return geometry;
}
function indexLines(geometry) {
if (defined_default(geometry.indices)) {
return geometry;
}
const numberOfVertices = Geometry_default.computeNumberOfVertices(geometry);
if (numberOfVertices < 2) {
throw new DeveloperError_default("The number of vertices must be at least two.");
}
if (numberOfVertices % 2 !== 0) {
throw new DeveloperError_default("The number of vertices must be a multiple of 2.");
}
const indices2 = IndexDatatype_default.createTypedArray(
numberOfVertices,
numberOfVertices
);
for (let i = 0; i < numberOfVertices; ++i) {
indices2[i] = i;
}
geometry.indices = indices2;
return geometry;
}
function indexLineStrip(geometry) {
const numberOfVertices = Geometry_default.computeNumberOfVertices(geometry);
if (numberOfVertices < 2) {
throw new DeveloperError_default("The number of vertices must be at least two.");
}
const indices2 = IndexDatatype_default.createTypedArray(
numberOfVertices,
(numberOfVertices - 1) * 2
);
indices2[0] = 0;
indices2[1] = 1;
let indicesIndex = 2;
for (let i = 2; i < numberOfVertices; ++i) {
indices2[indicesIndex++] = i - 1;
indices2[indicesIndex++] = i;
}
geometry.indices = indices2;
geometry.primitiveType = PrimitiveType_default.LINES;
return geometry;
}
function indexLineLoop(geometry) {
const numberOfVertices = Geometry_default.computeNumberOfVertices(geometry);
if (numberOfVertices < 2) {
throw new DeveloperError_default("The number of vertices must be at least two.");
}
const indices2 = IndexDatatype_default.createTypedArray(
numberOfVertices,
numberOfVertices * 2
);
indices2[0] = 0;
indices2[1] = 1;
let indicesIndex = 2;
for (let i = 2; i < numberOfVertices; ++i) {
indices2[indicesIndex++] = i - 1;
indices2[indicesIndex++] = i;
}
indices2[indicesIndex++] = numberOfVertices - 1;
indices2[indicesIndex] = 0;
geometry.indices = indices2;
geometry.primitiveType = PrimitiveType_default.LINES;
return geometry;
}
function indexPrimitive(geometry) {
switch (geometry.primitiveType) {
case PrimitiveType_default.TRIANGLE_FAN:
return indexTriangleFan(geometry);
case PrimitiveType_default.TRIANGLE_STRIP:
return indexTriangleStrip(geometry);
case PrimitiveType_default.TRIANGLES:
return indexTriangles(geometry);
case PrimitiveType_default.LINE_STRIP:
return indexLineStrip(geometry);
case PrimitiveType_default.LINE_LOOP:
return indexLineLoop(geometry);
case PrimitiveType_default.LINES:
return indexLines(geometry);
}
return geometry;
}
function offsetPointFromXZPlane(p, isBehind) {
if (Math.abs(p.y) < Math_default.EPSILON6) {
if (isBehind) {
p.y = -Math_default.EPSILON6;
} else {
p.y = Math_default.EPSILON6;
}
}
}
function offsetTriangleFromXZPlane(p0, p1, p2) {
if (p0.y !== 0 && p1.y !== 0 && p2.y !== 0) {
offsetPointFromXZPlane(p0, p0.y < 0);
offsetPointFromXZPlane(p1, p1.y < 0);
offsetPointFromXZPlane(p2, p2.y < 0);
return;
}
const p0y = Math.abs(p0.y);
const p1y = Math.abs(p1.y);
const p2y = Math.abs(p2.y);
let sign2;
if (p0y > p1y) {
if (p0y > p2y) {
sign2 = Math_default.sign(p0.y);
} else {
sign2 = Math_default.sign(p2.y);
}
} else if (p1y > p2y) {
sign2 = Math_default.sign(p1.y);
} else {
sign2 = Math_default.sign(p2.y);
}
const isBehind = sign2 < 0;
offsetPointFromXZPlane(p0, isBehind);
offsetPointFromXZPlane(p1, isBehind);
offsetPointFromXZPlane(p2, isBehind);
}
var c3 = new Cartesian3_default();
function getXZIntersectionOffsetPoints(p, p1, u12, v13) {
Cartesian3_default.add(
p,
Cartesian3_default.multiplyByScalar(
Cartesian3_default.subtract(p1, p, c3),
p.y / (p.y - p1.y),
c3
),
u12
);
Cartesian3_default.clone(u12, v13);
offsetPointFromXZPlane(u12, true);
offsetPointFromXZPlane(v13, false);
}
var u1 = new Cartesian3_default();
var u2 = new Cartesian3_default();
var q1 = new Cartesian3_default();
var q2 = new Cartesian3_default();
var splitTriangleResult = {
positions: new Array(7),
indices: new Array(3 * 3)
};
function splitTriangle(p0, p1, p2) {
if (p0.x >= 0 || p1.x >= 0 || p2.x >= 0) {
return void 0;
}
offsetTriangleFromXZPlane(p0, p1, p2);
const p0Behind = p0.y < 0;
const p1Behind = p1.y < 0;
const p2Behind = p2.y < 0;
let numBehind = 0;
numBehind += p0Behind ? 1 : 0;
numBehind += p1Behind ? 1 : 0;
numBehind += p2Behind ? 1 : 0;
const indices2 = splitTriangleResult.indices;
if (numBehind === 1) {
indices2[1] = 3;
indices2[2] = 4;
indices2[5] = 6;
indices2[7] = 6;
indices2[8] = 5;
if (p0Behind) {
getXZIntersectionOffsetPoints(p0, p1, u1, q1);
getXZIntersectionOffsetPoints(p0, p2, u2, q2);
indices2[0] = 0;
indices2[3] = 1;
indices2[4] = 2;
indices2[6] = 1;
} else if (p1Behind) {
getXZIntersectionOffsetPoints(p1, p2, u1, q1);
getXZIntersectionOffsetPoints(p1, p0, u2, q2);
indices2[0] = 1;
indices2[3] = 2;
indices2[4] = 0;
indices2[6] = 2;
} else if (p2Behind) {
getXZIntersectionOffsetPoints(p2, p0, u1, q1);
getXZIntersectionOffsetPoints(p2, p1, u2, q2);
indices2[0] = 2;
indices2[3] = 0;
indices2[4] = 1;
indices2[6] = 0;
}
} else if (numBehind === 2) {
indices2[2] = 4;
indices2[4] = 4;
indices2[5] = 3;
indices2[7] = 5;
indices2[8] = 6;
if (!p0Behind) {
getXZIntersectionOffsetPoints(p0, p1, u1, q1);
getXZIntersectionOffsetPoints(p0, p2, u2, q2);
indices2[0] = 1;
indices2[1] = 2;
indices2[3] = 1;
indices2[6] = 0;
} else if (!p1Behind) {
getXZIntersectionOffsetPoints(p1, p2, u1, q1);
getXZIntersectionOffsetPoints(p1, p0, u2, q2);
indices2[0] = 2;
indices2[1] = 0;
indices2[3] = 2;
indices2[6] = 1;
} else if (!p2Behind) {
getXZIntersectionOffsetPoints(p2, p0, u1, q1);
getXZIntersectionOffsetPoints(p2, p1, u2, q2);
indices2[0] = 0;
indices2[1] = 1;
indices2[3] = 0;
indices2[6] = 2;
}
}
const positions = splitTriangleResult.positions;
positions[0] = p0;
positions[1] = p1;
positions[2] = p2;
positions.length = 3;
if (numBehind === 1 || numBehind === 2) {
positions[3] = u1;
positions[4] = u2;
positions[5] = q1;
positions[6] = q2;
positions.length = 7;
}
return splitTriangleResult;
}
function updateGeometryAfterSplit(geometry, computeBoundingSphere) {
const attributes = geometry.attributes;
if (attributes.position.values.length === 0) {
return void 0;
}
for (const property in attributes) {
if (attributes.hasOwnProperty(property) && defined_default(attributes[property]) && defined_default(attributes[property].values)) {
const attribute = attributes[property];
attribute.values = ComponentDatatype_default.createTypedArray(
attribute.componentDatatype,
attribute.values
);
}
}
const numberOfVertices = Geometry_default.computeNumberOfVertices(geometry);
geometry.indices = IndexDatatype_default.createTypedArray(
numberOfVertices,
geometry.indices
);
if (computeBoundingSphere) {
geometry.boundingSphere = BoundingSphere_default.fromVertices(
attributes.position.values
);
}
return geometry;
}
function copyGeometryForSplit(geometry) {
const attributes = geometry.attributes;
const copiedAttributes = {};
for (const property in attributes) {
if (attributes.hasOwnProperty(property) && defined_default(attributes[property]) && defined_default(attributes[property].values)) {
const attribute = attributes[property];
copiedAttributes[property] = new GeometryAttribute_default({
componentDatatype: attribute.componentDatatype,
componentsPerAttribute: attribute.componentsPerAttribute,
normalize: attribute.normalize,
values: []
});
}
}
return new Geometry_default({
attributes: copiedAttributes,
indices: [],
primitiveType: geometry.primitiveType
});
}
function updateInstanceAfterSplit(instance, westGeometry, eastGeometry) {
const computeBoundingSphere = defined_default(instance.geometry.boundingSphere);
westGeometry = updateGeometryAfterSplit(westGeometry, computeBoundingSphere);
eastGeometry = updateGeometryAfterSplit(eastGeometry, computeBoundingSphere);
if (defined_default(eastGeometry) && !defined_default(westGeometry)) {
instance.geometry = eastGeometry;
} else if (!defined_default(eastGeometry) && defined_default(westGeometry)) {
instance.geometry = westGeometry;
} else {
instance.westHemisphereGeometry = westGeometry;
instance.eastHemisphereGeometry = eastGeometry;
instance.geometry = void 0;
}
}
function generateBarycentricInterpolateFunction(CartesianType, numberOfComponents) {
const v0Scratch = new CartesianType();
const v1Scratch2 = new CartesianType();
const v2Scratch2 = new CartesianType();
return function(i0, i1, i2, coords, sourceValues, currentValues, insertedIndex, normalize2) {
const v02 = CartesianType.fromArray(
sourceValues,
i0 * numberOfComponents,
v0Scratch
);
const v13 = CartesianType.fromArray(
sourceValues,
i1 * numberOfComponents,
v1Scratch2
);
const v23 = CartesianType.fromArray(
sourceValues,
i2 * numberOfComponents,
v2Scratch2
);
CartesianType.multiplyByScalar(v02, coords.x, v02);
CartesianType.multiplyByScalar(v13, coords.y, v13);
CartesianType.multiplyByScalar(v23, coords.z, v23);
const value = CartesianType.add(v02, v13, v02);
CartesianType.add(value, v23, value);
if (normalize2) {
CartesianType.normalize(value, value);
}
CartesianType.pack(
value,
currentValues,
insertedIndex * numberOfComponents
);
};
}
var interpolateAndPackCartesian4 = generateBarycentricInterpolateFunction(
Cartesian4_default,
4
);
var interpolateAndPackCartesian3 = generateBarycentricInterpolateFunction(
Cartesian3_default,
3
);
var interpolateAndPackCartesian2 = generateBarycentricInterpolateFunction(
Cartesian2_default,
2
);
var interpolateAndPackBoolean = function(i0, i1, i2, coords, sourceValues, currentValues, insertedIndex) {
const v13 = sourceValues[i0] * coords.x;
const v23 = sourceValues[i1] * coords.y;
const v32 = sourceValues[i2] * coords.z;
currentValues[insertedIndex] = v13 + v23 + v32 > Math_default.EPSILON6 ? 1 : 0;
};
var p0Scratch = new Cartesian3_default();
var p1Scratch = new Cartesian3_default();
var p2Scratch = new Cartesian3_default();
var barycentricScratch = new Cartesian3_default();
function computeTriangleAttributes(i0, i1, i2, point, positions, normals, tangents, bitangents, texCoords, extrudeDirections, applyOffset, currentAttributes, customAttributeNames, customAttributesLength, allAttributes, insertedIndex) {
if (!defined_default(normals) && !defined_default(tangents) && !defined_default(bitangents) && !defined_default(texCoords) && !defined_default(extrudeDirections) && customAttributesLength === 0) {
return;
}
const p0 = Cartesian3_default.fromArray(positions, i0 * 3, p0Scratch);
const p1 = Cartesian3_default.fromArray(positions, i1 * 3, p1Scratch);
const p2 = Cartesian3_default.fromArray(positions, i2 * 3, p2Scratch);
const coords = barycentricCoordinates_default(point, p0, p1, p2, barycentricScratch);
if (!defined_default(coords)) {
return;
}
if (defined_default(normals)) {
interpolateAndPackCartesian3(
i0,
i1,
i2,
coords,
normals,
currentAttributes.normal.values,
insertedIndex,
true
);
}
if (defined_default(extrudeDirections)) {
const d0 = Cartesian3_default.fromArray(extrudeDirections, i0 * 3, p0Scratch);
const d1 = Cartesian3_default.fromArray(extrudeDirections, i1 * 3, p1Scratch);
const d2 = Cartesian3_default.fromArray(extrudeDirections, i2 * 3, p2Scratch);
Cartesian3_default.multiplyByScalar(d0, coords.x, d0);
Cartesian3_default.multiplyByScalar(d1, coords.y, d1);
Cartesian3_default.multiplyByScalar(d2, coords.z, d2);
let direction2;
if (!Cartesian3_default.equals(d0, Cartesian3_default.ZERO) || !Cartesian3_default.equals(d1, Cartesian3_default.ZERO) || !Cartesian3_default.equals(d2, Cartesian3_default.ZERO)) {
direction2 = Cartesian3_default.add(d0, d1, d0);
Cartesian3_default.add(direction2, d2, direction2);
Cartesian3_default.normalize(direction2, direction2);
} else {
direction2 = p0Scratch;
direction2.x = 0;
direction2.y = 0;
direction2.z = 0;
}
Cartesian3_default.pack(
direction2,
currentAttributes.extrudeDirection.values,
insertedIndex * 3
);
}
if (defined_default(applyOffset)) {
interpolateAndPackBoolean(
i0,
i1,
i2,
coords,
applyOffset,
currentAttributes.applyOffset.values,
insertedIndex
);
}
if (defined_default(tangents)) {
interpolateAndPackCartesian3(
i0,
i1,
i2,
coords,
tangents,
currentAttributes.tangent.values,
insertedIndex,
true
);
}
if (defined_default(bitangents)) {
interpolateAndPackCartesian3(
i0,
i1,
i2,
coords,
bitangents,
currentAttributes.bitangent.values,
insertedIndex,
true
);
}
if (defined_default(texCoords)) {
interpolateAndPackCartesian2(
i0,
i1,
i2,
coords,
texCoords,
currentAttributes.st.values,
insertedIndex
);
}
if (customAttributesLength > 0) {
for (let i = 0; i < customAttributesLength; i++) {
const attributeName = customAttributeNames[i];
genericInterpolate(
i0,
i1,
i2,
coords,
insertedIndex,
allAttributes[attributeName],
currentAttributes[attributeName]
);
}
}
}
function genericInterpolate(i0, i1, i2, coords, insertedIndex, sourceAttribute, currentAttribute) {
const componentsPerAttribute = sourceAttribute.componentsPerAttribute;
const sourceValues = sourceAttribute.values;
const currentValues = currentAttribute.values;
switch (componentsPerAttribute) {
case 4:
interpolateAndPackCartesian4(
i0,
i1,
i2,
coords,
sourceValues,
currentValues,
insertedIndex,
false
);
break;
case 3:
interpolateAndPackCartesian3(
i0,
i1,
i2,
coords,
sourceValues,
currentValues,
insertedIndex,
false
);
break;
case 2:
interpolateAndPackCartesian2(
i0,
i1,
i2,
coords,
sourceValues,
currentValues,
insertedIndex,
false
);
break;
default:
currentValues[insertedIndex] = sourceValues[i0] * coords.x + sourceValues[i1] * coords.y + sourceValues[i2] * coords.z;
}
}
function insertSplitPoint(currentAttributes, currentIndices, currentIndexMap, indices2, currentIndex, point) {
const insertIndex = currentAttributes.position.values.length / 3;
if (currentIndex !== -1) {
const prevIndex = indices2[currentIndex];
const newIndex = currentIndexMap[prevIndex];
if (newIndex === -1) {
currentIndexMap[prevIndex] = insertIndex;
currentAttributes.position.values.push(point.x, point.y, point.z);
currentIndices.push(insertIndex);
return insertIndex;
}
currentIndices.push(newIndex);
return newIndex;
}
currentAttributes.position.values.push(point.x, point.y, point.z);
currentIndices.push(insertIndex);
return insertIndex;
}
var NAMED_ATTRIBUTES = {
position: true,
normal: true,
bitangent: true,
tangent: true,
st: true,
extrudeDirection: true,
applyOffset: true
};
function splitLongitudeTriangles(instance) {
const geometry = instance.geometry;
const attributes = geometry.attributes;
const positions = attributes.position.values;
const normals = defined_default(attributes.normal) ? attributes.normal.values : void 0;
const bitangents = defined_default(attributes.bitangent) ? attributes.bitangent.values : void 0;
const tangents = defined_default(attributes.tangent) ? attributes.tangent.values : void 0;
const texCoords = defined_default(attributes.st) ? attributes.st.values : void 0;
const extrudeDirections = defined_default(attributes.extrudeDirection) ? attributes.extrudeDirection.values : void 0;
const applyOffset = defined_default(attributes.applyOffset) ? attributes.applyOffset.values : void 0;
const indices2 = geometry.indices;
const customAttributeNames = [];
for (const attributeName in attributes) {
if (attributes.hasOwnProperty(attributeName) && !NAMED_ATTRIBUTES[attributeName] && defined_default(attributes[attributeName])) {
customAttributeNames.push(attributeName);
}
}
const customAttributesLength = customAttributeNames.length;
const eastGeometry = copyGeometryForSplit(geometry);
const westGeometry = copyGeometryForSplit(geometry);
let currentAttributes;
let currentIndices;
let currentIndexMap;
let insertedIndex;
let i;
const westGeometryIndexMap = [];
westGeometryIndexMap.length = positions.length / 3;
const eastGeometryIndexMap = [];
eastGeometryIndexMap.length = positions.length / 3;
for (i = 0; i < westGeometryIndexMap.length; ++i) {
westGeometryIndexMap[i] = -1;
eastGeometryIndexMap[i] = -1;
}
const len = indices2.length;
for (i = 0; i < len; i += 3) {
const i0 = indices2[i];
const i1 = indices2[i + 1];
const i2 = indices2[i + 2];
let p0 = Cartesian3_default.fromArray(positions, i0 * 3);
let p1 = Cartesian3_default.fromArray(positions, i1 * 3);
let p2 = Cartesian3_default.fromArray(positions, i2 * 3);
const result = splitTriangle(p0, p1, p2);
if (defined_default(result) && result.positions.length > 3) {
const resultPositions = result.positions;
const resultIndices = result.indices;
const resultLength = resultIndices.length;
for (let j = 0; j < resultLength; ++j) {
const resultIndex = resultIndices[j];
const point = resultPositions[resultIndex];
if (point.y < 0) {
currentAttributes = westGeometry.attributes;
currentIndices = westGeometry.indices;
currentIndexMap = westGeometryIndexMap;
} else {
currentAttributes = eastGeometry.attributes;
currentIndices = eastGeometry.indices;
currentIndexMap = eastGeometryIndexMap;
}
insertedIndex = insertSplitPoint(
currentAttributes,
currentIndices,
currentIndexMap,
indices2,
resultIndex < 3 ? i + resultIndex : -1,
point
);
computeTriangleAttributes(
i0,
i1,
i2,
point,
positions,
normals,
tangents,
bitangents,
texCoords,
extrudeDirections,
applyOffset,
currentAttributes,
customAttributeNames,
customAttributesLength,
attributes,
insertedIndex
);
}
} else {
if (defined_default(result)) {
p0 = result.positions[0];
p1 = result.positions[1];
p2 = result.positions[2];
}
if (p0.y < 0) {
currentAttributes = westGeometry.attributes;
currentIndices = westGeometry.indices;
currentIndexMap = westGeometryIndexMap;
} else {
currentAttributes = eastGeometry.attributes;
currentIndices = eastGeometry.indices;
currentIndexMap = eastGeometryIndexMap;
}
insertedIndex = insertSplitPoint(
currentAttributes,
currentIndices,
currentIndexMap,
indices2,
i,
p0
);
computeTriangleAttributes(
i0,
i1,
i2,
p0,
positions,
normals,
tangents,
bitangents,
texCoords,
extrudeDirections,
applyOffset,
currentAttributes,
customAttributeNames,
customAttributesLength,
attributes,
insertedIndex
);
insertedIndex = insertSplitPoint(
currentAttributes,
currentIndices,
currentIndexMap,
indices2,
i + 1,
p1
);
computeTriangleAttributes(
i0,
i1,
i2,
p1,
positions,
normals,
tangents,
bitangents,
texCoords,
extrudeDirections,
applyOffset,
currentAttributes,
customAttributeNames,
customAttributesLength,
attributes,
insertedIndex
);
insertedIndex = insertSplitPoint(
currentAttributes,
currentIndices,
currentIndexMap,
indices2,
i + 2,
p2
);
computeTriangleAttributes(
i0,
i1,
i2,
p2,
positions,
normals,
tangents,
bitangents,
texCoords,
extrudeDirections,
applyOffset,
currentAttributes,
customAttributeNames,
customAttributesLength,
attributes,
insertedIndex
);
}
}
updateInstanceAfterSplit(instance, westGeometry, eastGeometry);
}
var xzPlane = Plane_default.fromPointNormal(Cartesian3_default.ZERO, Cartesian3_default.UNIT_Y);
var offsetScratch = new Cartesian3_default();
var offsetPointScratch = new Cartesian3_default();
function computeLineAttributes(i0, i1, point, positions, insertIndex, currentAttributes, applyOffset) {
if (!defined_default(applyOffset)) {
return;
}
const p0 = Cartesian3_default.fromArray(positions, i0 * 3, p0Scratch);
if (Cartesian3_default.equalsEpsilon(p0, point, Math_default.EPSILON10)) {
currentAttributes.applyOffset.values[insertIndex] = applyOffset[i0];
} else {
currentAttributes.applyOffset.values[insertIndex] = applyOffset[i1];
}
}
function splitLongitudeLines(instance) {
const geometry = instance.geometry;
const attributes = geometry.attributes;
const positions = attributes.position.values;
const applyOffset = defined_default(attributes.applyOffset) ? attributes.applyOffset.values : void 0;
const indices2 = geometry.indices;
const eastGeometry = copyGeometryForSplit(geometry);
const westGeometry = copyGeometryForSplit(geometry);
let i;
const length3 = indices2.length;
const westGeometryIndexMap = [];
westGeometryIndexMap.length = positions.length / 3;
const eastGeometryIndexMap = [];
eastGeometryIndexMap.length = positions.length / 3;
for (i = 0; i < westGeometryIndexMap.length; ++i) {
westGeometryIndexMap[i] = -1;
eastGeometryIndexMap[i] = -1;
}
for (i = 0; i < length3; i += 2) {
const i0 = indices2[i];
const i1 = indices2[i + 1];
const p0 = Cartesian3_default.fromArray(positions, i0 * 3, p0Scratch);
const p1 = Cartesian3_default.fromArray(positions, i1 * 3, p1Scratch);
let insertIndex;
if (Math.abs(p0.y) < Math_default.EPSILON6) {
if (p0.y < 0) {
p0.y = -Math_default.EPSILON6;
} else {
p0.y = Math_default.EPSILON6;
}
}
if (Math.abs(p1.y) < Math_default.EPSILON6) {
if (p1.y < 0) {
p1.y = -Math_default.EPSILON6;
} else {
p1.y = Math_default.EPSILON6;
}
}
let p0Attributes = eastGeometry.attributes;
let p0Indices = eastGeometry.indices;
let p0IndexMap = eastGeometryIndexMap;
let p1Attributes = westGeometry.attributes;
let p1Indices = westGeometry.indices;
let p1IndexMap = westGeometryIndexMap;
const intersection = IntersectionTests_default.lineSegmentPlane(
p0,
p1,
xzPlane,
p2Scratch
);
if (defined_default(intersection)) {
const offset2 = Cartesian3_default.multiplyByScalar(
Cartesian3_default.UNIT_Y,
5 * Math_default.EPSILON9,
offsetScratch
);
if (p0.y < 0) {
Cartesian3_default.negate(offset2, offset2);
p0Attributes = westGeometry.attributes;
p0Indices = westGeometry.indices;
p0IndexMap = westGeometryIndexMap;
p1Attributes = eastGeometry.attributes;
p1Indices = eastGeometry.indices;
p1IndexMap = eastGeometryIndexMap;
}
const offsetPoint = Cartesian3_default.add(
intersection,
offset2,
offsetPointScratch
);
insertIndex = insertSplitPoint(
p0Attributes,
p0Indices,
p0IndexMap,
indices2,
i,
p0
);
computeLineAttributes(
i0,
i1,
p0,
positions,
insertIndex,
p0Attributes,
applyOffset
);
insertIndex = insertSplitPoint(
p0Attributes,
p0Indices,
p0IndexMap,
indices2,
-1,
offsetPoint
);
computeLineAttributes(
i0,
i1,
offsetPoint,
positions,
insertIndex,
p0Attributes,
applyOffset
);
Cartesian3_default.negate(offset2, offset2);
Cartesian3_default.add(intersection, offset2, offsetPoint);
insertIndex = insertSplitPoint(
p1Attributes,
p1Indices,
p1IndexMap,
indices2,
-1,
offsetPoint
);
computeLineAttributes(
i0,
i1,
offsetPoint,
positions,
insertIndex,
p1Attributes,
applyOffset
);
insertIndex = insertSplitPoint(
p1Attributes,
p1Indices,
p1IndexMap,
indices2,
i + 1,
p1
);
computeLineAttributes(
i0,
i1,
p1,
positions,
insertIndex,
p1Attributes,
applyOffset
);
} else {
let currentAttributes;
let currentIndices;
let currentIndexMap;
if (p0.y < 0) {
currentAttributes = westGeometry.attributes;
currentIndices = westGeometry.indices;
currentIndexMap = westGeometryIndexMap;
} else {
currentAttributes = eastGeometry.attributes;
currentIndices = eastGeometry.indices;
currentIndexMap = eastGeometryIndexMap;
}
insertIndex = insertSplitPoint(
currentAttributes,
currentIndices,
currentIndexMap,
indices2,
i,
p0
);
computeLineAttributes(
i0,
i1,
p0,
positions,
insertIndex,
currentAttributes,
applyOffset
);
insertIndex = insertSplitPoint(
currentAttributes,
currentIndices,
currentIndexMap,
indices2,
i + 1,
p1
);
computeLineAttributes(
i0,
i1,
p1,
positions,
insertIndex,
currentAttributes,
applyOffset
);
}
}
updateInstanceAfterSplit(instance, westGeometry, eastGeometry);
}
var cartesian2Scratch0 = new Cartesian2_default();
var cartesian2Scratch1 = new Cartesian2_default();
var cartesian3Scratch0 = new Cartesian3_default();
var cartesian3Scratch22 = new Cartesian3_default();
var cartesian3Scratch3 = new Cartesian3_default();
var cartesian3Scratch4 = new Cartesian3_default();
var cartesian3Scratch5 = new Cartesian3_default();
var cartesian3Scratch6 = new Cartesian3_default();
var cartesian4Scratch0 = new Cartesian4_default();
function updateAdjacencyAfterSplit(geometry) {
const attributes = geometry.attributes;
const positions = attributes.position.values;
const prevPositions = attributes.prevPosition.values;
const nextPositions = attributes.nextPosition.values;
const length3 = positions.length;
for (let j = 0; j < length3; j += 3) {
const position = Cartesian3_default.unpack(positions, j, cartesian3Scratch0);
if (position.x > 0) {
continue;
}
const prevPosition = Cartesian3_default.unpack(
prevPositions,
j,
cartesian3Scratch22
);
if (position.y < 0 && prevPosition.y > 0 || position.y > 0 && prevPosition.y < 0) {
if (j - 3 > 0) {
prevPositions[j] = positions[j - 3];
prevPositions[j + 1] = positions[j - 2];
prevPositions[j + 2] = positions[j - 1];
} else {
Cartesian3_default.pack(position, prevPositions, j);
}
}
const nextPosition = Cartesian3_default.unpack(
nextPositions,
j,
cartesian3Scratch3
);
if (position.y < 0 && nextPosition.y > 0 || position.y > 0 && nextPosition.y < 0) {
if (j + 3 < length3) {
nextPositions[j] = positions[j + 3];
nextPositions[j + 1] = positions[j + 4];
nextPositions[j + 2] = positions[j + 5];
} else {
Cartesian3_default.pack(position, nextPositions, j);
}
}
}
}
var offsetScalar = 5 * Math_default.EPSILON9;
var coplanarOffset = Math_default.EPSILON6;
function splitLongitudePolyline(instance) {
const geometry = instance.geometry;
const attributes = geometry.attributes;
const positions = attributes.position.values;
const prevPositions = attributes.prevPosition.values;
const nextPositions = attributes.nextPosition.values;
const expandAndWidths = attributes.expandAndWidth.values;
const texCoords = defined_default(attributes.st) ? attributes.st.values : void 0;
const colors = defined_default(attributes.color) ? attributes.color.values : void 0;
const eastGeometry = copyGeometryForSplit(geometry);
const westGeometry = copyGeometryForSplit(geometry);
let i;
let j;
let index;
let intersectionFound = false;
const length3 = positions.length / 3;
for (i = 0; i < length3; i += 4) {
const i0 = i;
const i2 = i + 2;
const p0 = Cartesian3_default.fromArray(positions, i0 * 3, cartesian3Scratch0);
const p2 = Cartesian3_default.fromArray(positions, i2 * 3, cartesian3Scratch22);
if (Math.abs(p0.y) < coplanarOffset) {
p0.y = coplanarOffset * (p2.y < 0 ? -1 : 1);
positions[i * 3 + 1] = p0.y;
positions[(i + 1) * 3 + 1] = p0.y;
for (j = i0 * 3; j < i0 * 3 + 4 * 3; j += 3) {
prevPositions[j] = positions[i * 3];
prevPositions[j + 1] = positions[i * 3 + 1];
prevPositions[j + 2] = positions[i * 3 + 2];
}
}
if (Math.abs(p2.y) < coplanarOffset) {
p2.y = coplanarOffset * (p0.y < 0 ? -1 : 1);
positions[(i + 2) * 3 + 1] = p2.y;
positions[(i + 3) * 3 + 1] = p2.y;
for (j = i0 * 3; j < i0 * 3 + 4 * 3; j += 3) {
nextPositions[j] = positions[(i + 2) * 3];
nextPositions[j + 1] = positions[(i + 2) * 3 + 1];
nextPositions[j + 2] = positions[(i + 2) * 3 + 2];
}
}
let p0Attributes = eastGeometry.attributes;
let p0Indices = eastGeometry.indices;
let p2Attributes = westGeometry.attributes;
let p2Indices = westGeometry.indices;
const intersection = IntersectionTests_default.lineSegmentPlane(
p0,
p2,
xzPlane,
cartesian3Scratch4
);
if (defined_default(intersection)) {
intersectionFound = true;
const offset2 = Cartesian3_default.multiplyByScalar(
Cartesian3_default.UNIT_Y,
offsetScalar,
cartesian3Scratch5
);
if (p0.y < 0) {
Cartesian3_default.negate(offset2, offset2);
p0Attributes = westGeometry.attributes;
p0Indices = westGeometry.indices;
p2Attributes = eastGeometry.attributes;
p2Indices = eastGeometry.indices;
}
const offsetPoint = Cartesian3_default.add(
intersection,
offset2,
cartesian3Scratch6
);
p0Attributes.position.values.push(p0.x, p0.y, p0.z, p0.x, p0.y, p0.z);
p0Attributes.position.values.push(
offsetPoint.x,
offsetPoint.y,
offsetPoint.z
);
p0Attributes.position.values.push(
offsetPoint.x,
offsetPoint.y,
offsetPoint.z
);
p0Attributes.prevPosition.values.push(
prevPositions[i0 * 3],
prevPositions[i0 * 3 + 1],
prevPositions[i0 * 3 + 2]
);
p0Attributes.prevPosition.values.push(
prevPositions[i0 * 3 + 3],
prevPositions[i0 * 3 + 4],
prevPositions[i0 * 3 + 5]
);
p0Attributes.prevPosition.values.push(p0.x, p0.y, p0.z, p0.x, p0.y, p0.z);
p0Attributes.nextPosition.values.push(
offsetPoint.x,
offsetPoint.y,
offsetPoint.z
);
p0Attributes.nextPosition.values.push(
offsetPoint.x,
offsetPoint.y,
offsetPoint.z
);
p0Attributes.nextPosition.values.push(
offsetPoint.x,
offsetPoint.y,
offsetPoint.z
);
p0Attributes.nextPosition.values.push(
offsetPoint.x,
offsetPoint.y,
offsetPoint.z
);
Cartesian3_default.negate(offset2, offset2);
Cartesian3_default.add(intersection, offset2, offsetPoint);
p2Attributes.position.values.push(
offsetPoint.x,
offsetPoint.y,
offsetPoint.z
);
p2Attributes.position.values.push(
offsetPoint.x,
offsetPoint.y,
offsetPoint.z
);
p2Attributes.position.values.push(p2.x, p2.y, p2.z, p2.x, p2.y, p2.z);
p2Attributes.prevPosition.values.push(
offsetPoint.x,
offsetPoint.y,
offsetPoint.z
);
p2Attributes.prevPosition.values.push(
offsetPoint.x,
offsetPoint.y,
offsetPoint.z
);
p2Attributes.prevPosition.values.push(
offsetPoint.x,
offsetPoint.y,
offsetPoint.z
);
p2Attributes.prevPosition.values.push(
offsetPoint.x,
offsetPoint.y,
offsetPoint.z
);
p2Attributes.nextPosition.values.push(p2.x, p2.y, p2.z, p2.x, p2.y, p2.z);
p2Attributes.nextPosition.values.push(
nextPositions[i2 * 3],
nextPositions[i2 * 3 + 1],
nextPositions[i2 * 3 + 2]
);
p2Attributes.nextPosition.values.push(
nextPositions[i2 * 3 + 3],
nextPositions[i2 * 3 + 4],
nextPositions[i2 * 3 + 5]
);
const ew0 = Cartesian2_default.fromArray(
expandAndWidths,
i0 * 2,
cartesian2Scratch0
);
const width = Math.abs(ew0.y);
p0Attributes.expandAndWidth.values.push(-1, width, 1, width);
p0Attributes.expandAndWidth.values.push(-1, -width, 1, -width);
p2Attributes.expandAndWidth.values.push(-1, width, 1, width);
p2Attributes.expandAndWidth.values.push(-1, -width, 1, -width);
let t = Cartesian3_default.magnitudeSquared(
Cartesian3_default.subtract(intersection, p0, cartesian3Scratch3)
);
t /= Cartesian3_default.magnitudeSquared(
Cartesian3_default.subtract(p2, p0, cartesian3Scratch3)
);
if (defined_default(colors)) {
const c0 = Cartesian4_default.fromArray(colors, i0 * 4, cartesian4Scratch0);
const c22 = Cartesian4_default.fromArray(colors, i2 * 4, cartesian4Scratch0);
const r = Math_default.lerp(c0.x, c22.x, t);
const g = Math_default.lerp(c0.y, c22.y, t);
const b = Math_default.lerp(c0.z, c22.z, t);
const a3 = Math_default.lerp(c0.w, c22.w, t);
for (j = i0 * 4; j < i0 * 4 + 2 * 4; ++j) {
p0Attributes.color.values.push(colors[j]);
}
p0Attributes.color.values.push(r, g, b, a3);
p0Attributes.color.values.push(r, g, b, a3);
p2Attributes.color.values.push(r, g, b, a3);
p2Attributes.color.values.push(r, g, b, a3);
for (j = i2 * 4; j < i2 * 4 + 2 * 4; ++j) {
p2Attributes.color.values.push(colors[j]);
}
}
if (defined_default(texCoords)) {
const s0 = Cartesian2_default.fromArray(texCoords, i0 * 2, cartesian2Scratch0);
const s3 = Cartesian2_default.fromArray(
texCoords,
(i + 3) * 2,
cartesian2Scratch1
);
const sx = Math_default.lerp(s0.x, s3.x, t);
for (j = i0 * 2; j < i0 * 2 + 2 * 2; ++j) {
p0Attributes.st.values.push(texCoords[j]);
}
p0Attributes.st.values.push(sx, s0.y);
p0Attributes.st.values.push(sx, s3.y);
p2Attributes.st.values.push(sx, s0.y);
p2Attributes.st.values.push(sx, s3.y);
for (j = i2 * 2; j < i2 * 2 + 2 * 2; ++j) {
p2Attributes.st.values.push(texCoords[j]);
}
}
index = p0Attributes.position.values.length / 3 - 4;
p0Indices.push(index, index + 2, index + 1);
p0Indices.push(index + 1, index + 2, index + 3);
index = p2Attributes.position.values.length / 3 - 4;
p2Indices.push(index, index + 2, index + 1);
p2Indices.push(index + 1, index + 2, index + 3);
} else {
let currentAttributes;
let currentIndices;
if (p0.y < 0) {
currentAttributes = westGeometry.attributes;
currentIndices = westGeometry.indices;
} else {
currentAttributes = eastGeometry.attributes;
currentIndices = eastGeometry.indices;
}
currentAttributes.position.values.push(p0.x, p0.y, p0.z);
currentAttributes.position.values.push(p0.x, p0.y, p0.z);
currentAttributes.position.values.push(p2.x, p2.y, p2.z);
currentAttributes.position.values.push(p2.x, p2.y, p2.z);
for (j = i * 3; j < i * 3 + 4 * 3; ++j) {
currentAttributes.prevPosition.values.push(prevPositions[j]);
currentAttributes.nextPosition.values.push(nextPositions[j]);
}
for (j = i * 2; j < i * 2 + 4 * 2; ++j) {
currentAttributes.expandAndWidth.values.push(expandAndWidths[j]);
if (defined_default(texCoords)) {
currentAttributes.st.values.push(texCoords[j]);
}
}
if (defined_default(colors)) {
for (j = i * 4; j < i * 4 + 4 * 4; ++j) {
currentAttributes.color.values.push(colors[j]);
}
}
index = currentAttributes.position.values.length / 3 - 4;
currentIndices.push(index, index + 2, index + 1);
currentIndices.push(index + 1, index + 2, index + 3);
}
}
if (intersectionFound) {
updateAdjacencyAfterSplit(westGeometry);
updateAdjacencyAfterSplit(eastGeometry);
}
updateInstanceAfterSplit(instance, westGeometry, eastGeometry);
}
GeometryPipeline.splitLongitude = function(instance) {
if (!defined_default(instance)) {
throw new DeveloperError_default("instance is required.");
}
const geometry = instance.geometry;
const boundingSphere = geometry.boundingSphere;
if (defined_default(boundingSphere)) {
const minX = boundingSphere.center.x - boundingSphere.radius;
if (minX > 0 || BoundingSphere_default.intersectPlane(boundingSphere, Plane_default.ORIGIN_ZX_PLANE) !== Intersect_default.INTERSECTING) {
return instance;
}
}
if (geometry.geometryType !== GeometryType_default.NONE) {
switch (geometry.geometryType) {
case GeometryType_default.POLYLINES:
splitLongitudePolyline(instance);
break;
case GeometryType_default.TRIANGLES:
splitLongitudeTriangles(instance);
break;
case GeometryType_default.LINES:
splitLongitudeLines(instance);
break;
}
} else {
indexPrimitive(geometry);
if (geometry.primitiveType === PrimitiveType_default.TRIANGLES) {
splitLongitudeTriangles(instance);
} else if (geometry.primitiveType === PrimitiveType_default.LINES) {
splitLongitudeLines(instance);
}
}
return instance;
};
var GeometryPipeline_default = GeometryPipeline;
// Source/Core/EllipseGeometry.js
var scratchCartesian14 = new Cartesian3_default();
var scratchCartesian26 = new Cartesian3_default();
var scratchCartesian36 = new Cartesian3_default();
var scratchCartesian42 = new Cartesian3_default();
var texCoordScratch = new Cartesian2_default();
var textureMatrixScratch = new Matrix3_default();
var tangentMatrixScratch = new Matrix3_default();
var quaternionScratch = new Quaternion_default();
var scratchNormal3 = new Cartesian3_default();
var scratchTangent = new Cartesian3_default();
var scratchBitangent = new Cartesian3_default();
var scratchCartographic3 = new Cartographic_default();
var projectedCenterScratch = new Cartesian3_default();
var scratchMinTexCoord = new Cartesian2_default();
var scratchMaxTexCoord = new Cartesian2_default();
function computeTopBottomAttributes(positions, options, extrude) {
const vertexFormat = options.vertexFormat;
const center = options.center;
const semiMajorAxis = options.semiMajorAxis;
const semiMinorAxis = options.semiMinorAxis;
const ellipsoid = options.ellipsoid;
const stRotation = options.stRotation;
const size = extrude ? positions.length / 3 * 2 : positions.length / 3;
const shadowVolume = options.shadowVolume;
const textureCoordinates = vertexFormat.st ? new Float32Array(size * 2) : void 0;
const normals = vertexFormat.normal ? new Float32Array(size * 3) : void 0;
const tangents = vertexFormat.tangent ? new Float32Array(size * 3) : void 0;
const bitangents = vertexFormat.bitangent ? new Float32Array(size * 3) : void 0;
const extrudeNormals = shadowVolume ? new Float32Array(size * 3) : void 0;
let textureCoordIndex = 0;
let normal2 = scratchNormal3;
let tangent = scratchTangent;
let bitangent = scratchBitangent;
const projection = new GeographicProjection_default(ellipsoid);
const projectedCenter = projection.project(
ellipsoid.cartesianToCartographic(center, scratchCartographic3),
projectedCenterScratch
);
const geodeticNormal = ellipsoid.scaleToGeodeticSurface(
center,
scratchCartesian14
);
ellipsoid.geodeticSurfaceNormal(geodeticNormal, geodeticNormal);
let textureMatrix = textureMatrixScratch;
let tangentMatrix = tangentMatrixScratch;
if (stRotation !== 0) {
let rotation = Quaternion_default.fromAxisAngle(
geodeticNormal,
stRotation,
quaternionScratch
);
textureMatrix = Matrix3_default.fromQuaternion(rotation, textureMatrix);
rotation = Quaternion_default.fromAxisAngle(
geodeticNormal,
-stRotation,
quaternionScratch
);
tangentMatrix = Matrix3_default.fromQuaternion(rotation, tangentMatrix);
} else {
textureMatrix = Matrix3_default.clone(Matrix3_default.IDENTITY, textureMatrix);
tangentMatrix = Matrix3_default.clone(Matrix3_default.IDENTITY, tangentMatrix);
}
const minTexCoord = Cartesian2_default.fromElements(
Number.POSITIVE_INFINITY,
Number.POSITIVE_INFINITY,
scratchMinTexCoord
);
const maxTexCoord = Cartesian2_default.fromElements(
Number.NEGATIVE_INFINITY,
Number.NEGATIVE_INFINITY,
scratchMaxTexCoord
);
let length3 = positions.length;
const bottomOffset = extrude ? length3 : 0;
const stOffset = bottomOffset / 3 * 2;
for (let i = 0; i < length3; i += 3) {
const i1 = i + 1;
const i2 = i + 2;
const position = Cartesian3_default.fromArray(positions, i, scratchCartesian14);
if (vertexFormat.st) {
const rotatedPoint = Matrix3_default.multiplyByVector(
textureMatrix,
position,
scratchCartesian26
);
const projectedPoint = projection.project(
ellipsoid.cartesianToCartographic(rotatedPoint, scratchCartographic3),
scratchCartesian36
);
Cartesian3_default.subtract(projectedPoint, projectedCenter, projectedPoint);
texCoordScratch.x = (projectedPoint.x + semiMajorAxis) / (2 * semiMajorAxis);
texCoordScratch.y = (projectedPoint.y + semiMinorAxis) / (2 * semiMinorAxis);
minTexCoord.x = Math.min(texCoordScratch.x, minTexCoord.x);
minTexCoord.y = Math.min(texCoordScratch.y, minTexCoord.y);
maxTexCoord.x = Math.max(texCoordScratch.x, maxTexCoord.x);
maxTexCoord.y = Math.max(texCoordScratch.y, maxTexCoord.y);
if (extrude) {
textureCoordinates[textureCoordIndex + stOffset] = texCoordScratch.x;
textureCoordinates[textureCoordIndex + 1 + stOffset] = texCoordScratch.y;
}
textureCoordinates[textureCoordIndex++] = texCoordScratch.x;
textureCoordinates[textureCoordIndex++] = texCoordScratch.y;
}
if (vertexFormat.normal || vertexFormat.tangent || vertexFormat.bitangent || shadowVolume) {
normal2 = ellipsoid.geodeticSurfaceNormal(position, normal2);
if (shadowVolume) {
extrudeNormals[i + bottomOffset] = -normal2.x;
extrudeNormals[i1 + bottomOffset] = -normal2.y;
extrudeNormals[i2 + bottomOffset] = -normal2.z;
}
if (vertexFormat.normal || vertexFormat.tangent || vertexFormat.bitangent) {
if (vertexFormat.tangent || vertexFormat.bitangent) {
tangent = Cartesian3_default.normalize(
Cartesian3_default.cross(Cartesian3_default.UNIT_Z, normal2, tangent),
tangent
);
Matrix3_default.multiplyByVector(tangentMatrix, tangent, tangent);
}
if (vertexFormat.normal) {
normals[i] = normal2.x;
normals[i1] = normal2.y;
normals[i2] = normal2.z;
if (extrude) {
normals[i + bottomOffset] = -normal2.x;
normals[i1 + bottomOffset] = -normal2.y;
normals[i2 + bottomOffset] = -normal2.z;
}
}
if (vertexFormat.tangent) {
tangents[i] = tangent.x;
tangents[i1] = tangent.y;
tangents[i2] = tangent.z;
if (extrude) {
tangents[i + bottomOffset] = -tangent.x;
tangents[i1 + bottomOffset] = -tangent.y;
tangents[i2 + bottomOffset] = -tangent.z;
}
}
if (vertexFormat.bitangent) {
bitangent = Cartesian3_default.normalize(
Cartesian3_default.cross(normal2, tangent, bitangent),
bitangent
);
bitangents[i] = bitangent.x;
bitangents[i1] = bitangent.y;
bitangents[i2] = bitangent.z;
if (extrude) {
bitangents[i + bottomOffset] = bitangent.x;
bitangents[i1 + bottomOffset] = bitangent.y;
bitangents[i2 + bottomOffset] = bitangent.z;
}
}
}
}
}
if (vertexFormat.st) {
length3 = textureCoordinates.length;
for (let k = 0; k < length3; k += 2) {
textureCoordinates[k] = (textureCoordinates[k] - minTexCoord.x) / (maxTexCoord.x - minTexCoord.x);
textureCoordinates[k + 1] = (textureCoordinates[k + 1] - minTexCoord.y) / (maxTexCoord.y - minTexCoord.y);
}
}
const attributes = new GeometryAttributes_default();
if (vertexFormat.position) {
const finalPositions = EllipseGeometryLibrary_default.raisePositionsToHeight(
positions,
options,
extrude
);
attributes.position = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.DOUBLE,
componentsPerAttribute: 3,
values: finalPositions
});
}
if (vertexFormat.st) {
attributes.st = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.FLOAT,
componentsPerAttribute: 2,
values: textureCoordinates
});
}
if (vertexFormat.normal) {
attributes.normal = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.FLOAT,
componentsPerAttribute: 3,
values: normals
});
}
if (vertexFormat.tangent) {
attributes.tangent = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.FLOAT,
componentsPerAttribute: 3,
values: tangents
});
}
if (vertexFormat.bitangent) {
attributes.bitangent = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.FLOAT,
componentsPerAttribute: 3,
values: bitangents
});
}
if (shadowVolume) {
attributes.extrudeDirection = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.FLOAT,
componentsPerAttribute: 3,
values: extrudeNormals
});
}
if (extrude && defined_default(options.offsetAttribute)) {
let offsetAttribute = new Uint8Array(size);
if (options.offsetAttribute === GeometryOffsetAttribute_default.TOP) {
offsetAttribute = offsetAttribute.fill(1, 0, size / 2);
} else {
const offsetValue = options.offsetAttribute === GeometryOffsetAttribute_default.NONE ? 0 : 1;
offsetAttribute = offsetAttribute.fill(offsetValue);
}
attributes.applyOffset = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.UNSIGNED_BYTE,
componentsPerAttribute: 1,
values: offsetAttribute
});
}
return attributes;
}
function topIndices(numPts) {
const indices2 = new Array(12 * (numPts * (numPts + 1)) - 6);
let indicesIndex = 0;
let prevIndex;
let numInterior;
let positionIndex;
let i;
let j;
prevIndex = 0;
positionIndex = 1;
for (i = 0; i < 3; i++) {
indices2[indicesIndex++] = positionIndex++;
indices2[indicesIndex++] = prevIndex;
indices2[indicesIndex++] = positionIndex;
}
for (i = 2; i < numPts + 1; ++i) {
positionIndex = i * (i + 1) - 1;
prevIndex = (i - 1) * i - 1;
indices2[indicesIndex++] = positionIndex++;
indices2[indicesIndex++] = prevIndex;
indices2[indicesIndex++] = positionIndex;
numInterior = 2 * i;
for (j = 0; j < numInterior - 1; ++j) {
indices2[indicesIndex++] = positionIndex;
indices2[indicesIndex++] = prevIndex++;
indices2[indicesIndex++] = prevIndex;
indices2[indicesIndex++] = positionIndex++;
indices2[indicesIndex++] = prevIndex;
indices2[indicesIndex++] = positionIndex;
}
indices2[indicesIndex++] = positionIndex++;
indices2[indicesIndex++] = prevIndex;
indices2[indicesIndex++] = positionIndex;
}
numInterior = numPts * 2;
++positionIndex;
++prevIndex;
for (i = 0; i < numInterior - 1; ++i) {
indices2[indicesIndex++] = positionIndex;
indices2[indicesIndex++] = prevIndex++;
indices2[indicesIndex++] = prevIndex;
indices2[indicesIndex++] = positionIndex++;
indices2[indicesIndex++] = prevIndex;
indices2[indicesIndex++] = positionIndex;
}
indices2[indicesIndex++] = positionIndex;
indices2[indicesIndex++] = prevIndex++;
indices2[indicesIndex++] = prevIndex;
indices2[indicesIndex++] = positionIndex++;
indices2[indicesIndex++] = prevIndex++;
indices2[indicesIndex++] = prevIndex;
++prevIndex;
for (i = numPts - 1; i > 1; --i) {
indices2[indicesIndex++] = prevIndex++;
indices2[indicesIndex++] = prevIndex;
indices2[indicesIndex++] = positionIndex;
numInterior = 2 * i;
for (j = 0; j < numInterior - 1; ++j) {
indices2[indicesIndex++] = positionIndex;
indices2[indicesIndex++] = prevIndex++;
indices2[indicesIndex++] = prevIndex;
indices2[indicesIndex++] = positionIndex++;
indices2[indicesIndex++] = prevIndex;
indices2[indicesIndex++] = positionIndex;
}
indices2[indicesIndex++] = prevIndex++;
indices2[indicesIndex++] = prevIndex++;
indices2[indicesIndex++] = positionIndex++;
}
for (i = 0; i < 3; i++) {
indices2[indicesIndex++] = prevIndex++;
indices2[indicesIndex++] = prevIndex;
indices2[indicesIndex++] = positionIndex;
}
return indices2;
}
var boundingSphereCenter = new Cartesian3_default();
function computeEllipse(options) {
const center = options.center;
boundingSphereCenter = Cartesian3_default.multiplyByScalar(
options.ellipsoid.geodeticSurfaceNormal(center, boundingSphereCenter),
options.height,
boundingSphereCenter
);
boundingSphereCenter = Cartesian3_default.add(
center,
boundingSphereCenter,
boundingSphereCenter
);
const boundingSphere = new BoundingSphere_default(
boundingSphereCenter,
options.semiMajorAxis
);
const cep = EllipseGeometryLibrary_default.computeEllipsePositions(
options,
true,
false
);
const positions = cep.positions;
const numPts = cep.numPts;
const attributes = computeTopBottomAttributes(positions, options, false);
let indices2 = topIndices(numPts);
indices2 = IndexDatatype_default.createTypedArray(positions.length / 3, indices2);
return {
boundingSphere,
attributes,
indices: indices2
};
}
function computeWallAttributes(positions, options) {
const vertexFormat = options.vertexFormat;
const center = options.center;
const semiMajorAxis = options.semiMajorAxis;
const semiMinorAxis = options.semiMinorAxis;
const ellipsoid = options.ellipsoid;
const height = options.height;
const extrudedHeight = options.extrudedHeight;
const stRotation = options.stRotation;
const size = positions.length / 3 * 2;
const finalPositions = new Float64Array(size * 3);
const textureCoordinates = vertexFormat.st ? new Float32Array(size * 2) : void 0;
const normals = vertexFormat.normal ? new Float32Array(size * 3) : void 0;
const tangents = vertexFormat.tangent ? new Float32Array(size * 3) : void 0;
const bitangents = vertexFormat.bitangent ? new Float32Array(size * 3) : void 0;
const shadowVolume = options.shadowVolume;
const extrudeNormals = shadowVolume ? new Float32Array(size * 3) : void 0;
let textureCoordIndex = 0;
let normal2 = scratchNormal3;
let tangent = scratchTangent;
let bitangent = scratchBitangent;
const projection = new GeographicProjection_default(ellipsoid);
const projectedCenter = projection.project(
ellipsoid.cartesianToCartographic(center, scratchCartographic3),
projectedCenterScratch
);
const geodeticNormal = ellipsoid.scaleToGeodeticSurface(
center,
scratchCartesian14
);
ellipsoid.geodeticSurfaceNormal(geodeticNormal, geodeticNormal);
const rotation = Quaternion_default.fromAxisAngle(
geodeticNormal,
stRotation,
quaternionScratch
);
const textureMatrix = Matrix3_default.fromQuaternion(rotation, textureMatrixScratch);
const minTexCoord = Cartesian2_default.fromElements(
Number.POSITIVE_INFINITY,
Number.POSITIVE_INFINITY,
scratchMinTexCoord
);
const maxTexCoord = Cartesian2_default.fromElements(
Number.NEGATIVE_INFINITY,
Number.NEGATIVE_INFINITY,
scratchMaxTexCoord
);
let length3 = positions.length;
const stOffset = length3 / 3 * 2;
for (let i = 0; i < length3; i += 3) {
const i1 = i + 1;
const i2 = i + 2;
let position = Cartesian3_default.fromArray(positions, i, scratchCartesian14);
let extrudedPosition;
if (vertexFormat.st) {
const rotatedPoint = Matrix3_default.multiplyByVector(
textureMatrix,
position,
scratchCartesian26
);
const projectedPoint = projection.project(
ellipsoid.cartesianToCartographic(rotatedPoint, scratchCartographic3),
scratchCartesian36
);
Cartesian3_default.subtract(projectedPoint, projectedCenter, projectedPoint);
texCoordScratch.x = (projectedPoint.x + semiMajorAxis) / (2 * semiMajorAxis);
texCoordScratch.y = (projectedPoint.y + semiMinorAxis) / (2 * semiMinorAxis);
minTexCoord.x = Math.min(texCoordScratch.x, minTexCoord.x);
minTexCoord.y = Math.min(texCoordScratch.y, minTexCoord.y);
maxTexCoord.x = Math.max(texCoordScratch.x, maxTexCoord.x);
maxTexCoord.y = Math.max(texCoordScratch.y, maxTexCoord.y);
textureCoordinates[textureCoordIndex + stOffset] = texCoordScratch.x;
textureCoordinates[textureCoordIndex + 1 + stOffset] = texCoordScratch.y;
textureCoordinates[textureCoordIndex++] = texCoordScratch.x;
textureCoordinates[textureCoordIndex++] = texCoordScratch.y;
}
position = ellipsoid.scaleToGeodeticSurface(position, position);
extrudedPosition = Cartesian3_default.clone(position, scratchCartesian26);
normal2 = ellipsoid.geodeticSurfaceNormal(position, normal2);
if (shadowVolume) {
extrudeNormals[i + length3] = -normal2.x;
extrudeNormals[i1 + length3] = -normal2.y;
extrudeNormals[i2 + length3] = -normal2.z;
}
let scaledNormal = Cartesian3_default.multiplyByScalar(
normal2,
height,
scratchCartesian42
);
position = Cartesian3_default.add(position, scaledNormal, position);
scaledNormal = Cartesian3_default.multiplyByScalar(
normal2,
extrudedHeight,
scaledNormal
);
extrudedPosition = Cartesian3_default.add(
extrudedPosition,
scaledNormal,
extrudedPosition
);
if (vertexFormat.position) {
finalPositions[i + length3] = extrudedPosition.x;
finalPositions[i1 + length3] = extrudedPosition.y;
finalPositions[i2 + length3] = extrudedPosition.z;
finalPositions[i] = position.x;
finalPositions[i1] = position.y;
finalPositions[i2] = position.z;
}
if (vertexFormat.normal || vertexFormat.tangent || vertexFormat.bitangent) {
bitangent = Cartesian3_default.clone(normal2, bitangent);
const next = Cartesian3_default.fromArray(
positions,
(i + 3) % length3,
scratchCartesian42
);
Cartesian3_default.subtract(next, position, next);
const bottom = Cartesian3_default.subtract(
extrudedPosition,
position,
scratchCartesian36
);
normal2 = Cartesian3_default.normalize(
Cartesian3_default.cross(bottom, next, normal2),
normal2
);
if (vertexFormat.normal) {
normals[i] = normal2.x;
normals[i1] = normal2.y;
normals[i2] = normal2.z;
normals[i + length3] = normal2.x;
normals[i1 + length3] = normal2.y;
normals[i2 + length3] = normal2.z;
}
if (vertexFormat.tangent) {
tangent = Cartesian3_default.normalize(
Cartesian3_default.cross(bitangent, normal2, tangent),
tangent
);
tangents[i] = tangent.x;
tangents[i1] = tangent.y;
tangents[i2] = tangent.z;
tangents[i + length3] = tangent.x;
tangents[i + 1 + length3] = tangent.y;
tangents[i + 2 + length3] = tangent.z;
}
if (vertexFormat.bitangent) {
bitangents[i] = bitangent.x;
bitangents[i1] = bitangent.y;
bitangents[i2] = bitangent.z;
bitangents[i + length3] = bitangent.x;
bitangents[i1 + length3] = bitangent.y;
bitangents[i2 + length3] = bitangent.z;
}
}
}
if (vertexFormat.st) {
length3 = textureCoordinates.length;
for (let k = 0; k < length3; k += 2) {
textureCoordinates[k] = (textureCoordinates[k] - minTexCoord.x) / (maxTexCoord.x - minTexCoord.x);
textureCoordinates[k + 1] = (textureCoordinates[k + 1] - minTexCoord.y) / (maxTexCoord.y - minTexCoord.y);
}
}
const attributes = new GeometryAttributes_default();
if (vertexFormat.position) {
attributes.position = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.DOUBLE,
componentsPerAttribute: 3,
values: finalPositions
});
}
if (vertexFormat.st) {
attributes.st = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.FLOAT,
componentsPerAttribute: 2,
values: textureCoordinates
});
}
if (vertexFormat.normal) {
attributes.normal = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.FLOAT,
componentsPerAttribute: 3,
values: normals
});
}
if (vertexFormat.tangent) {
attributes.tangent = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.FLOAT,
componentsPerAttribute: 3,
values: tangents
});
}
if (vertexFormat.bitangent) {
attributes.bitangent = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.FLOAT,
componentsPerAttribute: 3,
values: bitangents
});
}
if (shadowVolume) {
attributes.extrudeDirection = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.FLOAT,
componentsPerAttribute: 3,
values: extrudeNormals
});
}
if (defined_default(options.offsetAttribute)) {
let offsetAttribute = new Uint8Array(size);
if (options.offsetAttribute === GeometryOffsetAttribute_default.TOP) {
offsetAttribute = offsetAttribute.fill(1, 0, size / 2);
} else {
const offsetValue = options.offsetAttribute === GeometryOffsetAttribute_default.NONE ? 0 : 1;
offsetAttribute = offsetAttribute.fill(offsetValue);
}
attributes.applyOffset = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.UNSIGNED_BYTE,
componentsPerAttribute: 1,
values: offsetAttribute
});
}
return attributes;
}
function computeWallIndices(positions) {
const length3 = positions.length / 3;
const indices2 = IndexDatatype_default.createTypedArray(length3, length3 * 6);
let index = 0;
for (let i = 0; i < length3; i++) {
const UL = i;
const LL = i + length3;
const UR = (UL + 1) % length3;
const LR = UR + length3;
indices2[index++] = UL;
indices2[index++] = LL;
indices2[index++] = UR;
indices2[index++] = UR;
indices2[index++] = LL;
indices2[index++] = LR;
}
return indices2;
}
var topBoundingSphere = new BoundingSphere_default();
var bottomBoundingSphere = new BoundingSphere_default();
function computeExtrudedEllipse(options) {
const center = options.center;
const ellipsoid = options.ellipsoid;
const semiMajorAxis = options.semiMajorAxis;
let scaledNormal = Cartesian3_default.multiplyByScalar(
ellipsoid.geodeticSurfaceNormal(center, scratchCartesian14),
options.height,
scratchCartesian14
);
topBoundingSphere.center = Cartesian3_default.add(
center,
scaledNormal,
topBoundingSphere.center
);
topBoundingSphere.radius = semiMajorAxis;
scaledNormal = Cartesian3_default.multiplyByScalar(
ellipsoid.geodeticSurfaceNormal(center, scaledNormal),
options.extrudedHeight,
scaledNormal
);
bottomBoundingSphere.center = Cartesian3_default.add(
center,
scaledNormal,
bottomBoundingSphere.center
);
bottomBoundingSphere.radius = semiMajorAxis;
const cep = EllipseGeometryLibrary_default.computeEllipsePositions(
options,
true,
true
);
const positions = cep.positions;
const numPts = cep.numPts;
const outerPositions = cep.outerPositions;
const boundingSphere = BoundingSphere_default.union(
topBoundingSphere,
bottomBoundingSphere
);
const topBottomAttributes = computeTopBottomAttributes(
positions,
options,
true
);
let indices2 = topIndices(numPts);
const length3 = indices2.length;
indices2.length = length3 * 2;
const posLength = positions.length / 3;
for (let i = 0; i < length3; i += 3) {
indices2[i + length3] = indices2[i + 2] + posLength;
indices2[i + 1 + length3] = indices2[i + 1] + posLength;
indices2[i + 2 + length3] = indices2[i] + posLength;
}
const topBottomIndices = IndexDatatype_default.createTypedArray(
posLength * 2 / 3,
indices2
);
const topBottomGeo = new Geometry_default({
attributes: topBottomAttributes,
indices: topBottomIndices,
primitiveType: PrimitiveType_default.TRIANGLES
});
const wallAttributes = computeWallAttributes(outerPositions, options);
indices2 = computeWallIndices(outerPositions);
const wallIndices = IndexDatatype_default.createTypedArray(
outerPositions.length * 2 / 3,
indices2
);
const wallGeo = new Geometry_default({
attributes: wallAttributes,
indices: wallIndices,
primitiveType: PrimitiveType_default.TRIANGLES
});
const geo = GeometryPipeline_default.combineInstances([
new GeometryInstance_default({
geometry: topBottomGeo
}),
new GeometryInstance_default({
geometry: wallGeo
})
]);
return {
boundingSphere,
attributes: geo[0].attributes,
indices: geo[0].indices
};
}
function computeRectangle(center, semiMajorAxis, semiMinorAxis, rotation, granularity, ellipsoid, result) {
const cep = EllipseGeometryLibrary_default.computeEllipsePositions(
{
center,
semiMajorAxis,
semiMinorAxis,
rotation,
granularity
},
false,
true
);
const positionsFlat = cep.outerPositions;
const positionsCount = positionsFlat.length / 3;
const positions = new Array(positionsCount);
for (let i = 0; i < positionsCount; ++i) {
positions[i] = Cartesian3_default.fromArray(positionsFlat, i * 3);
}
const rectangle = Rectangle_default.fromCartesianArray(positions, ellipsoid, result);
if (rectangle.width > Math_default.PI) {
rectangle.north = rectangle.north > 0 ? Math_default.PI_OVER_TWO - Math_default.EPSILON7 : rectangle.north;
rectangle.south = rectangle.south < 0 ? Math_default.EPSILON7 - Math_default.PI_OVER_TWO : rectangle.south;
rectangle.east = Math_default.PI;
rectangle.west = -Math_default.PI;
}
return rectangle;
}
function EllipseGeometry(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
const center = options.center;
const ellipsoid = defaultValue_default(options.ellipsoid, Ellipsoid_default.WGS84);
const semiMajorAxis = options.semiMajorAxis;
const semiMinorAxis = options.semiMinorAxis;
const granularity = defaultValue_default(
options.granularity,
Math_default.RADIANS_PER_DEGREE
);
const vertexFormat = defaultValue_default(options.vertexFormat, VertexFormat_default.DEFAULT);
Check_default.defined("options.center", center);
Check_default.typeOf.number("options.semiMajorAxis", semiMajorAxis);
Check_default.typeOf.number("options.semiMinorAxis", semiMinorAxis);
if (semiMajorAxis < semiMinorAxis) {
throw new DeveloperError_default(
"semiMajorAxis must be greater than or equal to the semiMinorAxis."
);
}
if (granularity <= 0) {
throw new DeveloperError_default("granularity must be greater than zero.");
}
const height = defaultValue_default(options.height, 0);
const extrudedHeight = defaultValue_default(options.extrudedHeight, height);
this._center = Cartesian3_default.clone(center);
this._semiMajorAxis = semiMajorAxis;
this._semiMinorAxis = semiMinorAxis;
this._ellipsoid = Ellipsoid_default.clone(ellipsoid);
this._rotation = defaultValue_default(options.rotation, 0);
this._stRotation = defaultValue_default(options.stRotation, 0);
this._height = Math.max(extrudedHeight, height);
this._granularity = granularity;
this._vertexFormat = VertexFormat_default.clone(vertexFormat);
this._extrudedHeight = Math.min(extrudedHeight, height);
this._shadowVolume = defaultValue_default(options.shadowVolume, false);
this._workerName = "createEllipseGeometry";
this._offsetAttribute = options.offsetAttribute;
this._rectangle = void 0;
this._textureCoordinateRotationPoints = void 0;
}
EllipseGeometry.packedLength = Cartesian3_default.packedLength + Ellipsoid_default.packedLength + VertexFormat_default.packedLength + 9;
EllipseGeometry.pack = function(value, array, startingIndex) {
Check_default.defined("value", value);
Check_default.defined("array", array);
startingIndex = defaultValue_default(startingIndex, 0);
Cartesian3_default.pack(value._center, array, startingIndex);
startingIndex += Cartesian3_default.packedLength;
Ellipsoid_default.pack(value._ellipsoid, array, startingIndex);
startingIndex += Ellipsoid_default.packedLength;
VertexFormat_default.pack(value._vertexFormat, array, startingIndex);
startingIndex += VertexFormat_default.packedLength;
array[startingIndex++] = value._semiMajorAxis;
array[startingIndex++] = value._semiMinorAxis;
array[startingIndex++] = value._rotation;
array[startingIndex++] = value._stRotation;
array[startingIndex++] = value._height;
array[startingIndex++] = value._granularity;
array[startingIndex++] = value._extrudedHeight;
array[startingIndex++] = value._shadowVolume ? 1 : 0;
array[startingIndex] = defaultValue_default(value._offsetAttribute, -1);
return array;
};
var scratchCenter2 = new Cartesian3_default();
var scratchEllipsoid = new Ellipsoid_default();
var scratchVertexFormat2 = new VertexFormat_default();
var scratchOptions3 = {
center: scratchCenter2,
ellipsoid: scratchEllipsoid,
vertexFormat: scratchVertexFormat2,
semiMajorAxis: void 0,
semiMinorAxis: void 0,
rotation: void 0,
stRotation: void 0,
height: void 0,
granularity: void 0,
extrudedHeight: void 0,
shadowVolume: void 0,
offsetAttribute: void 0
};
EllipseGeometry.unpack = function(array, startingIndex, result) {
Check_default.defined("array", array);
startingIndex = defaultValue_default(startingIndex, 0);
const center = Cartesian3_default.unpack(array, startingIndex, scratchCenter2);
startingIndex += Cartesian3_default.packedLength;
const ellipsoid = Ellipsoid_default.unpack(array, startingIndex, scratchEllipsoid);
startingIndex += Ellipsoid_default.packedLength;
const vertexFormat = VertexFormat_default.unpack(
array,
startingIndex,
scratchVertexFormat2
);
startingIndex += VertexFormat_default.packedLength;
const semiMajorAxis = array[startingIndex++];
const semiMinorAxis = array[startingIndex++];
const rotation = array[startingIndex++];
const stRotation = array[startingIndex++];
const height = array[startingIndex++];
const granularity = array[startingIndex++];
const extrudedHeight = array[startingIndex++];
const shadowVolume = array[startingIndex++] === 1;
const offsetAttribute = array[startingIndex];
if (!defined_default(result)) {
scratchOptions3.height = height;
scratchOptions3.extrudedHeight = extrudedHeight;
scratchOptions3.granularity = granularity;
scratchOptions3.stRotation = stRotation;
scratchOptions3.rotation = rotation;
scratchOptions3.semiMajorAxis = semiMajorAxis;
scratchOptions3.semiMinorAxis = semiMinorAxis;
scratchOptions3.shadowVolume = shadowVolume;
scratchOptions3.offsetAttribute = offsetAttribute === -1 ? void 0 : offsetAttribute;
return new EllipseGeometry(scratchOptions3);
}
result._center = Cartesian3_default.clone(center, result._center);
result._ellipsoid = Ellipsoid_default.clone(ellipsoid, result._ellipsoid);
result._vertexFormat = VertexFormat_default.clone(vertexFormat, result._vertexFormat);
result._semiMajorAxis = semiMajorAxis;
result._semiMinorAxis = semiMinorAxis;
result._rotation = rotation;
result._stRotation = stRotation;
result._height = height;
result._granularity = granularity;
result._extrudedHeight = extrudedHeight;
result._shadowVolume = shadowVolume;
result._offsetAttribute = offsetAttribute === -1 ? void 0 : offsetAttribute;
return result;
};
EllipseGeometry.computeRectangle = function(options, result) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
const center = options.center;
const ellipsoid = defaultValue_default(options.ellipsoid, Ellipsoid_default.WGS84);
const semiMajorAxis = options.semiMajorAxis;
const semiMinorAxis = options.semiMinorAxis;
const granularity = defaultValue_default(
options.granularity,
Math_default.RADIANS_PER_DEGREE
);
const rotation = defaultValue_default(options.rotation, 0);
Check_default.defined("options.center", center);
Check_default.typeOf.number("options.semiMajorAxis", semiMajorAxis);
Check_default.typeOf.number("options.semiMinorAxis", semiMinorAxis);
if (semiMajorAxis < semiMinorAxis) {
throw new DeveloperError_default(
"semiMajorAxis must be greater than or equal to the semiMinorAxis."
);
}
if (granularity <= 0) {
throw new DeveloperError_default("granularity must be greater than zero.");
}
return computeRectangle(
center,
semiMajorAxis,
semiMinorAxis,
rotation,
granularity,
ellipsoid,
result
);
};
EllipseGeometry.createGeometry = function(ellipseGeometry) {
if (ellipseGeometry._semiMajorAxis <= 0 || ellipseGeometry._semiMinorAxis <= 0) {
return;
}
const height = ellipseGeometry._height;
const extrudedHeight = ellipseGeometry._extrudedHeight;
const extrude = !Math_default.equalsEpsilon(
height,
extrudedHeight,
0,
Math_default.EPSILON2
);
ellipseGeometry._center = ellipseGeometry._ellipsoid.scaleToGeodeticSurface(
ellipseGeometry._center,
ellipseGeometry._center
);
const options = {
center: ellipseGeometry._center,
semiMajorAxis: ellipseGeometry._semiMajorAxis,
semiMinorAxis: ellipseGeometry._semiMinorAxis,
ellipsoid: ellipseGeometry._ellipsoid,
rotation: ellipseGeometry._rotation,
height,
granularity: ellipseGeometry._granularity,
vertexFormat: ellipseGeometry._vertexFormat,
stRotation: ellipseGeometry._stRotation
};
let geometry;
if (extrude) {
options.extrudedHeight = extrudedHeight;
options.shadowVolume = ellipseGeometry._shadowVolume;
options.offsetAttribute = ellipseGeometry._offsetAttribute;
geometry = computeExtrudedEllipse(options);
} else {
geometry = computeEllipse(options);
if (defined_default(ellipseGeometry._offsetAttribute)) {
const length3 = geometry.attributes.position.values.length;
const offsetValue = ellipseGeometry._offsetAttribute === GeometryOffsetAttribute_default.NONE ? 0 : 1;
const applyOffset = new Uint8Array(length3 / 3).fill(offsetValue);
geometry.attributes.applyOffset = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.UNSIGNED_BYTE,
componentsPerAttribute: 1,
values: applyOffset
});
}
}
return new Geometry_default({
attributes: geometry.attributes,
indices: geometry.indices,
primitiveType: PrimitiveType_default.TRIANGLES,
boundingSphere: geometry.boundingSphere,
offsetAttribute: ellipseGeometry._offsetAttribute
});
};
EllipseGeometry.createShadowVolume = function(ellipseGeometry, minHeightFunc, maxHeightFunc) {
const granularity = ellipseGeometry._granularity;
const ellipsoid = ellipseGeometry._ellipsoid;
const minHeight = minHeightFunc(granularity, ellipsoid);
const maxHeight = maxHeightFunc(granularity, ellipsoid);
return new EllipseGeometry({
center: ellipseGeometry._center,
semiMajorAxis: ellipseGeometry._semiMajorAxis,
semiMinorAxis: ellipseGeometry._semiMinorAxis,
ellipsoid,
rotation: ellipseGeometry._rotation,
stRotation: ellipseGeometry._stRotation,
granularity,
extrudedHeight: minHeight,
height: maxHeight,
vertexFormat: VertexFormat_default.POSITION_ONLY,
shadowVolume: true
});
};
function textureCoordinateRotationPoints(ellipseGeometry) {
const stRotation = -ellipseGeometry._stRotation;
if (stRotation === 0) {
return [0, 0, 0, 1, 1, 0];
}
const cep = EllipseGeometryLibrary_default.computeEllipsePositions(
{
center: ellipseGeometry._center,
semiMajorAxis: ellipseGeometry._semiMajorAxis,
semiMinorAxis: ellipseGeometry._semiMinorAxis,
rotation: ellipseGeometry._rotation,
granularity: ellipseGeometry._granularity
},
false,
true
);
const positionsFlat = cep.outerPositions;
const positionsCount = positionsFlat.length / 3;
const positions = new Array(positionsCount);
for (let i = 0; i < positionsCount; ++i) {
positions[i] = Cartesian3_default.fromArray(positionsFlat, i * 3);
}
const ellipsoid = ellipseGeometry._ellipsoid;
const boundingRectangle = ellipseGeometry.rectangle;
return Geometry_default._textureCoordinateRotationPoints(
positions,
stRotation,
ellipsoid,
boundingRectangle
);
}
Object.defineProperties(EllipseGeometry.prototype, {
rectangle: {
get: function() {
if (!defined_default(this._rectangle)) {
this._rectangle = computeRectangle(
this._center,
this._semiMajorAxis,
this._semiMinorAxis,
this._rotation,
this._granularity,
this._ellipsoid
);
}
return this._rectangle;
}
},
textureCoordinateRotationPoints: {
get: function() {
if (!defined_default(this._textureCoordinateRotationPoints)) {
this._textureCoordinateRotationPoints = textureCoordinateRotationPoints(
this
);
}
return this._textureCoordinateRotationPoints;
}
}
});
var EllipseGeometry_default = EllipseGeometry;
// Source/Core/CircleGeometry.js
function CircleGeometry(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
const radius = options.radius;
Check_default.typeOf.number("radius", radius);
const ellipseGeometryOptions = {
center: options.center,
semiMajorAxis: radius,
semiMinorAxis: radius,
ellipsoid: options.ellipsoid,
height: options.height,
extrudedHeight: options.extrudedHeight,
granularity: options.granularity,
vertexFormat: options.vertexFormat,
stRotation: options.stRotation,
shadowVolume: options.shadowVolume
};
this._ellipseGeometry = new EllipseGeometry_default(ellipseGeometryOptions);
this._workerName = "createCircleGeometry";
}
CircleGeometry.packedLength = EllipseGeometry_default.packedLength;
CircleGeometry.pack = function(value, array, startingIndex) {
Check_default.typeOf.object("value", value);
return EllipseGeometry_default.pack(value._ellipseGeometry, array, startingIndex);
};
var scratchEllipseGeometry = new EllipseGeometry_default({
center: new Cartesian3_default(),
semiMajorAxis: 1,
semiMinorAxis: 1
});
var scratchOptions4 = {
center: new Cartesian3_default(),
radius: void 0,
ellipsoid: Ellipsoid_default.clone(Ellipsoid_default.UNIT_SPHERE),
height: void 0,
extrudedHeight: void 0,
granularity: void 0,
vertexFormat: new VertexFormat_default(),
stRotation: void 0,
semiMajorAxis: void 0,
semiMinorAxis: void 0,
shadowVolume: void 0
};
CircleGeometry.unpack = function(array, startingIndex, result) {
const ellipseGeometry = EllipseGeometry_default.unpack(
array,
startingIndex,
scratchEllipseGeometry
);
scratchOptions4.center = Cartesian3_default.clone(
ellipseGeometry._center,
scratchOptions4.center
);
scratchOptions4.ellipsoid = Ellipsoid_default.clone(
ellipseGeometry._ellipsoid,
scratchOptions4.ellipsoid
);
scratchOptions4.height = ellipseGeometry._height;
scratchOptions4.extrudedHeight = ellipseGeometry._extrudedHeight;
scratchOptions4.granularity = ellipseGeometry._granularity;
scratchOptions4.vertexFormat = VertexFormat_default.clone(
ellipseGeometry._vertexFormat,
scratchOptions4.vertexFormat
);
scratchOptions4.stRotation = ellipseGeometry._stRotation;
scratchOptions4.shadowVolume = ellipseGeometry._shadowVolume;
if (!defined_default(result)) {
scratchOptions4.radius = ellipseGeometry._semiMajorAxis;
return new CircleGeometry(scratchOptions4);
}
scratchOptions4.semiMajorAxis = ellipseGeometry._semiMajorAxis;
scratchOptions4.semiMinorAxis = ellipseGeometry._semiMinorAxis;
result._ellipseGeometry = new EllipseGeometry_default(scratchOptions4);
return result;
};
CircleGeometry.createGeometry = function(circleGeometry) {
return EllipseGeometry_default.createGeometry(circleGeometry._ellipseGeometry);
};
CircleGeometry.createShadowVolume = function(circleGeometry, minHeightFunc, maxHeightFunc) {
const granularity = circleGeometry._ellipseGeometry._granularity;
const ellipsoid = circleGeometry._ellipseGeometry._ellipsoid;
const minHeight = minHeightFunc(granularity, ellipsoid);
const maxHeight = maxHeightFunc(granularity, ellipsoid);
return new CircleGeometry({
center: circleGeometry._ellipseGeometry._center,
radius: circleGeometry._ellipseGeometry._semiMajorAxis,
ellipsoid,
stRotation: circleGeometry._ellipseGeometry._stRotation,
granularity,
extrudedHeight: minHeight,
height: maxHeight,
vertexFormat: VertexFormat_default.POSITION_ONLY,
shadowVolume: true
});
};
Object.defineProperties(CircleGeometry.prototype, {
rectangle: {
get: function() {
return this._ellipseGeometry.rectangle;
}
},
textureCoordinateRotationPoints: {
get: function() {
return this._ellipseGeometry.textureCoordinateRotationPoints;
}
}
});
var CircleGeometry_default = CircleGeometry;
// Source/Core/EllipseOutlineGeometry.js
var scratchCartesian15 = new Cartesian3_default();
var boundingSphereCenter2 = new Cartesian3_default();
function computeEllipse2(options) {
const center = options.center;
boundingSphereCenter2 = Cartesian3_default.multiplyByScalar(
options.ellipsoid.geodeticSurfaceNormal(center, boundingSphereCenter2),
options.height,
boundingSphereCenter2
);
boundingSphereCenter2 = Cartesian3_default.add(
center,
boundingSphereCenter2,
boundingSphereCenter2
);
const boundingSphere = new BoundingSphere_default(
boundingSphereCenter2,
options.semiMajorAxis
);
const positions = EllipseGeometryLibrary_default.computeEllipsePositions(
options,
false,
true
).outerPositions;
const attributes = new GeometryAttributes_default({
position: new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.DOUBLE,
componentsPerAttribute: 3,
values: EllipseGeometryLibrary_default.raisePositionsToHeight(
positions,
options,
false
)
})
});
const length3 = positions.length / 3;
const indices2 = IndexDatatype_default.createTypedArray(length3, length3 * 2);
let index = 0;
for (let i = 0; i < length3; ++i) {
indices2[index++] = i;
indices2[index++] = (i + 1) % length3;
}
return {
boundingSphere,
attributes,
indices: indices2
};
}
var topBoundingSphere2 = new BoundingSphere_default();
var bottomBoundingSphere2 = new BoundingSphere_default();
function computeExtrudedEllipse2(options) {
const center = options.center;
const ellipsoid = options.ellipsoid;
const semiMajorAxis = options.semiMajorAxis;
let scaledNormal = Cartesian3_default.multiplyByScalar(
ellipsoid.geodeticSurfaceNormal(center, scratchCartesian15),
options.height,
scratchCartesian15
);
topBoundingSphere2.center = Cartesian3_default.add(
center,
scaledNormal,
topBoundingSphere2.center
);
topBoundingSphere2.radius = semiMajorAxis;
scaledNormal = Cartesian3_default.multiplyByScalar(
ellipsoid.geodeticSurfaceNormal(center, scaledNormal),
options.extrudedHeight,
scaledNormal
);
bottomBoundingSphere2.center = Cartesian3_default.add(
center,
scaledNormal,
bottomBoundingSphere2.center
);
bottomBoundingSphere2.radius = semiMajorAxis;
let positions = EllipseGeometryLibrary_default.computeEllipsePositions(
options,
false,
true
).outerPositions;
const attributes = new GeometryAttributes_default({
position: new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.DOUBLE,
componentsPerAttribute: 3,
values: EllipseGeometryLibrary_default.raisePositionsToHeight(
positions,
options,
true
)
})
});
positions = attributes.position.values;
const boundingSphere = BoundingSphere_default.union(
topBoundingSphere2,
bottomBoundingSphere2
);
let length3 = positions.length / 3;
if (defined_default(options.offsetAttribute)) {
let applyOffset = new Uint8Array(length3);
if (options.offsetAttribute === GeometryOffsetAttribute_default.TOP) {
applyOffset = applyOffset.fill(1, 0, length3 / 2);
} else {
const offsetValue = options.offsetAttribute === GeometryOffsetAttribute_default.NONE ? 0 : 1;
applyOffset = applyOffset.fill(offsetValue);
}
attributes.applyOffset = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.UNSIGNED_BYTE,
componentsPerAttribute: 1,
values: applyOffset
});
}
let numberOfVerticalLines = defaultValue_default(options.numberOfVerticalLines, 16);
numberOfVerticalLines = Math_default.clamp(
numberOfVerticalLines,
0,
length3 / 2
);
const indices2 = IndexDatatype_default.createTypedArray(
length3,
length3 * 2 + numberOfVerticalLines * 2
);
length3 /= 2;
let index = 0;
let i;
for (i = 0; i < length3; ++i) {
indices2[index++] = i;
indices2[index++] = (i + 1) % length3;
indices2[index++] = i + length3;
indices2[index++] = (i + 1) % length3 + length3;
}
let numSide;
if (numberOfVerticalLines > 0) {
const numSideLines = Math.min(numberOfVerticalLines, length3);
numSide = Math.round(length3 / numSideLines);
const maxI = Math.min(numSide * numberOfVerticalLines, length3);
for (i = 0; i < maxI; i += numSide) {
indices2[index++] = i;
indices2[index++] = i + length3;
}
}
return {
boundingSphere,
attributes,
indices: indices2
};
}
function EllipseOutlineGeometry(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
const center = options.center;
const ellipsoid = defaultValue_default(options.ellipsoid, Ellipsoid_default.WGS84);
const semiMajorAxis = options.semiMajorAxis;
const semiMinorAxis = options.semiMinorAxis;
const granularity = defaultValue_default(
options.granularity,
Math_default.RADIANS_PER_DEGREE
);
if (!defined_default(center)) {
throw new DeveloperError_default("center is required.");
}
if (!defined_default(semiMajorAxis)) {
throw new DeveloperError_default("semiMajorAxis is required.");
}
if (!defined_default(semiMinorAxis)) {
throw new DeveloperError_default("semiMinorAxis is required.");
}
if (semiMajorAxis < semiMinorAxis) {
throw new DeveloperError_default(
"semiMajorAxis must be greater than or equal to the semiMinorAxis."
);
}
if (granularity <= 0) {
throw new DeveloperError_default("granularity must be greater than zero.");
}
const height = defaultValue_default(options.height, 0);
const extrudedHeight = defaultValue_default(options.extrudedHeight, height);
this._center = Cartesian3_default.clone(center);
this._semiMajorAxis = semiMajorAxis;
this._semiMinorAxis = semiMinorAxis;
this._ellipsoid = Ellipsoid_default.clone(ellipsoid);
this._rotation = defaultValue_default(options.rotation, 0);
this._height = Math.max(extrudedHeight, height);
this._granularity = granularity;
this._extrudedHeight = Math.min(extrudedHeight, height);
this._numberOfVerticalLines = Math.max(
defaultValue_default(options.numberOfVerticalLines, 16),
0
);
this._offsetAttribute = options.offsetAttribute;
this._workerName = "createEllipseOutlineGeometry";
}
EllipseOutlineGeometry.packedLength = Cartesian3_default.packedLength + Ellipsoid_default.packedLength + 8;
EllipseOutlineGeometry.pack = function(value, array, startingIndex) {
if (!defined_default(value)) {
throw new DeveloperError_default("value is required");
}
if (!defined_default(array)) {
throw new DeveloperError_default("array is required");
}
startingIndex = defaultValue_default(startingIndex, 0);
Cartesian3_default.pack(value._center, array, startingIndex);
startingIndex += Cartesian3_default.packedLength;
Ellipsoid_default.pack(value._ellipsoid, array, startingIndex);
startingIndex += Ellipsoid_default.packedLength;
array[startingIndex++] = value._semiMajorAxis;
array[startingIndex++] = value._semiMinorAxis;
array[startingIndex++] = value._rotation;
array[startingIndex++] = value._height;
array[startingIndex++] = value._granularity;
array[startingIndex++] = value._extrudedHeight;
array[startingIndex++] = value._numberOfVerticalLines;
array[startingIndex] = defaultValue_default(value._offsetAttribute, -1);
return array;
};
var scratchCenter3 = new Cartesian3_default();
var scratchEllipsoid2 = new Ellipsoid_default();
var scratchOptions5 = {
center: scratchCenter3,
ellipsoid: scratchEllipsoid2,
semiMajorAxis: void 0,
semiMinorAxis: void 0,
rotation: void 0,
height: void 0,
granularity: void 0,
extrudedHeight: void 0,
numberOfVerticalLines: void 0,
offsetAttribute: void 0
};
EllipseOutlineGeometry.unpack = function(array, startingIndex, result) {
if (!defined_default(array)) {
throw new DeveloperError_default("array is required");
}
startingIndex = defaultValue_default(startingIndex, 0);
const center = Cartesian3_default.unpack(array, startingIndex, scratchCenter3);
startingIndex += Cartesian3_default.packedLength;
const ellipsoid = Ellipsoid_default.unpack(array, startingIndex, scratchEllipsoid2);
startingIndex += Ellipsoid_default.packedLength;
const semiMajorAxis = array[startingIndex++];
const semiMinorAxis = array[startingIndex++];
const rotation = array[startingIndex++];
const height = array[startingIndex++];
const granularity = array[startingIndex++];
const extrudedHeight = array[startingIndex++];
const numberOfVerticalLines = array[startingIndex++];
const offsetAttribute = array[startingIndex];
if (!defined_default(result)) {
scratchOptions5.height = height;
scratchOptions5.extrudedHeight = extrudedHeight;
scratchOptions5.granularity = granularity;
scratchOptions5.rotation = rotation;
scratchOptions5.semiMajorAxis = semiMajorAxis;
scratchOptions5.semiMinorAxis = semiMinorAxis;
scratchOptions5.numberOfVerticalLines = numberOfVerticalLines;
scratchOptions5.offsetAttribute = offsetAttribute === -1 ? void 0 : offsetAttribute;
return new EllipseOutlineGeometry(scratchOptions5);
}
result._center = Cartesian3_default.clone(center, result._center);
result._ellipsoid = Ellipsoid_default.clone(ellipsoid, result._ellipsoid);
result._semiMajorAxis = semiMajorAxis;
result._semiMinorAxis = semiMinorAxis;
result._rotation = rotation;
result._height = height;
result._granularity = granularity;
result._extrudedHeight = extrudedHeight;
result._numberOfVerticalLines = numberOfVerticalLines;
result._offsetAttribute = offsetAttribute === -1 ? void 0 : offsetAttribute;
return result;
};
EllipseOutlineGeometry.createGeometry = function(ellipseGeometry) {
if (ellipseGeometry._semiMajorAxis <= 0 || ellipseGeometry._semiMinorAxis <= 0) {
return;
}
const height = ellipseGeometry._height;
const extrudedHeight = ellipseGeometry._extrudedHeight;
const extrude = !Math_default.equalsEpsilon(
height,
extrudedHeight,
0,
Math_default.EPSILON2
);
ellipseGeometry._center = ellipseGeometry._ellipsoid.scaleToGeodeticSurface(
ellipseGeometry._center,
ellipseGeometry._center
);
const options = {
center: ellipseGeometry._center,
semiMajorAxis: ellipseGeometry._semiMajorAxis,
semiMinorAxis: ellipseGeometry._semiMinorAxis,
ellipsoid: ellipseGeometry._ellipsoid,
rotation: ellipseGeometry._rotation,
height,
granularity: ellipseGeometry._granularity,
numberOfVerticalLines: ellipseGeometry._numberOfVerticalLines
};
let geometry;
if (extrude) {
options.extrudedHeight = extrudedHeight;
options.offsetAttribute = ellipseGeometry._offsetAttribute;
geometry = computeExtrudedEllipse2(options);
} else {
geometry = computeEllipse2(options);
if (defined_default(ellipseGeometry._offsetAttribute)) {
const length3 = geometry.attributes.position.values.length;
const offsetValue = ellipseGeometry._offsetAttribute === GeometryOffsetAttribute_default.NONE ? 0 : 1;
const applyOffset = new Uint8Array(length3 / 3).fill(offsetValue);
geometry.attributes.applyOffset = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.UNSIGNED_BYTE,
componentsPerAttribute: 1,
values: applyOffset
});
}
}
return new Geometry_default({
attributes: geometry.attributes,
indices: geometry.indices,
primitiveType: PrimitiveType_default.LINES,
boundingSphere: geometry.boundingSphere,
offsetAttribute: ellipseGeometry._offsetAttribute
});
};
var EllipseOutlineGeometry_default = EllipseOutlineGeometry;
// Source/Core/CircleOutlineGeometry.js
function CircleOutlineGeometry(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
const radius = options.radius;
Check_default.typeOf.number("radius", radius);
const ellipseGeometryOptions = {
center: options.center,
semiMajorAxis: radius,
semiMinorAxis: radius,
ellipsoid: options.ellipsoid,
height: options.height,
extrudedHeight: options.extrudedHeight,
granularity: options.granularity,
numberOfVerticalLines: options.numberOfVerticalLines
};
this._ellipseGeometry = new EllipseOutlineGeometry_default(ellipseGeometryOptions);
this._workerName = "createCircleOutlineGeometry";
}
CircleOutlineGeometry.packedLength = EllipseOutlineGeometry_default.packedLength;
CircleOutlineGeometry.pack = function(value, array, startingIndex) {
Check_default.typeOf.object("value", value);
return EllipseOutlineGeometry_default.pack(
value._ellipseGeometry,
array,
startingIndex
);
};
var scratchEllipseGeometry2 = new EllipseOutlineGeometry_default({
center: new Cartesian3_default(),
semiMajorAxis: 1,
semiMinorAxis: 1
});
var scratchOptions6 = {
center: new Cartesian3_default(),
radius: void 0,
ellipsoid: Ellipsoid_default.clone(Ellipsoid_default.UNIT_SPHERE),
height: void 0,
extrudedHeight: void 0,
granularity: void 0,
numberOfVerticalLines: void 0,
semiMajorAxis: void 0,
semiMinorAxis: void 0
};
CircleOutlineGeometry.unpack = function(array, startingIndex, result) {
const ellipseGeometry = EllipseOutlineGeometry_default.unpack(
array,
startingIndex,
scratchEllipseGeometry2
);
scratchOptions6.center = Cartesian3_default.clone(
ellipseGeometry._center,
scratchOptions6.center
);
scratchOptions6.ellipsoid = Ellipsoid_default.clone(
ellipseGeometry._ellipsoid,
scratchOptions6.ellipsoid
);
scratchOptions6.height = ellipseGeometry._height;
scratchOptions6.extrudedHeight = ellipseGeometry._extrudedHeight;
scratchOptions6.granularity = ellipseGeometry._granularity;
scratchOptions6.numberOfVerticalLines = ellipseGeometry._numberOfVerticalLines;
if (!defined_default(result)) {
scratchOptions6.radius = ellipseGeometry._semiMajorAxis;
return new CircleOutlineGeometry(scratchOptions6);
}
scratchOptions6.semiMajorAxis = ellipseGeometry._semiMajorAxis;
scratchOptions6.semiMinorAxis = ellipseGeometry._semiMinorAxis;
result._ellipseGeometry = new EllipseOutlineGeometry_default(scratchOptions6);
return result;
};
CircleOutlineGeometry.createGeometry = function(circleGeometry) {
return EllipseOutlineGeometry_default.createGeometry(circleGeometry._ellipseGeometry);
};
var CircleOutlineGeometry_default = CircleOutlineGeometry;
// Source/Core/ClockRange.js
var ClockRange = {
UNBOUNDED: 0,
CLAMPED: 1,
LOOP_STOP: 2
};
var ClockRange_default = Object.freeze(ClockRange);
// Source/Core/ClockStep.js
var ClockStep = {
TICK_DEPENDENT: 0,
SYSTEM_CLOCK_MULTIPLIER: 1,
SYSTEM_CLOCK: 2
};
var ClockStep_default = Object.freeze(ClockStep);
// Source/Core/getTimestamp.js
var getTimestamp;
if (typeof performance !== "undefined" && typeof performance.now === "function" && isFinite(performance.now())) {
getTimestamp = function() {
return performance.now();
};
} else {
getTimestamp = function() {
return Date.now();
};
}
var getTimestamp_default = getTimestamp;
// Source/Core/Clock.js
function Clock(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
let currentTime = options.currentTime;
let startTime = options.startTime;
let stopTime = options.stopTime;
if (!defined_default(currentTime)) {
if (defined_default(startTime)) {
currentTime = JulianDate_default.clone(startTime);
} else if (defined_default(stopTime)) {
currentTime = JulianDate_default.addDays(stopTime, -1, new JulianDate_default());
} else {
currentTime = JulianDate_default.now();
}
} else {
currentTime = JulianDate_default.clone(currentTime);
}
if (!defined_default(startTime)) {
startTime = JulianDate_default.clone(currentTime);
} else {
startTime = JulianDate_default.clone(startTime);
}
if (!defined_default(stopTime)) {
stopTime = JulianDate_default.addDays(startTime, 1, new JulianDate_default());
} else {
stopTime = JulianDate_default.clone(stopTime);
}
if (JulianDate_default.greaterThan(startTime, stopTime)) {
throw new DeveloperError_default("startTime must come before stopTime.");
}
this.startTime = startTime;
this.stopTime = stopTime;
this.clockRange = defaultValue_default(options.clockRange, ClockRange_default.UNBOUNDED);
this.canAnimate = defaultValue_default(options.canAnimate, true);
this.onTick = new Event_default();
this.onStop = new Event_default();
this._currentTime = void 0;
this._multiplier = void 0;
this._clockStep = void 0;
this._shouldAnimate = void 0;
this._lastSystemTime = getTimestamp_default();
this.currentTime = currentTime;
this.multiplier = defaultValue_default(options.multiplier, 1);
this.shouldAnimate = defaultValue_default(options.shouldAnimate, false);
this.clockStep = defaultValue_default(
options.clockStep,
ClockStep_default.SYSTEM_CLOCK_MULTIPLIER
);
}
Object.defineProperties(Clock.prototype, {
currentTime: {
get: function() {
return this._currentTime;
},
set: function(value) {
if (JulianDate_default.equals(this._currentTime, value)) {
return;
}
if (this._clockStep === ClockStep_default.SYSTEM_CLOCK) {
this._clockStep = ClockStep_default.SYSTEM_CLOCK_MULTIPLIER;
}
this._currentTime = value;
}
},
multiplier: {
get: function() {
return this._multiplier;
},
set: function(value) {
if (this._multiplier === value) {
return;
}
if (this._clockStep === ClockStep_default.SYSTEM_CLOCK) {
this._clockStep = ClockStep_default.SYSTEM_CLOCK_MULTIPLIER;
}
this._multiplier = value;
}
},
clockStep: {
get: function() {
return this._clockStep;
},
set: function(value) {
if (value === ClockStep_default.SYSTEM_CLOCK) {
this._multiplier = 1;
this._shouldAnimate = true;
this._currentTime = JulianDate_default.now();
}
this._clockStep = value;
}
},
shouldAnimate: {
get: function() {
return this._shouldAnimate;
},
set: function(value) {
if (this._shouldAnimate === value) {
return;
}
if (this._clockStep === ClockStep_default.SYSTEM_CLOCK) {
this._clockStep = ClockStep_default.SYSTEM_CLOCK_MULTIPLIER;
}
this._shouldAnimate = value;
}
}
});
Clock.prototype.tick = function() {
const currentSystemTime = getTimestamp_default();
let currentTime = JulianDate_default.clone(this._currentTime);
if (this.canAnimate && this._shouldAnimate) {
const clockStep = this._clockStep;
if (clockStep === ClockStep_default.SYSTEM_CLOCK) {
currentTime = JulianDate_default.now(currentTime);
} else {
const multiplier = this._multiplier;
if (clockStep === ClockStep_default.TICK_DEPENDENT) {
currentTime = JulianDate_default.addSeconds(
currentTime,
multiplier,
currentTime
);
} else {
const milliseconds = currentSystemTime - this._lastSystemTime;
currentTime = JulianDate_default.addSeconds(
currentTime,
multiplier * (milliseconds / 1e3),
currentTime
);
}
const clockRange = this.clockRange;
const startTime = this.startTime;
const stopTime = this.stopTime;
if (clockRange === ClockRange_default.CLAMPED) {
if (JulianDate_default.lessThan(currentTime, startTime)) {
currentTime = JulianDate_default.clone(startTime, currentTime);
} else if (JulianDate_default.greaterThan(currentTime, stopTime)) {
currentTime = JulianDate_default.clone(stopTime, currentTime);
this.onStop.raiseEvent(this);
}
} else if (clockRange === ClockRange_default.LOOP_STOP) {
if (JulianDate_default.lessThan(currentTime, startTime)) {
currentTime = JulianDate_default.clone(startTime, currentTime);
}
while (JulianDate_default.greaterThan(currentTime, stopTime)) {
currentTime = JulianDate_default.addSeconds(
startTime,
JulianDate_default.secondsDifference(currentTime, stopTime),
currentTime
);
this.onStop.raiseEvent(this);
}
}
}
}
this._currentTime = currentTime;
this._lastSystemTime = currentSystemTime;
this.onTick.raiseEvent(this);
return currentTime;
};
var Clock_default = Clock;
// Source/Core/Color.js
function hue2rgb(m1, m2, h) {
if (h < 0) {
h += 1;
}
if (h > 1) {
h -= 1;
}
if (h * 6 < 1) {
return m1 + (m2 - m1) * 6 * h;
}
if (h * 2 < 1) {
return m2;
}
if (h * 3 < 2) {
return m1 + (m2 - m1) * (2 / 3 - h) * 6;
}
return m1;
}
function Color(red, green, blue, alpha) {
this.red = defaultValue_default(red, 1);
this.green = defaultValue_default(green, 1);
this.blue = defaultValue_default(blue, 1);
this.alpha = defaultValue_default(alpha, 1);
}
Color.fromCartesian4 = function(cartesian11, result) {
Check_default.typeOf.object("cartesian", cartesian11);
if (!defined_default(result)) {
return new Color(cartesian11.x, cartesian11.y, cartesian11.z, cartesian11.w);
}
result.red = cartesian11.x;
result.green = cartesian11.y;
result.blue = cartesian11.z;
result.alpha = cartesian11.w;
return result;
};
Color.fromBytes = function(red, green, blue, alpha, result) {
red = Color.byteToFloat(defaultValue_default(red, 255));
green = Color.byteToFloat(defaultValue_default(green, 255));
blue = Color.byteToFloat(defaultValue_default(blue, 255));
alpha = Color.byteToFloat(defaultValue_default(alpha, 255));
if (!defined_default(result)) {
return new Color(red, green, blue, alpha);
}
result.red = red;
result.green = green;
result.blue = blue;
result.alpha = alpha;
return result;
};
Color.fromAlpha = function(color, alpha, result) {
Check_default.typeOf.object("color", color);
Check_default.typeOf.number("alpha", alpha);
if (!defined_default(result)) {
return new Color(color.red, color.green, color.blue, alpha);
}
result.red = color.red;
result.green = color.green;
result.blue = color.blue;
result.alpha = alpha;
return result;
};
var scratchArrayBuffer;
var scratchUint32Array;
var scratchUint8Array;
if (FeatureDetection_default.supportsTypedArrays()) {
scratchArrayBuffer = new ArrayBuffer(4);
scratchUint32Array = new Uint32Array(scratchArrayBuffer);
scratchUint8Array = new Uint8Array(scratchArrayBuffer);
}
Color.fromRgba = function(rgba, result) {
scratchUint32Array[0] = rgba;
return Color.fromBytes(
scratchUint8Array[0],
scratchUint8Array[1],
scratchUint8Array[2],
scratchUint8Array[3],
result
);
};
Color.fromHsl = function(hue, saturation, lightness, alpha, result) {
hue = defaultValue_default(hue, 0) % 1;
saturation = defaultValue_default(saturation, 0);
lightness = defaultValue_default(lightness, 0);
alpha = defaultValue_default(alpha, 1);
let red = lightness;
let green = lightness;
let blue = lightness;
if (saturation !== 0) {
let m2;
if (lightness < 0.5) {
m2 = lightness * (1 + saturation);
} else {
m2 = lightness + saturation - lightness * saturation;
}
const m1 = 2 * lightness - m2;
red = hue2rgb(m1, m2, hue + 1 / 3);
green = hue2rgb(m1, m2, hue);
blue = hue2rgb(m1, m2, hue - 1 / 3);
}
if (!defined_default(result)) {
return new Color(red, green, blue, alpha);
}
result.red = red;
result.green = green;
result.blue = blue;
result.alpha = alpha;
return result;
};
Color.fromRandom = function(options, result) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
let red = options.red;
if (!defined_default(red)) {
const minimumRed = defaultValue_default(options.minimumRed, 0);
const maximumRed = defaultValue_default(options.maximumRed, 1);
Check_default.typeOf.number.lessThanOrEquals("minimumRed", minimumRed, maximumRed);
red = minimumRed + Math_default.nextRandomNumber() * (maximumRed - minimumRed);
}
let green = options.green;
if (!defined_default(green)) {
const minimumGreen = defaultValue_default(options.minimumGreen, 0);
const maximumGreen = defaultValue_default(options.maximumGreen, 1);
Check_default.typeOf.number.lessThanOrEquals(
"minimumGreen",
minimumGreen,
maximumGreen
);
green = minimumGreen + Math_default.nextRandomNumber() * (maximumGreen - minimumGreen);
}
let blue = options.blue;
if (!defined_default(blue)) {
const minimumBlue = defaultValue_default(options.minimumBlue, 0);
const maximumBlue = defaultValue_default(options.maximumBlue, 1);
Check_default.typeOf.number.lessThanOrEquals(
"minimumBlue",
minimumBlue,
maximumBlue
);
blue = minimumBlue + Math_default.nextRandomNumber() * (maximumBlue - minimumBlue);
}
let alpha = options.alpha;
if (!defined_default(alpha)) {
const minimumAlpha = defaultValue_default(options.minimumAlpha, 0);
const maximumAlpha = defaultValue_default(options.maximumAlpha, 1);
Check_default.typeOf.number.lessThanOrEquals(
"minumumAlpha",
minimumAlpha,
maximumAlpha
);
alpha = minimumAlpha + Math_default.nextRandomNumber() * (maximumAlpha - minimumAlpha);
}
if (!defined_default(result)) {
return new Color(red, green, blue, alpha);
}
result.red = red;
result.green = green;
result.blue = blue;
result.alpha = alpha;
return result;
};
var rgbaMatcher = /^#([0-9a-f])([0-9a-f])([0-9a-f])([0-9a-f])?$/i;
var rrggbbaaMatcher = /^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})?$/i;
var rgbParenthesesMatcher = /^rgba?\(\s*([0-9.]+%?)\s*,\s*([0-9.]+%?)\s*,\s*([0-9.]+%?)(?:\s*,\s*([0-9.]+))?\s*\)$/i;
var hslParenthesesMatcher = /^hsla?\(\s*([0-9.]+)\s*,\s*([0-9.]+%)\s*,\s*([0-9.]+%)(?:\s*,\s*([0-9.]+))?\s*\)$/i;
Color.fromCssColorString = function(color, result) {
Check_default.typeOf.string("color", color);
if (!defined_default(result)) {
result = new Color();
}
color = color.replace(/\s/g, "");
const namedColor = Color[color.toUpperCase()];
if (defined_default(namedColor)) {
Color.clone(namedColor, result);
return result;
}
let matches = rgbaMatcher.exec(color);
if (matches !== null) {
result.red = parseInt(matches[1], 16) / 15;
result.green = parseInt(matches[2], 16) / 15;
result.blue = parseInt(matches[3], 16) / 15;
result.alpha = parseInt(defaultValue_default(matches[4], "f"), 16) / 15;
return result;
}
matches = rrggbbaaMatcher.exec(color);
if (matches !== null) {
result.red = parseInt(matches[1], 16) / 255;
result.green = parseInt(matches[2], 16) / 255;
result.blue = parseInt(matches[3], 16) / 255;
result.alpha = parseInt(defaultValue_default(matches[4], "ff"), 16) / 255;
return result;
}
matches = rgbParenthesesMatcher.exec(color);
if (matches !== null) {
result.red = parseFloat(matches[1]) / ("%" === matches[1].substr(-1) ? 100 : 255);
result.green = parseFloat(matches[2]) / ("%" === matches[2].substr(-1) ? 100 : 255);
result.blue = parseFloat(matches[3]) / ("%" === matches[3].substr(-1) ? 100 : 255);
result.alpha = parseFloat(defaultValue_default(matches[4], "1.0"));
return result;
}
matches = hslParenthesesMatcher.exec(color);
if (matches !== null) {
return Color.fromHsl(
parseFloat(matches[1]) / 360,
parseFloat(matches[2]) / 100,
parseFloat(matches[3]) / 100,
parseFloat(defaultValue_default(matches[4], "1.0")),
result
);
}
result = void 0;
return result;
};
Color.packedLength = 4;
Color.pack = function(value, array, startingIndex) {
Check_default.typeOf.object("value", value);
Check_default.defined("array", array);
startingIndex = defaultValue_default(startingIndex, 0);
array[startingIndex++] = value.red;
array[startingIndex++] = value.green;
array[startingIndex++] = value.blue;
array[startingIndex] = value.alpha;
return array;
};
Color.unpack = function(array, startingIndex, result) {
Check_default.defined("array", array);
startingIndex = defaultValue_default(startingIndex, 0);
if (!defined_default(result)) {
result = new Color();
}
result.red = array[startingIndex++];
result.green = array[startingIndex++];
result.blue = array[startingIndex++];
result.alpha = array[startingIndex];
return result;
};
Color.byteToFloat = function(number) {
return number / 255;
};
Color.floatToByte = function(number) {
return number === 1 ? 255 : number * 256 | 0;
};
Color.clone = function(color, result) {
if (!defined_default(color)) {
return void 0;
}
if (!defined_default(result)) {
return new Color(color.red, color.green, color.blue, color.alpha);
}
result.red = color.red;
result.green = color.green;
result.blue = color.blue;
result.alpha = color.alpha;
return result;
};
Color.equals = function(left, right) {
return left === right || defined_default(left) && defined_default(right) && left.red === right.red && left.green === right.green && left.blue === right.blue && left.alpha === right.alpha;
};
Color.equalsArray = function(color, array, offset2) {
return color.red === array[offset2] && color.green === array[offset2 + 1] && color.blue === array[offset2 + 2] && color.alpha === array[offset2 + 3];
};
Color.prototype.clone = function(result) {
return Color.clone(this, result);
};
Color.prototype.equals = function(other) {
return Color.equals(this, other);
};
Color.prototype.equalsEpsilon = function(other, epsilon) {
return this === other || defined_default(other) && Math.abs(this.red - other.red) <= epsilon && Math.abs(this.green - other.green) <= epsilon && Math.abs(this.blue - other.blue) <= epsilon && Math.abs(this.alpha - other.alpha) <= epsilon;
};
Color.prototype.toString = function() {
return `(${this.red}, ${this.green}, ${this.blue}, ${this.alpha})`;
};
Color.prototype.toCssColorString = function() {
const red = Color.floatToByte(this.red);
const green = Color.floatToByte(this.green);
const blue = Color.floatToByte(this.blue);
if (this.alpha === 1) {
return `rgb(${red},${green},${blue})`;
}
return `rgba(${red},${green},${blue},${this.alpha})`;
};
Color.prototype.toCssHexString = function() {
let r = Color.floatToByte(this.red).toString(16);
if (r.length < 2) {
r = `0${r}`;
}
let g = Color.floatToByte(this.green).toString(16);
if (g.length < 2) {
g = `0${g}`;
}
let b = Color.floatToByte(this.blue).toString(16);
if (b.length < 2) {
b = `0${b}`;
}
if (this.alpha < 1) {
let hexAlpha = Color.floatToByte(this.alpha).toString(16);
if (hexAlpha.length < 2) {
hexAlpha = `0${hexAlpha}`;
}
return `#${r}${g}${b}${hexAlpha}`;
}
return `#${r}${g}${b}`;
};
Color.prototype.toBytes = function(result) {
const red = Color.floatToByte(this.red);
const green = Color.floatToByte(this.green);
const blue = Color.floatToByte(this.blue);
const alpha = Color.floatToByte(this.alpha);
if (!defined_default(result)) {
return [red, green, blue, alpha];
}
result[0] = red;
result[1] = green;
result[2] = blue;
result[3] = alpha;
return result;
};
Color.prototype.toRgba = function() {
scratchUint8Array[0] = Color.floatToByte(this.red);
scratchUint8Array[1] = Color.floatToByte(this.green);
scratchUint8Array[2] = Color.floatToByte(this.blue);
scratchUint8Array[3] = Color.floatToByte(this.alpha);
return scratchUint32Array[0];
};
Color.prototype.brighten = function(magnitude, result) {
Check_default.typeOf.number("magnitude", magnitude);
Check_default.typeOf.number.greaterThanOrEquals("magnitude", magnitude, 0);
Check_default.typeOf.object("result", result);
magnitude = 1 - magnitude;
result.red = 1 - (1 - this.red) * magnitude;
result.green = 1 - (1 - this.green) * magnitude;
result.blue = 1 - (1 - this.blue) * magnitude;
result.alpha = this.alpha;
return result;
};
Color.prototype.darken = function(magnitude, result) {
Check_default.typeOf.number("magnitude", magnitude);
Check_default.typeOf.number.greaterThanOrEquals("magnitude", magnitude, 0);
Check_default.typeOf.object("result", result);
magnitude = 1 - magnitude;
result.red = this.red * magnitude;
result.green = this.green * magnitude;
result.blue = this.blue * magnitude;
result.alpha = this.alpha;
return result;
};
Color.prototype.withAlpha = function(alpha, result) {
return Color.fromAlpha(this, alpha, result);
};
Color.add = function(left, right, result) {
Check_default.typeOf.object("left", left);
Check_default.typeOf.object("right", right);
Check_default.typeOf.object("result", result);
result.red = left.red + right.red;
result.green = left.green + right.green;
result.blue = left.blue + right.blue;
result.alpha = left.alpha + right.alpha;
return result;
};
Color.subtract = function(left, right, result) {
Check_default.typeOf.object("left", left);
Check_default.typeOf.object("right", right);
Check_default.typeOf.object("result", result);
result.red = left.red - right.red;
result.green = left.green - right.green;
result.blue = left.blue - right.blue;
result.alpha = left.alpha - right.alpha;
return result;
};
Color.multiply = function(left, right, result) {
Check_default.typeOf.object("left", left);
Check_default.typeOf.object("right", right);
Check_default.typeOf.object("result", result);
result.red = left.red * right.red;
result.green = left.green * right.green;
result.blue = left.blue * right.blue;
result.alpha = left.alpha * right.alpha;
return result;
};
Color.divide = function(left, right, result) {
Check_default.typeOf.object("left", left);
Check_default.typeOf.object("right", right);
Check_default.typeOf.object("result", result);
result.red = left.red / right.red;
result.green = left.green / right.green;
result.blue = left.blue / right.blue;
result.alpha = left.alpha / right.alpha;
return result;
};
Color.mod = function(left, right, result) {
Check_default.typeOf.object("left", left);
Check_default.typeOf.object("right", right);
Check_default.typeOf.object("result", result);
result.red = left.red % right.red;
result.green = left.green % right.green;
result.blue = left.blue % right.blue;
result.alpha = left.alpha % right.alpha;
return result;
};
Color.lerp = function(start, end, t, result) {
Check_default.typeOf.object("start", start);
Check_default.typeOf.object("end", end);
Check_default.typeOf.number("t", t);
Check_default.typeOf.object("result", result);
result.red = Math_default.lerp(start.red, end.red, t);
result.green = Math_default.lerp(start.green, end.green, t);
result.blue = Math_default.lerp(start.blue, end.blue, t);
result.alpha = Math_default.lerp(start.alpha, end.alpha, t);
return result;
};
Color.multiplyByScalar = function(color, scalar, result) {
Check_default.typeOf.object("color", color);
Check_default.typeOf.number("scalar", scalar);
Check_default.typeOf.object("result", result);
result.red = color.red * scalar;
result.green = color.green * scalar;
result.blue = color.blue * scalar;
result.alpha = color.alpha * scalar;
return result;
};
Color.divideByScalar = function(color, scalar, result) {
Check_default.typeOf.object("color", color);
Check_default.typeOf.number("scalar", scalar);
Check_default.typeOf.object("result", result);
result.red = color.red / scalar;
result.green = color.green / scalar;
result.blue = color.blue / scalar;
result.alpha = color.alpha / scalar;
return result;
};
Color.ALICEBLUE = Object.freeze(Color.fromCssColorString("#F0F8FF"));
Color.ANTIQUEWHITE = Object.freeze(Color.fromCssColorString("#FAEBD7"));
Color.AQUA = Object.freeze(Color.fromCssColorString("#00FFFF"));
Color.AQUAMARINE = Object.freeze(Color.fromCssColorString("#7FFFD4"));
Color.AZURE = Object.freeze(Color.fromCssColorString("#F0FFFF"));
Color.BEIGE = Object.freeze(Color.fromCssColorString("#F5F5DC"));
Color.BISQUE = Object.freeze(Color.fromCssColorString("#FFE4C4"));
Color.BLACK = Object.freeze(Color.fromCssColorString("#000000"));
Color.BLANCHEDALMOND = Object.freeze(Color.fromCssColorString("#FFEBCD"));
Color.BLUE = Object.freeze(Color.fromCssColorString("#0000FF"));
Color.BLUEVIOLET = Object.freeze(Color.fromCssColorString("#8A2BE2"));
Color.BROWN = Object.freeze(Color.fromCssColorString("#A52A2A"));
Color.BURLYWOOD = Object.freeze(Color.fromCssColorString("#DEB887"));
Color.CADETBLUE = Object.freeze(Color.fromCssColorString("#5F9EA0"));
Color.CHARTREUSE = Object.freeze(Color.fromCssColorString("#7FFF00"));
Color.CHOCOLATE = Object.freeze(Color.fromCssColorString("#D2691E"));
Color.CORAL = Object.freeze(Color.fromCssColorString("#FF7F50"));
Color.CORNFLOWERBLUE = Object.freeze(Color.fromCssColorString("#6495ED"));
Color.CORNSILK = Object.freeze(Color.fromCssColorString("#FFF8DC"));
Color.CRIMSON = Object.freeze(Color.fromCssColorString("#DC143C"));
Color.CYAN = Object.freeze(Color.fromCssColorString("#00FFFF"));
Color.DARKBLUE = Object.freeze(Color.fromCssColorString("#00008B"));
Color.DARKCYAN = Object.freeze(Color.fromCssColorString("#008B8B"));
Color.DARKGOLDENROD = Object.freeze(Color.fromCssColorString("#B8860B"));
Color.DARKGRAY = Object.freeze(Color.fromCssColorString("#A9A9A9"));
Color.DARKGREEN = Object.freeze(Color.fromCssColorString("#006400"));
Color.DARKGREY = Color.DARKGRAY;
Color.DARKKHAKI = Object.freeze(Color.fromCssColorString("#BDB76B"));
Color.DARKMAGENTA = Object.freeze(Color.fromCssColorString("#8B008B"));
Color.DARKOLIVEGREEN = Object.freeze(Color.fromCssColorString("#556B2F"));
Color.DARKORANGE = Object.freeze(Color.fromCssColorString("#FF8C00"));
Color.DARKORCHID = Object.freeze(Color.fromCssColorString("#9932CC"));
Color.DARKRED = Object.freeze(Color.fromCssColorString("#8B0000"));
Color.DARKSALMON = Object.freeze(Color.fromCssColorString("#E9967A"));
Color.DARKSEAGREEN = Object.freeze(Color.fromCssColorString("#8FBC8F"));
Color.DARKSLATEBLUE = Object.freeze(Color.fromCssColorString("#483D8B"));
Color.DARKSLATEGRAY = Object.freeze(Color.fromCssColorString("#2F4F4F"));
Color.DARKSLATEGREY = Color.DARKSLATEGRAY;
Color.DARKTURQUOISE = Object.freeze(Color.fromCssColorString("#00CED1"));
Color.DARKVIOLET = Object.freeze(Color.fromCssColorString("#9400D3"));
Color.DEEPPINK = Object.freeze(Color.fromCssColorString("#FF1493"));
Color.DEEPSKYBLUE = Object.freeze(Color.fromCssColorString("#00BFFF"));
Color.DIMGRAY = Object.freeze(Color.fromCssColorString("#696969"));
Color.DIMGREY = Color.DIMGRAY;
Color.DODGERBLUE = Object.freeze(Color.fromCssColorString("#1E90FF"));
Color.FIREBRICK = Object.freeze(Color.fromCssColorString("#B22222"));
Color.FLORALWHITE = Object.freeze(Color.fromCssColorString("#FFFAF0"));
Color.FORESTGREEN = Object.freeze(Color.fromCssColorString("#228B22"));
Color.FUCHSIA = Object.freeze(Color.fromCssColorString("#FF00FF"));
Color.GAINSBORO = Object.freeze(Color.fromCssColorString("#DCDCDC"));
Color.GHOSTWHITE = Object.freeze(Color.fromCssColorString("#F8F8FF"));
Color.GOLD = Object.freeze(Color.fromCssColorString("#FFD700"));
Color.GOLDENROD = Object.freeze(Color.fromCssColorString("#DAA520"));
Color.GRAY = Object.freeze(Color.fromCssColorString("#808080"));
Color.GREEN = Object.freeze(Color.fromCssColorString("#008000"));
Color.GREENYELLOW = Object.freeze(Color.fromCssColorString("#ADFF2F"));
Color.GREY = Color.GRAY;
Color.HONEYDEW = Object.freeze(Color.fromCssColorString("#F0FFF0"));
Color.HOTPINK = Object.freeze(Color.fromCssColorString("#FF69B4"));
Color.INDIANRED = Object.freeze(Color.fromCssColorString("#CD5C5C"));
Color.INDIGO = Object.freeze(Color.fromCssColorString("#4B0082"));
Color.IVORY = Object.freeze(Color.fromCssColorString("#FFFFF0"));
Color.KHAKI = Object.freeze(Color.fromCssColorString("#F0E68C"));
Color.LAVENDER = Object.freeze(Color.fromCssColorString("#E6E6FA"));
Color.LAVENDAR_BLUSH = Object.freeze(Color.fromCssColorString("#FFF0F5"));
Color.LAWNGREEN = Object.freeze(Color.fromCssColorString("#7CFC00"));
Color.LEMONCHIFFON = Object.freeze(Color.fromCssColorString("#FFFACD"));
Color.LIGHTBLUE = Object.freeze(Color.fromCssColorString("#ADD8E6"));
Color.LIGHTCORAL = Object.freeze(Color.fromCssColorString("#F08080"));
Color.LIGHTCYAN = Object.freeze(Color.fromCssColorString("#E0FFFF"));
Color.LIGHTGOLDENRODYELLOW = Object.freeze(Color.fromCssColorString("#FAFAD2"));
Color.LIGHTGRAY = Object.freeze(Color.fromCssColorString("#D3D3D3"));
Color.LIGHTGREEN = Object.freeze(Color.fromCssColorString("#90EE90"));
Color.LIGHTGREY = Color.LIGHTGRAY;
Color.LIGHTPINK = Object.freeze(Color.fromCssColorString("#FFB6C1"));
Color.LIGHTSEAGREEN = Object.freeze(Color.fromCssColorString("#20B2AA"));
Color.LIGHTSKYBLUE = Object.freeze(Color.fromCssColorString("#87CEFA"));
Color.LIGHTSLATEGRAY = Object.freeze(Color.fromCssColorString("#778899"));
Color.LIGHTSLATEGREY = Color.LIGHTSLATEGRAY;
Color.LIGHTSTEELBLUE = Object.freeze(Color.fromCssColorString("#B0C4DE"));
Color.LIGHTYELLOW = Object.freeze(Color.fromCssColorString("#FFFFE0"));
Color.LIME = Object.freeze(Color.fromCssColorString("#00FF00"));
Color.LIMEGREEN = Object.freeze(Color.fromCssColorString("#32CD32"));
Color.LINEN = Object.freeze(Color.fromCssColorString("#FAF0E6"));
Color.MAGENTA = Object.freeze(Color.fromCssColorString("#FF00FF"));
Color.MAROON = Object.freeze(Color.fromCssColorString("#800000"));
Color.MEDIUMAQUAMARINE = Object.freeze(Color.fromCssColorString("#66CDAA"));
Color.MEDIUMBLUE = Object.freeze(Color.fromCssColorString("#0000CD"));
Color.MEDIUMORCHID = Object.freeze(Color.fromCssColorString("#BA55D3"));
Color.MEDIUMPURPLE = Object.freeze(Color.fromCssColorString("#9370DB"));
Color.MEDIUMSEAGREEN = Object.freeze(Color.fromCssColorString("#3CB371"));
Color.MEDIUMSLATEBLUE = Object.freeze(Color.fromCssColorString("#7B68EE"));
Color.MEDIUMSPRINGGREEN = Object.freeze(Color.fromCssColorString("#00FA9A"));
Color.MEDIUMTURQUOISE = Object.freeze(Color.fromCssColorString("#48D1CC"));
Color.MEDIUMVIOLETRED = Object.freeze(Color.fromCssColorString("#C71585"));
Color.MIDNIGHTBLUE = Object.freeze(Color.fromCssColorString("#191970"));
Color.MINTCREAM = Object.freeze(Color.fromCssColorString("#F5FFFA"));
Color.MISTYROSE = Object.freeze(Color.fromCssColorString("#FFE4E1"));
Color.MOCCASIN = Object.freeze(Color.fromCssColorString("#FFE4B5"));
Color.NAVAJOWHITE = Object.freeze(Color.fromCssColorString("#FFDEAD"));
Color.NAVY = Object.freeze(Color.fromCssColorString("#000080"));
Color.OLDLACE = Object.freeze(Color.fromCssColorString("#FDF5E6"));
Color.OLIVE = Object.freeze(Color.fromCssColorString("#808000"));
Color.OLIVEDRAB = Object.freeze(Color.fromCssColorString("#6B8E23"));
Color.ORANGE = Object.freeze(Color.fromCssColorString("#FFA500"));
Color.ORANGERED = Object.freeze(Color.fromCssColorString("#FF4500"));
Color.ORCHID = Object.freeze(Color.fromCssColorString("#DA70D6"));
Color.PALEGOLDENROD = Object.freeze(Color.fromCssColorString("#EEE8AA"));
Color.PALEGREEN = Object.freeze(Color.fromCssColorString("#98FB98"));
Color.PALETURQUOISE = Object.freeze(Color.fromCssColorString("#AFEEEE"));
Color.PALEVIOLETRED = Object.freeze(Color.fromCssColorString("#DB7093"));
Color.PAPAYAWHIP = Object.freeze(Color.fromCssColorString("#FFEFD5"));
Color.PEACHPUFF = Object.freeze(Color.fromCssColorString("#FFDAB9"));
Color.PERU = Object.freeze(Color.fromCssColorString("#CD853F"));
Color.PINK = Object.freeze(Color.fromCssColorString("#FFC0CB"));
Color.PLUM = Object.freeze(Color.fromCssColorString("#DDA0DD"));
Color.POWDERBLUE = Object.freeze(Color.fromCssColorString("#B0E0E6"));
Color.PURPLE = Object.freeze(Color.fromCssColorString("#800080"));
Color.RED = Object.freeze(Color.fromCssColorString("#FF0000"));
Color.ROSYBROWN = Object.freeze(Color.fromCssColorString("#BC8F8F"));
Color.ROYALBLUE = Object.freeze(Color.fromCssColorString("#4169E1"));
Color.SADDLEBROWN = Object.freeze(Color.fromCssColorString("#8B4513"));
Color.SALMON = Object.freeze(Color.fromCssColorString("#FA8072"));
Color.SANDYBROWN = Object.freeze(Color.fromCssColorString("#F4A460"));
Color.SEAGREEN = Object.freeze(Color.fromCssColorString("#2E8B57"));
Color.SEASHELL = Object.freeze(Color.fromCssColorString("#FFF5EE"));
Color.SIENNA = Object.freeze(Color.fromCssColorString("#A0522D"));
Color.SILVER = Object.freeze(Color.fromCssColorString("#C0C0C0"));
Color.SKYBLUE = Object.freeze(Color.fromCssColorString("#87CEEB"));
Color.SLATEBLUE = Object.freeze(Color.fromCssColorString("#6A5ACD"));
Color.SLATEGRAY = Object.freeze(Color.fromCssColorString("#708090"));
Color.SLATEGREY = Color.SLATEGRAY;
Color.SNOW = Object.freeze(Color.fromCssColorString("#FFFAFA"));
Color.SPRINGGREEN = Object.freeze(Color.fromCssColorString("#00FF7F"));
Color.STEELBLUE = Object.freeze(Color.fromCssColorString("#4682B4"));
Color.TAN = Object.freeze(Color.fromCssColorString("#D2B48C"));
Color.TEAL = Object.freeze(Color.fromCssColorString("#008080"));
Color.THISTLE = Object.freeze(Color.fromCssColorString("#D8BFD8"));
Color.TOMATO = Object.freeze(Color.fromCssColorString("#FF6347"));
Color.TURQUOISE = Object.freeze(Color.fromCssColorString("#40E0D0"));
Color.VIOLET = Object.freeze(Color.fromCssColorString("#EE82EE"));
Color.WHEAT = Object.freeze(Color.fromCssColorString("#F5DEB3"));
Color.WHITE = Object.freeze(Color.fromCssColorString("#FFFFFF"));
Color.WHITESMOKE = Object.freeze(Color.fromCssColorString("#F5F5F5"));
Color.YELLOW = Object.freeze(Color.fromCssColorString("#FFFF00"));
Color.YELLOWGREEN = Object.freeze(Color.fromCssColorString("#9ACD32"));
Color.TRANSPARENT = Object.freeze(new Color(0, 0, 0, 0));
var Color_default = Color;
// Source/Core/ColorGeometryInstanceAttribute.js
function ColorGeometryInstanceAttribute(red, green, blue, alpha) {
red = defaultValue_default(red, 1);
green = defaultValue_default(green, 1);
blue = defaultValue_default(blue, 1);
alpha = defaultValue_default(alpha, 1);
this.value = new Uint8Array([
Color_default.floatToByte(red),
Color_default.floatToByte(green),
Color_default.floatToByte(blue),
Color_default.floatToByte(alpha)
]);
}
Object.defineProperties(ColorGeometryInstanceAttribute.prototype, {
componentDatatype: {
get: function() {
return ComponentDatatype_default.UNSIGNED_BYTE;
}
},
componentsPerAttribute: {
get: function() {
return 4;
}
},
normalize: {
get: function() {
return true;
}
}
});
ColorGeometryInstanceAttribute.fromColor = function(color) {
if (!defined_default(color)) {
throw new DeveloperError_default("color is required.");
}
return new ColorGeometryInstanceAttribute(
color.red,
color.green,
color.blue,
color.alpha
);
};
ColorGeometryInstanceAttribute.toValue = function(color, result) {
if (!defined_default(color)) {
throw new DeveloperError_default("color is required.");
}
if (!defined_default(result)) {
return new Uint8Array(color.toBytes());
}
return color.toBytes(result);
};
ColorGeometryInstanceAttribute.equals = function(left, right) {
return left === right || defined_default(left) && defined_default(right) && left.value[0] === right.value[0] && left.value[1] === right.value[1] && left.value[2] === right.value[2] && left.value[3] === right.value[3];
};
var ColorGeometryInstanceAttribute_default = ColorGeometryInstanceAttribute;
// Source/Core/CompressedTextureBuffer.js
function CompressedTextureBuffer(internalFormat, pixelDatatype, width, height, buffer) {
this._format = internalFormat;
this._datatype = pixelDatatype;
this._width = width;
this._height = height;
this._buffer = buffer;
}
Object.defineProperties(CompressedTextureBuffer.prototype, {
internalFormat: {
get: function() {
return this._format;
}
},
pixelDatatype: {
get: function() {
return this._datatype;
}
},
width: {
get: function() {
return this._width;
}
},
height: {
get: function() {
return this._height;
}
},
bufferView: {
get: function() {
return this._buffer;
}
}
});
CompressedTextureBuffer.clone = function(object) {
if (!defined_default(object)) {
return void 0;
}
return new CompressedTextureBuffer(
object._format,
object._datatype,
object._width,
object._height,
object._buffer
);
};
CompressedTextureBuffer.prototype.clone = function() {
return CompressedTextureBuffer.clone(this);
};
var CompressedTextureBuffer_default = CompressedTextureBuffer;
// Source/Core/ConstantSpline.js
function ConstantSpline(value) {
this._value = value;
this._valueType = Spline_default.getPointType(value);
}
Object.defineProperties(ConstantSpline.prototype, {
value: {
get: function() {
return this._value;
}
}
});
ConstantSpline.prototype.findTimeInterval = function(time) {
throw new DeveloperError_default(
"findTimeInterval cannot be called on a ConstantSpline."
);
};
ConstantSpline.prototype.wrapTime = function(time) {
Check_default.typeOf.number("time", time);
return 0;
};
ConstantSpline.prototype.clampTime = function(time) {
Check_default.typeOf.number("time", time);
return 0;
};
ConstantSpline.prototype.evaluate = function(time, result) {
Check_default.typeOf.number("time", time);
const value = this._value;
const ValueType = this._valueType;
if (ValueType === Number) {
return value;
}
return ValueType.clone(value, result);
};
var ConstantSpline_default = ConstantSpline;
// Source/Core/CoplanarPolygonGeometryLibrary.js
var CoplanarPolygonGeometryLibrary = {};
var scratchIntersectionPoint = new Cartesian3_default();
var scratchXAxis2 = new Cartesian3_default();
var scratchYAxis2 = new Cartesian3_default();
var scratchZAxis2 = new Cartesian3_default();
var obbScratch = new OrientedBoundingBox_default();
CoplanarPolygonGeometryLibrary.validOutline = function(positions) {
Check_default.defined("positions", positions);
const orientedBoundingBox = OrientedBoundingBox_default.fromPoints(
positions,
obbScratch
);
const halfAxes = orientedBoundingBox.halfAxes;
const xAxis = Matrix3_default.getColumn(halfAxes, 0, scratchXAxis2);
const yAxis = Matrix3_default.getColumn(halfAxes, 1, scratchYAxis2);
const zAxis = Matrix3_default.getColumn(halfAxes, 2, scratchZAxis2);
const xMag = Cartesian3_default.magnitude(xAxis);
const yMag = Cartesian3_default.magnitude(yAxis);
const zMag = Cartesian3_default.magnitude(zAxis);
return !(xMag === 0 && (yMag === 0 || zMag === 0) || yMag === 0 && zMag === 0);
};
CoplanarPolygonGeometryLibrary.computeProjectTo2DArguments = function(positions, centerResult, planeAxis1Result, planeAxis2Result) {
Check_default.defined("positions", positions);
Check_default.defined("centerResult", centerResult);
Check_default.defined("planeAxis1Result", planeAxis1Result);
Check_default.defined("planeAxis2Result", planeAxis2Result);
const orientedBoundingBox = OrientedBoundingBox_default.fromPoints(
positions,
obbScratch
);
const halfAxes = orientedBoundingBox.halfAxes;
const xAxis = Matrix3_default.getColumn(halfAxes, 0, scratchXAxis2);
const yAxis = Matrix3_default.getColumn(halfAxes, 1, scratchYAxis2);
const zAxis = Matrix3_default.getColumn(halfAxes, 2, scratchZAxis2);
const xMag = Cartesian3_default.magnitude(xAxis);
const yMag = Cartesian3_default.magnitude(yAxis);
const zMag = Cartesian3_default.magnitude(zAxis);
const min3 = Math.min(xMag, yMag, zMag);
if (xMag === 0 && (yMag === 0 || zMag === 0) || yMag === 0 && zMag === 0) {
return false;
}
let planeAxis1;
let planeAxis2;
if (min3 === yMag || min3 === zMag) {
planeAxis1 = xAxis;
}
if (min3 === xMag) {
planeAxis1 = yAxis;
} else if (min3 === zMag) {
planeAxis2 = yAxis;
}
if (min3 === xMag || min3 === yMag) {
planeAxis2 = zAxis;
}
Cartesian3_default.normalize(planeAxis1, planeAxis1Result);
Cartesian3_default.normalize(planeAxis2, planeAxis2Result);
Cartesian3_default.clone(orientedBoundingBox.center, centerResult);
return true;
};
function projectTo2D(position, center, axis1, axis2, result) {
const v7 = Cartesian3_default.subtract(position, center, scratchIntersectionPoint);
const x = Cartesian3_default.dot(axis1, v7);
const y = Cartesian3_default.dot(axis2, v7);
return Cartesian2_default.fromElements(x, y, result);
}
CoplanarPolygonGeometryLibrary.createProjectPointsTo2DFunction = function(center, axis1, axis2) {
return function(positions) {
const positionResults = new Array(positions.length);
for (let i = 0; i < positions.length; i++) {
positionResults[i] = projectTo2D(positions[i], center, axis1, axis2);
}
return positionResults;
};
};
CoplanarPolygonGeometryLibrary.createProjectPointTo2DFunction = function(center, axis1, axis2) {
return function(position, result) {
return projectTo2D(position, center, axis1, axis2, result);
};
};
var CoplanarPolygonGeometryLibrary_default = CoplanarPolygonGeometryLibrary;
// Source/Core/EllipsoidRhumbLine.js
function calculateM(ellipticity, major, latitude) {
if (ellipticity === 0) {
return major * latitude;
}
const e2 = ellipticity * ellipticity;
const e4 = e2 * e2;
const e6 = e4 * e2;
const e8 = e6 * e2;
const e10 = e8 * e2;
const e12 = e10 * e2;
const phi = latitude;
const sin2Phi = Math.sin(2 * phi);
const sin4Phi = Math.sin(4 * phi);
const sin6Phi = Math.sin(6 * phi);
const sin8Phi = Math.sin(8 * phi);
const sin10Phi = Math.sin(10 * phi);
const sin12Phi = Math.sin(12 * phi);
return major * ((1 - e2 / 4 - 3 * e4 / 64 - 5 * e6 / 256 - 175 * e8 / 16384 - 441 * e10 / 65536 - 4851 * e12 / 1048576) * phi - (3 * e2 / 8 + 3 * e4 / 32 + 45 * e6 / 1024 + 105 * e8 / 4096 + 2205 * e10 / 131072 + 6237 * e12 / 524288) * sin2Phi + (15 * e4 / 256 + 45 * e6 / 1024 + 525 * e8 / 16384 + 1575 * e10 / 65536 + 155925 * e12 / 8388608) * sin4Phi - (35 * e6 / 3072 + 175 * e8 / 12288 + 3675 * e10 / 262144 + 13475 * e12 / 1048576) * sin6Phi + (315 * e8 / 131072 + 2205 * e10 / 524288 + 43659 * e12 / 8388608) * sin8Phi - (693 * e10 / 1310720 + 6237 * e12 / 5242880) * sin10Phi + 1001 * e12 / 8388608 * sin12Phi);
}
function calculateInverseM(M, ellipticity, major) {
const d = M / major;
if (ellipticity === 0) {
return d;
}
const d2 = d * d;
const d3 = d2 * d;
const d4 = d3 * d;
const e = ellipticity;
const e2 = e * e;
const e4 = e2 * e2;
const e6 = e4 * e2;
const e8 = e6 * e2;
const e10 = e8 * e2;
const e12 = e10 * e2;
const sin2D = Math.sin(2 * d);
const cos2D = Math.cos(2 * d);
const sin4D = Math.sin(4 * d);
const cos4D = Math.cos(4 * d);
const sin6D = Math.sin(6 * d);
const cos6D = Math.cos(6 * d);
const sin8D = Math.sin(8 * d);
const cos8D = Math.cos(8 * d);
const sin10D = Math.sin(10 * d);
const cos10D = Math.cos(10 * d);
const sin12D = Math.sin(12 * d);
return d + d * e2 / 4 + 7 * d * e4 / 64 + 15 * d * e6 / 256 + 579 * d * e8 / 16384 + 1515 * d * e10 / 65536 + 16837 * d * e12 / 1048576 + (3 * d * e4 / 16 + 45 * d * e6 / 256 - d * (32 * d2 - 561) * e8 / 4096 - d * (232 * d2 - 1677) * e10 / 16384 + d * (399985 - 90560 * d2 + 512 * d4) * e12 / 5242880) * cos2D + (21 * d * e6 / 256 + 483 * d * e8 / 4096 - d * (224 * d2 - 1969) * e10 / 16384 - d * (33152 * d2 - 112599) * e12 / 1048576) * cos4D + (151 * d * e8 / 4096 + 4681 * d * e10 / 65536 + 1479 * d * e12 / 16384 - 453 * d3 * e12 / 32768) * cos6D + (1097 * d * e10 / 65536 + 42783 * d * e12 / 1048576) * cos8D + 8011 * d * e12 / 1048576 * cos10D + (3 * e2 / 8 + 3 * e4 / 16 + 213 * e6 / 2048 - 3 * d2 * e6 / 64 + 255 * e8 / 4096 - 33 * d2 * e8 / 512 + 20861 * e10 / 524288 - 33 * d2 * e10 / 512 + d4 * e10 / 1024 + 28273 * e12 / 1048576 - 471 * d2 * e12 / 8192 + 9 * d4 * e12 / 4096) * sin2D + (21 * e4 / 256 + 21 * e6 / 256 + 533 * e8 / 8192 - 21 * d2 * e8 / 512 + 197 * e10 / 4096 - 315 * d2 * e10 / 4096 + 584039 * e12 / 16777216 - 12517 * d2 * e12 / 131072 + 7 * d4 * e12 / 2048) * sin4D + (151 * e6 / 6144 + 151 * e8 / 4096 + 5019 * e10 / 131072 - 453 * d2 * e10 / 16384 + 26965 * e12 / 786432 - 8607 * d2 * e12 / 131072) * sin6D + (1097 * e8 / 131072 + 1097 * e10 / 65536 + 225797 * e12 / 10485760 - 1097 * d2 * e12 / 65536) * sin8D + (8011 * e10 / 2621440 + 8011 * e12 / 1048576) * sin10D + 293393 * e12 / 251658240 * sin12D;
}
function calculateSigma(ellipticity, latitude) {
if (ellipticity === 0) {
return Math.log(Math.tan(0.5 * (Math_default.PI_OVER_TWO + latitude)));
}
const eSinL = ellipticity * Math.sin(latitude);
return Math.log(Math.tan(0.5 * (Math_default.PI_OVER_TWO + latitude))) - ellipticity / 2 * Math.log((1 + eSinL) / (1 - eSinL));
}
function calculateHeading(ellipsoidRhumbLine, firstLongitude, firstLatitude, secondLongitude, secondLatitude) {
const sigma1 = calculateSigma(ellipsoidRhumbLine._ellipticity, firstLatitude);
const sigma2 = calculateSigma(
ellipsoidRhumbLine._ellipticity,
secondLatitude
);
return Math.atan2(
Math_default.negativePiToPi(secondLongitude - firstLongitude),
sigma2 - sigma1
);
}
function calculateArcLength(ellipsoidRhumbLine, major, minor, firstLongitude, firstLatitude, secondLongitude, secondLatitude) {
const heading = ellipsoidRhumbLine._heading;
const deltaLongitude = secondLongitude - firstLongitude;
let distance2 = 0;
if (Math_default.equalsEpsilon(
Math.abs(heading),
Math_default.PI_OVER_TWO,
Math_default.EPSILON8
)) {
if (major === minor) {
distance2 = major * Math.cos(firstLatitude) * Math_default.negativePiToPi(deltaLongitude);
} else {
const sinPhi = Math.sin(firstLatitude);
distance2 = major * Math.cos(firstLatitude) * Math_default.negativePiToPi(deltaLongitude) / Math.sqrt(1 - ellipsoidRhumbLine._ellipticitySquared * sinPhi * sinPhi);
}
} else {
const M1 = calculateM(
ellipsoidRhumbLine._ellipticity,
major,
firstLatitude
);
const M2 = calculateM(
ellipsoidRhumbLine._ellipticity,
major,
secondLatitude
);
distance2 = (M2 - M1) / Math.cos(heading);
}
return Math.abs(distance2);
}
var scratchCart1 = new Cartesian3_default();
var scratchCart2 = new Cartesian3_default();
function computeProperties(ellipsoidRhumbLine, start, end, ellipsoid) {
const firstCartesian = Cartesian3_default.normalize(
ellipsoid.cartographicToCartesian(start, scratchCart2),
scratchCart1
);
const lastCartesian = Cartesian3_default.normalize(
ellipsoid.cartographicToCartesian(end, scratchCart2),
scratchCart2
);
Check_default.typeOf.number.greaterThanOrEquals(
"value",
Math.abs(
Math.abs(Cartesian3_default.angleBetween(firstCartesian, lastCartesian)) - Math.PI
),
0.0125
);
const major = ellipsoid.maximumRadius;
const minor = ellipsoid.minimumRadius;
const majorSquared = major * major;
const minorSquared = minor * minor;
ellipsoidRhumbLine._ellipticitySquared = (majorSquared - minorSquared) / majorSquared;
ellipsoidRhumbLine._ellipticity = Math.sqrt(
ellipsoidRhumbLine._ellipticitySquared
);
ellipsoidRhumbLine._start = Cartographic_default.clone(
start,
ellipsoidRhumbLine._start
);
ellipsoidRhumbLine._start.height = 0;
ellipsoidRhumbLine._end = Cartographic_default.clone(end, ellipsoidRhumbLine._end);
ellipsoidRhumbLine._end.height = 0;
ellipsoidRhumbLine._heading = calculateHeading(
ellipsoidRhumbLine,
start.longitude,
start.latitude,
end.longitude,
end.latitude
);
ellipsoidRhumbLine._distance = calculateArcLength(
ellipsoidRhumbLine,
ellipsoid.maximumRadius,
ellipsoid.minimumRadius,
start.longitude,
start.latitude,
end.longitude,
end.latitude
);
}
function interpolateUsingSurfaceDistance(start, heading, distance2, major, ellipticity, result) {
if (distance2 === 0) {
return Cartographic_default.clone(start, result);
}
const ellipticitySquared = ellipticity * ellipticity;
let longitude;
let latitude;
let deltaLongitude;
if (Math.abs(Math_default.PI_OVER_TWO - Math.abs(heading)) > Math_default.EPSILON8) {
const M1 = calculateM(ellipticity, major, start.latitude);
const deltaM = distance2 * Math.cos(heading);
const M2 = M1 + deltaM;
latitude = calculateInverseM(M2, ellipticity, major);
const sigma1 = calculateSigma(ellipticity, start.latitude);
const sigma2 = calculateSigma(ellipticity, latitude);
deltaLongitude = Math.tan(heading) * (sigma2 - sigma1);
longitude = Math_default.negativePiToPi(start.longitude + deltaLongitude);
} else {
latitude = start.latitude;
let localRad;
if (ellipticity === 0) {
localRad = major * Math.cos(start.latitude);
} else {
const sinPhi = Math.sin(start.latitude);
localRad = major * Math.cos(start.latitude) / Math.sqrt(1 - ellipticitySquared * sinPhi * sinPhi);
}
deltaLongitude = distance2 / localRad;
if (heading > 0) {
longitude = Math_default.negativePiToPi(start.longitude + deltaLongitude);
} else {
longitude = Math_default.negativePiToPi(start.longitude - deltaLongitude);
}
}
if (defined_default(result)) {
result.longitude = longitude;
result.latitude = latitude;
result.height = 0;
return result;
}
return new Cartographic_default(longitude, latitude, 0);
}
function EllipsoidRhumbLine(start, end, ellipsoid) {
const e = defaultValue_default(ellipsoid, Ellipsoid_default.WGS84);
this._ellipsoid = e;
this._start = new Cartographic_default();
this._end = new Cartographic_default();
this._heading = void 0;
this._distance = void 0;
this._ellipticity = void 0;
this._ellipticitySquared = void 0;
if (defined_default(start) && defined_default(end)) {
computeProperties(this, start, end, e);
}
}
Object.defineProperties(EllipsoidRhumbLine.prototype, {
ellipsoid: {
get: function() {
return this._ellipsoid;
}
},
surfaceDistance: {
get: function() {
Check_default.defined("distance", this._distance);
return this._distance;
}
},
start: {
get: function() {
return this._start;
}
},
end: {
get: function() {
return this._end;
}
},
heading: {
get: function() {
Check_default.defined("distance", this._distance);
return this._heading;
}
}
});
EllipsoidRhumbLine.fromStartHeadingDistance = function(start, heading, distance2, ellipsoid, result) {
Check_default.defined("start", start);
Check_default.defined("heading", heading);
Check_default.defined("distance", distance2);
Check_default.typeOf.number.greaterThan("distance", distance2, 0);
const e = defaultValue_default(ellipsoid, Ellipsoid_default.WGS84);
const major = e.maximumRadius;
const minor = e.minimumRadius;
const majorSquared = major * major;
const minorSquared = minor * minor;
const ellipticity = Math.sqrt((majorSquared - minorSquared) / majorSquared);
heading = Math_default.negativePiToPi(heading);
const end = interpolateUsingSurfaceDistance(
start,
heading,
distance2,
e.maximumRadius,
ellipticity
);
if (!defined_default(result) || defined_default(ellipsoid) && !ellipsoid.equals(result.ellipsoid)) {
return new EllipsoidRhumbLine(start, end, e);
}
result.setEndPoints(start, end);
return result;
};
EllipsoidRhumbLine.prototype.setEndPoints = function(start, end) {
Check_default.defined("start", start);
Check_default.defined("end", end);
computeProperties(this, start, end, this._ellipsoid);
};
EllipsoidRhumbLine.prototype.interpolateUsingFraction = function(fraction, result) {
return this.interpolateUsingSurfaceDistance(
fraction * this._distance,
result
);
};
EllipsoidRhumbLine.prototype.interpolateUsingSurfaceDistance = function(distance2, result) {
Check_default.typeOf.number("distance", distance2);
if (!defined_default(this._distance) || this._distance === 0) {
throw new DeveloperError_default(
"EllipsoidRhumbLine must have distinct start and end set."
);
}
return interpolateUsingSurfaceDistance(
this._start,
this._heading,
distance2,
this._ellipsoid.maximumRadius,
this._ellipticity,
result
);
};
EllipsoidRhumbLine.prototype.findIntersectionWithLongitude = function(intersectionLongitude, result) {
Check_default.typeOf.number("intersectionLongitude", intersectionLongitude);
if (!defined_default(this._distance) || this._distance === 0) {
throw new DeveloperError_default(
"EllipsoidRhumbLine must have distinct start and end set."
);
}
const ellipticity = this._ellipticity;
const heading = this._heading;
const absHeading = Math.abs(heading);
const start = this._start;
intersectionLongitude = Math_default.negativePiToPi(intersectionLongitude);
if (Math_default.equalsEpsilon(
Math.abs(intersectionLongitude),
Math.PI,
Math_default.EPSILON14
)) {
intersectionLongitude = Math_default.sign(start.longitude) * Math.PI;
}
if (!defined_default(result)) {
result = new Cartographic_default();
}
if (Math.abs(Math_default.PI_OVER_TWO - absHeading) <= Math_default.EPSILON8) {
result.longitude = intersectionLongitude;
result.latitude = start.latitude;
result.height = 0;
return result;
} else if (Math_default.equalsEpsilon(
Math.abs(Math_default.PI_OVER_TWO - absHeading),
Math_default.PI_OVER_TWO,
Math_default.EPSILON8
)) {
if (Math_default.equalsEpsilon(
intersectionLongitude,
start.longitude,
Math_default.EPSILON12
)) {
return void 0;
}
result.longitude = intersectionLongitude;
result.latitude = Math_default.PI_OVER_TWO * Math_default.sign(Math_default.PI_OVER_TWO - heading);
result.height = 0;
return result;
}
const phi1 = start.latitude;
const eSinPhi1 = ellipticity * Math.sin(phi1);
const leftComponent = Math.tan(0.5 * (Math_default.PI_OVER_TWO + phi1)) * Math.exp((intersectionLongitude - start.longitude) / Math.tan(heading));
const denominator = (1 + eSinPhi1) / (1 - eSinPhi1);
let newPhi = start.latitude;
let phi;
do {
phi = newPhi;
const eSinPhi = ellipticity * Math.sin(phi);
const numerator = (1 + eSinPhi) / (1 - eSinPhi);
newPhi = 2 * Math.atan(
leftComponent * Math.pow(numerator / denominator, ellipticity / 2)
) - Math_default.PI_OVER_TWO;
} while (!Math_default.equalsEpsilon(newPhi, phi, Math_default.EPSILON12));
result.longitude = intersectionLongitude;
result.latitude = newPhi;
result.height = 0;
return result;
};
EllipsoidRhumbLine.prototype.findIntersectionWithLatitude = function(intersectionLatitude, result) {
Check_default.typeOf.number("intersectionLatitude", intersectionLatitude);
if (!defined_default(this._distance) || this._distance === 0) {
throw new DeveloperError_default(
"EllipsoidRhumbLine must have distinct start and end set."
);
}
const ellipticity = this._ellipticity;
const heading = this._heading;
const start = this._start;
if (Math_default.equalsEpsilon(
Math.abs(heading),
Math_default.PI_OVER_TWO,
Math_default.EPSILON8
)) {
return;
}
const sigma1 = calculateSigma(ellipticity, start.latitude);
const sigma2 = calculateSigma(ellipticity, intersectionLatitude);
const deltaLongitude = Math.tan(heading) * (sigma2 - sigma1);
const longitude = Math_default.negativePiToPi(start.longitude + deltaLongitude);
if (defined_default(result)) {
result.longitude = longitude;
result.latitude = intersectionLatitude;
result.height = 0;
return result;
}
return new Cartographic_default(longitude, intersectionLatitude, 0);
};
var EllipsoidRhumbLine_default = EllipsoidRhumbLine;
// Source/ThirdParty/earcut.js
var import_earcut = __toESM(require_earcut(), 1);
// Source/Core/WindingOrder.js
var WindingOrder = {
CLOCKWISE: WebGLConstants_default.CW,
COUNTER_CLOCKWISE: WebGLConstants_default.CCW
};
WindingOrder.validate = function(windingOrder) {
return windingOrder === WindingOrder.CLOCKWISE || windingOrder === WindingOrder.COUNTER_CLOCKWISE;
};
var WindingOrder_default = Object.freeze(WindingOrder);
// Source/Core/PolygonPipeline.js
var scaleToGeodeticHeightN = new Cartesian3_default();
var scaleToGeodeticHeightP = new Cartesian3_default();
var PolygonPipeline = {};
PolygonPipeline.computeArea2D = function(positions) {
Check_default.defined("positions", positions);
Check_default.typeOf.number.greaterThanOrEquals(
"positions.length",
positions.length,
3
);
const length3 = positions.length;
let area = 0;
for (let i0 = length3 - 1, i1 = 0; i1 < length3; i0 = i1++) {
const v02 = positions[i0];
const v13 = positions[i1];
area += v02.x * v13.y - v13.x * v02.y;
}
return area * 0.5;
};
PolygonPipeline.computeWindingOrder2D = function(positions) {
const area = PolygonPipeline.computeArea2D(positions);
return area > 0 ? WindingOrder_default.COUNTER_CLOCKWISE : WindingOrder_default.CLOCKWISE;
};
PolygonPipeline.triangulate = function(positions, holes) {
Check_default.defined("positions", positions);
const flattenedPositions = Cartesian2_default.packArray(positions);
return (0, import_earcut.default)(flattenedPositions, holes, 2);
};
var subdivisionV0Scratch = new Cartesian3_default();
var subdivisionV1Scratch = new Cartesian3_default();
var subdivisionV2Scratch = new Cartesian3_default();
var subdivisionS0Scratch = new Cartesian3_default();
var subdivisionS1Scratch = new Cartesian3_default();
var subdivisionS2Scratch = new Cartesian3_default();
var subdivisionMidScratch = new Cartesian3_default();
var subdivisionT0Scratch = new Cartesian2_default();
var subdivisionT1Scratch = new Cartesian2_default();
var subdivisionT2Scratch = new Cartesian2_default();
var subdivisionTexcoordMidScratch = new Cartesian2_default();
PolygonPipeline.computeSubdivision = function(ellipsoid, positions, indices2, texcoords, granularity) {
granularity = defaultValue_default(granularity, Math_default.RADIANS_PER_DEGREE);
const hasTexcoords = defined_default(texcoords);
Check_default.typeOf.object("ellipsoid", ellipsoid);
Check_default.defined("positions", positions);
Check_default.defined("indices", indices2);
Check_default.typeOf.number.greaterThanOrEquals("indices.length", indices2.length, 3);
Check_default.typeOf.number.equals("indices.length % 3", "0", indices2.length % 3, 0);
Check_default.typeOf.number.greaterThan("granularity", granularity, 0);
const triangles = indices2.slice(0);
let i;
const length3 = positions.length;
const subdividedPositions = new Array(length3 * 3);
const subdividedTexcoords = new Array(length3 * 2);
let q = 0;
let p = 0;
for (i = 0; i < length3; i++) {
const item = positions[i];
subdividedPositions[q++] = item.x;
subdividedPositions[q++] = item.y;
subdividedPositions[q++] = item.z;
if (hasTexcoords) {
const texcoordItem = texcoords[i];
subdividedTexcoords[p++] = texcoordItem.x;
subdividedTexcoords[p++] = texcoordItem.y;
}
}
const subdividedIndices = [];
const edges = {};
const radius = ellipsoid.maximumRadius;
const minDistance = Math_default.chordLength(granularity, radius);
const minDistanceSqrd = minDistance * minDistance;
while (triangles.length > 0) {
const i2 = triangles.pop();
const i1 = triangles.pop();
const i0 = triangles.pop();
const v02 = Cartesian3_default.fromArray(
subdividedPositions,
i0 * 3,
subdivisionV0Scratch
);
const v13 = Cartesian3_default.fromArray(
subdividedPositions,
i1 * 3,
subdivisionV1Scratch
);
const v23 = Cartesian3_default.fromArray(
subdividedPositions,
i2 * 3,
subdivisionV2Scratch
);
let t0, t1, t2;
if (hasTexcoords) {
t0 = Cartesian2_default.fromArray(
subdividedTexcoords,
i0 * 2,
subdivisionT0Scratch
);
t1 = Cartesian2_default.fromArray(
subdividedTexcoords,
i1 * 2,
subdivisionT1Scratch
);
t2 = Cartesian2_default.fromArray(
subdividedTexcoords,
i2 * 2,
subdivisionT2Scratch
);
}
const s0 = Cartesian3_default.multiplyByScalar(
Cartesian3_default.normalize(v02, subdivisionS0Scratch),
radius,
subdivisionS0Scratch
);
const s1 = Cartesian3_default.multiplyByScalar(
Cartesian3_default.normalize(v13, subdivisionS1Scratch),
radius,
subdivisionS1Scratch
);
const s2 = Cartesian3_default.multiplyByScalar(
Cartesian3_default.normalize(v23, subdivisionS2Scratch),
radius,
subdivisionS2Scratch
);
const g0 = Cartesian3_default.magnitudeSquared(
Cartesian3_default.subtract(s0, s1, subdivisionMidScratch)
);
const g1 = Cartesian3_default.magnitudeSquared(
Cartesian3_default.subtract(s1, s2, subdivisionMidScratch)
);
const g2 = Cartesian3_default.magnitudeSquared(
Cartesian3_default.subtract(s2, s0, subdivisionMidScratch)
);
const max3 = Math.max(g0, g1, g2);
let edge;
let mid;
let midTexcoord;
if (max3 > minDistanceSqrd) {
if (g0 === max3) {
edge = `${Math.min(i0, i1)} ${Math.max(i0, i1)}`;
i = edges[edge];
if (!defined_default(i)) {
mid = Cartesian3_default.add(v02, v13, subdivisionMidScratch);
Cartesian3_default.multiplyByScalar(mid, 0.5, mid);
subdividedPositions.push(mid.x, mid.y, mid.z);
i = subdividedPositions.length / 3 - 1;
edges[edge] = i;
if (hasTexcoords) {
midTexcoord = Cartesian2_default.add(t0, t1, subdivisionTexcoordMidScratch);
Cartesian2_default.multiplyByScalar(midTexcoord, 0.5, midTexcoord);
subdividedTexcoords.push(midTexcoord.x, midTexcoord.y);
}
}
triangles.push(i0, i, i2);
triangles.push(i, i1, i2);
} else if (g1 === max3) {
edge = `${Math.min(i1, i2)} ${Math.max(i1, i2)}`;
i = edges[edge];
if (!defined_default(i)) {
mid = Cartesian3_default.add(v13, v23, subdivisionMidScratch);
Cartesian3_default.multiplyByScalar(mid, 0.5, mid);
subdividedPositions.push(mid.x, mid.y, mid.z);
i = subdividedPositions.length / 3 - 1;
edges[edge] = i;
if (hasTexcoords) {
midTexcoord = Cartesian2_default.add(t1, t2, subdivisionTexcoordMidScratch);
Cartesian2_default.multiplyByScalar(midTexcoord, 0.5, midTexcoord);
subdividedTexcoords.push(midTexcoord.x, midTexcoord.y);
}
}
triangles.push(i1, i, i0);
triangles.push(i, i2, i0);
} else if (g2 === max3) {
edge = `${Math.min(i2, i0)} ${Math.max(i2, i0)}`;
i = edges[edge];
if (!defined_default(i)) {
mid = Cartesian3_default.add(v23, v02, subdivisionMidScratch);
Cartesian3_default.multiplyByScalar(mid, 0.5, mid);
subdividedPositions.push(mid.x, mid.y, mid.z);
i = subdividedPositions.length / 3 - 1;
edges[edge] = i;
if (hasTexcoords) {
midTexcoord = Cartesian2_default.add(t2, t0, subdivisionTexcoordMidScratch);
Cartesian2_default.multiplyByScalar(midTexcoord, 0.5, midTexcoord);
subdividedTexcoords.push(midTexcoord.x, midTexcoord.y);
}
}
triangles.push(i2, i, i1);
triangles.push(i, i0, i1);
}
} else {
subdividedIndices.push(i0);
subdividedIndices.push(i1);
subdividedIndices.push(i2);
}
}
const geometryOptions = {
attributes: {
position: new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.DOUBLE,
componentsPerAttribute: 3,
values: subdividedPositions
})
},
indices: subdividedIndices,
primitiveType: PrimitiveType_default.TRIANGLES
};
if (hasTexcoords) {
geometryOptions.attributes.st = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.FLOAT,
componentsPerAttribute: 2,
values: subdividedTexcoords
});
}
return new Geometry_default(geometryOptions);
};
var subdivisionC0Scratch = new Cartographic_default();
var subdivisionC1Scratch = new Cartographic_default();
var subdivisionC2Scratch = new Cartographic_default();
var subdivisionCartographicScratch = new Cartographic_default();
PolygonPipeline.computeRhumbLineSubdivision = function(ellipsoid, positions, indices2, texcoords, granularity) {
granularity = defaultValue_default(granularity, Math_default.RADIANS_PER_DEGREE);
const hasTexcoords = defined_default(texcoords);
Check_default.typeOf.object("ellipsoid", ellipsoid);
Check_default.defined("positions", positions);
Check_default.defined("indices", indices2);
Check_default.typeOf.number.greaterThanOrEquals("indices.length", indices2.length, 3);
Check_default.typeOf.number.equals("indices.length % 3", "0", indices2.length % 3, 0);
Check_default.typeOf.number.greaterThan("granularity", granularity, 0);
const triangles = indices2.slice(0);
let i;
const length3 = positions.length;
const subdividedPositions = new Array(length3 * 3);
const subdividedTexcoords = new Array(length3 * 2);
let q = 0;
let p = 0;
for (i = 0; i < length3; i++) {
const item = positions[i];
subdividedPositions[q++] = item.x;
subdividedPositions[q++] = item.y;
subdividedPositions[q++] = item.z;
if (hasTexcoords) {
const texcoordItem = texcoords[i];
subdividedTexcoords[p++] = texcoordItem.x;
subdividedTexcoords[p++] = texcoordItem.y;
}
}
const subdividedIndices = [];
const edges = {};
const radius = ellipsoid.maximumRadius;
const minDistance = Math_default.chordLength(granularity, radius);
const rhumb0 = new EllipsoidRhumbLine_default(void 0, void 0, ellipsoid);
const rhumb1 = new EllipsoidRhumbLine_default(void 0, void 0, ellipsoid);
const rhumb2 = new EllipsoidRhumbLine_default(void 0, void 0, ellipsoid);
while (triangles.length > 0) {
const i2 = triangles.pop();
const i1 = triangles.pop();
const i0 = triangles.pop();
const v02 = Cartesian3_default.fromArray(
subdividedPositions,
i0 * 3,
subdivisionV0Scratch
);
const v13 = Cartesian3_default.fromArray(
subdividedPositions,
i1 * 3,
subdivisionV1Scratch
);
const v23 = Cartesian3_default.fromArray(
subdividedPositions,
i2 * 3,
subdivisionV2Scratch
);
let t0, t1, t2;
if (hasTexcoords) {
t0 = Cartesian2_default.fromArray(
subdividedTexcoords,
i0 * 2,
subdivisionT0Scratch
);
t1 = Cartesian2_default.fromArray(
subdividedTexcoords,
i1 * 2,
subdivisionT1Scratch
);
t2 = Cartesian2_default.fromArray(
subdividedTexcoords,
i2 * 2,
subdivisionT2Scratch
);
}
const c0 = ellipsoid.cartesianToCartographic(v02, subdivisionC0Scratch);
const c14 = ellipsoid.cartesianToCartographic(v13, subdivisionC1Scratch);
const c22 = ellipsoid.cartesianToCartographic(v23, subdivisionC2Scratch);
rhumb0.setEndPoints(c0, c14);
const g0 = rhumb0.surfaceDistance;
rhumb1.setEndPoints(c14, c22);
const g1 = rhumb1.surfaceDistance;
rhumb2.setEndPoints(c22, c0);
const g2 = rhumb2.surfaceDistance;
const max3 = Math.max(g0, g1, g2);
let edge;
let mid;
let midHeight;
let midCartesian3;
let midTexcoord;
if (max3 > minDistance) {
if (g0 === max3) {
edge = `${Math.min(i0, i1)} ${Math.max(i0, i1)}`;
i = edges[edge];
if (!defined_default(i)) {
mid = rhumb0.interpolateUsingFraction(
0.5,
subdivisionCartographicScratch
);
midHeight = (c0.height + c14.height) * 0.5;
midCartesian3 = Cartesian3_default.fromRadians(
mid.longitude,
mid.latitude,
midHeight,
ellipsoid,
subdivisionMidScratch
);
subdividedPositions.push(
midCartesian3.x,
midCartesian3.y,
midCartesian3.z
);
i = subdividedPositions.length / 3 - 1;
edges[edge] = i;
if (hasTexcoords) {
midTexcoord = Cartesian2_default.add(t0, t1, subdivisionTexcoordMidScratch);
Cartesian2_default.multiplyByScalar(midTexcoord, 0.5, midTexcoord);
subdividedTexcoords.push(midTexcoord.x, midTexcoord.y);
}
}
triangles.push(i0, i, i2);
triangles.push(i, i1, i2);
} else if (g1 === max3) {
edge = `${Math.min(i1, i2)} ${Math.max(i1, i2)}`;
i = edges[edge];
if (!defined_default(i)) {
mid = rhumb1.interpolateUsingFraction(
0.5,
subdivisionCartographicScratch
);
midHeight = (c14.height + c22.height) * 0.5;
midCartesian3 = Cartesian3_default.fromRadians(
mid.longitude,
mid.latitude,
midHeight,
ellipsoid,
subdivisionMidScratch
);
subdividedPositions.push(
midCartesian3.x,
midCartesian3.y,
midCartesian3.z
);
i = subdividedPositions.length / 3 - 1;
edges[edge] = i;
if (hasTexcoords) {
midTexcoord = Cartesian2_default.add(t1, t2, subdivisionTexcoordMidScratch);
Cartesian2_default.multiplyByScalar(midTexcoord, 0.5, midTexcoord);
subdividedTexcoords.push(midTexcoord.x, midTexcoord.y);
}
}
triangles.push(i1, i, i0);
triangles.push(i, i2, i0);
} else if (g2 === max3) {
edge = `${Math.min(i2, i0)} ${Math.max(i2, i0)}`;
i = edges[edge];
if (!defined_default(i)) {
mid = rhumb2.interpolateUsingFraction(
0.5,
subdivisionCartographicScratch
);
midHeight = (c22.height + c0.height) * 0.5;
midCartesian3 = Cartesian3_default.fromRadians(
mid.longitude,
mid.latitude,
midHeight,
ellipsoid,
subdivisionMidScratch
);
subdividedPositions.push(
midCartesian3.x,
midCartesian3.y,
midCartesian3.z
);
i = subdividedPositions.length / 3 - 1;
edges[edge] = i;
if (hasTexcoords) {
midTexcoord = Cartesian2_default.add(t2, t0, subdivisionTexcoordMidScratch);
Cartesian2_default.multiplyByScalar(midTexcoord, 0.5, midTexcoord);
subdividedTexcoords.push(midTexcoord.x, midTexcoord.y);
}
}
triangles.push(i2, i, i1);
triangles.push(i, i0, i1);
}
} else {
subdividedIndices.push(i0);
subdividedIndices.push(i1);
subdividedIndices.push(i2);
}
}
const geometryOptions = {
attributes: {
position: new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.DOUBLE,
componentsPerAttribute: 3,
values: subdividedPositions
})
},
indices: subdividedIndices,
primitiveType: PrimitiveType_default.TRIANGLES
};
if (hasTexcoords) {
geometryOptions.attributes.st = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.FLOAT,
componentsPerAttribute: 2,
values: subdividedTexcoords
});
}
return new Geometry_default(geometryOptions);
};
PolygonPipeline.scaleToGeodeticHeight = function(positions, height, ellipsoid, scaleToSurface4) {
ellipsoid = defaultValue_default(ellipsoid, Ellipsoid_default.WGS84);
let n = scaleToGeodeticHeightN;
let p = scaleToGeodeticHeightP;
height = defaultValue_default(height, 0);
scaleToSurface4 = defaultValue_default(scaleToSurface4, true);
if (defined_default(positions)) {
const length3 = positions.length;
for (let i = 0; i < length3; i += 3) {
Cartesian3_default.fromArray(positions, i, p);
if (scaleToSurface4) {
p = ellipsoid.scaleToGeodeticSurface(p, p);
}
if (height !== 0) {
n = ellipsoid.geodeticSurfaceNormal(p, n);
Cartesian3_default.multiplyByScalar(n, height, n);
Cartesian3_default.add(p, n, p);
}
positions[i] = p.x;
positions[i + 1] = p.y;
positions[i + 2] = p.z;
}
}
return positions;
};
var PolygonPipeline_default = PolygonPipeline;
// Source/Core/Queue.js
function Queue() {
this._array = [];
this._offset = 0;
this._length = 0;
}
Object.defineProperties(Queue.prototype, {
length: {
get: function() {
return this._length;
}
}
});
Queue.prototype.enqueue = function(item) {
this._array.push(item);
this._length++;
};
Queue.prototype.dequeue = function() {
if (this._length === 0) {
return void 0;
}
const array = this._array;
let offset2 = this._offset;
const item = array[offset2];
array[offset2] = void 0;
offset2++;
if (offset2 > 10 && offset2 * 2 > array.length) {
this._array = array.slice(offset2);
offset2 = 0;
}
this._offset = offset2;
this._length--;
return item;
};
Queue.prototype.peek = function() {
if (this._length === 0) {
return void 0;
}
return this._array[this._offset];
};
Queue.prototype.contains = function(item) {
return this._array.indexOf(item) !== -1;
};
Queue.prototype.clear = function() {
this._array.length = this._offset = this._length = 0;
};
Queue.prototype.sort = function(compareFunction) {
if (this._offset > 0) {
this._array = this._array.slice(this._offset);
this._offset = 0;
}
this._array.sort(compareFunction);
};
var Queue_default = Queue;
// Source/Core/PolygonGeometryLibrary.js
var PolygonGeometryLibrary = {};
PolygonGeometryLibrary.computeHierarchyPackedLength = function(polygonHierarchy, CartesianX) {
let numComponents = 0;
const stack = [polygonHierarchy];
while (stack.length > 0) {
const hierarchy = stack.pop();
if (!defined_default(hierarchy)) {
continue;
}
numComponents += 2;
const positions = hierarchy.positions;
const holes = hierarchy.holes;
if (defined_default(positions) && positions.length > 0) {
numComponents += positions.length * CartesianX.packedLength;
}
if (defined_default(holes)) {
const length3 = holes.length;
for (let i = 0; i < length3; ++i) {
stack.push(holes[i]);
}
}
}
return numComponents;
};
PolygonGeometryLibrary.packPolygonHierarchy = function(polygonHierarchy, array, startingIndex, CartesianX) {
const stack = [polygonHierarchy];
while (stack.length > 0) {
const hierarchy = stack.pop();
if (!defined_default(hierarchy)) {
continue;
}
const positions = hierarchy.positions;
const holes = hierarchy.holes;
array[startingIndex++] = defined_default(positions) ? positions.length : 0;
array[startingIndex++] = defined_default(holes) ? holes.length : 0;
if (defined_default(positions)) {
const positionsLength = positions.length;
for (let i = 0; i < positionsLength; ++i, startingIndex += CartesianX.packedLength) {
CartesianX.pack(positions[i], array, startingIndex);
}
}
if (defined_default(holes)) {
const holesLength = holes.length;
for (let j = 0; j < holesLength; ++j) {
stack.push(holes[j]);
}
}
}
return startingIndex;
};
PolygonGeometryLibrary.unpackPolygonHierarchy = function(array, startingIndex, CartesianX) {
const positionsLength = array[startingIndex++];
const holesLength = array[startingIndex++];
const positions = new Array(positionsLength);
const holes = holesLength > 0 ? new Array(holesLength) : void 0;
for (let i = 0; i < positionsLength; ++i, startingIndex += CartesianX.packedLength) {
positions[i] = CartesianX.unpack(array, startingIndex);
}
for (let j = 0; j < holesLength; ++j) {
holes[j] = PolygonGeometryLibrary.unpackPolygonHierarchy(
array,
startingIndex,
CartesianX
);
startingIndex = holes[j].startingIndex;
delete holes[j].startingIndex;
}
return {
positions,
holes,
startingIndex
};
};
var distance2DScratch = new Cartesian2_default();
function getPointAtDistance2D(p0, p1, distance2, length3) {
Cartesian2_default.subtract(p1, p0, distance2DScratch);
Cartesian2_default.multiplyByScalar(
distance2DScratch,
distance2 / length3,
distance2DScratch
);
Cartesian2_default.add(p0, distance2DScratch, distance2DScratch);
return [distance2DScratch.x, distance2DScratch.y];
}
var distanceScratch4 = new Cartesian3_default();
function getPointAtDistance(p0, p1, distance2, length3) {
Cartesian3_default.subtract(p1, p0, distanceScratch4);
Cartesian3_default.multiplyByScalar(
distanceScratch4,
distance2 / length3,
distanceScratch4
);
Cartesian3_default.add(p0, distanceScratch4, distanceScratch4);
return [distanceScratch4.x, distanceScratch4.y, distanceScratch4.z];
}
PolygonGeometryLibrary.subdivideLineCount = function(p0, p1, minDistance) {
const distance2 = Cartesian3_default.distance(p0, p1);
const n = distance2 / minDistance;
const countDivide = Math.max(0, Math.ceil(Math_default.log2(n)));
return Math.pow(2, countDivide);
};
var scratchCartographic0 = new Cartographic_default();
var scratchCartographic1 = new Cartographic_default();
var scratchCartographic22 = new Cartographic_default();
var scratchCartesian0 = new Cartesian3_default();
var scratchRhumbLine = new EllipsoidRhumbLine_default();
PolygonGeometryLibrary.subdivideRhumbLineCount = function(ellipsoid, p0, p1, minDistance) {
const c0 = ellipsoid.cartesianToCartographic(p0, scratchCartographic0);
const c14 = ellipsoid.cartesianToCartographic(p1, scratchCartographic1);
const rhumb = new EllipsoidRhumbLine_default(c0, c14, ellipsoid);
const n = rhumb.surfaceDistance / minDistance;
const countDivide = Math.max(0, Math.ceil(Math_default.log2(n)));
return Math.pow(2, countDivide);
};
PolygonGeometryLibrary.subdivideTexcoordLine = function(t0, t1, p0, p1, minDistance, result) {
const subdivisions = PolygonGeometryLibrary.subdivideLineCount(
p0,
p1,
minDistance
);
const length2D = Cartesian2_default.distance(t0, t1);
const distanceBetweenCoords = length2D / subdivisions;
const texcoords = result;
texcoords.length = subdivisions * 2;
let index = 0;
for (let i = 0; i < subdivisions; i++) {
const t = getPointAtDistance2D(t0, t1, i * distanceBetweenCoords, length2D);
texcoords[index++] = t[0];
texcoords[index++] = t[1];
}
return texcoords;
};
PolygonGeometryLibrary.subdivideLine = function(p0, p1, minDistance, result) {
const numVertices = PolygonGeometryLibrary.subdivideLineCount(
p0,
p1,
minDistance
);
const length3 = Cartesian3_default.distance(p0, p1);
const distanceBetweenVertices = length3 / numVertices;
if (!defined_default(result)) {
result = [];
}
const positions = result;
positions.length = numVertices * 3;
let index = 0;
for (let i = 0; i < numVertices; i++) {
const p = getPointAtDistance(p0, p1, i * distanceBetweenVertices, length3);
positions[index++] = p[0];
positions[index++] = p[1];
positions[index++] = p[2];
}
return positions;
};
PolygonGeometryLibrary.subdivideTexcoordRhumbLine = function(t0, t1, ellipsoid, p0, p1, minDistance, result) {
const c0 = ellipsoid.cartesianToCartographic(p0, scratchCartographic0);
const c14 = ellipsoid.cartesianToCartographic(p1, scratchCartographic1);
scratchRhumbLine.setEndPoints(c0, c14);
const n = scratchRhumbLine.surfaceDistance / minDistance;
const countDivide = Math.max(0, Math.ceil(Math_default.log2(n)));
const subdivisions = Math.pow(2, countDivide);
const length2D = Cartesian2_default.distance(t0, t1);
const distanceBetweenCoords = length2D / subdivisions;
const texcoords = result;
texcoords.length = subdivisions * 2;
let index = 0;
for (let i = 0; i < subdivisions; i++) {
const t = getPointAtDistance2D(t0, t1, i * distanceBetweenCoords, length2D);
texcoords[index++] = t[0];
texcoords[index++] = t[1];
}
return texcoords;
};
PolygonGeometryLibrary.subdivideRhumbLine = function(ellipsoid, p0, p1, minDistance, result) {
const c0 = ellipsoid.cartesianToCartographic(p0, scratchCartographic0);
const c14 = ellipsoid.cartesianToCartographic(p1, scratchCartographic1);
const rhumb = new EllipsoidRhumbLine_default(c0, c14, ellipsoid);
const n = rhumb.surfaceDistance / minDistance;
const countDivide = Math.max(0, Math.ceil(Math_default.log2(n)));
const numVertices = Math.pow(2, countDivide);
const distanceBetweenVertices = rhumb.surfaceDistance / numVertices;
if (!defined_default(result)) {
result = [];
}
const positions = result;
positions.length = numVertices * 3;
let index = 0;
for (let i = 0; i < numVertices; i++) {
const c = rhumb.interpolateUsingSurfaceDistance(
i * distanceBetweenVertices,
scratchCartographic22
);
const p = ellipsoid.cartographicToCartesian(c, scratchCartesian0);
positions[index++] = p.x;
positions[index++] = p.y;
positions[index++] = p.z;
}
return positions;
};
var scaleToGeodeticHeightN1 = new Cartesian3_default();
var scaleToGeodeticHeightN2 = new Cartesian3_default();
var scaleToGeodeticHeightP1 = new Cartesian3_default();
var scaleToGeodeticHeightP2 = new Cartesian3_default();
PolygonGeometryLibrary.scaleToGeodeticHeightExtruded = function(geometry, maxHeight, minHeight, ellipsoid, perPositionHeight) {
ellipsoid = defaultValue_default(ellipsoid, Ellipsoid_default.WGS84);
const n1 = scaleToGeodeticHeightN1;
let n2 = scaleToGeodeticHeightN2;
const p = scaleToGeodeticHeightP1;
let p2 = scaleToGeodeticHeightP2;
if (defined_default(geometry) && defined_default(geometry.attributes) && defined_default(geometry.attributes.position)) {
const positions = geometry.attributes.position.values;
const length3 = positions.length / 2;
for (let i = 0; i < length3; i += 3) {
Cartesian3_default.fromArray(positions, i, p);
ellipsoid.geodeticSurfaceNormal(p, n1);
p2 = ellipsoid.scaleToGeodeticSurface(p, p2);
n2 = Cartesian3_default.multiplyByScalar(n1, minHeight, n2);
n2 = Cartesian3_default.add(p2, n2, n2);
positions[i + length3] = n2.x;
positions[i + 1 + length3] = n2.y;
positions[i + 2 + length3] = n2.z;
if (perPositionHeight) {
p2 = Cartesian3_default.clone(p, p2);
}
n2 = Cartesian3_default.multiplyByScalar(n1, maxHeight, n2);
n2 = Cartesian3_default.add(p2, n2, n2);
positions[i] = n2.x;
positions[i + 1] = n2.y;
positions[i + 2] = n2.z;
}
}
return geometry;
};
PolygonGeometryLibrary.polygonOutlinesFromHierarchy = function(polygonHierarchy, scaleToEllipsoidSurface, ellipsoid) {
const polygons = [];
const queue = new Queue_default();
queue.enqueue(polygonHierarchy);
let i;
let j;
let length3;
while (queue.length !== 0) {
const outerNode = queue.dequeue();
let outerRing = outerNode.positions;
if (scaleToEllipsoidSurface) {
length3 = outerRing.length;
for (i = 0; i < length3; i++) {
ellipsoid.scaleToGeodeticSurface(outerRing[i], outerRing[i]);
}
}
outerRing = arrayRemoveDuplicates_default(
outerRing,
Cartesian3_default.equalsEpsilon,
true
);
if (outerRing.length < 3) {
continue;
}
const numChildren = outerNode.holes ? outerNode.holes.length : 0;
for (i = 0; i < numChildren; i++) {
const hole = outerNode.holes[i];
let holePositions = hole.positions;
if (scaleToEllipsoidSurface) {
length3 = holePositions.length;
for (j = 0; j < length3; ++j) {
ellipsoid.scaleToGeodeticSurface(holePositions[j], holePositions[j]);
}
}
holePositions = arrayRemoveDuplicates_default(
holePositions,
Cartesian3_default.equalsEpsilon,
true
);
if (holePositions.length < 3) {
continue;
}
polygons.push(holePositions);
let numGrandchildren = 0;
if (defined_default(hole.holes)) {
numGrandchildren = hole.holes.length;
}
for (j = 0; j < numGrandchildren; j++) {
queue.enqueue(hole.holes[j]);
}
}
polygons.push(outerRing);
}
return polygons;
};
PolygonGeometryLibrary.polygonsFromHierarchy = function(polygonHierarchy, keepDuplicates, projectPointsTo2D, scaleToEllipsoidSurface, ellipsoid) {
const hierarchy = [];
const polygons = [];
const queue = new Queue_default();
queue.enqueue(polygonHierarchy);
while (queue.length !== 0) {
const outerNode = queue.dequeue();
let outerRing = outerNode.positions;
const holes = outerNode.holes;
let i;
let length3;
if (scaleToEllipsoidSurface) {
length3 = outerRing.length;
for (i = 0; i < length3; i++) {
ellipsoid.scaleToGeodeticSurface(outerRing[i], outerRing[i]);
}
}
if (!keepDuplicates) {
outerRing = arrayRemoveDuplicates_default(
outerRing,
Cartesian3_default.equalsEpsilon,
true
);
}
if (outerRing.length < 3) {
continue;
}
let positions2D = projectPointsTo2D(outerRing);
if (!defined_default(positions2D)) {
continue;
}
const holeIndices = [];
let originalWindingOrder = PolygonPipeline_default.computeWindingOrder2D(
positions2D
);
if (originalWindingOrder === WindingOrder_default.CLOCKWISE) {
positions2D.reverse();
outerRing = outerRing.slice().reverse();
}
let positions = outerRing.slice();
const numChildren = defined_default(holes) ? holes.length : 0;
const polygonHoles = [];
let j;
for (i = 0; i < numChildren; i++) {
const hole = holes[i];
let holePositions = hole.positions;
if (scaleToEllipsoidSurface) {
length3 = holePositions.length;
for (j = 0; j < length3; ++j) {
ellipsoid.scaleToGeodeticSurface(holePositions[j], holePositions[j]);
}
}
if (!keepDuplicates) {
holePositions = arrayRemoveDuplicates_default(
holePositions,
Cartesian3_default.equalsEpsilon,
true
);
}
if (holePositions.length < 3) {
continue;
}
const holePositions2D = projectPointsTo2D(holePositions);
if (!defined_default(holePositions2D)) {
continue;
}
originalWindingOrder = PolygonPipeline_default.computeWindingOrder2D(
holePositions2D
);
if (originalWindingOrder === WindingOrder_default.CLOCKWISE) {
holePositions2D.reverse();
holePositions = holePositions.slice().reverse();
}
polygonHoles.push(holePositions);
holeIndices.push(positions.length);
positions = positions.concat(holePositions);
positions2D = positions2D.concat(holePositions2D);
let numGrandchildren = 0;
if (defined_default(hole.holes)) {
numGrandchildren = hole.holes.length;
}
for (j = 0; j < numGrandchildren; j++) {
queue.enqueue(hole.holes[j]);
}
}
hierarchy.push({
outerRing,
holes: polygonHoles
});
polygons.push({
positions,
positions2D,
holes: holeIndices
});
}
return {
hierarchy,
polygons
};
};
var computeBoundingRectangleCartesian2 = new Cartesian2_default();
var computeBoundingRectangleCartesian3 = new Cartesian3_default();
var computeBoundingRectangleQuaternion = new Quaternion_default();
var computeBoundingRectangleMatrix3 = new Matrix3_default();
PolygonGeometryLibrary.computeBoundingRectangle = function(planeNormal, projectPointTo2D, positions, angle, result) {
const rotation = Quaternion_default.fromAxisAngle(
planeNormal,
angle,
computeBoundingRectangleQuaternion
);
const textureMatrix = Matrix3_default.fromQuaternion(
rotation,
computeBoundingRectangleMatrix3
);
let minX = Number.POSITIVE_INFINITY;
let maxX = Number.NEGATIVE_INFINITY;
let minY = Number.POSITIVE_INFINITY;
let maxY = Number.NEGATIVE_INFINITY;
const length3 = positions.length;
for (let i = 0; i < length3; ++i) {
const p = Cartesian3_default.clone(
positions[i],
computeBoundingRectangleCartesian3
);
Matrix3_default.multiplyByVector(textureMatrix, p, p);
const st = projectPointTo2D(p, computeBoundingRectangleCartesian2);
if (defined_default(st)) {
minX = Math.min(minX, st.x);
maxX = Math.max(maxX, st.x);
minY = Math.min(minY, st.y);
maxY = Math.max(maxY, st.y);
}
}
result.x = minX;
result.y = minY;
result.width = maxX - minX;
result.height = maxY - minY;
return result;
};
PolygonGeometryLibrary.createGeometryFromPositions = function(ellipsoid, polygon, textureCoordinates, granularity, perPositionHeight, vertexFormat, arcType) {
let indices2 = PolygonPipeline_default.triangulate(polygon.positions2D, polygon.holes);
if (indices2.length < 3) {
indices2 = [0, 1, 2];
}
const positions = polygon.positions;
const hasTexcoords = defined_default(textureCoordinates);
const texcoords = hasTexcoords ? textureCoordinates.positions : void 0;
if (perPositionHeight) {
const length3 = positions.length;
const flattenedPositions = new Array(length3 * 3);
let index = 0;
for (let i = 0; i < length3; i++) {
const p = positions[i];
flattenedPositions[index++] = p.x;
flattenedPositions[index++] = p.y;
flattenedPositions[index++] = p.z;
}
const geometryOptions = {
attributes: {
position: new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.DOUBLE,
componentsPerAttribute: 3,
values: flattenedPositions
})
},
indices: indices2,
primitiveType: PrimitiveType_default.TRIANGLES
};
if (hasTexcoords) {
geometryOptions.attributes.st = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.FLOAT,
componentsPerAttribute: 2,
values: Cartesian2_default.packArray(texcoords)
});
}
const geometry = new Geometry_default(geometryOptions);
if (vertexFormat.normal) {
return GeometryPipeline_default.computeNormal(geometry);
}
return geometry;
}
if (arcType === ArcType_default.GEODESIC) {
return PolygonPipeline_default.computeSubdivision(
ellipsoid,
positions,
indices2,
texcoords,
granularity
);
} else if (arcType === ArcType_default.RHUMB) {
return PolygonPipeline_default.computeRhumbLineSubdivision(
ellipsoid,
positions,
indices2,
texcoords,
granularity
);
}
};
var computeWallTexcoordsSubdivided = [];
var computeWallIndicesSubdivided = [];
var p1Scratch2 = new Cartesian3_default();
var p2Scratch2 = new Cartesian3_default();
PolygonGeometryLibrary.computeWallGeometry = function(positions, textureCoordinates, ellipsoid, granularity, perPositionHeight, arcType) {
let edgePositions;
let topEdgeLength;
let i;
let p1;
let p2;
let t1;
let t2;
let edgeTexcoords;
let topEdgeTexcoordLength;
let length3 = positions.length;
let index = 0;
let textureIndex = 0;
const hasTexcoords = defined_default(textureCoordinates);
const texcoords = hasTexcoords ? textureCoordinates.positions : void 0;
if (!perPositionHeight) {
const minDistance = Math_default.chordLength(
granularity,
ellipsoid.maximumRadius
);
let numVertices = 0;
if (arcType === ArcType_default.GEODESIC) {
for (i = 0; i < length3; i++) {
numVertices += PolygonGeometryLibrary.subdivideLineCount(
positions[i],
positions[(i + 1) % length3],
minDistance
);
}
} else if (arcType === ArcType_default.RHUMB) {
for (i = 0; i < length3; i++) {
numVertices += PolygonGeometryLibrary.subdivideRhumbLineCount(
ellipsoid,
positions[i],
positions[(i + 1) % length3],
minDistance
);
}
}
topEdgeLength = (numVertices + length3) * 3;
edgePositions = new Array(topEdgeLength * 2);
if (hasTexcoords) {
topEdgeTexcoordLength = (numVertices + length3) * 2;
edgeTexcoords = new Array(topEdgeTexcoordLength * 2);
}
for (i = 0; i < length3; i++) {
p1 = positions[i];
p2 = positions[(i + 1) % length3];
let tempPositions;
let tempTexcoords;
if (hasTexcoords) {
t1 = texcoords[i];
t2 = texcoords[(i + 1) % length3];
}
if (arcType === ArcType_default.GEODESIC) {
tempPositions = PolygonGeometryLibrary.subdivideLine(
p1,
p2,
minDistance,
computeWallIndicesSubdivided
);
if (hasTexcoords) {
tempTexcoords = PolygonGeometryLibrary.subdivideTexcoordLine(
t1,
t2,
p1,
p2,
minDistance,
computeWallTexcoordsSubdivided
);
}
} else if (arcType === ArcType_default.RHUMB) {
tempPositions = PolygonGeometryLibrary.subdivideRhumbLine(
ellipsoid,
p1,
p2,
minDistance,
computeWallIndicesSubdivided
);
if (hasTexcoords) {
tempTexcoords = PolygonGeometryLibrary.subdivideTexcoordRhumbLine(
t1,
t2,
ellipsoid,
p1,
p2,
minDistance,
computeWallTexcoordsSubdivided
);
}
}
const tempPositionsLength = tempPositions.length;
for (let j = 0; j < tempPositionsLength; ++j, ++index) {
edgePositions[index] = tempPositions[j];
edgePositions[index + topEdgeLength] = tempPositions[j];
}
edgePositions[index] = p2.x;
edgePositions[index + topEdgeLength] = p2.x;
++index;
edgePositions[index] = p2.y;
edgePositions[index + topEdgeLength] = p2.y;
++index;
edgePositions[index] = p2.z;
edgePositions[index + topEdgeLength] = p2.z;
++index;
if (hasTexcoords) {
const tempTexcoordsLength = tempTexcoords.length;
for (let k = 0; k < tempTexcoordsLength; ++k, ++textureIndex) {
edgeTexcoords[textureIndex] = tempTexcoords[k];
edgeTexcoords[textureIndex + topEdgeTexcoordLength] = tempTexcoords[k];
}
edgeTexcoords[textureIndex] = t2.x;
edgeTexcoords[textureIndex + topEdgeTexcoordLength] = t2.x;
++textureIndex;
edgeTexcoords[textureIndex] = t2.y;
edgeTexcoords[textureIndex + topEdgeTexcoordLength] = t2.y;
++textureIndex;
}
}
} else {
topEdgeLength = length3 * 3 * 2;
edgePositions = new Array(topEdgeLength * 2);
if (hasTexcoords) {
topEdgeTexcoordLength = length3 * 2 * 2;
edgeTexcoords = new Array(topEdgeTexcoordLength * 2);
}
for (i = 0; i < length3; i++) {
p1 = positions[i];
p2 = positions[(i + 1) % length3];
edgePositions[index] = edgePositions[index + topEdgeLength] = p1.x;
++index;
edgePositions[index] = edgePositions[index + topEdgeLength] = p1.y;
++index;
edgePositions[index] = edgePositions[index + topEdgeLength] = p1.z;
++index;
edgePositions[index] = edgePositions[index + topEdgeLength] = p2.x;
++index;
edgePositions[index] = edgePositions[index + topEdgeLength] = p2.y;
++index;
edgePositions[index] = edgePositions[index + topEdgeLength] = p2.z;
++index;
if (hasTexcoords) {
t1 = texcoords[i];
t2 = texcoords[(i + 1) % length3];
edgeTexcoords[textureIndex] = edgeTexcoords[textureIndex + topEdgeTexcoordLength] = t1.x;
++textureIndex;
edgeTexcoords[textureIndex] = edgeTexcoords[textureIndex + topEdgeTexcoordLength] = t1.y;
++textureIndex;
edgeTexcoords[textureIndex] = edgeTexcoords[textureIndex + topEdgeTexcoordLength] = t2.x;
++textureIndex;
edgeTexcoords[textureIndex] = edgeTexcoords[textureIndex + topEdgeTexcoordLength] = t2.y;
++textureIndex;
}
}
}
length3 = edgePositions.length;
const indices2 = IndexDatatype_default.createTypedArray(
length3 / 3,
length3 - positions.length * 6
);
let edgeIndex = 0;
length3 /= 6;
for (i = 0; i < length3; i++) {
const UL = i;
const UR = UL + 1;
const LL = UL + length3;
const LR = LL + 1;
p1 = Cartesian3_default.fromArray(edgePositions, UL * 3, p1Scratch2);
p2 = Cartesian3_default.fromArray(edgePositions, UR * 3, p2Scratch2);
if (Cartesian3_default.equalsEpsilon(
p1,
p2,
Math_default.EPSILON10,
Math_default.EPSILON10
)) {
continue;
}
indices2[edgeIndex++] = UL;
indices2[edgeIndex++] = LL;
indices2[edgeIndex++] = UR;
indices2[edgeIndex++] = UR;
indices2[edgeIndex++] = LL;
indices2[edgeIndex++] = LR;
}
const geometryOptions = {
attributes: new GeometryAttributes_default({
position: new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.DOUBLE,
componentsPerAttribute: 3,
values: edgePositions
})
}),
indices: indices2,
primitiveType: PrimitiveType_default.TRIANGLES
};
if (hasTexcoords) {
geometryOptions.attributes.st = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.FLOAT,
componentsPerAttribute: 2,
values: edgeTexcoords
});
}
const geometry = new Geometry_default(geometryOptions);
return geometry;
};
var PolygonGeometryLibrary_default = PolygonGeometryLibrary;
// Source/Core/CoplanarPolygonGeometry.js
var scratchPosition2 = new Cartesian3_default();
var scratchBR = new BoundingRectangle_default();
var stScratch = new Cartesian2_default();
var textureCoordinatesOrigin = new Cartesian2_default();
var scratchNormal4 = new Cartesian3_default();
var scratchTangent2 = new Cartesian3_default();
var scratchBitangent2 = new Cartesian3_default();
var centerScratch = new Cartesian3_default();
var axis1Scratch = new Cartesian3_default();
var axis2Scratch = new Cartesian3_default();
var quaternionScratch2 = new Quaternion_default();
var textureMatrixScratch2 = new Matrix3_default();
var tangentRotationScratch = new Matrix3_default();
var surfaceNormalScratch = new Cartesian3_default();
function createGeometryFromPolygon(polygon, vertexFormat, boundingRectangle, stRotation, hardcodedTextureCoordinates, projectPointTo2D, normal2, tangent, bitangent) {
const positions = polygon.positions;
let indices2 = PolygonPipeline_default.triangulate(polygon.positions2D, polygon.holes);
if (indices2.length < 3) {
indices2 = [0, 1, 2];
}
const newIndices = IndexDatatype_default.createTypedArray(
positions.length,
indices2.length
);
newIndices.set(indices2);
let textureMatrix = textureMatrixScratch2;
if (stRotation !== 0) {
let rotation = Quaternion_default.fromAxisAngle(
normal2,
stRotation,
quaternionScratch2
);
textureMatrix = Matrix3_default.fromQuaternion(rotation, textureMatrix);
if (vertexFormat.tangent || vertexFormat.bitangent) {
rotation = Quaternion_default.fromAxisAngle(
normal2,
-stRotation,
quaternionScratch2
);
const tangentRotation = Matrix3_default.fromQuaternion(
rotation,
tangentRotationScratch
);
tangent = Cartesian3_default.normalize(
Matrix3_default.multiplyByVector(tangentRotation, tangent, tangent),
tangent
);
if (vertexFormat.bitangent) {
bitangent = Cartesian3_default.normalize(
Cartesian3_default.cross(normal2, tangent, bitangent),
bitangent
);
}
}
} else {
textureMatrix = Matrix3_default.clone(Matrix3_default.IDENTITY, textureMatrix);
}
const stOrigin = textureCoordinatesOrigin;
if (vertexFormat.st) {
stOrigin.x = boundingRectangle.x;
stOrigin.y = boundingRectangle.y;
}
const length3 = positions.length;
const size = length3 * 3;
const flatPositions2 = new Float64Array(size);
const normals = vertexFormat.normal ? new Float32Array(size) : void 0;
const tangents = vertexFormat.tangent ? new Float32Array(size) : void 0;
const bitangents = vertexFormat.bitangent ? new Float32Array(size) : void 0;
const textureCoordinates = vertexFormat.st ? new Float32Array(length3 * 2) : void 0;
let positionIndex = 0;
let normalIndex = 0;
let bitangentIndex = 0;
let tangentIndex = 0;
let stIndex = 0;
for (let i = 0; i < length3; i++) {
const position = positions[i];
flatPositions2[positionIndex++] = position.x;
flatPositions2[positionIndex++] = position.y;
flatPositions2[positionIndex++] = position.z;
if (vertexFormat.st) {
if (defined_default(hardcodedTextureCoordinates) && hardcodedTextureCoordinates.positions.length === length3) {
textureCoordinates[stIndex++] = hardcodedTextureCoordinates.positions[i].x;
textureCoordinates[stIndex++] = hardcodedTextureCoordinates.positions[i].y;
} else {
const p = Matrix3_default.multiplyByVector(
textureMatrix,
position,
scratchPosition2
);
const st = projectPointTo2D(p, stScratch);
Cartesian2_default.subtract(st, stOrigin, st);
const stx = Math_default.clamp(st.x / boundingRectangle.width, 0, 1);
const sty = Math_default.clamp(st.y / boundingRectangle.height, 0, 1);
textureCoordinates[stIndex++] = stx;
textureCoordinates[stIndex++] = sty;
}
}
if (vertexFormat.normal) {
normals[normalIndex++] = normal2.x;
normals[normalIndex++] = normal2.y;
normals[normalIndex++] = normal2.z;
}
if (vertexFormat.tangent) {
tangents[tangentIndex++] = tangent.x;
tangents[tangentIndex++] = tangent.y;
tangents[tangentIndex++] = tangent.z;
}
if (vertexFormat.bitangent) {
bitangents[bitangentIndex++] = bitangent.x;
bitangents[bitangentIndex++] = bitangent.y;
bitangents[bitangentIndex++] = bitangent.z;
}
}
const attributes = new GeometryAttributes_default();
if (vertexFormat.position) {
attributes.position = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.DOUBLE,
componentsPerAttribute: 3,
values: flatPositions2
});
}
if (vertexFormat.normal) {
attributes.normal = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.FLOAT,
componentsPerAttribute: 3,
values: normals
});
}
if (vertexFormat.tangent) {
attributes.tangent = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.FLOAT,
componentsPerAttribute: 3,
values: tangents
});
}
if (vertexFormat.bitangent) {
attributes.bitangent = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.FLOAT,
componentsPerAttribute: 3,
values: bitangents
});
}
if (vertexFormat.st) {
attributes.st = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.FLOAT,
componentsPerAttribute: 2,
values: textureCoordinates
});
}
return new Geometry_default({
attributes,
indices: newIndices,
primitiveType: PrimitiveType_default.TRIANGLES
});
}
function CoplanarPolygonGeometry(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
const polygonHierarchy = options.polygonHierarchy;
const textureCoordinates = options.textureCoordinates;
Check_default.defined("options.polygonHierarchy", polygonHierarchy);
const vertexFormat = defaultValue_default(options.vertexFormat, VertexFormat_default.DEFAULT);
this._vertexFormat = VertexFormat_default.clone(vertexFormat);
this._polygonHierarchy = polygonHierarchy;
this._stRotation = defaultValue_default(options.stRotation, 0);
this._ellipsoid = Ellipsoid_default.clone(
defaultValue_default(options.ellipsoid, Ellipsoid_default.WGS84)
);
this._workerName = "createCoplanarPolygonGeometry";
this._textureCoordinates = textureCoordinates;
this.packedLength = PolygonGeometryLibrary_default.computeHierarchyPackedLength(
polygonHierarchy,
Cartesian3_default
) + VertexFormat_default.packedLength + Ellipsoid_default.packedLength + (defined_default(textureCoordinates) ? PolygonGeometryLibrary_default.computeHierarchyPackedLength(
textureCoordinates,
Cartesian2_default
) : 1) + 2;
}
CoplanarPolygonGeometry.fromPositions = function(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
Check_default.defined("options.positions", options.positions);
const newOptions2 = {
polygonHierarchy: {
positions: options.positions
},
vertexFormat: options.vertexFormat,
stRotation: options.stRotation,
ellipsoid: options.ellipsoid,
textureCoordinates: options.textureCoordinates
};
return new CoplanarPolygonGeometry(newOptions2);
};
CoplanarPolygonGeometry.pack = function(value, array, startingIndex) {
Check_default.typeOf.object("value", value);
Check_default.defined("array", array);
startingIndex = defaultValue_default(startingIndex, 0);
startingIndex = PolygonGeometryLibrary_default.packPolygonHierarchy(
value._polygonHierarchy,
array,
startingIndex,
Cartesian3_default
);
Ellipsoid_default.pack(value._ellipsoid, array, startingIndex);
startingIndex += Ellipsoid_default.packedLength;
VertexFormat_default.pack(value._vertexFormat, array, startingIndex);
startingIndex += VertexFormat_default.packedLength;
array[startingIndex++] = value._stRotation;
if (defined_default(value._textureCoordinates)) {
startingIndex = PolygonGeometryLibrary_default.packPolygonHierarchy(
value._textureCoordinates,
array,
startingIndex,
Cartesian2_default
);
} else {
array[startingIndex++] = -1;
}
array[startingIndex++] = value.packedLength;
return array;
};
var scratchEllipsoid3 = Ellipsoid_default.clone(Ellipsoid_default.UNIT_SPHERE);
var scratchVertexFormat3 = new VertexFormat_default();
var scratchOptions7 = {
polygonHierarchy: {}
};
CoplanarPolygonGeometry.unpack = function(array, startingIndex, result) {
Check_default.defined("array", array);
startingIndex = defaultValue_default(startingIndex, 0);
const polygonHierarchy = PolygonGeometryLibrary_default.unpackPolygonHierarchy(
array,
startingIndex,
Cartesian3_default
);
startingIndex = polygonHierarchy.startingIndex;
delete polygonHierarchy.startingIndex;
const ellipsoid = Ellipsoid_default.unpack(array, startingIndex, scratchEllipsoid3);
startingIndex += Ellipsoid_default.packedLength;
const vertexFormat = VertexFormat_default.unpack(
array,
startingIndex,
scratchVertexFormat3
);
startingIndex += VertexFormat_default.packedLength;
const stRotation = array[startingIndex++];
const textureCoordinates = array[startingIndex] === -1 ? void 0 : PolygonGeometryLibrary_default.unpackPolygonHierarchy(
array,
startingIndex,
Cartesian2_default
);
if (defined_default(textureCoordinates)) {
startingIndex = textureCoordinates.startingIndex;
delete textureCoordinates.startingIndex;
} else {
startingIndex++;
}
const packedLength = array[startingIndex++];
if (!defined_default(result)) {
result = new CoplanarPolygonGeometry(scratchOptions7);
}
result._polygonHierarchy = polygonHierarchy;
result._ellipsoid = Ellipsoid_default.clone(ellipsoid, result._ellipsoid);
result._vertexFormat = VertexFormat_default.clone(vertexFormat, result._vertexFormat);
result._stRotation = stRotation;
result._textureCoordinates = textureCoordinates;
result.packedLength = packedLength;
return result;
};
CoplanarPolygonGeometry.createGeometry = function(polygonGeometry) {
const vertexFormat = polygonGeometry._vertexFormat;
const polygonHierarchy = polygonGeometry._polygonHierarchy;
const stRotation = polygonGeometry._stRotation;
const textureCoordinates = polygonGeometry._textureCoordinates;
const hasTextureCoordinates = defined_default(textureCoordinates);
let outerPositions = polygonHierarchy.positions;
outerPositions = arrayRemoveDuplicates_default(
outerPositions,
Cartesian3_default.equalsEpsilon,
true
);
if (outerPositions.length < 3) {
return;
}
let normal2 = scratchNormal4;
let tangent = scratchTangent2;
let bitangent = scratchBitangent2;
let axis1 = axis1Scratch;
const axis2 = axis2Scratch;
const validGeometry = CoplanarPolygonGeometryLibrary_default.computeProjectTo2DArguments(
outerPositions,
centerScratch,
axis1,
axis2
);
if (!validGeometry) {
return void 0;
}
normal2 = Cartesian3_default.cross(axis1, axis2, normal2);
normal2 = Cartesian3_default.normalize(normal2, normal2);
if (!Cartesian3_default.equalsEpsilon(
centerScratch,
Cartesian3_default.ZERO,
Math_default.EPSILON6
)) {
const surfaceNormal = polygonGeometry._ellipsoid.geodeticSurfaceNormal(
centerScratch,
surfaceNormalScratch
);
if (Cartesian3_default.dot(normal2, surfaceNormal) < 0) {
normal2 = Cartesian3_default.negate(normal2, normal2);
axis1 = Cartesian3_default.negate(axis1, axis1);
}
}
const projectPoints = CoplanarPolygonGeometryLibrary_default.createProjectPointsTo2DFunction(
centerScratch,
axis1,
axis2
);
const projectPoint = CoplanarPolygonGeometryLibrary_default.createProjectPointTo2DFunction(
centerScratch,
axis1,
axis2
);
if (vertexFormat.tangent) {
tangent = Cartesian3_default.clone(axis1, tangent);
}
if (vertexFormat.bitangent) {
bitangent = Cartesian3_default.clone(axis2, bitangent);
}
const results = PolygonGeometryLibrary_default.polygonsFromHierarchy(
polygonHierarchy,
hasTextureCoordinates,
projectPoints,
false
);
const hierarchy = results.hierarchy;
const polygons = results.polygons;
const dummyFunction = function(identity) {
return identity;
};
const textureCoordinatePolygons = hasTextureCoordinates ? PolygonGeometryLibrary_default.polygonsFromHierarchy(
textureCoordinates,
true,
dummyFunction,
false
).polygons : void 0;
if (hierarchy.length === 0) {
return;
}
outerPositions = hierarchy[0].outerRing;
const boundingSphere = BoundingSphere_default.fromPoints(outerPositions);
const boundingRectangle = PolygonGeometryLibrary_default.computeBoundingRectangle(
normal2,
projectPoint,
outerPositions,
stRotation,
scratchBR
);
const geometries = [];
for (let i = 0; i < polygons.length; i++) {
const geometryInstance = new GeometryInstance_default({
geometry: createGeometryFromPolygon(
polygons[i],
vertexFormat,
boundingRectangle,
stRotation,
hasTextureCoordinates ? textureCoordinatePolygons[i] : void 0,
projectPoint,
normal2,
tangent,
bitangent
)
});
geometries.push(geometryInstance);
}
const geometry = GeometryPipeline_default.combineInstances(geometries)[0];
geometry.attributes.position.values = new Float64Array(
geometry.attributes.position.values
);
geometry.indices = IndexDatatype_default.createTypedArray(
geometry.attributes.position.values.length / 3,
geometry.indices
);
const attributes = geometry.attributes;
if (!vertexFormat.position) {
delete attributes.position;
}
return new Geometry_default({
attributes,
indices: geometry.indices,
primitiveType: geometry.primitiveType,
boundingSphere
});
};
var CoplanarPolygonGeometry_default = CoplanarPolygonGeometry;
// Source/Core/CoplanarPolygonOutlineGeometry.js
function createGeometryFromPositions(positions) {
const length3 = positions.length;
const flatPositions2 = new Float64Array(length3 * 3);
const indices2 = IndexDatatype_default.createTypedArray(length3, length3 * 2);
let positionIndex = 0;
let index = 0;
for (let i = 0; i < length3; i++) {
const position = positions[i];
flatPositions2[positionIndex++] = position.x;
flatPositions2[positionIndex++] = position.y;
flatPositions2[positionIndex++] = position.z;
indices2[index++] = i;
indices2[index++] = (i + 1) % length3;
}
const attributes = new GeometryAttributes_default({
position: new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.DOUBLE,
componentsPerAttribute: 3,
values: flatPositions2
})
});
return new Geometry_default({
attributes,
indices: indices2,
primitiveType: PrimitiveType_default.LINES
});
}
function CoplanarPolygonOutlineGeometry(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
const polygonHierarchy = options.polygonHierarchy;
Check_default.defined("options.polygonHierarchy", polygonHierarchy);
this._polygonHierarchy = polygonHierarchy;
this._workerName = "createCoplanarPolygonOutlineGeometry";
this.packedLength = PolygonGeometryLibrary_default.computeHierarchyPackedLength(
polygonHierarchy,
Cartesian3_default
) + 1;
}
CoplanarPolygonOutlineGeometry.fromPositions = function(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
Check_default.defined("options.positions", options.positions);
const newOptions2 = {
polygonHierarchy: {
positions: options.positions
}
};
return new CoplanarPolygonOutlineGeometry(newOptions2);
};
CoplanarPolygonOutlineGeometry.pack = function(value, array, startingIndex) {
Check_default.typeOf.object("value", value);
Check_default.defined("array", array);
startingIndex = defaultValue_default(startingIndex, 0);
startingIndex = PolygonGeometryLibrary_default.packPolygonHierarchy(
value._polygonHierarchy,
array,
startingIndex,
Cartesian3_default
);
array[startingIndex] = value.packedLength;
return array;
};
var scratchOptions8 = {
polygonHierarchy: {}
};
CoplanarPolygonOutlineGeometry.unpack = function(array, startingIndex, result) {
Check_default.defined("array", array);
startingIndex = defaultValue_default(startingIndex, 0);
const polygonHierarchy = PolygonGeometryLibrary_default.unpackPolygonHierarchy(
array,
startingIndex,
Cartesian3_default
);
startingIndex = polygonHierarchy.startingIndex;
delete polygonHierarchy.startingIndex;
const packedLength = array[startingIndex];
if (!defined_default(result)) {
result = new CoplanarPolygonOutlineGeometry(scratchOptions8);
}
result._polygonHierarchy = polygonHierarchy;
result.packedLength = packedLength;
return result;
};
CoplanarPolygonOutlineGeometry.createGeometry = function(polygonGeometry) {
const polygonHierarchy = polygonGeometry._polygonHierarchy;
let outerPositions = polygonHierarchy.positions;
outerPositions = arrayRemoveDuplicates_default(
outerPositions,
Cartesian3_default.equalsEpsilon,
true
);
if (outerPositions.length < 3) {
return;
}
const isValid = CoplanarPolygonGeometryLibrary_default.validOutline(outerPositions);
if (!isValid) {
return void 0;
}
const polygons = PolygonGeometryLibrary_default.polygonOutlinesFromHierarchy(
polygonHierarchy,
false
);
if (polygons.length === 0) {
return void 0;
}
const geometries = [];
for (let i = 0; i < polygons.length; i++) {
const geometryInstance = new GeometryInstance_default({
geometry: createGeometryFromPositions(polygons[i])
});
geometries.push(geometryInstance);
}
const geometry = GeometryPipeline_default.combineInstances(geometries)[0];
const boundingSphere = BoundingSphere_default.fromPoints(polygonHierarchy.positions);
return new Geometry_default({
attributes: geometry.attributes,
indices: geometry.indices,
primitiveType: geometry.primitiveType,
boundingSphere
});
};
var CoplanarPolygonOutlineGeometry_default = CoplanarPolygonOutlineGeometry;
// Source/Core/CornerType.js
var CornerType = {
ROUNDED: 0,
MITERED: 1,
BEVELED: 2
};
var CornerType_default = Object.freeze(CornerType);
// Source/Core/EllipsoidGeodesic.js
function setConstants(ellipsoidGeodesic3) {
const uSquared = ellipsoidGeodesic3._uSquared;
const a3 = ellipsoidGeodesic3._ellipsoid.maximumRadius;
const b = ellipsoidGeodesic3._ellipsoid.minimumRadius;
const f = (a3 - b) / a3;
const cosineHeading = Math.cos(ellipsoidGeodesic3._startHeading);
const sineHeading = Math.sin(ellipsoidGeodesic3._startHeading);
const tanU = (1 - f) * Math.tan(ellipsoidGeodesic3._start.latitude);
const cosineU = 1 / Math.sqrt(1 + tanU * tanU);
const sineU = cosineU * tanU;
const sigma = Math.atan2(tanU, cosineHeading);
const sineAlpha = cosineU * sineHeading;
const sineSquaredAlpha = sineAlpha * sineAlpha;
const cosineSquaredAlpha = 1 - sineSquaredAlpha;
const cosineAlpha = Math.sqrt(cosineSquaredAlpha);
const u2Over4 = uSquared / 4;
const u4Over16 = u2Over4 * u2Over4;
const u6Over64 = u4Over16 * u2Over4;
const u8Over256 = u4Over16 * u4Over16;
const a0 = 1 + u2Over4 - 3 * u4Over16 / 4 + 5 * u6Over64 / 4 - 175 * u8Over256 / 64;
const a1 = 1 - u2Over4 + 15 * u4Over16 / 8 - 35 * u6Over64 / 8;
const a22 = 1 - 3 * u2Over4 + 35 * u4Over16 / 4;
const a32 = 1 - 5 * u2Over4;
const distanceRatio = a0 * sigma - a1 * Math.sin(2 * sigma) * u2Over4 / 2 - a22 * Math.sin(4 * sigma) * u4Over16 / 16 - a32 * Math.sin(6 * sigma) * u6Over64 / 48 - Math.sin(8 * sigma) * 5 * u8Over256 / 512;
const constants = ellipsoidGeodesic3._constants;
constants.a = a3;
constants.b = b;
constants.f = f;
constants.cosineHeading = cosineHeading;
constants.sineHeading = sineHeading;
constants.tanU = tanU;
constants.cosineU = cosineU;
constants.sineU = sineU;
constants.sigma = sigma;
constants.sineAlpha = sineAlpha;
constants.sineSquaredAlpha = sineSquaredAlpha;
constants.cosineSquaredAlpha = cosineSquaredAlpha;
constants.cosineAlpha = cosineAlpha;
constants.u2Over4 = u2Over4;
constants.u4Over16 = u4Over16;
constants.u6Over64 = u6Over64;
constants.u8Over256 = u8Over256;
constants.a0 = a0;
constants.a1 = a1;
constants.a2 = a22;
constants.a3 = a32;
constants.distanceRatio = distanceRatio;
}
function computeC(f, cosineSquaredAlpha) {
return f * cosineSquaredAlpha * (4 + f * (4 - 3 * cosineSquaredAlpha)) / 16;
}
function computeDeltaLambda(f, sineAlpha, cosineSquaredAlpha, sigma, sineSigma, cosineSigma, cosineTwiceSigmaMidpoint) {
const C = computeC(f, cosineSquaredAlpha);
return (1 - C) * f * sineAlpha * (sigma + C * sineSigma * (cosineTwiceSigmaMidpoint + C * cosineSigma * (2 * cosineTwiceSigmaMidpoint * cosineTwiceSigmaMidpoint - 1)));
}
function vincentyInverseFormula(ellipsoidGeodesic3, major, minor, firstLongitude, firstLatitude, secondLongitude, secondLatitude) {
const eff = (major - minor) / major;
const l = secondLongitude - firstLongitude;
const u12 = Math.atan((1 - eff) * Math.tan(firstLatitude));
const u22 = Math.atan((1 - eff) * Math.tan(secondLatitude));
const cosineU1 = Math.cos(u12);
const sineU1 = Math.sin(u12);
const cosineU2 = Math.cos(u22);
const sineU2 = Math.sin(u22);
const cc = cosineU1 * cosineU2;
const cs = cosineU1 * sineU2;
const ss = sineU1 * sineU2;
const sc = sineU1 * cosineU2;
let lambda = l;
let lambdaDot = Math_default.TWO_PI;
let cosineLambda = Math.cos(lambda);
let sineLambda = Math.sin(lambda);
let sigma;
let cosineSigma;
let sineSigma;
let cosineSquaredAlpha;
let cosineTwiceSigmaMidpoint;
do {
cosineLambda = Math.cos(lambda);
sineLambda = Math.sin(lambda);
const temp = cs - sc * cosineLambda;
sineSigma = Math.sqrt(
cosineU2 * cosineU2 * sineLambda * sineLambda + temp * temp
);
cosineSigma = ss + cc * cosineLambda;
sigma = Math.atan2(sineSigma, cosineSigma);
let sineAlpha;
if (sineSigma === 0) {
sineAlpha = 0;
cosineSquaredAlpha = 1;
} else {
sineAlpha = cc * sineLambda / sineSigma;
cosineSquaredAlpha = 1 - sineAlpha * sineAlpha;
}
lambdaDot = lambda;
cosineTwiceSigmaMidpoint = cosineSigma - 2 * ss / cosineSquaredAlpha;
if (!isFinite(cosineTwiceSigmaMidpoint)) {
cosineTwiceSigmaMidpoint = 0;
}
lambda = l + computeDeltaLambda(
eff,
sineAlpha,
cosineSquaredAlpha,
sigma,
sineSigma,
cosineSigma,
cosineTwiceSigmaMidpoint
);
} while (Math.abs(lambda - lambdaDot) > Math_default.EPSILON12);
const uSquared = cosineSquaredAlpha * (major * major - minor * minor) / (minor * minor);
const A = 1 + uSquared * (4096 + uSquared * (uSquared * (320 - 175 * uSquared) - 768)) / 16384;
const B = uSquared * (256 + uSquared * (uSquared * (74 - 47 * uSquared) - 128)) / 1024;
const cosineSquaredTwiceSigmaMidpoint = cosineTwiceSigmaMidpoint * cosineTwiceSigmaMidpoint;
const deltaSigma = B * sineSigma * (cosineTwiceSigmaMidpoint + B * (cosineSigma * (2 * cosineSquaredTwiceSigmaMidpoint - 1) - B * cosineTwiceSigmaMidpoint * (4 * sineSigma * sineSigma - 3) * (4 * cosineSquaredTwiceSigmaMidpoint - 3) / 6) / 4);
const distance2 = minor * A * (sigma - deltaSigma);
const startHeading = Math.atan2(
cosineU2 * sineLambda,
cs - sc * cosineLambda
);
const endHeading = Math.atan2(cosineU1 * sineLambda, cs * cosineLambda - sc);
ellipsoidGeodesic3._distance = distance2;
ellipsoidGeodesic3._startHeading = startHeading;
ellipsoidGeodesic3._endHeading = endHeading;
ellipsoidGeodesic3._uSquared = uSquared;
}
var scratchCart12 = new Cartesian3_default();
var scratchCart22 = new Cartesian3_default();
function computeProperties2(ellipsoidGeodesic3, start, end, ellipsoid) {
const firstCartesian = Cartesian3_default.normalize(
ellipsoid.cartographicToCartesian(start, scratchCart22),
scratchCart12
);
const lastCartesian = Cartesian3_default.normalize(
ellipsoid.cartographicToCartesian(end, scratchCart22),
scratchCart22
);
Check_default.typeOf.number.greaterThanOrEquals(
"value",
Math.abs(
Math.abs(Cartesian3_default.angleBetween(firstCartesian, lastCartesian)) - Math.PI
),
0.0125
);
vincentyInverseFormula(
ellipsoidGeodesic3,
ellipsoid.maximumRadius,
ellipsoid.minimumRadius,
start.longitude,
start.latitude,
end.longitude,
end.latitude
);
ellipsoidGeodesic3._start = Cartographic_default.clone(
start,
ellipsoidGeodesic3._start
);
ellipsoidGeodesic3._end = Cartographic_default.clone(end, ellipsoidGeodesic3._end);
ellipsoidGeodesic3._start.height = 0;
ellipsoidGeodesic3._end.height = 0;
setConstants(ellipsoidGeodesic3);
}
function EllipsoidGeodesic(start, end, ellipsoid) {
const e = defaultValue_default(ellipsoid, Ellipsoid_default.WGS84);
this._ellipsoid = e;
this._start = new Cartographic_default();
this._end = new Cartographic_default();
this._constants = {};
this._startHeading = void 0;
this._endHeading = void 0;
this._distance = void 0;
this._uSquared = void 0;
if (defined_default(start) && defined_default(end)) {
computeProperties2(this, start, end, e);
}
}
Object.defineProperties(EllipsoidGeodesic.prototype, {
ellipsoid: {
get: function() {
return this._ellipsoid;
}
},
surfaceDistance: {
get: function() {
Check_default.defined("distance", this._distance);
return this._distance;
}
},
start: {
get: function() {
return this._start;
}
},
end: {
get: function() {
return this._end;
}
},
startHeading: {
get: function() {
Check_default.defined("distance", this._distance);
return this._startHeading;
}
},
endHeading: {
get: function() {
Check_default.defined("distance", this._distance);
return this._endHeading;
}
}
});
EllipsoidGeodesic.prototype.setEndPoints = function(start, end) {
Check_default.defined("start", start);
Check_default.defined("end", end);
computeProperties2(this, start, end, this._ellipsoid);
};
EllipsoidGeodesic.prototype.interpolateUsingFraction = function(fraction, result) {
return this.interpolateUsingSurfaceDistance(
this._distance * fraction,
result
);
};
EllipsoidGeodesic.prototype.interpolateUsingSurfaceDistance = function(distance2, result) {
Check_default.defined("distance", this._distance);
const constants = this._constants;
const s = constants.distanceRatio + distance2 / constants.b;
const cosine2S = Math.cos(2 * s);
const cosine4S = Math.cos(4 * s);
const cosine6S = Math.cos(6 * s);
const sine2S = Math.sin(2 * s);
const sine4S = Math.sin(4 * s);
const sine6S = Math.sin(6 * s);
const sine8S = Math.sin(8 * s);
const s2 = s * s;
const s3 = s * s2;
const u8Over256 = constants.u8Over256;
const u2Over4 = constants.u2Over4;
const u6Over64 = constants.u6Over64;
const u4Over16 = constants.u4Over16;
let sigma = 2 * s3 * u8Over256 * cosine2S / 3 + s * (1 - u2Over4 + 7 * u4Over16 / 4 - 15 * u6Over64 / 4 + 579 * u8Over256 / 64 - (u4Over16 - 15 * u6Over64 / 4 + 187 * u8Over256 / 16) * cosine2S - (5 * u6Over64 / 4 - 115 * u8Over256 / 16) * cosine4S - 29 * u8Over256 * cosine6S / 16) + (u2Over4 / 2 - u4Over16 + 71 * u6Over64 / 32 - 85 * u8Over256 / 16) * sine2S + (5 * u4Over16 / 16 - 5 * u6Over64 / 4 + 383 * u8Over256 / 96) * sine4S - s2 * ((u6Over64 - 11 * u8Over256 / 2) * sine2S + 5 * u8Over256 * sine4S / 2) + (29 * u6Over64 / 96 - 29 * u8Over256 / 16) * sine6S + 539 * u8Over256 * sine8S / 1536;
const theta = Math.asin(Math.sin(sigma) * constants.cosineAlpha);
const latitude = Math.atan(constants.a / constants.b * Math.tan(theta));
sigma = sigma - constants.sigma;
const cosineTwiceSigmaMidpoint = Math.cos(2 * constants.sigma + sigma);
const sineSigma = Math.sin(sigma);
const cosineSigma = Math.cos(sigma);
const cc = constants.cosineU * cosineSigma;
const ss = constants.sineU * sineSigma;
const lambda = Math.atan2(
sineSigma * constants.sineHeading,
cc - ss * constants.cosineHeading
);
const l = lambda - computeDeltaLambda(
constants.f,
constants.sineAlpha,
constants.cosineSquaredAlpha,
sigma,
sineSigma,
cosineSigma,
cosineTwiceSigmaMidpoint
);
if (defined_default(result)) {
result.longitude = this._start.longitude + l;
result.latitude = latitude;
result.height = 0;
return result;
}
return new Cartographic_default(this._start.longitude + l, latitude, 0);
};
var EllipsoidGeodesic_default = EllipsoidGeodesic;
// Source/Core/PolylinePipeline.js
var PolylinePipeline = {};
PolylinePipeline.numberOfPoints = function(p0, p1, minDistance) {
const distance2 = Cartesian3_default.distance(p0, p1);
return Math.ceil(distance2 / minDistance);
};
PolylinePipeline.numberOfPointsRhumbLine = function(p0, p1, granularity) {
const radiansDistanceSquared = Math.pow(p0.longitude - p1.longitude, 2) + Math.pow(p0.latitude - p1.latitude, 2);
return Math.max(
1,
Math.ceil(Math.sqrt(radiansDistanceSquared / (granularity * granularity)))
);
};
var cartoScratch = new Cartographic_default();
PolylinePipeline.extractHeights = function(positions, ellipsoid) {
const length3 = positions.length;
const heights = new Array(length3);
for (let i = 0; i < length3; i++) {
const p = positions[i];
heights[i] = ellipsoid.cartesianToCartographic(p, cartoScratch).height;
}
return heights;
};
var wrapLongitudeInversMatrix = new Matrix4_default();
var wrapLongitudeOrigin = new Cartesian3_default();
var wrapLongitudeXZNormal = new Cartesian3_default();
var wrapLongitudeXZPlane = new Plane_default(Cartesian3_default.UNIT_X, 0);
var wrapLongitudeYZNormal = new Cartesian3_default();
var wrapLongitudeYZPlane = new Plane_default(Cartesian3_default.UNIT_X, 0);
var wrapLongitudeIntersection = new Cartesian3_default();
var wrapLongitudeOffset = new Cartesian3_default();
var subdivideHeightsScratchArray = [];
function subdivideHeights(numPoints, h0, h1) {
const heights = subdivideHeightsScratchArray;
heights.length = numPoints;
let i;
if (h0 === h1) {
for (i = 0; i < numPoints; i++) {
heights[i] = h0;
}
return heights;
}
const dHeight = h1 - h0;
const heightPerVertex = dHeight / numPoints;
for (i = 0; i < numPoints; i++) {
const h = h0 + i * heightPerVertex;
heights[i] = h;
}
return heights;
}
var carto1 = new Cartographic_default();
var carto2 = new Cartographic_default();
var cartesian = new Cartesian3_default();
var scaleFirst = new Cartesian3_default();
var scaleLast = new Cartesian3_default();
var ellipsoidGeodesic = new EllipsoidGeodesic_default();
var ellipsoidRhumb = new EllipsoidRhumbLine_default();
function generateCartesianArc(p0, p1, minDistance, ellipsoid, h0, h1, array, offset2) {
const first = ellipsoid.scaleToGeodeticSurface(p0, scaleFirst);
const last = ellipsoid.scaleToGeodeticSurface(p1, scaleLast);
const numPoints = PolylinePipeline.numberOfPoints(p0, p1, minDistance);
const start = ellipsoid.cartesianToCartographic(first, carto1);
const end = ellipsoid.cartesianToCartographic(last, carto2);
const heights = subdivideHeights(numPoints, h0, h1);
ellipsoidGeodesic.setEndPoints(start, end);
const surfaceDistanceBetweenPoints = ellipsoidGeodesic.surfaceDistance / numPoints;
let index = offset2;
start.height = h0;
let cart = ellipsoid.cartographicToCartesian(start, cartesian);
Cartesian3_default.pack(cart, array, index);
index += 3;
for (let i = 1; i < numPoints; i++) {
const carto = ellipsoidGeodesic.interpolateUsingSurfaceDistance(
i * surfaceDistanceBetweenPoints,
carto2
);
carto.height = heights[i];
cart = ellipsoid.cartographicToCartesian(carto, cartesian);
Cartesian3_default.pack(cart, array, index);
index += 3;
}
return index;
}
function generateCartesianRhumbArc(p0, p1, granularity, ellipsoid, h0, h1, array, offset2) {
const start = ellipsoid.cartesianToCartographic(p0, carto1);
const end = ellipsoid.cartesianToCartographic(p1, carto2);
const numPoints = PolylinePipeline.numberOfPointsRhumbLine(
start,
end,
granularity
);
start.height = 0;
end.height = 0;
const heights = subdivideHeights(numPoints, h0, h1);
if (!ellipsoidRhumb.ellipsoid.equals(ellipsoid)) {
ellipsoidRhumb = new EllipsoidRhumbLine_default(void 0, void 0, ellipsoid);
}
ellipsoidRhumb.setEndPoints(start, end);
const surfaceDistanceBetweenPoints = ellipsoidRhumb.surfaceDistance / numPoints;
let index = offset2;
start.height = h0;
let cart = ellipsoid.cartographicToCartesian(start, cartesian);
Cartesian3_default.pack(cart, array, index);
index += 3;
for (let i = 1; i < numPoints; i++) {
const carto = ellipsoidRhumb.interpolateUsingSurfaceDistance(
i * surfaceDistanceBetweenPoints,
carto2
);
carto.height = heights[i];
cart = ellipsoid.cartographicToCartesian(carto, cartesian);
Cartesian3_default.pack(cart, array, index);
index += 3;
}
return index;
}
PolylinePipeline.wrapLongitude = function(positions, modelMatrix) {
const cartesians = [];
const segments = [];
if (defined_default(positions) && positions.length > 0) {
modelMatrix = defaultValue_default(modelMatrix, Matrix4_default.IDENTITY);
const inverseModelMatrix = Matrix4_default.inverseTransformation(
modelMatrix,
wrapLongitudeInversMatrix
);
const origin = Matrix4_default.multiplyByPoint(
inverseModelMatrix,
Cartesian3_default.ZERO,
wrapLongitudeOrigin
);
const xzNormal = Cartesian3_default.normalize(
Matrix4_default.multiplyByPointAsVector(
inverseModelMatrix,
Cartesian3_default.UNIT_Y,
wrapLongitudeXZNormal
),
wrapLongitudeXZNormal
);
const xzPlane2 = Plane_default.fromPointNormal(
origin,
xzNormal,
wrapLongitudeXZPlane
);
const yzNormal = Cartesian3_default.normalize(
Matrix4_default.multiplyByPointAsVector(
inverseModelMatrix,
Cartesian3_default.UNIT_X,
wrapLongitudeYZNormal
),
wrapLongitudeYZNormal
);
const yzPlane = Plane_default.fromPointNormal(
origin,
yzNormal,
wrapLongitudeYZPlane
);
let count = 1;
cartesians.push(Cartesian3_default.clone(positions[0]));
let prev = cartesians[0];
const length3 = positions.length;
for (let i = 1; i < length3; ++i) {
const cur = positions[i];
if (Plane_default.getPointDistance(yzPlane, prev) < 0 || Plane_default.getPointDistance(yzPlane, cur) < 0) {
const intersection = IntersectionTests_default.lineSegmentPlane(
prev,
cur,
xzPlane2,
wrapLongitudeIntersection
);
if (defined_default(intersection)) {
const offset2 = Cartesian3_default.multiplyByScalar(
xzNormal,
5e-9,
wrapLongitudeOffset
);
if (Plane_default.getPointDistance(xzPlane2, prev) < 0) {
Cartesian3_default.negate(offset2, offset2);
}
cartesians.push(
Cartesian3_default.add(intersection, offset2, new Cartesian3_default())
);
segments.push(count + 1);
Cartesian3_default.negate(offset2, offset2);
cartesians.push(
Cartesian3_default.add(intersection, offset2, new Cartesian3_default())
);
count = 1;
}
}
cartesians.push(Cartesian3_default.clone(positions[i]));
count++;
prev = cur;
}
segments.push(count);
}
return {
positions: cartesians,
lengths: segments
};
};
PolylinePipeline.generateArc = function(options) {
if (!defined_default(options)) {
options = {};
}
const positions = options.positions;
if (!defined_default(positions)) {
throw new DeveloperError_default("options.positions is required.");
}
const length3 = positions.length;
const ellipsoid = defaultValue_default(options.ellipsoid, Ellipsoid_default.WGS84);
let height = defaultValue_default(options.height, 0);
const hasHeightArray = Array.isArray(height);
if (length3 < 1) {
return [];
} else if (length3 === 1) {
const p = ellipsoid.scaleToGeodeticSurface(positions[0], scaleFirst);
height = hasHeightArray ? height[0] : height;
if (height !== 0) {
const n = ellipsoid.geodeticSurfaceNormal(p, cartesian);
Cartesian3_default.multiplyByScalar(n, height, n);
Cartesian3_default.add(p, n, p);
}
return [p.x, p.y, p.z];
}
let minDistance = options.minDistance;
if (!defined_default(minDistance)) {
const granularity = defaultValue_default(
options.granularity,
Math_default.RADIANS_PER_DEGREE
);
minDistance = Math_default.chordLength(granularity, ellipsoid.maximumRadius);
}
let numPoints = 0;
let i;
for (i = 0; i < length3 - 1; i++) {
numPoints += PolylinePipeline.numberOfPoints(
positions[i],
positions[i + 1],
minDistance
);
}
const arrayLength = (numPoints + 1) * 3;
const newPositions = new Array(arrayLength);
let offset2 = 0;
for (i = 0; i < length3 - 1; i++) {
const p0 = positions[i];
const p1 = positions[i + 1];
const h0 = hasHeightArray ? height[i] : height;
const h1 = hasHeightArray ? height[i + 1] : height;
offset2 = generateCartesianArc(
p0,
p1,
minDistance,
ellipsoid,
h0,
h1,
newPositions,
offset2
);
}
subdivideHeightsScratchArray.length = 0;
const lastPoint = positions[length3 - 1];
const carto = ellipsoid.cartesianToCartographic(lastPoint, carto1);
carto.height = hasHeightArray ? height[length3 - 1] : height;
const cart = ellipsoid.cartographicToCartesian(carto, cartesian);
Cartesian3_default.pack(cart, newPositions, arrayLength - 3);
return newPositions;
};
var scratchCartographic02 = new Cartographic_default();
var scratchCartographic12 = new Cartographic_default();
PolylinePipeline.generateRhumbArc = function(options) {
if (!defined_default(options)) {
options = {};
}
const positions = options.positions;
if (!defined_default(positions)) {
throw new DeveloperError_default("options.positions is required.");
}
const length3 = positions.length;
const ellipsoid = defaultValue_default(options.ellipsoid, Ellipsoid_default.WGS84);
let height = defaultValue_default(options.height, 0);
const hasHeightArray = Array.isArray(height);
if (length3 < 1) {
return [];
} else if (length3 === 1) {
const p = ellipsoid.scaleToGeodeticSurface(positions[0], scaleFirst);
height = hasHeightArray ? height[0] : height;
if (height !== 0) {
const n = ellipsoid.geodeticSurfaceNormal(p, cartesian);
Cartesian3_default.multiplyByScalar(n, height, n);
Cartesian3_default.add(p, n, p);
}
return [p.x, p.y, p.z];
}
const granularity = defaultValue_default(
options.granularity,
Math_default.RADIANS_PER_DEGREE
);
let numPoints = 0;
let i;
let c0 = ellipsoid.cartesianToCartographic(
positions[0],
scratchCartographic02
);
let c14;
for (i = 0; i < length3 - 1; i++) {
c14 = ellipsoid.cartesianToCartographic(
positions[i + 1],
scratchCartographic12
);
numPoints += PolylinePipeline.numberOfPointsRhumbLine(c0, c14, granularity);
c0 = Cartographic_default.clone(c14, scratchCartographic02);
}
const arrayLength = (numPoints + 1) * 3;
const newPositions = new Array(arrayLength);
let offset2 = 0;
for (i = 0; i < length3 - 1; i++) {
const p0 = positions[i];
const p1 = positions[i + 1];
const h0 = hasHeightArray ? height[i] : height;
const h1 = hasHeightArray ? height[i + 1] : height;
offset2 = generateCartesianRhumbArc(
p0,
p1,
granularity,
ellipsoid,
h0,
h1,
newPositions,
offset2
);
}
subdivideHeightsScratchArray.length = 0;
const lastPoint = positions[length3 - 1];
const carto = ellipsoid.cartesianToCartographic(lastPoint, carto1);
carto.height = hasHeightArray ? height[length3 - 1] : height;
const cart = ellipsoid.cartographicToCartesian(carto, cartesian);
Cartesian3_default.pack(cart, newPositions, arrayLength - 3);
return newPositions;
};
PolylinePipeline.generateCartesianArc = function(options) {
const numberArray = PolylinePipeline.generateArc(options);
const size = numberArray.length / 3;
const newPositions = new Array(size);
for (let i = 0; i < size; i++) {
newPositions[i] = Cartesian3_default.unpack(numberArray, i * 3);
}
return newPositions;
};
PolylinePipeline.generateCartesianRhumbArc = function(options) {
const numberArray = PolylinePipeline.generateRhumbArc(options);
const size = numberArray.length / 3;
const newPositions = new Array(size);
for (let i = 0; i < size; i++) {
newPositions[i] = Cartesian3_default.unpack(numberArray, i * 3);
}
return newPositions;
};
var PolylinePipeline_default = PolylinePipeline;
// Source/Core/PolylineVolumeGeometryLibrary.js
var scratch2Array = [new Cartesian3_default(), new Cartesian3_default()];
var scratchCartesian16 = new Cartesian3_default();
var scratchCartesian27 = new Cartesian3_default();
var scratchCartesian37 = new Cartesian3_default();
var scratchCartesian43 = new Cartesian3_default();
var scratchCartesian52 = new Cartesian3_default();
var scratchCartesian62 = new Cartesian3_default();
var scratchCartesian7 = new Cartesian3_default();
var scratchCartesian8 = new Cartesian3_default();
var scratchCartesian9 = new Cartesian3_default();
var scratch1 = new Cartesian3_default();
var scratch2 = new Cartesian3_default();
var PolylineVolumeGeometryLibrary = {};
var cartographic = new Cartographic_default();
function scaleToSurface(positions, ellipsoid) {
const heights = new Array(positions.length);
for (let i = 0; i < positions.length; i++) {
const pos = positions[i];
cartographic = ellipsoid.cartesianToCartographic(pos, cartographic);
heights[i] = cartographic.height;
positions[i] = ellipsoid.scaleToGeodeticSurface(pos, pos);
}
return heights;
}
function subdivideHeights2(points, h0, h1, granularity) {
const p0 = points[0];
const p1 = points[1];
const angleBetween = Cartesian3_default.angleBetween(p0, p1);
const numPoints = Math.ceil(angleBetween / granularity);
const heights = new Array(numPoints);
let i;
if (h0 === h1) {
for (i = 0; i < numPoints; i++) {
heights[i] = h0;
}
heights.push(h1);
return heights;
}
const dHeight = h1 - h0;
const heightPerVertex = dHeight / numPoints;
for (i = 1; i < numPoints; i++) {
const h = h0 + i * heightPerVertex;
heights[i] = h;
}
heights[0] = h0;
heights.push(h1);
return heights;
}
var nextScratch = new Cartesian3_default();
var prevScratch = new Cartesian3_default();
function computeRotationAngle(start, end, position, ellipsoid) {
const tangentPlane = new EllipsoidTangentPlane_default(position, ellipsoid);
const next = tangentPlane.projectPointOntoPlane(
Cartesian3_default.add(position, start, nextScratch),
nextScratch
);
const prev = tangentPlane.projectPointOntoPlane(
Cartesian3_default.add(position, end, prevScratch),
prevScratch
);
const angle = Cartesian2_default.angleBetween(next, prev);
return prev.x * next.y - prev.y * next.x >= 0 ? -angle : angle;
}
var negativeX = new Cartesian3_default(-1, 0, 0);
var transform = new Matrix4_default();
var translation = new Matrix4_default();
var rotationZ = new Matrix3_default();
var scaleMatrix = Matrix3_default.IDENTITY.clone();
var westScratch2 = new Cartesian3_default();
var finalPosScratch = new Cartesian4_default();
var heightCartesian = new Cartesian3_default();
function addPosition(center, left, shape, finalPositions, ellipsoid, height, xScalar, repeat) {
let west = westScratch2;
let finalPosition = finalPosScratch;
transform = Transforms_default.eastNorthUpToFixedFrame(center, ellipsoid, transform);
west = Matrix4_default.multiplyByPointAsVector(transform, negativeX, west);
west = Cartesian3_default.normalize(west, west);
const angle = computeRotationAngle(west, left, center, ellipsoid);
rotationZ = Matrix3_default.fromRotationZ(angle, rotationZ);
heightCartesian.z = height;
transform = Matrix4_default.multiplyTransformation(
transform,
Matrix4_default.fromRotationTranslation(rotationZ, heightCartesian, translation),
transform
);
const scale = scaleMatrix;
scale[0] = xScalar;
for (let j = 0; j < repeat; j++) {
for (let i = 0; i < shape.length; i += 3) {
finalPosition = Cartesian3_default.fromArray(shape, i, finalPosition);
finalPosition = Matrix3_default.multiplyByVector(
scale,
finalPosition,
finalPosition
);
finalPosition = Matrix4_default.multiplyByPoint(
transform,
finalPosition,
finalPosition
);
finalPositions.push(finalPosition.x, finalPosition.y, finalPosition.z);
}
}
return finalPositions;
}
var centerScratch2 = new Cartesian3_default();
function addPositions(centers, left, shape, finalPositions, ellipsoid, heights, xScalar) {
for (let i = 0; i < centers.length; i += 3) {
const center = Cartesian3_default.fromArray(centers, i, centerScratch2);
finalPositions = addPosition(
center,
left,
shape,
finalPositions,
ellipsoid,
heights[i / 3],
xScalar,
1
);
}
return finalPositions;
}
function convertShapeTo3DDuplicate(shape2D, boundingRectangle) {
const length3 = shape2D.length;
const shape = new Array(length3 * 6);
let index = 0;
const xOffset = boundingRectangle.x + boundingRectangle.width / 2;
const yOffset = boundingRectangle.y + boundingRectangle.height / 2;
let point = shape2D[0];
shape[index++] = point.x - xOffset;
shape[index++] = 0;
shape[index++] = point.y - yOffset;
for (let i = 1; i < length3; i++) {
point = shape2D[i];
const x = point.x - xOffset;
const z = point.y - yOffset;
shape[index++] = x;
shape[index++] = 0;
shape[index++] = z;
shape[index++] = x;
shape[index++] = 0;
shape[index++] = z;
}
point = shape2D[0];
shape[index++] = point.x - xOffset;
shape[index++] = 0;
shape[index++] = point.y - yOffset;
return shape;
}
function convertShapeTo3D(shape2D, boundingRectangle) {
const length3 = shape2D.length;
const shape = new Array(length3 * 3);
let index = 0;
const xOffset = boundingRectangle.x + boundingRectangle.width / 2;
const yOffset = boundingRectangle.y + boundingRectangle.height / 2;
for (let i = 0; i < length3; i++) {
shape[index++] = shape2D[i].x - xOffset;
shape[index++] = 0;
shape[index++] = shape2D[i].y - yOffset;
}
return shape;
}
var quaterion = new Quaternion_default();
var startPointScratch = new Cartesian3_default();
var rotMatrix = new Matrix3_default();
function computeRoundCorner(pivot, startPoint, endPoint, cornerType, leftIsOutside, ellipsoid, finalPositions, shape, height, duplicatePoints) {
const angle = Cartesian3_default.angleBetween(
Cartesian3_default.subtract(startPoint, pivot, scratch1),
Cartesian3_default.subtract(endPoint, pivot, scratch2)
);
const granularity = cornerType === CornerType_default.BEVELED ? 0 : Math.ceil(angle / Math_default.toRadians(5));
let m;
if (leftIsOutside) {
m = Matrix3_default.fromQuaternion(
Quaternion_default.fromAxisAngle(
Cartesian3_default.negate(pivot, scratch1),
angle / (granularity + 1),
quaterion
),
rotMatrix
);
} else {
m = Matrix3_default.fromQuaternion(
Quaternion_default.fromAxisAngle(pivot, angle / (granularity + 1), quaterion),
rotMatrix
);
}
let left;
let surfacePoint;
startPoint = Cartesian3_default.clone(startPoint, startPointScratch);
if (granularity > 0) {
const repeat = duplicatePoints ? 2 : 1;
for (let i = 0; i < granularity; i++) {
startPoint = Matrix3_default.multiplyByVector(m, startPoint, startPoint);
left = Cartesian3_default.subtract(startPoint, pivot, scratch1);
left = Cartesian3_default.normalize(left, left);
if (!leftIsOutside) {
left = Cartesian3_default.negate(left, left);
}
surfacePoint = ellipsoid.scaleToGeodeticSurface(startPoint, scratch2);
finalPositions = addPosition(
surfacePoint,
left,
shape,
finalPositions,
ellipsoid,
height,
1,
repeat
);
}
} else {
left = Cartesian3_default.subtract(startPoint, pivot, scratch1);
left = Cartesian3_default.normalize(left, left);
if (!leftIsOutside) {
left = Cartesian3_default.negate(left, left);
}
surfacePoint = ellipsoid.scaleToGeodeticSurface(startPoint, scratch2);
finalPositions = addPosition(
surfacePoint,
left,
shape,
finalPositions,
ellipsoid,
height,
1,
1
);
endPoint = Cartesian3_default.clone(endPoint, startPointScratch);
left = Cartesian3_default.subtract(endPoint, pivot, scratch1);
left = Cartesian3_default.normalize(left, left);
if (!leftIsOutside) {
left = Cartesian3_default.negate(left, left);
}
surfacePoint = ellipsoid.scaleToGeodeticSurface(endPoint, scratch2);
finalPositions = addPosition(
surfacePoint,
left,
shape,
finalPositions,
ellipsoid,
height,
1,
1
);
}
return finalPositions;
}
PolylineVolumeGeometryLibrary.removeDuplicatesFromShape = function(shapePositions) {
const length3 = shapePositions.length;
const cleanedPositions = [];
for (let i0 = length3 - 1, i1 = 0; i1 < length3; i0 = i1++) {
const v02 = shapePositions[i0];
const v13 = shapePositions[i1];
if (!Cartesian2_default.equals(v02, v13)) {
cleanedPositions.push(v13);
}
}
return cleanedPositions;
};
PolylineVolumeGeometryLibrary.angleIsGreaterThanPi = function(forward, backward, position, ellipsoid) {
const tangentPlane = new EllipsoidTangentPlane_default(position, ellipsoid);
const next = tangentPlane.projectPointOntoPlane(
Cartesian3_default.add(position, forward, nextScratch),
nextScratch
);
const prev = tangentPlane.projectPointOntoPlane(
Cartesian3_default.add(position, backward, prevScratch),
prevScratch
);
return prev.x * next.y - prev.y * next.x >= 0;
};
var scratchForwardProjection = new Cartesian3_default();
var scratchBackwardProjection = new Cartesian3_default();
PolylineVolumeGeometryLibrary.computePositions = function(positions, shape2D, boundingRectangle, geometry, duplicatePoints) {
const ellipsoid = geometry._ellipsoid;
const heights = scaleToSurface(positions, ellipsoid);
const granularity = geometry._granularity;
const cornerType = geometry._cornerType;
const shapeForSides = duplicatePoints ? convertShapeTo3DDuplicate(shape2D, boundingRectangle) : convertShapeTo3D(shape2D, boundingRectangle);
const shapeForEnds = duplicatePoints ? convertShapeTo3D(shape2D, boundingRectangle) : void 0;
const heightOffset = boundingRectangle.height / 2;
const width = boundingRectangle.width / 2;
let length3 = positions.length;
let finalPositions = [];
let ends = duplicatePoints ? [] : void 0;
let forward = scratchCartesian16;
let backward = scratchCartesian27;
let cornerDirection = scratchCartesian37;
let surfaceNormal = scratchCartesian43;
let pivot = scratchCartesian52;
let start = scratchCartesian62;
let end = scratchCartesian7;
let left = scratchCartesian8;
let previousPosition = scratchCartesian9;
let position = positions[0];
let nextPosition = positions[1];
surfaceNormal = ellipsoid.geodeticSurfaceNormal(position, surfaceNormal);
forward = Cartesian3_default.subtract(nextPosition, position, forward);
forward = Cartesian3_default.normalize(forward, forward);
left = Cartesian3_default.cross(surfaceNormal, forward, left);
left = Cartesian3_default.normalize(left, left);
let h0 = heights[0];
let h1 = heights[1];
if (duplicatePoints) {
ends = addPosition(
position,
left,
shapeForEnds,
ends,
ellipsoid,
h0 + heightOffset,
1,
1
);
}
previousPosition = Cartesian3_default.clone(position, previousPosition);
position = nextPosition;
backward = Cartesian3_default.negate(forward, backward);
let subdividedHeights;
let subdividedPositions;
for (let i = 1; i < length3 - 1; i++) {
const repeat = duplicatePoints ? 2 : 1;
nextPosition = positions[i + 1];
if (position.equals(nextPosition)) {
oneTimeWarning_default(
"Positions are too close and are considered equivalent with rounding error."
);
continue;
}
forward = Cartesian3_default.subtract(nextPosition, position, forward);
forward = Cartesian3_default.normalize(forward, forward);
cornerDirection = Cartesian3_default.add(forward, backward, cornerDirection);
cornerDirection = Cartesian3_default.normalize(cornerDirection, cornerDirection);
surfaceNormal = ellipsoid.geodeticSurfaceNormal(position, surfaceNormal);
const forwardProjection = Cartesian3_default.multiplyByScalar(
surfaceNormal,
Cartesian3_default.dot(forward, surfaceNormal),
scratchForwardProjection
);
Cartesian3_default.subtract(forward, forwardProjection, forwardProjection);
Cartesian3_default.normalize(forwardProjection, forwardProjection);
const backwardProjection = Cartesian3_default.multiplyByScalar(
surfaceNormal,
Cartesian3_default.dot(backward, surfaceNormal),
scratchBackwardProjection
);
Cartesian3_default.subtract(backward, backwardProjection, backwardProjection);
Cartesian3_default.normalize(backwardProjection, backwardProjection);
const doCorner = !Math_default.equalsEpsilon(
Math.abs(Cartesian3_default.dot(forwardProjection, backwardProjection)),
1,
Math_default.EPSILON7
);
if (doCorner) {
cornerDirection = Cartesian3_default.cross(
cornerDirection,
surfaceNormal,
cornerDirection
);
cornerDirection = Cartesian3_default.cross(
surfaceNormal,
cornerDirection,
cornerDirection
);
cornerDirection = Cartesian3_default.normalize(cornerDirection, cornerDirection);
const scalar = 1 / Math.max(
0.25,
Cartesian3_default.magnitude(
Cartesian3_default.cross(cornerDirection, backward, scratch1)
)
);
const leftIsOutside = PolylineVolumeGeometryLibrary.angleIsGreaterThanPi(
forward,
backward,
position,
ellipsoid
);
if (leftIsOutside) {
pivot = Cartesian3_default.add(
position,
Cartesian3_default.multiplyByScalar(
cornerDirection,
scalar * width,
cornerDirection
),
pivot
);
start = Cartesian3_default.add(
pivot,
Cartesian3_default.multiplyByScalar(left, width, start),
start
);
scratch2Array[0] = Cartesian3_default.clone(previousPosition, scratch2Array[0]);
scratch2Array[1] = Cartesian3_default.clone(start, scratch2Array[1]);
subdividedHeights = subdivideHeights2(
scratch2Array,
h0 + heightOffset,
h1 + heightOffset,
granularity
);
subdividedPositions = PolylinePipeline_default.generateArc({
positions: scratch2Array,
granularity,
ellipsoid
});
finalPositions = addPositions(
subdividedPositions,
left,
shapeForSides,
finalPositions,
ellipsoid,
subdividedHeights,
1
);
left = Cartesian3_default.cross(surfaceNormal, forward, left);
left = Cartesian3_default.normalize(left, left);
end = Cartesian3_default.add(
pivot,
Cartesian3_default.multiplyByScalar(left, width, end),
end
);
if (cornerType === CornerType_default.ROUNDED || cornerType === CornerType_default.BEVELED) {
computeRoundCorner(
pivot,
start,
end,
cornerType,
leftIsOutside,
ellipsoid,
finalPositions,
shapeForSides,
h1 + heightOffset,
duplicatePoints
);
} else {
cornerDirection = Cartesian3_default.negate(cornerDirection, cornerDirection);
finalPositions = addPosition(
position,
cornerDirection,
shapeForSides,
finalPositions,
ellipsoid,
h1 + heightOffset,
scalar,
repeat
);
}
previousPosition = Cartesian3_default.clone(end, previousPosition);
} else {
pivot = Cartesian3_default.add(
position,
Cartesian3_default.multiplyByScalar(
cornerDirection,
scalar * width,
cornerDirection
),
pivot
);
start = Cartesian3_default.add(
pivot,
Cartesian3_default.multiplyByScalar(left, -width, start),
start
);
scratch2Array[0] = Cartesian3_default.clone(previousPosition, scratch2Array[0]);
scratch2Array[1] = Cartesian3_default.clone(start, scratch2Array[1]);
subdividedHeights = subdivideHeights2(
scratch2Array,
h0 + heightOffset,
h1 + heightOffset,
granularity
);
subdividedPositions = PolylinePipeline_default.generateArc({
positions: scratch2Array,
granularity,
ellipsoid
});
finalPositions = addPositions(
subdividedPositions,
left,
shapeForSides,
finalPositions,
ellipsoid,
subdividedHeights,
1
);
left = Cartesian3_default.cross(surfaceNormal, forward, left);
left = Cartesian3_default.normalize(left, left);
end = Cartesian3_default.add(
pivot,
Cartesian3_default.multiplyByScalar(left, -width, end),
end
);
if (cornerType === CornerType_default.ROUNDED || cornerType === CornerType_default.BEVELED) {
computeRoundCorner(
pivot,
start,
end,
cornerType,
leftIsOutside,
ellipsoid,
finalPositions,
shapeForSides,
h1 + heightOffset,
duplicatePoints
);
} else {
finalPositions = addPosition(
position,
cornerDirection,
shapeForSides,
finalPositions,
ellipsoid,
h1 + heightOffset,
scalar,
repeat
);
}
previousPosition = Cartesian3_default.clone(end, previousPosition);
}
backward = Cartesian3_default.negate(forward, backward);
} else {
finalPositions = addPosition(
previousPosition,
left,
shapeForSides,
finalPositions,
ellipsoid,
h0 + heightOffset,
1,
1
);
previousPosition = position;
}
h0 = h1;
h1 = heights[i + 1];
position = nextPosition;
}
scratch2Array[0] = Cartesian3_default.clone(previousPosition, scratch2Array[0]);
scratch2Array[1] = Cartesian3_default.clone(position, scratch2Array[1]);
subdividedHeights = subdivideHeights2(
scratch2Array,
h0 + heightOffset,
h1 + heightOffset,
granularity
);
subdividedPositions = PolylinePipeline_default.generateArc({
positions: scratch2Array,
granularity,
ellipsoid
});
finalPositions = addPositions(
subdividedPositions,
left,
shapeForSides,
finalPositions,
ellipsoid,
subdividedHeights,
1
);
if (duplicatePoints) {
ends = addPosition(
position,
left,
shapeForEnds,
ends,
ellipsoid,
h1 + heightOffset,
1,
1
);
}
length3 = finalPositions.length;
const posLength = duplicatePoints ? length3 + ends.length : length3;
const combinedPositions = new Float64Array(posLength);
combinedPositions.set(finalPositions);
if (duplicatePoints) {
combinedPositions.set(ends, length3);
}
return combinedPositions;
};
var PolylineVolumeGeometryLibrary_default = PolylineVolumeGeometryLibrary;
// Source/Core/CorridorGeometryLibrary.js
var CorridorGeometryLibrary = {};
var scratch12 = new Cartesian3_default();
var scratch22 = new Cartesian3_default();
var scratch3 = new Cartesian3_default();
var scratch4 = new Cartesian3_default();
var scaleArray2 = [new Cartesian3_default(), new Cartesian3_default()];
var cartesian1 = new Cartesian3_default();
var cartesian2 = new Cartesian3_default();
var cartesian3 = new Cartesian3_default();
var cartesian4 = new Cartesian3_default();
var cartesian5 = new Cartesian3_default();
var cartesian6 = new Cartesian3_default();
var cartesian7 = new Cartesian3_default();
var cartesian8 = new Cartesian3_default();
var cartesian9 = new Cartesian3_default();
var cartesian10 = new Cartesian3_default();
var quaterion2 = new Quaternion_default();
var rotMatrix2 = new Matrix3_default();
function computeRoundCorner2(cornerPoint, startPoint, endPoint, cornerType, leftIsOutside) {
const angle = Cartesian3_default.angleBetween(
Cartesian3_default.subtract(startPoint, cornerPoint, scratch12),
Cartesian3_default.subtract(endPoint, cornerPoint, scratch22)
);
const granularity = cornerType === CornerType_default.BEVELED ? 1 : Math.ceil(angle / Math_default.toRadians(5)) + 1;
const size = granularity * 3;
const array = new Array(size);
array[size - 3] = endPoint.x;
array[size - 2] = endPoint.y;
array[size - 1] = endPoint.z;
let m;
if (leftIsOutside) {
m = Matrix3_default.fromQuaternion(
Quaternion_default.fromAxisAngle(
Cartesian3_default.negate(cornerPoint, scratch12),
angle / granularity,
quaterion2
),
rotMatrix2
);
} else {
m = Matrix3_default.fromQuaternion(
Quaternion_default.fromAxisAngle(cornerPoint, angle / granularity, quaterion2),
rotMatrix2
);
}
let index = 0;
startPoint = Cartesian3_default.clone(startPoint, scratch12);
for (let i = 0; i < granularity; i++) {
startPoint = Matrix3_default.multiplyByVector(m, startPoint, startPoint);
array[index++] = startPoint.x;
array[index++] = startPoint.y;
array[index++] = startPoint.z;
}
return array;
}
function addEndCaps(calculatedPositions) {
let cornerPoint = cartesian1;
let startPoint = cartesian2;
let endPoint = cartesian3;
let leftEdge = calculatedPositions[1];
startPoint = Cartesian3_default.fromArray(
calculatedPositions[1],
leftEdge.length - 3,
startPoint
);
endPoint = Cartesian3_default.fromArray(calculatedPositions[0], 0, endPoint);
cornerPoint = Cartesian3_default.midpoint(startPoint, endPoint, cornerPoint);
const firstEndCap = computeRoundCorner2(
cornerPoint,
startPoint,
endPoint,
CornerType_default.ROUNDED,
false
);
const length3 = calculatedPositions.length - 1;
const rightEdge = calculatedPositions[length3 - 1];
leftEdge = calculatedPositions[length3];
startPoint = Cartesian3_default.fromArray(
rightEdge,
rightEdge.length - 3,
startPoint
);
endPoint = Cartesian3_default.fromArray(leftEdge, 0, endPoint);
cornerPoint = Cartesian3_default.midpoint(startPoint, endPoint, cornerPoint);
const lastEndCap = computeRoundCorner2(
cornerPoint,
startPoint,
endPoint,
CornerType_default.ROUNDED,
false
);
return [firstEndCap, lastEndCap];
}
function computeMiteredCorner(position, leftCornerDirection, lastPoint, leftIsOutside) {
let cornerPoint = scratch12;
if (leftIsOutside) {
cornerPoint = Cartesian3_default.add(position, leftCornerDirection, cornerPoint);
} else {
leftCornerDirection = Cartesian3_default.negate(
leftCornerDirection,
leftCornerDirection
);
cornerPoint = Cartesian3_default.add(position, leftCornerDirection, cornerPoint);
}
return [
cornerPoint.x,
cornerPoint.y,
cornerPoint.z,
lastPoint.x,
lastPoint.y,
lastPoint.z
];
}
function addShiftedPositions(positions, left, scalar, calculatedPositions) {
const rightPositions = new Array(positions.length);
const leftPositions = new Array(positions.length);
const scaledLeft = Cartesian3_default.multiplyByScalar(left, scalar, scratch12);
const scaledRight = Cartesian3_default.negate(scaledLeft, scratch22);
let rightIndex = 0;
let leftIndex = positions.length - 1;
for (let i = 0; i < positions.length; i += 3) {
const pos = Cartesian3_default.fromArray(positions, i, scratch3);
const rightPos = Cartesian3_default.add(pos, scaledRight, scratch4);
rightPositions[rightIndex++] = rightPos.x;
rightPositions[rightIndex++] = rightPos.y;
rightPositions[rightIndex++] = rightPos.z;
const leftPos = Cartesian3_default.add(pos, scaledLeft, scratch4);
leftPositions[leftIndex--] = leftPos.z;
leftPositions[leftIndex--] = leftPos.y;
leftPositions[leftIndex--] = leftPos.x;
}
calculatedPositions.push(rightPositions, leftPositions);
return calculatedPositions;
}
CorridorGeometryLibrary.addAttribute = function(attribute, value, front, back) {
const x = value.x;
const y = value.y;
const z = value.z;
if (defined_default(front)) {
attribute[front] = x;
attribute[front + 1] = y;
attribute[front + 2] = z;
}
if (defined_default(back)) {
attribute[back] = z;
attribute[back - 1] = y;
attribute[back - 2] = x;
}
};
var scratchForwardProjection2 = new Cartesian3_default();
var scratchBackwardProjection2 = new Cartesian3_default();
CorridorGeometryLibrary.computePositions = function(params) {
const granularity = params.granularity;
const positions = params.positions;
const ellipsoid = params.ellipsoid;
const width = params.width / 2;
const cornerType = params.cornerType;
const saveAttributes = params.saveAttributes;
let normal2 = cartesian1;
let forward = cartesian2;
let backward = cartesian3;
let left = cartesian4;
let cornerDirection = cartesian5;
let startPoint = cartesian6;
let previousPos = cartesian7;
let rightPos = cartesian8;
let leftPos = cartesian9;
let center = cartesian10;
let calculatedPositions = [];
const calculatedLefts = saveAttributes ? [] : void 0;
const calculatedNormals = saveAttributes ? [] : void 0;
let position = positions[0];
let nextPosition = positions[1];
forward = Cartesian3_default.normalize(
Cartesian3_default.subtract(nextPosition, position, forward),
forward
);
normal2 = ellipsoid.geodeticSurfaceNormal(position, normal2);
left = Cartesian3_default.normalize(Cartesian3_default.cross(normal2, forward, left), left);
if (saveAttributes) {
calculatedLefts.push(left.x, left.y, left.z);
calculatedNormals.push(normal2.x, normal2.y, normal2.z);
}
previousPos = Cartesian3_default.clone(position, previousPos);
position = nextPosition;
backward = Cartesian3_default.negate(forward, backward);
let subdividedPositions;
const corners = [];
let i;
const length3 = positions.length;
for (i = 1; i < length3 - 1; i++) {
normal2 = ellipsoid.geodeticSurfaceNormal(position, normal2);
nextPosition = positions[i + 1];
forward = Cartesian3_default.normalize(
Cartesian3_default.subtract(nextPosition, position, forward),
forward
);
cornerDirection = Cartesian3_default.normalize(
Cartesian3_default.add(forward, backward, cornerDirection),
cornerDirection
);
const forwardProjection = Cartesian3_default.multiplyByScalar(
normal2,
Cartesian3_default.dot(forward, normal2),
scratchForwardProjection2
);
Cartesian3_default.subtract(forward, forwardProjection, forwardProjection);
Cartesian3_default.normalize(forwardProjection, forwardProjection);
const backwardProjection = Cartesian3_default.multiplyByScalar(
normal2,
Cartesian3_default.dot(backward, normal2),
scratchBackwardProjection2
);
Cartesian3_default.subtract(backward, backwardProjection, backwardProjection);
Cartesian3_default.normalize(backwardProjection, backwardProjection);
const doCorner = !Math_default.equalsEpsilon(
Math.abs(Cartesian3_default.dot(forwardProjection, backwardProjection)),
1,
Math_default.EPSILON7
);
if (doCorner) {
cornerDirection = Cartesian3_default.cross(
cornerDirection,
normal2,
cornerDirection
);
cornerDirection = Cartesian3_default.cross(
normal2,
cornerDirection,
cornerDirection
);
cornerDirection = Cartesian3_default.normalize(cornerDirection, cornerDirection);
const scalar = width / Math.max(
0.25,
Cartesian3_default.magnitude(
Cartesian3_default.cross(cornerDirection, backward, scratch12)
)
);
const leftIsOutside = PolylineVolumeGeometryLibrary_default.angleIsGreaterThanPi(
forward,
backward,
position,
ellipsoid
);
cornerDirection = Cartesian3_default.multiplyByScalar(
cornerDirection,
scalar,
cornerDirection
);
if (leftIsOutside) {
rightPos = Cartesian3_default.add(position, cornerDirection, rightPos);
center = Cartesian3_default.add(
rightPos,
Cartesian3_default.multiplyByScalar(left, width, center),
center
);
leftPos = Cartesian3_default.add(
rightPos,
Cartesian3_default.multiplyByScalar(left, width * 2, leftPos),
leftPos
);
scaleArray2[0] = Cartesian3_default.clone(previousPos, scaleArray2[0]);
scaleArray2[1] = Cartesian3_default.clone(center, scaleArray2[1]);
subdividedPositions = PolylinePipeline_default.generateArc({
positions: scaleArray2,
granularity,
ellipsoid
});
calculatedPositions = addShiftedPositions(
subdividedPositions,
left,
width,
calculatedPositions
);
if (saveAttributes) {
calculatedLefts.push(left.x, left.y, left.z);
calculatedNormals.push(normal2.x, normal2.y, normal2.z);
}
startPoint = Cartesian3_default.clone(leftPos, startPoint);
left = Cartesian3_default.normalize(
Cartesian3_default.cross(normal2, forward, left),
left
);
leftPos = Cartesian3_default.add(
rightPos,
Cartesian3_default.multiplyByScalar(left, width * 2, leftPos),
leftPos
);
previousPos = Cartesian3_default.add(
rightPos,
Cartesian3_default.multiplyByScalar(left, width, previousPos),
previousPos
);
if (cornerType === CornerType_default.ROUNDED || cornerType === CornerType_default.BEVELED) {
corners.push({
leftPositions: computeRoundCorner2(
rightPos,
startPoint,
leftPos,
cornerType,
leftIsOutside
)
});
} else {
corners.push({
leftPositions: computeMiteredCorner(
position,
Cartesian3_default.negate(cornerDirection, cornerDirection),
leftPos,
leftIsOutside
)
});
}
} else {
leftPos = Cartesian3_default.add(position, cornerDirection, leftPos);
center = Cartesian3_default.add(
leftPos,
Cartesian3_default.negate(
Cartesian3_default.multiplyByScalar(left, width, center),
center
),
center
);
rightPos = Cartesian3_default.add(
leftPos,
Cartesian3_default.negate(
Cartesian3_default.multiplyByScalar(left, width * 2, rightPos),
rightPos
),
rightPos
);
scaleArray2[0] = Cartesian3_default.clone(previousPos, scaleArray2[0]);
scaleArray2[1] = Cartesian3_default.clone(center, scaleArray2[1]);
subdividedPositions = PolylinePipeline_default.generateArc({
positions: scaleArray2,
granularity,
ellipsoid
});
calculatedPositions = addShiftedPositions(
subdividedPositions,
left,
width,
calculatedPositions
);
if (saveAttributes) {
calculatedLefts.push(left.x, left.y, left.z);
calculatedNormals.push(normal2.x, normal2.y, normal2.z);
}
startPoint = Cartesian3_default.clone(rightPos, startPoint);
left = Cartesian3_default.normalize(
Cartesian3_default.cross(normal2, forward, left),
left
);
rightPos = Cartesian3_default.add(
leftPos,
Cartesian3_default.negate(
Cartesian3_default.multiplyByScalar(left, width * 2, rightPos),
rightPos
),
rightPos
);
previousPos = Cartesian3_default.add(
leftPos,
Cartesian3_default.negate(
Cartesian3_default.multiplyByScalar(left, width, previousPos),
previousPos
),
previousPos
);
if (cornerType === CornerType_default.ROUNDED || cornerType === CornerType_default.BEVELED) {
corners.push({
rightPositions: computeRoundCorner2(
leftPos,
startPoint,
rightPos,
cornerType,
leftIsOutside
)
});
} else {
corners.push({
rightPositions: computeMiteredCorner(
position,
cornerDirection,
rightPos,
leftIsOutside
)
});
}
}
backward = Cartesian3_default.negate(forward, backward);
}
position = nextPosition;
}
normal2 = ellipsoid.geodeticSurfaceNormal(position, normal2);
scaleArray2[0] = Cartesian3_default.clone(previousPos, scaleArray2[0]);
scaleArray2[1] = Cartesian3_default.clone(position, scaleArray2[1]);
subdividedPositions = PolylinePipeline_default.generateArc({
positions: scaleArray2,
granularity,
ellipsoid
});
calculatedPositions = addShiftedPositions(
subdividedPositions,
left,
width,
calculatedPositions
);
if (saveAttributes) {
calculatedLefts.push(left.x, left.y, left.z);
calculatedNormals.push(normal2.x, normal2.y, normal2.z);
}
let endPositions;
if (cornerType === CornerType_default.ROUNDED) {
endPositions = addEndCaps(calculatedPositions);
}
return {
positions: calculatedPositions,
corners,
lefts: calculatedLefts,
normals: calculatedNormals,
endPositions
};
};
var CorridorGeometryLibrary_default = CorridorGeometryLibrary;
// Source/Core/CorridorGeometry.js
var cartesian12 = new Cartesian3_default();
var cartesian22 = new Cartesian3_default();
var cartesian32 = new Cartesian3_default();
var cartesian42 = new Cartesian3_default();
var cartesian52 = new Cartesian3_default();
var cartesian62 = new Cartesian3_default();
var scratch13 = new Cartesian3_default();
var scratch23 = new Cartesian3_default();
function scaleToSurface2(positions, ellipsoid) {
for (let i = 0; i < positions.length; i++) {
positions[i] = ellipsoid.scaleToGeodeticSurface(positions[i], positions[i]);
}
return positions;
}
function addNormals(attr, normal2, left, front, back, vertexFormat) {
const normals = attr.normals;
const tangents = attr.tangents;
const bitangents = attr.bitangents;
const forward = Cartesian3_default.normalize(
Cartesian3_default.cross(left, normal2, scratch13),
scratch13
);
if (vertexFormat.normal) {
CorridorGeometryLibrary_default.addAttribute(normals, normal2, front, back);
}
if (vertexFormat.tangent) {
CorridorGeometryLibrary_default.addAttribute(tangents, forward, front, back);
}
if (vertexFormat.bitangent) {
CorridorGeometryLibrary_default.addAttribute(bitangents, left, front, back);
}
}
function combine2(computedPositions, vertexFormat, ellipsoid) {
const positions = computedPositions.positions;
const corners = computedPositions.corners;
const endPositions = computedPositions.endPositions;
const computedLefts = computedPositions.lefts;
const computedNormals = computedPositions.normals;
const attributes = new GeometryAttributes_default();
let corner;
let leftCount = 0;
let rightCount = 0;
let i;
let indicesLength = 0;
let length3;
for (i = 0; i < positions.length; i += 2) {
length3 = positions[i].length - 3;
leftCount += length3;
indicesLength += length3 * 2;
rightCount += positions[i + 1].length - 3;
}
leftCount += 3;
rightCount += 3;
for (i = 0; i < corners.length; i++) {
corner = corners[i];
const leftSide = corners[i].leftPositions;
if (defined_default(leftSide)) {
length3 = leftSide.length;
leftCount += length3;
indicesLength += length3;
} else {
length3 = corners[i].rightPositions.length;
rightCount += length3;
indicesLength += length3;
}
}
const addEndPositions = defined_default(endPositions);
let endPositionLength;
if (addEndPositions) {
endPositionLength = endPositions[0].length - 3;
leftCount += endPositionLength;
rightCount += endPositionLength;
endPositionLength /= 3;
indicesLength += endPositionLength * 6;
}
const size = leftCount + rightCount;
const finalPositions = new Float64Array(size);
const normals = vertexFormat.normal ? new Float32Array(size) : void 0;
const tangents = vertexFormat.tangent ? new Float32Array(size) : void 0;
const bitangents = vertexFormat.bitangent ? new Float32Array(size) : void 0;
const attr = {
normals,
tangents,
bitangents
};
let front = 0;
let back = size - 1;
let UL, LL, UR, LR;
let normal2 = cartesian12;
let left = cartesian22;
let rightPos, leftPos;
const halfLength = endPositionLength / 2;
const indices2 = IndexDatatype_default.createTypedArray(size / 3, indicesLength);
let index = 0;
if (addEndPositions) {
leftPos = cartesian32;
rightPos = cartesian42;
const firstEndPositions = endPositions[0];
normal2 = Cartesian3_default.fromArray(computedNormals, 0, normal2);
left = Cartesian3_default.fromArray(computedLefts, 0, left);
for (i = 0; i < halfLength; i++) {
leftPos = Cartesian3_default.fromArray(
firstEndPositions,
(halfLength - 1 - i) * 3,
leftPos
);
rightPos = Cartesian3_default.fromArray(
firstEndPositions,
(halfLength + i) * 3,
rightPos
);
CorridorGeometryLibrary_default.addAttribute(finalPositions, rightPos, front);
CorridorGeometryLibrary_default.addAttribute(
finalPositions,
leftPos,
void 0,
back
);
addNormals(attr, normal2, left, front, back, vertexFormat);
LL = front / 3;
LR = LL + 1;
UL = (back - 2) / 3;
UR = UL - 1;
indices2[index++] = UL;
indices2[index++] = LL;
indices2[index++] = UR;
indices2[index++] = UR;
indices2[index++] = LL;
indices2[index++] = LR;
front += 3;
back -= 3;
}
}
let posIndex = 0;
let compIndex = 0;
let rightEdge = positions[posIndex++];
let leftEdge = positions[posIndex++];
finalPositions.set(rightEdge, front);
finalPositions.set(leftEdge, back - leftEdge.length + 1);
left = Cartesian3_default.fromArray(computedLefts, compIndex, left);
let rightNormal;
let leftNormal;
length3 = leftEdge.length - 3;
for (i = 0; i < length3; i += 3) {
rightNormal = ellipsoid.geodeticSurfaceNormal(
Cartesian3_default.fromArray(rightEdge, i, scratch13),
scratch13
);
leftNormal = ellipsoid.geodeticSurfaceNormal(
Cartesian3_default.fromArray(leftEdge, length3 - i, scratch23),
scratch23
);
normal2 = Cartesian3_default.normalize(
Cartesian3_default.add(rightNormal, leftNormal, normal2),
normal2
);
addNormals(attr, normal2, left, front, back, vertexFormat);
LL = front / 3;
LR = LL + 1;
UL = (back - 2) / 3;
UR = UL - 1;
indices2[index++] = UL;
indices2[index++] = LL;
indices2[index++] = UR;
indices2[index++] = UR;
indices2[index++] = LL;
indices2[index++] = LR;
front += 3;
back -= 3;
}
rightNormal = ellipsoid.geodeticSurfaceNormal(
Cartesian3_default.fromArray(rightEdge, length3, scratch13),
scratch13
);
leftNormal = ellipsoid.geodeticSurfaceNormal(
Cartesian3_default.fromArray(leftEdge, length3, scratch23),
scratch23
);
normal2 = Cartesian3_default.normalize(
Cartesian3_default.add(rightNormal, leftNormal, normal2),
normal2
);
compIndex += 3;
for (i = 0; i < corners.length; i++) {
let j;
corner = corners[i];
const l = corner.leftPositions;
const r = corner.rightPositions;
let pivot;
let start;
let outsidePoint = cartesian62;
let previousPoint = cartesian32;
let nextPoint = cartesian42;
normal2 = Cartesian3_default.fromArray(computedNormals, compIndex, normal2);
if (defined_default(l)) {
addNormals(attr, normal2, left, void 0, back, vertexFormat);
back -= 3;
pivot = LR;
start = UR;
for (j = 0; j < l.length / 3; j++) {
outsidePoint = Cartesian3_default.fromArray(l, j * 3, outsidePoint);
indices2[index++] = pivot;
indices2[index++] = start - j - 1;
indices2[index++] = start - j;
CorridorGeometryLibrary_default.addAttribute(
finalPositions,
outsidePoint,
void 0,
back
);
previousPoint = Cartesian3_default.fromArray(
finalPositions,
(start - j - 1) * 3,
previousPoint
);
nextPoint = Cartesian3_default.fromArray(finalPositions, pivot * 3, nextPoint);
left = Cartesian3_default.normalize(
Cartesian3_default.subtract(previousPoint, nextPoint, left),
left
);
addNormals(attr, normal2, left, void 0, back, vertexFormat);
back -= 3;
}
outsidePoint = Cartesian3_default.fromArray(
finalPositions,
pivot * 3,
outsidePoint
);
previousPoint = Cartesian3_default.subtract(
Cartesian3_default.fromArray(finalPositions, start * 3, previousPoint),
outsidePoint,
previousPoint
);
nextPoint = Cartesian3_default.subtract(
Cartesian3_default.fromArray(finalPositions, (start - j) * 3, nextPoint),
outsidePoint,
nextPoint
);
left = Cartesian3_default.normalize(
Cartesian3_default.add(previousPoint, nextPoint, left),
left
);
addNormals(attr, normal2, left, front, void 0, vertexFormat);
front += 3;
} else {
addNormals(attr, normal2, left, front, void 0, vertexFormat);
front += 3;
pivot = UR;
start = LR;
for (j = 0; j < r.length / 3; j++) {
outsidePoint = Cartesian3_default.fromArray(r, j * 3, outsidePoint);
indices2[index++] = pivot;
indices2[index++] = start + j;
indices2[index++] = start + j + 1;
CorridorGeometryLibrary_default.addAttribute(
finalPositions,
outsidePoint,
front
);
previousPoint = Cartesian3_default.fromArray(
finalPositions,
pivot * 3,
previousPoint
);
nextPoint = Cartesian3_default.fromArray(
finalPositions,
(start + j) * 3,
nextPoint
);
left = Cartesian3_default.normalize(
Cartesian3_default.subtract(previousPoint, nextPoint, left),
left
);
addNormals(attr, normal2, left, front, void 0, vertexFormat);
front += 3;
}
outsidePoint = Cartesian3_default.fromArray(
finalPositions,
pivot * 3,
outsidePoint
);
previousPoint = Cartesian3_default.subtract(
Cartesian3_default.fromArray(finalPositions, (start + j) * 3, previousPoint),
outsidePoint,
previousPoint
);
nextPoint = Cartesian3_default.subtract(
Cartesian3_default.fromArray(finalPositions, start * 3, nextPoint),
outsidePoint,
nextPoint
);
left = Cartesian3_default.normalize(
Cartesian3_default.negate(Cartesian3_default.add(nextPoint, previousPoint, left), left),
left
);
addNormals(attr, normal2, left, void 0, back, vertexFormat);
back -= 3;
}
rightEdge = positions[posIndex++];
leftEdge = positions[posIndex++];
rightEdge.splice(0, 3);
leftEdge.splice(leftEdge.length - 3, 3);
finalPositions.set(rightEdge, front);
finalPositions.set(leftEdge, back - leftEdge.length + 1);
length3 = leftEdge.length - 3;
compIndex += 3;
left = Cartesian3_default.fromArray(computedLefts, compIndex, left);
for (j = 0; j < leftEdge.length; j += 3) {
rightNormal = ellipsoid.geodeticSurfaceNormal(
Cartesian3_default.fromArray(rightEdge, j, scratch13),
scratch13
);
leftNormal = ellipsoid.geodeticSurfaceNormal(
Cartesian3_default.fromArray(leftEdge, length3 - j, scratch23),
scratch23
);
normal2 = Cartesian3_default.normalize(
Cartesian3_default.add(rightNormal, leftNormal, normal2),
normal2
);
addNormals(attr, normal2, left, front, back, vertexFormat);
LR = front / 3;
LL = LR - 1;
UR = (back - 2) / 3;
UL = UR + 1;
indices2[index++] = UL;
indices2[index++] = LL;
indices2[index++] = UR;
indices2[index++] = UR;
indices2[index++] = LL;
indices2[index++] = LR;
front += 3;
back -= 3;
}
front -= 3;
back += 3;
}
normal2 = Cartesian3_default.fromArray(
computedNormals,
computedNormals.length - 3,
normal2
);
addNormals(attr, normal2, left, front, back, vertexFormat);
if (addEndPositions) {
front += 3;
back -= 3;
leftPos = cartesian32;
rightPos = cartesian42;
const lastEndPositions = endPositions[1];
for (i = 0; i < halfLength; i++) {
leftPos = Cartesian3_default.fromArray(
lastEndPositions,
(endPositionLength - i - 1) * 3,
leftPos
);
rightPos = Cartesian3_default.fromArray(lastEndPositions, i * 3, rightPos);
CorridorGeometryLibrary_default.addAttribute(
finalPositions,
leftPos,
void 0,
back
);
CorridorGeometryLibrary_default.addAttribute(finalPositions, rightPos, front);
addNormals(attr, normal2, left, front, back, vertexFormat);
LR = front / 3;
LL = LR - 1;
UR = (back - 2) / 3;
UL = UR + 1;
indices2[index++] = UL;
indices2[index++] = LL;
indices2[index++] = UR;
indices2[index++] = UR;
indices2[index++] = LL;
indices2[index++] = LR;
front += 3;
back -= 3;
}
}
attributes.position = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.DOUBLE,
componentsPerAttribute: 3,
values: finalPositions
});
if (vertexFormat.st) {
const st = new Float32Array(size / 3 * 2);
let rightSt;
let leftSt;
let stIndex = 0;
if (addEndPositions) {
leftCount /= 3;
rightCount /= 3;
const theta = Math.PI / (endPositionLength + 1);
leftSt = 1 / (leftCount - endPositionLength + 1);
rightSt = 1 / (rightCount - endPositionLength + 1);
let a3;
const halfEndPos = endPositionLength / 2;
for (i = halfEndPos + 1; i < endPositionLength + 1; i++) {
a3 = Math_default.PI_OVER_TWO + theta * i;
st[stIndex++] = rightSt * (1 + Math.cos(a3));
st[stIndex++] = 0.5 * (1 + Math.sin(a3));
}
for (i = 1; i < rightCount - endPositionLength + 1; i++) {
st[stIndex++] = i * rightSt;
st[stIndex++] = 0;
}
for (i = endPositionLength; i > halfEndPos; i--) {
a3 = Math_default.PI_OVER_TWO - i * theta;
st[stIndex++] = 1 - rightSt * (1 + Math.cos(a3));
st[stIndex++] = 0.5 * (1 + Math.sin(a3));
}
for (i = halfEndPos; i > 0; i--) {
a3 = Math_default.PI_OVER_TWO - theta * i;
st[stIndex++] = 1 - leftSt * (1 + Math.cos(a3));
st[stIndex++] = 0.5 * (1 + Math.sin(a3));
}
for (i = leftCount - endPositionLength; i > 0; i--) {
st[stIndex++] = i * leftSt;
st[stIndex++] = 1;
}
for (i = 1; i < halfEndPos + 1; i++) {
a3 = Math_default.PI_OVER_TWO + theta * i;
st[stIndex++] = leftSt * (1 + Math.cos(a3));
st[stIndex++] = 0.5 * (1 + Math.sin(a3));
}
} else {
leftCount /= 3;
rightCount /= 3;
leftSt = 1 / (leftCount - 1);
rightSt = 1 / (rightCount - 1);
for (i = 0; i < rightCount; i++) {
st[stIndex++] = i * rightSt;
st[stIndex++] = 0;
}
for (i = leftCount; i > 0; i--) {
st[stIndex++] = (i - 1) * leftSt;
st[stIndex++] = 1;
}
}
attributes.st = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.FLOAT,
componentsPerAttribute: 2,
values: st
});
}
if (vertexFormat.normal) {
attributes.normal = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.FLOAT,
componentsPerAttribute: 3,
values: attr.normals
});
}
if (vertexFormat.tangent) {
attributes.tangent = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.FLOAT,
componentsPerAttribute: 3,
values: attr.tangents
});
}
if (vertexFormat.bitangent) {
attributes.bitangent = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.FLOAT,
componentsPerAttribute: 3,
values: attr.bitangents
});
}
return {
attributes,
indices: indices2
};
}
function extrudedAttributes(attributes, vertexFormat) {
if (!vertexFormat.normal && !vertexFormat.tangent && !vertexFormat.bitangent && !vertexFormat.st) {
return attributes;
}
const positions = attributes.position.values;
let topNormals;
let topBitangents;
if (vertexFormat.normal || vertexFormat.bitangent) {
topNormals = attributes.normal.values;
topBitangents = attributes.bitangent.values;
}
const size = attributes.position.values.length / 18;
const threeSize = size * 3;
const twoSize = size * 2;
const sixSize = threeSize * 2;
let i;
if (vertexFormat.normal || vertexFormat.bitangent || vertexFormat.tangent) {
const normals = vertexFormat.normal ? new Float32Array(threeSize * 6) : void 0;
const tangents = vertexFormat.tangent ? new Float32Array(threeSize * 6) : void 0;
const bitangents = vertexFormat.bitangent ? new Float32Array(threeSize * 6) : void 0;
let topPosition = cartesian12;
let bottomPosition = cartesian22;
let previousPosition = cartesian32;
let normal2 = cartesian42;
let tangent = cartesian52;
let bitangent = cartesian62;
let attrIndex = sixSize;
for (i = 0; i < threeSize; i += 3) {
const attrIndexOffset = attrIndex + sixSize;
topPosition = Cartesian3_default.fromArray(positions, i, topPosition);
bottomPosition = Cartesian3_default.fromArray(
positions,
i + threeSize,
bottomPosition
);
previousPosition = Cartesian3_default.fromArray(
positions,
(i + 3) % threeSize,
previousPosition
);
bottomPosition = Cartesian3_default.subtract(
bottomPosition,
topPosition,
bottomPosition
);
previousPosition = Cartesian3_default.subtract(
previousPosition,
topPosition,
previousPosition
);
normal2 = Cartesian3_default.normalize(
Cartesian3_default.cross(bottomPosition, previousPosition, normal2),
normal2
);
if (vertexFormat.normal) {
CorridorGeometryLibrary_default.addAttribute(normals, normal2, attrIndexOffset);
CorridorGeometryLibrary_default.addAttribute(
normals,
normal2,
attrIndexOffset + 3
);
CorridorGeometryLibrary_default.addAttribute(normals, normal2, attrIndex);
CorridorGeometryLibrary_default.addAttribute(normals, normal2, attrIndex + 3);
}
if (vertexFormat.tangent || vertexFormat.bitangent) {
bitangent = Cartesian3_default.fromArray(topNormals, i, bitangent);
if (vertexFormat.bitangent) {
CorridorGeometryLibrary_default.addAttribute(
bitangents,
bitangent,
attrIndexOffset
);
CorridorGeometryLibrary_default.addAttribute(
bitangents,
bitangent,
attrIndexOffset + 3
);
CorridorGeometryLibrary_default.addAttribute(
bitangents,
bitangent,
attrIndex
);
CorridorGeometryLibrary_default.addAttribute(
bitangents,
bitangent,
attrIndex + 3
);
}
if (vertexFormat.tangent) {
tangent = Cartesian3_default.normalize(
Cartesian3_default.cross(bitangent, normal2, tangent),
tangent
);
CorridorGeometryLibrary_default.addAttribute(
tangents,
tangent,
attrIndexOffset
);
CorridorGeometryLibrary_default.addAttribute(
tangents,
tangent,
attrIndexOffset + 3
);
CorridorGeometryLibrary_default.addAttribute(tangents, tangent, attrIndex);
CorridorGeometryLibrary_default.addAttribute(
tangents,
tangent,
attrIndex + 3
);
}
}
attrIndex += 6;
}
if (vertexFormat.normal) {
normals.set(topNormals);
for (i = 0; i < threeSize; i += 3) {
normals[i + threeSize] = -topNormals[i];
normals[i + threeSize + 1] = -topNormals[i + 1];
normals[i + threeSize + 2] = -topNormals[i + 2];
}
attributes.normal.values = normals;
} else {
attributes.normal = void 0;
}
if (vertexFormat.bitangent) {
bitangents.set(topBitangents);
bitangents.set(topBitangents, threeSize);
attributes.bitangent.values = bitangents;
} else {
attributes.bitangent = void 0;
}
if (vertexFormat.tangent) {
const topTangents = attributes.tangent.values;
tangents.set(topTangents);
tangents.set(topTangents, threeSize);
attributes.tangent.values = tangents;
}
}
if (vertexFormat.st) {
const topSt = attributes.st.values;
const st = new Float32Array(twoSize * 6);
st.set(topSt);
st.set(topSt, twoSize);
let index = twoSize * 2;
for (let j = 0; j < 2; j++) {
st[index++] = topSt[0];
st[index++] = topSt[1];
for (i = 2; i < twoSize; i += 2) {
const s = topSt[i];
const t = topSt[i + 1];
st[index++] = s;
st[index++] = t;
st[index++] = s;
st[index++] = t;
}
st[index++] = topSt[0];
st[index++] = topSt[1];
}
attributes.st.values = st;
}
return attributes;
}
function addWallPositions(positions, index, wallPositions) {
wallPositions[index++] = positions[0];
wallPositions[index++] = positions[1];
wallPositions[index++] = positions[2];
for (let i = 3; i < positions.length; i += 3) {
const x = positions[i];
const y = positions[i + 1];
const z = positions[i + 2];
wallPositions[index++] = x;
wallPositions[index++] = y;
wallPositions[index++] = z;
wallPositions[index++] = x;
wallPositions[index++] = y;
wallPositions[index++] = z;
}
wallPositions[index++] = positions[0];
wallPositions[index++] = positions[1];
wallPositions[index++] = positions[2];
return wallPositions;
}
function computePositionsExtruded(params, vertexFormat) {
const topVertexFormat = new VertexFormat_default({
position: vertexFormat.position,
normal: vertexFormat.normal || vertexFormat.bitangent || params.shadowVolume,
tangent: vertexFormat.tangent,
bitangent: vertexFormat.normal || vertexFormat.bitangent,
st: vertexFormat.st
});
const ellipsoid = params.ellipsoid;
const computedPositions = CorridorGeometryLibrary_default.computePositions(params);
const attr = combine2(computedPositions, topVertexFormat, ellipsoid);
const height = params.height;
const extrudedHeight = params.extrudedHeight;
let attributes = attr.attributes;
const indices2 = attr.indices;
let positions = attributes.position.values;
let length3 = positions.length;
const newPositions = new Float64Array(length3 * 6);
let extrudedPositions = new Float64Array(length3);
extrudedPositions.set(positions);
let wallPositions = new Float64Array(length3 * 4);
positions = PolygonPipeline_default.scaleToGeodeticHeight(
positions,
height,
ellipsoid
);
wallPositions = addWallPositions(positions, 0, wallPositions);
extrudedPositions = PolygonPipeline_default.scaleToGeodeticHeight(
extrudedPositions,
extrudedHeight,
ellipsoid
);
wallPositions = addWallPositions(
extrudedPositions,
length3 * 2,
wallPositions
);
newPositions.set(positions);
newPositions.set(extrudedPositions, length3);
newPositions.set(wallPositions, length3 * 2);
attributes.position.values = newPositions;
attributes = extrudedAttributes(attributes, vertexFormat);
let i;
const size = length3 / 3;
if (params.shadowVolume) {
const topNormals = attributes.normal.values;
length3 = topNormals.length;
let extrudeNormals = new Float32Array(length3 * 6);
for (i = 0; i < length3; i++) {
topNormals[i] = -topNormals[i];
}
extrudeNormals.set(topNormals, length3);
extrudeNormals = addWallPositions(topNormals, length3 * 4, extrudeNormals);
attributes.extrudeDirection = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.FLOAT,
componentsPerAttribute: 3,
values: extrudeNormals
});
if (!vertexFormat.normal) {
attributes.normal = void 0;
}
}
if (defined_default(params.offsetAttribute)) {
let applyOffset = new Uint8Array(size * 6);
if (params.offsetAttribute === GeometryOffsetAttribute_default.TOP) {
applyOffset = applyOffset.fill(1, 0, size).fill(1, size * 2, size * 4);
} else {
const applyOffsetValue = params.offsetAttribute === GeometryOffsetAttribute_default.NONE ? 0 : 1;
applyOffset = applyOffset.fill(applyOffsetValue);
}
attributes.applyOffset = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.UNSIGNED_BYTE,
componentsPerAttribute: 1,
values: applyOffset
});
}
const iLength = indices2.length;
const twoSize = size + size;
const newIndices = IndexDatatype_default.createTypedArray(
newPositions.length / 3,
iLength * 2 + twoSize * 3
);
newIndices.set(indices2);
let index = iLength;
for (i = 0; i < iLength; i += 3) {
const v02 = indices2[i];
const v13 = indices2[i + 1];
const v23 = indices2[i + 2];
newIndices[index++] = v23 + size;
newIndices[index++] = v13 + size;
newIndices[index++] = v02 + size;
}
let UL, LL, UR, LR;
for (i = 0; i < twoSize; i += 2) {
UL = i + twoSize;
LL = UL + twoSize;
UR = UL + 1;
LR = LL + 1;
newIndices[index++] = UL;
newIndices[index++] = LL;
newIndices[index++] = UR;
newIndices[index++] = UR;
newIndices[index++] = LL;
newIndices[index++] = LR;
}
return {
attributes,
indices: newIndices
};
}
var scratchCartesian17 = new Cartesian3_default();
var scratchCartesian28 = new Cartesian3_default();
var scratchCartographic4 = new Cartographic_default();
function computeOffsetPoints(position1, position2, ellipsoid, halfWidth, min3, max3) {
const direction2 = Cartesian3_default.subtract(
position2,
position1,
scratchCartesian17
);
Cartesian3_default.normalize(direction2, direction2);
const normal2 = ellipsoid.geodeticSurfaceNormal(position1, scratchCartesian28);
const offsetDirection = Cartesian3_default.cross(
direction2,
normal2,
scratchCartesian17
);
Cartesian3_default.multiplyByScalar(offsetDirection, halfWidth, offsetDirection);
let minLat = min3.latitude;
let minLon = min3.longitude;
let maxLat = max3.latitude;
let maxLon = max3.longitude;
Cartesian3_default.add(position1, offsetDirection, scratchCartesian28);
ellipsoid.cartesianToCartographic(scratchCartesian28, scratchCartographic4);
let lat = scratchCartographic4.latitude;
let lon = scratchCartographic4.longitude;
minLat = Math.min(minLat, lat);
minLon = Math.min(minLon, lon);
maxLat = Math.max(maxLat, lat);
maxLon = Math.max(maxLon, lon);
Cartesian3_default.subtract(position1, offsetDirection, scratchCartesian28);
ellipsoid.cartesianToCartographic(scratchCartesian28, scratchCartographic4);
lat = scratchCartographic4.latitude;
lon = scratchCartographic4.longitude;
minLat = Math.min(minLat, lat);
minLon = Math.min(minLon, lon);
maxLat = Math.max(maxLat, lat);
maxLon = Math.max(maxLon, lon);
min3.latitude = minLat;
min3.longitude = minLon;
max3.latitude = maxLat;
max3.longitude = maxLon;
}
var scratchCartesianOffset = new Cartesian3_default();
var scratchCartesianEnds = new Cartesian3_default();
var scratchCartographicMin = new Cartographic_default();
var scratchCartographicMax = new Cartographic_default();
function computeRectangle2(positions, ellipsoid, width, cornerType, result) {
positions = scaleToSurface2(positions, ellipsoid);
const cleanPositions = arrayRemoveDuplicates_default(
positions,
Cartesian3_default.equalsEpsilon
);
const length3 = cleanPositions.length;
if (length3 < 2 || width <= 0) {
return new Rectangle_default();
}
const halfWidth = width * 0.5;
scratchCartographicMin.latitude = Number.POSITIVE_INFINITY;
scratchCartographicMin.longitude = Number.POSITIVE_INFINITY;
scratchCartographicMax.latitude = Number.NEGATIVE_INFINITY;
scratchCartographicMax.longitude = Number.NEGATIVE_INFINITY;
let lat, lon;
if (cornerType === CornerType_default.ROUNDED) {
const first = cleanPositions[0];
Cartesian3_default.subtract(first, cleanPositions[1], scratchCartesianOffset);
Cartesian3_default.normalize(scratchCartesianOffset, scratchCartesianOffset);
Cartesian3_default.multiplyByScalar(
scratchCartesianOffset,
halfWidth,
scratchCartesianOffset
);
Cartesian3_default.add(first, scratchCartesianOffset, scratchCartesianEnds);
ellipsoid.cartesianToCartographic(
scratchCartesianEnds,
scratchCartographic4
);
lat = scratchCartographic4.latitude;
lon = scratchCartographic4.longitude;
scratchCartographicMin.latitude = Math.min(
scratchCartographicMin.latitude,
lat
);
scratchCartographicMin.longitude = Math.min(
scratchCartographicMin.longitude,
lon
);
scratchCartographicMax.latitude = Math.max(
scratchCartographicMax.latitude,
lat
);
scratchCartographicMax.longitude = Math.max(
scratchCartographicMax.longitude,
lon
);
}
for (let i = 0; i < length3 - 1; ++i) {
computeOffsetPoints(
cleanPositions[i],
cleanPositions[i + 1],
ellipsoid,
halfWidth,
scratchCartographicMin,
scratchCartographicMax
);
}
const last = cleanPositions[length3 - 1];
Cartesian3_default.subtract(last, cleanPositions[length3 - 2], scratchCartesianOffset);
Cartesian3_default.normalize(scratchCartesianOffset, scratchCartesianOffset);
Cartesian3_default.multiplyByScalar(
scratchCartesianOffset,
halfWidth,
scratchCartesianOffset
);
Cartesian3_default.add(last, scratchCartesianOffset, scratchCartesianEnds);
computeOffsetPoints(
last,
scratchCartesianEnds,
ellipsoid,
halfWidth,
scratchCartographicMin,
scratchCartographicMax
);
if (cornerType === CornerType_default.ROUNDED) {
ellipsoid.cartesianToCartographic(
scratchCartesianEnds,
scratchCartographic4
);
lat = scratchCartographic4.latitude;
lon = scratchCartographic4.longitude;
scratchCartographicMin.latitude = Math.min(
scratchCartographicMin.latitude,
lat
);
scratchCartographicMin.longitude = Math.min(
scratchCartographicMin.longitude,
lon
);
scratchCartographicMax.latitude = Math.max(
scratchCartographicMax.latitude,
lat
);
scratchCartographicMax.longitude = Math.max(
scratchCartographicMax.longitude,
lon
);
}
const rectangle = defined_default(result) ? result : new Rectangle_default();
rectangle.north = scratchCartographicMax.latitude;
rectangle.south = scratchCartographicMin.latitude;
rectangle.east = scratchCartographicMax.longitude;
rectangle.west = scratchCartographicMin.longitude;
return rectangle;
}
function CorridorGeometry(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
const positions = options.positions;
const width = options.width;
Check_default.defined("options.positions", positions);
Check_default.defined("options.width", width);
const height = defaultValue_default(options.height, 0);
const extrudedHeight = defaultValue_default(options.extrudedHeight, height);
this._positions = positions;
this._ellipsoid = Ellipsoid_default.clone(
defaultValue_default(options.ellipsoid, Ellipsoid_default.WGS84)
);
this._vertexFormat = VertexFormat_default.clone(
defaultValue_default(options.vertexFormat, VertexFormat_default.DEFAULT)
);
this._width = width;
this._height = Math.max(height, extrudedHeight);
this._extrudedHeight = Math.min(height, extrudedHeight);
this._cornerType = defaultValue_default(options.cornerType, CornerType_default.ROUNDED);
this._granularity = defaultValue_default(
options.granularity,
Math_default.RADIANS_PER_DEGREE
);
this._shadowVolume = defaultValue_default(options.shadowVolume, false);
this._workerName = "createCorridorGeometry";
this._offsetAttribute = options.offsetAttribute;
this._rectangle = void 0;
this.packedLength = 1 + positions.length * Cartesian3_default.packedLength + Ellipsoid_default.packedLength + VertexFormat_default.packedLength + 7;
}
CorridorGeometry.pack = function(value, array, startingIndex) {
Check_default.defined("value", value);
Check_default.defined("array", array);
startingIndex = defaultValue_default(startingIndex, 0);
const positions = value._positions;
const length3 = positions.length;
array[startingIndex++] = length3;
for (let i = 0; i < length3; ++i, startingIndex += Cartesian3_default.packedLength) {
Cartesian3_default.pack(positions[i], array, startingIndex);
}
Ellipsoid_default.pack(value._ellipsoid, array, startingIndex);
startingIndex += Ellipsoid_default.packedLength;
VertexFormat_default.pack(value._vertexFormat, array, startingIndex);
startingIndex += VertexFormat_default.packedLength;
array[startingIndex++] = value._width;
array[startingIndex++] = value._height;
array[startingIndex++] = value._extrudedHeight;
array[startingIndex++] = value._cornerType;
array[startingIndex++] = value._granularity;
array[startingIndex++] = value._shadowVolume ? 1 : 0;
array[startingIndex] = defaultValue_default(value._offsetAttribute, -1);
return array;
};
var scratchEllipsoid4 = Ellipsoid_default.clone(Ellipsoid_default.UNIT_SPHERE);
var scratchVertexFormat4 = new VertexFormat_default();
var scratchOptions9 = {
positions: void 0,
ellipsoid: scratchEllipsoid4,
vertexFormat: scratchVertexFormat4,
width: void 0,
height: void 0,
extrudedHeight: void 0,
cornerType: void 0,
granularity: void 0,
shadowVolume: void 0,
offsetAttribute: void 0
};
CorridorGeometry.unpack = function(array, startingIndex, result) {
Check_default.defined("array", array);
startingIndex = defaultValue_default(startingIndex, 0);
const length3 = array[startingIndex++];
const positions = new Array(length3);
for (let i = 0; i < length3; ++i, startingIndex += Cartesian3_default.packedLength) {
positions[i] = Cartesian3_default.unpack(array, startingIndex);
}
const ellipsoid = Ellipsoid_default.unpack(array, startingIndex, scratchEllipsoid4);
startingIndex += Ellipsoid_default.packedLength;
const vertexFormat = VertexFormat_default.unpack(
array,
startingIndex,
scratchVertexFormat4
);
startingIndex += VertexFormat_default.packedLength;
const width = array[startingIndex++];
const height = array[startingIndex++];
const extrudedHeight = array[startingIndex++];
const cornerType = array[startingIndex++];
const granularity = array[startingIndex++];
const shadowVolume = array[startingIndex++] === 1;
const offsetAttribute = array[startingIndex];
if (!defined_default(result)) {
scratchOptions9.positions = positions;
scratchOptions9.width = width;
scratchOptions9.height = height;
scratchOptions9.extrudedHeight = extrudedHeight;
scratchOptions9.cornerType = cornerType;
scratchOptions9.granularity = granularity;
scratchOptions9.shadowVolume = shadowVolume;
scratchOptions9.offsetAttribute = offsetAttribute === -1 ? void 0 : offsetAttribute;
return new CorridorGeometry(scratchOptions9);
}
result._positions = positions;
result._ellipsoid = Ellipsoid_default.clone(ellipsoid, result._ellipsoid);
result._vertexFormat = VertexFormat_default.clone(vertexFormat, result._vertexFormat);
result._width = width;
result._height = height;
result._extrudedHeight = extrudedHeight;
result._cornerType = cornerType;
result._granularity = granularity;
result._shadowVolume = shadowVolume;
result._offsetAttribute = offsetAttribute === -1 ? void 0 : offsetAttribute;
return result;
};
CorridorGeometry.computeRectangle = function(options, result) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
const positions = options.positions;
const width = options.width;
Check_default.defined("options.positions", positions);
Check_default.defined("options.width", width);
const ellipsoid = defaultValue_default(options.ellipsoid, Ellipsoid_default.WGS84);
const cornerType = defaultValue_default(options.cornerType, CornerType_default.ROUNDED);
return computeRectangle2(positions, ellipsoid, width, cornerType, result);
};
CorridorGeometry.createGeometry = function(corridorGeometry) {
let positions = corridorGeometry._positions;
const width = corridorGeometry._width;
const ellipsoid = corridorGeometry._ellipsoid;
positions = scaleToSurface2(positions, ellipsoid);
const cleanPositions = arrayRemoveDuplicates_default(
positions,
Cartesian3_default.equalsEpsilon
);
if (cleanPositions.length < 2 || width <= 0) {
return;
}
const height = corridorGeometry._height;
const extrudedHeight = corridorGeometry._extrudedHeight;
const extrude = !Math_default.equalsEpsilon(
height,
extrudedHeight,
0,
Math_default.EPSILON2
);
const vertexFormat = corridorGeometry._vertexFormat;
const params = {
ellipsoid,
positions: cleanPositions,
width,
cornerType: corridorGeometry._cornerType,
granularity: corridorGeometry._granularity,
saveAttributes: true
};
let attr;
if (extrude) {
params.height = height;
params.extrudedHeight = extrudedHeight;
params.shadowVolume = corridorGeometry._shadowVolume;
params.offsetAttribute = corridorGeometry._offsetAttribute;
attr = computePositionsExtruded(params, vertexFormat);
} else {
const computedPositions = CorridorGeometryLibrary_default.computePositions(params);
attr = combine2(computedPositions, vertexFormat, ellipsoid);
attr.attributes.position.values = PolygonPipeline_default.scaleToGeodeticHeight(
attr.attributes.position.values,
height,
ellipsoid
);
if (defined_default(corridorGeometry._offsetAttribute)) {
const applyOffsetValue = corridorGeometry._offsetAttribute === GeometryOffsetAttribute_default.NONE ? 0 : 1;
const length3 = attr.attributes.position.values.length;
const applyOffset = new Uint8Array(length3 / 3).fill(applyOffsetValue);
attr.attributes.applyOffset = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.UNSIGNED_BYTE,
componentsPerAttribute: 1,
values: applyOffset
});
}
}
const attributes = attr.attributes;
const boundingSphere = BoundingSphere_default.fromVertices(
attributes.position.values,
void 0,
3
);
if (!vertexFormat.position) {
attr.attributes.position.values = void 0;
}
return new Geometry_default({
attributes,
indices: attr.indices,
primitiveType: PrimitiveType_default.TRIANGLES,
boundingSphere,
offsetAttribute: corridorGeometry._offsetAttribute
});
};
CorridorGeometry.createShadowVolume = function(corridorGeometry, minHeightFunc, maxHeightFunc) {
const granularity = corridorGeometry._granularity;
const ellipsoid = corridorGeometry._ellipsoid;
const minHeight = minHeightFunc(granularity, ellipsoid);
const maxHeight = maxHeightFunc(granularity, ellipsoid);
return new CorridorGeometry({
positions: corridorGeometry._positions,
width: corridorGeometry._width,
cornerType: corridorGeometry._cornerType,
ellipsoid,
granularity,
extrudedHeight: minHeight,
height: maxHeight,
vertexFormat: VertexFormat_default.POSITION_ONLY,
shadowVolume: true
});
};
Object.defineProperties(CorridorGeometry.prototype, {
rectangle: {
get: function() {
if (!defined_default(this._rectangle)) {
this._rectangle = computeRectangle2(
this._positions,
this._ellipsoid,
this._width,
this._cornerType
);
}
return this._rectangle;
}
},
textureCoordinateRotationPoints: {
get: function() {
return [0, 0, 0, 1, 1, 0];
}
}
});
var CorridorGeometry_default = CorridorGeometry;
// Source/Core/CorridorOutlineGeometry.js
var cartesian13 = new Cartesian3_default();
var cartesian23 = new Cartesian3_default();
var cartesian33 = new Cartesian3_default();
function scaleToSurface3(positions, ellipsoid) {
for (let i = 0; i < positions.length; i++) {
positions[i] = ellipsoid.scaleToGeodeticSurface(positions[i], positions[i]);
}
return positions;
}
function combine3(computedPositions, cornerType) {
const wallIndices = [];
const positions = computedPositions.positions;
const corners = computedPositions.corners;
const endPositions = computedPositions.endPositions;
const attributes = new GeometryAttributes_default();
let corner;
let leftCount = 0;
let rightCount = 0;
let i;
let indicesLength = 0;
let length3;
for (i = 0; i < positions.length; i += 2) {
length3 = positions[i].length - 3;
leftCount += length3;
indicesLength += length3 / 3 * 4;
rightCount += positions[i + 1].length - 3;
}
leftCount += 3;
rightCount += 3;
for (i = 0; i < corners.length; i++) {
corner = corners[i];
const leftSide = corners[i].leftPositions;
if (defined_default(leftSide)) {
length3 = leftSide.length;
leftCount += length3;
indicesLength += length3 / 3 * 2;
} else {
length3 = corners[i].rightPositions.length;
rightCount += length3;
indicesLength += length3 / 3 * 2;
}
}
const addEndPositions = defined_default(endPositions);
let endPositionLength;
if (addEndPositions) {
endPositionLength = endPositions[0].length - 3;
leftCount += endPositionLength;
rightCount += endPositionLength;
endPositionLength /= 3;
indicesLength += endPositionLength * 4;
}
const size = leftCount + rightCount;
const finalPositions = new Float64Array(size);
let front = 0;
let back = size - 1;
let UL, LL, UR, LR;
let rightPos, leftPos;
const halfLength = endPositionLength / 2;
const indices2 = IndexDatatype_default.createTypedArray(size / 3, indicesLength + 4);
let index = 0;
indices2[index++] = front / 3;
indices2[index++] = (back - 2) / 3;
if (addEndPositions) {
wallIndices.push(front / 3);
leftPos = cartesian13;
rightPos = cartesian23;
const firstEndPositions = endPositions[0];
for (i = 0; i < halfLength; i++) {
leftPos = Cartesian3_default.fromArray(
firstEndPositions,
(halfLength - 1 - i) * 3,
leftPos
);
rightPos = Cartesian3_default.fromArray(
firstEndPositions,
(halfLength + i) * 3,
rightPos
);
CorridorGeometryLibrary_default.addAttribute(finalPositions, rightPos, front);
CorridorGeometryLibrary_default.addAttribute(
finalPositions,
leftPos,
void 0,
back
);
LL = front / 3;
LR = LL + 1;
UL = (back - 2) / 3;
UR = UL - 1;
indices2[index++] = UL;
indices2[index++] = UR;
indices2[index++] = LL;
indices2[index++] = LR;
front += 3;
back -= 3;
}
}
let posIndex = 0;
let rightEdge = positions[posIndex++];
let leftEdge = positions[posIndex++];
finalPositions.set(rightEdge, front);
finalPositions.set(leftEdge, back - leftEdge.length + 1);
length3 = leftEdge.length - 3;
wallIndices.push(front / 3, (back - 2) / 3);
for (i = 0; i < length3; i += 3) {
LL = front / 3;
LR = LL + 1;
UL = (back - 2) / 3;
UR = UL - 1;
indices2[index++] = UL;
indices2[index++] = UR;
indices2[index++] = LL;
indices2[index++] = LR;
front += 3;
back -= 3;
}
for (i = 0; i < corners.length; i++) {
let j;
corner = corners[i];
const l = corner.leftPositions;
const r = corner.rightPositions;
let start;
let outsidePoint = cartesian33;
if (defined_default(l)) {
back -= 3;
start = UR;
wallIndices.push(LR);
for (j = 0; j < l.length / 3; j++) {
outsidePoint = Cartesian3_default.fromArray(l, j * 3, outsidePoint);
indices2[index++] = start - j - 1;
indices2[index++] = start - j;
CorridorGeometryLibrary_default.addAttribute(
finalPositions,
outsidePoint,
void 0,
back
);
back -= 3;
}
wallIndices.push(start - Math.floor(l.length / 6));
if (cornerType === CornerType_default.BEVELED) {
wallIndices.push((back - 2) / 3 + 1);
}
front += 3;
} else {
front += 3;
start = LR;
wallIndices.push(UR);
for (j = 0; j < r.length / 3; j++) {
outsidePoint = Cartesian3_default.fromArray(r, j * 3, outsidePoint);
indices2[index++] = start + j;
indices2[index++] = start + j + 1;
CorridorGeometryLibrary_default.addAttribute(
finalPositions,
outsidePoint,
front
);
front += 3;
}
wallIndices.push(start + Math.floor(r.length / 6));
if (cornerType === CornerType_default.BEVELED) {
wallIndices.push(front / 3 - 1);
}
back -= 3;
}
rightEdge = positions[posIndex++];
leftEdge = positions[posIndex++];
rightEdge.splice(0, 3);
leftEdge.splice(leftEdge.length - 3, 3);
finalPositions.set(rightEdge, front);
finalPositions.set(leftEdge, back - leftEdge.length + 1);
length3 = leftEdge.length - 3;
for (j = 0; j < leftEdge.length; j += 3) {
LR = front / 3;
LL = LR - 1;
UR = (back - 2) / 3;
UL = UR + 1;
indices2[index++] = UL;
indices2[index++] = UR;
indices2[index++] = LL;
indices2[index++] = LR;
front += 3;
back -= 3;
}
front -= 3;
back += 3;
wallIndices.push(front / 3, (back - 2) / 3);
}
if (addEndPositions) {
front += 3;
back -= 3;
leftPos = cartesian13;
rightPos = cartesian23;
const lastEndPositions = endPositions[1];
for (i = 0; i < halfLength; i++) {
leftPos = Cartesian3_default.fromArray(
lastEndPositions,
(endPositionLength - i - 1) * 3,
leftPos
);
rightPos = Cartesian3_default.fromArray(lastEndPositions, i * 3, rightPos);
CorridorGeometryLibrary_default.addAttribute(
finalPositions,
leftPos,
void 0,
back
);
CorridorGeometryLibrary_default.addAttribute(finalPositions, rightPos, front);
LR = front / 3;
LL = LR - 1;
UR = (back - 2) / 3;
UL = UR + 1;
indices2[index++] = UL;
indices2[index++] = UR;
indices2[index++] = LL;
indices2[index++] = LR;
front += 3;
back -= 3;
}
wallIndices.push(front / 3);
} else {
wallIndices.push(front / 3, (back - 2) / 3);
}
indices2[index++] = front / 3;
indices2[index++] = (back - 2) / 3;
attributes.position = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.DOUBLE,
componentsPerAttribute: 3,
values: finalPositions
});
return {
attributes,
indices: indices2,
wallIndices
};
}
function computePositionsExtruded2(params) {
const ellipsoid = params.ellipsoid;
const computedPositions = CorridorGeometryLibrary_default.computePositions(params);
const attr = combine3(computedPositions, params.cornerType);
const wallIndices = attr.wallIndices;
const height = params.height;
const extrudedHeight = params.extrudedHeight;
const attributes = attr.attributes;
const indices2 = attr.indices;
let positions = attributes.position.values;
let length3 = positions.length;
let extrudedPositions = new Float64Array(length3);
extrudedPositions.set(positions);
const newPositions = new Float64Array(length3 * 2);
positions = PolygonPipeline_default.scaleToGeodeticHeight(
positions,
height,
ellipsoid
);
extrudedPositions = PolygonPipeline_default.scaleToGeodeticHeight(
extrudedPositions,
extrudedHeight,
ellipsoid
);
newPositions.set(positions);
newPositions.set(extrudedPositions, length3);
attributes.position.values = newPositions;
length3 /= 3;
if (defined_default(params.offsetAttribute)) {
let applyOffset = new Uint8Array(length3 * 2);
if (params.offsetAttribute === GeometryOffsetAttribute_default.TOP) {
applyOffset = applyOffset.fill(1, 0, length3);
} else {
const applyOffsetValue = params.offsetAttribute === GeometryOffsetAttribute_default.NONE ? 0 : 1;
applyOffset = applyOffset.fill(applyOffsetValue);
}
attributes.applyOffset = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.UNSIGNED_BYTE,
componentsPerAttribute: 1,
values: applyOffset
});
}
let i;
const iLength = indices2.length;
const newIndices = IndexDatatype_default.createTypedArray(
newPositions.length / 3,
(iLength + wallIndices.length) * 2
);
newIndices.set(indices2);
let index = iLength;
for (i = 0; i < iLength; i += 2) {
const v02 = indices2[i];
const v13 = indices2[i + 1];
newIndices[index++] = v02 + length3;
newIndices[index++] = v13 + length3;
}
let UL, LL;
for (i = 0; i < wallIndices.length; i++) {
UL = wallIndices[i];
LL = UL + length3;
newIndices[index++] = UL;
newIndices[index++] = LL;
}
return {
attributes,
indices: newIndices
};
}
function CorridorOutlineGeometry(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
const positions = options.positions;
const width = options.width;
Check_default.typeOf.object("options.positions", positions);
Check_default.typeOf.number("options.width", width);
const height = defaultValue_default(options.height, 0);
const extrudedHeight = defaultValue_default(options.extrudedHeight, height);
this._positions = positions;
this._ellipsoid = Ellipsoid_default.clone(
defaultValue_default(options.ellipsoid, Ellipsoid_default.WGS84)
);
this._width = width;
this._height = Math.max(height, extrudedHeight);
this._extrudedHeight = Math.min(height, extrudedHeight);
this._cornerType = defaultValue_default(options.cornerType, CornerType_default.ROUNDED);
this._granularity = defaultValue_default(
options.granularity,
Math_default.RADIANS_PER_DEGREE
);
this._offsetAttribute = options.offsetAttribute;
this._workerName = "createCorridorOutlineGeometry";
this.packedLength = 1 + positions.length * Cartesian3_default.packedLength + Ellipsoid_default.packedLength + 6;
}
CorridorOutlineGeometry.pack = function(value, array, startingIndex) {
Check_default.typeOf.object("value", value);
Check_default.typeOf.object("array", array);
startingIndex = defaultValue_default(startingIndex, 0);
const positions = value._positions;
const length3 = positions.length;
array[startingIndex++] = length3;
for (let i = 0; i < length3; ++i, startingIndex += Cartesian3_default.packedLength) {
Cartesian3_default.pack(positions[i], array, startingIndex);
}
Ellipsoid_default.pack(value._ellipsoid, array, startingIndex);
startingIndex += Ellipsoid_default.packedLength;
array[startingIndex++] = value._width;
array[startingIndex++] = value._height;
array[startingIndex++] = value._extrudedHeight;
array[startingIndex++] = value._cornerType;
array[startingIndex++] = value._granularity;
array[startingIndex] = defaultValue_default(value._offsetAttribute, -1);
return array;
};
var scratchEllipsoid5 = Ellipsoid_default.clone(Ellipsoid_default.UNIT_SPHERE);
var scratchOptions10 = {
positions: void 0,
ellipsoid: scratchEllipsoid5,
width: void 0,
height: void 0,
extrudedHeight: void 0,
cornerType: void 0,
granularity: void 0,
offsetAttribute: void 0
};
CorridorOutlineGeometry.unpack = function(array, startingIndex, result) {
Check_default.typeOf.object("array", array);
startingIndex = defaultValue_default(startingIndex, 0);
const length3 = array[startingIndex++];
const positions = new Array(length3);
for (let i = 0; i < length3; ++i, startingIndex += Cartesian3_default.packedLength) {
positions[i] = Cartesian3_default.unpack(array, startingIndex);
}
const ellipsoid = Ellipsoid_default.unpack(array, startingIndex, scratchEllipsoid5);
startingIndex += Ellipsoid_default.packedLength;
const width = array[startingIndex++];
const height = array[startingIndex++];
const extrudedHeight = array[startingIndex++];
const cornerType = array[startingIndex++];
const granularity = array[startingIndex++];
const offsetAttribute = array[startingIndex];
if (!defined_default(result)) {
scratchOptions10.positions = positions;
scratchOptions10.width = width;
scratchOptions10.height = height;
scratchOptions10.extrudedHeight = extrudedHeight;
scratchOptions10.cornerType = cornerType;
scratchOptions10.granularity = granularity;
scratchOptions10.offsetAttribute = offsetAttribute === -1 ? void 0 : offsetAttribute;
return new CorridorOutlineGeometry(scratchOptions10);
}
result._positions = positions;
result._ellipsoid = Ellipsoid_default.clone(ellipsoid, result._ellipsoid);
result._width = width;
result._height = height;
result._extrudedHeight = extrudedHeight;
result._cornerType = cornerType;
result._granularity = granularity;
result._offsetAttribute = offsetAttribute === -1 ? void 0 : offsetAttribute;
return result;
};
CorridorOutlineGeometry.createGeometry = function(corridorOutlineGeometry) {
let positions = corridorOutlineGeometry._positions;
const width = corridorOutlineGeometry._width;
const ellipsoid = corridorOutlineGeometry._ellipsoid;
positions = scaleToSurface3(positions, ellipsoid);
const cleanPositions = arrayRemoveDuplicates_default(
positions,
Cartesian3_default.equalsEpsilon
);
if (cleanPositions.length < 2 || width <= 0) {
return;
}
const height = corridorOutlineGeometry._height;
const extrudedHeight = corridorOutlineGeometry._extrudedHeight;
const extrude = !Math_default.equalsEpsilon(
height,
extrudedHeight,
0,
Math_default.EPSILON2
);
const params = {
ellipsoid,
positions: cleanPositions,
width,
cornerType: corridorOutlineGeometry._cornerType,
granularity: corridorOutlineGeometry._granularity,
saveAttributes: false
};
let attr;
if (extrude) {
params.height = height;
params.extrudedHeight = extrudedHeight;
params.offsetAttribute = corridorOutlineGeometry._offsetAttribute;
attr = computePositionsExtruded2(params);
} else {
const computedPositions = CorridorGeometryLibrary_default.computePositions(params);
attr = combine3(computedPositions, params.cornerType);
attr.attributes.position.values = PolygonPipeline_default.scaleToGeodeticHeight(
attr.attributes.position.values,
height,
ellipsoid
);
if (defined_default(corridorOutlineGeometry._offsetAttribute)) {
const length3 = attr.attributes.position.values.length;
const offsetValue = corridorOutlineGeometry._offsetAttribute === GeometryOffsetAttribute_default.NONE ? 0 : 1;
const applyOffset = new Uint8Array(length3 / 3).fill(offsetValue);
attr.attributes.applyOffset = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.UNSIGNED_BYTE,
componentsPerAttribute: 1,
values: applyOffset
});
}
}
const attributes = attr.attributes;
const boundingSphere = BoundingSphere_default.fromVertices(
attributes.position.values,
void 0,
3
);
return new Geometry_default({
attributes,
indices: attr.indices,
primitiveType: PrimitiveType_default.LINES,
boundingSphere,
offsetAttribute: corridorOutlineGeometry._offsetAttribute
});
};
var CorridorOutlineGeometry_default = CorridorOutlineGeometry;
// Source/Core/createGuid.js
function createGuid() {
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
const r = Math.random() * 16 | 0;
const v7 = c === "x" ? r : r & 3 | 8;
return v7.toString(16);
});
}
var createGuid_default = createGuid;
// Source/Core/Ion.js
var defaultTokenCredit;
var defaultAccessToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiIyNDBiMjBhOS1jZWE5LTRmYWYtOGI3Yy05ZDg3ODBiZDZiZjUiLCJpZCI6MjU5LCJpYXQiOjE2NTkzNjE0MTJ9.tXPPvw93XpCGHG71h7s_mMLlWGCuAL55o8LC309hLAg";
var Ion = {};
Ion.defaultAccessToken = defaultAccessToken;
Ion.defaultServer = new Resource_default({ url: "https://api.cesium.com/" });
Ion.getDefaultTokenCredit = function(providedKey) {
if (providedKey !== defaultAccessToken) {
return void 0;
}
if (!defined_default(defaultTokenCredit)) {
const defaultTokenMessage = ` This application is using Cesium's default ion access token. Please assign Cesium.Ion.defaultAccessToken with an access token from your ion account before making any Cesium API calls. You can sign up for a free ion account at https://cesium.com.`;
defaultTokenCredit = new Credit_default(defaultTokenMessage, true);
}
return defaultTokenCredit;
};
var Ion_default = Ion;
// Source/Core/IonResource.js
function IonResource(endpoint, endpointResource) {
Check_default.defined("endpoint", endpoint);
Check_default.defined("endpointResource", endpointResource);
let options;
const externalType = endpoint.externalType;
const isExternal = defined_default(externalType);
if (!isExternal) {
options = {
url: endpoint.url,
retryAttempts: 1,
retryCallback
};
} else if (externalType === "3DTILES" || externalType === "STK_TERRAIN_SERVER") {
options = { url: endpoint.options.url };
} else {
throw new RuntimeError_default(
"Ion.createResource does not support external imagery assets; use IonImageryProvider instead."
);
}
Resource_default.call(this, options);
this._ionEndpoint = endpoint;
this._ionEndpointDomain = isExternal ? void 0 : new import_urijs.default(endpoint.url).authority();
this._ionEndpointResource = endpointResource;
this._ionRoot = void 0;
this._pendingPromise = void 0;
this._credits = void 0;
this._isExternal = isExternal;
}
if (defined_default(Object.create)) {
IonResource.prototype = Object.create(Resource_default.prototype);
IonResource.prototype.constructor = IonResource;
}
IonResource.fromAssetId = function(assetId, options) {
const endpointResource = IonResource._createEndpointResource(
assetId,
options
);
return endpointResource.fetchJson().then(function(endpoint) {
return new IonResource(endpoint, endpointResource);
});
};
Object.defineProperties(IonResource.prototype, {
credits: {
get: function() {
if (defined_default(this._ionRoot)) {
return this._ionRoot.credits;
}
if (defined_default(this._credits)) {
return this._credits;
}
this._credits = IonResource.getCreditsFromEndpoint(
this._ionEndpoint,
this._ionEndpointResource
);
return this._credits;
}
}
});
IonResource.getCreditsFromEndpoint = function(endpoint, endpointResource) {
const credits = endpoint.attributions.map(Credit_default.getIonCredit);
const defaultTokenCredit2 = Ion_default.getDefaultTokenCredit(
endpointResource.queryParameters.access_token
);
if (defined_default(defaultTokenCredit2)) {
credits.push(Credit_default.clone(defaultTokenCredit2));
}
return credits;
};
IonResource.prototype.clone = function(result) {
const ionRoot = defaultValue_default(this._ionRoot, this);
if (!defined_default(result)) {
result = new IonResource(
ionRoot._ionEndpoint,
ionRoot._ionEndpointResource
);
}
result = Resource_default.prototype.clone.call(this, result);
result._ionRoot = ionRoot;
result._isExternal = this._isExternal;
return result;
};
IonResource.prototype.fetchImage = function(options) {
if (!this._isExternal) {
const userOptions = options;
options = {
preferBlob: true
};
if (defined_default(userOptions)) {
options.flipY = userOptions.flipY;
options.preferImageBitmap = userOptions.preferImageBitmap;
}
}
return Resource_default.prototype.fetchImage.call(this, options);
};
IonResource.prototype._makeRequest = function(options) {
if (this._isExternal || new import_urijs.default(this.url).authority() !== this._ionEndpointDomain) {
return Resource_default.prototype._makeRequest.call(this, options);
}
if (!defined_default(options.headers)) {
options.headers = {};
}
options.headers.Authorization = `Bearer ${this._ionEndpoint.accessToken}`;
return Resource_default.prototype._makeRequest.call(this, options);
};
IonResource._createEndpointResource = function(assetId, options) {
Check_default.defined("assetId", assetId);
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
let server = defaultValue_default(options.server, Ion_default.defaultServer);
const accessToken = defaultValue_default(options.accessToken, Ion_default.defaultAccessToken);
server = Resource_default.createIfNeeded(server);
const resourceOptions = {
url: `v1/assets/${assetId}/endpoint`
};
if (defined_default(accessToken)) {
resourceOptions.queryParameters = { access_token: accessToken };
}
return server.getDerivedResource(resourceOptions);
};
function retryCallback(that, error) {
const ionRoot = defaultValue_default(that._ionRoot, that);
const endpointResource = ionRoot._ionEndpointResource;
const imageDefined = typeof Image !== "undefined";
if (!defined_default(error) || error.statusCode !== 401 && !(imageDefined && error.target instanceof Image)) {
return Promise.resolve(false);
}
if (!defined_default(ionRoot._pendingPromise)) {
ionRoot._pendingPromise = endpointResource.fetchJson().then(function(newEndpoint) {
ionRoot._ionEndpoint = newEndpoint;
return newEndpoint;
}).finally(function(newEndpoint) {
ionRoot._pendingPromise = void 0;
return newEndpoint;
});
}
return ionRoot._pendingPromise.then(function(newEndpoint) {
that._ionEndpoint = newEndpoint;
return true;
});
}
var IonResource_default = IonResource;
// Source/Core/createWorldTerrain.js
function createWorldTerrain(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
return new CesiumTerrainProvider_default({
url: IonResource_default.fromAssetId(1),
requestVertexNormals: defaultValue_default(options.requestVertexNormals, false),
requestWaterMask: defaultValue_default(options.requestWaterMask, false)
});
}
var createWorldTerrain_default = createWorldTerrain;
// Source/Core/CullingVolume.js
function CullingVolume(planes) {
this.planes = defaultValue_default(planes, []);
}
var faces = [new Cartesian3_default(), new Cartesian3_default(), new Cartesian3_default()];
Cartesian3_default.clone(Cartesian3_default.UNIT_X, faces[0]);
Cartesian3_default.clone(Cartesian3_default.UNIT_Y, faces[1]);
Cartesian3_default.clone(Cartesian3_default.UNIT_Z, faces[2]);
var scratchPlaneCenter = new Cartesian3_default();
var scratchPlaneNormal2 = new Cartesian3_default();
var scratchPlane2 = new Plane_default(new Cartesian3_default(1, 0, 0), 0);
CullingVolume.fromBoundingSphere = function(boundingSphere, result) {
if (!defined_default(boundingSphere)) {
throw new DeveloperError_default("boundingSphere is required.");
}
if (!defined_default(result)) {
result = new CullingVolume();
}
const length3 = faces.length;
const planes = result.planes;
planes.length = 2 * length3;
const center = boundingSphere.center;
const radius = boundingSphere.radius;
let planeIndex = 0;
for (let i = 0; i < length3; ++i) {
const faceNormal = faces[i];
let plane0 = planes[planeIndex];
let plane1 = planes[planeIndex + 1];
if (!defined_default(plane0)) {
plane0 = planes[planeIndex] = new Cartesian4_default();
}
if (!defined_default(plane1)) {
plane1 = planes[planeIndex + 1] = new Cartesian4_default();
}
Cartesian3_default.multiplyByScalar(faceNormal, -radius, scratchPlaneCenter);
Cartesian3_default.add(center, scratchPlaneCenter, scratchPlaneCenter);
plane0.x = faceNormal.x;
plane0.y = faceNormal.y;
plane0.z = faceNormal.z;
plane0.w = -Cartesian3_default.dot(faceNormal, scratchPlaneCenter);
Cartesian3_default.multiplyByScalar(faceNormal, radius, scratchPlaneCenter);
Cartesian3_default.add(center, scratchPlaneCenter, scratchPlaneCenter);
plane1.x = -faceNormal.x;
plane1.y = -faceNormal.y;
plane1.z = -faceNormal.z;
plane1.w = -Cartesian3_default.dot(
Cartesian3_default.negate(faceNormal, scratchPlaneNormal2),
scratchPlaneCenter
);
planeIndex += 2;
}
return result;
};
CullingVolume.prototype.computeVisibility = function(boundingVolume) {
if (!defined_default(boundingVolume)) {
throw new DeveloperError_default("boundingVolume is required.");
}
const planes = this.planes;
let intersecting = false;
for (let k = 0, len = planes.length; k < len; ++k) {
const result = boundingVolume.intersectPlane(
Plane_default.fromCartesian4(planes[k], scratchPlane2)
);
if (result === Intersect_default.OUTSIDE) {
return Intersect_default.OUTSIDE;
} else if (result === Intersect_default.INTERSECTING) {
intersecting = true;
}
}
return intersecting ? Intersect_default.INTERSECTING : Intersect_default.INSIDE;
};
CullingVolume.prototype.computeVisibilityWithPlaneMask = function(boundingVolume, parentPlaneMask) {
if (!defined_default(boundingVolume)) {
throw new DeveloperError_default("boundingVolume is required.");
}
if (!defined_default(parentPlaneMask)) {
throw new DeveloperError_default("parentPlaneMask is required.");
}
if (parentPlaneMask === CullingVolume.MASK_OUTSIDE || parentPlaneMask === CullingVolume.MASK_INSIDE) {
return parentPlaneMask;
}
let mask = CullingVolume.MASK_INSIDE;
const planes = this.planes;
for (let k = 0, len = planes.length; k < len; ++k) {
const flag = k < 31 ? 1 << k : 0;
if (k < 31 && (parentPlaneMask & flag) === 0) {
continue;
}
const result = boundingVolume.intersectPlane(
Plane_default.fromCartesian4(planes[k], scratchPlane2)
);
if (result === Intersect_default.OUTSIDE) {
return CullingVolume.MASK_OUTSIDE;
} else if (result === Intersect_default.INTERSECTING) {
mask |= flag;
}
}
return mask;
};
CullingVolume.MASK_OUTSIDE = 4294967295;
CullingVolume.MASK_INSIDE = 0;
CullingVolume.MASK_INDETERMINATE = 2147483647;
var CullingVolume_default = CullingVolume;
// Source/Core/CustomHeightmapTerrainProvider.js
function CustomHeightmapTerrainProvider(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
Check_default.defined("options.callback", options.callback);
Check_default.defined("options.width", options.width);
Check_default.defined("options.height", options.height);
this._callback = options.callback;
this._tilingScheme = options.tilingScheme;
if (!defined_default(this._tilingScheme)) {
this._tilingScheme = new GeographicTilingScheme_default({
ellipsoid: defaultValue_default(options.ellipsoid, Ellipsoid_default.WGS84)
});
}
this._width = options.width;
this._height = options.height;
const maxTileDimensions = Math.max(this._width, this._height);
this._levelZeroMaximumGeometricError = TerrainProvider_default.getEstimatedLevelZeroGeometricErrorForAHeightmap(
this._tilingScheme.ellipsoid,
maxTileDimensions,
this._tilingScheme.getNumberOfXTilesAtLevel(0)
);
this._errorEvent = new Event_default();
let credit = options.credit;
if (typeof credit === "string") {
credit = new Credit_default(credit);
}
this._credit = credit;
this._readyPromise = Promise.resolve(true);
}
Object.defineProperties(CustomHeightmapTerrainProvider.prototype, {
errorEvent: {
get: function() {
return this._errorEvent;
}
},
credit: {
get: function() {
return this._credit;
}
},
tilingScheme: {
get: function() {
return this._tilingScheme;
}
},
ready: {
get: function() {
return true;
}
},
readyPromise: {
get: function() {
return this._readyPromise;
}
},
hasWaterMask: {
get: function() {
return false;
}
},
hasVertexNormals: {
get: function() {
return false;
}
},
width: {
get: function() {
return this._width;
}
},
height: {
get: function() {
return this._height;
}
}
});
CustomHeightmapTerrainProvider.prototype.requestTileGeometry = function(x, y, level, request) {
const promise = this._callback(x, y, level);
if (!defined_default(promise)) {
return void 0;
}
const width = this._width;
const height = this._height;
return Promise.resolve(promise).then(function(heightmapData) {
let buffer = heightmapData;
if (Array.isArray(buffer)) {
buffer = new Float64Array(buffer);
}
return new HeightmapTerrainData_default({
buffer,
width,
height
});
});
};
CustomHeightmapTerrainProvider.prototype.getLevelMaximumGeometricError = function(level) {
return this._levelZeroMaximumGeometricError / (1 << level);
};
CustomHeightmapTerrainProvider.prototype.getTileDataAvailable = function(x, y, level) {
return void 0;
};
CustomHeightmapTerrainProvider.prototype.loadTileDataAvailability = function(x, y, level) {
return void 0;
};
var CustomHeightmapTerrainProvider_default = CustomHeightmapTerrainProvider;
// Source/Core/CylinderGeometryLibrary.js
var CylinderGeometryLibrary = {};
CylinderGeometryLibrary.computePositions = function(length3, topRadius, bottomRadius, slices, fill) {
const topZ = length3 * 0.5;
const bottomZ = -topZ;
const twoSlice = slices + slices;
const size = fill ? 2 * twoSlice : twoSlice;
const positions = new Float64Array(size * 3);
let i;
let index = 0;
let tbIndex = 0;
const bottomOffset = fill ? twoSlice * 3 : 0;
const topOffset = fill ? (twoSlice + slices) * 3 : slices * 3;
for (i = 0; i < slices; i++) {
const angle = i / slices * Math_default.TWO_PI;
const x = Math.cos(angle);
const y = Math.sin(angle);
const bottomX = x * bottomRadius;
const bottomY = y * bottomRadius;
const topX = x * topRadius;
const topY = y * topRadius;
positions[tbIndex + bottomOffset] = bottomX;
positions[tbIndex + bottomOffset + 1] = bottomY;
positions[tbIndex + bottomOffset + 2] = bottomZ;
positions[tbIndex + topOffset] = topX;
positions[tbIndex + topOffset + 1] = topY;
positions[tbIndex + topOffset + 2] = topZ;
tbIndex += 3;
if (fill) {
positions[index++] = bottomX;
positions[index++] = bottomY;
positions[index++] = bottomZ;
positions[index++] = topX;
positions[index++] = topY;
positions[index++] = topZ;
}
}
return positions;
};
var CylinderGeometryLibrary_default = CylinderGeometryLibrary;
// Source/Core/CylinderGeometry.js
var radiusScratch = new Cartesian2_default();
var normalScratch3 = new Cartesian3_default();
var bitangentScratch = new Cartesian3_default();
var tangentScratch = new Cartesian3_default();
var positionScratch2 = new Cartesian3_default();
function CylinderGeometry(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
const length3 = options.length;
const topRadius = options.topRadius;
const bottomRadius = options.bottomRadius;
const vertexFormat = defaultValue_default(options.vertexFormat, VertexFormat_default.DEFAULT);
const slices = defaultValue_default(options.slices, 128);
if (!defined_default(length3)) {
throw new DeveloperError_default("options.length must be defined.");
}
if (!defined_default(topRadius)) {
throw new DeveloperError_default("options.topRadius must be defined.");
}
if (!defined_default(bottomRadius)) {
throw new DeveloperError_default("options.bottomRadius must be defined.");
}
if (slices < 3) {
throw new DeveloperError_default(
"options.slices must be greater than or equal to 3."
);
}
if (defined_default(options.offsetAttribute) && options.offsetAttribute === GeometryOffsetAttribute_default.TOP) {
throw new DeveloperError_default(
"GeometryOffsetAttribute.TOP is not a supported options.offsetAttribute for this geometry."
);
}
this._length = length3;
this._topRadius = topRadius;
this._bottomRadius = bottomRadius;
this._vertexFormat = VertexFormat_default.clone(vertexFormat);
this._slices = slices;
this._offsetAttribute = options.offsetAttribute;
this._workerName = "createCylinderGeometry";
}
CylinderGeometry.packedLength = VertexFormat_default.packedLength + 5;
CylinderGeometry.pack = function(value, array, startingIndex) {
if (!defined_default(value)) {
throw new DeveloperError_default("value is required");
}
if (!defined_default(array)) {
throw new DeveloperError_default("array is required");
}
startingIndex = defaultValue_default(startingIndex, 0);
VertexFormat_default.pack(value._vertexFormat, array, startingIndex);
startingIndex += VertexFormat_default.packedLength;
array[startingIndex++] = value._length;
array[startingIndex++] = value._topRadius;
array[startingIndex++] = value._bottomRadius;
array[startingIndex++] = value._slices;
array[startingIndex] = defaultValue_default(value._offsetAttribute, -1);
return array;
};
var scratchVertexFormat5 = new VertexFormat_default();
var scratchOptions11 = {
vertexFormat: scratchVertexFormat5,
length: void 0,
topRadius: void 0,
bottomRadius: void 0,
slices: void 0,
offsetAttribute: void 0
};
CylinderGeometry.unpack = function(array, startingIndex, result) {
if (!defined_default(array)) {
throw new DeveloperError_default("array is required");
}
startingIndex = defaultValue_default(startingIndex, 0);
const vertexFormat = VertexFormat_default.unpack(
array,
startingIndex,
scratchVertexFormat5
);
startingIndex += VertexFormat_default.packedLength;
const length3 = array[startingIndex++];
const topRadius = array[startingIndex++];
const bottomRadius = array[startingIndex++];
const slices = array[startingIndex++];
const offsetAttribute = array[startingIndex];
if (!defined_default(result)) {
scratchOptions11.length = length3;
scratchOptions11.topRadius = topRadius;
scratchOptions11.bottomRadius = bottomRadius;
scratchOptions11.slices = slices;
scratchOptions11.offsetAttribute = offsetAttribute === -1 ? void 0 : offsetAttribute;
return new CylinderGeometry(scratchOptions11);
}
result._vertexFormat = VertexFormat_default.clone(vertexFormat, result._vertexFormat);
result._length = length3;
result._topRadius = topRadius;
result._bottomRadius = bottomRadius;
result._slices = slices;
result._offsetAttribute = offsetAttribute === -1 ? void 0 : offsetAttribute;
return result;
};
CylinderGeometry.createGeometry = function(cylinderGeometry) {
let length3 = cylinderGeometry._length;
const topRadius = cylinderGeometry._topRadius;
const bottomRadius = cylinderGeometry._bottomRadius;
const vertexFormat = cylinderGeometry._vertexFormat;
const slices = cylinderGeometry._slices;
if (length3 <= 0 || topRadius < 0 || bottomRadius < 0 || topRadius === 0 && bottomRadius === 0) {
return;
}
const twoSlices = slices + slices;
const threeSlices = slices + twoSlices;
const numVertices = twoSlices + twoSlices;
const positions = CylinderGeometryLibrary_default.computePositions(
length3,
topRadius,
bottomRadius,
slices,
true
);
const st = vertexFormat.st ? new Float32Array(numVertices * 2) : void 0;
const normals = vertexFormat.normal ? new Float32Array(numVertices * 3) : void 0;
const tangents = vertexFormat.tangent ? new Float32Array(numVertices * 3) : void 0;
const bitangents = vertexFormat.bitangent ? new Float32Array(numVertices * 3) : void 0;
let i;
const computeNormal = vertexFormat.normal || vertexFormat.tangent || vertexFormat.bitangent;
if (computeNormal) {
const computeTangent = vertexFormat.tangent || vertexFormat.bitangent;
let normalIndex = 0;
let tangentIndex = 0;
let bitangentIndex = 0;
const theta = Math.atan2(bottomRadius - topRadius, length3);
const normal2 = normalScratch3;
normal2.z = Math.sin(theta);
const normalScale2 = Math.cos(theta);
let tangent = tangentScratch;
let bitangent = bitangentScratch;
for (i = 0; i < slices; i++) {
const angle = i / slices * Math_default.TWO_PI;
const x = normalScale2 * Math.cos(angle);
const y = normalScale2 * Math.sin(angle);
if (computeNormal) {
normal2.x = x;
normal2.y = y;
if (computeTangent) {
tangent = Cartesian3_default.normalize(
Cartesian3_default.cross(Cartesian3_default.UNIT_Z, normal2, tangent),
tangent
);
}
if (vertexFormat.normal) {
normals[normalIndex++] = normal2.x;
normals[normalIndex++] = normal2.y;
normals[normalIndex++] = normal2.z;
normals[normalIndex++] = normal2.x;
normals[normalIndex++] = normal2.y;
normals[normalIndex++] = normal2.z;
}
if (vertexFormat.tangent) {
tangents[tangentIndex++] = tangent.x;
tangents[tangentIndex++] = tangent.y;
tangents[tangentIndex++] = tangent.z;
tangents[tangentIndex++] = tangent.x;
tangents[tangentIndex++] = tangent.y;
tangents[tangentIndex++] = tangent.z;
}
if (vertexFormat.bitangent) {
bitangent = Cartesian3_default.normalize(
Cartesian3_default.cross(normal2, tangent, bitangent),
bitangent
);
bitangents[bitangentIndex++] = bitangent.x;
bitangents[bitangentIndex++] = bitangent.y;
bitangents[bitangentIndex++] = bitangent.z;
bitangents[bitangentIndex++] = bitangent.x;
bitangents[bitangentIndex++] = bitangent.y;
bitangents[bitangentIndex++] = bitangent.z;
}
}
}
for (i = 0; i < slices; i++) {
if (vertexFormat.normal) {
normals[normalIndex++] = 0;
normals[normalIndex++] = 0;
normals[normalIndex++] = -1;
}
if (vertexFormat.tangent) {
tangents[tangentIndex++] = 1;
tangents[tangentIndex++] = 0;
tangents[tangentIndex++] = 0;
}
if (vertexFormat.bitangent) {
bitangents[bitangentIndex++] = 0;
bitangents[bitangentIndex++] = -1;
bitangents[bitangentIndex++] = 0;
}
}
for (i = 0; i < slices; i++) {
if (vertexFormat.normal) {
normals[normalIndex++] = 0;
normals[normalIndex++] = 0;
normals[normalIndex++] = 1;
}
if (vertexFormat.tangent) {
tangents[tangentIndex++] = 1;
tangents[tangentIndex++] = 0;
tangents[tangentIndex++] = 0;
}
if (vertexFormat.bitangent) {
bitangents[bitangentIndex++] = 0;
bitangents[bitangentIndex++] = 1;
bitangents[bitangentIndex++] = 0;
}
}
}
const numIndices = 12 * slices - 12;
const indices2 = IndexDatatype_default.createTypedArray(numVertices, numIndices);
let index = 0;
let j = 0;
for (i = 0; i < slices - 1; i++) {
indices2[index++] = j;
indices2[index++] = j + 2;
indices2[index++] = j + 3;
indices2[index++] = j;
indices2[index++] = j + 3;
indices2[index++] = j + 1;
j += 2;
}
indices2[index++] = twoSlices - 2;
indices2[index++] = 0;
indices2[index++] = 1;
indices2[index++] = twoSlices - 2;
indices2[index++] = 1;
indices2[index++] = twoSlices - 1;
for (i = 1; i < slices - 1; i++) {
indices2[index++] = twoSlices + i + 1;
indices2[index++] = twoSlices + i;
indices2[index++] = twoSlices;
}
for (i = 1; i < slices - 1; i++) {
indices2[index++] = threeSlices;
indices2[index++] = threeSlices + i;
indices2[index++] = threeSlices + i + 1;
}
let textureCoordIndex = 0;
if (vertexFormat.st) {
const rad = Math.max(topRadius, bottomRadius);
for (i = 0; i < numVertices; i++) {
const position = Cartesian3_default.fromArray(positions, i * 3, positionScratch2);
st[textureCoordIndex++] = (position.x + rad) / (2 * rad);
st[textureCoordIndex++] = (position.y + rad) / (2 * rad);
}
}
const attributes = new GeometryAttributes_default();
if (vertexFormat.position) {
attributes.position = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.DOUBLE,
componentsPerAttribute: 3,
values: positions
});
}
if (vertexFormat.normal) {
attributes.normal = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.FLOAT,
componentsPerAttribute: 3,
values: normals
});
}
if (vertexFormat.tangent) {
attributes.tangent = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.FLOAT,
componentsPerAttribute: 3,
values: tangents
});
}
if (vertexFormat.bitangent) {
attributes.bitangent = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.FLOAT,
componentsPerAttribute: 3,
values: bitangents
});
}
if (vertexFormat.st) {
attributes.st = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.FLOAT,
componentsPerAttribute: 2,
values: st
});
}
radiusScratch.x = length3 * 0.5;
radiusScratch.y = Math.max(bottomRadius, topRadius);
const boundingSphere = new BoundingSphere_default(
Cartesian3_default.ZERO,
Cartesian2_default.magnitude(radiusScratch)
);
if (defined_default(cylinderGeometry._offsetAttribute)) {
length3 = positions.length;
const offsetValue = cylinderGeometry._offsetAttribute === GeometryOffsetAttribute_default.NONE ? 0 : 1;
const applyOffset = new Uint8Array(length3 / 3).fill(offsetValue);
attributes.applyOffset = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.UNSIGNED_BYTE,
componentsPerAttribute: 1,
values: applyOffset
});
}
return new Geometry_default({
attributes,
indices: indices2,
primitiveType: PrimitiveType_default.TRIANGLES,
boundingSphere,
offsetAttribute: cylinderGeometry._offsetAttribute
});
};
var unitCylinderGeometry;
CylinderGeometry.getUnitCylinder = function() {
if (!defined_default(unitCylinderGeometry)) {
unitCylinderGeometry = CylinderGeometry.createGeometry(
new CylinderGeometry({
topRadius: 1,
bottomRadius: 1,
length: 1,
vertexFormat: VertexFormat_default.POSITION_ONLY
})
);
}
return unitCylinderGeometry;
};
var CylinderGeometry_default = CylinderGeometry;
// Source/Core/CylinderOutlineGeometry.js
var radiusScratch2 = new Cartesian2_default();
function CylinderOutlineGeometry(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
const length3 = options.length;
const topRadius = options.topRadius;
const bottomRadius = options.bottomRadius;
const slices = defaultValue_default(options.slices, 128);
const numberOfVerticalLines = Math.max(
defaultValue_default(options.numberOfVerticalLines, 16),
0
);
Check_default.typeOf.number("options.positions", length3);
Check_default.typeOf.number("options.topRadius", topRadius);
Check_default.typeOf.number("options.bottomRadius", bottomRadius);
Check_default.typeOf.number.greaterThanOrEquals("options.slices", slices, 3);
if (defined_default(options.offsetAttribute) && options.offsetAttribute === GeometryOffsetAttribute_default.TOP) {
throw new DeveloperError_default(
"GeometryOffsetAttribute.TOP is not a supported options.offsetAttribute for this geometry."
);
}
this._length = length3;
this._topRadius = topRadius;
this._bottomRadius = bottomRadius;
this._slices = slices;
this._numberOfVerticalLines = numberOfVerticalLines;
this._offsetAttribute = options.offsetAttribute;
this._workerName = "createCylinderOutlineGeometry";
}
CylinderOutlineGeometry.packedLength = 6;
CylinderOutlineGeometry.pack = function(value, array, startingIndex) {
Check_default.typeOf.object("value", value);
Check_default.defined("array", array);
startingIndex = defaultValue_default(startingIndex, 0);
array[startingIndex++] = value._length;
array[startingIndex++] = value._topRadius;
array[startingIndex++] = value._bottomRadius;
array[startingIndex++] = value._slices;
array[startingIndex++] = value._numberOfVerticalLines;
array[startingIndex] = defaultValue_default(value._offsetAttribute, -1);
return array;
};
var scratchOptions12 = {
length: void 0,
topRadius: void 0,
bottomRadius: void 0,
slices: void 0,
numberOfVerticalLines: void 0,
offsetAttribute: void 0
};
CylinderOutlineGeometry.unpack = function(array, startingIndex, result) {
Check_default.defined("array", array);
startingIndex = defaultValue_default(startingIndex, 0);
const length3 = array[startingIndex++];
const topRadius = array[startingIndex++];
const bottomRadius = array[startingIndex++];
const slices = array[startingIndex++];
const numberOfVerticalLines = array[startingIndex++];
const offsetAttribute = array[startingIndex];
if (!defined_default(result)) {
scratchOptions12.length = length3;
scratchOptions12.topRadius = topRadius;
scratchOptions12.bottomRadius = bottomRadius;
scratchOptions12.slices = slices;
scratchOptions12.numberOfVerticalLines = numberOfVerticalLines;
scratchOptions12.offsetAttribute = offsetAttribute === -1 ? void 0 : offsetAttribute;
return new CylinderOutlineGeometry(scratchOptions12);
}
result._length = length3;
result._topRadius = topRadius;
result._bottomRadius = bottomRadius;
result._slices = slices;
result._numberOfVerticalLines = numberOfVerticalLines;
result._offsetAttribute = offsetAttribute === -1 ? void 0 : offsetAttribute;
return result;
};
CylinderOutlineGeometry.createGeometry = function(cylinderGeometry) {
let length3 = cylinderGeometry._length;
const topRadius = cylinderGeometry._topRadius;
const bottomRadius = cylinderGeometry._bottomRadius;
const slices = cylinderGeometry._slices;
const numberOfVerticalLines = cylinderGeometry._numberOfVerticalLines;
if (length3 <= 0 || topRadius < 0 || bottomRadius < 0 || topRadius === 0 && bottomRadius === 0) {
return;
}
const numVertices = slices * 2;
const positions = CylinderGeometryLibrary_default.computePositions(
length3,
topRadius,
bottomRadius,
slices,
false
);
let numIndices = slices * 2;
let numSide;
if (numberOfVerticalLines > 0) {
const numSideLines = Math.min(numberOfVerticalLines, slices);
numSide = Math.round(slices / numSideLines);
numIndices += numSideLines;
}
const indices2 = IndexDatatype_default.createTypedArray(numVertices, numIndices * 2);
let index = 0;
let i;
for (i = 0; i < slices - 1; i++) {
indices2[index++] = i;
indices2[index++] = i + 1;
indices2[index++] = i + slices;
indices2[index++] = i + 1 + slices;
}
indices2[index++] = slices - 1;
indices2[index++] = 0;
indices2[index++] = slices + slices - 1;
indices2[index++] = slices;
if (numberOfVerticalLines > 0) {
for (i = 0; i < slices; i += numSide) {
indices2[index++] = i;
indices2[index++] = i + slices;
}
}
const attributes = new GeometryAttributes_default();
attributes.position = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.DOUBLE,
componentsPerAttribute: 3,
values: positions
});
radiusScratch2.x = length3 * 0.5;
radiusScratch2.y = Math.max(bottomRadius, topRadius);
const boundingSphere = new BoundingSphere_default(
Cartesian3_default.ZERO,
Cartesian2_default.magnitude(radiusScratch2)
);
if (defined_default(cylinderGeometry._offsetAttribute)) {
length3 = positions.length;
const offsetValue = cylinderGeometry._offsetAttribute === GeometryOffsetAttribute_default.NONE ? 0 : 1;
const applyOffset = new Uint8Array(length3 / 3).fill(offsetValue);
attributes.applyOffset = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.UNSIGNED_BYTE,
componentsPerAttribute: 1,
values: applyOffset
});
}
return new Geometry_default({
attributes,
indices: indices2,
primitiveType: PrimitiveType_default.LINES,
boundingSphere,
offsetAttribute: cylinderGeometry._offsetAttribute
});
};
var CylinderOutlineGeometry_default = CylinderOutlineGeometry;
// Source/Core/decodeGoogleEarthEnterpriseData.js
var compressedMagic = 1953029805;
var compressedMagicSwap = 2917034100;
function decodeGoogleEarthEnterpriseData(key, data) {
if (decodeGoogleEarthEnterpriseData.passThroughDataForTesting) {
return data;
}
Check_default.typeOf.object("key", key);
Check_default.typeOf.object("data", data);
const keyLength = key.byteLength;
if (keyLength === 0 || keyLength % 4 !== 0) {
throw new RuntimeError_default(
"The length of key must be greater than 0 and a multiple of 4."
);
}
const dataView = new DataView(data);
const magic = dataView.getUint32(0, true);
if (magic === compressedMagic || magic === compressedMagicSwap) {
return data;
}
const keyView = new DataView(key);
let dp = 0;
const dpend = data.byteLength;
const dpend64 = dpend - dpend % 8;
const kpend = keyLength;
let kp;
let off = 8;
while (dp < dpend64) {
off = (off + 8) % 24;
kp = off;
while (dp < dpend64 && kp < kpend) {
dataView.setUint32(
dp,
dataView.getUint32(dp, true) ^ keyView.getUint32(kp, true),
true
);
dataView.setUint32(
dp + 4,
dataView.getUint32(dp + 4, true) ^ keyView.getUint32(kp + 4, true),
true
);
dp += 8;
kp += 24;
}
}
if (dp < dpend) {
if (kp >= kpend) {
off = (off + 8) % 24;
kp = off;
}
while (dp < dpend) {
dataView.setUint8(dp, dataView.getUint8(dp) ^ keyView.getUint8(kp));
dp++;
kp++;
}
}
}
decodeGoogleEarthEnterpriseData.passThroughDataForTesting = false;
var decodeGoogleEarthEnterpriseData_default = decodeGoogleEarthEnterpriseData;
// Source/Core/decodeVectorPolylinePositions.js
var maxShort2 = 32767;
var scratchBVCartographic = new Cartographic_default();
var scratchEncodedPosition = new Cartesian3_default();
function decodeVectorPolylinePositions(positions, rectangle, minimumHeight, maximumHeight, ellipsoid) {
const positionsLength = positions.length / 3;
const uBuffer = positions.subarray(0, positionsLength);
const vBuffer = positions.subarray(positionsLength, 2 * positionsLength);
const heightBuffer = positions.subarray(
2 * positionsLength,
3 * positionsLength
);
AttributeCompression_default.zigZagDeltaDecode(uBuffer, vBuffer, heightBuffer);
const decoded = new Float64Array(positions.length);
for (let i = 0; i < positionsLength; ++i) {
const u3 = uBuffer[i];
const v7 = vBuffer[i];
const h = heightBuffer[i];
const lon = Math_default.lerp(rectangle.west, rectangle.east, u3 / maxShort2);
const lat = Math_default.lerp(rectangle.south, rectangle.north, v7 / maxShort2);
const alt = Math_default.lerp(minimumHeight, maximumHeight, h / maxShort2);
const cartographic2 = Cartographic_default.fromRadians(
lon,
lat,
alt,
scratchBVCartographic
);
const decodedPosition = ellipsoid.cartographicToCartesian(
cartographic2,
scratchEncodedPosition
);
Cartesian3_default.pack(decodedPosition, decoded, i * 3);
}
return decoded;
}
var decodeVectorPolylinePositions_default = decodeVectorPolylinePositions;
// Source/Core/DefaultProxy.js
function DefaultProxy(proxy) {
this.proxy = proxy;
}
DefaultProxy.prototype.getURL = function(resource) {
const prefix = this.proxy.indexOf("?") === -1 ? "?" : "";
return this.proxy + prefix + encodeURIComponent(resource);
};
var DefaultProxy_default = DefaultProxy;
// Source/Core/DistanceDisplayCondition.js
function DistanceDisplayCondition(near, far) {
near = defaultValue_default(near, 0);
this._near = near;
far = defaultValue_default(far, Number.MAX_VALUE);
this._far = far;
}
Object.defineProperties(DistanceDisplayCondition.prototype, {
near: {
get: function() {
return this._near;
},
set: function(value) {
this._near = value;
}
},
far: {
get: function() {
return this._far;
},
set: function(value) {
this._far = value;
}
}
});
DistanceDisplayCondition.packedLength = 2;
DistanceDisplayCondition.pack = function(value, array, startingIndex) {
if (!defined_default(value)) {
throw new DeveloperError_default("value is required");
}
if (!defined_default(array)) {
throw new DeveloperError_default("array is required");
}
startingIndex = defaultValue_default(startingIndex, 0);
array[startingIndex++] = value.near;
array[startingIndex] = value.far;
return array;
};
DistanceDisplayCondition.unpack = function(array, startingIndex, result) {
if (!defined_default(array)) {
throw new DeveloperError_default("array is required");
}
startingIndex = defaultValue_default(startingIndex, 0);
if (!defined_default(result)) {
result = new DistanceDisplayCondition();
}
result.near = array[startingIndex++];
result.far = array[startingIndex];
return result;
};
DistanceDisplayCondition.equals = function(left, right) {
return left === right || defined_default(left) && defined_default(right) && left.near === right.near && left.far === right.far;
};
DistanceDisplayCondition.clone = function(value, result) {
if (!defined_default(value)) {
return void 0;
}
if (!defined_default(result)) {
result = new DistanceDisplayCondition();
}
result.near = value.near;
result.far = value.far;
return result;
};
DistanceDisplayCondition.prototype.clone = function(result) {
return DistanceDisplayCondition.clone(this, result);
};
DistanceDisplayCondition.prototype.equals = function(other) {
return DistanceDisplayCondition.equals(this, other);
};
var DistanceDisplayCondition_default = DistanceDisplayCondition;
// Source/Core/DistanceDisplayConditionGeometryInstanceAttribute.js
function DistanceDisplayConditionGeometryInstanceAttribute(near, far) {
near = defaultValue_default(near, 0);
far = defaultValue_default(far, Number.MAX_VALUE);
if (far <= near) {
throw new DeveloperError_default(
"far distance must be greater than near distance."
);
}
this.value = new Float32Array([near, far]);
}
Object.defineProperties(
DistanceDisplayConditionGeometryInstanceAttribute.prototype,
{
componentDatatype: {
get: function() {
return ComponentDatatype_default.FLOAT;
}
},
componentsPerAttribute: {
get: function() {
return 2;
}
},
normalize: {
get: function() {
return false;
}
}
}
);
DistanceDisplayConditionGeometryInstanceAttribute.fromDistanceDisplayCondition = function(distanceDisplayCondition) {
if (!defined_default(distanceDisplayCondition)) {
throw new DeveloperError_default("distanceDisplayCondition is required.");
}
if (distanceDisplayCondition.far <= distanceDisplayCondition.near) {
throw new DeveloperError_default(
"distanceDisplayCondition.far distance must be greater than distanceDisplayCondition.near distance."
);
}
return new DistanceDisplayConditionGeometryInstanceAttribute(
distanceDisplayCondition.near,
distanceDisplayCondition.far
);
};
DistanceDisplayConditionGeometryInstanceAttribute.toValue = function(distanceDisplayCondition, result) {
if (!defined_default(distanceDisplayCondition)) {
throw new DeveloperError_default("distanceDisplayCondition is required.");
}
if (!defined_default(result)) {
return new Float32Array([
distanceDisplayCondition.near,
distanceDisplayCondition.far
]);
}
result[0] = distanceDisplayCondition.near;
result[1] = distanceDisplayCondition.far;
return result;
};
var DistanceDisplayConditionGeometryInstanceAttribute_default = DistanceDisplayConditionGeometryInstanceAttribute;
// Source/Core/DoubleEndedPriorityQueue.js
function DoubleEndedPriorityQueue(options) {
Check_default.typeOf.object("options", options);
Check_default.defined("options.comparator", options.comparator);
if (defined_default(options.maximumLength)) {
Check_default.typeOf.number.greaterThanOrEquals(
"options.maximumLength",
options.maximumLength,
0
);
}
this._comparator = options.comparator;
this._maximumLength = options.maximumLength;
this._array = defined_default(options.maximumLength) ? new Array(options.maximumLength) : [];
this._length = 0;
}
Object.defineProperties(DoubleEndedPriorityQueue.prototype, {
length: {
get: function() {
return this._length;
}
},
maximumLength: {
get: function() {
return this._maximumLength;
},
set: function(value) {
if (defined_default(value)) {
Check_default.typeOf.number.greaterThanOrEquals("maximumLength", value, 0);
while (this._length > value) {
this.removeMinimum();
}
this._array.length = value;
}
this._maximumLength = value;
}
},
internalArray: {
get: function() {
return this._array;
}
},
comparator: {
get: function() {
return this._comparator;
}
}
});
DoubleEndedPriorityQueue.prototype.clone = function() {
const maximumLength = this._maximumLength;
const comparator = this._comparator;
const array = this._array;
const length3 = this._length;
const result = new DoubleEndedPriorityQueue({
comparator,
maximumLength
});
result._length = length3;
for (let i = 0; i < length3; i++) {
result._array[i] = array[i];
}
return result;
};
DoubleEndedPriorityQueue.prototype.reset = function() {
this._length = 0;
const maximumLength = this._maximumLength;
if (defined_default(maximumLength)) {
for (let i = 0; i < maximumLength; i++) {
this._array[i] = void 0;
}
} else {
this._array.length = 0;
}
};
DoubleEndedPriorityQueue.prototype.resort = function() {
const length3 = this._length;
for (let i = 0; i < length3; i++) {
pushUp(this, i);
}
};
DoubleEndedPriorityQueue.prototype.insert = function(element) {
let removedElement;
const maximumLength = this._maximumLength;
if (defined_default(maximumLength)) {
if (maximumLength === 0) {
return void 0;
} else if (this._length === maximumLength) {
const minimumElement = this._array[0];
if (this._comparator(element, minimumElement) <= 0) {
return element;
}
removedElement = this.removeMinimum();
}
}
const index = this._length;
this._array[index] = element;
this._length++;
pushUp(this, index);
return removedElement;
};
DoubleEndedPriorityQueue.prototype.removeMinimum = function() {
const length3 = this._length;
if (length3 === 0) {
return void 0;
}
this._length--;
const minimumElement = this._array[0];
if (length3 >= 2) {
this._array[0] = this._array[length3 - 1];
pushDown(this, 0);
}
this._array[length3 - 1] = void 0;
return minimumElement;
};
DoubleEndedPriorityQueue.prototype.removeMaximum = function() {
const length3 = this._length;
if (length3 === 0) {
return void 0;
}
this._length--;
let maximumElement;
if (length3 <= 2) {
maximumElement = this._array[length3 - 1];
} else {
const maximumElementIndex = greaterThan(this, 1, 2) ? 1 : 2;
maximumElement = this._array[maximumElementIndex];
this._array[maximumElementIndex] = this._array[length3 - 1];
if (length3 >= 4) {
pushDown(this, maximumElementIndex);
}
}
this._array[length3 - 1] = void 0;
return maximumElement;
};
DoubleEndedPriorityQueue.prototype.getMinimum = function() {
const length3 = this._length;
if (length3 === 0) {
return void 0;
}
return this._array[0];
};
DoubleEndedPriorityQueue.prototype.getMaximum = function() {
const length3 = this._length;
if (length3 === 0) {
return void 0;
}
if (length3 <= 2) {
return this._array[length3 - 1];
}
return this._array[greaterThan(this, 1, 2) ? 1 : 2];
};
function swap2(that, indexA, indexB) {
const array = that._array;
const temp = array[indexA];
array[indexA] = array[indexB];
array[indexB] = temp;
}
function lessThan(that, indexA, indexB) {
return that._comparator(that._array[indexA], that._array[indexB]) < 0;
}
function greaterThan(that, indexA, indexB) {
return that._comparator(that._array[indexA], that._array[indexB]) > 0;
}
function pushUp(that, index) {
if (index === 0) {
return;
}
const onMinLevel = Math.floor(Math_default.log2(index + 1)) % 2 === 0;
const parentIndex = Math.floor((index - 1) / 2);
const lessThanParent = lessThan(that, index, parentIndex);
if (lessThanParent !== onMinLevel) {
swap2(that, index, parentIndex);
index = parentIndex;
}
while (index >= 3) {
const grandparentIndex = Math.floor((index - 3) / 4);
if (lessThan(that, index, grandparentIndex) !== lessThanParent) {
break;
}
swap2(that, index, grandparentIndex);
index = grandparentIndex;
}
}
function pushDown(that, index) {
const length3 = that._length;
const onMinLevel = Math.floor(Math_default.log2(index + 1)) % 2 === 0;
let leftChildIndex;
while ((leftChildIndex = 2 * index + 1) < length3) {
let target = leftChildIndex;
const rightChildIndex = leftChildIndex + 1;
if (rightChildIndex < length3) {
if (lessThan(that, rightChildIndex, target) === onMinLevel) {
target = rightChildIndex;
}
const grandChildStart = 2 * leftChildIndex + 1;
const grandChildCount = Math.max(
Math.min(length3 - grandChildStart, 4),
0
);
for (let i = 0; i < grandChildCount; i++) {
const grandChildIndex = grandChildStart + i;
if (lessThan(that, grandChildIndex, target) === onMinLevel) {
target = grandChildIndex;
}
}
}
if (lessThan(that, target, index) === onMinLevel) {
swap2(that, target, index);
if (target !== leftChildIndex && target !== rightChildIndex) {
const parentOfGrandchildIndex = Math.floor((target - 1) / 2);
if (greaterThan(that, target, parentOfGrandchildIndex) === onMinLevel) {
swap2(that, target, parentOfGrandchildIndex);
}
}
}
index = target;
}
}
var DoubleEndedPriorityQueue_default = DoubleEndedPriorityQueue;
// Source/Core/DoublyLinkedList.js
function DoublyLinkedList() {
this.head = void 0;
this.tail = void 0;
this._length = 0;
}
Object.defineProperties(DoublyLinkedList.prototype, {
length: {
get: function() {
return this._length;
}
}
});
function DoublyLinkedListNode(item, previous, next) {
this.item = item;
this.previous = previous;
this.next = next;
}
DoublyLinkedList.prototype.add = function(item) {
const node = new DoublyLinkedListNode(item, this.tail, void 0);
if (defined_default(this.tail)) {
this.tail.next = node;
this.tail = node;
} else {
this.head = node;
this.tail = node;
}
++this._length;
return node;
};
function remove(list, node) {
if (defined_default(node.previous) && defined_default(node.next)) {
node.previous.next = node.next;
node.next.previous = node.previous;
} else if (defined_default(node.previous)) {
node.previous.next = void 0;
list.tail = node.previous;
} else if (defined_default(node.next)) {
node.next.previous = void 0;
list.head = node.next;
} else {
list.head = void 0;
list.tail = void 0;
}
node.next = void 0;
node.previous = void 0;
}
DoublyLinkedList.prototype.remove = function(node) {
if (!defined_default(node)) {
return;
}
remove(this, node);
--this._length;
};
DoublyLinkedList.prototype.splice = function(node, nextNode) {
if (node === nextNode) {
return;
}
remove(this, nextNode);
const oldNodeNext = node.next;
node.next = nextNode;
if (this.tail === node) {
this.tail = nextNode;
} else {
oldNodeNext.previous = nextNode;
}
nextNode.next = oldNodeNext;
nextNode.previous = node;
};
var DoublyLinkedList_default = DoublyLinkedList;
// Source/ThirdParty/Tween.js
var import_tween = __toESM(require_Tween(), 1);
// Source/Core/EasingFunction.js
var EasingFunction = {
LINEAR_NONE: import_tween.default.Easing.Linear.None,
QUADRATIC_IN: import_tween.default.Easing.Quadratic.In,
QUADRATIC_OUT: import_tween.default.Easing.Quadratic.Out,
QUADRATIC_IN_OUT: import_tween.default.Easing.Quadratic.InOut,
CUBIC_IN: import_tween.default.Easing.Cubic.In,
CUBIC_OUT: import_tween.default.Easing.Cubic.Out,
CUBIC_IN_OUT: import_tween.default.Easing.Cubic.InOut,
QUARTIC_IN: import_tween.default.Easing.Quartic.In,
QUARTIC_OUT: import_tween.default.Easing.Quartic.Out,
QUARTIC_IN_OUT: import_tween.default.Easing.Quartic.InOut,
QUINTIC_IN: import_tween.default.Easing.Quintic.In,
QUINTIC_OUT: import_tween.default.Easing.Quintic.Out,
QUINTIC_IN_OUT: import_tween.default.Easing.Quintic.InOut,
SINUSOIDAL_IN: import_tween.default.Easing.Sinusoidal.In,
SINUSOIDAL_OUT: import_tween.default.Easing.Sinusoidal.Out,
SINUSOIDAL_IN_OUT: import_tween.default.Easing.Sinusoidal.InOut,
EXPONENTIAL_IN: import_tween.default.Easing.Exponential.In,
EXPONENTIAL_OUT: import_tween.default.Easing.Exponential.Out,
EXPONENTIAL_IN_OUT: import_tween.default.Easing.Exponential.InOut,
CIRCULAR_IN: import_tween.default.Easing.Circular.In,
CIRCULAR_OUT: import_tween.default.Easing.Circular.Out,
CIRCULAR_IN_OUT: import_tween.default.Easing.Circular.InOut,
ELASTIC_IN: import_tween.default.Easing.Elastic.In,
ELASTIC_OUT: import_tween.default.Easing.Elastic.Out,
ELASTIC_IN_OUT: import_tween.default.Easing.Elastic.InOut,
BACK_IN: import_tween.default.Easing.Back.In,
BACK_OUT: import_tween.default.Easing.Back.Out,
BACK_IN_OUT: import_tween.default.Easing.Back.InOut,
BOUNCE_IN: import_tween.default.Easing.Bounce.In,
BOUNCE_OUT: import_tween.default.Easing.Bounce.Out,
BOUNCE_IN_OUT: import_tween.default.Easing.Bounce.InOut
};
var EasingFunction_default = Object.freeze(EasingFunction);
// Source/Core/EllipsoidGeometry.js
var scratchPosition3 = new Cartesian3_default();
var scratchNormal5 = new Cartesian3_default();
var scratchTangent3 = new Cartesian3_default();
var scratchBitangent3 = new Cartesian3_default();
var scratchNormalST = new Cartesian3_default();
var defaultRadii = new Cartesian3_default(1, 1, 1);
var cos = Math.cos;
var sin = Math.sin;
function EllipsoidGeometry(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
const radii = defaultValue_default(options.radii, defaultRadii);
const innerRadii = defaultValue_default(options.innerRadii, radii);
const minimumClock = defaultValue_default(options.minimumClock, 0);
const maximumClock = defaultValue_default(options.maximumClock, Math_default.TWO_PI);
const minimumCone = defaultValue_default(options.minimumCone, 0);
const maximumCone = defaultValue_default(options.maximumCone, Math_default.PI);
const stackPartitions = Math.round(defaultValue_default(options.stackPartitions, 64));
const slicePartitions = Math.round(defaultValue_default(options.slicePartitions, 64));
const vertexFormat = defaultValue_default(options.vertexFormat, VertexFormat_default.DEFAULT);
if (slicePartitions < 3) {
throw new DeveloperError_default(
"options.slicePartitions cannot be less than three."
);
}
if (stackPartitions < 3) {
throw new DeveloperError_default(
"options.stackPartitions cannot be less than three."
);
}
this._radii = Cartesian3_default.clone(radii);
this._innerRadii = Cartesian3_default.clone(innerRadii);
this._minimumClock = minimumClock;
this._maximumClock = maximumClock;
this._minimumCone = minimumCone;
this._maximumCone = maximumCone;
this._stackPartitions = stackPartitions;
this._slicePartitions = slicePartitions;
this._vertexFormat = VertexFormat_default.clone(vertexFormat);
this._offsetAttribute = options.offsetAttribute;
this._workerName = "createEllipsoidGeometry";
}
EllipsoidGeometry.packedLength = 2 * Cartesian3_default.packedLength + VertexFormat_default.packedLength + 7;
EllipsoidGeometry.pack = function(value, array, startingIndex) {
if (!defined_default(value)) {
throw new DeveloperError_default("value is required");
}
if (!defined_default(array)) {
throw new DeveloperError_default("array is required");
}
startingIndex = defaultValue_default(startingIndex, 0);
Cartesian3_default.pack(value._radii, array, startingIndex);
startingIndex += Cartesian3_default.packedLength;
Cartesian3_default.pack(value._innerRadii, array, startingIndex);
startingIndex += Cartesian3_default.packedLength;
VertexFormat_default.pack(value._vertexFormat, array, startingIndex);
startingIndex += VertexFormat_default.packedLength;
array[startingIndex++] = value._minimumClock;
array[startingIndex++] = value._maximumClock;
array[startingIndex++] = value._minimumCone;
array[startingIndex++] = value._maximumCone;
array[startingIndex++] = value._stackPartitions;
array[startingIndex++] = value._slicePartitions;
array[startingIndex] = defaultValue_default(value._offsetAttribute, -1);
return array;
};
var scratchRadii = new Cartesian3_default();
var scratchInnerRadii = new Cartesian3_default();
var scratchVertexFormat6 = new VertexFormat_default();
var scratchOptions13 = {
radii: scratchRadii,
innerRadii: scratchInnerRadii,
vertexFormat: scratchVertexFormat6,
minimumClock: void 0,
maximumClock: void 0,
minimumCone: void 0,
maximumCone: void 0,
stackPartitions: void 0,
slicePartitions: void 0,
offsetAttribute: void 0
};
EllipsoidGeometry.unpack = function(array, startingIndex, result) {
if (!defined_default(array)) {
throw new DeveloperError_default("array is required");
}
startingIndex = defaultValue_default(startingIndex, 0);
const radii = Cartesian3_default.unpack(array, startingIndex, scratchRadii);
startingIndex += Cartesian3_default.packedLength;
const innerRadii = Cartesian3_default.unpack(array, startingIndex, scratchInnerRadii);
startingIndex += Cartesian3_default.packedLength;
const vertexFormat = VertexFormat_default.unpack(
array,
startingIndex,
scratchVertexFormat6
);
startingIndex += VertexFormat_default.packedLength;
const minimumClock = array[startingIndex++];
const maximumClock = array[startingIndex++];
const minimumCone = array[startingIndex++];
const maximumCone = array[startingIndex++];
const stackPartitions = array[startingIndex++];
const slicePartitions = array[startingIndex++];
const offsetAttribute = array[startingIndex];
if (!defined_default(result)) {
scratchOptions13.minimumClock = minimumClock;
scratchOptions13.maximumClock = maximumClock;
scratchOptions13.minimumCone = minimumCone;
scratchOptions13.maximumCone = maximumCone;
scratchOptions13.stackPartitions = stackPartitions;
scratchOptions13.slicePartitions = slicePartitions;
scratchOptions13.offsetAttribute = offsetAttribute === -1 ? void 0 : offsetAttribute;
return new EllipsoidGeometry(scratchOptions13);
}
result._radii = Cartesian3_default.clone(radii, result._radii);
result._innerRadii = Cartesian3_default.clone(innerRadii, result._innerRadii);
result._vertexFormat = VertexFormat_default.clone(vertexFormat, result._vertexFormat);
result._minimumClock = minimumClock;
result._maximumClock = maximumClock;
result._minimumCone = minimumCone;
result._maximumCone = maximumCone;
result._stackPartitions = stackPartitions;
result._slicePartitions = slicePartitions;
result._offsetAttribute = offsetAttribute === -1 ? void 0 : offsetAttribute;
return result;
};
EllipsoidGeometry.createGeometry = function(ellipsoidGeometry) {
const radii = ellipsoidGeometry._radii;
if (radii.x <= 0 || radii.y <= 0 || radii.z <= 0) {
return;
}
const innerRadii = ellipsoidGeometry._innerRadii;
if (innerRadii.x <= 0 || innerRadii.y <= 0 || innerRadii.z <= 0) {
return;
}
const minimumClock = ellipsoidGeometry._minimumClock;
const maximumClock = ellipsoidGeometry._maximumClock;
const minimumCone = ellipsoidGeometry._minimumCone;
const maximumCone = ellipsoidGeometry._maximumCone;
const vertexFormat = ellipsoidGeometry._vertexFormat;
let slicePartitions = ellipsoidGeometry._slicePartitions + 1;
let stackPartitions = ellipsoidGeometry._stackPartitions + 1;
slicePartitions = Math.round(
slicePartitions * Math.abs(maximumClock - minimumClock) / Math_default.TWO_PI
);
stackPartitions = Math.round(
stackPartitions * Math.abs(maximumCone - minimumCone) / Math_default.PI
);
if (slicePartitions < 2) {
slicePartitions = 2;
}
if (stackPartitions < 2) {
stackPartitions = 2;
}
let i;
let j;
let index = 0;
const phis = [minimumCone];
const thetas = [minimumClock];
for (i = 0; i < stackPartitions; i++) {
phis.push(
minimumCone + i * (maximumCone - minimumCone) / (stackPartitions - 1)
);
}
phis.push(maximumCone);
for (j = 0; j < slicePartitions; j++) {
thetas.push(
minimumClock + j * (maximumClock - minimumClock) / (slicePartitions - 1)
);
}
thetas.push(maximumClock);
const numPhis = phis.length;
const numThetas = thetas.length;
let extraIndices = 0;
let vertexMultiplier = 1;
const hasInnerSurface = innerRadii.x !== radii.x || innerRadii.y !== radii.y || innerRadii.z !== radii.z;
let isTopOpen = false;
let isBotOpen = false;
let isClockOpen = false;
if (hasInnerSurface) {
vertexMultiplier = 2;
if (minimumCone > 0) {
isTopOpen = true;
extraIndices += slicePartitions - 1;
}
if (maximumCone < Math.PI) {
isBotOpen = true;
extraIndices += slicePartitions - 1;
}
if ((maximumClock - minimumClock) % Math_default.TWO_PI) {
isClockOpen = true;
extraIndices += (stackPartitions - 1) * 2 + 1;
} else {
extraIndices += 1;
}
}
const vertexCount = numThetas * numPhis * vertexMultiplier;
const positions = new Float64Array(vertexCount * 3);
const isInner = new Array(vertexCount).fill(false);
const negateNormal = new Array(vertexCount).fill(false);
const indexCount = slicePartitions * stackPartitions * vertexMultiplier;
const numIndices = 6 * (indexCount + extraIndices + 1 - (slicePartitions + stackPartitions) * vertexMultiplier);
const indices2 = IndexDatatype_default.createTypedArray(indexCount, numIndices);
const normals = vertexFormat.normal ? new Float32Array(vertexCount * 3) : void 0;
const tangents = vertexFormat.tangent ? new Float32Array(vertexCount * 3) : void 0;
const bitangents = vertexFormat.bitangent ? new Float32Array(vertexCount * 3) : void 0;
const st = vertexFormat.st ? new Float32Array(vertexCount * 2) : void 0;
const sinPhi = new Array(numPhis);
const cosPhi = new Array(numPhis);
for (i = 0; i < numPhis; i++) {
sinPhi[i] = sin(phis[i]);
cosPhi[i] = cos(phis[i]);
}
const sinTheta = new Array(numThetas);
const cosTheta = new Array(numThetas);
for (j = 0; j < numThetas; j++) {
cosTheta[j] = cos(thetas[j]);
sinTheta[j] = sin(thetas[j]);
}
for (i = 0; i < numPhis; i++) {
for (j = 0; j < numThetas; j++) {
positions[index++] = radii.x * sinPhi[i] * cosTheta[j];
positions[index++] = radii.y * sinPhi[i] * sinTheta[j];
positions[index++] = radii.z * cosPhi[i];
}
}
let vertexIndex = vertexCount / 2;
if (hasInnerSurface) {
for (i = 0; i < numPhis; i++) {
for (j = 0; j < numThetas; j++) {
positions[index++] = innerRadii.x * sinPhi[i] * cosTheta[j];
positions[index++] = innerRadii.y * sinPhi[i] * sinTheta[j];
positions[index++] = innerRadii.z * cosPhi[i];
isInner[vertexIndex] = true;
if (i > 0 && i !== numPhis - 1 && j !== 0 && j !== numThetas - 1) {
negateNormal[vertexIndex] = true;
}
vertexIndex++;
}
}
}
index = 0;
let topOffset;
let bottomOffset;
for (i = 1; i < numPhis - 2; i++) {
topOffset = i * numThetas;
bottomOffset = (i + 1) * numThetas;
for (j = 1; j < numThetas - 2; j++) {
indices2[index++] = bottomOffset + j;
indices2[index++] = bottomOffset + j + 1;
indices2[index++] = topOffset + j + 1;
indices2[index++] = bottomOffset + j;
indices2[index++] = topOffset + j + 1;
indices2[index++] = topOffset + j;
}
}
if (hasInnerSurface) {
const offset2 = numPhis * numThetas;
for (i = 1; i < numPhis - 2; i++) {
topOffset = offset2 + i * numThetas;
bottomOffset = offset2 + (i + 1) * numThetas;
for (j = 1; j < numThetas - 2; j++) {
indices2[index++] = bottomOffset + j;
indices2[index++] = topOffset + j;
indices2[index++] = topOffset + j + 1;
indices2[index++] = bottomOffset + j;
indices2[index++] = topOffset + j + 1;
indices2[index++] = bottomOffset + j + 1;
}
}
}
let outerOffset;
let innerOffset;
if (hasInnerSurface) {
if (isTopOpen) {
innerOffset = numPhis * numThetas;
for (i = 1; i < numThetas - 2; i++) {
indices2[index++] = i;
indices2[index++] = i + 1;
indices2[index++] = innerOffset + i + 1;
indices2[index++] = i;
indices2[index++] = innerOffset + i + 1;
indices2[index++] = innerOffset + i;
}
}
if (isBotOpen) {
outerOffset = numPhis * numThetas - numThetas;
innerOffset = numPhis * numThetas * vertexMultiplier - numThetas;
for (i = 1; i < numThetas - 2; i++) {
indices2[index++] = outerOffset + i + 1;
indices2[index++] = outerOffset + i;
indices2[index++] = innerOffset + i;
indices2[index++] = outerOffset + i + 1;
indices2[index++] = innerOffset + i;
indices2[index++] = innerOffset + i + 1;
}
}
}
if (isClockOpen) {
for (i = 1; i < numPhis - 2; i++) {
innerOffset = numThetas * numPhis + numThetas * i;
outerOffset = numThetas * i;
indices2[index++] = innerOffset;
indices2[index++] = outerOffset + numThetas;
indices2[index++] = outerOffset;
indices2[index++] = innerOffset;
indices2[index++] = innerOffset + numThetas;
indices2[index++] = outerOffset + numThetas;
}
for (i = 1; i < numPhis - 2; i++) {
innerOffset = numThetas * numPhis + numThetas * (i + 1) - 1;
outerOffset = numThetas * (i + 1) - 1;
indices2[index++] = outerOffset + numThetas;
indices2[index++] = innerOffset;
indices2[index++] = outerOffset;
indices2[index++] = outerOffset + numThetas;
indices2[index++] = innerOffset + numThetas;
indices2[index++] = innerOffset;
}
}
const attributes = new GeometryAttributes_default();
if (vertexFormat.position) {
attributes.position = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.DOUBLE,
componentsPerAttribute: 3,
values: positions
});
}
let stIndex = 0;
let normalIndex = 0;
let tangentIndex = 0;
let bitangentIndex = 0;
const vertexCountHalf = vertexCount / 2;
let ellipsoid;
const ellipsoidOuter = Ellipsoid_default.fromCartesian3(radii);
const ellipsoidInner = Ellipsoid_default.fromCartesian3(innerRadii);
if (vertexFormat.st || vertexFormat.normal || vertexFormat.tangent || vertexFormat.bitangent) {
for (i = 0; i < vertexCount; i++) {
ellipsoid = isInner[i] ? ellipsoidInner : ellipsoidOuter;
const position = Cartesian3_default.fromArray(positions, i * 3, scratchPosition3);
const normal2 = ellipsoid.geodeticSurfaceNormal(position, scratchNormal5);
if (negateNormal[i]) {
Cartesian3_default.negate(normal2, normal2);
}
if (vertexFormat.st) {
const normalST = Cartesian2_default.negate(normal2, scratchNormalST);
st[stIndex++] = Math.atan2(normalST.y, normalST.x) / Math_default.TWO_PI + 0.5;
st[stIndex++] = Math.asin(normal2.z) / Math.PI + 0.5;
}
if (vertexFormat.normal) {
normals[normalIndex++] = normal2.x;
normals[normalIndex++] = normal2.y;
normals[normalIndex++] = normal2.z;
}
if (vertexFormat.tangent || vertexFormat.bitangent) {
const tangent = scratchTangent3;
let tangetOffset = 0;
let unit;
if (isInner[i]) {
tangetOffset = vertexCountHalf;
}
if (!isTopOpen && i >= tangetOffset && i < tangetOffset + numThetas * 2) {
unit = Cartesian3_default.UNIT_X;
} else {
unit = Cartesian3_default.UNIT_Z;
}
Cartesian3_default.cross(unit, normal2, tangent);
Cartesian3_default.normalize(tangent, tangent);
if (vertexFormat.tangent) {
tangents[tangentIndex++] = tangent.x;
tangents[tangentIndex++] = tangent.y;
tangents[tangentIndex++] = tangent.z;
}
if (vertexFormat.bitangent) {
const bitangent = Cartesian3_default.cross(normal2, tangent, scratchBitangent3);
Cartesian3_default.normalize(bitangent, bitangent);
bitangents[bitangentIndex++] = bitangent.x;
bitangents[bitangentIndex++] = bitangent.y;
bitangents[bitangentIndex++] = bitangent.z;
}
}
}
if (vertexFormat.st) {
attributes.st = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.FLOAT,
componentsPerAttribute: 2,
values: st
});
}
if (vertexFormat.normal) {
attributes.normal = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.FLOAT,
componentsPerAttribute: 3,
values: normals
});
}
if (vertexFormat.tangent) {
attributes.tangent = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.FLOAT,
componentsPerAttribute: 3,
values: tangents
});
}
if (vertexFormat.bitangent) {
attributes.bitangent = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.FLOAT,
componentsPerAttribute: 3,
values: bitangents
});
}
}
if (defined_default(ellipsoidGeometry._offsetAttribute)) {
const length3 = positions.length;
const offsetValue = ellipsoidGeometry._offsetAttribute === GeometryOffsetAttribute_default.NONE ? 0 : 1;
const applyOffset = new Uint8Array(length3 / 3).fill(offsetValue);
attributes.applyOffset = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.UNSIGNED_BYTE,
componentsPerAttribute: 1,
values: applyOffset
});
}
return new Geometry_default({
attributes,
indices: indices2,
primitiveType: PrimitiveType_default.TRIANGLES,
boundingSphere: BoundingSphere_default.fromEllipsoid(ellipsoidOuter),
offsetAttribute: ellipsoidGeometry._offsetAttribute
});
};
var unitEllipsoidGeometry;
EllipsoidGeometry.getUnitEllipsoid = function() {
if (!defined_default(unitEllipsoidGeometry)) {
unitEllipsoidGeometry = EllipsoidGeometry.createGeometry(
new EllipsoidGeometry({
radii: new Cartesian3_default(1, 1, 1),
vertexFormat: VertexFormat_default.POSITION_ONLY
})
);
}
return unitEllipsoidGeometry;
};
var EllipsoidGeometry_default = EllipsoidGeometry;
// Source/Core/EllipsoidOutlineGeometry.js
var defaultRadii2 = new Cartesian3_default(1, 1, 1);
var cos2 = Math.cos;
var sin2 = Math.sin;
function EllipsoidOutlineGeometry(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
const radii = defaultValue_default(options.radii, defaultRadii2);
const innerRadii = defaultValue_default(options.innerRadii, radii);
const minimumClock = defaultValue_default(options.minimumClock, 0);
const maximumClock = defaultValue_default(options.maximumClock, Math_default.TWO_PI);
const minimumCone = defaultValue_default(options.minimumCone, 0);
const maximumCone = defaultValue_default(options.maximumCone, Math_default.PI);
const stackPartitions = Math.round(defaultValue_default(options.stackPartitions, 10));
const slicePartitions = Math.round(defaultValue_default(options.slicePartitions, 8));
const subdivisions = Math.round(defaultValue_default(options.subdivisions, 128));
if (stackPartitions < 1) {
throw new DeveloperError_default("options.stackPartitions cannot be less than 1");
}
if (slicePartitions < 0) {
throw new DeveloperError_default("options.slicePartitions cannot be less than 0");
}
if (subdivisions < 0) {
throw new DeveloperError_default(
"options.subdivisions must be greater than or equal to zero."
);
}
if (defined_default(options.offsetAttribute) && options.offsetAttribute === GeometryOffsetAttribute_default.TOP) {
throw new DeveloperError_default(
"GeometryOffsetAttribute.TOP is not a supported options.offsetAttribute for this geometry."
);
}
this._radii = Cartesian3_default.clone(radii);
this._innerRadii = Cartesian3_default.clone(innerRadii);
this._minimumClock = minimumClock;
this._maximumClock = maximumClock;
this._minimumCone = minimumCone;
this._maximumCone = maximumCone;
this._stackPartitions = stackPartitions;
this._slicePartitions = slicePartitions;
this._subdivisions = subdivisions;
this._offsetAttribute = options.offsetAttribute;
this._workerName = "createEllipsoidOutlineGeometry";
}
EllipsoidOutlineGeometry.packedLength = 2 * Cartesian3_default.packedLength + 8;
EllipsoidOutlineGeometry.pack = function(value, array, startingIndex) {
if (!defined_default(value)) {
throw new DeveloperError_default("value is required");
}
if (!defined_default(array)) {
throw new DeveloperError_default("array is required");
}
startingIndex = defaultValue_default(startingIndex, 0);
Cartesian3_default.pack(value._radii, array, startingIndex);
startingIndex += Cartesian3_default.packedLength;
Cartesian3_default.pack(value._innerRadii, array, startingIndex);
startingIndex += Cartesian3_default.packedLength;
array[startingIndex++] = value._minimumClock;
array[startingIndex++] = value._maximumClock;
array[startingIndex++] = value._minimumCone;
array[startingIndex++] = value._maximumCone;
array[startingIndex++] = value._stackPartitions;
array[startingIndex++] = value._slicePartitions;
array[startingIndex++] = value._subdivisions;
array[startingIndex] = defaultValue_default(value._offsetAttribute, -1);
return array;
};
var scratchRadii2 = new Cartesian3_default();
var scratchInnerRadii2 = new Cartesian3_default();
var scratchOptions14 = {
radii: scratchRadii2,
innerRadii: scratchInnerRadii2,
minimumClock: void 0,
maximumClock: void 0,
minimumCone: void 0,
maximumCone: void 0,
stackPartitions: void 0,
slicePartitions: void 0,
subdivisions: void 0,
offsetAttribute: void 0
};
EllipsoidOutlineGeometry.unpack = function(array, startingIndex, result) {
if (!defined_default(array)) {
throw new DeveloperError_default("array is required");
}
startingIndex = defaultValue_default(startingIndex, 0);
const radii = Cartesian3_default.unpack(array, startingIndex, scratchRadii2);
startingIndex += Cartesian3_default.packedLength;
const innerRadii = Cartesian3_default.unpack(array, startingIndex, scratchInnerRadii2);
startingIndex += Cartesian3_default.packedLength;
const minimumClock = array[startingIndex++];
const maximumClock = array[startingIndex++];
const minimumCone = array[startingIndex++];
const maximumCone = array[startingIndex++];
const stackPartitions = array[startingIndex++];
const slicePartitions = array[startingIndex++];
const subdivisions = array[startingIndex++];
const offsetAttribute = array[startingIndex];
if (!defined_default(result)) {
scratchOptions14.minimumClock = minimumClock;
scratchOptions14.maximumClock = maximumClock;
scratchOptions14.minimumCone = minimumCone;
scratchOptions14.maximumCone = maximumCone;
scratchOptions14.stackPartitions = stackPartitions;
scratchOptions14.slicePartitions = slicePartitions;
scratchOptions14.subdivisions = subdivisions;
scratchOptions14.offsetAttribute = offsetAttribute === -1 ? void 0 : offsetAttribute;
return new EllipsoidOutlineGeometry(scratchOptions14);
}
result._radii = Cartesian3_default.clone(radii, result._radii);
result._innerRadii = Cartesian3_default.clone(innerRadii, result._innerRadii);
result._minimumClock = minimumClock;
result._maximumClock = maximumClock;
result._minimumCone = minimumCone;
result._maximumCone = maximumCone;
result._stackPartitions = stackPartitions;
result._slicePartitions = slicePartitions;
result._subdivisions = subdivisions;
result._offsetAttribute = offsetAttribute === -1 ? void 0 : offsetAttribute;
return result;
};
EllipsoidOutlineGeometry.createGeometry = function(ellipsoidGeometry) {
const radii = ellipsoidGeometry._radii;
if (radii.x <= 0 || radii.y <= 0 || radii.z <= 0) {
return;
}
const innerRadii = ellipsoidGeometry._innerRadii;
if (innerRadii.x <= 0 || innerRadii.y <= 0 || innerRadii.z <= 0) {
return;
}
const minimumClock = ellipsoidGeometry._minimumClock;
const maximumClock = ellipsoidGeometry._maximumClock;
const minimumCone = ellipsoidGeometry._minimumCone;
const maximumCone = ellipsoidGeometry._maximumCone;
const subdivisions = ellipsoidGeometry._subdivisions;
const ellipsoid = Ellipsoid_default.fromCartesian3(radii);
let slicePartitions = ellipsoidGeometry._slicePartitions + 1;
let stackPartitions = ellipsoidGeometry._stackPartitions + 1;
slicePartitions = Math.round(
slicePartitions * Math.abs(maximumClock - minimumClock) / Math_default.TWO_PI
);
stackPartitions = Math.round(
stackPartitions * Math.abs(maximumCone - minimumCone) / Math_default.PI
);
if (slicePartitions < 2) {
slicePartitions = 2;
}
if (stackPartitions < 2) {
stackPartitions = 2;
}
let extraIndices = 0;
let vertexMultiplier = 1;
const hasInnerSurface = innerRadii.x !== radii.x || innerRadii.y !== radii.y || innerRadii.z !== radii.z;
let isTopOpen = false;
let isBotOpen = false;
if (hasInnerSurface) {
vertexMultiplier = 2;
if (minimumCone > 0) {
isTopOpen = true;
extraIndices += slicePartitions;
}
if (maximumCone < Math.PI) {
isBotOpen = true;
extraIndices += slicePartitions;
}
}
const vertexCount = subdivisions * vertexMultiplier * (stackPartitions + slicePartitions);
const positions = new Float64Array(vertexCount * 3);
const numIndices = 2 * (vertexCount + extraIndices - (slicePartitions + stackPartitions) * vertexMultiplier);
const indices2 = IndexDatatype_default.createTypedArray(vertexCount, numIndices);
let i;
let j;
let theta;
let phi;
let index = 0;
const sinPhi = new Array(stackPartitions);
const cosPhi = new Array(stackPartitions);
for (i = 0; i < stackPartitions; i++) {
phi = minimumCone + i * (maximumCone - minimumCone) / (stackPartitions - 1);
sinPhi[i] = sin2(phi);
cosPhi[i] = cos2(phi);
}
const sinTheta = new Array(subdivisions);
const cosTheta = new Array(subdivisions);
for (i = 0; i < subdivisions; i++) {
theta = minimumClock + i * (maximumClock - minimumClock) / (subdivisions - 1);
sinTheta[i] = sin2(theta);
cosTheta[i] = cos2(theta);
}
for (i = 0; i < stackPartitions; i++) {
for (j = 0; j < subdivisions; j++) {
positions[index++] = radii.x * sinPhi[i] * cosTheta[j];
positions[index++] = radii.y * sinPhi[i] * sinTheta[j];
positions[index++] = radii.z * cosPhi[i];
}
}
if (hasInnerSurface) {
for (i = 0; i < stackPartitions; i++) {
for (j = 0; j < subdivisions; j++) {
positions[index++] = innerRadii.x * sinPhi[i] * cosTheta[j];
positions[index++] = innerRadii.y * sinPhi[i] * sinTheta[j];
positions[index++] = innerRadii.z * cosPhi[i];
}
}
}
sinPhi.length = subdivisions;
cosPhi.length = subdivisions;
for (i = 0; i < subdivisions; i++) {
phi = minimumCone + i * (maximumCone - minimumCone) / (subdivisions - 1);
sinPhi[i] = sin2(phi);
cosPhi[i] = cos2(phi);
}
sinTheta.length = slicePartitions;
cosTheta.length = slicePartitions;
for (i = 0; i < slicePartitions; i++) {
theta = minimumClock + i * (maximumClock - minimumClock) / (slicePartitions - 1);
sinTheta[i] = sin2(theta);
cosTheta[i] = cos2(theta);
}
for (i = 0; i < subdivisions; i++) {
for (j = 0; j < slicePartitions; j++) {
positions[index++] = radii.x * sinPhi[i] * cosTheta[j];
positions[index++] = radii.y * sinPhi[i] * sinTheta[j];
positions[index++] = radii.z * cosPhi[i];
}
}
if (hasInnerSurface) {
for (i = 0; i < subdivisions; i++) {
for (j = 0; j < slicePartitions; j++) {
positions[index++] = innerRadii.x * sinPhi[i] * cosTheta[j];
positions[index++] = innerRadii.y * sinPhi[i] * sinTheta[j];
positions[index++] = innerRadii.z * cosPhi[i];
}
}
}
index = 0;
for (i = 0; i < stackPartitions * vertexMultiplier; i++) {
const topOffset = i * subdivisions;
for (j = 0; j < subdivisions - 1; j++) {
indices2[index++] = topOffset + j;
indices2[index++] = topOffset + j + 1;
}
}
let offset2 = stackPartitions * subdivisions * vertexMultiplier;
for (i = 0; i < slicePartitions; i++) {
for (j = 0; j < subdivisions - 1; j++) {
indices2[index++] = offset2 + i + j * slicePartitions;
indices2[index++] = offset2 + i + (j + 1) * slicePartitions;
}
}
if (hasInnerSurface) {
offset2 = stackPartitions * subdivisions * vertexMultiplier + slicePartitions * subdivisions;
for (i = 0; i < slicePartitions; i++) {
for (j = 0; j < subdivisions - 1; j++) {
indices2[index++] = offset2 + i + j * slicePartitions;
indices2[index++] = offset2 + i + (j + 1) * slicePartitions;
}
}
}
if (hasInnerSurface) {
let outerOffset = stackPartitions * subdivisions * vertexMultiplier;
let innerOffset = outerOffset + subdivisions * slicePartitions;
if (isTopOpen) {
for (i = 0; i < slicePartitions; i++) {
indices2[index++] = outerOffset + i;
indices2[index++] = innerOffset + i;
}
}
if (isBotOpen) {
outerOffset += subdivisions * slicePartitions - slicePartitions;
innerOffset += subdivisions * slicePartitions - slicePartitions;
for (i = 0; i < slicePartitions; i++) {
indices2[index++] = outerOffset + i;
indices2[index++] = innerOffset + i;
}
}
}
const attributes = new GeometryAttributes_default({
position: new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.DOUBLE,
componentsPerAttribute: 3,
values: positions
})
});
if (defined_default(ellipsoidGeometry._offsetAttribute)) {
const length3 = positions.length;
const offsetValue = ellipsoidGeometry._offsetAttribute === GeometryOffsetAttribute_default.NONE ? 0 : 1;
const applyOffset = new Uint8Array(length3 / 3).fill(offsetValue);
attributes.applyOffset = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.UNSIGNED_BYTE,
componentsPerAttribute: 1,
values: applyOffset
});
}
return new Geometry_default({
attributes,
indices: indices2,
primitiveType: PrimitiveType_default.LINES,
boundingSphere: BoundingSphere_default.fromEllipsoid(ellipsoid),
offsetAttribute: ellipsoidGeometry._offsetAttribute
});
};
var EllipsoidOutlineGeometry_default = EllipsoidOutlineGeometry;
// Source/Core/EllipsoidTerrainProvider.js
function EllipsoidTerrainProvider(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
this._tilingScheme = options.tilingScheme;
if (!defined_default(this._tilingScheme)) {
this._tilingScheme = new GeographicTilingScheme_default({
ellipsoid: defaultValue_default(options.ellipsoid, Ellipsoid_default.WGS84)
});
}
this._levelZeroMaximumGeometricError = TerrainProvider_default.getEstimatedLevelZeroGeometricErrorForAHeightmap(
this._tilingScheme.ellipsoid,
64,
this._tilingScheme.getNumberOfXTilesAtLevel(0)
);
this._errorEvent = new Event_default();
this._readyPromise = Promise.resolve(true);
}
Object.defineProperties(EllipsoidTerrainProvider.prototype, {
errorEvent: {
get: function() {
return this._errorEvent;
}
},
credit: {
get: function() {
return void 0;
}
},
tilingScheme: {
get: function() {
return this._tilingScheme;
}
},
ready: {
get: function() {
return true;
}
},
readyPromise: {
get: function() {
return this._readyPromise;
}
},
hasWaterMask: {
get: function() {
return false;
}
},
hasVertexNormals: {
get: function() {
return false;
}
},
availability: {
get: function() {
return void 0;
}
}
});
EllipsoidTerrainProvider.prototype.requestTileGeometry = function(x, y, level, request) {
const width = 16;
const height = 16;
return Promise.resolve(
new HeightmapTerrainData_default({
buffer: new Uint8Array(width * height),
width,
height
})
);
};
EllipsoidTerrainProvider.prototype.getLevelMaximumGeometricError = function(level) {
return this._levelZeroMaximumGeometricError / (1 << level);
};
EllipsoidTerrainProvider.prototype.getTileDataAvailable = function(x, y, level) {
return void 0;
};
EllipsoidTerrainProvider.prototype.loadTileDataAvailability = function(x, y, level) {
return void 0;
};
var EllipsoidTerrainProvider_default = EllipsoidTerrainProvider;
// Source/Core/EventHelper.js
function EventHelper() {
this._removalFunctions = [];
}
EventHelper.prototype.add = function(event, listener, scope) {
if (!defined_default(event)) {
throw new DeveloperError_default("event is required");
}
const removalFunction = event.addEventListener(listener, scope);
this._removalFunctions.push(removalFunction);
const that = this;
return function() {
removalFunction();
const removalFunctions = that._removalFunctions;
removalFunctions.splice(removalFunctions.indexOf(removalFunction), 1);
};
};
EventHelper.prototype.removeAll = function() {
const removalFunctions = this._removalFunctions;
for (let i = 0, len = removalFunctions.length; i < len; ++i) {
removalFunctions[i]();
}
removalFunctions.length = 0;
};
var EventHelper_default = EventHelper;
// Source/Core/ExperimentalFeatures.js
var ExperimentalFeatures = {
enableModelExperimental: false
};
var ExperimentalFeatures_default = ExperimentalFeatures;
// Source/Core/ExtrapolationType.js
var ExtrapolationType = {
NONE: 0,
HOLD: 1,
EXTRAPOLATE: 2
};
var ExtrapolationType_default = Object.freeze(ExtrapolationType);
// Source/Core/OrthographicOffCenterFrustum.js
function OrthographicOffCenterFrustum(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
this.left = options.left;
this._left = void 0;
this.right = options.right;
this._right = void 0;
this.top = options.top;
this._top = void 0;
this.bottom = options.bottom;
this._bottom = void 0;
this.near = defaultValue_default(options.near, 1);
this._near = this.near;
this.far = defaultValue_default(options.far, 5e8);
this._far = this.far;
this._cullingVolume = new CullingVolume_default();
this._orthographicMatrix = new Matrix4_default();
}
function update(frustum) {
if (!defined_default(frustum.right) || !defined_default(frustum.left) || !defined_default(frustum.top) || !defined_default(frustum.bottom) || !defined_default(frustum.near) || !defined_default(frustum.far)) {
throw new DeveloperError_default(
"right, left, top, bottom, near, or far parameters are not set."
);
}
if (frustum.top !== frustum._top || frustum.bottom !== frustum._bottom || frustum.left !== frustum._left || frustum.right !== frustum._right || frustum.near !== frustum._near || frustum.far !== frustum._far) {
if (frustum.left > frustum.right) {
throw new DeveloperError_default("right must be greater than left.");
}
if (frustum.bottom > frustum.top) {
throw new DeveloperError_default("top must be greater than bottom.");
}
if (frustum.near <= 0 || frustum.near > frustum.far) {
throw new DeveloperError_default(
"near must be greater than zero and less than far."
);
}
frustum._left = frustum.left;
frustum._right = frustum.right;
frustum._top = frustum.top;
frustum._bottom = frustum.bottom;
frustum._near = frustum.near;
frustum._far = frustum.far;
frustum._orthographicMatrix = Matrix4_default.computeOrthographicOffCenter(
frustum.left,
frustum.right,
frustum.bottom,
frustum.top,
frustum.near,
frustum.far,
frustum._orthographicMatrix
);
}
}
Object.defineProperties(OrthographicOffCenterFrustum.prototype, {
projectionMatrix: {
get: function() {
update(this);
return this._orthographicMatrix;
}
}
});
var getPlanesRight = new Cartesian3_default();
var getPlanesNearCenter = new Cartesian3_default();
var getPlanesPoint = new Cartesian3_default();
var negateScratch = new Cartesian3_default();
OrthographicOffCenterFrustum.prototype.computeCullingVolume = function(position, direction2, up) {
if (!defined_default(position)) {
throw new DeveloperError_default("position is required.");
}
if (!defined_default(direction2)) {
throw new DeveloperError_default("direction is required.");
}
if (!defined_default(up)) {
throw new DeveloperError_default("up is required.");
}
const planes = this._cullingVolume.planes;
const t = this.top;
const b = this.bottom;
const r = this.right;
const l = this.left;
const n = this.near;
const f = this.far;
const right = Cartesian3_default.cross(direction2, up, getPlanesRight);
Cartesian3_default.normalize(right, right);
const nearCenter = getPlanesNearCenter;
Cartesian3_default.multiplyByScalar(direction2, n, nearCenter);
Cartesian3_default.add(position, nearCenter, nearCenter);
const point = getPlanesPoint;
Cartesian3_default.multiplyByScalar(right, l, point);
Cartesian3_default.add(nearCenter, point, point);
let plane = planes[0];
if (!defined_default(plane)) {
plane = planes[0] = new Cartesian4_default();
}
plane.x = right.x;
plane.y = right.y;
plane.z = right.z;
plane.w = -Cartesian3_default.dot(right, point);
Cartesian3_default.multiplyByScalar(right, r, point);
Cartesian3_default.add(nearCenter, point, point);
plane = planes[1];
if (!defined_default(plane)) {
plane = planes[1] = new Cartesian4_default();
}
plane.x = -right.x;
plane.y = -right.y;
plane.z = -right.z;
plane.w = -Cartesian3_default.dot(Cartesian3_default.negate(right, negateScratch), point);
Cartesian3_default.multiplyByScalar(up, b, point);
Cartesian3_default.add(nearCenter, point, point);
plane = planes[2];
if (!defined_default(plane)) {
plane = planes[2] = new Cartesian4_default();
}
plane.x = up.x;
plane.y = up.y;
plane.z = up.z;
plane.w = -Cartesian3_default.dot(up, point);
Cartesian3_default.multiplyByScalar(up, t, point);
Cartesian3_default.add(nearCenter, point, point);
plane = planes[3];
if (!defined_default(plane)) {
plane = planes[3] = new Cartesian4_default();
}
plane.x = -up.x;
plane.y = -up.y;
plane.z = -up.z;
plane.w = -Cartesian3_default.dot(Cartesian3_default.negate(up, negateScratch), point);
plane = planes[4];
if (!defined_default(plane)) {
plane = planes[4] = new Cartesian4_default();
}
plane.x = direction2.x;
plane.y = direction2.y;
plane.z = direction2.z;
plane.w = -Cartesian3_default.dot(direction2, nearCenter);
Cartesian3_default.multiplyByScalar(direction2, f, point);
Cartesian3_default.add(position, point, point);
plane = planes[5];
if (!defined_default(plane)) {
plane = planes[5] = new Cartesian4_default();
}
plane.x = -direction2.x;
plane.y = -direction2.y;
plane.z = -direction2.z;
plane.w = -Cartesian3_default.dot(Cartesian3_default.negate(direction2, negateScratch), point);
return this._cullingVolume;
};
OrthographicOffCenterFrustum.prototype.getPixelDimensions = function(drawingBufferWidth, drawingBufferHeight, distance2, pixelRatio, result) {
update(this);
if (!defined_default(drawingBufferWidth) || !defined_default(drawingBufferHeight)) {
throw new DeveloperError_default(
"Both drawingBufferWidth and drawingBufferHeight are required."
);
}
if (drawingBufferWidth <= 0) {
throw new DeveloperError_default("drawingBufferWidth must be greater than zero.");
}
if (drawingBufferHeight <= 0) {
throw new DeveloperError_default("drawingBufferHeight must be greater than zero.");
}
if (!defined_default(distance2)) {
throw new DeveloperError_default("distance is required.");
}
if (!defined_default(pixelRatio)) {
throw new DeveloperError_default("pixelRatio is required.");
}
if (pixelRatio <= 0) {
throw new DeveloperError_default("pixelRatio must be greater than zero.");
}
if (!defined_default(result)) {
throw new DeveloperError_default("A result object is required.");
}
const frustumWidth = this.right - this.left;
const frustumHeight = this.top - this.bottom;
const pixelWidth = pixelRatio * frustumWidth / drawingBufferWidth;
const pixelHeight = pixelRatio * frustumHeight / drawingBufferHeight;
result.x = pixelWidth;
result.y = pixelHeight;
return result;
};
OrthographicOffCenterFrustum.prototype.clone = function(result) {
if (!defined_default(result)) {
result = new OrthographicOffCenterFrustum();
}
result.left = this.left;
result.right = this.right;
result.top = this.top;
result.bottom = this.bottom;
result.near = this.near;
result.far = this.far;
result._left = void 0;
result._right = void 0;
result._top = void 0;
result._bottom = void 0;
result._near = void 0;
result._far = void 0;
return result;
};
OrthographicOffCenterFrustum.prototype.equals = function(other) {
return defined_default(other) && other instanceof OrthographicOffCenterFrustum && this.right === other.right && this.left === other.left && this.top === other.top && this.bottom === other.bottom && this.near === other.near && this.far === other.far;
};
OrthographicOffCenterFrustum.prototype.equalsEpsilon = function(other, relativeEpsilon, absoluteEpsilon) {
return other === this || defined_default(other) && other instanceof OrthographicOffCenterFrustum && Math_default.equalsEpsilon(
this.right,
other.right,
relativeEpsilon,
absoluteEpsilon
) && Math_default.equalsEpsilon(
this.left,
other.left,
relativeEpsilon,
absoluteEpsilon
) && Math_default.equalsEpsilon(
this.top,
other.top,
relativeEpsilon,
absoluteEpsilon
) && Math_default.equalsEpsilon(
this.bottom,
other.bottom,
relativeEpsilon,
absoluteEpsilon
) && Math_default.equalsEpsilon(
this.near,
other.near,
relativeEpsilon,
absoluteEpsilon
) && Math_default.equalsEpsilon(
this.far,
other.far,
relativeEpsilon,
absoluteEpsilon
);
};
var OrthographicOffCenterFrustum_default = OrthographicOffCenterFrustum;
// Source/Core/OrthographicFrustum.js
function OrthographicFrustum(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
this._offCenterFrustum = new OrthographicOffCenterFrustum_default();
this.width = options.width;
this._width = void 0;
this.aspectRatio = options.aspectRatio;
this._aspectRatio = void 0;
this.near = defaultValue_default(options.near, 1);
this._near = this.near;
this.far = defaultValue_default(options.far, 5e8);
this._far = this.far;
}
OrthographicFrustum.packedLength = 4;
OrthographicFrustum.pack = function(value, array, startingIndex) {
Check_default.typeOf.object("value", value);
Check_default.defined("array", array);
startingIndex = defaultValue_default(startingIndex, 0);
array[startingIndex++] = value.width;
array[startingIndex++] = value.aspectRatio;
array[startingIndex++] = value.near;
array[startingIndex] = value.far;
return array;
};
OrthographicFrustum.unpack = function(array, startingIndex, result) {
Check_default.defined("array", array);
startingIndex = defaultValue_default(startingIndex, 0);
if (!defined_default(result)) {
result = new OrthographicFrustum();
}
result.width = array[startingIndex++];
result.aspectRatio = array[startingIndex++];
result.near = array[startingIndex++];
result.far = array[startingIndex];
return result;
};
function update2(frustum) {
if (!defined_default(frustum.width) || !defined_default(frustum.aspectRatio) || !defined_default(frustum.near) || !defined_default(frustum.far)) {
throw new DeveloperError_default(
"width, aspectRatio, near, or far parameters are not set."
);
}
const f = frustum._offCenterFrustum;
if (frustum.width !== frustum._width || frustum.aspectRatio !== frustum._aspectRatio || frustum.near !== frustum._near || frustum.far !== frustum._far) {
if (frustum.aspectRatio < 0) {
throw new DeveloperError_default("aspectRatio must be positive.");
}
if (frustum.near < 0 || frustum.near > frustum.far) {
throw new DeveloperError_default(
"near must be greater than zero and less than far."
);
}
frustum._aspectRatio = frustum.aspectRatio;
frustum._width = frustum.width;
frustum._near = frustum.near;
frustum._far = frustum.far;
const ratio = 1 / frustum.aspectRatio;
f.right = frustum.width * 0.5;
f.left = -f.right;
f.top = ratio * f.right;
f.bottom = -f.top;
f.near = frustum.near;
f.far = frustum.far;
}
}
Object.defineProperties(OrthographicFrustum.prototype, {
projectionMatrix: {
get: function() {
update2(this);
return this._offCenterFrustum.projectionMatrix;
}
}
});
OrthographicFrustum.prototype.computeCullingVolume = function(position, direction2, up) {
update2(this);
return this._offCenterFrustum.computeCullingVolume(position, direction2, up);
};
OrthographicFrustum.prototype.getPixelDimensions = function(drawingBufferWidth, drawingBufferHeight, distance2, pixelRatio, result) {
update2(this);
return this._offCenterFrustum.getPixelDimensions(
drawingBufferWidth,
drawingBufferHeight,
distance2,
pixelRatio,
result
);
};
OrthographicFrustum.prototype.clone = function(result) {
if (!defined_default(result)) {
result = new OrthographicFrustum();
}
result.aspectRatio = this.aspectRatio;
result.width = this.width;
result.near = this.near;
result.far = this.far;
result._aspectRatio = void 0;
result._width = void 0;
result._near = void 0;
result._far = void 0;
this._offCenterFrustum.clone(result._offCenterFrustum);
return result;
};
OrthographicFrustum.prototype.equals = function(other) {
if (!defined_default(other) || !(other instanceof OrthographicFrustum)) {
return false;
}
update2(this);
update2(other);
return this.width === other.width && this.aspectRatio === other.aspectRatio && this._offCenterFrustum.equals(other._offCenterFrustum);
};
OrthographicFrustum.prototype.equalsEpsilon = function(other, relativeEpsilon, absoluteEpsilon) {
if (!defined_default(other) || !(other instanceof OrthographicFrustum)) {
return false;
}
update2(this);
update2(other);
return Math_default.equalsEpsilon(
this.width,
other.width,
relativeEpsilon,
absoluteEpsilon
) && Math_default.equalsEpsilon(
this.aspectRatio,
other.aspectRatio,
relativeEpsilon,
absoluteEpsilon
) && this._offCenterFrustum.equalsEpsilon(
other._offCenterFrustum,
relativeEpsilon,
absoluteEpsilon
);
};
var OrthographicFrustum_default = OrthographicFrustum;
// Source/Core/PerspectiveOffCenterFrustum.js
function PerspectiveOffCenterFrustum(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
this.left = options.left;
this._left = void 0;
this.right = options.right;
this._right = void 0;
this.top = options.top;
this._top = void 0;
this.bottom = options.bottom;
this._bottom = void 0;
this.near = defaultValue_default(options.near, 1);
this._near = this.near;
this.far = defaultValue_default(options.far, 5e8);
this._far = this.far;
this._cullingVolume = new CullingVolume_default();
this._perspectiveMatrix = new Matrix4_default();
this._infinitePerspective = new Matrix4_default();
}
function update3(frustum) {
if (!defined_default(frustum.right) || !defined_default(frustum.left) || !defined_default(frustum.top) || !defined_default(frustum.bottom) || !defined_default(frustum.near) || !defined_default(frustum.far)) {
throw new DeveloperError_default(
"right, left, top, bottom, near, or far parameters are not set."
);
}
const t = frustum.top;
const b = frustum.bottom;
const r = frustum.right;
const l = frustum.left;
const n = frustum.near;
const f = frustum.far;
if (t !== frustum._top || b !== frustum._bottom || l !== frustum._left || r !== frustum._right || n !== frustum._near || f !== frustum._far) {
if (frustum.near <= 0 || frustum.near > frustum.far) {
throw new DeveloperError_default(
"near must be greater than zero and less than far."
);
}
frustum._left = l;
frustum._right = r;
frustum._top = t;
frustum._bottom = b;
frustum._near = n;
frustum._far = f;
frustum._perspectiveMatrix = Matrix4_default.computePerspectiveOffCenter(
l,
r,
b,
t,
n,
f,
frustum._perspectiveMatrix
);
frustum._infinitePerspective = Matrix4_default.computeInfinitePerspectiveOffCenter(
l,
r,
b,
t,
n,
frustum._infinitePerspective
);
}
}
Object.defineProperties(PerspectiveOffCenterFrustum.prototype, {
projectionMatrix: {
get: function() {
update3(this);
return this._perspectiveMatrix;
}
},
infiniteProjectionMatrix: {
get: function() {
update3(this);
return this._infinitePerspective;
}
}
});
var getPlanesRight2 = new Cartesian3_default();
var getPlanesNearCenter2 = new Cartesian3_default();
var getPlanesFarCenter = new Cartesian3_default();
var getPlanesNormal = new Cartesian3_default();
PerspectiveOffCenterFrustum.prototype.computeCullingVolume = function(position, direction2, up) {
if (!defined_default(position)) {
throw new DeveloperError_default("position is required.");
}
if (!defined_default(direction2)) {
throw new DeveloperError_default("direction is required.");
}
if (!defined_default(up)) {
throw new DeveloperError_default("up is required.");
}
const planes = this._cullingVolume.planes;
const t = this.top;
const b = this.bottom;
const r = this.right;
const l = this.left;
const n = this.near;
const f = this.far;
const right = Cartesian3_default.cross(direction2, up, getPlanesRight2);
const nearCenter = getPlanesNearCenter2;
Cartesian3_default.multiplyByScalar(direction2, n, nearCenter);
Cartesian3_default.add(position, nearCenter, nearCenter);
const farCenter = getPlanesFarCenter;
Cartesian3_default.multiplyByScalar(direction2, f, farCenter);
Cartesian3_default.add(position, farCenter, farCenter);
const normal2 = getPlanesNormal;
Cartesian3_default.multiplyByScalar(right, l, normal2);
Cartesian3_default.add(nearCenter, normal2, normal2);
Cartesian3_default.subtract(normal2, position, normal2);
Cartesian3_default.normalize(normal2, normal2);
Cartesian3_default.cross(normal2, up, normal2);
Cartesian3_default.normalize(normal2, normal2);
let plane = planes[0];
if (!defined_default(plane)) {
plane = planes[0] = new Cartesian4_default();
}
plane.x = normal2.x;
plane.y = normal2.y;
plane.z = normal2.z;
plane.w = -Cartesian3_default.dot(normal2, position);
Cartesian3_default.multiplyByScalar(right, r, normal2);
Cartesian3_default.add(nearCenter, normal2, normal2);
Cartesian3_default.subtract(normal2, position, normal2);
Cartesian3_default.cross(up, normal2, normal2);
Cartesian3_default.normalize(normal2, normal2);
plane = planes[1];
if (!defined_default(plane)) {
plane = planes[1] = new Cartesian4_default();
}
plane.x = normal2.x;
plane.y = normal2.y;
plane.z = normal2.z;
plane.w = -Cartesian3_default.dot(normal2, position);
Cartesian3_default.multiplyByScalar(up, b, normal2);
Cartesian3_default.add(nearCenter, normal2, normal2);
Cartesian3_default.subtract(normal2, position, normal2);
Cartesian3_default.cross(right, normal2, normal2);
Cartesian3_default.normalize(normal2, normal2);
plane = planes[2];
if (!defined_default(plane)) {
plane = planes[2] = new Cartesian4_default();
}
plane.x = normal2.x;
plane.y = normal2.y;
plane.z = normal2.z;
plane.w = -Cartesian3_default.dot(normal2, position);
Cartesian3_default.multiplyByScalar(up, t, normal2);
Cartesian3_default.add(nearCenter, normal2, normal2);
Cartesian3_default.subtract(normal2, position, normal2);
Cartesian3_default.cross(normal2, right, normal2);
Cartesian3_default.normalize(normal2, normal2);
plane = planes[3];
if (!defined_default(plane)) {
plane = planes[3] = new Cartesian4_default();
}
plane.x = normal2.x;
plane.y = normal2.y;
plane.z = normal2.z;
plane.w = -Cartesian3_default.dot(normal2, position);
plane = planes[4];
if (!defined_default(plane)) {
plane = planes[4] = new Cartesian4_default();
}
plane.x = direction2.x;
plane.y = direction2.y;
plane.z = direction2.z;
plane.w = -Cartesian3_default.dot(direction2, nearCenter);
Cartesian3_default.negate(direction2, normal2);
plane = planes[5];
if (!defined_default(plane)) {
plane = planes[5] = new Cartesian4_default();
}
plane.x = normal2.x;
plane.y = normal2.y;
plane.z = normal2.z;
plane.w = -Cartesian3_default.dot(normal2, farCenter);
return this._cullingVolume;
};
PerspectiveOffCenterFrustum.prototype.getPixelDimensions = function(drawingBufferWidth, drawingBufferHeight, distance2, pixelRatio, result) {
update3(this);
if (!defined_default(drawingBufferWidth) || !defined_default(drawingBufferHeight)) {
throw new DeveloperError_default(
"Both drawingBufferWidth and drawingBufferHeight are required."
);
}
if (drawingBufferWidth <= 0) {
throw new DeveloperError_default("drawingBufferWidth must be greater than zero.");
}
if (drawingBufferHeight <= 0) {
throw new DeveloperError_default("drawingBufferHeight must be greater than zero.");
}
if (!defined_default(distance2)) {
throw new DeveloperError_default("distance is required.");
}
if (!defined_default(pixelRatio)) {
throw new DeveloperError_default("pixelRatio is required");
}
if (pixelRatio <= 0) {
throw new DeveloperError_default("pixelRatio must be greater than zero.");
}
if (!defined_default(result)) {
throw new DeveloperError_default("A result object is required.");
}
const inverseNear = 1 / this.near;
let tanTheta = this.top * inverseNear;
const pixelHeight = 2 * pixelRatio * distance2 * tanTheta / drawingBufferHeight;
tanTheta = this.right * inverseNear;
const pixelWidth = 2 * pixelRatio * distance2 * tanTheta / drawingBufferWidth;
result.x = pixelWidth;
result.y = pixelHeight;
return result;
};
PerspectiveOffCenterFrustum.prototype.clone = function(result) {
if (!defined_default(result)) {
result = new PerspectiveOffCenterFrustum();
}
result.right = this.right;
result.left = this.left;
result.top = this.top;
result.bottom = this.bottom;
result.near = this.near;
result.far = this.far;
result._left = void 0;
result._right = void 0;
result._top = void 0;
result._bottom = void 0;
result._near = void 0;
result._far = void 0;
return result;
};
PerspectiveOffCenterFrustum.prototype.equals = function(other) {
return defined_default(other) && other instanceof PerspectiveOffCenterFrustum && this.right === other.right && this.left === other.left && this.top === other.top && this.bottom === other.bottom && this.near === other.near && this.far === other.far;
};
PerspectiveOffCenterFrustum.prototype.equalsEpsilon = function(other, relativeEpsilon, absoluteEpsilon) {
return other === this || defined_default(other) && other instanceof PerspectiveOffCenterFrustum && Math_default.equalsEpsilon(
this.right,
other.right,
relativeEpsilon,
absoluteEpsilon
) && Math_default.equalsEpsilon(
this.left,
other.left,
relativeEpsilon,
absoluteEpsilon
) && Math_default.equalsEpsilon(
this.top,
other.top,
relativeEpsilon,
absoluteEpsilon
) && Math_default.equalsEpsilon(
this.bottom,
other.bottom,
relativeEpsilon,
absoluteEpsilon
) && Math_default.equalsEpsilon(
this.near,
other.near,
relativeEpsilon,
absoluteEpsilon
) && Math_default.equalsEpsilon(
this.far,
other.far,
relativeEpsilon,
absoluteEpsilon
);
};
var PerspectiveOffCenterFrustum_default = PerspectiveOffCenterFrustum;
// Source/Core/PerspectiveFrustum.js
function PerspectiveFrustum(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
this._offCenterFrustum = new PerspectiveOffCenterFrustum_default();
this.fov = options.fov;
this._fov = void 0;
this._fovy = void 0;
this._sseDenominator = void 0;
this.aspectRatio = options.aspectRatio;
this._aspectRatio = void 0;
this.near = defaultValue_default(options.near, 1);
this._near = this.near;
this.far = defaultValue_default(options.far, 5e8);
this._far = this.far;
this.xOffset = defaultValue_default(options.xOffset, 0);
this._xOffset = this.xOffset;
this.yOffset = defaultValue_default(options.yOffset, 0);
this._yOffset = this.yOffset;
}
PerspectiveFrustum.packedLength = 6;
PerspectiveFrustum.pack = function(value, array, startingIndex) {
Check_default.typeOf.object("value", value);
Check_default.defined("array", array);
startingIndex = defaultValue_default(startingIndex, 0);
array[startingIndex++] = value.fov;
array[startingIndex++] = value.aspectRatio;
array[startingIndex++] = value.near;
array[startingIndex++] = value.far;
array[startingIndex++] = value.xOffset;
array[startingIndex] = value.yOffset;
return array;
};
PerspectiveFrustum.unpack = function(array, startingIndex, result) {
Check_default.defined("array", array);
startingIndex = defaultValue_default(startingIndex, 0);
if (!defined_default(result)) {
result = new PerspectiveFrustum();
}
result.fov = array[startingIndex++];
result.aspectRatio = array[startingIndex++];
result.near = array[startingIndex++];
result.far = array[startingIndex++];
result.xOffset = array[startingIndex++];
result.yOffset = array[startingIndex];
return result;
};
function update4(frustum) {
if (!defined_default(frustum.fov) || !defined_default(frustum.aspectRatio) || !defined_default(frustum.near) || !defined_default(frustum.far)) {
throw new DeveloperError_default(
"fov, aspectRatio, near, or far parameters are not set."
);
}
const f = frustum._offCenterFrustum;
if (frustum.fov !== frustum._fov || frustum.aspectRatio !== frustum._aspectRatio || frustum.near !== frustum._near || frustum.far !== frustum._far || frustum.xOffset !== frustum._xOffset || frustum.yOffset !== frustum._yOffset) {
if (frustum.fov < 0 || frustum.fov >= Math.PI) {
throw new DeveloperError_default("fov must be in the range [0, PI).");
}
if (frustum.aspectRatio < 0) {
throw new DeveloperError_default("aspectRatio must be positive.");
}
if (frustum.near < 0 || frustum.near > frustum.far) {
throw new DeveloperError_default(
"near must be greater than zero and less than far."
);
}
frustum._aspectRatio = frustum.aspectRatio;
frustum._fov = frustum.fov;
frustum._fovy = frustum.aspectRatio <= 1 ? frustum.fov : Math.atan(Math.tan(frustum.fov * 0.5) / frustum.aspectRatio) * 2;
frustum._near = frustum.near;
frustum._far = frustum.far;
frustum._sseDenominator = 2 * Math.tan(0.5 * frustum._fovy);
frustum._xOffset = frustum.xOffset;
frustum._yOffset = frustum.yOffset;
f.top = frustum.near * Math.tan(0.5 * frustum._fovy);
f.bottom = -f.top;
f.right = frustum.aspectRatio * f.top;
f.left = -f.right;
f.near = frustum.near;
f.far = frustum.far;
f.right += frustum.xOffset;
f.left += frustum.xOffset;
f.top += frustum.yOffset;
f.bottom += frustum.yOffset;
}
}
Object.defineProperties(PerspectiveFrustum.prototype, {
projectionMatrix: {
get: function() {
update4(this);
return this._offCenterFrustum.projectionMatrix;
}
},
infiniteProjectionMatrix: {
get: function() {
update4(this);
return this._offCenterFrustum.infiniteProjectionMatrix;
}
},
fovy: {
get: function() {
update4(this);
return this._fovy;
}
},
sseDenominator: {
get: function() {
update4(this);
return this._sseDenominator;
}
}
});
PerspectiveFrustum.prototype.computeCullingVolume = function(position, direction2, up) {
update4(this);
return this._offCenterFrustum.computeCullingVolume(position, direction2, up);
};
PerspectiveFrustum.prototype.getPixelDimensions = function(drawingBufferWidth, drawingBufferHeight, distance2, pixelRatio, result) {
update4(this);
return this._offCenterFrustum.getPixelDimensions(
drawingBufferWidth,
drawingBufferHeight,
distance2,
pixelRatio,
result
);
};
PerspectiveFrustum.prototype.clone = function(result) {
if (!defined_default(result)) {
result = new PerspectiveFrustum();
}
result.aspectRatio = this.aspectRatio;
result.fov = this.fov;
result.near = this.near;
result.far = this.far;
result._aspectRatio = void 0;
result._fov = void 0;
result._near = void 0;
result._far = void 0;
this._offCenterFrustum.clone(result._offCenterFrustum);
return result;
};
PerspectiveFrustum.prototype.equals = function(other) {
if (!defined_default(other) || !(other instanceof PerspectiveFrustum)) {
return false;
}
update4(this);
update4(other);
return this.fov === other.fov && this.aspectRatio === other.aspectRatio && this._offCenterFrustum.equals(other._offCenterFrustum);
};
PerspectiveFrustum.prototype.equalsEpsilon = function(other, relativeEpsilon, absoluteEpsilon) {
if (!defined_default(other) || !(other instanceof PerspectiveFrustum)) {
return false;
}
update4(this);
update4(other);
return Math_default.equalsEpsilon(
this.fov,
other.fov,
relativeEpsilon,
absoluteEpsilon
) && Math_default.equalsEpsilon(
this.aspectRatio,
other.aspectRatio,
relativeEpsilon,
absoluteEpsilon
) && this._offCenterFrustum.equalsEpsilon(
other._offCenterFrustum,
relativeEpsilon,
absoluteEpsilon
);
};
var PerspectiveFrustum_default = PerspectiveFrustum;
// Source/Core/FrustumGeometry.js
var PERSPECTIVE = 0;
var ORTHOGRAPHIC = 1;
function FrustumGeometry(options) {
Check_default.typeOf.object("options", options);
Check_default.typeOf.object("options.frustum", options.frustum);
Check_default.typeOf.object("options.origin", options.origin);
Check_default.typeOf.object("options.orientation", options.orientation);
const frustum = options.frustum;
const orientation = options.orientation;
const origin = options.origin;
const vertexFormat = defaultValue_default(options.vertexFormat, VertexFormat_default.DEFAULT);
const drawNearPlane = defaultValue_default(options._drawNearPlane, true);
let frustumType;
let frustumPackedLength;
if (frustum instanceof PerspectiveFrustum_default) {
frustumType = PERSPECTIVE;
frustumPackedLength = PerspectiveFrustum_default.packedLength;
} else if (frustum instanceof OrthographicFrustum_default) {
frustumType = ORTHOGRAPHIC;
frustumPackedLength = OrthographicFrustum_default.packedLength;
}
this._frustumType = frustumType;
this._frustum = frustum.clone();
this._origin = Cartesian3_default.clone(origin);
this._orientation = Quaternion_default.clone(orientation);
this._drawNearPlane = drawNearPlane;
this._vertexFormat = vertexFormat;
this._workerName = "createFrustumGeometry";
this.packedLength = 2 + frustumPackedLength + Cartesian3_default.packedLength + Quaternion_default.packedLength + VertexFormat_default.packedLength;
}
FrustumGeometry.pack = function(value, array, startingIndex) {
Check_default.typeOf.object("value", value);
Check_default.defined("array", array);
startingIndex = defaultValue_default(startingIndex, 0);
const frustumType = value._frustumType;
const frustum = value._frustum;
array[startingIndex++] = frustumType;
if (frustumType === PERSPECTIVE) {
PerspectiveFrustum_default.pack(frustum, array, startingIndex);
startingIndex += PerspectiveFrustum_default.packedLength;
} else {
OrthographicFrustum_default.pack(frustum, array, startingIndex);
startingIndex += OrthographicFrustum_default.packedLength;
}
Cartesian3_default.pack(value._origin, array, startingIndex);
startingIndex += Cartesian3_default.packedLength;
Quaternion_default.pack(value._orientation, array, startingIndex);
startingIndex += Quaternion_default.packedLength;
VertexFormat_default.pack(value._vertexFormat, array, startingIndex);
startingIndex += VertexFormat_default.packedLength;
array[startingIndex] = value._drawNearPlane ? 1 : 0;
return array;
};
var scratchPackPerspective = new PerspectiveFrustum_default();
var scratchPackOrthographic = new OrthographicFrustum_default();
var scratchPackQuaternion = new Quaternion_default();
var scratchPackorigin = new Cartesian3_default();
var scratchVertexFormat7 = new VertexFormat_default();
FrustumGeometry.unpack = function(array, startingIndex, result) {
Check_default.defined("array", array);
startingIndex = defaultValue_default(startingIndex, 0);
const frustumType = array[startingIndex++];
let frustum;
if (frustumType === PERSPECTIVE) {
frustum = PerspectiveFrustum_default.unpack(
array,
startingIndex,
scratchPackPerspective
);
startingIndex += PerspectiveFrustum_default.packedLength;
} else {
frustum = OrthographicFrustum_default.unpack(
array,
startingIndex,
scratchPackOrthographic
);
startingIndex += OrthographicFrustum_default.packedLength;
}
const origin = Cartesian3_default.unpack(array, startingIndex, scratchPackorigin);
startingIndex += Cartesian3_default.packedLength;
const orientation = Quaternion_default.unpack(
array,
startingIndex,
scratchPackQuaternion
);
startingIndex += Quaternion_default.packedLength;
const vertexFormat = VertexFormat_default.unpack(
array,
startingIndex,
scratchVertexFormat7
);
startingIndex += VertexFormat_default.packedLength;
const drawNearPlane = array[startingIndex] === 1;
if (!defined_default(result)) {
return new FrustumGeometry({
frustum,
origin,
orientation,
vertexFormat,
_drawNearPlane: drawNearPlane
});
}
const frustumResult = frustumType === result._frustumType ? result._frustum : void 0;
result._frustum = frustum.clone(frustumResult);
result._frustumType = frustumType;
result._origin = Cartesian3_default.clone(origin, result._origin);
result._orientation = Quaternion_default.clone(orientation, result._orientation);
result._vertexFormat = VertexFormat_default.clone(vertexFormat, result._vertexFormat);
result._drawNearPlane = drawNearPlane;
return result;
};
function getAttributes(offset2, normals, tangents, bitangents, st, normal2, tangent, bitangent) {
const stOffset = offset2 / 3 * 2;
for (let i = 0; i < 4; ++i) {
if (defined_default(normals)) {
normals[offset2] = normal2.x;
normals[offset2 + 1] = normal2.y;
normals[offset2 + 2] = normal2.z;
}
if (defined_default(tangents)) {
tangents[offset2] = tangent.x;
tangents[offset2 + 1] = tangent.y;
tangents[offset2 + 2] = tangent.z;
}
if (defined_default(bitangents)) {
bitangents[offset2] = bitangent.x;
bitangents[offset2 + 1] = bitangent.y;
bitangents[offset2 + 2] = bitangent.z;
}
offset2 += 3;
}
st[stOffset] = 0;
st[stOffset + 1] = 0;
st[stOffset + 2] = 1;
st[stOffset + 3] = 0;
st[stOffset + 4] = 1;
st[stOffset + 5] = 1;
st[stOffset + 6] = 0;
st[stOffset + 7] = 1;
}
var scratchRotationMatrix = new Matrix3_default();
var scratchViewMatrix = new Matrix4_default();
var scratchInverseMatrix = new Matrix4_default();
var scratchXDirection = new Cartesian3_default();
var scratchYDirection = new Cartesian3_default();
var scratchZDirection = new Cartesian3_default();
var scratchNegativeX = new Cartesian3_default();
var scratchNegativeY = new Cartesian3_default();
var scratchNegativeZ = new Cartesian3_default();
var frustumSplits = new Array(3);
var frustumCornersNDC = new Array(4);
frustumCornersNDC[0] = new Cartesian4_default(-1, -1, 1, 1);
frustumCornersNDC[1] = new Cartesian4_default(1, -1, 1, 1);
frustumCornersNDC[2] = new Cartesian4_default(1, 1, 1, 1);
frustumCornersNDC[3] = new Cartesian4_default(-1, 1, 1, 1);
var scratchFrustumCorners = new Array(4);
for (let i = 0; i < 4; ++i) {
scratchFrustumCorners[i] = new Cartesian4_default();
}
FrustumGeometry._computeNearFarPlanes = function(origin, orientation, frustumType, frustum, positions, xDirection, yDirection, zDirection) {
const rotationMatrix = Matrix3_default.fromQuaternion(
orientation,
scratchRotationMatrix
);
let x = defaultValue_default(xDirection, scratchXDirection);
let y = defaultValue_default(yDirection, scratchYDirection);
let z = defaultValue_default(zDirection, scratchZDirection);
x = Matrix3_default.getColumn(rotationMatrix, 0, x);
y = Matrix3_default.getColumn(rotationMatrix, 1, y);
z = Matrix3_default.getColumn(rotationMatrix, 2, z);
Cartesian3_default.normalize(x, x);
Cartesian3_default.normalize(y, y);
Cartesian3_default.normalize(z, z);
Cartesian3_default.negate(x, x);
const view = Matrix4_default.computeView(origin, z, y, x, scratchViewMatrix);
let inverseView;
let inverseViewProjection;
if (frustumType === PERSPECTIVE) {
const projection = frustum.projectionMatrix;
const viewProjection = Matrix4_default.multiply(
projection,
view,
scratchInverseMatrix
);
inverseViewProjection = Matrix4_default.inverse(
viewProjection,
scratchInverseMatrix
);
} else {
inverseView = Matrix4_default.inverseTransformation(view, scratchInverseMatrix);
}
if (defined_default(inverseViewProjection)) {
frustumSplits[0] = frustum.near;
frustumSplits[1] = frustum.far;
} else {
frustumSplits[0] = 0;
frustumSplits[1] = frustum.near;
frustumSplits[2] = frustum.far;
}
for (let i = 0; i < 2; ++i) {
for (let j = 0; j < 4; ++j) {
let corner = Cartesian4_default.clone(
frustumCornersNDC[j],
scratchFrustumCorners[j]
);
if (!defined_default(inverseViewProjection)) {
if (defined_default(frustum._offCenterFrustum)) {
frustum = frustum._offCenterFrustum;
}
const near = frustumSplits[i];
const far = frustumSplits[i + 1];
corner.x = (corner.x * (frustum.right - frustum.left) + frustum.left + frustum.right) * 0.5;
corner.y = (corner.y * (frustum.top - frustum.bottom) + frustum.bottom + frustum.top) * 0.5;
corner.z = (corner.z * (near - far) - near - far) * 0.5;
corner.w = 1;
Matrix4_default.multiplyByVector(inverseView, corner, corner);
} else {
corner = Matrix4_default.multiplyByVector(
inverseViewProjection,
corner,
corner
);
const w = 1 / corner.w;
Cartesian3_default.multiplyByScalar(corner, w, corner);
Cartesian3_default.subtract(corner, origin, corner);
Cartesian3_default.normalize(corner, corner);
const fac = Cartesian3_default.dot(z, corner);
Cartesian3_default.multiplyByScalar(corner, frustumSplits[i] / fac, corner);
Cartesian3_default.add(corner, origin, corner);
}
positions[12 * i + j * 3] = corner.x;
positions[12 * i + j * 3 + 1] = corner.y;
positions[12 * i + j * 3 + 2] = corner.z;
}
}
};
FrustumGeometry.createGeometry = function(frustumGeometry) {
const frustumType = frustumGeometry._frustumType;
const frustum = frustumGeometry._frustum;
const origin = frustumGeometry._origin;
const orientation = frustumGeometry._orientation;
const drawNearPlane = frustumGeometry._drawNearPlane;
const vertexFormat = frustumGeometry._vertexFormat;
const numberOfPlanes = drawNearPlane ? 6 : 5;
let positions = new Float64Array(3 * 4 * 6);
FrustumGeometry._computeNearFarPlanes(
origin,
orientation,
frustumType,
frustum,
positions
);
let offset2 = 3 * 4 * 2;
positions[offset2] = positions[3 * 4];
positions[offset2 + 1] = positions[3 * 4 + 1];
positions[offset2 + 2] = positions[3 * 4 + 2];
positions[offset2 + 3] = positions[0];
positions[offset2 + 4] = positions[1];
positions[offset2 + 5] = positions[2];
positions[offset2 + 6] = positions[3 * 3];
positions[offset2 + 7] = positions[3 * 3 + 1];
positions[offset2 + 8] = positions[3 * 3 + 2];
positions[offset2 + 9] = positions[3 * 7];
positions[offset2 + 10] = positions[3 * 7 + 1];
positions[offset2 + 11] = positions[3 * 7 + 2];
offset2 += 3 * 4;
positions[offset2] = positions[3 * 5];
positions[offset2 + 1] = positions[3 * 5 + 1];
positions[offset2 + 2] = positions[3 * 5 + 2];
positions[offset2 + 3] = positions[3];
positions[offset2 + 4] = positions[3 + 1];
positions[offset2 + 5] = positions[3 + 2];
positions[offset2 + 6] = positions[0];
positions[offset2 + 7] = positions[1];
positions[offset2 + 8] = positions[2];
positions[offset2 + 9] = positions[3 * 4];
positions[offset2 + 10] = positions[3 * 4 + 1];
positions[offset2 + 11] = positions[3 * 4 + 2];
offset2 += 3 * 4;
positions[offset2] = positions[3];
positions[offset2 + 1] = positions[3 + 1];
positions[offset2 + 2] = positions[3 + 2];
positions[offset2 + 3] = positions[3 * 5];
positions[offset2 + 4] = positions[3 * 5 + 1];
positions[offset2 + 5] = positions[3 * 5 + 2];
positions[offset2 + 6] = positions[3 * 6];
positions[offset2 + 7] = positions[3 * 6 + 1];
positions[offset2 + 8] = positions[3 * 6 + 2];
positions[offset2 + 9] = positions[3 * 2];
positions[offset2 + 10] = positions[3 * 2 + 1];
positions[offset2 + 11] = positions[3 * 2 + 2];
offset2 += 3 * 4;
positions[offset2] = positions[3 * 2];
positions[offset2 + 1] = positions[3 * 2 + 1];
positions[offset2 + 2] = positions[3 * 2 + 2];
positions[offset2 + 3] = positions[3 * 6];
positions[offset2 + 4] = positions[3 * 6 + 1];
positions[offset2 + 5] = positions[3 * 6 + 2];
positions[offset2 + 6] = positions[3 * 7];
positions[offset2 + 7] = positions[3 * 7 + 1];
positions[offset2 + 8] = positions[3 * 7 + 2];
positions[offset2 + 9] = positions[3 * 3];
positions[offset2 + 10] = positions[3 * 3 + 1];
positions[offset2 + 11] = positions[3 * 3 + 2];
if (!drawNearPlane) {
positions = positions.subarray(3 * 4);
}
const attributes = new GeometryAttributes_default({
position: new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.DOUBLE,
componentsPerAttribute: 3,
values: positions
})
});
if (defined_default(vertexFormat.normal) || defined_default(vertexFormat.tangent) || defined_default(vertexFormat.bitangent) || defined_default(vertexFormat.st)) {
const normals = defined_default(vertexFormat.normal) ? new Float32Array(3 * 4 * numberOfPlanes) : void 0;
const tangents = defined_default(vertexFormat.tangent) ? new Float32Array(3 * 4 * numberOfPlanes) : void 0;
const bitangents = defined_default(vertexFormat.bitangent) ? new Float32Array(3 * 4 * numberOfPlanes) : void 0;
const st = defined_default(vertexFormat.st) ? new Float32Array(2 * 4 * numberOfPlanes) : void 0;
const x = scratchXDirection;
const y = scratchYDirection;
const z = scratchZDirection;
const negativeX2 = Cartesian3_default.negate(x, scratchNegativeX);
const negativeY = Cartesian3_default.negate(y, scratchNegativeY);
const negativeZ = Cartesian3_default.negate(z, scratchNegativeZ);
offset2 = 0;
if (drawNearPlane) {
getAttributes(offset2, normals, tangents, bitangents, st, negativeZ, x, y);
offset2 += 3 * 4;
}
getAttributes(offset2, normals, tangents, bitangents, st, z, negativeX2, y);
offset2 += 3 * 4;
getAttributes(
offset2,
normals,
tangents,
bitangents,
st,
negativeX2,
negativeZ,
y
);
offset2 += 3 * 4;
getAttributes(
offset2,
normals,
tangents,
bitangents,
st,
negativeY,
negativeZ,
negativeX2
);
offset2 += 3 * 4;
getAttributes(offset2, normals, tangents, bitangents, st, x, z, y);
offset2 += 3 * 4;
getAttributes(offset2, normals, tangents, bitangents, st, y, z, negativeX2);
if (defined_default(normals)) {
attributes.normal = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.FLOAT,
componentsPerAttribute: 3,
values: normals
});
}
if (defined_default(tangents)) {
attributes.tangent = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.FLOAT,
componentsPerAttribute: 3,
values: tangents
});
}
if (defined_default(bitangents)) {
attributes.bitangent = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.FLOAT,
componentsPerAttribute: 3,
values: bitangents
});
}
if (defined_default(st)) {
attributes.st = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.FLOAT,
componentsPerAttribute: 2,
values: st
});
}
}
const indices2 = new Uint16Array(6 * numberOfPlanes);
for (let i = 0; i < numberOfPlanes; ++i) {
const indexOffset = i * 6;
const index = i * 4;
indices2[indexOffset] = index;
indices2[indexOffset + 1] = index + 1;
indices2[indexOffset + 2] = index + 2;
indices2[indexOffset + 3] = index;
indices2[indexOffset + 4] = index + 2;
indices2[indexOffset + 5] = index + 3;
}
return new Geometry_default({
attributes,
indices: indices2,
primitiveType: PrimitiveType_default.TRIANGLES,
boundingSphere: BoundingSphere_default.fromVertices(positions)
});
};
var FrustumGeometry_default = FrustumGeometry;
// Source/Core/FrustumOutlineGeometry.js
var PERSPECTIVE2 = 0;
var ORTHOGRAPHIC2 = 1;
function FrustumOutlineGeometry(options) {
Check_default.typeOf.object("options", options);
Check_default.typeOf.object("options.frustum", options.frustum);
Check_default.typeOf.object("options.origin", options.origin);
Check_default.typeOf.object("options.orientation", options.orientation);
const frustum = options.frustum;
const orientation = options.orientation;
const origin = options.origin;
const drawNearPlane = defaultValue_default(options._drawNearPlane, true);
let frustumType;
let frustumPackedLength;
if (frustum instanceof PerspectiveFrustum_default) {
frustumType = PERSPECTIVE2;
frustumPackedLength = PerspectiveFrustum_default.packedLength;
} else if (frustum instanceof OrthographicFrustum_default) {
frustumType = ORTHOGRAPHIC2;
frustumPackedLength = OrthographicFrustum_default.packedLength;
}
this._frustumType = frustumType;
this._frustum = frustum.clone();
this._origin = Cartesian3_default.clone(origin);
this._orientation = Quaternion_default.clone(orientation);
this._drawNearPlane = drawNearPlane;
this._workerName = "createFrustumOutlineGeometry";
this.packedLength = 2 + frustumPackedLength + Cartesian3_default.packedLength + Quaternion_default.packedLength;
}
FrustumOutlineGeometry.pack = function(value, array, startingIndex) {
Check_default.typeOf.object("value", value);
Check_default.defined("array", array);
startingIndex = defaultValue_default(startingIndex, 0);
const frustumType = value._frustumType;
const frustum = value._frustum;
array[startingIndex++] = frustumType;
if (frustumType === PERSPECTIVE2) {
PerspectiveFrustum_default.pack(frustum, array, startingIndex);
startingIndex += PerspectiveFrustum_default.packedLength;
} else {
OrthographicFrustum_default.pack(frustum, array, startingIndex);
startingIndex += OrthographicFrustum_default.packedLength;
}
Cartesian3_default.pack(value._origin, array, startingIndex);
startingIndex += Cartesian3_default.packedLength;
Quaternion_default.pack(value._orientation, array, startingIndex);
startingIndex += Quaternion_default.packedLength;
array[startingIndex] = value._drawNearPlane ? 1 : 0;
return array;
};
var scratchPackPerspective2 = new PerspectiveFrustum_default();
var scratchPackOrthographic2 = new OrthographicFrustum_default();
var scratchPackQuaternion2 = new Quaternion_default();
var scratchPackorigin2 = new Cartesian3_default();
FrustumOutlineGeometry.unpack = function(array, startingIndex, result) {
Check_default.defined("array", array);
startingIndex = defaultValue_default(startingIndex, 0);
const frustumType = array[startingIndex++];
let frustum;
if (frustumType === PERSPECTIVE2) {
frustum = PerspectiveFrustum_default.unpack(
array,
startingIndex,
scratchPackPerspective2
);
startingIndex += PerspectiveFrustum_default.packedLength;
} else {
frustum = OrthographicFrustum_default.unpack(
array,
startingIndex,
scratchPackOrthographic2
);
startingIndex += OrthographicFrustum_default.packedLength;
}
const origin = Cartesian3_default.unpack(array, startingIndex, scratchPackorigin2);
startingIndex += Cartesian3_default.packedLength;
const orientation = Quaternion_default.unpack(
array,
startingIndex,
scratchPackQuaternion2
);
startingIndex += Quaternion_default.packedLength;
const drawNearPlane = array[startingIndex] === 1;
if (!defined_default(result)) {
return new FrustumOutlineGeometry({
frustum,
origin,
orientation,
_drawNearPlane: drawNearPlane
});
}
const frustumResult = frustumType === result._frustumType ? result._frustum : void 0;
result._frustum = frustum.clone(frustumResult);
result._frustumType = frustumType;
result._origin = Cartesian3_default.clone(origin, result._origin);
result._orientation = Quaternion_default.clone(orientation, result._orientation);
result._drawNearPlane = drawNearPlane;
return result;
};
FrustumOutlineGeometry.createGeometry = function(frustumGeometry) {
const frustumType = frustumGeometry._frustumType;
const frustum = frustumGeometry._frustum;
const origin = frustumGeometry._origin;
const orientation = frustumGeometry._orientation;
const drawNearPlane = frustumGeometry._drawNearPlane;
const positions = new Float64Array(3 * 4 * 2);
FrustumGeometry_default._computeNearFarPlanes(
origin,
orientation,
frustumType,
frustum,
positions
);
const attributes = new GeometryAttributes_default({
position: new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.DOUBLE,
componentsPerAttribute: 3,
values: positions
})
});
let offset2;
let index;
const numberOfPlanes = drawNearPlane ? 2 : 1;
const indices2 = new Uint16Array(8 * (numberOfPlanes + 1));
let i = drawNearPlane ? 0 : 1;
for (; i < 2; ++i) {
offset2 = drawNearPlane ? i * 8 : 0;
index = i * 4;
indices2[offset2] = index;
indices2[offset2 + 1] = index + 1;
indices2[offset2 + 2] = index + 1;
indices2[offset2 + 3] = index + 2;
indices2[offset2 + 4] = index + 2;
indices2[offset2 + 5] = index + 3;
indices2[offset2 + 6] = index + 3;
indices2[offset2 + 7] = index;
}
for (i = 0; i < 2; ++i) {
offset2 = (numberOfPlanes + i) * 8;
index = i * 4;
indices2[offset2] = index;
indices2[offset2 + 1] = index + 4;
indices2[offset2 + 2] = index + 1;
indices2[offset2 + 3] = index + 5;
indices2[offset2 + 4] = index + 2;
indices2[offset2 + 5] = index + 6;
indices2[offset2 + 6] = index + 3;
indices2[offset2 + 7] = index + 7;
}
return new Geometry_default({
attributes,
indices: indices2,
primitiveType: PrimitiveType_default.LINES,
boundingSphere: BoundingSphere_default.fromVertices(positions)
});
};
var FrustumOutlineGeometry_default = FrustumOutlineGeometry;
// Source/Core/GeocoderService.js
function GeocoderService() {
}
GeocoderService.prototype.geocode = DeveloperError_default.throwInstantiationError;
var GeocoderService_default = GeocoderService;
// Source/Core/GeocodeType.js
var GeocodeType = {
SEARCH: 0,
AUTOCOMPLETE: 1
};
var GeocodeType_default = Object.freeze(GeocodeType);
// Source/Core/GeometryFactory.js
function GeometryFactory() {
DeveloperError_default.throwInstantiationError();
}
GeometryFactory.createGeometry = function(geometryFactory) {
DeveloperError_default.throwInstantiationError();
};
var GeometryFactory_default = GeometryFactory;
// Source/Core/GeometryInstanceAttribute.js
function GeometryInstanceAttribute(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
if (!defined_default(options.componentDatatype)) {
throw new DeveloperError_default("options.componentDatatype is required.");
}
if (!defined_default(options.componentsPerAttribute)) {
throw new DeveloperError_default("options.componentsPerAttribute is required.");
}
if (options.componentsPerAttribute < 1 || options.componentsPerAttribute > 4) {
throw new DeveloperError_default(
"options.componentsPerAttribute must be between 1 and 4."
);
}
if (!defined_default(options.value)) {
throw new DeveloperError_default("options.value is required.");
}
this.componentDatatype = options.componentDatatype;
this.componentsPerAttribute = options.componentsPerAttribute;
this.normalize = defaultValue_default(options.normalize, false);
this.value = options.value;
}
var GeometryInstanceAttribute_default = GeometryInstanceAttribute;
// Source/Core/getFilenameFromUri.js
function getFilenameFromUri(uri) {
if (!defined_default(uri)) {
throw new DeveloperError_default("uri is required.");
}
const uriObject = new import_urijs.default(uri);
uriObject.normalize();
let path = uriObject.path();
const index = path.lastIndexOf("/");
if (index !== -1) {
path = path.substr(index + 1);
}
return path;
}
var getFilenameFromUri_default = getFilenameFromUri;
// Source/Core/getImageFromTypedArray.js
function getImageFromTypedArray(typedArray, width, height) {
const dataArray = new Uint8ClampedArray(typedArray.buffer);
const imageData = new ImageData(dataArray, width, height);
const canvas = document.createElement("canvas");
canvas.width = width;
canvas.height = height;
canvas.getContext("2d").putImageData(imageData, 0, 0);
return canvas;
}
var getImageFromTypedArray_default = getImageFromTypedArray;
// Source/Core/getMagic.js
function getMagic(uint8Array, byteOffset) {
byteOffset = defaultValue_default(byteOffset, 0);
return getStringFromTypedArray_default(
uint8Array,
byteOffset,
Math.min(4, uint8Array.length)
);
}
var getMagic_default = getMagic;
// Source/ThirdParty/protobufjs.js
var protobuf = __toESM(require_protobuf(), 1);
// Source/Core/isBitSet.js
function isBitSet(bits, mask) {
return (bits & mask) !== 0;
}
var isBitSet_default = isBitSet;
// Source/Core/GoogleEarthEnterpriseTileInformation.js
var childrenBitmasks = [1, 2, 4, 8];
var anyChildBitmask = 15;
var cacheFlagBitmask = 16;
var imageBitmask = 64;
var terrainBitmask = 128;
function GoogleEarthEnterpriseTileInformation(bits, cnodeVersion, imageryVersion, terrainVersion, imageryProvider, terrainProvider) {
this._bits = bits;
this.cnodeVersion = cnodeVersion;
this.imageryVersion = imageryVersion;
this.terrainVersion = terrainVersion;
this.imageryProvider = imageryProvider;
this.terrainProvider = terrainProvider;
this.ancestorHasTerrain = false;
this.terrainState = void 0;
}
GoogleEarthEnterpriseTileInformation.clone = function(info, result) {
if (!defined_default(result)) {
result = new GoogleEarthEnterpriseTileInformation(
info._bits,
info.cnodeVersion,
info.imageryVersion,
info.terrainVersion,
info.imageryProvider,
info.terrainProvider
);
} else {
result._bits = info._bits;
result.cnodeVersion = info.cnodeVersion;
result.imageryVersion = info.imageryVersion;
result.terrainVersion = info.terrainVersion;
result.imageryProvider = info.imageryProvider;
result.terrainProvider = info.terrainProvider;
}
result.ancestorHasTerrain = info.ancestorHasTerrain;
result.terrainState = info.terrainState;
return result;
};
GoogleEarthEnterpriseTileInformation.prototype.setParent = function(parent) {
this.ancestorHasTerrain = parent.ancestorHasTerrain || this.hasTerrain();
};
GoogleEarthEnterpriseTileInformation.prototype.hasSubtree = function() {
return isBitSet_default(this._bits, cacheFlagBitmask);
};
GoogleEarthEnterpriseTileInformation.prototype.hasImagery = function() {
return isBitSet_default(this._bits, imageBitmask);
};
GoogleEarthEnterpriseTileInformation.prototype.hasTerrain = function() {
return isBitSet_default(this._bits, terrainBitmask);
};
GoogleEarthEnterpriseTileInformation.prototype.hasChildren = function() {
return isBitSet_default(this._bits, anyChildBitmask);
};
GoogleEarthEnterpriseTileInformation.prototype.hasChild = function(index) {
return isBitSet_default(this._bits, childrenBitmasks[index]);
};
GoogleEarthEnterpriseTileInformation.prototype.getChildBitmask = function() {
return this._bits & anyChildBitmask;
};
var GoogleEarthEnterpriseTileInformation_default = GoogleEarthEnterpriseTileInformation;
// Source/Core/GoogleEarthEnterpriseMetadata.js
function stringToBuffer(str) {
const len = str.length;
const buffer = new ArrayBuffer(len);
const ui8 = new Uint8Array(buffer);
for (let i = 0; i < len; ++i) {
ui8[i] = str.charCodeAt(i);
}
return buffer;
}
var defaultKey = stringToBuffer(
`E\xF4\xBD\vy\xE2jE"\x92,\xCDq\xF8IFgQ\0B%\xC6\xE8a,f)\b\xC64\xDCjb%y
wmi\xD6\xF0\x9Ck\x93\xA1\xBDNu\xE0A[\xDF@V\f\xD9\xBBr\x9B\x81|3S\xEEOl\xD4q\xB0{\xC0\x7FEVZ\xADwUe\v3\x92*\xACl5\xC50s\xF83>mF8J\xB4\xDD\xF0.\xDDu\xDA\x8CDt"\xFAa"\f3"So\xAF9D\v\x8C9\xD99L\xB9\xBF\x7F\xAB\\\x8CP_\x9F"ux\xE9\x07q\x91h;\xC1\xC4\x9B\x7F\xF0M\xAA>}\xE6\xCEI\x89\xC6\xE6x\fa1-\xA4O\xA5~q \x88\xEC\r1\xE8N\v\0nPh}=\b\r\x95\xA6n\xA3h\x97$[k\xF3#\xF3\xB6s\xB3\r\v@\xC0\x9F\xD8Q]\xFA".j\xDFI\0\xB9\xA0wU\xC6\xEFj\xBF{GL\x7F\x83\xEE\xDC\xDCF\x85\xA9\xADS\x07+S4\x07\xFF\x94Y\xE48\xE81\x83N\xB9XFk\xCB-#\x86\x92p\x005\x88"\xCF1\xB2&/\xE7\xC3u-6,rt\xB0#G\xB7\xD3\xD1&\x857r\xE2\0\x8CD\xCF\xDA3-\xDE\`\x86i#i*|\xCDKQ\r\x95T9w.)\xEA\x1B\xA6P\xA2j\x8FoP\x99\\>T\xFB\xEFP[\v\x07E\x89m(w7\xDB\x8EJfJo\x99 \xE5p\xE2\xB9q~\fmI-z\xFEr\xC7\xF2Y0\x8F\xBB]s\xE5\xC9 \xEAx\xEC \x90\xF0\x8A\x7FB|G\`\xB0\xBD&\xB7q\xB6\xC7\x9F\xD13\x82=\xD3\xAB\xEEc\x99\xC8+S\xA0D\\q\xC6\xCCD2O<\xCA\xC0)=R\xD3aX\xA9}e\xB4\xDC\xCF\r\xF4=\xF1\b\xA9B\xDA# \xD8\xBF^PI\xF8M\xC0\xCBGLO\xF7{+\xD8\xC51\x92;\xB5o\xDCl\r\x92\x88\xD1\x9E\xDB?\xE2\xE9\xDA_\xD4\x84\xE2FaZ\xDEU\xCF\xA4\0\xBE\xFD\xCEg\xF1Ji\x97\xE6 H\xD8]\x7F~\xAEq N\xAE\xC0V\xA9\x91<\x82r\xE7v\xEC)I\xD6]-\x83\xE3\xDB6\xA9;f\x97\x87j\xD5\xB6=P^R\xB9K\xC7sWx\xC9\xF4.Y\x07\x95\x93o\xD0KW>''\xC7\`\xDB;\xED\x9ASD>?\x8D\x92mw\xA2
\xEB?R\xA8\xC6U^1I7\x85\xF4\xC5&-\xA9\xBF\x8B'T\xDA\xC3j \xE5*x\xB0\xD6\x90pr\xAA\x8Bh\xBD\x88\xF7_H\xB1~\xC0XL?f\xF9>\xE1e\xC0p\xA7\xCF8i\xAF\xF0VldI\x9C'\xADxtO\xC2\x87\xDEV9\0\xDAw\v\xCB-\x1B\x89\xFB5O\xF5\bQ\`\xC1
ZGM&30x\xDA\xC0\x9CFG\xE2[y\`In7gS
>\xE9\xECF9\xB2\xF14\r\xC6\x84Sun\xE1\fY\xD9\xDE)\x85{II\xA5wy\xBEIV.6\xE7\v:\xBBOb{\xD2M1\x95/\xBD8{\xA8O!\xE1\xECFpv\x95})"x\x88
\x90\xDD\x9D\\\xDA\xDEQ\xCF\xF0\xFCYRe|3\xDF\xF3H\xDA\xBB*u\xDB\`\xB2\xD4\xFC\xED\x1B\xEC\x7F5\xA8\xFF(1\x07-\xC8\xDC\x88F|\x8A["`
);
function GoogleEarthEnterpriseMetadata(resourceOrUrl) {
Check_default.defined("resourceOrUrl", resourceOrUrl);
let url2 = resourceOrUrl;
if (typeof url2 !== "string" && !(url2 instanceof Resource_default)) {
Check_default.typeOf.string("resourceOrUrl.url", resourceOrUrl.url);
url2 = resourceOrUrl.url;
}
const resource = Resource_default.createIfNeeded(url2);
resource.appendForwardSlash();
this._resource = resource;
this.imageryPresent = true;
this.protoImagery = void 0;
this.terrainPresent = true;
this.negativeAltitudeExponentBias = 32;
this.negativeAltitudeThreshold = Math_default.EPSILON12;
this.providers = {};
this.key = void 0;
this._quadPacketVersion = 1;
this._tileInfo = {};
this._subtreePromises = {};
const that = this;
this._readyPromise = requestDbRoot(this).then(function() {
return that.getQuadTreePacket("", that._quadPacketVersion);
}).then(function() {
return true;
}).catch(function(e) {
const message = `An error occurred while accessing ${getMetadataResource(that, "", 1).url}.`;
return Promise.reject(new RuntimeError_default(message));
});
}
Object.defineProperties(GoogleEarthEnterpriseMetadata.prototype, {
url: {
get: function() {
return this._resource.url;
}
},
proxy: {
get: function() {
return this._resource.proxy;
}
},
resource: {
get: function() {
return this._resource;
}
},
readyPromise: {
get: function() {
return this._readyPromise;
}
}
});
GoogleEarthEnterpriseMetadata.tileXYToQuadKey = function(x, y, level) {
let quadkey = "";
for (let i = level; i >= 0; --i) {
const bitmask = 1 << i;
let digit = 0;
if (!isBitSet_default(y, bitmask)) {
digit |= 2;
if (!isBitSet_default(x, bitmask)) {
digit |= 1;
}
} else if (isBitSet_default(x, bitmask)) {
digit |= 1;
}
quadkey += digit;
}
return quadkey;
};
GoogleEarthEnterpriseMetadata.quadKeyToTileXY = function(quadkey) {
let x = 0;
let y = 0;
const level = quadkey.length - 1;
for (let i = level; i >= 0; --i) {
const bitmask = 1 << i;
const digit = +quadkey[level - i];
if (isBitSet_default(digit, 2)) {
if (!isBitSet_default(digit, 1)) {
x |= bitmask;
}
} else {
y |= bitmask;
if (isBitSet_default(digit, 1)) {
x |= bitmask;
}
}
}
return {
x,
y,
level
};
};
GoogleEarthEnterpriseMetadata.prototype.isValid = function(quadKey) {
let info = this.getTileInformationFromQuadKey(quadKey);
if (defined_default(info)) {
return info !== null;
}
let valid = true;
let q = quadKey;
let last;
while (q.length > 1) {
last = q.substring(q.length - 1);
q = q.substring(0, q.length - 1);
info = this.getTileInformationFromQuadKey(q);
if (defined_default(info)) {
if (!info.hasSubtree() && !info.hasChild(parseInt(last))) {
valid = false;
}
break;
} else if (info === null) {
valid = false;
break;
}
}
return valid;
};
var taskProcessor = new TaskProcessor_default("decodeGoogleEarthEnterprisePacket");
GoogleEarthEnterpriseMetadata.prototype.getQuadTreePacket = function(quadKey, version, request) {
version = defaultValue_default(version, 1);
quadKey = defaultValue_default(quadKey, "");
const resource = getMetadataResource(this, quadKey, version, request);
const promise = resource.fetchArrayBuffer();
if (!defined_default(promise)) {
return void 0;
}
const tileInfo = this._tileInfo;
const key = this.key;
return promise.then(function(metadata) {
const decodePromise = taskProcessor.scheduleTask(
{
buffer: metadata,
quadKey,
type: "Metadata",
key
},
[metadata]
);
return decodePromise.then(function(result) {
let root;
let topLevelKeyLength = -1;
if (quadKey !== "") {
topLevelKeyLength = quadKey.length + 1;
const top = result[quadKey];
root = tileInfo[quadKey];
root._bits |= top._bits;
delete result[quadKey];
}
const keys = Object.keys(result);
keys.sort(function(a3, b) {
return a3.length - b.length;
});
const keysLength = keys.length;
for (let i = 0; i < keysLength; ++i) {
const key2 = keys[i];
const r = result[key2];
if (r !== null) {
const info = GoogleEarthEnterpriseTileInformation_default.clone(result[key2]);
const keyLength = key2.length;
if (keyLength === topLevelKeyLength) {
info.setParent(root);
} else if (keyLength > 1) {
const parent = tileInfo[key2.substring(0, key2.length - 1)];
info.setParent(parent);
}
tileInfo[key2] = info;
} else {
tileInfo[key2] = null;
}
}
});
});
};
GoogleEarthEnterpriseMetadata.prototype.populateSubtree = function(x, y, level, request) {
const quadkey = GoogleEarthEnterpriseMetadata.tileXYToQuadKey(x, y, level);
return populateSubtree(this, quadkey, request);
};
function populateSubtree(that, quadKey, request) {
const tileInfo = that._tileInfo;
let q = quadKey;
let t = tileInfo[q];
if (defined_default(t) && (!t.hasSubtree() || t.hasChildren())) {
return t;
}
while (t === void 0 && q.length > 1) {
q = q.substring(0, q.length - 1);
t = tileInfo[q];
}
let subtreeRequest;
const subtreePromises = that._subtreePromises;
let promise = subtreePromises[q];
if (defined_default(promise)) {
return promise.then(function() {
subtreeRequest = new Request_default({
throttle: request.throttle,
throttleByServer: request.throttleByServer,
type: request.type,
priorityFunction: request.priorityFunction
});
return populateSubtree(that, quadKey, subtreeRequest);
});
}
if (!defined_default(t) || !t.hasSubtree()) {
return Promise.reject(
new RuntimeError_default(`Couldn't load metadata for tile ${quadKey}`)
);
}
promise = that.getQuadTreePacket(q, t.cnodeVersion, request);
if (!defined_default(promise)) {
return void 0;
}
subtreePromises[q] = promise;
return promise.then(function() {
subtreeRequest = new Request_default({
throttle: request.throttle,
throttleByServer: request.throttleByServer,
type: request.type,
priorityFunction: request.priorityFunction
});
return populateSubtree(that, quadKey, subtreeRequest);
}).finally(function() {
delete subtreePromises[q];
});
}
GoogleEarthEnterpriseMetadata.prototype.getTileInformation = function(x, y, level) {
const quadkey = GoogleEarthEnterpriseMetadata.tileXYToQuadKey(x, y, level);
return this._tileInfo[quadkey];
};
GoogleEarthEnterpriseMetadata.prototype.getTileInformationFromQuadKey = function(quadkey) {
return this._tileInfo[quadkey];
};
function getMetadataResource(that, quadKey, version, request) {
return that._resource.getDerivedResource({
url: `flatfile?q2-0${quadKey}-q.${version.toString()}`,
request
});
}
var dbrootParser;
var dbrootParserPromise;
function requestDbRoot(that) {
const resource = that._resource.getDerivedResource({
url: "dbRoot.v5",
queryParameters: {
output: "proto"
}
});
if (!defined_default(dbrootParserPromise)) {
const url2 = buildModuleUrl_default("ThirdParty/google-earth-dbroot-parser.js");
const oldValue2 = window.cesiumGoogleEarthDbRootParser;
dbrootParserPromise = loadAndExecuteScript_default(url2).then(function() {
dbrootParser = window.cesiumGoogleEarthDbRootParser(protobuf);
if (defined_default(oldValue2)) {
window.cesiumGoogleEarthDbRootParser = oldValue2;
} else {
delete window.cesiumGoogleEarthDbRootParser;
}
});
}
return dbrootParserPromise.then(function() {
return resource.fetchArrayBuffer();
}).then(function(buf) {
const encryptedDbRootProto = dbrootParser.EncryptedDbRootProto.decode(
new Uint8Array(buf)
);
let byteArray = encryptedDbRootProto.encryptionData;
let offset2 = byteArray.byteOffset;
let end = offset2 + byteArray.byteLength;
const key = that.key = byteArray.buffer.slice(offset2, end);
byteArray = encryptedDbRootProto.dbrootData;
offset2 = byteArray.byteOffset;
end = offset2 + byteArray.byteLength;
const dbRootCompressed = byteArray.buffer.slice(offset2, end);
return taskProcessor.scheduleTask(
{
buffer: dbRootCompressed,
type: "DbRoot",
key
},
[dbRootCompressed]
);
}).then(function(result) {
const dbRoot = dbrootParser.DbRootProto.decode(
new Uint8Array(result.buffer)
);
that.imageryPresent = defaultValue_default(
dbRoot.imageryPresent,
that.imageryPresent
);
that.protoImagery = dbRoot.protoImagery;
that.terrainPresent = defaultValue_default(
dbRoot.terrainPresent,
that.terrainPresent
);
if (defined_default(dbRoot.endSnippet) && defined_default(dbRoot.endSnippet.model)) {
const model = dbRoot.endSnippet.model;
that.negativeAltitudeExponentBias = defaultValue_default(
model.negativeAltitudeExponentBias,
that.negativeAltitudeExponentBias
);
that.negativeAltitudeThreshold = defaultValue_default(
model.compressedNegativeAltitudeThreshold,
that.negativeAltitudeThreshold
);
}
if (defined_default(dbRoot.databaseVersion)) {
that._quadPacketVersion = defaultValue_default(
dbRoot.databaseVersion.quadtreeVersion,
that._quadPacketVersion
);
}
const providers = that.providers;
const providerInfo = defaultValue_default(dbRoot.providerInfo, []);
const count = providerInfo.length;
for (let i = 0; i < count; ++i) {
const provider = providerInfo[i];
const copyrightString = provider.copyrightString;
if (defined_default(copyrightString)) {
providers[provider.providerId] = new Credit_default(copyrightString.value);
}
}
}).catch(function() {
console.log(`Failed to retrieve ${resource.url}. Using defaults.`);
that.key = defaultKey;
});
}
var GoogleEarthEnterpriseMetadata_default = GoogleEarthEnterpriseMetadata;
// Source/Core/GoogleEarthEnterpriseTerrainData.js
function GoogleEarthEnterpriseTerrainData(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
Check_default.typeOf.object("options.buffer", options.buffer);
Check_default.typeOf.number(
"options.negativeAltitudeExponentBias",
options.negativeAltitudeExponentBias
);
Check_default.typeOf.number(
"options.negativeElevationThreshold",
options.negativeElevationThreshold
);
this._buffer = options.buffer;
this._credits = options.credits;
this._negativeAltitudeExponentBias = options.negativeAltitudeExponentBias;
this._negativeElevationThreshold = options.negativeElevationThreshold;
const googleChildTileMask = defaultValue_default(options.childTileMask, 15);
let childTileMask = googleChildTileMask & 3;
childTileMask |= googleChildTileMask & 4 ? 8 : 0;
childTileMask |= googleChildTileMask & 8 ? 4 : 0;
this._childTileMask = childTileMask;
this._createdByUpsampling = defaultValue_default(options.createdByUpsampling, false);
this._skirtHeight = void 0;
this._bufferType = this._buffer.constructor;
this._mesh = void 0;
this._minimumHeight = void 0;
this._maximumHeight = void 0;
}
Object.defineProperties(GoogleEarthEnterpriseTerrainData.prototype, {
credits: {
get: function() {
return this._credits;
}
},
waterMask: {
get: function() {
return void 0;
}
}
});
var createMeshTaskName3 = "createVerticesFromGoogleEarthEnterpriseBuffer";
var createMeshTaskProcessorNoThrottle3 = new TaskProcessor_default(createMeshTaskName3);
var createMeshTaskProcessorThrottle3 = new TaskProcessor_default(
createMeshTaskName3,
TerrainData_default.maximumAsynchronousTasks
);
var nativeRectangleScratch = new Rectangle_default();
var rectangleScratch2 = new Rectangle_default();
GoogleEarthEnterpriseTerrainData.prototype.createMesh = function(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
Check_default.typeOf.object("options.tilingScheme", options.tilingScheme);
Check_default.typeOf.number("options.x", options.x);
Check_default.typeOf.number("options.y", options.y);
Check_default.typeOf.number("options.level", options.level);
const tilingScheme2 = options.tilingScheme;
const x = options.x;
const y = options.y;
const level = options.level;
const exaggeration = defaultValue_default(options.exaggeration, 1);
const exaggerationRelativeHeight = defaultValue_default(
options.exaggerationRelativeHeight,
0
);
const throttle = defaultValue_default(options.throttle, true);
const ellipsoid = tilingScheme2.ellipsoid;
tilingScheme2.tileXYToNativeRectangle(x, y, level, nativeRectangleScratch);
tilingScheme2.tileXYToRectangle(x, y, level, rectangleScratch2);
const center = ellipsoid.cartographicToCartesian(
Rectangle_default.center(rectangleScratch2)
);
const levelZeroMaxError = 40075.16;
const thisLevelMaxError = levelZeroMaxError / (1 << level);
this._skirtHeight = Math.min(thisLevelMaxError * 8, 1e3);
const createMeshTaskProcessor = throttle ? createMeshTaskProcessorThrottle3 : createMeshTaskProcessorNoThrottle3;
const verticesPromise = createMeshTaskProcessor.scheduleTask({
buffer: this._buffer,
nativeRectangle: nativeRectangleScratch,
rectangle: rectangleScratch2,
relativeToCenter: center,
ellipsoid,
skirtHeight: this._skirtHeight,
exaggeration,
exaggerationRelativeHeight,
includeWebMercatorT: true,
negativeAltitudeExponentBias: this._negativeAltitudeExponentBias,
negativeElevationThreshold: this._negativeElevationThreshold
});
if (!defined_default(verticesPromise)) {
return void 0;
}
const that = this;
return verticesPromise.then(function(result) {
that._mesh = new TerrainMesh_default(
center,
new Float32Array(result.vertices),
new Uint16Array(result.indices),
result.indexCountWithoutSkirts,
result.vertexCountWithoutSkirts,
result.minimumHeight,
result.maximumHeight,
BoundingSphere_default.clone(result.boundingSphere3D),
Cartesian3_default.clone(result.occludeePointInScaledSpace),
result.numberOfAttributes,
OrientedBoundingBox_default.clone(result.orientedBoundingBox),
TerrainEncoding_default.clone(result.encoding),
result.westIndicesSouthToNorth,
result.southIndicesEastToWest,
result.eastIndicesNorthToSouth,
result.northIndicesWestToEast
);
that._minimumHeight = result.minimumHeight;
that._maximumHeight = result.maximumHeight;
that._buffer = void 0;
return that._mesh;
});
};
GoogleEarthEnterpriseTerrainData.prototype.interpolateHeight = function(rectangle, longitude, latitude) {
const u3 = Math_default.clamp(
(longitude - rectangle.west) / rectangle.width,
0,
1
);
const v7 = Math_default.clamp(
(latitude - rectangle.south) / rectangle.height,
0,
1
);
if (!defined_default(this._mesh)) {
return interpolateHeight3(this, u3, v7, rectangle);
}
return interpolateMeshHeight3(this, u3, v7);
};
var upsampleTaskProcessor2 = new TaskProcessor_default(
"upsampleQuantizedTerrainMesh",
TerrainData_default.maximumAsynchronousTasks
);
GoogleEarthEnterpriseTerrainData.prototype.upsample = function(tilingScheme2, thisX, thisY, thisLevel, descendantX, descendantY, descendantLevel) {
Check_default.typeOf.object("tilingScheme", tilingScheme2);
Check_default.typeOf.number("thisX", thisX);
Check_default.typeOf.number("thisY", thisY);
Check_default.typeOf.number("thisLevel", thisLevel);
Check_default.typeOf.number("descendantX", descendantX);
Check_default.typeOf.number("descendantY", descendantY);
Check_default.typeOf.number("descendantLevel", descendantLevel);
const levelDifference = descendantLevel - thisLevel;
if (levelDifference > 1) {
throw new DeveloperError_default(
"Upsampling through more than one level at a time is not currently supported."
);
}
const mesh = this._mesh;
if (!defined_default(this._mesh)) {
return void 0;
}
const isEastChild = thisX * 2 !== descendantX;
const isNorthChild = thisY * 2 === descendantY;
const ellipsoid = tilingScheme2.ellipsoid;
const childRectangle = tilingScheme2.tileXYToRectangle(
descendantX,
descendantY,
descendantLevel
);
const upsamplePromise = upsampleTaskProcessor2.scheduleTask({
vertices: mesh.vertices,
indices: mesh.indices,
indexCountWithoutSkirts: mesh.indexCountWithoutSkirts,
vertexCountWithoutSkirts: mesh.vertexCountWithoutSkirts,
encoding: mesh.encoding,
minimumHeight: this._minimumHeight,
maximumHeight: this._maximumHeight,
isEastChild,
isNorthChild,
childRectangle,
ellipsoid
});
if (!defined_default(upsamplePromise)) {
return void 0;
}
const that = this;
return upsamplePromise.then(function(result) {
const quantizedVertices = new Uint16Array(result.vertices);
const indicesTypedArray = IndexDatatype_default.createTypedArray(
quantizedVertices.length / 3,
result.indices
);
const skirtHeight = that._skirtHeight;
return new QuantizedMeshTerrainData_default({
quantizedVertices,
indices: indicesTypedArray,
minimumHeight: result.minimumHeight,
maximumHeight: result.maximumHeight,
boundingSphere: BoundingSphere_default.clone(result.boundingSphere),
orientedBoundingBox: OrientedBoundingBox_default.clone(
result.orientedBoundingBox
),
horizonOcclusionPoint: Cartesian3_default.clone(result.horizonOcclusionPoint),
westIndices: result.westIndices,
southIndices: result.southIndices,
eastIndices: result.eastIndices,
northIndices: result.northIndices,
westSkirtHeight: skirtHeight,
southSkirtHeight: skirtHeight,
eastSkirtHeight: skirtHeight,
northSkirtHeight: skirtHeight,
childTileMask: 0,
createdByUpsampling: true,
credits: that._credits
});
});
};
GoogleEarthEnterpriseTerrainData.prototype.isChildAvailable = function(thisX, thisY, childX, childY) {
Check_default.typeOf.number("thisX", thisX);
Check_default.typeOf.number("thisY", thisY);
Check_default.typeOf.number("childX", childX);
Check_default.typeOf.number("childY", childY);
let bitNumber = 2;
if (childX !== thisX * 2) {
++bitNumber;
}
if (childY !== thisY * 2) {
bitNumber -= 2;
}
return (this._childTileMask & 1 << bitNumber) !== 0;
};
GoogleEarthEnterpriseTerrainData.prototype.wasCreatedByUpsampling = function() {
return this._createdByUpsampling;
};
var texCoordScratch02 = new Cartesian2_default();
var texCoordScratch12 = new Cartesian2_default();
var texCoordScratch22 = new Cartesian2_default();
var barycentricCoordinateScratch2 = new Cartesian3_default();
function interpolateMeshHeight3(terrainData, u3, v7) {
const mesh = terrainData._mesh;
const vertices = mesh.vertices;
const encoding = mesh.encoding;
const indices2 = mesh.indices;
for (let i = 0, len = indices2.length; i < len; i += 3) {
const i0 = indices2[i];
const i1 = indices2[i + 1];
const i2 = indices2[i + 2];
const uv0 = encoding.decodeTextureCoordinates(
vertices,
i0,
texCoordScratch02
);
const uv1 = encoding.decodeTextureCoordinates(
vertices,
i1,
texCoordScratch12
);
const uv2 = encoding.decodeTextureCoordinates(
vertices,
i2,
texCoordScratch22
);
const barycentric = Intersections2D_default.computeBarycentricCoordinates(
u3,
v7,
uv0.x,
uv0.y,
uv1.x,
uv1.y,
uv2.x,
uv2.y,
barycentricCoordinateScratch2
);
if (barycentric.x >= -1e-15 && barycentric.y >= -1e-15 && barycentric.z >= -1e-15) {
const h0 = encoding.decodeHeight(vertices, i0);
const h1 = encoding.decodeHeight(vertices, i1);
const h2 = encoding.decodeHeight(vertices, i2);
return barycentric.x * h0 + barycentric.y * h1 + barycentric.z * h2;
}
}
return void 0;
}
var sizeOfUint16 = Uint16Array.BYTES_PER_ELEMENT;
var sizeOfUint32 = Uint32Array.BYTES_PER_ELEMENT;
var sizeOfInt32 = Int32Array.BYTES_PER_ELEMENT;
var sizeOfFloat = Float32Array.BYTES_PER_ELEMENT;
var sizeOfDouble = Float64Array.BYTES_PER_ELEMENT;
function interpolateHeight3(terrainData, u3, v7, rectangle) {
const buffer = terrainData._buffer;
let quad = 0;
let uStart = 0;
let vStart = 0;
if (v7 > 0.5) {
if (u3 > 0.5) {
quad = 2;
uStart = 0.5;
} else {
quad = 3;
}
vStart = 0.5;
} else if (u3 > 0.5) {
quad = 1;
uStart = 0.5;
}
const dv = new DataView(buffer);
let offset2 = 0;
for (let q = 0; q < quad; ++q) {
offset2 += dv.getUint32(offset2, true);
offset2 += sizeOfUint32;
}
offset2 += sizeOfUint32;
offset2 += 2 * sizeOfDouble;
const xSize = Math_default.toRadians(dv.getFloat64(offset2, true) * 180);
offset2 += sizeOfDouble;
const ySize = Math_default.toRadians(dv.getFloat64(offset2, true) * 180);
offset2 += sizeOfDouble;
const xScale = rectangle.width / xSize / 2;
const yScale = rectangle.height / ySize / 2;
const numPoints = dv.getInt32(offset2, true);
offset2 += sizeOfInt32;
const numIndices = dv.getInt32(offset2, true) * 3;
offset2 += sizeOfInt32;
offset2 += sizeOfInt32;
const uBuffer = new Array(numPoints);
const vBuffer = new Array(numPoints);
const heights = new Array(numPoints);
let i;
for (i = 0; i < numPoints; ++i) {
uBuffer[i] = uStart + dv.getUint8(offset2++) * xScale;
vBuffer[i] = vStart + dv.getUint8(offset2++) * yScale;
heights[i] = dv.getFloat32(offset2, true) * 6371010;
offset2 += sizeOfFloat;
}
const indices2 = new Array(numIndices);
for (i = 0; i < numIndices; ++i) {
indices2[i] = dv.getUint16(offset2, true);
offset2 += sizeOfUint16;
}
for (i = 0; i < numIndices; i += 3) {
const i0 = indices2[i];
const i1 = indices2[i + 1];
const i2 = indices2[i + 2];
const u0 = uBuffer[i0];
const u12 = uBuffer[i1];
const u22 = uBuffer[i2];
const v02 = vBuffer[i0];
const v13 = vBuffer[i1];
const v23 = vBuffer[i2];
const barycentric = Intersections2D_default.computeBarycentricCoordinates(
u3,
v7,
u0,
v02,
u12,
v13,
u22,
v23,
barycentricCoordinateScratch2
);
if (barycentric.x >= -1e-15 && barycentric.y >= -1e-15 && barycentric.z >= -1e-15) {
return barycentric.x * heights[i0] + barycentric.y * heights[i1] + barycentric.z * heights[i2];
}
}
return void 0;
}
var GoogleEarthEnterpriseTerrainData_default = GoogleEarthEnterpriseTerrainData;
// Source/Core/GoogleEarthEnterpriseTerrainProvider.js
var TerrainState = {
UNKNOWN: 0,
NONE: 1,
SELF: 2,
PARENT: 3
};
var julianDateScratch2 = new JulianDate_default();
function TerrainCache() {
this._terrainCache = {};
this._lastTidy = JulianDate_default.now();
}
TerrainCache.prototype.add = function(quadKey, buffer) {
this._terrainCache[quadKey] = {
buffer,
timestamp: JulianDate_default.now()
};
};
TerrainCache.prototype.get = function(quadKey) {
const terrainCache = this._terrainCache;
const result = terrainCache[quadKey];
if (defined_default(result)) {
delete this._terrainCache[quadKey];
return result.buffer;
}
};
TerrainCache.prototype.tidy = function() {
JulianDate_default.now(julianDateScratch2);
if (JulianDate_default.secondsDifference(julianDateScratch2, this._lastTidy) > 10) {
const terrainCache = this._terrainCache;
const keys = Object.keys(terrainCache);
const count = keys.length;
for (let i = 0; i < count; ++i) {
const k = keys[i];
const e = terrainCache[k];
if (JulianDate_default.secondsDifference(julianDateScratch2, e.timestamp) > 10) {
delete terrainCache[k];
}
}
JulianDate_default.clone(julianDateScratch2, this._lastTidy);
}
};
function GoogleEarthEnterpriseTerrainProvider(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
if (!(defined_default(options.url) || defined_default(options.metadata))) {
throw new DeveloperError_default("options.url or options.metadata is required.");
}
let metadata;
if (defined_default(options.metadata)) {
metadata = options.metadata;
} else {
const resource = Resource_default.createIfNeeded(options.url);
metadata = new GoogleEarthEnterpriseMetadata_default(resource);
}
this._metadata = metadata;
this._tilingScheme = new GeographicTilingScheme_default({
numberOfLevelZeroTilesX: 2,
numberOfLevelZeroTilesY: 2,
rectangle: new Rectangle_default(
-Math_default.PI,
-Math_default.PI,
Math_default.PI,
Math_default.PI
),
ellipsoid: options.ellipsoid
});
let credit = options.credit;
if (typeof credit === "string") {
credit = new Credit_default(credit);
}
this._credit = credit;
this._levelZeroMaximumGeometricError = 40075.16;
this._terrainCache = new TerrainCache();
this._terrainPromises = {};
this._terrainRequests = {};
this._errorEvent = new Event_default();
this._ready = false;
const that = this;
let metadataError;
this._readyPromise = metadata.readyPromise.then(function(result) {
if (!metadata.terrainPresent) {
const e = new RuntimeError_default(
`The server ${metadata.url} doesn't have terrain`
);
metadataError = TileProviderError_default.reportError(
metadataError,
that,
that._errorEvent,
e.message,
void 0,
void 0,
void 0,
e
);
return Promise.reject(e);
}
TileProviderError_default.reportSuccess(metadataError);
that._ready = result;
return result;
}).catch(function(e) {
metadataError = TileProviderError_default.reportError(
metadataError,
that,
that._errorEvent,
e.message,
void 0,
void 0,
void 0,
e
);
return Promise.reject(e);
});
}
Object.defineProperties(GoogleEarthEnterpriseTerrainProvider.prototype, {
url: {
get: function() {
return this._metadata.url;
}
},
proxy: {
get: function() {
return this._metadata.proxy;
}
},
tilingScheme: {
get: function() {
if (!this._ready) {
throw new DeveloperError_default(
"tilingScheme must not be called before the imagery provider is ready."
);
}
return this._tilingScheme;
}
},
errorEvent: {
get: function() {
return this._errorEvent;
}
},
ready: {
get: function() {
return this._ready;
}
},
readyPromise: {
get: function() {
return this._readyPromise;
}
},
credit: {
get: function() {
return this._credit;
}
},
hasWaterMask: {
get: function() {
return false;
}
},
hasVertexNormals: {
get: function() {
return false;
}
},
availability: {
get: function() {
return void 0;
}
}
});
var taskProcessor2 = new TaskProcessor_default("decodeGoogleEarthEnterprisePacket");
function computeChildMask(quadKey, info, metadata) {
let childMask = info.getChildBitmask();
if (info.terrainState === TerrainState.PARENT) {
childMask = 0;
for (let i = 0; i < 4; ++i) {
const child = metadata.getTileInformationFromQuadKey(
quadKey + i.toString()
);
if (defined_default(child) && child.hasTerrain()) {
childMask |= 1 << i;
}
}
}
return childMask;
}
GoogleEarthEnterpriseTerrainProvider.prototype.requestTileGeometry = function(x, y, level, request) {
if (!this._ready) {
throw new DeveloperError_default(
"requestTileGeometry must not be called before the terrain provider is ready."
);
}
const quadKey = GoogleEarthEnterpriseMetadata_default.tileXYToQuadKey(x, y, level);
const terrainCache = this._terrainCache;
const metadata = this._metadata;
const info = metadata.getTileInformationFromQuadKey(quadKey);
if (!defined_default(info)) {
return Promise.reject(new RuntimeError_default("Terrain tile doesn't exist"));
}
let terrainState = info.terrainState;
if (!defined_default(terrainState)) {
terrainState = info.terrainState = TerrainState.UNKNOWN;
}
const buffer = terrainCache.get(quadKey);
if (defined_default(buffer)) {
const credit = metadata.providers[info.terrainProvider];
return Promise.resolve(
new GoogleEarthEnterpriseTerrainData_default({
buffer,
childTileMask: computeChildMask(quadKey, info, metadata),
credits: defined_default(credit) ? [credit] : void 0,
negativeAltitudeExponentBias: metadata.negativeAltitudeExponentBias,
negativeElevationThreshold: metadata.negativeAltitudeThreshold
})
);
}
terrainCache.tidy();
if (!info.ancestorHasTerrain) {
return Promise.resolve(
new HeightmapTerrainData_default({
buffer: new Uint8Array(16 * 16),
width: 16,
height: 16
})
);
} else if (terrainState === TerrainState.NONE) {
return Promise.reject(new RuntimeError_default("Terrain tile doesn't exist"));
}
let parentInfo;
let q = quadKey;
let terrainVersion = -1;
switch (terrainState) {
case TerrainState.SELF:
terrainVersion = info.terrainVersion;
break;
case TerrainState.PARENT:
q = q.substring(0, q.length - 1);
parentInfo = metadata.getTileInformationFromQuadKey(q);
terrainVersion = parentInfo.terrainVersion;
break;
case TerrainState.UNKNOWN:
if (info.hasTerrain()) {
terrainVersion = info.terrainVersion;
} else {
q = q.substring(0, q.length - 1);
parentInfo = metadata.getTileInformationFromQuadKey(q);
if (defined_default(parentInfo) && parentInfo.hasTerrain()) {
terrainVersion = parentInfo.terrainVersion;
}
}
break;
}
if (terrainVersion < 0) {
return Promise.reject(new RuntimeError_default("Terrain tile doesn't exist"));
}
const terrainPromises = this._terrainPromises;
const terrainRequests = this._terrainRequests;
let sharedPromise;
let sharedRequest;
if (defined_default(terrainPromises[q])) {
sharedPromise = terrainPromises[q];
sharedRequest = terrainRequests[q];
} else {
sharedRequest = request;
const requestPromise = buildTerrainResource(
this,
q,
terrainVersion,
sharedRequest
).fetchArrayBuffer();
if (!defined_default(requestPromise)) {
return void 0;
}
sharedPromise = requestPromise.then(function(terrain) {
if (defined_default(terrain)) {
return taskProcessor2.scheduleTask(
{
buffer: terrain,
type: "Terrain",
key: metadata.key
},
[terrain]
).then(function(terrainTiles) {
const requestedInfo = metadata.getTileInformationFromQuadKey(q);
requestedInfo.terrainState = TerrainState.SELF;
terrainCache.add(q, terrainTiles[0]);
const provider = requestedInfo.terrainProvider;
const count = terrainTiles.length - 1;
for (let j = 0; j < count; ++j) {
const childKey = q + j.toString();
const child = metadata.getTileInformationFromQuadKey(childKey);
if (defined_default(child)) {
terrainCache.add(childKey, terrainTiles[j + 1]);
child.terrainState = TerrainState.PARENT;
if (child.terrainProvider === 0) {
child.terrainProvider = provider;
}
}
}
});
}
return Promise.reject(new RuntimeError_default("Failed to load terrain."));
});
terrainPromises[q] = sharedPromise;
terrainRequests[q] = sharedRequest;
sharedPromise = sharedPromise.finally(function() {
delete terrainPromises[q];
delete terrainRequests[q];
});
}
return sharedPromise.then(function() {
const buffer2 = terrainCache.get(quadKey);
if (defined_default(buffer2)) {
const credit = metadata.providers[info.terrainProvider];
return new GoogleEarthEnterpriseTerrainData_default({
buffer: buffer2,
childTileMask: computeChildMask(quadKey, info, metadata),
credits: defined_default(credit) ? [credit] : void 0,
negativeAltitudeExponentBias: metadata.negativeAltitudeExponentBias,
negativeElevationThreshold: metadata.negativeAltitudeThreshold
});
}
return Promise.reject(new RuntimeError_default("Failed to load terrain."));
}).catch(function(error) {
if (sharedRequest.state === RequestState_default.CANCELLED) {
request.state = sharedRequest.state;
return Promise.reject(error);
}
info.terrainState = TerrainState.NONE;
return Promise.reject(error);
});
};
GoogleEarthEnterpriseTerrainProvider.prototype.getLevelMaximumGeometricError = function(level) {
return this._levelZeroMaximumGeometricError / (1 << level);
};
GoogleEarthEnterpriseTerrainProvider.prototype.getTileDataAvailable = function(x, y, level) {
const metadata = this._metadata;
let quadKey = GoogleEarthEnterpriseMetadata_default.tileXYToQuadKey(x, y, level);
const info = metadata.getTileInformation(x, y, level);
if (info === null) {
return false;
}
if (defined_default(info)) {
if (!info.ancestorHasTerrain) {
return true;
}
const terrainState = info.terrainState;
if (terrainState === TerrainState.NONE) {
return false;
}
if (!defined_default(terrainState) || terrainState === TerrainState.UNKNOWN) {
info.terrainState = TerrainState.UNKNOWN;
if (!info.hasTerrain()) {
quadKey = quadKey.substring(0, quadKey.length - 1);
const parentInfo = metadata.getTileInformationFromQuadKey(quadKey);
if (!defined_default(parentInfo) || !parentInfo.hasTerrain()) {
return false;
}
}
}
return true;
}
if (metadata.isValid(quadKey)) {
const request = new Request_default({
throttle: false,
throttleByServer: true,
type: RequestType_default.TERRAIN
});
metadata.populateSubtree(x, y, level, request);
}
return false;
};
GoogleEarthEnterpriseTerrainProvider.prototype.loadTileDataAvailability = function(x, y, level) {
return void 0;
};
function buildTerrainResource(terrainProvider, quadKey, version, request) {
version = defined_default(version) && version > 0 ? version : 1;
return terrainProvider._metadata.resource.getDerivedResource({
url: `flatfile?f1c-0${quadKey}-t.${version.toString()}`,
request
});
}
var GoogleEarthEnterpriseTerrainProvider_default = GoogleEarthEnterpriseTerrainProvider;
// Source/Core/GroundPolylineGeometry.js
var PROJECTIONS = [GeographicProjection_default, WebMercatorProjection_default];
var PROJECTION_COUNT = PROJECTIONS.length;
var MITER_BREAK_SMALL = Math.cos(Math_default.toRadians(30));
var MITER_BREAK_LARGE = Math.cos(Math_default.toRadians(150));
var WALL_INITIAL_MIN_HEIGHT = 0;
var WALL_INITIAL_MAX_HEIGHT = 1e3;
function GroundPolylineGeometry(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
const positions = options.positions;
if (!defined_default(positions) || positions.length < 2) {
throw new DeveloperError_default("At least two positions are required.");
}
if (defined_default(options.arcType) && options.arcType !== ArcType_default.GEODESIC && options.arcType !== ArcType_default.RHUMB) {
throw new DeveloperError_default(
"Valid options for arcType are ArcType.GEODESIC and ArcType.RHUMB."
);
}
this.width = defaultValue_default(options.width, 1);
this._positions = positions;
this.granularity = defaultValue_default(options.granularity, 9999);
this.loop = defaultValue_default(options.loop, false);
this.arcType = defaultValue_default(options.arcType, ArcType_default.GEODESIC);
this._ellipsoid = Ellipsoid_default.WGS84;
this._projectionIndex = 0;
this._workerName = "createGroundPolylineGeometry";
this._scene3DOnly = false;
}
Object.defineProperties(GroundPolylineGeometry.prototype, {
packedLength: {
get: function() {
return 1 + this._positions.length * 3 + 1 + 1 + 1 + Ellipsoid_default.packedLength + 1 + 1;
}
}
});
GroundPolylineGeometry.setProjectionAndEllipsoid = function(groundPolylineGeometry, mapProjection) {
let projectionIndex = 0;
for (let i = 0; i < PROJECTION_COUNT; i++) {
if (mapProjection instanceof PROJECTIONS[i]) {
projectionIndex = i;
break;
}
}
groundPolylineGeometry._projectionIndex = projectionIndex;
groundPolylineGeometry._ellipsoid = mapProjection.ellipsoid;
};
var cart3Scratch1 = new Cartesian3_default();
var cart3Scratch2 = new Cartesian3_default();
var cart3Scratch3 = new Cartesian3_default();
function computeRightNormal(start, end, maxHeight, ellipsoid, result) {
const startBottom = getPosition(ellipsoid, start, 0, cart3Scratch1);
const startTop = getPosition(ellipsoid, start, maxHeight, cart3Scratch2);
const endBottom = getPosition(ellipsoid, end, 0, cart3Scratch3);
const up = direction(startTop, startBottom, cart3Scratch2);
const forward = direction(endBottom, startBottom, cart3Scratch3);
Cartesian3_default.cross(forward, up, result);
return Cartesian3_default.normalize(result, result);
}
var interpolatedCartographicScratch = new Cartographic_default();
var interpolatedBottomScratch = new Cartesian3_default();
var interpolatedTopScratch = new Cartesian3_default();
var interpolatedNormalScratch = new Cartesian3_default();
function interpolateSegment(start, end, minHeight, maxHeight, granularity, arcType, ellipsoid, normalsArray, bottomPositionsArray, topPositionsArray, cartographicsArray) {
if (granularity === 0) {
return;
}
let ellipsoidLine;
if (arcType === ArcType_default.GEODESIC) {
ellipsoidLine = new EllipsoidGeodesic_default(start, end, ellipsoid);
} else if (arcType === ArcType_default.RHUMB) {
ellipsoidLine = new EllipsoidRhumbLine_default(start, end, ellipsoid);
}
const surfaceDistance = ellipsoidLine.surfaceDistance;
if (surfaceDistance < granularity) {
return;
}
const interpolatedNormal = computeRightNormal(
start,
end,
maxHeight,
ellipsoid,
interpolatedNormalScratch
);
const segments = Math.ceil(surfaceDistance / granularity);
const interpointDistance = surfaceDistance / segments;
let distanceFromStart = interpointDistance;
const pointsToAdd = segments - 1;
let packIndex = normalsArray.length;
for (let i = 0; i < pointsToAdd; i++) {
const interpolatedCartographic = ellipsoidLine.interpolateUsingSurfaceDistance(
distanceFromStart,
interpolatedCartographicScratch
);
const interpolatedBottom = getPosition(
ellipsoid,
interpolatedCartographic,
minHeight,
interpolatedBottomScratch
);
const interpolatedTop = getPosition(
ellipsoid,
interpolatedCartographic,
maxHeight,
interpolatedTopScratch
);
Cartesian3_default.pack(interpolatedNormal, normalsArray, packIndex);
Cartesian3_default.pack(interpolatedBottom, bottomPositionsArray, packIndex);
Cartesian3_default.pack(interpolatedTop, topPositionsArray, packIndex);
cartographicsArray.push(interpolatedCartographic.latitude);
cartographicsArray.push(interpolatedCartographic.longitude);
packIndex += 3;
distanceFromStart += interpointDistance;
}
}
var heightlessCartographicScratch = new Cartographic_default();
function getPosition(ellipsoid, cartographic2, height, result) {
Cartographic_default.clone(cartographic2, heightlessCartographicScratch);
heightlessCartographicScratch.height = height;
return Cartographic_default.toCartesian(
heightlessCartographicScratch,
ellipsoid,
result
);
}
GroundPolylineGeometry.pack = function(value, array, startingIndex) {
Check_default.typeOf.object("value", value);
Check_default.defined("array", array);
let index = defaultValue_default(startingIndex, 0);
const positions = value._positions;
const positionsLength = positions.length;
array[index++] = positionsLength;
for (let i = 0; i < positionsLength; ++i) {
const cartesian11 = positions[i];
Cartesian3_default.pack(cartesian11, array, index);
index += 3;
}
array[index++] = value.granularity;
array[index++] = value.loop ? 1 : 0;
array[index++] = value.arcType;
Ellipsoid_default.pack(value._ellipsoid, array, index);
index += Ellipsoid_default.packedLength;
array[index++] = value._projectionIndex;
array[index++] = value._scene3DOnly ? 1 : 0;
return array;
};
GroundPolylineGeometry.unpack = function(array, startingIndex, result) {
Check_default.defined("array", array);
let index = defaultValue_default(startingIndex, 0);
const positionsLength = array[index++];
const positions = new Array(positionsLength);
for (let i = 0; i < positionsLength; i++) {
positions[i] = Cartesian3_default.unpack(array, index);
index += 3;
}
const granularity = array[index++];
const loop = array[index++] === 1;
const arcType = array[index++];
const ellipsoid = Ellipsoid_default.unpack(array, index);
index += Ellipsoid_default.packedLength;
const projectionIndex = array[index++];
const scene3DOnly = array[index++] === 1;
if (!defined_default(result)) {
result = new GroundPolylineGeometry({
positions
});
}
result._positions = positions;
result.granularity = granularity;
result.loop = loop;
result.arcType = arcType;
result._ellipsoid = ellipsoid;
result._projectionIndex = projectionIndex;
result._scene3DOnly = scene3DOnly;
return result;
};
function direction(target, origin, result) {
Cartesian3_default.subtract(target, origin, result);
Cartesian3_default.normalize(result, result);
return result;
}
function tangentDirection(target, origin, up, result) {
result = direction(target, origin, result);
result = Cartesian3_default.cross(result, up, result);
result = Cartesian3_default.normalize(result, result);
result = Cartesian3_default.cross(up, result, result);
return result;
}
var toPreviousScratch = new Cartesian3_default();
var toNextScratch = new Cartesian3_default();
var forwardScratch = new Cartesian3_default();
var vertexUpScratch = new Cartesian3_default();
var cosine90 = 0;
var cosine180 = -1;
function computeVertexMiterNormal(previousBottom, vertexBottom, vertexTop, nextBottom, result) {
const up = direction(vertexTop, vertexBottom, vertexUpScratch);
const toPrevious = tangentDirection(
previousBottom,
vertexBottom,
up,
toPreviousScratch
);
const toNext = tangentDirection(nextBottom, vertexBottom, up, toNextScratch);
if (Math_default.equalsEpsilon(
Cartesian3_default.dot(toPrevious, toNext),
cosine180,
Math_default.EPSILON5
)) {
result = Cartesian3_default.cross(up, toPrevious, result);
result = Cartesian3_default.normalize(result, result);
return result;
}
result = Cartesian3_default.add(toNext, toPrevious, result);
result = Cartesian3_default.normalize(result, result);
const forward = Cartesian3_default.cross(up, result, forwardScratch);
if (Cartesian3_default.dot(toNext, forward) < cosine90) {
result = Cartesian3_default.negate(result, result);
}
return result;
}
var XZ_PLANE = Plane_default.fromPointNormal(Cartesian3_default.ZERO, Cartesian3_default.UNIT_Y);
var previousBottomScratch = new Cartesian3_default();
var vertexBottomScratch = new Cartesian3_default();
var vertexTopScratch = new Cartesian3_default();
var nextBottomScratch = new Cartesian3_default();
var vertexNormalScratch = new Cartesian3_default();
var intersectionScratch = new Cartesian3_default();
var cartographicScratch0 = new Cartographic_default();
var cartographicScratch1 = new Cartographic_default();
var cartographicIntersectionScratch = new Cartographic_default();
GroundPolylineGeometry.createGeometry = function(groundPolylineGeometry) {
const compute2dAttributes = !groundPolylineGeometry._scene3DOnly;
let loop = groundPolylineGeometry.loop;
const ellipsoid = groundPolylineGeometry._ellipsoid;
const granularity = groundPolylineGeometry.granularity;
const arcType = groundPolylineGeometry.arcType;
const projection = new PROJECTIONS[groundPolylineGeometry._projectionIndex](
ellipsoid
);
const minHeight = WALL_INITIAL_MIN_HEIGHT;
const maxHeight = WALL_INITIAL_MAX_HEIGHT;
let index;
let i;
const positions = groundPolylineGeometry._positions;
const positionsLength = positions.length;
if (positionsLength === 2) {
loop = false;
}
let p0;
let p1;
let c0;
let c14;
const rhumbLine = new EllipsoidRhumbLine_default(void 0, void 0, ellipsoid);
let intersection;
let intersectionCartographic;
let intersectionLongitude;
const splitPositions = [positions[0]];
for (i = 0; i < positionsLength - 1; i++) {
p0 = positions[i];
p1 = positions[i + 1];
intersection = IntersectionTests_default.lineSegmentPlane(
p0,
p1,
XZ_PLANE,
intersectionScratch
);
if (defined_default(intersection) && !Cartesian3_default.equalsEpsilon(intersection, p0, Math_default.EPSILON7) && !Cartesian3_default.equalsEpsilon(intersection, p1, Math_default.EPSILON7)) {
if (groundPolylineGeometry.arcType === ArcType_default.GEODESIC) {
splitPositions.push(Cartesian3_default.clone(intersection));
} else if (groundPolylineGeometry.arcType === ArcType_default.RHUMB) {
intersectionLongitude = ellipsoid.cartesianToCartographic(
intersection,
cartographicScratch0
).longitude;
c0 = ellipsoid.cartesianToCartographic(p0, cartographicScratch0);
c14 = ellipsoid.cartesianToCartographic(p1, cartographicScratch1);
rhumbLine.setEndPoints(c0, c14);
intersectionCartographic = rhumbLine.findIntersectionWithLongitude(
intersectionLongitude,
cartographicIntersectionScratch
);
intersection = ellipsoid.cartographicToCartesian(
intersectionCartographic,
intersectionScratch
);
if (defined_default(intersection) && !Cartesian3_default.equalsEpsilon(intersection, p0, Math_default.EPSILON7) && !Cartesian3_default.equalsEpsilon(intersection, p1, Math_default.EPSILON7)) {
splitPositions.push(Cartesian3_default.clone(intersection));
}
}
}
splitPositions.push(p1);
}
if (loop) {
p0 = positions[positionsLength - 1];
p1 = positions[0];
intersection = IntersectionTests_default.lineSegmentPlane(
p0,
p1,
XZ_PLANE,
intersectionScratch
);
if (defined_default(intersection) && !Cartesian3_default.equalsEpsilon(intersection, p0, Math_default.EPSILON7) && !Cartesian3_default.equalsEpsilon(intersection, p1, Math_default.EPSILON7)) {
if (groundPolylineGeometry.arcType === ArcType_default.GEODESIC) {
splitPositions.push(Cartesian3_default.clone(intersection));
} else if (groundPolylineGeometry.arcType === ArcType_default.RHUMB) {
intersectionLongitude = ellipsoid.cartesianToCartographic(
intersection,
cartographicScratch0
).longitude;
c0 = ellipsoid.cartesianToCartographic(p0, cartographicScratch0);
c14 = ellipsoid.cartesianToCartographic(p1, cartographicScratch1);
rhumbLine.setEndPoints(c0, c14);
intersectionCartographic = rhumbLine.findIntersectionWithLongitude(
intersectionLongitude,
cartographicIntersectionScratch
);
intersection = ellipsoid.cartographicToCartesian(
intersectionCartographic,
intersectionScratch
);
if (defined_default(intersection) && !Cartesian3_default.equalsEpsilon(intersection, p0, Math_default.EPSILON7) && !Cartesian3_default.equalsEpsilon(intersection, p1, Math_default.EPSILON7)) {
splitPositions.push(Cartesian3_default.clone(intersection));
}
}
}
}
let cartographicsLength = splitPositions.length;
let cartographics = new Array(cartographicsLength);
for (i = 0; i < cartographicsLength; i++) {
const cartographic2 = Cartographic_default.fromCartesian(
splitPositions[i],
ellipsoid
);
cartographic2.height = 0;
cartographics[i] = cartographic2;
}
cartographics = arrayRemoveDuplicates_default(
cartographics,
Cartographic_default.equalsEpsilon
);
cartographicsLength = cartographics.length;
if (cartographicsLength < 2) {
return void 0;
}
const cartographicsArray = [];
const normalsArray = [];
const bottomPositionsArray = [];
const topPositionsArray = [];
let previousBottom = previousBottomScratch;
let vertexBottom = vertexBottomScratch;
let vertexTop = vertexTopScratch;
let nextBottom = nextBottomScratch;
let vertexNormal = vertexNormalScratch;
const startCartographic = cartographics[0];
const nextCartographic = cartographics[1];
const prestartCartographic = cartographics[cartographicsLength - 1];
previousBottom = getPosition(
ellipsoid,
prestartCartographic,
minHeight,
previousBottom
);
nextBottom = getPosition(ellipsoid, nextCartographic, minHeight, nextBottom);
vertexBottom = getPosition(
ellipsoid,
startCartographic,
minHeight,
vertexBottom
);
vertexTop = getPosition(ellipsoid, startCartographic, maxHeight, vertexTop);
if (loop) {
vertexNormal = computeVertexMiterNormal(
previousBottom,
vertexBottom,
vertexTop,
nextBottom,
vertexNormal
);
} else {
vertexNormal = computeRightNormal(
startCartographic,
nextCartographic,
maxHeight,
ellipsoid,
vertexNormal
);
}
Cartesian3_default.pack(vertexNormal, normalsArray, 0);
Cartesian3_default.pack(vertexBottom, bottomPositionsArray, 0);
Cartesian3_default.pack(vertexTop, topPositionsArray, 0);
cartographicsArray.push(startCartographic.latitude);
cartographicsArray.push(startCartographic.longitude);
interpolateSegment(
startCartographic,
nextCartographic,
minHeight,
maxHeight,
granularity,
arcType,
ellipsoid,
normalsArray,
bottomPositionsArray,
topPositionsArray,
cartographicsArray
);
for (i = 1; i < cartographicsLength - 1; ++i) {
previousBottom = Cartesian3_default.clone(vertexBottom, previousBottom);
vertexBottom = Cartesian3_default.clone(nextBottom, vertexBottom);
const vertexCartographic = cartographics[i];
getPosition(ellipsoid, vertexCartographic, maxHeight, vertexTop);
getPosition(ellipsoid, cartographics[i + 1], minHeight, nextBottom);
computeVertexMiterNormal(
previousBottom,
vertexBottom,
vertexTop,
nextBottom,
vertexNormal
);
index = normalsArray.length;
Cartesian3_default.pack(vertexNormal, normalsArray, index);
Cartesian3_default.pack(vertexBottom, bottomPositionsArray, index);
Cartesian3_default.pack(vertexTop, topPositionsArray, index);
cartographicsArray.push(vertexCartographic.latitude);
cartographicsArray.push(vertexCartographic.longitude);
interpolateSegment(
cartographics[i],
cartographics[i + 1],
minHeight,
maxHeight,
granularity,
arcType,
ellipsoid,
normalsArray,
bottomPositionsArray,
topPositionsArray,
cartographicsArray
);
}
const endCartographic = cartographics[cartographicsLength - 1];
const preEndCartographic = cartographics[cartographicsLength - 2];
vertexBottom = getPosition(
ellipsoid,
endCartographic,
minHeight,
vertexBottom
);
vertexTop = getPosition(ellipsoid, endCartographic, maxHeight, vertexTop);
if (loop) {
const postEndCartographic = cartographics[0];
previousBottom = getPosition(
ellipsoid,
preEndCartographic,
minHeight,
previousBottom
);
nextBottom = getPosition(
ellipsoid,
postEndCartographic,
minHeight,
nextBottom
);
vertexNormal = computeVertexMiterNormal(
previousBottom,
vertexBottom,
vertexTop,
nextBottom,
vertexNormal
);
} else {
vertexNormal = computeRightNormal(
preEndCartographic,
endCartographic,
maxHeight,
ellipsoid,
vertexNormal
);
}
index = normalsArray.length;
Cartesian3_default.pack(vertexNormal, normalsArray, index);
Cartesian3_default.pack(vertexBottom, bottomPositionsArray, index);
Cartesian3_default.pack(vertexTop, topPositionsArray, index);
cartographicsArray.push(endCartographic.latitude);
cartographicsArray.push(endCartographic.longitude);
if (loop) {
interpolateSegment(
endCartographic,
startCartographic,
minHeight,
maxHeight,
granularity,
arcType,
ellipsoid,
normalsArray,
bottomPositionsArray,
topPositionsArray,
cartographicsArray
);
index = normalsArray.length;
for (i = 0; i < 3; ++i) {
normalsArray[index + i] = normalsArray[i];
bottomPositionsArray[index + i] = bottomPositionsArray[i];
topPositionsArray[index + i] = topPositionsArray[i];
}
cartographicsArray.push(startCartographic.latitude);
cartographicsArray.push(startCartographic.longitude);
}
return generateGeometryAttributes(
loop,
projection,
bottomPositionsArray,
topPositionsArray,
normalsArray,
cartographicsArray,
compute2dAttributes
);
};
var lineDirectionScratch = new Cartesian3_default();
var matrix3Scratch = new Matrix3_default();
var quaternionScratch3 = new Quaternion_default();
function breakMiter(endGeometryNormal, startBottom, endBottom, endTop) {
const lineDirection = direction(endBottom, startBottom, lineDirectionScratch);
const dot2 = Cartesian3_default.dot(lineDirection, endGeometryNormal);
if (dot2 > MITER_BREAK_SMALL || dot2 < MITER_BREAK_LARGE) {
const vertexUp = direction(endTop, endBottom, vertexUpScratch);
const angle = dot2 < MITER_BREAK_LARGE ? Math_default.PI_OVER_TWO : -Math_default.PI_OVER_TWO;
const quaternion = Quaternion_default.fromAxisAngle(
vertexUp,
angle,
quaternionScratch3
);
const rotationMatrix = Matrix3_default.fromQuaternion(quaternion, matrix3Scratch);
Matrix3_default.multiplyByVector(
rotationMatrix,
endGeometryNormal,
endGeometryNormal
);
return true;
}
return false;
}
var endPosCartographicScratch = new Cartographic_default();
var normalStartpointScratch = new Cartesian3_default();
var normalEndpointScratch = new Cartesian3_default();
function projectNormal(projection, cartographic2, normal2, projectedPosition2, result) {
const position = Cartographic_default.toCartesian(
cartographic2,
projection._ellipsoid,
normalStartpointScratch
);
let normalEndpoint = Cartesian3_default.add(position, normal2, normalEndpointScratch);
let flipNormal = false;
const ellipsoid = projection._ellipsoid;
let normalEndpointCartographic = ellipsoid.cartesianToCartographic(
normalEndpoint,
endPosCartographicScratch
);
if (Math.abs(cartographic2.longitude - normalEndpointCartographic.longitude) > Math_default.PI_OVER_TWO) {
flipNormal = true;
normalEndpoint = Cartesian3_default.subtract(
position,
normal2,
normalEndpointScratch
);
normalEndpointCartographic = ellipsoid.cartesianToCartographic(
normalEndpoint,
endPosCartographicScratch
);
}
normalEndpointCartographic.height = 0;
const normalEndpointProjected = projection.project(
normalEndpointCartographic,
result
);
result = Cartesian3_default.subtract(
normalEndpointProjected,
projectedPosition2,
result
);
result.z = 0;
result = Cartesian3_default.normalize(result, result);
if (flipNormal) {
Cartesian3_default.negate(result, result);
}
return result;
}
var adjustHeightNormalScratch = new Cartesian3_default();
var adjustHeightOffsetScratch = new Cartesian3_default();
function adjustHeights(bottom, top, minHeight, maxHeight, adjustHeightBottom, adjustHeightTop) {
const adjustHeightNormal = Cartesian3_default.subtract(
top,
bottom,
adjustHeightNormalScratch
);
Cartesian3_default.normalize(adjustHeightNormal, adjustHeightNormal);
const distanceForBottom = minHeight - WALL_INITIAL_MIN_HEIGHT;
let adjustHeightOffset = Cartesian3_default.multiplyByScalar(
adjustHeightNormal,
distanceForBottom,
adjustHeightOffsetScratch
);
Cartesian3_default.add(bottom, adjustHeightOffset, adjustHeightBottom);
const distanceForTop = maxHeight - WALL_INITIAL_MAX_HEIGHT;
adjustHeightOffset = Cartesian3_default.multiplyByScalar(
adjustHeightNormal,
distanceForTop,
adjustHeightOffsetScratch
);
Cartesian3_default.add(top, adjustHeightOffset, adjustHeightTop);
}
var nudgeDirectionScratch = new Cartesian3_default();
function nudgeXZ(start, end) {
const startToXZdistance = Plane_default.getPointDistance(XZ_PLANE, start);
const endToXZdistance = Plane_default.getPointDistance(XZ_PLANE, end);
let offset2 = nudgeDirectionScratch;
if (Math_default.equalsEpsilon(startToXZdistance, 0, Math_default.EPSILON2)) {
offset2 = direction(end, start, offset2);
Cartesian3_default.multiplyByScalar(offset2, Math_default.EPSILON2, offset2);
Cartesian3_default.add(start, offset2, start);
} else if (Math_default.equalsEpsilon(endToXZdistance, 0, Math_default.EPSILON2)) {
offset2 = direction(start, end, offset2);
Cartesian3_default.multiplyByScalar(offset2, Math_default.EPSILON2, offset2);
Cartesian3_default.add(end, offset2, end);
}
}
function nudgeCartographic(start, end) {
const absStartLon = Math.abs(start.longitude);
const absEndLon = Math.abs(end.longitude);
if (Math_default.equalsEpsilon(absStartLon, Math_default.PI, Math_default.EPSILON11)) {
const endSign = Math_default.sign(end.longitude);
start.longitude = endSign * (absStartLon - Math_default.EPSILON11);
return 1;
} else if (Math_default.equalsEpsilon(absEndLon, Math_default.PI, Math_default.EPSILON11)) {
const startSign = Math_default.sign(start.longitude);
end.longitude = startSign * (absEndLon - Math_default.EPSILON11);
return 2;
}
return 0;
}
var startCartographicScratch = new Cartographic_default();
var endCartographicScratch = new Cartographic_default();
var segmentStartTopScratch = new Cartesian3_default();
var segmentEndTopScratch = new Cartesian3_default();
var segmentStartBottomScratch = new Cartesian3_default();
var segmentEndBottomScratch = new Cartesian3_default();
var segmentStartNormalScratch = new Cartesian3_default();
var segmentEndNormalScratch = new Cartesian3_default();
var getHeightCartographics = [
startCartographicScratch,
endCartographicScratch
];
var getHeightRectangleScratch = new Rectangle_default();
var adjustHeightStartTopScratch = new Cartesian3_default();
var adjustHeightEndTopScratch = new Cartesian3_default();
var adjustHeightStartBottomScratch = new Cartesian3_default();
var adjustHeightEndBottomScratch = new Cartesian3_default();
var segmentStart2DScratch = new Cartesian3_default();
var segmentEnd2DScratch = new Cartesian3_default();
var segmentStartNormal2DScratch = new Cartesian3_default();
var segmentEndNormal2DScratch = new Cartesian3_default();
var offsetScratch2 = new Cartesian3_default();
var startUpScratch = new Cartesian3_default();
var endUpScratch = new Cartesian3_default();
var rightScratch2 = new Cartesian3_default();
var startPlaneNormalScratch = new Cartesian3_default();
var endPlaneNormalScratch = new Cartesian3_default();
var encodeScratch = new EncodedCartesian3_default();
var encodeScratch2D = new EncodedCartesian3_default();
var forwardOffset2DScratch = new Cartesian3_default();
var right2DScratch = new Cartesian3_default();
var normalNudgeScratch = new Cartesian3_default();
var scratchBoundingSpheres = [new BoundingSphere_default(), new BoundingSphere_default()];
var REFERENCE_INDICES = [
0,
2,
1,
0,
3,
2,
0,
7,
3,
0,
4,
7,
0,
5,
4,
0,
1,
5,
5,
7,
4,
5,
6,
7,
5,
2,
6,
5,
1,
2,
3,
6,
2,
3,
7,
6
];
var REFERENCE_INDICES_LENGTH = REFERENCE_INDICES.length;
function generateGeometryAttributes(loop, projection, bottomPositionsArray, topPositionsArray, normalsArray, cartographicsArray, compute2dAttributes) {
let i;
let index;
const ellipsoid = projection._ellipsoid;
const segmentCount = bottomPositionsArray.length / 3 - 1;
const vertexCount = segmentCount * 8;
const arraySizeVec4 = vertexCount * 4;
const indexCount = segmentCount * 36;
const indices2 = vertexCount > 65535 ? new Uint32Array(indexCount) : new Uint16Array(indexCount);
const positionsArray = new Float64Array(vertexCount * 3);
const startHiAndForwardOffsetX = new Float32Array(arraySizeVec4);
const startLoAndForwardOffsetY = new Float32Array(arraySizeVec4);
const startNormalAndForwardOffsetZ = new Float32Array(arraySizeVec4);
const endNormalAndTextureCoordinateNormalizationX = new Float32Array(
arraySizeVec4
);
const rightNormalAndTextureCoordinateNormalizationY = new Float32Array(
arraySizeVec4
);
let startHiLo2D;
let offsetAndRight2D;
let startEndNormals2D;
let texcoordNormalization2D;
if (compute2dAttributes) {
startHiLo2D = new Float32Array(arraySizeVec4);
offsetAndRight2D = new Float32Array(arraySizeVec4);
startEndNormals2D = new Float32Array(arraySizeVec4);
texcoordNormalization2D = new Float32Array(vertexCount * 2);
}
const cartographicsLength = cartographicsArray.length / 2;
let length2D = 0;
const startCartographic = startCartographicScratch;
startCartographic.height = 0;
const endCartographic = endCartographicScratch;
endCartographic.height = 0;
let segmentStartCartesian = segmentStartTopScratch;
let segmentEndCartesian = segmentEndTopScratch;
if (compute2dAttributes) {
index = 0;
for (i = 1; i < cartographicsLength; i++) {
startCartographic.latitude = cartographicsArray[index];
startCartographic.longitude = cartographicsArray[index + 1];
endCartographic.latitude = cartographicsArray[index + 2];
endCartographic.longitude = cartographicsArray[index + 3];
segmentStartCartesian = projection.project(
startCartographic,
segmentStartCartesian
);
segmentEndCartesian = projection.project(
endCartographic,
segmentEndCartesian
);
length2D += Cartesian3_default.distance(
segmentStartCartesian,
segmentEndCartesian
);
index += 2;
}
}
const positionsLength = topPositionsArray.length / 3;
segmentEndCartesian = Cartesian3_default.unpack(
topPositionsArray,
0,
segmentEndCartesian
);
let length3D = 0;
index = 3;
for (i = 1; i < positionsLength; i++) {
segmentStartCartesian = Cartesian3_default.clone(
segmentEndCartesian,
segmentStartCartesian
);
segmentEndCartesian = Cartesian3_default.unpack(
topPositionsArray,
index,
segmentEndCartesian
);
length3D += Cartesian3_default.distance(segmentStartCartesian, segmentEndCartesian);
index += 3;
}
let j;
index = 3;
let cartographicsIndex = 0;
let vec2sWriteIndex = 0;
let vec3sWriteIndex = 0;
let vec4sWriteIndex = 0;
let miterBroken = false;
let endBottom = Cartesian3_default.unpack(
bottomPositionsArray,
0,
segmentEndBottomScratch
);
let endTop = Cartesian3_default.unpack(topPositionsArray, 0, segmentEndTopScratch);
let endGeometryNormal = Cartesian3_default.unpack(
normalsArray,
0,
segmentEndNormalScratch
);
if (loop) {
const preEndBottom = Cartesian3_default.unpack(
bottomPositionsArray,
bottomPositionsArray.length - 6,
segmentStartBottomScratch
);
if (breakMiter(endGeometryNormal, preEndBottom, endBottom, endTop)) {
endGeometryNormal = Cartesian3_default.negate(
endGeometryNormal,
endGeometryNormal
);
}
}
let lengthSoFar3D = 0;
let lengthSoFar2D = 0;
let sumHeights = 0;
for (i = 0; i < segmentCount; i++) {
const startBottom = Cartesian3_default.clone(endBottom, segmentStartBottomScratch);
const startTop = Cartesian3_default.clone(endTop, segmentStartTopScratch);
let startGeometryNormal = Cartesian3_default.clone(
endGeometryNormal,
segmentStartNormalScratch
);
if (miterBroken) {
startGeometryNormal = Cartesian3_default.negate(
startGeometryNormal,
startGeometryNormal
);
}
endBottom = Cartesian3_default.unpack(
bottomPositionsArray,
index,
segmentEndBottomScratch
);
endTop = Cartesian3_default.unpack(topPositionsArray, index, segmentEndTopScratch);
endGeometryNormal = Cartesian3_default.unpack(
normalsArray,
index,
segmentEndNormalScratch
);
miterBroken = breakMiter(endGeometryNormal, startBottom, endBottom, endTop);
startCartographic.latitude = cartographicsArray[cartographicsIndex];
startCartographic.longitude = cartographicsArray[cartographicsIndex + 1];
endCartographic.latitude = cartographicsArray[cartographicsIndex + 2];
endCartographic.longitude = cartographicsArray[cartographicsIndex + 3];
let start2D;
let end2D;
let startGeometryNormal2D;
let endGeometryNormal2D;
if (compute2dAttributes) {
const nudgeResult = nudgeCartographic(startCartographic, endCartographic);
start2D = projection.project(startCartographic, segmentStart2DScratch);
end2D = projection.project(endCartographic, segmentEnd2DScratch);
const direction2D = direction(end2D, start2D, forwardOffset2DScratch);
direction2D.y = Math.abs(direction2D.y);
startGeometryNormal2D = segmentStartNormal2DScratch;
endGeometryNormal2D = segmentEndNormal2DScratch;
if (nudgeResult === 0 || Cartesian3_default.dot(direction2D, Cartesian3_default.UNIT_Y) > MITER_BREAK_SMALL) {
startGeometryNormal2D = projectNormal(
projection,
startCartographic,
startGeometryNormal,
start2D,
segmentStartNormal2DScratch
);
endGeometryNormal2D = projectNormal(
projection,
endCartographic,
endGeometryNormal,
end2D,
segmentEndNormal2DScratch
);
} else if (nudgeResult === 1) {
endGeometryNormal2D = projectNormal(
projection,
endCartographic,
endGeometryNormal,
end2D,
segmentEndNormal2DScratch
);
startGeometryNormal2D.x = 0;
startGeometryNormal2D.y = Math_default.sign(
startCartographic.longitude - Math.abs(endCartographic.longitude)
);
startGeometryNormal2D.z = 0;
} else {
startGeometryNormal2D = projectNormal(
projection,
startCartographic,
startGeometryNormal,
start2D,
segmentStartNormal2DScratch
);
endGeometryNormal2D.x = 0;
endGeometryNormal2D.y = Math_default.sign(
startCartographic.longitude - endCartographic.longitude
);
endGeometryNormal2D.z = 0;
}
}
const segmentLength3D = Cartesian3_default.distance(startTop, endTop);
const encodedStart = EncodedCartesian3_default.fromCartesian(
startBottom,
encodeScratch
);
const forwardOffset = Cartesian3_default.subtract(
endBottom,
startBottom,
offsetScratch2
);
const forward = Cartesian3_default.normalize(forwardOffset, rightScratch2);
let startUp = Cartesian3_default.subtract(startTop, startBottom, startUpScratch);
startUp = Cartesian3_default.normalize(startUp, startUp);
let rightNormal = Cartesian3_default.cross(forward, startUp, rightScratch2);
rightNormal = Cartesian3_default.normalize(rightNormal, rightNormal);
let startPlaneNormal = Cartesian3_default.cross(
startUp,
startGeometryNormal,
startPlaneNormalScratch
);
startPlaneNormal = Cartesian3_default.normalize(startPlaneNormal, startPlaneNormal);
let endUp = Cartesian3_default.subtract(endTop, endBottom, endUpScratch);
endUp = Cartesian3_default.normalize(endUp, endUp);
let endPlaneNormal = Cartesian3_default.cross(
endGeometryNormal,
endUp,
endPlaneNormalScratch
);
endPlaneNormal = Cartesian3_default.normalize(endPlaneNormal, endPlaneNormal);
const texcoordNormalization3DX = segmentLength3D / length3D;
const texcoordNormalization3DY = lengthSoFar3D / length3D;
let segmentLength2D = 0;
let encodedStart2D;
let forwardOffset2D;
let right2D;
let texcoordNormalization2DX = 0;
let texcoordNormalization2DY = 0;
if (compute2dAttributes) {
segmentLength2D = Cartesian3_default.distance(start2D, end2D);
encodedStart2D = EncodedCartesian3_default.fromCartesian(
start2D,
encodeScratch2D
);
forwardOffset2D = Cartesian3_default.subtract(
end2D,
start2D,
forwardOffset2DScratch
);
right2D = Cartesian3_default.normalize(forwardOffset2D, right2DScratch);
const swap3 = right2D.x;
right2D.x = right2D.y;
right2D.y = -swap3;
texcoordNormalization2DX = segmentLength2D / length2D;
texcoordNormalization2DY = lengthSoFar2D / length2D;
}
for (j = 0; j < 8; j++) {
const vec4Index = vec4sWriteIndex + j * 4;
const vec2Index = vec2sWriteIndex + j * 2;
const wIndex = vec4Index + 3;
const rightPlaneSide = j < 4 ? 1 : -1;
const topBottomSide = j === 2 || j === 3 || j === 6 || j === 7 ? 1 : -1;
Cartesian3_default.pack(encodedStart.high, startHiAndForwardOffsetX, vec4Index);
startHiAndForwardOffsetX[wIndex] = forwardOffset.x;
Cartesian3_default.pack(encodedStart.low, startLoAndForwardOffsetY, vec4Index);
startLoAndForwardOffsetY[wIndex] = forwardOffset.y;
Cartesian3_default.pack(
startPlaneNormal,
startNormalAndForwardOffsetZ,
vec4Index
);
startNormalAndForwardOffsetZ[wIndex] = forwardOffset.z;
Cartesian3_default.pack(
endPlaneNormal,
endNormalAndTextureCoordinateNormalizationX,
vec4Index
);
endNormalAndTextureCoordinateNormalizationX[wIndex] = texcoordNormalization3DX * rightPlaneSide;
Cartesian3_default.pack(
rightNormal,
rightNormalAndTextureCoordinateNormalizationY,
vec4Index
);
let texcoordNormalization = texcoordNormalization3DY * topBottomSide;
if (texcoordNormalization === 0 && topBottomSide < 0) {
texcoordNormalization = 9;
}
rightNormalAndTextureCoordinateNormalizationY[wIndex] = texcoordNormalization;
if (compute2dAttributes) {
startHiLo2D[vec4Index] = encodedStart2D.high.x;
startHiLo2D[vec4Index + 1] = encodedStart2D.high.y;
startHiLo2D[vec4Index + 2] = encodedStart2D.low.x;
startHiLo2D[vec4Index + 3] = encodedStart2D.low.y;
startEndNormals2D[vec4Index] = -startGeometryNormal2D.y;
startEndNormals2D[vec4Index + 1] = startGeometryNormal2D.x;
startEndNormals2D[vec4Index + 2] = endGeometryNormal2D.y;
startEndNormals2D[vec4Index + 3] = -endGeometryNormal2D.x;
offsetAndRight2D[vec4Index] = forwardOffset2D.x;
offsetAndRight2D[vec4Index + 1] = forwardOffset2D.y;
offsetAndRight2D[vec4Index + 2] = right2D.x;
offsetAndRight2D[vec4Index + 3] = right2D.y;
texcoordNormalization2D[vec2Index] = texcoordNormalization2DX * rightPlaneSide;
texcoordNormalization = texcoordNormalization2DY * topBottomSide;
if (texcoordNormalization === 0 && topBottomSide < 0) {
texcoordNormalization = 9;
}
texcoordNormalization2D[vec2Index + 1] = texcoordNormalization;
}
}
const adjustHeightStartBottom = adjustHeightStartBottomScratch;
const adjustHeightEndBottom = adjustHeightEndBottomScratch;
const adjustHeightStartTop = adjustHeightStartTopScratch;
const adjustHeightEndTop = adjustHeightEndTopScratch;
const getHeightsRectangle = Rectangle_default.fromCartographicArray(
getHeightCartographics,
getHeightRectangleScratch
);
const minMaxHeights = ApproximateTerrainHeights_default.getMinimumMaximumHeights(
getHeightsRectangle,
ellipsoid
);
const minHeight = minMaxHeights.minimumTerrainHeight;
const maxHeight = minMaxHeights.maximumTerrainHeight;
sumHeights += minHeight;
sumHeights += maxHeight;
adjustHeights(
startBottom,
startTop,
minHeight,
maxHeight,
adjustHeightStartBottom,
adjustHeightStartTop
);
adjustHeights(
endBottom,
endTop,
minHeight,
maxHeight,
adjustHeightEndBottom,
adjustHeightEndTop
);
let normalNudge = Cartesian3_default.multiplyByScalar(
rightNormal,
Math_default.EPSILON5,
normalNudgeScratch
);
Cartesian3_default.add(
adjustHeightStartBottom,
normalNudge,
adjustHeightStartBottom
);
Cartesian3_default.add(adjustHeightEndBottom, normalNudge, adjustHeightEndBottom);
Cartesian3_default.add(adjustHeightStartTop, normalNudge, adjustHeightStartTop);
Cartesian3_default.add(adjustHeightEndTop, normalNudge, adjustHeightEndTop);
nudgeXZ(adjustHeightStartBottom, adjustHeightEndBottom);
nudgeXZ(adjustHeightStartTop, adjustHeightEndTop);
Cartesian3_default.pack(adjustHeightStartBottom, positionsArray, vec3sWriteIndex);
Cartesian3_default.pack(adjustHeightEndBottom, positionsArray, vec3sWriteIndex + 3);
Cartesian3_default.pack(adjustHeightEndTop, positionsArray, vec3sWriteIndex + 6);
Cartesian3_default.pack(adjustHeightStartTop, positionsArray, vec3sWriteIndex + 9);
normalNudge = Cartesian3_default.multiplyByScalar(
rightNormal,
-2 * Math_default.EPSILON5,
normalNudgeScratch
);
Cartesian3_default.add(
adjustHeightStartBottom,
normalNudge,
adjustHeightStartBottom
);
Cartesian3_default.add(adjustHeightEndBottom, normalNudge, adjustHeightEndBottom);
Cartesian3_default.add(adjustHeightStartTop, normalNudge, adjustHeightStartTop);
Cartesian3_default.add(adjustHeightEndTop, normalNudge, adjustHeightEndTop);
nudgeXZ(adjustHeightStartBottom, adjustHeightEndBottom);
nudgeXZ(adjustHeightStartTop, adjustHeightEndTop);
Cartesian3_default.pack(
adjustHeightStartBottom,
positionsArray,
vec3sWriteIndex + 12
);
Cartesian3_default.pack(
adjustHeightEndBottom,
positionsArray,
vec3sWriteIndex + 15
);
Cartesian3_default.pack(adjustHeightEndTop, positionsArray, vec3sWriteIndex + 18);
Cartesian3_default.pack(adjustHeightStartTop, positionsArray, vec3sWriteIndex + 21);
cartographicsIndex += 2;
index += 3;
vec2sWriteIndex += 16;
vec3sWriteIndex += 24;
vec4sWriteIndex += 32;
lengthSoFar3D += segmentLength3D;
lengthSoFar2D += segmentLength2D;
}
index = 0;
let indexOffset = 0;
for (i = 0; i < segmentCount; i++) {
for (j = 0; j < REFERENCE_INDICES_LENGTH; j++) {
indices2[index + j] = REFERENCE_INDICES[j] + indexOffset;
}
indexOffset += 8;
index += REFERENCE_INDICES_LENGTH;
}
const boundingSpheres = scratchBoundingSpheres;
BoundingSphere_default.fromVertices(
bottomPositionsArray,
Cartesian3_default.ZERO,
3,
boundingSpheres[0]
);
BoundingSphere_default.fromVertices(
topPositionsArray,
Cartesian3_default.ZERO,
3,
boundingSpheres[1]
);
const boundingSphere = BoundingSphere_default.fromBoundingSpheres(boundingSpheres);
boundingSphere.radius += sumHeights / (segmentCount * 2);
const attributes = {
position: new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.DOUBLE,
componentsPerAttribute: 3,
normalize: false,
values: positionsArray
}),
startHiAndForwardOffsetX: getVec4GeometryAttribute(
startHiAndForwardOffsetX
),
startLoAndForwardOffsetY: getVec4GeometryAttribute(
startLoAndForwardOffsetY
),
startNormalAndForwardOffsetZ: getVec4GeometryAttribute(
startNormalAndForwardOffsetZ
),
endNormalAndTextureCoordinateNormalizationX: getVec4GeometryAttribute(
endNormalAndTextureCoordinateNormalizationX
),
rightNormalAndTextureCoordinateNormalizationY: getVec4GeometryAttribute(
rightNormalAndTextureCoordinateNormalizationY
)
};
if (compute2dAttributes) {
attributes.startHiLo2D = getVec4GeometryAttribute(startHiLo2D);
attributes.offsetAndRight2D = getVec4GeometryAttribute(offsetAndRight2D);
attributes.startEndNormals2D = getVec4GeometryAttribute(startEndNormals2D);
attributes.texcoordNormalization2D = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.FLOAT,
componentsPerAttribute: 2,
normalize: false,
values: texcoordNormalization2D
});
}
return new Geometry_default({
attributes,
indices: indices2,
boundingSphere
});
}
function getVec4GeometryAttribute(typedArray) {
return new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.FLOAT,
componentsPerAttribute: 4,
normalize: false,
values: typedArray
});
}
GroundPolylineGeometry._projectNormal = projectNormal;
var GroundPolylineGeometry_default = GroundPolylineGeometry;
// Source/Core/HeadingPitchRange.js
function HeadingPitchRange(heading, pitch, range) {
this.heading = defaultValue_default(heading, 0);
this.pitch = defaultValue_default(pitch, 0);
this.range = defaultValue_default(range, 0);
}
HeadingPitchRange.clone = function(hpr, result) {
if (!defined_default(hpr)) {
return void 0;
}
if (!defined_default(result)) {
result = new HeadingPitchRange();
}
result.heading = hpr.heading;
result.pitch = hpr.pitch;
result.range = hpr.range;
return result;
};
var HeadingPitchRange_default = HeadingPitchRange;
// Source/Core/HermitePolynomialApproximation.js
var factorial = Math_default.factorial;
function calculateCoefficientTerm(x, zIndices, xTable, derivOrder, termOrder, reservedIndices) {
let result = 0;
let reserved;
let i;
let j;
if (derivOrder > 0) {
for (i = 0; i < termOrder; i++) {
reserved = false;
for (j = 0; j < reservedIndices.length && !reserved; j++) {
if (i === reservedIndices[j]) {
reserved = true;
}
}
if (!reserved) {
reservedIndices.push(i);
result += calculateCoefficientTerm(
x,
zIndices,
xTable,
derivOrder - 1,
termOrder,
reservedIndices
);
reservedIndices.splice(reservedIndices.length - 1, 1);
}
}
return result;
}
result = 1;
for (i = 0; i < termOrder; i++) {
reserved = false;
for (j = 0; j < reservedIndices.length && !reserved; j++) {
if (i === reservedIndices[j]) {
reserved = true;
}
}
if (!reserved) {
result *= x - xTable[zIndices[i]];
}
}
return result;
}
var HermitePolynomialApproximation = {
type: "Hermite"
};
HermitePolynomialApproximation.getRequiredDataPoints = function(degree, inputOrder) {
inputOrder = defaultValue_default(inputOrder, 0);
if (!defined_default(degree)) {
throw new DeveloperError_default("degree is required.");
}
if (degree < 0) {
throw new DeveloperError_default("degree must be 0 or greater.");
}
if (inputOrder < 0) {
throw new DeveloperError_default("inputOrder must be 0 or greater.");
}
return Math.max(Math.floor((degree + 1) / (inputOrder + 1)), 2);
};
HermitePolynomialApproximation.interpolateOrderZero = function(x, xTable, yTable, yStride, result) {
if (!defined_default(result)) {
result = new Array(yStride);
}
let i;
let j;
let d;
let s;
let len;
let index;
const length3 = xTable.length;
const coefficients = new Array(yStride);
for (i = 0; i < yStride; i++) {
result[i] = 0;
const l = new Array(length3);
coefficients[i] = l;
for (j = 0; j < length3; j++) {
l[j] = [];
}
}
const zIndicesLength = length3, zIndices = new Array(zIndicesLength);
for (i = 0; i < zIndicesLength; i++) {
zIndices[i] = i;
}
let highestNonZeroCoef = length3 - 1;
for (s = 0; s < yStride; s++) {
for (j = 0; j < zIndicesLength; j++) {
index = zIndices[j] * yStride + s;
coefficients[s][0].push(yTable[index]);
}
for (i = 1; i < zIndicesLength; i++) {
let nonZeroCoefficients = false;
for (j = 0; j < zIndicesLength - i; j++) {
const zj = xTable[zIndices[j]];
const zn = xTable[zIndices[j + i]];
let numerator;
if (zn - zj <= 0) {
index = zIndices[j] * yStride + yStride * i + s;
numerator = yTable[index];
coefficients[s][i].push(numerator / factorial(i));
} else {
numerator = coefficients[s][i - 1][j + 1] - coefficients[s][i - 1][j];
coefficients[s][i].push(numerator / (zn - zj));
}
nonZeroCoefficients = nonZeroCoefficients || numerator !== 0;
}
if (!nonZeroCoefficients) {
highestNonZeroCoef = i - 1;
}
}
}
for (d = 0, len = 0; d <= len; d++) {
for (i = d; i <= highestNonZeroCoef; i++) {
const tempTerm = calculateCoefficientTerm(x, zIndices, xTable, d, i, []);
for (s = 0; s < yStride; s++) {
const coeff = coefficients[s][i][0];
result[s + d * yStride] += coeff * tempTerm;
}
}
}
return result;
};
var arrayScratch2 = [];
HermitePolynomialApproximation.interpolate = function(x, xTable, yTable, yStride, inputOrder, outputOrder, result) {
const resultLength = yStride * (outputOrder + 1);
if (!defined_default(result)) {
result = new Array(resultLength);
}
for (let r = 0; r < resultLength; r++) {
result[r] = 0;
}
const length3 = xTable.length;
const zIndices = new Array(length3 * (inputOrder + 1));
let i;
for (i = 0; i < length3; i++) {
for (let j = 0; j < inputOrder + 1; j++) {
zIndices[i * (inputOrder + 1) + j] = i;
}
}
const zIndiceslength = zIndices.length;
const coefficients = arrayScratch2;
const highestNonZeroCoef = fillCoefficientList(
coefficients,
zIndices,
xTable,
yTable,
yStride,
inputOrder
);
const reservedIndices = [];
const tmp2 = zIndiceslength * (zIndiceslength + 1) / 2;
const loopStop = Math.min(highestNonZeroCoef, outputOrder);
for (let d = 0; d <= loopStop; d++) {
for (i = d; i <= highestNonZeroCoef; i++) {
reservedIndices.length = 0;
const tempTerm = calculateCoefficientTerm(
x,
zIndices,
xTable,
d,
i,
reservedIndices
);
const dimTwo = Math.floor(i * (1 - i) / 2) + zIndiceslength * i;
for (let s = 0; s < yStride; s++) {
const dimOne = Math.floor(s * tmp2);
const coef = coefficients[dimOne + dimTwo];
result[s + d * yStride] += coef * tempTerm;
}
}
}
return result;
};
function fillCoefficientList(coefficients, zIndices, xTable, yTable, yStride, inputOrder) {
let j;
let index;
let highestNonZero = -1;
const zIndiceslength = zIndices.length;
const tmp2 = zIndiceslength * (zIndiceslength + 1) / 2;
for (let s = 0; s < yStride; s++) {
const dimOne = Math.floor(s * tmp2);
for (j = 0; j < zIndiceslength; j++) {
index = zIndices[j] * yStride * (inputOrder + 1) + s;
coefficients[dimOne + j] = yTable[index];
}
for (let i = 1; i < zIndiceslength; i++) {
let coefIndex = 0;
const dimTwo = Math.floor(i * (1 - i) / 2) + zIndiceslength * i;
let nonZeroCoefficients = false;
for (j = 0; j < zIndiceslength - i; j++) {
const zj = xTable[zIndices[j]];
const zn = xTable[zIndices[j + i]];
let numerator;
let coefficient;
if (zn - zj <= 0) {
index = zIndices[j] * yStride * (inputOrder + 1) + yStride * i + s;
numerator = yTable[index];
coefficient = numerator / Math_default.factorial(i);
coefficients[dimOne + dimTwo + coefIndex] = coefficient;
coefIndex++;
} else {
const dimTwoMinusOne = Math.floor((i - 1) * (2 - i) / 2) + zIndiceslength * (i - 1);
numerator = coefficients[dimOne + dimTwoMinusOne + j + 1] - coefficients[dimOne + dimTwoMinusOne + j];
coefficient = numerator / (zn - zj);
coefficients[dimOne + dimTwo + coefIndex] = coefficient;
coefIndex++;
}
nonZeroCoefficients = nonZeroCoefficients || numerator !== 0;
}
if (nonZeroCoefficients) {
highestNonZero = Math.max(highestNonZero, i);
}
}
}
return highestNonZero;
}
var HermitePolynomialApproximation_default = HermitePolynomialApproximation;
// Source/Core/HilbertOrder.js
var HilbertOrder = {};
HilbertOrder.encode2D = function(level, x, y) {
const n = Math.pow(2, level);
Check_default.typeOf.number("level", level);
Check_default.typeOf.number("x", x);
Check_default.typeOf.number("y", y);
if (level < 1) {
throw new DeveloperError_default("Hilbert level cannot be less than 1.");
}
if (x < 0 || x >= n || y < 0 || y >= n) {
throw new DeveloperError_default("Invalid coordinates for given level.");
}
const p = {
x,
y
};
let rx, ry, s, index = BigInt(0);
for (s = n / 2; s > 0; s /= 2) {
rx = (p.x & s) > 0 ? 1 : 0;
ry = (p.y & s) > 0 ? 1 : 0;
index += BigInt((3 * rx ^ ry) * s * s);
rotate(n, p, rx, ry);
}
return index;
};
HilbertOrder.decode2D = function(level, index) {
Check_default.typeOf.number("level", level);
Check_default.typeOf.bigint("index", index);
if (level < 1) {
throw new DeveloperError_default("Hilbert level cannot be less than 1.");
}
if (index < BigInt(0) || index >= BigInt(Math.pow(4, level))) {
throw new DeveloperError_default(
"Hilbert index exceeds valid maximum for given level."
);
}
const n = Math.pow(2, level);
const p = {
x: 0,
y: 0
};
let rx, ry, s, t;
for (s = 1, t = index; s < n; s *= 2) {
rx = 1 & Number(t / BigInt(2));
ry = 1 & Number(t ^ BigInt(rx));
rotate(s, p, rx, ry);
p.x += s * rx;
p.y += s * ry;
t /= BigInt(4);
}
return [p.x, p.y];
};
function rotate(n, p, rx, ry) {
if (ry !== 0) {
return;
}
if (rx === 1) {
p.x = n - 1 - p.x;
p.y = n - 1 - p.y;
}
const t = p.x;
p.x = p.y;
p.y = t;
}
var HilbertOrder_default = HilbertOrder;
// Source/Core/IauOrientationParameters.js
function IauOrientationParameters(rightAscension, declination, rotation, rotationRate) {
this.rightAscension = rightAscension;
this.declination = declination;
this.rotation = rotation;
this.rotationRate = rotationRate;
}
var IauOrientationParameters_default = IauOrientationParameters;
// Source/Core/Iau2000Orientation.js
var Iau2000Orientation = {};
var TdtMinusTai = 32.184;
var J2000d = 2451545;
var c1 = -0.0529921;
var c2 = -0.1059842;
var c32 = 13.0120009;
var c4 = 13.3407154;
var c5 = 0.9856003;
var c6 = 26.4057084;
var c7 = 13.064993;
var c8 = 0.3287146;
var c9 = 1.7484877;
var c10 = -0.1589763;
var c11 = 36096e-7;
var c12 = 0.1643573;
var c13 = 12.9590088;
var dateTT = new JulianDate_default();
Iau2000Orientation.ComputeMoon = function(date, result) {
if (!defined_default(date)) {
date = JulianDate_default.now();
}
dateTT = JulianDate_default.addSeconds(date, TdtMinusTai, dateTT);
const d = JulianDate_default.totalDays(dateTT) - J2000d;
const T = d / TimeConstants_default.DAYS_PER_JULIAN_CENTURY;
const E1 = (125.045 + c1 * d) * Math_default.RADIANS_PER_DEGREE;
const E2 = (250.089 + c2 * d) * Math_default.RADIANS_PER_DEGREE;
const E3 = (260.008 + c32 * d) * Math_default.RADIANS_PER_DEGREE;
const E4 = (176.625 + c4 * d) * Math_default.RADIANS_PER_DEGREE;
const E5 = (357.529 + c5 * d) * Math_default.RADIANS_PER_DEGREE;
const E6 = (311.589 + c6 * d) * Math_default.RADIANS_PER_DEGREE;
const E7 = (134.963 + c7 * d) * Math_default.RADIANS_PER_DEGREE;
const E8 = (276.617 + c8 * d) * Math_default.RADIANS_PER_DEGREE;
const E9 = (34.226 + c9 * d) * Math_default.RADIANS_PER_DEGREE;
const E10 = (15.134 + c10 * d) * Math_default.RADIANS_PER_DEGREE;
const E11 = (119.743 + c11 * d) * Math_default.RADIANS_PER_DEGREE;
const E12 = (239.961 + c12 * d) * Math_default.RADIANS_PER_DEGREE;
const E13 = (25.053 + c13 * d) * Math_default.RADIANS_PER_DEGREE;
const sinE1 = Math.sin(E1);
const sinE2 = Math.sin(E2);
const sinE3 = Math.sin(E3);
const sinE4 = Math.sin(E4);
const sinE5 = Math.sin(E5);
const sinE6 = Math.sin(E6);
const sinE7 = Math.sin(E7);
const sinE8 = Math.sin(E8);
const sinE9 = Math.sin(E9);
const sinE10 = Math.sin(E10);
const sinE11 = Math.sin(E11);
const sinE12 = Math.sin(E12);
const sinE13 = Math.sin(E13);
const cosE1 = Math.cos(E1);
const cosE2 = Math.cos(E2);
const cosE3 = Math.cos(E3);
const cosE4 = Math.cos(E4);
const cosE5 = Math.cos(E5);
const cosE6 = Math.cos(E6);
const cosE7 = Math.cos(E7);
const cosE8 = Math.cos(E8);
const cosE9 = Math.cos(E9);
const cosE10 = Math.cos(E10);
const cosE11 = Math.cos(E11);
const cosE12 = Math.cos(E12);
const cosE13 = Math.cos(E13);
const rightAscension = (269.9949 + 31e-4 * T - 3.8787 * sinE1 - 0.1204 * sinE2 + 0.07 * sinE3 - 0.0172 * sinE4 + 72e-4 * sinE6 - 52e-4 * sinE10 + 43e-4 * sinE13) * Math_default.RADIANS_PER_DEGREE;
const declination = (66.5392 + 0.013 * T + 1.5419 * cosE1 + 0.0239 * cosE2 - 0.0278 * cosE3 + 68e-4 * cosE4 - 29e-4 * cosE6 + 9e-4 * cosE7 + 8e-4 * cosE10 - 9e-4 * cosE13) * Math_default.RADIANS_PER_DEGREE;
const rotation = (38.3213 + 13.17635815 * d - 14e-13 * d * d + 3.561 * sinE1 + 0.1208 * sinE2 - 0.0642 * sinE3 + 0.0158 * sinE4 + 0.0252 * sinE5 - 66e-4 * sinE6 - 47e-4 * sinE7 - 46e-4 * sinE8 + 28e-4 * sinE9 + 52e-4 * sinE10 + 4e-3 * sinE11 + 19e-4 * sinE12 - 44e-4 * sinE13) * Math_default.RADIANS_PER_DEGREE;
const rotationRate = (13.17635815 - 14e-13 * (2 * d) + 3.561 * cosE1 * c1 + 0.1208 * cosE2 * c2 - 0.0642 * cosE3 * c32 + 0.0158 * cosE4 * c4 + 0.0252 * cosE5 * c5 - 66e-4 * cosE6 * c6 - 47e-4 * cosE7 * c7 - 46e-4 * cosE8 * c8 + 28e-4 * cosE9 * c9 + 52e-4 * cosE10 * c10 + 4e-3 * cosE11 * c11 + 19e-4 * cosE12 * c12 - 44e-4 * cosE13 * c13) / 86400 * Math_default.RADIANS_PER_DEGREE;
if (!defined_default(result)) {
result = new IauOrientationParameters_default();
}
result.rightAscension = rightAscension;
result.declination = declination;
result.rotation = rotation;
result.rotationRate = rotationRate;
return result;
};
var Iau2000Orientation_default = Iau2000Orientation;
// Source/Core/IauOrientationAxes.js
function IauOrientationAxes(computeFunction) {
if (!defined_default(computeFunction) || typeof computeFunction !== "function") {
computeFunction = Iau2000Orientation_default.ComputeMoon;
}
this._computeFunction = computeFunction;
}
var xAxisScratch = new Cartesian3_default();
var yAxisScratch = new Cartesian3_default();
var zAxisScratch = new Cartesian3_default();
function computeRotationMatrix(alpha, delta, result) {
const xAxis = xAxisScratch;
xAxis.x = Math.cos(alpha + Math_default.PI_OVER_TWO);
xAxis.y = Math.sin(alpha + Math_default.PI_OVER_TWO);
xAxis.z = 0;
const cosDec = Math.cos(delta);
const zAxis = zAxisScratch;
zAxis.x = cosDec * Math.cos(alpha);
zAxis.y = cosDec * Math.sin(alpha);
zAxis.z = Math.sin(delta);
const yAxis = Cartesian3_default.cross(zAxis, xAxis, yAxisScratch);
if (!defined_default(result)) {
result = new Matrix3_default();
}
result[0] = xAxis.x;
result[1] = yAxis.x;
result[2] = zAxis.x;
result[3] = xAxis.y;
result[4] = yAxis.y;
result[5] = zAxis.y;
result[6] = xAxis.z;
result[7] = yAxis.z;
result[8] = zAxis.z;
return result;
}
var rotMtxScratch = new Matrix3_default();
var quatScratch = new Quaternion_default();
IauOrientationAxes.prototype.evaluate = function(date, result) {
if (!defined_default(date)) {
date = JulianDate_default.now();
}
const alphaDeltaW = this._computeFunction(date);
const precMtx = computeRotationMatrix(
alphaDeltaW.rightAscension,
alphaDeltaW.declination,
result
);
const rot = Math_default.zeroToTwoPi(alphaDeltaW.rotation);
const quat = Quaternion_default.fromAxisAngle(Cartesian3_default.UNIT_Z, rot, quatScratch);
const rotMtx2 = Matrix3_default.fromQuaternion(
Quaternion_default.conjugate(quat, quat),
rotMtxScratch
);
const cbi2cbf = Matrix3_default.multiply(rotMtx2, precMtx, precMtx);
return cbi2cbf;
};
var IauOrientationAxes_default = IauOrientationAxes;
// Source/Core/InterpolationAlgorithm.js
var InterpolationAlgorithm = {};
InterpolationAlgorithm.type = void 0;
InterpolationAlgorithm.getRequiredDataPoints = DeveloperError_default.throwInstantiationError;
InterpolationAlgorithm.interpolateOrderZero = DeveloperError_default.throwInstantiationError;
InterpolationAlgorithm.interpolate = DeveloperError_default.throwInstantiationError;
var InterpolationAlgorithm_default = InterpolationAlgorithm;
// Source/Core/InterpolationType.js
var InterpolationType = {
STEP: 0,
LINEAR: 1,
CUBICSPLINE: 2
};
var InterpolationType_default = Object.freeze(InterpolationType);
// Source/Core/PeliasGeocoderService.js
function PeliasGeocoderService(url2) {
Check_default.defined("url", url2);
this._url = Resource_default.createIfNeeded(url2);
this._url.appendForwardSlash();
}
Object.defineProperties(PeliasGeocoderService.prototype, {
url: {
get: function() {
return this._url;
}
}
});
PeliasGeocoderService.prototype.geocode = function(query, type) {
Check_default.typeOf.string("query", query);
const resource = this._url.getDerivedResource({
url: type === GeocodeType_default.AUTOCOMPLETE ? "autocomplete" : "search",
queryParameters: {
text: query
}
});
return resource.fetchJson().then(function(results) {
return results.features.map(function(resultObject) {
let destination;
const bboxDegrees = resultObject.bbox;
if (defined_default(bboxDegrees)) {
destination = Rectangle_default.fromDegrees(
bboxDegrees[0],
bboxDegrees[1],
bboxDegrees[2],
bboxDegrees[3]
);
} else {
const lon = resultObject.geometry.coordinates[0];
const lat = resultObject.geometry.coordinates[1];
destination = Cartesian3_default.fromDegrees(lon, lat);
}
return {
displayName: resultObject.properties.label,
destination
};
});
});
};
var PeliasGeocoderService_default = PeliasGeocoderService;
// Source/Core/IonGeocoderService.js
function IonGeocoderService(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
Check_default.typeOf.object("options.scene", options.scene);
const accessToken = defaultValue_default(options.accessToken, Ion_default.defaultAccessToken);
const server = Resource_default.createIfNeeded(
defaultValue_default(options.server, Ion_default.defaultServer)
);
server.appendForwardSlash();
const defaultTokenCredit2 = Ion_default.getDefaultTokenCredit(accessToken);
if (defined_default(defaultTokenCredit2)) {
options.scene.frameState.creditDisplay.addDefaultCredit(
Credit_default.clone(defaultTokenCredit2)
);
}
const searchEndpoint = server.getDerivedResource({
url: "v1/geocode"
});
if (defined_default(accessToken)) {
searchEndpoint.appendQueryParameters({ access_token: accessToken });
}
this._accessToken = accessToken;
this._server = server;
this._pelias = new PeliasGeocoderService_default(searchEndpoint);
}
IonGeocoderService.prototype.geocode = function(query, geocodeType) {
return this._pelias.geocode(query, geocodeType);
};
var IonGeocoderService_default = IonGeocoderService;
// Source/Core/TimeInterval.js
function TimeInterval(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
this.start = defined_default(options.start) ? JulianDate_default.clone(options.start) : new JulianDate_default();
this.stop = defined_default(options.stop) ? JulianDate_default.clone(options.stop) : new JulianDate_default();
this.data = options.data;
this.isStartIncluded = defaultValue_default(options.isStartIncluded, true);
this.isStopIncluded = defaultValue_default(options.isStopIncluded, true);
}
Object.defineProperties(TimeInterval.prototype, {
isEmpty: {
get: function() {
const stopComparedToStart = JulianDate_default.compare(this.stop, this.start);
return stopComparedToStart < 0 || stopComparedToStart === 0 && (!this.isStartIncluded || !this.isStopIncluded);
}
}
});
var scratchInterval = {
start: void 0,
stop: void 0,
isStartIncluded: void 0,
isStopIncluded: void 0,
data: void 0
};
TimeInterval.fromIso8601 = function(options, result) {
Check_default.typeOf.object("options", options);
Check_default.typeOf.string("options.iso8601", options.iso8601);
const dates = options.iso8601.split("/");
if (dates.length !== 2) {
throw new DeveloperError_default(
"options.iso8601 is an invalid ISO 8601 interval."
);
}
const start = JulianDate_default.fromIso8601(dates[0]);
const stop2 = JulianDate_default.fromIso8601(dates[1]);
const isStartIncluded = defaultValue_default(options.isStartIncluded, true);
const isStopIncluded = defaultValue_default(options.isStopIncluded, true);
const data = options.data;
if (!defined_default(result)) {
scratchInterval.start = start;
scratchInterval.stop = stop2;
scratchInterval.isStartIncluded = isStartIncluded;
scratchInterval.isStopIncluded = isStopIncluded;
scratchInterval.data = data;
return new TimeInterval(scratchInterval);
}
result.start = start;
result.stop = stop2;
result.isStartIncluded = isStartIncluded;
result.isStopIncluded = isStopIncluded;
result.data = data;
return result;
};
TimeInterval.toIso8601 = function(timeInterval, precision) {
Check_default.typeOf.object("timeInterval", timeInterval);
return `${JulianDate_default.toIso8601(
timeInterval.start,
precision
)}/${JulianDate_default.toIso8601(timeInterval.stop, precision)}`;
};
TimeInterval.clone = function(timeInterval, result) {
if (!defined_default(timeInterval)) {
return void 0;
}
if (!defined_default(result)) {
return new TimeInterval(timeInterval);
}
result.start = timeInterval.start;
result.stop = timeInterval.stop;
result.isStartIncluded = timeInterval.isStartIncluded;
result.isStopIncluded = timeInterval.isStopIncluded;
result.data = timeInterval.data;
return result;
};
TimeInterval.equals = function(left, right, dataComparer) {
return left === right || defined_default(left) && defined_default(right) && (left.isEmpty && right.isEmpty || left.isStartIncluded === right.isStartIncluded && left.isStopIncluded === right.isStopIncluded && JulianDate_default.equals(left.start, right.start) && JulianDate_default.equals(left.stop, right.stop) && (left.data === right.data || defined_default(dataComparer) && dataComparer(left.data, right.data)));
};
TimeInterval.equalsEpsilon = function(left, right, epsilon, dataComparer) {
epsilon = defaultValue_default(epsilon, 0);
return left === right || defined_default(left) && defined_default(right) && (left.isEmpty && right.isEmpty || left.isStartIncluded === right.isStartIncluded && left.isStopIncluded === right.isStopIncluded && JulianDate_default.equalsEpsilon(left.start, right.start, epsilon) && JulianDate_default.equalsEpsilon(left.stop, right.stop, epsilon) && (left.data === right.data || defined_default(dataComparer) && dataComparer(left.data, right.data)));
};
TimeInterval.intersect = function(left, right, result, mergeCallback) {
Check_default.typeOf.object("left", left);
if (!defined_default(right)) {
return TimeInterval.clone(TimeInterval.EMPTY, result);
}
const leftStart = left.start;
const leftStop = left.stop;
const rightStart = right.start;
const rightStop = right.stop;
const intersectsStartRight = JulianDate_default.greaterThanOrEquals(rightStart, leftStart) && JulianDate_default.greaterThanOrEquals(leftStop, rightStart);
const intersectsStartLeft = !intersectsStartRight && JulianDate_default.lessThanOrEquals(rightStart, leftStart) && JulianDate_default.lessThanOrEquals(leftStart, rightStop);
if (!intersectsStartRight && !intersectsStartLeft) {
return TimeInterval.clone(TimeInterval.EMPTY, result);
}
const leftIsStartIncluded = left.isStartIncluded;
const leftIsStopIncluded = left.isStopIncluded;
const rightIsStartIncluded = right.isStartIncluded;
const rightIsStopIncluded = right.isStopIncluded;
const leftLessThanRight = JulianDate_default.lessThan(leftStop, rightStop);
if (!defined_default(result)) {
result = new TimeInterval();
}
result.start = intersectsStartRight ? rightStart : leftStart;
result.isStartIncluded = leftIsStartIncluded && rightIsStartIncluded || !JulianDate_default.equals(rightStart, leftStart) && (intersectsStartRight && rightIsStartIncluded || intersectsStartLeft && leftIsStartIncluded);
result.stop = leftLessThanRight ? leftStop : rightStop;
result.isStopIncluded = leftLessThanRight ? leftIsStopIncluded : leftIsStopIncluded && rightIsStopIncluded || !JulianDate_default.equals(rightStop, leftStop) && rightIsStopIncluded;
result.data = defined_default(mergeCallback) ? mergeCallback(left.data, right.data) : left.data;
return result;
};
TimeInterval.contains = function(timeInterval, julianDate) {
Check_default.typeOf.object("timeInterval", timeInterval);
Check_default.typeOf.object("julianDate", julianDate);
if (timeInterval.isEmpty) {
return false;
}
const startComparedToDate = JulianDate_default.compare(
timeInterval.start,
julianDate
);
if (startComparedToDate === 0) {
return timeInterval.isStartIncluded;
}
const dateComparedToStop = JulianDate_default.compare(julianDate, timeInterval.stop);
if (dateComparedToStop === 0) {
return timeInterval.isStopIncluded;
}
return startComparedToDate < 0 && dateComparedToStop < 0;
};
TimeInterval.prototype.clone = function(result) {
return TimeInterval.clone(this, result);
};
TimeInterval.prototype.equals = function(right, dataComparer) {
return TimeInterval.equals(this, right, dataComparer);
};
TimeInterval.prototype.equalsEpsilon = function(right, epsilon, dataComparer) {
return TimeInterval.equalsEpsilon(this, right, epsilon, dataComparer);
};
TimeInterval.prototype.toString = function() {
return TimeInterval.toIso8601(this);
};
TimeInterval.EMPTY = Object.freeze(
new TimeInterval({
start: new JulianDate_default(),
stop: new JulianDate_default(),
isStartIncluded: false,
isStopIncluded: false
})
);
var TimeInterval_default = TimeInterval;
// Source/Core/Iso8601.js
var MINIMUM_VALUE = Object.freeze(
JulianDate_default.fromIso8601("0000-01-01T00:00:00Z")
);
var MAXIMUM_VALUE = Object.freeze(
JulianDate_default.fromIso8601("9999-12-31T24:00:00Z")
);
var MAXIMUM_INTERVAL = Object.freeze(
new TimeInterval_default({
start: MINIMUM_VALUE,
stop: MAXIMUM_VALUE
})
);
var Iso8601 = {
MINIMUM_VALUE,
MAXIMUM_VALUE,
MAXIMUM_INTERVAL
};
var Iso8601_default = Iso8601;
// Source/Core/KeyboardEventModifier.js
var KeyboardEventModifier = {
SHIFT: 0,
CTRL: 1,
ALT: 2
};
var KeyboardEventModifier_default = Object.freeze(KeyboardEventModifier);
// Source/Core/KTX2Transcoder.js
function KTX2Transcoder() {
}
KTX2Transcoder._transcodeTaskProcessor = new TaskProcessor_default(
"transcodeKTX2",
Number.POSITIVE_INFINITY
);
KTX2Transcoder._readyPromise = void 0;
function makeReadyPromise() {
const readyPromise = KTX2Transcoder._transcodeTaskProcessor.initWebAssemblyModule({
modulePath: "ThirdParty/Workers/basis_transcoder.js",
wasmBinaryFile: "ThirdParty/basis_transcoder.wasm"
}).then(function() {
return KTX2Transcoder._transcodeTaskProcessor;
});
KTX2Transcoder._readyPromise = readyPromise;
}
KTX2Transcoder.transcode = function(ktx2Buffer, supportedTargetFormats) {
Check_default.defined("supportedTargetFormats", supportedTargetFormats);
if (!defined_default(KTX2Transcoder._readyPromise)) {
makeReadyPromise();
}
return KTX2Transcoder._readyPromise.then(function(taskProcessor3) {
let parameters;
if (ktx2Buffer instanceof ArrayBuffer) {
const view = new Uint8Array(ktx2Buffer);
parameters = {
supportedTargetFormats,
ktx2Buffer: view
};
return taskProcessor3.scheduleTask(parameters, [ktx2Buffer]);
}
parameters = {
supportedTargetFormats,
ktx2Buffer
};
return taskProcessor3.scheduleTask(parameters, [ktx2Buffer.buffer]);
}).then(function(result) {
const levelsLength = result.length;
const faceKeys = Object.keys(result[0]);
const faceKeysLength = faceKeys.length;
let i;
for (i = 0; i < levelsLength; i++) {
const faces2 = result[i];
for (let j = 0; j < faceKeysLength; j++) {
const face = faces2[faceKeys[j]];
faces2[faceKeys[j]] = new CompressedTextureBuffer_default(
face.internalFormat,
face.datatype,
face.width,
face.height,
face.levelBuffer
);
}
}
if (faceKeysLength === 1) {
for (i = 0; i < levelsLength; ++i) {
result[i] = result[i][faceKeys[0]];
}
if (levelsLength === 1) {
result = result[0];
}
}
return result;
}).catch(function(error) {
throw error;
});
};
var KTX2Transcoder_default = KTX2Transcoder;
// Source/Core/LagrangePolynomialApproximation.js
var LagrangePolynomialApproximation = {
type: "Lagrange"
};
LagrangePolynomialApproximation.getRequiredDataPoints = function(degree) {
return Math.max(degree + 1, 2);
};
LagrangePolynomialApproximation.interpolateOrderZero = function(x, xTable, yTable, yStride, result) {
if (!defined_default(result)) {
result = new Array(yStride);
}
let i;
let j;
const length3 = xTable.length;
for (i = 0; i < yStride; i++) {
result[i] = 0;
}
for (i = 0; i < length3; i++) {
let coefficient = 1;
for (j = 0; j < length3; j++) {
if (j !== i) {
const diffX = xTable[i] - xTable[j];
coefficient *= (x - xTable[j]) / diffX;
}
}
for (j = 0; j < yStride; j++) {
result[j] += coefficient * yTable[i * yStride + j];
}
}
return result;
};
var LagrangePolynomialApproximation_default = LagrangePolynomialApproximation;
// Source/Core/LinearApproximation.js
var LinearApproximation = {
type: "Linear"
};
LinearApproximation.getRequiredDataPoints = function(degree) {
return 2;
};
LinearApproximation.interpolateOrderZero = function(x, xTable, yTable, yStride, result) {
if (xTable.length !== 2) {
throw new DeveloperError_default(
"The xTable provided to the linear interpolator must have exactly two elements."
);
} else if (yStride <= 0) {
throw new DeveloperError_default(
"There must be at least 1 dependent variable for each independent variable."
);
}
if (!defined_default(result)) {
result = new Array(yStride);
}
let i;
let y0;
let y1;
const x0 = xTable[0];
const x1 = xTable[1];
if (x0 === x1) {
throw new DeveloperError_default(
"Divide by zero error: xTable[0] and xTable[1] are equal"
);
}
for (i = 0; i < yStride; i++) {
y0 = yTable[i];
y1 = yTable[i + yStride];
result[i] = ((y1 - y0) * x + x1 * y0 - x0 * y1) / (x1 - x0);
}
return result;
};
var LinearApproximation_default = LinearApproximation;
// Source/Core/loadImageFromTypedArray.js
function loadImageFromTypedArray(options) {
const uint8Array = options.uint8Array;
const format = options.format;
const request = options.request;
const flipY = defaultValue_default(options.flipY, false);
const skipColorSpaceConversion = defaultValue_default(
options.skipColorSpaceConversion,
false
);
Check_default.typeOf.object("uint8Array", uint8Array);
Check_default.typeOf.string("format", format);
const blob = new Blob([uint8Array], {
type: format
});
let blobUrl;
return Resource_default.supportsImageBitmapOptions().then(function(result) {
if (result) {
return Promise.resolve(
Resource_default.createImageBitmapFromBlob(blob, {
flipY,
premultiplyAlpha: false,
skipColorSpaceConversion
})
);
}
blobUrl = window.URL.createObjectURL(blob);
const resource = new Resource_default({
url: blobUrl,
request
});
return resource.fetchImage({
flipY,
skipColorSpaceConversion
});
}).then(function(result) {
if (defined_default(blobUrl)) {
window.URL.revokeObjectURL(blobUrl);
}
return result;
}).catch(function(error) {
if (defined_default(blobUrl)) {
window.URL.revokeObjectURL(blobUrl);
}
return Promise.reject(error);
});
}
var loadImageFromTypedArray_default = loadImageFromTypedArray;
// Source/Core/loadKTX2.js
var supportedTranscoderFormats;
loadKTX2.setKTX2SupportedFormats = function(s3tc, pvrtc, astc, etc, etc1, bc7) {
supportedTranscoderFormats = {
s3tc,
pvrtc,
astc,
etc,
etc1,
bc7
};
};
function loadKTX2(resourceOrUrlOrBuffer) {
Check_default.defined("resourceOrUrlOrBuffer", resourceOrUrlOrBuffer);
let loadPromise;
if (resourceOrUrlOrBuffer instanceof ArrayBuffer || ArrayBuffer.isView(resourceOrUrlOrBuffer)) {
loadPromise = Promise.resolve(resourceOrUrlOrBuffer);
} else {
const resource = Resource_default.createIfNeeded(resourceOrUrlOrBuffer);
loadPromise = resource.fetchArrayBuffer();
}
return loadPromise.then(function(data) {
return KTX2Transcoder_default.transcode(data, supportedTranscoderFormats);
});
}
var loadKTX2_default = loadKTX2;
// Source/Core/ManagedArray.js
function ManagedArray(length3) {
length3 = defaultValue_default(length3, 0);
this._array = new Array(length3);
this._length = length3;
}
Object.defineProperties(ManagedArray.prototype, {
length: {
get: function() {
return this._length;
},
set: function(length3) {
Check_default.typeOf.number.greaterThanOrEquals("length", length3, 0);
const array = this._array;
const originalLength = this._length;
if (length3 < originalLength) {
for (let i = length3; i < originalLength; ++i) {
array[i] = void 0;
}
} else if (length3 > array.length) {
array.length = length3;
}
this._length = length3;
}
},
values: {
get: function() {
return this._array;
}
}
});
ManagedArray.prototype.get = function(index) {
Check_default.typeOf.number.lessThan("index", index, this._array.length);
return this._array[index];
};
ManagedArray.prototype.set = function(index, element) {
Check_default.typeOf.number("index", index);
if (index >= this._length) {
this.length = index + 1;
}
this._array[index] = element;
};
ManagedArray.prototype.peek = function() {
return this._array[this._length - 1];
};
ManagedArray.prototype.push = function(element) {
const index = this.length++;
this._array[index] = element;
};
ManagedArray.prototype.pop = function() {
if (this._length === 0) {
return void 0;
}
const element = this._array[this._length - 1];
--this.length;
return element;
};
ManagedArray.prototype.reserve = function(length3) {
Check_default.typeOf.number.greaterThanOrEquals("length", length3, 0);
if (length3 > this._array.length) {
this._array.length = length3;
}
};
ManagedArray.prototype.resize = function(length3) {
Check_default.typeOf.number.greaterThanOrEquals("length", length3, 0);
this.length = length3;
};
ManagedArray.prototype.trim = function(length3) {
length3 = defaultValue_default(length3, this._length);
this._array.length = length3;
};
var ManagedArray_default = ManagedArray;
// Source/Core/MapProjection.js
function MapProjection() {
DeveloperError_default.throwInstantiationError();
}
Object.defineProperties(MapProjection.prototype, {
ellipsoid: {
get: DeveloperError_default.throwInstantiationError
}
});
MapProjection.prototype.project = DeveloperError_default.throwInstantiationError;
MapProjection.prototype.unproject = DeveloperError_default.throwInstantiationError;
var MapProjection_default = MapProjection;
// Source/Core/mergeSort.js
var leftScratchArray = [];
var rightScratchArray = [];
function merge(array, compare, userDefinedObject, start, middle, end) {
const leftLength = middle - start + 1;
const rightLength = end - middle;
const left = leftScratchArray;
const right = rightScratchArray;
let i;
let j;
for (i = 0; i < leftLength; ++i) {
left[i] = array[start + i];
}
for (j = 0; j < rightLength; ++j) {
right[j] = array[middle + j + 1];
}
i = 0;
j = 0;
for (let k = start; k <= end; ++k) {
const leftElement = left[i];
const rightElement = right[j];
if (i < leftLength && (j >= rightLength || compare(leftElement, rightElement, userDefinedObject) <= 0)) {
array[k] = leftElement;
++i;
} else if (j < rightLength) {
array[k] = rightElement;
++j;
}
}
}
function sort(array, compare, userDefinedObject, start, end) {
if (start >= end) {
return;
}
const middle = Math.floor((start + end) * 0.5);
sort(array, compare, userDefinedObject, start, middle);
sort(array, compare, userDefinedObject, middle + 1, end);
merge(array, compare, userDefinedObject, start, middle, end);
}
function mergeSort(array, comparator, userDefinedObject) {
if (!defined_default(array)) {
throw new DeveloperError_default("array is required.");
}
if (!defined_default(comparator)) {
throw new DeveloperError_default("comparator is required.");
}
const length3 = array.length;
const scratchLength = Math.ceil(length3 * 0.5);
leftScratchArray.length = scratchLength;
rightScratchArray.length = scratchLength;
sort(array, comparator, userDefinedObject, 0, length3 - 1);
leftScratchArray.length = 0;
rightScratchArray.length = 0;
}
var mergeSort_default = mergeSort;
// Source/Core/MorphWeightSpline.js
function MorphWeightSpline(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
const weights2 = options.weights;
const times = options.times;
Check_default.defined("weights", weights2);
Check_default.defined("times", times);
Check_default.typeOf.number.greaterThanOrEquals("weights.length", weights2.length, 3);
if (weights2.length % times.length !== 0) {
throw new DeveloperError_default(
"times.length must be a factor of weights.length."
);
}
this._times = times;
this._weights = weights2;
this._count = weights2.length / times.length;
this._lastTimeIndex = 0;
}
Object.defineProperties(MorphWeightSpline.prototype, {
times: {
get: function() {
return this._times;
}
},
weights: {
get: function() {
return this._weights;
}
}
});
MorphWeightSpline.prototype.findTimeInterval = Spline_default.prototype.findTimeInterval;
MorphWeightSpline.prototype.wrapTime = Spline_default.prototype.wrapTime;
MorphWeightSpline.prototype.clampTime = Spline_default.prototype.clampTime;
MorphWeightSpline.prototype.evaluate = function(time, result) {
const weights2 = this.weights;
const times = this.times;
const i = this._lastTimeIndex = this.findTimeInterval(
time,
this._lastTimeIndex
);
const u3 = (time - times[i]) / (times[i + 1] - times[i]);
if (!defined_default(result)) {
result = new Array(this._count);
}
for (let j = 0; j < this._count; j++) {
const index = i * this._count + j;
result[j] = weights2[index] * (1 - u3) + weights2[index + this._count] * u3;
}
return result;
};
var MorphWeightSpline_default = MorphWeightSpline;
// Source/Core/MortonOrder.js
var MortonOrder = {};
function insertOneSpacing(v7) {
v7 = (v7 ^ v7 << 8) & 16711935;
v7 = (v7 ^ v7 << 4) & 252645135;
v7 = (v7 ^ v7 << 2) & 858993459;
v7 = (v7 ^ v7 << 1) & 1431655765;
return v7;
}
function insertTwoSpacing(v7) {
v7 = (v7 ^ v7 << 16) & 50331903;
v7 = (v7 ^ v7 << 8) & 50393103;
v7 = (v7 ^ v7 << 4) & 51130563;
v7 = (v7 ^ v7 << 2) & 153391689;
return v7;
}
function removeOneSpacing(v7) {
v7 &= 1431655765;
v7 = (v7 ^ v7 >> 1) & 858993459;
v7 = (v7 ^ v7 >> 2) & 252645135;
v7 = (v7 ^ v7 >> 4) & 16711935;
v7 = (v7 ^ v7 >> 8) & 65535;
return v7;
}
function removeTwoSpacing(v7) {
v7 &= 153391689;
v7 = (v7 ^ v7 >> 2) & 51130563;
v7 = (v7 ^ v7 >> 4) & 50393103;
v7 = (v7 ^ v7 >> 8) & 4278190335;
v7 = (v7 ^ v7 >> 16) & 1023;
return v7;
}
MortonOrder.encode2D = function(x, y) {
Check_default.typeOf.number("x", x);
Check_default.typeOf.number("y", y);
if (x < 0 || x > 65535 || y < 0 || y > 65535) {
throw new DeveloperError_default("inputs must be 16-bit unsigned integers");
}
return (insertOneSpacing(x) | insertOneSpacing(y) << 1) >>> 0;
};
MortonOrder.decode2D = function(mortonIndex, result) {
Check_default.typeOf.number("mortonIndex", mortonIndex);
if (mortonIndex < 0 || mortonIndex > 4294967295) {
throw new DeveloperError_default("input must be a 32-bit unsigned integer");
}
if (!defined_default(result)) {
result = new Array(2);
}
result[0] = removeOneSpacing(mortonIndex);
result[1] = removeOneSpacing(mortonIndex >> 1);
return result;
};
MortonOrder.encode3D = function(x, y, z) {
Check_default.typeOf.number("x", x);
Check_default.typeOf.number("y", y);
Check_default.typeOf.number("z", z);
if (x < 0 || x > 1023 || y < 0 || y > 1023 || z < 0 || z > 1023) {
throw new DeveloperError_default("inputs must be 10-bit unsigned integers");
}
return insertTwoSpacing(x) | insertTwoSpacing(y) << 1 | insertTwoSpacing(z) << 2;
};
MortonOrder.decode3D = function(mortonIndex, result) {
Check_default.typeOf.number("mortonIndex", mortonIndex);
if (mortonIndex < 0 || mortonIndex > 1073741823) {
throw new DeveloperError_default("input must be a 30-bit unsigned integer");
}
if (!defined_default(result)) {
result = new Array(3);
}
result[0] = removeTwoSpacing(mortonIndex);
result[1] = removeTwoSpacing(mortonIndex >> 1);
result[2] = removeTwoSpacing(mortonIndex >> 2);
return result;
};
var MortonOrder_default = MortonOrder;
// Source/Core/NearFarScalar.js
function NearFarScalar(near, nearValue, far, farValue) {
this.near = defaultValue_default(near, 0);
this.nearValue = defaultValue_default(nearValue, 0);
this.far = defaultValue_default(far, 1);
this.farValue = defaultValue_default(farValue, 0);
}
NearFarScalar.clone = function(nearFarScalar, result) {
if (!defined_default(nearFarScalar)) {
return void 0;
}
if (!defined_default(result)) {
return new NearFarScalar(
nearFarScalar.near,
nearFarScalar.nearValue,
nearFarScalar.far,
nearFarScalar.farValue
);
}
result.near = nearFarScalar.near;
result.nearValue = nearFarScalar.nearValue;
result.far = nearFarScalar.far;
result.farValue = nearFarScalar.farValue;
return result;
};
NearFarScalar.packedLength = 4;
NearFarScalar.pack = function(value, array, startingIndex) {
if (!defined_default(value)) {
throw new DeveloperError_default("value is required");
}
if (!defined_default(array)) {
throw new DeveloperError_default("array is required");
}
startingIndex = defaultValue_default(startingIndex, 0);
array[startingIndex++] = value.near;
array[startingIndex++] = value.nearValue;
array[startingIndex++] = value.far;
array[startingIndex] = value.farValue;
return array;
};
NearFarScalar.unpack = function(array, startingIndex, result) {
if (!defined_default(array)) {
throw new DeveloperError_default("array is required");
}
startingIndex = defaultValue_default(startingIndex, 0);
if (!defined_default(result)) {
result = new NearFarScalar();
}
result.near = array[startingIndex++];
result.nearValue = array[startingIndex++];
result.far = array[startingIndex++];
result.farValue = array[startingIndex];
return result;
};
NearFarScalar.equals = function(left, right) {
return left === right || defined_default(left) && defined_default(right) && left.near === right.near && left.nearValue === right.nearValue && left.far === right.far && left.farValue === right.farValue;
};
NearFarScalar.prototype.clone = function(result) {
return NearFarScalar.clone(this, result);
};
NearFarScalar.prototype.equals = function(right) {
return NearFarScalar.equals(this, right);
};
var NearFarScalar_default = NearFarScalar;
// Source/Core/Visibility.js
var Visibility = {
NONE: -1,
PARTIAL: 0,
FULL: 1
};
var Visibility_default = Object.freeze(Visibility);
// Source/Core/Occluder.js
function Occluder(occluderBoundingSphere, cameraPosition) {
if (!defined_default(occluderBoundingSphere)) {
throw new DeveloperError_default("occluderBoundingSphere is required.");
}
if (!defined_default(cameraPosition)) {
throw new DeveloperError_default("camera position is required.");
}
this._occluderPosition = Cartesian3_default.clone(occluderBoundingSphere.center);
this._occluderRadius = occluderBoundingSphere.radius;
this._horizonDistance = 0;
this._horizonPlaneNormal = void 0;
this._horizonPlanePosition = void 0;
this._cameraPosition = void 0;
this.cameraPosition = cameraPosition;
}
var scratchCartesian38 = new Cartesian3_default();
Object.defineProperties(Occluder.prototype, {
position: {
get: function() {
return this._occluderPosition;
}
},
radius: {
get: function() {
return this._occluderRadius;
}
},
cameraPosition: {
set: function(cameraPosition) {
if (!defined_default(cameraPosition)) {
throw new DeveloperError_default("cameraPosition is required.");
}
cameraPosition = Cartesian3_default.clone(cameraPosition, this._cameraPosition);
const cameraToOccluderVec = Cartesian3_default.subtract(
this._occluderPosition,
cameraPosition,
scratchCartesian38
);
let invCameraToOccluderDistance = Cartesian3_default.magnitudeSquared(
cameraToOccluderVec
);
const occluderRadiusSqrd = this._occluderRadius * this._occluderRadius;
let horizonDistance;
let horizonPlaneNormal;
let horizonPlanePosition;
if (invCameraToOccluderDistance > occluderRadiusSqrd) {
horizonDistance = Math.sqrt(
invCameraToOccluderDistance - occluderRadiusSqrd
);
invCameraToOccluderDistance = 1 / Math.sqrt(invCameraToOccluderDistance);
horizonPlaneNormal = Cartesian3_default.multiplyByScalar(
cameraToOccluderVec,
invCameraToOccluderDistance,
scratchCartesian38
);
const nearPlaneDistance = horizonDistance * horizonDistance * invCameraToOccluderDistance;
horizonPlanePosition = Cartesian3_default.add(
cameraPosition,
Cartesian3_default.multiplyByScalar(
horizonPlaneNormal,
nearPlaneDistance,
scratchCartesian38
),
scratchCartesian38
);
} else {
horizonDistance = Number.MAX_VALUE;
}
this._horizonDistance = horizonDistance;
this._horizonPlaneNormal = horizonPlaneNormal;
this._horizonPlanePosition = horizonPlanePosition;
this._cameraPosition = cameraPosition;
}
}
});
Occluder.fromBoundingSphere = function(occluderBoundingSphere, cameraPosition, result) {
if (!defined_default(occluderBoundingSphere)) {
throw new DeveloperError_default("occluderBoundingSphere is required.");
}
if (!defined_default(cameraPosition)) {
throw new DeveloperError_default("camera position is required.");
}
if (!defined_default(result)) {
return new Occluder(occluderBoundingSphere, cameraPosition);
}
Cartesian3_default.clone(occluderBoundingSphere.center, result._occluderPosition);
result._occluderRadius = occluderBoundingSphere.radius;
result.cameraPosition = cameraPosition;
return result;
};
var tempVecScratch = new Cartesian3_default();
Occluder.prototype.isPointVisible = function(occludee) {
if (this._horizonDistance !== Number.MAX_VALUE) {
let tempVec2 = Cartesian3_default.subtract(
occludee,
this._occluderPosition,
tempVecScratch
);
let temp = this._occluderRadius;
temp = Cartesian3_default.magnitudeSquared(tempVec2) - temp * temp;
if (temp > 0) {
temp = Math.sqrt(temp) + this._horizonDistance;
tempVec2 = Cartesian3_default.subtract(occludee, this._cameraPosition, tempVec2);
return temp * temp > Cartesian3_default.magnitudeSquared(tempVec2);
}
}
return false;
};
var occludeePositionScratch = new Cartesian3_default();
Occluder.prototype.isBoundingSphereVisible = function(occludee) {
const occludeePosition = Cartesian3_default.clone(
occludee.center,
occludeePositionScratch
);
const occludeeRadius = occludee.radius;
if (this._horizonDistance !== Number.MAX_VALUE) {
let tempVec2 = Cartesian3_default.subtract(
occludeePosition,
this._occluderPosition,
tempVecScratch
);
let temp = this._occluderRadius - occludeeRadius;
temp = Cartesian3_default.magnitudeSquared(tempVec2) - temp * temp;
if (occludeeRadius < this._occluderRadius) {
if (temp > 0) {
temp = Math.sqrt(temp) + this._horizonDistance;
tempVec2 = Cartesian3_default.subtract(
occludeePosition,
this._cameraPosition,
tempVec2
);
return temp * temp + occludeeRadius * occludeeRadius > Cartesian3_default.magnitudeSquared(tempVec2);
}
return false;
}
if (temp > 0) {
tempVec2 = Cartesian3_default.subtract(
occludeePosition,
this._cameraPosition,
tempVec2
);
const tempVecMagnitudeSquared = Cartesian3_default.magnitudeSquared(tempVec2);
const occluderRadiusSquared = this._occluderRadius * this._occluderRadius;
const occludeeRadiusSquared = occludeeRadius * occludeeRadius;
if ((this._horizonDistance * this._horizonDistance + occluderRadiusSquared) * occludeeRadiusSquared > tempVecMagnitudeSquared * occluderRadiusSquared) {
return true;
}
temp = Math.sqrt(temp) + this._horizonDistance;
return temp * temp + occludeeRadiusSquared > tempVecMagnitudeSquared;
}
return true;
}
return false;
};
var tempScratch2 = new Cartesian3_default();
Occluder.prototype.computeVisibility = function(occludeeBS) {
if (!defined_default(occludeeBS)) {
throw new DeveloperError_default("occludeeBS is required.");
}
const occludeePosition = Cartesian3_default.clone(occludeeBS.center);
const occludeeRadius = occludeeBS.radius;
if (occludeeRadius > this._occluderRadius) {
return Visibility_default.FULL;
}
if (this._horizonDistance !== Number.MAX_VALUE) {
let tempVec2 = Cartesian3_default.subtract(
occludeePosition,
this._occluderPosition,
tempScratch2
);
let temp = this._occluderRadius - occludeeRadius;
const occluderToOccludeeDistSqrd = Cartesian3_default.magnitudeSquared(tempVec2);
temp = occluderToOccludeeDistSqrd - temp * temp;
if (temp > 0) {
temp = Math.sqrt(temp) + this._horizonDistance;
tempVec2 = Cartesian3_default.subtract(
occludeePosition,
this._cameraPosition,
tempVec2
);
const cameraToOccludeeDistSqrd = Cartesian3_default.magnitudeSquared(tempVec2);
if (temp * temp + occludeeRadius * occludeeRadius < cameraToOccludeeDistSqrd) {
return Visibility_default.NONE;
}
temp = this._occluderRadius + occludeeRadius;
temp = occluderToOccludeeDistSqrd - temp * temp;
if (temp > 0) {
temp = Math.sqrt(temp) + this._horizonDistance;
return cameraToOccludeeDistSqrd < temp * temp + occludeeRadius * occludeeRadius ? Visibility_default.FULL : Visibility_default.PARTIAL;
}
tempVec2 = Cartesian3_default.subtract(
occludeePosition,
this._horizonPlanePosition,
tempVec2
);
return Cartesian3_default.dot(tempVec2, this._horizonPlaneNormal) > -occludeeRadius ? Visibility_default.PARTIAL : Visibility_default.FULL;
}
}
return Visibility_default.NONE;
};
var occludeePointScratch = new Cartesian3_default();
Occluder.computeOccludeePoint = function(occluderBoundingSphere, occludeePosition, positions) {
if (!defined_default(occluderBoundingSphere)) {
throw new DeveloperError_default("occluderBoundingSphere is required.");
}
if (!defined_default(positions)) {
throw new DeveloperError_default("positions is required.");
}
if (positions.length === 0) {
throw new DeveloperError_default("positions must contain at least one element");
}
const occludeePos = Cartesian3_default.clone(occludeePosition);
const occluderPosition = Cartesian3_default.clone(occluderBoundingSphere.center);
const occluderRadius = occluderBoundingSphere.radius;
const numPositions = positions.length;
if (Cartesian3_default.equals(occluderPosition, occludeePosition)) {
throw new DeveloperError_default(
"occludeePosition must be different than occluderBoundingSphere.center"
);
}
const occluderPlaneNormal = Cartesian3_default.normalize(
Cartesian3_default.subtract(occludeePos, occluderPosition, occludeePointScratch),
occludeePointScratch
);
const occluderPlaneD = -Cartesian3_default.dot(occluderPlaneNormal, occluderPosition);
const aRotationVector = Occluder._anyRotationVector(
occluderPosition,
occluderPlaneNormal,
occluderPlaneD
);
let dot2 = Occluder._horizonToPlaneNormalDotProduct(
occluderBoundingSphere,
occluderPlaneNormal,
occluderPlaneD,
aRotationVector,
positions[0]
);
if (!dot2) {
return void 0;
}
let tempDot;
for (let i = 1; i < numPositions; ++i) {
tempDot = Occluder._horizonToPlaneNormalDotProduct(
occluderBoundingSphere,
occluderPlaneNormal,
occluderPlaneD,
aRotationVector,
positions[i]
);
if (!tempDot) {
return void 0;
}
if (tempDot < dot2) {
dot2 = tempDot;
}
}
if (dot2 < 0.0017453283658983088) {
return void 0;
}
const distance2 = occluderRadius / dot2;
return Cartesian3_default.add(
occluderPosition,
Cartesian3_default.multiplyByScalar(
occluderPlaneNormal,
distance2,
occludeePointScratch
),
occludeePointScratch
);
};
var computeOccludeePointFromRectangleScratch = [];
Occluder.computeOccludeePointFromRectangle = function(rectangle, ellipsoid) {
if (!defined_default(rectangle)) {
throw new DeveloperError_default("rectangle is required.");
}
ellipsoid = defaultValue_default(ellipsoid, Ellipsoid_default.WGS84);
const positions = Rectangle_default.subsample(
rectangle,
ellipsoid,
0,
computeOccludeePointFromRectangleScratch
);
const bs = BoundingSphere_default.fromPoints(positions);
const ellipsoidCenter = Cartesian3_default.ZERO;
if (!Cartesian3_default.equals(ellipsoidCenter, bs.center)) {
return Occluder.computeOccludeePoint(
new BoundingSphere_default(ellipsoidCenter, ellipsoid.minimumRadius),
bs.center,
positions
);
}
return void 0;
};
var tempVec0Scratch = new Cartesian3_default();
Occluder._anyRotationVector = function(occluderPosition, occluderPlaneNormal, occluderPlaneD) {
const tempVec0 = Cartesian3_default.abs(occluderPlaneNormal, tempVec0Scratch);
let majorAxis = tempVec0.x > tempVec0.y ? 0 : 1;
if (majorAxis === 0 && tempVec0.z > tempVec0.x || majorAxis === 1 && tempVec0.z > tempVec0.y) {
majorAxis = 2;
}
const tempVec2 = new Cartesian3_default();
let tempVec1;
if (majorAxis === 0) {
tempVec0.x = occluderPosition.x;
tempVec0.y = occluderPosition.y + 1;
tempVec0.z = occluderPosition.z + 1;
tempVec1 = Cartesian3_default.UNIT_X;
} else if (majorAxis === 1) {
tempVec0.x = occluderPosition.x + 1;
tempVec0.y = occluderPosition.y;
tempVec0.z = occluderPosition.z + 1;
tempVec1 = Cartesian3_default.UNIT_Y;
} else {
tempVec0.x = occluderPosition.x + 1;
tempVec0.y = occluderPosition.y + 1;
tempVec0.z = occluderPosition.z;
tempVec1 = Cartesian3_default.UNIT_Z;
}
const u3 = (Cartesian3_default.dot(occluderPlaneNormal, tempVec0) + occluderPlaneD) / -Cartesian3_default.dot(occluderPlaneNormal, tempVec1);
return Cartesian3_default.normalize(
Cartesian3_default.subtract(
Cartesian3_default.add(
tempVec0,
Cartesian3_default.multiplyByScalar(tempVec1, u3, tempVec2),
tempVec0
),
occluderPosition,
tempVec0
),
tempVec0
);
};
var posDirectionScratch = new Cartesian3_default();
Occluder._rotationVector = function(occluderPosition, occluderPlaneNormal, occluderPlaneD, position, anyRotationVector) {
let positionDirection = Cartesian3_default.subtract(
position,
occluderPosition,
posDirectionScratch
);
positionDirection = Cartesian3_default.normalize(
positionDirection,
positionDirection
);
if (Cartesian3_default.dot(occluderPlaneNormal, positionDirection) < 0.9999999847691291) {
const crossProduct = Cartesian3_default.cross(
occluderPlaneNormal,
positionDirection,
positionDirection
);
const length3 = Cartesian3_default.magnitude(crossProduct);
if (length3 > Math_default.EPSILON13) {
return Cartesian3_default.normalize(crossProduct, new Cartesian3_default());
}
}
return anyRotationVector;
};
var posScratch1 = new Cartesian3_default();
var occluerPosScratch = new Cartesian3_default();
var posScratch2 = new Cartesian3_default();
var horizonPlanePosScratch = new Cartesian3_default();
Occluder._horizonToPlaneNormalDotProduct = function(occluderBS, occluderPlaneNormal, occluderPlaneD, anyRotationVector, position) {
const pos = Cartesian3_default.clone(position, posScratch1);
const occluderPosition = Cartesian3_default.clone(
occluderBS.center,
occluerPosScratch
);
const occluderRadius = occluderBS.radius;
let positionToOccluder = Cartesian3_default.subtract(
occluderPosition,
pos,
posScratch2
);
const occluderToPositionDistanceSquared = Cartesian3_default.magnitudeSquared(
positionToOccluder
);
const occluderRadiusSquared = occluderRadius * occluderRadius;
if (occluderToPositionDistanceSquared < occluderRadiusSquared) {
return false;
}
const horizonDistanceSquared = occluderToPositionDistanceSquared - occluderRadiusSquared;
const horizonDistance = Math.sqrt(horizonDistanceSquared);
const occluderToPositionDistance = Math.sqrt(
occluderToPositionDistanceSquared
);
const invOccluderToPositionDistance = 1 / occluderToPositionDistance;
const cosTheta = horizonDistance * invOccluderToPositionDistance;
const horizonPlaneDistance = cosTheta * horizonDistance;
positionToOccluder = Cartesian3_default.normalize(
positionToOccluder,
positionToOccluder
);
const horizonPlanePosition = Cartesian3_default.add(
pos,
Cartesian3_default.multiplyByScalar(
positionToOccluder,
horizonPlaneDistance,
horizonPlanePosScratch
),
horizonPlanePosScratch
);
const horizonCrossDistance = Math.sqrt(
horizonDistanceSquared - horizonPlaneDistance * horizonPlaneDistance
);
let tempVec2 = this._rotationVector(
occluderPosition,
occluderPlaneNormal,
occluderPlaneD,
pos,
anyRotationVector
);
let horizonCrossDirection = Cartesian3_default.fromElements(
tempVec2.x * tempVec2.x * positionToOccluder.x + (tempVec2.x * tempVec2.y - tempVec2.z) * positionToOccluder.y + (tempVec2.x * tempVec2.z + tempVec2.y) * positionToOccluder.z,
(tempVec2.x * tempVec2.y + tempVec2.z) * positionToOccluder.x + tempVec2.y * tempVec2.y * positionToOccluder.y + (tempVec2.y * tempVec2.z - tempVec2.x) * positionToOccluder.z,
(tempVec2.x * tempVec2.z - tempVec2.y) * positionToOccluder.x + (tempVec2.y * tempVec2.z + tempVec2.x) * positionToOccluder.y + tempVec2.z * tempVec2.z * positionToOccluder.z,
posScratch1
);
horizonCrossDirection = Cartesian3_default.normalize(
horizonCrossDirection,
horizonCrossDirection
);
const offset2 = Cartesian3_default.multiplyByScalar(
horizonCrossDirection,
horizonCrossDistance,
posScratch1
);
tempVec2 = Cartesian3_default.normalize(
Cartesian3_default.subtract(
Cartesian3_default.add(horizonPlanePosition, offset2, posScratch2),
occluderPosition,
posScratch2
),
posScratch2
);
const dot0 = Cartesian3_default.dot(occluderPlaneNormal, tempVec2);
tempVec2 = Cartesian3_default.normalize(
Cartesian3_default.subtract(
Cartesian3_default.subtract(horizonPlanePosition, offset2, tempVec2),
occluderPosition,
tempVec2
),
tempVec2
);
const dot1 = Cartesian3_default.dot(occluderPlaneNormal, tempVec2);
return dot0 < dot1 ? dot0 : dot1;
};
var Occluder_default = Occluder;
// Source/Core/OffsetGeometryInstanceAttribute.js
function OffsetGeometryInstanceAttribute(x, y, z) {
x = defaultValue_default(x, 0);
y = defaultValue_default(y, 0);
z = defaultValue_default(z, 0);
this.value = new Float32Array([x, y, z]);
}
Object.defineProperties(OffsetGeometryInstanceAttribute.prototype, {
componentDatatype: {
get: function() {
return ComponentDatatype_default.FLOAT;
}
},
componentsPerAttribute: {
get: function() {
return 3;
}
},
normalize: {
get: function() {
return false;
}
}
});
OffsetGeometryInstanceAttribute.fromCartesian3 = function(offset2) {
Check_default.defined("offset", offset2);
return new OffsetGeometryInstanceAttribute(offset2.x, offset2.y, offset2.z);
};
OffsetGeometryInstanceAttribute.toValue = function(offset2, result) {
Check_default.defined("offset", offset2);
if (!defined_default(result)) {
result = new Float32Array([offset2.x, offset2.y, offset2.z]);
}
result[0] = offset2.x;
result[1] = offset2.y;
result[2] = offset2.z;
return result;
};
var OffsetGeometryInstanceAttribute_default = OffsetGeometryInstanceAttribute;
// Source/Core/OpenCageGeocoderService.js
function OpenCageGeocoderService(url2, apiKey, params) {
Check_default.defined("url", url2);
Check_default.defined("apiKey", apiKey);
if (defined_default(params)) {
Check_default.typeOf.object("params", params);
}
url2 = Resource_default.createIfNeeded(url2);
url2.appendForwardSlash();
url2.setQueryParameters({ key: apiKey });
this._url = url2;
this._params = defaultValue_default(params, {});
}
Object.defineProperties(OpenCageGeocoderService.prototype, {
url: {
get: function() {
return this._url;
}
},
params: {
get: function() {
return this._params;
}
}
});
OpenCageGeocoderService.prototype.geocode = function(query) {
Check_default.typeOf.string("query", query);
const resource = this._url.getDerivedResource({
url: "json",
queryParameters: combine_default(this._params, { q: query })
});
return resource.fetchJson().then(function(response) {
return response.results.map(function(resultObject) {
let destination;
const bounds = resultObject.bounds;
if (defined_default(bounds)) {
destination = Rectangle_default.fromDegrees(
bounds.southwest.lng,
bounds.southwest.lat,
bounds.northeast.lng,
bounds.northeast.lat
);
} else {
const lon = resultObject.geometry.lat;
const lat = resultObject.geometry.lng;
destination = Cartesian3_default.fromDegrees(lon, lat);
}
return {
displayName: resultObject.formatted,
destination
};
});
});
};
var OpenCageGeocoderService_default = OpenCageGeocoderService;
// Source/Core/Packable.js
var Packable = {
packedLength: void 0,
pack: DeveloperError_default.throwInstantiationError,
unpack: DeveloperError_default.throwInstantiationError
};
var Packable_default = Packable;
// Source/Core/PackableForInterpolation.js
var PackableForInterpolation = {
packedInterpolationLength: void 0,
convertPackedArrayForInterpolation: DeveloperError_default.throwInstantiationError,
unpackInterpolationResult: DeveloperError_default.throwInstantiationError
};
var PackableForInterpolation_default = PackableForInterpolation;
// Source/Core/writeTextToCanvas.js
function measureText(context2D, textString, font, stroke, fill) {
const metrics = context2D.measureText(textString);
const isSpace = !/\S/.test(textString);
if (!isSpace) {
const fontSize = document.defaultView.getComputedStyle(context2D.canvas).getPropertyValue("font-size").replace("px", "");
const canvas = document.createElement("canvas");
const padding = 100;
const width = metrics.width + padding | 0;
const height = 3 * fontSize;
const baseline = height / 2;
canvas.width = width;
canvas.height = height;
const ctx = canvas.getContext("2d");
ctx.font = font;
ctx.fillStyle = "white";
ctx.fillRect(0, 0, canvas.width + 1, canvas.height + 1);
if (stroke) {
ctx.strokeStyle = "black";
ctx.lineWidth = context2D.lineWidth;
ctx.strokeText(textString, padding / 2, baseline);
}
if (fill) {
ctx.fillStyle = "black";
ctx.fillText(textString, padding / 2, baseline);
}
const pixelData = ctx.getImageData(0, 0, width, height).data;
const length3 = pixelData.length;
const width4 = width * 4;
let i, j;
let ascent, descent;
for (i = 0; i < length3; ++i) {
if (pixelData[i] !== 255) {
ascent = i / width4 | 0;
break;
}
}
for (i = length3 - 1; i >= 0; --i) {
if (pixelData[i] !== 255) {
descent = i / width4 | 0;
break;
}
}
let minx = -1;
for (i = 0; i < width && minx === -1; ++i) {
for (j = 0; j < height; ++j) {
const pixelIndex = i * 4 + j * width4;
if (pixelData[pixelIndex] !== 255 || pixelData[pixelIndex + 1] !== 255 || pixelData[pixelIndex + 2] !== 255 || pixelData[pixelIndex + 3] !== 255) {
minx = i;
break;
}
}
}
return {
width: metrics.width,
height: descent - ascent,
ascent: baseline - ascent,
descent: descent - baseline,
minx: minx - padding / 2
};
}
return {
width: metrics.width,
height: 0,
ascent: 0,
descent: 0,
minx: 0
};
}
var imageSmoothingEnabledName;
function writeTextToCanvas(text, options) {
if (!defined_default(text)) {
throw new DeveloperError_default("text is required.");
}
if (text === "") {
return void 0;
}
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
const font = defaultValue_default(options.font, "10px sans-serif");
const stroke = defaultValue_default(options.stroke, false);
const fill = defaultValue_default(options.fill, true);
const strokeWidth = defaultValue_default(options.strokeWidth, 1);
const backgroundColor = defaultValue_default(
options.backgroundColor,
Color_default.TRANSPARENT
);
const padding = defaultValue_default(options.padding, 0);
const doublePadding = padding * 2;
const canvas = document.createElement("canvas");
canvas.width = 1;
canvas.height = 1;
canvas.style.font = font;
const context2D = canvas.getContext("2d");
if (!defined_default(imageSmoothingEnabledName)) {
if (defined_default(context2D.imageSmoothingEnabled)) {
imageSmoothingEnabledName = "imageSmoothingEnabled";
} else if (defined_default(context2D.mozImageSmoothingEnabled)) {
imageSmoothingEnabledName = "mozImageSmoothingEnabled";
} else if (defined_default(context2D.webkitImageSmoothingEnabled)) {
imageSmoothingEnabledName = "webkitImageSmoothingEnabled";
} else if (defined_default(context2D.msImageSmoothingEnabled)) {
imageSmoothingEnabledName = "msImageSmoothingEnabled";
}
}
context2D.font = font;
context2D.lineJoin = "round";
context2D.lineWidth = strokeWidth;
context2D[imageSmoothingEnabledName] = false;
canvas.style.visibility = "hidden";
document.body.appendChild(canvas);
const dimensions = measureText(context2D, text, font, stroke, fill);
canvas.dimensions = dimensions;
document.body.removeChild(canvas);
canvas.style.visibility = "";
const x = -dimensions.minx;
const width = Math.ceil(dimensions.width) + x + doublePadding;
const height = dimensions.height + doublePadding;
const baseline = height - dimensions.ascent + padding;
const y = height - baseline + doublePadding;
canvas.width = width;
canvas.height = height;
context2D.font = font;
context2D.lineJoin = "round";
context2D.lineWidth = strokeWidth;
context2D[imageSmoothingEnabledName] = false;
if (backgroundColor !== Color_default.TRANSPARENT) {
context2D.fillStyle = backgroundColor.toCssColorString();
context2D.fillRect(0, 0, canvas.width, canvas.height);
}
if (stroke) {
const strokeColor = defaultValue_default(options.strokeColor, Color_default.BLACK);
context2D.strokeStyle = strokeColor.toCssColorString();
context2D.strokeText(text, x + padding, y);
}
if (fill) {
const fillColor = defaultValue_default(options.fillColor, Color_default.WHITE);
context2D.fillStyle = fillColor.toCssColorString();
context2D.fillText(text, x + padding, y);
}
return canvas;
}
var writeTextToCanvas_default = writeTextToCanvas;
// Source/Core/PinBuilder.js
function PinBuilder() {
this._cache = {};
}
PinBuilder.prototype.fromColor = function(color, size) {
if (!defined_default(color)) {
throw new DeveloperError_default("color is required");
}
if (!defined_default(size)) {
throw new DeveloperError_default("size is required");
}
return createPin(void 0, void 0, color, size, this._cache);
};
PinBuilder.prototype.fromUrl = function(url2, color, size) {
if (!defined_default(url2)) {
throw new DeveloperError_default("url is required");
}
if (!defined_default(color)) {
throw new DeveloperError_default("color is required");
}
if (!defined_default(size)) {
throw new DeveloperError_default("size is required");
}
return createPin(url2, void 0, color, size, this._cache);
};
PinBuilder.prototype.fromMakiIconId = function(id, color, size) {
if (!defined_default(id)) {
throw new DeveloperError_default("id is required");
}
if (!defined_default(color)) {
throw new DeveloperError_default("color is required");
}
if (!defined_default(size)) {
throw new DeveloperError_default("size is required");
}
return createPin(
buildModuleUrl_default(`Assets/Textures/maki/${encodeURIComponent(id)}.png`),
void 0,
color,
size,
this._cache
);
};
PinBuilder.prototype.fromText = function(text, color, size) {
if (!defined_default(text)) {
throw new DeveloperError_default("text is required");
}
if (!defined_default(color)) {
throw new DeveloperError_default("color is required");
}
if (!defined_default(size)) {
throw new DeveloperError_default("size is required");
}
return createPin(void 0, text, color, size, this._cache);
};
var colorScratch = new Color_default();
function drawPin(context2D, color, size) {
context2D.save();
context2D.scale(size / 24, size / 24);
context2D.fillStyle = color.toCssColorString();
context2D.strokeStyle = color.brighten(0.6, colorScratch).toCssColorString();
context2D.lineWidth = 0.846;
context2D.beginPath();
context2D.moveTo(6.72, 0.422);
context2D.lineTo(17.28, 0.422);
context2D.bezierCurveTo(18.553, 0.422, 19.577, 1.758, 19.577, 3.415);
context2D.lineTo(19.577, 10.973);
context2D.bezierCurveTo(19.577, 12.63, 18.553, 13.966, 17.282, 13.966);
context2D.lineTo(14.386, 14.008);
context2D.lineTo(11.826, 23.578);
context2D.lineTo(9.614, 14.008);
context2D.lineTo(6.719, 13.965);
context2D.bezierCurveTo(5.446, 13.983, 4.422, 12.629, 4.422, 10.972);
context2D.lineTo(4.422, 3.416);
context2D.bezierCurveTo(4.423, 1.76, 5.447, 0.423, 6.718, 0.423);
context2D.closePath();
context2D.fill();
context2D.stroke();
context2D.restore();
}
function drawIcon(context2D, image, size) {
const imageSize = size / 2.5;
let sizeX = imageSize;
let sizeY = imageSize;
if (image.width > image.height) {
sizeY = imageSize * (image.height / image.width);
} else if (image.width < image.height) {
sizeX = imageSize * (image.width / image.height);
}
const x = Math.round((size - sizeX) / 2);
const y = Math.round(7 / 24 * size - sizeY / 2);
context2D.globalCompositeOperation = "destination-out";
context2D.drawImage(image, x - 1, y, sizeX, sizeY);
context2D.drawImage(image, x, y - 1, sizeX, sizeY);
context2D.drawImage(image, x + 1, y, sizeX, sizeY);
context2D.drawImage(image, x, y + 1, sizeX, sizeY);
context2D.globalCompositeOperation = "destination-over";
context2D.fillStyle = Color_default.BLACK.toCssColorString();
context2D.fillRect(x - 1, y - 1, sizeX + 2, sizeY + 2);
context2D.globalCompositeOperation = "destination-out";
context2D.drawImage(image, x, y, sizeX, sizeY);
context2D.globalCompositeOperation = "destination-over";
context2D.fillStyle = Color_default.WHITE.toCssColorString();
context2D.fillRect(x - 1, y - 2, sizeX + 2, sizeY + 2);
}
var stringifyScratch = new Array(4);
function createPin(url2, label, color, size, cache) {
stringifyScratch[0] = url2;
stringifyScratch[1] = label;
stringifyScratch[2] = color;
stringifyScratch[3] = size;
const id = JSON.stringify(stringifyScratch);
const item = cache[id];
if (defined_default(item)) {
return item;
}
const canvas = document.createElement("canvas");
canvas.width = size;
canvas.height = size;
const context2D = canvas.getContext("2d");
drawPin(context2D, color, size);
if (defined_default(url2)) {
const resource = Resource_default.createIfNeeded(url2);
const promise = resource.fetchImage().then(function(image) {
drawIcon(context2D, image, size);
cache[id] = canvas;
return canvas;
});
cache[id] = promise;
return promise;
} else if (defined_default(label)) {
const image = writeTextToCanvas_default(label, {
font: `bold ${size}px sans-serif`
});
drawIcon(context2D, image, size);
}
cache[id] = canvas;
return canvas;
}
var PinBuilder_default = PinBuilder;
// Source/Renderer/PixelDatatype.js
var PixelDatatype = {
UNSIGNED_BYTE: WebGLConstants_default.UNSIGNED_BYTE,
UNSIGNED_SHORT: WebGLConstants_default.UNSIGNED_SHORT,
UNSIGNED_INT: WebGLConstants_default.UNSIGNED_INT,
FLOAT: WebGLConstants_default.FLOAT,
HALF_FLOAT: WebGLConstants_default.HALF_FLOAT_OES,
UNSIGNED_INT_24_8: WebGLConstants_default.UNSIGNED_INT_24_8,
UNSIGNED_SHORT_4_4_4_4: WebGLConstants_default.UNSIGNED_SHORT_4_4_4_4,
UNSIGNED_SHORT_5_5_5_1: WebGLConstants_default.UNSIGNED_SHORT_5_5_5_1,
UNSIGNED_SHORT_5_6_5: WebGLConstants_default.UNSIGNED_SHORT_5_6_5
};
PixelDatatype.toWebGLConstant = function(pixelDatatype, context) {
switch (pixelDatatype) {
case PixelDatatype.UNSIGNED_BYTE:
return WebGLConstants_default.UNSIGNED_BYTE;
case PixelDatatype.UNSIGNED_SHORT:
return WebGLConstants_default.UNSIGNED_SHORT;
case PixelDatatype.UNSIGNED_INT:
return WebGLConstants_default.UNSIGNED_INT;
case PixelDatatype.FLOAT:
return WebGLConstants_default.FLOAT;
case PixelDatatype.HALF_FLOAT:
return context.webgl2 ? WebGLConstants_default.HALF_FLOAT : WebGLConstants_default.HALF_FLOAT_OES;
case PixelDatatype.UNSIGNED_INT_24_8:
return WebGLConstants_default.UNSIGNED_INT_24_8;
case PixelDatatype.UNSIGNED_SHORT_4_4_4_4:
return WebGLConstants_default.UNSIGNED_SHORT_4_4_4_4;
case PixelDatatype.UNSIGNED_SHORT_5_5_5_1:
return WebGLConstants_default.UNSIGNED_SHORT_5_5_5_1;
case PixelDatatype.UNSIGNED_SHORT_5_6_5:
return PixelDatatype.UNSIGNED_SHORT_5_6_5;
}
};
PixelDatatype.isPacked = function(pixelDatatype) {
return pixelDatatype === PixelDatatype.UNSIGNED_INT_24_8 || pixelDatatype === PixelDatatype.UNSIGNED_SHORT_4_4_4_4 || pixelDatatype === PixelDatatype.UNSIGNED_SHORT_5_5_5_1 || pixelDatatype === PixelDatatype.UNSIGNED_SHORT_5_6_5;
};
PixelDatatype.sizeInBytes = function(pixelDatatype) {
switch (pixelDatatype) {
case PixelDatatype.UNSIGNED_BYTE:
return 1;
case PixelDatatype.UNSIGNED_SHORT:
case PixelDatatype.UNSIGNED_SHORT_4_4_4_4:
case PixelDatatype.UNSIGNED_SHORT_5_5_5_1:
case PixelDatatype.UNSIGNED_SHORT_5_6_5:
case PixelDatatype.HALF_FLOAT:
return 2;
case PixelDatatype.UNSIGNED_INT:
case PixelDatatype.FLOAT:
case PixelDatatype.UNSIGNED_INT_24_8:
return 4;
}
};
PixelDatatype.validate = function(pixelDatatype) {
return pixelDatatype === PixelDatatype.UNSIGNED_BYTE || pixelDatatype === PixelDatatype.UNSIGNED_SHORT || pixelDatatype === PixelDatatype.UNSIGNED_INT || pixelDatatype === PixelDatatype.FLOAT || pixelDatatype === PixelDatatype.HALF_FLOAT || pixelDatatype === PixelDatatype.UNSIGNED_INT_24_8 || pixelDatatype === PixelDatatype.UNSIGNED_SHORT_4_4_4_4 || pixelDatatype === PixelDatatype.UNSIGNED_SHORT_5_5_5_1 || pixelDatatype === PixelDatatype.UNSIGNED_SHORT_5_6_5;
};
var PixelDatatype_default = Object.freeze(PixelDatatype);
// Source/Core/PixelFormat.js
var PixelFormat = {
DEPTH_COMPONENT: WebGLConstants_default.DEPTH_COMPONENT,
DEPTH_STENCIL: WebGLConstants_default.DEPTH_STENCIL,
ALPHA: WebGLConstants_default.ALPHA,
RGB: WebGLConstants_default.RGB,
RGBA: WebGLConstants_default.RGBA,
LUMINANCE: WebGLConstants_default.LUMINANCE,
LUMINANCE_ALPHA: WebGLConstants_default.LUMINANCE_ALPHA,
RGB_DXT1: WebGLConstants_default.COMPRESSED_RGB_S3TC_DXT1_EXT,
RGBA_DXT1: WebGLConstants_default.COMPRESSED_RGBA_S3TC_DXT1_EXT,
RGBA_DXT3: WebGLConstants_default.COMPRESSED_RGBA_S3TC_DXT3_EXT,
RGBA_DXT5: WebGLConstants_default.COMPRESSED_RGBA_S3TC_DXT5_EXT,
RGB_PVRTC_4BPPV1: WebGLConstants_default.COMPRESSED_RGB_PVRTC_4BPPV1_IMG,
RGB_PVRTC_2BPPV1: WebGLConstants_default.COMPRESSED_RGB_PVRTC_2BPPV1_IMG,
RGBA_PVRTC_4BPPV1: WebGLConstants_default.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG,
RGBA_PVRTC_2BPPV1: WebGLConstants_default.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG,
RGBA_ASTC: WebGLConstants_default.COMPRESSED_RGBA_ASTC_4x4_WEBGL,
RGB_ETC1: WebGLConstants_default.COMPRESSED_RGB_ETC1_WEBGL,
RGB8_ETC2: WebGLConstants_default.COMPRESSED_RGB8_ETC2,
RGBA8_ETC2_EAC: WebGLConstants_default.COMPRESSED_RGBA8_ETC2_EAC,
RGBA_BC7: WebGLConstants_default.COMPRESSED_RGBA_BPTC_UNORM
};
PixelFormat.componentsLength = function(pixelFormat) {
switch (pixelFormat) {
case PixelFormat.RGB:
return 3;
case PixelFormat.RGBA:
return 4;
case PixelFormat.LUMINANCE_ALPHA:
return 2;
case PixelFormat.ALPHA:
case PixelFormat.LUMINANCE:
return 1;
default:
return 1;
}
};
PixelFormat.validate = function(pixelFormat) {
return pixelFormat === PixelFormat.DEPTH_COMPONENT || pixelFormat === PixelFormat.DEPTH_STENCIL || pixelFormat === PixelFormat.ALPHA || pixelFormat === PixelFormat.RGB || pixelFormat === PixelFormat.RGBA || pixelFormat === PixelFormat.LUMINANCE || pixelFormat === PixelFormat.LUMINANCE_ALPHA || pixelFormat === PixelFormat.RGB_DXT1 || pixelFormat === PixelFormat.RGBA_DXT1 || pixelFormat === PixelFormat.RGBA_DXT3 || pixelFormat === PixelFormat.RGBA_DXT5 || pixelFormat === PixelFormat.RGB_PVRTC_4BPPV1 || pixelFormat === PixelFormat.RGB_PVRTC_2BPPV1 || pixelFormat === PixelFormat.RGBA_PVRTC_4BPPV1 || pixelFormat === PixelFormat.RGBA_PVRTC_2BPPV1 || pixelFormat === PixelFormat.RGBA_ASTC || pixelFormat === PixelFormat.RGB_ETC1 || pixelFormat === PixelFormat.RGB8_ETC2 || pixelFormat === PixelFormat.RGBA8_ETC2_EAC || pixelFormat === PixelFormat.RGBA_BC7;
};
PixelFormat.isColorFormat = function(pixelFormat) {
return pixelFormat === PixelFormat.ALPHA || pixelFormat === PixelFormat.RGB || pixelFormat === PixelFormat.RGBA || pixelFormat === PixelFormat.LUMINANCE || pixelFormat === PixelFormat.LUMINANCE_ALPHA;
};
PixelFormat.isDepthFormat = function(pixelFormat) {
return pixelFormat === PixelFormat.DEPTH_COMPONENT || pixelFormat === PixelFormat.DEPTH_STENCIL;
};
PixelFormat.isCompressedFormat = function(pixelFormat) {
return pixelFormat === PixelFormat.RGB_DXT1 || pixelFormat === PixelFormat.RGBA_DXT1 || pixelFormat === PixelFormat.RGBA_DXT3 || pixelFormat === PixelFormat.RGBA_DXT5 || pixelFormat === PixelFormat.RGB_PVRTC_4BPPV1 || pixelFormat === PixelFormat.RGB_PVRTC_2BPPV1 || pixelFormat === PixelFormat.RGBA_PVRTC_4BPPV1 || pixelFormat === PixelFormat.RGBA_PVRTC_2BPPV1 || pixelFormat === PixelFormat.RGBA_ASTC || pixelFormat === PixelFormat.RGB_ETC1 || pixelFormat === PixelFormat.RGB8_ETC2 || pixelFormat === PixelFormat.RGBA8_ETC2_EAC || pixelFormat === PixelFormat.RGBA_BC7;
};
PixelFormat.isDXTFormat = function(pixelFormat) {
return pixelFormat === PixelFormat.RGB_DXT1 || pixelFormat === PixelFormat.RGBA_DXT1 || pixelFormat === PixelFormat.RGBA_DXT3 || pixelFormat === PixelFormat.RGBA_DXT5;
};
PixelFormat.isPVRTCFormat = function(pixelFormat) {
return pixelFormat === PixelFormat.RGB_PVRTC_4BPPV1 || pixelFormat === PixelFormat.RGB_PVRTC_2BPPV1 || pixelFormat === PixelFormat.RGBA_PVRTC_4BPPV1 || pixelFormat === PixelFormat.RGBA_PVRTC_2BPPV1;
};
PixelFormat.isASTCFormat = function(pixelFormat) {
return pixelFormat === PixelFormat.RGBA_ASTC;
};
PixelFormat.isETC1Format = function(pixelFormat) {
return pixelFormat === PixelFormat.RGB_ETC1;
};
PixelFormat.isETC2Format = function(pixelFormat) {
return pixelFormat === PixelFormat.RGB8_ETC2 || pixelFormat === PixelFormat.RGBA8_ETC2_EAC;
};
PixelFormat.isBC7Format = function(pixelFormat) {
return pixelFormat === PixelFormat.RGBA_BC7;
};
PixelFormat.compressedTextureSizeInBytes = function(pixelFormat, width, height) {
switch (pixelFormat) {
case PixelFormat.RGB_DXT1:
case PixelFormat.RGBA_DXT1:
case PixelFormat.RGB_ETC1:
case PixelFormat.RGB8_ETC2:
return Math.floor((width + 3) / 4) * Math.floor((height + 3) / 4) * 8;
case PixelFormat.RGBA_DXT3:
case PixelFormat.RGBA_DXT5:
case PixelFormat.RGBA_ASTC:
case PixelFormat.RGBA8_ETC2_EAC:
return Math.floor((width + 3) / 4) * Math.floor((height + 3) / 4) * 16;
case PixelFormat.RGB_PVRTC_4BPPV1:
case PixelFormat.RGBA_PVRTC_4BPPV1:
return Math.floor((Math.max(width, 8) * Math.max(height, 8) * 4 + 7) / 8);
case PixelFormat.RGB_PVRTC_2BPPV1:
case PixelFormat.RGBA_PVRTC_2BPPV1:
return Math.floor(
(Math.max(width, 16) * Math.max(height, 8) * 2 + 7) / 8
);
case PixelFormat.RGBA_BC7:
return Math.ceil(width / 4) * Math.ceil(height / 4) * 16;
default:
return 0;
}
};
PixelFormat.textureSizeInBytes = function(pixelFormat, pixelDatatype, width, height) {
let componentsLength = PixelFormat.componentsLength(pixelFormat);
if (PixelDatatype_default.isPacked(pixelDatatype)) {
componentsLength = 1;
}
return componentsLength * PixelDatatype_default.sizeInBytes(pixelDatatype) * width * height;
};
PixelFormat.alignmentInBytes = function(pixelFormat, pixelDatatype, width) {
const mod2 = PixelFormat.textureSizeInBytes(pixelFormat, pixelDatatype, width, 1) % 4;
return mod2 === 0 ? 4 : mod2 === 2 ? 2 : 1;
};
PixelFormat.createTypedArray = function(pixelFormat, pixelDatatype, width, height) {
let constructor;
const sizeInBytes = PixelDatatype_default.sizeInBytes(pixelDatatype);
if (sizeInBytes === Uint8Array.BYTES_PER_ELEMENT) {
constructor = Uint8Array;
} else if (sizeInBytes === Uint16Array.BYTES_PER_ELEMENT) {
constructor = Uint16Array;
} else if (sizeInBytes === Float32Array.BYTES_PER_ELEMENT && pixelDatatype === PixelDatatype_default.FLOAT) {
constructor = Float32Array;
} else {
constructor = Uint32Array;
}
const size = PixelFormat.componentsLength(pixelFormat) * width * height;
return new constructor(size);
};
PixelFormat.flipY = function(bufferView, pixelFormat, pixelDatatype, width, height) {
if (height === 1) {
return bufferView;
}
const flipped = PixelFormat.createTypedArray(
pixelFormat,
pixelDatatype,
width,
height
);
const numberOfComponents = PixelFormat.componentsLength(pixelFormat);
const textureWidth = width * numberOfComponents;
for (let i = 0; i < height; ++i) {
const row = i * width * numberOfComponents;
const flippedRow = (height - i - 1) * width * numberOfComponents;
for (let j = 0; j < textureWidth; ++j) {
flipped[flippedRow + j] = bufferView[row + j];
}
}
return flipped;
};
PixelFormat.toInternalFormat = function(pixelFormat, pixelDatatype, context) {
if (!context.webgl2) {
return pixelFormat;
}
if (pixelFormat === PixelFormat.DEPTH_STENCIL) {
return WebGLConstants_default.DEPTH24_STENCIL8;
}
if (pixelFormat === PixelFormat.DEPTH_COMPONENT) {
if (pixelDatatype === PixelDatatype_default.UNSIGNED_SHORT) {
return WebGLConstants_default.DEPTH_COMPONENT16;
} else if (pixelDatatype === PixelDatatype_default.UNSIGNED_INT) {
return WebGLConstants_default.DEPTH_COMPONENT24;
}
}
if (pixelDatatype === PixelDatatype_default.FLOAT) {
switch (pixelFormat) {
case PixelFormat.RGBA:
return WebGLConstants_default.RGBA32F;
case PixelFormat.RGB:
return WebGLConstants_default.RGB32F;
case PixelFormat.RG:
return WebGLConstants_default.RG32F;
case PixelFormat.R:
return WebGLConstants_default.R32F;
}
}
if (pixelDatatype === PixelDatatype_default.HALF_FLOAT) {
switch (pixelFormat) {
case PixelFormat.RGBA:
return WebGLConstants_default.RGBA16F;
case PixelFormat.RGB:
return WebGLConstants_default.RGB16F;
case PixelFormat.RG:
return WebGLConstants_default.RG16F;
case PixelFormat.R:
return WebGLConstants_default.R16F;
}
}
return pixelFormat;
};
var PixelFormat_default = Object.freeze(PixelFormat);
// Source/Core/PlaneGeometry.js
function PlaneGeometry(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
const vertexFormat = defaultValue_default(options.vertexFormat, VertexFormat_default.DEFAULT);
this._vertexFormat = vertexFormat;
this._workerName = "createPlaneGeometry";
}
PlaneGeometry.packedLength = VertexFormat_default.packedLength;
PlaneGeometry.pack = function(value, array, startingIndex) {
Check_default.typeOf.object("value", value);
Check_default.defined("array", array);
startingIndex = defaultValue_default(startingIndex, 0);
VertexFormat_default.pack(value._vertexFormat, array, startingIndex);
return array;
};
var scratchVertexFormat8 = new VertexFormat_default();
var scratchOptions15 = {
vertexFormat: scratchVertexFormat8
};
PlaneGeometry.unpack = function(array, startingIndex, result) {
Check_default.defined("array", array);
startingIndex = defaultValue_default(startingIndex, 0);
const vertexFormat = VertexFormat_default.unpack(
array,
startingIndex,
scratchVertexFormat8
);
if (!defined_default(result)) {
return new PlaneGeometry(scratchOptions15);
}
result._vertexFormat = VertexFormat_default.clone(vertexFormat, result._vertexFormat);
return result;
};
var min = new Cartesian3_default(-0.5, -0.5, 0);
var max = new Cartesian3_default(0.5, 0.5, 0);
PlaneGeometry.createGeometry = function(planeGeometry) {
const vertexFormat = planeGeometry._vertexFormat;
const attributes = new GeometryAttributes_default();
let indices2;
let positions;
if (vertexFormat.position) {
positions = new Float64Array(4 * 3);
positions[0] = min.x;
positions[1] = min.y;
positions[2] = 0;
positions[3] = max.x;
positions[4] = min.y;
positions[5] = 0;
positions[6] = max.x;
positions[7] = max.y;
positions[8] = 0;
positions[9] = min.x;
positions[10] = max.y;
positions[11] = 0;
attributes.position = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.DOUBLE,
componentsPerAttribute: 3,
values: positions
});
if (vertexFormat.normal) {
const normals = new Float32Array(4 * 3);
normals[0] = 0;
normals[1] = 0;
normals[2] = 1;
normals[3] = 0;
normals[4] = 0;
normals[5] = 1;
normals[6] = 0;
normals[7] = 0;
normals[8] = 1;
normals[9] = 0;
normals[10] = 0;
normals[11] = 1;
attributes.normal = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.FLOAT,
componentsPerAttribute: 3,
values: normals
});
}
if (vertexFormat.st) {
const texCoords = new Float32Array(4 * 2);
texCoords[0] = 0;
texCoords[1] = 0;
texCoords[2] = 1;
texCoords[3] = 0;
texCoords[4] = 1;
texCoords[5] = 1;
texCoords[6] = 0;
texCoords[7] = 1;
attributes.st = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.FLOAT,
componentsPerAttribute: 2,
values: texCoords
});
}
if (vertexFormat.tangent) {
const tangents = new Float32Array(4 * 3);
tangents[0] = 1;
tangents[1] = 0;
tangents[2] = 0;
tangents[3] = 1;
tangents[4] = 0;
tangents[5] = 0;
tangents[6] = 1;
tangents[7] = 0;
tangents[8] = 0;
tangents[9] = 1;
tangents[10] = 0;
tangents[11] = 0;
attributes.tangent = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.FLOAT,
componentsPerAttribute: 3,
values: tangents
});
}
if (vertexFormat.bitangent) {
const bitangents = new Float32Array(4 * 3);
bitangents[0] = 0;
bitangents[1] = 1;
bitangents[2] = 0;
bitangents[3] = 0;
bitangents[4] = 1;
bitangents[5] = 0;
bitangents[6] = 0;
bitangents[7] = 1;
bitangents[8] = 0;
bitangents[9] = 0;
bitangents[10] = 1;
bitangents[11] = 0;
attributes.bitangent = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.FLOAT,
componentsPerAttribute: 3,
values: bitangents
});
}
indices2 = new Uint16Array(2 * 3);
indices2[0] = 0;
indices2[1] = 1;
indices2[2] = 2;
indices2[3] = 0;
indices2[4] = 2;
indices2[5] = 3;
}
return new Geometry_default({
attributes,
indices: indices2,
primitiveType: PrimitiveType_default.TRIANGLES,
boundingSphere: new BoundingSphere_default(Cartesian3_default.ZERO, Math.sqrt(2))
});
};
var PlaneGeometry_default = PlaneGeometry;
// Source/Core/PlaneOutlineGeometry.js
function PlaneOutlineGeometry() {
this._workerName = "createPlaneOutlineGeometry";
}
PlaneOutlineGeometry.packedLength = 0;
PlaneOutlineGeometry.pack = function(value, array) {
Check_default.defined("value", value);
Check_default.defined("array", array);
return array;
};
PlaneOutlineGeometry.unpack = function(array, startingIndex, result) {
Check_default.defined("array", array);
if (!defined_default(result)) {
return new PlaneOutlineGeometry();
}
return result;
};
var min2 = new Cartesian3_default(-0.5, -0.5, 0);
var max2 = new Cartesian3_default(0.5, 0.5, 0);
PlaneOutlineGeometry.createGeometry = function() {
const attributes = new GeometryAttributes_default();
const indices2 = new Uint16Array(4 * 2);
const positions = new Float64Array(4 * 3);
positions[0] = min2.x;
positions[1] = min2.y;
positions[2] = min2.z;
positions[3] = max2.x;
positions[4] = min2.y;
positions[5] = min2.z;
positions[6] = max2.x;
positions[7] = max2.y;
positions[8] = min2.z;
positions[9] = min2.x;
positions[10] = max2.y;
positions[11] = min2.z;
attributes.position = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.DOUBLE,
componentsPerAttribute: 3,
values: positions
});
indices2[0] = 0;
indices2[1] = 1;
indices2[2] = 1;
indices2[3] = 2;
indices2[4] = 2;
indices2[5] = 3;
indices2[6] = 3;
indices2[7] = 0;
return new Geometry_default({
attributes,
indices: indices2,
primitiveType: PrimitiveType_default.LINES,
boundingSphere: new BoundingSphere_default(Cartesian3_default.ZERO, Math.sqrt(2))
});
};
var PlaneOutlineGeometry_default = PlaneOutlineGeometry;
// Source/Core/pointInsideTriangle.js
var scratchBarycentricCoords = new Cartesian3_default();
function pointInsideTriangle(point, p0, p1, p2) {
const coords = barycentricCoordinates_default(
point,
p0,
p1,
p2,
scratchBarycentricCoords
);
if (!defined_default(coords)) {
return false;
}
return coords.x > 0 && coords.y > 0 && coords.z > 0;
}
var pointInsideTriangle_default = pointInsideTriangle;
// Source/Core/PolygonGeometry.js
var scratchCarto1 = new Cartographic_default();
var scratchCarto2 = new Cartographic_default();
function adjustPosHeightsForNormal(position, p1, p2, ellipsoid) {
const carto12 = ellipsoid.cartesianToCartographic(position, scratchCarto1);
const height = carto12.height;
const p1Carto = ellipsoid.cartesianToCartographic(p1, scratchCarto2);
p1Carto.height = height;
ellipsoid.cartographicToCartesian(p1Carto, p1);
const p2Carto = ellipsoid.cartesianToCartographic(p2, scratchCarto2);
p2Carto.height = height - 100;
ellipsoid.cartographicToCartesian(p2Carto, p2);
}
var scratchBoundingRectangle = new BoundingRectangle_default();
var scratchPosition4 = new Cartesian3_default();
var scratchNormal6 = new Cartesian3_default();
var scratchTangent4 = new Cartesian3_default();
var scratchBitangent4 = new Cartesian3_default();
var p1Scratch3 = new Cartesian3_default();
var p2Scratch3 = new Cartesian3_default();
var scratchPerPosNormal = new Cartesian3_default();
var scratchPerPosTangent = new Cartesian3_default();
var scratchPerPosBitangent = new Cartesian3_default();
var appendTextureCoordinatesOrigin = new Cartesian2_default();
var appendTextureCoordinatesCartesian2 = new Cartesian2_default();
var appendTextureCoordinatesCartesian3 = new Cartesian3_default();
var appendTextureCoordinatesQuaternion = new Quaternion_default();
var appendTextureCoordinatesMatrix3 = new Matrix3_default();
var tangentMatrixScratch2 = new Matrix3_default();
function computeAttributes(options) {
const vertexFormat = options.vertexFormat;
const geometry = options.geometry;
const shadowVolume = options.shadowVolume;
const flatPositions2 = geometry.attributes.position.values;
const flatTexcoords = defined_default(geometry.attributes.st) ? geometry.attributes.st.values : void 0;
let length3 = flatPositions2.length;
const wall = options.wall;
const top = options.top || wall;
const bottom = options.bottom || wall;
if (vertexFormat.st || vertexFormat.normal || vertexFormat.tangent || vertexFormat.bitangent || shadowVolume) {
const boundingRectangle = options.boundingRectangle;
const tangentPlane = options.tangentPlane;
const ellipsoid = options.ellipsoid;
const stRotation = options.stRotation;
const perPositionHeight = options.perPositionHeight;
const origin = appendTextureCoordinatesOrigin;
origin.x = boundingRectangle.x;
origin.y = boundingRectangle.y;
const textureCoordinates = vertexFormat.st ? new Float32Array(2 * (length3 / 3)) : void 0;
let normals;
if (vertexFormat.normal) {
if (perPositionHeight && top && !wall) {
normals = geometry.attributes.normal.values;
} else {
normals = new Float32Array(length3);
}
}
const tangents = vertexFormat.tangent ? new Float32Array(length3) : void 0;
const bitangents = vertexFormat.bitangent ? new Float32Array(length3) : void 0;
const extrudeNormals = shadowVolume ? new Float32Array(length3) : void 0;
let textureCoordIndex = 0;
let attrIndex = 0;
let normal2 = scratchNormal6;
let tangent = scratchTangent4;
let bitangent = scratchBitangent4;
let recomputeNormal = true;
let textureMatrix = appendTextureCoordinatesMatrix3;
let tangentRotationMatrix = tangentMatrixScratch2;
if (stRotation !== 0) {
let rotation = Quaternion_default.fromAxisAngle(
tangentPlane._plane.normal,
stRotation,
appendTextureCoordinatesQuaternion
);
textureMatrix = Matrix3_default.fromQuaternion(rotation, textureMatrix);
rotation = Quaternion_default.fromAxisAngle(
tangentPlane._plane.normal,
-stRotation,
appendTextureCoordinatesQuaternion
);
tangentRotationMatrix = Matrix3_default.fromQuaternion(
rotation,
tangentRotationMatrix
);
} else {
textureMatrix = Matrix3_default.clone(Matrix3_default.IDENTITY, textureMatrix);
tangentRotationMatrix = Matrix3_default.clone(
Matrix3_default.IDENTITY,
tangentRotationMatrix
);
}
let bottomOffset = 0;
let bottomOffset2 = 0;
if (top && bottom) {
bottomOffset = length3 / 2;
bottomOffset2 = length3 / 3;
length3 /= 2;
}
for (let i = 0; i < length3; i += 3) {
const position = Cartesian3_default.fromArray(
flatPositions2,
i,
appendTextureCoordinatesCartesian3
);
if (vertexFormat.st) {
if (!defined_default(flatTexcoords)) {
let p = Matrix3_default.multiplyByVector(
textureMatrix,
position,
scratchPosition4
);
p = ellipsoid.scaleToGeodeticSurface(p, p);
const st = tangentPlane.projectPointOntoPlane(
p,
appendTextureCoordinatesCartesian2
);
Cartesian2_default.subtract(st, origin, st);
const stx = Math_default.clamp(st.x / boundingRectangle.width, 0, 1);
const sty = Math_default.clamp(st.y / boundingRectangle.height, 0, 1);
if (bottom) {
textureCoordinates[textureCoordIndex + bottomOffset2] = stx;
textureCoordinates[textureCoordIndex + 1 + bottomOffset2] = sty;
}
if (top) {
textureCoordinates[textureCoordIndex] = stx;
textureCoordinates[textureCoordIndex + 1] = sty;
}
textureCoordIndex += 2;
}
}
if (vertexFormat.normal || vertexFormat.tangent || vertexFormat.bitangent || shadowVolume) {
const attrIndex1 = attrIndex + 1;
const attrIndex2 = attrIndex + 2;
if (wall) {
if (i + 3 < length3) {
const p1 = Cartesian3_default.fromArray(flatPositions2, i + 3, p1Scratch3);
if (recomputeNormal) {
const p2 = Cartesian3_default.fromArray(
flatPositions2,
i + length3,
p2Scratch3
);
if (perPositionHeight) {
adjustPosHeightsForNormal(position, p1, p2, ellipsoid);
}
Cartesian3_default.subtract(p1, position, p1);
Cartesian3_default.subtract(p2, position, p2);
normal2 = Cartesian3_default.normalize(
Cartesian3_default.cross(p2, p1, normal2),
normal2
);
recomputeNormal = false;
}
if (Cartesian3_default.equalsEpsilon(p1, position, Math_default.EPSILON10)) {
recomputeNormal = true;
}
}
if (vertexFormat.tangent || vertexFormat.bitangent) {
bitangent = ellipsoid.geodeticSurfaceNormal(position, bitangent);
if (vertexFormat.tangent) {
tangent = Cartesian3_default.normalize(
Cartesian3_default.cross(bitangent, normal2, tangent),
tangent
);
}
}
} else {
normal2 = ellipsoid.geodeticSurfaceNormal(position, normal2);
if (vertexFormat.tangent || vertexFormat.bitangent) {
if (perPositionHeight) {
scratchPerPosNormal = Cartesian3_default.fromArray(
normals,
attrIndex,
scratchPerPosNormal
);
scratchPerPosTangent = Cartesian3_default.cross(
Cartesian3_default.UNIT_Z,
scratchPerPosNormal,
scratchPerPosTangent
);
scratchPerPosTangent = Cartesian3_default.normalize(
Matrix3_default.multiplyByVector(
tangentRotationMatrix,
scratchPerPosTangent,
scratchPerPosTangent
),
scratchPerPosTangent
);
if (vertexFormat.bitangent) {
scratchPerPosBitangent = Cartesian3_default.normalize(
Cartesian3_default.cross(
scratchPerPosNormal,
scratchPerPosTangent,
scratchPerPosBitangent
),
scratchPerPosBitangent
);
}
}
tangent = Cartesian3_default.cross(Cartesian3_default.UNIT_Z, normal2, tangent);
tangent = Cartesian3_default.normalize(
Matrix3_default.multiplyByVector(tangentRotationMatrix, tangent, tangent),
tangent
);
if (vertexFormat.bitangent) {
bitangent = Cartesian3_default.normalize(
Cartesian3_default.cross(normal2, tangent, bitangent),
bitangent
);
}
}
}
if (vertexFormat.normal) {
if (options.wall) {
normals[attrIndex + bottomOffset] = normal2.x;
normals[attrIndex1 + bottomOffset] = normal2.y;
normals[attrIndex2 + bottomOffset] = normal2.z;
} else if (bottom) {
normals[attrIndex + bottomOffset] = -normal2.x;
normals[attrIndex1 + bottomOffset] = -normal2.y;
normals[attrIndex2 + bottomOffset] = -normal2.z;
}
if (top && !perPositionHeight || wall) {
normals[attrIndex] = normal2.x;
normals[attrIndex1] = normal2.y;
normals[attrIndex2] = normal2.z;
}
}
if (shadowVolume) {
if (wall) {
normal2 = ellipsoid.geodeticSurfaceNormal(position, normal2);
}
extrudeNormals[attrIndex + bottomOffset] = -normal2.x;
extrudeNormals[attrIndex1 + bottomOffset] = -normal2.y;
extrudeNormals[attrIndex2 + bottomOffset] = -normal2.z;
}
if (vertexFormat.tangent) {
if (options.wall) {
tangents[attrIndex + bottomOffset] = tangent.x;
tangents[attrIndex1 + bottomOffset] = tangent.y;
tangents[attrIndex2 + bottomOffset] = tangent.z;
} else if (bottom) {
tangents[attrIndex + bottomOffset] = -tangent.x;
tangents[attrIndex1 + bottomOffset] = -tangent.y;
tangents[attrIndex2 + bottomOffset] = -tangent.z;
}
if (top) {
if (perPositionHeight) {
tangents[attrIndex] = scratchPerPosTangent.x;
tangents[attrIndex1] = scratchPerPosTangent.y;
tangents[attrIndex2] = scratchPerPosTangent.z;
} else {
tangents[attrIndex] = tangent.x;
tangents[attrIndex1] = tangent.y;
tangents[attrIndex2] = tangent.z;
}
}
}
if (vertexFormat.bitangent) {
if (bottom) {
bitangents[attrIndex + bottomOffset] = bitangent.x;
bitangents[attrIndex1 + bottomOffset] = bitangent.y;
bitangents[attrIndex2 + bottomOffset] = bitangent.z;
}
if (top) {
if (perPositionHeight) {
bitangents[attrIndex] = scratchPerPosBitangent.x;
bitangents[attrIndex1] = scratchPerPosBitangent.y;
bitangents[attrIndex2] = scratchPerPosBitangent.z;
} else {
bitangents[attrIndex] = bitangent.x;
bitangents[attrIndex1] = bitangent.y;
bitangents[attrIndex2] = bitangent.z;
}
}
}
attrIndex += 3;
}
}
if (vertexFormat.st && !defined_default(flatTexcoords)) {
geometry.attributes.st = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.FLOAT,
componentsPerAttribute: 2,
values: textureCoordinates
});
}
if (vertexFormat.normal) {
geometry.attributes.normal = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.FLOAT,
componentsPerAttribute: 3,
values: normals
});
}
if (vertexFormat.tangent) {
geometry.attributes.tangent = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.FLOAT,
componentsPerAttribute: 3,
values: tangents
});
}
if (vertexFormat.bitangent) {
geometry.attributes.bitangent = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.FLOAT,
componentsPerAttribute: 3,
values: bitangents
});
}
if (shadowVolume) {
geometry.attributes.extrudeDirection = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.FLOAT,
componentsPerAttribute: 3,
values: extrudeNormals
});
}
}
if (options.extrude && defined_default(options.offsetAttribute)) {
const size = flatPositions2.length / 3;
let offsetAttribute = new Uint8Array(size);
if (options.offsetAttribute === GeometryOffsetAttribute_default.TOP) {
if (top && bottom || wall) {
offsetAttribute = offsetAttribute.fill(1, 0, size / 2);
} else if (top) {
offsetAttribute = offsetAttribute.fill(1);
}
} else {
const offsetValue = options.offsetAttribute === GeometryOffsetAttribute_default.NONE ? 0 : 1;
offsetAttribute = offsetAttribute.fill(offsetValue);
}
geometry.attributes.applyOffset = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.UNSIGNED_BYTE,
componentsPerAttribute: 1,
values: offsetAttribute
});
}
return geometry;
}
var startCartographicScratch2 = new Cartographic_default();
var endCartographicScratch2 = new Cartographic_default();
var idlCross = {
westOverIDL: 0,
eastOverIDL: 0
};
var ellipsoidGeodesic2 = new EllipsoidGeodesic_default();
function computeRectangle3(positions, ellipsoid, arcType, granularity, result) {
result = defaultValue_default(result, new Rectangle_default());
if (!defined_default(positions) || positions.length < 3) {
result.west = 0;
result.north = 0;
result.south = 0;
result.east = 0;
return result;
}
if (arcType === ArcType_default.RHUMB) {
return Rectangle_default.fromCartesianArray(positions, ellipsoid, result);
}
if (!ellipsoidGeodesic2.ellipsoid.equals(ellipsoid)) {
ellipsoidGeodesic2 = new EllipsoidGeodesic_default(void 0, void 0, ellipsoid);
}
result.west = Number.POSITIVE_INFINITY;
result.east = Number.NEGATIVE_INFINITY;
result.south = Number.POSITIVE_INFINITY;
result.north = Number.NEGATIVE_INFINITY;
idlCross.westOverIDL = Number.POSITIVE_INFINITY;
idlCross.eastOverIDL = Number.NEGATIVE_INFINITY;
const inverseChordLength = 1 / Math_default.chordLength(granularity, ellipsoid.maximumRadius);
const positionsLength = positions.length;
let endCartographic = ellipsoid.cartesianToCartographic(
positions[0],
endCartographicScratch2
);
let startCartographic = startCartographicScratch2;
let swap3;
for (let i = 1; i < positionsLength; i++) {
swap3 = startCartographic;
startCartographic = endCartographic;
endCartographic = ellipsoid.cartesianToCartographic(positions[i], swap3);
ellipsoidGeodesic2.setEndPoints(startCartographic, endCartographic);
interpolateAndGrowRectangle(
ellipsoidGeodesic2,
inverseChordLength,
result,
idlCross
);
}
swap3 = startCartographic;
startCartographic = endCartographic;
endCartographic = ellipsoid.cartesianToCartographic(positions[0], swap3);
ellipsoidGeodesic2.setEndPoints(startCartographic, endCartographic);
interpolateAndGrowRectangle(
ellipsoidGeodesic2,
inverseChordLength,
result,
idlCross
);
if (result.east - result.west > idlCross.eastOverIDL - idlCross.westOverIDL) {
result.west = idlCross.westOverIDL;
result.east = idlCross.eastOverIDL;
if (result.east > Math_default.PI) {
result.east = result.east - Math_default.TWO_PI;
}
if (result.west > Math_default.PI) {
result.west = result.west - Math_default.TWO_PI;
}
}
return result;
}
var interpolatedCartographicScratch2 = new Cartographic_default();
function interpolateAndGrowRectangle(ellipsoidGeodesic3, inverseChordLength, result, idlCross2) {
const segmentLength = ellipsoidGeodesic3.surfaceDistance;
const numPoints = Math.ceil(segmentLength * inverseChordLength);
const subsegmentDistance = numPoints > 0 ? segmentLength / (numPoints - 1) : Number.POSITIVE_INFINITY;
let interpolationDistance = 0;
for (let i = 0; i < numPoints; i++) {
const interpolatedCartographic = ellipsoidGeodesic3.interpolateUsingSurfaceDistance(
interpolationDistance,
interpolatedCartographicScratch2
);
interpolationDistance += subsegmentDistance;
const longitude = interpolatedCartographic.longitude;
const latitude = interpolatedCartographic.latitude;
result.west = Math.min(result.west, longitude);
result.east = Math.max(result.east, longitude);
result.south = Math.min(result.south, latitude);
result.north = Math.max(result.north, latitude);
const lonAdjusted = longitude >= 0 ? longitude : longitude + Math_default.TWO_PI;
idlCross2.westOverIDL = Math.min(idlCross2.westOverIDL, lonAdjusted);
idlCross2.eastOverIDL = Math.max(idlCross2.eastOverIDL, lonAdjusted);
}
}
var createGeometryFromPositionsExtrudedPositions = [];
function createGeometryFromPositionsExtruded(ellipsoid, polygon, textureCoordinates, granularity, hierarchy, perPositionHeight, closeTop, closeBottom, vertexFormat, arcType) {
const geos = {
walls: []
};
let i;
if (closeTop || closeBottom) {
const topGeo = PolygonGeometryLibrary_default.createGeometryFromPositions(
ellipsoid,
polygon,
textureCoordinates,
granularity,
perPositionHeight,
vertexFormat,
arcType
);
const edgePoints = topGeo.attributes.position.values;
const indices2 = topGeo.indices;
let numPositions;
let newIndices;
if (closeTop && closeBottom) {
const topBottomPositions = edgePoints.concat(edgePoints);
numPositions = topBottomPositions.length / 3;
newIndices = IndexDatatype_default.createTypedArray(
numPositions,
indices2.length * 2
);
newIndices.set(indices2);
const ilength = indices2.length;
const length3 = numPositions / 2;
for (i = 0; i < ilength; i += 3) {
const i0 = newIndices[i] + length3;
const i1 = newIndices[i + 1] + length3;
const i2 = newIndices[i + 2] + length3;
newIndices[i + ilength] = i2;
newIndices[i + 1 + ilength] = i1;
newIndices[i + 2 + ilength] = i0;
}
topGeo.attributes.position.values = topBottomPositions;
if (perPositionHeight && vertexFormat.normal) {
const normals = topGeo.attributes.normal.values;
topGeo.attributes.normal.values = new Float32Array(
topBottomPositions.length
);
topGeo.attributes.normal.values.set(normals);
}
if (vertexFormat.st && defined_default(textureCoordinates)) {
const texcoords = topGeo.attributes.st.values;
topGeo.attributes.st.values = new Float32Array(numPositions * 2);
topGeo.attributes.st.values = texcoords.concat(texcoords);
}
topGeo.indices = newIndices;
} else if (closeBottom) {
numPositions = edgePoints.length / 3;
newIndices = IndexDatatype_default.createTypedArray(numPositions, indices2.length);
for (i = 0; i < indices2.length; i += 3) {
newIndices[i] = indices2[i + 2];
newIndices[i + 1] = indices2[i + 1];
newIndices[i + 2] = indices2[i];
}
topGeo.indices = newIndices;
}
geos.topAndBottom = new GeometryInstance_default({
geometry: topGeo
});
}
let outerRing = hierarchy.outerRing;
let tangentPlane = EllipsoidTangentPlane_default.fromPoints(outerRing, ellipsoid);
let positions2D = tangentPlane.projectPointsOntoPlane(
outerRing,
createGeometryFromPositionsExtrudedPositions
);
let windingOrder = PolygonPipeline_default.computeWindingOrder2D(positions2D);
if (windingOrder === WindingOrder_default.CLOCKWISE) {
outerRing = outerRing.slice().reverse();
}
let wallGeo = PolygonGeometryLibrary_default.computeWallGeometry(
outerRing,
textureCoordinates,
ellipsoid,
granularity,
perPositionHeight,
arcType
);
geos.walls.push(
new GeometryInstance_default({
geometry: wallGeo
})
);
const holes = hierarchy.holes;
for (i = 0; i < holes.length; i++) {
let hole = holes[i];
tangentPlane = EllipsoidTangentPlane_default.fromPoints(hole, ellipsoid);
positions2D = tangentPlane.projectPointsOntoPlane(
hole,
createGeometryFromPositionsExtrudedPositions
);
windingOrder = PolygonPipeline_default.computeWindingOrder2D(positions2D);
if (windingOrder === WindingOrder_default.COUNTER_CLOCKWISE) {
hole = hole.slice().reverse();
}
wallGeo = PolygonGeometryLibrary_default.computeWallGeometry(
hole,
textureCoordinates,
ellipsoid,
granularity,
perPositionHeight,
arcType
);
geos.walls.push(
new GeometryInstance_default({
geometry: wallGeo
})
);
}
return geos;
}
function PolygonGeometry(options) {
Check_default.typeOf.object("options", options);
Check_default.typeOf.object("options.polygonHierarchy", options.polygonHierarchy);
if (defined_default(options.perPositionHeight) && options.perPositionHeight && defined_default(options.height)) {
throw new DeveloperError_default(
"Cannot use both options.perPositionHeight and options.height"
);
}
if (defined_default(options.arcType) && options.arcType !== ArcType_default.GEODESIC && options.arcType !== ArcType_default.RHUMB) {
throw new DeveloperError_default(
"Invalid arcType. Valid options are ArcType.GEODESIC and ArcType.RHUMB."
);
}
const polygonHierarchy = options.polygonHierarchy;
const vertexFormat = defaultValue_default(options.vertexFormat, VertexFormat_default.DEFAULT);
const ellipsoid = defaultValue_default(options.ellipsoid, Ellipsoid_default.WGS84);
const granularity = defaultValue_default(
options.granularity,
Math_default.RADIANS_PER_DEGREE
);
const stRotation = defaultValue_default(options.stRotation, 0);
const textureCoordinates = options.textureCoordinates;
const perPositionHeight = defaultValue_default(options.perPositionHeight, false);
const perPositionHeightExtrude = perPositionHeight && defined_default(options.extrudedHeight);
let height = defaultValue_default(options.height, 0);
let extrudedHeight = defaultValue_default(options.extrudedHeight, height);
if (!perPositionHeightExtrude) {
const h = Math.max(height, extrudedHeight);
extrudedHeight = Math.min(height, extrudedHeight);
height = h;
}
this._vertexFormat = VertexFormat_default.clone(vertexFormat);
this._ellipsoid = Ellipsoid_default.clone(ellipsoid);
this._granularity = granularity;
this._stRotation = stRotation;
this._height = height;
this._extrudedHeight = extrudedHeight;
this._closeTop = defaultValue_default(options.closeTop, true);
this._closeBottom = defaultValue_default(options.closeBottom, true);
this._polygonHierarchy = polygonHierarchy;
this._perPositionHeight = perPositionHeight;
this._perPositionHeightExtrude = perPositionHeightExtrude;
this._shadowVolume = defaultValue_default(options.shadowVolume, false);
this._workerName = "createPolygonGeometry";
this._offsetAttribute = options.offsetAttribute;
this._arcType = defaultValue_default(options.arcType, ArcType_default.GEODESIC);
this._rectangle = void 0;
this._textureCoordinateRotationPoints = void 0;
this._textureCoordinates = textureCoordinates;
this.packedLength = PolygonGeometryLibrary_default.computeHierarchyPackedLength(
polygonHierarchy,
Cartesian3_default
) + Ellipsoid_default.packedLength + VertexFormat_default.packedLength + (textureCoordinates ? PolygonGeometryLibrary_default.computeHierarchyPackedLength(
textureCoordinates,
Cartesian2_default
) : 1) + 12;
}
PolygonGeometry.fromPositions = function(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
Check_default.defined("options.positions", options.positions);
const newOptions2 = {
polygonHierarchy: {
positions: options.positions
},
height: options.height,
extrudedHeight: options.extrudedHeight,
vertexFormat: options.vertexFormat,
stRotation: options.stRotation,
ellipsoid: options.ellipsoid,
granularity: options.granularity,
perPositionHeight: options.perPositionHeight,
closeTop: options.closeTop,
closeBottom: options.closeBottom,
offsetAttribute: options.offsetAttribute,
arcType: options.arcType,
textureCoordinates: options.textureCoordinates
};
return new PolygonGeometry(newOptions2);
};
PolygonGeometry.pack = function(value, array, startingIndex) {
Check_default.typeOf.object("value", value);
Check_default.defined("array", array);
startingIndex = defaultValue_default(startingIndex, 0);
startingIndex = PolygonGeometryLibrary_default.packPolygonHierarchy(
value._polygonHierarchy,
array,
startingIndex,
Cartesian3_default
);
Ellipsoid_default.pack(value._ellipsoid, array, startingIndex);
startingIndex += Ellipsoid_default.packedLength;
VertexFormat_default.pack(value._vertexFormat, array, startingIndex);
startingIndex += VertexFormat_default.packedLength;
array[startingIndex++] = value._height;
array[startingIndex++] = value._extrudedHeight;
array[startingIndex++] = value._granularity;
array[startingIndex++] = value._stRotation;
array[startingIndex++] = value._perPositionHeightExtrude ? 1 : 0;
array[startingIndex++] = value._perPositionHeight ? 1 : 0;
array[startingIndex++] = value._closeTop ? 1 : 0;
array[startingIndex++] = value._closeBottom ? 1 : 0;
array[startingIndex++] = value._shadowVolume ? 1 : 0;
array[startingIndex++] = defaultValue_default(value._offsetAttribute, -1);
array[startingIndex++] = value._arcType;
if (defined_default(value._textureCoordinates)) {
startingIndex = PolygonGeometryLibrary_default.packPolygonHierarchy(
value._textureCoordinates,
array,
startingIndex,
Cartesian2_default
);
} else {
array[startingIndex++] = -1;
}
array[startingIndex++] = value.packedLength;
return array;
};
var scratchEllipsoid6 = Ellipsoid_default.clone(Ellipsoid_default.UNIT_SPHERE);
var scratchVertexFormat9 = new VertexFormat_default();
var dummyOptions = {
polygonHierarchy: {}
};
PolygonGeometry.unpack = function(array, startingIndex, result) {
Check_default.defined("array", array);
startingIndex = defaultValue_default(startingIndex, 0);
const polygonHierarchy = PolygonGeometryLibrary_default.unpackPolygonHierarchy(
array,
startingIndex,
Cartesian3_default
);
startingIndex = polygonHierarchy.startingIndex;
delete polygonHierarchy.startingIndex;
const ellipsoid = Ellipsoid_default.unpack(array, startingIndex, scratchEllipsoid6);
startingIndex += Ellipsoid_default.packedLength;
const vertexFormat = VertexFormat_default.unpack(
array,
startingIndex,
scratchVertexFormat9
);
startingIndex += VertexFormat_default.packedLength;
const height = array[startingIndex++];
const extrudedHeight = array[startingIndex++];
const granularity = array[startingIndex++];
const stRotation = array[startingIndex++];
const perPositionHeightExtrude = array[startingIndex++] === 1;
const perPositionHeight = array[startingIndex++] === 1;
const closeTop = array[startingIndex++] === 1;
const closeBottom = array[startingIndex++] === 1;
const shadowVolume = array[startingIndex++] === 1;
const offsetAttribute = array[startingIndex++];
const arcType = array[startingIndex++];
const textureCoordinates = array[startingIndex] === -1 ? void 0 : PolygonGeometryLibrary_default.unpackPolygonHierarchy(
array,
startingIndex,
Cartesian2_default
);
if (defined_default(textureCoordinates)) {
startingIndex = textureCoordinates.startingIndex;
delete textureCoordinates.startingIndex;
} else {
startingIndex++;
}
const packedLength = array[startingIndex++];
if (!defined_default(result)) {
result = new PolygonGeometry(dummyOptions);
}
result._polygonHierarchy = polygonHierarchy;
result._ellipsoid = Ellipsoid_default.clone(ellipsoid, result._ellipsoid);
result._vertexFormat = VertexFormat_default.clone(vertexFormat, result._vertexFormat);
result._height = height;
result._extrudedHeight = extrudedHeight;
result._granularity = granularity;
result._stRotation = stRotation;
result._perPositionHeightExtrude = perPositionHeightExtrude;
result._perPositionHeight = perPositionHeight;
result._closeTop = closeTop;
result._closeBottom = closeBottom;
result._shadowVolume = shadowVolume;
result._offsetAttribute = offsetAttribute === -1 ? void 0 : offsetAttribute;
result._arcType = arcType;
result._textureCoordinates = textureCoordinates;
result.packedLength = packedLength;
return result;
};
PolygonGeometry.computeRectangle = function(options, result) {
Check_default.typeOf.object("options", options);
Check_default.typeOf.object("options.polygonHierarchy", options.polygonHierarchy);
const granularity = defaultValue_default(
options.granularity,
Math_default.RADIANS_PER_DEGREE
);
const arcType = defaultValue_default(options.arcType, ArcType_default.GEODESIC);
if (arcType !== ArcType_default.GEODESIC && arcType !== ArcType_default.RHUMB) {
throw new DeveloperError_default(
"Invalid arcType. Valid options are ArcType.GEODESIC and ArcType.RHUMB."
);
}
const polygonHierarchy = options.polygonHierarchy;
const ellipsoid = defaultValue_default(options.ellipsoid, Ellipsoid_default.WGS84);
return computeRectangle3(
polygonHierarchy.positions,
ellipsoid,
arcType,
granularity,
result
);
};
PolygonGeometry.createGeometry = function(polygonGeometry) {
const vertexFormat = polygonGeometry._vertexFormat;
const ellipsoid = polygonGeometry._ellipsoid;
const granularity = polygonGeometry._granularity;
const stRotation = polygonGeometry._stRotation;
const polygonHierarchy = polygonGeometry._polygonHierarchy;
const perPositionHeight = polygonGeometry._perPositionHeight;
const closeTop = polygonGeometry._closeTop;
const closeBottom = polygonGeometry._closeBottom;
const arcType = polygonGeometry._arcType;
const textureCoordinates = polygonGeometry._textureCoordinates;
const hasTextureCoordinates = defined_default(textureCoordinates);
let outerPositions = polygonHierarchy.positions;
if (outerPositions.length < 3) {
return;
}
const tangentPlane = EllipsoidTangentPlane_default.fromPoints(
outerPositions,
ellipsoid
);
const results = PolygonGeometryLibrary_default.polygonsFromHierarchy(
polygonHierarchy,
hasTextureCoordinates,
tangentPlane.projectPointsOntoPlane.bind(tangentPlane),
!perPositionHeight,
ellipsoid
);
const hierarchy = results.hierarchy;
const polygons = results.polygons;
const dummyFunction = function(identity) {
return identity;
};
const textureCoordinatePolygons = hasTextureCoordinates ? PolygonGeometryLibrary_default.polygonsFromHierarchy(
textureCoordinates,
true,
dummyFunction,
false
).polygons : void 0;
if (hierarchy.length === 0) {
return;
}
outerPositions = hierarchy[0].outerRing;
const boundingRectangle = PolygonGeometryLibrary_default.computeBoundingRectangle(
tangentPlane.plane.normal,
tangentPlane.projectPointOntoPlane.bind(tangentPlane),
outerPositions,
stRotation,
scratchBoundingRectangle
);
const geometries = [];
const height = polygonGeometry._height;
const extrudedHeight = polygonGeometry._extrudedHeight;
const extrude = polygonGeometry._perPositionHeightExtrude || !Math_default.equalsEpsilon(height, extrudedHeight, 0, Math_default.EPSILON2);
const options = {
perPositionHeight,
vertexFormat,
geometry: void 0,
tangentPlane,
boundingRectangle,
ellipsoid,
stRotation,
textureCoordinates: void 0,
bottom: false,
top: true,
wall: false,
extrude: false,
arcType
};
let i;
if (extrude) {
options.extrude = true;
options.top = closeTop;
options.bottom = closeBottom;
options.shadowVolume = polygonGeometry._shadowVolume;
options.offsetAttribute = polygonGeometry._offsetAttribute;
for (i = 0; i < polygons.length; i++) {
const splitGeometry = createGeometryFromPositionsExtruded(
ellipsoid,
polygons[i],
hasTextureCoordinates ? textureCoordinatePolygons[i] : void 0,
granularity,
hierarchy[i],
perPositionHeight,
closeTop,
closeBottom,
vertexFormat,
arcType
);
let topAndBottom;
if (closeTop && closeBottom) {
topAndBottom = splitGeometry.topAndBottom;
options.geometry = PolygonGeometryLibrary_default.scaleToGeodeticHeightExtruded(
topAndBottom.geometry,
height,
extrudedHeight,
ellipsoid,
perPositionHeight
);
} else if (closeTop) {
topAndBottom = splitGeometry.topAndBottom;
topAndBottom.geometry.attributes.position.values = PolygonPipeline_default.scaleToGeodeticHeight(
topAndBottom.geometry.attributes.position.values,
height,
ellipsoid,
!perPositionHeight
);
options.geometry = topAndBottom.geometry;
} else if (closeBottom) {
topAndBottom = splitGeometry.topAndBottom;
topAndBottom.geometry.attributes.position.values = PolygonPipeline_default.scaleToGeodeticHeight(
topAndBottom.geometry.attributes.position.values,
extrudedHeight,
ellipsoid,
true
);
options.geometry = topAndBottom.geometry;
}
if (closeTop || closeBottom) {
options.wall = false;
topAndBottom.geometry = computeAttributes(options);
geometries.push(topAndBottom);
}
const walls = splitGeometry.walls;
options.wall = true;
for (let k = 0; k < walls.length; k++) {
const wall = walls[k];
options.geometry = PolygonGeometryLibrary_default.scaleToGeodeticHeightExtruded(
wall.geometry,
height,
extrudedHeight,
ellipsoid,
perPositionHeight
);
wall.geometry = computeAttributes(options);
geometries.push(wall);
}
}
} else {
for (i = 0; i < polygons.length; i++) {
const geometryInstance = new GeometryInstance_default({
geometry: PolygonGeometryLibrary_default.createGeometryFromPositions(
ellipsoid,
polygons[i],
hasTextureCoordinates ? textureCoordinatePolygons[i] : void 0,
granularity,
perPositionHeight,
vertexFormat,
arcType
)
});
geometryInstance.geometry.attributes.position.values = PolygonPipeline_default.scaleToGeodeticHeight(
geometryInstance.geometry.attributes.position.values,
height,
ellipsoid,
!perPositionHeight
);
options.geometry = geometryInstance.geometry;
geometryInstance.geometry = computeAttributes(options);
if (defined_default(polygonGeometry._offsetAttribute)) {
const length3 = geometryInstance.geometry.attributes.position.values.length;
const offsetValue = polygonGeometry._offsetAttribute === GeometryOffsetAttribute_default.NONE ? 0 : 1;
const applyOffset = new Uint8Array(length3 / 3).fill(offsetValue);
geometryInstance.geometry.attributes.applyOffset = new GeometryAttribute_default(
{
componentDatatype: ComponentDatatype_default.UNSIGNED_BYTE,
componentsPerAttribute: 1,
values: applyOffset
}
);
}
geometries.push(geometryInstance);
}
}
const geometry = GeometryPipeline_default.combineInstances(geometries)[0];
geometry.attributes.position.values = new Float64Array(
geometry.attributes.position.values
);
geometry.indices = IndexDatatype_default.createTypedArray(
geometry.attributes.position.values.length / 3,
geometry.indices
);
const attributes = geometry.attributes;
const boundingSphere = BoundingSphere_default.fromVertices(
attributes.position.values
);
if (!vertexFormat.position) {
delete attributes.position;
}
return new Geometry_default({
attributes,
indices: geometry.indices,
primitiveType: geometry.primitiveType,
boundingSphere,
offsetAttribute: polygonGeometry._offsetAttribute
});
};
PolygonGeometry.createShadowVolume = function(polygonGeometry, minHeightFunc, maxHeightFunc) {
const granularity = polygonGeometry._granularity;
const ellipsoid = polygonGeometry._ellipsoid;
const minHeight = minHeightFunc(granularity, ellipsoid);
const maxHeight = maxHeightFunc(granularity, ellipsoid);
return new PolygonGeometry({
polygonHierarchy: polygonGeometry._polygonHierarchy,
ellipsoid,
stRotation: polygonGeometry._stRotation,
granularity,
perPositionHeight: false,
extrudedHeight: minHeight,
height: maxHeight,
vertexFormat: VertexFormat_default.POSITION_ONLY,
shadowVolume: true,
arcType: polygonGeometry._arcType
});
};
function textureCoordinateRotationPoints2(polygonGeometry) {
const stRotation = -polygonGeometry._stRotation;
if (stRotation === 0) {
return [0, 0, 0, 1, 1, 0];
}
const ellipsoid = polygonGeometry._ellipsoid;
const positions = polygonGeometry._polygonHierarchy.positions;
const boundingRectangle = polygonGeometry.rectangle;
return Geometry_default._textureCoordinateRotationPoints(
positions,
stRotation,
ellipsoid,
boundingRectangle
);
}
Object.defineProperties(PolygonGeometry.prototype, {
rectangle: {
get: function() {
if (!defined_default(this._rectangle)) {
const positions = this._polygonHierarchy.positions;
this._rectangle = computeRectangle3(
positions,
this._ellipsoid,
this._arcType,
this._granularity
);
}
return this._rectangle;
}
},
textureCoordinateRotationPoints: {
get: function() {
if (!defined_default(this._textureCoordinateRotationPoints)) {
this._textureCoordinateRotationPoints = textureCoordinateRotationPoints2(
this
);
}
return this._textureCoordinateRotationPoints;
}
}
});
var PolygonGeometry_default = PolygonGeometry;
// Source/Core/PolygonHierarchy.js
function PolygonHierarchy(positions, holes) {
this.positions = defined_default(positions) ? positions : [];
this.holes = defined_default(holes) ? holes : [];
}
var PolygonHierarchy_default = PolygonHierarchy;
// Source/Core/PolygonOutlineGeometry.js
var createGeometryFromPositionsPositions = [];
var createGeometryFromPositionsSubdivided = [];
function createGeometryFromPositions2(ellipsoid, positions, minDistance, perPositionHeight, arcType) {
const tangentPlane = EllipsoidTangentPlane_default.fromPoints(positions, ellipsoid);
const positions2D = tangentPlane.projectPointsOntoPlane(
positions,
createGeometryFromPositionsPositions
);
const originalWindingOrder = PolygonPipeline_default.computeWindingOrder2D(
positions2D
);
if (originalWindingOrder === WindingOrder_default.CLOCKWISE) {
positions2D.reverse();
positions = positions.slice().reverse();
}
let subdividedPositions;
let i;
let length3 = positions.length;
let index = 0;
if (!perPositionHeight) {
let numVertices = 0;
if (arcType === ArcType_default.GEODESIC) {
for (i = 0; i < length3; i++) {
numVertices += PolygonGeometryLibrary_default.subdivideLineCount(
positions[i],
positions[(i + 1) % length3],
minDistance
);
}
} else if (arcType === ArcType_default.RHUMB) {
for (i = 0; i < length3; i++) {
numVertices += PolygonGeometryLibrary_default.subdivideRhumbLineCount(
ellipsoid,
positions[i],
positions[(i + 1) % length3],
minDistance
);
}
}
subdividedPositions = new Float64Array(numVertices * 3);
for (i = 0; i < length3; i++) {
let tempPositions;
if (arcType === ArcType_default.GEODESIC) {
tempPositions = PolygonGeometryLibrary_default.subdivideLine(
positions[i],
positions[(i + 1) % length3],
minDistance,
createGeometryFromPositionsSubdivided
);
} else if (arcType === ArcType_default.RHUMB) {
tempPositions = PolygonGeometryLibrary_default.subdivideRhumbLine(
ellipsoid,
positions[i],
positions[(i + 1) % length3],
minDistance,
createGeometryFromPositionsSubdivided
);
}
const tempPositionsLength = tempPositions.length;
for (let j = 0; j < tempPositionsLength; ++j) {
subdividedPositions[index++] = tempPositions[j];
}
}
} else {
subdividedPositions = new Float64Array(length3 * 2 * 3);
for (i = 0; i < length3; i++) {
const p0 = positions[i];
const p1 = positions[(i + 1) % length3];
subdividedPositions[index++] = p0.x;
subdividedPositions[index++] = p0.y;
subdividedPositions[index++] = p0.z;
subdividedPositions[index++] = p1.x;
subdividedPositions[index++] = p1.y;
subdividedPositions[index++] = p1.z;
}
}
length3 = subdividedPositions.length / 3;
const indicesSize = length3 * 2;
const indices2 = IndexDatatype_default.createTypedArray(length3, indicesSize);
index = 0;
for (i = 0; i < length3 - 1; i++) {
indices2[index++] = i;
indices2[index++] = i + 1;
}
indices2[index++] = length3 - 1;
indices2[index++] = 0;
return new GeometryInstance_default({
geometry: new Geometry_default({
attributes: new GeometryAttributes_default({
position: new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.DOUBLE,
componentsPerAttribute: 3,
values: subdividedPositions
})
}),
indices: indices2,
primitiveType: PrimitiveType_default.LINES
})
});
}
function createGeometryFromPositionsExtruded2(ellipsoid, positions, minDistance, perPositionHeight, arcType) {
const tangentPlane = EllipsoidTangentPlane_default.fromPoints(positions, ellipsoid);
const positions2D = tangentPlane.projectPointsOntoPlane(
positions,
createGeometryFromPositionsPositions
);
const originalWindingOrder = PolygonPipeline_default.computeWindingOrder2D(
positions2D
);
if (originalWindingOrder === WindingOrder_default.CLOCKWISE) {
positions2D.reverse();
positions = positions.slice().reverse();
}
let subdividedPositions;
let i;
let length3 = positions.length;
const corners = new Array(length3);
let index = 0;
if (!perPositionHeight) {
let numVertices = 0;
if (arcType === ArcType_default.GEODESIC) {
for (i = 0; i < length3; i++) {
numVertices += PolygonGeometryLibrary_default.subdivideLineCount(
positions[i],
positions[(i + 1) % length3],
minDistance
);
}
} else if (arcType === ArcType_default.RHUMB) {
for (i = 0; i < length3; i++) {
numVertices += PolygonGeometryLibrary_default.subdivideRhumbLineCount(
ellipsoid,
positions[i],
positions[(i + 1) % length3],
minDistance
);
}
}
subdividedPositions = new Float64Array(numVertices * 3 * 2);
for (i = 0; i < length3; ++i) {
corners[i] = index / 3;
let tempPositions;
if (arcType === ArcType_default.GEODESIC) {
tempPositions = PolygonGeometryLibrary_default.subdivideLine(
positions[i],
positions[(i + 1) % length3],
minDistance,
createGeometryFromPositionsSubdivided
);
} else if (arcType === ArcType_default.RHUMB) {
tempPositions = PolygonGeometryLibrary_default.subdivideRhumbLine(
ellipsoid,
positions[i],
positions[(i + 1) % length3],
minDistance,
createGeometryFromPositionsSubdivided
);
}
const tempPositionsLength = tempPositions.length;
for (let j = 0; j < tempPositionsLength; ++j) {
subdividedPositions[index++] = tempPositions[j];
}
}
} else {
subdividedPositions = new Float64Array(length3 * 2 * 3 * 2);
for (i = 0; i < length3; ++i) {
corners[i] = index / 3;
const p0 = positions[i];
const p1 = positions[(i + 1) % length3];
subdividedPositions[index++] = p0.x;
subdividedPositions[index++] = p0.y;
subdividedPositions[index++] = p0.z;
subdividedPositions[index++] = p1.x;
subdividedPositions[index++] = p1.y;
subdividedPositions[index++] = p1.z;
}
}
length3 = subdividedPositions.length / (3 * 2);
const cornersLength = corners.length;
const indicesSize = (length3 * 2 + cornersLength) * 2;
const indices2 = IndexDatatype_default.createTypedArray(
length3 + cornersLength,
indicesSize
);
index = 0;
for (i = 0; i < length3; ++i) {
indices2[index++] = i;
indices2[index++] = (i + 1) % length3;
indices2[index++] = i + length3;
indices2[index++] = (i + 1) % length3 + length3;
}
for (i = 0; i < cornersLength; i++) {
const corner = corners[i];
indices2[index++] = corner;
indices2[index++] = corner + length3;
}
return new GeometryInstance_default({
geometry: new Geometry_default({
attributes: new GeometryAttributes_default({
position: new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.DOUBLE,
componentsPerAttribute: 3,
values: subdividedPositions
})
}),
indices: indices2,
primitiveType: PrimitiveType_default.LINES
})
});
}
function PolygonOutlineGeometry(options) {
Check_default.typeOf.object("options", options);
Check_default.typeOf.object("options.polygonHierarchy", options.polygonHierarchy);
if (options.perPositionHeight && defined_default(options.height)) {
throw new DeveloperError_default(
"Cannot use both options.perPositionHeight and options.height"
);
}
if (defined_default(options.arcType) && options.arcType !== ArcType_default.GEODESIC && options.arcType !== ArcType_default.RHUMB) {
throw new DeveloperError_default(
"Invalid arcType. Valid options are ArcType.GEODESIC and ArcType.RHUMB."
);
}
const polygonHierarchy = options.polygonHierarchy;
const ellipsoid = defaultValue_default(options.ellipsoid, Ellipsoid_default.WGS84);
const granularity = defaultValue_default(
options.granularity,
Math_default.RADIANS_PER_DEGREE
);
const perPositionHeight = defaultValue_default(options.perPositionHeight, false);
const perPositionHeightExtrude = perPositionHeight && defined_default(options.extrudedHeight);
const arcType = defaultValue_default(options.arcType, ArcType_default.GEODESIC);
let height = defaultValue_default(options.height, 0);
let extrudedHeight = defaultValue_default(options.extrudedHeight, height);
if (!perPositionHeightExtrude) {
const h = Math.max(height, extrudedHeight);
extrudedHeight = Math.min(height, extrudedHeight);
height = h;
}
this._ellipsoid = Ellipsoid_default.clone(ellipsoid);
this._granularity = granularity;
this._height = height;
this._extrudedHeight = extrudedHeight;
this._arcType = arcType;
this._polygonHierarchy = polygonHierarchy;
this._perPositionHeight = perPositionHeight;
this._perPositionHeightExtrude = perPositionHeightExtrude;
this._offsetAttribute = options.offsetAttribute;
this._workerName = "createPolygonOutlineGeometry";
this.packedLength = PolygonGeometryLibrary_default.computeHierarchyPackedLength(
polygonHierarchy,
Cartesian3_default
) + Ellipsoid_default.packedLength + 8;
}
PolygonOutlineGeometry.pack = function(value, array, startingIndex) {
Check_default.typeOf.object("value", value);
Check_default.defined("array", array);
startingIndex = defaultValue_default(startingIndex, 0);
startingIndex = PolygonGeometryLibrary_default.packPolygonHierarchy(
value._polygonHierarchy,
array,
startingIndex,
Cartesian3_default
);
Ellipsoid_default.pack(value._ellipsoid, array, startingIndex);
startingIndex += Ellipsoid_default.packedLength;
array[startingIndex++] = value._height;
array[startingIndex++] = value._extrudedHeight;
array[startingIndex++] = value._granularity;
array[startingIndex++] = value._perPositionHeightExtrude ? 1 : 0;
array[startingIndex++] = value._perPositionHeight ? 1 : 0;
array[startingIndex++] = value._arcType;
array[startingIndex++] = defaultValue_default(value._offsetAttribute, -1);
array[startingIndex] = value.packedLength;
return array;
};
var scratchEllipsoid7 = Ellipsoid_default.clone(Ellipsoid_default.UNIT_SPHERE);
var dummyOptions2 = {
polygonHierarchy: {}
};
PolygonOutlineGeometry.unpack = function(array, startingIndex, result) {
Check_default.defined("array", array);
startingIndex = defaultValue_default(startingIndex, 0);
const polygonHierarchy = PolygonGeometryLibrary_default.unpackPolygonHierarchy(
array,
startingIndex,
Cartesian3_default
);
startingIndex = polygonHierarchy.startingIndex;
delete polygonHierarchy.startingIndex;
const ellipsoid = Ellipsoid_default.unpack(array, startingIndex, scratchEllipsoid7);
startingIndex += Ellipsoid_default.packedLength;
const height = array[startingIndex++];
const extrudedHeight = array[startingIndex++];
const granularity = array[startingIndex++];
const perPositionHeightExtrude = array[startingIndex++] === 1;
const perPositionHeight = array[startingIndex++] === 1;
const arcType = array[startingIndex++];
const offsetAttribute = array[startingIndex++];
const packedLength = array[startingIndex];
if (!defined_default(result)) {
result = new PolygonOutlineGeometry(dummyOptions2);
}
result._polygonHierarchy = polygonHierarchy;
result._ellipsoid = Ellipsoid_default.clone(ellipsoid, result._ellipsoid);
result._height = height;
result._extrudedHeight = extrudedHeight;
result._granularity = granularity;
result._perPositionHeight = perPositionHeight;
result._perPositionHeightExtrude = perPositionHeightExtrude;
result._arcType = arcType;
result._offsetAttribute = offsetAttribute === -1 ? void 0 : offsetAttribute;
result.packedLength = packedLength;
return result;
};
PolygonOutlineGeometry.fromPositions = function(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
Check_default.defined("options.positions", options.positions);
const newOptions2 = {
polygonHierarchy: {
positions: options.positions
},
height: options.height,
extrudedHeight: options.extrudedHeight,
ellipsoid: options.ellipsoid,
granularity: options.granularity,
perPositionHeight: options.perPositionHeight,
arcType: options.arcType,
offsetAttribute: options.offsetAttribute
};
return new PolygonOutlineGeometry(newOptions2);
};
PolygonOutlineGeometry.createGeometry = function(polygonGeometry) {
const ellipsoid = polygonGeometry._ellipsoid;
const granularity = polygonGeometry._granularity;
const polygonHierarchy = polygonGeometry._polygonHierarchy;
const perPositionHeight = polygonGeometry._perPositionHeight;
const arcType = polygonGeometry._arcType;
const polygons = PolygonGeometryLibrary_default.polygonOutlinesFromHierarchy(
polygonHierarchy,
!perPositionHeight,
ellipsoid
);
if (polygons.length === 0) {
return void 0;
}
let geometryInstance;
const geometries = [];
const minDistance = Math_default.chordLength(
granularity,
ellipsoid.maximumRadius
);
const height = polygonGeometry._height;
const extrudedHeight = polygonGeometry._extrudedHeight;
const extrude = polygonGeometry._perPositionHeightExtrude || !Math_default.equalsEpsilon(height, extrudedHeight, 0, Math_default.EPSILON2);
let offsetValue;
let i;
if (extrude) {
for (i = 0; i < polygons.length; i++) {
geometryInstance = createGeometryFromPositionsExtruded2(
ellipsoid,
polygons[i],
minDistance,
perPositionHeight,
arcType
);
geometryInstance.geometry = PolygonGeometryLibrary_default.scaleToGeodeticHeightExtruded(
geometryInstance.geometry,
height,
extrudedHeight,
ellipsoid,
perPositionHeight
);
if (defined_default(polygonGeometry._offsetAttribute)) {
const size = geometryInstance.geometry.attributes.position.values.length / 3;
let offsetAttribute = new Uint8Array(size);
if (polygonGeometry._offsetAttribute === GeometryOffsetAttribute_default.TOP) {
offsetAttribute = offsetAttribute.fill(1, 0, size / 2);
} else {
offsetValue = polygonGeometry._offsetAttribute === GeometryOffsetAttribute_default.NONE ? 0 : 1;
offsetAttribute = offsetAttribute.fill(offsetValue);
}
geometryInstance.geometry.attributes.applyOffset = new GeometryAttribute_default(
{
componentDatatype: ComponentDatatype_default.UNSIGNED_BYTE,
componentsPerAttribute: 1,
values: offsetAttribute
}
);
}
geometries.push(geometryInstance);
}
} else {
for (i = 0; i < polygons.length; i++) {
geometryInstance = createGeometryFromPositions2(
ellipsoid,
polygons[i],
minDistance,
perPositionHeight,
arcType
);
geometryInstance.geometry.attributes.position.values = PolygonPipeline_default.scaleToGeodeticHeight(
geometryInstance.geometry.attributes.position.values,
height,
ellipsoid,
!perPositionHeight
);
if (defined_default(polygonGeometry._offsetAttribute)) {
const length3 = geometryInstance.geometry.attributes.position.values.length;
offsetValue = polygonGeometry._offsetAttribute === GeometryOffsetAttribute_default.NONE ? 0 : 1;
const applyOffset = new Uint8Array(length3 / 3).fill(offsetValue);
geometryInstance.geometry.attributes.applyOffset = new GeometryAttribute_default(
{
componentDatatype: ComponentDatatype_default.UNSIGNED_BYTE,
componentsPerAttribute: 1,
values: applyOffset
}
);
}
geometries.push(geometryInstance);
}
}
const geometry = GeometryPipeline_default.combineInstances(geometries)[0];
const boundingSphere = BoundingSphere_default.fromVertices(
geometry.attributes.position.values
);
return new Geometry_default({
attributes: geometry.attributes,
indices: geometry.indices,
primitiveType: geometry.primitiveType,
boundingSphere,
offsetAttribute: polygonGeometry._offsetAttribute
});
};
var PolygonOutlineGeometry_default = PolygonOutlineGeometry;
// Source/Core/PolylineGeometry.js
var scratchInterpolateColorsArray = [];
function interpolateColors(p0, p1, color0, color1, numPoints) {
const colors = scratchInterpolateColorsArray;
colors.length = numPoints;
let i;
const r0 = color0.red;
const g0 = color0.green;
const b0 = color0.blue;
const a0 = color0.alpha;
const r1 = color1.red;
const g1 = color1.green;
const b1 = color1.blue;
const a1 = color1.alpha;
if (Color_default.equals(color0, color1)) {
for (i = 0; i < numPoints; i++) {
colors[i] = Color_default.clone(color0);
}
return colors;
}
const redPerVertex = (r1 - r0) / numPoints;
const greenPerVertex = (g1 - g0) / numPoints;
const bluePerVertex = (b1 - b0) / numPoints;
const alphaPerVertex = (a1 - a0) / numPoints;
for (i = 0; i < numPoints; i++) {
colors[i] = new Color_default(
r0 + i * redPerVertex,
g0 + i * greenPerVertex,
b0 + i * bluePerVertex,
a0 + i * alphaPerVertex
);
}
return colors;
}
function PolylineGeometry(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
const positions = options.positions;
const colors = options.colors;
const width = defaultValue_default(options.width, 1);
const colorsPerVertex = defaultValue_default(options.colorsPerVertex, false);
if (!defined_default(positions) || positions.length < 2) {
throw new DeveloperError_default("At least two positions are required.");
}
if (typeof width !== "number") {
throw new DeveloperError_default("width must be a number");
}
if (defined_default(colors) && (colorsPerVertex && colors.length < positions.length || !colorsPerVertex && colors.length < positions.length - 1)) {
throw new DeveloperError_default("colors has an invalid length.");
}
this._positions = positions;
this._colors = colors;
this._width = width;
this._colorsPerVertex = colorsPerVertex;
this._vertexFormat = VertexFormat_default.clone(
defaultValue_default(options.vertexFormat, VertexFormat_default.DEFAULT)
);
this._arcType = defaultValue_default(options.arcType, ArcType_default.GEODESIC);
this._granularity = defaultValue_default(
options.granularity,
Math_default.RADIANS_PER_DEGREE
);
this._ellipsoid = Ellipsoid_default.clone(
defaultValue_default(options.ellipsoid, Ellipsoid_default.WGS84)
);
this._workerName = "createPolylineGeometry";
let numComponents = 1 + positions.length * Cartesian3_default.packedLength;
numComponents += defined_default(colors) ? 1 + colors.length * Color_default.packedLength : 1;
this.packedLength = numComponents + Ellipsoid_default.packedLength + VertexFormat_default.packedLength + 4;
}
PolylineGeometry.pack = function(value, array, startingIndex) {
if (!defined_default(value)) {
throw new DeveloperError_default("value is required");
}
if (!defined_default(array)) {
throw new DeveloperError_default("array is required");
}
startingIndex = defaultValue_default(startingIndex, 0);
let i;
const positions = value._positions;
let length3 = positions.length;
array[startingIndex++] = length3;
for (i = 0; i < length3; ++i, startingIndex += Cartesian3_default.packedLength) {
Cartesian3_default.pack(positions[i], array, startingIndex);
}
const colors = value._colors;
length3 = defined_default(colors) ? colors.length : 0;
array[startingIndex++] = length3;
for (i = 0; i < length3; ++i, startingIndex += Color_default.packedLength) {
Color_default.pack(colors[i], array, startingIndex);
}
Ellipsoid_default.pack(value._ellipsoid, array, startingIndex);
startingIndex += Ellipsoid_default.packedLength;
VertexFormat_default.pack(value._vertexFormat, array, startingIndex);
startingIndex += VertexFormat_default.packedLength;
array[startingIndex++] = value._width;
array[startingIndex++] = value._colorsPerVertex ? 1 : 0;
array[startingIndex++] = value._arcType;
array[startingIndex] = value._granularity;
return array;
};
var scratchEllipsoid8 = Ellipsoid_default.clone(Ellipsoid_default.UNIT_SPHERE);
var scratchVertexFormat10 = new VertexFormat_default();
var scratchOptions16 = {
positions: void 0,
colors: void 0,
ellipsoid: scratchEllipsoid8,
vertexFormat: scratchVertexFormat10,
width: void 0,
colorsPerVertex: void 0,
arcType: void 0,
granularity: void 0
};
PolylineGeometry.unpack = function(array, startingIndex, result) {
if (!defined_default(array)) {
throw new DeveloperError_default("array is required");
}
startingIndex = defaultValue_default(startingIndex, 0);
let i;
let length3 = array[startingIndex++];
const positions = new Array(length3);
for (i = 0; i < length3; ++i, startingIndex += Cartesian3_default.packedLength) {
positions[i] = Cartesian3_default.unpack(array, startingIndex);
}
length3 = array[startingIndex++];
const colors = length3 > 0 ? new Array(length3) : void 0;
for (i = 0; i < length3; ++i, startingIndex += Color_default.packedLength) {
colors[i] = Color_default.unpack(array, startingIndex);
}
const ellipsoid = Ellipsoid_default.unpack(array, startingIndex, scratchEllipsoid8);
startingIndex += Ellipsoid_default.packedLength;
const vertexFormat = VertexFormat_default.unpack(
array,
startingIndex,
scratchVertexFormat10
);
startingIndex += VertexFormat_default.packedLength;
const width = array[startingIndex++];
const colorsPerVertex = array[startingIndex++] === 1;
const arcType = array[startingIndex++];
const granularity = array[startingIndex];
if (!defined_default(result)) {
scratchOptions16.positions = positions;
scratchOptions16.colors = colors;
scratchOptions16.width = width;
scratchOptions16.colorsPerVertex = colorsPerVertex;
scratchOptions16.arcType = arcType;
scratchOptions16.granularity = granularity;
return new PolylineGeometry(scratchOptions16);
}
result._positions = positions;
result._colors = colors;
result._ellipsoid = Ellipsoid_default.clone(ellipsoid, result._ellipsoid);
result._vertexFormat = VertexFormat_default.clone(vertexFormat, result._vertexFormat);
result._width = width;
result._colorsPerVertex = colorsPerVertex;
result._arcType = arcType;
result._granularity = granularity;
return result;
};
var scratchCartesian39 = new Cartesian3_default();
var scratchPosition5 = new Cartesian3_default();
var scratchPrevPosition = new Cartesian3_default();
var scratchNextPosition = new Cartesian3_default();
PolylineGeometry.createGeometry = function(polylineGeometry) {
const width = polylineGeometry._width;
const vertexFormat = polylineGeometry._vertexFormat;
let colors = polylineGeometry._colors;
const colorsPerVertex = polylineGeometry._colorsPerVertex;
const arcType = polylineGeometry._arcType;
const granularity = polylineGeometry._granularity;
const ellipsoid = polylineGeometry._ellipsoid;
let i;
let j;
let k;
const removedIndices = [];
let positions = arrayRemoveDuplicates_default(
polylineGeometry._positions,
Cartesian3_default.equalsEpsilon,
false,
removedIndices
);
if (defined_default(colors) && removedIndices.length > 0) {
let removedArrayIndex = 0;
let nextRemovedIndex = removedIndices[0];
colors = colors.filter(function(color, index2) {
let remove3 = false;
if (colorsPerVertex) {
remove3 = index2 === nextRemovedIndex || index2 === 0 && nextRemovedIndex === 1;
} else {
remove3 = index2 + 1 === nextRemovedIndex;
}
if (remove3) {
removedArrayIndex++;
nextRemovedIndex = removedIndices[removedArrayIndex];
return false;
}
return true;
});
}
let positionsLength = positions.length;
if (positionsLength < 2 || width <= 0) {
return void 0;
}
if (arcType === ArcType_default.GEODESIC || arcType === ArcType_default.RHUMB) {
let subdivisionSize;
let numberOfPointsFunction;
if (arcType === ArcType_default.GEODESIC) {
subdivisionSize = Math_default.chordLength(
granularity,
ellipsoid.maximumRadius
);
numberOfPointsFunction = PolylinePipeline_default.numberOfPoints;
} else {
subdivisionSize = granularity;
numberOfPointsFunction = PolylinePipeline_default.numberOfPointsRhumbLine;
}
const heights = PolylinePipeline_default.extractHeights(positions, ellipsoid);
if (defined_default(colors)) {
let colorLength = 1;
for (i = 0; i < positionsLength - 1; ++i) {
colorLength += numberOfPointsFunction(
positions[i],
positions[i + 1],
subdivisionSize
);
}
const newColors = new Array(colorLength);
let newColorIndex = 0;
for (i = 0; i < positionsLength - 1; ++i) {
const p0 = positions[i];
const p1 = positions[i + 1];
const c0 = colors[i];
const numColors = numberOfPointsFunction(p0, p1, subdivisionSize);
if (colorsPerVertex && i < colorLength) {
const c14 = colors[i + 1];
const interpolatedColors = interpolateColors(
p0,
p1,
c0,
c14,
numColors
);
const interpolatedColorsLength = interpolatedColors.length;
for (j = 0; j < interpolatedColorsLength; ++j) {
newColors[newColorIndex++] = interpolatedColors[j];
}
} else {
for (j = 0; j < numColors; ++j) {
newColors[newColorIndex++] = Color_default.clone(c0);
}
}
}
newColors[newColorIndex] = Color_default.clone(colors[colors.length - 1]);
colors = newColors;
scratchInterpolateColorsArray.length = 0;
}
if (arcType === ArcType_default.GEODESIC) {
positions = PolylinePipeline_default.generateCartesianArc({
positions,
minDistance: subdivisionSize,
ellipsoid,
height: heights
});
} else {
positions = PolylinePipeline_default.generateCartesianRhumbArc({
positions,
granularity: subdivisionSize,
ellipsoid,
height: heights
});
}
}
positionsLength = positions.length;
const size = positionsLength * 4 - 4;
const finalPositions = new Float64Array(size * 3);
const prevPositions = new Float64Array(size * 3);
const nextPositions = new Float64Array(size * 3);
const expandAndWidth = new Float32Array(size * 2);
const st = vertexFormat.st ? new Float32Array(size * 2) : void 0;
const finalColors = defined_default(colors) ? new Uint8Array(size * 4) : void 0;
let positionIndex = 0;
let expandAndWidthIndex = 0;
let stIndex = 0;
let colorIndex = 0;
let position;
for (j = 0; j < positionsLength; ++j) {
if (j === 0) {
position = scratchCartesian39;
Cartesian3_default.subtract(positions[0], positions[1], position);
Cartesian3_default.add(positions[0], position, position);
} else {
position = positions[j - 1];
}
Cartesian3_default.clone(position, scratchPrevPosition);
Cartesian3_default.clone(positions[j], scratchPosition5);
if (j === positionsLength - 1) {
position = scratchCartesian39;
Cartesian3_default.subtract(
positions[positionsLength - 1],
positions[positionsLength - 2],
position
);
Cartesian3_default.add(positions[positionsLength - 1], position, position);
} else {
position = positions[j + 1];
}
Cartesian3_default.clone(position, scratchNextPosition);
let color0, color1;
if (defined_default(finalColors)) {
if (j !== 0 && !colorsPerVertex) {
color0 = colors[j - 1];
} else {
color0 = colors[j];
}
if (j !== positionsLength - 1) {
color1 = colors[j];
}
}
const startK = j === 0 ? 2 : 0;
const endK = j === positionsLength - 1 ? 2 : 4;
for (k = startK; k < endK; ++k) {
Cartesian3_default.pack(scratchPosition5, finalPositions, positionIndex);
Cartesian3_default.pack(scratchPrevPosition, prevPositions, positionIndex);
Cartesian3_default.pack(scratchNextPosition, nextPositions, positionIndex);
positionIndex += 3;
const direction2 = k - 2 < 0 ? -1 : 1;
expandAndWidth[expandAndWidthIndex++] = 2 * (k % 2) - 1;
expandAndWidth[expandAndWidthIndex++] = direction2 * width;
if (vertexFormat.st) {
st[stIndex++] = j / (positionsLength - 1);
st[stIndex++] = Math.max(expandAndWidth[expandAndWidthIndex - 2], 0);
}
if (defined_default(finalColors)) {
const color = k < 2 ? color0 : color1;
finalColors[colorIndex++] = Color_default.floatToByte(color.red);
finalColors[colorIndex++] = Color_default.floatToByte(color.green);
finalColors[colorIndex++] = Color_default.floatToByte(color.blue);
finalColors[colorIndex++] = Color_default.floatToByte(color.alpha);
}
}
}
const attributes = new GeometryAttributes_default();
attributes.position = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.DOUBLE,
componentsPerAttribute: 3,
values: finalPositions
});
attributes.prevPosition = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.DOUBLE,
componentsPerAttribute: 3,
values: prevPositions
});
attributes.nextPosition = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.DOUBLE,
componentsPerAttribute: 3,
values: nextPositions
});
attributes.expandAndWidth = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.FLOAT,
componentsPerAttribute: 2,
values: expandAndWidth
});
if (vertexFormat.st) {
attributes.st = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.FLOAT,
componentsPerAttribute: 2,
values: st
});
}
if (defined_default(finalColors)) {
attributes.color = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.UNSIGNED_BYTE,
componentsPerAttribute: 4,
values: finalColors,
normalize: true
});
}
const indices2 = IndexDatatype_default.createTypedArray(size, positionsLength * 6 - 6);
let index = 0;
let indicesIndex = 0;
const length3 = positionsLength - 1;
for (j = 0; j < length3; ++j) {
indices2[indicesIndex++] = index;
indices2[indicesIndex++] = index + 2;
indices2[indicesIndex++] = index + 1;
indices2[indicesIndex++] = index + 1;
indices2[indicesIndex++] = index + 2;
indices2[indicesIndex++] = index + 3;
index += 4;
}
return new Geometry_default({
attributes,
indices: indices2,
primitiveType: PrimitiveType_default.TRIANGLES,
boundingSphere: BoundingSphere_default.fromPoints(positions),
geometryType: GeometryType_default.POLYLINES
});
};
var PolylineGeometry_default = PolylineGeometry;
// Source/Core/PolylineVolumeGeometry.js
function computeAttributes2(combinedPositions, shape, boundingRectangle, vertexFormat) {
const attributes = new GeometryAttributes_default();
if (vertexFormat.position) {
attributes.position = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.DOUBLE,
componentsPerAttribute: 3,
values: combinedPositions
});
}
const shapeLength = shape.length;
const vertexCount = combinedPositions.length / 3;
const length3 = (vertexCount - shapeLength * 2) / (shapeLength * 2);
const firstEndIndices = PolygonPipeline_default.triangulate(shape);
const indicesCount = (length3 - 1) * shapeLength * 6 + firstEndIndices.length * 2;
const indices2 = IndexDatatype_default.createTypedArray(vertexCount, indicesCount);
let i, j;
let ll, ul, ur, lr;
const offset2 = shapeLength * 2;
let index = 0;
for (i = 0; i < length3 - 1; i++) {
for (j = 0; j < shapeLength - 1; j++) {
ll = j * 2 + i * shapeLength * 2;
lr = ll + offset2;
ul = ll + 1;
ur = ul + offset2;
indices2[index++] = ul;
indices2[index++] = ll;
indices2[index++] = ur;
indices2[index++] = ur;
indices2[index++] = ll;
indices2[index++] = lr;
}
ll = shapeLength * 2 - 2 + i * shapeLength * 2;
ul = ll + 1;
ur = ul + offset2;
lr = ll + offset2;
indices2[index++] = ul;
indices2[index++] = ll;
indices2[index++] = ur;
indices2[index++] = ur;
indices2[index++] = ll;
indices2[index++] = lr;
}
if (vertexFormat.st || vertexFormat.tangent || vertexFormat.bitangent) {
const st = new Float32Array(vertexCount * 2);
const lengthSt = 1 / (length3 - 1);
const heightSt = 1 / boundingRectangle.height;
const heightOffset = boundingRectangle.height / 2;
let s, t;
let stindex = 0;
for (i = 0; i < length3; i++) {
s = i * lengthSt;
t = heightSt * (shape[0].y + heightOffset);
st[stindex++] = s;
st[stindex++] = t;
for (j = 1; j < shapeLength; j++) {
t = heightSt * (shape[j].y + heightOffset);
st[stindex++] = s;
st[stindex++] = t;
st[stindex++] = s;
st[stindex++] = t;
}
t = heightSt * (shape[0].y + heightOffset);
st[stindex++] = s;
st[stindex++] = t;
}
for (j = 0; j < shapeLength; j++) {
s = 0;
t = heightSt * (shape[j].y + heightOffset);
st[stindex++] = s;
st[stindex++] = t;
}
for (j = 0; j < shapeLength; j++) {
s = (length3 - 1) * lengthSt;
t = heightSt * (shape[j].y + heightOffset);
st[stindex++] = s;
st[stindex++] = t;
}
attributes.st = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.FLOAT,
componentsPerAttribute: 2,
values: new Float32Array(st)
});
}
const endOffset = vertexCount - shapeLength * 2;
for (i = 0; i < firstEndIndices.length; i += 3) {
const v02 = firstEndIndices[i] + endOffset;
const v13 = firstEndIndices[i + 1] + endOffset;
const v23 = firstEndIndices[i + 2] + endOffset;
indices2[index++] = v02;
indices2[index++] = v13;
indices2[index++] = v23;
indices2[index++] = v23 + shapeLength;
indices2[index++] = v13 + shapeLength;
indices2[index++] = v02 + shapeLength;
}
let geometry = new Geometry_default({
attributes,
indices: indices2,
boundingSphere: BoundingSphere_default.fromVertices(combinedPositions),
primitiveType: PrimitiveType_default.TRIANGLES
});
if (vertexFormat.normal) {
geometry = GeometryPipeline_default.computeNormal(geometry);
}
if (vertexFormat.tangent || vertexFormat.bitangent) {
try {
geometry = GeometryPipeline_default.computeTangentAndBitangent(geometry);
} catch (e) {
oneTimeWarning_default(
"polyline-volume-tangent-bitangent",
"Unable to compute tangents and bitangents for polyline volume geometry"
);
}
if (!vertexFormat.tangent) {
geometry.attributes.tangent = void 0;
}
if (!vertexFormat.bitangent) {
geometry.attributes.bitangent = void 0;
}
if (!vertexFormat.st) {
geometry.attributes.st = void 0;
}
}
return geometry;
}
function PolylineVolumeGeometry(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
const positions = options.polylinePositions;
const shape = options.shapePositions;
if (!defined_default(positions)) {
throw new DeveloperError_default("options.polylinePositions is required.");
}
if (!defined_default(shape)) {
throw new DeveloperError_default("options.shapePositions is required.");
}
this._positions = positions;
this._shape = shape;
this._ellipsoid = Ellipsoid_default.clone(
defaultValue_default(options.ellipsoid, Ellipsoid_default.WGS84)
);
this._cornerType = defaultValue_default(options.cornerType, CornerType_default.ROUNDED);
this._vertexFormat = VertexFormat_default.clone(
defaultValue_default(options.vertexFormat, VertexFormat_default.DEFAULT)
);
this._granularity = defaultValue_default(
options.granularity,
Math_default.RADIANS_PER_DEGREE
);
this._workerName = "createPolylineVolumeGeometry";
let numComponents = 1 + positions.length * Cartesian3_default.packedLength;
numComponents += 1 + shape.length * Cartesian2_default.packedLength;
this.packedLength = numComponents + Ellipsoid_default.packedLength + VertexFormat_default.packedLength + 2;
}
PolylineVolumeGeometry.pack = function(value, array, startingIndex) {
if (!defined_default(value)) {
throw new DeveloperError_default("value is required");
}
if (!defined_default(array)) {
throw new DeveloperError_default("array is required");
}
startingIndex = defaultValue_default(startingIndex, 0);
let i;
const positions = value._positions;
let length3 = positions.length;
array[startingIndex++] = length3;
for (i = 0; i < length3; ++i, startingIndex += Cartesian3_default.packedLength) {
Cartesian3_default.pack(positions[i], array, startingIndex);
}
const shape = value._shape;
length3 = shape.length;
array[startingIndex++] = length3;
for (i = 0; i < length3; ++i, startingIndex += Cartesian2_default.packedLength) {
Cartesian2_default.pack(shape[i], array, startingIndex);
}
Ellipsoid_default.pack(value._ellipsoid, array, startingIndex);
startingIndex += Ellipsoid_default.packedLength;
VertexFormat_default.pack(value._vertexFormat, array, startingIndex);
startingIndex += VertexFormat_default.packedLength;
array[startingIndex++] = value._cornerType;
array[startingIndex] = value._granularity;
return array;
};
var scratchEllipsoid9 = Ellipsoid_default.clone(Ellipsoid_default.UNIT_SPHERE);
var scratchVertexFormat11 = new VertexFormat_default();
var scratchOptions17 = {
polylinePositions: void 0,
shapePositions: void 0,
ellipsoid: scratchEllipsoid9,
vertexFormat: scratchVertexFormat11,
cornerType: void 0,
granularity: void 0
};
PolylineVolumeGeometry.unpack = function(array, startingIndex, result) {
if (!defined_default(array)) {
throw new DeveloperError_default("array is required");
}
startingIndex = defaultValue_default(startingIndex, 0);
let i;
let length3 = array[startingIndex++];
const positions = new Array(length3);
for (i = 0; i < length3; ++i, startingIndex += Cartesian3_default.packedLength) {
positions[i] = Cartesian3_default.unpack(array, startingIndex);
}
length3 = array[startingIndex++];
const shape = new Array(length3);
for (i = 0; i < length3; ++i, startingIndex += Cartesian2_default.packedLength) {
shape[i] = Cartesian2_default.unpack(array, startingIndex);
}
const ellipsoid = Ellipsoid_default.unpack(array, startingIndex, scratchEllipsoid9);
startingIndex += Ellipsoid_default.packedLength;
const vertexFormat = VertexFormat_default.unpack(
array,
startingIndex,
scratchVertexFormat11
);
startingIndex += VertexFormat_default.packedLength;
const cornerType = array[startingIndex++];
const granularity = array[startingIndex];
if (!defined_default(result)) {
scratchOptions17.polylinePositions = positions;
scratchOptions17.shapePositions = shape;
scratchOptions17.cornerType = cornerType;
scratchOptions17.granularity = granularity;
return new PolylineVolumeGeometry(scratchOptions17);
}
result._positions = positions;
result._shape = shape;
result._ellipsoid = Ellipsoid_default.clone(ellipsoid, result._ellipsoid);
result._vertexFormat = VertexFormat_default.clone(vertexFormat, result._vertexFormat);
result._cornerType = cornerType;
result._granularity = granularity;
return result;
};
var brScratch = new BoundingRectangle_default();
PolylineVolumeGeometry.createGeometry = function(polylineVolumeGeometry) {
const positions = polylineVolumeGeometry._positions;
const cleanPositions = arrayRemoveDuplicates_default(
positions,
Cartesian3_default.equalsEpsilon
);
let shape2D = polylineVolumeGeometry._shape;
shape2D = PolylineVolumeGeometryLibrary_default.removeDuplicatesFromShape(shape2D);
if (cleanPositions.length < 2 || shape2D.length < 3) {
return void 0;
}
if (PolygonPipeline_default.computeWindingOrder2D(shape2D) === WindingOrder_default.CLOCKWISE) {
shape2D.reverse();
}
const boundingRectangle = BoundingRectangle_default.fromPoints(shape2D, brScratch);
const computedPositions = PolylineVolumeGeometryLibrary_default.computePositions(
cleanPositions,
shape2D,
boundingRectangle,
polylineVolumeGeometry,
true
);
return computeAttributes2(
computedPositions,
shape2D,
boundingRectangle,
polylineVolumeGeometry._vertexFormat
);
};
var PolylineVolumeGeometry_default = PolylineVolumeGeometry;
// Source/Core/PolylineVolumeOutlineGeometry.js
function computeAttributes3(positions, shape) {
const attributes = new GeometryAttributes_default();
attributes.position = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.DOUBLE,
componentsPerAttribute: 3,
values: positions
});
const shapeLength = shape.length;
const vertexCount = attributes.position.values.length / 3;
const positionLength = positions.length / 3;
const shapeCount = positionLength / shapeLength;
const indices2 = IndexDatatype_default.createTypedArray(
vertexCount,
2 * shapeLength * (shapeCount + 1)
);
let i, j;
let index = 0;
i = 0;
let offset2 = i * shapeLength;
for (j = 0; j < shapeLength - 1; j++) {
indices2[index++] = j + offset2;
indices2[index++] = j + offset2 + 1;
}
indices2[index++] = shapeLength - 1 + offset2;
indices2[index++] = offset2;
i = shapeCount - 1;
offset2 = i * shapeLength;
for (j = 0; j < shapeLength - 1; j++) {
indices2[index++] = j + offset2;
indices2[index++] = j + offset2 + 1;
}
indices2[index++] = shapeLength - 1 + offset2;
indices2[index++] = offset2;
for (i = 0; i < shapeCount - 1; i++) {
const firstOffset = shapeLength * i;
const secondOffset = firstOffset + shapeLength;
for (j = 0; j < shapeLength; j++) {
indices2[index++] = j + firstOffset;
indices2[index++] = j + secondOffset;
}
}
const geometry = new Geometry_default({
attributes,
indices: IndexDatatype_default.createTypedArray(vertexCount, indices2),
boundingSphere: BoundingSphere_default.fromVertices(positions),
primitiveType: PrimitiveType_default.LINES
});
return geometry;
}
function PolylineVolumeOutlineGeometry(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
const positions = options.polylinePositions;
const shape = options.shapePositions;
if (!defined_default(positions)) {
throw new DeveloperError_default("options.polylinePositions is required.");
}
if (!defined_default(shape)) {
throw new DeveloperError_default("options.shapePositions is required.");
}
this._positions = positions;
this._shape = shape;
this._ellipsoid = Ellipsoid_default.clone(
defaultValue_default(options.ellipsoid, Ellipsoid_default.WGS84)
);
this._cornerType = defaultValue_default(options.cornerType, CornerType_default.ROUNDED);
this._granularity = defaultValue_default(
options.granularity,
Math_default.RADIANS_PER_DEGREE
);
this._workerName = "createPolylineVolumeOutlineGeometry";
let numComponents = 1 + positions.length * Cartesian3_default.packedLength;
numComponents += 1 + shape.length * Cartesian2_default.packedLength;
this.packedLength = numComponents + Ellipsoid_default.packedLength + 2;
}
PolylineVolumeOutlineGeometry.pack = function(value, array, startingIndex) {
if (!defined_default(value)) {
throw new DeveloperError_default("value is required");
}
if (!defined_default(array)) {
throw new DeveloperError_default("array is required");
}
startingIndex = defaultValue_default(startingIndex, 0);
let i;
const positions = value._positions;
let length3 = positions.length;
array[startingIndex++] = length3;
for (i = 0; i < length3; ++i, startingIndex += Cartesian3_default.packedLength) {
Cartesian3_default.pack(positions[i], array, startingIndex);
}
const shape = value._shape;
length3 = shape.length;
array[startingIndex++] = length3;
for (i = 0; i < length3; ++i, startingIndex += Cartesian2_default.packedLength) {
Cartesian2_default.pack(shape[i], array, startingIndex);
}
Ellipsoid_default.pack(value._ellipsoid, array, startingIndex);
startingIndex += Ellipsoid_default.packedLength;
array[startingIndex++] = value._cornerType;
array[startingIndex] = value._granularity;
return array;
};
var scratchEllipsoid10 = Ellipsoid_default.clone(Ellipsoid_default.UNIT_SPHERE);
var scratchOptions18 = {
polylinePositions: void 0,
shapePositions: void 0,
ellipsoid: scratchEllipsoid10,
height: void 0,
cornerType: void 0,
granularity: void 0
};
PolylineVolumeOutlineGeometry.unpack = function(array, startingIndex, result) {
if (!defined_default(array)) {
throw new DeveloperError_default("array is required");
}
startingIndex = defaultValue_default(startingIndex, 0);
let i;
let length3 = array[startingIndex++];
const positions = new Array(length3);
for (i = 0; i < length3; ++i, startingIndex += Cartesian3_default.packedLength) {
positions[i] = Cartesian3_default.unpack(array, startingIndex);
}
length3 = array[startingIndex++];
const shape = new Array(length3);
for (i = 0; i < length3; ++i, startingIndex += Cartesian2_default.packedLength) {
shape[i] = Cartesian2_default.unpack(array, startingIndex);
}
const ellipsoid = Ellipsoid_default.unpack(array, startingIndex, scratchEllipsoid10);
startingIndex += Ellipsoid_default.packedLength;
const cornerType = array[startingIndex++];
const granularity = array[startingIndex];
if (!defined_default(result)) {
scratchOptions18.polylinePositions = positions;
scratchOptions18.shapePositions = shape;
scratchOptions18.cornerType = cornerType;
scratchOptions18.granularity = granularity;
return new PolylineVolumeOutlineGeometry(scratchOptions18);
}
result._positions = positions;
result._shape = shape;
result._ellipsoid = Ellipsoid_default.clone(ellipsoid, result._ellipsoid);
result._cornerType = cornerType;
result._granularity = granularity;
return result;
};
var brScratch2 = new BoundingRectangle_default();
PolylineVolumeOutlineGeometry.createGeometry = function(polylineVolumeOutlineGeometry) {
const positions = polylineVolumeOutlineGeometry._positions;
const cleanPositions = arrayRemoveDuplicates_default(
positions,
Cartesian3_default.equalsEpsilon
);
let shape2D = polylineVolumeOutlineGeometry._shape;
shape2D = PolylineVolumeGeometryLibrary_default.removeDuplicatesFromShape(shape2D);
if (cleanPositions.length < 2 || shape2D.length < 3) {
return void 0;
}
if (PolygonPipeline_default.computeWindingOrder2D(shape2D) === WindingOrder_default.CLOCKWISE) {
shape2D.reverse();
}
const boundingRectangle = BoundingRectangle_default.fromPoints(shape2D, brScratch2);
const computedPositions = PolylineVolumeGeometryLibrary_default.computePositions(
cleanPositions,
shape2D,
boundingRectangle,
polylineVolumeOutlineGeometry,
false
);
return computeAttributes3(computedPositions, shape2D);
};
var PolylineVolumeOutlineGeometry_default = PolylineVolumeOutlineGeometry;
// Source/Core/Proxy.js
function Proxy2() {
DeveloperError_default.throwInstantiationError();
}
Proxy2.prototype.getURL = DeveloperError_default.throwInstantiationError;
var Proxy_default = Proxy2;
// Source/Core/QuaternionSpline.js
function createEvaluateFunction2(spline) {
const points = spline.points;
const times = spline.times;
return function(time, result) {
if (!defined_default(result)) {
result = new Quaternion_default();
}
const i = spline._lastTimeIndex = spline.findTimeInterval(
time,
spline._lastTimeIndex
);
const u3 = (time - times[i]) / (times[i + 1] - times[i]);
const q0 = points[i];
const q12 = points[i + 1];
return Quaternion_default.fastSlerp(q0, q12, u3, result);
};
}
function QuaternionSpline(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
const points = options.points;
const times = options.times;
if (!defined_default(points) || !defined_default(times)) {
throw new DeveloperError_default("points and times are required.");
}
if (points.length < 2) {
throw new DeveloperError_default(
"points.length must be greater than or equal to 2."
);
}
if (times.length !== points.length) {
throw new DeveloperError_default("times.length must be equal to points.length.");
}
this._times = times;
this._points = points;
this._evaluateFunction = createEvaluateFunction2(this);
this._lastTimeIndex = 0;
}
Object.defineProperties(QuaternionSpline.prototype, {
times: {
get: function() {
return this._times;
}
},
points: {
get: function() {
return this._points;
}
}
});
QuaternionSpline.prototype.findTimeInterval = Spline_default.prototype.findTimeInterval;
QuaternionSpline.prototype.wrapTime = Spline_default.prototype.wrapTime;
QuaternionSpline.prototype.clampTime = Spline_default.prototype.clampTime;
QuaternionSpline.prototype.evaluate = function(time, result) {
return this._evaluateFunction(time, result);
};
var QuaternionSpline_default = QuaternionSpline;
// Source/ThirdParty/rbush.js
var import_rbush = __toESM(require_rbush(), 1);
// Source/Core/RectangleCollisionChecker.js
function RectangleCollisionChecker() {
this._tree = new import_rbush.default();
}
function RectangleWithId() {
this.minX = 0;
this.minY = 0;
this.maxX = 0;
this.maxY = 0;
this.id = "";
}
RectangleWithId.fromRectangleAndId = function(id, rectangle, result) {
result.minX = rectangle.west;
result.minY = rectangle.south;
result.maxX = rectangle.east;
result.maxY = rectangle.north;
result.id = id;
return result;
};
RectangleCollisionChecker.prototype.insert = function(id, rectangle) {
Check_default.typeOf.string("id", id);
Check_default.typeOf.object("rectangle", rectangle);
const withId = RectangleWithId.fromRectangleAndId(
id,
rectangle,
new RectangleWithId()
);
this._tree.insert(withId);
};
function idCompare(a3, b) {
return a3.id === b.id;
}
var removalScratch = new RectangleWithId();
RectangleCollisionChecker.prototype.remove = function(id, rectangle) {
Check_default.typeOf.string("id", id);
Check_default.typeOf.object("rectangle", rectangle);
const withId = RectangleWithId.fromRectangleAndId(
id,
rectangle,
removalScratch
);
this._tree.remove(withId, idCompare);
};
var collisionScratch = new RectangleWithId();
RectangleCollisionChecker.prototype.collides = function(rectangle) {
Check_default.typeOf.object("rectangle", rectangle);
const withId = RectangleWithId.fromRectangleAndId(
"",
rectangle,
collisionScratch
);
return this._tree.collides(withId);
};
var RectangleCollisionChecker_default = RectangleCollisionChecker;
// Source/Core/RectangleGeometryLibrary.js
var cos3 = Math.cos;
var sin3 = Math.sin;
var sqrt = Math.sqrt;
var RectangleGeometryLibrary = {};
RectangleGeometryLibrary.computePosition = function(computedOptions, ellipsoid, computeST, row, col, position, st) {
const radiiSquared = ellipsoid.radiiSquared;
const nwCorner = computedOptions.nwCorner;
const rectangle = computedOptions.boundingRectangle;
let stLatitude = nwCorner.latitude - computedOptions.granYCos * row + col * computedOptions.granXSin;
const cosLatitude = cos3(stLatitude);
const nZ = sin3(stLatitude);
const kZ = radiiSquared.z * nZ;
let stLongitude = nwCorner.longitude + row * computedOptions.granYSin + col * computedOptions.granXCos;
const nX = cosLatitude * cos3(stLongitude);
const nY = cosLatitude * sin3(stLongitude);
const kX = radiiSquared.x * nX;
const kY = radiiSquared.y * nY;
const gamma = sqrt(kX * nX + kY * nY + kZ * nZ);
position.x = kX / gamma;
position.y = kY / gamma;
position.z = kZ / gamma;
if (computeST) {
const stNwCorner = computedOptions.stNwCorner;
if (defined_default(stNwCorner)) {
stLatitude = stNwCorner.latitude - computedOptions.stGranYCos * row + col * computedOptions.stGranXSin;
stLongitude = stNwCorner.longitude + row * computedOptions.stGranYSin + col * computedOptions.stGranXCos;
st.x = (stLongitude - computedOptions.stWest) * computedOptions.lonScalar;
st.y = (stLatitude - computedOptions.stSouth) * computedOptions.latScalar;
} else {
st.x = (stLongitude - rectangle.west) * computedOptions.lonScalar;
st.y = (stLatitude - rectangle.south) * computedOptions.latScalar;
}
}
};
var rotationMatrixScratch = new Matrix2_default();
var nwCartesian = new Cartesian3_default();
var centerScratch3 = new Cartographic_default();
var centerCartesian = new Cartesian3_default();
var proj = new GeographicProjection_default();
function getRotationOptions(nwCorner, rotation, granularityX, granularityY, center, width, height) {
const cosRotation = Math.cos(rotation);
const granYCos = granularityY * cosRotation;
const granXCos = granularityX * cosRotation;
const sinRotation = Math.sin(rotation);
const granYSin = granularityY * sinRotation;
const granXSin = granularityX * sinRotation;
nwCartesian = proj.project(nwCorner, nwCartesian);
nwCartesian = Cartesian3_default.subtract(nwCartesian, centerCartesian, nwCartesian);
const rotationMatrix = Matrix2_default.fromRotation(rotation, rotationMatrixScratch);
nwCartesian = Matrix2_default.multiplyByVector(
rotationMatrix,
nwCartesian,
nwCartesian
);
nwCartesian = Cartesian3_default.add(nwCartesian, centerCartesian, nwCartesian);
nwCorner = proj.unproject(nwCartesian, nwCorner);
width -= 1;
height -= 1;
const latitude = nwCorner.latitude;
const latitude0 = latitude + width * granXSin;
const latitude1 = latitude - granYCos * height;
const latitude2 = latitude - granYCos * height + width * granXSin;
const north = Math.max(latitude, latitude0, latitude1, latitude2);
const south = Math.min(latitude, latitude0, latitude1, latitude2);
const longitude = nwCorner.longitude;
const longitude0 = longitude + width * granXCos;
const longitude1 = longitude + height * granYSin;
const longitude2 = longitude + height * granYSin + width * granXCos;
const east = Math.max(longitude, longitude0, longitude1, longitude2);
const west = Math.min(longitude, longitude0, longitude1, longitude2);
return {
north,
south,
east,
west,
granYCos,
granYSin,
granXCos,
granXSin,
nwCorner
};
}
RectangleGeometryLibrary.computeOptions = function(rectangle, granularity, rotation, stRotation, boundingRectangleScratch2, nwCornerResult, stNwCornerResult) {
let east = rectangle.east;
let west = rectangle.west;
let north = rectangle.north;
let south = rectangle.south;
let northCap = false;
let southCap = false;
if (north === Math_default.PI_OVER_TWO) {
northCap = true;
}
if (south === -Math_default.PI_OVER_TWO) {
southCap = true;
}
let dx;
const dy = north - south;
if (west > east) {
dx = Math_default.TWO_PI - west + east;
} else {
dx = east - west;
}
const width = Math.ceil(dx / granularity) + 1;
const height = Math.ceil(dy / granularity) + 1;
const granularityX = dx / (width - 1);
const granularityY = dy / (height - 1);
const nwCorner = Rectangle_default.northwest(rectangle, nwCornerResult);
const center = Rectangle_default.center(rectangle, centerScratch3);
if (rotation !== 0 || stRotation !== 0) {
if (center.longitude < nwCorner.longitude) {
center.longitude += Math_default.TWO_PI;
}
centerCartesian = proj.project(center, centerCartesian);
}
const granYCos = granularityY;
const granXCos = granularityX;
const granYSin = 0;
const granXSin = 0;
const boundingRectangle = Rectangle_default.clone(
rectangle,
boundingRectangleScratch2
);
const computedOptions = {
granYCos,
granYSin,
granXCos,
granXSin,
nwCorner,
boundingRectangle,
width,
height,
northCap,
southCap
};
if (rotation !== 0) {
const rotationOptions = getRotationOptions(
nwCorner,
rotation,
granularityX,
granularityY,
center,
width,
height
);
north = rotationOptions.north;
south = rotationOptions.south;
east = rotationOptions.east;
west = rotationOptions.west;
if (north < -Math_default.PI_OVER_TWO || north > Math_default.PI_OVER_TWO || south < -Math_default.PI_OVER_TWO || south > Math_default.PI_OVER_TWO) {
throw new DeveloperError_default(
"Rotated rectangle is invalid. It crosses over either the north or south pole."
);
}
computedOptions.granYCos = rotationOptions.granYCos;
computedOptions.granYSin = rotationOptions.granYSin;
computedOptions.granXCos = rotationOptions.granXCos;
computedOptions.granXSin = rotationOptions.granXSin;
boundingRectangle.north = north;
boundingRectangle.south = south;
boundingRectangle.east = east;
boundingRectangle.west = west;
}
if (stRotation !== 0) {
rotation = rotation - stRotation;
const stNwCorner = Rectangle_default.northwest(boundingRectangle, stNwCornerResult);
const stRotationOptions = getRotationOptions(
stNwCorner,
rotation,
granularityX,
granularityY,
center,
width,
height
);
computedOptions.stGranYCos = stRotationOptions.granYCos;
computedOptions.stGranXCos = stRotationOptions.granXCos;
computedOptions.stGranYSin = stRotationOptions.granYSin;
computedOptions.stGranXSin = stRotationOptions.granXSin;
computedOptions.stNwCorner = stNwCorner;
computedOptions.stWest = stRotationOptions.west;
computedOptions.stSouth = stRotationOptions.south;
}
return computedOptions;
};
var RectangleGeometryLibrary_default = RectangleGeometryLibrary;
// Source/Core/RectangleGeometry.js
var positionScratch3 = new Cartesian3_default();
var normalScratch4 = new Cartesian3_default();
var tangentScratch2 = new Cartesian3_default();
var bitangentScratch2 = new Cartesian3_default();
var rectangleScratch3 = new Rectangle_default();
var stScratch2 = new Cartesian2_default();
var bottomBoundingSphere3 = new BoundingSphere_default();
var topBoundingSphere3 = new BoundingSphere_default();
function createAttributes(vertexFormat, attributes) {
const geo = new Geometry_default({
attributes: new GeometryAttributes_default(),
primitiveType: PrimitiveType_default.TRIANGLES
});
geo.attributes.position = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.DOUBLE,
componentsPerAttribute: 3,
values: attributes.positions
});
if (vertexFormat.normal) {
geo.attributes.normal = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.FLOAT,
componentsPerAttribute: 3,
values: attributes.normals
});
}
if (vertexFormat.tangent) {
geo.attributes.tangent = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.FLOAT,
componentsPerAttribute: 3,
values: attributes.tangents
});
}
if (vertexFormat.bitangent) {
geo.attributes.bitangent = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.FLOAT,
componentsPerAttribute: 3,
values: attributes.bitangents
});
}
return geo;
}
function calculateAttributes(positions, vertexFormat, ellipsoid, tangentRotationMatrix) {
const length3 = positions.length;
const normals = vertexFormat.normal ? new Float32Array(length3) : void 0;
const tangents = vertexFormat.tangent ? new Float32Array(length3) : void 0;
const bitangents = vertexFormat.bitangent ? new Float32Array(length3) : void 0;
let attrIndex = 0;
const bitangent = bitangentScratch2;
const tangent = tangentScratch2;
let normal2 = normalScratch4;
if (vertexFormat.normal || vertexFormat.tangent || vertexFormat.bitangent) {
for (let i = 0; i < length3; i += 3) {
const p = Cartesian3_default.fromArray(positions, i, positionScratch3);
const attrIndex1 = attrIndex + 1;
const attrIndex2 = attrIndex + 2;
normal2 = ellipsoid.geodeticSurfaceNormal(p, normal2);
if (vertexFormat.tangent || vertexFormat.bitangent) {
Cartesian3_default.cross(Cartesian3_default.UNIT_Z, normal2, tangent);
Matrix3_default.multiplyByVector(tangentRotationMatrix, tangent, tangent);
Cartesian3_default.normalize(tangent, tangent);
if (vertexFormat.bitangent) {
Cartesian3_default.normalize(
Cartesian3_default.cross(normal2, tangent, bitangent),
bitangent
);
}
}
if (vertexFormat.normal) {
normals[attrIndex] = normal2.x;
normals[attrIndex1] = normal2.y;
normals[attrIndex2] = normal2.z;
}
if (vertexFormat.tangent) {
tangents[attrIndex] = tangent.x;
tangents[attrIndex1] = tangent.y;
tangents[attrIndex2] = tangent.z;
}
if (vertexFormat.bitangent) {
bitangents[attrIndex] = bitangent.x;
bitangents[attrIndex1] = bitangent.y;
bitangents[attrIndex2] = bitangent.z;
}
attrIndex += 3;
}
}
return createAttributes(vertexFormat, {
positions,
normals,
tangents,
bitangents
});
}
var v1Scratch = new Cartesian3_default();
var v2Scratch = new Cartesian3_default();
function calculateAttributesWall(positions, vertexFormat, ellipsoid) {
const length3 = positions.length;
const normals = vertexFormat.normal ? new Float32Array(length3) : void 0;
const tangents = vertexFormat.tangent ? new Float32Array(length3) : void 0;
const bitangents = vertexFormat.bitangent ? new Float32Array(length3) : void 0;
let normalIndex = 0;
let tangentIndex = 0;
let bitangentIndex = 0;
let recomputeNormal = true;
let bitangent = bitangentScratch2;
let tangent = tangentScratch2;
let normal2 = normalScratch4;
if (vertexFormat.normal || vertexFormat.tangent || vertexFormat.bitangent) {
for (let i = 0; i < length3; i += 6) {
const p = Cartesian3_default.fromArray(positions, i, positionScratch3);
const p1 = Cartesian3_default.fromArray(positions, (i + 6) % length3, v1Scratch);
if (recomputeNormal) {
const p2 = Cartesian3_default.fromArray(positions, (i + 3) % length3, v2Scratch);
Cartesian3_default.subtract(p1, p, p1);
Cartesian3_default.subtract(p2, p, p2);
normal2 = Cartesian3_default.normalize(Cartesian3_default.cross(p2, p1, normal2), normal2);
recomputeNormal = false;
}
if (Cartesian3_default.equalsEpsilon(p1, p, Math_default.EPSILON10)) {
recomputeNormal = true;
}
if (vertexFormat.tangent || vertexFormat.bitangent) {
bitangent = ellipsoid.geodeticSurfaceNormal(p, bitangent);
if (vertexFormat.tangent) {
tangent = Cartesian3_default.normalize(
Cartesian3_default.cross(bitangent, normal2, tangent),
tangent
);
}
}
if (vertexFormat.normal) {
normals[normalIndex++] = normal2.x;
normals[normalIndex++] = normal2.y;
normals[normalIndex++] = normal2.z;
normals[normalIndex++] = normal2.x;
normals[normalIndex++] = normal2.y;
normals[normalIndex++] = normal2.z;
}
if (vertexFormat.tangent) {
tangents[tangentIndex++] = tangent.x;
tangents[tangentIndex++] = tangent.y;
tangents[tangentIndex++] = tangent.z;
tangents[tangentIndex++] = tangent.x;
tangents[tangentIndex++] = tangent.y;
tangents[tangentIndex++] = tangent.z;
}
if (vertexFormat.bitangent) {
bitangents[bitangentIndex++] = bitangent.x;
bitangents[bitangentIndex++] = bitangent.y;
bitangents[bitangentIndex++] = bitangent.z;
bitangents[bitangentIndex++] = bitangent.x;
bitangents[bitangentIndex++] = bitangent.y;
bitangents[bitangentIndex++] = bitangent.z;
}
}
}
return createAttributes(vertexFormat, {
positions,
normals,
tangents,
bitangents
});
}
function constructRectangle(rectangleGeometry, computedOptions) {
const vertexFormat = rectangleGeometry._vertexFormat;
const ellipsoid = rectangleGeometry._ellipsoid;
const height = computedOptions.height;
const width = computedOptions.width;
const northCap = computedOptions.northCap;
const southCap = computedOptions.southCap;
let rowStart = 0;
let rowEnd = height;
let rowHeight = height;
let size = 0;
if (northCap) {
rowStart = 1;
rowHeight -= 1;
size += 1;
}
if (southCap) {
rowEnd -= 1;
rowHeight -= 1;
size += 1;
}
size += width * rowHeight;
const positions = vertexFormat.position ? new Float64Array(size * 3) : void 0;
const textureCoordinates = vertexFormat.st ? new Float32Array(size * 2) : void 0;
let posIndex = 0;
let stIndex = 0;
const position = positionScratch3;
const st = stScratch2;
let minX = Number.MAX_VALUE;
let minY = Number.MAX_VALUE;
let maxX = -Number.MAX_VALUE;
let maxY = -Number.MAX_VALUE;
for (let row = rowStart; row < rowEnd; ++row) {
for (let col = 0; col < width; ++col) {
RectangleGeometryLibrary_default.computePosition(
computedOptions,
ellipsoid,
vertexFormat.st,
row,
col,
position,
st
);
positions[posIndex++] = position.x;
positions[posIndex++] = position.y;
positions[posIndex++] = position.z;
if (vertexFormat.st) {
textureCoordinates[stIndex++] = st.x;
textureCoordinates[stIndex++] = st.y;
minX = Math.min(minX, st.x);
minY = Math.min(minY, st.y);
maxX = Math.max(maxX, st.x);
maxY = Math.max(maxY, st.y);
}
}
}
if (northCap) {
RectangleGeometryLibrary_default.computePosition(
computedOptions,
ellipsoid,
vertexFormat.st,
0,
0,
position,
st
);
positions[posIndex++] = position.x;
positions[posIndex++] = position.y;
positions[posIndex++] = position.z;
if (vertexFormat.st) {
textureCoordinates[stIndex++] = st.x;
textureCoordinates[stIndex++] = st.y;
minX = st.x;
minY = st.y;
maxX = st.x;
maxY = st.y;
}
}
if (southCap) {
RectangleGeometryLibrary_default.computePosition(
computedOptions,
ellipsoid,
vertexFormat.st,
height - 1,
0,
position,
st
);
positions[posIndex++] = position.x;
positions[posIndex++] = position.y;
positions[posIndex] = position.z;
if (vertexFormat.st) {
textureCoordinates[stIndex++] = st.x;
textureCoordinates[stIndex] = st.y;
minX = Math.min(minX, st.x);
minY = Math.min(minY, st.y);
maxX = Math.max(maxX, st.x);
maxY = Math.max(maxY, st.y);
}
}
if (vertexFormat.st && (minX < 0 || minY < 0 || maxX > 1 || maxY > 1)) {
for (let k = 0; k < textureCoordinates.length; k += 2) {
textureCoordinates[k] = (textureCoordinates[k] - minX) / (maxX - minX);
textureCoordinates[k + 1] = (textureCoordinates[k + 1] - minY) / (maxY - minY);
}
}
const geo = calculateAttributes(
positions,
vertexFormat,
ellipsoid,
computedOptions.tangentRotationMatrix
);
let indicesSize = 6 * (width - 1) * (rowHeight - 1);
if (northCap) {
indicesSize += 3 * (width - 1);
}
if (southCap) {
indicesSize += 3 * (width - 1);
}
const indices2 = IndexDatatype_default.createTypedArray(size, indicesSize);
let index = 0;
let indicesIndex = 0;
let i;
for (i = 0; i < rowHeight - 1; ++i) {
for (let j = 0; j < width - 1; ++j) {
const upperLeft = index;
const lowerLeft = upperLeft + width;
const lowerRight = lowerLeft + 1;
const upperRight = upperLeft + 1;
indices2[indicesIndex++] = upperLeft;
indices2[indicesIndex++] = lowerLeft;
indices2[indicesIndex++] = upperRight;
indices2[indicesIndex++] = upperRight;
indices2[indicesIndex++] = lowerLeft;
indices2[indicesIndex++] = lowerRight;
++index;
}
++index;
}
if (northCap || southCap) {
let northIndex = size - 1;
const southIndex = size - 1;
if (northCap && southCap) {
northIndex = size - 2;
}
let p1;
let p2;
index = 0;
if (northCap) {
for (i = 0; i < width - 1; i++) {
p1 = index;
p2 = p1 + 1;
indices2[indicesIndex++] = northIndex;
indices2[indicesIndex++] = p1;
indices2[indicesIndex++] = p2;
++index;
}
}
if (southCap) {
index = (rowHeight - 1) * width;
for (i = 0; i < width - 1; i++) {
p1 = index;
p2 = p1 + 1;
indices2[indicesIndex++] = p1;
indices2[indicesIndex++] = southIndex;
indices2[indicesIndex++] = p2;
++index;
}
}
}
geo.indices = indices2;
if (vertexFormat.st) {
geo.attributes.st = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.FLOAT,
componentsPerAttribute: 2,
values: textureCoordinates
});
}
return geo;
}
function addWallPositions2(wallPositions, posIndex, i, topPositions, bottomPositions) {
wallPositions[posIndex++] = topPositions[i];
wallPositions[posIndex++] = topPositions[i + 1];
wallPositions[posIndex++] = topPositions[i + 2];
wallPositions[posIndex++] = bottomPositions[i];
wallPositions[posIndex++] = bottomPositions[i + 1];
wallPositions[posIndex] = bottomPositions[i + 2];
return wallPositions;
}
function addWallTextureCoordinates(wallTextures, stIndex, i, st) {
wallTextures[stIndex++] = st[i];
wallTextures[stIndex++] = st[i + 1];
wallTextures[stIndex++] = st[i];
wallTextures[stIndex] = st[i + 1];
return wallTextures;
}
var scratchVertexFormat12 = new VertexFormat_default();
function constructExtrudedRectangle(rectangleGeometry, computedOptions) {
const shadowVolume = rectangleGeometry._shadowVolume;
const offsetAttributeValue = rectangleGeometry._offsetAttribute;
const vertexFormat = rectangleGeometry._vertexFormat;
const minHeight = rectangleGeometry._extrudedHeight;
const maxHeight = rectangleGeometry._surfaceHeight;
const ellipsoid = rectangleGeometry._ellipsoid;
const height = computedOptions.height;
const width = computedOptions.width;
let i;
if (shadowVolume) {
const newVertexFormat = VertexFormat_default.clone(
vertexFormat,
scratchVertexFormat12
);
newVertexFormat.normal = true;
rectangleGeometry._vertexFormat = newVertexFormat;
}
const topBottomGeo = constructRectangle(rectangleGeometry, computedOptions);
if (shadowVolume) {
rectangleGeometry._vertexFormat = vertexFormat;
}
let topPositions = PolygonPipeline_default.scaleToGeodeticHeight(
topBottomGeo.attributes.position.values,
maxHeight,
ellipsoid,
false
);
topPositions = new Float64Array(topPositions);
let length3 = topPositions.length;
const newLength = length3 * 2;
const positions = new Float64Array(newLength);
positions.set(topPositions);
const bottomPositions = PolygonPipeline_default.scaleToGeodeticHeight(
topBottomGeo.attributes.position.values,
minHeight,
ellipsoid
);
positions.set(bottomPositions, length3);
topBottomGeo.attributes.position.values = positions;
const normals = vertexFormat.normal ? new Float32Array(newLength) : void 0;
const tangents = vertexFormat.tangent ? new Float32Array(newLength) : void 0;
const bitangents = vertexFormat.bitangent ? new Float32Array(newLength) : void 0;
const textures = vertexFormat.st ? new Float32Array(newLength / 3 * 2) : void 0;
let topSt;
let topNormals;
if (vertexFormat.normal) {
topNormals = topBottomGeo.attributes.normal.values;
normals.set(topNormals);
for (i = 0; i < length3; i++) {
topNormals[i] = -topNormals[i];
}
normals.set(topNormals, length3);
topBottomGeo.attributes.normal.values = normals;
}
if (shadowVolume) {
topNormals = topBottomGeo.attributes.normal.values;
if (!vertexFormat.normal) {
topBottomGeo.attributes.normal = void 0;
}
const extrudeNormals = new Float32Array(newLength);
for (i = 0; i < length3; i++) {
topNormals[i] = -topNormals[i];
}
extrudeNormals.set(topNormals, length3);
topBottomGeo.attributes.extrudeDirection = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.FLOAT,
componentsPerAttribute: 3,
values: extrudeNormals
});
}
let offsetValue;
const hasOffsets = defined_default(offsetAttributeValue);
if (hasOffsets) {
const size = length3 / 3 * 2;
let offsetAttribute = new Uint8Array(size);
if (offsetAttributeValue === GeometryOffsetAttribute_default.TOP) {
offsetAttribute = offsetAttribute.fill(1, 0, size / 2);
} else {
offsetValue = offsetAttributeValue === GeometryOffsetAttribute_default.NONE ? 0 : 1;
offsetAttribute = offsetAttribute.fill(offsetValue);
}
topBottomGeo.attributes.applyOffset = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.UNSIGNED_BYTE,
componentsPerAttribute: 1,
values: offsetAttribute
});
}
if (vertexFormat.tangent) {
const topTangents = topBottomGeo.attributes.tangent.values;
tangents.set(topTangents);
for (i = 0; i < length3; i++) {
topTangents[i] = -topTangents[i];
}
tangents.set(topTangents, length3);
topBottomGeo.attributes.tangent.values = tangents;
}
if (vertexFormat.bitangent) {
const topBitangents = topBottomGeo.attributes.bitangent.values;
bitangents.set(topBitangents);
bitangents.set(topBitangents, length3);
topBottomGeo.attributes.bitangent.values = bitangents;
}
if (vertexFormat.st) {
topSt = topBottomGeo.attributes.st.values;
textures.set(topSt);
textures.set(topSt, length3 / 3 * 2);
topBottomGeo.attributes.st.values = textures;
}
const indices2 = topBottomGeo.indices;
const indicesLength = indices2.length;
const posLength = length3 / 3;
const newIndices = IndexDatatype_default.createTypedArray(
newLength / 3,
indicesLength * 2
);
newIndices.set(indices2);
for (i = 0; i < indicesLength; i += 3) {
newIndices[i + indicesLength] = indices2[i + 2] + posLength;
newIndices[i + 1 + indicesLength] = indices2[i + 1] + posLength;
newIndices[i + 2 + indicesLength] = indices2[i] + posLength;
}
topBottomGeo.indices = newIndices;
const northCap = computedOptions.northCap;
const southCap = computedOptions.southCap;
let rowHeight = height;
let widthMultiplier = 2;
let perimeterPositions = 0;
let corners = 4;
let dupliateCorners = 4;
if (northCap) {
widthMultiplier -= 1;
rowHeight -= 1;
perimeterPositions += 1;
corners -= 2;
dupliateCorners -= 1;
}
if (southCap) {
widthMultiplier -= 1;
rowHeight -= 1;
perimeterPositions += 1;
corners -= 2;
dupliateCorners -= 1;
}
perimeterPositions += widthMultiplier * width + 2 * rowHeight - corners;
const wallCount = (perimeterPositions + dupliateCorners) * 2;
let wallPositions = new Float64Array(wallCount * 3);
const wallExtrudeNormals = shadowVolume ? new Float32Array(wallCount * 3) : void 0;
let wallOffsetAttribute = hasOffsets ? new Uint8Array(wallCount) : void 0;
let wallTextures = vertexFormat.st ? new Float32Array(wallCount * 2) : void 0;
const computeTopOffsets = offsetAttributeValue === GeometryOffsetAttribute_default.TOP;
if (hasOffsets && !computeTopOffsets) {
offsetValue = offsetAttributeValue === GeometryOffsetAttribute_default.ALL ? 1 : 0;
wallOffsetAttribute = wallOffsetAttribute.fill(offsetValue);
}
let posIndex = 0;
let stIndex = 0;
let extrudeNormalIndex = 0;
let wallOffsetIndex = 0;
const area = width * rowHeight;
let threeI;
for (i = 0; i < area; i += width) {
threeI = i * 3;
wallPositions = addWallPositions2(
wallPositions,
posIndex,
threeI,
topPositions,
bottomPositions
);
posIndex += 6;
if (vertexFormat.st) {
wallTextures = addWallTextureCoordinates(
wallTextures,
stIndex,
i * 2,
topSt
);
stIndex += 4;
}
if (shadowVolume) {
extrudeNormalIndex += 3;
wallExtrudeNormals[extrudeNormalIndex++] = topNormals[threeI];
wallExtrudeNormals[extrudeNormalIndex++] = topNormals[threeI + 1];
wallExtrudeNormals[extrudeNormalIndex++] = topNormals[threeI + 2];
}
if (computeTopOffsets) {
wallOffsetAttribute[wallOffsetIndex++] = 1;
wallOffsetIndex += 1;
}
}
if (!southCap) {
for (i = area - width; i < area; i++) {
threeI = i * 3;
wallPositions = addWallPositions2(
wallPositions,
posIndex,
threeI,
topPositions,
bottomPositions
);
posIndex += 6;
if (vertexFormat.st) {
wallTextures = addWallTextureCoordinates(
wallTextures,
stIndex,
i * 2,
topSt
);
stIndex += 4;
}
if (shadowVolume) {
extrudeNormalIndex += 3;
wallExtrudeNormals[extrudeNormalIndex++] = topNormals[threeI];
wallExtrudeNormals[extrudeNormalIndex++] = topNormals[threeI + 1];
wallExtrudeNormals[extrudeNormalIndex++] = topNormals[threeI + 2];
}
if (computeTopOffsets) {
wallOffsetAttribute[wallOffsetIndex++] = 1;
wallOffsetIndex += 1;
}
}
} else {
const southIndex = northCap ? area + 1 : area;
threeI = southIndex * 3;
for (i = 0; i < 2; i++) {
wallPositions = addWallPositions2(
wallPositions,
posIndex,
threeI,
topPositions,
bottomPositions
);
posIndex += 6;
if (vertexFormat.st) {
wallTextures = addWallTextureCoordinates(
wallTextures,
stIndex,
southIndex * 2,
topSt
);
stIndex += 4;
}
if (shadowVolume) {
extrudeNormalIndex += 3;
wallExtrudeNormals[extrudeNormalIndex++] = topNormals[threeI];
wallExtrudeNormals[extrudeNormalIndex++] = topNormals[threeI + 1];
wallExtrudeNormals[extrudeNormalIndex++] = topNormals[threeI + 2];
}
if (computeTopOffsets) {
wallOffsetAttribute[wallOffsetIndex++] = 1;
wallOffsetIndex += 1;
}
}
}
for (i = area - 1; i > 0; i -= width) {
threeI = i * 3;
wallPositions = addWallPositions2(
wallPositions,
posIndex,
threeI,
topPositions,
bottomPositions
);
posIndex += 6;
if (vertexFormat.st) {
wallTextures = addWallTextureCoordinates(
wallTextures,
stIndex,
i * 2,
topSt
);
stIndex += 4;
}
if (shadowVolume) {
extrudeNormalIndex += 3;
wallExtrudeNormals[extrudeNormalIndex++] = topNormals[threeI];
wallExtrudeNormals[extrudeNormalIndex++] = topNormals[threeI + 1];
wallExtrudeNormals[extrudeNormalIndex++] = topNormals[threeI + 2];
}
if (computeTopOffsets) {
wallOffsetAttribute[wallOffsetIndex++] = 1;
wallOffsetIndex += 1;
}
}
if (!northCap) {
for (i = width - 1; i >= 0; i--) {
threeI = i * 3;
wallPositions = addWallPositions2(
wallPositions,
posIndex,
threeI,
topPositions,
bottomPositions
);
posIndex += 6;
if (vertexFormat.st) {
wallTextures = addWallTextureCoordinates(
wallTextures,
stIndex,
i * 2,
topSt
);
stIndex += 4;
}
if (shadowVolume) {
extrudeNormalIndex += 3;
wallExtrudeNormals[extrudeNormalIndex++] = topNormals[threeI];
wallExtrudeNormals[extrudeNormalIndex++] = topNormals[threeI + 1];
wallExtrudeNormals[extrudeNormalIndex++] = topNormals[threeI + 2];
}
if (computeTopOffsets) {
wallOffsetAttribute[wallOffsetIndex++] = 1;
wallOffsetIndex += 1;
}
}
} else {
const northIndex = area;
threeI = northIndex * 3;
for (i = 0; i < 2; i++) {
wallPositions = addWallPositions2(
wallPositions,
posIndex,
threeI,
topPositions,
bottomPositions
);
posIndex += 6;
if (vertexFormat.st) {
wallTextures = addWallTextureCoordinates(
wallTextures,
stIndex,
northIndex * 2,
topSt
);
stIndex += 4;
}
if (shadowVolume) {
extrudeNormalIndex += 3;
wallExtrudeNormals[extrudeNormalIndex++] = topNormals[threeI];
wallExtrudeNormals[extrudeNormalIndex++] = topNormals[threeI + 1];
wallExtrudeNormals[extrudeNormalIndex++] = topNormals[threeI + 2];
}
if (computeTopOffsets) {
wallOffsetAttribute[wallOffsetIndex++] = 1;
wallOffsetIndex += 1;
}
}
}
let geo = calculateAttributesWall(wallPositions, vertexFormat, ellipsoid);
if (vertexFormat.st) {
geo.attributes.st = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.FLOAT,
componentsPerAttribute: 2,
values: wallTextures
});
}
if (shadowVolume) {
geo.attributes.extrudeDirection = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.FLOAT,
componentsPerAttribute: 3,
values: wallExtrudeNormals
});
}
if (hasOffsets) {
geo.attributes.applyOffset = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.UNSIGNED_BYTE,
componentsPerAttribute: 1,
values: wallOffsetAttribute
});
}
const wallIndices = IndexDatatype_default.createTypedArray(
wallCount,
perimeterPositions * 6
);
let upperLeft;
let lowerLeft;
let lowerRight;
let upperRight;
length3 = wallPositions.length / 3;
let index = 0;
for (i = 0; i < length3 - 1; i += 2) {
upperLeft = i;
upperRight = (upperLeft + 2) % length3;
const p1 = Cartesian3_default.fromArray(wallPositions, upperLeft * 3, v1Scratch);
const p2 = Cartesian3_default.fromArray(wallPositions, upperRight * 3, v2Scratch);
if (Cartesian3_default.equalsEpsilon(p1, p2, Math_default.EPSILON10)) {
continue;
}
lowerLeft = (upperLeft + 1) % length3;
lowerRight = (lowerLeft + 2) % length3;
wallIndices[index++] = upperLeft;
wallIndices[index++] = lowerLeft;
wallIndices[index++] = upperRight;
wallIndices[index++] = upperRight;
wallIndices[index++] = lowerLeft;
wallIndices[index++] = lowerRight;
}
geo.indices = wallIndices;
geo = GeometryPipeline_default.combineInstances([
new GeometryInstance_default({
geometry: topBottomGeo
}),
new GeometryInstance_default({
geometry: geo
})
]);
return geo[0];
}
var scratchRectanglePoints = [
new Cartesian3_default(),
new Cartesian3_default(),
new Cartesian3_default(),
new Cartesian3_default()
];
var nwScratch = new Cartographic_default();
var stNwScratch = new Cartographic_default();
function computeRectangle4(rectangle, granularity, rotation, ellipsoid, result) {
if (rotation === 0) {
return Rectangle_default.clone(rectangle, result);
}
const computedOptions = RectangleGeometryLibrary_default.computeOptions(
rectangle,
granularity,
rotation,
0,
rectangleScratch3,
nwScratch
);
const height = computedOptions.height;
const width = computedOptions.width;
const positions = scratchRectanglePoints;
RectangleGeometryLibrary_default.computePosition(
computedOptions,
ellipsoid,
false,
0,
0,
positions[0]
);
RectangleGeometryLibrary_default.computePosition(
computedOptions,
ellipsoid,
false,
0,
width - 1,
positions[1]
);
RectangleGeometryLibrary_default.computePosition(
computedOptions,
ellipsoid,
false,
height - 1,
0,
positions[2]
);
RectangleGeometryLibrary_default.computePosition(
computedOptions,
ellipsoid,
false,
height - 1,
width - 1,
positions[3]
);
return Rectangle_default.fromCartesianArray(positions, ellipsoid, result);
}
function RectangleGeometry(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
const rectangle = options.rectangle;
Check_default.typeOf.object("rectangle", rectangle);
Rectangle_default.validate(rectangle);
if (rectangle.north < rectangle.south) {
throw new DeveloperError_default(
"options.rectangle.north must be greater than or equal to options.rectangle.south"
);
}
const height = defaultValue_default(options.height, 0);
const extrudedHeight = defaultValue_default(options.extrudedHeight, height);
this._rectangle = Rectangle_default.clone(rectangle);
this._granularity = defaultValue_default(
options.granularity,
Math_default.RADIANS_PER_DEGREE
);
this._ellipsoid = Ellipsoid_default.clone(
defaultValue_default(options.ellipsoid, Ellipsoid_default.WGS84)
);
this._surfaceHeight = Math.max(height, extrudedHeight);
this._rotation = defaultValue_default(options.rotation, 0);
this._stRotation = defaultValue_default(options.stRotation, 0);
this._vertexFormat = VertexFormat_default.clone(
defaultValue_default(options.vertexFormat, VertexFormat_default.DEFAULT)
);
this._extrudedHeight = Math.min(height, extrudedHeight);
this._shadowVolume = defaultValue_default(options.shadowVolume, false);
this._workerName = "createRectangleGeometry";
this._offsetAttribute = options.offsetAttribute;
this._rotatedRectangle = void 0;
this._textureCoordinateRotationPoints = void 0;
}
RectangleGeometry.packedLength = Rectangle_default.packedLength + Ellipsoid_default.packedLength + VertexFormat_default.packedLength + 7;
RectangleGeometry.pack = function(value, array, startingIndex) {
Check_default.typeOf.object("value", value);
Check_default.defined("array", array);
startingIndex = defaultValue_default(startingIndex, 0);
Rectangle_default.pack(value._rectangle, array, startingIndex);
startingIndex += Rectangle_default.packedLength;
Ellipsoid_default.pack(value._ellipsoid, array, startingIndex);
startingIndex += Ellipsoid_default.packedLength;
VertexFormat_default.pack(value._vertexFormat, array, startingIndex);
startingIndex += VertexFormat_default.packedLength;
array[startingIndex++] = value._granularity;
array[startingIndex++] = value._surfaceHeight;
array[startingIndex++] = value._rotation;
array[startingIndex++] = value._stRotation;
array[startingIndex++] = value._extrudedHeight;
array[startingIndex++] = value._shadowVolume ? 1 : 0;
array[startingIndex] = defaultValue_default(value._offsetAttribute, -1);
return array;
};
var scratchRectangle = new Rectangle_default();
var scratchEllipsoid11 = Ellipsoid_default.clone(Ellipsoid_default.UNIT_SPHERE);
var scratchOptions19 = {
rectangle: scratchRectangle,
ellipsoid: scratchEllipsoid11,
vertexFormat: scratchVertexFormat12,
granularity: void 0,
height: void 0,
rotation: void 0,
stRotation: void 0,
extrudedHeight: void 0,
shadowVolume: void 0,
offsetAttribute: void 0
};
RectangleGeometry.unpack = function(array, startingIndex, result) {
Check_default.defined("array", array);
startingIndex = defaultValue_default(startingIndex, 0);
const rectangle = Rectangle_default.unpack(array, startingIndex, scratchRectangle);
startingIndex += Rectangle_default.packedLength;
const ellipsoid = Ellipsoid_default.unpack(array, startingIndex, scratchEllipsoid11);
startingIndex += Ellipsoid_default.packedLength;
const vertexFormat = VertexFormat_default.unpack(
array,
startingIndex,
scratchVertexFormat12
);
startingIndex += VertexFormat_default.packedLength;
const granularity = array[startingIndex++];
const surfaceHeight = array[startingIndex++];
const rotation = array[startingIndex++];
const stRotation = array[startingIndex++];
const extrudedHeight = array[startingIndex++];
const shadowVolume = array[startingIndex++] === 1;
const offsetAttribute = array[startingIndex];
if (!defined_default(result)) {
scratchOptions19.granularity = granularity;
scratchOptions19.height = surfaceHeight;
scratchOptions19.rotation = rotation;
scratchOptions19.stRotation = stRotation;
scratchOptions19.extrudedHeight = extrudedHeight;
scratchOptions19.shadowVolume = shadowVolume;
scratchOptions19.offsetAttribute = offsetAttribute === -1 ? void 0 : offsetAttribute;
return new RectangleGeometry(scratchOptions19);
}
result._rectangle = Rectangle_default.clone(rectangle, result._rectangle);
result._ellipsoid = Ellipsoid_default.clone(ellipsoid, result._ellipsoid);
result._vertexFormat = VertexFormat_default.clone(vertexFormat, result._vertexFormat);
result._granularity = granularity;
result._surfaceHeight = surfaceHeight;
result._rotation = rotation;
result._stRotation = stRotation;
result._extrudedHeight = extrudedHeight;
result._shadowVolume = shadowVolume;
result._offsetAttribute = offsetAttribute === -1 ? void 0 : offsetAttribute;
return result;
};
RectangleGeometry.computeRectangle = function(options, result) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
const rectangle = options.rectangle;
Check_default.typeOf.object("rectangle", rectangle);
Rectangle_default.validate(rectangle);
if (rectangle.north < rectangle.south) {
throw new DeveloperError_default(
"options.rectangle.north must be greater than or equal to options.rectangle.south"
);
}
const granularity = defaultValue_default(
options.granularity,
Math_default.RADIANS_PER_DEGREE
);
const ellipsoid = defaultValue_default(options.ellipsoid, Ellipsoid_default.WGS84);
const rotation = defaultValue_default(options.rotation, 0);
return computeRectangle4(rectangle, granularity, rotation, ellipsoid, result);
};
var tangentRotationMatrixScratch = new Matrix3_default();
var quaternionScratch4 = new Quaternion_default();
var centerScratch4 = new Cartographic_default();
RectangleGeometry.createGeometry = function(rectangleGeometry) {
if (Math_default.equalsEpsilon(
rectangleGeometry._rectangle.north,
rectangleGeometry._rectangle.south,
Math_default.EPSILON10
) || Math_default.equalsEpsilon(
rectangleGeometry._rectangle.east,
rectangleGeometry._rectangle.west,
Math_default.EPSILON10
)) {
return void 0;
}
let rectangle = rectangleGeometry._rectangle;
const ellipsoid = rectangleGeometry._ellipsoid;
const rotation = rectangleGeometry._rotation;
const stRotation = rectangleGeometry._stRotation;
const vertexFormat = rectangleGeometry._vertexFormat;
const computedOptions = RectangleGeometryLibrary_default.computeOptions(
rectangle,
rectangleGeometry._granularity,
rotation,
stRotation,
rectangleScratch3,
nwScratch,
stNwScratch
);
const tangentRotationMatrix = tangentRotationMatrixScratch;
if (stRotation !== 0 || rotation !== 0) {
const center = Rectangle_default.center(rectangle, centerScratch4);
const axis = ellipsoid.geodeticSurfaceNormalCartographic(center, v1Scratch);
Quaternion_default.fromAxisAngle(axis, -stRotation, quaternionScratch4);
Matrix3_default.fromQuaternion(quaternionScratch4, tangentRotationMatrix);
} else {
Matrix3_default.clone(Matrix3_default.IDENTITY, tangentRotationMatrix);
}
const surfaceHeight = rectangleGeometry._surfaceHeight;
const extrudedHeight = rectangleGeometry._extrudedHeight;
const extrude = !Math_default.equalsEpsilon(
surfaceHeight,
extrudedHeight,
0,
Math_default.EPSILON2
);
computedOptions.lonScalar = 1 / rectangleGeometry._rectangle.width;
computedOptions.latScalar = 1 / rectangleGeometry._rectangle.height;
computedOptions.tangentRotationMatrix = tangentRotationMatrix;
let geometry;
let boundingSphere;
rectangle = rectangleGeometry._rectangle;
if (extrude) {
geometry = constructExtrudedRectangle(rectangleGeometry, computedOptions);
const topBS = BoundingSphere_default.fromRectangle3D(
rectangle,
ellipsoid,
surfaceHeight,
topBoundingSphere3
);
const bottomBS = BoundingSphere_default.fromRectangle3D(
rectangle,
ellipsoid,
extrudedHeight,
bottomBoundingSphere3
);
boundingSphere = BoundingSphere_default.union(topBS, bottomBS);
} else {
geometry = constructRectangle(rectangleGeometry, computedOptions);
geometry.attributes.position.values = PolygonPipeline_default.scaleToGeodeticHeight(
geometry.attributes.position.values,
surfaceHeight,
ellipsoid,
false
);
if (defined_default(rectangleGeometry._offsetAttribute)) {
const length3 = geometry.attributes.position.values.length;
const offsetValue = rectangleGeometry._offsetAttribute === GeometryOffsetAttribute_default.NONE ? 0 : 1;
const applyOffset = new Uint8Array(length3 / 3).fill(offsetValue);
geometry.attributes.applyOffset = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.UNSIGNED_BYTE,
componentsPerAttribute: 1,
values: applyOffset
});
}
boundingSphere = BoundingSphere_default.fromRectangle3D(
rectangle,
ellipsoid,
surfaceHeight
);
}
if (!vertexFormat.position) {
delete geometry.attributes.position;
}
return new Geometry_default({
attributes: geometry.attributes,
indices: geometry.indices,
primitiveType: geometry.primitiveType,
boundingSphere,
offsetAttribute: rectangleGeometry._offsetAttribute
});
};
RectangleGeometry.createShadowVolume = function(rectangleGeometry, minHeightFunc, maxHeightFunc) {
const granularity = rectangleGeometry._granularity;
const ellipsoid = rectangleGeometry._ellipsoid;
const minHeight = minHeightFunc(granularity, ellipsoid);
const maxHeight = maxHeightFunc(granularity, ellipsoid);
return new RectangleGeometry({
rectangle: rectangleGeometry._rectangle,
rotation: rectangleGeometry._rotation,
ellipsoid,
stRotation: rectangleGeometry._stRotation,
granularity,
extrudedHeight: maxHeight,
height: minHeight,
vertexFormat: VertexFormat_default.POSITION_ONLY,
shadowVolume: true
});
};
var unrotatedTextureRectangleScratch = new Rectangle_default();
var points2DScratch2 = [new Cartesian2_default(), new Cartesian2_default(), new Cartesian2_default()];
var rotation2DScratch2 = new Matrix2_default();
var rectangleCenterScratch2 = new Cartographic_default();
function textureCoordinateRotationPoints3(rectangleGeometry) {
if (rectangleGeometry._stRotation === 0) {
return [0, 0, 0, 1, 1, 0];
}
const rectangle = Rectangle_default.clone(
rectangleGeometry._rectangle,
unrotatedTextureRectangleScratch
);
const granularity = rectangleGeometry._granularity;
const ellipsoid = rectangleGeometry._ellipsoid;
const rotation = rectangleGeometry._rotation - rectangleGeometry._stRotation;
const unrotatedTextureRectangle = computeRectangle4(
rectangle,
granularity,
rotation,
ellipsoid,
unrotatedTextureRectangleScratch
);
const points2D = points2DScratch2;
points2D[0].x = unrotatedTextureRectangle.west;
points2D[0].y = unrotatedTextureRectangle.south;
points2D[1].x = unrotatedTextureRectangle.west;
points2D[1].y = unrotatedTextureRectangle.north;
points2D[2].x = unrotatedTextureRectangle.east;
points2D[2].y = unrotatedTextureRectangle.south;
const boundingRectangle = rectangleGeometry.rectangle;
const toDesiredInComputed = Matrix2_default.fromRotation(
rectangleGeometry._stRotation,
rotation2DScratch2
);
const boundingRectangleCenter = Rectangle_default.center(
boundingRectangle,
rectangleCenterScratch2
);
for (let i = 0; i < 3; ++i) {
const point2D = points2D[i];
point2D.x -= boundingRectangleCenter.longitude;
point2D.y -= boundingRectangleCenter.latitude;
Matrix2_default.multiplyByVector(toDesiredInComputed, point2D, point2D);
point2D.x += boundingRectangleCenter.longitude;
point2D.y += boundingRectangleCenter.latitude;
point2D.x = (point2D.x - boundingRectangle.west) / boundingRectangle.width;
point2D.y = (point2D.y - boundingRectangle.south) / boundingRectangle.height;
}
const minXYCorner = points2D[0];
const maxYCorner = points2D[1];
const maxXCorner = points2D[2];
const result = new Array(6);
Cartesian2_default.pack(minXYCorner, result);
Cartesian2_default.pack(maxYCorner, result, 2);
Cartesian2_default.pack(maxXCorner, result, 4);
return result;
}
Object.defineProperties(RectangleGeometry.prototype, {
rectangle: {
get: function() {
if (!defined_default(this._rotatedRectangle)) {
this._rotatedRectangle = computeRectangle4(
this._rectangle,
this._granularity,
this._rotation,
this._ellipsoid
);
}
return this._rotatedRectangle;
}
},
textureCoordinateRotationPoints: {
get: function() {
if (!defined_default(this._textureCoordinateRotationPoints)) {
this._textureCoordinateRotationPoints = textureCoordinateRotationPoints3(
this
);
}
return this._textureCoordinateRotationPoints;
}
}
});
var RectangleGeometry_default = RectangleGeometry;
// Source/Core/RectangleOutlineGeometry.js
var bottomBoundingSphere4 = new BoundingSphere_default();
var topBoundingSphere4 = new BoundingSphere_default();
var positionScratch4 = new Cartesian3_default();
var rectangleScratch4 = new Rectangle_default();
function constructRectangle2(geometry, computedOptions) {
const ellipsoid = geometry._ellipsoid;
const height = computedOptions.height;
const width = computedOptions.width;
const northCap = computedOptions.northCap;
const southCap = computedOptions.southCap;
let rowHeight = height;
let widthMultiplier = 2;
let size = 0;
let corners = 4;
if (northCap) {
widthMultiplier -= 1;
rowHeight -= 1;
size += 1;
corners -= 2;
}
if (southCap) {
widthMultiplier -= 1;
rowHeight -= 1;
size += 1;
corners -= 2;
}
size += widthMultiplier * width + 2 * rowHeight - corners;
const positions = new Float64Array(size * 3);
let posIndex = 0;
let row = 0;
let col;
const position = positionScratch4;
if (northCap) {
RectangleGeometryLibrary_default.computePosition(
computedOptions,
ellipsoid,
false,
row,
0,
position
);
positions[posIndex++] = position.x;
positions[posIndex++] = position.y;
positions[posIndex++] = position.z;
} else {
for (col = 0; col < width; col++) {
RectangleGeometryLibrary_default.computePosition(
computedOptions,
ellipsoid,
false,
row,
col,
position
);
positions[posIndex++] = position.x;
positions[posIndex++] = position.y;
positions[posIndex++] = position.z;
}
}
col = width - 1;
for (row = 1; row < height; row++) {
RectangleGeometryLibrary_default.computePosition(
computedOptions,
ellipsoid,
false,
row,
col,
position
);
positions[posIndex++] = position.x;
positions[posIndex++] = position.y;
positions[posIndex++] = position.z;
}
row = height - 1;
if (!southCap) {
for (col = width - 2; col >= 0; col--) {
RectangleGeometryLibrary_default.computePosition(
computedOptions,
ellipsoid,
false,
row,
col,
position
);
positions[posIndex++] = position.x;
positions[posIndex++] = position.y;
positions[posIndex++] = position.z;
}
}
col = 0;
for (row = height - 2; row > 0; row--) {
RectangleGeometryLibrary_default.computePosition(
computedOptions,
ellipsoid,
false,
row,
col,
position
);
positions[posIndex++] = position.x;
positions[posIndex++] = position.y;
positions[posIndex++] = position.z;
}
const indicesSize = positions.length / 3 * 2;
const indices2 = IndexDatatype_default.createTypedArray(
positions.length / 3,
indicesSize
);
let index = 0;
for (let i = 0; i < positions.length / 3 - 1; i++) {
indices2[index++] = i;
indices2[index++] = i + 1;
}
indices2[index++] = positions.length / 3 - 1;
indices2[index++] = 0;
const geo = new Geometry_default({
attributes: new GeometryAttributes_default(),
primitiveType: PrimitiveType_default.LINES
});
geo.attributes.position = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.DOUBLE,
componentsPerAttribute: 3,
values: positions
});
geo.indices = indices2;
return geo;
}
function constructExtrudedRectangle2(rectangleGeometry, computedOptions) {
const surfaceHeight = rectangleGeometry._surfaceHeight;
const extrudedHeight = rectangleGeometry._extrudedHeight;
const ellipsoid = rectangleGeometry._ellipsoid;
const minHeight = extrudedHeight;
const maxHeight = surfaceHeight;
const geo = constructRectangle2(rectangleGeometry, computedOptions);
const height = computedOptions.height;
const width = computedOptions.width;
const topPositions = PolygonPipeline_default.scaleToGeodeticHeight(
geo.attributes.position.values,
maxHeight,
ellipsoid,
false
);
let length3 = topPositions.length;
const positions = new Float64Array(length3 * 2);
positions.set(topPositions);
const bottomPositions = PolygonPipeline_default.scaleToGeodeticHeight(
geo.attributes.position.values,
minHeight,
ellipsoid
);
positions.set(bottomPositions, length3);
geo.attributes.position.values = positions;
const northCap = computedOptions.northCap;
const southCap = computedOptions.southCap;
let corners = 4;
if (northCap) {
corners -= 1;
}
if (southCap) {
corners -= 1;
}
const indicesSize = (positions.length / 3 + corners) * 2;
const indices2 = IndexDatatype_default.createTypedArray(
positions.length / 3,
indicesSize
);
length3 = positions.length / 6;
let index = 0;
for (let i = 0; i < length3 - 1; i++) {
indices2[index++] = i;
indices2[index++] = i + 1;
indices2[index++] = i + length3;
indices2[index++] = i + length3 + 1;
}
indices2[index++] = length3 - 1;
indices2[index++] = 0;
indices2[index++] = length3 + length3 - 1;
indices2[index++] = length3;
indices2[index++] = 0;
indices2[index++] = length3;
let bottomCorner;
if (northCap) {
bottomCorner = height - 1;
} else {
const topRightCorner = width - 1;
indices2[index++] = topRightCorner;
indices2[index++] = topRightCorner + length3;
bottomCorner = width + height - 2;
}
indices2[index++] = bottomCorner;
indices2[index++] = bottomCorner + length3;
if (!southCap) {
const bottomLeftCorner = width + bottomCorner - 1;
indices2[index++] = bottomLeftCorner;
indices2[index] = bottomLeftCorner + length3;
}
geo.indices = indices2;
return geo;
}
function RectangleOutlineGeometry(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
const rectangle = options.rectangle;
const granularity = defaultValue_default(
options.granularity,
Math_default.RADIANS_PER_DEGREE
);
const ellipsoid = defaultValue_default(options.ellipsoid, Ellipsoid_default.WGS84);
const rotation = defaultValue_default(options.rotation, 0);
if (!defined_default(rectangle)) {
throw new DeveloperError_default("rectangle is required.");
}
Rectangle_default.validate(rectangle);
if (rectangle.north < rectangle.south) {
throw new DeveloperError_default(
"options.rectangle.north must be greater than options.rectangle.south"
);
}
const height = defaultValue_default(options.height, 0);
const extrudedHeight = defaultValue_default(options.extrudedHeight, height);
this._rectangle = Rectangle_default.clone(rectangle);
this._granularity = granularity;
this._ellipsoid = ellipsoid;
this._surfaceHeight = Math.max(height, extrudedHeight);
this._rotation = rotation;
this._extrudedHeight = Math.min(height, extrudedHeight);
this._offsetAttribute = options.offsetAttribute;
this._workerName = "createRectangleOutlineGeometry";
}
RectangleOutlineGeometry.packedLength = Rectangle_default.packedLength + Ellipsoid_default.packedLength + 5;
RectangleOutlineGeometry.pack = function(value, array, startingIndex) {
if (!defined_default(value)) {
throw new DeveloperError_default("value is required");
}
if (!defined_default(array)) {
throw new DeveloperError_default("array is required");
}
startingIndex = defaultValue_default(startingIndex, 0);
Rectangle_default.pack(value._rectangle, array, startingIndex);
startingIndex += Rectangle_default.packedLength;
Ellipsoid_default.pack(value._ellipsoid, array, startingIndex);
startingIndex += Ellipsoid_default.packedLength;
array[startingIndex++] = value._granularity;
array[startingIndex++] = value._surfaceHeight;
array[startingIndex++] = value._rotation;
array[startingIndex++] = value._extrudedHeight;
array[startingIndex] = defaultValue_default(value._offsetAttribute, -1);
return array;
};
var scratchRectangle2 = new Rectangle_default();
var scratchEllipsoid12 = Ellipsoid_default.clone(Ellipsoid_default.UNIT_SPHERE);
var scratchOptions20 = {
rectangle: scratchRectangle2,
ellipsoid: scratchEllipsoid12,
granularity: void 0,
height: void 0,
rotation: void 0,
extrudedHeight: void 0,
offsetAttribute: void 0
};
RectangleOutlineGeometry.unpack = function(array, startingIndex, result) {
if (!defined_default(array)) {
throw new DeveloperError_default("array is required");
}
startingIndex = defaultValue_default(startingIndex, 0);
const rectangle = Rectangle_default.unpack(array, startingIndex, scratchRectangle2);
startingIndex += Rectangle_default.packedLength;
const ellipsoid = Ellipsoid_default.unpack(array, startingIndex, scratchEllipsoid12);
startingIndex += Ellipsoid_default.packedLength;
const granularity = array[startingIndex++];
const height = array[startingIndex++];
const rotation = array[startingIndex++];
const extrudedHeight = array[startingIndex++];
const offsetAttribute = array[startingIndex];
if (!defined_default(result)) {
scratchOptions20.granularity = granularity;
scratchOptions20.height = height;
scratchOptions20.rotation = rotation;
scratchOptions20.extrudedHeight = extrudedHeight;
scratchOptions20.offsetAttribute = offsetAttribute === -1 ? void 0 : offsetAttribute;
return new RectangleOutlineGeometry(scratchOptions20);
}
result._rectangle = Rectangle_default.clone(rectangle, result._rectangle);
result._ellipsoid = Ellipsoid_default.clone(ellipsoid, result._ellipsoid);
result._surfaceHeight = height;
result._rotation = rotation;
result._extrudedHeight = extrudedHeight;
result._offsetAttribute = offsetAttribute === -1 ? void 0 : offsetAttribute;
return result;
};
var nwScratch2 = new Cartographic_default();
RectangleOutlineGeometry.createGeometry = function(rectangleGeometry) {
const rectangle = rectangleGeometry._rectangle;
const ellipsoid = rectangleGeometry._ellipsoid;
const computedOptions = RectangleGeometryLibrary_default.computeOptions(
rectangle,
rectangleGeometry._granularity,
rectangleGeometry._rotation,
0,
rectangleScratch4,
nwScratch2
);
let geometry;
let boundingSphere;
if (Math_default.equalsEpsilon(
rectangle.north,
rectangle.south,
Math_default.EPSILON10
) || Math_default.equalsEpsilon(
rectangle.east,
rectangle.west,
Math_default.EPSILON10
)) {
return void 0;
}
const surfaceHeight = rectangleGeometry._surfaceHeight;
const extrudedHeight = rectangleGeometry._extrudedHeight;
const extrude = !Math_default.equalsEpsilon(
surfaceHeight,
extrudedHeight,
0,
Math_default.EPSILON2
);
let offsetValue;
if (extrude) {
geometry = constructExtrudedRectangle2(rectangleGeometry, computedOptions);
if (defined_default(rectangleGeometry._offsetAttribute)) {
const size = geometry.attributes.position.values.length / 3;
let offsetAttribute = new Uint8Array(size);
if (rectangleGeometry._offsetAttribute === GeometryOffsetAttribute_default.TOP) {
offsetAttribute = offsetAttribute.fill(1, 0, size / 2);
} else {
offsetValue = rectangleGeometry._offsetAttribute === GeometryOffsetAttribute_default.NONE ? 0 : 1;
offsetAttribute = offsetAttribute.fill(offsetValue);
}
geometry.attributes.applyOffset = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.UNSIGNED_BYTE,
componentsPerAttribute: 1,
values: offsetAttribute
});
}
const topBS = BoundingSphere_default.fromRectangle3D(
rectangle,
ellipsoid,
surfaceHeight,
topBoundingSphere4
);
const bottomBS = BoundingSphere_default.fromRectangle3D(
rectangle,
ellipsoid,
extrudedHeight,
bottomBoundingSphere4
);
boundingSphere = BoundingSphere_default.union(topBS, bottomBS);
} else {
geometry = constructRectangle2(rectangleGeometry, computedOptions);
geometry.attributes.position.values = PolygonPipeline_default.scaleToGeodeticHeight(
geometry.attributes.position.values,
surfaceHeight,
ellipsoid,
false
);
if (defined_default(rectangleGeometry._offsetAttribute)) {
const length3 = geometry.attributes.position.values.length;
offsetValue = rectangleGeometry._offsetAttribute === GeometryOffsetAttribute_default.NONE ? 0 : 1;
const applyOffset = new Uint8Array(length3 / 3).fill(offsetValue);
geometry.attributes.applyOffset = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.UNSIGNED_BYTE,
componentsPerAttribute: 1,
values: applyOffset
});
}
boundingSphere = BoundingSphere_default.fromRectangle3D(
rectangle,
ellipsoid,
surfaceHeight
);
}
return new Geometry_default({
attributes: geometry.attributes,
indices: geometry.indices,
primitiveType: PrimitiveType_default.LINES,
boundingSphere,
offsetAttribute: rectangleGeometry._offsetAttribute
});
};
var RectangleOutlineGeometry_default = RectangleOutlineGeometry;
// Source/Core/ReferenceFrame.js
var ReferenceFrame = {
FIXED: 0,
INERTIAL: 1
};
var ReferenceFrame_default = Object.freeze(ReferenceFrame);
// Source/Core/requestAnimationFrame.js
var implementation3;
if (typeof requestAnimationFrame !== "undefined") {
implementation3 = requestAnimationFrame;
}
(function() {
if (!defined_default(implementation3) && typeof window !== "undefined") {
const vendors = ["webkit", "moz", "ms", "o"];
let i = 0;
const len = vendors.length;
while (i < len && !defined_default(implementation3)) {
implementation3 = window[`${vendors[i]}RequestAnimationFrame`];
++i;
}
}
if (!defined_default(implementation3)) {
const msPerFrame = 1e3 / 60;
let lastFrameTime = 0;
implementation3 = function(callback) {
const currentTime = getTimestamp_default();
const delay2 = Math.max(msPerFrame - (currentTime - lastFrameTime), 0);
lastFrameTime = currentTime + delay2;
return setTimeout(function() {
callback(lastFrameTime);
}, delay2);
};
}
})();
function requestAnimationFramePolyFill(callback) {
deprecationWarning_default(
"Cesium.requestAnimationFrame",
"Cesium.requestAnimationFrame was deprecated in CesiumJS 1.96 and will be removed in 1.99. Use the native requestAnimationFrame method instead."
);
return implementation3(callback);
}
var requestAnimationFrame_default = requestAnimationFramePolyFill;
// Source/Core/resizeImageToNextPowerOfTwo.js
function resizeImageToNextPowerOfTwo(image) {
const canvas = document.createElement("canvas");
canvas.width = Math_default.nextPowerOfTwo(image.width);
canvas.height = Math_default.nextPowerOfTwo(image.height);
const canvasContext = canvas.getContext("2d");
canvasContext.drawImage(
image,
0,
0,
image.width,
image.height,
0,
0,
canvas.width,
canvas.height
);
return canvas;
}
var resizeImageToNextPowerOfTwo_default = resizeImageToNextPowerOfTwo;
// Source/Core/S2Cell.js
var S2_MAX_LEVEL = 30;
var S2_LIMIT_IJ = 1 << S2_MAX_LEVEL;
var S2_MAX_SITI = 1 << S2_MAX_LEVEL + 1 >>> 0;
var S2_POSITION_BITS = 2 * S2_MAX_LEVEL + 1;
var S2_LOOKUP_BITS = 4;
var S2_LOOKUP_POSITIONS = [];
var S2_LOOKUP_IJ = [];
var S2_POSITION_TO_IJ = [
[0, 1, 3, 2],
[0, 2, 3, 1],
[3, 2, 0, 1],
[3, 1, 0, 2]
];
var S2_SWAP_MASK = 1;
var S2_INVERT_MASK = 2;
var S2_POSITION_TO_ORIENTATION_MASK = [
S2_SWAP_MASK,
0,
0,
S2_SWAP_MASK | S2_INVERT_MASK
];
function S2Cell(cellId) {
if (!FeatureDetection_default.supportsBigInt()) {
throw new RuntimeError_default("S2 required BigInt support");
}
if (!defined_default(cellId)) {
throw new DeveloperError_default("cell ID is required.");
}
if (!S2Cell.isValidId(cellId)) {
throw new DeveloperError_default("cell ID is invalid.");
}
this._cellId = cellId;
this._level = S2Cell.getLevel(cellId);
}
S2Cell.fromToken = function(token) {
Check_default.typeOf.string("token", token);
if (!S2Cell.isValidToken(token)) {
throw new DeveloperError_default("token is invalid.");
}
return new S2Cell(S2Cell.getIdFromToken(token));
};
S2Cell.isValidId = function(cellId) {
Check_default.typeOf.bigint("cellId", cellId);
if (cellId <= 0) {
return false;
}
if (cellId >> BigInt(S2_POSITION_BITS) > 5) {
return false;
}
const lowestSetBit = cellId & ~cellId + BigInt(1);
if (!(lowestSetBit & BigInt("0x1555555555555555"))) {
return false;
}
return true;
};
S2Cell.isValidToken = function(token) {
Check_default.typeOf.string("token", token);
if (!/^[0-9a-fA-F]{1,16}$/.test(token)) {
return false;
}
return S2Cell.isValidId(S2Cell.getIdFromToken(token));
};
S2Cell.getIdFromToken = function(token) {
Check_default.typeOf.string("token", token);
return BigInt("0x" + token + "0".repeat(16 - token.length));
};
S2Cell.getTokenFromId = function(cellId) {
Check_default.typeOf.bigint("cellId", cellId);
const trailingZeroHexChars = Math.floor(countTrailingZeroBits(cellId) / 4);
const hexString = cellId.toString(16).replace(/0*$/, "");
const zeroString = Array(17 - trailingZeroHexChars - hexString.length).join(
"0"
);
return zeroString + hexString;
};
S2Cell.getLevel = function(cellId) {
Check_default.typeOf.bigint("cellId", cellId);
if (!S2Cell.isValidId(cellId)) {
throw new DeveloperError_default();
}
let lsbPosition = 0;
while (cellId !== BigInt(0)) {
if (cellId & BigInt(1)) {
break;
}
lsbPosition++;
cellId = cellId >> BigInt(1);
}
return S2_MAX_LEVEL - (lsbPosition >> 1);
};
S2Cell.prototype.getChild = function(index) {
Check_default.typeOf.number("index", index);
if (index < 0 || index > 3) {
throw new DeveloperError_default("child index must be in the range [0-3].");
}
if (this._level === 30) {
throw new DeveloperError_default("cannot get child of leaf cell.");
}
const newLsb = lsb(this._cellId) >> BigInt(2);
const childCellId = this._cellId + BigInt(2 * index + 1 - 4) * newLsb;
return new S2Cell(childCellId);
};
S2Cell.prototype.getParent = function() {
if (this._level === 0) {
throw new DeveloperError_default("cannot get parent of root cell.");
}
const newLsb = lsb(this._cellId) << BigInt(2);
return new S2Cell(this._cellId & ~newLsb + BigInt(1) | newLsb);
};
S2Cell.prototype.getParentAtLevel = function(level) {
if (this._level === 0 || level < 0 || this._level < level) {
throw new DeveloperError_default("cannot get parent at invalid level.");
}
const newLsb = lsbForLevel(level);
return new S2Cell(this._cellId & -newLsb | newLsb);
};
S2Cell.prototype.getCenter = function(ellipsoid) {
ellipsoid = defaultValue_default(ellipsoid, Ellipsoid_default.WGS84);
let center = getS2Center(this._cellId, this._level);
center = Cartesian3_default.normalize(center, center);
const cartographic2 = new Cartographic_default.fromCartesian(
center,
Ellipsoid_default.UNIT_SPHERE
);
return Cartographic_default.toCartesian(cartographic2, ellipsoid, new Cartesian3_default());
};
S2Cell.prototype.getVertex = function(index, ellipsoid) {
Check_default.typeOf.number("index", index);
if (index < 0 || index > 3) {
throw new DeveloperError_default("vertex index must be in the range [0-3].");
}
ellipsoid = defaultValue_default(ellipsoid, Ellipsoid_default.WGS84);
let vertex = getS2Vertex(this._cellId, this._level, index);
vertex = Cartesian3_default.normalize(vertex, vertex);
const cartographic2 = new Cartographic_default.fromCartesian(
vertex,
Ellipsoid_default.UNIT_SPHERE
);
return Cartographic_default.toCartesian(cartographic2, ellipsoid, new Cartesian3_default());
};
S2Cell.fromFacePositionLevel = function(face, position, level) {
Check_default.typeOf.bigint("position", position);
if (face < 0 || face > 5) {
throw new DeveloperError_default("Invalid S2 Face (must be within 0-5)");
}
if (level < 0 || level > S2_MAX_LEVEL) {
throw new DeveloperError_default("Invalid level (must be within 0-30)");
}
if (position < 0 || position >= Math.pow(4, level)) {
throw new DeveloperError_default("Invalid Hilbert position for level");
}
const faceBitString = (face < 4 ? "0" : "") + (face < 2 ? "0" : "") + face.toString(2);
const positionBitString = position.toString(2);
const positionPrefixPadding = Array(
2 * level - positionBitString.length + 1
).join("0");
const positionSuffixPadding = Array(S2_POSITION_BITS - 2 * level).join("0");
const cellId = BigInt(
`0b${faceBitString}${positionPrefixPadding}${positionBitString}1${positionSuffixPadding}`
);
return new S2Cell(cellId);
};
function getS2Center(cellId, level) {
const faceSiTi = convertCellIdToFaceSiTi(cellId, level);
return convertFaceSiTitoXYZ(faceSiTi[0], faceSiTi[1], faceSiTi[2]);
}
function getS2Vertex(cellId, level, index) {
const faceIJ = convertCellIdToFaceIJ(cellId, level);
const uv = convertIJLeveltoBoundUV([faceIJ[1], faceIJ[2]], level);
const y = index >> 1 & 1;
return convertFaceUVtoXYZ(faceIJ[0], uv[0][y ^ index & 1], uv[1][y]);
}
function convertCellIdToFaceSiTi(cellId, level) {
const faceIJ = convertCellIdToFaceIJ(cellId);
const face = faceIJ[0];
const i = faceIJ[1];
const j = faceIJ[2];
const isLeaf = level === 30;
const shouldCorrect = !isLeaf && (BigInt(i) ^ cellId >> BigInt(2)) & BigInt(1);
const correction = isLeaf ? 1 : shouldCorrect ? 2 : 0;
const si = (i << 1) + correction;
const ti = (j << 1) + correction;
return [face, si, ti];
}
function convertCellIdToFaceIJ(cellId) {
if (S2_LOOKUP_POSITIONS.length === 0) {
generateLookupTable();
}
const face = Number(cellId >> BigInt(S2_POSITION_BITS));
let bits = face & S2_SWAP_MASK;
const lookupMask = (1 << S2_LOOKUP_BITS) - 1;
let i = 0;
let j = 0;
for (let k = 7; k >= 0; k--) {
const numberOfBits = k === 7 ? S2_MAX_LEVEL - 7 * S2_LOOKUP_BITS : S2_LOOKUP_BITS;
const extractMask = (1 << 2 * numberOfBits) - 1;
bits += Number(
cellId >> BigInt(k * 2 * S2_LOOKUP_BITS + 1) & BigInt(extractMask)
) << 2;
bits = S2_LOOKUP_IJ[bits];
const offset2 = k * S2_LOOKUP_BITS;
i += bits >> S2_LOOKUP_BITS + 2 << offset2;
j += (bits >> 2 & lookupMask) << offset2;
bits &= S2_SWAP_MASK | S2_INVERT_MASK;
}
return [face, i, j];
}
function convertFaceSiTitoXYZ(face, si, ti) {
const s = convertSiTitoST(si);
const t = convertSiTitoST(ti);
const u3 = convertSTtoUV(s);
const v7 = convertSTtoUV(t);
return convertFaceUVtoXYZ(face, u3, v7);
}
function convertFaceUVtoXYZ(face, u3, v7) {
switch (face) {
case 0:
return new Cartesian3_default(1, u3, v7);
case 1:
return new Cartesian3_default(-u3, 1, v7);
case 2:
return new Cartesian3_default(-u3, -v7, 1);
case 3:
return new Cartesian3_default(-1, -v7, -u3);
case 4:
return new Cartesian3_default(v7, -1, -u3);
default:
return new Cartesian3_default(v7, u3, -1);
}
}
function convertSTtoUV(s) {
if (s >= 0.5) {
return 1 / 3 * (4 * s * s - 1);
}
return 1 / 3 * (1 - 4 * (1 - s) * (1 - s));
}
function convertSiTitoST(si) {
return 1 / S2_MAX_SITI * si;
}
function convertIJLeveltoBoundUV(ij, level) {
const result = [[], []];
const cellSize = getSizeIJ(level);
for (let d = 0; d < 2; ++d) {
const ijLow = ij[d] & -cellSize;
const ijHigh = ijLow + cellSize;
result[d][0] = convertSTtoUV(convertIJtoSTMinimum(ijLow));
result[d][1] = convertSTtoUV(convertIJtoSTMinimum(ijHigh));
}
return result;
}
function getSizeIJ(level) {
return 1 << S2_MAX_LEVEL - level >>> 0;
}
function convertIJtoSTMinimum(i) {
return 1 / S2_LIMIT_IJ * i;
}
function generateLookupCell(level, i, j, originalOrientation, position, orientation) {
if (level === S2_LOOKUP_BITS) {
const ij = (i << S2_LOOKUP_BITS) + j;
S2_LOOKUP_POSITIONS[(ij << 2) + originalOrientation] = (position << 2) + orientation;
S2_LOOKUP_IJ[(position << 2) + originalOrientation] = (ij << 2) + orientation;
} else {
level++;
i <<= 1;
j <<= 1;
position <<= 2;
const r = S2_POSITION_TO_IJ[orientation];
generateLookupCell(
level,
i + (r[0] >> 1),
j + (r[0] & 1),
originalOrientation,
position,
orientation ^ S2_POSITION_TO_ORIENTATION_MASK[0]
);
generateLookupCell(
level,
i + (r[1] >> 1),
j + (r[1] & 1),
originalOrientation,
position + 1,
orientation ^ S2_POSITION_TO_ORIENTATION_MASK[1]
);
generateLookupCell(
level,
i + (r[2] >> 1),
j + (r[2] & 1),
originalOrientation,
position + 2,
orientation ^ S2_POSITION_TO_ORIENTATION_MASK[2]
);
generateLookupCell(
level,
i + (r[3] >> 1),
j + (r[3] & 1),
originalOrientation,
position + 3,
orientation ^ S2_POSITION_TO_ORIENTATION_MASK[3]
);
}
}
function generateLookupTable() {
generateLookupCell(0, 0, 0, 0, 0, 0);
generateLookupCell(0, 0, 0, S2_SWAP_MASK, 0, S2_SWAP_MASK);
generateLookupCell(0, 0, 0, S2_INVERT_MASK, 0, S2_INVERT_MASK);
generateLookupCell(
0,
0,
0,
S2_SWAP_MASK | S2_INVERT_MASK,
0,
S2_SWAP_MASK | S2_INVERT_MASK
);
}
function lsb(cellId) {
return cellId & ~cellId + BigInt(1);
}
function lsbForLevel(level) {
return BigInt(1) << BigInt(2 * (S2_MAX_LEVEL - level));
}
var Mod67BitPosition = [
64,
0,
1,
39,
2,
15,
40,
23,
3,
12,
16,
59,
41,
19,
24,
54,
4,
64,
13,
10,
17,
62,
60,
28,
42,
30,
20,
51,
25,
44,
55,
47,
5,
32,
65,
38,
14,
22,
11,
58,
18,
53,
63,
9,
61,
27,
29,
50,
43,
46,
31,
37,
21,
57,
52,
8,
26,
49,
45,
36,
56,
7,
48,
35,
6,
34,
33,
0
];
function countTrailingZeroBits(x) {
return Mod67BitPosition[(-x & x) % BigInt(67)];
}
var S2Cell_default = S2Cell;
// Source/Core/sampleTerrain.js
function sampleTerrain(terrainProvider, level, positions) {
Check_default.typeOf.object("terrainProvider", terrainProvider);
Check_default.typeOf.number("level", level);
Check_default.defined("positions", positions);
return terrainProvider.readyPromise.then(function() {
return doSampling(terrainProvider, level, positions);
});
}
function attemptConsumeNextQueueItem(tileRequests, results) {
const tileRequest = tileRequests[0];
const requestPromise = tileRequest.terrainProvider.requestTileGeometry(
tileRequest.x,
tileRequest.y,
tileRequest.level
);
if (!requestPromise) {
return false;
}
const promise = requestPromise.then(createInterpolateFunction(tileRequest)).catch(createMarkFailedFunction(tileRequest));
tileRequests.shift();
results.push(promise);
return true;
}
function delay(ms) {
return new Promise(function(res) {
setTimeout(res, ms);
});
}
function drainTileRequestQueue(tileRequests, results) {
if (!tileRequests.length) {
return Promise.resolve();
}
const success = attemptConsumeNextQueueItem(tileRequests, results);
if (success) {
return drainTileRequestQueue(tileRequests, results);
}
return delay(100).then(() => {
return drainTileRequestQueue(tileRequests, results);
});
}
function doSampling(terrainProvider, level, positions) {
const tilingScheme2 = terrainProvider.tilingScheme;
let i;
const tileRequests = [];
const tileRequestSet = {};
for (i = 0; i < positions.length; ++i) {
const xy = tilingScheme2.positionToTileXY(positions[i], level);
const key = xy.toString();
if (!tileRequestSet.hasOwnProperty(key)) {
const value = {
x: xy.x,
y: xy.y,
level,
tilingScheme: tilingScheme2,
terrainProvider,
positions: []
};
tileRequestSet[key] = value;
tileRequests.push(value);
}
tileRequestSet[key].positions.push(positions[i]);
}
const tilePromises = [];
return drainTileRequestQueue(tileRequests, tilePromises).then(function() {
return Promise.all(tilePromises).then(function() {
return positions;
});
});
}
function interpolateAndAssignHeight(position, terrainData, rectangle) {
const height = terrainData.interpolateHeight(
rectangle,
position.longitude,
position.latitude
);
if (height === void 0) {
return false;
}
position.height = height;
return true;
}
function createInterpolateFunction(tileRequest) {
const tilePositions = tileRequest.positions;
const rectangle = tileRequest.tilingScheme.tileXYToRectangle(
tileRequest.x,
tileRequest.y,
tileRequest.level
);
return function(terrainData) {
let isMeshRequired = false;
for (let i = 0; i < tilePositions.length; ++i) {
const position = tilePositions[i];
const isHeightAssigned = interpolateAndAssignHeight(
position,
terrainData,
rectangle
);
if (!isHeightAssigned) {
isMeshRequired = true;
break;
}
}
if (!isMeshRequired) {
return Promise.resolve();
}
return terrainData.createMesh({
tilingScheme: tileRequest.tilingScheme,
x: tileRequest.x,
y: tileRequest.y,
level: tileRequest.level,
throttle: false
}).then(function() {
for (let i = 0; i < tilePositions.length; ++i) {
const position = tilePositions[i];
interpolateAndAssignHeight(position, terrainData, rectangle);
}
});
};
}
function createMarkFailedFunction(tileRequest) {
const tilePositions = tileRequest.positions;
return function() {
for (let i = 0; i < tilePositions.length; ++i) {
const position = tilePositions[i];
position.height = void 0;
}
};
}
var sampleTerrain_default = sampleTerrain;
// Source/Core/sampleTerrainMostDetailed.js
var scratchCartesian29 = new Cartesian2_default();
function sampleTerrainMostDetailed(terrainProvider, positions) {
if (!defined_default(terrainProvider)) {
throw new DeveloperError_default("terrainProvider is required.");
}
if (!defined_default(positions)) {
throw new DeveloperError_default("positions is required.");
}
return terrainProvider.readyPromise.then(function() {
const byLevel = [];
const maxLevels = [];
const availability = terrainProvider.availability;
if (!defined_default(availability)) {
throw new DeveloperError_default(
"sampleTerrainMostDetailed requires a terrain provider that has tile availability."
);
}
const promises = [];
for (let i = 0; i < positions.length; ++i) {
const position = positions[i];
const maxLevel = availability.computeMaximumLevelAtPosition(position);
maxLevels[i] = maxLevel;
if (maxLevel === 0) {
terrainProvider.tilingScheme.positionToTileXY(
position,
1,
scratchCartesian29
);
const promise = terrainProvider.loadTileDataAvailability(
scratchCartesian29.x,
scratchCartesian29.y,
1
);
if (defined_default(promise)) {
promises.push(promise);
}
}
let atLevel = byLevel[maxLevel];
if (!defined_default(atLevel)) {
byLevel[maxLevel] = atLevel = [];
}
atLevel.push(position);
}
return Promise.all(promises).then(function() {
return Promise.all(
byLevel.map(function(positionsAtLevel, index) {
if (defined_default(positionsAtLevel)) {
return sampleTerrain_default(terrainProvider, index, positionsAtLevel);
}
})
);
}).then(function() {
const changedPositions = [];
for (let i = 0; i < positions.length; ++i) {
const position = positions[i];
const maxLevel = availability.computeMaximumLevelAtPosition(position);
if (maxLevel !== maxLevels[i]) {
changedPositions.push(position);
}
}
if (changedPositions.length > 0) {
return sampleTerrainMostDetailed(terrainProvider, changedPositions);
}
}).then(function() {
return positions;
});
});
}
var sampleTerrainMostDetailed_default = sampleTerrainMostDetailed;
// Source/Core/ScreenSpaceEventType.js
var ScreenSpaceEventType = {
LEFT_DOWN: 0,
LEFT_UP: 1,
LEFT_CLICK: 2,
LEFT_DOUBLE_CLICK: 3,
RIGHT_DOWN: 5,
RIGHT_UP: 6,
RIGHT_CLICK: 7,
MIDDLE_DOWN: 10,
MIDDLE_UP: 11,
MIDDLE_CLICK: 12,
MOUSE_MOVE: 15,
WHEEL: 16,
PINCH_START: 17,
PINCH_END: 18,
PINCH_MOVE: 19
};
var ScreenSpaceEventType_default = Object.freeze(ScreenSpaceEventType);
// Source/Core/ScreenSpaceEventHandler.js
function getPosition2(screenSpaceEventHandler, event, result) {
const element = screenSpaceEventHandler._element;
if (element === document) {
result.x = event.clientX;
result.y = event.clientY;
return result;
}
const rect = element.getBoundingClientRect();
result.x = event.clientX - rect.left;
result.y = event.clientY - rect.top;
return result;
}
function getInputEventKey(type, modifier) {
let key = type;
if (defined_default(modifier)) {
key += `+${modifier}`;
}
return key;
}
function getModifier(event) {
if (event.shiftKey) {
return KeyboardEventModifier_default.SHIFT;
} else if (event.ctrlKey) {
return KeyboardEventModifier_default.CTRL;
} else if (event.altKey) {
return KeyboardEventModifier_default.ALT;
}
return void 0;
}
var MouseButton = {
LEFT: 0,
MIDDLE: 1,
RIGHT: 2
};
function registerListener(screenSpaceEventHandler, domType, element, callback) {
function listener(e) {
callback(screenSpaceEventHandler, e);
}
if (FeatureDetection_default.isInternetExplorer()) {
element.addEventListener(domType, listener, false);
} else {
element.addEventListener(domType, listener, {
capture: false,
passive: false
});
}
screenSpaceEventHandler._removalFunctions.push(function() {
element.removeEventListener(domType, listener, false);
});
}
function registerListeners(screenSpaceEventHandler) {
const element = screenSpaceEventHandler._element;
const alternateElement = !defined_default(element.disableRootEvents) ? document : element;
if (FeatureDetection_default.supportsPointerEvents()) {
registerListener(
screenSpaceEventHandler,
"pointerdown",
element,
handlePointerDown
);
registerListener(
screenSpaceEventHandler,
"pointerup",
element,
handlePointerUp
);
registerListener(
screenSpaceEventHandler,
"pointermove",
element,
handlePointerMove
);
registerListener(
screenSpaceEventHandler,
"pointercancel",
element,
handlePointerUp
);
} else {
registerListener(
screenSpaceEventHandler,
"mousedown",
element,
handleMouseDown
);
registerListener(
screenSpaceEventHandler,
"mouseup",
alternateElement,
handleMouseUp
);
registerListener(
screenSpaceEventHandler,
"mousemove",
alternateElement,
handleMouseMove
);
registerListener(
screenSpaceEventHandler,
"touchstart",
element,
handleTouchStart
);
registerListener(
screenSpaceEventHandler,
"touchend",
alternateElement,
handleTouchEnd
);
registerListener(
screenSpaceEventHandler,
"touchmove",
alternateElement,
handleTouchMove
);
registerListener(
screenSpaceEventHandler,
"touchcancel",
alternateElement,
handleTouchEnd
);
}
registerListener(
screenSpaceEventHandler,
"dblclick",
element,
handleDblClick
);
let wheelEvent;
if ("onwheel" in element) {
wheelEvent = "wheel";
} else if (document.onmousewheel !== void 0) {
wheelEvent = "mousewheel";
} else {
wheelEvent = "DOMMouseScroll";
}
registerListener(screenSpaceEventHandler, wheelEvent, element, handleWheel);
}
function unregisterListeners(screenSpaceEventHandler) {
const removalFunctions = screenSpaceEventHandler._removalFunctions;
for (let i = 0; i < removalFunctions.length; ++i) {
removalFunctions[i]();
}
}
var mouseDownEvent = {
position: new Cartesian2_default()
};
function gotTouchEvent(screenSpaceEventHandler) {
screenSpaceEventHandler._lastSeenTouchEvent = getTimestamp_default();
}
function canProcessMouseEvent(screenSpaceEventHandler) {
return getTimestamp_default() - screenSpaceEventHandler._lastSeenTouchEvent > ScreenSpaceEventHandler.mouseEmulationIgnoreMilliseconds;
}
function checkPixelTolerance(startPosition, endPosition, pixelTolerance) {
const xDiff = startPosition.x - endPosition.x;
const yDiff = startPosition.y - endPosition.y;
const totalPixels = Math.sqrt(xDiff * xDiff + yDiff * yDiff);
return totalPixels < pixelTolerance;
}
function handleMouseDown(screenSpaceEventHandler, event) {
if (!canProcessMouseEvent(screenSpaceEventHandler)) {
return;
}
const button = event.button;
screenSpaceEventHandler._buttonDown[button] = true;
let screenSpaceEventType;
if (button === MouseButton.LEFT) {
screenSpaceEventType = ScreenSpaceEventType_default.LEFT_DOWN;
} else if (button === MouseButton.MIDDLE) {
screenSpaceEventType = ScreenSpaceEventType_default.MIDDLE_DOWN;
} else if (button === MouseButton.RIGHT) {
screenSpaceEventType = ScreenSpaceEventType_default.RIGHT_DOWN;
} else {
return;
}
const position = getPosition2(
screenSpaceEventHandler,
event,
screenSpaceEventHandler._primaryPosition
);
Cartesian2_default.clone(position, screenSpaceEventHandler._primaryStartPosition);
Cartesian2_default.clone(position, screenSpaceEventHandler._primaryPreviousPosition);
const modifier = getModifier(event);
const action = screenSpaceEventHandler.getInputAction(
screenSpaceEventType,
modifier
);
if (defined_default(action)) {
Cartesian2_default.clone(position, mouseDownEvent.position);
action(mouseDownEvent);
event.preventDefault();
}
}
var mouseUpEvent = {
position: new Cartesian2_default()
};
var mouseClickEvent = {
position: new Cartesian2_default()
};
function cancelMouseEvent(screenSpaceEventHandler, screenSpaceEventType, clickScreenSpaceEventType, event) {
const modifier = getModifier(event);
const action = screenSpaceEventHandler.getInputAction(
screenSpaceEventType,
modifier
);
const clickAction = screenSpaceEventHandler.getInputAction(
clickScreenSpaceEventType,
modifier
);
if (defined_default(action) || defined_default(clickAction)) {
const position = getPosition2(
screenSpaceEventHandler,
event,
screenSpaceEventHandler._primaryPosition
);
if (defined_default(action)) {
Cartesian2_default.clone(position, mouseUpEvent.position);
action(mouseUpEvent);
}
if (defined_default(clickAction)) {
const startPosition = screenSpaceEventHandler._primaryStartPosition;
if (checkPixelTolerance(
startPosition,
position,
screenSpaceEventHandler._clickPixelTolerance
)) {
Cartesian2_default.clone(position, mouseClickEvent.position);
clickAction(mouseClickEvent);
}
}
}
}
function handleMouseUp(screenSpaceEventHandler, event) {
if (!canProcessMouseEvent(screenSpaceEventHandler)) {
return;
}
const button = event.button;
if (button !== MouseButton.LEFT && button !== MouseButton.MIDDLE && button !== MouseButton.RIGHT) {
return;
}
if (screenSpaceEventHandler._buttonDown[MouseButton.LEFT]) {
cancelMouseEvent(
screenSpaceEventHandler,
ScreenSpaceEventType_default.LEFT_UP,
ScreenSpaceEventType_default.LEFT_CLICK,
event
);
screenSpaceEventHandler._buttonDown[MouseButton.LEFT] = false;
}
if (screenSpaceEventHandler._buttonDown[MouseButton.MIDDLE]) {
cancelMouseEvent(
screenSpaceEventHandler,
ScreenSpaceEventType_default.MIDDLE_UP,
ScreenSpaceEventType_default.MIDDLE_CLICK,
event
);
screenSpaceEventHandler._buttonDown[MouseButton.MIDDLE] = false;
}
if (screenSpaceEventHandler._buttonDown[MouseButton.RIGHT]) {
cancelMouseEvent(
screenSpaceEventHandler,
ScreenSpaceEventType_default.RIGHT_UP,
ScreenSpaceEventType_default.RIGHT_CLICK,
event
);
screenSpaceEventHandler._buttonDown[MouseButton.RIGHT] = false;
}
}
var mouseMoveEvent = {
startPosition: new Cartesian2_default(),
endPosition: new Cartesian2_default()
};
function handleMouseMove(screenSpaceEventHandler, event) {
if (!canProcessMouseEvent(screenSpaceEventHandler)) {
return;
}
const modifier = getModifier(event);
const position = getPosition2(
screenSpaceEventHandler,
event,
screenSpaceEventHandler._primaryPosition
);
const previousPosition = screenSpaceEventHandler._primaryPreviousPosition;
const action = screenSpaceEventHandler.getInputAction(
ScreenSpaceEventType_default.MOUSE_MOVE,
modifier
);
if (defined_default(action)) {
Cartesian2_default.clone(previousPosition, mouseMoveEvent.startPosition);
Cartesian2_default.clone(position, mouseMoveEvent.endPosition);
action(mouseMoveEvent);
}
Cartesian2_default.clone(position, previousPosition);
if (screenSpaceEventHandler._buttonDown[MouseButton.LEFT] || screenSpaceEventHandler._buttonDown[MouseButton.MIDDLE] || screenSpaceEventHandler._buttonDown[MouseButton.RIGHT]) {
event.preventDefault();
}
}
var mouseDblClickEvent = {
position: new Cartesian2_default()
};
function handleDblClick(screenSpaceEventHandler, event) {
const button = event.button;
let screenSpaceEventType;
if (button === MouseButton.LEFT) {
screenSpaceEventType = ScreenSpaceEventType_default.LEFT_DOUBLE_CLICK;
} else {
return;
}
const modifier = getModifier(event);
const action = screenSpaceEventHandler.getInputAction(
screenSpaceEventType,
modifier
);
if (defined_default(action)) {
getPosition2(screenSpaceEventHandler, event, mouseDblClickEvent.position);
action(mouseDblClickEvent);
}
}
function handleWheel(screenSpaceEventHandler, event) {
let delta;
if (defined_default(event.deltaY)) {
const deltaMode = event.deltaMode;
if (deltaMode === event.DOM_DELTA_PIXEL) {
delta = -event.deltaY;
} else if (deltaMode === event.DOM_DELTA_LINE) {
delta = -event.deltaY * 40;
} else {
delta = -event.deltaY * 120;
}
} else if (event.detail > 0) {
delta = event.detail * -120;
} else {
delta = event.wheelDelta;
}
if (!defined_default(delta)) {
return;
}
const modifier = getModifier(event);
const action = screenSpaceEventHandler.getInputAction(
ScreenSpaceEventType_default.WHEEL,
modifier
);
if (defined_default(action)) {
action(delta);
event.preventDefault();
}
}
function handleTouchStart(screenSpaceEventHandler, event) {
gotTouchEvent(screenSpaceEventHandler);
const changedTouches = event.changedTouches;
let i;
const length3 = changedTouches.length;
let touch;
let identifier;
const positions = screenSpaceEventHandler._positions;
for (i = 0; i < length3; ++i) {
touch = changedTouches[i];
identifier = touch.identifier;
positions.set(
identifier,
getPosition2(screenSpaceEventHandler, touch, new Cartesian2_default())
);
}
fireTouchEvents(screenSpaceEventHandler, event);
const previousPositions = screenSpaceEventHandler._previousPositions;
for (i = 0; i < length3; ++i) {
touch = changedTouches[i];
identifier = touch.identifier;
previousPositions.set(
identifier,
Cartesian2_default.clone(positions.get(identifier))
);
}
}
function handleTouchEnd(screenSpaceEventHandler, event) {
gotTouchEvent(screenSpaceEventHandler);
const changedTouches = event.changedTouches;
let i;
const length3 = changedTouches.length;
let touch;
let identifier;
const positions = screenSpaceEventHandler._positions;
for (i = 0; i < length3; ++i) {
touch = changedTouches[i];
identifier = touch.identifier;
positions.remove(identifier);
}
fireTouchEvents(screenSpaceEventHandler, event);
const previousPositions = screenSpaceEventHandler._previousPositions;
for (i = 0; i < length3; ++i) {
touch = changedTouches[i];
identifier = touch.identifier;
previousPositions.remove(identifier);
}
}
var touchStartEvent = {
position: new Cartesian2_default()
};
var touch2StartEvent = {
position1: new Cartesian2_default(),
position2: new Cartesian2_default()
};
var touchEndEvent = {
position: new Cartesian2_default()
};
var touchClickEvent = {
position: new Cartesian2_default()
};
var touchHoldEvent = {
position: new Cartesian2_default()
};
function fireTouchEvents(screenSpaceEventHandler, event) {
const modifier = getModifier(event);
const positions = screenSpaceEventHandler._positions;
const numberOfTouches = positions.length;
let action;
let clickAction;
const pinching = screenSpaceEventHandler._isPinching;
if (numberOfTouches !== 1 && screenSpaceEventHandler._buttonDown[MouseButton.LEFT]) {
screenSpaceEventHandler._buttonDown[MouseButton.LEFT] = false;
if (defined_default(screenSpaceEventHandler._touchHoldTimer)) {
clearTimeout(screenSpaceEventHandler._touchHoldTimer);
screenSpaceEventHandler._touchHoldTimer = void 0;
}
action = screenSpaceEventHandler.getInputAction(
ScreenSpaceEventType_default.LEFT_UP,
modifier
);
if (defined_default(action)) {
Cartesian2_default.clone(
screenSpaceEventHandler._primaryPosition,
touchEndEvent.position
);
action(touchEndEvent);
}
if (numberOfTouches === 0 && !screenSpaceEventHandler._isTouchHolding) {
clickAction = screenSpaceEventHandler.getInputAction(
ScreenSpaceEventType_default.LEFT_CLICK,
modifier
);
if (defined_default(clickAction)) {
const startPosition = screenSpaceEventHandler._primaryStartPosition;
const endPosition = screenSpaceEventHandler._previousPositions.values[0];
if (checkPixelTolerance(
startPosition,
endPosition,
screenSpaceEventHandler._clickPixelTolerance
)) {
Cartesian2_default.clone(
screenSpaceEventHandler._primaryPosition,
touchClickEvent.position
);
clickAction(touchClickEvent);
}
}
}
screenSpaceEventHandler._isTouchHolding = false;
}
if (numberOfTouches === 0 && pinching) {
screenSpaceEventHandler._isPinching = false;
action = screenSpaceEventHandler.getInputAction(
ScreenSpaceEventType_default.PINCH_END,
modifier
);
if (defined_default(action)) {
action();
}
}
if (numberOfTouches === 1 && !pinching) {
const position = positions.values[0];
Cartesian2_default.clone(position, screenSpaceEventHandler._primaryPosition);
Cartesian2_default.clone(position, screenSpaceEventHandler._primaryStartPosition);
Cartesian2_default.clone(
position,
screenSpaceEventHandler._primaryPreviousPosition
);
screenSpaceEventHandler._buttonDown[MouseButton.LEFT] = true;
action = screenSpaceEventHandler.getInputAction(
ScreenSpaceEventType_default.LEFT_DOWN,
modifier
);
if (defined_default(action)) {
Cartesian2_default.clone(position, touchStartEvent.position);
action(touchStartEvent);
}
screenSpaceEventHandler._touchHoldTimer = setTimeout(function() {
if (!screenSpaceEventHandler.isDestroyed()) {
screenSpaceEventHandler._touchHoldTimer = void 0;
screenSpaceEventHandler._isTouchHolding = true;
clickAction = screenSpaceEventHandler.getInputAction(
ScreenSpaceEventType_default.RIGHT_CLICK,
modifier
);
if (defined_default(clickAction)) {
const startPosition = screenSpaceEventHandler._primaryStartPosition;
const endPosition = screenSpaceEventHandler._previousPositions.values[0];
if (checkPixelTolerance(
startPosition,
endPosition,
screenSpaceEventHandler._holdPixelTolerance
)) {
Cartesian2_default.clone(
screenSpaceEventHandler._primaryPosition,
touchHoldEvent.position
);
clickAction(touchHoldEvent);
}
}
}
}, ScreenSpaceEventHandler.touchHoldDelayMilliseconds);
event.preventDefault();
}
if (numberOfTouches === 2 && !pinching) {
screenSpaceEventHandler._isPinching = true;
action = screenSpaceEventHandler.getInputAction(
ScreenSpaceEventType_default.PINCH_START,
modifier
);
if (defined_default(action)) {
Cartesian2_default.clone(positions.values[0], touch2StartEvent.position1);
Cartesian2_default.clone(positions.values[1], touch2StartEvent.position2);
action(touch2StartEvent);
event.preventDefault();
}
}
}
function handleTouchMove(screenSpaceEventHandler, event) {
gotTouchEvent(screenSpaceEventHandler);
const changedTouches = event.changedTouches;
let i;
const length3 = changedTouches.length;
let touch;
let identifier;
const positions = screenSpaceEventHandler._positions;
for (i = 0; i < length3; ++i) {
touch = changedTouches[i];
identifier = touch.identifier;
const position = positions.get(identifier);
if (defined_default(position)) {
getPosition2(screenSpaceEventHandler, touch, position);
}
}
fireTouchMoveEvents(screenSpaceEventHandler, event);
const previousPositions = screenSpaceEventHandler._previousPositions;
for (i = 0; i < length3; ++i) {
touch = changedTouches[i];
identifier = touch.identifier;
Cartesian2_default.clone(
positions.get(identifier),
previousPositions.get(identifier)
);
}
}
var touchMoveEvent = {
startPosition: new Cartesian2_default(),
endPosition: new Cartesian2_default()
};
var touchPinchMovementEvent = {
distance: {
startPosition: new Cartesian2_default(),
endPosition: new Cartesian2_default()
},
angleAndHeight: {
startPosition: new Cartesian2_default(),
endPosition: new Cartesian2_default()
}
};
function fireTouchMoveEvents(screenSpaceEventHandler, event) {
const modifier = getModifier(event);
const positions = screenSpaceEventHandler._positions;
const previousPositions = screenSpaceEventHandler._previousPositions;
const numberOfTouches = positions.length;
let action;
if (numberOfTouches === 1 && screenSpaceEventHandler._buttonDown[MouseButton.LEFT]) {
const position = positions.values[0];
Cartesian2_default.clone(position, screenSpaceEventHandler._primaryPosition);
const previousPosition = screenSpaceEventHandler._primaryPreviousPosition;
action = screenSpaceEventHandler.getInputAction(
ScreenSpaceEventType_default.MOUSE_MOVE,
modifier
);
if (defined_default(action)) {
Cartesian2_default.clone(previousPosition, touchMoveEvent.startPosition);
Cartesian2_default.clone(position, touchMoveEvent.endPosition);
action(touchMoveEvent);
}
Cartesian2_default.clone(position, previousPosition);
event.preventDefault();
} else if (numberOfTouches === 2 && screenSpaceEventHandler._isPinching) {
action = screenSpaceEventHandler.getInputAction(
ScreenSpaceEventType_default.PINCH_MOVE,
modifier
);
if (defined_default(action)) {
const position1 = positions.values[0];
const position2 = positions.values[1];
const previousPosition1 = previousPositions.values[0];
const previousPosition2 = previousPositions.values[1];
const dX = position2.x - position1.x;
const dY = position2.y - position1.y;
const dist = Math.sqrt(dX * dX + dY * dY) * 0.25;
const prevDX = previousPosition2.x - previousPosition1.x;
const prevDY = previousPosition2.y - previousPosition1.y;
const prevDist = Math.sqrt(prevDX * prevDX + prevDY * prevDY) * 0.25;
const cY = (position2.y + position1.y) * 0.125;
const prevCY = (previousPosition2.y + previousPosition1.y) * 0.125;
const angle = Math.atan2(dY, dX);
const prevAngle = Math.atan2(prevDY, prevDX);
Cartesian2_default.fromElements(
0,
prevDist,
touchPinchMovementEvent.distance.startPosition
);
Cartesian2_default.fromElements(
0,
dist,
touchPinchMovementEvent.distance.endPosition
);
Cartesian2_default.fromElements(
prevAngle,
prevCY,
touchPinchMovementEvent.angleAndHeight.startPosition
);
Cartesian2_default.fromElements(
angle,
cY,
touchPinchMovementEvent.angleAndHeight.endPosition
);
action(touchPinchMovementEvent);
}
}
}
function handlePointerDown(screenSpaceEventHandler, event) {
event.target.setPointerCapture(event.pointerId);
if (event.pointerType === "touch") {
const positions = screenSpaceEventHandler._positions;
const identifier = event.pointerId;
positions.set(
identifier,
getPosition2(screenSpaceEventHandler, event, new Cartesian2_default())
);
fireTouchEvents(screenSpaceEventHandler, event);
const previousPositions = screenSpaceEventHandler._previousPositions;
previousPositions.set(
identifier,
Cartesian2_default.clone(positions.get(identifier))
);
} else {
handleMouseDown(screenSpaceEventHandler, event);
}
}
function handlePointerUp(screenSpaceEventHandler, event) {
if (event.pointerType === "touch") {
const positions = screenSpaceEventHandler._positions;
const identifier = event.pointerId;
positions.remove(identifier);
fireTouchEvents(screenSpaceEventHandler, event);
const previousPositions = screenSpaceEventHandler._previousPositions;
previousPositions.remove(identifier);
} else {
handleMouseUp(screenSpaceEventHandler, event);
}
}
function handlePointerMove(screenSpaceEventHandler, event) {
if (event.pointerType === "touch") {
const positions = screenSpaceEventHandler._positions;
const identifier = event.pointerId;
const position = positions.get(identifier);
if (!defined_default(position)) {
return;
}
getPosition2(screenSpaceEventHandler, event, position);
fireTouchMoveEvents(screenSpaceEventHandler, event);
const previousPositions = screenSpaceEventHandler._previousPositions;
Cartesian2_default.clone(
positions.get(identifier),
previousPositions.get(identifier)
);
} else {
handleMouseMove(screenSpaceEventHandler, event);
}
}
function ScreenSpaceEventHandler(element) {
this._inputEvents = {};
this._buttonDown = {
LEFT: false,
MIDDLE: false,
RIGHT: false
};
this._isPinching = false;
this._isTouchHolding = false;
this._lastSeenTouchEvent = -ScreenSpaceEventHandler.mouseEmulationIgnoreMilliseconds;
this._primaryStartPosition = new Cartesian2_default();
this._primaryPosition = new Cartesian2_default();
this._primaryPreviousPosition = new Cartesian2_default();
this._positions = new AssociativeArray_default();
this._previousPositions = new AssociativeArray_default();
this._removalFunctions = [];
this._touchHoldTimer = void 0;
this._clickPixelTolerance = 5;
this._holdPixelTolerance = 25;
this._element = defaultValue_default(element, document);
registerListeners(this);
}
ScreenSpaceEventHandler.prototype.setInputAction = function(action, type, modifier) {
if (!defined_default(action)) {
throw new DeveloperError_default("action is required.");
}
if (!defined_default(type)) {
throw new DeveloperError_default("type is required.");
}
const key = getInputEventKey(type, modifier);
this._inputEvents[key] = action;
};
ScreenSpaceEventHandler.prototype.getInputAction = function(type, modifier) {
if (!defined_default(type)) {
throw new DeveloperError_default("type is required.");
}
const key = getInputEventKey(type, modifier);
return this._inputEvents[key];
};
ScreenSpaceEventHandler.prototype.removeInputAction = function(type, modifier) {
if (!defined_default(type)) {
throw new DeveloperError_default("type is required.");
}
const key = getInputEventKey(type, modifier);
delete this._inputEvents[key];
};
ScreenSpaceEventHandler.prototype.isDestroyed = function() {
return false;
};
ScreenSpaceEventHandler.prototype.destroy = function() {
unregisterListeners(this);
return destroyObject_default(this);
};
ScreenSpaceEventHandler.mouseEmulationIgnoreMilliseconds = 800;
ScreenSpaceEventHandler.touchHoldDelayMilliseconds = 1500;
var ScreenSpaceEventHandler_default = ScreenSpaceEventHandler;
// Source/Core/ShowGeometryInstanceAttribute.js
function ShowGeometryInstanceAttribute(show) {
show = defaultValue_default(show, true);
this.value = ShowGeometryInstanceAttribute.toValue(show);
}
Object.defineProperties(ShowGeometryInstanceAttribute.prototype, {
componentDatatype: {
get: function() {
return ComponentDatatype_default.UNSIGNED_BYTE;
}
},
componentsPerAttribute: {
get: function() {
return 1;
}
},
normalize: {
get: function() {
return false;
}
}
});
ShowGeometryInstanceAttribute.toValue = function(show, result) {
if (!defined_default(show)) {
throw new DeveloperError_default("show is required.");
}
if (!defined_default(result)) {
return new Uint8Array([show]);
}
result[0] = show;
return result;
};
var ShowGeometryInstanceAttribute_default = ShowGeometryInstanceAttribute;
// Source/Core/Simon1994PlanetaryPositions.js
var Simon1994PlanetaryPositions = {};
function computeTdbMinusTtSpice(daysSinceJ2000InTerrestrialTime) {
const g = 6.239996 + 0.0172019696544 * daysSinceJ2000InTerrestrialTime;
return 1657e-6 * Math.sin(g + 0.01671 * Math.sin(g));
}
var TdtMinusTai2 = 32.184;
var J2000d2 = 2451545;
function taiToTdb(date, result) {
result = JulianDate_default.addSeconds(date, TdtMinusTai2, result);
const days = JulianDate_default.totalDays(result) - J2000d2;
result = JulianDate_default.addSeconds(result, computeTdbMinusTtSpice(days), result);
return result;
}
var epoch = new JulianDate_default(2451545, 0, TimeStandard_default.TAI);
var MetersPerKilometer = 1e3;
var RadiansPerDegree = Math_default.RADIANS_PER_DEGREE;
var RadiansPerArcSecond = Math_default.RADIANS_PER_ARCSECOND;
var MetersPerAstronomicalUnit = 14959787e4;
var perifocalToEquatorial = new Matrix3_default();
function elementsToCartesian(semimajorAxis, eccentricity, inclination, longitudeOfPerigee, longitudeOfNode, meanLongitude, result) {
if (inclination < 0) {
inclination = -inclination;
longitudeOfNode += Math_default.PI;
}
if (inclination < 0 || inclination > Math_default.PI) {
throw new DeveloperError_default(
"The inclination is out of range. Inclination must be greater than or equal to zero and less than or equal to Pi radians."
);
}
const radiusOfPeriapsis = semimajorAxis * (1 - eccentricity);
const argumentOfPeriapsis = longitudeOfPerigee - longitudeOfNode;
const rightAscensionOfAscendingNode = longitudeOfNode;
const trueAnomaly = meanAnomalyToTrueAnomaly(
meanLongitude - longitudeOfPerigee,
eccentricity
);
const type = chooseOrbit(eccentricity, 0);
if (type === "Hyperbolic" && Math.abs(Math_default.negativePiToPi(trueAnomaly)) >= Math.acos(-1 / eccentricity)) {
throw new DeveloperError_default(
"The true anomaly of the hyperbolic orbit lies outside of the bounds of the hyperbola."
);
}
perifocalToCartesianMatrix(
argumentOfPeriapsis,
inclination,
rightAscensionOfAscendingNode,
perifocalToEquatorial
);
const semilatus = radiusOfPeriapsis * (1 + eccentricity);
const costheta = Math.cos(trueAnomaly);
const sintheta = Math.sin(trueAnomaly);
const denom = 1 + eccentricity * costheta;
if (denom <= Math_default.Epsilon10) {
throw new DeveloperError_default("elements cannot be converted to cartesian");
}
const radius = semilatus / denom;
if (!defined_default(result)) {
result = new Cartesian3_default(radius * costheta, radius * sintheta, 0);
} else {
result.x = radius * costheta;
result.y = radius * sintheta;
result.z = 0;
}
return Matrix3_default.multiplyByVector(perifocalToEquatorial, result, result);
}
function chooseOrbit(eccentricity, tolerance) {
if (eccentricity < 0) {
throw new DeveloperError_default("eccentricity cannot be negative.");
}
if (eccentricity <= tolerance) {
return "Circular";
} else if (eccentricity < 1 - tolerance) {
return "Elliptical";
} else if (eccentricity <= 1 + tolerance) {
return "Parabolic";
}
return "Hyperbolic";
}
function meanAnomalyToTrueAnomaly(meanAnomaly, eccentricity) {
if (eccentricity < 0 || eccentricity >= 1) {
throw new DeveloperError_default("eccentricity out of range.");
}
const eccentricAnomaly = meanAnomalyToEccentricAnomaly(
meanAnomaly,
eccentricity
);
return eccentricAnomalyToTrueAnomaly(eccentricAnomaly, eccentricity);
}
var maxIterationCount = 50;
var keplerEqConvergence = Math_default.EPSILON8;
function meanAnomalyToEccentricAnomaly(meanAnomaly, eccentricity) {
if (eccentricity < 0 || eccentricity >= 1) {
throw new DeveloperError_default("eccentricity out of range.");
}
const revs = Math.floor(meanAnomaly / Math_default.TWO_PI);
meanAnomaly -= revs * Math_default.TWO_PI;
let iterationValue = meanAnomaly + eccentricity * Math.sin(meanAnomaly) / (1 - Math.sin(meanAnomaly + eccentricity) + Math.sin(meanAnomaly));
let eccentricAnomaly = Number.MAX_VALUE;
let count;
for (count = 0; count < maxIterationCount && Math.abs(eccentricAnomaly - iterationValue) > keplerEqConvergence; ++count) {
eccentricAnomaly = iterationValue;
const NRfunction = eccentricAnomaly - eccentricity * Math.sin(eccentricAnomaly) - meanAnomaly;
const dNRfunction = 1 - eccentricity * Math.cos(eccentricAnomaly);
iterationValue = eccentricAnomaly - NRfunction / dNRfunction;
}
if (count >= maxIterationCount) {
throw new DeveloperError_default("Kepler equation did not converge");
}
eccentricAnomaly = iterationValue + revs * Math_default.TWO_PI;
return eccentricAnomaly;
}
function eccentricAnomalyToTrueAnomaly(eccentricAnomaly, eccentricity) {
if (eccentricity < 0 || eccentricity >= 1) {
throw new DeveloperError_default("eccentricity out of range.");
}
const revs = Math.floor(eccentricAnomaly / Math_default.TWO_PI);
eccentricAnomaly -= revs * Math_default.TWO_PI;
const trueAnomalyX = Math.cos(eccentricAnomaly) - eccentricity;
const trueAnomalyY = Math.sin(eccentricAnomaly) * Math.sqrt(1 - eccentricity * eccentricity);
let trueAnomaly = Math.atan2(trueAnomalyY, trueAnomalyX);
trueAnomaly = Math_default.zeroToTwoPi(trueAnomaly);
if (eccentricAnomaly < 0) {
trueAnomaly -= Math_default.TWO_PI;
}
trueAnomaly += revs * Math_default.TWO_PI;
return trueAnomaly;
}
function perifocalToCartesianMatrix(argumentOfPeriapsis, inclination, rightAscension, result) {
if (inclination < 0 || inclination > Math_default.PI) {
throw new DeveloperError_default("inclination out of range");
}
const cosap = Math.cos(argumentOfPeriapsis);
const sinap = Math.sin(argumentOfPeriapsis);
const cosi = Math.cos(inclination);
const sini = Math.sin(inclination);
const cosraan = Math.cos(rightAscension);
const sinraan = Math.sin(rightAscension);
if (!defined_default(result)) {
result = new Matrix3_default(
cosraan * cosap - sinraan * sinap * cosi,
-cosraan * sinap - sinraan * cosap * cosi,
sinraan * sini,
sinraan * cosap + cosraan * sinap * cosi,
-sinraan * sinap + cosraan * cosap * cosi,
-cosraan * sini,
sinap * sini,
cosap * sini,
cosi
);
} else {
result[0] = cosraan * cosap - sinraan * sinap * cosi;
result[1] = sinraan * cosap + cosraan * sinap * cosi;
result[2] = sinap * sini;
result[3] = -cosraan * sinap - sinraan * cosap * cosi;
result[4] = -sinraan * sinap + cosraan * cosap * cosi;
result[5] = cosap * sini;
result[6] = sinraan * sini;
result[7] = -cosraan * sini;
result[8] = cosi;
}
return result;
}
var semiMajorAxis0 = 1.0000010178 * MetersPerAstronomicalUnit;
var meanLongitude0 = 100.46645683 * RadiansPerDegree;
var meanLongitude1 = 129597742283429e-5 * RadiansPerArcSecond;
var p1u = 16002;
var p2u = 21863;
var p3u = 32004;
var p4u = 10931;
var p5u = 14529;
var p6u = 16368;
var p7u = 15318;
var p8u = 32794;
var Ca1 = 64 * 1e-7 * MetersPerAstronomicalUnit;
var Ca2 = -152 * 1e-7 * MetersPerAstronomicalUnit;
var Ca3 = 62 * 1e-7 * MetersPerAstronomicalUnit;
var Ca4 = -8 * 1e-7 * MetersPerAstronomicalUnit;
var Ca5 = 32 * 1e-7 * MetersPerAstronomicalUnit;
var Ca6 = -41 * 1e-7 * MetersPerAstronomicalUnit;
var Ca7 = 19 * 1e-7 * MetersPerAstronomicalUnit;
var Ca8 = -11 * 1e-7 * MetersPerAstronomicalUnit;
var Sa1 = -150 * 1e-7 * MetersPerAstronomicalUnit;
var Sa2 = -46 * 1e-7 * MetersPerAstronomicalUnit;
var Sa3 = 68 * 1e-7 * MetersPerAstronomicalUnit;
var Sa4 = 54 * 1e-7 * MetersPerAstronomicalUnit;
var Sa5 = 14 * 1e-7 * MetersPerAstronomicalUnit;
var Sa6 = 24 * 1e-7 * MetersPerAstronomicalUnit;
var Sa7 = -28 * 1e-7 * MetersPerAstronomicalUnit;
var Sa8 = 22 * 1e-7 * MetersPerAstronomicalUnit;
var q1u = 10;
var q2u = 16002;
var q3u = 21863;
var q4u = 10931;
var q5u = 1473;
var q6u = 32004;
var q7u = 4387;
var q8u = 73;
var Cl1 = -325 * 1e-7;
var Cl2 = -322 * 1e-7;
var Cl3 = -79 * 1e-7;
var Cl4 = 232 * 1e-7;
var Cl5 = -52 * 1e-7;
var Cl6 = 97 * 1e-7;
var Cl7 = 55 * 1e-7;
var Cl8 = -41 * 1e-7;
var Sl1 = -105 * 1e-7;
var Sl2 = -137 * 1e-7;
var Sl3 = 258 * 1e-7;
var Sl4 = 35 * 1e-7;
var Sl5 = -116 * 1e-7;
var Sl6 = -88 * 1e-7;
var Sl7 = -112 * 1e-7;
var Sl8 = -80 * 1e-7;
var scratchDate = new JulianDate_default(0, 0, TimeStandard_default.TAI);
function computeSimonEarthMoonBarycenter(date, result) {
taiToTdb(date, scratchDate);
const x = scratchDate.dayNumber - epoch.dayNumber + (scratchDate.secondsOfDay - epoch.secondsOfDay) / TimeConstants_default.SECONDS_PER_DAY;
const t = x / (TimeConstants_default.DAYS_PER_JULIAN_CENTURY * 10);
const u3 = 0.3595362 * t;
const semimajorAxis = semiMajorAxis0 + Ca1 * Math.cos(p1u * u3) + Sa1 * Math.sin(p1u * u3) + Ca2 * Math.cos(p2u * u3) + Sa2 * Math.sin(p2u * u3) + Ca3 * Math.cos(p3u * u3) + Sa3 * Math.sin(p3u * u3) + Ca4 * Math.cos(p4u * u3) + Sa4 * Math.sin(p4u * u3) + Ca5 * Math.cos(p5u * u3) + Sa5 * Math.sin(p5u * u3) + Ca6 * Math.cos(p6u * u3) + Sa6 * Math.sin(p6u * u3) + Ca7 * Math.cos(p7u * u3) + Sa7 * Math.sin(p7u * u3) + Ca8 * Math.cos(p8u * u3) + Sa8 * Math.sin(p8u * u3);
const meanLongitude = meanLongitude0 + meanLongitude1 * t + Cl1 * Math.cos(q1u * u3) + Sl1 * Math.sin(q1u * u3) + Cl2 * Math.cos(q2u * u3) + Sl2 * Math.sin(q2u * u3) + Cl3 * Math.cos(q3u * u3) + Sl3 * Math.sin(q3u * u3) + Cl4 * Math.cos(q4u * u3) + Sl4 * Math.sin(q4u * u3) + Cl5 * Math.cos(q5u * u3) + Sl5 * Math.sin(q5u * u3) + Cl6 * Math.cos(q6u * u3) + Sl6 * Math.sin(q6u * u3) + Cl7 * Math.cos(q7u * u3) + Sl7 * Math.sin(q7u * u3) + Cl8 * Math.cos(q8u * u3) + Sl8 * Math.sin(q8u * u3);
const eccentricity = 0.0167086342 - 4203654e-10 * t;
const longitudeOfPerigee = 102.93734808 * RadiansPerDegree + 11612.3529 * RadiansPerArcSecond * t;
const inclination = 469.97289 * RadiansPerArcSecond * t;
const longitudeOfNode = 174.87317577 * RadiansPerDegree - 8679.27034 * RadiansPerArcSecond * t;
return elementsToCartesian(
semimajorAxis,
eccentricity,
inclination,
longitudeOfPerigee,
longitudeOfNode,
meanLongitude,
result
);
}
function computeSimonMoon(date, result) {
taiToTdb(date, scratchDate);
const x = scratchDate.dayNumber - epoch.dayNumber + (scratchDate.secondsOfDay - epoch.secondsOfDay) / TimeConstants_default.SECONDS_PER_DAY;
const t = x / TimeConstants_default.DAYS_PER_JULIAN_CENTURY;
const t2 = t * t;
const t3 = t2 * t;
const t4 = t3 * t;
let semimajorAxis = 383397.7725 + 4e-3 * t;
let eccentricity = 0.055545526 - 16e-9 * t;
const inclinationConstant = 5.15668983 * RadiansPerDegree;
let inclinationSecPart = -8e-5 * t + 0.02966 * t2 - 42e-6 * t3 - 13e-8 * t4;
const longitudeOfPerigeeConstant = 83.35324312 * RadiansPerDegree;
let longitudeOfPerigeeSecPart = 146434202669e-4 * t - 38.2702 * t2 - 0.045047 * t3 + 21301e-8 * t4;
const longitudeOfNodeConstant = 125.04455501 * RadiansPerDegree;
let longitudeOfNodeSecPart = -69679193631e-4 * t + 6.3602 * t2 + 7625e-6 * t3 - 3586e-8 * t4;
const meanLongitudeConstant = 218.31664563 * RadiansPerDegree;
let meanLongitudeSecPart = 17325593434847e-4 * t - 6.391 * t2 + 6588e-6 * t3 - 3169e-8 * t4;
const D = 297.85019547 * RadiansPerDegree + RadiansPerArcSecond * (1602961601209e-3 * t - 6.3706 * t2 + 6593e-6 * t3 - 3169e-8 * t4);
const F = 93.27209062 * RadiansPerDegree + RadiansPerArcSecond * (17395272628478e-4 * t - 12.7512 * t2 - 1037e-6 * t3 + 417e-8 * t4);
const l = 134.96340251 * RadiansPerDegree + RadiansPerArcSecond * (17179159232178e-4 * t + 31.8792 * t2 + 0.051635 * t3 - 2447e-7 * t4);
const lprime = 357.52910918 * RadiansPerDegree + RadiansPerArcSecond * (1295965810481e-4 * t - 0.5532 * t2 + 136e-6 * t3 - 1149e-8 * t4);
const psi = 310.17137918 * RadiansPerDegree - RadiansPerArcSecond * (6967051436e-3 * t + 6.2068 * t2 + 7618e-6 * t3 - 3219e-8 * t4);
const twoD = 2 * D;
const fourD = 4 * D;
const sixD = 6 * D;
const twol = 2 * l;
const threel = 3 * l;
const fourl = 4 * l;
const twoF = 2 * F;
semimajorAxis += 3400.4 * Math.cos(twoD) - 635.6 * Math.cos(twoD - l) - 235.6 * Math.cos(l) + 218.1 * Math.cos(twoD - lprime) + 181 * Math.cos(twoD + l);
eccentricity += 0.014216 * Math.cos(twoD - l) + 8551e-6 * Math.cos(twoD - twol) - 1383e-6 * Math.cos(l) + 1356e-6 * Math.cos(twoD + l) - 1147e-6 * Math.cos(fourD - threel) - 914e-6 * Math.cos(fourD - twol) + 869e-6 * Math.cos(twoD - lprime - l) - 627e-6 * Math.cos(twoD) - 394e-6 * Math.cos(fourD - fourl) + 282e-6 * Math.cos(twoD - lprime - twol) - 279e-6 * Math.cos(D - l) - 236e-6 * Math.cos(twol) + 231e-6 * Math.cos(fourD) + 229e-6 * Math.cos(sixD - fourl) - 201e-6 * Math.cos(twol - twoF);
inclinationSecPart += 486.26 * Math.cos(twoD - twoF) - 40.13 * Math.cos(twoD) + 37.51 * Math.cos(twoF) + 25.73 * Math.cos(twol - twoF) + 19.97 * Math.cos(twoD - lprime - twoF);
longitudeOfPerigeeSecPart += -55609 * Math.sin(twoD - l) - 34711 * Math.sin(twoD - twol) - 9792 * Math.sin(l) + 9385 * Math.sin(fourD - threel) + 7505 * Math.sin(fourD - twol) + 5318 * Math.sin(twoD + l) + 3484 * Math.sin(fourD - fourl) - 3417 * Math.sin(twoD - lprime - l) - 2530 * Math.sin(sixD - fourl) - 2376 * Math.sin(twoD) - 2075 * Math.sin(twoD - threel) - 1883 * Math.sin(twol) - 1736 * Math.sin(sixD - 5 * l) + 1626 * Math.sin(lprime) - 1370 * Math.sin(sixD - threel);
longitudeOfNodeSecPart += -5392 * Math.sin(twoD - twoF) - 540 * Math.sin(lprime) - 441 * Math.sin(twoD) + 423 * Math.sin(twoF) - 288 * Math.sin(twol - twoF);
meanLongitudeSecPart += -3332.9 * Math.sin(twoD) + 1197.4 * Math.sin(twoD - l) - 662.5 * Math.sin(lprime) + 396.3 * Math.sin(l) - 218 * Math.sin(twoD - lprime);
const twoPsi = 2 * psi;
const threePsi = 3 * psi;
inclinationSecPart += 46.997 * Math.cos(psi) * t - 0.614 * Math.cos(twoD - twoF + psi) * t + 0.614 * Math.cos(twoD - twoF - psi) * t - 0.0297 * Math.cos(twoPsi) * t2 - 0.0335 * Math.cos(psi) * t2 + 12e-4 * Math.cos(twoD - twoF + twoPsi) * t2 - 16e-5 * Math.cos(psi) * t3 + 4e-5 * Math.cos(threePsi) * t3 + 4e-5 * Math.cos(twoPsi) * t3;
const perigeeAndMean = 2.116 * Math.sin(psi) * t - 0.111 * Math.sin(twoD - twoF - psi) * t - 15e-4 * Math.sin(psi) * t2;
longitudeOfPerigeeSecPart += perigeeAndMean;
meanLongitudeSecPart += perigeeAndMean;
longitudeOfNodeSecPart += -520.77 * Math.sin(psi) * t + 13.66 * Math.sin(twoD - twoF + psi) * t + 1.12 * Math.sin(twoD - psi) * t - 1.06 * Math.sin(twoF - psi) * t + 0.66 * Math.sin(twoPsi) * t2 + 0.371 * Math.sin(psi) * t2 - 0.035 * Math.sin(twoD - twoF + twoPsi) * t2 - 0.015 * Math.sin(twoD - twoF + psi) * t2 + 14e-4 * Math.sin(psi) * t3 - 11e-4 * Math.sin(threePsi) * t3 - 9e-4 * Math.sin(twoPsi) * t3;
semimajorAxis *= MetersPerKilometer;
const inclination = inclinationConstant + inclinationSecPart * RadiansPerArcSecond;
const longitudeOfPerigee = longitudeOfPerigeeConstant + longitudeOfPerigeeSecPart * RadiansPerArcSecond;
const meanLongitude = meanLongitudeConstant + meanLongitudeSecPart * RadiansPerArcSecond;
const longitudeOfNode = longitudeOfNodeConstant + longitudeOfNodeSecPart * RadiansPerArcSecond;
return elementsToCartesian(
semimajorAxis,
eccentricity,
inclination,
longitudeOfPerigee,
longitudeOfNode,
meanLongitude,
result
);
}
var moonEarthMassRatio = 0.012300034;
var factor = moonEarthMassRatio / (moonEarthMassRatio + 1) * -1;
function computeSimonEarth(date, result) {
result = computeSimonMoon(date, result);
return Cartesian3_default.multiplyByScalar(result, factor, result);
}
var axesTransformation = new Matrix3_default(
1.0000000000000002,
5619723173785822e-31,
4690511510146299e-34,
-5154129427414611e-31,
0.9174820620691819,
-0.39777715593191376,
-223970096136568e-30,
0.39777715593191376,
0.9174820620691819
);
var translation2 = new Cartesian3_default();
Simon1994PlanetaryPositions.computeSunPositionInEarthInertialFrame = function(julianDate, result) {
if (!defined_default(julianDate)) {
julianDate = JulianDate_default.now();
}
if (!defined_default(result)) {
result = new Cartesian3_default();
}
translation2 = computeSimonEarthMoonBarycenter(julianDate, translation2);
result = Cartesian3_default.negate(translation2, result);
computeSimonEarth(julianDate, translation2);
Cartesian3_default.subtract(result, translation2, result);
Matrix3_default.multiplyByVector(axesTransformation, result, result);
return result;
};
Simon1994PlanetaryPositions.computeMoonPositionInEarthInertialFrame = function(julianDate, result) {
if (!defined_default(julianDate)) {
julianDate = JulianDate_default.now();
}
result = computeSimonMoon(julianDate, result);
Matrix3_default.multiplyByVector(axesTransformation, result, result);
return result;
};
var Simon1994PlanetaryPositions_default = Simon1994PlanetaryPositions;
// Source/Core/SimplePolylineGeometry.js
function interpolateColors2(p0, p1, color0, color1, minDistance, array, offset2) {
const numPoints = PolylinePipeline_default.numberOfPoints(p0, p1, minDistance);
let i;
const r0 = color0.red;
const g0 = color0.green;
const b0 = color0.blue;
const a0 = color0.alpha;
const r1 = color1.red;
const g1 = color1.green;
const b1 = color1.blue;
const a1 = color1.alpha;
if (Color_default.equals(color0, color1)) {
for (i = 0; i < numPoints; i++) {
array[offset2++] = Color_default.floatToByte(r0);
array[offset2++] = Color_default.floatToByte(g0);
array[offset2++] = Color_default.floatToByte(b0);
array[offset2++] = Color_default.floatToByte(a0);
}
return offset2;
}
const redPerVertex = (r1 - r0) / numPoints;
const greenPerVertex = (g1 - g0) / numPoints;
const bluePerVertex = (b1 - b0) / numPoints;
const alphaPerVertex = (a1 - a0) / numPoints;
let index = offset2;
for (i = 0; i < numPoints; i++) {
array[index++] = Color_default.floatToByte(r0 + i * redPerVertex);
array[index++] = Color_default.floatToByte(g0 + i * greenPerVertex);
array[index++] = Color_default.floatToByte(b0 + i * bluePerVertex);
array[index++] = Color_default.floatToByte(a0 + i * alphaPerVertex);
}
return index;
}
function SimplePolylineGeometry(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
const positions = options.positions;
const colors = options.colors;
const colorsPerVertex = defaultValue_default(options.colorsPerVertex, false);
if (!defined_default(positions) || positions.length < 2) {
throw new DeveloperError_default("At least two positions are required.");
}
if (defined_default(colors) && (colorsPerVertex && colors.length < positions.length || !colorsPerVertex && colors.length < positions.length - 1)) {
throw new DeveloperError_default("colors has an invalid length.");
}
this._positions = positions;
this._colors = colors;
this._colorsPerVertex = colorsPerVertex;
this._arcType = defaultValue_default(options.arcType, ArcType_default.GEODESIC);
this._granularity = defaultValue_default(
options.granularity,
Math_default.RADIANS_PER_DEGREE
);
this._ellipsoid = defaultValue_default(options.ellipsoid, Ellipsoid_default.WGS84);
this._workerName = "createSimplePolylineGeometry";
let numComponents = 1 + positions.length * Cartesian3_default.packedLength;
numComponents += defined_default(colors) ? 1 + colors.length * Color_default.packedLength : 1;
this.packedLength = numComponents + Ellipsoid_default.packedLength + 3;
}
SimplePolylineGeometry.pack = function(value, array, startingIndex) {
if (!defined_default(value)) {
throw new DeveloperError_default("value is required");
}
if (!defined_default(array)) {
throw new DeveloperError_default("array is required");
}
startingIndex = defaultValue_default(startingIndex, 0);
let i;
const positions = value._positions;
let length3 = positions.length;
array[startingIndex++] = length3;
for (i = 0; i < length3; ++i, startingIndex += Cartesian3_default.packedLength) {
Cartesian3_default.pack(positions[i], array, startingIndex);
}
const colors = value._colors;
length3 = defined_default(colors) ? colors.length : 0;
array[startingIndex++] = length3;
for (i = 0; i < length3; ++i, startingIndex += Color_default.packedLength) {
Color_default.pack(colors[i], array, startingIndex);
}
Ellipsoid_default.pack(value._ellipsoid, array, startingIndex);
startingIndex += Ellipsoid_default.packedLength;
array[startingIndex++] = value._colorsPerVertex ? 1 : 0;
array[startingIndex++] = value._arcType;
array[startingIndex] = value._granularity;
return array;
};
SimplePolylineGeometry.unpack = function(array, startingIndex, result) {
if (!defined_default(array)) {
throw new DeveloperError_default("array is required");
}
startingIndex = defaultValue_default(startingIndex, 0);
let i;
let length3 = array[startingIndex++];
const positions = new Array(length3);
for (i = 0; i < length3; ++i, startingIndex += Cartesian3_default.packedLength) {
positions[i] = Cartesian3_default.unpack(array, startingIndex);
}
length3 = array[startingIndex++];
const colors = length3 > 0 ? new Array(length3) : void 0;
for (i = 0; i < length3; ++i, startingIndex += Color_default.packedLength) {
colors[i] = Color_default.unpack(array, startingIndex);
}
const ellipsoid = Ellipsoid_default.unpack(array, startingIndex);
startingIndex += Ellipsoid_default.packedLength;
const colorsPerVertex = array[startingIndex++] === 1;
const arcType = array[startingIndex++];
const granularity = array[startingIndex];
if (!defined_default(result)) {
return new SimplePolylineGeometry({
positions,
colors,
ellipsoid,
colorsPerVertex,
arcType,
granularity
});
}
result._positions = positions;
result._colors = colors;
result._ellipsoid = ellipsoid;
result._colorsPerVertex = colorsPerVertex;
result._arcType = arcType;
result._granularity = granularity;
return result;
};
var scratchArray1 = new Array(2);
var scratchArray2 = new Array(2);
var generateArcOptionsScratch = {
positions: scratchArray1,
height: scratchArray2,
ellipsoid: void 0,
minDistance: void 0,
granularity: void 0
};
SimplePolylineGeometry.createGeometry = function(simplePolylineGeometry) {
const positions = simplePolylineGeometry._positions;
const colors = simplePolylineGeometry._colors;
const colorsPerVertex = simplePolylineGeometry._colorsPerVertex;
const arcType = simplePolylineGeometry._arcType;
const granularity = simplePolylineGeometry._granularity;
const ellipsoid = simplePolylineGeometry._ellipsoid;
const minDistance = Math_default.chordLength(
granularity,
ellipsoid.maximumRadius
);
const perSegmentColors = defined_default(colors) && !colorsPerVertex;
let i;
const length3 = positions.length;
let positionValues;
let numberOfPositions;
let colorValues;
let color;
let offset2 = 0;
if (arcType === ArcType_default.GEODESIC || arcType === ArcType_default.RHUMB) {
let subdivisionSize;
let numberOfPointsFunction;
let generateArcFunction;
if (arcType === ArcType_default.GEODESIC) {
subdivisionSize = Math_default.chordLength(
granularity,
ellipsoid.maximumRadius
);
numberOfPointsFunction = PolylinePipeline_default.numberOfPoints;
generateArcFunction = PolylinePipeline_default.generateArc;
} else {
subdivisionSize = granularity;
numberOfPointsFunction = PolylinePipeline_default.numberOfPointsRhumbLine;
generateArcFunction = PolylinePipeline_default.generateRhumbArc;
}
const heights = PolylinePipeline_default.extractHeights(positions, ellipsoid);
const generateArcOptions = generateArcOptionsScratch;
if (arcType === ArcType_default.GEODESIC) {
generateArcOptions.minDistance = minDistance;
} else {
generateArcOptions.granularity = granularity;
}
generateArcOptions.ellipsoid = ellipsoid;
if (perSegmentColors) {
let positionCount = 0;
for (i = 0; i < length3 - 1; i++) {
positionCount += numberOfPointsFunction(
positions[i],
positions[i + 1],
subdivisionSize
) + 1;
}
positionValues = new Float64Array(positionCount * 3);
colorValues = new Uint8Array(positionCount * 4);
generateArcOptions.positions = scratchArray1;
generateArcOptions.height = scratchArray2;
let ci = 0;
for (i = 0; i < length3 - 1; ++i) {
scratchArray1[0] = positions[i];
scratchArray1[1] = positions[i + 1];
scratchArray2[0] = heights[i];
scratchArray2[1] = heights[i + 1];
const pos = generateArcFunction(generateArcOptions);
if (defined_default(colors)) {
const segLen = pos.length / 3;
color = colors[i];
for (let k = 0; k < segLen; ++k) {
colorValues[ci++] = Color_default.floatToByte(color.red);
colorValues[ci++] = Color_default.floatToByte(color.green);
colorValues[ci++] = Color_default.floatToByte(color.blue);
colorValues[ci++] = Color_default.floatToByte(color.alpha);
}
}
positionValues.set(pos, offset2);
offset2 += pos.length;
}
} else {
generateArcOptions.positions = positions;
generateArcOptions.height = heights;
positionValues = new Float64Array(
generateArcFunction(generateArcOptions)
);
if (defined_default(colors)) {
colorValues = new Uint8Array(positionValues.length / 3 * 4);
for (i = 0; i < length3 - 1; ++i) {
const p0 = positions[i];
const p1 = positions[i + 1];
const c0 = colors[i];
const c14 = colors[i + 1];
offset2 = interpolateColors2(
p0,
p1,
c0,
c14,
minDistance,
colorValues,
offset2
);
}
const lastColor = colors[length3 - 1];
colorValues[offset2++] = Color_default.floatToByte(lastColor.red);
colorValues[offset2++] = Color_default.floatToByte(lastColor.green);
colorValues[offset2++] = Color_default.floatToByte(lastColor.blue);
colorValues[offset2++] = Color_default.floatToByte(lastColor.alpha);
}
}
} else {
numberOfPositions = perSegmentColors ? length3 * 2 - 2 : length3;
positionValues = new Float64Array(numberOfPositions * 3);
colorValues = defined_default(colors) ? new Uint8Array(numberOfPositions * 4) : void 0;
let positionIndex = 0;
let colorIndex = 0;
for (i = 0; i < length3; ++i) {
const p = positions[i];
if (perSegmentColors && i > 0) {
Cartesian3_default.pack(p, positionValues, positionIndex);
positionIndex += 3;
color = colors[i - 1];
colorValues[colorIndex++] = Color_default.floatToByte(color.red);
colorValues[colorIndex++] = Color_default.floatToByte(color.green);
colorValues[colorIndex++] = Color_default.floatToByte(color.blue);
colorValues[colorIndex++] = Color_default.floatToByte(color.alpha);
}
if (perSegmentColors && i === length3 - 1) {
break;
}
Cartesian3_default.pack(p, positionValues, positionIndex);
positionIndex += 3;
if (defined_default(colors)) {
color = colors[i];
colorValues[colorIndex++] = Color_default.floatToByte(color.red);
colorValues[colorIndex++] = Color_default.floatToByte(color.green);
colorValues[colorIndex++] = Color_default.floatToByte(color.blue);
colorValues[colorIndex++] = Color_default.floatToByte(color.alpha);
}
}
}
const attributes = new GeometryAttributes_default();
attributes.position = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.DOUBLE,
componentsPerAttribute: 3,
values: positionValues
});
if (defined_default(colors)) {
attributes.color = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.UNSIGNED_BYTE,
componentsPerAttribute: 4,
values: colorValues,
normalize: true
});
}
numberOfPositions = positionValues.length / 3;
const numberOfIndices = (numberOfPositions - 1) * 2;
const indices2 = IndexDatatype_default.createTypedArray(
numberOfPositions,
numberOfIndices
);
let index = 0;
for (i = 0; i < numberOfPositions - 1; ++i) {
indices2[index++] = i;
indices2[index++] = i + 1;
}
return new Geometry_default({
attributes,
indices: indices2,
primitiveType: PrimitiveType_default.LINES,
boundingSphere: BoundingSphere_default.fromPoints(positions)
});
};
var SimplePolylineGeometry_default = SimplePolylineGeometry;
// Source/Core/SphereGeometry.js
function SphereGeometry(options) {
const radius = defaultValue_default(options.radius, 1);
const radii = new Cartesian3_default(radius, radius, radius);
const ellipsoidOptions = {
radii,
stackPartitions: options.stackPartitions,
slicePartitions: options.slicePartitions,
vertexFormat: options.vertexFormat
};
this._ellipsoidGeometry = new EllipsoidGeometry_default(ellipsoidOptions);
this._workerName = "createSphereGeometry";
}
SphereGeometry.packedLength = EllipsoidGeometry_default.packedLength;
SphereGeometry.pack = function(value, array, startingIndex) {
Check_default.typeOf.object("value", value);
return EllipsoidGeometry_default.pack(value._ellipsoidGeometry, array, startingIndex);
};
var scratchEllipsoidGeometry = new EllipsoidGeometry_default();
var scratchOptions21 = {
radius: void 0,
radii: new Cartesian3_default(),
vertexFormat: new VertexFormat_default(),
stackPartitions: void 0,
slicePartitions: void 0
};
SphereGeometry.unpack = function(array, startingIndex, result) {
const ellipsoidGeometry = EllipsoidGeometry_default.unpack(
array,
startingIndex,
scratchEllipsoidGeometry
);
scratchOptions21.vertexFormat = VertexFormat_default.clone(
ellipsoidGeometry._vertexFormat,
scratchOptions21.vertexFormat
);
scratchOptions21.stackPartitions = ellipsoidGeometry._stackPartitions;
scratchOptions21.slicePartitions = ellipsoidGeometry._slicePartitions;
if (!defined_default(result)) {
scratchOptions21.radius = ellipsoidGeometry._radii.x;
return new SphereGeometry(scratchOptions21);
}
Cartesian3_default.clone(ellipsoidGeometry._radii, scratchOptions21.radii);
result._ellipsoidGeometry = new EllipsoidGeometry_default(scratchOptions21);
return result;
};
SphereGeometry.createGeometry = function(sphereGeometry) {
return EllipsoidGeometry_default.createGeometry(sphereGeometry._ellipsoidGeometry);
};
var SphereGeometry_default = SphereGeometry;
// Source/Core/SphereOutlineGeometry.js
function SphereOutlineGeometry(options) {
const radius = defaultValue_default(options.radius, 1);
const radii = new Cartesian3_default(radius, radius, radius);
const ellipsoidOptions = {
radii,
stackPartitions: options.stackPartitions,
slicePartitions: options.slicePartitions,
subdivisions: options.subdivisions
};
this._ellipsoidGeometry = new EllipsoidOutlineGeometry_default(ellipsoidOptions);
this._workerName = "createSphereOutlineGeometry";
}
SphereOutlineGeometry.packedLength = EllipsoidOutlineGeometry_default.packedLength;
SphereOutlineGeometry.pack = function(value, array, startingIndex) {
Check_default.typeOf.object("value", value);
return EllipsoidOutlineGeometry_default.pack(
value._ellipsoidGeometry,
array,
startingIndex
);
};
var scratchEllipsoidGeometry2 = new EllipsoidOutlineGeometry_default();
var scratchOptions22 = {
radius: void 0,
radii: new Cartesian3_default(),
stackPartitions: void 0,
slicePartitions: void 0,
subdivisions: void 0
};
SphereOutlineGeometry.unpack = function(array, startingIndex, result) {
const ellipsoidGeometry = EllipsoidOutlineGeometry_default.unpack(
array,
startingIndex,
scratchEllipsoidGeometry2
);
scratchOptions22.stackPartitions = ellipsoidGeometry._stackPartitions;
scratchOptions22.slicePartitions = ellipsoidGeometry._slicePartitions;
scratchOptions22.subdivisions = ellipsoidGeometry._subdivisions;
if (!defined_default(result)) {
scratchOptions22.radius = ellipsoidGeometry._radii.x;
return new SphereOutlineGeometry(scratchOptions22);
}
Cartesian3_default.clone(ellipsoidGeometry._radii, scratchOptions22.radii);
result._ellipsoidGeometry = new EllipsoidOutlineGeometry_default(scratchOptions22);
return result;
};
SphereOutlineGeometry.createGeometry = function(sphereGeometry) {
return EllipsoidOutlineGeometry_default.createGeometry(
sphereGeometry._ellipsoidGeometry
);
};
var SphereOutlineGeometry_default = SphereOutlineGeometry;
// Source/Core/Spherical.js
function Spherical(clock, cone, magnitude) {
this.clock = defaultValue_default(clock, 0);
this.cone = defaultValue_default(cone, 0);
this.magnitude = defaultValue_default(magnitude, 1);
}
Spherical.fromCartesian3 = function(cartesian34, result) {
Check_default.typeOf.object("cartesian3", cartesian34);
const x = cartesian34.x;
const y = cartesian34.y;
const z = cartesian34.z;
const radialSquared = x * x + y * y;
if (!defined_default(result)) {
result = new Spherical();
}
result.clock = Math.atan2(y, x);
result.cone = Math.atan2(Math.sqrt(radialSquared), z);
result.magnitude = Math.sqrt(radialSquared + z * z);
return result;
};
Spherical.clone = function(spherical, result) {
if (!defined_default(spherical)) {
return void 0;
}
if (!defined_default(result)) {
return new Spherical(spherical.clock, spherical.cone, spherical.magnitude);
}
result.clock = spherical.clock;
result.cone = spherical.cone;
result.magnitude = spherical.magnitude;
return result;
};
Spherical.normalize = function(spherical, result) {
Check_default.typeOf.object("spherical", spherical);
if (!defined_default(result)) {
return new Spherical(spherical.clock, spherical.cone, 1);
}
result.clock = spherical.clock;
result.cone = spherical.cone;
result.magnitude = 1;
return result;
};
Spherical.equals = function(left, right) {
return left === right || defined_default(left) && defined_default(right) && left.clock === right.clock && left.cone === right.cone && left.magnitude === right.magnitude;
};
Spherical.equalsEpsilon = function(left, right, epsilon) {
epsilon = defaultValue_default(epsilon, 0);
return left === right || defined_default(left) && defined_default(right) && Math.abs(left.clock - right.clock) <= epsilon && Math.abs(left.cone - right.cone) <= epsilon && Math.abs(left.magnitude - right.magnitude) <= epsilon;
};
Spherical.prototype.equals = function(other) {
return Spherical.equals(this, other);
};
Spherical.prototype.clone = function(result) {
return Spherical.clone(this, result);
};
Spherical.prototype.equalsEpsilon = function(other, epsilon) {
return Spherical.equalsEpsilon(this, other, epsilon);
};
Spherical.prototype.toString = function() {
return `(${this.clock}, ${this.cone}, ${this.magnitude})`;
};
var Spherical_default = Spherical;
// Source/Core/SteppedSpline.js
function SteppedSpline(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
const points = options.points;
const times = options.times;
if (!defined_default(points) || !defined_default(times)) {
throw new DeveloperError_default("points and times are required.");
}
if (points.length < 2) {
throw new DeveloperError_default(
"points.length must be greater than or equal to 2."
);
}
if (times.length !== points.length) {
throw new DeveloperError_default("times.length must be equal to points.length.");
}
this._times = times;
this._points = points;
this._pointType = Spline_default.getPointType(points[0]);
this._lastTimeIndex = 0;
}
Object.defineProperties(SteppedSpline.prototype, {
times: {
get: function() {
return this._times;
}
},
points: {
get: function() {
return this._points;
}
}
});
SteppedSpline.prototype.findTimeInterval = Spline_default.prototype.findTimeInterval;
SteppedSpline.prototype.wrapTime = Spline_default.prototype.wrapTime;
SteppedSpline.prototype.clampTime = Spline_default.prototype.clampTime;
SteppedSpline.prototype.evaluate = function(time, result) {
const points = this.points;
this._lastTimeIndex = this.findTimeInterval(time, this._lastTimeIndex);
const i = this._lastTimeIndex;
const PointType = this._pointType;
if (PointType === Number) {
return points[i];
}
if (!defined_default(result)) {
result = new PointType();
}
return PointType.clone(points[i], result);
};
var SteppedSpline_default = SteppedSpline;
// Source/Core/subdivideArray.js
function subdivideArray(array, numberOfArrays) {
if (!defined_default(array)) {
throw new DeveloperError_default("array is required.");
}
if (!defined_default(numberOfArrays) || numberOfArrays < 1) {
throw new DeveloperError_default("numberOfArrays must be greater than 0.");
}
const result = [];
const len = array.length;
let i = 0;
while (i < len) {
const size = Math.ceil((len - i) / numberOfArrays--);
result.push(array.slice(i, i + size));
i += size;
}
return result;
}
var subdivideArray_default = subdivideArray;
// Source/Core/TileEdge.js
var TileEdge = {
WEST: 0,
NORTH: 1,
EAST: 2,
SOUTH: 3,
NORTHWEST: 4,
NORTHEAST: 5,
SOUTHWEST: 6,
SOUTHEAST: 7
};
var TileEdge_default = TileEdge;
// Source/Core/TilingScheme.js
function TilingScheme(options) {
throw new DeveloperError_default(
"This type should not be instantiated directly. Instead, use WebMercatorTilingScheme or GeographicTilingScheme."
);
}
Object.defineProperties(TilingScheme.prototype, {
ellipsoid: {
get: DeveloperError_default.throwInstantiationError
},
rectangle: {
get: DeveloperError_default.throwInstantiationError
},
projection: {
get: DeveloperError_default.throwInstantiationError
}
});
TilingScheme.prototype.getNumberOfXTilesAtLevel = DeveloperError_default.throwInstantiationError;
TilingScheme.prototype.getNumberOfYTilesAtLevel = DeveloperError_default.throwInstantiationError;
TilingScheme.prototype.rectangleToNativeRectangle = DeveloperError_default.throwInstantiationError;
TilingScheme.prototype.tileXYToNativeRectangle = DeveloperError_default.throwInstantiationError;
TilingScheme.prototype.tileXYToRectangle = DeveloperError_default.throwInstantiationError;
TilingScheme.prototype.positionToTileXY = DeveloperError_default.throwInstantiationError;
var TilingScheme_default = TilingScheme;
// Source/Core/TimeIntervalCollection.js
function compareIntervalStartTimes(left, right) {
return JulianDate_default.compare(left.start, right.start);
}
function TimeIntervalCollection(intervals) {
this._intervals = [];
this._changedEvent = new Event_default();
if (defined_default(intervals)) {
const length3 = intervals.length;
for (let i = 0; i < length3; i++) {
this.addInterval(intervals[i]);
}
}
}
Object.defineProperties(TimeIntervalCollection.prototype, {
changedEvent: {
get: function() {
return this._changedEvent;
}
},
start: {
get: function() {
const intervals = this._intervals;
return intervals.length === 0 ? void 0 : intervals[0].start;
}
},
isStartIncluded: {
get: function() {
const intervals = this._intervals;
return intervals.length === 0 ? false : intervals[0].isStartIncluded;
}
},
stop: {
get: function() {
const intervals = this._intervals;
const length3 = intervals.length;
return length3 === 0 ? void 0 : intervals[length3 - 1].stop;
}
},
isStopIncluded: {
get: function() {
const intervals = this._intervals;
const length3 = intervals.length;
return length3 === 0 ? false : intervals[length3 - 1].isStopIncluded;
}
},
length: {
get: function() {
return this._intervals.length;
}
},
isEmpty: {
get: function() {
return this._intervals.length === 0;
}
}
});
TimeIntervalCollection.prototype.equals = function(right, dataComparer) {
if (this === right) {
return true;
}
if (!(right instanceof TimeIntervalCollection)) {
return false;
}
const intervals = this._intervals;
const rightIntervals = right._intervals;
const length3 = intervals.length;
if (length3 !== rightIntervals.length) {
return false;
}
for (let i = 0; i < length3; i++) {
if (!TimeInterval_default.equals(intervals[i], rightIntervals[i], dataComparer)) {
return false;
}
}
return true;
};
TimeIntervalCollection.prototype.get = function(index) {
if (!defined_default(index)) {
throw new DeveloperError_default("index is required.");
}
return this._intervals[index];
};
TimeIntervalCollection.prototype.removeAll = function() {
if (this._intervals.length > 0) {
this._intervals.length = 0;
this._changedEvent.raiseEvent(this);
}
};
TimeIntervalCollection.prototype.findIntervalContainingDate = function(date) {
const index = this.indexOf(date);
return index >= 0 ? this._intervals[index] : void 0;
};
TimeIntervalCollection.prototype.findDataForIntervalContainingDate = function(date) {
const index = this.indexOf(date);
return index >= 0 ? this._intervals[index].data : void 0;
};
TimeIntervalCollection.prototype.contains = function(julianDate) {
return this.indexOf(julianDate) >= 0;
};
var indexOfScratch = new TimeInterval_default();
TimeIntervalCollection.prototype.indexOf = function(date) {
if (!defined_default(date)) {
throw new DeveloperError_default("date is required");
}
const intervals = this._intervals;
indexOfScratch.start = date;
indexOfScratch.stop = date;
let index = binarySearch_default(
intervals,
indexOfScratch,
compareIntervalStartTimes
);
if (index >= 0) {
if (intervals[index].isStartIncluded) {
return index;
}
if (index > 0 && intervals[index - 1].stop.equals(date) && intervals[index - 1].isStopIncluded) {
return index - 1;
}
return ~index;
}
index = ~index;
if (index > 0 && index - 1 < intervals.length && TimeInterval_default.contains(intervals[index - 1], date)) {
return index - 1;
}
return ~index;
};
TimeIntervalCollection.prototype.findInterval = function(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
const start = options.start;
const stop2 = options.stop;
const isStartIncluded = options.isStartIncluded;
const isStopIncluded = options.isStopIncluded;
const intervals = this._intervals;
for (let i = 0, len = intervals.length; i < len; i++) {
const interval = intervals[i];
if ((!defined_default(start) || interval.start.equals(start)) && (!defined_default(stop2) || interval.stop.equals(stop2)) && (!defined_default(isStartIncluded) || interval.isStartIncluded === isStartIncluded) && (!defined_default(isStopIncluded) || interval.isStopIncluded === isStopIncluded)) {
return intervals[i];
}
}
return void 0;
};
TimeIntervalCollection.prototype.addInterval = function(interval, dataComparer) {
if (!defined_default(interval)) {
throw new DeveloperError_default("interval is required");
}
if (interval.isEmpty) {
return;
}
const intervals = this._intervals;
if (intervals.length === 0 || JulianDate_default.greaterThan(interval.start, intervals[intervals.length - 1].stop)) {
intervals.push(interval);
this._changedEvent.raiseEvent(this);
return;
}
let index = binarySearch_default(intervals, interval, compareIntervalStartTimes);
if (index < 0) {
index = ~index;
} else {
if (index > 0 && interval.isStartIncluded && intervals[index - 1].isStartIncluded && intervals[index - 1].start.equals(interval.start)) {
--index;
} else if (index < intervals.length && !interval.isStartIncluded && intervals[index].isStartIncluded && intervals[index].start.equals(interval.start)) {
++index;
}
}
let comparison;
if (index > 0) {
comparison = JulianDate_default.compare(intervals[index - 1].stop, interval.start);
if (comparison > 0 || comparison === 0 && (intervals[index - 1].isStopIncluded || interval.isStartIncluded)) {
if (defined_default(dataComparer) ? dataComparer(intervals[index - 1].data, interval.data) : intervals[index - 1].data === interval.data) {
if (JulianDate_default.greaterThan(interval.stop, intervals[index - 1].stop)) {
interval = new TimeInterval_default({
start: intervals[index - 1].start,
stop: interval.stop,
isStartIncluded: intervals[index - 1].isStartIncluded,
isStopIncluded: interval.isStopIncluded,
data: interval.data
});
} else {
interval = new TimeInterval_default({
start: intervals[index - 1].start,
stop: intervals[index - 1].stop,
isStartIncluded: intervals[index - 1].isStartIncluded,
isStopIncluded: intervals[index - 1].isStopIncluded || interval.stop.equals(intervals[index - 1].stop) && interval.isStopIncluded,
data: interval.data
});
}
intervals.splice(index - 1, 1);
--index;
} else {
comparison = JulianDate_default.compare(
intervals[index - 1].stop,
interval.stop
);
if (comparison > 0 || comparison === 0 && intervals[index - 1].isStopIncluded && !interval.isStopIncluded) {
intervals.splice(
index,
0,
new TimeInterval_default({
start: interval.stop,
stop: intervals[index - 1].stop,
isStartIncluded: !interval.isStopIncluded,
isStopIncluded: intervals[index - 1].isStopIncluded,
data: intervals[index - 1].data
})
);
}
intervals[index - 1] = new TimeInterval_default({
start: intervals[index - 1].start,
stop: interval.start,
isStartIncluded: intervals[index - 1].isStartIncluded,
isStopIncluded: !interval.isStartIncluded,
data: intervals[index - 1].data
});
}
}
}
while (index < intervals.length) {
comparison = JulianDate_default.compare(interval.stop, intervals[index].start);
if (comparison > 0 || comparison === 0 && (interval.isStopIncluded || intervals[index].isStartIncluded)) {
if (defined_default(dataComparer) ? dataComparer(intervals[index].data, interval.data) : intervals[index].data === interval.data) {
interval = new TimeInterval_default({
start: interval.start,
stop: JulianDate_default.greaterThan(intervals[index].stop, interval.stop) ? intervals[index].stop : interval.stop,
isStartIncluded: interval.isStartIncluded,
isStopIncluded: JulianDate_default.greaterThan(
intervals[index].stop,
interval.stop
) ? intervals[index].isStopIncluded : interval.isStopIncluded,
data: interval.data
});
intervals.splice(index, 1);
} else {
intervals[index] = new TimeInterval_default({
start: interval.stop,
stop: intervals[index].stop,
isStartIncluded: !interval.isStopIncluded,
isStopIncluded: intervals[index].isStopIncluded,
data: intervals[index].data
});
if (intervals[index].isEmpty) {
intervals.splice(index, 1);
} else {
break;
}
}
} else {
break;
}
}
intervals.splice(index, 0, interval);
this._changedEvent.raiseEvent(this);
};
TimeIntervalCollection.prototype.removeInterval = function(interval) {
if (!defined_default(interval)) {
throw new DeveloperError_default("interval is required");
}
if (interval.isEmpty) {
return false;
}
const intervals = this._intervals;
let index = binarySearch_default(intervals, interval, compareIntervalStartTimes);
if (index < 0) {
index = ~index;
}
let result = false;
if (index > 0 && (JulianDate_default.greaterThan(intervals[index - 1].stop, interval.start) || intervals[index - 1].stop.equals(interval.start) && intervals[index - 1].isStopIncluded && interval.isStartIncluded)) {
result = true;
if (JulianDate_default.greaterThan(intervals[index - 1].stop, interval.stop) || intervals[index - 1].isStopIncluded && !interval.isStopIncluded && intervals[index - 1].stop.equals(interval.stop)) {
intervals.splice(
index,
0,
new TimeInterval_default({
start: interval.stop,
stop: intervals[index - 1].stop,
isStartIncluded: !interval.isStopIncluded,
isStopIncluded: intervals[index - 1].isStopIncluded,
data: intervals[index - 1].data
})
);
}
intervals[index - 1] = new TimeInterval_default({
start: intervals[index - 1].start,
stop: interval.start,
isStartIncluded: intervals[index - 1].isStartIncluded,
isStopIncluded: !interval.isStartIncluded,
data: intervals[index - 1].data
});
}
if (index < intervals.length && !interval.isStartIncluded && intervals[index].isStartIncluded && interval.start.equals(intervals[index].start)) {
result = true;
intervals.splice(
index,
0,
new TimeInterval_default({
start: intervals[index].start,
stop: intervals[index].start,
isStartIncluded: true,
isStopIncluded: true,
data: intervals[index].data
})
);
++index;
}
while (index < intervals.length && JulianDate_default.greaterThan(interval.stop, intervals[index].stop)) {
result = true;
intervals.splice(index, 1);
}
if (index < intervals.length && interval.stop.equals(intervals[index].stop)) {
result = true;
if (!interval.isStopIncluded && intervals[index].isStopIncluded) {
if (index + 1 < intervals.length && intervals[index + 1].start.equals(interval.stop) && intervals[index].data === intervals[index + 1].data) {
intervals.splice(index, 1);
intervals[index] = new TimeInterval_default({
start: intervals[index].start,
stop: intervals[index].stop,
isStartIncluded: true,
isStopIncluded: intervals[index].isStopIncluded,
data: intervals[index].data
});
} else {
intervals[index] = new TimeInterval_default({
start: interval.stop,
stop: interval.stop,
isStartIncluded: true,
isStopIncluded: true,
data: intervals[index].data
});
}
} else {
intervals.splice(index, 1);
}
}
if (index < intervals.length && (JulianDate_default.greaterThan(interval.stop, intervals[index].start) || interval.stop.equals(intervals[index].start) && interval.isStopIncluded && intervals[index].isStartIncluded)) {
result = true;
intervals[index] = new TimeInterval_default({
start: interval.stop,
stop: intervals[index].stop,
isStartIncluded: !interval.isStopIncluded,
isStopIncluded: intervals[index].isStopIncluded,
data: intervals[index].data
});
}
if (result) {
this._changedEvent.raiseEvent(this);
}
return result;
};
TimeIntervalCollection.prototype.intersect = function(other, dataComparer, mergeCallback) {
if (!defined_default(other)) {
throw new DeveloperError_default("other is required.");
}
const result = new TimeIntervalCollection();
let left = 0;
let right = 0;
const intervals = this._intervals;
const otherIntervals = other._intervals;
while (left < intervals.length && right < otherIntervals.length) {
const leftInterval = intervals[left];
const rightInterval = otherIntervals[right];
if (JulianDate_default.lessThan(leftInterval.stop, rightInterval.start)) {
++left;
} else if (JulianDate_default.lessThan(rightInterval.stop, leftInterval.start)) {
++right;
} else {
if (defined_default(mergeCallback) || defined_default(dataComparer) && dataComparer(leftInterval.data, rightInterval.data) || !defined_default(dataComparer) && rightInterval.data === leftInterval.data) {
const intersection = TimeInterval_default.intersect(
leftInterval,
rightInterval,
new TimeInterval_default(),
mergeCallback
);
if (!intersection.isEmpty) {
result.addInterval(intersection, dataComparer);
}
}
if (JulianDate_default.lessThan(leftInterval.stop, rightInterval.stop) || leftInterval.stop.equals(rightInterval.stop) && !leftInterval.isStopIncluded && rightInterval.isStopIncluded) {
++left;
} else {
++right;
}
}
}
return result;
};
TimeIntervalCollection.fromJulianDateArray = function(options, result) {
if (!defined_default(options)) {
throw new DeveloperError_default("options is required.");
}
if (!defined_default(options.julianDates)) {
throw new DeveloperError_default("options.iso8601Array is required.");
}
if (!defined_default(result)) {
result = new TimeIntervalCollection();
}
const julianDates = options.julianDates;
const length3 = julianDates.length;
const dataCallback = options.dataCallback;
const isStartIncluded = defaultValue_default(options.isStartIncluded, true);
const isStopIncluded = defaultValue_default(options.isStopIncluded, true);
const leadingInterval = defaultValue_default(options.leadingInterval, false);
const trailingInterval = defaultValue_default(options.trailingInterval, false);
let interval;
let startIndex = 0;
if (leadingInterval) {
++startIndex;
interval = new TimeInterval_default({
start: Iso8601_default.MINIMUM_VALUE,
stop: julianDates[0],
isStartIncluded: true,
isStopIncluded: !isStartIncluded
});
interval.data = defined_default(dataCallback) ? dataCallback(interval, result.length) : result.length;
result.addInterval(interval);
}
for (let i = 0; i < length3 - 1; ++i) {
let startDate = julianDates[i];
const endDate = julianDates[i + 1];
interval = new TimeInterval_default({
start: startDate,
stop: endDate,
isStartIncluded: result.length === startIndex ? isStartIncluded : true,
isStopIncluded: i === length3 - 2 ? isStopIncluded : false
});
interval.data = defined_default(dataCallback) ? dataCallback(interval, result.length) : result.length;
result.addInterval(interval);
startDate = endDate;
}
if (trailingInterval) {
interval = new TimeInterval_default({
start: julianDates[length3 - 1],
stop: Iso8601_default.MAXIMUM_VALUE,
isStartIncluded: !isStopIncluded,
isStopIncluded: true
});
interval.data = defined_default(dataCallback) ? dataCallback(interval, result.length) : result.length;
result.addInterval(interval);
}
return result;
};
var scratchGregorianDate = new GregorianDate_default();
var monthLengths = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
function addToDate(julianDate, duration, result) {
if (!defined_default(result)) {
result = new JulianDate_default();
}
JulianDate_default.toGregorianDate(julianDate, scratchGregorianDate);
let millisecond = scratchGregorianDate.millisecond + duration.millisecond;
let second = scratchGregorianDate.second + duration.second;
let minute = scratchGregorianDate.minute + duration.minute;
let hour = scratchGregorianDate.hour + duration.hour;
let day = scratchGregorianDate.day + duration.day;
let month = scratchGregorianDate.month + duration.month;
let year = scratchGregorianDate.year + duration.year;
if (millisecond >= 1e3) {
second += Math.floor(millisecond / 1e3);
millisecond = millisecond % 1e3;
}
if (second >= 60) {
minute += Math.floor(second / 60);
second = second % 60;
}
if (minute >= 60) {
hour += Math.floor(minute / 60);
minute = minute % 60;
}
if (hour >= 24) {
day += Math.floor(hour / 24);
hour = hour % 24;
}
monthLengths[2] = isLeapYear_default(year) ? 29 : 28;
while (day > monthLengths[month] || month >= 13) {
if (day > monthLengths[month]) {
day -= monthLengths[month];
++month;
}
if (month >= 13) {
--month;
year += Math.floor(month / 12);
month = month % 12;
++month;
}
monthLengths[2] = isLeapYear_default(year) ? 29 : 28;
}
scratchGregorianDate.millisecond = millisecond;
scratchGregorianDate.second = second;
scratchGregorianDate.minute = minute;
scratchGregorianDate.hour = hour;
scratchGregorianDate.day = day;
scratchGregorianDate.month = month;
scratchGregorianDate.year = year;
return JulianDate_default.fromGregorianDate(scratchGregorianDate, result);
}
var scratchJulianDate = new JulianDate_default();
var durationRegex = /P(?:([\d.,]+)Y)?(?:([\d.,]+)M)?(?:([\d.,]+)W)?(?:([\d.,]+)D)?(?:T(?:([\d.,]+)H)?(?:([\d.,]+)M)?(?:([\d.,]+)S)?)?/;
function parseDuration(iso8601, result) {
if (!defined_default(iso8601) || iso8601.length === 0) {
return false;
}
result.year = 0;
result.month = 0;
result.day = 0;
result.hour = 0;
result.minute = 0;
result.second = 0;
result.millisecond = 0;
if (iso8601[0] === "P") {
const matches = iso8601.match(durationRegex);
if (!defined_default(matches)) {
return false;
}
if (defined_default(matches[1])) {
result.year = Number(matches[1].replace(",", "."));
}
if (defined_default(matches[2])) {
result.month = Number(matches[2].replace(",", "."));
}
if (defined_default(matches[3])) {
result.day = Number(matches[3].replace(",", ".")) * 7;
}
if (defined_default(matches[4])) {
result.day += Number(matches[4].replace(",", "."));
}
if (defined_default(matches[5])) {
result.hour = Number(matches[5].replace(",", "."));
}
if (defined_default(matches[6])) {
result.minute = Number(matches[6].replace(",", "."));
}
if (defined_default(matches[7])) {
const seconds = Number(matches[7].replace(",", "."));
result.second = Math.floor(seconds);
result.millisecond = seconds % 1 * 1e3;
}
} else {
if (iso8601[iso8601.length - 1] !== "Z") {
iso8601 += "Z";
}
JulianDate_default.toGregorianDate(
JulianDate_default.fromIso8601(iso8601, scratchJulianDate),
result
);
}
return result.year || result.month || result.day || result.hour || result.minute || result.second || result.millisecond;
}
var scratchDuration = new GregorianDate_default();
TimeIntervalCollection.fromIso8601 = function(options, result) {
if (!defined_default(options)) {
throw new DeveloperError_default("options is required.");
}
if (!defined_default(options.iso8601)) {
throw new DeveloperError_default("options.iso8601 is required.");
}
const dates = options.iso8601.split("/");
const start = JulianDate_default.fromIso8601(dates[0]);
const stop2 = JulianDate_default.fromIso8601(dates[1]);
const julianDates = [];
if (!parseDuration(dates[2], scratchDuration)) {
julianDates.push(start, stop2);
} else {
let date = JulianDate_default.clone(start);
julianDates.push(date);
while (JulianDate_default.compare(date, stop2) < 0) {
date = addToDate(date, scratchDuration);
const afterStop = JulianDate_default.compare(stop2, date) <= 0;
if (afterStop) {
JulianDate_default.clone(stop2, date);
}
julianDates.push(date);
}
}
return TimeIntervalCollection.fromJulianDateArray(
{
julianDates,
isStartIncluded: options.isStartIncluded,
isStopIncluded: options.isStopIncluded,
leadingInterval: options.leadingInterval,
trailingInterval: options.trailingInterval,
dataCallback: options.dataCallback
},
result
);
};
TimeIntervalCollection.fromIso8601DateArray = function(options, result) {
if (!defined_default(options)) {
throw new DeveloperError_default("options is required.");
}
if (!defined_default(options.iso8601Dates)) {
throw new DeveloperError_default("options.iso8601Dates is required.");
}
return TimeIntervalCollection.fromJulianDateArray(
{
julianDates: options.iso8601Dates.map(function(date) {
return JulianDate_default.fromIso8601(date);
}),
isStartIncluded: options.isStartIncluded,
isStopIncluded: options.isStopIncluded,
leadingInterval: options.leadingInterval,
trailingInterval: options.trailingInterval,
dataCallback: options.dataCallback
},
result
);
};
TimeIntervalCollection.fromIso8601DurationArray = function(options, result) {
if (!defined_default(options)) {
throw new DeveloperError_default("options is required.");
}
if (!defined_default(options.epoch)) {
throw new DeveloperError_default("options.epoch is required.");
}
if (!defined_default(options.iso8601Durations)) {
throw new DeveloperError_default("options.iso8601Durations is required.");
}
const epoch2 = options.epoch;
const iso8601Durations = options.iso8601Durations;
const relativeToPrevious = defaultValue_default(options.relativeToPrevious, false);
const julianDates = [];
let date, previousDate;
const length3 = iso8601Durations.length;
for (let i = 0; i < length3; ++i) {
if (parseDuration(iso8601Durations[i], scratchDuration) || i === 0) {
if (relativeToPrevious && defined_default(previousDate)) {
date = addToDate(previousDate, scratchDuration);
} else {
date = addToDate(epoch2, scratchDuration);
}
julianDates.push(date);
previousDate = date;
}
}
return TimeIntervalCollection.fromJulianDateArray(
{
julianDates,
isStartIncluded: options.isStartIncluded,
isStopIncluded: options.isStopIncluded,
leadingInterval: options.leadingInterval,
trailingInterval: options.trailingInterval,
dataCallback: options.dataCallback
},
result
);
};
var TimeIntervalCollection_default = TimeIntervalCollection;
// Source/Core/TranslationRotationScale.js
var defaultScale = new Cartesian3_default(1, 1, 1);
var defaultTranslation = Cartesian3_default.ZERO;
var defaultRotation = Quaternion_default.IDENTITY;
function TranslationRotationScale(translation3, rotation, scale) {
this.translation = Cartesian3_default.clone(
defaultValue_default(translation3, defaultTranslation)
);
this.rotation = Quaternion_default.clone(defaultValue_default(rotation, defaultRotation));
this.scale = Cartesian3_default.clone(defaultValue_default(scale, defaultScale));
}
TranslationRotationScale.prototype.equals = function(right) {
return this === right || defined_default(right) && Cartesian3_default.equals(this.translation, right.translation) && Quaternion_default.equals(this.rotation, right.rotation) && Cartesian3_default.equals(this.scale, right.scale);
};
var TranslationRotationScale_default = TranslationRotationScale;
// Source/Core/VideoSynchronizer.js
function VideoSynchronizer(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
this._clock = void 0;
this._element = void 0;
this._clockSubscription = void 0;
this._seekFunction = void 0;
this._lastPlaybackRate = void 0;
this.clock = options.clock;
this.element = options.element;
this.epoch = defaultValue_default(options.epoch, Iso8601_default.MINIMUM_VALUE);
this.tolerance = defaultValue_default(options.tolerance, 1);
this._seeking = false;
this._seekFunction = void 0;
this._firstTickAfterSeek = false;
}
Object.defineProperties(VideoSynchronizer.prototype, {
clock: {
get: function() {
return this._clock;
},
set: function(value) {
const oldValue2 = this._clock;
if (oldValue2 === value) {
return;
}
if (defined_default(oldValue2)) {
this._clockSubscription();
this._clockSubscription = void 0;
}
if (defined_default(value)) {
this._clockSubscription = value.onTick.addEventListener(
VideoSynchronizer.prototype._onTick,
this
);
}
this._clock = value;
}
},
element: {
get: function() {
return this._element;
},
set: function(value) {
const oldValue2 = this._element;
if (oldValue2 === value) {
return;
}
if (defined_default(oldValue2)) {
oldValue2.removeEventListener("seeked", this._seekFunction, false);
}
if (defined_default(value)) {
this._seeking = false;
this._seekFunction = createSeekFunction(this);
value.addEventListener("seeked", this._seekFunction, false);
}
this._element = value;
this._seeking = false;
this._firstTickAfterSeek = false;
}
}
});
VideoSynchronizer.prototype.destroy = function() {
this.element = void 0;
this.clock = void 0;
return destroyObject_default(this);
};
VideoSynchronizer.prototype.isDestroyed = function() {
return false;
};
VideoSynchronizer.prototype._trySetPlaybackRate = function(clock) {
if (this._lastPlaybackRate === clock.multiplier) {
return;
}
const element = this._element;
try {
element.playbackRate = clock.multiplier;
} catch (error) {
element.playbackRate = 0;
}
this._lastPlaybackRate = clock.multiplier;
};
VideoSynchronizer.prototype._onTick = function(clock) {
const element = this._element;
if (!defined_default(element) || element.readyState < 2) {
return;
}
const paused = element.paused;
const shouldAnimate = clock.shouldAnimate;
if (shouldAnimate === paused) {
if (shouldAnimate) {
element.play();
} else {
element.pause();
}
}
if (this._seeking || this._firstTickAfterSeek) {
this._firstTickAfterSeek = false;
return;
}
this._trySetPlaybackRate(clock);
const clockTime = clock.currentTime;
const epoch2 = defaultValue_default(this.epoch, Iso8601_default.MINIMUM_VALUE);
let videoTime = JulianDate_default.secondsDifference(clockTime, epoch2);
const duration = element.duration;
let desiredTime;
const currentTime = element.currentTime;
if (element.loop) {
videoTime = videoTime % duration;
if (videoTime < 0) {
videoTime = duration - videoTime;
}
desiredTime = videoTime;
} else if (videoTime > duration) {
desiredTime = duration;
} else if (videoTime < 0) {
desiredTime = 0;
} else {
desiredTime = videoTime;
}
const tolerance = shouldAnimate ? defaultValue_default(this.tolerance, 1) : 1e-3;
if (Math.abs(desiredTime - currentTime) > tolerance) {
this._seeking = true;
element.currentTime = desiredTime;
}
};
function createSeekFunction(that) {
return function() {
that._seeking = false;
that._firstTickAfterSeek = true;
};
}
var VideoSynchronizer_default = VideoSynchronizer;
// Source/Core/VRTheWorldTerrainProvider.js
function DataRectangle(rectangle, maxLevel) {
this.rectangle = rectangle;
this.maxLevel = maxLevel;
}
function VRTheWorldTerrainProvider(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
if (!defined_default(options.url)) {
throw new DeveloperError_default("options.url is required.");
}
const resource = Resource_default.createIfNeeded(options.url);
this._resource = resource;
this._errorEvent = new Event_default();
this._ready = false;
this._terrainDataStructure = {
heightScale: 1 / 1e3,
heightOffset: -1e3,
elementsPerHeight: 3,
stride: 4,
elementMultiplier: 256,
isBigEndian: true,
lowestEncodedHeight: 0,
highestEncodedHeight: 256 * 256 * 256 - 1
};
let credit = options.credit;
if (typeof credit === "string") {
credit = new Credit_default(credit);
}
this._credit = credit;
this._tilingScheme = void 0;
this._rectangles = [];
const that = this;
let metadataError;
const ellipsoid = defaultValue_default(options.ellipsoid, Ellipsoid_default.WGS84);
function metadataSuccess(xml) {
const srs = xml.getElementsByTagName("SRS")[0].textContent;
if (srs === "EPSG:4326") {
that._tilingScheme = new GeographicTilingScheme_default({ ellipsoid });
} else {
return Promise.reject(new RuntimeError_default(`SRS ${srs} is not supported.`));
}
const tileFormat = xml.getElementsByTagName("TileFormat")[0];
that._heightmapWidth = parseInt(tileFormat.getAttribute("width"), 10);
that._heightmapHeight = parseInt(tileFormat.getAttribute("height"), 10);
that._levelZeroMaximumGeometricError = TerrainProvider_default.getEstimatedLevelZeroGeometricErrorForAHeightmap(
ellipsoid,
Math.min(that._heightmapWidth, that._heightmapHeight),
that._tilingScheme.getNumberOfXTilesAtLevel(0)
);
const dataRectangles = xml.getElementsByTagName("DataExtent");
for (let i = 0; i < dataRectangles.length; ++i) {
const dataRectangle = dataRectangles[i];
const west = Math_default.toRadians(
parseFloat(dataRectangle.getAttribute("minx"))
);
const south = Math_default.toRadians(
parseFloat(dataRectangle.getAttribute("miny"))
);
const east = Math_default.toRadians(
parseFloat(dataRectangle.getAttribute("maxx"))
);
const north = Math_default.toRadians(
parseFloat(dataRectangle.getAttribute("maxy"))
);
const maxLevel = parseInt(dataRectangle.getAttribute("maxlevel"), 10);
that._rectangles.push(
new DataRectangle(new Rectangle_default(west, south, east, north), maxLevel)
);
}
that._ready = true;
return Promise.resolve(true);
}
function metadataFailure(e) {
const message = defaultValue_default(
defined_default(e) ? e.message : void 0,
`An error occurred while accessing ${that._resource.url}.`
);
metadataError = TileProviderError_default.reportError(
metadataError,
that,
that._errorEvent,
message
);
if (metadataError.retry) {
return requestMetadata();
}
return Promise.reject(new RuntimeError_default(message));
}
function requestMetadata() {
return that._resource.fetchXML().then(metadataSuccess).catch(metadataFailure);
}
this._readyPromise = requestMetadata();
}
Object.defineProperties(VRTheWorldTerrainProvider.prototype, {
errorEvent: {
get: function() {
return this._errorEvent;
}
},
credit: {
get: function() {
return this._credit;
}
},
tilingScheme: {
get: function() {
if (!this.ready) {
throw new DeveloperError_default(
"requestTileGeometry must not be called before ready returns true."
);
}
return this._tilingScheme;
}
},
ready: {
get: function() {
return this._ready;
}
},
readyPromise: {
get: function() {
return this._readyPromise;
}
},
hasWaterMask: {
get: function() {
return false;
}
},
hasVertexNormals: {
get: function() {
return false;
}
},
availability: {
get: function() {
return void 0;
}
}
});
VRTheWorldTerrainProvider.prototype.requestTileGeometry = function(x, y, level, request) {
if (!this.ready) {
throw new DeveloperError_default(
"requestTileGeometry must not be called before ready returns true."
);
}
const yTiles = this._tilingScheme.getNumberOfYTilesAtLevel(level);
const resource = this._resource.getDerivedResource({
url: `${level}/${x}/${yTiles - y - 1}.tif`,
queryParameters: {
cesium: true
},
request
});
const promise = resource.fetchImage({
preferImageBitmap: true
});
if (!defined_default(promise)) {
return void 0;
}
const that = this;
return Promise.resolve(promise).then(function(image) {
return new HeightmapTerrainData_default({
buffer: getImagePixels_default(image),
width: that._heightmapWidth,
height: that._heightmapHeight,
childTileMask: getChildMask(that, x, y, level),
structure: that._terrainDataStructure
});
});
};
VRTheWorldTerrainProvider.prototype.getLevelMaximumGeometricError = function(level) {
if (!this.ready) {
throw new DeveloperError_default(
"requestTileGeometry must not be called before ready returns true."
);
}
return this._levelZeroMaximumGeometricError / (1 << level);
};
var rectangleScratch5 = new Rectangle_default();
function getChildMask(provider, x, y, level) {
const tilingScheme2 = provider._tilingScheme;
const rectangles = provider._rectangles;
const parentRectangle = tilingScheme2.tileXYToRectangle(x, y, level);
let childMask = 0;
for (let i = 0; i < rectangles.length && childMask !== 15; ++i) {
const rectangle = rectangles[i];
if (rectangle.maxLevel <= level) {
continue;
}
const testRectangle = rectangle.rectangle;
const intersection = Rectangle_default.intersection(
testRectangle,
parentRectangle,
rectangleScratch5
);
if (defined_default(intersection)) {
if (isTileInRectangle(tilingScheme2, testRectangle, x * 2, y * 2, level + 1)) {
childMask |= 4;
}
if (isTileInRectangle(
tilingScheme2,
testRectangle,
x * 2 + 1,
y * 2,
level + 1
)) {
childMask |= 8;
}
if (isTileInRectangle(
tilingScheme2,
testRectangle,
x * 2,
y * 2 + 1,
level + 1
)) {
childMask |= 1;
}
if (isTileInRectangle(
tilingScheme2,
testRectangle,
x * 2 + 1,
y * 2 + 1,
level + 1
)) {
childMask |= 2;
}
}
}
return childMask;
}
function isTileInRectangle(tilingScheme2, rectangle, x, y, level) {
const tileRectangle = tilingScheme2.tileXYToRectangle(x, y, level);
return defined_default(
Rectangle_default.intersection(tileRectangle, rectangle, rectangleScratch5)
);
}
VRTheWorldTerrainProvider.prototype.getTileDataAvailable = function(x, y, level) {
return void 0;
};
VRTheWorldTerrainProvider.prototype.loadTileDataAvailability = function(x, y, level) {
return void 0;
};
var VRTheWorldTerrainProvider_default = VRTheWorldTerrainProvider;
// Source/Core/VulkanConstants.js
var VulkanConstants = {
VK_FORMAT_UNDEFINED: 0,
VK_FORMAT_R4G4_UNORM_PACK8: 1,
VK_FORMAT_R4G4B4A4_UNORM_PACK16: 2,
VK_FORMAT_B4G4R4A4_UNORM_PACK16: 3,
VK_FORMAT_R5G6B5_UNORM_PACK16: 4,
VK_FORMAT_B5G6R5_UNORM_PACK16: 5,
VK_FORMAT_R5G5B5A1_UNORM_PACK16: 6,
VK_FORMAT_B5G5R5A1_UNORM_PACK16: 7,
VK_FORMAT_A1R5G5B5_UNORM_PACK16: 8,
VK_FORMAT_R8_UNORM: 9,
VK_FORMAT_R8_SNORM: 10,
VK_FORMAT_R8_USCALED: 11,
VK_FORMAT_R8_SSCALED: 12,
VK_FORMAT_R8_UINT: 13,
VK_FORMAT_R8_SINT: 14,
VK_FORMAT_R8_SRGB: 15,
VK_FORMAT_R8G8_UNORM: 16,
VK_FORMAT_R8G8_SNORM: 17,
VK_FORMAT_R8G8_USCALED: 18,
VK_FORMAT_R8G8_SSCALED: 19,
VK_FORMAT_R8G8_UINT: 20,
VK_FORMAT_R8G8_SINT: 21,
VK_FORMAT_R8G8_SRGB: 22,
VK_FORMAT_R8G8B8_UNORM: 23,
VK_FORMAT_R8G8B8_SNORM: 24,
VK_FORMAT_R8G8B8_USCALED: 25,
VK_FORMAT_R8G8B8_SSCALED: 26,
VK_FORMAT_R8G8B8_UINT: 27,
VK_FORMAT_R8G8B8_SINT: 28,
VK_FORMAT_R8G8B8_SRGB: 29,
VK_FORMAT_B8G8R8_UNORM: 30,
VK_FORMAT_B8G8R8_SNORM: 31,
VK_FORMAT_B8G8R8_USCALED: 32,
VK_FORMAT_B8G8R8_SSCALED: 33,
VK_FORMAT_B8G8R8_UINT: 34,
VK_FORMAT_B8G8R8_SINT: 35,
VK_FORMAT_B8G8R8_SRGB: 36,
VK_FORMAT_R8G8B8A8_UNORM: 37,
VK_FORMAT_R8G8B8A8_SNORM: 38,
VK_FORMAT_R8G8B8A8_USCALED: 39,
VK_FORMAT_R8G8B8A8_SSCALED: 40,
VK_FORMAT_R8G8B8A8_UINT: 41,
VK_FORMAT_R8G8B8A8_SINT: 42,
VK_FORMAT_R8G8B8A8_SRGB: 43,
VK_FORMAT_B8G8R8A8_UNORM: 44,
VK_FORMAT_B8G8R8A8_SNORM: 45,
VK_FORMAT_B8G8R8A8_USCALED: 46,
VK_FORMAT_B8G8R8A8_SSCALED: 47,
VK_FORMAT_B8G8R8A8_UINT: 48,
VK_FORMAT_B8G8R8A8_SINT: 49,
VK_FORMAT_B8G8R8A8_SRGB: 50,
VK_FORMAT_A8B8G8R8_UNORM_PACK32: 51,
VK_FORMAT_A8B8G8R8_SNORM_PACK32: 52,
VK_FORMAT_A8B8G8R8_USCALED_PACK32: 53,
VK_FORMAT_A8B8G8R8_SSCALED_PACK32: 54,
VK_FORMAT_A8B8G8R8_UINT_PACK32: 55,
VK_FORMAT_A8B8G8R8_SINT_PACK32: 56,
VK_FORMAT_A8B8G8R8_SRGB_PACK32: 57,
VK_FORMAT_A2R10G10B10_UNORM_PACK32: 58,
VK_FORMAT_A2R10G10B10_SNORM_PACK32: 59,
VK_FORMAT_A2R10G10B10_USCALED_PACK32: 60,
VK_FORMAT_A2R10G10B10_SSCALED_PACK32: 61,
VK_FORMAT_A2R10G10B10_UINT_PACK32: 62,
VK_FORMAT_A2R10G10B10_SINT_PACK32: 63,
VK_FORMAT_A2B10G10R10_UNORM_PACK32: 64,
VK_FORMAT_A2B10G10R10_SNORM_PACK32: 65,
VK_FORMAT_A2B10G10R10_USCALED_PACK32: 66,
VK_FORMAT_A2B10G10R10_SSCALED_PACK32: 67,
VK_FORMAT_A2B10G10R10_UINT_PACK32: 68,
VK_FORMAT_A2B10G10R10_SINT_PACK32: 69,
VK_FORMAT_R16_UNORM: 70,
VK_FORMAT_R16_SNORM: 71,
VK_FORMAT_R16_USCALED: 72,
VK_FORMAT_R16_SSCALED: 73,
VK_FORMAT_R16_UINT: 74,
VK_FORMAT_R16_SINT: 75,
VK_FORMAT_R16_SFLOAT: 76,
VK_FORMAT_R16G16_UNORM: 77,
VK_FORMAT_R16G16_SNORM: 78,
VK_FORMAT_R16G16_USCALED: 79,
VK_FORMAT_R16G16_SSCALED: 80,
VK_FORMAT_R16G16_UINT: 81,
VK_FORMAT_R16G16_SINT: 82,
VK_FORMAT_R16G16_SFLOAT: 83,
VK_FORMAT_R16G16B16_UNORM: 84,
VK_FORMAT_R16G16B16_SNORM: 85,
VK_FORMAT_R16G16B16_USCALED: 86,
VK_FORMAT_R16G16B16_SSCALED: 87,
VK_FORMAT_R16G16B16_UINT: 88,
VK_FORMAT_R16G16B16_SINT: 89,
VK_FORMAT_R16G16B16_SFLOAT: 90,
VK_FORMAT_R16G16B16A16_UNORM: 91,
VK_FORMAT_R16G16B16A16_SNORM: 92,
VK_FORMAT_R16G16B16A16_USCALED: 93,
VK_FORMAT_R16G16B16A16_SSCALED: 94,
VK_FORMAT_R16G16B16A16_UINT: 95,
VK_FORMAT_R16G16B16A16_SINT: 96,
VK_FORMAT_R16G16B16A16_SFLOAT: 97,
VK_FORMAT_R32_UINT: 98,
VK_FORMAT_R32_SINT: 99,
VK_FORMAT_R32_SFLOAT: 100,
VK_FORMAT_R32G32_UINT: 101,
VK_FORMAT_R32G32_SINT: 102,
VK_FORMAT_R32G32_SFLOAT: 103,
VK_FORMAT_R32G32B32_UINT: 104,
VK_FORMAT_R32G32B32_SINT: 105,
VK_FORMAT_R32G32B32_SFLOAT: 106,
VK_FORMAT_R32G32B32A32_UINT: 107,
VK_FORMAT_R32G32B32A32_SINT: 108,
VK_FORMAT_R32G32B32A32_SFLOAT: 109,
VK_FORMAT_R64_UINT: 110,
VK_FORMAT_R64_SINT: 111,
VK_FORMAT_R64_SFLOAT: 112,
VK_FORMAT_R64G64_UINT: 113,
VK_FORMAT_R64G64_SINT: 114,
VK_FORMAT_R64G64_SFLOAT: 115,
VK_FORMAT_R64G64B64_UINT: 116,
VK_FORMAT_R64G64B64_SINT: 117,
VK_FORMAT_R64G64B64_SFLOAT: 118,
VK_FORMAT_R64G64B64A64_UINT: 119,
VK_FORMAT_R64G64B64A64_SINT: 120,
VK_FORMAT_R64G64B64A64_SFLOAT: 121,
VK_FORMAT_B10G11R11_UFLOAT_PACK32: 122,
VK_FORMAT_E5B9G9R9_UFLOAT_PACK32: 123,
VK_FORMAT_D16_UNORM: 124,
VK_FORMAT_X8_D24_UNORM_PACK32: 125,
VK_FORMAT_D32_SFLOAT: 126,
VK_FORMAT_S8_UINT: 127,
VK_FORMAT_D16_UNORM_S8_UINT: 128,
VK_FORMAT_D24_UNORM_S8_UINT: 129,
VK_FORMAT_D32_SFLOAT_S8_UINT: 130,
VK_FORMAT_BC1_RGB_UNORM_BLOCK: 131,
VK_FORMAT_BC1_RGB_SRGB_BLOCK: 132,
VK_FORMAT_BC1_RGBA_UNORM_BLOCK: 133,
VK_FORMAT_BC1_RGBA_SRGB_BLOCK: 134,
VK_FORMAT_BC2_UNORM_BLOCK: 135,
VK_FORMAT_BC2_SRGB_BLOCK: 136,
VK_FORMAT_BC3_UNORM_BLOCK: 137,
VK_FORMAT_BC3_SRGB_BLOCK: 138,
VK_FORMAT_BC4_UNORM_BLOCK: 139,
VK_FORMAT_BC4_SNORM_BLOCK: 140,
VK_FORMAT_BC5_UNORM_BLOCK: 141,
VK_FORMAT_BC5_SNORM_BLOCK: 142,
VK_FORMAT_BC6H_UFLOAT_BLOCK: 143,
VK_FORMAT_BC6H_SFLOAT_BLOCK: 144,
VK_FORMAT_BC7_UNORM_BLOCK: 145,
VK_FORMAT_BC7_SRGB_BLOCK: 146,
VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK: 147,
VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK: 148,
VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK: 149,
VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK: 150,
VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK: 151,
VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK: 152,
VK_FORMAT_EAC_R11_UNORM_BLOCK: 153,
VK_FORMAT_EAC_R11_SNORM_BLOCK: 154,
VK_FORMAT_EAC_R11G11_UNORM_BLOCK: 155,
VK_FORMAT_EAC_R11G11_SNORM_BLOCK: 156,
VK_FORMAT_ASTC_4x4_UNORM_BLOCK: 157,
VK_FORMAT_ASTC_4x4_SRGB_BLOCK: 158,
VK_FORMAT_ASTC_5x4_UNORM_BLOCK: 159,
VK_FORMAT_ASTC_5x4_SRGB_BLOCK: 160,
VK_FORMAT_ASTC_5x5_UNORM_BLOCK: 161,
VK_FORMAT_ASTC_5x5_SRGB_BLOCK: 162,
VK_FORMAT_ASTC_6x5_UNORM_BLOCK: 163,
VK_FORMAT_ASTC_6x5_SRGB_BLOCK: 164,
VK_FORMAT_ASTC_6x6_UNORM_BLOCK: 165,
VK_FORMAT_ASTC_6x6_SRGB_BLOCK: 166,
VK_FORMAT_ASTC_8x5_UNORM_BLOCK: 167,
VK_FORMAT_ASTC_8x5_SRGB_BLOCK: 168,
VK_FORMAT_ASTC_8x6_UNORM_BLOCK: 169,
VK_FORMAT_ASTC_8x6_SRGB_BLOCK: 170,
VK_FORMAT_ASTC_8x8_UNORM_BLOCK: 171,
VK_FORMAT_ASTC_8x8_SRGB_BLOCK: 172,
VK_FORMAT_ASTC_10x5_UNORM_BLOCK: 173,
VK_FORMAT_ASTC_10x5_SRGB_BLOCK: 174,
VK_FORMAT_ASTC_10x6_UNORM_BLOCK: 175,
VK_FORMAT_ASTC_10x6_SRGB_BLOCK: 176,
VK_FORMAT_ASTC_10x8_UNORM_BLOCK: 177,
VK_FORMAT_ASTC_10x8_SRGB_BLOCK: 178,
VK_FORMAT_ASTC_10x10_UNORM_BLOCK: 179,
VK_FORMAT_ASTC_10x10_SRGB_BLOCK: 180,
VK_FORMAT_ASTC_12x10_UNORM_BLOCK: 181,
VK_FORMAT_ASTC_12x10_SRGB_BLOCK: 182,
VK_FORMAT_ASTC_12x12_UNORM_BLOCK: 183,
VK_FORMAT_ASTC_12x12_SRGB_BLOCK: 184,
VK_FORMAT_G8B8G8R8_422_UNORM: 1000156e3,
VK_FORMAT_B8G8R8G8_422_UNORM: 1000156001,
VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM: 1000156002,
VK_FORMAT_G8_B8R8_2PLANE_420_UNORM: 1000156003,
VK_FORMAT_G8_B8_R8_3PLANE_422_UNORM: 1000156004,
VK_FORMAT_G8_B8R8_2PLANE_422_UNORM: 1000156005,
VK_FORMAT_G8_B8_R8_3PLANE_444_UNORM: 1000156006,
VK_FORMAT_R10X6_UNORM_PACK16: 1000156007,
VK_FORMAT_R10X6G10X6_UNORM_2PACK16: 1000156008,
VK_FORMAT_R10X6G10X6B10X6A10X6_UNORM_4PACK16: 1000156009,
VK_FORMAT_G10X6B10X6G10X6R10X6_422_UNORM_4PACK16: 1000156010,
VK_FORMAT_B10X6G10X6R10X6G10X6_422_UNORM_4PACK16: 1000156011,
VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_420_UNORM_3PACK16: 1000156012,
VK_FORMAT_G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16: 1000156013,
VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_422_UNORM_3PACK16: 1000156014,
VK_FORMAT_G10X6_B10X6R10X6_2PLANE_422_UNORM_3PACK16: 1000156015,
VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_444_UNORM_3PACK16: 1000156016,
VK_FORMAT_R12X4_UNORM_PACK16: 1000156017,
VK_FORMAT_R12X4G12X4_UNORM_2PACK16: 1000156018,
VK_FORMAT_R12X4G12X4B12X4A12X4_UNORM_4PACK16: 1000156019,
VK_FORMAT_G12X4B12X4G12X4R12X4_422_UNORM_4PACK16: 1000156020,
VK_FORMAT_B12X4G12X4R12X4G12X4_422_UNORM_4PACK16: 1000156021,
VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_420_UNORM_3PACK16: 1000156022,
VK_FORMAT_G12X4_B12X4R12X4_2PLANE_420_UNORM_3PACK16: 1000156023,
VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_422_UNORM_3PACK16: 1000156024,
VK_FORMAT_G12X4_B12X4R12X4_2PLANE_422_UNORM_3PACK16: 1000156025,
VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_444_UNORM_3PACK16: 1000156026,
VK_FORMAT_G16B16G16R16_422_UNORM: 1000156027,
VK_FORMAT_B16G16R16G16_422_UNORM: 1000156028,
VK_FORMAT_G16_B16_R16_3PLANE_420_UNORM: 1000156029,
VK_FORMAT_G16_B16R16_2PLANE_420_UNORM: 1000156030,
VK_FORMAT_G16_B16_R16_3PLANE_422_UNORM: 1000156031,
VK_FORMAT_G16_B16R16_2PLANE_422_UNORM: 1000156032,
VK_FORMAT_G16_B16_R16_3PLANE_444_UNORM: 1000156033,
VK_FORMAT_PVRTC1_2BPP_UNORM_BLOCK_IMG: 1000054e3,
VK_FORMAT_PVRTC1_4BPP_UNORM_BLOCK_IMG: 1000054001,
VK_FORMAT_PVRTC2_2BPP_UNORM_BLOCK_IMG: 1000054002,
VK_FORMAT_PVRTC2_4BPP_UNORM_BLOCK_IMG: 1000054003,
VK_FORMAT_PVRTC1_2BPP_SRGB_BLOCK_IMG: 1000054004,
VK_FORMAT_PVRTC1_4BPP_SRGB_BLOCK_IMG: 1000054005,
VK_FORMAT_PVRTC2_2BPP_SRGB_BLOCK_IMG: 1000054006,
VK_FORMAT_PVRTC2_4BPP_SRGB_BLOCK_IMG: 1000054007,
VK_FORMAT_ASTC_4x4_SFLOAT_BLOCK_EXT: 1000066e3,
VK_FORMAT_ASTC_5x4_SFLOAT_BLOCK_EXT: 1000066001,
VK_FORMAT_ASTC_5x5_SFLOAT_BLOCK_EXT: 1000066002,
VK_FORMAT_ASTC_6x5_SFLOAT_BLOCK_EXT: 1000066003,
VK_FORMAT_ASTC_6x6_SFLOAT_BLOCK_EXT: 1000066004,
VK_FORMAT_ASTC_8x5_SFLOAT_BLOCK_EXT: 1000066005,
VK_FORMAT_ASTC_8x6_SFLOAT_BLOCK_EXT: 1000066006,
VK_FORMAT_ASTC_8x8_SFLOAT_BLOCK_EXT: 1000066007,
VK_FORMAT_ASTC_10x5_SFLOAT_BLOCK_EXT: 1000066008,
VK_FORMAT_ASTC_10x6_SFLOAT_BLOCK_EXT: 1000066009,
VK_FORMAT_ASTC_10x8_SFLOAT_BLOCK_EXT: 1000066010,
VK_FORMAT_ASTC_10x10_SFLOAT_BLOCK_EXT: 1000066011,
VK_FORMAT_ASTC_12x10_SFLOAT_BLOCK_EXT: 1000066012,
VK_FORMAT_ASTC_12x12_SFLOAT_BLOCK_EXT: 1000066013,
VK_FORMAT_G8B8G8R8_422_UNORM_KHR: 1000156e3,
VK_FORMAT_B8G8R8G8_422_UNORM_KHR: 1000156001,
VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM_KHR: 1000156002,
VK_FORMAT_G8_B8R8_2PLANE_420_UNORM_KHR: 1000156003,
VK_FORMAT_G8_B8_R8_3PLANE_422_UNORM_KHR: 1000156004,
VK_FORMAT_G8_B8R8_2PLANE_422_UNORM_KHR: 1000156005,
VK_FORMAT_G8_B8_R8_3PLANE_444_UNORM_KHR: 1000156006,
VK_FORMAT_R10X6_UNORM_PACK16_KHR: 1000156007,
VK_FORMAT_R10X6G10X6_UNORM_2PACK16_KHR: 1000156008,
VK_FORMAT_R10X6G10X6B10X6A10X6_UNORM_4PACK16_KHR: 1000156009,
VK_FORMAT_G10X6B10X6G10X6R10X6_422_UNORM_4PACK16_KHR: 1000156010,
VK_FORMAT_B10X6G10X6R10X6G10X6_422_UNORM_4PACK16_KHR: 1000156011,
VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_420_UNORM_3PACK16_KHR: 1000156012,
VK_FORMAT_G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16_KHR: 1000156013,
VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_422_UNORM_3PACK16_KHR: 1000156014,
VK_FORMAT_G10X6_B10X6R10X6_2PLANE_422_UNORM_3PACK16_KHR: 1000156015,
VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_444_UNORM_3PACK16_KHR: 1000156016,
VK_FORMAT_R12X4_UNORM_PACK16_KHR: 1000156017,
VK_FORMAT_R12X4G12X4_UNORM_2PACK16_KHR: 1000156018,
VK_FORMAT_R12X4G12X4B12X4A12X4_UNORM_4PACK16_KHR: 1000156019,
VK_FORMAT_G12X4B12X4G12X4R12X4_422_UNORM_4PACK16_KHR: 1000156020,
VK_FORMAT_B12X4G12X4R12X4G12X4_422_UNORM_4PACK16_KHR: 1000156021,
VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_420_UNORM_3PACK16_KHR: 1000156022,
VK_FORMAT_G12X4_B12X4R12X4_2PLANE_420_UNORM_3PACK16_KHR: 1000156023,
VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_422_UNORM_3PACK16_KHR: 1000156024,
VK_FORMAT_G12X4_B12X4R12X4_2PLANE_422_UNORM_3PACK16_KHR: 1000156025,
VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_444_UNORM_3PACK16_KHR: 1000156026,
VK_FORMAT_G16B16G16R16_422_UNORM_KHR: 1000156027,
VK_FORMAT_B16G16R16G16_422_UNORM_KHR: 1000156028,
VK_FORMAT_G16_B16_R16_3PLANE_420_UNORM_KHR: 1000156029,
VK_FORMAT_G16_B16R16_2PLANE_420_UNORM_KHR: 1000156030,
VK_FORMAT_G16_B16_R16_3PLANE_422_UNORM_KHR: 1000156031,
VK_FORMAT_G16_B16R16_2PLANE_422_UNORM_KHR: 1000156032,
VK_FORMAT_G16_B16_R16_3PLANE_444_UNORM_KHR: 1000156033
};
var VulkanConstants_default = Object.freeze(VulkanConstants);
// Source/Core/WallGeometryLibrary.js
var WallGeometryLibrary = {};
function latLonEquals(c0, c14) {
return Math_default.equalsEpsilon(c0.latitude, c14.latitude, Math_default.EPSILON10) && Math_default.equalsEpsilon(c0.longitude, c14.longitude, Math_default.EPSILON10);
}
var scratchCartographic13 = new Cartographic_default();
var scratchCartographic23 = new Cartographic_default();
function removeDuplicates(ellipsoid, positions, topHeights, bottomHeights) {
positions = arrayRemoveDuplicates_default(positions, Cartesian3_default.equalsEpsilon);
const length3 = positions.length;
if (length3 < 2) {
return;
}
const hasBottomHeights = defined_default(bottomHeights);
const hasTopHeights = defined_default(topHeights);
const cleanedPositions = new Array(length3);
const cleanedTopHeights = new Array(length3);
const cleanedBottomHeights = new Array(length3);
const v02 = positions[0];
cleanedPositions[0] = v02;
const c0 = ellipsoid.cartesianToCartographic(v02, scratchCartographic13);
if (hasTopHeights) {
c0.height = topHeights[0];
}
cleanedTopHeights[0] = c0.height;
if (hasBottomHeights) {
cleanedBottomHeights[0] = bottomHeights[0];
} else {
cleanedBottomHeights[0] = 0;
}
const startTopHeight = cleanedTopHeights[0];
const startBottomHeight = cleanedBottomHeights[0];
let hasAllSameHeights = startTopHeight === startBottomHeight;
let index = 1;
for (let i = 1; i < length3; ++i) {
const v13 = positions[i];
const c14 = ellipsoid.cartesianToCartographic(v13, scratchCartographic23);
if (hasTopHeights) {
c14.height = topHeights[i];
}
hasAllSameHeights = hasAllSameHeights && c14.height === 0;
if (!latLonEquals(c0, c14)) {
cleanedPositions[index] = v13;
cleanedTopHeights[index] = c14.height;
if (hasBottomHeights) {
cleanedBottomHeights[index] = bottomHeights[i];
} else {
cleanedBottomHeights[index] = 0;
}
hasAllSameHeights = hasAllSameHeights && cleanedTopHeights[index] === cleanedBottomHeights[index];
Cartographic_default.clone(c14, c0);
++index;
} else if (c0.height < c14.height) {
cleanedTopHeights[index - 1] = c14.height;
}
}
if (hasAllSameHeights || index < 2) {
return;
}
cleanedPositions.length = index;
cleanedTopHeights.length = index;
cleanedBottomHeights.length = index;
return {
positions: cleanedPositions,
topHeights: cleanedTopHeights,
bottomHeights: cleanedBottomHeights
};
}
var positionsArrayScratch = new Array(2);
var heightsArrayScratch = new Array(2);
var generateArcOptionsScratch2 = {
positions: void 0,
height: void 0,
granularity: void 0,
ellipsoid: void 0
};
WallGeometryLibrary.computePositions = function(ellipsoid, wallPositions, maximumHeights, minimumHeights, granularity, duplicateCorners) {
const o = removeDuplicates(
ellipsoid,
wallPositions,
maximumHeights,
minimumHeights
);
if (!defined_default(o)) {
return;
}
wallPositions = o.positions;
maximumHeights = o.topHeights;
minimumHeights = o.bottomHeights;
const length3 = wallPositions.length;
const numCorners = length3 - 2;
let topPositions;
let bottomPositions;
const minDistance = Math_default.chordLength(
granularity,
ellipsoid.maximumRadius
);
const generateArcOptions = generateArcOptionsScratch2;
generateArcOptions.minDistance = minDistance;
generateArcOptions.ellipsoid = ellipsoid;
if (duplicateCorners) {
let count = 0;
let i;
for (i = 0; i < length3 - 1; i++) {
count += PolylinePipeline_default.numberOfPoints(
wallPositions[i],
wallPositions[i + 1],
minDistance
) + 1;
}
topPositions = new Float64Array(count * 3);
bottomPositions = new Float64Array(count * 3);
const generateArcPositions = positionsArrayScratch;
const generateArcHeights = heightsArrayScratch;
generateArcOptions.positions = generateArcPositions;
generateArcOptions.height = generateArcHeights;
let offset2 = 0;
for (i = 0; i < length3 - 1; i++) {
generateArcPositions[0] = wallPositions[i];
generateArcPositions[1] = wallPositions[i + 1];
generateArcHeights[0] = maximumHeights[i];
generateArcHeights[1] = maximumHeights[i + 1];
const pos = PolylinePipeline_default.generateArc(generateArcOptions);
topPositions.set(pos, offset2);
generateArcHeights[0] = minimumHeights[i];
generateArcHeights[1] = minimumHeights[i + 1];
bottomPositions.set(
PolylinePipeline_default.generateArc(generateArcOptions),
offset2
);
offset2 += pos.length;
}
} else {
generateArcOptions.positions = wallPositions;
generateArcOptions.height = maximumHeights;
topPositions = new Float64Array(
PolylinePipeline_default.generateArc(generateArcOptions)
);
generateArcOptions.height = minimumHeights;
bottomPositions = new Float64Array(
PolylinePipeline_default.generateArc(generateArcOptions)
);
}
return {
bottomPositions,
topPositions,
numCorners
};
};
var WallGeometryLibrary_default = WallGeometryLibrary;
// Source/Core/WallGeometry.js
var scratchCartesian3Position1 = new Cartesian3_default();
var scratchCartesian3Position2 = new Cartesian3_default();
var scratchCartesian3Position4 = new Cartesian3_default();
var scratchCartesian3Position5 = new Cartesian3_default();
var scratchBitangent5 = new Cartesian3_default();
var scratchTangent5 = new Cartesian3_default();
var scratchNormal7 = new Cartesian3_default();
function WallGeometry(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
const wallPositions = options.positions;
const maximumHeights = options.maximumHeights;
const minimumHeights = options.minimumHeights;
if (!defined_default(wallPositions)) {
throw new DeveloperError_default("options.positions is required.");
}
if (defined_default(maximumHeights) && maximumHeights.length !== wallPositions.length) {
throw new DeveloperError_default(
"options.positions and options.maximumHeights must have the same length."
);
}
if (defined_default(minimumHeights) && minimumHeights.length !== wallPositions.length) {
throw new DeveloperError_default(
"options.positions and options.minimumHeights must have the same length."
);
}
const vertexFormat = defaultValue_default(options.vertexFormat, VertexFormat_default.DEFAULT);
const granularity = defaultValue_default(
options.granularity,
Math_default.RADIANS_PER_DEGREE
);
const ellipsoid = defaultValue_default(options.ellipsoid, Ellipsoid_default.WGS84);
this._positions = wallPositions;
this._minimumHeights = minimumHeights;
this._maximumHeights = maximumHeights;
this._vertexFormat = VertexFormat_default.clone(vertexFormat);
this._granularity = granularity;
this._ellipsoid = Ellipsoid_default.clone(ellipsoid);
this._workerName = "createWallGeometry";
let numComponents = 1 + wallPositions.length * Cartesian3_default.packedLength + 2;
if (defined_default(minimumHeights)) {
numComponents += minimumHeights.length;
}
if (defined_default(maximumHeights)) {
numComponents += maximumHeights.length;
}
this.packedLength = numComponents + Ellipsoid_default.packedLength + VertexFormat_default.packedLength + 1;
}
WallGeometry.pack = function(value, array, startingIndex) {
if (!defined_default(value)) {
throw new DeveloperError_default("value is required");
}
if (!defined_default(array)) {
throw new DeveloperError_default("array is required");
}
startingIndex = defaultValue_default(startingIndex, 0);
let i;
const positions = value._positions;
let length3 = positions.length;
array[startingIndex++] = length3;
for (i = 0; i < length3; ++i, startingIndex += Cartesian3_default.packedLength) {
Cartesian3_default.pack(positions[i], array, startingIndex);
}
const minimumHeights = value._minimumHeights;
length3 = defined_default(minimumHeights) ? minimumHeights.length : 0;
array[startingIndex++] = length3;
if (defined_default(minimumHeights)) {
for (i = 0; i < length3; ++i) {
array[startingIndex++] = minimumHeights[i];
}
}
const maximumHeights = value._maximumHeights;
length3 = defined_default(maximumHeights) ? maximumHeights.length : 0;
array[startingIndex++] = length3;
if (defined_default(maximumHeights)) {
for (i = 0; i < length3; ++i) {
array[startingIndex++] = maximumHeights[i];
}
}
Ellipsoid_default.pack(value._ellipsoid, array, startingIndex);
startingIndex += Ellipsoid_default.packedLength;
VertexFormat_default.pack(value._vertexFormat, array, startingIndex);
startingIndex += VertexFormat_default.packedLength;
array[startingIndex] = value._granularity;
return array;
};
var scratchEllipsoid13 = Ellipsoid_default.clone(Ellipsoid_default.UNIT_SPHERE);
var scratchVertexFormat13 = new VertexFormat_default();
var scratchOptions23 = {
positions: void 0,
minimumHeights: void 0,
maximumHeights: void 0,
ellipsoid: scratchEllipsoid13,
vertexFormat: scratchVertexFormat13,
granularity: void 0
};
WallGeometry.unpack = function(array, startingIndex, result) {
if (!defined_default(array)) {
throw new DeveloperError_default("array is required");
}
startingIndex = defaultValue_default(startingIndex, 0);
let i;
let length3 = array[startingIndex++];
const positions = new Array(length3);
for (i = 0; i < length3; ++i, startingIndex += Cartesian3_default.packedLength) {
positions[i] = Cartesian3_default.unpack(array, startingIndex);
}
length3 = array[startingIndex++];
let minimumHeights;
if (length3 > 0) {
minimumHeights = new Array(length3);
for (i = 0; i < length3; ++i) {
minimumHeights[i] = array[startingIndex++];
}
}
length3 = array[startingIndex++];
let maximumHeights;
if (length3 > 0) {
maximumHeights = new Array(length3);
for (i = 0; i < length3; ++i) {
maximumHeights[i] = array[startingIndex++];
}
}
const ellipsoid = Ellipsoid_default.unpack(array, startingIndex, scratchEllipsoid13);
startingIndex += Ellipsoid_default.packedLength;
const vertexFormat = VertexFormat_default.unpack(
array,
startingIndex,
scratchVertexFormat13
);
startingIndex += VertexFormat_default.packedLength;
const granularity = array[startingIndex];
if (!defined_default(result)) {
scratchOptions23.positions = positions;
scratchOptions23.minimumHeights = minimumHeights;
scratchOptions23.maximumHeights = maximumHeights;
scratchOptions23.granularity = granularity;
return new WallGeometry(scratchOptions23);
}
result._positions = positions;
result._minimumHeights = minimumHeights;
result._maximumHeights = maximumHeights;
result._ellipsoid = Ellipsoid_default.clone(ellipsoid, result._ellipsoid);
result._vertexFormat = VertexFormat_default.clone(vertexFormat, result._vertexFormat);
result._granularity = granularity;
return result;
};
WallGeometry.fromConstantHeights = function(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
const positions = options.positions;
if (!defined_default(positions)) {
throw new DeveloperError_default("options.positions is required.");
}
let minHeights;
let maxHeights;
const min3 = options.minimumHeight;
const max3 = options.maximumHeight;
const doMin = defined_default(min3);
const doMax = defined_default(max3);
if (doMin || doMax) {
const length3 = positions.length;
minHeights = doMin ? new Array(length3) : void 0;
maxHeights = doMax ? new Array(length3) : void 0;
for (let i = 0; i < length3; ++i) {
if (doMin) {
minHeights[i] = min3;
}
if (doMax) {
maxHeights[i] = max3;
}
}
}
const newOptions2 = {
positions,
maximumHeights: maxHeights,
minimumHeights: minHeights,
ellipsoid: options.ellipsoid,
vertexFormat: options.vertexFormat
};
return new WallGeometry(newOptions2);
};
WallGeometry.createGeometry = function(wallGeometry) {
const wallPositions = wallGeometry._positions;
const minimumHeights = wallGeometry._minimumHeights;
const maximumHeights = wallGeometry._maximumHeights;
const vertexFormat = wallGeometry._vertexFormat;
const granularity = wallGeometry._granularity;
const ellipsoid = wallGeometry._ellipsoid;
const pos = WallGeometryLibrary_default.computePositions(
ellipsoid,
wallPositions,
maximumHeights,
minimumHeights,
granularity,
true
);
if (!defined_default(pos)) {
return;
}
const bottomPositions = pos.bottomPositions;
const topPositions = pos.topPositions;
const numCorners = pos.numCorners;
let length3 = topPositions.length;
let size = length3 * 2;
const positions = vertexFormat.position ? new Float64Array(size) : void 0;
const normals = vertexFormat.normal ? new Float32Array(size) : void 0;
const tangents = vertexFormat.tangent ? new Float32Array(size) : void 0;
const bitangents = vertexFormat.bitangent ? new Float32Array(size) : void 0;
const textureCoordinates = vertexFormat.st ? new Float32Array(size / 3 * 2) : void 0;
let positionIndex = 0;
let normalIndex = 0;
let bitangentIndex = 0;
let tangentIndex = 0;
let stIndex = 0;
let normal2 = scratchNormal7;
let tangent = scratchTangent5;
let bitangent = scratchBitangent5;
let recomputeNormal = true;
length3 /= 3;
let i;
let s = 0;
const ds = 1 / (length3 - numCorners - 1);
for (i = 0; i < length3; ++i) {
const i3 = i * 3;
const topPosition = Cartesian3_default.fromArray(
topPositions,
i3,
scratchCartesian3Position1
);
const bottomPosition = Cartesian3_default.fromArray(
bottomPositions,
i3,
scratchCartesian3Position2
);
if (vertexFormat.position) {
positions[positionIndex++] = bottomPosition.x;
positions[positionIndex++] = bottomPosition.y;
positions[positionIndex++] = bottomPosition.z;
positions[positionIndex++] = topPosition.x;
positions[positionIndex++] = topPosition.y;
positions[positionIndex++] = topPosition.z;
}
if (vertexFormat.st) {
textureCoordinates[stIndex++] = s;
textureCoordinates[stIndex++] = 0;
textureCoordinates[stIndex++] = s;
textureCoordinates[stIndex++] = 1;
}
if (vertexFormat.normal || vertexFormat.tangent || vertexFormat.bitangent) {
let nextTop = Cartesian3_default.clone(
Cartesian3_default.ZERO,
scratchCartesian3Position5
);
const groundPosition = Cartesian3_default.subtract(
topPosition,
ellipsoid.geodeticSurfaceNormal(
topPosition,
scratchCartesian3Position2
),
scratchCartesian3Position2
);
if (i + 1 < length3) {
nextTop = Cartesian3_default.fromArray(
topPositions,
i3 + 3,
scratchCartesian3Position5
);
}
if (recomputeNormal) {
const scalednextPosition = Cartesian3_default.subtract(
nextTop,
topPosition,
scratchCartesian3Position4
);
const scaledGroundPosition = Cartesian3_default.subtract(
groundPosition,
topPosition,
scratchCartesian3Position1
);
normal2 = Cartesian3_default.normalize(
Cartesian3_default.cross(scaledGroundPosition, scalednextPosition, normal2),
normal2
);
recomputeNormal = false;
}
if (Cartesian3_default.equalsEpsilon(topPosition, nextTop, Math_default.EPSILON10)) {
recomputeNormal = true;
} else {
s += ds;
if (vertexFormat.tangent) {
tangent = Cartesian3_default.normalize(
Cartesian3_default.subtract(nextTop, topPosition, tangent),
tangent
);
}
if (vertexFormat.bitangent) {
bitangent = Cartesian3_default.normalize(
Cartesian3_default.cross(normal2, tangent, bitangent),
bitangent
);
}
}
if (vertexFormat.normal) {
normals[normalIndex++] = normal2.x;
normals[normalIndex++] = normal2.y;
normals[normalIndex++] = normal2.z;
normals[normalIndex++] = normal2.x;
normals[normalIndex++] = normal2.y;
normals[normalIndex++] = normal2.z;
}
if (vertexFormat.tangent) {
tangents[tangentIndex++] = tangent.x;
tangents[tangentIndex++] = tangent.y;
tangents[tangentIndex++] = tangent.z;
tangents[tangentIndex++] = tangent.x;
tangents[tangentIndex++] = tangent.y;
tangents[tangentIndex++] = tangent.z;
}
if (vertexFormat.bitangent) {
bitangents[bitangentIndex++] = bitangent.x;
bitangents[bitangentIndex++] = bitangent.y;
bitangents[bitangentIndex++] = bitangent.z;
bitangents[bitangentIndex++] = bitangent.x;
bitangents[bitangentIndex++] = bitangent.y;
bitangents[bitangentIndex++] = bitangent.z;
}
}
}
const attributes = new GeometryAttributes_default();
if (vertexFormat.position) {
attributes.position = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.DOUBLE,
componentsPerAttribute: 3,
values: positions
});
}
if (vertexFormat.normal) {
attributes.normal = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.FLOAT,
componentsPerAttribute: 3,
values: normals
});
}
if (vertexFormat.tangent) {
attributes.tangent = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.FLOAT,
componentsPerAttribute: 3,
values: tangents
});
}
if (vertexFormat.bitangent) {
attributes.bitangent = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.FLOAT,
componentsPerAttribute: 3,
values: bitangents
});
}
if (vertexFormat.st) {
attributes.st = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.FLOAT,
componentsPerAttribute: 2,
values: textureCoordinates
});
}
const numVertices = size / 3;
size -= 6 * (numCorners + 1);
const indices2 = IndexDatatype_default.createTypedArray(numVertices, size);
let edgeIndex = 0;
for (i = 0; i < numVertices - 2; i += 2) {
const LL = i;
const LR = i + 2;
const pl = Cartesian3_default.fromArray(
positions,
LL * 3,
scratchCartesian3Position1
);
const pr = Cartesian3_default.fromArray(
positions,
LR * 3,
scratchCartesian3Position2
);
if (Cartesian3_default.equalsEpsilon(pl, pr, Math_default.EPSILON10)) {
continue;
}
const UL = i + 1;
const UR = i + 3;
indices2[edgeIndex++] = UL;
indices2[edgeIndex++] = LL;
indices2[edgeIndex++] = UR;
indices2[edgeIndex++] = UR;
indices2[edgeIndex++] = LL;
indices2[edgeIndex++] = LR;
}
return new Geometry_default({
attributes,
indices: indices2,
primitiveType: PrimitiveType_default.TRIANGLES,
boundingSphere: new BoundingSphere_default.fromVertices(positions)
});
};
var WallGeometry_default = WallGeometry;
// Source/Core/WallOutlineGeometry.js
var scratchCartesian3Position12 = new Cartesian3_default();
var scratchCartesian3Position22 = new Cartesian3_default();
function WallOutlineGeometry(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
const wallPositions = options.positions;
const maximumHeights = options.maximumHeights;
const minimumHeights = options.minimumHeights;
if (!defined_default(wallPositions)) {
throw new DeveloperError_default("options.positions is required.");
}
if (defined_default(maximumHeights) && maximumHeights.length !== wallPositions.length) {
throw new DeveloperError_default(
"options.positions and options.maximumHeights must have the same length."
);
}
if (defined_default(minimumHeights) && minimumHeights.length !== wallPositions.length) {
throw new DeveloperError_default(
"options.positions and options.minimumHeights must have the same length."
);
}
const granularity = defaultValue_default(
options.granularity,
Math_default.RADIANS_PER_DEGREE
);
const ellipsoid = defaultValue_default(options.ellipsoid, Ellipsoid_default.WGS84);
this._positions = wallPositions;
this._minimumHeights = minimumHeights;
this._maximumHeights = maximumHeights;
this._granularity = granularity;
this._ellipsoid = Ellipsoid_default.clone(ellipsoid);
this._workerName = "createWallOutlineGeometry";
let numComponents = 1 + wallPositions.length * Cartesian3_default.packedLength + 2;
if (defined_default(minimumHeights)) {
numComponents += minimumHeights.length;
}
if (defined_default(maximumHeights)) {
numComponents += maximumHeights.length;
}
this.packedLength = numComponents + Ellipsoid_default.packedLength + 1;
}
WallOutlineGeometry.pack = function(value, array, startingIndex) {
if (!defined_default(value)) {
throw new DeveloperError_default("value is required");
}
if (!defined_default(array)) {
throw new DeveloperError_default("array is required");
}
startingIndex = defaultValue_default(startingIndex, 0);
let i;
const positions = value._positions;
let length3 = positions.length;
array[startingIndex++] = length3;
for (i = 0; i < length3; ++i, startingIndex += Cartesian3_default.packedLength) {
Cartesian3_default.pack(positions[i], array, startingIndex);
}
const minimumHeights = value._minimumHeights;
length3 = defined_default(minimumHeights) ? minimumHeights.length : 0;
array[startingIndex++] = length3;
if (defined_default(minimumHeights)) {
for (i = 0; i < length3; ++i) {
array[startingIndex++] = minimumHeights[i];
}
}
const maximumHeights = value._maximumHeights;
length3 = defined_default(maximumHeights) ? maximumHeights.length : 0;
array[startingIndex++] = length3;
if (defined_default(maximumHeights)) {
for (i = 0; i < length3; ++i) {
array[startingIndex++] = maximumHeights[i];
}
}
Ellipsoid_default.pack(value._ellipsoid, array, startingIndex);
startingIndex += Ellipsoid_default.packedLength;
array[startingIndex] = value._granularity;
return array;
};
var scratchEllipsoid14 = Ellipsoid_default.clone(Ellipsoid_default.UNIT_SPHERE);
var scratchOptions24 = {
positions: void 0,
minimumHeights: void 0,
maximumHeights: void 0,
ellipsoid: scratchEllipsoid14,
granularity: void 0
};
WallOutlineGeometry.unpack = function(array, startingIndex, result) {
if (!defined_default(array)) {
throw new DeveloperError_default("array is required");
}
startingIndex = defaultValue_default(startingIndex, 0);
let i;
let length3 = array[startingIndex++];
const positions = new Array(length3);
for (i = 0; i < length3; ++i, startingIndex += Cartesian3_default.packedLength) {
positions[i] = Cartesian3_default.unpack(array, startingIndex);
}
length3 = array[startingIndex++];
let minimumHeights;
if (length3 > 0) {
minimumHeights = new Array(length3);
for (i = 0; i < length3; ++i) {
minimumHeights[i] = array[startingIndex++];
}
}
length3 = array[startingIndex++];
let maximumHeights;
if (length3 > 0) {
maximumHeights = new Array(length3);
for (i = 0; i < length3; ++i) {
maximumHeights[i] = array[startingIndex++];
}
}
const ellipsoid = Ellipsoid_default.unpack(array, startingIndex, scratchEllipsoid14);
startingIndex += Ellipsoid_default.packedLength;
const granularity = array[startingIndex];
if (!defined_default(result)) {
scratchOptions24.positions = positions;
scratchOptions24.minimumHeights = minimumHeights;
scratchOptions24.maximumHeights = maximumHeights;
scratchOptions24.granularity = granularity;
return new WallOutlineGeometry(scratchOptions24);
}
result._positions = positions;
result._minimumHeights = minimumHeights;
result._maximumHeights = maximumHeights;
result._ellipsoid = Ellipsoid_default.clone(ellipsoid, result._ellipsoid);
result._granularity = granularity;
return result;
};
WallOutlineGeometry.fromConstantHeights = function(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
const positions = options.positions;
if (!defined_default(positions)) {
throw new DeveloperError_default("options.positions is required.");
}
let minHeights;
let maxHeights;
const min3 = options.minimumHeight;
const max3 = options.maximumHeight;
const doMin = defined_default(min3);
const doMax = defined_default(max3);
if (doMin || doMax) {
const length3 = positions.length;
minHeights = doMin ? new Array(length3) : void 0;
maxHeights = doMax ? new Array(length3) : void 0;
for (let i = 0; i < length3; ++i) {
if (doMin) {
minHeights[i] = min3;
}
if (doMax) {
maxHeights[i] = max3;
}
}
}
const newOptions2 = {
positions,
maximumHeights: maxHeights,
minimumHeights: minHeights,
ellipsoid: options.ellipsoid
};
return new WallOutlineGeometry(newOptions2);
};
WallOutlineGeometry.createGeometry = function(wallGeometry) {
const wallPositions = wallGeometry._positions;
const minimumHeights = wallGeometry._minimumHeights;
const maximumHeights = wallGeometry._maximumHeights;
const granularity = wallGeometry._granularity;
const ellipsoid = wallGeometry._ellipsoid;
const pos = WallGeometryLibrary_default.computePositions(
ellipsoid,
wallPositions,
maximumHeights,
minimumHeights,
granularity,
false
);
if (!defined_default(pos)) {
return;
}
const bottomPositions = pos.bottomPositions;
const topPositions = pos.topPositions;
let length3 = topPositions.length;
let size = length3 * 2;
const positions = new Float64Array(size);
let positionIndex = 0;
length3 /= 3;
let i;
for (i = 0; i < length3; ++i) {
const i3 = i * 3;
const topPosition = Cartesian3_default.fromArray(
topPositions,
i3,
scratchCartesian3Position12
);
const bottomPosition = Cartesian3_default.fromArray(
bottomPositions,
i3,
scratchCartesian3Position22
);
positions[positionIndex++] = bottomPosition.x;
positions[positionIndex++] = bottomPosition.y;
positions[positionIndex++] = bottomPosition.z;
positions[positionIndex++] = topPosition.x;
positions[positionIndex++] = topPosition.y;
positions[positionIndex++] = topPosition.z;
}
const attributes = new GeometryAttributes_default({
position: new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.DOUBLE,
componentsPerAttribute: 3,
values: positions
})
});
const numVertices = size / 3;
size = 2 * numVertices - 4 + numVertices;
const indices2 = IndexDatatype_default.createTypedArray(numVertices, size);
let edgeIndex = 0;
for (i = 0; i < numVertices - 2; i += 2) {
const LL = i;
const LR = i + 2;
const pl = Cartesian3_default.fromArray(
positions,
LL * 3,
scratchCartesian3Position12
);
const pr = Cartesian3_default.fromArray(
positions,
LR * 3,
scratchCartesian3Position22
);
if (Cartesian3_default.equalsEpsilon(pl, pr, Math_default.EPSILON10)) {
continue;
}
const UL = i + 1;
const UR = i + 3;
indices2[edgeIndex++] = UL;
indices2[edgeIndex++] = LL;
indices2[edgeIndex++] = UL;
indices2[edgeIndex++] = UR;
indices2[edgeIndex++] = LL;
indices2[edgeIndex++] = LR;
}
indices2[edgeIndex++] = numVertices - 2;
indices2[edgeIndex++] = numVertices - 1;
return new Geometry_default({
attributes,
indices: indices2,
primitiveType: PrimitiveType_default.LINES,
boundingSphere: new BoundingSphere_default.fromVertices(positions)
});
};
var WallOutlineGeometry_default = WallOutlineGeometry;
// Source/Core/webGLConstantToGlslType.js
function webGLConstantToGlslType(webGLValue) {
switch (webGLValue) {
case WebGLConstants_default.FLOAT:
return "float";
case WebGLConstants_default.FLOAT_VEC2:
return "vec2";
case WebGLConstants_default.FLOAT_VEC3:
return "vec3";
case WebGLConstants_default.FLOAT_VEC4:
return "vec4";
case WebGLConstants_default.FLOAT_MAT2:
return "mat2";
case WebGLConstants_default.FLOAT_MAT3:
return "mat3";
case WebGLConstants_default.FLOAT_MAT4:
return "mat4";
case WebGLConstants_default.SAMPLER_2D:
return "sampler2D";
case WebGLConstants_default.BOOL:
return "bool";
}
}
var webGLConstantToGlslType_default = webGLConstantToGlslType;
// Source/Core/WireframeIndexGenerator.js
var WireframeIndexGenerator = {};
function createWireframeFromTriangles(vertexCount) {
const wireframeIndices = IndexDatatype_default.createTypedArray(
vertexCount,
vertexCount * 2
);
const length3 = vertexCount;
let index = 0;
for (let i = 0; i < length3; i += 3) {
wireframeIndices[index++] = i;
wireframeIndices[index++] = i + 1;
wireframeIndices[index++] = i + 1;
wireframeIndices[index++] = i + 2;
wireframeIndices[index++] = i + 2;
wireframeIndices[index++] = i;
}
return wireframeIndices;
}
function createWireframeFromTriangleIndices(vertexCount, originalIndices) {
const originalIndicesCount = originalIndices.length;
const wireframeIndices = IndexDatatype_default.createTypedArray(
vertexCount,
originalIndicesCount * 2
);
let index = 0;
for (let i = 0; i < originalIndicesCount; i += 3) {
const point0 = originalIndices[i];
const point1 = originalIndices[i + 1];
const point2 = originalIndices[i + 2];
wireframeIndices[index++] = point0;
wireframeIndices[index++] = point1;
wireframeIndices[index++] = point1;
wireframeIndices[index++] = point2;
wireframeIndices[index++] = point2;
wireframeIndices[index++] = point0;
}
return wireframeIndices;
}
function createWireframeFromTriangleStrip(vertexCount) {
const numberOfTriangles = vertexCount - 2;
const wireframeIndicesCount = 2 + numberOfTriangles * 4;
const wireframeIndices = IndexDatatype_default.createTypedArray(
vertexCount,
wireframeIndicesCount
);
let index = 0;
wireframeIndices[index++] = 0;
wireframeIndices[index++] = 1;
for (let i = 0; i < numberOfTriangles; i++) {
wireframeIndices[index++] = i + 1;
wireframeIndices[index++] = i + 2;
wireframeIndices[index++] = i + 2;
wireframeIndices[index++] = i;
}
return wireframeIndices;
}
function createWireframeFromTriangleStripIndices(vertexCount, originalIndices) {
const originalIndicesCount = originalIndices.length;
const numberOfTriangles = originalIndicesCount - 2;
const wireframeIndicesCount = 2 + numberOfTriangles * 4;
const wireframeIndices = IndexDatatype_default.createTypedArray(
vertexCount,
wireframeIndicesCount
);
let index = 0;
wireframeIndices[index++] = originalIndices[0];
wireframeIndices[index++] = originalIndices[1];
for (let i = 0; i < numberOfTriangles; i++) {
const point0 = originalIndices[i];
const point1 = originalIndices[i + 1];
const point2 = originalIndices[i + 2];
wireframeIndices[index++] = point1;
wireframeIndices[index++] = point2;
wireframeIndices[index++] = point2;
wireframeIndices[index++] = point0;
}
return wireframeIndices;
}
function createWireframeFromTriangleFan(vertexCount) {
const numberOfTriangles = vertexCount - 2;
const wireframeIndicesCount = 2 + numberOfTriangles * 4;
const wireframeIndices = IndexDatatype_default.createTypedArray(
vertexCount,
wireframeIndicesCount
);
let index = 0;
wireframeIndices[index++] = 0;
wireframeIndices[index++] = 1;
for (let i = 0; i < numberOfTriangles; i++) {
wireframeIndices[index++] = i + 1;
wireframeIndices[index++] = i + 2;
wireframeIndices[index++] = i + 2;
wireframeIndices[index++] = 0;
}
return wireframeIndices;
}
function createWireframeFromTriangleFanIndices(vertexCount, originalIndices) {
const originalIndicesCount = originalIndices.length;
const numberOfTriangles = originalIndicesCount - 2;
const wireframeIndicesCount = 2 + numberOfTriangles * 4;
const wireframeIndices = IndexDatatype_default.createTypedArray(
vertexCount,
wireframeIndicesCount
);
let index = 0;
const firstPoint = originalIndices[0];
wireframeIndices[index++] = firstPoint;
wireframeIndices[index++] = originalIndices[1];
for (let i = 0; i < numberOfTriangles; i++) {
const point1 = originalIndices[i + 1];
const point2 = originalIndices[i + 2];
wireframeIndices[index++] = point1;
wireframeIndices[index++] = point2;
wireframeIndices[index++] = point2;
wireframeIndices[index++] = firstPoint;
}
return wireframeIndices;
}
WireframeIndexGenerator.createWireframeIndices = function(primitiveType, vertexCount, originalIndices) {
const hasOriginalIndices = defined_default(originalIndices);
if (primitiveType === PrimitiveType_default.TRIANGLES) {
return hasOriginalIndices ? createWireframeFromTriangleIndices(vertexCount, originalIndices) : createWireframeFromTriangles(vertexCount);
}
if (primitiveType === PrimitiveType_default.TRIANGLE_STRIP) {
return hasOriginalIndices ? createWireframeFromTriangleStripIndices(vertexCount, originalIndices) : createWireframeFromTriangleStrip(vertexCount);
}
if (primitiveType === PrimitiveType_default.TRIANGLE_FAN) {
return hasOriginalIndices ? createWireframeFromTriangleFanIndices(vertexCount, originalIndices) : createWireframeFromTriangleFan(vertexCount);
}
return void 0;
};
WireframeIndexGenerator.getWireframeIndicesCount = function(primitiveType, originalCount) {
if (primitiveType === PrimitiveType_default.TRIANGLES) {
return originalCount * 2;
}
if (primitiveType === PrimitiveType_default.TRIANGLE_STRIP || primitiveType === PrimitiveType_default.TRIANGLE_FAN) {
const numberOfTriangles = originalCount - 2;
return 2 + numberOfTriangles * 4;
}
return originalCount;
};
var WireframeIndexGenerator_default = WireframeIndexGenerator;
// Source/Core/wrapFunction.js
function wrapFunction(obj, oldFunction, newFunction) {
if (typeof oldFunction !== "function") {
throw new DeveloperError_default("oldFunction is required to be a function.");
}
if (typeof newFunction !== "function") {
throw new DeveloperError_default("oldFunction is required to be a function.");
}
return function() {
newFunction.apply(obj, arguments);
oldFunction.apply(obj, arguments);
};
}
var wrapFunction_default = wrapFunction;
// Source/DataSources/ConstantProperty.js
function ConstantProperty(value) {
this._value = void 0;
this._hasClone = false;
this._hasEquals = false;
this._definitionChanged = new Event_default();
this.setValue(value);
}
Object.defineProperties(ConstantProperty.prototype, {
isConstant: {
value: true
},
definitionChanged: {
get: function() {
return this._definitionChanged;
}
}
});
ConstantProperty.prototype.getValue = function(time, result) {
return this._hasClone ? this._value.clone(result) : this._value;
};
ConstantProperty.prototype.setValue = function(value) {
const oldValue2 = this._value;
if (oldValue2 !== value) {
const isDefined = defined_default(value);
const hasClone = isDefined && typeof value.clone === "function";
const hasEquals = isDefined && typeof value.equals === "function";
const changed = !hasEquals || !value.equals(oldValue2);
if (changed) {
this._hasClone = hasClone;
this._hasEquals = hasEquals;
this._value = !hasClone ? value : value.clone(this._value);
this._definitionChanged.raiseEvent(this);
}
}
};
ConstantProperty.prototype.equals = function(other) {
return this === other || other instanceof ConstantProperty && (!this._hasEquals && this._value === other._value || this._hasEquals && this._value.equals(other._value));
};
ConstantProperty.prototype.valueOf = function() {
return this._value;
};
ConstantProperty.prototype.toString = function() {
return String(this._value);
};
var ConstantProperty_default = ConstantProperty;
// Source/DataSources/createPropertyDescriptor.js
function createProperty(name, privateName, subscriptionName, configurable, createPropertyCallback) {
return {
configurable,
get: function() {
return this[privateName];
},
set: function(value) {
const oldValue2 = this[privateName];
const subscription = this[subscriptionName];
if (defined_default(subscription)) {
subscription();
this[subscriptionName] = void 0;
}
const hasValue = value !== void 0;
if (hasValue && (!defined_default(value) || !defined_default(value.getValue)) && defined_default(createPropertyCallback)) {
value = createPropertyCallback(value);
}
if (oldValue2 !== value) {
this[privateName] = value;
this._definitionChanged.raiseEvent(this, name, value, oldValue2);
}
if (defined_default(value) && defined_default(value.definitionChanged)) {
this[subscriptionName] = value.definitionChanged.addEventListener(
function() {
this._definitionChanged.raiseEvent(this, name, value, value);
},
this
);
}
}
};
}
function createConstantProperty(value) {
return new ConstantProperty_default(value);
}
function createPropertyDescriptor(name, configurable, createPropertyCallback) {
return createProperty(
name,
`_${name.toString()}`,
`_${name.toString()}Subscription`,
defaultValue_default(configurable, false),
defaultValue_default(createPropertyCallback, createConstantProperty)
);
}
var createPropertyDescriptor_default = createPropertyDescriptor;
// Source/DataSources/BillboardGraphics.js
function BillboardGraphics(options) {
this._definitionChanged = new Event_default();
this._show = void 0;
this._showSubscription = void 0;
this._image = void 0;
this._imageSubscription = void 0;
this._scale = void 0;
this._scaleSubscription = void 0;
this._pixelOffset = void 0;
this._pixelOffsetSubscription = void 0;
this._eyeOffset = void 0;
this._eyeOffsetSubscription = void 0;
this._horizontalOrigin = void 0;
this._horizontalOriginSubscription = void 0;
this._verticalOrigin = void 0;
this._verticalOriginSubscription = void 0;
this._heightReference = void 0;
this._heightReferenceSubscription = void 0;
this._color = void 0;
this._colorSubscription = void 0;
this._rotation = void 0;
this._rotationSubscription = void 0;
this._alignedAxis = void 0;
this._alignedAxisSubscription = void 0;
this._sizeInMeters = void 0;
this._sizeInMetersSubscription = void 0;
this._width = void 0;
this._widthSubscription = void 0;
this._height = void 0;
this._heightSubscription = void 0;
this._scaleByDistance = void 0;
this._scaleByDistanceSubscription = void 0;
this._translucencyByDistance = void 0;
this._translucencyByDistanceSubscription = void 0;
this._pixelOffsetScaleByDistance = void 0;
this._pixelOffsetScaleByDistanceSubscription = void 0;
this._imageSubRegion = void 0;
this._imageSubRegionSubscription = void 0;
this._distanceDisplayCondition = void 0;
this._distanceDisplayConditionSubscription = void 0;
this._disableDepthTestDistance = void 0;
this._disableDepthTestDistanceSubscription = void 0;
this.merge(defaultValue_default(options, defaultValue_default.EMPTY_OBJECT));
}
Object.defineProperties(BillboardGraphics.prototype, {
definitionChanged: {
get: function() {
return this._definitionChanged;
}
},
show: createPropertyDescriptor_default("show"),
image: createPropertyDescriptor_default("image"),
scale: createPropertyDescriptor_default("scale"),
pixelOffset: createPropertyDescriptor_default("pixelOffset"),
eyeOffset: createPropertyDescriptor_default("eyeOffset"),
horizontalOrigin: createPropertyDescriptor_default("horizontalOrigin"),
verticalOrigin: createPropertyDescriptor_default("verticalOrigin"),
heightReference: createPropertyDescriptor_default("heightReference"),
color: createPropertyDescriptor_default("color"),
rotation: createPropertyDescriptor_default("rotation"),
alignedAxis: createPropertyDescriptor_default("alignedAxis"),
sizeInMeters: createPropertyDescriptor_default("sizeInMeters"),
width: createPropertyDescriptor_default("width"),
height: createPropertyDescriptor_default("height"),
scaleByDistance: createPropertyDescriptor_default("scaleByDistance"),
translucencyByDistance: createPropertyDescriptor_default("translucencyByDistance"),
pixelOffsetScaleByDistance: createPropertyDescriptor_default(
"pixelOffsetScaleByDistance"
),
imageSubRegion: createPropertyDescriptor_default("imageSubRegion"),
distanceDisplayCondition: createPropertyDescriptor_default(
"distanceDisplayCondition"
),
disableDepthTestDistance: createPropertyDescriptor_default(
"disableDepthTestDistance"
)
});
BillboardGraphics.prototype.clone = function(result) {
if (!defined_default(result)) {
return new BillboardGraphics(this);
}
result.show = this._show;
result.image = this._image;
result.scale = this._scale;
result.pixelOffset = this._pixelOffset;
result.eyeOffset = this._eyeOffset;
result.horizontalOrigin = this._horizontalOrigin;
result.verticalOrigin = this._verticalOrigin;
result.heightReference = this._heightReference;
result.color = this._color;
result.rotation = this._rotation;
result.alignedAxis = this._alignedAxis;
result.sizeInMeters = this._sizeInMeters;
result.width = this._width;
result.height = this._height;
result.scaleByDistance = this._scaleByDistance;
result.translucencyByDistance = this._translucencyByDistance;
result.pixelOffsetScaleByDistance = this._pixelOffsetScaleByDistance;
result.imageSubRegion = this._imageSubRegion;
result.distanceDisplayCondition = this._distanceDisplayCondition;
result.disableDepthTestDistance = this._disableDepthTestDistance;
return result;
};
BillboardGraphics.prototype.merge = function(source) {
if (!defined_default(source)) {
throw new DeveloperError_default("source is required.");
}
this.show = defaultValue_default(this._show, source.show);
this.image = defaultValue_default(this._image, source.image);
this.scale = defaultValue_default(this._scale, source.scale);
this.pixelOffset = defaultValue_default(this._pixelOffset, source.pixelOffset);
this.eyeOffset = defaultValue_default(this._eyeOffset, source.eyeOffset);
this.horizontalOrigin = defaultValue_default(
this._horizontalOrigin,
source.horizontalOrigin
);
this.verticalOrigin = defaultValue_default(
this._verticalOrigin,
source.verticalOrigin
);
this.heightReference = defaultValue_default(
this._heightReference,
source.heightReference
);
this.color = defaultValue_default(this._color, source.color);
this.rotation = defaultValue_default(this._rotation, source.rotation);
this.alignedAxis = defaultValue_default(this._alignedAxis, source.alignedAxis);
this.sizeInMeters = defaultValue_default(this._sizeInMeters, source.sizeInMeters);
this.width = defaultValue_default(this._width, source.width);
this.height = defaultValue_default(this._height, source.height);
this.scaleByDistance = defaultValue_default(
this._scaleByDistance,
source.scaleByDistance
);
this.translucencyByDistance = defaultValue_default(
this._translucencyByDistance,
source.translucencyByDistance
);
this.pixelOffsetScaleByDistance = defaultValue_default(
this._pixelOffsetScaleByDistance,
source.pixelOffsetScaleByDistance
);
this.imageSubRegion = defaultValue_default(
this._imageSubRegion,
source.imageSubRegion
);
this.distanceDisplayCondition = defaultValue_default(
this._distanceDisplayCondition,
source.distanceDisplayCondition
);
this.disableDepthTestDistance = defaultValue_default(
this._disableDepthTestDistance,
source.disableDepthTestDistance
);
};
var BillboardGraphics_default = BillboardGraphics;
// Source/Scene/HeightReference.js
var HeightReference = {
NONE: 0,
CLAMP_TO_GROUND: 1,
RELATIVE_TO_GROUND: 2
};
var HeightReference_default = Object.freeze(HeightReference);
// Source/Scene/HorizontalOrigin.js
var HorizontalOrigin = {
CENTER: 0,
LEFT: 1,
RIGHT: -1
};
var HorizontalOrigin_default = Object.freeze(HorizontalOrigin);
// Source/Scene/VerticalOrigin.js
var VerticalOrigin = {
CENTER: 0,
BOTTOM: 1,
BASELINE: 2,
TOP: -1
};
var VerticalOrigin_default = Object.freeze(VerticalOrigin);
// Source/DataSources/BoundingSphereState.js
var BoundingSphereState = {
DONE: 0,
PENDING: 1,
FAILED: 2
};
var BoundingSphereState_default = Object.freeze(BoundingSphereState);
// Source/DataSources/Property.js
function Property() {
DeveloperError_default.throwInstantiationError();
}
Object.defineProperties(Property.prototype, {
isConstant: {
get: DeveloperError_default.throwInstantiationError
},
definitionChanged: {
get: DeveloperError_default.throwInstantiationError
}
});
Property.prototype.getValue = DeveloperError_default.throwInstantiationError;
Property.prototype.equals = DeveloperError_default.throwInstantiationError;
Property.equals = function(left, right) {
return left === right || defined_default(left) && left.equals(right);
};
Property.arrayEquals = function(left, right) {
if (left === right) {
return true;
}
if (!defined_default(left) || !defined_default(right) || left.length !== right.length) {
return false;
}
const length3 = left.length;
for (let i = 0; i < length3; i++) {
if (!Property.equals(left[i], right[i])) {
return false;
}
}
return true;
};
Property.isConstant = function(property) {
return !defined_default(property) || property.isConstant;
};
Property.getValueOrUndefined = function(property, time, result) {
return defined_default(property) ? property.getValue(time, result) : void 0;
};
Property.getValueOrDefault = function(property, time, valueDefault, result) {
return defined_default(property) ? defaultValue_default(property.getValue(time, result), valueDefault) : valueDefault;
};
Property.getValueOrClonedDefault = function(property, time, valueDefault, result) {
let value;
if (defined_default(property)) {
value = property.getValue(time, result);
}
if (!defined_default(value)) {
value = valueDefault.clone(value);
}
return value;
};
var Property_default = Property;
// Source/DataSources/BillboardVisualizer.js
var defaultColor = Color_default.WHITE;
var defaultEyeOffset = Cartesian3_default.ZERO;
var defaultHeightReference = HeightReference_default.NONE;
var defaultPixelOffset = Cartesian2_default.ZERO;
var defaultScale2 = 1;
var defaultRotation2 = 0;
var defaultAlignedAxis = Cartesian3_default.ZERO;
var defaultHorizontalOrigin = HorizontalOrigin_default.CENTER;
var defaultVerticalOrigin = VerticalOrigin_default.CENTER;
var defaultSizeInMeters = false;
var positionScratch5 = new Cartesian3_default();
var colorScratch2 = new Color_default();
var eyeOffsetScratch = new Cartesian3_default();
var pixelOffsetScratch = new Cartesian2_default();
var scaleByDistanceScratch = new NearFarScalar_default();
var translucencyByDistanceScratch = new NearFarScalar_default();
var pixelOffsetScaleByDistanceScratch = new NearFarScalar_default();
var boundingRectangleScratch = new BoundingRectangle_default();
var distanceDisplayConditionScratch = new DistanceDisplayCondition_default();
function EntityData(entity) {
this.entity = entity;
this.billboard = void 0;
this.textureValue = void 0;
}
function BillboardVisualizer(entityCluster, entityCollection) {
if (!defined_default(entityCluster)) {
throw new DeveloperError_default("entityCluster is required.");
}
if (!defined_default(entityCollection)) {
throw new DeveloperError_default("entityCollection is required.");
}
entityCollection.collectionChanged.addEventListener(
BillboardVisualizer.prototype._onCollectionChanged,
this
);
this._cluster = entityCluster;
this._entityCollection = entityCollection;
this._items = new AssociativeArray_default();
this._onCollectionChanged(entityCollection, entityCollection.values, [], []);
}
BillboardVisualizer.prototype.update = function(time) {
if (!defined_default(time)) {
throw new DeveloperError_default("time is required.");
}
const items = this._items.values;
const cluster = this._cluster;
for (let i = 0, len = items.length; i < len; i++) {
const item = items[i];
const entity = item.entity;
const billboardGraphics = entity._billboard;
let textureValue;
let billboard = item.billboard;
let show = entity.isShowing && entity.isAvailable(time) && Property_default.getValueOrDefault(billboardGraphics._show, time, true);
let position;
if (show) {
position = Property_default.getValueOrUndefined(
entity._position,
time,
positionScratch5
);
textureValue = Property_default.getValueOrUndefined(
billboardGraphics._image,
time
);
show = defined_default(position) && defined_default(textureValue);
}
if (!show) {
returnPrimitive(item, entity, cluster);
continue;
}
if (!Property_default.isConstant(entity._position)) {
cluster._clusterDirty = true;
}
if (!defined_default(billboard)) {
billboard = cluster.getBillboard(entity);
billboard.id = entity;
billboard.image = void 0;
item.billboard = billboard;
}
billboard.show = show;
if (!defined_default(billboard.image) || item.textureValue !== textureValue) {
billboard.image = textureValue;
item.textureValue = textureValue;
}
billboard.position = position;
billboard.color = Property_default.getValueOrDefault(
billboardGraphics._color,
time,
defaultColor,
colorScratch2
);
billboard.eyeOffset = Property_default.getValueOrDefault(
billboardGraphics._eyeOffset,
time,
defaultEyeOffset,
eyeOffsetScratch
);
billboard.heightReference = Property_default.getValueOrDefault(
billboardGraphics._heightReference,
time,
defaultHeightReference
);
billboard.pixelOffset = Property_default.getValueOrDefault(
billboardGraphics._pixelOffset,
time,
defaultPixelOffset,
pixelOffsetScratch
);
billboard.scale = Property_default.getValueOrDefault(
billboardGraphics._scale,
time,
defaultScale2
);
billboard.rotation = Property_default.getValueOrDefault(
billboardGraphics._rotation,
time,
defaultRotation2
);
billboard.alignedAxis = Property_default.getValueOrDefault(
billboardGraphics._alignedAxis,
time,
defaultAlignedAxis
);
billboard.horizontalOrigin = Property_default.getValueOrDefault(
billboardGraphics._horizontalOrigin,
time,
defaultHorizontalOrigin
);
billboard.verticalOrigin = Property_default.getValueOrDefault(
billboardGraphics._verticalOrigin,
time,
defaultVerticalOrigin
);
billboard.width = Property_default.getValueOrUndefined(
billboardGraphics._width,
time
);
billboard.height = Property_default.getValueOrUndefined(
billboardGraphics._height,
time
);
billboard.scaleByDistance = Property_default.getValueOrUndefined(
billboardGraphics._scaleByDistance,
time,
scaleByDistanceScratch
);
billboard.translucencyByDistance = Property_default.getValueOrUndefined(
billboardGraphics._translucencyByDistance,
time,
translucencyByDistanceScratch
);
billboard.pixelOffsetScaleByDistance = Property_default.getValueOrUndefined(
billboardGraphics._pixelOffsetScaleByDistance,
time,
pixelOffsetScaleByDistanceScratch
);
billboard.sizeInMeters = Property_default.getValueOrDefault(
billboardGraphics._sizeInMeters,
time,
defaultSizeInMeters
);
billboard.distanceDisplayCondition = Property_default.getValueOrUndefined(
billboardGraphics._distanceDisplayCondition,
time,
distanceDisplayConditionScratch
);
billboard.disableDepthTestDistance = Property_default.getValueOrUndefined(
billboardGraphics._disableDepthTestDistance,
time
);
const subRegion = Property_default.getValueOrUndefined(
billboardGraphics._imageSubRegion,
time,
boundingRectangleScratch
);
if (defined_default(subRegion)) {
billboard.setImageSubRegion(billboard._imageId, subRegion);
}
}
return true;
};
BillboardVisualizer.prototype.getBoundingSphere = function(entity, result) {
if (!defined_default(entity)) {
throw new DeveloperError_default("entity is required.");
}
if (!defined_default(result)) {
throw new DeveloperError_default("result is required.");
}
const item = this._items.get(entity.id);
if (!defined_default(item) || !defined_default(item.billboard)) {
return BoundingSphereState_default.FAILED;
}
const billboard = item.billboard;
if (billboard.heightReference === HeightReference_default.NONE) {
result.center = Cartesian3_default.clone(billboard.position, result.center);
} else {
if (!defined_default(billboard._clampedPosition)) {
return BoundingSphereState_default.PENDING;
}
result.center = Cartesian3_default.clone(billboard._clampedPosition, result.center);
}
result.radius = 0;
return BoundingSphereState_default.DONE;
};
BillboardVisualizer.prototype.isDestroyed = function() {
return false;
};
BillboardVisualizer.prototype.destroy = function() {
this._entityCollection.collectionChanged.removeEventListener(
BillboardVisualizer.prototype._onCollectionChanged,
this
);
const entities = this._entityCollection.values;
for (let i = 0; i < entities.length; i++) {
this._cluster.removeBillboard(entities[i]);
}
return destroyObject_default(this);
};
BillboardVisualizer.prototype._onCollectionChanged = function(entityCollection, added, removed, changed) {
let i;
let entity;
const items = this._items;
const cluster = this._cluster;
for (i = added.length - 1; i > -1; i--) {
entity = added[i];
if (defined_default(entity._billboard) && defined_default(entity._position)) {
items.set(entity.id, new EntityData(entity));
}
}
for (i = changed.length - 1; i > -1; i--) {
entity = changed[i];
if (defined_default(entity._billboard) && defined_default(entity._position)) {
if (!items.contains(entity.id)) {
items.set(entity.id, new EntityData(entity));
}
} else {
returnPrimitive(items.get(entity.id), entity, cluster);
items.remove(entity.id);
}
}
for (i = removed.length - 1; i > -1; i--) {
entity = removed[i];
returnPrimitive(items.get(entity.id), entity, cluster);
items.remove(entity.id);
}
};
function returnPrimitive(item, entity, cluster) {
if (defined_default(item)) {
item.billboard = void 0;
cluster.removeBillboard(entity);
}
}
var BillboardVisualizer_default = BillboardVisualizer;
// Source/Shaders/Appearances/AllMaterialAppearanceFS.js
var AllMaterialAppearanceFS_default = "varying vec3 v_positionEC;\nvarying vec3 v_normalEC;\nvarying vec3 v_tangentEC;\nvarying vec3 v_bitangentEC;\nvarying vec2 v_st;\n\nvoid main()\n{\n vec3 positionToEyeEC = -v_positionEC;\n mat3 tangentToEyeMatrix = czm_tangentToEyeSpaceMatrix(v_normalEC, v_tangentEC, v_bitangentEC);\n\n vec3 normalEC = normalize(v_normalEC);\n#ifdef FACE_FORWARD\n normalEC = faceforward(normalEC, vec3(0.0, 0.0, 1.0), -normalEC);\n#endif\n\n czm_materialInput materialInput;\n materialInput.normalEC = normalEC;\n materialInput.tangentToEyeMatrix = tangentToEyeMatrix;\n materialInput.positionToEyeEC = positionToEyeEC;\n materialInput.st = v_st;\n czm_material material = czm_getMaterial(materialInput);\n\n#ifdef FLAT\n gl_FragColor = vec4(material.diffuse + material.emission, material.alpha);\n#else\n gl_FragColor = czm_phong(normalize(positionToEyeEC), material, czm_lightDirectionEC);\n#endif\n}\n";
// Source/Shaders/Appearances/AllMaterialAppearanceVS.js
var AllMaterialAppearanceVS_default = "attribute vec3 position3DHigh;\nattribute vec3 position3DLow;\nattribute vec3 normal;\nattribute vec3 tangent;\nattribute vec3 bitangent;\nattribute vec2 st;\nattribute float batchId;\n\nvarying vec3 v_positionEC;\nvarying vec3 v_normalEC;\nvarying vec3 v_tangentEC;\nvarying vec3 v_bitangentEC;\nvarying vec2 v_st;\n\nvoid main()\n{\n vec4 p = czm_computePosition();\n\n v_positionEC = (czm_modelViewRelativeToEye * p).xyz; // position in eye coordinates\n v_normalEC = czm_normal * normal; // normal in eye coordinates\n v_tangentEC = czm_normal * tangent; // tangent in eye coordinates\n v_bitangentEC = czm_normal * bitangent; // bitangent in eye coordinates\n v_st = st;\n\n gl_Position = czm_modelViewProjectionRelativeToEye * p;\n}\n";
// Source/Shaders/Appearances/BasicMaterialAppearanceFS.js
var BasicMaterialAppearanceFS_default = "varying vec3 v_positionEC;\nvarying vec3 v_normalEC;\n\nvoid main()\n{\n vec3 positionToEyeEC = -v_positionEC;\n\n vec3 normalEC = normalize(v_normalEC);\n#ifdef FACE_FORWARD\n normalEC = faceforward(normalEC, vec3(0.0, 0.0, 1.0), -normalEC);\n#endif\n\n czm_materialInput materialInput;\n materialInput.normalEC = normalEC;\n materialInput.positionToEyeEC = positionToEyeEC;\n czm_material material = czm_getMaterial(materialInput);\n\n#ifdef FLAT\n gl_FragColor = vec4(material.diffuse + material.emission, material.alpha);\n#else\n gl_FragColor = czm_phong(normalize(positionToEyeEC), material, czm_lightDirectionEC);\n#endif\n}\n";
// Source/Shaders/Appearances/BasicMaterialAppearanceVS.js
var BasicMaterialAppearanceVS_default = "attribute vec3 position3DHigh;\nattribute vec3 position3DLow;\nattribute vec3 normal;\nattribute float batchId;\n\nvarying vec3 v_positionEC;\nvarying vec3 v_normalEC;\n\nvoid main()\n{\n vec4 p = czm_computePosition();\n\n v_positionEC = (czm_modelViewRelativeToEye * p).xyz; // position in eye coordinates\n v_normalEC = czm_normal * normal; // normal in eye coordinates\n\n gl_Position = czm_modelViewProjectionRelativeToEye * p;\n}\n";
// Source/Shaders/Appearances/TexturedMaterialAppearanceFS.js
var TexturedMaterialAppearanceFS_default = "varying vec3 v_positionEC;\nvarying vec3 v_normalEC;\nvarying vec2 v_st;\n\nvoid main()\n{\n vec3 positionToEyeEC = -v_positionEC;\n\n vec3 normalEC = normalize(v_normalEC);\n#ifdef FACE_FORWARD\n normalEC = faceforward(normalEC, vec3(0.0, 0.0, 1.0), -normalEC);\n#endif\n\n czm_materialInput materialInput;\n materialInput.normalEC = normalEC;\n materialInput.positionToEyeEC = positionToEyeEC;\n materialInput.st = v_st;\n czm_material material = czm_getMaterial(materialInput);\n\n#ifdef FLAT\n gl_FragColor = vec4(material.diffuse + material.emission, material.alpha);\n#else\n gl_FragColor = czm_phong(normalize(positionToEyeEC), material, czm_lightDirectionEC);\n#endif\n}\n";
// Source/Shaders/Appearances/TexturedMaterialAppearanceVS.js
var TexturedMaterialAppearanceVS_default = "attribute vec3 position3DHigh;\nattribute vec3 position3DLow;\nattribute vec3 normal;\nattribute vec2 st;\nattribute float batchId;\n\nvarying vec3 v_positionEC;\nvarying vec3 v_normalEC;\nvarying vec2 v_st;\n\nvoid main()\n{\n vec4 p = czm_computePosition();\n\n v_positionEC = (czm_modelViewRelativeToEye * p).xyz; // position in eye coordinates\n v_normalEC = czm_normal * normal; // normal in eye coordinates\n v_st = st;\n\n gl_Position = czm_modelViewProjectionRelativeToEye * p;\n}\n";
// Source/Scene/BlendEquation.js
var BlendEquation = {
ADD: WebGLConstants_default.FUNC_ADD,
SUBTRACT: WebGLConstants_default.FUNC_SUBTRACT,
REVERSE_SUBTRACT: WebGLConstants_default.FUNC_REVERSE_SUBTRACT,
MIN: WebGLConstants_default.MIN,
MAX: WebGLConstants_default.MAX
};
var BlendEquation_default = Object.freeze(BlendEquation);
// Source/Scene/BlendFunction.js
var BlendFunction = {
ZERO: WebGLConstants_default.ZERO,
ONE: WebGLConstants_default.ONE,
SOURCE_COLOR: WebGLConstants_default.SRC_COLOR,
ONE_MINUS_SOURCE_COLOR: WebGLConstants_default.ONE_MINUS_SRC_COLOR,
DESTINATION_COLOR: WebGLConstants_default.DST_COLOR,
ONE_MINUS_DESTINATION_COLOR: WebGLConstants_default.ONE_MINUS_DST_COLOR,
SOURCE_ALPHA: WebGLConstants_default.SRC_ALPHA,
ONE_MINUS_SOURCE_ALPHA: WebGLConstants_default.ONE_MINUS_SRC_ALPHA,
DESTINATION_ALPHA: WebGLConstants_default.DST_ALPHA,
ONE_MINUS_DESTINATION_ALPHA: WebGLConstants_default.ONE_MINUS_DST_ALPHA,
CONSTANT_COLOR: WebGLConstants_default.CONSTANT_COLOR,
ONE_MINUS_CONSTANT_COLOR: WebGLConstants_default.ONE_MINUS_CONSTANT_COLOR,
CONSTANT_ALPHA: WebGLConstants_default.CONSTANT_ALPHA,
ONE_MINUS_CONSTANT_ALPHA: WebGLConstants_default.ONE_MINUS_CONSTANT_ALPHA,
SOURCE_ALPHA_SATURATE: WebGLConstants_default.SRC_ALPHA_SATURATE
};
var BlendFunction_default = Object.freeze(BlendFunction);
// Source/Scene/BlendingState.js
var BlendingState = {
DISABLED: Object.freeze({
enabled: false
}),
ALPHA_BLEND: Object.freeze({
enabled: true,
equationRgb: BlendEquation_default.ADD,
equationAlpha: BlendEquation_default.ADD,
functionSourceRgb: BlendFunction_default.SOURCE_ALPHA,
functionSourceAlpha: BlendFunction_default.ONE,
functionDestinationRgb: BlendFunction_default.ONE_MINUS_SOURCE_ALPHA,
functionDestinationAlpha: BlendFunction_default.ONE_MINUS_SOURCE_ALPHA
}),
PRE_MULTIPLIED_ALPHA_BLEND: Object.freeze({
enabled: true,
equationRgb: BlendEquation_default.ADD,
equationAlpha: BlendEquation_default.ADD,
functionSourceRgb: BlendFunction_default.ONE,
functionSourceAlpha: BlendFunction_default.ONE,
functionDestinationRgb: BlendFunction_default.ONE_MINUS_SOURCE_ALPHA,
functionDestinationAlpha: BlendFunction_default.ONE_MINUS_SOURCE_ALPHA
}),
ADDITIVE_BLEND: Object.freeze({
enabled: true,
equationRgb: BlendEquation_default.ADD,
equationAlpha: BlendEquation_default.ADD,
functionSourceRgb: BlendFunction_default.SOURCE_ALPHA,
functionSourceAlpha: BlendFunction_default.ONE,
functionDestinationRgb: BlendFunction_default.ONE,
functionDestinationAlpha: BlendFunction_default.ONE
})
};
var BlendingState_default = Object.freeze(BlendingState);
// Source/Scene/CullFace.js
var CullFace = {
FRONT: WebGLConstants_default.FRONT,
BACK: WebGLConstants_default.BACK,
FRONT_AND_BACK: WebGLConstants_default.FRONT_AND_BACK
};
var CullFace_default = Object.freeze(CullFace);
// Source/Scene/Appearance.js
function Appearance(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
this.material = options.material;
this.translucent = defaultValue_default(options.translucent, true);
this._vertexShaderSource = options.vertexShaderSource;
this._fragmentShaderSource = options.fragmentShaderSource;
this._renderState = options.renderState;
this._closed = defaultValue_default(options.closed, false);
}
Object.defineProperties(Appearance.prototype, {
vertexShaderSource: {
get: function() {
return this._vertexShaderSource;
}
},
fragmentShaderSource: {
get: function() {
return this._fragmentShaderSource;
}
},
renderState: {
get: function() {
return this._renderState;
}
},
closed: {
get: function() {
return this._closed;
}
}
});
Appearance.prototype.getFragmentShaderSource = function() {
const parts = [];
if (this.flat) {
parts.push("#define FLAT");
}
if (this.faceForward) {
parts.push("#define FACE_FORWARD");
}
if (defined_default(this.material)) {
parts.push(this.material.shaderSource);
}
parts.push(this.fragmentShaderSource);
return parts.join("\n");
};
Appearance.prototype.isTranslucent = function() {
return defined_default(this.material) && this.material.isTranslucent() || !defined_default(this.material) && this.translucent;
};
Appearance.prototype.getRenderState = function() {
const translucent = this.isTranslucent();
const rs = clone_default(this.renderState, false);
if (translucent) {
rs.depthMask = false;
rs.blending = BlendingState_default.ALPHA_BLEND;
} else {
rs.depthMask = true;
}
return rs;
};
Appearance.getDefaultRenderState = function(translucent, closed, existing) {
let rs = {
depthTest: {
enabled: true
}
};
if (translucent) {
rs.depthMask = false;
rs.blending = BlendingState_default.ALPHA_BLEND;
}
if (closed) {
rs.cull = {
enabled: true,
face: CullFace_default.BACK
};
}
if (defined_default(existing)) {
rs = combine_default(existing, rs, true);
}
return rs;
};
var Appearance_default = Appearance;
// Source/Renderer/ContextLimits.js
var ContextLimits = {
_maximumCombinedTextureImageUnits: 0,
_maximumCubeMapSize: 0,
_maximumFragmentUniformVectors: 0,
_maximumTextureImageUnits: 0,
_maximumRenderbufferSize: 0,
_maximumTextureSize: 0,
_maximumVaryingVectors: 0,
_maximumVertexAttributes: 0,
_maximumVertexTextureImageUnits: 0,
_maximumVertexUniformVectors: 0,
_minimumAliasedLineWidth: 0,
_maximumAliasedLineWidth: 0,
_minimumAliasedPointSize: 0,
_maximumAliasedPointSize: 0,
_maximumViewportWidth: 0,
_maximumViewportHeight: 0,
_maximumTextureFilterAnisotropy: 0,
_maximumDrawBuffers: 0,
_maximumColorAttachments: 0,
_maximumSamples: 0,
_highpFloatSupported: false,
_highpIntSupported: false
};
Object.defineProperties(ContextLimits, {
maximumCombinedTextureImageUnits: {
get: function() {
return ContextLimits._maximumCombinedTextureImageUnits;
}
},
maximumCubeMapSize: {
get: function() {
return ContextLimits._maximumCubeMapSize;
}
},
maximumFragmentUniformVectors: {
get: function() {
return ContextLimits._maximumFragmentUniformVectors;
}
},
maximumTextureImageUnits: {
get: function() {
return ContextLimits._maximumTextureImageUnits;
}
},
maximumRenderbufferSize: {
get: function() {
return ContextLimits._maximumRenderbufferSize;
}
},
maximumTextureSize: {
get: function() {
return ContextLimits._maximumTextureSize;
}
},
maximumVaryingVectors: {
get: function() {
return ContextLimits._maximumVaryingVectors;
}
},
maximumVertexAttributes: {
get: function() {
return ContextLimits._maximumVertexAttributes;
}
},
maximumVertexTextureImageUnits: {
get: function() {
return ContextLimits._maximumVertexTextureImageUnits;
}
},
maximumVertexUniformVectors: {
get: function() {
return ContextLimits._maximumVertexUniformVectors;
}
},
minimumAliasedLineWidth: {
get: function() {
return ContextLimits._minimumAliasedLineWidth;
}
},
maximumAliasedLineWidth: {
get: function() {
return ContextLimits._maximumAliasedLineWidth;
}
},
minimumAliasedPointSize: {
get: function() {
return ContextLimits._minimumAliasedPointSize;
}
},
maximumAliasedPointSize: {
get: function() {
return ContextLimits._maximumAliasedPointSize;
}
},
maximumViewportWidth: {
get: function() {
return ContextLimits._maximumViewportWidth;
}
},
maximumViewportHeight: {
get: function() {
return ContextLimits._maximumViewportHeight;
}
},
maximumTextureFilterAnisotropy: {
get: function() {
return ContextLimits._maximumTextureFilterAnisotropy;
}
},
maximumDrawBuffers: {
get: function() {
return ContextLimits._maximumDrawBuffers;
}
},
maximumColorAttachments: {
get: function() {
return ContextLimits._maximumColorAttachments;
}
},
maximumSamples: {
get: function() {
return ContextLimits._maximumSamples;
}
},
highpFloatSupported: {
get: function() {
return ContextLimits._highpFloatSupported;
}
},
highpIntSupported: {
get: function() {
return ContextLimits._highpIntSupported;
}
}
});
var ContextLimits_default = ContextLimits;
// Source/Renderer/CubeMapFace.js
function CubeMapFace(context, texture, textureTarget, targetFace, internalFormat, pixelFormat, pixelDatatype, size, preMultiplyAlpha, flipY, initialized) {
this._context = context;
this._texture = texture;
this._textureTarget = textureTarget;
this._targetFace = targetFace;
this._pixelDatatype = pixelDatatype;
this._internalFormat = internalFormat;
this._pixelFormat = pixelFormat;
this._size = size;
this._preMultiplyAlpha = preMultiplyAlpha;
this._flipY = flipY;
this._initialized = initialized;
}
Object.defineProperties(CubeMapFace.prototype, {
pixelFormat: {
get: function() {
return this._pixelFormat;
}
},
pixelDatatype: {
get: function() {
return this._pixelDatatype;
}
},
_target: {
get: function() {
return this._targetFace;
}
}
});
CubeMapFace.prototype.copyFrom = function(options) {
Check_default.defined("options", options);
const xOffset = defaultValue_default(options.xOffset, 0);
const yOffset = defaultValue_default(options.yOffset, 0);
Check_default.defined("options.source", options.source);
Check_default.typeOf.number.greaterThanOrEquals("xOffset", xOffset, 0);
Check_default.typeOf.number.greaterThanOrEquals("yOffset", yOffset, 0);
if (xOffset + options.source.width > this._size) {
throw new DeveloperError_default(
"xOffset + options.source.width must be less than or equal to width."
);
}
if (yOffset + options.source.height > this._size) {
throw new DeveloperError_default(
"yOffset + options.source.height must be less than or equal to height."
);
}
const source = options.source;
const gl = this._context._gl;
const target = this._textureTarget;
const targetFace = this._targetFace;
gl.activeTexture(gl.TEXTURE0);
gl.bindTexture(target, this._texture);
const width = source.width;
const height = source.height;
let arrayBufferView = source.arrayBufferView;
const size = this._size;
const pixelFormat = this._pixelFormat;
const internalFormat = this._internalFormat;
const pixelDatatype = this._pixelDatatype;
const preMultiplyAlpha = this._preMultiplyAlpha;
const flipY = this._flipY;
const skipColorSpaceConversion = defaultValue_default(
options.skipColorSpaceConversion,
false
);
let unpackAlignment = 4;
if (defined_default(arrayBufferView)) {
unpackAlignment = PixelFormat_default.alignmentInBytes(
pixelFormat,
pixelDatatype,
width
);
}
gl.pixelStorei(gl.UNPACK_ALIGNMENT, unpackAlignment);
if (skipColorSpaceConversion) {
gl.pixelStorei(gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, gl.NONE);
} else {
gl.pixelStorei(
gl.UNPACK_COLORSPACE_CONVERSION_WEBGL,
gl.BROWSER_DEFAULT_WEBGL
);
}
let uploaded = false;
if (!this._initialized) {
if (xOffset === 0 && yOffset === 0 && width === size && height === size) {
if (defined_default(arrayBufferView)) {
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, false);
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
if (flipY) {
arrayBufferView = PixelFormat_default.flipY(
arrayBufferView,
pixelFormat,
pixelDatatype,
size,
size
);
}
gl.texImage2D(
targetFace,
0,
internalFormat,
size,
size,
0,
pixelFormat,
PixelDatatype_default.toWebGLConstant(pixelDatatype, this._context),
arrayBufferView
);
} else {
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, preMultiplyAlpha);
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, flipY);
gl.texImage2D(
targetFace,
0,
internalFormat,
pixelFormat,
PixelDatatype_default.toWebGLConstant(pixelDatatype, this._context),
source
);
}
uploaded = true;
} else {
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, false);
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
const bufferView = PixelFormat_default.createTypedArray(
pixelFormat,
pixelDatatype,
size,
size
);
gl.texImage2D(
targetFace,
0,
internalFormat,
size,
size,
0,
pixelFormat,
PixelDatatype_default.toWebGLConstant(pixelDatatype, this._context),
bufferView
);
}
this._initialized = true;
}
if (!uploaded) {
if (defined_default(arrayBufferView)) {
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, false);
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
if (flipY) {
arrayBufferView = PixelFormat_default.flipY(
arrayBufferView,
pixelFormat,
pixelDatatype,
width,
height
);
}
gl.texSubImage2D(
targetFace,
0,
xOffset,
yOffset,
width,
height,
pixelFormat,
PixelDatatype_default.toWebGLConstant(pixelDatatype, this._context),
arrayBufferView
);
} else {
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, preMultiplyAlpha);
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, flipY);
gl.texSubImage2D(
targetFace,
0,
xOffset,
yOffset,
pixelFormat,
PixelDatatype_default.toWebGLConstant(pixelDatatype, this._context),
source
);
}
}
gl.bindTexture(target, null);
};
CubeMapFace.prototype.copyFromFramebuffer = function(xOffset, yOffset, framebufferXOffset, framebufferYOffset, width, height) {
xOffset = defaultValue_default(xOffset, 0);
yOffset = defaultValue_default(yOffset, 0);
framebufferXOffset = defaultValue_default(framebufferXOffset, 0);
framebufferYOffset = defaultValue_default(framebufferYOffset, 0);
width = defaultValue_default(width, this._size);
height = defaultValue_default(height, this._size);
Check_default.typeOf.number.greaterThanOrEquals("xOffset", xOffset, 0);
Check_default.typeOf.number.greaterThanOrEquals("yOffset", yOffset, 0);
Check_default.typeOf.number.greaterThanOrEquals(
"framebufferXOffset",
framebufferXOffset,
0
);
Check_default.typeOf.number.greaterThanOrEquals(
"framebufferYOffset",
framebufferYOffset,
0
);
if (xOffset + width > this._size) {
throw new DeveloperError_default(
"xOffset + source.width must be less than or equal to width."
);
}
if (yOffset + height > this._size) {
throw new DeveloperError_default(
"yOffset + source.height must be less than or equal to height."
);
}
if (this._pixelDatatype === PixelDatatype_default.FLOAT) {
throw new DeveloperError_default(
"Cannot call copyFromFramebuffer when the texture pixel data type is FLOAT."
);
}
if (this._pixelDatatype === PixelDatatype_default.HALF_FLOAT) {
throw new DeveloperError_default(
"Cannot call copyFromFramebuffer when the texture pixel data type is HALF_FLOAT."
);
}
const gl = this._context._gl;
const target = this._textureTarget;
gl.activeTexture(gl.TEXTURE0);
gl.bindTexture(target, this._texture);
gl.copyTexSubImage2D(
this._targetFace,
0,
xOffset,
yOffset,
framebufferXOffset,
framebufferYOffset,
width,
height
);
gl.bindTexture(target, null);
this._initialized = true;
};
var CubeMapFace_default = CubeMapFace;
// Source/Renderer/MipmapHint.js
var MipmapHint = {
DONT_CARE: WebGLConstants_default.DONT_CARE,
FASTEST: WebGLConstants_default.FASTEST,
NICEST: WebGLConstants_default.NICEST,
validate: function(mipmapHint) {
return mipmapHint === MipmapHint.DONT_CARE || mipmapHint === MipmapHint.FASTEST || mipmapHint === MipmapHint.NICEST;
}
};
var MipmapHint_default = Object.freeze(MipmapHint);
// Source/Renderer/TextureMagnificationFilter.js
var TextureMagnificationFilter = {
NEAREST: WebGLConstants_default.NEAREST,
LINEAR: WebGLConstants_default.LINEAR
};
TextureMagnificationFilter.validate = function(textureMagnificationFilter) {
return textureMagnificationFilter === TextureMagnificationFilter.NEAREST || textureMagnificationFilter === TextureMagnificationFilter.LINEAR;
};
var TextureMagnificationFilter_default = Object.freeze(TextureMagnificationFilter);
// Source/Renderer/TextureMinificationFilter.js
var TextureMinificationFilter = {
NEAREST: WebGLConstants_default.NEAREST,
LINEAR: WebGLConstants_default.LINEAR,
NEAREST_MIPMAP_NEAREST: WebGLConstants_default.NEAREST_MIPMAP_NEAREST,
LINEAR_MIPMAP_NEAREST: WebGLConstants_default.LINEAR_MIPMAP_NEAREST,
NEAREST_MIPMAP_LINEAR: WebGLConstants_default.NEAREST_MIPMAP_LINEAR,
LINEAR_MIPMAP_LINEAR: WebGLConstants_default.LINEAR_MIPMAP_LINEAR
};
TextureMinificationFilter.validate = function(textureMinificationFilter) {
return textureMinificationFilter === TextureMinificationFilter.NEAREST || textureMinificationFilter === TextureMinificationFilter.LINEAR || textureMinificationFilter === TextureMinificationFilter.NEAREST_MIPMAP_NEAREST || textureMinificationFilter === TextureMinificationFilter.LINEAR_MIPMAP_NEAREST || textureMinificationFilter === TextureMinificationFilter.NEAREST_MIPMAP_LINEAR || textureMinificationFilter === TextureMinificationFilter.LINEAR_MIPMAP_LINEAR;
};
var TextureMinificationFilter_default = Object.freeze(TextureMinificationFilter);
// Source/Renderer/TextureWrap.js
var TextureWrap = {
CLAMP_TO_EDGE: WebGLConstants_default.CLAMP_TO_EDGE,
REPEAT: WebGLConstants_default.REPEAT,
MIRRORED_REPEAT: WebGLConstants_default.MIRRORED_REPEAT,
validate: function(textureWrap) {
return textureWrap === TextureWrap.CLAMP_TO_EDGE || textureWrap === TextureWrap.REPEAT || textureWrap === TextureWrap.MIRRORED_REPEAT;
}
};
var TextureWrap_default = Object.freeze(TextureWrap);
// Source/Renderer/Sampler.js
function Sampler(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
const wrapS = defaultValue_default(options.wrapS, TextureWrap_default.CLAMP_TO_EDGE);
const wrapT = defaultValue_default(options.wrapT, TextureWrap_default.CLAMP_TO_EDGE);
const minificationFilter = defaultValue_default(
options.minificationFilter,
TextureMinificationFilter_default.LINEAR
);
const magnificationFilter = defaultValue_default(
options.magnificationFilter,
TextureMagnificationFilter_default.LINEAR
);
const maximumAnisotropy = defined_default(options.maximumAnisotropy) ? options.maximumAnisotropy : 1;
if (!TextureWrap_default.validate(wrapS)) {
throw new DeveloperError_default("Invalid sampler.wrapS.");
}
if (!TextureWrap_default.validate(wrapT)) {
throw new DeveloperError_default("Invalid sampler.wrapT.");
}
if (!TextureMinificationFilter_default.validate(minificationFilter)) {
throw new DeveloperError_default("Invalid sampler.minificationFilter.");
}
if (!TextureMagnificationFilter_default.validate(magnificationFilter)) {
throw new DeveloperError_default("Invalid sampler.magnificationFilter.");
}
Check_default.typeOf.number.greaterThanOrEquals(
"maximumAnisotropy",
maximumAnisotropy,
1
);
this._wrapS = wrapS;
this._wrapT = wrapT;
this._minificationFilter = minificationFilter;
this._magnificationFilter = magnificationFilter;
this._maximumAnisotropy = maximumAnisotropy;
}
Object.defineProperties(Sampler.prototype, {
wrapS: {
get: function() {
return this._wrapS;
}
},
wrapT: {
get: function() {
return this._wrapT;
}
},
minificationFilter: {
get: function() {
return this._minificationFilter;
}
},
magnificationFilter: {
get: function() {
return this._magnificationFilter;
}
},
maximumAnisotropy: {
get: function() {
return this._maximumAnisotropy;
}
}
});
Sampler.equals = function(left, right) {
return left === right || defined_default(left) && defined_default(right) && left._wrapS === right._wrapS && left._wrapT === right._wrapT && left._minificationFilter === right._minificationFilter && left._magnificationFilter === right._magnificationFilter && left._maximumAnisotropy === right._maximumAnisotropy;
};
Sampler.NEAREST = Object.freeze(
new Sampler({
wrapS: TextureWrap_default.CLAMP_TO_EDGE,
wrapT: TextureWrap_default.CLAMP_TO_EDGE,
minificationFilter: TextureMinificationFilter_default.NEAREST,
magnificationFilter: TextureMagnificationFilter_default.NEAREST
})
);
var Sampler_default = Sampler;
// Source/Renderer/CubeMap.js
function CubeMap(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
Check_default.defined("options.context", options.context);
const context = options.context;
const source = options.source;
let width;
let height;
if (defined_default(source)) {
const faces2 = [
source.positiveX,
source.negativeX,
source.positiveY,
source.negativeY,
source.positiveZ,
source.negativeZ
];
if (!faces2[0] || !faces2[1] || !faces2[2] || !faces2[3] || !faces2[4] || !faces2[5]) {
throw new DeveloperError_default(
"options.source requires positiveX, negativeX, positiveY, negativeY, positiveZ, and negativeZ faces."
);
}
width = faces2[0].width;
height = faces2[0].height;
for (let i = 1; i < 6; ++i) {
if (Number(faces2[i].width) !== width || Number(faces2[i].height) !== height) {
throw new DeveloperError_default(
"Each face in options.source must have the same width and height."
);
}
}
} else {
width = options.width;
height = options.height;
}
const size = width;
const pixelDatatype = defaultValue_default(
options.pixelDatatype,
PixelDatatype_default.UNSIGNED_BYTE
);
const pixelFormat = defaultValue_default(options.pixelFormat, PixelFormat_default.RGBA);
const internalFormat = PixelFormat_default.toInternalFormat(
pixelFormat,
pixelDatatype,
context
);
if (!defined_default(width) || !defined_default(height)) {
throw new DeveloperError_default(
"options requires a source field to create an initialized cube map or width and height fields to create a blank cube map."
);
}
if (width !== height) {
throw new DeveloperError_default("Width must equal height.");
}
if (size <= 0) {
throw new DeveloperError_default("Width and height must be greater than zero.");
}
if (size > ContextLimits_default.maximumCubeMapSize) {
throw new DeveloperError_default(
`Width and height must be less than or equal to the maximum cube map size (${ContextLimits_default.maximumCubeMapSize}). Check maximumCubeMapSize.`
);
}
if (!PixelFormat_default.validate(pixelFormat)) {
throw new DeveloperError_default("Invalid options.pixelFormat.");
}
if (PixelFormat_default.isDepthFormat(pixelFormat)) {
throw new DeveloperError_default(
"options.pixelFormat cannot be DEPTH_COMPONENT or DEPTH_STENCIL."
);
}
if (!PixelDatatype_default.validate(pixelDatatype)) {
throw new DeveloperError_default("Invalid options.pixelDatatype.");
}
if (pixelDatatype === PixelDatatype_default.FLOAT && !context.floatingPointTexture) {
throw new DeveloperError_default(
"When options.pixelDatatype is FLOAT, this WebGL implementation must support the OES_texture_float extension."
);
}
if (pixelDatatype === PixelDatatype_default.HALF_FLOAT && !context.halfFloatingPointTexture) {
throw new DeveloperError_default(
"When options.pixelDatatype is HALF_FLOAT, this WebGL implementation must support the OES_texture_half_float extension."
);
}
const sizeInBytes = PixelFormat_default.textureSizeInBytes(pixelFormat, pixelDatatype, size, size) * 6;
const preMultiplyAlpha = options.preMultiplyAlpha || pixelFormat === PixelFormat_default.RGB || pixelFormat === PixelFormat_default.LUMINANCE;
const flipY = defaultValue_default(options.flipY, true);
const skipColorSpaceConversion = defaultValue_default(
options.skipColorSpaceConversion,
false
);
const gl = context._gl;
const textureTarget = gl.TEXTURE_CUBE_MAP;
const texture = gl.createTexture();
gl.activeTexture(gl.TEXTURE0);
gl.bindTexture(textureTarget, texture);
function createFace(target, sourceFace, preMultiplyAlpha2, flipY2, skipColorSpaceConversion2) {
let arrayBufferView = sourceFace.arrayBufferView;
if (!defined_default(arrayBufferView)) {
arrayBufferView = sourceFace.bufferView;
}
let unpackAlignment = 4;
if (defined_default(arrayBufferView)) {
unpackAlignment = PixelFormat_default.alignmentInBytes(
pixelFormat,
pixelDatatype,
width
);
}
gl.pixelStorei(gl.UNPACK_ALIGNMENT, unpackAlignment);
if (skipColorSpaceConversion2) {
gl.pixelStorei(gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, gl.NONE);
} else {
gl.pixelStorei(
gl.UNPACK_COLORSPACE_CONVERSION_WEBGL,
gl.BROWSER_DEFAULT_WEBGL
);
}
if (defined_default(arrayBufferView)) {
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, false);
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
if (flipY2) {
arrayBufferView = PixelFormat_default.flipY(
arrayBufferView,
pixelFormat,
pixelDatatype,
size,
size
);
}
gl.texImage2D(
target,
0,
internalFormat,
size,
size,
0,
pixelFormat,
PixelDatatype_default.toWebGLConstant(pixelDatatype, context),
arrayBufferView
);
} else {
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, preMultiplyAlpha2);
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, flipY2);
gl.texImage2D(
target,
0,
internalFormat,
pixelFormat,
PixelDatatype_default.toWebGLConstant(pixelDatatype, context),
sourceFace
);
}
}
if (defined_default(source)) {
createFace(
gl.TEXTURE_CUBE_MAP_POSITIVE_X,
source.positiveX,
preMultiplyAlpha,
flipY,
skipColorSpaceConversion
);
createFace(
gl.TEXTURE_CUBE_MAP_NEGATIVE_X,
source.negativeX,
preMultiplyAlpha,
flipY,
skipColorSpaceConversion
);
createFace(
gl.TEXTURE_CUBE_MAP_POSITIVE_Y,
source.positiveY,
preMultiplyAlpha,
flipY,
skipColorSpaceConversion
);
createFace(
gl.TEXTURE_CUBE_MAP_NEGATIVE_Y,
source.negativeY,
preMultiplyAlpha,
flipY,
skipColorSpaceConversion
);
createFace(
gl.TEXTURE_CUBE_MAP_POSITIVE_Z,
source.positiveZ,
preMultiplyAlpha,
flipY,
skipColorSpaceConversion
);
createFace(
gl.TEXTURE_CUBE_MAP_NEGATIVE_Z,
source.negativeZ,
preMultiplyAlpha,
flipY,
skipColorSpaceConversion
);
} else {
gl.texImage2D(
gl.TEXTURE_CUBE_MAP_POSITIVE_X,
0,
internalFormat,
size,
size,
0,
pixelFormat,
PixelDatatype_default.toWebGLConstant(pixelDatatype, context),
null
);
gl.texImage2D(
gl.TEXTURE_CUBE_MAP_NEGATIVE_X,
0,
internalFormat,
size,
size,
0,
pixelFormat,
PixelDatatype_default.toWebGLConstant(pixelDatatype, context),
null
);
gl.texImage2D(
gl.TEXTURE_CUBE_MAP_POSITIVE_Y,
0,
internalFormat,
size,
size,
0,
pixelFormat,
PixelDatatype_default.toWebGLConstant(pixelDatatype, context),
null
);
gl.texImage2D(
gl.TEXTURE_CUBE_MAP_NEGATIVE_Y,
0,
internalFormat,
size,
size,
0,
pixelFormat,
PixelDatatype_default.toWebGLConstant(pixelDatatype, context),
null
);
gl.texImage2D(
gl.TEXTURE_CUBE_MAP_POSITIVE_Z,
0,
internalFormat,
size,
size,
0,
pixelFormat,
PixelDatatype_default.toWebGLConstant(pixelDatatype, context),
null
);
gl.texImage2D(
gl.TEXTURE_CUBE_MAP_NEGATIVE_Z,
0,
internalFormat,
size,
size,
0,
pixelFormat,
PixelDatatype_default.toWebGLConstant(pixelDatatype, context),
null
);
}
gl.bindTexture(textureTarget, null);
this._context = context;
this._textureFilterAnisotropic = context._textureFilterAnisotropic;
this._textureTarget = textureTarget;
this._texture = texture;
this._pixelFormat = pixelFormat;
this._pixelDatatype = pixelDatatype;
this._size = size;
this._hasMipmap = false;
this._sizeInBytes = sizeInBytes;
this._preMultiplyAlpha = preMultiplyAlpha;
this._flipY = flipY;
this._sampler = void 0;
const initialized = defined_default(source);
this._positiveX = new CubeMapFace_default(
context,
texture,
textureTarget,
gl.TEXTURE_CUBE_MAP_POSITIVE_X,
internalFormat,
pixelFormat,
pixelDatatype,
size,
preMultiplyAlpha,
flipY,
initialized
);
this._negativeX = new CubeMapFace_default(
context,
texture,
textureTarget,
gl.TEXTURE_CUBE_MAP_NEGATIVE_X,
internalFormat,
pixelFormat,
pixelDatatype,
size,
preMultiplyAlpha,
flipY,
initialized
);
this._positiveY = new CubeMapFace_default(
context,
texture,
textureTarget,
gl.TEXTURE_CUBE_MAP_POSITIVE_Y,
internalFormat,
pixelFormat,
pixelDatatype,
size,
preMultiplyAlpha,
flipY,
initialized
);
this._negativeY = new CubeMapFace_default(
context,
texture,
textureTarget,
gl.TEXTURE_CUBE_MAP_NEGATIVE_Y,
internalFormat,
pixelFormat,
pixelDatatype,
size,
preMultiplyAlpha,
flipY,
initialized
);
this._positiveZ = new CubeMapFace_default(
context,
texture,
textureTarget,
gl.TEXTURE_CUBE_MAP_POSITIVE_Z,
internalFormat,
pixelFormat,
pixelDatatype,
size,
preMultiplyAlpha,
flipY,
initialized
);
this._negativeZ = new CubeMapFace_default(
context,
texture,
textureTarget,
gl.TEXTURE_CUBE_MAP_NEGATIVE_Z,
internalFormat,
pixelFormat,
pixelDatatype,
size,
preMultiplyAlpha,
flipY,
initialized
);
this.sampler = defined_default(options.sampler) ? options.sampler : new Sampler_default();
}
Object.defineProperties(CubeMap.prototype, {
positiveX: {
get: function() {
return this._positiveX;
}
},
negativeX: {
get: function() {
return this._negativeX;
}
},
positiveY: {
get: function() {
return this._positiveY;
}
},
negativeY: {
get: function() {
return this._negativeY;
}
},
positiveZ: {
get: function() {
return this._positiveZ;
}
},
negativeZ: {
get: function() {
return this._negativeZ;
}
},
sampler: {
get: function() {
return this._sampler;
},
set: function(sampler) {
let minificationFilter = sampler.minificationFilter;
let magnificationFilter = sampler.magnificationFilter;
const mipmap = minificationFilter === TextureMinificationFilter_default.NEAREST_MIPMAP_NEAREST || minificationFilter === TextureMinificationFilter_default.NEAREST_MIPMAP_LINEAR || minificationFilter === TextureMinificationFilter_default.LINEAR_MIPMAP_NEAREST || minificationFilter === TextureMinificationFilter_default.LINEAR_MIPMAP_LINEAR;
const context = this._context;
const pixelDatatype = this._pixelDatatype;
if (pixelDatatype === PixelDatatype_default.FLOAT && !context.textureFloatLinear || pixelDatatype === PixelDatatype_default.HALF_FLOAT && !context.textureHalfFloatLinear) {
minificationFilter = mipmap ? TextureMinificationFilter_default.NEAREST_MIPMAP_NEAREST : TextureMinificationFilter_default.NEAREST;
magnificationFilter = TextureMagnificationFilter_default.NEAREST;
}
const gl = context._gl;
const target = this._textureTarget;
gl.activeTexture(gl.TEXTURE0);
gl.bindTexture(target, this._texture);
gl.texParameteri(target, gl.TEXTURE_MIN_FILTER, minificationFilter);
gl.texParameteri(target, gl.TEXTURE_MAG_FILTER, magnificationFilter);
gl.texParameteri(target, gl.TEXTURE_WRAP_S, sampler.wrapS);
gl.texParameteri(target, gl.TEXTURE_WRAP_T, sampler.wrapT);
if (defined_default(this._textureFilterAnisotropic)) {
gl.texParameteri(
target,
this._textureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,
sampler.maximumAnisotropy
);
}
gl.bindTexture(target, null);
this._sampler = sampler;
}
},
pixelFormat: {
get: function() {
return this._pixelFormat;
}
},
pixelDatatype: {
get: function() {
return this._pixelDatatype;
}
},
width: {
get: function() {
return this._size;
}
},
height: {
get: function() {
return this._size;
}
},
sizeInBytes: {
get: function() {
if (this._hasMipmap) {
return Math.floor(this._sizeInBytes * 4 / 3);
}
return this._sizeInBytes;
}
},
preMultiplyAlpha: {
get: function() {
return this._preMultiplyAlpha;
}
},
flipY: {
get: function() {
return this._flipY;
}
},
_target: {
get: function() {
return this._textureTarget;
}
}
});
CubeMap.prototype.generateMipmap = function(hint) {
hint = defaultValue_default(hint, MipmapHint_default.DONT_CARE);
if (this._size > 1 && !Math_default.isPowerOfTwo(this._size)) {
throw new DeveloperError_default(
"width and height must be a power of two to call generateMipmap()."
);
}
if (!MipmapHint_default.validate(hint)) {
throw new DeveloperError_default("hint is invalid.");
}
this._hasMipmap = true;
const gl = this._context._gl;
const target = this._textureTarget;
gl.hint(gl.GENERATE_MIPMAP_HINT, hint);
gl.activeTexture(gl.TEXTURE0);
gl.bindTexture(target, this._texture);
gl.generateMipmap(target);
gl.bindTexture(target, null);
};
CubeMap.prototype.isDestroyed = function() {
return false;
};
CubeMap.prototype.destroy = function() {
this._context._gl.deleteTexture(this._texture);
this._positiveX = destroyObject_default(this._positiveX);
this._negativeX = destroyObject_default(this._negativeX);
this._positiveY = destroyObject_default(this._positiveY);
this._negativeY = destroyObject_default(this._negativeY);
this._positiveZ = destroyObject_default(this._positiveZ);
this._negativeZ = destroyObject_default(this._negativeZ);
return destroyObject_default(this);
};
var CubeMap_default = CubeMap;
// Source/Renderer/Texture.js
function Texture(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
Check_default.defined("options.context", options.context);
const context = options.context;
let width = options.width;
let height = options.height;
const source = options.source;
if (defined_default(source)) {
if (!defined_default(width)) {
width = defaultValue_default(source.videoWidth, source.width);
}
if (!defined_default(height)) {
height = defaultValue_default(source.videoHeight, source.height);
}
}
const pixelFormat = defaultValue_default(options.pixelFormat, PixelFormat_default.RGBA);
const pixelDatatype = defaultValue_default(
options.pixelDatatype,
PixelDatatype_default.UNSIGNED_BYTE
);
const internalFormat = PixelFormat_default.toInternalFormat(
pixelFormat,
pixelDatatype,
context
);
const isCompressed = PixelFormat_default.isCompressedFormat(internalFormat);
if (!defined_default(width) || !defined_default(height)) {
throw new DeveloperError_default(
"options requires a source field to create an initialized texture or width and height fields to create a blank texture."
);
}
Check_default.typeOf.number.greaterThan("width", width, 0);
if (width > ContextLimits_default.maximumTextureSize) {
throw new DeveloperError_default(
`Width must be less than or equal to the maximum texture size (${ContextLimits_default.maximumTextureSize}). Check maximumTextureSize.`
);
}
Check_default.typeOf.number.greaterThan("height", height, 0);
if (height > ContextLimits_default.maximumTextureSize) {
throw new DeveloperError_default(
`Height must be less than or equal to the maximum texture size (${ContextLimits_default.maximumTextureSize}). Check maximumTextureSize.`
);
}
if (!PixelFormat_default.validate(pixelFormat)) {
throw new DeveloperError_default("Invalid options.pixelFormat.");
}
if (!isCompressed && !PixelDatatype_default.validate(pixelDatatype)) {
throw new DeveloperError_default("Invalid options.pixelDatatype.");
}
if (pixelFormat === PixelFormat_default.DEPTH_COMPONENT && pixelDatatype !== PixelDatatype_default.UNSIGNED_SHORT && pixelDatatype !== PixelDatatype_default.UNSIGNED_INT) {
throw new DeveloperError_default(
"When options.pixelFormat is DEPTH_COMPONENT, options.pixelDatatype must be UNSIGNED_SHORT or UNSIGNED_INT."
);
}
if (pixelFormat === PixelFormat_default.DEPTH_STENCIL && pixelDatatype !== PixelDatatype_default.UNSIGNED_INT_24_8) {
throw new DeveloperError_default(
"When options.pixelFormat is DEPTH_STENCIL, options.pixelDatatype must be UNSIGNED_INT_24_8."
);
}
if (pixelDatatype === PixelDatatype_default.FLOAT && !context.floatingPointTexture) {
throw new DeveloperError_default(
"When options.pixelDatatype is FLOAT, this WebGL implementation must support the OES_texture_float extension. Check context.floatingPointTexture."
);
}
if (pixelDatatype === PixelDatatype_default.HALF_FLOAT && !context.halfFloatingPointTexture) {
throw new DeveloperError_default(
"When options.pixelDatatype is HALF_FLOAT, this WebGL implementation must support the OES_texture_half_float extension. Check context.halfFloatingPointTexture."
);
}
if (PixelFormat_default.isDepthFormat(pixelFormat)) {
if (defined_default(source)) {
throw new DeveloperError_default(
"When options.pixelFormat is DEPTH_COMPONENT or DEPTH_STENCIL, source cannot be provided."
);
}
if (!context.depthTexture) {
throw new DeveloperError_default(
"When options.pixelFormat is DEPTH_COMPONENT or DEPTH_STENCIL, this WebGL implementation must support WEBGL_depth_texture. Check context.depthTexture."
);
}
}
if (isCompressed) {
if (!defined_default(source) || !defined_default(source.arrayBufferView)) {
throw new DeveloperError_default(
"When options.pixelFormat is compressed, options.source.arrayBufferView must be defined."
);
}
if (PixelFormat_default.isDXTFormat(internalFormat) && !context.s3tc) {
throw new DeveloperError_default(
"When options.pixelFormat is S3TC compressed, this WebGL implementation must support the WEBGL_compressed_texture_s3tc extension. Check context.s3tc."
);
} else if (PixelFormat_default.isPVRTCFormat(internalFormat) && !context.pvrtc) {
throw new DeveloperError_default(
"When options.pixelFormat is PVRTC compressed, this WebGL implementation must support the WEBGL_compressed_texture_pvrtc extension. Check context.pvrtc."
);
} else if (PixelFormat_default.isASTCFormat(internalFormat) && !context.astc) {
throw new DeveloperError_default(
"When options.pixelFormat is ASTC compressed, this WebGL implementation must support the WEBGL_compressed_texture_astc extension. Check context.astc."
);
} else if (PixelFormat_default.isETC2Format(internalFormat) && !context.etc) {
throw new DeveloperError_default(
"When options.pixelFormat is ETC2 compressed, this WebGL implementation must support the WEBGL_compressed_texture_etc extension. Check context.etc."
);
} else if (PixelFormat_default.isETC1Format(internalFormat) && !context.etc1) {
throw new DeveloperError_default(
"When options.pixelFormat is ETC1 compressed, this WebGL implementation must support the WEBGL_compressed_texture_etc1 extension. Check context.etc1."
);
} else if (PixelFormat_default.isBC7Format(internalFormat) && !context.bc7) {
throw new DeveloperError_default(
"When options.pixelFormat is BC7 compressed, this WebGL implementation must support the EXT_texture_compression_bptc extension. Check context.bc7."
);
}
if (PixelFormat_default.compressedTextureSizeInBytes(
internalFormat,
width,
height
) !== source.arrayBufferView.byteLength) {
throw new DeveloperError_default(
"The byte length of the array buffer is invalid for the compressed texture with the given width and height."
);
}
}
const preMultiplyAlpha = options.preMultiplyAlpha || pixelFormat === PixelFormat_default.RGB || pixelFormat === PixelFormat_default.LUMINANCE;
const flipY = defaultValue_default(options.flipY, true);
const skipColorSpaceConversion = defaultValue_default(
options.skipColorSpaceConversion,
false
);
let initialized = true;
const gl = context._gl;
const textureTarget = gl.TEXTURE_2D;
const texture = gl.createTexture();
gl.activeTexture(gl.TEXTURE0);
gl.bindTexture(textureTarget, texture);
let unpackAlignment = 4;
if (defined_default(source) && defined_default(source.arrayBufferView) && !isCompressed) {
unpackAlignment = PixelFormat_default.alignmentInBytes(
pixelFormat,
pixelDatatype,
width
);
}
gl.pixelStorei(gl.UNPACK_ALIGNMENT, unpackAlignment);
if (skipColorSpaceConversion) {
gl.pixelStorei(gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, gl.NONE);
} else {
gl.pixelStorei(
gl.UNPACK_COLORSPACE_CONVERSION_WEBGL,
gl.BROWSER_DEFAULT_WEBGL
);
}
if (defined_default(source)) {
if (defined_default(source.arrayBufferView)) {
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, false);
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
let arrayBufferView = source.arrayBufferView;
let i, mipWidth, mipHeight;
if (isCompressed) {
gl.compressedTexImage2D(
textureTarget,
0,
internalFormat,
width,
height,
0,
arrayBufferView
);
if (defined_default(source.mipLevels)) {
mipWidth = width;
mipHeight = height;
for (i = 0; i < source.mipLevels.length; ++i) {
mipWidth = Math.floor(mipWidth / 2) | 0;
if (mipWidth < 1) {
mipWidth = 1;
}
mipHeight = Math.floor(mipHeight / 2) | 0;
if (mipHeight < 1) {
mipHeight = 1;
}
gl.compressedTexImage2D(
textureTarget,
i + 1,
internalFormat,
mipWidth,
mipHeight,
0,
source.mipLevels[i]
);
}
}
} else {
if (flipY) {
arrayBufferView = PixelFormat_default.flipY(
arrayBufferView,
pixelFormat,
pixelDatatype,
width,
height
);
}
gl.texImage2D(
textureTarget,
0,
internalFormat,
width,
height,
0,
pixelFormat,
PixelDatatype_default.toWebGLConstant(pixelDatatype, context),
arrayBufferView
);
if (defined_default(source.mipLevels)) {
mipWidth = width;
mipHeight = height;
for (i = 0; i < source.mipLevels.length; ++i) {
mipWidth = Math.floor(mipWidth / 2) | 0;
if (mipWidth < 1) {
mipWidth = 1;
}
mipHeight = Math.floor(mipHeight / 2) | 0;
if (mipHeight < 1) {
mipHeight = 1;
}
gl.texImage2D(
textureTarget,
i + 1,
internalFormat,
mipWidth,
mipHeight,
0,
pixelFormat,
PixelDatatype_default.toWebGLConstant(pixelDatatype, context),
source.mipLevels[i]
);
}
}
}
} else if (defined_default(source.framebuffer)) {
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, false);
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
if (source.framebuffer !== context.defaultFramebuffer) {
source.framebuffer._bind();
}
gl.copyTexImage2D(
textureTarget,
0,
internalFormat,
source.xOffset,
source.yOffset,
width,
height,
0
);
if (source.framebuffer !== context.defaultFramebuffer) {
source.framebuffer._unBind();
}
} else {
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, preMultiplyAlpha);
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, flipY);
gl.texImage2D(
textureTarget,
0,
internalFormat,
pixelFormat,
PixelDatatype_default.toWebGLConstant(pixelDatatype, context),
source
);
}
} else {
gl.texImage2D(
textureTarget,
0,
internalFormat,
width,
height,
0,
pixelFormat,
PixelDatatype_default.toWebGLConstant(pixelDatatype, context),
null
);
initialized = false;
}
gl.bindTexture(textureTarget, null);
let sizeInBytes;
if (isCompressed) {
sizeInBytes = PixelFormat_default.compressedTextureSizeInBytes(
pixelFormat,
width,
height
);
} else {
sizeInBytes = PixelFormat_default.textureSizeInBytes(
pixelFormat,
pixelDatatype,
width,
height
);
}
this._id = createGuid_default();
this._context = context;
this._textureFilterAnisotropic = context._textureFilterAnisotropic;
this._textureTarget = textureTarget;
this._texture = texture;
this._internalFormat = internalFormat;
this._pixelFormat = pixelFormat;
this._pixelDatatype = pixelDatatype;
this._width = width;
this._height = height;
this._dimensions = new Cartesian2_default(width, height);
this._hasMipmap = false;
this._sizeInBytes = sizeInBytes;
this._preMultiplyAlpha = preMultiplyAlpha;
this._flipY = flipY;
this._initialized = initialized;
this._sampler = void 0;
this.sampler = defined_default(options.sampler) ? options.sampler : new Sampler_default();
}
Texture.create = function(options) {
return new Texture(options);
};
Texture.fromFramebuffer = function(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
Check_default.defined("options.context", options.context);
const context = options.context;
const gl = context._gl;
const pixelFormat = defaultValue_default(options.pixelFormat, PixelFormat_default.RGB);
const framebufferXOffset = defaultValue_default(options.framebufferXOffset, 0);
const framebufferYOffset = defaultValue_default(options.framebufferYOffset, 0);
const width = defaultValue_default(options.width, gl.drawingBufferWidth);
const height = defaultValue_default(options.height, gl.drawingBufferHeight);
const framebuffer = options.framebuffer;
if (!PixelFormat_default.validate(pixelFormat)) {
throw new DeveloperError_default("Invalid pixelFormat.");
}
if (PixelFormat_default.isDepthFormat(pixelFormat) || PixelFormat_default.isCompressedFormat(pixelFormat)) {
throw new DeveloperError_default(
"pixelFormat cannot be DEPTH_COMPONENT, DEPTH_STENCIL or a compressed format."
);
}
Check_default.defined("options.context", options.context);
Check_default.typeOf.number.greaterThanOrEquals(
"framebufferXOffset",
framebufferXOffset,
0
);
Check_default.typeOf.number.greaterThanOrEquals(
"framebufferYOffset",
framebufferYOffset,
0
);
if (framebufferXOffset + width > gl.drawingBufferWidth) {
throw new DeveloperError_default(
"framebufferXOffset + width must be less than or equal to drawingBufferWidth"
);
}
if (framebufferYOffset + height > gl.drawingBufferHeight) {
throw new DeveloperError_default(
"framebufferYOffset + height must be less than or equal to drawingBufferHeight."
);
}
const texture = new Texture({
context,
width,
height,
pixelFormat,
source: {
framebuffer: defined_default(framebuffer) ? framebuffer : context.defaultFramebuffer,
xOffset: framebufferXOffset,
yOffset: framebufferYOffset,
width,
height
}
});
return texture;
};
Object.defineProperties(Texture.prototype, {
id: {
get: function() {
return this._id;
}
},
sampler: {
get: function() {
return this._sampler;
},
set: function(sampler) {
let minificationFilter = sampler.minificationFilter;
let magnificationFilter = sampler.magnificationFilter;
const context = this._context;
const pixelFormat = this._pixelFormat;
const pixelDatatype = this._pixelDatatype;
const mipmap = minificationFilter === TextureMinificationFilter_default.NEAREST_MIPMAP_NEAREST || minificationFilter === TextureMinificationFilter_default.NEAREST_MIPMAP_LINEAR || minificationFilter === TextureMinificationFilter_default.LINEAR_MIPMAP_NEAREST || minificationFilter === TextureMinificationFilter_default.LINEAR_MIPMAP_LINEAR;
if (pixelDatatype === PixelDatatype_default.FLOAT && !context.textureFloatLinear || pixelDatatype === PixelDatatype_default.HALF_FLOAT && !context.textureHalfFloatLinear) {
minificationFilter = mipmap ? TextureMinificationFilter_default.NEAREST_MIPMAP_NEAREST : TextureMinificationFilter_default.NEAREST;
magnificationFilter = TextureMagnificationFilter_default.NEAREST;
}
if (context.webgl2) {
if (PixelFormat_default.isDepthFormat(pixelFormat)) {
minificationFilter = TextureMinificationFilter_default.NEAREST;
magnificationFilter = TextureMagnificationFilter_default.NEAREST;
}
}
const gl = context._gl;
const target = this._textureTarget;
gl.activeTexture(gl.TEXTURE0);
gl.bindTexture(target, this._texture);
gl.texParameteri(target, gl.TEXTURE_MIN_FILTER, minificationFilter);
gl.texParameteri(target, gl.TEXTURE_MAG_FILTER, magnificationFilter);
gl.texParameteri(target, gl.TEXTURE_WRAP_S, sampler.wrapS);
gl.texParameteri(target, gl.TEXTURE_WRAP_T, sampler.wrapT);
if (defined_default(this._textureFilterAnisotropic)) {
gl.texParameteri(
target,
this._textureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,
sampler.maximumAnisotropy
);
}
gl.bindTexture(target, null);
this._sampler = sampler;
}
},
pixelFormat: {
get: function() {
return this._pixelFormat;
}
},
pixelDatatype: {
get: function() {
return this._pixelDatatype;
}
},
dimensions: {
get: function() {
return this._dimensions;
}
},
preMultiplyAlpha: {
get: function() {
return this._preMultiplyAlpha;
}
},
flipY: {
get: function() {
return this._flipY;
}
},
width: {
get: function() {
return this._width;
}
},
height: {
get: function() {
return this._height;
}
},
sizeInBytes: {
get: function() {
if (this._hasMipmap) {
return Math.floor(this._sizeInBytes * 4 / 3);
}
return this._sizeInBytes;
}
},
_target: {
get: function() {
return this._textureTarget;
}
}
});
Texture.prototype.copyFrom = function(options) {
Check_default.defined("options", options);
const xOffset = defaultValue_default(options.xOffset, 0);
const yOffset = defaultValue_default(options.yOffset, 0);
Check_default.defined("options.source", options.source);
if (PixelFormat_default.isDepthFormat(this._pixelFormat)) {
throw new DeveloperError_default(
"Cannot call copyFrom when the texture pixel format is DEPTH_COMPONENT or DEPTH_STENCIL."
);
}
if (PixelFormat_default.isCompressedFormat(this._pixelFormat)) {
throw new DeveloperError_default(
"Cannot call copyFrom with a compressed texture pixel format."
);
}
Check_default.typeOf.number.greaterThanOrEquals("xOffset", xOffset, 0);
Check_default.typeOf.number.greaterThanOrEquals("yOffset", yOffset, 0);
Check_default.typeOf.number.lessThanOrEquals(
"xOffset + options.source.width",
xOffset + options.source.width,
this._width
);
Check_default.typeOf.number.lessThanOrEquals(
"yOffset + options.source.height",
yOffset + options.source.height,
this._height
);
const source = options.source;
const context = this._context;
const gl = context._gl;
const target = this._textureTarget;
gl.activeTexture(gl.TEXTURE0);
gl.bindTexture(target, this._texture);
const width = source.width;
const height = source.height;
let arrayBufferView = source.arrayBufferView;
const textureWidth = this._width;
const textureHeight = this._height;
const internalFormat = this._internalFormat;
const pixelFormat = this._pixelFormat;
const pixelDatatype = this._pixelDatatype;
const preMultiplyAlpha = this._preMultiplyAlpha;
const flipY = this._flipY;
const skipColorSpaceConversion = defaultValue_default(
options.skipColorSpaceConversion,
false
);
let unpackAlignment = 4;
if (defined_default(arrayBufferView)) {
unpackAlignment = PixelFormat_default.alignmentInBytes(
pixelFormat,
pixelDatatype,
width
);
}
gl.pixelStorei(gl.UNPACK_ALIGNMENT, unpackAlignment);
if (skipColorSpaceConversion) {
gl.pixelStorei(gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, gl.NONE);
} else {
gl.pixelStorei(
gl.UNPACK_COLORSPACE_CONVERSION_WEBGL,
gl.BROWSER_DEFAULT_WEBGL
);
}
let uploaded = false;
if (!this._initialized) {
if (xOffset === 0 && yOffset === 0 && width === textureWidth && height === textureHeight) {
if (defined_default(arrayBufferView)) {
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, false);
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
if (flipY) {
arrayBufferView = PixelFormat_default.flipY(
arrayBufferView,
pixelFormat,
pixelDatatype,
textureWidth,
textureHeight
);
}
gl.texImage2D(
target,
0,
internalFormat,
textureWidth,
textureHeight,
0,
pixelFormat,
PixelDatatype_default.toWebGLConstant(pixelDatatype, context),
arrayBufferView
);
} else {
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, preMultiplyAlpha);
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, flipY);
gl.texImage2D(
target,
0,
internalFormat,
pixelFormat,
PixelDatatype_default.toWebGLConstant(pixelDatatype, context),
source
);
}
uploaded = true;
} else {
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, false);
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
const bufferView = PixelFormat_default.createTypedArray(
pixelFormat,
pixelDatatype,
textureWidth,
textureHeight
);
gl.texImage2D(
target,
0,
internalFormat,
textureWidth,
textureHeight,
0,
pixelFormat,
PixelDatatype_default.toWebGLConstant(pixelDatatype, context),
bufferView
);
}
this._initialized = true;
}
if (!uploaded) {
if (defined_default(arrayBufferView)) {
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, false);
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
if (flipY) {
arrayBufferView = PixelFormat_default.flipY(
arrayBufferView,
pixelFormat,
pixelDatatype,
width,
height
);
}
gl.texSubImage2D(
target,
0,
xOffset,
yOffset,
width,
height,
pixelFormat,
PixelDatatype_default.toWebGLConstant(pixelDatatype, context),
arrayBufferView
);
} else {
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, preMultiplyAlpha);
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, flipY);
gl.texSubImage2D(
target,
0,
xOffset,
yOffset,
pixelFormat,
PixelDatatype_default.toWebGLConstant(pixelDatatype, context),
source
);
}
}
gl.bindTexture(target, null);
};
Texture.prototype.copyFromFramebuffer = function(xOffset, yOffset, framebufferXOffset, framebufferYOffset, width, height) {
xOffset = defaultValue_default(xOffset, 0);
yOffset = defaultValue_default(yOffset, 0);
framebufferXOffset = defaultValue_default(framebufferXOffset, 0);
framebufferYOffset = defaultValue_default(framebufferYOffset, 0);
width = defaultValue_default(width, this._width);
height = defaultValue_default(height, this._height);
if (PixelFormat_default.isDepthFormat(this._pixelFormat)) {
throw new DeveloperError_default(
"Cannot call copyFromFramebuffer when the texture pixel format is DEPTH_COMPONENT or DEPTH_STENCIL."
);
}
if (this._pixelDatatype === PixelDatatype_default.FLOAT) {
throw new DeveloperError_default(
"Cannot call copyFromFramebuffer when the texture pixel data type is FLOAT."
);
}
if (this._pixelDatatype === PixelDatatype_default.HALF_FLOAT) {
throw new DeveloperError_default(
"Cannot call copyFromFramebuffer when the texture pixel data type is HALF_FLOAT."
);
}
if (PixelFormat_default.isCompressedFormat(this._pixelFormat)) {
throw new DeveloperError_default(
"Cannot call copyFrom with a compressed texture pixel format."
);
}
Check_default.typeOf.number.greaterThanOrEquals("xOffset", xOffset, 0);
Check_default.typeOf.number.greaterThanOrEquals("yOffset", yOffset, 0);
Check_default.typeOf.number.greaterThanOrEquals(
"framebufferXOffset",
framebufferXOffset,
0
);
Check_default.typeOf.number.greaterThanOrEquals(
"framebufferYOffset",
framebufferYOffset,
0
);
Check_default.typeOf.number.lessThanOrEquals(
"xOffset + width",
xOffset + width,
this._width
);
Check_default.typeOf.number.lessThanOrEquals(
"yOffset + height",
yOffset + height,
this._height
);
const gl = this._context._gl;
const target = this._textureTarget;
gl.activeTexture(gl.TEXTURE0);
gl.bindTexture(target, this._texture);
gl.copyTexSubImage2D(
target,
0,
xOffset,
yOffset,
framebufferXOffset,
framebufferYOffset,
width,
height
);
gl.bindTexture(target, null);
this._initialized = true;
};
Texture.prototype.generateMipmap = function(hint) {
hint = defaultValue_default(hint, MipmapHint_default.DONT_CARE);
if (PixelFormat_default.isDepthFormat(this._pixelFormat)) {
throw new DeveloperError_default(
"Cannot call generateMipmap when the texture pixel format is DEPTH_COMPONENT or DEPTH_STENCIL."
);
}
if (PixelFormat_default.isCompressedFormat(this._pixelFormat)) {
throw new DeveloperError_default(
"Cannot call generateMipmap with a compressed pixel format."
);
}
if (!this._context.webgl2) {
if (this._width > 1 && !Math_default.isPowerOfTwo(this._width)) {
throw new DeveloperError_default(
"width must be a power of two to call generateMipmap() in a WebGL1 context."
);
}
if (this._height > 1 && !Math_default.isPowerOfTwo(this._height)) {
throw new DeveloperError_default(
"height must be a power of two to call generateMipmap() in a WebGL1 context."
);
}
}
if (!MipmapHint_default.validate(hint)) {
throw new DeveloperError_default("hint is invalid.");
}
this._hasMipmap = true;
const gl = this._context._gl;
const target = this._textureTarget;
gl.hint(gl.GENERATE_MIPMAP_HINT, hint);
gl.activeTexture(gl.TEXTURE0);
gl.bindTexture(target, this._texture);
gl.generateMipmap(target);
gl.bindTexture(target, null);
};
Texture.prototype.isDestroyed = function() {
return false;
};
Texture.prototype.destroy = function() {
this._context._gl.deleteTexture(this._texture);
return destroyObject_default(this);
};
var Texture_default = Texture;
// Source/Shaders/Materials/AspectRampMaterial.js
var AspectRampMaterial_default = "uniform sampler2D image;\n\nczm_material czm_getMaterial(czm_materialInput materialInput)\n{\n czm_material material = czm_getDefaultMaterial(materialInput);\n vec4 rampColor = texture2D(image, vec2(materialInput.aspect / (2.0 * czm_pi), 0.5));\n rampColor = czm_gammaCorrect(rampColor);\n material.diffuse = rampColor.rgb;\n material.alpha = rampColor.a;\n return material;\n}\n";
// Source/Shaders/Materials/BumpMapMaterial.js
var BumpMapMaterial_default = "uniform sampler2D image;\nuniform float strength;\nuniform vec2 repeat;\n\nczm_material czm_getMaterial(czm_materialInput materialInput)\n{\n czm_material material = czm_getDefaultMaterial(materialInput);\n\n vec2 st = materialInput.st;\n\n vec2 centerPixel = fract(repeat * st);\n float centerBump = texture2D(image, centerPixel).channel;\n\n float imageWidth = float(imageDimensions.x);\n vec2 rightPixel = fract(repeat * (st + vec2(1.0 / imageWidth, 0.0)));\n float rightBump = texture2D(image, rightPixel).channel;\n\n float imageHeight = float(imageDimensions.y);\n vec2 leftPixel = fract(repeat * (st + vec2(0.0, 1.0 / imageHeight)));\n float topBump = texture2D(image, leftPixel).channel;\n\n vec3 normalTangentSpace = normalize(vec3(centerBump - rightBump, centerBump - topBump, clamp(1.0 - strength, 0.1, 1.0)));\n vec3 normalEC = materialInput.tangentToEyeMatrix * normalTangentSpace;\n\n material.normal = normalEC;\n material.diffuse = vec3(0.01);\n\n return material;\n}\n";
// Source/Shaders/Materials/CheckerboardMaterial.js
var CheckerboardMaterial_default = "uniform vec4 lightColor;\nuniform vec4 darkColor;\nuniform vec2 repeat;\n\nczm_material czm_getMaterial(czm_materialInput materialInput)\n{\n czm_material material = czm_getDefaultMaterial(materialInput);\n\n vec2 st = materialInput.st;\n\n // From Stefan Gustavson's Procedural Textures in GLSL in OpenGL Insights\n float b = mod(floor(repeat.s * st.s) + floor(repeat.t * st.t), 2.0); // 0.0 or 1.0\n\n // Find the distance from the closest separator (region between two colors)\n float scaledWidth = fract(repeat.s * st.s);\n scaledWidth = abs(scaledWidth - floor(scaledWidth + 0.5));\n float scaledHeight = fract(repeat.t * st.t);\n scaledHeight = abs(scaledHeight - floor(scaledHeight + 0.5));\n float value = min(scaledWidth, scaledHeight);\n\n vec4 currentColor = mix(lightColor, darkColor, b);\n vec4 color = czm_antialias(lightColor, darkColor, currentColor, value, 0.03);\n\n color = czm_gammaCorrect(color);\n material.diffuse = color.rgb;\n material.alpha = color.a;\n\n return material;\n}\n";
// Source/Shaders/Materials/DotMaterial.js
var DotMaterial_default = "uniform vec4 lightColor;\nuniform vec4 darkColor;\nuniform vec2 repeat;\n\nczm_material czm_getMaterial(czm_materialInput materialInput)\n{\n czm_material material = czm_getDefaultMaterial(materialInput);\n\n // From Stefan Gustavson's Procedural Textures in GLSL in OpenGL Insights\n float b = smoothstep(0.3, 0.32, length(fract(repeat * materialInput.st) - 0.5)); // 0.0 or 1.0\n\n vec4 color = mix(lightColor, darkColor, b);\n color = czm_gammaCorrect(color);\n material.diffuse = color.rgb;\n material.alpha = color.a;\n\n return material;\n}\n";
// Source/Shaders/Materials/ElevationBandMaterial.js
var ElevationBandMaterial_default = "uniform sampler2D heights;\nuniform sampler2D colors;\n\n// This material expects heights to be sorted from lowest to highest.\n\nfloat getHeight(int idx, float invTexSize)\n{\n vec2 uv = vec2((float(idx) + 0.5) * invTexSize, 0.5);\n#ifdef OES_texture_float\n return texture2D(heights, uv).x;\n#else\n return czm_unpackFloat(texture2D(heights, uv));\n#endif\n}\n\nczm_material czm_getMaterial(czm_materialInput materialInput)\n{\n czm_material material = czm_getDefaultMaterial(materialInput);\n\n float height = materialInput.height;\n float invTexSize = 1.0 / float(heightsDimensions.x);\n\n float minHeight = getHeight(0, invTexSize);\n float maxHeight = getHeight(heightsDimensions.x - 1, invTexSize);\n\n // early-out when outside the height range\n if (height < minHeight || height > maxHeight) {\n material.diffuse = vec3(0.0);\n material.alpha = 0.0;\n return material;\n }\n\n // Binary search to find heights above and below.\n int idxBelow = 0;\n int idxAbove = heightsDimensions.x;\n float heightBelow = minHeight;\n float heightAbove = maxHeight;\n\n // while loop not allowed, so use for loop with max iterations.\n // maxIterations of 16 supports a texture size up to 65536 (2^16).\n const int maxIterations = 16;\n for (int i = 0; i < maxIterations; i++) {\n if (idxBelow >= idxAbove - 1) {\n break;\n }\n\n int idxMid = (idxBelow + idxAbove) / 2;\n float heightTex = getHeight(idxMid, invTexSize);\n\n if (height > heightTex) {\n idxBelow = idxMid;\n heightBelow = heightTex;\n } else {\n idxAbove = idxMid;\n heightAbove = heightTex;\n }\n }\n\n float lerper = heightBelow == heightAbove ? 1.0 : (height - heightBelow) / (heightAbove - heightBelow);\n vec2 colorUv = vec2(invTexSize * (float(idxBelow) + 0.5 + lerper), 0.5);\n vec4 color = texture2D(colors, colorUv);\n\n // undo preumultiplied alpha\n if (color.a > 0.0) \n {\n color.rgb /= color.a;\n }\n \n color.rgb = czm_gammaCorrect(color.rgb);\n\n material.diffuse = color.rgb;\n material.alpha = color.a;\n return material;\n}\n";
// Source/Shaders/Materials/ElevationContourMaterial.js
var ElevationContourMaterial_default = "#ifdef GL_OES_standard_derivatives\n #extension GL_OES_standard_derivatives : enable\n#endif\n\nuniform vec4 color;\nuniform float spacing;\nuniform float width;\n\nczm_material czm_getMaterial(czm_materialInput materialInput)\n{\n czm_material material = czm_getDefaultMaterial(materialInput);\n\n float distanceToContour = mod(materialInput.height, spacing);\n\n#ifdef GL_OES_standard_derivatives\n float dxc = abs(dFdx(materialInput.height));\n float dyc = abs(dFdy(materialInput.height));\n float dF = max(dxc, dyc) * czm_pixelRatio * width;\n float alpha = (distanceToContour < dF) ? 1.0 : 0.0;\n#else\n float alpha = (distanceToContour < (czm_pixelRatio * width)) ? 1.0 : 0.0;\n#endif\n\n vec4 outColor = czm_gammaCorrect(vec4(color.rgb, alpha * color.a));\n material.diffuse = outColor.rgb;\n material.alpha = outColor.a;\n\n return material;\n}\n";
// Source/Shaders/Materials/ElevationRampMaterial.js
var ElevationRampMaterial_default = "uniform sampler2D image;\nuniform float minimumHeight;\nuniform float maximumHeight;\n\nczm_material czm_getMaterial(czm_materialInput materialInput)\n{\n czm_material material = czm_getDefaultMaterial(materialInput);\n float scaledHeight = clamp((materialInput.height - minimumHeight) / (maximumHeight - minimumHeight), 0.0, 1.0);\n vec4 rampColor = texture2D(image, vec2(scaledHeight, 0.5));\n rampColor = czm_gammaCorrect(rampColor);\n material.diffuse = rampColor.rgb;\n material.alpha = rampColor.a;\n return material;\n}\n";
// Source/Shaders/Materials/FadeMaterial.js
var FadeMaterial_default = "uniform vec4 fadeInColor;\nuniform vec4 fadeOutColor;\nuniform float maximumDistance;\nuniform bool repeat;\nuniform vec2 fadeDirection;\nuniform vec2 time;\n\nfloat getTime(float t, float coord)\n{\n float scalar = 1.0 / maximumDistance;\n float q = distance(t, coord) * scalar;\n if (repeat)\n {\n float r = distance(t, coord + 1.0) * scalar;\n float s = distance(t, coord - 1.0) * scalar;\n q = min(min(r, s), q);\n }\n return clamp(q, 0.0, 1.0);\n}\n\nczm_material czm_getMaterial(czm_materialInput materialInput)\n{\n czm_material material = czm_getDefaultMaterial(materialInput);\n\n vec2 st = materialInput.st;\n float s = getTime(time.x, st.s) * fadeDirection.s;\n float t = getTime(time.y, st.t) * fadeDirection.t;\n\n float u = length(vec2(s, t));\n vec4 color = mix(fadeInColor, fadeOutColor, u);\n\n color = czm_gammaCorrect(color);\n material.emission = color.rgb;\n material.alpha = color.a;\n\n return material;\n}\n";
// Source/Shaders/Materials/GridMaterial.js
var GridMaterial_default = '#ifdef GL_OES_standard_derivatives\n #extension GL_OES_standard_derivatives : enable\n#endif\n\nuniform vec4 color;\nuniform float cellAlpha;\nuniform vec2 lineCount;\nuniform vec2 lineThickness;\nuniform vec2 lineOffset;\n\nczm_material czm_getMaterial(czm_materialInput materialInput)\n{\n czm_material material = czm_getDefaultMaterial(materialInput);\n\n vec2 st = materialInput.st;\n\n float scaledWidth = fract(lineCount.s * st.s - lineOffset.s);\n scaledWidth = abs(scaledWidth - floor(scaledWidth + 0.5));\n float scaledHeight = fract(lineCount.t * st.t - lineOffset.t);\n scaledHeight = abs(scaledHeight - floor(scaledHeight + 0.5));\n\n float value;\n#ifdef GL_OES_standard_derivatives\n // Fuzz Factor - Controls blurriness of lines\n const float fuzz = 1.2;\n vec2 thickness = (lineThickness * czm_pixelRatio) - 1.0;\n\n // From "3D Engine Design for Virtual Globes" by Cozzi and Ring, Listing 4.13.\n vec2 dx = abs(dFdx(st));\n vec2 dy = abs(dFdy(st));\n vec2 dF = vec2(max(dx.s, dy.s), max(dx.t, dy.t)) * lineCount;\n value = min(\n smoothstep(dF.s * thickness.s, dF.s * (fuzz + thickness.s), scaledWidth),\n smoothstep(dF.t * thickness.t, dF.t * (fuzz + thickness.t), scaledHeight));\n#else\n // Fuzz Factor - Controls blurriness of lines\n const float fuzz = 0.05;\n\n vec2 range = 0.5 - (lineThickness * 0.05);\n value = min(\n 1.0 - smoothstep(range.s, range.s + fuzz, scaledWidth),\n 1.0 - smoothstep(range.t, range.t + fuzz, scaledHeight));\n#endif\n\n // Edges taken from RimLightingMaterial.glsl\n // See http://www.fundza.com/rman_shaders/surface/fake_rim/fake_rim1.html\n float dRim = 1.0 - abs(dot(materialInput.normalEC, normalize(materialInput.positionToEyeEC)));\n float sRim = smoothstep(0.8, 1.0, dRim);\n value *= (1.0 - sRim);\n\n vec4 halfColor;\n halfColor.rgb = color.rgb * 0.5;\n halfColor.a = color.a * (1.0 - ((1.0 - cellAlpha) * value));\n halfColor = czm_gammaCorrect(halfColor);\n material.diffuse = halfColor.rgb;\n material.emission = halfColor.rgb;\n material.alpha = halfColor.a;\n\n return material;\n}\n';
// Source/Shaders/Materials/NormalMapMaterial.js
var NormalMapMaterial_default = "uniform sampler2D image;\nuniform float strength;\nuniform vec2 repeat;\n\nczm_material czm_getMaterial(czm_materialInput materialInput)\n{\n czm_material material = czm_getDefaultMaterial(materialInput);\n \n vec4 textureValue = texture2D(image, fract(repeat * materialInput.st));\n vec3 normalTangentSpace = textureValue.channels;\n normalTangentSpace.xy = normalTangentSpace.xy * 2.0 - 1.0;\n normalTangentSpace.z = clamp(1.0 - strength, 0.1, 1.0);\n normalTangentSpace = normalize(normalTangentSpace);\n vec3 normalEC = materialInput.tangentToEyeMatrix * normalTangentSpace;\n \n material.normal = normalEC;\n \n return material;\n}\n";
// Source/Shaders/Materials/PolylineArrowMaterial.js
var PolylineArrowMaterial_default = "#ifdef GL_OES_standard_derivatives\n#extension GL_OES_standard_derivatives : enable\n#endif\n\nuniform vec4 color;\n\nfloat getPointOnLine(vec2 p0, vec2 p1, float x)\n{\n float slope = (p0.y - p1.y) / (p0.x - p1.x);\n return slope * (x - p0.x) + p0.y;\n}\n\nczm_material czm_getMaterial(czm_materialInput materialInput)\n{\n czm_material material = czm_getDefaultMaterial(materialInput);\n\n vec2 st = materialInput.st;\n\n#ifdef GL_OES_standard_derivatives\n float base = 1.0 - abs(fwidth(st.s)) * 10.0 * czm_pixelRatio;\n#else\n float base = 0.975; // 2.5% of the line will be the arrow head\n#endif\n\n vec2 center = vec2(1.0, 0.5);\n float ptOnUpperLine = getPointOnLine(vec2(base, 1.0), center, st.s);\n float ptOnLowerLine = getPointOnLine(vec2(base, 0.0), center, st.s);\n\n float halfWidth = 0.15;\n float s = step(0.5 - halfWidth, st.t);\n s *= 1.0 - step(0.5 + halfWidth, st.t);\n s *= 1.0 - step(base, st.s);\n\n float t = step(base, materialInput.st.s);\n t *= 1.0 - step(ptOnUpperLine, st.t);\n t *= step(ptOnLowerLine, st.t);\n\n // Find the distance from the closest separator (region between two colors)\n float dist;\n if (st.s < base)\n {\n float d1 = abs(st.t - (0.5 - halfWidth));\n float d2 = abs(st.t - (0.5 + halfWidth));\n dist = min(d1, d2);\n }\n else\n {\n float d1 = czm_infinity;\n if (st.t < 0.5 - halfWidth && st.t > 0.5 + halfWidth)\n {\n d1 = abs(st.s - base);\n }\n float d2 = abs(st.t - ptOnUpperLine);\n float d3 = abs(st.t - ptOnLowerLine);\n dist = min(min(d1, d2), d3);\n }\n\n vec4 outsideColor = vec4(0.0);\n vec4 currentColor = mix(outsideColor, color, clamp(s + t, 0.0, 1.0));\n vec4 outColor = czm_antialias(outsideColor, color, currentColor, dist);\n\n outColor = czm_gammaCorrect(outColor);\n material.diffuse = outColor.rgb;\n material.alpha = outColor.a;\n return material;\n}\n";
// Source/Shaders/Materials/PolylineDashMaterial.js
var PolylineDashMaterial_default = "uniform vec4 color;\nuniform vec4 gapColor;\nuniform float dashLength;\nuniform float dashPattern;\nvarying float v_polylineAngle;\n\nconst float maskLength = 16.0;\n\nmat2 rotate(float rad) {\n float c = cos(rad);\n float s = sin(rad);\n return mat2(\n c, s,\n -s, c\n );\n}\n\nczm_material czm_getMaterial(czm_materialInput materialInput)\n{\n czm_material material = czm_getDefaultMaterial(materialInput);\n\n vec2 pos = rotate(v_polylineAngle) * gl_FragCoord.xy;\n\n // Get the relative position within the dash from 0 to 1\n float dashPosition = fract(pos.x / (dashLength * czm_pixelRatio));\n // Figure out the mask index.\n float maskIndex = floor(dashPosition * maskLength);\n // Test the bit mask.\n float maskTest = floor(dashPattern / pow(2.0, maskIndex));\n vec4 fragColor = (mod(maskTest, 2.0) < 1.0) ? gapColor : color;\n if (fragColor.a < 0.005) { // matches 0/255 and 1/255\n discard;\n }\n\n fragColor = czm_gammaCorrect(fragColor);\n material.emission = fragColor.rgb;\n material.alpha = fragColor.a;\n return material;\n}\n";
// Source/Shaders/Materials/PolylineGlowMaterial.js
var PolylineGlowMaterial_default = "uniform vec4 color;\nuniform float glowPower;\nuniform float taperPower;\n\nczm_material czm_getMaterial(czm_materialInput materialInput)\n{\n czm_material material = czm_getDefaultMaterial(materialInput);\n\n vec2 st = materialInput.st;\n float glow = glowPower / abs(st.t - 0.5) - (glowPower / 0.5);\n\n if (taperPower <= 0.99999) {\n glow *= min(1.0, taperPower / (0.5 - st.s * 0.5) - (taperPower / 0.5));\n }\n\n vec4 fragColor;\n fragColor.rgb = max(vec3(glow - 1.0 + color.rgb), color.rgb);\n fragColor.a = clamp(0.0, 1.0, glow) * color.a;\n fragColor = czm_gammaCorrect(fragColor);\n\n material.emission = fragColor.rgb;\n material.alpha = fragColor.a;\n\n return material;\n}\n";
// Source/Shaders/Materials/PolylineOutlineMaterial.js
var PolylineOutlineMaterial_default = "uniform vec4 color;\nuniform vec4 outlineColor;\nuniform float outlineWidth;\n\nvarying float v_width;\n\nczm_material czm_getMaterial(czm_materialInput materialInput)\n{\n czm_material material = czm_getDefaultMaterial(materialInput);\n\n vec2 st = materialInput.st;\n float halfInteriorWidth = 0.5 * (v_width - outlineWidth) / v_width;\n float b = step(0.5 - halfInteriorWidth, st.t);\n b *= 1.0 - step(0.5 + halfInteriorWidth, st.t);\n\n // Find the distance from the closest separator (region between two colors)\n float d1 = abs(st.t - (0.5 - halfInteriorWidth));\n float d2 = abs(st.t - (0.5 + halfInteriorWidth));\n float dist = min(d1, d2);\n\n vec4 currentColor = mix(outlineColor, color, b);\n vec4 outColor = czm_antialias(outlineColor, color, currentColor, dist);\n outColor = czm_gammaCorrect(outColor);\n\n material.diffuse = outColor.rgb;\n material.alpha = outColor.a;\n\n return material;\n}\n";
// Source/Shaders/Materials/RimLightingMaterial.js
var RimLightingMaterial_default = "uniform vec4 color;\nuniform vec4 rimColor;\nuniform float width;\n\nczm_material czm_getMaterial(czm_materialInput materialInput)\n{\n czm_material material = czm_getDefaultMaterial(materialInput);\n\n // See http://www.fundza.com/rman_shaders/surface/fake_rim/fake_rim1.html\n float d = 1.0 - dot(materialInput.normalEC, normalize(materialInput.positionToEyeEC));\n float s = smoothstep(1.0 - width, 1.0, d);\n\n vec4 outColor = czm_gammaCorrect(color);\n vec4 outRimColor = czm_gammaCorrect(rimColor);\n\n material.diffuse = outColor.rgb;\n material.emission = outRimColor.rgb * s;\n material.alpha = mix(outColor.a, outRimColor.a, s);\n\n return material;\n}\n";
// Source/Shaders/Materials/SlopeRampMaterial.js
var SlopeRampMaterial_default = "uniform sampler2D image;\n\nczm_material czm_getMaterial(czm_materialInput materialInput)\n{\n czm_material material = czm_getDefaultMaterial(materialInput);\n vec4 rampColor = texture2D(image, vec2(materialInput.slope / (czm_pi / 2.0), 0.5));\n rampColor = czm_gammaCorrect(rampColor);\n material.diffuse = rampColor.rgb;\n material.alpha = rampColor.a;\n return material;\n}\n";
// Source/Shaders/Materials/StripeMaterial.js
var StripeMaterial_default = "uniform vec4 evenColor;\nuniform vec4 oddColor;\nuniform float offset;\nuniform float repeat;\nuniform bool horizontal;\n\nczm_material czm_getMaterial(czm_materialInput materialInput)\n{\n czm_material material = czm_getDefaultMaterial(materialInput);\n\n // Based on the Stripes Fragment Shader in the Orange Book (11.1.2)\n float coord = mix(materialInput.st.s, materialInput.st.t, float(horizontal));\n float value = fract((coord - offset) * (repeat * 0.5));\n float dist = min(value, min(abs(value - 0.5), 1.0 - value));\n\n vec4 currentColor = mix(evenColor, oddColor, step(0.5, value));\n vec4 color = czm_antialias(evenColor, oddColor, currentColor, dist);\n color = czm_gammaCorrect(color);\n\n material.diffuse = color.rgb;\n material.alpha = color.a;\n\n return material;\n}\n";
// Source/Shaders/Materials/Water.js
var Water_default = "// Thanks for the contribution Jonas\n// http://29a.ch/2012/7/19/webgl-terrain-rendering-water-fog\n\nuniform sampler2D specularMap;\nuniform sampler2D normalMap;\nuniform vec4 baseWaterColor;\nuniform vec4 blendColor;\nuniform float frequency;\nuniform float animationSpeed;\nuniform float amplitude;\nuniform float specularIntensity;\nuniform float fadeFactor;\n\nczm_material czm_getMaterial(czm_materialInput materialInput)\n{\n czm_material material = czm_getDefaultMaterial(materialInput);\n\n float time = czm_frameNumber * animationSpeed;\n\n // fade is a function of the distance from the fragment and the frequency of the waves\n float fade = max(1.0, (length(materialInput.positionToEyeEC) / 10000000000.0) * frequency * fadeFactor);\n\n float specularMapValue = texture2D(specularMap, materialInput.st).r;\n\n // note: not using directional motion at this time, just set the angle to 0.0;\n vec4 noise = czm_getWaterNoise(normalMap, materialInput.st * frequency, time, 0.0);\n vec3 normalTangentSpace = noise.xyz * vec3(1.0, 1.0, (1.0 / amplitude));\n\n // fade out the normal perturbation as we move further from the water surface\n normalTangentSpace.xy /= fade;\n\n // attempt to fade out the normal perturbation as we approach non water areas (low specular map value)\n normalTangentSpace = mix(vec3(0.0, 0.0, 50.0), normalTangentSpace, specularMapValue);\n\n normalTangentSpace = normalize(normalTangentSpace);\n\n // get ratios for alignment of the new normal vector with a vector perpendicular to the tangent plane\n float tsPerturbationRatio = clamp(dot(normalTangentSpace, vec3(0.0, 0.0, 1.0)), 0.0, 1.0);\n\n // fade out water effect as specular map value decreases\n material.alpha = mix(blendColor.a, baseWaterColor.a, specularMapValue) * specularMapValue;\n\n // base color is a blend of the water and non-water color based on the value from the specular map\n // may need a uniform blend factor to better control this\n material.diffuse = mix(blendColor.rgb, baseWaterColor.rgb, specularMapValue);\n\n // diffuse highlights are based on how perturbed the normal is\n material.diffuse += (0.1 * tsPerturbationRatio);\n\n material.diffuse = material.diffuse;\n\n material.normal = normalize(materialInput.tangentToEyeMatrix * normalTangentSpace);\n\n material.specular = specularIntensity;\n material.shininess = 10.0;\n\n return material;\n}\n";
// Source/Scene/Material.js
function Material(options) {
this.type = void 0;
this.shaderSource = void 0;
this.materials = void 0;
this.uniforms = void 0;
this._uniforms = void 0;
this.translucent = void 0;
this._minificationFilter = defaultValue_default(
options.minificationFilter,
TextureMinificationFilter_default.LINEAR
);
this._magnificationFilter = defaultValue_default(
options.magnificationFilter,
TextureMagnificationFilter_default.LINEAR
);
this._strict = void 0;
this._template = void 0;
this._count = void 0;
this._texturePaths = {};
this._loadedImages = [];
this._loadedCubeMaps = [];
this._textures = {};
this._updateFunctions = [];
this._defaultTexture = void 0;
initializeMaterial(options, this);
Object.defineProperties(this, {
type: {
value: this.type,
writable: false
}
});
if (!defined_default(Material._uniformList[this.type])) {
Material._uniformList[this.type] = Object.keys(this._uniforms);
}
}
Material._uniformList = {};
Material.fromType = function(type, uniforms) {
if (!defined_default(Material._materialCache.getMaterial(type))) {
throw new DeveloperError_default(`material with type '${type}' does not exist.`);
}
const material = new Material({
fabric: {
type
}
});
if (defined_default(uniforms)) {
for (const name in uniforms) {
if (uniforms.hasOwnProperty(name)) {
material.uniforms[name] = uniforms[name];
}
}
}
return material;
};
Material.prototype.isTranslucent = function() {
if (defined_default(this.translucent)) {
if (typeof this.translucent === "function") {
return this.translucent();
}
return this.translucent;
}
let translucent = true;
const funcs = this._translucentFunctions;
const length3 = funcs.length;
for (let i = 0; i < length3; ++i) {
const func = funcs[i];
if (typeof func === "function") {
translucent = translucent && func();
} else {
translucent = translucent && func;
}
if (!translucent) {
break;
}
}
return translucent;
};
Material.prototype.update = function(context) {
this._defaultTexture = context.defaultTexture;
let i;
let uniformId;
const loadedImages = this._loadedImages;
let length3 = loadedImages.length;
for (i = 0; i < length3; ++i) {
const loadedImage = loadedImages[i];
uniformId = loadedImage.id;
let image = loadedImage.image;
let mipLevels;
if (Array.isArray(image)) {
mipLevels = image.slice(1, image.length).map(function(mipLevel) {
return mipLevel.bufferView;
});
image = image[0];
}
const sampler = new Sampler_default({
minificationFilter: this._minificationFilter,
magnificationFilter: this._magnificationFilter
});
let texture;
if (defined_default(image.internalFormat)) {
texture = new Texture_default({
context,
pixelFormat: image.internalFormat,
width: image.width,
height: image.height,
source: {
arrayBufferView: image.bufferView,
mipLevels
},
sampler
});
} else {
texture = new Texture_default({
context,
source: image,
sampler
});
}
const oldTexture = this._textures[uniformId];
if (defined_default(oldTexture) && oldTexture !== this._defaultTexture) {
oldTexture.destroy();
}
this._textures[uniformId] = texture;
const uniformDimensionsName = `${uniformId}Dimensions`;
if (this.uniforms.hasOwnProperty(uniformDimensionsName)) {
const uniformDimensions = this.uniforms[uniformDimensionsName];
uniformDimensions.x = texture._width;
uniformDimensions.y = texture._height;
}
}
loadedImages.length = 0;
const loadedCubeMaps = this._loadedCubeMaps;
length3 = loadedCubeMaps.length;
for (i = 0; i < length3; ++i) {
const loadedCubeMap = loadedCubeMaps[i];
uniformId = loadedCubeMap.id;
const images = loadedCubeMap.images;
const cubeMap = new CubeMap_default({
context,
source: {
positiveX: images[0],
negativeX: images[1],
positiveY: images[2],
negativeY: images[3],
positiveZ: images[4],
negativeZ: images[5]
},
sampler: new Sampler_default({
minificationFilter: this._minificationFilter,
magnificationFilter: this._magnificationFilter
})
});
this._textures[uniformId] = cubeMap;
}
loadedCubeMaps.length = 0;
const updateFunctions2 = this._updateFunctions;
length3 = updateFunctions2.length;
for (i = 0; i < length3; ++i) {
updateFunctions2[i](this, context);
}
const subMaterials = this.materials;
for (const name in subMaterials) {
if (subMaterials.hasOwnProperty(name)) {
subMaterials[name].update(context);
}
}
};
Material.prototype.isDestroyed = function() {
return false;
};
Material.prototype.destroy = function() {
const textures = this._textures;
for (const texture in textures) {
if (textures.hasOwnProperty(texture)) {
const instance = textures[texture];
if (instance !== this._defaultTexture) {
instance.destroy();
}
}
}
const materials = this.materials;
for (const material in materials) {
if (materials.hasOwnProperty(material)) {
materials[material].destroy();
}
}
return destroyObject_default(this);
};
function initializeMaterial(options, result) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
result._strict = defaultValue_default(options.strict, false);
result._count = defaultValue_default(options.count, 0);
result._template = clone_default(
defaultValue_default(options.fabric, defaultValue_default.EMPTY_OBJECT)
);
result._template.uniforms = clone_default(
defaultValue_default(result._template.uniforms, defaultValue_default.EMPTY_OBJECT)
);
result._template.materials = clone_default(
defaultValue_default(result._template.materials, defaultValue_default.EMPTY_OBJECT)
);
result.type = defined_default(result._template.type) ? result._template.type : createGuid_default();
result.shaderSource = "";
result.materials = {};
result.uniforms = {};
result._uniforms = {};
result._translucentFunctions = [];
let translucent;
const cachedMaterial = Material._materialCache.getMaterial(result.type);
if (defined_default(cachedMaterial)) {
const template = clone_default(cachedMaterial.fabric, true);
result._template = combine_default(result._template, template, true);
translucent = cachedMaterial.translucent;
}
checkForTemplateErrors(result);
if (!defined_default(cachedMaterial)) {
Material._materialCache.addMaterial(result.type, result);
}
createMethodDefinition(result);
createUniforms(result);
createSubMaterials(result);
const defaultTranslucent = result._translucentFunctions.length === 0 ? true : void 0;
translucent = defaultValue_default(translucent, defaultTranslucent);
translucent = defaultValue_default(options.translucent, translucent);
if (defined_default(translucent)) {
if (typeof translucent === "function") {
const wrappedTranslucent = function() {
return translucent(result);
};
result._translucentFunctions.push(wrappedTranslucent);
} else {
result._translucentFunctions.push(translucent);
}
}
}
function checkForValidProperties(object, properties, result, throwNotFound) {
if (defined_default(object)) {
for (const property in object) {
if (object.hasOwnProperty(property)) {
const hasProperty = properties.indexOf(property) !== -1;
if (throwNotFound && !hasProperty || !throwNotFound && hasProperty) {
result(property, properties);
}
}
}
}
}
function invalidNameError(property, properties) {
let errorString = `fabric: property name '${property}' is not valid. It should be `;
for (let i = 0; i < properties.length; i++) {
const propertyName = `'${properties[i]}'`;
errorString += i === properties.length - 1 ? `or ${propertyName}.` : `${propertyName}, `;
}
throw new DeveloperError_default(errorString);
}
function duplicateNameError(property, properties) {
const errorString = `fabric: uniforms and materials cannot share the same property '${property}'`;
throw new DeveloperError_default(errorString);
}
var templateProperties = [
"type",
"materials",
"uniforms",
"components",
"source"
];
var componentProperties = [
"diffuse",
"specular",
"shininess",
"normal",
"emission",
"alpha"
];
function checkForTemplateErrors(material) {
const template = material._template;
const uniforms = template.uniforms;
const materials = template.materials;
const components = template.components;
if (defined_default(components) && defined_default(template.source)) {
throw new DeveloperError_default(
"fabric: cannot have source and components in the same template."
);
}
checkForValidProperties(template, templateProperties, invalidNameError, true);
checkForValidProperties(
components,
componentProperties,
invalidNameError,
true
);
const materialNames = [];
for (const property in materials) {
if (materials.hasOwnProperty(property)) {
materialNames.push(property);
}
}
checkForValidProperties(uniforms, materialNames, duplicateNameError, false);
}
function isMaterialFused(shaderComponent, material) {
const materials = material._template.materials;
for (const subMaterialId in materials) {
if (materials.hasOwnProperty(subMaterialId)) {
if (shaderComponent.indexOf(subMaterialId) > -1) {
return true;
}
}
}
return false;
}
function createMethodDefinition(material) {
const components = material._template.components;
const source = material._template.source;
if (defined_default(source)) {
material.shaderSource += `${source}
`;
} else {
material.shaderSource += "czm_material czm_getMaterial(czm_materialInput materialInput)\n{\n";
material.shaderSource += "czm_material material = czm_getDefaultMaterial(materialInput);\n";
if (defined_default(components)) {
const isMultiMaterial = Object.keys(material._template.materials).length > 0;
for (const component in components) {
if (components.hasOwnProperty(component)) {
if (component === "diffuse" || component === "emission") {
const isFusion = isMultiMaterial && isMaterialFused(components[component], material);
const componentSource = isFusion ? components[component] : `czm_gammaCorrect(${components[component]})`;
material.shaderSource += `material.${component} = ${componentSource};
`;
} else if (component === "alpha") {
material.shaderSource += `material.alpha = ${components.alpha};
`;
} else {
material.shaderSource += `material.${component} = ${components[component]};
`;
}
}
}
}
material.shaderSource += "return material;\n}\n";
}
}
var matrixMap = {
mat2: Matrix2_default,
mat3: Matrix3_default,
mat4: Matrix4_default
};
var ktx2Regex = /\.ktx2$/i;
function createTexture2DUpdateFunction(uniformId) {
let oldUniformValue;
return function(material, context) {
const uniforms = material.uniforms;
const uniformValue = uniforms[uniformId];
const uniformChanged = oldUniformValue !== uniformValue;
const uniformValueIsDefaultImage = !defined_default(uniformValue) || uniformValue === Material.DefaultImageId;
oldUniformValue = uniformValue;
let texture = material._textures[uniformId];
let uniformDimensionsName;
let uniformDimensions;
if (uniformValue instanceof HTMLVideoElement) {
if (uniformValue.readyState >= 2) {
if (uniformChanged && defined_default(texture)) {
if (texture !== context.defaultTexture) {
texture.destroy();
}
texture = void 0;
}
if (!defined_default(texture) || texture === context.defaultTexture) {
const sampler = new Sampler_default({
minificationFilter: material._minificationFilter,
magnificationFilter: material._magnificationFilter
});
texture = new Texture_default({
context,
source: uniformValue,
sampler
});
material._textures[uniformId] = texture;
return;
}
texture.copyFrom({
source: uniformValue
});
} else if (!defined_default(texture)) {
material._textures[uniformId] = context.defaultTexture;
}
return;
}
if (uniformValue instanceof Texture_default && uniformValue !== texture) {
material._texturePaths[uniformId] = void 0;
const tmp2 = material._textures[uniformId];
if (defined_default(tmp2) && tmp2 !== material._defaultTexture) {
tmp2.destroy();
}
material._textures[uniformId] = uniformValue;
uniformDimensionsName = `${uniformId}Dimensions`;
if (uniforms.hasOwnProperty(uniformDimensionsName)) {
uniformDimensions = uniforms[uniformDimensionsName];
uniformDimensions.x = uniformValue._width;
uniformDimensions.y = uniformValue._height;
}
return;
}
if (uniformChanged && defined_default(texture) && uniformValueIsDefaultImage) {
if (texture !== material._defaultTexture) {
texture.destroy();
}
texture = void 0;
}
if (!defined_default(texture)) {
material._texturePaths[uniformId] = void 0;
texture = material._textures[uniformId] = material._defaultTexture;
uniformDimensionsName = `${uniformId}Dimensions`;
if (uniforms.hasOwnProperty(uniformDimensionsName)) {
uniformDimensions = uniforms[uniformDimensionsName];
uniformDimensions.x = texture._width;
uniformDimensions.y = texture._height;
}
}
if (uniformValueIsDefaultImage) {
return;
}
const isResource = uniformValue instanceof Resource_default;
if (!defined_default(material._texturePaths[uniformId]) || isResource && uniformValue.url !== material._texturePaths[uniformId].url || !isResource && uniformValue !== material._texturePaths[uniformId]) {
if (typeof uniformValue === "string" || isResource) {
const resource = isResource ? uniformValue : Resource_default.createIfNeeded(uniformValue);
let promise;
if (ktx2Regex.test(resource.url)) {
promise = loadKTX2_default(resource.url);
} else {
promise = resource.fetchImage();
}
Promise.resolve(promise).then(function(image) {
material._loadedImages.push({
id: uniformId,
image
});
}).catch(function() {
if (defined_default(texture) && texture !== material._defaultTexture) {
texture.destroy();
}
material._textures[uniformId] = material._defaultTexture;
});
} else if (uniformValue instanceof HTMLCanvasElement || uniformValue instanceof HTMLImageElement) {
material._loadedImages.push({
id: uniformId,
image: uniformValue
});
}
material._texturePaths[uniformId] = uniformValue;
}
};
}
function createCubeMapUpdateFunction(uniformId) {
return function(material, context) {
const uniformValue = material.uniforms[uniformId];
if (uniformValue instanceof CubeMap_default) {
const tmp2 = material._textures[uniformId];
if (tmp2 !== material._defaultTexture) {
tmp2.destroy();
}
material._texturePaths[uniformId] = void 0;
material._textures[uniformId] = uniformValue;
return;
}
if (!defined_default(material._textures[uniformId])) {
material._texturePaths[uniformId] = void 0;
material._textures[uniformId] = context.defaultCubeMap;
}
if (uniformValue === Material.DefaultCubeMapId) {
return;
}
const path = uniformValue.positiveX + uniformValue.negativeX + uniformValue.positiveY + uniformValue.negativeY + uniformValue.positiveZ + uniformValue.negativeZ;
if (path !== material._texturePaths[uniformId]) {
const promises = [
Resource_default.createIfNeeded(uniformValue.positiveX).fetchImage(),
Resource_default.createIfNeeded(uniformValue.negativeX).fetchImage(),
Resource_default.createIfNeeded(uniformValue.positiveY).fetchImage(),
Resource_default.createIfNeeded(uniformValue.negativeY).fetchImage(),
Resource_default.createIfNeeded(uniformValue.positiveZ).fetchImage(),
Resource_default.createIfNeeded(uniformValue.negativeZ).fetchImage()
];
Promise.all(promises).then(function(images) {
material._loadedCubeMaps.push({
id: uniformId,
images
});
});
material._texturePaths[uniformId] = path;
}
};
}
function createUniforms(material) {
const uniforms = material._template.uniforms;
for (const uniformId in uniforms) {
if (uniforms.hasOwnProperty(uniformId)) {
createUniform(material, uniformId);
}
}
}
function createUniform(material, uniformId) {
const strict = material._strict;
const materialUniforms = material._template.uniforms;
const uniformValue = materialUniforms[uniformId];
const uniformType = getUniformType(uniformValue);
if (!defined_default(uniformType)) {
throw new DeveloperError_default(
`fabric: uniform '${uniformId}' has invalid type.`
);
}
let replacedTokenCount;
if (uniformType === "channels") {
replacedTokenCount = replaceToken(material, uniformId, uniformValue, false);
if (replacedTokenCount === 0 && strict) {
throw new DeveloperError_default(
`strict: shader source does not use channels '${uniformId}'.`
);
}
} else {
if (uniformType === "sampler2D") {
const imageDimensionsUniformName = `${uniformId}Dimensions`;
if (getNumberOfTokens(material, imageDimensionsUniformName) > 0) {
materialUniforms[imageDimensionsUniformName] = {
type: "ivec3",
x: 1,
y: 1
};
createUniform(material, imageDimensionsUniformName);
}
}
const uniformDeclarationRegex = new RegExp(
`uniform\\s+${uniformType}\\s+${uniformId}\\s*;`
);
if (!uniformDeclarationRegex.test(material.shaderSource)) {
const uniformDeclaration = `uniform ${uniformType} ${uniformId};`;
material.shaderSource = uniformDeclaration + material.shaderSource;
}
const newUniformId = `${uniformId}_${material._count++}`;
replacedTokenCount = replaceToken(material, uniformId, newUniformId);
if (replacedTokenCount === 1 && strict) {
throw new DeveloperError_default(
`strict: shader source does not use uniform '${uniformId}'.`
);
}
material.uniforms[uniformId] = uniformValue;
if (uniformType === "sampler2D") {
material._uniforms[newUniformId] = function() {
return material._textures[uniformId];
};
material._updateFunctions.push(createTexture2DUpdateFunction(uniformId));
} else if (uniformType === "samplerCube") {
material._uniforms[newUniformId] = function() {
return material._textures[uniformId];
};
material._updateFunctions.push(createCubeMapUpdateFunction(uniformId));
} else if (uniformType.indexOf("mat") !== -1) {
const scratchMatrix7 = new matrixMap[uniformType]();
material._uniforms[newUniformId] = function() {
return matrixMap[uniformType].fromColumnMajorArray(
material.uniforms[uniformId],
scratchMatrix7
);
};
} else {
material._uniforms[newUniformId] = function() {
return material.uniforms[uniformId];
};
}
}
}
function getUniformType(uniformValue) {
let uniformType = uniformValue.type;
if (!defined_default(uniformType)) {
const type = typeof uniformValue;
if (type === "number") {
uniformType = "float";
} else if (type === "boolean") {
uniformType = "bool";
} else if (type === "string" || uniformValue instanceof Resource_default || uniformValue instanceof HTMLCanvasElement || uniformValue instanceof HTMLImageElement) {
if (/^([rgba]){1,4}$/i.test(uniformValue)) {
uniformType = "channels";
} else if (uniformValue === Material.DefaultCubeMapId) {
uniformType = "samplerCube";
} else {
uniformType = "sampler2D";
}
} else if (type === "object") {
if (Array.isArray(uniformValue)) {
if (uniformValue.length === 4 || uniformValue.length === 9 || uniformValue.length === 16) {
uniformType = `mat${Math.sqrt(uniformValue.length)}`;
}
} else {
let numAttributes = 0;
for (const attribute in uniformValue) {
if (uniformValue.hasOwnProperty(attribute)) {
numAttributes += 1;
}
}
if (numAttributes >= 2 && numAttributes <= 4) {
uniformType = `vec${numAttributes}`;
} else if (numAttributes === 6) {
uniformType = "samplerCube";
}
}
}
}
return uniformType;
}
function createSubMaterials(material) {
const strict = material._strict;
const subMaterialTemplates = material._template.materials;
for (const subMaterialId in subMaterialTemplates) {
if (subMaterialTemplates.hasOwnProperty(subMaterialId)) {
const subMaterial = new Material({
strict,
fabric: subMaterialTemplates[subMaterialId],
count: material._count
});
material._count = subMaterial._count;
material._uniforms = combine_default(
material._uniforms,
subMaterial._uniforms,
true
);
material.materials[subMaterialId] = subMaterial;
material._translucentFunctions = material._translucentFunctions.concat(
subMaterial._translucentFunctions
);
const originalMethodName = "czm_getMaterial";
const newMethodName = `${originalMethodName}_${material._count++}`;
replaceToken(subMaterial, originalMethodName, newMethodName);
material.shaderSource = subMaterial.shaderSource + material.shaderSource;
const materialMethodCall = `${newMethodName}(materialInput)`;
const tokensReplacedCount = replaceToken(
material,
subMaterialId,
materialMethodCall
);
if (tokensReplacedCount === 0 && strict) {
throw new DeveloperError_default(
`strict: shader source does not use material '${subMaterialId}'.`
);
}
}
}
}
function replaceToken(material, token, newToken, excludePeriod) {
excludePeriod = defaultValue_default(excludePeriod, true);
let count = 0;
const suffixChars = "([\\w])?";
const prefixChars = `([\\w${excludePeriod ? "." : ""}])?`;
const regExp = new RegExp(prefixChars + token + suffixChars, "g");
material.shaderSource = material.shaderSource.replace(regExp, function($0, $1, $2) {
if ($1 || $2) {
return $0;
}
count += 1;
return newToken;
});
return count;
}
function getNumberOfTokens(material, token, excludePeriod) {
return replaceToken(material, token, token, excludePeriod);
}
Material._materialCache = {
_materials: {},
addMaterial: function(type, materialTemplate) {
this._materials[type] = materialTemplate;
},
getMaterial: function(type) {
return this._materials[type];
}
};
Material.DefaultImageId = "czm_defaultImage";
Material.DefaultCubeMapId = "czm_defaultCubeMap";
Material.ColorType = "Color";
Material._materialCache.addMaterial(Material.ColorType, {
fabric: {
type: Material.ColorType,
uniforms: {
color: new Color_default(1, 0, 0, 0.5)
},
components: {
diffuse: "color.rgb",
alpha: "color.a"
}
},
translucent: function(material) {
return material.uniforms.color.alpha < 1;
}
});
Material.ImageType = "Image";
Material._materialCache.addMaterial(Material.ImageType, {
fabric: {
type: Material.ImageType,
uniforms: {
image: Material.DefaultImageId,
repeat: new Cartesian2_default(1, 1),
color: new Color_default(1, 1, 1, 1)
},
components: {
diffuse: "texture2D(image, fract(repeat * materialInput.st)).rgb * color.rgb",
alpha: "texture2D(image, fract(repeat * materialInput.st)).a * color.a"
}
},
translucent: function(material) {
return material.uniforms.color.alpha < 1;
}
});
Material.DiffuseMapType = "DiffuseMap";
Material._materialCache.addMaterial(Material.DiffuseMapType, {
fabric: {
type: Material.DiffuseMapType,
uniforms: {
image: Material.DefaultImageId,
channels: "rgb",
repeat: new Cartesian2_default(1, 1)
},
components: {
diffuse: "texture2D(image, fract(repeat * materialInput.st)).channels"
}
},
translucent: false
});
Material.AlphaMapType = "AlphaMap";
Material._materialCache.addMaterial(Material.AlphaMapType, {
fabric: {
type: Material.AlphaMapType,
uniforms: {
image: Material.DefaultImageId,
channel: "a",
repeat: new Cartesian2_default(1, 1)
},
components: {
alpha: "texture2D(image, fract(repeat * materialInput.st)).channel"
}
},
translucent: true
});
Material.SpecularMapType = "SpecularMap";
Material._materialCache.addMaterial(Material.SpecularMapType, {
fabric: {
type: Material.SpecularMapType,
uniforms: {
image: Material.DefaultImageId,
channel: "r",
repeat: new Cartesian2_default(1, 1)
},
components: {
specular: "texture2D(image, fract(repeat * materialInput.st)).channel"
}
},
translucent: false
});
Material.EmissionMapType = "EmissionMap";
Material._materialCache.addMaterial(Material.EmissionMapType, {
fabric: {
type: Material.EmissionMapType,
uniforms: {
image: Material.DefaultImageId,
channels: "rgb",
repeat: new Cartesian2_default(1, 1)
},
components: {
emission: "texture2D(image, fract(repeat * materialInput.st)).channels"
}
},
translucent: false
});
Material.BumpMapType = "BumpMap";
Material._materialCache.addMaterial(Material.BumpMapType, {
fabric: {
type: Material.BumpMapType,
uniforms: {
image: Material.DefaultImageId,
channel: "r",
strength: 0.8,
repeat: new Cartesian2_default(1, 1)
},
source: BumpMapMaterial_default
},
translucent: false
});
Material.NormalMapType = "NormalMap";
Material._materialCache.addMaterial(Material.NormalMapType, {
fabric: {
type: Material.NormalMapType,
uniforms: {
image: Material.DefaultImageId,
channels: "rgb",
strength: 0.8,
repeat: new Cartesian2_default(1, 1)
},
source: NormalMapMaterial_default
},
translucent: false
});
Material.GridType = "Grid";
Material._materialCache.addMaterial(Material.GridType, {
fabric: {
type: Material.GridType,
uniforms: {
color: new Color_default(0, 1, 0, 1),
cellAlpha: 0.1,
lineCount: new Cartesian2_default(8, 8),
lineThickness: new Cartesian2_default(1, 1),
lineOffset: new Cartesian2_default(0, 0)
},
source: GridMaterial_default
},
translucent: function(material) {
const uniforms = material.uniforms;
return uniforms.color.alpha < 1 || uniforms.cellAlpha < 1;
}
});
Material.StripeType = "Stripe";
Material._materialCache.addMaterial(Material.StripeType, {
fabric: {
type: Material.StripeType,
uniforms: {
horizontal: true,
evenColor: new Color_default(1, 1, 1, 0.5),
oddColor: new Color_default(0, 0, 1, 0.5),
offset: 0,
repeat: 5
},
source: StripeMaterial_default
},
translucent: function(material) {
const uniforms = material.uniforms;
return uniforms.evenColor.alpha < 1 || uniforms.oddColor.alpha < 1;
}
});
Material.CheckerboardType = "Checkerboard";
Material._materialCache.addMaterial(Material.CheckerboardType, {
fabric: {
type: Material.CheckerboardType,
uniforms: {
lightColor: new Color_default(1, 1, 1, 0.5),
darkColor: new Color_default(0, 0, 0, 0.5),
repeat: new Cartesian2_default(5, 5)
},
source: CheckerboardMaterial_default
},
translucent: function(material) {
const uniforms = material.uniforms;
return uniforms.lightColor.alpha < 1 || uniforms.darkColor.alpha < 1;
}
});
Material.DotType = "Dot";
Material._materialCache.addMaterial(Material.DotType, {
fabric: {
type: Material.DotType,
uniforms: {
lightColor: new Color_default(1, 1, 0, 0.75),
darkColor: new Color_default(0, 1, 1, 0.75),
repeat: new Cartesian2_default(5, 5)
},
source: DotMaterial_default
},
translucent: function(material) {
const uniforms = material.uniforms;
return uniforms.lightColor.alpha < 1 || uniforms.darkColor.alpha < 1;
}
});
Material.WaterType = "Water";
Material._materialCache.addMaterial(Material.WaterType, {
fabric: {
type: Material.WaterType,
uniforms: {
baseWaterColor: new Color_default(0.2, 0.3, 0.6, 1),
blendColor: new Color_default(0, 1, 0.699, 1),
specularMap: Material.DefaultImageId,
normalMap: Material.DefaultImageId,
frequency: 10,
animationSpeed: 0.01,
amplitude: 1,
specularIntensity: 0.5,
fadeFactor: 1
},
source: Water_default
},
translucent: function(material) {
const uniforms = material.uniforms;
return uniforms.baseWaterColor.alpha < 1 || uniforms.blendColor.alpha < 1;
}
});
Material.RimLightingType = "RimLighting";
Material._materialCache.addMaterial(Material.RimLightingType, {
fabric: {
type: Material.RimLightingType,
uniforms: {
color: new Color_default(1, 0, 0, 0.7),
rimColor: new Color_default(1, 1, 1, 0.4),
width: 0.3
},
source: RimLightingMaterial_default
},
translucent: function(material) {
const uniforms = material.uniforms;
return uniforms.color.alpha < 1 || uniforms.rimColor.alpha < 1;
}
});
Material.FadeType = "Fade";
Material._materialCache.addMaterial(Material.FadeType, {
fabric: {
type: Material.FadeType,
uniforms: {
fadeInColor: new Color_default(1, 0, 0, 1),
fadeOutColor: new Color_default(0, 0, 0, 0),
maximumDistance: 0.5,
repeat: true,
fadeDirection: {
x: true,
y: true
},
time: new Cartesian2_default(0.5, 0.5)
},
source: FadeMaterial_default
},
translucent: function(material) {
const uniforms = material.uniforms;
return uniforms.fadeInColor.alpha < 1 || uniforms.fadeOutColor.alpha < 1;
}
});
Material.PolylineArrowType = "PolylineArrow";
Material._materialCache.addMaterial(Material.PolylineArrowType, {
fabric: {
type: Material.PolylineArrowType,
uniforms: {
color: new Color_default(1, 1, 1, 1)
},
source: PolylineArrowMaterial_default
},
translucent: true
});
Material.PolylineDashType = "PolylineDash";
Material._materialCache.addMaterial(Material.PolylineDashType, {
fabric: {
type: Material.PolylineDashType,
uniforms: {
color: new Color_default(1, 0, 1, 1),
gapColor: new Color_default(0, 0, 0, 0),
dashLength: 16,
dashPattern: 255
},
source: PolylineDashMaterial_default
},
translucent: true
});
Material.PolylineGlowType = "PolylineGlow";
Material._materialCache.addMaterial(Material.PolylineGlowType, {
fabric: {
type: Material.PolylineGlowType,
uniforms: {
color: new Color_default(0, 0.5, 1, 1),
glowPower: 0.25,
taperPower: 1
},
source: PolylineGlowMaterial_default
},
translucent: true
});
Material.PolylineOutlineType = "PolylineOutline";
Material._materialCache.addMaterial(Material.PolylineOutlineType, {
fabric: {
type: Material.PolylineOutlineType,
uniforms: {
color: new Color_default(1, 1, 1, 1),
outlineColor: new Color_default(1, 0, 0, 1),
outlineWidth: 1
},
source: PolylineOutlineMaterial_default
},
translucent: function(material) {
const uniforms = material.uniforms;
return uniforms.color.alpha < 1 || uniforms.outlineColor.alpha < 1;
}
});
Material.ElevationContourType = "ElevationContour";
Material._materialCache.addMaterial(Material.ElevationContourType, {
fabric: {
type: Material.ElevationContourType,
uniforms: {
spacing: 100,
color: new Color_default(1, 0, 0, 1),
width: 1
},
source: ElevationContourMaterial_default
},
translucent: false
});
Material.ElevationRampType = "ElevationRamp";
Material._materialCache.addMaterial(Material.ElevationRampType, {
fabric: {
type: Material.ElevationRampType,
uniforms: {
image: Material.DefaultImageId,
minimumHeight: 0,
maximumHeight: 1e4
},
source: ElevationRampMaterial_default
},
translucent: false
});
Material.SlopeRampMaterialType = "SlopeRamp";
Material._materialCache.addMaterial(Material.SlopeRampMaterialType, {
fabric: {
type: Material.SlopeRampMaterialType,
uniforms: {
image: Material.DefaultImageId
},
source: SlopeRampMaterial_default
},
translucent: false
});
Material.AspectRampMaterialType = "AspectRamp";
Material._materialCache.addMaterial(Material.AspectRampMaterialType, {
fabric: {
type: Material.AspectRampMaterialType,
uniforms: {
image: Material.DefaultImageId
},
source: AspectRampMaterial_default
},
translucent: false
});
Material.ElevationBandType = "ElevationBand";
Material._materialCache.addMaterial(Material.ElevationBandType, {
fabric: {
type: Material.ElevationBandType,
uniforms: {
heights: Material.DefaultImageId,
colors: Material.DefaultImageId
},
source: ElevationBandMaterial_default
},
translucent: true
});
var Material_default = Material;
// Source/Scene/MaterialAppearance.js
function MaterialAppearance(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
const translucent = defaultValue_default(options.translucent, true);
const closed = defaultValue_default(options.closed, false);
const materialSupport = defaultValue_default(
options.materialSupport,
MaterialAppearance.MaterialSupport.TEXTURED
);
this.material = defined_default(options.material) ? options.material : Material_default.fromType(Material_default.ColorType);
this.translucent = translucent;
this._vertexShaderSource = defaultValue_default(
options.vertexShaderSource,
materialSupport.vertexShaderSource
);
this._fragmentShaderSource = defaultValue_default(
options.fragmentShaderSource,
materialSupport.fragmentShaderSource
);
this._renderState = Appearance_default.getDefaultRenderState(
translucent,
closed,
options.renderState
);
this._closed = closed;
this._materialSupport = materialSupport;
this._vertexFormat = materialSupport.vertexFormat;
this._flat = defaultValue_default(options.flat, false);
this._faceForward = defaultValue_default(options.faceForward, !closed);
}
Object.defineProperties(MaterialAppearance.prototype, {
vertexShaderSource: {
get: function() {
return this._vertexShaderSource;
}
},
fragmentShaderSource: {
get: function() {
return this._fragmentShaderSource;
}
},
renderState: {
get: function() {
return this._renderState;
}
},
closed: {
get: function() {
return this._closed;
}
},
materialSupport: {
get: function() {
return this._materialSupport;
}
},
vertexFormat: {
get: function() {
return this._vertexFormat;
}
},
flat: {
get: function() {
return this._flat;
}
},
faceForward: {
get: function() {
return this._faceForward;
}
}
});
MaterialAppearance.prototype.getFragmentShaderSource = Appearance_default.prototype.getFragmentShaderSource;
MaterialAppearance.prototype.isTranslucent = Appearance_default.prototype.isTranslucent;
MaterialAppearance.prototype.getRenderState = Appearance_default.prototype.getRenderState;
MaterialAppearance.MaterialSupport = {
BASIC: Object.freeze({
vertexFormat: VertexFormat_default.POSITION_AND_NORMAL,
vertexShaderSource: BasicMaterialAppearanceVS_default,
fragmentShaderSource: BasicMaterialAppearanceFS_default
}),
TEXTURED: Object.freeze({
vertexFormat: VertexFormat_default.POSITION_NORMAL_AND_ST,
vertexShaderSource: TexturedMaterialAppearanceVS_default,
fragmentShaderSource: TexturedMaterialAppearanceFS_default
}),
ALL: Object.freeze({
vertexFormat: VertexFormat_default.ALL,
vertexShaderSource: AllMaterialAppearanceVS_default,
fragmentShaderSource: AllMaterialAppearanceFS_default
})
};
var MaterialAppearance_default = MaterialAppearance;
// Source/Shaders/Appearances/PerInstanceColorAppearanceFS.js
var PerInstanceColorAppearanceFS_default = "varying vec3 v_positionEC;\nvarying vec3 v_normalEC;\nvarying vec4 v_color;\n\nvoid main()\n{\n vec3 positionToEyeEC = -v_positionEC;\n\n vec3 normalEC = normalize(v_normalEC);\n#ifdef FACE_FORWARD\n normalEC = faceforward(normalEC, vec3(0.0, 0.0, 1.0), -normalEC);\n#endif\n\n vec4 color = czm_gammaCorrect(v_color);\n\n czm_materialInput materialInput;\n materialInput.normalEC = normalEC;\n materialInput.positionToEyeEC = positionToEyeEC;\n czm_material material = czm_getDefaultMaterial(materialInput);\n material.diffuse = color.rgb;\n material.alpha = color.a;\n\n gl_FragColor = czm_phong(normalize(positionToEyeEC), material, czm_lightDirectionEC);\n}\n";
// Source/Shaders/Appearances/PerInstanceColorAppearanceVS.js
var PerInstanceColorAppearanceVS_default = "attribute vec3 position3DHigh;\nattribute vec3 position3DLow;\nattribute vec3 normal;\nattribute vec4 color;\nattribute float batchId;\n\nvarying vec3 v_positionEC;\nvarying vec3 v_normalEC;\nvarying vec4 v_color;\n\nvoid main()\n{\n vec4 p = czm_computePosition();\n\n v_positionEC = (czm_modelViewRelativeToEye * p).xyz; // position in eye coordinates\n v_normalEC = czm_normal * normal; // normal in eye coordinates\n v_color = color;\n\n gl_Position = czm_modelViewProjectionRelativeToEye * p;\n}\n";
// Source/Shaders/Appearances/PerInstanceFlatColorAppearanceFS.js
var PerInstanceFlatColorAppearanceFS_default = "varying vec4 v_color;\n\nvoid main()\n{\n gl_FragColor = czm_gammaCorrect(v_color);\n}\n";
// Source/Shaders/Appearances/PerInstanceFlatColorAppearanceVS.js
var PerInstanceFlatColorAppearanceVS_default = "attribute vec3 position3DHigh;\nattribute vec3 position3DLow;\nattribute vec4 color;\nattribute float batchId;\n\nvarying vec4 v_color;\n\nvoid main()\n{\n vec4 p = czm_computePosition();\n\n v_color = color;\n\n gl_Position = czm_modelViewProjectionRelativeToEye * p;\n}\n";
// Source/Scene/PerInstanceColorAppearance.js
function PerInstanceColorAppearance(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
const translucent = defaultValue_default(options.translucent, true);
const closed = defaultValue_default(options.closed, false);
const flat = defaultValue_default(options.flat, false);
const vs = flat ? PerInstanceFlatColorAppearanceVS_default : PerInstanceColorAppearanceVS_default;
const fs = flat ? PerInstanceFlatColorAppearanceFS_default : PerInstanceColorAppearanceFS_default;
const vertexFormat = flat ? PerInstanceColorAppearance.FLAT_VERTEX_FORMAT : PerInstanceColorAppearance.VERTEX_FORMAT;
this.material = void 0;
this.translucent = translucent;
this._vertexShaderSource = defaultValue_default(options.vertexShaderSource, vs);
this._fragmentShaderSource = defaultValue_default(options.fragmentShaderSource, fs);
this._renderState = Appearance_default.getDefaultRenderState(
translucent,
closed,
options.renderState
);
this._closed = closed;
this._vertexFormat = vertexFormat;
this._flat = flat;
this._faceForward = defaultValue_default(options.faceForward, !closed);
}
Object.defineProperties(PerInstanceColorAppearance.prototype, {
vertexShaderSource: {
get: function() {
return this._vertexShaderSource;
}
},
fragmentShaderSource: {
get: function() {
return this._fragmentShaderSource;
}
},
renderState: {
get: function() {
return this._renderState;
}
},
closed: {
get: function() {
return this._closed;
}
},
vertexFormat: {
get: function() {
return this._vertexFormat;
}
},
flat: {
get: function() {
return this._flat;
}
},
faceForward: {
get: function() {
return this._faceForward;
}
}
});
PerInstanceColorAppearance.VERTEX_FORMAT = VertexFormat_default.POSITION_AND_NORMAL;
PerInstanceColorAppearance.FLAT_VERTEX_FORMAT = VertexFormat_default.POSITION_ONLY;
PerInstanceColorAppearance.prototype.getFragmentShaderSource = Appearance_default.prototype.getFragmentShaderSource;
PerInstanceColorAppearance.prototype.isTranslucent = Appearance_default.prototype.isTranslucent;
PerInstanceColorAppearance.prototype.getRenderState = Appearance_default.prototype.getRenderState;
var PerInstanceColorAppearance_default = PerInstanceColorAppearance;
// Source/DataSources/ColorMaterialProperty.js
function ColorMaterialProperty(color) {
this._definitionChanged = new Event_default();
this._color = void 0;
this._colorSubscription = void 0;
this.color = color;
}
Object.defineProperties(ColorMaterialProperty.prototype, {
isConstant: {
get: function() {
return Property_default.isConstant(this._color);
}
},
definitionChanged: {
get: function() {
return this._definitionChanged;
}
},
color: createPropertyDescriptor_default("color")
});
ColorMaterialProperty.prototype.getType = function(time) {
return "Color";
};
ColorMaterialProperty.prototype.getValue = function(time, result) {
if (!defined_default(result)) {
result = {};
}
result.color = Property_default.getValueOrClonedDefault(
this._color,
time,
Color_default.WHITE,
result.color
);
return result;
};
ColorMaterialProperty.prototype.equals = function(other) {
return this === other || other instanceof ColorMaterialProperty && Property_default.equals(this._color, other._color);
};
var ColorMaterialProperty_default = ColorMaterialProperty;
// Source/Renderer/DrawCommand.js
var Flags = {
CULL: 1,
OCCLUDE: 2,
EXECUTE_IN_CLOSEST_FRUSTUM: 4,
DEBUG_SHOW_BOUNDING_VOLUME: 8,
CAST_SHADOWS: 16,
RECEIVE_SHADOWS: 32,
PICK_ONLY: 64,
DEPTH_FOR_TRANSLUCENT_CLASSIFICATION: 128
};
function DrawCommand(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
this._boundingVolume = options.boundingVolume;
this._orientedBoundingBox = options.orientedBoundingBox;
this._modelMatrix = options.modelMatrix;
this._primitiveType = defaultValue_default(
options.primitiveType,
PrimitiveType_default.TRIANGLES
);
this._vertexArray = options.vertexArray;
this._count = options.count;
this._offset = defaultValue_default(options.offset, 0);
this._instanceCount = defaultValue_default(options.instanceCount, 0);
this._shaderProgram = options.shaderProgram;
this._uniformMap = options.uniformMap;
this._renderState = options.renderState;
this._framebuffer = options.framebuffer;
this._pass = options.pass;
this._owner = options.owner;
this._debugOverlappingFrustums = 0;
this._pickId = options.pickId;
this._flags = 0;
this.cull = defaultValue_default(options.cull, true);
this.occlude = defaultValue_default(options.occlude, true);
this.executeInClosestFrustum = defaultValue_default(
options.executeInClosestFrustum,
false
);
this.debugShowBoundingVolume = defaultValue_default(
options.debugShowBoundingVolume,
false
);
this.castShadows = defaultValue_default(options.castShadows, false);
this.receiveShadows = defaultValue_default(options.receiveShadows, false);
this.pickOnly = defaultValue_default(options.pickOnly, false);
this.depthForTranslucentClassification = defaultValue_default(
options.depthForTranslucentClassification,
false
);
this.dirty = true;
this.lastDirtyTime = 0;
this.derivedCommands = {};
}
function hasFlag(command, flag) {
return (command._flags & flag) === flag;
}
function setFlag(command, flag, value) {
if (value) {
command._flags |= flag;
} else {
command._flags &= ~flag;
}
}
Object.defineProperties(DrawCommand.prototype, {
boundingVolume: {
get: function() {
return this._boundingVolume;
},
set: function(value) {
if (this._boundingVolume !== value) {
this._boundingVolume = value;
this.dirty = true;
}
}
},
orientedBoundingBox: {
get: function() {
return this._orientedBoundingBox;
},
set: function(value) {
if (this._orientedBoundingBox !== value) {
this._orientedBoundingBox = value;
this.dirty = true;
}
}
},
cull: {
get: function() {
return hasFlag(this, Flags.CULL);
},
set: function(value) {
if (hasFlag(this, Flags.CULL) !== value) {
setFlag(this, Flags.CULL, value);
this.dirty = true;
}
}
},
occlude: {
get: function() {
return hasFlag(this, Flags.OCCLUDE);
},
set: function(value) {
if (hasFlag(this, Flags.OCCLUDE) !== value) {
setFlag(this, Flags.OCCLUDE, value);
this.dirty = true;
}
}
},
modelMatrix: {
get: function() {
return this._modelMatrix;
},
set: function(value) {
if (this._modelMatrix !== value) {
this._modelMatrix = value;
this.dirty = true;
}
}
},
primitiveType: {
get: function() {
return this._primitiveType;
},
set: function(value) {
if (this._primitiveType !== value) {
this._primitiveType = value;
this.dirty = true;
}
}
},
vertexArray: {
get: function() {
return this._vertexArray;
},
set: function(value) {
if (this._vertexArray !== value) {
this._vertexArray = value;
this.dirty = true;
}
}
},
count: {
get: function() {
return this._count;
},
set: function(value) {
if (this._count !== value) {
this._count = value;
this.dirty = true;
}
}
},
offset: {
get: function() {
return this._offset;
},
set: function(value) {
if (this._offset !== value) {
this._offset = value;
this.dirty = true;
}
}
},
instanceCount: {
get: function() {
return this._instanceCount;
},
set: function(value) {
if (this._instanceCount !== value) {
this._instanceCount = value;
this.dirty = true;
}
}
},
shaderProgram: {
get: function() {
return this._shaderProgram;
},
set: function(value) {
if (this._shaderProgram !== value) {
this._shaderProgram = value;
this.dirty = true;
}
}
},
castShadows: {
get: function() {
return hasFlag(this, Flags.CAST_SHADOWS);
},
set: function(value) {
if (hasFlag(this, Flags.CAST_SHADOWS) !== value) {
setFlag(this, Flags.CAST_SHADOWS, value);
this.dirty = true;
}
}
},
receiveShadows: {
get: function() {
return hasFlag(this, Flags.RECEIVE_SHADOWS);
},
set: function(value) {
if (hasFlag(this, Flags.RECEIVE_SHADOWS) !== value) {
setFlag(this, Flags.RECEIVE_SHADOWS, value);
this.dirty = true;
}
}
},
uniformMap: {
get: function() {
return this._uniformMap;
},
set: function(value) {
if (this._uniformMap !== value) {
this._uniformMap = value;
this.dirty = true;
}
}
},
renderState: {
get: function() {
return this._renderState;
},
set: function(value) {
if (this._renderState !== value) {
this._renderState = value;
this.dirty = true;
}
}
},
framebuffer: {
get: function() {
return this._framebuffer;
},
set: function(value) {
if (this._framebuffer !== value) {
this._framebuffer = value;
this.dirty = true;
}
}
},
pass: {
get: function() {
return this._pass;
},
set: function(value) {
if (this._pass !== value) {
this._pass = value;
this.dirty = true;
}
}
},
executeInClosestFrustum: {
get: function() {
return hasFlag(this, Flags.EXECUTE_IN_CLOSEST_FRUSTUM);
},
set: function(value) {
if (hasFlag(this, Flags.EXECUTE_IN_CLOSEST_FRUSTUM) !== value) {
setFlag(this, Flags.EXECUTE_IN_CLOSEST_FRUSTUM, value);
this.dirty = true;
}
}
},
owner: {
get: function() {
return this._owner;
},
set: function(value) {
if (this._owner !== value) {
this._owner = value;
this.dirty = true;
}
}
},
debugShowBoundingVolume: {
get: function() {
return hasFlag(this, Flags.DEBUG_SHOW_BOUNDING_VOLUME);
},
set: function(value) {
if (hasFlag(this, Flags.DEBUG_SHOW_BOUNDING_VOLUME) !== value) {
setFlag(this, Flags.DEBUG_SHOW_BOUNDING_VOLUME, value);
this.dirty = true;
}
}
},
debugOverlappingFrustums: {
get: function() {
return this._debugOverlappingFrustums;
},
set: function(value) {
if (this._debugOverlappingFrustums !== value) {
this._debugOverlappingFrustums = value;
this.dirty = true;
}
}
},
pickId: {
get: function() {
return this._pickId;
},
set: function(value) {
if (this._pickId !== value) {
this._pickId = value;
this.dirty = true;
}
}
},
pickOnly: {
get: function() {
return hasFlag(this, Flags.PICK_ONLY);
},
set: function(value) {
if (hasFlag(this, Flags.PICK_ONLY) !== value) {
setFlag(this, Flags.PICK_ONLY, value);
this.dirty = true;
}
}
},
depthForTranslucentClassification: {
get: function() {
return hasFlag(this, Flags.DEPTH_FOR_TRANSLUCENT_CLASSIFICATION);
},
set: function(value) {
if (hasFlag(this, Flags.DEPTH_FOR_TRANSLUCENT_CLASSIFICATION) !== value) {
setFlag(this, Flags.DEPTH_FOR_TRANSLUCENT_CLASSIFICATION, value);
this.dirty = true;
}
}
}
});
DrawCommand.shallowClone = function(command, result) {
if (!defined_default(command)) {
return void 0;
}
if (!defined_default(result)) {
result = new DrawCommand();
}
result._boundingVolume = command._boundingVolume;
result._orientedBoundingBox = command._orientedBoundingBox;
result._modelMatrix = command._modelMatrix;
result._primitiveType = command._primitiveType;
result._vertexArray = command._vertexArray;
result._count = command._count;
result._offset = command._offset;
result._instanceCount = command._instanceCount;
result._shaderProgram = command._shaderProgram;
result._uniformMap = command._uniformMap;
result._renderState = command._renderState;
result._framebuffer = command._framebuffer;
result._pass = command._pass;
result._owner = command._owner;
result._debugOverlappingFrustums = command._debugOverlappingFrustums;
result._pickId = command._pickId;
result._flags = command._flags;
result.dirty = true;
result.lastDirtyTime = 0;
return result;
};
DrawCommand.prototype.execute = function(context, passState) {
context.draw(this, passState);
};
var DrawCommand_default = DrawCommand;
// Source/Renderer/Pass.js
var Pass = {
ENVIRONMENT: 0,
COMPUTE: 1,
GLOBE: 2,
TERRAIN_CLASSIFICATION: 3,
CESIUM_3D_TILE: 4,
CESIUM_3D_TILE_CLASSIFICATION: 5,
CESIUM_3D_TILE_CLASSIFICATION_IGNORE_SHOW: 6,
OPAQUE: 7,
TRANSLUCENT: 8,
OVERLAY: 9,
NUMBER_OF_PASSES: 10
};
var Pass_default = Object.freeze(Pass);
// Source/Renderer/freezeRenderState.js
function freezeRenderState(renderState) {
if (typeof renderState !== "object" || renderState === null) {
return renderState;
}
let propName;
const propNames = Object.keys(renderState);
for (let i = 0; i < propNames.length; i++) {
propName = propNames[i];
if (renderState.hasOwnProperty(propName) && propName !== "_applyFunctions") {
renderState[propName] = freezeRenderState(renderState[propName]);
}
}
return Object.freeze(renderState);
}
var freezeRenderState_default = freezeRenderState;
// Source/Renderer/RenderState.js
function validateBlendEquation(blendEquation) {
return blendEquation === WebGLConstants_default.FUNC_ADD || blendEquation === WebGLConstants_default.FUNC_SUBTRACT || blendEquation === WebGLConstants_default.FUNC_REVERSE_SUBTRACT || blendEquation === WebGLConstants_default.MIN || blendEquation === WebGLConstants_default.MAX;
}
function validateBlendFunction(blendFunction) {
return blendFunction === WebGLConstants_default.ZERO || blendFunction === WebGLConstants_default.ONE || blendFunction === WebGLConstants_default.SRC_COLOR || blendFunction === WebGLConstants_default.ONE_MINUS_SRC_COLOR || blendFunction === WebGLConstants_default.DST_COLOR || blendFunction === WebGLConstants_default.ONE_MINUS_DST_COLOR || blendFunction === WebGLConstants_default.SRC_ALPHA || blendFunction === WebGLConstants_default.ONE_MINUS_SRC_ALPHA || blendFunction === WebGLConstants_default.DST_ALPHA || blendFunction === WebGLConstants_default.ONE_MINUS_DST_ALPHA || blendFunction === WebGLConstants_default.CONSTANT_COLOR || blendFunction === WebGLConstants_default.ONE_MINUS_CONSTANT_COLOR || blendFunction === WebGLConstants_default.CONSTANT_ALPHA || blendFunction === WebGLConstants_default.ONE_MINUS_CONSTANT_ALPHA || blendFunction === WebGLConstants_default.SRC_ALPHA_SATURATE;
}
function validateCullFace(cullFace) {
return cullFace === WebGLConstants_default.FRONT || cullFace === WebGLConstants_default.BACK || cullFace === WebGLConstants_default.FRONT_AND_BACK;
}
function validateDepthFunction(depthFunction) {
return depthFunction === WebGLConstants_default.NEVER || depthFunction === WebGLConstants_default.LESS || depthFunction === WebGLConstants_default.EQUAL || depthFunction === WebGLConstants_default.LEQUAL || depthFunction === WebGLConstants_default.GREATER || depthFunction === WebGLConstants_default.NOTEQUAL || depthFunction === WebGLConstants_default.GEQUAL || depthFunction === WebGLConstants_default.ALWAYS;
}
function validateStencilFunction(stencilFunction) {
return stencilFunction === WebGLConstants_default.NEVER || stencilFunction === WebGLConstants_default.LESS || stencilFunction === WebGLConstants_default.EQUAL || stencilFunction === WebGLConstants_default.LEQUAL || stencilFunction === WebGLConstants_default.GREATER || stencilFunction === WebGLConstants_default.NOTEQUAL || stencilFunction === WebGLConstants_default.GEQUAL || stencilFunction === WebGLConstants_default.ALWAYS;
}
function validateStencilOperation(stencilOperation) {
return stencilOperation === WebGLConstants_default.ZERO || stencilOperation === WebGLConstants_default.KEEP || stencilOperation === WebGLConstants_default.REPLACE || stencilOperation === WebGLConstants_default.INCR || stencilOperation === WebGLConstants_default.DECR || stencilOperation === WebGLConstants_default.INVERT || stencilOperation === WebGLConstants_default.INCR_WRAP || stencilOperation === WebGLConstants_default.DECR_WRAP;
}
function RenderState(renderState) {
const rs = defaultValue_default(renderState, defaultValue_default.EMPTY_OBJECT);
const cull = defaultValue_default(rs.cull, defaultValue_default.EMPTY_OBJECT);
const polygonOffset = defaultValue_default(
rs.polygonOffset,
defaultValue_default.EMPTY_OBJECT
);
const scissorTest = defaultValue_default(rs.scissorTest, defaultValue_default.EMPTY_OBJECT);
const scissorTestRectangle = defaultValue_default(
scissorTest.rectangle,
defaultValue_default.EMPTY_OBJECT
);
const depthRange = defaultValue_default(rs.depthRange, defaultValue_default.EMPTY_OBJECT);
const depthTest = defaultValue_default(rs.depthTest, defaultValue_default.EMPTY_OBJECT);
const colorMask = defaultValue_default(rs.colorMask, defaultValue_default.EMPTY_OBJECT);
const blending = defaultValue_default(rs.blending, defaultValue_default.EMPTY_OBJECT);
const blendingColor = defaultValue_default(blending.color, defaultValue_default.EMPTY_OBJECT);
const stencilTest = defaultValue_default(rs.stencilTest, defaultValue_default.EMPTY_OBJECT);
const stencilTestFrontOperation = defaultValue_default(
stencilTest.frontOperation,
defaultValue_default.EMPTY_OBJECT
);
const stencilTestBackOperation = defaultValue_default(
stencilTest.backOperation,
defaultValue_default.EMPTY_OBJECT
);
const sampleCoverage = defaultValue_default(
rs.sampleCoverage,
defaultValue_default.EMPTY_OBJECT
);
const viewport = rs.viewport;
this.frontFace = defaultValue_default(rs.frontFace, WindingOrder_default.COUNTER_CLOCKWISE);
this.cull = {
enabled: defaultValue_default(cull.enabled, false),
face: defaultValue_default(cull.face, WebGLConstants_default.BACK)
};
this.lineWidth = defaultValue_default(rs.lineWidth, 1);
this.polygonOffset = {
enabled: defaultValue_default(polygonOffset.enabled, false),
factor: defaultValue_default(polygonOffset.factor, 0),
units: defaultValue_default(polygonOffset.units, 0)
};
this.scissorTest = {
enabled: defaultValue_default(scissorTest.enabled, false),
rectangle: BoundingRectangle_default.clone(scissorTestRectangle)
};
this.depthRange = {
near: defaultValue_default(depthRange.near, 0),
far: defaultValue_default(depthRange.far, 1)
};
this.depthTest = {
enabled: defaultValue_default(depthTest.enabled, false),
func: defaultValue_default(depthTest.func, WebGLConstants_default.LESS)
};
this.colorMask = {
red: defaultValue_default(colorMask.red, true),
green: defaultValue_default(colorMask.green, true),
blue: defaultValue_default(colorMask.blue, true),
alpha: defaultValue_default(colorMask.alpha, true)
};
this.depthMask = defaultValue_default(rs.depthMask, true);
this.stencilMask = defaultValue_default(rs.stencilMask, ~0);
this.blending = {
enabled: defaultValue_default(blending.enabled, false),
color: new Color_default(
defaultValue_default(blendingColor.red, 0),
defaultValue_default(blendingColor.green, 0),
defaultValue_default(blendingColor.blue, 0),
defaultValue_default(blendingColor.alpha, 0)
),
equationRgb: defaultValue_default(blending.equationRgb, WebGLConstants_default.FUNC_ADD),
equationAlpha: defaultValue_default(
blending.equationAlpha,
WebGLConstants_default.FUNC_ADD
),
functionSourceRgb: defaultValue_default(
blending.functionSourceRgb,
WebGLConstants_default.ONE
),
functionSourceAlpha: defaultValue_default(
blending.functionSourceAlpha,
WebGLConstants_default.ONE
),
functionDestinationRgb: defaultValue_default(
blending.functionDestinationRgb,
WebGLConstants_default.ZERO
),
functionDestinationAlpha: defaultValue_default(
blending.functionDestinationAlpha,
WebGLConstants_default.ZERO
)
};
this.stencilTest = {
enabled: defaultValue_default(stencilTest.enabled, false),
frontFunction: defaultValue_default(
stencilTest.frontFunction,
WebGLConstants_default.ALWAYS
),
backFunction: defaultValue_default(stencilTest.backFunction, WebGLConstants_default.ALWAYS),
reference: defaultValue_default(stencilTest.reference, 0),
mask: defaultValue_default(stencilTest.mask, ~0),
frontOperation: {
fail: defaultValue_default(stencilTestFrontOperation.fail, WebGLConstants_default.KEEP),
zFail: defaultValue_default(stencilTestFrontOperation.zFail, WebGLConstants_default.KEEP),
zPass: defaultValue_default(stencilTestFrontOperation.zPass, WebGLConstants_default.KEEP)
},
backOperation: {
fail: defaultValue_default(stencilTestBackOperation.fail, WebGLConstants_default.KEEP),
zFail: defaultValue_default(stencilTestBackOperation.zFail, WebGLConstants_default.KEEP),
zPass: defaultValue_default(stencilTestBackOperation.zPass, WebGLConstants_default.KEEP)
}
};
this.sampleCoverage = {
enabled: defaultValue_default(sampleCoverage.enabled, false),
value: defaultValue_default(sampleCoverage.value, 1),
invert: defaultValue_default(sampleCoverage.invert, false)
};
this.viewport = defined_default(viewport) ? new BoundingRectangle_default(
viewport.x,
viewport.y,
viewport.width,
viewport.height
) : void 0;
if (this.lineWidth < ContextLimits_default.minimumAliasedLineWidth || this.lineWidth > ContextLimits_default.maximumAliasedLineWidth) {
throw new DeveloperError_default(
"renderState.lineWidth is out of range. Check minimumAliasedLineWidth and maximumAliasedLineWidth."
);
}
if (!WindingOrder_default.validate(this.frontFace)) {
throw new DeveloperError_default("Invalid renderState.frontFace.");
}
if (!validateCullFace(this.cull.face)) {
throw new DeveloperError_default("Invalid renderState.cull.face.");
}
if (this.scissorTest.rectangle.width < 0 || this.scissorTest.rectangle.height < 0) {
throw new DeveloperError_default(
"renderState.scissorTest.rectangle.width and renderState.scissorTest.rectangle.height must be greater than or equal to zero."
);
}
if (this.depthRange.near > this.depthRange.far) {
throw new DeveloperError_default(
"renderState.depthRange.near can not be greater than renderState.depthRange.far."
);
}
if (this.depthRange.near < 0) {
throw new DeveloperError_default(
"renderState.depthRange.near must be greater than or equal to zero."
);
}
if (this.depthRange.far > 1) {
throw new DeveloperError_default(
"renderState.depthRange.far must be less than or equal to one."
);
}
if (!validateDepthFunction(this.depthTest.func)) {
throw new DeveloperError_default("Invalid renderState.depthTest.func.");
}
if (this.blending.color.red < 0 || this.blending.color.red > 1 || this.blending.color.green < 0 || this.blending.color.green > 1 || this.blending.color.blue < 0 || this.blending.color.blue > 1 || this.blending.color.alpha < 0 || this.blending.color.alpha > 1) {
throw new DeveloperError_default(
"renderState.blending.color components must be greater than or equal to zero and less than or equal to one."
);
}
if (!validateBlendEquation(this.blending.equationRgb)) {
throw new DeveloperError_default("Invalid renderState.blending.equationRgb.");
}
if (!validateBlendEquation(this.blending.equationAlpha)) {
throw new DeveloperError_default("Invalid renderState.blending.equationAlpha.");
}
if (!validateBlendFunction(this.blending.functionSourceRgb)) {
throw new DeveloperError_default("Invalid renderState.blending.functionSourceRgb.");
}
if (!validateBlendFunction(this.blending.functionSourceAlpha)) {
throw new DeveloperError_default(
"Invalid renderState.blending.functionSourceAlpha."
);
}
if (!validateBlendFunction(this.blending.functionDestinationRgb)) {
throw new DeveloperError_default(
"Invalid renderState.blending.functionDestinationRgb."
);
}
if (!validateBlendFunction(this.blending.functionDestinationAlpha)) {
throw new DeveloperError_default(
"Invalid renderState.blending.functionDestinationAlpha."
);
}
if (!validateStencilFunction(this.stencilTest.frontFunction)) {
throw new DeveloperError_default("Invalid renderState.stencilTest.frontFunction.");
}
if (!validateStencilFunction(this.stencilTest.backFunction)) {
throw new DeveloperError_default("Invalid renderState.stencilTest.backFunction.");
}
if (!validateStencilOperation(this.stencilTest.frontOperation.fail)) {
throw new DeveloperError_default(
"Invalid renderState.stencilTest.frontOperation.fail."
);
}
if (!validateStencilOperation(this.stencilTest.frontOperation.zFail)) {
throw new DeveloperError_default(
"Invalid renderState.stencilTest.frontOperation.zFail."
);
}
if (!validateStencilOperation(this.stencilTest.frontOperation.zPass)) {
throw new DeveloperError_default(
"Invalid renderState.stencilTest.frontOperation.zPass."
);
}
if (!validateStencilOperation(this.stencilTest.backOperation.fail)) {
throw new DeveloperError_default(
"Invalid renderState.stencilTest.backOperation.fail."
);
}
if (!validateStencilOperation(this.stencilTest.backOperation.zFail)) {
throw new DeveloperError_default(
"Invalid renderState.stencilTest.backOperation.zFail."
);
}
if (!validateStencilOperation(this.stencilTest.backOperation.zPass)) {
throw new DeveloperError_default(
"Invalid renderState.stencilTest.backOperation.zPass."
);
}
if (defined_default(this.viewport)) {
if (this.viewport.width < 0) {
throw new DeveloperError_default(
"renderState.viewport.width must be greater than or equal to zero."
);
}
if (this.viewport.height < 0) {
throw new DeveloperError_default(
"renderState.viewport.height must be greater than or equal to zero."
);
}
if (this.viewport.width > ContextLimits_default.maximumViewportWidth) {
throw new DeveloperError_default(
`renderState.viewport.width must be less than or equal to the maximum viewport width (${ContextLimits_default.maximumViewportWidth.toString()}). Check maximumViewportWidth.`
);
}
if (this.viewport.height > ContextLimits_default.maximumViewportHeight) {
throw new DeveloperError_default(
`renderState.viewport.height must be less than or equal to the maximum viewport height (${ContextLimits_default.maximumViewportHeight.toString()}). Check maximumViewportHeight.`
);
}
}
this.id = 0;
this._applyFunctions = [];
}
var nextRenderStateId = 0;
var renderStateCache = {};
RenderState.fromCache = function(renderState) {
const partialKey = JSON.stringify(renderState);
let cachedState = renderStateCache[partialKey];
if (defined_default(cachedState)) {
++cachedState.referenceCount;
return cachedState.state;
}
let states = new RenderState(renderState);
const fullKey = JSON.stringify(states);
cachedState = renderStateCache[fullKey];
if (!defined_default(cachedState)) {
states.id = nextRenderStateId++;
states = freezeRenderState_default(states);
cachedState = {
referenceCount: 0,
state: states
};
renderStateCache[fullKey] = cachedState;
}
++cachedState.referenceCount;
renderStateCache[partialKey] = {
referenceCount: 1,
state: cachedState.state
};
return cachedState.state;
};
RenderState.removeFromCache = function(renderState) {
const states = new RenderState(renderState);
const fullKey = JSON.stringify(states);
const fullCachedState = renderStateCache[fullKey];
const partialKey = JSON.stringify(renderState);
const cachedState = renderStateCache[partialKey];
if (defined_default(cachedState)) {
--cachedState.referenceCount;
if (cachedState.referenceCount === 0) {
delete renderStateCache[partialKey];
if (defined_default(fullCachedState)) {
--fullCachedState.referenceCount;
}
}
}
if (defined_default(fullCachedState) && fullCachedState.referenceCount === 0) {
delete renderStateCache[fullKey];
}
};
RenderState.getCache = function() {
return renderStateCache;
};
RenderState.clearCache = function() {
renderStateCache = {};
};
function enableOrDisable(gl, glEnum, enable) {
if (enable) {
gl.enable(glEnum);
} else {
gl.disable(glEnum);
}
}
function applyFrontFace(gl, renderState) {
gl.frontFace(renderState.frontFace);
}
function applyCull(gl, renderState) {
const cull = renderState.cull;
const enabled = cull.enabled;
enableOrDisable(gl, gl.CULL_FACE, enabled);
if (enabled) {
gl.cullFace(cull.face);
}
}
function applyLineWidth(gl, renderState) {
gl.lineWidth(renderState.lineWidth);
}
function applyPolygonOffset(gl, renderState) {
const polygonOffset = renderState.polygonOffset;
const enabled = polygonOffset.enabled;
enableOrDisable(gl, gl.POLYGON_OFFSET_FILL, enabled);
if (enabled) {
gl.polygonOffset(polygonOffset.factor, polygonOffset.units);
}
}
function applyScissorTest(gl, renderState, passState) {
const scissorTest = renderState.scissorTest;
const enabled = defined_default(passState.scissorTest) ? passState.scissorTest.enabled : scissorTest.enabled;
enableOrDisable(gl, gl.SCISSOR_TEST, enabled);
if (enabled) {
const rectangle = defined_default(passState.scissorTest) ? passState.scissorTest.rectangle : scissorTest.rectangle;
gl.scissor(rectangle.x, rectangle.y, rectangle.width, rectangle.height);
}
}
function applyDepthRange(gl, renderState) {
const depthRange = renderState.depthRange;
gl.depthRange(depthRange.near, depthRange.far);
}
function applyDepthTest(gl, renderState) {
const depthTest = renderState.depthTest;
const enabled = depthTest.enabled;
enableOrDisable(gl, gl.DEPTH_TEST, enabled);
if (enabled) {
gl.depthFunc(depthTest.func);
}
}
function applyColorMask(gl, renderState) {
const colorMask = renderState.colorMask;
gl.colorMask(colorMask.red, colorMask.green, colorMask.blue, colorMask.alpha);
}
function applyDepthMask(gl, renderState) {
gl.depthMask(renderState.depthMask);
}
function applyStencilMask(gl, renderState) {
gl.stencilMask(renderState.stencilMask);
}
function applyBlendingColor(gl, color) {
gl.blendColor(color.red, color.green, color.blue, color.alpha);
}
function applyBlending(gl, renderState, passState) {
const blending = renderState.blending;
const enabled = defined_default(passState.blendingEnabled) ? passState.blendingEnabled : blending.enabled;
enableOrDisable(gl, gl.BLEND, enabled);
if (enabled) {
applyBlendingColor(gl, blending.color);
gl.blendEquationSeparate(blending.equationRgb, blending.equationAlpha);
gl.blendFuncSeparate(
blending.functionSourceRgb,
blending.functionDestinationRgb,
blending.functionSourceAlpha,
blending.functionDestinationAlpha
);
}
}
function applyStencilTest(gl, renderState) {
const stencilTest = renderState.stencilTest;
const enabled = stencilTest.enabled;
enableOrDisable(gl, gl.STENCIL_TEST, enabled);
if (enabled) {
const frontFunction = stencilTest.frontFunction;
const backFunction = stencilTest.backFunction;
const reference = stencilTest.reference;
const mask = stencilTest.mask;
gl.stencilFunc(frontFunction, reference, mask);
gl.stencilFuncSeparate(gl.BACK, backFunction, reference, mask);
gl.stencilFuncSeparate(gl.FRONT, frontFunction, reference, mask);
const frontOperation = stencilTest.frontOperation;
const frontOperationFail = frontOperation.fail;
const frontOperationZFail = frontOperation.zFail;
const frontOperationZPass = frontOperation.zPass;
gl.stencilOpSeparate(
gl.FRONT,
frontOperationFail,
frontOperationZFail,
frontOperationZPass
);
const backOperation = stencilTest.backOperation;
const backOperationFail = backOperation.fail;
const backOperationZFail = backOperation.zFail;
const backOperationZPass = backOperation.zPass;
gl.stencilOpSeparate(
gl.BACK,
backOperationFail,
backOperationZFail,
backOperationZPass
);
}
}
function applySampleCoverage(gl, renderState) {
const sampleCoverage = renderState.sampleCoverage;
const enabled = sampleCoverage.enabled;
enableOrDisable(gl, gl.SAMPLE_COVERAGE, enabled);
if (enabled) {
gl.sampleCoverage(sampleCoverage.value, sampleCoverage.invert);
}
}
var scratchViewport = new BoundingRectangle_default();
function applyViewport(gl, renderState, passState) {
let viewport = defaultValue_default(renderState.viewport, passState.viewport);
if (!defined_default(viewport)) {
viewport = scratchViewport;
viewport.width = passState.context.drawingBufferWidth;
viewport.height = passState.context.drawingBufferHeight;
}
passState.context.uniformState.viewport = viewport;
gl.viewport(viewport.x, viewport.y, viewport.width, viewport.height);
}
RenderState.apply = function(gl, renderState, passState) {
applyFrontFace(gl, renderState);
applyCull(gl, renderState);
applyLineWidth(gl, renderState);
applyPolygonOffset(gl, renderState);
applyDepthRange(gl, renderState);
applyDepthTest(gl, renderState);
applyColorMask(gl, renderState);
applyDepthMask(gl, renderState);
applyStencilMask(gl, renderState);
applyStencilTest(gl, renderState);
applySampleCoverage(gl, renderState);
applyScissorTest(gl, renderState, passState);
applyBlending(gl, renderState, passState);
applyViewport(gl, renderState, passState);
};
function createFuncs(previousState, nextState) {
const funcs = [];
if (previousState.frontFace !== nextState.frontFace) {
funcs.push(applyFrontFace);
}
if (previousState.cull.enabled !== nextState.cull.enabled || previousState.cull.face !== nextState.cull.face) {
funcs.push(applyCull);
}
if (previousState.lineWidth !== nextState.lineWidth) {
funcs.push(applyLineWidth);
}
if (previousState.polygonOffset.enabled !== nextState.polygonOffset.enabled || previousState.polygonOffset.factor !== nextState.polygonOffset.factor || previousState.polygonOffset.units !== nextState.polygonOffset.units) {
funcs.push(applyPolygonOffset);
}
if (previousState.depthRange.near !== nextState.depthRange.near || previousState.depthRange.far !== nextState.depthRange.far) {
funcs.push(applyDepthRange);
}
if (previousState.depthTest.enabled !== nextState.depthTest.enabled || previousState.depthTest.func !== nextState.depthTest.func) {
funcs.push(applyDepthTest);
}
if (previousState.colorMask.red !== nextState.colorMask.red || previousState.colorMask.green !== nextState.colorMask.green || previousState.colorMask.blue !== nextState.colorMask.blue || previousState.colorMask.alpha !== nextState.colorMask.alpha) {
funcs.push(applyColorMask);
}
if (previousState.depthMask !== nextState.depthMask) {
funcs.push(applyDepthMask);
}
if (previousState.stencilMask !== nextState.stencilMask) {
funcs.push(applyStencilMask);
}
if (previousState.stencilTest.enabled !== nextState.stencilTest.enabled || previousState.stencilTest.frontFunction !== nextState.stencilTest.frontFunction || previousState.stencilTest.backFunction !== nextState.stencilTest.backFunction || previousState.stencilTest.reference !== nextState.stencilTest.reference || previousState.stencilTest.mask !== nextState.stencilTest.mask || previousState.stencilTest.frontOperation.fail !== nextState.stencilTest.frontOperation.fail || previousState.stencilTest.frontOperation.zFail !== nextState.stencilTest.frontOperation.zFail || previousState.stencilTest.backOperation.fail !== nextState.stencilTest.backOperation.fail || previousState.stencilTest.backOperation.zFail !== nextState.stencilTest.backOperation.zFail || previousState.stencilTest.backOperation.zPass !== nextState.stencilTest.backOperation.zPass) {
funcs.push(applyStencilTest);
}
if (previousState.sampleCoverage.enabled !== nextState.sampleCoverage.enabled || previousState.sampleCoverage.value !== nextState.sampleCoverage.value || previousState.sampleCoverage.invert !== nextState.sampleCoverage.invert) {
funcs.push(applySampleCoverage);
}
return funcs;
}
RenderState.partialApply = function(gl, previousRenderState, renderState, previousPassState, passState, clear2) {
if (previousRenderState !== renderState) {
let funcs = renderState._applyFunctions[previousRenderState.id];
if (!defined_default(funcs)) {
funcs = createFuncs(previousRenderState, renderState);
renderState._applyFunctions[previousRenderState.id] = funcs;
}
const len = funcs.length;
for (let i = 0; i < len; ++i) {
funcs[i](gl, renderState);
}
}
const previousScissorTest = defined_default(previousPassState.scissorTest) ? previousPassState.scissorTest : previousRenderState.scissorTest;
const scissorTest = defined_default(passState.scissorTest) ? passState.scissorTest : renderState.scissorTest;
if (previousScissorTest !== scissorTest || clear2) {
applyScissorTest(gl, renderState, passState);
}
const previousBlendingEnabled = defined_default(previousPassState.blendingEnabled) ? previousPassState.blendingEnabled : previousRenderState.blending.enabled;
const blendingEnabled = defined_default(passState.blendingEnabled) ? passState.blendingEnabled : renderState.blending.enabled;
if (previousBlendingEnabled !== blendingEnabled || blendingEnabled && previousRenderState.blending !== renderState.blending) {
applyBlending(gl, renderState, passState);
}
if (previousRenderState !== renderState || previousPassState !== passState || previousPassState.context !== passState.context) {
applyViewport(gl, renderState, passState);
}
};
RenderState.getState = function(renderState) {
if (!defined_default(renderState)) {
throw new DeveloperError_default("renderState is required.");
}
return {
frontFace: renderState.frontFace,
cull: {
enabled: renderState.cull.enabled,
face: renderState.cull.face
},
lineWidth: renderState.lineWidth,
polygonOffset: {
enabled: renderState.polygonOffset.enabled,
factor: renderState.polygonOffset.factor,
units: renderState.polygonOffset.units
},
scissorTest: {
enabled: renderState.scissorTest.enabled,
rectangle: BoundingRectangle_default.clone(renderState.scissorTest.rectangle)
},
depthRange: {
near: renderState.depthRange.near,
far: renderState.depthRange.far
},
depthTest: {
enabled: renderState.depthTest.enabled,
func: renderState.depthTest.func
},
colorMask: {
red: renderState.colorMask.red,
green: renderState.colorMask.green,
blue: renderState.colorMask.blue,
alpha: renderState.colorMask.alpha
},
depthMask: renderState.depthMask,
stencilMask: renderState.stencilMask,
blending: {
enabled: renderState.blending.enabled,
color: Color_default.clone(renderState.blending.color),
equationRgb: renderState.blending.equationRgb,
equationAlpha: renderState.blending.equationAlpha,
functionSourceRgb: renderState.blending.functionSourceRgb,
functionSourceAlpha: renderState.blending.functionSourceAlpha,
functionDestinationRgb: renderState.blending.functionDestinationRgb,
functionDestinationAlpha: renderState.blending.functionDestinationAlpha
},
stencilTest: {
enabled: renderState.stencilTest.enabled,
frontFunction: renderState.stencilTest.frontFunction,
backFunction: renderState.stencilTest.backFunction,
reference: renderState.stencilTest.reference,
mask: renderState.stencilTest.mask,
frontOperation: {
fail: renderState.stencilTest.frontOperation.fail,
zFail: renderState.stencilTest.frontOperation.zFail,
zPass: renderState.stencilTest.frontOperation.zPass
},
backOperation: {
fail: renderState.stencilTest.backOperation.fail,
zFail: renderState.stencilTest.backOperation.zFail,
zPass: renderState.stencilTest.backOperation.zPass
}
},
sampleCoverage: {
enabled: renderState.sampleCoverage.enabled,
value: renderState.sampleCoverage.value,
invert: renderState.sampleCoverage.invert
},
viewport: defined_default(renderState.viewport) ? BoundingRectangle_default.clone(renderState.viewport) : void 0
};
};
var RenderState_default = RenderState;
// Source/Renderer/AutomaticUniforms.js
var viewerPositionWCScratch = new Cartesian3_default();
function AutomaticUniform(options) {
this._size = options.size;
this._datatype = options.datatype;
this.getValue = options.getValue;
}
var datatypeToGlsl = {};
datatypeToGlsl[WebGLConstants_default.FLOAT] = "float";
datatypeToGlsl[WebGLConstants_default.FLOAT_VEC2] = "vec2";
datatypeToGlsl[WebGLConstants_default.FLOAT_VEC3] = "vec3";
datatypeToGlsl[WebGLConstants_default.FLOAT_VEC4] = "vec4";
datatypeToGlsl[WebGLConstants_default.INT] = "int";
datatypeToGlsl[WebGLConstants_default.INT_VEC2] = "ivec2";
datatypeToGlsl[WebGLConstants_default.INT_VEC3] = "ivec3";
datatypeToGlsl[WebGLConstants_default.INT_VEC4] = "ivec4";
datatypeToGlsl[WebGLConstants_default.BOOL] = "bool";
datatypeToGlsl[WebGLConstants_default.BOOL_VEC2] = "bvec2";
datatypeToGlsl[WebGLConstants_default.BOOL_VEC3] = "bvec3";
datatypeToGlsl[WebGLConstants_default.BOOL_VEC4] = "bvec4";
datatypeToGlsl[WebGLConstants_default.FLOAT_MAT2] = "mat2";
datatypeToGlsl[WebGLConstants_default.FLOAT_MAT3] = "mat3";
datatypeToGlsl[WebGLConstants_default.FLOAT_MAT4] = "mat4";
datatypeToGlsl[WebGLConstants_default.SAMPLER_2D] = "sampler2D";
datatypeToGlsl[WebGLConstants_default.SAMPLER_CUBE] = "samplerCube";
AutomaticUniform.prototype.getDeclaration = function(name) {
let declaration = `uniform ${datatypeToGlsl[this._datatype]} ${name}`;
const size = this._size;
if (size === 1) {
declaration += ";";
} else {
declaration += `[${size.toString()}];`;
}
return declaration;
};
var AutomaticUniforms = {
czm_viewport: new AutomaticUniform({
size: 1,
datatype: WebGLConstants_default.FLOAT_VEC4,
getValue: function(uniformState) {
return uniformState.viewportCartesian4;
}
}),
czm_viewportOrthographic: new AutomaticUniform({
size: 1,
datatype: WebGLConstants_default.FLOAT_MAT4,
getValue: function(uniformState) {
return uniformState.viewportOrthographic;
}
}),
czm_viewportTransformation: new AutomaticUniform({
size: 1,
datatype: WebGLConstants_default.FLOAT_MAT4,
getValue: function(uniformState) {
return uniformState.viewportTransformation;
}
}),
czm_globeDepthTexture: new AutomaticUniform({
size: 1,
datatype: WebGLConstants_default.SAMPLER_2D,
getValue: function(uniformState) {
return uniformState.globeDepthTexture;
}
}),
czm_model: new AutomaticUniform({
size: 1,
datatype: WebGLConstants_default.FLOAT_MAT4,
getValue: function(uniformState) {
return uniformState.model;
}
}),
czm_inverseModel: new AutomaticUniform({
size: 1,
datatype: WebGLConstants_default.FLOAT_MAT4,
getValue: function(uniformState) {
return uniformState.inverseModel;
}
}),
czm_view: new AutomaticUniform({
size: 1,
datatype: WebGLConstants_default.FLOAT_MAT4,
getValue: function(uniformState) {
return uniformState.view;
}
}),
czm_view3D: new AutomaticUniform({
size: 1,
datatype: WebGLConstants_default.FLOAT_MAT4,
getValue: function(uniformState) {
return uniformState.view3D;
}
}),
czm_viewRotation: new AutomaticUniform({
size: 1,
datatype: WebGLConstants_default.FLOAT_MAT3,
getValue: function(uniformState) {
return uniformState.viewRotation;
}
}),
czm_viewRotation3D: new AutomaticUniform({
size: 1,
datatype: WebGLConstants_default.FLOAT_MAT3,
getValue: function(uniformState) {
return uniformState.viewRotation3D;
}
}),
czm_inverseView: new AutomaticUniform({
size: 1,
datatype: WebGLConstants_default.FLOAT_MAT4,
getValue: function(uniformState) {
return uniformState.inverseView;
}
}),
czm_inverseView3D: new AutomaticUniform({
size: 1,
datatype: WebGLConstants_default.FLOAT_MAT4,
getValue: function(uniformState) {
return uniformState.inverseView3D;
}
}),
czm_inverseViewRotation: new AutomaticUniform({
size: 1,
datatype: WebGLConstants_default.FLOAT_MAT3,
getValue: function(uniformState) {
return uniformState.inverseViewRotation;
}
}),
czm_inverseViewRotation3D: new AutomaticUniform({
size: 1,
datatype: WebGLConstants_default.FLOAT_MAT3,
getValue: function(uniformState) {
return uniformState.inverseViewRotation3D;
}
}),
czm_projection: new AutomaticUniform({
size: 1,
datatype: WebGLConstants_default.FLOAT_MAT4,
getValue: function(uniformState) {
return uniformState.projection;
}
}),
czm_inverseProjection: new AutomaticUniform({
size: 1,
datatype: WebGLConstants_default.FLOAT_MAT4,
getValue: function(uniformState) {
return uniformState.inverseProjection;
}
}),
czm_infiniteProjection: new AutomaticUniform({
size: 1,
datatype: WebGLConstants_default.FLOAT_MAT4,
getValue: function(uniformState) {
return uniformState.infiniteProjection;
}
}),
czm_modelView: new AutomaticUniform({
size: 1,
datatype: WebGLConstants_default.FLOAT_MAT4,
getValue: function(uniformState) {
return uniformState.modelView;
}
}),
czm_modelView3D: new AutomaticUniform({
size: 1,
datatype: WebGLConstants_default.FLOAT_MAT4,
getValue: function(uniformState) {
return uniformState.modelView3D;
}
}),
czm_modelViewRelativeToEye: new AutomaticUniform({
size: 1,
datatype: WebGLConstants_default.FLOAT_MAT4,
getValue: function(uniformState) {
return uniformState.modelViewRelativeToEye;
}
}),
czm_inverseModelView: new AutomaticUniform({
size: 1,
datatype: WebGLConstants_default.FLOAT_MAT4,
getValue: function(uniformState) {
return uniformState.inverseModelView;
}
}),
czm_inverseModelView3D: new AutomaticUniform({
size: 1,
datatype: WebGLConstants_default.FLOAT_MAT4,
getValue: function(uniformState) {
return uniformState.inverseModelView3D;
}
}),
czm_viewProjection: new AutomaticUniform({
size: 1,
datatype: WebGLConstants_default.FLOAT_MAT4,
getValue: function(uniformState) {
return uniformState.viewProjection;
}
}),
czm_inverseViewProjection: new AutomaticUniform({
size: 1,
datatype: WebGLConstants_default.FLOAT_MAT4,
getValue: function(uniformState) {
return uniformState.inverseViewProjection;
}
}),
czm_modelViewProjection: new AutomaticUniform({
size: 1,
datatype: WebGLConstants_default.FLOAT_MAT4,
getValue: function(uniformState) {
return uniformState.modelViewProjection;
}
}),
czm_inverseModelViewProjection: new AutomaticUniform({
size: 1,
datatype: WebGLConstants_default.FLOAT_MAT4,
getValue: function(uniformState) {
return uniformState.inverseModelViewProjection;
}
}),
czm_modelViewProjectionRelativeToEye: new AutomaticUniform({
size: 1,
datatype: WebGLConstants_default.FLOAT_MAT4,
getValue: function(uniformState) {
return uniformState.modelViewProjectionRelativeToEye;
}
}),
czm_modelViewInfiniteProjection: new AutomaticUniform({
size: 1,
datatype: WebGLConstants_default.FLOAT_MAT4,
getValue: function(uniformState) {
return uniformState.modelViewInfiniteProjection;
}
}),
czm_orthographicIn3D: new AutomaticUniform({
size: 1,
datatype: WebGLConstants_default.FLOAT,
getValue: function(uniformState) {
return uniformState.orthographicIn3D ? 1 : 0;
}
}),
czm_normal: new AutomaticUniform({
size: 1,
datatype: WebGLConstants_default.FLOAT_MAT3,
getValue: function(uniformState) {
return uniformState.normal;
}
}),
czm_normal3D: new AutomaticUniform({
size: 1,
datatype: WebGLConstants_default.FLOAT_MAT3,
getValue: function(uniformState) {
return uniformState.normal3D;
}
}),
czm_inverseNormal: new AutomaticUniform({
size: 1,
datatype: WebGLConstants_default.FLOAT_MAT3,
getValue: function(uniformState) {
return uniformState.inverseNormal;
}
}),
czm_inverseNormal3D: new AutomaticUniform({
size: 1,
datatype: WebGLConstants_default.FLOAT_MAT3,
getValue: function(uniformState) {
return uniformState.inverseNormal3D;
}
}),
czm_eyeHeight: new AutomaticUniform({
size: 1,
datatype: WebGLConstants_default.FLOAT,
getValue: function(uniformState) {
return uniformState.eyeHeight;
}
}),
czm_eyeHeight2D: new AutomaticUniform({
size: 1,
datatype: WebGLConstants_default.FLOAT_VEC2,
getValue: function(uniformState) {
return uniformState.eyeHeight2D;
}
}),
czm_entireFrustum: new AutomaticUniform({
size: 1,
datatype: WebGLConstants_default.FLOAT_VEC2,
getValue: function(uniformState) {
return uniformState.entireFrustum;
}
}),
czm_currentFrustum: new AutomaticUniform({
size: 1,
datatype: WebGLConstants_default.FLOAT_VEC2,
getValue: function(uniformState) {
return uniformState.currentFrustum;
}
}),
czm_frustumPlanes: new AutomaticUniform({
size: 1,
datatype: WebGLConstants_default.FLOAT_VEC4,
getValue: function(uniformState) {
return uniformState.frustumPlanes;
}
}),
czm_farDepthFromNearPlusOne: new AutomaticUniform({
size: 1,
datatype: WebGLConstants_default.FLOAT,
getValue: function(uniformState) {
return uniformState.farDepthFromNearPlusOne;
}
}),
czm_log2FarDepthFromNearPlusOne: new AutomaticUniform({
size: 1,
datatype: WebGLConstants_default.FLOAT,
getValue: function(uniformState) {
return uniformState.log2FarDepthFromNearPlusOne;
}
}),
czm_oneOverLog2FarDepthFromNearPlusOne: new AutomaticUniform({
size: 1,
datatype: WebGLConstants_default.FLOAT,
getValue: function(uniformState) {
return uniformState.oneOverLog2FarDepthFromNearPlusOne;
}
}),
czm_sunPositionWC: new AutomaticUniform({
size: 1,
datatype: WebGLConstants_default.FLOAT_VEC3,
getValue: function(uniformState) {
return uniformState.sunPositionWC;
}
}),
czm_sunPositionColumbusView: new AutomaticUniform({
size: 1,
datatype: WebGLConstants_default.FLOAT_VEC3,
getValue: function(uniformState) {
return uniformState.sunPositionColumbusView;
}
}),
czm_sunDirectionEC: new AutomaticUniform({
size: 1,
datatype: WebGLConstants_default.FLOAT_VEC3,
getValue: function(uniformState) {
return uniformState.sunDirectionEC;
}
}),
czm_sunDirectionWC: new AutomaticUniform({
size: 1,
datatype: WebGLConstants_default.FLOAT_VEC3,
getValue: function(uniformState) {
return uniformState.sunDirectionWC;
}
}),
czm_moonDirectionEC: new AutomaticUniform({
size: 1,
datatype: WebGLConstants_default.FLOAT_VEC3,
getValue: function(uniformState) {
return uniformState.moonDirectionEC;
}
}),
czm_lightDirectionEC: new AutomaticUniform({
size: 1,
datatype: WebGLConstants_default.FLOAT_VEC3,
getValue: function(uniformState) {
return uniformState.lightDirectionEC;
}
}),
czm_lightDirectionWC: new AutomaticUniform({
size: 1,
datatype: WebGLConstants_default.FLOAT_VEC3,
getValue: function(uniformState) {
return uniformState.lightDirectionWC;
}
}),
czm_lightColor: new AutomaticUniform({
size: 1,
datatype: WebGLConstants_default.FLOAT_VEC3,
getValue: function(uniformState) {
return uniformState.lightColor;
}
}),
czm_lightColorHdr: new AutomaticUniform({
size: 1,
datatype: WebGLConstants_default.FLOAT_VEC3,
getValue: function(uniformState) {
return uniformState.lightColorHdr;
}
}),
czm_encodedCameraPositionMCHigh: new AutomaticUniform({
size: 1,
datatype: WebGLConstants_default.FLOAT_VEC3,
getValue: function(uniformState) {
return uniformState.encodedCameraPositionMCHigh;
}
}),
czm_encodedCameraPositionMCLow: new AutomaticUniform({
size: 1,
datatype: WebGLConstants_default.FLOAT_VEC3,
getValue: function(uniformState) {
return uniformState.encodedCameraPositionMCLow;
}
}),
czm_viewerPositionWC: new AutomaticUniform({
size: 1,
datatype: WebGLConstants_default.FLOAT_VEC3,
getValue: function(uniformState) {
return Matrix4_default.getTranslation(
uniformState.inverseView,
viewerPositionWCScratch
);
}
}),
czm_frameNumber: new AutomaticUniform({
size: 1,
datatype: WebGLConstants_default.FLOAT,
getValue: function(uniformState) {
return uniformState.frameState.frameNumber;
}
}),
czm_morphTime: new AutomaticUniform({
size: 1,
datatype: WebGLConstants_default.FLOAT,
getValue: function(uniformState) {
return uniformState.frameState.morphTime;
}
}),
czm_sceneMode: new AutomaticUniform({
size: 1,
datatype: WebGLConstants_default.FLOAT,
getValue: function(uniformState) {
return uniformState.frameState.mode;
}
}),
czm_pass: new AutomaticUniform({
size: 1,
datatype: WebGLConstants_default.FLOAT,
getValue: function(uniformState) {
return uniformState.pass;
}
}),
czm_backgroundColor: new AutomaticUniform({
size: 1,
datatype: WebGLConstants_default.FLOAT_VEC4,
getValue: function(uniformState) {
return uniformState.backgroundColor;
}
}),
czm_brdfLut: new AutomaticUniform({
size: 1,
datatype: WebGLConstants_default.SAMPLER_2D,
getValue: function(uniformState) {
return uniformState.brdfLut;
}
}),
czm_environmentMap: new AutomaticUniform({
size: 1,
datatype: WebGLConstants_default.SAMPLER_CUBE,
getValue: function(uniformState) {
return uniformState.environmentMap;
}
}),
czm_specularEnvironmentMaps: new AutomaticUniform({
size: 1,
datatype: WebGLConstants_default.SAMPLER_2D,
getValue: function(uniformState) {
return uniformState.specularEnvironmentMaps;
}
}),
czm_specularEnvironmentMapSize: new AutomaticUniform({
size: 1,
datatype: WebGLConstants_default.FLOAT_VEC2,
getValue: function(uniformState) {
return uniformState.specularEnvironmentMapsDimensions;
}
}),
czm_specularEnvironmentMapsMaximumLOD: new AutomaticUniform({
size: 1,
datatype: WebGLConstants_default.FLOAT,
getValue: function(uniformState) {
return uniformState.specularEnvironmentMapsMaximumLOD;
}
}),
czm_sphericalHarmonicCoefficients: new AutomaticUniform({
size: 9,
datatype: WebGLConstants_default.FLOAT_VEC3,
getValue: function(uniformState) {
return uniformState.sphericalHarmonicCoefficients;
}
}),
czm_temeToPseudoFixed: new AutomaticUniform({
size: 1,
datatype: WebGLConstants_default.FLOAT_MAT3,
getValue: function(uniformState) {
return uniformState.temeToPseudoFixedMatrix;
}
}),
czm_pixelRatio: new AutomaticUniform({
size: 1,
datatype: WebGLConstants_default.FLOAT,
getValue: function(uniformState) {
return uniformState.pixelRatio;
}
}),
czm_fogDensity: new AutomaticUniform({
size: 1,
datatype: WebGLConstants_default.FLOAT,
getValue: function(uniformState) {
return uniformState.fogDensity;
}
}),
czm_splitPosition: new AutomaticUniform({
size: 1,
datatype: WebGLConstants_default.FLOAT,
getValue: function(uniformState) {
return uniformState.splitPosition;
}
}),
czm_geometricToleranceOverMeter: new AutomaticUniform({
size: 1,
datatype: WebGLConstants_default.FLOAT,
getValue: function(uniformState) {
return uniformState.geometricToleranceOverMeter;
}
}),
czm_minimumDisableDepthTestDistance: new AutomaticUniform({
size: 1,
datatype: WebGLConstants_default.FLOAT,
getValue: function(uniformState) {
return uniformState.minimumDisableDepthTestDistance;
}
}),
czm_invertClassificationColor: new AutomaticUniform({
size: 1,
datatype: WebGLConstants_default.FLOAT_VEC4,
getValue: function(uniformState) {
return uniformState.invertClassificationColor;
}
}),
czm_gamma: new AutomaticUniform({
size: 1,
datatype: WebGLConstants_default.FLOAT,
getValue: function(uniformState) {
return uniformState.gamma;
}
}),
czm_ellipsoidRadii: new AutomaticUniform({
size: 1,
datatype: WebGLConstants_default.FLOAT_VEC3,
getValue: function(uniformState) {
return uniformState.ellipsoid.radii;
}
}),
czm_ellipsoidInverseRadii: new AutomaticUniform({
size: 1,
datatype: WebGLConstants_default.FLOAT_VEC3,
getValue: function(uniformState) {
return uniformState.ellipsoid.oneOverRadii;
}
})
};
var AutomaticUniforms_default = AutomaticUniforms;
// Source/Renderer/createUniform.js
function createUniform2(gl, activeUniform, uniformName, location2) {
switch (activeUniform.type) {
case gl.FLOAT:
return new UniformFloat(gl, activeUniform, uniformName, location2);
case gl.FLOAT_VEC2:
return new UniformFloatVec2(gl, activeUniform, uniformName, location2);
case gl.FLOAT_VEC3:
return new UniformFloatVec3(gl, activeUniform, uniformName, location2);
case gl.FLOAT_VEC4:
return new UniformFloatVec4(gl, activeUniform, uniformName, location2);
case gl.SAMPLER_2D:
case gl.SAMPLER_CUBE:
return new UniformSampler(gl, activeUniform, uniformName, location2);
case gl.INT:
case gl.BOOL:
return new UniformInt(gl, activeUniform, uniformName, location2);
case gl.INT_VEC2:
case gl.BOOL_VEC2:
return new UniformIntVec2(gl, activeUniform, uniformName, location2);
case gl.INT_VEC3:
case gl.BOOL_VEC3:
return new UniformIntVec3(gl, activeUniform, uniformName, location2);
case gl.INT_VEC4:
case gl.BOOL_VEC4:
return new UniformIntVec4(gl, activeUniform, uniformName, location2);
case gl.FLOAT_MAT2:
return new UniformMat2(gl, activeUniform, uniformName, location2);
case gl.FLOAT_MAT3:
return new UniformMat3(gl, activeUniform, uniformName, location2);
case gl.FLOAT_MAT4:
return new UniformMat4(gl, activeUniform, uniformName, location2);
default:
throw new RuntimeError_default(
`Unrecognized uniform type: ${activeUniform.type} for uniform "${uniformName}".`
);
}
}
function UniformFloat(gl, activeUniform, uniformName, location2) {
this.name = uniformName;
this.value = void 0;
this._value = 0;
this._gl = gl;
this._location = location2;
}
UniformFloat.prototype.set = function() {
if (this.value !== this._value) {
this._value = this.value;
this._gl.uniform1f(this._location, this.value);
}
};
function UniformFloatVec2(gl, activeUniform, uniformName, location2) {
this.name = uniformName;
this.value = void 0;
this._value = new Cartesian2_default();
this._gl = gl;
this._location = location2;
}
UniformFloatVec2.prototype.set = function() {
const v7 = this.value;
if (!Cartesian2_default.equals(v7, this._value)) {
Cartesian2_default.clone(v7, this._value);
this._gl.uniform2f(this._location, v7.x, v7.y);
}
};
function UniformFloatVec3(gl, activeUniform, uniformName, location2) {
this.name = uniformName;
this.value = void 0;
this._value = void 0;
this._gl = gl;
this._location = location2;
}
UniformFloatVec3.prototype.set = function() {
const v7 = this.value;
if (defined_default(v7.red)) {
if (!Color_default.equals(v7, this._value)) {
this._value = Color_default.clone(v7, this._value);
this._gl.uniform3f(this._location, v7.red, v7.green, v7.blue);
}
} else if (defined_default(v7.x)) {
if (!Cartesian3_default.equals(v7, this._value)) {
this._value = Cartesian3_default.clone(v7, this._value);
this._gl.uniform3f(this._location, v7.x, v7.y, v7.z);
}
} else {
throw new DeveloperError_default(`Invalid vec3 value for uniform "${this.name}".`);
}
};
function UniformFloatVec4(gl, activeUniform, uniformName, location2) {
this.name = uniformName;
this.value = void 0;
this._value = void 0;
this._gl = gl;
this._location = location2;
}
UniformFloatVec4.prototype.set = function() {
const v7 = this.value;
if (defined_default(v7.red)) {
if (!Color_default.equals(v7, this._value)) {
this._value = Color_default.clone(v7, this._value);
this._gl.uniform4f(this._location, v7.red, v7.green, v7.blue, v7.alpha);
}
} else if (defined_default(v7.x)) {
if (!Cartesian4_default.equals(v7, this._value)) {
this._value = Cartesian4_default.clone(v7, this._value);
this._gl.uniform4f(this._location, v7.x, v7.y, v7.z, v7.w);
}
} else {
throw new DeveloperError_default(`Invalid vec4 value for uniform "${this.name}".`);
}
};
function UniformSampler(gl, activeUniform, uniformName, location2) {
this.name = uniformName;
this.value = void 0;
this._gl = gl;
this._location = location2;
this.textureUnitIndex = void 0;
}
UniformSampler.prototype.set = function() {
const gl = this._gl;
gl.activeTexture(gl.TEXTURE0 + this.textureUnitIndex);
const v7 = this.value;
gl.bindTexture(v7._target, v7._texture);
};
UniformSampler.prototype._setSampler = function(textureUnitIndex) {
this.textureUnitIndex = textureUnitIndex;
this._gl.uniform1i(this._location, textureUnitIndex);
return textureUnitIndex + 1;
};
function UniformInt(gl, activeUniform, uniformName, location2) {
this.name = uniformName;
this.value = void 0;
this._value = 0;
this._gl = gl;
this._location = location2;
}
UniformInt.prototype.set = function() {
if (this.value !== this._value) {
this._value = this.value;
this._gl.uniform1i(this._location, this.value);
}
};
function UniformIntVec2(gl, activeUniform, uniformName, location2) {
this.name = uniformName;
this.value = void 0;
this._value = new Cartesian2_default();
this._gl = gl;
this._location = location2;
}
UniformIntVec2.prototype.set = function() {
const v7 = this.value;
if (!Cartesian2_default.equals(v7, this._value)) {
Cartesian2_default.clone(v7, this._value);
this._gl.uniform2i(this._location, v7.x, v7.y);
}
};
function UniformIntVec3(gl, activeUniform, uniformName, location2) {
this.name = uniformName;
this.value = void 0;
this._value = new Cartesian3_default();
this._gl = gl;
this._location = location2;
}
UniformIntVec3.prototype.set = function() {
const v7 = this.value;
if (!Cartesian3_default.equals(v7, this._value)) {
Cartesian3_default.clone(v7, this._value);
this._gl.uniform3i(this._location, v7.x, v7.y, v7.z);
}
};
function UniformIntVec4(gl, activeUniform, uniformName, location2) {
this.name = uniformName;
this.value = void 0;
this._value = new Cartesian4_default();
this._gl = gl;
this._location = location2;
}
UniformIntVec4.prototype.set = function() {
const v7 = this.value;
if (!Cartesian4_default.equals(v7, this._value)) {
Cartesian4_default.clone(v7, this._value);
this._gl.uniform4i(this._location, v7.x, v7.y, v7.z, v7.w);
}
};
var scratchUniformArray = new Float32Array(4);
function UniformMat2(gl, activeUniform, uniformName, location2) {
this.name = uniformName;
this.value = void 0;
this._value = new Matrix2_default();
this._gl = gl;
this._location = location2;
}
UniformMat2.prototype.set = function() {
if (!Matrix2_default.equalsArray(this.value, this._value, 0)) {
Matrix2_default.clone(this.value, this._value);
const array = Matrix2_default.toArray(this.value, scratchUniformArray);
this._gl.uniformMatrix2fv(this._location, false, array);
}
};
var scratchMat3Array = new Float32Array(9);
function UniformMat3(gl, activeUniform, uniformName, location2) {
this.name = uniformName;
this.value = void 0;
this._value = new Matrix3_default();
this._gl = gl;
this._location = location2;
}
UniformMat3.prototype.set = function() {
if (!Matrix3_default.equalsArray(this.value, this._value, 0)) {
Matrix3_default.clone(this.value, this._value);
const array = Matrix3_default.toArray(this.value, scratchMat3Array);
this._gl.uniformMatrix3fv(this._location, false, array);
}
};
var scratchMat4Array = new Float32Array(16);
function UniformMat4(gl, activeUniform, uniformName, location2) {
this.name = uniformName;
this.value = void 0;
this._value = new Matrix4_default();
this._gl = gl;
this._location = location2;
}
UniformMat4.prototype.set = function() {
if (!Matrix4_default.equalsArray(this.value, this._value, 0)) {
Matrix4_default.clone(this.value, this._value);
const array = Matrix4_default.toArray(this.value, scratchMat4Array);
this._gl.uniformMatrix4fv(this._location, false, array);
}
};
var createUniform_default = createUniform2;
// Source/Renderer/createUniformArray.js
function createUniformArray(gl, activeUniform, uniformName, locations) {
switch (activeUniform.type) {
case gl.FLOAT:
return new UniformArrayFloat(gl, activeUniform, uniformName, locations);
case gl.FLOAT_VEC2:
return new UniformArrayFloatVec2(
gl,
activeUniform,
uniformName,
locations
);
case gl.FLOAT_VEC3:
return new UniformArrayFloatVec3(
gl,
activeUniform,
uniformName,
locations
);
case gl.FLOAT_VEC4:
return new UniformArrayFloatVec4(
gl,
activeUniform,
uniformName,
locations
);
case gl.SAMPLER_2D:
case gl.SAMPLER_CUBE:
return new UniformArraySampler(gl, activeUniform, uniformName, locations);
case gl.INT:
case gl.BOOL:
return new UniformArrayInt(gl, activeUniform, uniformName, locations);
case gl.INT_VEC2:
case gl.BOOL_VEC2:
return new UniformArrayIntVec2(gl, activeUniform, uniformName, locations);
case gl.INT_VEC3:
case gl.BOOL_VEC3:
return new UniformArrayIntVec3(gl, activeUniform, uniformName, locations);
case gl.INT_VEC4:
case gl.BOOL_VEC4:
return new UniformArrayIntVec4(gl, activeUniform, uniformName, locations);
case gl.FLOAT_MAT2:
return new UniformArrayMat2(gl, activeUniform, uniformName, locations);
case gl.FLOAT_MAT3:
return new UniformArrayMat3(gl, activeUniform, uniformName, locations);
case gl.FLOAT_MAT4:
return new UniformArrayMat4(gl, activeUniform, uniformName, locations);
default:
throw new RuntimeError_default(
`Unrecognized uniform type: ${activeUniform.type} for uniform "${uniformName}".`
);
}
}
function UniformArrayFloat(gl, activeUniform, uniformName, locations) {
const length3 = locations.length;
this.name = uniformName;
this.value = new Array(length3);
this._value = new Float32Array(length3);
this._gl = gl;
this._location = locations[0];
}
UniformArrayFloat.prototype.set = function() {
const value = this.value;
const length3 = value.length;
const arraybuffer = this._value;
let changed = false;
for (let i = 0; i < length3; ++i) {
const v7 = value[i];
if (v7 !== arraybuffer[i]) {
arraybuffer[i] = v7;
changed = true;
}
}
if (changed) {
this._gl.uniform1fv(this._location, arraybuffer);
}
};
function UniformArrayFloatVec2(gl, activeUniform, uniformName, locations) {
const length3 = locations.length;
this.name = uniformName;
this.value = new Array(length3);
this._value = new Float32Array(length3 * 2);
this._gl = gl;
this._location = locations[0];
}
UniformArrayFloatVec2.prototype.set = function() {
const value = this.value;
const length3 = value.length;
const arraybuffer = this._value;
let changed = false;
let j = 0;
for (let i = 0; i < length3; ++i) {
const v7 = value[i];
if (!Cartesian2_default.equalsArray(v7, arraybuffer, j)) {
Cartesian2_default.pack(v7, arraybuffer, j);
changed = true;
}
j += 2;
}
if (changed) {
this._gl.uniform2fv(this._location, arraybuffer);
}
};
function UniformArrayFloatVec3(gl, activeUniform, uniformName, locations) {
const length3 = locations.length;
this.name = uniformName;
this.value = new Array(length3);
this._value = new Float32Array(length3 * 3);
this._gl = gl;
this._location = locations[0];
}
UniformArrayFloatVec3.prototype.set = function() {
const value = this.value;
const length3 = value.length;
const arraybuffer = this._value;
let changed = false;
let j = 0;
for (let i = 0; i < length3; ++i) {
const v7 = value[i];
if (defined_default(v7.red)) {
if (v7.red !== arraybuffer[j] || v7.green !== arraybuffer[j + 1] || v7.blue !== arraybuffer[j + 2]) {
arraybuffer[j] = v7.red;
arraybuffer[j + 1] = v7.green;
arraybuffer[j + 2] = v7.blue;
changed = true;
}
} else if (defined_default(v7.x)) {
if (!Cartesian3_default.equalsArray(v7, arraybuffer, j)) {
Cartesian3_default.pack(v7, arraybuffer, j);
changed = true;
}
} else {
throw new DeveloperError_default("Invalid vec3 value.");
}
j += 3;
}
if (changed) {
this._gl.uniform3fv(this._location, arraybuffer);
}
};
function UniformArrayFloatVec4(gl, activeUniform, uniformName, locations) {
const length3 = locations.length;
this.name = uniformName;
this.value = new Array(length3);
this._value = new Float32Array(length3 * 4);
this._gl = gl;
this._location = locations[0];
}
UniformArrayFloatVec4.prototype.set = function() {
const value = this.value;
const length3 = value.length;
const arraybuffer = this._value;
let changed = false;
let j = 0;
for (let i = 0; i < length3; ++i) {
const v7 = value[i];
if (defined_default(v7.red)) {
if (!Color_default.equalsArray(v7, arraybuffer, j)) {
Color_default.pack(v7, arraybuffer, j);
changed = true;
}
} else if (defined_default(v7.x)) {
if (!Cartesian4_default.equalsArray(v7, arraybuffer, j)) {
Cartesian4_default.pack(v7, arraybuffer, j);
changed = true;
}
} else {
throw new DeveloperError_default("Invalid vec4 value.");
}
j += 4;
}
if (changed) {
this._gl.uniform4fv(this._location, arraybuffer);
}
};
function UniformArraySampler(gl, activeUniform, uniformName, locations) {
const length3 = locations.length;
this.name = uniformName;
this.value = new Array(length3);
this._value = new Float32Array(length3);
this._gl = gl;
this._locations = locations;
this.textureUnitIndex = void 0;
}
UniformArraySampler.prototype.set = function() {
const gl = this._gl;
const textureUnitIndex = gl.TEXTURE0 + this.textureUnitIndex;
const value = this.value;
const length3 = value.length;
for (let i = 0; i < length3; ++i) {
const v7 = value[i];
gl.activeTexture(textureUnitIndex + i);
gl.bindTexture(v7._target, v7._texture);
}
};
UniformArraySampler.prototype._setSampler = function(textureUnitIndex) {
this.textureUnitIndex = textureUnitIndex;
const locations = this._locations;
const length3 = locations.length;
for (let i = 0; i < length3; ++i) {
const index = textureUnitIndex + i;
this._gl.uniform1i(locations[i], index);
}
return textureUnitIndex + length3;
};
function UniformArrayInt(gl, activeUniform, uniformName, locations) {
const length3 = locations.length;
this.name = uniformName;
this.value = new Array(length3);
this._value = new Int32Array(length3);
this._gl = gl;
this._location = locations[0];
}
UniformArrayInt.prototype.set = function() {
const value = this.value;
const length3 = value.length;
const arraybuffer = this._value;
let changed = false;
for (let i = 0; i < length3; ++i) {
const v7 = value[i];
if (v7 !== arraybuffer[i]) {
arraybuffer[i] = v7;
changed = true;
}
}
if (changed) {
this._gl.uniform1iv(this._location, arraybuffer);
}
};
function UniformArrayIntVec2(gl, activeUniform, uniformName, locations) {
const length3 = locations.length;
this.name = uniformName;
this.value = new Array(length3);
this._value = new Int32Array(length3 * 2);
this._gl = gl;
this._location = locations[0];
}
UniformArrayIntVec2.prototype.set = function() {
const value = this.value;
const length3 = value.length;
const arraybuffer = this._value;
let changed = false;
let j = 0;
for (let i = 0; i < length3; ++i) {
const v7 = value[i];
if (!Cartesian2_default.equalsArray(v7, arraybuffer, j)) {
Cartesian2_default.pack(v7, arraybuffer, j);
changed = true;
}
j += 2;
}
if (changed) {
this._gl.uniform2iv(this._location, arraybuffer);
}
};
function UniformArrayIntVec3(gl, activeUniform, uniformName, locations) {
const length3 = locations.length;
this.name = uniformName;
this.value = new Array(length3);
this._value = new Int32Array(length3 * 3);
this._gl = gl;
this._location = locations[0];
}
UniformArrayIntVec3.prototype.set = function() {
const value = this.value;
const length3 = value.length;
const arraybuffer = this._value;
let changed = false;
let j = 0;
for (let i = 0; i < length3; ++i) {
const v7 = value[i];
if (!Cartesian3_default.equalsArray(v7, arraybuffer, j)) {
Cartesian3_default.pack(v7, arraybuffer, j);
changed = true;
}
j += 3;
}
if (changed) {
this._gl.uniform3iv(this._location, arraybuffer);
}
};
function UniformArrayIntVec4(gl, activeUniform, uniformName, locations) {
const length3 = locations.length;
this.name = uniformName;
this.value = new Array(length3);
this._value = new Int32Array(length3 * 4);
this._gl = gl;
this._location = locations[0];
}
UniformArrayIntVec4.prototype.set = function() {
const value = this.value;
const length3 = value.length;
const arraybuffer = this._value;
let changed = false;
let j = 0;
for (let i = 0; i < length3; ++i) {
const v7 = value[i];
if (!Cartesian4_default.equalsArray(v7, arraybuffer, j)) {
Cartesian4_default.pack(v7, arraybuffer, j);
changed = true;
}
j += 4;
}
if (changed) {
this._gl.uniform4iv(this._location, arraybuffer);
}
};
function UniformArrayMat2(gl, activeUniform, uniformName, locations) {
const length3 = locations.length;
this.name = uniformName;
this.value = new Array(length3);
this._value = new Float32Array(length3 * 4);
this._gl = gl;
this._location = locations[0];
}
UniformArrayMat2.prototype.set = function() {
const value = this.value;
const length3 = value.length;
const arraybuffer = this._value;
let changed = false;
let j = 0;
for (let i = 0; i < length3; ++i) {
const v7 = value[i];
if (!Matrix2_default.equalsArray(v7, arraybuffer, j)) {
Matrix2_default.pack(v7, arraybuffer, j);
changed = true;
}
j += 4;
}
if (changed) {
this._gl.uniformMatrix2fv(this._location, false, arraybuffer);
}
};
function UniformArrayMat3(gl, activeUniform, uniformName, locations) {
const length3 = locations.length;
this.name = uniformName;
this.value = new Array(length3);
this._value = new Float32Array(length3 * 9);
this._gl = gl;
this._location = locations[0];
}
UniformArrayMat3.prototype.set = function() {
const value = this.value;
const length3 = value.length;
const arraybuffer = this._value;
let changed = false;
let j = 0;
for (let i = 0; i < length3; ++i) {
const v7 = value[i];
if (!Matrix3_default.equalsArray(v7, arraybuffer, j)) {
Matrix3_default.pack(v7, arraybuffer, j);
changed = true;
}
j += 9;
}
if (changed) {
this._gl.uniformMatrix3fv(this._location, false, arraybuffer);
}
};
function UniformArrayMat4(gl, activeUniform, uniformName, locations) {
const length3 = locations.length;
this.name = uniformName;
this.value = new Array(length3);
this._value = new Float32Array(length3 * 16);
this._gl = gl;
this._location = locations[0];
}
UniformArrayMat4.prototype.set = function() {
const value = this.value;
const length3 = value.length;
const arraybuffer = this._value;
let changed = false;
let j = 0;
for (let i = 0; i < length3; ++i) {
const v7 = value[i];
if (!Matrix4_default.equalsArray(v7, arraybuffer, j)) {
Matrix4_default.pack(v7, arraybuffer, j);
changed = true;
}
j += 16;
}
if (changed) {
this._gl.uniformMatrix4fv(this._location, false, arraybuffer);
}
};
var createUniformArray_default = createUniformArray;
// Source/Renderer/ShaderProgram.js
var nextShaderProgramId = 0;
function ShaderProgram(options) {
let vertexShaderText = options.vertexShaderText;
let fragmentShaderText = options.fragmentShaderText;
if (typeof spector !== "undefined") {
vertexShaderText = vertexShaderText.replace(/^#line/gm, "//#line");
fragmentShaderText = fragmentShaderText.replace(/^#line/gm, "//#line");
}
const modifiedFS = handleUniformPrecisionMismatches(
vertexShaderText,
fragmentShaderText
);
this._gl = options.gl;
this._logShaderCompilation = options.logShaderCompilation;
this._debugShaders = options.debugShaders;
this._attributeLocations = options.attributeLocations;
this._program = void 0;
this._numberOfVertexAttributes = void 0;
this._vertexAttributes = void 0;
this._uniformsByName = void 0;
this._uniforms = void 0;
this._automaticUniforms = void 0;
this._manualUniforms = void 0;
this._duplicateUniformNames = modifiedFS.duplicateUniformNames;
this._cachedShader = void 0;
this.maximumTextureUnitIndex = void 0;
this._vertexShaderSource = options.vertexShaderSource;
this._vertexShaderText = options.vertexShaderText;
this._fragmentShaderSource = options.fragmentShaderSource;
this._fragmentShaderText = modifiedFS.fragmentShaderText;
this.id = nextShaderProgramId++;
}
ShaderProgram.fromCache = function(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
Check_default.defined("options.context", options.context);
return options.context.shaderCache.getShaderProgram(options);
};
ShaderProgram.replaceCache = function(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
Check_default.defined("options.context", options.context);
return options.context.shaderCache.replaceShaderProgram(options);
};
Object.defineProperties(ShaderProgram.prototype, {
vertexShaderSource: {
get: function() {
return this._vertexShaderSource;
}
},
fragmentShaderSource: {
get: function() {
return this._fragmentShaderSource;
}
},
vertexAttributes: {
get: function() {
initialize2(this);
return this._vertexAttributes;
}
},
numberOfVertexAttributes: {
get: function() {
initialize2(this);
return this._numberOfVertexAttributes;
}
},
allUniforms: {
get: function() {
initialize2(this);
return this._uniformsByName;
}
}
});
function extractUniforms(shaderText) {
const uniformNames = [];
const uniformLines = shaderText.match(/uniform.*?(?![^{]*})(?=[=\[;])/g);
if (defined_default(uniformLines)) {
const len = uniformLines.length;
for (let i = 0; i < len; i++) {
const line = uniformLines[i].trim();
const name = line.slice(line.lastIndexOf(" ") + 1);
uniformNames.push(name);
}
}
return uniformNames;
}
function handleUniformPrecisionMismatches(vertexShaderText, fragmentShaderText) {
const duplicateUniformNames = {};
if (!ContextLimits_default.highpFloatSupported || !ContextLimits_default.highpIntSupported) {
let i, j;
let uniformName;
let duplicateName;
const vertexShaderUniforms = extractUniforms(vertexShaderText);
const fragmentShaderUniforms = extractUniforms(fragmentShaderText);
const vertexUniformsCount = vertexShaderUniforms.length;
const fragmentUniformsCount = fragmentShaderUniforms.length;
for (i = 0; i < vertexUniformsCount; i++) {
for (j = 0; j < fragmentUniformsCount; j++) {
if (vertexShaderUniforms[i] === fragmentShaderUniforms[j]) {
uniformName = vertexShaderUniforms[i];
duplicateName = `czm_mediump_${uniformName}`;
const re = new RegExp(`${uniformName}\\b`, "g");
fragmentShaderText = fragmentShaderText.replace(re, duplicateName);
duplicateUniformNames[duplicateName] = uniformName;
}
}
}
}
return {
fragmentShaderText,
duplicateUniformNames
};
}
var consolePrefix = "[Cesium WebGL] ";
function createAndLinkProgram(gl, shader) {
const vsSource = shader._vertexShaderText;
const fsSource = shader._fragmentShaderText;
const vertexShader = gl.createShader(gl.VERTEX_SHADER);
gl.shaderSource(vertexShader, vsSource);
gl.compileShader(vertexShader);
const fragmentShader = gl.createShader(gl.FRAGMENT_SHADER);
gl.shaderSource(fragmentShader, fsSource);
gl.compileShader(fragmentShader);
const program = gl.createProgram();
gl.attachShader(program, vertexShader);
gl.attachShader(program, fragmentShader);
gl.deleteShader(vertexShader);
gl.deleteShader(fragmentShader);
const attributeLocations8 = shader._attributeLocations;
if (defined_default(attributeLocations8)) {
for (const attribute in attributeLocations8) {
if (attributeLocations8.hasOwnProperty(attribute)) {
gl.bindAttribLocation(
program,
attributeLocations8[attribute],
attribute
);
}
}
}
gl.linkProgram(program);
let log;
if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
const debugShaders = shader._debugShaders;
if (!gl.getShaderParameter(fragmentShader, gl.COMPILE_STATUS)) {
log = gl.getShaderInfoLog(fragmentShader);
console.error(`${consolePrefix}Fragment shader compile log: ${log}`);
if (defined_default(debugShaders)) {
const fragmentSourceTranslation = debugShaders.getTranslatedShaderSource(
fragmentShader
);
if (fragmentSourceTranslation !== "") {
console.error(
`${consolePrefix}Translated fragment shader source:
${fragmentSourceTranslation}`
);
} else {
console.error(`${consolePrefix}Fragment shader translation failed.`);
}
}
gl.deleteProgram(program);
throw new RuntimeError_default(
`Fragment shader failed to compile. Compile log: ${log}`
);
}
if (!gl.getShaderParameter(vertexShader, gl.COMPILE_STATUS)) {
log = gl.getShaderInfoLog(vertexShader);
console.error(`${consolePrefix}Vertex shader compile log: ${log}`);
if (defined_default(debugShaders)) {
const vertexSourceTranslation = debugShaders.getTranslatedShaderSource(
vertexShader
);
if (vertexSourceTranslation !== "") {
console.error(
`${consolePrefix}Translated vertex shader source:
${vertexSourceTranslation}`
);
} else {
console.error(`${consolePrefix}Vertex shader translation failed.`);
}
}
gl.deleteProgram(program);
throw new RuntimeError_default(
`Vertex shader failed to compile. Compile log: ${log}`
);
}
log = gl.getProgramInfoLog(program);
console.error(`${consolePrefix}Shader program link log: ${log}`);
if (defined_default(debugShaders)) {
console.error(
`${consolePrefix}Translated vertex shader source:
${debugShaders.getTranslatedShaderSource(
vertexShader
)}`
);
console.error(
`${consolePrefix}Translated fragment shader source:
${debugShaders.getTranslatedShaderSource(
fragmentShader
)}`
);
}
gl.deleteProgram(program);
throw new RuntimeError_default(`Program failed to link. Link log: ${log}`);
}
const logShaderCompilation = shader._logShaderCompilation;
if (logShaderCompilation) {
log = gl.getShaderInfoLog(vertexShader);
if (defined_default(log) && log.length > 0) {
console.log(`${consolePrefix}Vertex shader compile log: ${log}`);
}
}
if (logShaderCompilation) {
log = gl.getShaderInfoLog(fragmentShader);
if (defined_default(log) && log.length > 0) {
console.log(`${consolePrefix}Fragment shader compile log: ${log}`);
}
}
if (logShaderCompilation) {
log = gl.getProgramInfoLog(program);
if (defined_default(log) && log.length > 0) {
console.log(`${consolePrefix}Shader program link log: ${log}`);
}
}
return program;
}
function findVertexAttributes(gl, program, numberOfAttributes2) {
const attributes = {};
for (let i = 0; i < numberOfAttributes2; ++i) {
const attr = gl.getActiveAttrib(program, i);
const location2 = gl.getAttribLocation(program, attr.name);
attributes[attr.name] = {
name: attr.name,
type: attr.type,
index: location2
};
}
return attributes;
}
function findUniforms(gl, program) {
const uniformsByName = {};
const uniforms = [];
const samplerUniforms = [];
const numberOfUniforms = gl.getProgramParameter(program, gl.ACTIVE_UNIFORMS);
for (let i = 0; i < numberOfUniforms; ++i) {
const activeUniform = gl.getActiveUniform(program, i);
const suffix = "[0]";
const uniformName = activeUniform.name.indexOf(
suffix,
activeUniform.name.length - suffix.length
) !== -1 ? activeUniform.name.slice(0, activeUniform.name.length - 3) : activeUniform.name;
if (uniformName.indexOf("gl_") !== 0) {
if (activeUniform.name.indexOf("[") < 0) {
const location2 = gl.getUniformLocation(program, uniformName);
if (location2 !== null) {
const uniform = createUniform_default(
gl,
activeUniform,
uniformName,
location2
);
uniformsByName[uniformName] = uniform;
uniforms.push(uniform);
if (uniform._setSampler) {
samplerUniforms.push(uniform);
}
}
} else {
let uniformArray;
let locations;
let value;
let loc;
const indexOfBracket = uniformName.indexOf("[");
if (indexOfBracket >= 0) {
uniformArray = uniformsByName[uniformName.slice(0, indexOfBracket)];
if (!defined_default(uniformArray)) {
continue;
}
locations = uniformArray._locations;
if (locations.length <= 1) {
value = uniformArray.value;
loc = gl.getUniformLocation(program, uniformName);
if (loc !== null) {
locations.push(loc);
value.push(gl.getUniform(program, loc));
}
}
} else {
locations = [];
for (let j = 0; j < activeUniform.size; ++j) {
loc = gl.getUniformLocation(program, `${uniformName}[${j}]`);
if (loc !== null) {
locations.push(loc);
}
}
uniformArray = createUniformArray_default(
gl,
activeUniform,
uniformName,
locations
);
uniformsByName[uniformName] = uniformArray;
uniforms.push(uniformArray);
if (uniformArray._setSampler) {
samplerUniforms.push(uniformArray);
}
}
}
}
}
return {
uniformsByName,
uniforms,
samplerUniforms
};
}
function partitionUniforms(shader, uniforms) {
const automaticUniforms = [];
const manualUniforms = [];
for (const uniform in uniforms) {
if (uniforms.hasOwnProperty(uniform)) {
const uniformObject = uniforms[uniform];
let uniformName = uniform;
const duplicateUniform = shader._duplicateUniformNames[uniformName];
if (defined_default(duplicateUniform)) {
uniformObject.name = duplicateUniform;
uniformName = duplicateUniform;
}
const automaticUniform = AutomaticUniforms_default[uniformName];
if (defined_default(automaticUniform)) {
automaticUniforms.push({
uniform: uniformObject,
automaticUniform
});
} else {
manualUniforms.push(uniformObject);
}
}
}
return {
automaticUniforms,
manualUniforms
};
}
function setSamplerUniforms(gl, program, samplerUniforms) {
gl.useProgram(program);
let textureUnitIndex = 0;
const length3 = samplerUniforms.length;
for (let i = 0; i < length3; ++i) {
textureUnitIndex = samplerUniforms[i]._setSampler(textureUnitIndex);
}
gl.useProgram(null);
return textureUnitIndex;
}
function initialize2(shader) {
if (defined_default(shader._program)) {
return;
}
reinitialize(shader);
}
function reinitialize(shader) {
const oldProgram = shader._program;
const gl = shader._gl;
const program = createAndLinkProgram(gl, shader, shader._debugShaders);
const numberOfVertexAttributes = gl.getProgramParameter(
program,
gl.ACTIVE_ATTRIBUTES
);
const uniforms = findUniforms(gl, program);
const partitionedUniforms = partitionUniforms(
shader,
uniforms.uniformsByName
);
shader._program = program;
shader._numberOfVertexAttributes = numberOfVertexAttributes;
shader._vertexAttributes = findVertexAttributes(
gl,
program,
numberOfVertexAttributes
);
shader._uniformsByName = uniforms.uniformsByName;
shader._uniforms = uniforms.uniforms;
shader._automaticUniforms = partitionedUniforms.automaticUniforms;
shader._manualUniforms = partitionedUniforms.manualUniforms;
shader.maximumTextureUnitIndex = setSamplerUniforms(
gl,
program,
uniforms.samplerUniforms
);
if (oldProgram) {
shader._gl.deleteProgram(oldProgram);
}
if (typeof spector !== "undefined") {
shader._program.__SPECTOR_rebuildProgram = function(vertexSourceCode, fragmentSourceCode, onCompiled, onError) {
const originalVS = shader._vertexShaderText;
const originalFS = shader._fragmentShaderText;
const regex = / ! = /g;
shader._vertexShaderText = vertexSourceCode.replace(regex, " != ");
shader._fragmentShaderText = fragmentSourceCode.replace(regex, " != ");
try {
reinitialize(shader);
onCompiled(shader._program);
} catch (e) {
shader._vertexShaderText = originalVS;
shader._fragmentShaderText = originalFS;
const errorMatcher = /(?:Compile|Link) error: ([^]*)/;
const match = errorMatcher.exec(e.message);
if (match) {
onError(match[1]);
} else {
onError(e.message);
}
}
};
}
}
ShaderProgram.prototype._bind = function() {
initialize2(this);
this._gl.useProgram(this._program);
};
ShaderProgram.prototype._setUniforms = function(uniformMap2, uniformState, validate) {
let len;
let i;
if (defined_default(uniformMap2)) {
const manualUniforms = this._manualUniforms;
len = manualUniforms.length;
for (i = 0; i < len; ++i) {
const mu = manualUniforms[i];
mu.value = uniformMap2[mu.name]();
}
}
const automaticUniforms = this._automaticUniforms;
len = automaticUniforms.length;
for (i = 0; i < len; ++i) {
const au = automaticUniforms[i];
au.uniform.value = au.automaticUniform.getValue(uniformState);
}
const uniforms = this._uniforms;
len = uniforms.length;
for (i = 0; i < len; ++i) {
uniforms[i].set();
}
if (validate) {
const gl = this._gl;
const program = this._program;
gl.validateProgram(program);
if (!gl.getProgramParameter(program, gl.VALIDATE_STATUS)) {
throw new DeveloperError_default(
`Program validation failed. Program info log: ${gl.getProgramInfoLog(
program
)}`
);
}
}
};
ShaderProgram.prototype.isDestroyed = function() {
return false;
};
ShaderProgram.prototype.destroy = function() {
this._cachedShader.cache.releaseShaderProgram(this);
return void 0;
};
ShaderProgram.prototype.finalDestroy = function() {
this._gl.deleteProgram(this._program);
return destroyObject_default(this);
};
var ShaderProgram_default = ShaderProgram;
// Source/Renderer/modernizeShader.js
function modernizeShader(source, isFragmentShader) {
const outputDeclarationRegex = /#define OUTPUT_DECLARATION/;
const splitSource = source.split("\n");
if (/#version 300 es/g.test(source)) {
return source;
}
let outputDeclarationLine = -1;
let i, line;
for (i = 0; i < splitSource.length; ++i) {
line = splitSource[i];
if (outputDeclarationRegex.test(line)) {
outputDeclarationLine = i;
break;
}
}
if (outputDeclarationLine === -1) {
throw new DeveloperError_default("Could not find a #define OUTPUT_DECLARATION!");
}
const outputVariables = [];
for (i = 0; i < 10; i++) {
const fragDataString = `gl_FragData\\[${i}\\]`;
const newOutput = `czm_out${i}`;
const regex = new RegExp(fragDataString, "g");
if (regex.test(source)) {
setAdd(newOutput, outputVariables);
replaceInSourceString(fragDataString, newOutput, splitSource);
splitSource.splice(
outputDeclarationLine,
0,
`layout(location = ${i}) out vec4 ${newOutput};`
);
outputDeclarationLine += 1;
}
}
const czmFragColor = "czm_fragColor";
if (findInSource("gl_FragColor", splitSource)) {
setAdd(czmFragColor, outputVariables);
replaceInSourceString("gl_FragColor", czmFragColor, splitSource);
splitSource.splice(
outputDeclarationLine,
0,
"layout(location = 0) out vec4 czm_fragColor;"
);
outputDeclarationLine += 1;
}
const variableMap = getVariablePreprocessorBranch(
outputVariables,
splitSource
);
const lineAdds = {};
for (i = 0; i < splitSource.length; i++) {
line = splitSource[i];
for (const variable in variableMap) {
if (variableMap.hasOwnProperty(variable)) {
const matchVar = new RegExp(
`(layout)[^]+(out)[^]+(${variable})[^]+`,
"g"
);
if (matchVar.test(line)) {
lineAdds[line] = variable;
}
}
}
}
for (const layoutDeclaration in lineAdds) {
if (lineAdds.hasOwnProperty(layoutDeclaration)) {
const variableName = lineAdds[layoutDeclaration];
let lineNumber = splitSource.indexOf(layoutDeclaration);
const entry = variableMap[variableName];
const depth = entry.length;
for (let d = 0; d < depth; d++) {
splitSource.splice(lineNumber, 0, entry[d]);
}
lineNumber += depth + 1;
for (let d = depth - 1; d >= 0; d--) {
splitSource.splice(lineNumber, 0, `#endif //${entry[d]}`);
}
}
}
const webgl2UniqueID = "WEBGL_2";
const webgl2DefineMacro = `#define ${webgl2UniqueID}`;
const versionThree = "#version 300 es";
let foundVersion = false;
for (i = 0; i < splitSource.length; i++) {
if (/#version/.test(splitSource[i])) {
splitSource[i] = versionThree;
foundVersion = true;
break;
}
}
if (!foundVersion) {
splitSource.splice(0, 0, versionThree);
}
splitSource.splice(1, 0, webgl2DefineMacro);
removeExtension("EXT_draw_buffers", webgl2UniqueID, splitSource);
removeExtension("EXT_frag_depth", webgl2UniqueID, splitSource);
removeExtension("OES_standard_derivatives", webgl2UniqueID, splitSource);
replaceInSourceString("texture2D", "texture", splitSource);
replaceInSourceString("texture3D", "texture", splitSource);
replaceInSourceString("textureCube", "texture", splitSource);
replaceInSourceString("gl_FragDepthEXT", "gl_FragDepth", splitSource);
if (isFragmentShader) {
replaceInSourceString("varying", "in", splitSource);
} else {
replaceInSourceString("attribute", "in", splitSource);
replaceInSourceString("varying", "out", splitSource);
}
return compileSource(splitSource);
}
function replaceInSourceString(str, replacement, splitSource) {
const regexStr = `(^|[^\\w])(${str})($|[^\\w])`;
const regex = new RegExp(regexStr, "g");
const splitSourceLength = splitSource.length;
for (let i = 0; i < splitSourceLength; ++i) {
const line = splitSource[i];
splitSource[i] = line.replace(regex, `$1${replacement}$3`);
}
}
function replaceInSourceRegex(regex, replacement, splitSource) {
const splitSourceLength = splitSource.length;
for (let i = 0; i < splitSourceLength; ++i) {
const line = splitSource[i];
splitSource[i] = line.replace(regex, replacement);
}
}
function findInSource(str, splitSource) {
const regexStr = `(^|[^\\w])(${str})($|[^\\w])`;
const regex = new RegExp(regexStr, "g");
const splitSourceLength = splitSource.length;
for (let i = 0; i < splitSourceLength; ++i) {
const line = splitSource[i];
if (regex.test(line)) {
return true;
}
}
return false;
}
function compileSource(splitSource) {
let wholeSource = "";
const splitSourceLength = splitSource.length;
for (let i = 0; i < splitSourceLength; ++i) {
wholeSource += `${splitSource[i]}
`;
}
return wholeSource;
}
function setAdd(variable, set2) {
if (set2.indexOf(variable) === -1) {
set2.push(variable);
}
}
function getVariablePreprocessorBranch(layoutVariables, splitSource) {
const variableMap = {};
const numLayoutVariables = layoutVariables.length;
const stack = [];
for (let i = 0; i < splitSource.length; ++i) {
const line = splitSource[i];
const hasIF = /(#ifdef|#if)/g.test(line);
const hasELSE = /#else/g.test(line);
const hasENDIF = /#endif/g.test(line);
if (hasIF) {
stack.push(line);
} else if (hasELSE) {
const top = stack[stack.length - 1];
let op = top.replace("ifdef", "ifndef");
if (/if/g.test(op)) {
op = op.replace(/(#if\s+)(\S*)([^]*)/, "$1!($2)$3");
}
stack.pop();
stack.push(op);
} else if (hasENDIF) {
stack.pop();
} else if (!/layout/g.test(line)) {
for (let varIndex = 0; varIndex < numLayoutVariables; ++varIndex) {
const varName = layoutVariables[varIndex];
if (line.indexOf(varName) !== -1) {
if (!defined_default(variableMap[varName])) {
variableMap[varName] = stack.slice();
} else {
variableMap[varName] = variableMap[varName].filter(function(x) {
return stack.indexOf(x) >= 0;
});
}
}
}
}
}
return variableMap;
}
function removeExtension(name, webgl2UniqueID, splitSource) {
const regex = `#extension\\s+GL_${name}\\s+:\\s+[a-zA-Z0-9]+\\s*$`;
replaceInSourceRegex(new RegExp(regex, "g"), "", splitSource);
replaceInSourceString(`GL_${name}`, webgl2UniqueID, splitSource);
}
var modernizeShader_default = modernizeShader;
// Source/Shaders/Builtin/Constants/degreesPerRadian.js
var degreesPerRadian_default = "/**\n * A built-in GLSL floating-point constant for converting radians to degrees.\n *\n * @alias czm_degreesPerRadian\n * @glslConstant\n *\n * @see CesiumMath.DEGREES_PER_RADIAN\n *\n * @example\n * // GLSL declaration\n * const float czm_degreesPerRadian = ...;\n *\n * // Example\n * float deg = czm_degreesPerRadian * rad;\n */\nconst float czm_degreesPerRadian = 57.29577951308232;\n";
// Source/Shaders/Builtin/Constants/depthRange.js
var depthRange_default = "/**\n * A built-in GLSL vec2 constant for defining the depth range.\n * This is a workaround to a bug where IE11 does not implement gl_DepthRange.\n *\n * @alias czm_depthRange\n * @glslConstant\n *\n * @example\n * // GLSL declaration\n * float depthRangeNear = czm_depthRange.near;\n * float depthRangeFar = czm_depthRange.far;\n *\n */\nconst czm_depthRangeStruct czm_depthRange = czm_depthRangeStruct(0.0, 1.0);\n";
// Source/Shaders/Builtin/Constants/epsilon1.js
var epsilon1_default = "/**\n * 0.1\n *\n * @name czm_epsilon1\n * @glslConstant\n */\nconst float czm_epsilon1 = 0.1;\n";
// Source/Shaders/Builtin/Constants/epsilon2.js
var epsilon2_default = "/**\n * 0.01\n *\n * @name czm_epsilon2\n * @glslConstant\n */\nconst float czm_epsilon2 = 0.01;\n";
// Source/Shaders/Builtin/Constants/epsilon3.js
var epsilon3_default = "/**\n * 0.001\n *\n * @name czm_epsilon3\n * @glslConstant\n */\nconst float czm_epsilon3 = 0.001;\n";
// Source/Shaders/Builtin/Constants/epsilon4.js
var epsilon4_default = "/**\n * 0.0001\n *\n * @name czm_epsilon4\n * @glslConstant\n */\nconst float czm_epsilon4 = 0.0001;\n";
// Source/Shaders/Builtin/Constants/epsilon5.js
var epsilon5_default = "/**\n * 0.00001\n *\n * @name czm_epsilon5\n * @glslConstant\n */\nconst float czm_epsilon5 = 0.00001;\n";
// Source/Shaders/Builtin/Constants/epsilon6.js
var epsilon6_default = "/**\n * 0.000001\n *\n * @name czm_epsilon6\n * @glslConstant\n */\nconst float czm_epsilon6 = 0.000001;\n";
// Source/Shaders/Builtin/Constants/epsilon7.js
var epsilon7_default = "/**\n * 0.0000001\n *\n * @name czm_epsilon7\n * @glslConstant\n */\nconst float czm_epsilon7 = 0.0000001;\n";
// Source/Shaders/Builtin/Constants/infinity.js
var infinity_default = "/**\n * DOC_TBA\n *\n * @name czm_infinity\n * @glslConstant\n */\nconst float czm_infinity = 5906376272000.0; // Distance from the Sun to Pluto in meters. TODO: What is best given lowp, mediump, and highp?\n";
// Source/Shaders/Builtin/Constants/oneOverPi.js
var oneOverPi_default = "/**\n * A built-in GLSL floating-point constant for 1/pi.\n *\n * @alias czm_oneOverPi\n * @glslConstant\n *\n * @see CesiumMath.ONE_OVER_PI\n *\n * @example\n * // GLSL declaration\n * const float czm_oneOverPi = ...;\n *\n * // Example\n * float pi = 1.0 / czm_oneOverPi;\n */\nconst float czm_oneOverPi = 0.3183098861837907;\n";
// Source/Shaders/Builtin/Constants/oneOverTwoPi.js
var oneOverTwoPi_default = "/**\n * A built-in GLSL floating-point constant for 1/2pi.\n *\n * @alias czm_oneOverTwoPi\n * @glslConstant\n *\n * @see CesiumMath.ONE_OVER_TWO_PI\n *\n * @example\n * // GLSL declaration\n * const float czm_oneOverTwoPi = ...;\n *\n * // Example\n * float pi = 2.0 * czm_oneOverTwoPi;\n */\nconst float czm_oneOverTwoPi = 0.15915494309189535;\n";
// Source/Shaders/Builtin/Constants/passCesium3DTile.js
var passCesium3DTile_default = "/**\n * The automatic GLSL constant for {@link Pass#CESIUM_3D_TILE}\n *\n * @name czm_passCesium3DTile\n * @glslConstant\n *\n * @see czm_pass\n */\nconst float czm_passCesium3DTile = 4.0;\n";
// Source/Shaders/Builtin/Constants/passCesium3DTileClassification.js
var passCesium3DTileClassification_default = "/**\n * The automatic GLSL constant for {@link Pass#CESIUM_3D_TILE_CLASSIFICATION}\n *\n * @name czm_passCesium3DTileClassification\n * @glslConstant\n *\n * @see czm_pass\n */\nconst float czm_passCesium3DTileClassification = 5.0;\n";
// Source/Shaders/Builtin/Constants/passCesium3DTileClassificationIgnoreShow.js
var passCesium3DTileClassificationIgnoreShow_default = "/**\n * The automatic GLSL constant for {@link Pass#CESIUM_3D_TILE_CLASSIFICATION_IGNORE_SHOW}\n *\n * @name czm_passCesium3DTileClassificationIgnoreShow\n * @glslConstant\n *\n * @see czm_pass\n */\nconst float czm_passCesium3DTileClassificationIgnoreShow = 6.0;\n";
// Source/Shaders/Builtin/Constants/passClassification.js
var passClassification_default = "/**\n * The automatic GLSL constant for {@link Pass#CLASSIFICATION}\n *\n * @name czm_passClassification\n * @glslConstant\n *\n * @see czm_pass\n */\nconst float czm_passClassification = 7.0;\n";
// Source/Shaders/Builtin/Constants/passCompute.js
var passCompute_default = "/**\n * The automatic GLSL constant for {@link Pass#COMPUTE}\n *\n * @name czm_passCompute\n * @glslConstant\n *\n * @see czm_pass\n */\nconst float czm_passCompute = 1.0;\n";
// Source/Shaders/Builtin/Constants/passEnvironment.js
var passEnvironment_default = "/**\n * The automatic GLSL constant for {@link Pass#ENVIRONMENT}\n *\n * @name czm_passEnvironment\n * @glslConstant\n *\n * @see czm_pass\n */\nconst float czm_passEnvironment = 0.0;\n";
// Source/Shaders/Builtin/Constants/passGlobe.js
var passGlobe_default = "/**\n * The automatic GLSL constant for {@link Pass#GLOBE}\n *\n * @name czm_passGlobe\n * @glslConstant\n *\n * @see czm_pass\n */\nconst float czm_passGlobe = 2.0;\n";
// Source/Shaders/Builtin/Constants/passOpaque.js
var passOpaque_default = "/**\n * The automatic GLSL constant for {@link Pass#OPAQUE}\n *\n * @name czm_passOpaque\n * @glslConstant\n *\n * @see czm_pass\n */\nconst float czm_passOpaque = 7.0;\n";
// Source/Shaders/Builtin/Constants/passOverlay.js
var passOverlay_default = "/**\n * The automatic GLSL constant for {@link Pass#OVERLAY}\n *\n * @name czm_passOverlay\n * @glslConstant\n *\n * @see czm_pass\n */\nconst float czm_passOverlay = 9.0;\n";
// Source/Shaders/Builtin/Constants/passTerrainClassification.js
var passTerrainClassification_default = "/**\n * The automatic GLSL constant for {@link Pass#TERRAIN_CLASSIFICATION}\n *\n * @name czm_passTerrainClassification\n * @glslConstant\n *\n * @see czm_pass\n */\nconst float czm_passTerrainClassification = 3.0;\n";
// Source/Shaders/Builtin/Constants/passTranslucent.js
var passTranslucent_default = "/**\n * The automatic GLSL constant for {@link Pass#TRANSLUCENT}\n *\n * @name czm_passTranslucent\n * @glslConstant\n *\n * @see czm_pass\n */\nconst float czm_passTranslucent = 8.0;\n";
// Source/Shaders/Builtin/Constants/pi.js
var pi_default = "/**\n * A built-in GLSL floating-point constant for Math.PI.\n *\n * @alias czm_pi\n * @glslConstant\n *\n * @see CesiumMath.PI\n *\n * @example\n * // GLSL declaration\n * const float czm_pi = ...;\n *\n * // Example\n * float twoPi = 2.0 * czm_pi;\n */\nconst float czm_pi = 3.141592653589793;\n";
// Source/Shaders/Builtin/Constants/piOverFour.js
var piOverFour_default = "/**\n * A built-in GLSL floating-point constant for pi/4.\n *\n * @alias czm_piOverFour\n * @glslConstant\n *\n * @see CesiumMath.PI_OVER_FOUR\n *\n * @example\n * // GLSL declaration\n * const float czm_piOverFour = ...;\n *\n * // Example\n * float pi = 4.0 * czm_piOverFour;\n */\nconst float czm_piOverFour = 0.7853981633974483;\n";
// Source/Shaders/Builtin/Constants/piOverSix.js
var piOverSix_default = "/**\n * A built-in GLSL floating-point constant for pi/6.\n *\n * @alias czm_piOverSix\n * @glslConstant\n *\n * @see CesiumMath.PI_OVER_SIX\n *\n * @example\n * // GLSL declaration\n * const float czm_piOverSix = ...;\n *\n * // Example\n * float pi = 6.0 * czm_piOverSix;\n */\nconst float czm_piOverSix = 0.5235987755982988;\n";
// Source/Shaders/Builtin/Constants/piOverThree.js
var piOverThree_default = "/**\n * A built-in GLSL floating-point constant for pi/3.\n *\n * @alias czm_piOverThree\n * @glslConstant\n *\n * @see CesiumMath.PI_OVER_THREE\n *\n * @example\n * // GLSL declaration\n * const float czm_piOverThree = ...;\n *\n * // Example\n * float pi = 3.0 * czm_piOverThree;\n */\nconst float czm_piOverThree = 1.0471975511965976;\n";
// Source/Shaders/Builtin/Constants/piOverTwo.js
var piOverTwo_default = "/**\n * A built-in GLSL floating-point constant for pi/2.\n *\n * @alias czm_piOverTwo\n * @glslConstant\n *\n * @see CesiumMath.PI_OVER_TWO\n *\n * @example\n * // GLSL declaration\n * const float czm_piOverTwo = ...;\n *\n * // Example\n * float pi = 2.0 * czm_piOverTwo;\n */\nconst float czm_piOverTwo = 1.5707963267948966;\n";
// Source/Shaders/Builtin/Constants/radiansPerDegree.js
var radiansPerDegree_default = "/**\n * A built-in GLSL floating-point constant for converting degrees to radians.\n *\n * @alias czm_radiansPerDegree\n * @glslConstant\n *\n * @see CesiumMath.RADIANS_PER_DEGREE\n *\n * @example\n * // GLSL declaration\n * const float czm_radiansPerDegree = ...;\n *\n * // Example\n * float rad = czm_radiansPerDegree * deg;\n */\nconst float czm_radiansPerDegree = 0.017453292519943295;\n";
// Source/Shaders/Builtin/Constants/sceneMode2D.js
var sceneMode2D_default = "/**\n * The constant identifier for the 2D {@link SceneMode}\n *\n * @name czm_sceneMode2D\n * @glslConstant\n * @see czm_sceneMode\n * @see czm_sceneModeColumbusView\n * @see czm_sceneMode3D\n * @see czm_sceneModeMorphing\n */\nconst float czm_sceneMode2D = 2.0;\n";
// Source/Shaders/Builtin/Constants/sceneMode3D.js
var sceneMode3D_default = "/**\n * The constant identifier for the 3D {@link SceneMode}\n *\n * @name czm_sceneMode3D\n * @glslConstant\n * @see czm_sceneMode\n * @see czm_sceneMode2D\n * @see czm_sceneModeColumbusView\n * @see czm_sceneModeMorphing\n */\nconst float czm_sceneMode3D = 3.0;\n";
// Source/Shaders/Builtin/Constants/sceneModeColumbusView.js
var sceneModeColumbusView_default = "/**\n * The constant identifier for the Columbus View {@link SceneMode}\n *\n * @name czm_sceneModeColumbusView\n * @glslConstant\n * @see czm_sceneMode\n * @see czm_sceneMode2D\n * @see czm_sceneMode3D\n * @see czm_sceneModeMorphing\n */\nconst float czm_sceneModeColumbusView = 1.0;\n";
// Source/Shaders/Builtin/Constants/sceneModeMorphing.js
var sceneModeMorphing_default = "/**\n * The constant identifier for the Morphing {@link SceneMode}\n *\n * @name czm_sceneModeMorphing\n * @glslConstant\n * @see czm_sceneMode\n * @see czm_sceneMode2D\n * @see czm_sceneModeColumbusView\n * @see czm_sceneMode3D\n */\nconst float czm_sceneModeMorphing = 0.0;\n";
// Source/Shaders/Builtin/Constants/solarRadius.js
var solarRadius_default = "/**\n * A built-in GLSL floating-point constant for one solar radius.\n *\n * @alias czm_solarRadius\n * @glslConstant\n *\n * @see CesiumMath.SOLAR_RADIUS\n *\n * @example\n * // GLSL declaration\n * const float czm_solarRadius = ...;\n */\nconst float czm_solarRadius = 695500000.0;\n";
// Source/Shaders/Builtin/Constants/threePiOver2.js
var threePiOver2_default = "/**\n * A built-in GLSL floating-point constant for 3pi/2.\n *\n * @alias czm_threePiOver2\n * @glslConstant\n *\n * @see CesiumMath.THREE_PI_OVER_TWO\n *\n * @example\n * // GLSL declaration\n * const float czm_threePiOver2 = ...;\n *\n * // Example\n * float pi = (2.0 / 3.0) * czm_threePiOver2;\n */\nconst float czm_threePiOver2 = 4.71238898038469;\n";
// Source/Shaders/Builtin/Constants/twoPi.js
var twoPi_default = "/**\n * A built-in GLSL floating-point constant for 2pi.\n *\n * @alias czm_twoPi\n * @glslConstant\n *\n * @see CesiumMath.TWO_PI\n *\n * @example\n * // GLSL declaration\n * const float czm_twoPi = ...;\n *\n * // Example\n * float pi = czm_twoPi / 2.0;\n */\nconst float czm_twoPi = 6.283185307179586;\n";
// Source/Shaders/Builtin/Constants/webMercatorMaxLatitude.js
var webMercatorMaxLatitude_default = "/**\n * The maximum latitude, in radians, both North and South, supported by a Web Mercator\n * (EPSG:3857) projection. Technically, the Mercator projection is defined\n * for any latitude up to (but not including) 90 degrees, but it makes sense\n * to cut it off sooner because it grows exponentially with increasing latitude.\n * The logic behind this particular cutoff value, which is the one used by\n * Google Maps, Bing Maps, and Esri, is that it makes the projection\n * square. That is, the rectangle is equal in the X and Y directions.\n *\n * The constant value is computed as follows:\n * czm_pi * 0.5 - (2.0 * atan(exp(-czm_pi)))\n *\n * @name czm_webMercatorMaxLatitude\n * @glslConstant\n */\nconst float czm_webMercatorMaxLatitude = 1.4844222297453324;\n";
// Source/Shaders/Builtin/Structs/depthRangeStruct.js
var depthRangeStruct_default = "/**\n * @name czm_depthRangeStruct\n * @glslStruct\n */\nstruct czm_depthRangeStruct\n{\n float near;\n float far;\n};\n";
// Source/Shaders/Builtin/Structs/material.js
var material_default = "/**\n * Holds material information that can be used for lighting. Returned by all czm_getMaterial functions.\n *\n * @name czm_material\n * @glslStruct\n *\n * @property {vec3} diffuse Incoming light that scatters evenly in all directions.\n * @property {float} specular Intensity of incoming light reflecting in a single direction.\n * @property {float} shininess The sharpness of the specular reflection. Higher values create a smaller, more focused specular highlight.\n * @property {vec3} normal Surface's normal in eye coordinates. It is used for effects such as normal mapping. The default is the surface's unmodified normal.\n * @property {vec3} emission Light emitted by the material equally in all directions. The default is vec3(0.0), which emits no light.\n * @property {float} alpha Alpha of this material. 0.0 is completely transparent; 1.0 is completely opaque.\n */\nstruct czm_material\n{\n vec3 diffuse;\n float specular;\n float shininess;\n vec3 normal;\n vec3 emission;\n float alpha;\n};\n";
// Source/Shaders/Builtin/Structs/materialInput.js
var materialInput_default = "/**\n * Used as input to every material's czm_getMaterial function.\n *\n * @name czm_materialInput\n * @glslStruct\n *\n * @property {float} s 1D texture coordinates.\n * @property {vec2} st 2D texture coordinates.\n * @property {vec3} str 3D texture coordinates.\n * @property {vec3} normalEC Unperturbed surface normal in eye coordinates.\n * @property {mat3} tangentToEyeMatrix Matrix for converting a tangent space normal to eye space.\n * @property {vec3} positionToEyeEC Vector from the fragment to the eye in eye coordinates. The magnitude is the distance in meters from the fragment to the eye.\n * @property {float} height The height of the terrain in meters above or below the WGS84 ellipsoid. Only available for globe materials.\n * @property {float} slope The slope of the terrain in radians. 0 is flat; pi/2 is vertical. Only available for globe materials.\n * @property {float} aspect The aspect of the terrain in radians. 0 is East, pi/2 is North, pi is West, 3pi/2 is South. Only available for globe materials.\n */\nstruct czm_materialInput\n{\n float s;\n vec2 st;\n vec3 str;\n vec3 normalEC;\n mat3 tangentToEyeMatrix;\n vec3 positionToEyeEC;\n float height;\n float slope;\n float aspect;\n};\n";
// Source/Shaders/Builtin/Structs/modelMaterial.js
var modelMaterial_default = "/**\n * Struct for representing a material for a {@link ModelExperimental}. The model\n * rendering pipeline will pass this struct between material, custom shaders,\n * and lighting stages. This is not to be confused with {@link czm_material}\n * which is used by the older Fabric materials system, although they are similar.\n *
\n * All color values (diffuse, specular, emissive) are in linear color space.\n *
\n *\n * @name czm_modelMaterial\n * @glslStruct\n *\n * @property {vec3} diffuse Incoming light that scatters evenly in all directions.\n * @property {float} alpha Alpha of this material. 0.0 is completely transparent; 1.0 is completely opaque.\n * @property {vec3} specular Color of reflected light at normal incidence in PBR materials. This is sometimes referred to as f0 in the literature.\n * @property {float} roughness A number from 0.0 to 1.0 representing how rough the surface is. Values near 0.0 produce glossy surfaces, while values near 1.0 produce rough surfaces.\n * @property {vec3} normalEC Surface's normal in eye coordinates. It is used for effects such as normal mapping. The default is the surface's unmodified normal.\n * @property {float} occlusion Ambient occlusion recieved at this point on the material. 1.0 means fully lit, 0.0 means fully occluded.\n * @property {vec3} emissive Light emitted by the material equally in all directions. The default is vec3(0.0), which emits no light.\n */\nstruct czm_modelMaterial {\n vec3 diffuse;\n float alpha;\n vec3 specular;\n float roughness;\n vec3 normalEC;\n float occlusion;\n vec3 emissive;\n};\n";
// Source/Shaders/Builtin/Structs/modelVertexOutput.js
var modelVertexOutput_default = "/**\n * Struct for representing the output of a custom vertex shader.\n * \n * @name czm_modelVertexOutput\n * @glslStruct\n *\n * @see {@link CustomShader}\n * @see {@link ModelExperimental}\n *\n * @property {vec3} positionMC The position of the vertex in model coordinates\n * @property {float} pointSize A custom value for gl_PointSize. This is only used for point primitives. \n */\nstruct czm_modelVertexOutput {\n vec3 positionMC;\n float pointSize;\n};\n";
// Source/Shaders/Builtin/Structs/pbrParameters.js
var pbrParameters_default = "/**\n * Parameters for {@link czm_pbrLighting}\n *\n * @name czm_material\n * @glslStruct\n *\n * @property {vec3} diffuseColor the diffuse color of the material for the lambert term of the rendering equation\n * @property {float} roughness a value from 0.0 to 1.0 that indicates how rough the surface of the material is.\n * @property {vec3} f0 The reflectance of the material at normal incidence\n */\nstruct czm_pbrParameters\n{\n vec3 diffuseColor;\n float roughness;\n vec3 f0;\n};\n";
// Source/Shaders/Builtin/Structs/ray.js
var ray_default = "/**\n * DOC_TBA\n *\n * @name czm_ray\n * @glslStruct\n */\nstruct czm_ray\n{\n vec3 origin;\n vec3 direction;\n};\n";
// Source/Shaders/Builtin/Structs/raySegment.js
var raySegment_default = "/**\n * DOC_TBA\n *\n * @name czm_raySegment\n * @glslStruct\n */\nstruct czm_raySegment\n{\n float start;\n float stop;\n};\n\n/**\n * DOC_TBA\n *\n * @name czm_emptyRaySegment\n * @glslConstant \n */\nconst czm_raySegment czm_emptyRaySegment = czm_raySegment(-czm_infinity, -czm_infinity);\n\n/**\n * DOC_TBA\n *\n * @name czm_fullRaySegment\n * @glslConstant \n */\nconst czm_raySegment czm_fullRaySegment = czm_raySegment(0.0, czm_infinity);\n";
// Source/Shaders/Builtin/Structs/shadowParameters.js
var shadowParameters_default = "struct czm_shadowParameters\n{\n#ifdef USE_CUBE_MAP_SHADOW\n vec3 texCoords;\n#else\n vec2 texCoords;\n#endif\n\n float depthBias;\n float depth;\n float nDotL;\n vec2 texelStepSize;\n float normalShadingSmooth;\n float darkness;\n};\n";
// Source/Shaders/Builtin/Functions/acesTonemapping.js
var acesTonemapping_default = "// See:\n// https://knarkowicz.wordpress.com/2016/01/06/aces-filmic-tone-mapping-curve/\n\nvec3 czm_acesTonemapping(vec3 color) {\n float g = 0.985;\n float a = 0.065;\n float b = 0.0001;\n float c = 0.433;\n float d = 0.238;\n\n color = (color * (color + a) - b) / (color * (g * color + c) + d);\n\n color = clamp(color, 0.0, 1.0);\n\n return color;\n}\n";
// Source/Shaders/Builtin/Functions/alphaWeight.js
var alphaWeight_default = "/**\n * @private\n */\nfloat czm_alphaWeight(float a)\n{\n float z = (gl_FragCoord.z - czm_viewportTransformation[3][2]) / czm_viewportTransformation[2][2];\n\n // See Weighted Blended Order-Independent Transparency for examples of different weighting functions:\n // http://jcgt.org/published/0002/02/09/\n return pow(a + 0.01, 4.0) + max(1e-2, min(3.0 * 1e3, 0.003 / (1e-5 + pow(abs(z) / 200.0, 4.0))));\n}\n";
// Source/Shaders/Builtin/Functions/antialias.js
var antialias_default = "/**\n * Procedural anti-aliasing by blurring two colors that meet at a sharp edge.\n *\n * @name czm_antialias\n * @glslFunction\n *\n * @param {vec4} color1 The color on one side of the edge.\n * @param {vec4} color2 The color on the other side of the edge.\n * @param {vec4} currentcolor The current color, either color1 or color2.\n * @param {float} dist The distance to the edge in texture coordinates.\n * @param {float} [fuzzFactor=0.1] Controls the blurriness between the two colors.\n * @returns {vec4} The anti-aliased color.\n *\n * @example\n * // GLSL declarations\n * vec4 czm_antialias(vec4 color1, vec4 color2, vec4 currentColor, float dist, float fuzzFactor);\n * vec4 czm_antialias(vec4 color1, vec4 color2, vec4 currentColor, float dist);\n *\n * // get the color for a material that has a sharp edge at the line y = 0.5 in texture space\n * float dist = abs(textureCoordinates.t - 0.5);\n * vec4 currentColor = mix(bottomColor, topColor, step(0.5, textureCoordinates.t));\n * vec4 color = czm_antialias(bottomColor, topColor, currentColor, dist, 0.1);\n */\nvec4 czm_antialias(vec4 color1, vec4 color2, vec4 currentColor, float dist, float fuzzFactor)\n{\n float val1 = clamp(dist / fuzzFactor, 0.0, 1.0);\n float val2 = clamp((dist - 0.5) / fuzzFactor, 0.0, 1.0);\n val1 = val1 * (1.0 - val2);\n val1 = val1 * val1 * (3.0 - (2.0 * val1));\n val1 = pow(val1, 0.5); //makes the transition nicer\n \n vec4 midColor = (color1 + color2) * 0.5;\n return mix(midColor, currentColor, val1);\n}\n\nvec4 czm_antialias(vec4 color1, vec4 color2, vec4 currentColor, float dist)\n{\n return czm_antialias(color1, color2, currentColor, dist, 0.1);\n}\n";
// Source/Shaders/Builtin/Functions/approximateSphericalCoordinates.js
var approximateSphericalCoordinates_default = "/**\n * Approximately computes spherical coordinates given a normal.\n * Uses approximate inverse trigonometry for speed and consistency,\n * since inverse trigonometry can differ from vendor-to-vendor and when compared with the CPU.\n *\n * @name czm_approximateSphericalCoordinates\n * @glslFunction\n *\n * @param {vec3} normal arbitrary-length normal.\n *\n * @returns {vec2} Approximate latitude and longitude spherical coordinates.\n */\nvec2 czm_approximateSphericalCoordinates(vec3 normal) {\n // Project into plane with vertical for latitude\n float latitudeApproximation = czm_fastApproximateAtan(sqrt(normal.x * normal.x + normal.y * normal.y), normal.z);\n float longitudeApproximation = czm_fastApproximateAtan(normal.x, normal.y);\n return vec2(latitudeApproximation, longitudeApproximation);\n}\n";
// Source/Shaders/Builtin/Functions/backFacing.js
var backFacing_default = "/**\n * Determines if the fragment is back facing\n *\n * @name czm_backFacing\n * @glslFunction \n * \n * @returns {bool} true if the fragment is back facing; otherwise, false.\n */\nbool czm_backFacing()\n{\n // !gl_FrontFacing doesn't work as expected on Mac/Intel so use the more verbose form instead. See https://github.com/CesiumGS/cesium/pull/8494.\n return gl_FrontFacing == false;\n}\n";
// Source/Shaders/Builtin/Functions/branchFreeTernary.js
var branchFreeTernary_default = "/**\n * Branchless ternary operator to be used when it's inexpensive to explicitly\n * evaluate both possibilities for a float expression.\n *\n * @name czm_branchFreeTernary\n * @glslFunction\n *\n * @param {bool} comparison A comparison statement\n * @param {float} a Value to return if the comparison is true.\n * @param {float} b Value to return if the comparison is false.\n *\n * @returns {float} equivalent of comparison ? a : b\n */\nfloat czm_branchFreeTernary(bool comparison, float a, float b) {\n float useA = float(comparison);\n return a * useA + b * (1.0 - useA);\n}\n\n/**\n * Branchless ternary operator to be used when it's inexpensive to explicitly\n * evaluate both possibilities for a vec2 expression.\n *\n * @name czm_branchFreeTernary\n * @glslFunction\n *\n * @param {bool} comparison A comparison statement\n * @param {vec2} a Value to return if the comparison is true.\n * @param {vec2} b Value to return if the comparison is false.\n *\n * @returns {vec2} equivalent of comparison ? a : b\n */\nvec2 czm_branchFreeTernary(bool comparison, vec2 a, vec2 b) {\n float useA = float(comparison);\n return a * useA + b * (1.0 - useA);\n}\n\n/**\n * Branchless ternary operator to be used when it's inexpensive to explicitly\n * evaluate both possibilities for a vec3 expression.\n *\n * @name czm_branchFreeTernary\n * @glslFunction\n *\n * @param {bool} comparison A comparison statement\n * @param {vec3} a Value to return if the comparison is true.\n * @param {vec3} b Value to return if the comparison is false.\n *\n * @returns {vec3} equivalent of comparison ? a : b\n */\nvec3 czm_branchFreeTernary(bool comparison, vec3 a, vec3 b) {\n float useA = float(comparison);\n return a * useA + b * (1.0 - useA);\n}\n\n/**\n * Branchless ternary operator to be used when it's inexpensive to explicitly\n * evaluate both possibilities for a vec4 expression.\n *\n * @name czm_branchFreeTernary\n * @glslFunction\n *\n * @param {bool} comparison A comparison statement\n * @param {vec3} a Value to return if the comparison is true.\n * @param {vec3} b Value to return if the comparison is false.\n *\n * @returns {vec3} equivalent of comparison ? a : b\n */\nvec4 czm_branchFreeTernary(bool comparison, vec4 a, vec4 b) {\n float useA = float(comparison);\n return a * useA + b * (1.0 - useA);\n}\n";
// Source/Shaders/Builtin/Functions/cascadeColor.js
var cascadeColor_default = "\nvec4 czm_cascadeColor(vec4 weights)\n{\n return vec4(1.0, 0.0, 0.0, 1.0) * weights.x +\n vec4(0.0, 1.0, 0.0, 1.0) * weights.y +\n vec4(0.0, 0.0, 1.0, 1.0) * weights.z +\n vec4(1.0, 0.0, 1.0, 1.0) * weights.w;\n}\n";
// Source/Shaders/Builtin/Functions/cascadeDistance.js
var cascadeDistance_default = "\nuniform vec4 shadowMap_cascadeDistances;\n\nfloat czm_cascadeDistance(vec4 weights)\n{\n return dot(shadowMap_cascadeDistances, weights);\n}\n";
// Source/Shaders/Builtin/Functions/cascadeMatrix.js
var cascadeMatrix_default = "\nuniform mat4 shadowMap_cascadeMatrices[4];\n\nmat4 czm_cascadeMatrix(vec4 weights)\n{\n return shadowMap_cascadeMatrices[0] * weights.x +\n shadowMap_cascadeMatrices[1] * weights.y +\n shadowMap_cascadeMatrices[2] * weights.z +\n shadowMap_cascadeMatrices[3] * weights.w;\n}\n";
// Source/Shaders/Builtin/Functions/cascadeWeights.js
var cascadeWeights_default = "\nuniform vec4 shadowMap_cascadeSplits[2];\n\nvec4 czm_cascadeWeights(float depthEye)\n{\n // One component is set to 1.0 and all others set to 0.0.\n vec4 near = step(shadowMap_cascadeSplits[0], vec4(depthEye));\n vec4 far = step(depthEye, shadowMap_cascadeSplits[1]);\n return near * far;\n}\n";
// Source/Shaders/Builtin/Functions/columbusViewMorph.js
var columbusViewMorph_default = "/**\n * DOC_TBA\n *\n * @name czm_columbusViewMorph\n * @glslFunction\n */\nvec4 czm_columbusViewMorph(vec4 position2D, vec4 position3D, float time)\n{\n // Just linear for now.\n vec3 p = mix(position2D.xyz, position3D.xyz, time);\n return vec4(p, 1.0);\n}\n";
// Source/Shaders/Builtin/Functions/computePosition.js
var computePosition_default = "/**\n * Returns a position in model coordinates relative to eye taking into\n * account the current scene mode: 3D, 2D, or Columbus view.\n *
\n * This uses standard position attributes, position3DHigh, \n * position3DLow, position2DHigh, and position2DLow, \n * and should be used when writing a vertex shader for an {@link Appearance}.\n *
\n *\n * @name czm_computePosition\n * @glslFunction\n *\n * @returns {vec4} The position relative to eye.\n *\n * @example\n * vec4 p = czm_computePosition();\n * v_positionEC = (czm_modelViewRelativeToEye * p).xyz;\n * gl_Position = czm_modelViewProjectionRelativeToEye * p;\n *\n * @see czm_translateRelativeToEye\n */\nvec4 czm_computePosition();\n";
// Source/Shaders/Builtin/Functions/cosineAndSine.js
var cosineAndSine_default = "/**\n * @private\n */\nvec2 cordic(float angle)\n{\n// Scale the vector by the appropriate factor for the 24 iterations to follow.\n vec2 vector = vec2(6.0725293500888267e-1, 0.0);\n// Iteration 1\n float sense = (angle < 0.0) ? -1.0 : 1.0;\n // float factor = sense * 1.0; // 2^-0\n mat2 rotation = mat2(1.0, sense, -sense, 1.0);\n vector = rotation * vector;\n angle -= sense * 7.8539816339744828e-1; // atan(2^-0)\n// Iteration 2\n sense = (angle < 0.0) ? -1.0 : 1.0;\n float factor = sense * 5.0e-1; // 2^-1\n rotation[0][1] = factor;\n rotation[1][0] = -factor;\n vector = rotation * vector;\n angle -= sense * 4.6364760900080609e-1; // atan(2^-1)\n// Iteration 3\n sense = (angle < 0.0) ? -1.0 : 1.0;\n factor = sense * 2.5e-1; // 2^-2\n rotation[0][1] = factor;\n rotation[1][0] = -factor;\n vector = rotation * vector;\n angle -= sense * 2.4497866312686414e-1; // atan(2^-2)\n// Iteration 4\n sense = (angle < 0.0) ? -1.0 : 1.0;\n factor = sense * 1.25e-1; // 2^-3\n rotation[0][1] = factor;\n rotation[1][0] = -factor;\n vector = rotation * vector;\n angle -= sense * 1.2435499454676144e-1; // atan(2^-3)\n// Iteration 5\n sense = (angle < 0.0) ? -1.0 : 1.0;\n factor = sense * 6.25e-2; // 2^-4\n rotation[0][1] = factor;\n rotation[1][0] = -factor;\n vector = rotation * vector;\n angle -= sense * 6.2418809995957350e-2; // atan(2^-4)\n// Iteration 6\n sense = (angle < 0.0) ? -1.0 : 1.0;\n factor = sense * 3.125e-2; // 2^-5\n rotation[0][1] = factor;\n rotation[1][0] = -factor;\n vector = rotation * vector;\n angle -= sense * 3.1239833430268277e-2; // atan(2^-5)\n// Iteration 7\n sense = (angle < 0.0) ? -1.0 : 1.0;\n factor = sense * 1.5625e-2; // 2^-6\n rotation[0][1] = factor;\n rotation[1][0] = -factor;\n vector = rotation * vector;\n angle -= sense * 1.5623728620476831e-2; // atan(2^-6)\n// Iteration 8\n sense = (angle < 0.0) ? -1.0 : 1.0;\n factor = sense * 7.8125e-3; // 2^-7\n rotation[0][1] = factor;\n rotation[1][0] = -factor;\n vector = rotation * vector;\n angle -= sense * 7.8123410601011111e-3; // atan(2^-7)\n// Iteration 9\n sense = (angle < 0.0) ? -1.0 : 1.0;\n factor = sense * 3.90625e-3; // 2^-8\n rotation[0][1] = factor;\n rotation[1][0] = -factor;\n vector = rotation * vector;\n angle -= sense * 3.9062301319669718e-3; // atan(2^-8)\n// Iteration 10\n sense = (angle < 0.0) ? -1.0 : 1.0;\n factor = sense * 1.953125e-3; // 2^-9\n rotation[0][1] = factor;\n rotation[1][0] = -factor;\n vector = rotation * vector;\n angle -= sense * 1.9531225164788188e-3; // atan(2^-9)\n// Iteration 11\n sense = (angle < 0.0) ? -1.0 : 1.0;\n factor = sense * 9.765625e-4; // 2^-10\n rotation[0][1] = factor;\n rotation[1][0] = -factor;\n vector = rotation * vector;\n angle -= sense * 9.7656218955931946e-4; // atan(2^-10)\n// Iteration 12\n sense = (angle < 0.0) ? -1.0 : 1.0;\n factor = sense * 4.8828125e-4; // 2^-11\n rotation[0][1] = factor;\n rotation[1][0] = -factor;\n vector = rotation * vector;\n angle -= sense * 4.8828121119489829e-4; // atan(2^-11)\n// Iteration 13\n sense = (angle < 0.0) ? -1.0 : 1.0;\n factor = sense * 2.44140625e-4; // 2^-12\n rotation[0][1] = factor;\n rotation[1][0] = -factor;\n vector = rotation * vector;\n angle -= sense * 2.4414062014936177e-4; // atan(2^-12)\n// Iteration 14\n sense = (angle < 0.0) ? -1.0 : 1.0;\n factor = sense * 1.220703125e-4; // 2^-13\n rotation[0][1] = factor;\n rotation[1][0] = -factor;\n vector = rotation * vector;\n angle -= sense * 1.2207031189367021e-4; // atan(2^-13)\n// Iteration 15\n sense = (angle < 0.0) ? -1.0 : 1.0;\n factor = sense * 6.103515625e-5; // 2^-14\n rotation[0][1] = factor;\n rotation[1][0] = -factor;\n vector = rotation * vector;\n angle -= sense * 6.1035156174208773e-5; // atan(2^-14)\n// Iteration 16\n sense = (angle < 0.0) ? -1.0 : 1.0;\n factor = sense * 3.0517578125e-5; // 2^-15\n rotation[0][1] = factor;\n rotation[1][0] = -factor;\n vector = rotation * vector;\n angle -= sense * 3.0517578115526096e-5; // atan(2^-15)\n// Iteration 17\n sense = (angle < 0.0) ? -1.0 : 1.0;\n factor = sense * 1.52587890625e-5; // 2^-16\n rotation[0][1] = factor;\n rotation[1][0] = -factor;\n vector = rotation * vector;\n angle -= sense * 1.5258789061315762e-5; // atan(2^-16)\n// Iteration 18\n sense = (angle < 0.0) ? -1.0 : 1.0;\n factor = sense * 7.62939453125e-6; // 2^-17\n rotation[0][1] = factor;\n rotation[1][0] = -factor;\n vector = rotation * vector;\n angle -= sense * 7.6293945311019700e-6; // atan(2^-17)\n// Iteration 19\n sense = (angle < 0.0) ? -1.0 : 1.0;\n factor = sense * 3.814697265625e-6; // 2^-18\n rotation[0][1] = factor;\n rotation[1][0] = -factor;\n vector = rotation * vector;\n angle -= sense * 3.8146972656064961e-6; // atan(2^-18)\n// Iteration 20\n sense = (angle < 0.0) ? -1.0 : 1.0;\n factor = sense * 1.9073486328125e-6; // 2^-19\n rotation[0][1] = factor;\n rotation[1][0] = -factor;\n vector = rotation * vector;\n angle -= sense * 1.9073486328101870e-6; // atan(2^-19)\n// Iteration 21\n sense = (angle < 0.0) ? -1.0 : 1.0;\n factor = sense * 9.5367431640625e-7; // 2^-20\n rotation[0][1] = factor;\n rotation[1][0] = -factor;\n vector = rotation * vector;\n angle -= sense * 9.5367431640596084e-7; // atan(2^-20)\n// Iteration 22\n sense = (angle < 0.0) ? -1.0 : 1.0;\n factor = sense * 4.76837158203125e-7; // 2^-21\n rotation[0][1] = factor;\n rotation[1][0] = -factor;\n vector = rotation * vector;\n angle -= sense * 4.7683715820308884e-7; // atan(2^-21)\n// Iteration 23\n sense = (angle < 0.0) ? -1.0 : 1.0;\n factor = sense * 2.384185791015625e-7; // 2^-22\n rotation[0][1] = factor;\n rotation[1][0] = -factor;\n vector = rotation * vector;\n angle -= sense * 2.3841857910155797e-7; // atan(2^-22)\n// Iteration 24\n sense = (angle < 0.0) ? -1.0 : 1.0;\n factor = sense * 1.1920928955078125e-7; // 2^-23\n rotation[0][1] = factor;\n rotation[1][0] = -factor;\n vector = rotation * vector;\n// angle -= sense * 1.1920928955078068e-7; // atan(2^-23)\n\n return vector;\n}\n\n/**\n * Computes the cosine and sine of the provided angle using the CORDIC algorithm.\n *\n * @name czm_cosineAndSine\n * @glslFunction\n *\n * @param {float} angle The angle in radians.\n *\n * @returns {vec2} The resulting cosine of the angle (as the x coordinate) and sine of the angle (as the y coordinate).\n *\n * @example\n * vec2 v = czm_cosineAndSine(czm_piOverSix);\n * float cosine = v.x;\n * float sine = v.y;\n */\nvec2 czm_cosineAndSine(float angle)\n{\n if (angle < -czm_piOverTwo || angle > czm_piOverTwo)\n {\n if (angle < 0.0)\n {\n return -cordic(angle + czm_pi);\n }\n else\n {\n return -cordic(angle - czm_pi);\n }\n }\n else\n {\n return cordic(angle);\n }\n}\n";
// Source/Shaders/Builtin/Functions/decompressTextureCoordinates.js
var decompressTextureCoordinates_default = "/**\n * Decompresses texture coordinates that were packed into a single float.\n *\n * @name czm_decompressTextureCoordinates\n * @glslFunction\n *\n * @param {float} encoded The compressed texture coordinates.\n * @returns {vec2} The decompressed texture coordinates.\n */\n vec2 czm_decompressTextureCoordinates(float encoded)\n {\n float temp = encoded / 4096.0;\n float xZeroTo4095 = floor(temp);\n float stx = xZeroTo4095 / 4095.0;\n float sty = (encoded - xZeroTo4095 * 4096.0) / 4095.0;\n return vec2(stx, sty);\n }\n";
// Source/Shaders/Builtin/Functions/defaultPbrMaterial.js
var defaultPbrMaterial_default = "/**\n * Get default parameters for physically based rendering. These defaults\n * describe a rough dielectric (non-metal) surface (e.g. rough plastic).\n *\n * @return {czm_pbrParameters} Default parameters for {@link czm_pbrLighting}\n */\nczm_pbrParameters czm_defaultPbrMaterial()\n{\n czm_pbrParameters results;\n results.diffuseColor = vec3(1.0);\n results.roughness = 1.0;\n\n const vec3 REFLECTANCE_DIELECTRIC = vec3(0.04);\n results.f0 = REFLECTANCE_DIELECTRIC;\n return results;\n}\n";
// Source/Shaders/Builtin/Functions/depthClamp.js
var depthClamp_default = "// emulated noperspective\n#if defined(GL_EXT_frag_depth) && !defined(LOG_DEPTH)\nvarying float v_WindowZ;\n#endif\n\n/**\n * Emulates GL_DEPTH_CLAMP, which is not available in WebGL 1 or 2.\n * GL_DEPTH_CLAMP clamps geometry that is outside the near and far planes, \n * capping the shadow volume. More information here: \n * https://www.khronos.org/registry/OpenGL/extensions/ARB/ARB_depth_clamp.txt.\n *\n * When GL_EXT_frag_depth is available we emulate GL_DEPTH_CLAMP by ensuring \n * no geometry gets clipped by setting the clip space z value to 0.0 and then\n * sending the unaltered screen space z value (using emulated noperspective\n * interpolation) to the frag shader where it is clamped to [0,1] and then\n * written with gl_FragDepth (see czm_writeDepthClamp). This technique is based on:\n * https://stackoverflow.com/questions/5960757/how-to-emulate-gl-depth-clamp-nv.\n *\n * When GL_EXT_frag_depth is not available, which is the case on some mobile \n * devices, we must attempt to fix this only in the vertex shader. \n * The approach is to clamp the z value to the far plane, which closes the \n * shadow volume but also distorts the geometry, so there can still be artifacts\n * on frustum seams.\n *\n * @name czm_depthClamp\n * @glslFunction\n *\n * @param {vec4} coords The vertex in clip coordinates.\n * @returns {vec4} The modified vertex.\n *\n * @example\n * gl_Position = czm_depthClamp(czm_modelViewProjection * vec4(position, 1.0));\n *\n * @see czm_writeDepthClamp\n */\nvec4 czm_depthClamp(vec4 coords)\n{\n#ifndef LOG_DEPTH\n#ifdef GL_EXT_frag_depth\n v_WindowZ = (0.5 * (coords.z / coords.w) + 0.5) * coords.w;\n coords.z = 0.0;\n#else\n coords.z = min(coords.z, coords.w);\n#endif\n#endif\n return coords;\n}\n";
// Source/Shaders/Builtin/Functions/eastNorthUpToEyeCoordinates.js
var eastNorthUpToEyeCoordinates_default = "/**\n * Computes a 3x3 rotation matrix that transforms vectors from an ellipsoid's east-north-up coordinate system \n * to eye coordinates. In east-north-up coordinates, x points east, y points north, and z points along the \n * surface normal. East-north-up can be used as an ellipsoid's tangent space for operations such as bump mapping.\n *
\n * The ellipsoid is assumed to be centered at the model coordinate's origin.\n *\n * @name czm_eastNorthUpToEyeCoordinates\n * @glslFunction\n *\n * @param {vec3} positionMC The position on the ellipsoid in model coordinates.\n * @param {vec3} normalEC The normalized ellipsoid surface normal, at positionMC, in eye coordinates.\n *\n * @returns {mat3} A 3x3 rotation matrix that transforms vectors from the east-north-up coordinate system to eye coordinates.\n *\n * @example\n * // Transform a vector defined in the east-north-up coordinate \n * // system, (0, 0, 1) which is the surface normal, to eye \n * // coordinates.\n * mat3 m = czm_eastNorthUpToEyeCoordinates(positionMC, normalEC);\n * vec3 normalEC = m * vec3(0.0, 0.0, 1.0);\n */\nmat3 czm_eastNorthUpToEyeCoordinates(vec3 positionMC, vec3 normalEC)\n{\n vec3 tangentMC = normalize(vec3(-positionMC.y, positionMC.x, 0.0)); // normalized surface tangent in model coordinates\n vec3 tangentEC = normalize(czm_normal3D * tangentMC); // normalized surface tangent in eye coordiantes\n vec3 bitangentEC = normalize(cross(normalEC, tangentEC)); // normalized surface bitangent in eye coordinates\n\n return mat3(\n tangentEC.x, tangentEC.y, tangentEC.z,\n bitangentEC.x, bitangentEC.y, bitangentEC.z,\n normalEC.x, normalEC.y, normalEC.z);\n}\n";
// Source/Shaders/Builtin/Functions/ellipsoidContainsPoint.js
var ellipsoidContainsPoint_default = "/**\n * DOC_TBA\n *\n * @name czm_ellipsoidContainsPoint\n * @glslFunction\n *\n */\nbool czm_ellipsoidContainsPoint(vec3 ellipsoid_inverseRadii, vec3 point)\n{\n vec3 scaled = ellipsoid_inverseRadii * (czm_inverseModelView * vec4(point, 1.0)).xyz;\n return (dot(scaled, scaled) <= 1.0);\n}\n";
// Source/Shaders/Builtin/Functions/ellipsoidWgs84TextureCoordinates.js
var ellipsoidWgs84TextureCoordinates_default = "/**\n * DOC_TBA\n *\n * @name czm_ellipsoidWgs84TextureCoordinates\n * @glslFunction\n */\nvec2 czm_ellipsoidWgs84TextureCoordinates(vec3 normal)\n{\n return vec2(atan(normal.y, normal.x) * czm_oneOverTwoPi + 0.5, asin(normal.z) * czm_oneOverPi + 0.5);\n}\n";
// Source/Shaders/Builtin/Functions/equalsEpsilon.js
var equalsEpsilon_default = "/**\n * Compares left and right componentwise. Returns true\n * if they are within epsilon and false otherwise. The inputs\n * left and right can be floats, vec2s,\n * vec3s, or vec4s.\n *\n * @name czm_equalsEpsilon\n * @glslFunction\n *\n * @param {} left The first vector.\n * @param {} right The second vector.\n * @param {float} epsilon The epsilon to use for equality testing.\n * @returns {bool} true if the components are within epsilon and false otherwise.\n *\n * @example\n * // GLSL declarations\n * bool czm_equalsEpsilon(float left, float right, float epsilon);\n * bool czm_equalsEpsilon(vec2 left, vec2 right, float epsilon);\n * bool czm_equalsEpsilon(vec3 left, vec3 right, float epsilon);\n * bool czm_equalsEpsilon(vec4 left, vec4 right, float epsilon);\n */\nbool czm_equalsEpsilon(vec4 left, vec4 right, float epsilon) {\n return all(lessThanEqual(abs(left - right), vec4(epsilon)));\n}\n\nbool czm_equalsEpsilon(vec3 left, vec3 right, float epsilon) {\n return all(lessThanEqual(abs(left - right), vec3(epsilon)));\n}\n\nbool czm_equalsEpsilon(vec2 left, vec2 right, float epsilon) {\n return all(lessThanEqual(abs(left - right), vec2(epsilon)));\n}\n\nbool czm_equalsEpsilon(float left, float right, float epsilon) {\n return (abs(left - right) <= epsilon);\n}\n";
// Source/Shaders/Builtin/Functions/eyeOffset.js
var eyeOffset_default = "/**\n * DOC_TBA\n *\n * @name czm_eyeOffset\n * @glslFunction\n *\n * @param {vec4} positionEC DOC_TBA.\n * @param {vec3} eyeOffset DOC_TBA.\n *\n * @returns {vec4} DOC_TBA.\n */\nvec4 czm_eyeOffset(vec4 positionEC, vec3 eyeOffset)\n{\n // This equation is approximate in x and y.\n vec4 p = positionEC;\n vec4 zEyeOffset = normalize(p) * eyeOffset.z;\n p.xy += eyeOffset.xy + zEyeOffset.xy;\n p.z += zEyeOffset.z;\n return p;\n}\n";
// Source/Shaders/Builtin/Functions/eyeToWindowCoordinates.js
var eyeToWindowCoordinates_default = "/**\n * Transforms a position from eye to window coordinates. The transformation\n * from eye to clip coordinates is done using {@link czm_projection}.\n * The transform from normalized device coordinates to window coordinates is\n * done using {@link czm_viewportTransformation}, which assumes a depth range\n * of near = 0 and far = 1.\n *
\n * This transform is useful when there is a need to manipulate window coordinates\n * in a vertex shader as done by {@link BillboardCollection}.\n *\n * @name czm_eyeToWindowCoordinates\n * @glslFunction\n *\n * @param {vec4} position The position in eye coordinates to transform.\n *\n * @returns {vec4} The transformed position in window coordinates.\n *\n * @see czm_modelToWindowCoordinates\n * @see czm_projection\n * @see czm_viewportTransformation\n * @see BillboardCollection\n *\n * @example\n * vec4 positionWC = czm_eyeToWindowCoordinates(positionEC);\n */\nvec4 czm_eyeToWindowCoordinates(vec4 positionEC)\n{\n vec4 q = czm_projection * positionEC; // clip coordinates\n q.xyz /= q.w; // normalized device coordinates\n q.xyz = (czm_viewportTransformation * vec4(q.xyz, 1.0)).xyz; // window coordinates\n return q;\n}\n";
// Source/Shaders/Builtin/Functions/fastApproximateAtan.js
var fastApproximateAtan_default = `/**
* Approxiamtes atan over the range [0, 1]. Safe to flip output for negative input.
*
* Based on Michal Drobot's approximation from ShaderFastLibs, which in turn is based on
* "Efficient approximations for the arctangent function," Rajan, S. Sichun Wang Inkol, R. Joyal, A., May 2006.
* Adapted from ShaderFastLibs under MIT License.
*
* Chosen for the following characteristics over range [0, 1]:
* - basically no error at 0 and 1, important for getting around range limit (naive atan2 via atan requires infinite range atan)
* - no visible artifacts from first-derivative discontinuities, unlike latitude via range-reduced sqrt asin approximations (at equator)
*
* The original code is x * (-0.1784 * abs(x) - 0.0663 * x * x + 1.0301);
* Removed the abs() in here because it isn't needed, the input range is guaranteed as [0, 1] by how we're approximating atan2.
*
* @name czm_fastApproximateAtan
* @glslFunction
*
* @param {float} x Value between 0 and 1 inclusive.
*
* @returns {float} Approximation of atan(x)
*/
float czm_fastApproximateAtan(float x) {
return x * (-0.1784 * x - 0.0663 * x * x + 1.0301);
}
/**
* Approximation of atan2.
*
* Range reduction math based on nvidia's cg reference implementation for atan2: http://developer.download.nvidia.com/cg/atan2.html
* However, we replaced their atan curve with Michael Drobot's (see above).
*
* @name czm_fastApproximateAtan
* @glslFunction
*
* @param {float} x Value between -1 and 1 inclusive.
* @param {float} y Value between -1 and 1 inclusive.
*
* @returns {float} Approximation of atan2(x, y)
*/
float czm_fastApproximateAtan(float x, float y) {
// atan approximations are usually only reliable over [-1, 1], or, in our case, [0, 1] due to modifications.
// So range-reduce using abs and by flipping whether x or y is on top.
float t = abs(x); // t used as swap and atan result.
float opposite = abs(y);
float adjacent = max(t, opposite);
opposite = min(t, opposite);
t = czm_fastApproximateAtan(opposite / adjacent);
// Undo range reduction
t = czm_branchFreeTernary(abs(y) > abs(x), czm_piOverTwo - t, t);
t = czm_branchFreeTernary(x < 0.0, czm_pi - t, t);
t = czm_branchFreeTernary(y < 0.0, -t, t);
return t;
}
`;
// Source/Shaders/Builtin/Functions/fog.js
var fog_default = "/**\n * Gets the color with fog at a distance from the camera.\n *\n * @name czm_fog\n * @glslFunction\n *\n * @param {float} distanceToCamera The distance to the camera in meters.\n * @param {vec3} color The original color.\n * @param {vec3} fogColor The color of the fog.\n *\n * @returns {vec3} The color adjusted for fog at the distance from the camera.\n */\nvec3 czm_fog(float distanceToCamera, vec3 color, vec3 fogColor)\n{\n float scalar = distanceToCamera * czm_fogDensity;\n float fog = 1.0 - exp(-(scalar * scalar));\n return mix(color, fogColor, fog);\n}\n\n/**\n * Gets the color with fog at a distance from the camera.\n *\n * @name czm_fog\n * @glslFunction\n *\n * @param {float} distanceToCamera The distance to the camera in meters.\n * @param {vec3} color The original color.\n * @param {vec3} fogColor The color of the fog.\n * @param {float} fogModifierConstant A constant to modify the appearance of fog.\n *\n * @returns {vec3} The color adjusted for fog at the distance from the camera.\n */\nvec3 czm_fog(float distanceToCamera, vec3 color, vec3 fogColor, float fogModifierConstant)\n{\n float scalar = distanceToCamera * czm_fogDensity;\n float fog = 1.0 - exp(-((fogModifierConstant * scalar + fogModifierConstant) * (scalar * (1.0 + fogModifierConstant))));\n return mix(color, fogColor, fog);\n}\n";
// Source/Shaders/Builtin/Functions/gammaCorrect.js
var gammaCorrect_default = "/**\n * Converts a color from RGB space to linear space.\n *\n * @name czm_gammaCorrect\n * @glslFunction\n *\n * @param {vec3} color The color in RGB space.\n * @returns {vec3} The color in linear space.\n */\nvec3 czm_gammaCorrect(vec3 color) {\n#ifdef HDR\n color = pow(color, vec3(czm_gamma));\n#endif\n return color;\n}\n\nvec4 czm_gammaCorrect(vec4 color) {\n#ifdef HDR\n color.rgb = pow(color.rgb, vec3(czm_gamma));\n#endif\n return color;\n}\n";
// Source/Shaders/Builtin/Functions/geodeticSurfaceNormal.js
var geodeticSurfaceNormal_default = "/**\n * DOC_TBA\n *\n * @name czm_geodeticSurfaceNormal\n * @glslFunction\n *\n * @param {vec3} positionOnEllipsoid DOC_TBA\n * @param {vec3} ellipsoidCenter DOC_TBA\n * @param {vec3} oneOverEllipsoidRadiiSquared DOC_TBA\n * \n * @returns {vec3} DOC_TBA.\n */\nvec3 czm_geodeticSurfaceNormal(vec3 positionOnEllipsoid, vec3 ellipsoidCenter, vec3 oneOverEllipsoidRadiiSquared)\n{\n return normalize((positionOnEllipsoid - ellipsoidCenter) * oneOverEllipsoidRadiiSquared);\n}\n";
// Source/Shaders/Builtin/Functions/getDefaultMaterial.js
var getDefaultMaterial_default = "/**\n * An czm_material with default values. Every material's czm_getMaterial\n * should use this default material as a base for the material it returns.\n * The default normal value is given by materialInput.normalEC.\n *\n * @name czm_getDefaultMaterial\n * @glslFunction\n *\n * @param {czm_materialInput} input The input used to construct the default material.\n *\n * @returns {czm_material} The default material.\n *\n * @see czm_materialInput\n * @see czm_material\n * @see czm_getMaterial\n */\nczm_material czm_getDefaultMaterial(czm_materialInput materialInput)\n{\n czm_material material;\n material.diffuse = vec3(0.0);\n material.specular = 0.0;\n material.shininess = 1.0;\n material.normal = materialInput.normalEC;\n material.emission = vec3(0.0);\n material.alpha = 1.0;\n return material;\n}\n";
// Source/Shaders/Builtin/Functions/getLambertDiffuse.js
var getLambertDiffuse_default = "/**\n * Calculates the intensity of diffusely reflected light.\n *\n * @name czm_getLambertDiffuse\n * @glslFunction\n *\n * @param {vec3} lightDirectionEC Unit vector pointing to the light source in eye coordinates.\n * @param {vec3} normalEC The surface normal in eye coordinates.\n *\n * @returns {float} The intensity of the diffuse reflection.\n *\n * @see czm_phong\n *\n * @example\n * float diffuseIntensity = czm_getLambertDiffuse(lightDirectionEC, normalEC);\n * float specularIntensity = czm_getSpecular(lightDirectionEC, toEyeEC, normalEC, 200);\n * vec3 color = (diffuseColor * diffuseIntensity) + (specularColor * specularIntensity);\n */\nfloat czm_getLambertDiffuse(vec3 lightDirectionEC, vec3 normalEC)\n{\n return max(dot(lightDirectionEC, normalEC), 0.0);\n}\n";
// Source/Shaders/Builtin/Functions/getSpecular.js
var getSpecular_default = "/**\n * Calculates the specular intensity of reflected light.\n *\n * @name czm_getSpecular\n * @glslFunction\n *\n * @param {vec3} lightDirectionEC Unit vector pointing to the light source in eye coordinates.\n * @param {vec3} toEyeEC Unit vector pointing to the eye position in eye coordinates.\n * @param {vec3} normalEC The surface normal in eye coordinates.\n * @param {float} shininess The sharpness of the specular reflection. Higher values create a smaller, more focused specular highlight.\n *\n * @returns {float} The intensity of the specular highlight.\n *\n * @see czm_phong\n *\n * @example\n * float diffuseIntensity = czm_getLambertDiffuse(lightDirectionEC, normalEC);\n * float specularIntensity = czm_getSpecular(lightDirectionEC, toEyeEC, normalEC, 200);\n * vec3 color = (diffuseColor * diffuseIntensity) + (specularColor * specularIntensity);\n */\nfloat czm_getSpecular(vec3 lightDirectionEC, vec3 toEyeEC, vec3 normalEC, float shininess)\n{\n vec3 toReflectedLight = reflect(-lightDirectionEC, normalEC);\n float specular = max(dot(toReflectedLight, toEyeEC), 0.0);\n\n // pow has undefined behavior if both parameters <= 0.\n // Prevent this by making sure shininess is at least czm_epsilon2.\n return pow(specular, max(shininess, czm_epsilon2));\n}\n";
// Source/Shaders/Builtin/Functions/getWaterNoise.js
var getWaterNoise_default = "/**\n * @private\n */\nvec4 czm_getWaterNoise(sampler2D normalMap, vec2 uv, float time, float angleInRadians)\n{\n float cosAngle = cos(angleInRadians);\n float sinAngle = sin(angleInRadians);\n\n // time dependent sampling directions\n vec2 s0 = vec2(1.0/17.0, 0.0);\n vec2 s1 = vec2(-1.0/29.0, 0.0);\n vec2 s2 = vec2(1.0/101.0, 1.0/59.0);\n vec2 s3 = vec2(-1.0/109.0, -1.0/57.0);\n\n // rotate sampling direction by specified angle\n s0 = vec2((cosAngle * s0.x) - (sinAngle * s0.y), (sinAngle * s0.x) + (cosAngle * s0.y));\n s1 = vec2((cosAngle * s1.x) - (sinAngle * s1.y), (sinAngle * s1.x) + (cosAngle * s1.y));\n s2 = vec2((cosAngle * s2.x) - (sinAngle * s2.y), (sinAngle * s2.x) + (cosAngle * s2.y));\n s3 = vec2((cosAngle * s3.x) - (sinAngle * s3.y), (sinAngle * s3.x) + (cosAngle * s3.y));\n\n vec2 uv0 = (uv/103.0) + (time * s0);\n vec2 uv1 = uv/107.0 + (time * s1) + vec2(0.23);\n vec2 uv2 = uv/vec2(897.0, 983.0) + (time * s2) + vec2(0.51);\n vec2 uv3 = uv/vec2(991.0, 877.0) + (time * s3) + vec2(0.71);\n\n uv0 = fract(uv0);\n uv1 = fract(uv1);\n uv2 = fract(uv2);\n uv3 = fract(uv3);\n vec4 noise = (texture2D(normalMap, uv0)) +\n (texture2D(normalMap, uv1)) +\n (texture2D(normalMap, uv2)) +\n (texture2D(normalMap, uv3));\n\n // average and scale to between -1 and 1\n return ((noise / 4.0) - 0.5) * 2.0;\n}\n";
// Source/Shaders/Builtin/Functions/HSBToRGB.js
var HSBToRGB_default = "/**\n * Converts an HSB color (hue, saturation, brightness) to RGB\n * HSB <-> RGB conversion with minimal branching: {@link http://lolengine.net/blog/2013/07/27/rgb-to-hsv-in-glsl}\n *\n * @name czm_HSBToRGB\n * @glslFunction\n * \n * @param {vec3} hsb The color in HSB.\n *\n * @returns {vec3} The color in RGB.\n *\n * @example\n * vec3 hsb = czm_RGBToHSB(rgb);\n * hsb.z *= 0.1;\n * rgb = czm_HSBToRGB(hsb);\n */\n\nconst vec4 K_HSB2RGB = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);\n\nvec3 czm_HSBToRGB(vec3 hsb)\n{\n vec3 p = abs(fract(hsb.xxx + K_HSB2RGB.xyz) * 6.0 - K_HSB2RGB.www);\n return hsb.z * mix(K_HSB2RGB.xxx, clamp(p - K_HSB2RGB.xxx, 0.0, 1.0), hsb.y);\n}\n";
// Source/Shaders/Builtin/Functions/HSLToRGB.js
var HSLToRGB_default = "/**\n * Converts an HSL color (hue, saturation, lightness) to RGB\n * HSL <-> RGB conversion: {@link http://www.chilliant.com/rgb2hsv.html}\n *\n * @name czm_HSLToRGB\n * @glslFunction\n * \n * @param {vec3} rgb The color in HSL.\n *\n * @returns {vec3} The color in RGB.\n *\n * @example\n * vec3 hsl = czm_RGBToHSL(rgb);\n * hsl.z *= 0.1;\n * rgb = czm_HSLToRGB(hsl);\n */\n\nvec3 hueToRGB(float hue)\n{\n float r = abs(hue * 6.0 - 3.0) - 1.0;\n float g = 2.0 - abs(hue * 6.0 - 2.0);\n float b = 2.0 - abs(hue * 6.0 - 4.0);\n return clamp(vec3(r, g, b), 0.0, 1.0);\n}\n\nvec3 czm_HSLToRGB(vec3 hsl)\n{\n vec3 rgb = hueToRGB(hsl.x);\n float c = (1.0 - abs(2.0 * hsl.z - 1.0)) * hsl.y;\n return (rgb - 0.5) * c + hsl.z;\n}\n";
// Source/Shaders/Builtin/Functions/hue.js
var hue_default = "/**\n * Adjusts the hue of a color.\n * \n * @name czm_hue\n * @glslFunction\n * \n * @param {vec3} rgb The color.\n * @param {float} adjustment The amount to adjust the hue of the color in radians.\n *\n * @returns {float} The color with the hue adjusted.\n *\n * @example\n * vec3 adjustHue = czm_hue(color, czm_pi); // The same as czm_hue(color, -czm_pi)\n */\nvec3 czm_hue(vec3 rgb, float adjustment)\n{\n const mat3 toYIQ = mat3(0.299, 0.587, 0.114,\n 0.595716, -0.274453, -0.321263,\n 0.211456, -0.522591, 0.311135);\n const mat3 toRGB = mat3(1.0, 0.9563, 0.6210,\n 1.0, -0.2721, -0.6474,\n 1.0, -1.107, 1.7046);\n \n vec3 yiq = toYIQ * rgb;\n float hue = atan(yiq.z, yiq.y) + adjustment;\n float chroma = sqrt(yiq.z * yiq.z + yiq.y * yiq.y);\n \n vec3 color = vec3(yiq.x, chroma * cos(hue), chroma * sin(hue));\n return toRGB * color;\n}\n";
// Source/Shaders/Builtin/Functions/inverseGamma.js
var inverseGamma_default = "/**\n * Converts a color in linear space to RGB space.\n *\n * @name czm_inverseGamma\n * @glslFunction\n *\n * @param {vec3} color The color in linear space.\n * @returns {vec3} The color in RGB space.\n */\nvec3 czm_inverseGamma(vec3 color) {\n return pow(color, vec3(1.0 / czm_gamma));\n}\n";
// Source/Shaders/Builtin/Functions/isEmpty.js
var isEmpty_default = "/**\n * Determines if a time interval is empty.\n *\n * @name czm_isEmpty\n * @glslFunction \n * \n * @param {czm_raySegment} interval The interval to test.\n * \n * @returns {bool} true if the time interval is empty; otherwise, false.\n *\n * @example\n * bool b0 = czm_isEmpty(czm_emptyRaySegment); // true\n * bool b1 = czm_isEmpty(czm_raySegment(0.0, 1.0)); // false\n * bool b2 = czm_isEmpty(czm_raySegment(1.0, 1.0)); // false, contains 1.0.\n */\nbool czm_isEmpty(czm_raySegment interval)\n{\n return (interval.stop < 0.0);\n}\n";
// Source/Shaders/Builtin/Functions/isFull.js
var isFull_default = "/**\n * Determines if a time interval is empty.\n *\n * @name czm_isFull\n * @glslFunction \n * \n * @param {czm_raySegment} interval The interval to test.\n * \n * @returns {bool} true if the time interval is empty; otherwise, false.\n *\n * @example\n * bool b0 = czm_isEmpty(czm_emptyRaySegment); // true\n * bool b1 = czm_isEmpty(czm_raySegment(0.0, 1.0)); // false\n * bool b2 = czm_isEmpty(czm_raySegment(1.0, 1.0)); // false, contains 1.0.\n */\nbool czm_isFull(czm_raySegment interval)\n{\n return (interval.start == 0.0 && interval.stop == czm_infinity);\n}\n";
// Source/Shaders/Builtin/Functions/latitudeToWebMercatorFraction.js
var latitudeToWebMercatorFraction_default = "/**\n * Computes the fraction of a Web Wercator rectangle at which a given geodetic latitude is located.\n *\n * @name czm_latitudeToWebMercatorFraction\n * @glslFunction\n *\n * @param {float} latitude The geodetic latitude, in radians.\n * @param {float} southMercatorY The Web Mercator coordinate of the southern boundary of the rectangle.\n * @param {float} oneOverMercatorHeight The total height of the rectangle in Web Mercator coordinates.\n *\n * @returns {float} The fraction of the rectangle at which the latitude occurs. If the latitude is the southern\n * boundary of the rectangle, the return value will be zero. If it is the northern boundary, the return\n * value will be 1.0. Latitudes in between are mapped according to the Web Mercator projection.\n */ \nfloat czm_latitudeToWebMercatorFraction(float latitude, float southMercatorY, float oneOverMercatorHeight)\n{\n float sinLatitude = sin(latitude);\n float mercatorY = 0.5 * log((1.0 + sinLatitude) / (1.0 - sinLatitude));\n \n return (mercatorY - southMercatorY) * oneOverMercatorHeight;\n}\n";
// Source/Shaders/Builtin/Functions/linearToSrgb.js
var linearToSrgb_default = "/**\n * Converts a linear RGB color to an sRGB color.\n *\n * @param {vec3|vec4} linearIn The color in linear color space.\n * @returns {vec3|vec4} The color in sRGB color space. The vector type matches the input.\n */\nvec3 czm_linearToSrgb(vec3 linearIn) \n{\n return pow(linearIn, vec3(1.0/2.2));\n}\n\nvec4 czm_linearToSrgb(vec4 linearIn) \n{\n vec3 srgbOut = pow(linearIn.rgb, vec3(1.0/2.2));\n return vec4(srgbOut, linearIn.a);\n}\n";
// Source/Shaders/Builtin/Functions/lineDistance.js
var lineDistance_default = "/**\n * Computes distance from an point in 2D to a line in 2D.\n *\n * @name czm_lineDistance\n * @glslFunction\n *\n * param {vec2} point1 A point along the line.\n * param {vec2} point2 A point along the line.\n * param {vec2} point A point that may or may not be on the line.\n * returns {float} The distance from the point to the line.\n */\nfloat czm_lineDistance(vec2 point1, vec2 point2, vec2 point) {\n return abs((point2.y - point1.y) * point.x - (point2.x - point1.x) * point.y + point2.x * point1.y - point2.y * point1.x) / distance(point2, point1);\n}\n";
// Source/Shaders/Builtin/Functions/luminance.js
var luminance_default = "/**\n * Computes the luminance of a color. \n *\n * @name czm_luminance\n * @glslFunction\n *\n * @param {vec3} rgb The color.\n * \n * @returns {float} The luminance.\n *\n * @example\n * float light = czm_luminance(vec3(0.0)); // 0.0\n * float dark = czm_luminance(vec3(1.0)); // ~1.0 \n */\nfloat czm_luminance(vec3 rgb)\n{\n // Algorithm from Chapter 10 of Graphics Shaders.\n const vec3 W = vec3(0.2125, 0.7154, 0.0721);\n return dot(rgb, W);\n}\n";
// Source/Shaders/Builtin/Functions/metersPerPixel.js
var metersPerPixel_default = "/**\n * Computes the size of a pixel in meters at a distance from the eye.\n *
\n * Use this version when passing in a custom pixel ratio. For example, passing in 1.0 will return meters per native device pixel.\n *
\n * @name czm_metersPerPixel\n * @glslFunction\n *\n * @param {vec3} positionEC The position to get the meters per pixel in eye coordinates.\n * @param {float} pixelRatio The scaling factor from pixel space to coordinate space\n *\n * @returns {float} The meters per pixel at positionEC.\n */\nfloat czm_metersPerPixel(vec4 positionEC, float pixelRatio)\n{\n float width = czm_viewport.z;\n float height = czm_viewport.w;\n float pixelWidth;\n float pixelHeight;\n\n float top = czm_frustumPlanes.x;\n float bottom = czm_frustumPlanes.y;\n float left = czm_frustumPlanes.z;\n float right = czm_frustumPlanes.w;\n\n if (czm_sceneMode == czm_sceneMode2D || czm_orthographicIn3D == 1.0)\n {\n float frustumWidth = right - left;\n float frustumHeight = top - bottom;\n pixelWidth = frustumWidth / width;\n pixelHeight = frustumHeight / height;\n }\n else\n {\n float distanceToPixel = -positionEC.z;\n float inverseNear = 1.0 / czm_currentFrustum.x;\n float tanTheta = top * inverseNear;\n pixelHeight = 2.0 * distanceToPixel * tanTheta / height;\n tanTheta = right * inverseNear;\n pixelWidth = 2.0 * distanceToPixel * tanTheta / width;\n }\n\n return max(pixelWidth, pixelHeight) * pixelRatio;\n}\n\n/**\n * Computes the size of a pixel in meters at a distance from the eye.\n *
\n * Use this version when scaling by pixel ratio.\n *
\n * @name czm_metersPerPixel\n * @glslFunction\n *\n * @param {vec3} positionEC The position to get the meters per pixel in eye coordinates.\n *\n * @returns {float} The meters per pixel at positionEC.\n */\nfloat czm_metersPerPixel(vec4 positionEC)\n{\n return czm_metersPerPixel(positionEC, czm_pixelRatio);\n}\n";
// Source/Shaders/Builtin/Functions/modelToWindowCoordinates.js
var modelToWindowCoordinates_default = "/**\n * Transforms a position from model to window coordinates. The transformation\n * from model to clip coordinates is done using {@link czm_modelViewProjection}.\n * The transform from normalized device coordinates to window coordinates is\n * done using {@link czm_viewportTransformation}, which assumes a depth range\n * of near = 0 and far = 1.\n *
\n * This transform is useful when there is a need to manipulate window coordinates\n * in a vertex shader as done by {@link BillboardCollection}.\n *
\n * This function should not be confused with {@link czm_viewportOrthographic},\n * which is an orthographic projection matrix that transforms from window \n * coordinates to clip coordinates.\n *\n * @name czm_modelToWindowCoordinates\n * @glslFunction\n *\n * @param {vec4} position The position in model coordinates to transform.\n *\n * @returns {vec4} The transformed position in window coordinates.\n *\n * @see czm_eyeToWindowCoordinates\n * @see czm_modelViewProjection\n * @see czm_viewportTransformation\n * @see czm_viewportOrthographic\n * @see BillboardCollection\n *\n * @example\n * vec4 positionWC = czm_modelToWindowCoordinates(positionMC);\n */\nvec4 czm_modelToWindowCoordinates(vec4 position)\n{\n vec4 q = czm_modelViewProjection * position; // clip coordinates\n q.xyz /= q.w; // normalized device coordinates\n q.xyz = (czm_viewportTransformation * vec4(q.xyz, 1.0)).xyz; // window coordinates\n return q;\n}\n";
// Source/Shaders/Builtin/Functions/multiplyWithColorBalance.js
var multiplyWithColorBalance_default = "/**\n * DOC_TBA\n *\n * @name czm_multiplyWithColorBalance\n * @glslFunction\n */\nvec3 czm_multiplyWithColorBalance(vec3 left, vec3 right)\n{\n // Algorithm from Chapter 10 of Graphics Shaders.\n const vec3 W = vec3(0.2125, 0.7154, 0.0721);\n \n vec3 target = left * right;\n float leftLuminance = dot(left, W);\n float rightLuminance = dot(right, W);\n float targetLuminance = dot(target, W);\n \n return ((leftLuminance + rightLuminance) / (2.0 * targetLuminance)) * target;\n}\n";
// Source/Shaders/Builtin/Functions/nearFarScalar.js
var nearFarScalar_default = "/**\n * Computes a value that scales with distance. The scaling is clamped at the near and\n * far distances, and does not extrapolate. This function works with the\n * {@link NearFarScalar} JavaScript class.\n *\n * @name czm_nearFarScalar\n * @glslFunction\n *\n * @param {vec4} nearFarScalar A vector with 4 components: Near distance (x), Near value (y), Far distance (z), Far value (w).\n * @param {float} cameraDistSq The square of the current distance from the camera.\n *\n * @returns {float} The value at this distance.\n */\nfloat czm_nearFarScalar(vec4 nearFarScalar, float cameraDistSq)\n{\n float valueAtMin = nearFarScalar.y;\n float valueAtMax = nearFarScalar.w;\n float nearDistanceSq = nearFarScalar.x * nearFarScalar.x;\n float farDistanceSq = nearFarScalar.z * nearFarScalar.z;\n\n float t = (cameraDistSq - nearDistanceSq) / (farDistanceSq - nearDistanceSq);\n\n t = pow(clamp(t, 0.0, 1.0), 0.2);\n\n return mix(valueAtMin, valueAtMax, t);\n}\n";
// Source/Shaders/Builtin/Functions/octDecode.js
var octDecode_default = ` /**
* Decodes a unit-length vector in 'oct' encoding to a normalized 3-component Cartesian vector.
* The 'oct' encoding is described in "A Survey of Efficient Representations of Independent Unit Vectors",
* Cigolle et al 2014: http://jcgt.org/published/0003/02/01/
*
* @name czm_octDecode
* @param {vec2} encoded The oct-encoded, unit-length vector
* @param {float} range The maximum value of the SNORM range. The encoded vector is stored in log2(rangeMax+1) bits.
* @returns {vec3} The decoded and normalized vector
*/
vec3 czm_octDecode(vec2 encoded, float range)
{
if (encoded.x == 0.0 && encoded.y == 0.0) {
return vec3(0.0, 0.0, 0.0);
}
encoded = encoded / range * 2.0 - 1.0;
vec3 v = vec3(encoded.x, encoded.y, 1.0 - abs(encoded.x) - abs(encoded.y));
if (v.z < 0.0)
{
v.xy = (1.0 - abs(v.yx)) * czm_signNotZero(v.xy);
}
return normalize(v);
}
/**
* Decodes a unit-length vector in 'oct' encoding to a normalized 3-component Cartesian vector.
* The 'oct' encoding is described in "A Survey of Efficient Representations of Independent Unit Vectors",
* Cigolle et al 2014: http://jcgt.org/published/0003/02/01/
*
* @name czm_octDecode
* @param {vec2} encoded The oct-encoded, unit-length vector
* @returns {vec3} The decoded and normalized vector
*/
vec3 czm_octDecode(vec2 encoded)
{
return czm_octDecode(encoded, 255.0);
}
/**
* Decodes a unit-length vector in 'oct' encoding packed into a floating-point number to a normalized 3-component Cartesian vector.
* The 'oct' encoding is described in "A Survey of Efficient Representations of Independent Unit Vectors",
* Cigolle et al 2014: http://jcgt.org/published/0003/02/01/
*
* @name czm_octDecode
* @param {float} encoded The oct-encoded, unit-length vector
* @returns {vec3} The decoded and normalized vector
*/
vec3 czm_octDecode(float encoded)
{
float temp = encoded / 256.0;
float x = floor(temp);
float y = (temp - x) * 256.0;
return czm_octDecode(vec2(x, y));
}
/**
* Decodes three unit-length vectors in 'oct' encoding packed into two floating-point numbers to normalized 3-component Cartesian vectors.
* The 'oct' encoding is described in "A Survey of Efficient Representations of Independent Unit Vectors",
* Cigolle et al 2014: http://jcgt.org/published/0003/02/01/
*
* @name czm_octDecode
* @param {vec2} encoded The packed oct-encoded, unit-length vectors.
* @param {vec3} vector1 One decoded and normalized vector.
* @param {vec3} vector2 One decoded and normalized vector.
* @param {vec3} vector3 One decoded and normalized vector.
*/
void czm_octDecode(vec2 encoded, out vec3 vector1, out vec3 vector2, out vec3 vector3)
{
float temp = encoded.x / 65536.0;
float x = floor(temp);
float encodedFloat1 = (temp - x) * 65536.0;
temp = encoded.y / 65536.0;
float y = floor(temp);
float encodedFloat2 = (temp - y) * 65536.0;
vector1 = czm_octDecode(encodedFloat1);
vector2 = czm_octDecode(encodedFloat2);
vector3 = czm_octDecode(vec2(x, y));
}
`;
// Source/Shaders/Builtin/Functions/packDepth.js
var packDepth_default = "/**\n * Packs a depth value into a vec3 that can be represented by unsigned bytes.\n *\n * @name czm_packDepth\n * @glslFunction\n *\n * @param {float} depth The floating-point depth.\n * @returns {vec3} The packed depth.\n */\nvec4 czm_packDepth(float depth)\n{\n // See Aras Pranckevi\u010Dius' post Encoding Floats to RGBA\n // http://aras-p.info/blog/2009/07/30/encoding-floats-to-rgba-the-final/\n vec4 enc = vec4(1.0, 255.0, 65025.0, 16581375.0) * depth;\n enc = fract(enc);\n enc -= enc.yzww * vec4(1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0, 0.0);\n return enc;\n}\n";
// Source/Shaders/Builtin/Functions/pbrLighting.js
var pbrLighting_default = "vec3 lambertianDiffuse(vec3 diffuseColor)\n{\n return diffuseColor / czm_pi;\n}\n\nvec3 fresnelSchlick2(vec3 f0, vec3 f90, float VdotH)\n{\n return f0 + (f90 - f0) * pow(clamp(1.0 - VdotH, 0.0, 1.0), 5.0);\n}\n\nfloat smithVisibilityG1(float NdotV, float roughness)\n{\n // this is the k value for direct lighting.\n // for image based lighting it will be roughness^2 / 2\n float k = (roughness + 1.0) * (roughness + 1.0) / 8.0;\n return NdotV / (NdotV * (1.0 - k) + k);\n}\n\nfloat smithVisibilityGGX(float roughness, float NdotL, float NdotV)\n{\n return (\n smithVisibilityG1(NdotL, roughness) *\n smithVisibilityG1(NdotV, roughness)\n );\n}\n\nfloat GGX(float roughness, float NdotH)\n{\n float roughnessSquared = roughness * roughness;\n float f = (NdotH * roughnessSquared - NdotH) * NdotH + 1.0;\n return roughnessSquared / (czm_pi * f * f);\n}\n\n/**\n * Compute the diffuse and specular contributions using physically based\n * rendering. This function only handles direct lighting.\n *
\n * This function only handles the lighting calculations. Metallic/roughness\n * and specular/glossy must be handled separately. See {@czm_pbrMetallicRoughnessMaterial}, {@czm_pbrSpecularGlossinessMaterial} and {@czm_defaultPbrMaterial}\n *
\n *\n * @name czm_pbrlighting\n * @glslFunction\n *\n * @param {vec3} positionEC The position of the fragment in eye coordinates\n * @param {vec3} normalEC The surface normal in eye coordinates\n * @param {vec3} lightDirectionEC Unit vector pointing to the light source in eye coordinates.\n * @param {vec3} lightColorHdr radiance of the light source. This is a HDR value.\n * @param {czm_pbrParameters} The computed PBR parameters.\n * @return {vec3} The computed HDR color\n *\n * @example\n * czm_pbrParameters pbrParameters = czm_pbrMetallicRoughnessMaterial(\n * baseColor,\n * metallic,\n * roughness\n * );\n * vec3 color = czm_pbrlighting(\n * positionEC,\n * normalEC,\n * lightDirectionEC,\n * lightColorHdr,\n * pbrParameters);\n */\nvec3 czm_pbrLighting(\n vec3 positionEC,\n vec3 normalEC,\n vec3 lightDirectionEC,\n vec3 lightColorHdr,\n czm_pbrParameters pbrParameters\n)\n{\n vec3 v = -normalize(positionEC);\n vec3 l = normalize(lightDirectionEC);\n vec3 h = normalize(v + l);\n vec3 n = normalEC;\n float NdotL = clamp(dot(n, l), 0.001, 1.0);\n float NdotV = abs(dot(n, v)) + 0.001;\n float NdotH = clamp(dot(n, h), 0.0, 1.0);\n float LdotH = clamp(dot(l, h), 0.0, 1.0);\n float VdotH = clamp(dot(v, h), 0.0, 1.0);\n\n vec3 f0 = pbrParameters.f0;\n float reflectance = max(max(f0.r, f0.g), f0.b);\n vec3 f90 = vec3(clamp(reflectance * 25.0, 0.0, 1.0));\n vec3 F = fresnelSchlick2(f0, f90, VdotH);\n\n float alpha = pbrParameters.roughness;\n float G = smithVisibilityGGX(alpha, NdotL, NdotV);\n float D = GGX(alpha, NdotH);\n vec3 specularContribution = F * G * D / (4.0 * NdotL * NdotV);\n\n vec3 diffuseColor = pbrParameters.diffuseColor;\n // F here represents the specular contribution\n vec3 diffuseContribution = (1.0 - F) * lambertianDiffuse(diffuseColor);\n\n // Lo = (diffuse + specular) * Li * NdotL\n return (diffuseContribution + specularContribution) * NdotL * lightColorHdr;\n}\n";
// Source/Shaders/Builtin/Functions/pbrMetallicRoughnessMaterial.js
var pbrMetallicRoughnessMaterial_default = "/**\n * Compute parameters for physically based rendering using the\n * metallic/roughness workflow. All inputs are linear; sRGB texture values must\n * be decoded beforehand\n *\n * @name czm_pbrMetallicRoughnessMaterial\n * @glslFunction\n *\n * @param {vec3} baseColor For dielectrics, this is the base color. For metals, this is the f0 value (reflectance at normal incidence)\n * @param {float} metallic 0.0 indicates dielectric. 1.0 indicates metal. Values in between are allowed (e.g. to model rust or dirt);\n * @param {float} roughness A value between 0.0 and 1.0\n * @return {czm_pbrParameters} parameters to pass into {@link czm_pbrLighting}\n */\nczm_pbrParameters czm_pbrMetallicRoughnessMaterial(\n vec3 baseColor,\n float metallic,\n float roughness\n) \n{\n czm_pbrParameters results;\n\n // roughness is authored as perceptual roughness\n // square it to get material roughness\n roughness = clamp(roughness, 0.0, 1.0);\n results.roughness = roughness * roughness;\n\n // dielectrics use f0 = 0.04, metals use albedo as f0\n metallic = clamp(metallic, 0.0, 1.0);\n const vec3 REFLECTANCE_DIELECTRIC = vec3(0.04);\n vec3 f0 = mix(REFLECTANCE_DIELECTRIC, baseColor, metallic);\n results.f0 = f0;\n\n // diffuse only applies to dielectrics.\n results.diffuseColor = baseColor * (1.0 - f0) * (1.0 - metallic);\n\n return results;\n}\n";
// Source/Shaders/Builtin/Functions/pbrSpecularGlossinessMaterial.js
var pbrSpecularGlossinessMaterial_default = "/**\n * Compute parameters for physically based rendering using the\n * specular/glossy workflow. All inputs are linear; sRGB texture values must\n * be decoded beforehand\n *\n * @name czm_pbrSpecularGlossinessMaterial\n * @glslFunction\n *\n * @param {vec3} diffuse The diffuse color for dielectrics (non-metals)\n * @param {vec3} specular The reflectance at normal incidence (f0)\n * @param {float} glossiness A number from 0.0 to 1.0 indicating how smooth the surface is.\n * @return {czm_pbrParameters} parameters to pass into {@link czm_pbrLighting}\n */\nczm_pbrParameters czm_pbrSpecularGlossinessMaterial(\n vec3 diffuse,\n vec3 specular,\n float glossiness\n) \n{\n czm_pbrParameters results;\n\n // glossiness is the opposite of roughness, but easier for artists to use.\n float roughness = 1.0 - glossiness;\n results.roughness = roughness * roughness;\n\n results.diffuseColor = diffuse * (1.0 - max(max(specular.r, specular.g), specular.b));\n results.f0 = specular;\n\n return results;\n}\n";
// Source/Shaders/Builtin/Functions/phong.js
var phong_default = "float czm_private_getLambertDiffuseOfMaterial(vec3 lightDirectionEC, czm_material material)\n{\n return czm_getLambertDiffuse(lightDirectionEC, material.normal);\n}\n\nfloat czm_private_getSpecularOfMaterial(vec3 lightDirectionEC, vec3 toEyeEC, czm_material material)\n{\n return czm_getSpecular(lightDirectionEC, toEyeEC, material.normal, material.shininess);\n}\n\n/**\n * Computes a color using the Phong lighting model.\n *\n * @name czm_phong\n * @glslFunction\n *\n * @param {vec3} toEye A normalized vector from the fragment to the eye in eye coordinates.\n * @param {czm_material} material The fragment's material.\n *\n * @returns {vec4} The computed color.\n *\n * @example\n * vec3 positionToEyeEC = // ...\n * czm_material material = // ...\n * vec3 lightDirectionEC = // ...\n * gl_FragColor = czm_phong(normalize(positionToEyeEC), material, lightDirectionEC);\n *\n * @see czm_getMaterial\n */\nvec4 czm_phong(vec3 toEye, czm_material material, vec3 lightDirectionEC)\n{\n // Diffuse from directional light sources at eye (for top-down)\n float diffuse = czm_private_getLambertDiffuseOfMaterial(vec3(0.0, 0.0, 1.0), material);\n if (czm_sceneMode == czm_sceneMode3D) {\n // (and horizon views in 3D)\n diffuse += czm_private_getLambertDiffuseOfMaterial(vec3(0.0, 1.0, 0.0), material);\n }\n\n float specular = czm_private_getSpecularOfMaterial(lightDirectionEC, toEye, material);\n\n // Temporary workaround for adding ambient.\n vec3 materialDiffuse = material.diffuse * 0.5;\n\n vec3 ambient = materialDiffuse;\n vec3 color = ambient + material.emission;\n color += materialDiffuse * diffuse * czm_lightColor;\n color += material.specular * specular * czm_lightColor;\n\n return vec4(color, material.alpha);\n}\n\nvec4 czm_private_phong(vec3 toEye, czm_material material, vec3 lightDirectionEC)\n{\n float diffuse = czm_private_getLambertDiffuseOfMaterial(lightDirectionEC, material);\n float specular = czm_private_getSpecularOfMaterial(lightDirectionEC, toEye, material);\n\n vec3 ambient = vec3(0.0);\n vec3 color = ambient + material.emission;\n color += material.diffuse * diffuse * czm_lightColor;\n color += material.specular * specular * czm_lightColor;\n\n return vec4(color, material.alpha);\n}\n";
// Source/Shaders/Builtin/Functions/planeDistance.js
var planeDistance_default = "/**\n * Computes distance from a point to a plane.\n *\n * @name czm_planeDistance\n * @glslFunction\n *\n * param {vec4} plane A Plane in Hessian Normal Form. See Plane.js\n * param {vec3} point A point in the same space as the plane.\n * returns {float} The distance from the point to the plane.\n */\nfloat czm_planeDistance(vec4 plane, vec3 point) {\n return (dot(plane.xyz, point) + plane.w);\n}\n\n/**\n * Computes distance from a point to a plane.\n *\n * @name czm_planeDistance\n * @glslFunction\n *\n * param {vec3} planeNormal Normal for a plane in Hessian Normal Form. See Plane.js\n * param {float} planeDistance Distance for a plane in Hessian Normal form. See Plane.js\n * param {vec3} point A point in the same space as the plane.\n * returns {float} The distance from the point to the plane.\n */\nfloat czm_planeDistance(vec3 planeNormal, float planeDistance, vec3 point) {\n return (dot(planeNormal, point) + planeDistance);\n}\n";
// Source/Shaders/Builtin/Functions/pointAlongRay.js
var pointAlongRay_default = "/**\n * Computes the point along a ray at the given time. time can be positive, negative, or zero.\n *\n * @name czm_pointAlongRay\n * @glslFunction\n *\n * @param {czm_ray} ray The ray to compute the point along.\n * @param {float} time The time along the ray.\n * \n * @returns {vec3} The point along the ray at the given time.\n * \n * @example\n * czm_ray ray = czm_ray(vec3(0.0), vec3(1.0, 0.0, 0.0)); // origin, direction\n * vec3 v = czm_pointAlongRay(ray, 2.0); // (2.0, 0.0, 0.0)\n */\nvec3 czm_pointAlongRay(czm_ray ray, float time)\n{\n return ray.origin + (time * ray.direction);\n}\n";
// Source/Shaders/Builtin/Functions/rayEllipsoidIntersectionInterval.js
var rayEllipsoidIntersectionInterval_default = "/**\n * DOC_TBA\n *\n * @name czm_rayEllipsoidIntersectionInterval\n * @glslFunction\n */\nczm_raySegment czm_rayEllipsoidIntersectionInterval(czm_ray ray, vec3 ellipsoid_center, vec3 ellipsoid_inverseRadii)\n{\n // ray and ellipsoid center in eye coordinates. radii in model coordinates.\n vec3 q = ellipsoid_inverseRadii * (czm_inverseModelView * vec4(ray.origin, 1.0)).xyz;\n vec3 w = ellipsoid_inverseRadii * (czm_inverseModelView * vec4(ray.direction, 0.0)).xyz;\n\n q = q - ellipsoid_inverseRadii * (czm_inverseModelView * vec4(ellipsoid_center, 1.0)).xyz;\n\n float q2 = dot(q, q);\n float qw = dot(q, w);\n\n if (q2 > 1.0) // Outside ellipsoid.\n {\n if (qw >= 0.0) // Looking outward or tangent (0 intersections).\n {\n return czm_emptyRaySegment;\n }\n else // qw < 0.0.\n {\n float qw2 = qw * qw;\n float difference = q2 - 1.0; // Positively valued.\n float w2 = dot(w, w);\n float product = w2 * difference;\n\n if (qw2 < product) // Imaginary roots (0 intersections).\n {\n return czm_emptyRaySegment;\n }\n else if (qw2 > product) // Distinct roots (2 intersections).\n {\n float discriminant = qw * qw - product;\n float temp = -qw + sqrt(discriminant); // Avoid cancellation.\n float root0 = temp / w2;\n float root1 = difference / temp;\n if (root0 < root1)\n {\n czm_raySegment i = czm_raySegment(root0, root1);\n return i;\n }\n else\n {\n czm_raySegment i = czm_raySegment(root1, root0);\n return i;\n }\n }\n else // qw2 == product. Repeated roots (2 intersections).\n {\n float root = sqrt(difference / w2);\n czm_raySegment i = czm_raySegment(root, root);\n return i;\n }\n }\n }\n else if (q2 < 1.0) // Inside ellipsoid (2 intersections).\n {\n float difference = q2 - 1.0; // Negatively valued.\n float w2 = dot(w, w);\n float product = w2 * difference; // Negatively valued.\n float discriminant = qw * qw - product;\n float temp = -qw + sqrt(discriminant); // Positively valued.\n czm_raySegment i = czm_raySegment(0.0, temp / w2);\n return i;\n }\n else // q2 == 1.0. On ellipsoid.\n {\n if (qw < 0.0) // Looking inward.\n {\n float w2 = dot(w, w);\n czm_raySegment i = czm_raySegment(0.0, -qw / w2);\n return i;\n }\n else // qw >= 0.0. Looking outward or tangent.\n {\n return czm_emptyRaySegment;\n }\n }\n}\n";
// Source/Shaders/Builtin/Functions/raySphereIntersectionInterval.js
var raySphereIntersectionInterval_default = "/**\n * Compute the intersection interval of a ray with a sphere.\n *\n * @name czm_raySphereIntersectionInterval\n * @glslFunction\n *\n * @param {czm_ray} ray The ray.\n * @param {vec3} center The center of the sphere.\n * @param {float} radius The radius of the sphere.\n * @return {czm_raySegment} The intersection interval of the ray with the sphere.\n */\nczm_raySegment czm_raySphereIntersectionInterval(czm_ray ray, vec3 center, float radius)\n{\n vec3 o = ray.origin;\n vec3 d = ray.direction;\n\n vec3 oc = o - center;\n\n float a = dot(d, d);\n float b = 2.0 * dot(d, oc);\n float c = dot(oc, oc) - (radius * radius);\n\n float det = (b * b) - (4.0 * a * c);\n\n if (det < 0.0) {\n return czm_emptyRaySegment;\n }\n\n float sqrtDet = sqrt(det);\n\n float t0 = (-b - sqrtDet) / (2.0 * a);\n float t1 = (-b + sqrtDet) / (2.0 * a);\n\n czm_raySegment result = czm_raySegment(t0, t1);\n return result;\n}\n";
// Source/Shaders/Builtin/Functions/readDepth.js
var readDepth_default = "float czm_readDepth(sampler2D depthTexture, vec2 texCoords)\n{\n return czm_reverseLogDepth(texture2D(depthTexture, texCoords).r);\n}\n";
// Source/Shaders/Builtin/Functions/readNonPerspective.js
var readNonPerspective_default = "/**\n * Reads a value previously transformed with {@link czm_writeNonPerspective}\n * by dividing it by `w`, the value used in the perspective divide.\n * This function is intended to be called in a fragment shader to access a\n * `varying` that should not be subject to perspective interpolation.\n * For example, screen-space texture coordinates. The value should have been\n * previously written in the vertex shader with a call to\n * {@link czm_writeNonPerspective}.\n *\n * @name czm_readNonPerspective\n * @glslFunction\n *\n * @param {float|vec2|vec3|vec4} value The non-perspective value to be read.\n * @param {float} oneOverW One over the perspective divide value, `w`. Usually this is simply `gl_FragCoord.w`.\n * @returns {float|vec2|vec3|vec4} The usable value.\n */\nfloat czm_readNonPerspective(float value, float oneOverW) {\n return value * oneOverW;\n}\n\nvec2 czm_readNonPerspective(vec2 value, float oneOverW) {\n return value * oneOverW;\n}\n\nvec3 czm_readNonPerspective(vec3 value, float oneOverW) {\n return value * oneOverW;\n}\n\nvec4 czm_readNonPerspective(vec4 value, float oneOverW) {\n return value * oneOverW;\n}\n";
// Source/Shaders/Builtin/Functions/reverseLogDepth.js
var reverseLogDepth_default = "float czm_reverseLogDepth(float logZ)\n{\n#ifdef LOG_DEPTH\n float near = czm_currentFrustum.x;\n float far = czm_currentFrustum.y;\n float log2Depth = logZ * czm_log2FarDepthFromNearPlusOne;\n float depthFromNear = pow(2.0, log2Depth) - 1.0;\n return far * (1.0 - near / (depthFromNear + near)) / (far - near);\n#endif\n return logZ;\n}\n";
// Source/Shaders/Builtin/Functions/RGBToHSB.js
var RGBToHSB_default = "/**\n * Converts an RGB color to HSB (hue, saturation, brightness)\n * HSB <-> RGB conversion with minimal branching: {@link http://lolengine.net/blog/2013/07/27/rgb-to-hsv-in-glsl}\n *\n * @name czm_RGBToHSB\n * @glslFunction\n * \n * @param {vec3} rgb The color in RGB.\n *\n * @returns {vec3} The color in HSB.\n *\n * @example\n * vec3 hsb = czm_RGBToHSB(rgb);\n * hsb.z *= 0.1;\n * rgb = czm_HSBToRGB(hsb);\n */\n\nconst vec4 K_RGB2HSB = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);\n\nvec3 czm_RGBToHSB(vec3 rgb)\n{\n vec4 p = mix(vec4(rgb.bg, K_RGB2HSB.wz), vec4(rgb.gb, K_RGB2HSB.xy), step(rgb.b, rgb.g));\n vec4 q = mix(vec4(p.xyw, rgb.r), vec4(rgb.r, p.yzx), step(p.x, rgb.r));\n\n float d = q.x - min(q.w, q.y);\n return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + czm_epsilon7)), d / (q.x + czm_epsilon7), q.x);\n}\n";
// Source/Shaders/Builtin/Functions/RGBToHSL.js
var RGBToHSL_default = "/**\n * Converts an RGB color to HSL (hue, saturation, lightness)\n * HSL <-> RGB conversion: {@link http://www.chilliant.com/rgb2hsv.html}\n *\n * @name czm_RGBToHSL\n * @glslFunction\n * \n * @param {vec3} rgb The color in RGB.\n *\n * @returns {vec3} The color in HSL.\n *\n * @example\n * vec3 hsl = czm_RGBToHSL(rgb);\n * hsl.z *= 0.1;\n * rgb = czm_HSLToRGB(hsl);\n */\n \nvec3 RGBtoHCV(vec3 rgb)\n{\n // Based on work by Sam Hocevar and Emil Persson\n vec4 p = (rgb.g < rgb.b) ? vec4(rgb.bg, -1.0, 2.0 / 3.0) : vec4(rgb.gb, 0.0, -1.0 / 3.0);\n vec4 q = (rgb.r < p.x) ? vec4(p.xyw, rgb.r) : vec4(rgb.r, p.yzx);\n float c = q.x - min(q.w, q.y);\n float h = abs((q.w - q.y) / (6.0 * c + czm_epsilon7) + q.z);\n return vec3(h, c, q.x);\n}\n\nvec3 czm_RGBToHSL(vec3 rgb)\n{\n vec3 hcv = RGBtoHCV(rgb);\n float l = hcv.z - hcv.y * 0.5;\n float s = hcv.y / (1.0 - abs(l * 2.0 - 1.0) + czm_epsilon7);\n return vec3(hcv.x, s, l);\n}\n";
// Source/Shaders/Builtin/Functions/RGBToXYZ.js
var RGBToXYZ_default = "/**\n * Converts an RGB color to CIE Yxy.\n *
The conversion is described in\n * {@link http://content.gpwiki.org/index.php/D3DBook:High-Dynamic_Range_Rendering#Luminance_Transform|Luminance Transform}\n *
\n * \n * @name czm_RGBToXYZ\n * @glslFunction\n * \n * @param {vec3} rgb The color in RGB.\n *\n * @returns {vec3} The color in CIE Yxy.\n *\n * @example\n * vec3 xyz = czm_RGBToXYZ(rgb);\n * xyz.x = max(xyz.x - luminanceThreshold, 0.0);\n * rgb = czm_XYZToRGB(xyz);\n */\nvec3 czm_RGBToXYZ(vec3 rgb)\n{\n const mat3 RGB2XYZ = mat3(0.4124, 0.2126, 0.0193,\n 0.3576, 0.7152, 0.1192,\n 0.1805, 0.0722, 0.9505);\n vec3 xyz = RGB2XYZ * rgb;\n vec3 Yxy;\n Yxy.r = xyz.g;\n float temp = dot(vec3(1.0), xyz);\n Yxy.gb = xyz.rg / temp;\n return Yxy;\n}\n";
// Source/Shaders/Builtin/Functions/round.js
var round_default = "/**\n * Round a floating point value. This function exists because round() doesn't\n * exist in GLSL 1.00. \n *\n * @param {float|vec2|vec3|vec4} value The value to round\n * @param {float|vec2|vec3|vec3} The rounded value. The type matches the input.\n */\nfloat czm_round(float value) {\n return floor(value + 0.5);\n}\n\nvec2 czm_round(vec2 value) {\n return floor(value + 0.5);\n}\n\nvec3 czm_round(vec3 value) {\n return floor(value + 0.5);\n}\n\nvec4 czm_round(vec4 value) {\n return floor(value + 0.5);\n}\n";
// Source/Shaders/Builtin/Functions/sampleOctahedralProjection.js
var sampleOctahedralProjection_default = "/**\n * Samples the 4 neighboring pixels and return the weighted average.\n *\n * @private\n */\nvec3 czm_sampleOctahedralProjectionWithFiltering(sampler2D projectedMap, vec2 textureSize, vec3 direction, float lod)\n{\n direction /= dot(vec3(1.0), abs(direction));\n vec2 rev = abs(direction.zx) - vec2(1.0);\n vec2 neg = vec2(direction.x < 0.0 ? rev.x : -rev.x,\n direction.z < 0.0 ? rev.y : -rev.y);\n vec2 uv = direction.y < 0.0 ? neg : direction.xz;\n vec2 coord = 0.5 * uv + vec2(0.5);\n vec2 pixel = 1.0 / textureSize;\n\n if (lod > 0.0)\n {\n // Each subseqeuent mip level is half the size\n float scale = 1.0 / pow(2.0, lod);\n float offset = ((textureSize.y + 1.0) / textureSize.x);\n\n coord.x *= offset;\n coord *= scale;\n\n coord.x += offset + pixel.x;\n coord.y += (1.0 - (1.0 / pow(2.0, lod - 1.0))) + pixel.y * (lod - 1.0) * 2.0;\n }\n else\n {\n coord.x *= (textureSize.y / textureSize.x);\n }\n\n // Do bilinear filtering\n #ifndef OES_texture_float_linear\n vec3 color1 = texture2D(projectedMap, coord + vec2(0.0, pixel.y)).rgb;\n vec3 color2 = texture2D(projectedMap, coord + vec2(pixel.x, 0.0)).rgb;\n vec3 color3 = texture2D(projectedMap, coord + pixel).rgb;\n vec3 color4 = texture2D(projectedMap, coord).rgb;\n\n vec2 texturePosition = coord * textureSize;\n\n float fu = fract(texturePosition.x);\n float fv = fract(texturePosition.y);\n\n vec3 average1 = mix(color4, color2, fu);\n vec3 average2 = mix(color1, color3, fu);\n\n vec3 color = mix(average1, average2, fv);\n #else\n vec3 color = texture2D(projectedMap, coord).rgb;\n #endif\n\n return color;\n}\n\n\n/**\n * Samples from a cube map that has been projected using an octahedral projection from the given direction.\n *\n * @name czm_sampleOctahedralProjection\n * @glslFunction\n *\n * @param {sampler2D} projectedMap The texture with the octahedral projected cube map.\n * @param {vec2} textureSize The width and height dimensions in pixels of the projected map.\n * @param {vec3} direction The normalized direction used to sample the cube map.\n * @param {float} lod The level of detail to sample.\n * @param {float} maxLod The maximum level of detail.\n * @returns {vec3} The color of the cube map at the direction.\n */\nvec3 czm_sampleOctahedralProjection(sampler2D projectedMap, vec2 textureSize, vec3 direction, float lod, float maxLod) {\n float currentLod = floor(lod + 0.5);\n float nextLod = min(currentLod + 1.0, maxLod);\n\n vec3 colorCurrentLod = czm_sampleOctahedralProjectionWithFiltering(projectedMap, textureSize, direction, currentLod);\n vec3 colorNextLod = czm_sampleOctahedralProjectionWithFiltering(projectedMap, textureSize, direction, nextLod);\n\n return mix(colorNextLod, colorCurrentLod, nextLod - lod);\n}\n";
// Source/Shaders/Builtin/Functions/saturation.js
var saturation_default = "/**\n * Adjusts the saturation of a color.\n * \n * @name czm_saturation\n * @glslFunction\n * \n * @param {vec3} rgb The color.\n * @param {float} adjustment The amount to adjust the saturation of the color.\n *\n * @returns {float} The color with the saturation adjusted.\n *\n * @example\n * vec3 greyScale = czm_saturation(color, 0.0);\n * vec3 doubleSaturation = czm_saturation(color, 2.0);\n */\nvec3 czm_saturation(vec3 rgb, float adjustment)\n{\n // Algorithm from Chapter 16 of OpenGL Shading Language\n const vec3 W = vec3(0.2125, 0.7154, 0.0721);\n vec3 intensity = vec3(dot(rgb, W));\n return mix(intensity, rgb, adjustment);\n}\n";
// Source/Shaders/Builtin/Functions/shadowDepthCompare.js
var shadowDepthCompare_default = "\nfloat czm_sampleShadowMap(highp samplerCube shadowMap, vec3 d)\n{\n return czm_unpackDepth(textureCube(shadowMap, d));\n}\n\nfloat czm_sampleShadowMap(highp sampler2D shadowMap, vec2 uv)\n{\n#ifdef USE_SHADOW_DEPTH_TEXTURE\n return texture2D(shadowMap, uv).r;\n#else\n return czm_unpackDepth(texture2D(shadowMap, uv));\n#endif\n}\n\nfloat czm_shadowDepthCompare(samplerCube shadowMap, vec3 uv, float depth)\n{\n return step(depth, czm_sampleShadowMap(shadowMap, uv));\n}\n\nfloat czm_shadowDepthCompare(sampler2D shadowMap, vec2 uv, float depth)\n{\n return step(depth, czm_sampleShadowMap(shadowMap, uv));\n}\n";
// Source/Shaders/Builtin/Functions/shadowVisibility.js
var shadowVisibility_default = "\nfloat czm_private_shadowVisibility(float visibility, float nDotL, float normalShadingSmooth, float darkness)\n{\n#ifdef USE_NORMAL_SHADING\n#ifdef USE_NORMAL_SHADING_SMOOTH\n float strength = clamp(nDotL / normalShadingSmooth, 0.0, 1.0);\n#else\n float strength = step(0.0, nDotL);\n#endif\n visibility *= strength;\n#endif\n\n visibility = max(visibility, darkness);\n return visibility;\n}\n\n#ifdef USE_CUBE_MAP_SHADOW\nfloat czm_shadowVisibility(samplerCube shadowMap, czm_shadowParameters shadowParameters)\n{\n float depthBias = shadowParameters.depthBias;\n float depth = shadowParameters.depth;\n float nDotL = shadowParameters.nDotL;\n float normalShadingSmooth = shadowParameters.normalShadingSmooth;\n float darkness = shadowParameters.darkness;\n vec3 uvw = shadowParameters.texCoords;\n\n depth -= depthBias;\n float visibility = czm_shadowDepthCompare(shadowMap, uvw, depth);\n return czm_private_shadowVisibility(visibility, nDotL, normalShadingSmooth, darkness);\n}\n#else\nfloat czm_shadowVisibility(sampler2D shadowMap, czm_shadowParameters shadowParameters)\n{\n float depthBias = shadowParameters.depthBias;\n float depth = shadowParameters.depth;\n float nDotL = shadowParameters.nDotL;\n float normalShadingSmooth = shadowParameters.normalShadingSmooth;\n float darkness = shadowParameters.darkness;\n vec2 uv = shadowParameters.texCoords;\n\n depth -= depthBias;\n#ifdef USE_SOFT_SHADOWS\n vec2 texelStepSize = shadowParameters.texelStepSize;\n float radius = 1.0;\n float dx0 = -texelStepSize.x * radius;\n float dy0 = -texelStepSize.y * radius;\n float dx1 = texelStepSize.x * radius;\n float dy1 = texelStepSize.y * radius;\n float visibility = (\n czm_shadowDepthCompare(shadowMap, uv, depth) +\n czm_shadowDepthCompare(shadowMap, uv + vec2(dx0, dy0), depth) +\n czm_shadowDepthCompare(shadowMap, uv + vec2(0.0, dy0), depth) +\n czm_shadowDepthCompare(shadowMap, uv + vec2(dx1, dy0), depth) +\n czm_shadowDepthCompare(shadowMap, uv + vec2(dx0, 0.0), depth) +\n czm_shadowDepthCompare(shadowMap, uv + vec2(dx1, 0.0), depth) +\n czm_shadowDepthCompare(shadowMap, uv + vec2(dx0, dy1), depth) +\n czm_shadowDepthCompare(shadowMap, uv + vec2(0.0, dy1), depth) +\n czm_shadowDepthCompare(shadowMap, uv + vec2(dx1, dy1), depth)\n ) * (1.0 / 9.0);\n#else\n float visibility = czm_shadowDepthCompare(shadowMap, uv, depth);\n#endif\n\n return czm_private_shadowVisibility(visibility, nDotL, normalShadingSmooth, darkness);\n}\n#endif\n";
// Source/Shaders/Builtin/Functions/signNotZero.js
var signNotZero_default = "/**\n * Returns 1.0 if the given value is positive or zero, and -1.0 if it is negative. This is similar to the GLSL\n * built-in function sign except that returns 1.0 instead of 0.0 when the input value is 0.0.\n * \n * @name czm_signNotZero\n * @glslFunction\n *\n * @param {} value The value for which to determine the sign.\n * @returns {} 1.0 if the value is positive or zero, -1.0 if the value is negative.\n */\nfloat czm_signNotZero(float value)\n{\n return value >= 0.0 ? 1.0 : -1.0;\n}\n\nvec2 czm_signNotZero(vec2 value)\n{\n return vec2(czm_signNotZero(value.x), czm_signNotZero(value.y));\n}\n\nvec3 czm_signNotZero(vec3 value)\n{\n return vec3(czm_signNotZero(value.x), czm_signNotZero(value.y), czm_signNotZero(value.z));\n}\n\nvec4 czm_signNotZero(vec4 value)\n{\n return vec4(czm_signNotZero(value.x), czm_signNotZero(value.y), czm_signNotZero(value.z), czm_signNotZero(value.w));\n}\n";
// Source/Shaders/Builtin/Functions/sphericalHarmonics.js
var sphericalHarmonics_default = "/**\n * Computes a color from the third order spherical harmonic coefficients and a normalized direction vector.\n *
\n * The order of the coefficients is [L00, L1_1, L10, L11, L2_2, L2_1, L20, L21, L22].\n *
\n *\n * @name czm_sphericalHarmonics\n * @glslFunction\n *\n * @param {vec3} normal The normalized direction.\n * @param {vec3[9]} coefficients The third order spherical harmonic coefficients.\n * @returns {vec3} The color at the direction.\n *\n * @see https://graphics.stanford.edu/papers/envmap/envmap.pdf\n */\nvec3 czm_sphericalHarmonics(vec3 normal, vec3 coefficients[9])\n{\n vec3 L00 = coefficients[0];\n vec3 L1_1 = coefficients[1];\n vec3 L10 = coefficients[2];\n vec3 L11 = coefficients[3];\n vec3 L2_2 = coefficients[4];\n vec3 L2_1 = coefficients[5];\n vec3 L20 = coefficients[6];\n vec3 L21 = coefficients[7];\n vec3 L22 = coefficients[8];\n\n float x = normal.x;\n float y = normal.y;\n float z = normal.z;\n\n return\n L00\n + L1_1 * y\n + L10 * z\n + L11 * x\n + L2_2 * (y * x)\n + L2_1 * (y * z)\n + L20 * (3.0 * z * z - 1.0)\n + L21 * (z * x)\n + L22 * (x * x - y * y);\n}\n";
// Source/Shaders/Builtin/Functions/srgbToLinear.js
var srgbToLinear_default = "/**\n * Converts an sRGB color to a linear RGB color.\n *\n * @param {vec3|vec4} srgbIn The color in sRGB space\n * @returns {vec3|vec4} The color in linear color space. The vector type matches the input.\n */\nvec3 czm_srgbToLinear(vec3 srgbIn)\n{\n return pow(srgbIn, vec3(2.2));\n}\n\nvec4 czm_srgbToLinear(vec4 srgbIn) \n{\n vec3 linearOut = pow(srgbIn.rgb, vec3(2.2));\n return vec4(linearOut, srgbIn.a);\n}\n";
// Source/Shaders/Builtin/Functions/tangentToEyeSpaceMatrix.js
var tangentToEyeSpaceMatrix_default = "/**\n * Creates a matrix that transforms vectors from tangent space to eye space.\n *\n * @name czm_tangentToEyeSpaceMatrix\n * @glslFunction\n *\n * @param {vec3} normalEC The normal vector in eye coordinates.\n * @param {vec3} tangentEC The tangent vector in eye coordinates.\n * @param {vec3} bitangentEC The bitangent vector in eye coordinates.\n *\n * @returns {mat3} The matrix that transforms from tangent space to eye space.\n *\n * @example\n * mat3 tangentToEye = czm_tangentToEyeSpaceMatrix(normalEC, tangentEC, bitangentEC);\n * vec3 normal = tangentToEye * texture2D(normalMap, st).xyz;\n */\nmat3 czm_tangentToEyeSpaceMatrix(vec3 normalEC, vec3 tangentEC, vec3 bitangentEC)\n{\n vec3 normal = normalize(normalEC);\n vec3 tangent = normalize(tangentEC);\n vec3 bitangent = normalize(bitangentEC);\n return mat3(tangent.x , tangent.y , tangent.z,\n bitangent.x, bitangent.y, bitangent.z,\n normal.x , normal.y , normal.z);\n}\n";
// Source/Shaders/Builtin/Functions/transformPlane.js
var transformPlane_default = "/**\n * Transforms a plane.\n * \n * @name czm_transformPlane\n * @glslFunction\n *\n * @param {vec4} plane The plane in Hessian Normal Form.\n * @param {mat4} transform The inverse-transpose of a transformation matrix.\n */\nvec4 czm_transformPlane(vec4 plane, mat4 transform) {\n vec4 transformedPlane = transform * plane;\n // Convert the transformed plane to Hessian Normal Form\n float normalMagnitude = length(transformedPlane.xyz);\n return transformedPlane / normalMagnitude;\n}\n";
// Source/Shaders/Builtin/Functions/translateRelativeToEye.js
var translateRelativeToEye_default = "/**\n * Translates a position (or any vec3) that was encoded with {@link EncodedCartesian3},\n * and then provided to the shader as separate high and low bits to\n * be relative to the eye. As shown in the example, the position can then be transformed in eye\n * or clip coordinates using {@link czm_modelViewRelativeToEye} or {@link czm_modelViewProjectionRelativeToEye},\n * respectively.\n *
\n * This technique, called GPU RTE, eliminates jittering artifacts when using large coordinates as\n * described in {@link http://help.agi.com/AGIComponents/html/BlogPrecisionsPrecisions.htm|Precisions, Precisions}.\n *
\n *\n * @name czm_translateRelativeToEye\n * @glslFunction\n *\n * @param {vec3} high The position's high bits.\n * @param {vec3} low The position's low bits.\n * @returns {vec3} The position translated to be relative to the camera's position.\n *\n * @example\n * attribute vec3 positionHigh;\n * attribute vec3 positionLow;\n *\n * void main()\n * {\n * vec4 p = czm_translateRelativeToEye(positionHigh, positionLow);\n * gl_Position = czm_modelViewProjectionRelativeToEye * p;\n * }\n *\n * @see czm_modelViewRelativeToEye\n * @see czm_modelViewProjectionRelativeToEye\n * @see czm_computePosition\n * @see EncodedCartesian3\n */\nvec4 czm_translateRelativeToEye(vec3 high, vec3 low)\n{\n vec3 highDifference = high - czm_encodedCameraPositionMCHigh;\n vec3 lowDifference = low - czm_encodedCameraPositionMCLow;\n\n return vec4(highDifference + lowDifference, 1.0);\n}\n";
// Source/Shaders/Builtin/Functions/translucentPhong.js
var translucentPhong_default = "/**\n * @private\n */\nvec4 czm_translucentPhong(vec3 toEye, czm_material material, vec3 lightDirectionEC)\n{\n // Diffuse from directional light sources at eye (for top-down and horizon views)\n float diffuse = czm_getLambertDiffuse(vec3(0.0, 0.0, 1.0), material.normal);\n\n if (czm_sceneMode == czm_sceneMode3D) {\n // (and horizon views in 3D)\n diffuse += czm_getLambertDiffuse(vec3(0.0, 1.0, 0.0), material.normal);\n }\n\n diffuse = clamp(diffuse, 0.0, 1.0);\n\n float specular = czm_getSpecular(lightDirectionEC, toEye, material.normal, material.shininess);\n\n // Temporary workaround for adding ambient.\n vec3 materialDiffuse = material.diffuse * 0.5;\n\n vec3 ambient = materialDiffuse;\n vec3 color = ambient + material.emission;\n color += materialDiffuse * diffuse * czm_lightColor;\n color += material.specular * specular * czm_lightColor;\n\n return vec4(color, material.alpha);\n}\n";
// Source/Shaders/Builtin/Functions/transpose.js
var transpose_default = "/**\n * Returns the transpose of the matrix. The input matrix can be\n * a mat2, mat3, or mat4.\n *\n * @name czm_transpose\n * @glslFunction\n *\n * @param {} matrix The matrix to transpose.\n *\n * @returns {} The transposed matrix.\n *\n * @example\n * // GLSL declarations\n * mat2 czm_transpose(mat2 matrix);\n * mat3 czm_transpose(mat3 matrix);\n * mat4 czm_transpose(mat4 matrix);\n *\n * // Transpose a 3x3 rotation matrix to find its inverse.\n * mat3 eastNorthUpToEye = czm_eastNorthUpToEyeCoordinates(\n * positionMC, normalEC);\n * mat3 eyeToEastNorthUp = czm_transpose(eastNorthUpToEye);\n */\nmat2 czm_transpose(mat2 matrix)\n{\n return mat2(\n matrix[0][0], matrix[1][0],\n matrix[0][1], matrix[1][1]);\n}\n\nmat3 czm_transpose(mat3 matrix)\n{\n return mat3(\n matrix[0][0], matrix[1][0], matrix[2][0],\n matrix[0][1], matrix[1][1], matrix[2][1],\n matrix[0][2], matrix[1][2], matrix[2][2]);\n}\n\nmat4 czm_transpose(mat4 matrix)\n{\n return mat4(\n matrix[0][0], matrix[1][0], matrix[2][0], matrix[3][0],\n matrix[0][1], matrix[1][1], matrix[2][1], matrix[3][1],\n matrix[0][2], matrix[1][2], matrix[2][2], matrix[3][2],\n matrix[0][3], matrix[1][3], matrix[2][3], matrix[3][3]);\n}\n";
// Source/Shaders/Builtin/Functions/unpackDepth.js
var unpackDepth_default = "/**\n * Unpacks a vec4 depth value to a float in [0, 1) range.\n *\n * @name czm_unpackDepth\n * @glslFunction\n *\n * @param {vec4} packedDepth The packed depth.\n *\n * @returns {float} The floating-point depth in [0, 1) range.\n */\n float czm_unpackDepth(vec4 packedDepth)\n {\n // See Aras Pranckevi\u010Dius' post Encoding Floats to RGBA\n // http://aras-p.info/blog/2009/07/30/encoding-floats-to-rgba-the-final/\n return dot(packedDepth, vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0));\n }\n";
// Source/Shaders/Builtin/Functions/unpackFloat.js
var unpackFloat_default = "/**\n * Unpack an IEEE 754 single-precision float that is packed as a little-endian unsigned normalized vec4.\n *\n * @name czm_unpackFloat\n * @glslFunction\n *\n * @param {vec4} packedFloat The packed float.\n *\n * @returns {float} The floating-point depth in arbitrary range.\n */\nfloat czm_unpackFloat(vec4 packedFloat)\n{\n // Convert to [0.0, 255.0] and round to integer\n packedFloat = floor(packedFloat * 255.0 + 0.5);\n float sign = 1.0 - step(128.0, packedFloat[3]) * 2.0;\n float exponent = 2.0 * mod(packedFloat[3], 128.0) + step(128.0, packedFloat[2]) - 127.0; \n if (exponent == -127.0)\n {\n return 0.0;\n }\n float mantissa = mod(packedFloat[2], 128.0) * 65536.0 + packedFloat[1] * 256.0 + packedFloat[0] + float(0x800000);\n float result = sign * exp2(exponent - 23.0) * mantissa;\n return result;\n}\n";
// Source/Shaders/Builtin/Functions/unpackUint.js
var unpackUint_default = "/**\n * Unpack unsigned integers of 1-4 bytes. in WebGL 1, there is no uint type,\n * so the return value is an int.\n *
\n * There are also precision limitations in WebGL 1. highp int is still limited\n * to 24 bits. Above the value of 2^24 = 16777216, precision loss may occur.\n *
\n *\n * @param {float|vec2|vec3|vec4} packed The packed value. For vectors, the components are listed in little-endian order.\n *\n * @return {int} The unpacked value.\n */\n int czm_unpackUint(float packedValue) {\n float rounded = czm_round(packedValue * 255.0);\n return int(rounded);\n }\n\n int czm_unpackUint(vec2 packedValue) {\n vec2 rounded = czm_round(packedValue * 255.0);\n return int(dot(rounded, vec2(1.0, 256.0)));\n }\n\n int czm_unpackUint(vec3 packedValue) {\n vec3 rounded = czm_round(packedValue * 255.0);\n return int(dot(rounded, vec3(1.0, 256.0, 65536.0)));\n }\n\n int czm_unpackUint(vec4 packedValue) {\n vec4 rounded = czm_round(packedValue * 255.0);\n return int(dot(rounded, vec4(1.0, 256.0, 65536.0, 16777216.0)));\n }\n";
// Source/Shaders/Builtin/Functions/valueTransform.js
var valueTransform_default = "/**\n * Transform metadata values following the EXT_structural_metadata spec\n * by multiplying by scale and adding the offset. Operations are always\n * performed component-wise, even for matrices.\n * \n * @param {float|vec2|vec3|vec4|mat2|mat3|mat4} offset The offset to add\n * @param {float|vec2|vec3|vec4|mat2|mat3|mat4} scale The scale factor to multiply\n * @param {float|vec2|vec3|vec4|mat2|mat3|mat4} value The original value.\n *\n * @return {float|vec2|vec3|vec4|mat2|mat3|mat4} The transformed value of the same scalar/vector/matrix type as the input.\n */\nfloat czm_valueTransform(float offset, float scale, float value) {\n return scale * value + offset;\n}\n\nvec2 czm_valueTransform(vec2 offset, vec2 scale, vec2 value) {\n return scale * value + offset;\n}\n\nvec3 czm_valueTransform(vec3 offset, vec3 scale, vec3 value) {\n return scale * value + offset;\n}\n\nvec4 czm_valueTransform(vec4 offset, vec4 scale, vec4 value) {\n return scale * value + offset;\n}\n\nmat2 czm_valueTransform(mat2 offset, mat2 scale, mat2 value) {\n return matrixCompMult(scale, value) + offset;\n}\n\nmat3 czm_valueTransform(mat3 offset, mat3 scale, mat3 value) {\n return matrixCompMult(scale, value) + offset;\n}\n\nmat4 czm_valueTransform(mat4 offset, mat4 scale, mat4 value) {\n return matrixCompMult(scale, value) + offset;\n}\n";
// Source/Shaders/Builtin/Functions/vertexLogDepth.js
var vertexLogDepth_default = "#ifdef LOG_DEPTH\n// 1.0 at the near plane, increasing linearly from there.\nvarying float v_depthFromNearPlusOne;\n#ifdef SHADOW_MAP\nvarying vec3 v_logPositionEC;\n#endif\n#endif\n\nvec4 czm_updatePositionDepth(vec4 coords) {\n#if defined(LOG_DEPTH)\n\n#ifdef SHADOW_MAP\n vec3 logPositionEC = (czm_inverseProjection * coords).xyz;\n v_logPositionEC = logPositionEC;\n#endif\n\n // With the very high far/near ratios used with the logarithmic depth\n // buffer, floating point rounding errors can cause linear depth values\n // to end up on the wrong side of the far plane, even for vertices that\n // are really nowhere near it. Since we always write a correct logarithmic\n // depth value in the fragment shader anyway, we just need to make sure\n // such errors don't cause the primitive to be clipped entirely before\n // we even get to the fragment shader.\n coords.z = clamp(coords.z / coords.w, -1.0, 1.0) * coords.w;\n#endif\n\n return coords;\n}\n\n/**\n * Writes the logarithmic depth to gl_Position using the already computed gl_Position.\n *\n * @name czm_vertexLogDepth\n * @glslFunction\n */\nvoid czm_vertexLogDepth()\n{\n#ifdef LOG_DEPTH\n v_depthFromNearPlusOne = (gl_Position.w - czm_currentFrustum.x) + 1.0;\n gl_Position = czm_updatePositionDepth(gl_Position);\n#endif\n}\n\n/**\n * Writes the logarithmic depth to gl_Position using the provided clip coordinates.\n *
\n * An example use case for this function would be moving the vertex in window coordinates\n * before converting back to clip coordinates. Use the original vertex clip coordinates.\n *
\n * @name czm_vertexLogDepth\n * @glslFunction\n *\n * @param {vec4} clipCoords The vertex in clip coordinates.\n *\n * @example\n * czm_vertexLogDepth(czm_projection * vec4(positionEyeCoordinates, 1.0));\n */\nvoid czm_vertexLogDepth(vec4 clipCoords)\n{\n#ifdef LOG_DEPTH\n v_depthFromNearPlusOne = (clipCoords.w - czm_currentFrustum.x) + 1.0;\n czm_updatePositionDepth(clipCoords);\n#endif\n}\n";
// Source/Shaders/Builtin/Functions/windowToEyeCoordinates.js
var windowToEyeCoordinates_default = "/**\n * Transforms a position from window to eye coordinates.\n * The transform from window to normalized device coordinates is done using components\n * of (@link czm_viewport} and {@link czm_viewportTransformation} instead of calculating\n * the inverse of czm_viewportTransformation. The transformation from\n * normalized device coordinates to clip coordinates is done using fragmentCoordinate.w,\n * which is expected to be the scalar used in the perspective divide. The transformation\n * from clip to eye coordinates is done using {@link czm_inverseProjection}.\n *\n * @name czm_windowToEyeCoordinates\n * @glslFunction\n *\n * @param {vec4} fragmentCoordinate The position in window coordinates to transform.\n *\n * @returns {vec4} The transformed position in eye coordinates.\n *\n * @see czm_modelToWindowCoordinates\n * @see czm_eyeToWindowCoordinates\n * @see czm_inverseProjection\n * @see czm_viewport\n * @see czm_viewportTransformation\n *\n * @example\n * vec4 positionEC = czm_windowToEyeCoordinates(gl_FragCoord);\n */\nvec4 czm_windowToEyeCoordinates(vec4 fragmentCoordinate)\n{\n // Reconstruct NDC coordinates\n float x = 2.0 * (fragmentCoordinate.x - czm_viewport.x) / czm_viewport.z - 1.0;\n float y = 2.0 * (fragmentCoordinate.y - czm_viewport.y) / czm_viewport.w - 1.0;\n float z = (fragmentCoordinate.z - czm_viewportTransformation[3][2]) / czm_viewportTransformation[2][2];\n vec4 q = vec4(x, y, z, 1.0);\n\n // Reverse the perspective division to obtain clip coordinates.\n q /= fragmentCoordinate.w;\n\n // Reverse the projection transformation to obtain eye coordinates.\n if (!(czm_inverseProjection == mat4(0.0))) // IE and Edge sometimes do something weird with != between mat4s\n {\n q = czm_inverseProjection * q;\n }\n else\n {\n float top = czm_frustumPlanes.x;\n float bottom = czm_frustumPlanes.y;\n float left = czm_frustumPlanes.z;\n float right = czm_frustumPlanes.w;\n\n float near = czm_currentFrustum.x;\n float far = czm_currentFrustum.y;\n\n q.x = (q.x * (right - left) + left + right) * 0.5;\n q.y = (q.y * (top - bottom) + bottom + top) * 0.5;\n q.z = (q.z * (near - far) - near - far) * 0.5;\n q.w = 1.0;\n }\n\n return q;\n}\n\n/**\n * Transforms a position given as window x/y and a depth or a log depth from window to eye coordinates.\n * This function produces more accurate results for window positions with log depth than\n * conventionally unpacking the log depth using czm_reverseLogDepth and using the standard version\n * of czm_windowToEyeCoordinates.\n *\n * @name czm_windowToEyeCoordinates\n * @glslFunction\n *\n * @param {vec2} fragmentCoordinateXY The XY position in window coordinates to transform.\n * @param {float} depthOrLogDepth A depth or log depth for the fragment.\n *\n * @see czm_modelToWindowCoordinates\n * @see czm_eyeToWindowCoordinates\n * @see czm_inverseProjection\n * @see czm_viewport\n * @see czm_viewportTransformation\n *\n * @returns {vec4} The transformed position in eye coordinates.\n */\nvec4 czm_windowToEyeCoordinates(vec2 fragmentCoordinateXY, float depthOrLogDepth)\n{\n // See reverseLogDepth.glsl. This is separate to re-use the pow.\n#ifdef LOG_DEPTH\n float near = czm_currentFrustum.x;\n float far = czm_currentFrustum.y;\n float log2Depth = depthOrLogDepth * czm_log2FarDepthFromNearPlusOne;\n float depthFromNear = pow(2.0, log2Depth) - 1.0;\n float depthFromCamera = depthFromNear + near;\n vec4 windowCoord = vec4(fragmentCoordinateXY, far * (1.0 - near / depthFromCamera) / (far - near), 1.0);\n vec4 eyeCoordinate = czm_windowToEyeCoordinates(windowCoord);\n eyeCoordinate.w = 1.0 / depthFromCamera; // Better precision\n return eyeCoordinate;\n#else\n vec4 windowCoord = vec4(fragmentCoordinateXY, depthOrLogDepth, 1.0);\n vec4 eyeCoordinate = czm_windowToEyeCoordinates(windowCoord);\n#endif\n return eyeCoordinate;\n}\n";
// Source/Shaders/Builtin/Functions/writeDepthClamp.js
var writeDepthClamp_default = "// emulated noperspective\n#if defined(GL_EXT_frag_depth) && !defined(LOG_DEPTH)\nvarying float v_WindowZ;\n#endif\n\n/**\n * Emulates GL_DEPTH_CLAMP. Clamps a fragment to the near and far plane\n * by writing the fragment's depth. See czm_depthClamp for more details.\n *
\n * The shader must enable the GL_EXT_frag_depth extension.\n *
\n * Use this when the vertex shader does not call {@link czm_vertexlogDepth}, for example, when\n * ray-casting geometry using a full screen quad.\n *
\n * @name czm_writeLogDepth\n * @glslFunction\n *\n * @param {float} depth The depth coordinate, where 1.0 is on the near plane and\n * depth increases in eye-space units from there\n *\n * @example\n * czm_writeLogDepth((czm_projection * v_positionEyeCoordinates).w + 1.0);\n */\nvoid czm_writeLogDepth(float depth)\n{\n#if defined(GL_EXT_frag_depth) && defined(LOG_DEPTH)\n // Discard the vertex if it's not between the near and far planes.\n // We allow a bit of epsilon on the near plane comparison because a 1.0\n // from the vertex shader (indicating the vertex should be _on_ the near\n // plane) will not necessarily come here as exactly 1.0.\n if (depth <= 0.9999999 || depth > czm_farDepthFromNearPlusOne) {\n discard;\n }\n\n#ifdef POLYGON_OFFSET\n // Polygon offset: m * factor + r * units\n float factor = u_polygonOffset[0];\n float units = u_polygonOffset[1];\n\n // If we can't compute derivatives, just leave out the factor I guess?\n#ifdef GL_OES_standard_derivatives\n // m = sqrt(dZdX^2 + dZdY^2);\n float x = dFdx(depth);\n float y = dFdy(depth);\n float m = sqrt(x * x + y * y);\n\n // Apply the factor before computing the log depth.\n depth += m * factor;\n#endif\n\n#endif\n\n gl_FragDepthEXT = log2(depth) * czm_oneOverLog2FarDepthFromNearPlusOne;\n\n#ifdef POLYGON_OFFSET\n // Apply the units after the log depth.\n gl_FragDepthEXT += czm_epsilon7 * units;\n#endif\n\n#endif\n}\n\n/**\n * Writes the fragment depth to the logarithmic depth buffer.\n *
\n * Use this when the vertex shader calls {@link czm_vertexlogDepth}.\n *
\n *\n * @name czm_writeLogDepth\n * @glslFunction\n */\nvoid czm_writeLogDepth() {\n#ifdef LOG_DEPTH\n czm_writeLogDepth(v_depthFromNearPlusOne);\n#endif\n}\n";
// Source/Shaders/Builtin/Functions/writeNonPerspective.js
var writeNonPerspective_default = "/**\n * Transforms a value for non-perspective interpolation by multiplying\n * it by w, the value used in the perspective divide. This function is\n * intended to be called in a vertex shader to compute the value of a\n * `varying` that should not be subject to perspective interpolation.\n * For example, screen-space texture coordinates. The fragment shader\n * must call {@link czm_readNonPerspective} to retrieve the final\n * non-perspective value.\n *\n * @name czm_writeNonPerspective\n * @glslFunction\n *\n * @param {float|vec2|vec3|vec4} value The value to be interpolated without accounting for perspective.\n * @param {float} w The perspective divide value. Usually this is the computed `gl_Position.w`.\n * @returns {float|vec2|vec3|vec4} The transformed value, intended to be stored in a `varying` and read in the\n * fragment shader with {@link czm_readNonPerspective}.\n */\nfloat czm_writeNonPerspective(float value, float w) {\n return value * w;\n}\n\nvec2 czm_writeNonPerspective(vec2 value, float w) {\n return value * w;\n}\n\nvec3 czm_writeNonPerspective(vec3 value, float w) {\n return value * w;\n}\n\nvec4 czm_writeNonPerspective(vec4 value, float w) {\n return value * w;\n}\n";
// Source/Shaders/Builtin/Functions/XYZToRGB.js
var XYZToRGB_default = "/**\n * Converts a CIE Yxy color to RGB.\n *
The conversion is described in\n * {@link http://content.gpwiki.org/index.php/D3DBook:High-Dynamic_Range_Rendering#Luminance_Transform|Luminance Transform}\n *
';
for (const key in properties2) {
if (properties2.hasOwnProperty(key)) {
const value = properties2[key];
if (defined_default(value)) {
if (typeof value === "object") {
html += `