three-loader-3dtiles.min.js 232 KB

12345678910111213141516
  1. !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("three"),require("three/examples/jsm/loaders/GLTFLoader.js"),require("three/examples/jsm/loaders/DRACOLoader.js"),require("three/examples/jsm/loaders/KTX2Loader.js")):"function"==typeof define&&define.amd?define(["exports","three","three/examples/jsm/loaders/GLTFLoader.js","three/examples/jsm/loaders/DRACOLoader.js","three/examples/jsm/loaders/KTX2Loader.js"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).ThreeLoader3DTiles={},t.THREE,t.THREE,t.THREE,t.THREE)}(this,(function(t,e,r,n,s){"use strict";
  2. /*! *****************************************************************************
  3. Copyright (c) Microsoft Corporation.
  4. Permission to use, copy, modify, and/or distribute this software for any
  5. purpose with or without fee is hereby granted.
  6. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
  7. REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  8. AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
  9. INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  10. LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  11. OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  12. PERFORMANCE OF THIS SOFTWARE.
  13. ***************************************************************************** */function i(t,e,r,n){return new(r||(r=Promise))((function(s,i){function o(t){try{c(n.next(t))}catch(t){i(t)}}function a(t){try{c(n.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?s(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(o,a)}c((n=n.apply(t,e||[])).next())}))}function o(t,e){if(!t)throw new Error(e||"loader assertion failed.")}const a=Boolean("object"!=typeof process||"[object process]"!==String(process)||process.browser),c="undefined"!=typeof process&&process.version&&/v([0-9]*)/.exec(process.version);c&&parseFloat(c[1]);function u(t,e){if(!t)throw new Error(e||"loaders.gl assertion failed.")}const l={self:"undefined"!=typeof self&&self,window:"undefined"!=typeof window&&window,global:"undefined"!=typeof global&&global,document:"undefined"!=typeof document&&document},h=l.global||l.self||l.window||{},d="object"!=typeof process||"[object process]"!==String(process)||process.browser,f="function"==typeof importScripts,A="undefined"!=typeof window&&void 0!==window.orientation,m="undefined"!=typeof process&&process.version&&/v([0-9]*)/.exec(process.version);function p(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}m&&parseFloat(m[1]);class B{constructor(t,e){p(this,"name",void 0),p(this,"workerThread",void 0),p(this,"isRunning",void 0),p(this,"result",void 0),p(this,"_resolve",void 0),p(this,"_reject",void 0),this.name=t,this.workerThread=e,this.isRunning=!0,this._resolve=()=>{},this._reject=()=>{},this.result=new Promise(((t,e)=>{this._resolve=t,this._reject=e}))}postMessage(t,e){this.workerThread.postMessage({source:"loaders.gl",type:t,payload:e})}done(t){u(this.isRunning),this.isRunning=!1,this._resolve(t)}error(t){u(this.isRunning),this.isRunning=!1,this._reject(t)}}const g=new Map;function y(t){u(t.source&&!t.url||!t.source&&t.url);let e=g.get(t.source||t.url);return e||(t.url&&(e=function(t){if(!t.startsWith("http"))return t;return C((e=t,"try {\n importScripts('".concat(e,"');\n} catch (error) {\n console.error(error);\n throw error;\n}")));var e}(t.url),g.set(t.url,e)),t.source&&(e=C(t.source),g.set(t.source,e))),u(e),e}function C(t){const e=new Blob([t],{type:"application/javascript"});return URL.createObjectURL(e)}function b(t,e=!0,r){const n=r||new Set;if(t){if(w(t))n.add(t);else if(w(t.buffer))n.add(t.buffer);else if(ArrayBuffer.isView(t));else if(e&&"object"==typeof t)for(const r in t)b(t[r],e,n)}else;return void 0===r?Array.from(n):[]}function w(t){return!!t&&(t instanceof ArrayBuffer||("undefined"!=typeof MessagePort&&t instanceof MessagePort||("undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap||"undefined"!=typeof OffscreenCanvas&&t instanceof OffscreenCanvas)))}const T=()=>{};class E{static isSupported(){return"undefined"!=typeof Worker}constructor(t){p(this,"name",void 0),p(this,"source",void 0),p(this,"url",void 0),p(this,"terminated",!1),p(this,"worker",void 0),p(this,"onMessage",void 0),p(this,"onError",void 0),p(this,"_loadableURL","");const{name:e,source:r,url:n}=t;u(r||n),this.name=e,this.source=r,this.url=n,this.onMessage=T,this.onError=t=>console.log(t),this.worker=this._createBrowserWorker()}destroy(){this.onMessage=T,this.onError=T,this.worker.terminate(),this.terminated=!0}get isRunning(){return Boolean(this.onMessage)}postMessage(t,e){e=e||b(t),this.worker.postMessage(t,e)}_getErrorFromErrorEvent(t){let e="Failed to load ";return e+="worker ".concat(this.name," from ").concat(this.url,". "),t.message&&(e+="".concat(t.message," in ")),t.lineno&&(e+=":".concat(t.lineno,":").concat(t.colno)),new Error(e)}_createBrowserWorker(){this._loadableURL=y({source:this.source,url:this.url});const t=new Worker(this._loadableURL,{name:this.name});return t.onmessage=t=>{t.data?this.onMessage(t.data):this.onError(new Error("No data received"))},t.onerror=t=>{this.onError(this._getErrorFromErrorEvent(t)),this.terminated=!0},t.onmessageerror=t=>console.error(t),t}}class M{constructor(t){p(this,"name","unnamed"),p(this,"source",void 0),p(this,"url",void 0),p(this,"maxConcurrency",1),p(this,"maxMobileConcurrency",1),p(this,"onDebug",(()=>{})),p(this,"reuseWorkers",!0),p(this,"props",{}),p(this,"jobQueue",[]),p(this,"idleQueue",[]),p(this,"count",0),p(this,"isDestroyed",!1),this.source=t.source,this.url=t.url,this.setProps(t)}destroy(){this.idleQueue.forEach((t=>t.destroy())),this.isDestroyed=!0}setProps(t){this.props={...this.props,...t},void 0!==t.name&&(this.name=t.name),void 0!==t.maxConcurrency&&(this.maxConcurrency=t.maxConcurrency),void 0!==t.maxMobileConcurrency&&(this.maxMobileConcurrency=t.maxMobileConcurrency),void 0!==t.reuseWorkers&&(this.reuseWorkers=t.reuseWorkers),void 0!==t.onDebug&&(this.onDebug=t.onDebug)}async startJob(t,e=((t,e,r)=>t.done(r)),r=((t,e)=>t.error(e))){const n=new Promise((n=>(this.jobQueue.push({name:t,onMessage:e,onError:r,onStart:n}),this)));return this._startQueuedJob(),await n}async _startQueuedJob(){if(!this.jobQueue.length)return;const t=this._getAvailableWorker();if(!t)return;const e=this.jobQueue.shift();if(e){this.onDebug({message:"Starting job",name:e.name,workerThread:t,backlog:this.jobQueue.length});const r=new B(e.name,t);t.onMessage=t=>e.onMessage(r,t.type,t.payload),t.onError=t=>e.onError(r,t),e.onStart(r);try{await r.result}finally{this.returnWorkerToQueue(t)}}}returnWorkerToQueue(t){this.isDestroyed||!this.reuseWorkers||this.count>this._getMaxConcurrency()?(t.destroy(),this.count--):this.idleQueue.push(t),this.isDestroyed||this._startQueuedJob()}_getAvailableWorker(){if(this.idleQueue.length>0)return this.idleQueue.shift()||null;if(this.count<this._getMaxConcurrency()){this.count++;const t="".concat(this.name.toLowerCase()," (#").concat(this.count," of ").concat(this.maxConcurrency,")");return new E({name:t,source:this.source,url:this.url})}return null}_getMaxConcurrency(){return A?this.maxMobileConcurrency:this.maxConcurrency}}const v={maxConcurrency:3,maxMobileConcurrency:1,onDebug:()=>{},reuseWorkers:!0};class I{static isSupported(){return E.isSupported()}static getWorkerFarm(t={}){return I._workerFarm=I._workerFarm||new I({}),I._workerFarm.setProps(t),I._workerFarm}constructor(t){p(this,"props",void 0),p(this,"workerPools",new Map),this.props={...v},this.setProps(t),this.workerPools=new Map}destroy(){for(const t of this.workerPools.values())t.destroy()}setProps(t){this.props={...this.props,...t};for(const t of this.workerPools.values())t.setProps(this._getWorkerPoolProps())}getWorkerPool(t){const{name:e,source:r,url:n}=t;let s=this.workerPools.get(e);return s||(s=new M({name:e,source:r,url:n}),s.setProps(this._getWorkerPoolProps()),this.workerPools.set(e,s)),s}_getWorkerPoolProps(){return{maxConcurrency:this.props.maxConcurrency,maxMobileConcurrency:this.props.maxMobileConcurrency,reuseWorkers:this.props.reuseWorkers,onDebug:this.props.onDebug}}}p(I,"_workerFarm",void 0);var _={},F=Object.freeze(Object.assign(Object.create(null),_,{default:_}));const D="3.1.4",G={};async function R(t,e=null,r={}){return e&&(t=function(t,e,r){if(t.startsWith("http"))return t;const n=r.modules||{};if(n[t])return n[t];if(!d)return"modules/".concat(e,"/dist/libs/").concat(t);if(r.CDN)return u(r.CDN.startsWith("http")),"".concat(r.CDN,"/").concat(e,"@").concat(D,"/dist/libs/").concat(t);if(f)return"../src/libs/".concat(t);return"modules/".concat(e,"/src/libs/").concat(t)}(t,e,r)),G[t]=G[t]||async function(t){if(t.endsWith("wasm")){const e=await fetch(t);return await e.arrayBuffer()}if(!d)try{return F&&_.requireFromFile&&await _.requireFromFile(t)}catch{return null}if(f)return importScripts(t);const e=await fetch(t);return function(t,e){if(!d)return _.requireFromString&&_.requireFromString(t,e);if(f)return eval.call(h,t),null;const r=document.createElement("script");r.id=e;try{r.appendChild(document.createTextNode(t))}catch(e){r.text=t}return document.body.appendChild(r),null}(await e.text(),t)}(t),await G[t]}async function S(t,e,r,n,s){const i=t.id,o=function(t,e={}){const r=e[t.id]||{},n="".concat(t.id,"-worker.js");let s=r.workerUrl;if(s||"compression"!==t.id||(s=e.workerUrl),"test"===e._workerType&&(s="modules/".concat(t.module,"/dist/").concat(n)),!s){let e=t.version;"latest"===e&&(e="latest");const r=e?"@".concat(e):"";s="https://unpkg.com/@loaders.gl/".concat(t.module).concat(r,"/dist/").concat(n)}return u(s),s}(t,r),a=I.getWorkerFarm(r).getWorkerPool({name:i,url:o});r=JSON.parse(JSON.stringify(r));const c=await a.startJob("process-on-worker",O.bind(null,s));c.postMessage("process",{input:e,options:r});const l=await c.result;return await l.result}async function O(t,e,r,n){switch(r){case"done":e.done(n);break;case"error":e.error(new Error(n.error));break;case"process":const{id:s,input:i,options:o}=n;try{const r=await t(i,o);e.postMessage("done",{id:s,result:r})}catch(t){const r=t instanceof Error?t.message:"unknown error";e.postMessage("error",{id:s,error:r})}break;default:console.warn("parse-with-worker unknown message ".concat(r))}}function x(t,e,r){if(t.byteLength<=e+r)return"";const n=new DataView(t);let s="";for(let t=0;t<r;t++)s+=String.fromCharCode(n.getUint8(e+t));return s}function U(t){try{return JSON.parse(t)}catch(e){throw new Error('Failed to parse JSON from data starting with "'.concat(function(t,e=5){if("string"==typeof t)return t.slice(0,e);if(ArrayBuffer.isView(t))return x(t.buffer,t.byteOffset,e);if(t instanceof ArrayBuffer)return x(t,0,e);return""}(t),'"'))}}function L(t){return t&&"object"==typeof t&&t.isBuffer}function N(t){if(L(t))return function(t){if(L(t))return new Uint8Array(t.buffer,t.byteOffset,t.length).slice().buffer;return t}(t);if(t instanceof ArrayBuffer)return t;if(ArrayBuffer.isView(t))return 0===t.byteOffset&&t.byteLength===t.buffer.byteLength?t.buffer:t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength);if("string"==typeof t){const e=t;return(new TextEncoder).encode(e).buffer}if(t&&"object"==typeof t&&t._toArrayBuffer)return t._toArrayBuffer();throw new Error("toArrayBuffer")}function H(t,e,r){const n=void 0!==r?new Uint8Array(t).subarray(e,e+r):new Uint8Array(t).subarray(e);return new Uint8Array(n).buffer}function J(t,e){return o(t>=0),o(e>0),t+(e-1)&~(e-1)}function P(t,e,r){let n;if(t instanceof ArrayBuffer)n=new Uint8Array(t);else{const e=t.byteOffset,r=t.byteLength;n=new Uint8Array(t.buffer||t.arrayBuffer,e,r)}return e.set(n,r),r+J(n.byteLength,4)}async function j(t){const e=[];for await(const r of t)e.push(r);return function(...t){const e=t.map((t=>t instanceof ArrayBuffer?new Uint8Array(t):t)),r=e.reduce(((t,e)=>t+e.byteLength),0),n=new Uint8Array(r);let s=0;for(const t of e)n.set(t,s),s+=t.byteLength;return n.buffer}(...e)}function k(){let t;if("undefined"!=typeof window&&window.performance)t=window.performance.now();else if("undefined"!=typeof process&&process.hrtime){const e=process.hrtime();t=1e3*e[0]+e[1]/1e6}else t=Date.now();return t}class V{constructor(t,e){p(this,"name",void 0),p(this,"type",void 0),p(this,"sampleSize",1),p(this,"time",void 0),p(this,"count",void 0),p(this,"samples",void 0),p(this,"lastTiming",void 0),p(this,"lastSampleTime",void 0),p(this,"lastSampleCount",void 0),p(this,"_count",0),p(this,"_time",0),p(this,"_samples",0),p(this,"_startTime",0),p(this,"_timerPending",!1),this.name=t,this.type=e,this.reset()}setSampleSize(t){return this.sampleSize=t,this}incrementCount(){return this.addCount(1),this}decrementCount(){return this.subtractCount(1),this}addCount(t){return this._count+=t,this._samples++,this._checkSampling(),this}subtractCount(t){return this._count-=t,this._samples++,this._checkSampling(),this}addTime(t){return this._time+=t,this.lastTiming=t,this._samples++,this._checkSampling(),this}timeStart(){return this._startTime=k(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(k()-this._startTime),this._timerPending=!1,this._checkSampling(),this):this}getSampleAverageCount(){return this.sampleSize>0?this.lastSampleCount/this.sampleSize:0}getSampleAverageTime(){return this.sampleSize>0?this.lastSampleTime/this.sampleSize:0}getSampleHz(){return this.lastSampleTime>0?this.sampleSize/(this.lastSampleTime/1e3):0}getAverageCount(){return this.samples>0?this.count/this.samples:0}getAverageTime(){return this.samples>0?this.time/this.samples:0}getHz(){return this.time>0?this.samples/(this.time/1e3):0}reset(){return this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this}_checkSampling(){this._samples===this.sampleSize&&(this.lastSampleTime=this._time,this.lastSampleCount=this._count,this.count+=this._count,this.time+=this._time,this.samples+=this._samples,this._time=0,this._count=0,this._samples=0)}}class K{constructor(t){p(this,"id",void 0),p(this,"stats",{}),this.id=t.id,this.stats={},this._initializeStats(t.stats),Object.seal(this)}get(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"count";return this._getOrCreate({name:t,type:e})}get size(){return Object.keys(this.stats).length}reset(){for(const t in this.stats)this.stats[t].reset();return this}forEach(t){for(const e in this.stats)t(this.stats[e])}getTable(){const t={};return this.forEach((e=>{t[e.name]={time:e.time||0,count:e.count||0,average:e.getAverageTime()||0,hz:e.getHz()||0}})),t}_initializeStats(){(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).forEach((t=>this._getOrCreate(t)))}_getOrCreate(t){if(!t||!t.name)return null;const{name:e,type:r}=t;return this.stats[e]||(this.stats[e]=t instanceof V?t:new V(e,r)),this.stats[e]}}const Q={id:"request-scheduler",throttleRequests:!0,maxRequests:6};class q{constructor(t={}){p(this,"props",void 0),p(this,"stats",void 0),p(this,"activeRequestCount",0),p(this,"requestQueue",[]),p(this,"requestMap",new Map),p(this,"deferredUpdate",null),this.props={...Q,...t},this.stats=new K({id:this.props.id}),this.stats.get("Queued Requests"),this.stats.get("Active Requests"),this.stats.get("Cancelled Requests"),this.stats.get("Queued Requests Ever"),this.stats.get("Active Requests Ever")}scheduleRequest(t,e=(()=>0)){if(!this.props.throttleRequests)return Promise.resolve({done:()=>{}});if(this.requestMap.has(t))return this.requestMap.get(t);const r={handle:t,priority:0,getPriority:e},n=new Promise((t=>(r.resolve=t,r)));return this.requestQueue.push(r),this.requestMap.set(t,n),this._issueNewRequests(),n}_issueRequest(t){const{handle:e,resolve:r}=t;let n=!1;const s=()=>{n||(n=!0,this.requestMap.delete(e),this.activeRequestCount--,this._issueNewRequests())};return this.activeRequestCount++,r?r({done:s}):Promise.resolve({done:s})}_issueNewRequests(){this.deferredUpdate||(this.deferredUpdate=setTimeout((()=>this._issueNewRequestsAsync()),0))}_issueNewRequestsAsync(){this.deferredUpdate=null;const t=Math.max(this.props.maxRequests-this.activeRequestCount,0);if(0!==t){this._updateAllRequests();for(let e=0;e<t;++e){const t=this.requestQueue.shift();t&&this._issueRequest(t)}}}_updateAllRequests(){const t=this.requestQueue;for(let e=0;e<t.length;++e){const r=t[e];this._updateRequest(r)||(t.splice(e,1),this.requestMap.delete(r.handle),e--)}t.sort(((t,e)=>t.priority-e.priority))}_updateRequest(t){return t.priority=t.getPriority(t.handle),!(t.priority<0)||(t.resolve(null),!1)}}const z={};function W(t){const e=t&&t.lastIndexOf("/");return e>=0?t.substr(0,e):""}const Y=t=>"function"==typeof t,X=t=>null!==t&&"object"==typeof t,Z=t=>X(t)&&t.constructor==={}.constructor,$=t=>"undefined"!=typeof Response&&t instanceof Response||t&&t.arrayBuffer&&t.text&&t.json,tt=t=>"undefined"!=typeof Blob&&t instanceof Blob,et=t=>(t=>"undefined"!=typeof ReadableStream&&t instanceof ReadableStream||X(t)&&Y(t.tee)&&Y(t.cancel)&&Y(t.getReader))(t)||(t=>X(t)&&Y(t.read)&&Y(t.pipe)&&(t=>"boolean"==typeof t)(t.readable))(t),rt=/^data:([-\w.]+\/[-\w.+]+)(;|,)/,nt=/^([-\w.]+\/[-\w.+]+)/;function st(t){const e=nt.exec(t);return e?e[1]:t}function it(t){const e=rt.exec(t);return e?e[1]:""}const ot=/\?.*/;function at(t){if($(t)){const e=ct(t.url||"");return{url:e,type:st(t.headers.get("content-type")||"")||it(e)}}return tt(t)?{url:ct(t.name||""),type:t.type||""}:"string"==typeof t?{url:ct(t),type:it(t)}:{url:"",type:""}}function ct(t){return t.replace(ot,"")}async function ut(t){if($(t))return t;const e={},r=function(t){return $(t)?t.headers["content-length"]||-1:tt(t)?t.size:"string"==typeof t?t.length:t instanceof ArrayBuffer||ArrayBuffer.isView(t)?t.byteLength:-1}(t);r>=0&&(e["content-length"]=String(r));const{url:n,type:s}=at(t);s&&(e["content-type"]=s);const i=await async function(t){const e=5;if("string"==typeof t)return"data:,".concat(t.slice(0,e));if(t instanceof Blob){const e=t.slice(0,5);return await new Promise((t=>{const r=new FileReader;r.onload=e=>{var r;return t(null==e||null===(r=e.target)||void 0===r?void 0:r.result)},r.readAsDataURL(e)}))}if(t instanceof ArrayBuffer){const r=function(t){let e="";const r=new Uint8Array(t);for(let t=0;t<r.byteLength;t++)e+=String.fromCharCode(r[t]);return btoa(e)}(t.slice(0,e));return"data:base64,".concat(r)}return null}(t);i&&(e["x-first-bytes"]=i),"string"==typeof t&&(t=(new TextEncoder).encode(t));const o=new Response(t,{headers:e});return Object.defineProperty(o,"url",{value:n}),o}async function lt(t,e){if("string"==typeof t){t=function(t){for(const e in z)if(t.startsWith(e)){const r=z[e];t=t.replace(e,r)}return t.startsWith("http://")||t.startsWith("https://")||(t="".concat("").concat(t)),t}(t);let r=e;return null!=e&&e.fetch&&"function"!=typeof(null==e?void 0:e.fetch)&&(r=e.fetch),await fetch(t,r)}return await ut(t)}function ht(){return!("object"==typeof process&&"[object process]"===String(process)&&!process.browser)||function(t){if("undefined"!=typeof window&&"object"==typeof window.process&&"renderer"===window.process.type)return!0;if("undefined"!=typeof process&&"object"==typeof process.versions&&Boolean(process.versions.electron))return!0;const e="object"==typeof navigator&&"string"==typeof navigator.userAgent&&navigator.userAgent,r=t||e;return!!(r&&r.indexOf("Electron")>=0)}()}const dt={self:"undefined"!=typeof self&&self,window:"undefined"!=typeof window&&window,global:"undefined"!=typeof global&&global,document:"undefined"!=typeof document&&document,process:"object"==typeof process&&process},ft=dt.window||dt.self||dt.global,At=dt.process||{},mt="undefined"!=typeof __VERSION__?__VERSION__:"untranspiled source";ht();class pt{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"sessionStorage";p(this,"storage",void 0),p(this,"id",void 0),p(this,"config",{}),this.storage=function(t){try{const e=window[t],r="__storage_test__";return e.setItem(r,r),e.removeItem(r),e}catch(t){return null}}(r),this.id=t,this.config={},Object.assign(this.config,e),this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(t){return this.config={},this.updateConfiguration(t)}updateConfiguration(t){if(Object.assign(this.config,t),this.storage){const t=JSON.stringify(this.config);this.storage.setItem(this.id,t)}return this}_loadConfiguration(){let t={};if(this.storage){const e=this.storage.getItem(this.id);t=e?JSON.parse(e):{}}return Object.assign(this.config,t),this}}function Bt(t,e,r){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:600;const s=t.src.replace(/\(/g,"%28").replace(/\)/g,"%29");t.width>n&&(r=Math.min(r,n/t.width));const i=t.width*r,o=t.height*r,a=["font-size:1px;","padding:".concat(Math.floor(o/2),"px ").concat(Math.floor(i/2),"px;"),"line-height:".concat(o,"px;"),"background:url(".concat(s,");"),"background-size:".concat(i,"px ").concat(o,"px;"),"color:transparent;"].join("");return["".concat(e," %c+"),a]}let gt;function yt(t){return"string"==typeof t?gt[t.toUpperCase()]||gt.WHITE:t}function Ct(t,e){if(!t)throw new Error(e||"Assertion failed")}function bt(){let t;var e,r;if(ht&&"performance"in ft)t=null==ft||null===(e=ft.performance)||void 0===e||null===(r=e.now)||void 0===r?void 0:r.call(e);else if("hrtime"in At){var n;const e=null==At||null===(n=At.hrtime)||void 0===n?void 0:n.call(At);t=1e3*e[0]+e[1]/1e6}else t=Date.now();return t}!function(t){t[t.BLACK=30]="BLACK",t[t.RED=31]="RED",t[t.GREEN=32]="GREEN",t[t.YELLOW=33]="YELLOW",t[t.BLUE=34]="BLUE",t[t.MAGENTA=35]="MAGENTA",t[t.CYAN=36]="CYAN",t[t.WHITE=37]="WHITE",t[t.BRIGHT_BLACK=90]="BRIGHT_BLACK",t[t.BRIGHT_RED=91]="BRIGHT_RED",t[t.BRIGHT_GREEN=92]="BRIGHT_GREEN",t[t.BRIGHT_YELLOW=93]="BRIGHT_YELLOW",t[t.BRIGHT_BLUE=94]="BRIGHT_BLUE",t[t.BRIGHT_MAGENTA=95]="BRIGHT_MAGENTA",t[t.BRIGHT_CYAN=96]="BRIGHT_CYAN",t[t.BRIGHT_WHITE=97]="BRIGHT_WHITE"}(gt||(gt={}));const wt={debug:ht&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},Tt={enabled:!0,level:0};function Et(){}const Mt={},vt={once:!0};class It{constructor(){let{id:t}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{id:""};p(this,"id",void 0),p(this,"VERSION",mt),p(this,"_startTs",bt()),p(this,"_deltaTs",bt()),p(this,"_storage",void 0),p(this,"userData",{}),p(this,"LOG_THROTTLE_TIMEOUT",0),this.id=t,this._storage=new pt("__probe-".concat(this.id,"__"),Tt),this.userData={},this.timeStamp("".concat(this.id," started")),function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:["constructor"];const r=Object.getPrototypeOf(t),n=Object.getOwnPropertyNames(r);for(const r of n)"function"==typeof t[r]&&(e.find((t=>r===t))||(t[r]=t[r].bind(t)))}(this),Object.seal(this)}set level(t){this.setLevel(t)}get level(){return this.getLevel()}isEnabled(){return this._storage.config.enabled}getLevel(){return this._storage.config.level}getTotal(){return Number((bt()-this._startTs).toPrecision(10))}getDelta(){return Number((bt()-this._deltaTs).toPrecision(10))}set priority(t){this.level=t}get priority(){return this.level}getPriority(){return this.level}enable(){let t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return this._storage.updateConfiguration({enabled:t}),this}setLevel(t){return this._storage.updateConfiguration({level:t}),this}get(t){return this._storage.config[t]}set(t,e){this._storage.updateConfiguration({[t]:e})}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}assert(t,e){Ct(t,e)}warn(t){return this._getLogFunction(0,t,wt.warn,arguments,vt)}error(t){return this._getLogFunction(0,t,wt.error,arguments)}deprecated(t,e){return this.warn("`".concat(t,"` is deprecated and will be removed in a later version. Use `").concat(e,"` instead"))}removed(t,e){return this.error("`".concat(t,"` has been removed. Use `").concat(e,"` instead"))}probe(t,e){return this._getLogFunction(t,e,wt.log,arguments,{time:!0,once:!0})}log(t,e){return this._getLogFunction(t,e,wt.debug,arguments)}info(t,e){return this._getLogFunction(t,e,console.info,arguments)}once(t,e){for(var r=arguments.length,n=new Array(r>2?r-2:0),s=2;s<r;s++)n[s-2]=arguments[s];return this._getLogFunction(t,e,wt.debug||wt.info,arguments,vt)}table(t,e,r){return e?this._getLogFunction(t,e,console.table||Et,r&&[r],{tag:Dt(e)}):Et}image(t){let{logLevel:e,priority:r,image:n,message:s="",scale:i=1}=t;return this._shouldLog(e||r)?ht?function(t){let{image:e,message:r="",scale:n=1}=t;if("string"==typeof e){const t=new Image;return t.onload=()=>{const e=Bt(t,r,n);console.log(...e)},t.src=e,Et}const s=e.nodeName||"";if("img"===s.toLowerCase())return console.log(...Bt(e,r,n)),Et;if("canvas"===s.toLowerCase()){const t=new Image;return t.onload=()=>console.log(...Bt(t,r,n)),t.src=e.toDataURL(),Et}return Et}({image:n,message:s,scale:i}):function(t){let{image:e,message:r="",scale:n=1}=t,s=null;try{s=module.require("asciify-image")}catch(t){}if(s)return()=>s(e,{fit:"box",width:"".concat(Math.round(80*n),"%")}).then((t=>console.log(t)));return Et}({image:n,message:s,scale:i}):Et}time(t,e){return this._getLogFunction(t,e,console.time?console.time:console.info)}timeEnd(t,e){return this._getLogFunction(t,e,console.timeEnd?console.timeEnd:console.info)}timeStamp(t,e){return this._getLogFunction(t,e,console.timeStamp||Et)}group(t,e){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{collapsed:!1};const n=Ft({logLevel:t,message:e,opts:r}),{collapsed:s}=r;return n.method=(s?console.groupCollapsed:console.group)||console.info,this._getLogFunction(n)}groupCollapsed(t,e){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.group(t,e,Object.assign({},r,{collapsed:!0}))}groupEnd(t){return this._getLogFunction(t,"",console.groupEnd||Et)}withGroup(t,e,r){this.group(t,e)();try{r()}finally{this.groupEnd(t)()}}trace(){console.trace&&console.trace()}_shouldLog(t){return this.isEnabled()&&this.getLevel()>=_t(t)}_getLogFunction(t,e,r,n,s){if(this._shouldLog(t)){s=Ft({logLevel:t,message:e,args:n,opts:s}),Ct(r=r||s.method),s.total=this.getTotal(),s.delta=this.getDelta(),this._deltaTs=bt();const i=s.tag||s.message;if(s.once){if(Mt[i])return Et;Mt[i]=bt()}return e=function(t,e,r){if("string"==typeof e){const o=r.time?function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:8;const r=Math.max(e-t.length,0);return"".concat(" ".repeat(r)).concat(t)}(function(t){let e;return e=t<10?"".concat(t.toFixed(2),"ms"):t<100?"".concat(t.toFixed(1),"ms"):t<1e3?"".concat(t.toFixed(0),"ms"):"".concat((t/1e3).toFixed(2),"s"),e}(r.total)):"";e=r.time?"".concat(t,": ").concat(o," ").concat(e):"".concat(t,": ").concat(e),n=e,s=r.color,i=r.background,ht||"string"!=typeof n||(s&&(s=yt(s),n="[".concat(s,"m").concat(n,"")),i&&(s=yt(i),n="[".concat(i+10,"m").concat(n,""))),e=n}var n,s,i;return e}(this.id,s.message,s),r.bind(console,e,...s.args)}return Et}}function _t(t){if(!t)return 0;let e;switch(typeof t){case"number":e=t;break;case"object":e=t.logLevel||t.priority||0;break;default:return 0}return Ct(Number.isFinite(e)&&e>=0),e}function Ft(t){const{logLevel:e,message:r}=t;t.logLevel=_t(e);const n=t.args?Array.from(t.args):[];for(;n.length&&n.shift()!==r;);switch(typeof e){case"string":case"function":void 0!==r&&n.unshift(r),t.message=e;break;case"object":Object.assign(t,e)}"function"==typeof t.message&&(t.message=t.message());const s=typeof t.message;return Ct("string"===s||"object"===s),Object.assign(t,{args:n},t.opts)}function Dt(t){for(const e in t)for(const r in t[e])return r||"untitled";return"empty"}p(It,"VERSION",mt);const Gt=new It({id:"loaders.gl"});class Rt{log(){return()=>{}}info(){return()=>{}}warn(){return()=>{}}error(){return()=>{}}}const St={fetch:null,mimeType:void 0,nothrow:!1,log:new class{constructor(){p(this,"console",void 0),this.console=console}log(...t){return this.console.log.bind(this.console,...t)}info(...t){return this.console.info.bind(this.console,...t)}warn(...t){return this.console.warn.bind(this.console,...t)}error(...t){return this.console.error.bind(this.console,...t)}},CDN:"https://unpkg.com/@loaders.gl",worker:!0,maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:!0,_workerType:"",limit:0,_limitMB:0,batchSize:"auto",batchDebounceMs:0,metadata:!1,transforms:[]},Ot={throws:"nothrow",dataType:"(no longer used)",uri:"baseUri",method:"fetch.method",headers:"fetch.headers",body:"fetch.body",mode:"fetch.mode",credentials:"fetch.credentials",cache:"fetch.cache",redirect:"fetch.redirect",referrer:"fetch.referrer",referrerPolicy:"fetch.referrerPolicy",integrity:"fetch.integrity",keepalive:"fetch.keepalive",signal:"fetch.signal"};function xt(){globalThis.loaders=globalThis.loaders||{};const{loaders:t}=globalThis;return t._state=t._state||{},t._state}const Ut=()=>{const t=xt();return t.globalOptions=t.globalOptions||{...St},t.globalOptions};function Lt(t,e,r,n){return r=r||[],function(t,e){Ht(t,null,St,Ot,e);for(const r of e){const n=t&&t[r.id]||{},s=r.options&&r.options[r.id]||{},i=r.deprecatedOptions&&r.deprecatedOptions[r.id]||{};Ht(n,r.id,s,i,e)}}(t,r=Array.isArray(r)?r:[r]),function(t,e,r){const n={...t.options||{}};(function(t,e){e&&!("baseUri"in t)&&(t.baseUri=e)})(n,r),null===n.log&&(n.log=new Rt);return Pt(n,Ut()),Pt(n,e),n}(e,t,n)}function Nt(t,e){const r=Ut(),n=t||r;return"function"==typeof n.fetch?n.fetch:X(n.fetch)?t=>lt(t,n):null!=e&&e.fetch?null==e?void 0:e.fetch:lt}function Ht(t,e,r,n,s){const i=e||"Top level",o=e?"".concat(e,"."):"";for(const a in t){const c=!e&&X(t[a]),u="baseUri"===a&&!e,l="workerUrl"===a&&e;if(!(a in r)&&!u&&!l)if(a in n)Gt.warn("".concat(i," loader option '").concat(o).concat(a,"' no longer supported, use '").concat(n[a],"'"))();else if(!c){const t=Jt(a,s);Gt.warn("".concat(i," loader option '").concat(o).concat(a,"' not recognized. ").concat(t))()}}}function Jt(t,e){const r=t.toLowerCase();let n="";for(const s of e)for(const e in s.options){if(t===e)return"Did you mean '".concat(s.id,".").concat(e,"'?");const i=e.toLowerCase();(r.startsWith(i)||i.startsWith(r))&&(n=n||"Did you mean '".concat(s.id,".").concat(e,"'?"))}return n}function Pt(t,e){for(const r in e)if(r in e){const n=e[r];Z(n)&&Z(t[r])?t[r]={...t[r],...e[r]}:t[r]=e[r]}}function jt(t){var e;if(!t)return!1;Array.isArray(t)&&(t=t[0]);return Array.isArray(null===(e=t)||void 0===e?void 0:e.extensions)}function kt(t){var e,r;let n;return o(t,"null loader"),o(jt(t),"invalid loader"),Array.isArray(t)&&(n=t[1],t=t[0],t={...t,options:{...t.options,...n}}),(null!==(e=t)&&void 0!==e&&e.parseTextSync||null!==(r=t)&&void 0!==r&&r.parseText)&&(t.text=!0),t.text||(t.binary=!0),t}function Vt(){return(()=>{const t=xt();return t.loaderRegistry=t.loaderRegistry||[],t.loaderRegistry})()}const Kt=/\.([^.]+)$/;function Qt(t,e=[],r,n){if(!qt(t))return null;if(e&&!Array.isArray(e))return kt(e);let s=[];e&&(s=s.concat(e)),null!=r&&r.ignoreRegisteredLoaders||s.push(...Vt()),function(t){for(const e of t)kt(e)}(s);const i=function(t,e,r,n){const{url:s,type:i}=at(t),o=s||(null==n?void 0:n.url);let a=null;null!=r&&r.mimeType&&(a=Wt(e,null==r?void 0:r.mimeType));return a=a||function(t,e){const r=e&&Kt.exec(e),n=r&&r[1];return n?function(t,e){e=e.toLowerCase();for(const r of t)for(const t of r.extensions)if(t.toLowerCase()===e)return r;return null}(t,n):null}(e,o),a=a||Wt(e,i),a=a||function(t,e){if(!e)return null;for(const r of t)if("string"==typeof e){if(Yt(e,r))return r}else if(ArrayBuffer.isView(e)){if(Xt(e.buffer,e.byteOffset,r))return r}else if(e instanceof ArrayBuffer){if(Xt(e,0,r))return r}return null}(e,t),a=a||Wt(e,null==r?void 0:r.fallbackMimeType),a}(t,s,r,n);if(!(i||null!=r&&r.nothrow))throw new Error(zt(t));return i}function qt(t){return!(t instanceof Response&&204===t.status)}function zt(t){const{url:e,type:r}=at(t);let n="No valid loader found (";n+=e?"".concat(function(t){const e=t&&t.lastIndexOf("/");return e>=0?t.substr(e+1):""}(e),", "):"no url provided, ",n+="MIME type: ".concat(r?'"'.concat(r,'"'):"not provided",", ");const s=t?function(t,e=5){if("string"==typeof t)return t.slice(0,e);if(ArrayBuffer.isView(t))return Zt(t.buffer,t.byteOffset,e);if(t instanceof ArrayBuffer){return Zt(t,0,e)}return""}(t):"";return n+=s?' first bytes: "'.concat(s,'"'):"first bytes: not available",n+=")",n}function Wt(t,e){for(const r of t){if(r.mimeTypes&&r.mimeTypes.includes(e))return r;if(e==="application/x.".concat(r.id))return r}return null}function Yt(t,e){if(e.testText)return e.testText(t);return(Array.isArray(e.tests)?e.tests:[e.tests]).some((e=>t.startsWith(e)))}function Xt(t,e,r){return(Array.isArray(r.tests)?r.tests:[r.tests]).some((n=>function(t,e,r,n){if(n instanceof ArrayBuffer)return function(t,e,r){if(r=r||t.byteLength,t.byteLength<r||e.byteLength<r)return!1;const n=new Uint8Array(t),s=new Uint8Array(e);for(let t=0;t<n.length;++t)if(n[t]!==s[t])return!1;return!0}(n,t,n.byteLength);switch(typeof n){case"function":return n(t,r);case"string":return n===Zt(t,e,n.length);default:return!1}}(t,e,r,n)))}function Zt(t,e,r){if(t.byteLength<e+r)return"";const n=new DataView(t);let s="";for(let t=0;t<r;t++)s+=String.fromCharCode(n.getUint8(e+t));return s}const $t=262144;function te(t,e){return a?async function*(t,e){const r=t.getReader();let n;try{for(;;){const t=n||r.read();null!=e&&e._streamReadAhead&&(n=r.read());const{done:s,value:i}=await t;if(s)return;yield N(i)}}catch(t){r.releaseLock()}}(t,e):async function*(t,e){for await(const e of t)yield N(e)}(t)}function ee(t,e){if("string"==typeof t)return function*(t,e){const r=(null==e?void 0:e.chunkSize)||262144;let n=0;const s=new TextEncoder;for(;n<t.length;){const e=Math.min(t.length-n,r),i=t.slice(n,n+e);n+=e,yield s.encode(i)}}(t,e);if(t instanceof ArrayBuffer)return function*(t,e={}){const{chunkSize:r=$t}=e;let n=0;for(;n<t.byteLength;){const e=Math.min(t.byteLength-n,r),s=new ArrayBuffer(e),i=new Uint8Array(t,n,e);new Uint8Array(s).set(i),n+=e,yield s}}(t,e);if(tt(t))return async function*(t,e){const r=(null==e?void 0:e.chunkSize)||1048576;let n=0;for(;n<t.size;){const e=n+r,s=await t.slice(n,e).arrayBuffer();n=e,yield s}}(t,e);if(et(t))return te(t,e);if($(t)){return te(t.body,e)}throw new Error("makeIterator")}const re="Cannot convert supplied data type";async function ne(t,e,r){const n=t instanceof ArrayBuffer||ArrayBuffer.isView(t);if("string"==typeof t||n)return function(t,e,r){if(e.text&&"string"==typeof t)return t;var n;if((n=t)&&"object"==typeof n&&n.isBuffer&&(t=t.buffer),t instanceof ArrayBuffer){const r=t;return e.text&&!e.binary?new TextDecoder("utf8").decode(r):r}if(ArrayBuffer.isView(t)){if(e.text&&!e.binary)return new TextDecoder("utf8").decode(t);let r=t.buffer;const n=t.byteLength||t.length;return 0===t.byteOffset&&n===r.byteLength||(r=r.slice(t.byteOffset,t.byteOffset+n)),r}throw new Error(re)}(t,e);if(tt(t)&&(t=await ut(t)),$(t)){const r=t;return await async function(t){if(!t.ok){const e=await async function(t){let e="Failed to fetch resource ".concat(t.url," (").concat(t.status,"): ");try{const r=t.headers.get("Content-Type");let n=t.statusText;r.includes("application/json")&&(n+=" ".concat(await t.text())),e+=n,e=e.length>60?"".concat(e.slice(60),"..."):e}catch(t){}return e}(t);throw new Error(e)}}(r),e.binary?await r.arrayBuffer():await r.text()}if(et(t)&&(t=ee(t,r)),(s=t)&&"function"==typeof s[Symbol.iterator]||(t=>t&&"function"==typeof t[Symbol.asyncIterator])(t))return j(t);var s;throw new Error(re)}async function se(t,e,r,n){u(!n||"object"==typeof n),!e||Array.isArray(e)||jt(e)||(n=void 0,r=e,e=void 0),t=await t,r=r||{};const{url:s}=at(t),i=function(t,e){if(!e&&t&&!Array.isArray(t))return t;let r;if(t&&(r=Array.isArray(t)?t:[t]),e&&e.loaders){const t=Array.isArray(e.loaders)?e.loaders:[e.loaders];r=r?[...r,...t]:t}return r&&r.length?r:null}(e,n),o=await async function(t,e=[],r,n){if(!qt(t))return null;let s=Qt(t,e,{...r,nothrow:!0},n);if(s)return s;if(tt(t)&&(s=Qt(t=await t.slice(0,10).arrayBuffer(),e,r,n)),!(s||null!=r&&r.nothrow))throw new Error(zt(t));return s}(t,i,r);return o?(n=function(t,e,r=null){if(r)return r;const n={fetch:Nt(e,t),...t};return Array.isArray(n.loaders)||(n.loaders=null),n}({url:s,parse:se,loaders:i},r=Lt(r,o,i,s),n),await async function(t,e,r,n){if(function(t,e="3.1.4"){u(t,"no worker provided");const r=t.version}(t),e=await ne(e,t,r),t.parseTextSync&&"string"==typeof e)return r.dataType="text",t.parseTextSync(e,r,n,t);if(function(t,e){return!!I.isSupported()&&t.worker&&(null==e?void 0:e.worker)}(t,r))return await S(t,e,r,0,se);if(t.parseText&&"string"==typeof e)return await t.parseText(e,r,n,t);if(t.parse)return await t.parse(e,r,n,t);throw u(!t.parseSync),new Error("".concat(t.id," loader - no parser found and worker is disabled"))}(o,t,r,n)):null}async function ie(t,e,r,n){Array.isArray(e)||jt(e)||(r=e,e=void 0);const s=Nt(r);let i=t;return"string"==typeof t&&(i=await s(t)),tt(t)&&(i=await s(t)),await se(i,e,r)}function oe(t,e){if(!t)throw new Error("math.gl assertion ".concat(e))}const ae=1/Math.PI*180,ce=1/180*Math.PI,ue={};function le(t,{precision:e=ue.precision||4}={}){return t=function(t){return Math.round(t/ue.EPSILON)*ue.EPSILON}(t),"".concat(parseFloat(t.toPrecision(e)))}function he(t){return Array.isArray(t)||ArrayBuffer.isView(t)&&!(t instanceof DataView)}function de(t,e,r){if(he(t)){r=r||((n=t).clone?n.clone():new Array(n.length));for(let n=0;n<r.length&&n<t.length;++n)r[n]=e(t[n],n,r);return r}var n;return e(t)}function fe(t){return function(t,e){return de(t,(t=>t*ce),e)}(t)}function Ae(t){return me(t)}function me(t,e){return de(t,(t=>t*ae),e)}function pe(t,e,r){const n=ue.EPSILON;r&&(ue.EPSILON=r);try{if(t===e)return!0;if(he(t)&&he(e)){if(t.length!==e.length)return!1;for(let r=0;r<t.length;++r)if(!pe(t[r],e[r]))return!1;return!0}return t&&t.equals?t.equals(e):e&&e.equals?e.equals(t):!(!Number.isFinite(t)||!Number.isFinite(e))&&Math.abs(t-e)<=ue.EPSILON*Math.max(1,Math.abs(t),Math.abs(e))}finally{ue.EPSILON=n}}ue.EPSILON=1e-12,ue.debug=!1,ue.precision=4,ue.printTypes=!1,ue.printDegrees=!1,ue.printRowMajor=!0;class Be extends(function(t){function e(){var e=Reflect.construct(t,Array.from(arguments));return Object.setPrototypeOf(e,Object.getPrototypeOf(this)),e}return e.prototype=Object.create(t.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t,e}(Array)){get ELEMENTS(){return oe(!1),0}clone(){return(new this.constructor).copy(this)}from(t){return Array.isArray(t)?this.copy(t):this.fromObject(t)}fromArray(t,e=0){for(let r=0;r<this.ELEMENTS;++r)this[r]=t[r+e];return this.check()}to(t){return t===this?this:he(t)?this.toArray(t):this.toObject(t)}toTarget(t){return t?this.to(t):this}toArray(t=[],e=0){for(let r=0;r<this.ELEMENTS;++r)t[e+r]=this[r];return t}toFloat32Array(){return new Float32Array(this)}toString(){return this.formatString(ue)}formatString(t){let e="";for(let r=0;r<this.ELEMENTS;++r)e+=(r>0?", ":"")+le(this[r],t);return"".concat(t.printTypes?this.constructor.name:"","[").concat(e,"]")}equals(t){if(!t||this.length!==t.length)return!1;for(let e=0;e<this.ELEMENTS;++e)if(!pe(this[e],t[e]))return!1;return!0}exactEquals(t){if(!t||this.length!==t.length)return!1;for(let e=0;e<this.ELEMENTS;++e)if(this[e]!==t[e])return!1;return!0}negate(){for(let t=0;t<this.ELEMENTS;++t)this[t]=-this[t];return this.check()}lerp(t,e,r){void 0===r&&(r=e,e=t,t=this);for(let n=0;n<this.ELEMENTS;++n){const s=t[n];this[n]=s+r*(e[n]-s)}return this.check()}min(t){for(let e=0;e<this.ELEMENTS;++e)this[e]=Math.min(t[e],this[e]);return this.check()}max(t){for(let e=0;e<this.ELEMENTS;++e)this[e]=Math.max(t[e],this[e]);return this.check()}clamp(t,e){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(Math.max(this[r],t[r]),e[r]);return this.check()}add(...t){for(const e of t)for(let t=0;t<this.ELEMENTS;++t)this[t]+=e[t];return this.check()}subtract(...t){for(const e of t)for(let t=0;t<this.ELEMENTS;++t)this[t]-=e[t];return this.check()}scale(t){if(Array.isArray(t))return this.multiply(t);for(let e=0;e<this.ELEMENTS;++e)this[e]*=t;return this.check()}sub(t){return this.subtract(t)}setScalar(t){for(let e=0;e<this.ELEMENTS;++e)this[e]=t;return this.check()}addScalar(t){for(let e=0;e<this.ELEMENTS;++e)this[e]+=t;return this.check()}subScalar(t){return this.addScalar(-t)}multiplyScalar(t){for(let e=0;e<this.ELEMENTS;++e)this[e]*=t;return this.check()}divideScalar(t){return this.scale(1/t)}clampScalar(t,e){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(Math.max(this[r],t),e);return this.check()}multiplyByScalar(t){return this.scale(t)}get elements(){return this}check(){if(ue.debug&&!this.validate())throw new Error("math.gl: ".concat(this.constructor.name," some fields set to invalid numbers'"));return this}validate(){let t=this.length===this.ELEMENTS;for(let e=0;e<this.ELEMENTS;++e)t=t&&Number.isFinite(this[e]);return t}}function ge(t){if(!Number.isFinite(t))throw new Error("Invalid number ".concat(t));return t}function ye(t,e,r=""){if(ue.debug&&!function(t,e){if(t.length!==e)return!1;for(let e=0;e<t.length;++e)if(!Number.isFinite(t[e]))return!1;return!0}(t,e))throw new Error("math.gl: ".concat(r," some fields set to invalid numbers'"));return t}const Ce={};function be(t,e){Ce[t]||(Ce[t]=!0,console.warn("".concat(t," has been removed in version ").concat(e,", see upgrade guide for more information")))}class we extends Be{get ELEMENTS(){return oe(!1),0}copy(t){return oe(!1),this}get x(){return this[0]}set x(t){this[0]=ge(t)}get y(){return this[1]}set y(t){this[1]=ge(t)}len(){return Math.sqrt(this.lengthSquared())}magnitude(){return this.len()}lengthSquared(){let t=0;for(let e=0;e<this.ELEMENTS;++e)t+=this[e]*this[e];return t}magnitudeSquared(){return this.lengthSquared()}distance(t){return Math.sqrt(this.distanceSquared(t))}distanceSquared(t){let e=0;for(let r=0;r<this.ELEMENTS;++r){const n=this[r]-t[r];e+=n*n}return ge(e)}dot(t){let e=0;for(let r=0;r<this.ELEMENTS;++r)e+=this[r]*t[r];return ge(e)}normalize(){const t=this.magnitude();if(0!==t)for(let e=0;e<this.ELEMENTS;++e)this[e]/=t;return this.check()}multiply(...t){for(const e of t)for(let t=0;t<this.ELEMENTS;++t)this[t]*=e[t];return this.check()}divide(...t){for(const e of t)for(let t=0;t<this.ELEMENTS;++t)this[t]/=e[t];return this.check()}lengthSq(){return this.lengthSquared()}distanceTo(t){return this.distance(t)}distanceToSquared(t){return this.distanceSquared(t)}getComponent(t){return oe(t>=0&&t<this.ELEMENTS,"index is out of range"),ge(this[t])}setComponent(t,e){return oe(t>=0&&t<this.ELEMENTS,"index is out of range"),this[t]=e,this.check()}addVectors(t,e){return this.copy(t).add(e)}subVectors(t,e){return this.copy(t).subtract(e)}multiplyVectors(t,e){return this.copy(t).multiply(e)}addScaledVector(t,e){return this.add(new this.constructor(t).multiplyScalar(e))}}var Te,Ee=1e-6,Me="undefined"!=typeof Float32Array?Float32Array:Array;function ve(t,e,r){var n=e[0],s=e[1];return t[0]=r[0]*n+r[3]*s+r[6],t[1]=r[1]*n+r[4]*s+r[7],t}function Ie(t,e,r){var n=e[0],s=e[1];return t[0]=r[0]*n+r[4]*s+r[12],t[1]=r[1]*n+r[5]*s+r[13],t}function _e(t,e,r){const n=e[0],s=e[1],i=r[3]*n+r[7]*s||1;return t[0]=(r[0]*n+r[4]*s)/i,t[1]=(r[1]*n+r[5]*s)/i,t}function Fe(t,e,r){const n=e[0],s=e[1],i=e[2],o=r[3]*n+r[7]*s+r[11]*i||1;return t[0]=(r[0]*n+r[4]*s+r[8]*i)/o,t[1]=(r[1]*n+r[5]*s+r[9]*i)/o,t[2]=(r[2]*n+r[6]*s+r[10]*i)/o,t}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)}),Te=new Me(2),Me!=Float32Array&&(Te[0]=0,Te[1]=0);class De extends we{constructor(t=0,e=0){super(2),he(t)&&1===arguments.length?this.copy(t):(ue.debug&&(ge(t),ge(e)),this[0]=t,this[1]=e)}set(t,e){return this[0]=t,this[1]=e,this.check()}copy(t){return this[0]=t[0],this[1]=t[1],this.check()}fromObject(t){return ue.debug&&(ge(t.x),ge(t.y)),this[0]=t.x,this[1]=t.y,this.check()}toObject(t){return t.x=this[0],t.y=this[1],t}get ELEMENTS(){return 2}horizontalAngle(){return Math.atan2(this.y,this.x)}verticalAngle(){return Math.atan2(this.x,this.y)}transform(t){return this.transformAsPoint(t)}transformAsPoint(t){return Ie(this,this,t),this.check()}transformAsVector(t){return _e(this,this,t),this.check()}transformByMatrix3(t){return ve(this,this,t),this.check()}transformByMatrix2x3(t){return function(t,e,r){var n=e[0],s=e[1];t[0]=r[0]*n+r[2]*s+r[4],t[1]=r[1]*n+r[3]*s+r[5]}(this,this,t),this.check()}transformByMatrix2(t){return function(t,e,r){var n=e[0],s=e[1];t[0]=r[0]*n+r[2]*s,t[1]=r[1]*n+r[3]*s}(this,this,t),this.check()}}function Ge(){var t=new Me(3);return Me!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function Re(t){var e=t[0],r=t[1],n=t[2];return Math.hypot(e,r,n)}function Se(t,e,r){var n=new Me(3);return n[0]=t,n[1]=e,n[2]=r,n}function Oe(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function xe(t,e,r){var n=e[0],s=e[1],i=e[2],o=r[0],a=r[1],c=r[2];return t[0]=s*c-i*a,t[1]=i*o-n*c,t[2]=n*a-s*o,t}function Ue(t,e,r){var n=e[0],s=e[1],i=e[2],o=r[3]*n+r[7]*s+r[11]*i+r[15];return o=o||1,t[0]=(r[0]*n+r[4]*s+r[8]*i+r[12])/o,t[1]=(r[1]*n+r[5]*s+r[9]*i+r[13])/o,t[2]=(r[2]*n+r[6]*s+r[10]*i+r[14])/o,t}function Le(t,e,r){var n=e[0],s=e[1],i=e[2];return t[0]=n*r[0]+s*r[3]+i*r[6],t[1]=n*r[1]+s*r[4]+i*r[7],t[2]=n*r[2]+s*r[5]+i*r[8],t}var Ne=Re;!function(){var t=Ge()}();const He=[0,0,0],Je={};class Pe extends we{static get ZERO(){return Je.ZERO=Je.ZERO||Object.freeze(new Pe(0,0,0,0))}constructor(t=0,e=0,r=0){super(-0,-0,-0),1===arguments.length&&he(t)?this.copy(t):(ue.debug&&(ge(t),ge(e),ge(r)),this[0]=t,this[1]=e,this[2]=r)}set(t,e,r){return this[0]=t,this[1]=e,this[2]=r,this.check()}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this.check()}fromObject(t){return ue.debug&&(ge(t.x),ge(t.y),ge(t.z)),this[0]=t.x,this[1]=t.y,this[2]=t.z,this.check()}toObject(t){return t.x=this[0],t.y=this[1],t.z=this[2],t}get ELEMENTS(){return 3}get z(){return this[2]}set z(t){this[2]=ge(t)}angle(t){return function(t,e){var r=t[0],n=t[1],s=t[2],i=e[0],o=e[1],a=e[2],c=Math.sqrt(r*r+n*n+s*s)*Math.sqrt(i*i+o*o+a*a),u=c&&Oe(t,e)/c;return Math.acos(Math.min(Math.max(u,-1),1))}(this,t)}cross(t){return xe(this,this,t),this.check()}rotateX({radians:t,origin:e=He}){return function(t,e,r,n){var s=[],i=[];s[0]=e[0]-r[0],s[1]=e[1]-r[1],s[2]=e[2]-r[2],i[0]=s[0],i[1]=s[1]*Math.cos(n)-s[2]*Math.sin(n),i[2]=s[1]*Math.sin(n)+s[2]*Math.cos(n),t[0]=i[0]+r[0],t[1]=i[1]+r[1],t[2]=i[2]+r[2]}(this,this,e,t),this.check()}rotateY({radians:t,origin:e=He}){return function(t,e,r,n){var s=[],i=[];s[0]=e[0]-r[0],s[1]=e[1]-r[1],s[2]=e[2]-r[2],i[0]=s[2]*Math.sin(n)+s[0]*Math.cos(n),i[1]=s[1],i[2]=s[2]*Math.cos(n)-s[0]*Math.sin(n),t[0]=i[0]+r[0],t[1]=i[1]+r[1],t[2]=i[2]+r[2]}(this,this,e,t),this.check()}rotateZ({radians:t,origin:e=He}){return function(t,e,r,n){var s=[],i=[];s[0]=e[0]-r[0],s[1]=e[1]-r[1],s[2]=e[2]-r[2],i[0]=s[0]*Math.cos(n)-s[1]*Math.sin(n),i[1]=s[0]*Math.sin(n)+s[1]*Math.cos(n),i[2]=s[2],t[0]=i[0]+r[0],t[1]=i[1]+r[1],t[2]=i[2]+r[2]}(this,this,e,t),this.check()}transform(t){return this.transformAsPoint(t)}transformAsPoint(t){return Ue(this,this,t),this.check()}transformAsVector(t){return Fe(this,this,t),this.check()}transformByMatrix3(t){return Le(this,this,t),this.check()}transformByMatrix2(t){return function(t,e,r){const n=e[0],s=e[1];t[0]=r[0]*n+r[2]*s,t[1]=r[1]*n+r[3]*s,t[2]=e[2]}(this,this,t),this.check()}transformByQuaternion(t){return function(t,e,r){var n=r[0],s=r[1],i=r[2],o=r[3],a=e[0],c=e[1],u=e[2],l=s*u-i*c,h=i*a-n*u,d=n*c-s*a,f=s*d-i*h,A=i*l-n*d,m=n*h-s*l,p=2*o;l*=p,h*=p,d*=p,f*=2,A*=2,m*=2,t[0]=a+l+f,t[1]=c+h+A,t[2]=u+d+m}(this,this,t),this.check()}}class je extends Be{get ELEMENTS(){return oe(!1),0}get RANK(){return oe(!1),0}toString(){let t="[";if(ue.printRowMajor){t+="row-major:";for(let e=0;e<this.RANK;++e)for(let r=0;r<this.RANK;++r)t+=" ".concat(this[r*this.RANK+e])}else{t+="column-major:";for(let e=0;e<this.ELEMENTS;++e)t+=" ".concat(this[e])}return t+="]",t}getElementIndex(t,e){return e*this.RANK+t}getElement(t,e){return this[e*this.RANK+t]}setElement(t,e,r){return this[e*this.RANK+t]=ge(r),this}getColumn(t,e=new Array(this.RANK).fill(-0)){const r=t*this.RANK;for(let t=0;t<this.RANK;++t)e[t]=this[r+t];return e}setColumn(t,e){const r=t*this.RANK;for(let t=0;t<this.RANK;++t)this[r+t]=e[t];return this}}function ke(t,e,r){var n=e[0],s=e[1],i=e[2],o=e[3],a=e[4],c=e[5],u=e[6],l=e[7],h=e[8],d=r[0],f=r[1],A=r[2],m=r[3],p=r[4],B=r[5],g=r[6],y=r[7],C=r[8];return t[0]=d*n+f*o+A*u,t[1]=d*s+f*a+A*l,t[2]=d*i+f*c+A*h,t[3]=m*n+p*o+B*u,t[4]=m*s+p*a+B*l,t[5]=m*i+p*c+B*h,t[6]=g*n+y*o+C*u,t[7]=g*s+y*a+C*l,t[8]=g*i+y*c+C*h,t}function Ve(t,e,r){var n=r[0],s=r[1];return t[0]=n*e[0],t[1]=n*e[1],t[2]=n*e[2],t[3]=s*e[3],t[4]=s*e[4],t[5]=s*e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t}const Ke=Object.freeze([1,0,0,0,1,0,0,0,1]),Qe=Object.freeze([0,0,0,0,0,0,0,0,0]),qe=Object.freeze({COL0ROW0:0,COL0ROW1:1,COL0ROW2:2,COL1ROW0:3,COL1ROW1:4,COL1ROW2:5,COL2ROW0:6,COL2ROW1:7,COL2ROW2:8}),ze={};class We extends je{static get IDENTITY(){return ze.IDENTITY=ze.IDENTITY||Object.freeze(new We(Ke)),ze.IDENTITY}static get ZERO(){return ze.ZERO=ze.ZERO||Object.freeze(new We(Qe)),ze.ZERO}get ELEMENTS(){return 9}get RANK(){return 3}get INDICES(){return qe}constructor(t){super(-0,-0,-0,-0,-0,-0,-0,-0,-0),1===arguments.length&&Array.isArray(t)?this.copy(t):this.identity()}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this[3]=t[3],this[4]=t[4],this[5]=t[5],this[6]=t[6],this[7]=t[7],this[8]=t[8],this.check()}set(t,e,r,n,s,i,o,a,c){return this[0]=t,this[1]=e,this[2]=r,this[3]=n,this[4]=s,this[5]=i,this[6]=o,this[7]=a,this[8]=c,this.check()}setRowMajor(t,e,r,n,s,i,o,a,c){return this[0]=t,this[1]=n,this[2]=o,this[3]=e,this[4]=s,this[5]=a,this[6]=r,this[7]=i,this[8]=c,this.check()}determinant(){return function(t){var e=t[0],r=t[1],n=t[2],s=t[3],i=t[4],o=t[5],a=t[6],c=t[7],u=t[8];return e*(u*i-o*c)+r*(-u*s+o*a)+n*(c*s-i*a)}(this)}identity(){return this.copy(Ke)}fromQuaternion(t){return function(t,e){var r=e[0],n=e[1],s=e[2],i=e[3],o=r+r,a=n+n,c=s+s,u=r*o,l=n*o,h=n*a,d=s*o,f=s*a,A=s*c,m=i*o,p=i*a,B=i*c;t[0]=1-h-A,t[3]=l-B,t[6]=d+p,t[1]=l+B,t[4]=1-u-A,t[7]=f-m,t[2]=d-p,t[5]=f+m,t[8]=1-u-h}(this,t),this.check()}transpose(){return function(t,e){if(t===e){var r=e[1],n=e[2],s=e[5];t[1]=e[3],t[2]=e[6],t[3]=r,t[5]=e[7],t[6]=n,t[7]=s}else t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8]}(this,this),this.check()}invert(){return function(t,e){var r=e[0],n=e[1],s=e[2],i=e[3],o=e[4],a=e[5],c=e[6],u=e[7],l=e[8],h=l*o-a*u,d=-l*i+a*c,f=u*i-o*c,A=r*h+n*d+s*f;A&&(A=1/A,t[0]=h*A,t[1]=(-l*n+s*u)*A,t[2]=(a*n-s*o)*A,t[3]=d*A,t[4]=(l*r-s*c)*A,t[5]=(-a*r+s*i)*A,t[6]=f*A,t[7]=(-u*r+n*c)*A,t[8]=(o*r-n*i)*A)}(this,this),this.check()}multiplyLeft(t){return ke(this,t,this),this.check()}multiplyRight(t){return ke(this,this,t),this.check()}rotate(t){return function(t,e,r){var n=e[0],s=e[1],i=e[2],o=e[3],a=e[4],c=e[5],u=e[6],l=e[7],h=e[8],d=Math.sin(r),f=Math.cos(r);t[0]=f*n+d*o,t[1]=f*s+d*a,t[2]=f*i+d*c,t[3]=f*o-d*n,t[4]=f*a-d*s,t[5]=f*c-d*i,t[6]=u,t[7]=l,t[8]=h}(this,this,t),this.check()}scale(t){return Array.isArray(t)?Ve(this,this,t):Ve(this,this,[t,t,t]),this.check()}translate(t){return function(t,e,r){var n=e[0],s=e[1],i=e[2],o=e[3],a=e[4],c=e[5],u=e[6],l=e[7],h=e[8],d=r[0],f=r[1];t[0]=n,t[1]=s,t[2]=i,t[3]=o,t[4]=a,t[5]=c,t[6]=d*n+f*o+u,t[7]=d*s+f*a+l,t[8]=d*i+f*c+h}(this,this,t),this.check()}transform(t,e){switch(t.length){case 2:e=ve(e||[-0,-0],t,this);break;case 3:e=Le(e||[-0,-0,-0],t,this);break;case 4:e=function(t,e,r){const n=e[0],s=e[1],i=e[2];return t[0]=r[0]*n+r[3]*s+r[6]*i,t[1]=r[1]*n+r[4]*s+r[7]*i,t[2]=r[2]*n+r[5]*s+r[8]*i,t[3]=e[3],t}(e||[-0,-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return ye(e,t.length),e}transformVector(t,e){return be("Matrix3.transformVector"),this.transform(t,e)}transformVector2(t,e){return be("Matrix3.transformVector"),this.transform(t,e)}transformVector3(t,e){return be("Matrix3.transformVector"),this.transform(t,e)}}function Ye(t,e,r){var n=e[0],s=e[1],i=e[2],o=e[3],a=e[4],c=e[5],u=e[6],l=e[7],h=e[8],d=e[9],f=e[10],A=e[11],m=e[12],p=e[13],B=e[14],g=e[15],y=r[0],C=r[1],b=r[2],w=r[3];return t[0]=y*n+C*a+b*h+w*m,t[1]=y*s+C*c+b*d+w*p,t[2]=y*i+C*u+b*f+w*B,t[3]=y*o+C*l+b*A+w*g,y=r[4],C=r[5],b=r[6],w=r[7],t[4]=y*n+C*a+b*h+w*m,t[5]=y*s+C*c+b*d+w*p,t[6]=y*i+C*u+b*f+w*B,t[7]=y*o+C*l+b*A+w*g,y=r[8],C=r[9],b=r[10],w=r[11],t[8]=y*n+C*a+b*h+w*m,t[9]=y*s+C*c+b*d+w*p,t[10]=y*i+C*u+b*f+w*B,t[11]=y*o+C*l+b*A+w*g,y=r[12],C=r[13],b=r[14],w=r[15],t[12]=y*n+C*a+b*h+w*m,t[13]=y*s+C*c+b*d+w*p,t[14]=y*i+C*u+b*f+w*B,t[15]=y*o+C*l+b*A+w*g,t}function Xe(t,e,r){var n=r[0],s=r[1],i=r[2];return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t[4]=e[4]*s,t[5]=e[5]*s,t[6]=e[6]*s,t[7]=e[7]*s,t[8]=e[8]*i,t[9]=e[9]*i,t[10]=e[10]*i,t[11]=e[11]*i,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}!function(){var t=function(){var t=new Me(4);return Me!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t}()}();const Ze=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),$e=Object.freeze([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),tr=Object.freeze({COL0ROW0:0,COL0ROW1:1,COL0ROW2:2,COL0ROW3:3,COL1ROW0:4,COL1ROW1:5,COL1ROW2:6,COL1ROW3:7,COL2ROW0:8,COL2ROW1:9,COL2ROW2:10,COL2ROW3:11,COL3ROW0:12,COL3ROW1:13,COL3ROW2:14,COL3ROW3:15}),er={};class rr extends je{static get IDENTITY(){return er.IDENTITY=er.IDENTITY||Object.freeze(new rr(Ze)),er.IDENTITY}static get ZERO(){return er.ZERO=er.ZERO||Object.freeze(new rr($e)),er.ZERO}get INDICES(){return tr}get ELEMENTS(){return 16}get RANK(){return 4}constructor(t){super(-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0),1===arguments.length&&Array.isArray(t)?this.copy(t):this.identity()}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this[3]=t[3],this[4]=t[4],this[5]=t[5],this[6]=t[6],this[7]=t[7],this[8]=t[8],this[9]=t[9],this[10]=t[10],this[11]=t[11],this[12]=t[12],this[13]=t[13],this[14]=t[14],this[15]=t[15],this.check()}set(t,e,r,n,s,i,o,a,c,u,l,h,d,f,A,m){return this[0]=t,this[1]=e,this[2]=r,this[3]=n,this[4]=s,this[5]=i,this[6]=o,this[7]=a,this[8]=c,this[9]=u,this[10]=l,this[11]=h,this[12]=d,this[13]=f,this[14]=A,this[15]=m,this.check()}setRowMajor(t,e,r,n,s,i,o,a,c,u,l,h,d,f,A,m){return this[0]=t,this[1]=s,this[2]=c,this[3]=d,this[4]=e,this[5]=i,this[6]=u,this[7]=f,this[8]=r,this[9]=o,this[10]=l,this[11]=A,this[12]=n,this[13]=a,this[14]=h,this[15]=m,this.check()}toRowMajor(t){return t[0]=this[0],t[1]=this[4],t[2]=this[8],t[3]=this[12],t[4]=this[1],t[5]=this[5],t[6]=this[9],t[7]=this[13],t[8]=this[2],t[9]=this[6],t[10]=this[10],t[11]=this[14],t[12]=this[3],t[13]=this[7],t[14]=this[11],t[15]=this[15],t}identity(){return this.copy(Ze)}fromQuaternion(t){return function(t,e){var r=e[0],n=e[1],s=e[2],i=e[3],o=r+r,a=n+n,c=s+s,u=r*o,l=n*o,h=n*a,d=s*o,f=s*a,A=s*c,m=i*o,p=i*a,B=i*c;t[0]=1-h-A,t[1]=l+B,t[2]=d-p,t[3]=0,t[4]=l-B,t[5]=1-u-A,t[6]=f+m,t[7]=0,t[8]=d+p,t[9]=f-m,t[10]=1-u-h,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1}(this,t),this.check()}frustum({left:t,right:e,bottom:r,top:n,near:s,far:i}){return i===1/0?rr._computeInfinitePerspectiveOffCenter(this,t,e,r,n,s):function(t,e,r,n,s,i,o){var a=1/(r-e),c=1/(s-n),u=1/(i-o);t[0]=2*i*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=2*i*c,t[6]=0,t[7]=0,t[8]=(r+e)*a,t[9]=(s+n)*c,t[10]=(o+i)*u,t[11]=-1,t[12]=0,t[13]=0,t[14]=o*i*2*u,t[15]=0}(this,t,e,r,n,s,i),this.check()}static _computeInfinitePerspectiveOffCenter(t,e,r,n,s,i){const o=2*i/(r-e),a=2*i/(s-n),c=(r+e)/(r-e),u=(s+n)/(s-n),l=-2*i;return t[0]=o,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=a,t[6]=0,t[7]=0,t[8]=c,t[9]=u,t[10]=-1,t[11]=-1,t[12]=0,t[13]=0,t[14]=l,t[15]=0,t}lookAt(t,e,r){return 1===arguments.length&&({eye:t,center:e,up:r}=t),function(t,e,r,n){var s,i,o,a,c,u,l,h,d,f,A=e[0],m=e[1],p=e[2],B=n[0],g=n[1],y=n[2],C=r[0],b=r[1],w=r[2];Math.abs(A-C)<Ee&&Math.abs(m-b)<Ee&&Math.abs(p-w)<Ee?function(t){t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1}(t):(l=A-C,h=m-b,d=p-w,s=g*(d*=f=1/Math.hypot(l,h,d))-y*(h*=f),i=y*(l*=f)-B*d,o=B*h-g*l,(f=Math.hypot(s,i,o))?(s*=f=1/f,i*=f,o*=f):(s=0,i=0,o=0),a=h*o-d*i,c=d*s-l*o,u=l*i-h*s,(f=Math.hypot(a,c,u))?(a*=f=1/f,c*=f,u*=f):(a=0,c=0,u=0),t[0]=s,t[1]=a,t[2]=l,t[3]=0,t[4]=i,t[5]=c,t[6]=h,t[7]=0,t[8]=o,t[9]=u,t[10]=d,t[11]=0,t[12]=-(s*A+i*m+o*p),t[13]=-(a*A+c*m+u*p),t[14]=-(l*A+h*m+d*p),t[15]=1)}(this,t,e=e||[0,0,0],r=r||[0,1,0]),this.check()}ortho({left:t,right:e,bottom:r,top:n,near:s=.1,far:i=500}){return function(t,e,r,n,s,i,o){var a=1/(e-r),c=1/(n-s),u=1/(i-o);t[0]=-2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*c,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*u,t[11]=0,t[12]=(e+r)*a,t[13]=(s+n)*c,t[14]=(o+i)*u,t[15]=1}(this,t,e,r,n,s,i),this.check()}orthographic({fovy:t=45*Math.PI/180,aspect:e=1,focalDistance:r=1,near:n=.1,far:s=500}){if(t>2*Math.PI)throw Error("radians");const i=t/2,o=r*Math.tan(i),a=o*e;return(new rr).ortho({left:-a,right:a,bottom:-o,top:o,near:n,far:s})}perspective({fovy:t,fov:e=45*Math.PI/180,aspect:r=1,near:n=.1,far:s=500}={}){if((t=t||e)>2*Math.PI)throw Error("radians");return function(t,e,r,n,s){var i,o=1/Math.tan(e/2);t[0]=o/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=o,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,null!=s&&s!==1/0?(i=1/(n-s),t[10]=(s+n)*i,t[14]=2*s*n*i):(t[10]=-1,t[14]=-2*n)}(this,t,r,n,s),this.check()}determinant(){return function(t){var e=t[0],r=t[1],n=t[2],s=t[3],i=t[4],o=t[5],a=t[6],c=t[7],u=t[8],l=t[9],h=t[10],d=t[11],f=t[12],A=t[13],m=t[14],p=t[15];return(e*o-r*i)*(h*p-d*m)-(e*a-n*i)*(l*p-d*A)+(e*c-s*i)*(l*m-h*A)+(r*a-n*o)*(u*p-d*f)-(r*c-s*o)*(u*m-h*f)+(n*c-s*a)*(u*A-l*f)}(this)}getScale(t=[-0,-0,-0]){return t[0]=Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]),t[1]=Math.sqrt(this[4]*this[4]+this[5]*this[5]+this[6]*this[6]),t[2]=Math.sqrt(this[8]*this[8]+this[9]*this[9]+this[10]*this[10]),t}getTranslation(t=[-0,-0,-0]){return t[0]=this[12],t[1]=this[13],t[2]=this[14],t}getRotation(t=[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],e=null){const r=this.getScale(e||[-0,-0,-0]),n=1/r[0],s=1/r[1],i=1/r[2];return t[0]=this[0]*n,t[1]=this[1]*s,t[2]=this[2]*i,t[3]=0,t[4]=this[4]*n,t[5]=this[5]*s,t[6]=this[6]*i,t[7]=0,t[8]=this[8]*n,t[9]=this[9]*s,t[10]=this[10]*i,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}getRotationMatrix3(t=[-0,-0,-0,-0,-0,-0,-0,-0,-0],e=null){const r=this.getScale(e||[-0,-0,-0]),n=1/r[0],s=1/r[1],i=1/r[2];return t[0]=this[0]*n,t[1]=this[1]*s,t[2]=this[2]*i,t[3]=this[4]*n,t[4]=this[5]*s,t[5]=this[6]*i,t[6]=this[8]*n,t[7]=this[9]*s,t[8]=this[10]*i,t}transpose(){return function(t,e){if(t===e){var r=e[1],n=e[2],s=e[3],i=e[6],o=e[7],a=e[11];t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=r,t[6]=e[9],t[7]=e[13],t[8]=n,t[9]=i,t[11]=e[14],t[12]=s,t[13]=o,t[14]=a}else t[0]=e[0],t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=e[1],t[5]=e[5],t[6]=e[9],t[7]=e[13],t[8]=e[2],t[9]=e[6],t[10]=e[10],t[11]=e[14],t[12]=e[3],t[13]=e[7],t[14]=e[11],t[15]=e[15]}(this,this),this.check()}invert(){return function(t,e){var r=e[0],n=e[1],s=e[2],i=e[3],o=e[4],a=e[5],c=e[6],u=e[7],l=e[8],h=e[9],d=e[10],f=e[11],A=e[12],m=e[13],p=e[14],B=e[15],g=r*a-n*o,y=r*c-s*o,C=r*u-i*o,b=n*c-s*a,w=n*u-i*a,T=s*u-i*c,E=l*m-h*A,M=l*p-d*A,v=l*B-f*A,I=h*p-d*m,_=h*B-f*m,F=d*B-f*p,D=g*F-y*_+C*I+b*v-w*M+T*E;D&&(D=1/D,t[0]=(a*F-c*_+u*I)*D,t[1]=(s*_-n*F-i*I)*D,t[2]=(m*T-p*w+B*b)*D,t[3]=(d*w-h*T-f*b)*D,t[4]=(c*v-o*F-u*M)*D,t[5]=(r*F-s*v+i*M)*D,t[6]=(p*C-A*T-B*y)*D,t[7]=(l*T-d*C+f*y)*D,t[8]=(o*_-a*v+u*E)*D,t[9]=(n*v-r*_-i*E)*D,t[10]=(A*w-m*C+B*g)*D,t[11]=(h*C-l*w-f*g)*D,t[12]=(a*M-o*I-c*E)*D,t[13]=(r*I-n*M+s*E)*D,t[14]=(m*y-A*b-p*g)*D,t[15]=(l*b-h*y+d*g)*D)}(this,this),this.check()}multiplyLeft(t){return Ye(this,t,this),this.check()}multiplyRight(t){return Ye(this,this,t),this.check()}rotateX(t){return function(t,e,r){var n=Math.sin(r),s=Math.cos(r),i=e[4],o=e[5],a=e[6],c=e[7],u=e[8],l=e[9],h=e[10],d=e[11];e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=i*s+u*n,t[5]=o*s+l*n,t[6]=a*s+h*n,t[7]=c*s+d*n,t[8]=u*s-i*n,t[9]=l*s-o*n,t[10]=h*s-a*n,t[11]=d*s-c*n}(this,this,t),this.check()}rotateY(t){return function(t,e,r){var n=Math.sin(r),s=Math.cos(r),i=e[0],o=e[1],a=e[2],c=e[3],u=e[8],l=e[9],h=e[10],d=e[11];e!==t&&(t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=i*s-u*n,t[1]=o*s-l*n,t[2]=a*s-h*n,t[3]=c*s-d*n,t[8]=i*n+u*s,t[9]=o*n+l*s,t[10]=a*n+h*s,t[11]=c*n+d*s}(this,this,t),this.check()}rotateZ(t){return function(t,e,r){var n=Math.sin(r),s=Math.cos(r),i=e[0],o=e[1],a=e[2],c=e[3],u=e[4],l=e[5],h=e[6],d=e[7];e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=i*s+u*n,t[1]=o*s+l*n,t[2]=a*s+h*n,t[3]=c*s+d*n,t[4]=u*s-i*n,t[5]=l*s-o*n,t[6]=h*s-a*n,t[7]=d*s-c*n}(this,this,t),this.check()}rotateXYZ([t,e,r]){return this.rotateX(t).rotateY(e).rotateZ(r)}rotateAxis(t,e){return function(t,e,r,n){var s,i,o,a,c,u,l,h,d,f,A,m,p,B,g,y,C,b,w,T,E,M,v,I,_=n[0],F=n[1],D=n[2],G=Math.hypot(_,F,D);G<Ee||(_*=G=1/G,F*=G,D*=G,s=Math.sin(r),o=1-(i=Math.cos(r)),a=e[0],c=e[1],u=e[2],l=e[3],h=e[4],d=e[5],f=e[6],A=e[7],m=e[8],p=e[9],B=e[10],g=e[11],y=_*_*o+i,C=F*_*o+D*s,b=D*_*o-F*s,w=_*F*o-D*s,T=F*F*o+i,E=D*F*o+_*s,M=_*D*o+F*s,v=F*D*o-_*s,I=D*D*o+i,t[0]=a*y+h*C+m*b,t[1]=c*y+d*C+p*b,t[2]=u*y+f*C+B*b,t[3]=l*y+A*C+g*b,t[4]=a*w+h*T+m*E,t[5]=c*w+d*T+p*E,t[6]=u*w+f*T+B*E,t[7]=l*w+A*T+g*E,t[8]=a*M+h*v+m*I,t[9]=c*M+d*v+p*I,t[10]=u*M+f*v+B*I,t[11]=l*M+A*v+g*I,e!==t&&(t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]))}(this,this,t,e),this.check()}scale(t){return Array.isArray(t)?Xe(this,this,t):Xe(this,this,[t,t,t]),this.check()}translate(t){return function(t,e,r){var n,s,i,o,a,c,u,l,h,d,f,A,m=r[0],p=r[1],B=r[2];e===t?(t[12]=e[0]*m+e[4]*p+e[8]*B+e[12],t[13]=e[1]*m+e[5]*p+e[9]*B+e[13],t[14]=e[2]*m+e[6]*p+e[10]*B+e[14],t[15]=e[3]*m+e[7]*p+e[11]*B+e[15]):(n=e[0],s=e[1],i=e[2],o=e[3],a=e[4],c=e[5],u=e[6],l=e[7],h=e[8],d=e[9],f=e[10],A=e[11],t[0]=n,t[1]=s,t[2]=i,t[3]=o,t[4]=a,t[5]=c,t[6]=u,t[7]=l,t[8]=h,t[9]=d,t[10]=f,t[11]=A,t[12]=n*m+a*p+h*B+e[12],t[13]=s*m+c*p+d*B+e[13],t[14]=i*m+u*p+f*B+e[14],t[15]=o*m+l*p+A*B+e[15])}(this,this,t),this.check()}transform(t,e){return 4===t.length?(e=function(t,e,r){var n=e[0],s=e[1],i=e[2],o=e[3];return t[0]=r[0]*n+r[4]*s+r[8]*i+r[12]*o,t[1]=r[1]*n+r[5]*s+r[9]*i+r[13]*o,t[2]=r[2]*n+r[6]*s+r[10]*i+r[14]*o,t[3]=r[3]*n+r[7]*s+r[11]*i+r[15]*o,t}(e||[-0,-0,-0,-0],t,this),ye(e,4),e):this.transformAsPoint(t,e)}transformAsPoint(t,e){const{length:r}=t;switch(r){case 2:e=Ie(e||[-0,-0],t,this);break;case 3:e=Ue(e||[-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return ye(e,t.length),e}transformAsVector(t,e){switch(t.length){case 2:e=_e(e||[-0,-0],t,this);break;case 3:e=Fe(e||[-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return ye(e,t.length),e}makeRotationX(t){return this.identity().rotateX(t)}makeTranslation(t,e,r){return this.identity().translate([t,e,r])}transformPoint(t,e){return be("Matrix4.transformPoint","3.0"),this.transformAsPoint(t,e)}transformVector(t,e){return be("Matrix4.transformVector","3.0"),this.transformAsPoint(t,e)}transformDirection(t,e){return be("Matrix4.transformDirection","3.0"),this.transformAsVector(t,e)}}function nr(){var t=new Me(4);return Me!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function sr(t,e,r){r*=.5;var n=Math.sin(r);return t[0]=n*e[0],t[1]=n*e[1],t[2]=n*e[2],t[3]=Math.cos(r),t}function ir(t,e,r){var n=e[0],s=e[1],i=e[2],o=e[3],a=r[0],c=r[1],u=r[2],l=r[3];return t[0]=n*l+o*a+s*u-i*c,t[1]=s*l+o*c+i*a-n*u,t[2]=i*l+o*u+n*c-s*a,t[3]=o*l-n*a-s*c-i*u,t}function or(t,e,r,n){var s,i,o,a,c,u=e[0],l=e[1],h=e[2],d=e[3],f=r[0],A=r[1],m=r[2],p=r[3];return(i=u*f+l*A+h*m+d*p)<0&&(i=-i,f=-f,A=-A,m=-m,p=-p),1-i>Ee?(s=Math.acos(i),o=Math.sin(s),a=Math.sin((1-n)*s)/o,c=Math.sin(n*s)/o):(a=1-n,c=n),t[0]=a*u+c*f,t[1]=a*l+c*A,t[2]=a*h+c*m,t[3]=a*d+c*p,t}function ar(t,e){var r,n=e[0]+e[4]+e[8];if(n>0)r=Math.sqrt(n+1),t[3]=.5*r,r=.5/r,t[0]=(e[5]-e[7])*r,t[1]=(e[6]-e[2])*r,t[2]=(e[1]-e[3])*r;else{var s=0;e[4]>e[0]&&(s=1),e[8]>e[3*s+s]&&(s=2);var i=(s+1)%3,o=(s+2)%3;r=Math.sqrt(e[3*s+s]-e[3*i+i]-e[3*o+o]+1),t[s]=.5*r,r=.5/r,t[3]=(e[3*i+o]-e[3*o+i])*r,t[i]=(e[3*i+s]+e[3*s+i])*r,t[o]=(e[3*o+s]+e[3*s+o])*r}return t}var cr,ur,lr,hr=function(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t},dr=function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t},fr=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]*e[3]},Ar=function(t,e,r,n){var s=e[0],i=e[1],o=e[2],a=e[3];return t[0]=s+n*(r[0]-s),t[1]=i+n*(r[1]-i),t[2]=o+n*(r[2]-o),t[3]=a+n*(r[3]-a),t},mr=function(t){var e=t[0],r=t[1],n=t[2],s=t[3];return Math.hypot(e,r,n,s)},pr=function(t){var e=t[0],r=t[1],n=t[2],s=t[3];return e*e+r*r+n*n+s*s},Br=function(t,e){var r=e[0],n=e[1],s=e[2],i=e[3],o=r*r+n*n+s*s+i*i;return o>0&&(o=1/Math.sqrt(o)),t[0]=r*o,t[1]=n*o,t[2]=s*o,t[3]=i*o,t},gr=(cr=Ge(),ur=Se(1,0,0),lr=Se(0,1,0),function(t,e,r){var n=Oe(e,r);return n<-.999999?(xe(cr,ur,e),Ne(cr)<1e-6&&xe(cr,lr,e),function(t,e){var r=e[0],n=e[1],s=e[2],i=r*r+n*n+s*s;i>0&&(i=1/Math.sqrt(i)),t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i}(cr,cr),sr(t,cr,Math.PI),t):n>.999999?(t[0]=0,t[1]=0,t[2]=0,t[3]=1,t):(xe(cr,e,r),t[0]=cr[0],t[1]=cr[1],t[2]=cr[2],t[3]=1+n,Br(t,t))});nr(),nr(),function(){var t=new Me(9);Me!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[5]=0,t[6]=0,t[7]=0),t[0]=1,t[4]=1,t[8]=1}();const yr=[0,0,0,1];class Cr extends Be{constructor(t=0,e=0,r=0,n=1){super(-0,-0,-0,-0),Array.isArray(t)&&1===arguments.length?this.copy(t):this.set(t,e,r,n)}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this[3]=t[3],this.check()}set(t,e,r,n){return this[0]=t,this[1]=e,this[2]=r,this[3]=n,this.check()}fromMatrix3(t){return ar(this,t),this.check()}identity(){return function(t){t[0]=0,t[1]=0,t[2]=0,t[3]=1}(this),this.check()}fromAxisRotation(t,e){return sr(this,t,e),this.check()}setAxisAngle(t,e){return this.fromAxisRotation(t,e)}get ELEMENTS(){return 4}get x(){return this[0]}set x(t){this[0]=ge(t)}get y(){return this[1]}set y(t){this[1]=ge(t)}get z(){return this[2]}set z(t){this[2]=ge(t)}get w(){return this[3]}set w(t){this[3]=ge(t)}len(){return mr(this)}lengthSquared(){return pr(this)}dot(t,e){if(void 0!==e)throw new Error("Quaternion.dot only takes one argument");return fr(this,t)}rotationTo(t,e){return gr(this,t,e),this.check()}add(t,e){if(void 0!==e)throw new Error("Quaternion.add only takes one argument");return hr(this,this,t),this.check()}calculateW(){return function(t,e){var r=e[0],n=e[1],s=e[2];t[0]=r,t[1]=n,t[2]=s,t[3]=Math.sqrt(Math.abs(1-r*r-n*n-s*s))}(this,this),this.check()}conjugate(){return function(t,e){t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=e[3]}(this,this),this.check()}invert(){return function(t,e){var r=e[0],n=e[1],s=e[2],i=e[3],o=r*r+n*n+s*s+i*i,a=o?1/o:0;t[0]=-r*a,t[1]=-n*a,t[2]=-s*a,t[3]=i*a}(this,this),this.check()}lerp(t,e,r){return Ar(this,t,e,r),this.check()}multiplyRight(t,e){return oe(!e),ir(this,this,t),this.check()}multiplyLeft(t,e){return oe(!e),ir(this,t,this),this.check()}normalize(){const t=this.len(),e=t>0?1/t:0;return this[0]=this[0]*e,this[1]=this[1]*e,this[2]=this[2]*e,this[3]=this[3]*e,0===t&&(this[3]=1),this.check()}rotateX(t){return function(t,e,r){r*=.5;var n=e[0],s=e[1],i=e[2],o=e[3],a=Math.sin(r),c=Math.cos(r);t[0]=n*c+o*a,t[1]=s*c+i*a,t[2]=i*c-s*a,t[3]=o*c-n*a}(this,this,t),this.check()}rotateY(t){return function(t,e,r){r*=.5;var n=e[0],s=e[1],i=e[2],o=e[3],a=Math.sin(r),c=Math.cos(r);t[0]=n*c-i*a,t[1]=s*c+o*a,t[2]=i*c+n*a,t[3]=o*c-s*a}(this,this,t),this.check()}rotateZ(t){return function(t,e,r){r*=.5;var n=e[0],s=e[1],i=e[2],o=e[3],a=Math.sin(r),c=Math.cos(r);t[0]=n*c+s*a,t[1]=s*c-n*a,t[2]=i*c+o*a,t[3]=o*c-i*a}(this,this,t),this.check()}scale(t){return dr(this,this,t),this.check()}slerp(t,e,r){switch(arguments.length){case 1:({start:t=yr,target:e,ratio:r}=arguments[0]);break;case 2:[e,r]=arguments,t=this}return or(this,t,e,r),this.check()}transformVector4(t,e=t){return function(t,e,r){var n=e[0],s=e[1],i=e[2],o=r[0],a=r[1],c=r[2],u=r[3],l=u*n+a*i-c*s,h=u*s+c*n-o*i,d=u*i+o*s-a*n,f=-o*n-a*s-c*i;t[0]=l*u+f*-o+h*-c-d*-a,t[1]=h*u+f*-a+d*-o-l*-c,t[2]=d*u+f*-c+l*-a-h*-o,t[3]=e[3]}(e,t,this),ye(e,4)}lengthSq(){return this.lengthSquared()}setFromAxisAngle(t,e){return this.setAxisAngle(t,e)}premultiply(t,e){return this.multiplyLeft(t,e)}multiply(t,e){return this.multiplyRight(t,e)}}var br=.1,wr=1e-12,Tr=1e-15;Math.PI,Math.PI,Math.PI,Math.PI;const Er=t=>t,Mr=new Pe;function vr(t,e=Mr){return function(t,e,r=Er){return he(t)?(e[0]=r(t[0]),e[1]=r(t[1]),e[2]=t[2]):"longitude"in t?(e[0]=r(t.longitude),e[1]=r(t.latitude),e[2]=t.height):(e[0]=r(t.x),e[1]=r(t.y),e[2]=t.z),e}(t,e,ue._cartographicRadians?Er:fe)}function Ir(t,e){return function(t,e,r=Er){return he(e)?(e[0]=r(t[0]),e[1]=r(t[1]),e[2]=t[2]):"longitude"in e?(e.longitude=r(t[0]),e.latitude=r(t[1]),e.height=t[2]):(e.x=r(t[0]),e.y=r(t[1]),e.z=t[2]),e}(t,e,ue._cartographicRadians?Er:Ae)}const _r=new Pe,Fr=new Pe,Dr=new Pe;const Gr=new Pe,Rr={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"}},Sr={north:[-1,0,0],east:[0,1,0],up:[0,0,1],south:[1,0,0],west:[0,-1,0],down:[0,0,-1]},Or={east:new Pe,north:new Pe,up:new Pe,west:new Pe,south:new Pe,down:new Pe},xr=new Pe,Ur=new Pe,Lr=new Pe;function Nr(t,e,r,n,s,i){const o=Rr[e]&&Rr[e][r];let a,c,u;oe(o&&(!n||n===o));const l=Gr.copy(s);if(pe(l.x,0,1e-14)&&pe(l.y,0,1e-14)){const t=Math.sign(l.z);a=xr.fromArray(Sr[e]),"east"!==e&&"west"!==e&&a.scale(t),c=Ur.fromArray(Sr[r]),"east"!==r&&"west"!==r&&c.scale(t),u=Lr.fromArray(Sr[n]),"east"!==n&&"west"!==n&&u.scale(t)}else{const{up:s,east:i,north:o}=Or;i.set(-l.y,l.x,0).normalize(),t.geodeticSurfaceNormal(l,s),o.copy(s).cross(i);const{down:h,west:d,south:f}=Or;h.copy(s).scale(-1),d.copy(i).scale(-1),f.copy(o).scale(-1),a=Or[e],c=Or[r],u=Or[n]}return i[0]=a.x,i[1]=a.y,i[2]=a.z,i[3]=0,i[4]=c.x,i[5]=c.y,i[6]=c.z,i[7]=0,i[8]=u.x,i[9]=u.y,i[10]=u.z,i[11]=0,i[12]=l.x,i[13]=l.y,i[14]=l.z,i[15]=1,i}const Hr=new Pe,Jr=new Pe,Pr=new Pe,jr=new Pe,kr=new Pe,Vr=new Pe;let Kr;class Qr{static get WGS84(){return Kr=Kr||new Qr(6378137,6378137,6356752.314245179),Kr}constructor(t=0,e=0,r=0){oe(t>=0),oe(e>=0),oe(r>=0),this.radii=new Pe(t,e,r),this.radiiSquared=new Pe(t*t,e*e,r*r),this.radiiToTheFourth=new Pe(t*t*t*t,e*e*e*e,r*r*r*r),this.oneOverRadii=new Pe(0===t?0:1/t,0===e?0:1/e,0===r?0:1/r),this.oneOverRadiiSquared=new Pe(0===t?0:1/(t*t),0===e?0:1/(e*e),0===r?0:1/(r*r)),this.minimumRadius=Math.min(t,e,r),this.maximumRadius=Math.max(t,e,r),this.centerToleranceSquared=br,0!==this.radiiSquared.z&&(this.squaredXOverSquaredZ=this.radiiSquared.x/this.radiiSquared.z),Object.freeze(this)}equals(t){return this===t||Boolean(t&&this.radii.equals(t.radii))}toString(){return this.radii.toString()}cartographicToCartesian(t,e=[0,0,0]){const r=Jr,n=Pr,[,,s]=t;this.geodeticSurfaceNormalCartographic(t,r),n.copy(this.radiiSquared).scale(r);const i=Math.sqrt(r.dot(n));return n.scale(1/i),r.scale(s),n.add(r),n.to(e)}cartesianToCartographic(t,e=[0,0,0]){Vr.from(t);const r=this.scaleToGeodeticSurface(Vr,jr);if(!r)return;const n=this.geodeticSurfaceNormal(r,Jr),s=kr;s.copy(Vr).subtract(r);return Ir([Math.atan2(n.y,n.x),Math.asin(n.z),Math.sign(Oe(s,Vr))*Re(s)],e)}eastNorthUpToFixedFrame(t,e=new rr){return Nr(this,"east","north","up",t,e)}localFrameToFixedFrame(t,e,r,n,s=new rr){return Nr(this,t,e,r,n,s)}geocentricSurfaceNormal(t,e=[0,0,0]){return Hr.from(t).normalize().to(e)}geodeticSurfaceNormalCartographic(t,e=[0,0,0]){const r=vr(t),n=r[0],s=r[1],i=Math.cos(s);return Hr.set(i*Math.cos(n),i*Math.sin(n),Math.sin(s)).normalize(),Hr.to(e)}geodeticSurfaceNormal(t,e=[0,0,0]){return Hr.from(t).scale(this.oneOverRadiiSquared).normalize().to(e)}scaleToGeodeticSurface(t,e){return function(t,e,r=new Pe){const{oneOverRadii:n,oneOverRadiiSquared:s,centerToleranceSquared:i}=e;_r.from(t);const o=t.x,a=t.y,c=t.z,u=n.x,l=n.y,h=n.z,d=o*o*u*u,f=a*a*l*l,A=c*c*h*h,m=d+f+A,p=Math.sqrt(1/m);if(!Number.isFinite(p))return;const B=Fr;if(B.copy(t).scale(p),m<i)return B.to(r);const g=s.x,y=s.y,C=s.z,b=Dr;b.set(B.x*g*2,B.y*y*2,B.z*C*2);let w,T,E,M,v=(1-p)*t.len()/(.5*b.len()),I=0;do{v-=I,w=1/(1+v*g),T=1/(1+v*y),E=1/(1+v*C);const t=w*w,e=T*T,r=E*E;M=d*t+f*e+A*r-1,I=M/(-2*(d*(t*w)*g+f*(e*T)*y+A*(r*E)*C))}while(Math.abs(M)>wr);return _r.scale([w,T,E]).to(r)}(t,this,e)}scaleToGeocentricSurface(t,e=[0,0,0]){jr.from(t);const r=jr.x,n=jr.y,s=jr.z,i=this.oneOverRadiiSquared,o=1/Math.sqrt(r*r*i.x+n*n*i.y+s*s*i.z);return jr.multiplyScalar(o).to(e)}transformPositionToScaledSpace(t,e=[0,0,0]){return jr.from(t).scale(this.oneOverRadii).to(e)}transformPositionFromScaledSpace(t,e=[0,0,0]){return jr.from(t).scale(this.radii).to(e)}getSurfaceNormalIntersectionWithZAxis(t,e=0,r=[0,0,0]){oe(pe(this.radii.x,this.radii.y,Tr)),oe(this.radii.z>0),jr.from(t);const n=jr.z*(1-this.squaredXOverSquaredZ);if(!(Math.abs(n)>=this.radii.z-e))return jr.set(0,0,n).to(r)}}class qr{constructor(t,e,r){p(this,"item",void 0),p(this,"previous",void 0),p(this,"next",void 0),this.item=t,this.previous=e,this.next=r}}class zr{constructor(){p(this,"head",null),p(this,"tail",null),p(this,"_length",0)}get length(){return this._length}add(t){const e=new qr(t,this.tail,null);return this.tail?(this.tail.next=e,this.tail=e):(this.head=e,this.tail=e),++this._length,e}remove(t){t&&(t.previous&&t.next?(t.previous.next=t.next,t.next.previous=t.previous):t.previous?(t.previous.next=null,this.tail=t.previous):t.next?(t.next.previous=null,this.head=t.next):(this.head=null,this.tail=null),t.next=null,t.previous=null,--this._length)}splice(t,e){t!==e&&(this.remove(e),this._insert(t,e))}_insert(t,e){const r=t.next;t.next=e,this.tail===t?this.tail=e:r.previous=e,e.next=r,e.previous=t,++this._length}}function Wr(t){return null!=t}class Yr{constructor(){p(this,"_list",void 0),p(this,"_sentinel",void 0),p(this,"_trimTiles",void 0),this._list=new zr,this._sentinel=this._list.add("sentinel"),this._trimTiles=!1}reset(){this._list.splice(this._list.tail,this._sentinel)}touch(t){const e=t._cacheNode;Wr(e)&&this._list.splice(this._sentinel,e)}add(t,e,r){Wr(e._cacheNode)||(e._cacheNode=this._list.add(e),r&&r(t,e))}unloadTile(t,e,r){const n=e._cacheNode;Wr(n)&&(this._list.remove(n),e._cacheNode=void 0,r&&r(t,e))}unloadTiles(t,e){const r=this._trimTiles;this._trimTiles=!1;const n=this._list,s=1024*t.maximumMemoryUsage*1024,i=this._sentinel;let o=n.head;for(;o!==i&&(t.gpuMemoryUsageInBytes>s||r);){const r=o.item;o=o.next,this.unloadTile(t,r,e)}}trim(){this._trimTiles=!0}}const Xr=Object.freeze({OUTSIDE:-1,INTERSECTING:0,INSIDE:1});new Pe,new Pe;const Zr=new Pe,$r=new Pe;class tn{constructor(t=[0,0,0],e=0){this.radius=-0,this.center=new Pe,this.fromCenterRadius(t,e)}fromCenterRadius(t,e){return this.center.from(t),this.radius=e,this}fromCornerPoints(t,e){return e=Zr.from(e),this.center=(new Pe).from(t).add(e).scale(.5),this.radius=this.center.distance(e),this}equals(t){return this===t||Boolean(t)&&this.center.equals(t.center)&&this.radius===t.radius}clone(){return new tn(this.center,this.radius)}union(t){const e=this.center,r=this.radius,n=t.center,s=t.radius,i=Zr.copy(n).subtract(e),o=i.magnitude();if(r>=o+s)return this.clone();if(s>=o+r)return t.clone();const a=.5*(r+o+s);return $r.copy(i).scale((-r+a)/o).add(e),this.center.copy($r),this.radius=a,this}expand(t){const e=(t=Zr.from(t)).subtract(this.center).magnitude();return e>this.radius&&(this.radius=e),this}transform(t){this.center.transform(t);const e=function(t,e){var r=e[0],n=e[1],s=e[2],i=e[4],o=e[5],a=e[6],c=e[8],u=e[9],l=e[10];return t[0]=Math.hypot(r,n,s),t[1]=Math.hypot(i,o,a),t[2]=Math.hypot(c,u,l),t}(Zr,t);return this.radius=Math.max(e[0],Math.max(e[1],e[2]))*this.radius,this}distanceSquaredTo(t){const e=this.distanceTo(t);return e*e}distanceTo(t){const e=(t=Zr.from(t)).subtract(this.center);return Math.max(0,e.len()-this.radius)}intersectPlane(t){const e=this.center,r=this.radius,n=t.normal.dot(e)+t.distance;return n<-r?Xr.OUTSIDE:n<r?Xr.INTERSECTING:Xr.INSIDE}}const en=new Pe,rn=new Pe,nn=new Pe,sn=new Pe,on=new Pe,an=new Pe,cn=new Pe,un=0,ln=1,hn=2,dn=3,fn=4,An=5,mn=6,pn=7,Bn=8;class gn{constructor(t=[0,0,0],e=[0,0,0,0,0,0,0,0,0]){this.center=(new Pe).from(t),this.halfAxes=new We(e)}get halfSize(){const t=this.halfAxes.getColumn(0),e=this.halfAxes.getColumn(1),r=this.halfAxes.getColumn(2);return[new Pe(t).len(),new Pe(e).len(),new Pe(r).len()]}get quaternion(){const t=this.halfAxes.getColumn(0),e=this.halfAxes.getColumn(1),r=this.halfAxes.getColumn(2),n=new Pe(t).normalize(),s=new Pe(e).normalize(),i=new Pe(r).normalize();return(new Cr).fromMatrix3(new We([...n,...s,...i]))}fromCenterHalfSizeQuaternion(t,e,r){const n=new Cr(r),s=(new We).fromQuaternion(n);return s[0]=s[0]*e[0],s[1]=s[1]*e[0],s[2]=s[2]*e[0],s[3]=s[3]*e[1],s[4]=s[4]*e[1],s[5]=s[5]*e[1],s[6]=s[6]*e[2],s[7]=s[7]*e[2],s[8]=s[8]*e[2],this.center=(new Pe).from(t),this.halfAxes=s,this}clone(){return new gn(this.center,this.halfAxes)}equals(t){return this===t||Boolean(t)&&this.center.equals(t.center)&&this.halfAxes.equals(t.halfAxes)}getBoundingSphere(t=new tn){const e=this.halfAxes,r=e.getColumn(0,nn),n=e.getColumn(1,sn),s=e.getColumn(2,on),i=en.copy(r).add(n).add(s);return t.center.copy(this.center),t.radius=i.magnitude(),t}intersectPlane(t){const e=this.center,r=t.normal,n=this.halfAxes,s=r.x,i=r.y,o=r.z,a=Math.abs(s*n[un]+i*n[ln]+o*n[hn])+Math.abs(s*n[dn]+i*n[fn]+o*n[An])+Math.abs(s*n[mn]+i*n[pn]+o*n[Bn]),c=r.dot(e)+t.distance;return c<=-a?Xr.OUTSIDE:c>=a?Xr.INSIDE:Xr.INTERSECTING}distanceTo(t){return Math.sqrt(this.distanceSquaredTo(t))}distanceSquaredTo(t){const e=rn.from(t).subtract(this.center),r=this.halfAxes,n=r.getColumn(0,nn),s=r.getColumn(1,sn),i=r.getColumn(2,on),o=n.magnitude(),a=s.magnitude(),c=i.magnitude();n.normalize(),s.normalize(),i.normalize();let u,l=0;return u=Math.abs(e.dot(n))-o,u>0&&(l+=u*u),u=Math.abs(e.dot(s))-a,u>0&&(l+=u*u),u=Math.abs(e.dot(i))-c,u>0&&(l+=u*u),l}computePlaneDistances(t,e,r=[-0,-0]){let n=Number.POSITIVE_INFINITY,s=Number.NEGATIVE_INFINITY;const i=this.center,o=this.halfAxes,a=o.getColumn(0,nn),c=o.getColumn(1,sn),u=o.getColumn(2,on),l=an.copy(a).add(c).add(u).add(i),h=cn.copy(l).subtract(t);let d=e.dot(h);return n=Math.min(d,n),s=Math.max(d,s),l.copy(i).add(a).add(c).subtract(u),h.copy(l).subtract(t),d=e.dot(h),n=Math.min(d,n),s=Math.max(d,s),l.copy(i).add(a).subtract(c).add(u),h.copy(l).subtract(t),d=e.dot(h),n=Math.min(d,n),s=Math.max(d,s),l.copy(i).add(a).subtract(c).subtract(u),h.copy(l).subtract(t),d=e.dot(h),n=Math.min(d,n),s=Math.max(d,s),i.copy(l).subtract(a).add(c).add(u),h.copy(l).subtract(t),d=e.dot(h),n=Math.min(d,n),s=Math.max(d,s),i.copy(l).subtract(a).add(c).subtract(u),h.copy(l).subtract(t),d=e.dot(h),n=Math.min(d,n),s=Math.max(d,s),i.copy(l).subtract(a).subtract(c).add(u),h.copy(l).subtract(t),d=e.dot(h),n=Math.min(d,n),s=Math.max(d,s),i.copy(l).subtract(a).subtract(c).subtract(u),h.copy(l).subtract(t),d=e.dot(h),n=Math.min(d,n),s=Math.max(d,s),r[0]=n,r[1]=s,r}transform(t){this.center.transformAsPoint(t);const e=this.halfAxes.getColumn(0,nn);e.transformAsPoint(t);const r=this.halfAxes.getColumn(1,sn);r.transformAsPoint(t);const n=this.halfAxes.getColumn(2,on);return n.transformAsPoint(t),this.halfAxes=new We([...e,...r,...n]),this}getTransform(){throw new Error("not implemented")}}const yn=new Pe,Cn=new Pe;class bn{constructor(t=[0,0,1],e=0){this.normal=new Pe,this.distance=-0,this.fromNormalDistance(t,e)}fromNormalDistance(t,e){return oe(Number.isFinite(e)),this.normal.from(t).normalize(),this.distance=e,this}fromPointNormal(t,e){t=yn.from(t),this.normal.from(e).normalize();const r=-this.normal.dot(t);return this.distance=r,this}fromCoefficients(t,e,r,n){return this.normal.set(t,e,r),oe(pe(this.normal.len(),1)),this.distance=n,this}clone(t){return new bn(this.normal,this.distance)}equals(t){return pe(this.distance,t.distance)&&pe(this.normal,t.normal)}getPointDistance(t){return this.normal.dot(t)+this.distance}transform(t){const e=Cn.copy(this.normal).transformAsVector(t).normalize(),r=this.normal.scale(-this.distance).transform(t);return this.fromPointNormal(r,e)}projectPointOntoPlane(t,e=[0,0,0]){t=yn.from(t);const r=this.getPointDistance(t),n=Cn.copy(this.normal).scale(r);return t.subtract(n).to(e)}}const wn=[new Pe([1,0,0]),new Pe([0,1,0]),new Pe([0,0,1])],Tn=new Pe,En=new Pe;new bn(new Pe(1,0,0),0);class Mn{static get MASK_OUTSIDE(){return 4294967295}static get MASK_INSIDE(){return 0}static get MASK_INDETERMINATE(){return 2147483647}constructor(t=[]){this.planes=t,oe(this.planes.every((t=>t instanceof bn)))}fromBoundingSphere(t){this.planes.length=2*wn.length;const e=t.center,r=t.radius;let n=0;for(const t of wn){let s=this.planes[n],i=this.planes[n+1];s||(s=this.planes[n]=new bn),i||(i=this.planes[n+1]=new bn);const o=Tn.copy(t).scale(-r).add(e);t.dot(o),s.fromPointNormal(o,t);const a=Tn.copy(t).scale(r).add(e),c=En.copy(t).negate();c.dot(a),i.fromPointNormal(a,c),n+=2}return this}computeVisibility(t){oe(t);let e=Xr.INSIDE;for(const r of this.planes){switch(t.intersectPlane(r)){case Xr.OUTSIDE:return Xr.OUTSIDE;case Xr.INTERSECTING:e=Xr.INTERSECTING}}return e}computeVisibilityWithPlaneMask(t,e){if(oe(t,"boundingVolume is required."),oe(Number.isFinite(e),"parentPlaneMask is required."),e===Mn.MASK_OUTSIDE||e===Mn.MASK_INSIDE)return e;let r=Mn.MASK_INSIDE;const n=this.planes;for(let s=0;s<this.planes.length;++s){const i=s<31?1<<s:0;if(s<31&&0==(e&i))continue;const o=n[s],a=t.intersectPlane(o);if(a===Xr.OUTSIDE)return Mn.MASK_OUTSIDE;a===Xr.INTERSECTING&&(r|=i)}return r}}const vn=new Pe,In=new Pe,_n=new Pe,Fn=new Pe,Dn=new Pe;class Gn{constructor(t={}){t={near:1,far:5e8,...t},this.left=t.left,this._left=void 0,this.right=t.right,this._right=void 0,this.top=t.top,this._top=void 0,this.bottom=t.bottom,this._bottom=void 0,this.near=t.near,this._near=this.near,this.far=t.far,this._far=this.far,this._cullingVolume=new Mn([new bn,new bn,new bn,new bn,new bn,new bn]),this._perspectiveMatrix=new rr,this._infinitePerspective=new rr}clone(){return new Gn({right:this.right,left:this.left,top:this.top,bottom:this.bottom,near:this.near,far:this.far})}equals(t){return t&&t instanceof Gn&&this.right===t.right&&this.left===t.left&&this.top===t.top&&this.bottom===t.bottom&&this.near===t.near&&this.far===t.far}get projectionMatrix(){return Rn(this),this._perspectiveMatrix}get infiniteProjectionMatrix(){return Rn(this),this._infinitePerspective}computeCullingVolume(t,e,r){oe(t,"position is required."),oe(e,"direction is required."),oe(r,"up is required.");const n=this._cullingVolume.planes;r=vn.copy(r).normalize();const s=In.copy(e).cross(r).normalize(),i=_n.copy(e).multiplyByScalar(this.near).add(t),o=Fn.copy(e).multiplyByScalar(this.far).add(t);let a=Dn;return a.copy(s).multiplyByScalar(this.left).add(i).subtract(t).cross(r),n[0].fromPointNormal(t,a),a.copy(s).multiplyByScalar(this.right).add(i).subtract(t).cross(r).negate(),n[1].fromPointNormal(t,a),a.copy(r).multiplyByScalar(this.bottom).add(i).subtract(t).cross(s).negate(),n[2].fromPointNormal(t,a),a.copy(r).multiplyByScalar(this.top).add(i).subtract(t).cross(s),n[3].fromPointNormal(t,a),a=(new Pe).copy(e),n[4].fromPointNormal(i,a),a.negate(),n[5].fromPointNormal(o,a),this._cullingVolume}getPixelDimensions(t,e,r,n){Rn(this),oe(Number.isFinite(t)&&Number.isFinite(e)),oe(t>0),oe(e>0),oe(r>0),oe(n);const s=1/this.near;let i=this.top*s;const o=2*r*i/e;i=this.right*s;const a=2*r*i/t;return n.x=a,n.y=o,n}}function Rn(t){oe(Number.isFinite(t.right)&&Number.isFinite(t.left)&&Number.isFinite(t.top)&&Number.isFinite(t.bottom)&&Number.isFinite(t.near)&&Number.isFinite(t.far));const{top:e,bottom:r,right:n,left:s,near:i,far:o}=t;e===t._top&&r===t._bottom&&s===t._left&&n===t._right&&i===t._near&&o===t._far||(oe(t.near>0&&t.near<t.far,"near must be greater than zero and less than far."),t._left=s,t._right=n,t._top=e,t._bottom=r,t._near=i,t._far=o,t._perspectiveMatrix=(new rr).frustum({left:s,right:n,bottom:r,top:e,near:i,far:o}),t._infinitePerspective=(new rr).frustum({left:s,right:n,bottom:r,top:e,near:i,far:1/0}))}class Sn{constructor(t={}){t={near:1,far:5e8,xOffset:0,yOffset:0,...t},this._offCenterFrustum=new Gn,this.fov=t.fov,this._fov=void 0,this._fovy=void 0,this._sseDenominator=void 0,this.aspectRatio=t.aspectRatio,this._aspectRatio=void 0,this.near=t.near,this._near=this.near,this.far=t.far,this._far=this.far,this.xOffset=t.xOffset,this._xOffset=this.xOffset,this.yOffset=t.yOffset,this._yOffset=this.yOffset}clone(){return new Sn({aspectRatio:this.aspectRatio,fov:this.fov,near:this.near,far:this.far})}equals(t){return null!=t&&t instanceof Sn&&(On(this),On(t),this.fov===t.fov&&this.aspectRatio===t.aspectRatio&&this.near===t.near&&this.far===t.far&&this._offCenterFrustum.equals(t._offCenterFrustum))}get projectionMatrix(){return On(this),this._offCenterFrustum.projectionMatrix}get infiniteProjectionMatrix(){return On(this),this._offCenterFrustum.infiniteProjectionMatrix}get fovy(){return On(this),this._fovy}get sseDenominator(){return On(this),this._sseDenominator}computeCullingVolume(t,e,r){return On(this),this._offCenterFrustum.computeCullingVolume(t,e,r)}getPixelDimensions(t,e,r,n){return On(this),this._offCenterFrustum.getPixelDimensions(t,e,r,n)}}function On(t){oe(Number.isFinite(t.fov)&&Number.isFinite(t.aspectRatio)&&Number.isFinite(t.near)&&Number.isFinite(t.far));const e=t._offCenterFrustum;t.fov===t._fov&&t.aspectRatio===t._aspectRatio&&t.near===t._near&&t.far===t._far&&t.xOffset===t._xOffset&&t.yOffset===t._yOffset||(oe(t.fov>=0&&t.fov<Math.PI),oe(t.aspectRatio>0),oe(t.near>=0&&t.near<t.far),t._aspectRatio=t.aspectRatio,t._fov=t.fov,t._fovy=t.aspectRatio<=1?t.fov:2*Math.atan(Math.tan(.5*t.fov)/t.aspectRatio),t._near=t.near,t._far=t.far,t._sseDenominator=2*Math.tan(.5*t._fovy),t._xOffset=t.xOffset,t._yOffset=t.yOffset,e.top=t.near*Math.tan(.5*t._fovy),e.bottom=-e.top,e.right=t.aspectRatio*e.top,e.left=-e.right,e.near=t.near,e.far=t.far,e.right+=t.xOffset,e.left+=t.xOffset,e.top+=t.yOffset,e.bottom+=t.yOffset)}new Pe,new Pe,new Pe,new Pe,new Pe,new Pe,new Pe,new Pe,new Pe,new Pe,new Pe,new Pe,new We,new We,new We,new We,new We,new Pe,new Pe,new Pe,new Pe,new Pe,new We,new We,new We;const xn=new Pe,Un=new Pe,Ln=new Mn([new bn,new bn,new bn,new bn,new bn,new bn]);function Nn(t,e){const{cameraDirection:r,cameraUp:n,height:s}=t,{metersPerUnit:i}=t.distanceScales,o=t.unprojectPosition(t.center),a=Qr.WGS84.cartographicToCartesian(o,new Pe),c=Qr.WGS84.eastNorthUpToFixedFrame(a),u=t.unprojectPosition(t.cameraPosition),l=Qr.WGS84.cartographicToCartesian(u,new Pe),h=new Pe(c.transformAsVector(new Pe(r).scale(i))).normalize(),d=new Pe(c.transformAsVector(new Pe(n).scale(i))).normalize();return function(t,e){const r=t.getFrustumPlanes();let n=0;for(const s in r){const i=r[s],o=i.normal.dot(t.center);Un.copy(i.normal).scale(i.distance-o).add(t.center);const a=t.unprojectPosition(Un),c=Qr.WGS84.cartographicToCartesian(a,new Pe);Ln.planes[n++].fromPointNormal(c,xn.copy(e).subtract(c))}}(t,a),{camera:{position:l,direction:h,up:d},viewport:t,height:s,cullingVolume:Ln,frameNumber:e,sseDenominator:1.15}}const Hn=6356752.314245179,Jn=new Pe;function Pn(t){const{halfAxes:e,radius:r,width:n,height:s}=t;if(e){const t=function(t){t.getColumn(0,Jn);const e=t.getColumn(1),r=t.getColumn(2),n=Jn.add(e).add(r);return n.len()}(e);return Math.log2(Hn/t)}if(r)return Math.log2(Hn/r);if(s&&n){return(Math.log2(6378137/n)+Math.log2(6378137/s))/2}return 1}const jn=0,kn=1,Vn=3,Kn=4,Qn=5,qn=1,zn=2,Wn="empty",Yn="scenegraph",Xn="pointcloud",Zn="mesh",$n="I3S",ts="TILES3D",es="geometricError",rs=1;function ns(t){return null!=t}const ss=new Pe,is=new Pe,os=new Pe;function as(t,e,r){if(o(t,"3D Tile: boundingVolume must be defined"),t.box)return function(t,e,r){const n=new Pe(t[0],t[1],t[2]);e.transform(n,n);let s=[];if(10===t.length){const e=t.slice(3,6),r=new Cr;r.fromArray(t,6);const n=new Pe([1,0,0]),i=new Pe([0,1,0]),o=new Pe([0,0,1]);n.transformByQuaternion(r),n.scale(e[0]),i.transformByQuaternion(r),i.scale(e[1]),o.transformByQuaternion(r),o.scale(e[2]),s=[...n.toArray(),...i.toArray(),...o.toArray()]}else s=[...t.slice(3,6),...t.slice(6,9),...t.slice(9,12)];const i=e.transformAsVector(s.slice(0,3)),o=e.transformAsVector(s.slice(3,6)),a=e.transformAsVector(s.slice(6,9)),c=new We([i[0],i[1],i[2],o[0],o[1],o[2],a[0],a[1],a[2]]);if(ns(r))return r.center=n,r.halfAxes=c,r;return new gn(n,c)}(t.box,e,r);if(t.region){const[e,r,n,s,i,o]=t.region,a=Qr.WGS84.cartographicToCartesian([me(e),me(s),i],is),c=Qr.WGS84.cartographicToCartesian([me(n),me(r),o],os),u=(new Pe).addVectors(a,c).multiplyScalar(.5),l=(new Pe).subVectors(a,c).len()/2;return cs([u[0],u[1],u[2],l],new rr)}if(t.sphere)return cs(t.sphere,e,r);throw new Error("3D Tile: boundingVolume must contain a sphere, region, or box")}function cs(t,e,r){const n=new Pe(t[0],t[1],t[2]);e.transform(n,n);const s=e.getScale(ss),i=Math.max(Math.max(s[0],s[1]),s[2]),o=t[3]*i;return ns(r)?(r.center=n,r.radius=o,r):new tn(n,o)}function us(t,e){if(t.dynamicScreenSpaceError&&t.dynamicScreenSpaceErrorComputedDensity){const r=t.dynamicScreenSpaceErrorComputedDensity,n=t.dynamicScreenSpaceErrorFactor,s=function(t,e){const r=t*e;return 1-Math.exp(-r*r)}(e,r)*n;return s}return 0}function ls(t,e){const r=e.viewport,n=r.constructor,{longitude:s,latitude:i,height:o,width:a,bearing:c,zoom:u}=r,l=new n({longitude:s,latitude:i,height:o,width:a,bearing:c,zoom:u,pitch:0}),h=t.header.mbs[1],d=t.header.mbs[0],f=t.header.mbs[2],A=t.header.mbs[3],m=[...t.boundingVolume.center],p=l.unprojectPosition(l.cameraPosition),B=Qr.WGS84.cartographicToCartesian(p,new Pe),g=new Pe(B).subtract(m).normalize(),y=new rr;Qr.WGS84.eastNorthUpToFixedFrame(m,y);const C=new rr(y).invert(),b=new Pe(B).transform(C),w=Math.sqrt(b[0]*b[0]+b[1]*b[1]),T=w*w/b[2],E=new Pe([b[0],b[1],T]).transform(y),M=new Pe(E).subtract(m).normalize(),v=g.cross(M).normalize().scale(A),I=new Pe(m).add(v),_=Qr.WGS84.cartesianToCartographic(I),F=l.project([d,h,f]),D=l.project(_);return new Pe(F).subtract(D).magnitude()}new Pe,new Pe,new rr,new Pe,new Pe,new Pe;class hs{constructor(t=0){p(this,"_map",new Map),p(this,"_array",void 0),p(this,"_length",void 0),this._array=new Array(t),this._length=t}get length(){return this._length}set length(t){this._length=t,t>this._array.length&&(this._array.length=t)}get values(){return this._array}get(t){return o(t<this._array.length),this._array[t]}set(t,e){o(t>=0),t>=this.length&&(this.length=t+1),this._map.has(this._array[t])&&this._map.delete(this._array[t]),this._array[t]=e,this._map.set(e,t)}delete(t){const e=this._map.get(t);e>=0&&(this._array.splice(e,1),this._map.delete(t),this.length--)}peek(){return this._array[this._length-1]}push(t){if(!this._map.has(t)){const e=this.length++;this._array[e]=t,this._map.set(t,e)}}pop(){const t=this._array[--this.length];return this._map.delete(t),t}reserve(t){o(t>=0),t>this._array.length&&(this._array.length=t)}resize(t){o(t>=0),this.length=t}trim(t){null==t&&(t=this.length),this._array.length=t}reset(){this._array=[],this._map=new Map,this._length=0}find(t){return this._map.has(t)}}const ds={loadSiblings:!1,skipLevelOfDetail:!1,maximumScreenSpaceError:2,updateTransforms:!0,onTraversalEnd:()=>{},viewportTraversersMap:{},basePath:""};class fs{constructor(t){p(this,"options",void 0),p(this,"root",void 0),p(this,"requestedTiles",void 0),p(this,"selectedTiles",void 0),p(this,"emptyTiles",void 0),p(this,"_traversalStack",void 0),p(this,"_emptyTraversalStack",void 0),p(this,"_frameNumber",void 0),this.options={...ds,...t},this._traversalStack=new hs,this._emptyTraversalStack=new hs,this._frameNumber=null,this.root=null,this.selectedTiles={},this.requestedTiles={},this.emptyTiles={}}traverse(t,e,r){this.root=t,this.options={...this.options,...r},this.reset(),this.updateTile(t,e),this._frameNumber=e.frameNumber,this.executeTraversal(t,e)}reset(){this.requestedTiles={},this.selectedTiles={},this.emptyTiles={},this._traversalStack.reset(),this._emptyTraversalStack.reset()}executeTraversal(t,e){const r=this._traversalStack;for(t._selectionDepth=1,r.push(t);r.length>0;){const t=r.pop();let n=!1;this.canTraverse(t,e)&&(this.updateChildTiles(t,e),n=this.updateAndPushChildren(t,e,r,t.hasRenderContent?t._selectionDepth+1:t._selectionDepth));const s=t.parent,i=Boolean(!s||s._shouldRefine),o=!n;t.hasRenderContent?t.refine===qn?(this.loadTile(t,e),this.selectTile(t,e)):t.refine===zn&&(this.loadTile(t,e),o&&this.selectTile(t,e)):(this.emptyTiles[t.id]=t,this.loadTile(t,e),o&&this.selectTile(t,e)),this.touchTile(t,e),t._shouldRefine=n&&i}this.options.onTraversalEnd(e)}updateChildTiles(t,e){const r=t.children;for(const t of r)this.updateTile(t,e);return!0}updateAndPushChildren(t,e,r,n){const{loadSiblings:s,skipLevelOfDetail:i}=this.options,o=t.children;o.sort(this.compareDistanceToCamera.bind(this));const a=t.refine===zn&&t.hasRenderContent&&!i;let c=!1,u=!0;for(const t of o)if(t._selectionDepth=n,t.isVisibleAndInRequestVolume?(r.find(t)&&r.delete(t),r.push(t),c=!0):(a||s)&&(this.loadTile(t,e),this.touchTile(t,e)),a){let r;if(r=!!t._inRequestVolume&&(t.hasRenderContent?t.contentAvailable:this.executeEmptyTraversal(t,e)),u=u&&r,!u)return!1}return c||(u=!1),u}updateTile(t,e){this.updateTileVisibility(t,e)}selectTile(t,e){this.shouldSelectTile(t)&&(t._selectedFrame=e.frameNumber,this.selectedTiles[t.id]=t)}loadTile(t,e){this.shouldLoadTile(t)&&(t._requestedFrame=e.frameNumber,t._priority=t._getPriority(),this.requestedTiles[t.id]=t)}touchTile(t,e){t.tileset._cache.touch(t),t._touchedFrame=e.frameNumber}canTraverse(t,e,r=!1,n=!1){return!!t.hasChildren&&(t.hasTilesetContent?!t.contentExpired:!(!n&&!t.isVisibleAndInRequestVolume)&&this.shouldRefine(t,e,r))}shouldLoadTile(t){return t.hasUnloadedContent||t.contentExpired}shouldSelectTile(t){return t.contentAvailable&&!this.options.skipLevelOfDetail}shouldRefine(t,e,r){let n=t._screenSpaceError;return r&&(n=t.getScreenSpaceError(e,!0)),n>this.options.maximumScreenSpaceError}updateTileVisibility(t,e){const r=[];if(this.options.viewportTraversersMap)for(const t in this.options.viewportTraversersMap){this.options.viewportTraversersMap[t]===e.viewport.id&&r.push(t)}else r.push(e.viewport.id);t.updateVisibility(e,r)}compareDistanceToCamera(t,e){return t._distanceToCamera-e._distanceToCamera}anyChildrenVisible(t,e){let r=!1;for(const n of t.children)n.updateVisibility(e),r=r||n.isVisibleAndInRequestVolume;return r}executeEmptyTraversal(t,e){let r=!0;const n=this._emptyTraversalStack;for(n.push(t);n.length>0&&r;){const t=n.pop();this.updateTile(t,e),t.isVisibleAndInRequestVolume||this.loadTile(t,e),this.touchTile(t,e);if(!t.hasRenderContent&&this.canTraverse(t,e,!1,!0)){const e=t.children;for(const t of e)n.find(t)&&n.delete(t),n.push(t)}else t.contentAvailable||(r=!1)}return r}}const As=new Pe;class ms{constructor(t,e,r,n=""){p(this,"tileset",void 0),p(this,"header",void 0),p(this,"id",void 0),p(this,"url",void 0),p(this,"parent",void 0),p(this,"refine",void 0),p(this,"type",void 0),p(this,"contentUrl",void 0),p(this,"lodMetricType",void 0),p(this,"lodMetricValue",void 0),p(this,"boundingVolume",void 0),p(this,"content",void 0),p(this,"contentState",void 0),p(this,"gpuMemoryUsageInBytes",void 0),p(this,"children",void 0),p(this,"depth",void 0),p(this,"viewportIds",void 0),p(this,"transform",void 0),p(this,"extensions",void 0),p(this,"userData",void 0),p(this,"computedTransform",void 0),p(this,"hasEmptyContent",void 0),p(this,"hasTilesetContent",void 0),p(this,"traverser",void 0),p(this,"_cacheNode",void 0),p(this,"_frameNumber",void 0),p(this,"_lodJudge",void 0),p(this,"_expireDate",void 0),p(this,"_expiredContent",void 0),p(this,"_shouldRefine",void 0),p(this,"_distanceToCamera",void 0),p(this,"_centerZDepth",void 0),p(this,"_screenSpaceError",void 0),p(this,"_visibilityPlaneMask",void 0),p(this,"_visible",void 0),p(this,"_inRequestVolume",void 0),p(this,"_stackLength",void 0),p(this,"_selectionDepth",void 0),p(this,"_touchedFrame",void 0),p(this,"_visitedFrame",void 0),p(this,"_selectedFrame",void 0),p(this,"_requestedFrame",void 0),p(this,"_priority",void 0),p(this,"_contentBoundingVolume",void 0),p(this,"_viewerRequestVolume",void 0),p(this,"_initialTransform",void 0),this.header=e,this.tileset=t,this.id=n||e.id,this.url=e.url,this.parent=r,this.refine=this._getRefine(e.refine),this.type=e.type,this.contentUrl=e.contentUrl,this.lodMetricType="geometricError",this.lodMetricValue=0,this.boundingVolume=null,this.content=null,this.contentState=jn,this.gpuMemoryUsageInBytes=0,this.children=[],this.hasEmptyContent=!1,this.hasTilesetContent=!1,this.depth=0,this.viewportIds=[],this.userData={},this.extensions=null,this._priority=0,this._touchedFrame=0,this._visitedFrame=0,this._selectedFrame=0,this._requestedFrame=0,this._screenSpaceError=0,this._cacheNode=null,this._frameNumber=null,this._cacheNode=null,this.traverser=new fs({}),this._shouldRefine=!1,this._distanceToCamera=0,this._centerZDepth=0,this._visible=void 0,this._inRequestVolume=!1,this._stackLength=0,this._selectionDepth=0,this._initialTransform=new rr,this.transform=new rr,this._initializeLodMetric(e),this._initializeTransforms(e),this._initializeBoundingVolumes(e),this._initializeContent(e),this._initializeRenderingState(e),this._lodJudge=null,this._expireDate=null,this._expiredContent=null,Object.seal(this)}destroy(){this.header=null}isDestroyed(){return null===this.header}get selected(){return this._selectedFrame===this.tileset._frameNumber}get isVisible(){return this._visible}get isVisibleAndInRequestVolume(){return this._visible&&this._inRequestVolume}get hasRenderContent(){return!this.hasEmptyContent&&!this.hasTilesetContent}get hasChildren(){return this.children.length>0||this.header.children&&this.header.children.length>0}get contentReady(){return this.contentState===Vn||this.hasEmptyContent}get contentAvailable(){return Boolean(this.contentReady&&this.hasRenderContent||this._expiredContent&&!this.contentFailed)}get hasUnloadedContent(){return this.hasRenderContent&&this.contentUnloaded}get contentUnloaded(){return this.contentState===jn}get contentExpired(){return this.contentState===Kn}get contentFailed(){return this.contentState===Qn}getScreenSpaceError(t,e){switch(this.tileset.type){case $n:return ls(this,t);case ts:return function(t,e,r){const n=t.tileset,s=t.parent&&t.parent.lodMetricValue||t.lodMetricValue,i=r?s:t.lodMetricValue;if(0===i)return 0;const o=Math.max(t._distanceToCamera,1e-7),{height:a,sseDenominator:c}=e,{viewDistanceScale:u}=n.options;let l=i*a*(u||1)/(o*c);return l-=us(n,o),l}(this,t,e);default:throw new Error("Unsupported tileset type")}}_getPriority(){const t=this.tileset._traverser,{skipLevelOfDetail:e}=t.options,r=this.refine===qn||e;if(r&&!this.isVisible&&void 0!==this._visible)return-1;if(this.tileset._frameNumber-this._touchedFrame>=1)return-1;if(this.contentState===jn)return-1;const n=this.parent,s=n&&(!r||0===this._screenSpaceError||n.hasTilesetContent)?n._screenSpaceError:this._screenSpaceError,i=t.root?t.root._screenSpaceError:0;return Math.max(i-s,0)}async loadContent(){if(this.hasEmptyContent)return!1;if(this.content)return!0;this.contentExpired&&(this._expireDate=null),this.contentState=kn;const t=await this.tileset._requestScheduler.scheduleRequest(this.id,this._getPriority.bind(this));if(!t)return this.contentState=jn,!1;try{const e=this.tileset.getTileUrl(this.contentUrl),r=this.tileset.loader,n={...this.tileset.loadOptions,[r.id]:{...this.tileset.loadOptions[r.id],isTileset:"json"===this.type,...this._getLoaderSpecificOptions(r.id)}};return this.content=await ie(e,r,n),this.tileset.options.contentLoader&&await this.tileset.options.contentLoader(this),this._isTileset()&&this.tileset._initializeTileHeaders(this.content,this),this.contentState=Vn,this._onContentLoaded(),!0}catch(t){throw this.contentState=Qn,t}finally{t.done()}}unloadContent(){return this.content&&this.content.destroy&&this.content.destroy(),this.content=null,this.header.content&&this.header.content.destroy&&this.header.content.destroy(),this.header.content=null,this.contentState=jn,!0}updateVisibility(t,e){if(this._frameNumber===t.frameNumber)return;const r=this.parent,n=r?r._visibilityPlaneMask:Mn.MASK_INDETERMINATE;if(this.tileset._traverser.options.updateTransforms){const t=r?r.computedTransform:this.tileset.modelMatrix;this._updateTransform(t)}this._distanceToCamera=this.distanceToTile(t),this._screenSpaceError=this.getScreenSpaceError(t,!1),this._visibilityPlaneMask=this.visibility(t,n),this._visible=this._visibilityPlaneMask!==Mn.MASK_OUTSIDE,this._inRequestVolume=this.insideViewerRequestVolume(t),this._frameNumber=t.frameNumber,this.viewportIds=e}visibility(t,e){const{cullingVolume:r}=t,{boundingVolume:n}=this;return r.computeVisibilityWithPlaneMask(n,e)}contentVisibility(){return!0}distanceToTile(t){const e=this.boundingVolume;return Math.sqrt(Math.max(e.distanceSquaredTo(t.camera.position),0))}cameraSpaceZDepth({camera:t}){const e=this.boundingVolume;return As.subVectors(e.center,t.position),t.direction.dot(As)}insideViewerRequestVolume(t){const e=this._viewerRequestVolume;return!e||e.distanceSquaredTo(t.camera.position)<=0}updateExpiration(){if(null!=this._expireDate&&this.contentReady&&!this.hasEmptyContent){const t=Date.now();Date.lessThan(this._expireDate,t)&&(this.contentState=Kn,this._expiredContent=this.content)}}get extras(){return this.header.extras}_initializeLodMetric(t){"lodMetricType"in t?this.lodMetricType=t.lodMetricType:(this.lodMetricType=this.parent&&this.parent.lodMetricType||this.tileset.lodMetricType,console.warn("3D Tile: Required prop lodMetricType is undefined. Using parent lodMetricType")),"lodMetricValue"in t?this.lodMetricValue=t.lodMetricValue:(this.lodMetricValue=this.parent&&this.parent.lodMetricValue||this.tileset.lodMetricValue,console.warn("3D Tile: Required prop lodMetricValue is undefined. Using parent lodMetricValue"))}_initializeTransforms(t){this.transform=t.transform?new rr(t.transform):new rr;const e=this.parent,r=this.tileset,n=e&&e.computedTransform?e.computedTransform.clone():r.modelMatrix.clone();this.computedTransform=new rr(n).multiplyRight(this.transform);const s=e&&e._initialTransform?e._initialTransform.clone():new rr;this._initialTransform=new rr(s).multiplyRight(this.transform)}_initializeBoundingVolumes(t){this._contentBoundingVolume=null,this._viewerRequestVolume=null,this._updateBoundingVolume(t)}_initializeContent(t){this.content={_tileset:this.tileset,_tile:this},this.hasEmptyContent=!0,this.contentState=jn,this.hasTilesetContent=!1,t.contentUrl&&(this.content=null,this.hasEmptyContent=!1)}_initializeRenderingState(t){this.depth=t.level||(this.parent?this.parent.depth+1:0),this._shouldRefine=!1,this._distanceToCamera=0,this._centerZDepth=0,this._screenSpaceError=0,this._visibilityPlaneMask=Mn.MASK_INDETERMINATE,this._visible=void 0,this._inRequestVolume=!1,this._stackLength=0,this._selectionDepth=0,this._frameNumber=0,this._touchedFrame=0,this._visitedFrame=0,this._selectedFrame=0,this._requestedFrame=0,this._priority=0}_getRefine(t){return t||this.parent&&this.parent.refine||zn}_isTileset(){return-1!==this.contentUrl.indexOf(".json")}_onContentLoaded(){switch(this.content&&this.content.type){case"vctr":case"geom":this.tileset._traverser.disableSkipLevelOfDetail=!0}this._isTileset()&&(this.hasTilesetContent=!0)}_updateBoundingVolume(t){this.boundingVolume=as(t.boundingVolume,this.computedTransform,this.boundingVolume);const e=t.content;e&&(e.boundingVolume&&(this._contentBoundingVolume=as(e.boundingVolume,this.computedTransform,this._contentBoundingVolume)),t.viewerRequestVolume&&(this._viewerRequestVolume=as(t.viewerRequestVolume,this.computedTransform,this._viewerRequestVolume)))}_updateTransform(t=new rr){const e=t.clone().multiplyRight(this.transform);!e.equals(this.computedTransform)&&(this.computedTransform=e,this._updateBoundingVolume(this.header))}_getLoaderSpecificOptions(t){return"i3s"===t?{...this.tileset.options.i3s,tile:this.header,tileset:this.tileset.tileset,isTileHeader:!1}:{assetGltfUpAxis:(e=this.tileset.tileset).asset&&e.asset.gltfUpAxis||"Y"};var e}}class ps extends fs{compareDistanceToCamera(t,e){return 0===e._distanceToCamera&&0===t._distanceToCamera?e._centerZDepth-t._centerZDepth:e._distanceToCamera-t._distanceToCamera}updateTileVisibility(t,e){if(super.updateTileVisibility(t,e),!t.isVisibleAndInRequestVolume)return;const r=t.children.length>0;if(t.hasTilesetContent&&r){const r=t.children[0];return this.updateTileVisibility(r,e),void(t._visible=r._visible)}if(this.meetsScreenSpaceErrorEarly(t,e))return void(t._visible=!1);const n=t.refine===zn,s=t._optimChildrenWithinParent===rs;n&&s&&r&&!this.anyChildrenVisible(t,e)&&(t._visible=!1)}meetsScreenSpaceErrorEarly(t,e){const{parent:r}=t;return!(!r||r.hasTilesetContent||r.refine!==qn)&&!this.shouldRefine(t,e,!0)}}const Bs="REQUESTED",gs="COMPLETED",ys="ERROR";class Cs{constructor(){p(this,"_statusMap",void 0),this._statusMap={}}add(t,e,r,n){this._statusMap[e]||(this._statusMap[e]={request:t,callback:r,key:e,frameState:n,status:Bs},t().then((t=>{this._statusMap[e].status=gs,this._statusMap[e].callback(t,n)})).catch((t=>{this._statusMap[e].status=ys,r(t)})))}update(t,e){this._statusMap[t]&&(this._statusMap[t].frameState=e)}find(t){return this._statusMap[t]}}class bs extends fs{constructor(t){super(t),p(this,"_tileManager",void 0),this._tileManager=new Cs}shouldRefine(t,e){return t._lodJudge=function(t,e){if(0===t.lodMetricValue||isNaN(t.lodMetricValue))return"DIG";const r=2*ls(t,e);return r<2?"OUT":!t.header.children||r<=t.lodMetricValue?"DRAW":t.header.children?"DIG":"OUT"}(t,e),"DIG"===t._lodJudge}updateChildTiles(t,e){const r=t.header.children||[],n=t.children,s=t.tileset;for(const i of r){const r="".concat(i.id,"-").concat(e.viewport.id),o=n&&n.find((t=>t.id===r));if(o)o&&this.updateTile(o,e);else{let n=()=>this._loadTile(i.id,s);this._tileManager.find(r)?this._tileManager.update(r,e):(s.tileset.nodePages&&(n=()=>s.tileset.nodePagesTile.formTileFromNodePages(i.id)),this._tileManager.add(n,r,(e=>this._onTileLoad(e,t,r)),e))}}return!1}async _loadTile(t,e){const{loader:r}=e,n=e.getTileUrl("".concat(e.url,"/nodes/").concat(t)),s={...e.loadOptions,i3s:{...e.loadOptions.i3s,isTileHeader:!0,loadContent:!1}};return await ie(n,r,s)}_onTileLoad(t,e,r){const n=new ms(e.tileset,t,e,r);e.children.push(n);const s=this._tileManager.find(n.id).frameState;this.updateTile(n,s),this._frameNumber===s.frameNumber&&this.executeTraversal(n,s)}}const ws={description:"",ellipsoid:Qr.WGS84,modelMatrix:new rr,throttleRequests:!0,maxRequests:64,maximumMemoryUsage:32,onTileLoad:()=>{},onTileUnload:()=>{},onTileError:()=>{},onTraversalComplete:t=>t,contentLoader:void 0,viewDistanceScale:1,maximumScreenSpaceError:8,loadTiles:!0,updateTransforms:!0,viewportTraversersMap:null,loadOptions:{fetch:{}},attributions:[],basePath:"",i3s:{}},Ts="Tiles In Tileset(s)",Es="Tiles In Memory",Ms="Tiles In View",vs="Tiles To Render",Is="Tiles Loaded",_s="Tiles Loading",Fs="Tiles Unloaded",Ds="Failed Tile Loads",Gs="Points",Rs="Tile Memory Use";class Ss{constructor(t,e){p(this,"options",void 0),p(this,"loadOptions",void 0),p(this,"type",void 0),p(this,"tileset",void 0),p(this,"loader",void 0),p(this,"url",void 0),p(this,"basePath",void 0),p(this,"modelMatrix",void 0),p(this,"ellipsoid",void 0),p(this,"lodMetricType",void 0),p(this,"lodMetricValue",void 0),p(this,"refine",void 0),p(this,"root",void 0),p(this,"roots",void 0),p(this,"asset",void 0),p(this,"description",void 0),p(this,"properties",void 0),p(this,"extras",void 0),p(this,"attributions",void 0),p(this,"credits",void 0),p(this,"stats",void 0),p(this,"traverseCounter",void 0),p(this,"geometricError",void 0),p(this,"selectedTiles",void 0),p(this,"cartographicCenter",void 0),p(this,"cartesianCenter",void 0),p(this,"zoom",void 0),p(this,"boundingVolume",void 0),p(this,"gpuMemoryUsageInBytes",void 0),p(this,"dynamicScreenSpaceErrorComputedDensity",void 0),p(this,"_traverser",void 0),p(this,"_cache",void 0),p(this,"_requestScheduler",void 0),p(this,"_frameNumber",void 0),p(this,"_queryParamsString",void 0),p(this,"_queryParams",void 0),p(this,"_extensionsUsed",void 0),p(this,"_tiles",void 0),p(this,"_pendingCount",void 0),p(this,"lastUpdatedVieports",void 0),p(this,"_requestedTiles",void 0),p(this,"_emptyTiles",void 0),p(this,"frameStateData",void 0),p(this,"maximumMemoryUsage",void 0),o(t),this.options={...ws,...e},this.tileset=t,this.loader=t.loader,this.type=t.type,this.url=t.url,this.basePath=t.basePath||W(this.url),this.modelMatrix=this.options.modelMatrix,this.ellipsoid=this.options.ellipsoid,this.lodMetricType=t.lodMetricType,this.lodMetricValue=t.lodMetricValue,this.refine=t.root.refine,this.loadOptions=this.options.loadOptions||{},this.root=null,this.roots={},this.cartographicCenter=null,this.cartesianCenter=null,this.zoom=1,this.boundingVolume=null,this.traverseCounter=0,this.geometricError=0,this._traverser=this._initializeTraverser(),this._cache=new Yr,this._requestScheduler=new q({throttleRequests:this.options.throttleRequests,maxRequests:this.options.maxRequests}),this._frameNumber=0,this._pendingCount=0,this._tiles={},this.selectedTiles=[],this._emptyTiles=[],this._requestedTiles=[],this.frameStateData={},this.lastUpdatedVieports=null,this._queryParams={},this._queryParamsString="",this.maximumMemoryUsage=this.options.maximumMemoryUsage||32,this.gpuMemoryUsageInBytes=0,this.stats=new K({id:this.url}),this._initializeStats(),this._extensionsUsed=void 0,this.dynamicScreenSpaceErrorComputedDensity=0,this.extras=null,this.asset={},this.credits={},this.description=this.options.description||"",this._initializeTileSet(t)}destroy(){this._destroy()}isLoaded(){return 0===this._pendingCount&&0!==this._frameNumber}get tiles(){return Object.values(this._tiles)}get frameNumber(){return this._frameNumber}get queryParams(){return this._queryParamsString||(this._queryParamsString=function(t){const e=[];for(const r of Object.keys(t))e.push("".concat(r,"=").concat(t[r]));switch(e.length){case 0:return"";case 1:return"?".concat(e[0]);default:return"?".concat(e.join("&"))}}(this._queryParams)),this._queryParamsString}setProps(t){this.options={...this.options,...t}}setOptions(t){this.options={...this.options,...t}}getTileUrl(t){return t.startsWith("data:")?t:"".concat(t).concat(this.queryParams)}hasExtension(t){return Boolean(this._extensionsUsed&&this._extensionsUsed.indexOf(t)>-1)}update(t){if("loadTiles"in this.options&&!this.options.loadTiles)return;if(this.traverseCounter>0)return;!t&&this.lastUpdatedVieports?t=this.lastUpdatedVieports:this.lastUpdatedVieports=t,t instanceof Array||(t=[t]),this._cache.reset(),this._frameNumber++,this.traverseCounter=t.length;const e=[];for(const r of t){const t=r.id;this._needTraverse(t)?e.push(t):this.traverseCounter--}for(const r of t){const t=r.id;if(this.roots[t]||(this.roots[t]=this._initializeTileHeaders(this.tileset,null)),!e.includes(t))continue;const n=Nn(r,this._frameNumber);this._traverser.traverse(this.roots[t],n,this.options)}}_needTraverse(t){let e=t;return this.options.viewportTraversersMap&&(e=this.options.viewportTraversersMap[t]),e===t}_onTraversalEnd(t){const e=t.viewport.id;this.frameStateData[e]||(this.frameStateData[e]={selectedTiles:[],_requestedTiles:[],_emptyTiles:[]});const r=this.frameStateData[e],n=Object.values(this._traverser.selectedTiles);r.selectedTiles=n,r._requestedTiles=Object.values(this._traverser.requestedTiles),r._emptyTiles=Object.values(this._traverser.emptyTiles),this.traverseCounter--,this.traverseCounter>0||this._updateTiles()}_updateTiles(){this.selectedTiles=[],this._requestedTiles=[],this._emptyTiles=[];for(const t in this.frameStateData){const e=this.frameStateData[t];this.selectedTiles=this.selectedTiles.concat(e.selectedTiles),this._requestedTiles=this._requestedTiles.concat(e._requestedTiles),this._emptyTiles=this._emptyTiles.concat(e._emptyTiles)}this.selectedTiles=this.options.onTraversalComplete(this.selectedTiles);for(const t of this.selectedTiles)this._tiles[t.id]=t;this._loadTiles(),this._unloadTiles(),this._updateStats()}_tilesChanged(t,e){if(t.length!==e.length)return!0;const r=new Set(t.map((t=>t.id))),n=new Set(e.map((t=>t.id)));let s=t.filter((t=>!n.has(t.id))).length>0;return s=s||e.filter((t=>!r.has(t.id))).length>0,s}_loadTiles(){for(const t of this._requestedTiles)t.contentUnloaded&&this._loadTile(t)}_unloadTiles(){this._cache.unloadTiles(this,((t,e)=>t._unloadTile(e)))}_updateStats(){let t=0,e=0;for(const r of this.selectedTiles)r.contentAvailable&&r.content&&(t++,r.content.pointCount&&(e+=r.content.pointCount));this.stats.get(Ms).count=this.selectedTiles.length,this.stats.get(vs).count=t,this.stats.get(Gs).count=e}_initializeTileSet(t){this.root=this._initializeTileHeaders(t,null),this.type===ts&&this._initializeCesiumTileset(t),this.type===$n&&this._initializeI3STileset(),this._calculateViewProps()}_calculateViewProps(){const t=this.root;o(t);const{center:e}=t.boundingVolume;if(!e)return console.warn("center was not pre-calculated for the root tile"),this.cartographicCenter=new Pe,void(this.zoom=1);this.cartographicCenter=Qr.WGS84.cartesianToCartographic(e,new Pe),this.cartesianCenter=e,this.zoom=Pn(t.boundingVolume)}_initializeStats(){this.stats.get(Ts),this.stats.get(_s),this.stats.get(Es),this.stats.get(Ms),this.stats.get(vs),this.stats.get(Is),this.stats.get(Fs),this.stats.get(Ds),this.stats.get(Gs,"memory"),this.stats.get(Rs,"memory")}_initializeTileHeaders(t,e){const r=new ms(this,t.root,e);if(e&&(e.children.push(r),r.depth=e.depth+1),this.type===ts){const t=[];for(t.push(r);t.length>0;){const e=t.pop();this.stats.get(Ts).incrementCount();const r=e.header.children||[];for(const n of r){const r=new ms(this,n,e);e.children.push(r),r.depth=e.depth+1,t.push(r)}}}return r}_initializeTraverser(){let t;switch(this.type){case ts:t=ps;break;case $n:t=bs;break;default:t=fs}return new t({basePath:this.basePath,onTraversalEnd:this._onTraversalEnd.bind(this)})}_destroyTileHeaders(t){this._destroySubtree(t)}async _loadTile(t){let e;try{this._onStartTileLoading(),e=await t.loadContent()}catch(e){this._onTileLoadError(t,e)}finally{this._onEndTileLoading(),this._onTileLoad(t,e)}}_onTileLoadError(t,e){this.stats.get(Ds).incrementCount();const r=e.message||e.toString(),n=t.url;console.error("A 3D tile failed to load: ".concat(t.url," ").concat(r)),this.options.onTileError(t,r,n)}_onTileLoad(t,e){e&&(t&&t.content&&function(t,e){o(t),o(e);const{rtcCenter:r,gltfUpAxis:n}=e,{computedTransform:s,boundingVolume:{center:i}}=t;let a=new rr(s);switch(r&&a.translate(r),n){case"Z":break;case"Y":const t=(new rr).rotateX(Math.PI/2);a=a.multiplyRight(t);break;case"X":const e=(new rr).rotateY(-Math.PI/2);a=a.multiplyRight(e)}e.isQuantized&&a.translate(e.quantizedVolumeOffset).scale(e.quantizedVolumeScale);const c=new Pe(i);e.cartesianModelMatrix=a,e.cartesianOrigin=c;const u=Qr.WGS84.cartesianToCartographic(c,new Pe),l=Qr.WGS84.eastNorthUpToFixedFrame(c).invert();e.cartographicModelMatrix=l.multiplyRight(a),e.cartographicOrigin=u,e.coordinateSystem||(e.modelMatrix=e.cartographicModelMatrix)}(t,t.content),this._addTileToCache(t),this.options.onTileLoad(t))}_onStartTileLoading(){this._pendingCount++,this.stats.get(_s).incrementCount()}_onEndTileLoading(){this._pendingCount--,this.stats.get(_s).decrementCount()}_addTileToCache(t){this._cache.add(this,t,(e=>e._updateCacheStats(t)))}_updateCacheStats(t){this.stats.get(Is).incrementCount(),this.stats.get(Es).incrementCount(),this.gpuMemoryUsageInBytes+=t.content.byteLength||0,this.stats.get(Rs).count=this.gpuMemoryUsageInBytes}_unloadTile(t){this.gpuMemoryUsageInBytes-=t.content&&t.content.byteLength||0,this.stats.get(Es).decrementCount(),this.stats.get(Fs).incrementCount(),this.stats.get(Rs).count=this.gpuMemoryUsageInBytes,this.options.onTileUnload(t),t.unloadContent()}_destroy(){const t=[];for(this.root&&t.push(this.root);t.length>0;){const e=t.pop();for(const r of e.children)t.push(r);this._destroyTile(e)}this.root=null}_destroySubtree(t){const e=t,r=[];for(r.push(e);r.length>0;){t=r.pop();for(const e of t.children)r.push(e);t!==e&&this._destroyTile(t)}e.children=[]}_destroyTile(t){this._cache.unloadTile(this,t),this._unloadTile(t),t.destroy()}_initializeCesiumTileset(t){if(this.asset=t.asset,!this.asset)throw new Error("Tileset must have an asset property.");if("0.0"!==this.asset.version&&"1.0"!==this.asset.version)throw new Error("The tileset must be 3D Tiles version 0.0 or 1.0.");"tilesetVersion"in this.asset&&(this._queryParams.v=this.asset.tilesetVersion),this.credits={attributions:this.options.attributions||[]},this.description=this.options.description||"",this.properties=t.properties,this.geometricError=t.geometricError,this._extensionsUsed=t.extensionsUsed,this.extras=t.extras}_initializeI3STileset(){this.loadOptions.i3s&&"token"in this.loadOptions.i3s&&(this._queryParams.token=this.loadOptions.i3s.token)}}const Os="3.1.4",xs="cmpt",Us="pnts",Ls="b3dm",Ns="i3dm",Hs="glTF";function Js(t,e,r){o(t instanceof ArrayBuffer);const n=new TextDecoder("utf8"),s=new Uint8Array(t,e,r);return n.decode(s)}const Ps={name:"Draco",id:"draco",module:"draco",shapes:["mesh"],version:"3.1.4",worker:!0,extensions:["drc"],mimeTypes:["application/octet-stream"],binary:!0,tests:["DRACO"],options:{draco:{decoderType:"object"==typeof WebAssembly?"wasm":"js",libraryPath:"libs/",extraAttributes:{},attributeNameEntry:void 0}}};class js{constructor(t,e){p(this,"fields",void 0),p(this,"metadata",void 0),function(t,e){if(!t)throw new Error(e||"loader assertion failed.")}(Array.isArray(t)),function(t){const e={};for(const r of t)e[r.name]&&console.warn("Schema: duplicated field name",r.name,r),e[r.name]=!0}(t),this.fields=t,this.metadata=e||new Map}compareTo(t){if(this.metadata!==t.metadata)return!1;if(this.fields.length!==t.fields.length)return!1;for(let e=0;e<this.fields.length;++e)if(!this.fields[e].compareTo(t.fields[e]))return!1;return!0}select(...t){const e=Object.create(null);for(const r of t)e[r]=!0;const r=this.fields.filter((t=>e[t.name]));return new js(r,this.metadata)}selectAt(...t){const e=t.map((t=>this.fields[t])).filter(Boolean);return new js(e,this.metadata)}assign(t){let e,r=this.metadata;if(t instanceof js){const n=t;e=n.fields,r=ks(ks(new Map,this.metadata),n.metadata)}else e=t;const n=Object.create(null);for(const t of this.fields)n[t.name]=t;for(const t of e)n[t.name]=t;const s=Object.values(n);return new js(s,r)}}function ks(t,e){return new Map([...t||new Map,...e||new Map])}class Vs{constructor(t,e,r=!1,n=new Map){p(this,"name",void 0),p(this,"type",void 0),p(this,"nullable",void 0),p(this,"metadata",void 0),this.name=t,this.type=e,this.nullable=r,this.metadata=n}get typeId(){return this.type&&this.type.typeId}clone(){return new Vs(this.name,this.type,this.nullable,this.metadata)}compareTo(t){return this.name===t.name&&this.type===t.type&&this.nullable===t.nullable&&this.metadata===t.metadata}toString(){return"".concat(this.type).concat(this.nullable?", nullable":"").concat(this.metadata?", metadata: ".concat(this.metadata):"")}}let Ks,Qs,qs,zs;!function(t){t[t.NONE=0]="NONE",t[t.Null=1]="Null",t[t.Int=2]="Int",t[t.Float=3]="Float",t[t.Binary=4]="Binary",t[t.Utf8=5]="Utf8",t[t.Bool=6]="Bool",t[t.Decimal=7]="Decimal",t[t.Date=8]="Date",t[t.Time=9]="Time",t[t.Timestamp=10]="Timestamp",t[t.Interval=11]="Interval",t[t.List=12]="List",t[t.Struct=13]="Struct",t[t.Union=14]="Union",t[t.FixedSizeBinary=15]="FixedSizeBinary",t[t.FixedSizeList=16]="FixedSizeList",t[t.Map=17]="Map",t[t.Dictionary=-1]="Dictionary",t[t.Int8=-2]="Int8",t[t.Int16=-3]="Int16",t[t.Int32=-4]="Int32",t[t.Int64=-5]="Int64",t[t.Uint8=-6]="Uint8",t[t.Uint16=-7]="Uint16",t[t.Uint32=-8]="Uint32",t[t.Uint64=-9]="Uint64",t[t.Float16=-10]="Float16",t[t.Float32=-11]="Float32",t[t.Float64=-12]="Float64",t[t.DateDay=-13]="DateDay",t[t.DateMillisecond=-14]="DateMillisecond",t[t.TimestampSecond=-15]="TimestampSecond",t[t.TimestampMillisecond=-16]="TimestampMillisecond",t[t.TimestampMicrosecond=-17]="TimestampMicrosecond",t[t.TimestampNanosecond=-18]="TimestampNanosecond",t[t.TimeSecond=-19]="TimeSecond",t[t.TimeMillisecond=-20]="TimeMillisecond",t[t.TimeMicrosecond=-21]="TimeMicrosecond",t[t.TimeNanosecond=-22]="TimeNanosecond",t[t.DenseUnion=-23]="DenseUnion",t[t.SparseUnion=-24]="SparseUnion",t[t.IntervalDayTime=-25]="IntervalDayTime",t[t.IntervalYearMonth=-26]="IntervalYearMonth"}(Ks||(Ks={}));class Ws{static isNull(t){return t&&t.typeId===Ks.Null}static isInt(t){return t&&t.typeId===Ks.Int}static isFloat(t){return t&&t.typeId===Ks.Float}static isBinary(t){return t&&t.typeId===Ks.Binary}static isUtf8(t){return t&&t.typeId===Ks.Utf8}static isBool(t){return t&&t.typeId===Ks.Bool}static isDecimal(t){return t&&t.typeId===Ks.Decimal}static isDate(t){return t&&t.typeId===Ks.Date}static isTime(t){return t&&t.typeId===Ks.Time}static isTimestamp(t){return t&&t.typeId===Ks.Timestamp}static isInterval(t){return t&&t.typeId===Ks.Interval}static isList(t){return t&&t.typeId===Ks.List}static isStruct(t){return t&&t.typeId===Ks.Struct}static isUnion(t){return t&&t.typeId===Ks.Union}static isFixedSizeBinary(t){return t&&t.typeId===Ks.FixedSizeBinary}static isFixedSizeList(t){return t&&t.typeId===Ks.FixedSizeList}static isMap(t){return t&&t.typeId===Ks.Map}static isDictionary(t){return t&&t.typeId===Ks.Dictionary}get typeId(){return Ks.NONE}compareTo(t){return this===t}}Qs=Symbol.toStringTag;class Ys extends Ws{constructor(t,e){super(),p(this,"isSigned",void 0),p(this,"bitWidth",void 0),this.isSigned=t,this.bitWidth=e}get typeId(){return Ks.Int}get[Qs](){return"Int"}toString(){return"".concat(this.isSigned?"I":"Ui","nt").concat(this.bitWidth)}}class Xs extends Ys{constructor(){super(!0,8)}}class Zs extends Ys{constructor(){super(!0,16)}}class $s extends Ys{constructor(){super(!0,32)}}class ti extends Ys{constructor(){super(!1,8)}}class ei extends Ys{constructor(){super(!1,16)}}class ri extends Ys{constructor(){super(!1,32)}}const ni=32,si=64;qs=Symbol.toStringTag;class ii extends Ws{constructor(t){super(),p(this,"precision",void 0),this.precision=t}get typeId(){return Ks.Float}get[qs](){return"Float"}toString(){return"Float".concat(this.precision)}}class oi extends ii{constructor(){super(ni)}}class ai extends ii{constructor(){super(si)}}zs=Symbol.toStringTag;class ci extends Ws{constructor(t,e){super(),p(this,"listSize",void 0),p(this,"children",void 0),this.listSize=t,this.children=[e]}get typeId(){return Ks.FixedSizeList}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get[zs](){return"FixedSizeList"}toString(){return"FixedSizeList[".concat(this.listSize,"]<").concat(this.valueType,">")}}function ui(t,e,r){const n=function(t){switch(t.constructor){case Int8Array:return new Xs;case Uint8Array:return new ti;case Int16Array:return new Zs;case Uint16Array:return new ei;case Int32Array:return new $s;case Uint32Array:return new ri;case Float32Array:return new oi;case Float64Array:return new ai;default:throw new Error("array type not supported")}}(e.value),s=r||function(t){const e=new Map;"byteOffset"in t&&e.set("byteOffset",t.byteOffset.toString(10));"byteStride"in t&&e.set("byteStride",t.byteStride.toString(10));"normalized"in t&&e.set("normalized",t.normalized.toString());return e}(e);return new Vs(t,new ci(e.size,new Vs("value",n)),!1,s)}function li(t,e,r){return ui(t,e,r?hi(r.metadata):void 0)}function hi(t){const e=new Map;for(const r in t)e.set("".concat(r,".string"),JSON.stringify(t[r]));return e}const di={POSITION:"POSITION",NORMAL:"NORMAL",COLOR:"COLOR_0",TEX_COORD:"TEXCOORD_0"},fi={1:Int8Array,2:Uint8Array,3:Int16Array,4:Uint16Array,5:Int32Array,6:Uint32Array,9:Float32Array};class Ai{constructor(t){p(this,"draco",void 0),p(this,"decoder",void 0),p(this,"metadataQuerier",void 0),this.draco=t,this.decoder=new this.draco.Decoder,this.metadataQuerier=new this.draco.MetadataQuerier}destroy(){this.draco.destroy(this.decoder),this.draco.destroy(this.metadataQuerier)}parseSync(t,e={}){const r=new this.draco.DecoderBuffer;r.Init(new Int8Array(t),t.byteLength),this._disableAttributeTransforms(e);const n=this.decoder.GetEncodedGeometryType(r),s=n===this.draco.TRIANGULAR_MESH?new this.draco.Mesh:new this.draco.PointCloud;try{let t;switch(n){case this.draco.TRIANGULAR_MESH:t=this.decoder.DecodeBufferToMesh(r,s);break;case this.draco.POINT_CLOUD:t=this.decoder.DecodeBufferToPointCloud(r,s);break;default:throw new Error("DRACO: Unknown geometry type.")}if(!t.ok()||!s.ptr){const e="DRACO decompression failed: ".concat(t.error_msg());throw new Error(e)}const i=this._getDracoLoaderData(s,n,e),o=this._getMeshData(s,i,e),a=function(t){let e=1/0,r=1/0,n=1/0,s=-1/0,i=-1/0,o=-1/0;const a=t.POSITION?t.POSITION.value:[],c=a&&a.length;for(let t=0;t<c;t+=3){const c=a[t],u=a[t+1],l=a[t+2];e=c<e?c:e,r=u<r?u:r,n=l<n?l:n,s=c>s?c:s,i=u>i?u:i,o=l>o?l:o}return[[e,r,n],[s,i,o]]}(o.attributes),c=function(t,e,r){const n=hi(e.metadata),s=[],i=function(t){const e={};for(const r in t){const n=t[r];e[n.name||"undefined"]=n}return e}(e.attributes);for(const e in t){const r=li(e,t[e],i[e]);s.push(r)}if(r){const t=li("indices",r);s.push(t)}return new js(s,n)}(o.attributes,i,o.indices);return{loader:"draco",loaderData:i,header:{vertexCount:s.num_points(),boundingBox:a},...o,schema:c}}finally{this.draco.destroy(r),s&&this.draco.destroy(s)}}_getDracoLoaderData(t,e,r){const n=this._getTopLevelMetadata(t),s=this._getDracoAttributes(t,r);return{geometry_type:e,num_attributes:t.num_attributes(),num_points:t.num_points(),num_faces:t instanceof this.draco.Mesh?t.num_faces():0,metadata:n,attributes:s}}_getDracoAttributes(t,e){const r={};for(let n=0;n<t.num_attributes();n++){const s=this.decoder.GetAttribute(t,n),i=this._getAttributeMetadata(t,n);r[s.unique_id()]={unique_id:s.unique_id(),attribute_type:s.attribute_type(),data_type:s.data_type(),num_components:s.num_components(),byte_offset:s.byte_offset(),byte_stride:s.byte_stride(),normalized:s.normalized(),attribute_index:n,metadata:i};const o=this._getQuantizationTransform(s,e);o&&(r[s.unique_id()].quantization_transform=o);const a=this._getOctahedronTransform(s,e);a&&(r[s.unique_id()].octahedron_transform=a)}return r}_getMeshData(t,e,r){const n=this._getMeshAttributes(e,t,r);if(!n.POSITION)throw new Error("DRACO: No position attribute found.");return t instanceof this.draco.Mesh?"triangle-strip"===r.topology?{topology:"triangle-strip",mode:4,attributes:n,indices:{value:this._getTriangleStripIndices(t),size:1}}:{topology:"triangle-list",mode:5,attributes:n,indices:{value:this._getTriangleListIndices(t),size:1}}:{topology:"point-list",mode:0,attributes:n}}_getMeshAttributes(t,e,r){const n={};for(const s of Object.values(t.attributes)){const t=this._deduceAttributeName(s,r);s.name=t;const{value:i,size:o}=this._getAttributeValues(e,s);n[t]={value:i,size:o,byteOffset:s.byte_offset,byteStride:s.byte_stride,normalized:s.normalized}}return n}_getTriangleListIndices(t){const e=3*t.num_faces(),r=4*e,n=this.draco._malloc(r);try{return this.decoder.GetTrianglesUInt32Array(t,r,n),new Uint32Array(this.draco.HEAPF32.buffer,n,e).slice()}finally{this.draco._free(n)}}_getTriangleStripIndices(t){const e=new this.draco.DracoInt32Array;try{return this.decoder.GetTriangleStripsFromMesh(t,e),function(t){const e=t.size(),r=new Int32Array(e);for(let n=0;n<e;n++)r[n]=t.GetValue(n);return r}(e)}finally{this.draco.destroy(e)}}_getAttributeValues(t,e){const r=fi[e.data_type],n=e.num_components,s=t.num_points()*n,i=s*r.BYTES_PER_ELEMENT,o=function(t,e){switch(e){case Float32Array:return t.DT_FLOAT32;case Int8Array:return t.DT_INT8;case Int16Array:return t.DT_INT16;case Int32Array:return t.DT_INT32;case Uint8Array:return t.DT_UINT8;case Uint16Array:return t.DT_UINT16;case Uint32Array:return t.DT_UINT32;default:return t.DT_INVALID}}(this.draco,r);let a;const c=this.draco._malloc(i);try{const n=this.decoder.GetAttribute(t,e.attribute_index);this.decoder.GetAttributeDataArrayForAllPoints(t,n,o,i,c),a=new r(this.draco.HEAPF32.buffer,c,s).slice()}finally{this.draco._free(c)}return{value:a,size:n}}_deduceAttributeName(t,e){const r=t.unique_id;for(const[t,n]of Object.entries(e.extraAttributes||{}))if(n===r)return t;const n=t.attribute_type;for(const t in di){if(this.draco[t]===n)return di[t]}const s=e.attributeNameEntry||"name";return t.metadata[s]?t.metadata[s].string:"CUSTOM_ATTRIBUTE_".concat(r)}_getTopLevelMetadata(t){const e=this.decoder.GetMetadata(t);return this._getDracoMetadata(e)}_getAttributeMetadata(t,e){const r=this.decoder.GetAttributeMetadata(t,e);return this._getDracoMetadata(r)}_getDracoMetadata(t){if(!t||!t.ptr)return{};const e={},r=this.metadataQuerier.NumEntries(t);for(let n=0;n<r;n++){const r=this.metadataQuerier.GetEntryName(t,n);e[r]=this._getDracoMetadataField(t,r)}return e}_getDracoMetadataField(t,e){const r=new this.draco.DracoInt32Array;try{this.metadataQuerier.GetIntEntryArray(t,e,r);const n=function(t){const e=t.size(),r=new Int32Array(e);for(let n=0;n<e;n++)r[n]=t.GetValue(n);return r}(r);return{int:this.metadataQuerier.GetIntEntry(t,e),string:this.metadataQuerier.GetStringEntry(t,e),double:this.metadataQuerier.GetDoubleEntry(t,e),intArray:n}}finally{this.draco.destroy(r)}}_disableAttributeTransforms(t){const{quantizedAttributes:e=[],octahedronAttributes:r=[]}=t,n=[...e,...r];for(const t of n)this.decoder.SkipAttributeTransform(this.draco[t])}_getQuantizationTransform(t,e){const{quantizedAttributes:r=[]}=e,n=t.attribute_type();if(r.map((t=>this.decoder[t])).includes(n)){const e=new this.draco.AttributeQuantizationTransform;try{if(e.InitFromAttribute(t))return{quantization_bits:e.quantization_bits(),range:e.range(),min_values:new Float32Array([1,2,3]).map((t=>e.min_value(t)))}}finally{this.draco.destroy(e)}}return null}_getOctahedronTransform(t,e){const{octahedronAttributes:r=[]}=e,n=t.attribute_type();if(r.map((t=>this.decoder[t])).includes(n)){const e=new this.draco.AttributeQuantizationTransform;try{if(e.InitFromAttribute(t))return{quantization_bits:e.quantization_bits()}}finally{this.draco.destroy(e)}}return null}}const mi="1.4.1",pi="https://www.gstatic.com/draco/versioned/decoders/".concat(mi,"/draco_decoder.js"),Bi="https://www.gstatic.com/draco/versioned/decoders/".concat(mi,"/draco_wasm_wrapper.js"),gi="https://www.gstatic.com/draco/versioned/decoders/".concat(mi,"/draco_decoder.wasm");let yi;async function Ci(t){const e=t.modules||{};return yi=e.draco3d?yi||e.draco3d.createDecoderModule({}).then((t=>({draco:t}))):yi||async function(t){let e,r;if("js"===(t.draco&&t.draco.decoderType))e=await R(pi,"draco",t);else[e,r]=await Promise.all([await R(Bi,"draco",t),await R(gi,"draco",t)]);return e=e||globalThis.DracoDecoderModule,await function(t,e){const r={};e&&(r.wasmBinary=e);return new Promise((e=>{t({...r,onModuleLoaded:t=>e({draco:t})})}))}(e,r)}(t),await yi}const bi={...Ps,parse:async function(t,e){const{draco:r}=await Ci(e),n=new Ai(r);try{return n.parseSync(t,null==e?void 0:e.draco)}finally{n.destroy()}}};const wi={BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,INT:5124,UNSIGNED_INT:5125,FLOAT:5126,DOUBLE:5130},Ti={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,...wi},Ei={[wi.DOUBLE]:Float64Array,[wi.FLOAT]:Float32Array,[wi.UNSIGNED_SHORT]:Uint16Array,[wi.UNSIGNED_INT]:Uint32Array,[wi.UNSIGNED_BYTE]:Uint8Array,[wi.BYTE]:Int8Array,[wi.SHORT]:Int16Array,[wi.INT]:Int32Array},Mi={DOUBLE:wi.DOUBLE,FLOAT:wi.FLOAT,UNSIGNED_SHORT:wi.UNSIGNED_SHORT,UNSIGNED_INT:wi.UNSIGNED_INT,UNSIGNED_BYTE:wi.UNSIGNED_BYTE,BYTE:wi.BYTE,SHORT:wi.SHORT,INT:wi.INT},vi="Failed to convert GL type";class Ii{static fromTypedArray(t){t=ArrayBuffer.isView(t)?t.constructor:t;for(const e in Ei){if(Ei[e]===t)return e}throw new Error(vi)}static fromName(t){const e=Mi[t];if(!e)throw new Error(vi);return e}static getArrayType(t){switch(t){case wi.UNSIGNED_SHORT_5_6_5:case wi.UNSIGNED_SHORT_4_4_4_4:case wi.UNSIGNED_SHORT_5_5_5_1:return Uint16Array;default:const e=Ei[t];if(!e)throw new Error(vi);return e}}static getByteSize(t){return Ii.getArrayType(t).BYTES_PER_ELEMENT}static validate(t){return Boolean(Ii.getArrayType(t))}static createTypedArray(t,e,r=0,n){void 0===n&&(n=(e.byteLength-r)/Ii.getByteSize(t));return new(Ii.getArrayType(t))(e,r,n)}}function _i(t,e=[0,0,0]){const r=t>>11&31,n=t>>5&63,s=31&t;return e[0]=r<<3,e[1]=n<<2,e[2]=s<<3,e}function Fi(t,e=255){return function(t,e,r){return de(t,(t=>Math.max(e,Math.min(r,t))))}(t,0,e)/e*2-1}function Di(t){return t<0?-1:1}function Gi(t,e,r,n){if(function(t,e){if(!t)throw new Error("math.gl assertion failed. ".concat(e))}(n),t<0||t>r||e<0||e>r)throw new Error("x and y must be unsigned normalized integers between 0 and ".concat(r));if(n.x=Fi(t,r),n.y=Fi(e,r),n.z=1-(Math.abs(n.x)+Math.abs(n.y)),n.z<0){const t=n.x;n.x=(1-Math.abs(n.y))*Di(t),n.y=(1-Math.abs(t))*Di(n.y)}return n.normalize()}new De,new Pe,new De,new De;class Ri{constructor(t,e){p(this,"json",void 0),p(this,"buffer",void 0),p(this,"featuresLength",0),p(this,"_cachedTypedArrays",{}),this.json=t,this.buffer=e}getExtension(t){return this.json.extensions&&this.json.extensions[t]}hasProperty(t){return Boolean(this.json[t])}getGlobalProperty(t,e=Ti.UNSIGNED_INT,r=1){const n=this.json[t];return n&&Number.isFinite(n.byteOffset)?this._getTypedArrayFromBinary(t,e,r,1,n.byteOffset):n}getPropertyArray(t,e,r){const n=this.json[t];return n&&Number.isFinite(n.byteOffset)?("componentType"in n&&(e=Ii.fromName(n.componentType)),this._getTypedArrayFromBinary(t,e,r,this.featuresLength,n.byteOffset)):this._getTypedArrayFromArray(t,e,n)}getProperty(t,e,r,n,s){const i=this.json[t];if(!i)return i;const o=this.getPropertyArray(t,e,r);if(1===r)return o[n];for(let t=0;t<r;++t)s[t]=o[r*n+t];return s}_getTypedArrayFromBinary(t,e,r,n,s){const i=this._cachedTypedArrays;let o=i[t];return o||(o=Ii.createTypedArray(e,this.buffer.buffer,this.buffer.byteOffset+s,n*r),i[t]=o),o}_getTypedArrayFromArray(t,e,r){const n=this._cachedTypedArrays;let s=n[t];return s||(s=Ii.createTypedArray(e,r),n[t]=s),s}}const Si={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Oi={SCALAR:(t,e)=>t[e],VEC2:(t,e)=>[t[2*e+0],t[2*e+1]],VEC3:(t,e)=>[t[3*e+0],t[3*e+1],t[3*e+2]],VEC4:(t,e)=>[t[4*e+0],t[4*e+1],t[4*e+2],t[4*e+3]],MAT2:(t,e)=>[t[4*e+0],t[4*e+1],t[4*e+2],t[4*e+3]],MAT3:(t,e)=>[t[9*e+0],t[9*e+1],t[9*e+2],t[9*e+3],t[9*e+4],t[9*e+5],t[9*e+6],t[9*e+7],t[9*e+8]],MAT4:(t,e)=>[t[16*e+0],t[16*e+1],t[16*e+2],t[16*e+3],t[16*e+4],t[16*e+5],t[16*e+6],t[16*e+7],t[16*e+8],t[16*e+9],t[16*e+10],t[16*e+11],t[16*e+12],t[16*e+13],t[16*e+14],t[16*e+15]]},xi={SCALAR:(t,e,r)=>{e[r]=t},VEC2:(t,e,r)=>{e[2*r+0]=t[0],e[2*r+1]=t[1]},VEC3:(t,e,r)=>{e[3*r+0]=t[0],e[3*r+1]=t[1],e[3*r+2]=t[2]},VEC4:(t,e,r)=>{e[4*r+0]=t[0],e[4*r+1]=t[1],e[4*r+2]=t[2],e[4*r+3]=t[3]},MAT2:(t,e,r)=>{e[4*r+0]=t[0],e[4*r+1]=t[1],e[4*r+2]=t[2],e[4*r+3]=t[3]},MAT3:(t,e,r)=>{e[9*r+0]=t[0],e[9*r+1]=t[1],e[9*r+2]=t[2],e[9*r+3]=t[3],e[9*r+4]=t[4],e[9*r+5]=t[5],e[9*r+6]=t[6],e[9*r+7]=t[7],e[9*r+8]=t[8],e[9*r+9]=t[9]},MAT4:(t,e,r)=>{e[16*r+0]=t[0],e[16*r+1]=t[1],e[16*r+2]=t[2],e[16*r+3]=t[3],e[16*r+4]=t[4],e[16*r+5]=t[5],e[16*r+6]=t[6],e[16*r+7]=t[7],e[16*r+8]=t[8],e[16*r+9]=t[9],e[16*r+10]=t[10],e[16*r+11]=t[11],e[16*r+12]=t[12],e[16*r+13]=t[13],e[16*r+14]=t[14],e[16*r+15]=t[15]}};const Ui=t=>void 0!==t;function Li(t,e,r){if(!e)return null;let n=t.getExtension("3DTILES_batch_table_hierarchy");const s=e.HIERARCHY;return s&&(console.warn("3D Tile Parser: HIERARCHY is deprecated. Use 3DTILES_batch_table_hierarchy."),e.extensions=e.extensions||{},e.extensions["3DTILES_batch_table_hierarchy"]=s,n=s),n?function(t,e){let r,n,s;const i=t.instancesLength,o=t.classes;let a,c=t.classIds,u=t.parentCounts,l=t.parentIds,h=i;Ui(c.byteOffset)&&(c.componentType=defaultValue(c.componentType,GL.UNSIGNED_SHORT),c.type=AttributeType.SCALAR,s=getBinaryAccessor(c),c=s.createArrayBufferView(e.buffer,e.byteOffset+c.byteOffset,i));if(Ui(u))for(Ui(u.byteOffset)&&(u.componentType=defaultValue(u.componentType,GL.UNSIGNED_SHORT),u.type=AttributeType.SCALAR,s=getBinaryAccessor(u),u=s.createArrayBufferView(e.buffer,e.byteOffset+u.byteOffset,i)),a=new Uint16Array(i),h=0,r=0;r<i;++r)a[r]=h,h+=u[r];Ui(l)&&Ui(l.byteOffset)&&(l.componentType=defaultValue(l.componentType,GL.UNSIGNED_SHORT),l.type=AttributeType.SCALAR,s=getBinaryAccessor(l),l=s.createArrayBufferView(e.buffer,e.byteOffset+l.byteOffset,h));const d=o.length;for(r=0;r<d;++r){const t=o[r].length,n=o[r].instances,s=getBinaryProperties(t,n,e);o[r].instances=combine(s,n)}const f=new Array(d).fill(0),A=new Uint16Array(i);for(r=0;r<i;++r)n=c[r],A[r]=f[n],++f[n];const m={classes:o,classIds:c,classIndexes:A,parentCounts:u,parentIndexes:a,parentIds:l};return function(t){const e=t.classIds.length;for(let r=0;r<e;++r)Hi(t,r,stack)}(m),m}(n,r):null}function Ni(t,e,r){if(!t)return;const n=t.parentCounts;return t.parentIds?r(t,e):n>0?function(t,e,r){const n=t.classIds,s=t.parentCounts,i=t.parentIds,o=t.parentIndexes,a=n.length,c=scratchVisited;c.length=Math.max(c.length,a);const u=++marker,l=scratchStack;l.length=0,l.push(e);for(;l.length>0;){if(c[e=l.pop()]===u)continue;c[e]=u;const n=r(t,e);if(Ui(n))return n;const a=s[e],h=o[e];for(let t=0;t<a;++t){const r=i[h+t];r!==e&&l.push(r)}}return null}(t,e,r):function(t,e,r){let n=!0;for(;n;){const s=r(t,e);if(Ui(s))return s;const i=t.parentIds[e];n=i!==e,e=i}throw new Error("traverseHierarchySingleParent")}(t,e,r)}function Hi(t,e,r){const n=t.parentCounts,s=t.parentIds,i=t.parentIndexes,o=t.classIds.length;if(!Ui(s))return;assert(e<o,"Parent index ".concat(e," exceeds the total number of instances: ").concat(o)),assert(-1===r.indexOf(e),"Circular dependency detected in the batch table hierarchy."),r.push(e);const a=Ui(n)?n[e]:1,c=Ui(n)?i[e]:e;for(let n=0;n<a;++n){const i=s[c+n];i!==e&&Hi(t,i,r)}r.pop(e)}function Ji(t){return null!=t}const Pi=(t,e)=>t,ji={HIERARCHY:!0,extensions:!0,extras:!0};class ki{constructor(t,e,r,n={}){var s;p(this,"json",void 0),p(this,"binary",void 0),p(this,"featureCount",void 0),p(this,"_extensions",void 0),p(this,"_properties",void 0),p(this,"_binaryProperties",void 0),p(this,"_hierarchy",void 0),o(r>=0),this.json=t||{},this.binary=e,this.featureCount=r,this._extensions=(null===(s=this.json)||void 0===s?void 0:s.extensions)||{},this._properties={};for(const t in this.json)ji[t]||(this._properties[t]=this.json[t]);this._binaryProperties=this._initializeBinaryProperties(),n["3DTILES_batch_table_hierarchy"]&&(this._hierarchy=Li(this,this.json,this.binary))}getExtension(t){return this.json&&this.json.extensions&&this.json.extensions[t]}memorySizeInBytes(){return 0}isClass(t,e){if(this._checkBatchId(t),o("string"==typeof e,e),this._hierarchy){return Ji(Ni(this._hierarchy,t,((t,r)=>{const n=t.classIds[r];return t.classes[n].name===e})))}return!1}isExactClass(t,e){return o("string"==typeof e,e),this.getExactClassName(t)===e}getExactClassName(t){if(this._checkBatchId(t),this._hierarchy){const e=this._hierarchy.classIds[t];return this._hierarchy.classes[e].name}}hasProperty(t,e){return this._checkBatchId(t),o("string"==typeof e,e),Ji(this._properties[e])||this._hasPropertyInHierarchy(t,e)}getPropertyNames(t,e){this._checkBatchId(t),(e=Ji(e)?e:[]).length=0;const r=Object.keys(this._properties);return e.push(...r),this._hierarchy&&this._getPropertyNamesInHierarchy(t,e),e}getProperty(t,e){if(this._checkBatchId(t),o("string"==typeof e,e),this._binaryProperties){const r=this._binaryProperties[e];if(Ji(r))return this._getBinaryProperty(r,t)}const r=this._properties[e];if(Ji(r))return Pi(r[t]);if(this._hierarchy){const r=this._getHierarchyProperty(t,e);if(Ji(r))return r}}setProperty(t,e,r){const n=this.featureCount;if(this._checkBatchId(t),o("string"==typeof e,e),this._binaryProperties){const n=this._binaryProperties[e];if(n)return void this._setBinaryProperty(n,t,r)}if(this._hierarchy&&this._setHierarchyProperty(this,t,e,r))return;let s=this._properties[e];Ji(s)||(this._properties[e]=new Array(n),s=this._properties[e]),s[t]=Pi(r)}_checkBatchId(t){if(!(t>=0&&t<this.featureCount))throw new Error("batchId not in range [0, featureCount - 1].")}_getBinaryProperty(t,e){return t.unpack(t.typedArray,e)}_setBinaryProperty(t,e,r){t.pack(r,t.typedArray,e)}_initializeBinaryProperties(){let t=null;for(const e in this._properties){const r=this._properties[e],n=this._initializeBinaryProperty(e,r);n&&(t=t||{},t[e]=n)}return t}_initializeBinaryProperty(t,e){if("byteOffset"in e){const r=e;o(this.binary,"Property ".concat(t," requires a batch table binary.")),o(r.type,"Property ".concat(t," requires a type."));const n=function(t,e,r,n){const{componentType:s}=t;o(t.componentType);const i="string"==typeof s?Ii.fromName(s):s,a=Si[t.type],c=Oi[t.type],u=xi[t.type];return r+=t.byteOffset,{values:Ii.createTypedArray(i,e,r,a*n),type:i,size:a,unpacker:c,packer:u}}(r,this.binary.buffer,0|this.binary.byteOffset,this.featureCount);return{typedArray:n.values,componentCount:n.size,unpack:n.unpacker,pack:n.packer}}return null}_hasPropertyInHierarchy(t,e){if(!this._hierarchy)return!1;const r=Ni(this._hierarchy,t,((t,r)=>{const n=t.classIds[r];return Ji(t.classes[n].instances[e])}));return Ji(r)}_getPropertyNamesInHierarchy(t,e){Ni(this._hierarchy,t,((t,r)=>{const n=t.classIds[r],s=t.classes[n].instances;for(const t in s)s.hasOwnProperty(t)&&-1===e.indexOf(t)&&e.push(t)}))}_getHierarchyProperty(t,e){return Ni(this._hierarchy,t,((t,r)=>{const n=t.classIds[r],s=t.classes[n],i=t.classIndexes[r],o=s.instances[e];return Ji(o)?Ji(o.typedArray)?this._getBinaryProperty(o,i):Pi(o[i]):null}))}_setHierarchyProperty(t,e,r,n){const s=Ni(this._hierarchy,e,((t,s)=>{const i=t.classIds[s],a=t.classes[i],c=t.classIndexes[s],u=a.instances[r];return!!Ji(u)&&(o(s===e,'Inherited property "'.concat(r,'" is read-only.')),Ji(u.typedArray)?this._setBinaryProperty(u,c,n):u[c]=Pi(n),!0)}));return Ji(s)}}function Vi(t,e,r=0){const n=new DataView(e);if(t.magic=n.getUint32(r,!0),r+=4,t.version=n.getUint32(r,!0),r+=4,t.byteLength=n.getUint32(r,!0),r+=4,1!==t.version)throw new Error("3D Tile Version ".concat(t.version," not supported"));return r}const Ki="b3dm tile in legacy format.";function Qi(t,e,r){const n=new DataView(e);let s;t.header=t.header||{};let i=n.getUint32(r,!0);r+=4;let o=n.getUint32(r,!0);r+=4;let a=n.getUint32(r,!0);r+=4;let c=n.getUint32(r,!0);return r+=4,a>=570425344?(r-=8,s=i,a=o,c=0,i=0,o=0,console.warn(Ki)):c>=570425344&&(r-=4,s=a,a=i,c=o,i=0,o=0,console.warn(Ki)),t.header.featureTableJsonByteLength=i,t.header.featureTableBinaryByteLength=o,t.header.batchTableJsonByteLength=a,t.header.batchTableBinaryByteLength=c,t.header.batchLength=s,r}function qi(t,e,r,n){return r=function(t,e,r,n){const{featureTableJsonByteLength:s,featureTableBinaryByteLength:i,batchLength:o}=t.header;if(t.featureTableJson={BATCH_LENGTH:o||0},s>0){const n=Js(e,r,s);t.featureTableJson=JSON.parse(n)}return r+=s,t.featureTableBinary=new Uint8Array(e,r,i),r+=i}(t,e,r),r=function(t,e,r,n){const{batchTableJsonByteLength:s,batchTableBinaryByteLength:i}=t.header;if(s>0){const n=Js(e,r,s);t.batchTableJson=JSON.parse(n),r+=s,i>0&&(t.batchTableBinary=new Uint8Array(e,r,i),t.batchTableBinary=new Uint8Array(t.batchTableBinary),r+=i)}return r}(t,e,r),r}function zi(t,e,r){if(!(e||t&&t.batchIds&&r))return null;const{batchIds:n,isRGB565:s,pointCount:i}=t;if(n&&r){const t=new Uint8ClampedArray(3*i);for(let e=0;e<i;e++){const s=n[e],i=r.getProperty(s,"dimensions").map((t=>255*t));t[3*e]=i[0],t[3*e+1]=i[1],t[3*e+2]=i[2]}return{type:Ti.UNSIGNED_BYTE,value:t,size:3,normalized:!0}}if(s){const t=new Uint8ClampedArray(3*i);for(let r=0;r<i;r++){const n=_i(e[r]);t[3*r]=n[0],t[3*r+1]=n[1],t[3*r+2]=n[2]}return{type:Ti.UNSIGNED_BYTE,value:t,size:3,normalized:!0}}return e&&e.length===3*i?{type:Ti.UNSIGNED_BYTE,value:e,size:3,normalized:!0}:{type:Ti.UNSIGNED_BYTE,value:e,size:4,normalized:!0}}const Wi=new Pe;function Yi(t,e,r){return t.isQuantized?r["3d-tiles"]&&r["3d-tiles"].decodeQuantizedPositions?(t.isQuantized=!1,function(t,e){const r=new Pe,n=new Float32Array(3*t.pointCount);for(let s=0;s<t.pointCount;s++)r.set(e[3*s],e[3*s+1],e[3*s+2]).scale(1/t.quantizedRange).multiply(t.quantizedVolumeScale).add(t.quantizedVolumeOffset).toArray(n,3*s);return n}(t,e)):{type:Ti.UNSIGNED_SHORT,value:e,size:3,normalized:!0}:e}async function Xi(t,e,r,n,s){r=qi(t,e,r=Qi(t,e,r=Vi(t,e,r))),function(t){t.attributes={positions:null,colors:null,normals:null,batchIds:null},t.isQuantized=!1,t.isTranslucent=!1,t.isRGB565=!1,t.isOctEncoded16P=!1}(t);const{featureTable:i,batchTable:o}=function(t){const e=new Ri(t.featureTableJson,t.featureTableBinary),r=e.getGlobalProperty("POINTS_LENGTH");if(!Number.isFinite(r))throw new Error("POINTS_LENGTH must be defined");e.featuresLength=r,t.featuresLength=r,t.pointsLength=r,t.pointCount=r,t.rtcCenter=e.getGlobalProperty("RTC_CENTER",Ti.FLOAT,3);const n=function(t,e){let r=null;if(!t.batchIds&&e.hasProperty("BATCH_ID")&&(t.batchIds=e.getPropertyArray("BATCH_ID",Ti.UNSIGNED_SHORT,1),t.batchIds)){const n=e.getGlobalProperty("BATCH_LENGTH");if(!n)throw new Error("Global property: BATCH_LENGTH must be defined when BATCH_ID is defined.");const{batchTableJson:s,batchTableBinary:i}=t;r=new ki(s,i,n)}return r}(t,e);return{featureTable:e,batchTable:n}}(t);return await async function(t,e,r,n,s){let i,o,a;const c=t.batchTableJson&&t.batchTableJson.extensions&&t.batchTableJson.extensions["3DTILES_draco_point_compression"];c&&(a=c.properties);const u=e.getExtension("3DTILES_draco_point_compression");if(u){o=u.properties;const e=u.byteOffset,r=u.byteLength;if(!o||!Number.isFinite(e)||!r)throw new Error("Draco properties, byteOffset, and byteLength must be defined");i=t.featureTableBinary.slice(e,e+r),t.hasPositions=Number.isFinite(o.POSITION),t.hasColors=Number.isFinite(o.RGB)||Number.isFinite(o.RGBA),t.hasNormals=Number.isFinite(o.NORMAL),t.hasBatchIds=Number.isFinite(o.BATCH_ID),t.isTranslucent=Number.isFinite(o.RGBA)}if(!i)return!0;const l={buffer:i,properties:{...o,...a},featureTableProperties:o,batchTableProperties:a,dequantizeInShader:!1};return await async function(t,e,r,n){const{parse:s}=n,i={...r,draco:{...r.draco,extraAttributes:e.batchTableProperties||{}}};delete i["3d-tiles"];const o=await s(e.buffer,bi,i),a=o.attributes.POSITION&&o.attributes.POSITION.value,c=o.attributes.COLOR_0&&o.attributes.COLOR_0.value,u=o.attributes.NORMAL&&o.attributes.NORMAL.value,l=o.attributes.BATCH_ID&&o.attributes.BATCH_ID.value,h=a&&o.attributes.POSITION.value.quantization,d=u&&o.attributes.NORMAL.value.quantization;if(h){const e=o.POSITION.data.quantization,r=e.range;t.quantizedVolumeScale=new Pe(r,r,r),t.quantizedVolumeOffset=new Pe(e.minValues),t.quantizedRange=(1<<e.quantizationBits)-1,t.isQuantizedDraco=!0}d&&(t.octEncodedRange=(1<<o.NORMAL.data.quantization.quantizationBits)-1,t.isOctEncodedDraco=!0);const f={};if(e.batchTableProperties)for(const t of Object.keys(e.batchTableProperties))o.attributes[t]&&o.attributes[t].value&&(f[t.toLowerCase()]=o.attributes[t].value);t.attributes={positions:a,colors:zi(t,c,void 0),normals:u,batchIds:l,...f}}(t,l,n,s)}(t,i,0,n,s),function(t,e,r){if(!t.attributes.positions)if(e.hasProperty("POSITION"))t.attributes.positions=e.getPropertyArray("POSITION",Ti.FLOAT,3);else if(e.hasProperty("POSITION_QUANTIZED")){const n=e.getPropertyArray("POSITION_QUANTIZED",Ti.UNSIGNED_SHORT,3);if(t.isQuantized=!0,t.quantizedRange=65535,t.quantizedVolumeScale=e.getGlobalProperty("QUANTIZED_VOLUME_SCALE",Ti.FLOAT,3),!t.quantizedVolumeScale)throw new Error("QUANTIZED_VOLUME_SCALE must be defined for quantized positions.");if(t.quantizedVolumeOffset=e.getGlobalProperty("QUANTIZED_VOLUME_OFFSET",Ti.FLOAT,3),!t.quantizedVolumeOffset)throw new Error("QUANTIZED_VOLUME_OFFSET must be defined for quantized positions.");t.attributes.positions=Yi(t,n,r)}if(!t.attributes.positions)throw new Error("Either POSITION or POSITION_QUANTIZED must be defined.")}(t,i,n),function(t,e,r){if(!t.attributes.colors){let n=null;e.hasProperty("RGBA")?(n=e.getPropertyArray("RGBA",Ti.UNSIGNED_BYTE,4),t.isTranslucent=!0):e.hasProperty("RGB")?n=e.getPropertyArray("RGB",Ti.UNSIGNED_BYTE,3):e.hasProperty("RGB565")&&(n=e.getPropertyArray("RGB565",Ti.UNSIGNED_SHORT,1),t.isRGB565=!0),t.attributes.colors=zi(t,n,r)}e.hasProperty("CONSTANT_RGBA")&&(t.constantRGBA=e.getGlobalProperty("CONSTANT_RGBA",Ti.UNSIGNED_BYTE,4))}(t,i,o),function(t,e){if(!t.attributes.normals){let r=null;e.hasProperty("NORMAL")?r=e.getPropertyArray("NORMAL",Ti.FLOAT,3):e.hasProperty("NORMAL_OCT16P")&&(r=e.getPropertyArray("NORMAL_OCT16P",Ti.UNSIGNED_BYTE,2),t.isOctEncoded16P=!0),t.attributes.normals=function(t,e){if(!e)return null;if(t.isOctEncoded16P){const s=new Float32Array(3*t.pointsLength);for(let i=0;i<t.pointsLength;i++)r=e[2*i],n=e[2*i+1],Gi(r,n,255,Wi),Wi.toArray(s,3*i);return{type:Ti.FLOAT,size:2,value:s}}var r,n;return{type:Ti.FLOAT,size:2,value:e}}(t,r)}}(t,i),r}const Zi="3.1.4",$i="https://unpkg.com/@loaders.gl/textures@".concat(Zi,"/dist/libs/basis_encoder.wasm"),to="https://unpkg.com/@loaders.gl/textures@".concat(Zi,"/dist/libs/basis_encoder.js");let eo,ro;async function no(t){const e=t.modules||{};return e.basis?e.basis:(eo=eo||async function(t){let e=null,r=null;return[e,r]=await Promise.all([await R("basis_transcoder.js","textures",t),await R("basis_transcoder.wasm","textures",t)]),e=e||globalThis.BASIS,await function(t,e){const r={};e&&(r.wasmBinary=e);return new Promise((e=>{t(r).then((t=>{const{BasisFile:r,initializeBasis:n}=t;n(),e({BasisFile:r})}))}))}(e,r)}(t),await eo)}async function so(t){const e=t.modules||{};return e.basisEncoder?e.basisEncoder:(ro=ro||async function(t){let e=null,r=null;return[e,r]=await Promise.all([await R(to,"textures",t),await R($i,"textures",t)]),e=e||globalThis.BASIS,await function(t,e){const r={};e&&(r.wasmBinary=e);return new Promise((e=>{t(r).then((t=>{const{BasisFile:r,KTX2File:n,initializeBasis:s,BasisEncoder:i}=t;s(),e({BasisFile:r,KTX2File:n,BasisEncoder:i})}))}))}(e,r)}(t),await ro)}const io=33776,oo=33779,ao=35840,co=35842,uo=36196,lo=37808,ho=["","WEBKIT_","MOZ_"],fo={WEBGL_compressed_texture_s3tc:"dxt",WEBGL_compressed_texture_s3tc_srgb:"dxt-srgb",WEBGL_compressed_texture_etc1:"etc1",WEBGL_compressed_texture_etc:"etc2",WEBGL_compressed_texture_pvrtc:"pvrtc",WEBGL_compressed_texture_atc:"atc",WEBGL_compressed_texture_astc:"astc",EXT_texture_compression_rgtc:"rgtc"};let Ao=null;function mo(t){if(!Ao){t=t||function(){try{return document.createElement("canvas").getContext("webgl")}catch(t){return null}}()||void 0,Ao=new Set;for(const e of ho)for(const r in fo)if(t&&t.getExtension("".concat(e).concat(r))){const t=fo[r];Ao.add(t)}}return Ao}var po,Bo,go,yo,Co,bo,wo,To,Eo;(Eo=po||(po={}))[Eo.NONE=0]="NONE",Eo[Eo.BASISLZ=1]="BASISLZ",Eo[Eo.ZSTD=2]="ZSTD",Eo[Eo.ZLIB=3]="ZLIB",function(t){t[t.BASICFORMAT=0]="BASICFORMAT"}(Bo||(Bo={})),function(t){t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.ETC1S=163]="ETC1S",t[t.UASTC=166]="UASTC"}(go||(go={})),function(t){t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.SRGB=1]="SRGB"}(yo||(yo={})),function(t){t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.LINEAR=1]="LINEAR",t[t.SRGB=2]="SRGB",t[t.ITU=3]="ITU",t[t.NTSC=4]="NTSC",t[t.SLOG=5]="SLOG",t[t.SLOG2=6]="SLOG2"}(Co||(Co={})),function(t){t[t.ALPHA_STRAIGHT=0]="ALPHA_STRAIGHT",t[t.ALPHA_PREMULTIPLIED=1]="ALPHA_PREMULTIPLIED"}(bo||(bo={})),function(t){t[t.RGB=0]="RGB",t[t.RRR=3]="RRR",t[t.GGG=4]="GGG",t[t.AAA=15]="AAA"}(wo||(wo={})),function(t){t[t.RGB=0]="RGB",t[t.RGBA=3]="RGBA",t[t.RRR=4]="RRR",t[t.RRRG=5]="RRRG"}(To||(To={}));const Mo=[171,75,84,88,32,50,48,187,13,10,26,10];const vo={etc1:{basisFormat:0,compressed:!0,format:uo},etc2:{basisFormat:1,compressed:!0},bc1:{basisFormat:2,compressed:!0,format:io},bc3:{basisFormat:3,compressed:!0,format:oo},bc4:{basisFormat:4,compressed:!0},bc5:{basisFormat:5,compressed:!0},"bc7-m6-opaque-only":{basisFormat:6,compressed:!0},"bc7-m5":{basisFormat:7,compressed:!0},"pvrtc1-4-rgb":{basisFormat:8,compressed:!0,format:ao},"pvrtc1-4-rgba":{basisFormat:9,compressed:!0,format:co},"astc-4x4":{basisFormat:10,compressed:!0,format:lo},"atc-rgb":{basisFormat:11,compressed:!0},"atc-rgba-interpolated-alpha":{basisFormat:12,compressed:!0},rgba32:{basisFormat:13,compressed:!1},rgb565:{basisFormat:14,compressed:!1},bgr565:{basisFormat:15,compressed:!1},rgba4444:{basisFormat:16,compressed:!1}};function Io(t,e,r){const n=new t(new Uint8Array(e));try{if(!n.startTranscoding())return null;const t=n.getNumImages(),e=[];for(let s=0;s<t;s++){const t=n.getNumLevels(s),i=[];for(let e=0;e<t;e++)i.push(_o(n,s,e,r));e.push(i)}return e}finally{n.close(),n.delete()}}function _o(t,e,r,n){const s=t.getImageWidth(e,r),i=t.getImageHeight(e,r),o=t.getHasAlpha(),{compressed:a,format:c,basisFormat:u}=Go(n,o),l=t.getImageTranscodedSizeInBytes(e,r,u),h=new Uint8Array(l);return t.transcodeImage(h,e,r,u,0,0)?{width:s,height:i,data:h,compressed:a,hasAlpha:o,format:c}:null}function Fo(t,e,r){const n=new t(new Uint8Array(e));try{if(!n.startTranscoding())return null;const t=n.getLevels(),e=[];for(let s=0;s<t;s++){e.push(Do(n,s,r));break}return e}finally{n.close(),n.delete()}}function Do(t,e,r){const{alphaFlag:n,height:s,width:i}=t.getImageLevelInfo(e,0,0),{compressed:o,format:a,basisFormat:c}=Go(r,n),u=t.getImageTranscodedSizeInBytes(e,0,0,c),l=new Uint8Array(u);return t.transcodeImage(l,e,0,0,c,0,-1,-1)?{width:i,height:s,data:l,compressed:o,alphaFlag:n,format:a}:null}function Go(t,e){let r=t&&t.basis&&t.basis.format;return"auto"===r&&(r=Ro()),"object"==typeof r&&(r=e?r.alpha:r.noAlpha),r=r.toLowerCase(),vo[r]}function Ro(){const t=mo();return t.has("astc")?"astc-4x4":t.has("dxt")?{alpha:"bc3",noAlpha:"bc1"}:t.has("pvrtc")?{alpha:"pvrtc1-4-rgba",noAlpha:"pvrtc1-4-rgb"}:t.has("etc1")?"etc1":t.has("etc2")?"etc2":"rgb565"}const So={...{name:"Basis",id:"basis",module:"textures",version:"3.1.4",worker:!0,extensions:["basis","ktx2"],mimeTypes:["application/octet-stream","image/ktx2"],tests:["sB"],binary:!0,options:{basis:{format:"auto",libraryPath:"libs/",containerFormat:"auto",module:"transcoder"}}},parse:async function(t,e){if("auto"===e.basis.containerFormat){if(function(t){const e=new Uint8Array(t);return!(e.byteLength<Mo.length||e[0]!==Mo[0]||e[1]!==Mo[1]||e[2]!==Mo[2]||e[3]!==Mo[3]||e[4]!==Mo[4]||e[5]!==Mo[5]||e[6]!==Mo[6]||e[7]!==Mo[7]||e[8]!==Mo[8]||e[9]!==Mo[9]||e[10]!==Mo[10]||e[11]!==Mo[11])}(t)){return Fo((await so(e)).KTX2File,t,e)}const{BasisFile:r}=await no(e);return Io(r,t,e)}if("encoder"===e.basis.module){const r=await so(e);return"ktx2"===e.basis.containerFormat?Fo(r.KTX2File,t,e):Io(r.BasisFile,t,e)}{const{BasisFile:r}=await no(e);return Io(r,t,e)}}},{_parseImageNode:Oo}=globalThis,xo="undefined"!=typeof Image,Uo="undefined"!=typeof ImageBitmap,Lo=Boolean(Oo),No=!!a||Lo;function Ho(t){const e=function(t){if("undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap)return"imagebitmap";if("undefined"!=typeof Image&&t instanceof Image)return"image";if(t&&"object"==typeof t&&t.data&&t.width&&t.height)return"data";return null}(t);if(!e)throw new Error("Not an image");return e}const Jo=/^data:image\/svg\+xml/,Po=/\.svg((\?|#).*)?$/;function jo(t){return t&&(Jo.test(t)||Po.test(t))}function ko(t,e){if(jo(e))throw new Error("SVG cannot be parsed directly to imagebitmap");return new Blob([new Uint8Array(t)])}async function Vo(t,e,r){const n=function(t,e){if(jo(e)){let e=(new TextDecoder).decode(t);try{"function"==typeof unescape&&"function"==typeof encodeURIComponent&&(e=unescape(encodeURIComponent(e)))}catch(t){throw new Error(t.message)}return"data:image/svg+xml;base64,".concat(btoa(e))}return ko(t,e)}(t,r),s=self.URL||self.webkitURL,i="string"!=typeof n&&s.createObjectURL(n);try{return await async function(t,e){const r=new Image;if(r.src=t,e.image&&e.image.decode&&r.decode)return await r.decode(),r;return await new Promise(((e,n)=>{try{r.onload=()=>e(r),r.onerror=e=>n(new Error("Could not load image ".concat(t,": ").concat(e)))}catch(t){n(t)}}))}(i||n,e)}finally{i&&s.revokeObjectURL(i)}}const Ko={};let Qo=!0;async function qo(t,e,r){let n;if(jo(r)){n=await Vo(t,e,r)}else n=ko(t,r);const s=e&&e.imagebitmap;return await async function(t,e=null){!function(t){for(const e in t||Ko)return!1;return!0}(e)&&Qo||(e=null);if(e)try{return await createImageBitmap(t,e)}catch(t){console.warn(t),Qo=!1}return await createImageBitmap(t)}(n,s)}const zo=!1,Wo=!0;function Yo(t){const e=Xo(t);return function(t){const e=Xo(t);if(!(e.byteLength>=24&&2303741511===e.getUint32(0,zo)))return null;return{mimeType:"image/png",width:e.getUint32(16,zo),height:e.getUint32(20,zo)}}(e)||function(t){const e=Xo(t);if(!(e.byteLength>=3&&65496===e.getUint16(0,zo)&&255===e.getUint8(2)))return null;const{tableMarkers:r,sofMarkers:n}=function(){const t=new Set([65499,65476,65484,65501,65534]);for(let e=65504;e<65520;++e)t.add(e);const e=new Set([65472,65473,65474,65475,65477,65478,65479,65481,65482,65483,65485,65486,65487,65502]);return{tableMarkers:t,sofMarkers:e}}();let s=2;for(;s+9<e.byteLength;){const t=e.getUint16(s,zo);if(n.has(t))return{mimeType:"image/jpeg",height:e.getUint16(s+5,zo),width:e.getUint16(s+7,zo)};if(!r.has(t))return null;s+=2,s+=e.getUint16(s,zo)}return null}(e)||function(t){const e=Xo(t);if(!(e.byteLength>=10&&1195984440===e.getUint32(0,zo)))return null;return{mimeType:"image/gif",width:e.getUint16(6,Wo),height:e.getUint16(8,Wo)}}(e)||function(t){const e=Xo(t);if(!(e.byteLength>=14&&16973===e.getUint16(0,zo)&&e.getUint32(2,Wo)===e.byteLength))return null;return{mimeType:"image/bmp",width:e.getUint32(18,Wo),height:e.getUint32(22,Wo)}}(e)}function Xo(t){if(t instanceof DataView)return t;if(ArrayBuffer.isView(t))return new DataView(t.buffer);if(t instanceof ArrayBuffer)return new DataView(t);throw new Error("toDataView")}const Zo={id:"image",module:"images",name:"Images",version:"3.1.4",mimeTypes:["image/png","image/jpeg","image/gif","image/webp","image/bmp","image/vnd.microsoft.icon","image/svg+xml"],extensions:["png","jpg","jpeg","gif","webp","bmp","ico","svg"],parse:async function(t,e,r){const n=((e=e||{}).image||{}).type||"auto",{url:s}=r||{};let i;switch(function(t){switch(t){case"auto":case"data":return function(){if(Uo)return"imagebitmap";if(xo)return"image";if(No)return"data";throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js")}();default:return function(t){switch(t){case"auto":return Uo||xo||No;case"imagebitmap":return Uo;case"image":return xo;case"data":return No;default:throw new Error("@loaders.gl/images: image ".concat(t," not supported in this environment"))}}(t),t}}(n)){case"imagebitmap":i=await qo(t,e,s);break;case"image":i=await Vo(t,e,s);break;case"data":i=await async function(t,e){const{mimeType:r}=Yo(t)||{},n=globalThis._parseImageNode;return o(n),await n(t,r)}(t);break;default:o(!1)}return"data"===n&&(i=function(t){switch(Ho(t)){case"data":return t;case"image":case"imagebitmap":const e=document.createElement("canvas"),r=e.getContext("2d");if(!r)throw new Error("getImageData");return e.width=t.width,e.height=t.height,r.drawImage(t,0,0),r.getImageData(0,0,t.width,t.height);default:throw new Error("getImageData")}}(i)),i},tests:[t=>Boolean(Yo(new DataView(t)))],options:{image:{type:"auto",decode:!0}}},$o=["image/png","image/jpeg","image/gif"],ta={};function ea(t){return void 0===ta[t]&&(ta[t]=function(t){switch(t){case"image/webp":return function(){if(!a)return!1;try{return 0===document.createElement("canvas").toDataURL("image/webp").indexOf("data:image/webp")}catch{return!1}}();case"image/svg":return a;default:if(!a){const{_parseImageNode:e}=globalThis;return Boolean(e)&&$o.includes(t)}return!0}}(t)),ta[t]}function ra(t,e){if(!t)throw new Error(e||"assert failed: gltf")}function na(t,e){if(t.startsWith("data:")||t.startsWith("http:")||t.startsWith("https:"))return t;const r=e.baseUri||e.uri;if(!r)throw new Error("'baseUri' must be provided to resolve relative url ".concat(t));return r.substr(0,r.lastIndexOf("/")+1)+t}const sa=["SCALAR","VEC2","VEC3","VEC4"],ia=[[Int8Array,5120],[Uint8Array,5121],[Int16Array,5122],[Uint16Array,5123],[Uint32Array,5125],[Float32Array,5126],[Float64Array,5130]],oa=new Map(ia),aa={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},ca={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},ua={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};function la(t){return sa[t-1]||sa[0]}function ha(t){const e=oa.get(t.constructor);if(!e)throw new Error("Illegal typed array");return e}function da(t,e){const r=ua[t.componentType],n=aa[t.type],s=ca[t.componentType],i=t.count*n,o=t.count*n*s;return ra(o>=0&&o<=e.byteLength),{ArrayType:r,length:i,byteLength:o}}const fa={asset:{version:"2.0",generator:"loaders.gl"},buffers:[]};class Aa{constructor(t){p(this,"gltf",void 0),p(this,"sourceBuffers",void 0),p(this,"byteLength",void 0),this.gltf=t||{json:{...fa},buffers:[]},this.sourceBuffers=[],this.byteLength=0,this.gltf.buffers&&this.gltf.buffers[0]&&(this.byteLength=this.gltf.buffers[0].byteLength,this.sourceBuffers=[this.gltf.buffers[0]])}get json(){return this.gltf.json}getApplicationData(t){return this.json[t]}getExtraData(t){return(this.json.extras||{})[t]}getExtension(t){const e=this.getUsedExtensions().find((e=>e===t)),r=this.json.extensions||{};return e?r[t]||!0:null}getRequiredExtension(t){const e=this.getRequiredExtensions().find((e=>e===t));return e?this.getExtension(t):null}getRequiredExtensions(){return this.json.extensionsRequired||[]}getUsedExtensions(){return this.json.extensionsUsed||[]}getObjectExtension(t,e){return(t.extensions||{})[e]}getScene(t){return this.getObject("scenes",t)}getNode(t){return this.getObject("nodes",t)}getSkin(t){return this.getObject("skins",t)}getMesh(t){return this.getObject("meshes",t)}getMaterial(t){return this.getObject("materials",t)}getAccessor(t){return this.getObject("accessors",t)}getTexture(t){return this.getObject("textures",t)}getSampler(t){return this.getObject("samplers",t)}getImage(t){return this.getObject("images",t)}getBufferView(t){return this.getObject("bufferViews",t)}getBuffer(t){return this.getObject("buffers",t)}getObject(t,e){if("object"==typeof e)return e;const r=this.json[t]&&this.json[t][e];if(!r)throw new Error("glTF file error: Could not find ".concat(t,"[").concat(e,"]"));return r}getTypedArrayForBufferView(t){const e=(t=this.getBufferView(t)).buffer,r=this.gltf.buffers[e];ra(r);const n=(t.byteOffset||0)+r.byteOffset;return new Uint8Array(r.arrayBuffer,n,t.byteLength)}getTypedArrayForAccessor(t){t=this.getAccessor(t);const e=this.getBufferView(t.bufferView),r=this.getBuffer(e.buffer).data,{ArrayType:n,length:s}=da(t,e);return new n(r,e.byteOffset+t.byteOffset,s)}getTypedArrayForImageData(t){t=this.getAccessor(t);const e=this.getBufferView(t.bufferView),r=this.getBuffer(e.buffer).data,n=e.byteOffset||0;return new Uint8Array(r,n,e.byteLength)}addApplicationData(t,e){return this.json[t]=e,this}addExtraData(t,e){return this.json.extras=this.json.extras||{},this.json.extras[t]=e,this}addObjectExtension(t,e,r){return t.extensions=t.extensions||{},t.extensions[e]=r,this.registerUsedExtension(e),this}setObjectExtension(t,e,r){(t.extensions||{})[e]=r}removeObjectExtension(t,e){const r=t.extensions||{},n=r[e];return delete r[e],n}addExtension(t,e={}){return ra(e),this.json.extensions=this.json.extensions||{},this.json.extensions[t]=e,this.registerUsedExtension(t),e}addRequiredExtension(t,e={}){return ra(e),this.addExtension(t,e),this.registerRequiredExtension(t),e}registerUsedExtension(t){this.json.extensionsUsed=this.json.extensionsUsed||[],this.json.extensionsUsed.find((e=>e===t))||this.json.extensionsUsed.push(t)}registerRequiredExtension(t){this.registerUsedExtension(t),this.json.extensionsRequired=this.json.extensionsRequired||[],this.json.extensionsRequired.find((e=>e===t))||this.json.extensionsRequired.push(t)}removeExtension(t){this.json.extensionsRequired&&this._removeStringFromArray(this.json.extensionsRequired,t),this.json.extensionsUsed&&this._removeStringFromArray(this.json.extensionsUsed,t),this.json.extensions&&delete this.json.extensions[t]}setDefaultScene(t){this.json.scene=t}addScene(t){const{nodeIndices:e}=t;return this.json.scenes=this.json.scenes||[],this.json.scenes.push({nodes:e}),this.json.scenes.length-1}addNode(t){const{meshIndex:e,matrix:r}=t;this.json.nodes=this.json.nodes||[];const n={mesh:e};return r&&(n.matrix=r),this.json.nodes.push(n),this.json.nodes.length-1}addMesh(t){const{attributes:e,indices:r,material:n,mode:s=4}=t,i={primitives:[{attributes:this._addAttributes(e),mode:s}]};if(r){const t=this._addIndices(r);i.primitives[0].indices=t}return Number.isFinite(n)&&(i.primitives[0].material=n),this.json.meshes=this.json.meshes||[],this.json.meshes.push(i),this.json.meshes.length-1}addPointCloud(t){const e={primitives:[{attributes:this._addAttributes(t),mode:0}]};return this.json.meshes=this.json.meshes||[],this.json.meshes.push(e),this.json.meshes.length-1}addImage(t,e){const r=Yo(t),n=e||(null==r?void 0:r.mimeType),s={bufferView:this.addBufferView(t),mimeType:n};return this.json.images=this.json.images||[],this.json.images.push(s),this.json.images.length-1}addBufferView(t){const e=t.byteLength;ra(Number.isFinite(e)),this.sourceBuffers=this.sourceBuffers||[],this.sourceBuffers.push(t);const r={buffer:0,byteOffset:this.byteLength,byteLength:e};return this.byteLength+=J(e,4),this.json.bufferViews=this.json.bufferViews||[],this.json.bufferViews.push(r),this.json.bufferViews.length-1}addAccessor(t,e){const r={bufferView:t,type:la(e.size),componentType:e.componentType,count:e.count,max:e.max,min:e.min};return this.json.accessors=this.json.accessors||[],this.json.accessors.push(r),this.json.accessors.length-1}addBinaryBuffer(t,e={size:3}){const r=this.addBufferView(t);let n={min:e.min,max:e.max};n.min&&n.max||(n=this._getAccessorMinMax(t,e.size));const s={size:e.size,componentType:ha(t),count:Math.round(t.length/e.size),min:n.min,max:n.max};return this.addAccessor(r,Object.assign(s,e))}addTexture(t){const{imageIndex:e}=t,r={source:e};return this.json.textures=this.json.textures||[],this.json.textures.push(r),this.json.textures.length-1}addMaterial(t){return this.json.materials=this.json.materials||[],this.json.materials.push(t),this.json.materials.length-1}createBinaryChunk(){var t,e;this.gltf.buffers=[];const r=this.byteLength,n=new ArrayBuffer(r),s=new Uint8Array(n);let i=0;for(const t of this.sourceBuffers||[])i=P(t,s,i);null!==(t=this.json)&&void 0!==t&&null!==(e=t.buffers)&&void 0!==e&&e[0]?this.json.buffers[0].byteLength=r:this.json.buffers=[{byteLength:r}],this.gltf.binary=n,this.sourceBuffers=[n]}_removeStringFromArray(t,e){let r=!0;for(;r;){const n=t.indexOf(e);n>-1?t.splice(n,1):r=!1}}_addAttributes(t={}){const e={};for(const r in t){const n=t[r],s=this._getGltfAttributeName(r),i=this.addBinaryBuffer(n.value,n);e[s]=i}return e}_addIndices(t){return this.addBinaryBuffer(t,{size:1})}_getGltfAttributeName(t){switch(t.toLowerCase()){case"position":case"positions":case"vertices":return"POSITION";case"normal":case"normals":return"NORMAL";case"color":case"colors":return"COLOR_0";case"texcoord":case"texcoords":return"TEXCOORD_0";default:return t}}_getAccessorMinMax(t,e){const r={min:null,max:null};if(t.length<e)return r;r.min=[],r.max=[];const n=t.subarray(0,e);for(const t of n)r.min.push(t),r.max.push(t);for(let n=e;n<t.length;n+=e)for(let s=0;s<e;s++)r.min[0+s]=Math.min(r.min[0+s],t[n+s]),r.max[0+s]=Math.max(r.max[0+s],t[n+s]);return r}}const ma="object"!=typeof WebAssembly,pa="B9h9z9tFBBBF8fL9gBB9gLaaaaaFa9gEaaaB9gFaFa9gEaaaFaEMcBFFFGGGEIIILF9wFFFLEFBFKNFaFCx/IFMO/LFVK9tv9t9vq95GBt9f9f939h9z9t9f9j9h9s9s9f9jW9vq9zBBp9tv9z9o9v9wW9f9kv9j9v9kv9WvqWv94h919m9mvqBF8Z9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv94h919m9mvqBGy9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv949TvZ91v9u9jvBEn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9P9jWBIi9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9R919hWBLn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9F949wBKI9z9iqlBOc+x8ycGBM/qQFTa8jUUUUBCU/EBlHL8kUUUUBC9+RKGXAGCFJAI9LQBCaRKAE2BBC+gF9HQBALAEAIJHOAGlAGTkUUUBRNCUoBAG9uC/wgBZHKCUGAKCUG9JyRVAECFJRICBRcGXEXAcAF9PQFAVAFAclAcAVJAF9JyRMGXGXAG9FQBAMCbJHKC9wZRSAKCIrCEJCGrRQANCUGJRfCBRbAIRTEXGXAOATlAQ9PQBCBRISEMATAQJRIGXAS9FQBCBRtCBREEXGXAOAIlCi9PQBCBRISLMANCU/CBJAEJRKGXGXGXGXGXATAECKrJ2BBAtCKZrCEZfIBFGEBMAKhB83EBAKCNJhB83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FCnD+rFCUUU/8EDtD+uFD/mFDMIBMALAEAF/8cBBMM9TFEaCBCB8oGUkUUBHFABCEJC98ZJHBjGUkUUBGXGXAB8/BCTWHGuQBCaREABAGlCggEJCTrXBCa6QFMAFREMAEMMMFBCUNMIT9tBB",ga=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]),ya=new Uint8Array([32,0,65,253,3,1,2,34,4,106,6,5,11,8,7,20,13,33,12,16,128,9,116,64,19,113,127,15,10,21,22,14,255,66,24,54,136,107,18,23,192,26,114,118,132,17,77,101,130,144,27,87,131,44,45,74,156,154,70,167]),Ca={0:"",1:"meshopt_decodeFilterOct",2:"meshopt_decodeFilterQuat",3:"meshopt_decodeFilterExp",NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},ba={0:"meshopt_decodeVertexBuffer",1:"meshopt_decodeIndexBuffer",2:"meshopt_decodeIndexSequence",ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};async function wa(t,e,r,n,s,i="NONE"){const o=await async function(){Ta||(Ta=async function(){let t=pa;WebAssembly.validate(ga)&&(t=Ba,console.log("Warning: meshopt_decoder is using experimental SIMD support"));const e=await WebAssembly.instantiate(function(t){const e=new Uint8Array(t.length);for(let r=0;r<t.length;++r){const n=t.charCodeAt(r);e[r]=n>96?n-71:n>64?n-65:n>47?n+4:n>46?63:62}let r=0;for(let n=0;n<t.length;++n)e[r++]=e[n]<60?ya[e[n]]:64*(e[n]-60)+e[++n];return e.buffer.slice(0,r)}(t),{});return await e.instance.exports.__wasm_call_ctors(),e.instance}());return Ta}();!function(t,e,r,n,s,i,o){const a=t.exports.sbrk,c=n+3&-4,u=a(c*s),l=a(i.length),h=new Uint8Array(t.exports.memory.buffer);h.set(i,l);const d=e(u,n,s,l,i.length);0===d&&o&&o(u,c,s);if(r.set(h.subarray(u,u+n*s)),a(u-a(0)),0!==d)throw new Error("Malformed buffer data: ".concat(d))}(o,o.exports[ba[s]],t,e,r,n,o.exports[Ca[i||"NONE"]])}let Ta;const Ea="EXT_meshopt_compression";async function Ma(t,e){const r=t.getObjectExtension(e,Ea);if(r){const t=e.buffer,{byteOffset:n=0,byteLength:s=0,byteStride:i,count:o,mode:a,filter:c="NONE"}=r,u=new Uint8Array(t,n,s),l=new ArrayBuffer(o*i);return await wa(new Uint8Array(l),o,i,u,a,c),l}return null}var va=Object.freeze({__proto__:null,name:"EXT_meshopt_compression",preprocess:function(t){if(new Aa(t).getRequiredExtensions().includes(Ea)&&!ma)throw new Error("gltf: Required extension ".concat(Ea," not supported by browser"))},decode:async function(t,e){var r;const n=new Aa(t);if(null==e||null===(r=e.gltf)||void 0===r||!r.decompressMeshes)return;const s=[];for(const e of t.json.bufferViews||[])s.push(Ma(n,e));await Promise.all(s),n.removeExtension(Ea)}});const Ia="EXT_texture_webp";var _a=Object.freeze({__proto__:null,name:"EXT_texture_webp",preprocess:function(t,e){const r=new Aa(t);if(!ea("image/webp")){if(r.getRequiredExtensions().includes(Ia))throw new Error("gltf: Required extension ".concat(Ia," not supported by browser"));return}const{json:n}=r;for(const t of n.textures||[]){const e=r.getObjectExtension(t,Ia);e&&(t.source=e.source),r.removeObjectExtension(t,Ia)}r.removeExtension(Ia)}});const Fa="KHR_texture_basisu";var Da=Object.freeze({__proto__:null,name:"KHR_texture_basisu",preprocess:function(t,e){const r=new Aa(t),{json:n}=r;for(const t of n.textures||[]){const e=r.getObjectExtension(t,Fa);e&&(t.source=e.source),r.removeObjectExtension(t,Fa)}r.removeExtension(Fa)}});function Ga(t){const{buffer:e,size:r,count:n}=function(t){let e=t,r=1,n=0;t&&t.value&&(e=t.value,r=t.size||1);e&&(ArrayBuffer.isView(e)||(e=function(t,e,r=!1){if(!t)return null;if(Array.isArray(t))return new e(t);if(r&&!(t instanceof e))return new e(t);return t}(e,Float32Array)),n=e.length/r);return{buffer:e,size:r,count:n}}(t);return{value:e,size:r,byteOffset:0,count:n,type:la(r),componentType:ha(e)}}const Ra="KHR_draco_mesh_compression";async function Sa(t,e,r,n){const s=t.getObjectExtension(e,Ra);if(!s)return;const i=t.getTypedArrayForBufferView(s.bufferView),o=H(i.buffer,i.byteOffset),{parse:a}=n,c={...r};delete c["3d-tiles"];const u=await a(o,bi,c,n),l=function(t){const e={};for(const r in t){const n=t[r];if("indices"!==r){const t=Ga(n);e[r]=t}}return e}(u.attributes);for(const[r,n]of Object.entries(l))if(r in e.attributes){const s=e.attributes[r],i=t.getAccessor(s);null!=i&&i.min&&null!=i&&i.max&&(n.min=i.min,n.max=i.max)}e.attributes=l,u.indices&&(e.indices=Ga(u.indices)),function(t){if(!t.attributes&&Object.keys(t.attributes).length>0)throw new Error("glTF: Empty primitive detected: Draco decompression failure?")}(e)}function Oa(t,e,r=4,n,s){var i;if(!n.DracoWriter)throw new Error("options.gltf.DracoWriter not provided");const o=n.DracoWriter.encodeSync({attributes:t}),a=null==s||null===(i=s.parseSync)||void 0===i?void 0:i.call(s,{attributes:t}),c=n._addFauxAttributes(a.attributes),u=n.addBufferView(o);return{primitives:[{attributes:c,mode:r,extensions:{[Ra]:{bufferView:u,attributes:c}}}]}}function*xa(t){for(const e of t.json.meshes||[])for(const t of e.primitives)yield t}var Ua=Object.freeze({__proto__:null,name:"KHR_draco_mesh_compression",preprocess:function(t,e,r){const n=new Aa(t);for(const t of xa(n))n.getObjectExtension(t,Ra)},decode:async function(t,e,r){var n;if(null==e||null===(n=e.gltf)||void 0===n||!n.decompressMeshes)return;const s=new Aa(t),i=[];for(const t of xa(s))s.getObjectExtension(t,Ra)&&i.push(Sa(s,t,e,r));await Promise.all(i),s.removeExtension(Ra)},encode:function(t,e={}){const r=new Aa(t);for(const t of r.json.meshes||[])Oa(t),r.addRequiredExtension(Ra)}});const La="KHR_lights_punctual";var Na=Object.freeze({__proto__:null,name:"KHR_lights_punctual",decode:async function(t){const e=new Aa(t),{json:r}=e,n=e.getExtension(La);n&&(e.json.lights=n.lights,e.removeExtension(La));for(const t of r.nodes||[]){const r=e.getObjectExtension(t,La);r&&(t.light=r.light),e.removeObjectExtension(t,La)}},encode:async function(t){const e=new Aa(t),{json:r}=e;if(r.lights){const t=e.addExtension(La);ra(!t.lights),t.lights=r.lights,delete r.lights}if(e.json.lights){for(const t of e.json.lights){const r=t.node;e.addObjectExtension(r,La,t)}delete e.json.lights}}});const Ha="KHR_materials_unlit";const Ja="KHR_techniques_webgl";function Pa(t,e){const r=Object.assign({},t.values);return Object.keys(t.uniforms||{}).forEach((e=>{t.uniforms[e].value&&!(e in r)&&(r[e]=t.uniforms[e].value)})),Object.keys(r).forEach((t=>{"object"==typeof r[t]&&void 0!==r[t].index&&(r[t].texture=e.getTexture(r[t].index))})),r}const ja=[va,_a,Da,Ua,Na,Object.freeze({__proto__:null,name:"KHR_materials_unlit",decode:async function(t){const e=new Aa(t),{json:r}=e;e.removeExtension(Ha);for(const t of r.materials||[]){t.extensions&&t.extensions.KHR_materials_unlit&&(t.unlit=!0),e.removeObjectExtension(t,Ha)}},encode:function(t){const e=new Aa(t),{json:r}=e;if(e.materials)for(const t of r.materials||[])t.unlit&&(delete t.unlit,e.addObjectExtension(t,Ha,{}),e.addExtension(Ha))}}),Object.freeze({__proto__:null,name:"KHR_techniques_webgl",decode:async function(t){const e=new Aa(t),{json:r}=e,n=e.getExtension(Ja);if(n){const t=function(t,e){const{programs:r=[],shaders:n=[],techniques:s=[]}=t,i=new TextDecoder;return n.forEach((t=>{if(!Number.isFinite(t.bufferView))throw new Error("KHR_techniques_webgl: no shader code");t.code=i.decode(e.getTypedArrayForBufferView(t.bufferView))})),r.forEach((t=>{t.fragmentShader=n[t.fragmentShader],t.vertexShader=n[t.vertexShader]})),s.forEach((t=>{t.program=r[t.program]})),s}(n,e);for(const n of r.materials||[]){const r=e.getObjectExtension(n,Ja);r&&(n.technique=Object.assign({},r,t[r.technique]),n.technique.values=Pa(n.technique,e)),e.removeObjectExtension(n,Ja)}e.removeExtension(Ja)}},encode:async function(t,e){}})];function ka(t,e){var r;const n=(null==e||null===(r=e.gltf)||void 0===r?void 0:r.excludeExtensions)||{};return!(t in n&&!n[t])}const Va="KHR_binary_glTF";const Ka={accessors:"accessor",animations:"animation",buffers:"buffer",bufferViews:"bufferView",images:"image",materials:"material",meshes:"mesh",nodes:"node",samplers:"sampler",scenes:"scene",skins:"skin",textures:"texture"},Qa={accessor:"accessors",animations:"animation",buffer:"buffers",bufferView:"bufferViews",image:"images",material:"materials",mesh:"meshes",node:"nodes",sampler:"samplers",scene:"scenes",skin:"skins",texture:"textures"};class qa{constructor(){p(this,"idToIndexMap",{animations:{},accessors:{},buffers:{},bufferViews:{},images:{},materials:{},meshes:{},nodes:{},samplers:{},scenes:{},skins:{},textures:{}}),p(this,"json",void 0)}normalize(t,e){this.json=t.json;const r=t.json;switch(r.asset&&r.asset.version){case"2.0":return;case void 0:case"1.0":break;default:return void console.warn("glTF: Unknown version ".concat(r.asset.version))}if(!e.normalize)throw new Error("glTF v1 is not supported.");console.warn("Converting glTF v1 to glTF v2 format. This is experimental and may fail."),this._addAsset(r),this._convertTopLevelObjectsToArrays(r),function(t){const e=new Aa(t),{json:r}=e;for(const t of r.images||[]){const r=e.getObjectExtension(t,Va);r&&Object.assign(t,r),e.removeObjectExtension(t,Va)}r.buffers&&r.buffers[0]&&delete r.buffers[0].uri,e.removeExtension(Va)}(t),this._convertObjectIdsToArrayIndices(r),this._updateObjects(r),this._updateMaterial(r)}_addAsset(t){t.asset=t.asset||{},t.asset.version="2.0",t.asset.generator=t.asset.generator||"Normalized to glTF 2.0 by loaders.gl"}_convertTopLevelObjectsToArrays(t){for(const e in Ka)this._convertTopLevelObjectToArray(t,e)}_convertTopLevelObjectToArray(t,e){const r=t[e];if(r&&!Array.isArray(r)){t[e]=[];for(const n in r){const s=r[n];s.id=s.id||n;const i=t[e].length;t[e].push(s),this.idToIndexMap[e][n]=i}}}_convertObjectIdsToArrayIndices(t){for(const e in Ka)this._convertIdsToIndices(t,e);"scene"in t&&(t.scene=this._convertIdToIndex(t.scene,"scene"));for(const e of t.textures)this._convertTextureIds(e);for(const e of t.meshes)this._convertMeshIds(e);for(const e of t.nodes)this._convertNodeIds(e);for(const e of t.scenes)this._convertSceneIds(e)}_convertTextureIds(t){t.source&&(t.source=this._convertIdToIndex(t.source,"image"))}_convertMeshIds(t){for(const e of t.primitives){const{attributes:t,indices:r,material:n}=e;for(const e in t)t[e]=this._convertIdToIndex(t[e],"accessor");r&&(e.indices=this._convertIdToIndex(r,"accessor")),n&&(e.material=this._convertIdToIndex(n,"material"))}}_convertNodeIds(t){t.children&&(t.children=t.children.map((t=>this._convertIdToIndex(t,"node")))),t.meshes&&(t.meshes=t.meshes.map((t=>this._convertIdToIndex(t,"mesh"))))}_convertSceneIds(t){t.nodes&&(t.nodes=t.nodes.map((t=>this._convertIdToIndex(t,"node"))))}_convertIdsToIndices(t,e){t[e]||(console.warn("gltf v1: json doesn't contain attribute ".concat(e)),t[e]=[]);for(const r of t[e])for(const t in r){const e=r[t],n=this._convertIdToIndex(e,t);r[t]=n}}_convertIdToIndex(t,e){const r=Qa[e];if(r in this.idToIndexMap){const n=this.idToIndexMap[r][t];if(!Number.isFinite(n))throw new Error("gltf v1: failed to resolve ".concat(e," with id ").concat(t));return n}return t}_updateObjects(t){for(const t of this.json.buffers)delete t.type}_updateMaterial(t){for(const e of t.materials){e.pbrMetallicRoughness={baseColorFactor:[1,1,1,1],metallicFactor:1,roughnessFactor:1};const r=e.values&&e.values.tex,n=t.textures.findIndex((t=>t.id===r));-1!==n&&(e.pbrMetallicRoughness.baseColorTexture={index:n})}}}const za={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Wa={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},Ya=10240,Xa=10241,Za=10242,$a=10243,tc=10497,ec={magFilter:Ya,minFilter:Xa,wrapS:Za,wrapT:$a},rc={[Ya]:9729,[Xa]:9986,[Za]:tc,[$a]:tc};class nc{constructor(){p(this,"baseUri",""),p(this,"json",{}),p(this,"buffers",[]),p(this,"images",[])}postProcess(t,e={}){const{json:r,buffers:n=[],images:s=[],baseUri:i=""}=t;return ra(r),this.baseUri=i,this.json=r,this.buffers=n,this.images=s,this._resolveTree(this.json,e),this.json}_resolveTree(t,e={}){t.bufferViews&&(t.bufferViews=t.bufferViews.map(((t,e)=>this._resolveBufferView(t,e)))),t.images&&(t.images=t.images.map(((t,e)=>this._resolveImage(t,e)))),t.samplers&&(t.samplers=t.samplers.map(((t,e)=>this._resolveSampler(t,e)))),t.textures&&(t.textures=t.textures.map(((t,e)=>this._resolveTexture(t,e)))),t.accessors&&(t.accessors=t.accessors.map(((t,e)=>this._resolveAccessor(t,e)))),t.materials&&(t.materials=t.materials.map(((t,e)=>this._resolveMaterial(t,e)))),t.meshes&&(t.meshes=t.meshes.map(((t,e)=>this._resolveMesh(t,e)))),t.nodes&&(t.nodes=t.nodes.map(((t,e)=>this._resolveNode(t,e)))),t.skins&&(t.skins=t.skins.map(((t,e)=>this._resolveSkin(t,e)))),t.scenes&&(t.scenes=t.scenes.map(((t,e)=>this._resolveScene(t,e)))),void 0!==t.scene&&(t.scene=t.scenes[this.json.scene])}getScene(t){return this._get("scenes",t)}getNode(t){return this._get("nodes",t)}getSkin(t){return this._get("skins",t)}getMesh(t){return this._get("meshes",t)}getMaterial(t){return this._get("materials",t)}getAccessor(t){return this._get("accessors",t)}getCamera(t){return null}getTexture(t){return this._get("textures",t)}getSampler(t){return this._get("samplers",t)}getImage(t){return this._get("images",t)}getBufferView(t){return this._get("bufferViews",t)}getBuffer(t){return this._get("buffers",t)}_get(t,e){if("object"==typeof e)return e;const r=this.json[t]&&this.json[t][e];return r||console.warn("glTF file error: Could not find ".concat(t,"[").concat(e,"]")),r}_resolveScene(t,e){return t.id=t.id||"scene-".concat(e),t.nodes=(t.nodes||[]).map((t=>this.getNode(t))),t}_resolveNode(t,e){return t.id=t.id||"node-".concat(e),t.children&&(t.children=t.children.map((t=>this.getNode(t)))),void 0!==t.mesh?t.mesh=this.getMesh(t.mesh):void 0!==t.meshes&&t.meshes.length&&(t.mesh=t.meshes.reduce(((t,e)=>{const r=this.getMesh(e);return t.id=r.id,t.primitives=t.primitives.concat(r.primitives),t}),{primitives:[]})),void 0!==t.camera&&(t.camera=this.getCamera(t.camera)),void 0!==t.skin&&(t.skin=this.getSkin(t.skin)),t}_resolveSkin(t,e){return t.id=t.id||"skin-".concat(e),t.inverseBindMatrices=this.getAccessor(t.inverseBindMatrices),t}_resolveMesh(t,e){return t.id=t.id||"mesh-".concat(e),t.primitives&&(t.primitives=t.primitives.map((t=>{const e=(t={...t}).attributes;t.attributes={};for(const r in e)t.attributes[r]=this.getAccessor(e[r]);return void 0!==t.indices&&(t.indices=this.getAccessor(t.indices)),void 0!==t.material&&(t.material=this.getMaterial(t.material)),t}))),t}_resolveMaterial(t,e){if(t.id=t.id||"material-".concat(e),t.normalTexture&&(t.normalTexture={...t.normalTexture},t.normalTexture.texture=this.getTexture(t.normalTexture.index)),t.occlusionTexture&&(t.occlustionTexture={...t.occlustionTexture},t.occlusionTexture.texture=this.getTexture(t.occlusionTexture.index)),t.emissiveTexture&&(t.emmisiveTexture={...t.emmisiveTexture},t.emissiveTexture.texture=this.getTexture(t.emissiveTexture.index)),t.emissiveFactor||(t.emissiveFactor=t.emmisiveTexture?[1,1,1]:[0,0,0]),t.pbrMetallicRoughness){t.pbrMetallicRoughness={...t.pbrMetallicRoughness};const e=t.pbrMetallicRoughness;e.baseColorTexture&&(e.baseColorTexture={...e.baseColorTexture},e.baseColorTexture.texture=this.getTexture(e.baseColorTexture.index)),e.metallicRoughnessTexture&&(e.metallicRoughnessTexture={...e.metallicRoughnessTexture},e.metallicRoughnessTexture.texture=this.getTexture(e.metallicRoughnessTexture.index))}return t}_resolveAccessor(t,e){var r,n;if(t.id=t.id||"accessor-".concat(e),void 0!==t.bufferView&&(t.bufferView=this.getBufferView(t.bufferView)),t.bytesPerComponent=(r=t.componentType,Wa[r]),t.components=(n=t.type,za[n]),t.bytesPerElement=t.bytesPerComponent*t.components,t.bufferView){const e=t.bufferView.buffer,{ArrayType:r,byteLength:n}=da(t,t.bufferView),s=(t.bufferView.byteOffset||0)+(t.byteOffset||0)+e.byteOffset;let i=e.arrayBuffer.slice(s,s+n);t.bufferView.byteStride&&(i=this._getValueFromInterleavedBuffer(e,s,t.bufferView.byteStride,t.bytesPerElement,t.count)),t.value=new r(i)}return t}_getValueFromInterleavedBuffer(t,e,r,n,s){const i=new Uint8Array(s*n);for(let o=0;o<s;o++){const s=e+o*r;i.set(new Uint8Array(t.arrayBuffer.slice(s,s+n)),o*n)}return i.buffer}_resolveTexture(t,e){return t.id=t.id||"texture-".concat(e),t.sampler="sampler"in t?this.getSampler(t.sampler):rc,t.source=this.getImage(t.source),t}_resolveSampler(t,e){t.id=t.id||"sampler-".concat(e),t.parameters={};for(const e in t){const r=this._enumSamplerParameter(e);void 0!==r&&(t.parameters[r]=t[e])}return t}_enumSamplerParameter(t){return ec[t]}_resolveImage(t,e){t.id=t.id||"image-".concat(e),void 0!==t.bufferView&&(t.bufferView=this.getBufferView(t.bufferView));const r=this.images[e];return r&&(t.image=r),t}_resolveBufferView(t,e){const r=t.buffer,n={id:"bufferView-".concat(e),...t,buffer:this.buffers[r]},s=this.buffers[r].arrayBuffer;let i=this.buffers[r].byteOffset||0;return"byteOffset"in t&&(i+=t.byteOffset),n.data=new Uint8Array(s,i,t.byteLength),n}_resolveCamera(t,e){return t.id=t.id||"camera-".concat(e),t.perspective,t.orthographic,t}}const sc=1735152710,ic=1313821514,oc=5130562,ac=!0;function cc(t,e,r=0,n={}){const s=new DataView(e),i=function(t,e=0){return"".concat(String.fromCharCode(t.getUint8(e+0))).concat(String.fromCharCode(t.getUint8(e+1))).concat(String.fromCharCode(t.getUint8(e+2))).concat(String.fromCharCode(t.getUint8(e+3)))}(s,r+0),a=s.getUint32(r+4,ac),c=s.getUint32(r+8,ac);switch(Object.assign(t,{header:{byteOffset:r,byteLength:c,hasBinChunk:!1},type:i,version:a,json:{},binChunks:[]}),r+=12,t.version){case 1:return function(t,e,r){o(t.header.byteLength>20);const n=e.getUint32(r+0,ac),s=e.getUint32(r+4,ac);return r+=8,o(0===s),uc(t,e,r,n),r+=n,r+=lc(t,e,r,t.header.byteLength)}(t,s,r);case 2:return function(t,e,r,n){return o(t.header.byteLength>20),function(t,e,r,n){for(;r+8<=t.header.byteLength;){const s=e.getUint32(r+0,ac),i=e.getUint32(r+4,ac);switch(r+=8,i){case ic:uc(t,e,r,s);break;case oc:lc(t,e,r,s);break;case 0:n.strict||uc(t,e,r,s);break;case 1:n.strict||lc(t,e,r,s)}r+=J(s,4)}}(t,e,r,n),r+t.header.byteLength}(t,s,r,{});default:throw new Error("Invalid GLB version ".concat(t.version,". Only supports v1 and v2."))}}function uc(t,e,r,n){const s=new Uint8Array(e.buffer,r,n),i=new TextDecoder("utf8").decode(s);return t.json=JSON.parse(i),J(n,4)}function lc(t,e,r,n){return t.header.hasBinChunk=!0,t.binChunks.push({byteOffset:r,byteLength:n,arrayBuffer:e.buffer}),J(n,4)}async function hc(t,e,r=0,n,s){var i,o,a,c;!function(t,e,r,n){n.uri&&(t.baseUri=n.uri);if(e instanceof ArrayBuffer&&!function(t,e=0,r={}){const n=new DataView(t),{magic:s=sc}=r,i=n.getUint32(e,!1);return i===s||i===sc}(e,r,n)){e=(new TextDecoder).decode(e)}if("string"==typeof e)t.json=U(e);else if(e instanceof ArrayBuffer){const s={};r=cc(s,e,r,n.glb),ra("glTF"===s.type,"Invalid GLB magic string ".concat(s.type)),t._glb=s,t.json=s.json}else ra(!1,"GLTF: must be ArrayBuffer or string");const s=t.json.buffers||[];if(t.buffers=new Array(s.length).fill(null),t._glb&&t._glb.header.hasBinChunk){const{binChunks:e}=t._glb;t.buffers[0]={arrayBuffer:e[0].arrayBuffer,byteOffset:e[0].byteOffset,byteLength:e[0].byteLength}}const i=t.json.images||[];t.images=new Array(i.length).fill({})}(t,e,r,n),function(t,e={}){(new qa).normalize(t,e)}(t,{normalize:null==n||null===(i=n.gltf)||void 0===i?void 0:i.normalize}),function(t,e={},r){const n=ja.filter((t=>ka(t.name,e)));for(const i of n){var s;null===(s=i.preprocess)||void 0===s||s.call(i,t,e,r)}}(t,n,s);const u=[];if(null!=n&&null!==(o=n.gltf)&&void 0!==o&&o.loadBuffers&&t.json.buffers&&await async function(t,e,r){const n=t.json.buffers||[];for(let o=0;o<n.length;++o){const a=n[o];if(a.uri){var s,i;const{fetch:n}=r;ra(n);const c=na(a.uri,e),u=await(null==r||null===(s=r.fetch)||void 0===s?void 0:s.call(r,c)),l=await(null==u||null===(i=u.arrayBuffer)||void 0===i?void 0:i.call(u));t.buffers[o]={arrayBuffer:l,byteOffset:0,byteLength:l.byteLength},delete a.uri}}}(t,n,s),null!=n&&null!==(a=n.gltf)&&void 0!==a&&a.loadImages){const e=async function(t,e,r){const n=function(t){const e=new Set,r=t.json.textures||[];for(const t of r)void 0!==t.source&&e.add(t.source);return Array.from(e).sort()}(t),s=t.json.images||[],i=[];for(const o of n)i.push(dc(t,s[o],o,e,r));return await Promise.all(i)}(t,n,s);u.push(e)}const l=async function(t,e={},r){const n=ja.filter((t=>ka(t.name,e)));for(const i of n){var s;await(null===(s=i.decode)||void 0===s?void 0:s.call(i,t,e,r))}}(t,n,s);return u.push(l),await Promise.all(u),null!=n&&null!==(c=n.gltf)&&void 0!==c&&c.postProcess?function(t,e){return(new nc).postProcess(t,e)}(t,n):t}async function dc(t,e,r,n,s){const{fetch:i,parse:o}=s;let a;if(e.uri){const t=na(e.uri,n),r=await i(t);a=await r.arrayBuffer()}if(Number.isFinite(e.bufferView)){const r=function(t,e,r){const n=t.bufferViews[r];ra(n);const s=e[n.buffer];ra(s);const i=(n.byteOffset||0)+s.byteOffset;return new Uint8Array(s.arrayBuffer,i,n.byteLength)}(t.json,t.buffers,e.bufferView);a=H(r.buffer,r.byteOffset,r.byteLength)}ra(a,"glTF image has no data");let c=await o(a,[Zo,So],{mimeType:e.mimeType,basis:n.basis||{format:Ro()}},s);c&&c[0]&&(c={compressed:!0,mipmaps:!1,width:c[0].width,height:c[0].height,data:c}),t.images=t.images||[],t.images[r]=c}const fc={name:"glTF",id:"gltf",module:"gltf",version:"3.1.4",extensions:["gltf","glb"],mimeTypes:["model/gltf+json","model/gltf-binary"],text:!0,binary:!0,tests:["glTF"],parse:async function(t,e={},r){(e={...fc.options,...e}).gltf={...fc.options.gltf,...e.gltf};const{byteOffset:n=0}=e;return await hc({},t,n,e,r)},options:{gltf:{normalize:!0,loadBuffers:!0,loadImages:!0,decompressMeshes:!0,postProcess:!0},log:console},deprecatedOptions:{fetchImages:"gltf.loadImages",createImages:"gltf.loadImages",decompress:"gltf.decompressMeshes",postProcess:"gltf.postProcess",gltf:{decompress:"gltf.decompressMeshes"}}};const Ac=0,mc=1;function pc(t,e,r,n){t.rotateYtoZ=!0;const s=t.byteOffset+t.byteLength-r;if(0===s)throw new Error("glTF byte length must be greater than 0.");return t.gltfUpAxis=n["3d-tiles"]&&n["3d-tiles"].assetGltfUpAxis?n["3d-tiles"].assetGltfUpAxis:"Y",t.gltfArrayBuffer=H(e,r,s),t.gltfByteOffset=0,t.gltfByteLength=s,r%4==0||console.warn("".concat(t.type,": embedded glb is not aligned to a 4-byte boundary.")),t.byteOffset+t.byteLength}async function Bc(t,e,r,n){const s=r["3d-tiles"]||{};if(function(t,e,r){switch(e){case Ac:const e=new Uint8Array(t.gltfArrayBuffer,t.gltfByteOffset),r=(new TextDecoder).decode(e);t.gltfUrl=r.replace(/[\s\0]+$/,""),delete t.gltfArrayBuffer,delete t.gltfByteOffset,delete t.gltfByteLength;break;case mc:break;default:throw new Error("b3dm: Illegal glTF format field")}}(t,e),s.loadGLTF){const{parse:e,fetch:s}=n;t.gltfUrl&&(t.gltfArrayBuffer=await s(t.gltfUrl,r),t.gltfByteOffset=0),t.gltfArrayBuffer&&(t.gltf=await e(t.gltfArrayBuffer,fc,r,n),delete t.gltfArrayBuffer,delete t.gltfByteOffset,delete t.gltfByteLength)}}async function gc(t,e,r,n,s){var i;r=function(t,e,r,n,s){r=Vi(t,e,r),r=Qi(t,e,r),r=qi(t,e,r),r=pc(t,e,r,n);const i=new Ri(t.featureTableJson,t.featureTableBinary);return t.rtcCenter=i.getGlobalProperty("RTC_CENTER",Ti.FLOAT,3),r}(t,e,r,n),await Bc(t,mc,n,s);const o=null==t||null===(i=t.gltf)||void 0===i?void 0:i.extensions;return o&&o.CESIUM_RTC&&(t.rtcCenter=o.CESIUM_RTC.center),r}async function yc(t,e,r,n,s){return r=function(t,e,r,n,s){if(r=Vi(t,e,r),1!==t.version)throw new Error("Instanced 3D Model version ".concat(t.version," is not supported"));r=Qi(t,e,r);const i=new DataView(e);if(t.gltfFormat=i.getUint32(r,!0),r=qi(t,e,r+=4),r=pc(t,e,r,n),0===t.featureTableJsonByteLength)throw new Error("i3dm parser: featureTableJsonByteLength is zero.");const o=new Ri(t.featureTableJson,t.featureTableBinary),a=o.getGlobalProperty("INSTANCES_LENGTH");if(o.featuresLength=a,!Number.isFinite(a))throw new Error("i3dm parser: INSTANCES_LENGTH must be defined");t.eastNorthUp=o.getGlobalProperty("EAST_NORTH_UP"),t.rtcCenter=o.getGlobalProperty("RTC_CENTER",Ti.FLOAT,3);new ki(t.batchTableJson,t.batchTableBinary,a);return function(t,e,r,n){const s=[new Array(n),t._batchTable][0],i=new Pe;new Pe,new Pe,new Pe;const o=new We,a=new Cr,c=new Pe,u={},l=new rr,h=[],d=[],f=new Pe,A=new Pe;for(let r=0;r<n;r++){let n;if(e.hasProperty("POSITION"))n=e.getProperty("POSITION",Ti.FLOAT,3,r,i);else if(e.hasProperty("POSITION_QUANTIZED")){n=e.getProperty("POSITION_QUANTIZED",Ti.UNSIGNED_SHORT,3,r,i);const t=e.getGlobalProperty("QUANTIZED_VOLUME_OFFSET",Ti.FLOAT,3,f);if(!t)throw new Error("i3dm parser: QUANTIZED_VOLUME_OFFSET must be defined for quantized positions.");const s=e.getGlobalProperty("QUANTIZED_VOLUME_SCALE",Ti.FLOAT,3,A);if(!s)throw new Error("i3dm parser: QUANTIZED_VOLUME_SCALE must be defined for quantized positions.");const o=65535;for(let e=0;e<3;e++)n[e]=n[e]/o*s[e]+t[e]}if(!n)throw new Error("i3dm: POSITION or POSITION_QUANTIZED must be defined for each instance.");if(i.copy(n),u.translation=i,t.normalUp=e.getProperty("NORMAL_UP",Ti.FLOAT,3,r,h),t.normalRight=e.getProperty("NORMAL_RIGHT",Ti.FLOAT,3,r,d),t.normalUp){if(!t.normalRight)throw new Error("i3dm: Custom orientation requires both NORMAL_UP and NORMAL_RIGHT.");t.hasCustomOrientation=!0}else{if(t.octNormalUp=e.getProperty("NORMAL_UP_OCT32P",Ti.UNSIGNED_SHORT,2,h),t.octNormalRight=e.getProperty("NORMAL_RIGHT_OCT32P",Ti.UNSIGNED_SHORT,2,d),t.octNormalUp){if(!t.octNormalRight)throw new Error("i3dm: oct-encoded orientation requires NORMAL_UP_OCT32P and NORMAL_RIGHT_OCT32P");throw new Error("i3dm: oct-encoded orientation not implemented")}t.eastNorthUp?(Qr.WGS84.eastNorthUpToFixedFrame(i,l),l.getRotationMatrix3(o)):o.identity()}a.fromMatrix3(o),u.rotation=a,c.set(1,1,1);const m=e.getProperty("SCALE",Ti.FLOAT,1,r);Number.isFinite(m)&&c.multiplyByScalar(m);const p=e.getProperty("SCALE_NON_UNIFORM",Ti.FLOAT,3,r,h);p&&c.scale(p),u.scale=c;let B=e.getProperty("BATCH_ID",Ti.UNSIGNED_SHORT,1,r);void 0===B&&(B=r);const g=(new rr).fromQuaternion(u.rotation);l.identity(),l.translate(u.translation),l.multiplyRight(g),l.scale(u.scale);const y=l.clone();s[r]={modelMatrix:y,batchId:B}}t.instances=s}(t,o,0,a),r}(t,e,r,n),await Bc(t,t.gltfFormat,n,s),r}async function Cc(t,e=0,r,n,s={}){switch(s.byteOffset=e,s.type=function(t,e=0){const r=new DataView(t);return"".concat(String.fromCharCode(r.getUint8(e+0))).concat(String.fromCharCode(r.getUint8(e+1))).concat(String.fromCharCode(r.getUint8(e+2))).concat(String.fromCharCode(r.getUint8(e+3)))}(t,e),s.type){case xs:return await async function(t,e,r,n,s,i){r=Vi(t,e,r);const o=new DataView(e);for(t.tilesLength=o.getUint32(r,!0),r+=4,t.tiles=[];t.tiles.length<t.tilesLength&&t.byteLength-r>12;){const o={};t.tiles.push(o),r=await i(e,r,n,s,o)}return r}(s,t,e,r,n,Cc);case Ls:return await gc(s,t,e,r,n);case Hs:return await async function(t,e,r,n){t.rotateYtoZ=!0,t.gltfUpAxis=r["3d-tiles"]&&r["3d-tiles"].assetGltfUpAxis?r["3d-tiles"].assetGltfUpAxis:"Y";const{parse:s}=n;t.gltf=await s(e,fc,r,n)}(s,t,r,n);case Ns:return await yc(s,t,e,r,n);case Us:return await Xi(s,t,e,r,n);default:throw new Error("3DTileLoader: unknown type ".concat(s.type))}}async function bc(t,e,r){const n=t[e].bufferView,s=t.bufferViews[n],i=t.buffers[s.buffer];if(i.uri){const t=await lt(i.uri),e=await t.arrayBuffer();return new Uint8Array(e,s.byteOffset,s.byteLength)}return new Uint8Array(r,s.byteOffset,s.byteLength)}function wc(t){const e=new DataView(t);return e.getUint32(0,!0)+2**32*e.getUint32(4,!0)}const Tc={id:"3d-tiles-subtree",name:"3D Tiles Subtree",module:"3d-tiles",version:Os,extensions:["subtree"],mimeTypes:["application/octet-stream"],tests:["subtree"],parse:async function(t){if(1952609651!==new Uint32Array(t.slice(0,4))[0])throw new Error("Wrong subtree file magic number");if(1!==new Uint32Array(t.slice(4,8))[0])throw new Error("Wrong subtree file verson, must be 1");const e=wc(t.slice(8,16)),r=new Uint8Array(t,24,e),n=new TextDecoder("utf8").decode(r),s=JSON.parse(n),i=wc(t.slice(16,24));let o=new ArrayBuffer(0);return i&&(o=t.slice(24+e)),"bufferView"in s.tileAvailability&&(s.tileAvailability.explicitBitstream=await bc(s,"tileAvailability",o)),"bufferView"in s.contentAvailability&&(s.contentAvailability.explicitBitstream=await bc(s,"contentAvailability",o)),"bufferView"in s.childSubtreeAvailability&&(s.childSubtreeAvailability.explicitBitstream=await bc(s,"childSubtreeAvailability",o)),s},options:{}},Ec={QUADTREE:4,OCTREE:8};async function Mc(t,e,r={mortonIndex:0,x:0,y:0,z:0},n=0,s=0,i={level:0,mortonIndex:0,x:0,y:0,z:0}){const{subdivisionScheme:o,subtreeLevels:a,maximumLevel:c,contentUrlTemplate:u,subtreesUriTemplate:l,basePath:h}=e,d={children:[],lodMetricValue:0,contentUrl:""},f=Ec[o],A=1&n,m=n>>1&1,p=n>>2&1,B=(f**s-1)/(f-1);let g=_c(r.mortonIndex,n),y=B+g,C=_c(r.x,A),b=_c(r.y,m),w=_c(r.z,p),T=!1;s+1>a&&(T=vc(t.childSubtreeAvailability,g));const E=_c(i.x,C),M=_c(i.y,b),v=_c(i.z,w),I=s+i.level;if(T){const e=Fc("".concat(h,"/").concat(l),I,E,M,v);t=await ie(e,Tc),i.mortonIndex=g,i.x=C,i.y=b,i.z=w,i.level=s,g=0,y=0,C=0,b=0,w=0,s=0}if(!vc(t.tileAvailability,y)||s>c)return d;vc(t.contentAvailability,y)&&(d.contentUrl=Fc(u,I,E,M,v));const _=s+1,F={mortonIndex:g,x:C,y:b,z:w};for(let r=0;r<f;r++){const n=await Mc(t,e,F,r,_,i);if(n.contentUrl||n.children.length){const t=Ic(n,I+1,{childTileX:C,childTileY:b,childTileZ:w},e);d.children.push(t)}}return d}function vc(t,e){return"constant"in t?Boolean(t.constant):!!t.explicitBitstream&&function(t,e){const r=Math.floor(t/8),n=t%8;return 1==(e[r]>>n&1)}(e,t.explicitBitstream)}function Ic(t,e,r,n){const{basePath:s,refine:i,getRefine:o,lodMetricType:a,getTileType:c,rootLodMetricValue:u,rootBoundingVolume:l}=n,h=t.contentUrl&&t.contentUrl.replace("".concat(s,"/"),""),d=u/2**e,f=function(t,e,r){if(e.region){const{childTileX:n,childTileY:s,childTileZ:i}=r,[o,a,c,u,l,h]=e.region,d=2**t,f=(c-o)/d,A=(u-a)/d,m=(h-l)/d,[p,B]=[o+f*n,o+f*(n+1)],[g,y]=[a+A*s,a+A*(s+1)],[C,b]=[l+m*i,l+m*(i+1)];return{region:[p,g,B,y,C,b]}}return console.warn("Unsupported bounding volume type: ",e),null}(e,l,r);return{children:t.children,contentUrl:t.contentUrl,content:{uri:h},id:t.contentUrl,refine:o(i),type:c(t),lodMetricType:a,lodMetricValue:d,boundingVolume:f}}function _c(t,e){return parseInt(t.toString(2)+e.toString(2),2)}function Fc(t,e,r,n,s){const i=function(t){const e={};for(const r in t)e["{".concat(r,"}")]=t[r];return e}({level:e,x:r,y:n,z:s});return t.replace(/{level}|{x}|{y}|{z}/gi,(t=>i[t]))}function Dc(t){if(!t.contentUrl)return Wn;const e=t.contentUrl.split(".").pop();switch(e){case"pnts":return Xn;case"i3dm":case"b3dm":case"glb":case"gltf":return Yn;default:return e}}function Gc(t){switch(t){case"REPLACE":case"replace":return zn;case"ADD":case"add":return qn;default:return t}}function Rc(t,e){if(!t)return null;if(t.content){const r=t.content.uri||t.content.url;t.contentUrl="".concat(e.basePath,"/").concat(r)}return t.id=t.contentUrl,t.lodMetricType=es,t.lodMetricValue=t.geometricError,t.transformMatrix=t.transform,t.type=Dc(t),t.refine=Gc(t.refine),t}async function Sc(t){if(!t.root)return null;const e=t.basePath,r=t.root.extensions["3DTILES_implicit_tiling"],{subdivisionScheme:n,maximumLevel:s,subtreeLevels:i,subtrees:{uri:o}}=r,a=Fc(o,0,0,0,0),c="".concat(e,"/").concat(a),u=await ie(c,Tc),l="".concat(e,"/").concat(t.root.content.uri),h=t.root.refine,d=t.root.geometricError,f=t.root.boundingVolume,A={contentUrlTemplate:l,subtreesUriTemplate:o,subdivisionScheme:n,subtreeLevels:i,maximumLevel:s,refine:h,basePath:e,lodMetricType:es,rootLodMetricValue:d,rootBoundingVolume:f,getTileType:Dc,getRefine:Gc};return await async function(t,e,r){if(!t)return null;t.lodMetricType=es,t.lodMetricValue=t.geometricError,t.transformMatrix=t.transform;const{children:n,contentUrl:s}=await Mc(e,r);s&&(t.contentUrl=s,t.content={uri:s.replace("".concat(r.basePath,"/"),"")});return t.refine=Gc(t.refine),t.type=Dc(t),t.children=n,t.id=t.contentUrl,t}(t.root,u,A)}const Oc="3DTILES_implicit_tiling",xc={id:"3d-tiles",name:"3D Tiles",module:"3d-tiles",version:Os,extensions:["cmpt","pnts","b3dm","i3dm"],mimeTypes:["application/octet-stream"],tests:["cmpt","pnts","b3dm","i3dm"],parse:async function(t,e,r){const n=e["3d-tiles"]||{};let s;s="auto"===n.isTileset?r.url&&-1!==r.url.indexOf(".json"):n.isTileset;t=s?await async function(t,e,r){var n;const s=JSON.parse((new TextDecoder).decode(t));return s.loader=e.loader||xc,s.url=r.url,s.basePath=function(t){return W(t.url)}(s),s.root=function(t){var e,r;return(null==t||null===(e=t.extensionsRequired)||void 0===e?void 0:e.includes(Oc))&&(null==t||null===(r=t.extensionsUsed)||void 0===r?void 0:r.includes(Oc))}(s)?await Sc(s):function(t){const e=t.basePath,r=Rc(t.root,t),n=[];for(n.push(r);n.length>0;){const t=(n.pop()||{}).children||[];for(const r of t)Rc(r,{basePath:e}),n.push(r)}return r}(s),s.type=ts,s.lodMetricType=es,s.lodMetricValue=(null===(n=s.root)||void 0===n?void 0:n.lodMetricValue)||0,s}(t,e,r):await async function(t,e,r){const n={content:{featureIds:null}},s=0;return await Cc(t,s,e,r,n.content),n.content}(t,e,r);return t},options:{"3d-tiles":{loadGLTF:!0,decodeQuantizedPositions:!1,isTileset:"auto",assetGltfUpAxis:null}}};const Uc="https://api.cesium.com/v1/assets";async function Lc(t,e){if(!e){const r=await async function(t){o(t);const e=Uc,r={Authorization:"Bearer ".concat(t)},n=await lt(e,{fetch:{headers:r}});if(!n.ok)throw new Error(n.statusText);return await n.json()}(t);for(const t of r.items)"3DTILES"===t.type&&(e=t.id)}const r=await async function(t,e){o(t,e);const r={Authorization:"Bearer ".concat(t)},n="".concat(Uc,"/").concat(e);let s=await lt("".concat(n),{fetch:{headers:r}});if(!s.ok)throw new Error(s.statusText);let i=await s.json();if(s=await lt("".concat(n,"/endpoint"),{fetch:{headers:r}}),!s.ok)throw new Error(s.statusText);const a=await s.json();return i={...i,...a},i}(t,e),{type:n,url:s}=r;return o("3DTILES"===n&&s),r.headers={Authorization:"Bearer ".concat(r.accessToken)},r}const Nc={...xc,id:"cesium-ion",name:"Cesium Ion",preload:async function(t,e={}){e=e["cesium-ion"]||{};const{accessToken:r}=e;let n=e.assetId;if(!Number.isFinite(n)){const e=t.match(/\/([0-9]+)\/tileset.json/);n=e&&e[1]}return Lc(r,n)},parse:async(t,e,r)=>((e={...e})["3d-tiles"]=e["cesium-ion"],e.loader=Nc,xc.parse(t,e,r)),options:{"cesium-ion":{...xc.options["3d-tiles"],accessToken:null}}};function Hc(t){const r=64,n=document.createElement("canvas");n.width=r,n.height=r;const s=n.getContext("2d");s.rect(0,0,r,r);const i=s.createLinearGradient(0,0,r,r);for(let e=0;e<t.length;e++){const r=t[e];i.addColorStop(r[0],"#"+r[1].getHexString())}s.fillStyle=i,s.fill();const o=new e.CanvasTexture(n);return o.needsUpdate=!0,o.minFilter=e.LinearFilter,o.wrapS=e.RepeatWrapping,o.wrapT=e.RepeatWrapping,o.repeat.set(2,2),o}function Jc(t){t.updateMatrix(),t.updateMatrixWorld(),t.matrixWorldInverse.copy(t.matrixWorld).invert();const r=new e.Frustum;return r.setFromProjectionMatrix((new e.Matrix4).multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse)),r}function Pc(t){const{boundingVolume:r}=t;let n=0;t.content&&(n=Math.min(t.content.byteLength/5e5,1));const s=new e.Color(n,1,0),i=new e.BoxGeometry(1,1,1),o=new e.Matrix4;r.halfAxes?o.copy(jc(r.halfAxes)):r.radius&&i.scale(2*r.radius,2*r.radius,2*r.radius),i.applyMatrix4(o);const a=new e.EdgesGeometry(i),c=new e.LineSegments(a,new e.LineBasicMaterial({color:s}));return c.position.copy(new e.Vector3(...r.center)),c}function jc(t){const r=t;return(new e.Matrix4).fromArray([2*r[0],2*r[1],2*r[2],0,2*r[3],2*r[4],2*r[5],0,2*r[6],2*r[7],2*r[8],0,0,0,0,1])}const kc={SPECTRAL:[[0,new e.Color(.3686,.3098,.6353)],[.1,new e.Color(.1961,.5333,.7412)],[.2,new e.Color(.4,.7608,.6471)],[.3,new e.Color(.6706,.8667,.6431)],[.4,new e.Color(.902,.9608,.5961)],[.5,new e.Color(1,1,.749)],[.6,new e.Color(.9961,.8784,.5451)],[.7,new e.Color(.9922,.6824,.3804)],[.8,new e.Color(.9569,.4275,.2627)],[.9,new e.Color(.8353,.2431,.3098)],[1,new e.Color(.6196,.0039,.2588)]],PLASMA:[[0,new e.Color(.241,.015,.61)],[.1,new e.Color(.387,.001,.654)],[.2,new e.Color(.524,.025,.653)],[.3,new e.Color(.651,.125,.596)],[.4,new e.Color(.752,.227,.513)],[.5,new e.Color(.837,.329,.431)],[.6,new e.Color(.907,.435,.353)],[.7,new e.Color(.963,.554,.272)],[.8,new e.Color(.992,.681,.195)],[.9,new e.Color(.987,.822,.144)],[1,new e.Color(.94,.975,.131)]],YELLOW_GREEN:[[0,new e.Color(.1647,.2824,.3451)],[.1,new e.Color(.1338,.3555,.4227)],[.2,new e.Color(.061,.4319,.4864)],[.3,new e.Color(0,.5099,.5319)],[.4,new e.Color(0,.5881,.5569)],[.5,new e.Color(.137,.665,.5614)],[.6,new e.Color(.2906,.7395,.5477)],[.7,new e.Color(.4453,.8099,.5201)],[.8,new e.Color(.6102,.8748,.485)],[.9,new e.Color(.7883,.9323,.4514)],[1,new e.Color(.9804,.9804,.4314)]],VIRIDIS:[[0,new e.Color(.267,.005,.329)],[.1,new e.Color(.283,.141,.458)],[.2,new e.Color(.254,.265,.53)],[.3,new e.Color(.207,.372,.553)],[.4,new e.Color(.164,.471,.558)],[.5,new e.Color(.128,.567,.551)],[.6,new e.Color(.135,.659,.518)],[.7,new e.Color(.267,.749,.441)],[.8,new e.Color(.478,.821,.318)],[.9,new e.Color(.741,.873,.15)],[1,new e.Color(.993,.906,.144)]],INFERNO:[[0,new e.Color(.077,.042,.206)],[.1,new e.Color(.225,.036,.388)],[.2,new e.Color(.373,.074,.432)],[.3,new e.Color(.522,.128,.42)],[.4,new e.Color(.665,.182,.37)],[.5,new e.Color(.797,.255,.287)],[.6,new e.Color(.902,.364,.184)],[.7,new e.Color(.969,.516,.063)],[.8,new e.Color(.988,.683,.072)],[.9,new e.Color(.961,.859,.298)],[1,new e.Color(.988,.998,.645)]],GRAYSCALE:[[0,new e.Color(0,0,0)],[1,new e.Color(1,1,1)]],TURBO:[[0,new e.Color(.18995,.07176,.23217)],[.07,new e.Color(.25107,.25237,.63374)],[.13,new e.Color(.27628,.42118,.89123)],[.2,new e.Color(.25862,.57958,.99876)],[.27,new e.Color(.15844,.73551,.92305)],[.33,new e.Color(.09267,.86554,.7623)],[.4,new e.Color(.19659,.94901,.59466)],[.47,new e.Color(.42778,.99419,.38575)],[.53,new e.Color(.64362,.98999,.23356)],[.6,new e.Color(.80473,.92452,.20459)],[.67,new e.Color(.93301,.81236,.22667)],[.73,new e.Color(.99314,.67408,.20348)],[.8,new e.Color(.9836,.49291,.12849)],[.87,new e.Color(.92105,.31489,.05475)],[.93,new e.Color(.81608,.18462,.01809)],[1,new e.Color(.66449,.08436,.00424)]],RAINBOW:[[0,new e.Color(.278,0,.714)],[1/6,new e.Color(0,0,1)],[2/6,new e.Color(0,1,1)],[.5,new e.Color(0,1,0)],[4/6,new e.Color(1,1,0)],[5/6,new e.Color(1,.64,0)],[1,new e.Color(1,0,0)]],CONTOUR:[[0,new e.Color(0,0,0)],[.03,new e.Color(0,0,0)],[.04,new e.Color(1,1,1)],[1,new e.Color(1,1,1)]]};var Vc,Kc,Qc;t.PointCloudColoring=void 0,(Vc=t.PointCloudColoring||(t.PointCloudColoring={}))[Vc.Intensity=1]="Intensity",Vc[Vc.Classification=2]="Classification",Vc[Vc.Elevation=3]="Elevation",Vc[Vc.RGB=4]="RGB",Vc[Vc.White=5]="White",t.Shading=void 0,(Kc=t.Shading||(t.Shading={}))[Kc.FlatTexture=1]="FlatTexture",Kc[Kc.ShadedTexture=2]="ShadedTexture",Kc[Kc.ShadedNoTexture=3]="ShadedNoTexture",t.GeoTransform=void 0,(Qc=t.GeoTransform||(t.GeoTransform={}))[Qc.Reset=1]="Reset",Qc[Qc.Mercator=2]="Mercator",Qc[Qc.WGS84Cartesian=3]="WGS84Cartesian";const qc="undefined"!=typeof document?Hc(kc.RAINBOW):null,zc="undefined"!=typeof document?Hc(kc.GRAYSCALE):null,Wc={throttleRequests:!0,maxRequests:64,updateInterval:.1,maxConcurrency:1,maximumScreenSpaceError:16,maximumMemoryUsage:32,viewDistanceScale:1,skipLevelOfDetail:!1,updateTransforms:!0,shading:t.Shading.FlatTexture,transparent:!1,pointCloudColoring:t.PointCloudColoring.White,pointSize:1,worker:!0,wireframe:!1,debug:!1,basisTranscoderPath:null,dracoDecoderPath:null,material:null,computeNormals:!1,shaderCallback:null,geoTransform:t.GeoTransform.Reset,preloadTilesCount:null};function Yc(t){var e,r,n,s;(null===(e=null==t?void 0:t.uniforms)||void 0===e?void 0:e.map)?null===(n=null===(r=null==t?void 0:t.uniforms)||void 0===r?void 0:r.map.value)||void 0===n||n.dispose():t.map&&(null===(s=t.map)||void 0===s||s.dispose()),t.dispose()}function Xc(t){t.traverse((t=>{if(t.isMesh)if(t.geometry.dispose(),t.material.isMaterial)Yc(t.material);else for(const e of t.material)Yc(e)}));for(let e=t.children.length-1;e>=0;e--){const r=t.children[e];t.remove(r)}}t.Loader3DTiles=class{static load(o){return i(this,void 0,void 0,(function*(){const a=Object.assign(Object.assign({},Wc),o.options),{url:c}=o,u=a.updateInterval,l={};if(a.cesiumIONToken){l["cesium-ion"]={accessToken:a.cesiumIONToken};const t=yield Nc.preload(c,l);l.fetch={headers:t.headers}}o.loadingManager&&o.loadingManager.itemStart(c);const h=yield ie(c,xc,Object.assign({},l)),d={},f={},A=[],m=new e.Group,p=new e.Group;a.debug||(p.visible=!1);const B={pointSize:{type:"f",value:a.pointSize},gradient:{type:"t",value:qc},grayscale:{type:"t",value:zc},rootCenter:{type:"vec3",value:new e.Vector3},rootNormal:{type:"vec3",value:new e.Vector3},coloring:{type:"i",value:a.pointCloudColoring},hideGround:{type:"b",value:!0},elevationRange:{type:"vec2",value:new e.Vector2(0,400)},maxIntensity:{type:"f",value:1},intensityContrast:{type:"f",value:1},alpha:{type:"f",value:1}},g=new e.ShaderMaterial({uniforms:B,vertexShader:"\n varying vec3 vColor;\n uniform sampler2D gradient;\n uniform sampler2D grayscale;\n attribute float intensity;\n attribute float classification;\n uniform vec3 rootCenter;\n uniform vec3 rootNormal;\n uniform vec2 elevationRange;\n uniform int coloring;\n uniform bool hideGround;\n uniform float maxIntensity;\n uniform float intensityContrast;\n uniform float pointSize;\n\n #ifdef USE_COLOR\n vec3 getRGB() {\n vec3 rgb = color;\n return rgb;\n }\n #endif\n\n vec3 getElevation(){\n vec4 world = modelMatrix * vec4( position, 1.0 );\n float diff = abs(dot(rootNormal, (vec3(world) - rootCenter)));\n float w = max(diff - elevationRange.x,0.0) / max(elevationRange.y - elevationRange.x,1.0);\n vec3 cElevation = texture2D(gradient, vec2(w,1.0-w)).rgb;\n\n return cElevation;\n }\n\n vec3 getIntensity(){\n // TODO: real contrast enhancement. Check https://github.com/yuki-koyama/enhancer/blob/master/shaders/enhancer.fs\n float intmod = pow(intensity, intensityContrast);\n vec3 cIntensity = texture2D(grayscale, vec2(intmod / maxIntensity ,1.0-(intmod / maxIntensity))).rgb;\n return cIntensity;\n }\n\n vec3 getClassification(){\n float classNormalized = classification / 255.0;\n vec3 cClassification = texture2D(gradient, vec2(classNormalized * 5.0,1.0-classNormalized * 5.0)).rgb;\n return cClassification;\n }\n\n vec3 getColor(){\n vec3 color;\n if (hideGround && classification == 2.0) {\n return vec3(0.0, 0.0, 0.0); \n }\n\n if (coloring == 1) {\n color = getIntensity();\n }\n else if (coloring == 2) {\n color = getClassification();\n } else if (coloring == 3) {\n color = getElevation();\n } \n #ifdef USE_COLOR\n else if (coloring == 4) {\n color = getRGB();\n }\n #endif\n else {\n color = vec3(1.0, 1.0, 1.0);\n }\n return color;\n }\n\n void main() {\n vColor = getColor();\n\n gl_PointSize = pointSize;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n }\n",fragmentShader:"\n varying vec3 vColor;\n uniform float alpha;\n\n void main() {\n if (vColor == vec3(0.0, 0.0, 0.0)) {\n discard;\n } else {\n gl_FragColor = vec4( vColor, alpha);\n }\n }\n",transparent:a.transparent,vertexColors:!0});let y=null,C=null;const b=new r.GLTFLoader;let w,T;a.basisTranscoderPath&&(w=new s.KTX2Loader,w.detectSupport(o.renderer),w.setTranscoderPath(a.basisTranscoderPath+"/"),w.setWorkerLimit(1),b.setKTX2Loader(w)),a.dracoDecoderPath&&(T=new n.DRACOLoader,T.setDecoderPath(a.dracoDecoderPath+"/"),T.setWorkerLimit(a.maxConcurrency),b.setDRACOLoader(T));const E=new e.MeshBasicMaterial({transparent:a.transparent}),M={maximumMemoryUsage:a.maximumMemoryUsage,maximumScreenSpaceError:a.maximumScreenSpaceError,viewDistanceScale:a.viewDistanceScale,skipLevelOfDetail:a.skipLevelOfDetail,updateTransforms:a.updateTransforms,throttleRequests:a.throttleRequests,maxRequests:a.maxRequests,contentLoader:r=>i(this,void 0,void 0,(function*(){let n=null;switch(r.type){case Xn:n=function(t,r,n,s){const i={rtc_center:t.content.rtcCenter,points:t.content.attributes.positions,intensities:t.content.attributes.intensity,classifications:t.content.attributes.classification,rgb:null,rgba:null},{colors:o}=t.content.attributes;o&&3===o.size&&(i.rgb=o.value);o&&4===o.size&&(i.rgba=o.value);const a=new e.BufferGeometry;a.setAttribute("position",new e.Float32BufferAttribute(i.points,3));const c=(new e.Matrix4).fromArray(t.computedTransform).premultiply(s);i.rgba?a.setAttribute("color",new e.Float32BufferAttribute(i.rgba,4)):i.rgb&&a.setAttribute("color",new e.Uint8BufferAttribute(i.rgb,3,!0));i.intensities&&a.setAttribute("intensity",new e.BufferAttribute(i.intensities,1,!0));i.classifications&&a.setAttribute("classification",new e.Uint8BufferAttribute(i.classifications,1,!1));const u=new e.Points(a,n.material||r);if(i.rtc_center){const t=i.rtc_center;c.multiply((new e.Matrix4).makeTranslation(t[0],t[1],t[2]))}return u.applyMatrix4(c),u}(r,g,a,H);break;case Yn:case Zn:n=yield function(r,n,s,o,a){return i(this,void 0,void 0,(function*(){return new Promise(((i,c)=>{var u;const l=(new e.Matrix4).makeRotationAxis(new e.Vector3(1,0,0),Math.PI/2),h="Z"!==(null===(u=n.tileset.asset)||void 0===u?void 0:u.gltfUpAxis),d=(new e.Matrix4).fromArray(n.computedTransform).premultiply(a);h&&d.multiply(l),r.parse(n.content.gltfArrayBuffer,n.contentUrl?n.contentUrl.substr(0,n.contentUrl.lastIndexOf("/")+1):"",(e=>{const r=e.scenes[0];r.applyMatrix4(d),r.traverse((e=>{if("Mesh"==e.type){const r=e,n=r.material,i=n.map;o.material?(r.material=o.material.clone(),n.dispose()):o.shading==t.Shading.FlatTexture&&(r.material=s.clone(),n.dispose()),o.shading!=t.Shading.ShadedNoTexture?"ShaderMaterial"==r.material.type?r.material.uniforms.map={value:i}:r.material.map=i:(i&&i.dispose(),r.material.map=null),o.shaderCallback&&(r.onBeforeRender=o.shaderCallback),r.material.wireframe=o.wireframe,o.computeNormals&&r.geometry.computeVertexNormals()}})),i(r)}),(t=>{c(new Error(`error parsing gltf in tile ${n.id}: ${t}`))}))}))}))}(b,r,E,a,H)}if(n&&(n.visible=!1,d[r.id]=n,m.add(d[r.id]),a.debug)){const t=Pc(r);p.add(t),f[r.id]=t}})),onTileLoad:t=>i(this,void 0,void 0,(function*(){v&&(!D&&(null==t?void 0:t.depth)<=5&&J(t),v._frameNumber++,j(v,d,C,y))})),onTileUnload:t=>{A.push(t)},onTileError:(t,e)=>{console.error("Tile error",t.id,e)}},v=new Ss(h,Object.assign(Object.assign({},M),{loadOptions:Object.assign(Object.assign({},l),{maxConcurrency:a.maxConcurrency,worker:a.worker,gltf:{loadImages:!1},"3d-tiles":{loadGLTF:!1}})})),I=new e.Matrix4,_=new e.Matrix4,F=new e.Vector3;let D=!1;if(v.root.boundingVolume?(v.root.header.boundingVolume.region&&(console.warn("Cannot apply a model matrix to bounding volumes of type region. Tileset stays in original geo-coordinates."),a.geoTransform=t.GeoTransform.WGS84Cartesian),_.setPosition(v.root.boundingVolume.center[0],v.root.boundingVolume.center[1],v.root.boundingVolume.center[2])):console.warn("Bounding volume not found, no transformations applied"),a.debug){const t=Pc(v.root);p.add(t),f[v.root.id]=t}let G=!1,R=!1;B.rootCenter.value.copy(F),B.rootNormal.value.copy(new e.Vector3(0,0,1).normalize()),v.stats.get("Loader concurrency").count=a.maxConcurrency,v.stats.get("Maximum SSE").count=a.maximumScreenSpaceError,v.stats.get("Maximum mem usage").count=a.maximumMemoryUsage;let S=0;const O=(new e.Matrix4).makeTranslation(1/0,1/0,1/0);let x=null;const U=new e.Vector3(1/0,1/0,1/0);let L=null;m.updateMatrixWorld(!0);const N=(new e.Matrix4).copy(m.matrixWorld),H=(new e.Matrix4).copy(N).invert();if(J(v.root),P(),a.debug&&(f[v.root.id].applyMatrix4(I),p.matrixWorld.copy(m.matrixWorld)),a.geoTransform==t.GeoTransform.Mercator){const t=function(t,r){const n=2*Math.PI*6378137/2,s=r*n/180;let i=Math.log(Math.tan((90+t)*Math.PI/360))/(Math.PI/180);return i=i*n/180,new e.Vector2(s,i)}(v.cartographicCenter[1],v.cartographicCenter[0]);F.set(t.x,0,-t.y),m.position.copy(F),m.rotation.set(-Math.PI/2,0,0),m.updateMatrixWorld(!0)}else a.geoTransform==t.GeoTransform.WGS84Cartesian&&(m.applyMatrix4(_),m.updateMatrixWorld(!0),F.copy(m.position));function J(t){if(!t.boundingVolume.halfAxes)return;const r=t.boundingVolume.halfAxes,n=(new e.Matrix4).extractRotation(jc(r)).premultiply((new e.Matrix4).extractRotation(H));if(!(new e.Euler).setFromRotationMatrix(n).equals(new e.Euler)){D=!0;const t=new e.Vector3(_.elements[12],_.elements[13],_.elements[14]);_.extractRotation(n),_.setPosition(t),P()}}function P(){a.geoTransform!=t.GeoTransform.WGS84Cartesian&&(I.copy(_).invert(),I.premultiply(N),I.copy(N).multiply((new e.Matrix4).copy(_).invert()),v.modelMatrix=new rr(I.toArray()))}function j(t,r,n,s){if(G)return;if(!L||s.aspect!=x){const t=new Sn({fov:s.fov/180*Math.PI,aspectRatio:s.aspect,near:s.near,far:s.far});L=t.sseDenominator,x=s.aspect,a.debug&&console.log("Updated sse denonimator:",L)}const i=Jc(s).planes.map((t=>new bn(t.normal.toArray(),t.constant))),c=new Mn(i),u=new e.Vector2;n.getSize(u);const l={camera:{position:U.toArray()},height:u.y,frameNumber:t._frameNumber,sseDenominator:L,cullingVolume:c,viewport:{id:0}};t._cache.reset(),t._traverser.traverse(t.root,l,t.options);for(const e of t.tiles)e.selected?r[e.id]?r[e.id].visible=!0:console.error("TILE SELECTED BUT NOT LOADED!!",e.id):r[e.id]&&(r[e.id].visible=!1);for(;A.length>0;){const t=A.pop();r[t.id]&&t.contentState==jn&&(m.remove(r[t.id]),Xc(r[t.id]),delete r[t.id]),f[t.id]&&(Xc(f[t.id]),p.remove(f[t.id]),delete f[t.id])}const h=t.stats.get("Tiles Loaded").count,d=t.stats.get("Tiles Loading").count;return o.onProgress&&o.onProgress(h,h+d),o.loadingManager&&!R&&0==d&&(null==a.preloadTilesCount||h>=a.preloadTilesCount)&&(R=!0,o.loadingManager.itemEnd(o.url)),l}return{model:m,runtime:{getTileset:()=>v,getStats:()=>v.stats,showTiles:t=>{p.visible=t},setWireframe:t=>{a.wireframe=t,m.traverse((r=>{r instanceof e.Mesh&&(r.material.wireframe=t)}))},setDebug:t=>{a.debug=t,p.visible=t},setShading:t=>{a.shading=t},getTileBoxes:()=>p,setViewDistanceScale:t=>{v.options.viewDistanceScale=t,v._frameNumber++,j(v,d,C,y)},setHideGround:t=>{B.hideGround.value=t},setPointCloudColoring:t=>{B.coloring.value=t},setElevationRange:t=>{B.elevationRange.value.set(t[0],t[1])},setMaxIntensity:t=>{B.maxIntensity.value=t},setIntensityContrast:t=>{B.intensityContrast.value=t},setPointAlpha:t=>{B.alpha.value=t},getLatLongHeightFromPosition:t=>{const r=v.ellipsoid.cartesianToCartographic((new e.Vector3).copy(t).applyMatrix4((new e.Matrix4).copy(I).invert()).toArray());return{lat:r[1],long:r[0],height:r[2]}},getPositionFromLatLongHeight:t=>{const r=v.ellipsoid.cartographicToCartesian([t.long,t.lat,t.height]);return new e.Vector3(...r).applyMatrix4(I)},getCameraFrustum:t=>{const r=Jc(t).planes.map((t=>new bn(t.normal.toArray(),t.constant))).map((t=>function(t){const r=new e.Group,n=new e.PlaneGeometry(10,5),s=new e.Vector3(...t.projectPointOntoPlane([0,0,0])),i=new e.Vector3(t.normal.x,t.normal.y,t.normal.z),o=(new e.Vector3).copy(s).add(i);n.lookAt(o),n.translate(s.x,s.y,s.z);const a=new e.MeshBasicMaterial({color:65535,side:e.DoubleSide}),c=new e.Mesh(n,a),u=new e.ArrowHelper(i,s,5,16776960);return r.add(u),r.add(c),r}(t))),n=new e.Group;for(const t of r)n.add(t);return n},update:function(t,r,n){if(y=n,C=r,S+=t,v&&S>=u){if(!N.equals(m.matrixWorld)){N.copy(m.matrixWorld),P();const t=(new e.Vector3).setFromMatrixPosition(N);B.rootCenter.value.copy(t),B.rootNormal.value.copy(new e.Vector3(0,0,1).applyMatrix4(N).normalize()),H.copy(N).invert(),a.debug&&(f[v.root.id].matrixWorld.copy(I),f[v.root.id].applyMatrix4(N))}!(n.matrixWorld.equals(O)&&n.aspect==x)&&(S=0,v._frameNumber++,n.getWorldPosition(U),O.copy(n.matrixWorld),j(v,d,r,n))}},dispose:function(){for(G=!0,v._destroy();m.children.length>0;){const t=m.children[0];Xc(t),m.remove(t)}for(;p.children.length>0;){const t=p.children[0];p.remove(t),t.geometry.dispose(),t.material.dispose()}w&&w.dispose(),T&&T.dispose()}}}}))}},Object.defineProperty(t,"__esModule",{value:!0})}));
  14. //# sourceMappingURL=three-loader-3dtiles.min.js.map