text: import{CanvasTexture as e,LinearFilter as t,RepeatWrapping as r,Frustum as s,Matrix4 as n,Group as i,PlaneGeometry as o,Vector3 as a,MeshBasicMaterial as c,DoubleSide as u,Mesh as h,ArrowHelper as l,Color as d,BoxGeometry as f,EdgesGeometry as p,LineSegments as m,LineBasicMaterial as g,MeshStandardMaterial as y,Interpolant as w,Loader as b,LoaderUtils as T,FileLoader as v,SpotLight as _,PointLight as E,DirectionalLight as x,MeshPhysicalMaterial as S,Vector2 as A,TangentSpaceNormalMap as M,ImageBitmapLoader as R,TextureLoader as O,InterleavedBuffer as I,InterleavedBufferAttribute as N,BufferAttribute as L,RGBFormat as C,LinearMipmapLinearFilter as P,PointsMaterial as U,Material as k,sRGBEncoding as D,PropertyBinding as j,BufferGeometry as B,SkinnedMesh as F,Line as V,LineLoop as q,Points as z,PerspectiveCamera as G,MathUtils as H,OrthographicCamera as $,InterpolateLinear as W,AnimationClip as K,Bone as Q,Object3D as X,Skeleton as Y,NearestFilter as Z,NearestMipmapNearestFilter as J,LinearMipmapNearestFilter as ee,NearestMipmapLinearFilter as te,ClampToEdgeWrapping as re,MirroredRepeatWrapping as se,InterpolateDiscrete as ne,FrontSide as ie,TriangleFanDrawMode as oe,TriangleStripDrawMode as ae,VectorKeyframeTrack as ce,QuaternionKeyframeTrack as ue,NumberKeyframeTrack as he,Box3 as le,Sphere as de,ShaderMaterial as fe,Float32BufferAttribute as pe,Uint8BufferAttribute as me}from"three";import{GLTFLoader as ge}from"three/examples/jsm/loaders/GLTFLoader.js";import{DRACOLoader as ye}from"three/examples/jsm/loaders/DRACOLoader.js";import{KTX2Loader as we}from"three/examples/jsm/loaders/KTX2Loader.js";
  /*! *****************************************************************************
  Copyright (c) Microsoft Corporation.
  
  Permission to use, copy, modify, and/or distribute this software for any
  purpose with or without fee is hereby granted.
  
  THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
  REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
  INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  PERFORMANCE OF THIS SOFTWARE.
  ***************************************************************************** */function be(e,t,r,s){return new(r||(r=Promise))((function(n,i){function o(e){try{c(s.next(e))}catch(e){i(e)}}function a(e){try{c(s.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,a)}c((s=s.apply(e,t||[])).next())}))}function Te(e,t){if(!e)throw new Error(t||"loader assertion failed.")}const ve={self:"undefined"!=typeof self&&self,window:"undefined"!=typeof window&&window,global:"undefined"!=typeof global&&global,document:"undefined"!=typeof document&&document},_e=ve.global||ve.self||ve.window||{},Ee="object"!=typeof process||"[object process]"!==String(process)||process.browser,xe="undefined"!=typeof process&&process.version&&/v([0-9]*)/.exec(process.version);xe&&parseFloat(xe[1]);function Se(e,t){if(!e)throw new Error(t||"loaders.gl assertion failed.")}const Ae={self:"undefined"!=typeof self&&self,window:"undefined"!=typeof window&&window,global:"undefined"!=typeof global&&global,document:"undefined"!=typeof document&&document},Me=Ae.global||Ae.self||Ae.window||{},Re="object"!=typeof process||"[object process]"!==String(process)||process.browser,Oe="function"==typeof importScripts,Ie="undefined"!=typeof window&&void 0!==window.orientation,Ne="undefined"!=typeof process&&process.version&&/v([0-9]*)/.exec(process.version);function Le(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}Ne&&parseFloat(Ne[1]);class Ce{constructor(e,t){Le(this,"name",void 0),Le(this,"workerThread",void 0),Le(this,"isRunning",void 0),Le(this,"result",void 0),Le(this,"_resolve",void 0),Le(this,"_reject",void 0),this.name=e,this.workerThread=t,this.isRunning=!0,this._resolve=()=>{},this._reject=()=>{},this.result=new Promise(((e,t)=>{this._resolve=e,this._reject=t}))}postMessage(e,t){this.workerThread.postMessage({source:"loaders.gl",type:e,payload:t})}done(e){Se(this.isRunning),this.isRunning=!1,this._resolve(e)}error(e){Se(this.isRunning),this.isRunning=!1,this._reject(e)}}const Pe=new Map;function Ue(e){Se(e.source&&!e.url||!e.source&&e.url);let t=Pe.get(e.source||e.url);return t||(e.url&&(t=function(e){if(!e.startsWith("http"))return e;return ke((t=e,`try {\n  importScripts('${t}');\n} catch (error) {\n  console.error(error);\n  throw error;\n}`));var t}(e.url),Pe.set(e.url,t)),e.source&&(t=ke(e.source),Pe.set(e.source,t))),Se(t),t}function ke(e){const t=new Blob([e],{type:"application/javascript"});return URL.createObjectURL(t)}function De(e,t=!0,r){const s=r||new Set;if(e){if(je(e))s.add(e);else if(je(e.buffer))s.add(e.buffer);else if(ArrayBuffer.isView(e));else if(t&&"object"==typeof e)for(const r in e)De(e[r],t,s)}else;return void 0===r?Array.from(s):[]}function je(e){return!!e&&(e instanceof ArrayBuffer||("undefined"!=typeof MessagePort&&e instanceof MessagePort||("undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap||"undefined"!=typeof OffscreenCanvas&&e instanceof OffscreenCanvas)))}const Be=()=>{};class Fe{static isSupported(){return"undefined"!=typeof Worker}constructor(e){Le(this,"name",void 0),Le(this,"source",void 0),Le(this,"url",void 0),Le(this,"terminated",!1),Le(this,"worker",void 0),Le(this,"onMessage",void 0),Le(this,"onError",void 0),Le(this,"_loadableURL","");const{name:t,source:r,url:s}=e;Se(r||s),this.name=t,this.source=r,this.url=s,this.onMessage=Be,this.onError=e=>console.log(e),this.worker=this._createBrowserWorker()}destroy(){this.onMessage=Be,this.onError=Be,this.worker.terminate(),this.terminated=!0}get isRunning(){return Boolean(this.onMessage)}postMessage(e,t){t=t||De(e),this.worker.postMessage(e,t)}_getErrorFromErrorEvent(e){let t="Failed to load ";return t+=`worker ${this.name}. `,e.message&&(t+=`${e.message} in `),e.lineno&&(t+=`:${e.lineno}:${e.colno}`),new Error(t)}_createBrowserWorker(){this._loadableURL=Ue({source:this.source,url:this.url});const e=new Worker(this._loadableURL,{name:this.name});return e.onmessage=e=>{e.data?this.onMessage(e.data):this.onError(new Error("No data received"))},e.onerror=e=>{this.onError(this._getErrorFromErrorEvent(e)),this.terminated=!0},e.onmessageerror=e=>console.error(e),e}}class Ve{constructor(e){Le(this,"name","unnamed"),Le(this,"source",void 0),Le(this,"url",void 0),Le(this,"maxConcurrency",1),Le(this,"maxMobileConcurrency",1),Le(this,"onDebug",(()=>{})),Le(this,"reuseWorkers",!0),Le(this,"props",{}),Le(this,"jobQueue",[]),Le(this,"idleQueue",[]),Le(this,"count",0),Le(this,"isDestroyed",!1),this.source=e.source,this.url=e.url,this.setProps(e)}destroy(){this.idleQueue.forEach((e=>e.destroy())),this.isDestroyed=!0}setProps(e){this.props={...this.props,...e},void 0!==e.name&&(this.name=e.name),void 0!==e.maxConcurrency&&(this.maxConcurrency=e.maxConcurrency),void 0!==e.maxMobileConcurrency&&(this.maxMobileConcurrency=e.maxMobileConcurrency),void 0!==e.reuseWorkers&&(this.reuseWorkers=e.reuseWorkers),void 0!==e.onDebug&&(this.onDebug=e.onDebug)}async startJob(e,t=((e,t,r)=>e.done(r)),r=((e,t)=>e.error(t))){const s=new Promise((s=>(this.jobQueue.push({name:e,onMessage:t,onError:r,onStart:s}),this)));return this._startQueuedJob(),await s}async _startQueuedJob(){if(!this.jobQueue.length)return;const e=this._getAvailableWorker();if(!e)return;const t=this.jobQueue.shift();if(t){this.onDebug({message:"Starting job",name:t.name,workerThread:e,backlog:this.jobQueue.length});const r=new Ce(t.name,e);e.onMessage=e=>t.onMessage(r,e.type,e.payload),e.onError=e=>t.onError(r,e),t.onStart(r);try{await r.result}finally{this.returnWorkerToQueue(e)}}}returnWorkerToQueue(e){this.isDestroyed||!this.reuseWorkers||this.count>this._getMaxConcurrency()?(e.destroy(),this.count--):this.idleQueue.push(e),this.isDestroyed||this._startQueuedJob()}_getAvailableWorker(){if(this.idleQueue.length>0)return this.idleQueue.shift()||null;if(this.count<this._getMaxConcurrency()){this.count++;const e=`${this.name.toLowerCase()} (#${this.count} of ${this.maxConcurrency})`;return new Fe({name:e,source:this.source,url:this.url})}return null}_getMaxConcurrency(){return Ie?this.maxMobileConcurrency:this.maxConcurrency}}const qe={maxConcurrency:3,maxMobileConcurrency:1,onDebug:()=>{},reuseWorkers:!0};class ze{static isSupported(){return Fe.isSupported()}static getWorkerFarm(e={}){return ze._workerFarm=ze._workerFarm||new ze({}),ze._workerFarm.setProps(e),ze._workerFarm}constructor(e){Le(this,"props",void 0),Le(this,"workerPools",new Map),this.props={...qe},this.setProps(e),this.workerPools=new Map}destroy(){for(const e of this.workerPools.values())e.destroy()}setProps(e){this.props={...this.props,...e};for(const e of this.workerPools.values())e.setProps(this._getWorkerPoolProps())}getWorkerPool(e){const{name:t,source:r,url:s}=e;let n=this.workerPools.get(t);return n||(n=new Ve({name:t,source:r,url:s}),n.setProps(this._getWorkerPoolProps()),this.workerPools.set(t,n)),n}_getWorkerPoolProps(){return{maxConcurrency:this.props.maxConcurrency,maxMobileConcurrency:this.props.maxMobileConcurrency,reuseWorkers:this.props.reuseWorkers,onDebug:this.props.onDebug}}}Le(ze,"_workerFarm",void 0);var Ge={};const He={};async function $e(e,t=null,r={}){return t&&(e=function(e,t,r){if(e.startsWith("http"))return e;const s=r.modules||{};if(s[e])return s[e];if(!Re)return`modules/${t}/dist/libs/${e}`;if(r.CDN)return Se(r.CDN.startsWith("http")),`${r.CDN}/${t}@3.0.10/dist/libs/${e}`;if(Oe)return`../src/libs/${e}`;return`modules/${t}/src/libs/${e}`}(e,t,r)),He[e]=He[e]||async function(e){if(e.endsWith("wasm")){const t=await fetch(e);return await t.arrayBuffer()}if(!Re)return Ge.requireFromFile&&await Ge.requireFromFile(e);if(Oe)return importScripts(e);const t=await fetch(e);return function(e,t){if(!Re)return Ge.requireFromString&&Ge.requireFromString(e,t);if(Oe)return eval.call(Me,e),null;const r=document.createElement("script");r.id=t;try{r.appendChild(document.createTextNode(e))}catch(t){r.text=e}return document.body.appendChild(r),null}(await t.text(),e)}(e),await He[e]}async function We(e,t,r,s,n){const i=e.id,o=function(e,t={}){const r=t[e.id]||{},s=`${e.id}-worker.js`;let n=r.workerUrl;if("test"===t._workerType&&(n=`modules/${e.module}/dist/${s}`),!n){let t=e.version;"latest"===t&&(t="latest");const r=t?`@${t}`:"";n=`https://unpkg.com/@loaders.gl/${e.module}${r}/dist/${s}`}return Se(n),n}(e,r),a=ze.getWorkerFarm(r).getWorkerPool({name:i,url:o});r=JSON.parse(JSON.stringify(r));const c=await a.startJob("process-on-worker",Ke.bind(null,n));c.postMessage("process",{input:t,options:r});const u=await c.result;return await u.result}async function Ke(e,t,r,s){switch(r){case"done":t.done(s);break;case"error":t.error(s.error);break;case"process":const{id:n,input:i,options:o}=s;try{const r=await e(i,o);t.postMessage("done",{id:n,result:r})}catch(e){const r=e instanceof Error?e.message:"unknown error";t.postMessage("error",{id:n,error:r})}break;default:console.warn(`parse-with-worker unknown message ${r}`)}}function Qe(e,t,r){if(e.byteLength<=t+r)return"";const s=new DataView(e);let n="";for(let e=0;e<r;e++)n+=String.fromCharCode(s.getUint8(t+e));return n}function Xe(e){try{return JSON.parse(e)}catch(t){throw new Error(`Failed to parse JSON from data starting with "${function(e,t=5){if("string"==typeof e)return e.slice(0,t);if(ArrayBuffer.isView(e))return Qe(e.buffer,e.byteOffset,t);if(e instanceof ArrayBuffer)return Qe(e,0,t);return""}(e)}"`)}}function Ye(e){if(Ge.toArrayBuffer&&(e=Ge.toArrayBuffer(e)),e instanceof ArrayBuffer)return e;if(ArrayBuffer.isView(e))return e.buffer;if("string"==typeof e){const t=e;return(new TextEncoder).encode(t).buffer}if(e&&"object"==typeof e&&e._toArrayBuffer)return e._toArrayBuffer();throw new Error("toArrayBuffer")}function Ze(e,t,r){const s=void 0!==r?new Uint8Array(e).subarray(t,t+r):new Uint8Array(e).subarray(t);return new Uint8Array(s).buffer}function Je(e,t){return Te(e>=0),Te(t>0),e+(t-1)&~(t-1)}function et(e,t,r){let s;if(e instanceof ArrayBuffer)s=new Uint8Array(e);else{const t=e.byteOffset,r=e.byteLength;s=new Uint8Array(e.buffer||e.arrayBuffer,t,r)}return t.set(s,r),r+Je(s.byteLength,4)}async function tt(e){const t=[];for await(const r of e)t.push(r);return function(...e){const t=e.map((e=>e instanceof ArrayBuffer?new Uint8Array(e):e)),r=t.reduce(((e,t)=>e+t.byteLength),0),s=new Uint8Array(r);let n=0;for(const e of t)s.set(e,n),n+=e.byteLength;return s.buffer}(...t)}function rt(){let e;if("undefined"!=typeof window&&window.performance)e=window.performance.now();else if("undefined"!=typeof process&&process.hrtime){const t=process.hrtime();e=1e3*t[0]+t[1]/1e6}else e=Date.now();return e}class st{constructor(e,t){this.name=e,this.type=t,this.sampleSize=1,this.reset()}setSampleSize(e){return this.sampleSize=e,this}incrementCount(){return this.addCount(1),this}decrementCount(){return this.subtractCount(1),this}addCount(e){return this._count+=e,this._samples++,this._checkSampling(),this}subtractCount(e){return this._count-=e,this._samples++,this._checkSampling(),this}addTime(e){return this._time+=e,this.lastTiming=e,this._samples++,this._checkSampling(),this}timeStart(){return this._startTime=rt(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(rt()-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 nt{constructor({id:e,stats:t}){this.id=e,this.stats={},this._initializeStats(t),Object.seal(this)}get(e,t="count"){return this._getOrCreate({name:e,type:t})}get size(){return Object.keys(this.stats).length}reset(){for(const e in this.stats)this.stats[e].reset();return this}forEach(e){for(const t in this.stats)e(this.stats[t])}getTable(){const e={};return this.forEach((t=>{e[t.name]={time:t.time||0,count:t.count||0,average:t.getAverageTime()||0,hz:t.getHz()||0}})),e}_initializeStats(e=[]){e.forEach((e=>this._getOrCreate(e)))}_getOrCreate(e){if(!e||!e.name)return null;const{name:t,type:r}=e;return this.stats[t]||(this.stats[t]=e instanceof st?e:new st(t,r)),this.stats[t]}}const it={id:"request-scheduler",throttleRequests:!0,maxRequests:6};class ot{constructor(e={}){Le(this,"props",void 0),Le(this,"stats",void 0),Le(this,"activeRequestCount",0),Le(this,"requestQueue",[]),Le(this,"requestMap",new Map),Le(this,"deferredUpdate",null),this.props={...it,...e},this.stats=new nt({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(e,t=(()=>0)){if(!this.props.throttleRequests)return Promise.resolve({done:()=>{}});if(this.requestMap.has(e))return this.requestMap.get(e);const r={handle:e,priority:0,getPriority:t},s=new Promise((e=>(r.resolve=e,r)));return this.requestQueue.push(r),this.requestMap.set(e,s),this._issueNewRequests(),s}_issueRequest(e){const{handle:t,resolve:r}=e;let s=!1;const n=()=>{s||(s=!0,this.requestMap.delete(t),this.activeRequestCount--,this._issueNewRequests())};return this.activeRequestCount++,r?r({done:n}):Promise.resolve({done:n})}_issueNewRequests(){this.deferredUpdate||(this.deferredUpdate=setTimeout((()=>this._issueNewRequestsAsync()),0))}_issueNewRequestsAsync(){this.deferredUpdate=null;const e=Math.max(this.props.maxRequests-this.activeRequestCount,0);if(0!==e){this._updateAllRequests();for(let t=0;t<e;++t){const e=this.requestQueue.shift();e&&this._issueRequest(e)}}}_updateAllRequests(){const e=this.requestQueue;for(let t=0;t<e.length;++t){const r=e[t];this._updateRequest(r)||(e.splice(t,1),this.requestMap.delete(r.handle),t--)}e.sort(((e,t)=>e.priority-t.priority))}_updateRequest(e){return e.priority=e.getPriority(e.handle),!(e.priority<0)||(e.resolve(null),!1)}}function at(e){const t=e&&e.lastIndexOf("/");return t>=0?e.substr(0,t):""}const ct={};const ut=e=>"function"==typeof e,ht=e=>null!==e&&"object"==typeof e,lt=e=>ht(e)&&e.constructor==={}.constructor,dt=e=>"undefined"!=typeof Response&&e instanceof Response||e&&e.arrayBuffer&&e.text&&e.json,ft=e=>"undefined"!=typeof Blob&&e instanceof Blob,pt=e=>(e=>"undefined"!=typeof ReadableStream&&e instanceof ReadableStream||ht(e)&&ut(e.tee)&&ut(e.cancel)&&ut(e.getReader))(e)||(e=>ht(e)&&ut(e.read)&&ut(e.pipe)&&(e=>"boolean"==typeof e)(e.readable))(e),mt=/^data:([-\w.]+\/[-\w.+]+)(;|,)/,gt=/^([-\w.]+\/[-\w.+]+)/;function yt(e){const t=gt.exec(e);return t?t[1]:e}function wt(e){const t=mt.exec(e);return t?t[1]:""}const bt=/\?.*/;function Tt(e){if(dt(e)){const t=vt(e.url||"");return{url:t,type:yt(e.headers.get("content-type")||"")||wt(t)}}return ft(e)?{url:vt(e.name||""),type:e.type||""}:"string"==typeof e?{url:vt(e),type:wt(e)}:{url:"",type:""}}function vt(e){return e.replace(bt,"")}async function _t(e){if(dt(e))return e;const t={},r=function(e){return dt(e)?e.headers["content-length"]||-1:ft(e)?e.size:"string"==typeof e?e.length:e instanceof ArrayBuffer||ArrayBuffer.isView(e)?e.byteLength:-1}(e);r>=0&&(t["content-length"]=String(r));const{url:s,type:n}=Tt(e);n&&(t["content-type"]=n);const i=await async function(e){const t=5;if("string"==typeof e)return`data:,${e.slice(0,t)}`;if(e instanceof Blob){const t=e.slice(0,5);return await new Promise((e=>{const r=new FileReader;r.onload=t=>{var r;return e(null==t||null===(r=t.target)||void 0===r?void 0:r.result)},r.readAsDataURL(t)}))}if(e instanceof ArrayBuffer){return`data:base64,${function(e){let t="";const r=new Uint8Array(e);for(let e=0;e<r.byteLength;e++)t+=String.fromCharCode(r[e]);return btoa(t)}(e.slice(0,t))}`}return null}(e);i&&(t["x-first-bytes"]=i),"string"==typeof e&&(e=(new TextEncoder).encode(e));const o=new Response(e,{headers:t});return Object.defineProperty(o,"url",{value:s}),o}async function Et(e,t){if("string"==typeof e){e=function(e){for(const t in ct)if(e.startsWith(t)){const r=ct[t];e=e.replace(t,r)}return e.startsWith("http://")||e.startsWith("https://")||(e=`${e}`),e}(e);let r=t;return null!=t&&t.fetch&&"function"!=typeof(null==t?void 0:t.fetch)&&(r=t.fetch),await fetch(e,r)}return await _t(e)}const xt={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},St=xt.window||xt.self||xt.global,At=xt.process||{},Mt="undefined"!=typeof __VERSION__?__VERSION__:"untranspiled source",Rt=!("object"==typeof process&&"[object process]"===String(process)&&!process.browser)||function(e){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 t="object"==typeof navigator&&"string"==typeof navigator.userAgent&&navigator.userAgent,r=e||t;return!!(r&&r.indexOf("Electron")>=0)}();class Ot{constructor(e,t,r="sessionStorage"){this.storage=function(e){try{const t=window[e],r="__storage_test__";return t.setItem(r,r),t.removeItem(r),t}catch(e){return null}}(r),this.id=e,this.config={},Object.assign(this.config,t),this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(e){return this.config={},this.updateConfiguration(e)}updateConfiguration(e){if(Object.assign(this.config,e),this.storage){const e=JSON.stringify(this.config);this.storage.setItem(this.id,e)}return this}_loadConfiguration(){let e={};if(this.storage){const t=this.storage.getItem(this.id);e=t?JSON.parse(t):{}}return Object.assign(this.config,e),this}}function It(e,t,r,s=600){const n=e.src.replace(/\(/g,"%28").replace(/\)/g,"%29");e.width>s&&(r=Math.min(r,s/e.width));const i=e.width*r,o=e.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(n,");"),"background-size:".concat(i,"px ").concat(o,"px;"),"color:transparent;"].join("");return["".concat(t," %c+"),a]}const Nt={BLACK:30,RED:31,GREEN:32,YELLOW:33,BLUE:34,MAGENTA:35,CYAN:36,WHITE:37,BRIGHT_BLACK:90,BRIGHT_RED:91,BRIGHT_GREEN:92,BRIGHT_YELLOW:93,BRIGHT_BLUE:94,BRIGHT_MAGENTA:95,BRIGHT_CYAN:96,BRIGHT_WHITE:97};function Lt(e){return"string"==typeof e?Nt[e.toUpperCase()]||Nt.WHITE:e}function Ct(e,t){if(!e)throw new Error(t||"Assertion failed")}function Pt(){let e;if(Rt&&St.performance)e=St.performance.now();else if(At.hrtime){const t=At.hrtime();e=1e3*t[0]+t[1]/1e6}else e=Date.now();return e}const Ut={debug:Rt&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},kt={enabled:!0,level:0};function Dt(){}const jt={},Bt={once:!0};function Ft(e){for(const t in e)for(const r in e[t])return r||"untitled";return"empty"}class Vt{constructor({id:e}={id:""}){this.id=e,this.VERSION=Mt,this._startTs=Pt(),this._deltaTs=Pt(),this.LOG_THROTTLE_TIMEOUT=0,this._storage=new Ot("__probe-".concat(this.id,"__"),kt),this.userData={},this.timeStamp("".concat(this.id," started")),function(e,t=["constructor"]){const r=Object.getPrototypeOf(e),s=Object.getOwnPropertyNames(r);for(const r of s)"function"==typeof e[r]&&(t.find((e=>r===e))||(e[r]=e[r].bind(e)))}(this),Object.seal(this)}set level(e){this.setLevel(e)}get level(){return this.getLevel()}isEnabled(){return this._storage.config.enabled}getLevel(){return this._storage.config.level}getTotal(){return Number((Pt()-this._startTs).toPrecision(10))}getDelta(){return Number((Pt()-this._deltaTs).toPrecision(10))}set priority(e){this.level=e}get priority(){return this.level}getPriority(){return this.level}enable(e=!0){return this._storage.updateConfiguration({enabled:e}),this}setLevel(e){return this._storage.updateConfiguration({level:e}),this}assert(e,t){Ct(e,t)}warn(e){return this._getLogFunction(0,e,Ut.warn,arguments,Bt)}error(e){return this._getLogFunction(0,e,Ut.error,arguments)}deprecated(e,t){return this.warn("`".concat(e,"` is deprecated and will be removed in a later version. Use `").concat(t,"` instead"))}removed(e,t){return this.error("`".concat(e,"` has been removed. Use `").concat(t,"` instead"))}probe(e,t){return this._getLogFunction(e,t,Ut.log,arguments,{time:!0,once:!0})}log(e,t){return this._getLogFunction(e,t,Ut.debug,arguments)}info(e,t){return this._getLogFunction(e,t,console.info,arguments)}once(e,t){return this._getLogFunction(e,t,Ut.debug||Ut.info,arguments,Bt)}table(e,t,r){return t?this._getLogFunction(e,t,console.table||Dt,r&&[r],{tag:Ft(t)}):Dt}image({logLevel:e,priority:t,image:r,message:s="",scale:n=1}){return this._shouldLog(e||t)?Rt?function({image:e,message:t="",scale:r=1}){if("string"==typeof e){const s=new Image;return s.onload=()=>{const e=It(s,t,r);console.log(...e)},s.src=e,Dt}const s=e.nodeName||"";if("img"===s.toLowerCase())return console.log(...It(e,t,r)),Dt;if("canvas"===s.toLowerCase()){const s=new Image;return s.onload=()=>console.log(...It(s,t,r)),s.src=e.toDataURL(),Dt}return Dt}({image:r,message:s,scale:n}):function({image:e,message:t="",scale:r=1}){let s=null;try{s=module.require("asciify-image")}catch(e){}if(s)return()=>s(e,{fit:"box",width:"".concat(Math.round(80*r),"%")}).then((e=>console.log(e)));return Dt}({image:r,message:s,scale:n}):Dt}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}get(e){return this._storage.config[e]}set(e,t){this._storage.updateConfiguration({[e]:t})}time(e,t){return this._getLogFunction(e,t,console.time?console.time:console.info)}timeEnd(e,t){return this._getLogFunction(e,t,console.timeEnd?console.timeEnd:console.info)}timeStamp(e,t){return this._getLogFunction(e,t,console.timeStamp||Dt)}group(e,t,r={collapsed:!1}){r=zt({logLevel:e,message:t,opts:r});const{collapsed:s}=r;return r.method=(s?console.groupCollapsed:console.group)||console.info,this._getLogFunction(r)}groupCollapsed(e,t,r={}){return this.group(e,t,Object.assign({},r,{collapsed:!0}))}groupEnd(e){return this._getLogFunction(e,"",console.groupEnd||Dt)}withGroup(e,t,r){this.group(e,t)();try{r()}finally{this.groupEnd(e)()}}trace(){console.trace&&console.trace()}_shouldLog(e){return this.isEnabled()&&this.getLevel()>=qt(e)}_getLogFunction(e,t,r,s=[],n){if(this._shouldLog(e)){n=zt({logLevel:e,message:t,args:s,opts:n}),Ct(r=r||n.method),n.total=this.getTotal(),n.delta=this.getDelta(),this._deltaTs=Pt();const i=n.tag||n.message;if(n.once){if(jt[i])return Dt;jt[i]=Pt()}return t=function(e,t,r){if("string"==typeof t){const o=r.time?function(e,t=8){const r=Math.max(t-e.length,0);return"".concat(" ".repeat(r)).concat(e)}(function(e){let t;return t=e<10?"".concat(e.toFixed(2),"ms"):e<100?"".concat(e.toFixed(1),"ms"):e<1e3?"".concat(e.toFixed(0),"ms"):"".concat((e/1e3).toFixed(2),"s"),t}(r.total)):"";t=r.time?"".concat(e,": ").concat(o,"  ").concat(t):"".concat(e,": ").concat(t),s=t,n=r.color,i=r.background,Rt||"string"!=typeof s||(n&&(n=Lt(n),s="[".concat(n,"m").concat(s,"[39m")),i&&(n=Lt(i),s="[".concat(i+10,"m").concat(s,"[49m"))),t=s}var s,n,i;return t}(this.id,n.message,n),r.bind(console,t,...n.args)}return Dt}}function qt(e){if(!e)return 0;let t;switch(typeof e){case"number":t=e;break;case"object":t=e.logLevel||e.priority||0;break;default:return 0}return Ct(Number.isFinite(t)&&t>=0),t}function zt(e){const{logLevel:t,message:r}=e;e.logLevel=qt(t);const s=e.args?Array.from(e.args):[];for(;s.length&&s.shift()!==r;);switch(e.args=s,typeof t){case"string":case"function":void 0!==r&&s.unshift(r),e.message=t;break;case"object":Object.assign(e,t)}"function"==typeof e.message&&(e.message=e.message());const n=typeof e.message;return Ct("string"===n||"object"===n),Object.assign(e,e.opts)}Vt.VERSION=Mt;const Gt=new Vt({id:"loaders.gl"});class Ht{log(){return()=>{}}info(){return()=>{}}warn(){return()=>{}}error(){return()=>{}}}const $t={fetch:null,mimeType:void 0,nothrow:!1,log:new class{constructor(){Le(this,"console",void 0),this.console=console}log(...e){return this.console.log.bind(this.console,...e)}info(...e){return this.console.info.bind(this.console,...e)}warn(...e){return this.console.warn.bind(this.console,...e)}error(...e){return this.console.error.bind(this.console,...e)}},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:[]},Wt={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 Kt(){_e.loaders=_e.loaders||{};const{loaders:e}=_e;return e._state=e._state||{},e._state}const Qt=()=>{const e=Kt();return e.globalOptions=e.globalOptions||{...$t},e.globalOptions};function Xt(e,t,r,s){return r=r||[],function(e,t){Zt(e,null,$t,Wt,t);for(const r of t){const s=e&&e[r.id]||{},n=r.options&&r.options[r.id]||{},i=r.deprecatedOptions&&r.deprecatedOptions[r.id]||{};Zt(s,r.id,n,i,t)}}(e,r=Array.isArray(r)?r:[r]),function(e,t,r){const s={...e.options||{}};(function(e,t){t&&!("baseUri"in e)&&(e.baseUri=t)})(s,r),null===s.log&&(s.log=new Ht);return er(s,Qt()),er(s,t),s}(t,e,s)}function Yt(e,t){const r=Qt(),s=e||r;return"function"==typeof s.fetch?s.fetch:ht(s.fetch)?e=>Et(e,s):null!=t&&t.fetch?null==t?void 0:t.fetch:Et}function Zt(e,t,r,s,n){const i=t||"Top level",o=t?`${t}.`:"";for(const a in e){const c=!t&&ht(e[a]),u="baseUri"===a&&!t,h="workerUrl"===a&&t;if(!(a in r)&&!u&&!h)if(a in s)Gt.warn(`${i} loader option '${o}${a}' no longer supported, use '${s[a]}'`)();else if(!c){const e=Jt(a,n);Gt.warn(`${i} loader option '${o}${a}' not recognized. ${e}`)()}}}function Jt(e,t){const r=e.toLowerCase();let s="";for(const n of t)for(const t in n.options){if(e===t)return`Did you mean '${n.id}.${t}'?`;const i=t.toLowerCase();(r.startsWith(i)||i.startsWith(r))&&(s=s||`Did you mean '${n.id}.${t}'?`)}return s}function er(e,t){for(const r in t)if(r in t){const s=t[r];lt(s)&&lt(e[r])?e[r]={...e[r],...t[r]}:e[r]=t[r]}}function tr(e){var t;if(!e)return!1;Array.isArray(e)&&(e=e[0]);return Array.isArray(null===(t=e)||void 0===t?void 0:t.extensions)}function rr(e){var t,r;let s;return Te(e,"null loader"),Te(tr(e),"invalid loader"),Array.isArray(e)&&(s=e[1],e=e[0],e={...e,options:{...e.options,...s}}),(null!==(t=e)&&void 0!==t&&t.parseTextSync||null!==(r=e)&&void 0!==r&&r.parseText)&&(e.text=!0),e.text||(e.binary=!0),e}function sr(){return(()=>{const e=Kt();return e.loaderRegistry=e.loaderRegistry||[],e.loaderRegistry})()}const nr=/\.([^.]+)$/;function ir(e,t=[],r,s){if(!or(e))return null;if(t&&!Array.isArray(t))return rr(t);let n=[];t&&(n=n.concat(t)),null!=r&&r.ignoreRegisteredLoaders||n.push(...sr()),function(e){for(const t of e)rr(t)}(n);const i=function(e,t,r,s){const{url:n,type:i}=Tt(e),o=n||(null==s?void 0:s.url);let a=null;null!=r&&r.mimeType&&(a=cr(t,null==r?void 0:r.mimeType));return a=a||function(e,t){const r=t&&nr.exec(t),s=r&&r[1];return s?function(e,t){t=t.toLowerCase();for(const r of e)for(const e of r.extensions)if(e.toLowerCase()===t)return r;return null}(e,s):null}(t,o),a=a||cr(t,i),a=a||function(e,t){if(!t)return null;for(const r of e)if("string"==typeof t){if(ur(t,r))return r}else if(ArrayBuffer.isView(t)){if(hr(t.buffer,t.byteOffset,r))return r}else if(t instanceof ArrayBuffer){if(hr(t,0,r))return r}return null}(t,e),a=a||cr(t,null==r?void 0:r.fallbackMimeType),a}(e,n,r,s);if(!(i||null!=r&&r.nothrow))throw new Error(ar(e));return i}function or(e){return!(e instanceof Response&&204===e.status)}function ar(e){const{url:t,type:r}=Tt(e);let s="No valid loader found";return e&&(s+=` data: "${function(e,t=5){if("string"==typeof e)return e.slice(0,t);if(ArrayBuffer.isView(e))return lr(e.buffer,e.byteOffset,t);if(e instanceof ArrayBuffer){return lr(e,0,t)}return""}(e)}", contentType: "${r}"`),t&&(s+=` url: ${t}`),s}function cr(e,t){for(const r of e){if(r.mimeTypes&&r.mimeTypes.includes(t))return r;if(t===`application/x.${r.id}`)return r}return null}function ur(e,t){if(t.testText)return t.testText(e);return(Array.isArray(t.tests)?t.tests:[t.tests]).some((t=>e.startsWith(t)))}function hr(e,t,r){return(Array.isArray(r.tests)?r.tests:[r.tests]).some((s=>function(e,t,r,s){if(s instanceof ArrayBuffer)return function(e,t,r){if(r=r||e.byteLength,e.byteLength<r||t.byteLength<r)return!1;const s=new Uint8Array(e),n=new Uint8Array(t);for(let e=0;e<s.length;++e)if(s[e]!==n[e])return!1;return!0}(s,e,s.byteLength);switch(typeof s){case"function":return s(e,r);case"string":return s===lr(e,t,s.length);default:return!1}}(e,t,r,s)))}function lr(e,t,r){if(e.byteLength<t+r)return"";const s=new DataView(e);let n="";for(let e=0;e<r;e++)n+=String.fromCharCode(s.getUint8(t+e));return n}const dr=262144;function fr(e,t){return Ee?async function*(e,t){const r=e.getReader();let s;try{for(;;){const e=s||r.read();null!=t&&t._streamReadAhead&&(s=r.read());const{done:n,value:i}=await e;if(n)return;yield Ye(i)}}catch(e){r.releaseLock()}}(e,t):async function*(e,t){for await(const t of e)yield Ye(t)}(e)}function pr(e,t){if("string"==typeof e)return function*(e,t){const r=(null==t?void 0:t.chunkSize)||262144;let s=0;const n=new TextEncoder;for(;s<e.length;){const t=Math.min(e.length-s,r),i=e.slice(s,s+t);s+=t,yield n.encode(i)}}(e,t);if(e instanceof ArrayBuffer)return function*(e,t={}){const{chunkSize:r=dr}=t;let s=0;for(;s<e.byteLength;){const t=Math.min(e.byteLength-s,r),n=new ArrayBuffer(t),i=new Uint8Array(e,s,t);new Uint8Array(n).set(i),s+=t,yield n}}(e,t);if(ft(e))return async function*(e,t){const r=(null==t?void 0:t.chunkSize)||1048576;let s=0;for(;s<e.size;){const t=s+r,n=await e.slice(s,t).arrayBuffer();s=t,yield n}}(e,t);if(pt(e))return fr(e,t);if(dt(e)){return fr(e.body,t)}throw new Error("makeIterator")}const mr="Cannot convert supplied data type";async function gr(e,t,r){const s=e instanceof ArrayBuffer||ArrayBuffer.isView(e);if("string"==typeof e||s)return function(e,t,r){if(t.text&&"string"==typeof e)return e;var s;if((s=e)&&"object"==typeof s&&s.isBuffer&&(e=e.buffer),e instanceof ArrayBuffer){const r=e;return t.text&&!t.binary?new TextDecoder("utf8").decode(r):r}if(ArrayBuffer.isView(e)){if(t.text&&!t.binary)return new TextDecoder("utf8").decode(e);let r=e.buffer;const s=e.byteLength||e.length;return 0===e.byteOffset&&s===r.byteLength||(r=r.slice(e.byteOffset,e.byteOffset+s)),r}throw new Error(mr)}(e,t);if(ft(e)&&(e=await _t(e)),dt(e)){const r=e;return await async function(e){if(!e.ok){const t=await async function(e){let t=`Failed to fetch resource ${e.url} (${e.status}): `;try{const r=e.headers.get("Content-Type");let s=e.statusText;r.includes("application/json")&&(s+=` ${await e.text()}`),t+=s,t=t.length>60?`${t.slice(60)}...`:t}catch(e){}return t}(e);throw new Error(t)}}(r),t.binary?await r.arrayBuffer():await r.text()}if(pt(e)&&(e=pr(e,r)),(n=e)&&"function"==typeof n[Symbol.iterator]||(e=>e&&"function"==typeof e[Symbol.asyncIterator])(e))return tt(e);var n;throw new Error(mr)}async function yr(e,t,r,s){Se(!s||"object"==typeof s),!t||Array.isArray(t)||tr(t)||(s=void 0,r=t,t=void 0),e=await e,r=r||{};const{url:n}=Tt(e),i=function(e,t){if(!t&&e&&!Array.isArray(e))return e;let r;if(e&&(r=Array.isArray(e)?e:[e]),t&&t.loaders){const e=Array.isArray(t.loaders)?t.loaders:[t.loaders];r=r?[...r,...e]:e}return r&&r.length?r:null}(t,s),o=await async function(e,t=[],r,s){if(!or(e))return null;let n=ir(e,t,{...r,nothrow:!0},s);if(n)return n;if(ft(e)&&(n=ir(e=await e.slice(0,10).arrayBuffer(),t,r,s)),!(n||null!=r&&r.nothrow))throw new Error(ar(e));return n}(e,i,r);return o?(s=function(e,t,r=null){if(r)return r;const s={fetch:Yt(t,e),...e};return Array.isArray(s.loaders)||(s.loaders=null),s}({url:n,parse:yr,loaders:i},r=Xt(r,o,i,n),s),await async function(e,t,r,s){if(function(e,t="3.0.10"){Se(e,"no worker provided");const r=e.version}(e),t=await gr(t,e,r),e.parseTextSync&&"string"==typeof t)return r.dataType="text",e.parseTextSync(t,r,s,e);if(function(e,t){return!!ze.isSupported()&&e.worker&&(null==t?void 0:t.worker)}(e,r))return await We(e,t,r,0,yr);if(e.parseText&&"string"==typeof t)return await e.parseText(t,r,s,e);if(e.parse)return await e.parse(t,r,s,e);throw Se(!e.parseSync),new Error(`${e.id} loader - no parser found and worker is disabled`)}(o,e,r,s)):null}async function wr(e,t,r,s){Array.isArray(t)||tr(t)||(r=t,t=void 0);const n=Yt(r);let i=e;return"string"==typeof e&&(i=await n(e)),ft(e)&&(i=await n(e)),await yr(i,t,r)}function br(e,t){if(!e)throw new Error("math.gl assertion ".concat(t))}const Tr=1/Math.PI*180,vr=1/180*Math.PI,_r={};function Er(e,{precision:t=_r.precision||4}={}){return e=function(e){return Math.round(e/_r.EPSILON)*_r.EPSILON}(e),"".concat(parseFloat(e.toPrecision(t)))}function xr(e){return Array.isArray(e)||ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Sr(e,t,r){if(xr(e)){r=r||((s=e).clone?s.clone():new Array(s.length));for(let s=0;s<r.length&&s<e.length;++s)r[s]=t(e[s],s,r);return r}var s;return t(e)}function Ar(e){return function(e,t){return Sr(e,(e=>e*vr),t)}(e)}function Mr(e,t){return Sr(e,(e=>e*Tr),t)}function Rr(e,t,r){const s=_r.EPSILON;r&&(_r.EPSILON=r);try{if(e===t)return!0;if(xr(e)&&xr(t)){if(e.length!==t.length)return!1;for(let r=0;r<e.length;++r)if(!Rr(e[r],t[r]))return!1;return!0}return e&&e.equals?e.equals(t):t&&t.equals?t.equals(e):!(!Number.isFinite(e)||!Number.isFinite(t))&&Math.abs(e-t)<=_r.EPSILON*Math.max(1,Math.abs(e),Math.abs(t))}finally{_r.EPSILON=s}}_r.EPSILON=1e-12,_r.debug=!1,_r.precision=4,_r.printTypes=!1,_r.printDegrees=!1,_r.printRowMajor=!0;class Or extends(function(e){function t(){var t=Reflect.construct(e,Array.from(arguments));return Object.setPrototypeOf(t,Object.getPrototypeOf(this)),t}return t.prototype=Object.create(e.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e,t}(Array)){get ELEMENTS(){return br(!1),0}clone(){return(new this.constructor).copy(this)}from(e){return Array.isArray(e)?this.copy(e):this.fromObject(e)}fromArray(e,t=0){for(let r=0;r<this.ELEMENTS;++r)this[r]=e[r+t];return this.check()}to(e){return e===this?this:xr(e)?this.toArray(e):this.toObject(e)}toTarget(e){return e?this.to(e):this}toArray(e=[],t=0){for(let r=0;r<this.ELEMENTS;++r)e[t+r]=this[r];return e}toFloat32Array(){return new Float32Array(this)}toString(){return this.formatString(_r)}formatString(e){let t="";for(let r=0;r<this.ELEMENTS;++r)t+=(r>0?", ":"")+Er(this[r],e);return"".concat(e.printTypes?this.constructor.name:"","[").concat(t,"]")}equals(e){if(!e||this.length!==e.length)return!1;for(let t=0;t<this.ELEMENTS;++t)if(!Rr(this[t],e[t]))return!1;return!0}exactEquals(e){if(!e||this.length!==e.length)return!1;for(let t=0;t<this.ELEMENTS;++t)if(this[t]!==e[t])return!1;return!0}negate(){for(let e=0;e<this.ELEMENTS;++e)this[e]=-this[e];return this.check()}lerp(e,t,r){void 0===r&&(r=t,t=e,e=this);for(let s=0;s<this.ELEMENTS;++s){const n=e[s];this[s]=n+r*(t[s]-n)}return this.check()}min(e){for(let t=0;t<this.ELEMENTS;++t)this[t]=Math.min(e[t],this[t]);return this.check()}max(e){for(let t=0;t<this.ELEMENTS;++t)this[t]=Math.max(e[t],this[t]);return this.check()}clamp(e,t){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(Math.max(this[r],e[r]),t[r]);return this.check()}add(...e){for(const t of e)for(let e=0;e<this.ELEMENTS;++e)this[e]+=t[e];return this.check()}subtract(...e){for(const t of e)for(let e=0;e<this.ELEMENTS;++e)this[e]-=t[e];return this.check()}scale(e){if(Array.isArray(e))return this.multiply(e);for(let t=0;t<this.ELEMENTS;++t)this[t]*=e;return this.check()}sub(e){return this.subtract(e)}setScalar(e){for(let t=0;t<this.ELEMENTS;++t)this[t]=e;return this.check()}addScalar(e){for(let t=0;t<this.ELEMENTS;++t)this[t]+=e;return this.check()}subScalar(e){return this.addScalar(-e)}multiplyScalar(e){for(let t=0;t<this.ELEMENTS;++t)this[t]*=e;return this.check()}divideScalar(e){return this.scale(1/e)}clampScalar(e,t){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(Math.max(this[r],e),t);return this.check()}multiplyByScalar(e){return this.scale(e)}get elements(){return this}check(){if(_r.debug&&!this.validate())throw new Error("math.gl: ".concat(this.constructor.name," some fields set to invalid numbers'"));return this}validate(){let e=this.length===this.ELEMENTS;for(let t=0;t<this.ELEMENTS;++t)e=e&&Number.isFinite(this[t]);return e}}function Ir(e){if(!Number.isFinite(e))throw new Error("Invalid number ".concat(e));return e}function Nr(e,t,r=""){if(_r.debug&&!function(e,t){if(e.length!==t)return!1;for(let t=0;t<e.length;++t)if(!Number.isFinite(e[t]))return!1;return!0}(e,t))throw new Error("math.gl: ".concat(r," some fields set to invalid numbers'"));return e}const Lr={};function Cr(e,t){Lr[e]||(Lr[e]=!0,console.warn("".concat(e," has been removed in version ").concat(t,", see upgrade guide for more information")))}class Pr extends Or{get ELEMENTS(){return br(!1),0}copy(e){return br(!1),this}get x(){return this[0]}set x(e){this[0]=Ir(e)}get y(){return this[1]}set y(e){this[1]=Ir(e)}len(){return Math.sqrt(this.lengthSquared())}magnitude(){return this.len()}lengthSquared(){let e=0;for(let t=0;t<this.ELEMENTS;++t)e+=this[t]*this[t];return e}magnitudeSquared(){return this.lengthSquared()}distance(e){return Math.sqrt(this.distanceSquared(e))}distanceSquared(e){let t=0;for(let r=0;r<this.ELEMENTS;++r){const s=this[r]-e[r];t+=s*s}return Ir(t)}dot(e){let t=0;for(let r=0;r<this.ELEMENTS;++r)t+=this[r]*e[r];return Ir(t)}normalize(){const e=this.magnitude();if(0!==e)for(let t=0;t<this.ELEMENTS;++t)this[t]/=e;return this.check()}multiply(...e){for(const t of e)for(let e=0;e<this.ELEMENTS;++e)this[e]*=t[e];return this.check()}divide(...e){for(const t of e)for(let e=0;e<this.ELEMENTS;++e)this[e]/=t[e];return this.check()}lengthSq(){return this.lengthSquared()}distanceTo(e){return this.distance(e)}distanceToSquared(e){return this.distanceSquared(e)}getComponent(e){return br(e>=0&&e<this.ELEMENTS,"index is out of range"),Ir(this[e])}setComponent(e,t){return br(e>=0&&e<this.ELEMENTS,"index is out of range"),this[e]=t,this.check()}addVectors(e,t){return this.copy(e).add(t)}subVectors(e,t){return this.copy(e).subtract(t)}multiplyVectors(e,t){return this.copy(e).multiply(t)}addScaledVector(e,t){return this.add(new this.constructor(e).multiplyScalar(t))}}var Ur,kr="undefined"!=typeof Float32Array?Float32Array:Array;function Dr(e,t,r){var s=t[0],n=t[1];return e[0]=r[0]*s+r[3]*n+r[6],e[1]=r[1]*s+r[4]*n+r[7],e}function jr(e,t,r){var s=t[0],n=t[1];return e[0]=r[0]*s+r[4]*n+r[12],e[1]=r[1]*s+r[5]*n+r[13],e}function Br(e,t,r){const s=t[0],n=t[1],i=r[3]*s+r[7]*n||1;return e[0]=(r[0]*s+r[4]*n)/i,e[1]=(r[1]*s+r[5]*n)/i,e}function Fr(e,t,r){const s=t[0],n=t[1],i=t[2],o=r[3]*s+r[7]*n+r[11]*i||1;return e[0]=(r[0]*s+r[4]*n+r[8]*i)/o,e[1]=(r[1]*s+r[5]*n+r[9]*i)/o,e[2]=(r[2]*s+r[6]*n+r[10]*i)/o,e}Math.hypot||(Math.hypot=function(){for(var e=0,t=arguments.length;t--;)e+=arguments[t]*arguments[t];return Math.sqrt(e)}),Ur=new kr(2),kr!=Float32Array&&(Ur[0]=0,Ur[1]=0);class Vr extends Pr{constructor(e=0,t=0){super(2),xr(e)&&1===arguments.length?this.copy(e):(_r.debug&&(Ir(e),Ir(t)),this[0]=e,this[1]=t)}set(e,t){return this[0]=e,this[1]=t,this.check()}copy(e){return this[0]=e[0],this[1]=e[1],this.check()}fromObject(e){return _r.debug&&(Ir(e.x),Ir(e.y)),this[0]=e.x,this[1]=e.y,this.check()}toObject(e){return e.x=this[0],e.y=this[1],e}get ELEMENTS(){return 2}horizontalAngle(){return Math.atan2(this.y,this.x)}verticalAngle(){return Math.atan2(this.x,this.y)}transform(e){return this.transformAsPoint(e)}transformAsPoint(e){return jr(this,this,e),this.check()}transformAsVector(e){return Br(this,this,e),this.check()}transformByMatrix3(e){return Dr(this,this,e),this.check()}transformByMatrix2x3(e){return function(e,t,r){var s=t[0],n=t[1];e[0]=r[0]*s+r[2]*n+r[4],e[1]=r[1]*s+r[3]*n+r[5]}(this,this,e),this.check()}transformByMatrix2(e){return function(e,t,r){var s=t[0],n=t[1];e[0]=r[0]*s+r[2]*n,e[1]=r[1]*s+r[3]*n}(this,this,e),this.check()}}function qr(){var e=new kr(3);return kr!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function zr(e){var t=e[0],r=e[1],s=e[2];return Math.hypot(t,r,s)}function Gr(e,t,r){var s=new kr(3);return s[0]=e,s[1]=t,s[2]=r,s}function Hr(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function $r(e,t,r){var s=t[0],n=t[1],i=t[2],o=r[0],a=r[1],c=r[2];return e[0]=n*c-i*a,e[1]=i*o-s*c,e[2]=s*a-n*o,e}function Wr(e,t,r){var s=t[0],n=t[1],i=t[2],o=r[3]*s+r[7]*n+r[11]*i+r[15];return o=o||1,e[0]=(r[0]*s+r[4]*n+r[8]*i+r[12])/o,e[1]=(r[1]*s+r[5]*n+r[9]*i+r[13])/o,e[2]=(r[2]*s+r[6]*n+r[10]*i+r[14])/o,e}function Kr(e,t,r){var s=t[0],n=t[1],i=t[2];return e[0]=s*r[0]+n*r[3]+i*r[6],e[1]=s*r[1]+n*r[4]+i*r[7],e[2]=s*r[2]+n*r[5]+i*r[8],e}function Qr(e,t,r){var s=r[0],n=r[1],i=r[2],o=r[3],a=t[0],c=t[1],u=t[2],h=n*u-i*c,l=i*a-s*u,d=s*c-n*a,f=n*d-i*l,p=i*h-s*d,m=s*l-n*h,g=2*o;return h*=g,l*=g,d*=g,f*=2,p*=2,m*=2,e[0]=a+h+f,e[1]=c+l+p,e[2]=u+d+m,e}function Xr(e,t,r,s){var n=[],i=[];return n[0]=t[0]-r[0],n[1]=t[1]-r[1],n[2]=t[2]-r[2],i[0]=n[0],i[1]=n[1]*Math.cos(s)-n[2]*Math.sin(s),i[2]=n[1]*Math.sin(s)+n[2]*Math.cos(s),e[0]=i[0]+r[0],e[1]=i[1]+r[1],e[2]=i[2]+r[2],e}function Yr(e,t,r,s){var n=[],i=[];return n[0]=t[0]-r[0],n[1]=t[1]-r[1],n[2]=t[2]-r[2],i[0]=n[2]*Math.sin(s)+n[0]*Math.cos(s),i[1]=n[1],i[2]=n[2]*Math.cos(s)-n[0]*Math.sin(s),e[0]=i[0]+r[0],e[1]=i[1]+r[1],e[2]=i[2]+r[2],e}function Zr(e,t,r,s){var n=[],i=[];return n[0]=t[0]-r[0],n[1]=t[1]-r[1],n[2]=t[2]-r[2],i[0]=n[0]*Math.cos(s)-n[1]*Math.sin(s),i[1]=n[0]*Math.sin(s)+n[1]*Math.cos(s),i[2]=n[2],e[0]=i[0]+r[0],e[1]=i[1]+r[1],e[2]=i[2]+r[2],e}function Jr(e,t){var r=e[0],s=e[1],n=e[2],i=t[0],o=t[1],a=t[2],c=Math.sqrt(r*r+s*s+n*n)*Math.sqrt(i*i+o*o+a*a),u=c&&Hr(e,t)/c;return Math.acos(Math.min(Math.max(u,-1),1))}var es=zr;!function(){var e=qr()}();const ts=[0,0,0],rs={};class ss extends Pr{static get ZERO(){return rs.ZERO=rs.ZERO||Object.freeze(new ss(0,0,0,0))}constructor(e=0,t=0,r=0){super(-0,-0,-0),1===arguments.length&&xr(e)?this.copy(e):(_r.debug&&(Ir(e),Ir(t),Ir(r)),this[0]=e,this[1]=t,this[2]=r)}set(e,t,r){return this[0]=e,this[1]=t,this[2]=r,this.check()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this.check()}fromObject(e){return _r.debug&&(Ir(e.x),Ir(e.y),Ir(e.z)),this[0]=e.x,this[1]=e.y,this[2]=e.z,this.check()}toObject(e){return e.x=this[0],e.y=this[1],e.z=this[2],e}get ELEMENTS(){return 3}get z(){return this[2]}set z(e){this[2]=Ir(e)}angle(e){return Jr(this,e)}cross(e){return $r(this,this,e),this.check()}rotateX({radians:e,origin:t=ts}){return Xr(this,this,t,e),this.check()}rotateY({radians:e,origin:t=ts}){return Yr(this,this,t,e),this.check()}rotateZ({radians:e,origin:t=ts}){return Zr(this,this,t,e),this.check()}transform(e){return this.transformAsPoint(e)}transformAsPoint(e){return Wr(this,this,e),this.check()}transformAsVector(e){return Fr(this,this,e),this.check()}transformByMatrix3(e){return Kr(this,this,e),this.check()}transformByMatrix2(e){return function(e,t,r){const s=t[0],n=t[1];e[0]=r[0]*s+r[2]*n,e[1]=r[1]*s+r[3]*n,e[2]=t[2]}(this,this,e),this.check()}transformByQuaternion(e){return Qr(this,this,e),this.check()}}class ns extends Or{get ELEMENTS(){return br(!1),0}get RANK(){return br(!1),0}toString(){let e="[";if(_r.printRowMajor){e+="row-major:";for(let t=0;t<this.RANK;++t)for(let r=0;r<this.RANK;++r)e+=" ".concat(this[r*this.RANK+t])}else{e+="column-major:";for(let t=0;t<this.ELEMENTS;++t)e+=" ".concat(this[t])}return e+="]",e}getElementIndex(e,t){return t*this.RANK+e}getElement(e,t){return this[t*this.RANK+e]}setElement(e,t,r){return this[t*this.RANK+e]=Ir(r),this}getColumn(e,t=new Array(this.RANK).fill(-0)){const r=e*this.RANK;for(let e=0;e<this.RANK;++e)t[e]=this[r+e];return t}setColumn(e,t){const r=e*this.RANK;for(let e=0;e<this.RANK;++e)this[r+e]=t[e];return this}}function is(e,t,r){var s=t[0],n=t[1],i=t[2],o=t[3],a=t[4],c=t[5],u=t[6],h=t[7],l=t[8],d=r[0],f=r[1],p=r[2],m=r[3],g=r[4],y=r[5],w=r[6],b=r[7],T=r[8];return e[0]=d*s+f*o+p*u,e[1]=d*n+f*a+p*h,e[2]=d*i+f*c+p*l,e[3]=m*s+g*o+y*u,e[4]=m*n+g*a+y*h,e[5]=m*i+g*c+y*l,e[6]=w*s+b*o+T*u,e[7]=w*n+b*a+T*h,e[8]=w*i+b*c+T*l,e}function os(e,t,r){var s=r[0],n=r[1];return e[0]=s*t[0],e[1]=s*t[1],e[2]=s*t[2],e[3]=n*t[3],e[4]=n*t[4],e[5]=n*t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e}const as=Object.freeze([1,0,0,0,1,0,0,0,1]),cs=Object.freeze([0,0,0,0,0,0,0,0,0]),us=Object.freeze({COL0ROW0:0,COL0ROW1:1,COL0ROW2:2,COL1ROW0:3,COL1ROW1:4,COL1ROW2:5,COL2ROW0:6,COL2ROW1:7,COL2ROW2:8}),hs={};class ls extends ns{static get IDENTITY(){return hs.IDENTITY=hs.IDENTITY||Object.freeze(new ls(as)),hs.IDENTITY}static get ZERO(){return hs.ZERO=hs.ZERO||Object.freeze(new ls(cs)),hs.ZERO}get ELEMENTS(){return 9}get RANK(){return 3}get INDICES(){return us}constructor(e){super(-0,-0,-0,-0,-0,-0,-0,-0,-0),1===arguments.length&&Array.isArray(e)?this.copy(e):this.identity()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this[4]=e[4],this[5]=e[5],this[6]=e[6],this[7]=e[7],this[8]=e[8],this.check()}set(e,t,r,s,n,i,o,a,c){return this[0]=e,this[1]=t,this[2]=r,this[3]=s,this[4]=n,this[5]=i,this[6]=o,this[7]=a,this[8]=c,this.check()}setRowMajor(e,t,r,s,n,i,o,a,c){return this[0]=e,this[1]=s,this[2]=o,this[3]=t,this[4]=n,this[5]=a,this[6]=r,this[7]=i,this[8]=c,this.check()}determinant(){return t=(e=this)[0],r=e[1],s=e[2],n=e[3],i=e[4],o=e[5],a=e[6],c=e[7],u=e[8],t*(u*i-o*c)+r*(-u*n+o*a)+s*(c*n-i*a);var e,t,r,s,n,i,o,a,c,u}identity(){return this.copy(as)}fromQuaternion(e){return function(e,t){var r=t[0],s=t[1],n=t[2],i=t[3],o=r+r,a=s+s,c=n+n,u=r*o,h=s*o,l=s*a,d=n*o,f=n*a,p=n*c,m=i*o,g=i*a,y=i*c;e[0]=1-l-p,e[3]=h-y,e[6]=d+g,e[1]=h+y,e[4]=1-u-p,e[7]=f-m,e[2]=d-g,e[5]=f+m,e[8]=1-u-l}(this,e),this.check()}transpose(){return function(e,t){if(e===t){var r=t[1],s=t[2],n=t[5];e[1]=t[3],e[2]=t[6],e[3]=r,e[5]=t[7],e[6]=s,e[7]=n}else e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8]}(this,this),this.check()}invert(){return function(e,t){var r=t[0],s=t[1],n=t[2],i=t[3],o=t[4],a=t[5],c=t[6],u=t[7],h=t[8],l=h*o-a*u,d=-h*i+a*c,f=u*i-o*c,p=r*l+s*d+n*f;p&&(p=1/p,e[0]=l*p,e[1]=(-h*s+n*u)*p,e[2]=(a*s-n*o)*p,e[3]=d*p,e[4]=(h*r-n*c)*p,e[5]=(-a*r+n*i)*p,e[6]=f*p,e[7]=(-u*r+s*c)*p,e[8]=(o*r-s*i)*p)}(this,this),this.check()}multiplyLeft(e){return is(this,e,this),this.check()}multiplyRight(e){return is(this,this,e),this.check()}rotate(e){return function(e,t,r){var s=t[0],n=t[1],i=t[2],o=t[3],a=t[4],c=t[5],u=t[6],h=t[7],l=t[8],d=Math.sin(r),f=Math.cos(r);e[0]=f*s+d*o,e[1]=f*n+d*a,e[2]=f*i+d*c,e[3]=f*o-d*s,e[4]=f*a-d*n,e[5]=f*c-d*i,e[6]=u,e[7]=h,e[8]=l}(this,this,e),this.check()}scale(e){return Array.isArray(e)?os(this,this,e):os(this,this,[e,e,e]),this.check()}translate(e){return function(e,t,r){var s=t[0],n=t[1],i=t[2],o=t[3],a=t[4],c=t[5],u=t[6],h=t[7],l=t[8],d=r[0],f=r[1];e[0]=s,e[1]=n,e[2]=i,e[3]=o,e[4]=a,e[5]=c,e[6]=d*s+f*o+u,e[7]=d*n+f*a+h,e[8]=d*i+f*c+l}(this,this,e),this.check()}transform(e,t){switch(e.length){case 2:t=Dr(t||[-0,-0],e,this);break;case 3:t=Kr(t||[-0,-0,-0],e,this);break;case 4:t=function(e,t,r){const s=t[0],n=t[1],i=t[2];return e[0]=r[0]*s+r[3]*n+r[6]*i,e[1]=r[1]*s+r[4]*n+r[7]*i,e[2]=r[2]*s+r[5]*n+r[8]*i,e[3]=t[3],e}(t||[-0,-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return Nr(t,e.length),t}transformVector(e,t){return Cr("Matrix3.transformVector"),this.transform(e,t)}transformVector2(e,t){return Cr("Matrix3.transformVector"),this.transform(e,t)}transformVector3(e,t){return Cr("Matrix3.transformVector"),this.transform(e,t)}}function ds(e,t){if(e===t){var r=t[1],s=t[2],n=t[3],i=t[6],o=t[7],a=t[11];e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=r,e[6]=t[9],e[7]=t[13],e[8]=s,e[9]=i,e[11]=t[14],e[12]=n,e[13]=o,e[14]=a}else e[0]=t[0],e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=t[1],e[5]=t[5],e[6]=t[9],e[7]=t[13],e[8]=t[2],e[9]=t[6],e[10]=t[10],e[11]=t[14],e[12]=t[3],e[13]=t[7],e[14]=t[11],e[15]=t[15];return e}function fs(e,t){var r=t[0],s=t[1],n=t[2],i=t[3],o=t[4],a=t[5],c=t[6],u=t[7],h=t[8],l=t[9],d=t[10],f=t[11],p=t[12],m=t[13],g=t[14],y=t[15],w=r*a-s*o,b=r*c-n*o,T=r*u-i*o,v=s*c-n*a,_=s*u-i*a,E=n*u-i*c,x=h*m-l*p,S=h*g-d*p,A=h*y-f*p,M=l*g-d*m,R=l*y-f*m,O=d*y-f*g,I=w*O-b*R+T*M+v*A-_*S+E*x;return I?(I=1/I,e[0]=(a*O-c*R+u*M)*I,e[1]=(n*R-s*O-i*M)*I,e[2]=(m*E-g*_+y*v)*I,e[3]=(d*_-l*E-f*v)*I,e[4]=(c*A-o*O-u*S)*I,e[5]=(r*O-n*A+i*S)*I,e[6]=(g*T-p*E-y*b)*I,e[7]=(h*E-d*T+f*b)*I,e[8]=(o*R-a*A+u*x)*I,e[9]=(s*A-r*R-i*x)*I,e[10]=(p*_-m*T+y*w)*I,e[11]=(l*T-h*_-f*w)*I,e[12]=(a*S-o*M-c*x)*I,e[13]=(r*M-s*S+n*x)*I,e[14]=(m*b-p*v-g*w)*I,e[15]=(h*v-l*b+d*w)*I,e):null}function ps(e){var t=e[0],r=e[1],s=e[2],n=e[3],i=e[4],o=e[5],a=e[6],c=e[7],u=e[8],h=e[9],l=e[10],d=e[11],f=e[12],p=e[13],m=e[14],g=e[15];return(t*o-r*i)*(l*g-d*m)-(t*a-s*i)*(h*g-d*p)+(t*c-n*i)*(h*m-l*p)+(r*a-s*o)*(u*g-d*f)-(r*c-n*o)*(u*m-l*f)+(s*c-n*a)*(u*p-h*f)}function ms(e,t,r){var s=t[0],n=t[1],i=t[2],o=t[3],a=t[4],c=t[5],u=t[6],h=t[7],l=t[8],d=t[9],f=t[10],p=t[11],m=t[12],g=t[13],y=t[14],w=t[15],b=r[0],T=r[1],v=r[2],_=r[3];return e[0]=b*s+T*a+v*l+_*m,e[1]=b*n+T*c+v*d+_*g,e[2]=b*i+T*u+v*f+_*y,e[3]=b*o+T*h+v*p+_*w,b=r[4],T=r[5],v=r[6],_=r[7],e[4]=b*s+T*a+v*l+_*m,e[5]=b*n+T*c+v*d+_*g,e[6]=b*i+T*u+v*f+_*y,e[7]=b*o+T*h+v*p+_*w,b=r[8],T=r[9],v=r[10],_=r[11],e[8]=b*s+T*a+v*l+_*m,e[9]=b*n+T*c+v*d+_*g,e[10]=b*i+T*u+v*f+_*y,e[11]=b*o+T*h+v*p+_*w,b=r[12],T=r[13],v=r[14],_=r[15],e[12]=b*s+T*a+v*l+_*m,e[13]=b*n+T*c+v*d+_*g,e[14]=b*i+T*u+v*f+_*y,e[15]=b*o+T*h+v*p+_*w,e}function gs(e,t,r){var s,n,i,o,a,c,u,h,l,d,f,p,m=r[0],g=r[1],y=r[2];return t===e?(e[12]=t[0]*m+t[4]*g+t[8]*y+t[12],e[13]=t[1]*m+t[5]*g+t[9]*y+t[13],e[14]=t[2]*m+t[6]*g+t[10]*y+t[14],e[15]=t[3]*m+t[7]*g+t[11]*y+t[15]):(s=t[0],n=t[1],i=t[2],o=t[3],a=t[4],c=t[5],u=t[6],h=t[7],l=t[8],d=t[9],f=t[10],p=t[11],e[0]=s,e[1]=n,e[2]=i,e[3]=o,e[4]=a,e[5]=c,e[6]=u,e[7]=h,e[8]=l,e[9]=d,e[10]=f,e[11]=p,e[12]=s*m+a*g+l*y+t[12],e[13]=n*m+c*g+d*y+t[13],e[14]=i*m+u*g+f*y+t[14],e[15]=o*m+h*g+p*y+t[15]),e}function ys(e,t,r){var s=r[0],n=r[1],i=r[2];return e[0]=t[0]*s,e[1]=t[1]*s,e[2]=t[2]*s,e[3]=t[3]*s,e[4]=t[4]*n,e[5]=t[5]*n,e[6]=t[6]*n,e[7]=t[7]*n,e[8]=t[8]*i,e[9]=t[9]*i,e[10]=t[10]*i,e[11]=t[11]*i,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function ws(e,t,r,s){var n,i,o,a,c,u,h,l,d,f,p,m,g,y,w,b,T,v,_,E,x,S,A,M,R=s[0],O=s[1],I=s[2],N=Math.hypot(R,O,I);return N<1e-6?null:(R*=N=1/N,O*=N,I*=N,n=Math.sin(r),o=1-(i=Math.cos(r)),a=t[0],c=t[1],u=t[2],h=t[3],l=t[4],d=t[5],f=t[6],p=t[7],m=t[8],g=t[9],y=t[10],w=t[11],b=R*R*o+i,T=O*R*o+I*n,v=I*R*o-O*n,_=R*O*o-I*n,E=O*O*o+i,x=I*O*o+R*n,S=R*I*o+O*n,A=O*I*o-R*n,M=I*I*o+i,e[0]=a*b+l*T+m*v,e[1]=c*b+d*T+g*v,e[2]=u*b+f*T+y*v,e[3]=h*b+p*T+w*v,e[4]=a*_+l*E+m*x,e[5]=c*_+d*E+g*x,e[6]=u*_+f*E+y*x,e[7]=h*_+p*E+w*x,e[8]=a*S+l*A+m*M,e[9]=c*S+d*A+g*M,e[10]=u*S+f*A+y*M,e[11]=h*S+p*A+w*M,t!==e&&(e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e)}function bs(e,t,r){var s=Math.sin(r),n=Math.cos(r),i=t[4],o=t[5],a=t[6],c=t[7],u=t[8],h=t[9],l=t[10],d=t[11];return t!==e&&(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[4]=i*n+u*s,e[5]=o*n+h*s,e[6]=a*n+l*s,e[7]=c*n+d*s,e[8]=u*n-i*s,e[9]=h*n-o*s,e[10]=l*n-a*s,e[11]=d*n-c*s,e}function Ts(e,t,r){var s=Math.sin(r),n=Math.cos(r),i=t[0],o=t[1],a=t[2],c=t[3],u=t[8],h=t[9],l=t[10],d=t[11];return t!==e&&(e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=i*n-u*s,e[1]=o*n-h*s,e[2]=a*n-l*s,e[3]=c*n-d*s,e[8]=i*s+u*n,e[9]=o*s+h*n,e[10]=a*s+l*n,e[11]=c*s+d*n,e}function vs(e,t,r){var s=Math.sin(r),n=Math.cos(r),i=t[0],o=t[1],a=t[2],c=t[3],u=t[4],h=t[5],l=t[6],d=t[7];return t!==e&&(e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=i*n+u*s,e[1]=o*n+h*s,e[2]=a*n+l*s,e[3]=c*n+d*s,e[4]=u*n-i*s,e[5]=h*n-o*s,e[6]=l*n-a*s,e[7]=d*n-c*s,e}function _s(e,t){var r=t[0],s=t[1],n=t[2],i=t[3],o=r+r,a=s+s,c=n+n,u=r*o,h=s*o,l=s*a,d=n*o,f=n*a,p=n*c,m=i*o,g=i*a,y=i*c;return e[0]=1-l-p,e[1]=h+y,e[2]=d-g,e[3]=0,e[4]=h-y,e[5]=1-u-p,e[6]=f+m,e[7]=0,e[8]=d+g,e[9]=f-m,e[10]=1-u-l,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function Es(e,t,r,s,n,i,o){var a=1/(r-t),c=1/(n-s),u=1/(i-o);return e[0]=2*i*a,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=2*i*c,e[6]=0,e[7]=0,e[8]=(r+t)*a,e[9]=(n+s)*c,e[10]=(o+i)*u,e[11]=-1,e[12]=0,e[13]=0,e[14]=o*i*2*u,e[15]=0,e}function xs(e,t,r,s,n){var i,o=1/Math.tan(t/2);return e[0]=o/r,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=o,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,null!=n&&n!==1/0?(i=1/(s-n),e[10]=(n+s)*i,e[14]=2*n*s*i):(e[10]=-1,e[14]=-2*s),e}function Ss(e,t,r,s,n,i,o){var a=1/(t-r),c=1/(s-n),u=1/(i-o);return e[0]=-2*a,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*c,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*u,e[11]=0,e[12]=(t+r)*a,e[13]=(n+s)*c,e[14]=(o+i)*u,e[15]=1,e}function As(e,t,r,s){var n,i,o,a,c,u,h,l,d,f,p=t[0],m=t[1],g=t[2],y=s[0],w=s[1],b=s[2],T=r[0],v=r[1],_=r[2];return Math.abs(p-T)<1e-6&&Math.abs(m-v)<1e-6&&Math.abs(g-_)<1e-6?function(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}(e):(h=p-T,l=m-v,d=g-_,n=w*(d*=f=1/Math.hypot(h,l,d))-b*(l*=f),i=b*(h*=f)-y*d,o=y*l-w*h,(f=Math.hypot(n,i,o))?(n*=f=1/f,i*=f,o*=f):(n=0,i=0,o=0),a=l*o-d*i,c=d*n-h*o,u=h*i-l*n,(f=Math.hypot(a,c,u))?(a*=f=1/f,c*=f,u*=f):(a=0,c=0,u=0),e[0]=n,e[1]=a,e[2]=h,e[3]=0,e[4]=i,e[5]=c,e[6]=l,e[7]=0,e[8]=o,e[9]=u,e[10]=d,e[11]=0,e[12]=-(n*p+i*m+o*g),e[13]=-(a*p+c*m+u*g),e[14]=-(h*p+l*m+d*g),e[15]=1,e)}function Ms(e,t,r){var s=t[0],n=t[1],i=t[2],o=t[3];return e[0]=r[0]*s+r[4]*n+r[8]*i+r[12]*o,e[1]=r[1]*s+r[5]*n+r[9]*i+r[13]*o,e[2]=r[2]*s+r[6]*n+r[10]*i+r[14]*o,e[3]=r[3]*s+r[7]*n+r[11]*i+r[15]*o,e}!function(){var e=function(){var e=new kr(4);return kr!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e}()}();const Rs=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),Os=Object.freeze([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Is=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}),Ns={};class Ls extends ns{static get IDENTITY(){return Ns.IDENTITY=Ns.IDENTITY||Object.freeze(new Ls(Rs)),Ns.IDENTITY}static get ZERO(){return Ns.ZERO=Ns.ZERO||Object.freeze(new Ls(Os)),Ns.ZERO}get INDICES(){return Is}get ELEMENTS(){return 16}get RANK(){return 4}constructor(e){super(-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0),1===arguments.length&&Array.isArray(e)?this.copy(e):this.identity()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this[4]=e[4],this[5]=e[5],this[6]=e[6],this[7]=e[7],this[8]=e[8],this[9]=e[9],this[10]=e[10],this[11]=e[11],this[12]=e[12],this[13]=e[13],this[14]=e[14],this[15]=e[15],this.check()}set(e,t,r,s,n,i,o,a,c,u,h,l,d,f,p,m){return this[0]=e,this[1]=t,this[2]=r,this[3]=s,this[4]=n,this[5]=i,this[6]=o,this[7]=a,this[8]=c,this[9]=u,this[10]=h,this[11]=l,this[12]=d,this[13]=f,this[14]=p,this[15]=m,this.check()}setRowMajor(e,t,r,s,n,i,o,a,c,u,h,l,d,f,p,m){return this[0]=e,this[1]=n,this[2]=c,this[3]=d,this[4]=t,this[5]=i,this[6]=u,this[7]=f,this[8]=r,this[9]=o,this[10]=h,this[11]=p,this[12]=s,this[13]=a,this[14]=l,this[15]=m,this.check()}toRowMajor(e){return e[0]=this[0],e[1]=this[4],e[2]=this[8],e[3]=this[12],e[4]=this[1],e[5]=this[5],e[6]=this[9],e[7]=this[13],e[8]=this[2],e[9]=this[6],e[10]=this[10],e[11]=this[14],e[12]=this[3],e[13]=this[7],e[14]=this[11],e[15]=this[15],e}identity(){return this.copy(Rs)}fromQuaternion(e){return _s(this,e),this.check()}frustum({left:e,right:t,bottom:r,top:s,near:n,far:i}){return i===1/0?Ls._computeInfinitePerspectiveOffCenter(this,e,t,r,s,n):Es(this,e,t,r,s,n,i),this.check()}static _computeInfinitePerspectiveOffCenter(e,t,r,s,n,i){const o=2*i/(r-t),a=2*i/(n-s),c=(r+t)/(r-t),u=(n+s)/(n-s),h=-2*i;return e[0]=o,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=a,e[6]=0,e[7]=0,e[8]=c,e[9]=u,e[10]=-1,e[11]=-1,e[12]=0,e[13]=0,e[14]=h,e[15]=0,e}lookAt(e,t,r){return 1===arguments.length&&({eye:e,center:t,up:r}=e),As(this,e,t=t||[0,0,0],r=r||[0,1,0]),this.check()}ortho({left:e,right:t,bottom:r,top:s,near:n=.1,far:i=500}){return Ss(this,e,t,r,s,n,i),this.check()}orthographic({fovy:e=45*Math.PI/180,aspect:t=1,focalDistance:r=1,near:s=.1,far:n=500}){if(e>2*Math.PI)throw Error("radians");const i=e/2,o=r*Math.tan(i),a=o*t;return(new Ls).ortho({left:-a,right:a,bottom:-o,top:o,near:s,far:n})}perspective({fovy:e,fov:t=45*Math.PI/180,aspect:r=1,near:s=.1,far:n=500}={}){if((e=e||t)>2*Math.PI)throw Error("radians");return xs(this,e,r,s,n),this.check()}determinant(){return ps(this)}getScale(e=[-0,-0,-0]){return e[0]=Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]),e[1]=Math.sqrt(this[4]*this[4]+this[5]*this[5]+this[6]*this[6]),e[2]=Math.sqrt(this[8]*this[8]+this[9]*this[9]+this[10]*this[10]),e}getTranslation(e=[-0,-0,-0]){return e[0]=this[12],e[1]=this[13],e[2]=this[14],e}getRotation(e=[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],t=null){const r=this.getScale(t||[-0,-0,-0]),s=1/r[0],n=1/r[1],i=1/r[2];return e[0]=this[0]*s,e[1]=this[1]*n,e[2]=this[2]*i,e[3]=0,e[4]=this[4]*s,e[5]=this[5]*n,e[6]=this[6]*i,e[7]=0,e[8]=this[8]*s,e[9]=this[9]*n,e[10]=this[10]*i,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}getRotationMatrix3(e=[-0,-0,-0,-0,-0,-0,-0,-0,-0],t=null){const r=this.getScale(t||[-0,-0,-0]),s=1/r[0],n=1/r[1],i=1/r[2];return e[0]=this[0]*s,e[1]=this[1]*n,e[2]=this[2]*i,e[3]=this[4]*s,e[4]=this[5]*n,e[5]=this[6]*i,e[6]=this[8]*s,e[7]=this[9]*n,e[8]=this[10]*i,e}transpose(){return ds(this,this),this.check()}invert(){return fs(this,this),this.check()}multiplyLeft(e){return ms(this,e,this),this.check()}multiplyRight(e){return ms(this,this,e),this.check()}rotateX(e){return bs(this,this,e),this.check()}rotateY(e){return Ts(this,this,e),this.check()}rotateZ(e){return vs(this,this,e),this.check()}rotateXYZ([e,t,r]){return this.rotateX(e).rotateY(t).rotateZ(r)}rotateAxis(e,t){return ws(this,this,e,t),this.check()}scale(e){return Array.isArray(e)?ys(this,this,e):ys(this,this,[e,e,e]),this.check()}translate(e){return gs(this,this,e),this.check()}transform(e,t){return 4===e.length?(Nr(t=Ms(t||[-0,-0,-0,-0],e,this),4),t):this.transformAsPoint(e,t)}transformAsPoint(e,t){const{length:r}=e;switch(r){case 2:t=jr(t||[-0,-0],e,this);break;case 3:t=Wr(t||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return Nr(t,e.length),t}transformAsVector(e,t){switch(e.length){case 2:t=Br(t||[-0,-0],e,this);break;case 3:t=Fr(t||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return Nr(t,e.length),t}makeRotationX(e){return this.identity().rotateX(e)}makeTranslation(e,t,r){return this.identity().translate([e,t,r])}transformPoint(e,t){return Cr("Matrix4.transformPoint","3.0"),this.transformAsPoint(e,t)}transformVector(e,t){return Cr("Matrix4.transformVector","3.0"),this.transformAsPoint(e,t)}transformDirection(e,t){return Cr("Matrix4.transformDirection","3.0"),this.transformAsVector(e,t)}}function Cs(){var e=new kr(4);return kr!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function Ps(e,t,r){r*=.5;var s=Math.sin(r);return e[0]=s*t[0],e[1]=s*t[1],e[2]=s*t[2],e[3]=Math.cos(r),e}function Us(e,t,r){var s=t[0],n=t[1],i=t[2],o=t[3],a=r[0],c=r[1],u=r[2],h=r[3];return e[0]=s*h+o*a+n*u-i*c,e[1]=n*h+o*c+i*a-s*u,e[2]=i*h+o*u+s*c-n*a,e[3]=o*h-s*a-n*c-i*u,e}function ks(e,t,r,s){var n,i,o,a,c,u=t[0],h=t[1],l=t[2],d=t[3],f=r[0],p=r[1],m=r[2],g=r[3];return(i=u*f+h*p+l*m+d*g)<0&&(i=-i,f=-f,p=-p,m=-m,g=-g),1-i>1e-6?(n=Math.acos(i),o=Math.sin(n),a=Math.sin((1-s)*n)/o,c=Math.sin(s*n)/o):(a=1-s,c=s),e[0]=a*u+c*f,e[1]=a*h+c*p,e[2]=a*l+c*m,e[3]=a*d+c*g,e}function Ds(e,t){var r,s=t[0]+t[4]+t[8];if(s>0)r=Math.sqrt(s+1),e[3]=.5*r,r=.5/r,e[0]=(t[5]-t[7])*r,e[1]=(t[6]-t[2])*r,e[2]=(t[1]-t[3])*r;else{var n=0;t[4]>t[0]&&(n=1),t[8]>t[3*n+n]&&(n=2);var i=(n+1)%3,o=(n+2)%3;r=Math.sqrt(t[3*n+n]-t[3*i+i]-t[3*o+o]+1),e[n]=.5*r,r=.5/r,e[3]=(t[3*i+o]-t[3*o+i])*r,e[i]=(t[3*i+n]+t[3*n+i])*r,e[o]=(t[3*o+n]+t[3*n+o])*r}return e}var js,Bs,Fs,Vs=function(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e[3]=t[3]+r[3],e},qs=function(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e},zs=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]},Gs=function(e,t,r,s){var n=t[0],i=t[1],o=t[2],a=t[3];return e[0]=n+s*(r[0]-n),e[1]=i+s*(r[1]-i),e[2]=o+s*(r[2]-o),e[3]=a+s*(r[3]-a),e},Hs=function(e){var t=e[0],r=e[1],s=e[2],n=e[3];return Math.hypot(t,r,s,n)},$s=function(e){var t=e[0],r=e[1],s=e[2],n=e[3];return t*t+r*r+s*s+n*n},Ws=function(e,t){var r=t[0],s=t[1],n=t[2],i=t[3],o=r*r+s*s+n*n+i*i;return o>0&&(o=1/Math.sqrt(o)),e[0]=r*o,e[1]=s*o,e[2]=n*o,e[3]=i*o,e},Ks=(js=qr(),Bs=Gr(1,0,0),Fs=Gr(0,1,0),function(e,t,r){var s=Hr(t,r);return s<-.999999?($r(js,Bs,t),es(js)<1e-6&&$r(js,Fs,t),function(e,t){var r=t[0],s=t[1],n=t[2],i=r*r+s*s+n*n;i>0&&(i=1/Math.sqrt(i)),e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i}(js,js),Ps(e,js,Math.PI),e):s>.999999?(e[0]=0,e[1]=0,e[2]=0,e[3]=1,e):($r(js,t,r),e[0]=js[0],e[1]=js[1],e[2]=js[2],e[3]=1+s,Ws(e,e))});Cs(),Cs(),function(){var e=new kr(9);kr!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[5]=0,e[6]=0,e[7]=0),e[0]=1,e[4]=1,e[8]=1}();const Qs=[0,0,0,1];class Xs extends Or{constructor(e=0,t=0,r=0,s=1){super(-0,-0,-0,-0),Array.isArray(e)&&1===arguments.length?this.copy(e):this.set(e,t,r,s)}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this.check()}set(e,t,r,s){return this[0]=e,this[1]=t,this[2]=r,this[3]=s,this.check()}fromMatrix3(e){return Ds(this,e),this.check()}identity(){return function(e){e[0]=0,e[1]=0,e[2]=0,e[3]=1}(this),this.check()}fromAxisRotation(e,t){return Ps(this,e,t),this.check()}setAxisAngle(e,t){return this.fromAxisRotation(e,t)}get ELEMENTS(){return 4}get x(){return this[0]}set x(e){this[0]=Ir(e)}get y(){return this[1]}set y(e){this[1]=Ir(e)}get z(){return this[2]}set z(e){this[2]=Ir(e)}get w(){return this[3]}set w(e){this[3]=Ir(e)}len(){return Hs(this)}lengthSquared(){return $s(this)}dot(e,t){if(void 0!==t)throw new Error("Quaternion.dot only takes one argument");return zs(this,e)}rotationTo(e,t){return Ks(this,e,t),this.check()}add(e,t){if(void 0!==t)throw new Error("Quaternion.add only takes one argument");return Vs(this,this,e),this.check()}calculateW(){return function(e,t){var r=t[0],s=t[1],n=t[2];e[0]=r,e[1]=s,e[2]=n,e[3]=Math.sqrt(Math.abs(1-r*r-s*s-n*n))}(this,this),this.check()}conjugate(){return function(e,t){e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3]}(this,this),this.check()}invert(){return function(e,t){var r=t[0],s=t[1],n=t[2],i=t[3],o=r*r+s*s+n*n+i*i,a=o?1/o:0;e[0]=-r*a,e[1]=-s*a,e[2]=-n*a,e[3]=i*a}(this,this),this.check()}lerp(e,t,r){return Gs(this,e,t,r),this.check()}multiplyRight(e,t){return br(!t),Us(this,this,e),this.check()}multiplyLeft(e,t){return br(!t),Us(this,e,this),this.check()}normalize(){const e=this.len(),t=e>0?1/e:0;return this[0]=this[0]*t,this[1]=this[1]*t,this[2]=this[2]*t,this[3]=this[3]*t,0===e&&(this[3]=1),this.check()}rotateX(e){return function(e,t,r){r*=.5;var s=t[0],n=t[1],i=t[2],o=t[3],a=Math.sin(r),c=Math.cos(r);e[0]=s*c+o*a,e[1]=n*c+i*a,e[2]=i*c-n*a,e[3]=o*c-s*a}(this,this,e),this.check()}rotateY(e){return function(e,t,r){r*=.5;var s=t[0],n=t[1],i=t[2],o=t[3],a=Math.sin(r),c=Math.cos(r);e[0]=s*c-i*a,e[1]=n*c+o*a,e[2]=i*c+s*a,e[3]=o*c-n*a}(this,this,e),this.check()}rotateZ(e){return function(e,t,r){r*=.5;var s=t[0],n=t[1],i=t[2],o=t[3],a=Math.sin(r),c=Math.cos(r);e[0]=s*c+n*a,e[1]=n*c-s*a,e[2]=i*c+o*a,e[3]=o*c-i*a}(this,this,e),this.check()}scale(e){return qs(this,this,e),this.check()}slerp(e,t,r){switch(arguments.length){case 1:({start:e=Qs,target:t,ratio:r}=arguments[0]);break;case 2:[t,r]=arguments,e=this}return ks(this,e,t,r),this.check()}transformVector4(e,t=e){return function(e,t,r){var s=t[0],n=t[1],i=t[2],o=r[0],a=r[1],c=r[2],u=r[3],h=u*s+a*i-c*n,l=u*n+c*s-o*i,d=u*i+o*n-a*s,f=-o*s-a*n-c*i;e[0]=h*u+f*-o+l*-c-d*-a,e[1]=l*u+f*-a+d*-o-h*-c,e[2]=d*u+f*-c+h*-a-l*-o,e[3]=t[3]}(t,e,this),Nr(t,4)}lengthSq(){return this.lengthSquared()}setFromAxisAngle(e,t){return this.setAxisAngle(e,t)}premultiply(e,t){return this.multiplyLeft(e,t)}multiply(e,t){return this.multiplyRight(e,t)}}function Ys(e,t){if(!e)throw new Error(`math.gl assertion ${t}`)}const Zs=1/Math.PI*180,Js=1/180*Math.PI,en={};function tn(e,{precision:t=en.precision||4}={}){return e=function(e){return Math.round(e/en.EPSILON)*en.EPSILON}(e),`${parseFloat(e.toPrecision(t))}`}function rn(e){return Array.isArray(e)||ArrayBuffer.isView(e)&&!(e instanceof DataView)}function sn(e,t,r){if(rn(e)){r=r||((s=e).clone?s.clone():new Array(s.length));for(let s=0;s<r.length&&s<e.length;++s)r[s]=t(e[s],s,r);return r}var s;return t(e)}function nn(e){return function(e,t){return sn(e,(e=>e*Js),t)}(e)}function on(e){return function(e,t){return sn(e,(e=>e*Zs),t)}(e)}function an(e,t,r){const s=en.EPSILON;r&&(en.EPSILON=r);try{if(e===t)return!0;if(rn(e)&&rn(t)){if(e.length!==t.length)return!1;for(let r=0;r<e.length;++r)if(!an(e[r],t[r]))return!1;return!0}return e&&e.equals?e.equals(t):t&&t.equals?t.equals(e):!(!Number.isFinite(e)||!Number.isFinite(t))&&Math.abs(e-t)<=en.EPSILON*Math.max(1,Math.abs(e),Math.abs(t))}finally{en.EPSILON=s}}en.EPSILON=1e-12,en.debug=!1,en.precision=4,en.printTypes=!1,en.printDegrees=!1,en.printRowMajor=!0;class cn extends(function(e){function t(){var t=Reflect.construct(e,Array.from(arguments));return Object.setPrototypeOf(t,Object.getPrototypeOf(this)),t}return t.prototype=Object.create(e.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e,t}(Array)){get ELEMENTS(){return Ys(!1),0}clone(){return(new this.constructor).copy(this)}from(e){return Array.isArray(e)?this.copy(e):this.fromObject(e)}fromArray(e,t=0){for(let r=0;r<this.ELEMENTS;++r)this[r]=e[r+t];return this.check()}to(e){return e===this?this:rn(e)?this.toArray(e):this.toObject(e)}toTarget(e){return e?this.to(e):this}toArray(e=[],t=0){for(let r=0;r<this.ELEMENTS;++r)e[t+r]=this[r];return e}toFloat32Array(){return new Float32Array(this)}toString(){return this.formatString(en)}formatString(e){let t="";for(let r=0;r<this.ELEMENTS;++r)t+=(r>0?", ":"")+tn(this[r],e);return`${e.printTypes?this.constructor.name:""}[${t}]`}equals(e){if(!e||this.length!==e.length)return!1;for(let t=0;t<this.ELEMENTS;++t)if(!an(this[t],e[t]))return!1;return!0}exactEquals(e){if(!e||this.length!==e.length)return!1;for(let t=0;t<this.ELEMENTS;++t)if(this[t]!==e[t])return!1;return!0}negate(){for(let e=0;e<this.ELEMENTS;++e)this[e]=-this[e];return this.check()}lerp(e,t,r){void 0===r&&(r=t,t=e,e=this);for(let s=0;s<this.ELEMENTS;++s){const n=e[s];this[s]=n+r*(t[s]-n)}return this.check()}min(e){for(let t=0;t<this.ELEMENTS;++t)this[t]=Math.min(e[t],this[t]);return this.check()}max(e){for(let t=0;t<this.ELEMENTS;++t)this[t]=Math.max(e[t],this[t]);return this.check()}clamp(e,t){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(Math.max(this[r],e[r]),t[r]);return this.check()}add(...e){for(const t of e)for(let e=0;e<this.ELEMENTS;++e)this[e]+=t[e];return this.check()}subtract(...e){for(const t of e)for(let e=0;e<this.ELEMENTS;++e)this[e]-=t[e];return this.check()}scale(e){if(Array.isArray(e))return this.multiply(e);for(let t=0;t<this.ELEMENTS;++t)this[t]*=e;return this.check()}sub(e){return this.subtract(e)}setScalar(e){for(let t=0;t<this.ELEMENTS;++t)this[t]=e;return this.check()}addScalar(e){for(let t=0;t<this.ELEMENTS;++t)this[t]+=e;return this.check()}subScalar(e){return this.addScalar(-e)}multiplyScalar(e){for(let t=0;t<this.ELEMENTS;++t)this[t]*=e;return this.check()}divideScalar(e){return this.scale(1/e)}clampScalar(e,t){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(Math.max(this[r],e),t);return this.check()}multiplyByScalar(e){return this.scale(e)}get elements(){return this}check(){if(en.debug&&!this.validate())throw new Error(`math.gl: ${this.constructor.name} some fields set to invalid numbers'`);return this}validate(){let e=this.length===this.ELEMENTS;for(let t=0;t<this.ELEMENTS;++t)e=e&&Number.isFinite(this[t]);return e}}function un(e){if(!Number.isFinite(e))throw new Error(`Invalid number ${e}`);return e}function hn(e,t,r=""){if(en.debug&&!function(e,t){if(e.length!==t)return!1;for(let t=0;t<e.length;++t)if(!Number.isFinite(e[t]))return!1;return!0}(e,t))throw new Error(`math.gl: ${r} some fields set to invalid numbers'`);return e}const ln={};function dn(e,t){ln[e]||(ln[e]=!0,console.warn(`${e} has been removed in version ${t}, see upgrade guide for more information`))}class fn extends cn{get ELEMENTS(){return Ys(!1),0}copy(e){return Ys(!1),this}get x(){return this[0]}set x(e){this[0]=un(e)}get y(){return this[1]}set y(e){this[1]=un(e)}len(){return Math.sqrt(this.lengthSquared())}magnitude(){return this.len()}lengthSquared(){let e=0;for(let t=0;t<this.ELEMENTS;++t)e+=this[t]*this[t];return e}magnitudeSquared(){return this.lengthSquared()}distance(e){return Math.sqrt(this.distanceSquared(e))}distanceSquared(e){let t=0;for(let r=0;r<this.ELEMENTS;++r){const s=this[r]-e[r];t+=s*s}return un(t)}dot(e){let t=0;for(let r=0;r<this.ELEMENTS;++r)t+=this[r]*e[r];return un(t)}normalize(){const e=this.magnitude();if(0!==e)for(let t=0;t<this.ELEMENTS;++t)this[t]/=e;return this.check()}multiply(...e){for(const t of e)for(let e=0;e<this.ELEMENTS;++e)this[e]*=t[e];return this.check()}divide(...e){for(const t of e)for(let e=0;e<this.ELEMENTS;++e)this[e]/=t[e];return this.check()}lengthSq(){return this.lengthSquared()}distanceTo(e){return this.distance(e)}distanceToSquared(e){return this.distanceSquared(e)}getComponent(e){return Ys(e>=0&&e<this.ELEMENTS,"index is out of range"),un(this[e])}setComponent(e,t){return Ys(e>=0&&e<this.ELEMENTS,"index is out of range"),this[e]=t,this.check()}addVectors(e,t){return this.copy(e).add(t)}subVectors(e,t){return this.copy(e).subtract(t)}multiplyVectors(e,t){return this.copy(e).multiply(t)}addScaledVector(e,t){return this.add(new this.constructor(e).multiplyScalar(t))}}function pn(e,t,r){const s=t[0],n=t[1],i=t[2],o=r[3]*s+r[7]*n+r[11]*i||1;return e[0]=(r[0]*s+r[4]*n+r[8]*i)/o,e[1]=(r[1]*s+r[5]*n+r[9]*i)/o,e[2]=(r[2]*s+r[6]*n+r[10]*i)/o,e}const mn=[0,0,0],gn={};class yn extends fn{static get ZERO(){return gn.ZERO=gn.ZERO||Object.freeze(new yn(0,0,0,0))}constructor(e=0,t=0,r=0){super(-0,-0,-0),1===arguments.length&&rn(e)?this.copy(e):(en.debug&&(un(e),un(t),un(r)),this[0]=e,this[1]=t,this[2]=r)}set(e,t,r){return this[0]=e,this[1]=t,this[2]=r,this.check()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this.check()}fromObject(e){return en.debug&&(un(e.x),un(e.y),un(e.z)),this[0]=e.x,this[1]=e.y,this[2]=e.z,this.check()}toObject(e){return e.x=this[0],e.y=this[1],e.z=this[2],e}get ELEMENTS(){return 3}get z(){return this[2]}set z(e){this[2]=un(e)}angle(e){return Jr(this,e)}cross(e){return $r(this,this,e),this.check()}rotateX({radians:e,origin:t=mn}){return Xr(this,this,t,e),this.check()}rotateY({radians:e,origin:t=mn}){return Yr(this,this,t,e),this.check()}rotateZ({radians:e,origin:t=mn}){return Zr(this,this,t,e),this.check()}transform(e){return this.transformAsPoint(e)}transformAsPoint(e){return Wr(this,this,e),this.check()}transformAsVector(e){return pn(this,this,e),this.check()}transformByMatrix3(e){return Kr(this,this,e),this.check()}transformByMatrix2(e){return function(e,t,r){const s=t[0],n=t[1];e[0]=r[0]*s+r[2]*n,e[1]=r[1]*s+r[3]*n,e[2]=t[2]}(this,this,e),this.check()}transformByQuaternion(e){return Qr(this,this,e),this.check()}}class wn extends cn{get ELEMENTS(){return Ys(!1),0}get RANK(){return Ys(!1),0}toString(){let e="[";if(en.printRowMajor){e+="row-major:";for(let t=0;t<this.RANK;++t)for(let r=0;r<this.RANK;++r)e+=` ${this[r*this.RANK+t]}`}else{e+="column-major:";for(let t=0;t<this.ELEMENTS;++t)e+=` ${this[t]}`}return e+="]",e}getElementIndex(e,t){return t*this.RANK+e}getElement(e,t){return this[t*this.RANK+e]}setElement(e,t,r){return this[t*this.RANK+e]=un(r),this}getColumn(e,t=new Array(this.RANK).fill(-0)){const r=e*this.RANK;for(let e=0;e<this.RANK;++e)t[e]=this[r+e];return t}setColumn(e,t){const r=e*this.RANK;for(let e=0;e<this.RANK;++e)this[r+e]=t[e];return this}}const bn=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),Tn=Object.freeze([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),vn=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}),_n={};class En extends wn{static get IDENTITY(){return _n.IDENTITY=_n.IDENTITY||Object.freeze(new En(bn)),_n.IDENTITY}static get ZERO(){return _n.ZERO=_n.ZERO||Object.freeze(new En(Tn)),_n.ZERO}get INDICES(){return vn}get ELEMENTS(){return 16}get RANK(){return 4}constructor(e){super(-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0),1===arguments.length&&Array.isArray(e)?this.copy(e):this.identity()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this[4]=e[4],this[5]=e[5],this[6]=e[6],this[7]=e[7],this[8]=e[8],this[9]=e[9],this[10]=e[10],this[11]=e[11],this[12]=e[12],this[13]=e[13],this[14]=e[14],this[15]=e[15],this.check()}set(e,t,r,s,n,i,o,a,c,u,h,l,d,f,p,m){return this[0]=e,this[1]=t,this[2]=r,this[3]=s,this[4]=n,this[5]=i,this[6]=o,this[7]=a,this[8]=c,this[9]=u,this[10]=h,this[11]=l,this[12]=d,this[13]=f,this[14]=p,this[15]=m,this.check()}setRowMajor(e,t,r,s,n,i,o,a,c,u,h,l,d,f,p,m){return this[0]=e,this[1]=n,this[2]=c,this[3]=d,this[4]=t,this[5]=i,this[6]=u,this[7]=f,this[8]=r,this[9]=o,this[10]=h,this[11]=p,this[12]=s,this[13]=a,this[14]=l,this[15]=m,this.check()}toRowMajor(e){return e[0]=this[0],e[1]=this[4],e[2]=this[8],e[3]=this[12],e[4]=this[1],e[5]=this[5],e[6]=this[9],e[7]=this[13],e[8]=this[2],e[9]=this[6],e[10]=this[10],e[11]=this[14],e[12]=this[3],e[13]=this[7],e[14]=this[11],e[15]=this[15],e}identity(){return this.copy(bn)}fromQuaternion(e){return _s(this,e),this.check()}frustum({left:e,right:t,bottom:r,top:s,near:n,far:i}){return i===1/0?En._computeInfinitePerspectiveOffCenter(this,e,t,r,s,n):Es(this,e,t,r,s,n,i),this.check()}static _computeInfinitePerspectiveOffCenter(e,t,r,s,n,i){const o=2*i/(r-t),a=2*i/(n-s),c=(r+t)/(r-t),u=(n+s)/(n-s),h=-2*i;return e[0]=o,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=a,e[6]=0,e[7]=0,e[8]=c,e[9]=u,e[10]=-1,e[11]=-1,e[12]=0,e[13]=0,e[14]=h,e[15]=0,e}lookAt(e,t,r){return 1===arguments.length&&({eye:e,center:t,up:r}=e),As(this,e,t=t||[0,0,0],r=r||[0,1,0]),this.check()}ortho({left:e,right:t,bottom:r,top:s,near:n=.1,far:i=500}){return Ss(this,e,t,r,s,n,i),this.check()}orthographic({fovy:e=45*Math.PI/180,aspect:t=1,focalDistance:r=1,near:s=.1,far:n=500}){if(e>2*Math.PI)throw Error("radians");const i=e/2,o=r*Math.tan(i),a=o*t;return(new En).ortho({left:-a,right:a,bottom:-o,top:o,near:s,far:n})}perspective({fovy:e,fov:t=45*Math.PI/180,aspect:r=1,near:s=.1,far:n=500}={}){if((e=e||t)>2*Math.PI)throw Error("radians");return xs(this,e,r,s,n),this.check()}determinant(){return ps(this)}getScale(e=[-0,-0,-0]){return e[0]=Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]),e[1]=Math.sqrt(this[4]*this[4]+this[5]*this[5]+this[6]*this[6]),e[2]=Math.sqrt(this[8]*this[8]+this[9]*this[9]+this[10]*this[10]),e}getTranslation(e=[-0,-0,-0]){return e[0]=this[12],e[1]=this[13],e[2]=this[14],e}getRotation(e=[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],t=null){const r=this.getScale(t||[-0,-0,-0]),s=1/r[0],n=1/r[1],i=1/r[2];return e[0]=this[0]*s,e[1]=this[1]*n,e[2]=this[2]*i,e[3]=0,e[4]=this[4]*s,e[5]=this[5]*n,e[6]=this[6]*i,e[7]=0,e[8]=this[8]*s,e[9]=this[9]*n,e[10]=this[10]*i,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}getRotationMatrix3(e=[-0,-0,-0,-0,-0,-0,-0,-0,-0],t=null){const r=this.getScale(t||[-0,-0,-0]),s=1/r[0],n=1/r[1],i=1/r[2];return e[0]=this[0]*s,e[1]=this[1]*n,e[2]=this[2]*i,e[3]=this[4]*s,e[4]=this[5]*n,e[5]=this[6]*i,e[6]=this[8]*s,e[7]=this[9]*n,e[8]=this[10]*i,e}transpose(){return ds(this,this),this.check()}invert(){return fs(this,this),this.check()}multiplyLeft(e){return ms(this,e,this),this.check()}multiplyRight(e){return ms(this,this,e),this.check()}rotateX(e){return bs(this,this,e),this.check()}rotateY(e){return Ts(this,this,e),this.check()}rotateZ(e){return vs(this,this,e),this.check()}rotateXYZ([e,t,r]){return this.rotateX(e).rotateY(t).rotateZ(r)}rotateAxis(e,t){return ws(this,this,e,t),this.check()}scale(e){return Array.isArray(e)?ys(this,this,e):ys(this,this,[e,e,e]),this.check()}translate(e){return gs(this,this,e),this.check()}transform(e,t){return 4===e.length?(hn(t=Ms(t||[-0,-0,-0,-0],e,this),4),t):this.transformAsPoint(e,t)}transformAsPoint(e,t){const{length:r}=e;switch(r){case 2:t=jr(t||[-0,-0],e,this);break;case 3:t=Wr(t||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return hn(t,e.length),t}transformAsVector(e,t){switch(e.length){case 2:t=function(e,t,r){const s=t[0],n=t[1],i=r[3]*s+r[7]*n||1;return e[0]=(r[0]*s+r[4]*n)/i,e[1]=(r[1]*s+r[5]*n)/i,e}(t||[-0,-0],e,this);break;case 3:t=pn(t||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return hn(t,e.length),t}makeRotationX(e){return this.identity().rotateX(e)}makeTranslation(e,t,r){return this.identity().translate([e,t,r])}transformPoint(e,t){return dn("Matrix4.transformPoint","3.0"),this.transformAsPoint(e,t)}transformVector(e,t){return dn("Matrix4.transformVector","3.0"),this.transformAsPoint(e,t)}transformDirection(e,t){return dn("Matrix4.transformDirection","3.0"),this.transformAsVector(e,t)}}var xn=.1,Sn=1e-12,An=1e-15;Math.PI,Math.PI,Math.PI,Math.PI;const Mn=e=>e,Rn=new yn;function On(e,t=Rn){return function(e,t,r=Mn){return rn(e)?(t[0]=r(e[0]),t[1]=r(e[1]),t[2]=e[2]):"longitude"in e?(t[0]=r(e.longitude),t[1]=r(e.latitude),t[2]=e.height):(t[0]=r(e.x),t[1]=r(e.y),t[2]=e.z),t}(e,t,en._cartographicRadians?Mn:nn)}function In(e,t){return function(e,t,r=Mn){return rn(t)?(t[0]=r(e[0]),t[1]=r(e[1]),t[2]=e[2]):"longitude"in t?(t.longitude=r(e[0]),t.latitude=r(e[1]),t.height=e[2]):(t.x=r(e[0]),t.y=r(e[1]),t.z=e[2]),t}(e,t,en._cartographicRadians?Mn:on)}const Nn=new yn,Ln=new yn,Cn=new yn;const Pn=new yn,Un={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"}},kn={north:[-1,0,0],east:[0,1,0],up:[0,0,1],south:[1,0,0],west:[0,-1,0],down:[0,0,-1]},Dn={east:new yn,north:new yn,up:new yn,west:new yn,south:new yn,down:new yn},jn=new yn,Bn=new yn,Fn=new yn;function Vn(e,t,r,s,n,i){const o=Un[t]&&Un[t][r];let a,c,u;Ys(o&&(!s||s===o));const h=Pn.copy(n);if(an(h.x,0,1e-14)&&an(h.y,0,1e-14)){const e=Math.sign(h.z);a=jn.fromArray(kn[t]),"east"!==t&&"west"!==t&&a.scale(e),c=Bn.fromArray(kn[r]),"east"!==r&&"west"!==r&&c.scale(e),u=Fn.fromArray(kn[s]),"east"!==s&&"west"!==s&&u.scale(e)}else{const{up:n,east:i,north:o}=Dn;i.set(-h.y,h.x,0).normalize(),e.geodeticSurfaceNormal(h,n),o.copy(n).cross(i);const{down:l,west:d,south:f}=Dn;l.copy(n).scale(-1),d.copy(i).scale(-1),f.copy(o).scale(-1),a=Dn[t],c=Dn[r],u=Dn[s]}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]=h.x,i[13]=h.y,i[14]=h.z,i[15]=1,i}const qn=new yn,zn=new yn,Gn=new yn,Hn=new yn,$n=new yn,Wn=new yn;let Kn;class Qn{static get WGS84(){return Kn=Kn||new Qn(6378137,6378137,6356752.314245179),Kn}constructor(e=0,t=0,r=0){Ys(e>=0),Ys(t>=0),Ys(r>=0),this.radii=new yn(e,t,r),this.radiiSquared=new yn(e*e,t*t,r*r),this.radiiToTheFourth=new yn(e*e*e*e,t*t*t*t,r*r*r*r),this.oneOverRadii=new yn(0===e?0:1/e,0===t?0:1/t,0===r?0:1/r),this.oneOverRadiiSquared=new yn(0===e?0:1/(e*e),0===t?0:1/(t*t),0===r?0:1/(r*r)),this.minimumRadius=Math.min(e,t,r),this.maximumRadius=Math.max(e,t,r),this.centerToleranceSquared=xn,0!==this.radiiSquared.z&&(this.squaredXOverSquaredZ=this.radiiSquared.x/this.radiiSquared.z),Object.freeze(this)}equals(e){return this===e||Boolean(e&&this.radii.equals(e.radii))}toString(){return this.radii.toString()}cartographicToCartesian(e,t=[0,0,0]){const r=zn,s=Gn,[,,n]=e;this.geodeticSurfaceNormalCartographic(e,r),s.copy(this.radiiSquared).scale(r);const i=Math.sqrt(r.dot(s));return s.scale(1/i),r.scale(n),s.add(r),s.to(t)}cartesianToCartographic(e,t=[0,0,0]){Wn.from(e);const r=this.scaleToGeodeticSurface(Wn,Hn);if(!r)return;const s=this.geodeticSurfaceNormal(r,zn),n=$n;n.copy(Wn).subtract(r);return In([Math.atan2(s.y,s.x),Math.asin(s.z),Math.sign(Hr(n,Wn))*zr(n)],t)}eastNorthUpToFixedFrame(e,t=new En){return Vn(this,"east","north","up",e,t)}localFrameToFixedFrame(e,t,r,s,n=new En){return Vn(this,e,t,r,s,n)}geocentricSurfaceNormal(e,t=[0,0,0]){return qn.from(e).normalize().to(t)}geodeticSurfaceNormalCartographic(e,t=[0,0,0]){const r=On(e),s=r[0],n=r[1],i=Math.cos(n);return qn.set(i*Math.cos(s),i*Math.sin(s),Math.sin(n)).normalize(),qn.to(t)}geodeticSurfaceNormal(e,t=[0,0,0]){return qn.from(e).scale(this.oneOverRadiiSquared).normalize().to(t)}scaleToGeodeticSurface(e,t){return function(e,t,r=new yn){const{oneOverRadii:s,oneOverRadiiSquared:n,centerToleranceSquared:i}=t;Nn.from(e);const o=e.x,a=e.y,c=e.z,u=s.x,h=s.y,l=s.z,d=o*o*u*u,f=a*a*h*h,p=c*c*l*l,m=d+f+p,g=Math.sqrt(1/m);if(!Number.isFinite(g))return;const y=Ln;if(y.copy(e).scale(g),m<i)return y.to(r);const w=n.x,b=n.y,T=n.z,v=Cn;v.set(y.x*w*2,y.y*b*2,y.z*T*2);let _,E,x,S,A=(1-g)*e.len()/(.5*v.len()),M=0;do{A-=M,_=1/(1+A*w),E=1/(1+A*b),x=1/(1+A*T);const e=_*_,t=E*E,r=x*x;S=d*e+f*t+p*r-1,M=S/(-2*(d*(e*_)*w+f*(t*E)*b+p*(r*x)*T))}while(Math.abs(S)>Sn);return Nn.scale([_,E,x]).to(r)}(e,this,t)}scaleToGeocentricSurface(e,t=[0,0,0]){Hn.from(e);const r=Hn.x,s=Hn.y,n=Hn.z,i=this.oneOverRadiiSquared,o=1/Math.sqrt(r*r*i.x+s*s*i.y+n*n*i.z);return Hn.multiplyScalar(o).to(t)}transformPositionToScaledSpace(e,t=[0,0,0]){return Hn.from(e).scale(this.oneOverRadii).to(t)}transformPositionFromScaledSpace(e,t=[0,0,0]){return Hn.from(e).scale(this.radii).to(t)}getSurfaceNormalIntersectionWithZAxis(e,t=0,r=[0,0,0]){Ys(an(this.radii.x,this.radii.y,An)),Ys(this.radii.z>0),Hn.from(e);const s=Hn.z*(1-this.squaredXOverSquaredZ);if(!(Math.abs(s)>=this.radii.z-t))return Hn.set(0,0,s).to(r)}}class Xn{constructor(e,t,r){this.item=e,this.previous=t,this.next=r}}class Yn{constructor(){this.head=null,this.tail=null,this._length=0}get length(){return this._length}add(e){const t=new Xn(e,this.tail,null);return this.tail?(this.tail.next=t,this.tail=t):(this.head=t,this.tail=t),++this._length,t}remove(e){e&&(e.previous&&e.next?(e.previous.next=e.next,e.next.previous=e.previous):e.previous?(e.previous.next=null,this.tail=e.previous):e.next?(e.next.previous=null,this.head=e.next):(this.head=null,this.tail=null),e.next=null,e.previous=null,--this._length)}splice(e,t){e!==t&&(this.remove(t),this._insert(e,t))}_insert(e,t){const r=e.next;e.next=t,this.tail===e?this.tail=t:r.previous=t,t.next=r,t.previous=e,++this._length}}function Zn(e){return null!=e}class Jn{constructor(){Le(this,"_list",void 0),Le(this,"_sentinel",void 0),Le(this,"_trimTiles",void 0),this._list=new Yn,this._sentinel=this._list.add("sentinel"),this._trimTiles=!1}reset(){this._list.splice(this._list.tail,this._sentinel)}touch(e){const t=e._cacheNode;Zn(t)&&this._list.splice(this._sentinel,t)}add(e,t,r){Zn(t._cacheNode)||(t._cacheNode=this._list.add(t),r&&r(e,t))}unloadTile(e,t,r){const s=t._cacheNode;Zn(s)&&(this._list.remove(s),t._cacheNode=void 0,r&&r(e,t))}unloadTiles(e,t){const r=this._trimTiles;this._trimTiles=!1;const s=this._list,n=1024*e.maximumMemoryUsage*1024,i=this._sentinel;let o=s.head;for(;o!==i&&(e.gpuMemoryUsageInBytes>n||r);){const r=o.item;o=o.next,this.unloadTile(e,r,t)}}trim(){this._trimTiles=!0}}const ei=Object.freeze({OUTSIDE:-1,INTERSECTING:0,INSIDE:1});new ss,new ss;const ti=new ss,ri=new ss;class si{constructor(e=[0,0,0],t=0){this.radius=-0,this.center=new ss,this.fromCenterRadius(e,t)}fromCenterRadius(e,t){return this.center.from(e),this.radius=t,this}fromCornerPoints(e,t){return t=ti.from(t),this.center=(new ss).from(e).add(t).scale(.5),this.radius=this.center.distance(t),this}equals(e){return this===e||Boolean(e)&&this.center.equals(e.center)&&this.radius===e.radius}clone(){return new si(this.center,this.radius)}union(e){const t=this.center,r=this.radius,s=e.center,n=e.radius,i=ti.copy(s).subtract(t),o=i.magnitude();if(r>=o+n)return this.clone();if(n>=o+r)return e.clone();const a=.5*(r+o+n);return ri.copy(i).scale((-r+a)/o).add(t),this.center.copy(ri),this.radius=a,this}expand(e){const t=(e=ti.from(e)).subtract(this.center).magnitude();return t>this.radius&&(this.radius=t),this}transform(e){this.center.transform(e);const t=function(e,t){var r=t[0],s=t[1],n=t[2],i=t[4],o=t[5],a=t[6],c=t[8],u=t[9],h=t[10];return e[0]=Math.hypot(r,s,n),e[1]=Math.hypot(i,o,a),e[2]=Math.hypot(c,u,h),e}(ti,e);return this.radius=Math.max(t[0],Math.max(t[1],t[2]))*this.radius,this}distanceSquaredTo(e){return(e=ti.from(e)).subtract(this.center).lengthSquared()-this.radius*this.radius}distanceTo(e){return Math.sqrt(this.distanceSquaredTo(e))}intersectPlane(e){const t=this.center,r=this.radius,s=e.normal.dot(t)+e.distance;return s<-r?ei.OUTSIDE:s<r?ei.INTERSECTING:ei.INSIDE}}const ni=new ss,ii=new ss,oi=new ss,ai=new ss,ci=new ss,ui=new ss,hi=new ss,li=0,di=1,fi=2,pi=3,mi=4,gi=5,yi=6,wi=7,bi=8;class Ti{constructor(e=[0,0,0],t=[0,0,0,0,0,0,0,0,0]){this.center=(new ss).from(e),this.halfAxes=new ls(t)}get halfSize(){const e=this.halfAxes.getColumn(0),t=this.halfAxes.getColumn(1),r=this.halfAxes.getColumn(2);return[new ss(e).len(),new ss(t).len(),new ss(r).len()]}get quaternion(){const e=this.halfAxes.getColumn(0),t=this.halfAxes.getColumn(1),r=this.halfAxes.getColumn(2),s=new ss(e).normalize(),n=new ss(t).normalize(),i=new ss(r).normalize();return(new Xs).fromMatrix3(new ls([...s,...n,...i]))}fromCenterHalfSizeQuaternion(e,t,r){const s=new Xs(r),n=(new ls).fromQuaternion(s);return n[0]=n[0]*t[0],n[1]=n[1]*t[0],n[2]=n[2]*t[0],n[3]=n[3]*t[1],n[4]=n[4]*t[1],n[5]=n[5]*t[1],n[6]=n[6]*t[2],n[7]=n[7]*t[2],n[8]=n[8]*t[2],this.center=(new ss).from(e),this.halfAxes=n,this}clone(){return new Ti(this.center,this.halfAxes)}equals(e){return this===e||Boolean(e)&&this.center.equals(e.center)&&this.halfAxes.equals(e.halfAxes)}getBoundingSphere(e=new si){const t=this.halfAxes,r=t.getColumn(0,oi),s=t.getColumn(1,ai),n=t.getColumn(2,ci),i=ni.copy(r).add(s).add(n);return e.center.copy(this.center),e.radius=i.magnitude(),e}intersectPlane(e){const t=this.center,r=e.normal,s=this.halfAxes,n=r.x,i=r.y,o=r.z,a=Math.abs(n*s[li]+i*s[di]+o*s[fi])+Math.abs(n*s[pi]+i*s[mi]+o*s[gi])+Math.abs(n*s[yi]+i*s[wi]+o*s[bi]),c=r.dot(t)+e.distance;return c<=-a?ei.OUTSIDE:c>=a?ei.INSIDE:ei.INTERSECTING}distanceTo(e){return Math.sqrt(this.distanceSquaredTo(e))}distanceSquaredTo(e){const t=ii.from(e).subtract(this.center),r=this.halfAxes,s=r.getColumn(0,oi),n=r.getColumn(1,ai),i=r.getColumn(2,ci),o=s.magnitude(),a=n.magnitude(),c=i.magnitude();s.normalize(),n.normalize(),i.normalize();let u,h=0;return u=Math.abs(t.dot(s))-o,u>0&&(h+=u*u),u=Math.abs(t.dot(n))-a,u>0&&(h+=u*u),u=Math.abs(t.dot(i))-c,u>0&&(h+=u*u),h}computePlaneDistances(e,t,r=[-0,-0]){let s=Number.POSITIVE_INFINITY,n=Number.NEGATIVE_INFINITY;const i=this.center,o=this.halfAxes,a=o.getColumn(0,oi),c=o.getColumn(1,ai),u=o.getColumn(2,ci),h=ui.copy(a).add(c).add(u).add(i),l=hi.copy(h).subtract(e);let d=t.dot(l);return s=Math.min(d,s),n=Math.max(d,n),h.copy(i).add(a).add(c).subtract(u),l.copy(h).subtract(e),d=t.dot(l),s=Math.min(d,s),n=Math.max(d,n),h.copy(i).add(a).subtract(c).add(u),l.copy(h).subtract(e),d=t.dot(l),s=Math.min(d,s),n=Math.max(d,n),h.copy(i).add(a).subtract(c).subtract(u),l.copy(h).subtract(e),d=t.dot(l),s=Math.min(d,s),n=Math.max(d,n),i.copy(h).subtract(a).add(c).add(u),l.copy(h).subtract(e),d=t.dot(l),s=Math.min(d,s),n=Math.max(d,n),i.copy(h).subtract(a).add(c).subtract(u),l.copy(h).subtract(e),d=t.dot(l),s=Math.min(d,s),n=Math.max(d,n),i.copy(h).subtract(a).subtract(c).add(u),l.copy(h).subtract(e),d=t.dot(l),s=Math.min(d,s),n=Math.max(d,n),i.copy(h).subtract(a).subtract(c).subtract(u),l.copy(h).subtract(e),d=t.dot(l),s=Math.min(d,s),n=Math.max(d,n),r[0]=s,r[1]=n,r}transform(e){this.center.transformAsPoint(e);const t=this.halfAxes.getColumn(0,oi);t.transformAsPoint(e);const r=this.halfAxes.getColumn(1,ai);r.transformAsPoint(e);const s=this.halfAxes.getColumn(2,ci);return s.transformAsPoint(e),this.halfAxes=new ls([...t,...r,...s]),this}getTransform(){throw new Error("not implemented")}}const vi=new ss,_i=new ss;class Ei{constructor(e=[0,0,1],t=0){this.normal=new ss,this.distance=-0,this.fromNormalDistance(e,t)}fromNormalDistance(e,t){return br(Number.isFinite(t)),this.normal.from(e).normalize(),this.distance=t,this}fromPointNormal(e,t){e=vi.from(e),this.normal.from(t).normalize();const r=-this.normal.dot(e);return this.distance=r,this}fromCoefficients(e,t,r,s){return this.normal.set(e,t,r),br(Rr(this.normal.len(),1)),this.distance=s,this}clone(e){return new Ei(this.normal,this.distance)}equals(e){return Rr(this.distance,e.distance)&&Rr(this.normal,e.normal)}getPointDistance(e){return this.normal.dot(e)+this.distance}transform(e){const t=_i.copy(this.normal).transformAsVector(e).normalize(),r=this.normal.scale(-this.distance).transform(e);return this.fromPointNormal(r,t)}projectPointOntoPlane(e,t=[0,0,0]){e=vi.from(e);const r=this.getPointDistance(e),s=_i.copy(this.normal).scale(r);return e.subtract(s).to(t)}}const xi=[new ss([1,0,0]),new ss([0,1,0]),new ss([0,0,1])],Si=new ss,Ai=new ss;new Ei(new ss(1,0,0),0);class Mi{static get MASK_OUTSIDE(){return 4294967295}static get MASK_INSIDE(){return 0}static get MASK_INDETERMINATE(){return 2147483647}constructor(e=[]){this.planes=e,br(this.planes.every((e=>e instanceof Ei)))}fromBoundingSphere(e){this.planes.length=2*xi.length;const t=e.center,r=e.radius;let s=0;for(const e of xi){let n=this.planes[s],i=this.planes[s+1];n||(n=this.planes[s]=new Ei),i||(i=this.planes[s+1]=new Ei);const o=Si.copy(e).scale(-r).add(t);e.dot(o),n.fromPointNormal(o,e);const a=Si.copy(e).scale(r).add(t),c=Ai.copy(e).negate();c.dot(a),i.fromPointNormal(a,c),s+=2}return this}computeVisibility(e){br(e);let t=ei.INSIDE;for(const r of this.planes){switch(e.intersectPlane(r)){case ei.OUTSIDE:return ei.OUTSIDE;case ei.INTERSECTING:t=ei.INTERSECTING}}return t}computeVisibilityWithPlaneMask(e,t){if(br(e,"boundingVolume is required."),br(Number.isFinite(t),"parentPlaneMask is required."),t===Mi.MASK_OUTSIDE||t===Mi.MASK_INSIDE)return t;let r=Mi.MASK_INSIDE;const s=this.planes;for(let n=0;n<this.planes.length;++n){const i=n<31?1<<n:0;if(n<31&&0==(t&i))continue;const o=s[n],a=e.intersectPlane(o);if(a===ei.OUTSIDE)return Mi.MASK_OUTSIDE;a===ei.INTERSECTING&&(r|=i)}return r}}const Ri=new ss,Oi=new ss,Ii=new ss,Ni=new ss,Li=new ss;class Ci{constructor(e={}){e={near:1,far:5e8,...e},this.left=e.left,this._left=void 0,this.right=e.right,this._right=void 0,this.top=e.top,this._top=void 0,this.bottom=e.bottom,this._bottom=void 0,this.near=e.near,this._near=this.near,this.far=e.far,this._far=this.far,this._cullingVolume=new Mi([new Ei,new Ei,new Ei,new Ei,new Ei,new Ei]),this._perspectiveMatrix=new Ls,this._infinitePerspective=new Ls}clone(){return new Ci({right:this.right,left:this.left,top:this.top,bottom:this.bottom,near:this.near,far:this.far})}equals(e){return e&&e instanceof Ci&&this.right===e.right&&this.left===e.left&&this.top===e.top&&this.bottom===e.bottom&&this.near===e.near&&this.far===e.far}get projectionMatrix(){return Pi(this),this._perspectiveMatrix}get infiniteProjectionMatrix(){return Pi(this),this._infinitePerspective}computeCullingVolume(e,t,r){br(e,"position is required."),br(t,"direction is required."),br(r,"up is required.");const s=this._cullingVolume.planes;r=Ri.copy(r).normalize();const n=Oi.copy(t).cross(r).normalize(),i=Ii.copy(t).multiplyByScalar(this.near).add(e),o=Ni.copy(t).multiplyByScalar(this.far).add(e);let a=Li;return a.copy(n).multiplyByScalar(this.left).add(i).subtract(e).cross(r),s[0].fromPointNormal(e,a),a.copy(n).multiplyByScalar(this.right).add(i).subtract(e).cross(r).negate(),s[1].fromPointNormal(e,a),a.copy(r).multiplyByScalar(this.bottom).add(i).subtract(e).cross(n).negate(),s[2].fromPointNormal(e,a),a.copy(r).multiplyByScalar(this.top).add(i).subtract(e).cross(n),s[3].fromPointNormal(e,a),a=(new ss).copy(t),s[4].fromPointNormal(i,a),a.negate(),s[5].fromPointNormal(o,a),this._cullingVolume}getPixelDimensions(e,t,r,s){Pi(this),br(Number.isFinite(e)&&Number.isFinite(t)),br(e>0),br(t>0),br(r>0),br(s);const n=1/this.near;let i=this.top*n;const o=2*r*i/t;i=this.right*n;const a=2*r*i/e;return s.x=a,s.y=o,s}}function Pi(e){br(Number.isFinite(e.right)&&Number.isFinite(e.left)&&Number.isFinite(e.top)&&Number.isFinite(e.bottom)&&Number.isFinite(e.near)&&Number.isFinite(e.far));const{top:t,bottom:r,right:s,left:n,near:i,far:o}=e;t===e._top&&r===e._bottom&&n===e._left&&s===e._right&&i===e._near&&o===e._far||(br(e.near>0&&e.near<e.far,"near must be greater than zero and less than far."),e._left=n,e._right=s,e._top=t,e._bottom=r,e._near=i,e._far=o,e._perspectiveMatrix=(new Ls).frustum({left:n,right:s,bottom:r,top:t,near:i,far:o}),e._infinitePerspective=(new Ls).frustum({left:n,right:s,bottom:r,top:t,near:i,far:1/0}))}class Ui{constructor(e={}){e={near:1,far:5e8,xOffset:0,yOffset:0,...e},this._offCenterFrustum=new Ci,this.fov=e.fov,this._fov=void 0,this._fovy=void 0,this._sseDenominator=void 0,this.aspectRatio=e.aspectRatio,this._aspectRatio=void 0,this.near=e.near,this._near=this.near,this.far=e.far,this._far=this.far,this.xOffset=e.xOffset,this._xOffset=this.xOffset,this.yOffset=e.yOffset,this._yOffset=this.yOffset}clone(){return new Ui({aspectRatio:this.aspectRatio,fov:this.fov,near:this.near,far:this.far})}equals(e){return null!=e&&e instanceof Ui&&(ki(this),ki(e),this.fov===e.fov&&this.aspectRatio===e.aspectRatio&&this.near===e.near&&this.far===e.far&&this._offCenterFrustum.equals(e._offCenterFrustum))}get projectionMatrix(){return ki(this),this._offCenterFrustum.projectionMatrix}get infiniteProjectionMatrix(){return ki(this),this._offCenterFrustum.infiniteProjectionMatrix}get fovy(){return ki(this),this._fovy}get sseDenominator(){return ki(this),this._sseDenominator}computeCullingVolume(e,t,r){return ki(this),this._offCenterFrustum.computeCullingVolume(e,t,r)}getPixelDimensions(e,t,r,s){return ki(this),this._offCenterFrustum.getPixelDimensions(e,t,r,s)}}function ki(e){br(Number.isFinite(e.fov)&&Number.isFinite(e.aspectRatio)&&Number.isFinite(e.near)&&Number.isFinite(e.far));const t=e._offCenterFrustum;e.fov===e._fov&&e.aspectRatio===e._aspectRatio&&e.near===e._near&&e.far===e._far&&e.xOffset===e._xOffset&&e.yOffset===e._yOffset||(br(e.fov>=0&&e.fov<Math.PI),br(e.aspectRatio>0),br(e.near>=0&&e.near<e.far),e._aspectRatio=e.aspectRatio,e._fov=e.fov,e._fovy=e.aspectRatio<=1?e.fov:2*Math.atan(Math.tan(.5*e.fov)/e.aspectRatio),e._near=e.near,e._far=e.far,e._sseDenominator=2*Math.tan(.5*e._fovy),e._xOffset=e.xOffset,e._yOffset=e.yOffset,t.top=e.near*Math.tan(.5*e._fovy),t.bottom=-t.top,t.right=e.aspectRatio*t.top,t.left=-t.right,t.near=e.near,t.far=e.far,t.right+=e.xOffset,t.left+=e.xOffset,t.top+=e.yOffset,t.bottom+=e.yOffset)}new ss,new ss,new ss,new ss,new ss,new ss,new ss,new ss,new ss,new ss,new ss,new ss,new ls,new ls,new ls,new ls,new ls,new ss,new ss,new ss,new ss,new ss,new ls,new ls,new ls;const Di=new ss,ji=new ss,Bi=new Mi([new Ei,new Ei,new Ei,new Ei,new Ei,new Ei]);function Fi(e,t){const{cameraDirection:r,cameraUp:s,height:n}=e,{metersPerUnit:i}=e.distanceScales,o=[e.longitude,e.latitude,0],a=Qn.WGS84.cartographicToCartesian(o,new ss),c=Qn.WGS84.eastNorthUpToFixedFrame(a),u=e.unprojectPosition(e.cameraPosition),h=Qn.WGS84.cartographicToCartesian(u,new ss),l=new ss(c.transformAsVector(new ss(r).scale(i))).normalize(),d=new ss(c.transformAsVector(new ss(s).scale(i))).normalize();return function(e,t){const r=e.getFrustumPlanes();let s=0;for(const n in r){const i=r[n],o=i.normal.dot(e.center);ji.copy(i.normal).scale(i.distance-o).add(e.center);const a=e.unprojectPosition(ji),c=Qn.WGS84.cartographicToCartesian(a,new ss);Bi.planes[s++].fromPointNormal(c,Di.copy(t).subtract(c))}}(e,a),{camera:{position:h,direction:l,up:d},viewport:e,height:n,cullingVolume:Bi,frameNumber:t,sseDenominator:1.15}}const Vi=new ss;function qi(e){const{halfAxes:t,radius:r,width:s,height:n}=e;if(t){const e=function(e){e.getColumn(0,Vi);const t=e.getColumn(1),r=e.getColumn(2),s=Vi.add(t).add(r);return s.len()}(t);return Math.log2(6356752.314245179/e)}if(r)return Math.log2(6356752.314245179/r);if(n&&s){return(Math.log2(6378137/s)+Math.log2(6378137/n))/2}return 1}const zi=0,Gi=1,Hi=3,$i=4,Wi=5,Ki=1,Qi=2,Xi="empty",Yi="scenegraph",Zi="pointcloud",Ji="mesh",eo="I3S",to="TILES3D",ro="geometricError",so=1;function no(e){return null!=e}const io=new ss,oo=new ss,ao=new ss;function co(e,t,r){if(Te(e,"3D Tile: boundingVolume must be defined"),e.box)return function(e,t,r){const s=new ss(e[0],e[1],e[2]);t.transform(s,s);let n=[];if(10===e.length){const t=e.slice(3,6),r=new Xs;r.fromArray(e,6);const s=new ss([1,0,0]),i=new ss([0,1,0]),o=new ss([0,0,1]);s.transformByQuaternion(r),s.scale(t[0]),i.transformByQuaternion(r),i.scale(t[1]),o.transformByQuaternion(r),o.scale(t[2]),n=[...s.toArray(),...i.toArray(),...o.toArray()]}else n=[...e.slice(3,6),...e.slice(6,9),...e.slice(9,12)];const i=t.transformAsVector(n.slice(0,3)),o=t.transformAsVector(n.slice(3,6)),a=t.transformAsVector(n.slice(6,9)),c=new ls([i[0],i[1],i[2],o[0],o[1],o[2],a[0],a[1],a[2]]);if(no(r))return r.center=s,r.halfAxes=c,r;return new Ti(s,c)}(e.box,t,r);if(e.region){const[t,r,s,n,i,o]=e.region,a=Qn.WGS84.cartographicToCartesian([Mr(t),Mr(n),i],oo),c=Qn.WGS84.cartographicToCartesian([Mr(s),Mr(r),o],ao),u=(new ss).addVectors(a,c).multiplyScalar(.5),h=(new ss).subVectors(a,c).len()/2;return uo([u[0],u[1],u[2],h],new Ls)}if(e.sphere)return uo(e.sphere,t,r);throw new Error("3D Tile: boundingVolume must contain a sphere, region, or box")}function uo(e,t,r){const s=new ss(e[0],e[1],e[2]);t.transform(s,s);const n=t.getScale(io),i=Math.max(Math.max(n[0],n[1]),n[2]),o=e[3]*i;return no(r)?(r.center=s,r.radius=o,r):new si(s,o)}function ho(e,t){if(e.dynamicScreenSpaceError&&e.dynamicScreenSpaceErrorComputedDensity){const r=e.dynamicScreenSpaceErrorComputedDensity,s=e.dynamicScreenSpaceErrorFactor;return function(e,t){const r=e*t;return 1-Math.exp(-r*r)}(t,r)*s}return 0}new ss,new ss,new Ls,new ss,new ss,new ss;const lo=Math.PI/2;function fo([e,t,r]){const s=Ar(e),n=Ar(t),i=1+r/6378137,o=i*Math.cos(n);return[e=o*Math.cos(s),t=o*Math.sin(s),r=i*Math.sin(n)]}function po(e,t){const[r,s,n=0]=e,[i,o,a=0]=t,c=fo([i,o,a]),u=fo([r,s,n]),h=u[0]-c[0],l=u[1]-c[1],d=u[2]-c[2];return h*h+l*l+d*d}function mo(e,t){const r=t.viewport,s=e.header.mbs[1],n=[e.header.mbs[0],s,e.header.mbs[2]],i=e.header.mbs[3]/6378137,o=po(r.unprojectPosition(r.cameraPosition),n)-i*i;if(o<=0)return 170141175e30;return function(e){const{projectionMatrix:t}=e.viewport;return t[5]}(t)*i/Math.sqrt(o)*300}class go{constructor(e=0){this._array=new Array(e),this._map=new Map,this._length=e}get length(){return this._length}set length(e){this._length=e,e>this._array.length&&(this._array.length=e)}get values(){return this._array}get(e){return Te(e<this._array.length),this._array[e]}set(e,t){Te(e>=0),e>=this.length&&(this.length=e+1),this._map.has(this._array[e])&&this._map.delete(this._array[e]),this._array[e]=t,this._map.set(t,e)}delete(e){const t=this._map.get(e);t>=0&&(this._array.splice(t,1),this._map.delete(e),this.length--)}peek(){return this._array[this._length-1]}push(e){if(!this._map.has(e)){const t=this.length++;this._array[t]=e,this._map.set(e,t)}}pop(){const e=this._array[--this.length];return this._map.delete(e),e}reserve(e){Te(e>=0),e>this._array.length&&(this._array.length=e)}resize(e){Te(e>=0),this.length=e}trim(e){null==e&&(e=this.length),this._array.length=e}reset(){this._array=[],this._map=new Map,this._length=0}find(e){return this._map.has(e)}}const yo={loadSiblings:!1,skipLevelOfDetail:!1,maximumScreenSpaceError:2,updateTransforms:!0,onTraversalEnd:()=>{},viewportTraversersMap:{},basePath:""};class wo{constructor(e){Le(this,"options",void 0),Le(this,"root",void 0),Le(this,"requestedTiles",void 0),Le(this,"selectedTiles",void 0),Le(this,"emptyTiles",void 0),Le(this,"_traversalStack",void 0),Le(this,"_emptyTraversalStack",void 0),Le(this,"_frameNumber",void 0),this.options={...yo,...e},this._traversalStack=new go,this._emptyTraversalStack=new go,this._frameNumber=null,this.root=null,this.selectedTiles={},this.requestedTiles={},this.emptyTiles={}}traverse(e,t,r){this.root=e,this.options={...this.options,...r},this.reset(),this.updateTile(e,t),this._frameNumber=t.frameNumber,this.executeTraversal(e,t)}reset(){this.requestedTiles={},this.selectedTiles={},this.emptyTiles={},this._traversalStack.reset(),this._emptyTraversalStack.reset()}executeTraversal(e,t){const r=this._traversalStack;for(e._selectionDepth=1,r.push(e);r.length>0;){const e=r.pop();let s=!1;this.canTraverse(e,t)&&(this.updateChildTiles(e,t),s=this.updateAndPushChildren(e,t,r,e.hasRenderContent?e._selectionDepth+1:e._selectionDepth));const n=e.parent,i=Boolean(!n||n._shouldRefine),o=!s;e.hasRenderContent?e.refine===Ki?(this.loadTile(e,t),this.selectTile(e,t)):e.refine===Qi&&(this.loadTile(e,t),o&&this.selectTile(e,t)):(this.emptyTiles[e.id]=e,this.loadTile(e,t),o&&this.selectTile(e,t)),this.touchTile(e,t),e._shouldRefine=s&&i}this.options.onTraversalEnd(t)}updateChildTiles(e,t){const r=e.children;for(const e of r)this.updateTile(e,t);return!0}updateAndPushChildren(e,t,r,s){const{loadSiblings:n,skipLevelOfDetail:i}=this.options,o=e.children;o.sort(this.compareDistanceToCamera.bind(this));const a=e.refine===Qi&&e.hasRenderContent&&!i;let c=!1,u=!0;for(const e of o)if(e._selectionDepth=s,e.isVisibleAndInRequestVolume?(r.find(e)&&r.delete(e),r.push(e),c=!0):(a||n)&&(this.loadTile(e,t),this.touchTile(e,t)),a){let r;if(r=!!e._inRequestVolume&&(e.hasRenderContent?e.contentAvailable:this.executeEmptyTraversal(e,t)),u=u&&r,!u)return!1}return c||(u=!1),u}updateTile(e,t){this.updateTileVisibility(e,t)}selectTile(e,t){this.shouldSelectTile(e)&&(e._selectedFrame=t.frameNumber,this.selectedTiles[e.id]=e)}loadTile(e,t){this.shouldLoadTile(e)&&(e._requestedFrame=t.frameNumber,e._priority=e._getPriority(),this.requestedTiles[e.id]=e)}touchTile(e,t){e.tileset._cache.touch(e),e._touchedFrame=t.frameNumber}canTraverse(e,t,r=!1,s=!1){return!!e.hasChildren&&(e.hasTilesetContent?!e.contentExpired:!(!s&&!e.isVisibleAndInRequestVolume)&&this.shouldRefine(e,t,r))}shouldLoadTile(e){return e.hasUnloadedContent||e.contentExpired}shouldSelectTile(e){return e.contentAvailable&&!this.options.skipLevelOfDetail}shouldRefine(e,t,r){let s=e._screenSpaceError;return r&&(s=e.getScreenSpaceError(t,!0)),s>this.options.maximumScreenSpaceError}updateTileVisibility(e,t){const r=[];if(this.options.viewportTraversersMap)for(const e in this.options.viewportTraversersMap){this.options.viewportTraversersMap[e]===t.viewport.id&&r.push(e)}else r.push(t.viewport.id);e.updateVisibility(t,r)}compareDistanceToCamera(e,t){return e._distanceToCamera-t._distanceToCamera}anyChildrenVisible(e,t){let r=!1;for(const s of e.children)s.updateVisibility(t),r=r||s.isVisibleAndInRequestVolume;return r}executeEmptyTraversal(e,t){let r=!0;const s=this._emptyTraversalStack;for(s.push(e);s.length>0&&r;){const e=s.pop();this.updateTile(e,t),e.isVisibleAndInRequestVolume||this.loadTile(e,t),this.touchTile(e,t);if(!e.hasRenderContent&&this.canTraverse(e,t,!1,!0)){const t=e.children;for(const e of t)s.find(e)&&s.delete(e),s.push(e)}else e.contentAvailable||(r=!1)}return r}}const bo=new ss;class To{constructor(e,t,r,s=""){Le(this,"tileset",void 0),Le(this,"header",void 0),Le(this,"id",void 0),Le(this,"url",void 0),Le(this,"parent",void 0),Le(this,"refine",void 0),Le(this,"type",void 0),Le(this,"contentUrl",void 0),Le(this,"lodMetricType",void 0),Le(this,"lodMetricValue",void 0),Le(this,"boundingVolume",void 0),Le(this,"content",void 0),Le(this,"contentState",void 0),Le(this,"gpuMemoryUsageInBytes",void 0),Le(this,"children",void 0),Le(this,"depth",void 0),Le(this,"viewportIds",void 0),Le(this,"transform",void 0),Le(this,"userData",void 0),Le(this,"computedTransform",void 0),Le(this,"hasEmptyContent",void 0),Le(this,"hasTilesetContent",void 0),Le(this,"traverser",void 0),Le(this,"_cacheNode",void 0),Le(this,"_frameNumber",void 0),Le(this,"_lodJudge",void 0),Le(this,"_expireDate",void 0),Le(this,"_expiredContent",void 0),Le(this,"_shouldRefine",void 0),Le(this,"_distanceToCamera",void 0),Le(this,"_centerZDepth",void 0),Le(this,"_screenSpaceError",void 0),Le(this,"_visibilityPlaneMask",void 0),Le(this,"_visible",void 0),Le(this,"_inRequestVolume",void 0),Le(this,"_stackLength",void 0),Le(this,"_selectionDepth",void 0),Le(this,"_touchedFrame",void 0),Le(this,"_visitedFrame",void 0),Le(this,"_selectedFrame",void 0),Le(this,"_requestedFrame",void 0),Le(this,"_priority",void 0),Le(this,"_contentBoundingVolume",void 0),Le(this,"_viewerRequestVolume",void 0),Le(this,"_initialTransform",void 0),this.header=t,this.tileset=e,this.id=s||t.id,this.url=t.url,this.parent=r,this.refine=this._getRefine(t.refine),this.type=t.type,this.contentUrl=t.contentUrl,this.lodMetricType="geometricError",this.lodMetricValue=0,this.boundingVolume=null,this.content=null,this.contentState=zi,this.gpuMemoryUsageInBytes=0,this.children=[],this.hasEmptyContent=!1,this.hasTilesetContent=!1,this.depth=0,this.viewportIds=[],this.userData={},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 wo({}),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 Ls,this.transform=new Ls,this._initializeLodMetric(t),this._initializeTransforms(t),this._initializeBoundingVolumes(t),this._initializeContent(t),this._initializeRenderingState(t),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===Hi||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===zi}get contentExpired(){return this.contentState===$i}get contentFailed(){return this.contentState===Wi}getScreenSpaceError(e,t){switch(this.tileset.type){case eo:return mo(this,e);case to:return function(e,t,r){const s=e.tileset,n=e.parent&&e.parent.lodMetricValue||e.lodMetricValue,i=r?n:e.lodMetricValue;if(0===i)return 0;const o=Math.max(e._distanceToCamera,1e-7),{height:a,sseDenominator:c}=t,{viewDistanceScale:u}=s.options;let h=i*a*(u||1)/(o*c);return h-=ho(s,o),h}(this,e,t);default:throw new Error("Unsupported tileset type")}}_getPriority(){const e=this.tileset._traverser,{skipLevelOfDetail:t}=e.options,r=this.refine===Ki||t;if(r&&!this.isVisible&&void 0!==this._visible)return-1;if(this.tileset._frameNumber-this._touchedFrame>=1)return-1;if(this.contentState===zi)return-1;const s=this.parent,n=s&&(!r||0===this._screenSpaceError||s.hasTilesetContent)?s._screenSpaceError:this._screenSpaceError,i=e.root?e.root._screenSpaceError:0;return Math.max(i-n,0)}async loadContent(){if(this.hasEmptyContent)return!1;if(this.content)return!0;this.contentExpired&&(this._expireDate=null),this.contentState=Gi;const e=await this.tileset._requestScheduler.scheduleRequest(this.id,this._getPriority.bind(this));if(!e)return this.contentState=zi,!1;try{const t=this.tileset.getTileUrl(this.contentUrl),r=this.tileset.loader,s={...this.tileset.loadOptions,[r.id]:{...this.tileset.loadOptions[r.id],isTileset:"json"===this.type,...this._getLoaderSpecificOptions(r.id)}};return this.content=await wr(t,r,s),this.tileset.options.contentLoader&&await this.tileset.options.contentLoader(this),this._isTileset()&&this.tileset._initializeTileHeaders(this.content,this),this.contentState=Hi,this._onContentLoaded(),!0}catch(e){throw this.contentState=Wi,e}finally{e.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=zi,!0}updateVisibility(e,t){if(this._frameNumber===e.frameNumber)return;const r=this.parent,s=r?r._visibilityPlaneMask:Mi.MASK_INDETERMINATE;if(this.tileset._traverser.options.updateTransforms){const e=r?r.computedTransform:this.tileset.modelMatrix;this._updateTransform(e)}this._distanceToCamera=this.distanceToTile(e),this._screenSpaceError=this.getScreenSpaceError(e,!1),this._visibilityPlaneMask=this.visibility(e,s),this._visible=this._visibilityPlaneMask!==Mi.MASK_OUTSIDE,this._inRequestVolume=this.insideViewerRequestVolume(e),this._frameNumber=e.frameNumber,this.viewportIds=t}visibility(e,t){const{cullingVolume:r}=e,{boundingVolume:s}=this;return r.computeVisibilityWithPlaneMask(s,t)}contentVisibility(){return!0}distanceToTile(e){const t=this.boundingVolume;return Math.sqrt(Math.max(t.distanceSquaredTo(e.camera.position),0))}cameraSpaceZDepth({camera:e}){const t=this.boundingVolume;return bo.subVectors(t.center,e.position),e.direction.dot(bo)}insideViewerRequestVolume(e){const t=this._viewerRequestVolume;return!t||t.distanceSquaredTo(e.camera.position)<=0}updateExpiration(){if(null!=this._expireDate&&this.contentReady&&!this.hasEmptyContent){const e=Date.now();Date.lessThan(this._expireDate,e)&&(this.contentState=$i,this._expiredContent=this.content)}}get extras(){return this.header.extras}_initializeLodMetric(e){"lodMetricType"in e?this.lodMetricType=e.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 e?this.lodMetricValue=e.lodMetricValue:(this.lodMetricValue=this.parent&&this.parent.lodMetricValue||this.tileset.lodMetricValue,console.warn("3D Tile: Required prop lodMetricValue is undefined. Using parent lodMetricValue"))}_initializeTransforms(e){this.transform=e.transform?new Ls(e.transform):new Ls;const t=this.parent,r=this.tileset,s=t&&t.computedTransform?t.computedTransform.clone():r.modelMatrix.clone();this.computedTransform=new Ls(s).multiplyRight(this.transform);const n=t&&t._initialTransform?t._initialTransform.clone():new Ls;this._initialTransform=new Ls(n).multiplyRight(this.transform)}_initializeBoundingVolumes(e){this._contentBoundingVolume=null,this._viewerRequestVolume=null,this._updateBoundingVolume(e)}_initializeContent(e){this.content={_tileset:this.tileset,_tile:this},this.hasEmptyContent=!0,this.contentState=zi,this.hasTilesetContent=!1,e.contentUrl&&(this.content=null,this.hasEmptyContent=!1)}_initializeRenderingState(e){this.depth=e.level||(this.parent?this.parent.depth+1:0),this._shouldRefine=!1,this._distanceToCamera=0,this._centerZDepth=0,this._screenSpaceError=0,this._visibilityPlaneMask=Mi.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(e){return e||this.parent&&this.parent.refine||Qi}_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(e){this.boundingVolume=co(e.boundingVolume,this.computedTransform,this.boundingVolume);const t=e.content;t&&(t.boundingVolume&&(this._contentBoundingVolume=co(t.boundingVolume,this.computedTransform,this._contentBoundingVolume)),e.viewerRequestVolume&&(this._viewerRequestVolume=co(e.viewerRequestVolume,this.computedTransform,this._viewerRequestVolume)))}_updateTransform(e=new Ls){const t=e.clone().multiplyRight(this.transform);!t.equals(this.computedTransform)&&(this.computedTransform=t,this._updateBoundingVolume(this.header))}_getLoaderSpecificOptions(e){switch(e){case"i3s":return{...this.tileset.options.i3s,tile:this.header,tileset:this.tileset.tileset,isTileHeader:!1};case"3d-tiles":case"cesium-ion":default:return{assetGltfUpAxis:(t=this.tileset.tileset).asset&&t.asset.gltfUpAxis||"Y"}}var t}}class vo extends wo{compareDistanceToCamera(e,t){return 0===t._distanceToCamera&&0===e._distanceToCamera?t._centerZDepth-e._centerZDepth:t._distanceToCamera-e._distanceToCamera}updateTileVisibility(e,t){if(super.updateTileVisibility(e,t),!e.isVisibleAndInRequestVolume)return;const r=e.children.length>0;if(e.hasTilesetContent&&r){const r=e.children[0];return this.updateTileVisibility(r,t),void(e._visible=r._visible)}if(this.meetsScreenSpaceErrorEarly(e,t))return void(e._visible=!1);const s=e.refine===Qi,n=e._optimChildrenWithinParent===so;s&&n&&r&&!this.anyChildrenVisible(e,t)&&(e._visible=!1)}meetsScreenSpaceErrorEarly(e,t){const{parent:r}=e;return!(!r||r.hasTilesetContent||r.refine!==Ki)&&!this.shouldRefine(e,t,!0)}}const _o="REQUESTED",Eo="COMPLETED",xo="ERROR";class So{constructor(){Le(this,"_statusMap",void 0),this._statusMap={}}add(e,t,r,s){this._statusMap[t]||(this._statusMap[t]={request:e,callback:r,key:t,frameState:s,status:_o},e().then((e=>{this._statusMap[t].status=Eo,this._statusMap[t].callback(e,s)})).catch((e=>{this._statusMap[t].status=xo,r(e)})))}update(e,t){this._statusMap[e]&&(this._statusMap[e].frameState=t)}find(e){return this._statusMap[e]}}class Ao extends wo{constructor(e){super(e),Le(this,"_tileManager",void 0),this._tileManager=new So}shouldRefine(e,t){return e._lodJudge=function(e,t){const r=t.viewport,s=r.metersPerPixel,n=e.header.mbs[1],i=e.header.mbs[0],o=e.header.mbs[2],a=e.header.mbs[3],{height:c,width:u,latitude:h,longitude:l}=r,d=[l,h],f=[i,n,o],p=[l,n],m=[i,h],g=Math.sqrt(c*c+u*u)*s[0],y=.5*c+a/6378137,w=.5*u+a/6378137;if(po(d,f)>g+a/6378137)return"OUT";if(po(d,p)>y)return"OUT";if(po(d,m)>w)return"OUT";if(0===e.lodMetricValue)return"DIG";let b=mo(e,t);return b*=lo,b<.5?"OUT":!e.header.children||b<=e.lodMetricValue?"DRAW":e.header.children?"DIG":"OUT"}(e,t),"DIG"===e._lodJudge}updateChildTiles(e,t){const r=e.header.children||[],s=e.children,n=e.tileset;for(const i of r){const r=`${i.id}-${t.viewport.id}`,o=s&&s.find((e=>e.id===r));if(o)o&&this.updateTile(o,t);else{let s=()=>this._loadTile(i.id,n);this._tileManager.find(r)?this._tileManager.update(r,t):(n.tileset.nodePages&&(s=()=>n.tileset.nodePagesTile.formTileFromNodePages(i.id)),this._tileManager.add(s,r,(t=>this._onTileLoad(t,e,r)),t))}}return!1}async _loadTile(e,t){const{loader:r}=t,s=t.getTileUrl(`${t.url}/nodes/${e}`),n={...t.loadOptions,i3s:{...t.loadOptions.i3s,isTileHeader:!0,loadContent:!1}};return await wr(s,r,n)}_onTileLoad(e,t,r){const s=new To(t.tileset,e,t,r);t.children.push(s);const n=this._tileManager.find(s.id).frameState;this.updateTile(s,n),this._frameNumber===n.frameNumber&&this.executeTraversal(s,n)}}const Mo={description:"",ellipsoid:Qn.WGS84,modelMatrix:new Ls,throttleRequests:!0,maxRequests:64,maximumMemoryUsage:32,onTileLoad:()=>{},onTileUnload:()=>{},onTileError:()=>{},onTraversalComplete:e=>e,contentLoader:void 0,viewDistanceScale:1,maximumScreenSpaceError:8,loadTiles:!0,updateTransforms:!0,viewportTraversersMap:null,loadOptions:{fetch:{}},attributions:[],basePath:"",i3s:{}};class Ro{constructor(e,t){Le(this,"options",void 0),Le(this,"loadOptions",void 0),Le(this,"type",void 0),Le(this,"tileset",void 0),Le(this,"loader",void 0),Le(this,"url",void 0),Le(this,"basePath",void 0),Le(this,"modelMatrix",void 0),Le(this,"ellipsoid",void 0),Le(this,"lodMetricType",void 0),Le(this,"lodMetricValue",void 0),Le(this,"refine",void 0),Le(this,"root",void 0),Le(this,"roots",void 0),Le(this,"asset",void 0),Le(this,"description",void 0),Le(this,"properties",void 0),Le(this,"extras",void 0),Le(this,"attributions",void 0),Le(this,"credits",void 0),Le(this,"stats",void 0),Le(this,"traverseCounter",void 0),Le(this,"geometricError",void 0),Le(this,"selectedTiles",void 0),Le(this,"cartographicCenter",void 0),Le(this,"cartesianCenter",void 0),Le(this,"zoom",void 0),Le(this,"boundingVolume",void 0),Le(this,"gpuMemoryUsageInBytes",void 0),Le(this,"dynamicScreenSpaceErrorComputedDensity",void 0),Le(this,"_traverser",void 0),Le(this,"_cache",void 0),Le(this,"_requestScheduler",void 0),Le(this,"_frameNumber",void 0),Le(this,"_queryParamsString",void 0),Le(this,"_queryParams",void 0),Le(this,"_extensionsUsed",void 0),Le(this,"_tiles",void 0),Le(this,"_pendingCount",void 0),Le(this,"lastUpdatedVieports",void 0),Le(this,"_requestedTiles",void 0),Le(this,"_emptyTiles",void 0),Le(this,"frameStateData",void 0),Le(this,"maximumMemoryUsage",void 0),Te(e),this.options={...Mo,...t},this.tileset=e,this.loader=e.loader,this.type=e.type,this.url=e.url,this.basePath=e.basePath||at(this.url),this.modelMatrix=this.options.modelMatrix,this.ellipsoid=this.options.ellipsoid,this.lodMetricType=e.lodMetricType,this.lodMetricValue=e.lodMetricValue,this.refine=e.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 Jn,this._requestScheduler=new ot({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 nt({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(e)}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(e){const t=[];for(const r of Object.keys(e))t.push(`${r}=${e[r]}`);switch(t.length){case 0:return"";case 1:return`?${t[0]}`;default:return`?${t.join("&")}`}}(this._queryParams)),this._queryParamsString}setProps(e){this.options={...this.options,...e}}setOptions(e){this.options={...this.options,...e}}getTileUrl(e){return e.startsWith("data:")?e:`${e}${this.queryParams}`}hasExtension(e){return Boolean(this._extensionsUsed&&this._extensionsUsed.indexOf(e)>-1)}update(e){if("loadTiles"in this.options&&!this.options.loadTiles)return;if(this.traverseCounter>0)return;!e&&this.lastUpdatedVieports?e=this.lastUpdatedVieports:this.lastUpdatedVieports=e,e instanceof Array||(e=[e]),this._cache.reset(),this._frameNumber++,this.traverseCounter=e.length;const t=[];for(const r of e){const e=r.id;this._needTraverse(e)?t.push(e):this.traverseCounter--}for(const r of e){const e=r.id;if(this.roots[e]||(this.roots[e]=this._initializeTileHeaders(this.tileset,null)),!t.includes(e))continue;const s=Fi(r,this._frameNumber);this._traverser.traverse(this.roots[e],s,this.options)}}_needTraverse(e){let t=e;return this.options.viewportTraversersMap&&(t=this.options.viewportTraversersMap[e]),t===e}_onTraversalEnd(e){const t=e.viewport.id;this.frameStateData[t]||(this.frameStateData[t]={selectedTiles:[],_requestedTiles:[],_emptyTiles:[]});const r=this.frameStateData[t],s=Object.values(this._traverser.selectedTiles);r.selectedTiles=s,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 e in this.frameStateData){const t=this.frameStateData[e];this.selectedTiles=this.selectedTiles.concat(t.selectedTiles),this._requestedTiles=this._requestedTiles.concat(t._requestedTiles),this._emptyTiles=this._emptyTiles.concat(t._emptyTiles)}this.selectedTiles=this.options.onTraversalComplete(this.selectedTiles);for(const e of this.selectedTiles)this._tiles[e.id]=e;this._loadTiles(),this._unloadTiles(),this._updateStats()}_tilesChanged(e,t){if(e.length!==t.length)return!0;const r=new Set(e.map((e=>e.id))),s=new Set(t.map((e=>e.id)));let n=e.filter((e=>!s.has(e.id))).length>0;return n=n||t.filter((e=>!r.has(e.id))).length>0,n}_loadTiles(){for(const e of this._requestedTiles)e.contentUnloaded&&this._loadTile(e)}_unloadTiles(){this._cache.unloadTiles(this,((e,t)=>e._unloadTile(t)))}_updateStats(){let e=0,t=0;for(const r of this.selectedTiles)r.contentAvailable&&r.content&&(e++,r.content.pointCount&&(t+=r.content.pointCount));this.stats.get("Tiles In View").count=this.selectedTiles.length,this.stats.get("Tiles To Render").count=e,this.stats.get("Points").count=t}_initializeTileSet(e){this.root=this._initializeTileHeaders(e,null),this.type===to&&this._initializeCesiumTileset(e),this.type===eo&&this._initializeI3STileset(),this._calculateViewProps()}_calculateViewProps(){const e=this.root;Te(e);const{center:t}=e.boundingVolume;if(!t)return console.warn("center was not pre-calculated for the root tile"),this.cartographicCenter=new ss,void(this.zoom=1);this.cartographicCenter=Qn.WGS84.cartesianToCartographic(t,new ss),this.cartesianCenter=t,this.zoom=qi(e.boundingVolume)}_initializeStats(){this.stats.get("Tiles In Tileset(s)"),this.stats.get("Tiles Loading"),this.stats.get("Tiles In Memory"),this.stats.get("Tiles In View"),this.stats.get("Tiles To Render"),this.stats.get("Tiles Loaded"),this.stats.get("Tiles Unloaded"),this.stats.get("Failed Tile Loads"),this.stats.get("Points","memory"),this.stats.get("Tile Memory Use","memory")}_initializeTileHeaders(e,t){const r=new To(this,e.root,t);if(t&&(t.children.push(r),r.depth=t.depth+1),this.type===to){const e=[];for(e.push(r);e.length>0;){const t=e.pop();this.stats.get("Tiles In Tileset(s)").incrementCount();const r=t.header.children||[];for(const s of r){const r=new To(this,s,t);t.children.push(r),r.depth=t.depth+1,e.push(r)}}}return r}_initializeTraverser(){let e;switch(this.type){case to:e=vo;break;case eo:e=Ao;break;default:e=wo}return new e({basePath:this.basePath,onTraversalEnd:this._onTraversalEnd.bind(this)})}_destroyTileHeaders(e){this._destroySubtree(e)}async _loadTile(e){let t;try{this._onStartTileLoading(),t=await e.loadContent()}catch(t){this._onTileLoadError(e,t)}finally{this._onEndTileLoading(),this._onTileLoad(e,t)}}_onTileLoadError(e,t){this.stats.get("Failed Tile Loads").incrementCount();const r=t.message||t.toString(),s=e.url;console.error(`A 3D tile failed to load: ${e.url} ${r}`),this.options.onTileError(e,r,s)}_onTileLoad(e,t){t&&(e&&e.content&&function(e,t){Te(e),Te(t);const{rtcCenter:r,gltfUpAxis:s}=t,{computedTransform:n,boundingVolume:{center:i}}=e;let o=new Ls(n);switch(r&&o.translate(r),s){case"Z":break;case"Y":const e=(new Ls).rotateX(Math.PI/2);o=o.multiplyRight(e);break;case"X":const t=(new Ls).rotateY(-Math.PI/2);o=o.multiplyRight(t)}t.isQuantized&&o.translate(t.quantizedVolumeOffset).scale(t.quantizedVolumeScale);const a=new ss(i);t.cartesianModelMatrix=o,t.cartesianOrigin=a;const c=Qn.WGS84.cartesianToCartographic(a,new ss),u=Qn.WGS84.eastNorthUpToFixedFrame(a).invert();t.cartographicModelMatrix=u.multiplyRight(o),t.cartographicOrigin=c,t.modelMatrix=t.cartographicModelMatrix}(e,e.content),this._addTileToCache(e),this.options.onTileLoad(e))}_onStartTileLoading(){this._pendingCount++,this.stats.get("Tiles Loading").incrementCount()}_onEndTileLoading(){this._pendingCount--,this.stats.get("Tiles Loading").decrementCount()}_addTileToCache(e){this._cache.add(this,e,(t=>t._updateCacheStats(e)))}_updateCacheStats(e){this.stats.get("Tiles Loaded").incrementCount(),this.stats.get("Tiles In Memory").incrementCount(),this.gpuMemoryUsageInBytes+=e.content.byteLength||0,this.stats.get("Tile Memory Use").count=this.gpuMemoryUsageInBytes}_unloadTile(e){this.gpuMemoryUsageInBytes-=e.content&&e.content.byteLength||0,this.stats.get("Tiles In Memory").decrementCount(),this.stats.get("Tiles Unloaded").incrementCount(),this.stats.get("Tile Memory Use").count=this.gpuMemoryUsageInBytes,this.options.onTileUnload(e),e.unloadContent()}_destroy(){const e=[];for(this.root&&e.push(this.root);e.length>0;){const t=e.pop();for(const r of t.children)e.push(r);this._destroyTile(t)}this.root=null}_destroySubtree(e){const t=e,r=[];for(r.push(t);r.length>0;){e=r.pop();for(const t of e.children)r.push(t);e!==t&&this._destroyTile(e)}t.children=[]}_destroyTile(e){this._cache.unloadTile(this,e),this._unloadTile(e),e.destroy()}_initializeCesiumTileset(e){if(this.asset=e.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=e.properties,this.geometricError=e.geometricError,this._extensionsUsed=e.extensionsUsed,this.extras=e.extras}_initializeI3STileset(){this.loadOptions.i3s&&"token"in this.loadOptions.i3s&&(this._queryParams.token=this.loadOptions.i3s.token)}}const Oo="cmpt",Io="pnts",No="b3dm",Lo="i3dm";function Co(e,t,r){Te(e instanceof ArrayBuffer);const s=new TextDecoder("utf8"),n=new Uint8Array(e,t,r);return s.decode(n)}const Po={name:"Draco",id:"draco",module:"draco",version:"3.0.10",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 Uo{constructor(e,t){Le(this,"fields",void 0),Le(this,"metadata",void 0),function(e,t){if(!e)throw new Error(t||"loader assertion failed.")}(Array.isArray(e)),function(e){const t={};for(const r of e)t[r.name]&&console.warn("Schema: duplicated field name",r.name,r),t[r.name]=!0}(e),this.fields=e,this.metadata=t||new Map}compareTo(e){if(this.metadata!==e.metadata)return!1;if(this.fields.length!==e.fields.length)return!1;for(let t=0;t<this.fields.length;++t)if(!this.fields[t].compareTo(e.fields[t]))return!1;return!0}select(...e){const t=Object.create(null);for(const r of e)t[r]=!0;const r=this.fields.filter((e=>t[e.name]));return new Uo(r,this.metadata)}selectAt(...e){const t=e.map((e=>this.fields[e])).filter(Boolean);return new Uo(t,this.metadata)}assign(e){let t,r=this.metadata;if(e instanceof Uo){const s=e;t=s.fields,r=ko(ko(new Map,this.metadata),s.metadata)}else t=e;const s=Object.create(null);for(const e of this.fields)s[e.name]=e;for(const e of t)s[e.name]=e;const n=Object.values(s);return new Uo(n,r)}}function ko(e,t){return new Map([...e||new Map,...t||new Map])}class Do{constructor(e,t,r=!1,s=new Map){Le(this,"name",void 0),Le(this,"type",void 0),Le(this,"nullable",void 0),Le(this,"metadata",void 0),this.name=e,this.type=t,this.nullable=r,this.metadata=s}get typeId(){return this.type&&this.type.typeId}clone(){return new Do(this.name,this.type,this.nullable,this.metadata)}compareTo(e){return this.name===e.name&&this.type===e.type&&this.nullable===e.nullable&&this.metadata===e.metadata}toString(){return`${this.type}${this.nullable?", nullable":""}${this.metadata?`, metadata: ${this.metadata}`:""}`}}let jo,Bo,Fo,Vo;!function(e){e[e.NONE=0]="NONE",e[e.Null=1]="Null",e[e.Int=2]="Int",e[e.Float=3]="Float",e[e.Binary=4]="Binary",e[e.Utf8=5]="Utf8",e[e.Bool=6]="Bool",e[e.Decimal=7]="Decimal",e[e.Date=8]="Date",e[e.Time=9]="Time",e[e.Timestamp=10]="Timestamp",e[e.Interval=11]="Interval",e[e.List=12]="List",e[e.Struct=13]="Struct",e[e.Union=14]="Union",e[e.FixedSizeBinary=15]="FixedSizeBinary",e[e.FixedSizeList=16]="FixedSizeList",e[e.Map=17]="Map",e[e.Dictionary=-1]="Dictionary",e[e.Int8=-2]="Int8",e[e.Int16=-3]="Int16",e[e.Int32=-4]="Int32",e[e.Int64=-5]="Int64",e[e.Uint8=-6]="Uint8",e[e.Uint16=-7]="Uint16",e[e.Uint32=-8]="Uint32",e[e.Uint64=-9]="Uint64",e[e.Float16=-10]="Float16",e[e.Float32=-11]="Float32",e[e.Float64=-12]="Float64",e[e.DateDay=-13]="DateDay",e[e.DateMillisecond=-14]="DateMillisecond",e[e.TimestampSecond=-15]="TimestampSecond",e[e.TimestampMillisecond=-16]="TimestampMillisecond",e[e.TimestampMicrosecond=-17]="TimestampMicrosecond",e[e.TimestampNanosecond=-18]="TimestampNanosecond",e[e.TimeSecond=-19]="TimeSecond",e[e.TimeMillisecond=-20]="TimeMillisecond",e[e.TimeMicrosecond=-21]="TimeMicrosecond",e[e.TimeNanosecond=-22]="TimeNanosecond",e[e.DenseUnion=-23]="DenseUnion",e[e.SparseUnion=-24]="SparseUnion",e[e.IntervalDayTime=-25]="IntervalDayTime",e[e.IntervalYearMonth=-26]="IntervalYearMonth"}(jo||(jo={}));class qo{static isNull(e){return e&&e.typeId===jo.Null}static isInt(e){return e&&e.typeId===jo.Int}static isFloat(e){return e&&e.typeId===jo.Float}static isBinary(e){return e&&e.typeId===jo.Binary}static isUtf8(e){return e&&e.typeId===jo.Utf8}static isBool(e){return e&&e.typeId===jo.Bool}static isDecimal(e){return e&&e.typeId===jo.Decimal}static isDate(e){return e&&e.typeId===jo.Date}static isTime(e){return e&&e.typeId===jo.Time}static isTimestamp(e){return e&&e.typeId===jo.Timestamp}static isInterval(e){return e&&e.typeId===jo.Interval}static isList(e){return e&&e.typeId===jo.List}static isStruct(e){return e&&e.typeId===jo.Struct}static isUnion(e){return e&&e.typeId===jo.Union}static isFixedSizeBinary(e){return e&&e.typeId===jo.FixedSizeBinary}static isFixedSizeList(e){return e&&e.typeId===jo.FixedSizeList}static isMap(e){return e&&e.typeId===jo.Map}static isDictionary(e){return e&&e.typeId===jo.Dictionary}get typeId(){return jo.NONE}compareTo(e){return this===e}}Bo=Symbol.toStringTag;class zo extends qo{constructor(e,t){super(),Le(this,"isSigned",void 0),Le(this,"bitWidth",void 0),this.isSigned=e,this.bitWidth=t}get typeId(){return jo.Int}get[Bo](){return"Int"}toString(){return`${this.isSigned?"I":"Ui"}nt${this.bitWidth}`}}class Go extends zo{constructor(){super(!0,8)}}class Ho extends zo{constructor(){super(!0,16)}}class $o extends zo{constructor(){super(!0,32)}}class Wo extends zo{constructor(){super(!1,8)}}class Ko extends zo{constructor(){super(!1,16)}}class Qo extends zo{constructor(){super(!1,32)}}const Xo=32,Yo=64;Fo=Symbol.toStringTag;class Zo extends qo{constructor(e){super(),Le(this,"precision",void 0),this.precision=e}get typeId(){return jo.Float}get[Fo](){return"Float"}toString(){return`Float${this.precision}`}}class Jo extends Zo{constructor(){super(Xo)}}class ea extends Zo{constructor(){super(Yo)}}Vo=Symbol.toStringTag;class ta extends qo{constructor(e,t){super(),Le(this,"listSize",void 0),Le(this,"children",void 0),this.listSize=e,this.children=[t]}get typeId(){return jo.FixedSizeList}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get[Vo](){return"FixedSizeList"}toString(){return`FixedSizeList[${this.listSize}]<${this.valueType}>`}}function ra(e,t,r){const s=r?sa(r.metadata):void 0,n=function(e){switch(e.constructor){case Int8Array:return new Go;case Uint8Array:return new Wo;case Int16Array:return new Ho;case Uint16Array:return new Ko;case Int32Array:return new $o;case Uint32Array:return new Qo;case Float32Array:return new Jo;case Float64Array:return new ea;default:throw new Error("array type not supported")}}(t.value);return new Do(e,new ta(t.size,new Do("value",n)),!1,s)}function sa(e){const t=new Map;for(const r in e)t.set(`${r}.string`,JSON.stringify(e[r]));return t}const na={POSITION:"POSITION",NORMAL:"NORMAL",COLOR:"COLOR_0",TEX_COORD:"TEXCOORD_0"},ia={1:Int8Array,2:Uint8Array,3:Int16Array,4:Uint16Array,5:Int32Array,6:Uint32Array,9:Float32Array};class oa{constructor(e){Le(this,"draco",void 0),Le(this,"decoder",void 0),Le(this,"metadataQuerier",void 0),this.draco=e,this.decoder=new this.draco.Decoder,this.metadataQuerier=new this.draco.MetadataQuerier}destroy(){this.draco.destroy(this.decoder),this.draco.destroy(this.metadataQuerier)}parseSync(e,t={}){const r=new this.draco.DecoderBuffer;r.Init(new Int8Array(e),e.byteLength),this._disableAttributeTransforms(t);const s=this.decoder.GetEncodedGeometryType(r),n=s===this.draco.TRIANGULAR_MESH?new this.draco.Mesh:new this.draco.PointCloud;try{let e;switch(s){case this.draco.TRIANGULAR_MESH:e=this.decoder.DecodeBufferToMesh(r,n);break;case this.draco.POINT_CLOUD:e=this.decoder.DecodeBufferToPointCloud(r,n);break;default:throw new Error("DRACO: Unknown geometry type.")}if(!e.ok()||!n.ptr){const t=`DRACO decompression failed: ${e.error_msg()}`;throw new Error(t)}const i=this._getDracoLoaderData(n,s,t),o=this._getMeshData(n,i,t),a=function(e){let t=1/0,r=1/0,s=1/0,n=-1/0,i=-1/0,o=-1/0;const a=e.POSITION?e.POSITION.value:[],c=a&&a.length;for(let e=0;e<c;e+=3){const c=a[e],u=a[e+1],h=a[e+2];t=c<t?c:t,r=u<r?u:r,s=h<s?h:s,n=c>n?c:n,i=u>i?u:i,o=h>o?h:o}return[[t,r,s],[n,i,o]]}(o.attributes),c=function(e,t,r){const s=sa(t.metadata),n=[],i=function(e){const t={};for(const r in e){const s=e[r];t[s.name||"undefined"]=s}return t}(t.attributes);for(const t in e){const r=ra(t,e[t],i[t]);n.push(r)}if(r){const e=ra("indices",r);n.push(e)}return new Uo(n,s)}(o.attributes,i,o.indices);return{loader:"draco",loaderData:i,header:{vertexCount:n.num_points(),boundingBox:a},...o,schema:c}}finally{this.draco.destroy(r),n&&this.draco.destroy(n)}}_getDracoLoaderData(e,t,r){const s=this._getTopLevelMetadata(e),n=this._getDracoAttributes(e,r);return{geometry_type:t,num_attributes:e.num_attributes(),num_points:e.num_points(),num_faces:e instanceof this.draco.Mesh?e.num_faces():0,metadata:s,attributes:n}}_getDracoAttributes(e,t){const r={};for(let s=0;s<e.num_attributes();s++){const n=this.decoder.GetAttribute(e,s),i=this._getAttributeMetadata(e,s);r[n.unique_id()]={unique_id:n.unique_id(),attribute_type:n.attribute_type(),data_type:n.data_type(),num_components:n.num_components(),byte_offset:n.byte_offset(),byte_stride:n.byte_stride(),normalized:n.normalized(),attribute_index:s,metadata:i};const o=this._getQuantizationTransform(n,t);o&&(r[n.unique_id()].quantization_transform=o);const a=this._getOctahedronTransform(n,t);a&&(r[n.unique_id()].octahedron_transform=a)}return r}_getMeshData(e,t,r){const s=this._getMeshAttributes(t,e,r);if(!s.POSITION)throw new Error("DRACO: No position attribute found.");if(e instanceof this.draco.Mesh)switch(r.topology){case"triangle-strip":return{topology:"triangle-strip",mode:4,attributes:s,indices:{value:this._getTriangleStripIndices(e),size:1}};case"triangle-list":default:return{topology:"triangle-list",mode:5,attributes:s,indices:{value:this._getTriangleListIndices(e),size:1}}}return{topology:"point-list",mode:0,attributes:s}}_getMeshAttributes(e,t,r){const s={};for(const n of Object.values(e.attributes)){const e=this._deduceAttributeName(n,r);n.name=e;const{value:i,size:o}=this._getAttributeValues(t,n);s[e]={value:i,size:o,byteOffset:n.byte_offset,byteStride:n.byte_stride,normalized:n.normalized}}return s}_getTriangleListIndices(e){const t=3*e.num_faces(),r=4*t,s=this.draco._malloc(r);try{return this.decoder.GetTrianglesUInt32Array(e,r,s),new Uint32Array(this.draco.HEAPF32.buffer,s,t).slice()}finally{this.draco._free(s)}}_getTriangleStripIndices(e){const t=new this.draco.DracoInt32Array;try{return this.decoder.GetTriangleStripsFromMesh(e,t),function(e){const t=e.size(),r=new Int32Array(t);for(let s=0;s<t;s++)r[s]=e.GetValue(s);return r}(t)}finally{this.draco.destroy(t)}}_getAttributeValues(e,t){const r=ia[t.data_type],s=t.num_components,n=e.num_points()*s,i=n*r.BYTES_PER_ELEMENT,o=function(e,t){switch(t){case Float32Array:return e.DT_FLOAT32;case Int8Array:return e.DT_INT8;case Int16Array:return e.DT_INT16;case Int32Array:return e.DT_INT32;case Uint8Array:return e.DT_UINT8;case Uint16Array:return e.DT_UINT16;case Uint32Array:return e.DT_UINT32;default:return e.DT_INVALID}}(this.draco,r);let a;const c=this.draco._malloc(i);try{const s=this.decoder.GetAttribute(e,t.attribute_index);this.decoder.GetAttributeDataArrayForAllPoints(e,s,o,i,c),a=new r(this.draco.HEAPF32.buffer,c,n).slice()}finally{this.draco._free(c)}return{value:a,size:s}}_deduceAttributeName(e,t){const r=e.unique_id;for(const[e,s]of Object.entries(t.extraAttributes||{}))if(s===r)return e;const s=e.attribute_type;for(const e in na){if(this.draco[e]===s)return na[e]}const n=t.attributeNameEntry||"name";return e.metadata[n]?e.metadata[n].string:`CUSTOM_ATTRIBUTE_${r}`}_getTopLevelMetadata(e){const t=this.decoder.GetMetadata(e);return this._getDracoMetadata(t)}_getAttributeMetadata(e,t){const r=this.decoder.GetAttributeMetadata(e,t);return this._getDracoMetadata(r)}_getDracoMetadata(e){if(!e||!e.ptr)return{};const t={},r=this.metadataQuerier.NumEntries(e);for(let s=0;s<r;s++){const r=this.metadataQuerier.GetEntryName(e,s);t[r]=this._getDracoMetadataField(e,r)}return t}_getDracoMetadataField(e,t){const r=new this.draco.DracoInt32Array;try{this.metadataQuerier.GetIntEntryArray(e,t,r);const s=function(e){const t=e.size(),r=new Int32Array(t);for(let s=0;s<t;s++)r[s]=e.GetValue(s);return r}(r);return{int:this.metadataQuerier.GetIntEntry(e,t),string:this.metadataQuerier.GetStringEntry(e,t),double:this.metadataQuerier.GetDoubleEntry(e,t),intArray:s}}finally{this.draco.destroy(r)}}_disableAttributeTransforms(e){const{quantizedAttributes:t=[],octahedronAttributes:r=[]}=e,s=[...t,...r];for(const e of s)this.decoder.SkipAttributeTransform(this.draco[e])}_getQuantizationTransform(e,t){const{quantizedAttributes:r=[]}=t,s=e.attribute_type();if(r.map((e=>this.decoder[e])).includes(s)){const t=new this.draco.AttributeQuantizationTransform;try{if(t.InitFromAttribute(e))return{quantization_bits:t.quantization_bits(),range:t.range(),min_values:new Float32Array([1,2,3]).map((e=>t.min_value(e)))}}finally{this.draco.destroy(t)}}return null}_getOctahedronTransform(e,t){const{octahedronAttributes:r=[]}=t,s=e.attribute_type();if(r.map((e=>this.decoder[e])).includes(s)){const t=new this.draco.AttributeQuantizationTransform;try{if(t.InitFromAttribute(e))return{quantization_bits:t.quantization_bits()}}finally{this.draco.destroy(t)}}return null}}const aa="https://www.gstatic.com/draco/versioned/decoders/1.4.1/draco_decoder.js",ca="https://www.gstatic.com/draco/versioned/decoders/1.4.1/draco_wasm_wrapper.js",ua="https://www.gstatic.com/draco/versioned/decoders/1.4.1/draco_decoder.wasm";let ha;async function la(e){const t=e.modules||{};return ha=t.draco3d?ha||t.draco3d.createDecoderModule({}).then((e=>({draco:e}))):ha||async function(e){let t,r;switch(e.draco&&e.draco.decoderType){case"js":t=await $e(aa,"draco",e);break;case"wasm":default:[t,r]=await Promise.all([await $e(ca,"draco",e),await $e(ua,"draco",e)])}return t=t||globalThis.DracoDecoderModule,await function(e,t){const r={};t&&(r.wasmBinary=t);return new Promise((t=>{e({...r,onModuleLoaded:e=>t({draco:e})})}))}(t,r)}(e),await ha}const da={...Po,parse:async function(e,t){const{draco:r}=await la(t),s=new oa(r);try{return s.parseSync(e,null==t?void 0:t.draco)}finally{s.destroy()}}};const fa={BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,INT:5124,UNSIGNED_INT:5125,FLOAT:5126,DOUBLE:5130},pa={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,...fa},ma={[fa.DOUBLE]:Float64Array,[fa.FLOAT]:Float32Array,[fa.UNSIGNED_SHORT]:Uint16Array,[fa.UNSIGNED_INT]:Uint32Array,[fa.UNSIGNED_BYTE]:Uint8Array,[fa.BYTE]:Int8Array,[fa.SHORT]:Int16Array,[fa.INT]:Int32Array},ga={DOUBLE:fa.DOUBLE,FLOAT:fa.FLOAT,UNSIGNED_SHORT:fa.UNSIGNED_SHORT,UNSIGNED_INT:fa.UNSIGNED_INT,UNSIGNED_BYTE:fa.UNSIGNED_BYTE,BYTE:fa.BYTE,SHORT:fa.SHORT,INT:fa.INT};class ya{static fromTypedArray(e){e=ArrayBuffer.isView(e)?e.constructor:e;for(const t in ma){if(ma[t]===e)return t}throw new Error("Failed to convert GL type")}static fromName(e){const t=ga[e];if(!t)throw new Error("Failed to convert GL type");return t}static getArrayType(e){switch(e){case fa.UNSIGNED_SHORT_5_6_5:case fa.UNSIGNED_SHORT_4_4_4_4:case fa.UNSIGNED_SHORT_5_5_5_1:return Uint16Array;default:const t=ma[e];if(!t)throw new Error("Failed to convert GL type");return t}}static getByteSize(e){return ya.getArrayType(e).BYTES_PER_ELEMENT}static validate(e){return Boolean(ya.getArrayType(e))}static createTypedArray(e,t,r=0,s){void 0===s&&(s=(t.byteLength-r)/ya.getByteSize(e));return new(ya.getArrayType(e))(t,r,s)}}function wa(e,t=[0,0,0]){const r=e>>11&31,s=e>>5&63,n=31&e;return t[0]=r<<3,t[1]=s<<2,t[2]=n<<3,t}function ba(e,t=255){return function(e,t,r){return Sr(e,(e=>Math.max(t,Math.min(r,e))))}(e,0,t)/t*2-1}function Ta(e){return e<0?-1:1}function va(e,t,r,s){if(function(e,t){if(!e)throw new Error(`math.gl assertion failed. ${t}`)}(s),e<0||e>r||t<0||t>r)throw new Error(`x and y must be unsigned normalized integers between 0 and ${r}`);if(s.x=ba(e,r),s.y=ba(t,r),s.z=1-(Math.abs(s.x)+Math.abs(s.y)),s.z<0){const e=s.x;s.x=(1-Math.abs(s.y))*Ta(e),s.y=(1-Math.abs(e))*Ta(s.y)}return s.normalize()}new Vr,new ss,new Vr,new Vr;class _a{constructor(e,t){this.json=e,this.buffer=t,this.featuresLength=0,this._cachedTypedArrays={}}getExtension(e){return this.json.extensions&&this.json.extensions[e]}hasProperty(e){return Boolean(this.json[e])}getGlobalProperty(e,t=pa.UNSIGNED_INT,r=1){const s=this.json[e];return s&&Number.isFinite(s.byteOffset)?this._getTypedArrayFromBinary(e,t,r,1,s.byteOffset):s}getPropertyArray(e,t,r){const s=this.json[e];return s&&Number.isFinite(s.byteOffset)?("componentType"in s&&(t=ya.fromName(s.componentType)),this._getTypedArrayFromBinary(e,t,r,this.featuresLength,s.byteOffset)):this._getTypedArrayFromArray(e,t,s)}getProperty(e,t,r,s,n){const i=this.json[e];if(!i)return i;const o=this.getPropertyArray(e,t,r);if(1===r)return o[s];for(let e=0;e<r;++e)n[e]=o[r*s+e];return n}_getTypedArrayFromBinary(e,t,r,s,n){const i=this._cachedTypedArrays;let o=i[e];return o||(o=ya.createTypedArray(t,this.buffer.buffer,this.buffer.byteOffset+n,s*r),i[e]=o),o}_getTypedArrayFromArray(e,t,r){const s=this._cachedTypedArrays;let n=s[e];return n||(n=ya.createTypedArray(t,r),s[e]=n),n}}const Ea={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},xa={SCALAR:(e,t)=>e[t],VEC2:(e,t)=>[e[2*t+0],e[2*t+1]],VEC3:(e,t)=>[e[3*t+0],e[3*t+1],e[3*t+2]],VEC4:(e,t)=>[e[4*t+0],e[4*t+1],e[4*t+2],e[4*t+3]],MAT2:(e,t)=>[e[4*t+0],e[4*t+1],e[4*t+2],e[4*t+3]],MAT3:(e,t)=>[e[9*t+0],e[9*t+1],e[9*t+2],e[9*t+3],e[9*t+4],e[9*t+5],e[9*t+6],e[9*t+7],e[9*t+8]],MAT4:(e,t)=>[e[16*t+0],e[16*t+1],e[16*t+2],e[16*t+3],e[16*t+4],e[16*t+5],e[16*t+6],e[16*t+7],e[16*t+8],e[16*t+9],e[16*t+10],e[16*t+11],e[16*t+12],e[16*t+13],e[16*t+14],e[16*t+15]]},Sa={SCALAR:(e,t,r)=>{t[r]=e},VEC2:(e,t,r)=>{t[2*r+0]=e[0],t[2*r+1]=e[1]},VEC3:(e,t,r)=>{t[3*r+0]=e[0],t[3*r+1]=e[1],t[3*r+2]=e[2]},VEC4:(e,t,r)=>{t[4*r+0]=e[0],t[4*r+1]=e[1],t[4*r+2]=e[2],t[4*r+3]=e[3]},MAT2:(e,t,r)=>{t[4*r+0]=e[0],t[4*r+1]=e[1],t[4*r+2]=e[2],t[4*r+3]=e[3]},MAT3:(e,t,r)=>{t[9*r+0]=e[0],t[9*r+1]=e[1],t[9*r+2]=e[2],t[9*r+3]=e[3],t[9*r+4]=e[4],t[9*r+5]=e[5],t[9*r+6]=e[6],t[9*r+7]=e[7],t[9*r+8]=e[8],t[9*r+9]=e[9]},MAT4:(e,t,r)=>{t[16*r+0]=e[0],t[16*r+1]=e[1],t[16*r+2]=e[2],t[16*r+3]=e[3],t[16*r+4]=e[4],t[16*r+5]=e[5],t[16*r+6]=e[6],t[16*r+7]=e[7],t[16*r+8]=e[8],t[16*r+9]=e[9],t[16*r+10]=e[10],t[16*r+11]=e[11],t[16*r+12]=e[12],t[16*r+13]=e[13],t[16*r+14]=e[14],t[16*r+15]=e[15]}};const Aa=e=>void 0!==e;function Ma(e,t,r){if(!t)return null;let s=e.getExtension("3DTILES_batch_table_hierarchy");const n=t.HIERARCHY;return n&&(console.warn("3D Tile Parser: HIERARCHY is deprecated. Use 3DTILES_batch_table_hierarchy."),t.extensions=t.extensions||{},t.extensions["3DTILES_batch_table_hierarchy"]=n,s=n),s?function(e,t){let r,s,n;const i=e.instancesLength,o=e.classes;let a,c=e.classIds,u=e.parentCounts,h=e.parentIds,l=i;Aa(c.byteOffset)&&(c.componentType=defaultValue(c.componentType,GL.UNSIGNED_SHORT),c.type=AttributeType.SCALAR,n=getBinaryAccessor(c),c=n.createArrayBufferView(t.buffer,t.byteOffset+c.byteOffset,i));if(Aa(u))for(Aa(u.byteOffset)&&(u.componentType=defaultValue(u.componentType,GL.UNSIGNED_SHORT),u.type=AttributeType.SCALAR,n=getBinaryAccessor(u),u=n.createArrayBufferView(t.buffer,t.byteOffset+u.byteOffset,i)),a=new Uint16Array(i),l=0,r=0;r<i;++r)a[r]=l,l+=u[r];Aa(h)&&Aa(h.byteOffset)&&(h.componentType=defaultValue(h.componentType,GL.UNSIGNED_SHORT),h.type=AttributeType.SCALAR,n=getBinaryAccessor(h),h=n.createArrayBufferView(t.buffer,t.byteOffset+h.byteOffset,l));const d=o.length;for(r=0;r<d;++r){const e=o[r].length,s=o[r].instances,n=getBinaryProperties(e,s,t);o[r].instances=combine(n,s)}const f=new Array(d).fill(0),p=new Uint16Array(i);for(r=0;r<i;++r)s=c[r],p[r]=f[s],++f[s];const m={classes:o,classIds:c,classIndexes:p,parentCounts:u,parentIndexes:a,parentIds:h};return function(e){const t=e.classIds.length;for(let r=0;r<t;++r)Oa(e,r,stack)}(m),m}(s,r):null}function Ra(e,t,r){if(!e)return;const s=e.parentCounts;return e.parentIds?r(e,t):s>0?function(e,t,r){const s=e.classIds,n=e.parentCounts,i=e.parentIds,o=e.parentIndexes,a=s.length,c=scratchVisited;c.length=Math.max(c.length,a);const u=++marker,h=scratchStack;h.length=0,h.push(t);for(;h.length>0;){if(c[t=h.pop()]===u)continue;c[t]=u;const s=r(e,t);if(Aa(s))return s;const a=n[t],l=o[t];for(let e=0;e<a;++e){const r=i[l+e];r!==t&&h.push(r)}}return null}(e,t,r):function(e,t,r){let s=!0;for(;s;){const n=r(e,t);if(Aa(n))return n;const i=e.parentIds[t];s=i!==t,t=i}throw new Error("traverseHierarchySingleParent")}(e,t,r)}function Oa(e,t,r){const s=e.parentCounts,n=e.parentIds,i=e.parentIndexes,o=e.classIds.length;if(!Aa(n))return;assert(t<o,`Parent index ${t} exceeds the total number of instances: ${o}`),assert(-1===r.indexOf(t),"Circular dependency detected in the batch table hierarchy."),r.push(t);const a=Aa(s)?s[t]:1,c=Aa(s)?i[t]:t;for(let s=0;s<a;++s){const i=n[c+s];i!==t&&Oa(e,i,r)}r.pop(t)}function Ia(e){return null!=e}const Na=(e,t)=>e,La={HIERARCHY:!0,extensions:!0,extras:!0};class Ca{constructor(e,t,r,s={}){var n;Te(r>=0),this.json=e||{},this.binary=t,this.featureCount=r,this._extensions=(null===(n=this.json)||void 0===n?void 0:n.extensions)||{},this._properties={};for(const e in this.json)La[e]||(this._properties[e]=this.json[e]);this._binaryProperties=this._initializeBinaryProperties(),s["3DTILES_batch_table_hierarchy"]&&(this._hierarchy=Ma(this,this.json,this.binary))}getExtension(e){return this.json&&this.json.extensions&&this.json.extensions[e]}memorySizeInBytes(){return 0}isClass(e,t){if(this._checkBatchId(e),Te("string"==typeof t,t),this._hierarchy){return Ia(Ra(this._hierarchy,e,((e,r)=>{const s=e.classIds[r];return e.classes[s].name===t})))}return!1}isExactClass(e,t){return Te("string"==typeof t,t),this.getExactClassName(e)===t}getExactClassName(e){if(this._checkBatchId(e),this._hierarchy){const t=this._hierarchy.classIds[e];return this._hierarchy.classes[t].name}}hasProperty(e,t){return this._checkBatchId(e),Te("string"==typeof t,t),Ia(this._properties[t])||this._hasPropertyInHierarchy(e,t)}getPropertyNames(e,t){this._checkBatchId(e),(t=Ia(t)?t:[]).length=0;const r=Object.keys(this._properties);return t.push(...r),this._hierarchy&&this._getPropertyNamesInHierarchy(e,t),t}getProperty(e,t){if(this._checkBatchId(e),Te("string"==typeof t,t),this._binaryProperties){const r=this._binaryProperties[t];if(Ia(r))return this._getBinaryProperty(r,e)}const r=this._properties[t];if(Ia(r))return Na(r[e]);if(this._hierarchy){const r=this._getHierarchyProperty(e,t);if(Ia(r))return r}}setProperty(e,t,r){const s=this.featureCount;if(this._checkBatchId(e),Te("string"==typeof t,t),this._binaryProperties){const s=this._binaryProperties[t];if(s)return void this._setBinaryProperty(s,e,r)}if(this._hierarchy&&this._setHierarchyProperty(this,e,t,r))return;let n=this._properties[t];Ia(n)||(this._properties[t]=new Array(s),n=this._properties[t]),n[e]=Na(r)}_checkBatchId(e){if(!(e>=0&&e<this.featureCount))throw new Error("batchId not in range [0, featureCount - 1].")}_getBinaryProperty(e,t){return e.unpack(e.typedArray,t)}_setBinaryProperty(e,t,r){e.pack(r,e.typedArray,t)}_initializeBinaryProperties(){let e=null;for(const t in this._properties){const r=this._properties[t],s=this._initializeBinaryProperty(t,r);s&&(e=e||{},e[t]=s)}return e}_initializeBinaryProperty(e,t){if("byteOffset"in t){const r=t;Te(this.binary,`Property ${e} requires a batch table binary.`),Te(r.type,`Property ${e} requires a type.`);const s=function(e,t,r,s){const{componentType:n}=e;Te(e.componentType);const i="string"==typeof n?ya.fromName(n):n,o=Ea[e.type],a=xa[e.type],c=Sa[e.type];return r+=e.byteOffset,{values:ya.createTypedArray(i,t,r,o*s),type:i,size:o,unpacker:a,packer:c}}(r,this.binary.buffer,0|this.binary.byteOffset,this.featureCount);return{typedArray:s.values,componentCount:s.size,unpack:s.unpacker,pack:s.packer}}return null}_hasPropertyInHierarchy(e,t){if(!this._hierarchy)return!1;const r=Ra(this._hierarchy,e,((e,r)=>{const s=e.classIds[r];return Ia(e.classes[s].instances[t])}));return Ia(r)}_getPropertyNamesInHierarchy(e,t){Ra(this._hierarchy,e,((e,r)=>{const s=e.classIds[r],n=e.classes[s].instances;for(const e in n)n.hasOwnProperty(e)&&-1===t.indexOf(e)&&t.push(e)}))}_getHierarchyProperty(e,t){return Ra(this._hierarchy,e,((e,r)=>{const s=e.classIds[r],n=e.classes[s],i=e.classIndexes[r],o=n.instances[t];return Ia(o)?Ia(o.typedArray)?this._getBinaryProperty(o,i):Na(o[i]):null}))}_setHierarchyProperty(e,t,r,s){const n=Ra(this._hierarchy,t,((e,n)=>{const i=e.classIds[n],o=e.classes[i],a=e.classIndexes[n],c=o.instances[r];return!!Ia(c)&&(Te(n===t,`Inherited property "${r}" is read-only.`),Ia(c.typedArray)?this._setBinaryProperty(c,a,s):c[a]=Na(s),!0)}));return Ia(n)}}function Pa(e,t,r=0){const s=new DataView(t);if(e.magic=s.getUint32(r,!0),r+=4,e.version=s.getUint32(r,!0),r+=4,e.byteLength=s.getUint32(r,!0),r+=4,1!==e.version)throw new Error(`3D Tile Version ${e.version} not supported`);return r}function Ua(e,t,r){const s=new DataView(t);let n;e.header=e.header||{};let i=s.getUint32(r,!0);r+=4;let o=s.getUint32(r,!0);r+=4;let a=s.getUint32(r,!0);r+=4;let c=s.getUint32(r,!0);return r+=4,a>=570425344?(r-=8,n=i,a=o,c=0,i=0,o=0,console.warn("b3dm tile in legacy format.")):c>=570425344&&(r-=4,n=a,a=i,c=o,i=0,o=0,console.warn("b3dm tile in legacy format.")),e.header.featureTableJsonByteLength=i,e.header.featureTableBinaryByteLength=o,e.header.batchTableJsonByteLength=a,e.header.batchTableBinaryByteLength=c,e.header.batchLength=n,r}function ka(e,t,r,s){return r=function(e,t,r,s){const{featureTableJsonByteLength:n,featureTableBinaryByteLength:i,batchLength:o}=e.header;if(e.featureTableJson={BATCH_LENGTH:o||0},n>0){const s=Co(t,r,n);e.featureTableJson=JSON.parse(s)}return r+=n,e.featureTableBinary=new Uint8Array(t,r,i),r+=i}(e,t,r),r=function(e,t,r,s){const{batchTableJsonByteLength:n,batchTableBinaryByteLength:i}=e.header;if(n>0){const s=Co(t,r,n);e.batchTableJson=JSON.parse(s),r+=n,i>0&&(e.batchTableBinary=new Uint8Array(t,r,i),e.batchTableBinary=new Uint8Array(e.batchTableBinary),r+=i)}return r}(e,t,r)}function Da(e,t,r){if(!(t||e&&e.batchIds&&r))return null;const{batchIds:s,isRGB565:n,pointCount:i}=e;if(s&&r){const e=new Uint8ClampedArray(3*i);for(let t=0;t<i;t++){const n=s[t],i=r.getProperty(n,"dimensions").map((e=>255*e));e[3*t]=i[0],e[3*t+1]=i[1],e[3*t+2]=i[2]}return{type:pa.UNSIGNED_BYTE,value:e,size:3,normalized:!0}}if(n){const e=new Uint8ClampedArray(3*i);for(let r=0;r<i;r++){const s=wa(t[r]);e[3*r]=s[0],e[3*r+1]=s[1],e[3*r+2]=s[2]}return{type:pa.UNSIGNED_BYTE,value:e,size:3,normalized:!0}}return t&&t.length===3*i?{type:pa.UNSIGNED_BYTE,value:t,size:3,normalized:!0}:{type:pa.UNSIGNED_BYTE,value:t,size:4,normalized:!0}}const ja=new ss;function Ba(e,t,r){return e.isQuantized?r["3d-tiles"]&&r["3d-tiles"].decodeQuantizedPositions?(e.isQuantized=!1,function(e,t){const r=new ss,s=new Float32Array(3*e.pointCount);for(let n=0;n<e.pointCount;n++)r.set(t[3*n],t[3*n+1],t[3*n+2]).scale(1/e.quantizedRange).multiply(e.quantizedVolumeScale).add(e.quantizedVolumeOffset).toArray(s,3*n);return s}(e,t)):{type:pa.UNSIGNED_SHORT,value:t,size:3,normalized:!0}:t}async function Fa(e,t,r,s,n){r=ka(e,t,r=Ua(e,t,r=Pa(e,t,r))),function(e){e.attributes={positions:null,colors:null,normals:null,batchIds:null},e.isQuantized=!1,e.isTranslucent=!1,e.isRGB565=!1,e.isOctEncoded16P=!1}(e);const{featureTable:i,batchTable:o}=function(e){const t=new _a(e.featureTableJson,e.featureTableBinary),r=t.getGlobalProperty("POINTS_LENGTH");if(!Number.isFinite(r))throw new Error("POINTS_LENGTH must be defined");t.featuresLength=r,e.featuresLength=r,e.pointsLength=r,e.pointCount=r,e.rtcCenter=t.getGlobalProperty("RTC_CENTER",pa.FLOAT,3);const s=function(e,t){let r=null;if(!e.batchIds&&t.hasProperty("BATCH_ID")&&(e.batchIds=t.getPropertyArray("BATCH_ID",pa.UNSIGNED_SHORT,1),e.batchIds)){const s=t.getGlobalProperty("BATCH_LENGTH");if(!s)throw new Error("Global property: BATCH_LENGTH must be defined when BATCH_ID is defined.");const{batchTableJson:n,batchTableBinary:i}=e;r=new Ca(n,i,s)}return r}(e,t);return{featureTable:t,batchTable:s}}(e);return await async function(e,t,r,s,n){let i,o,a;const c=e.batchTableJson&&e.batchTableJson.extensions&&e.batchTableJson.extensions["3DTILES_draco_point_compression"];c&&(a=c.properties);const u=t.getExtension("3DTILES_draco_point_compression");if(u){o=u.properties;const t=u.byteOffset,r=u.byteLength;if(!o||!Number.isFinite(t)||!r)throw new Error("Draco properties, byteOffset, and byteLength must be defined");i=e.featureTableBinary.slice(t,t+r),e.hasPositions=Number.isFinite(o.POSITION),e.hasColors=Number.isFinite(o.RGB)||Number.isFinite(o.RGBA),e.hasNormals=Number.isFinite(o.NORMAL),e.hasBatchIds=Number.isFinite(o.BATCH_ID),e.isTranslucent=Number.isFinite(o.RGBA)}if(!i)return!0;const h={buffer:i,properties:{...o,...a},featureTableProperties:o,batchTableProperties:a,dequantizeInShader:!1};return await async function(e,t,r,s){const{parse:n}=s,i={...r,draco:{...r.draco,extraAttributes:t.batchTableProperties||{}}};delete i["3d-tiles"];const o=await n(t.buffer,da,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,h=o.attributes.BATCH_ID&&o.attributes.BATCH_ID.value,l=a&&o.attributes.POSITION.value.quantization,d=u&&o.attributes.NORMAL.value.quantization;if(l){const t=o.POSITION.data.quantization,r=t.range;e.quantizedVolumeScale=new ss(r,r,r),e.quantizedVolumeOffset=new ss(t.minValues),e.quantizedRange=(1<<t.quantizationBits)-1,e.isQuantizedDraco=!0}d&&(e.octEncodedRange=(1<<o.NORMAL.data.quantization.quantizationBits)-1,e.isOctEncodedDraco=!0);const f={};if(t.batchTableProperties)for(const e of Object.keys(t.batchTableProperties))o.attributes[e]&&o.attributes[e].value&&(f[e.toLowerCase()]=o.attributes[e].value);e.attributes={positions:a,colors:Da(e,c),normals:u,batchIds:h,...f}}(e,h,s,n)}(e,i,0,s,n),function(e,t,r){if(!e.attributes.positions)if(t.hasProperty("POSITION"))e.attributes.positions=t.getPropertyArray("POSITION",pa.FLOAT,3);else if(t.hasProperty("POSITION_QUANTIZED")){const s=t.getPropertyArray("POSITION_QUANTIZED",pa.UNSIGNED_SHORT,3);if(e.isQuantized=!0,e.quantizedRange=65535,e.quantizedVolumeScale=t.getGlobalProperty("QUANTIZED_VOLUME_SCALE",pa.FLOAT,3),!e.quantizedVolumeScale)throw new Error("QUANTIZED_VOLUME_SCALE must be defined for quantized positions.");if(e.quantizedVolumeOffset=t.getGlobalProperty("QUANTIZED_VOLUME_OFFSET",pa.FLOAT,3),!e.quantizedVolumeOffset)throw new Error("QUANTIZED_VOLUME_OFFSET must be defined for quantized positions.");e.attributes.positions=Ba(e,s,r)}if(!e.attributes.positions)throw new Error("Either POSITION or POSITION_QUANTIZED must be defined.")}(e,i,s),function(e,t,r){if(!e.attributes.colors){let s=null;t.hasProperty("RGBA")?(s=t.getPropertyArray("RGBA",pa.UNSIGNED_BYTE,4),e.isTranslucent=!0):t.hasProperty("RGB")?s=t.getPropertyArray("RGB",pa.UNSIGNED_BYTE,3):t.hasProperty("RGB565")&&(s=t.getPropertyArray("RGB565",pa.UNSIGNED_SHORT,1),e.isRGB565=!0),e.attributes.colors=Da(e,s,r)}t.hasProperty("CONSTANT_RGBA")&&(e.constantRGBA=t.getGlobalProperty("CONSTANT_RGBA",pa.UNSIGNED_BYTE,4))}(e,i,o),function(e,t){if(!e.attributes.normals){let r=null;t.hasProperty("NORMAL")?r=t.getPropertyArray("NORMAL",pa.FLOAT,3):t.hasProperty("NORMAL_OCT16P")&&(r=t.getPropertyArray("NORMAL_OCT16P",pa.UNSIGNED_BYTE,2),e.isOctEncoded16P=!0),e.attributes.normals=function(e,t){if(!t)return null;if(e.isOctEncoded16P){const r=new Float32Array(3*e.pointsLength);for(let s=0;s<e.pointsLength;s++)va(t[2*s],t[2*s+1],255,ja),ja.toArray(r,3*s);return{type:pa.FLOAT,size:2,value:r}}return{type:pa.FLOAT,size:2,value:t}}(e,r)}}(e,i),r}function Va(e,t){if(!e)throw new Error(t)}const qa={self:"undefined"!=typeof self&&self,window:"undefined"!=typeof window&&window,global:"undefined"!=typeof global&&global,document:"undefined"!=typeof document&&document},za=qa.global||qa.self||qa.window,Ga="object"!=typeof process||"[object process]"!==String(process)||process.browser,Ha="undefined"!=typeof process&&process.version&&/v([0-9]*)/.exec(process.version);Ha&&parseFloat(Ha[1]);const{_parseImageNode:$a}=za,Wa="undefined"!=typeof Image,Ka="undefined"!=typeof ImageBitmap,Qa=Boolean($a),Xa=!!Ga||Qa;function Ya(e){const t=function(e){if("undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap)return"imagebitmap";if("undefined"!=typeof Image&&e instanceof Image)return"image";if(e&&"object"==typeof e&&e.data&&e.width&&e.height)return"data";return null}(e);if(!t)throw new Error("Not an image");return t}const Za=/^data:image\/svg\+xml/,Ja=/\.svg((\?|#).*)?$/;function ec(e){return e&&(Za.test(e)||Ja.test(e))}function tc(e,t){if(ec(t))throw new Error("SVG cannot be parsed directly to imagebitmap");return new Blob([new Uint8Array(e)])}async function rc(e,t,r){const s=function(e,t){if(ec(t)){let t=(new TextDecoder).decode(e);try{"function"==typeof unescape&&"function"==typeof encodeURIComponent&&(t=unescape(encodeURIComponent(t)))}catch(e){throw new Error(e.message)}return`data:image/svg+xml;base64,${btoa(t)}`}return tc(e,t)}(e,r),n=self.URL||self.webkitURL,i="string"!=typeof s&&n.createObjectURL(s);try{return await async function(e,t){const r=new Image;if(r.src=e,t.image&&t.image.decode&&r.decode)return await r.decode(),r;return await new Promise(((t,s)=>{try{r.onload=()=>t(r),r.onerror=t=>s(new Error(`Could not load image ${e}: ${t}`))}catch(e){s(e)}}))}(i||s,t)}finally{i&&n.revokeObjectURL(i)}}const sc={};let nc=!0;async function ic(e,t,r){let s;if(ec(r)){s=await rc(e,t,r)}else s=tc(e,r);const n=t&&t.imagebitmap;return await async function(e,t=null){!function(e){for(const t in e||sc)return!1;return!0}(t)&&nc||(t=null);if(t)try{return await createImageBitmap(e,t)}catch(e){console.warn(e),nc=!1}return await createImageBitmap(e)}(s,n)}function oc(e){const t=ac(e);return function(e){const t=ac(e);if(!(t.byteLength>=24&&2303741511===t.getUint32(0,false)))return null;return{mimeType:"image/png",width:t.getUint32(16,false),height:t.getUint32(20,false)}}(t)||function(e){const t=ac(e);if(!(t.byteLength>=3&&65496===t.getUint16(0,false)&&255===t.getUint8(2)))return null;const{tableMarkers:r,sofMarkers:s}=function(){const e=new Set([65499,65476,65484,65501,65534]);for(let t=65504;t<65520;++t)e.add(t);const t=new Set([65472,65473,65474,65475,65477,65478,65479,65481,65482,65483,65485,65486,65487,65502]);return{tableMarkers:e,sofMarkers:t}}();let n=2;for(;n+9<t.byteLength;){const e=t.getUint16(n,false);if(s.has(e))return{mimeType:"image/jpeg",height:t.getUint16(n+5,false),width:t.getUint16(n+7,false)};if(!r.has(e))return null;n+=2,n+=t.getUint16(n,false)}return null}(t)||function(e){const t=ac(e);if(!(t.byteLength>=10&&1195984440===t.getUint32(0,false)))return null;return{mimeType:"image/gif",width:t.getUint16(6,true),height:t.getUint16(8,true)}}(t)||function(e){const t=ac(e);if(!(t.byteLength>=14&&16973===t.getUint16(0,false)&&t.getUint32(2,true)===t.byteLength))return null;return{mimeType:"image/bmp",width:t.getUint32(18,true),height:t.getUint32(22,true)}}(t)}function ac(e){if(e instanceof DataView)return e;if(ArrayBuffer.isView(e))return new DataView(e.buffer);if(e instanceof ArrayBuffer)return new DataView(e);throw new Error("toDataView")}const cc={id:"image",module:"images",name:"Images",version:"3.0.10",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(e,t,r){const s=((t=t||{}).image||{}).type||"auto",{url:n}=r||{};let i;switch(function(e){switch(e){case"auto":case"data":return function(){if(Ka)return"imagebitmap";if(Wa)return"image";if(Xa)return"data";throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js")}();default:return function(e){switch(e){case"auto":return Ka||Wa||Xa;case"imagebitmap":return Ka;case"image":return Wa;case"data":return Xa;default:throw new Error(`@loaders.gl/images: image ${e} not supported in this environment`)}}(e),e}}(s)){case"imagebitmap":i=await ic(e,t,n);break;case"image":i=await rc(e,t,n);break;case"data":i=await function(e,t){const{mimeType:r}=oc(e)||{},{_parseImageNode:s}=za;return Va(s),s(e,r,t)}(e,t);break;default:Va(!1)}return"data"===s&&(i=function(e){switch(Ya(e)){case"data":return e;case"image":case"imagebitmap":const t=document.createElement("canvas"),r=t.getContext("2d");if(!r)throw new Error("getImageData");return t.width=e.width,t.height=e.height,r.drawImage(e,0,0),r.getImageData(0,0,e.width,e.height);default:throw new Error("getImageData")}}(i)),i},tests:[e=>Boolean(oc(new DataView(e)))],options:{image:{type:"auto",decode:!0}}};function uc(e,t){if(!e)throw new Error(t||"assert failed: gltf")}function hc(e,t){if(e.startsWith("data:")||e.startsWith("http:")||e.startsWith("https:"))return e;const r=t.baseUri||t.uri;if(!r)throw new Error(`'baseUri' must be provided to resolve relative url ${e}`);return r.substr(0,r.lastIndexOf("/")+1)+e}const lc=["SCALAR","VEC2","VEC3","VEC4"],dc=[[Int8Array,5120],[Uint8Array,5121],[Int16Array,5122],[Uint16Array,5123],[Uint32Array,5125],[Float32Array,5126],[Float64Array,5130]],fc=new Map(dc),pc={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},mc={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},gc={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};function yc(e){return lc[e-1]||lc[0]}function wc(e){const t=fc.get(e.constructor);if(!t)throw new Error("Illegal typed array");return t}function bc(e,t){const r=gc[e.componentType],s=pc[e.type],n=mc[e.componentType],i=e.count*s,o=e.count*s*n;return uc(o>=0&&o<=t.byteLength),{ArrayType:r,length:i,byteLength:o}}const Tc={asset:{version:"2.0",generator:"loaders.gl"},buffers:[]};class vc{constructor(e){Le(this,"gltf",void 0),Le(this,"sourceBuffers",void 0),Le(this,"byteLength",void 0),this.gltf=e||{json:{...Tc},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(e){return this.json[e]}getExtraData(e){return(this.json.extras||{})[e]}getExtension(e){const t=this.getUsedExtensions().find((t=>t===e)),r=this.json.extensions||{};return t?r[e]||!0:null}getRequiredExtension(e){return this.getRequiredExtensions().find((t=>t===e))?this.getExtension(e):null}getRequiredExtensions(){return this.json.extensionsRequired||[]}getUsedExtensions(){return this.json.extensionsUsed||[]}getObjectExtension(e,t){return(e.extensions||{})[t]}getScene(e){return this.getObject("scenes",e)}getNode(e){return this.getObject("nodes",e)}getSkin(e){return this.getObject("skins",e)}getMesh(e){return this.getObject("meshes",e)}getMaterial(e){return this.getObject("materials",e)}getAccessor(e){return this.getObject("accessors",e)}getTexture(e){return this.getObject("textures",e)}getSampler(e){return this.getObject("samplers",e)}getImage(e){return this.getObject("images",e)}getBufferView(e){return this.getObject("bufferViews",e)}getBuffer(e){return this.getObject("buffers",e)}getObject(e,t){if("object"==typeof t)return t;const r=this.json[e]&&this.json[e][t];if(!r)throw new Error(`glTF file error: Could not find ${e}[${t}]`);return r}getTypedArrayForBufferView(e){const t=(e=this.getBufferView(e)).buffer,r=this.gltf.buffers[t];uc(r);const s=(e.byteOffset||0)+r.byteOffset;return new Uint8Array(r.arrayBuffer,s,e.byteLength)}getTypedArrayForAccessor(e){e=this.getAccessor(e);const t=this.getBufferView(e.bufferView),r=this.getBuffer(t.buffer).data,{ArrayType:s,length:n}=bc(e,t);return new s(r,t.byteOffset+e.byteOffset,n)}getTypedArrayForImageData(e){e=this.getAccessor(e);const t=this.getBufferView(e.bufferView),r=this.getBuffer(t.buffer).data,s=t.byteOffset||0;return new Uint8Array(r,s,t.byteLength)}addApplicationData(e,t){return this.json[e]=t,this}addExtraData(e,t){return this.json.extras=this.json.extras||{},this.json.extras[e]=t,this}addObjectExtension(e,t,r){return e.extensions=e.extensions||{},e.extensions[t]=r,this.registerUsedExtension(t),this}setObjectExtension(e,t,r){(e.extensions||{})[t]=r}removeObjectExtension(e,t){const r=e.extensions||{},s=r[t];return delete r[t],s}addExtension(e,t={}){return uc(t),this.json.extensions=this.json.extensions||{},this.json.extensions[e]=t,this.registerUsedExtension(e),t}addRequiredExtension(e,t={}){return uc(t),this.addExtension(e,t),this.registerRequiredExtension(e),t}registerUsedExtension(e){this.json.extensionsUsed=this.json.extensionsUsed||[],this.json.extensionsUsed.find((t=>t===e))||this.json.extensionsUsed.push(e)}registerRequiredExtension(e){this.registerUsedExtension(e),this.json.extensionsRequired=this.json.extensionsRequired||[],this.json.extensionsRequired.find((t=>t===e))||this.json.extensionsRequired.push(e)}removeExtension(e){this.json.extensionsRequired&&this._removeStringFromArray(this.json.extensionsRequired,e),this.json.extensionsUsed&&this._removeStringFromArray(this.json.extensionsUsed,e),this.json.extensions&&delete this.json.extensions[e]}setDefaultScene(e){this.json.scene=e}addScene(e){const{nodeIndices:t}=e;return this.json.scenes=this.json.scenes||[],this.json.scenes.push({nodes:t}),this.json.scenes.length-1}addNode(e){const{meshIndex:t,matrix:r}=e;this.json.nodes=this.json.nodes||[];const s={mesh:t};return r&&(s.matrix=r),this.json.nodes.push(s),this.json.nodes.length-1}addMesh(e){const{attributes:t,indices:r,material:s,mode:n=4}=e,i={primitives:[{attributes:this._addAttributes(t),mode:n}]};if(r){const e=this._addIndices(r);i.primitives[0].indices=e}return Number.isFinite(s)&&(i.primitives[0].material=s),this.json.meshes=this.json.meshes||[],this.json.meshes.push(i),this.json.meshes.length-1}addPointCloud(e){const t={primitives:[{attributes:this._addAttributes(e),mode:0}]};return this.json.meshes=this.json.meshes||[],this.json.meshes.push(t),this.json.meshes.length-1}addImage(e,t){const r=oc(e),s=t||(null==r?void 0:r.mimeType),n={bufferView:this.addBufferView(e),mimeType:s};return this.json.images=this.json.images||[],this.json.images.push(n),this.json.images.length-1}addBufferView(e){const t=e.byteLength;uc(Number.isFinite(t)),this.sourceBuffers=this.sourceBuffers||[],this.sourceBuffers.push(e);const r={buffer:0,byteOffset:this.byteLength,byteLength:t};return this.byteLength+=Je(t,4),this.json.bufferViews=this.json.bufferViews||[],this.json.bufferViews.push(r),this.json.bufferViews.length-1}addAccessor(e,t){const r={bufferView:e,type:yc(t.size),componentType:t.componentType,count:t.count,max:t.max,min:t.min};return this.json.accessors=this.json.accessors||[],this.json.accessors.push(r),this.json.accessors.length-1}addBinaryBuffer(e,t={size:3}){const r=this.addBufferView(e);let s={min:t.min,max:t.max};s.min&&s.max||(s=this._getAccessorMinMax(e,t.size));const n={size:t.size,componentType:wc(e),count:Math.round(e.length/t.size),min:s.min,max:s.max};return this.addAccessor(r,Object.assign(n,t))}addTexture(e){const{imageIndex:t}=e,r={source:t};return this.json.textures=this.json.textures||[],this.json.textures.push(r),this.json.textures.length-1}addMaterial(e){return this.json.materials=this.json.materials||[],this.json.materials.push(e),this.json.materials.length-1}createBinaryChunk(){var e,t;this.gltf.buffers=[];const r=this.byteLength,s=new ArrayBuffer(r),n=new Uint8Array(s);let i=0;for(const e of this.sourceBuffers||[])i=et(e,n,i);null!==(e=this.json)&&void 0!==e&&null!==(t=e.buffers)&&void 0!==t&&t[0]?this.json.buffers[0].byteLength=r:this.json.buffers=[{byteLength:r}],this.gltf.binary=s,this.sourceBuffers=[s]}_removeStringFromArray(e,t){let r=!0;for(;r;){const s=e.indexOf(t);s>-1?e.splice(s,1):r=!1}}_addAttributes(e={}){const t={};for(const r in e){const s=e[r],n=this._getGltfAttributeName(r),i=this.addBinaryBuffer(s.value,s);t[n]=i}return t}_addIndices(e){return this.addBinaryBuffer(e,{size:1})}_getGltfAttributeName(e){switch(e.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 e}}_getAccessorMinMax(e,t){const r={min:null,max:null};if(e.length<t)return r;r.min=[],r.max=[];const s=e.subarray(0,t);for(const e of s)r.min.push(e),r.max.push(e);for(let s=t;s<e.length;s+=t)for(let n=0;n<t;n++)r.min[0+n]=Math.min(r.min[0+n],e[s+n]),r.max[0+n]=Math.max(r.max[0+n],e[s+n]);return r}}function _c(e){const{buffer:t,size:r,count:s}=function(e){let t=e,r=1,s=0;e&&e.value&&(t=e.value,r=e.size||1);t&&(ArrayBuffer.isView(t)||(t=function(e,t,r=!1){if(!e)return null;if(Array.isArray(e))return new t(e);if(r&&!(e instanceof t))return new t(e);return e}(t,Float32Array)),s=t.length/r);return{buffer:t,size:r,count:s}}(e);return{value:t,size:r,byteOffset:0,count:s,type:yc(r),componentType:wc(t)}}async function Ec(e,t,r,s){const n=e.getObjectExtension(t,"KHR_draco_mesh_compression");if(!n)return;const i=e.getTypedArrayForBufferView(n.bufferView),o=Ze(i.buffer,i.byteOffset),{parse:a}=s,c={...r};delete c["3d-tiles"];const u=await a(o,da,c,s),h=function(e){const t={};for(const r in e){const s=e[r];if("indices"!==r){const e=_c(s);t[r]=e}}return t}(u.attributes);for(const[r,s]of Object.entries(h))if(r in t.attributes){const n=t.attributes[r],i=e.getAccessor(n);null!=i&&i.min&&null!=i&&i.max&&(s.min=i.min,s.max=i.max)}t.attributes=h,u.indices&&(t.indices=_c(u.indices)),function(e){if(!e.attributes&&Object.keys(e.attributes).length>0)throw new Error("glTF: Empty primitive detected: Draco decompression failure?")}(t)}function xc(e,t,r=4,s,n){var i;if(!s.DracoWriter)throw new Error("options.gltf.DracoWriter not provided");const o=s.DracoWriter.encodeSync({attributes:e}),a=null==n||null===(i=n.parseSync)||void 0===i?void 0:i.call(n,{attributes:e}),c=s._addFauxAttributes(a.attributes);return{primitives:[{attributes:c,mode:r,extensions:{KHR_draco_mesh_compression:{bufferView:s.addBufferView(o),attributes:c}}}]}}function Sc(e,t){const r=Object.assign({},e.values);return Object.keys(e.uniforms||{}).forEach((t=>{e.uniforms[t].value&&!(t in r)&&(r[t]=e.uniforms[t].value)})),Object.keys(r).forEach((e=>{"object"==typeof r[e]&&void 0!==r[e].index&&(r[e].texture=t.getTexture(r[e].index))})),r}const Ac={KHR_draco_mesh_compression:Object.freeze({__proto__:null,decode:async function(e,t,r){var s;if(null==t||null===(s=t.gltf)||void 0===s||!s.decompressMeshes)return;const n=new vc(e),i=[];for(const e of function*(e){for(const t of e.json.meshes||[])for(const e of t.primitives)yield e}(n))n.getObjectExtension(e,"KHR_draco_mesh_compression")&&i.push(Ec(n,e,t,r));await Promise.all(i),n.removeExtension("KHR_draco_mesh_compression")},encode:function(e,t={}){const r=new vc(e);for(const e of r.json.meshes||[])xc(e),r.addRequiredExtension("KHR_draco_mesh_compression")}}),KHR_materials_unlit:Object.freeze({__proto__:null,decode:async function(e){const t=new vc(e),{json:r}=t;t.removeExtension("KHR_materials_unlit");for(const e of r.materials||[]){e.extensions&&e.extensions.KHR_materials_unlit&&(e.unlit=!0),t.removeObjectExtension(e,"KHR_materials_unlit")}},encode:function(e){const t=new vc(e),{json:r}=t;if(t.materials)for(const e of r.materials||[])e.unlit&&(delete e.unlit,t.addObjectExtension(e,"KHR_materials_unlit",{}),t.addExtension("KHR_materials_unlit"))}}),KHR_lights_punctual:Object.freeze({__proto__:null,decode:async function(e){const t=new vc(e),{json:r}=t,s=t.getExtension("KHR_lights_punctual");s&&(t.json.lights=s.lights,t.removeExtension("KHR_lights_punctual"));for(const e of r.nodes||[]){const r=t.getObjectExtension(e,"KHR_lights_punctual");r&&(e.light=r.light),t.removeObjectExtension(e,"KHR_lights_punctual")}},encode:async function(e){const t=new vc(e),{json:r}=t;if(r.lights){const e=t.addExtension("KHR_lights_punctual");uc(!e.lights),e.lights=r.lights,delete r.lights}if(t.json.lights){for(const e of t.json.lights){const r=e.node;t.addObjectExtension(r,"KHR_lights_punctual",e)}delete t.json.lights}}}),KHR_techniques_webgl:Object.freeze({__proto__:null,decode:async function(e){const t=new vc(e),{json:r}=t,s=t.getExtension("KHR_techniques_webgl");if(s){const e=function(e,t){const{programs:r=[],shaders:s=[],techniques:n=[]}=e,i=new TextDecoder;return s.forEach((e=>{if(!Number.isFinite(e.bufferView))throw new Error("KHR_techniques_webgl: no shader code");e.code=i.decode(t.getTypedArrayForBufferView(e.bufferView))})),r.forEach((e=>{e.fragmentShader=s[e.fragmentShader],e.vertexShader=s[e.vertexShader]})),n.forEach((e=>{e.program=r[e.program]})),n}(s,t);for(const s of r.materials||[]){const r=t.getObjectExtension(s,"KHR_techniques_webgl");r&&(s.technique=Object.assign({},r,e[r.technique]),s.technique.values=Sc(s.technique,t)),t.removeObjectExtension(s,"KHR_techniques_webgl")}t.removeExtension("KHR_techniques_webgl")}},encode:async function(e,t){}})};const Mc={accessors:"accessor",animations:"animation",buffers:"buffer",bufferViews:"bufferView",images:"image",materials:"material",meshes:"mesh",nodes:"node",samplers:"sampler",scenes:"scene",skins:"skin",textures:"texture"},Rc={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 Oc{constructor(e){this.idToIndexMap={animations:{},accessors:{},buffers:{},bufferViews:{},images:{},materials:{},meshes:{},nodes:{},samplers:{},scenes:{},skins:{},textures:{}}}normalize(e,t){this.json=e.json;const r=e.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 ${r.asset.version}`)}if(!t.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(e){const t=new vc(e),{json:r}=t;for(const e of r.images||[]){const r=t.removeObjectExtension(e,"KHR_binary_glTF");r&&Object.assign(e,r)}r.buffers&&r.buffers[0]&&delete r.buffers[0].uri,t.removeExtension("KHR_binary_glTF")}(e),this._convertObjectIdsToArrayIndices(r),this._updateObjects(r),this._updateMaterial(r)}_addAsset(e){e.asset=e.asset||{},e.asset.version="2.0",e.asset.generator=e.asset.generator||"Normalized to glTF 2.0 by loaders.gl"}_convertTopLevelObjectsToArrays(e){for(const t in Mc)this._convertTopLevelObjectToArray(e,t)}_convertTopLevelObjectToArray(e,t){const r=e[t];if(r&&!Array.isArray(r)){e[t]=[];for(const s in r){const n=r[s];n.id=n.id||s;const i=e[t].length;e[t].push(n),this.idToIndexMap[t][s]=i}}}_convertObjectIdsToArrayIndices(e){for(const t in Mc)this._convertIdsToIndices(e,t);"scene"in e&&(e.scene=this._convertIdToIndex(e.scene,"scene"));for(const t of e.textures)this._convertTextureIds(t);for(const t of e.meshes)this._convertMeshIds(t);for(const t of e.nodes)this._convertNodeIds(t);for(const t of e.scenes)this._convertSceneIds(t)}_convertTextureIds(e){e.source&&(e.source=this._convertIdToIndex(e.source,"image"))}_convertMeshIds(e){for(const t of e.primitives){const{attributes:e,indices:r,material:s}=t;for(const t in e)e[t]=this._convertIdToIndex(e[t],"accessor");r&&(t.indices=this._convertIdToIndex(r,"accessor")),s&&(t.material=this._convertIdToIndex(s,"material"))}}_convertNodeIds(e){e.children&&(e.children=e.children.map((e=>this._convertIdToIndex(e,"node")))),e.meshes&&(e.meshes=e.meshes.map((e=>this._convertIdToIndex(e,"mesh"))))}_convertSceneIds(e){e.nodes&&(e.nodes=e.nodes.map((e=>this._convertIdToIndex(e,"node"))))}_convertIdsToIndices(e,t){e[t]||(console.warn(`gltf v1: json doesn't contain attribute ${t}`),e[t]=[]);for(const r of e[t])for(const e in r){const t=r[e],s=this._convertIdToIndex(t,e);r[e]=s}}_convertIdToIndex(e,t){const r=Rc[t];if(r in this.idToIndexMap){const s=this.idToIndexMap[r][e];if(!Number.isFinite(s))throw new Error(`gltf v1: failed to resolve ${t} with id ${e}`);return s}return e}_updateObjects(e){for(const e of this.json.buffers)delete e.type}_updateMaterial(e){for(const t of e.materials){t.pbrMetallicRoughness={baseColorFactor:[1,1,1,1],metallicFactor:1,roughnessFactor:1};const r=t.values&&t.values.tex,s=e.textures.findIndex((e=>e.id===r));-1!==s&&(t.pbrMetallicRoughness.baseColorTexture={index:s})}}}const Ic={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Nc={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},Lc={TEXTURE_MAG_FILTER:10240,TEXTURE_MIN_FILTER:10241,TEXTURE_WRAP_S:10242,TEXTURE_WRAP_T:10243,REPEAT:10497,LINEAR:9729,NEAREST_MIPMAP_LINEAR:9986},Cc={magFilter:Lc.TEXTURE_MAG_FILTER,minFilter:Lc.TEXTURE_MIN_FILTER,wrapS:Lc.TEXTURE_WRAP_S,wrapT:Lc.TEXTURE_WRAP_T},Pc={[Lc.TEXTURE_MAG_FILTER]:Lc.LINEAR,[Lc.TEXTURE_MIN_FILTER]:Lc.NEAREST_MIPMAP_LINEAR,[Lc.TEXTURE_WRAP_S]:Lc.REPEAT,[Lc.TEXTURE_WRAP_]:Lc.REPEAT};class Uc{postProcess(e,t={}){const{json:r,buffers:s=[],images:n=[],baseUri:i=""}=e;return uc(r),this.baseUri=i,this.json=r,this.buffers=s,this.images=n,this._resolveTree(this.json,t),this.json}_resolveTree(e,t={}){e.bufferViews&&(e.bufferViews=e.bufferViews.map(((e,t)=>this._resolveBufferView(e,t)))),e.images&&(e.images=e.images.map(((e,t)=>this._resolveImage(e,t)))),e.samplers&&(e.samplers=e.samplers.map(((e,t)=>this._resolveSampler(e,t)))),e.textures&&(e.textures=e.textures.map(((e,t)=>this._resolveTexture(e,t)))),e.accessors&&(e.accessors=e.accessors.map(((e,t)=>this._resolveAccessor(e,t)))),e.materials&&(e.materials=e.materials.map(((e,t)=>this._resolveMaterial(e,t)))),e.meshes&&(e.meshes=e.meshes.map(((e,t)=>this._resolveMesh(e,t)))),e.nodes&&(e.nodes=e.nodes.map(((e,t)=>this._resolveNode(e,t)))),e.skins&&(e.skins=e.skins.map(((e,t)=>this._resolveSkin(e,t)))),e.scenes&&(e.scenes=e.scenes.map(((e,t)=>this._resolveScene(e,t)))),void 0!==e.scene&&(e.scene=e.scenes[this.json.scene])}getScene(e){return this._get("scenes",e)}getNode(e){return this._get("nodes",e)}getSkin(e){return this._get("skins",e)}getMesh(e){return this._get("meshes",e)}getMaterial(e){return this._get("materials",e)}getAccessor(e){return this._get("accessors",e)}getCamera(e){return null}getTexture(e){return this._get("textures",e)}getSampler(e){return this._get("samplers",e)}getImage(e){return this._get("images",e)}getBufferView(e){return this._get("bufferViews",e)}getBuffer(e){return this._get("buffers",e)}_get(e,t){if("object"==typeof t)return t;const r=this.json[e]&&this.json[e][t];return r||console.warn(`glTF file error: Could not find ${e}[${t}]`),r}_resolveScene(e,t){return e.id=e.id||`scene-${t}`,e.nodes=(e.nodes||[]).map((e=>this.getNode(e))),e}_resolveNode(e,t){return e.id=e.id||`node-${t}`,e.children&&(e.children=e.children.map((e=>this.getNode(e)))),void 0!==e.mesh?e.mesh=this.getMesh(e.mesh):void 0!==e.meshes&&e.meshes.length&&(e.mesh=e.meshes.reduce(((e,t)=>{const r=this.getMesh(t);return e.id=r.id,e.primitives=e.primitives.concat(r.primitives),e}),{primitives:[]})),void 0!==e.camera&&(e.camera=this.getCamera(e.camera)),void 0!==e.skin&&(e.skin=this.getSkin(e.skin)),e}_resolveSkin(e,t){return e.id=e.id||`skin-${t}`,e.inverseBindMatrices=this.getAccessor(e.inverseBindMatrices),e}_resolveMesh(e,t){return e.id=e.id||`mesh-${t}`,e.primitives&&(e.primitives=e.primitives.map((e=>{const t=(e={...e}).attributes;e.attributes={};for(const r in t)e.attributes[r]=this.getAccessor(t[r]);return void 0!==e.indices&&(e.indices=this.getAccessor(e.indices)),void 0!==e.material&&(e.material=this.getMaterial(e.material)),e}))),e}_resolveMaterial(e,t){if(e.id=e.id||`material-${t}`,e.normalTexture&&(e.normalTexture={...e.normalTexture},e.normalTexture.texture=this.getTexture(e.normalTexture.index)),e.occlusionTexture&&(e.occlustionTexture={...e.occlustionTexture},e.occlusionTexture.texture=this.getTexture(e.occlusionTexture.index)),e.emissiveTexture&&(e.emmisiveTexture={...e.emmisiveTexture},e.emissiveTexture.texture=this.getTexture(e.emissiveTexture.index)),e.emissiveFactor||(e.emissiveFactor=e.emmisiveTexture?[1,1,1]:[0,0,0]),e.pbrMetallicRoughness){e.pbrMetallicRoughness={...e.pbrMetallicRoughness};const t=e.pbrMetallicRoughness;t.baseColorTexture&&(t.baseColorTexture={...t.baseColorTexture},t.baseColorTexture.texture=this.getTexture(t.baseColorTexture.index)),t.metallicRoughnessTexture&&(t.metallicRoughnessTexture={...t.metallicRoughnessTexture},t.metallicRoughnessTexture.texture=this.getTexture(t.metallicRoughnessTexture.index))}return e}_resolveAccessor(e,t){var r,s;if(e.id=e.id||`accessor-${t}`,void 0!==e.bufferView&&(e.bufferView=this.getBufferView(e.bufferView)),e.bytesPerComponent=(r=e.componentType,Nc[r]),e.components=(s=e.type,Ic[s]),e.bytesPerElement=e.bytesPerComponent*e.components,e.bufferView){const t=e.bufferView.buffer,{ArrayType:r,byteLength:s}=bc(e,e.bufferView),n=(e.bufferView.byteOffset||0)+(e.byteOffset||0)+t.byteOffset,i=t.arrayBuffer.slice(n,n+s);e.value=new r(i)}return e}_resolveTexture(e,t){return e.id=e.id||`texture-${t}`,e.sampler="sampler"in e?this.getSampler(e.sampler):Pc,e.source=this.getImage(e.source),e}_resolveSampler(e,t){e.id=e.id||`sampler-${t}`,e.parameters={};for(const t in e){const r=this._enumSamplerParameter(t);void 0!==r&&(e.parameters[r]=e[t])}return e}_enumSamplerParameter(e){return Cc[e]}_resolveImage(e,t){e.id=e.id||`image-${t}`,void 0!==e.bufferView&&(e.bufferView=this.getBufferView(e.bufferView));const r=this.images[t];return r&&(e.image=r),e}_resolveBufferView(e,t){e.id=e.id||`bufferView-${t}`;const r=e.buffer;e.buffer=this.buffers[r];const s=this.buffers[r].arrayBuffer;let n=this.buffers[r].byteOffset||0;return"byteOffset"in e&&(n+=e.byteOffset),e.data=new Uint8Array(s,n,e.byteLength),e}_resolveCamera(e,t){return e.id=e.id||`camera-${t}`,e.perspective,e.orthographic,e}}const kc=1735152710,Dc=!0;function jc(e,t,r=0,s={}){const n=new DataView(t),i=function(e,t=0){return`${String.fromCharCode(e.getUint8(t+0))}${String.fromCharCode(e.getUint8(t+1))}${String.fromCharCode(e.getUint8(t+2))}${String.fromCharCode(e.getUint8(t+3))}`}(n,r+0),o=n.getUint32(r+4,Dc),a=n.getUint32(r+8,Dc);switch(Object.assign(e,{header:{byteOffset:r,byteLength:a,hasBinChunk:!1},type:i,version:o,json:{},binChunks:[]}),r+=12,e.version){case 1:return function(e,t,r){Te(e.header.byteLength>20);const s=t.getUint32(r+0,Dc),n=t.getUint32(r+4,Dc);return r+=8,Te(0===n),Bc(e,t,r,s),r+=s,r+=Fc(e,t,r,e.header.byteLength)}(e,n,r);case 2:return function(e,t,r,s){return Te(e.header.byteLength>20),function(e,t,r,s){for(;r+8<=e.header.byteLength;){const n=t.getUint32(r+0,Dc),i=t.getUint32(r+4,Dc);switch(r+=8,i){case 1313821514:Bc(e,t,r,n);break;case 5130562:Fc(e,t,r,n);break;case 0:s.strict||Bc(e,t,r,n);break;case 1:s.strict||Fc(e,t,r,n)}r+=Je(n,4)}}(e,t,r,s),r+e.header.byteLength}(e,n,r,{});default:throw new Error(`Invalid GLB version ${e.version}. Only supports v1 and v2.`)}}function Bc(e,t,r,s){const n=new Uint8Array(t.buffer,r,s),i=new TextDecoder("utf8").decode(n);return e.json=JSON.parse(i),Je(s,4)}function Fc(e,t,r,s){return e.header.hasBinChunk=!0,e.binChunks.push({byteOffset:r,byteLength:s,arrayBuffer:t.buffer}),Je(s,4)}async function Vc(e,t,r=0,s,n){var i,o,a,c;!function(e,t,r,s){s.uri&&(e.baseUri=s.uri);if(t instanceof ArrayBuffer&&!function(e,t=0,r={}){const s=new DataView(e),{magic:n=kc}=r,i=s.getUint32(t,!1);return i===n||i===kc}(t,r,s)){t=(new TextDecoder).decode(t)}if("string"==typeof t)e.json=Xe(t);else if(t instanceof ArrayBuffer){const n={};r=jc(n,t,r,s.glb),uc("glTF"===n.type,`Invalid GLB magic string ${n.type}`),e._glb=n,e.json=n.json}else uc(!1,"GLTF: must be ArrayBuffer or string");const n=e.json.buffers||[];if(e.buffers=new Array(n.length).fill(null),e._glb&&e._glb.header.hasBinChunk){const{binChunks:t}=e._glb;e.buffers[0]={arrayBuffer:t[0].arrayBuffer,byteOffset:t[0].byteOffset,byteLength:t[0].byteLength}}const i=e.json.images||[];e.images=new Array(i.length).fill({})}(e,t,r,s),function(e,t={}){(new Oc).normalize(e,t)}(e,{normalize:null==s||null===(i=s.gltf)||void 0===i?void 0:i.normalize});const u=[];if(null!=s&&null!==(o=s.gltf)&&void 0!==o&&o.loadBuffers&&e.json.buffers&&await async function(e,t,r){for(let i=0;i<e.json.buffers.length;++i){const o=e.json.buffers[i];if(o.uri){var s,n;const{fetch:a}=r;uc(a);const c=hc(o.uri,t),u=await(null==r||null===(s=r.fetch)||void 0===s?void 0:s.call(r,c)),h=await(null==u||null===(n=u.arrayBuffer)||void 0===n?void 0:n.call(u));e.buffers[i]={arrayBuffer:h,byteOffset:0,byteLength:h.byteLength},delete o.uri}}}(e,s,n),null!=s&&null!==(a=s.gltf)&&void 0!==a&&a.loadImages){const t=async function(e,t,r){const s=e.json.images||[],n=[];for(let i=0;i<s.length;++i)n.push(qc(e,s[i],i,t,r));return await Promise.all(n)}(e,s,n);u.push(t)}const h=async function(e,t={},r){for(const n in Ac){var s;const i=(null==t||null===(s=t.gltf)||void 0===s?void 0:s.excludeExtensions)||{};if(!(n in i)||i[n]){const s=Ac[n];await s.decode(e,t,r)}}}(e,s,n);return u.push(h),await Promise.all(u),null!=s&&null!==(c=s.gltf)&&void 0!==c&&c.postProcess?function(e,t){return(new Uc).postProcess(e,t)}(e,s):e}async function qc(e,t,r,s,n){const{fetch:i,parse:o}=n;let a;if(t.uri){const e=hc(t.uri,s),r=await i(e);a=await r.arrayBuffer()}if(Number.isFinite(t.bufferView)){const r=function(e,t,r){const s=e.bufferViews[r];uc(s);const n=t[s.buffer];uc(n);const i=(s.byteOffset||0)+n.byteOffset;return new Uint8Array(n.arrayBuffer,i,s.byteLength)}(e.json,e.buffers,t.bufferView);a=Ze(r.buffer,r.byteOffset,r.byteLength)}uc(a,"glTF image has no data");const c=await o(a,cc,{},n);e.images[r]=c}const zc={name:"glTF",id:"gltf",module:"gltf",version:"3.0.10",extensions:["gltf","glb"],mimeTypes:["model/gltf+json","model/gltf-binary"],text:!0,binary:!0,tests:["glTF"],parse:async function(e,t={},r){(t={...zc.options,...t}).gltf={...zc.options.gltf,...t.gltf};const{byteOffset:s=0}=t;return await Vc({},e,s,t,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 Gc=0,Hc=1;function $c(e,t,r,s){e.rotateYtoZ=!0;const n=e.byteOffset+e.byteLength-r;if(0===n)throw new Error("glTF byte length must be greater than 0.");return e.gltfUpAxis=s["3d-tiles"]&&s["3d-tiles"].assetGltfUpAxis?s["3d-tiles"].assetGltfUpAxis:"Y",e.gltfArrayBuffer=Ze(t,r,n),e.gltfByteOffset=0,e.gltfByteLength=n,r%4==0||console.warn(`${e.type}: embedded glb is not aligned to a 4-byte boundary.`),e.byteOffset+e.byteLength}async function Wc(e,t,r,s){const n=r["3d-tiles"]||{};if(function(e,t,r){switch(t){case Gc:const t=new Uint8Array(e.gltfArrayBuffer,e.gltfByteOffset),r=(new TextDecoder).decode(t);e.gltfUrl=r.replace(/[\s\0]+$/,""),delete e.gltfArrayBuffer,delete e.gltfByteOffset,delete e.gltfByteLength;break;case Hc:break;default:throw new Error("b3dm: Illegal glTF format field")}}(e,t),n.loadGLTF){const{parse:t,fetch:n}=s;e.gltfUrl&&(e.gltfArrayBuffer=await n(e.gltfUrl,r),e.gltfByteOffset=0),e.gltfArrayBuffer&&(e.gltf=await t(e.gltfArrayBuffer,zc,r,s),delete e.gltfArrayBuffer,delete e.gltfByteOffset,delete e.gltfByteLength)}}async function Kc(e,t,r,s,n){var i;r=function(e,t,r,s,n){r=Pa(e,t,r),r=Ua(e,t,r),r=ka(e,t,r),r=$c(e,t,r,s);const i=new _a(e.featureTableJson,e.featureTableBinary);return e.rtcCenter=i.getGlobalProperty("RTC_CENTER",pa.FLOAT,3),r}(e,t,r,s),await Wc(e,Hc,s,n);const o=null==e||null===(i=e.gltf)||void 0===i?void 0:i.extensions;return o&&o.CESIUM_RTC&&(e.rtcCenter=o.CESIUM_RTC.center),r}async function Qc(e,t,r,s,n){return r=function(e,t,r,s,n){if(r=Pa(e,t,r),1!==e.version)throw new Error(`Instanced 3D Model version ${e.version} is not supported`);r=Ua(e,t,r);const i=new DataView(t);if(e.gltfFormat=i.getUint32(r,!0),r=ka(e,t,r+=4),r=$c(e,t,r,s),0===e.featureTableJsonByteLength)throw new Error("i3dm parser: featureTableJsonByteLength is zero.");const o=new _a(e.featureTableJson,e.featureTableBinary),a=o.getGlobalProperty("INSTANCES_LENGTH");if(o.featuresLength=a,!Number.isFinite(a))throw new Error("i3dm parser: INSTANCES_LENGTH must be defined");e.eastNorthUp=o.getGlobalProperty("EAST_NORTH_UP"),e.rtcCenter=o.getGlobalProperty("RTC_CENTER",pa.FLOAT,3);new Ca(e.batchTableJson,e.batchTableBinary,a);return function(e,t,r,s){const n=[new Array(s),e._batchTable][0],i=new ss;new ss,new ss,new ss;const o=new ls,a=new Xs,c=new ss,u={},h=new Ls,l=[],d=[],f=new ss,p=new ss;for(let r=0;r<s;r++){let s;if(t.hasProperty("POSITION"))s=t.getProperty("POSITION",pa.FLOAT,3,r,i);else if(t.hasProperty("POSITION_QUANTIZED")){s=t.getProperty("POSITION_QUANTIZED",pa.UNSIGNED_SHORT,3,r,i);const e=t.getGlobalProperty("QUANTIZED_VOLUME_OFFSET",pa.FLOAT,3,f);if(!e)throw new Error("i3dm parser: QUANTIZED_VOLUME_OFFSET must be defined for quantized positions.");const n=t.getGlobalProperty("QUANTIZED_VOLUME_SCALE",pa.FLOAT,3,p);if(!n)throw new Error("i3dm parser: QUANTIZED_VOLUME_SCALE must be defined for quantized positions.");const o=65535;for(let t=0;t<3;t++)s[t]=s[t]/o*n[t]+e[t]}if(!s)throw new Error("i3dm: POSITION or POSITION_QUANTIZED must be defined for each instance.");if(i.copy(s),u.translation=i,e.normalUp=t.getProperty("NORMAL_UP",pa.FLOAT,3,r,l),e.normalRight=t.getProperty("NORMAL_RIGHT",pa.FLOAT,3,r,d),e.normalUp){if(!e.normalRight)throw new Error("i3dm: Custom orientation requires both NORMAL_UP and NORMAL_RIGHT.");e.hasCustomOrientation=!0}else{if(e.octNormalUp=t.getProperty("NORMAL_UP_OCT32P",pa.UNSIGNED_SHORT,2,l),e.octNormalRight=t.getProperty("NORMAL_RIGHT_OCT32P",pa.UNSIGNED_SHORT,2,d),e.octNormalUp){if(!e.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")}e.eastNorthUp?(Qn.WGS84.eastNorthUpToFixedFrame(i,h),h.getRotationMatrix3(o)):o.identity()}a.fromMatrix3(o),u.rotation=a,c.set(1,1,1);const m=t.getProperty("SCALE",pa.FLOAT,1,r);Number.isFinite(m)&&c.multiplyByScalar(m);const g=t.getProperty("SCALE_NON_UNIFORM",pa.FLOAT,3,r,l);g&&c.scale(g),u.scale=c;let y=t.getProperty("BATCH_ID",pa.UNSIGNED_SHORT,1,r);void 0===y&&(y=r);const w=(new Ls).fromQuaternion(u.rotation);h.identity(),h.translate(u.translation),h.multiplyRight(w),h.scale(u.scale);const b=h.clone();n[r]={modelMatrix:b,batchId:y}}e.instances=n}(e,o,0,a),r}(e,t,r,s),await Wc(e,e.gltfFormat,s,n),r}async function Xc(e,t=0,r,s,n={}){switch(n.byteOffset=t,n.type=function(e,t=0){const r=new DataView(e);return`${String.fromCharCode(r.getUint8(t+0))}${String.fromCharCode(r.getUint8(t+1))}${String.fromCharCode(r.getUint8(t+2))}${String.fromCharCode(r.getUint8(t+3))}`}(e,t),n.type){case Oo:return await async function(e,t,r,s,n,i){r=Pa(e,t,r);const o=new DataView(t);for(e.tilesLength=o.getUint32(r,!0),r+=4,e.tiles=[];e.tiles.length<e.tilesLength&&e.byteLength-r>12;){const o={};e.tiles.push(o),r=await i(t,r,s,n,o)}return r}(n,e,t,r,s,Xc);case No:return await Kc(n,e,t,r,s);case Lo:return await Qc(n,e,t,r,s);case Io:return await Fa(n,e,t,r,s);default:throw new Error(`3DTileLoader: unknown type ${n.type}`)}}function Yc(e,t){if(e.content){const r=e.content.uri||e.content.url;e.contentUrl=`${t.basePath}/${r}`}return e.id=e.contentUrl,e.lodMetricType=ro,e.lodMetricValue=e.geometricError,e.transformMatrix=e.transform,e.type=function(e){if(!e.contentUrl)return Xi;const t=e.contentUrl.split(".").pop();switch(t){case"pnts":return Zi;case"i3dm":case"b3dm":return Yi;default:return t}}(e),e.refine=function(e){switch(e){case"REPLACE":case"replace":return Qi;case"ADD":case"add":return Ki;default:return e}}(e.refine),e}const Zc={id:"3d-tiles",name:"3D Tiles",module:"3d-tiles",version:"3.0.10",extensions:["cmpt","pnts","b3dm","i3dm"],mimeTypes:["application/octet-stream"],tests:["cmpt","pnts","b3dm","i3dm"],parse:async function(e,t,r){const s=t["3d-tiles"]||{};let n;n="auto"===s.isTileset?r.url&&-1!==r.url.indexOf(".json"):s.isTileset;e=n?await async function(e,t,r){const s=JSON.parse((new TextDecoder).decode(e));return s.loader=t.loader||Zc,s.url=r.url,s.basePath=function(e){return at(e.url)}(s),s.root=function(e){const t=e.basePath,r=Yc(e.root,e),s=[];for(s.push(r);s.length>0;){const e=s.pop().children||[];for(const r of e)Yc(r,{basePath:t}),s.push(r)}return r}(s),s.type=to,s.lodMetricType=ro,s.lodMetricValue=s.root.lodMetricValue,s}(e,t,r):await async function(e,t,r){const s={content:{featureIds:null}},n=0;return await Xc(e,n,t,r,s.content),s.content}(e,t,r);return e},options:{"3d-tiles":{loadGLTF:!0,decodeQuantizedPositions:!1,isTileset:"auto",assetGltfUpAxis:null}}};const Jc="https://api.cesium.com/v1/assets";async function eu(e,t){if(!t){const r=await async function(e){Te(e);const t=Jc,r={Authorization:`Bearer ${e}`},s=await Et(t,{fetch:{headers:r}});if(!s.ok)throw new Error(s.statusText);return await s.json()}(e);for(const e of r.items)"3DTILES"===e.type&&(t=e.id)}const r=await async function(e,t){Te(e,t);const r={Authorization:`Bearer ${e}`},s=`${Jc}/${t}`;let n=await Et(`${s}`,{fetch:{headers:r}});if(!n.ok)throw new Error(n.statusText);let i=await n.json();if(n=await Et(`${s}/endpoint`,{fetch:{headers:r}}),!n.ok)throw new Error(n.statusText);const o=await n.json();return i={...i,...o},i}(e,t),{type:s,url:n}=r;return Te("3DTILES"===s&&n),r.headers={Authorization:`Bearer ${r.accessToken}`},r}const tu={...Zc,id:"cesium-ion",name:"Cesium Ion",preload:async function(e,t={}){t=t["cesium-ion"]||{};const{accessToken:r}=t;let s=t.assetId;if(!Number.isFinite(s)){const t=e.match(/\/([0-9]+)\/tileset.json/);s=t&&t[1]}return eu(r,s)},parse:async(e,t,r)=>((t={...t})["3d-tiles"]=t["cesium-ion"],t.loader=tu,Zc.parse(e,t,r)),options:{"cesium-ion":{...Zc.options["3d-tiles"],accessToken:null}}};function ru(s){const n=64,i=document.createElement("canvas");i.width=n,i.height=n;const o=i.getContext("2d");o.rect(0,0,n,n);const a=o.createLinearGradient(0,0,n,n);for(let e=0;e<s.length;e++){const t=s[e];a.addColorStop(t[0],"#"+t[1].getHexString())}o.fillStyle=a,o.fill();const c=new e(i);return c.needsUpdate=!0,c.minFilter=t,c.wrapS=r,c.wrapT=r,c.repeat.set(2,2),c}function su(e){e.updateMatrix(),e.updateMatrixWorld(),e.matrixWorldInverse.copy(e.matrixWorld).invert();const t=new s;return t.setFromProjectionMatrix((new n).multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse)),t}function nu(e){const t=e.boundingVolume;let r=0;e.content&&(r=Math.min(e.content.byteLength/5e5,1));const s=new d(r,1,0),i=new f(1,1,1),o=function(e){const t=e;return(new n).fromArray([2*t[0],2*t[1],2*t[2],0,2*t[3],2*t[4],2*t[5],0,2*t[6],2*t[7],2*t[8],0,0,0,0,1])}(t.halfAxes);i.applyMatrix4(o);const c=new p(i),u=new m(c,new g({color:s}));return u.position.copy(new a(...t.center)),u}class iu extends b{constructor(e){super(e),this.dracoLoader=null,this.ddsLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register((function(e){return new lu(e)})),this.register((function(e){return new fu(e)})),this.register((function(e){return new pu(e)})),this.register((function(e){return new du(e)})),this.register((function(e){return new uu(e)})),this.register((function(e){return new mu(e)}))}load(e,t,r,s){var n,i=this;n=""!==this.resourcePath?this.resourcePath:""!==this.path?this.path:T.extractUrlBase(e),this.manager.itemStart(e);var o=function(t){s?s(t):console.error(t),i.manager.itemError(e),i.manager.itemEnd(e)},a=new v(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,(function(r){try{i.parse(r,n,(function(r){t(r),i.manager.itemEnd(e)}),o)}catch(e){o(e)}}),r,o)}setDRACOLoader(e){return this.dracoLoader=e,this}setDDSLoader(e){return this.ddsLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return-1===this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.push(e),this}unregister(e){return-1!==this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,r,s){var n,i={},o={};if("string"==typeof e)n=e;else if(T.decodeText(new Uint8Array(e,0,4))===gu){try{i[au.KHR_BINARY_GLTF]=new bu(e)}catch(e){return void(s&&s(e))}n=i[au.KHR_BINARY_GLTF].content}else n=T.decodeText(new Uint8Array(e));var a=e instanceof ArrayBuffer?JSON.parse(n):e;if(void 0===a.asset||a.asset.version[0]<2)s&&s(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));else{var c=new Qu(a,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(var u=0;u<this.pluginCallbacks.length;u++){var h=this.pluginCallbacks[u](c);o[h.name]=h,i[h.name]=!0}if(a.extensionsUsed)for(u=0;u<a.extensionsUsed.length;++u){var l=a.extensionsUsed[u],d=a.extensionsRequired||[];switch(l){case au.KHR_MATERIALS_UNLIT:i[l]=new hu;break;case au.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:i[l]=new Eu;break;case au.KHR_DRACO_MESH_COMPRESSION:i[l]=new Tu(a,this.dracoLoader);break;case au.MSFT_TEXTURE_DDS:i[l]=new cu(this.ddsLoader);break;case au.KHR_TEXTURE_TRANSFORM:i[l]=new vu;break;case au.KHR_MESH_QUANTIZATION:i[l]=new xu;break;default:d.indexOf(l)>=0&&void 0===o[l]&&console.warn('THREE.GLTFLoader: Unknown extension "'+l+'".')}}c.setExtensions(i),c.setPlugins(o),c.parse(r,s)}}}function ou(){var e={};return{get:function(t){return e[t]},add:function(t,r){e[t]=r},remove:function(t){delete e[t]},removeAll:function(){e={}}}}var au={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:"KHR_materials_pbrSpecularGlossiness",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",MSFT_TEXTURE_DDS:"MSFT_texture_dds"};function cu(e){if(!e)throw new Error("THREE.GLTFLoader: Attempting to load .dds texture without importing DDSLoader");this.name=au.MSFT_TEXTURE_DDS,this.ddsLoader=e}function uu(e){this.parser=e,this.name=au.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}function hu(){this.name=au.KHR_MATERIALS_UNLIT}function lu(e){this.parser=e,this.name=au.KHR_MATERIALS_CLEARCOAT}function du(e){this.parser=e,this.name=au.KHR_MATERIALS_TRANSMISSION}function fu(e){this.parser=e,this.name=au.KHR_TEXTURE_BASISU}function pu(e){this.parser=e,this.name=au.EXT_TEXTURE_WEBP,this.isSupported=null}function mu(e){this.name=au.EXT_MESHOPT_COMPRESSION,this.parser=e}uu.prototype._markDefs=function(){for(var e=this.parser,t=this.parser.json.nodes||[],r=0,s=t.length;r<s;r++){var n=t[r];n.extensions&&n.extensions[this.name]&&void 0!==n.extensions[this.name].light&&e._addNodeRef(this.cache,n.extensions[this.name].light)}},uu.prototype._loadLight=function(e){var t=this.parser,r="light:"+e,s=t.cache.get(r);if(s)return s;var n,i=t.json,o=((i.extensions&&i.extensions[this.name]||{}).lights||[])[e],a=new d(16777215);void 0!==o.color&&a.fromArray(o.color);var c=void 0!==o.range?o.range:0;switch(o.type){case"directional":(n=new x(a)).target.position.set(0,0,-1),n.add(n.target);break;case"point":(n=new E(a)).distance=c;break;case"spot":(n=new _(a)).distance=c,o.spot=o.spot||{},o.spot.innerConeAngle=void 0!==o.spot.innerConeAngle?o.spot.innerConeAngle:0,o.spot.outerConeAngle=void 0!==o.spot.outerConeAngle?o.spot.outerConeAngle:Math.PI/4,n.angle=o.spot.outerConeAngle,n.penumbra=1-o.spot.innerConeAngle/o.spot.outerConeAngle,n.target.position.set(0,0,-1),n.add(n.target);break;default:throw new Error('THREE.GLTFLoader: Unexpected light type, "'+o.type+'".')}return n.position.set(0,0,0),n.decay=2,void 0!==o.intensity&&(n.intensity=o.intensity),n.name=t.createUniqueName(o.name||"light_"+e),s=Promise.resolve(n),t.cache.add(r,s),s},uu.prototype.createNodeAttachment=function(e){var t=this,r=this.parser,s=r.json.nodes[e]||e,n=(s.extensions&&s.extensions[this.name]||{}).light;return void 0===n?null:this._loadLight(n).then((function(e){return r._getNodeRef(t.cache,n,e)}))},hu.prototype.getMaterialType=function(){return c},hu.prototype.extendParams=function(e,t,r){var s=[];e.color=new d(1,1,1),e.opacity=1;var n=t.pbrMetallicRoughness;if(n){if(Array.isArray(n.baseColorFactor)){var i=n.baseColorFactor;e.color.fromArray(i),e.opacity=i[3]}void 0!==n.baseColorTexture&&s.push(r.assignTexture(e,"map",n.baseColorTexture))}return Promise.all(s)},lu.prototype.getMaterialType=function(e){var t=this.parser.json.materials[e]||e;return t.extensions&&t.extensions[this.name]?S:null},lu.prototype.extendMaterialParams=function(e,t){var r=this.parser,s=r.json.materials[e]||e;if(!s.extensions||!s.extensions[this.name])return Promise.resolve();var n=[],i=s.extensions[this.name];if(void 0!==i.clearcoatFactor&&(t.clearcoat=i.clearcoatFactor),void 0!==i.clearcoatTexture&&n.push(r.assignTexture(t,"clearcoatMap",i.clearcoatTexture)),void 0!==i.clearcoatRoughnessFactor&&(t.clearcoatRoughness=i.clearcoatRoughnessFactor),void 0!==i.clearcoatRoughnessTexture&&n.push(r.assignTexture(t,"clearcoatRoughnessMap",i.clearcoatRoughnessTexture)),void 0!==i.clearcoatNormalTexture&&(n.push(r.assignTexture(t,"clearcoatNormalMap",i.clearcoatNormalTexture)),void 0!==i.clearcoatNormalTexture.scale)){var o=i.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new A(o,o)}return Promise.all(n)},du.prototype.getMaterialType=function(e){var t=this.parser.json.materials[e]||e;return t.extensions&&t.extensions[this.name]?S:null},du.prototype.extendMaterialParams=function(e,t){var r=this.parser,s=r.json.materials[e]||e;if(!s.extensions||!s.extensions[this.name])return Promise.resolve();var n=[],i=s.extensions[this.name];return void 0!==i.transmissionFactor&&(t.transmission=i.transmissionFactor),void 0!==i.transmissionTexture&&n.push(r.assignTexture(t,"transmissionMap",i.transmissionTexture)),Promise.all(n)},fu.prototype.loadTexture=function(e){var t=this.parser,r=t.json,s=r.textures[e]||e;if(!s.extensions||!s.extensions[this.name])return null;var n=s.extensions[this.name],i=r.images[n.source],o=t.options.ktx2Loader;if(!o){if(r.extensionsRequired&&r.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,i,o)},pu.prototype.loadTexture=function(e){var t=this.name,r=this.parser,s=r.json,n=s.textures[e];if(!n.extensions||!n.extensions[t])return null;var i=n.extensions[t],o=s.images[i.source],a=o.uri?r.options.manager.getHandler(o.uri):r.textureLoader;return this.detectSupport().then((function(n){if(n)return r.loadTextureImage(e,o,a);if(s.extensionsRequired&&s.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return r.loadTexture(e)}))},pu.prototype.detectSupport=function(){return this.isSupported||(this.isSupported=new Promise((function(e){var t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(1===t.height)}}))),this.isSupported},mu.prototype.loadBufferView=function(e){var t=this.parser.json,r=t.bufferViews[e]||e;if(r.extensions&&r.extensions[this.name]){var s=r.extensions[this.name],n=this.parser.getDependency("buffer",s.buffer),i=this.parser.options.meshoptDecoder;if(!i||!i.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return Promise.all([n,i.ready]).then((function(e){var t=s.byteOffset||0,r=s.byteLength||0,n=s.count,o=s.byteStride,a=new ArrayBuffer(n*o),c=new Uint8Array(e[0],t,r);return i.decodeGltfBuffer(new Uint8Array(a),n,o,c,s.mode,s.filter),a}))}return null};var gu="glTF",yu=1313821514,wu=5130562;function bu(e){this.name=au.KHR_BINARY_GLTF,this.content=null,this.body=null;var t=new DataView(e,0,12);if(this.header={magic:T.decodeText(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==gu)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");for(var r=new DataView(e,12),s=0;s<r.byteLength;){var n=r.getUint32(s,!0);s+=4;var i=r.getUint32(s,!0);if(s+=4,i===yu){var o=new Uint8Array(e,12+s,n);this.content=T.decodeText(o)}else if(i===wu){var a=12+s;this.body=e.slice(a,a+n)}s+=n}if(null===this.content)throw new Error("THREE.GLTFLoader: JSON content not found.")}function Tu(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=au.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}function vu(){this.name=au.KHR_TEXTURE_TRANSFORM}function _u(e){y.call(this),this.isGLTFSpecularGlossinessMaterial=!0;var t=["#ifdef USE_SPECULARMAP","\tuniform sampler2D specularMap;","#endif"].join("\n"),r=["#ifdef USE_GLOSSINESSMAP","\tuniform sampler2D glossinessMap;","#endif"].join("\n"),s=["vec3 specularFactor = specular;","#ifdef USE_SPECULARMAP","\tvec4 texelSpecular = texture2D( specularMap, vUv );","\ttexelSpecular = sRGBToLinear( texelSpecular );","\t// reads channel RGB, compatible with a glTF Specular-Glossiness (RGBA) texture","\tspecularFactor *= texelSpecular.rgb;","#endif"].join("\n"),n=["float glossinessFactor = glossiness;","#ifdef USE_GLOSSINESSMAP","\tvec4 texelGlossiness = texture2D( glossinessMap, vUv );","\t// reads channel A, compatible with a glTF Specular-Glossiness (RGBA) texture","\tglossinessFactor *= texelGlossiness.a;","#endif"].join("\n"),i=["PhysicalMaterial material;","material.diffuseColor = diffuseColor.rgb * ( 1. - max( specularFactor.r, max( specularFactor.g, specularFactor.b ) ) );","vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );","float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );","material.specularRoughness = max( 1.0 - glossinessFactor, 0.0525 ); // 0.0525 corresponds to the base mip of a 256 cubemap.","material.specularRoughness += geometryRoughness;","material.specularRoughness = min( material.specularRoughness, 1.0 );","material.specularColor = specularFactor;"].join("\n"),o={specular:{value:(new d).setHex(16777215)},glossiness:{value:1},specularMap:{value:null},glossinessMap:{value:null}};this._extraUniforms=o,this.onBeforeCompile=function(e){for(var a in o)e.uniforms[a]=o[a];e.fragmentShader=e.fragmentShader.replace("uniform float roughness;","uniform vec3 specular;").replace("uniform float metalness;","uniform float glossiness;").replace("#include <roughnessmap_pars_fragment>",t).replace("#include <metalnessmap_pars_fragment>",r).replace("#include <roughnessmap_fragment>",s).replace("#include <metalnessmap_fragment>",n).replace("#include <lights_physical_fragment>",i)},Object.defineProperties(this,{specular:{get:function(){return o.specular.value},set:function(e){o.specular.value=e}},specularMap:{get:function(){return o.specularMap.value},set:function(e){o.specularMap.value=e,e?this.defines.USE_SPECULARMAP="":delete this.defines.USE_SPECULARMAP}},glossiness:{get:function(){return o.glossiness.value},set:function(e){o.glossiness.value=e}},glossinessMap:{get:function(){return o.glossinessMap.value},set:function(e){o.glossinessMap.value=e,e?(this.defines.USE_GLOSSINESSMAP="",this.defines.USE_UV=""):(delete this.defines.USE_GLOSSINESSMAP,delete this.defines.USE_UV)}}}),delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this.setValues(e)}function Eu(){return{name:au.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS,specularGlossinessParams:["color","map","lightMap","lightMapIntensity","aoMap","aoMapIntensity","emissive","emissiveIntensity","emissiveMap","bumpMap","bumpScale","normalMap","normalMapType","displacementMap","displacementScale","displacementBias","specularMap","specular","glossinessMap","glossiness","alphaMap","envMap","envMapIntensity","refractionRatio"],getMaterialType:function(){return _u},extendParams:function(e,t,r){var s=t.extensions[this.name];e.color=new d(1,1,1),e.opacity=1;var n=[];if(Array.isArray(s.diffuseFactor)){var i=s.diffuseFactor;e.color.fromArray(i),e.opacity=i[3]}if(void 0!==s.diffuseTexture&&n.push(r.assignTexture(e,"map",s.diffuseTexture)),e.emissive=new d(0,0,0),e.glossiness=void 0!==s.glossinessFactor?s.glossinessFactor:1,e.specular=new d(1,1,1),Array.isArray(s.specularFactor)&&e.specular.fromArray(s.specularFactor),void 0!==s.specularGlossinessTexture){var o=s.specularGlossinessTexture;n.push(r.assignTexture(e,"glossinessMap",o)),n.push(r.assignTexture(e,"specularMap",o))}return Promise.all(n)},createMaterial:function(e){var t=new _u(e);return t.fog=!0,t.color=e.color,t.map=void 0===e.map?null:e.map,t.lightMap=null,t.lightMapIntensity=1,t.aoMap=void 0===e.aoMap?null:e.aoMap,t.aoMapIntensity=1,t.emissive=e.emissive,t.emissiveIntensity=1,t.emissiveMap=void 0===e.emissiveMap?null:e.emissiveMap,t.bumpMap=void 0===e.bumpMap?null:e.bumpMap,t.bumpScale=1,t.normalMap=void 0===e.normalMap?null:e.normalMap,t.normalMapType=M,e.normalScale&&(t.normalScale=e.normalScale),t.displacementMap=null,t.displacementScale=1,t.displacementBias=0,t.specularMap=void 0===e.specularMap?null:e.specularMap,t.specular=e.specular,t.glossinessMap=void 0===e.glossinessMap?null:e.glossinessMap,t.glossiness=e.glossiness,t.alphaMap=null,t.envMap=void 0===e.envMap?null:e.envMap,t.envMapIntensity=1,t.refractionRatio=.98,t}}}function xu(){this.name=au.KHR_MESH_QUANTIZATION}function Su(e,t,r,s){w.call(this,e,t,r,s)}Tu.prototype.decodePrimitive=function(e,t){var r=this.json,s=this.dracoLoader,n=e.extensions[this.name].bufferView,i=e.extensions[this.name].attributes,o={},a={},c={};for(var u in i){var h=Du[u]||u.toLowerCase();o[h]=i[u]}for(u in e.attributes){h=Du[u]||u.toLowerCase();if(void 0!==i[u]){var l=r.accessors[e.attributes[u]],d=Cu[l.componentType];c[h]=d,a[h]=!0===l.normalized}}return t.getDependency("bufferView",n).then((function(e){return new Promise((function(t){s.decodeDracoFile(e,(function(e){for(var r in e.attributes){var s=e.attributes[r],n=a[r];void 0!==n&&(s.normalized=n)}t(e)}),o,c)}))}))},vu.prototype.extendTexture=function(e,t){return e=e.clone(),void 0!==t.offset&&e.offset.fromArray(t.offset),void 0!==t.rotation&&(e.rotation=t.rotation),void 0!==t.scale&&e.repeat.fromArray(t.scale),void 0!==t.texCoord&&console.warn('THREE.GLTFLoader: Custom UV sets in "'+this.name+'" extension not yet supported.'),e.needsUpdate=!0,e},_u.prototype=Object.create(y.prototype),_u.prototype.constructor=_u,_u.prototype.copy=function(e){return y.prototype.copy.call(this,e),this.specularMap=e.specularMap,this.specular.copy(e.specular),this.glossinessMap=e.glossinessMap,this.glossiness=e.glossiness,delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this},Su.prototype=Object.create(w.prototype),Su.prototype.constructor=Su,Su.prototype.copySampleValue_=function(e){for(var t=this.resultBuffer,r=this.sampleValues,s=this.valueSize,n=e*s*3+s,i=0;i!==s;i++)t[i]=r[n+i];return t},Su.prototype.beforeStart_=Su.prototype.copySampleValue_,Su.prototype.afterEnd_=Su.prototype.copySampleValue_,Su.prototype.interpolate_=function(e,t,r,s){for(var n=this.resultBuffer,i=this.sampleValues,o=this.valueSize,a=2*o,c=3*o,u=s-t,h=(r-t)/u,l=h*h,d=l*h,f=e*c,p=f-c,m=-2*d+3*l,g=d-l,y=1-m,w=g-l+h,b=0;b!==o;b++){var T=i[p+b+o],v=i[p+b+a]*u,_=i[f+b+o],E=i[f+b]*u;n[b]=y*T+w*v+m*_+g*E}return n};var Au=0,Mu=1,Ru=2,Ou=3,Iu=4,Nu=5,Lu=6,Cu={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Pu={9728:Z,9729:t,9984:J,9985:ee,9986:te,9987:P},Uu={33071:re,33648:se,10497:r},ku={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Du={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv2",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},ju={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},Bu={CUBICSPLINE:void 0,LINEAR:W,STEP:ne},Fu="OPAQUE",Vu="MASK",qu="BLEND";function zu(e,t){return"string"!=typeof e||""===e?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}function Gu(e){return void 0===e.DefaultMaterial&&(e.DefaultMaterial=new y({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:ie})),e.DefaultMaterial}function Hu(e,t,r){for(var s in r.extensions)void 0===e[s]&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[s]=r.extensions[s])}function $u(e,t){void 0!==t.extras&&("object"==typeof t.extras?Object.assign(e.userData,t.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras))}function Wu(e,t){if(e.updateMorphTargets(),void 0!==t.weights)for(var r=0,s=t.weights.length;r<s;r++)e.morphTargetInfluences[r]=t.weights[r];if(t.extras&&Array.isArray(t.extras.targetNames)){var n=t.extras.targetNames;if(e.morphTargetInfluences.length===n.length){e.morphTargetDictionary={};for(r=0,s=n.length;r<s;r++)e.morphTargetDictionary[n[r]]=r}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function Ku(e){for(var t="",r=Object.keys(e).sort(),s=0,n=r.length;s<n;s++)t+=r[s]+":"+e[r[s]]+";";return t}function Qu(e,t){this.json=e||{},this.extensions={},this.plugins={},this.options=t||{},this.cache=new ou,this.associations=new Map,this.primitiveCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.nodeNamesUsed={},"undefined"!=typeof createImageBitmap&&!1===/Firefox/.test(navigator.userAgent)?this.textureLoader=new R(this.options.manager):this.textureLoader=new O(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.fileLoader=new v(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}function Xu(e,t,r){var s=t.attributes,n=[];function i(t,s){return r.getDependency("accessor",t).then((function(t){e.setAttribute(s,t)}))}for(var o in s){var c=Du[o]||o.toLowerCase();c in e.attributes&&null!=e.attributes[c]||n.push(i(s[o],c))}if(void 0!==t.indices&&!e.index){var u=r.getDependency("accessor",t.indices).then((function(t){e.setIndex(t)}));n.push(u)}return $u(e,t),function(e,t,r){var s=t.attributes,n=new le;if(void 0!==s.POSITION){var i=(f=r.json.accessors[s.POSITION]||s.POSITION).min,o=f.max;if(void 0!==i&&void 0!==o){n.set(new a(i[0],i[1],i[2]),new a(o[0],o[1],o[2]));var c=t.targets;if(void 0!==c){for(var u=new a,h=new a,l=0,d=c.length;l<d;l++){var f,p=c[l];if(void 0!==p.POSITION)i=(f=r.json.accessors[p.POSITION]).min,o=f.max,void 0!==i&&void 0!==o?(h.setX(Math.max(Math.abs(i[0]),Math.abs(o[0]))),h.setY(Math.max(Math.abs(i[1]),Math.abs(o[1]))),h.setZ(Math.max(Math.abs(i[2]),Math.abs(o[2]))),u.max(h)):console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}n.expandByVector(u)}e.boundingBox=n;var m=new de;n.getCenter(m.center),m.radius=n.min.distanceTo(n.max)/2,e.boundingSphere=m}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}(e,t,r),Promise.all(n).then((function(){return void 0!==t.targets?function(e,t,r){for(var s=!1,n=!1,i=0,o=t.length;i<o&&(void 0!==(u=t[i]).POSITION&&(s=!0),void 0!==u.NORMAL&&(n=!0),!s||!n);i++);if(!s&&!n)return Promise.resolve(e);var a=[],c=[];for(i=0,o=t.length;i<o;i++){var u=t[i];if(s){var h=void 0!==u.POSITION?r.getDependency("accessor",u.POSITION):e.attributes.position;a.push(h)}n&&(h=void 0!==u.NORMAL?r.getDependency("accessor",u.NORMAL):e.attributes.normal,c.push(h))}return Promise.all([Promise.all(a),Promise.all(c)]).then((function(t){var r=t[0],i=t[1];return s&&(e.morphAttributes.position=r),n&&(e.morphAttributes.normal=i),e.morphTargetsRelative=!0,e}))}(e,t.targets,r):e}))}function Yu(e,t){var r=e.getIndex();if(null===r){var s=[],n=e.getAttribute("position");if(void 0===n)return console.error("THREE.GLTFLoader.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),e;for(var i=0;i<n.count;i++)s.push(i);e.setIndex(s),r=e.getIndex()}var o=r.count-2,a=[];if(t===oe)for(i=1;i<=o;i++)a.push(r.getX(0)),a.push(r.getX(i)),a.push(r.getX(i+1));else for(i=0;i<o;i++)i%2==0?(a.push(r.getX(i)),a.push(r.getX(i+1)),a.push(r.getX(i+2))):(a.push(r.getX(i+2)),a.push(r.getX(i+1)),a.push(r.getX(i)));a.length/3!==o&&console.error("THREE.GLTFLoader.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");var c=e.clone();return c.setIndex(a),c}Qu.prototype.setExtensions=function(e){this.extensions=e},Qu.prototype.setPlugins=function(e){this.plugins=e},Qu.prototype.parse=function(e,t){var r=this,s=this.json,n=this.extensions;this.cache.removeAll(),this._invokeAll((function(e){return e._markDefs&&e._markDefs()})),Promise.all([this.getDependencies("scene"),this.getDependencies("animation"),this.getDependencies("camera")]).then((function(t){var i={scene:t[0][s.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:s.asset,parser:r,userData:{}};Hu(n,i,s),$u(i,s),e(i)})).catch(t)},Qu.prototype._markDefs=function(){for(var e=this.json.nodes||[],t=this.json.skins||[],r=this.json.meshes||[],s=0,n=t.length;s<n;s++)for(var i=t[s].joints,o=0,a=i.length;o<a;o++)e[i[o]].isBone=!0;for(var c=0,u=e.length;c<u;c++){var h=e[c];void 0!==h.mesh&&(this._addNodeRef(this.meshCache,h.mesh),void 0!==h.skin&&(r[h.mesh].isSkinnedMesh=!0)),void 0!==h.camera&&this._addNodeRef(this.cameraCache,h.camera)}},Qu.prototype._addNodeRef=function(e,t){void 0!==t&&(void 0===e.refs[t]&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)},Qu.prototype._getNodeRef=function(e,t,r){if(e.refs[t]<=1)return r;var s=r.clone();return s.name+="_instance_"+e.uses[t]++,s},Qu.prototype._invokeOne=function(e){var t=Object.values(this.plugins);t.push(this);for(var r=0;r<t.length;r++){var s=e(t[r]);if(s)return s}},Qu.prototype._invokeAll=function(e){var t=Object.values(this.plugins);t.unshift(this);for(var r=[],s=0;s<t.length;s++){var n=e(t[s]);n&&r.push(n)}return r},Qu.prototype.getDependency=function(e,t){var r=e+":"+t,s="number"==typeof t?this.cache.get(r):null;if(!s){switch(e){case"scene":s=this.loadScene(t);break;case"node":s=this.loadNode(t);break;case"mesh":s=this._invokeOne((function(e){return e.loadMesh&&e.loadMesh(t)}));break;case"accessor":s=this.loadAccessor(t);break;case"bufferView":s=this._invokeOne((function(e){return e.loadBufferView&&e.loadBufferView(t)}));break;case"buffer":s=this.loadBuffer(t);break;case"material":s=this._invokeOne((function(e){return e.loadMaterial&&e.loadMaterial(t)}));break;case"texture":s=this._invokeOne((function(e){return e.loadTexture&&e.loadTexture(t)}));break;case"skin":s=this.loadSkin(t);break;case"animation":s=this.loadAnimation(t);break;case"camera":s=this.loadCamera(t);break;default:throw new Error("Unknown type: "+e)}this.cache.add(r,s)}return s},Qu.prototype.getDependencies=function(e){var t=this.cache.get(e);if(!t){var r=this,s=this.json[e+("mesh"===e?"es":"s")]||[];t=Promise.all(s.map((function(t,s){return r.getDependency(e,s)}))),this.cache.add(e,t)}return t},Qu.prototype.loadBuffer=function(e){var t=this.json.buffers[e]||e,r=this.fileLoader;if(t.type&&"arraybuffer"!==t.type)throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(void 0===t.uri&&0===e&&this.extensions[au.KHR_BINARY_GLTF])return Promise.resolve(this.extensions[au.KHR_BINARY_GLTF].body);var s=this.options;return new Promise((function(e,n){r.load(zu(t.uri,s.path),e,void 0,(function(){n(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))}))}))},Qu.prototype.loadBufferView=function(e){var t=this.json.bufferViews[e]||e;return t.data?Promise.resolve(t.data):this.getDependency("buffer",t.buffer).then((function(e){var r=t.byteLength||0,s=t.byteOffset||0;return e.slice(s,s+r)}))},Qu.prototype.loadAccessor=function(e){var t=this,r=this.json,s=this.json.accessors[e]||e;if((void 0===s.bufferView||null===s.bufferView)&&void 0===s.sparse&&!s.value)return Promise.resolve(null);var n=[];return void 0===s.bufferView||s.value?n.push(null):n.push(this.getDependency("bufferView",s.bufferView)),void 0!==s.sparse&&(n.push(this.getDependency("bufferView",s.sparse.indices.bufferView)),n.push(this.getDependency("bufferView",s.sparse.values.bufferView))),Promise.all(n).then((function(e){var n,i,o=e[0],a=ku[s.type],c=Cu[s.componentType],u=c.BYTES_PER_ELEMENT,h=u*a,l=s.byteOffset||0,d=void 0===s.bufferView||s.value?void 0:r.bufferViews[s.bufferView].byteStride,f=!0===s.normalized;if(d&&d!==h){var p=Math.floor(l/d),m="InterleavedBuffer:"+s.bufferView+":"+s.componentType+":"+p+":"+s.count,g=t.cache.get(m);g||(n=new c(o,p*d,s.count*d/u),g=new I(n,d/u),t.cache.add(m,g)),i=new N(g,a,l%d/u,f)}else n=s.value?s.value:null===o?new c(s.count*a):new c(o,l,s.count*a),i=new L(n,a,f);if(void 0!==s.sparse){var y=ku.SCALAR,w=Cu[s.sparse.indices.componentType],b=s.sparse.indices.byteOffset||0,T=s.sparse.values.byteOffset||0,v=new w(e[1],b,s.sparse.count*y),_=new c(e[2],T,s.sparse.count*a);null!==o&&(i=new L(i.array.slice(),i.itemSize,i.normalized));for(var E=0,x=v.length;E<x;E++){var S=v[E];if(i.setX(S,_[E*a]),a>=2&&i.setY(S,_[E*a+1]),a>=3&&i.setZ(S,_[E*a+2]),a>=4&&i.setW(S,_[E*a+3]),a>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return i}))},Qu.prototype.loadTexture=function(e){var t,r,s=this.json,n=this.options,i=s.textures[e]||e,o=i.extensions||{};return(t=o[au.MSFT_TEXTURE_DDS]?s.images[o[au.MSFT_TEXTURE_DDS].source]:s.images[i.source]||i.source).uri&&(r=n.manager.getHandler(t.uri)),r||(r=o[au.MSFT_TEXTURE_DDS]?this.extensions[au.MSFT_TEXTURE_DDS].ddsLoader:this.textureLoader),this.loadTextureImage(e,t,r)},Qu.prototype.loadTextureImage=function(s,n,i){var o,a=this,c=this.json,u=this.options,h=c.textures[s]||s,l=self.URL||self.webkitURL,d=n.uri,f=!1,p=!0;return"image/jpeg"===n.mimeType&&(p=!1),void 0!==n.bufferView&&(d=a.getDependency("bufferView",n.bufferView).then((function(e){if("image/png"===n.mimeType){var t=new DataView(e,25,1).getUint8(0,!1);p=6===t||4===t||3===t}return new Blob([e],{type:n.mimeType})}))),o=i.isImageBitmapLoader?Promise.resolve(d).then((function(e){return createImageBitmap(e,{premultiplyAlpha:"none"})})).then((function(t){return new e(t)})):Promise.resolve(d).then((function(e){return f=!0,d=l.createObjectURL(e)})).then((function(e){return new Promise((function(t,r){var s=t;i.load(zu(e,u.path),s,void 0,r)}))})),Promise.resolve(o).then((function(e){!0===f&&l.revokeObjectURL(d),e.flipY=!1,h.name&&(e.name=h.name),p||(e.format=C);var n=(c.samplers||{})[h.sampler]||{};return e.magFilter=Pu[n.magFilter]||t,e.minFilter=Pu[n.minFilter]||P,e.wrapS=Uu[n.wrapS]||r,e.wrapT=Uu[n.wrapT]||r,a.associations.set(e,{type:"textures",index:s}),e}))},Qu.prototype.assignTexture=function(e,t,r){var s=this;return this.getDependency("texture",r.index).then((function(n){if(void 0===r.texCoord||0==r.texCoord||"aoMap"===t&&1==r.texCoord||console.warn("THREE.GLTFLoader: Custom UV set "+r.texCoord+" for texture "+t+" not yet supported."),s.extensions[au.KHR_TEXTURE_TRANSFORM]){var i=void 0!==r.extensions?r.extensions[au.KHR_TEXTURE_TRANSFORM]:void 0;if(i){var o=s.associations.get(n);n=s.extensions[au.KHR_TEXTURE_TRANSFORM].extendTexture(n,i),s.associations.set(n,o)}}e[t]=n}))},Qu.prototype.assignFinalMaterial=function(e){var t=e.geometry,r=e.material,s=void 0!==t.attributes.tangent,n=void 0!==t.attributes.color,i=void 0===t.attributes.normal,o=!0===e.isSkinnedMesh,a=Object.keys(t.morphAttributes).length>0,c=a&&void 0!==t.morphAttributes.normal;if(e.isPoints){var u="PointsMaterial:"+r.uuid,h=this.cache.get(u);h||(h=new U,k.prototype.copy.call(h,r),h.color.copy(r.color),h.map=r.map,h.sizeAttenuation=!1,this.cache.add(u,h)),r=h}else if(e.isLine){u="LineBasicMaterial:"+r.uuid;var l=this.cache.get(u);l||(l=new g,k.prototype.copy.call(l,r),l.color.copy(r.color),this.cache.add(u,l)),r=l}if(s||n||i||o||a){u="ClonedMaterial:"+r.uuid+":";r.isGLTFSpecularGlossinessMaterial&&(u+="specular-glossiness:"),o&&(u+="skinning:"),s&&(u+="vertex-tangents:"),n&&(u+="vertex-colors:"),i&&(u+="flat-shading:"),a&&(u+="morph-targets:"),c&&(u+="morph-normals:");var d=this.cache.get(u);d||(d=r.clone(),o&&(d.skinning=!0),s&&(d.vertexTangents=!0),n&&(d.vertexColors=!0),i&&(d.flatShading=!0),a&&(d.morphTargets=!0),c&&(d.morphNormals=!0),this.cache.add(u,d),this.associations.set(d,this.associations.get(r))),r=d}r.aoMap&&void 0===t.attributes.uv2&&void 0!==t.attributes.uv&&t.setAttribute("uv2",t.attributes.uv),r.normalScale&&!s&&(r.normalScale.y=-r.normalScale.y),r.clearcoatNormalScale&&!s&&(r.clearcoatNormalScale.y=-r.clearcoatNormalScale.y),e.material=r},Qu.prototype.getMaterialType=function(){return y},Qu.prototype.loadMaterial=function(e){var t,r=this,s=this.json,n=this.extensions,i=s.materials[e]||e,o={},a=i.extensions||{},h=[];if(a[au.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS]){var l=n[au.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS];t=l.getMaterialType(),h.push(l.extendParams(o,i,r))}else if(a[au.KHR_MATERIALS_UNLIT]){var f=n[au.KHR_MATERIALS_UNLIT];t=f.getMaterialType(),h.push(f.extendParams(o,i,r))}else{var p=i.pbrMetallicRoughness||{};if(o.color=new d(1,1,1),o.opacity=1,Array.isArray(p.baseColorFactor)){var m=p.baseColorFactor;o.color.fromArray(m),o.opacity=m[3]}void 0!==p.baseColorTexture&&h.push(r.assignTexture(o,"map",p.baseColorTexture)),o.metalness=void 0!==p.metallicFactor?p.metallicFactor:1,o.roughness=void 0!==p.roughnessFactor?p.roughnessFactor:1,void 0!==p.metallicRoughnessTexture&&(h.push(r.assignTexture(o,"metalnessMap",p.metallicRoughnessTexture)),h.push(r.assignTexture(o,"roughnessMap",p.metallicRoughnessTexture))),t=this._invokeOne((function(t){return t.getMaterialType&&t.getMaterialType(e)})),h.push(Promise.all(this._invokeAll((function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,o)}))))}!0===i.doubleSided&&(o.side=u);var g=i.alphaMode||Fu;return g===qu?(o.transparent=!0,o.depthWrite=!1):(o.transparent=!1,g===Vu&&(o.alphaTest=void 0!==i.alphaCutoff?i.alphaCutoff:.5)),void 0!==i.normalTexture&&t!==c&&(h.push(r.assignTexture(o,"normalMap",i.normalTexture)),o.normalScale=new A(1,1),void 0!==i.normalTexture.scale&&o.normalScale.set(i.normalTexture.scale,i.normalTexture.scale)),void 0!==i.occlusionTexture&&t!==c&&(h.push(r.assignTexture(o,"aoMap",i.occlusionTexture)),void 0!==i.occlusionTexture.strength&&(o.aoMapIntensity=i.occlusionTexture.strength)),void 0!==i.emissiveFactor&&t!==c&&(o.emissive=(new d).fromArray(i.emissiveFactor)),void 0!==i.emissiveTexture&&t!==c&&h.push(r.assignTexture(o,"emissiveMap",i.emissiveTexture)),Promise.all(h).then((function(){var s;return s=t===_u?n[au.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS].createMaterial(o):new t(o),i.name&&(s.name=i.name),s.map&&(s.map.encoding=D),s.emissiveMap&&(s.emissiveMap.encoding=D),$u(s,i),r.associations.set(s,{type:"materials",index:e}),i.extensions&&Hu(n,s,i),s}))},Qu.prototype.createUniqueName=function(e){for(var t=j.sanitizeNodeName(e||""),r=1;this.nodeNamesUsed[t];++r)t=e+"_"+r;return this.nodeNamesUsed[t]=!0,t},Qu.prototype.loadGeometries=function(e){var t=this,r=this.extensions,s=this.primitiveCache;function n(e){return r[au.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then((function(r){return Xu(r,e,t)}))}for(var i,o,a=[],c=0,u=e.length;c<u;c++){var h,l=e[c],d=null,f=null;if("number"==typeof l.indices&&(o=void 0,f=s[d=(o=(i=l).extensions&&i.extensions[au.KHR_DRACO_MESH_COMPRESSION])?"draco:"+o.bufferView+":"+o.indices+":"+Ku(o.attributes):i.indices+":"+Ku(i.attributes)+":"+i.mode]),f)a.push(f.promise);else h=l.extensions&&l.extensions[au.KHR_DRACO_MESH_COMPRESSION]&&"number"==typeof l.indices?n(l):Xu(new B,l,t),d&&(s[d]={primitive:l,promise:h}),a.push(h)}return Promise.all(a)},Qu.prototype.loadMesh=function(e){for(var t=this,r=this.json.meshes[e]||e,s=r.primitives,n=[],o=0,a=s.length;o<a;o++){var c=void 0===s[o].material?Gu(this.cache):this.getDependency("material",s[o].material);n.push(c)}return n.push(t.loadGeometries(s)),Promise.all(n).then((function(n){for(var o=n.slice(0,n.length-1),a=n[n.length-1],c=[],u=0,l=a.length;u<l;u++){var d,f=a[u],p=s[u],g=o[u];if(p.mode===Iu||p.mode===Nu||p.mode===Lu||void 0===p.mode)!0!==(d=!0===r.isSkinnedMesh?new F(f,g):new h(f,g)).isSkinnedMesh||d.geometry.attributes.skinWeight.normalized||d.normalizeSkinWeights(),p.mode===Nu?d.geometry=Yu(d.geometry,ae):p.mode===Lu&&(d.geometry=Yu(d.geometry,oe));else if(p.mode===Mu)d=new m(f,g);else if(p.mode===Ou)d=new V(f,g);else if(p.mode===Ru)d=new q(f,g);else{if(p.mode!==Au)throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+p.mode);d=new z(f,g)}Object.keys(d.geometry.morphAttributes).length>0&&Wu(d,r),d.name=t.createUniqueName(r.name||"mesh_"+e),$u(d,r),t.assignFinalMaterial(d),c.push(d)}if(1===c.length)return c[0];var y=new i;for(u=0,l=c.length;u<l;u++)y.add(c[u]);return y}))},Qu.prototype.loadCamera=function(e){var t,r=this.json.cameras[e],s=r[r.type];if(s)return"perspective"===r.type?t=new G(H.radToDeg(s.yfov),s.aspectRatio||1,s.znear||1,s.zfar||2e6):"orthographic"===r.type&&(t=new $(-s.xmag,s.xmag,s.ymag,-s.ymag,s.znear,s.zfar)),r.name&&(t.name=this.createUniqueName(r.name)),$u(t,r),Promise.resolve(t);console.warn("THREE.GLTFLoader: Missing camera parameters.")},Qu.prototype.loadSkin=function(e){var t=this.json.skins[e],r={joints:t.joints};return void 0===t.inverseBindMatrices?Promise.resolve(r):this.getDependency("accessor",t.inverseBindMatrices).then((function(e){return r.inverseBindMatrices=e,r}))},Qu.prototype.loadAnimation=function(e){for(var t=this.json.animations[e],r=[],s=[],n=[],i=[],o=[],a=0,c=t.channels.length;a<c;a++){var u=t.channels[a],h=t.samplers[u.sampler],l=u.target,d=void 0!==l.node?l.node:l.id,f=void 0!==t.parameters?t.parameters[h.input]:h.input,p=void 0!==t.parameters?t.parameters[h.output]:h.output;r.push(this.getDependency("node",d)),s.push(this.getDependency("accessor",f)),n.push(this.getDependency("accessor",p)),i.push(h),o.push(l)}return Promise.all([Promise.all(r),Promise.all(s),Promise.all(n),Promise.all(i),Promise.all(o)]).then((function(r){for(var s=r[0],n=r[1],i=r[2],o=r[3],a=r[4],c=[],u=0,h=s.length;u<h;u++){var l=s[u],d=n[u],f=i[u],p=o[u],m=a[u];if(void 0!==l){var g;switch(l.updateMatrix(),l.matrixAutoUpdate=!0,ju[m.path]){case ju.weights:g=he;break;case ju.rotation:g=ue;break;case ju.position:case ju.scale:default:g=ce}var y=l.name?l.name:l.uuid,w=void 0!==p.interpolation?Bu[p.interpolation]:W,b=[];ju[m.path]===ju.weights?l.traverse((function(e){!0===e.isMesh&&e.morphTargetInfluences&&b.push(e.name?e.name:e.uuid)})):b.push(y);var T=f.array;if(f.normalized){var v;if(T.constructor===Int8Array)v=1/127;else if(T.constructor===Uint8Array)v=1/255;else if(T.constructor==Int16Array)v=1/32767;else{if(T.constructor!==Uint16Array)throw new Error("THREE.GLTFLoader: Unsupported output accessor component type.");v=1/65535}for(var _=new Float32Array(T.length),E=0,x=T.length;E<x;E++)_[E]=T[E]*v;T=_}for(E=0,x=b.length;E<x;E++){var S=new g(b[E]+"."+ju[m.path],d.array,T,w);"CUBICSPLINE"===p.interpolation&&(S.createInterpolant=function(e){return new Su(this.times,this.values,this.getValueSize()/3,e)},S.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0),c.push(S)}}}var A=t.name?t.name:"animation_"+e;return new K(A,void 0,c)}))},Qu.prototype.loadNode=function(e){var t,r=this.json,s=this.extensions,o=this,a=r.nodes[e]||e,c=a.name?o.createUniqueName(a.name):"";return(t=[],void 0!==a.mesh&&t.push(o.getDependency("mesh",a.mesh).then((function(e){var t=o._getNodeRef(o.meshCache,a.mesh,e);return void 0!==a.weights&&t.traverse((function(e){if(e.isMesh)for(var t=0,r=a.weights.length;t<r;t++)e.morphTargetInfluences[t]=a.weights[t]})),t}))),void 0!==a.camera&&t.push(o.getDependency("camera",a.camera).then((function(e){return o._getNodeRef(o.cameraCache,a.camera,e)}))),o._invokeAll((function(t){return t.createNodeAttachment&&t.createNodeAttachment(e)})).forEach((function(e){t.push(e)})),Promise.all(t)).then((function(t){var r;if((r=!0===a.isBone?new Q:t.length>1?new i:1===t.length?t[0]:new X)!==t[0])for(var u=0,h=t.length;u<h;u++)r.add(t[u]);if(a.name&&(r.userData.name=a.name,r.name=c),$u(r,a),a.extensions&&Hu(s,r,a),void 0!==a.matrix){var l=new n;l.fromArray(a.matrix),r.applyMatrix4(l)}else void 0!==a.translation&&r.position.fromArray(a.translation),void 0!==a.rotation&&r.quaternion.fromArray(a.rotation),void 0!==a.scale&&r.scale.fromArray(a.scale);return o.associations.set(r,{type:"nodes",index:e}),r}))},Qu.prototype.loadScene=function(){function e(t,r,s,i){var o=s.nodes[t]||t;return i.getDependency("node",t).then((function(e){return void 0===o.skin?e:i.getDependency("skin",o.skin).then((function(e){for(var r=[],s=0,n=(t=e).joints.length;s<n;s++)r.push(i.getDependency("node",t.joints[s]));return Promise.all(r)})).then((function(r){return e.traverse((function(e){if(e.isMesh){for(var s=[],i=[],o=0,a=r.length;o<a;o++){var c=r[o];if(c){s.push(c);var u=new n;void 0!==t.inverseBindMatrices&&u.fromArray(t.inverseBindMatrices.array,16*o),i.push(u)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[o])}e.bind(new Y(s,i),e.matrixWorld)}})),e}));var t})).then((function(t){r.add(t);var n=[];if(o.children)for(var a=o.children,c=0,u=a.length;c<u;c++){var h=a[c];n.push(e(h,t,s,i))}return Promise.all(n)}))}return function(t){var r=this.json,s=this.extensions,n=this.json.scenes[t],o=new i;n.name&&(o.name=this.createUniqueName(n.name)),$u(o,n),n.extensions&&Hu(s,o,n);for(var a=n.nodes||[],c=[],u=0,h=a.length;u<h;u++)c.push(e(a[u],o,r,this));return Promise.all(c).then((function(){return o}))}}();const Zu={SPECTRAL:[[0,new d(.3686,.3098,.6353)],[.1,new d(.1961,.5333,.7412)],[.2,new d(.4,.7608,.6471)],[.3,new d(.6706,.8667,.6431)],[.4,new d(.902,.9608,.5961)],[.5,new d(1,1,.749)],[.6,new d(.9961,.8784,.5451)],[.7,new d(.9922,.6824,.3804)],[.8,new d(.9569,.4275,.2627)],[.9,new d(.8353,.2431,.3098)],[1,new d(.6196,.0039,.2588)]],PLASMA:[[0,new d(.241,.015,.61)],[.1,new d(.387,.001,.654)],[.2,new d(.524,.025,.653)],[.3,new d(.651,.125,.596)],[.4,new d(.752,.227,.513)],[.5,new d(.837,.329,.431)],[.6,new d(.907,.435,.353)],[.7,new d(.963,.554,.272)],[.8,new d(.992,.681,.195)],[.9,new d(.987,.822,.144)],[1,new d(.94,.975,.131)]],YELLOW_GREEN:[[0,new d(.1647,.2824,.3451)],[.1,new d(.1338,.3555,.4227)],[.2,new d(.061,.4319,.4864)],[.3,new d(0,.5099,.5319)],[.4,new d(0,.5881,.5569)],[.5,new d(.137,.665,.5614)],[.6,new d(.2906,.7395,.5477)],[.7,new d(.4453,.8099,.5201)],[.8,new d(.6102,.8748,.485)],[.9,new d(.7883,.9323,.4514)],[1,new d(.9804,.9804,.4314)]],VIRIDIS:[[0,new d(.267,.005,.329)],[.1,new d(.283,.141,.458)],[.2,new d(.254,.265,.53)],[.3,new d(.207,.372,.553)],[.4,new d(.164,.471,.558)],[.5,new d(.128,.567,.551)],[.6,new d(.135,.659,.518)],[.7,new d(.267,.749,.441)],[.8,new d(.478,.821,.318)],[.9,new d(.741,.873,.15)],[1,new d(.993,.906,.144)]],INFERNO:[[0,new d(.077,.042,.206)],[.1,new d(.225,.036,.388)],[.2,new d(.373,.074,.432)],[.3,new d(.522,.128,.42)],[.4,new d(.665,.182,.37)],[.5,new d(.797,.255,.287)],[.6,new d(.902,.364,.184)],[.7,new d(.969,.516,.063)],[.8,new d(.988,.683,.072)],[.9,new d(.961,.859,.298)],[1,new d(.988,.998,.645)]],GRAYSCALE:[[0,new d(0,0,0)],[1,new d(1,1,1)]],TURBO:[[0,new d(.18995,.07176,.23217)],[.07,new d(.25107,.25237,.63374)],[.13,new d(.27628,.42118,.89123)],[.2,new d(.25862,.57958,.99876)],[.27,new d(.15844,.73551,.92305)],[.33,new d(.09267,.86554,.7623)],[.4,new d(.19659,.94901,.59466)],[.47,new d(.42778,.99419,.38575)],[.53,new d(.64362,.98999,.23356)],[.6,new d(.80473,.92452,.20459)],[.67,new d(.93301,.81236,.22667)],[.73,new d(.99314,.67408,.20348)],[.8,new d(.9836,.49291,.12849)],[.87,new d(.92105,.31489,.05475)],[.93,new d(.81608,.18462,.01809)],[1,new d(.66449,.08436,.00424)]],RAINBOW:[[0,new d(.278,0,.714)],[1/6,new d(0,0,1)],[2/6,new d(0,1,1)],[.5,new d(0,1,0)],[4/6,new d(1,1,0)],[5/6,new d(1,.64,0)],[1,new d(1,0,0)]],CONTOUR:[[0,new d(0,0,0)],[.03,new d(0,0,0)],[.04,new d(1,1,1)],[1,new d(1,1,1)]]},Ju="\n  varying vec3 vColor;\n  void main() {\n    if (vColor == vec3(0.0, 0.0, 0.0)) {\n      discard;\n    } else {\n      gl_FragColor = vec4( vColor, 1.0 );\n    }\n  }\n",eh="\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\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 = 1.0;\n      gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n  }\n";var th,rh;!function(e){e[e.Intensity=1]="Intensity",e[e.Classification=2]="Classification",e[e.Elevation=3]="Elevation",e[e.RGB=4]="RGB",e[e.White=5]="White"}(th||(th={})),function(e){e[e.FlatTexture=1]="FlatTexture",e[e.ShadedTexture=2]="ShadedTexture",e[e.ShadedNoTexture=3]="ShadedNoTexture"}(rh||(rh={}));const sh="undefined"!=typeof document?ru(Zu.RAINBOW):null,nh="undefined"!=typeof document?ru(Zu.GRAYSCALE):null,ih={initialTransform:new n,throttleRequests:!0,maxRequests:64,updateInterval:.1,maxConcurrency:1,maximumScreenSpaceError:16,maximumMemoryUsage:32,viewDistanceScale:1,skipLevelOfDetail:!1,updateTransforms:!0,shading:rh.FlatTexture,pointCloudColoring:th.White,worker:!0,wireframe:!1,debug:!1,basisTranscoderPath:null,dracoDecoderPath:null,material:null,computeNormals:!1,shaderCallback:null,loadersGlGltf:!0};class oh{static load(e){return be(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},ih),e.options),{url:r}=e,s=t.updateInterval,d={};if(t.cesiumIONToken){d["cesium-ion"]={accessToken:t.cesiumIONToken};const e=yield tu.preload(r,d);d.fetch={headers:e.headers}}const f=yield wr(r,Zc,Object.assign({},d)),p={},m={},g=[],y=new i,w=new i;t.debug||(w.visible=!1);let b=new n;const T=f.root.transform?(new n).fromArray(f.root.transform):new n;if(1==f.root.children.length&&f.root.children[0].transform){const e=(new n).fromArray(f.root.children[0].transform);T.multiply(e)}b.copy(T).invert();const v=b.clone();b.premultiply(t.initialTransform);let _=new Ls(b.toArray());const E={pointSize:{type:"f",value:1},gradient:{type:"t",value:sh},grayscale:{type:"t",value:nh},rootCenter:{type:"vec3",value:new a},rootNormal:{type:"vec3",value:new a},coloring:{type:"i",value:t.pointCloudColoring},hideGround:{type:"b",value:!0},elevationRange:{type:"vec2",value:new A(0,400)},maxIntensity:{type:"f",value:1},intensityContrast:{type:"f",value:1}};let x=null,S=null;const M=t.loadersGlGltf?new iu:new ge;if(t.basisTranscoderPath){const r=new we;r.detectSupport(e.renderer),r.setTranscoderPath(t.basisTranscoderPath+"/"),r.setWorkerLimit(1),M.setKTX2Loader(r)}if(!t.loadersGlGltf&&t.dracoDecoderPath){const e=new ye;e.setDecoderPath(t.dracoDecoderPath+"/"),e.setWorkerLimit(t.maxConcurrency),M.setDRACOLoader(e)}const R=new fe({uniforms:{},vertexShader:"\n  varying vec2 vUv;\n  void main() {\n      vUv = uv;\n      gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n  }\n",fragmentShader:"\n  uniform sampler2D map;\n  varying vec2 vUv;\n\n  void main() {\n    vec4 realColor = texture2D(map, vUv);\n    gl_FragColor = realColor;\n  }\n"}),O={modelMatrix:_,maximumMemoryUsage:t.maximumMemoryUsage,maximumScreenSpaceError:t.maximumScreenSpaceError,viewDistanceScale:t.viewDistanceScale,skipLevelOfDetail:t.skipLevelOfDetail,updateTransforms:t.updateTransforms,throttleRequests:t.throttleRequests,maxRequests:t.maxRequests,contentLoader:e=>be(this,void 0,void 0,(function*(){let r=null;switch(e.type){case Zi:r=function(e,t){const r={rtc_center:e.content.rtcCenter,points:e.content.attributes.positions,intensities:e.content.attributes.intensity,classifications:e.content.attributes.classification,rgb:null,rgba:null},{colors:s}=e.content.attributes;s&&3===s.size&&(r.rgb=s.value);s&&4===s.size&&(r.rgba=s.value);const i=new B;i.setAttribute("position",new pe(r.points,3));const o=new fe({uniforms:t,vertexShader:eh,fragmentShader:Ju,transparent:!0});r.rgba?(i.setAttribute("color",new pe(r.rgba,4)),o.vertexColors=!0):r.rgb&&(i.setAttribute("color",new me(r.rgb,3,!0)),o.vertexColors=!0);r.intensities&&i.setAttribute("intensity",new me(r.intensities,1,!0));r.classifications&&i.setAttribute("classification",new me(r.classifications,1,!1));const a=new z(i,o);if(r.rtc_center){const e=r.rtc_center;a.applyMatrix4((new n).makeTranslation(e[0],e[1],e[2]))}return a}(e,E);break;case Yi:case Ji:r=yield function(e,t,r,s){return be(this,void 0,void 0,(function*(){return new Promise(((i,o)=>{const c=(new n).makeRotationAxis(new a(1,0,0),Math.PI/2);e.parse(s.loadersGlGltf?t.content.gltf:t.content.gltfArrayBuffer,"",(e=>{const t=e.scenes[0].children[0];t.applyMatrix4(c),t.traverse((e=>{if(e instanceof h){const t=e.material,n=t.map;s.material?(e.material=s.material.clone(),t.dispose()):s.shading==rh.FlatTexture&&(e.material=r.clone(),t.dispose()),s.shading!=rh.ShadedNoTexture?e.material.uniforms?e.material.uniforms.map={value:n}:e.material.map=n:(n.dispose(),e.material.map=null),s.shaderCallback&&(e.onBeforeRender=s.shaderCallback),e.material.wireframe=s.wireframe,s.computeNormals&&e.geometry.computeVertexNormals()}})),i(t)}),(e=>{o(new Error(`error parsing gltf in tile ${t.id}: ${e}`))}))}))}))}(M,e,R,t)}if(r&&(r.visible=!1,p[e.id]=r,y.add(p[e.id]),t.debug)){const t=nu(e);w.add(t),m[e.id]=t}})),onTileLoad:()=>be(this,void 0,void 0,(function*(){I&&(I._frameNumber++,F(I,p,S,x))})),onTileUnload:e=>{g.push(e)},onTileError:(e,t)=>{console.error("Tile error",e.id,t)}},I=new Ro(f,Object.assign(Object.assign({},O),{loadOptions:Object.assign(Object.assign({},d),{maxConcurrency:t.maxConcurrency,worker:t.worker,gltf:{loadImages:!1},"3d-tiles":{loadGLTF:t.loadersGlGltf}})}));let N=!1;const L=(new a).setFromMatrixPosition(t.initialTransform);E.rootCenter.value.copy(L),E.rootNormal.value.copy(new a(0,0,1).applyMatrix4(t.initialTransform).normalize()),y.applyMatrix4(t.initialTransform),I.stats.get("Loader concurrency").count=t.maxConcurrency,I.stats.get("Maximum SSE").count=t.maximumScreenSpaceError,I.stats.get("Maximum mem usage").count=t.maximumMemoryUsage;let C=0;const P=(new n).makeTranslation(1/0,1/0,1/0);let U=null;const k=new a(1/0,1/0,1/0);let D=null;const j=(new n).copy(y.matrixWorld);function F(r,s,n,i){if(N)return;if(!D||i.aspect!=U){const e=new Ui({fov:i.fov/180*Math.PI,aspectRatio:i.aspect,near:i.near,far:i.far});D=e.sseDenominator,U=i.aspect,t.debug&&console.log("Updated sse denonimator:",D)}const o=su(i).planes.map((e=>new Ei(e.normal.toArray(),e.constant))),a=new Mi(o),c=new A;n.getSize(c);const u={camera:{position:k.toArray()},height:c.y,frameNumber:r._frameNumber,sseDenominator:D,cullingVolume:a,viewport:{id:0}};r._cache.reset(),r._traverser.traverse(r.root,u,r.options);for(const e of r.tiles)e.selected?s[e.id]?s[e.id].visible=!0:console.error("TILE SELECTED BUT NOT LOADED!!",e.id):s[e.id]&&(s[e.id].visible=!1);for(;g.length>0;){const e=g.pop();s[e.id]&&e.contentState==zi&&(y.remove(s[e.id]),ah(s[e.id]),delete s[e.id]),m[e.id]&&(ah(m[e.id]),w.remove(m[e.id]),delete m[e.id])}return e.onProgress&&e.onProgress(r.stats.get("Tiles Loaded").count,r.stats.get("Tiles Loaded").count+r.stats.get("Tiles Loading").count),u}return{model:y,runtime:{getTileset:()=>I,getStats:()=>I.stats,showTiles:e=>{w.visible=e},setWireframe:e=>{t.wireframe=e,y.traverse((t=>{t instanceof h&&(t.material.wireframe=e)}))},setDebug:e=>{t.debug=e,w.visible=e},setShading:e=>{t.shading=e},getTileBoxes:()=>w,setViewDistanceScale:e=>{I.options.viewDistanceScale=e,I._frameNumber++,F(I,p,S,x)},setHideGround:e=>{E.hideGround.value=e},setPointCloudColoring:e=>{E.coloring.value=e},setElevationRange:e=>{E.elevationRange.value.set(e[0],e[1])},setMaxIntensity:e=>{E.maxIntensity.value=e},setIntensityContrast:e=>{E.intensityContrast.value=e},getLatLongHeightFromPosition:e=>{const t=I.ellipsoid.cartesianToCartographic((new a).copy(e).applyMatrix4((new n).copy(b).invert()).toArray());return{lat:t[1],long:t[0],height:t[2]}},getPositionFromLatLongHeight:e=>{const t=I.ellipsoid.cartographicToCartesian([e.long,e.lat,e.height]);return new a(...t).applyMatrix4(b)},getCameraFrustum:e=>{const t=su(e).planes.map((e=>new Ei(e.normal.toArray(),e.constant))).map((e=>function(e){const t=new i,r=new o(10,5),s=new a(...e.projectPointOntoPlane([0,0,0])),n=new a(e.normal.x,e.normal.y,e.normal.z),d=(new a).copy(s).add(n);r.lookAt(d),r.translate(s.x,s.y,s.z);const f=new c({color:65535,side:u}),p=new h(r,f),m=new l(n,s,5,16776960);return t.add(m),t.add(p),t}(e))),r=new i;for(const e of t)r.add(e);return r},update:function(e,t,r){if(x=r,S=t,C+=e,I&&C>=s){j.equals(y.matrixWorld)||(j.copy(y.matrixWorld),b=v.clone(),b.premultiply(j),_=new Ls(b.toArray()),I.modelMatrix=_);!(r.matrixWorld.equals(P)&&r.aspect==U)&&(C=0,I._frameNumber++,r.getWorldPosition(k),P.copy(r.matrixWorld),F(I,p,t,r))}},dispose:function(){for(N=!0,I._destroy();y.children.length>0;){const e=y.children[0];ah(e),y.remove(e)}for(;w.children.length>0;){const e=w.children[0];w.remove(e),e.geometry.dispose(),e.material.dispose()}}}}}))}}function ah(e){e.traverse((e=>{var t,r;if(e.isMesh)if(e.geometry.dispose(),e.material.isMaterial)null===(t=e.material.uniforms.map.value)||void 0===t||t.dispose(),e.material.dispose();else for(const t of e.material)null===(r=t.uniforms.map.value)||void 0===r||r.dispose(),t.dispose()}));for(let t=e.children.length-1;t>=0;t--){const r=e.children[t];e.remove(r)}}export{oh as Loader3DTiles,th as PointCloudColoring,rh as Shading};
  //# sourceMappingURL=three-loader-3dtiles.esm.min.js.map
  